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 &
I may suggest to the IDL people that the default netCDF type for string
attributes in NETCDF4 files should be CHAR, not STRING.
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>