NetCDF  4.7.0
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. */
8 #include "config.h"
9 #include "ncdispatch.h"
10 #ifdef USE_HDF5
11 #include <hdf5.h>
12 #endif /* USE_HDF5 */
13 
14 #ifndef H5Z_FILTER_SZIP
15 
16 #define H5Z_FILTER_SZIP 4
17 #endif
18  /* All these functions are part of this named group... */
23 
61 int
62 nc_inq_varid(int ncid, const char *name, int *varidp)
63 {
64  NC* ncp;
65  int stat = NC_check_id(ncid, &ncp);
66  if(stat != NC_NOERR) return stat;
67  return ncp->dispatch->inq_varid(ncid, name, varidp);
68 }
69 
125 int
126 nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep,
127  int *ndimsp, int *dimidsp, int *nattsp)
128 {
129  NC* ncp;
130  int stat = NC_check_id(ncid, &ncp);
131  if(stat != NC_NOERR) return stat;
132  TRACE(nc_inq_var);
133  return ncp->dispatch->inq_var_all(ncid, varid, name, xtypep, ndimsp,
134  dimidsp, nattsp, NULL, NULL, NULL,
135  NULL, NULL, NULL, NULL, NULL, NULL,
136  NULL,NULL,NULL);
137 }
138 
157 int
158 nc_inq_varname(int ncid, int varid, char *name)
159 {
160  return nc_inq_var(ncid, varid, name, NULL, NULL,
161  NULL, NULL);
162 }
163 
179 int
180 nc_inq_vartype(int ncid, int varid, nc_type *typep)
181 {
182  return nc_inq_var(ncid, varid, NULL, typep, NULL,
183  NULL, NULL);
184 }
185 
203 int
204 nc_inq_varndims(int ncid, int varid, int *ndimsp)
205 {
206  return nc_inq_var(ncid, varid, NULL, NULL, ndimsp, NULL, NULL);
207 }
208 
226 int
227 nc_inq_vardimid(int ncid, int varid, int *dimidsp)
228 {
229  return nc_inq_var(ncid, varid, NULL, NULL, NULL,
230  dimidsp, NULL);
231 }
232 
250 int
251 nc_inq_varnatts(int ncid, int varid, int *nattsp)
252 {
253  if (varid == NC_GLOBAL)
254  return nc_inq_natts(ncid,nattsp);
255  /*else*/
256  return nc_inq_var(ncid, varid, NULL, NULL, NULL, NULL,
257  nattsp);
258 }
259 
286 int
287 nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep,
288  int *deflate_levelp)
289 {
290  NC* ncp;
291  int stat = NC_check_id(ncid,&ncp);
292  if(stat != NC_NOERR) return stat;
293  TRACE(nc_inq_var_deflate);
294  return ncp->dispatch->inq_var_all(
295  ncid, varid,
296  NULL, /*name*/
297  NULL, /*xtypep*/
298  NULL, /*ndimsp*/
299  NULL, /*dimidsp*/
300  NULL, /*nattsp*/
301  shufflep, /*shufflep*/
302  deflatep, /*deflatep*/
303  deflate_levelp, /*deflatelevelp*/
304  NULL, /*fletcher32p*/
305  NULL, /*contiguousp*/
306  NULL, /*chunksizep*/
307  NULL, /*nofillp*/
308  NULL, /*fillvaluep*/
309  NULL, /*endianp*/
310  NULL,NULL,NULL
311  );
312 }
313 
334 int
335 nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
336 {
337  NC* ncp;
338  int stat = NC_check_id(ncid,&ncp);
339  if(stat != NC_NOERR) return stat;
340  TRACE(nc_inq_var_fletcher32);
341  return ncp->dispatch->inq_var_all(
342  ncid, varid,
343  NULL, /*name*/
344  NULL, /*xtypep*/
345  NULL, /*ndimsp*/
346  NULL, /*dimidsp*/
347  NULL, /*nattsp*/
348  NULL, /*shufflep*/
349  NULL, /*deflatep*/
350  NULL, /*deflatelevelp*/
351  fletcher32p, /*fletcher32p*/
352  NULL, /*contiguousp*/
353  NULL, /*chunksizep*/
354  NULL, /*nofillp*/
355  NULL, /*fillvaluep*/
356  NULL, /*endianp*/
357  NULL, NULL, NULL
358  );
359 }
360 
421 int
422 nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
423 {
424  NC *ncp;
425  int stat = NC_check_id(ncid, &ncp);
426  if(stat != NC_NOERR) return stat;
427  TRACE(nc_inq_var_chunking);
428  return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL,
429  NULL, NULL, NULL, NULL, NULL, storagep,
430  chunksizesp, NULL, NULL, NULL,
431  NULL, NULL, NULL);
432 }
433 
457 int
458 nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
459 {
460  NC* ncp;
461  int stat = NC_check_id(ncid,&ncp);
462  if(stat != NC_NOERR) return stat;
463  TRACE(nc_inq_var_fill);
464  return ncp->dispatch->inq_var_all(
465  ncid, varid,
466  NULL, /*name*/
467  NULL, /*xtypep*/
468  NULL, /*ndimsp*/
469  NULL, /*dimidsp*/
470  NULL, /*nattsp*/
471  NULL, /*shufflep*/
472  NULL, /*deflatep*/
473  NULL, /*deflatelevelp*/
474  NULL, /*fletcher32p*/
475  NULL, /*contiguousp*/
476  NULL, /*chunksizep*/
477  no_fill, /*nofillp*/
478  fill_valuep, /*fillvaluep*/
479  NULL, /*endianp*/
480  NULL, NULL, NULL
481  );
482 }
483 
505 int
506 nc_inq_var_endian(int ncid, int varid, int *endianp)
507 {
508  NC* ncp;
509  int stat = NC_check_id(ncid,&ncp);
510  if(stat != NC_NOERR) return stat;
511  TRACE(nc_inq_var_endian);
512  return ncp->dispatch->inq_var_all(
513  ncid, varid,
514  NULL, /*name*/
515  NULL, /*xtypep*/
516  NULL, /*ndimsp*/
517  NULL, /*dimidsp*/
518  NULL, /*nattsp*/
519  NULL, /*shufflep*/
520  NULL, /*deflatep*/
521  NULL, /*deflatelevelp*/
522  NULL, /*fletcher32p*/
523  NULL, /*contiguousp*/
524  NULL, /*chunksizep*/
525  NULL, /*nofillp*/
526  NULL, /*fillvaluep*/
527  endianp, /*endianp*/
528  NULL, NULL, NULL);
529 }
530 
595 int
596 nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
597 {
598 #ifndef USE_NETCDF4
599  return NC_ENOTNC4;
600 #else
601  NC* ncp;
602  int stat = NC_check_id(ncid,&ncp);
603  if(stat != NC_NOERR) return stat;
604  TRACE(nc_inq_unlimdims);
605  return ncp->dispatch->inq_unlimdims(ncid, nunlimdimsp,
606  unlimdimidsp);
607 #endif
608 }
609 
637 int
638 nc_inq_var_filter(int ncid, int varid, unsigned int* idp, size_t* nparamsp, unsigned int* params)
639 {
640  NC* ncp;
641  int stat = NC_check_id(ncid,&ncp);
642  if(stat != NC_NOERR) return stat;
643  TRACE(nc_inq_var_filter);
644  return ncp->dispatch->inq_var_all(
645  ncid, varid,
646  NULL, /*name*/
647  NULL, /*xtypep*/
648  NULL, /*ndimsp*/
649  NULL, /*dimidsp*/
650  NULL, /*nattsp*/
651  NULL, /*shufflep*/
652  NULL, /*deflatep*/
653  NULL, /*deflatelevelp*/
654  NULL, /*fletcher32p*/
655  NULL, /*contiguousp*/
656  NULL, /*chunksizep*/
657  NULL, /*nofillp*/
658  NULL, /*fillvaluep*/
659  NULL, /*endianp*/
660  idp, nparamsp, params);
661 }
662 
691 int
692 nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
693 {
694  NC* ncp;
695  unsigned int id;
696  size_t nparams;
697  unsigned int params[4];
698 
699  int stat = NC_check_id(ncid,&ncp);
700  if(stat != NC_NOERR) return stat;
701  TRACE(nc_inq_var_szip);
702 
703  /* Verify id and nparams */
704  stat = ncp->dispatch->inq_var_all(
705  ncid, varid,
706  NULL, /*name*/
707  NULL, /*xtypep*/
708  NULL, /*ndimsp*/
709  NULL, /*dimidsp*/
710  NULL, /*nattsp*/
711  NULL, /*shufflep*/
712  NULL, /*deflatep*/
713  NULL, /*deflatelevelp*/
714  NULL, /*fletcher32p*/
715  NULL, /*contiguousp*/
716  NULL, /*chunksizep*/
717  NULL, /*nofillp*/
718  NULL, /*fillvaluep*/
719  NULL, /*endianp*/
720  &id,
721  &nparams,
722  NULL
723  );
724  if(stat != NC_NOERR) return stat;
725  /* Warning: the szip filter internally expands the set of parameters */
726  if(id != H5Z_FILTER_SZIP || nparams != 4)
727  return NC_EFILTER; /* not szip or bad # params */
728  /* Get params */
729  stat = ncp->dispatch->inq_var_all(
730  ncid, varid,
731  NULL, /*name*/
732  NULL, /*xtypep*/
733  NULL, /*ndimsp*/
734  NULL, /*dimidsp*/
735  NULL, /*nattsp*/
736  NULL, /*shufflep*/
737  NULL, /*deflatep*/
738  NULL, /*deflatelevelp*/
739  NULL, /*fletcher32p*/
740  NULL, /*contiguousp*/
741  NULL, /*chunksizep*/
742  NULL, /*nofillp*/
743  NULL, /*fillvaluep*/
744  NULL, /*endianp*/
745  &id,
746  &nparams,
747  params
748  );
749  if(stat != NC_NOERR) return stat;
750  /* Param[0] should be options_mask with possibly some other flags set,
751  Param[1] should be pixels_per_block */
752  if(options_maskp) *options_maskp = (int)params[0];
753  if(pixels_per_blockp) *pixels_per_blockp = (int)params[1];
754  return NC_NOERR;
755 }
756 
805 int
806 NC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
807  int *ndimsp, int *dimidsp, int *nattsp,
808  int *shufflep, int *deflatep, int *deflate_levelp,
809  int *fletcher32p, int *contiguousp, size_t *chunksizesp,
810  int *no_fill, void *fill_valuep, int *endiannessp,
811  unsigned int* idp, size_t* nparamsp, unsigned int* params
812  )
813 {
814  NC* ncp;
815  int stat = NC_check_id(ncid,&ncp);
816  if(stat != NC_NOERR) return stat;
817  return ncp->dispatch->inq_var_all(
818  ncid, varid, name, xtypep,
819  ndimsp, dimidsp, nattsp,
820  shufflep, deflatep, deflate_levelp, fletcher32p,
821  contiguousp, chunksizesp,
822  no_fill, fill_valuep,
823  endiannessp,
824  idp,nparamsp,params);
825 }
826  /* End of named group ...*/
int nc_inq_var_endian(int ncid, int varid, int *endianp)
Find the endianness of a variable.
Definition: dvarinq.c:506
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition: netcdf.h:448
int nc_inq_vardimid(int ncid, int varid, int *dimidsp)
Learn the dimension IDs associated with a variable.
Definition: dvarinq.c:227
int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
Definition: dvarinq.c:596
int nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
This is a wrapper for nc_inq_var_all().
Definition: dvarinq.c:422
int nc_inq_varndims(int ncid, int varid, int *ndimsp)
Learn how many dimensions are associated with a variable.
Definition: dvarinq.c:204
int nc_type
The nc_type type is just an int.
Definition: netcdf.h:25
#define H5Z_FILTER_SZIP
ID of HDF SZIP filter.
Definition: dvarinq.c:16
EXTERNL int nc_inq_natts(int ncid, int *nattsp)
Find number of global or group attributes.
Definition: dattinq.c:300
#define NC_EFILTER
Filter operation failed.
Definition: netcdf.h:470
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:692
int nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
Learn the checksum settings for a variable.
Definition: dvarinq.c:335
int nc_inq_var_filter(int ncid, int varid, unsigned int *idp, size_t *nparamsp, unsigned int *params)
Find the filter (if any) associated with a variable.
Definition: dvarinq.c:638
int nc_inq_vartype(int ncid, int varid, nc_type *typep)
Learn the type of a variable.
Definition: dvarinq.c:180
int nc_inq_varname(int ncid, int varid, char *name)
Learn the name of a variable.
Definition: dvarinq.c:158
int nc_inq_varid(int ncid, const char *name, int *varidp)
Find the ID of a variable, from the name.
Definition: dvarinq.c:62
int NC_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 *contiguousp, size_t *chunksizesp, int *no_fill, void *fill_valuep, int *endiannessp, unsigned int *idp, size_t *nparamsp, unsigned int *params)
Learn all about a variable.
Definition: dvarinq.c:806
int nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp)
Learn the storage and deflate settings for a variable.
Definition: dvarinq.c:287
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:126
#define NC_NOERR
No Error.
Definition: netcdf.h:325
int nc_inq_varnatts(int ncid, int varid, int *nattsp)
Learn how many attributes are associated with a variable.
Definition: dvarinq.c:251
#define NC_GLOBAL
Attribute id to put/get a global attribute.
Definition: netcdf.h:248
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:458

Return to the Main Unidata NetCDF page.
Generated on Mon Apr 29 2019 10:59:59 for NetCDF. NetCDF is a Unidata library.