Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Macrolib/macro.ukmo_gfortran
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# module load netcdf-fortran/4.6.1-gcc-12.2.0-43finqs gcc/13.2.0-gcc-12.2.0-lx4jx7u

NCDF = -I${NETCDFF_ROOT}/include -L${NETCDFF_ROOT}/lib -lnetcdff

NC4 = -D key_netcdf4
#CMIP6 = -D key_CMIP6
CMIP6 =

F90=gfortran
#OMP=-fopenmp
OMP=
FFLAGS= -O $(NCDF) $(NC4) -Wl,-rpath=${NETCDFF_ROOT}/lib -fno-second-underscore -ffree-line-length-256 $(OMP)

#INSTALL=$(HOME)/local/bin
#INSTALL_MAN=$(HOME)/local/man
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# CDFTOOLS
CDFTOOLS is a diagnostic package written in fortran 90 for the analysis of NEMO model output, initialized in the frame of the DRAKKAR project (<https://www.drakkar-ocean.eu/>). It is now available on GitHub under the CeCILL license (<http://www.cecill.info/licences/Licence_CeCILL_V2-en.html>).

CDFTOOLS is an open source package and contributions from other group are welcomed. The Git workflow policy is still to be defined.

Actual version of CDFTOOLS is known as version 4. (See changes in paragraph *New features in version 4*, below).

# CDFTOOLS - JMMP development branch
This is the main development branch of the JMMP FORK of [CDFTOOLS](https://github.com/meom-group/CDFTOOLS), a diagnostic package written in fortran 90 for the analysis of NEMO model output, initialized in the frame of the DRAKKAR project (<https://www.drakkar-ocean.eu/>). The main repository of CDFTOOLS is available on GitHub (<https://github.com/meom-group/CDFTOOLS>) under the CeCILL license (<http://www.cecill.info/licences/Licence_CeCILL_V2-en.html>). The current supported version of CDFTOOLS is version 4.

## Using CDFTOOLS

#### Cloning the git repository
To retrieve a copy of the CDFTOOLS source code and create a working directory, run the following on the command line:
#### Cloning the git JMMP development branch
To retrieve a local copy of the CDFTOOLS `dev_jmmp` development branch run the following on the command line:

```> git clone https://github.com/meom-group/CDFTOOLS ```
```> git clone -b dev_jmmp --single-branch https://github.com/JMMP-Group/CDFTOOLS.git CDFTOOLS_jmmp```

#### Compiling CDFTOOLS
All the fortran source are in src/ subdirectory. In src/ there is a Makefile for compiling the sources. The compiler/machines related definitions are supposed to be collected in a `make.macro` file. Some examples of `make.macro` are given in the Macrolib directory and can be used as template for a new compiler or new machine. Then the good practice is to make a link
Expand Down
104 changes: 104 additions & 0 deletions nam_cdf_names
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
! ================================
! cdftools namelist
! ================================

!---------------------------------------
&namdim ! Dimension names
!---------------------------------------
cn_x = 'x' !: longitude
cn_y = 'y' !: latitude
cn_z = 'depth' !: depth
cn_t = 'time_counter' !: time
/

!---------------------------------------
&namdimvar ! Dimension variable names
!---------------------------------------
cn_vlon2d = 'nav_lon' !: longitude
cn_vlat2d = 'nav_lat' !: latitude

cn_vdeptht = 'deptht'
cn_vdepthu = 'depthu'
cn_vdepthv = 'depthv'
cn_vdepthw = 'depthw' !: depth

cn_vtimec = 'time_centered' !: time
/

!---------------------------------------
&nammetrics ! Mesh mask variable names
!---------------------------------------
cn_ve1t = 'e1t'
cn_ve1u = 'e1u'
cn_ve1v = 'e1v'
cn_ve1f = 'e1f' !: e1

cn_ve2t = 'e2t'
cn_ve2u = 'e2u'
cn_ve2v = 'e2v'
cn_ve2f = 'e2f' !: e2

cn_ve3t1d = 'e3t' !: e3 (1D)
cn_ve3w1d = 'e3w' !: e3 (1D)
cn_ve3t = 'e3t_0' !: e3 (3D)
cn_ve3u = 'e3u_0' !: e3 (3D)
cn_ve3v = 'e3v_0' !: e3 (3D)
cn_ve3w = 'e3w_0' !: e3 (3D)

cn_vff = 'ff_f' !: f^2

cn_glamt = 'glamt'
cn_glamu = 'glamu'
cn_glamv = 'glamv'
cn_glamf = 'glamf' !: longitude

cn_gphit = 'gphit'
cn_gphiu = 'gphiu'
cn_gphiv = 'gphiv'
cn_gphif = 'gphif' !: latitude

cn_gdept = 'gdept'
cn_gdepw = 'gdepw' !: 1d dep variable

cn_hdept = 'hdept'
cn_hdepw = 'hdepw' !: 2d dep variable
/

!---------------------------------------
&namvars ! Variable names
!---------------------------------------
cn_votemper = 'thetao_con' !: conservative temperature
cn_vosaline = 'so_abs' !: absolute salinity
cn_vozocrtx = 'uo' !: zonal velocity
cn_vomecrty = 'vo' !: meridional velocity
cn_sozotaux = 'tauuo' !: zonal wind stress
/

!---------------------------------------
&nambathy ! Bathymetry file and variable names
!---------------------------------------
cn_bathymet = 'bathy_metry'
/

!---------------------------------------
&namsqdvar ! Squared variable names
!---------------------------------------
/

!---------------------------------------
&namcubvar ! Cubed variable names
!---------------------------------------
/

!---------------------------------------
&nammeshmask ! Mesh mask file names
!---------------------------------------
cn_fzgr = 'mesh_mask.nc' !: vertical mesh file
cn_fhgr = 'mesh_mask.nc' !: horizontal mesh file
cn_fmsk = 'mesh_mask.nc' !: mesh mask file
/

!---------------------------------------
&nammeshmask_var ! Basin mask names
!---------------------------------------
/
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ cdfvtrp: cdfio.o cdfvtrp.f90
cdfpsi: cdfio.o modutils.o cdfpsi.f90
$(F90) cdfpsi.f90 -o $(BINDIR)/cdfpsi cdfio.o modcdfnames.o modutils.o $(FFLAGS)

cdftransport: cdfio.o modutils.o cdftransport.f90
$(F90) cdftransport.f90 -o $(BINDIR)/cdftransport cdfio.o modcdfnames.o modutils.o $(FFLAGS)
cdftransport: cdfio.o modutils.o cdftools.o cdftransport.f90
$(F90) cdftransport.f90 -o $(BINDIR)/cdftransport cdfio.o modcdfnames.o modutils.o cdftools.o $(FFLAGS)

cdfvFWov: cdfio.o modutils.o cdfvFWov.f90
$(F90) cdfvFWov.f90 -o $(BINDIR)/cdfvFWov cdfio.o modcdfnames.o modutils.o $(FFLAGS)
Expand Down
28 changes: 18 additions & 10 deletions src/cdfio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ FUNCTION FindVarName(cdfile,cdvar,ld_verbose)

END FUNCTION FindVarName

FUNCTION getvar (cdfile,cdvar,klev,kpi,kpj,kimin,kjmin, ktime, ldiom)
FUNCTION getvar (cdfile,cdvar,klev,kpi,kpj,kimin,kjmin, ktime, ldiom, ld_zeromask)
!!---------------------------------------------------------------------
!! *** FUNCTION getvar ***
!!
Expand All @@ -1443,6 +1443,7 @@ FUNCTION getvar (cdfile,cdvar,klev,kpi,kpj,kimin,kjmin, ktime, ldiom)
INTEGER(KIND=4), OPTIONAL, INTENT(in) :: kimin, kjmin ! Optional variable. If missing 1 is assumed
INTEGER(KIND=4), OPTIONAL, INTENT(in) :: ktime ! Optional variable. If missing 1 is assumed
LOGICAL, OPTIONAL, INTENT(in) :: ldiom ! Optional variable. If missing false is assumed
LOGICAL, OPTIONAL, INTENT(in) :: ld_zeromask ! Optional variable. Reset field to zero at missing value points. If missing false is assumed
REAL(KIND=4), DIMENSION(kpi,kpj) :: getvar ! 2D REAL 4 holding variable field at klev

INTEGER(KIND=4), DIMENSION(4) :: istart, icount, inldim
Expand All @@ -1454,7 +1455,7 @@ FUNCTION getvar (cdfile,cdvar,klev,kpi,kpj,kimin,kjmin, ktime, ldiom)
REAL(KIND=4) :: spval !: missing value
REAL(KIND=4) , DIMENSION (:,:), ALLOCATABLE :: zend, zstart
CHARACTER(LEN=256) :: clvar
LOGICAL :: lliom=.false., llperio=.false.
LOGICAL :: lliom=.false., llperio=.false., ll_zeromask=.false.
LOGICAL :: llog=.FALSE. , lsf=.FALSE. , lao=.FALSE.
!!
INTEGER(KIND=4) :: ityp
Expand Down Expand Up @@ -1499,6 +1500,12 @@ FUNCTION getvar (cdfile,cdvar,klev,kpi,kpj,kimin,kjmin, ktime, ldiom)
lliom=.false.
ENDIF

IF (PRESENT(ld_zeromask) ) THEN
ll_zeromask=ld_zeromask
ELSE
ll_zeromask=.false.
ENDIF

! Must reset the flags to false for every call to getvar
clvar=cdvar
llog = .FALSE.
Expand Down Expand Up @@ -1603,7 +1610,8 @@ FUNCTION getvar (cdfile,cdvar,klev,kpi,kpj,kimin,kjmin, ktime, ldiom)
IF (lsf ) WHERE (getvar /= spval ) getvar=getvar*sf
IF (lao ) WHERE (getvar /= spval ) getvar=getvar + ao
IF (llog) WHERE (getvar /= spval ) getvar=10**getvar

IF (ll_zeromask) WHERE (getvar == spval ) getvar=0.0

istatus=NF90_CLOSE(incid)

END FUNCTION getvar
Expand Down Expand Up @@ -1981,13 +1989,13 @@ FUNCTION getvarxz (cdfile, cdvar, kj, kpi, kpz, kimin, kkmin, ktime)
lao=.FALSE.

clvar=cdvar
IF ( clvar == cn_ve3v) THEN
SELECT CASE ( cg_zgr_ver )
CASE ( 'v2.0' ) ; clvar = 'e3v_ps'
CASE ( 'v3.0' ) ; clvar = 'e3v'
CASE ( 'v3.6' ) ; clvar = 'e3v_0'
END SELECT
ENDIF
!IF ( clvar == cn_ve3v) THEN
!SELECT CASE ( cg_zgr_ver )
!CASE ( 'v2.0' ) ; clvar = 'e3v_ps'
!CASE ( 'v3.0' ) ; clvar = 'e3v'
!CASE ( 'v3.6' ) ; clvar = 'e3v_0'
!END SELECT
!ENDIF

CALL ERR_HDL(NF90_OPEN(cdfile,NF90_NOWRITE,incid) )
CALL ERR_HDL(NF90_INQ_VARID ( incid,clvar,id_var))
Expand Down
6 changes: 4 additions & 2 deletions src/cdfpsi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ PROGRAM cdfpsi

CALL CreateOutput

PRINT *, 'Getting ',TRIM(cn_ve1v), TRIM(cn_ve2u)
e1v(:,:) = getvar(cn_fhgr, cn_ve1v, 1, npiglo, npjglo)
e2u(:,:) = getvar(cn_fhgr, cn_ve2u, 1, npiglo, npjglo)
IF ( lmask) THEN
Expand Down Expand Up @@ -270,7 +271,7 @@ PROGRAM cdfpsi

DO jk = 1,npk
IF ( ll_v ) THEN
zv(:,:) = getvar(cf_vfil, cn_vomecrty, jk, npiglo, npjglo, ktime=jt )
zv(:,:) = getvar(cf_vfil, cn_vomecrty, jk, npiglo, npjglo, ktime=jt, ld_zeromask=.true. )
IF ( lfull ) THEN ; e3v(:,:) = e31d(jk)
ELSE ; e3v(:,:) = getvar(cn_fe3v, cn_ve3v, jk, npiglo, npjglo, ktime=it, ldiom=.NOT.lg_vvl)
ENDIF
Expand All @@ -289,7 +290,8 @@ PROGRAM cdfpsi
ENDIF

IF ( ll_u) THEN
zu(:,:) = getvar(cf_ufil, cn_vozocrtx, jk, npiglo, npjglo, ktime=jt )
zu(:,:) = getvar(cf_ufil, cn_vozocrtx, jk, npiglo, npjglo, ktime=jt, ld_zeromask=.true. )
PRINT *, 'Getting ',TRIM(cn_ve3u)
IF ( lfull ) THEN ; e3u(:,:) = e31d(jk)
ELSE ; e3u(:,:) = getvar(cn_fe3u, cn_ve3u, jk, npiglo, npjglo, ktime=it, ldiom=.NOT.lg_vvl)
ENDIF
Expand Down
14 changes: 7 additions & 7 deletions src/cdfsigtrp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,10 @@ PROGRAM cdfsigtrp
lchk = lchk .OR. chkfile( cf_vfil )
IF ( lchk ) STOP 99 ! missing file

! Look for missing value for salinity, U and V
zsps = getspval(cf_sfil, cn_vosaline )
zspu = getspval(cf_ufil, cn_vozocrtx )
zspv = getspval(cf_vfil, cn_vomecrty )

! Look for missing value for salinity, U and V
zsps = getspval(cf_sfil, cn_vosaline )
zspu = getspval(cf_ufil, cn_vozocrtx )
zspv = getspval(cf_vfil, cn_vomecrty )

IF ( lg_vvl ) THEN
cn_fe3u = cf_ufil
Expand Down Expand Up @@ -327,8 +326,9 @@ PROGRAM cdfsigtrp
! Initialise sections from file
! first call to get nsection and allocate arrays
IF ( lbrk ) THEN
npiglo = getdim (cf_brk, cn_x)
nsection = 1 ; iimina=1 ; iimaxa=npiglo ; ijmina=1 ; ijmaxa=1
!npiglo = getdim (cf_brk, cn_x)
!nsection = 1 ; iimina=1 ; iimaxa=npiglo ; ijmina=1 ; ijmaxa=1
nsection = 1
ELSE
nsection = 0
CALL section_init(cf_section, csection,cvarname,clongname,iimina, iimaxa, ijmina, ijmaxa, nsection)
Expand Down
Loading