11 #define FILE_NAME "simple_xy.nc" 21 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);} 28 int ncid, x_dimid, y_dimid, varid;
41 for (x = 0; x < NX; x++)
42 for (y = 0; y < NY; y++)
43 data_out[x][y] = x * NY + y;
56 if ((retval =
nc_def_dim(ncid,
"x", NX, &x_dimid)))
58 if ((retval =
nc_def_dim(ncid,
"y", NY, &y_dimid)))
88 printf(
"*** SUCCESS writing example file simple_xy.nc!\n");
EXTERNL int nc_def_var(int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
Define a new variable.
EXTERNL int nc_def_dim(int ncid, const char *name, size_t len, int *idp)
Define a new dimension.
Main header file for the C API.
int nc_put_var_int(int ncid, int varid, const int *op)
Write an entire variable with one call.
EXTERNL int nc_close(int ncid)
Close an open netCDF dataset.
#define NC_INT
signed 4 byte integer
#define NC_CLOBBER
Destroy existing file.
EXTERNL int nc_enddef(int ncid)
Leave define mode.
EXTERNL int nc_create(const char *path, int cmode, int *ncidp)
Create a new netCDF file.