|
NetCDF
4.8.1
|
Go to the documentation of this file.
23 #define FILE_NAME "simple_nc4.nc"
33 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
40 int ncid, x_dimid, y_dimid, varid1, varid2, grp1id, grp2id,
typeid;
45 unsigned long long data_out[NX][NY];
56 struct s1 compound_data[NX][NY];
59 for (x = 0; x < NX; x++)
60 for (y = 0; y < NY; y++)
62 data_out[x][y] = x * NY + y;
63 compound_data[x][y].i1 = 42;
64 compound_data[x][y].i2 = -42;
74 if ((retval =
nc_def_dim(ncid,
"x", NX, &x_dimid)))
76 if ((retval =
nc_def_dim(ncid,
"y", NY, &y_dimid)))
84 if ((retval =
nc_def_grp(ncid,
"grp1", &grp1id)))
86 if ((retval =
nc_def_grp(ncid,
"grp2", &grp2id)))
105 offsetof(
struct s1, i1),
NC_INT))
108 offsetof(
struct s1, i2),
NC_INT))
113 if ((retval =
nc_def_var(grp2id,
"data",
typeid, NDIMS,
119 if ((retval =
nc_put_var(grp2id, varid2, &compound_data[0][0])))
126 printf(
"*** SUCCESS writing example file simple_nc4.nc!\n");
EXTERNL int nc_def_compound(int ncid, size_t size, const char *name, nc_type *typeidp)
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_insert_compound(int ncid, nc_type xtype, const char *name, size_t offset, nc_type field_typeid)
EXTERNL int nc_def_dim(int ncid, const char *name, size_t len, int *idp)
Define a new dimension.
#define NC_INT
signed 4 byte integer
int nc_put_var_ulonglong(int ncid, int varid, const unsigned long long *op)
EXTERNL int nc_put_var(int ncid, int varid, const void *op)
EXTERNL int nc_close(int ncid)
EXTERNL int nc_def_grp(int parent_ncid, const char *name, int *new_ncid)
Define a new group.
#define NC_UINT64
unsigned 8-byte int
#define NC_NETCDF4
Use netCDF-4/HDF5 format.
EXTERNL int nc_create(const char *path, int cmode, int *ncidp)
#define NC_CLOBBER
Destroy existing file.