Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Vegas-Regidor committed Mar 31, 2017
2 parents 9b44a7d + 32ba7c0 commit 7cf716c
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 47 deletions.
94 changes: 71 additions & 23 deletions DOC/cdftools.html
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ <h2 id="cdfheatc">cdfheatc</h2>

<pre><code> usage : cdfheatc -f T-file [-mxloption option] ...
[-zoom imin imax jmin jmax kmin kmax] [-full] [-o OUT-file]
[-M MSK-file VAR-mask ]

PURPOSE :
Computes the heat content in the specified 3D area (Joules)
Expand All @@ -1503,6 +1504,10 @@ <h2 id="cdfheatc">cdfheatc</h2>
option=-1 : exclude mixed layer in the computation
option= 0 : [Default], do not take care of mxl.
[-o OUT-file ] : specify netcdf output filename instead of heatc.nc
[-M MSK-file VAR-mask] : Allow the use of a non standard mask file
with VAR-mask, instead of mask.nc and tmask
This option is a usefull alternative to -zoom option, when the
area of interest is not &#39;box-like&#39;

REQUIRED FILES :
Files mesh_hgr.nc, mesh_zgr.nc and mask.nc
Expand All @@ -1512,7 +1517,10 @@ <h2 id="cdfheatc">cdfheatc</h2>
variables: heatc3d (Joules)
: heatc(dep) (Joules)
: heatc3dpervol (Joules/m3)
Standard output</code></pre>
Standard output

SEE ALSO:
cdfpolymask </code></pre>

<h2 id="cdfhflx">cdfhflx</h2>

Expand Down Expand Up @@ -2022,7 +2030,9 @@ <h2 id="cdfmaxmoc">cdfmaxmoc</h2>
<h2 id="cdfmean">cdfmean</h2>

<pre><code> usage : cdfmean IN-file IN-var T|U|V|F|W [imin imax jmin jmax kmin kmax]
... [-full] [-var] [-zeromean]
... [-full] [-var] [-zeromean] [-M MSK-file VAR-mask ]
... [-o OUT-file] [ -ot OUTASCII-file] [-oz ZEROMEAN-file]
... [ -ov VAR-file]

PURPOSE :
Computes the mean value of the field (3D, weighted). For 3D fields,
Expand All @@ -2040,10 +2050,24 @@ <h2 id="cdfmean">cdfmean</h2>
if imin = 0 then ALL i are taken
if jmin = 0 then ALL j are taken
if kmin = 0 then ALL k are taken
[-M MSK-file VAR-mask] : Allow the use of a non standard mask file
with VAR-mask, instead of mask.nc and
This option is a usefull alternative to the previous options, whe
n the
area of interest is not &#39;box-like&#39;
[ -full ] : compute the mean for full steps, instead of default
partial steps.
[ -var ] : also compute the spatial variance of cdfvar
[ -zeromean ] : create a file with cdfvar having a zero spatial mean.
[ -o OUT-file] : specify the name of the output file instead of
cdfmean.nc
[ -ot OUTASCII-file] : specify the name of the output ASCII file instead

of cdfmean.txt
[ -oz ZEROMEAN-file] : specify the name of the output file for option
-zeromean, instead of zeromean.nc
[ -ov VAR-file] : specify the name of the output file for option
-var, instead of cdfvar.txt

REQUIRED FILES :
Files mesh_hgr.nc, mesh_zgr.nc, mask.nc
Expand All @@ -2061,7 +2085,7 @@ <h2 id="cdfmean">cdfmean</h2>
<h2 id="cdfmhst">cdfmhst</h2>

<pre><code> usage : cdfmhst VT-file | (V-file T-file [S-file]) [MST] [-full] ...
... [-Zdim]
... [-Zdim] [-o OUT-file]

PURPOSE :
Compute the meridional heat/salt transport as a function of
Expand All @@ -2080,6 +2104,7 @@ <h2 id="cdfmhst">cdfmhst</h2>
If not specified, only the MHT is output.
[-full ] : to be set for full step case.
[-Zdim ] : to be set to output vertical structure of Heat/salt transport
[-o OUT-file ] : change name of the output file. Default:mhst.nc

REQUIRED FILES :
mesh_hgr.nc, mesh_zgr.nc and mask.nc
Expand All @@ -2089,7 +2114,7 @@ <h2 id="cdfmhst">cdfmhst</h2>
OUTPUT :
ASCII files : zonal_heat_trp.dat : Meridional Heat Transport
zonal_salt_trp.dat : Meridional Salt Transport
netcdf file : mhst.nc
netcdf file : mhst.nc unless -o option is used.
variables : ( [... ] : MST option )
zomht_glo : Meridional Heat Transport (global)
[ zomst_glo : Meridional Salt Transport (global) ]
Expand Down Expand Up @@ -2835,26 +2860,30 @@ <h2 id="cdfpendep">cdfpendep</h2>

<h2 id="cdfpolymask">cdfpolymask</h2>

<pre><code> usage : cdfpolymask POLY-file REF-file [ -r]
<pre><code> usage : cdfpolymask -p POLY-file -ref REF-file [ -r] [-o OUT_file]

PURPOSE :
Create a maskfile with polymask variable having 1
inside the polygon, and 0 outside. Option -r revert
the behaviour (0 inside, 1 outside).

ARGUMENTS :
POLY-file : input ASCII file describing a polyline in I J grid.
-p POLY-file : input ASCII file describing a polyline in I J grid.
This file is structured by block, one block corresponding
to a polygon:
1rst line of the block gives a polygon name
2nd line gives the number of vertices (nvert) and a dummy 0
the block finishes with nvert pairs of (I,J) describing
the polygon vertices.
REF-file : reference netcdf file for header of polymask file.
-ref REF-file : reference netcdf file for header of polymask file.
This file will be used to look for domain dimensions, and
in order to build the output file (nav_lon, nav_lat etc ...)

OPTIONS :
[ -r ] : revert option. When used, 0 is inside the polygon,
1 outside.
[ -o OUT-file ] : spefify the name of the output mask file instead
of polymask.nc

REQUIRED FILES :
none
Expand Down Expand Up @@ -3744,31 +3773,45 @@ <h2 id="cdfstrconv">cdfstrconv</h2>

<h2 id="cdfsum">cdfsum</h2>

<pre><code> usage : cdfsum IN-file IN-var T| U | V | F | W ...
... [imin imax jmin jmax kmin kmax] [-full ]
<pre><code> usage : cdfsum -f IN-file -v IN-var -p T| U | V | F | W ...
... [-zoom imin imax jmin jmax kmin kmax] [-full ] [-o OUT-file]
... [-M MSK-file VAR-mask ]

PURPOSE :
Computes the sum value of the field (3D, weighted)
This sum can be optionally limited to a sub-area.
This sum can be optionally limited to a 3D sub-area.

ARGUMENTS :
IN-file : netcdf input file.
IN-var : netcdf variable to work with.
T| U | V | F | W : C-grid point where IN-var is located.
-f IN-file : netcdf input file.
-v IN-var : netcdf variable to work with.
-p T| U | V | F | W : C-grid point where IN-var is located.

OPTIONS :
[imin imax jmin jmax kmin kmax] : limit of the sub area to work with.
[-zoom imin imax jmin jmax kmin kmax] : limit of the 3D sub area.
if imin=0 all i are taken
if jmin=0 all j are taken
if kmin=0 all k are taken
[ -full : ] Use full steps instead of default partial steps
[-o OUT-file ] : name of the output file instead ofcdfsum.nc
[-M MSK-file VAR-mask] : Allow the use of a non standard mask file
with VAR-mask, instead of mask.nc and the variable
associated with the grid point set by -p argument.
This option is a usefull alternative to -zoom option, when the
area of interest is not &#39;box-like&#39;

REQUIRED FILES :
mesh_hgr.nc, mesh_zgr.nc and mask.nc
mesh_hgr.nc, mesh_zgr.nc and mask.nc. If
-M option is used, the specified mask file is required instead
mask.nc

OUTPUT :
Standard output.
netcdf file : cdfsum.nc with 2 variables : vertical profile of sum
and 3D sum.</code></pre>
netcdf file : cdfsum.nc unless modified with -o option.
- 2 variables : vertical profile of sum and 3D sum.
names are sum_&lt;varname&gt; and sum3D_&lt;varname&gt;.

SEE ALSO:
cdfmean </code></pre>

<h2 id="cdftempvol-full">cdftempvol-full</h2>

Expand All @@ -3784,9 +3827,9 @@ <h2 id="cdftempvol-full">cdftempvol-full</h2>

<h2 id="cdftransport">cdftransport</h2>

<pre><code> usage : cdftransport [-test u v ] [-noheat ] [-plus_minus ] [-obc]...
<pre><code> usage : cdftransport [-test u v ] [-noheat ] [-plus_minus ] [-obc] [-TS]
... [VT-file] U-file V-file [-full] |-time jt] ...
... [-time jt ] [-zlimit limits of level]
... [-time jt ] [-zlimit limits of level] [-self]

PURPOSE :
Compute the transports accross a section.
Expand All @@ -3812,18 +3855,23 @@ <h2 id="cdftransport">cdftransport</h2>
the volume transport. This option implicitly set -noheat,
and must be used before the file names.
[-obc ] : indicates that input files are obc files (vertical slices)
Take care that for this case, mesh files must be adapted.
This option implicitly set -noheat, and must be used before
the file names.
Take care that for this case, mesh files must be adapted.
This option implicitly set -noheat, and must be used before
the file names.
[ -TS ] : Indicate that UT VT US VS will be recomputed from T U V
files. T-file is passed as the first file instead of VT
[-full ] : use for full step configurations.
[-time jt ]: compute transports for time index jt. Default is 1.
[-zlimit list of depth] : Specify depths limits defining layers where the
transports will be computed. If not used, the transports
are computed for the whole water column. If used, this
option must be the last on the command line.
[ -self ] : This option indicates that input files corresponds to a
broken line, hence data files hold the metrics.

REQUIRED FILES :
Files mesh_hgr.nc, mesh_zgr.nc must be in the current directory.
unless -self option is used.

OUTPUT :
- Standard output
Expand All @@ -3834,7 +3882,7 @@ <h2 id="cdftransport">cdftransport</h2>
from section name.

SEE ALSO :
cdfsigtrp
cdfsigtrp cdf_xtrac_brokenline
</code></pre>

<h2 id="cdfuv">cdfuv</h2>
Expand Down
36 changes: 34 additions & 2 deletions src/cdfio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,18 @@ MODULE cdfio
INTEGER(KIND=4) :: idz ! z dimid
INTEGER(KIND=4) :: idt ! t dimid
INTEGER(KIND=4) :: idb ! time-bound dimid
INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: ideflat ! deflate level (nvar)
INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: nvatt ! number of att of each variable (var)
INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: nvid ! varid of each variable (var)
INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: nvdim ! dimension of each variable (var)
INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: itype ! type of each variable (var)
INTEGER(KIND=4), DIMENSION(:), ALLOCATABLE :: nlen ! len of each dimension ( ndims)
INTEGER(KIND=4), DIMENSION(:,:), ALLOCATABLE :: ichunk ! size of chunk (nvar, ndims)
INTEGER(KIND=4), DIMENSION(:,:), ALLOCATABLE :: idimids ! dimids of each variable (nvar, ndims)
CHARACTER(LEN=255) :: c_fnam ! name of working file
CHARACTER(LEN=80 ), DIMENSION(:), ALLOCATABLE :: c_vnam ! name of each variable (var)
CHARACTER(LEN=80 ), DIMENSION(:), ALLOCATABLE :: c_dnam ! name of each dimension (ndims)
LOGICAL, DIMENSION(:), ALLOCATABLE :: lconti ! contiguous flag (nvar)
! extra information for global attribute
INTEGER(KIND=4) :: number_total ! DOMAIN_number_total
INTEGER(KIND=4) :: number ! DOMAIN_number
Expand Down Expand Up @@ -3026,18 +3029,47 @@ FUNCTION GetNcFile (cd_file)
ALLOCATE (GetNcFile%c_vnam (GetNcFile%nvars) )
ALLOCATE (GetNcFile%nvatt (GetNcFile%nvars) )
ALLOCATE (GetNcFile%itype (GetNcFile%nvars) )
ALLOCATE (GetNcFile%c_dnam(GetNcFile%ndims) )
ALLOCATE (GetNcFile%c_dnam (GetNcFile%ndims) )
ALLOCATE (GetNcFile%nlen (GetNcFile%ndims) )
ALLOCATE (GetNcFile%idimids (GetNcFile%nvars,GetNcFile%ndims) )

! Look for dimensions
DO jdim = 1, GetNcFile%ndims
ierr = NF90_INQUIRE_DIMENSION(GetNcFile%ncid,jdim, &
& name = GetNcFile%c_dnam(jdim), &
& len = GetNcFile%nlen (jdim) )
ENDDO
! Look for variables
DO jvar = 1, GetNcFile%nvars
ierr = NF90_INQUIRE_VARIABLE (GetNcFile%ncid, jvar, &
& name = GetNcFile%c_vnam(jvar), &
& xtype = GetNcFile%itype(jvar), &
& ndims = GetNcFile%nvdim(jvar), &
& dimids = GetNcFile%idimids(jvar,:), &
& nAtts = GetNcFile%nvatt(jvar) )
& nAtts = GetNcFile%nvatt(jvar), &
& contiguous = GetNcFile%lconti(jvar), &
& chunksizes = GetNcFile%ichunk(jvar,:), &
& deflate_level = GetNcFile%ideflat(jvar) )
END DO
! Look for attributes
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_number_total' , GetNcFile%number_total )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_number ' , GetNcFile%number )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , GetNcFile%idimensions_ids(:) )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_size_global' , GetNcFile%isize_global(:) )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_size_local' , GetNcFile%isize_local(:) )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_position_first' , GetNcFile%iposition_first(:) )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_position_last' , GetNcFile%iposition_last(:) )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', GetNcFile%ihalo_size_start(:))
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end' , GetNcFile%ihalo_size_end(:) )
ierr = NF90_GET_ATT (GetNcFile%ncid, NF90_GLOBAL, 'DOMAIN_type' , GetNcFile%c_type )

! NOTE : for recombined files, no more DOMAIN attributes !!!
! DOMAIN_dimensions_ids gives ids for x, y
idx = GetNcFile%idimensions_ids(1)
idy = GetNcFile%idimensions_ids(2)
! time is unlimited dim
idt = GetNcFile%iunlim

! try to infer size of the domain assuming some basis:
! (1) 2D var are (x,y)
! (2) time dim is unlimited
Expand Down
4 changes: 2 additions & 2 deletions src/cdfmean.f90
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ PROGRAM cdfmean
narg = iargc()
IF ( narg == 0 ) THEN
PRINT *,' usage : cdfmean IN-file IN-var T|U|V|F|W [imin imax jmin jmax kmin kmax]'
PRINT *,' ... [-full] [-var] [-zeromean] [-M MSK-file VAR-mask ]
PRINT *,' ... [-full] [-var] [-zeromean] [-M MSK-file VAR-mask ]'
PRINT *,' ... [-o OUT-file] [ -ot OUTASCII-file] [-oz ZEROMEAN-file]'
PRINT *,' ... [ -ov VAR-file]
PRINT *,' ... [ -ov VAR-file]'
PRINT *,' '
PRINT *,' PURPOSE :'
PRINT *,' Computes the mean value of the field (3D, weighted). For 3D fields,'
Expand Down
39 changes: 19 additions & 20 deletions src/cdfmoy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ PROGRAM cdfmoy
!!-----------------------------------------------------------------------------
IMPLICIT NONE

INTEGER(KIND=4) :: jk, jfil ! dummy loop index
INTEGER(KIND=4) :: jk, jfil,jdep ! dummy loop index
INTEGER(KIND=4) :: jvar, jv, jt ! dummy loop index
INTEGER(KIND=4) :: ierr ! working integer
INTEGER(KIND=4) :: idep, idep_max ! possible depth index, maximum
INTEGER(KIND=4) :: narg, iargc, ijarg ! browsing command line
INTEGER(KIND=4) :: nfil ! number of files to average
INTEGER(KIND=4) :: npiglo, npjglo ! size of the domain
Expand Down Expand Up @@ -84,6 +85,7 @@ PROGRAM cdfmoy
CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_nam2 ! array of var2 name for output
CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_nam3 ! array of var3 name for output
CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: cv_nam4 ! array of var3 name for output
CHARACTER(LEN=256), DIMENSION(:), ALLOCATABLE :: clv_dep ! array of possible depth name (or 3rd dimension)

TYPE (variable), DIMENSION(:), ALLOCATABLE :: stypvar ! attributes for average values
TYPE (variable), DIMENSION(:), ALLOCATABLE :: stypvar2 ! attributes for square averaged values
Expand Down Expand Up @@ -211,31 +213,28 @@ PROGRAM cdfmoy

cf_in = cf_list(1)
IF ( chkfile (cf_in) ) STOP ! missing file

!
npiglo = getdim (cf_in, cn_x)
npjglo = getdim (cf_in, cn_y)
npk = getdim (cf_in, cn_z, cdtrue=cv_dep, kstatus=ierr)

IF (ierr /= 0 ) THEN
npk = getdim (cf_in, 'z',cdtrue=cv_dep,kstatus=ierr)
IF (ierr /= 0 ) THEN
npk = getdim (cf_in,'sigma',cdtrue=cv_dep,kstatus=ierr)
IF ( ierr /= 0 ) THEN
npk = getdim (cf_in,'nav_lev',cdtrue=cv_dep,kstatus=ierr)
IF ( ierr /= 0 ) THEN
npk = getdim (cf_in,'levels',cdtrue=cv_dep,kstatus=ierr)
IF ( ierr /= 0 ) THEN
PRINT *,' assume file with no depth'
npk=0
ENDIF
ENDIF
ENDIF
ENDIF

! looking for npk among various possible name
idep_max=8
ALLOCATE ( clv_dep(idep_max) )
clv_dep(:) = (/cn_z,'z','sigma','nav_lev','levels','ncatice','icbcla','icbsect'/)
idep=1 ; ierr=1000
DO WHILE ( ierr /= 0 .AND. idep <= idep_max )
npk = getdim (cf_in, clv_dep(idep), cdtrue=cv_dep, kstatus=ierr)
idep = idep + 1
ENDDO

IF ( ierr /= 0 ) THEN ! none of the dim name was found
PRINT *,' assume file with no depth'
npk=0
ENDIF

PRINT *, 'npiglo = ', npiglo
PRINT *, 'npjglo = ', npjglo
PRINT *, 'npk = ', npk
PRINT *, 'npk = ', npk , 'Dep name :' , TRIM(cv_dep)

ALLOCATE( dtab(npiglo,npjglo), dtab2(npiglo,npjglo), v2d(npiglo,npjglo),rmask2d(npiglo,npjglo)) ! [from SL]
ALLOCATE( rmean(npiglo,npjglo), rmean2(npiglo,npjglo) )
Expand Down

0 comments on commit 7cf716c

Please sign in to comment.