Defining a Variable-related Function
Function Syntax
- Define a new variable.
nc_def_var(int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
- Set a new filter.
nc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, const unsigned int *params)
- Set the zlib compression and shuffle settings for a variable in a NetCDF/HDF5 file.
nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflate_level)
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
ncid |
File ID |
Non-negative integer |
Input |
*name |
Variable name |
Non-empty string of less than 256 bytes |
Input |
xtype |
Variable data type |
Non-negative integer |
Input |
ndims |
Number of dimensions |
[1, 1024] |
Input |
*dimidsp |
Dimension ID list |
Non-empty |
Input |
*varidp |
Pointer to the variable ID |
Non-empty |
Input |
id |
Filter ID |
Integer |
Input |
nparams |
Number of parameters |
Non-empty |
Input |
*params |
Pointer to the parameters |
Non-empty |
Input |
varid |
Variable ID |
Non-negative integer |
Input |
shuffle |
Shuffle parameter |
Non-empty |
Input |
deflate |
Compression parameter |
Non-empty |
Input |
deflate_level |
Compression level |
Non-empty |
Input |
Return Value
- Success: NC_NOERR
- Failure: An error code is returned.
Error Code
Error Code |
Description |
|---|---|
NC_EBADID |
Invalid ncid |
NC_EBADTYPE |
Invalid data type |
NC_EINVAL |
Invalid argument |
Notes
- Currently, only the following data types are supported: NC_BYTE, NC_UBYTE, NC_CHAR, NC_SHORT, NC_USHORT, NC_INT, NC_UINT, NC_INT64, NC_UINT64, NC_FLOAT, and NC_DOUBLE.
- The memory size of the dimension ID list must match the number of dimensions. The memory size is not checked.