NetCDF  4.8.0
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 DEFAULT_1D_UNLIM_SIZE   (4096)
 

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 nc4_find_default_chunksizes2 (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
 
int nc4_get_default_fill_value (nc_type typecode, 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

◆ DEFAULT_1D_UNLIM_SIZE

#define DEFAULT_1D_UNLIM_SIZE   (4096)

Default size for unlimited dim chunksize.

Definition at line 22 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 1485 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 
)

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.

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.
Returns
NC_NOERR No error.
NC_EBADTYPE Type not found.
Author
Ed Hartnett, Dennis Heimbigner

Definition at line 465 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 1519 of file nc4var.c.

◆ nc4_get_default_fill_value()

int nc4_get_default_fill_value ( nc_type  typecode,
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
type_infoPointer to type info struct.
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 1345 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 1264 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 1417 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 41 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 148 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 342 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_var.
NC_EINVAL Invalid par_access specified.
NC_NOERR for success
Author
Ed Hartnett, Dennis Heimbigner

Definition at line 394 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 89 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 292 of file nc4var.c.