6.12 Define Compression Parameters for a Variable: nc_def_var_deflate
The function nc_def_var_deflate sets the deflate parameters for a
variable in a netCDF-4 file.
This function must be called after the variable is defined, but before
nc_enddef is called.
This does not work with scalar variables.
Usage
nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
int deflate_level);
ncid
- NetCDF ID, from a previous call to nc_open or nc_create.
varid
- Variable ID.
shuffle
- If non-zero, turn on the shuffle filter.
deflate
- If non-zero, turn on the deflate filter at the level specified by the
deflate_level parameter.
deflate_level
- If the deflate parameter is non-zero, set the deflate level to this
value. Must be between 0 and 9.
Errors
nc_def_var_deflate returns the value NC_NOERR if no errors
occurred. Otherwise, the returned status indicates an error.
Possible return codes include:
NC_NOERR
- No error.
NC_BADID
- Bad ncid.
NC_ENOTNC4
- Not a netCDF-4 file.
NC_ENOTVAR
- Can't find this variable.
NC_ELATEDEF
- This variable has already been the subject of a nc_enddef call. In
netCDF-4 files nc_enddef will be called automatically for any data
read or write. Once enddef has been called, it is impossible to set
the deflate for a variable.
NC_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
NC_STRICT_NC3 flag. (see nc_create).
NC_EPERM
- Attempt to create object in read-only file.
NC_EINVAL
- Invalid deflate_level. The deflate level must be between 0 and 9,
inclusive.
Example