20 #define FILE_NAME "simple_nc4.nc"
30 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
37 int ncid, x_dimid, y_dimid, varid1, varid2, grp1id, grp2id,
typeid;
42 unsigned long long data_out[NX][NY];
53 struct s1 compound_data[NX][NY];
56 for (x = 0; x < NX; x++)
57 for (y = 0; y < NY; y++)
59 data_out[x][y] = x * NY + y;
60 compound_data[x][y].i1 = 42;
61 compound_data[x][y].i2 = -42;
71 if ((retval =
nc_def_dim(ncid,
"x", NX, &x_dimid)))
73 if ((retval =
nc_def_dim(ncid,
"y", NY, &y_dimid)))
81 if ((retval = nc_def_grp(ncid,
"grp1", &grp1id)))
83 if ((retval = nc_def_grp(ncid,
"grp2", &grp2id)))
102 offsetof(
struct s1, i1),
NC_INT))
105 offsetof(
struct s1, i2),
NC_INT))
110 if ((retval =
nc_def_var(grp2id,
"data",
typeid, NDIMS,
116 if ((retval =
nc_put_var(grp2id, varid2, &compound_data[0][0])))
123 printf(
"*** SUCCESS writing example file simple_nc4.nc!\n");