23 #define FILE_NAME "simple_nc4.nc"
32 #define ERR(e) {printf("Error: %s\n", nc_strerror(e)); exit(ERRCODE);}
39 int ncid, varid1, varid2, grp1id, grp2id;
41 unsigned long long data_in[NX][NY];
52 struct s1 compound_data[NX][NY];
80 if ((retval =
nc_get_var(grp2id, varid2, &compound_data[0][0])))
84 for (x = 0; x < NX; x++)
85 for (y = 0; y < NY; y++)
87 if (data_in[x][y] != x * NY + y ||
88 compound_data[x][y].i1 != 42 ||
89 compound_data[x][y].i2 != -42)
97 printf(
"*** SUCCESS reading example file %s!\n", FILE_NAME);
EXTERNL int nc_close(int ncid)
Close an open netCDF dataset.
EXTERNL int nc_open(const char *path, int mode, int *ncidp)
Open an existing netCDF file.
EXTERNL int nc_inq_ncid(int ncid, const char *name, int *grp_ncid)
Return the group ID for a group given the name.
EXTERNL int nc_inq_varid(int ncid, const char *name, int *varidp)
Find the ID of a variable, from the name.
EXTERNL int nc_get_var(int ncid, int varid, void *ip)
Read an entire variable in one call.
int nc_get_var_ulonglong(int ncid, int varid, unsigned long long *ip)
Read an entire variable in one call.
Main header file for the C API.
#define NC_NOWRITE
Set read-only access for nc_open().