NetCDF 4.10.1
Loading...
Searching...
No Matches
dvarinq.c
Go to the documentation of this file.
1/* Copyright 2018 University Corporation for Atmospheric
2 Research/Unidata. See COPYRIGHT file for more info. */
7
8#include "config.h"
9#include "netcdf.h"
10#include "netcdf_filter.h"
11#include "ncdispatch.h"
12#include "nc4internal.h"
13#ifdef USE_HDF5
14#include <hdf5.h>
15#endif /* USE_HDF5 */
16 /* All these functions are part of this named group... */
21
59int
60nc_inq_varid(int ncid, const char *name, int *varidp)
61{
62 NC* ncp;
63 int stat = NC_check_id(ncid, &ncp);
64 if(stat != NC_NOERR) return stat;
65 return ncp->dispatch->inq_varid(ncid, name, varidp);
66}
67
123int
124nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep,
125 int *ndimsp, int *dimidsp, int *nattsp)
126{
127 NC* ncp;
128 int stat = NC_check_id(ncid, &ncp);
129 if(stat != NC_NOERR) return stat;
130 TRACE(nc_inq_var);
131 return ncp->dispatch->inq_var_all(ncid, varid, name, xtypep, ndimsp,
132 dimidsp, nattsp, NULL, NULL, NULL,
133 NULL, NULL, NULL, NULL, NULL, NULL,
134 NULL,NULL,NULL);
135}
136
155int
156nc_inq_varname(int ncid, int varid, char *name)
157{
158 return nc_inq_var(ncid, varid, name, NULL, NULL,
159 NULL, NULL);
160}
161
177int
178nc_inq_vartype(int ncid, int varid, nc_type *typep)
179{
180 return nc_inq_var(ncid, varid, NULL, typep, NULL,
181 NULL, NULL);
182}
183
201int
202nc_inq_varndims(int ncid, int varid, int *ndimsp)
203{
204 return nc_inq_var(ncid, varid, NULL, NULL, ndimsp, NULL, NULL);
205}
206
224int
225nc_inq_vardimid(int ncid, int varid, int *dimidsp)
226{
227 return nc_inq_var(ncid, varid, NULL, NULL, NULL,
228 dimidsp, NULL);
229}
230
248int
249nc_inq_varnatts(int ncid, int varid, int *nattsp)
250{
251 if (varid == NC_GLOBAL)
252 return nc_inq_natts(ncid,nattsp);
253 /*else*/
254 return nc_inq_var(ncid, varid, NULL, NULL, NULL, NULL,
255 nattsp);
256}
257
294int
295nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp)
296{
297 NC* ncp;
298 size_t nparams;
299 unsigned int params[4];
300 int deflating = 0;
301 int stat;
302
303 stat = NC_check_id(ncid,&ncp);
304 if(stat != NC_NOERR) return stat;
305 TRACE(nc_inq_var_deflate);
306
307 /* Verify id and nparams */
308 stat = nc_inq_var_filter_info(ncid,varid,H5Z_FILTER_DEFLATE,&nparams,params);
309 switch (stat) {
310 case NC_ENOFILTER: deflating = 0; stat = NC_NOERR; break;
311 case NC_NOERR: deflating = 1; break;
312 case NC_ENOTNC4:
313 /* As a special case, to support behavior already coded into user
314 * applications, handle classic format files by reporting no
315 * deflation. */
316 if (shufflep)
317 *shufflep = 0;
318 if (deflatep)
319 *deflatep = 0;
320 if (deflate_levelp)
321 *deflate_levelp = 0;
322 return NC_NOERR;
323 break;
324 default: return stat;
325 }
326 if(deflatep) *deflatep = deflating;
327 if(deflating) {
328 if(nparams != 1)
329 return NC_EFILTER; /* bad # params */
330 /* Param[0] should be level */
331 if(deflate_levelp) *deflate_levelp = (int)params[0];
332 } else if (deflate_levelp)
333 *deflate_levelp = 0;
334 /* also get the shuffle state */
335 if(!shufflep)
336 return NC_NOERR;
337 return ncp->dispatch->inq_var_all(
338 ncid, varid,
339 NULL, /*name*/
340 NULL, /*xtypep*/
341 NULL, /*ndimsp*/
342 NULL, /*dimidsp*/
343 NULL, /*nattsp*/
344 shufflep, /*shufflep*/
345 NULL, /*deflatep*/
346 NULL, /*deflatelevelp*/
347 NULL, /*fletcher32p*/
348 NULL, /*contiguousp*/
349 NULL, /*chunksizep*/
350 NULL, /*nofillp*/
351 NULL, /*fillvaluep*/
352 NULL, /*endianp*/
353 NULL, NULL, NULL
354 );
355}
356
377int
378nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
379{
380 NC* ncp;
381 int stat = NC_check_id(ncid,&ncp);
382 if(stat != NC_NOERR) return stat;
384 return ncp->dispatch->inq_var_all(
385 ncid, varid,
386 NULL, /*name*/
387 NULL, /*xtypep*/
388 NULL, /*ndimsp*/
389 NULL, /*dimidsp*/
390 NULL, /*nattsp*/
391 NULL, /*shufflep*/
392 NULL, /*deflatep*/
393 NULL, /*deflatelevelp*/
394 fletcher32p, /*fletcher32p*/
395 NULL, /*contiguousp*/
396 NULL, /*chunksizep*/
397 NULL, /*nofillp*/
398 NULL, /*fillvaluep*/
399 NULL, /*endianp*/
400 NULL, NULL, NULL
401 );
402}
403
465int
466nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
467{
468 NC *ncp;
469 int stat = NC_check_id(ncid, &ncp);
470 if(stat != NC_NOERR) return stat;
471 TRACE(nc_inq_var_chunking);
472 return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL,
473 NULL, NULL, NULL, NULL, NULL, storagep,
474 chunksizesp, NULL, NULL, NULL,
475 NULL, NULL, NULL);
476}
477
501int
502nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
503{
504 NC* ncp;
505 int stat = NC_check_id(ncid,&ncp);
506
507 if(stat != NC_NOERR) return stat;
508 TRACE(nc_inq_var_fill);
509
510 return ncp->dispatch->inq_var_all(
511 ncid,varid,
512 NULL, /*name*/
513 NULL, /*xtypep*/
514 NULL, /*ndimsp*/
515 NULL, /*dimidsp*/
516 NULL, /*nattsp*/
517 NULL, /*shufflep*/
518 NULL, /*deflatep*/
519 NULL, /*deflatelevelp*/
520 NULL, /*fletcher32p*/
521 NULL, /*contiguousp*/
522 NULL, /*chunksizep*/
523 no_fill, /*nofillp*/
524 fill_valuep, /*fillvaluep*/
525 NULL, /*endianp*/
526 NULL, NULL, NULL
527 );
528}
529
545int
546nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp)
547{
548 NC* ncp;
549 int stat = NC_check_id(ncid,&ncp);
550
551 if(stat != NC_NOERR) return stat;
552 TRACE(nc_inq_var_quantize);
553
554 /* Using NC_GLOBAL is illegal. */
555 if (varid == NC_GLOBAL) return NC_EGLOBAL;
556
557 return ncp->dispatch->inq_var_quantize(ncid, varid,
558 quantize_modep, nsdp);
559}
560
582int
583nc_inq_var_endian(int ncid, int varid, int *endianp)
584{
585 NC* ncp;
586 int stat = NC_check_id(ncid,&ncp);
587 if(stat != NC_NOERR) return stat;
588 TRACE(nc_inq_var_endian);
589 return ncp->dispatch->inq_var_all(
590 ncid, varid,
591 NULL, /*name*/
592 NULL, /*xtypep*/
593 NULL, /*ndimsp*/
594 NULL, /*dimidsp*/
595 NULL, /*nattsp*/
596 NULL, /*shufflep*/
597 NULL, /*deflatep*/
598 NULL, /*deflatelevelp*/
599 NULL, /*fletcher32p*/
600 NULL, /*contiguousp*/
601 NULL, /*chunksizep*/
602 NULL, /*nofillp*/
603 NULL, /*fillvaluep*/
604 endianp, /*endianp*/
605 NULL, NULL, NULL);
606}
607
672int
673nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
674{
675#ifndef USE_NETCDF4
676 return NC_ENOTNC4;
677#else
678 NC* ncp;
679 int stat = NC_check_id(ncid,&ncp);
680 if(stat != NC_NOERR) return stat;
681 TRACE(nc_inq_unlimdims);
682 return ncp->dispatch->inq_unlimdims(ncid, nunlimdimsp,
683 unlimdimidsp);
684#endif
685}
686
732int
733nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
734{
735 NC* ncp;
736 size_t nparams;
737 unsigned int params[4];
738
739 int stat = NC_check_id(ncid,&ncp);
740 if(stat != NC_NOERR) return stat;
741 TRACE(nc_inq_var_szip);
742
743 /* Verify id and nparams */
744 stat = nc_inq_var_filter_info(ncid,varid,H5Z_FILTER_SZIP,&nparams,params);
745 switch (stat) {
746 case NC_NOERR:
747 if(nparams < 2)
748 return NC_EFILTER; /* bad # params */
749 if(nparams > 2)
750 nparams = 2; /* for compatibility, only return 2 params */
751 break;
752 case NC_ENOFILTER:
753 case NC_ENOTNC4:
754 /* If the szip filter is not in use, or if this is not a HDF5
755 * file, return 0 for both parameters. */
756 params[0] = 0;
757 params[1] = 0;
758 stat = NC_NOERR;
759 break;
760 default:
761 return stat;
762 }
763
764 /* Param[0] should be options_mask
765 Param[1] should be pixels_per_block */
766 if(options_maskp) *options_maskp = (int)params[0];
767 if(pixels_per_blockp) *pixels_per_blockp = (int)params[1];
768 return stat;
769}
770 /* End of named group ...*/
EXTERNL int nc_inq_natts(int ncid, int *nattsp)
Find number of global or group attributes.
Definition dattinq.c:300
int nc_inq_var_endian(int ncid, int varid, int *endianp)
Find the endianness of a variable.
Definition dvarinq.c:583
int nc_inq_varndims(int ncid, int varid, int *ndimsp)
Learn how many dimensions are associated with a variable.
Definition dvarinq.c:202
int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
Definition dvarinq.c:673
int nc_inq_varname(int ncid, int varid, char *name)
Learn the name of a variable.
Definition dvarinq.c:156
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
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
int nc_inq_vartype(int ncid, int varid, nc_type *typep)
Learn the type of a variable.
Definition dvarinq.c:178
int nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
Learn the checksum settings for a variable.
Definition dvarinq.c:378
int nc_inq_varid(int ncid, const char *name, int *varidp)
Find the ID of a variable, from the name.
Definition dvarinq.c:60
int nc_inq_varnatts(int ncid, int varid, int *nattsp)
Learn how many attributes are associated with a variable.
Definition dvarinq.c:249
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:95
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
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
int nc_inq_vardimid(int ncid, int varid, int *dimidsp)
Learn the dimension IDs associated with a variable.
Definition dvarinq.c:225
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
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
Main header file for the C API.
#define NC_EFILTER
Filter operation failed.
Definition netcdf.h:562
EXTERNL int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
Definition dvarinq.c:673
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition netcdf.h:540
#define NC_GLOBAL
Attribute id to put/get a global attribute.
Definition netcdf.h:303
#define NC_NOERR
No Error.
Definition netcdf.h:417
#define NC_EGLOBAL
Action prohibited on NC_GLOBAL varid.
Definition netcdf.h:472
#define NC_ENOFILTER
Filter not defined on variable.
Definition netcdf.h:566
int nc_type
The nc_type type is just an int.
Definition netcdf.h:25