netCDF  4.3.0
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
dvarget.c
Go to the documentation of this file.
1 
7 #include "ncdispatch.h"
8 
9 #undef VARS_USES_VARM
10 #ifndef VARS_USES_VARM
11 struct GETodometer {
12  int rank;
13  size_t index[NC_MAX_VAR_DIMS];
14  size_t start[NC_MAX_VAR_DIMS];
15  size_t edges[NC_MAX_VAR_DIMS];
16  ptrdiff_t stride[NC_MAX_VAR_DIMS];
17  size_t stop[NC_MAX_VAR_DIMS];
18 };
19 
20 static void
21 odom_init(struct GETodometer* odom,
22  size_t rank,
23  const size_t* start, const size_t* edges, const ptrdiff_t* stride)
24 {
25  int i;
26  memset(odom,0,sizeof(struct GETodometer));
27  odom->rank = rank;
28  assert(odom->rank <= NC_MAX_VAR_DIMS);
29  for(i=0;i<odom->rank;i++) {
30  odom->start[i] = (start != NULL ? start[i] : 0);
31  odom->edges[i] = (edges != NULL ? edges[i] : 1);
32  odom->stride[i] = (stride != NULL ? stride[i] : 1);
33  odom->stop[i] = odom->start[i] + (odom->edges[i]*odom->stride[i]);
34  odom->index[i] = odom->start[i];
35  }
36 }
37 
38 static int
39 odom_more(struct GETodometer* odom)
40 {
41  return (odom->index[0] < odom->stop[0]);
42 }
43 
44 static int
45 odom_next(struct GETodometer* odom)
46 {
47  int i;
48  if(odom->rank == 0) return 0;
49  for(i=odom->rank-1;i>=0;i--) {
50  odom->index[i] += odom->stride[i];
51  if(odom->index[i] < odom->stop[i]) break;
52  if(i == 0) return 0; /* leave the 0th entry if it overflows*/
53  odom->index[i] = odom->start[i]; /* reset this position*/
54  }
55  return 1;
56 }
57 #endif
58 
63 int
64 NC_get_vara(int ncid, int varid,
65  const size_t *start, const size_t *edges,
66  void *value, nc_type memtype)
67 {
68  NC* ncp;
69  int stat = NC_check_id(ncid, &ncp);
70  if(stat != NC_NOERR) return stat;
71 #ifdef USE_NETCDF4
72  if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT;
73 #endif
74  if(edges == NULL) {
75  size_t shape[NC_MAX_VAR_DIMS];
76  int ndims;
77  stat = nc_inq_varndims(ncid, varid, &ndims);
78  if(stat != NC_NOERR) return stat;
79  stat = NC_getshape(ncid,varid,ndims,shape);
80  if(stat != NC_NOERR) return stat;
81  return ncp->dispatch->get_vara(ncid,varid,start,shape,value,memtype);
82  } else
83  return ncp->dispatch->get_vara(ncid,varid,start,edges,value,memtype);
84 }
85 
89 static int
90 NC_get_var(int ncid, int varid, void *value, nc_type memtype)
91 {
92  int ndims;
93  size_t shape[NC_MAX_VAR_DIMS];
94  int stat = nc_inq_varndims(ncid,varid, &ndims);
95  if(stat) return stat;
96  stat = NC_getshape(ncid,varid, ndims, shape);
97  if(stat) return stat;
98  return NC_get_vara(ncid, varid, NC_coord_zero, shape, value, memtype);
99 }
100 
105 int
106 NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
107  const size_t * edges, const ptrdiff_t * stride,
108  void *value0, nc_type memtype)
109 {
110 #ifdef VARS_USES_VARM
111  NC* ncp;
112  int stat = NC_check_id(ncid, &ncp);
113 
114  if(stat != NC_NOERR) return stat;
115  return ncp->dispatch->get_varm(ncid,varid,start,edges,stride,NULL,value0,memtype);
116 #else
117  /* Rebuilt get_vars code to simplify and avoid use of get_varm */
118 
119  int status = NC_NOERR;
120  int i,simplestride,rank,isrecvar;
121  struct GETodometer odom;
122  nc_type vartype = NC_NAT;
123  NC* ncp;
124  size_t vartypelen, memtypelen;
125  char* value = (char*)value0;
126  size_t numrecs;
127  size_t varshape[NC_MAX_VAR_DIMS];
128  size_t mystart[NC_MAX_VAR_DIMS];
129  size_t myedges[NC_MAX_VAR_DIMS];
130  ptrdiff_t mystride[NC_MAX_VAR_DIMS];
131  char *memptr = NULL;
132 
133  status = NC_check_id (ncid, &ncp);
134  if(status != NC_NOERR) return status;
135 
136  status = nc_inq_vartype(ncid, varid, &vartype);
137  if(status != NC_NOERR) return status;
138 
139  if(memtype == NC_NAT) memtype = vartype;
140 
141  /* compute the variable type size */
142  status = nc_inq_type(ncid,vartype,NULL,&vartypelen);
143  if(status != NC_NOERR) return status;
144 
145  if(memtype > NC_MAX_ATOMIC_TYPE)
146  memtypelen = vartypelen;
147  else
148  memtypelen = nctypelen(memtype);
149 
150  /* Check gross internal/external type compatibility */
151  if(vartype != memtype) {
152  /* If !atomic, the two types must be the same */
153  if(vartype > NC_MAX_ATOMIC_TYPE
154  || memtype > NC_MAX_ATOMIC_TYPE)
155  return NC_EBADTYPE;
156  /* ok, the types differ but both are atomic */
157  if(memtype == NC_CHAR || vartype == NC_CHAR)
158  return NC_ECHAR;
159  }
160 
161  /* Get the variable rank */
162  status = nc_inq_varndims(ncid, varid, &rank);
163  if(status != NC_NOERR) return status;
164 
165  /* Get variable dimension sizes */
166  isrecvar = NC_is_recvar(ncid,varid,&numrecs);
167  NC_getshape(ncid,varid,rank,varshape);
168 
169  /* Optimize out using various checks */
170  if (rank == 0) {
171  /*
172  * The variable is a scalar; consequently,
173  * there s only one thing to get and only one place to put it.
174  * (Why was I called?)
175  */
176  size_t edge1[1] = {1};
177  return NC_get_vara(ncid, varid, start, edge1, value, memtype);
178  }
179 
180  /* Do various checks and fixups on start/edges/stride */
181  simplestride = 1; /* assume so */
182  for(i=0;i<rank;i++) {
183  size_t dimlen;
184  mystart[i] = (start == NULL ? 0 : start[i]);
185  if(edges == NULL) {
186  if(i == 0 && isrecvar)
187  myedges[i] = numrecs - start[i];
188  else
189  myedges[i] = varshape[i] - mystart[i];
190  } else
191  myedges[i] = edges[i];
192  if(myedges[i] == 0)
193  return NC_NOERR; /* cannot read anything */
194  mystride[i] = (stride == NULL ? 1 : stride[i]);
195  if(mystride[i] <= 0
196  /* cast needed for braindead systems with signed size_t */
197  || ((unsigned long) mystride[i] >= X_INT_MAX))
198  return NC_ESTRIDE;
199  if(mystride[i] != 1) simplestride = 0;
200  /* illegal value checks */
201  dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
202  if(mystart < 0 || mystart[i] >= dimlen)
203  return NC_EINVALCOORDS;
204  if(myedges[i] < 0 || (mystart[i] + myedges[i] > dimlen))
205  return NC_EEDGE;
206  }
207  if(simplestride) {
208  return NC_get_vara(ncid, varid, mystart, myedges, value, memtype);
209  }
210 
211  /* memptr indicates where to store the next value */
212  memptr = value;
213 
214  odom_init(&odom,rank,mystart,myedges,mystride);
215 
216  /* walk the odometer to extract values */
217  while(odom_more(&odom)) {
218  int localstatus = NC_NOERR;
219  /* Read a single value */
220  localstatus = NC_get_vara(ncid,varid,odom.index,nc_sizevector1,memptr,memtype);
221  /* So it turns out that when get_varm is used, all errors are
222  delayed and ERANGE will be overwritten by more serious errors.
223  */
224  if(localstatus != NC_NOERR) {
225  if(status == NC_NOERR || localstatus != NC_ERANGE)
226  status = localstatus;
227  }
228  memptr += memtypelen;
229  odom_next(&odom);
230  }
231  return status;
232 #endif
233 }
234 
238 static int
239 NC_get_var1(int ncid, int varid, const size_t *coord, void* value,
240  nc_type memtype)
241 {
242  return NC_get_vara(ncid, varid, coord, NC_coord_one, value, memtype);
243 }
244 
248 int
249 NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
250  const size_t *edges, const ptrdiff_t *stride,
251  const ptrdiff_t *imapp, void *value0, nc_type memtype)
252 {
253  int status = NC_NOERR;
254  nc_type vartype = NC_NAT;
255  int varndims,maxidim;
256  NC* ncp;
257  size_t memtypelen;
258  ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
259  char* value = (char*)value0;
260 
261  status = NC_check_id (ncid, &ncp);
262  if(status != NC_NOERR) return status;
263 
264 /*
265  if(NC_indef(ncp)) return NC_EINDEFINE;
266 */
267 
268  status = nc_inq_vartype(ncid, varid, &vartype);
269  if(status != NC_NOERR) return status;
270  /* Check that this is an atomic type */
271  if(vartype > NC_MAX_ATOMIC_TYPE)
272  return NC_EMAPTYPE;
273 
274  status = nc_inq_varndims(ncid, varid, &varndims);
275  if(status != NC_NOERR) return status;
276 
277  if(memtype == NC_NAT) {
278  if(imapp != NULL && varndims != 0) {
279  /*
280  * convert map units from bytes to units of sizeof(type)
281  */
282  size_t ii;
283  const ptrdiff_t szof = (ptrdiff_t) nctypelen(vartype);
284  for(ii = 0; ii < varndims; ii++) {
285  if(imapp[ii] % szof != 0) {
286  /*free(cvtmap);*/
287  return NC_EINVAL;
288  }
289  cvtmap[ii] = imapp[ii] / szof;
290  }
291  imapp = cvtmap;
292  }
293  memtype = vartype;
294  }
295 
296  if(memtype == NC_CHAR && vartype != NC_CHAR)
297  return NC_ECHAR;
298  else if(memtype != NC_CHAR && vartype == NC_CHAR)
299  return NC_ECHAR;
300 
301  memtypelen = nctypelen(memtype);
302 
303  maxidim = (int) varndims - 1;
304 
305  if (maxidim < 0)
306  {
307  /*
308  * The variable is a scalar; consequently,
309  * there s only one thing to get and only one place to put it.
310  * (Why was I called?)
311  */
312  size_t edge1[1] = {1};
313  return NC_get_vara(ncid, varid, start, edge1, value, memtype);
314  }
315 
316  /*
317  * else
318  * The variable is an array.
319  */
320  {
321  int idim;
322  size_t *mystart = NULL;
323  size_t *myedges;
324  size_t *iocount; /* count vector */
325  size_t *stop; /* stop indexes */
326  size_t *length; /* edge lengths in bytes */
327  ptrdiff_t *mystride;
328  ptrdiff_t *mymap;
329  size_t varshape[NC_MAX_VAR_DIMS];
330  int isrecvar;
331  size_t numrecs;
332 
333  /* Compute some dimension related values */
334  isrecvar = NC_is_recvar(ncid,varid,&numrecs);
335  NC_getshape(ncid,varid,varndims,varshape);
336 
337  /*
338  * Verify stride argument; also see if stride is all ones
339  */
340  if(stride != NULL) {
341  int stride1 = 1;
342  for (idim = 0; idim <= maxidim; ++idim)
343  {
344  if (stride[idim] == 0
345  /* cast needed for braindead systems with signed size_t */
346  || ((unsigned long) stride[idim] >= X_INT_MAX))
347  {
348  return NC_ESTRIDE;
349  }
350  if(stride[idim] != 1) stride1 = 0;
351  }
352  /* If stride1 is true, and there is no imap
353  then call get_vara directly.
354  */
355  if(stride1 && imapp == NULL) {
356  return NC_get_vara(ncid, varid, start, edges, value, memtype);
357  }
358  }
359 
360  /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
361  /* Allocate space for mystart,mystride,mymap etc.all at once */
362  mystart = (size_t *)calloc(varndims * 7, sizeof(ptrdiff_t));
363  if(mystart == NULL) return NC_ENOMEM;
364  myedges = mystart + varndims;
365  iocount = myedges + varndims;
366  stop = iocount + varndims;
367  length = stop + varndims;
368  mystride = (ptrdiff_t *)(length + varndims);
369  mymap = mystride + varndims;
370 
371  /*
372  * Initialize I/O parameters.
373  */
374  for (idim = maxidim; idim >= 0; --idim)
375  {
376  mystart[idim] = start != NULL
377  ? start[idim]
378  : 0;
379 
380  if (edges != NULL && edges[idim] == 0)
381  {
382  status = NC_NOERR; /* read/write no data */
383  goto done;
384  }
385 
386 #ifdef COMPLEX
387  myedges[idim] = edges != NULL
388  ? edges[idim]
389  : idim == 0 && isrecvar
390  ? numrecs - mystart[idim]
391  : varshape[idim] - mystart[idim];
392 #else
393  if(edges != NULL)
394  myedges[idim] = edges[idim];
395  else if (idim == 0 && isrecvar)
396  myedges[idim] = numrecs - mystart[idim];
397  else
398  myedges[idim] = varshape[idim] - mystart[idim];
399 #endif
400 
401  mystride[idim] = stride != NULL
402  ? stride[idim]
403  : 1;
404 
405  /* Remember: imapp is byte oriented, not index oriented */
406 #ifdef COMPLEX
407  mymap[idim] = (imapp != NULL
408  ? imapp[idim]
409  : (idim == maxidim ? 1
410  : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1]));
411 #else
412  if(imapp != NULL)
413  mymap[idim] = imapp[idim];
414  else if (idim == maxidim)
415  mymap[idim] = 1;
416  else
417  mymap[idim] =
418  mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
419 #endif
420  iocount[idim] = 1;
421  length[idim] = mymap[idim] * myedges[idim];
422  stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
423  }
424 
425  /*
426  * Check start, edges
427  */
428  for (idim = maxidim; idim >= 0; --idim)
429  {
430  size_t dimlen =
431  idim == 0 && isrecvar
432  ? numrecs
433  : varshape[idim];
434  if (mystart[idim] >= dimlen)
435  {
436  status = NC_EINVALCOORDS;
437  goto done;
438  }
439 
440  if (mystart[idim] + myedges[idim] > dimlen)
441  {
442  status = NC_EEDGE;
443  goto done;
444  }
445 
446  }
447 
448 
449  /* Lower body */
450  /*
451  * As an optimization, adjust I/O parameters when the fastest
452  * dimension has unity stride both externally and internally.
453  * In this case, the user could have called a simpler routine
454  * (i.e. ncvar$1()
455  */
456  if (mystride[maxidim] == 1
457  && mymap[maxidim] == 1)
458  {
459  iocount[maxidim] = myedges[maxidim];
460  mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
461  mymap[maxidim] = (ptrdiff_t) length[maxidim];
462  }
463 
464  /*
465  * Perform I/O. Exit when done.
466  */
467  for (;;)
468  {
469  /* TODO: */
470  int lstatus = NC_get_vara(ncid, varid, mystart, iocount,
471  value, memtype);
472  if (lstatus != NC_NOERR) {
473  if(status == NC_NOERR || lstatus != NC_ERANGE)
474  status = lstatus;
475  }
476  /*
477  * The following code permutes through the variable s
478  * external start-index space and it s internal address
479  * space. At the UPC, this algorithm is commonly
480  * called "odometer code".
481  */
482  idim = maxidim;
483  carry:
484  value += (mymap[idim] * memtypelen);
485  mystart[idim] += mystride[idim];
486  if (mystart[idim] == stop[idim])
487  {
488  mystart[idim] = start[idim];
489  value -= (length[idim] * memtypelen);
490  if (--idim < 0)
491  break; /* normal return */
492  goto carry;
493  }
494  } /* I/O loop */
495  done:
496  free(mystart);
497  } /* variable is array */
498  return status;
499 }
500 
504 static int
505 NC_get_vars(int ncid, int varid, const size_t *start,
506  const size_t *edges, const ptrdiff_t *stride, void *value,
507  nc_type memtype)
508 {
509  NC* ncp;
510  int stat = NC_check_id(ncid, &ncp);
511 
512  if(stat != NC_NOERR) return stat;
513 #ifdef USE_NETCDF4
514  if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT;
515 #endif
516  return ncp->dispatch->get_vars(ncid,varid,start,edges,stride,value,memtype);
517 }
518 
523 static int
524 NC_get_varm(int ncid, int varid, const size_t *start,
525  const size_t *edges, const ptrdiff_t *stride, const ptrdiff_t* map,
526  void *value, nc_type memtype)
527 {
528  NC* ncp;
529  int stat = NC_check_id(ncid, &ncp);
530 
531  if(stat != NC_NOERR) return stat;
532 #ifdef USE_NETCDF4
533  if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT;
534 #endif
535  return ncp->dispatch->get_varm(ncid,varid,start,edges,stride,map,value,memtype);
536 }
537  /* All these functions are part of this named group... */
542 
617 int
618 nc_get_vara(int ncid, int varid, const size_t *startp,
619  const size_t *countp, void *ip)
620 {
621  NC* ncp = NULL;
622  nc_type xtype = NC_NAT;
623  int stat = NC_check_id(ncid, &ncp);
624  if(stat != NC_NOERR) return stat;
625  stat = nc_inq_vartype(ncid, varid, &xtype);
626  if(stat != NC_NOERR) return stat;
627  return NC_get_vara(ncid, varid, startp, countp, ip, xtype);
628 }
629 
630 int
631 nc_get_vara_text(int ncid, int varid, const size_t *startp,
632  const size_t *countp, char *ip)
633 {
634  NC* ncp;
635  int stat = NC_check_id(ncid, &ncp);
636  if(stat != NC_NOERR) return stat;
637  return NC_get_vara(ncid, varid, startp, countp,
638  (void *)ip, NC_CHAR);
639 }
640 
641 int
642 nc_get_vara_schar(int ncid, int varid, const size_t *startp,
643  const size_t *countp, signed char *ip)
644 {
645  NC* ncp;
646  int stat = NC_check_id(ncid, &ncp);
647  if(stat != NC_NOERR) return stat;
648  return NC_get_vara(ncid, varid, startp, countp,
649  (void *)ip, NC_BYTE);
650 }
651 
652 int
653 nc_get_vara_uchar(int ncid, int varid, const size_t *startp,
654  const size_t *countp, unsigned char *ip)
655 {
656  NC* ncp;
657  int stat = NC_check_id(ncid, &ncp);
658  if(stat != NC_NOERR) return stat;
659  return NC_get_vara(ncid, varid, startp, countp,
660  (void *)ip, T_uchar);
661 }
662 
663 int
664 nc_get_vara_short(int ncid, int varid, const size_t *startp,
665  const size_t *countp, short *ip)
666 {
667  NC* ncp;
668  int stat = NC_check_id(ncid, &ncp);
669  if(stat != NC_NOERR) return stat;
670  return NC_get_vara(ncid, varid, startp, countp,
671  (void *)ip, NC_SHORT);
672 }
673 
674 int
675 nc_get_vara_int(int ncid, int varid,
676  const size_t *startp, const size_t *countp, int *ip)
677 {
678  NC* ncp;
679  int stat = NC_check_id(ncid, &ncp);
680  if(stat != NC_NOERR) return stat;
681  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_INT);
682 }
683 
684 int
685 nc_get_vara_long(int ncid, int varid,
686  const size_t *startp, const size_t *countp, long *ip)
687 {
688  NC* ncp;
689  int stat = NC_check_id(ncid, &ncp);
690  if(stat != NC_NOERR) return stat;
691  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_long);
692 }
693 
694 int
695 nc_get_vara_float(int ncid, int varid,
696  const size_t *startp, const size_t *countp, float *ip)
697 {
698  NC* ncp;
699  int stat = NC_check_id(ncid, &ncp);
700  if(stat != NC_NOERR) return stat;
701  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_float);
702 }
703 
704 
705 int
706 nc_get_vara_double(int ncid, int varid, const size_t *startp,
707  const size_t *countp, double *ip)
708 {
709  NC* ncp;
710  int stat = NC_check_id(ncid, &ncp);
711  if(stat != NC_NOERR) return stat;
712  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_double);
713 }
714 
715 int
716 nc_get_vara_ubyte(int ncid, int varid,
717  const size_t *startp, const size_t *countp, unsigned char *ip)
718 {
719  NC* ncp;
720  int stat = NC_check_id(ncid, &ncp);
721  if(stat != NC_NOERR) return stat;
722  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ubyte);
723 }
724 
725 int
726 nc_get_vara_ushort(int ncid, int varid,
727  const size_t *startp, const size_t *countp, unsigned short *ip)
728 {
729  NC* ncp;
730  int stat = NC_check_id(ncid, &ncp);
731  if(stat != NC_NOERR) return stat;
732  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ushort);
733 }
734 
735 int
736 nc_get_vara_uint(int ncid, int varid,
737  const size_t *startp, const size_t *countp, unsigned int *ip)
738 {
739  NC* ncp;
740  int stat = NC_check_id(ncid, &ncp);
741  if(stat != NC_NOERR) return stat;
742  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_uint);
743 }
744 
745 int
746 nc_get_vara_longlong(int ncid, int varid,
747  const size_t *startp, const size_t *countp, long long *ip)
748 {
749  NC* ncp;
750  int stat = NC_check_id(ncid, &ncp);
751  if(stat != NC_NOERR) return stat;
752  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_longlong);
753 }
754 
755 int
756 nc_get_vara_ulonglong(int ncid, int varid,
757  const size_t *startp, const size_t *countp, unsigned long long *ip)
758 {
759  NC* ncp;
760  int stat = NC_check_id(ncid, &ncp);
761  if(stat != NC_NOERR) return stat;
762  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_UINT64);
763 }
764 
765 #ifdef USE_NETCDF4
766 int
767 nc_get_vara_string(int ncid, int varid,
768  const size_t *startp, const size_t *countp, char* *ip)
769 {
770  NC* ncp;
771  int stat = NC_check_id(ncid, &ncp);
772  if(stat != NC_NOERR) return stat;
773  return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_STRING);
774 }
775 
776 #endif /*USE_NETCDF4*/
777 
813 int
814 nc_get_var1(int ncid, int varid, const size_t *indexp, void *ip)
815 {
816  return NC_get_var1(ncid, varid, indexp, ip, NC_NAT);
817 }
818 
819 int
820 nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip)
821 {
822  NC* ncp;
823  int stat = NC_check_id(ncid, &ncp);
824  if(stat != NC_NOERR) return stat;
825  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_CHAR);
826 }
827 
828 int
829 nc_get_var1_schar(int ncid, int varid, const size_t *indexp, signed char *ip)
830 {
831  NC* ncp;
832  int stat = NC_check_id(ncid, &ncp);
833  if(stat != NC_NOERR) return stat;
834  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_BYTE);
835 }
836 
837 int
838 nc_get_var1_uchar(int ncid, int varid, const size_t *indexp, unsigned char *ip)
839 {
840  NC* ncp;
841  int stat = NC_check_id(ncid, &ncp);
842  if(stat != NC_NOERR) return stat;
843  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE);
844 }
845 
846 int
847 nc_get_var1_short(int ncid, int varid, const size_t *indexp, short *ip)
848 {
849  NC* ncp;
850  int stat = NC_check_id(ncid, &ncp);
851  if(stat != NC_NOERR) return stat;
852  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_SHORT);
853 }
854 
855 int
856 nc_get_var1_int(int ncid, int varid, const size_t *indexp, int *ip)
857 {
858  NC* ncp;
859  int stat = NC_check_id(ncid, &ncp);
860  if(stat != NC_NOERR) return stat;
861  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT);
862 }
863 
864 int
865 nc_get_var1_long(int ncid, int varid, const size_t *indexp,
866  long *ip)
867 {
868  NC* ncp;
869  int stat = NC_check_id(ncid, &ncp);
870  if(stat != NC_NOERR) return stat;
871  return NC_get_var1(ncid, varid, indexp, (void *)ip, longtype);
872 }
873 
874 int
875 nc_get_var1_float(int ncid, int varid, const size_t *indexp,
876  float *ip)
877 {
878  NC* ncp;
879  int stat = NC_check_id(ncid, &ncp);
880  if(stat != NC_NOERR) return stat;
881  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_FLOAT);
882 }
883 
884 int
885 nc_get_var1_double(int ncid, int varid, const size_t *indexp,
886  double *ip)
887 {
888  NC* ncp;
889  int stat = NC_check_id(ncid, &ncp);
890  if(stat != NC_NOERR) return stat;
891  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_DOUBLE);
892 }
893 
894 int
895 nc_get_var1_ubyte(int ncid, int varid, const size_t *indexp,
896  unsigned char *ip)
897 {
898  NC* ncp;
899  int stat = NC_check_id(ncid, &ncp);
900  if(stat != NC_NOERR) return stat;
901  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE);
902 }
903 
904 int
905 nc_get_var1_ushort(int ncid, int varid, const size_t *indexp,
906  unsigned short *ip)
907 {
908  NC* ncp;
909  int stat = NC_check_id(ncid, &ncp);
910  if(stat != NC_NOERR) return stat;
911  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_USHORT);
912 }
913 
914 int
915 nc_get_var1_uint(int ncid, int varid, const size_t *indexp,
916  unsigned int *ip)
917 {
918  NC* ncp;
919  int stat = NC_check_id(ncid, &ncp);
920  if(stat != NC_NOERR) return stat;
921  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UINT);
922 }
923 
924 int
925 nc_get_var1_longlong(int ncid, int varid, const size_t *indexp,
926  long long *ip)
927 {
928  NC* ncp;
929  int stat = NC_check_id(ncid, &ncp);
930  if(stat != NC_NOERR) return stat;
931  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT64);
932 }
933 
934 int
935 nc_get_var1_ulonglong(int ncid, int varid, const size_t *indexp,
936  unsigned long long *ip)
937 {
938  NC* ncp;
939  int stat = NC_check_id(ncid, &ncp);
940  if(stat != NC_NOERR) return stat;
941  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UINT64);
942 }
943 
944 #ifdef USE_NETCDF4
945 int
946 nc_get_var1_string(int ncid, int varid, const size_t *indexp, char* *ip)
947 {
948  NC* ncp;
949  int stat = NC_check_id(ncid, &ncp);
950  if(stat != NC_NOERR) return stat;
951  return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_STRING);
952 }
953 #endif /*USE_NETCDF4*/
954 
999 int
1000 nc_get_var(int ncid, int varid, void *ip)
1001 {
1002  return NC_get_var(ncid, varid, ip, NC_NAT);
1003 }
1004 
1005 int
1006 nc_get_var_text(int ncid, int varid, char *ip)
1007 {
1008  NC *ncp;
1009  int stat = NC_check_id(ncid, &ncp);
1010  if(stat != NC_NOERR) return stat;
1011  return NC_get_var(ncid, varid, (void *)ip, NC_CHAR);
1012 }
1013 
1014 int
1015 nc_get_var_schar(int ncid, int varid, signed char *ip)
1016 {
1017  NC *ncp;
1018  int stat = NC_check_id(ncid, &ncp);
1019  if(stat != NC_NOERR) return stat;
1020  return NC_get_var(ncid, varid, (void *)ip, NC_BYTE);
1021 }
1022 
1023 int
1024 nc_get_var_uchar(int ncid, int varid, unsigned char *ip)
1025 {
1026  NC *ncp;
1027  int stat = NC_check_id(ncid, &ncp);
1028  if(stat != NC_NOERR) return stat;
1029  return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE);
1030 }
1031 
1032 int
1033 nc_get_var_short(int ncid, int varid, short *ip)
1034 {
1035  NC* ncp;
1036  int stat = NC_check_id(ncid, &ncp);
1037  if(stat != NC_NOERR) return stat;
1038  return NC_get_var(ncid, varid, (void *)ip, NC_SHORT);
1039 }
1040 
1041 int
1042 nc_get_var_int(int ncid, int varid, int *ip)
1043 {
1044  NC* ncp;
1045  int stat = NC_check_id(ncid, &ncp);
1046  if(stat != NC_NOERR) return stat;
1047  return NC_get_var(ncid,varid, (void *)ip, NC_INT);
1048 }
1049 
1050 int
1051 nc_get_var_long(int ncid, int varid, long *ip)
1052 {
1053  NC* ncp;
1054  int stat = NC_check_id(ncid, &ncp);
1055  if(stat != NC_NOERR) return stat;
1056  return NC_get_var(ncid,varid, (void *)ip, longtype);
1057 }
1058 
1059 int
1060 nc_get_var_float(int ncid, int varid, float *ip)
1061 {
1062  NC* ncp;
1063  int stat = NC_check_id(ncid, &ncp);
1064  if(stat != NC_NOERR) return stat;
1065  return NC_get_var(ncid,varid, (void *)ip, NC_FLOAT);
1066 }
1067 
1068 int
1069 nc_get_var_double(int ncid, int varid, double *ip)
1070 {
1071  NC* ncp;
1072  int stat = NC_check_id(ncid, &ncp);
1073  if(stat != NC_NOERR) return stat;
1074  return NC_get_var(ncid,varid, (void *)ip, NC_DOUBLE);
1075 }
1076 
1077 int
1078 nc_get_var_ubyte(int ncid, int varid, unsigned char *ip)
1079 {
1080  NC* ncp;
1081  int stat = NC_check_id(ncid, &ncp);
1082  if(stat != NC_NOERR) return stat;
1083  return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE);
1084 }
1085 
1086 int
1087 nc_get_var_ushort(int ncid, int varid, unsigned short *ip)
1088 {
1089  NC* ncp;
1090  int stat = NC_check_id(ncid, &ncp);
1091  if(stat != NC_NOERR) return stat;
1092  return NC_get_var(ncid,varid, (void *)ip, NC_USHORT);
1093 }
1094 
1095 int
1096 nc_get_var_uint(int ncid, int varid, unsigned int *ip)
1097 {
1098  NC* ncp;
1099  int stat = NC_check_id(ncid, &ncp);
1100  if(stat != NC_NOERR) return stat;
1101  return NC_get_var(ncid,varid, (void *)ip, NC_UINT);
1102 }
1103 
1104 int
1105 nc_get_var_longlong(int ncid, int varid, long long *ip)
1106 {
1107  NC* ncp;
1108  int stat = NC_check_id(ncid, &ncp);
1109  if(stat != NC_NOERR) return stat;
1110  return NC_get_var(ncid,varid, (void *)ip, NC_INT64);
1111 }
1112 
1113 int
1114 nc_get_var_ulonglong(int ncid, int varid, unsigned long long *ip)
1115 {
1116  NC* ncp;
1117  int stat = NC_check_id(ncid, &ncp);
1118  if(stat != NC_NOERR) return stat;
1119  return NC_get_var(ncid,varid, (void *)ip,NC_UINT64);
1120 }
1121 
1122 #ifdef USE_NETCDF4
1123 int
1124 nc_get_var_string(int ncid, int varid, char* *ip)
1125 {
1126  NC* ncp;
1127  int stat = NC_check_id(ncid, &ncp);
1128  if(stat != NC_NOERR) return stat;
1129  return NC_get_var(ncid,varid, (void *)ip,NC_STRING);
1130 }
1131 #endif /*USE_NETCDF4*/
1132 
1174 int
1175 nc_get_vars (int ncid, int varid, const size_t * startp,
1176  const size_t * countp, const ptrdiff_t * stridep,
1177  void *ip)
1178 {
1179  NC* ncp;
1180  int stat = NC_NOERR;
1181 
1182  if ((stat = NC_check_id(ncid, &ncp)))
1183  return stat;
1184  return ncp->dispatch->get_vars(ncid, varid, startp, countp, stridep,
1185  ip, NC_NAT);
1186 }
1187 
1188 int
1189 nc_get_vars_text(int ncid, int varid, const size_t *startp,
1190  const size_t *countp, const ptrdiff_t * stridep,
1191  char *ip)
1192 {
1193  NC* ncp;
1194  int stat = NC_check_id(ncid, &ncp);
1195  if(stat != NC_NOERR) return stat;
1196  return NC_get_vars(ncid,varid,startp, countp, stridep,
1197  (void *)ip, NC_CHAR);
1198 }
1199 
1200 int
1201 nc_get_vars_schar(int ncid, int varid, const size_t *startp,
1202  const size_t *countp, const ptrdiff_t * stridep,
1203  signed char *ip)
1204 {
1205  NC* ncp;
1206  int stat = NC_check_id(ncid, &ncp);
1207  if(stat != NC_NOERR) return stat;
1208  return NC_get_vars(ncid,varid,startp, countp, stridep,
1209  (void *)ip, NC_BYTE);
1210 }
1211 
1212 int
1213 nc_get_vars_uchar(int ncid, int varid, const size_t *startp,
1214  const size_t *countp, const ptrdiff_t * stridep,
1215  unsigned char *ip)
1216 {
1217  NC* ncp;
1218  int stat = NC_check_id(ncid, &ncp);
1219  if(stat != NC_NOERR) return stat;
1220  return NC_get_vars(ncid,varid,startp, countp, stridep,
1221  (void *)ip, T_uchar);
1222 }
1223 
1224 int
1225 nc_get_vars_short(int ncid, int varid, const size_t *startp,
1226  const size_t *countp, const ptrdiff_t *stridep,
1227  short *ip)
1228 {
1229  NC* ncp;
1230  int stat = NC_check_id(ncid, &ncp);
1231  if(stat != NC_NOERR) return stat;
1232  return NC_get_vars(ncid,varid,startp, countp, stridep,
1233  (void *)ip, NC_SHORT);
1234 }
1235 
1236 int
1237 nc_get_vars_int(int ncid, int varid, const size_t *startp,
1238  const size_t *countp, const ptrdiff_t * stridep,
1239  int *ip)
1240 {
1241  NC* ncp;
1242  int stat = NC_check_id(ncid, &ncp);
1243  if(stat != NC_NOERR) return stat;
1244  return NC_get_vars(ncid,varid,startp, countp, stridep,
1245  (void *)ip, NC_INT);
1246 }
1247 
1248 int
1249 nc_get_vars_long(int ncid, int varid, const size_t *startp,
1250  const size_t *countp, const ptrdiff_t * stridep,
1251  long *ip)
1252 {
1253  NC* ncp;
1254  int stat = NC_check_id(ncid, &ncp);
1255  if(stat != NC_NOERR) return stat;
1256  return NC_get_vars(ncid,varid,startp, countp, stridep,
1257  (void *)ip, T_long);
1258 }
1259 
1260 int
1261 nc_get_vars_float(int ncid, int varid, const size_t *startp,
1262  const size_t *countp, const ptrdiff_t * stridep,
1263  float *ip)
1264 {
1265  NC* ncp;
1266  int stat = NC_check_id(ncid, &ncp);
1267  if(stat != NC_NOERR) return stat;
1268  return NC_get_vars(ncid,varid,startp, countp, stridep,
1269  (void *)ip, T_float);
1270 }
1271 
1272 int
1273 nc_get_vars_double(int ncid, int varid, const size_t *startp,
1274  const size_t *countp, const ptrdiff_t * stridep,
1275  double *ip)
1276 {
1277  NC* ncp;
1278  int stat = NC_check_id(ncid, &ncp);
1279  if(stat != NC_NOERR) return stat;
1280  return NC_get_vars(ncid,varid,startp, countp, stridep,
1281  (void *)ip, T_double);
1282 }
1283 
1284 int
1285 nc_get_vars_ubyte(int ncid, int varid, const size_t *startp,
1286  const size_t *countp, const ptrdiff_t * stridep,
1287  unsigned char *ip)
1288 {
1289  NC* ncp;
1290  int stat = NC_check_id(ncid, &ncp);
1291  if(stat != NC_NOERR) return stat;
1292  return NC_get_vars(ncid,varid, startp, countp, stridep,
1293  (void *)ip, T_ubyte);
1294 }
1295 
1296 int
1297 nc_get_vars_ushort(int ncid, int varid, const size_t *startp,
1298  const size_t *countp, const ptrdiff_t * stridep,
1299  unsigned short *ip)
1300 {
1301  NC* ncp;
1302  int stat = NC_check_id(ncid, &ncp);
1303  if(stat != NC_NOERR) return stat;
1304  return NC_get_vars(ncid,varid,startp,countp, stridep,
1305  (void *)ip, T_ushort);
1306 }
1307 
1308 int
1309 nc_get_vars_uint(int ncid, int varid, const size_t *startp,
1310  const size_t *countp, const ptrdiff_t * stridep,
1311  unsigned int *ip)
1312 {
1313  NC* ncp;
1314  int stat = NC_check_id(ncid, &ncp);
1315  if(stat != NC_NOERR) return stat;
1316  return NC_get_vars(ncid,varid,startp, countp, stridep,
1317  (void *)ip, T_uint);
1318 }
1319 
1320 int
1321 nc_get_vars_longlong(int ncid, int varid, const size_t *startp,
1322  const size_t *countp, const ptrdiff_t * stridep,
1323  long long *ip)
1324 {
1325  NC* ncp;
1326  int stat = NC_check_id(ncid, &ncp);
1327  if(stat != NC_NOERR) return stat;
1328  return NC_get_vars(ncid, varid, startp, countp, stridep,
1329  (void *)ip, T_longlong);
1330 }
1331 
1332 int
1333 nc_get_vars_ulonglong(int ncid, int varid, const size_t *startp,
1334  const size_t *countp, const ptrdiff_t * stridep,
1335  unsigned long long *ip)
1336 {
1337  NC* ncp;
1338  int stat = NC_check_id(ncid, &ncp);
1339  if(stat != NC_NOERR) return stat;
1340  return NC_get_vars(ncid, varid, startp, countp, stridep,
1341  (void *)ip, NC_UINT64);
1342 }
1343 
1344 #ifdef USE_NETCDF4
1345 int
1346 nc_get_vars_string(int ncid, int varid,
1347  const size_t *startp, const size_t *countp,
1348  const ptrdiff_t * stridep,
1349  char* *ip)
1350 {
1351  NC* ncp;
1352  int stat = NC_check_id(ncid, &ncp);
1353  if(stat != NC_NOERR) return stat;
1354  return NC_get_vars(ncid, varid, startp, countp, stridep,
1355  (void *)ip, NC_STRING);
1356 }
1357 #endif /*USE_NETCDF4*/
1358 
1414 int
1415 nc_get_varm(int ncid, int varid, const size_t * startp,
1416  const size_t * countp, const ptrdiff_t * stridep,
1417  const ptrdiff_t * imapp, void *ip)
1418 {
1419  NC* ncp;
1420  int stat = NC_NOERR;
1421 
1422  if ((stat = NC_check_id(ncid, &ncp)))
1423  return stat;
1424  return ncp->dispatch->get_varm(ncid, varid, startp, countp,
1425  stridep, imapp, ip, NC_NAT);
1426 }
1427 
1428 int
1429 nc_get_varm_schar(int ncid, int varid,
1430  const size_t *startp, const size_t *countp,
1431  const ptrdiff_t *stridep,
1432  const ptrdiff_t *imapp, signed char *ip)
1433 {
1434  NC *ncp;
1435  int stat = NC_check_id(ncid, &ncp);
1436  if(stat != NC_NOERR) return stat;
1437  return NC_get_varm(ncid, varid, startp, countp,
1438  stridep, imapp, (void *)ip, NC_BYTE);
1439 }
1440 
1441 int
1442 nc_get_varm_uchar(int ncid, int varid,
1443  const size_t *startp, const size_t *countp,
1444  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1445  unsigned char *ip)
1446 {
1447  NC *ncp;
1448  int stat = NC_check_id(ncid, &ncp);
1449  if(stat != NC_NOERR) return stat;
1450  return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_uchar);
1451 }
1452 
1453 int
1454 nc_get_varm_short(int ncid, int varid, const size_t *startp,
1455  const size_t *countp, const ptrdiff_t *stridep,
1456  const ptrdiff_t *imapp, short *ip)
1457 {
1458  NC *ncp;
1459  int stat = NC_check_id(ncid, &ncp);
1460  if(stat != NC_NOERR) return stat;
1461  return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_SHORT);
1462 }
1463 
1464 int
1465 nc_get_varm_int(int ncid, int varid,
1466  const size_t *startp, const size_t *countp,
1467  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1468  int *ip)
1469 {
1470  NC *ncp;
1471  int stat = NC_check_id(ncid, &ncp);
1472  if(stat != NC_NOERR) return stat;
1473  return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_INT);
1474 }
1475 
1476 int
1477 nc_get_varm_long(int ncid, int varid,
1478  const size_t *startp, const size_t *countp,
1479  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1480  long *ip)
1481 {
1482  NC *ncp;
1483  int stat = NC_check_id(ncid, &ncp);
1484  if(stat != NC_NOERR) return stat;
1485  return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_long);
1486 }
1487 
1488 int
1489 nc_get_varm_float(int ncid, int varid,
1490  const size_t *startp, const size_t *countp,
1491  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1492  float *ip)
1493 {
1494  NC *ncp;
1495  int stat = NC_check_id(ncid, &ncp);
1496  if(stat != NC_NOERR) return stat;
1497  return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_float);
1498 }
1499 
1500 int
1501 nc_get_varm_double(int ncid, int varid,
1502  const size_t *startp, const size_t *countp,
1503  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1504  double *ip)
1505 {
1506  NC *ncp;
1507  int stat = NC_check_id(ncid, &ncp);
1508  if(stat != NC_NOERR) return stat;
1509  return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_double);
1510 }
1511 
1512 int
1513 nc_get_varm_ubyte(int ncid, int varid,
1514  const size_t *startp, const size_t *countp,
1515  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1516  unsigned char *ip)
1517 {
1518  NC *ncp;
1519  int stat = NC_check_id(ncid, &ncp);
1520  if(stat != NC_NOERR) return stat;
1521  return NC_get_varm(ncid,varid,startp,countp,stridep,
1522  imapp, (void *)ip, T_ubyte);
1523 }
1524 
1525 int
1526 nc_get_varm_ushort(int ncid, int varid,
1527  const size_t *startp, const size_t *countp,
1528  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1529  unsigned short *ip)
1530 {
1531  NC *ncp;
1532  int stat = NC_check_id(ncid, &ncp);
1533  if(stat != NC_NOERR) return stat;
1534  return NC_get_varm(ncid, varid, startp, countp, stridep,
1535  imapp, (void *)ip, T_ushort);
1536 }
1537 
1538 int
1539 nc_get_varm_uint(int ncid, int varid,
1540  const size_t *startp, const size_t *countp,
1541  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1542  unsigned int *ip)
1543 {
1544  NC *ncp;
1545  int stat = NC_check_id(ncid, &ncp);
1546  if(stat != NC_NOERR) return stat;
1547  return NC_get_varm(ncid, varid, startp, countp,
1548  stridep, imapp, (void *)ip, T_uint);
1549 }
1550 
1551 int
1552 nc_get_varm_longlong(int ncid, int varid, const size_t *startp,
1553  const size_t *countp, const ptrdiff_t *stridep,
1554  const ptrdiff_t *imapp, long long *ip)
1555 {
1556  NC *ncp;
1557  int stat = NC_check_id(ncid, &ncp);
1558  if(stat != NC_NOERR) return stat;
1559  return NC_get_varm(ncid, varid, startp, countp, stridep, imapp,
1560  (void *)ip, T_longlong);
1561 }
1562 
1563 int
1564 nc_get_varm_ulonglong(int ncid, int varid,
1565  const size_t *startp, const size_t *countp,
1566  const ptrdiff_t *stridep, const ptrdiff_t *imapp,
1567  unsigned long long *ip)
1568 {
1569  NC *ncp;
1570  int stat = NC_check_id(ncid, &ncp);
1571  if(stat != NC_NOERR) return stat;
1572  return NC_get_varm(ncid, varid, startp, countp, stridep, imapp,
1573  (void *)ip, NC_UINT64);
1574 }
1575 
1576 int
1577 nc_get_varm_text(int ncid, int varid, const size_t *startp,
1578  const size_t *countp, const ptrdiff_t *stridep,
1579  const ptrdiff_t *imapp, char *ip)
1580 {
1581  NC *ncp;
1582  int stat = NC_check_id(ncid, &ncp);
1583  if(stat != NC_NOERR) return stat;
1584  return NC_get_varm(ncid, varid, startp, countp, stridep, imapp,
1585  (void *)ip, NC_CHAR);
1586 }
1587 
1588 #ifdef USE_NETCDF4
1589 int
1590 nc_get_varm_string(int ncid, int varid, const size_t *startp,
1591  const size_t *countp, const ptrdiff_t *stridep,
1592  const ptrdiff_t *imapp, char **ip)
1593 {
1594  NC *ncp;
1595  int stat = NC_check_id(ncid, &ncp);
1596  if(stat != NC_NOERR) return stat;
1597  return NC_get_varm(ncid, varid, startp, countp, stridep, imapp,
1598  (void *)ip, NC_STRING);
1599 }
1601 #endif /*USE_NETCDF4*/
1602 
1603  /* End of named group... */
1605 

Generated on Tue Jul 9 2013 19:17:27 for netCDF. NetCDF is a Unidata library.