Coverage Report

Created: 2023-05-28 06:42

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