Next: , Previous: NF90_DEF_VAR, Up: Variables


6.4 Define Chunking Parameters for a Variable: NF90_DEF_VAR_CHUNKING

The function NF90_DEF_VAR_CHUNKING sets the chunking parameters for a variable in a netCDF-4 file. It can set the chunk sizes to get chunked storage, or it can set the contiguous flag to get contiguous storage.

The total size of a chunk must be less than 4 GiB. That is, the product of all chunksizes and the size of the data (or the size of nc_vlen_t for VLEN types) must be less than 4 GiB.

This function may only be called after the variable is defined, but before nf90_enddef is called. Once the chunking parameters are set for a variable, they cannot be changed.

Usage

       function nf90_def_var_chunking(ncid, varid, storage, chunksizes)
         integer, intent(in) :: ncid
         integer, intent(in) :: varid
         integer, intent(in) :: storage
         integer, dimension(:), intent(in) :: chunksizes
         integer :: nf90_def_var_chunking
ncid
NetCDF ID, from a previous call to NF90_OPEN or NF90_CREATE.
varid
Variable ID.
storage
If NF90_CONTIGUOUS, then contiguous storage is used for this variable. Variables with one or more unlimited dimensions cannot use contiguous storage. If contiguous storage is turned on, the chunksizes parameter is ignored.

If NF90_CHUNKED, then chunked storage is used for this variable. Chunk sizes may be specified with the chunksizes parameter. Default sizes will be used if chunking is required and this function is not called.

chunksizes
An array of chunk sizes. The array must have the one chunksize for each dimension in the variable. If contiguous storage is used, then the chunksizes parameter is ignored.

Errors

NF90_DEF_VAR_CHUNKING returns the value NF90_NOERR if no errors occurred. Otherwise, the returned status indicates an error.

Possible return codes include:

NF90_NOERR
No error.
NF90_BADID
Bad ncid.
NF90_ENOTNC4
Not a netCDF-4 file.
NF90_ENOTVAR
Can't find this variable.
NF90_ELATEDEF
This variable has already been the subject of a NF90_ENDDEF call. In netCDF-4 files NF90_ENDDEF will be called automatically for any data read or write. Once enddef has been called, it is impossible to set the chunking for a variable.
NF90_ENOTINDEFINE
Not in define mode. This is returned for netCDF classic or 64-bit offset files, or for netCDF-4 files, when they were been created with NF90_STRICT_NC3 flag. (see NF90_CREATE).
NF90_ESTRICTNC3
Trying to create a var some place other than the root group in a netCDF file with NF90_STRICT_NC3 turned on.

Example