[netcdfgroup] Some more definite clues for Fortran users regarding NF_UNLIMITED and NF_PUT_VAR_type.

Hi folks,

a colleague had an issue with the Fortran 77 interface that several other 
colleagues were also stymified by.

Somehow the documentation didn't make it clear enough that when you define a 
record dimension with NF_UNLIMITED, that you need to fill that dimension using 
the NF_PUT_VARA family, as the NF_PUT_VAR family would simply write nothing. 
After coming to that conclusion by applying some reasoning, I found the hint on 
http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f77/NF_005fPUT_005fVAR_005f-type.html#NF_005fPUT_005fVAR_005f-type
 about "being careful" with record variables.

I asked the colleague about what could be improved in the docs so that she 
would have spotted that herself. Mind: she is coding Fortran 90, actually ... 
so is used to functions that know the extend of their array arguments, so did 
not think about the array extends of the data variable being irrelevant to the 
Fortran 77 interface. The effect was "Why does NF_PUT_VAR_REAL(..., 
data(1:endtime)) not write anything when I make the time dimension 
NF_UNLIMITED?"
Two suggestions arose:

1. Put the token NF_UNLIMITED into the hint about record variables ... someone 
just browsing the docs and not having read them fully doesn't necessarily 
connect the term "record variable" with "unlimited dimension".

2. Mention in the page for NF_DEF_DIM that unlimited dimensions need to be 
filled with NF_PUT_VARA.
That would have prevented the fatal combination of the example code for 
NF_DEF_DIM with NF_UNLIMITED and the example code for NF_PUT_VAR that suggested 
that you can use NF_PUT_VAR to fill also record dimensions. Well, the latter 
suggestion only arises when you read the doc for NF_DEF_DIM and the doc for 
NF_PUT_VAR right after each other ... and perhaps it would help to prevent that 
link by using an example not involving a dimension named "time" for NF_PUT_VAR 
... as "time" has been established as the canonical record dimension.


Alrighty then,

Thomas.

PS: The reason for using the Fortran 77 interface is apparently that the 
Fortran 90 interface is not that readily available in installations. Well, I 
realized long ago that I have to do my own NetCDF builds, carefully matching 
the detailed compiler version I am using to make the NetCDF module work. Not 
everyone does that ... so that might be a hint on continued usage of the 
somewhat foreign interface even in Fortran 90 programs.

-- 
Dipl. Phys. Thomas Orgis
Atmospheric Modelling
Alfred-Wegener-Institute for Polar and Marine Research
Office phone: 049 331 288 2164



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: