Loading...
Searching...
No Matches
dvarinq.c
Go to the documentation of this file.
/* Copyright 2018 University Corporation for Atmospheric
Research/Unidata. See COPYRIGHT file for more info. */
#include "config.h"
#include "netcdf.h"
#include "netcdf_filter.h"
#include "ncdispatch.h"
#include "nc4internal.h"
#ifdef USE_HDF5
#include <hdf5.h>
#endif /* USE_HDF5 */
/* All these functions are part of this named group... */
int
nc_inq_varid(int ncid, const char *name, int *varidp)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->inq_varid(ncid, name, varidp);
}
int
nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep,
int *ndimsp, int *dimidsp, int *nattsp)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var);
return ncp->dispatch->inq_var_all(ncid, varid, name, xtypep, ndimsp,
dimidsp, nattsp, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL,NULL,NULL);
}
int
nc_inq_varname(int ncid, int varid, char *name)
{
return nc_inq_var(ncid, varid, name, NULL, NULL,
NULL, NULL);
}
int
nc_inq_vartype(int ncid, int varid, nc_type *typep)
{
return nc_inq_var(ncid, varid, NULL, typep, NULL,
NULL, NULL);
}
int
nc_inq_varndims(int ncid, int varid, int *ndimsp)
{
return nc_inq_var(ncid, varid, NULL, NULL, ndimsp, NULL, NULL);
}
int
nc_inq_vardimid(int ncid, int varid, int *dimidsp)
{
return nc_inq_var(ncid, varid, NULL, NULL, NULL,
dimidsp, NULL);
}
int
nc_inq_varnatts(int ncid, int varid, int *nattsp)
{
if (varid == NC_GLOBAL)
return nc_inq_natts(ncid,nattsp);
/*else*/
return nc_inq_var(ncid, varid, NULL, NULL, NULL, NULL,
nattsp);
}
int
nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp)
{
NC* ncp;
size_t nparams;
unsigned int params[4];
int deflating = 0;
int stat;
stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_deflate);
/* Verify id and nparams */
stat = nc_inq_var_filter_info(ncid,varid,H5Z_FILTER_DEFLATE,&nparams,params);
switch (stat) {
case NC_ENOFILTER: deflating = 0; stat = NC_NOERR; break;
case NC_NOERR: deflating = 1; break;
case NC_ENOTNC4:
/* As a special case, to support behavior already coded into user
* applications, handle classic format files by reporting no
* deflation. */
if (shufflep)
*shufflep = 0;
if (deflatep)
*deflatep = 0;
if (deflate_levelp)
*deflate_levelp = 0;
return NC_NOERR;
break;
default: return stat;
}
if(deflatep) *deflatep = deflating;
if(deflating) {
if(nparams != 1)
return NC_EFILTER; /* bad # params */
/* Param[0] should be level */
if(deflate_levelp) *deflate_levelp = (int)params[0];
} else if (deflate_levelp)
*deflate_levelp = 0;
/* also get the shuffle state */
if(!shufflep)
return NC_NOERR;
return ncp->dispatch->inq_var_all(
ncid, varid,
NULL, /*name*/
NULL, /*xtypep*/
NULL, /*ndimsp*/
NULL, /*dimidsp*/
NULL, /*nattsp*/
shufflep, /*shufflep*/
NULL, /*deflatep*/
NULL, /*deflatelevelp*/
NULL, /*fletcher32p*/
NULL, /*contiguousp*/
NULL, /*chunksizep*/
NULL, /*nofillp*/
NULL, /*fillvaluep*/
NULL, /*endianp*/
NULL, NULL, NULL
);
}
int
nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
{
NC* ncp;
int stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_fletcher32);
return ncp->dispatch->inq_var_all(
ncid, varid,
NULL, /*name*/
NULL, /*xtypep*/
NULL, /*ndimsp*/
NULL, /*dimidsp*/
NULL, /*nattsp*/
NULL, /*shufflep*/
NULL, /*deflatep*/
NULL, /*deflatelevelp*/
fletcher32p, /*fletcher32p*/
NULL, /*contiguousp*/
NULL, /*chunksizep*/
NULL, /*nofillp*/
NULL, /*fillvaluep*/
NULL, /*endianp*/
NULL, NULL, NULL
);
}
int
nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
{
NC *ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_chunking);
return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, storagep,
chunksizesp, NULL, NULL, NULL,
NULL, NULL, NULL);
}
int
nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
{
NC* ncp;
int stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_fill);
return ncp->dispatch->inq_var_all(
ncid,varid,
NULL, /*name*/
NULL, /*xtypep*/
NULL, /*ndimsp*/
NULL, /*dimidsp*/
NULL, /*nattsp*/
NULL, /*shufflep*/
NULL, /*deflatep*/
NULL, /*deflatelevelp*/
NULL, /*fletcher32p*/
NULL, /*contiguousp*/
NULL, /*chunksizep*/
no_fill, /*nofillp*/
fill_valuep, /*fillvaluep*/
NULL, /*endianp*/
NULL, NULL, NULL
);
}
int
nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp)
{
NC* ncp;
int stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_quantize);
/* Using NC_GLOBAL is illegal. */
if (varid == NC_GLOBAL) return NC_EGLOBAL;
return ncp->dispatch->inq_var_quantize(ncid, varid,
quantize_modep, nsdp);
}
int
nc_inq_var_endian(int ncid, int varid, int *endianp)
{
NC* ncp;
int stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_endian);
return ncp->dispatch->inq_var_all(
ncid, varid,
NULL, /*name*/
NULL, /*xtypep*/
NULL, /*ndimsp*/
NULL, /*dimidsp*/
NULL, /*nattsp*/
NULL, /*shufflep*/
NULL, /*deflatep*/
NULL, /*deflatelevelp*/
NULL, /*fletcher32p*/
NULL, /*contiguousp*/
NULL, /*chunksizep*/
NULL, /*nofillp*/
NULL, /*fillvaluep*/
endianp, /*endianp*/
NULL, NULL, NULL);
}
int
nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
{
#ifndef USE_NETCDF4
return NC_ENOTNC4;
#else
NC* ncp;
int stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_unlimdims);
return ncp->dispatch->inq_unlimdims(ncid, nunlimdimsp,
unlimdimidsp);
#endif
}
int
nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
{
NC* ncp;
size_t nparams;
unsigned int params[4];
int stat = NC_check_id(ncid,&ncp);
if(stat != NC_NOERR) return stat;
TRACE(nc_inq_var_szip);
/* Verify id and nparams */
stat = nc_inq_var_filter_info(ncid,varid,H5Z_FILTER_SZIP,&nparams,params);
switch (stat) {
case NC_NOERR:
if(nparams < 2)
return NC_EFILTER; /* bad # params */
if(nparams > 2)
nparams = 2; /* for compatibility, only return 2 params */
break;
case NC_ENOFILTER:
case NC_ENOTNC4:
/* If the szip filter is not in use, or if this is not a HDF5
* file, return 0 for both parameters. */
params[0] = 0;
params[1] = 0;
stat = NC_NOERR;
break;
default:
return stat;
}
/* Param[0] should be options_mask
Param[1] should be pixels_per_block */
if(options_maskp) *options_maskp = (int)params[0];
if(pixels_per_blockp) *pixels_per_blockp = (int)params[1];
return stat;
}
/* End of named group ...*/
nc_inq_natts
EXTERNL int nc_inq_natts(int ncid, int *nattsp)
Find number of global or group attributes.
Definition dattinq.c:300
nc_inq_var_endian
int nc_inq_var_endian(int ncid, int varid, int *endianp)
Find the endianness of a variable.
Definition dvarinq.c:583
nc_inq_varndims
int nc_inq_varndims(int ncid, int varid, int *ndimsp)
Learn how many dimensions are associated with a variable.
Definition dvarinq.c:202
nc_inq_unlimdims
int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
Definition dvarinq.c:673
nc_inq_varname
int nc_inq_varname(int ncid, int varid, char *name)
Learn the name of a variable.
Definition dvarinq.c:156
nc_inq_var_quantize
int nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp)
Learn whether quantization is on for a variable, and, if so, the NSD setting.
Definition dvarinq.c:546
nc_inq_var_deflate
int nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp)
Learn the shuffle and deflate settings for a variable.
Definition dvarinq.c:295
nc_inq_vartype
int nc_inq_vartype(int ncid, int varid, nc_type *typep)
Learn the type of a variable.
Definition dvarinq.c:178
nc_inq_var_fletcher32
int nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
Learn the checksum settings for a variable.
Definition dvarinq.c:378
nc_inq_varid
int nc_inq_varid(int ncid, const char *name, int *varidp)
Find the ID of a variable, from the name.
Definition dvarinq.c:60
nc_inq_varnatts
int nc_inq_varnatts(int ncid, int varid, int *nattsp)
Learn how many attributes are associated with a variable.
Definition dvarinq.c:249
nc_inq_var_filter_info
EXTERNL int nc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t *nparams, unsigned int *params)
Find the param info about filter (if any) associated with a variable and with specified id.
Definition dfilter.c:98
nc_inq_var
int nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)
Learn about a variable.
Definition dvarinq.c:124
nc_inq_var_szip
int nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
Learn the szip settings of a variable.
Definition dvarinq.c:733
nc_inq_vardimid
int nc_inq_vardimid(int ncid, int varid, int *dimidsp)
Learn the dimension IDs associated with a variable.
Definition dvarinq.c:225
nc_inq_var_chunking
int nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
Get the storage and (for chunked variables) the chunksizes of a variable.
Definition dvarinq.c:466
nc_inq_var_fill
int nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
Learn the fill mode of a variable.
Definition dvarinq.c:502
netcdf.h
Main header file for the C API.
NC_EFILTER
#define NC_EFILTER
Filter operation failed.
Definition netcdf.h:562
nc_inq_unlimdims
EXTERNL int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
Definition dvarinq.c:673
NC_ENOTNC4
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition netcdf.h:540
NC_GLOBAL
#define NC_GLOBAL
Attribute id to put/get a global attribute.
Definition netcdf.h:303
NC_NOERR
#define NC_NOERR
No Error.
Definition netcdf.h:417
NC_EGLOBAL
#define NC_EGLOBAL
Action prohibited on NC_GLOBAL varid.
Definition netcdf.h:472
NC_ENOFILTER
#define NC_ENOFILTER
Filter not defined on variable.
Definition netcdf.h:566
nc_type
int nc_type
The nc_type type is just an int.
Definition netcdf.h:25
netcdf_filter.h