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.
Results from netcdf 3.6.2 (ubuntu hardy default package): heikok@tko2635:~$ ./write_numeric_varname try defining pressure ...success try defining 2t ...success *** SUCCESS writing example file! Results from netcdf 3.6.3 (ubuntu lucid default package): heikok@topp:~$ ./write_numeric_varname try defining pressure ...success try defining 2t ...Error: NetCDF: Name contains illegal characters Best regards, Heiko
#include <stdio.h> #include <string.h> #include <netcdf.h> /* This is the name of the data file we will create. */ #define FILE_NAME "var_starting_numeric.nc" /* We are writing 2D data, a 6 x 12 lat-lon grid. We will need two * netCDF dimensions. */ #define NDIMS 0 /* Names of things. */ #define PRES_NAME "pressure" #define TEMP_NAME "2t" /* Handle errors by printing an error message and exiting with a * non-zero status. */ #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;} int main() { int ncid, pres_varid, temp_varid; int dimids[NDIMS]; /* Error handling. */ int retval; /* Create the file. */ if ((retval = nc_create(FILE_NAME, NC_CLOBBER, &ncid))) ERR(retval); /* Define the netCDF variables. */ fprintf(stderr, "try defining pressure ..."); if ((retval = nc_def_var(ncid, PRES_NAME, NC_FLOAT, NDIMS, dimids, &pres_varid))) ERR(retval); fprintf(stderr, "success\n"); fprintf(stderr, "try defining 2t ..."); if ((retval = nc_def_var(ncid, TEMP_NAME, NC_FLOAT, NDIMS, dimids, &temp_varid))) ERR(retval); fprintf(stderr, "success\n"); /* End define mode. */ if ((retval = nc_enddef(ncid))) ERR(retval); printf("*** SUCCESS writing example file!\n"); return 0; }
netcdfgroup
archives: