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

Return to the Main Unidata NetCDF page.
Generated on Wed Mar 4 2020 06:29:56 for NetCDF. NetCDF is a Unidata library.