NetCDF 4.9.3
Loading...
Searching...
No Matches
nc4var.c File Reference
#include "config.h"
#include "nc4internal.h"
#include "nc4dispatch.h"
#include <math.h>

Go to the source code of this file.

Macros

#define BIT_XPL_NBR_SGN_DBL   (52)
 Used in quantize code.
 
#define BIT_XPL_NBR_SGN_FLT   (23)
 Used in quantize code.
 
#define DEFAULT_1D_UNLIM_SIZE   (4096)
 
#define M_LN10   2.30258509299404568402
 log_e 10
 
#define M_LN2   0.69314718055994530942
 log_e 2
 

Functions

int nc4_check_chunksizes (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, const size_t *chunksizes)
 
int nc4_convert_type (const void *src, void *dest, const nc_type src_type, const nc_type dest_type, const size_t len, int *range_error, const void *fill_value, int strict_nc3, int quantize_mode, int nsd)
 
int nc4_find_default_chunksizes2 (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
 
int nc4_get_default_atomic_fill_value (nc_type xtype, void *fill_value)
 
int nc4_get_default_fill_value (NC_TYPE_INFO_T *tinfo, void *fill_value)
 
int nc4_get_fill_value (NC_FILE_INFO_T *h5, NC_VAR_INFO_T *var, void **fillp)
 
int nc4_get_typelen_mem (NC_FILE_INFO_T *h5, nc_type xtype, size_t *len)
 
int NC4_get_var_chunk_cache (int ncid, int varid, size_t *sizep, size_t *nelemsp, float *preemptionp)
 
int NC4_inq_var_all (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp, int *shufflep, int *deflatep, int *deflate_levelp, int *fletcher32p, int *storagep, size_t *chunksizesp, int *no_fill, void *fill_valuep, int *endiannessp, unsigned int *idp, size_t *nparamsp, unsigned int *params)
 
int NC4_inq_varid (int ncid, const char *name, int *varidp)
 
int NC4_var_par_access (int ncid, int varid, int par_access)
 
int nc_get_var_chunk_cache_ints (int ncid, int varid, int *sizep, int *nelemsp, int *preemptionp)
 
int nc_inq_var_chunking_ints (int ncid, int varid, int *storagep, int *chunksizesp)
 

Detailed Description

This file is part of netcdf-4, a netCDF-like interface for HDF5, or a HDF5 backend for netCDF, depending on your point of view. This file handles the NetCDF-4 variable functions.

Author
Ed Hartnett, Dennis Heimbigner, Ward Fisher

Definition in file nc4var.c.

Macro Definition Documentation

◆ BIT_XPL_NBR_SGN_DBL

#define BIT_XPL_NBR_SGN_DBL   (52)

Used in quantize code.

Number of explicit bits in significand for doubles. Bits 0-51 of DP significands are explicit. Bit 52 is implicitly 1. Currently redundant with NC_QUANTIZE_MAX_DOUBLE_NSB and with limits.h/climit (DBL_MANT_DIG-1)

Definition at line 44 of file nc4var.c.

◆ BIT_XPL_NBR_SGN_FLT

#define BIT_XPL_NBR_SGN_FLT   (23)

Used in quantize code.

Number of explicit bits in significand for floats. Bits 0-22 of SP significands are explicit. Bit 23 is implicitly 1. Currently redundant with NC_QUANTIZE_MAX_FLOAT_NSB and with limits.h/climit (FLT_MANT_DIG-1)

Definition at line 38 of file nc4var.c.

◆ DEFAULT_1D_UNLIM_SIZE

#define DEFAULT_1D_UNLIM_SIZE   (4096)

Default size for unlimited dim chunksize.

Definition at line 22 of file nc4var.c.

◆ M_LN10

#define M_LN10   2.30258509299404568402

log_e 10

Definition at line 28 of file nc4var.c.

◆ M_LN2

#define M_LN2   0.69314718055994530942

log_e 2

Definition at line 31 of file nc4var.c.

Function Documentation

◆ nc4_check_chunksizes()

int nc4_check_chunksizes ( NC_GRP_INFO_T * grp,
NC_VAR_INFO_T * var,
const size_t * chunksizes )

Check a set of chunksizes to see if they specify a chunk that is too big.

Parameters
grpPointer to the group info.
varPointer to the var info.
chunksizesArray of chunksizes to check.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_ENOTVAR Invalid variable ID.
NC_EBADCHUNK Bad chunksize.

Definition at line 1679 of file nc4var.c.

◆ nc4_convert_type()

int nc4_convert_type ( const void * src,
void * dest,
const nc_type src_type,
const nc_type dest_type,
const size_t len,
int * range_error,
const void * fill_value,
int strict_nc3,
int quantize_mode,
int nsd )

Copy data from one buffer to another, performing appropriate data conversion.

This function will copy data from one buffer to another, in accordance with the types. Range errors will be noted, and the fill value used (or the default fill value if none is supplied) for values that overflow the type.

This function applies quantization to float and double data, if desired. The code to do this is derived from the corresponding filter in the CCR project (e.g., https://github.com/ccr/ccr/blob/master/hdf5_plugins/BITGROOM/src/H5Zbitgroom.c).

Parameters
srcPointer to source of data.
destPointer that gets data.
src_typeType ID of source data.
dest_typeType ID of destination data.
lenNumber of elements of data to copy.
range_errorPointer that gets 1 if there was a range error.
fill_valueThe fill value.
strict_nc3Non-zero if strict model in effect.
quantize_modeMay be NC_NOQUANTIZE, NC_QUANTIZE_BITGROOM, NC_QUANTIZE_GRANULARBR, or NC_QUANTIZE_BITROUND.
nsdNumber of significant digits for quantize. Ignored unless quantize_mode is NC_QUANTIZE_BITGROOM, NC_QUANTIZE_GRANULARBR, or NC_QUANTIZE_BITROUND
Returns
NC_NOERR No error.
NC_EBADTYPE Type not found.
Author
Ed Hartnett, Dennis Heimbigner

Definition at line 484 of file nc4var.c.

◆ nc4_find_default_chunksizes2()

int nc4_find_default_chunksizes2 ( NC_GRP_INFO_T * grp,
NC_VAR_INFO_T * var )

Determine some default chunksizes for a variable.

Parameters
grpPointer to the group info.
varPointer to the var info.
Returns
NC_NOERR for success
NC_EBADID Bad ncid.
NC_ENOTVAR Invalid variable ID.
Author
Ed Hartnett, Dennis Heimbigner

Definition at line 1713 of file nc4var.c.

◆ nc4_get_default_atomic_fill_value()

int nc4_get_default_atomic_fill_value ( nc_type xtype,
void * fill_value )

Get the default fill value for an atomic type. Memory for fill_value must already be allocated, or you are DOOMED!

Parameters
xtypetype id
fill_valuePointer that gets the default fill value.
Returns
NC_NOERR No error.
NC_EINVAL Can't find atomic type.
Author
Ed Hartnett

Definition at line 1874 of file nc4var.c.

◆ nc4_get_default_fill_value()

int nc4_get_default_fill_value ( NC_TYPE_INFO_T * tinfo,
void * fill_value )

Get the default fill value for an atomic type. Memory for fill_value must already be allocated, or you are DOOMED!

Parameters
tinfotype object
fill_valuePointer that gets the default fill value.
Returns
NC_NOERR No error.
NC_EINVAL Can't find atomic type.
Author
Ed Hartnett

Definition at line 1842 of file nc4var.c.

◆ nc4_get_fill_value()

int nc4_get_fill_value ( NC_FILE_INFO_T * h5,
NC_VAR_INFO_T * var,
void ** fillp )

What fill value should be used for a variable?

Parameters
h5Pointer to HDF5 file info struct.
varPointer to variable info struct.
fillpPointer that gets pointer to fill value.
Returns
NC_NOERR No error.
NC_ENOMEM Out of memory.
Author
Ed Hartnett

Definition at line 1529 of file nc4var.c.

◆ nc4_get_typelen_mem()

int nc4_get_typelen_mem ( NC_FILE_INFO_T * h5,
nc_type xtype,
size_t * len )

Get the length, in bytes, of one element of a type in memory.

Parameters
h5Pointer to HDF5 file info struct.
xtypeNetCDF type ID.
lenPointer that gets length in bytes.
Returns
NC_NOERR No error.
NC_EBADTYPE Type not found.
Author
Ed Hartnett

Definition at line 1611 of file nc4var.c.

◆ NC4_get_var_chunk_cache()

int NC4_get_var_chunk_cache ( int ncid,
int varid,
size_t * sizep,
size_t * nelemsp,
float * preemptionp )

This is called by nc_get_var_chunk_cache(). Get chunk cache size for a variable.

Parameters
ncidFile ID.
varidVariable ID.
sizepGets size in bytes of cache.
nelemspGets number of element slots in cache.
preemptionpGets cache swapping setting.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_ENOTVAR Invalid variable ID.
NC_ENOTNC4 Not a netCDF-4 file.
Author
Ed Hartnett

Definition at line 72 of file nc4var.c.

◆ NC4_inq_var_all()

int NC4_inq_var_all ( int ncid,
int varid,
char * name,
nc_type * xtypep,
int * ndimsp,
int * dimidsp,
int * nattsp,
int * shufflep,
int * deflatep,
int * deflate_levelp,
int * fletcher32p,
int * storagep,
size_t * chunksizesp,
int * no_fill,
void * fill_valuep,
int * endiannessp,
unsigned int * idp,
size_t * nparamsp,
unsigned int * params )

Get all the information about a variable. Pass NULL for whatever you don't care about. This is the internal function called by nc_inq_var(), nc_inq_var_deflate(), nc_inq_var_fletcher32(), nc_inq_var_chunking(), nc_inq_var_chunking_ints(), nc_inq_var_fill(), nc_inq_var_endian(), nc_inq_var_filter(), and nc_inq_var_szip().

Parameters
ncidFile ID.
varidVariable ID.
nameGets name.
xtypepGets type.
ndimspGets number of dims.
dimidspGets array of dim IDs.
nattspGets number of attributes.
shufflepGets shuffle setting.
deflatepGets deflate setting.
deflate_levelpGets deflate level.
fletcher32pGets fletcher32 setting.
storagepGets storage setting.
chunksizespGets chunksizes.
no_fillGets fill mode.
fill_valuepGets fill value.
endiannesspGets one of NC_ENDIAN_BIG NC_ENDIAN_LITTLE NC_ENDIAN_NATIVE
idpPointer to memory to store filter id.
nparamspPointer to memory to store filter parameter count.
paramsPointer to vector of unsigned integers into which to store filter parameters.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_ENOTVAR Bad varid.
NC_ENOMEM Out of memory.
NC_EINVAL Invalid input.
Author
Ed Hartnett, Dennis Heimbigner

Definition at line 179 of file nc4var.c.

◆ NC4_inq_varid()

int NC4_inq_varid ( int ncid,
const char * name,
int * varidp )

Find the ID of a variable, from the name. This function is called by nc_inq_varid().

Parameters
ncidFile ID.
nameName of the variable.
varidpGets variable ID.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_ENOTVAR Bad variable ID.

Definition at line 351 of file nc4var.c.

◆ NC4_var_par_access()

int NC4_var_par_access ( int ncid,
int varid,
int par_access )

This function will change the parallel access of a variable from independent to collective.

Parameters
ncidFile ID.
varidVariable ID.
par_accessNC_COLLECTIVE or NC_INDEPENDENT.
Returns
NC_NOERR No error.
NC_EBADID Invalid ncid passed.
NC_ENOTVAR Invalid varid passed.
NC_ENOPAR LFile was not opened with nc_open_par/nc_create_par.
NC_EINVAL Invalid par_access specified.
NC_NOERR for success
Author
Ed Hartnett, Dennis Heimbigner

Definition at line 403 of file nc4var.c.

◆ nc_get_var_chunk_cache_ints()

int nc_get_var_chunk_cache_ints ( int ncid,
int varid,
int * sizep,
int * nelemsp,
int * preemptionp )

A wrapper for NC4_get_var_chunk_cache(), we need this version for fortran.

Parameters
ncidFile ID.
varidVariable ID.
sizepGets size in MB of cache.
nelemspGets number of element slots in cache.
preemptionpGets cache swapping setting.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_ENOTVAR Invalid variable ID.
NC_ENOTNC4 Not a netCDF-4 file.
Author
Ed Hartnett

Definition at line 120 of file nc4var.c.

◆ nc_inq_var_chunking_ints()

int nc_inq_var_chunking_ints ( int ncid,
int varid,
int * storagep,
int * chunksizesp )

Inquire about chunking settings for a var. This is used by the fortran API.

Parameters
ncidFile ID.
varidVariable ID.
storagepGets contiguous setting.
chunksizespGets chunksizes.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_ENOTVAR Invalid variable ID.
NC_EINVAL Invalid input
NC_ENOMEM Out of memory.
Author
Ed Hartnett

Definition at line 301 of file nc4var.c.