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).
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:
> git clone https://github.com/meom-group/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
> cd src/
> ln -sf ../Macrolib/macro.MACHINE make.macro
make.macro file, the PATH for the netcdf library is specified, as well as compiler name and used flags. In order to activate netcdf4/HDF5 chunking and deflation ( available in some cdftools), you need to set:
in the make.macro file, otherwise set
In order to activate CMIP6 variable naming convention (for input files), you need to set:
make (or even
make -j n if you can compile on n cores), you will have the cdftools programs executable available in the bin/ sub directory. The executable files are ignore by git.
CDFTOOLS is a collection of programs. Every single program performs one or many computation(s) using a set of input files and output the results as a netcdf file, and eventually also gives some results on the standard output.
CDFTOOLS coding rules imply that a
usage message is displayed when just running the tool without any arguments ( or with -h ). At the moment it is the only up to date documentation.
As CDFTOOLS is a collection of programs, a full diagnostic of model output can be performed writing a script using a sequence of tools. This is done for example in the Drakkar Monitoring Tools (DMONTOOLS, soon available on GitHub!).
The coding rules are the NEMO coding rules, strictly followed. The idea is that people familiar with NEMO are familiar with CDFTOOLS. In DEV_TOOLS/ some template fortran line are available for program, modules, routine or function headers. Also a template for the
Run time behaviour
cdftool, run without argument or with option -h, should display a short documentation (
usage message), similar to a unix man page, describing the purpose of the tool, the syntax (arguments, options, etc...) and giving details on the output files. For some tools, mesh or/and mask files are required to be present in the working directory, with respective name
mask.nc (links are OK). The usage message should indicate the required files.
usage : cdfcurl -u U-file U-var -v V-file V-var -l levlist [-T] [-8]... ... [-surf] [-overf] [-nc4] [-o OUT-file ] PURPOSE : Compute the curl of a vector field, at a specified level. If level is specified as 0, assume that the input files are forcing files, presumably on A-grid. In this latter case, the vector field is interpolated on the C-grid. In any case, the curl is computed on the F-point (unless -T option is used). ARGUMENTS : -u U-file U-var : file and variable name for zonal component -v V-file V-var : file and variable name for meridional component -l levlist : levels to be processed. If set to 0, assume forcing file in input. Example of recognized syntax : -l "1,10,30" or -l "1-20" or even -l "1-3,10-20,30-" -l 1 . Note that -l "3-" set a levlist from 3 to the bottom OPTIONS : -T : compute curl at T point instead of default F-point -8 : save in double precision instead of standard simple precision. -surf : work with single level C-grid (not forcing) -overf : store the ratio curl/f where f is the coriolis parameter -nc4 : use netcdf4 output with chunking and deflation 1 -o OUT-file : specify output file name instead of curl.nc REQUIRED FILES : mesh_hgr.nc OUTPUT : netcdf file : curl.nc variables : socurl or socurlt (if -T option), units : s^-1 or socurloverf, no units (if -overf option)
Improving/modifying existing tool
It is possible to improve (of course !) or modify any tools, but one important law to respect is that the modified tool should still be able to be used with previous syntax, in order to avoid breaking of existing scripts using CDFTOOLS. If for some reason, this is not possible, then a discussion must be done to reach to a common decision. Eventually, some old options must be documented as osbolete in the usage message, which means that they may be removed from a future release.
New features in version 4
Modified user interface
All arguments are passed with a
-keyswitch. No more
cdfmoy -l fich1.nc fich2.nc
-nc4options in all tools (when relevant). With
-othe default output name can be changed, allowing easier paralellisation. With
-nc4output file will use NetCdf4/Hdf5 format with chunking and deflation level 1.
Use of environment variable CDFT_xxx for overriding the default names of auxiliary files such as mesh_hgr.nc, mask.nc etc...so far there is support for
CDFT_MESH_HGR CDFT_MESH_ZGR CDFT_MASK CDFT_BASINS CDFT_COORD
Support for vvl simulations
- When relevant, the switch
-vvlindicates that the vertical metrics is time-varying. Therefore, CDFTOOLS assume that the vertical metrics is saved in the same file than the data.
Support for CMIP6 naming convention
- When the code is compiled with CPP key key_CMIP6 set, the default variable names are taken form modcdfnames_CMIP6.h90 instead of the standard DRAKKAR names.
- The codes have been cleaned for obsolescences. Coding rules were reinforced.
- Obsolete tools were removed or merged as options in more generic tools.
- Gathering the
usagemessage into man pages still works (
make man). Readibility of the man pages is improved by grouping the tools by category. The
usagemessages have been reviewed in order to give better information.
- The man pages are automaticaly translated to an html document that can be vizualized from any browser.
Back to release 3:
- The last version 3's release has been tagged as v3.0.2. Use this tag if you want to stay at version 3.
Introducing TEOS10 in the CDFTOOLS
- This introduction is made following the NEMO coding of eosbn2, using a polynomial form (Roquet et Al, Ocean Modelling, 2015) for both
EOS80 and TEOS10 equation of state, with a side effect of slightly changing the results (even using EOS80).
last commit before the introduction of this change corresponds to tag v4.0.0.
Also note that is you decide to use TEOS10, all relevant CDFTOOLS have now an option (-teos10) that switch the force the used EOS to be TEOS10. Without this option, EOS80 (polynomial form) is used.
Last but important :
When using TEOS10, temperatures should be Conservative Temperature (CT, DegC) and salinity should be Absolute Salinity (SA, g/kg)
When using EOS80, temperatures should be Potential Temperature (PT, DegC) and salinity should be Practical Salinity (SP, PSU)
As of Oct. 2021, no sanity check is performed for controling this important point.
Interface with GSW library.
- GSW library provides a collection of functions and routines linked
with the TEOS-10 Equation of state for Sea Water, using Conservative Temperature (CT) and Absolute Salinity (SA).
cdf_gswis an interface with GSW toolbox. For using it, key_GSW must be defined in make.macro and the
libgsw.amust be precompiled on your system. Up to now, only a subset of the GSW functions is interfaced, but cdf_gsw provides a usefull framework for interfacing other functions.