NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
NOTE: The netcdf-hdf
mailing list is no longer active. The list archives are made available for historical reasons.
Ed: The attached C program creates a netcdf4_classic file that is unreadable (ncdump'ing it gives an 'HDF Error').
-Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@xxxxxxxx 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
#include <stdio.h> #include <string.h> #include <netcdf.h> #define FILENAME "testfile.nc" #define ATT1 "foo" #define ATT2 "bar" #define LONG_NAME "attribute" #define ATT3 "long_name" #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;} int main() { int ncid, retval, att; if ((retval = nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL))) ERR(retval); if ((retval = nc_create(FILENAME, NC_CLOBBER, &ncid))) ERR(retval); if ((retval = nc_enddef(ncid))) ERR(retval); att = 1; if ((retval = nc_redef(ncid))) ERR(retval); if ((retval = nc_put_att(ncid, NC_GLOBAL, ATT1, NC_INT, 1, &att))) ERR(retval); if ((retval = nc_enddef(ncid))) ERR(retval); att = 2; if ((retval = nc_redef(ncid))) ERR(retval); if ((retval = nc_put_att(ncid, NC_GLOBAL, ATT2, NC_INT, 1, &att))) ERR(retval); if ((retval = nc_enddef(ncid))) ERR(retval); if ((retval = nc_redef(ncid))) ERR(retval); if ((retval = nc_put_att_text(ncid, NC_GLOBAL, ATT3, strlen(LONG_NAME), LONG_NAME))) ERR(retval); if ((retval = nc_enddef(ncid))) ERR(retval); if ((retval = nc_close(ncid))) ERR(retval); }
netcdf-hdf
archives: