Next: , Previous: NF_INQ_VAR_CHUNKING, Up: Variables


6.6 Set HDF5 Chunk Cache for a Variable: NF_SET_VAR_CHUNK_CACHE

This function changes the chunk cache settings for a variable. The change in cache size happens immediately. This is a property of the open file - it does not persist the next time you open the file.

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

Usage

     nc_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems,
     		       float preemption);
ncid
NetCDF ID, from a previous call to nc_open or nc_create.
varid
Variable ID.
size
The total size of the raw data chunk cache, in megabytes. This should be big enough to hold multiple chunks of data. (Note that the C API uses bytes, but the Fortran APIs uses megabytes to avoid numbers that can't fit in 4-byte integers.)
nelems
The number of chunk slots in the raw data chunk cache hash table. This should be a prime number larger than the number of chunks that will be in the cache.
preemption
The preemtion value must be between 0 and 100 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 100 means fully read chunks are always preempted before other chunks. (The C API uses a float between 0 and 1 for this value).

Return Codes

NF_NOERR
No error.
NF_EINVAL
Preemption must be between zero and 100 (inclusive).

Example

This example is from nf_test/ftst_vars2.F:

           include 'netcdf.inc'
      ...
     C     These will be used to set the per-variable chunk cache.
           integer CACHE_SIZE, CACHE_NELEMS, CACHE_PREEMPTION
           parameter (CACHE_SIZE = 8, CACHE_NELEMS = 571)
           parameter (CACHE_PREEMPTION = 42)
     ...
     C        Set variable caches.
              retval = nf_set_var_chunk_cache(ncid, varid(i), CACHE_SIZE,
          &        CACHE_NELEMS, CACHE_PREEMPTION)
              if (retval .ne. nf_noerr) call handle_err(retval)