Next: , Previous: nc_set_var_chunk_cache, Up: Variables


6.9 Get the HDF5 Chunk Cache Settings for a Variable: nc_get_var_chunk_cache

This function gets the current chunk cache settings for a variable in a netCDF-4/HDF5 file.

For more information, see the documentation for the H5Pget_cache() function in the HDF5 library at the HDF5 website: http://hdfgroup.org/HDF5/.

Usage

     int nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp,
                                float *preemptionp);
ncid
NetCDF ID, from a previous call to nc_open or nc_create.
varid
Variable ID.
sizep
The total size of the raw data chunk cache, in bytes, will be put here. If NULL, will be ignored.
nelemsp
The number of chunk slots in the raw data chunk cache hash table will be put here. If NULL, will be ignored.
preemptionp
The preemption will be put here. The preemtion value is between 0 and 1 inclusive and indicates how much chunks that have been fully read are favored for preemption. A value of zero means fully read chunks are treated no differently than other chunks (the preemption is strictly LRU) while a value of one means fully read chunks are always preempted before other chunks. If NULL, will be ignored.

Return Codes

NC_NOERR
No error.

Example

This example is from libsrc4/tst_vars2.c:

     #include <netcdf.h>
        ...
           /* 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, DIM5_NAME, DIM5_LEN, &dimids[0])) ERR;
           if (nc_def_var(ncid, VAR_NAME5, NC_INT, NDIMS5, dimids, &varid)) ERR;
           if (nc_def_var_chunking(ncid, varid, NC_CHUNKED, chunksize)) ERR;
           if (nc_set_var_chunk_cache(ncid, varid, CACHE_SIZE, CACHE_NELEMS,
                                      CACHE_PREEMPTION)) ERR;
        ...
           if (nc_get_var_chunk_cache(ncid, varid, &cache_size_in, &cache_nelems_in,
     				 &cache_preemption_in)) ERR;
           if (cache_size_in != CACHE_SIZE || cache_nelems_in != CACHE_NELEMS ||
     	  cache_preemption_in != CACHE_PREEMPTION) ERR;
     
        ...