[netcdfgroup] nf90_put_var treatment of scalar strings

Hi All,

I have discovered (the hard way, of course) that the Fortran 90 interface
nf90_put_var treats scalar strings in an unexpected way.  The specific
function for writing a scalar string is nf90_put_var_text (in
netcdf_text_variables.f90) and this function uses the len_trim intrinsic to
compute count, and uses the trim intrinsic in the call to nf_put_vars_text.
This strips the trailing blanks that fortran codes depend on.  If the
default prefill is on then the application that reads the string gets
trailing nulls rather than blanks which is not too hard to deal with.
However, if prefill is turned off, which is the normal mode of operation
for models writing large datasets, then the reading application gets
trailing garbage which is a disaster.

The specific interface for scalar strings is the only one that does this;
arrays of strings are treated properly.

I consider it a bug that the F90 interface alters the data passed by the
user to be written to the file.  I'm interested to hear whether there are
other points of view about this behavior.

Thanks,
Brian



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