- To: netcdf@xxxxxxxxxxxxxxxx
- Subject: Re: [netcdfgroup] Allowed characters in variable names?
- From: Heiko Klein <Heiko.Klein@xxxxxx>
- Date: Fri, 13 Aug 2010 11:15:43 +0200
I just wrote a small example file (attached), defining to variables:
pressure and 2t
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;
}
- Follow-Ups:
- Re: [netcdfgroup] Allowed characters in variable names?
- From: Ed Hartnett
- Re: [netcdfgroup] Allowed characters in variable names?
- References:
- [netcdfgroup] Allowed characters in variable names?
- From: Heiko Klein
- Re: [netcdfgroup] Allowed characters in variable names?
- From: Dennis Heimbigner
- [netcdfgroup] Allowed characters in variable names?