1 /* Do not edit this file. It is produced from the corresponding .m4 source */
2 /*
3 * Copyright 1996, University Corporation for Atmospheric Research
4 * See netcdf/COPYRIGHT file for copying and redistribution conditions.
5 */
6 /* $Id: putget.m4 2783 2014-10-26 05:19:35Z wkliao $ */
7
8 #if HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include <string.h>
13 #include <stdlib.h>
14 #include <assert.h>
15
16 #include "xxxnetcdf.h"
17 #include "nc3dispatch.h"
18 #include "nc3internal.h"
19 #include "ncx.h"
20 #include "fbits.h"
21 #include "onstack.h"
22 #ifdef LOCKNUMREC
23 # include <mpp/shmem.h> /* for SGI/Cray SHMEM routines */
24 # ifdef LN_TEST
25 # include <stdio.h>
26 # endif
27 #endif
28
29
30 #undef MIN /* system may define MIN somewhere and complain */
31 #define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))
32
33 static int
34 readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
35 const size_t nelems, void* value, const nc_type memtype);
36 static int
37 writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
38 const size_t nelems, const void* value, const nc_type memtype);
39
40
41 /* #define ODEBUG 1 */
42
43 #if ODEBUG
44 #include <stdio.h>
45 /*
46 * Print the values of an array of size_t
47 */
48 void
arrayp(const char * label,size_t count,const size_t * array)49 arrayp(const char *label, size_t count, const size_t *array)
50 {
51 (void) fprintf(stderr, "%s", label);
52 (void) fputc('\t',stderr);
53 for(; count > 0; count--, array++)
54 (void) fprintf(stderr," %lu", (unsigned long)*array);
55 (void) fputc('\n',stderr);
56 }
57 #endif /* ODEBUG */
58
59
60 /* Begin fill */
61 /*
62 * This is tunable parameter.
63 * It essentially controls the tradeoff between the number of times
64 * memcpy() gets called to copy the external data to fill
65 * a large buffer vs the number of times its called to
66 * prepare the external data.
67 */
68 #if _SX
69 /* NEC SX specific optimization */
70 #define NFILL 2048
71 #else
72 #define NFILL 16
73 #endif
74
75
76
77 /*
78 * Next 6 type specific functions
79 * Fill a some memory with the default special value.
80 * Formerly
81 NC_arrayfill()
82 */
83 static int
NC_fill_schar(void ** xpp,size_t nelems)84 NC_fill_schar(
85 void **xpp,
86 size_t nelems) /* how many */
87 {
88 schar fillp[NFILL * sizeof(double)/X_SIZEOF_CHAR];
89
90 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
91
92 {
93 schar *vp = fillp; /* lower bound of area to be filled */
94 const schar *const end = vp + nelems;
95 while(vp < end)
96 {
97 *vp++ = NC_FILL_BYTE;
98 }
99 }
100 return ncx_putn_schar_schar(xpp, nelems, fillp ,NULL);
101 }
102
103 static int
NC_fill_char(void ** xpp,size_t nelems)104 NC_fill_char(
105 void **xpp,
106 size_t nelems) /* how many */
107 {
108 char fillp[NFILL * sizeof(double)/X_SIZEOF_CHAR];
109
110 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
111
112 {
113 char *vp = fillp; /* lower bound of area to be filled */
114 const char *const end = vp + nelems;
115 while(vp < end)
116 {
117 *vp++ = NC_FILL_CHAR;
118 }
119 }
120 return ncx_putn_char_char(xpp, nelems, fillp );
121 }
122
123 static int
NC_fill_short(void ** xpp,size_t nelems)124 NC_fill_short(
125 void **xpp,
126 size_t nelems) /* how many */
127 {
128 short fillp[NFILL * sizeof(double)/X_SIZEOF_SHORT];
129
130 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
131
132 {
133 short *vp = fillp; /* lower bound of area to be filled */
134 const short *const end = vp + nelems;
135 while(vp < end)
136 {
137 *vp++ = NC_FILL_SHORT;
138 }
139 }
140 return ncx_putn_short_short(xpp, nelems, fillp ,NULL);
141 }
142
143
144 #if (SIZEOF_INT >= X_SIZEOF_INT)
145 static int
NC_fill_int(void ** xpp,size_t nelems)146 NC_fill_int(
147 void **xpp,
148 size_t nelems) /* how many */
149 {
150 int fillp[NFILL * sizeof(double)/X_SIZEOF_INT];
151
152 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
153
154 {
155 int *vp = fillp; /* lower bound of area to be filled */
156 const int *const end = vp + nelems;
157 while(vp < end)
158 {
159 *vp++ = NC_FILL_INT;
160 }
161 }
162 return ncx_putn_int_int(xpp, nelems, fillp ,NULL);
163 }
164
165 #elif SIZEOF_LONG == X_SIZEOF_INT
166 static int
NC_fill_int(void ** xpp,size_t nelems)167 NC_fill_int(
168 void **xpp,
169 size_t nelems) /* how many */
170 {
171 long fillp[NFILL * sizeof(double)/X_SIZEOF_INT];
172
173 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
174
175 {
176 long *vp = fillp; /* lower bound of area to be filled */
177 const long *const end = vp + nelems;
178 while(vp < end)
179 {
180 *vp++ = NC_FILL_INT;
181 }
182 }
183 return ncx_putn_int_long(xpp, nelems, fillp ,NULL);
184 }
185
186 #else
187 #error "NC_fill_int implementation"
188 #endif
189
190 static int
NC_fill_float(void ** xpp,size_t nelems)191 NC_fill_float(
192 void **xpp,
193 size_t nelems) /* how many */
194 {
195 float fillp[NFILL * sizeof(double)/X_SIZEOF_FLOAT];
196
197 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
198
199 {
200 float *vp = fillp; /* lower bound of area to be filled */
201 const float *const end = vp + nelems;
202 while(vp < end)
203 {
204 *vp++ = NC_FILL_FLOAT;
205 }
206 }
207 return ncx_putn_float_float(xpp, nelems, fillp ,NULL);
208 }
209
210 static int
NC_fill_double(void ** xpp,size_t nelems)211 NC_fill_double(
212 void **xpp,
213 size_t nelems) /* how many */
214 {
215 double fillp[NFILL * sizeof(double)/X_SIZEOF_DOUBLE];
216
217 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
218
219 {
220 double *vp = fillp; /* lower bound of area to be filled */
221 const double *const end = vp + nelems;
222 while(vp < end)
223 {
224 *vp++ = NC_FILL_DOUBLE;
225 }
226 }
227 return ncx_putn_double_double(xpp, nelems, fillp ,NULL);
228 }
229
230
231 static int
NC_fill_uchar(void ** xpp,size_t nelems)232 NC_fill_uchar(
233 void **xpp,
234 size_t nelems) /* how many */
235 {
236 uchar fillp[NFILL * sizeof(double)/X_SIZEOF_UBYTE];
237
238 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
239
240 {
241 uchar *vp = fillp; /* lower bound of area to be filled */
242 const uchar *const end = vp + nelems;
243 while(vp < end)
244 {
245 *vp++ = NC_FILL_UBYTE;
246 }
247 }
248 return ncx_putn_uchar_uchar(xpp, nelems, fillp ,NULL);
249 }
250
251 static int
NC_fill_ushort(void ** xpp,size_t nelems)252 NC_fill_ushort(
253 void **xpp,
254 size_t nelems) /* how many */
255 {
256 ushort fillp[NFILL * sizeof(double)/X_SIZEOF_USHORT];
257
258 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
259
260 {
261 ushort *vp = fillp; /* lower bound of area to be filled */
262 const ushort *const end = vp + nelems;
263 while(vp < end)
264 {
265 *vp++ = NC_FILL_USHORT;
266 }
267 }
268 return ncx_putn_ushort_ushort(xpp, nelems, fillp ,NULL);
269 }
270
271 static int
NC_fill_uint(void ** xpp,size_t nelems)272 NC_fill_uint(
273 void **xpp,
274 size_t nelems) /* how many */
275 {
276 uint fillp[NFILL * sizeof(double)/X_SIZEOF_UINT];
277
278 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
279
280 {
281 uint *vp = fillp; /* lower bound of area to be filled */
282 const uint *const end = vp + nelems;
283 while(vp < end)
284 {
285 *vp++ = NC_FILL_UINT;
286 }
287 }
288 return ncx_putn_uint_uint(xpp, nelems, fillp ,NULL);
289 }
290
291 static int
NC_fill_longlong(void ** xpp,size_t nelems)292 NC_fill_longlong(
293 void **xpp,
294 size_t nelems) /* how many */
295 {
296 longlong fillp[NFILL * sizeof(double)/X_SIZEOF_LONGLONG];
297
298 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
299
300 {
301 longlong *vp = fillp; /* lower bound of area to be filled */
302 const longlong *const end = vp + nelems;
303 while(vp < end)
304 {
305 *vp++ = NC_FILL_INT64;
306 }
307 }
308 return ncx_putn_longlong_longlong(xpp, nelems, fillp ,NULL);
309 }
310
311 static int
NC_fill_ulonglong(void ** xpp,size_t nelems)312 NC_fill_ulonglong(
313 void **xpp,
314 size_t nelems) /* how many */
315 {
316 ulonglong fillp[NFILL * sizeof(double)/X_SIZEOF_ULONGLONG];
317
318 assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
319
320 {
321 ulonglong *vp = fillp; /* lower bound of area to be filled */
322 const ulonglong *const end = vp + nelems;
323 while(vp < end)
324 {
325 *vp++ = NC_FILL_UINT64;
326 }
327 }
328 return ncx_putn_ulonglong_ulonglong(xpp, nelems, fillp ,NULL);
329 }
330
331
332
333
334 /*
335 * Fill the external space for variable 'varp' values at 'recno' with
336 * the appropriate value. If 'varp' is not a record variable, fill the
337 * whole thing. For the special case when 'varp' is the only record
338 * variable and it is of type byte, char, or short, varsize should be
339 * ncp->recsize, otherwise it should be varp->len.
340 * Formerly
341 xdr_NC_fill()
342 */
343 int
fill_NC_var(NC3_INFO * ncp,const NC_var * varp,size_t varsize,size_t recno)344 fill_NC_var(NC3_INFO* ncp, const NC_var *varp, size_t varsize, size_t recno)
345 {
346 char xfillp[NFILL * X_SIZEOF_DOUBLE];
347 const size_t step = varp->xsz;
348 const size_t nelems = sizeof(xfillp)/step;
349 const size_t xsz = varp->xsz * nelems;
350 NC_attr **attrpp = NULL;
351 off_t offset;
352 size_t remaining = varsize;
353
354 void *xp;
355 int status = NC_NOERR;
356
357 /*
358 * Set up fill value
359 */
360 attrpp = NC_findattr(&varp->attrs, _FillValue);
361 if( attrpp != NULL )
362 {
363 /* User defined fill value */
364 if( (*attrpp)->type != varp->type || (*attrpp)->nelems != 1 )
365 {
366 return NC_EBADTYPE;
367 }
368 else
369 {
370 /* Use the user defined value */
371 char *cp = xfillp;
372 const char *const end = &xfillp[sizeof(xfillp)];
373
374 assert(step <= (*attrpp)->xsz);
375
376 for( /*NADA*/; cp < end; cp += step)
377 {
378 (void) memcpy(cp, (*attrpp)->xvalue, step);
379 }
380 }
381 }
382 else
383 {
384 /* use the default */
385
386 assert(xsz % X_ALIGN == 0);
387 assert(xsz <= sizeof(xfillp));
388
389 xp = xfillp;
390
391 switch(varp->type){
392 case NC_BYTE :
393 status = NC_fill_schar(&xp, nelems);
394 break;
395 case NC_CHAR :
396 status = NC_fill_char(&xp, nelems);
397 break;
398 case NC_SHORT :
399 status = NC_fill_short(&xp, nelems);
400 break;
401 case NC_INT :
402 status = NC_fill_int(&xp, nelems);
403 break;
404 case NC_FLOAT :
405 status = NC_fill_float(&xp, nelems);
406 break;
407 case NC_DOUBLE :
408 status = NC_fill_double(&xp, nelems);
409 break;
410 case NC_UBYTE :
411 status = NC_fill_uchar(&xp, nelems);
412 break;
413 case NC_USHORT :
414 status = NC_fill_ushort(&xp, nelems);
415 break;
416 case NC_UINT :
417 status = NC_fill_uint(&xp, nelems);
418 break;
419 case NC_INT64 :
420 status = NC_fill_longlong(&xp, nelems);
421 break;
422 case NC_UINT64 :
423 status = NC_fill_ulonglong(&xp, nelems);
424 break;
425 default :
426 assert("fill_NC_var invalid type" == 0);
427 status = NC_EBADTYPE;
428 break;
429 }
430 if(status != NC_NOERR)
431 return status;
432
433 assert(xp == xfillp + xsz);
434 }
435
436 /*
437 * copyout:
438 * xfillp now contains 'nelems' elements of the fill value
439 * in external representation.
440 */
441
442 /*
443 * Copy it out.
444 */
445
446 offset = varp->begin;
447 if(IS_RECVAR(varp))
448 {
449 offset += (off_t)ncp->recsize * recno;
450 }
451
452 assert(remaining > 0);
453 for(;;)
454 {
455 const size_t chunksz = MIN(remaining, ncp->chunk);
456 size_t ii;
457
458 status = ncio_get(ncp->nciop, offset, chunksz,
459 RGN_WRITE, &xp);
460 if(status != NC_NOERR)
461 {
462 return status;
463 }
464
465 /*
466 * fill the chunksz buffer in units of xsz
467 */
468 for(ii = 0; ii < chunksz/xsz; ii++)
469 {
470 (void) memcpy(xp, xfillp, xsz);
471 xp = (char *)xp + xsz;
472 }
473 /*
474 * Deal with any remainder
475 */
476 {
477 const size_t rem = chunksz % xsz;
478 if(rem != 0)
479 {
480 (void) memcpy(xp, xfillp, rem);
481 /* xp = (char *)xp + xsz; */
482 }
483
484 }
485
486 status = ncio_rel(ncp->nciop, offset, RGN_MODIFIED);
487
488 if(status != NC_NOERR)
489 {
490 break;
491 }
492
493 remaining -= chunksz;
494 if(remaining == 0)
495 break; /* normal loop exit */
496 offset += chunksz;
497
498 }
499
500 return status;
501 }
502 /* End fill */
503
504
505 /*
506 * Add a record containing the fill values.
507 */
508 static int
NCfillrecord(NC3_INFO * ncp,const NC_var * const * varpp,size_t recno)509 NCfillrecord(NC3_INFO* ncp, const NC_var *const *varpp, size_t recno)
510 {
511 size_t ii = 0;
512 for(; ii < ncp->vars.nelems; ii++, varpp++)
513 {
514 if( !IS_RECVAR(*varpp) )
515 {
516 continue; /* skip non-record variables */
517 }
518 {
519 const int status = fill_NC_var(ncp, *varpp, (*varpp)->len, recno);
520 if(status != NC_NOERR)
521 return status;
522 }
523 }
524 return NC_NOERR;
525 }
526
527
528 /*
529 * Add a record containing the fill values in the special case when
530 * there is exactly one record variable, where we don't require each
531 * record to be four-byte aligned (no record padding).
532 */
533 static int
NCfillspecialrecord(NC3_INFO * ncp,const NC_var * varp,size_t recno)534 NCfillspecialrecord(NC3_INFO* ncp, const NC_var *varp, size_t recno)
535 {
536 int status;
537 assert(IS_RECVAR(varp));
538 status = fill_NC_var(ncp, varp, ncp->recsize, recno);
539 if(status != NC_NOERR)
540 return status;
541 return NC_NOERR;
542 }
543
544
545 /*
546 * It is advantageous to
547 * #define TOUCH_LAST
548 * when using memory mapped io.
549 */
550 #if TOUCH_LAST
551 /*
552 * Grow the file to a size which can contain recno
553 */
554 static int
NCtouchlast(NC3_INFO * ncp,const NC_var * const * varpp,size_t recno)555 NCtouchlast(NC3_INFO* ncp, const NC_var *const *varpp, size_t recno)
556 {
557 int status = NC_NOERR;
558 const NC_var *varp = NULL;
559
560 {
561 size_t ii = 0;
562 for(; ii < ncp->vars.nelems; ii++, varpp++)
563 {
564 if( !IS_RECVAR(*varpp) )
565 {
566 continue; /* skip non-record variables */
567 }
568 varp = *varpp;
569 }
570 }
571 assert(varp != NULL);
572 assert( IS_RECVAR(varp) );
573 {
574 const off_t offset = varp->begin
575 + (off_t)(recno-1) * (off_t)ncp->recsize
576 + (off_t)(varp->len - varp->xsz);
577 void *xp;
578
579
580 status = ncio_get(ncp->nciop, offset, varp->xsz,
581 RGN_WRITE, &xp);
582 if(status != NC_NOERR)
583 return status;
584 (void)memset(xp, 0, varp->xsz);
585 status = ncio_rel(ncp->nciop, offset, RGN_MODIFIED);
586 }
587 return status;
588 }
589 #endif /* TOUCH_LAST */
590
591
592 /*
593 * Ensure that the netcdf file has 'numrecs' records,
594 * add records and fill as necessary.
595 */
596 static int
NCvnrecs(NC3_INFO * ncp,size_t numrecs)597 NCvnrecs(NC3_INFO* ncp, size_t numrecs)
598 {
599 int status = NC_NOERR;
600 #ifdef LOCKNUMREC
601 ushmem_t myticket = 0, nowserving = 0;
602 ushmem_t numpe = (ushmem_t) _num_pes();
603
604 /* get ticket and wait */
605 myticket = shmem_short_finc((shmem_t *) ncp->lock + LOCKNUMREC_LOCK,
606 ncp->lock[LOCKNUMREC_BASEPE]);
607 #ifdef LN_TEST
608 fprintf(stderr,"%d of %d : ticket = %hu\n",
609 _my_pe(), _num_pes(), myticket);
610 #endif
611 do {
612 shmem_short_get((shmem_t *) &nowserving,
613 (shmem_t *) ncp->lock + LOCKNUMREC_SERVING, 1,
614 ncp->lock[LOCKNUMREC_BASEPE]);
615 #ifdef LN_TEST
616 fprintf(stderr,"%d of %d : serving = %hu\n",
617 _my_pe(), _num_pes(), nowserving);
618 #endif
619 /* work-around for non-unique tickets */
620 if (nowserving > myticket && nowserving < myticket + numpe ) {
621 /* get a new ticket ... you've been bypassed */
622 /* and handle the unlikely wrap-around effect */
623 myticket = shmem_short_finc(
624 (shmem_t *) ncp->lock + LOCKNUMREC_LOCK,
625 ncp->lock[LOCKNUMREC_BASEPE]);
626 #ifdef LN_TEST
627 fprintf(stderr,"%d of %d : new ticket = %hu\n",
628 _my_pe(), _num_pes(), myticket);
629 #endif
630 }
631 } while(nowserving != myticket);
632 /* now our turn to check & update value */
633 #endif
634
635 if(numrecs > NC_get_numrecs(ncp))
636 {
637
638
639 #if TOUCH_LAST
640 status = NCtouchlast(ncp,
641 (const NC_var *const*)ncp->vars.value,
642 numrecs);
643 if(status != NC_NOERR)
644 goto common_return;
645 #endif /* TOUCH_LAST */
646
647 set_NC_ndirty(ncp);
648
649 if(!NC_dofill(ncp))
650 {
651 /* Simply set the new numrecs value */
652 NC_set_numrecs(ncp, numrecs);
653 }
654 else
655 {
656 /* Treat two cases differently:
657 - exactly one record variable (no padding)
658 - multiple record variables (each record padded
659 to 4-byte alignment)
660 */
661 NC_var **vpp = (NC_var **)ncp->vars.value;
662 NC_var *const *const end = &vpp[ncp->vars.nelems];
663 NC_var *recvarp = NULL; /* last record var */
664 int numrecvars = 0;
665 size_t cur_nrecs;
666
667 /* determine how many record variables */
668 for( /*NADA*/; vpp < end; vpp++) {
669 if(IS_RECVAR(*vpp)) {
670 recvarp = *vpp;
671 numrecvars++;
672 }
673 }
674
675 if (numrecvars != 1) { /* usual case */
676 /* Fill each record out to numrecs */
677 while((cur_nrecs = NC_get_numrecs(ncp)) < numrecs)
678 {
679 status = NCfillrecord(ncp,
680 (const NC_var *const*)ncp->vars.value,
681 cur_nrecs);
682 if(status != NC_NOERR)
683 {
684 break;
685 }
686 NC_increase_numrecs(ncp, cur_nrecs +1);
687 }
688 if(status != NC_NOERR)
689 goto common_return;
690 } else { /* special case */
691 /* Fill each record out to numrecs */
692 while((cur_nrecs = NC_get_numrecs(ncp)) < numrecs)
693 {
694 status = NCfillspecialrecord(ncp,
695 recvarp,
696 cur_nrecs);
697 if(status != NC_NOERR)
698 {
699 break;
700 }
701 NC_increase_numrecs(ncp, cur_nrecs +1);
702 }
703 if(status != NC_NOERR)
704 goto common_return;
705
706 }
707 }
708
709 if(NC_doNsync(ncp))
710 {
711 status = write_numrecs(ncp);
712 }
713
714 }
715 common_return:
716 #ifdef LOCKNUMREC
717 /* finished with our lock - increment serving number */
718 (void) shmem_short_finc((shmem_t *) ncp->lock + LOCKNUMREC_SERVING,
719 ncp->lock[LOCKNUMREC_BASEPE]);
720 #endif
721 return status;
722 }
723
724
725 /*
726 * Check whether 'coord' values are valid for the variable.
727 */
728 static int
NCcoordck(NC3_INFO * ncp,const NC_var * varp,const size_t * coord)729 NCcoordck(NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
730 {
731 const size_t *ip;
732 size_t *up;
733
734 if(varp->ndims == 0)
735 return NC_NOERR; /* 'scalar' variable */
736
737 if(IS_RECVAR(varp))
738 {
739 if(*coord > X_UINT_MAX) /* rkr: bug fix from previous X_INT_MAX */
740 return NC_EINVALCOORDS; /* sanity check */
741 #ifdef RELAX_COORD_BOUND
742 if(NC_readonly(ncp) && *coord > NC_get_numrecs(ncp))
743 #else
744 if(NC_readonly(ncp) && *coord >= NC_get_numrecs(ncp))
745 #endif
746 {
747 if(!NC_doNsync(ncp))
748 return NC_EINVALCOORDS;
749 /* else */
750 {
751 /* Update from disk and check again */
752 const int status = read_numrecs(ncp);
753 if(status != NC_NOERR)
754 return status;
755 #ifdef RELAX_COORD_BOUND
756 if(*coord > NC_get_numrecs(ncp))
757 #else
758 if(*coord >= NC_get_numrecs(ncp))
759 #endif
760 return NC_EINVALCOORDS;
761 }
762 }
763 ip = coord + 1;
764 up = varp->shape + 1;
765 }
766 else
767 {
768 ip = coord;
769 up = varp->shape;
770 }
771
772 #ifdef CDEBUG
773 fprintf(stderr," NCcoordck: coord %ld, count %d, ip %ld\n",
774 coord, varp->ndims, ip );
775 #endif /* CDEBUG */
776
777 for(; ip < coord + varp->ndims; ip++, up++)
778 {
779
780 #ifdef CDEBUG
781 fprintf(stderr," NCcoordck: ip %p, *ip %ld, up %p, *up %lu\n",
782 ip, *ip, up, *up );
783 #endif /* CDEBUG */
784
785 /* cast needed for braindead systems with signed size_t */
786 #ifdef RELAX_COORD_BOUND
787 if((unsigned long) *ip > (unsigned long) *up )
788 #else
789 if((unsigned long) *ip >= (unsigned long) *up )
790 #endif
791 return NC_EINVALCOORDS;
792 }
793
794 return NC_NOERR;
795 }
796
797
798 /*
799 * Check whether 'edges' are valid for the variable and 'start'
800 */
801 /*ARGSUSED*/
802 static int
NCedgeck(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,const size_t * edges)803 NCedgeck(const NC3_INFO* ncp, const NC_var *varp,
804 const size_t *start, const size_t *edges)
805 {
806 const size_t *const end = start + varp->ndims;
807 const size_t *shp = varp->shape;
808
809 if(varp->ndims == 0)
810 return NC_NOERR; /* 'scalar' variable */
811
812 if(IS_RECVAR(varp))
813 {
814 #ifdef RELAX_COORD_BOUND
815 if (NC_readonly(ncp) &&
816 (start[0] == NC_get_numrecs(ncp) && edges[0] > 0))
817 return(NC_EINVALCOORDS);
818 #endif
819 start++;
820 edges++;
821 shp++;
822 }
823
824 for(; start < end; start++, edges++, shp++)
825 {
826 #ifdef RELAX_COORD_BOUND
827 if ((unsigned long) *start == *shp && *edges > 0)
828 return(NC_EINVALCOORDS);
829 #endif
830 /* cast needed for braindead systems with signed size_t */
831 if((unsigned long) *edges > *shp ||
832 (unsigned long) *start + (unsigned long) *edges > *shp)
833 {
834 return(NC_EEDGE);
835 }
836 }
837 return NC_NOERR;
838 }
839
840
841 /*
842 * Translate the (variable, coord) pair into a seek index
843 */
844 static off_t
NC_varoffset(const NC3_INFO * ncp,const NC_var * varp,const size_t * coord)845 NC_varoffset(const NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
846 {
847 if(varp->ndims == 0) /* 'scalar' variable */
848 return varp->begin;
849
850 if(varp->ndims == 1)
851 {
852 if(IS_RECVAR(varp))
853 return varp->begin +
854 (off_t)(*coord) * (off_t)ncp->recsize;
855 /* else */
856 return varp->begin + (off_t)(*coord) * (off_t)varp->xsz;
857 }
858 /* else */
859 {
860 off_t lcoord = (off_t)coord[varp->ndims -1];
861
862 off_t *up = varp->dsizes +1;
863 const size_t *ip = coord;
864 const off_t *const end = varp->dsizes + varp->ndims;
865
866 if(IS_RECVAR(varp))
867 up++, ip++;
868
869 for(; up < end; up++, ip++)
870 lcoord += (off_t)(*up) * (off_t)(*ip);
871
872 lcoord *= varp->xsz;
873
874 if(IS_RECVAR(varp))
875 lcoord += (off_t)(*coord) * ncp->recsize;
876
877 lcoord += varp->begin;
878 return lcoord;
879 }
880 }
881
882
883
884 static int
putNCvx_char_char(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const char * value)885 putNCvx_char_char(NC3_INFO* ncp, const NC_var *varp,
886 const size_t *start, size_t nelems, const char *value)
887 {
888 off_t offset = NC_varoffset(ncp, varp, start);
889 size_t remaining = varp->xsz * nelems;
890 int status = NC_NOERR;
891 void *xp;
892 void *fillp=NULL;
893
894 if(nelems == 0)
895 return NC_NOERR;
896
897 assert(value != NULL);
898
899 #ifdef ERANGE_FILL
900 fillp = malloc(varp->xsz);
901 status = NC3_inq_var_fill(varp, fillp);
902 #endif
903
904 for(;;)
905 {
906 size_t extent = MIN(remaining, ncp->chunk);
907 size_t nput = ncx_howmany(varp->type, extent);
908
909 int lstatus = ncio_get(ncp->nciop, offset, extent,
910 RGN_WRITE, &xp);
911 if(lstatus != NC_NOERR)
912 return lstatus;
913
914 lstatus = ncx_putn_char_char(&xp, nput, value );
915 if(lstatus != NC_NOERR && status == NC_NOERR)
916 {
917 /* not fatal to the loop */
918 status = lstatus;
919 }
920
921 (void) ncio_rel(ncp->nciop, offset,
922 RGN_MODIFIED);
923
924 remaining -= extent;
925 if(remaining == 0)
926 break; /* normal loop exit */
927 offset += (off_t)extent;
928 value += nput;
929
930 }
931 #ifdef ERANGE_FILL
932 free(fillp);
933 #endif
934
935 return status;
936 }
937
938
939 static int
putNCvx_schar_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)940 putNCvx_schar_schar(NC3_INFO* ncp, const NC_var *varp,
941 const size_t *start, size_t nelems, const schar *value)
942 {
943 off_t offset = NC_varoffset(ncp, varp, start);
944 size_t remaining = varp->xsz * nelems;
945 int status = NC_NOERR;
946 void *xp;
947 void *fillp=NULL;
948
949 if(nelems == 0)
950 return NC_NOERR;
951
952 assert(value != NULL);
953
954 #ifdef ERANGE_FILL
955 fillp = malloc(varp->xsz);
956 status = NC3_inq_var_fill(varp, fillp);
957 #endif
958
959 for(;;)
960 {
961 size_t extent = MIN(remaining, ncp->chunk);
962 size_t nput = ncx_howmany(varp->type, extent);
963
964 int lstatus = ncio_get(ncp->nciop, offset, extent,
965 RGN_WRITE, &xp);
966 if(lstatus != NC_NOERR)
967 return lstatus;
968
969 lstatus = ncx_putn_schar_schar(&xp, nput, value ,fillp);
970 if(lstatus != NC_NOERR && status == NC_NOERR)
971 {
972 /* not fatal to the loop */
973 status = lstatus;
974 }
975
976 (void) ncio_rel(ncp->nciop, offset,
977 RGN_MODIFIED);
978
979 remaining -= extent;
980 if(remaining == 0)
981 break; /* normal loop exit */
982 offset += (off_t)extent;
983 value += nput;
984
985 }
986 #ifdef ERANGE_FILL
987 free(fillp);
988 #endif
989
990 return status;
991 }
992
993 static int
putNCvx_schar_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)994 putNCvx_schar_uchar(NC3_INFO* ncp, const NC_var *varp,
995 const size_t *start, size_t nelems, const uchar *value)
996 {
997 off_t offset = NC_varoffset(ncp, varp, start);
998 size_t remaining = varp->xsz * nelems;
999 int status = NC_NOERR;
1000 void *xp;
1001 void *fillp=NULL;
1002
1003 if(nelems == 0)
1004 return NC_NOERR;
1005
1006 assert(value != NULL);
1007
1008 #ifdef ERANGE_FILL
1009 fillp = malloc(varp->xsz);
1010 status = NC3_inq_var_fill(varp, fillp);
1011 #endif
1012
1013 for(;;)
1014 {
1015 size_t extent = MIN(remaining, ncp->chunk);
1016 size_t nput = ncx_howmany(varp->type, extent);
1017
1018 int lstatus = ncio_get(ncp->nciop, offset, extent,
1019 RGN_WRITE, &xp);
1020 if(lstatus != NC_NOERR)
1021 return lstatus;
1022
1023 lstatus = ncx_putn_schar_uchar(&xp, nput, value ,fillp);
1024 if(lstatus != NC_NOERR && status == NC_NOERR)
1025 {
1026 /* not fatal to the loop */
1027 status = lstatus;
1028 }
1029
1030 (void) ncio_rel(ncp->nciop, offset,
1031 RGN_MODIFIED);
1032
1033 remaining -= extent;
1034 if(remaining == 0)
1035 break; /* normal loop exit */
1036 offset += (off_t)extent;
1037 value += nput;
1038
1039 }
1040 #ifdef ERANGE_FILL
1041 free(fillp);
1042 #endif
1043
1044 return status;
1045 }
1046
1047 static int
putNCvx_schar_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)1048 putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
1049 const size_t *start, size_t nelems, const short *value)
1050 {
1051 off_t offset = NC_varoffset(ncp, varp, start);
1052 size_t remaining = varp->xsz * nelems;
1053 int status = NC_NOERR;
1054 void *xp;
1055 void *fillp=NULL;
1056
1057 if(nelems == 0)
1058 return NC_NOERR;
1059
1060 assert(value != NULL);
1061
1062 #ifdef ERANGE_FILL
1063 fillp = malloc(varp->xsz);
1064 status = NC3_inq_var_fill(varp, fillp);
1065 #endif
1066
1067 for(;;)
1068 {
1069 size_t extent = MIN(remaining, ncp->chunk);
1070 size_t nput = ncx_howmany(varp->type, extent);
1071
1072 int lstatus = ncio_get(ncp->nciop, offset, extent,
1073 RGN_WRITE, &xp);
1074 if(lstatus != NC_NOERR)
1075 return lstatus;
1076
1077 lstatus = ncx_putn_schar_short(&xp, nput, value ,fillp);
1078 if(lstatus != NC_NOERR && status == NC_NOERR)
1079 {
1080 /* not fatal to the loop */
1081 status = lstatus;
1082 }
1083
1084 (void) ncio_rel(ncp->nciop, offset,
1085 RGN_MODIFIED);
1086
1087 remaining -= extent;
1088 if(remaining == 0)
1089 break; /* normal loop exit */
1090 offset += (off_t)extent;
1091 value += nput;
1092
1093 }
1094 #ifdef ERANGE_FILL
1095 free(fillp);
1096 #endif
1097
1098 return status;
1099 }
1100
1101 static int
putNCvx_schar_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)1102 putNCvx_schar_int(NC3_INFO* ncp, const NC_var *varp,
1103 const size_t *start, size_t nelems, const int *value)
1104 {
1105 off_t offset = NC_varoffset(ncp, varp, start);
1106 size_t remaining = varp->xsz * nelems;
1107 int status = NC_NOERR;
1108 void *xp;
1109 void *fillp=NULL;
1110
1111 if(nelems == 0)
1112 return NC_NOERR;
1113
1114 assert(value != NULL);
1115
1116 #ifdef ERANGE_FILL
1117 fillp = malloc(varp->xsz);
1118 status = NC3_inq_var_fill(varp, fillp);
1119 #endif
1120
1121 for(;;)
1122 {
1123 size_t extent = MIN(remaining, ncp->chunk);
1124 size_t nput = ncx_howmany(varp->type, extent);
1125
1126 int lstatus = ncio_get(ncp->nciop, offset, extent,
1127 RGN_WRITE, &xp);
1128 if(lstatus != NC_NOERR)
1129 return lstatus;
1130
1131 lstatus = ncx_putn_schar_int(&xp, nput, value ,fillp);
1132 if(lstatus != NC_NOERR && status == NC_NOERR)
1133 {
1134 /* not fatal to the loop */
1135 status = lstatus;
1136 }
1137
1138 (void) ncio_rel(ncp->nciop, offset,
1139 RGN_MODIFIED);
1140
1141 remaining -= extent;
1142 if(remaining == 0)
1143 break; /* normal loop exit */
1144 offset += (off_t)extent;
1145 value += nput;
1146
1147 }
1148 #ifdef ERANGE_FILL
1149 free(fillp);
1150 #endif
1151
1152 return status;
1153 }
1154
1155 static int
putNCvx_schar_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)1156 putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
1157 const size_t *start, size_t nelems, const float *value)
1158 {
1159 off_t offset = NC_varoffset(ncp, varp, start);
1160 size_t remaining = varp->xsz * nelems;
1161 int status = NC_NOERR;
1162 void *xp;
1163 void *fillp=NULL;
1164
1165 if(nelems == 0)
1166 return NC_NOERR;
1167
1168 assert(value != NULL);
1169
1170 #ifdef ERANGE_FILL
1171 fillp = malloc(varp->xsz);
1172 status = NC3_inq_var_fill(varp, fillp);
1173 #endif
1174
1175 for(;;)
1176 {
1177 size_t extent = MIN(remaining, ncp->chunk);
1178 size_t nput = ncx_howmany(varp->type, extent);
1179
1180 int lstatus = ncio_get(ncp->nciop, offset, extent,
1181 RGN_WRITE, &xp);
1182 if(lstatus != NC_NOERR)
1183 return lstatus;
1184
1185 lstatus = ncx_putn_schar_float(&xp, nput, value ,fillp);
1186 if(lstatus != NC_NOERR && status == NC_NOERR)
1187 {
1188 /* not fatal to the loop */
1189 status = lstatus;
1190 }
1191
1192 (void) ncio_rel(ncp->nciop, offset,
1193 RGN_MODIFIED);
1194
1195 remaining -= extent;
1196 if(remaining == 0)
1197 break; /* normal loop exit */
1198 offset += (off_t)extent;
1199 value += nput;
1200
1201 }
1202 #ifdef ERANGE_FILL
1203 free(fillp);
1204 #endif
1205
1206 return status;
1207 }
1208
1209 static int
putNCvx_schar_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)1210 putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
1211 const size_t *start, size_t nelems, const double *value)
1212 {
1213 off_t offset = NC_varoffset(ncp, varp, start);
1214 size_t remaining = varp->xsz * nelems;
1215 int status = NC_NOERR;
1216 void *xp;
1217 void *fillp=NULL;
1218
1219 if(nelems == 0)
1220 return NC_NOERR;
1221
1222 assert(value != NULL);
1223
1224 #ifdef ERANGE_FILL
1225 fillp = malloc(varp->xsz);
1226 status = NC3_inq_var_fill(varp, fillp);
1227 #endif
1228
1229 for(;;)
1230 {
1231 size_t extent = MIN(remaining, ncp->chunk);
1232 size_t nput = ncx_howmany(varp->type, extent);
1233
1234 int lstatus = ncio_get(ncp->nciop, offset, extent,
1235 RGN_WRITE, &xp);
1236 if(lstatus != NC_NOERR)
1237 return lstatus;
1238
1239 lstatus = ncx_putn_schar_double(&xp, nput, value ,fillp);
1240 if(lstatus != NC_NOERR && status == NC_NOERR)
1241 {
1242 /* not fatal to the loop */
1243 status = lstatus;
1244 }
1245
1246 (void) ncio_rel(ncp->nciop, offset,
1247 RGN_MODIFIED);
1248
1249 remaining -= extent;
1250 if(remaining == 0)
1251 break; /* normal loop exit */
1252 offset += (off_t)extent;
1253 value += nput;
1254
1255 }
1256 #ifdef ERANGE_FILL
1257 free(fillp);
1258 #endif
1259
1260 return status;
1261 }
1262
1263 static int
putNCvx_schar_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)1264 putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
1265 const size_t *start, size_t nelems, const longlong *value)
1266 {
1267 off_t offset = NC_varoffset(ncp, varp, start);
1268 size_t remaining = varp->xsz * nelems;
1269 int status = NC_NOERR;
1270 void *xp;
1271 void *fillp=NULL;
1272
1273 if(nelems == 0)
1274 return NC_NOERR;
1275
1276 assert(value != NULL);
1277
1278 #ifdef ERANGE_FILL
1279 fillp = malloc(varp->xsz);
1280 status = NC3_inq_var_fill(varp, fillp);
1281 #endif
1282
1283 for(;;)
1284 {
1285 size_t extent = MIN(remaining, ncp->chunk);
1286 size_t nput = ncx_howmany(varp->type, extent);
1287
1288 int lstatus = ncio_get(ncp->nciop, offset, extent,
1289 RGN_WRITE, &xp);
1290 if(lstatus != NC_NOERR)
1291 return lstatus;
1292
1293 lstatus = ncx_putn_schar_longlong(&xp, nput, value ,fillp);
1294 if(lstatus != NC_NOERR && status == NC_NOERR)
1295 {
1296 /* not fatal to the loop */
1297 status = lstatus;
1298 }
1299
1300 (void) ncio_rel(ncp->nciop, offset,
1301 RGN_MODIFIED);
1302
1303 remaining -= extent;
1304 if(remaining == 0)
1305 break; /* normal loop exit */
1306 offset += (off_t)extent;
1307 value += nput;
1308
1309 }
1310 #ifdef ERANGE_FILL
1311 free(fillp);
1312 #endif
1313
1314 return status;
1315 }
1316
1317 static int
putNCvx_schar_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)1318 putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
1319 const size_t *start, size_t nelems, const ushort *value)
1320 {
1321 off_t offset = NC_varoffset(ncp, varp, start);
1322 size_t remaining = varp->xsz * nelems;
1323 int status = NC_NOERR;
1324 void *xp;
1325 void *fillp=NULL;
1326
1327 if(nelems == 0)
1328 return NC_NOERR;
1329
1330 assert(value != NULL);
1331
1332 #ifdef ERANGE_FILL
1333 fillp = malloc(varp->xsz);
1334 status = NC3_inq_var_fill(varp, fillp);
1335 #endif
1336
1337 for(;;)
1338 {
1339 size_t extent = MIN(remaining, ncp->chunk);
1340 size_t nput = ncx_howmany(varp->type, extent);
1341
1342 int lstatus = ncio_get(ncp->nciop, offset, extent,
1343 RGN_WRITE, &xp);
1344 if(lstatus != NC_NOERR)
1345 return lstatus;
1346
1347 lstatus = ncx_putn_schar_ushort(&xp, nput, value ,fillp);
1348 if(lstatus != NC_NOERR && status == NC_NOERR)
1349 {
1350 /* not fatal to the loop */
1351 status = lstatus;
1352 }
1353
1354 (void) ncio_rel(ncp->nciop, offset,
1355 RGN_MODIFIED);
1356
1357 remaining -= extent;
1358 if(remaining == 0)
1359 break; /* normal loop exit */
1360 offset += (off_t)extent;
1361 value += nput;
1362
1363 }
1364 #ifdef ERANGE_FILL
1365 free(fillp);
1366 #endif
1367
1368 return status;
1369 }
1370
1371 static int
putNCvx_schar_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)1372 putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
1373 const size_t *start, size_t nelems, const uint *value)
1374 {
1375 off_t offset = NC_varoffset(ncp, varp, start);
1376 size_t remaining = varp->xsz * nelems;
1377 int status = NC_NOERR;
1378 void *xp;
1379 void *fillp=NULL;
1380
1381 if(nelems == 0)
1382 return NC_NOERR;
1383
1384 assert(value != NULL);
1385
1386 #ifdef ERANGE_FILL
1387 fillp = malloc(varp->xsz);
1388 status = NC3_inq_var_fill(varp, fillp);
1389 #endif
1390
1391 for(;;)
1392 {
1393 size_t extent = MIN(remaining, ncp->chunk);
1394 size_t nput = ncx_howmany(varp->type, extent);
1395
1396 int lstatus = ncio_get(ncp->nciop, offset, extent,
1397 RGN_WRITE, &xp);
1398 if(lstatus != NC_NOERR)
1399 return lstatus;
1400
1401 lstatus = ncx_putn_schar_uint(&xp, nput, value ,fillp);
1402 if(lstatus != NC_NOERR && status == NC_NOERR)
1403 {
1404 /* not fatal to the loop */
1405 status = lstatus;
1406 }
1407
1408 (void) ncio_rel(ncp->nciop, offset,
1409 RGN_MODIFIED);
1410
1411 remaining -= extent;
1412 if(remaining == 0)
1413 break; /* normal loop exit */
1414 offset += (off_t)extent;
1415 value += nput;
1416
1417 }
1418 #ifdef ERANGE_FILL
1419 free(fillp);
1420 #endif
1421
1422 return status;
1423 }
1424
1425 static int
putNCvx_schar_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)1426 putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
1427 const size_t *start, size_t nelems, const ulonglong *value)
1428 {
1429 off_t offset = NC_varoffset(ncp, varp, start);
1430 size_t remaining = varp->xsz * nelems;
1431 int status = NC_NOERR;
1432 void *xp;
1433 void *fillp=NULL;
1434
1435 if(nelems == 0)
1436 return NC_NOERR;
1437
1438 assert(value != NULL);
1439
1440 #ifdef ERANGE_FILL
1441 fillp = malloc(varp->xsz);
1442 status = NC3_inq_var_fill(varp, fillp);
1443 #endif
1444
1445 for(;;)
1446 {
1447 size_t extent = MIN(remaining, ncp->chunk);
1448 size_t nput = ncx_howmany(varp->type, extent);
1449
1450 int lstatus = ncio_get(ncp->nciop, offset, extent,
1451 RGN_WRITE, &xp);
1452 if(lstatus != NC_NOERR)
1453 return lstatus;
1454
1455 lstatus = ncx_putn_schar_ulonglong(&xp, nput, value ,fillp);
1456 if(lstatus != NC_NOERR && status == NC_NOERR)
1457 {
1458 /* not fatal to the loop */
1459 status = lstatus;
1460 }
1461
1462 (void) ncio_rel(ncp->nciop, offset,
1463 RGN_MODIFIED);
1464
1465 remaining -= extent;
1466 if(remaining == 0)
1467 break; /* normal loop exit */
1468 offset += (off_t)extent;
1469 value += nput;
1470
1471 }
1472 #ifdef ERANGE_FILL
1473 free(fillp);
1474 #endif
1475
1476 return status;
1477 }
1478
1479
1480 static int
putNCvx_short_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)1481 putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
1482 const size_t *start, size_t nelems, const schar *value)
1483 {
1484 off_t offset = NC_varoffset(ncp, varp, start);
1485 size_t remaining = varp->xsz * nelems;
1486 int status = NC_NOERR;
1487 void *xp;
1488 void *fillp=NULL;
1489
1490 if(nelems == 0)
1491 return NC_NOERR;
1492
1493 assert(value != NULL);
1494
1495 #ifdef ERANGE_FILL
1496 fillp = malloc(varp->xsz);
1497 status = NC3_inq_var_fill(varp, fillp);
1498 #endif
1499
1500 for(;;)
1501 {
1502 size_t extent = MIN(remaining, ncp->chunk);
1503 size_t nput = ncx_howmany(varp->type, extent);
1504
1505 int lstatus = ncio_get(ncp->nciop, offset, extent,
1506 RGN_WRITE, &xp);
1507 if(lstatus != NC_NOERR)
1508 return lstatus;
1509
1510 lstatus = ncx_putn_short_schar(&xp, nput, value ,fillp);
1511 if(lstatus != NC_NOERR && status == NC_NOERR)
1512 {
1513 /* not fatal to the loop */
1514 status = lstatus;
1515 }
1516
1517 (void) ncio_rel(ncp->nciop, offset,
1518 RGN_MODIFIED);
1519
1520 remaining -= extent;
1521 if(remaining == 0)
1522 break; /* normal loop exit */
1523 offset += (off_t)extent;
1524 value += nput;
1525
1526 }
1527 #ifdef ERANGE_FILL
1528 free(fillp);
1529 #endif
1530
1531 return status;
1532 }
1533
1534 static int
putNCvx_short_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)1535 putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
1536 const size_t *start, size_t nelems, const uchar *value)
1537 {
1538 off_t offset = NC_varoffset(ncp, varp, start);
1539 size_t remaining = varp->xsz * nelems;
1540 int status = NC_NOERR;
1541 void *xp;
1542 void *fillp=NULL;
1543
1544 if(nelems == 0)
1545 return NC_NOERR;
1546
1547 assert(value != NULL);
1548
1549 #ifdef ERANGE_FILL
1550 fillp = malloc(varp->xsz);
1551 status = NC3_inq_var_fill(varp, fillp);
1552 #endif
1553
1554 for(;;)
1555 {
1556 size_t extent = MIN(remaining, ncp->chunk);
1557 size_t nput = ncx_howmany(varp->type, extent);
1558
1559 int lstatus = ncio_get(ncp->nciop, offset, extent,
1560 RGN_WRITE, &xp);
1561 if(lstatus != NC_NOERR)
1562 return lstatus;
1563
1564 lstatus = ncx_putn_short_uchar(&xp, nput, value ,fillp);
1565 if(lstatus != NC_NOERR && status == NC_NOERR)
1566 {
1567 /* not fatal to the loop */
1568 status = lstatus;
1569 }
1570
1571 (void) ncio_rel(ncp->nciop, offset,
1572 RGN_MODIFIED);
1573
1574 remaining -= extent;
1575 if(remaining == 0)
1576 break; /* normal loop exit */
1577 offset += (off_t)extent;
1578 value += nput;
1579
1580 }
1581 #ifdef ERANGE_FILL
1582 free(fillp);
1583 #endif
1584
1585 return status;
1586 }
1587
1588 static int
putNCvx_short_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)1589 putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
1590 const size_t *start, size_t nelems, const short *value)
1591 {
1592 off_t offset = NC_varoffset(ncp, varp, start);
1593 size_t remaining = varp->xsz * nelems;
1594 int status = NC_NOERR;
1595 void *xp;
1596 void *fillp=NULL;
1597
1598 if(nelems == 0)
1599 return NC_NOERR;
1600
1601 assert(value != NULL);
1602
1603 #ifdef ERANGE_FILL
1604 fillp = malloc(varp->xsz);
1605 status = NC3_inq_var_fill(varp, fillp);
1606 #endif
1607
1608 for(;;)
1609 {
1610 size_t extent = MIN(remaining, ncp->chunk);
1611 size_t nput = ncx_howmany(varp->type, extent);
1612
1613 int lstatus = ncio_get(ncp->nciop, offset, extent,
1614 RGN_WRITE, &xp);
1615 if(lstatus != NC_NOERR)
1616 return lstatus;
1617
1618 lstatus = ncx_putn_short_short(&xp, nput, value ,fillp);
1619 if(lstatus != NC_NOERR && status == NC_NOERR)
1620 {
1621 /* not fatal to the loop */
1622 status = lstatus;
1623 }
1624
1625 (void) ncio_rel(ncp->nciop, offset,
1626 RGN_MODIFIED);
1627
1628 remaining -= extent;
1629 if(remaining == 0)
1630 break; /* normal loop exit */
1631 offset += (off_t)extent;
1632 value += nput;
1633
1634 }
1635 #ifdef ERANGE_FILL
1636 free(fillp);
1637 #endif
1638
1639 return status;
1640 }
1641
1642 static int
putNCvx_short_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)1643 putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
1644 const size_t *start, size_t nelems, const int *value)
1645 {
1646 off_t offset = NC_varoffset(ncp, varp, start);
1647 size_t remaining = varp->xsz * nelems;
1648 int status = NC_NOERR;
1649 void *xp;
1650 void *fillp=NULL;
1651
1652 if(nelems == 0)
1653 return NC_NOERR;
1654
1655 assert(value != NULL);
1656
1657 #ifdef ERANGE_FILL
1658 fillp = malloc(varp->xsz);
1659 status = NC3_inq_var_fill(varp, fillp);
1660 #endif
1661
1662 for(;;)
1663 {
1664 size_t extent = MIN(remaining, ncp->chunk);
1665 size_t nput = ncx_howmany(varp->type, extent);
1666
1667 int lstatus = ncio_get(ncp->nciop, offset, extent,
1668 RGN_WRITE, &xp);
1669 if(lstatus != NC_NOERR)
1670 return lstatus;
1671
1672 lstatus = ncx_putn_short_int(&xp, nput, value ,fillp);
1673 if(lstatus != NC_NOERR && status == NC_NOERR)
1674 {
1675 /* not fatal to the loop */
1676 status = lstatus;
1677 }
1678
1679 (void) ncio_rel(ncp->nciop, offset,
1680 RGN_MODIFIED);
1681
1682 remaining -= extent;
1683 if(remaining == 0)
1684 break; /* normal loop exit */
1685 offset += (off_t)extent;
1686 value += nput;
1687
1688 }
1689 #ifdef ERANGE_FILL
1690 free(fillp);
1691 #endif
1692
1693 return status;
1694 }
1695
1696 static int
putNCvx_short_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)1697 putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
1698 const size_t *start, size_t nelems, const float *value)
1699 {
1700 off_t offset = NC_varoffset(ncp, varp, start);
1701 size_t remaining = varp->xsz * nelems;
1702 int status = NC_NOERR;
1703 void *xp;
1704 void *fillp=NULL;
1705
1706 if(nelems == 0)
1707 return NC_NOERR;
1708
1709 assert(value != NULL);
1710
1711 #ifdef ERANGE_FILL
1712 fillp = malloc(varp->xsz);
1713 status = NC3_inq_var_fill(varp, fillp);
1714 #endif
1715
1716 for(;;)
1717 {
1718 size_t extent = MIN(remaining, ncp->chunk);
1719 size_t nput = ncx_howmany(varp->type, extent);
1720
1721 int lstatus = ncio_get(ncp->nciop, offset, extent,
1722 RGN_WRITE, &xp);
1723 if(lstatus != NC_NOERR)
1724 return lstatus;
1725
1726 lstatus = ncx_putn_short_float(&xp, nput, value ,fillp);
1727 if(lstatus != NC_NOERR && status == NC_NOERR)
1728 {
1729 /* not fatal to the loop */
1730 status = lstatus;
1731 }
1732
1733 (void) ncio_rel(ncp->nciop, offset,
1734 RGN_MODIFIED);
1735
1736 remaining -= extent;
1737 if(remaining == 0)
1738 break; /* normal loop exit */
1739 offset += (off_t)extent;
1740 value += nput;
1741
1742 }
1743 #ifdef ERANGE_FILL
1744 free(fillp);
1745 #endif
1746
1747 return status;
1748 }
1749
1750 static int
putNCvx_short_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)1751 putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
1752 const size_t *start, size_t nelems, const double *value)
1753 {
1754 off_t offset = NC_varoffset(ncp, varp, start);
1755 size_t remaining = varp->xsz * nelems;
1756 int status = NC_NOERR;
1757 void *xp;
1758 void *fillp=NULL;
1759
1760 if(nelems == 0)
1761 return NC_NOERR;
1762
1763 assert(value != NULL);
1764
1765 #ifdef ERANGE_FILL
1766 fillp = malloc(varp->xsz);
1767 status = NC3_inq_var_fill(varp, fillp);
1768 #endif
1769
1770 for(;;)
1771 {
1772 size_t extent = MIN(remaining, ncp->chunk);
1773 size_t nput = ncx_howmany(varp->type, extent);
1774
1775 int lstatus = ncio_get(ncp->nciop, offset, extent,
1776 RGN_WRITE, &xp);
1777 if(lstatus != NC_NOERR)
1778 return lstatus;
1779
1780 lstatus = ncx_putn_short_double(&xp, nput, value ,fillp);
1781 if(lstatus != NC_NOERR && status == NC_NOERR)
1782 {
1783 /* not fatal to the loop */
1784 status = lstatus;
1785 }
1786
1787 (void) ncio_rel(ncp->nciop, offset,
1788 RGN_MODIFIED);
1789
1790 remaining -= extent;
1791 if(remaining == 0)
1792 break; /* normal loop exit */
1793 offset += (off_t)extent;
1794 value += nput;
1795
1796 }
1797 #ifdef ERANGE_FILL
1798 free(fillp);
1799 #endif
1800
1801 return status;
1802 }
1803
1804 static int
putNCvx_short_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)1805 putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
1806 const size_t *start, size_t nelems, const longlong *value)
1807 {
1808 off_t offset = NC_varoffset(ncp, varp, start);
1809 size_t remaining = varp->xsz * nelems;
1810 int status = NC_NOERR;
1811 void *xp;
1812 void *fillp=NULL;
1813
1814 if(nelems == 0)
1815 return NC_NOERR;
1816
1817 assert(value != NULL);
1818
1819 #ifdef ERANGE_FILL
1820 fillp = malloc(varp->xsz);
1821 status = NC3_inq_var_fill(varp, fillp);
1822 #endif
1823
1824 for(;;)
1825 {
1826 size_t extent = MIN(remaining, ncp->chunk);
1827 size_t nput = ncx_howmany(varp->type, extent);
1828
1829 int lstatus = ncio_get(ncp->nciop, offset, extent,
1830 RGN_WRITE, &xp);
1831 if(lstatus != NC_NOERR)
1832 return lstatus;
1833
1834 lstatus = ncx_putn_short_longlong(&xp, nput, value ,fillp);
1835 if(lstatus != NC_NOERR && status == NC_NOERR)
1836 {
1837 /* not fatal to the loop */
1838 status = lstatus;
1839 }
1840
1841 (void) ncio_rel(ncp->nciop, offset,
1842 RGN_MODIFIED);
1843
1844 remaining -= extent;
1845 if(remaining == 0)
1846 break; /* normal loop exit */
1847 offset += (off_t)extent;
1848 value += nput;
1849
1850 }
1851 #ifdef ERANGE_FILL
1852 free(fillp);
1853 #endif
1854
1855 return status;
1856 }
1857
1858 static int
putNCvx_short_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)1859 putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
1860 const size_t *start, size_t nelems, const ushort *value)
1861 {
1862 off_t offset = NC_varoffset(ncp, varp, start);
1863 size_t remaining = varp->xsz * nelems;
1864 int status = NC_NOERR;
1865 void *xp;
1866 void *fillp=NULL;
1867
1868 if(nelems == 0)
1869 return NC_NOERR;
1870
1871 assert(value != NULL);
1872
1873 #ifdef ERANGE_FILL
1874 fillp = malloc(varp->xsz);
1875 status = NC3_inq_var_fill(varp, fillp);
1876 #endif
1877
1878 for(;;)
1879 {
1880 size_t extent = MIN(remaining, ncp->chunk);
1881 size_t nput = ncx_howmany(varp->type, extent);
1882
1883 int lstatus = ncio_get(ncp->nciop, offset, extent,
1884 RGN_WRITE, &xp);
1885 if(lstatus != NC_NOERR)
1886 return lstatus;
1887
1888 lstatus = ncx_putn_short_ushort(&xp, nput, value ,fillp);
1889 if(lstatus != NC_NOERR && status == NC_NOERR)
1890 {
1891 /* not fatal to the loop */
1892 status = lstatus;
1893 }
1894
1895 (void) ncio_rel(ncp->nciop, offset,
1896 RGN_MODIFIED);
1897
1898 remaining -= extent;
1899 if(remaining == 0)
1900 break; /* normal loop exit */
1901 offset += (off_t)extent;
1902 value += nput;
1903
1904 }
1905 #ifdef ERANGE_FILL
1906 free(fillp);
1907 #endif
1908
1909 return status;
1910 }
1911
1912 static int
putNCvx_short_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)1913 putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
1914 const size_t *start, size_t nelems, const uint *value)
1915 {
1916 off_t offset = NC_varoffset(ncp, varp, start);
1917 size_t remaining = varp->xsz * nelems;
1918 int status = NC_NOERR;
1919 void *xp;
1920 void *fillp=NULL;
1921
1922 if(nelems == 0)
1923 return NC_NOERR;
1924
1925 assert(value != NULL);
1926
1927 #ifdef ERANGE_FILL
1928 fillp = malloc(varp->xsz);
1929 status = NC3_inq_var_fill(varp, fillp);
1930 #endif
1931
1932 for(;;)
1933 {
1934 size_t extent = MIN(remaining, ncp->chunk);
1935 size_t nput = ncx_howmany(varp->type, extent);
1936
1937 int lstatus = ncio_get(ncp->nciop, offset, extent,
1938 RGN_WRITE, &xp);
1939 if(lstatus != NC_NOERR)
1940 return lstatus;
1941
1942 lstatus = ncx_putn_short_uint(&xp, nput, value ,fillp);
1943 if(lstatus != NC_NOERR && status == NC_NOERR)
1944 {
1945 /* not fatal to the loop */
1946 status = lstatus;
1947 }
1948
1949 (void) ncio_rel(ncp->nciop, offset,
1950 RGN_MODIFIED);
1951
1952 remaining -= extent;
1953 if(remaining == 0)
1954 break; /* normal loop exit */
1955 offset += (off_t)extent;
1956 value += nput;
1957
1958 }
1959 #ifdef ERANGE_FILL
1960 free(fillp);
1961 #endif
1962
1963 return status;
1964 }
1965
1966 static int
putNCvx_short_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)1967 putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
1968 const size_t *start, size_t nelems, const ulonglong *value)
1969 {
1970 off_t offset = NC_varoffset(ncp, varp, start);
1971 size_t remaining = varp->xsz * nelems;
1972 int status = NC_NOERR;
1973 void *xp;
1974 void *fillp=NULL;
1975
1976 if(nelems == 0)
1977 return NC_NOERR;
1978
1979 assert(value != NULL);
1980
1981 #ifdef ERANGE_FILL
1982 fillp = malloc(varp->xsz);
1983 status = NC3_inq_var_fill(varp, fillp);
1984 #endif
1985
1986 for(;;)
1987 {
1988 size_t extent = MIN(remaining, ncp->chunk);
1989 size_t nput = ncx_howmany(varp->type, extent);
1990
1991 int lstatus = ncio_get(ncp->nciop, offset, extent,
1992 RGN_WRITE, &xp);
1993 if(lstatus != NC_NOERR)
1994 return lstatus;
1995
1996 lstatus = ncx_putn_short_ulonglong(&xp, nput, value ,fillp);
1997 if(lstatus != NC_NOERR && status == NC_NOERR)
1998 {
1999 /* not fatal to the loop */
2000 status = lstatus;
2001 }
2002
2003 (void) ncio_rel(ncp->nciop, offset,
2004 RGN_MODIFIED);
2005
2006 remaining -= extent;
2007 if(remaining == 0)
2008 break; /* normal loop exit */
2009 offset += (off_t)extent;
2010 value += nput;
2011
2012 }
2013 #ifdef ERANGE_FILL
2014 free(fillp);
2015 #endif
2016
2017 return status;
2018 }
2019
2020
2021 static int
putNCvx_int_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)2022 putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
2023 const size_t *start, size_t nelems, const schar *value)
2024 {
2025 off_t offset = NC_varoffset(ncp, varp, start);
2026 size_t remaining = varp->xsz * nelems;
2027 int status = NC_NOERR;
2028 void *xp;
2029 void *fillp=NULL;
2030
2031 if(nelems == 0)
2032 return NC_NOERR;
2033
2034 assert(value != NULL);
2035
2036 #ifdef ERANGE_FILL
2037 fillp = malloc(varp->xsz);
2038 status = NC3_inq_var_fill(varp, fillp);
2039 #endif
2040
2041 for(;;)
2042 {
2043 size_t extent = MIN(remaining, ncp->chunk);
2044 size_t nput = ncx_howmany(varp->type, extent);
2045
2046 int lstatus = ncio_get(ncp->nciop, offset, extent,
2047 RGN_WRITE, &xp);
2048 if(lstatus != NC_NOERR)
2049 return lstatus;
2050
2051 lstatus = ncx_putn_int_schar(&xp, nput, value ,fillp);
2052 if(lstatus != NC_NOERR && status == NC_NOERR)
2053 {
2054 /* not fatal to the loop */
2055 status = lstatus;
2056 }
2057
2058 (void) ncio_rel(ncp->nciop, offset,
2059 RGN_MODIFIED);
2060
2061 remaining -= extent;
2062 if(remaining == 0)
2063 break; /* normal loop exit */
2064 offset += (off_t)extent;
2065 value += nput;
2066
2067 }
2068 #ifdef ERANGE_FILL
2069 free(fillp);
2070 #endif
2071
2072 return status;
2073 }
2074
2075 static int
putNCvx_int_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)2076 putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
2077 const size_t *start, size_t nelems, const uchar *value)
2078 {
2079 off_t offset = NC_varoffset(ncp, varp, start);
2080 size_t remaining = varp->xsz * nelems;
2081 int status = NC_NOERR;
2082 void *xp;
2083 void *fillp=NULL;
2084
2085 if(nelems == 0)
2086 return NC_NOERR;
2087
2088 assert(value != NULL);
2089
2090 #ifdef ERANGE_FILL
2091 fillp = malloc(varp->xsz);
2092 status = NC3_inq_var_fill(varp, fillp);
2093 #endif
2094
2095 for(;;)
2096 {
2097 size_t extent = MIN(remaining, ncp->chunk);
2098 size_t nput = ncx_howmany(varp->type, extent);
2099
2100 int lstatus = ncio_get(ncp->nciop, offset, extent,
2101 RGN_WRITE, &xp);
2102 if(lstatus != NC_NOERR)
2103 return lstatus;
2104
2105 lstatus = ncx_putn_int_uchar(&xp, nput, value ,fillp);
2106 if(lstatus != NC_NOERR && status == NC_NOERR)
2107 {
2108 /* not fatal to the loop */
2109 status = lstatus;
2110 }
2111
2112 (void) ncio_rel(ncp->nciop, offset,
2113 RGN_MODIFIED);
2114
2115 remaining -= extent;
2116 if(remaining == 0)
2117 break; /* normal loop exit */
2118 offset += (off_t)extent;
2119 value += nput;
2120
2121 }
2122 #ifdef ERANGE_FILL
2123 free(fillp);
2124 #endif
2125
2126 return status;
2127 }
2128
2129 static int
putNCvx_int_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)2130 putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
2131 const size_t *start, size_t nelems, const short *value)
2132 {
2133 off_t offset = NC_varoffset(ncp, varp, start);
2134 size_t remaining = varp->xsz * nelems;
2135 int status = NC_NOERR;
2136 void *xp;
2137 void *fillp=NULL;
2138
2139 if(nelems == 0)
2140 return NC_NOERR;
2141
2142 assert(value != NULL);
2143
2144 #ifdef ERANGE_FILL
2145 fillp = malloc(varp->xsz);
2146 status = NC3_inq_var_fill(varp, fillp);
2147 #endif
2148
2149 for(;;)
2150 {
2151 size_t extent = MIN(remaining, ncp->chunk);
2152 size_t nput = ncx_howmany(varp->type, extent);
2153
2154 int lstatus = ncio_get(ncp->nciop, offset, extent,
2155 RGN_WRITE, &xp);
2156 if(lstatus != NC_NOERR)
2157 return lstatus;
2158
2159 lstatus = ncx_putn_int_short(&xp, nput, value ,fillp);
2160 if(lstatus != NC_NOERR && status == NC_NOERR)
2161 {
2162 /* not fatal to the loop */
2163 status = lstatus;
2164 }
2165
2166 (void) ncio_rel(ncp->nciop, offset,
2167 RGN_MODIFIED);
2168
2169 remaining -= extent;
2170 if(remaining == 0)
2171 break; /* normal loop exit */
2172 offset += (off_t)extent;
2173 value += nput;
2174
2175 }
2176 #ifdef ERANGE_FILL
2177 free(fillp);
2178 #endif
2179
2180 return status;
2181 }
2182
2183 static int
putNCvx_int_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)2184 putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
2185 const size_t *start, size_t nelems, const int *value)
2186 {
2187 off_t offset = NC_varoffset(ncp, varp, start);
2188 size_t remaining = varp->xsz * nelems;
2189 int status = NC_NOERR;
2190 void *xp;
2191 void *fillp=NULL;
2192
2193 if(nelems == 0)
2194 return NC_NOERR;
2195
2196 assert(value != NULL);
2197
2198 #ifdef ERANGE_FILL
2199 fillp = malloc(varp->xsz);
2200 status = NC3_inq_var_fill(varp, fillp);
2201 #endif
2202
2203 for(;;)
2204 {
2205 size_t extent = MIN(remaining, ncp->chunk);
2206 size_t nput = ncx_howmany(varp->type, extent);
2207
2208 int lstatus = ncio_get(ncp->nciop, offset, extent,
2209 RGN_WRITE, &xp);
2210 if(lstatus != NC_NOERR)
2211 return lstatus;
2212
2213 lstatus = ncx_putn_int_int(&xp, nput, value ,fillp);
2214 if(lstatus != NC_NOERR && status == NC_NOERR)
2215 {
2216 /* not fatal to the loop */
2217 status = lstatus;
2218 }
2219
2220 (void) ncio_rel(ncp->nciop, offset,
2221 RGN_MODIFIED);
2222
2223 remaining -= extent;
2224 if(remaining == 0)
2225 break; /* normal loop exit */
2226 offset += (off_t)extent;
2227 value += nput;
2228
2229 }
2230 #ifdef ERANGE_FILL
2231 free(fillp);
2232 #endif
2233
2234 return status;
2235 }
2236
2237 static int
putNCvx_int_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)2238 putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
2239 const size_t *start, size_t nelems, const float *value)
2240 {
2241 off_t offset = NC_varoffset(ncp, varp, start);
2242 size_t remaining = varp->xsz * nelems;
2243 int status = NC_NOERR;
2244 void *xp;
2245 void *fillp=NULL;
2246
2247 if(nelems == 0)
2248 return NC_NOERR;
2249
2250 assert(value != NULL);
2251
2252 #ifdef ERANGE_FILL
2253 fillp = malloc(varp->xsz);
2254 status = NC3_inq_var_fill(varp, fillp);
2255 #endif
2256
2257 for(;;)
2258 {
2259 size_t extent = MIN(remaining, ncp->chunk);
2260 size_t nput = ncx_howmany(varp->type, extent);
2261
2262 int lstatus = ncio_get(ncp->nciop, offset, extent,
2263 RGN_WRITE, &xp);
2264 if(lstatus != NC_NOERR)
2265 return lstatus;
2266
2267 lstatus = ncx_putn_int_float(&xp, nput, value ,fillp);
2268 if(lstatus != NC_NOERR && status == NC_NOERR)
2269 {
2270 /* not fatal to the loop */
2271 status = lstatus;
2272 }
2273
2274 (void) ncio_rel(ncp->nciop, offset,
2275 RGN_MODIFIED);
2276
2277 remaining -= extent;
2278 if(remaining == 0)
2279 break; /* normal loop exit */
2280 offset += (off_t)extent;
2281 value += nput;
2282
2283 }
2284 #ifdef ERANGE_FILL
2285 free(fillp);
2286 #endif
2287
2288 return status;
2289 }
2290
2291 static int
putNCvx_int_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)2292 putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
2293 const size_t *start, size_t nelems, const double *value)
2294 {
2295 off_t offset = NC_varoffset(ncp, varp, start);
2296 size_t remaining = varp->xsz * nelems;
2297 int status = NC_NOERR;
2298 void *xp;
2299 void *fillp=NULL;
2300
2301 if(nelems == 0)
2302 return NC_NOERR;
2303
2304 assert(value != NULL);
2305
2306 #ifdef ERANGE_FILL
2307 fillp = malloc(varp->xsz);
2308 status = NC3_inq_var_fill(varp, fillp);
2309 #endif
2310
2311 for(;;)
2312 {
2313 size_t extent = MIN(remaining, ncp->chunk);
2314 size_t nput = ncx_howmany(varp->type, extent);
2315
2316 int lstatus = ncio_get(ncp->nciop, offset, extent,
2317 RGN_WRITE, &xp);
2318 if(lstatus != NC_NOERR)
2319 return lstatus;
2320
2321 lstatus = ncx_putn_int_double(&xp, nput, value ,fillp);
2322 if(lstatus != NC_NOERR && status == NC_NOERR)
2323 {
2324 /* not fatal to the loop */
2325 status = lstatus;
2326 }
2327
2328 (void) ncio_rel(ncp->nciop, offset,
2329 RGN_MODIFIED);
2330
2331 remaining -= extent;
2332 if(remaining == 0)
2333 break; /* normal loop exit */
2334 offset += (off_t)extent;
2335 value += nput;
2336
2337 }
2338 #ifdef ERANGE_FILL
2339 free(fillp);
2340 #endif
2341
2342 return status;
2343 }
2344
2345 static int
putNCvx_int_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)2346 putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
2347 const size_t *start, size_t nelems, const longlong *value)
2348 {
2349 off_t offset = NC_varoffset(ncp, varp, start);
2350 size_t remaining = varp->xsz * nelems;
2351 int status = NC_NOERR;
2352 void *xp;
2353 void *fillp=NULL;
2354
2355 if(nelems == 0)
2356 return NC_NOERR;
2357
2358 assert(value != NULL);
2359
2360 #ifdef ERANGE_FILL
2361 fillp = malloc(varp->xsz);
2362 status = NC3_inq_var_fill(varp, fillp);
2363 #endif
2364
2365 for(;;)
2366 {
2367 size_t extent = MIN(remaining, ncp->chunk);
2368 size_t nput = ncx_howmany(varp->type, extent);
2369
2370 int lstatus = ncio_get(ncp->nciop, offset, extent,
2371 RGN_WRITE, &xp);
2372 if(lstatus != NC_NOERR)
2373 return lstatus;
2374
2375 lstatus = ncx_putn_int_longlong(&xp, nput, value ,fillp);
2376 if(lstatus != NC_NOERR && status == NC_NOERR)
2377 {
2378 /* not fatal to the loop */
2379 status = lstatus;
2380 }
2381
2382 (void) ncio_rel(ncp->nciop, offset,
2383 RGN_MODIFIED);
2384
2385 remaining -= extent;
2386 if(remaining == 0)
2387 break; /* normal loop exit */
2388 offset += (off_t)extent;
2389 value += nput;
2390
2391 }
2392 #ifdef ERANGE_FILL
2393 free(fillp);
2394 #endif
2395
2396 return status;
2397 }
2398
2399 static int
putNCvx_int_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)2400 putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
2401 const size_t *start, size_t nelems, const ushort *value)
2402 {
2403 off_t offset = NC_varoffset(ncp, varp, start);
2404 size_t remaining = varp->xsz * nelems;
2405 int status = NC_NOERR;
2406 void *xp;
2407 void *fillp=NULL;
2408
2409 if(nelems == 0)
2410 return NC_NOERR;
2411
2412 assert(value != NULL);
2413
2414 #ifdef ERANGE_FILL
2415 fillp = malloc(varp->xsz);
2416 status = NC3_inq_var_fill(varp, fillp);
2417 #endif
2418
2419 for(;;)
2420 {
2421 size_t extent = MIN(remaining, ncp->chunk);
2422 size_t nput = ncx_howmany(varp->type, extent);
2423
2424 int lstatus = ncio_get(ncp->nciop, offset, extent,
2425 RGN_WRITE, &xp);
2426 if(lstatus != NC_NOERR)
2427 return lstatus;
2428
2429 lstatus = ncx_putn_int_ushort(&xp, nput, value ,fillp);
2430 if(lstatus != NC_NOERR && status == NC_NOERR)
2431 {
2432 /* not fatal to the loop */
2433 status = lstatus;
2434 }
2435
2436 (void) ncio_rel(ncp->nciop, offset,
2437 RGN_MODIFIED);
2438
2439 remaining -= extent;
2440 if(remaining == 0)
2441 break; /* normal loop exit */
2442 offset += (off_t)extent;
2443 value += nput;
2444
2445 }
2446 #ifdef ERANGE_FILL
2447 free(fillp);
2448 #endif
2449
2450 return status;
2451 }
2452
2453 static int
putNCvx_int_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)2454 putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
2455 const size_t *start, size_t nelems, const uint *value)
2456 {
2457 off_t offset = NC_varoffset(ncp, varp, start);
2458 size_t remaining = varp->xsz * nelems;
2459 int status = NC_NOERR;
2460 void *xp;
2461 void *fillp=NULL;
2462
2463 if(nelems == 0)
2464 return NC_NOERR;
2465
2466 assert(value != NULL);
2467
2468 #ifdef ERANGE_FILL
2469 fillp = malloc(varp->xsz);
2470 status = NC3_inq_var_fill(varp, fillp);
2471 #endif
2472
2473 for(;;)
2474 {
2475 size_t extent = MIN(remaining, ncp->chunk);
2476 size_t nput = ncx_howmany(varp->type, extent);
2477
2478 int lstatus = ncio_get(ncp->nciop, offset, extent,
2479 RGN_WRITE, &xp);
2480 if(lstatus != NC_NOERR)
2481 return lstatus;
2482
2483 lstatus = ncx_putn_int_uint(&xp, nput, value ,fillp);
2484 if(lstatus != NC_NOERR && status == NC_NOERR)
2485 {
2486 /* not fatal to the loop */
2487 status = lstatus;
2488 }
2489
2490 (void) ncio_rel(ncp->nciop, offset,
2491 RGN_MODIFIED);
2492
2493 remaining -= extent;
2494 if(remaining == 0)
2495 break; /* normal loop exit */
2496 offset += (off_t)extent;
2497 value += nput;
2498
2499 }
2500 #ifdef ERANGE_FILL
2501 free(fillp);
2502 #endif
2503
2504 return status;
2505 }
2506
2507 static int
putNCvx_int_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)2508 putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
2509 const size_t *start, size_t nelems, const ulonglong *value)
2510 {
2511 off_t offset = NC_varoffset(ncp, varp, start);
2512 size_t remaining = varp->xsz * nelems;
2513 int status = NC_NOERR;
2514 void *xp;
2515 void *fillp=NULL;
2516
2517 if(nelems == 0)
2518 return NC_NOERR;
2519
2520 assert(value != NULL);
2521
2522 #ifdef ERANGE_FILL
2523 fillp = malloc(varp->xsz);
2524 status = NC3_inq_var_fill(varp, fillp);
2525 #endif
2526
2527 for(;;)
2528 {
2529 size_t extent = MIN(remaining, ncp->chunk);
2530 size_t nput = ncx_howmany(varp->type, extent);
2531
2532 int lstatus = ncio_get(ncp->nciop, offset, extent,
2533 RGN_WRITE, &xp);
2534 if(lstatus != NC_NOERR)
2535 return lstatus;
2536
2537 lstatus = ncx_putn_int_ulonglong(&xp, nput, value ,fillp);
2538 if(lstatus != NC_NOERR && status == NC_NOERR)
2539 {
2540 /* not fatal to the loop */
2541 status = lstatus;
2542 }
2543
2544 (void) ncio_rel(ncp->nciop, offset,
2545 RGN_MODIFIED);
2546
2547 remaining -= extent;
2548 if(remaining == 0)
2549 break; /* normal loop exit */
2550 offset += (off_t)extent;
2551 value += nput;
2552
2553 }
2554 #ifdef ERANGE_FILL
2555 free(fillp);
2556 #endif
2557
2558 return status;
2559 }
2560
2561
2562 static int
putNCvx_float_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)2563 putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
2564 const size_t *start, size_t nelems, const schar *value)
2565 {
2566 off_t offset = NC_varoffset(ncp, varp, start);
2567 size_t remaining = varp->xsz * nelems;
2568 int status = NC_NOERR;
2569 void *xp;
2570 void *fillp=NULL;
2571
2572 if(nelems == 0)
2573 return NC_NOERR;
2574
2575 assert(value != NULL);
2576
2577 #ifdef ERANGE_FILL
2578 fillp = malloc(varp->xsz);
2579 status = NC3_inq_var_fill(varp, fillp);
2580 #endif
2581
2582 for(;;)
2583 {
2584 size_t extent = MIN(remaining, ncp->chunk);
2585 size_t nput = ncx_howmany(varp->type, extent);
2586
2587 int lstatus = ncio_get(ncp->nciop, offset, extent,
2588 RGN_WRITE, &xp);
2589 if(lstatus != NC_NOERR)
2590 return lstatus;
2591
2592 lstatus = ncx_putn_float_schar(&xp, nput, value ,fillp);
2593 if(lstatus != NC_NOERR && status == NC_NOERR)
2594 {
2595 /* not fatal to the loop */
2596 status = lstatus;
2597 }
2598
2599 (void) ncio_rel(ncp->nciop, offset,
2600 RGN_MODIFIED);
2601
2602 remaining -= extent;
2603 if(remaining == 0)
2604 break; /* normal loop exit */
2605 offset += (off_t)extent;
2606 value += nput;
2607
2608 }
2609 #ifdef ERANGE_FILL
2610 free(fillp);
2611 #endif
2612
2613 return status;
2614 }
2615
2616 static int
putNCvx_float_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)2617 putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
2618 const size_t *start, size_t nelems, const uchar *value)
2619 {
2620 off_t offset = NC_varoffset(ncp, varp, start);
2621 size_t remaining = varp->xsz * nelems;
2622 int status = NC_NOERR;
2623 void *xp;
2624 void *fillp=NULL;
2625
2626 if(nelems == 0)
2627 return NC_NOERR;
2628
2629 assert(value != NULL);
2630
2631 #ifdef ERANGE_FILL
2632 fillp = malloc(varp->xsz);
2633 status = NC3_inq_var_fill(varp, fillp);
2634 #endif
2635
2636 for(;;)
2637 {
2638 size_t extent = MIN(remaining, ncp->chunk);
2639 size_t nput = ncx_howmany(varp->type, extent);
2640
2641 int lstatus = ncio_get(ncp->nciop, offset, extent,
2642 RGN_WRITE, &xp);
2643 if(lstatus != NC_NOERR)
2644 return lstatus;
2645
2646 lstatus = ncx_putn_float_uchar(&xp, nput, value ,fillp);
2647 if(lstatus != NC_NOERR && status == NC_NOERR)
2648 {
2649 /* not fatal to the loop */
2650 status = lstatus;
2651 }
2652
2653 (void) ncio_rel(ncp->nciop, offset,
2654 RGN_MODIFIED);
2655
2656 remaining -= extent;
2657 if(remaining == 0)
2658 break; /* normal loop exit */
2659 offset += (off_t)extent;
2660 value += nput;
2661
2662 }
2663 #ifdef ERANGE_FILL
2664 free(fillp);
2665 #endif
2666
2667 return status;
2668 }
2669
2670 static int
putNCvx_float_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)2671 putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
2672 const size_t *start, size_t nelems, const short *value)
2673 {
2674 off_t offset = NC_varoffset(ncp, varp, start);
2675 size_t remaining = varp->xsz * nelems;
2676 int status = NC_NOERR;
2677 void *xp;
2678 void *fillp=NULL;
2679
2680 if(nelems == 0)
2681 return NC_NOERR;
2682
2683 assert(value != NULL);
2684
2685 #ifdef ERANGE_FILL
2686 fillp = malloc(varp->xsz);
2687 status = NC3_inq_var_fill(varp, fillp);
2688 #endif
2689
2690 for(;;)
2691 {
2692 size_t extent = MIN(remaining, ncp->chunk);
2693 size_t nput = ncx_howmany(varp->type, extent);
2694
2695 int lstatus = ncio_get(ncp->nciop, offset, extent,
2696 RGN_WRITE, &xp);
2697 if(lstatus != NC_NOERR)
2698 return lstatus;
2699
2700 lstatus = ncx_putn_float_short(&xp, nput, value ,fillp);
2701 if(lstatus != NC_NOERR && status == NC_NOERR)
2702 {
2703 /* not fatal to the loop */
2704 status = lstatus;
2705 }
2706
2707 (void) ncio_rel(ncp->nciop, offset,
2708 RGN_MODIFIED);
2709
2710 remaining -= extent;
2711 if(remaining == 0)
2712 break; /* normal loop exit */
2713 offset += (off_t)extent;
2714 value += nput;
2715
2716 }
2717 #ifdef ERANGE_FILL
2718 free(fillp);
2719 #endif
2720
2721 return status;
2722 }
2723
2724 static int
putNCvx_float_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)2725 putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
2726 const size_t *start, size_t nelems, const int *value)
2727 {
2728 off_t offset = NC_varoffset(ncp, varp, start);
2729 size_t remaining = varp->xsz * nelems;
2730 int status = NC_NOERR;
2731 void *xp;
2732 void *fillp=NULL;
2733
2734 if(nelems == 0)
2735 return NC_NOERR;
2736
2737 assert(value != NULL);
2738
2739 #ifdef ERANGE_FILL
2740 fillp = malloc(varp->xsz);
2741 status = NC3_inq_var_fill(varp, fillp);
2742 #endif
2743
2744 for(;;)
2745 {
2746 size_t extent = MIN(remaining, ncp->chunk);
2747 size_t nput = ncx_howmany(varp->type, extent);
2748
2749 int lstatus = ncio_get(ncp->nciop, offset, extent,
2750 RGN_WRITE, &xp);
2751 if(lstatus != NC_NOERR)
2752 return lstatus;
2753
2754 lstatus = ncx_putn_float_int(&xp, nput, value ,fillp);
2755 if(lstatus != NC_NOERR && status == NC_NOERR)
2756 {
2757 /* not fatal to the loop */
2758 status = lstatus;
2759 }
2760
2761 (void) ncio_rel(ncp->nciop, offset,
2762 RGN_MODIFIED);
2763
2764 remaining -= extent;
2765 if(remaining == 0)
2766 break; /* normal loop exit */
2767 offset += (off_t)extent;
2768 value += nput;
2769
2770 }
2771 #ifdef ERANGE_FILL
2772 free(fillp);
2773 #endif
2774
2775 return status;
2776 }
2777
2778 static int
putNCvx_float_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)2779 putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
2780 const size_t *start, size_t nelems, const float *value)
2781 {
2782 off_t offset = NC_varoffset(ncp, varp, start);
2783 size_t remaining = varp->xsz * nelems;
2784 int status = NC_NOERR;
2785 void *xp;
2786 void *fillp=NULL;
2787
2788 if(nelems == 0)
2789 return NC_NOERR;
2790
2791 assert(value != NULL);
2792
2793 #ifdef ERANGE_FILL
2794 fillp = malloc(varp->xsz);
2795 status = NC3_inq_var_fill(varp, fillp);
2796 #endif
2797
2798 for(;;)
2799 {
2800 size_t extent = MIN(remaining, ncp->chunk);
2801 size_t nput = ncx_howmany(varp->type, extent);
2802
2803 int lstatus = ncio_get(ncp->nciop, offset, extent,
2804 RGN_WRITE, &xp);
2805 if(lstatus != NC_NOERR)
2806 return lstatus;
2807
2808 lstatus = ncx_putn_float_float(&xp, nput, value ,fillp);
2809 if(lstatus != NC_NOERR && status == NC_NOERR)
2810 {
2811 /* not fatal to the loop */
2812 status = lstatus;
2813 }
2814
2815 (void) ncio_rel(ncp->nciop, offset,
2816 RGN_MODIFIED);
2817
2818 remaining -= extent;
2819 if(remaining == 0)
2820 break; /* normal loop exit */
2821 offset += (off_t)extent;
2822 value += nput;
2823
2824 }
2825 #ifdef ERANGE_FILL
2826 free(fillp);
2827 #endif
2828
2829 return status;
2830 }
2831
2832 static int
putNCvx_float_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)2833 putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
2834 const size_t *start, size_t nelems, const double *value)
2835 {
2836 off_t offset = NC_varoffset(ncp, varp, start);
2837 size_t remaining = varp->xsz * nelems;
2838 int status = NC_NOERR;
2839 void *xp;
2840 void *fillp=NULL;
2841
2842 if(nelems == 0)
2843 return NC_NOERR;
2844
2845 assert(value != NULL);
2846
2847 #ifdef ERANGE_FILL
2848 fillp = malloc(varp->xsz);
2849 status = NC3_inq_var_fill(varp, fillp);
2850 #endif
2851
2852 for(;;)
2853 {
2854 size_t extent = MIN(remaining, ncp->chunk);
2855 size_t nput = ncx_howmany(varp->type, extent);
2856
2857 int lstatus = ncio_get(ncp->nciop, offset, extent,
2858 RGN_WRITE, &xp);
2859 if(lstatus != NC_NOERR)
2860 return lstatus;
2861
2862 lstatus = ncx_putn_float_double(&xp, nput, value ,fillp);
2863 if(lstatus != NC_NOERR && status == NC_NOERR)
2864 {
2865 /* not fatal to the loop */
2866 status = lstatus;
2867 }
2868
2869 (void) ncio_rel(ncp->nciop, offset,
2870 RGN_MODIFIED);
2871
2872 remaining -= extent;
2873 if(remaining == 0)
2874 break; /* normal loop exit */
2875 offset += (off_t)extent;
2876 value += nput;
2877
2878 }
2879 #ifdef ERANGE_FILL
2880 free(fillp);
2881 #endif
2882
2883 return status;
2884 }
2885
2886 static int
putNCvx_float_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)2887 putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
2888 const size_t *start, size_t nelems, const longlong *value)
2889 {
2890 off_t offset = NC_varoffset(ncp, varp, start);
2891 size_t remaining = varp->xsz * nelems;
2892 int status = NC_NOERR;
2893 void *xp;
2894 void *fillp=NULL;
2895
2896 if(nelems == 0)
2897 return NC_NOERR;
2898
2899 assert(value != NULL);
2900
2901 #ifdef ERANGE_FILL
2902 fillp = malloc(varp->xsz);
2903 status = NC3_inq_var_fill(varp, fillp);
2904 #endif
2905
2906 for(;;)
2907 {
2908 size_t extent = MIN(remaining, ncp->chunk);
2909 size_t nput = ncx_howmany(varp->type, extent);
2910
2911 int lstatus = ncio_get(ncp->nciop, offset, extent,
2912 RGN_WRITE, &xp);
2913 if(lstatus != NC_NOERR)
2914 return lstatus;
2915
2916 lstatus = ncx_putn_float_longlong(&xp, nput, value ,fillp);
2917 if(lstatus != NC_NOERR && status == NC_NOERR)
2918 {
2919 /* not fatal to the loop */
2920 status = lstatus;
2921 }
2922
2923 (void) ncio_rel(ncp->nciop, offset,
2924 RGN_MODIFIED);
2925
2926 remaining -= extent;
2927 if(remaining == 0)
2928 break; /* normal loop exit */
2929 offset += (off_t)extent;
2930 value += nput;
2931
2932 }
2933 #ifdef ERANGE_FILL
2934 free(fillp);
2935 #endif
2936
2937 return status;
2938 }
2939
2940 static int
putNCvx_float_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)2941 putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
2942 const size_t *start, size_t nelems, const ushort *value)
2943 {
2944 off_t offset = NC_varoffset(ncp, varp, start);
2945 size_t remaining = varp->xsz * nelems;
2946 int status = NC_NOERR;
2947 void *xp;
2948 void *fillp=NULL;
2949
2950 if(nelems == 0)
2951 return NC_NOERR;
2952
2953 assert(value != NULL);
2954
2955 #ifdef ERANGE_FILL
2956 fillp = malloc(varp->xsz);
2957 status = NC3_inq_var_fill(varp, fillp);
2958 #endif
2959
2960 for(;;)
2961 {
2962 size_t extent = MIN(remaining, ncp->chunk);
2963 size_t nput = ncx_howmany(varp->type, extent);
2964
2965 int lstatus = ncio_get(ncp->nciop, offset, extent,
2966 RGN_WRITE, &xp);
2967 if(lstatus != NC_NOERR)
2968 return lstatus;
2969
2970 lstatus = ncx_putn_float_ushort(&xp, nput, value ,fillp);
2971 if(lstatus != NC_NOERR && status == NC_NOERR)
2972 {
2973 /* not fatal to the loop */
2974 status = lstatus;
2975 }
2976
2977 (void) ncio_rel(ncp->nciop, offset,
2978 RGN_MODIFIED);
2979
2980 remaining -= extent;
2981 if(remaining == 0)
2982 break; /* normal loop exit */
2983 offset += (off_t)extent;
2984 value += nput;
2985
2986 }
2987 #ifdef ERANGE_FILL
2988 free(fillp);
2989 #endif
2990
2991 return status;
2992 }
2993
2994 static int
putNCvx_float_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)2995 putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
2996 const size_t *start, size_t nelems, const uint *value)
2997 {
2998 off_t offset = NC_varoffset(ncp, varp, start);
2999 size_t remaining = varp->xsz * nelems;
3000 int status = NC_NOERR;
3001 void *xp;
3002 void *fillp=NULL;
3003
3004 if(nelems == 0)
3005 return NC_NOERR;
3006
3007 assert(value != NULL);
3008
3009 #ifdef ERANGE_FILL
3010 fillp = malloc(varp->xsz);
3011 status = NC3_inq_var_fill(varp, fillp);
3012 #endif
3013
3014 for(;;)
3015 {
3016 size_t extent = MIN(remaining, ncp->chunk);
3017 size_t nput = ncx_howmany(varp->type, extent);
3018
3019 int lstatus = ncio_get(ncp->nciop, offset, extent,
3020 RGN_WRITE, &xp);
3021 if(lstatus != NC_NOERR)
3022 return lstatus;
3023
3024 lstatus = ncx_putn_float_uint(&xp, nput, value ,fillp);
3025 if(lstatus != NC_NOERR && status == NC_NOERR)
3026 {
3027 /* not fatal to the loop */
3028 status = lstatus;
3029 }
3030
3031 (void) ncio_rel(ncp->nciop, offset,
3032 RGN_MODIFIED);
3033
3034 remaining -= extent;
3035 if(remaining == 0)
3036 break; /* normal loop exit */
3037 offset += (off_t)extent;
3038 value += nput;
3039
3040 }
3041 #ifdef ERANGE_FILL
3042 free(fillp);
3043 #endif
3044
3045 return status;
3046 }
3047
3048 static int
putNCvx_float_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)3049 putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
3050 const size_t *start, size_t nelems, const ulonglong *value)
3051 {
3052 off_t offset = NC_varoffset(ncp, varp, start);
3053 size_t remaining = varp->xsz * nelems;
3054 int status = NC_NOERR;
3055 void *xp;
3056 void *fillp=NULL;
3057
3058 if(nelems == 0)
3059 return NC_NOERR;
3060
3061 assert(value != NULL);
3062
3063 #ifdef ERANGE_FILL
3064 fillp = malloc(varp->xsz);
3065 status = NC3_inq_var_fill(varp, fillp);
3066 #endif
3067
3068 for(;;)
3069 {
3070 size_t extent = MIN(remaining, ncp->chunk);
3071 size_t nput = ncx_howmany(varp->type, extent);
3072
3073 int lstatus = ncio_get(ncp->nciop, offset, extent,
3074 RGN_WRITE, &xp);
3075 if(lstatus != NC_NOERR)
3076 return lstatus;
3077
3078 lstatus = ncx_putn_float_ulonglong(&xp, nput, value ,fillp);
3079 if(lstatus != NC_NOERR && status == NC_NOERR)
3080 {
3081 /* not fatal to the loop */
3082 status = lstatus;
3083 }
3084
3085 (void) ncio_rel(ncp->nciop, offset,
3086 RGN_MODIFIED);
3087
3088 remaining -= extent;
3089 if(remaining == 0)
3090 break; /* normal loop exit */
3091 offset += (off_t)extent;
3092 value += nput;
3093
3094 }
3095 #ifdef ERANGE_FILL
3096 free(fillp);
3097 #endif
3098
3099 return status;
3100 }
3101
3102
3103 static int
putNCvx_double_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)3104 putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
3105 const size_t *start, size_t nelems, const schar *value)
3106 {
3107 off_t offset = NC_varoffset(ncp, varp, start);
3108 size_t remaining = varp->xsz * nelems;
3109 int status = NC_NOERR;
3110 void *xp;
3111 void *fillp=NULL;
3112
3113 if(nelems == 0)
3114 return NC_NOERR;
3115
3116 assert(value != NULL);
3117
3118 #ifdef ERANGE_FILL
3119 fillp = malloc(varp->xsz);
3120 status = NC3_inq_var_fill(varp, fillp);
3121 #endif
3122
3123 for(;;)
3124 {
3125 size_t extent = MIN(remaining, ncp->chunk);
3126 size_t nput = ncx_howmany(varp->type, extent);
3127
3128 int lstatus = ncio_get(ncp->nciop, offset, extent,
3129 RGN_WRITE, &xp);
3130 if(lstatus != NC_NOERR)
3131 return lstatus;
3132
3133 lstatus = ncx_putn_double_schar(&xp, nput, value ,fillp);
3134 if(lstatus != NC_NOERR && status == NC_NOERR)
3135 {
3136 /* not fatal to the loop */
3137 status = lstatus;
3138 }
3139
3140 (void) ncio_rel(ncp->nciop, offset,
3141 RGN_MODIFIED);
3142
3143 remaining -= extent;
3144 if(remaining == 0)
3145 break; /* normal loop exit */
3146 offset += (off_t)extent;
3147 value += nput;
3148
3149 }
3150 #ifdef ERANGE_FILL
3151 free(fillp);
3152 #endif
3153
3154 return status;
3155 }
3156
3157 static int
putNCvx_double_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)3158 putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
3159 const size_t *start, size_t nelems, const uchar *value)
3160 {
3161 off_t offset = NC_varoffset(ncp, varp, start);
3162 size_t remaining = varp->xsz * nelems;
3163 int status = NC_NOERR;
3164 void *xp;
3165 void *fillp=NULL;
3166
3167 if(nelems == 0)
3168 return NC_NOERR;
3169
3170 assert(value != NULL);
3171
3172 #ifdef ERANGE_FILL
3173 fillp = malloc(varp->xsz);
3174 status = NC3_inq_var_fill(varp, fillp);
3175 #endif
3176
3177 for(;;)
3178 {
3179 size_t extent = MIN(remaining, ncp->chunk);
3180 size_t nput = ncx_howmany(varp->type, extent);
3181
3182 int lstatus = ncio_get(ncp->nciop, offset, extent,
3183 RGN_WRITE, &xp);
3184 if(lstatus != NC_NOERR)
3185 return lstatus;
3186
3187 lstatus = ncx_putn_double_uchar(&xp, nput, value ,fillp);
3188 if(lstatus != NC_NOERR && status == NC_NOERR)
3189 {
3190 /* not fatal to the loop */
3191 status = lstatus;
3192 }
3193
3194 (void) ncio_rel(ncp->nciop, offset,
3195 RGN_MODIFIED);
3196
3197 remaining -= extent;
3198 if(remaining == 0)
3199 break; /* normal loop exit */
3200 offset += (off_t)extent;
3201 value += nput;
3202
3203 }
3204 #ifdef ERANGE_FILL
3205 free(fillp);
3206 #endif
3207
3208 return status;
3209 }
3210
3211 static int
putNCvx_double_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)3212 putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
3213 const size_t *start, size_t nelems, const short *value)
3214 {
3215 off_t offset = NC_varoffset(ncp, varp, start);
3216 size_t remaining = varp->xsz * nelems;
3217 int status = NC_NOERR;
3218 void *xp;
3219 void *fillp=NULL;
3220
3221 if(nelems == 0)
3222 return NC_NOERR;
3223
3224 assert(value != NULL);
3225
3226 #ifdef ERANGE_FILL
3227 fillp = malloc(varp->xsz);
3228 status = NC3_inq_var_fill(varp, fillp);
3229 #endif
3230
3231 for(;;)
3232 {
3233 size_t extent = MIN(remaining, ncp->chunk);
3234 size_t nput = ncx_howmany(varp->type, extent);
3235
3236 int lstatus = ncio_get(ncp->nciop, offset, extent,
3237 RGN_WRITE, &xp);
3238 if(lstatus != NC_NOERR)
3239 return lstatus;
3240
3241 lstatus = ncx_putn_double_short(&xp, nput, value ,fillp);
3242 if(lstatus != NC_NOERR && status == NC_NOERR)
3243 {
3244 /* not fatal to the loop */
3245 status = lstatus;
3246 }
3247
3248 (void) ncio_rel(ncp->nciop, offset,
3249 RGN_MODIFIED);
3250
3251 remaining -= extent;
3252 if(remaining == 0)
3253 break; /* normal loop exit */
3254 offset += (off_t)extent;
3255 value += nput;
3256
3257 }
3258 #ifdef ERANGE_FILL
3259 free(fillp);
3260 #endif
3261
3262 return status;
3263 }
3264
3265 static int
putNCvx_double_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)3266 putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
3267 const size_t *start, size_t nelems, const int *value)
3268 {
3269 off_t offset = NC_varoffset(ncp, varp, start);
3270 size_t remaining = varp->xsz * nelems;
3271 int status = NC_NOERR;
3272 void *xp;
3273 void *fillp=NULL;
3274
3275 if(nelems == 0)
3276 return NC_NOERR;
3277
3278 assert(value != NULL);
3279
3280 #ifdef ERANGE_FILL
3281 fillp = malloc(varp->xsz);
3282 status = NC3_inq_var_fill(varp, fillp);
3283 #endif
3284
3285 for(;;)
3286 {
3287 size_t extent = MIN(remaining, ncp->chunk);
3288 size_t nput = ncx_howmany(varp->type, extent);
3289
3290 int lstatus = ncio_get(ncp->nciop, offset, extent,
3291 RGN_WRITE, &xp);
3292 if(lstatus != NC_NOERR)
3293 return lstatus;
3294
3295 lstatus = ncx_putn_double_int(&xp, nput, value ,fillp);
3296 if(lstatus != NC_NOERR && status == NC_NOERR)
3297 {
3298 /* not fatal to the loop */
3299 status = lstatus;
3300 }
3301
3302 (void) ncio_rel(ncp->nciop, offset,
3303 RGN_MODIFIED);
3304
3305 remaining -= extent;
3306 if(remaining == 0)
3307 break; /* normal loop exit */
3308 offset += (off_t)extent;
3309 value += nput;
3310
3311 }
3312 #ifdef ERANGE_FILL
3313 free(fillp);
3314 #endif
3315
3316 return status;
3317 }
3318
3319 static int
putNCvx_double_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)3320 putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
3321 const size_t *start, size_t nelems, const float *value)
3322 {
3323 off_t offset = NC_varoffset(ncp, varp, start);
3324 size_t remaining = varp->xsz * nelems;
3325 int status = NC_NOERR;
3326 void *xp;
3327 void *fillp=NULL;
3328
3329 if(nelems == 0)
3330 return NC_NOERR;
3331
3332 assert(value != NULL);
3333
3334 #ifdef ERANGE_FILL
3335 fillp = malloc(varp->xsz);
3336 status = NC3_inq_var_fill(varp, fillp);
3337 #endif
3338
3339 for(;;)
3340 {
3341 size_t extent = MIN(remaining, ncp->chunk);
3342 size_t nput = ncx_howmany(varp->type, extent);
3343
3344 int lstatus = ncio_get(ncp->nciop, offset, extent,
3345 RGN_WRITE, &xp);
3346 if(lstatus != NC_NOERR)
3347 return lstatus;
3348
3349 lstatus = ncx_putn_double_float(&xp, nput, value ,fillp);
3350 if(lstatus != NC_NOERR && status == NC_NOERR)
3351 {
3352 /* not fatal to the loop */
3353 status = lstatus;
3354 }
3355
3356 (void) ncio_rel(ncp->nciop, offset,
3357 RGN_MODIFIED);
3358
3359 remaining -= extent;
3360 if(remaining == 0)
3361 break; /* normal loop exit */
3362 offset += (off_t)extent;
3363 value += nput;
3364
3365 }
3366 #ifdef ERANGE_FILL
3367 free(fillp);
3368 #endif
3369
3370 return status;
3371 }
3372
3373 static int
putNCvx_double_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)3374 putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
3375 const size_t *start, size_t nelems, const double *value)
3376 {
3377 off_t offset = NC_varoffset(ncp, varp, start);
3378 size_t remaining = varp->xsz * nelems;
3379 int status = NC_NOERR;
3380 void *xp;
3381 void *fillp=NULL;
3382
3383 if(nelems == 0)
3384 return NC_NOERR;
3385
3386 assert(value != NULL);
3387
3388 #ifdef ERANGE_FILL
3389 fillp = malloc(varp->xsz);
3390 status = NC3_inq_var_fill(varp, fillp);
3391 #endif
3392
3393 for(;;)
3394 {
3395 size_t extent = MIN(remaining, ncp->chunk);
3396 size_t nput = ncx_howmany(varp->type, extent);
3397
3398 int lstatus = ncio_get(ncp->nciop, offset, extent,
3399 RGN_WRITE, &xp);
3400 if(lstatus != NC_NOERR)
3401 return lstatus;
3402
3403 lstatus = ncx_putn_double_double(&xp, nput, value ,fillp);
3404 if(lstatus != NC_NOERR && status == NC_NOERR)
3405 {
3406 /* not fatal to the loop */
3407 status = lstatus;
3408 }
3409
3410 (void) ncio_rel(ncp->nciop, offset,
3411 RGN_MODIFIED);
3412
3413 remaining -= extent;
3414 if(remaining == 0)
3415 break; /* normal loop exit */
3416 offset += (off_t)extent;
3417 value += nput;
3418
3419 }
3420 #ifdef ERANGE_FILL
3421 free(fillp);
3422 #endif
3423
3424 return status;
3425 }
3426
3427 static int
putNCvx_double_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)3428 putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
3429 const size_t *start, size_t nelems, const longlong *value)
3430 {
3431 off_t offset = NC_varoffset(ncp, varp, start);
3432 size_t remaining = varp->xsz * nelems;
3433 int status = NC_NOERR;
3434 void *xp;
3435 void *fillp=NULL;
3436
3437 if(nelems == 0)
3438 return NC_NOERR;
3439
3440 assert(value != NULL);
3441
3442 #ifdef ERANGE_FILL
3443 fillp = malloc(varp->xsz);
3444 status = NC3_inq_var_fill(varp, fillp);
3445 #endif
3446
3447 for(;;)
3448 {
3449 size_t extent = MIN(remaining, ncp->chunk);
3450 size_t nput = ncx_howmany(varp->type, extent);
3451
3452 int lstatus = ncio_get(ncp->nciop, offset, extent,
3453 RGN_WRITE, &xp);
3454 if(lstatus != NC_NOERR)
3455 return lstatus;
3456
3457 lstatus = ncx_putn_double_longlong(&xp, nput, value ,fillp);
3458 if(lstatus != NC_NOERR && status == NC_NOERR)
3459 {
3460 /* not fatal to the loop */
3461 status = lstatus;
3462 }
3463
3464 (void) ncio_rel(ncp->nciop, offset,
3465 RGN_MODIFIED);
3466
3467 remaining -= extent;
3468 if(remaining == 0)
3469 break; /* normal loop exit */
3470 offset += (off_t)extent;
3471 value += nput;
3472
3473 }
3474 #ifdef ERANGE_FILL
3475 free(fillp);
3476 #endif
3477
3478 return status;
3479 }
3480
3481 static int
putNCvx_double_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)3482 putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
3483 const size_t *start, size_t nelems, const ushort *value)
3484 {
3485 off_t offset = NC_varoffset(ncp, varp, start);
3486 size_t remaining = varp->xsz * nelems;
3487 int status = NC_NOERR;
3488 void *xp;
3489 void *fillp=NULL;
3490
3491 if(nelems == 0)
3492 return NC_NOERR;
3493
3494 assert(value != NULL);
3495
3496 #ifdef ERANGE_FILL
3497 fillp = malloc(varp->xsz);
3498 status = NC3_inq_var_fill(varp, fillp);
3499 #endif
3500
3501 for(;;)
3502 {
3503 size_t extent = MIN(remaining, ncp->chunk);
3504 size_t nput = ncx_howmany(varp->type, extent);
3505
3506 int lstatus = ncio_get(ncp->nciop, offset, extent,
3507 RGN_WRITE, &xp);
3508 if(lstatus != NC_NOERR)
3509 return lstatus;
3510
3511 lstatus = ncx_putn_double_ushort(&xp, nput, value ,fillp);
3512 if(lstatus != NC_NOERR && status == NC_NOERR)
3513 {
3514 /* not fatal to the loop */
3515 status = lstatus;
3516 }
3517
3518 (void) ncio_rel(ncp->nciop, offset,
3519 RGN_MODIFIED);
3520
3521 remaining -= extent;
3522 if(remaining == 0)
3523 break; /* normal loop exit */
3524 offset += (off_t)extent;
3525 value += nput;
3526
3527 }
3528 #ifdef ERANGE_FILL
3529 free(fillp);
3530 #endif
3531
3532 return status;
3533 }
3534
3535 static int
putNCvx_double_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)3536 putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
3537 const size_t *start, size_t nelems, const uint *value)
3538 {
3539 off_t offset = NC_varoffset(ncp, varp, start);
3540 size_t remaining = varp->xsz * nelems;
3541 int status = NC_NOERR;
3542 void *xp;
3543 void *fillp=NULL;
3544
3545 if(nelems == 0)
3546 return NC_NOERR;
3547
3548 assert(value != NULL);
3549
3550 #ifdef ERANGE_FILL
3551 fillp = malloc(varp->xsz);
3552 status = NC3_inq_var_fill(varp, fillp);
3553 #endif
3554
3555 for(;;)
3556 {
3557 size_t extent = MIN(remaining, ncp->chunk);
3558 size_t nput = ncx_howmany(varp->type, extent);
3559
3560 int lstatus = ncio_get(ncp->nciop, offset, extent,
3561 RGN_WRITE, &xp);
3562 if(lstatus != NC_NOERR)
3563 return lstatus;
3564
3565 lstatus = ncx_putn_double_uint(&xp, nput, value ,fillp);
3566 if(lstatus != NC_NOERR && status == NC_NOERR)
3567 {
3568 /* not fatal to the loop */
3569 status = lstatus;
3570 }
3571
3572 (void) ncio_rel(ncp->nciop, offset,
3573 RGN_MODIFIED);
3574
3575 remaining -= extent;
3576 if(remaining == 0)
3577 break; /* normal loop exit */
3578 offset += (off_t)extent;
3579 value += nput;
3580
3581 }
3582 #ifdef ERANGE_FILL
3583 free(fillp);
3584 #endif
3585
3586 return status;
3587 }
3588
3589 static int
putNCvx_double_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)3590 putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
3591 const size_t *start, size_t nelems, const ulonglong *value)
3592 {
3593 off_t offset = NC_varoffset(ncp, varp, start);
3594 size_t remaining = varp->xsz * nelems;
3595 int status = NC_NOERR;
3596 void *xp;
3597 void *fillp=NULL;
3598
3599 if(nelems == 0)
3600 return NC_NOERR;
3601
3602 assert(value != NULL);
3603
3604 #ifdef ERANGE_FILL
3605 fillp = malloc(varp->xsz);
3606 status = NC3_inq_var_fill(varp, fillp);
3607 #endif
3608
3609 for(;;)
3610 {
3611 size_t extent = MIN(remaining, ncp->chunk);
3612 size_t nput = ncx_howmany(varp->type, extent);
3613
3614 int lstatus = ncio_get(ncp->nciop, offset, extent,
3615 RGN_WRITE, &xp);
3616 if(lstatus != NC_NOERR)
3617 return lstatus;
3618
3619 lstatus = ncx_putn_double_ulonglong(&xp, nput, value ,fillp);
3620 if(lstatus != NC_NOERR && status == NC_NOERR)
3621 {
3622 /* not fatal to the loop */
3623 status = lstatus;
3624 }
3625
3626 (void) ncio_rel(ncp->nciop, offset,
3627 RGN_MODIFIED);
3628
3629 remaining -= extent;
3630 if(remaining == 0)
3631 break; /* normal loop exit */
3632 offset += (off_t)extent;
3633 value += nput;
3634
3635 }
3636 #ifdef ERANGE_FILL
3637 free(fillp);
3638 #endif
3639
3640 return status;
3641 }
3642
3643
3644 static int
putNCvx_uchar_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)3645 putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
3646 const size_t *start, size_t nelems, const schar *value)
3647 {
3648 off_t offset = NC_varoffset(ncp, varp, start);
3649 size_t remaining = varp->xsz * nelems;
3650 int status = NC_NOERR;
3651 void *xp;
3652 void *fillp=NULL;
3653
3654 if(nelems == 0)
3655 return NC_NOERR;
3656
3657 assert(value != NULL);
3658
3659 #ifdef ERANGE_FILL
3660 fillp = malloc(varp->xsz);
3661 status = NC3_inq_var_fill(varp, fillp);
3662 #endif
3663
3664 for(;;)
3665 {
3666 size_t extent = MIN(remaining, ncp->chunk);
3667 size_t nput = ncx_howmany(varp->type, extent);
3668
3669 int lstatus = ncio_get(ncp->nciop, offset, extent,
3670 RGN_WRITE, &xp);
3671 if(lstatus != NC_NOERR)
3672 return lstatus;
3673
3674 lstatus = ncx_putn_uchar_schar(&xp, nput, value ,fillp);
3675 if(lstatus != NC_NOERR && status == NC_NOERR)
3676 {
3677 /* not fatal to the loop */
3678 status = lstatus;
3679 }
3680
3681 (void) ncio_rel(ncp->nciop, offset,
3682 RGN_MODIFIED);
3683
3684 remaining -= extent;
3685 if(remaining == 0)
3686 break; /* normal loop exit */
3687 offset += (off_t)extent;
3688 value += nput;
3689
3690 }
3691 #ifdef ERANGE_FILL
3692 free(fillp);
3693 #endif
3694
3695 return status;
3696 }
3697
3698 static int
putNCvx_uchar_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)3699 putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
3700 const size_t *start, size_t nelems, const uchar *value)
3701 {
3702 off_t offset = NC_varoffset(ncp, varp, start);
3703 size_t remaining = varp->xsz * nelems;
3704 int status = NC_NOERR;
3705 void *xp;
3706 void *fillp=NULL;
3707
3708 if(nelems == 0)
3709 return NC_NOERR;
3710
3711 assert(value != NULL);
3712
3713 #ifdef ERANGE_FILL
3714 fillp = malloc(varp->xsz);
3715 status = NC3_inq_var_fill(varp, fillp);
3716 #endif
3717
3718 for(;;)
3719 {
3720 size_t extent = MIN(remaining, ncp->chunk);
3721 size_t nput = ncx_howmany(varp->type, extent);
3722
3723 int lstatus = ncio_get(ncp->nciop, offset, extent,
3724 RGN_WRITE, &xp);
3725 if(lstatus != NC_NOERR)
3726 return lstatus;
3727
3728 lstatus = ncx_putn_uchar_uchar(&xp, nput, value ,fillp);
3729 if(lstatus != NC_NOERR && status == NC_NOERR)
3730 {
3731 /* not fatal to the loop */
3732 status = lstatus;
3733 }
3734
3735 (void) ncio_rel(ncp->nciop, offset,
3736 RGN_MODIFIED);
3737
3738 remaining -= extent;
3739 if(remaining == 0)
3740 break; /* normal loop exit */
3741 offset += (off_t)extent;
3742 value += nput;
3743
3744 }
3745 #ifdef ERANGE_FILL
3746 free(fillp);
3747 #endif
3748
3749 return status;
3750 }
3751
3752 static int
putNCvx_uchar_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)3753 putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
3754 const size_t *start, size_t nelems, const short *value)
3755 {
3756 off_t offset = NC_varoffset(ncp, varp, start);
3757 size_t remaining = varp->xsz * nelems;
3758 int status = NC_NOERR;
3759 void *xp;
3760 void *fillp=NULL;
3761
3762 if(nelems == 0)
3763 return NC_NOERR;
3764
3765 assert(value != NULL);
3766
3767 #ifdef ERANGE_FILL
3768 fillp = malloc(varp->xsz);
3769 status = NC3_inq_var_fill(varp, fillp);
3770 #endif
3771
3772 for(;;)
3773 {
3774 size_t extent = MIN(remaining, ncp->chunk);
3775 size_t nput = ncx_howmany(varp->type, extent);
3776
3777 int lstatus = ncio_get(ncp->nciop, offset, extent,
3778 RGN_WRITE, &xp);
3779 if(lstatus != NC_NOERR)
3780 return lstatus;
3781
3782 lstatus = ncx_putn_uchar_short(&xp, nput, value ,fillp);
3783 if(lstatus != NC_NOERR && status == NC_NOERR)
3784 {
3785 /* not fatal to the loop */
3786 status = lstatus;
3787 }
3788
3789 (void) ncio_rel(ncp->nciop, offset,
3790 RGN_MODIFIED);
3791
3792 remaining -= extent;
3793 if(remaining == 0)
3794 break; /* normal loop exit */
3795 offset += (off_t)extent;
3796 value += nput;
3797
3798 }
3799 #ifdef ERANGE_FILL
3800 free(fillp);
3801 #endif
3802
3803 return status;
3804 }
3805
3806 static int
putNCvx_uchar_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)3807 putNCvx_uchar_int(NC3_INFO* ncp, const NC_var *varp,
3808 const size_t *start, size_t nelems, const int *value)
3809 {
3810 off_t offset = NC_varoffset(ncp, varp, start);
3811 size_t remaining = varp->xsz * nelems;
3812 int status = NC_NOERR;
3813 void *xp;
3814 void *fillp=NULL;
3815
3816 if(nelems == 0)
3817 return NC_NOERR;
3818
3819 assert(value != NULL);
3820
3821 #ifdef ERANGE_FILL
3822 fillp = malloc(varp->xsz);
3823 status = NC3_inq_var_fill(varp, fillp);
3824 #endif
3825
3826 for(;;)
3827 {
3828 size_t extent = MIN(remaining, ncp->chunk);
3829 size_t nput = ncx_howmany(varp->type, extent);
3830
3831 int lstatus = ncio_get(ncp->nciop, offset, extent,
3832 RGN_WRITE, &xp);
3833 if(lstatus != NC_NOERR)
3834 return lstatus;
3835
3836 lstatus = ncx_putn_uchar_int(&xp, nput, value ,fillp);
3837 if(lstatus != NC_NOERR && status == NC_NOERR)
3838 {
3839 /* not fatal to the loop */
3840 status = lstatus;
3841 }
3842
3843 (void) ncio_rel(ncp->nciop, offset,
3844 RGN_MODIFIED);
3845
3846 remaining -= extent;
3847 if(remaining == 0)
3848 break; /* normal loop exit */
3849 offset += (off_t)extent;
3850 value += nput;
3851
3852 }
3853 #ifdef ERANGE_FILL
3854 free(fillp);
3855 #endif
3856
3857 return status;
3858 }
3859
3860 static int
putNCvx_uchar_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)3861 putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
3862 const size_t *start, size_t nelems, const float *value)
3863 {
3864 off_t offset = NC_varoffset(ncp, varp, start);
3865 size_t remaining = varp->xsz * nelems;
3866 int status = NC_NOERR;
3867 void *xp;
3868 void *fillp=NULL;
3869
3870 if(nelems == 0)
3871 return NC_NOERR;
3872
3873 assert(value != NULL);
3874
3875 #ifdef ERANGE_FILL
3876 fillp = malloc(varp->xsz);
3877 status = NC3_inq_var_fill(varp, fillp);
3878 #endif
3879
3880 for(;;)
3881 {
3882 size_t extent = MIN(remaining, ncp->chunk);
3883 size_t nput = ncx_howmany(varp->type, extent);
3884
3885 int lstatus = ncio_get(ncp->nciop, offset, extent,
3886 RGN_WRITE, &xp);
3887 if(lstatus != NC_NOERR)
3888 return lstatus;
3889
3890 lstatus = ncx_putn_uchar_float(&xp, nput, value ,fillp);
3891 if(lstatus != NC_NOERR && status == NC_NOERR)
3892 {
3893 /* not fatal to the loop */
3894 status = lstatus;
3895 }
3896
3897 (void) ncio_rel(ncp->nciop, offset,
3898 RGN_MODIFIED);
3899
3900 remaining -= extent;
3901 if(remaining == 0)
3902 break; /* normal loop exit */
3903 offset += (off_t)extent;
3904 value += nput;
3905
3906 }
3907 #ifdef ERANGE_FILL
3908 free(fillp);
3909 #endif
3910
3911 return status;
3912 }
3913
3914 static int
putNCvx_uchar_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)3915 putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
3916 const size_t *start, size_t nelems, const double *value)
3917 {
3918 off_t offset = NC_varoffset(ncp, varp, start);
3919 size_t remaining = varp->xsz * nelems;
3920 int status = NC_NOERR;
3921 void *xp;
3922 void *fillp=NULL;
3923
3924 if(nelems == 0)
3925 return NC_NOERR;
3926
3927 assert(value != NULL);
3928
3929 #ifdef ERANGE_FILL
3930 fillp = malloc(varp->xsz);
3931 status = NC3_inq_var_fill(varp, fillp);
3932 #endif
3933
3934 for(;;)
3935 {
3936 size_t extent = MIN(remaining, ncp->chunk);
3937 size_t nput = ncx_howmany(varp->type, extent);
3938
3939 int lstatus = ncio_get(ncp->nciop, offset, extent,
3940 RGN_WRITE, &xp);
3941 if(lstatus != NC_NOERR)
3942 return lstatus;
3943
3944 lstatus = ncx_putn_uchar_double(&xp, nput, value ,fillp);
3945 if(lstatus != NC_NOERR && status == NC_NOERR)
3946 {
3947 /* not fatal to the loop */
3948 status = lstatus;
3949 }
3950
3951 (void) ncio_rel(ncp->nciop, offset,
3952 RGN_MODIFIED);
3953
3954 remaining -= extent;
3955 if(remaining == 0)
3956 break; /* normal loop exit */
3957 offset += (off_t)extent;
3958 value += nput;
3959
3960 }
3961 #ifdef ERANGE_FILL
3962 free(fillp);
3963 #endif
3964
3965 return status;
3966 }
3967
3968 static int
putNCvx_uchar_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)3969 putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
3970 const size_t *start, size_t nelems, const longlong *value)
3971 {
3972 off_t offset = NC_varoffset(ncp, varp, start);
3973 size_t remaining = varp->xsz * nelems;
3974 int status = NC_NOERR;
3975 void *xp;
3976 void *fillp=NULL;
3977
3978 if(nelems == 0)
3979 return NC_NOERR;
3980
3981 assert(value != NULL);
3982
3983 #ifdef ERANGE_FILL
3984 fillp = malloc(varp->xsz);
3985 status = NC3_inq_var_fill(varp, fillp);
3986 #endif
3987
3988 for(;;)
3989 {
3990 size_t extent = MIN(remaining, ncp->chunk);
3991 size_t nput = ncx_howmany(varp->type, extent);
3992
3993 int lstatus = ncio_get(ncp->nciop, offset, extent,
3994 RGN_WRITE, &xp);
3995 if(lstatus != NC_NOERR)
3996 return lstatus;
3997
3998 lstatus = ncx_putn_uchar_longlong(&xp, nput, value ,fillp);
3999 if(lstatus != NC_NOERR && status == NC_NOERR)
4000 {
4001 /* not fatal to the loop */
4002 status = lstatus;
4003 }
4004
4005 (void) ncio_rel(ncp->nciop, offset,
4006 RGN_MODIFIED);
4007
4008 remaining -= extent;
4009 if(remaining == 0)
4010 break; /* normal loop exit */
4011 offset += (off_t)extent;
4012 value += nput;
4013
4014 }
4015 #ifdef ERANGE_FILL
4016 free(fillp);
4017 #endif
4018
4019 return status;
4020 }
4021
4022 static int
putNCvx_uchar_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)4023 putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
4024 const size_t *start, size_t nelems, const ushort *value)
4025 {
4026 off_t offset = NC_varoffset(ncp, varp, start);
4027 size_t remaining = varp->xsz * nelems;
4028 int status = NC_NOERR;
4029 void *xp;
4030 void *fillp=NULL;
4031
4032 if(nelems == 0)
4033 return NC_NOERR;
4034
4035 assert(value != NULL);
4036
4037 #ifdef ERANGE_FILL
4038 fillp = malloc(varp->xsz);
4039 status = NC3_inq_var_fill(varp, fillp);
4040 #endif
4041
4042 for(;;)
4043 {
4044 size_t extent = MIN(remaining, ncp->chunk);
4045 size_t nput = ncx_howmany(varp->type, extent);
4046
4047 int lstatus = ncio_get(ncp->nciop, offset, extent,
4048 RGN_WRITE, &xp);
4049 if(lstatus != NC_NOERR)
4050 return lstatus;
4051
4052 lstatus = ncx_putn_uchar_ushort(&xp, nput, value ,fillp);
4053 if(lstatus != NC_NOERR && status == NC_NOERR)
4054 {
4055 /* not fatal to the loop */
4056 status = lstatus;
4057 }
4058
4059 (void) ncio_rel(ncp->nciop, offset,
4060 RGN_MODIFIED);
4061
4062 remaining -= extent;
4063 if(remaining == 0)
4064 break; /* normal loop exit */
4065 offset += (off_t)extent;
4066 value += nput;
4067
4068 }
4069 #ifdef ERANGE_FILL
4070 free(fillp);
4071 #endif
4072
4073 return status;
4074 }
4075
4076 static int
putNCvx_uchar_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)4077 putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
4078 const size_t *start, size_t nelems, const uint *value)
4079 {
4080 off_t offset = NC_varoffset(ncp, varp, start);
4081 size_t remaining = varp->xsz * nelems;
4082 int status = NC_NOERR;
4083 void *xp;
4084 void *fillp=NULL;
4085
4086 if(nelems == 0)
4087 return NC_NOERR;
4088
4089 assert(value != NULL);
4090
4091 #ifdef ERANGE_FILL
4092 fillp = malloc(varp->xsz);
4093 status = NC3_inq_var_fill(varp, fillp);
4094 #endif
4095
4096 for(;;)
4097 {
4098 size_t extent = MIN(remaining, ncp->chunk);
4099 size_t nput = ncx_howmany(varp->type, extent);
4100
4101 int lstatus = ncio_get(ncp->nciop, offset, extent,
4102 RGN_WRITE, &xp);
4103 if(lstatus != NC_NOERR)
4104 return lstatus;
4105
4106 lstatus = ncx_putn_uchar_uint(&xp, nput, value ,fillp);
4107 if(lstatus != NC_NOERR && status == NC_NOERR)
4108 {
4109 /* not fatal to the loop */
4110 status = lstatus;
4111 }
4112
4113 (void) ncio_rel(ncp->nciop, offset,
4114 RGN_MODIFIED);
4115
4116 remaining -= extent;
4117 if(remaining == 0)
4118 break; /* normal loop exit */
4119 offset += (off_t)extent;
4120 value += nput;
4121
4122 }
4123 #ifdef ERANGE_FILL
4124 free(fillp);
4125 #endif
4126
4127 return status;
4128 }
4129
4130 static int
putNCvx_uchar_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)4131 putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
4132 const size_t *start, size_t nelems, const ulonglong *value)
4133 {
4134 off_t offset = NC_varoffset(ncp, varp, start);
4135 size_t remaining = varp->xsz * nelems;
4136 int status = NC_NOERR;
4137 void *xp;
4138 void *fillp=NULL;
4139
4140 if(nelems == 0)
4141 return NC_NOERR;
4142
4143 assert(value != NULL);
4144
4145 #ifdef ERANGE_FILL
4146 fillp = malloc(varp->xsz);
4147 status = NC3_inq_var_fill(varp, fillp);
4148 #endif
4149
4150 for(;;)
4151 {
4152 size_t extent = MIN(remaining, ncp->chunk);
4153 size_t nput = ncx_howmany(varp->type, extent);
4154
4155 int lstatus = ncio_get(ncp->nciop, offset, extent,
4156 RGN_WRITE, &xp);
4157 if(lstatus != NC_NOERR)
4158 return lstatus;
4159
4160 lstatus = ncx_putn_uchar_ulonglong(&xp, nput, value ,fillp);
4161 if(lstatus != NC_NOERR && status == NC_NOERR)
4162 {
4163 /* not fatal to the loop */
4164 status = lstatus;
4165 }
4166
4167 (void) ncio_rel(ncp->nciop, offset,
4168 RGN_MODIFIED);
4169
4170 remaining -= extent;
4171 if(remaining == 0)
4172 break; /* normal loop exit */
4173 offset += (off_t)extent;
4174 value += nput;
4175
4176 }
4177 #ifdef ERANGE_FILL
4178 free(fillp);
4179 #endif
4180
4181 return status;
4182 }
4183
4184
4185 static int
putNCvx_ushort_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)4186 putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
4187 const size_t *start, size_t nelems, const schar *value)
4188 {
4189 off_t offset = NC_varoffset(ncp, varp, start);
4190 size_t remaining = varp->xsz * nelems;
4191 int status = NC_NOERR;
4192 void *xp;
4193 void *fillp=NULL;
4194
4195 if(nelems == 0)
4196 return NC_NOERR;
4197
4198 assert(value != NULL);
4199
4200 #ifdef ERANGE_FILL
4201 fillp = malloc(varp->xsz);
4202 status = NC3_inq_var_fill(varp, fillp);
4203 #endif
4204
4205 for(;;)
4206 {
4207 size_t extent = MIN(remaining, ncp->chunk);
4208 size_t nput = ncx_howmany(varp->type, extent);
4209
4210 int lstatus = ncio_get(ncp->nciop, offset, extent,
4211 RGN_WRITE, &xp);
4212 if(lstatus != NC_NOERR)
4213 return lstatus;
4214
4215 lstatus = ncx_putn_ushort_schar(&xp, nput, value ,fillp);
4216 if(lstatus != NC_NOERR && status == NC_NOERR)
4217 {
4218 /* not fatal to the loop */
4219 status = lstatus;
4220 }
4221
4222 (void) ncio_rel(ncp->nciop, offset,
4223 RGN_MODIFIED);
4224
4225 remaining -= extent;
4226 if(remaining == 0)
4227 break; /* normal loop exit */
4228 offset += (off_t)extent;
4229 value += nput;
4230
4231 }
4232 #ifdef ERANGE_FILL
4233 free(fillp);
4234 #endif
4235
4236 return status;
4237 }
4238
4239 static int
putNCvx_ushort_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)4240 putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
4241 const size_t *start, size_t nelems, const uchar *value)
4242 {
4243 off_t offset = NC_varoffset(ncp, varp, start);
4244 size_t remaining = varp->xsz * nelems;
4245 int status = NC_NOERR;
4246 void *xp;
4247 void *fillp=NULL;
4248
4249 if(nelems == 0)
4250 return NC_NOERR;
4251
4252 assert(value != NULL);
4253
4254 #ifdef ERANGE_FILL
4255 fillp = malloc(varp->xsz);
4256 status = NC3_inq_var_fill(varp, fillp);
4257 #endif
4258
4259 for(;;)
4260 {
4261 size_t extent = MIN(remaining, ncp->chunk);
4262 size_t nput = ncx_howmany(varp->type, extent);
4263
4264 int lstatus = ncio_get(ncp->nciop, offset, extent,
4265 RGN_WRITE, &xp);
4266 if(lstatus != NC_NOERR)
4267 return lstatus;
4268
4269 lstatus = ncx_putn_ushort_uchar(&xp, nput, value ,fillp);
4270 if(lstatus != NC_NOERR && status == NC_NOERR)
4271 {
4272 /* not fatal to the loop */
4273 status = lstatus;
4274 }
4275
4276 (void) ncio_rel(ncp->nciop, offset,
4277 RGN_MODIFIED);
4278
4279 remaining -= extent;
4280 if(remaining == 0)
4281 break; /* normal loop exit */
4282 offset += (off_t)extent;
4283 value += nput;
4284
4285 }
4286 #ifdef ERANGE_FILL
4287 free(fillp);
4288 #endif
4289
4290 return status;
4291 }
4292
4293 static int
putNCvx_ushort_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)4294 putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
4295 const size_t *start, size_t nelems, const short *value)
4296 {
4297 off_t offset = NC_varoffset(ncp, varp, start);
4298 size_t remaining = varp->xsz * nelems;
4299 int status = NC_NOERR;
4300 void *xp;
4301 void *fillp=NULL;
4302
4303 if(nelems == 0)
4304 return NC_NOERR;
4305
4306 assert(value != NULL);
4307
4308 #ifdef ERANGE_FILL
4309 fillp = malloc(varp->xsz);
4310 status = NC3_inq_var_fill(varp, fillp);
4311 #endif
4312
4313 for(;;)
4314 {
4315 size_t extent = MIN(remaining, ncp->chunk);
4316 size_t nput = ncx_howmany(varp->type, extent);
4317
4318 int lstatus = ncio_get(ncp->nciop, offset, extent,
4319 RGN_WRITE, &xp);
4320 if(lstatus != NC_NOERR)
4321 return lstatus;
4322
4323 lstatus = ncx_putn_ushort_short(&xp, nput, value ,fillp);
4324 if(lstatus != NC_NOERR && status == NC_NOERR)
4325 {
4326 /* not fatal to the loop */
4327 status = lstatus;
4328 }
4329
4330 (void) ncio_rel(ncp->nciop, offset,
4331 RGN_MODIFIED);
4332
4333 remaining -= extent;
4334 if(remaining == 0)
4335 break; /* normal loop exit */
4336 offset += (off_t)extent;
4337 value += nput;
4338
4339 }
4340 #ifdef ERANGE_FILL
4341 free(fillp);
4342 #endif
4343
4344 return status;
4345 }
4346
4347 static int
putNCvx_ushort_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)4348 putNCvx_ushort_int(NC3_INFO* ncp, const NC_var *varp,
4349 const size_t *start, size_t nelems, const int *value)
4350 {
4351 off_t offset = NC_varoffset(ncp, varp, start);
4352 size_t remaining = varp->xsz * nelems;
4353 int status = NC_NOERR;
4354 void *xp;
4355 void *fillp=NULL;
4356
4357 if(nelems == 0)
4358 return NC_NOERR;
4359
4360 assert(value != NULL);
4361
4362 #ifdef ERANGE_FILL
4363 fillp = malloc(varp->xsz);
4364 status = NC3_inq_var_fill(varp, fillp);
4365 #endif
4366
4367 for(;;)
4368 {
4369 size_t extent = MIN(remaining, ncp->chunk);
4370 size_t nput = ncx_howmany(varp->type, extent);
4371
4372 int lstatus = ncio_get(ncp->nciop, offset, extent,
4373 RGN_WRITE, &xp);
4374 if(lstatus != NC_NOERR)
4375 return lstatus;
4376
4377 lstatus = ncx_putn_ushort_int(&xp, nput, value ,fillp);
4378 if(lstatus != NC_NOERR && status == NC_NOERR)
4379 {
4380 /* not fatal to the loop */
4381 status = lstatus;
4382 }
4383
4384 (void) ncio_rel(ncp->nciop, offset,
4385 RGN_MODIFIED);
4386
4387 remaining -= extent;
4388 if(remaining == 0)
4389 break; /* normal loop exit */
4390 offset += (off_t)extent;
4391 value += nput;
4392
4393 }
4394 #ifdef ERANGE_FILL
4395 free(fillp);
4396 #endif
4397
4398 return status;
4399 }
4400
4401 static int
putNCvx_ushort_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)4402 putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
4403 const size_t *start, size_t nelems, const float *value)
4404 {
4405 off_t offset = NC_varoffset(ncp, varp, start);
4406 size_t remaining = varp->xsz * nelems;
4407 int status = NC_NOERR;
4408 void *xp;
4409 void *fillp=NULL;
4410
4411 if(nelems == 0)
4412 return NC_NOERR;
4413
4414 assert(value != NULL);
4415
4416 #ifdef ERANGE_FILL
4417 fillp = malloc(varp->xsz);
4418 status = NC3_inq_var_fill(varp, fillp);
4419 #endif
4420
4421 for(;;)
4422 {
4423 size_t extent = MIN(remaining, ncp->chunk);
4424 size_t nput = ncx_howmany(varp->type, extent);
4425
4426 int lstatus = ncio_get(ncp->nciop, offset, extent,
4427 RGN_WRITE, &xp);
4428 if(lstatus != NC_NOERR)
4429 return lstatus;
4430
4431 lstatus = ncx_putn_ushort_float(&xp, nput, value ,fillp);
4432 if(lstatus != NC_NOERR && status == NC_NOERR)
4433 {
4434 /* not fatal to the loop */
4435 status = lstatus;
4436 }
4437
4438 (void) ncio_rel(ncp->nciop, offset,
4439 RGN_MODIFIED);
4440
4441 remaining -= extent;
4442 if(remaining == 0)
4443 break; /* normal loop exit */
4444 offset += (off_t)extent;
4445 value += nput;
4446
4447 }
4448 #ifdef ERANGE_FILL
4449 free(fillp);
4450 #endif
4451
4452 return status;
4453 }
4454
4455 static int
putNCvx_ushort_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)4456 putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
4457 const size_t *start, size_t nelems, const double *value)
4458 {
4459 off_t offset = NC_varoffset(ncp, varp, start);
4460 size_t remaining = varp->xsz * nelems;
4461 int status = NC_NOERR;
4462 void *xp;
4463 void *fillp=NULL;
4464
4465 if(nelems == 0)
4466 return NC_NOERR;
4467
4468 assert(value != NULL);
4469
4470 #ifdef ERANGE_FILL
4471 fillp = malloc(varp->xsz);
4472 status = NC3_inq_var_fill(varp, fillp);
4473 #endif
4474
4475 for(;;)
4476 {
4477 size_t extent = MIN(remaining, ncp->chunk);
4478 size_t nput = ncx_howmany(varp->type, extent);
4479
4480 int lstatus = ncio_get(ncp->nciop, offset, extent,
4481 RGN_WRITE, &xp);
4482 if(lstatus != NC_NOERR)
4483 return lstatus;
4484
4485 lstatus = ncx_putn_ushort_double(&xp, nput, value ,fillp);
4486 if(lstatus != NC_NOERR && status == NC_NOERR)
4487 {
4488 /* not fatal to the loop */
4489 status = lstatus;
4490 }
4491
4492 (void) ncio_rel(ncp->nciop, offset,
4493 RGN_MODIFIED);
4494
4495 remaining -= extent;
4496 if(remaining == 0)
4497 break; /* normal loop exit */
4498 offset += (off_t)extent;
4499 value += nput;
4500
4501 }
4502 #ifdef ERANGE_FILL
4503 free(fillp);
4504 #endif
4505
4506 return status;
4507 }
4508
4509 static int
putNCvx_ushort_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)4510 putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
4511 const size_t *start, size_t nelems, const longlong *value)
4512 {
4513 off_t offset = NC_varoffset(ncp, varp, start);
4514 size_t remaining = varp->xsz * nelems;
4515 int status = NC_NOERR;
4516 void *xp;
4517 void *fillp=NULL;
4518
4519 if(nelems == 0)
4520 return NC_NOERR;
4521
4522 assert(value != NULL);
4523
4524 #ifdef ERANGE_FILL
4525 fillp = malloc(varp->xsz);
4526 status = NC3_inq_var_fill(varp, fillp);
4527 #endif
4528
4529 for(;;)
4530 {
4531 size_t extent = MIN(remaining, ncp->chunk);
4532 size_t nput = ncx_howmany(varp->type, extent);
4533
4534 int lstatus = ncio_get(ncp->nciop, offset, extent,
4535 RGN_WRITE, &xp);
4536 if(lstatus != NC_NOERR)
4537 return lstatus;
4538
4539 lstatus = ncx_putn_ushort_longlong(&xp, nput, value ,fillp);
4540 if(lstatus != NC_NOERR && status == NC_NOERR)
4541 {
4542 /* not fatal to the loop */
4543 status = lstatus;
4544 }
4545
4546 (void) ncio_rel(ncp->nciop, offset,
4547 RGN_MODIFIED);
4548
4549 remaining -= extent;
4550 if(remaining == 0)
4551 break; /* normal loop exit */
4552 offset += (off_t)extent;
4553 value += nput;
4554
4555 }
4556 #ifdef ERANGE_FILL
4557 free(fillp);
4558 #endif
4559
4560 return status;
4561 }
4562
4563 static int
putNCvx_ushort_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)4564 putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
4565 const size_t *start, size_t nelems, const ushort *value)
4566 {
4567 off_t offset = NC_varoffset(ncp, varp, start);
4568 size_t remaining = varp->xsz * nelems;
4569 int status = NC_NOERR;
4570 void *xp;
4571 void *fillp=NULL;
4572
4573 if(nelems == 0)
4574 return NC_NOERR;
4575
4576 assert(value != NULL);
4577
4578 #ifdef ERANGE_FILL
4579 fillp = malloc(varp->xsz);
4580 status = NC3_inq_var_fill(varp, fillp);
4581 #endif
4582
4583 for(;;)
4584 {
4585 size_t extent = MIN(remaining, ncp->chunk);
4586 size_t nput = ncx_howmany(varp->type, extent);
4587
4588 int lstatus = ncio_get(ncp->nciop, offset, extent,
4589 RGN_WRITE, &xp);
4590 if(lstatus != NC_NOERR)
4591 return lstatus;
4592
4593 lstatus = ncx_putn_ushort_ushort(&xp, nput, value ,fillp);
4594 if(lstatus != NC_NOERR && status == NC_NOERR)
4595 {
4596 /* not fatal to the loop */
4597 status = lstatus;
4598 }
4599
4600 (void) ncio_rel(ncp->nciop, offset,
4601 RGN_MODIFIED);
4602
4603 remaining -= extent;
4604 if(remaining == 0)
4605 break; /* normal loop exit */
4606 offset += (off_t)extent;
4607 value += nput;
4608
4609 }
4610 #ifdef ERANGE_FILL
4611 free(fillp);
4612 #endif
4613
4614 return status;
4615 }
4616
4617 static int
putNCvx_ushort_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)4618 putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
4619 const size_t *start, size_t nelems, const uint *value)
4620 {
4621 off_t offset = NC_varoffset(ncp, varp, start);
4622 size_t remaining = varp->xsz * nelems;
4623 int status = NC_NOERR;
4624 void *xp;
4625 void *fillp=NULL;
4626
4627 if(nelems == 0)
4628 return NC_NOERR;
4629
4630 assert(value != NULL);
4631
4632 #ifdef ERANGE_FILL
4633 fillp = malloc(varp->xsz);
4634 status = NC3_inq_var_fill(varp, fillp);
4635 #endif
4636
4637 for(;;)
4638 {
4639 size_t extent = MIN(remaining, ncp->chunk);
4640 size_t nput = ncx_howmany(varp->type, extent);
4641
4642 int lstatus = ncio_get(ncp->nciop, offset, extent,
4643 RGN_WRITE, &xp);
4644 if(lstatus != NC_NOERR)
4645 return lstatus;
4646
4647 lstatus = ncx_putn_ushort_uint(&xp, nput, value ,fillp);
4648 if(lstatus != NC_NOERR && status == NC_NOERR)
4649 {
4650 /* not fatal to the loop */
4651 status = lstatus;
4652 }
4653
4654 (void) ncio_rel(ncp->nciop, offset,
4655 RGN_MODIFIED);
4656
4657 remaining -= extent;
4658 if(remaining == 0)
4659 break; /* normal loop exit */
4660 offset += (off_t)extent;
4661 value += nput;
4662
4663 }
4664 #ifdef ERANGE_FILL
4665 free(fillp);
4666 #endif
4667
4668 return status;
4669 }
4670
4671 static int
putNCvx_ushort_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)4672 putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
4673 const size_t *start, size_t nelems, const ulonglong *value)
4674 {
4675 off_t offset = NC_varoffset(ncp, varp, start);
4676 size_t remaining = varp->xsz * nelems;
4677 int status = NC_NOERR;
4678 void *xp;
4679 void *fillp=NULL;
4680
4681 if(nelems == 0)
4682 return NC_NOERR;
4683
4684 assert(value != NULL);
4685
4686 #ifdef ERANGE_FILL
4687 fillp = malloc(varp->xsz);
4688 status = NC3_inq_var_fill(varp, fillp);
4689 #endif
4690
4691 for(;;)
4692 {
4693 size_t extent = MIN(remaining, ncp->chunk);
4694 size_t nput = ncx_howmany(varp->type, extent);
4695
4696 int lstatus = ncio_get(ncp->nciop, offset, extent,
4697 RGN_WRITE, &xp);
4698 if(lstatus != NC_NOERR)
4699 return lstatus;
4700
4701 lstatus = ncx_putn_ushort_ulonglong(&xp, nput, value ,fillp);
4702 if(lstatus != NC_NOERR && status == NC_NOERR)
4703 {
4704 /* not fatal to the loop */
4705 status = lstatus;
4706 }
4707
4708 (void) ncio_rel(ncp->nciop, offset,
4709 RGN_MODIFIED);
4710
4711 remaining -= extent;
4712 if(remaining == 0)
4713 break; /* normal loop exit */
4714 offset += (off_t)extent;
4715 value += nput;
4716
4717 }
4718 #ifdef ERANGE_FILL
4719 free(fillp);
4720 #endif
4721
4722 return status;
4723 }
4724
4725
4726 static int
putNCvx_uint_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)4727 putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
4728 const size_t *start, size_t nelems, const schar *value)
4729 {
4730 off_t offset = NC_varoffset(ncp, varp, start);
4731 size_t remaining = varp->xsz * nelems;
4732 int status = NC_NOERR;
4733 void *xp;
4734 void *fillp=NULL;
4735
4736 if(nelems == 0)
4737 return NC_NOERR;
4738
4739 assert(value != NULL);
4740
4741 #ifdef ERANGE_FILL
4742 fillp = malloc(varp->xsz);
4743 status = NC3_inq_var_fill(varp, fillp);
4744 #endif
4745
4746 for(;;)
4747 {
4748 size_t extent = MIN(remaining, ncp->chunk);
4749 size_t nput = ncx_howmany(varp->type, extent);
4750
4751 int lstatus = ncio_get(ncp->nciop, offset, extent,
4752 RGN_WRITE, &xp);
4753 if(lstatus != NC_NOERR)
4754 return lstatus;
4755
4756 lstatus = ncx_putn_uint_schar(&xp, nput, value ,fillp);
4757 if(lstatus != NC_NOERR && status == NC_NOERR)
4758 {
4759 /* not fatal to the loop */
4760 status = lstatus;
4761 }
4762
4763 (void) ncio_rel(ncp->nciop, offset,
4764 RGN_MODIFIED);
4765
4766 remaining -= extent;
4767 if(remaining == 0)
4768 break; /* normal loop exit */
4769 offset += (off_t)extent;
4770 value += nput;
4771
4772 }
4773 #ifdef ERANGE_FILL
4774 free(fillp);
4775 #endif
4776
4777 return status;
4778 }
4779
4780 static int
putNCvx_uint_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)4781 putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
4782 const size_t *start, size_t nelems, const uchar *value)
4783 {
4784 off_t offset = NC_varoffset(ncp, varp, start);
4785 size_t remaining = varp->xsz * nelems;
4786 int status = NC_NOERR;
4787 void *xp;
4788 void *fillp=NULL;
4789
4790 if(nelems == 0)
4791 return NC_NOERR;
4792
4793 assert(value != NULL);
4794
4795 #ifdef ERANGE_FILL
4796 fillp = malloc(varp->xsz);
4797 status = NC3_inq_var_fill(varp, fillp);
4798 #endif
4799
4800 for(;;)
4801 {
4802 size_t extent = MIN(remaining, ncp->chunk);
4803 size_t nput = ncx_howmany(varp->type, extent);
4804
4805 int lstatus = ncio_get(ncp->nciop, offset, extent,
4806 RGN_WRITE, &xp);
4807 if(lstatus != NC_NOERR)
4808 return lstatus;
4809
4810 lstatus = ncx_putn_uint_uchar(&xp, nput, value ,fillp);
4811 if(lstatus != NC_NOERR && status == NC_NOERR)
4812 {
4813 /* not fatal to the loop */
4814 status = lstatus;
4815 }
4816
4817 (void) ncio_rel(ncp->nciop, offset,
4818 RGN_MODIFIED);
4819
4820 remaining -= extent;
4821 if(remaining == 0)
4822 break; /* normal loop exit */
4823 offset += (off_t)extent;
4824 value += nput;
4825
4826 }
4827 #ifdef ERANGE_FILL
4828 free(fillp);
4829 #endif
4830
4831 return status;
4832 }
4833
4834 static int
putNCvx_uint_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)4835 putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
4836 const size_t *start, size_t nelems, const short *value)
4837 {
4838 off_t offset = NC_varoffset(ncp, varp, start);
4839 size_t remaining = varp->xsz * nelems;
4840 int status = NC_NOERR;
4841 void *xp;
4842 void *fillp=NULL;
4843
4844 if(nelems == 0)
4845 return NC_NOERR;
4846
4847 assert(value != NULL);
4848
4849 #ifdef ERANGE_FILL
4850 fillp = malloc(varp->xsz);
4851 status = NC3_inq_var_fill(varp, fillp);
4852 #endif
4853
4854 for(;;)
4855 {
4856 size_t extent = MIN(remaining, ncp->chunk);
4857 size_t nput = ncx_howmany(varp->type, extent);
4858
4859 int lstatus = ncio_get(ncp->nciop, offset, extent,
4860 RGN_WRITE, &xp);
4861 if(lstatus != NC_NOERR)
4862 return lstatus;
4863
4864 lstatus = ncx_putn_uint_short(&xp, nput, value ,fillp);
4865 if(lstatus != NC_NOERR && status == NC_NOERR)
4866 {
4867 /* not fatal to the loop */
4868 status = lstatus;
4869 }
4870
4871 (void) ncio_rel(ncp->nciop, offset,
4872 RGN_MODIFIED);
4873
4874 remaining -= extent;
4875 if(remaining == 0)
4876 break; /* normal loop exit */
4877 offset += (off_t)extent;
4878 value += nput;
4879
4880 }
4881 #ifdef ERANGE_FILL
4882 free(fillp);
4883 #endif
4884
4885 return status;
4886 }
4887
4888 static int
putNCvx_uint_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)4889 putNCvx_uint_int(NC3_INFO* ncp, const NC_var *varp,
4890 const size_t *start, size_t nelems, const int *value)
4891 {
4892 off_t offset = NC_varoffset(ncp, varp, start);
4893 size_t remaining = varp->xsz * nelems;
4894 int status = NC_NOERR;
4895 void *xp;
4896 void *fillp=NULL;
4897
4898 if(nelems == 0)
4899 return NC_NOERR;
4900
4901 assert(value != NULL);
4902
4903 #ifdef ERANGE_FILL
4904 fillp = malloc(varp->xsz);
4905 status = NC3_inq_var_fill(varp, fillp);
4906 #endif
4907
4908 for(;;)
4909 {
4910 size_t extent = MIN(remaining, ncp->chunk);
4911 size_t nput = ncx_howmany(varp->type, extent);
4912
4913 int lstatus = ncio_get(ncp->nciop, offset, extent,
4914 RGN_WRITE, &xp);
4915 if(lstatus != NC_NOERR)
4916 return lstatus;
4917
4918 lstatus = ncx_putn_uint_int(&xp, nput, value ,fillp);
4919 if(lstatus != NC_NOERR && status == NC_NOERR)
4920 {
4921 /* not fatal to the loop */
4922 status = lstatus;
4923 }
4924
4925 (void) ncio_rel(ncp->nciop, offset,
4926 RGN_MODIFIED);
4927
4928 remaining -= extent;
4929 if(remaining == 0)
4930 break; /* normal loop exit */
4931 offset += (off_t)extent;
4932 value += nput;
4933
4934 }
4935 #ifdef ERANGE_FILL
4936 free(fillp);
4937 #endif
4938
4939 return status;
4940 }
4941
4942 static int
putNCvx_uint_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)4943 putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
4944 const size_t *start, size_t nelems, const float *value)
4945 {
4946 off_t offset = NC_varoffset(ncp, varp, start);
4947 size_t remaining = varp->xsz * nelems;
4948 int status = NC_NOERR;
4949 void *xp;
4950 void *fillp=NULL;
4951
4952 if(nelems == 0)
4953 return NC_NOERR;
4954
4955 assert(value != NULL);
4956
4957 #ifdef ERANGE_FILL
4958 fillp = malloc(varp->xsz);
4959 status = NC3_inq_var_fill(varp, fillp);
4960 #endif
4961
4962 for(;;)
4963 {
4964 size_t extent = MIN(remaining, ncp->chunk);
4965 size_t nput = ncx_howmany(varp->type, extent);
4966
4967 int lstatus = ncio_get(ncp->nciop, offset, extent,
4968 RGN_WRITE, &xp);
4969 if(lstatus != NC_NOERR)
4970 return lstatus;
4971
4972 lstatus = ncx_putn_uint_float(&xp, nput, value ,fillp);
4973 if(lstatus != NC_NOERR && status == NC_NOERR)
4974 {
4975 /* not fatal to the loop */
4976 status = lstatus;
4977 }
4978
4979 (void) ncio_rel(ncp->nciop, offset,
4980 RGN_MODIFIED);
4981
4982 remaining -= extent;
4983 if(remaining == 0)
4984 break; /* normal loop exit */
4985 offset += (off_t)extent;
4986 value += nput;
4987
4988 }
4989 #ifdef ERANGE_FILL
4990 free(fillp);
4991 #endif
4992
4993 return status;
4994 }
4995
4996 static int
putNCvx_uint_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)4997 putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
4998 const size_t *start, size_t nelems, const double *value)
4999 {
5000 off_t offset = NC_varoffset(ncp, varp, start);
5001 size_t remaining = varp->xsz * nelems;
5002 int status = NC_NOERR;
5003 void *xp;
5004 void *fillp=NULL;
5005
5006 if(nelems == 0)
5007 return NC_NOERR;
5008
5009 assert(value != NULL);
5010
5011 #ifdef ERANGE_FILL
5012 fillp = malloc(varp->xsz);
5013 status = NC3_inq_var_fill(varp, fillp);
5014 #endif
5015
5016 for(;;)
5017 {
5018 size_t extent = MIN(remaining, ncp->chunk);
5019 size_t nput = ncx_howmany(varp->type, extent);
5020
5021 int lstatus = ncio_get(ncp->nciop, offset, extent,
5022 RGN_WRITE, &xp);
5023 if(lstatus != NC_NOERR)
5024 return lstatus;
5025
5026 lstatus = ncx_putn_uint_double(&xp, nput, value ,fillp);
5027 if(lstatus != NC_NOERR && status == NC_NOERR)
5028 {
5029 /* not fatal to the loop */
5030 status = lstatus;
5031 }
5032
5033 (void) ncio_rel(ncp->nciop, offset,
5034 RGN_MODIFIED);
5035
5036 remaining -= extent;
5037 if(remaining == 0)
5038 break; /* normal loop exit */
5039 offset += (off_t)extent;
5040 value += nput;
5041
5042 }
5043 #ifdef ERANGE_FILL
5044 free(fillp);
5045 #endif
5046
5047 return status;
5048 }
5049
5050 static int
putNCvx_uint_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)5051 putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
5052 const size_t *start, size_t nelems, const longlong *value)
5053 {
5054 off_t offset = NC_varoffset(ncp, varp, start);
5055 size_t remaining = varp->xsz * nelems;
5056 int status = NC_NOERR;
5057 void *xp;
5058 void *fillp=NULL;
5059
5060 if(nelems == 0)
5061 return NC_NOERR;
5062
5063 assert(value != NULL);
5064
5065 #ifdef ERANGE_FILL
5066 fillp = malloc(varp->xsz);
5067 status = NC3_inq_var_fill(varp, fillp);
5068 #endif
5069
5070 for(;;)
5071 {
5072 size_t extent = MIN(remaining, ncp->chunk);
5073 size_t nput = ncx_howmany(varp->type, extent);
5074
5075 int lstatus = ncio_get(ncp->nciop, offset, extent,
5076 RGN_WRITE, &xp);
5077 if(lstatus != NC_NOERR)
5078 return lstatus;
5079
5080 lstatus = ncx_putn_uint_longlong(&xp, nput, value ,fillp);
5081 if(lstatus != NC_NOERR && status == NC_NOERR)
5082 {
5083 /* not fatal to the loop */
5084 status = lstatus;
5085 }
5086
5087 (void) ncio_rel(ncp->nciop, offset,
5088 RGN_MODIFIED);
5089
5090 remaining -= extent;
5091 if(remaining == 0)
5092 break; /* normal loop exit */
5093 offset += (off_t)extent;
5094 value += nput;
5095
5096 }
5097 #ifdef ERANGE_FILL
5098 free(fillp);
5099 #endif
5100
5101 return status;
5102 }
5103
5104 static int
putNCvx_uint_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)5105 putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
5106 const size_t *start, size_t nelems, const ushort *value)
5107 {
5108 off_t offset = NC_varoffset(ncp, varp, start);
5109 size_t remaining = varp->xsz * nelems;
5110 int status = NC_NOERR;
5111 void *xp;
5112 void *fillp=NULL;
5113
5114 if(nelems == 0)
5115 return NC_NOERR;
5116
5117 assert(value != NULL);
5118
5119 #ifdef ERANGE_FILL
5120 fillp = malloc(varp->xsz);
5121 status = NC3_inq_var_fill(varp, fillp);
5122 #endif
5123
5124 for(;;)
5125 {
5126 size_t extent = MIN(remaining, ncp->chunk);
5127 size_t nput = ncx_howmany(varp->type, extent);
5128
5129 int lstatus = ncio_get(ncp->nciop, offset, extent,
5130 RGN_WRITE, &xp);
5131 if(lstatus != NC_NOERR)
5132 return lstatus;
5133
5134 lstatus = ncx_putn_uint_ushort(&xp, nput, value ,fillp);
5135 if(lstatus != NC_NOERR && status == NC_NOERR)
5136 {
5137 /* not fatal to the loop */
5138 status = lstatus;
5139 }
5140
5141 (void) ncio_rel(ncp->nciop, offset,
5142 RGN_MODIFIED);
5143
5144 remaining -= extent;
5145 if(remaining == 0)
5146 break; /* normal loop exit */
5147 offset += (off_t)extent;
5148 value += nput;
5149
5150 }
5151 #ifdef ERANGE_FILL
5152 free(fillp);
5153 #endif
5154
5155 return status;
5156 }
5157
5158 static int
putNCvx_uint_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)5159 putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
5160 const size_t *start, size_t nelems, const uint *value)
5161 {
5162 off_t offset = NC_varoffset(ncp, varp, start);
5163 size_t remaining = varp->xsz * nelems;
5164 int status = NC_NOERR;
5165 void *xp;
5166 void *fillp=NULL;
5167
5168 if(nelems == 0)
5169 return NC_NOERR;
5170
5171 assert(value != NULL);
5172
5173 #ifdef ERANGE_FILL
5174 fillp = malloc(varp->xsz);
5175 status = NC3_inq_var_fill(varp, fillp);
5176 #endif
5177
5178 for(;;)
5179 {
5180 size_t extent = MIN(remaining, ncp->chunk);
5181 size_t nput = ncx_howmany(varp->type, extent);
5182
5183 int lstatus = ncio_get(ncp->nciop, offset, extent,
5184 RGN_WRITE, &xp);
5185 if(lstatus != NC_NOERR)
5186 return lstatus;
5187
5188 lstatus = ncx_putn_uint_uint(&xp, nput, value ,fillp);
5189 if(lstatus != NC_NOERR && status == NC_NOERR)
5190 {
5191 /* not fatal to the loop */
5192 status = lstatus;
5193 }
5194
5195 (void) ncio_rel(ncp->nciop, offset,
5196 RGN_MODIFIED);
5197
5198 remaining -= extent;
5199 if(remaining == 0)
5200 break; /* normal loop exit */
5201 offset += (off_t)extent;
5202 value += nput;
5203
5204 }
5205 #ifdef ERANGE_FILL
5206 free(fillp);
5207 #endif
5208
5209 return status;
5210 }
5211
5212 static int
putNCvx_uint_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)5213 putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
5214 const size_t *start, size_t nelems, const ulonglong *value)
5215 {
5216 off_t offset = NC_varoffset(ncp, varp, start);
5217 size_t remaining = varp->xsz * nelems;
5218 int status = NC_NOERR;
5219 void *xp;
5220 void *fillp=NULL;
5221
5222 if(nelems == 0)
5223 return NC_NOERR;
5224
5225 assert(value != NULL);
5226
5227 #ifdef ERANGE_FILL
5228 fillp = malloc(varp->xsz);
5229 status = NC3_inq_var_fill(varp, fillp);
5230 #endif
5231
5232 for(;;)
5233 {
5234 size_t extent = MIN(remaining, ncp->chunk);
5235 size_t nput = ncx_howmany(varp->type, extent);
5236
5237 int lstatus = ncio_get(ncp->nciop, offset, extent,
5238 RGN_WRITE, &xp);
5239 if(lstatus != NC_NOERR)
5240 return lstatus;
5241
5242 lstatus = ncx_putn_uint_ulonglong(&xp, nput, value ,fillp);
5243 if(lstatus != NC_NOERR && status == NC_NOERR)
5244 {
5245 /* not fatal to the loop */
5246 status = lstatus;
5247 }
5248
5249 (void) ncio_rel(ncp->nciop, offset,
5250 RGN_MODIFIED);
5251
5252 remaining -= extent;
5253 if(remaining == 0)
5254 break; /* normal loop exit */
5255 offset += (off_t)extent;
5256 value += nput;
5257
5258 }
5259 #ifdef ERANGE_FILL
5260 free(fillp);
5261 #endif
5262
5263 return status;
5264 }
5265
5266
5267 static int
putNCvx_longlong_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)5268 putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
5269 const size_t *start, size_t nelems, const schar *value)
5270 {
5271 off_t offset = NC_varoffset(ncp, varp, start);
5272 size_t remaining = varp->xsz * nelems;
5273 int status = NC_NOERR;
5274 void *xp;
5275 void *fillp=NULL;
5276
5277 if(nelems == 0)
5278 return NC_NOERR;
5279
5280 assert(value != NULL);
5281
5282 #ifdef ERANGE_FILL
5283 fillp = malloc(varp->xsz);
5284 status = NC3_inq_var_fill(varp, fillp);
5285 #endif
5286
5287 for(;;)
5288 {
5289 size_t extent = MIN(remaining, ncp->chunk);
5290 size_t nput = ncx_howmany(varp->type, extent);
5291
5292 int lstatus = ncio_get(ncp->nciop, offset, extent,
5293 RGN_WRITE, &xp);
5294 if(lstatus != NC_NOERR)
5295 return lstatus;
5296
5297 lstatus = ncx_putn_longlong_schar(&xp, nput, value ,fillp);
5298 if(lstatus != NC_NOERR && status == NC_NOERR)
5299 {
5300 /* not fatal to the loop */
5301 status = lstatus;
5302 }
5303
5304 (void) ncio_rel(ncp->nciop, offset,
5305 RGN_MODIFIED);
5306
5307 remaining -= extent;
5308 if(remaining == 0)
5309 break; /* normal loop exit */
5310 offset += (off_t)extent;
5311 value += nput;
5312
5313 }
5314 #ifdef ERANGE_FILL
5315 free(fillp);
5316 #endif
5317
5318 return status;
5319 }
5320
5321 static int
putNCvx_longlong_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)5322 putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
5323 const size_t *start, size_t nelems, const uchar *value)
5324 {
5325 off_t offset = NC_varoffset(ncp, varp, start);
5326 size_t remaining = varp->xsz * nelems;
5327 int status = NC_NOERR;
5328 void *xp;
5329 void *fillp=NULL;
5330
5331 if(nelems == 0)
5332 return NC_NOERR;
5333
5334 assert(value != NULL);
5335
5336 #ifdef ERANGE_FILL
5337 fillp = malloc(varp->xsz);
5338 status = NC3_inq_var_fill(varp, fillp);
5339 #endif
5340
5341 for(;;)
5342 {
5343 size_t extent = MIN(remaining, ncp->chunk);
5344 size_t nput = ncx_howmany(varp->type, extent);
5345
5346 int lstatus = ncio_get(ncp->nciop, offset, extent,
5347 RGN_WRITE, &xp);
5348 if(lstatus != NC_NOERR)
5349 return lstatus;
5350
5351 lstatus = ncx_putn_longlong_uchar(&xp, nput, value ,fillp);
5352 if(lstatus != NC_NOERR && status == NC_NOERR)
5353 {
5354 /* not fatal to the loop */
5355 status = lstatus;
5356 }
5357
5358 (void) ncio_rel(ncp->nciop, offset,
5359 RGN_MODIFIED);
5360
5361 remaining -= extent;
5362 if(remaining == 0)
5363 break; /* normal loop exit */
5364 offset += (off_t)extent;
5365 value += nput;
5366
5367 }
5368 #ifdef ERANGE_FILL
5369 free(fillp);
5370 #endif
5371
5372 return status;
5373 }
5374
5375 static int
putNCvx_longlong_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)5376 putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
5377 const size_t *start, size_t nelems, const short *value)
5378 {
5379 off_t offset = NC_varoffset(ncp, varp, start);
5380 size_t remaining = varp->xsz * nelems;
5381 int status = NC_NOERR;
5382 void *xp;
5383 void *fillp=NULL;
5384
5385 if(nelems == 0)
5386 return NC_NOERR;
5387
5388 assert(value != NULL);
5389
5390 #ifdef ERANGE_FILL
5391 fillp = malloc(varp->xsz);
5392 status = NC3_inq_var_fill(varp, fillp);
5393 #endif
5394
5395 for(;;)
5396 {
5397 size_t extent = MIN(remaining, ncp->chunk);
5398 size_t nput = ncx_howmany(varp->type, extent);
5399
5400 int lstatus = ncio_get(ncp->nciop, offset, extent,
5401 RGN_WRITE, &xp);
5402 if(lstatus != NC_NOERR)
5403 return lstatus;
5404
5405 lstatus = ncx_putn_longlong_short(&xp, nput, value ,fillp);
5406 if(lstatus != NC_NOERR && status == NC_NOERR)
5407 {
5408 /* not fatal to the loop */
5409 status = lstatus;
5410 }
5411
5412 (void) ncio_rel(ncp->nciop, offset,
5413 RGN_MODIFIED);
5414
5415 remaining -= extent;
5416 if(remaining == 0)
5417 break; /* normal loop exit */
5418 offset += (off_t)extent;
5419 value += nput;
5420
5421 }
5422 #ifdef ERANGE_FILL
5423 free(fillp);
5424 #endif
5425
5426 return status;
5427 }
5428
5429 static int
putNCvx_longlong_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)5430 putNCvx_longlong_int(NC3_INFO* ncp, const NC_var *varp,
5431 const size_t *start, size_t nelems, const int *value)
5432 {
5433 off_t offset = NC_varoffset(ncp, varp, start);
5434 size_t remaining = varp->xsz * nelems;
5435 int status = NC_NOERR;
5436 void *xp;
5437 void *fillp=NULL;
5438
5439 if(nelems == 0)
5440 return NC_NOERR;
5441
5442 assert(value != NULL);
5443
5444 #ifdef ERANGE_FILL
5445 fillp = malloc(varp->xsz);
5446 status = NC3_inq_var_fill(varp, fillp);
5447 #endif
5448
5449 for(;;)
5450 {
5451 size_t extent = MIN(remaining, ncp->chunk);
5452 size_t nput = ncx_howmany(varp->type, extent);
5453
5454 int lstatus = ncio_get(ncp->nciop, offset, extent,
5455 RGN_WRITE, &xp);
5456 if(lstatus != NC_NOERR)
5457 return lstatus;
5458
5459 lstatus = ncx_putn_longlong_int(&xp, nput, value ,fillp);
5460 if(lstatus != NC_NOERR && status == NC_NOERR)
5461 {
5462 /* not fatal to the loop */
5463 status = lstatus;
5464 }
5465
5466 (void) ncio_rel(ncp->nciop, offset,
5467 RGN_MODIFIED);
5468
5469 remaining -= extent;
5470 if(remaining == 0)
5471 break; /* normal loop exit */
5472 offset += (off_t)extent;
5473 value += nput;
5474
5475 }
5476 #ifdef ERANGE_FILL
5477 free(fillp);
5478 #endif
5479
5480 return status;
5481 }
5482
5483 static int
putNCvx_longlong_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)5484 putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
5485 const size_t *start, size_t nelems, const float *value)
5486 {
5487 off_t offset = NC_varoffset(ncp, varp, start);
5488 size_t remaining = varp->xsz * nelems;
5489 int status = NC_NOERR;
5490 void *xp;
5491 void *fillp=NULL;
5492
5493 if(nelems == 0)
5494 return NC_NOERR;
5495
5496 assert(value != NULL);
5497
5498 #ifdef ERANGE_FILL
5499 fillp = malloc(varp->xsz);
5500 status = NC3_inq_var_fill(varp, fillp);
5501 #endif
5502
5503 for(;;)
5504 {
5505 size_t extent = MIN(remaining, ncp->chunk);
5506 size_t nput = ncx_howmany(varp->type, extent);
5507
5508 int lstatus = ncio_get(ncp->nciop, offset, extent,
5509 RGN_WRITE, &xp);
5510 if(lstatus != NC_NOERR)
5511 return lstatus;
5512
5513 lstatus = ncx_putn_longlong_float(&xp, nput, value ,fillp);
5514 if(lstatus != NC_NOERR && status == NC_NOERR)
5515 {
5516 /* not fatal to the loop */
5517 status = lstatus;
5518 }
5519
5520 (void) ncio_rel(ncp->nciop, offset,
5521 RGN_MODIFIED);
5522
5523 remaining -= extent;
5524 if(remaining == 0)
5525 break; /* normal loop exit */
5526 offset += (off_t)extent;
5527 value += nput;
5528
5529 }
5530 #ifdef ERANGE_FILL
5531 free(fillp);
5532 #endif
5533
5534 return status;
5535 }
5536
5537 static int
putNCvx_longlong_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)5538 putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
5539 const size_t *start, size_t nelems, const double *value)
5540 {
5541 off_t offset = NC_varoffset(ncp, varp, start);
5542 size_t remaining = varp->xsz * nelems;
5543 int status = NC_NOERR;
5544 void *xp;
5545 void *fillp=NULL;
5546
5547 if(nelems == 0)
5548 return NC_NOERR;
5549
5550 assert(value != NULL);
5551
5552 #ifdef ERANGE_FILL
5553 fillp = malloc(varp->xsz);
5554 status = NC3_inq_var_fill(varp, fillp);
5555 #endif
5556
5557 for(;;)
5558 {
5559 size_t extent = MIN(remaining, ncp->chunk);
5560 size_t nput = ncx_howmany(varp->type, extent);
5561
5562 int lstatus = ncio_get(ncp->nciop, offset, extent,
5563 RGN_WRITE, &xp);
5564 if(lstatus != NC_NOERR)
5565 return lstatus;
5566
5567 lstatus = ncx_putn_longlong_double(&xp, nput, value ,fillp);
5568 if(lstatus != NC_NOERR && status == NC_NOERR)
5569 {
5570 /* not fatal to the loop */
5571 status = lstatus;
5572 }
5573
5574 (void) ncio_rel(ncp->nciop, offset,
5575 RGN_MODIFIED);
5576
5577 remaining -= extent;
5578 if(remaining == 0)
5579 break; /* normal loop exit */
5580 offset += (off_t)extent;
5581 value += nput;
5582
5583 }
5584 #ifdef ERANGE_FILL
5585 free(fillp);
5586 #endif
5587
5588 return status;
5589 }
5590
5591 static int
putNCvx_longlong_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)5592 putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
5593 const size_t *start, size_t nelems, const longlong *value)
5594 {
5595 off_t offset = NC_varoffset(ncp, varp, start);
5596 size_t remaining = varp->xsz * nelems;
5597 int status = NC_NOERR;
5598 void *xp;
5599 void *fillp=NULL;
5600
5601 if(nelems == 0)
5602 return NC_NOERR;
5603
5604 assert(value != NULL);
5605
5606 #ifdef ERANGE_FILL
5607 fillp = malloc(varp->xsz);
5608 status = NC3_inq_var_fill(varp, fillp);
5609 #endif
5610
5611 for(;;)
5612 {
5613 size_t extent = MIN(remaining, ncp->chunk);
5614 size_t nput = ncx_howmany(varp->type, extent);
5615
5616 int lstatus = ncio_get(ncp->nciop, offset, extent,
5617 RGN_WRITE, &xp);
5618 if(lstatus != NC_NOERR)
5619 return lstatus;
5620
5621 lstatus = ncx_putn_longlong_longlong(&xp, nput, value ,fillp);
5622 if(lstatus != NC_NOERR && status == NC_NOERR)
5623 {
5624 /* not fatal to the loop */
5625 status = lstatus;
5626 }
5627
5628 (void) ncio_rel(ncp->nciop, offset,
5629 RGN_MODIFIED);
5630
5631 remaining -= extent;
5632 if(remaining == 0)
5633 break; /* normal loop exit */
5634 offset += (off_t)extent;
5635 value += nput;
5636
5637 }
5638 #ifdef ERANGE_FILL
5639 free(fillp);
5640 #endif
5641
5642 return status;
5643 }
5644
5645 static int
putNCvx_longlong_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)5646 putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
5647 const size_t *start, size_t nelems, const ushort *value)
5648 {
5649 off_t offset = NC_varoffset(ncp, varp, start);
5650 size_t remaining = varp->xsz * nelems;
5651 int status = NC_NOERR;
5652 void *xp;
5653 void *fillp=NULL;
5654
5655 if(nelems == 0)
5656 return NC_NOERR;
5657
5658 assert(value != NULL);
5659
5660 #ifdef ERANGE_FILL
5661 fillp = malloc(varp->xsz);
5662 status = NC3_inq_var_fill(varp, fillp);
5663 #endif
5664
5665 for(;;)
5666 {
5667 size_t extent = MIN(remaining, ncp->chunk);
5668 size_t nput = ncx_howmany(varp->type, extent);
5669
5670 int lstatus = ncio_get(ncp->nciop, offset, extent,
5671 RGN_WRITE, &xp);
5672 if(lstatus != NC_NOERR)
5673 return lstatus;
5674
5675 lstatus = ncx_putn_longlong_ushort(&xp, nput, value ,fillp);
5676 if(lstatus != NC_NOERR && status == NC_NOERR)
5677 {
5678 /* not fatal to the loop */
5679 status = lstatus;
5680 }
5681
5682 (void) ncio_rel(ncp->nciop, offset,
5683 RGN_MODIFIED);
5684
5685 remaining -= extent;
5686 if(remaining == 0)
5687 break; /* normal loop exit */
5688 offset += (off_t)extent;
5689 value += nput;
5690
5691 }
5692 #ifdef ERANGE_FILL
5693 free(fillp);
5694 #endif
5695
5696 return status;
5697 }
5698
5699 static int
putNCvx_longlong_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)5700 putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
5701 const size_t *start, size_t nelems, const uint *value)
5702 {
5703 off_t offset = NC_varoffset(ncp, varp, start);
5704 size_t remaining = varp->xsz * nelems;
5705 int status = NC_NOERR;
5706 void *xp;
5707 void *fillp=NULL;
5708
5709 if(nelems == 0)
5710 return NC_NOERR;
5711
5712 assert(value != NULL);
5713
5714 #ifdef ERANGE_FILL
5715 fillp = malloc(varp->xsz);
5716 status = NC3_inq_var_fill(varp, fillp);
5717 #endif
5718
5719 for(;;)
5720 {
5721 size_t extent = MIN(remaining, ncp->chunk);
5722 size_t nput = ncx_howmany(varp->type, extent);
5723
5724 int lstatus = ncio_get(ncp->nciop, offset, extent,
5725 RGN_WRITE, &xp);
5726 if(lstatus != NC_NOERR)
5727 return lstatus;
5728
5729 lstatus = ncx_putn_longlong_uint(&xp, nput, value ,fillp);
5730 if(lstatus != NC_NOERR && status == NC_NOERR)
5731 {
5732 /* not fatal to the loop */
5733 status = lstatus;
5734 }
5735
5736 (void) ncio_rel(ncp->nciop, offset,
5737 RGN_MODIFIED);
5738
5739 remaining -= extent;
5740 if(remaining == 0)
5741 break; /* normal loop exit */
5742 offset += (off_t)extent;
5743 value += nput;
5744
5745 }
5746 #ifdef ERANGE_FILL
5747 free(fillp);
5748 #endif
5749
5750 return status;
5751 }
5752
5753 static int
putNCvx_longlong_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)5754 putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
5755 const size_t *start, size_t nelems, const ulonglong *value)
5756 {
5757 off_t offset = NC_varoffset(ncp, varp, start);
5758 size_t remaining = varp->xsz * nelems;
5759 int status = NC_NOERR;
5760 void *xp;
5761 void *fillp=NULL;
5762
5763 if(nelems == 0)
5764 return NC_NOERR;
5765
5766 assert(value != NULL);
5767
5768 #ifdef ERANGE_FILL
5769 fillp = malloc(varp->xsz);
5770 status = NC3_inq_var_fill(varp, fillp);
5771 #endif
5772
5773 for(;;)
5774 {
5775 size_t extent = MIN(remaining, ncp->chunk);
5776 size_t nput = ncx_howmany(varp->type, extent);
5777
5778 int lstatus = ncio_get(ncp->nciop, offset, extent,
5779 RGN_WRITE, &xp);
5780 if(lstatus != NC_NOERR)
5781 return lstatus;
5782
5783 lstatus = ncx_putn_longlong_ulonglong(&xp, nput, value ,fillp);
5784 if(lstatus != NC_NOERR && status == NC_NOERR)
5785 {
5786 /* not fatal to the loop */
5787 status = lstatus;
5788 }
5789
5790 (void) ncio_rel(ncp->nciop, offset,
5791 RGN_MODIFIED);
5792
5793 remaining -= extent;
5794 if(remaining == 0)
5795 break; /* normal loop exit */
5796 offset += (off_t)extent;
5797 value += nput;
5798
5799 }
5800 #ifdef ERANGE_FILL
5801 free(fillp);
5802 #endif
5803
5804 return status;
5805 }
5806
5807
5808 static int
putNCvx_ulonglong_schar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const schar * value)5809 putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
5810 const size_t *start, size_t nelems, const schar *value)
5811 {
5812 off_t offset = NC_varoffset(ncp, varp, start);
5813 size_t remaining = varp->xsz * nelems;
5814 int status = NC_NOERR;
5815 void *xp;
5816 void *fillp=NULL;
5817
5818 if(nelems == 0)
5819 return NC_NOERR;
5820
5821 assert(value != NULL);
5822
5823 #ifdef ERANGE_FILL
5824 fillp = malloc(varp->xsz);
5825 status = NC3_inq_var_fill(varp, fillp);
5826 #endif
5827
5828 for(;;)
5829 {
5830 size_t extent = MIN(remaining, ncp->chunk);
5831 size_t nput = ncx_howmany(varp->type, extent);
5832
5833 int lstatus = ncio_get(ncp->nciop, offset, extent,
5834 RGN_WRITE, &xp);
5835 if(lstatus != NC_NOERR)
5836 return lstatus;
5837
5838 lstatus = ncx_putn_ulonglong_schar(&xp, nput, value ,fillp);
5839 if(lstatus != NC_NOERR && status == NC_NOERR)
5840 {
5841 /* not fatal to the loop */
5842 status = lstatus;
5843 }
5844
5845 (void) ncio_rel(ncp->nciop, offset,
5846 RGN_MODIFIED);
5847
5848 remaining -= extent;
5849 if(remaining == 0)
5850 break; /* normal loop exit */
5851 offset += (off_t)extent;
5852 value += nput;
5853
5854 }
5855 #ifdef ERANGE_FILL
5856 free(fillp);
5857 #endif
5858
5859 return status;
5860 }
5861
5862 static int
putNCvx_ulonglong_uchar(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uchar * value)5863 putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
5864 const size_t *start, size_t nelems, const uchar *value)
5865 {
5866 off_t offset = NC_varoffset(ncp, varp, start);
5867 size_t remaining = varp->xsz * nelems;
5868 int status = NC_NOERR;
5869 void *xp;
5870 void *fillp=NULL;
5871
5872 if(nelems == 0)
5873 return NC_NOERR;
5874
5875 assert(value != NULL);
5876
5877 #ifdef ERANGE_FILL
5878 fillp = malloc(varp->xsz);
5879 status = NC3_inq_var_fill(varp, fillp);
5880 #endif
5881
5882 for(;;)
5883 {
5884 size_t extent = MIN(remaining, ncp->chunk);
5885 size_t nput = ncx_howmany(varp->type, extent);
5886
5887 int lstatus = ncio_get(ncp->nciop, offset, extent,
5888 RGN_WRITE, &xp);
5889 if(lstatus != NC_NOERR)
5890 return lstatus;
5891
5892 lstatus = ncx_putn_ulonglong_uchar(&xp, nput, value ,fillp);
5893 if(lstatus != NC_NOERR && status == NC_NOERR)
5894 {
5895 /* not fatal to the loop */
5896 status = lstatus;
5897 }
5898
5899 (void) ncio_rel(ncp->nciop, offset,
5900 RGN_MODIFIED);
5901
5902 remaining -= extent;
5903 if(remaining == 0)
5904 break; /* normal loop exit */
5905 offset += (off_t)extent;
5906 value += nput;
5907
5908 }
5909 #ifdef ERANGE_FILL
5910 free(fillp);
5911 #endif
5912
5913 return status;
5914 }
5915
5916 static int
putNCvx_ulonglong_short(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const short * value)5917 putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
5918 const size_t *start, size_t nelems, const short *value)
5919 {
5920 off_t offset = NC_varoffset(ncp, varp, start);
5921 size_t remaining = varp->xsz * nelems;
5922 int status = NC_NOERR;
5923 void *xp;
5924 void *fillp=NULL;
5925
5926 if(nelems == 0)
5927 return NC_NOERR;
5928
5929 assert(value != NULL);
5930
5931 #ifdef ERANGE_FILL
5932 fillp = malloc(varp->xsz);
5933 status = NC3_inq_var_fill(varp, fillp);
5934 #endif
5935
5936 for(;;)
5937 {
5938 size_t extent = MIN(remaining, ncp->chunk);
5939 size_t nput = ncx_howmany(varp->type, extent);
5940
5941 int lstatus = ncio_get(ncp->nciop, offset, extent,
5942 RGN_WRITE, &xp);
5943 if(lstatus != NC_NOERR)
5944 return lstatus;
5945
5946 lstatus = ncx_putn_ulonglong_short(&xp, nput, value ,fillp);
5947 if(lstatus != NC_NOERR && status == NC_NOERR)
5948 {
5949 /* not fatal to the loop */
5950 status = lstatus;
5951 }
5952
5953 (void) ncio_rel(ncp->nciop, offset,
5954 RGN_MODIFIED);
5955
5956 remaining -= extent;
5957 if(remaining == 0)
5958 break; /* normal loop exit */
5959 offset += (off_t)extent;
5960 value += nput;
5961
5962 }
5963 #ifdef ERANGE_FILL
5964 free(fillp);
5965 #endif
5966
5967 return status;
5968 }
5969
5970 static int
putNCvx_ulonglong_int(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const int * value)5971 putNCvx_ulonglong_int(NC3_INFO* ncp, const NC_var *varp,
5972 const size_t *start, size_t nelems, const int *value)
5973 {
5974 off_t offset = NC_varoffset(ncp, varp, start);
5975 size_t remaining = varp->xsz * nelems;
5976 int status = NC_NOERR;
5977 void *xp;
5978 void *fillp=NULL;
5979
5980 if(nelems == 0)
5981 return NC_NOERR;
5982
5983 assert(value != NULL);
5984
5985 #ifdef ERANGE_FILL
5986 fillp = malloc(varp->xsz);
5987 status = NC3_inq_var_fill(varp, fillp);
5988 #endif
5989
5990 for(;;)
5991 {
5992 size_t extent = MIN(remaining, ncp->chunk);
5993 size_t nput = ncx_howmany(varp->type, extent);
5994
5995 int lstatus = ncio_get(ncp->nciop, offset, extent,
5996 RGN_WRITE, &xp);
5997 if(lstatus != NC_NOERR)
5998 return lstatus;
5999
6000 lstatus = ncx_putn_ulonglong_int(&xp, nput, value ,fillp);
6001 if(lstatus != NC_NOERR && status == NC_NOERR)
6002 {
6003 /* not fatal to the loop */
6004 status = lstatus;
6005 }
6006
6007 (void) ncio_rel(ncp->nciop, offset,
6008 RGN_MODIFIED);
6009
6010 remaining -= extent;
6011 if(remaining == 0)
6012 break; /* normal loop exit */
6013 offset += (off_t)extent;
6014 value += nput;
6015
6016 }
6017 #ifdef ERANGE_FILL
6018 free(fillp);
6019 #endif
6020
6021 return status;
6022 }
6023
6024 static int
putNCvx_ulonglong_float(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const float * value)6025 putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
6026 const size_t *start, size_t nelems, const float *value)
6027 {
6028 off_t offset = NC_varoffset(ncp, varp, start);
6029 size_t remaining = varp->xsz * nelems;
6030 int status = NC_NOERR;
6031 void *xp;
6032 void *fillp=NULL;
6033
6034 if(nelems == 0)
6035 return NC_NOERR;
6036
6037 assert(value != NULL);
6038
6039 #ifdef ERANGE_FILL
6040 fillp = malloc(varp->xsz);
6041 status = NC3_inq_var_fill(varp, fillp);
6042 #endif
6043
6044 for(;;)
6045 {
6046 size_t extent = MIN(remaining, ncp->chunk);
6047 size_t nput = ncx_howmany(varp->type, extent);
6048
6049 int lstatus = ncio_get(ncp->nciop, offset, extent,
6050 RGN_WRITE, &xp);
6051 if(lstatus != NC_NOERR)
6052 return lstatus;
6053
6054 lstatus = ncx_putn_ulonglong_float(&xp, nput, value ,fillp);
6055 if(lstatus != NC_NOERR && status == NC_NOERR)
6056 {
6057 /* not fatal to the loop */
6058 status = lstatus;
6059 }
6060
6061 (void) ncio_rel(ncp->nciop, offset,
6062 RGN_MODIFIED);
6063
6064 remaining -= extent;
6065 if(remaining == 0)
6066 break; /* normal loop exit */
6067 offset += (off_t)extent;
6068 value += nput;
6069
6070 }
6071 #ifdef ERANGE_FILL
6072 free(fillp);
6073 #endif
6074
6075 return status;
6076 }
6077
6078 static int
putNCvx_ulonglong_double(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const double * value)6079 putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
6080 const size_t *start, size_t nelems, const double *value)
6081 {
6082 off_t offset = NC_varoffset(ncp, varp, start);
6083 size_t remaining = varp->xsz * nelems;
6084 int status = NC_NOERR;
6085 void *xp;
6086 void *fillp=NULL;
6087
6088 if(nelems == 0)
6089 return NC_NOERR;
6090
6091 assert(value != NULL);
6092
6093 #ifdef ERANGE_FILL
6094 fillp = malloc(varp->xsz);
6095 status = NC3_inq_var_fill(varp, fillp);
6096 #endif
6097
6098 for(;;)
6099 {
6100 size_t extent = MIN(remaining, ncp->chunk);
6101 size_t nput = ncx_howmany(varp->type, extent);
6102
6103 int lstatus = ncio_get(ncp->nciop, offset, extent,
6104 RGN_WRITE, &xp);
6105 if(lstatus != NC_NOERR)
6106 return lstatus;
6107
6108 lstatus = ncx_putn_ulonglong_double(&xp, nput, value ,fillp);
6109 if(lstatus != NC_NOERR && status == NC_NOERR)
6110 {
6111 /* not fatal to the loop */
6112 status = lstatus;
6113 }
6114
6115 (void) ncio_rel(ncp->nciop, offset,
6116 RGN_MODIFIED);
6117
6118 remaining -= extent;
6119 if(remaining == 0)
6120 break; /* normal loop exit */
6121 offset += (off_t)extent;
6122 value += nput;
6123
6124 }
6125 #ifdef ERANGE_FILL
6126 free(fillp);
6127 #endif
6128
6129 return status;
6130 }
6131
6132 static int
putNCvx_ulonglong_longlong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const longlong * value)6133 putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
6134 const size_t *start, size_t nelems, const longlong *value)
6135 {
6136 off_t offset = NC_varoffset(ncp, varp, start);
6137 size_t remaining = varp->xsz * nelems;
6138 int status = NC_NOERR;
6139 void *xp;
6140 void *fillp=NULL;
6141
6142 if(nelems == 0)
6143 return NC_NOERR;
6144
6145 assert(value != NULL);
6146
6147 #ifdef ERANGE_FILL
6148 fillp = malloc(varp->xsz);
6149 status = NC3_inq_var_fill(varp, fillp);
6150 #endif
6151
6152 for(;;)
6153 {
6154 size_t extent = MIN(remaining, ncp->chunk);
6155 size_t nput = ncx_howmany(varp->type, extent);
6156
6157 int lstatus = ncio_get(ncp->nciop, offset, extent,
6158 RGN_WRITE, &xp);
6159 if(lstatus != NC_NOERR)
6160 return lstatus;
6161
6162 lstatus = ncx_putn_ulonglong_longlong(&xp, nput, value ,fillp);
6163 if(lstatus != NC_NOERR && status == NC_NOERR)
6164 {
6165 /* not fatal to the loop */
6166 status = lstatus;
6167 }
6168
6169 (void) ncio_rel(ncp->nciop, offset,
6170 RGN_MODIFIED);
6171
6172 remaining -= extent;
6173 if(remaining == 0)
6174 break; /* normal loop exit */
6175 offset += (off_t)extent;
6176 value += nput;
6177
6178 }
6179 #ifdef ERANGE_FILL
6180 free(fillp);
6181 #endif
6182
6183 return status;
6184 }
6185
6186 static int
putNCvx_ulonglong_ushort(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ushort * value)6187 putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
6188 const size_t *start, size_t nelems, const ushort *value)
6189 {
6190 off_t offset = NC_varoffset(ncp, varp, start);
6191 size_t remaining = varp->xsz * nelems;
6192 int status = NC_NOERR;
6193 void *xp;
6194 void *fillp=NULL;
6195
6196 if(nelems == 0)
6197 return NC_NOERR;
6198
6199 assert(value != NULL);
6200
6201 #ifdef ERANGE_FILL
6202 fillp = malloc(varp->xsz);
6203 status = NC3_inq_var_fill(varp, fillp);
6204 #endif
6205
6206 for(;;)
6207 {
6208 size_t extent = MIN(remaining, ncp->chunk);
6209 size_t nput = ncx_howmany(varp->type, extent);
6210
6211 int lstatus = ncio_get(ncp->nciop, offset, extent,
6212 RGN_WRITE, &xp);
6213 if(lstatus != NC_NOERR)
6214 return lstatus;
6215
6216 lstatus = ncx_putn_ulonglong_ushort(&xp, nput, value ,fillp);
6217 if(lstatus != NC_NOERR && status == NC_NOERR)
6218 {
6219 /* not fatal to the loop */
6220 status = lstatus;
6221 }
6222
6223 (void) ncio_rel(ncp->nciop, offset,
6224 RGN_MODIFIED);
6225
6226 remaining -= extent;
6227 if(remaining == 0)
6228 break; /* normal loop exit */
6229 offset += (off_t)extent;
6230 value += nput;
6231
6232 }
6233 #ifdef ERANGE_FILL
6234 free(fillp);
6235 #endif
6236
6237 return status;
6238 }
6239
6240 static int
putNCvx_ulonglong_uint(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const uint * value)6241 putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
6242 const size_t *start, size_t nelems, const uint *value)
6243 {
6244 off_t offset = NC_varoffset(ncp, varp, start);
6245 size_t remaining = varp->xsz * nelems;
6246 int status = NC_NOERR;
6247 void *xp;
6248 void *fillp=NULL;
6249
6250 if(nelems == 0)
6251 return NC_NOERR;
6252
6253 assert(value != NULL);
6254
6255 #ifdef ERANGE_FILL
6256 fillp = malloc(varp->xsz);
6257 status = NC3_inq_var_fill(varp, fillp);
6258 #endif
6259
6260 for(;;)
6261 {
6262 size_t extent = MIN(remaining, ncp->chunk);
6263 size_t nput = ncx_howmany(varp->type, extent);
6264
6265 int lstatus = ncio_get(ncp->nciop, offset, extent,
6266 RGN_WRITE, &xp);
6267 if(lstatus != NC_NOERR)
6268 return lstatus;
6269
6270 lstatus = ncx_putn_ulonglong_uint(&xp, nput, value ,fillp);
6271 if(lstatus != NC_NOERR && status == NC_NOERR)
6272 {
6273 /* not fatal to the loop */
6274 status = lstatus;
6275 }
6276
6277 (void) ncio_rel(ncp->nciop, offset,
6278 RGN_MODIFIED);
6279
6280 remaining -= extent;
6281 if(remaining == 0)
6282 break; /* normal loop exit */
6283 offset += (off_t)extent;
6284 value += nput;
6285
6286 }
6287 #ifdef ERANGE_FILL
6288 free(fillp);
6289 #endif
6290
6291 return status;
6292 }
6293
6294 static int
putNCvx_ulonglong_ulonglong(NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,const ulonglong * value)6295 putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
6296 const size_t *start, size_t nelems, const ulonglong *value)
6297 {
6298 off_t offset = NC_varoffset(ncp, varp, start);
6299 size_t remaining = varp->xsz * nelems;
6300 int status = NC_NOERR;
6301 void *xp;
6302 void *fillp=NULL;
6303
6304 if(nelems == 0)
6305 return NC_NOERR;
6306
6307 assert(value != NULL);
6308
6309 #ifdef ERANGE_FILL
6310 fillp = malloc(varp->xsz);
6311 status = NC3_inq_var_fill(varp, fillp);
6312 #endif
6313
6314 for(;;)
6315 {
6316 size_t extent = MIN(remaining, ncp->chunk);
6317 size_t nput = ncx_howmany(varp->type, extent);
6318
6319 int lstatus = ncio_get(ncp->nciop, offset, extent,
6320 RGN_WRITE, &xp);
6321 if(lstatus != NC_NOERR)
6322 return lstatus;
6323
6324 lstatus = ncx_putn_ulonglong_ulonglong(&xp, nput, value ,fillp);
6325 if(lstatus != NC_NOERR && status == NC_NOERR)
6326 {
6327 /* not fatal to the loop */
6328 status = lstatus;
6329 }
6330
6331 (void) ncio_rel(ncp->nciop, offset,
6332 RGN_MODIFIED);
6333
6334 remaining -= extent;
6335 if(remaining == 0)
6336 break; /* normal loop exit */
6337 offset += (off_t)extent;
6338 value += nput;
6339
6340 }
6341 #ifdef ERANGE_FILL
6342 free(fillp);
6343 #endif
6344
6345 return status;
6346 }
6347
6348
6349
6350 static int
getNCvx_char_char(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,char * value)6351 getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
6352 const size_t *start, size_t nelems, char *value)
6353 {
6354 off_t offset = NC_varoffset(ncp, varp, start);
6355 size_t remaining = varp->xsz * nelems;
6356 int status = NC_NOERR;
6357 const void *xp;
6358
6359 if(nelems == 0)
6360 return NC_NOERR;
6361
6362 assert(value != NULL);
6363
6364 for(;;)
6365 {
6366 size_t extent = MIN(remaining, ncp->chunk);
6367 size_t nget = ncx_howmany(varp->type, extent);
6368
6369 int lstatus = ncio_get(ncp->nciop, offset, extent,
6370 0, (void **)&xp); /* cast away const */
6371 if(lstatus != NC_NOERR)
6372 return lstatus;
6373
6374 lstatus = ncx_getn_char_char(&xp, nget, value);
6375 if(lstatus != NC_NOERR && status == NC_NOERR)
6376 status = lstatus;
6377
6378 (void) ncio_rel(ncp->nciop, offset, 0);
6379
6380 remaining -= extent;
6381 if(remaining == 0)
6382 break; /* normal loop exit */
6383 offset += (off_t)extent;
6384 value += nget;
6385 }
6386
6387 return status;
6388 }
6389
6390
6391 static int
getNCvx_schar_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)6392 getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
6393 const size_t *start, size_t nelems, schar *value)
6394 {
6395 off_t offset = NC_varoffset(ncp, varp, start);
6396 size_t remaining = varp->xsz * nelems;
6397 int status = NC_NOERR;
6398 const void *xp;
6399
6400 if(nelems == 0)
6401 return NC_NOERR;
6402
6403 assert(value != NULL);
6404
6405 for(;;)
6406 {
6407 size_t extent = MIN(remaining, ncp->chunk);
6408 size_t nget = ncx_howmany(varp->type, extent);
6409
6410 int lstatus = ncio_get(ncp->nciop, offset, extent,
6411 0, (void **)&xp); /* cast away const */
6412 if(lstatus != NC_NOERR)
6413 return lstatus;
6414
6415 lstatus = ncx_getn_schar_schar(&xp, nget, value);
6416 if(lstatus != NC_NOERR && status == NC_NOERR)
6417 status = lstatus;
6418
6419 (void) ncio_rel(ncp->nciop, offset, 0);
6420
6421 remaining -= extent;
6422 if(remaining == 0)
6423 break; /* normal loop exit */
6424 offset += (off_t)extent;
6425 value += nget;
6426 }
6427
6428 return status;
6429 }
6430
6431 static int
getNCvx_schar_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)6432 getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
6433 const size_t *start, size_t nelems, short *value)
6434 {
6435 off_t offset = NC_varoffset(ncp, varp, start);
6436 size_t remaining = varp->xsz * nelems;
6437 int status = NC_NOERR;
6438 const void *xp;
6439
6440 if(nelems == 0)
6441 return NC_NOERR;
6442
6443 assert(value != NULL);
6444
6445 for(;;)
6446 {
6447 size_t extent = MIN(remaining, ncp->chunk);
6448 size_t nget = ncx_howmany(varp->type, extent);
6449
6450 int lstatus = ncio_get(ncp->nciop, offset, extent,
6451 0, (void **)&xp); /* cast away const */
6452 if(lstatus != NC_NOERR)
6453 return lstatus;
6454
6455 lstatus = ncx_getn_schar_short(&xp, nget, value);
6456 if(lstatus != NC_NOERR && status == NC_NOERR)
6457 status = lstatus;
6458
6459 (void) ncio_rel(ncp->nciop, offset, 0);
6460
6461 remaining -= extent;
6462 if(remaining == 0)
6463 break; /* normal loop exit */
6464 offset += (off_t)extent;
6465 value += nget;
6466 }
6467
6468 return status;
6469 }
6470
6471 static int
getNCvx_schar_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)6472 getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
6473 const size_t *start, size_t nelems, int *value)
6474 {
6475 off_t offset = NC_varoffset(ncp, varp, start);
6476 size_t remaining = varp->xsz * nelems;
6477 int status = NC_NOERR;
6478 const void *xp;
6479
6480 if(nelems == 0)
6481 return NC_NOERR;
6482
6483 assert(value != NULL);
6484
6485 for(;;)
6486 {
6487 size_t extent = MIN(remaining, ncp->chunk);
6488 size_t nget = ncx_howmany(varp->type, extent);
6489
6490 int lstatus = ncio_get(ncp->nciop, offset, extent,
6491 0, (void **)&xp); /* cast away const */
6492 if(lstatus != NC_NOERR)
6493 return lstatus;
6494
6495 lstatus = ncx_getn_schar_int(&xp, nget, value);
6496 if(lstatus != NC_NOERR && status == NC_NOERR)
6497 status = lstatus;
6498
6499 (void) ncio_rel(ncp->nciop, offset, 0);
6500
6501 remaining -= extent;
6502 if(remaining == 0)
6503 break; /* normal loop exit */
6504 offset += (off_t)extent;
6505 value += nget;
6506 }
6507
6508 return status;
6509 }
6510
6511 static int
getNCvx_schar_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)6512 getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
6513 const size_t *start, size_t nelems, float *value)
6514 {
6515 off_t offset = NC_varoffset(ncp, varp, start);
6516 size_t remaining = varp->xsz * nelems;
6517 int status = NC_NOERR;
6518 const void *xp;
6519
6520 if(nelems == 0)
6521 return NC_NOERR;
6522
6523 assert(value != NULL);
6524
6525 for(;;)
6526 {
6527 size_t extent = MIN(remaining, ncp->chunk);
6528 size_t nget = ncx_howmany(varp->type, extent);
6529
6530 int lstatus = ncio_get(ncp->nciop, offset, extent,
6531 0, (void **)&xp); /* cast away const */
6532 if(lstatus != NC_NOERR)
6533 return lstatus;
6534
6535 lstatus = ncx_getn_schar_float(&xp, nget, value);
6536 if(lstatus != NC_NOERR && status == NC_NOERR)
6537 status = lstatus;
6538
6539 (void) ncio_rel(ncp->nciop, offset, 0);
6540
6541 remaining -= extent;
6542 if(remaining == 0)
6543 break; /* normal loop exit */
6544 offset += (off_t)extent;
6545 value += nget;
6546 }
6547
6548 return status;
6549 }
6550
6551 static int
getNCvx_schar_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)6552 getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
6553 const size_t *start, size_t nelems, double *value)
6554 {
6555 off_t offset = NC_varoffset(ncp, varp, start);
6556 size_t remaining = varp->xsz * nelems;
6557 int status = NC_NOERR;
6558 const void *xp;
6559
6560 if(nelems == 0)
6561 return NC_NOERR;
6562
6563 assert(value != NULL);
6564
6565 for(;;)
6566 {
6567 size_t extent = MIN(remaining, ncp->chunk);
6568 size_t nget = ncx_howmany(varp->type, extent);
6569
6570 int lstatus = ncio_get(ncp->nciop, offset, extent,
6571 0, (void **)&xp); /* cast away const */
6572 if(lstatus != NC_NOERR)
6573 return lstatus;
6574
6575 lstatus = ncx_getn_schar_double(&xp, nget, value);
6576 if(lstatus != NC_NOERR && status == NC_NOERR)
6577 status = lstatus;
6578
6579 (void) ncio_rel(ncp->nciop, offset, 0);
6580
6581 remaining -= extent;
6582 if(remaining == 0)
6583 break; /* normal loop exit */
6584 offset += (off_t)extent;
6585 value += nget;
6586 }
6587
6588 return status;
6589 }
6590
6591 static int
getNCvx_schar_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)6592 getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
6593 const size_t *start, size_t nelems, longlong *value)
6594 {
6595 off_t offset = NC_varoffset(ncp, varp, start);
6596 size_t remaining = varp->xsz * nelems;
6597 int status = NC_NOERR;
6598 const void *xp;
6599
6600 if(nelems == 0)
6601 return NC_NOERR;
6602
6603 assert(value != NULL);
6604
6605 for(;;)
6606 {
6607 size_t extent = MIN(remaining, ncp->chunk);
6608 size_t nget = ncx_howmany(varp->type, extent);
6609
6610 int lstatus = ncio_get(ncp->nciop, offset, extent,
6611 0, (void **)&xp); /* cast away const */
6612 if(lstatus != NC_NOERR)
6613 return lstatus;
6614
6615 lstatus = ncx_getn_schar_longlong(&xp, nget, value);
6616 if(lstatus != NC_NOERR && status == NC_NOERR)
6617 status = lstatus;
6618
6619 (void) ncio_rel(ncp->nciop, offset, 0);
6620
6621 remaining -= extent;
6622 if(remaining == 0)
6623 break; /* normal loop exit */
6624 offset += (off_t)extent;
6625 value += nget;
6626 }
6627
6628 return status;
6629 }
6630
6631 static int
getNCvx_schar_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)6632 getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
6633 const size_t *start, size_t nelems, uint *value)
6634 {
6635 off_t offset = NC_varoffset(ncp, varp, start);
6636 size_t remaining = varp->xsz * nelems;
6637 int status = NC_NOERR;
6638 const void *xp;
6639
6640 if(nelems == 0)
6641 return NC_NOERR;
6642
6643 assert(value != NULL);
6644
6645 for(;;)
6646 {
6647 size_t extent = MIN(remaining, ncp->chunk);
6648 size_t nget = ncx_howmany(varp->type, extent);
6649
6650 int lstatus = ncio_get(ncp->nciop, offset, extent,
6651 0, (void **)&xp); /* cast away const */
6652 if(lstatus != NC_NOERR)
6653 return lstatus;
6654
6655 lstatus = ncx_getn_schar_uint(&xp, nget, value);
6656 if(lstatus != NC_NOERR && status == NC_NOERR)
6657 status = lstatus;
6658
6659 (void) ncio_rel(ncp->nciop, offset, 0);
6660
6661 remaining -= extent;
6662 if(remaining == 0)
6663 break; /* normal loop exit */
6664 offset += (off_t)extent;
6665 value += nget;
6666 }
6667
6668 return status;
6669 }
6670
6671 static int
getNCvx_schar_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)6672 getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
6673 const size_t *start, size_t nelems, ulonglong *value)
6674 {
6675 off_t offset = NC_varoffset(ncp, varp, start);
6676 size_t remaining = varp->xsz * nelems;
6677 int status = NC_NOERR;
6678 const void *xp;
6679
6680 if(nelems == 0)
6681 return NC_NOERR;
6682
6683 assert(value != NULL);
6684
6685 for(;;)
6686 {
6687 size_t extent = MIN(remaining, ncp->chunk);
6688 size_t nget = ncx_howmany(varp->type, extent);
6689
6690 int lstatus = ncio_get(ncp->nciop, offset, extent,
6691 0, (void **)&xp); /* cast away const */
6692 if(lstatus != NC_NOERR)
6693 return lstatus;
6694
6695 lstatus = ncx_getn_schar_ulonglong(&xp, nget, value);
6696 if(lstatus != NC_NOERR && status == NC_NOERR)
6697 status = lstatus;
6698
6699 (void) ncio_rel(ncp->nciop, offset, 0);
6700
6701 remaining -= extent;
6702 if(remaining == 0)
6703 break; /* normal loop exit */
6704 offset += (off_t)extent;
6705 value += nget;
6706 }
6707
6708 return status;
6709 }
6710
6711 static int
getNCvx_schar_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)6712 getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
6713 const size_t *start, size_t nelems, uchar *value)
6714 {
6715 off_t offset = NC_varoffset(ncp, varp, start);
6716 size_t remaining = varp->xsz * nelems;
6717 int status = NC_NOERR;
6718 const void *xp;
6719
6720 if(nelems == 0)
6721 return NC_NOERR;
6722
6723 assert(value != NULL);
6724
6725 for(;;)
6726 {
6727 size_t extent = MIN(remaining, ncp->chunk);
6728 size_t nget = ncx_howmany(varp->type, extent);
6729
6730 int lstatus = ncio_get(ncp->nciop, offset, extent,
6731 0, (void **)&xp); /* cast away const */
6732 if(lstatus != NC_NOERR)
6733 return lstatus;
6734
6735 lstatus = ncx_getn_schar_uchar(&xp, nget, value);
6736 if(lstatus != NC_NOERR && status == NC_NOERR)
6737 status = lstatus;
6738
6739 (void) ncio_rel(ncp->nciop, offset, 0);
6740
6741 remaining -= extent;
6742 if(remaining == 0)
6743 break; /* normal loop exit */
6744 offset += (off_t)extent;
6745 value += nget;
6746 }
6747
6748 return status;
6749 }
6750
6751 static int
getNCvx_schar_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)6752 getNCvx_schar_ushort(const NC3_INFO* ncp, const NC_var *varp,
6753 const size_t *start, size_t nelems, ushort *value)
6754 {
6755 off_t offset = NC_varoffset(ncp, varp, start);
6756 size_t remaining = varp->xsz * nelems;
6757 int status = NC_NOERR;
6758 const void *xp;
6759
6760 if(nelems == 0)
6761 return NC_NOERR;
6762
6763 assert(value != NULL);
6764
6765 for(;;)
6766 {
6767 size_t extent = MIN(remaining, ncp->chunk);
6768 size_t nget = ncx_howmany(varp->type, extent);
6769
6770 int lstatus = ncio_get(ncp->nciop, offset, extent,
6771 0, (void **)&xp); /* cast away const */
6772 if(lstatus != NC_NOERR)
6773 return lstatus;
6774
6775 lstatus = ncx_getn_schar_ushort(&xp, nget, value);
6776 if(lstatus != NC_NOERR && status == NC_NOERR)
6777 status = lstatus;
6778
6779 (void) ncio_rel(ncp->nciop, offset, 0);
6780
6781 remaining -= extent;
6782 if(remaining == 0)
6783 break; /* normal loop exit */
6784 offset += (off_t)extent;
6785 value += nget;
6786 }
6787
6788 return status;
6789 }
6790
6791
6792 static int
getNCvx_short_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)6793 getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
6794 const size_t *start, size_t nelems, schar *value)
6795 {
6796 off_t offset = NC_varoffset(ncp, varp, start);
6797 size_t remaining = varp->xsz * nelems;
6798 int status = NC_NOERR;
6799 const void *xp;
6800
6801 if(nelems == 0)
6802 return NC_NOERR;
6803
6804 assert(value != NULL);
6805
6806 for(;;)
6807 {
6808 size_t extent = MIN(remaining, ncp->chunk);
6809 size_t nget = ncx_howmany(varp->type, extent);
6810
6811 int lstatus = ncio_get(ncp->nciop, offset, extent,
6812 0, (void **)&xp); /* cast away const */
6813 if(lstatus != NC_NOERR)
6814 return lstatus;
6815
6816 lstatus = ncx_getn_short_schar(&xp, nget, value);
6817 if(lstatus != NC_NOERR && status == NC_NOERR)
6818 status = lstatus;
6819
6820 (void) ncio_rel(ncp->nciop, offset, 0);
6821
6822 remaining -= extent;
6823 if(remaining == 0)
6824 break; /* normal loop exit */
6825 offset += (off_t)extent;
6826 value += nget;
6827 }
6828
6829 return status;
6830 }
6831
6832 static int
getNCvx_short_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)6833 getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
6834 const size_t *start, size_t nelems, uchar *value)
6835 {
6836 off_t offset = NC_varoffset(ncp, varp, start);
6837 size_t remaining = varp->xsz * nelems;
6838 int status = NC_NOERR;
6839 const void *xp;
6840
6841 if(nelems == 0)
6842 return NC_NOERR;
6843
6844 assert(value != NULL);
6845
6846 for(;;)
6847 {
6848 size_t extent = MIN(remaining, ncp->chunk);
6849 size_t nget = ncx_howmany(varp->type, extent);
6850
6851 int lstatus = ncio_get(ncp->nciop, offset, extent,
6852 0, (void **)&xp); /* cast away const */
6853 if(lstatus != NC_NOERR)
6854 return lstatus;
6855
6856 lstatus = ncx_getn_short_uchar(&xp, nget, value);
6857 if(lstatus != NC_NOERR && status == NC_NOERR)
6858 status = lstatus;
6859
6860 (void) ncio_rel(ncp->nciop, offset, 0);
6861
6862 remaining -= extent;
6863 if(remaining == 0)
6864 break; /* normal loop exit */
6865 offset += (off_t)extent;
6866 value += nget;
6867 }
6868
6869 return status;
6870 }
6871
6872 static int
getNCvx_short_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)6873 getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
6874 const size_t *start, size_t nelems, short *value)
6875 {
6876 off_t offset = NC_varoffset(ncp, varp, start);
6877 size_t remaining = varp->xsz * nelems;
6878 int status = NC_NOERR;
6879 const void *xp;
6880
6881 if(nelems == 0)
6882 return NC_NOERR;
6883
6884 assert(value != NULL);
6885
6886 for(;;)
6887 {
6888 size_t extent = MIN(remaining, ncp->chunk);
6889 size_t nget = ncx_howmany(varp->type, extent);
6890
6891 int lstatus = ncio_get(ncp->nciop, offset, extent,
6892 0, (void **)&xp); /* cast away const */
6893 if(lstatus != NC_NOERR)
6894 return lstatus;
6895
6896 lstatus = ncx_getn_short_short(&xp, nget, value);
6897 if(lstatus != NC_NOERR && status == NC_NOERR)
6898 status = lstatus;
6899
6900 (void) ncio_rel(ncp->nciop, offset, 0);
6901
6902 remaining -= extent;
6903 if(remaining == 0)
6904 break; /* normal loop exit */
6905 offset += (off_t)extent;
6906 value += nget;
6907 }
6908
6909 return status;
6910 }
6911
6912 static int
getNCvx_short_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)6913 getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
6914 const size_t *start, size_t nelems, int *value)
6915 {
6916 off_t offset = NC_varoffset(ncp, varp, start);
6917 size_t remaining = varp->xsz * nelems;
6918 int status = NC_NOERR;
6919 const void *xp;
6920
6921 if(nelems == 0)
6922 return NC_NOERR;
6923
6924 assert(value != NULL);
6925
6926 for(;;)
6927 {
6928 size_t extent = MIN(remaining, ncp->chunk);
6929 size_t nget = ncx_howmany(varp->type, extent);
6930
6931 int lstatus = ncio_get(ncp->nciop, offset, extent,
6932 0, (void **)&xp); /* cast away const */
6933 if(lstatus != NC_NOERR)
6934 return lstatus;
6935
6936 lstatus = ncx_getn_short_int(&xp, nget, value);
6937 if(lstatus != NC_NOERR && status == NC_NOERR)
6938 status = lstatus;
6939
6940 (void) ncio_rel(ncp->nciop, offset, 0);
6941
6942 remaining -= extent;
6943 if(remaining == 0)
6944 break; /* normal loop exit */
6945 offset += (off_t)extent;
6946 value += nget;
6947 }
6948
6949 return status;
6950 }
6951
6952 static int
getNCvx_short_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)6953 getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
6954 const size_t *start, size_t nelems, float *value)
6955 {
6956 off_t offset = NC_varoffset(ncp, varp, start);
6957 size_t remaining = varp->xsz * nelems;
6958 int status = NC_NOERR;
6959 const void *xp;
6960
6961 if(nelems == 0)
6962 return NC_NOERR;
6963
6964 assert(value != NULL);
6965
6966 for(;;)
6967 {
6968 size_t extent = MIN(remaining, ncp->chunk);
6969 size_t nget = ncx_howmany(varp->type, extent);
6970
6971 int lstatus = ncio_get(ncp->nciop, offset, extent,
6972 0, (void **)&xp); /* cast away const */
6973 if(lstatus != NC_NOERR)
6974 return lstatus;
6975
6976 lstatus = ncx_getn_short_float(&xp, nget, value);
6977 if(lstatus != NC_NOERR && status == NC_NOERR)
6978 status = lstatus;
6979
6980 (void) ncio_rel(ncp->nciop, offset, 0);
6981
6982 remaining -= extent;
6983 if(remaining == 0)
6984 break; /* normal loop exit */
6985 offset += (off_t)extent;
6986 value += nget;
6987 }
6988
6989 return status;
6990 }
6991
6992 static int
getNCvx_short_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)6993 getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
6994 const size_t *start, size_t nelems, double *value)
6995 {
6996 off_t offset = NC_varoffset(ncp, varp, start);
6997 size_t remaining = varp->xsz * nelems;
6998 int status = NC_NOERR;
6999 const void *xp;
7000
7001 if(nelems == 0)
7002 return NC_NOERR;
7003
7004 assert(value != NULL);
7005
7006 for(;;)
7007 {
7008 size_t extent = MIN(remaining, ncp->chunk);
7009 size_t nget = ncx_howmany(varp->type, extent);
7010
7011 int lstatus = ncio_get(ncp->nciop, offset, extent,
7012 0, (void **)&xp); /* cast away const */
7013 if(lstatus != NC_NOERR)
7014 return lstatus;
7015
7016 lstatus = ncx_getn_short_double(&xp, nget, value);
7017 if(lstatus != NC_NOERR && status == NC_NOERR)
7018 status = lstatus;
7019
7020 (void) ncio_rel(ncp->nciop, offset, 0);
7021
7022 remaining -= extent;
7023 if(remaining == 0)
7024 break; /* normal loop exit */
7025 offset += (off_t)extent;
7026 value += nget;
7027 }
7028
7029 return status;
7030 }
7031
7032 static int
getNCvx_short_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)7033 getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
7034 const size_t *start, size_t nelems, longlong *value)
7035 {
7036 off_t offset = NC_varoffset(ncp, varp, start);
7037 size_t remaining = varp->xsz * nelems;
7038 int status = NC_NOERR;
7039 const void *xp;
7040
7041 if(nelems == 0)
7042 return NC_NOERR;
7043
7044 assert(value != NULL);
7045
7046 for(;;)
7047 {
7048 size_t extent = MIN(remaining, ncp->chunk);
7049 size_t nget = ncx_howmany(varp->type, extent);
7050
7051 int lstatus = ncio_get(ncp->nciop, offset, extent,
7052 0, (void **)&xp); /* cast away const */
7053 if(lstatus != NC_NOERR)
7054 return lstatus;
7055
7056 lstatus = ncx_getn_short_longlong(&xp, nget, value);
7057 if(lstatus != NC_NOERR && status == NC_NOERR)
7058 status = lstatus;
7059
7060 (void) ncio_rel(ncp->nciop, offset, 0);
7061
7062 remaining -= extent;
7063 if(remaining == 0)
7064 break; /* normal loop exit */
7065 offset += (off_t)extent;
7066 value += nget;
7067 }
7068
7069 return status;
7070 }
7071
7072 static int
getNCvx_short_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)7073 getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
7074 const size_t *start, size_t nelems, uint *value)
7075 {
7076 off_t offset = NC_varoffset(ncp, varp, start);
7077 size_t remaining = varp->xsz * nelems;
7078 int status = NC_NOERR;
7079 const void *xp;
7080
7081 if(nelems == 0)
7082 return NC_NOERR;
7083
7084 assert(value != NULL);
7085
7086 for(;;)
7087 {
7088 size_t extent = MIN(remaining, ncp->chunk);
7089 size_t nget = ncx_howmany(varp->type, extent);
7090
7091 int lstatus = ncio_get(ncp->nciop, offset, extent,
7092 0, (void **)&xp); /* cast away const */
7093 if(lstatus != NC_NOERR)
7094 return lstatus;
7095
7096 lstatus = ncx_getn_short_uint(&xp, nget, value);
7097 if(lstatus != NC_NOERR && status == NC_NOERR)
7098 status = lstatus;
7099
7100 (void) ncio_rel(ncp->nciop, offset, 0);
7101
7102 remaining -= extent;
7103 if(remaining == 0)
7104 break; /* normal loop exit */
7105 offset += (off_t)extent;
7106 value += nget;
7107 }
7108
7109 return status;
7110 }
7111
7112 static int
getNCvx_short_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)7113 getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
7114 const size_t *start, size_t nelems, ulonglong *value)
7115 {
7116 off_t offset = NC_varoffset(ncp, varp, start);
7117 size_t remaining = varp->xsz * nelems;
7118 int status = NC_NOERR;
7119 const void *xp;
7120
7121 if(nelems == 0)
7122 return NC_NOERR;
7123
7124 assert(value != NULL);
7125
7126 for(;;)
7127 {
7128 size_t extent = MIN(remaining, ncp->chunk);
7129 size_t nget = ncx_howmany(varp->type, extent);
7130
7131 int lstatus = ncio_get(ncp->nciop, offset, extent,
7132 0, (void **)&xp); /* cast away const */
7133 if(lstatus != NC_NOERR)
7134 return lstatus;
7135
7136 lstatus = ncx_getn_short_ulonglong(&xp, nget, value);
7137 if(lstatus != NC_NOERR && status == NC_NOERR)
7138 status = lstatus;
7139
7140 (void) ncio_rel(ncp->nciop, offset, 0);
7141
7142 remaining -= extent;
7143 if(remaining == 0)
7144 break; /* normal loop exit */
7145 offset += (off_t)extent;
7146 value += nget;
7147 }
7148
7149 return status;
7150 }
7151
7152 static int
getNCvx_short_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)7153 getNCvx_short_ushort(const NC3_INFO* ncp, const NC_var *varp,
7154 const size_t *start, size_t nelems, ushort *value)
7155 {
7156 off_t offset = NC_varoffset(ncp, varp, start);
7157 size_t remaining = varp->xsz * nelems;
7158 int status = NC_NOERR;
7159 const void *xp;
7160
7161 if(nelems == 0)
7162 return NC_NOERR;
7163
7164 assert(value != NULL);
7165
7166 for(;;)
7167 {
7168 size_t extent = MIN(remaining, ncp->chunk);
7169 size_t nget = ncx_howmany(varp->type, extent);
7170
7171 int lstatus = ncio_get(ncp->nciop, offset, extent,
7172 0, (void **)&xp); /* cast away const */
7173 if(lstatus != NC_NOERR)
7174 return lstatus;
7175
7176 lstatus = ncx_getn_short_ushort(&xp, nget, value);
7177 if(lstatus != NC_NOERR && status == NC_NOERR)
7178 status = lstatus;
7179
7180 (void) ncio_rel(ncp->nciop, offset, 0);
7181
7182 remaining -= extent;
7183 if(remaining == 0)
7184 break; /* normal loop exit */
7185 offset += (off_t)extent;
7186 value += nget;
7187 }
7188
7189 return status;
7190 }
7191
7192
7193 static int
getNCvx_int_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)7194 getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
7195 const size_t *start, size_t nelems, schar *value)
7196 {
7197 off_t offset = NC_varoffset(ncp, varp, start);
7198 size_t remaining = varp->xsz * nelems;
7199 int status = NC_NOERR;
7200 const void *xp;
7201
7202 if(nelems == 0)
7203 return NC_NOERR;
7204
7205 assert(value != NULL);
7206
7207 for(;;)
7208 {
7209 size_t extent = MIN(remaining, ncp->chunk);
7210 size_t nget = ncx_howmany(varp->type, extent);
7211
7212 int lstatus = ncio_get(ncp->nciop, offset, extent,
7213 0, (void **)&xp); /* cast away const */
7214 if(lstatus != NC_NOERR)
7215 return lstatus;
7216
7217 lstatus = ncx_getn_int_schar(&xp, nget, value);
7218 if(lstatus != NC_NOERR && status == NC_NOERR)
7219 status = lstatus;
7220
7221 (void) ncio_rel(ncp->nciop, offset, 0);
7222
7223 remaining -= extent;
7224 if(remaining == 0)
7225 break; /* normal loop exit */
7226 offset += (off_t)extent;
7227 value += nget;
7228 }
7229
7230 return status;
7231 }
7232
7233 static int
getNCvx_int_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)7234 getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
7235 const size_t *start, size_t nelems, uchar *value)
7236 {
7237 off_t offset = NC_varoffset(ncp, varp, start);
7238 size_t remaining = varp->xsz * nelems;
7239 int status = NC_NOERR;
7240 const void *xp;
7241
7242 if(nelems == 0)
7243 return NC_NOERR;
7244
7245 assert(value != NULL);
7246
7247 for(;;)
7248 {
7249 size_t extent = MIN(remaining, ncp->chunk);
7250 size_t nget = ncx_howmany(varp->type, extent);
7251
7252 int lstatus = ncio_get(ncp->nciop, offset, extent,
7253 0, (void **)&xp); /* cast away const */
7254 if(lstatus != NC_NOERR)
7255 return lstatus;
7256
7257 lstatus = ncx_getn_int_uchar(&xp, nget, value);
7258 if(lstatus != NC_NOERR && status == NC_NOERR)
7259 status = lstatus;
7260
7261 (void) ncio_rel(ncp->nciop, offset, 0);
7262
7263 remaining -= extent;
7264 if(remaining == 0)
7265 break; /* normal loop exit */
7266 offset += (off_t)extent;
7267 value += nget;
7268 }
7269
7270 return status;
7271 }
7272
7273 static int
getNCvx_int_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)7274 getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
7275 const size_t *start, size_t nelems, short *value)
7276 {
7277 off_t offset = NC_varoffset(ncp, varp, start);
7278 size_t remaining = varp->xsz * nelems;
7279 int status = NC_NOERR;
7280 const void *xp;
7281
7282 if(nelems == 0)
7283 return NC_NOERR;
7284
7285 assert(value != NULL);
7286
7287 for(;;)
7288 {
7289 size_t extent = MIN(remaining, ncp->chunk);
7290 size_t nget = ncx_howmany(varp->type, extent);
7291
7292 int lstatus = ncio_get(ncp->nciop, offset, extent,
7293 0, (void **)&xp); /* cast away const */
7294 if(lstatus != NC_NOERR)
7295 return lstatus;
7296
7297 lstatus = ncx_getn_int_short(&xp, nget, value);
7298 if(lstatus != NC_NOERR && status == NC_NOERR)
7299 status = lstatus;
7300
7301 (void) ncio_rel(ncp->nciop, offset, 0);
7302
7303 remaining -= extent;
7304 if(remaining == 0)
7305 break; /* normal loop exit */
7306 offset += (off_t)extent;
7307 value += nget;
7308 }
7309
7310 return status;
7311 }
7312
7313 static int
getNCvx_int_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)7314 getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
7315 const size_t *start, size_t nelems, int *value)
7316 {
7317 off_t offset = NC_varoffset(ncp, varp, start);
7318 size_t remaining = varp->xsz * nelems;
7319 int status = NC_NOERR;
7320 const void *xp;
7321
7322 if(nelems == 0)
7323 return NC_NOERR;
7324
7325 assert(value != NULL);
7326
7327 for(;;)
7328 {
7329 size_t extent = MIN(remaining, ncp->chunk);
7330 size_t nget = ncx_howmany(varp->type, extent);
7331
7332 int lstatus = ncio_get(ncp->nciop, offset, extent,
7333 0, (void **)&xp); /* cast away const */
7334 if(lstatus != NC_NOERR)
7335 return lstatus;
7336
7337 lstatus = ncx_getn_int_int(&xp, nget, value);
7338 if(lstatus != NC_NOERR && status == NC_NOERR)
7339 status = lstatus;
7340
7341 (void) ncio_rel(ncp->nciop, offset, 0);
7342
7343 remaining -= extent;
7344 if(remaining == 0)
7345 break; /* normal loop exit */
7346 offset += (off_t)extent;
7347 value += nget;
7348 }
7349
7350 return status;
7351 }
7352
7353 static int
getNCvx_int_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)7354 getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
7355 const size_t *start, size_t nelems, float *value)
7356 {
7357 off_t offset = NC_varoffset(ncp, varp, start);
7358 size_t remaining = varp->xsz * nelems;
7359 int status = NC_NOERR;
7360 const void *xp;
7361
7362 if(nelems == 0)
7363 return NC_NOERR;
7364
7365 assert(value != NULL);
7366
7367 for(;;)
7368 {
7369 size_t extent = MIN(remaining, ncp->chunk);
7370 size_t nget = ncx_howmany(varp->type, extent);
7371
7372 int lstatus = ncio_get(ncp->nciop, offset, extent,
7373 0, (void **)&xp); /* cast away const */
7374 if(lstatus != NC_NOERR)
7375 return lstatus;
7376
7377 lstatus = ncx_getn_int_float(&xp, nget, value);
7378 if(lstatus != NC_NOERR && status == NC_NOERR)
7379 status = lstatus;
7380
7381 (void) ncio_rel(ncp->nciop, offset, 0);
7382
7383 remaining -= extent;
7384 if(remaining == 0)
7385 break; /* normal loop exit */
7386 offset += (off_t)extent;
7387 value += nget;
7388 }
7389
7390 return status;
7391 }
7392
7393 static int
getNCvx_int_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)7394 getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
7395 const size_t *start, size_t nelems, double *value)
7396 {
7397 off_t offset = NC_varoffset(ncp, varp, start);
7398 size_t remaining = varp->xsz * nelems;
7399 int status = NC_NOERR;
7400 const void *xp;
7401
7402 if(nelems == 0)
7403 return NC_NOERR;
7404
7405 assert(value != NULL);
7406
7407 for(;;)
7408 {
7409 size_t extent = MIN(remaining, ncp->chunk);
7410 size_t nget = ncx_howmany(varp->type, extent);
7411
7412 int lstatus = ncio_get(ncp->nciop, offset, extent,
7413 0, (void **)&xp); /* cast away const */
7414 if(lstatus != NC_NOERR)
7415 return lstatus;
7416
7417 lstatus = ncx_getn_int_double(&xp, nget, value);
7418 if(lstatus != NC_NOERR && status == NC_NOERR)
7419 status = lstatus;
7420
7421 (void) ncio_rel(ncp->nciop, offset, 0);
7422
7423 remaining -= extent;
7424 if(remaining == 0)
7425 break; /* normal loop exit */
7426 offset += (off_t)extent;
7427 value += nget;
7428 }
7429
7430 return status;
7431 }
7432
7433 static int
getNCvx_int_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)7434 getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
7435 const size_t *start, size_t nelems, longlong *value)
7436 {
7437 off_t offset = NC_varoffset(ncp, varp, start);
7438 size_t remaining = varp->xsz * nelems;
7439 int status = NC_NOERR;
7440 const void *xp;
7441
7442 if(nelems == 0)
7443 return NC_NOERR;
7444
7445 assert(value != NULL);
7446
7447 for(;;)
7448 {
7449 size_t extent = MIN(remaining, ncp->chunk);
7450 size_t nget = ncx_howmany(varp->type, extent);
7451
7452 int lstatus = ncio_get(ncp->nciop, offset, extent,
7453 0, (void **)&xp); /* cast away const */
7454 if(lstatus != NC_NOERR)
7455 return lstatus;
7456
7457 lstatus = ncx_getn_int_longlong(&xp, nget, value);
7458 if(lstatus != NC_NOERR && status == NC_NOERR)
7459 status = lstatus;
7460
7461 (void) ncio_rel(ncp->nciop, offset, 0);
7462
7463 remaining -= extent;
7464 if(remaining == 0)
7465 break; /* normal loop exit */
7466 offset += (off_t)extent;
7467 value += nget;
7468 }
7469
7470 return status;
7471 }
7472
7473 static int
getNCvx_int_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)7474 getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
7475 const size_t *start, size_t nelems, uint *value)
7476 {
7477 off_t offset = NC_varoffset(ncp, varp, start);
7478 size_t remaining = varp->xsz * nelems;
7479 int status = NC_NOERR;
7480 const void *xp;
7481
7482 if(nelems == 0)
7483 return NC_NOERR;
7484
7485 assert(value != NULL);
7486
7487 for(;;)
7488 {
7489 size_t extent = MIN(remaining, ncp->chunk);
7490 size_t nget = ncx_howmany(varp->type, extent);
7491
7492 int lstatus = ncio_get(ncp->nciop, offset, extent,
7493 0, (void **)&xp); /* cast away const */
7494 if(lstatus != NC_NOERR)
7495 return lstatus;
7496
7497 lstatus = ncx_getn_int_uint(&xp, nget, value);
7498 if(lstatus != NC_NOERR && status == NC_NOERR)
7499 status = lstatus;
7500
7501 (void) ncio_rel(ncp->nciop, offset, 0);
7502
7503 remaining -= extent;
7504 if(remaining == 0)
7505 break; /* normal loop exit */
7506 offset += (off_t)extent;
7507 value += nget;
7508 }
7509
7510 return status;
7511 }
7512
7513 static int
getNCvx_int_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)7514 getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
7515 const size_t *start, size_t nelems, ulonglong *value)
7516 {
7517 off_t offset = NC_varoffset(ncp, varp, start);
7518 size_t remaining = varp->xsz * nelems;
7519 int status = NC_NOERR;
7520 const void *xp;
7521
7522 if(nelems == 0)
7523 return NC_NOERR;
7524
7525 assert(value != NULL);
7526
7527 for(;;)
7528 {
7529 size_t extent = MIN(remaining, ncp->chunk);
7530 size_t nget = ncx_howmany(varp->type, extent);
7531
7532 int lstatus = ncio_get(ncp->nciop, offset, extent,
7533 0, (void **)&xp); /* cast away const */
7534 if(lstatus != NC_NOERR)
7535 return lstatus;
7536
7537 lstatus = ncx_getn_int_ulonglong(&xp, nget, value);
7538 if(lstatus != NC_NOERR && status == NC_NOERR)
7539 status = lstatus;
7540
7541 (void) ncio_rel(ncp->nciop, offset, 0);
7542
7543 remaining -= extent;
7544 if(remaining == 0)
7545 break; /* normal loop exit */
7546 offset += (off_t)extent;
7547 value += nget;
7548 }
7549
7550 return status;
7551 }
7552
7553 static int
getNCvx_int_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)7554 getNCvx_int_ushort(const NC3_INFO* ncp, const NC_var *varp,
7555 const size_t *start, size_t nelems, ushort *value)
7556 {
7557 off_t offset = NC_varoffset(ncp, varp, start);
7558 size_t remaining = varp->xsz * nelems;
7559 int status = NC_NOERR;
7560 const void *xp;
7561
7562 if(nelems == 0)
7563 return NC_NOERR;
7564
7565 assert(value != NULL);
7566
7567 for(;;)
7568 {
7569 size_t extent = MIN(remaining, ncp->chunk);
7570 size_t nget = ncx_howmany(varp->type, extent);
7571
7572 int lstatus = ncio_get(ncp->nciop, offset, extent,
7573 0, (void **)&xp); /* cast away const */
7574 if(lstatus != NC_NOERR)
7575 return lstatus;
7576
7577 lstatus = ncx_getn_int_ushort(&xp, nget, value);
7578 if(lstatus != NC_NOERR && status == NC_NOERR)
7579 status = lstatus;
7580
7581 (void) ncio_rel(ncp->nciop, offset, 0);
7582
7583 remaining -= extent;
7584 if(remaining == 0)
7585 break; /* normal loop exit */
7586 offset += (off_t)extent;
7587 value += nget;
7588 }
7589
7590 return status;
7591 }
7592
7593
7594 static int
getNCvx_float_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)7595 getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
7596 const size_t *start, size_t nelems, schar *value)
7597 {
7598 off_t offset = NC_varoffset(ncp, varp, start);
7599 size_t remaining = varp->xsz * nelems;
7600 int status = NC_NOERR;
7601 const void *xp;
7602
7603 if(nelems == 0)
7604 return NC_NOERR;
7605
7606 assert(value != NULL);
7607
7608 for(;;)
7609 {
7610 size_t extent = MIN(remaining, ncp->chunk);
7611 size_t nget = ncx_howmany(varp->type, extent);
7612
7613 int lstatus = ncio_get(ncp->nciop, offset, extent,
7614 0, (void **)&xp); /* cast away const */
7615 if(lstatus != NC_NOERR)
7616 return lstatus;
7617
7618 lstatus = ncx_getn_float_schar(&xp, nget, value);
7619 if(lstatus != NC_NOERR && status == NC_NOERR)
7620 status = lstatus;
7621
7622 (void) ncio_rel(ncp->nciop, offset, 0);
7623
7624 remaining -= extent;
7625 if(remaining == 0)
7626 break; /* normal loop exit */
7627 offset += (off_t)extent;
7628 value += nget;
7629 }
7630
7631 return status;
7632 }
7633
7634 static int
getNCvx_float_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)7635 getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
7636 const size_t *start, size_t nelems, uchar *value)
7637 {
7638 off_t offset = NC_varoffset(ncp, varp, start);
7639 size_t remaining = varp->xsz * nelems;
7640 int status = NC_NOERR;
7641 const void *xp;
7642
7643 if(nelems == 0)
7644 return NC_NOERR;
7645
7646 assert(value != NULL);
7647
7648 for(;;)
7649 {
7650 size_t extent = MIN(remaining, ncp->chunk);
7651 size_t nget = ncx_howmany(varp->type, extent);
7652
7653 int lstatus = ncio_get(ncp->nciop, offset, extent,
7654 0, (void **)&xp); /* cast away const */
7655 if(lstatus != NC_NOERR)
7656 return lstatus;
7657
7658 lstatus = ncx_getn_float_uchar(&xp, nget, value);
7659 if(lstatus != NC_NOERR && status == NC_NOERR)
7660 status = lstatus;
7661
7662 (void) ncio_rel(ncp->nciop, offset, 0);
7663
7664 remaining -= extent;
7665 if(remaining == 0)
7666 break; /* normal loop exit */
7667 offset += (off_t)extent;
7668 value += nget;
7669 }
7670
7671 return status;
7672 }
7673
7674 static int
getNCvx_float_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)7675 getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
7676 const size_t *start, size_t nelems, short *value)
7677 {
7678 off_t offset = NC_varoffset(ncp, varp, start);
7679 size_t remaining = varp->xsz * nelems;
7680 int status = NC_NOERR;
7681 const void *xp;
7682
7683 if(nelems == 0)
7684 return NC_NOERR;
7685
7686 assert(value != NULL);
7687
7688 for(;;)
7689 {
7690 size_t extent = MIN(remaining, ncp->chunk);
7691 size_t nget = ncx_howmany(varp->type, extent);
7692
7693 int lstatus = ncio_get(ncp->nciop, offset, extent,
7694 0, (void **)&xp); /* cast away const */
7695 if(lstatus != NC_NOERR)
7696 return lstatus;
7697
7698 lstatus = ncx_getn_float_short(&xp, nget, value);
7699 if(lstatus != NC_NOERR && status == NC_NOERR)
7700 status = lstatus;
7701
7702 (void) ncio_rel(ncp->nciop, offset, 0);
7703
7704 remaining -= extent;
7705 if(remaining == 0)
7706 break; /* normal loop exit */
7707 offset += (off_t)extent;
7708 value += nget;
7709 }
7710
7711 return status;
7712 }
7713
7714 static int
getNCvx_float_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)7715 getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
7716 const size_t *start, size_t nelems, int *value)
7717 {
7718 off_t offset = NC_varoffset(ncp, varp, start);
7719 size_t remaining = varp->xsz * nelems;
7720 int status = NC_NOERR;
7721 const void *xp;
7722
7723 if(nelems == 0)
7724 return NC_NOERR;
7725
7726 assert(value != NULL);
7727
7728 for(;;)
7729 {
7730 size_t extent = MIN(remaining, ncp->chunk);
7731 size_t nget = ncx_howmany(varp->type, extent);
7732
7733 int lstatus = ncio_get(ncp->nciop, offset, extent,
7734 0, (void **)&xp); /* cast away const */
7735 if(lstatus != NC_NOERR)
7736 return lstatus;
7737
7738 lstatus = ncx_getn_float_int(&xp, nget, value);
7739 if(lstatus != NC_NOERR && status == NC_NOERR)
7740 status = lstatus;
7741
7742 (void) ncio_rel(ncp->nciop, offset, 0);
7743
7744 remaining -= extent;
7745 if(remaining == 0)
7746 break; /* normal loop exit */
7747 offset += (off_t)extent;
7748 value += nget;
7749 }
7750
7751 return status;
7752 }
7753
7754 static int
getNCvx_float_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)7755 getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
7756 const size_t *start, size_t nelems, float *value)
7757 {
7758 off_t offset = NC_varoffset(ncp, varp, start);
7759 size_t remaining = varp->xsz * nelems;
7760 int status = NC_NOERR;
7761 const void *xp;
7762
7763 if(nelems == 0)
7764 return NC_NOERR;
7765
7766 assert(value != NULL);
7767
7768 for(;;)
7769 {
7770 size_t extent = MIN(remaining, ncp->chunk);
7771 size_t nget = ncx_howmany(varp->type, extent);
7772
7773 int lstatus = ncio_get(ncp->nciop, offset, extent,
7774 0, (void **)&xp); /* cast away const */
7775 if(lstatus != NC_NOERR)
7776 return lstatus;
7777
7778 lstatus = ncx_getn_float_float(&xp, nget, value);
7779 if(lstatus != NC_NOERR && status == NC_NOERR)
7780 status = lstatus;
7781
7782 (void) ncio_rel(ncp->nciop, offset, 0);
7783
7784 remaining -= extent;
7785 if(remaining == 0)
7786 break; /* normal loop exit */
7787 offset += (off_t)extent;
7788 value += nget;
7789 }
7790
7791 return status;
7792 }
7793
7794 static int
getNCvx_float_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)7795 getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
7796 const size_t *start, size_t nelems, double *value)
7797 {
7798 off_t offset = NC_varoffset(ncp, varp, start);
7799 size_t remaining = varp->xsz * nelems;
7800 int status = NC_NOERR;
7801 const void *xp;
7802
7803 if(nelems == 0)
7804 return NC_NOERR;
7805
7806 assert(value != NULL);
7807
7808 for(;;)
7809 {
7810 size_t extent = MIN(remaining, ncp->chunk);
7811 size_t nget = ncx_howmany(varp->type, extent);
7812
7813 int lstatus = ncio_get(ncp->nciop, offset, extent,
7814 0, (void **)&xp); /* cast away const */
7815 if(lstatus != NC_NOERR)
7816 return lstatus;
7817
7818 lstatus = ncx_getn_float_double(&xp, nget, value);
7819 if(lstatus != NC_NOERR && status == NC_NOERR)
7820 status = lstatus;
7821
7822 (void) ncio_rel(ncp->nciop, offset, 0);
7823
7824 remaining -= extent;
7825 if(remaining == 0)
7826 break; /* normal loop exit */
7827 offset += (off_t)extent;
7828 value += nget;
7829 }
7830
7831 return status;
7832 }
7833
7834 static int
getNCvx_float_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)7835 getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
7836 const size_t *start, size_t nelems, longlong *value)
7837 {
7838 off_t offset = NC_varoffset(ncp, varp, start);
7839 size_t remaining = varp->xsz * nelems;
7840 int status = NC_NOERR;
7841 const void *xp;
7842
7843 if(nelems == 0)
7844 return NC_NOERR;
7845
7846 assert(value != NULL);
7847
7848 for(;;)
7849 {
7850 size_t extent = MIN(remaining, ncp->chunk);
7851 size_t nget = ncx_howmany(varp->type, extent);
7852
7853 int lstatus = ncio_get(ncp->nciop, offset, extent,
7854 0, (void **)&xp); /* cast away const */
7855 if(lstatus != NC_NOERR)
7856 return lstatus;
7857
7858 lstatus = ncx_getn_float_longlong(&xp, nget, value);
7859 if(lstatus != NC_NOERR && status == NC_NOERR)
7860 status = lstatus;
7861
7862 (void) ncio_rel(ncp->nciop, offset, 0);
7863
7864 remaining -= extent;
7865 if(remaining == 0)
7866 break; /* normal loop exit */
7867 offset += (off_t)extent;
7868 value += nget;
7869 }
7870
7871 return status;
7872 }
7873
7874 static int
getNCvx_float_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)7875 getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
7876 const size_t *start, size_t nelems, uint *value)
7877 {
7878 off_t offset = NC_varoffset(ncp, varp, start);
7879 size_t remaining = varp->xsz * nelems;
7880 int status = NC_NOERR;
7881 const void *xp;
7882
7883 if(nelems == 0)
7884 return NC_NOERR;
7885
7886 assert(value != NULL);
7887
7888 for(;;)
7889 {
7890 size_t extent = MIN(remaining, ncp->chunk);
7891 size_t nget = ncx_howmany(varp->type, extent);
7892
7893 int lstatus = ncio_get(ncp->nciop, offset, extent,
7894 0, (void **)&xp); /* cast away const */
7895 if(lstatus != NC_NOERR)
7896 return lstatus;
7897
7898 lstatus = ncx_getn_float_uint(&xp, nget, value);
7899 if(lstatus != NC_NOERR && status == NC_NOERR)
7900 status = lstatus;
7901
7902 (void) ncio_rel(ncp->nciop, offset, 0);
7903
7904 remaining -= extent;
7905 if(remaining == 0)
7906 break; /* normal loop exit */
7907 offset += (off_t)extent;
7908 value += nget;
7909 }
7910
7911 return status;
7912 }
7913
7914 static int
getNCvx_float_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)7915 getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
7916 const size_t *start, size_t nelems, ulonglong *value)
7917 {
7918 off_t offset = NC_varoffset(ncp, varp, start);
7919 size_t remaining = varp->xsz * nelems;
7920 int status = NC_NOERR;
7921 const void *xp;
7922
7923 if(nelems == 0)
7924 return NC_NOERR;
7925
7926 assert(value != NULL);
7927
7928 for(;;)
7929 {
7930 size_t extent = MIN(remaining, ncp->chunk);
7931 size_t nget = ncx_howmany(varp->type, extent);
7932
7933 int lstatus = ncio_get(ncp->nciop, offset, extent,
7934 0, (void **)&xp); /* cast away const */
7935 if(lstatus != NC_NOERR)
7936 return lstatus;
7937
7938 lstatus = ncx_getn_float_ulonglong(&xp, nget, value);
7939 if(lstatus != NC_NOERR && status == NC_NOERR)
7940 status = lstatus;
7941
7942 (void) ncio_rel(ncp->nciop, offset, 0);
7943
7944 remaining -= extent;
7945 if(remaining == 0)
7946 break; /* normal loop exit */
7947 offset += (off_t)extent;
7948 value += nget;
7949 }
7950
7951 return status;
7952 }
7953
7954 static int
getNCvx_float_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)7955 getNCvx_float_ushort(const NC3_INFO* ncp, const NC_var *varp,
7956 const size_t *start, size_t nelems, ushort *value)
7957 {
7958 off_t offset = NC_varoffset(ncp, varp, start);
7959 size_t remaining = varp->xsz * nelems;
7960 int status = NC_NOERR;
7961 const void *xp;
7962
7963 if(nelems == 0)
7964 return NC_NOERR;
7965
7966 assert(value != NULL);
7967
7968 for(;;)
7969 {
7970 size_t extent = MIN(remaining, ncp->chunk);
7971 size_t nget = ncx_howmany(varp->type, extent);
7972
7973 int lstatus = ncio_get(ncp->nciop, offset, extent,
7974 0, (void **)&xp); /* cast away const */
7975 if(lstatus != NC_NOERR)
7976 return lstatus;
7977
7978 lstatus = ncx_getn_float_ushort(&xp, nget, value);
7979 if(lstatus != NC_NOERR && status == NC_NOERR)
7980 status = lstatus;
7981
7982 (void) ncio_rel(ncp->nciop, offset, 0);
7983
7984 remaining -= extent;
7985 if(remaining == 0)
7986 break; /* normal loop exit */
7987 offset += (off_t)extent;
7988 value += nget;
7989 }
7990
7991 return status;
7992 }
7993
7994
7995 static int
getNCvx_double_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)7996 getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
7997 const size_t *start, size_t nelems, schar *value)
7998 {
7999 off_t offset = NC_varoffset(ncp, varp, start);
8000 size_t remaining = varp->xsz * nelems;
8001 int status = NC_NOERR;
8002 const void *xp;
8003
8004 if(nelems == 0)
8005 return NC_NOERR;
8006
8007 assert(value != NULL);
8008
8009 for(;;)
8010 {
8011 size_t extent = MIN(remaining, ncp->chunk);
8012 size_t nget = ncx_howmany(varp->type, extent);
8013
8014 int lstatus = ncio_get(ncp->nciop, offset, extent,
8015 0, (void **)&xp); /* cast away const */
8016 if(lstatus != NC_NOERR)
8017 return lstatus;
8018
8019 lstatus = ncx_getn_double_schar(&xp, nget, value);
8020 if(lstatus != NC_NOERR && status == NC_NOERR)
8021 status = lstatus;
8022
8023 (void) ncio_rel(ncp->nciop, offset, 0);
8024
8025 remaining -= extent;
8026 if(remaining == 0)
8027 break; /* normal loop exit */
8028 offset += (off_t)extent;
8029 value += nget;
8030 }
8031
8032 return status;
8033 }
8034
8035 static int
getNCvx_double_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)8036 getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
8037 const size_t *start, size_t nelems, uchar *value)
8038 {
8039 off_t offset = NC_varoffset(ncp, varp, start);
8040 size_t remaining = varp->xsz * nelems;
8041 int status = NC_NOERR;
8042 const void *xp;
8043
8044 if(nelems == 0)
8045 return NC_NOERR;
8046
8047 assert(value != NULL);
8048
8049 for(;;)
8050 {
8051 size_t extent = MIN(remaining, ncp->chunk);
8052 size_t nget = ncx_howmany(varp->type, extent);
8053
8054 int lstatus = ncio_get(ncp->nciop, offset, extent,
8055 0, (void **)&xp); /* cast away const */
8056 if(lstatus != NC_NOERR)
8057 return lstatus;
8058
8059 lstatus = ncx_getn_double_uchar(&xp, nget, value);
8060 if(lstatus != NC_NOERR && status == NC_NOERR)
8061 status = lstatus;
8062
8063 (void) ncio_rel(ncp->nciop, offset, 0);
8064
8065 remaining -= extent;
8066 if(remaining == 0)
8067 break; /* normal loop exit */
8068 offset += (off_t)extent;
8069 value += nget;
8070 }
8071
8072 return status;
8073 }
8074
8075 static int
getNCvx_double_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)8076 getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
8077 const size_t *start, size_t nelems, short *value)
8078 {
8079 off_t offset = NC_varoffset(ncp, varp, start);
8080 size_t remaining = varp->xsz * nelems;
8081 int status = NC_NOERR;
8082 const void *xp;
8083
8084 if(nelems == 0)
8085 return NC_NOERR;
8086
8087 assert(value != NULL);
8088
8089 for(;;)
8090 {
8091 size_t extent = MIN(remaining, ncp->chunk);
8092 size_t nget = ncx_howmany(varp->type, extent);
8093
8094 int lstatus = ncio_get(ncp->nciop, offset, extent,
8095 0, (void **)&xp); /* cast away const */
8096 if(lstatus != NC_NOERR)
8097 return lstatus;
8098
8099 lstatus = ncx_getn_double_short(&xp, nget, value);
8100 if(lstatus != NC_NOERR && status == NC_NOERR)
8101 status = lstatus;
8102
8103 (void) ncio_rel(ncp->nciop, offset, 0);
8104
8105 remaining -= extent;
8106 if(remaining == 0)
8107 break; /* normal loop exit */
8108 offset += (off_t)extent;
8109 value += nget;
8110 }
8111
8112 return status;
8113 }
8114
8115 static int
getNCvx_double_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)8116 getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
8117 const size_t *start, size_t nelems, int *value)
8118 {
8119 off_t offset = NC_varoffset(ncp, varp, start);
8120 size_t remaining = varp->xsz * nelems;
8121 int status = NC_NOERR;
8122 const void *xp;
8123
8124 if(nelems == 0)
8125 return NC_NOERR;
8126
8127 assert(value != NULL);
8128
8129 for(;;)
8130 {
8131 size_t extent = MIN(remaining, ncp->chunk);
8132 size_t nget = ncx_howmany(varp->type, extent);
8133
8134 int lstatus = ncio_get(ncp->nciop, offset, extent,
8135 0, (void **)&xp); /* cast away const */
8136 if(lstatus != NC_NOERR)
8137 return lstatus;
8138
8139 lstatus = ncx_getn_double_int(&xp, nget, value);
8140 if(lstatus != NC_NOERR && status == NC_NOERR)
8141 status = lstatus;
8142
8143 (void) ncio_rel(ncp->nciop, offset, 0);
8144
8145 remaining -= extent;
8146 if(remaining == 0)
8147 break; /* normal loop exit */
8148 offset += (off_t)extent;
8149 value += nget;
8150 }
8151
8152 return status;
8153 }
8154
8155 static int
getNCvx_double_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)8156 getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
8157 const size_t *start, size_t nelems, float *value)
8158 {
8159 off_t offset = NC_varoffset(ncp, varp, start);
8160 size_t remaining = varp->xsz * nelems;
8161 int status = NC_NOERR;
8162 const void *xp;
8163
8164 if(nelems == 0)
8165 return NC_NOERR;
8166
8167 assert(value != NULL);
8168
8169 for(;;)
8170 {
8171 size_t extent = MIN(remaining, ncp->chunk);
8172 size_t nget = ncx_howmany(varp->type, extent);
8173
8174 int lstatus = ncio_get(ncp->nciop, offset, extent,
8175 0, (void **)&xp); /* cast away const */
8176 if(lstatus != NC_NOERR)
8177 return lstatus;
8178
8179 lstatus = ncx_getn_double_float(&xp, nget, value);
8180 if(lstatus != NC_NOERR && status == NC_NOERR)
8181 status = lstatus;
8182
8183 (void) ncio_rel(ncp->nciop, offset, 0);
8184
8185 remaining -= extent;
8186 if(remaining == 0)
8187 break; /* normal loop exit */
8188 offset += (off_t)extent;
8189 value += nget;
8190 }
8191
8192 return status;
8193 }
8194
8195 static int
getNCvx_double_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)8196 getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
8197 const size_t *start, size_t nelems, double *value)
8198 {
8199 off_t offset = NC_varoffset(ncp, varp, start);
8200 size_t remaining = varp->xsz * nelems;
8201 int status = NC_NOERR;
8202 const void *xp;
8203
8204 if(nelems == 0)
8205 return NC_NOERR;
8206
8207 assert(value != NULL);
8208
8209 for(;;)
8210 {
8211 size_t extent = MIN(remaining, ncp->chunk);
8212 size_t nget = ncx_howmany(varp->type, extent);
8213
8214 int lstatus = ncio_get(ncp->nciop, offset, extent,
8215 0, (void **)&xp); /* cast away const */
8216 if(lstatus != NC_NOERR)
8217 return lstatus;
8218
8219 lstatus = ncx_getn_double_double(&xp, nget, value);
8220 if(lstatus != NC_NOERR && status == NC_NOERR)
8221 status = lstatus;
8222
8223 (void) ncio_rel(ncp->nciop, offset, 0);
8224
8225 remaining -= extent;
8226 if(remaining == 0)
8227 break; /* normal loop exit */
8228 offset += (off_t)extent;
8229 value += nget;
8230 }
8231
8232 return status;
8233 }
8234
8235 static int
getNCvx_double_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)8236 getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
8237 const size_t *start, size_t nelems, longlong *value)
8238 {
8239 off_t offset = NC_varoffset(ncp, varp, start);
8240 size_t remaining = varp->xsz * nelems;
8241 int status = NC_NOERR;
8242 const void *xp;
8243
8244 if(nelems == 0)
8245 return NC_NOERR;
8246
8247 assert(value != NULL);
8248
8249 for(;;)
8250 {
8251 size_t extent = MIN(remaining, ncp->chunk);
8252 size_t nget = ncx_howmany(varp->type, extent);
8253
8254 int lstatus = ncio_get(ncp->nciop, offset, extent,
8255 0, (void **)&xp); /* cast away const */
8256 if(lstatus != NC_NOERR)
8257 return lstatus;
8258
8259 lstatus = ncx_getn_double_longlong(&xp, nget, value);
8260 if(lstatus != NC_NOERR && status == NC_NOERR)
8261 status = lstatus;
8262
8263 (void) ncio_rel(ncp->nciop, offset, 0);
8264
8265 remaining -= extent;
8266 if(remaining == 0)
8267 break; /* normal loop exit */
8268 offset += (off_t)extent;
8269 value += nget;
8270 }
8271
8272 return status;
8273 }
8274
8275 static int
getNCvx_double_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)8276 getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
8277 const size_t *start, size_t nelems, uint *value)
8278 {
8279 off_t offset = NC_varoffset(ncp, varp, start);
8280 size_t remaining = varp->xsz * nelems;
8281 int status = NC_NOERR;
8282 const void *xp;
8283
8284 if(nelems == 0)
8285 return NC_NOERR;
8286
8287 assert(value != NULL);
8288
8289 for(;;)
8290 {
8291 size_t extent = MIN(remaining, ncp->chunk);
8292 size_t nget = ncx_howmany(varp->type, extent);
8293
8294 int lstatus = ncio_get(ncp->nciop, offset, extent,
8295 0, (void **)&xp); /* cast away const */
8296 if(lstatus != NC_NOERR)
8297 return lstatus;
8298
8299 lstatus = ncx_getn_double_uint(&xp, nget, value);
8300 if(lstatus != NC_NOERR && status == NC_NOERR)
8301 status = lstatus;
8302
8303 (void) ncio_rel(ncp->nciop, offset, 0);
8304
8305 remaining -= extent;
8306 if(remaining == 0)
8307 break; /* normal loop exit */
8308 offset += (off_t)extent;
8309 value += nget;
8310 }
8311
8312 return status;
8313 }
8314
8315 static int
getNCvx_double_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)8316 getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
8317 const size_t *start, size_t nelems, ulonglong *value)
8318 {
8319 off_t offset = NC_varoffset(ncp, varp, start);
8320 size_t remaining = varp->xsz * nelems;
8321 int status = NC_NOERR;
8322 const void *xp;
8323
8324 if(nelems == 0)
8325 return NC_NOERR;
8326
8327 assert(value != NULL);
8328
8329 for(;;)
8330 {
8331 size_t extent = MIN(remaining, ncp->chunk);
8332 size_t nget = ncx_howmany(varp->type, extent);
8333
8334 int lstatus = ncio_get(ncp->nciop, offset, extent,
8335 0, (void **)&xp); /* cast away const */
8336 if(lstatus != NC_NOERR)
8337 return lstatus;
8338
8339 lstatus = ncx_getn_double_ulonglong(&xp, nget, value);
8340 if(lstatus != NC_NOERR && status == NC_NOERR)
8341 status = lstatus;
8342
8343 (void) ncio_rel(ncp->nciop, offset, 0);
8344
8345 remaining -= extent;
8346 if(remaining == 0)
8347 break; /* normal loop exit */
8348 offset += (off_t)extent;
8349 value += nget;
8350 }
8351
8352 return status;
8353 }
8354
8355 static int
getNCvx_double_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)8356 getNCvx_double_ushort(const NC3_INFO* ncp, const NC_var *varp,
8357 const size_t *start, size_t nelems, ushort *value)
8358 {
8359 off_t offset = NC_varoffset(ncp, varp, start);
8360 size_t remaining = varp->xsz * nelems;
8361 int status = NC_NOERR;
8362 const void *xp;
8363
8364 if(nelems == 0)
8365 return NC_NOERR;
8366
8367 assert(value != NULL);
8368
8369 for(;;)
8370 {
8371 size_t extent = MIN(remaining, ncp->chunk);
8372 size_t nget = ncx_howmany(varp->type, extent);
8373
8374 int lstatus = ncio_get(ncp->nciop, offset, extent,
8375 0, (void **)&xp); /* cast away const */
8376 if(lstatus != NC_NOERR)
8377 return lstatus;
8378
8379 lstatus = ncx_getn_double_ushort(&xp, nget, value);
8380 if(lstatus != NC_NOERR && status == NC_NOERR)
8381 status = lstatus;
8382
8383 (void) ncio_rel(ncp->nciop, offset, 0);
8384
8385 remaining -= extent;
8386 if(remaining == 0)
8387 break; /* normal loop exit */
8388 offset += (off_t)extent;
8389 value += nget;
8390 }
8391
8392 return status;
8393 }
8394
8395
8396 static int
getNCvx_uchar_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)8397 getNCvx_uchar_schar(const NC3_INFO* ncp, const NC_var *varp,
8398 const size_t *start, size_t nelems, schar *value)
8399 {
8400 off_t offset = NC_varoffset(ncp, varp, start);
8401 size_t remaining = varp->xsz * nelems;
8402 int status = NC_NOERR;
8403 const void *xp;
8404
8405 if(nelems == 0)
8406 return NC_NOERR;
8407
8408 assert(value != NULL);
8409
8410 for(;;)
8411 {
8412 size_t extent = MIN(remaining, ncp->chunk);
8413 size_t nget = ncx_howmany(varp->type, extent);
8414
8415 int lstatus = ncio_get(ncp->nciop, offset, extent,
8416 0, (void **)&xp); /* cast away const */
8417 if(lstatus != NC_NOERR)
8418 return lstatus;
8419
8420 lstatus = ncx_getn_uchar_schar(&xp, nget, value);
8421 if(lstatus != NC_NOERR && status == NC_NOERR)
8422 status = lstatus;
8423
8424 (void) ncio_rel(ncp->nciop, offset, 0);
8425
8426 remaining -= extent;
8427 if(remaining == 0)
8428 break; /* normal loop exit */
8429 offset += (off_t)extent;
8430 value += nget;
8431 }
8432
8433 return status;
8434 }
8435
8436 static int
getNCvx_uchar_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)8437 getNCvx_uchar_uchar(const NC3_INFO* ncp, const NC_var *varp,
8438 const size_t *start, size_t nelems, uchar *value)
8439 {
8440 off_t offset = NC_varoffset(ncp, varp, start);
8441 size_t remaining = varp->xsz * nelems;
8442 int status = NC_NOERR;
8443 const void *xp;
8444
8445 if(nelems == 0)
8446 return NC_NOERR;
8447
8448 assert(value != NULL);
8449
8450 for(;;)
8451 {
8452 size_t extent = MIN(remaining, ncp->chunk);
8453 size_t nget = ncx_howmany(varp->type, extent);
8454
8455 int lstatus = ncio_get(ncp->nciop, offset, extent,
8456 0, (void **)&xp); /* cast away const */
8457 if(lstatus != NC_NOERR)
8458 return lstatus;
8459
8460 lstatus = ncx_getn_uchar_uchar(&xp, nget, value);
8461 if(lstatus != NC_NOERR && status == NC_NOERR)
8462 status = lstatus;
8463
8464 (void) ncio_rel(ncp->nciop, offset, 0);
8465
8466 remaining -= extent;
8467 if(remaining == 0)
8468 break; /* normal loop exit */
8469 offset += (off_t)extent;
8470 value += nget;
8471 }
8472
8473 return status;
8474 }
8475
8476 static int
getNCvx_uchar_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)8477 getNCvx_uchar_short(const NC3_INFO* ncp, const NC_var *varp,
8478 const size_t *start, size_t nelems, short *value)
8479 {
8480 off_t offset = NC_varoffset(ncp, varp, start);
8481 size_t remaining = varp->xsz * nelems;
8482 int status = NC_NOERR;
8483 const void *xp;
8484
8485 if(nelems == 0)
8486 return NC_NOERR;
8487
8488 assert(value != NULL);
8489
8490 for(;;)
8491 {
8492 size_t extent = MIN(remaining, ncp->chunk);
8493 size_t nget = ncx_howmany(varp->type, extent);
8494
8495 int lstatus = ncio_get(ncp->nciop, offset, extent,
8496 0, (void **)&xp); /* cast away const */
8497 if(lstatus != NC_NOERR)
8498 return lstatus;
8499
8500 lstatus = ncx_getn_uchar_short(&xp, nget, value);
8501 if(lstatus != NC_NOERR && status == NC_NOERR)
8502 status = lstatus;
8503
8504 (void) ncio_rel(ncp->nciop, offset, 0);
8505
8506 remaining -= extent;
8507 if(remaining == 0)
8508 break; /* normal loop exit */
8509 offset += (off_t)extent;
8510 value += nget;
8511 }
8512
8513 return status;
8514 }
8515
8516 static int
getNCvx_uchar_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)8517 getNCvx_uchar_int(const NC3_INFO* ncp, const NC_var *varp,
8518 const size_t *start, size_t nelems, int *value)
8519 {
8520 off_t offset = NC_varoffset(ncp, varp, start);
8521 size_t remaining = varp->xsz * nelems;
8522 int status = NC_NOERR;
8523 const void *xp;
8524
8525 if(nelems == 0)
8526 return NC_NOERR;
8527
8528 assert(value != NULL);
8529
8530 for(;;)
8531 {
8532 size_t extent = MIN(remaining, ncp->chunk);
8533 size_t nget = ncx_howmany(varp->type, extent);
8534
8535 int lstatus = ncio_get(ncp->nciop, offset, extent,
8536 0, (void **)&xp); /* cast away const */
8537 if(lstatus != NC_NOERR)
8538 return lstatus;
8539
8540 lstatus = ncx_getn_uchar_int(&xp, nget, value);
8541 if(lstatus != NC_NOERR && status == NC_NOERR)
8542 status = lstatus;
8543
8544 (void) ncio_rel(ncp->nciop, offset, 0);
8545
8546 remaining -= extent;
8547 if(remaining == 0)
8548 break; /* normal loop exit */
8549 offset += (off_t)extent;
8550 value += nget;
8551 }
8552
8553 return status;
8554 }
8555
8556 static int
getNCvx_uchar_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)8557 getNCvx_uchar_float(const NC3_INFO* ncp, const NC_var *varp,
8558 const size_t *start, size_t nelems, float *value)
8559 {
8560 off_t offset = NC_varoffset(ncp, varp, start);
8561 size_t remaining = varp->xsz * nelems;
8562 int status = NC_NOERR;
8563 const void *xp;
8564
8565 if(nelems == 0)
8566 return NC_NOERR;
8567
8568 assert(value != NULL);
8569
8570 for(;;)
8571 {
8572 size_t extent = MIN(remaining, ncp->chunk);
8573 size_t nget = ncx_howmany(varp->type, extent);
8574
8575 int lstatus = ncio_get(ncp->nciop, offset, extent,
8576 0, (void **)&xp); /* cast away const */
8577 if(lstatus != NC_NOERR)
8578 return lstatus;
8579
8580 lstatus = ncx_getn_uchar_float(&xp, nget, value);
8581 if(lstatus != NC_NOERR && status == NC_NOERR)
8582 status = lstatus;
8583
8584 (void) ncio_rel(ncp->nciop, offset, 0);
8585
8586 remaining -= extent;
8587 if(remaining == 0)
8588 break; /* normal loop exit */
8589 offset += (off_t)extent;
8590 value += nget;
8591 }
8592
8593 return status;
8594 }
8595
8596 static int
getNCvx_uchar_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)8597 getNCvx_uchar_double(const NC3_INFO* ncp, const NC_var *varp,
8598 const size_t *start, size_t nelems, double *value)
8599 {
8600 off_t offset = NC_varoffset(ncp, varp, start);
8601 size_t remaining = varp->xsz * nelems;
8602 int status = NC_NOERR;
8603 const void *xp;
8604
8605 if(nelems == 0)
8606 return NC_NOERR;
8607
8608 assert(value != NULL);
8609
8610 for(;;)
8611 {
8612 size_t extent = MIN(remaining, ncp->chunk);
8613 size_t nget = ncx_howmany(varp->type, extent);
8614
8615 int lstatus = ncio_get(ncp->nciop, offset, extent,
8616 0, (void **)&xp); /* cast away const */
8617 if(lstatus != NC_NOERR)
8618 return lstatus;
8619
8620 lstatus = ncx_getn_uchar_double(&xp, nget, value);
8621 if(lstatus != NC_NOERR && status == NC_NOERR)
8622 status = lstatus;
8623
8624 (void) ncio_rel(ncp->nciop, offset, 0);
8625
8626 remaining -= extent;
8627 if(remaining == 0)
8628 break; /* normal loop exit */
8629 offset += (off_t)extent;
8630 value += nget;
8631 }
8632
8633 return status;
8634 }
8635
8636 static int
getNCvx_uchar_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)8637 getNCvx_uchar_longlong(const NC3_INFO* ncp, const NC_var *varp,
8638 const size_t *start, size_t nelems, longlong *value)
8639 {
8640 off_t offset = NC_varoffset(ncp, varp, start);
8641 size_t remaining = varp->xsz * nelems;
8642 int status = NC_NOERR;
8643 const void *xp;
8644
8645 if(nelems == 0)
8646 return NC_NOERR;
8647
8648 assert(value != NULL);
8649
8650 for(;;)
8651 {
8652 size_t extent = MIN(remaining, ncp->chunk);
8653 size_t nget = ncx_howmany(varp->type, extent);
8654
8655 int lstatus = ncio_get(ncp->nciop, offset, extent,
8656 0, (void **)&xp); /* cast away const */
8657 if(lstatus != NC_NOERR)
8658 return lstatus;
8659
8660 lstatus = ncx_getn_uchar_longlong(&xp, nget, value);
8661 if(lstatus != NC_NOERR && status == NC_NOERR)
8662 status = lstatus;
8663
8664 (void) ncio_rel(ncp->nciop, offset, 0);
8665
8666 remaining -= extent;
8667 if(remaining == 0)
8668 break; /* normal loop exit */
8669 offset += (off_t)extent;
8670 value += nget;
8671 }
8672
8673 return status;
8674 }
8675
8676 static int
getNCvx_uchar_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)8677 getNCvx_uchar_uint(const NC3_INFO* ncp, const NC_var *varp,
8678 const size_t *start, size_t nelems, uint *value)
8679 {
8680 off_t offset = NC_varoffset(ncp, varp, start);
8681 size_t remaining = varp->xsz * nelems;
8682 int status = NC_NOERR;
8683 const void *xp;
8684
8685 if(nelems == 0)
8686 return NC_NOERR;
8687
8688 assert(value != NULL);
8689
8690 for(;;)
8691 {
8692 size_t extent = MIN(remaining, ncp->chunk);
8693 size_t nget = ncx_howmany(varp->type, extent);
8694
8695 int lstatus = ncio_get(ncp->nciop, offset, extent,
8696 0, (void **)&xp); /* cast away const */
8697 if(lstatus != NC_NOERR)
8698 return lstatus;
8699
8700 lstatus = ncx_getn_uchar_uint(&xp, nget, value);
8701 if(lstatus != NC_NOERR && status == NC_NOERR)
8702 status = lstatus;
8703
8704 (void) ncio_rel(ncp->nciop, offset, 0);
8705
8706 remaining -= extent;
8707 if(remaining == 0)
8708 break; /* normal loop exit */
8709 offset += (off_t)extent;
8710 value += nget;
8711 }
8712
8713 return status;
8714 }
8715
8716 static int
getNCvx_uchar_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)8717 getNCvx_uchar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
8718 const size_t *start, size_t nelems, ulonglong *value)
8719 {
8720 off_t offset = NC_varoffset(ncp, varp, start);
8721 size_t remaining = varp->xsz * nelems;
8722 int status = NC_NOERR;
8723 const void *xp;
8724
8725 if(nelems == 0)
8726 return NC_NOERR;
8727
8728 assert(value != NULL);
8729
8730 for(;;)
8731 {
8732 size_t extent = MIN(remaining, ncp->chunk);
8733 size_t nget = ncx_howmany(varp->type, extent);
8734
8735 int lstatus = ncio_get(ncp->nciop, offset, extent,
8736 0, (void **)&xp); /* cast away const */
8737 if(lstatus != NC_NOERR)
8738 return lstatus;
8739
8740 lstatus = ncx_getn_uchar_ulonglong(&xp, nget, value);
8741 if(lstatus != NC_NOERR && status == NC_NOERR)
8742 status = lstatus;
8743
8744 (void) ncio_rel(ncp->nciop, offset, 0);
8745
8746 remaining -= extent;
8747 if(remaining == 0)
8748 break; /* normal loop exit */
8749 offset += (off_t)extent;
8750 value += nget;
8751 }
8752
8753 return status;
8754 }
8755
8756 static int
getNCvx_uchar_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)8757 getNCvx_uchar_ushort(const NC3_INFO* ncp, const NC_var *varp,
8758 const size_t *start, size_t nelems, ushort *value)
8759 {
8760 off_t offset = NC_varoffset(ncp, varp, start);
8761 size_t remaining = varp->xsz * nelems;
8762 int status = NC_NOERR;
8763 const void *xp;
8764
8765 if(nelems == 0)
8766 return NC_NOERR;
8767
8768 assert(value != NULL);
8769
8770 for(;;)
8771 {
8772 size_t extent = MIN(remaining, ncp->chunk);
8773 size_t nget = ncx_howmany(varp->type, extent);
8774
8775 int lstatus = ncio_get(ncp->nciop, offset, extent,
8776 0, (void **)&xp); /* cast away const */
8777 if(lstatus != NC_NOERR)
8778 return lstatus;
8779
8780 lstatus = ncx_getn_uchar_ushort(&xp, nget, value);
8781 if(lstatus != NC_NOERR && status == NC_NOERR)
8782 status = lstatus;
8783
8784 (void) ncio_rel(ncp->nciop, offset, 0);
8785
8786 remaining -= extent;
8787 if(remaining == 0)
8788 break; /* normal loop exit */
8789 offset += (off_t)extent;
8790 value += nget;
8791 }
8792
8793 return status;
8794 }
8795
8796
8797 static int
getNCvx_ushort_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)8798 getNCvx_ushort_schar(const NC3_INFO* ncp, const NC_var *varp,
8799 const size_t *start, size_t nelems, schar *value)
8800 {
8801 off_t offset = NC_varoffset(ncp, varp, start);
8802 size_t remaining = varp->xsz * nelems;
8803 int status = NC_NOERR;
8804 const void *xp;
8805
8806 if(nelems == 0)
8807 return NC_NOERR;
8808
8809 assert(value != NULL);
8810
8811 for(;;)
8812 {
8813 size_t extent = MIN(remaining, ncp->chunk);
8814 size_t nget = ncx_howmany(varp->type, extent);
8815
8816 int lstatus = ncio_get(ncp->nciop, offset, extent,
8817 0, (void **)&xp); /* cast away const */
8818 if(lstatus != NC_NOERR)
8819 return lstatus;
8820
8821 lstatus = ncx_getn_ushort_schar(&xp, nget, value);
8822 if(lstatus != NC_NOERR && status == NC_NOERR)
8823 status = lstatus;
8824
8825 (void) ncio_rel(ncp->nciop, offset, 0);
8826
8827 remaining -= extent;
8828 if(remaining == 0)
8829 break; /* normal loop exit */
8830 offset += (off_t)extent;
8831 value += nget;
8832 }
8833
8834 return status;
8835 }
8836
8837 static int
getNCvx_ushort_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)8838 getNCvx_ushort_uchar(const NC3_INFO* ncp, const NC_var *varp,
8839 const size_t *start, size_t nelems, uchar *value)
8840 {
8841 off_t offset = NC_varoffset(ncp, varp, start);
8842 size_t remaining = varp->xsz * nelems;
8843 int status = NC_NOERR;
8844 const void *xp;
8845
8846 if(nelems == 0)
8847 return NC_NOERR;
8848
8849 assert(value != NULL);
8850
8851 for(;;)
8852 {
8853 size_t extent = MIN(remaining, ncp->chunk);
8854 size_t nget = ncx_howmany(varp->type, extent);
8855
8856 int lstatus = ncio_get(ncp->nciop, offset, extent,
8857 0, (void **)&xp); /* cast away const */
8858 if(lstatus != NC_NOERR)
8859 return lstatus;
8860
8861 lstatus = ncx_getn_ushort_uchar(&xp, nget, value);
8862 if(lstatus != NC_NOERR && status == NC_NOERR)
8863 status = lstatus;
8864
8865 (void) ncio_rel(ncp->nciop, offset, 0);
8866
8867 remaining -= extent;
8868 if(remaining == 0)
8869 break; /* normal loop exit */
8870 offset += (off_t)extent;
8871 value += nget;
8872 }
8873
8874 return status;
8875 }
8876
8877 static int
getNCvx_ushort_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)8878 getNCvx_ushort_short(const NC3_INFO* ncp, const NC_var *varp,
8879 const size_t *start, size_t nelems, short *value)
8880 {
8881 off_t offset = NC_varoffset(ncp, varp, start);
8882 size_t remaining = varp->xsz * nelems;
8883 int status = NC_NOERR;
8884 const void *xp;
8885
8886 if(nelems == 0)
8887 return NC_NOERR;
8888
8889 assert(value != NULL);
8890
8891 for(;;)
8892 {
8893 size_t extent = MIN(remaining, ncp->chunk);
8894 size_t nget = ncx_howmany(varp->type, extent);
8895
8896 int lstatus = ncio_get(ncp->nciop, offset, extent,
8897 0, (void **)&xp); /* cast away const */
8898 if(lstatus != NC_NOERR)
8899 return lstatus;
8900
8901 lstatus = ncx_getn_ushort_short(&xp, nget, value);
8902 if(lstatus != NC_NOERR && status == NC_NOERR)
8903 status = lstatus;
8904
8905 (void) ncio_rel(ncp->nciop, offset, 0);
8906
8907 remaining -= extent;
8908 if(remaining == 0)
8909 break; /* normal loop exit */
8910 offset += (off_t)extent;
8911 value += nget;
8912 }
8913
8914 return status;
8915 }
8916
8917 static int
getNCvx_ushort_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)8918 getNCvx_ushort_int(const NC3_INFO* ncp, const NC_var *varp,
8919 const size_t *start, size_t nelems, int *value)
8920 {
8921 off_t offset = NC_varoffset(ncp, varp, start);
8922 size_t remaining = varp->xsz * nelems;
8923 int status = NC_NOERR;
8924 const void *xp;
8925
8926 if(nelems == 0)
8927 return NC_NOERR;
8928
8929 assert(value != NULL);
8930
8931 for(;;)
8932 {
8933 size_t extent = MIN(remaining, ncp->chunk);
8934 size_t nget = ncx_howmany(varp->type, extent);
8935
8936 int lstatus = ncio_get(ncp->nciop, offset, extent,
8937 0, (void **)&xp); /* cast away const */
8938 if(lstatus != NC_NOERR)
8939 return lstatus;
8940
8941 lstatus = ncx_getn_ushort_int(&xp, nget, value);
8942 if(lstatus != NC_NOERR && status == NC_NOERR)
8943 status = lstatus;
8944
8945 (void) ncio_rel(ncp->nciop, offset, 0);
8946
8947 remaining -= extent;
8948 if(remaining == 0)
8949 break; /* normal loop exit */
8950 offset += (off_t)extent;
8951 value += nget;
8952 }
8953
8954 return status;
8955 }
8956
8957 static int
getNCvx_ushort_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)8958 getNCvx_ushort_float(const NC3_INFO* ncp, const NC_var *varp,
8959 const size_t *start, size_t nelems, float *value)
8960 {
8961 off_t offset = NC_varoffset(ncp, varp, start);
8962 size_t remaining = varp->xsz * nelems;
8963 int status = NC_NOERR;
8964 const void *xp;
8965
8966 if(nelems == 0)
8967 return NC_NOERR;
8968
8969 assert(value != NULL);
8970
8971 for(;;)
8972 {
8973 size_t extent = MIN(remaining, ncp->chunk);
8974 size_t nget = ncx_howmany(varp->type, extent);
8975
8976 int lstatus = ncio_get(ncp->nciop, offset, extent,
8977 0, (void **)&xp); /* cast away const */
8978 if(lstatus != NC_NOERR)
8979 return lstatus;
8980
8981 lstatus = ncx_getn_ushort_float(&xp, nget, value);
8982 if(lstatus != NC_NOERR && status == NC_NOERR)
8983 status = lstatus;
8984
8985 (void) ncio_rel(ncp->nciop, offset, 0);
8986
8987 remaining -= extent;
8988 if(remaining == 0)
8989 break; /* normal loop exit */
8990 offset += (off_t)extent;
8991 value += nget;
8992 }
8993
8994 return status;
8995 }
8996
8997 static int
getNCvx_ushort_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)8998 getNCvx_ushort_double(const NC3_INFO* ncp, const NC_var *varp,
8999 const size_t *start, size_t nelems, double *value)
9000 {
9001 off_t offset = NC_varoffset(ncp, varp, start);
9002 size_t remaining = varp->xsz * nelems;
9003 int status = NC_NOERR;
9004 const void *xp;
9005
9006 if(nelems == 0)
9007 return NC_NOERR;
9008
9009 assert(value != NULL);
9010
9011 for(;;)
9012 {
9013 size_t extent = MIN(remaining, ncp->chunk);
9014 size_t nget = ncx_howmany(varp->type, extent);
9015
9016 int lstatus = ncio_get(ncp->nciop, offset, extent,
9017 0, (void **)&xp); /* cast away const */
9018 if(lstatus != NC_NOERR)
9019 return lstatus;
9020
9021 lstatus = ncx_getn_ushort_double(&xp, nget, value);
9022 if(lstatus != NC_NOERR && status == NC_NOERR)
9023 status = lstatus;
9024
9025 (void) ncio_rel(ncp->nciop, offset, 0);
9026
9027 remaining -= extent;
9028 if(remaining == 0)
9029 break; /* normal loop exit */
9030 offset += (off_t)extent;
9031 value += nget;
9032 }
9033
9034 return status;
9035 }
9036
9037 static int
getNCvx_ushort_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)9038 getNCvx_ushort_longlong(const NC3_INFO* ncp, const NC_var *varp,
9039 const size_t *start, size_t nelems, longlong *value)
9040 {
9041 off_t offset = NC_varoffset(ncp, varp, start);
9042 size_t remaining = varp->xsz * nelems;
9043 int status = NC_NOERR;
9044 const void *xp;
9045
9046 if(nelems == 0)
9047 return NC_NOERR;
9048
9049 assert(value != NULL);
9050
9051 for(;;)
9052 {
9053 size_t extent = MIN(remaining, ncp->chunk);
9054 size_t nget = ncx_howmany(varp->type, extent);
9055
9056 int lstatus = ncio_get(ncp->nciop, offset, extent,
9057 0, (void **)&xp); /* cast away const */
9058 if(lstatus != NC_NOERR)
9059 return lstatus;
9060
9061 lstatus = ncx_getn_ushort_longlong(&xp, nget, value);
9062 if(lstatus != NC_NOERR && status == NC_NOERR)
9063 status = lstatus;
9064
9065 (void) ncio_rel(ncp->nciop, offset, 0);
9066
9067 remaining -= extent;
9068 if(remaining == 0)
9069 break; /* normal loop exit */
9070 offset += (off_t)extent;
9071 value += nget;
9072 }
9073
9074 return status;
9075 }
9076
9077 static int
getNCvx_ushort_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)9078 getNCvx_ushort_uint(const NC3_INFO* ncp, const NC_var *varp,
9079 const size_t *start, size_t nelems, uint *value)
9080 {
9081 off_t offset = NC_varoffset(ncp, varp, start);
9082 size_t remaining = varp->xsz * nelems;
9083 int status = NC_NOERR;
9084 const void *xp;
9085
9086 if(nelems == 0)
9087 return NC_NOERR;
9088
9089 assert(value != NULL);
9090
9091 for(;;)
9092 {
9093 size_t extent = MIN(remaining, ncp->chunk);
9094 size_t nget = ncx_howmany(varp->type, extent);
9095
9096 int lstatus = ncio_get(ncp->nciop, offset, extent,
9097 0, (void **)&xp); /* cast away const */
9098 if(lstatus != NC_NOERR)
9099 return lstatus;
9100
9101 lstatus = ncx_getn_ushort_uint(&xp, nget, value);
9102 if(lstatus != NC_NOERR && status == NC_NOERR)
9103 status = lstatus;
9104
9105 (void) ncio_rel(ncp->nciop, offset, 0);
9106
9107 remaining -= extent;
9108 if(remaining == 0)
9109 break; /* normal loop exit */
9110 offset += (off_t)extent;
9111 value += nget;
9112 }
9113
9114 return status;
9115 }
9116
9117 static int
getNCvx_ushort_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)9118 getNCvx_ushort_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
9119 const size_t *start, size_t nelems, ulonglong *value)
9120 {
9121 off_t offset = NC_varoffset(ncp, varp, start);
9122 size_t remaining = varp->xsz * nelems;
9123 int status = NC_NOERR;
9124 const void *xp;
9125
9126 if(nelems == 0)
9127 return NC_NOERR;
9128
9129 assert(value != NULL);
9130
9131 for(;;)
9132 {
9133 size_t extent = MIN(remaining, ncp->chunk);
9134 size_t nget = ncx_howmany(varp->type, extent);
9135
9136 int lstatus = ncio_get(ncp->nciop, offset, extent,
9137 0, (void **)&xp); /* cast away const */
9138 if(lstatus != NC_NOERR)
9139 return lstatus;
9140
9141 lstatus = ncx_getn_ushort_ulonglong(&xp, nget, value);
9142 if(lstatus != NC_NOERR && status == NC_NOERR)
9143 status = lstatus;
9144
9145 (void) ncio_rel(ncp->nciop, offset, 0);
9146
9147 remaining -= extent;
9148 if(remaining == 0)
9149 break; /* normal loop exit */
9150 offset += (off_t)extent;
9151 value += nget;
9152 }
9153
9154 return status;
9155 }
9156
9157 static int
getNCvx_ushort_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)9158 getNCvx_ushort_ushort(const NC3_INFO* ncp, const NC_var *varp,
9159 const size_t *start, size_t nelems, ushort *value)
9160 {
9161 off_t offset = NC_varoffset(ncp, varp, start);
9162 size_t remaining = varp->xsz * nelems;
9163 int status = NC_NOERR;
9164 const void *xp;
9165
9166 if(nelems == 0)
9167 return NC_NOERR;
9168
9169 assert(value != NULL);
9170
9171 for(;;)
9172 {
9173 size_t extent = MIN(remaining, ncp->chunk);
9174 size_t nget = ncx_howmany(varp->type, extent);
9175
9176 int lstatus = ncio_get(ncp->nciop, offset, extent,
9177 0, (void **)&xp); /* cast away const */
9178 if(lstatus != NC_NOERR)
9179 return lstatus;
9180
9181 lstatus = ncx_getn_ushort_ushort(&xp, nget, value);
9182 if(lstatus != NC_NOERR && status == NC_NOERR)
9183 status = lstatus;
9184
9185 (void) ncio_rel(ncp->nciop, offset, 0);
9186
9187 remaining -= extent;
9188 if(remaining == 0)
9189 break; /* normal loop exit */
9190 offset += (off_t)extent;
9191 value += nget;
9192 }
9193
9194 return status;
9195 }
9196
9197
9198 static int
getNCvx_uint_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)9199 getNCvx_uint_schar(const NC3_INFO* ncp, const NC_var *varp,
9200 const size_t *start, size_t nelems, schar *value)
9201 {
9202 off_t offset = NC_varoffset(ncp, varp, start);
9203 size_t remaining = varp->xsz * nelems;
9204 int status = NC_NOERR;
9205 const void *xp;
9206
9207 if(nelems == 0)
9208 return NC_NOERR;
9209
9210 assert(value != NULL);
9211
9212 for(;;)
9213 {
9214 size_t extent = MIN(remaining, ncp->chunk);
9215 size_t nget = ncx_howmany(varp->type, extent);
9216
9217 int lstatus = ncio_get(ncp->nciop, offset, extent,
9218 0, (void **)&xp); /* cast away const */
9219 if(lstatus != NC_NOERR)
9220 return lstatus;
9221
9222 lstatus = ncx_getn_uint_schar(&xp, nget, value);
9223 if(lstatus != NC_NOERR && status == NC_NOERR)
9224 status = lstatus;
9225
9226 (void) ncio_rel(ncp->nciop, offset, 0);
9227
9228 remaining -= extent;
9229 if(remaining == 0)
9230 break; /* normal loop exit */
9231 offset += (off_t)extent;
9232 value += nget;
9233 }
9234
9235 return status;
9236 }
9237
9238 static int
getNCvx_uint_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)9239 getNCvx_uint_uchar(const NC3_INFO* ncp, const NC_var *varp,
9240 const size_t *start, size_t nelems, uchar *value)
9241 {
9242 off_t offset = NC_varoffset(ncp, varp, start);
9243 size_t remaining = varp->xsz * nelems;
9244 int status = NC_NOERR;
9245 const void *xp;
9246
9247 if(nelems == 0)
9248 return NC_NOERR;
9249
9250 assert(value != NULL);
9251
9252 for(;;)
9253 {
9254 size_t extent = MIN(remaining, ncp->chunk);
9255 size_t nget = ncx_howmany(varp->type, extent);
9256
9257 int lstatus = ncio_get(ncp->nciop, offset, extent,
9258 0, (void **)&xp); /* cast away const */
9259 if(lstatus != NC_NOERR)
9260 return lstatus;
9261
9262 lstatus = ncx_getn_uint_uchar(&xp, nget, value);
9263 if(lstatus != NC_NOERR && status == NC_NOERR)
9264 status = lstatus;
9265
9266 (void) ncio_rel(ncp->nciop, offset, 0);
9267
9268 remaining -= extent;
9269 if(remaining == 0)
9270 break; /* normal loop exit */
9271 offset += (off_t)extent;
9272 value += nget;
9273 }
9274
9275 return status;
9276 }
9277
9278 static int
getNCvx_uint_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)9279 getNCvx_uint_short(const NC3_INFO* ncp, const NC_var *varp,
9280 const size_t *start, size_t nelems, short *value)
9281 {
9282 off_t offset = NC_varoffset(ncp, varp, start);
9283 size_t remaining = varp->xsz * nelems;
9284 int status = NC_NOERR;
9285 const void *xp;
9286
9287 if(nelems == 0)
9288 return NC_NOERR;
9289
9290 assert(value != NULL);
9291
9292 for(;;)
9293 {
9294 size_t extent = MIN(remaining, ncp->chunk);
9295 size_t nget = ncx_howmany(varp->type, extent);
9296
9297 int lstatus = ncio_get(ncp->nciop, offset, extent,
9298 0, (void **)&xp); /* cast away const */
9299 if(lstatus != NC_NOERR)
9300 return lstatus;
9301
9302 lstatus = ncx_getn_uint_short(&xp, nget, value);
9303 if(lstatus != NC_NOERR && status == NC_NOERR)
9304 status = lstatus;
9305
9306 (void) ncio_rel(ncp->nciop, offset, 0);
9307
9308 remaining -= extent;
9309 if(remaining == 0)
9310 break; /* normal loop exit */
9311 offset += (off_t)extent;
9312 value += nget;
9313 }
9314
9315 return status;
9316 }
9317
9318 static int
getNCvx_uint_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)9319 getNCvx_uint_int(const NC3_INFO* ncp, const NC_var *varp,
9320 const size_t *start, size_t nelems, int *value)
9321 {
9322 off_t offset = NC_varoffset(ncp, varp, start);
9323 size_t remaining = varp->xsz * nelems;
9324 int status = NC_NOERR;
9325 const void *xp;
9326
9327 if(nelems == 0)
9328 return NC_NOERR;
9329
9330 assert(value != NULL);
9331
9332 for(;;)
9333 {
9334 size_t extent = MIN(remaining, ncp->chunk);
9335 size_t nget = ncx_howmany(varp->type, extent);
9336
9337 int lstatus = ncio_get(ncp->nciop, offset, extent,
9338 0, (void **)&xp); /* cast away const */
9339 if(lstatus != NC_NOERR)
9340 return lstatus;
9341
9342 lstatus = ncx_getn_uint_int(&xp, nget, value);
9343 if(lstatus != NC_NOERR && status == NC_NOERR)
9344 status = lstatus;
9345
9346 (void) ncio_rel(ncp->nciop, offset, 0);
9347
9348 remaining -= extent;
9349 if(remaining == 0)
9350 break; /* normal loop exit */
9351 offset += (off_t)extent;
9352 value += nget;
9353 }
9354
9355 return status;
9356 }
9357
9358 static int
getNCvx_uint_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)9359 getNCvx_uint_float(const NC3_INFO* ncp, const NC_var *varp,
9360 const size_t *start, size_t nelems, float *value)
9361 {
9362 off_t offset = NC_varoffset(ncp, varp, start);
9363 size_t remaining = varp->xsz * nelems;
9364 int status = NC_NOERR;
9365 const void *xp;
9366
9367 if(nelems == 0)
9368 return NC_NOERR;
9369
9370 assert(value != NULL);
9371
9372 for(;;)
9373 {
9374 size_t extent = MIN(remaining, ncp->chunk);
9375 size_t nget = ncx_howmany(varp->type, extent);
9376
9377 int lstatus = ncio_get(ncp->nciop, offset, extent,
9378 0, (void **)&xp); /* cast away const */
9379 if(lstatus != NC_NOERR)
9380 return lstatus;
9381
9382 lstatus = ncx_getn_uint_float(&xp, nget, value);
9383 if(lstatus != NC_NOERR && status == NC_NOERR)
9384 status = lstatus;
9385
9386 (void) ncio_rel(ncp->nciop, offset, 0);
9387
9388 remaining -= extent;
9389 if(remaining == 0)
9390 break; /* normal loop exit */
9391 offset += (off_t)extent;
9392 value += nget;
9393 }
9394
9395 return status;
9396 }
9397
9398 static int
getNCvx_uint_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)9399 getNCvx_uint_double(const NC3_INFO* ncp, const NC_var *varp,
9400 const size_t *start, size_t nelems, double *value)
9401 {
9402 off_t offset = NC_varoffset(ncp, varp, start);
9403 size_t remaining = varp->xsz * nelems;
9404 int status = NC_NOERR;
9405 const void *xp;
9406
9407 if(nelems == 0)
9408 return NC_NOERR;
9409
9410 assert(value != NULL);
9411
9412 for(;;)
9413 {
9414 size_t extent = MIN(remaining, ncp->chunk);
9415 size_t nget = ncx_howmany(varp->type, extent);
9416
9417 int lstatus = ncio_get(ncp->nciop, offset, extent,
9418 0, (void **)&xp); /* cast away const */
9419 if(lstatus != NC_NOERR)
9420 return lstatus;
9421
9422 lstatus = ncx_getn_uint_double(&xp, nget, value);
9423 if(lstatus != NC_NOERR && status == NC_NOERR)
9424 status = lstatus;
9425
9426 (void) ncio_rel(ncp->nciop, offset, 0);
9427
9428 remaining -= extent;
9429 if(remaining == 0)
9430 break; /* normal loop exit */
9431 offset += (off_t)extent;
9432 value += nget;
9433 }
9434
9435 return status;
9436 }
9437
9438 static int
getNCvx_uint_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)9439 getNCvx_uint_longlong(const NC3_INFO* ncp, const NC_var *varp,
9440 const size_t *start, size_t nelems, longlong *value)
9441 {
9442 off_t offset = NC_varoffset(ncp, varp, start);
9443 size_t remaining = varp->xsz * nelems;
9444 int status = NC_NOERR;
9445 const void *xp;
9446
9447 if(nelems == 0)
9448 return NC_NOERR;
9449
9450 assert(value != NULL);
9451
9452 for(;;)
9453 {
9454 size_t extent = MIN(remaining, ncp->chunk);
9455 size_t nget = ncx_howmany(varp->type, extent);
9456
9457 int lstatus = ncio_get(ncp->nciop, offset, extent,
9458 0, (void **)&xp); /* cast away const */
9459 if(lstatus != NC_NOERR)
9460 return lstatus;
9461
9462 lstatus = ncx_getn_uint_longlong(&xp, nget, value);
9463 if(lstatus != NC_NOERR && status == NC_NOERR)
9464 status = lstatus;
9465
9466 (void) ncio_rel(ncp->nciop, offset, 0);
9467
9468 remaining -= extent;
9469 if(remaining == 0)
9470 break; /* normal loop exit */
9471 offset += (off_t)extent;
9472 value += nget;
9473 }
9474
9475 return status;
9476 }
9477
9478 static int
getNCvx_uint_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)9479 getNCvx_uint_uint(const NC3_INFO* ncp, const NC_var *varp,
9480 const size_t *start, size_t nelems, uint *value)
9481 {
9482 off_t offset = NC_varoffset(ncp, varp, start);
9483 size_t remaining = varp->xsz * nelems;
9484 int status = NC_NOERR;
9485 const void *xp;
9486
9487 if(nelems == 0)
9488 return NC_NOERR;
9489
9490 assert(value != NULL);
9491
9492 for(;;)
9493 {
9494 size_t extent = MIN(remaining, ncp->chunk);
9495 size_t nget = ncx_howmany(varp->type, extent);
9496
9497 int lstatus = ncio_get(ncp->nciop, offset, extent,
9498 0, (void **)&xp); /* cast away const */
9499 if(lstatus != NC_NOERR)
9500 return lstatus;
9501
9502 lstatus = ncx_getn_uint_uint(&xp, nget, value);
9503 if(lstatus != NC_NOERR && status == NC_NOERR)
9504 status = lstatus;
9505
9506 (void) ncio_rel(ncp->nciop, offset, 0);
9507
9508 remaining -= extent;
9509 if(remaining == 0)
9510 break; /* normal loop exit */
9511 offset += (off_t)extent;
9512 value += nget;
9513 }
9514
9515 return status;
9516 }
9517
9518 static int
getNCvx_uint_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)9519 getNCvx_uint_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
9520 const size_t *start, size_t nelems, ulonglong *value)
9521 {
9522 off_t offset = NC_varoffset(ncp, varp, start);
9523 size_t remaining = varp->xsz * nelems;
9524 int status = NC_NOERR;
9525 const void *xp;
9526
9527 if(nelems == 0)
9528 return NC_NOERR;
9529
9530 assert(value != NULL);
9531
9532 for(;;)
9533 {
9534 size_t extent = MIN(remaining, ncp->chunk);
9535 size_t nget = ncx_howmany(varp->type, extent);
9536
9537 int lstatus = ncio_get(ncp->nciop, offset, extent,
9538 0, (void **)&xp); /* cast away const */
9539 if(lstatus != NC_NOERR)
9540 return lstatus;
9541
9542 lstatus = ncx_getn_uint_ulonglong(&xp, nget, value);
9543 if(lstatus != NC_NOERR && status == NC_NOERR)
9544 status = lstatus;
9545
9546 (void) ncio_rel(ncp->nciop, offset, 0);
9547
9548 remaining -= extent;
9549 if(remaining == 0)
9550 break; /* normal loop exit */
9551 offset += (off_t)extent;
9552 value += nget;
9553 }
9554
9555 return status;
9556 }
9557
9558 static int
getNCvx_uint_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)9559 getNCvx_uint_ushort(const NC3_INFO* ncp, const NC_var *varp,
9560 const size_t *start, size_t nelems, ushort *value)
9561 {
9562 off_t offset = NC_varoffset(ncp, varp, start);
9563 size_t remaining = varp->xsz * nelems;
9564 int status = NC_NOERR;
9565 const void *xp;
9566
9567 if(nelems == 0)
9568 return NC_NOERR;
9569
9570 assert(value != NULL);
9571
9572 for(;;)
9573 {
9574 size_t extent = MIN(remaining, ncp->chunk);
9575 size_t nget = ncx_howmany(varp->type, extent);
9576
9577 int lstatus = ncio_get(ncp->nciop, offset, extent,
9578 0, (void **)&xp); /* cast away const */
9579 if(lstatus != NC_NOERR)
9580 return lstatus;
9581
9582 lstatus = ncx_getn_uint_ushort(&xp, nget, value);
9583 if(lstatus != NC_NOERR && status == NC_NOERR)
9584 status = lstatus;
9585
9586 (void) ncio_rel(ncp->nciop, offset, 0);
9587
9588 remaining -= extent;
9589 if(remaining == 0)
9590 break; /* normal loop exit */
9591 offset += (off_t)extent;
9592 value += nget;
9593 }
9594
9595 return status;
9596 }
9597
9598
9599 static int
getNCvx_longlong_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)9600 getNCvx_longlong_schar(const NC3_INFO* ncp, const NC_var *varp,
9601 const size_t *start, size_t nelems, schar *value)
9602 {
9603 off_t offset = NC_varoffset(ncp, varp, start);
9604 size_t remaining = varp->xsz * nelems;
9605 int status = NC_NOERR;
9606 const void *xp;
9607
9608 if(nelems == 0)
9609 return NC_NOERR;
9610
9611 assert(value != NULL);
9612
9613 for(;;)
9614 {
9615 size_t extent = MIN(remaining, ncp->chunk);
9616 size_t nget = ncx_howmany(varp->type, extent);
9617
9618 int lstatus = ncio_get(ncp->nciop, offset, extent,
9619 0, (void **)&xp); /* cast away const */
9620 if(lstatus != NC_NOERR)
9621 return lstatus;
9622
9623 lstatus = ncx_getn_longlong_schar(&xp, nget, value);
9624 if(lstatus != NC_NOERR && status == NC_NOERR)
9625 status = lstatus;
9626
9627 (void) ncio_rel(ncp->nciop, offset, 0);
9628
9629 remaining -= extent;
9630 if(remaining == 0)
9631 break; /* normal loop exit */
9632 offset += (off_t)extent;
9633 value += nget;
9634 }
9635
9636 return status;
9637 }
9638
9639 static int
getNCvx_longlong_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)9640 getNCvx_longlong_uchar(const NC3_INFO* ncp, const NC_var *varp,
9641 const size_t *start, size_t nelems, uchar *value)
9642 {
9643 off_t offset = NC_varoffset(ncp, varp, start);
9644 size_t remaining = varp->xsz * nelems;
9645 int status = NC_NOERR;
9646 const void *xp;
9647
9648 if(nelems == 0)
9649 return NC_NOERR;
9650
9651 assert(value != NULL);
9652
9653 for(;;)
9654 {
9655 size_t extent = MIN(remaining, ncp->chunk);
9656 size_t nget = ncx_howmany(varp->type, extent);
9657
9658 int lstatus = ncio_get(ncp->nciop, offset, extent,
9659 0, (void **)&xp); /* cast away const */
9660 if(lstatus != NC_NOERR)
9661 return lstatus;
9662
9663 lstatus = ncx_getn_longlong_uchar(&xp, nget, value);
9664 if(lstatus != NC_NOERR && status == NC_NOERR)
9665 status = lstatus;
9666
9667 (void) ncio_rel(ncp->nciop, offset, 0);
9668
9669 remaining -= extent;
9670 if(remaining == 0)
9671 break; /* normal loop exit */
9672 offset += (off_t)extent;
9673 value += nget;
9674 }
9675
9676 return status;
9677 }
9678
9679 static int
getNCvx_longlong_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)9680 getNCvx_longlong_short(const NC3_INFO* ncp, const NC_var *varp,
9681 const size_t *start, size_t nelems, short *value)
9682 {
9683 off_t offset = NC_varoffset(ncp, varp, start);
9684 size_t remaining = varp->xsz * nelems;
9685 int status = NC_NOERR;
9686 const void *xp;
9687
9688 if(nelems == 0)
9689 return NC_NOERR;
9690
9691 assert(value != NULL);
9692
9693 for(;;)
9694 {
9695 size_t extent = MIN(remaining, ncp->chunk);
9696 size_t nget = ncx_howmany(varp->type, extent);
9697
9698 int lstatus = ncio_get(ncp->nciop, offset, extent,
9699 0, (void **)&xp); /* cast away const */
9700 if(lstatus != NC_NOERR)
9701 return lstatus;
9702
9703 lstatus = ncx_getn_longlong_short(&xp, nget, value);
9704 if(lstatus != NC_NOERR && status == NC_NOERR)
9705 status = lstatus;
9706
9707 (void) ncio_rel(ncp->nciop, offset, 0);
9708
9709 remaining -= extent;
9710 if(remaining == 0)
9711 break; /* normal loop exit */
9712 offset += (off_t)extent;
9713 value += nget;
9714 }
9715
9716 return status;
9717 }
9718
9719 static int
getNCvx_longlong_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)9720 getNCvx_longlong_int(const NC3_INFO* ncp, const NC_var *varp,
9721 const size_t *start, size_t nelems, int *value)
9722 {
9723 off_t offset = NC_varoffset(ncp, varp, start);
9724 size_t remaining = varp->xsz * nelems;
9725 int status = NC_NOERR;
9726 const void *xp;
9727
9728 if(nelems == 0)
9729 return NC_NOERR;
9730
9731 assert(value != NULL);
9732
9733 for(;;)
9734 {
9735 size_t extent = MIN(remaining, ncp->chunk);
9736 size_t nget = ncx_howmany(varp->type, extent);
9737
9738 int lstatus = ncio_get(ncp->nciop, offset, extent,
9739 0, (void **)&xp); /* cast away const */
9740 if(lstatus != NC_NOERR)
9741 return lstatus;
9742
9743 lstatus = ncx_getn_longlong_int(&xp, nget, value);
9744 if(lstatus != NC_NOERR && status == NC_NOERR)
9745 status = lstatus;
9746
9747 (void) ncio_rel(ncp->nciop, offset, 0);
9748
9749 remaining -= extent;
9750 if(remaining == 0)
9751 break; /* normal loop exit */
9752 offset += (off_t)extent;
9753 value += nget;
9754 }
9755
9756 return status;
9757 }
9758
9759 static int
getNCvx_longlong_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)9760 getNCvx_longlong_float(const NC3_INFO* ncp, const NC_var *varp,
9761 const size_t *start, size_t nelems, float *value)
9762 {
9763 off_t offset = NC_varoffset(ncp, varp, start);
9764 size_t remaining = varp->xsz * nelems;
9765 int status = NC_NOERR;
9766 const void *xp;
9767
9768 if(nelems == 0)
9769 return NC_NOERR;
9770
9771 assert(value != NULL);
9772
9773 for(;;)
9774 {
9775 size_t extent = MIN(remaining, ncp->chunk);
9776 size_t nget = ncx_howmany(varp->type, extent);
9777
9778 int lstatus = ncio_get(ncp->nciop, offset, extent,
9779 0, (void **)&xp); /* cast away const */
9780 if(lstatus != NC_NOERR)
9781 return lstatus;
9782
9783 lstatus = ncx_getn_longlong_float(&xp, nget, value);
9784 if(lstatus != NC_NOERR && status == NC_NOERR)
9785 status = lstatus;
9786
9787 (void) ncio_rel(ncp->nciop, offset, 0);
9788
9789 remaining -= extent;
9790 if(remaining == 0)
9791 break; /* normal loop exit */
9792 offset += (off_t)extent;
9793 value += nget;
9794 }
9795
9796 return status;
9797 }
9798
9799 static int
getNCvx_longlong_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)9800 getNCvx_longlong_double(const NC3_INFO* ncp, const NC_var *varp,
9801 const size_t *start, size_t nelems, double *value)
9802 {
9803 off_t offset = NC_varoffset(ncp, varp, start);
9804 size_t remaining = varp->xsz * nelems;
9805 int status = NC_NOERR;
9806 const void *xp;
9807
9808 if(nelems == 0)
9809 return NC_NOERR;
9810
9811 assert(value != NULL);
9812
9813 for(;;)
9814 {
9815 size_t extent = MIN(remaining, ncp->chunk);
9816 size_t nget = ncx_howmany(varp->type, extent);
9817
9818 int lstatus = ncio_get(ncp->nciop, offset, extent,
9819 0, (void **)&xp); /* cast away const */
9820 if(lstatus != NC_NOERR)
9821 return lstatus;
9822
9823 lstatus = ncx_getn_longlong_double(&xp, nget, value);
9824 if(lstatus != NC_NOERR && status == NC_NOERR)
9825 status = lstatus;
9826
9827 (void) ncio_rel(ncp->nciop, offset, 0);
9828
9829 remaining -= extent;
9830 if(remaining == 0)
9831 break; /* normal loop exit */
9832 offset += (off_t)extent;
9833 value += nget;
9834 }
9835
9836 return status;
9837 }
9838
9839 static int
getNCvx_longlong_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)9840 getNCvx_longlong_longlong(const NC3_INFO* ncp, const NC_var *varp,
9841 const size_t *start, size_t nelems, longlong *value)
9842 {
9843 off_t offset = NC_varoffset(ncp, varp, start);
9844 size_t remaining = varp->xsz * nelems;
9845 int status = NC_NOERR;
9846 const void *xp;
9847
9848 if(nelems == 0)
9849 return NC_NOERR;
9850
9851 assert(value != NULL);
9852
9853 for(;;)
9854 {
9855 size_t extent = MIN(remaining, ncp->chunk);
9856 size_t nget = ncx_howmany(varp->type, extent);
9857
9858 int lstatus = ncio_get(ncp->nciop, offset, extent,
9859 0, (void **)&xp); /* cast away const */
9860 if(lstatus != NC_NOERR)
9861 return lstatus;
9862
9863 lstatus = ncx_getn_longlong_longlong(&xp, nget, value);
9864 if(lstatus != NC_NOERR && status == NC_NOERR)
9865 status = lstatus;
9866
9867 (void) ncio_rel(ncp->nciop, offset, 0);
9868
9869 remaining -= extent;
9870 if(remaining == 0)
9871 break; /* normal loop exit */
9872 offset += (off_t)extent;
9873 value += nget;
9874 }
9875
9876 return status;
9877 }
9878
9879 static int
getNCvx_longlong_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)9880 getNCvx_longlong_uint(const NC3_INFO* ncp, const NC_var *varp,
9881 const size_t *start, size_t nelems, uint *value)
9882 {
9883 off_t offset = NC_varoffset(ncp, varp, start);
9884 size_t remaining = varp->xsz * nelems;
9885 int status = NC_NOERR;
9886 const void *xp;
9887
9888 if(nelems == 0)
9889 return NC_NOERR;
9890
9891 assert(value != NULL);
9892
9893 for(;;)
9894 {
9895 size_t extent = MIN(remaining, ncp->chunk);
9896 size_t nget = ncx_howmany(varp->type, extent);
9897
9898 int lstatus = ncio_get(ncp->nciop, offset, extent,
9899 0, (void **)&xp); /* cast away const */
9900 if(lstatus != NC_NOERR)
9901 return lstatus;
9902
9903 lstatus = ncx_getn_longlong_uint(&xp, nget, value);
9904 if(lstatus != NC_NOERR && status == NC_NOERR)
9905 status = lstatus;
9906
9907 (void) ncio_rel(ncp->nciop, offset, 0);
9908
9909 remaining -= extent;
9910 if(remaining == 0)
9911 break; /* normal loop exit */
9912 offset += (off_t)extent;
9913 value += nget;
9914 }
9915
9916 return status;
9917 }
9918
9919 static int
getNCvx_longlong_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)9920 getNCvx_longlong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
9921 const size_t *start, size_t nelems, ulonglong *value)
9922 {
9923 off_t offset = NC_varoffset(ncp, varp, start);
9924 size_t remaining = varp->xsz * nelems;
9925 int status = NC_NOERR;
9926 const void *xp;
9927
9928 if(nelems == 0)
9929 return NC_NOERR;
9930
9931 assert(value != NULL);
9932
9933 for(;;)
9934 {
9935 size_t extent = MIN(remaining, ncp->chunk);
9936 size_t nget = ncx_howmany(varp->type, extent);
9937
9938 int lstatus = ncio_get(ncp->nciop, offset, extent,
9939 0, (void **)&xp); /* cast away const */
9940 if(lstatus != NC_NOERR)
9941 return lstatus;
9942
9943 lstatus = ncx_getn_longlong_ulonglong(&xp, nget, value);
9944 if(lstatus != NC_NOERR && status == NC_NOERR)
9945 status = lstatus;
9946
9947 (void) ncio_rel(ncp->nciop, offset, 0);
9948
9949 remaining -= extent;
9950 if(remaining == 0)
9951 break; /* normal loop exit */
9952 offset += (off_t)extent;
9953 value += nget;
9954 }
9955
9956 return status;
9957 }
9958
9959 static int
getNCvx_longlong_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)9960 getNCvx_longlong_ushort(const NC3_INFO* ncp, const NC_var *varp,
9961 const size_t *start, size_t nelems, ushort *value)
9962 {
9963 off_t offset = NC_varoffset(ncp, varp, start);
9964 size_t remaining = varp->xsz * nelems;
9965 int status = NC_NOERR;
9966 const void *xp;
9967
9968 if(nelems == 0)
9969 return NC_NOERR;
9970
9971 assert(value != NULL);
9972
9973 for(;;)
9974 {
9975 size_t extent = MIN(remaining, ncp->chunk);
9976 size_t nget = ncx_howmany(varp->type, extent);
9977
9978 int lstatus = ncio_get(ncp->nciop, offset, extent,
9979 0, (void **)&xp); /* cast away const */
9980 if(lstatus != NC_NOERR)
9981 return lstatus;
9982
9983 lstatus = ncx_getn_longlong_ushort(&xp, nget, value);
9984 if(lstatus != NC_NOERR && status == NC_NOERR)
9985 status = lstatus;
9986
9987 (void) ncio_rel(ncp->nciop, offset, 0);
9988
9989 remaining -= extent;
9990 if(remaining == 0)
9991 break; /* normal loop exit */
9992 offset += (off_t)extent;
9993 value += nget;
9994 }
9995
9996 return status;
9997 }
9998
9999
10000 static int
getNCvx_ulonglong_schar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,schar * value)10001 getNCvx_ulonglong_schar(const NC3_INFO* ncp, const NC_var *varp,
10002 const size_t *start, size_t nelems, schar *value)
10003 {
10004 off_t offset = NC_varoffset(ncp, varp, start);
10005 size_t remaining = varp->xsz * nelems;
10006 int status = NC_NOERR;
10007 const void *xp;
10008
10009 if(nelems == 0)
10010 return NC_NOERR;
10011
10012 assert(value != NULL);
10013
10014 for(;;)
10015 {
10016 size_t extent = MIN(remaining, ncp->chunk);
10017 size_t nget = ncx_howmany(varp->type, extent);
10018
10019 int lstatus = ncio_get(ncp->nciop, offset, extent,
10020 0, (void **)&xp); /* cast away const */
10021 if(lstatus != NC_NOERR)
10022 return lstatus;
10023
10024 lstatus = ncx_getn_ulonglong_schar(&xp, nget, value);
10025 if(lstatus != NC_NOERR && status == NC_NOERR)
10026 status = lstatus;
10027
10028 (void) ncio_rel(ncp->nciop, offset, 0);
10029
10030 remaining -= extent;
10031 if(remaining == 0)
10032 break; /* normal loop exit */
10033 offset += (off_t)extent;
10034 value += nget;
10035 }
10036
10037 return status;
10038 }
10039
10040 static int
getNCvx_ulonglong_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)10041 getNCvx_ulonglong_uchar(const NC3_INFO* ncp, const NC_var *varp,
10042 const size_t *start, size_t nelems, uchar *value)
10043 {
10044 off_t offset = NC_varoffset(ncp, varp, start);
10045 size_t remaining = varp->xsz * nelems;
10046 int status = NC_NOERR;
10047 const void *xp;
10048
10049 if(nelems == 0)
10050 return NC_NOERR;
10051
10052 assert(value != NULL);
10053
10054 for(;;)
10055 {
10056 size_t extent = MIN(remaining, ncp->chunk);
10057 size_t nget = ncx_howmany(varp->type, extent);
10058
10059 int lstatus = ncio_get(ncp->nciop, offset, extent,
10060 0, (void **)&xp); /* cast away const */
10061 if(lstatus != NC_NOERR)
10062 return lstatus;
10063
10064 lstatus = ncx_getn_ulonglong_uchar(&xp, nget, value);
10065 if(lstatus != NC_NOERR && status == NC_NOERR)
10066 status = lstatus;
10067
10068 (void) ncio_rel(ncp->nciop, offset, 0);
10069
10070 remaining -= extent;
10071 if(remaining == 0)
10072 break; /* normal loop exit */
10073 offset += (off_t)extent;
10074 value += nget;
10075 }
10076
10077 return status;
10078 }
10079
10080 static int
getNCvx_ulonglong_short(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,short * value)10081 getNCvx_ulonglong_short(const NC3_INFO* ncp, const NC_var *varp,
10082 const size_t *start, size_t nelems, short *value)
10083 {
10084 off_t offset = NC_varoffset(ncp, varp, start);
10085 size_t remaining = varp->xsz * nelems;
10086 int status = NC_NOERR;
10087 const void *xp;
10088
10089 if(nelems == 0)
10090 return NC_NOERR;
10091
10092 assert(value != NULL);
10093
10094 for(;;)
10095 {
10096 size_t extent = MIN(remaining, ncp->chunk);
10097 size_t nget = ncx_howmany(varp->type, extent);
10098
10099 int lstatus = ncio_get(ncp->nciop, offset, extent,
10100 0, (void **)&xp); /* cast away const */
10101 if(lstatus != NC_NOERR)
10102 return lstatus;
10103
10104 lstatus = ncx_getn_ulonglong_short(&xp, nget, value);
10105 if(lstatus != NC_NOERR && status == NC_NOERR)
10106 status = lstatus;
10107
10108 (void) ncio_rel(ncp->nciop, offset, 0);
10109
10110 remaining -= extent;
10111 if(remaining == 0)
10112 break; /* normal loop exit */
10113 offset += (off_t)extent;
10114 value += nget;
10115 }
10116
10117 return status;
10118 }
10119
10120 static int
getNCvx_ulonglong_int(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,int * value)10121 getNCvx_ulonglong_int(const NC3_INFO* ncp, const NC_var *varp,
10122 const size_t *start, size_t nelems, int *value)
10123 {
10124 off_t offset = NC_varoffset(ncp, varp, start);
10125 size_t remaining = varp->xsz * nelems;
10126 int status = NC_NOERR;
10127 const void *xp;
10128
10129 if(nelems == 0)
10130 return NC_NOERR;
10131
10132 assert(value != NULL);
10133
10134 for(;;)
10135 {
10136 size_t extent = MIN(remaining, ncp->chunk);
10137 size_t nget = ncx_howmany(varp->type, extent);
10138
10139 int lstatus = ncio_get(ncp->nciop, offset, extent,
10140 0, (void **)&xp); /* cast away const */
10141 if(lstatus != NC_NOERR)
10142 return lstatus;
10143
10144 lstatus = ncx_getn_ulonglong_int(&xp, nget, value);
10145 if(lstatus != NC_NOERR && status == NC_NOERR)
10146 status = lstatus;
10147
10148 (void) ncio_rel(ncp->nciop, offset, 0);
10149
10150 remaining -= extent;
10151 if(remaining == 0)
10152 break; /* normal loop exit */
10153 offset += (off_t)extent;
10154 value += nget;
10155 }
10156
10157 return status;
10158 }
10159
10160 static int
getNCvx_ulonglong_float(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,float * value)10161 getNCvx_ulonglong_float(const NC3_INFO* ncp, const NC_var *varp,
10162 const size_t *start, size_t nelems, float *value)
10163 {
10164 off_t offset = NC_varoffset(ncp, varp, start);
10165 size_t remaining = varp->xsz * nelems;
10166 int status = NC_NOERR;
10167 const void *xp;
10168
10169 if(nelems == 0)
10170 return NC_NOERR;
10171
10172 assert(value != NULL);
10173
10174 for(;;)
10175 {
10176 size_t extent = MIN(remaining, ncp->chunk);
10177 size_t nget = ncx_howmany(varp->type, extent);
10178
10179 int lstatus = ncio_get(ncp->nciop, offset, extent,
10180 0, (void **)&xp); /* cast away const */
10181 if(lstatus != NC_NOERR)
10182 return lstatus;
10183
10184 lstatus = ncx_getn_ulonglong_float(&xp, nget, value);
10185 if(lstatus != NC_NOERR && status == NC_NOERR)
10186 status = lstatus;
10187
10188 (void) ncio_rel(ncp->nciop, offset, 0);
10189
10190 remaining -= extent;
10191 if(remaining == 0)
10192 break; /* normal loop exit */
10193 offset += (off_t)extent;
10194 value += nget;
10195 }
10196
10197 return status;
10198 }
10199
10200 static int
getNCvx_ulonglong_double(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,double * value)10201 getNCvx_ulonglong_double(const NC3_INFO* ncp, const NC_var *varp,
10202 const size_t *start, size_t nelems, double *value)
10203 {
10204 off_t offset = NC_varoffset(ncp, varp, start);
10205 size_t remaining = varp->xsz * nelems;
10206 int status = NC_NOERR;
10207 const void *xp;
10208
10209 if(nelems == 0)
10210 return NC_NOERR;
10211
10212 assert(value != NULL);
10213
10214 for(;;)
10215 {
10216 size_t extent = MIN(remaining, ncp->chunk);
10217 size_t nget = ncx_howmany(varp->type, extent);
10218
10219 int lstatus = ncio_get(ncp->nciop, offset, extent,
10220 0, (void **)&xp); /* cast away const */
10221 if(lstatus != NC_NOERR)
10222 return lstatus;
10223
10224 lstatus = ncx_getn_ulonglong_double(&xp, nget, value);
10225 if(lstatus != NC_NOERR && status == NC_NOERR)
10226 status = lstatus;
10227
10228 (void) ncio_rel(ncp->nciop, offset, 0);
10229
10230 remaining -= extent;
10231 if(remaining == 0)
10232 break; /* normal loop exit */
10233 offset += (off_t)extent;
10234 value += nget;
10235 }
10236
10237 return status;
10238 }
10239
10240 static int
getNCvx_ulonglong_longlong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,longlong * value)10241 getNCvx_ulonglong_longlong(const NC3_INFO* ncp, const NC_var *varp,
10242 const size_t *start, size_t nelems, longlong *value)
10243 {
10244 off_t offset = NC_varoffset(ncp, varp, start);
10245 size_t remaining = varp->xsz * nelems;
10246 int status = NC_NOERR;
10247 const void *xp;
10248
10249 if(nelems == 0)
10250 return NC_NOERR;
10251
10252 assert(value != NULL);
10253
10254 for(;;)
10255 {
10256 size_t extent = MIN(remaining, ncp->chunk);
10257 size_t nget = ncx_howmany(varp->type, extent);
10258
10259 int lstatus = ncio_get(ncp->nciop, offset, extent,
10260 0, (void **)&xp); /* cast away const */
10261 if(lstatus != NC_NOERR)
10262 return lstatus;
10263
10264 lstatus = ncx_getn_ulonglong_longlong(&xp, nget, value);
10265 if(lstatus != NC_NOERR && status == NC_NOERR)
10266 status = lstatus;
10267
10268 (void) ncio_rel(ncp->nciop, offset, 0);
10269
10270 remaining -= extent;
10271 if(remaining == 0)
10272 break; /* normal loop exit */
10273 offset += (off_t)extent;
10274 value += nget;
10275 }
10276
10277 return status;
10278 }
10279
10280 static int
getNCvx_ulonglong_uint(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uint * value)10281 getNCvx_ulonglong_uint(const NC3_INFO* ncp, const NC_var *varp,
10282 const size_t *start, size_t nelems, uint *value)
10283 {
10284 off_t offset = NC_varoffset(ncp, varp, start);
10285 size_t remaining = varp->xsz * nelems;
10286 int status = NC_NOERR;
10287 const void *xp;
10288
10289 if(nelems == 0)
10290 return NC_NOERR;
10291
10292 assert(value != NULL);
10293
10294 for(;;)
10295 {
10296 size_t extent = MIN(remaining, ncp->chunk);
10297 size_t nget = ncx_howmany(varp->type, extent);
10298
10299 int lstatus = ncio_get(ncp->nciop, offset, extent,
10300 0, (void **)&xp); /* cast away const */
10301 if(lstatus != NC_NOERR)
10302 return lstatus;
10303
10304 lstatus = ncx_getn_ulonglong_uint(&xp, nget, value);
10305 if(lstatus != NC_NOERR && status == NC_NOERR)
10306 status = lstatus;
10307
10308 (void) ncio_rel(ncp->nciop, offset, 0);
10309
10310 remaining -= extent;
10311 if(remaining == 0)
10312 break; /* normal loop exit */
10313 offset += (off_t)extent;
10314 value += nget;
10315 }
10316
10317 return status;
10318 }
10319
10320 static int
getNCvx_ulonglong_ulonglong(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ulonglong * value)10321 getNCvx_ulonglong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
10322 const size_t *start, size_t nelems, ulonglong *value)
10323 {
10324 off_t offset = NC_varoffset(ncp, varp, start);
10325 size_t remaining = varp->xsz * nelems;
10326 int status = NC_NOERR;
10327 const void *xp;
10328
10329 if(nelems == 0)
10330 return NC_NOERR;
10331
10332 assert(value != NULL);
10333
10334 for(;;)
10335 {
10336 size_t extent = MIN(remaining, ncp->chunk);
10337 size_t nget = ncx_howmany(varp->type, extent);
10338
10339 int lstatus = ncio_get(ncp->nciop, offset, extent,
10340 0, (void **)&xp); /* cast away const */
10341 if(lstatus != NC_NOERR)
10342 return lstatus;
10343
10344 lstatus = ncx_getn_ulonglong_ulonglong(&xp, nget, value);
10345 if(lstatus != NC_NOERR && status == NC_NOERR)
10346 status = lstatus;
10347
10348 (void) ncio_rel(ncp->nciop, offset, 0);
10349
10350 remaining -= extent;
10351 if(remaining == 0)
10352 break; /* normal loop exit */
10353 offset += (off_t)extent;
10354 value += nget;
10355 }
10356
10357 return status;
10358 }
10359
10360 static int
getNCvx_ulonglong_ushort(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,ushort * value)10361 getNCvx_ulonglong_ushort(const NC3_INFO* ncp, const NC_var *varp,
10362 const size_t *start, size_t nelems, ushort *value)
10363 {
10364 off_t offset = NC_varoffset(ncp, varp, start);
10365 size_t remaining = varp->xsz * nelems;
10366 int status = NC_NOERR;
10367 const void *xp;
10368
10369 if(nelems == 0)
10370 return NC_NOERR;
10371
10372 assert(value != NULL);
10373
10374 for(;;)
10375 {
10376 size_t extent = MIN(remaining, ncp->chunk);
10377 size_t nget = ncx_howmany(varp->type, extent);
10378
10379 int lstatus = ncio_get(ncp->nciop, offset, extent,
10380 0, (void **)&xp); /* cast away const */
10381 if(lstatus != NC_NOERR)
10382 return lstatus;
10383
10384 lstatus = ncx_getn_ulonglong_ushort(&xp, nget, value);
10385 if(lstatus != NC_NOERR && status == NC_NOERR)
10386 status = lstatus;
10387
10388 (void) ncio_rel(ncp->nciop, offset, 0);
10389
10390 remaining -= extent;
10391 if(remaining == 0)
10392 break; /* normal loop exit */
10393 offset += (off_t)extent;
10394 value += nget;
10395 }
10396
10397 return status;
10398 }
10399
10400
10401 #ifdef NOTUSED
10402 static int
getNCvx_schar_uchar(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,size_t nelems,uchar * value)10403 getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
10404 const size_t *start, size_t nelems, uchar *value)
10405 {
10406 off_t offset = NC_varoffset(ncp, varp, start);
10407 size_t remaining = varp->xsz * nelems;
10408 int status = NC_NOERR;
10409 const void *xp;
10410
10411 if(nelems == 0)
10412 return NC_NOERR;
10413
10414 assert(value != NULL);
10415
10416 for(;;)
10417 {
10418 size_t extent = MIN(remaining, ncp->chunk);
10419 size_t nget = ncx_howmany(varp->type, extent);
10420
10421 int lstatus = ncio_get(ncp->nciop, offset, extent,
10422 0, (void **)&xp); /* cast away const */
10423 if(lstatus != NC_NOERR)
10424 return lstatus;
10425
10426 lstatus = ncx_getn_schar_uchar(&xp, nget, value);
10427 if(lstatus != NC_NOERR && status == NC_NOERR)
10428 status = lstatus;
10429
10430 (void) ncio_rel(ncp->nciop, offset, 0);
10431
10432 remaining -= extent;
10433 if(remaining == 0)
10434 break; /* normal loop exit */
10435 offset += (off_t)extent;
10436 value += nget;
10437 }
10438
10439 return status;
10440 }
10441
10442 #endif /*NOTUSED*/
10443
10444 /*
10445 * For ncvar{put,get},
10446 * find the largest contiguous block from within 'edges'.
10447 * returns the index to the left of this (which may be -1).
10448 * Compute the number of contiguous elements and return
10449 * that in *iocountp.
10450 * The presence of "record" variables makes this routine
10451 * overly subtle.
10452 */
10453 static int
NCiocount(const NC3_INFO * const ncp,const NC_var * const varp,const size_t * const edges,size_t * const iocountp)10454 NCiocount(const NC3_INFO* const ncp, const NC_var *const varp,
10455 const size_t *const edges,
10456 size_t *const iocountp)
10457 {
10458 const size_t *edp0 = edges;
10459 const size_t *edp = edges + varp->ndims;
10460 const size_t *shp = varp->shape + varp->ndims;
10461
10462 if(IS_RECVAR(varp))
10463 {
10464 if(varp->ndims == 1 && ncp->recsize <= varp->len)
10465 {
10466 /* one dimensional && the only 'record' variable */
10467 *iocountp = *edges;
10468 return(0);
10469 }
10470 /* else */
10471 edp0++;
10472 }
10473
10474 assert(edges != NULL);
10475
10476 /* find max contiguous */
10477 while(edp > edp0)
10478 {
10479 shp--; edp--;
10480 if(*edp < *shp )
10481 {
10482 const size_t *zedp = edp;
10483 while(zedp >= edp0)
10484 {
10485 if(*zedp == 0)
10486 {
10487 *iocountp = 0;
10488 goto done;
10489 }
10490 /* Tip of the hat to segmented architectures */
10491 if(zedp == edp0)
10492 break;
10493 zedp--;
10494 }
10495 break;
10496 }
10497 assert(*edp == *shp);
10498 }
10499
10500 /*
10501 * edp, shp reference rightmost index s.t. *(edp +1) == *(shp +1)
10502 *
10503 * Or there is only one dimension.
10504 * If there is only one dimension and it is 'non record' dimension,
10505 * edp is &edges[0] and we will return -1.
10506 * If there is only one dimension and and it is a "record dimension",
10507 * edp is &edges[1] (out of bounds) and we will return 0;
10508 */
10509 assert(shp >= varp->shape + varp->ndims -1
10510 || *(edp +1) == *(shp +1));
10511
10512 /* now accumulate max count for a single io operation */
10513 for(*iocountp = 1, edp0 = edp;
10514 edp0 < edges + varp->ndims;
10515 edp0++)
10516 {
10517 *iocountp *= *edp0;
10518 }
10519
10520 done:
10521 return((int)(edp - edges) - 1);
10522 }
10523
10524
10525 /*
10526 * Set the elements of the array 'upp' to
10527 * the sum of the corresponding elements of
10528 * 'stp' and 'edp'. 'end' should be &stp[nelems].
10529 */
10530 static void
set_upper(size_t * upp,const size_t * stp,const size_t * edp,const size_t * const end)10531 set_upper(size_t *upp, /* modified on return */
10532 const size_t *stp,
10533 const size_t *edp,
10534 const size_t *const end)
10535 {
10536 while(upp < end) {
10537 *upp++ = *stp++ + *edp++;
10538 }
10539 }
10540
10541
10542 /*
10543 * The infamous and oft-discussed odometer code.
10544 *
10545 * 'start[]' is the starting coordinate.
10546 * 'upper[]' is the upper bound s.t. start[ii] < upper[ii].
10547 * 'coord[]' is the register, the current coordinate value.
10548 * For some ii,
10549 * upp == &upper[ii]
10550 * cdp == &coord[ii]
10551 *
10552 * Running this routine increments *cdp.
10553 *
10554 * If after the increment, *cdp is equal to *upp
10555 * (and cdp is not the leftmost dimension),
10556 * *cdp is "zeroed" to the starting value and
10557 * we need to "carry", eg, increment one place to
10558 * the left.
10559 *
10560 * TODO: Some architectures hate recursion?
10561 * Reimplement non-recursively.
10562 */
10563 static void
odo1(const size_t * const start,const size_t * const upper,size_t * const coord,const size_t * upp,size_t * cdp)10564 odo1(const size_t *const start, const size_t *const upper,
10565 size_t *const coord, /* modified on return */
10566 const size_t *upp,
10567 size_t *cdp)
10568 {
10569 assert(coord <= cdp && cdp <= coord + NC_MAX_VAR_DIMS);
10570 assert(upper <= upp && upp <= upper + NC_MAX_VAR_DIMS);
10571 assert(upp - upper == cdp - coord);
10572
10573 assert(*cdp <= *upp);
10574
10575 (*cdp)++;
10576 if(cdp != coord && *cdp >= *upp)
10577 {
10578 *cdp = start[cdp - coord];
10579 odo1(start, upper, coord, upp -1, cdp -1);
10580 }
10581 }
10582 #ifdef _CRAYC
10583 #pragma _CRI noinline odo1
10584 #endif
10585
10586
10587
10588 /* Define a macro to allow hash on two type values */
10589 #define CASE(nc1,nc2) (nc1*256+nc2)
10590
10591 static int
readNCv(const NC3_INFO * ncp,const NC_var * varp,const size_t * start,const size_t nelems,void * value,const nc_type memtype)10592 readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
10593 const size_t nelems, void* value, const nc_type memtype)
10594 {
10595 int status = NC_NOERR;
10596 switch (CASE(varp->type,memtype)) {
10597
10598 case CASE(NC_CHAR,NC_CHAR):
10599 case CASE(NC_CHAR,NC_UBYTE):
10600 return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
10601 break;
10602 case CASE(NC_BYTE,NC_BYTE):
10603 return getNCvx_schar_schar(ncp,varp,start,nelems, (schar*)value);
10604 break;
10605 case CASE(NC_BYTE,NC_UBYTE):
10606 if (fIsSet(ncp->flags,NC_64BIT_DATA))
10607 return getNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10608 else
10609 /* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
10610 return getNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10611 break;
10612 case CASE(NC_BYTE,NC_SHORT):
10613 return getNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
10614 break;
10615 case CASE(NC_BYTE,NC_INT):
10616 return getNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
10617 break;
10618 case CASE(NC_BYTE,NC_FLOAT):
10619 return getNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
10620 break;
10621 case CASE(NC_BYTE,NC_DOUBLE):
10622 return getNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
10623 break;
10624 case CASE(NC_BYTE,NC_INT64):
10625 return getNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
10626 break;
10627 case CASE(NC_BYTE,NC_UINT):
10628 return getNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
10629 break;
10630 case CASE(NC_BYTE,NC_UINT64):
10631 return getNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10632 break;
10633 case CASE(NC_BYTE,NC_USHORT):
10634 return getNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10635 break;
10636 case CASE(NC_SHORT,NC_BYTE):
10637 return getNCvx_short_schar(ncp,varp,start,nelems,(schar*)value);
10638 break;
10639 case CASE(NC_SHORT,NC_UBYTE):
10640 return getNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10641 break;
10642 case CASE(NC_SHORT,NC_SHORT):
10643 return getNCvx_short_short(ncp,varp,start,nelems,(short*)value);
10644 break;
10645 case CASE(NC_SHORT,NC_INT):
10646 return getNCvx_short_int(ncp,varp,start,nelems,(int*)value);
10647 break;
10648 case CASE(NC_SHORT,NC_FLOAT):
10649 return getNCvx_short_float(ncp,varp,start,nelems,(float*)value);
10650 break;
10651 case CASE(NC_SHORT,NC_DOUBLE):
10652 return getNCvx_short_double(ncp,varp,start,nelems,(double*)value);
10653 break;
10654 case CASE(NC_SHORT,NC_INT64):
10655 return getNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
10656 break;
10657 case CASE(NC_SHORT,NC_UINT):
10658 return getNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
10659 break;
10660 case CASE(NC_SHORT,NC_UINT64):
10661 return getNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10662 break;
10663 case CASE(NC_SHORT,NC_USHORT):
10664 return getNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10665 break;
10666
10667 case CASE(NC_INT,NC_BYTE):
10668 return getNCvx_int_schar(ncp,varp,start,nelems,(schar*)value);
10669 break;
10670 case CASE(NC_INT,NC_UBYTE):
10671 return getNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10672 break;
10673 case CASE(NC_INT,NC_SHORT):
10674 return getNCvx_int_short(ncp,varp,start,nelems,(short*)value);
10675 break;
10676 case CASE(NC_INT,NC_INT):
10677 return getNCvx_int_int(ncp,varp,start,nelems,(int*)value);
10678 break;
10679 case CASE(NC_INT,NC_FLOAT):
10680 return getNCvx_int_float(ncp,varp,start,nelems,(float*)value);
10681 break;
10682 case CASE(NC_INT,NC_DOUBLE):
10683 return getNCvx_int_double(ncp,varp,start,nelems,(double*)value);
10684 break;
10685 case CASE(NC_INT,NC_INT64):
10686 return getNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
10687 break;
10688 case CASE(NC_INT,NC_UINT):
10689 return getNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
10690 break;
10691 case CASE(NC_INT,NC_UINT64):
10692 return getNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10693 break;
10694 case CASE(NC_INT,NC_USHORT):
10695 return getNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10696 break;
10697
10698 case CASE(NC_FLOAT,NC_BYTE):
10699 return getNCvx_float_schar(ncp,varp,start,nelems,(schar*)value);
10700 break;
10701 case CASE(NC_FLOAT,NC_UBYTE):
10702 return getNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10703 break;
10704 case CASE(NC_FLOAT,NC_SHORT):
10705 return getNCvx_float_short(ncp,varp,start,nelems,(short*)value);
10706 break;
10707 case CASE(NC_FLOAT,NC_INT):
10708 return getNCvx_float_int(ncp,varp,start,nelems,(int*)value);
10709 break;
10710 case CASE(NC_FLOAT,NC_FLOAT):
10711 return getNCvx_float_float(ncp,varp,start,nelems,(float*)value);
10712 break;
10713 case CASE(NC_FLOAT,NC_DOUBLE):
10714 return getNCvx_float_double(ncp,varp,start,nelems,(double*)value);
10715 break;
10716 case CASE(NC_FLOAT,NC_INT64):
10717 return getNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
10718 break;
10719 case CASE(NC_FLOAT,NC_UINT):
10720 return getNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
10721 break;
10722 case CASE(NC_FLOAT,NC_UINT64):
10723 return getNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10724 break;
10725 case CASE(NC_FLOAT,NC_USHORT):
10726 return getNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10727 break;
10728
10729 case CASE(NC_DOUBLE,NC_BYTE):
10730 return getNCvx_double_schar(ncp,varp,start,nelems,(schar*)value);
10731 break;
10732 case CASE(NC_DOUBLE,NC_UBYTE):
10733 return getNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10734 break;
10735 case CASE(NC_DOUBLE,NC_SHORT):
10736 return getNCvx_double_short(ncp,varp,start,nelems,(short*)value);
10737 break;
10738 case CASE(NC_DOUBLE,NC_INT):
10739 return getNCvx_double_int(ncp,varp,start,nelems,(int*)value);
10740 break;
10741 case CASE(NC_DOUBLE,NC_FLOAT):
10742 return getNCvx_double_float(ncp,varp,start,nelems,(float*)value);
10743 break;
10744 case CASE(NC_DOUBLE,NC_DOUBLE):
10745 return getNCvx_double_double(ncp,varp,start,nelems,(double*)value);
10746 break;
10747 case CASE(NC_DOUBLE,NC_INT64):
10748 return getNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
10749 break;
10750 case CASE(NC_DOUBLE,NC_UINT):
10751 return getNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
10752 break;
10753 case CASE(NC_DOUBLE,NC_UINT64):
10754 return getNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10755 break;
10756 case CASE(NC_DOUBLE,NC_USHORT):
10757 return getNCvx_double_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10758 break;
10759
10760 case CASE(NC_UBYTE,NC_UBYTE):
10761 return getNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10762 break;
10763 case CASE(NC_UBYTE,NC_BYTE):
10764 return getNCvx_uchar_schar(ncp,varp,start,nelems,(schar*)value);
10765 break;
10766 case CASE(NC_UBYTE,NC_SHORT):
10767 return getNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
10768 break;
10769 case CASE(NC_UBYTE,NC_INT):
10770 return getNCvx_uchar_int(ncp,varp,start,nelems,(int*)value);
10771 break;
10772 case CASE(NC_UBYTE,NC_FLOAT):
10773 return getNCvx_uchar_float(ncp,varp,start,nelems,(float*)value);
10774 break;
10775 case CASE(NC_UBYTE,NC_DOUBLE):
10776 return getNCvx_uchar_double(ncp,varp,start,nelems,(double *)value);
10777 break;
10778 case CASE(NC_UBYTE,NC_INT64):
10779 return getNCvx_uchar_longlong(ncp,varp,start,nelems,(long long*)value);
10780 break;
10781 case CASE(NC_UBYTE,NC_UINT):
10782 return getNCvx_uchar_uint(ncp,varp,start,nelems,(unsigned int*)value);
10783 break;
10784 case CASE(NC_UBYTE,NC_UINT64):
10785 return getNCvx_uchar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10786 break;
10787 case CASE(NC_UBYTE,NC_USHORT):
10788 return getNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10789 break;
10790
10791 case CASE(NC_USHORT,NC_BYTE):
10792 return getNCvx_ushort_schar(ncp,varp,start,nelems,(schar*)value);
10793 break;
10794 case CASE(NC_USHORT,NC_UBYTE):
10795 return getNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10796 break;
10797 case CASE(NC_USHORT,NC_SHORT):
10798 return getNCvx_ushort_short(ncp,varp,start,nelems,(short*)value);
10799 break;
10800 case CASE(NC_USHORT,NC_INT):
10801 return getNCvx_ushort_int(ncp,varp,start,nelems,(int*)value);
10802 break;
10803 case CASE(NC_USHORT,NC_FLOAT):
10804 return getNCvx_ushort_float(ncp,varp,start,nelems,(float*)value);
10805 break;
10806 case CASE(NC_USHORT,NC_DOUBLE):
10807 return getNCvx_ushort_double(ncp,varp,start,nelems,(double*)value);
10808 break;
10809 case CASE(NC_USHORT,NC_INT64):
10810 return getNCvx_ushort_longlong(ncp,varp,start,nelems,(long long*)value);
10811 break;
10812 case CASE(NC_USHORT,NC_UINT):
10813 return getNCvx_ushort_uint(ncp,varp,start,nelems,(unsigned int*)value);
10814 break;
10815 case CASE(NC_USHORT,NC_UINT64):
10816 return getNCvx_ushort_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10817 break;
10818 case CASE(NC_USHORT,NC_USHORT):
10819 return getNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10820 break;
10821
10822 case CASE(NC_UINT,NC_BYTE):
10823 return getNCvx_uint_schar(ncp,varp,start,nelems,(schar*)value);
10824 break;
10825 case CASE(NC_UINT,NC_UBYTE):
10826 return getNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10827 break;
10828 case CASE(NC_UINT,NC_SHORT):
10829 return getNCvx_uint_short(ncp,varp,start,nelems,(short*)value);
10830 break;
10831 case CASE(NC_UINT,NC_INT):
10832 return getNCvx_uint_int(ncp,varp,start,nelems,(int*)value);
10833 break;
10834 case CASE(NC_UINT,NC_FLOAT):
10835 return getNCvx_uint_float(ncp,varp,start,nelems,(float*)value);
10836 break;
10837 case CASE(NC_UINT,NC_DOUBLE):
10838 return getNCvx_uint_double(ncp,varp,start,nelems,(double*)value);
10839 break;
10840 case CASE(NC_UINT,NC_INT64):
10841 return getNCvx_uint_longlong(ncp,varp,start,nelems,(long long*)value);
10842 break;
10843 case CASE(NC_UINT,NC_UINT):
10844 return getNCvx_uint_uint(ncp,varp,start,nelems,(unsigned int*)value);
10845 break;
10846 case CASE(NC_UINT,NC_UINT64):
10847 return getNCvx_uint_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10848 break;
10849 case CASE(NC_UINT,NC_USHORT):
10850 return getNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10851 break;
10852
10853 case CASE(NC_INT64,NC_BYTE):
10854 return getNCvx_longlong_schar(ncp,varp,start,nelems,(schar*)value);
10855 break;
10856 case CASE(NC_INT64,NC_UBYTE):
10857 return getNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10858 break;
10859 case CASE(NC_INT64,NC_SHORT):
10860 return getNCvx_longlong_short(ncp,varp,start,nelems,(short*)value);
10861 break;
10862 case CASE(NC_INT64,NC_INT):
10863 return getNCvx_longlong_int(ncp,varp,start,nelems,(int*)value);
10864 break;
10865 case CASE(NC_INT64,NC_FLOAT):
10866 return getNCvx_longlong_float(ncp,varp,start,nelems,(float*)value);
10867 break;
10868 case CASE(NC_INT64,NC_DOUBLE):
10869 return getNCvx_longlong_double(ncp,varp,start,nelems,(double*)value);
10870 break;
10871 case CASE(NC_INT64,NC_INT64):
10872 return getNCvx_longlong_longlong(ncp,varp,start,nelems,(long long*)value);
10873 break;
10874 case CASE(NC_INT64,NC_UINT):
10875 return getNCvx_longlong_uint(ncp,varp,start,nelems,(unsigned int*)value);
10876 break;
10877 case CASE(NC_INT64,NC_UINT64):
10878 return getNCvx_longlong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10879 break;
10880 case CASE(NC_INT64,NC_USHORT):
10881 return getNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10882 break;
10883
10884 case CASE(NC_UINT64,NC_BYTE):
10885 return getNCvx_ulonglong_schar(ncp,varp,start,nelems,(schar*)value);
10886 break;
10887 case CASE(NC_UINT64,NC_UBYTE):
10888 return getNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10889 break;
10890 case CASE(NC_UINT64,NC_SHORT):
10891 return getNCvx_ulonglong_short(ncp,varp,start,nelems,(short*)value);
10892 break;
10893 case CASE(NC_UINT64,NC_INT):
10894 return getNCvx_ulonglong_int(ncp,varp,start,nelems,(int*)value);
10895 break;
10896 case CASE(NC_UINT64,NC_FLOAT):
10897 return getNCvx_ulonglong_float(ncp,varp,start,nelems,(float*)value);
10898 break;
10899 case CASE(NC_UINT64,NC_DOUBLE):
10900 return getNCvx_ulonglong_double(ncp,varp,start,nelems,(double*)value);
10901 break;
10902 case CASE(NC_UINT64,NC_INT64):
10903 return getNCvx_ulonglong_longlong(ncp,varp,start,nelems,(long long*)value);
10904 break;
10905 case CASE(NC_UINT64,NC_UINT):
10906 return getNCvx_ulonglong_uint(ncp,varp,start,nelems,(unsigned int*)value);
10907 break;
10908 case CASE(NC_UINT64,NC_UINT64):
10909 return getNCvx_ulonglong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10910 break;
10911 case CASE(NC_UINT64,NC_USHORT):
10912 return getNCvx_ulonglong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10913 break;
10914
10915 default:
10916 return NC_EBADTYPE;
10917 break;
10918 }
10919 return status;
10920 }
10921
10922
10923 static int
writeNCv(NC3_INFO * ncp,const NC_var * varp,const size_t * start,const size_t nelems,const void * value,const nc_type memtype)10924 writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
10925 const size_t nelems, const void* value, const nc_type memtype)
10926 {
10927 int status = NC_NOERR;
10928 switch (CASE(varp->type,memtype)) {
10929
10930 case CASE(NC_CHAR,NC_CHAR):
10931 case CASE(NC_CHAR,NC_UBYTE):
10932 return putNCvx_char_char(ncp,varp,start,nelems,(char*)value);
10933 break;
10934 case CASE(NC_BYTE,NC_BYTE):
10935 return putNCvx_schar_schar(ncp,varp,start,nelems,(schar*)value);
10936 break;
10937 case CASE(NC_BYTE,NC_UBYTE):
10938 if (fIsSet(ncp->flags,NC_64BIT_DATA))
10939 return putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10940 else
10941 /* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
10942 return putNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10943 break;
10944 case CASE(NC_BYTE,NC_SHORT):
10945 return putNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
10946 break;
10947 case CASE(NC_BYTE,NC_INT):
10948 return putNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
10949 break;
10950 case CASE(NC_BYTE,NC_FLOAT):
10951 return putNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
10952 break;
10953 case CASE(NC_BYTE,NC_DOUBLE):
10954 return putNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
10955 break;
10956 case CASE(NC_BYTE,NC_INT64):
10957 return putNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
10958 break;
10959 case CASE(NC_BYTE,NC_UINT):
10960 return putNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
10961 break;
10962 case CASE(NC_BYTE,NC_UINT64):
10963 return putNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10964 break;
10965 case CASE(NC_BYTE,NC_USHORT):
10966 return putNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10967 break;
10968 case CASE(NC_SHORT,NC_BYTE):
10969 return putNCvx_short_schar(ncp,varp,start,nelems,(schar*)value);
10970 break;
10971 case CASE(NC_SHORT,NC_UBYTE):
10972 return putNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
10973 break;
10974 case CASE(NC_SHORT,NC_SHORT):
10975 return putNCvx_short_short(ncp,varp,start,nelems,(short*)value);
10976 break;
10977 case CASE(NC_SHORT,NC_INT):
10978 return putNCvx_short_int(ncp,varp,start,nelems,(int*)value);
10979 break;
10980 case CASE(NC_SHORT,NC_FLOAT):
10981 return putNCvx_short_float(ncp,varp,start,nelems,(float*)value);
10982 break;
10983 case CASE(NC_SHORT,NC_DOUBLE):
10984 return putNCvx_short_double(ncp,varp,start,nelems,(double*)value);
10985 break;
10986 case CASE(NC_SHORT,NC_INT64):
10987 return putNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
10988 break;
10989 case CASE(NC_SHORT,NC_UINT):
10990 return putNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
10991 break;
10992 case CASE(NC_SHORT,NC_UINT64):
10993 return putNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
10994 break;
10995 case CASE(NC_SHORT,NC_USHORT):
10996 return putNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
10997 break;
10998 case CASE(NC_INT,NC_BYTE):
10999 return putNCvx_int_schar(ncp,varp,start,nelems,(schar*)value);
11000 break;
11001 case CASE(NC_INT,NC_UBYTE):
11002 return putNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11003 break;
11004 case CASE(NC_INT,NC_SHORT):
11005 return putNCvx_int_short(ncp,varp,start,nelems,(short*)value);
11006 break;
11007 case CASE(NC_INT,NC_INT):
11008 return putNCvx_int_int(ncp,varp,start,nelems,(int*)value);
11009 break;
11010 case CASE(NC_INT,NC_FLOAT):
11011 return putNCvx_int_float(ncp,varp,start,nelems,(float*)value);
11012 break;
11013 case CASE(NC_INT,NC_DOUBLE):
11014 return putNCvx_int_double(ncp,varp,start,nelems,(double*)value);
11015 break;
11016 case CASE(NC_INT,NC_INT64):
11017 return putNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
11018 break;
11019 case CASE(NC_INT,NC_UINT):
11020 return putNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
11021 break;
11022 case CASE(NC_INT,NC_UINT64):
11023 return putNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11024 break;
11025 case CASE(NC_INT,NC_USHORT):
11026 return putNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11027 break;
11028 case CASE(NC_FLOAT,NC_BYTE):
11029 return putNCvx_float_schar(ncp,varp,start,nelems,(schar*)value);
11030 break;
11031 case CASE(NC_FLOAT,NC_UBYTE):
11032 return putNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11033 break;
11034 case CASE(NC_FLOAT,NC_SHORT):
11035 return putNCvx_float_short(ncp,varp,start,nelems,(short*)value);
11036 break;
11037 case CASE(NC_FLOAT,NC_INT):
11038 return putNCvx_float_int(ncp,varp,start,nelems,(int*)value);
11039 break;
11040 case CASE(NC_FLOAT,NC_FLOAT):
11041 return putNCvx_float_float(ncp,varp,start,nelems,(float*)value);
11042 break;
11043 case CASE(NC_FLOAT,NC_DOUBLE):
11044 return putNCvx_float_double(ncp,varp,start,nelems,(double*)value);
11045 break;
11046 case CASE(NC_FLOAT,NC_INT64):
11047 return putNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
11048 break;
11049 case CASE(NC_FLOAT,NC_UINT):
11050 return putNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
11051 break;
11052 case CASE(NC_FLOAT,NC_UINT64):
11053 return putNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11054 break;
11055 case CASE(NC_FLOAT,NC_USHORT):
11056 return putNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11057 break;
11058 case CASE(NC_DOUBLE,NC_BYTE):
11059 return putNCvx_double_schar(ncp,varp,start,nelems,(schar*)value);
11060 break;
11061 case CASE(NC_DOUBLE,NC_UBYTE):
11062 return putNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11063 break;
11064 case CASE(NC_DOUBLE,NC_SHORT):
11065 return putNCvx_double_short(ncp,varp,start,nelems,(short*)value);
11066 break;
11067 case CASE(NC_DOUBLE,NC_INT):
11068 return putNCvx_double_int(ncp,varp,start,nelems,(int*)value);
11069 break;
11070 case CASE(NC_DOUBLE,NC_FLOAT):
11071 return putNCvx_double_float(ncp,varp,start,nelems,(float*)value);
11072 break;
11073 case CASE(NC_DOUBLE,NC_DOUBLE):
11074 return putNCvx_double_double(ncp,varp,start,nelems,(double*)value);
11075 break;
11076 case CASE(NC_DOUBLE,NC_INT64):
11077 return putNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
11078 break;
11079 case CASE(NC_DOUBLE,NC_UINT):
11080 return putNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
11081 break;
11082 case CASE(NC_DOUBLE,NC_UINT64):
11083 return putNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11084 break;
11085 case CASE(NC_DOUBLE,NC_USHORT):
11086 return putNCvx_double_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11087 break;
11088 case CASE(NC_UBYTE,NC_UBYTE):
11089 return putNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11090 break;
11091 case CASE(NC_UBYTE,NC_BYTE):
11092 return putNCvx_uchar_schar(ncp,varp,start,nelems,(schar*)value);
11093 break;
11094 case CASE(NC_UBYTE,NC_SHORT):
11095 return putNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
11096 break;
11097 case CASE(NC_UBYTE,NC_INT):
11098 return putNCvx_uchar_int(ncp,varp,start,nelems,(int*)value);
11099 break;
11100 case CASE(NC_UBYTE,NC_FLOAT):
11101 return putNCvx_uchar_float(ncp,varp,start,nelems,(float*)value);
11102 break;
11103 case CASE(NC_UBYTE,NC_DOUBLE):
11104 return putNCvx_uchar_double(ncp,varp,start,nelems,(double *)value);
11105 break;
11106 case CASE(NC_UBYTE,NC_INT64):
11107 return putNCvx_uchar_longlong(ncp,varp,start,nelems,(long long*)value);
11108 break;
11109 case CASE(NC_UBYTE,NC_UINT):
11110 return putNCvx_uchar_uint(ncp,varp,start,nelems,(unsigned int*)value);
11111 break;
11112 case CASE(NC_UBYTE,NC_UINT64):
11113 return putNCvx_uchar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11114 break;
11115 case CASE(NC_UBYTE,NC_USHORT):
11116 return putNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11117 break;
11118 case CASE(NC_USHORT,NC_BYTE):
11119 return putNCvx_ushort_schar(ncp,varp,start,nelems,(schar*)value);
11120 break;
11121 case CASE(NC_USHORT,NC_UBYTE):
11122 return putNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11123 break;
11124 case CASE(NC_USHORT,NC_SHORT):
11125 return putNCvx_ushort_short(ncp,varp,start,nelems,(short*)value);
11126 break;
11127 case CASE(NC_USHORT,NC_INT):
11128 return putNCvx_ushort_int(ncp,varp,start,nelems,(int*)value);
11129 break;
11130 case CASE(NC_USHORT,NC_FLOAT):
11131 return putNCvx_ushort_float(ncp,varp,start,nelems,(float*)value);
11132 break;
11133 case CASE(NC_USHORT,NC_DOUBLE):
11134 return putNCvx_ushort_double(ncp,varp,start,nelems,(double*)value);
11135 break;
11136 case CASE(NC_USHORT,NC_INT64):
11137 return putNCvx_ushort_longlong(ncp,varp,start,nelems,(long long*)value);
11138 break;
11139 case CASE(NC_USHORT,NC_UINT):
11140 return putNCvx_ushort_uint(ncp,varp,start,nelems,(unsigned int*)value);
11141 break;
11142 case CASE(NC_USHORT,NC_UINT64):
11143 return putNCvx_ushort_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11144 break;
11145 case CASE(NC_USHORT,NC_USHORT):
11146 return putNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11147 break;
11148 case CASE(NC_UINT,NC_BYTE):
11149 return putNCvx_uint_schar(ncp,varp,start,nelems,(schar*)value);
11150 break;
11151 case CASE(NC_UINT,NC_UBYTE):
11152 return putNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11153 break;
11154 case CASE(NC_UINT,NC_SHORT):
11155 return putNCvx_uint_short(ncp,varp,start,nelems,(short*)value);
11156 break;
11157 case CASE(NC_UINT,NC_INT):
11158 return putNCvx_uint_int(ncp,varp,start,nelems,(int*)value);
11159 break;
11160 case CASE(NC_UINT,NC_FLOAT):
11161 return putNCvx_uint_float(ncp,varp,start,nelems,(float*)value);
11162 break;
11163 case CASE(NC_UINT,NC_DOUBLE):
11164 return putNCvx_uint_double(ncp,varp,start,nelems,(double*)value);
11165 break;
11166 case CASE(NC_UINT,NC_INT64):
11167 return putNCvx_uint_longlong(ncp,varp,start,nelems,(long long*)value);
11168 break;
11169 case CASE(NC_UINT,NC_UINT):
11170 return putNCvx_uint_uint(ncp,varp,start,nelems,(unsigned int*)value);
11171 break;
11172 case CASE(NC_UINT,NC_UINT64):
11173 return putNCvx_uint_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11174 break;
11175 case CASE(NC_UINT,NC_USHORT):
11176 return putNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11177 break;
11178 case CASE(NC_INT64,NC_BYTE):
11179 return putNCvx_longlong_schar(ncp,varp,start,nelems,(schar*)value);
11180 break;
11181 case CASE(NC_INT64,NC_UBYTE):
11182 return putNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11183 break;
11184 case CASE(NC_INT64,NC_SHORT):
11185 return putNCvx_longlong_short(ncp,varp,start,nelems,(short*)value);
11186 break;
11187 case CASE(NC_INT64,NC_INT):
11188 return putNCvx_longlong_int(ncp,varp,start,nelems,(int*)value);
11189 break;
11190 case CASE(NC_INT64,NC_FLOAT):
11191 return putNCvx_longlong_float(ncp,varp,start,nelems,(float*)value);
11192 break;
11193 case CASE(NC_INT64,NC_DOUBLE):
11194 return putNCvx_longlong_double(ncp,varp,start,nelems,(double*)value);
11195 break;
11196 case CASE(NC_INT64,NC_INT64):
11197 return putNCvx_longlong_longlong(ncp,varp,start,nelems,(long long*)value);
11198 break;
11199 case CASE(NC_INT64,NC_UINT):
11200 return putNCvx_longlong_uint(ncp,varp,start,nelems,(unsigned int*)value);
11201 break;
11202 case CASE(NC_INT64,NC_UINT64):
11203 return putNCvx_longlong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11204 break;
11205 case CASE(NC_INT64,NC_USHORT):
11206 return putNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11207 break;
11208 case CASE(NC_UINT64,NC_BYTE):
11209 return putNCvx_ulonglong_schar(ncp,varp,start,nelems,(schar*)value);
11210 break;
11211 case CASE(NC_UINT64,NC_UBYTE):
11212 return putNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
11213 break;
11214 case CASE(NC_UINT64,NC_SHORT):
11215 return putNCvx_ulonglong_short(ncp,varp,start,nelems,(short*)value);
11216 break;
11217 case CASE(NC_UINT64,NC_INT):
11218 return putNCvx_ulonglong_int(ncp,varp,start,nelems,(int*)value);
11219 break;
11220 case CASE(NC_UINT64,NC_FLOAT):
11221 return putNCvx_ulonglong_float(ncp,varp,start,nelems,(float*)value);
11222 break;
11223 case CASE(NC_UINT64,NC_DOUBLE):
11224 return putNCvx_ulonglong_double(ncp,varp,start,nelems,(double*)value);
11225 break;
11226 case CASE(NC_UINT64,NC_INT64):
11227 return putNCvx_ulonglong_longlong(ncp,varp,start,nelems,(long long*)value);
11228 break;
11229 case CASE(NC_UINT64,NC_UINT):
11230 return putNCvx_ulonglong_uint(ncp,varp,start,nelems,(unsigned int*)value);
11231 break;
11232 case CASE(NC_UINT64,NC_UINT64):
11233 return putNCvx_ulonglong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
11234 break;
11235 case CASE(NC_UINT64,NC_USHORT):
11236 return putNCvx_ulonglong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
11237 break;
11238
11239 default:
11240 return NC_EBADTYPE;
11241 break;
11242 }
11243 return status;
11244 }
11245
11246 /**************************************************/
11247
11248 int
NC3_get_vara(int ncid,int varid,const size_t * start,const size_t * edges0,void * value0,nc_type memtype)11249 NC3_get_vara(int ncid, int varid,
11250 const size_t *start, const size_t *edges0,
11251 void *value0,
11252 nc_type memtype)
11253 {
11254 int status = NC_NOERR;
11255 NC* nc;
11256 NC3_INFO* nc3;
11257 NC_var *varp;
11258 int ii;
11259 size_t iocount;
11260 size_t memtypelen;
11261 signed char* value = (signed char*) value0; /* legally allow ptr arithmetic */
11262 const size_t* edges = edges0; /* so we can modify for special cases */
11263 size_t modedges[NC_MAX_VAR_DIMS];
11264
11265 status = NC_check_id(ncid, &nc);
11266 if(status != NC_NOERR)
11267 return status;
11268 nc3 = NC3_DATA(nc);
11269
11270 if(NC_indef(nc3))
11271 return NC_EINDEFINE;
11272
11273 status = NC_lookupvar(nc3, varid, &varp);
11274 if(status != NC_NOERR)
11275 return status;
11276
11277 if(memtype == NC_NAT) memtype=varp->type;
11278
11279 if(memtype == NC_CHAR && varp->type != NC_CHAR)
11280 return NC_ECHAR;
11281 else if(memtype != NC_CHAR && varp->type == NC_CHAR)
11282 return NC_ECHAR;
11283
11284 /* If edges is NULL, then this was called from nc_get_var() */
11285 if(edges == NULL && varp->ndims > 0) {
11286 /* If this is a record variable, then we have to
11287 substitute the number of records into dimension 0. */
11288 if(varp->shape[0] == 0) {
11289 (void)memcpy((void*)modedges,(void*)varp->shape,
11290 sizeof(size_t)*varp->ndims);
11291 modedges[0] = NC_get_numrecs(nc3);
11292 edges = modedges;
11293 } else
11294 edges = varp->shape;
11295 }
11296
11297 status = NCcoordck(nc3, varp, start);
11298 if(status != NC_NOERR)
11299 return status;
11300
11301 status = NCedgeck(nc3, varp, start, edges);
11302 if(status != NC_NOERR)
11303 return status;
11304
11305 /* Get the size of the memtype */
11306 memtypelen = nctypelen(memtype);
11307
11308 if(varp->ndims == 0) /* scalar variable */
11309 {
11310 return( readNCv(nc3, varp, start, 1, (void*)value, memtype) );
11311 }
11312
11313 if(IS_RECVAR(varp))
11314 {
11315 if(*start + *edges > NC_get_numrecs(nc3))
11316 return NC_EEDGE;
11317 if(varp->ndims == 1 && nc3->recsize <= varp->len)
11318 {
11319 /* one dimensional && the only record variable */
11320 return( readNCv(nc3, varp, start, *edges, (void*)value, memtype) );
11321 }
11322 }
11323
11324 /*
11325 * find max contiguous
11326 * and accumulate max count for a single io operation
11327 */
11328 ii = NCiocount(nc3, varp, edges, &iocount);
11329
11330 if(ii == -1)
11331 {
11332 return( readNCv(nc3, varp, start, iocount, (void*)value, memtype) );
11333 }
11334
11335 assert(ii >= 0);
11336
11337 { /* inline */
11338 ALLOC_ONSTACK(coord, size_t, varp->ndims);
11339 ALLOC_ONSTACK(upper, size_t, varp->ndims);
11340 const size_t index = ii;
11341
11342 /* copy in starting indices */
11343 (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
11344
11345 /* set up in maximum indices */
11346 set_upper(upper, start, edges, &upper[varp->ndims]);
11347
11348 /* ripple counter */
11349 while(*coord < *upper)
11350 {
11351 const int lstatus = readNCv(nc3, varp, coord, iocount, (void*)value, memtype);
11352 if(lstatus != NC_NOERR)
11353 {
11354 if(lstatus != NC_ERANGE)
11355 {
11356 status = lstatus;
11357 /* fatal for the loop */
11358 break;
11359 }
11360 /* else NC_ERANGE, not fatal for the loop */
11361 if(status == NC_NOERR)
11362 status = lstatus;
11363 }
11364 value += (iocount * memtypelen);
11365 odo1(start, upper, coord, &upper[index], &coord[index]);
11366 }
11367
11368 FREE_ONSTACK(upper);
11369 FREE_ONSTACK(coord);
11370 } /* end inline */
11371
11372 return status;
11373 }
11374
11375 int
NC3_put_vara(int ncid,int varid,const size_t * start,const size_t * edges0,const void * value0,nc_type memtype)11376 NC3_put_vara(int ncid, int varid,
11377 const size_t *start, const size_t *edges0,
11378 const void *value0,
11379 nc_type memtype)
11380 {
11381 int status = NC_NOERR;
11382 NC *nc;
11383 NC3_INFO* nc3;
11384 NC_var *varp;
11385 int ii;
11386 size_t iocount;
11387 size_t memtypelen;
11388 signed char* value = (signed char*) value0; /* legally allow ptr arithmetic */
11389 const size_t* edges = edges0; /* so we can modify for special cases */
11390 size_t modedges[NC_MAX_VAR_DIMS];
11391
11392 status = NC_check_id(ncid, &nc);
11393 if(status != NC_NOERR)
11394 return status;
11395 nc3 = NC3_DATA(nc);
11396
11397 if(NC_readonly(nc3))
11398 return NC_EPERM;
11399
11400 if(NC_indef(nc3))
11401 return NC_EINDEFINE;
11402
11403 status = NC_lookupvar(nc3, varid, &varp);
11404 if(status != NC_NOERR)
11405 return status; /*invalid varid */
11406
11407
11408 if(memtype == NC_NAT) memtype=varp->type;
11409
11410 if(memtype == NC_CHAR && varp->type != NC_CHAR)
11411 return NC_ECHAR;
11412 else if(memtype != NC_CHAR && varp->type == NC_CHAR)
11413 return NC_ECHAR;
11414
11415 /* Get the size of the memtype */
11416 memtypelen = nctypelen(memtype);
11417
11418 /* If edges is NULL, then this was called from nc_get_var() */
11419 if(edges == NULL && varp->ndims > 0) {
11420 /* If this is a record variable, then we have to
11421 substitute the number of records into dimension 0. */
11422 if(varp->shape[0] == 0) {
11423 (void)memcpy((void*)modedges,(void*)varp->shape,
11424 sizeof(size_t)*varp->ndims);
11425 modedges[0] = NC_get_numrecs(nc3);
11426 edges = modedges;
11427 } else
11428 edges = varp->shape;
11429 }
11430
11431 status = NCcoordck(nc3, varp, start);
11432 if(status != NC_NOERR)
11433 return status;
11434 status = NCedgeck(nc3, varp, start, edges);
11435 if(status != NC_NOERR)
11436 return status;
11437
11438 if(varp->ndims == 0) /* scalar variable */
11439 {
11440 return( writeNCv(nc3, varp, start, 1, (void*)value, memtype) );
11441 }
11442
11443 if(IS_RECVAR(varp))
11444 {
11445 status = NCvnrecs(nc3, *start + *edges);
11446 if(status != NC_NOERR)
11447 return status;
11448
11449 if(varp->ndims == 1
11450 && nc3->recsize <= varp->len)
11451 {
11452 /* one dimensional && the only record variable */
11453 return( writeNCv(nc3, varp, start, *edges, (void*)value, memtype) );
11454 }
11455 }
11456
11457 /*
11458 * find max contiguous
11459 * and accumulate max count for a single io operation
11460 */
11461 ii = NCiocount(nc3, varp, edges, &iocount);
11462
11463 if(ii == -1)
11464 {
11465 return( writeNCv(nc3, varp, start, iocount, (void*)value, memtype) );
11466 }
11467
11468 assert(ii >= 0);
11469
11470 { /* inline */
11471 ALLOC_ONSTACK(coord, size_t, varp->ndims);
11472 ALLOC_ONSTACK(upper, size_t, varp->ndims);
11473 const size_t index = ii;
11474
11475 /* copy in starting indices */
11476 (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
11477
11478 /* set up in maximum indices */
11479 set_upper(upper, start, edges, &upper[varp->ndims]);
11480
11481 /* ripple counter */
11482 while(*coord < *upper)
11483 {
11484 const int lstatus = writeNCv(nc3, varp, coord, iocount, (void*)value, memtype);
11485 if(lstatus != NC_NOERR)
11486 {
11487 if(lstatus != NC_ERANGE)
11488 {
11489 status = lstatus;
11490 /* fatal for the loop */
11491 break;
11492 }
11493 /* else NC_ERANGE, not fatal for the loop */
11494 if(status == NC_NOERR)
11495 status = lstatus;
11496 }
11497 value += (iocount * memtypelen);
11498 odo1(start, upper, coord, &upper[index], &coord[index]);
11499 }
11500
11501 FREE_ONSTACK(upper);
11502 FREE_ONSTACK(coord);
11503 } /* end inline */
11504
11505 return status;
11506 }
11507