Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

[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


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690