NetCDF  4.6.1
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 
59 int
60 nc_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 
123 int
124 nc_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 
155 int
156 nc_inq_varname(int ncid, int varid, char *name)
157 {
158  return nc_inq_var(ncid, varid, name, NULL, NULL,
159  NULL, NULL);
160 }
161 
177 int
178 nc_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 
201 int
202 nc_inq_varndims(int ncid, int varid, int *ndimsp)
203 {
204  return nc_inq_var(ncid, varid, NULL, NULL, ndimsp, NULL, NULL);
205 }
206 
224 int
225 nc_inq_vardimid(int ncid, int varid, int *dimidsp)
226 {
227  return nc_inq_var(ncid, varid, NULL, NULL, NULL,
228  dimidsp, NULL);
229 }
230 
248 int
249 nc_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 
284 int
285 nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep,
286  int *deflate_levelp)
287 {
288  NC* ncp;
289  int stat = NC_check_id(ncid,&ncp);
290  if(stat != NC_NOERR) return stat;
291  TRACE(nc_inq_var_deflate);
292  return ncp->dispatch->inq_var_all(
293  ncid, varid,
294  NULL, /*name*/
295  NULL, /*xtypep*/
296  NULL, /*ndimsp*/
297  NULL, /*dimidsp*/
298  NULL, /*nattsp*/
299  shufflep, /*shufflep*/
300  deflatep, /*deflatep*/
301  deflate_levelp, /*deflatelevelp*/
302  NULL, /*fletcher32p*/
303  NULL, /*contiguousp*/
304  NULL, /*chunksizep*/
305  NULL, /*nofillp*/
306  NULL, /*fillvaluep*/
307  NULL, /*endianp*/
308  NULL,NULL,NULL
309  );
310 }
311 
332 int
333 nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
334 {
335  NC* ncp;
336  int stat = NC_check_id(ncid,&ncp);
337  if(stat != NC_NOERR) return stat;
338  TRACE(nc_inq_var_fletcher32);
339  return ncp->dispatch->inq_var_all(
340  ncid, varid,
341  NULL, /*name*/
342  NULL, /*xtypep*/
343  NULL, /*ndimsp*/
344  NULL, /*dimidsp*/
345  NULL, /*nattsp*/
346  NULL, /*shufflep*/
347  NULL, /*deflatep*/
348  NULL, /*deflatelevelp*/
349  fletcher32p, /*fletcher32p*/
350  NULL, /*contiguousp*/
351  NULL, /*chunksizep*/
352  NULL, /*nofillp*/
353  NULL, /*fillvaluep*/
354  NULL, /*endianp*/
355  NULL, NULL, NULL
356  );
357 }
358 
419 int
420 nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
421 {
422  NC *ncp;
423  int stat = NC_check_id(ncid, &ncp);
424  if(stat != NC_NOERR) return stat;
425  TRACE(nc_inq_var_chunking);
426  return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL,
427  NULL, NULL, NULL, NULL, NULL, storagep,
428  chunksizesp, NULL, NULL, NULL,
429  NULL, NULL, NULL);
430 }
431 
455 int
456 nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
457 {
458  NC* ncp;
459  int stat = NC_check_id(ncid,&ncp);
460  if(stat != NC_NOERR) return stat;
461  TRACE(nc_inq_var_fill);
462  return ncp->dispatch->inq_var_all(
463  ncid, varid,
464  NULL, /*name*/
465  NULL, /*xtypep*/
466  NULL, /*ndimsp*/
467  NULL, /*dimidsp*/
468  NULL, /*nattsp*/
469  NULL, /*shufflep*/
470  NULL, /*deflatep*/
471  NULL, /*deflatelevelp*/
472  NULL, /*fletcher32p*/
473  NULL, /*contiguousp*/
474  NULL, /*chunksizep*/
475  no_fill, /*nofillp*/
476  fill_valuep, /*fillvaluep*/
477  NULL, /*endianp*/
478  NULL, NULL, NULL
479  );
480 }
481 
503 int
504 nc_inq_var_endian(int ncid, int varid, int *endianp)
505 {
506  NC* ncp;
507  int stat = NC_check_id(ncid,&ncp);
508  if(stat != NC_NOERR) return stat;
509  TRACE(nc_inq_var_endian);
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  NULL, /*nofillp*/
524  NULL, /*fillvaluep*/
525  endianp, /*endianp*/
526  NULL, NULL, NULL);
527 }
528 
593 int
594 nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
595 {
596 #ifndef USE_NETCDF4
597  return NC_ENOTNC4;
598 #else
599  NC* ncp;
600  int stat = NC_check_id(ncid,&ncp);
601  if(stat != NC_NOERR) return stat;
602  TRACE(nc_inq_unlimdims);
603  return ncp->dispatch->inq_unlimdims(ncid, nunlimdimsp,
604  unlimdimidsp);
605 #endif
606 }
607 
635 int
636 nc_inq_var_filter(int ncid, int varid, unsigned int* idp, size_t* nparamsp, unsigned int* params)
637 {
638  NC* ncp;
639  int stat = NC_check_id(ncid,&ncp);
640  if(stat != NC_NOERR) return stat;
641  TRACE(nc_inq_var_filter);
642  return ncp->dispatch->inq_var_all(
643  ncid, varid,
644  NULL, /*name*/
645  NULL, /*xtypep*/
646  NULL, /*ndimsp*/
647  NULL, /*dimidsp*/
648  NULL, /*nattsp*/
649  NULL, /*shufflep*/
650  NULL, /*deflatep*/
651  NULL, /*deflatelevelp*/
652  NULL, /*fletcher32p*/
653  NULL, /*contiguousp*/
654  NULL, /*chunksizep*/
655  NULL, /*nofillp*/
656  NULL, /*fillvaluep*/
657  NULL, /*endianp*/
658  idp, nparamsp, params);
659 }
660 
689 int
690 nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
691 {
692  NC* ncp;
693  unsigned int id;
694  size_t nparams;
695  unsigned int params[2];
696 
697  int stat = NC_check_id(ncid,&ncp);
698  if(stat != NC_NOERR) return stat;
699  TRACE(nc_inq_var_szip);
700 
701  /* Verify id and nparams */
702  stat = ncp->dispatch->inq_var_all(
703  ncid, varid,
704  NULL, /*name*/
705  NULL, /*xtypep*/
706  NULL, /*ndimsp*/
707  NULL, /*dimidsp*/
708  NULL, /*nattsp*/
709  NULL, /*shufflep*/
710  NULL, /*deflatep*/
711  NULL, /*deflatelevelp*/
712  NULL, /*fletcher32p*/
713  NULL, /*contiguousp*/
714  NULL, /*chunksizep*/
715  NULL, /*nofillp*/
716  NULL, /*fillvaluep*/
717  NULL, /*endianp*/
718  &id,
719  &nparams,
720  NULL
721  );
722  if(stat != NC_NOERR) return stat;
723  if(id != H5Z_FILTER_SZIP || nparams != 2)
724  return NC_EFILTER; /* not szip or bad # params */
725  /* Get params */
726  stat = ncp->dispatch->inq_var_all(
727  ncid, varid,
728  NULL, /*name*/
729  NULL, /*xtypep*/
730  NULL, /*ndimsp*/
731  NULL, /*dimidsp*/
732  NULL, /*nattsp*/
733  NULL, /*shufflep*/
734  NULL, /*deflatep*/
735  NULL, /*deflatelevelp*/
736  NULL, /*fletcher32p*/
737  NULL, /*contiguousp*/
738  NULL, /*chunksizep*/
739  NULL, /*nofillp*/
740  NULL, /*fillvaluep*/
741  NULL, /*endianp*/
742  &id,
743  &nparams,
744  params
745  );
746  if(stat != NC_NOERR) return stat;
747  /* Param[0] should be options_mask, Param[1] should be pixels_per_block */
748  if(options_maskp) *options_maskp = (int)params[0];
749  if(pixels_per_blockp) *pixels_per_blockp = (int)params[1];
750  return NC_NOERR;
751 }
752 
801 int
802 NC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
803  int *ndimsp, int *dimidsp, int *nattsp,
804  int *shufflep, int *deflatep, int *deflate_levelp,
805  int *fletcher32p, int *contiguousp, size_t *chunksizesp,
806  int *no_fill, void *fill_valuep, int *endiannessp,
807  unsigned int* idp, size_t* nparamsp, unsigned int* params
808  )
809 {
810  NC* ncp;
811  int stat = NC_check_id(ncid,&ncp);
812  if(stat != NC_NOERR) return stat;
813  return ncp->dispatch->inq_var_all(
814  ncid, varid, name, xtypep,
815  ndimsp, dimidsp, nattsp,
816  shufflep, deflatep, deflate_levelp, fletcher32p,
817  contiguousp, chunksizesp,
818  no_fill, fill_valuep,
819  endiannessp,
820  idp,nparamsp,params);
821 }
822  /* End of named group ...*/
int nc_inq_var_endian(int ncid, int varid, int *endianp)
Find the endianness of a variable.
Definition: dvarinq.c:504
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition: netcdf.h:437
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_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
Return number and list of unlimited dimensions.
Definition: dvarinq.c:594
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:420
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_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:459
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:690
int nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
Learn the checksum settings for a variable.
Definition: dvarinq.c:333
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:636
int nc_inq_vartype(int ncid, int varid, nc_type *typep)
Learn the type of a variable.
Definition: dvarinq.c:178
int nc_inq_varname(int ncid, int varid, char *name)
Learn the name of a variable.
Definition: dvarinq.c:156
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_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:802
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:285
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
#define NC_NOERR
No Error.
Definition: netcdf.h:315
int nc_inq_varnatts(int ncid, int varid, int *nattsp)
Learn how many attributes are associated with a variable.
Definition: dvarinq.c:249
#define NC_GLOBAL
Attribute id to put/get a global attribute.
Definition: netcdf.h:238
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:456

Return to the Main Unidata NetCDF page.
Generated on Wed Aug 1 2018 05:36:48 for NetCDF. NetCDF is a Unidata library.