This programme, written in standard Fortran 90, is an example to show how to build a file compliant to WDF specifications. The programme must be linked with a NetCDF library customized for the operating system you work on. The result file uses GMT choice for WDF files, i.e. one polar per file and full record concept support. This demo file illustrate following configuration :
Creating a WDF specification compliant file is achieved in few steps detailed hereunder and corresponding to step comments in the WDF_CREATE_FILE source programme. Programme includes NetCDF.inc file which contains functions and constants used in source code. NetCDF.inc file is provided with WDF_CREATE_FILE and can also be found in ..\SRC\FORTRAN\ directory of the standard NetCDF package.
STEP 1 : Opening file in creation mode.
Call NetCDF routine NF_CREATE (). File name is TEST_PO8888.WDF.
STEP 2 : Defining global attributes.
Nine mandatory global attributes are defined in WDF specifications with following names and meanings :
Global attributes are defined by calls to NF_PUT_ATT_TEXT () or NF_PUT_ATT_INT () depending on their type.
STEP 3 : Defining dimensions used in the file.
Every dimension used in a WDF file is defined by a name and a value. Three kinds of dimension appear in a WDF file :
Record number dimension name is xxxxx_Dim where xxxxx is the record name.
Result arrays size names are Siz000nn where nn is the numeric value of the dimension.
Character string size names are Dim000nn where nn is the numeric value of the string length.
These naming conventions are not mandatory. We choose them for easier programming but they are not part of the WDF specifications. In the same way, to save space, we choose to define dimension only when there was no previous existing value, but this is not mandatory, a dimension value may be defined twice or more with different names.
A dimension is defined by a call to NF_DEF_DIM () which returns a dimension Id used afterwards as a reference.
STEP 4 : Defining result variables.
In the demo programme WDF_CREATE_FILE we consider only one dimension, numeric or string, arrays. This is to provide a quite simple programming example and not a limitation of the WDF format itself.
First dimension (slowest variation according to FORTRAN rules) will be the number of records the variable belongs to.
Second dimension will be the size of the array or one (1) if the variable is a scalar.
Third dimension will be string length for character strings. Does not exist for other kinds of variables.
Dimensions are stored (via Id’s numbers) in a dimension vector which is a parameter of the variable definition together with the name, the kind, and the number of items in the dimension vector. Variable definition is achieved by a call to NF_DEF_VAR () which returns a variable Id. Please not that variable Id is similar to the order number in which the variables is declared.
To allow users to have the same variable name in more than one record and to satisfy the unique variable name rule set by NetCDF standard, WDF specification say that the original variable name is concatenated with the record name the variable belongs to. The original variable name is stored in a variable attribute.
STEP 5 : Adding variable attributes.
As mentioned above, the only variable attribute used by WDF is “long_name” to store the original variable name. It is filled with a call to NF_PUT_ATT_TEXT () routine.
STEP 6 : Defining structuring variables.
To store chronology and organization of the original records, WDF defines five structuring variables, also called “extra variables” to distinguish them from result variables. These extra variables have compulsory names with the following meanings :
Furthermore, to allow storing of more than one series or run or polar in the same WDF file, four other structuring variables are added with following names and meanings :
All structuring variables are defined by successive calls to NF_DEF_VAR () after result variables. They do not have long_name attribute.
STEP 7 : Closing definition mode.
Call to NF_ENDEF () routine
STEP 8 : Adding values to structuring variables.
Successive calls to NF_PUT_VAR_INT () routine as all these variables, except RecordNames, contain integer values. RecordNames values are provided by a NF_PUT_VAR_TEXT () call.
STEP 9 : Adding values to result variables.
In the demo programme, we used real or integer variables of two, for or eight (for real only) bytes. The value of each variable is its place in the declaration sequence, followed by the record index. For the character string variable, the value is fixed to “Décembre”. Programme calls either NF_PUT_VAR_REAL, NF_PU_VAR_DOUBLE, NF_PUT_VAR_INT2, NF_PUT_VAR_INT, NF_PUT_VAR_TEXT, according to the type of the variable.
STEP 10 : Closing file
Call to NCCLOS () routine