Coverage Report

Created: 2026-08-14 09:29

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