This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: Paul Wessel <address@hidden> >Subject: netcdf 3 and GMT >Organization: University of Hawaii >Keywords: 199710022207.QAA22322 netCDF 3 Hi Paul, > We've converting GMT to use netcdf 3. All seems well except for one thing: > > Using version 2 code we wrote > > ncattget (c->cdfid, NC_GLOBAL, "title", (void *)c->title); > > which correctly got the title string. > Using version 3 this now looks like > > nc_get_att_text (c->cdfid, NC_GLOBAL, "title", c->title); > > But when we run the program that line gives an error: > Attempt to convert between text & numbers > > and no title is passed back. > > Any ideas? This is on an Ultra-2 with Solaris 2.5.1 and Sun compilers Yes, the netCDF-3 interface tries to prevent reading data as text that was written as numbers, so unless the external type of the "title" attribute is NC_CHAR, you will get this error message. If you wrote the "title" attributes using the NC_BYTE type instead of the NC_CHAR type, you can get around this by reading the data using nc_get_att_schar() instead of nc_get_att_text() to read the data into an array of signed char, for example: nc_get_att_schar (c->cdfid, NC_GLOBAL, "title", (signed char*) c->title); --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu