[netcdfgroup] NF90_CHAR vs NF90_STRING for attribute values

I have IDL code that writes a netCDF file to be read by the ROMS ocean model 
via the netCDF90 interface.

One of the variables in this file is defined thus:

      double ocean_time(ocean_time) ;
                string ocean_time:units = "days since 2008-01-01 00:00:00" ;

I recently changed the format from NETCDF3 to NETCDF4 to avoid file size 
limitations. (This is done in IDL by specifying the /NETCDF4_FORMAT keyword. 
There is a /NETCDF3_64BIT keyword that would also avoid those limitations, but 
it is not available in my version of IDL.)

ROMS now refuses to read the units attribute. This is because the attribute 
type has changed from NF90_CHAR (length 30) to NF90_STRING (length 1). This was 
not done deliberately by me, but by IDL.

I now see that I can override this by specifying the /CHAR keyword when I write 
the attribute. This should let me avoid the problem—I haven't checked yet—but 
having spent 4-6 hours tracking down the problem, I figure I might as well ask 
this question anyway.

Is it possible to read an attribute of type NF90_STRING into a Fortran 
character variable using the Fortran 90 interface? Calling NF90_GET_ATT (as 
ROMS does) with a character variable to accept the output does not work, but 
returns an error code that translates to  "Attempt to convert between text & 
numbers".

I may suggest to the IDL people that the default netCDF type for string 
attributes in NETCDF4 files should be CHAR, not STRING.

Mark

Dr Mark Hadfield
Marine Physics Modeller

+64-4-386-0363 | +64-21-027-41037 | 301 Evans Bay Parade, Greta Point, 
Wellington | www.niwa.co.nz<http://www.niwa.co.nz>
[NIWA]<http://www.niwa.co.nz>



JPEG image

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