NetCDF  4.7.4
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 "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 
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 
285 int
286 nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp)
287 {
288  NC* ncp;
289  size_t nparams;
290  unsigned int params[4];
291  int deflating = 0;
292 
293  int stat = NC_check_id(ncid,&ncp);
294  if(stat != NC_NOERR) return stat;
295  TRACE(nc_inq_var_deflate);
296 
297  /* Verify id and nparams */
298  stat = nc_inq_var_filter_info(ncid,varid,H5Z_FILTER_DEFLATE,&nparams,params);
299  switch (stat) {
300  case NC_ENOFILTER: deflating = 0; stat = NC_NOERR; break;
301  case NC_NOERR: deflating = 1; break;
302  default: return stat;
303  }
304  if(deflatep) *deflatep = deflating;
305  if(deflating) {
306  if(nparams != 1)
307  return NC_EFILTER; /* bad # params */
308  /* Param[0] should be level */
309  if(deflate_levelp) *deflate_levelp = (int)params[0];
310  } else if (deflate_levelp)
311  *deflate_levelp = 0;
312  /* also get the shuffle state */
313  if(!shufflep)
314  return NC_NOERR;
315  return ncp->dispatch->inq_var_all(
316  ncid, varid,
317  NULL, /*name*/
318  NULL, /*xtypep*/
319  NULL, /*ndimsp*/
320  NULL, /*dimidsp*/
321  NULL, /*nattsp*/
322  shufflep, /*shufflep*/
323  NULL, /*deflatep*/
324  NULL, /*deflatelevelp*/
325  NULL, /*fletcher32p*/
326  NULL, /*contiguousp*/
327  NULL, /*chunksizep*/
328  NULL, /*nofillp*/
329  NULL, /*fillvaluep*/
330  NULL, /*endianp*/
331  NULL, NULL, NULL
332  );
333 }
334 
355 int
356 nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
357 {
358  NC* ncp;
359  int stat = NC_check_id(ncid,&ncp);
360  if(stat != NC_NOERR) return stat;
361  TRACE(nc_inq_var_fletcher32);
362  return ncp->dispatch->inq_var_all(
363  ncid, varid,
364  NULL, /*name*/
365  NULL, /*xtypep*/
366  NULL, /*ndimsp*/
367  NULL, /*dimidsp*/
368  NULL, /*nattsp*/
369  NULL, /*shufflep*/
370  NULL, /*deflatep*/
371  NULL, /*deflatelevelp*/
372  fletcher32p, /*fletcher32p*/
373  NULL, /*contiguousp*/
374  NULL, /*chunksizep*/
375  NULL, /*nofillp*/
376  NULL, /*fillvaluep*/
377  NULL, /*endianp*/
378  NULL, NULL, NULL
379  );
380 }
381 
443 int
444 nc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)
445 {
446  NC *ncp;
447  int stat = NC_check_id(ncid, &ncp);
448  if(stat != NC_NOERR) return stat;
449  TRACE(nc_inq_var_chunking);
450  return ncp->dispatch->inq_var_all(ncid, varid, NULL, NULL, NULL, NULL,
451  NULL, NULL, NULL, NULL, NULL, storagep,
452  chunksizesp, NULL, NULL, NULL,
453  NULL, NULL, NULL);
454 }
455 
479 int
480 nc_inq_var_fill(int ncid, int varid, int *no_fill, void *fill_valuep)
481 {
482  NC* ncp;
483  int stat = NC_check_id(ncid,&ncp);
484 
485  if(stat != NC_NOERR) return stat;
486  TRACE(nc_inq_var_fill);
487 
488  return ncp->dispatch->inq_var_all(
489  ncid,varid,
490  NULL, /*name*/
491  NULL, /*xtypep*/
492  NULL, /*ndimsp*/
493  NULL, /*dimidsp*/
494  NULL, /*nattsp*/
495  NULL, /*shufflep*/
496  NULL, /*deflatep*/
497  NULL, /*deflatelevelp*/
498  NULL, /*fletcher32p*/
499  NULL, /*contiguousp*/
500  NULL, /*chunksizep*/
501  no_fill, /*nofillp*/
502  fill_valuep, /*fillvaluep*/
503  NULL, /*endianp*/
504  NULL, NULL, NULL
505  );
506 }
507 
529 int
530 nc_inq_var_endian(int ncid, int varid, int *endianp)
531 {
532  NC* ncp;
533  int stat = NC_check_id(ncid,&ncp);
534  if(stat != NC_NOERR) return stat;
535  TRACE(nc_inq_var_endian);
536  return ncp->dispatch->inq_var_all(
537  ncid, varid,
538  NULL, /*name*/
539  NULL, /*xtypep*/
540  NULL, /*ndimsp*/
541  NULL, /*dimidsp*/
542  NULL, /*nattsp*/
543  NULL, /*shufflep*/
544  NULL, /*deflatep*/
545  NULL, /*deflatelevelp*/
546  NULL, /*fletcher32p*/
547  NULL, /*contiguousp*/
548  NULL, /*chunksizep*/
549  NULL, /*nofillp*/
550  NULL, /*fillvaluep*/
551  endianp, /*endianp*/
552  NULL, NULL, NULL);
553 }
554 
619 int
620 nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
621 {
622 #ifndef USE_NETCDF4
623  return NC_ENOTNC4;
624 #else
625  NC* ncp;
626  int stat = NC_check_id(ncid,&ncp);
627  if(stat != NC_NOERR) return stat;
628  TRACE(nc_inq_unlimdims);
629  return ncp->dispatch->inq_unlimdims(ncid, nunlimdimsp,
630  unlimdimidsp);
631 #endif
632 }
633 
677 int
678 nc_inq_var_szip(int ncid, int varid, int *options_maskp, int *pixels_per_blockp)
679 {
680  NC* ncp;
681  size_t nparams;
682  unsigned int params[4];
683 
684  int stat = NC_check_id(ncid,&ncp);
685  if(stat != NC_NOERR) return stat;
686  TRACE(nc_inq_var_szip);
687 
688  /* Verify id and nparams */
689  stat = nc_inq_var_filter_info(ncid,varid,H5Z_FILTER_SZIP,&nparams,params);
690  switch (stat) {
691  case NC_NOERR:
692  if(nparams != 2)
693  return NC_EFILTER; /* bad # params */
694  break;
695  case NC_ENOFILTER:
696  /* If the szip filter is not in use, return 0 for both parameters. */
697  params[0] = 0;
698  params[1] = 0;
699  stat = NC_NOERR;
700  break;
701  default:
702  return stat;
703  }
704 
705  /* Param[0] should be options_mask
706  Param[1] should be pixels_per_block */
707  if(options_maskp) *options_maskp = (int)params[0];
708  if(pixels_per_blockp) *pixels_per_blockp = (int)params[1];
709  return stat;
710 }
711 
760 #if 0
761 int
762 NC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
763  int *ndimsp, int *dimidsp, int *nattsp,
764  int *shufflep, int *deflatep, int *deflate_levelp,
765  int *fletcher32p, int *contiguousp, size_t *chunksizesp,
766  int *no_fill, void *fill_valuep, int *endiannessp,
767  unsigned int* unused1, size_t* unused2, unsigned int* unused3
768  )
769 {
770  NC* ncp;
771  int stat = NC_check_id(ncid,&ncp);
772  if(stat != NC_NOERR) return stat;
773  return ncp->dispatch->inq_var_all(
774  ncid, varid, name, xtypep,
775  ndimsp, dimidsp, nattsp,
776  shufflep, deflatep, deflate_levelp, fletcher32p,
777  contiguousp, chunksizesp,
778  no_fill, fill_valuep,
779  endiannessp,
780  NULL, NULL, NULL);
781 }
782 #endif
783  /* End of named group ...*/
int nc_inq_var_endian(int ncid, int varid, int *endianp)
Find the endianness of a variable.
Definition: dvarinq.c:530
#define NC_ENOTNC4
Attempting netcdf-4 operation on netcdf-3 file.
Definition: netcdf.h:452
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:620
Main header file for the C API.
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:444
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:25
EXTERNL int nc_inq_natts(int ncid, int *nattsp)
Find number of global or group attributes.
Definition: dattinq.c:299
#define NC_EFILTER
Filter operation failed.
Definition: netcdf.h:474
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:678
int nc_inq_var_fletcher32(int ncid, int varid, int *fletcher32p)
Learn the checksum settings for a variable.
Definition: dvarinq.c:356
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
#define NC_ENOFILTER
Filter not defined on variable.
Definition: netcdf.h:478
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_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:124
#define NC_NOERR
No Error.
Definition: netcdf.h:329
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: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:480

Return to the Main Unidata NetCDF page.
Generated on Tue Nov 17 2020 14:09:02 for NetCDF. NetCDF is a Unidata library.