PIO  2.5.4
Functions
Define a Variable

Define a new variable in the file in C. More...

Functions

int PIOc_def_var (int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
 The PIO-C interface for the NetCDF function nc_def_var. More...
 
int PIOc_def_var_fill (int ncid, int varid, int fill_mode, const void *fill_valuep)
 Set the fill value for a variable. More...
 
int PIOc_def_var_deflate (int ncid, int varid, int shuffle, int deflate, int deflate_level)
 Set deflate (zlib) settings for a variable. More...
 
int PIOc_def_var_chunking (int ncid, int varid, int storage, const PIO_Offset *chunksizesp)
 Set chunksizes for a variable. More...
 
int PIOc_def_var_endian (int ncid, int varid, int endian)
 Set chunksizes for a variable. More...
 
int PIOc_set_chunk_cache (int iosysid, int iotype, PIO_Offset size, PIO_Offset nelems, float preemption)
 Set chunk cache netCDF files to be opened/created. More...
 
int PIOc_get_chunk_cache (int iosysid, int iotype, PIO_Offset *sizep, PIO_Offset *nelemsp, float *preemptionp)
 Get current file chunk cache settings from HDF5. More...
 
int PIOc_set_var_chunk_cache (int ncid, int varid, PIO_Offset size, PIO_Offset nelems, float preemption)
 Set chunksizes for a variable. More...
 

Detailed Description

Define a new variable in the file in C.

Function Documentation

◆ PIOc_def_var()

int PIOc_def_var ( int  ncid,
const char *  name,
nc_type  xtype,
int  ndims,
const int *  dimidsp,
int *  varidp 
)

The PIO-C interface for the NetCDF function nc_def_var.

This routine is called collectively by all tasks in the communicator ios.union_comm. For more information on the underlying NetCDF commmand please read about this function in the NetCDF documentation at: http://www.unidata.ucar.edu/software/netcdf/docs/group__variables.html

Parameters
ncidthe ncid of the open file, obtained from PIOc_openfile() or PIOc_createfile().
namethe variable name.
xtypethe PIO_TYPE of the variable.
ndimsthe number of dimensions.
dimidsppointer to array of dimension IDs.
varidpa pointer that will get the variable ID.
Returns
PIO_NOERR for success, error code otherwise.
Author
Jim Edwards, Ed Hartnett

◆ PIOc_def_var_chunking()

int PIOc_def_var_chunking ( int  ncid,
int  varid,
int  storage,
const PIO_Offset chunksizesp 
)

Set chunksizes for a variable.

This function only applies to netCDF-4 files. When used with netCDF classic files, the error PIO_ENOTNC4 will be returned.

Chunksizes have important performance repercussions. NetCDF attempts to choose sensible chunk sizes by default, but for best performance check chunking against access patterns.

See the netCDF variable documentation for details about the operation of this function.

Parameters
ncidthe ncid of the open file.
varidthe ID of the variable to set chunksizes for.
storageNC_CONTIGUOUS or NC_CHUNKED.
chunksizespan array of chunksizes. Must have a chunksize for every variable dimension.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Ed Hartnett

◆ PIOc_def_var_deflate()

int PIOc_def_var_deflate ( int  ncid,
int  varid,
int  shuffle,
int  deflate,
int  deflate_level 
)

Set deflate (zlib) settings for a variable.

This function only applies to netCDF-4 files. When used with netCDF classic files, the error PIO_ENOTNC4 will be returned.

See the netCDF variable documentation for details about the operation of this function.

Parameters
ncidthe ncid of the open file.
varidthe ID of the variable.
shufflenon-zero to turn on shuffle filter.
deflatenon-zero to turn on zlib compression for this variable.
deflate_level1 to 9, with 1 being faster and 9 being more compressed.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Ed Hartnett

◆ PIOc_def_var_endian()

int PIOc_def_var_endian ( int  ncid,
int  varid,
int  endian 
)

Set chunksizes for a variable.

This function only applies to netCDF-4 files. When used with netCDF classic files, the error PIO_ENOTNC4 will be returned.

See the netCDF variable documentation for details about the operation of this function.

Chunksizes have important performance repercussions. NetCDF attempts to choose sensible chunk sizes by default, but for best performance check chunking against access patterns.

Parameters
ncidthe ncid of the open file.
varidthe ID of the variable to set chunksizes for.
endianNC_ENDIAN_NATIVE, NC_ENDIAN_LITTLE, or NC_ENDIAN_BIG.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Ed Hartnett

◆ PIOc_def_var_fill()

int PIOc_def_var_fill ( int  ncid,
int  varid,
int  fill_mode,
const void *  fill_valuep 
)

Set the fill value for a variable.

See the netCDF variable documentation for details about the operation of this function.

When the fill mode for the file is NC_FILL, then fill values are used for missing data. This function sets the fill value to be used for a variable. If no specific fill value is set (as a _FillValue attribute), then the default fill values from netcdf.h are used.

NetCDF-4 and pnetcdf files allow setting fill_mode (to NC_FILL or NC_NOFILL) on a per-variable basis. NetCDF classic only allows the fill_mode setting to be set for the whole file. For this function, the fill_mode parameter is ignored for classic files. Set the file-level fill mode with PIOc_set_fill().

Parameters
ncidthe ncid of the open file.
varidthe ID of the variable to set chunksizes for.
fill_modefill mode for this variable (NC_FILL or NC_NOFILL)
fill_valueppointer to the fill value to be used if fill_mode is set to NC_FILL.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Jim Edwards, Ed Hartnett

◆ PIOc_get_chunk_cache()

int PIOc_get_chunk_cache ( int  iosysid,
int  iotype,
PIO_Offset sizep,
PIO_Offset nelemsp,
float *  preemptionp 
)

Get current file chunk cache settings from HDF5.

This function has no effect on netCDF classic files. Calling this function with iotype of PIO_IOTYPE_PNETCDF or PIO_IOTYPE_NETCDF returns an error.

The file chunk cache for HDF5 can be set, and will apply for any files opened or created until the program ends, or the settings are changed again. The cache settings apply only to the open file. They do not persist with the file, and must be set each time the file is opened, before it is opened, if they are to have effect.

See the netCDF variable documentation for details about the operation of this function.

Chunksizes have important performance repercussions. NetCDF attempts to choose sensible chunk sizes by default, but for best performance check chunking against access patterns.

Parameters
iosysidthe IO system ID.
iotypethe iotype of files to be created or opened.
sizepgets the size of file cache.
nelemspgets the number of elements in file cache.
preemptionpgets the preemption setting for file cache.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Ed Hartnett

◆ PIOc_set_chunk_cache()

int PIOc_set_chunk_cache ( int  iosysid,
int  iotype,
PIO_Offset  size,
PIO_Offset  nelems,
float  preemption 
)

Set chunk cache netCDF files to be opened/created.

This function only applies to netCDF-4 files. When used with netCDF classic files, the error PIO_ENOTNC4 will be returned.

The file chunk cache for HDF5 can be set, and will apply for any files opened or created until the program ends, or the settings are changed again. The cache settings apply only to the open file. They do not persist with the file, and must be set each time the file is opened, before it is opened, if they are to have effect.

See the netCDF variable documentation for details about the operation of this function.

Parameters
iosysidthe IO system ID.
iotypethe iotype of files to be created or opened.
sizesize of file cache.
nelemsnumber of elements in file cache.
preemptionpreemption setting for file cache.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Ed Hartnett

◆ PIOc_set_var_chunk_cache()

int PIOc_set_var_chunk_cache ( int  ncid,
int  varid,
PIO_Offset  size,
PIO_Offset  nelems,
float  preemption 
)

Set chunksizes for a variable.

This function only applies to netCDF-4 files. When used with netCDF classic files, the error PIO_ENOTNC4 will be returned.

See the netCDF variable documentation for details about the operation of this function.

Chunksizes have important performance repercussions. NetCDF attempts to choose sensible chunk sizes by default, but for best performance check chunking against access patterns.

Parameters
ncidthe ncid of the open file.
varidthe ID of the variable to set chunksizes for.
sizethe size in bytes for the cache.
nelemsthe number of elements in the cache.
preemptionthe cache preemption value.
Returns
PIO_NOERR for success, otherwise an error code.
Author
Ed Hartnett