nc_inq_var_chunking
The function nc_inq_var_chunking returns the chunking settings for a variable in a netCDF-4 file.
int nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp);
ncid
varid
storagep
*chunksizesp
nc_inq_var_chunking returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error.
Possible return codes include:
NC_NOERR
NC_BADID
NC_ENOTNC4
NC_ENOTVAR
This example is from libsrc4/tst_vars2.c in which a variable with contiguous storage is created, and then checked with nc_inq_var_chunking:
printf("**** testing contiguous storage..."); { #define NDIMS6 1 #define DIM6_NAME "D5" #define VAR_NAME6 "V5" #define DIM6_LEN 100 int dimids[NDIMS6], dimids_in[NDIMS6]; int varid; int ndims, nvars, natts, unlimdimid; nc_type xtype_in; char name_in[NC_MAX_NAME + 1]; int data[DIM6_LEN], data_in[DIM6_LEN]; size_t chunksize_in[NDIMS6]; int storage_in; int i, d; for (i = 0; i < DIM6_LEN; i++) data[i] = i; /* Create a netcdf-4 file with one dim and one var. */ if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; if (nc_def_dim(ncid, DIM6_NAME, DIM6_LEN, &dimids[0])) ERR; if (dimids[0] != 0) ERR; if (nc_def_var(ncid, VAR_NAME6, NC_INT, NDIMS6, dimids, &varid)) ERR; if (nc_def_var_chunking(ncid, varid, NC_CONTIGUOUS, NULL)) ERR; if (nc_put_var_int(ncid, varid, data)) ERR; /* Check stuff. */ if (nc_inq_var_chunking(ncid, 0, &storage_in, chunksize_in)) ERR; if (storage_in != NC_CONTIGUOUS) ERR;