From af4eb0fb1dc3fe7edfbc319966aff8babd393fd1 Mon Sep 17 00:00:00 2001 From: Rob Latham Date: Thu, 4 Dec 2014 09:30:01 -0600 Subject: [PATCH] sync lines for generated C files m4 can emit 'sync lines' which tell the toolchain "hey, this code actually came from this other file over here". Should help prevent anyone accidentally editing a generated file. --- libsrc/Makefile.am | 2 +- libsrc/attr.c | 363 ++- libsrc/ncx.c | 6159 +++++++++++++++++++++++++++++++++++- libsrc/putget.c | 3959 ++++++++++++++++++++++++ nc_test/Makefile.am | 2 +- nc_test/test_get.c | 6233 ++++++++++++++++++++++++++++++++++++- nc_test/test_put.c | 7206 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 23726 insertions(+), 198 deletions(-) diff --git a/libsrc/Makefile.am b/libsrc/Makefile.am index f582953f7..6ef6efcd1 100644 --- a/libsrc/Makefile.am +++ b/libsrc/Makefile.am @@ -43,7 +43,7 @@ EXTRA_DIST = attr.m4 ncx.m4 putget.m4 $(man_MANS) CMakeLists.txt XGetopt.c # This tells make how to turn .m4 files into .c files. .m4.c: - m4 $(AM_M4FLAGS) $(M4FLAGS) $< >$@ + m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >$@ # The C API man page. man_MANS = netcdf.3 diff --git a/libsrc/attr.c b/libsrc/attr.c index 6e7af78d6..96ecf9ca2 100644 --- a/libsrc/attr.c +++ b/libsrc/attr.c @@ -1,4 +1,6 @@ +#line 5 "../../libsrc/attr.m4" /* Do not edit this file. It is produced from the corresponding .m4 source */ +#line 7 /* * Copyright 1996, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. @@ -113,7 +115,7 @@ new_NC_attr( free(name); if(strp == NULL) return NULL; - + attrp = new_x_NC_attr(strp, type, nelems); if(attrp == NULL) { @@ -132,8 +134,7 @@ dup_NC_attr(const NC_attr *rattrp) rattrp->type, rattrp->nelems); if(attrp == NULL) return NULL; - if(attrp->xvalue && rattrp->xvalue) - (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); + (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz); return attrp; } @@ -175,7 +176,7 @@ void free_NC_attrarrayV(NC_attrarray *ncap) { assert(ncap != NULL); - + if(ncap->nalloc == 0) return; @@ -264,7 +265,7 @@ incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp) (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *)); if(vp == NULL) return NC_ENOMEM; - + ncap->value = vp; ncap->nalloc += NC_ARRAY_GROWBY; } @@ -361,7 +362,7 @@ NC_findattr(const NC_attrarray *ncap, const char *uname) /* * Look up by ncid, varid and name, return NULL if not found */ -static int +static int NC_lookupattr(int ncid, int varid, const char *name, /* attribute name */ @@ -423,7 +424,7 @@ NC3_inq_attname(int ncid, int varid, int attnum, char *name) } -int +int NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) { int status; @@ -440,7 +441,7 @@ NC3_inq_attid(int ncid, int varid, const char *name, int *attnump) ncap = NC_attrarray0(ncp, varid); if(ncap == NULL) return NC_ENOTVAR; - + attrpp = NC_findattr(ncap, name); if(attrpp == NULL) @@ -576,7 +577,7 @@ NC3_del_att(int ncid, int varid, const char *uname) char *name = (char *)utf8proc_NFC((const unsigned char *)uname); if(name == NULL) return NC_ENOMEM; - + /* sortof inline NC_findattr() */ slen = strlen(name); @@ -611,367 +612,704 @@ NC3_del_att(int ncid, int varid, const char *uname) return NC_NOERR; } +#line 673 static int +#line 674 ncx_pad_putn_Iuchar(void **xpp, size_t nelems, const uchar *tp, nc_type type) +#line 674 { +#line 674 switch(type) { +#line 674 case NC_CHAR: +#line 674 return NC_ECHAR; +#line 674 case NC_BYTE: +#line 674 return ncx_pad_putn_schar_uchar(xpp, nelems, tp); +#line 674 case NC_SHORT: +#line 674 return ncx_pad_putn_short_uchar(xpp, nelems, tp); +#line 674 case NC_INT: +#line 674 return ncx_putn_int_uchar(xpp, nelems, tp); +#line 674 case NC_FLOAT: +#line 674 return ncx_putn_float_uchar(xpp, nelems, tp); +#line 674 case NC_DOUBLE: +#line 674 return ncx_putn_double_uchar(xpp, nelems, tp); +#line 674 default: +#line 674 assert("ncx_pad_putn_Iuchar invalid type" == 0); +#line 674 } +#line 674 return NC_EBADTYPE; +#line 674 } +#line 674 static int +#line 675 ncx_pad_getn_Iuchar(const void **xpp, size_t nelems, uchar *tp, nc_type type) +#line 675 { +#line 675 switch(type) { +#line 675 case NC_CHAR: +#line 675 return NC_ECHAR; +#line 675 case NC_BYTE: +#line 675 return ncx_pad_getn_schar_uchar(xpp, nelems, tp); +#line 675 case NC_SHORT: +#line 675 return ncx_pad_getn_short_uchar(xpp, nelems, tp); +#line 675 case NC_INT: +#line 675 return ncx_getn_int_uchar(xpp, nelems, tp); +#line 675 case NC_FLOAT: +#line 675 return ncx_getn_float_uchar(xpp, nelems, tp); +#line 675 case NC_DOUBLE: +#line 675 return ncx_getn_double_uchar(xpp, nelems, tp); +#line 675 default: +#line 675 assert("ncx_pad_getn_Iuchar invalid type" == 0); +#line 675 } +#line 675 return NC_EBADTYPE; +#line 675 } +#line 675 static int +#line 677 ncx_pad_putn_Ischar(void **xpp, size_t nelems, const schar *tp, nc_type type) +#line 677 { +#line 677 switch(type) { +#line 677 case NC_CHAR: +#line 677 return NC_ECHAR; +#line 677 case NC_BYTE: +#line 677 return ncx_pad_putn_schar_schar(xpp, nelems, tp); +#line 677 case NC_SHORT: +#line 677 return ncx_pad_putn_short_schar(xpp, nelems, tp); +#line 677 case NC_INT: +#line 677 return ncx_putn_int_schar(xpp, nelems, tp); +#line 677 case NC_FLOAT: +#line 677 return ncx_putn_float_schar(xpp, nelems, tp); +#line 677 case NC_DOUBLE: +#line 677 return ncx_putn_double_schar(xpp, nelems, tp); +#line 677 default: +#line 677 assert("ncx_pad_putn_Ischar invalid type" == 0); +#line 677 } +#line 677 return NC_EBADTYPE; +#line 677 } +#line 677 static int +#line 678 ncx_pad_getn_Ischar(const void **xpp, size_t nelems, schar *tp, nc_type type) +#line 678 { +#line 678 switch(type) { +#line 678 case NC_CHAR: +#line 678 return NC_ECHAR; +#line 678 case NC_BYTE: +#line 678 return ncx_pad_getn_schar_schar(xpp, nelems, tp); +#line 678 case NC_SHORT: +#line 678 return ncx_pad_getn_short_schar(xpp, nelems, tp); +#line 678 case NC_INT: +#line 678 return ncx_getn_int_schar(xpp, nelems, tp); +#line 678 case NC_FLOAT: +#line 678 return ncx_getn_float_schar(xpp, nelems, tp); +#line 678 case NC_DOUBLE: +#line 678 return ncx_getn_double_schar(xpp, nelems, tp); +#line 678 default: +#line 678 assert("ncx_pad_getn_Ischar invalid type" == 0); +#line 678 } +#line 678 return NC_EBADTYPE; +#line 678 } +#line 678 static int +#line 680 ncx_pad_putn_Ishort(void **xpp, size_t nelems, const short *tp, nc_type type) +#line 680 { +#line 680 switch(type) { +#line 680 case NC_CHAR: +#line 680 return NC_ECHAR; +#line 680 case NC_BYTE: +#line 680 return ncx_pad_putn_schar_short(xpp, nelems, tp); +#line 680 case NC_SHORT: +#line 680 return ncx_pad_putn_short_short(xpp, nelems, tp); +#line 680 case NC_INT: +#line 680 return ncx_putn_int_short(xpp, nelems, tp); +#line 680 case NC_FLOAT: +#line 680 return ncx_putn_float_short(xpp, nelems, tp); +#line 680 case NC_DOUBLE: +#line 680 return ncx_putn_double_short(xpp, nelems, tp); +#line 680 default: +#line 680 assert("ncx_pad_putn_Ishort invalid type" == 0); +#line 680 } +#line 680 return NC_EBADTYPE; +#line 680 } +#line 680 static int +#line 681 ncx_pad_getn_Ishort(const void **xpp, size_t nelems, short *tp, nc_type type) +#line 681 { +#line 681 switch(type) { +#line 681 case NC_CHAR: +#line 681 return NC_ECHAR; +#line 681 case NC_BYTE: +#line 681 return ncx_pad_getn_schar_short(xpp, nelems, tp); +#line 681 case NC_SHORT: +#line 681 return ncx_pad_getn_short_short(xpp, nelems, tp); +#line 681 case NC_INT: +#line 681 return ncx_getn_int_short(xpp, nelems, tp); +#line 681 case NC_FLOAT: +#line 681 return ncx_getn_float_short(xpp, nelems, tp); +#line 681 case NC_DOUBLE: +#line 681 return ncx_getn_double_short(xpp, nelems, tp); +#line 681 default: +#line 681 assert("ncx_pad_getn_Ishort invalid type" == 0); +#line 681 } +#line 681 return NC_EBADTYPE; +#line 681 } +#line 681 static int +#line 683 ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type) +#line 683 { +#line 683 switch(type) { +#line 683 case NC_CHAR: +#line 683 return NC_ECHAR; +#line 683 case NC_BYTE: +#line 683 return ncx_pad_putn_schar_int(xpp, nelems, tp); +#line 683 case NC_SHORT: +#line 683 return ncx_pad_putn_short_int(xpp, nelems, tp); +#line 683 case NC_INT: +#line 683 return ncx_putn_int_int(xpp, nelems, tp); +#line 683 case NC_FLOAT: +#line 683 return ncx_putn_float_int(xpp, nelems, tp); +#line 683 case NC_DOUBLE: +#line 683 return ncx_putn_double_int(xpp, nelems, tp); +#line 683 default: +#line 683 assert("ncx_pad_putn_Iint invalid type" == 0); +#line 683 } +#line 683 return NC_EBADTYPE; +#line 683 } +#line 683 static int +#line 684 ncx_pad_getn_Iint(const void **xpp, size_t nelems, int *tp, nc_type type) +#line 684 { +#line 684 switch(type) { +#line 684 case NC_CHAR: +#line 684 return NC_ECHAR; +#line 684 case NC_BYTE: +#line 684 return ncx_pad_getn_schar_int(xpp, nelems, tp); +#line 684 case NC_SHORT: +#line 684 return ncx_pad_getn_short_int(xpp, nelems, tp); +#line 684 case NC_INT: +#line 684 return ncx_getn_int_int(xpp, nelems, tp); +#line 684 case NC_FLOAT: +#line 684 return ncx_getn_float_int(xpp, nelems, tp); +#line 684 case NC_DOUBLE: +#line 684 return ncx_getn_double_int(xpp, nelems, tp); +#line 684 default: +#line 684 assert("ncx_pad_getn_Iint invalid type" == 0); +#line 684 } +#line 684 return NC_EBADTYPE; +#line 684 } +#line 684 static int +#line 686 ncx_pad_putn_Ifloat(void **xpp, size_t nelems, const float *tp, nc_type type) +#line 686 { +#line 686 switch(type) { +#line 686 case NC_CHAR: +#line 686 return NC_ECHAR; +#line 686 case NC_BYTE: +#line 686 return ncx_pad_putn_schar_float(xpp, nelems, tp); +#line 686 case NC_SHORT: +#line 686 return ncx_pad_putn_short_float(xpp, nelems, tp); +#line 686 case NC_INT: +#line 686 return ncx_putn_int_float(xpp, nelems, tp); +#line 686 case NC_FLOAT: +#line 686 return ncx_putn_float_float(xpp, nelems, tp); +#line 686 case NC_DOUBLE: +#line 686 return ncx_putn_double_float(xpp, nelems, tp); +#line 686 default: +#line 686 assert("ncx_pad_putn_Ifloat invalid type" == 0); +#line 686 } +#line 686 return NC_EBADTYPE; +#line 686 } +#line 686 static int +#line 687 ncx_pad_getn_Ifloat(const void **xpp, size_t nelems, float *tp, nc_type type) +#line 687 { +#line 687 switch(type) { +#line 687 case NC_CHAR: +#line 687 return NC_ECHAR; +#line 687 case NC_BYTE: +#line 687 return ncx_pad_getn_schar_float(xpp, nelems, tp); +#line 687 case NC_SHORT: +#line 687 return ncx_pad_getn_short_float(xpp, nelems, tp); +#line 687 case NC_INT: +#line 687 return ncx_getn_int_float(xpp, nelems, tp); +#line 687 case NC_FLOAT: +#line 687 return ncx_getn_float_float(xpp, nelems, tp); +#line 687 case NC_DOUBLE: +#line 687 return ncx_getn_double_float(xpp, nelems, tp); +#line 687 default: +#line 687 assert("ncx_pad_getn_Ifloat invalid type" == 0); +#line 687 } +#line 687 return NC_EBADTYPE; +#line 687 } +#line 687 static int +#line 689 ncx_pad_putn_Idouble(void **xpp, size_t nelems, const double *tp, nc_type type) +#line 689 { +#line 689 switch(type) { +#line 689 case NC_CHAR: +#line 689 return NC_ECHAR; +#line 689 case NC_BYTE: +#line 689 return ncx_pad_putn_schar_double(xpp, nelems, tp); +#line 689 case NC_SHORT: +#line 689 return ncx_pad_putn_short_double(xpp, nelems, tp); +#line 689 case NC_INT: +#line 689 return ncx_putn_int_double(xpp, nelems, tp); +#line 689 case NC_FLOAT: +#line 689 return ncx_putn_float_double(xpp, nelems, tp); +#line 689 case NC_DOUBLE: +#line 689 return ncx_putn_double_double(xpp, nelems, tp); +#line 689 default: +#line 689 assert("ncx_pad_putn_Idouble invalid type" == 0); +#line 689 } +#line 689 return NC_EBADTYPE; +#line 689 } +#line 689 static int +#line 690 ncx_pad_getn_Idouble(const void **xpp, size_t nelems, double *tp, nc_type type) +#line 690 { +#line 690 switch(type) { +#line 690 case NC_CHAR: +#line 690 return NC_ECHAR; +#line 690 case NC_BYTE: +#line 690 return ncx_pad_getn_schar_double(xpp, nelems, tp); +#line 690 case NC_SHORT: +#line 690 return ncx_pad_getn_short_double(xpp, nelems, tp); +#line 690 case NC_INT: +#line 690 return ncx_getn_int_double(xpp, nelems, tp); +#line 690 case NC_FLOAT: +#line 690 return ncx_getn_float_double(xpp, nelems, tp); +#line 690 case NC_DOUBLE: +#line 690 return ncx_getn_double_double(xpp, nelems, tp); +#line 690 default: +#line 690 assert("ncx_pad_getn_Idouble invalid type" == 0); +#line 690 } +#line 690 return NC_EBADTYPE; +#line 690 } +#line 690 #ifdef IGNORE static int +#line 693 ncx_pad_putn_Ilong(void **xpp, size_t nelems, const long *tp, nc_type type) +#line 693 { +#line 693 switch(type) { +#line 693 case NC_CHAR: +#line 693 return NC_ECHAR; +#line 693 case NC_BYTE: +#line 693 return ncx_pad_putn_schar_long(xpp, nelems, tp); +#line 693 case NC_SHORT: +#line 693 return ncx_pad_putn_short_long(xpp, nelems, tp); +#line 693 case NC_INT: +#line 693 return ncx_putn_int_long(xpp, nelems, tp); +#line 693 case NC_FLOAT: +#line 693 return ncx_putn_float_long(xpp, nelems, tp); +#line 693 case NC_DOUBLE: +#line 693 return ncx_putn_double_long(xpp, nelems, tp); +#line 693 default: +#line 693 assert("ncx_pad_putn_Ilong invalid type" == 0); +#line 693 } +#line 693 return NC_EBADTYPE; +#line 693 } +#line 693 static int +#line 694 ncx_pad_getn_Ilong(const void **xpp, size_t nelems, long *tp, nc_type type) +#line 694 { +#line 694 switch(type) { +#line 694 case NC_CHAR: +#line 694 return NC_ECHAR; +#line 694 case NC_BYTE: +#line 694 return ncx_pad_getn_schar_long(xpp, nelems, tp); +#line 694 case NC_SHORT: +#line 694 return ncx_pad_getn_short_long(xpp, nelems, tp); +#line 694 case NC_INT: +#line 694 return ncx_getn_int_long(xpp, nelems, tp); +#line 694 case NC_FLOAT: +#line 694 return ncx_getn_float_long(xpp, nelems, tp); +#line 694 case NC_DOUBLE: +#line 694 return ncx_getn_double_long(xpp, nelems, tp); +#line 694 default: +#line 694 assert("ncx_pad_getn_Ilong invalid type" == 0); +#line 694 } +#line 694 return NC_EBADTYPE; +#line 694 } +#line 694 #endif static int +#line 697 ncx_pad_putn_Ilonglong(void **xpp, size_t nelems, const longlong *tp, nc_type type) +#line 697 { +#line 697 switch(type) { +#line 697 case NC_CHAR: +#line 697 return NC_ECHAR; +#line 697 case NC_BYTE: +#line 697 return ncx_pad_putn_schar_longlong(xpp, nelems, tp); +#line 697 case NC_SHORT: +#line 697 return ncx_pad_putn_short_longlong(xpp, nelems, tp); +#line 697 case NC_INT: +#line 697 return ncx_putn_int_longlong(xpp, nelems, tp); +#line 697 case NC_FLOAT: +#line 697 return ncx_putn_float_longlong(xpp, nelems, tp); +#line 697 case NC_DOUBLE: +#line 697 return ncx_putn_double_longlong(xpp, nelems, tp); +#line 697 default: +#line 697 assert("ncx_pad_putn_Ilonglong invalid type" == 0); +#line 697 } +#line 697 return NC_EBADTYPE; +#line 697 } +#line 697 static int +#line 698 ncx_pad_getn_Ilonglong(const void **xpp, size_t nelems, longlong *tp, nc_type type) +#line 698 { +#line 698 switch(type) { +#line 698 case NC_CHAR: +#line 698 return NC_ECHAR; +#line 698 case NC_BYTE: +#line 698 return ncx_pad_getn_schar_longlong(xpp, nelems, tp); +#line 698 case NC_SHORT: +#line 698 return ncx_pad_getn_short_longlong(xpp, nelems, tp); +#line 698 case NC_INT: +#line 698 return ncx_getn_int_longlong(xpp, nelems, tp); +#line 698 case NC_FLOAT: +#line 698 return ncx_getn_float_longlong(xpp, nelems, tp); +#line 698 case NC_DOUBLE: +#line 698 return ncx_getn_double_longlong(xpp, nelems, tp); +#line 698 default: +#line 698 assert("ncx_pad_getn_Ilonglong invalid type" == 0); +#line 698 } +#line 698 return NC_EBADTYPE; +#line 698 } +#line 698 @@ -1061,10 +1399,10 @@ NC3_put_att( if(!NC_indef(ncp)) { const size_t xsz = ncx_len_NC_attrV(type, nelems); attrp = *attrpp; /* convenience */ - + if(xsz > attrp->xsz) return NC_ENOTINDEFINE; /* else, we can reuse existing without redef */ - + attrp->xsz = xsz; attrp->type = type; attrp->nelems = nelems; @@ -1073,7 +1411,7 @@ NC3_put_att( void *xp = attrp->xvalue; status = dispatchput(&xp, nelems, (const void*)value, type, memtype); } - + set_NC_hdirty(ncp); if(NC_doHsync(ncp)) { @@ -1174,3 +1512,4 @@ NC3_get_att( status = NC_EBADTYPE; return status; } + diff --git a/libsrc/ncx.c b/libsrc/ncx.c index 4453e9b64..efd43104b 100644 --- a/libsrc/ncx.c +++ b/libsrc/ncx.c @@ -1,4 +1,6 @@ +#line 11 "../../libsrc/ncx.m4" /* Do not edit this file. It is produced from the corresponding .m4 source */ +#line 13 /* * Copyright 1996, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. @@ -991,105 +993,196 @@ static struct sgl_limits min = { { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } /* Min IEEE */ }; +#line 1057 static void get_ix_float(const void *xp, float *ip) { struct vax_single *const vsp = (struct vax_single *) ip; +#line 1060 const struct ieee_single *const isp = +#line 1060 (const struct ieee_single *) xp; +#line 1060 unsigned exp = isp->exp_hi << 1 | isp->exp_lo; +#line 1060 +#line 1060 switch(exp) { +#line 1060 case 0 : +#line 1060 /* ieee subnormal */ +#line 1060 if(isp->mant_hi == min.ieee.mant_hi +#line 1060 && isp->mant_lo_hi == min.ieee.mant_lo_hi +#line 1060 && isp->mant_lo_lo == min.ieee.mant_lo_lo) +#line 1060 { +#line 1060 *vsp = min.s; +#line 1060 } +#line 1060 else +#line 1060 { +#line 1060 unsigned mantissa = (isp->mant_hi << 16) +#line 1060 | isp->mant_lo_hi << 8 +#line 1060 | isp->mant_lo_lo; +#line 1060 unsigned tmp = mantissa >> 20; +#line 1060 if(tmp >= 4) { +#line 1060 vsp->exp = 2; +#line 1060 } else if (tmp >= 2) { +#line 1060 vsp->exp = 1; +#line 1060 } else { +#line 1060 *vsp = min.s; +#line 1060 break; +#line 1060 } /* else */ +#line 1060 tmp = mantissa - (1 << (20 + vsp->exp )); +#line 1060 tmp <<= 3 - vsp->exp; +#line 1060 vsp->mantissa2 = tmp; +#line 1060 vsp->mantissa1 = (tmp >> 16); +#line 1060 } +#line 1060 break; +#line 1060 case 0xfe : +#line 1060 case 0xff : +#line 1060 *vsp = max.s; +#line 1060 break; +#line 1060 default : +#line 1060 vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; +#line 1060 vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo; +#line 1060 vsp->mantissa1 = isp->mant_hi; +#line 1060 } +#line 1060 +#line 1060 vsp->sign = isp->sign; +#line 1060 } +#line 1114 static void put_ix_float(void *xp, const float *ip) { const struct vax_single *const vsp = +#line 1118 (const struct vax_single *)ip; +#line 1118 struct ieee_single *const isp = (struct ieee_single *) xp; +#line 1118 +#line 1118 switch(vsp->exp){ +#line 1118 case 0 : +#line 1118 /* all vax float with zero exponent map to zero */ +#line 1118 *isp = min.ieee; +#line 1118 break; +#line 1118 case 2 : +#line 1118 case 1 : +#line 1118 { +#line 1118 /* These will map to subnormals */ +#line 1118 unsigned mantissa = (vsp->mantissa1 << 16) +#line 1118 | vsp->mantissa2; +#line 1118 mantissa >>= 3 - vsp->exp; +#line 1118 mantissa += (1 << (20 + vsp->exp)); +#line 1118 isp->mant_lo_lo = mantissa; +#line 1118 isp->mant_lo_hi = mantissa >> 8; +#line 1118 isp->mant_hi = mantissa >> 16; +#line 1118 isp->exp_lo = 0; +#line 1118 isp->exp_hi = 0; +#line 1118 } +#line 1118 break; +#line 1118 case 0xff : /* max.s.exp */ +#line 1118 if( vsp->mantissa2 == max.s.mantissa2 +#line 1118 && vsp->mantissa1 == max.s.mantissa1) +#line 1118 { +#line 1118 /* map largest vax float to ieee infinity */ +#line 1118 *isp = max.ieee; +#line 1118 break; +#line 1118 } /* else, fall thru */ +#line 1118 default : +#line 1118 { +#line 1118 unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; +#line 1118 isp->exp_hi = exp >> 1; +#line 1118 isp->exp_lo = exp; +#line 1118 isp->mant_lo_lo = vsp->mantissa2; +#line 1118 isp->mant_lo_hi = vsp->mantissa2 >> 8; +#line 1118 isp->mant_hi = vsp->mantissa1; +#line 1118 } +#line 1118 } +#line 1118 +#line 1118 isp->sign = vsp->sign; +#line 1118 } @@ -1149,6 +1242,7 @@ static const int cs_ieis_bias = 0x4000 - 0x7f; static const int cs_id_bias = 0x4000 - 0x3ff; +#line 1253 static void get_ix_float(const void *xp, float *ip) @@ -1158,48 +1252,86 @@ get_ix_float(const void *xp, float *ip) { const ieee_single_hi *isp = (const ieee_single_hi *) xp; cray_single *csp = (cray_single *) ip; +#line 1261 +#line 1261 if(isp->exp == 0) +#line 1261 { +#line 1261 /* ieee subnormal */ +#line 1261 *ip = (double)isp->mant; +#line 1261 if(isp->mant != 0) +#line 1261 { +#line 1261 csp->exp -= (ieee_single_bias + 22); +#line 1261 } +#line 1261 } +#line 1261 else +#line 1261 { +#line 1261 csp->exp = isp->exp + cs_ieis_bias + 1; +#line 1261 csp->mant = isp->mant << (48 - 1 - 23); +#line 1261 csp->mant |= (1 << (48 - 1)); +#line 1261 } +#line 1261 csp->sign = isp->sign; +#line 1261 +#line 1261 } else { const ieee_single_lo *isp = (const ieee_single_lo *) xp; cray_single *csp = (cray_single *) ip; +#line 1266 +#line 1266 if(isp->exp == 0) +#line 1266 { +#line 1266 /* ieee subnormal */ +#line 1266 *ip = (double)isp->mant; +#line 1266 if(isp->mant != 0) +#line 1266 { +#line 1266 csp->exp -= (ieee_single_bias + 22); +#line 1266 } +#line 1266 } +#line 1266 else +#line 1266 { +#line 1266 csp->exp = isp->exp + cs_ieis_bias + 1; +#line 1266 csp->mant = isp->mant << (48 - 1 - 23); +#line 1266 csp->mant |= (1 << (48 - 1)); +#line 1266 } +#line 1266 csp->sign = isp->sign; +#line 1266 +#line 1266 } } @@ -1211,96 +1343,182 @@ put_ix_float(void *xp, const float *ip) { ieee_single_hi *isp = (ieee_single_hi*)xp; const cray_single *csp = (const cray_single *) ip; +#line 1276 int ieee_exp = csp->exp - cs_ieis_bias -1; +#line 1276 +#line 1276 isp->sign = csp->sign; +#line 1276 +#line 1276 if(ieee_exp >= 0xff) +#line 1276 { +#line 1276 /* NC_ERANGE => ieee Inf */ +#line 1276 isp->exp = 0xff; +#line 1276 isp->mant = 0x0; +#line 1276 } +#line 1276 else if(ieee_exp > 0) +#line 1276 { +#line 1276 /* normal ieee representation */ +#line 1276 isp->exp = ieee_exp; +#line 1276 /* assumes cray rep is in normal form */ +#line 1276 assert(csp->mant & 0x800000000000); +#line 1276 isp->mant = (((csp->mant << 1) & +#line 1276 0xffffffffffff) >> (48 - 23)); +#line 1276 } +#line 1276 else if(ieee_exp > -23) +#line 1276 { +#line 1276 /* ieee subnormal, right shift */ +#line 1276 const int rshift = (48 - 23 - ieee_exp); +#line 1276 +#line 1276 isp->mant = csp->mant >> rshift; +#line 1276 +#line 1276 #if 0 +#line 1276 if(csp->mant & (1 << (rshift -1))) +#line 1276 { +#line 1276 /* round up */ +#line 1276 isp->mant++; +#line 1276 } +#line 1276 #endif +#line 1276 +#line 1276 isp->exp = 0; +#line 1276 } +#line 1276 else +#line 1276 { +#line 1276 /* smaller than ieee can represent */ +#line 1276 isp->exp = 0; +#line 1276 isp->mant = 0; +#line 1276 } +#line 1276 } else { ieee_single_lo *isp = (ieee_single_lo*)xp; const cray_single *csp = (const cray_single *) ip; +#line 1281 int ieee_exp = csp->exp - cs_ieis_bias -1; +#line 1281 +#line 1281 isp->sign = csp->sign; +#line 1281 +#line 1281 if(ieee_exp >= 0xff) +#line 1281 { +#line 1281 /* NC_ERANGE => ieee Inf */ +#line 1281 isp->exp = 0xff; +#line 1281 isp->mant = 0x0; +#line 1281 } +#line 1281 else if(ieee_exp > 0) +#line 1281 { +#line 1281 /* normal ieee representation */ +#line 1281 isp->exp = ieee_exp; +#line 1281 /* assumes cray rep is in normal form */ +#line 1281 assert(csp->mant & 0x800000000000); +#line 1281 isp->mant = (((csp->mant << 1) & +#line 1281 0xffffffffffff) >> (48 - 23)); +#line 1281 } +#line 1281 else if(ieee_exp > -23) +#line 1281 { +#line 1281 /* ieee subnormal, right shift */ +#line 1281 const int rshift = (48 - 23 - ieee_exp); +#line 1281 +#line 1281 isp->mant = csp->mant >> rshift; +#line 1281 +#line 1281 #if 0 +#line 1281 if(csp->mant & (1 << (rshift -1))) +#line 1281 { +#line 1281 /* round up */ +#line 1281 isp->mant++; +#line 1281 } +#line 1281 #endif +#line 1281 +#line 1281 isp->exp = 0; +#line 1281 } +#line 1281 else +#line 1281 { +#line 1281 /* smaller than ieee can represent */ +#line 1281 isp->exp = 0; +#line 1281 isp->mant = 0; +#line 1281 } +#line 1281 } } @@ -1633,116 +1851,218 @@ static const struct dbl_limits { }; +#line 1661 static void get_ix_double(const void *xp, double *ip) { struct vax_double *const vdp = +#line 1664 (struct vax_double *)ip; +#line 1664 const struct ieee_double *const idp = +#line 1664 (const struct ieee_double *) xp; +#line 1664 { +#line 1664 const struct dbl_limits *lim; +#line 1664 int ii; +#line 1664 for (ii = 0, lim = dbl_limits; +#line 1664 ii < sizeof(dbl_limits)/sizeof(struct dbl_limits); +#line 1664 ii++, lim++) +#line 1664 { +#line 1664 if ((idp->mant_lo == lim->ieee.mant_lo) +#line 1664 && (idp->mant_4 == lim->ieee.mant_4) +#line 1664 && (idp->mant_5 == lim->ieee.mant_5) +#line 1664 && (idp->mant_6 == lim->ieee.mant_6) +#line 1664 && (idp->exp_lo == lim->ieee.exp_lo) +#line 1664 && (idp->exp_hi == lim->ieee.exp_hi) +#line 1664 ) +#line 1664 { +#line 1664 *vdp = lim->d; +#line 1664 goto doneit; +#line 1664 } +#line 1664 } +#line 1664 } +#line 1664 { +#line 1664 unsigned exp = idp->exp_hi << 4 | idp->exp_lo; +#line 1664 vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; +#line 1664 } +#line 1664 { +#line 1664 unsigned mant_hi = ((idp->mant_6 << 16) +#line 1664 | (idp->mant_5 << 8) +#line 1664 | idp->mant_4); +#line 1664 unsigned mant_lo = SWAP4(idp->mant_lo); +#line 1664 vdp->mantissa1 = (mant_hi >> 13); +#line 1664 vdp->mantissa2 = ((mant_hi & MASK(13)) << 3) +#line 1664 | (mant_lo >> 29); +#line 1664 vdp->mantissa3 = (mant_lo >> 13); +#line 1664 vdp->mantissa4 = (mant_lo << 3); +#line 1664 } +#line 1664 doneit: +#line 1664 vdp->sign = idp->sign; +#line 1664 } +#line 1734 static void put_ix_double(void *xp, const double *ip) { const struct vax_double *const vdp = +#line 1737 (const struct vax_double *)ip; +#line 1737 struct ieee_double *const idp = +#line 1737 (struct ieee_double *) xp; +#line 1737 +#line 1737 if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) && +#line 1737 (vdp->mantissa3 == dbl_limits[0].d.mantissa3) && +#line 1737 (vdp->mantissa2 == dbl_limits[0].d.mantissa2) && +#line 1737 (vdp->mantissa1 == dbl_limits[0].d.mantissa1) && +#line 1737 (vdp->exp == dbl_limits[0].d.exp)) +#line 1737 { +#line 1737 *idp = dbl_limits[0].ieee; +#line 1737 goto shipit; +#line 1737 } +#line 1737 if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) && +#line 1737 (vdp->mantissa3 == dbl_limits[1].d.mantissa3) && +#line 1737 (vdp->mantissa2 == dbl_limits[1].d.mantissa2) && +#line 1737 (vdp->mantissa1 == dbl_limits[1].d.mantissa1) && +#line 1737 (vdp->exp == dbl_limits[1].d.exp)) +#line 1737 { +#line 1737 *idp = dbl_limits[1].ieee; +#line 1737 goto shipit; +#line 1737 } +#line 1737 +#line 1737 { +#line 1737 unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; +#line 1737 +#line 1737 unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) | +#line 1737 (vdp->mantissa3 << 13) | +#line 1737 ((vdp->mantissa4 >> 3) & MASK(13)); +#line 1737 +#line 1737 unsigned mant_hi = (vdp->mantissa1 << 13) +#line 1737 | (vdp->mantissa2 >> 3); +#line 1737 +#line 1737 if((vdp->mantissa4 & 7) > 4) +#line 1737 { +#line 1737 /* round up */ +#line 1737 mant_lo++; +#line 1737 if(mant_lo == 0) +#line 1737 { +#line 1737 mant_hi++; +#line 1737 if(mant_hi > 0xffffff) +#line 1737 { +#line 1737 mant_hi = 0; +#line 1737 exp++; +#line 1737 } +#line 1737 } +#line 1737 } +#line 1737 +#line 1737 idp->mant_lo = SWAP4(mant_lo); +#line 1737 idp->mant_6 = mant_hi >> 16; +#line 1737 idp->mant_5 = (mant_hi & 0xff00) >> 8; +#line 1737 idp->mant_4 = mant_hi; +#line 1737 idp->exp_hi = exp >> 4; +#line 1737 idp->exp_lo = exp; +#line 1737 } +#line 1737 +#line 1737 shipit: +#line 1737 idp->sign = vdp->sign; +#line 1737 } @@ -2184,793 +2504,1505 @@ ncx_get_off_t(const void **xpp, off_t *lp, size_t sizeof_off_t) /* * Aggregate numeric conversion functions. */ +#line 2625 +#line 2632 /* schar */ +#line 2636 int ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp) { (void) memcpy(tp, *xpp, nelems); +#line 2639 *xpp = (void *)((char *)(*xpp) + nelems); +#line 2639 return ENOERR; +#line 2639 } +#line 2642 int ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp) { (void) memcpy(tp, *xpp, nelems); +#line 2645 *xpp = (void *)((char *)(*xpp) + nelems); +#line 2645 return ENOERR; +#line 2645 } int +#line 2647 ncx_getn_schar_short(const void **xpp, size_t nelems, short *tp) +#line 2647 { +#line 2647 schar *xp = (schar *)(*xpp); +#line 2647 +#line 2647 while(nelems-- != 0) +#line 2647 { +#line 2647 *tp++ = *xp++; +#line 2647 } +#line 2647 +#line 2647 *xpp = (const void *)xp; +#line 2647 return ENOERR; +#line 2647 } +#line 2647 int +#line 2648 ncx_getn_schar_int(const void **xpp, size_t nelems, int *tp) +#line 2648 { +#line 2648 schar *xp = (schar *)(*xpp); +#line 2648 +#line 2648 while(nelems-- != 0) +#line 2648 { +#line 2648 *tp++ = *xp++; +#line 2648 } +#line 2648 +#line 2648 *xpp = (const void *)xp; +#line 2648 return ENOERR; +#line 2648 } +#line 2648 int +#line 2649 ncx_getn_schar_float(const void **xpp, size_t nelems, float *tp) +#line 2649 { +#line 2649 schar *xp = (schar *)(*xpp); +#line 2649 +#line 2649 while(nelems-- != 0) +#line 2649 { +#line 2649 *tp++ = *xp++; +#line 2649 } +#line 2649 +#line 2649 *xpp = (const void *)xp; +#line 2649 return ENOERR; +#line 2649 } +#line 2649 int +#line 2650 ncx_getn_schar_double(const void **xpp, size_t nelems, double *tp) +#line 2650 { +#line 2650 schar *xp = (schar *)(*xpp); +#line 2650 +#line 2650 while(nelems-- != 0) +#line 2650 { +#line 2650 *tp++ = *xp++; +#line 2650 } +#line 2650 +#line 2650 *xpp = (const void *)xp; +#line 2650 return ENOERR; +#line 2650 } +#line 2650 int +#line 2651 ncx_getn_schar_uint(const void **xpp, size_t nelems, uint *tp) +#line 2651 { +#line 2651 schar *xp = (schar *)(*xpp); +#line 2651 +#line 2651 while(nelems-- != 0) +#line 2651 { +#line 2651 *tp++ = *xp++; +#line 2651 } +#line 2651 +#line 2651 *xpp = (const void *)xp; +#line 2651 return ENOERR; +#line 2651 } +#line 2651 int +#line 2652 ncx_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2652 { +#line 2652 schar *xp = (schar *)(*xpp); +#line 2652 +#line 2652 while(nelems-- != 0) +#line 2652 { +#line 2652 *tp++ = *xp++; +#line 2652 } +#line 2652 +#line 2652 *xpp = (const void *)xp; +#line 2652 return ENOERR; +#line 2652 } +#line 2652 int +#line 2653 ncx_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2653 { +#line 2653 schar *xp = (schar *)(*xpp); +#line 2653 +#line 2653 while(nelems-- != 0) +#line 2653 { +#line 2653 *tp++ = *xp++; +#line 2653 } +#line 2653 +#line 2653 *xpp = (const void *)xp; +#line 2653 return ENOERR; +#line 2653 } +#line 2653 +#line 2656 int ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *tp) { size_t rndup = nelems % X_ALIGN; +#line 2659 +#line 2659 if(rndup) +#line 2659 rndup = X_ALIGN - rndup; +#line 2659 +#line 2659 (void) memcpy(tp, *xpp, nelems); +#line 2659 *xpp = (void *)((char *)(*xpp) + nelems + rndup); +#line 2659 +#line 2659 return ENOERR; +#line 2659 } +#line 2662 int ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp) { size_t rndup = nelems % X_ALIGN; +#line 2665 +#line 2665 if(rndup) +#line 2665 rndup = X_ALIGN - rndup; +#line 2665 +#line 2665 (void) memcpy(tp, *xpp, nelems); +#line 2665 *xpp = (void *)((char *)(*xpp) + nelems + rndup); +#line 2665 +#line 2665 return ENOERR; +#line 2665 } int +#line 2667 ncx_pad_getn_schar_short(const void **xpp, size_t nelems, short *tp) +#line 2667 { +#line 2667 size_t rndup = nelems % X_ALIGN; +#line 2667 schar *xp = (schar *) *xpp; +#line 2667 +#line 2667 if(rndup) +#line 2667 rndup = X_ALIGN - rndup; +#line 2667 +#line 2667 while(nelems-- != 0) +#line 2667 { +#line 2667 *tp++ = *xp++; +#line 2667 } +#line 2667 +#line 2667 *xpp = (void *)(xp + rndup); +#line 2667 return ENOERR; +#line 2667 } +#line 2667 int +#line 2668 ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp) +#line 2668 { +#line 2668 size_t rndup = nelems % X_ALIGN; +#line 2668 schar *xp = (schar *) *xpp; +#line 2668 +#line 2668 if(rndup) +#line 2668 rndup = X_ALIGN - rndup; +#line 2668 +#line 2668 while(nelems-- != 0) +#line 2668 { +#line 2668 *tp++ = *xp++; +#line 2668 } +#line 2668 +#line 2668 *xpp = (void *)(xp + rndup); +#line 2668 return ENOERR; +#line 2668 } +#line 2668 int +#line 2669 ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp) +#line 2669 { +#line 2669 size_t rndup = nelems % X_ALIGN; +#line 2669 schar *xp = (schar *) *xpp; +#line 2669 +#line 2669 if(rndup) +#line 2669 rndup = X_ALIGN - rndup; +#line 2669 +#line 2669 while(nelems-- != 0) +#line 2669 { +#line 2669 *tp++ = *xp++; +#line 2669 } +#line 2669 +#line 2669 *xpp = (void *)(xp + rndup); +#line 2669 return ENOERR; +#line 2669 } +#line 2669 int +#line 2670 ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp) +#line 2670 { +#line 2670 size_t rndup = nelems % X_ALIGN; +#line 2670 schar *xp = (schar *) *xpp; +#line 2670 +#line 2670 if(rndup) +#line 2670 rndup = X_ALIGN - rndup; +#line 2670 +#line 2670 while(nelems-- != 0) +#line 2670 { +#line 2670 *tp++ = *xp++; +#line 2670 } +#line 2670 +#line 2670 *xpp = (void *)(xp + rndup); +#line 2670 return ENOERR; +#line 2670 } +#line 2670 int +#line 2671 ncx_pad_getn_schar_uint(const void **xpp, size_t nelems, uint *tp) +#line 2671 { +#line 2671 size_t rndup = nelems % X_ALIGN; +#line 2671 schar *xp = (schar *) *xpp; +#line 2671 +#line 2671 if(rndup) +#line 2671 rndup = X_ALIGN - rndup; +#line 2671 +#line 2671 while(nelems-- != 0) +#line 2671 { +#line 2671 *tp++ = *xp++; +#line 2671 } +#line 2671 +#line 2671 *xpp = (void *)(xp + rndup); +#line 2671 return ENOERR; +#line 2671 } +#line 2671 int +#line 2672 ncx_pad_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2672 { +#line 2672 size_t rndup = nelems % X_ALIGN; +#line 2672 schar *xp = (schar *) *xpp; +#line 2672 +#line 2672 if(rndup) +#line 2672 rndup = X_ALIGN - rndup; +#line 2672 +#line 2672 while(nelems-- != 0) +#line 2672 { +#line 2672 *tp++ = *xp++; +#line 2672 } +#line 2672 +#line 2672 *xpp = (void *)(xp + rndup); +#line 2672 return ENOERR; +#line 2672 } +#line 2672 int +#line 2673 ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2673 { +#line 2673 size_t rndup = nelems % X_ALIGN; +#line 2673 schar *xp = (schar *) *xpp; +#line 2673 +#line 2673 if(rndup) +#line 2673 rndup = X_ALIGN - rndup; +#line 2673 +#line 2673 while(nelems-- != 0) +#line 2673 { +#line 2673 *tp++ = *xp++; +#line 2673 } +#line 2673 +#line 2673 *xpp = (void *)(xp + rndup); +#line 2673 return ENOERR; +#line 2673 } +#line 2673 +#line 2676 int ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp) { (void) memcpy(*xpp, tp, nelems); +#line 2679 *xpp = (void *)((char *)(*xpp) + nelems); +#line 2679 +#line 2679 return ENOERR; +#line 2679 } +#line 2682 int ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp) { (void) memcpy(*xpp, tp, nelems); +#line 2685 *xpp = (void *)((char *)(*xpp) + nelems); +#line 2685 +#line 2685 return ENOERR; +#line 2685 } int +#line 2687 ncx_putn_schar_short(void **xpp, size_t nelems, const short *tp) +#line 2687 { +#line 2687 int status = ENOERR; +#line 2687 schar *xp = (schar *) *xpp; +#line 2687 +#line 2687 while(nelems-- != 0) +#line 2687 { +#line 2687 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2687 status = NC_ERANGE; +#line 2687 *xp++ = (schar) *tp++; +#line 2687 } +#line 2687 +#line 2687 *xpp = (void *)xp; +#line 2687 return status; +#line 2687 } +#line 2687 int +#line 2688 ncx_putn_schar_int(void **xpp, size_t nelems, const int *tp) +#line 2688 { +#line 2688 int status = ENOERR; +#line 2688 schar *xp = (schar *) *xpp; +#line 2688 +#line 2688 while(nelems-- != 0) +#line 2688 { +#line 2688 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2688 status = NC_ERANGE; +#line 2688 *xp++ = (schar) *tp++; +#line 2688 } +#line 2688 +#line 2688 *xpp = (void *)xp; +#line 2688 return status; +#line 2688 } +#line 2688 int +#line 2689 ncx_putn_schar_float(void **xpp, size_t nelems, const float *tp) +#line 2689 { +#line 2689 int status = ENOERR; +#line 2689 schar *xp = (schar *) *xpp; +#line 2689 +#line 2689 while(nelems-- != 0) +#line 2689 { +#line 2689 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2689 status = NC_ERANGE; +#line 2689 *xp++ = (schar) *tp++; +#line 2689 } +#line 2689 +#line 2689 *xpp = (void *)xp; +#line 2689 return status; +#line 2689 } +#line 2689 int +#line 2690 ncx_putn_schar_double(void **xpp, size_t nelems, const double *tp) +#line 2690 { +#line 2690 int status = ENOERR; +#line 2690 schar *xp = (schar *) *xpp; +#line 2690 +#line 2690 while(nelems-- != 0) +#line 2690 { +#line 2690 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2690 status = NC_ERANGE; +#line 2690 *xp++ = (schar) *tp++; +#line 2690 } +#line 2690 +#line 2690 *xpp = (void *)xp; +#line 2690 return status; +#line 2690 } +#line 2690 int +#line 2691 ncx_putn_schar_uint(void **xpp, size_t nelems, const uint *tp) +#line 2691 { +#line 2691 int status = ENOERR; +#line 2691 schar *xp = (schar *) *xpp; +#line 2691 +#line 2691 while(nelems-- != 0) +#line 2691 { +#line 2691 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2691 status = NC_ERANGE; +#line 2691 *xp++ = (schar) *tp++; +#line 2691 } +#line 2691 +#line 2691 *xpp = (void *)xp; +#line 2691 return status; +#line 2691 } +#line 2691 int +#line 2692 ncx_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 2692 { +#line 2692 int status = ENOERR; +#line 2692 schar *xp = (schar *) *xpp; +#line 2692 +#line 2692 while(nelems-- != 0) +#line 2692 { +#line 2692 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2692 status = NC_ERANGE; +#line 2692 *xp++ = (schar) *tp++; +#line 2692 } +#line 2692 +#line 2692 *xpp = (void *)xp; +#line 2692 return status; +#line 2692 } +#line 2692 int +#line 2693 ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 2693 { +#line 2693 int status = ENOERR; +#line 2693 schar *xp = (schar *) *xpp; +#line 2693 +#line 2693 while(nelems-- != 0) +#line 2693 { +#line 2693 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2693 status = NC_ERANGE; +#line 2693 *xp++ = (schar) *tp++; +#line 2693 } +#line 2693 +#line 2693 *xpp = (void *)xp; +#line 2693 return status; +#line 2693 } +#line 2693 +#line 2696 int ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp) { size_t rndup = nelems % X_ALIGN; +#line 2699 +#line 2699 if(rndup) +#line 2699 rndup = X_ALIGN - rndup; +#line 2699 +#line 2699 (void) memcpy(*xpp, tp, nelems); +#line 2699 *xpp = (void *)((char *)(*xpp) + nelems); +#line 2699 +#line 2699 if(rndup) +#line 2699 { +#line 2699 (void) memcpy(*xpp, nada, rndup); +#line 2699 *xpp = (void *)((char *)(*xpp) + rndup); +#line 2699 } +#line 2699 +#line 2699 return ENOERR; +#line 2699 } +#line 2702 int ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp) { size_t rndup = nelems % X_ALIGN; +#line 2705 +#line 2705 if(rndup) +#line 2705 rndup = X_ALIGN - rndup; +#line 2705 +#line 2705 (void) memcpy(*xpp, tp, nelems); +#line 2705 *xpp = (void *)((char *)(*xpp) + nelems); +#line 2705 +#line 2705 if(rndup) +#line 2705 { +#line 2705 (void) memcpy(*xpp, nada, rndup); +#line 2705 *xpp = (void *)((char *)(*xpp) + rndup); +#line 2705 } +#line 2705 +#line 2705 return ENOERR; +#line 2705 } int +#line 2707 ncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *tp) +#line 2707 { +#line 2707 int status = ENOERR; +#line 2707 size_t rndup = nelems % X_ALIGN; +#line 2707 schar *xp = (schar *) *xpp; +#line 2707 +#line 2707 if(rndup) +#line 2707 rndup = X_ALIGN - rndup; +#line 2707 +#line 2707 while(nelems-- != 0) +#line 2707 { +#line 2707 /* N.B. schar as signed */ +#line 2707 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2707 status = NC_ERANGE; +#line 2707 *xp++ = (schar) *tp++; +#line 2707 } +#line 2707 +#line 2707 +#line 2707 if(rndup) +#line 2707 { +#line 2707 (void) memcpy(xp, nada, rndup); +#line 2707 xp += rndup; +#line 2707 } +#line 2707 +#line 2707 *xpp = (void *)xp; +#line 2707 return status; +#line 2707 } +#line 2707 int +#line 2708 ncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *tp) +#line 2708 { +#line 2708 int status = ENOERR; +#line 2708 size_t rndup = nelems % X_ALIGN; +#line 2708 schar *xp = (schar *) *xpp; +#line 2708 +#line 2708 if(rndup) +#line 2708 rndup = X_ALIGN - rndup; +#line 2708 +#line 2708 while(nelems-- != 0) +#line 2708 { +#line 2708 /* N.B. schar as signed */ +#line 2708 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2708 status = NC_ERANGE; +#line 2708 *xp++ = (schar) *tp++; +#line 2708 } +#line 2708 +#line 2708 +#line 2708 if(rndup) +#line 2708 { +#line 2708 (void) memcpy(xp, nada, rndup); +#line 2708 xp += rndup; +#line 2708 } +#line 2708 +#line 2708 *xpp = (void *)xp; +#line 2708 return status; +#line 2708 } +#line 2708 int +#line 2709 ncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *tp) +#line 2709 { +#line 2709 int status = ENOERR; +#line 2709 size_t rndup = nelems % X_ALIGN; +#line 2709 schar *xp = (schar *) *xpp; +#line 2709 +#line 2709 if(rndup) +#line 2709 rndup = X_ALIGN - rndup; +#line 2709 +#line 2709 while(nelems-- != 0) +#line 2709 { +#line 2709 /* N.B. schar as signed */ +#line 2709 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2709 status = NC_ERANGE; +#line 2709 *xp++ = (schar) *tp++; +#line 2709 } +#line 2709 +#line 2709 +#line 2709 if(rndup) +#line 2709 { +#line 2709 (void) memcpy(xp, nada, rndup); +#line 2709 xp += rndup; +#line 2709 } +#line 2709 +#line 2709 *xpp = (void *)xp; +#line 2709 return status; +#line 2709 } +#line 2709 int +#line 2710 ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *tp) +#line 2710 { +#line 2710 int status = ENOERR; +#line 2710 size_t rndup = nelems % X_ALIGN; +#line 2710 schar *xp = (schar *) *xpp; +#line 2710 +#line 2710 if(rndup) +#line 2710 rndup = X_ALIGN - rndup; +#line 2710 +#line 2710 while(nelems-- != 0) +#line 2710 { +#line 2710 /* N.B. schar as signed */ +#line 2710 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2710 status = NC_ERANGE; +#line 2710 *xp++ = (schar) *tp++; +#line 2710 } +#line 2710 +#line 2710 +#line 2710 if(rndup) +#line 2710 { +#line 2710 (void) memcpy(xp, nada, rndup); +#line 2710 xp += rndup; +#line 2710 } +#line 2710 +#line 2710 *xpp = (void *)xp; +#line 2710 return status; +#line 2710 } +#line 2710 int +#line 2711 ncx_pad_putn_schar_uint(void **xpp, size_t nelems, const uint *tp) +#line 2711 { +#line 2711 int status = ENOERR; +#line 2711 size_t rndup = nelems % X_ALIGN; +#line 2711 schar *xp = (schar *) *xpp; +#line 2711 +#line 2711 if(rndup) +#line 2711 rndup = X_ALIGN - rndup; +#line 2711 +#line 2711 while(nelems-- != 0) +#line 2711 { +#line 2711 /* N.B. schar as signed */ +#line 2711 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2711 status = NC_ERANGE; +#line 2711 *xp++ = (schar) *tp++; +#line 2711 } +#line 2711 +#line 2711 +#line 2711 if(rndup) +#line 2711 { +#line 2711 (void) memcpy(xp, nada, rndup); +#line 2711 xp += rndup; +#line 2711 } +#line 2711 +#line 2711 *xpp = (void *)xp; +#line 2711 return status; +#line 2711 } +#line 2711 int +#line 2712 ncx_pad_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 2712 { +#line 2712 int status = ENOERR; +#line 2712 size_t rndup = nelems % X_ALIGN; +#line 2712 schar *xp = (schar *) *xpp; +#line 2712 +#line 2712 if(rndup) +#line 2712 rndup = X_ALIGN - rndup; +#line 2712 +#line 2712 while(nelems-- != 0) +#line 2712 { +#line 2712 /* N.B. schar as signed */ +#line 2712 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2712 status = NC_ERANGE; +#line 2712 *xp++ = (schar) *tp++; +#line 2712 } +#line 2712 +#line 2712 +#line 2712 if(rndup) +#line 2712 { +#line 2712 (void) memcpy(xp, nada, rndup); +#line 2712 xp += rndup; +#line 2712 } +#line 2712 +#line 2712 *xpp = (void *)xp; +#line 2712 return status; +#line 2712 } +#line 2712 int +#line 2713 ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 2713 { +#line 2713 int status = ENOERR; +#line 2713 size_t rndup = nelems % X_ALIGN; +#line 2713 schar *xp = (schar *) *xpp; +#line 2713 +#line 2713 if(rndup) +#line 2713 rndup = X_ALIGN - rndup; +#line 2713 +#line 2713 while(nelems-- != 0) +#line 2713 { +#line 2713 /* N.B. schar as signed */ +#line 2713 if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) +#line 2713 status = NC_ERANGE; +#line 2713 *xp++ = (schar) *tp++; +#line 2713 } +#line 2713 +#line 2713 +#line 2713 if(rndup) +#line 2713 { +#line 2713 (void) memcpy(xp, nada, rndup); +#line 2713 xp += rndup; +#line 2713 } +#line 2713 +#line 2713 *xpp = (void *)xp; +#line 2713 return status; +#line 2713 } +#line 2713 /* short */ int +#line 2718 ncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp) +#line 2718 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2718 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2718 +#line 2718 /* basic algorithm is: +#line 2718 * - ensure sane alignment of input data +#line 2718 * - copy (conversion happens automatically) input data +#line 2718 * to output +#line 2718 * - update xpp to point at next unconverted input, and tp to point +#line 2718 * at next location for converted output +#line 2718 */ +#line 2718 long i, j, ni; +#line 2718 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2718 short *xp; +#line 2718 int nrange = 0; /* number of range errors */ +#line 2718 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2718 long cxp = (long) *((char**)xpp); +#line 2718 +#line 2718 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2718 /* sjl: manually stripmine so we can limit amount of +#line 2718 * vector work space reserved to LOOPCNT elements. Also +#line 2718 * makes vectorisation easy */ +#line 2718 for (j=0; j SCHAR_MAX; +#line 2718 } +#line 2718 /* update xpp and tp */ +#line 2718 if (realign) xp = (short *) *xpp; +#line 2718 xp += ni; +#line 2718 tp += ni; +#line 2718 *xpp = (void*)xp; +#line 2718 } +#line 2718 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2718 +#line 2718 #else /* not SX */ +#line 2718 const char *xp = (const char *) *xpp; +#line 2718 int status = ENOERR; +#line 2718 +#line 2718 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2718 { +#line 2718 const int lstatus = ncx_get_short_schar(xp, tp); +#line 2718 if(lstatus != ENOERR) +#line 2718 status = lstatus; +#line 2718 } +#line 2718 +#line 2718 *xpp = (const void *)xp; +#line 2718 return status; +#line 2718 # endif +#line 2718 } +#line 2718 int +#line 2719 ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp) +#line 2719 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2719 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2719 +#line 2719 /* basic algorithm is: +#line 2719 * - ensure sane alignment of input data +#line 2719 * - copy (conversion happens automatically) input data +#line 2719 * to output +#line 2719 * - update xpp to point at next unconverted input, and tp to point +#line 2719 * at next location for converted output +#line 2719 */ +#line 2719 long i, j, ni; +#line 2719 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2719 short *xp; +#line 2719 int nrange = 0; /* number of range errors */ +#line 2719 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2719 long cxp = (long) *((char**)xpp); +#line 2719 +#line 2719 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2719 /* sjl: manually stripmine so we can limit amount of +#line 2719 * vector work space reserved to LOOPCNT elements. Also +#line 2719 * makes vectorisation easy */ +#line 2719 for (j=0; j UCHAR_MAX; +#line 2719 } +#line 2719 /* update xpp and tp */ +#line 2719 if (realign) xp = (short *) *xpp; +#line 2719 xp += ni; +#line 2719 tp += ni; +#line 2719 *xpp = (void*)xp; +#line 2719 } +#line 2719 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2719 +#line 2719 #else /* not SX */ +#line 2719 const char *xp = (const char *) *xpp; +#line 2719 int status = ENOERR; +#line 2719 +#line 2719 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2719 { +#line 2719 const int lstatus = ncx_get_short_uchar(xp, tp); +#line 2719 if(lstatus != ENOERR) +#line 2719 status = lstatus; +#line 2719 } +#line 2719 +#line 2719 *xpp = (const void *)xp; +#line 2719 return status; +#line 2719 # endif +#line 2719 } +#line 2719 #if X_SIZEOF_SHORT == SIZEOF_SHORT /* optimized version */ @@ -2987,791 +4019,1539 @@ ncx_getn_short_short(const void **xpp, size_t nelems, short *tp) } #else int +#line 2734 ncx_getn_short_short(const void **xpp, size_t nelems, short *tp) +#line 2734 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2734 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2734 +#line 2734 /* basic algorithm is: +#line 2734 * - ensure sane alignment of input data +#line 2734 * - copy (conversion happens automatically) input data +#line 2734 * to output +#line 2734 * - update xpp to point at next unconverted input, and tp to point +#line 2734 * at next location for converted output +#line 2734 */ +#line 2734 long i, j, ni; +#line 2734 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2734 short *xp; +#line 2734 int nrange = 0; /* number of range errors */ +#line 2734 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2734 long cxp = (long) *((char**)xpp); +#line 2734 +#line 2734 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2734 /* sjl: manually stripmine so we can limit amount of +#line 2734 * vector work space reserved to LOOPCNT elements. Also +#line 2734 * makes vectorisation easy */ +#line 2734 for (j=0; j SHORT_MAX; +#line 2734 } +#line 2734 /* update xpp and tp */ +#line 2734 if (realign) xp = (short *) *xpp; +#line 2734 xp += ni; +#line 2734 tp += ni; +#line 2734 *xpp = (void*)xp; +#line 2734 } +#line 2734 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2734 +#line 2734 #else /* not SX */ +#line 2734 const char *xp = (const char *) *xpp; +#line 2734 int status = ENOERR; +#line 2734 +#line 2734 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2734 { +#line 2734 const int lstatus = ncx_get_short_short(xp, tp); +#line 2734 if(lstatus != ENOERR) +#line 2734 status = lstatus; +#line 2734 } +#line 2734 +#line 2734 *xpp = (const void *)xp; +#line 2734 return status; +#line 2734 # endif +#line 2734 } +#line 2734 #endif int +#line 2736 ncx_getn_short_int(const void **xpp, size_t nelems, int *tp) +#line 2736 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2736 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2736 +#line 2736 /* basic algorithm is: +#line 2736 * - ensure sane alignment of input data +#line 2736 * - copy (conversion happens automatically) input data +#line 2736 * to output +#line 2736 * - update xpp to point at next unconverted input, and tp to point +#line 2736 * at next location for converted output +#line 2736 */ +#line 2736 long i, j, ni; +#line 2736 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2736 short *xp; +#line 2736 int nrange = 0; /* number of range errors */ +#line 2736 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2736 long cxp = (long) *((char**)xpp); +#line 2736 +#line 2736 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2736 /* sjl: manually stripmine so we can limit amount of +#line 2736 * vector work space reserved to LOOPCNT elements. Also +#line 2736 * makes vectorisation easy */ +#line 2736 for (j=0; j INT_MAX; +#line 2736 } +#line 2736 /* update xpp and tp */ +#line 2736 if (realign) xp = (short *) *xpp; +#line 2736 xp += ni; +#line 2736 tp += ni; +#line 2736 *xpp = (void*)xp; +#line 2736 } +#line 2736 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2736 +#line 2736 #else /* not SX */ +#line 2736 const char *xp = (const char *) *xpp; +#line 2736 int status = ENOERR; +#line 2736 +#line 2736 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2736 { +#line 2736 const int lstatus = ncx_get_short_int(xp, tp); +#line 2736 if(lstatus != ENOERR) +#line 2736 status = lstatus; +#line 2736 } +#line 2736 +#line 2736 *xpp = (const void *)xp; +#line 2736 return status; +#line 2736 # endif +#line 2736 } +#line 2736 int +#line 2737 ncx_getn_short_float(const void **xpp, size_t nelems, float *tp) +#line 2737 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2737 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2737 +#line 2737 /* basic algorithm is: +#line 2737 * - ensure sane alignment of input data +#line 2737 * - copy (conversion happens automatically) input data +#line 2737 * to output +#line 2737 * - update xpp to point at next unconverted input, and tp to point +#line 2737 * at next location for converted output +#line 2737 */ +#line 2737 long i, j, ni; +#line 2737 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2737 short *xp; +#line 2737 int nrange = 0; /* number of range errors */ +#line 2737 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2737 long cxp = (long) *((char**)xpp); +#line 2737 +#line 2737 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2737 /* sjl: manually stripmine so we can limit amount of +#line 2737 * vector work space reserved to LOOPCNT elements. Also +#line 2737 * makes vectorisation easy */ +#line 2737 for (j=0; j FLOAT_MAX; +#line 2737 } +#line 2737 /* update xpp and tp */ +#line 2737 if (realign) xp = (short *) *xpp; +#line 2737 xp += ni; +#line 2737 tp += ni; +#line 2737 *xpp = (void*)xp; +#line 2737 } +#line 2737 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2737 +#line 2737 #else /* not SX */ +#line 2737 const char *xp = (const char *) *xpp; +#line 2737 int status = ENOERR; +#line 2737 +#line 2737 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2737 { +#line 2737 const int lstatus = ncx_get_short_float(xp, tp); +#line 2737 if(lstatus != ENOERR) +#line 2737 status = lstatus; +#line 2737 } +#line 2737 +#line 2737 *xpp = (const void *)xp; +#line 2737 return status; +#line 2737 # endif +#line 2737 } +#line 2737 int +#line 2738 ncx_getn_short_double(const void **xpp, size_t nelems, double *tp) +#line 2738 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2738 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2738 +#line 2738 /* basic algorithm is: +#line 2738 * - ensure sane alignment of input data +#line 2738 * - copy (conversion happens automatically) input data +#line 2738 * to output +#line 2738 * - update xpp to point at next unconverted input, and tp to point +#line 2738 * at next location for converted output +#line 2738 */ +#line 2738 long i, j, ni; +#line 2738 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2738 short *xp; +#line 2738 int nrange = 0; /* number of range errors */ +#line 2738 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2738 long cxp = (long) *((char**)xpp); +#line 2738 +#line 2738 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2738 /* sjl: manually stripmine so we can limit amount of +#line 2738 * vector work space reserved to LOOPCNT elements. Also +#line 2738 * makes vectorisation easy */ +#line 2738 for (j=0; j DOUBLE_MAX; +#line 2738 } +#line 2738 /* update xpp and tp */ +#line 2738 if (realign) xp = (short *) *xpp; +#line 2738 xp += ni; +#line 2738 tp += ni; +#line 2738 *xpp = (void*)xp; +#line 2738 } +#line 2738 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2738 +#line 2738 #else /* not SX */ +#line 2738 const char *xp = (const char *) *xpp; +#line 2738 int status = ENOERR; +#line 2738 +#line 2738 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2738 { +#line 2738 const int lstatus = ncx_get_short_double(xp, tp); +#line 2738 if(lstatus != ENOERR) +#line 2738 status = lstatus; +#line 2738 } +#line 2738 +#line 2738 *xpp = (const void *)xp; +#line 2738 return status; +#line 2738 # endif +#line 2738 } +#line 2738 int +#line 2739 ncx_getn_short_uint(const void **xpp, size_t nelems, uint *tp) +#line 2739 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2739 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2739 +#line 2739 /* basic algorithm is: +#line 2739 * - ensure sane alignment of input data +#line 2739 * - copy (conversion happens automatically) input data +#line 2739 * to output +#line 2739 * - update xpp to point at next unconverted input, and tp to point +#line 2739 * at next location for converted output +#line 2739 */ +#line 2739 long i, j, ni; +#line 2739 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2739 short *xp; +#line 2739 int nrange = 0; /* number of range errors */ +#line 2739 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2739 long cxp = (long) *((char**)xpp); +#line 2739 +#line 2739 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2739 /* sjl: manually stripmine so we can limit amount of +#line 2739 * vector work space reserved to LOOPCNT elements. Also +#line 2739 * makes vectorisation easy */ +#line 2739 for (j=0; j UINT_MAX; +#line 2739 } +#line 2739 /* update xpp and tp */ +#line 2739 if (realign) xp = (short *) *xpp; +#line 2739 xp += ni; +#line 2739 tp += ni; +#line 2739 *xpp = (void*)xp; +#line 2739 } +#line 2739 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2739 +#line 2739 #else /* not SX */ +#line 2739 const char *xp = (const char *) *xpp; +#line 2739 int status = ENOERR; +#line 2739 +#line 2739 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2739 { +#line 2739 const int lstatus = ncx_get_short_uint(xp, tp); +#line 2739 if(lstatus != ENOERR) +#line 2739 status = lstatus; +#line 2739 } +#line 2739 +#line 2739 *xpp = (const void *)xp; +#line 2739 return status; +#line 2739 # endif +#line 2739 } +#line 2739 int +#line 2740 ncx_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2740 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2740 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2740 +#line 2740 /* basic algorithm is: +#line 2740 * - ensure sane alignment of input data +#line 2740 * - copy (conversion happens automatically) input data +#line 2740 * to output +#line 2740 * - update xpp to point at next unconverted input, and tp to point +#line 2740 * at next location for converted output +#line 2740 */ +#line 2740 long i, j, ni; +#line 2740 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2740 short *xp; +#line 2740 int nrange = 0; /* number of range errors */ +#line 2740 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2740 long cxp = (long) *((char**)xpp); +#line 2740 +#line 2740 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2740 /* sjl: manually stripmine so we can limit amount of +#line 2740 * vector work space reserved to LOOPCNT elements. Also +#line 2740 * makes vectorisation easy */ +#line 2740 for (j=0; j LONGLONG_MAX; +#line 2740 } +#line 2740 /* update xpp and tp */ +#line 2740 if (realign) xp = (short *) *xpp; +#line 2740 xp += ni; +#line 2740 tp += ni; +#line 2740 *xpp = (void*)xp; +#line 2740 } +#line 2740 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2740 +#line 2740 #else /* not SX */ +#line 2740 const char *xp = (const char *) *xpp; +#line 2740 int status = ENOERR; +#line 2740 +#line 2740 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2740 { +#line 2740 const int lstatus = ncx_get_short_longlong(xp, tp); +#line 2740 if(lstatus != ENOERR) +#line 2740 status = lstatus; +#line 2740 } +#line 2740 +#line 2740 *xpp = (const void *)xp; +#line 2740 return status; +#line 2740 # endif +#line 2740 } +#line 2740 int +#line 2741 ncx_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2741 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2741 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2741 +#line 2741 /* basic algorithm is: +#line 2741 * - ensure sane alignment of input data +#line 2741 * - copy (conversion happens automatically) input data +#line 2741 * to output +#line 2741 * - update xpp to point at next unconverted input, and tp to point +#line 2741 * at next location for converted output +#line 2741 */ +#line 2741 long i, j, ni; +#line 2741 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2741 short *xp; +#line 2741 int nrange = 0; /* number of range errors */ +#line 2741 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2741 long cxp = (long) *((char**)xpp); +#line 2741 +#line 2741 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2741 /* sjl: manually stripmine so we can limit amount of +#line 2741 * vector work space reserved to LOOPCNT elements. Also +#line 2741 * makes vectorisation easy */ +#line 2741 for (j=0; j ULONGLONG_MAX; +#line 2741 } +#line 2741 /* update xpp and tp */ +#line 2741 if (realign) xp = (short *) *xpp; +#line 2741 xp += ni; +#line 2741 tp += ni; +#line 2741 *xpp = (void*)xp; +#line 2741 } +#line 2741 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2741 +#line 2741 #else /* not SX */ +#line 2741 const char *xp = (const char *) *xpp; +#line 2741 int status = ENOERR; +#line 2741 +#line 2741 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2741 { +#line 2741 const int lstatus = ncx_get_short_ulonglong(xp, tp); +#line 2741 if(lstatus != ENOERR) +#line 2741 status = lstatus; +#line 2741 } +#line 2741 +#line 2741 *xpp = (const void *)xp; +#line 2741 return status; +#line 2741 # endif +#line 2741 } +#line 2741 int +#line 2743 ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp) +#line 2743 { +#line 2743 const size_t rndup = nelems % 2; +#line 2743 +#line 2743 const char *xp = (const char *) *xpp; +#line 2743 int status = ENOERR; +#line 2743 +#line 2743 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2743 { +#line 2743 const int lstatus = ncx_get_short_schar(xp, tp); +#line 2743 if(lstatus != ENOERR) +#line 2743 status = lstatus; +#line 2743 } +#line 2743 +#line 2743 if(rndup != 0) +#line 2743 xp += X_SIZEOF_SHORT; +#line 2743 +#line 2743 *xpp = (void *)xp; +#line 2743 return status; +#line 2743 } +#line 2743 int +#line 2744 ncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp) +#line 2744 { +#line 2744 const size_t rndup = nelems % 2; +#line 2744 +#line 2744 const char *xp = (const char *) *xpp; +#line 2744 int status = ENOERR; +#line 2744 +#line 2744 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2744 { +#line 2744 const int lstatus = ncx_get_short_uchar(xp, tp); +#line 2744 if(lstatus != ENOERR) +#line 2744 status = lstatus; +#line 2744 } +#line 2744 +#line 2744 if(rndup != 0) +#line 2744 xp += X_SIZEOF_SHORT; +#line 2744 +#line 2744 *xpp = (void *)xp; +#line 2744 return status; +#line 2744 } +#line 2744 int +#line 2745 ncx_pad_getn_short_short(const void **xpp, size_t nelems, short *tp) +#line 2745 { +#line 2745 const size_t rndup = nelems % 2; +#line 2745 +#line 2745 const char *xp = (const char *) *xpp; +#line 2745 int status = ENOERR; +#line 2745 +#line 2745 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2745 { +#line 2745 const int lstatus = ncx_get_short_short(xp, tp); +#line 2745 if(lstatus != ENOERR) +#line 2745 status = lstatus; +#line 2745 } +#line 2745 +#line 2745 if(rndup != 0) +#line 2745 xp += X_SIZEOF_SHORT; +#line 2745 +#line 2745 *xpp = (void *)xp; +#line 2745 return status; +#line 2745 } +#line 2745 int +#line 2746 ncx_pad_getn_short_int(const void **xpp, size_t nelems, int *tp) +#line 2746 { +#line 2746 const size_t rndup = nelems % 2; +#line 2746 +#line 2746 const char *xp = (const char *) *xpp; +#line 2746 int status = ENOERR; +#line 2746 +#line 2746 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2746 { +#line 2746 const int lstatus = ncx_get_short_int(xp, tp); +#line 2746 if(lstatus != ENOERR) +#line 2746 status = lstatus; +#line 2746 } +#line 2746 +#line 2746 if(rndup != 0) +#line 2746 xp += X_SIZEOF_SHORT; +#line 2746 +#line 2746 *xpp = (void *)xp; +#line 2746 return status; +#line 2746 } +#line 2746 int +#line 2747 ncx_pad_getn_short_float(const void **xpp, size_t nelems, float *tp) +#line 2747 { +#line 2747 const size_t rndup = nelems % 2; +#line 2747 +#line 2747 const char *xp = (const char *) *xpp; +#line 2747 int status = ENOERR; +#line 2747 +#line 2747 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2747 { +#line 2747 const int lstatus = ncx_get_short_float(xp, tp); +#line 2747 if(lstatus != ENOERR) +#line 2747 status = lstatus; +#line 2747 } +#line 2747 +#line 2747 if(rndup != 0) +#line 2747 xp += X_SIZEOF_SHORT; +#line 2747 +#line 2747 *xpp = (void *)xp; +#line 2747 return status; +#line 2747 } +#line 2747 int +#line 2748 ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *tp) +#line 2748 { +#line 2748 const size_t rndup = nelems % 2; +#line 2748 +#line 2748 const char *xp = (const char *) *xpp; +#line 2748 int status = ENOERR; +#line 2748 +#line 2748 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2748 { +#line 2748 const int lstatus = ncx_get_short_double(xp, tp); +#line 2748 if(lstatus != ENOERR) +#line 2748 status = lstatus; +#line 2748 } +#line 2748 +#line 2748 if(rndup != 0) +#line 2748 xp += X_SIZEOF_SHORT; +#line 2748 +#line 2748 *xpp = (void *)xp; +#line 2748 return status; +#line 2748 } +#line 2748 int +#line 2749 ncx_pad_getn_short_uint(const void **xpp, size_t nelems, uint *tp) +#line 2749 { +#line 2749 const size_t rndup = nelems % 2; +#line 2749 +#line 2749 const char *xp = (const char *) *xpp; +#line 2749 int status = ENOERR; +#line 2749 +#line 2749 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2749 { +#line 2749 const int lstatus = ncx_get_short_uint(xp, tp); +#line 2749 if(lstatus != ENOERR) +#line 2749 status = lstatus; +#line 2749 } +#line 2749 +#line 2749 if(rndup != 0) +#line 2749 xp += X_SIZEOF_SHORT; +#line 2749 +#line 2749 *xpp = (void *)xp; +#line 2749 return status; +#line 2749 } +#line 2749 int +#line 2750 ncx_pad_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2750 { +#line 2750 const size_t rndup = nelems % 2; +#line 2750 +#line 2750 const char *xp = (const char *) *xpp; +#line 2750 int status = ENOERR; +#line 2750 +#line 2750 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2750 { +#line 2750 const int lstatus = ncx_get_short_longlong(xp, tp); +#line 2750 if(lstatus != ENOERR) +#line 2750 status = lstatus; +#line 2750 } +#line 2750 +#line 2750 if(rndup != 0) +#line 2750 xp += X_SIZEOF_SHORT; +#line 2750 +#line 2750 *xpp = (void *)xp; +#line 2750 return status; +#line 2750 } +#line 2750 int +#line 2751 ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2751 { +#line 2751 const size_t rndup = nelems % 2; +#line 2751 +#line 2751 const char *xp = (const char *) *xpp; +#line 2751 int status = ENOERR; +#line 2751 +#line 2751 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2751 { +#line 2751 const int lstatus = ncx_get_short_ulonglong(xp, tp); +#line 2751 if(lstatus != ENOERR) +#line 2751 status = lstatus; +#line 2751 } +#line 2751 +#line 2751 if(rndup != 0) +#line 2751 xp += X_SIZEOF_SHORT; +#line 2751 +#line 2751 *xpp = (void *)xp; +#line 2751 return status; +#line 2751 } +#line 2751 int +#line 2753 ncx_putn_short_schar(void **xpp, size_t nelems, const schar *tp) +#line 2753 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2753 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2753 +#line 2753 /* basic algorithm is: +#line 2753 * - ensure sane alignment of output data +#line 2753 * - copy (conversion happens automatically) input data +#line 2753 * to output +#line 2753 * - update tp to point at next unconverted input, and xpp to point +#line 2753 * at next location for converted output +#line 2753 */ +#line 2753 long i, j, ni; +#line 2753 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2753 short *xp; +#line 2753 int nrange = 0; /* number of range errors */ +#line 2753 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2753 long cxp = (long) *((char**)xpp); +#line 2753 +#line 2753 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2753 /* sjl: manually stripmine so we can limit amount of +#line 2753 * vector work space reserved to LOOPCNT elements. Also +#line 2753 * makes vectorisation easy */ +#line 2753 for (j=0; j X_SHORT_MAX; +#line 2753 } +#line 2753 /* copy workspace back if necessary */ +#line 2753 if (realign) { +#line 2753 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2753 xp = (short *) *xpp; +#line 2753 } +#line 2753 /* update xpp and tp */ +#line 2753 xp += ni; +#line 2753 tp += ni; +#line 2753 *xpp = (void*)xp; +#line 2753 } +#line 2753 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2753 +#line 2753 #else /* not SX */ +#line 2753 +#line 2753 char *xp = (char *) *xpp; +#line 2753 int status = ENOERR; +#line 2753 +#line 2753 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2753 { +#line 2753 int lstatus = ncx_put_short_schar(xp, tp); +#line 2753 if(lstatus != ENOERR) +#line 2753 status = lstatus; +#line 2753 } +#line 2753 +#line 2753 *xpp = (void *)xp; +#line 2753 return status; +#line 2753 #endif +#line 2753 } +#line 2753 int +#line 2754 ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp) +#line 2754 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2754 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2754 +#line 2754 /* basic algorithm is: +#line 2754 * - ensure sane alignment of output data +#line 2754 * - copy (conversion happens automatically) input data +#line 2754 * to output +#line 2754 * - update tp to point at next unconverted input, and xpp to point +#line 2754 * at next location for converted output +#line 2754 */ +#line 2754 long i, j, ni; +#line 2754 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2754 short *xp; +#line 2754 int nrange = 0; /* number of range errors */ +#line 2754 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2754 long cxp = (long) *((char**)xpp); +#line 2754 +#line 2754 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2754 /* sjl: manually stripmine so we can limit amount of +#line 2754 * vector work space reserved to LOOPCNT elements. Also +#line 2754 * makes vectorisation easy */ +#line 2754 for (j=0; j X_SHORT_MAX; +#line 2754 } +#line 2754 /* copy workspace back if necessary */ +#line 2754 if (realign) { +#line 2754 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2754 xp = (short *) *xpp; +#line 2754 } +#line 2754 /* update xpp and tp */ +#line 2754 xp += ni; +#line 2754 tp += ni; +#line 2754 *xpp = (void*)xp; +#line 2754 } +#line 2754 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2754 +#line 2754 #else /* not SX */ +#line 2754 +#line 2754 char *xp = (char *) *xpp; +#line 2754 int status = ENOERR; +#line 2754 +#line 2754 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2754 { +#line 2754 int lstatus = ncx_put_short_uchar(xp, tp); +#line 2754 if(lstatus != ENOERR) +#line 2754 status = lstatus; +#line 2754 } +#line 2754 +#line 2754 *xpp = (void *)xp; +#line 2754 return status; +#line 2754 #endif +#line 2754 } +#line 2754 #if X_SIZEOF_SHORT == SIZEOF_SHORT /* optimized version */ @@ -3788,910 +5568,1771 @@ ncx_putn_short_short(void **xpp, size_t nelems, const short *tp) } #else int +#line 2769 ncx_putn_short_short(void **xpp, size_t nelems, const short *tp) +#line 2769 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2769 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2769 +#line 2769 /* basic algorithm is: +#line 2769 * - ensure sane alignment of output data +#line 2769 * - copy (conversion happens automatically) input data +#line 2769 * to output +#line 2769 * - update tp to point at next unconverted input, and xpp to point +#line 2769 * at next location for converted output +#line 2769 */ +#line 2769 long i, j, ni; +#line 2769 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2769 short *xp; +#line 2769 int nrange = 0; /* number of range errors */ +#line 2769 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2769 long cxp = (long) *((char**)xpp); +#line 2769 +#line 2769 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2769 /* sjl: manually stripmine so we can limit amount of +#line 2769 * vector work space reserved to LOOPCNT elements. Also +#line 2769 * makes vectorisation easy */ +#line 2769 for (j=0; j X_SHORT_MAX; +#line 2769 } +#line 2769 /* copy workspace back if necessary */ +#line 2769 if (realign) { +#line 2769 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2769 xp = (short *) *xpp; +#line 2769 } +#line 2769 /* update xpp and tp */ +#line 2769 xp += ni; +#line 2769 tp += ni; +#line 2769 *xpp = (void*)xp; +#line 2769 } +#line 2769 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2769 +#line 2769 #else /* not SX */ +#line 2769 +#line 2769 char *xp = (char *) *xpp; +#line 2769 int status = ENOERR; +#line 2769 +#line 2769 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2769 { +#line 2769 int lstatus = ncx_put_short_short(xp, tp); +#line 2769 if(lstatus != ENOERR) +#line 2769 status = lstatus; +#line 2769 } +#line 2769 +#line 2769 *xpp = (void *)xp; +#line 2769 return status; +#line 2769 #endif +#line 2769 } +#line 2769 #endif int +#line 2771 ncx_putn_short_int(void **xpp, size_t nelems, const int *tp) +#line 2771 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2771 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2771 +#line 2771 /* basic algorithm is: +#line 2771 * - ensure sane alignment of output data +#line 2771 * - copy (conversion happens automatically) input data +#line 2771 * to output +#line 2771 * - update tp to point at next unconverted input, and xpp to point +#line 2771 * at next location for converted output +#line 2771 */ +#line 2771 long i, j, ni; +#line 2771 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2771 short *xp; +#line 2771 int nrange = 0; /* number of range errors */ +#line 2771 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2771 long cxp = (long) *((char**)xpp); +#line 2771 +#line 2771 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2771 /* sjl: manually stripmine so we can limit amount of +#line 2771 * vector work space reserved to LOOPCNT elements. Also +#line 2771 * makes vectorisation easy */ +#line 2771 for (j=0; j X_SHORT_MAX; +#line 2771 } +#line 2771 /* copy workspace back if necessary */ +#line 2771 if (realign) { +#line 2771 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2771 xp = (short *) *xpp; +#line 2771 } +#line 2771 /* update xpp and tp */ +#line 2771 xp += ni; +#line 2771 tp += ni; +#line 2771 *xpp = (void*)xp; +#line 2771 } +#line 2771 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2771 +#line 2771 #else /* not SX */ +#line 2771 +#line 2771 char *xp = (char *) *xpp; +#line 2771 int status = ENOERR; +#line 2771 +#line 2771 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2771 { +#line 2771 int lstatus = ncx_put_short_int(xp, tp); +#line 2771 if(lstatus != ENOERR) +#line 2771 status = lstatus; +#line 2771 } +#line 2771 +#line 2771 *xpp = (void *)xp; +#line 2771 return status; +#line 2771 #endif +#line 2771 } +#line 2771 int +#line 2772 ncx_putn_short_float(void **xpp, size_t nelems, const float *tp) +#line 2772 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2772 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2772 +#line 2772 /* basic algorithm is: +#line 2772 * - ensure sane alignment of output data +#line 2772 * - copy (conversion happens automatically) input data +#line 2772 * to output +#line 2772 * - update tp to point at next unconverted input, and xpp to point +#line 2772 * at next location for converted output +#line 2772 */ +#line 2772 long i, j, ni; +#line 2772 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2772 short *xp; +#line 2772 int nrange = 0; /* number of range errors */ +#line 2772 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2772 long cxp = (long) *((char**)xpp); +#line 2772 +#line 2772 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2772 /* sjl: manually stripmine so we can limit amount of +#line 2772 * vector work space reserved to LOOPCNT elements. Also +#line 2772 * makes vectorisation easy */ +#line 2772 for (j=0; j X_SHORT_MAX; +#line 2772 } +#line 2772 /* copy workspace back if necessary */ +#line 2772 if (realign) { +#line 2772 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2772 xp = (short *) *xpp; +#line 2772 } +#line 2772 /* update xpp and tp */ +#line 2772 xp += ni; +#line 2772 tp += ni; +#line 2772 *xpp = (void*)xp; +#line 2772 } +#line 2772 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2772 +#line 2772 #else /* not SX */ +#line 2772 +#line 2772 char *xp = (char *) *xpp; +#line 2772 int status = ENOERR; +#line 2772 +#line 2772 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2772 { +#line 2772 int lstatus = ncx_put_short_float(xp, tp); +#line 2772 if(lstatus != ENOERR) +#line 2772 status = lstatus; +#line 2772 } +#line 2772 +#line 2772 *xpp = (void *)xp; +#line 2772 return status; +#line 2772 #endif +#line 2772 } +#line 2772 int +#line 2773 ncx_putn_short_double(void **xpp, size_t nelems, const double *tp) +#line 2773 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2773 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2773 +#line 2773 /* basic algorithm is: +#line 2773 * - ensure sane alignment of output data +#line 2773 * - copy (conversion happens automatically) input data +#line 2773 * to output +#line 2773 * - update tp to point at next unconverted input, and xpp to point +#line 2773 * at next location for converted output +#line 2773 */ +#line 2773 long i, j, ni; +#line 2773 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2773 short *xp; +#line 2773 int nrange = 0; /* number of range errors */ +#line 2773 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2773 long cxp = (long) *((char**)xpp); +#line 2773 +#line 2773 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2773 /* sjl: manually stripmine so we can limit amount of +#line 2773 * vector work space reserved to LOOPCNT elements. Also +#line 2773 * makes vectorisation easy */ +#line 2773 for (j=0; j X_SHORT_MAX; +#line 2773 } +#line 2773 /* copy workspace back if necessary */ +#line 2773 if (realign) { +#line 2773 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2773 xp = (short *) *xpp; +#line 2773 } +#line 2773 /* update xpp and tp */ +#line 2773 xp += ni; +#line 2773 tp += ni; +#line 2773 *xpp = (void*)xp; +#line 2773 } +#line 2773 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2773 +#line 2773 #else /* not SX */ +#line 2773 +#line 2773 char *xp = (char *) *xpp; +#line 2773 int status = ENOERR; +#line 2773 +#line 2773 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2773 { +#line 2773 int lstatus = ncx_put_short_double(xp, tp); +#line 2773 if(lstatus != ENOERR) +#line 2773 status = lstatus; +#line 2773 } +#line 2773 +#line 2773 *xpp = (void *)xp; +#line 2773 return status; +#line 2773 #endif +#line 2773 } +#line 2773 int +#line 2774 ncx_putn_short_uint(void **xpp, size_t nelems, const uint *tp) +#line 2774 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2774 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2774 +#line 2774 /* basic algorithm is: +#line 2774 * - ensure sane alignment of output data +#line 2774 * - copy (conversion happens automatically) input data +#line 2774 * to output +#line 2774 * - update tp to point at next unconverted input, and xpp to point +#line 2774 * at next location for converted output +#line 2774 */ +#line 2774 long i, j, ni; +#line 2774 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2774 short *xp; +#line 2774 int nrange = 0; /* number of range errors */ +#line 2774 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2774 long cxp = (long) *((char**)xpp); +#line 2774 +#line 2774 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2774 /* sjl: manually stripmine so we can limit amount of +#line 2774 * vector work space reserved to LOOPCNT elements. Also +#line 2774 * makes vectorisation easy */ +#line 2774 for (j=0; j X_SHORT_MAX; +#line 2774 } +#line 2774 /* copy workspace back if necessary */ +#line 2774 if (realign) { +#line 2774 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2774 xp = (short *) *xpp; +#line 2774 } +#line 2774 /* update xpp and tp */ +#line 2774 xp += ni; +#line 2774 tp += ni; +#line 2774 *xpp = (void*)xp; +#line 2774 } +#line 2774 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2774 +#line 2774 #else /* not SX */ +#line 2774 +#line 2774 char *xp = (char *) *xpp; +#line 2774 int status = ENOERR; +#line 2774 +#line 2774 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2774 { +#line 2774 int lstatus = ncx_put_short_uint(xp, tp); +#line 2774 if(lstatus != ENOERR) +#line 2774 status = lstatus; +#line 2774 } +#line 2774 +#line 2774 *xpp = (void *)xp; +#line 2774 return status; +#line 2774 #endif +#line 2774 } +#line 2774 int +#line 2775 ncx_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 2775 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2775 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2775 +#line 2775 /* basic algorithm is: +#line 2775 * - ensure sane alignment of output data +#line 2775 * - copy (conversion happens automatically) input data +#line 2775 * to output +#line 2775 * - update tp to point at next unconverted input, and xpp to point +#line 2775 * at next location for converted output +#line 2775 */ +#line 2775 long i, j, ni; +#line 2775 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2775 short *xp; +#line 2775 int nrange = 0; /* number of range errors */ +#line 2775 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2775 long cxp = (long) *((char**)xpp); +#line 2775 +#line 2775 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2775 /* sjl: manually stripmine so we can limit amount of +#line 2775 * vector work space reserved to LOOPCNT elements. Also +#line 2775 * makes vectorisation easy */ +#line 2775 for (j=0; j X_SHORT_MAX; +#line 2775 } +#line 2775 /* copy workspace back if necessary */ +#line 2775 if (realign) { +#line 2775 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2775 xp = (short *) *xpp; +#line 2775 } +#line 2775 /* update xpp and tp */ +#line 2775 xp += ni; +#line 2775 tp += ni; +#line 2775 *xpp = (void*)xp; +#line 2775 } +#line 2775 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2775 +#line 2775 #else /* not SX */ +#line 2775 +#line 2775 char *xp = (char *) *xpp; +#line 2775 int status = ENOERR; +#line 2775 +#line 2775 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2775 { +#line 2775 int lstatus = ncx_put_short_longlong(xp, tp); +#line 2775 if(lstatus != ENOERR) +#line 2775 status = lstatus; +#line 2775 } +#line 2775 +#line 2775 *xpp = (void *)xp; +#line 2775 return status; +#line 2775 #endif +#line 2775 } +#line 2775 int +#line 2776 ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 2776 { -#if _SX && \ - X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2776 +#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT +#line 2776 +#line 2776 /* basic algorithm is: +#line 2776 * - ensure sane alignment of output data +#line 2776 * - copy (conversion happens automatically) input data +#line 2776 * to output +#line 2776 * - update tp to point at next unconverted input, and xpp to point +#line 2776 * at next location for converted output +#line 2776 */ +#line 2776 long i, j, ni; +#line 2776 short tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2776 short *xp; +#line 2776 int nrange = 0; /* number of range errors */ +#line 2776 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2776 long cxp = (long) *((char**)xpp); +#line 2776 +#line 2776 realign = (cxp & 7) % SIZEOF_SHORT; +#line 2776 /* sjl: manually stripmine so we can limit amount of +#line 2776 * vector work space reserved to LOOPCNT elements. Also +#line 2776 * makes vectorisation easy */ +#line 2776 for (j=0; j X_SHORT_MAX; +#line 2776 } +#line 2776 /* copy workspace back if necessary */ +#line 2776 if (realign) { +#line 2776 memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT); +#line 2776 xp = (short *) *xpp; +#line 2776 } +#line 2776 /* update xpp and tp */ +#line 2776 xp += ni; +#line 2776 tp += ni; +#line 2776 *xpp = (void*)xp; +#line 2776 } +#line 2776 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2776 +#line 2776 #else /* not SX */ +#line 2776 +#line 2776 char *xp = (char *) *xpp; +#line 2776 int status = ENOERR; +#line 2776 +#line 2776 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2776 { +#line 2776 int lstatus = ncx_put_short_ulonglong(xp, tp); +#line 2776 if(lstatus != ENOERR) +#line 2776 status = lstatus; +#line 2776 } +#line 2776 +#line 2776 *xpp = (void *)xp; +#line 2776 return status; +#line 2776 #endif +#line 2776 } +#line 2776 int +#line 2778 ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *tp) +#line 2778 { +#line 2778 const size_t rndup = nelems % 2; +#line 2778 +#line 2778 char *xp = (char *) *xpp; +#line 2778 int status = ENOERR; +#line 2778 +#line 2778 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2778 { +#line 2778 int lstatus = ncx_put_short_schar(xp, tp); +#line 2778 if(lstatus != ENOERR) +#line 2778 status = lstatus; +#line 2778 } +#line 2778 +#line 2778 if(rndup != 0) +#line 2778 { +#line 2778 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2778 xp += X_SIZEOF_SHORT; +#line 2778 } +#line 2778 +#line 2778 *xpp = (void *)xp; +#line 2778 return status; +#line 2778 } +#line 2778 int +#line 2779 ncx_pad_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp) +#line 2779 { +#line 2779 const size_t rndup = nelems % 2; +#line 2779 +#line 2779 char *xp = (char *) *xpp; +#line 2779 int status = ENOERR; +#line 2779 +#line 2779 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2779 { +#line 2779 int lstatus = ncx_put_short_uchar(xp, tp); +#line 2779 if(lstatus != ENOERR) +#line 2779 status = lstatus; +#line 2779 } +#line 2779 +#line 2779 if(rndup != 0) +#line 2779 { +#line 2779 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2779 xp += X_SIZEOF_SHORT; +#line 2779 } +#line 2779 +#line 2779 *xpp = (void *)xp; +#line 2779 return status; +#line 2779 } +#line 2779 int +#line 2780 ncx_pad_putn_short_short(void **xpp, size_t nelems, const short *tp) +#line 2780 { +#line 2780 const size_t rndup = nelems % 2; +#line 2780 +#line 2780 char *xp = (char *) *xpp; +#line 2780 int status = ENOERR; +#line 2780 +#line 2780 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2780 { +#line 2780 int lstatus = ncx_put_short_short(xp, tp); +#line 2780 if(lstatus != ENOERR) +#line 2780 status = lstatus; +#line 2780 } +#line 2780 +#line 2780 if(rndup != 0) +#line 2780 { +#line 2780 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2780 xp += X_SIZEOF_SHORT; +#line 2780 } +#line 2780 +#line 2780 *xpp = (void *)xp; +#line 2780 return status; +#line 2780 } +#line 2780 int +#line 2781 ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *tp) +#line 2781 { +#line 2781 const size_t rndup = nelems % 2; +#line 2781 +#line 2781 char *xp = (char *) *xpp; +#line 2781 int status = ENOERR; +#line 2781 +#line 2781 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2781 { +#line 2781 int lstatus = ncx_put_short_int(xp, tp); +#line 2781 if(lstatus != ENOERR) +#line 2781 status = lstatus; +#line 2781 } +#line 2781 +#line 2781 if(rndup != 0) +#line 2781 { +#line 2781 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2781 xp += X_SIZEOF_SHORT; +#line 2781 } +#line 2781 +#line 2781 *xpp = (void *)xp; +#line 2781 return status; +#line 2781 } +#line 2781 int +#line 2782 ncx_pad_putn_short_float(void **xpp, size_t nelems, const float *tp) +#line 2782 { +#line 2782 const size_t rndup = nelems % 2; +#line 2782 +#line 2782 char *xp = (char *) *xpp; +#line 2782 int status = ENOERR; +#line 2782 +#line 2782 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2782 { +#line 2782 int lstatus = ncx_put_short_float(xp, tp); +#line 2782 if(lstatus != ENOERR) +#line 2782 status = lstatus; +#line 2782 } +#line 2782 +#line 2782 if(rndup != 0) +#line 2782 { +#line 2782 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2782 xp += X_SIZEOF_SHORT; +#line 2782 } +#line 2782 +#line 2782 *xpp = (void *)xp; +#line 2782 return status; +#line 2782 } +#line 2782 int +#line 2783 ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *tp) +#line 2783 { +#line 2783 const size_t rndup = nelems % 2; +#line 2783 +#line 2783 char *xp = (char *) *xpp; +#line 2783 int status = ENOERR; +#line 2783 +#line 2783 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2783 { +#line 2783 int lstatus = ncx_put_short_double(xp, tp); +#line 2783 if(lstatus != ENOERR) +#line 2783 status = lstatus; +#line 2783 } +#line 2783 +#line 2783 if(rndup != 0) +#line 2783 { +#line 2783 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2783 xp += X_SIZEOF_SHORT; +#line 2783 } +#line 2783 +#line 2783 *xpp = (void *)xp; +#line 2783 return status; +#line 2783 } +#line 2783 int +#line 2784 ncx_pad_putn_short_uint(void **xpp, size_t nelems, const uint *tp) +#line 2784 { +#line 2784 const size_t rndup = nelems % 2; +#line 2784 +#line 2784 char *xp = (char *) *xpp; +#line 2784 int status = ENOERR; +#line 2784 +#line 2784 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2784 { +#line 2784 int lstatus = ncx_put_short_uint(xp, tp); +#line 2784 if(lstatus != ENOERR) +#line 2784 status = lstatus; +#line 2784 } +#line 2784 +#line 2784 if(rndup != 0) +#line 2784 { +#line 2784 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2784 xp += X_SIZEOF_SHORT; +#line 2784 } +#line 2784 +#line 2784 *xpp = (void *)xp; +#line 2784 return status; +#line 2784 } +#line 2784 int +#line 2785 ncx_pad_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 2785 { +#line 2785 const size_t rndup = nelems % 2; +#line 2785 +#line 2785 char *xp = (char *) *xpp; +#line 2785 int status = ENOERR; +#line 2785 +#line 2785 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2785 { +#line 2785 int lstatus = ncx_put_short_longlong(xp, tp); +#line 2785 if(lstatus != ENOERR) +#line 2785 status = lstatus; +#line 2785 } +#line 2785 +#line 2785 if(rndup != 0) +#line 2785 { +#line 2785 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2785 xp += X_SIZEOF_SHORT; +#line 2785 } +#line 2785 +#line 2785 *xpp = (void *)xp; +#line 2785 return status; +#line 2785 } +#line 2785 int +#line 2786 ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 2786 { +#line 2786 const size_t rndup = nelems % 2; +#line 2786 +#line 2786 char *xp = (char *) *xpp; +#line 2786 int status = ENOERR; +#line 2786 +#line 2786 for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) +#line 2786 { +#line 2786 int lstatus = ncx_put_short_ulonglong(xp, tp); +#line 2786 if(lstatus != ENOERR) +#line 2786 status = lstatus; +#line 2786 } +#line 2786 +#line 2786 if(rndup != 0) +#line 2786 { +#line 2786 (void) memcpy(xp, nada, X_SIZEOF_SHORT); +#line 2786 xp += X_SIZEOF_SHORT; +#line 2786 } +#line 2786 +#line 2786 *xpp = (void *)xp; +#line 2786 return status; +#line 2786 } +#line 2786 /* int */ int +#line 2791 ncx_getn_int_schar(const void **xpp, size_t nelems, schar *tp) +#line 2791 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2791 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2791 +#line 2791 /* basic algorithm is: +#line 2791 * - ensure sane alignment of input data +#line 2791 * - copy (conversion happens automatically) input data +#line 2791 * to output +#line 2791 * - update xpp to point at next unconverted input, and tp to point +#line 2791 * at next location for converted output +#line 2791 */ +#line 2791 long i, j, ni; +#line 2791 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2791 int *xp; +#line 2791 int nrange = 0; /* number of range errors */ +#line 2791 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2791 long cxp = (long) *((char**)xpp); +#line 2791 +#line 2791 realign = (cxp & 7) % SIZEOF_INT; +#line 2791 /* sjl: manually stripmine so we can limit amount of +#line 2791 * vector work space reserved to LOOPCNT elements. Also +#line 2791 * makes vectorisation easy */ +#line 2791 for (j=0; j SCHAR_MAX; +#line 2791 } +#line 2791 /* update xpp and tp */ +#line 2791 if (realign) xp = (int *) *xpp; +#line 2791 xp += ni; +#line 2791 tp += ni; +#line 2791 *xpp = (void*)xp; +#line 2791 } +#line 2791 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2791 +#line 2791 #else /* not SX */ +#line 2791 const char *xp = (const char *) *xpp; +#line 2791 int status = ENOERR; +#line 2791 +#line 2791 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2791 { +#line 2791 const int lstatus = ncx_get_int_schar(xp, tp); +#line 2791 if(lstatus != ENOERR) +#line 2791 status = lstatus; +#line 2791 } +#line 2791 +#line 2791 *xpp = (const void *)xp; +#line 2791 return status; +#line 2791 # endif +#line 2791 } +#line 2791 int +#line 2792 ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *tp) +#line 2792 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2792 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2792 +#line 2792 /* basic algorithm is: +#line 2792 * - ensure sane alignment of input data +#line 2792 * - copy (conversion happens automatically) input data +#line 2792 * to output +#line 2792 * - update xpp to point at next unconverted input, and tp to point +#line 2792 * at next location for converted output +#line 2792 */ +#line 2792 long i, j, ni; +#line 2792 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2792 int *xp; +#line 2792 int nrange = 0; /* number of range errors */ +#line 2792 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2792 long cxp = (long) *((char**)xpp); +#line 2792 +#line 2792 realign = (cxp & 7) % SIZEOF_INT; +#line 2792 /* sjl: manually stripmine so we can limit amount of +#line 2792 * vector work space reserved to LOOPCNT elements. Also +#line 2792 * makes vectorisation easy */ +#line 2792 for (j=0; j UCHAR_MAX; +#line 2792 } +#line 2792 /* update xpp and tp */ +#line 2792 if (realign) xp = (int *) *xpp; +#line 2792 xp += ni; +#line 2792 tp += ni; +#line 2792 *xpp = (void*)xp; +#line 2792 } +#line 2792 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2792 +#line 2792 #else /* not SX */ +#line 2792 const char *xp = (const char *) *xpp; +#line 2792 int status = ENOERR; +#line 2792 +#line 2792 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2792 { +#line 2792 const int lstatus = ncx_get_int_uchar(xp, tp); +#line 2792 if(lstatus != ENOERR) +#line 2792 status = lstatus; +#line 2792 } +#line 2792 +#line 2792 *xpp = (const void *)xp; +#line 2792 return status; +#line 2792 # endif +#line 2792 } +#line 2792 int +#line 2793 ncx_getn_int_short(const void **xpp, size_t nelems, short *tp) +#line 2793 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2793 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2793 +#line 2793 /* basic algorithm is: +#line 2793 * - ensure sane alignment of input data +#line 2793 * - copy (conversion happens automatically) input data +#line 2793 * to output +#line 2793 * - update xpp to point at next unconverted input, and tp to point +#line 2793 * at next location for converted output +#line 2793 */ +#line 2793 long i, j, ni; +#line 2793 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2793 int *xp; +#line 2793 int nrange = 0; /* number of range errors */ +#line 2793 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2793 long cxp = (long) *((char**)xpp); +#line 2793 +#line 2793 realign = (cxp & 7) % SIZEOF_INT; +#line 2793 /* sjl: manually stripmine so we can limit amount of +#line 2793 * vector work space reserved to LOOPCNT elements. Also +#line 2793 * makes vectorisation easy */ +#line 2793 for (j=0; j SHORT_MAX; +#line 2793 } +#line 2793 /* update xpp and tp */ +#line 2793 if (realign) xp = (int *) *xpp; +#line 2793 xp += ni; +#line 2793 tp += ni; +#line 2793 *xpp = (void*)xp; +#line 2793 } +#line 2793 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2793 +#line 2793 #else /* not SX */ +#line 2793 const char *xp = (const char *) *xpp; +#line 2793 int status = ENOERR; +#line 2793 +#line 2793 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2793 { +#line 2793 const int lstatus = ncx_get_int_short(xp, tp); +#line 2793 if(lstatus != ENOERR) +#line 2793 status = lstatus; +#line 2793 } +#line 2793 +#line 2793 *xpp = (const void *)xp; +#line 2793 return status; +#line 2793 # endif +#line 2793 } +#line 2793 #if X_SIZEOF_INT == SIZEOF_INT /* optimized version */ @@ -4719,599 +7360,1163 @@ ncx_getn_int_uint(const void **xpp, size_t nelems, unsigned int *tp) } #else int +#line 2819 ncx_getn_int_int(const void **xpp, size_t nelems, int *tp) +#line 2819 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2819 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2819 +#line 2819 /* basic algorithm is: +#line 2819 * - ensure sane alignment of input data +#line 2819 * - copy (conversion happens automatically) input data +#line 2819 * to output +#line 2819 * - update xpp to point at next unconverted input, and tp to point +#line 2819 * at next location for converted output +#line 2819 */ +#line 2819 long i, j, ni; +#line 2819 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2819 int *xp; +#line 2819 int nrange = 0; /* number of range errors */ +#line 2819 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2819 long cxp = (long) *((char**)xpp); +#line 2819 +#line 2819 realign = (cxp & 7) % SIZEOF_INT; +#line 2819 /* sjl: manually stripmine so we can limit amount of +#line 2819 * vector work space reserved to LOOPCNT elements. Also +#line 2819 * makes vectorisation easy */ +#line 2819 for (j=0; j INT_MAX; +#line 2819 } +#line 2819 /* update xpp and tp */ +#line 2819 if (realign) xp = (int *) *xpp; +#line 2819 xp += ni; +#line 2819 tp += ni; +#line 2819 *xpp = (void*)xp; +#line 2819 } +#line 2819 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2819 +#line 2819 #else /* not SX */ +#line 2819 const char *xp = (const char *) *xpp; +#line 2819 int status = ENOERR; +#line 2819 +#line 2819 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2819 { +#line 2819 const int lstatus = ncx_get_int_int(xp, tp); +#line 2819 if(lstatus != ENOERR) +#line 2819 status = lstatus; +#line 2819 } +#line 2819 +#line 2819 *xpp = (const void *)xp; +#line 2819 return status; +#line 2819 # endif +#line 2819 } +#line 2819 int +#line 2820 ncx_getn_int_uint(const void **xpp, size_t nelems, uint *tp) +#line 2820 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2820 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2820 +#line 2820 /* basic algorithm is: +#line 2820 * - ensure sane alignment of input data +#line 2820 * - copy (conversion happens automatically) input data +#line 2820 * to output +#line 2820 * - update xpp to point at next unconverted input, and tp to point +#line 2820 * at next location for converted output +#line 2820 */ +#line 2820 long i, j, ni; +#line 2820 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2820 int *xp; +#line 2820 int nrange = 0; /* number of range errors */ +#line 2820 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2820 long cxp = (long) *((char**)xpp); +#line 2820 +#line 2820 realign = (cxp & 7) % SIZEOF_INT; +#line 2820 /* sjl: manually stripmine so we can limit amount of +#line 2820 * vector work space reserved to LOOPCNT elements. Also +#line 2820 * makes vectorisation easy */ +#line 2820 for (j=0; j UINT_MAX; +#line 2820 } +#line 2820 /* update xpp and tp */ +#line 2820 if (realign) xp = (int *) *xpp; +#line 2820 xp += ni; +#line 2820 tp += ni; +#line 2820 *xpp = (void*)xp; +#line 2820 } +#line 2820 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2820 +#line 2820 #else /* not SX */ +#line 2820 const char *xp = (const char *) *xpp; +#line 2820 int status = ENOERR; +#line 2820 +#line 2820 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2820 { +#line 2820 const int lstatus = ncx_get_int_uint(xp, tp); +#line 2820 if(lstatus != ENOERR) +#line 2820 status = lstatus; +#line 2820 } +#line 2820 +#line 2820 *xpp = (const void *)xp; +#line 2820 return status; +#line 2820 # endif +#line 2820 } +#line 2820 #endif int +#line 2823 ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2823 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2823 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2823 +#line 2823 /* basic algorithm is: +#line 2823 * - ensure sane alignment of input data +#line 2823 * - copy (conversion happens automatically) input data +#line 2823 * to output +#line 2823 * - update xpp to point at next unconverted input, and tp to point +#line 2823 * at next location for converted output +#line 2823 */ +#line 2823 long i, j, ni; +#line 2823 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2823 int *xp; +#line 2823 int nrange = 0; /* number of range errors */ +#line 2823 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2823 long cxp = (long) *((char**)xpp); +#line 2823 +#line 2823 realign = (cxp & 7) % SIZEOF_INT; +#line 2823 /* sjl: manually stripmine so we can limit amount of +#line 2823 * vector work space reserved to LOOPCNT elements. Also +#line 2823 * makes vectorisation easy */ +#line 2823 for (j=0; j LONGLONG_MAX; +#line 2823 } +#line 2823 /* update xpp and tp */ +#line 2823 if (realign) xp = (int *) *xpp; +#line 2823 xp += ni; +#line 2823 tp += ni; +#line 2823 *xpp = (void*)xp; +#line 2823 } +#line 2823 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2823 +#line 2823 #else /* not SX */ +#line 2823 const char *xp = (const char *) *xpp; +#line 2823 int status = ENOERR; +#line 2823 +#line 2823 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2823 { +#line 2823 const int lstatus = ncx_get_int_longlong(xp, tp); +#line 2823 if(lstatus != ENOERR) +#line 2823 status = lstatus; +#line 2823 } +#line 2823 +#line 2823 *xpp = (const void *)xp; +#line 2823 return status; +#line 2823 # endif +#line 2823 } +#line 2823 int +#line 2824 ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2824 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2824 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2824 +#line 2824 /* basic algorithm is: +#line 2824 * - ensure sane alignment of input data +#line 2824 * - copy (conversion happens automatically) input data +#line 2824 * to output +#line 2824 * - update xpp to point at next unconverted input, and tp to point +#line 2824 * at next location for converted output +#line 2824 */ +#line 2824 long i, j, ni; +#line 2824 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2824 int *xp; +#line 2824 int nrange = 0; /* number of range errors */ +#line 2824 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2824 long cxp = (long) *((char**)xpp); +#line 2824 +#line 2824 realign = (cxp & 7) % SIZEOF_INT; +#line 2824 /* sjl: manually stripmine so we can limit amount of +#line 2824 * vector work space reserved to LOOPCNT elements. Also +#line 2824 * makes vectorisation easy */ +#line 2824 for (j=0; j ULONGLONG_MAX; +#line 2824 } +#line 2824 /* update xpp and tp */ +#line 2824 if (realign) xp = (int *) *xpp; +#line 2824 xp += ni; +#line 2824 tp += ni; +#line 2824 *xpp = (void*)xp; +#line 2824 } +#line 2824 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2824 +#line 2824 #else /* not SX */ +#line 2824 const char *xp = (const char *) *xpp; +#line 2824 int status = ENOERR; +#line 2824 +#line 2824 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2824 { +#line 2824 const int lstatus = ncx_get_int_ulonglong(xp, tp); +#line 2824 if(lstatus != ENOERR) +#line 2824 status = lstatus; +#line 2824 } +#line 2824 +#line 2824 *xpp = (const void *)xp; +#line 2824 return status; +#line 2824 # endif +#line 2824 } +#line 2824 int +#line 2826 ncx_getn_int_float(const void **xpp, size_t nelems, float *tp) +#line 2826 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2826 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2826 +#line 2826 /* basic algorithm is: +#line 2826 * - ensure sane alignment of input data +#line 2826 * - copy (conversion happens automatically) input data +#line 2826 * to output +#line 2826 * - update xpp to point at next unconverted input, and tp to point +#line 2826 * at next location for converted output +#line 2826 */ +#line 2826 long i, j, ni; +#line 2826 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2826 int *xp; +#line 2826 int nrange = 0; /* number of range errors */ +#line 2826 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2826 long cxp = (long) *((char**)xpp); +#line 2826 +#line 2826 realign = (cxp & 7) % SIZEOF_INT; +#line 2826 /* sjl: manually stripmine so we can limit amount of +#line 2826 * vector work space reserved to LOOPCNT elements. Also +#line 2826 * makes vectorisation easy */ +#line 2826 for (j=0; j FLOAT_MAX; +#line 2826 } +#line 2826 /* update xpp and tp */ +#line 2826 if (realign) xp = (int *) *xpp; +#line 2826 xp += ni; +#line 2826 tp += ni; +#line 2826 *xpp = (void*)xp; +#line 2826 } +#line 2826 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2826 +#line 2826 #else /* not SX */ +#line 2826 const char *xp = (const char *) *xpp; +#line 2826 int status = ENOERR; +#line 2826 +#line 2826 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2826 { +#line 2826 const int lstatus = ncx_get_int_float(xp, tp); +#line 2826 if(lstatus != ENOERR) +#line 2826 status = lstatus; +#line 2826 } +#line 2826 +#line 2826 *xpp = (const void *)xp; +#line 2826 return status; +#line 2826 # endif +#line 2826 } +#line 2826 int +#line 2827 ncx_getn_int_double(const void **xpp, size_t nelems, double *tp) +#line 2827 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2827 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2827 +#line 2827 /* basic algorithm is: +#line 2827 * - ensure sane alignment of input data +#line 2827 * - copy (conversion happens automatically) input data +#line 2827 * to output +#line 2827 * - update xpp to point at next unconverted input, and tp to point +#line 2827 * at next location for converted output +#line 2827 */ +#line 2827 long i, j, ni; +#line 2827 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2827 int *xp; +#line 2827 int nrange = 0; /* number of range errors */ +#line 2827 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2827 long cxp = (long) *((char**)xpp); +#line 2827 +#line 2827 realign = (cxp & 7) % SIZEOF_INT; +#line 2827 /* sjl: manually stripmine so we can limit amount of +#line 2827 * vector work space reserved to LOOPCNT elements. Also +#line 2827 * makes vectorisation easy */ +#line 2827 for (j=0; j DOUBLE_MAX; +#line 2827 } +#line 2827 /* update xpp and tp */ +#line 2827 if (realign) xp = (int *) *xpp; +#line 2827 xp += ni; +#line 2827 tp += ni; +#line 2827 *xpp = (void*)xp; +#line 2827 } +#line 2827 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2827 +#line 2827 #else /* not SX */ +#line 2827 const char *xp = (const char *) *xpp; +#line 2827 int status = ENOERR; +#line 2827 +#line 2827 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2827 { +#line 2827 const int lstatus = ncx_get_int_double(xp, tp); +#line 2827 if(lstatus != ENOERR) +#line 2827 status = lstatus; +#line 2827 } +#line 2827 +#line 2827 *xpp = (const void *)xp; +#line 2827 return status; +#line 2827 # endif +#line 2827 } +#line 2827 int +#line 2829 ncx_putn_int_schar(void **xpp, size_t nelems, const schar *tp) +#line 2829 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2829 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2829 +#line 2829 /* basic algorithm is: +#line 2829 * - ensure sane alignment of output data +#line 2829 * - copy (conversion happens automatically) input data +#line 2829 * to output +#line 2829 * - update tp to point at next unconverted input, and xpp to point +#line 2829 * at next location for converted output +#line 2829 */ +#line 2829 long i, j, ni; +#line 2829 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2829 int *xp; +#line 2829 int nrange = 0; /* number of range errors */ +#line 2829 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2829 long cxp = (long) *((char**)xpp); +#line 2829 +#line 2829 realign = (cxp & 7) % SIZEOF_INT; +#line 2829 /* sjl: manually stripmine so we can limit amount of +#line 2829 * vector work space reserved to LOOPCNT elements. Also +#line 2829 * makes vectorisation easy */ +#line 2829 for (j=0; j X_INT_MAX; +#line 2829 } +#line 2829 /* copy workspace back if necessary */ +#line 2829 if (realign) { +#line 2829 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2829 xp = (int *) *xpp; +#line 2829 } +#line 2829 /* update xpp and tp */ +#line 2829 xp += ni; +#line 2829 tp += ni; +#line 2829 *xpp = (void*)xp; +#line 2829 } +#line 2829 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2829 +#line 2829 #else /* not SX */ +#line 2829 +#line 2829 char *xp = (char *) *xpp; +#line 2829 int status = ENOERR; +#line 2829 +#line 2829 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2829 { +#line 2829 int lstatus = ncx_put_int_schar(xp, tp); +#line 2829 if(lstatus != ENOERR) +#line 2829 status = lstatus; +#line 2829 } +#line 2829 +#line 2829 *xpp = (void *)xp; +#line 2829 return status; +#line 2829 #endif +#line 2829 } +#line 2829 int +#line 2830 ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *tp) +#line 2830 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2830 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2830 +#line 2830 /* basic algorithm is: +#line 2830 * - ensure sane alignment of output data +#line 2830 * - copy (conversion happens automatically) input data +#line 2830 * to output +#line 2830 * - update tp to point at next unconverted input, and xpp to point +#line 2830 * at next location for converted output +#line 2830 */ +#line 2830 long i, j, ni; +#line 2830 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2830 int *xp; +#line 2830 int nrange = 0; /* number of range errors */ +#line 2830 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2830 long cxp = (long) *((char**)xpp); +#line 2830 +#line 2830 realign = (cxp & 7) % SIZEOF_INT; +#line 2830 /* sjl: manually stripmine so we can limit amount of +#line 2830 * vector work space reserved to LOOPCNT elements. Also +#line 2830 * makes vectorisation easy */ +#line 2830 for (j=0; j X_INT_MAX; +#line 2830 } +#line 2830 /* copy workspace back if necessary */ +#line 2830 if (realign) { +#line 2830 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2830 xp = (int *) *xpp; +#line 2830 } +#line 2830 /* update xpp and tp */ +#line 2830 xp += ni; +#line 2830 tp += ni; +#line 2830 *xpp = (void*)xp; +#line 2830 } +#line 2830 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2830 +#line 2830 #else /* not SX */ +#line 2830 +#line 2830 char *xp = (char *) *xpp; +#line 2830 int status = ENOERR; +#line 2830 +#line 2830 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2830 { +#line 2830 int lstatus = ncx_put_int_uchar(xp, tp); +#line 2830 if(lstatus != ENOERR) +#line 2830 status = lstatus; +#line 2830 } +#line 2830 +#line 2830 *xpp = (void *)xp; +#line 2830 return status; +#line 2830 #endif +#line 2830 } +#line 2830 int +#line 2831 ncx_putn_int_short(void **xpp, size_t nelems, const short *tp) +#line 2831 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2831 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2831 +#line 2831 /* basic algorithm is: +#line 2831 * - ensure sane alignment of output data +#line 2831 * - copy (conversion happens automatically) input data +#line 2831 * to output +#line 2831 * - update tp to point at next unconverted input, and xpp to point +#line 2831 * at next location for converted output +#line 2831 */ +#line 2831 long i, j, ni; +#line 2831 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2831 int *xp; +#line 2831 int nrange = 0; /* number of range errors */ +#line 2831 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2831 long cxp = (long) *((char**)xpp); +#line 2831 +#line 2831 realign = (cxp & 7) % SIZEOF_INT; +#line 2831 /* sjl: manually stripmine so we can limit amount of +#line 2831 * vector work space reserved to LOOPCNT elements. Also +#line 2831 * makes vectorisation easy */ +#line 2831 for (j=0; j X_INT_MAX; +#line 2831 } +#line 2831 /* copy workspace back if necessary */ +#line 2831 if (realign) { +#line 2831 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2831 xp = (int *) *xpp; +#line 2831 } +#line 2831 /* update xpp and tp */ +#line 2831 xp += ni; +#line 2831 tp += ni; +#line 2831 *xpp = (void*)xp; +#line 2831 } +#line 2831 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2831 +#line 2831 #else /* not SX */ +#line 2831 +#line 2831 char *xp = (char *) *xpp; +#line 2831 int status = ENOERR; +#line 2831 +#line 2831 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2831 { +#line 2831 int lstatus = ncx_put_int_short(xp, tp); +#line 2831 if(lstatus != ENOERR) +#line 2831 status = lstatus; +#line 2831 } +#line 2831 +#line 2831 *xpp = (void *)xp; +#line 2831 return status; +#line 2831 #endif +#line 2831 } +#line 2831 #if X_SIZEOF_INT == SIZEOF_INT /* optimized version */ @@ -5339,681 +8544,1322 @@ ncx_putn_int_uint(void **xpp, size_t nelems, const unsigned int *tp) } #else int +#line 2857 ncx_putn_int_int(void **xpp, size_t nelems, const int *tp) +#line 2857 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2857 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2857 +#line 2857 /* basic algorithm is: +#line 2857 * - ensure sane alignment of output data +#line 2857 * - copy (conversion happens automatically) input data +#line 2857 * to output +#line 2857 * - update tp to point at next unconverted input, and xpp to point +#line 2857 * at next location for converted output +#line 2857 */ +#line 2857 long i, j, ni; +#line 2857 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2857 int *xp; +#line 2857 int nrange = 0; /* number of range errors */ +#line 2857 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2857 long cxp = (long) *((char**)xpp); +#line 2857 +#line 2857 realign = (cxp & 7) % SIZEOF_INT; +#line 2857 /* sjl: manually stripmine so we can limit amount of +#line 2857 * vector work space reserved to LOOPCNT elements. Also +#line 2857 * makes vectorisation easy */ +#line 2857 for (j=0; j X_INT_MAX; +#line 2857 } +#line 2857 /* copy workspace back if necessary */ +#line 2857 if (realign) { +#line 2857 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2857 xp = (int *) *xpp; +#line 2857 } +#line 2857 /* update xpp and tp */ +#line 2857 xp += ni; +#line 2857 tp += ni; +#line 2857 *xpp = (void*)xp; +#line 2857 } +#line 2857 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2857 +#line 2857 #else /* not SX */ +#line 2857 +#line 2857 char *xp = (char *) *xpp; +#line 2857 int status = ENOERR; +#line 2857 +#line 2857 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2857 { +#line 2857 int lstatus = ncx_put_int_int(xp, tp); +#line 2857 if(lstatus != ENOERR) +#line 2857 status = lstatus; +#line 2857 } +#line 2857 +#line 2857 *xpp = (void *)xp; +#line 2857 return status; +#line 2857 #endif +#line 2857 } +#line 2857 int +#line 2858 ncx_putn_int_uint(void **xpp, size_t nelems, const uint *tp) +#line 2858 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2858 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2858 +#line 2858 /* basic algorithm is: +#line 2858 * - ensure sane alignment of output data +#line 2858 * - copy (conversion happens automatically) input data +#line 2858 * to output +#line 2858 * - update tp to point at next unconverted input, and xpp to point +#line 2858 * at next location for converted output +#line 2858 */ +#line 2858 long i, j, ni; +#line 2858 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2858 int *xp; +#line 2858 int nrange = 0; /* number of range errors */ +#line 2858 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2858 long cxp = (long) *((char**)xpp); +#line 2858 +#line 2858 realign = (cxp & 7) % SIZEOF_INT; +#line 2858 /* sjl: manually stripmine so we can limit amount of +#line 2858 * vector work space reserved to LOOPCNT elements. Also +#line 2858 * makes vectorisation easy */ +#line 2858 for (j=0; j X_INT_MAX; +#line 2858 } +#line 2858 /* copy workspace back if necessary */ +#line 2858 if (realign) { +#line 2858 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2858 xp = (int *) *xpp; +#line 2858 } +#line 2858 /* update xpp and tp */ +#line 2858 xp += ni; +#line 2858 tp += ni; +#line 2858 *xpp = (void*)xp; +#line 2858 } +#line 2858 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2858 +#line 2858 #else /* not SX */ +#line 2858 +#line 2858 char *xp = (char *) *xpp; +#line 2858 int status = ENOERR; +#line 2858 +#line 2858 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2858 { +#line 2858 int lstatus = ncx_put_int_uint(xp, tp); +#line 2858 if(lstatus != ENOERR) +#line 2858 status = lstatus; +#line 2858 } +#line 2858 +#line 2858 *xpp = (void *)xp; +#line 2858 return status; +#line 2858 #endif +#line 2858 } +#line 2858 #endif int +#line 2861 ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 2861 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2861 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2861 +#line 2861 /* basic algorithm is: +#line 2861 * - ensure sane alignment of output data +#line 2861 * - copy (conversion happens automatically) input data +#line 2861 * to output +#line 2861 * - update tp to point at next unconverted input, and xpp to point +#line 2861 * at next location for converted output +#line 2861 */ +#line 2861 long i, j, ni; +#line 2861 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2861 int *xp; +#line 2861 int nrange = 0; /* number of range errors */ +#line 2861 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2861 long cxp = (long) *((char**)xpp); +#line 2861 +#line 2861 realign = (cxp & 7) % SIZEOF_INT; +#line 2861 /* sjl: manually stripmine so we can limit amount of +#line 2861 * vector work space reserved to LOOPCNT elements. Also +#line 2861 * makes vectorisation easy */ +#line 2861 for (j=0; j X_INT_MAX; +#line 2861 } +#line 2861 /* copy workspace back if necessary */ +#line 2861 if (realign) { +#line 2861 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2861 xp = (int *) *xpp; +#line 2861 } +#line 2861 /* update xpp and tp */ +#line 2861 xp += ni; +#line 2861 tp += ni; +#line 2861 *xpp = (void*)xp; +#line 2861 } +#line 2861 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2861 +#line 2861 #else /* not SX */ +#line 2861 +#line 2861 char *xp = (char *) *xpp; +#line 2861 int status = ENOERR; +#line 2861 +#line 2861 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2861 { +#line 2861 int lstatus = ncx_put_int_longlong(xp, tp); +#line 2861 if(lstatus != ENOERR) +#line 2861 status = lstatus; +#line 2861 } +#line 2861 +#line 2861 *xpp = (void *)xp; +#line 2861 return status; +#line 2861 #endif +#line 2861 } +#line 2861 int +#line 2862 ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 2862 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2862 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2862 +#line 2862 /* basic algorithm is: +#line 2862 * - ensure sane alignment of output data +#line 2862 * - copy (conversion happens automatically) input data +#line 2862 * to output +#line 2862 * - update tp to point at next unconverted input, and xpp to point +#line 2862 * at next location for converted output +#line 2862 */ +#line 2862 long i, j, ni; +#line 2862 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2862 int *xp; +#line 2862 int nrange = 0; /* number of range errors */ +#line 2862 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2862 long cxp = (long) *((char**)xpp); +#line 2862 +#line 2862 realign = (cxp & 7) % SIZEOF_INT; +#line 2862 /* sjl: manually stripmine so we can limit amount of +#line 2862 * vector work space reserved to LOOPCNT elements. Also +#line 2862 * makes vectorisation easy */ +#line 2862 for (j=0; j X_INT_MAX; +#line 2862 } +#line 2862 /* copy workspace back if necessary */ +#line 2862 if (realign) { +#line 2862 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2862 xp = (int *) *xpp; +#line 2862 } +#line 2862 /* update xpp and tp */ +#line 2862 xp += ni; +#line 2862 tp += ni; +#line 2862 *xpp = (void*)xp; +#line 2862 } +#line 2862 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2862 +#line 2862 #else /* not SX */ +#line 2862 +#line 2862 char *xp = (char *) *xpp; +#line 2862 int status = ENOERR; +#line 2862 +#line 2862 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2862 { +#line 2862 int lstatus = ncx_put_int_ulonglong(xp, tp); +#line 2862 if(lstatus != ENOERR) +#line 2862 status = lstatus; +#line 2862 } +#line 2862 +#line 2862 *xpp = (void *)xp; +#line 2862 return status; +#line 2862 #endif +#line 2862 } +#line 2862 int +#line 2863 ncx_putn_int_float(void **xpp, size_t nelems, const float *tp) +#line 2863 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2863 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2863 +#line 2863 /* basic algorithm is: +#line 2863 * - ensure sane alignment of output data +#line 2863 * - copy (conversion happens automatically) input data +#line 2863 * to output +#line 2863 * - update tp to point at next unconverted input, and xpp to point +#line 2863 * at next location for converted output +#line 2863 */ +#line 2863 long i, j, ni; +#line 2863 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2863 int *xp; +#line 2863 double d; /* special case for ncx_putn_int_float */ +#line 2863 int nrange = 0; /* number of range errors */ +#line 2863 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2863 long cxp = (long) *((char**)xpp); +#line 2863 +#line 2863 realign = (cxp & 7) % SIZEOF_INT; +#line 2863 /* sjl: manually stripmine so we can limit amount of +#line 2863 * vector work space reserved to LOOPCNT elements. Also +#line 2863 * makes vectorisation easy */ +#line 2863 for (j=0; j X_INT_MAX; +#line 2863 } +#line 2863 /* copy workspace back if necessary */ +#line 2863 if (realign) { +#line 2863 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2863 xp = (int *) *xpp; +#line 2863 } +#line 2863 /* update xpp and tp */ +#line 2863 xp += ni; +#line 2863 tp += ni; +#line 2863 *xpp = (void*)xp; +#line 2863 } +#line 2863 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2863 +#line 2863 #else /* not SX */ +#line 2863 +#line 2863 char *xp = (char *) *xpp; +#line 2863 int status = ENOERR; +#line 2863 +#line 2863 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2863 { +#line 2863 int lstatus = ncx_put_int_float(xp, tp); +#line 2863 if(lstatus != ENOERR) +#line 2863 status = lstatus; +#line 2863 } +#line 2863 +#line 2863 *xpp = (void *)xp; +#line 2863 return status; +#line 2863 #endif +#line 2863 } +#line 2863 int +#line 2864 ncx_putn_int_double(void **xpp, size_t nelems, const double *tp) +#line 2864 { -#if _SX && \ - X_SIZEOF_INT == SIZEOF_INT +#line 2864 +#if _SX && X_SIZEOF_INT == SIZEOF_INT +#line 2864 +#line 2864 /* basic algorithm is: +#line 2864 * - ensure sane alignment of output data +#line 2864 * - copy (conversion happens automatically) input data +#line 2864 * to output +#line 2864 * - update tp to point at next unconverted input, and xpp to point +#line 2864 * at next location for converted output +#line 2864 */ +#line 2864 long i, j, ni; +#line 2864 int tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2864 int *xp; +#line 2864 int nrange = 0; /* number of range errors */ +#line 2864 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2864 long cxp = (long) *((char**)xpp); +#line 2864 +#line 2864 realign = (cxp & 7) % SIZEOF_INT; +#line 2864 /* sjl: manually stripmine so we can limit amount of +#line 2864 * vector work space reserved to LOOPCNT elements. Also +#line 2864 * makes vectorisation easy */ +#line 2864 for (j=0; j X_INT_MAX; +#line 2864 } +#line 2864 /* copy workspace back if necessary */ +#line 2864 if (realign) { +#line 2864 memcpy(*xpp, tmp, ni*X_SIZEOF_INT); +#line 2864 xp = (int *) *xpp; +#line 2864 } +#line 2864 /* update xpp and tp */ +#line 2864 xp += ni; +#line 2864 tp += ni; +#line 2864 *xpp = (void*)xp; +#line 2864 } +#line 2864 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2864 +#line 2864 #else /* not SX */ +#line 2864 +#line 2864 char *xp = (char *) *xpp; +#line 2864 int status = ENOERR; +#line 2864 +#line 2864 for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++) +#line 2864 { +#line 2864 int lstatus = ncx_put_int_double(xp, tp); +#line 2864 if(lstatus != ENOERR) +#line 2864 status = lstatus; +#line 2864 } +#line 2864 +#line 2864 *xpp = (void *)xp; +#line 2864 return status; +#line 2864 #endif +#line 2864 } +#line 2864 /* float */ int +#line 2869 ncx_getn_float_schar(const void **xpp, size_t nelems, schar *tp) +#line 2869 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2869 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2869 +#line 2869 /* basic algorithm is: +#line 2869 * - ensure sane alignment of input data +#line 2869 * - copy (conversion happens automatically) input data +#line 2869 * to output +#line 2869 * - update xpp to point at next unconverted input, and tp to point +#line 2869 * at next location for converted output +#line 2869 */ +#line 2869 long i, j, ni; +#line 2869 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2869 float *xp; +#line 2869 int nrange = 0; /* number of range errors */ +#line 2869 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2869 long cxp = (long) *((char**)xpp); +#line 2869 +#line 2869 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2869 /* sjl: manually stripmine so we can limit amount of +#line 2869 * vector work space reserved to LOOPCNT elements. Also +#line 2869 * makes vectorisation easy */ +#line 2869 for (j=0; j SCHAR_MAX; +#line 2869 } +#line 2869 /* update xpp and tp */ +#line 2869 if (realign) xp = (float *) *xpp; +#line 2869 xp += ni; +#line 2869 tp += ni; +#line 2869 *xpp = (void*)xp; +#line 2869 } +#line 2869 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2869 +#line 2869 #else /* not SX */ +#line 2869 const char *xp = (const char *) *xpp; +#line 2869 int status = ENOERR; +#line 2869 +#line 2869 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2869 { +#line 2869 const int lstatus = ncx_get_float_schar(xp, tp); +#line 2869 if(lstatus != ENOERR) +#line 2869 status = lstatus; +#line 2869 } +#line 2869 +#line 2869 *xpp = (const void *)xp; +#line 2869 return status; +#line 2869 # endif +#line 2869 } +#line 2869 int +#line 2870 ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *tp) +#line 2870 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2870 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2870 +#line 2870 /* basic algorithm is: +#line 2870 * - ensure sane alignment of input data +#line 2870 * - copy (conversion happens automatically) input data +#line 2870 * to output +#line 2870 * - update xpp to point at next unconverted input, and tp to point +#line 2870 * at next location for converted output +#line 2870 */ +#line 2870 long i, j, ni; +#line 2870 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2870 float *xp; +#line 2870 int nrange = 0; /* number of range errors */ +#line 2870 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2870 long cxp = (long) *((char**)xpp); +#line 2870 +#line 2870 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2870 /* sjl: manually stripmine so we can limit amount of +#line 2870 * vector work space reserved to LOOPCNT elements. Also +#line 2870 * makes vectorisation easy */ +#line 2870 for (j=0; j UCHAR_MAX; +#line 2870 } +#line 2870 /* update xpp and tp */ +#line 2870 if (realign) xp = (float *) *xpp; +#line 2870 xp += ni; +#line 2870 tp += ni; +#line 2870 *xpp = (void*)xp; +#line 2870 } +#line 2870 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2870 +#line 2870 #else /* not SX */ +#line 2870 const char *xp = (const char *) *xpp; +#line 2870 int status = ENOERR; +#line 2870 +#line 2870 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2870 { +#line 2870 const int lstatus = ncx_get_float_uchar(xp, tp); +#line 2870 if(lstatus != ENOERR) +#line 2870 status = lstatus; +#line 2870 } +#line 2870 +#line 2870 *xpp = (const void *)xp; +#line 2870 return status; +#line 2870 # endif +#line 2870 } +#line 2870 int +#line 2871 ncx_getn_float_short(const void **xpp, size_t nelems, short *tp) +#line 2871 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2871 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2871 +#line 2871 /* basic algorithm is: +#line 2871 * - ensure sane alignment of input data +#line 2871 * - copy (conversion happens automatically) input data +#line 2871 * to output +#line 2871 * - update xpp to point at next unconverted input, and tp to point +#line 2871 * at next location for converted output +#line 2871 */ +#line 2871 long i, j, ni; +#line 2871 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2871 float *xp; +#line 2871 int nrange = 0; /* number of range errors */ +#line 2871 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2871 long cxp = (long) *((char**)xpp); +#line 2871 +#line 2871 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2871 /* sjl: manually stripmine so we can limit amount of +#line 2871 * vector work space reserved to LOOPCNT elements. Also +#line 2871 * makes vectorisation easy */ +#line 2871 for (j=0; j SHORT_MAX; +#line 2871 } +#line 2871 /* update xpp and tp */ +#line 2871 if (realign) xp = (float *) *xpp; +#line 2871 xp += ni; +#line 2871 tp += ni; +#line 2871 *xpp = (void*)xp; +#line 2871 } +#line 2871 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2871 +#line 2871 #else /* not SX */ +#line 2871 const char *xp = (const char *) *xpp; +#line 2871 int status = ENOERR; +#line 2871 +#line 2871 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2871 { +#line 2871 const int lstatus = ncx_get_float_short(xp, tp); +#line 2871 if(lstatus != ENOERR) +#line 2871 status = lstatus; +#line 2871 } +#line 2871 +#line 2871 *xpp = (const void *)xp; +#line 2871 return status; +#line 2871 # endif +#line 2871 } +#line 2871 int +#line 2872 ncx_getn_float_int(const void **xpp, size_t nelems, int *tp) +#line 2872 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2872 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2872 +#line 2872 /* basic algorithm is: +#line 2872 * - ensure sane alignment of input data +#line 2872 * - copy (conversion happens automatically) input data +#line 2872 * to output +#line 2872 * - update xpp to point at next unconverted input, and tp to point +#line 2872 * at next location for converted output +#line 2872 */ +#line 2872 long i, j, ni; +#line 2872 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2872 float *xp; +#line 2872 int nrange = 0; /* number of range errors */ +#line 2872 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2872 long cxp = (long) *((char**)xpp); +#line 2872 +#line 2872 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2872 /* sjl: manually stripmine so we can limit amount of +#line 2872 * vector work space reserved to LOOPCNT elements. Also +#line 2872 * makes vectorisation easy */ +#line 2872 for (j=0; j INT_MAX; +#line 2872 } +#line 2872 /* update xpp and tp */ +#line 2872 if (realign) xp = (float *) *xpp; +#line 2872 xp += ni; +#line 2872 tp += ni; +#line 2872 *xpp = (void*)xp; +#line 2872 } +#line 2872 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2872 +#line 2872 #else /* not SX */ +#line 2872 const char *xp = (const char *) *xpp; +#line 2872 int status = ENOERR; +#line 2872 +#line 2872 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2872 { +#line 2872 const int lstatus = ncx_get_float_int(xp, tp); +#line 2872 if(lstatus != ENOERR) +#line 2872 status = lstatus; +#line 2872 } +#line 2872 +#line 2872 *xpp = (const void *)xp; +#line 2872 return status; +#line 2872 # endif +#line 2872 } +#line 2872 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT) /* optimized version */ @@ -6037,50 +9883,95 @@ ncx_getn_float_float(const void **xpp, size_t nfloats, float *ip) while(ip < end) { struct vax_single *const vsp = (struct vax_single *) ip; +#line 2894 const struct ieee_single *const isp = +#line 2894 (const struct ieee_single *) (*xpp); +#line 2894 unsigned exp = isp->exp_hi << 1 | isp->exp_lo; +#line 2894 +#line 2894 switch(exp) { +#line 2894 case 0 : +#line 2894 /* ieee subnormal */ +#line 2894 if(isp->mant_hi == min.ieee.mant_hi +#line 2894 && isp->mant_lo_hi == min.ieee.mant_lo_hi +#line 2894 && isp->mant_lo_lo == min.ieee.mant_lo_lo) +#line 2894 { +#line 2894 *vsp = min.s; +#line 2894 } +#line 2894 else +#line 2894 { +#line 2894 unsigned mantissa = (isp->mant_hi << 16) +#line 2894 | isp->mant_lo_hi << 8 +#line 2894 | isp->mant_lo_lo; +#line 2894 unsigned tmp = mantissa >> 20; +#line 2894 if(tmp >= 4) { +#line 2894 vsp->exp = 2; +#line 2894 } else if (tmp >= 2) { +#line 2894 vsp->exp = 1; +#line 2894 } else { +#line 2894 *vsp = min.s; +#line 2894 break; +#line 2894 } /* else */ +#line 2894 tmp = mantissa - (1 << (20 + vsp->exp )); +#line 2894 tmp <<= 3 - vsp->exp; +#line 2894 vsp->mantissa2 = tmp; +#line 2894 vsp->mantissa1 = (tmp >> 16); +#line 2894 } +#line 2894 break; +#line 2894 case 0xfe : +#line 2894 case 0xff : +#line 2894 *vsp = max.s; +#line 2894 break; +#line 2894 default : +#line 2894 vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; +#line 2894 vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo; +#line 2894 vsp->mantissa1 = isp->mant_hi; +#line 2894 } +#line 2894 +#line 2894 vsp->sign = isp->sign; +#line 2894 ip++; @@ -6108,537 +9999,1045 @@ ncx_getn_float_float(const void **xpp, size_t nelems, float *tp) #endif int +#line 2920 ncx_getn_float_double(const void **xpp, size_t nelems, double *tp) +#line 2920 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2920 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2920 +#line 2920 /* basic algorithm is: +#line 2920 * - ensure sane alignment of input data +#line 2920 * - copy (conversion happens automatically) input data +#line 2920 * to output +#line 2920 * - update xpp to point at next unconverted input, and tp to point +#line 2920 * at next location for converted output +#line 2920 */ +#line 2920 long i, j, ni; +#line 2920 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2920 float *xp; +#line 2920 int nrange = 0; /* number of range errors */ +#line 2920 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2920 long cxp = (long) *((char**)xpp); +#line 2920 +#line 2920 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2920 /* sjl: manually stripmine so we can limit amount of +#line 2920 * vector work space reserved to LOOPCNT elements. Also +#line 2920 * makes vectorisation easy */ +#line 2920 for (j=0; j DOUBLE_MAX; +#line 2920 } +#line 2920 /* update xpp and tp */ +#line 2920 if (realign) xp = (float *) *xpp; +#line 2920 xp += ni; +#line 2920 tp += ni; +#line 2920 *xpp = (void*)xp; +#line 2920 } +#line 2920 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2920 +#line 2920 #else /* not SX */ +#line 2920 const char *xp = (const char *) *xpp; +#line 2920 int status = ENOERR; +#line 2920 +#line 2920 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2920 { +#line 2920 const int lstatus = ncx_get_float_double(xp, tp); +#line 2920 if(lstatus != ENOERR) +#line 2920 status = lstatus; +#line 2920 } +#line 2920 +#line 2920 *xpp = (const void *)xp; +#line 2920 return status; +#line 2920 # endif +#line 2920 } +#line 2920 int +#line 2921 ncx_getn_float_uint(const void **xpp, size_t nelems, uint *tp) +#line 2921 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2921 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2921 +#line 2921 /* basic algorithm is: +#line 2921 * - ensure sane alignment of input data +#line 2921 * - copy (conversion happens automatically) input data +#line 2921 * to output +#line 2921 * - update xpp to point at next unconverted input, and tp to point +#line 2921 * at next location for converted output +#line 2921 */ +#line 2921 long i, j, ni; +#line 2921 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2921 float *xp; +#line 2921 int nrange = 0; /* number of range errors */ +#line 2921 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2921 long cxp = (long) *((char**)xpp); +#line 2921 +#line 2921 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2921 /* sjl: manually stripmine so we can limit amount of +#line 2921 * vector work space reserved to LOOPCNT elements. Also +#line 2921 * makes vectorisation easy */ +#line 2921 for (j=0; j UINT_MAX; +#line 2921 } +#line 2921 /* update xpp and tp */ +#line 2921 if (realign) xp = (float *) *xpp; +#line 2921 xp += ni; +#line 2921 tp += ni; +#line 2921 *xpp = (void*)xp; +#line 2921 } +#line 2921 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2921 +#line 2921 #else /* not SX */ +#line 2921 const char *xp = (const char *) *xpp; +#line 2921 int status = ENOERR; +#line 2921 +#line 2921 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2921 { +#line 2921 const int lstatus = ncx_get_float_uint(xp, tp); +#line 2921 if(lstatus != ENOERR) +#line 2921 status = lstatus; +#line 2921 } +#line 2921 +#line 2921 *xpp = (const void *)xp; +#line 2921 return status; +#line 2921 # endif +#line 2921 } +#line 2921 int +#line 2922 ncx_getn_float_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2922 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2922 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2922 +#line 2922 /* basic algorithm is: +#line 2922 * - ensure sane alignment of input data +#line 2922 * - copy (conversion happens automatically) input data +#line 2922 * to output +#line 2922 * - update xpp to point at next unconverted input, and tp to point +#line 2922 * at next location for converted output +#line 2922 */ +#line 2922 long i, j, ni; +#line 2922 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2922 float *xp; +#line 2922 int nrange = 0; /* number of range errors */ +#line 2922 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2922 long cxp = (long) *((char**)xpp); +#line 2922 +#line 2922 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2922 /* sjl: manually stripmine so we can limit amount of +#line 2922 * vector work space reserved to LOOPCNT elements. Also +#line 2922 * makes vectorisation easy */ +#line 2922 for (j=0; j LONGLONG_MAX; +#line 2922 } +#line 2922 /* update xpp and tp */ +#line 2922 if (realign) xp = (float *) *xpp; +#line 2922 xp += ni; +#line 2922 tp += ni; +#line 2922 *xpp = (void*)xp; +#line 2922 } +#line 2922 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2922 +#line 2922 #else /* not SX */ +#line 2922 const char *xp = (const char *) *xpp; +#line 2922 int status = ENOERR; +#line 2922 +#line 2922 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2922 { +#line 2922 const int lstatus = ncx_get_float_longlong(xp, tp); +#line 2922 if(lstatus != ENOERR) +#line 2922 status = lstatus; +#line 2922 } +#line 2922 +#line 2922 *xpp = (const void *)xp; +#line 2922 return status; +#line 2922 # endif +#line 2922 } +#line 2922 int +#line 2923 ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2923 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2923 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2923 +#line 2923 /* basic algorithm is: +#line 2923 * - ensure sane alignment of input data +#line 2923 * - copy (conversion happens automatically) input data +#line 2923 * to output +#line 2923 * - update xpp to point at next unconverted input, and tp to point +#line 2923 * at next location for converted output +#line 2923 */ +#line 2923 long i, j, ni; +#line 2923 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2923 float *xp; +#line 2923 int nrange = 0; /* number of range errors */ +#line 2923 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2923 long cxp = (long) *((char**)xpp); +#line 2923 +#line 2923 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2923 /* sjl: manually stripmine so we can limit amount of +#line 2923 * vector work space reserved to LOOPCNT elements. Also +#line 2923 * makes vectorisation easy */ +#line 2923 for (j=0; j ULONGLONG_MAX; +#line 2923 } +#line 2923 /* update xpp and tp */ +#line 2923 if (realign) xp = (float *) *xpp; +#line 2923 xp += ni; +#line 2923 tp += ni; +#line 2923 *xpp = (void*)xp; +#line 2923 } +#line 2923 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2923 +#line 2923 #else /* not SX */ +#line 2923 const char *xp = (const char *) *xpp; +#line 2923 int status = ENOERR; +#line 2923 +#line 2923 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2923 { +#line 2923 const int lstatus = ncx_get_float_ulonglong(xp, tp); +#line 2923 if(lstatus != ENOERR) +#line 2923 status = lstatus; +#line 2923 } +#line 2923 +#line 2923 *xpp = (const void *)xp; +#line 2923 return status; +#line 2923 # endif +#line 2923 } +#line 2923 int +#line 2925 ncx_putn_float_schar(void **xpp, size_t nelems, const schar *tp) +#line 2925 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2925 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2925 +#line 2925 /* basic algorithm is: +#line 2925 * - ensure sane alignment of output data +#line 2925 * - copy (conversion happens automatically) input data +#line 2925 * to output +#line 2925 * - update tp to point at next unconverted input, and xpp to point +#line 2925 * at next location for converted output +#line 2925 */ +#line 2925 long i, j, ni; +#line 2925 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2925 float *xp; +#line 2925 int nrange = 0; /* number of range errors */ +#line 2925 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2925 long cxp = (long) *((char**)xpp); +#line 2925 +#line 2925 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2925 /* sjl: manually stripmine so we can limit amount of +#line 2925 * vector work space reserved to LOOPCNT elements. Also +#line 2925 * makes vectorisation easy */ +#line 2925 for (j=0; j X_FLOAT_MAX; +#line 2925 } +#line 2925 /* copy workspace back if necessary */ +#line 2925 if (realign) { +#line 2925 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2925 xp = (float *) *xpp; +#line 2925 } +#line 2925 /* update xpp and tp */ +#line 2925 xp += ni; +#line 2925 tp += ni; +#line 2925 *xpp = (void*)xp; +#line 2925 } +#line 2925 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2925 +#line 2925 #else /* not SX */ +#line 2925 +#line 2925 char *xp = (char *) *xpp; +#line 2925 int status = ENOERR; +#line 2925 +#line 2925 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2925 { +#line 2925 int lstatus = ncx_put_float_schar(xp, tp); +#line 2925 if(lstatus != ENOERR) +#line 2925 status = lstatus; +#line 2925 } +#line 2925 +#line 2925 *xpp = (void *)xp; +#line 2925 return status; +#line 2925 #endif +#line 2925 } +#line 2925 int +#line 2926 ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *tp) +#line 2926 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2926 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2926 +#line 2926 /* basic algorithm is: +#line 2926 * - ensure sane alignment of output data +#line 2926 * - copy (conversion happens automatically) input data +#line 2926 * to output +#line 2926 * - update tp to point at next unconverted input, and xpp to point +#line 2926 * at next location for converted output +#line 2926 */ +#line 2926 long i, j, ni; +#line 2926 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2926 float *xp; +#line 2926 int nrange = 0; /* number of range errors */ +#line 2926 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2926 long cxp = (long) *((char**)xpp); +#line 2926 +#line 2926 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2926 /* sjl: manually stripmine so we can limit amount of +#line 2926 * vector work space reserved to LOOPCNT elements. Also +#line 2926 * makes vectorisation easy */ +#line 2926 for (j=0; j X_FLOAT_MAX; +#line 2926 } +#line 2926 /* copy workspace back if necessary */ +#line 2926 if (realign) { +#line 2926 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2926 xp = (float *) *xpp; +#line 2926 } +#line 2926 /* update xpp and tp */ +#line 2926 xp += ni; +#line 2926 tp += ni; +#line 2926 *xpp = (void*)xp; +#line 2926 } +#line 2926 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2926 +#line 2926 #else /* not SX */ +#line 2926 +#line 2926 char *xp = (char *) *xpp; +#line 2926 int status = ENOERR; +#line 2926 +#line 2926 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2926 { +#line 2926 int lstatus = ncx_put_float_uchar(xp, tp); +#line 2926 if(lstatus != ENOERR) +#line 2926 status = lstatus; +#line 2926 } +#line 2926 +#line 2926 *xpp = (void *)xp; +#line 2926 return status; +#line 2926 #endif +#line 2926 } +#line 2926 int +#line 2927 ncx_putn_float_short(void **xpp, size_t nelems, const short *tp) +#line 2927 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2927 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2927 +#line 2927 /* basic algorithm is: +#line 2927 * - ensure sane alignment of output data +#line 2927 * - copy (conversion happens automatically) input data +#line 2927 * to output +#line 2927 * - update tp to point at next unconverted input, and xpp to point +#line 2927 * at next location for converted output +#line 2927 */ +#line 2927 long i, j, ni; +#line 2927 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2927 float *xp; +#line 2927 int nrange = 0; /* number of range errors */ +#line 2927 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2927 long cxp = (long) *((char**)xpp); +#line 2927 +#line 2927 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2927 /* sjl: manually stripmine so we can limit amount of +#line 2927 * vector work space reserved to LOOPCNT elements. Also +#line 2927 * makes vectorisation easy */ +#line 2927 for (j=0; j X_FLOAT_MAX; +#line 2927 } +#line 2927 /* copy workspace back if necessary */ +#line 2927 if (realign) { +#line 2927 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2927 xp = (float *) *xpp; +#line 2927 } +#line 2927 /* update xpp and tp */ +#line 2927 xp += ni; +#line 2927 tp += ni; +#line 2927 *xpp = (void*)xp; +#line 2927 } +#line 2927 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2927 +#line 2927 #else /* not SX */ +#line 2927 +#line 2927 char *xp = (char *) *xpp; +#line 2927 int status = ENOERR; +#line 2927 +#line 2927 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2927 { +#line 2927 int lstatus = ncx_put_float_short(xp, tp); +#line 2927 if(lstatus != ENOERR) +#line 2927 status = lstatus; +#line 2927 } +#line 2927 +#line 2927 *xpp = (void *)xp; +#line 2927 return status; +#line 2927 #endif +#line 2927 } +#line 2927 int +#line 2928 ncx_putn_float_int(void **xpp, size_t nelems, const int *tp) +#line 2928 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2928 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2928 +#line 2928 /* basic algorithm is: +#line 2928 * - ensure sane alignment of output data +#line 2928 * - copy (conversion happens automatically) input data +#line 2928 * to output +#line 2928 * - update tp to point at next unconverted input, and xpp to point +#line 2928 * at next location for converted output +#line 2928 */ +#line 2928 long i, j, ni; +#line 2928 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2928 float *xp; +#line 2928 int nrange = 0; /* number of range errors */ +#line 2928 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2928 long cxp = (long) *((char**)xpp); +#line 2928 +#line 2928 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2928 /* sjl: manually stripmine so we can limit amount of +#line 2928 * vector work space reserved to LOOPCNT elements. Also +#line 2928 * makes vectorisation easy */ +#line 2928 for (j=0; j X_FLOAT_MAX; +#line 2928 } +#line 2928 /* copy workspace back if necessary */ +#line 2928 if (realign) { +#line 2928 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2928 xp = (float *) *xpp; +#line 2928 } +#line 2928 /* update xpp and tp */ +#line 2928 xp += ni; +#line 2928 tp += ni; +#line 2928 *xpp = (void*)xp; +#line 2928 } +#line 2928 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2928 +#line 2928 #else /* not SX */ +#line 2928 +#line 2928 char *xp = (char *) *xpp; +#line 2928 int status = ENOERR; +#line 2928 +#line 2928 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2928 { +#line 2928 int lstatus = ncx_put_float_int(xp, tp); +#line 2928 if(lstatus != ENOERR) +#line 2928 status = lstatus; +#line 2928 } +#line 2928 +#line 2928 *xpp = (void *)xp; +#line 2928 return status; +#line 2928 #endif +#line 2928 } +#line 2928 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT) /* optimized version */ @@ -6662,49 +11061,93 @@ ncx_putn_float_float(void **xpp, size_t nfloats, const float *ip) while(ip < end) { const struct vax_single *const vsp = +#line 2950 (const struct vax_single *)ip; +#line 2950 struct ieee_single *const isp = (struct ieee_single *) (*xpp); +#line 2950 +#line 2950 switch(vsp->exp){ +#line 2950 case 0 : +#line 2950 /* all vax float with zero exponent map to zero */ +#line 2950 *isp = min.ieee; +#line 2950 break; +#line 2950 case 2 : +#line 2950 case 1 : +#line 2950 { +#line 2950 /* These will map to subnormals */ +#line 2950 unsigned mantissa = (vsp->mantissa1 << 16) +#line 2950 | vsp->mantissa2; +#line 2950 mantissa >>= 3 - vsp->exp; +#line 2950 mantissa += (1 << (20 + vsp->exp)); +#line 2950 isp->mant_lo_lo = mantissa; +#line 2950 isp->mant_lo_hi = mantissa >> 8; +#line 2950 isp->mant_hi = mantissa >> 16; +#line 2950 isp->exp_lo = 0; +#line 2950 isp->exp_hi = 0; +#line 2950 } +#line 2950 break; +#line 2950 case 0xff : /* max.s.exp */ +#line 2950 if( vsp->mantissa2 == max.s.mantissa2 +#line 2950 && vsp->mantissa1 == max.s.mantissa1) +#line 2950 { +#line 2950 /* map largest vax float to ieee infinity */ +#line 2950 *isp = max.ieee; +#line 2950 break; +#line 2950 } /* else, fall thru */ +#line 2950 default : +#line 2950 { +#line 2950 unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; +#line 2950 isp->exp_hi = exp >> 1; +#line 2950 isp->exp_lo = exp; +#line 2950 isp->mant_lo_lo = vsp->mantissa2; +#line 2950 isp->mant_lo_hi = vsp->mantissa2 >> 8; +#line 2950 isp->mant_hi = vsp->mantissa1; +#line 2950 } +#line 2950 } +#line 2950 +#line 2950 isp->sign = vsp->sign; +#line 2950 ip++; @@ -6732,795 +11175,1548 @@ ncx_putn_float_float(void **xpp, size_t nelems, const float *tp) #endif int +#line 2976 ncx_putn_float_double(void **xpp, size_t nelems, const double *tp) +#line 2976 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2976 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2976 +#line 2976 /* basic algorithm is: +#line 2976 * - ensure sane alignment of output data +#line 2976 * - copy (conversion happens automatically) input data +#line 2976 * to output +#line 2976 * - update tp to point at next unconverted input, and xpp to point +#line 2976 * at next location for converted output +#line 2976 */ +#line 2976 long i, j, ni; +#line 2976 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2976 float *xp; +#line 2976 int nrange = 0; /* number of range errors */ +#line 2976 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2976 long cxp = (long) *((char**)xpp); +#line 2976 +#line 2976 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2976 /* sjl: manually stripmine so we can limit amount of +#line 2976 * vector work space reserved to LOOPCNT elements. Also +#line 2976 * makes vectorisation easy */ +#line 2976 for (j=0; j X_FLOAT_MAX; +#line 2976 } +#line 2976 /* copy workspace back if necessary */ +#line 2976 if (realign) { +#line 2976 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2976 xp = (float *) *xpp; +#line 2976 } +#line 2976 /* update xpp and tp */ +#line 2976 xp += ni; +#line 2976 tp += ni; +#line 2976 *xpp = (void*)xp; +#line 2976 } +#line 2976 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2976 +#line 2976 #else /* not SX */ +#line 2976 +#line 2976 char *xp = (char *) *xpp; +#line 2976 int status = ENOERR; +#line 2976 +#line 2976 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2976 { +#line 2976 int lstatus = ncx_put_float_double(xp, tp); +#line 2976 if(lstatus != ENOERR) +#line 2976 status = lstatus; +#line 2976 } +#line 2976 +#line 2976 *xpp = (void *)xp; +#line 2976 return status; +#line 2976 #endif +#line 2976 } +#line 2976 int +#line 2977 ncx_putn_float_uint(void **xpp, size_t nelems, const uint *tp) +#line 2977 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2977 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2977 +#line 2977 /* basic algorithm is: +#line 2977 * - ensure sane alignment of output data +#line 2977 * - copy (conversion happens automatically) input data +#line 2977 * to output +#line 2977 * - update tp to point at next unconverted input, and xpp to point +#line 2977 * at next location for converted output +#line 2977 */ +#line 2977 long i, j, ni; +#line 2977 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2977 float *xp; +#line 2977 int nrange = 0; /* number of range errors */ +#line 2977 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2977 long cxp = (long) *((char**)xpp); +#line 2977 +#line 2977 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2977 /* sjl: manually stripmine so we can limit amount of +#line 2977 * vector work space reserved to LOOPCNT elements. Also +#line 2977 * makes vectorisation easy */ +#line 2977 for (j=0; j X_FLOAT_MAX; +#line 2977 } +#line 2977 /* copy workspace back if necessary */ +#line 2977 if (realign) { +#line 2977 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2977 xp = (float *) *xpp; +#line 2977 } +#line 2977 /* update xpp and tp */ +#line 2977 xp += ni; +#line 2977 tp += ni; +#line 2977 *xpp = (void*)xp; +#line 2977 } +#line 2977 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2977 +#line 2977 #else /* not SX */ +#line 2977 +#line 2977 char *xp = (char *) *xpp; +#line 2977 int status = ENOERR; +#line 2977 +#line 2977 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2977 { +#line 2977 int lstatus = ncx_put_float_uint(xp, tp); +#line 2977 if(lstatus != ENOERR) +#line 2977 status = lstatus; +#line 2977 } +#line 2977 +#line 2977 *xpp = (void *)xp; +#line 2977 return status; +#line 2977 #endif +#line 2977 } +#line 2977 int +#line 2978 ncx_putn_float_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 2978 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2978 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2978 +#line 2978 /* basic algorithm is: +#line 2978 * - ensure sane alignment of output data +#line 2978 * - copy (conversion happens automatically) input data +#line 2978 * to output +#line 2978 * - update tp to point at next unconverted input, and xpp to point +#line 2978 * at next location for converted output +#line 2978 */ +#line 2978 long i, j, ni; +#line 2978 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2978 float *xp; +#line 2978 int nrange = 0; /* number of range errors */ +#line 2978 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2978 long cxp = (long) *((char**)xpp); +#line 2978 +#line 2978 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2978 /* sjl: manually stripmine so we can limit amount of +#line 2978 * vector work space reserved to LOOPCNT elements. Also +#line 2978 * makes vectorisation easy */ +#line 2978 for (j=0; j X_FLOAT_MAX; +#line 2978 } +#line 2978 /* copy workspace back if necessary */ +#line 2978 if (realign) { +#line 2978 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2978 xp = (float *) *xpp; +#line 2978 } +#line 2978 /* update xpp and tp */ +#line 2978 xp += ni; +#line 2978 tp += ni; +#line 2978 *xpp = (void*)xp; +#line 2978 } +#line 2978 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2978 +#line 2978 #else /* not SX */ +#line 2978 +#line 2978 char *xp = (char *) *xpp; +#line 2978 int status = ENOERR; +#line 2978 +#line 2978 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2978 { +#line 2978 int lstatus = ncx_put_float_longlong(xp, tp); +#line 2978 if(lstatus != ENOERR) +#line 2978 status = lstatus; +#line 2978 } +#line 2978 +#line 2978 *xpp = (void *)xp; +#line 2978 return status; +#line 2978 #endif +#line 2978 } +#line 2978 int +#line 2979 ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 2979 { -#if _SX && \ - X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2979 +#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT +#line 2979 +#line 2979 /* basic algorithm is: +#line 2979 * - ensure sane alignment of output data +#line 2979 * - copy (conversion happens automatically) input data +#line 2979 * to output +#line 2979 * - update tp to point at next unconverted input, and xpp to point +#line 2979 * at next location for converted output +#line 2979 */ +#line 2979 long i, j, ni; +#line 2979 float tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2979 float *xp; +#line 2979 int nrange = 0; /* number of range errors */ +#line 2979 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2979 long cxp = (long) *((char**)xpp); +#line 2979 +#line 2979 realign = (cxp & 7) % SIZEOF_FLOAT; +#line 2979 /* sjl: manually stripmine so we can limit amount of +#line 2979 * vector work space reserved to LOOPCNT elements. Also +#line 2979 * makes vectorisation easy */ +#line 2979 for (j=0; j X_FLOAT_MAX; +#line 2979 } +#line 2979 /* copy workspace back if necessary */ +#line 2979 if (realign) { +#line 2979 memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT); +#line 2979 xp = (float *) *xpp; +#line 2979 } +#line 2979 /* update xpp and tp */ +#line 2979 xp += ni; +#line 2979 tp += ni; +#line 2979 *xpp = (void*)xp; +#line 2979 } +#line 2979 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2979 +#line 2979 #else /* not SX */ +#line 2979 +#line 2979 char *xp = (char *) *xpp; +#line 2979 int status = ENOERR; +#line 2979 +#line 2979 for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++) +#line 2979 { +#line 2979 int lstatus = ncx_put_float_ulonglong(xp, tp); +#line 2979 if(lstatus != ENOERR) +#line 2979 status = lstatus; +#line 2979 } +#line 2979 +#line 2979 *xpp = (void *)xp; +#line 2979 return status; +#line 2979 #endif +#line 2979 } +#line 2979 /* double */ int +#line 2983 ncx_getn_double_schar(const void **xpp, size_t nelems, schar *tp) +#line 2983 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2983 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2983 +#line 2983 /* basic algorithm is: +#line 2983 * - ensure sane alignment of input data +#line 2983 * - copy (conversion happens automatically) input data +#line 2983 * to output +#line 2983 * - update xpp to point at next unconverted input, and tp to point +#line 2983 * at next location for converted output +#line 2983 */ +#line 2983 long i, j, ni; +#line 2983 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2983 double *xp; +#line 2983 int nrange = 0; /* number of range errors */ +#line 2983 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2983 long cxp = (long) *((char**)xpp); +#line 2983 +#line 2983 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2983 /* sjl: manually stripmine so we can limit amount of +#line 2983 * vector work space reserved to LOOPCNT elements. Also +#line 2983 * makes vectorisation easy */ +#line 2983 for (j=0; j SCHAR_MAX; +#line 2983 } +#line 2983 /* update xpp and tp */ +#line 2983 if (realign) xp = (double *) *xpp; +#line 2983 xp += ni; +#line 2983 tp += ni; +#line 2983 *xpp = (void*)xp; +#line 2983 } +#line 2983 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2983 +#line 2983 #else /* not SX */ +#line 2983 const char *xp = (const char *) *xpp; +#line 2983 int status = ENOERR; +#line 2983 +#line 2983 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2983 { +#line 2983 const int lstatus = ncx_get_double_schar(xp, tp); +#line 2983 if(lstatus != ENOERR) +#line 2983 status = lstatus; +#line 2983 } +#line 2983 +#line 2983 *xpp = (const void *)xp; +#line 2983 return status; +#line 2983 # endif +#line 2983 } +#line 2983 int +#line 2984 ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *tp) +#line 2984 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2984 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2984 +#line 2984 /* basic algorithm is: +#line 2984 * - ensure sane alignment of input data +#line 2984 * - copy (conversion happens automatically) input data +#line 2984 * to output +#line 2984 * - update xpp to point at next unconverted input, and tp to point +#line 2984 * at next location for converted output +#line 2984 */ +#line 2984 long i, j, ni; +#line 2984 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2984 double *xp; +#line 2984 int nrange = 0; /* number of range errors */ +#line 2984 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2984 long cxp = (long) *((char**)xpp); +#line 2984 +#line 2984 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2984 /* sjl: manually stripmine so we can limit amount of +#line 2984 * vector work space reserved to LOOPCNT elements. Also +#line 2984 * makes vectorisation easy */ +#line 2984 for (j=0; j UCHAR_MAX; +#line 2984 } +#line 2984 /* update xpp and tp */ +#line 2984 if (realign) xp = (double *) *xpp; +#line 2984 xp += ni; +#line 2984 tp += ni; +#line 2984 *xpp = (void*)xp; +#line 2984 } +#line 2984 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2984 +#line 2984 #else /* not SX */ +#line 2984 const char *xp = (const char *) *xpp; +#line 2984 int status = ENOERR; +#line 2984 +#line 2984 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2984 { +#line 2984 const int lstatus = ncx_get_double_uchar(xp, tp); +#line 2984 if(lstatus != ENOERR) +#line 2984 status = lstatus; +#line 2984 } +#line 2984 +#line 2984 *xpp = (const void *)xp; +#line 2984 return status; +#line 2984 # endif +#line 2984 } +#line 2984 int +#line 2985 ncx_getn_double_short(const void **xpp, size_t nelems, short *tp) +#line 2985 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2985 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2985 +#line 2985 /* basic algorithm is: +#line 2985 * - ensure sane alignment of input data +#line 2985 * - copy (conversion happens automatically) input data +#line 2985 * to output +#line 2985 * - update xpp to point at next unconverted input, and tp to point +#line 2985 * at next location for converted output +#line 2985 */ +#line 2985 long i, j, ni; +#line 2985 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2985 double *xp; +#line 2985 int nrange = 0; /* number of range errors */ +#line 2985 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2985 long cxp = (long) *((char**)xpp); +#line 2985 +#line 2985 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2985 /* sjl: manually stripmine so we can limit amount of +#line 2985 * vector work space reserved to LOOPCNT elements. Also +#line 2985 * makes vectorisation easy */ +#line 2985 for (j=0; j SHORT_MAX; +#line 2985 } +#line 2985 /* update xpp and tp */ +#line 2985 if (realign) xp = (double *) *xpp; +#line 2985 xp += ni; +#line 2985 tp += ni; +#line 2985 *xpp = (void*)xp; +#line 2985 } +#line 2985 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2985 +#line 2985 #else /* not SX */ +#line 2985 const char *xp = (const char *) *xpp; +#line 2985 int status = ENOERR; +#line 2985 +#line 2985 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2985 { +#line 2985 const int lstatus = ncx_get_double_short(xp, tp); +#line 2985 if(lstatus != ENOERR) +#line 2985 status = lstatus; +#line 2985 } +#line 2985 +#line 2985 *xpp = (const void *)xp; +#line 2985 return status; +#line 2985 # endif +#line 2985 } +#line 2985 int +#line 2986 ncx_getn_double_int(const void **xpp, size_t nelems, int *tp) +#line 2986 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2986 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2986 +#line 2986 /* basic algorithm is: +#line 2986 * - ensure sane alignment of input data +#line 2986 * - copy (conversion happens automatically) input data +#line 2986 * to output +#line 2986 * - update xpp to point at next unconverted input, and tp to point +#line 2986 * at next location for converted output +#line 2986 */ +#line 2986 long i, j, ni; +#line 2986 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2986 double *xp; +#line 2986 int nrange = 0; /* number of range errors */ +#line 2986 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2986 long cxp = (long) *((char**)xpp); +#line 2986 +#line 2986 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2986 /* sjl: manually stripmine so we can limit amount of +#line 2986 * vector work space reserved to LOOPCNT elements. Also +#line 2986 * makes vectorisation easy */ +#line 2986 for (j=0; j INT_MAX; +#line 2986 } +#line 2986 /* update xpp and tp */ +#line 2986 if (realign) xp = (double *) *xpp; +#line 2986 xp += ni; +#line 2986 tp += ni; +#line 2986 *xpp = (void*)xp; +#line 2986 } +#line 2986 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2986 +#line 2986 #else /* not SX */ +#line 2986 const char *xp = (const char *) *xpp; +#line 2986 int status = ENOERR; +#line 2986 +#line 2986 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2986 { +#line 2986 const int lstatus = ncx_get_double_int(xp, tp); +#line 2986 if(lstatus != ENOERR) +#line 2986 status = lstatus; +#line 2986 } +#line 2986 +#line 2986 *xpp = (const void *)xp; +#line 2986 return status; +#line 2986 # endif +#line 2986 } +#line 2986 int +#line 2987 ncx_getn_double_float(const void **xpp, size_t nelems, float *tp) +#line 2987 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2987 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2987 +#line 2987 /* basic algorithm is: +#line 2987 * - ensure sane alignment of input data +#line 2987 * - copy (conversion happens automatically) input data +#line 2987 * to output +#line 2987 * - update xpp to point at next unconverted input, and tp to point +#line 2987 * at next location for converted output +#line 2987 */ +#line 2987 long i, j, ni; +#line 2987 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2987 double *xp; +#line 2987 int nrange = 0; /* number of range errors */ +#line 2987 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2987 long cxp = (long) *((char**)xpp); +#line 2987 +#line 2987 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2987 /* sjl: manually stripmine so we can limit amount of +#line 2987 * vector work space reserved to LOOPCNT elements. Also +#line 2987 * makes vectorisation easy */ +#line 2987 for (j=0; j FLOAT_MAX; +#line 2987 } +#line 2987 /* update xpp and tp */ +#line 2987 if (realign) xp = (double *) *xpp; +#line 2987 xp += ni; +#line 2987 tp += ni; +#line 2987 *xpp = (void*)xp; +#line 2987 } +#line 2987 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2987 +#line 2987 #else /* not SX */ +#line 2987 const char *xp = (const char *) *xpp; +#line 2987 int status = ENOERR; +#line 2987 +#line 2987 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2987 { +#line 2987 const int lstatus = ncx_get_double_float(xp, tp); +#line 2987 if(lstatus != ENOERR) +#line 2987 status = lstatus; +#line 2987 } +#line 2987 +#line 2987 *xpp = (const void *)xp; +#line 2987 return status; +#line 2987 # endif +#line 2987 } +#line 2987 +#line 2989 int +#line 2989 ncx_getn_double_uint(const void **xpp, size_t nelems, uint *tp) +#line 2989 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2989 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2989 +#line 2989 /* basic algorithm is: +#line 2989 * - ensure sane alignment of input data +#line 2989 * - copy (conversion happens automatically) input data +#line 2989 * to output +#line 2989 * - update xpp to point at next unconverted input, and tp to point +#line 2989 * at next location for converted output +#line 2989 */ +#line 2989 long i, j, ni; +#line 2989 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2989 double *xp; +#line 2989 int nrange = 0; /* number of range errors */ +#line 2989 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2989 long cxp = (long) *((char**)xpp); +#line 2989 +#line 2989 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2989 /* sjl: manually stripmine so we can limit amount of +#line 2989 * vector work space reserved to LOOPCNT elements. Also +#line 2989 * makes vectorisation easy */ +#line 2989 for (j=0; j UINT_MAX; +#line 2989 } +#line 2989 /* update xpp and tp */ +#line 2989 if (realign) xp = (double *) *xpp; +#line 2989 xp += ni; +#line 2989 tp += ni; +#line 2989 *xpp = (void*)xp; +#line 2989 } +#line 2989 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2989 +#line 2989 #else /* not SX */ +#line 2989 const char *xp = (const char *) *xpp; +#line 2989 int status = ENOERR; +#line 2989 +#line 2989 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2989 { +#line 2989 const int lstatus = ncx_get_double_uint(xp, tp); +#line 2989 if(lstatus != ENOERR) +#line 2989 status = lstatus; +#line 2989 } +#line 2989 +#line 2989 *xpp = (const void *)xp; +#line 2989 return status; +#line 2989 # endif +#line 2989 } +#line 2989 int +#line 2990 ncx_getn_double_longlong(const void **xpp, size_t nelems, longlong *tp) +#line 2990 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2990 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2990 +#line 2990 /* basic algorithm is: +#line 2990 * - ensure sane alignment of input data +#line 2990 * - copy (conversion happens automatically) input data +#line 2990 * to output +#line 2990 * - update xpp to point at next unconverted input, and tp to point +#line 2990 * at next location for converted output +#line 2990 */ +#line 2990 long i, j, ni; +#line 2990 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2990 double *xp; +#line 2990 int nrange = 0; /* number of range errors */ +#line 2990 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2990 long cxp = (long) *((char**)xpp); +#line 2990 +#line 2990 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2990 /* sjl: manually stripmine so we can limit amount of +#line 2990 * vector work space reserved to LOOPCNT elements. Also +#line 2990 * makes vectorisation easy */ +#line 2990 for (j=0; j LONGLONG_MAX; +#line 2990 } +#line 2990 /* update xpp and tp */ +#line 2990 if (realign) xp = (double *) *xpp; +#line 2990 xp += ni; +#line 2990 tp += ni; +#line 2990 *xpp = (void*)xp; +#line 2990 } +#line 2990 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2990 +#line 2990 #else /* not SX */ +#line 2990 const char *xp = (const char *) *xpp; +#line 2990 int status = ENOERR; +#line 2990 +#line 2990 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2990 { +#line 2990 const int lstatus = ncx_get_double_longlong(xp, tp); +#line 2990 if(lstatus != ENOERR) +#line 2990 status = lstatus; +#line 2990 } +#line 2990 +#line 2990 *xpp = (const void *)xp; +#line 2990 return status; +#line 2990 # endif +#line 2990 } +#line 2990 int +#line 2991 ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *tp) +#line 2991 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2991 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 2991 +#line 2991 /* basic algorithm is: +#line 2991 * - ensure sane alignment of input data +#line 2991 * - copy (conversion happens automatically) input data +#line 2991 * to output +#line 2991 * - update xpp to point at next unconverted input, and tp to point +#line 2991 * at next location for converted output +#line 2991 */ +#line 2991 long i, j, ni; +#line 2991 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 2991 double *xp; +#line 2991 int nrange = 0; /* number of range errors */ +#line 2991 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 2991 long cxp = (long) *((char**)xpp); +#line 2991 +#line 2991 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 2991 /* sjl: manually stripmine so we can limit amount of +#line 2991 * vector work space reserved to LOOPCNT elements. Also +#line 2991 * makes vectorisation easy */ +#line 2991 for (j=0; j ULONGLONG_MAX; +#line 2991 } +#line 2991 /* update xpp and tp */ +#line 2991 if (realign) xp = (double *) *xpp; +#line 2991 xp += ni; +#line 2991 tp += ni; +#line 2991 *xpp = (void*)xp; +#line 2991 } +#line 2991 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 2991 +#line 2991 #else /* not SX */ +#line 2991 const char *xp = (const char *) *xpp; +#line 2991 int status = ENOERR; +#line 2991 +#line 2991 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 2991 { +#line 2991 const int lstatus = ncx_get_double_ulonglong(xp, tp); +#line 2991 if(lstatus != ENOERR) +#line 2991 status = lstatus; +#line 2991 } +#line 2991 +#line 2991 *xpp = (const void *)xp; +#line 2991 return status; +#line 2991 # endif +#line 2991 } +#line 2991 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT) /* optimized version */ @@ -7544,46 +12740,87 @@ ncx_getn_double_double(const void **xpp, size_t ndoubles, double *ip) while(ip < end) { struct vax_double *const vdp = +#line 3013 (struct vax_double *)ip; +#line 3013 const struct ieee_double *const idp = +#line 3013 (const struct ieee_double *) (*xpp); +#line 3013 { +#line 3013 const struct dbl_limits *lim; +#line 3013 int ii; +#line 3013 for (ii = 0, lim = dbl_limits; +#line 3013 ii < sizeof(dbl_limits)/sizeof(struct dbl_limits); +#line 3013 ii++, lim++) +#line 3013 { +#line 3013 if ((idp->mant_lo == lim->ieee.mant_lo) +#line 3013 && (idp->mant_4 == lim->ieee.mant_4) +#line 3013 && (idp->mant_5 == lim->ieee.mant_5) +#line 3013 && (idp->mant_6 == lim->ieee.mant_6) +#line 3013 && (idp->exp_lo == lim->ieee.exp_lo) +#line 3013 && (idp->exp_hi == lim->ieee.exp_hi) +#line 3013 ) +#line 3013 { +#line 3013 *vdp = lim->d; +#line 3013 goto doneit; +#line 3013 } +#line 3013 } +#line 3013 } +#line 3013 { +#line 3013 unsigned exp = idp->exp_hi << 4 | idp->exp_lo; +#line 3013 vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; +#line 3013 } +#line 3013 { +#line 3013 unsigned mant_hi = ((idp->mant_6 << 16) +#line 3013 | (idp->mant_5 << 8) +#line 3013 | idp->mant_4); +#line 3013 unsigned mant_lo = SWAP4(idp->mant_lo); +#line 3013 vdp->mantissa1 = (mant_hi >> 13); +#line 3013 vdp->mantissa2 = ((mant_hi & MASK(13)) << 3) +#line 3013 | (mant_lo >> 29); +#line 3013 vdp->mantissa3 = (mant_lo >> 13); +#line 3013 vdp->mantissa4 = (mant_lo << 3); +#line 3013 } +#line 3013 doneit: +#line 3013 vdp->sign = idp->sign; +#line 3013 ip++; *xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE; @@ -7612,556 +12849,1085 @@ ncx_getn_double_double(const void **xpp, size_t nelems, double *tp) #endif int +#line 3040 ncx_putn_double_schar(void **xpp, size_t nelems, const schar *tp) +#line 3040 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3040 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3040 +#line 3040 /* basic algorithm is: +#line 3040 * - ensure sane alignment of output data +#line 3040 * - copy (conversion happens automatically) input data +#line 3040 * to output +#line 3040 * - update tp to point at next unconverted input, and xpp to point +#line 3040 * at next location for converted output +#line 3040 */ +#line 3040 long i, j, ni; +#line 3040 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3040 double *xp; +#line 3040 int nrange = 0; /* number of range errors */ +#line 3040 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3040 long cxp = (long) *((char**)xpp); +#line 3040 +#line 3040 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3040 /* sjl: manually stripmine so we can limit amount of +#line 3040 * vector work space reserved to LOOPCNT elements. Also +#line 3040 * makes vectorisation easy */ +#line 3040 for (j=0; j X_DOUBLE_MAX; +#line 3040 } +#line 3040 /* copy workspace back if necessary */ +#line 3040 if (realign) { +#line 3040 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3040 xp = (double *) *xpp; +#line 3040 } +#line 3040 /* update xpp and tp */ +#line 3040 xp += ni; +#line 3040 tp += ni; +#line 3040 *xpp = (void*)xp; +#line 3040 } +#line 3040 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3040 +#line 3040 #else /* not SX */ +#line 3040 +#line 3040 char *xp = (char *) *xpp; +#line 3040 int status = ENOERR; +#line 3040 +#line 3040 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3040 { +#line 3040 int lstatus = ncx_put_double_schar(xp, tp); +#line 3040 if(lstatus != ENOERR) +#line 3040 status = lstatus; +#line 3040 } +#line 3040 +#line 3040 *xpp = (void *)xp; +#line 3040 return status; +#line 3040 #endif +#line 3040 } +#line 3040 int +#line 3041 ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *tp) +#line 3041 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3041 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3041 +#line 3041 /* basic algorithm is: +#line 3041 * - ensure sane alignment of output data +#line 3041 * - copy (conversion happens automatically) input data +#line 3041 * to output +#line 3041 * - update tp to point at next unconverted input, and xpp to point +#line 3041 * at next location for converted output +#line 3041 */ +#line 3041 long i, j, ni; +#line 3041 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3041 double *xp; +#line 3041 int nrange = 0; /* number of range errors */ +#line 3041 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3041 long cxp = (long) *((char**)xpp); +#line 3041 +#line 3041 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3041 /* sjl: manually stripmine so we can limit amount of +#line 3041 * vector work space reserved to LOOPCNT elements. Also +#line 3041 * makes vectorisation easy */ +#line 3041 for (j=0; j X_DOUBLE_MAX; +#line 3041 } +#line 3041 /* copy workspace back if necessary */ +#line 3041 if (realign) { +#line 3041 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3041 xp = (double *) *xpp; +#line 3041 } +#line 3041 /* update xpp and tp */ +#line 3041 xp += ni; +#line 3041 tp += ni; +#line 3041 *xpp = (void*)xp; +#line 3041 } +#line 3041 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3041 +#line 3041 #else /* not SX */ +#line 3041 +#line 3041 char *xp = (char *) *xpp; +#line 3041 int status = ENOERR; +#line 3041 +#line 3041 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3041 { +#line 3041 int lstatus = ncx_put_double_uchar(xp, tp); +#line 3041 if(lstatus != ENOERR) +#line 3041 status = lstatus; +#line 3041 } +#line 3041 +#line 3041 *xpp = (void *)xp; +#line 3041 return status; +#line 3041 #endif +#line 3041 } +#line 3041 int +#line 3042 ncx_putn_double_short(void **xpp, size_t nelems, const short *tp) +#line 3042 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3042 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3042 +#line 3042 /* basic algorithm is: +#line 3042 * - ensure sane alignment of output data +#line 3042 * - copy (conversion happens automatically) input data +#line 3042 * to output +#line 3042 * - update tp to point at next unconverted input, and xpp to point +#line 3042 * at next location for converted output +#line 3042 */ +#line 3042 long i, j, ni; +#line 3042 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3042 double *xp; +#line 3042 int nrange = 0; /* number of range errors */ +#line 3042 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3042 long cxp = (long) *((char**)xpp); +#line 3042 +#line 3042 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3042 /* sjl: manually stripmine so we can limit amount of +#line 3042 * vector work space reserved to LOOPCNT elements. Also +#line 3042 * makes vectorisation easy */ +#line 3042 for (j=0; j X_DOUBLE_MAX; +#line 3042 } +#line 3042 /* copy workspace back if necessary */ +#line 3042 if (realign) { +#line 3042 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3042 xp = (double *) *xpp; +#line 3042 } +#line 3042 /* update xpp and tp */ +#line 3042 xp += ni; +#line 3042 tp += ni; +#line 3042 *xpp = (void*)xp; +#line 3042 } +#line 3042 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3042 +#line 3042 #else /* not SX */ +#line 3042 +#line 3042 char *xp = (char *) *xpp; +#line 3042 int status = ENOERR; +#line 3042 +#line 3042 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3042 { +#line 3042 int lstatus = ncx_put_double_short(xp, tp); +#line 3042 if(lstatus != ENOERR) +#line 3042 status = lstatus; +#line 3042 } +#line 3042 +#line 3042 *xpp = (void *)xp; +#line 3042 return status; +#line 3042 #endif +#line 3042 } +#line 3042 int +#line 3043 ncx_putn_double_int(void **xpp, size_t nelems, const int *tp) +#line 3043 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3043 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3043 +#line 3043 /* basic algorithm is: +#line 3043 * - ensure sane alignment of output data +#line 3043 * - copy (conversion happens automatically) input data +#line 3043 * to output +#line 3043 * - update tp to point at next unconverted input, and xpp to point +#line 3043 * at next location for converted output +#line 3043 */ +#line 3043 long i, j, ni; +#line 3043 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3043 double *xp; +#line 3043 int nrange = 0; /* number of range errors */ +#line 3043 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3043 long cxp = (long) *((char**)xpp); +#line 3043 +#line 3043 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3043 /* sjl: manually stripmine so we can limit amount of +#line 3043 * vector work space reserved to LOOPCNT elements. Also +#line 3043 * makes vectorisation easy */ +#line 3043 for (j=0; j X_DOUBLE_MAX; +#line 3043 } +#line 3043 /* copy workspace back if necessary */ +#line 3043 if (realign) { +#line 3043 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3043 xp = (double *) *xpp; +#line 3043 } +#line 3043 /* update xpp and tp */ +#line 3043 xp += ni; +#line 3043 tp += ni; +#line 3043 *xpp = (void*)xp; +#line 3043 } +#line 3043 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3043 +#line 3043 #else /* not SX */ +#line 3043 +#line 3043 char *xp = (char *) *xpp; +#line 3043 int status = ENOERR; +#line 3043 +#line 3043 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3043 { +#line 3043 int lstatus = ncx_put_double_int(xp, tp); +#line 3043 if(lstatus != ENOERR) +#line 3043 status = lstatus; +#line 3043 } +#line 3043 +#line 3043 *xpp = (void *)xp; +#line 3043 return status; +#line 3043 #endif +#line 3043 } +#line 3043 int +#line 3044 ncx_putn_double_float(void **xpp, size_t nelems, const float *tp) +#line 3044 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3044 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3044 +#line 3044 /* basic algorithm is: +#line 3044 * - ensure sane alignment of output data +#line 3044 * - copy (conversion happens automatically) input data +#line 3044 * to output +#line 3044 * - update tp to point at next unconverted input, and xpp to point +#line 3044 * at next location for converted output +#line 3044 */ +#line 3044 long i, j, ni; +#line 3044 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3044 double *xp; +#line 3044 int nrange = 0; /* number of range errors */ +#line 3044 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3044 long cxp = (long) *((char**)xpp); +#line 3044 +#line 3044 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3044 /* sjl: manually stripmine so we can limit amount of +#line 3044 * vector work space reserved to LOOPCNT elements. Also +#line 3044 * makes vectorisation easy */ +#line 3044 for (j=0; j X_DOUBLE_MAX; +#line 3044 } +#line 3044 /* copy workspace back if necessary */ +#line 3044 if (realign) { +#line 3044 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3044 xp = (double *) *xpp; +#line 3044 } +#line 3044 /* update xpp and tp */ +#line 3044 xp += ni; +#line 3044 tp += ni; +#line 3044 *xpp = (void*)xp; +#line 3044 } +#line 3044 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3044 +#line 3044 #else /* not SX */ +#line 3044 +#line 3044 char *xp = (char *) *xpp; +#line 3044 int status = ENOERR; +#line 3044 +#line 3044 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3044 { +#line 3044 int lstatus = ncx_put_double_float(xp, tp); +#line 3044 if(lstatus != ENOERR) +#line 3044 status = lstatus; +#line 3044 } +#line 3044 +#line 3044 *xpp = (void *)xp; +#line 3044 return status; +#line 3044 #endif +#line 3044 } +#line 3044 +#line 3046 int +#line 3046 ncx_putn_double_uint(void **xpp, size_t nelems, const uint *tp) +#line 3046 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3046 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3046 +#line 3046 /* basic algorithm is: +#line 3046 * - ensure sane alignment of output data +#line 3046 * - copy (conversion happens automatically) input data +#line 3046 * to output +#line 3046 * - update tp to point at next unconverted input, and xpp to point +#line 3046 * at next location for converted output +#line 3046 */ +#line 3046 long i, j, ni; +#line 3046 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3046 double *xp; +#line 3046 int nrange = 0; /* number of range errors */ +#line 3046 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3046 long cxp = (long) *((char**)xpp); +#line 3046 +#line 3046 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3046 /* sjl: manually stripmine so we can limit amount of +#line 3046 * vector work space reserved to LOOPCNT elements. Also +#line 3046 * makes vectorisation easy */ +#line 3046 for (j=0; j X_DOUBLE_MAX; +#line 3046 } +#line 3046 /* copy workspace back if necessary */ +#line 3046 if (realign) { +#line 3046 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3046 xp = (double *) *xpp; +#line 3046 } +#line 3046 /* update xpp and tp */ +#line 3046 xp += ni; +#line 3046 tp += ni; +#line 3046 *xpp = (void*)xp; +#line 3046 } +#line 3046 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3046 +#line 3046 #else /* not SX */ +#line 3046 +#line 3046 char *xp = (char *) *xpp; +#line 3046 int status = ENOERR; +#line 3046 +#line 3046 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3046 { +#line 3046 int lstatus = ncx_put_double_uint(xp, tp); +#line 3046 if(lstatus != ENOERR) +#line 3046 status = lstatus; +#line 3046 } +#line 3046 +#line 3046 *xpp = (void *)xp; +#line 3046 return status; +#line 3046 #endif +#line 3046 } +#line 3046 int +#line 3047 ncx_putn_double_longlong(void **xpp, size_t nelems, const longlong *tp) +#line 3047 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3047 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3047 +#line 3047 /* basic algorithm is: +#line 3047 * - ensure sane alignment of output data +#line 3047 * - copy (conversion happens automatically) input data +#line 3047 * to output +#line 3047 * - update tp to point at next unconverted input, and xpp to point +#line 3047 * at next location for converted output +#line 3047 */ +#line 3047 long i, j, ni; +#line 3047 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3047 double *xp; +#line 3047 int nrange = 0; /* number of range errors */ +#line 3047 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3047 long cxp = (long) *((char**)xpp); +#line 3047 +#line 3047 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3047 /* sjl: manually stripmine so we can limit amount of +#line 3047 * vector work space reserved to LOOPCNT elements. Also +#line 3047 * makes vectorisation easy */ +#line 3047 for (j=0; j X_DOUBLE_MAX; +#line 3047 } +#line 3047 /* copy workspace back if necessary */ +#line 3047 if (realign) { +#line 3047 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3047 xp = (double *) *xpp; +#line 3047 } +#line 3047 /* update xpp and tp */ +#line 3047 xp += ni; +#line 3047 tp += ni; +#line 3047 *xpp = (void*)xp; +#line 3047 } +#line 3047 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3047 +#line 3047 #else /* not SX */ +#line 3047 +#line 3047 char *xp = (char *) *xpp; +#line 3047 int status = ENOERR; +#line 3047 +#line 3047 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3047 { +#line 3047 int lstatus = ncx_put_double_longlong(xp, tp); +#line 3047 if(lstatus != ENOERR) +#line 3047 status = lstatus; +#line 3047 } +#line 3047 +#line 3047 *xpp = (void *)xp; +#line 3047 return status; +#line 3047 #endif +#line 3047 } +#line 3047 int +#line 3048 ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *tp) +#line 3048 { -#if _SX && \ - X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3048 +#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE +#line 3048 +#line 3048 /* basic algorithm is: +#line 3048 * - ensure sane alignment of output data +#line 3048 * - copy (conversion happens automatically) input data +#line 3048 * to output +#line 3048 * - update tp to point at next unconverted input, and xpp to point +#line 3048 * at next location for converted output +#line 3048 */ +#line 3048 long i, j, ni; +#line 3048 double tmp[LOOPCNT]; /* in case input is misaligned */ +#line 3048 double *xp; +#line 3048 int nrange = 0; /* number of range errors */ +#line 3048 int realign = 0; /* "do we need to fix input data alignment?" */ +#line 3048 long cxp = (long) *((char**)xpp); +#line 3048 +#line 3048 realign = (cxp & 7) % SIZEOF_DOUBLE; +#line 3048 /* sjl: manually stripmine so we can limit amount of +#line 3048 * vector work space reserved to LOOPCNT elements. Also +#line 3048 * makes vectorisation easy */ +#line 3048 for (j=0; j X_DOUBLE_MAX; +#line 3048 } +#line 3048 /* copy workspace back if necessary */ +#line 3048 if (realign) { +#line 3048 memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE); +#line 3048 xp = (double *) *xpp; +#line 3048 } +#line 3048 /* update xpp and tp */ +#line 3048 xp += ni; +#line 3048 tp += ni; +#line 3048 *xpp = (void*)xp; +#line 3048 } +#line 3048 return nrange == 0 ? ENOERR : NC_ERANGE; +#line 3048 +#line 3048 #else /* not SX */ +#line 3048 +#line 3048 char *xp = (char *) *xpp; +#line 3048 int status = ENOERR; +#line 3048 +#line 3048 for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++) +#line 3048 { +#line 3048 int lstatus = ncx_put_double_ulonglong(xp, tp); +#line 3048 if(lstatus != ENOERR) +#line 3048 status = lstatus; +#line 3048 } +#line 3048 +#line 3048 *xpp = (void *)xp; +#line 3048 return status; +#line 3048 #endif +#line 3048 } +#line 3048 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT) /* optimized version */ @@ -8185,64 +13951,123 @@ ncx_putn_double_double(void **xpp, size_t ndoubles, const double *ip) while(ip < end) { const struct vax_double *const vdp = +#line 3070 (const struct vax_double *)ip; +#line 3070 struct ieee_double *const idp = +#line 3070 (struct ieee_double *) (*xpp); +#line 3070 +#line 3070 if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) && +#line 3070 (vdp->mantissa3 == dbl_limits[0].d.mantissa3) && +#line 3070 (vdp->mantissa2 == dbl_limits[0].d.mantissa2) && +#line 3070 (vdp->mantissa1 == dbl_limits[0].d.mantissa1) && +#line 3070 (vdp->exp == dbl_limits[0].d.exp)) +#line 3070 { +#line 3070 *idp = dbl_limits[0].ieee; +#line 3070 goto shipit; +#line 3070 } +#line 3070 if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) && +#line 3070 (vdp->mantissa3 == dbl_limits[1].d.mantissa3) && +#line 3070 (vdp->mantissa2 == dbl_limits[1].d.mantissa2) && +#line 3070 (vdp->mantissa1 == dbl_limits[1].d.mantissa1) && +#line 3070 (vdp->exp == dbl_limits[1].d.exp)) +#line 3070 { +#line 3070 *idp = dbl_limits[1].ieee; +#line 3070 goto shipit; +#line 3070 } +#line 3070 +#line 3070 { +#line 3070 unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; +#line 3070 +#line 3070 unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) | +#line 3070 (vdp->mantissa3 << 13) | +#line 3070 ((vdp->mantissa4 >> 3) & MASK(13)); +#line 3070 +#line 3070 unsigned mant_hi = (vdp->mantissa1 << 13) +#line 3070 | (vdp->mantissa2 >> 3); +#line 3070 +#line 3070 if((vdp->mantissa4 & 7) > 4) +#line 3070 { +#line 3070 /* round up */ +#line 3070 mant_lo++; +#line 3070 if(mant_lo == 0) +#line 3070 { +#line 3070 mant_hi++; +#line 3070 if(mant_hi > 0xffffff) +#line 3070 { +#line 3070 mant_hi = 0; +#line 3070 exp++; +#line 3070 } +#line 3070 } +#line 3070 } +#line 3070 +#line 3070 idp->mant_lo = SWAP4(mant_lo); +#line 3070 idp->mant_6 = mant_hi >> 16; +#line 3070 idp->mant_5 = (mant_hi & 0xff00) >> 8; +#line 3070 idp->mant_4 = mant_hi; +#line 3070 idp->exp_hi = exp >> 4; +#line 3070 idp->exp_lo = exp; +#line 3070 } +#line 3070 +#line 3070 shipit: +#line 3070 idp->sign = vdp->sign; +#line 3070 ip++; *xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE; @@ -8281,8 +14106,11 @@ int ncx_getn_text(const void **xpp, size_t nelems, char *tp) { (void) memcpy(tp, *xpp, nelems); +#line 3107 *xpp = (void *)((char *)(*xpp) + nelems); +#line 3107 return ENOERR; +#line 3107 } @@ -8290,14 +14118,23 @@ int ncx_pad_getn_text(const void **xpp, size_t nelems, char *tp) { size_t rndup = nelems % X_ALIGN; +#line 3113 +#line 3113 if(rndup) +#line 3113 rndup = X_ALIGN - rndup; +#line 3113 +#line 3113 (void) memcpy(tp, *xpp, nelems); +#line 3113 *xpp = (void *)((char *)(*xpp) + nelems + rndup); +#line 3113 +#line 3113 return ENOERR; +#line 3113 } @@ -8305,9 +14142,13 @@ int ncx_putn_text(void **xpp, size_t nelems, const char *tp) { (void) memcpy(*xpp, tp, nelems); +#line 3119 *xpp = (void *)((char *)(*xpp) + nelems); +#line 3119 +#line 3119 return ENOERR; +#line 3119 } @@ -8315,20 +14156,35 @@ int ncx_pad_putn_text(void **xpp, size_t nelems, const char *tp) { size_t rndup = nelems % X_ALIGN; +#line 3125 +#line 3125 if(rndup) +#line 3125 rndup = X_ALIGN - rndup; +#line 3125 +#line 3125 (void) memcpy(*xpp, tp, nelems); +#line 3125 *xpp = (void *)((char *)(*xpp) + nelems); +#line 3125 +#line 3125 if(rndup) +#line 3125 { +#line 3125 (void) memcpy(*xpp, nada, rndup); +#line 3125 *xpp = (void *)((char *)(*xpp) + rndup); +#line 3125 } +#line 3125 +#line 3125 return ENOERR; +#line 3125 } @@ -8339,8 +14195,11 @@ int ncx_getn_void(const void **xpp, size_t nelems, void *tp) { (void) memcpy(tp, *xpp, nelems); +#line 3134 *xpp = (void *)((char *)(*xpp) + nelems); +#line 3134 return ENOERR; +#line 3134 } @@ -8348,14 +14207,23 @@ int ncx_pad_getn_void(const void **xpp, size_t nelems, void *tp) { size_t rndup = nelems % X_ALIGN; +#line 3140 +#line 3140 if(rndup) +#line 3140 rndup = X_ALIGN - rndup; +#line 3140 +#line 3140 (void) memcpy(tp, *xpp, nelems); +#line 3140 *xpp = (void *)((char *)(*xpp) + nelems + rndup); +#line 3140 +#line 3140 return ENOERR; +#line 3140 } @@ -8363,9 +14231,13 @@ int ncx_putn_void(void **xpp, size_t nelems, const void *tp) { (void) memcpy(*xpp, tp, nelems); +#line 3146 *xpp = (void *)((char *)(*xpp) + nelems); +#line 3146 +#line 3146 return ENOERR; +#line 3146 } @@ -8373,19 +14245,34 @@ int ncx_pad_putn_void(void **xpp, size_t nelems, const void *tp) { size_t rndup = nelems % X_ALIGN; +#line 3152 +#line 3152 if(rndup) +#line 3152 rndup = X_ALIGN - rndup; +#line 3152 +#line 3152 (void) memcpy(*xpp, tp, nelems); +#line 3152 *xpp = (void *)((char *)(*xpp) + nelems); +#line 3152 +#line 3152 if(rndup) +#line 3152 { +#line 3152 (void) memcpy(*xpp, nada, rndup); +#line 3152 *xpp = (void *)((char *)(*xpp) + rndup); +#line 3152 } +#line 3152 +#line 3152 return ENOERR; +#line 3152 } diff --git a/libsrc/putget.c b/libsrc/putget.c index 3add44aaf..6520b926b 100644 --- a/libsrc/putget.c +++ b/libsrc/putget.c @@ -1,4 +1,6 @@ +#line 9 "../../libsrc/putget.m4" /* Do not edit this file. It is produced from the corresponding .m4 source */ +#line 11 /* * Copyright 1996, University Corporation for Atmospheric Research * See netcdf/COPYRIGHT file for copying and redistribution conditions. @@ -70,6 +72,7 @@ arrayp(const char *label, size_t count, const size_t *array) #endif +#line 107 /* * Next 6 type specific functions @@ -78,151 +81,284 @@ arrayp(const char *label, size_t count, const size_t *array) NC_arrayfill() */ static int +#line 114 NC_fill_schar( +#line 114 void **xpp, +#line 114 size_t nelems) /* how many */ +#line 114 { +#line 114 schar fillp[NFILL * sizeof(double)/X_SIZEOF_CHAR]; +#line 114 +#line 114 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 114 +#line 114 { +#line 114 schar *vp = fillp; /* lower bound of area to be filled */ +#line 114 const schar *const end = vp + nelems; +#line 114 while(vp < end) +#line 114 { +#line 114 *vp++ = NC_FILL_BYTE; +#line 114 } +#line 114 } +#line 114 return ncx_putn_schar_schar(xpp, nelems, fillp); +#line 114 } +#line 114 static int +#line 115 NC_fill_char( +#line 115 void **xpp, +#line 115 size_t nelems) /* how many */ +#line 115 { +#line 115 char fillp[NFILL * sizeof(double)/X_SIZEOF_CHAR]; +#line 115 +#line 115 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 115 +#line 115 { +#line 115 char *vp = fillp; /* lower bound of area to be filled */ +#line 115 const char *const end = vp + nelems; +#line 115 while(vp < end) +#line 115 { +#line 115 *vp++ = NC_FILL_CHAR; +#line 115 } +#line 115 } +#line 115 return ncx_putn_char_char(xpp, nelems, fillp); +#line 115 } +#line 115 static int +#line 116 NC_fill_short( +#line 116 void **xpp, +#line 116 size_t nelems) /* how many */ +#line 116 { +#line 116 short fillp[NFILL * sizeof(double)/X_SIZEOF_SHORT]; +#line 116 +#line 116 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 116 +#line 116 { +#line 116 short *vp = fillp; /* lower bound of area to be filled */ +#line 116 const short *const end = vp + nelems; +#line 116 while(vp < end) +#line 116 { +#line 116 *vp++ = NC_FILL_SHORT; +#line 116 } +#line 116 } +#line 116 return ncx_putn_short_short(xpp, nelems, fillp); +#line 116 } +#line 116 #if (SIZEOF_INT >= X_SIZEOF_INT) static int +#line 119 NC_fill_int( +#line 119 void **xpp, +#line 119 size_t nelems) /* how many */ +#line 119 { +#line 119 int fillp[NFILL * sizeof(double)/X_SIZEOF_INT]; +#line 119 +#line 119 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 119 +#line 119 { +#line 119 int *vp = fillp; /* lower bound of area to be filled */ +#line 119 const int *const end = vp + nelems; +#line 119 while(vp < end) +#line 119 { +#line 119 *vp++ = NC_FILL_INT; +#line 119 } +#line 119 } +#line 119 return ncx_putn_int_int(xpp, nelems, fillp); +#line 119 } +#line 119 #elif SIZEOF_LONG == X_SIZEOF_INT static int +#line 121 NC_fill_int( +#line 121 void **xpp, +#line 121 size_t nelems) /* how many */ +#line 121 { +#line 121 long fillp[NFILL * sizeof(double)/X_SIZEOF_INT]; +#line 121 +#line 121 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 121 +#line 121 { +#line 121 long *vp = fillp; /* lower bound of area to be filled */ +#line 121 const long *const end = vp + nelems; +#line 121 while(vp < end) +#line 121 { +#line 121 *vp++ = NC_FILL_INT; +#line 121 } +#line 121 } +#line 121 return ncx_putn_int_long(xpp, nelems, fillp); +#line 121 } +#line 121 #else #error "NC_fill_int implementation" #endif static int +#line 126 NC_fill_float( +#line 126 void **xpp, +#line 126 size_t nelems) /* how many */ +#line 126 { +#line 126 float fillp[NFILL * sizeof(double)/X_SIZEOF_FLOAT]; +#line 126 +#line 126 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 126 +#line 126 { +#line 126 float *vp = fillp; /* lower bound of area to be filled */ +#line 126 const float *const end = vp + nelems; +#line 126 while(vp < end) +#line 126 { +#line 126 *vp++ = NC_FILL_FLOAT; +#line 126 } +#line 126 } +#line 126 return ncx_putn_float_float(xpp, nelems, fillp); +#line 126 } +#line 126 static int +#line 127 NC_fill_double( +#line 127 void **xpp, +#line 127 size_t nelems) /* how many */ +#line 127 { +#line 127 double fillp[NFILL * sizeof(double)/X_SIZEOF_DOUBLE]; +#line 127 +#line 127 assert(nelems <= sizeof(fillp)/sizeof(fillp[0])); +#line 127 +#line 127 { +#line 127 double *vp = fillp; /* lower bound of area to be filled */ +#line 127 const double *const end = vp + nelems; +#line 127 while(vp < end) +#line 127 { +#line 127 *vp++ = NC_FILL_DOUBLE; +#line 127 } +#line 127 } +#line 127 return ncx_putn_double_double(xpp, nelems, fillp); +#line 127 } +#line 127 @@ -741,3933 +877,7755 @@ NC_varoffset(const NC3_INFO* ncp, const NC_var *varp, const size_t *coord) } +#line 700 static int +#line 701 putNCvx_char_char(NC3_INFO* ncp, const NC_var *varp, +#line 701 const size_t *start, size_t nelems, const char *value) +#line 701 { +#line 701 off_t offset = NC_varoffset(ncp, varp, start); +#line 701 size_t remaining = varp->xsz * nelems; +#line 701 int status = NC_NOERR; +#line 701 void *xp; +#line 701 +#line 701 if(nelems == 0) +#line 701 return NC_NOERR; +#line 701 +#line 701 assert(value != NULL); +#line 701 +#line 701 for(;;) +#line 701 { +#line 701 size_t extent = MIN(remaining, ncp->chunk); +#line 701 size_t nput = ncx_howmany(varp->type, extent); +#line 701 +#line 701 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 701 RGN_WRITE, &xp); +#line 701 if(lstatus != NC_NOERR) +#line 701 return lstatus; +#line 701 +#line 701 lstatus = ncx_putn_char_char(&xp, nput, value); +#line 701 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 701 { +#line 701 /* not fatal to the loop */ +#line 701 status = lstatus; +#line 701 } +#line 701 +#line 701 (void) ncio_rel(ncp->nciop, offset, +#line 701 RGN_MODIFIED); +#line 701 +#line 701 remaining -= extent; +#line 701 if(remaining == 0) +#line 701 break; /* normal loop exit */ +#line 701 offset += extent; +#line 701 value += nput; +#line 701 +#line 701 } +#line 701 +#line 701 return status; +#line 701 } +#line 701 static int +#line 703 putNCvx_schar_schar(NC3_INFO* ncp, const NC_var *varp, +#line 703 const size_t *start, size_t nelems, const schar *value) +#line 703 { +#line 703 off_t offset = NC_varoffset(ncp, varp, start); +#line 703 size_t remaining = varp->xsz * nelems; +#line 703 int status = NC_NOERR; +#line 703 void *xp; +#line 703 +#line 703 if(nelems == 0) +#line 703 return NC_NOERR; +#line 703 +#line 703 assert(value != NULL); +#line 703 +#line 703 for(;;) +#line 703 { +#line 703 size_t extent = MIN(remaining, ncp->chunk); +#line 703 size_t nput = ncx_howmany(varp->type, extent); +#line 703 +#line 703 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 703 RGN_WRITE, &xp); +#line 703 if(lstatus != NC_NOERR) +#line 703 return lstatus; +#line 703 +#line 703 lstatus = ncx_putn_schar_schar(&xp, nput, value); +#line 703 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 703 { +#line 703 /* not fatal to the loop */ +#line 703 status = lstatus; +#line 703 } +#line 703 +#line 703 (void) ncio_rel(ncp->nciop, offset, +#line 703 RGN_MODIFIED); +#line 703 +#line 703 remaining -= extent; +#line 703 if(remaining == 0) +#line 703 break; /* normal loop exit */ +#line 703 offset += extent; +#line 703 value += nput; +#line 703 +#line 703 } +#line 703 +#line 703 return status; +#line 703 } +#line 703 static int +#line 704 putNCvx_schar_uchar(NC3_INFO* ncp, const NC_var *varp, +#line 704 const size_t *start, size_t nelems, const uchar *value) +#line 704 { +#line 704 off_t offset = NC_varoffset(ncp, varp, start); +#line 704 size_t remaining = varp->xsz * nelems; +#line 704 int status = NC_NOERR; +#line 704 void *xp; +#line 704 +#line 704 if(nelems == 0) +#line 704 return NC_NOERR; +#line 704 +#line 704 assert(value != NULL); +#line 704 +#line 704 for(;;) +#line 704 { +#line 704 size_t extent = MIN(remaining, ncp->chunk); +#line 704 size_t nput = ncx_howmany(varp->type, extent); +#line 704 +#line 704 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 704 RGN_WRITE, &xp); +#line 704 if(lstatus != NC_NOERR) +#line 704 return lstatus; +#line 704 +#line 704 lstatus = ncx_putn_schar_uchar(&xp, nput, value); +#line 704 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 704 { +#line 704 /* not fatal to the loop */ +#line 704 status = lstatus; +#line 704 } +#line 704 +#line 704 (void) ncio_rel(ncp->nciop, offset, +#line 704 RGN_MODIFIED); +#line 704 +#line 704 remaining -= extent; +#line 704 if(remaining == 0) +#line 704 break; /* normal loop exit */ +#line 704 offset += extent; +#line 704 value += nput; +#line 704 +#line 704 } +#line 704 +#line 704 return status; +#line 704 } +#line 704 static int +#line 705 putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp, +#line 705 const size_t *start, size_t nelems, const short *value) +#line 705 { +#line 705 off_t offset = NC_varoffset(ncp, varp, start); +#line 705 size_t remaining = varp->xsz * nelems; +#line 705 int status = NC_NOERR; +#line 705 void *xp; +#line 705 +#line 705 if(nelems == 0) +#line 705 return NC_NOERR; +#line 705 +#line 705 assert(value != NULL); +#line 705 +#line 705 for(;;) +#line 705 { +#line 705 size_t extent = MIN(remaining, ncp->chunk); +#line 705 size_t nput = ncx_howmany(varp->type, extent); +#line 705 +#line 705 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 705 RGN_WRITE, &xp); +#line 705 if(lstatus != NC_NOERR) +#line 705 return lstatus; +#line 705 +#line 705 lstatus = ncx_putn_schar_short(&xp, nput, value); +#line 705 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 705 { +#line 705 /* not fatal to the loop */ +#line 705 status = lstatus; +#line 705 } +#line 705 +#line 705 (void) ncio_rel(ncp->nciop, offset, +#line 705 RGN_MODIFIED); +#line 705 +#line 705 remaining -= extent; +#line 705 if(remaining == 0) +#line 705 break; /* normal loop exit */ +#line 705 offset += extent; +#line 705 value += nput; +#line 705 +#line 705 } +#line 705 +#line 705 return status; +#line 705 } +#line 705 static int +#line 706 putNCvx_schar_int(NC3_INFO* ncp, const NC_var *varp, +#line 706 const size_t *start, size_t nelems, const int *value) +#line 706 { +#line 706 off_t offset = NC_varoffset(ncp, varp, start); +#line 706 size_t remaining = varp->xsz * nelems; +#line 706 int status = NC_NOERR; +#line 706 void *xp; +#line 706 +#line 706 if(nelems == 0) +#line 706 return NC_NOERR; +#line 706 +#line 706 assert(value != NULL); +#line 706 +#line 706 for(;;) +#line 706 { +#line 706 size_t extent = MIN(remaining, ncp->chunk); +#line 706 size_t nput = ncx_howmany(varp->type, extent); +#line 706 +#line 706 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 706 RGN_WRITE, &xp); +#line 706 if(lstatus != NC_NOERR) +#line 706 return lstatus; +#line 706 +#line 706 lstatus = ncx_putn_schar_int(&xp, nput, value); +#line 706 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 706 { +#line 706 /* not fatal to the loop */ +#line 706 status = lstatus; +#line 706 } +#line 706 +#line 706 (void) ncio_rel(ncp->nciop, offset, +#line 706 RGN_MODIFIED); +#line 706 +#line 706 remaining -= extent; +#line 706 if(remaining == 0) +#line 706 break; /* normal loop exit */ +#line 706 offset += extent; +#line 706 value += nput; +#line 706 +#line 706 } +#line 706 +#line 706 return status; +#line 706 } +#line 706 static int +#line 707 putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp, +#line 707 const size_t *start, size_t nelems, const float *value) +#line 707 { +#line 707 off_t offset = NC_varoffset(ncp, varp, start); +#line 707 size_t remaining = varp->xsz * nelems; +#line 707 int status = NC_NOERR; +#line 707 void *xp; +#line 707 +#line 707 if(nelems == 0) +#line 707 return NC_NOERR; +#line 707 +#line 707 assert(value != NULL); +#line 707 +#line 707 for(;;) +#line 707 { +#line 707 size_t extent = MIN(remaining, ncp->chunk); +#line 707 size_t nput = ncx_howmany(varp->type, extent); +#line 707 +#line 707 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 707 RGN_WRITE, &xp); +#line 707 if(lstatus != NC_NOERR) +#line 707 return lstatus; +#line 707 +#line 707 lstatus = ncx_putn_schar_float(&xp, nput, value); +#line 707 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 707 { +#line 707 /* not fatal to the loop */ +#line 707 status = lstatus; +#line 707 } +#line 707 +#line 707 (void) ncio_rel(ncp->nciop, offset, +#line 707 RGN_MODIFIED); +#line 707 +#line 707 remaining -= extent; +#line 707 if(remaining == 0) +#line 707 break; /* normal loop exit */ +#line 707 offset += extent; +#line 707 value += nput; +#line 707 +#line 707 } +#line 707 +#line 707 return status; +#line 707 } +#line 707 static int +#line 708 putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp, +#line 708 const size_t *start, size_t nelems, const double *value) +#line 708 { +#line 708 off_t offset = NC_varoffset(ncp, varp, start); +#line 708 size_t remaining = varp->xsz * nelems; +#line 708 int status = NC_NOERR; +#line 708 void *xp; +#line 708 +#line 708 if(nelems == 0) +#line 708 return NC_NOERR; +#line 708 +#line 708 assert(value != NULL); +#line 708 +#line 708 for(;;) +#line 708 { +#line 708 size_t extent = MIN(remaining, ncp->chunk); +#line 708 size_t nput = ncx_howmany(varp->type, extent); +#line 708 +#line 708 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 708 RGN_WRITE, &xp); +#line 708 if(lstatus != NC_NOERR) +#line 708 return lstatus; +#line 708 +#line 708 lstatus = ncx_putn_schar_double(&xp, nput, value); +#line 708 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 708 { +#line 708 /* not fatal to the loop */ +#line 708 status = lstatus; +#line 708 } +#line 708 +#line 708 (void) ncio_rel(ncp->nciop, offset, +#line 708 RGN_MODIFIED); +#line 708 +#line 708 remaining -= extent; +#line 708 if(remaining == 0) +#line 708 break; /* normal loop exit */ +#line 708 offset += extent; +#line 708 value += nput; +#line 708 +#line 708 } +#line 708 +#line 708 return status; +#line 708 } +#line 708 static int +#line 709 putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp, +#line 709 const size_t *start, size_t nelems, const longlong *value) +#line 709 { +#line 709 off_t offset = NC_varoffset(ncp, varp, start); +#line 709 size_t remaining = varp->xsz * nelems; +#line 709 int status = NC_NOERR; +#line 709 void *xp; +#line 709 +#line 709 if(nelems == 0) +#line 709 return NC_NOERR; +#line 709 +#line 709 assert(value != NULL); +#line 709 +#line 709 for(;;) +#line 709 { +#line 709 size_t extent = MIN(remaining, ncp->chunk); +#line 709 size_t nput = ncx_howmany(varp->type, extent); +#line 709 +#line 709 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 709 RGN_WRITE, &xp); +#line 709 if(lstatus != NC_NOERR) +#line 709 return lstatus; +#line 709 +#line 709 lstatus = ncx_putn_schar_longlong(&xp, nput, value); +#line 709 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 709 { +#line 709 /* not fatal to the loop */ +#line 709 status = lstatus; +#line 709 } +#line 709 +#line 709 (void) ncio_rel(ncp->nciop, offset, +#line 709 RGN_MODIFIED); +#line 709 +#line 709 remaining -= extent; +#line 709 if(remaining == 0) +#line 709 break; /* normal loop exit */ +#line 709 offset += extent; +#line 709 value += nput; +#line 709 +#line 709 } +#line 709 +#line 709 return status; +#line 709 } +#line 709 static int +#line 711 putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp, +#line 711 const size_t *start, size_t nelems, const schar *value) +#line 711 { +#line 711 off_t offset = NC_varoffset(ncp, varp, start); +#line 711 size_t remaining = varp->xsz * nelems; +#line 711 int status = NC_NOERR; +#line 711 void *xp; +#line 711 +#line 711 if(nelems == 0) +#line 711 return NC_NOERR; +#line 711 +#line 711 assert(value != NULL); +#line 711 +#line 711 for(;;) +#line 711 { +#line 711 size_t extent = MIN(remaining, ncp->chunk); +#line 711 size_t nput = ncx_howmany(varp->type, extent); +#line 711 +#line 711 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 711 RGN_WRITE, &xp); +#line 711 if(lstatus != NC_NOERR) +#line 711 return lstatus; +#line 711 +#line 711 lstatus = ncx_putn_short_schar(&xp, nput, value); +#line 711 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 711 { +#line 711 /* not fatal to the loop */ +#line 711 status = lstatus; +#line 711 } +#line 711 +#line 711 (void) ncio_rel(ncp->nciop, offset, +#line 711 RGN_MODIFIED); +#line 711 +#line 711 remaining -= extent; +#line 711 if(remaining == 0) +#line 711 break; /* normal loop exit */ +#line 711 offset += extent; +#line 711 value += nput; +#line 711 +#line 711 } +#line 711 +#line 711 return status; +#line 711 } +#line 711 static int +#line 712 putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp, +#line 712 const size_t *start, size_t nelems, const uchar *value) +#line 712 { +#line 712 off_t offset = NC_varoffset(ncp, varp, start); +#line 712 size_t remaining = varp->xsz * nelems; +#line 712 int status = NC_NOERR; +#line 712 void *xp; +#line 712 +#line 712 if(nelems == 0) +#line 712 return NC_NOERR; +#line 712 +#line 712 assert(value != NULL); +#line 712 +#line 712 for(;;) +#line 712 { +#line 712 size_t extent = MIN(remaining, ncp->chunk); +#line 712 size_t nput = ncx_howmany(varp->type, extent); +#line 712 +#line 712 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 712 RGN_WRITE, &xp); +#line 712 if(lstatus != NC_NOERR) +#line 712 return lstatus; +#line 712 +#line 712 lstatus = ncx_putn_short_uchar(&xp, nput, value); +#line 712 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 712 { +#line 712 /* not fatal to the loop */ +#line 712 status = lstatus; +#line 712 } +#line 712 +#line 712 (void) ncio_rel(ncp->nciop, offset, +#line 712 RGN_MODIFIED); +#line 712 +#line 712 remaining -= extent; +#line 712 if(remaining == 0) +#line 712 break; /* normal loop exit */ +#line 712 offset += extent; +#line 712 value += nput; +#line 712 +#line 712 } +#line 712 +#line 712 return status; +#line 712 } +#line 712 static int +#line 713 putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp, +#line 713 const size_t *start, size_t nelems, const short *value) +#line 713 { +#line 713 off_t offset = NC_varoffset(ncp, varp, start); +#line 713 size_t remaining = varp->xsz * nelems; +#line 713 int status = NC_NOERR; +#line 713 void *xp; +#line 713 +#line 713 if(nelems == 0) +#line 713 return NC_NOERR; +#line 713 +#line 713 assert(value != NULL); +#line 713 +#line 713 for(;;) +#line 713 { +#line 713 size_t extent = MIN(remaining, ncp->chunk); +#line 713 size_t nput = ncx_howmany(varp->type, extent); +#line 713 +#line 713 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 713 RGN_WRITE, &xp); +#line 713 if(lstatus != NC_NOERR) +#line 713 return lstatus; +#line 713 +#line 713 lstatus = ncx_putn_short_short(&xp, nput, value); +#line 713 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 713 { +#line 713 /* not fatal to the loop */ +#line 713 status = lstatus; +#line 713 } +#line 713 +#line 713 (void) ncio_rel(ncp->nciop, offset, +#line 713 RGN_MODIFIED); +#line 713 +#line 713 remaining -= extent; +#line 713 if(remaining == 0) +#line 713 break; /* normal loop exit */ +#line 713 offset += extent; +#line 713 value += nput; +#line 713 +#line 713 } +#line 713 +#line 713 return status; +#line 713 } +#line 713 static int +#line 714 putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp, +#line 714 const size_t *start, size_t nelems, const int *value) +#line 714 { +#line 714 off_t offset = NC_varoffset(ncp, varp, start); +#line 714 size_t remaining = varp->xsz * nelems; +#line 714 int status = NC_NOERR; +#line 714 void *xp; +#line 714 +#line 714 if(nelems == 0) +#line 714 return NC_NOERR; +#line 714 +#line 714 assert(value != NULL); +#line 714 +#line 714 for(;;) +#line 714 { +#line 714 size_t extent = MIN(remaining, ncp->chunk); +#line 714 size_t nput = ncx_howmany(varp->type, extent); +#line 714 +#line 714 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 714 RGN_WRITE, &xp); +#line 714 if(lstatus != NC_NOERR) +#line 714 return lstatus; +#line 714 +#line 714 lstatus = ncx_putn_short_int(&xp, nput, value); +#line 714 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 714 { +#line 714 /* not fatal to the loop */ +#line 714 status = lstatus; +#line 714 } +#line 714 +#line 714 (void) ncio_rel(ncp->nciop, offset, +#line 714 RGN_MODIFIED); +#line 714 +#line 714 remaining -= extent; +#line 714 if(remaining == 0) +#line 714 break; /* normal loop exit */ +#line 714 offset += extent; +#line 714 value += nput; +#line 714 +#line 714 } +#line 714 +#line 714 return status; +#line 714 } +#line 714 static int +#line 715 putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp, +#line 715 const size_t *start, size_t nelems, const float *value) +#line 715 { +#line 715 off_t offset = NC_varoffset(ncp, varp, start); +#line 715 size_t remaining = varp->xsz * nelems; +#line 715 int status = NC_NOERR; +#line 715 void *xp; +#line 715 +#line 715 if(nelems == 0) +#line 715 return NC_NOERR; +#line 715 +#line 715 assert(value != NULL); +#line 715 +#line 715 for(;;) +#line 715 { +#line 715 size_t extent = MIN(remaining, ncp->chunk); +#line 715 size_t nput = ncx_howmany(varp->type, extent); +#line 715 +#line 715 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 715 RGN_WRITE, &xp); +#line 715 if(lstatus != NC_NOERR) +#line 715 return lstatus; +#line 715 +#line 715 lstatus = ncx_putn_short_float(&xp, nput, value); +#line 715 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 715 { +#line 715 /* not fatal to the loop */ +#line 715 status = lstatus; +#line 715 } +#line 715 +#line 715 (void) ncio_rel(ncp->nciop, offset, +#line 715 RGN_MODIFIED); +#line 715 +#line 715 remaining -= extent; +#line 715 if(remaining == 0) +#line 715 break; /* normal loop exit */ +#line 715 offset += extent; +#line 715 value += nput; +#line 715 +#line 715 } +#line 715 +#line 715 return status; +#line 715 } +#line 715 static int +#line 716 putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp, +#line 716 const size_t *start, size_t nelems, const double *value) +#line 716 { +#line 716 off_t offset = NC_varoffset(ncp, varp, start); +#line 716 size_t remaining = varp->xsz * nelems; +#line 716 int status = NC_NOERR; +#line 716 void *xp; +#line 716 +#line 716 if(nelems == 0) +#line 716 return NC_NOERR; +#line 716 +#line 716 assert(value != NULL); +#line 716 +#line 716 for(;;) +#line 716 { +#line 716 size_t extent = MIN(remaining, ncp->chunk); +#line 716 size_t nput = ncx_howmany(varp->type, extent); +#line 716 +#line 716 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 716 RGN_WRITE, &xp); +#line 716 if(lstatus != NC_NOERR) +#line 716 return lstatus; +#line 716 +#line 716 lstatus = ncx_putn_short_double(&xp, nput, value); +#line 716 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 716 { +#line 716 /* not fatal to the loop */ +#line 716 status = lstatus; +#line 716 } +#line 716 +#line 716 (void) ncio_rel(ncp->nciop, offset, +#line 716 RGN_MODIFIED); +#line 716 +#line 716 remaining -= extent; +#line 716 if(remaining == 0) +#line 716 break; /* normal loop exit */ +#line 716 offset += extent; +#line 716 value += nput; +#line 716 +#line 716 } +#line 716 +#line 716 return status; +#line 716 } +#line 716 static int +#line 717 putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp, +#line 717 const size_t *start, size_t nelems, const longlong *value) +#line 717 { +#line 717 off_t offset = NC_varoffset(ncp, varp, start); +#line 717 size_t remaining = varp->xsz * nelems; +#line 717 int status = NC_NOERR; +#line 717 void *xp; +#line 717 +#line 717 if(nelems == 0) +#line 717 return NC_NOERR; +#line 717 +#line 717 assert(value != NULL); +#line 717 +#line 717 for(;;) +#line 717 { +#line 717 size_t extent = MIN(remaining, ncp->chunk); +#line 717 size_t nput = ncx_howmany(varp->type, extent); +#line 717 +#line 717 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 717 RGN_WRITE, &xp); +#line 717 if(lstatus != NC_NOERR) +#line 717 return lstatus; +#line 717 +#line 717 lstatus = ncx_putn_short_longlong(&xp, nput, value); +#line 717 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 717 { +#line 717 /* not fatal to the loop */ +#line 717 status = lstatus; +#line 717 } +#line 717 +#line 717 (void) ncio_rel(ncp->nciop, offset, +#line 717 RGN_MODIFIED); +#line 717 +#line 717 remaining -= extent; +#line 717 if(remaining == 0) +#line 717 break; /* normal loop exit */ +#line 717 offset += extent; +#line 717 value += nput; +#line 717 +#line 717 } +#line 717 +#line 717 return status; +#line 717 } +#line 717 static int +#line 719 putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp, +#line 719 const size_t *start, size_t nelems, const schar *value) +#line 719 { +#line 719 off_t offset = NC_varoffset(ncp, varp, start); +#line 719 size_t remaining = varp->xsz * nelems; +#line 719 int status = NC_NOERR; +#line 719 void *xp; +#line 719 +#line 719 if(nelems == 0) +#line 719 return NC_NOERR; +#line 719 +#line 719 assert(value != NULL); +#line 719 +#line 719 for(;;) +#line 719 { +#line 719 size_t extent = MIN(remaining, ncp->chunk); +#line 719 size_t nput = ncx_howmany(varp->type, extent); +#line 719 +#line 719 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 719 RGN_WRITE, &xp); +#line 719 if(lstatus != NC_NOERR) +#line 719 return lstatus; +#line 719 +#line 719 lstatus = ncx_putn_int_schar(&xp, nput, value); +#line 719 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 719 { +#line 719 /* not fatal to the loop */ +#line 719 status = lstatus; +#line 719 } +#line 719 +#line 719 (void) ncio_rel(ncp->nciop, offset, +#line 719 RGN_MODIFIED); +#line 719 +#line 719 remaining -= extent; +#line 719 if(remaining == 0) +#line 719 break; /* normal loop exit */ +#line 719 offset += extent; +#line 719 value += nput; +#line 719 +#line 719 } +#line 719 +#line 719 return status; +#line 719 } +#line 719 static int +#line 720 putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp, +#line 720 const size_t *start, size_t nelems, const uchar *value) +#line 720 { +#line 720 off_t offset = NC_varoffset(ncp, varp, start); +#line 720 size_t remaining = varp->xsz * nelems; +#line 720 int status = NC_NOERR; +#line 720 void *xp; +#line 720 +#line 720 if(nelems == 0) +#line 720 return NC_NOERR; +#line 720 +#line 720 assert(value != NULL); +#line 720 +#line 720 for(;;) +#line 720 { +#line 720 size_t extent = MIN(remaining, ncp->chunk); +#line 720 size_t nput = ncx_howmany(varp->type, extent); +#line 720 +#line 720 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 720 RGN_WRITE, &xp); +#line 720 if(lstatus != NC_NOERR) +#line 720 return lstatus; +#line 720 +#line 720 lstatus = ncx_putn_int_uchar(&xp, nput, value); +#line 720 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 720 { +#line 720 /* not fatal to the loop */ +#line 720 status = lstatus; +#line 720 } +#line 720 +#line 720 (void) ncio_rel(ncp->nciop, offset, +#line 720 RGN_MODIFIED); +#line 720 +#line 720 remaining -= extent; +#line 720 if(remaining == 0) +#line 720 break; /* normal loop exit */ +#line 720 offset += extent; +#line 720 value += nput; +#line 720 +#line 720 } +#line 720 +#line 720 return status; +#line 720 } +#line 720 static int +#line 721 putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp, +#line 721 const size_t *start, size_t nelems, const short *value) +#line 721 { +#line 721 off_t offset = NC_varoffset(ncp, varp, start); +#line 721 size_t remaining = varp->xsz * nelems; +#line 721 int status = NC_NOERR; +#line 721 void *xp; +#line 721 +#line 721 if(nelems == 0) +#line 721 return NC_NOERR; +#line 721 +#line 721 assert(value != NULL); +#line 721 +#line 721 for(;;) +#line 721 { +#line 721 size_t extent = MIN(remaining, ncp->chunk); +#line 721 size_t nput = ncx_howmany(varp->type, extent); +#line 721 +#line 721 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 721 RGN_WRITE, &xp); +#line 721 if(lstatus != NC_NOERR) +#line 721 return lstatus; +#line 721 +#line 721 lstatus = ncx_putn_int_short(&xp, nput, value); +#line 721 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 721 { +#line 721 /* not fatal to the loop */ +#line 721 status = lstatus; +#line 721 } +#line 721 +#line 721 (void) ncio_rel(ncp->nciop, offset, +#line 721 RGN_MODIFIED); +#line 721 +#line 721 remaining -= extent; +#line 721 if(remaining == 0) +#line 721 break; /* normal loop exit */ +#line 721 offset += extent; +#line 721 value += nput; +#line 721 +#line 721 } +#line 721 +#line 721 return status; +#line 721 } +#line 721 static int +#line 722 putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp, +#line 722 const size_t *start, size_t nelems, const int *value) +#line 722 { +#line 722 off_t offset = NC_varoffset(ncp, varp, start); +#line 722 size_t remaining = varp->xsz * nelems; +#line 722 int status = NC_NOERR; +#line 722 void *xp; +#line 722 +#line 722 if(nelems == 0) +#line 722 return NC_NOERR; +#line 722 +#line 722 assert(value != NULL); +#line 722 +#line 722 for(;;) +#line 722 { +#line 722 size_t extent = MIN(remaining, ncp->chunk); +#line 722 size_t nput = ncx_howmany(varp->type, extent); +#line 722 +#line 722 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 722 RGN_WRITE, &xp); +#line 722 if(lstatus != NC_NOERR) +#line 722 return lstatus; +#line 722 +#line 722 lstatus = ncx_putn_int_int(&xp, nput, value); +#line 722 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 722 { +#line 722 /* not fatal to the loop */ +#line 722 status = lstatus; +#line 722 } +#line 722 +#line 722 (void) ncio_rel(ncp->nciop, offset, +#line 722 RGN_MODIFIED); +#line 722 +#line 722 remaining -= extent; +#line 722 if(remaining == 0) +#line 722 break; /* normal loop exit */ +#line 722 offset += extent; +#line 722 value += nput; +#line 722 +#line 722 } +#line 722 +#line 722 return status; +#line 722 } +#line 722 static int +#line 723 putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp, +#line 723 const size_t *start, size_t nelems, const float *value) +#line 723 { +#line 723 off_t offset = NC_varoffset(ncp, varp, start); +#line 723 size_t remaining = varp->xsz * nelems; +#line 723 int status = NC_NOERR; +#line 723 void *xp; +#line 723 +#line 723 if(nelems == 0) +#line 723 return NC_NOERR; +#line 723 +#line 723 assert(value != NULL); +#line 723 +#line 723 for(;;) +#line 723 { +#line 723 size_t extent = MIN(remaining, ncp->chunk); +#line 723 size_t nput = ncx_howmany(varp->type, extent); +#line 723 +#line 723 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 723 RGN_WRITE, &xp); +#line 723 if(lstatus != NC_NOERR) +#line 723 return lstatus; +#line 723 +#line 723 lstatus = ncx_putn_int_float(&xp, nput, value); +#line 723 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 723 { +#line 723 /* not fatal to the loop */ +#line 723 status = lstatus; +#line 723 } +#line 723 +#line 723 (void) ncio_rel(ncp->nciop, offset, +#line 723 RGN_MODIFIED); +#line 723 +#line 723 remaining -= extent; +#line 723 if(remaining == 0) +#line 723 break; /* normal loop exit */ +#line 723 offset += extent; +#line 723 value += nput; +#line 723 +#line 723 } +#line 723 +#line 723 return status; +#line 723 } +#line 723 static int +#line 724 putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp, +#line 724 const size_t *start, size_t nelems, const double *value) +#line 724 { +#line 724 off_t offset = NC_varoffset(ncp, varp, start); +#line 724 size_t remaining = varp->xsz * nelems; +#line 724 int status = NC_NOERR; +#line 724 void *xp; +#line 724 +#line 724 if(nelems == 0) +#line 724 return NC_NOERR; +#line 724 +#line 724 assert(value != NULL); +#line 724 +#line 724 for(;;) +#line 724 { +#line 724 size_t extent = MIN(remaining, ncp->chunk); +#line 724 size_t nput = ncx_howmany(varp->type, extent); +#line 724 +#line 724 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 724 RGN_WRITE, &xp); +#line 724 if(lstatus != NC_NOERR) +#line 724 return lstatus; +#line 724 +#line 724 lstatus = ncx_putn_int_double(&xp, nput, value); +#line 724 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 724 { +#line 724 /* not fatal to the loop */ +#line 724 status = lstatus; +#line 724 } +#line 724 +#line 724 (void) ncio_rel(ncp->nciop, offset, +#line 724 RGN_MODIFIED); +#line 724 +#line 724 remaining -= extent; +#line 724 if(remaining == 0) +#line 724 break; /* normal loop exit */ +#line 724 offset += extent; +#line 724 value += nput; +#line 724 +#line 724 } +#line 724 +#line 724 return status; +#line 724 } +#line 724 static int +#line 725 putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp, +#line 725 const size_t *start, size_t nelems, const longlong *value) +#line 725 { +#line 725 off_t offset = NC_varoffset(ncp, varp, start); +#line 725 size_t remaining = varp->xsz * nelems; +#line 725 int status = NC_NOERR; +#line 725 void *xp; +#line 725 +#line 725 if(nelems == 0) +#line 725 return NC_NOERR; +#line 725 +#line 725 assert(value != NULL); +#line 725 +#line 725 for(;;) +#line 725 { +#line 725 size_t extent = MIN(remaining, ncp->chunk); +#line 725 size_t nput = ncx_howmany(varp->type, extent); +#line 725 +#line 725 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 725 RGN_WRITE, &xp); +#line 725 if(lstatus != NC_NOERR) +#line 725 return lstatus; +#line 725 +#line 725 lstatus = ncx_putn_int_longlong(&xp, nput, value); +#line 725 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 725 { +#line 725 /* not fatal to the loop */ +#line 725 status = lstatus; +#line 725 } +#line 725 +#line 725 (void) ncio_rel(ncp->nciop, offset, +#line 725 RGN_MODIFIED); +#line 725 +#line 725 remaining -= extent; +#line 725 if(remaining == 0) +#line 725 break; /* normal loop exit */ +#line 725 offset += extent; +#line 725 value += nput; +#line 725 +#line 725 } +#line 725 +#line 725 return status; +#line 725 } +#line 725 static int +#line 727 putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp, +#line 727 const size_t *start, size_t nelems, const schar *value) +#line 727 { +#line 727 off_t offset = NC_varoffset(ncp, varp, start); +#line 727 size_t remaining = varp->xsz * nelems; +#line 727 int status = NC_NOERR; +#line 727 void *xp; +#line 727 +#line 727 if(nelems == 0) +#line 727 return NC_NOERR; +#line 727 +#line 727 assert(value != NULL); +#line 727 +#line 727 for(;;) +#line 727 { +#line 727 size_t extent = MIN(remaining, ncp->chunk); +#line 727 size_t nput = ncx_howmany(varp->type, extent); +#line 727 +#line 727 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 727 RGN_WRITE, &xp); +#line 727 if(lstatus != NC_NOERR) +#line 727 return lstatus; +#line 727 +#line 727 lstatus = ncx_putn_float_schar(&xp, nput, value); +#line 727 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 727 { +#line 727 /* not fatal to the loop */ +#line 727 status = lstatus; +#line 727 } +#line 727 +#line 727 (void) ncio_rel(ncp->nciop, offset, +#line 727 RGN_MODIFIED); +#line 727 +#line 727 remaining -= extent; +#line 727 if(remaining == 0) +#line 727 break; /* normal loop exit */ +#line 727 offset += extent; +#line 727 value += nput; +#line 727 +#line 727 } +#line 727 +#line 727 return status; +#line 727 } +#line 727 static int +#line 728 putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp, +#line 728 const size_t *start, size_t nelems, const uchar *value) +#line 728 { +#line 728 off_t offset = NC_varoffset(ncp, varp, start); +#line 728 size_t remaining = varp->xsz * nelems; +#line 728 int status = NC_NOERR; +#line 728 void *xp; +#line 728 +#line 728 if(nelems == 0) +#line 728 return NC_NOERR; +#line 728 +#line 728 assert(value != NULL); +#line 728 +#line 728 for(;;) +#line 728 { +#line 728 size_t extent = MIN(remaining, ncp->chunk); +#line 728 size_t nput = ncx_howmany(varp->type, extent); +#line 728 +#line 728 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 728 RGN_WRITE, &xp); +#line 728 if(lstatus != NC_NOERR) +#line 728 return lstatus; +#line 728 +#line 728 lstatus = ncx_putn_float_uchar(&xp, nput, value); +#line 728 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 728 { +#line 728 /* not fatal to the loop */ +#line 728 status = lstatus; +#line 728 } +#line 728 +#line 728 (void) ncio_rel(ncp->nciop, offset, +#line 728 RGN_MODIFIED); +#line 728 +#line 728 remaining -= extent; +#line 728 if(remaining == 0) +#line 728 break; /* normal loop exit */ +#line 728 offset += extent; +#line 728 value += nput; +#line 728 +#line 728 } +#line 728 +#line 728 return status; +#line 728 } +#line 728 static int +#line 729 putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp, +#line 729 const size_t *start, size_t nelems, const short *value) +#line 729 { +#line 729 off_t offset = NC_varoffset(ncp, varp, start); +#line 729 size_t remaining = varp->xsz * nelems; +#line 729 int status = NC_NOERR; +#line 729 void *xp; +#line 729 +#line 729 if(nelems == 0) +#line 729 return NC_NOERR; +#line 729 +#line 729 assert(value != NULL); +#line 729 +#line 729 for(;;) +#line 729 { +#line 729 size_t extent = MIN(remaining, ncp->chunk); +#line 729 size_t nput = ncx_howmany(varp->type, extent); +#line 729 +#line 729 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 729 RGN_WRITE, &xp); +#line 729 if(lstatus != NC_NOERR) +#line 729 return lstatus; +#line 729 +#line 729 lstatus = ncx_putn_float_short(&xp, nput, value); +#line 729 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 729 { +#line 729 /* not fatal to the loop */ +#line 729 status = lstatus; +#line 729 } +#line 729 +#line 729 (void) ncio_rel(ncp->nciop, offset, +#line 729 RGN_MODIFIED); +#line 729 +#line 729 remaining -= extent; +#line 729 if(remaining == 0) +#line 729 break; /* normal loop exit */ +#line 729 offset += extent; +#line 729 value += nput; +#line 729 +#line 729 } +#line 729 +#line 729 return status; +#line 729 } +#line 729 static int +#line 730 putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp, +#line 730 const size_t *start, size_t nelems, const int *value) +#line 730 { +#line 730 off_t offset = NC_varoffset(ncp, varp, start); +#line 730 size_t remaining = varp->xsz * nelems; +#line 730 int status = NC_NOERR; +#line 730 void *xp; +#line 730 +#line 730 if(nelems == 0) +#line 730 return NC_NOERR; +#line 730 +#line 730 assert(value != NULL); +#line 730 +#line 730 for(;;) +#line 730 { +#line 730 size_t extent = MIN(remaining, ncp->chunk); +#line 730 size_t nput = ncx_howmany(varp->type, extent); +#line 730 +#line 730 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 730 RGN_WRITE, &xp); +#line 730 if(lstatus != NC_NOERR) +#line 730 return lstatus; +#line 730 +#line 730 lstatus = ncx_putn_float_int(&xp, nput, value); +#line 730 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 730 { +#line 730 /* not fatal to the loop */ +#line 730 status = lstatus; +#line 730 } +#line 730 +#line 730 (void) ncio_rel(ncp->nciop, offset, +#line 730 RGN_MODIFIED); +#line 730 +#line 730 remaining -= extent; +#line 730 if(remaining == 0) +#line 730 break; /* normal loop exit */ +#line 730 offset += extent; +#line 730 value += nput; +#line 730 +#line 730 } +#line 730 +#line 730 return status; +#line 730 } +#line 730 static int +#line 731 putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp, +#line 731 const size_t *start, size_t nelems, const float *value) +#line 731 { +#line 731 off_t offset = NC_varoffset(ncp, varp, start); +#line 731 size_t remaining = varp->xsz * nelems; +#line 731 int status = NC_NOERR; +#line 731 void *xp; +#line 731 +#line 731 if(nelems == 0) +#line 731 return NC_NOERR; +#line 731 +#line 731 assert(value != NULL); +#line 731 +#line 731 for(;;) +#line 731 { +#line 731 size_t extent = MIN(remaining, ncp->chunk); +#line 731 size_t nput = ncx_howmany(varp->type, extent); +#line 731 +#line 731 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 731 RGN_WRITE, &xp); +#line 731 if(lstatus != NC_NOERR) +#line 731 return lstatus; +#line 731 +#line 731 lstatus = ncx_putn_float_float(&xp, nput, value); +#line 731 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 731 { +#line 731 /* not fatal to the loop */ +#line 731 status = lstatus; +#line 731 } +#line 731 +#line 731 (void) ncio_rel(ncp->nciop, offset, +#line 731 RGN_MODIFIED); +#line 731 +#line 731 remaining -= extent; +#line 731 if(remaining == 0) +#line 731 break; /* normal loop exit */ +#line 731 offset += extent; +#line 731 value += nput; +#line 731 +#line 731 } +#line 731 +#line 731 return status; +#line 731 } +#line 731 static int +#line 732 putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp, +#line 732 const size_t *start, size_t nelems, const double *value) +#line 732 { +#line 732 off_t offset = NC_varoffset(ncp, varp, start); +#line 732 size_t remaining = varp->xsz * nelems; +#line 732 int status = NC_NOERR; +#line 732 void *xp; +#line 732 +#line 732 if(nelems == 0) +#line 732 return NC_NOERR; +#line 732 +#line 732 assert(value != NULL); +#line 732 +#line 732 for(;;) +#line 732 { +#line 732 size_t extent = MIN(remaining, ncp->chunk); +#line 732 size_t nput = ncx_howmany(varp->type, extent); +#line 732 +#line 732 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 732 RGN_WRITE, &xp); +#line 732 if(lstatus != NC_NOERR) +#line 732 return lstatus; +#line 732 +#line 732 lstatus = ncx_putn_float_double(&xp, nput, value); +#line 732 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 732 { +#line 732 /* not fatal to the loop */ +#line 732 status = lstatus; +#line 732 } +#line 732 +#line 732 (void) ncio_rel(ncp->nciop, offset, +#line 732 RGN_MODIFIED); +#line 732 +#line 732 remaining -= extent; +#line 732 if(remaining == 0) +#line 732 break; /* normal loop exit */ +#line 732 offset += extent; +#line 732 value += nput; +#line 732 +#line 732 } +#line 732 +#line 732 return status; +#line 732 } +#line 732 static int +#line 733 putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp, +#line 733 const size_t *start, size_t nelems, const longlong *value) +#line 733 { +#line 733 off_t offset = NC_varoffset(ncp, varp, start); +#line 733 size_t remaining = varp->xsz * nelems; +#line 733 int status = NC_NOERR; +#line 733 void *xp; +#line 733 +#line 733 if(nelems == 0) +#line 733 return NC_NOERR; +#line 733 +#line 733 assert(value != NULL); +#line 733 +#line 733 for(;;) +#line 733 { +#line 733 size_t extent = MIN(remaining, ncp->chunk); +#line 733 size_t nput = ncx_howmany(varp->type, extent); +#line 733 +#line 733 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 733 RGN_WRITE, &xp); +#line 733 if(lstatus != NC_NOERR) +#line 733 return lstatus; +#line 733 +#line 733 lstatus = ncx_putn_float_longlong(&xp, nput, value); +#line 733 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 733 { +#line 733 /* not fatal to the loop */ +#line 733 status = lstatus; +#line 733 } +#line 733 +#line 733 (void) ncio_rel(ncp->nciop, offset, +#line 733 RGN_MODIFIED); +#line 733 +#line 733 remaining -= extent; +#line 733 if(remaining == 0) +#line 733 break; /* normal loop exit */ +#line 733 offset += extent; +#line 733 value += nput; +#line 733 +#line 733 } +#line 733 +#line 733 return status; +#line 733 } +#line 733 static int +#line 735 putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp, +#line 735 const size_t *start, size_t nelems, const schar *value) +#line 735 { +#line 735 off_t offset = NC_varoffset(ncp, varp, start); +#line 735 size_t remaining = varp->xsz * nelems; +#line 735 int status = NC_NOERR; +#line 735 void *xp; +#line 735 +#line 735 if(nelems == 0) +#line 735 return NC_NOERR; +#line 735 +#line 735 assert(value != NULL); +#line 735 +#line 735 for(;;) +#line 735 { +#line 735 size_t extent = MIN(remaining, ncp->chunk); +#line 735 size_t nput = ncx_howmany(varp->type, extent); +#line 735 +#line 735 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 735 RGN_WRITE, &xp); +#line 735 if(lstatus != NC_NOERR) +#line 735 return lstatus; +#line 735 +#line 735 lstatus = ncx_putn_double_schar(&xp, nput, value); +#line 735 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 735 { +#line 735 /* not fatal to the loop */ +#line 735 status = lstatus; +#line 735 } +#line 735 +#line 735 (void) ncio_rel(ncp->nciop, offset, +#line 735 RGN_MODIFIED); +#line 735 +#line 735 remaining -= extent; +#line 735 if(remaining == 0) +#line 735 break; /* normal loop exit */ +#line 735 offset += extent; +#line 735 value += nput; +#line 735 +#line 735 } +#line 735 +#line 735 return status; +#line 735 } +#line 735 static int +#line 736 putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp, +#line 736 const size_t *start, size_t nelems, const uchar *value) +#line 736 { +#line 736 off_t offset = NC_varoffset(ncp, varp, start); +#line 736 size_t remaining = varp->xsz * nelems; +#line 736 int status = NC_NOERR; +#line 736 void *xp; +#line 736 +#line 736 if(nelems == 0) +#line 736 return NC_NOERR; +#line 736 +#line 736 assert(value != NULL); +#line 736 +#line 736 for(;;) +#line 736 { +#line 736 size_t extent = MIN(remaining, ncp->chunk); +#line 736 size_t nput = ncx_howmany(varp->type, extent); +#line 736 +#line 736 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 736 RGN_WRITE, &xp); +#line 736 if(lstatus != NC_NOERR) +#line 736 return lstatus; +#line 736 +#line 736 lstatus = ncx_putn_double_uchar(&xp, nput, value); +#line 736 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 736 { +#line 736 /* not fatal to the loop */ +#line 736 status = lstatus; +#line 736 } +#line 736 +#line 736 (void) ncio_rel(ncp->nciop, offset, +#line 736 RGN_MODIFIED); +#line 736 +#line 736 remaining -= extent; +#line 736 if(remaining == 0) +#line 736 break; /* normal loop exit */ +#line 736 offset += extent; +#line 736 value += nput; +#line 736 +#line 736 } +#line 736 +#line 736 return status; +#line 736 } +#line 736 static int +#line 737 putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp, +#line 737 const size_t *start, size_t nelems, const short *value) +#line 737 { +#line 737 off_t offset = NC_varoffset(ncp, varp, start); +#line 737 size_t remaining = varp->xsz * nelems; +#line 737 int status = NC_NOERR; +#line 737 void *xp; +#line 737 +#line 737 if(nelems == 0) +#line 737 return NC_NOERR; +#line 737 +#line 737 assert(value != NULL); +#line 737 +#line 737 for(;;) +#line 737 { +#line 737 size_t extent = MIN(remaining, ncp->chunk); +#line 737 size_t nput = ncx_howmany(varp->type, extent); +#line 737 +#line 737 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 737 RGN_WRITE, &xp); +#line 737 if(lstatus != NC_NOERR) +#line 737 return lstatus; +#line 737 +#line 737 lstatus = ncx_putn_double_short(&xp, nput, value); +#line 737 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 737 { +#line 737 /* not fatal to the loop */ +#line 737 status = lstatus; +#line 737 } +#line 737 +#line 737 (void) ncio_rel(ncp->nciop, offset, +#line 737 RGN_MODIFIED); +#line 737 +#line 737 remaining -= extent; +#line 737 if(remaining == 0) +#line 737 break; /* normal loop exit */ +#line 737 offset += extent; +#line 737 value += nput; +#line 737 +#line 737 } +#line 737 +#line 737 return status; +#line 737 } +#line 737 static int +#line 738 putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp, +#line 738 const size_t *start, size_t nelems, const int *value) +#line 738 { +#line 738 off_t offset = NC_varoffset(ncp, varp, start); +#line 738 size_t remaining = varp->xsz * nelems; +#line 738 int status = NC_NOERR; +#line 738 void *xp; +#line 738 +#line 738 if(nelems == 0) +#line 738 return NC_NOERR; +#line 738 +#line 738 assert(value != NULL); +#line 738 +#line 738 for(;;) +#line 738 { +#line 738 size_t extent = MIN(remaining, ncp->chunk); +#line 738 size_t nput = ncx_howmany(varp->type, extent); +#line 738 +#line 738 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 738 RGN_WRITE, &xp); +#line 738 if(lstatus != NC_NOERR) +#line 738 return lstatus; +#line 738 +#line 738 lstatus = ncx_putn_double_int(&xp, nput, value); +#line 738 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 738 { +#line 738 /* not fatal to the loop */ +#line 738 status = lstatus; +#line 738 } +#line 738 +#line 738 (void) ncio_rel(ncp->nciop, offset, +#line 738 RGN_MODIFIED); +#line 738 +#line 738 remaining -= extent; +#line 738 if(remaining == 0) +#line 738 break; /* normal loop exit */ +#line 738 offset += extent; +#line 738 value += nput; +#line 738 +#line 738 } +#line 738 +#line 738 return status; +#line 738 } +#line 738 static int +#line 739 putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp, +#line 739 const size_t *start, size_t nelems, const float *value) +#line 739 { +#line 739 off_t offset = NC_varoffset(ncp, varp, start); +#line 739 size_t remaining = varp->xsz * nelems; +#line 739 int status = NC_NOERR; +#line 739 void *xp; +#line 739 +#line 739 if(nelems == 0) +#line 739 return NC_NOERR; +#line 739 +#line 739 assert(value != NULL); +#line 739 +#line 739 for(;;) +#line 739 { +#line 739 size_t extent = MIN(remaining, ncp->chunk); +#line 739 size_t nput = ncx_howmany(varp->type, extent); +#line 739 +#line 739 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 739 RGN_WRITE, &xp); +#line 739 if(lstatus != NC_NOERR) +#line 739 return lstatus; +#line 739 +#line 739 lstatus = ncx_putn_double_float(&xp, nput, value); +#line 739 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 739 { +#line 739 /* not fatal to the loop */ +#line 739 status = lstatus; +#line 739 } +#line 739 +#line 739 (void) ncio_rel(ncp->nciop, offset, +#line 739 RGN_MODIFIED); +#line 739 +#line 739 remaining -= extent; +#line 739 if(remaining == 0) +#line 739 break; /* normal loop exit */ +#line 739 offset += extent; +#line 739 value += nput; +#line 739 +#line 739 } +#line 739 +#line 739 return status; +#line 739 } +#line 739 static int +#line 740 putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp, +#line 740 const size_t *start, size_t nelems, const double *value) +#line 740 { +#line 740 off_t offset = NC_varoffset(ncp, varp, start); +#line 740 size_t remaining = varp->xsz * nelems; +#line 740 int status = NC_NOERR; +#line 740 void *xp; +#line 740 +#line 740 if(nelems == 0) +#line 740 return NC_NOERR; +#line 740 +#line 740 assert(value != NULL); +#line 740 +#line 740 for(;;) +#line 740 { +#line 740 size_t extent = MIN(remaining, ncp->chunk); +#line 740 size_t nput = ncx_howmany(varp->type, extent); +#line 740 +#line 740 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 740 RGN_WRITE, &xp); +#line 740 if(lstatus != NC_NOERR) +#line 740 return lstatus; +#line 740 +#line 740 lstatus = ncx_putn_double_double(&xp, nput, value); +#line 740 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 740 { +#line 740 /* not fatal to the loop */ +#line 740 status = lstatus; +#line 740 } +#line 740 +#line 740 (void) ncio_rel(ncp->nciop, offset, +#line 740 RGN_MODIFIED); +#line 740 +#line 740 remaining -= extent; +#line 740 if(remaining == 0) +#line 740 break; /* normal loop exit */ +#line 740 offset += extent; +#line 740 value += nput; +#line 740 +#line 740 } +#line 740 +#line 740 return status; +#line 740 } +#line 740 static int +#line 741 putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp, +#line 741 const size_t *start, size_t nelems, const longlong *value) +#line 741 { +#line 741 off_t offset = NC_varoffset(ncp, varp, start); +#line 741 size_t remaining = varp->xsz * nelems; +#line 741 int status = NC_NOERR; +#line 741 void *xp; +#line 741 +#line 741 if(nelems == 0) +#line 741 return NC_NOERR; +#line 741 +#line 741 assert(value != NULL); +#line 741 +#line 741 for(;;) +#line 741 { +#line 741 size_t extent = MIN(remaining, ncp->chunk); +#line 741 size_t nput = ncx_howmany(varp->type, extent); +#line 741 +#line 741 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 741 RGN_WRITE, &xp); +#line 741 if(lstatus != NC_NOERR) +#line 741 return lstatus; +#line 741 +#line 741 lstatus = ncx_putn_double_longlong(&xp, nput, value); +#line 741 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 741 { +#line 741 /* not fatal to the loop */ +#line 741 status = lstatus; +#line 741 } +#line 741 +#line 741 (void) ncio_rel(ncp->nciop, offset, +#line 741 RGN_MODIFIED); +#line 741 +#line 741 remaining -= extent; +#line 741 if(remaining == 0) +#line 741 break; /* normal loop exit */ +#line 741 offset += extent; +#line 741 value += nput; +#line 741 +#line 741 } +#line 741 +#line 741 return status; +#line 741 } +#line 741 +#line 744 #ifdef NOTUSED static int +#line 745 putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp, +#line 745 const size_t *start, size_t nelems, const uint *value) +#line 745 { +#line 745 off_t offset = NC_varoffset(ncp, varp, start); +#line 745 size_t remaining = varp->xsz * nelems; +#line 745 int status = NC_NOERR; +#line 745 void *xp; +#line 745 +#line 745 if(nelems == 0) +#line 745 return NC_NOERR; +#line 745 +#line 745 assert(value != NULL); +#line 745 +#line 745 for(;;) +#line 745 { +#line 745 size_t extent = MIN(remaining, ncp->chunk); +#line 745 size_t nput = ncx_howmany(varp->type, extent); +#line 745 +#line 745 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 745 RGN_WRITE, &xp); +#line 745 if(lstatus != NC_NOERR) +#line 745 return lstatus; +#line 745 +#line 745 lstatus = ncx_putn_schar_uint(&xp, nput, value); +#line 745 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 745 { +#line 745 /* not fatal to the loop */ +#line 745 status = lstatus; +#line 745 } +#line 745 +#line 745 (void) ncio_rel(ncp->nciop, offset, +#line 745 RGN_MODIFIED); +#line 745 +#line 745 remaining -= extent; +#line 745 if(remaining == 0) +#line 745 break; /* normal loop exit */ +#line 745 offset += extent; +#line 745 value += nput; +#line 745 +#line 745 } +#line 745 +#line 745 return status; +#line 745 } +#line 745 static int +#line 746 putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp, +#line 746 const size_t *start, size_t nelems, const ulonglong *value) +#line 746 { +#line 746 off_t offset = NC_varoffset(ncp, varp, start); +#line 746 size_t remaining = varp->xsz * nelems; +#line 746 int status = NC_NOERR; +#line 746 void *xp; +#line 746 +#line 746 if(nelems == 0) +#line 746 return NC_NOERR; +#line 746 +#line 746 assert(value != NULL); +#line 746 +#line 746 for(;;) +#line 746 { +#line 746 size_t extent = MIN(remaining, ncp->chunk); +#line 746 size_t nput = ncx_howmany(varp->type, extent); +#line 746 +#line 746 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 746 RGN_WRITE, &xp); +#line 746 if(lstatus != NC_NOERR) +#line 746 return lstatus; +#line 746 +#line 746 lstatus = ncx_putn_schar_ulonglong(&xp, nput, value); +#line 746 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 746 { +#line 746 /* not fatal to the loop */ +#line 746 status = lstatus; +#line 746 } +#line 746 +#line 746 (void) ncio_rel(ncp->nciop, offset, +#line 746 RGN_MODIFIED); +#line 746 +#line 746 remaining -= extent; +#line 746 if(remaining == 0) +#line 746 break; /* normal loop exit */ +#line 746 offset += extent; +#line 746 value += nput; +#line 746 +#line 746 } +#line 746 +#line 746 return status; +#line 746 } +#line 746 static int +#line 747 putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp, +#line 747 const size_t *start, size_t nelems, const uint *value) +#line 747 { +#line 747 off_t offset = NC_varoffset(ncp, varp, start); +#line 747 size_t remaining = varp->xsz * nelems; +#line 747 int status = NC_NOERR; +#line 747 void *xp; +#line 747 +#line 747 if(nelems == 0) +#line 747 return NC_NOERR; +#line 747 +#line 747 assert(value != NULL); +#line 747 +#line 747 for(;;) +#line 747 { +#line 747 size_t extent = MIN(remaining, ncp->chunk); +#line 747 size_t nput = ncx_howmany(varp->type, extent); +#line 747 +#line 747 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 747 RGN_WRITE, &xp); +#line 747 if(lstatus != NC_NOERR) +#line 747 return lstatus; +#line 747 +#line 747 lstatus = ncx_putn_short_uint(&xp, nput, value); +#line 747 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 747 { +#line 747 /* not fatal to the loop */ +#line 747 status = lstatus; +#line 747 } +#line 747 +#line 747 (void) ncio_rel(ncp->nciop, offset, +#line 747 RGN_MODIFIED); +#line 747 +#line 747 remaining -= extent; +#line 747 if(remaining == 0) +#line 747 break; /* normal loop exit */ +#line 747 offset += extent; +#line 747 value += nput; +#line 747 +#line 747 } +#line 747 +#line 747 return status; +#line 747 } +#line 747 static int +#line 748 putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp, +#line 748 const size_t *start, size_t nelems, const ulonglong *value) +#line 748 { +#line 748 off_t offset = NC_varoffset(ncp, varp, start); +#line 748 size_t remaining = varp->xsz * nelems; +#line 748 int status = NC_NOERR; +#line 748 void *xp; +#line 748 +#line 748 if(nelems == 0) +#line 748 return NC_NOERR; +#line 748 +#line 748 assert(value != NULL); +#line 748 +#line 748 for(;;) +#line 748 { +#line 748 size_t extent = MIN(remaining, ncp->chunk); +#line 748 size_t nput = ncx_howmany(varp->type, extent); +#line 748 +#line 748 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 748 RGN_WRITE, &xp); +#line 748 if(lstatus != NC_NOERR) +#line 748 return lstatus; +#line 748 +#line 748 lstatus = ncx_putn_short_ulonglong(&xp, nput, value); +#line 748 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 748 { +#line 748 /* not fatal to the loop */ +#line 748 status = lstatus; +#line 748 } +#line 748 +#line 748 (void) ncio_rel(ncp->nciop, offset, +#line 748 RGN_MODIFIED); +#line 748 +#line 748 remaining -= extent; +#line 748 if(remaining == 0) +#line 748 break; /* normal loop exit */ +#line 748 offset += extent; +#line 748 value += nput; +#line 748 +#line 748 } +#line 748 +#line 748 return status; +#line 748 } +#line 748 static int +#line 749 putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp, +#line 749 const size_t *start, size_t nelems, const uint *value) +#line 749 { +#line 749 off_t offset = NC_varoffset(ncp, varp, start); +#line 749 size_t remaining = varp->xsz * nelems; +#line 749 int status = NC_NOERR; +#line 749 void *xp; +#line 749 +#line 749 if(nelems == 0) +#line 749 return NC_NOERR; +#line 749 +#line 749 assert(value != NULL); +#line 749 +#line 749 for(;;) +#line 749 { +#line 749 size_t extent = MIN(remaining, ncp->chunk); +#line 749 size_t nput = ncx_howmany(varp->type, extent); +#line 749 +#line 749 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 749 RGN_WRITE, &xp); +#line 749 if(lstatus != NC_NOERR) +#line 749 return lstatus; +#line 749 +#line 749 lstatus = ncx_putn_int_uint(&xp, nput, value); +#line 749 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 749 { +#line 749 /* not fatal to the loop */ +#line 749 status = lstatus; +#line 749 } +#line 749 +#line 749 (void) ncio_rel(ncp->nciop, offset, +#line 749 RGN_MODIFIED); +#line 749 +#line 749 remaining -= extent; +#line 749 if(remaining == 0) +#line 749 break; /* normal loop exit */ +#line 749 offset += extent; +#line 749 value += nput; +#line 749 +#line 749 } +#line 749 +#line 749 return status; +#line 749 } +#line 749 static int +#line 750 putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp, +#line 750 const size_t *start, size_t nelems, const ulonglong *value) +#line 750 { +#line 750 off_t offset = NC_varoffset(ncp, varp, start); +#line 750 size_t remaining = varp->xsz * nelems; +#line 750 int status = NC_NOERR; +#line 750 void *xp; +#line 750 +#line 750 if(nelems == 0) +#line 750 return NC_NOERR; +#line 750 +#line 750 assert(value != NULL); +#line 750 +#line 750 for(;;) +#line 750 { +#line 750 size_t extent = MIN(remaining, ncp->chunk); +#line 750 size_t nput = ncx_howmany(varp->type, extent); +#line 750 +#line 750 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 750 RGN_WRITE, &xp); +#line 750 if(lstatus != NC_NOERR) +#line 750 return lstatus; +#line 750 +#line 750 lstatus = ncx_putn_int_ulonglong(&xp, nput, value); +#line 750 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 750 { +#line 750 /* not fatal to the loop */ +#line 750 status = lstatus; +#line 750 } +#line 750 +#line 750 (void) ncio_rel(ncp->nciop, offset, +#line 750 RGN_MODIFIED); +#line 750 +#line 750 remaining -= extent; +#line 750 if(remaining == 0) +#line 750 break; /* normal loop exit */ +#line 750 offset += extent; +#line 750 value += nput; +#line 750 +#line 750 } +#line 750 +#line 750 return status; +#line 750 } +#line 750 static int +#line 751 putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp, +#line 751 const size_t *start, size_t nelems, const uint *value) +#line 751 { +#line 751 off_t offset = NC_varoffset(ncp, varp, start); +#line 751 size_t remaining = varp->xsz * nelems; +#line 751 int status = NC_NOERR; +#line 751 void *xp; +#line 751 +#line 751 if(nelems == 0) +#line 751 return NC_NOERR; +#line 751 +#line 751 assert(value != NULL); +#line 751 +#line 751 for(;;) +#line 751 { +#line 751 size_t extent = MIN(remaining, ncp->chunk); +#line 751 size_t nput = ncx_howmany(varp->type, extent); +#line 751 +#line 751 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 751 RGN_WRITE, &xp); +#line 751 if(lstatus != NC_NOERR) +#line 751 return lstatus; +#line 751 +#line 751 lstatus = ncx_putn_float_uint(&xp, nput, value); +#line 751 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 751 { +#line 751 /* not fatal to the loop */ +#line 751 status = lstatus; +#line 751 } +#line 751 +#line 751 (void) ncio_rel(ncp->nciop, offset, +#line 751 RGN_MODIFIED); +#line 751 +#line 751 remaining -= extent; +#line 751 if(remaining == 0) +#line 751 break; /* normal loop exit */ +#line 751 offset += extent; +#line 751 value += nput; +#line 751 +#line 751 } +#line 751 +#line 751 return status; +#line 751 } +#line 751 static int +#line 752 putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp, +#line 752 const size_t *start, size_t nelems, const ulonglong *value) +#line 752 { +#line 752 off_t offset = NC_varoffset(ncp, varp, start); +#line 752 size_t remaining = varp->xsz * nelems; +#line 752 int status = NC_NOERR; +#line 752 void *xp; +#line 752 +#line 752 if(nelems == 0) +#line 752 return NC_NOERR; +#line 752 +#line 752 assert(value != NULL); +#line 752 +#line 752 for(;;) +#line 752 { +#line 752 size_t extent = MIN(remaining, ncp->chunk); +#line 752 size_t nput = ncx_howmany(varp->type, extent); +#line 752 +#line 752 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 752 RGN_WRITE, &xp); +#line 752 if(lstatus != NC_NOERR) +#line 752 return lstatus; +#line 752 +#line 752 lstatus = ncx_putn_float_ulonglong(&xp, nput, value); +#line 752 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 752 { +#line 752 /* not fatal to the loop */ +#line 752 status = lstatus; +#line 752 } +#line 752 +#line 752 (void) ncio_rel(ncp->nciop, offset, +#line 752 RGN_MODIFIED); +#line 752 +#line 752 remaining -= extent; +#line 752 if(remaining == 0) +#line 752 break; /* normal loop exit */ +#line 752 offset += extent; +#line 752 value += nput; +#line 752 +#line 752 } +#line 752 +#line 752 return status; +#line 752 } +#line 752 static int +#line 753 putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp, +#line 753 const size_t *start, size_t nelems, const uint *value) +#line 753 { +#line 753 off_t offset = NC_varoffset(ncp, varp, start); +#line 753 size_t remaining = varp->xsz * nelems; +#line 753 int status = NC_NOERR; +#line 753 void *xp; +#line 753 +#line 753 if(nelems == 0) +#line 753 return NC_NOERR; +#line 753 +#line 753 assert(value != NULL); +#line 753 +#line 753 for(;;) +#line 753 { +#line 753 size_t extent = MIN(remaining, ncp->chunk); +#line 753 size_t nput = ncx_howmany(varp->type, extent); +#line 753 +#line 753 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 753 RGN_WRITE, &xp); +#line 753 if(lstatus != NC_NOERR) +#line 753 return lstatus; +#line 753 +#line 753 lstatus = ncx_putn_double_uint(&xp, nput, value); +#line 753 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 753 { +#line 753 /* not fatal to the loop */ +#line 753 status = lstatus; +#line 753 } +#line 753 +#line 753 (void) ncio_rel(ncp->nciop, offset, +#line 753 RGN_MODIFIED); +#line 753 +#line 753 remaining -= extent; +#line 753 if(remaining == 0) +#line 753 break; /* normal loop exit */ +#line 753 offset += extent; +#line 753 value += nput; +#line 753 +#line 753 } +#line 753 +#line 753 return status; +#line 753 } +#line 753 static int +#line 754 putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp, +#line 754 const size_t *start, size_t nelems, const ulonglong *value) +#line 754 { +#line 754 off_t offset = NC_varoffset(ncp, varp, start); +#line 754 size_t remaining = varp->xsz * nelems; +#line 754 int status = NC_NOERR; +#line 754 void *xp; +#line 754 +#line 754 if(nelems == 0) +#line 754 return NC_NOERR; +#line 754 +#line 754 assert(value != NULL); +#line 754 +#line 754 for(;;) +#line 754 { +#line 754 size_t extent = MIN(remaining, ncp->chunk); +#line 754 size_t nput = ncx_howmany(varp->type, extent); +#line 754 +#line 754 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 754 RGN_WRITE, &xp); +#line 754 if(lstatus != NC_NOERR) +#line 754 return lstatus; +#line 754 +#line 754 lstatus = ncx_putn_double_ulonglong(&xp, nput, value); +#line 754 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 754 { +#line 754 /* not fatal to the loop */ +#line 754 status = lstatus; +#line 754 } +#line 754 +#line 754 (void) ncio_rel(ncp->nciop, offset, +#line 754 RGN_MODIFIED); +#line 754 +#line 754 remaining -= extent; +#line 754 if(remaining == 0) +#line 754 break; /* normal loop exit */ +#line 754 offset += extent; +#line 754 value += nput; +#line 754 +#line 754 } +#line 754 +#line 754 return status; +#line 754 } +#line 754 #endif /*NOTUSED*/ +#line 802 static int +#line 803 getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp, +#line 803 const size_t *start, size_t nelems, char *value) +#line 803 { +#line 803 off_t offset = NC_varoffset(ncp, varp, start); +#line 803 size_t remaining = varp->xsz * nelems; +#line 803 int status = NC_NOERR; +#line 803 const void *xp; +#line 803 +#line 803 if(nelems == 0) +#line 803 return NC_NOERR; +#line 803 +#line 803 assert(value != NULL); +#line 803 +#line 803 for(;;) +#line 803 { +#line 803 size_t extent = MIN(remaining, ncp->chunk); +#line 803 size_t nget = ncx_howmany(varp->type, extent); +#line 803 +#line 803 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 803 0, (void **)&xp); /* cast away const */ +#line 803 if(lstatus != NC_NOERR) +#line 803 return lstatus; +#line 803 +#line 803 lstatus = ncx_getn_char_char(&xp, nget, value); +#line 803 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 803 status = lstatus; +#line 803 +#line 803 (void) ncio_rel(ncp->nciop, offset, 0); +#line 803 +#line 803 remaining -= extent; +#line 803 if(remaining == 0) +#line 803 break; /* normal loop exit */ +#line 803 offset += extent; +#line 803 value += nget; +#line 803 } +#line 803 +#line 803 return status; +#line 803 } +#line 803 static int +#line 805 getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp, +#line 805 const size_t *start, size_t nelems, schar *value) +#line 805 { +#line 805 off_t offset = NC_varoffset(ncp, varp, start); +#line 805 size_t remaining = varp->xsz * nelems; +#line 805 int status = NC_NOERR; +#line 805 const void *xp; +#line 805 +#line 805 if(nelems == 0) +#line 805 return NC_NOERR; +#line 805 +#line 805 assert(value != NULL); +#line 805 +#line 805 for(;;) +#line 805 { +#line 805 size_t extent = MIN(remaining, ncp->chunk); +#line 805 size_t nget = ncx_howmany(varp->type, extent); +#line 805 +#line 805 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 805 0, (void **)&xp); /* cast away const */ +#line 805 if(lstatus != NC_NOERR) +#line 805 return lstatus; +#line 805 +#line 805 lstatus = ncx_getn_schar_schar(&xp, nget, value); +#line 805 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 805 status = lstatus; +#line 805 +#line 805 (void) ncio_rel(ncp->nciop, offset, 0); +#line 805 +#line 805 remaining -= extent; +#line 805 if(remaining == 0) +#line 805 break; /* normal loop exit */ +#line 805 offset += extent; +#line 805 value += nget; +#line 805 } +#line 805 +#line 805 return status; +#line 805 } +#line 805 static int +#line 806 getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp, +#line 806 const size_t *start, size_t nelems, short *value) +#line 806 { +#line 806 off_t offset = NC_varoffset(ncp, varp, start); +#line 806 size_t remaining = varp->xsz * nelems; +#line 806 int status = NC_NOERR; +#line 806 const void *xp; +#line 806 +#line 806 if(nelems == 0) +#line 806 return NC_NOERR; +#line 806 +#line 806 assert(value != NULL); +#line 806 +#line 806 for(;;) +#line 806 { +#line 806 size_t extent = MIN(remaining, ncp->chunk); +#line 806 size_t nget = ncx_howmany(varp->type, extent); +#line 806 +#line 806 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 806 0, (void **)&xp); /* cast away const */ +#line 806 if(lstatus != NC_NOERR) +#line 806 return lstatus; +#line 806 +#line 806 lstatus = ncx_getn_schar_short(&xp, nget, value); +#line 806 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 806 status = lstatus; +#line 806 +#line 806 (void) ncio_rel(ncp->nciop, offset, 0); +#line 806 +#line 806 remaining -= extent; +#line 806 if(remaining == 0) +#line 806 break; /* normal loop exit */ +#line 806 offset += extent; +#line 806 value += nget; +#line 806 } +#line 806 +#line 806 return status; +#line 806 } +#line 806 static int +#line 807 getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp, +#line 807 const size_t *start, size_t nelems, int *value) +#line 807 { +#line 807 off_t offset = NC_varoffset(ncp, varp, start); +#line 807 size_t remaining = varp->xsz * nelems; +#line 807 int status = NC_NOERR; +#line 807 const void *xp; +#line 807 +#line 807 if(nelems == 0) +#line 807 return NC_NOERR; +#line 807 +#line 807 assert(value != NULL); +#line 807 +#line 807 for(;;) +#line 807 { +#line 807 size_t extent = MIN(remaining, ncp->chunk); +#line 807 size_t nget = ncx_howmany(varp->type, extent); +#line 807 +#line 807 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 807 0, (void **)&xp); /* cast away const */ +#line 807 if(lstatus != NC_NOERR) +#line 807 return lstatus; +#line 807 +#line 807 lstatus = ncx_getn_schar_int(&xp, nget, value); +#line 807 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 807 status = lstatus; +#line 807 +#line 807 (void) ncio_rel(ncp->nciop, offset, 0); +#line 807 +#line 807 remaining -= extent; +#line 807 if(remaining == 0) +#line 807 break; /* normal loop exit */ +#line 807 offset += extent; +#line 807 value += nget; +#line 807 } +#line 807 +#line 807 return status; +#line 807 } +#line 807 static int +#line 808 getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp, +#line 808 const size_t *start, size_t nelems, float *value) +#line 808 { +#line 808 off_t offset = NC_varoffset(ncp, varp, start); +#line 808 size_t remaining = varp->xsz * nelems; +#line 808 int status = NC_NOERR; +#line 808 const void *xp; +#line 808 +#line 808 if(nelems == 0) +#line 808 return NC_NOERR; +#line 808 +#line 808 assert(value != NULL); +#line 808 +#line 808 for(;;) +#line 808 { +#line 808 size_t extent = MIN(remaining, ncp->chunk); +#line 808 size_t nget = ncx_howmany(varp->type, extent); +#line 808 +#line 808 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 808 0, (void **)&xp); /* cast away const */ +#line 808 if(lstatus != NC_NOERR) +#line 808 return lstatus; +#line 808 +#line 808 lstatus = ncx_getn_schar_float(&xp, nget, value); +#line 808 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 808 status = lstatus; +#line 808 +#line 808 (void) ncio_rel(ncp->nciop, offset, 0); +#line 808 +#line 808 remaining -= extent; +#line 808 if(remaining == 0) +#line 808 break; /* normal loop exit */ +#line 808 offset += extent; +#line 808 value += nget; +#line 808 } +#line 808 +#line 808 return status; +#line 808 } +#line 808 static int +#line 809 getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp, +#line 809 const size_t *start, size_t nelems, double *value) +#line 809 { +#line 809 off_t offset = NC_varoffset(ncp, varp, start); +#line 809 size_t remaining = varp->xsz * nelems; +#line 809 int status = NC_NOERR; +#line 809 const void *xp; +#line 809 +#line 809 if(nelems == 0) +#line 809 return NC_NOERR; +#line 809 +#line 809 assert(value != NULL); +#line 809 +#line 809 for(;;) +#line 809 { +#line 809 size_t extent = MIN(remaining, ncp->chunk); +#line 809 size_t nget = ncx_howmany(varp->type, extent); +#line 809 +#line 809 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 809 0, (void **)&xp); /* cast away const */ +#line 809 if(lstatus != NC_NOERR) +#line 809 return lstatus; +#line 809 +#line 809 lstatus = ncx_getn_schar_double(&xp, nget, value); +#line 809 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 809 status = lstatus; +#line 809 +#line 809 (void) ncio_rel(ncp->nciop, offset, 0); +#line 809 +#line 809 remaining -= extent; +#line 809 if(remaining == 0) +#line 809 break; /* normal loop exit */ +#line 809 offset += extent; +#line 809 value += nget; +#line 809 } +#line 809 +#line 809 return status; +#line 809 } +#line 809 static int +#line 810 getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp, +#line 810 const size_t *start, size_t nelems, longlong *value) +#line 810 { +#line 810 off_t offset = NC_varoffset(ncp, varp, start); +#line 810 size_t remaining = varp->xsz * nelems; +#line 810 int status = NC_NOERR; +#line 810 const void *xp; +#line 810 +#line 810 if(nelems == 0) +#line 810 return NC_NOERR; +#line 810 +#line 810 assert(value != NULL); +#line 810 +#line 810 for(;;) +#line 810 { +#line 810 size_t extent = MIN(remaining, ncp->chunk); +#line 810 size_t nget = ncx_howmany(varp->type, extent); +#line 810 +#line 810 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 810 0, (void **)&xp); /* cast away const */ +#line 810 if(lstatus != NC_NOERR) +#line 810 return lstatus; +#line 810 +#line 810 lstatus = ncx_getn_schar_longlong(&xp, nget, value); +#line 810 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 810 status = lstatus; +#line 810 +#line 810 (void) ncio_rel(ncp->nciop, offset, 0); +#line 810 +#line 810 remaining -= extent; +#line 810 if(remaining == 0) +#line 810 break; /* normal loop exit */ +#line 810 offset += extent; +#line 810 value += nget; +#line 810 } +#line 810 +#line 810 return status; +#line 810 } +#line 810 static int +#line 811 getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp, +#line 811 const size_t *start, size_t nelems, uint *value) +#line 811 { +#line 811 off_t offset = NC_varoffset(ncp, varp, start); +#line 811 size_t remaining = varp->xsz * nelems; +#line 811 int status = NC_NOERR; +#line 811 const void *xp; +#line 811 +#line 811 if(nelems == 0) +#line 811 return NC_NOERR; +#line 811 +#line 811 assert(value != NULL); +#line 811 +#line 811 for(;;) +#line 811 { +#line 811 size_t extent = MIN(remaining, ncp->chunk); +#line 811 size_t nget = ncx_howmany(varp->type, extent); +#line 811 +#line 811 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 811 0, (void **)&xp); /* cast away const */ +#line 811 if(lstatus != NC_NOERR) +#line 811 return lstatus; +#line 811 +#line 811 lstatus = ncx_getn_schar_uint(&xp, nget, value); +#line 811 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 811 status = lstatus; +#line 811 +#line 811 (void) ncio_rel(ncp->nciop, offset, 0); +#line 811 +#line 811 remaining -= extent; +#line 811 if(remaining == 0) +#line 811 break; /* normal loop exit */ +#line 811 offset += extent; +#line 811 value += nget; +#line 811 } +#line 811 +#line 811 return status; +#line 811 } +#line 811 static int +#line 812 getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp, +#line 812 const size_t *start, size_t nelems, ulonglong *value) +#line 812 { +#line 812 off_t offset = NC_varoffset(ncp, varp, start); +#line 812 size_t remaining = varp->xsz * nelems; +#line 812 int status = NC_NOERR; +#line 812 const void *xp; +#line 812 +#line 812 if(nelems == 0) +#line 812 return NC_NOERR; +#line 812 +#line 812 assert(value != NULL); +#line 812 +#line 812 for(;;) +#line 812 { +#line 812 size_t extent = MIN(remaining, ncp->chunk); +#line 812 size_t nget = ncx_howmany(varp->type, extent); +#line 812 +#line 812 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 812 0, (void **)&xp); /* cast away const */ +#line 812 if(lstatus != NC_NOERR) +#line 812 return lstatus; +#line 812 +#line 812 lstatus = ncx_getn_schar_ulonglong(&xp, nget, value); +#line 812 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 812 status = lstatus; +#line 812 +#line 812 (void) ncio_rel(ncp->nciop, offset, 0); +#line 812 +#line 812 remaining -= extent; +#line 812 if(remaining == 0) +#line 812 break; /* normal loop exit */ +#line 812 offset += extent; +#line 812 value += nget; +#line 812 } +#line 812 +#line 812 return status; +#line 812 } +#line 812 static int +#line 814 getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp, +#line 814 const size_t *start, size_t nelems, schar *value) +#line 814 { +#line 814 off_t offset = NC_varoffset(ncp, varp, start); +#line 814 size_t remaining = varp->xsz * nelems; +#line 814 int status = NC_NOERR; +#line 814 const void *xp; +#line 814 +#line 814 if(nelems == 0) +#line 814 return NC_NOERR; +#line 814 +#line 814 assert(value != NULL); +#line 814 +#line 814 for(;;) +#line 814 { +#line 814 size_t extent = MIN(remaining, ncp->chunk); +#line 814 size_t nget = ncx_howmany(varp->type, extent); +#line 814 +#line 814 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 814 0, (void **)&xp); /* cast away const */ +#line 814 if(lstatus != NC_NOERR) +#line 814 return lstatus; +#line 814 +#line 814 lstatus = ncx_getn_short_schar(&xp, nget, value); +#line 814 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 814 status = lstatus; +#line 814 +#line 814 (void) ncio_rel(ncp->nciop, offset, 0); +#line 814 +#line 814 remaining -= extent; +#line 814 if(remaining == 0) +#line 814 break; /* normal loop exit */ +#line 814 offset += extent; +#line 814 value += nget; +#line 814 } +#line 814 +#line 814 return status; +#line 814 } +#line 814 static int +#line 815 getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp, +#line 815 const size_t *start, size_t nelems, uchar *value) +#line 815 { +#line 815 off_t offset = NC_varoffset(ncp, varp, start); +#line 815 size_t remaining = varp->xsz * nelems; +#line 815 int status = NC_NOERR; +#line 815 const void *xp; +#line 815 +#line 815 if(nelems == 0) +#line 815 return NC_NOERR; +#line 815 +#line 815 assert(value != NULL); +#line 815 +#line 815 for(;;) +#line 815 { +#line 815 size_t extent = MIN(remaining, ncp->chunk); +#line 815 size_t nget = ncx_howmany(varp->type, extent); +#line 815 +#line 815 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 815 0, (void **)&xp); /* cast away const */ +#line 815 if(lstatus != NC_NOERR) +#line 815 return lstatus; +#line 815 +#line 815 lstatus = ncx_getn_short_uchar(&xp, nget, value); +#line 815 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 815 status = lstatus; +#line 815 +#line 815 (void) ncio_rel(ncp->nciop, offset, 0); +#line 815 +#line 815 remaining -= extent; +#line 815 if(remaining == 0) +#line 815 break; /* normal loop exit */ +#line 815 offset += extent; +#line 815 value += nget; +#line 815 } +#line 815 +#line 815 return status; +#line 815 } +#line 815 static int +#line 816 getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp, +#line 816 const size_t *start, size_t nelems, short *value) +#line 816 { +#line 816 off_t offset = NC_varoffset(ncp, varp, start); +#line 816 size_t remaining = varp->xsz * nelems; +#line 816 int status = NC_NOERR; +#line 816 const void *xp; +#line 816 +#line 816 if(nelems == 0) +#line 816 return NC_NOERR; +#line 816 +#line 816 assert(value != NULL); +#line 816 +#line 816 for(;;) +#line 816 { +#line 816 size_t extent = MIN(remaining, ncp->chunk); +#line 816 size_t nget = ncx_howmany(varp->type, extent); +#line 816 +#line 816 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 816 0, (void **)&xp); /* cast away const */ +#line 816 if(lstatus != NC_NOERR) +#line 816 return lstatus; +#line 816 +#line 816 lstatus = ncx_getn_short_short(&xp, nget, value); +#line 816 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 816 status = lstatus; +#line 816 +#line 816 (void) ncio_rel(ncp->nciop, offset, 0); +#line 816 +#line 816 remaining -= extent; +#line 816 if(remaining == 0) +#line 816 break; /* normal loop exit */ +#line 816 offset += extent; +#line 816 value += nget; +#line 816 } +#line 816 +#line 816 return status; +#line 816 } +#line 816 static int +#line 817 getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp, +#line 817 const size_t *start, size_t nelems, int *value) +#line 817 { +#line 817 off_t offset = NC_varoffset(ncp, varp, start); +#line 817 size_t remaining = varp->xsz * nelems; +#line 817 int status = NC_NOERR; +#line 817 const void *xp; +#line 817 +#line 817 if(nelems == 0) +#line 817 return NC_NOERR; +#line 817 +#line 817 assert(value != NULL); +#line 817 +#line 817 for(;;) +#line 817 { +#line 817 size_t extent = MIN(remaining, ncp->chunk); +#line 817 size_t nget = ncx_howmany(varp->type, extent); +#line 817 +#line 817 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 817 0, (void **)&xp); /* cast away const */ +#line 817 if(lstatus != NC_NOERR) +#line 817 return lstatus; +#line 817 +#line 817 lstatus = ncx_getn_short_int(&xp, nget, value); +#line 817 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 817 status = lstatus; +#line 817 +#line 817 (void) ncio_rel(ncp->nciop, offset, 0); +#line 817 +#line 817 remaining -= extent; +#line 817 if(remaining == 0) +#line 817 break; /* normal loop exit */ +#line 817 offset += extent; +#line 817 value += nget; +#line 817 } +#line 817 +#line 817 return status; +#line 817 } +#line 817 static int +#line 818 getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp, +#line 818 const size_t *start, size_t nelems, float *value) +#line 818 { +#line 818 off_t offset = NC_varoffset(ncp, varp, start); +#line 818 size_t remaining = varp->xsz * nelems; +#line 818 int status = NC_NOERR; +#line 818 const void *xp; +#line 818 +#line 818 if(nelems == 0) +#line 818 return NC_NOERR; +#line 818 +#line 818 assert(value != NULL); +#line 818 +#line 818 for(;;) +#line 818 { +#line 818 size_t extent = MIN(remaining, ncp->chunk); +#line 818 size_t nget = ncx_howmany(varp->type, extent); +#line 818 +#line 818 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 818 0, (void **)&xp); /* cast away const */ +#line 818 if(lstatus != NC_NOERR) +#line 818 return lstatus; +#line 818 +#line 818 lstatus = ncx_getn_short_float(&xp, nget, value); +#line 818 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 818 status = lstatus; +#line 818 +#line 818 (void) ncio_rel(ncp->nciop, offset, 0); +#line 818 +#line 818 remaining -= extent; +#line 818 if(remaining == 0) +#line 818 break; /* normal loop exit */ +#line 818 offset += extent; +#line 818 value += nget; +#line 818 } +#line 818 +#line 818 return status; +#line 818 } +#line 818 static int +#line 819 getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp, +#line 819 const size_t *start, size_t nelems, double *value) +#line 819 { +#line 819 off_t offset = NC_varoffset(ncp, varp, start); +#line 819 size_t remaining = varp->xsz * nelems; +#line 819 int status = NC_NOERR; +#line 819 const void *xp; +#line 819 +#line 819 if(nelems == 0) +#line 819 return NC_NOERR; +#line 819 +#line 819 assert(value != NULL); +#line 819 +#line 819 for(;;) +#line 819 { +#line 819 size_t extent = MIN(remaining, ncp->chunk); +#line 819 size_t nget = ncx_howmany(varp->type, extent); +#line 819 +#line 819 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 819 0, (void **)&xp); /* cast away const */ +#line 819 if(lstatus != NC_NOERR) +#line 819 return lstatus; +#line 819 +#line 819 lstatus = ncx_getn_short_double(&xp, nget, value); +#line 819 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 819 status = lstatus; +#line 819 +#line 819 (void) ncio_rel(ncp->nciop, offset, 0); +#line 819 +#line 819 remaining -= extent; +#line 819 if(remaining == 0) +#line 819 break; /* normal loop exit */ +#line 819 offset += extent; +#line 819 value += nget; +#line 819 } +#line 819 +#line 819 return status; +#line 819 } +#line 819 static int +#line 820 getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp, +#line 820 const size_t *start, size_t nelems, longlong *value) +#line 820 { +#line 820 off_t offset = NC_varoffset(ncp, varp, start); +#line 820 size_t remaining = varp->xsz * nelems; +#line 820 int status = NC_NOERR; +#line 820 const void *xp; +#line 820 +#line 820 if(nelems == 0) +#line 820 return NC_NOERR; +#line 820 +#line 820 assert(value != NULL); +#line 820 +#line 820 for(;;) +#line 820 { +#line 820 size_t extent = MIN(remaining, ncp->chunk); +#line 820 size_t nget = ncx_howmany(varp->type, extent); +#line 820 +#line 820 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 820 0, (void **)&xp); /* cast away const */ +#line 820 if(lstatus != NC_NOERR) +#line 820 return lstatus; +#line 820 +#line 820 lstatus = ncx_getn_short_longlong(&xp, nget, value); +#line 820 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 820 status = lstatus; +#line 820 +#line 820 (void) ncio_rel(ncp->nciop, offset, 0); +#line 820 +#line 820 remaining -= extent; +#line 820 if(remaining == 0) +#line 820 break; /* normal loop exit */ +#line 820 offset += extent; +#line 820 value += nget; +#line 820 } +#line 820 +#line 820 return status; +#line 820 } +#line 820 static int +#line 821 getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp, +#line 821 const size_t *start, size_t nelems, uint *value) +#line 821 { +#line 821 off_t offset = NC_varoffset(ncp, varp, start); +#line 821 size_t remaining = varp->xsz * nelems; +#line 821 int status = NC_NOERR; +#line 821 const void *xp; +#line 821 +#line 821 if(nelems == 0) +#line 821 return NC_NOERR; +#line 821 +#line 821 assert(value != NULL); +#line 821 +#line 821 for(;;) +#line 821 { +#line 821 size_t extent = MIN(remaining, ncp->chunk); +#line 821 size_t nget = ncx_howmany(varp->type, extent); +#line 821 +#line 821 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 821 0, (void **)&xp); /* cast away const */ +#line 821 if(lstatus != NC_NOERR) +#line 821 return lstatus; +#line 821 +#line 821 lstatus = ncx_getn_short_uint(&xp, nget, value); +#line 821 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 821 status = lstatus; +#line 821 +#line 821 (void) ncio_rel(ncp->nciop, offset, 0); +#line 821 +#line 821 remaining -= extent; +#line 821 if(remaining == 0) +#line 821 break; /* normal loop exit */ +#line 821 offset += extent; +#line 821 value += nget; +#line 821 } +#line 821 +#line 821 return status; +#line 821 } +#line 821 static int +#line 822 getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp, +#line 822 const size_t *start, size_t nelems, ulonglong *value) +#line 822 { +#line 822 off_t offset = NC_varoffset(ncp, varp, start); +#line 822 size_t remaining = varp->xsz * nelems; +#line 822 int status = NC_NOERR; +#line 822 const void *xp; +#line 822 +#line 822 if(nelems == 0) +#line 822 return NC_NOERR; +#line 822 +#line 822 assert(value != NULL); +#line 822 +#line 822 for(;;) +#line 822 { +#line 822 size_t extent = MIN(remaining, ncp->chunk); +#line 822 size_t nget = ncx_howmany(varp->type, extent); +#line 822 +#line 822 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 822 0, (void **)&xp); /* cast away const */ +#line 822 if(lstatus != NC_NOERR) +#line 822 return lstatus; +#line 822 +#line 822 lstatus = ncx_getn_short_ulonglong(&xp, nget, value); +#line 822 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 822 status = lstatus; +#line 822 +#line 822 (void) ncio_rel(ncp->nciop, offset, 0); +#line 822 +#line 822 remaining -= extent; +#line 822 if(remaining == 0) +#line 822 break; /* normal loop exit */ +#line 822 offset += extent; +#line 822 value += nget; +#line 822 } +#line 822 +#line 822 return status; +#line 822 } +#line 822 static int +#line 824 getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp, +#line 824 const size_t *start, size_t nelems, schar *value) +#line 824 { +#line 824 off_t offset = NC_varoffset(ncp, varp, start); +#line 824 size_t remaining = varp->xsz * nelems; +#line 824 int status = NC_NOERR; +#line 824 const void *xp; +#line 824 +#line 824 if(nelems == 0) +#line 824 return NC_NOERR; +#line 824 +#line 824 assert(value != NULL); +#line 824 +#line 824 for(;;) +#line 824 { +#line 824 size_t extent = MIN(remaining, ncp->chunk); +#line 824 size_t nget = ncx_howmany(varp->type, extent); +#line 824 +#line 824 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 824 0, (void **)&xp); /* cast away const */ +#line 824 if(lstatus != NC_NOERR) +#line 824 return lstatus; +#line 824 +#line 824 lstatus = ncx_getn_int_schar(&xp, nget, value); +#line 824 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 824 status = lstatus; +#line 824 +#line 824 (void) ncio_rel(ncp->nciop, offset, 0); +#line 824 +#line 824 remaining -= extent; +#line 824 if(remaining == 0) +#line 824 break; /* normal loop exit */ +#line 824 offset += extent; +#line 824 value += nget; +#line 824 } +#line 824 +#line 824 return status; +#line 824 } +#line 824 static int +#line 825 getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp, +#line 825 const size_t *start, size_t nelems, uchar *value) +#line 825 { +#line 825 off_t offset = NC_varoffset(ncp, varp, start); +#line 825 size_t remaining = varp->xsz * nelems; +#line 825 int status = NC_NOERR; +#line 825 const void *xp; +#line 825 +#line 825 if(nelems == 0) +#line 825 return NC_NOERR; +#line 825 +#line 825 assert(value != NULL); +#line 825 +#line 825 for(;;) +#line 825 { +#line 825 size_t extent = MIN(remaining, ncp->chunk); +#line 825 size_t nget = ncx_howmany(varp->type, extent); +#line 825 +#line 825 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 825 0, (void **)&xp); /* cast away const */ +#line 825 if(lstatus != NC_NOERR) +#line 825 return lstatus; +#line 825 +#line 825 lstatus = ncx_getn_int_uchar(&xp, nget, value); +#line 825 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 825 status = lstatus; +#line 825 +#line 825 (void) ncio_rel(ncp->nciop, offset, 0); +#line 825 +#line 825 remaining -= extent; +#line 825 if(remaining == 0) +#line 825 break; /* normal loop exit */ +#line 825 offset += extent; +#line 825 value += nget; +#line 825 } +#line 825 +#line 825 return status; +#line 825 } +#line 825 static int +#line 826 getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp, +#line 826 const size_t *start, size_t nelems, short *value) +#line 826 { +#line 826 off_t offset = NC_varoffset(ncp, varp, start); +#line 826 size_t remaining = varp->xsz * nelems; +#line 826 int status = NC_NOERR; +#line 826 const void *xp; +#line 826 +#line 826 if(nelems == 0) +#line 826 return NC_NOERR; +#line 826 +#line 826 assert(value != NULL); +#line 826 +#line 826 for(;;) +#line 826 { +#line 826 size_t extent = MIN(remaining, ncp->chunk); +#line 826 size_t nget = ncx_howmany(varp->type, extent); +#line 826 +#line 826 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 826 0, (void **)&xp); /* cast away const */ +#line 826 if(lstatus != NC_NOERR) +#line 826 return lstatus; +#line 826 +#line 826 lstatus = ncx_getn_int_short(&xp, nget, value); +#line 826 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 826 status = lstatus; +#line 826 +#line 826 (void) ncio_rel(ncp->nciop, offset, 0); +#line 826 +#line 826 remaining -= extent; +#line 826 if(remaining == 0) +#line 826 break; /* normal loop exit */ +#line 826 offset += extent; +#line 826 value += nget; +#line 826 } +#line 826 +#line 826 return status; +#line 826 } +#line 826 static int +#line 827 getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp, +#line 827 const size_t *start, size_t nelems, int *value) +#line 827 { +#line 827 off_t offset = NC_varoffset(ncp, varp, start); +#line 827 size_t remaining = varp->xsz * nelems; +#line 827 int status = NC_NOERR; +#line 827 const void *xp; +#line 827 +#line 827 if(nelems == 0) +#line 827 return NC_NOERR; +#line 827 +#line 827 assert(value != NULL); +#line 827 +#line 827 for(;;) +#line 827 { +#line 827 size_t extent = MIN(remaining, ncp->chunk); +#line 827 size_t nget = ncx_howmany(varp->type, extent); +#line 827 +#line 827 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 827 0, (void **)&xp); /* cast away const */ +#line 827 if(lstatus != NC_NOERR) +#line 827 return lstatus; +#line 827 +#line 827 lstatus = ncx_getn_int_int(&xp, nget, value); +#line 827 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 827 status = lstatus; +#line 827 +#line 827 (void) ncio_rel(ncp->nciop, offset, 0); +#line 827 +#line 827 remaining -= extent; +#line 827 if(remaining == 0) +#line 827 break; /* normal loop exit */ +#line 827 offset += extent; +#line 827 value += nget; +#line 827 } +#line 827 +#line 827 return status; +#line 827 } +#line 827 static int +#line 828 getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp, +#line 828 const size_t *start, size_t nelems, float *value) +#line 828 { +#line 828 off_t offset = NC_varoffset(ncp, varp, start); +#line 828 size_t remaining = varp->xsz * nelems; +#line 828 int status = NC_NOERR; +#line 828 const void *xp; +#line 828 +#line 828 if(nelems == 0) +#line 828 return NC_NOERR; +#line 828 +#line 828 assert(value != NULL); +#line 828 +#line 828 for(;;) +#line 828 { +#line 828 size_t extent = MIN(remaining, ncp->chunk); +#line 828 size_t nget = ncx_howmany(varp->type, extent); +#line 828 +#line 828 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 828 0, (void **)&xp); /* cast away const */ +#line 828 if(lstatus != NC_NOERR) +#line 828 return lstatus; +#line 828 +#line 828 lstatus = ncx_getn_int_float(&xp, nget, value); +#line 828 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 828 status = lstatus; +#line 828 +#line 828 (void) ncio_rel(ncp->nciop, offset, 0); +#line 828 +#line 828 remaining -= extent; +#line 828 if(remaining == 0) +#line 828 break; /* normal loop exit */ +#line 828 offset += extent; +#line 828 value += nget; +#line 828 } +#line 828 +#line 828 return status; +#line 828 } +#line 828 static int +#line 829 getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp, +#line 829 const size_t *start, size_t nelems, double *value) +#line 829 { +#line 829 off_t offset = NC_varoffset(ncp, varp, start); +#line 829 size_t remaining = varp->xsz * nelems; +#line 829 int status = NC_NOERR; +#line 829 const void *xp; +#line 829 +#line 829 if(nelems == 0) +#line 829 return NC_NOERR; +#line 829 +#line 829 assert(value != NULL); +#line 829 +#line 829 for(;;) +#line 829 { +#line 829 size_t extent = MIN(remaining, ncp->chunk); +#line 829 size_t nget = ncx_howmany(varp->type, extent); +#line 829 +#line 829 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 829 0, (void **)&xp); /* cast away const */ +#line 829 if(lstatus != NC_NOERR) +#line 829 return lstatus; +#line 829 +#line 829 lstatus = ncx_getn_int_double(&xp, nget, value); +#line 829 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 829 status = lstatus; +#line 829 +#line 829 (void) ncio_rel(ncp->nciop, offset, 0); +#line 829 +#line 829 remaining -= extent; +#line 829 if(remaining == 0) +#line 829 break; /* normal loop exit */ +#line 829 offset += extent; +#line 829 value += nget; +#line 829 } +#line 829 +#line 829 return status; +#line 829 } +#line 829 static int +#line 830 getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp, +#line 830 const size_t *start, size_t nelems, longlong *value) +#line 830 { +#line 830 off_t offset = NC_varoffset(ncp, varp, start); +#line 830 size_t remaining = varp->xsz * nelems; +#line 830 int status = NC_NOERR; +#line 830 const void *xp; +#line 830 +#line 830 if(nelems == 0) +#line 830 return NC_NOERR; +#line 830 +#line 830 assert(value != NULL); +#line 830 +#line 830 for(;;) +#line 830 { +#line 830 size_t extent = MIN(remaining, ncp->chunk); +#line 830 size_t nget = ncx_howmany(varp->type, extent); +#line 830 +#line 830 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 830 0, (void **)&xp); /* cast away const */ +#line 830 if(lstatus != NC_NOERR) +#line 830 return lstatus; +#line 830 +#line 830 lstatus = ncx_getn_int_longlong(&xp, nget, value); +#line 830 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 830 status = lstatus; +#line 830 +#line 830 (void) ncio_rel(ncp->nciop, offset, 0); +#line 830 +#line 830 remaining -= extent; +#line 830 if(remaining == 0) +#line 830 break; /* normal loop exit */ +#line 830 offset += extent; +#line 830 value += nget; +#line 830 } +#line 830 +#line 830 return status; +#line 830 } +#line 830 static int +#line 831 getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp, +#line 831 const size_t *start, size_t nelems, uint *value) +#line 831 { +#line 831 off_t offset = NC_varoffset(ncp, varp, start); +#line 831 size_t remaining = varp->xsz * nelems; +#line 831 int status = NC_NOERR; +#line 831 const void *xp; +#line 831 +#line 831 if(nelems == 0) +#line 831 return NC_NOERR; +#line 831 +#line 831 assert(value != NULL); +#line 831 +#line 831 for(;;) +#line 831 { +#line 831 size_t extent = MIN(remaining, ncp->chunk); +#line 831 size_t nget = ncx_howmany(varp->type, extent); +#line 831 +#line 831 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 831 0, (void **)&xp); /* cast away const */ +#line 831 if(lstatus != NC_NOERR) +#line 831 return lstatus; +#line 831 +#line 831 lstatus = ncx_getn_int_uint(&xp, nget, value); +#line 831 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 831 status = lstatus; +#line 831 +#line 831 (void) ncio_rel(ncp->nciop, offset, 0); +#line 831 +#line 831 remaining -= extent; +#line 831 if(remaining == 0) +#line 831 break; /* normal loop exit */ +#line 831 offset += extent; +#line 831 value += nget; +#line 831 } +#line 831 +#line 831 return status; +#line 831 } +#line 831 static int +#line 832 getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp, +#line 832 const size_t *start, size_t nelems, ulonglong *value) +#line 832 { +#line 832 off_t offset = NC_varoffset(ncp, varp, start); +#line 832 size_t remaining = varp->xsz * nelems; +#line 832 int status = NC_NOERR; +#line 832 const void *xp; +#line 832 +#line 832 if(nelems == 0) +#line 832 return NC_NOERR; +#line 832 +#line 832 assert(value != NULL); +#line 832 +#line 832 for(;;) +#line 832 { +#line 832 size_t extent = MIN(remaining, ncp->chunk); +#line 832 size_t nget = ncx_howmany(varp->type, extent); +#line 832 +#line 832 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 832 0, (void **)&xp); /* cast away const */ +#line 832 if(lstatus != NC_NOERR) +#line 832 return lstatus; +#line 832 +#line 832 lstatus = ncx_getn_int_ulonglong(&xp, nget, value); +#line 832 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 832 status = lstatus; +#line 832 +#line 832 (void) ncio_rel(ncp->nciop, offset, 0); +#line 832 +#line 832 remaining -= extent; +#line 832 if(remaining == 0) +#line 832 break; /* normal loop exit */ +#line 832 offset += extent; +#line 832 value += nget; +#line 832 } +#line 832 +#line 832 return status; +#line 832 } +#line 832 static int +#line 834 getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp, +#line 834 const size_t *start, size_t nelems, schar *value) +#line 834 { +#line 834 off_t offset = NC_varoffset(ncp, varp, start); +#line 834 size_t remaining = varp->xsz * nelems; +#line 834 int status = NC_NOERR; +#line 834 const void *xp; +#line 834 +#line 834 if(nelems == 0) +#line 834 return NC_NOERR; +#line 834 +#line 834 assert(value != NULL); +#line 834 +#line 834 for(;;) +#line 834 { +#line 834 size_t extent = MIN(remaining, ncp->chunk); +#line 834 size_t nget = ncx_howmany(varp->type, extent); +#line 834 +#line 834 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 834 0, (void **)&xp); /* cast away const */ +#line 834 if(lstatus != NC_NOERR) +#line 834 return lstatus; +#line 834 +#line 834 lstatus = ncx_getn_float_schar(&xp, nget, value); +#line 834 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 834 status = lstatus; +#line 834 +#line 834 (void) ncio_rel(ncp->nciop, offset, 0); +#line 834 +#line 834 remaining -= extent; +#line 834 if(remaining == 0) +#line 834 break; /* normal loop exit */ +#line 834 offset += extent; +#line 834 value += nget; +#line 834 } +#line 834 +#line 834 return status; +#line 834 } +#line 834 static int +#line 835 getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp, +#line 835 const size_t *start, size_t nelems, uchar *value) +#line 835 { +#line 835 off_t offset = NC_varoffset(ncp, varp, start); +#line 835 size_t remaining = varp->xsz * nelems; +#line 835 int status = NC_NOERR; +#line 835 const void *xp; +#line 835 +#line 835 if(nelems == 0) +#line 835 return NC_NOERR; +#line 835 +#line 835 assert(value != NULL); +#line 835 +#line 835 for(;;) +#line 835 { +#line 835 size_t extent = MIN(remaining, ncp->chunk); +#line 835 size_t nget = ncx_howmany(varp->type, extent); +#line 835 +#line 835 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 835 0, (void **)&xp); /* cast away const */ +#line 835 if(lstatus != NC_NOERR) +#line 835 return lstatus; +#line 835 +#line 835 lstatus = ncx_getn_float_uchar(&xp, nget, value); +#line 835 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 835 status = lstatus; +#line 835 +#line 835 (void) ncio_rel(ncp->nciop, offset, 0); +#line 835 +#line 835 remaining -= extent; +#line 835 if(remaining == 0) +#line 835 break; /* normal loop exit */ +#line 835 offset += extent; +#line 835 value += nget; +#line 835 } +#line 835 +#line 835 return status; +#line 835 } +#line 835 static int +#line 836 getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp, +#line 836 const size_t *start, size_t nelems, short *value) +#line 836 { +#line 836 off_t offset = NC_varoffset(ncp, varp, start); +#line 836 size_t remaining = varp->xsz * nelems; +#line 836 int status = NC_NOERR; +#line 836 const void *xp; +#line 836 +#line 836 if(nelems == 0) +#line 836 return NC_NOERR; +#line 836 +#line 836 assert(value != NULL); +#line 836 +#line 836 for(;;) +#line 836 { +#line 836 size_t extent = MIN(remaining, ncp->chunk); +#line 836 size_t nget = ncx_howmany(varp->type, extent); +#line 836 +#line 836 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 836 0, (void **)&xp); /* cast away const */ +#line 836 if(lstatus != NC_NOERR) +#line 836 return lstatus; +#line 836 +#line 836 lstatus = ncx_getn_float_short(&xp, nget, value); +#line 836 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 836 status = lstatus; +#line 836 +#line 836 (void) ncio_rel(ncp->nciop, offset, 0); +#line 836 +#line 836 remaining -= extent; +#line 836 if(remaining == 0) +#line 836 break; /* normal loop exit */ +#line 836 offset += extent; +#line 836 value += nget; +#line 836 } +#line 836 +#line 836 return status; +#line 836 } +#line 836 static int +#line 837 getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp, +#line 837 const size_t *start, size_t nelems, int *value) +#line 837 { +#line 837 off_t offset = NC_varoffset(ncp, varp, start); +#line 837 size_t remaining = varp->xsz * nelems; +#line 837 int status = NC_NOERR; +#line 837 const void *xp; +#line 837 +#line 837 if(nelems == 0) +#line 837 return NC_NOERR; +#line 837 +#line 837 assert(value != NULL); +#line 837 +#line 837 for(;;) +#line 837 { +#line 837 size_t extent = MIN(remaining, ncp->chunk); +#line 837 size_t nget = ncx_howmany(varp->type, extent); +#line 837 +#line 837 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 837 0, (void **)&xp); /* cast away const */ +#line 837 if(lstatus != NC_NOERR) +#line 837 return lstatus; +#line 837 +#line 837 lstatus = ncx_getn_float_int(&xp, nget, value); +#line 837 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 837 status = lstatus; +#line 837 +#line 837 (void) ncio_rel(ncp->nciop, offset, 0); +#line 837 +#line 837 remaining -= extent; +#line 837 if(remaining == 0) +#line 837 break; /* normal loop exit */ +#line 837 offset += extent; +#line 837 value += nget; +#line 837 } +#line 837 +#line 837 return status; +#line 837 } +#line 837 static int +#line 838 getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp, +#line 838 const size_t *start, size_t nelems, float *value) +#line 838 { +#line 838 off_t offset = NC_varoffset(ncp, varp, start); +#line 838 size_t remaining = varp->xsz * nelems; +#line 838 int status = NC_NOERR; +#line 838 const void *xp; +#line 838 +#line 838 if(nelems == 0) +#line 838 return NC_NOERR; +#line 838 +#line 838 assert(value != NULL); +#line 838 +#line 838 for(;;) +#line 838 { +#line 838 size_t extent = MIN(remaining, ncp->chunk); +#line 838 size_t nget = ncx_howmany(varp->type, extent); +#line 838 +#line 838 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 838 0, (void **)&xp); /* cast away const */ +#line 838 if(lstatus != NC_NOERR) +#line 838 return lstatus; +#line 838 +#line 838 lstatus = ncx_getn_float_float(&xp, nget, value); +#line 838 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 838 status = lstatus; +#line 838 +#line 838 (void) ncio_rel(ncp->nciop, offset, 0); +#line 838 +#line 838 remaining -= extent; +#line 838 if(remaining == 0) +#line 838 break; /* normal loop exit */ +#line 838 offset += extent; +#line 838 value += nget; +#line 838 } +#line 838 +#line 838 return status; +#line 838 } +#line 838 static int +#line 839 getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp, +#line 839 const size_t *start, size_t nelems, double *value) +#line 839 { +#line 839 off_t offset = NC_varoffset(ncp, varp, start); +#line 839 size_t remaining = varp->xsz * nelems; +#line 839 int status = NC_NOERR; +#line 839 const void *xp; +#line 839 +#line 839 if(nelems == 0) +#line 839 return NC_NOERR; +#line 839 +#line 839 assert(value != NULL); +#line 839 +#line 839 for(;;) +#line 839 { +#line 839 size_t extent = MIN(remaining, ncp->chunk); +#line 839 size_t nget = ncx_howmany(varp->type, extent); +#line 839 +#line 839 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 839 0, (void **)&xp); /* cast away const */ +#line 839 if(lstatus != NC_NOERR) +#line 839 return lstatus; +#line 839 +#line 839 lstatus = ncx_getn_float_double(&xp, nget, value); +#line 839 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 839 status = lstatus; +#line 839 +#line 839 (void) ncio_rel(ncp->nciop, offset, 0); +#line 839 +#line 839 remaining -= extent; +#line 839 if(remaining == 0) +#line 839 break; /* normal loop exit */ +#line 839 offset += extent; +#line 839 value += nget; +#line 839 } +#line 839 +#line 839 return status; +#line 839 } +#line 839 static int +#line 840 getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp, +#line 840 const size_t *start, size_t nelems, longlong *value) +#line 840 { +#line 840 off_t offset = NC_varoffset(ncp, varp, start); +#line 840 size_t remaining = varp->xsz * nelems; +#line 840 int status = NC_NOERR; +#line 840 const void *xp; +#line 840 +#line 840 if(nelems == 0) +#line 840 return NC_NOERR; +#line 840 +#line 840 assert(value != NULL); +#line 840 +#line 840 for(;;) +#line 840 { +#line 840 size_t extent = MIN(remaining, ncp->chunk); +#line 840 size_t nget = ncx_howmany(varp->type, extent); +#line 840 +#line 840 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 840 0, (void **)&xp); /* cast away const */ +#line 840 if(lstatus != NC_NOERR) +#line 840 return lstatus; +#line 840 +#line 840 lstatus = ncx_getn_float_longlong(&xp, nget, value); +#line 840 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 840 status = lstatus; +#line 840 +#line 840 (void) ncio_rel(ncp->nciop, offset, 0); +#line 840 +#line 840 remaining -= extent; +#line 840 if(remaining == 0) +#line 840 break; /* normal loop exit */ +#line 840 offset += extent; +#line 840 value += nget; +#line 840 } +#line 840 +#line 840 return status; +#line 840 } +#line 840 static int +#line 841 getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp, +#line 841 const size_t *start, size_t nelems, uint *value) +#line 841 { +#line 841 off_t offset = NC_varoffset(ncp, varp, start); +#line 841 size_t remaining = varp->xsz * nelems; +#line 841 int status = NC_NOERR; +#line 841 const void *xp; +#line 841 +#line 841 if(nelems == 0) +#line 841 return NC_NOERR; +#line 841 +#line 841 assert(value != NULL); +#line 841 +#line 841 for(;;) +#line 841 { +#line 841 size_t extent = MIN(remaining, ncp->chunk); +#line 841 size_t nget = ncx_howmany(varp->type, extent); +#line 841 +#line 841 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 841 0, (void **)&xp); /* cast away const */ +#line 841 if(lstatus != NC_NOERR) +#line 841 return lstatus; +#line 841 +#line 841 lstatus = ncx_getn_float_uint(&xp, nget, value); +#line 841 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 841 status = lstatus; +#line 841 +#line 841 (void) ncio_rel(ncp->nciop, offset, 0); +#line 841 +#line 841 remaining -= extent; +#line 841 if(remaining == 0) +#line 841 break; /* normal loop exit */ +#line 841 offset += extent; +#line 841 value += nget; +#line 841 } +#line 841 +#line 841 return status; +#line 841 } +#line 841 static int +#line 842 getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp, +#line 842 const size_t *start, size_t nelems, ulonglong *value) +#line 842 { +#line 842 off_t offset = NC_varoffset(ncp, varp, start); +#line 842 size_t remaining = varp->xsz * nelems; +#line 842 int status = NC_NOERR; +#line 842 const void *xp; +#line 842 +#line 842 if(nelems == 0) +#line 842 return NC_NOERR; +#line 842 +#line 842 assert(value != NULL); +#line 842 +#line 842 for(;;) +#line 842 { +#line 842 size_t extent = MIN(remaining, ncp->chunk); +#line 842 size_t nget = ncx_howmany(varp->type, extent); +#line 842 +#line 842 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 842 0, (void **)&xp); /* cast away const */ +#line 842 if(lstatus != NC_NOERR) +#line 842 return lstatus; +#line 842 +#line 842 lstatus = ncx_getn_float_ulonglong(&xp, nget, value); +#line 842 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 842 status = lstatus; +#line 842 +#line 842 (void) ncio_rel(ncp->nciop, offset, 0); +#line 842 +#line 842 remaining -= extent; +#line 842 if(remaining == 0) +#line 842 break; /* normal loop exit */ +#line 842 offset += extent; +#line 842 value += nget; +#line 842 } +#line 842 +#line 842 return status; +#line 842 } +#line 842 static int +#line 844 getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp, +#line 844 const size_t *start, size_t nelems, schar *value) +#line 844 { +#line 844 off_t offset = NC_varoffset(ncp, varp, start); +#line 844 size_t remaining = varp->xsz * nelems; +#line 844 int status = NC_NOERR; +#line 844 const void *xp; +#line 844 +#line 844 if(nelems == 0) +#line 844 return NC_NOERR; +#line 844 +#line 844 assert(value != NULL); +#line 844 +#line 844 for(;;) +#line 844 { +#line 844 size_t extent = MIN(remaining, ncp->chunk); +#line 844 size_t nget = ncx_howmany(varp->type, extent); +#line 844 +#line 844 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 844 0, (void **)&xp); /* cast away const */ +#line 844 if(lstatus != NC_NOERR) +#line 844 return lstatus; +#line 844 +#line 844 lstatus = ncx_getn_double_schar(&xp, nget, value); +#line 844 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 844 status = lstatus; +#line 844 +#line 844 (void) ncio_rel(ncp->nciop, offset, 0); +#line 844 +#line 844 remaining -= extent; +#line 844 if(remaining == 0) +#line 844 break; /* normal loop exit */ +#line 844 offset += extent; +#line 844 value += nget; +#line 844 } +#line 844 +#line 844 return status; +#line 844 } +#line 844 static int +#line 845 getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp, +#line 845 const size_t *start, size_t nelems, uchar *value) +#line 845 { +#line 845 off_t offset = NC_varoffset(ncp, varp, start); +#line 845 size_t remaining = varp->xsz * nelems; +#line 845 int status = NC_NOERR; +#line 845 const void *xp; +#line 845 +#line 845 if(nelems == 0) +#line 845 return NC_NOERR; +#line 845 +#line 845 assert(value != NULL); +#line 845 +#line 845 for(;;) +#line 845 { +#line 845 size_t extent = MIN(remaining, ncp->chunk); +#line 845 size_t nget = ncx_howmany(varp->type, extent); +#line 845 +#line 845 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 845 0, (void **)&xp); /* cast away const */ +#line 845 if(lstatus != NC_NOERR) +#line 845 return lstatus; +#line 845 +#line 845 lstatus = ncx_getn_double_uchar(&xp, nget, value); +#line 845 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 845 status = lstatus; +#line 845 +#line 845 (void) ncio_rel(ncp->nciop, offset, 0); +#line 845 +#line 845 remaining -= extent; +#line 845 if(remaining == 0) +#line 845 break; /* normal loop exit */ +#line 845 offset += extent; +#line 845 value += nget; +#line 845 } +#line 845 +#line 845 return status; +#line 845 } +#line 845 static int +#line 846 getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp, +#line 846 const size_t *start, size_t nelems, short *value) +#line 846 { +#line 846 off_t offset = NC_varoffset(ncp, varp, start); +#line 846 size_t remaining = varp->xsz * nelems; +#line 846 int status = NC_NOERR; +#line 846 const void *xp; +#line 846 +#line 846 if(nelems == 0) +#line 846 return NC_NOERR; +#line 846 +#line 846 assert(value != NULL); +#line 846 +#line 846 for(;;) +#line 846 { +#line 846 size_t extent = MIN(remaining, ncp->chunk); +#line 846 size_t nget = ncx_howmany(varp->type, extent); +#line 846 +#line 846 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 846 0, (void **)&xp); /* cast away const */ +#line 846 if(lstatus != NC_NOERR) +#line 846 return lstatus; +#line 846 +#line 846 lstatus = ncx_getn_double_short(&xp, nget, value); +#line 846 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 846 status = lstatus; +#line 846 +#line 846 (void) ncio_rel(ncp->nciop, offset, 0); +#line 846 +#line 846 remaining -= extent; +#line 846 if(remaining == 0) +#line 846 break; /* normal loop exit */ +#line 846 offset += extent; +#line 846 value += nget; +#line 846 } +#line 846 +#line 846 return status; +#line 846 } +#line 846 static int +#line 847 getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp, +#line 847 const size_t *start, size_t nelems, int *value) +#line 847 { +#line 847 off_t offset = NC_varoffset(ncp, varp, start); +#line 847 size_t remaining = varp->xsz * nelems; +#line 847 int status = NC_NOERR; +#line 847 const void *xp; +#line 847 +#line 847 if(nelems == 0) +#line 847 return NC_NOERR; +#line 847 +#line 847 assert(value != NULL); +#line 847 +#line 847 for(;;) +#line 847 { +#line 847 size_t extent = MIN(remaining, ncp->chunk); +#line 847 size_t nget = ncx_howmany(varp->type, extent); +#line 847 +#line 847 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 847 0, (void **)&xp); /* cast away const */ +#line 847 if(lstatus != NC_NOERR) +#line 847 return lstatus; +#line 847 +#line 847 lstatus = ncx_getn_double_int(&xp, nget, value); +#line 847 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 847 status = lstatus; +#line 847 +#line 847 (void) ncio_rel(ncp->nciop, offset, 0); +#line 847 +#line 847 remaining -= extent; +#line 847 if(remaining == 0) +#line 847 break; /* normal loop exit */ +#line 847 offset += extent; +#line 847 value += nget; +#line 847 } +#line 847 +#line 847 return status; +#line 847 } +#line 847 static int +#line 848 getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp, +#line 848 const size_t *start, size_t nelems, float *value) +#line 848 { +#line 848 off_t offset = NC_varoffset(ncp, varp, start); +#line 848 size_t remaining = varp->xsz * nelems; +#line 848 int status = NC_NOERR; +#line 848 const void *xp; +#line 848 +#line 848 if(nelems == 0) +#line 848 return NC_NOERR; +#line 848 +#line 848 assert(value != NULL); +#line 848 +#line 848 for(;;) +#line 848 { +#line 848 size_t extent = MIN(remaining, ncp->chunk); +#line 848 size_t nget = ncx_howmany(varp->type, extent); +#line 848 +#line 848 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 848 0, (void **)&xp); /* cast away const */ +#line 848 if(lstatus != NC_NOERR) +#line 848 return lstatus; +#line 848 +#line 848 lstatus = ncx_getn_double_float(&xp, nget, value); +#line 848 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 848 status = lstatus; +#line 848 +#line 848 (void) ncio_rel(ncp->nciop, offset, 0); +#line 848 +#line 848 remaining -= extent; +#line 848 if(remaining == 0) +#line 848 break; /* normal loop exit */ +#line 848 offset += extent; +#line 848 value += nget; +#line 848 } +#line 848 +#line 848 return status; +#line 848 } +#line 848 static int +#line 849 getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp, +#line 849 const size_t *start, size_t nelems, double *value) +#line 849 { +#line 849 off_t offset = NC_varoffset(ncp, varp, start); +#line 849 size_t remaining = varp->xsz * nelems; +#line 849 int status = NC_NOERR; +#line 849 const void *xp; +#line 849 +#line 849 if(nelems == 0) +#line 849 return NC_NOERR; +#line 849 +#line 849 assert(value != NULL); +#line 849 +#line 849 for(;;) +#line 849 { +#line 849 size_t extent = MIN(remaining, ncp->chunk); +#line 849 size_t nget = ncx_howmany(varp->type, extent); +#line 849 +#line 849 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 849 0, (void **)&xp); /* cast away const */ +#line 849 if(lstatus != NC_NOERR) +#line 849 return lstatus; +#line 849 +#line 849 lstatus = ncx_getn_double_double(&xp, nget, value); +#line 849 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 849 status = lstatus; +#line 849 +#line 849 (void) ncio_rel(ncp->nciop, offset, 0); +#line 849 +#line 849 remaining -= extent; +#line 849 if(remaining == 0) +#line 849 break; /* normal loop exit */ +#line 849 offset += extent; +#line 849 value += nget; +#line 849 } +#line 849 +#line 849 return status; +#line 849 } +#line 849 static int +#line 850 getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp, +#line 850 const size_t *start, size_t nelems, longlong *value) +#line 850 { +#line 850 off_t offset = NC_varoffset(ncp, varp, start); +#line 850 size_t remaining = varp->xsz * nelems; +#line 850 int status = NC_NOERR; +#line 850 const void *xp; +#line 850 +#line 850 if(nelems == 0) +#line 850 return NC_NOERR; +#line 850 +#line 850 assert(value != NULL); +#line 850 +#line 850 for(;;) +#line 850 { +#line 850 size_t extent = MIN(remaining, ncp->chunk); +#line 850 size_t nget = ncx_howmany(varp->type, extent); +#line 850 +#line 850 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 850 0, (void **)&xp); /* cast away const */ +#line 850 if(lstatus != NC_NOERR) +#line 850 return lstatus; +#line 850 +#line 850 lstatus = ncx_getn_double_longlong(&xp, nget, value); +#line 850 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 850 status = lstatus; +#line 850 +#line 850 (void) ncio_rel(ncp->nciop, offset, 0); +#line 850 +#line 850 remaining -= extent; +#line 850 if(remaining == 0) +#line 850 break; /* normal loop exit */ +#line 850 offset += extent; +#line 850 value += nget; +#line 850 } +#line 850 +#line 850 return status; +#line 850 } +#line 850 static int +#line 851 getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp, +#line 851 const size_t *start, size_t nelems, uint *value) +#line 851 { +#line 851 off_t offset = NC_varoffset(ncp, varp, start); +#line 851 size_t remaining = varp->xsz * nelems; +#line 851 int status = NC_NOERR; +#line 851 const void *xp; +#line 851 +#line 851 if(nelems == 0) +#line 851 return NC_NOERR; +#line 851 +#line 851 assert(value != NULL); +#line 851 +#line 851 for(;;) +#line 851 { +#line 851 size_t extent = MIN(remaining, ncp->chunk); +#line 851 size_t nget = ncx_howmany(varp->type, extent); +#line 851 +#line 851 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 851 0, (void **)&xp); /* cast away const */ +#line 851 if(lstatus != NC_NOERR) +#line 851 return lstatus; +#line 851 +#line 851 lstatus = ncx_getn_double_uint(&xp, nget, value); +#line 851 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 851 status = lstatus; +#line 851 +#line 851 (void) ncio_rel(ncp->nciop, offset, 0); +#line 851 +#line 851 remaining -= extent; +#line 851 if(remaining == 0) +#line 851 break; /* normal loop exit */ +#line 851 offset += extent; +#line 851 value += nget; +#line 851 } +#line 851 +#line 851 return status; +#line 851 } +#line 851 static int +#line 852 getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp, +#line 852 const size_t *start, size_t nelems, ulonglong *value) +#line 852 { +#line 852 off_t offset = NC_varoffset(ncp, varp, start); +#line 852 size_t remaining = varp->xsz * nelems; +#line 852 int status = NC_NOERR; +#line 852 const void *xp; +#line 852 +#line 852 if(nelems == 0) +#line 852 return NC_NOERR; +#line 852 +#line 852 assert(value != NULL); +#line 852 +#line 852 for(;;) +#line 852 { +#line 852 size_t extent = MIN(remaining, ncp->chunk); +#line 852 size_t nget = ncx_howmany(varp->type, extent); +#line 852 +#line 852 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 852 0, (void **)&xp); /* cast away const */ +#line 852 if(lstatus != NC_NOERR) +#line 852 return lstatus; +#line 852 +#line 852 lstatus = ncx_getn_double_ulonglong(&xp, nget, value); +#line 852 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 852 status = lstatus; +#line 852 +#line 852 (void) ncio_rel(ncp->nciop, offset, 0); +#line 852 +#line 852 remaining -= extent; +#line 852 if(remaining == 0) +#line 852 break; /* normal loop exit */ +#line 852 offset += extent; +#line 852 value += nget; +#line 852 } +#line 852 +#line 852 return status; +#line 852 } +#line 852 +#line 855 #ifdef NOTUSED static int +#line 856 getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp, +#line 856 const size_t *start, size_t nelems, uchar *value) +#line 856 { +#line 856 off_t offset = NC_varoffset(ncp, varp, start); +#line 856 size_t remaining = varp->xsz * nelems; +#line 856 int status = NC_NOERR; +#line 856 const void *xp; +#line 856 +#line 856 if(nelems == 0) +#line 856 return NC_NOERR; +#line 856 +#line 856 assert(value != NULL); +#line 856 +#line 856 for(;;) +#line 856 { +#line 856 size_t extent = MIN(remaining, ncp->chunk); +#line 856 size_t nget = ncx_howmany(varp->type, extent); +#line 856 +#line 856 int lstatus = ncio_get(ncp->nciop, offset, extent, +#line 856 0, (void **)&xp); /* cast away const */ +#line 856 if(lstatus != NC_NOERR) +#line 856 return lstatus; +#line 856 +#line 856 lstatus = ncx_getn_schar_uchar(&xp, nget, value); +#line 856 if(lstatus != NC_NOERR && status == NC_NOERR) +#line 856 status = lstatus; +#line 856 +#line 856 (void) ncio_rel(ncp->nciop, offset, 0); +#line 856 +#line 856 remaining -= extent; +#line 856 if(remaining == 0) +#line 856 break; /* normal loop exit */ +#line 856 offset += extent; +#line 856 value += nget; +#line 856 } +#line 856 +#line 856 return status; +#line 856 } +#line 856 #endif /*NOTUSED*/ @@ -4814,6 +8772,7 @@ odo1(const size_t *const start, const size_t *const upper, #endif +#line 1018 /* Define a macro to allow hash on two type values */ #define CASE(nc1,nc2) (nc1*256+nc2) diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am index db8da4fc3..40b1324ff 100644 --- a/nc_test/Makefile.am +++ b/nc_test/Makefile.am @@ -106,4 +106,4 @@ EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt # This rule tells make how to turn our .m4 files into .c files. .m4.c: - m4 $(AM_M4FLAGS) $(M4FLAGS) $< >$@ + m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >$@ diff --git a/nc_test/test_get.c b/nc_test/test_get.c index 0c6239d1e..039987a98 100644 --- a/nc_test/test_get.c +++ b/nc_test/test_get.c @@ -1,6251 +1,12388 @@ +#line 5 "../../nc_test/test_get.m4" /* Do not edit this file. It is produced from the corresponding .m4 source */ +#line 7 /********************************************************************* * Copyright 1996, UCAR/Unidata * See netcdf/COPYRIGHT file for copying and redistribution conditions. * $Id: test_get.m4,v 1.16 2005/03/08 03:04:19 ed Exp $ *********************************************************************/ +#line 31 #include "tests.h" +#line 116 void +#line 117 test_nc_get_var1_text(void) +#line 117 { +#line 117 int ncid; +#line 117 int i; +#line 117 int j; +#line 117 int err; +#line 117 int nok = 0; /* count of valid comparisons */ +#line 117 size_t index[MAX_RANK]; +#line 117 double expect; +#line 117 int canConvert; /* Both text or both numeric */ +#line 117 text value; +#line 117 +#line 117 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 117 IF (err) +#line 117 error("nc_open: %s", nc_strerror(err)); +#line 117 for (i = 0; i < NVARS; i++) { +#line 117 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 117 for (j = 0; j < var_rank[i]; j++) +#line 117 index[j] = 0; +#line 117 err = nc_get_var1_text(BAD_ID, i, index, &value); +#line 117 IF (err != NC_EBADID) +#line 117 error("bad ncid: status = %d", err); +#line 117 err = nc_get_var1_text(ncid, BAD_VARID, index, &value); +#line 117 IF (err != NC_ENOTVAR) +#line 117 error("bad var id: status = %d", err); +#line 117 for (j = 0; j < var_rank[i]; j++) { +#line 117 index[j] = var_shape[i][j]; +#line 117 err = nc_get_var1_text(ncid, i, index, &value); +#line 117 if(!canConvert) { +#line 117 IF(err != NC_ECHAR) +#line 117 error("conversion: status = %d", err); +#line 117 } else IF (err != NC_EINVALCOORDS) +#line 117 error("bad index: status = %d", err); +#line 117 index[j] = 0; +#line 117 } +#line 117 for (j = 0; j < var_nels[i]; j++) { +#line 117 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 117 IF (err) +#line 117 error("error in toMixedBase 1"); +#line 117 expect = hash4( var_type[i], var_rank[i], index, NCT_TEXT ); +#line 117 if (var_rank[i] == 0 && i%2 ) +#line 117 err = nc_get_var1_text(ncid, i, NULL, &value); +#line 117 else +#line 117 err = nc_get_var1_text(ncid, i, index, &value); +#line 117 if (canConvert) { +#line 117 if (inRange3(expect,var_type[i], NCT_TEXT)) { +#line 117 if (expect >= text_min && expect <= text_max) { +#line 117 IF (err) { +#line 117 error("%s", nc_strerror(err)); +#line 117 } else { +#line 117 IF (!equal(value,expect,var_type[i],NCT_TEXT)) { +#line 117 error("expected: %G, got: %G", expect, +#line 117 (double) value); +#line 117 } else { +#line 117 nok++; +#line 117 } +#line 117 } +#line 117 } else { +#line 117 IF (err != NC_ERANGE) +#line 117 error("Range error: status = %d", err); +#line 117 } +#line 117 } else { +#line 117 IF (err != 0 && err != NC_ERANGE) +#line 117 error("OK or Range error: status = %d", err); +#line 117 } +#line 117 } else { +#line 117 IF (err != NC_ECHAR) +#line 117 error("wrong type: status = %d", err); +#line 117 } +#line 117 } +#line 117 } +#line 117 err = nc_close(ncid); +#line 117 IF (err) +#line 117 error("nc_close: %s", nc_strerror(err)); +#line 117 print_nok(nok); +#line 117 } +#line 117 void +#line 118 test_nc_get_var1_uchar(void) +#line 118 { +#line 118 int ncid; +#line 118 int i; +#line 118 int j; +#line 118 int err; +#line 118 int nok = 0; /* count of valid comparisons */ +#line 118 size_t index[MAX_RANK]; +#line 118 double expect; +#line 118 int canConvert; /* Both text or both numeric */ +#line 118 uchar value; +#line 118 +#line 118 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 118 IF (err) +#line 118 error("nc_open: %s", nc_strerror(err)); +#line 118 for (i = 0; i < NVARS; i++) { +#line 118 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 118 for (j = 0; j < var_rank[i]; j++) +#line 118 index[j] = 0; +#line 118 err = nc_get_var1_uchar(BAD_ID, i, index, &value); +#line 118 IF (err != NC_EBADID) +#line 118 error("bad ncid: status = %d", err); +#line 118 err = nc_get_var1_uchar(ncid, BAD_VARID, index, &value); +#line 118 IF (err != NC_ENOTVAR) +#line 118 error("bad var id: status = %d", err); +#line 118 for (j = 0; j < var_rank[i]; j++) { +#line 118 index[j] = var_shape[i][j]; +#line 118 err = nc_get_var1_uchar(ncid, i, index, &value); +#line 118 if(!canConvert) { +#line 118 IF(err != NC_ECHAR) +#line 118 error("conversion: status = %d", err); +#line 118 } else IF (err != NC_EINVALCOORDS) +#line 118 error("bad index: status = %d", err); +#line 118 index[j] = 0; +#line 118 } +#line 118 for (j = 0; j < var_nels[i]; j++) { +#line 118 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 118 IF (err) +#line 118 error("error in toMixedBase 1"); +#line 118 expect = hash4( var_type[i], var_rank[i], index, NCT_UCHAR ); +#line 118 if (var_rank[i] == 0 && i%2 ) +#line 118 err = nc_get_var1_uchar(ncid, i, NULL, &value); +#line 118 else +#line 118 err = nc_get_var1_uchar(ncid, i, index, &value); +#line 118 if (canConvert) { +#line 118 if (inRange3(expect,var_type[i], NCT_UCHAR)) { +#line 118 if (expect >= uchar_min && expect <= uchar_max) { +#line 118 IF (err) { +#line 118 error("%s", nc_strerror(err)); +#line 118 } else { +#line 118 IF (!equal(value,expect,var_type[i],NCT_UCHAR)) { +#line 118 error("expected: %G, got: %G", expect, +#line 118 (double) value); +#line 118 } else { +#line 118 nok++; +#line 118 } +#line 118 } +#line 118 } else { +#line 118 IF (err != NC_ERANGE) +#line 118 error("Range error: status = %d", err); +#line 118 } +#line 118 } else { +#line 118 IF (err != 0 && err != NC_ERANGE) +#line 118 error("OK or Range error: status = %d", err); +#line 118 } +#line 118 } else { +#line 118 IF (err != NC_ECHAR) +#line 118 error("wrong type: status = %d", err); +#line 118 } +#line 118 } +#line 118 } +#line 118 err = nc_close(ncid); +#line 118 IF (err) +#line 118 error("nc_close: %s", nc_strerror(err)); +#line 118 print_nok(nok); +#line 118 } +#line 118 void +#line 119 test_nc_get_var1_schar(void) +#line 119 { +#line 119 int ncid; +#line 119 int i; +#line 119 int j; +#line 119 int err; +#line 119 int nok = 0; /* count of valid comparisons */ +#line 119 size_t index[MAX_RANK]; +#line 119 double expect; +#line 119 int canConvert; /* Both text or both numeric */ +#line 119 schar value; +#line 119 +#line 119 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 119 IF (err) +#line 119 error("nc_open: %s", nc_strerror(err)); +#line 119 for (i = 0; i < NVARS; i++) { +#line 119 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 119 for (j = 0; j < var_rank[i]; j++) +#line 119 index[j] = 0; +#line 119 err = nc_get_var1_schar(BAD_ID, i, index, &value); +#line 119 IF (err != NC_EBADID) +#line 119 error("bad ncid: status = %d", err); +#line 119 err = nc_get_var1_schar(ncid, BAD_VARID, index, &value); +#line 119 IF (err != NC_ENOTVAR) +#line 119 error("bad var id: status = %d", err); +#line 119 for (j = 0; j < var_rank[i]; j++) { +#line 119 index[j] = var_shape[i][j]; +#line 119 err = nc_get_var1_schar(ncid, i, index, &value); +#line 119 if(!canConvert) { +#line 119 IF(err != NC_ECHAR) +#line 119 error("conversion: status = %d", err); +#line 119 } else IF (err != NC_EINVALCOORDS) +#line 119 error("bad index: status = %d", err); +#line 119 index[j] = 0; +#line 119 } +#line 119 for (j = 0; j < var_nels[i]; j++) { +#line 119 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 119 IF (err) +#line 119 error("error in toMixedBase 1"); +#line 119 expect = hash4( var_type[i], var_rank[i], index, NCT_SCHAR ); +#line 119 if (var_rank[i] == 0 && i%2 ) +#line 119 err = nc_get_var1_schar(ncid, i, NULL, &value); +#line 119 else +#line 119 err = nc_get_var1_schar(ncid, i, index, &value); +#line 119 if (canConvert) { +#line 119 if (inRange3(expect,var_type[i], NCT_SCHAR)) { +#line 119 if (expect >= schar_min && expect <= schar_max) { +#line 119 IF (err) { +#line 119 error("%s", nc_strerror(err)); +#line 119 } else { +#line 119 IF (!equal(value,expect,var_type[i],NCT_SCHAR)) { +#line 119 error("expected: %G, got: %G", expect, +#line 119 (double) value); +#line 119 } else { +#line 119 nok++; +#line 119 } +#line 119 } +#line 119 } else { +#line 119 IF (err != NC_ERANGE) +#line 119 error("Range error: status = %d", err); +#line 119 } +#line 119 } else { +#line 119 IF (err != 0 && err != NC_ERANGE) +#line 119 error("OK or Range error: status = %d", err); +#line 119 } +#line 119 } else { +#line 119 IF (err != NC_ECHAR) +#line 119 error("wrong type: status = %d", err); +#line 119 } +#line 119 } +#line 119 } +#line 119 err = nc_close(ncid); +#line 119 IF (err) +#line 119 error("nc_close: %s", nc_strerror(err)); +#line 119 print_nok(nok); +#line 119 } +#line 119 void +#line 120 test_nc_get_var1_short(void) +#line 120 { +#line 120 int ncid; +#line 120 int i; +#line 120 int j; +#line 120 int err; +#line 120 int nok = 0; /* count of valid comparisons */ +#line 120 size_t index[MAX_RANK]; +#line 120 double expect; +#line 120 int canConvert; /* Both text or both numeric */ +#line 120 short value; +#line 120 +#line 120 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 120 IF (err) +#line 120 error("nc_open: %s", nc_strerror(err)); +#line 120 for (i = 0; i < NVARS; i++) { +#line 120 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 120 for (j = 0; j < var_rank[i]; j++) +#line 120 index[j] = 0; +#line 120 err = nc_get_var1_short(BAD_ID, i, index, &value); +#line 120 IF (err != NC_EBADID) +#line 120 error("bad ncid: status = %d", err); +#line 120 err = nc_get_var1_short(ncid, BAD_VARID, index, &value); +#line 120 IF (err != NC_ENOTVAR) +#line 120 error("bad var id: status = %d", err); +#line 120 for (j = 0; j < var_rank[i]; j++) { +#line 120 index[j] = var_shape[i][j]; +#line 120 err = nc_get_var1_short(ncid, i, index, &value); +#line 120 if(!canConvert) { +#line 120 IF(err != NC_ECHAR) +#line 120 error("conversion: status = %d", err); +#line 120 } else IF (err != NC_EINVALCOORDS) +#line 120 error("bad index: status = %d", err); +#line 120 index[j] = 0; +#line 120 } +#line 120 for (j = 0; j < var_nels[i]; j++) { +#line 120 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 120 IF (err) +#line 120 error("error in toMixedBase 1"); +#line 120 expect = hash4( var_type[i], var_rank[i], index, NCT_SHORT ); +#line 120 if (var_rank[i] == 0 && i%2 ) +#line 120 err = nc_get_var1_short(ncid, i, NULL, &value); +#line 120 else +#line 120 err = nc_get_var1_short(ncid, i, index, &value); +#line 120 if (canConvert) { +#line 120 if (inRange3(expect,var_type[i], NCT_SHORT)) { +#line 120 if (expect >= short_min && expect <= short_max) { +#line 120 IF (err) { +#line 120 error("%s", nc_strerror(err)); +#line 120 } else { +#line 120 IF (!equal(value,expect,var_type[i],NCT_SHORT)) { +#line 120 error("expected: %G, got: %G", expect, +#line 120 (double) value); +#line 120 } else { +#line 120 nok++; +#line 120 } +#line 120 } +#line 120 } else { +#line 120 IF (err != NC_ERANGE) +#line 120 error("Range error: status = %d", err); +#line 120 } +#line 120 } else { +#line 120 IF (err != 0 && err != NC_ERANGE) +#line 120 error("OK or Range error: status = %d", err); +#line 120 } +#line 120 } else { +#line 120 IF (err != NC_ECHAR) +#line 120 error("wrong type: status = %d", err); +#line 120 } +#line 120 } +#line 120 } +#line 120 err = nc_close(ncid); +#line 120 IF (err) +#line 120 error("nc_close: %s", nc_strerror(err)); +#line 120 print_nok(nok); +#line 120 } +#line 120 void +#line 121 test_nc_get_var1_int(void) +#line 121 { +#line 121 int ncid; +#line 121 int i; +#line 121 int j; +#line 121 int err; +#line 121 int nok = 0; /* count of valid comparisons */ +#line 121 size_t index[MAX_RANK]; +#line 121 double expect; +#line 121 int canConvert; /* Both text or both numeric */ +#line 121 int value; +#line 121 +#line 121 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 121 IF (err) +#line 121 error("nc_open: %s", nc_strerror(err)); +#line 121 for (i = 0; i < NVARS; i++) { +#line 121 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 121 for (j = 0; j < var_rank[i]; j++) +#line 121 index[j] = 0; +#line 121 err = nc_get_var1_int(BAD_ID, i, index, &value); +#line 121 IF (err != NC_EBADID) +#line 121 error("bad ncid: status = %d", err); +#line 121 err = nc_get_var1_int(ncid, BAD_VARID, index, &value); +#line 121 IF (err != NC_ENOTVAR) +#line 121 error("bad var id: status = %d", err); +#line 121 for (j = 0; j < var_rank[i]; j++) { +#line 121 index[j] = var_shape[i][j]; +#line 121 err = nc_get_var1_int(ncid, i, index, &value); +#line 121 if(!canConvert) { +#line 121 IF(err != NC_ECHAR) +#line 121 error("conversion: status = %d", err); +#line 121 } else IF (err != NC_EINVALCOORDS) +#line 121 error("bad index: status = %d", err); +#line 121 index[j] = 0; +#line 121 } +#line 121 for (j = 0; j < var_nels[i]; j++) { +#line 121 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 121 IF (err) +#line 121 error("error in toMixedBase 1"); +#line 121 expect = hash4( var_type[i], var_rank[i], index, NCT_INT ); +#line 121 if (var_rank[i] == 0 && i%2 ) +#line 121 err = nc_get_var1_int(ncid, i, NULL, &value); +#line 121 else +#line 121 err = nc_get_var1_int(ncid, i, index, &value); +#line 121 if (canConvert) { +#line 121 if (inRange3(expect,var_type[i], NCT_INT)) { +#line 121 if (expect >= int_min && expect <= int_max) { +#line 121 IF (err) { +#line 121 error("%s", nc_strerror(err)); +#line 121 } else { +#line 121 IF (!equal(value,expect,var_type[i],NCT_INT)) { +#line 121 error("expected: %G, got: %G", expect, +#line 121 (double) value); +#line 121 } else { +#line 121 nok++; +#line 121 } +#line 121 } +#line 121 } else { +#line 121 IF (err != NC_ERANGE) +#line 121 error("Range error: status = %d", err); +#line 121 } +#line 121 } else { +#line 121 IF (err != 0 && err != NC_ERANGE) +#line 121 error("OK or Range error: status = %d", err); +#line 121 } +#line 121 } else { +#line 121 IF (err != NC_ECHAR) +#line 121 error("wrong type: status = %d", err); +#line 121 } +#line 121 } +#line 121 } +#line 121 err = nc_close(ncid); +#line 121 IF (err) +#line 121 error("nc_close: %s", nc_strerror(err)); +#line 121 print_nok(nok); +#line 121 } +#line 121 void +#line 122 test_nc_get_var1_long(void) +#line 122 { +#line 122 int ncid; +#line 122 int i; +#line 122 int j; +#line 122 int err; +#line 122 int nok = 0; /* count of valid comparisons */ +#line 122 size_t index[MAX_RANK]; +#line 122 double expect; +#line 122 int canConvert; /* Both text or both numeric */ +#line 122 long value; +#line 122 +#line 122 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 122 IF (err) +#line 122 error("nc_open: %s", nc_strerror(err)); +#line 122 for (i = 0; i < NVARS; i++) { +#line 122 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 122 for (j = 0; j < var_rank[i]; j++) +#line 122 index[j] = 0; +#line 122 err = nc_get_var1_long(BAD_ID, i, index, &value); +#line 122 IF (err != NC_EBADID) +#line 122 error("bad ncid: status = %d", err); +#line 122 err = nc_get_var1_long(ncid, BAD_VARID, index, &value); +#line 122 IF (err != NC_ENOTVAR) +#line 122 error("bad var id: status = %d", err); +#line 122 for (j = 0; j < var_rank[i]; j++) { +#line 122 index[j] = var_shape[i][j]; +#line 122 err = nc_get_var1_long(ncid, i, index, &value); +#line 122 if(!canConvert) { +#line 122 IF(err != NC_ECHAR) +#line 122 error("conversion: status = %d", err); +#line 122 } else IF (err != NC_EINVALCOORDS) +#line 122 error("bad index: status = %d", err); +#line 122 index[j] = 0; +#line 122 } +#line 122 for (j = 0; j < var_nels[i]; j++) { +#line 122 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 122 IF (err) +#line 122 error("error in toMixedBase 1"); +#line 122 expect = hash4( var_type[i], var_rank[i], index, NCT_LONG ); +#line 122 if (var_rank[i] == 0 && i%2 ) +#line 122 err = nc_get_var1_long(ncid, i, NULL, &value); +#line 122 else +#line 122 err = nc_get_var1_long(ncid, i, index, &value); +#line 122 if (canConvert) { +#line 122 if (inRange3(expect,var_type[i], NCT_LONG)) { +#line 122 if (expect >= long_min && expect <= long_max) { +#line 122 IF (err) { +#line 122 error("%s", nc_strerror(err)); +#line 122 } else { +#line 122 IF (!equal(value,expect,var_type[i],NCT_LONG)) { +#line 122 error("expected: %G, got: %G", expect, +#line 122 (double) value); +#line 122 } else { +#line 122 nok++; +#line 122 } +#line 122 } +#line 122 } else { +#line 122 IF (err != NC_ERANGE) +#line 122 error("Range error: status = %d", err); +#line 122 } +#line 122 } else { +#line 122 IF (err != 0 && err != NC_ERANGE) +#line 122 error("OK or Range error: status = %d", err); +#line 122 } +#line 122 } else { +#line 122 IF (err != NC_ECHAR) +#line 122 error("wrong type: status = %d", err); +#line 122 } +#line 122 } +#line 122 } +#line 122 err = nc_close(ncid); +#line 122 IF (err) +#line 122 error("nc_close: %s", nc_strerror(err)); +#line 122 print_nok(nok); +#line 122 } +#line 122 void +#line 123 test_nc_get_var1_float(void) +#line 123 { +#line 123 int ncid; +#line 123 int i; +#line 123 int j; +#line 123 int err; +#line 123 int nok = 0; /* count of valid comparisons */ +#line 123 size_t index[MAX_RANK]; +#line 123 double expect; +#line 123 int canConvert; /* Both text or both numeric */ +#line 123 float value; +#line 123 +#line 123 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 123 IF (err) +#line 123 error("nc_open: %s", nc_strerror(err)); +#line 123 for (i = 0; i < NVARS; i++) { +#line 123 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 123 for (j = 0; j < var_rank[i]; j++) +#line 123 index[j] = 0; +#line 123 err = nc_get_var1_float(BAD_ID, i, index, &value); +#line 123 IF (err != NC_EBADID) +#line 123 error("bad ncid: status = %d", err); +#line 123 err = nc_get_var1_float(ncid, BAD_VARID, index, &value); +#line 123 IF (err != NC_ENOTVAR) +#line 123 error("bad var id: status = %d", err); +#line 123 for (j = 0; j < var_rank[i]; j++) { +#line 123 index[j] = var_shape[i][j]; +#line 123 err = nc_get_var1_float(ncid, i, index, &value); +#line 123 if(!canConvert) { +#line 123 IF(err != NC_ECHAR) +#line 123 error("conversion: status = %d", err); +#line 123 } else IF (err != NC_EINVALCOORDS) +#line 123 error("bad index: status = %d", err); +#line 123 index[j] = 0; +#line 123 } +#line 123 for (j = 0; j < var_nels[i]; j++) { +#line 123 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 123 IF (err) +#line 123 error("error in toMixedBase 1"); +#line 123 expect = hash4( var_type[i], var_rank[i], index, NCT_FLOAT ); +#line 123 if (var_rank[i] == 0 && i%2 ) +#line 123 err = nc_get_var1_float(ncid, i, NULL, &value); +#line 123 else +#line 123 err = nc_get_var1_float(ncid, i, index, &value); +#line 123 if (canConvert) { +#line 123 if (inRange3(expect,var_type[i], NCT_FLOAT)) { +#line 123 if (expect >= float_min && expect <= float_max) { +#line 123 IF (err) { +#line 123 error("%s", nc_strerror(err)); +#line 123 } else { +#line 123 IF (!equal(value,expect,var_type[i],NCT_FLOAT)) { +#line 123 error("expected: %G, got: %G", expect, +#line 123 (double) value); +#line 123 } else { +#line 123 nok++; +#line 123 } +#line 123 } +#line 123 } else { +#line 123 IF (err != NC_ERANGE) +#line 123 error("Range error: status = %d", err); +#line 123 } +#line 123 } else { +#line 123 IF (err != 0 && err != NC_ERANGE) +#line 123 error("OK or Range error: status = %d", err); +#line 123 } +#line 123 } else { +#line 123 IF (err != NC_ECHAR) +#line 123 error("wrong type: status = %d", err); +#line 123 } +#line 123 } +#line 123 } +#line 123 err = nc_close(ncid); +#line 123 IF (err) +#line 123 error("nc_close: %s", nc_strerror(err)); +#line 123 print_nok(nok); +#line 123 } +#line 123 void +#line 124 test_nc_get_var1_double(void) +#line 124 { +#line 124 int ncid; +#line 124 int i; +#line 124 int j; +#line 124 int err; +#line 124 int nok = 0; /* count of valid comparisons */ +#line 124 size_t index[MAX_RANK]; +#line 124 double expect; +#line 124 int canConvert; /* Both text or both numeric */ +#line 124 double value; +#line 124 +#line 124 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 124 IF (err) +#line 124 error("nc_open: %s", nc_strerror(err)); +#line 124 for (i = 0; i < NVARS; i++) { +#line 124 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 124 for (j = 0; j < var_rank[i]; j++) +#line 124 index[j] = 0; +#line 124 err = nc_get_var1_double(BAD_ID, i, index, &value); +#line 124 IF (err != NC_EBADID) +#line 124 error("bad ncid: status = %d", err); +#line 124 err = nc_get_var1_double(ncid, BAD_VARID, index, &value); +#line 124 IF (err != NC_ENOTVAR) +#line 124 error("bad var id: status = %d", err); +#line 124 for (j = 0; j < var_rank[i]; j++) { +#line 124 index[j] = var_shape[i][j]; +#line 124 err = nc_get_var1_double(ncid, i, index, &value); +#line 124 if(!canConvert) { +#line 124 IF(err != NC_ECHAR) +#line 124 error("conversion: status = %d", err); +#line 124 } else IF (err != NC_EINVALCOORDS) +#line 124 error("bad index: status = %d", err); +#line 124 index[j] = 0; +#line 124 } +#line 124 for (j = 0; j < var_nels[i]; j++) { +#line 124 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 124 IF (err) +#line 124 error("error in toMixedBase 1"); +#line 124 expect = hash4( var_type[i], var_rank[i], index, NCT_DOUBLE ); +#line 124 if (var_rank[i] == 0 && i%2 ) +#line 124 err = nc_get_var1_double(ncid, i, NULL, &value); +#line 124 else +#line 124 err = nc_get_var1_double(ncid, i, index, &value); +#line 124 if (canConvert) { +#line 124 if (inRange3(expect,var_type[i], NCT_DOUBLE)) { +#line 124 if (expect >= double_min && expect <= double_max) { +#line 124 IF (err) { +#line 124 error("%s", nc_strerror(err)); +#line 124 } else { +#line 124 IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) { +#line 124 error("expected: %G, got: %G", expect, +#line 124 (double) value); +#line 124 } else { +#line 124 nok++; +#line 124 } +#line 124 } +#line 124 } else { +#line 124 IF (err != NC_ERANGE) +#line 124 error("Range error: status = %d", err); +#line 124 } +#line 124 } else { +#line 124 IF (err != 0 && err != NC_ERANGE) +#line 124 error("OK or Range error: status = %d", err); +#line 124 } +#line 124 } else { +#line 124 IF (err != NC_ECHAR) +#line 124 error("wrong type: status = %d", err); +#line 124 } +#line 124 } +#line 124 } +#line 124 err = nc_close(ncid); +#line 124 IF (err) +#line 124 error("nc_close: %s", nc_strerror(err)); +#line 124 print_nok(nok); +#line 124 } +#line 124 +#line 221 void +#line 222 test_nc_get_var_text(void) +#line 222 { +#line 222 int ncid; +#line 222 int i; +#line 222 int j; +#line 222 int err; +#line 222 int allInExtRange; /* all values within external range? */ +#line 222 int allInIntRange; /* all values within internal range? */ +#line 222 int nels; +#line 222 int nok = 0; /* count of valid comparisons */ +#line 222 size_t index[MAX_RANK]; +#line 222 int canConvert; /* Both text or both numeric */ +#line 222 text value[MAX_NELS]; +#line 222 double expect[MAX_NELS]; +#line 222 +#line 222 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 222 IF (err) +#line 222 error("nc_open: %s", nc_strerror(err)); +#line 222 for (i = 0; i < NVARS; i++) { +#line 222 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 222 assert(var_rank[i] <= MAX_RANK); +#line 222 assert(var_nels[i] <= MAX_NELS); +#line 222 err = nc_get_var_text(BAD_ID, i, value); +#line 222 IF (err != NC_EBADID) +#line 222 error("bad ncid: status = %d", err); +#line 222 err = nc_get_var_text(ncid, BAD_VARID, value); +#line 222 IF (err != NC_ENOTVAR) +#line 222 error("bad var id: status = %d", err); +#line 222 +#line 222 nels = 1; +#line 222 for (j = 0; j < var_rank[i]; j++) { +#line 222 nels *= var_shape[i][j]; +#line 222 } +#line 222 allInExtRange = allInIntRange = 1; +#line 222 for (j = 0; j < nels; j++) { +#line 222 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 222 IF (err) +#line 222 error("error in toMixedBase 1"); +#line 222 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT); +#line 222 if (inRange3(expect[j],var_type[i], NCT_TEXT)) { +#line 222 allInIntRange = allInIntRange && expect[j] >= text_min +#line 222 && expect[j] <= text_max; +#line 222 } else { +#line 222 allInExtRange = 0; +#line 222 } +#line 222 } +#line 222 err = nc_get_var_text(ncid, i, value); +#line 222 if (canConvert) { +#line 222 if (allInExtRange) { +#line 222 if (allInIntRange) { +#line 222 IF (err) +#line 222 error("%s", nc_strerror(err)); +#line 222 } else { +#line 222 IF (err != NC_ERANGE) +#line 222 error("Range error: status = %d", err); +#line 222 } +#line 222 } else { +#line 222 IF (err != 0 && err != NC_ERANGE) +#line 222 error("OK or Range error: status = %d", err); +#line 222 } +#line 222 for (j = 0; j < nels; j++) { +#line 222 if (inRange3(expect[j],var_type[i],NCT_TEXT) +#line 222 && expect[j] >= text_min && expect[j] <= text_max) { +#line 222 IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){ +#line 222 error("value read not that expected"); +#line 222 if (verbose) { +#line 222 error("\n"); +#line 222 error("varid: %d, ", i); +#line 222 error("var_name: %s, ", var_name[i]); +#line 222 error("element number: %d ", j); +#line 222 error("expect: %g", expect[j]); +#line 222 error("got: %g", (double) value[j]); +#line 222 } +#line 222 } else { +#line 222 nok++; +#line 222 } +#line 222 } +#line 222 } +#line 222 } else { +#line 222 IF (nels > 0 && err != NC_ECHAR) +#line 222 error("wrong type: status = %d", err); +#line 222 } +#line 222 } +#line 222 err = nc_close(ncid); +#line 222 IF (err) +#line 222 error("nc_close: %s", nc_strerror(err)); +#line 222 print_nok(nok); +#line 222 } +#line 222 void +#line 223 test_nc_get_var_uchar(void) +#line 223 { +#line 223 int ncid; +#line 223 int i; +#line 223 int j; +#line 223 int err; +#line 223 int allInExtRange; /* all values within external range? */ +#line 223 int allInIntRange; /* all values within internal range? */ +#line 223 int nels; +#line 223 int nok = 0; /* count of valid comparisons */ +#line 223 size_t index[MAX_RANK]; +#line 223 int canConvert; /* Both text or both numeric */ +#line 223 uchar value[MAX_NELS]; +#line 223 double expect[MAX_NELS]; +#line 223 +#line 223 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 223 IF (err) +#line 223 error("nc_open: %s", nc_strerror(err)); +#line 223 for (i = 0; i < NVARS; i++) { +#line 223 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 223 assert(var_rank[i] <= MAX_RANK); +#line 223 assert(var_nels[i] <= MAX_NELS); +#line 223 err = nc_get_var_uchar(BAD_ID, i, value); +#line 223 IF (err != NC_EBADID) +#line 223 error("bad ncid: status = %d", err); +#line 223 err = nc_get_var_uchar(ncid, BAD_VARID, value); +#line 223 IF (err != NC_ENOTVAR) +#line 223 error("bad var id: status = %d", err); +#line 223 +#line 223 nels = 1; +#line 223 for (j = 0; j < var_rank[i]; j++) { +#line 223 nels *= var_shape[i][j]; +#line 223 } +#line 223 allInExtRange = allInIntRange = 1; +#line 223 for (j = 0; j < nels; j++) { +#line 223 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 223 IF (err) +#line 223 error("error in toMixedBase 1"); +#line 223 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR); +#line 223 if (inRange3(expect[j],var_type[i], NCT_UCHAR)) { +#line 223 allInIntRange = allInIntRange && expect[j] >= uchar_min +#line 223 && expect[j] <= uchar_max; +#line 223 } else { +#line 223 allInExtRange = 0; +#line 223 } +#line 223 } +#line 223 err = nc_get_var_uchar(ncid, i, value); +#line 223 if (canConvert) { +#line 223 if (allInExtRange) { +#line 223 if (allInIntRange) { +#line 223 IF (err) +#line 223 error("%s", nc_strerror(err)); +#line 223 } else { +#line 223 IF (err != NC_ERANGE) +#line 223 error("Range error: status = %d", err); +#line 223 } +#line 223 } else { +#line 223 IF (err != 0 && err != NC_ERANGE) +#line 223 error("OK or Range error: status = %d", err); +#line 223 } +#line 223 for (j = 0; j < nels; j++) { +#line 223 if (inRange3(expect[j],var_type[i],NCT_UCHAR) +#line 223 && expect[j] >= uchar_min && expect[j] <= uchar_max) { +#line 223 IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){ +#line 223 error("value read not that expected"); +#line 223 if (verbose) { +#line 223 error("\n"); +#line 223 error("varid: %d, ", i); +#line 223 error("var_name: %s, ", var_name[i]); +#line 223 error("element number: %d ", j); +#line 223 error("expect: %g", expect[j]); +#line 223 error("got: %g", (double) value[j]); +#line 223 } +#line 223 } else { +#line 223 nok++; +#line 223 } +#line 223 } +#line 223 } +#line 223 } else { +#line 223 IF (nels > 0 && err != NC_ECHAR) +#line 223 error("wrong type: status = %d", err); +#line 223 } +#line 223 } +#line 223 err = nc_close(ncid); +#line 223 IF (err) +#line 223 error("nc_close: %s", nc_strerror(err)); +#line 223 print_nok(nok); +#line 223 } +#line 223 void +#line 224 test_nc_get_var_schar(void) +#line 224 { +#line 224 int ncid; +#line 224 int i; +#line 224 int j; +#line 224 int err; +#line 224 int allInExtRange; /* all values within external range? */ +#line 224 int allInIntRange; /* all values within internal range? */ +#line 224 int nels; +#line 224 int nok = 0; /* count of valid comparisons */ +#line 224 size_t index[MAX_RANK]; +#line 224 int canConvert; /* Both text or both numeric */ +#line 224 schar value[MAX_NELS]; +#line 224 double expect[MAX_NELS]; +#line 224 +#line 224 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 224 IF (err) +#line 224 error("nc_open: %s", nc_strerror(err)); +#line 224 for (i = 0; i < NVARS; i++) { +#line 224 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 224 assert(var_rank[i] <= MAX_RANK); +#line 224 assert(var_nels[i] <= MAX_NELS); +#line 224 err = nc_get_var_schar(BAD_ID, i, value); +#line 224 IF (err != NC_EBADID) +#line 224 error("bad ncid: status = %d", err); +#line 224 err = nc_get_var_schar(ncid, BAD_VARID, value); +#line 224 IF (err != NC_ENOTVAR) +#line 224 error("bad var id: status = %d", err); +#line 224 +#line 224 nels = 1; +#line 224 for (j = 0; j < var_rank[i]; j++) { +#line 224 nels *= var_shape[i][j]; +#line 224 } +#line 224 allInExtRange = allInIntRange = 1; +#line 224 for (j = 0; j < nels; j++) { +#line 224 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 224 IF (err) +#line 224 error("error in toMixedBase 1"); +#line 224 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR); +#line 224 if (inRange3(expect[j],var_type[i], NCT_SCHAR)) { +#line 224 allInIntRange = allInIntRange && expect[j] >= schar_min +#line 224 && expect[j] <= schar_max; +#line 224 } else { +#line 224 allInExtRange = 0; +#line 224 } +#line 224 } +#line 224 err = nc_get_var_schar(ncid, i, value); +#line 224 if (canConvert) { +#line 224 if (allInExtRange) { +#line 224 if (allInIntRange) { +#line 224 IF (err) +#line 224 error("%s", nc_strerror(err)); +#line 224 } else { +#line 224 IF (err != NC_ERANGE) +#line 224 error("Range error: status = %d", err); +#line 224 } +#line 224 } else { +#line 224 IF (err != 0 && err != NC_ERANGE) +#line 224 error("OK or Range error: status = %d", err); +#line 224 } +#line 224 for (j = 0; j < nels; j++) { +#line 224 if (inRange3(expect[j],var_type[i],NCT_SCHAR) +#line 224 && expect[j] >= schar_min && expect[j] <= schar_max) { +#line 224 IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){ +#line 224 error("value read not that expected"); +#line 224 if (verbose) { +#line 224 error("\n"); +#line 224 error("varid: %d, ", i); +#line 224 error("var_name: %s, ", var_name[i]); +#line 224 error("element number: %d ", j); +#line 224 error("expect: %g", expect[j]); +#line 224 error("got: %g", (double) value[j]); +#line 224 } +#line 224 } else { +#line 224 nok++; +#line 224 } +#line 224 } +#line 224 } +#line 224 } else { +#line 224 IF (nels > 0 && err != NC_ECHAR) +#line 224 error("wrong type: status = %d", err); +#line 224 } +#line 224 } +#line 224 err = nc_close(ncid); +#line 224 IF (err) +#line 224 error("nc_close: %s", nc_strerror(err)); +#line 224 print_nok(nok); +#line 224 } +#line 224 void +#line 225 test_nc_get_var_short(void) +#line 225 { +#line 225 int ncid; +#line 225 int i; +#line 225 int j; +#line 225 int err; +#line 225 int allInExtRange; /* all values within external range? */ +#line 225 int allInIntRange; /* all values within internal range? */ +#line 225 int nels; +#line 225 int nok = 0; /* count of valid comparisons */ +#line 225 size_t index[MAX_RANK]; +#line 225 int canConvert; /* Both text or both numeric */ +#line 225 short value[MAX_NELS]; +#line 225 double expect[MAX_NELS]; +#line 225 +#line 225 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 225 IF (err) +#line 225 error("nc_open: %s", nc_strerror(err)); +#line 225 for (i = 0; i < NVARS; i++) { +#line 225 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 225 assert(var_rank[i] <= MAX_RANK); +#line 225 assert(var_nels[i] <= MAX_NELS); +#line 225 err = nc_get_var_short(BAD_ID, i, value); +#line 225 IF (err != NC_EBADID) +#line 225 error("bad ncid: status = %d", err); +#line 225 err = nc_get_var_short(ncid, BAD_VARID, value); +#line 225 IF (err != NC_ENOTVAR) +#line 225 error("bad var id: status = %d", err); +#line 225 +#line 225 nels = 1; +#line 225 for (j = 0; j < var_rank[i]; j++) { +#line 225 nels *= var_shape[i][j]; +#line 225 } +#line 225 allInExtRange = allInIntRange = 1; +#line 225 for (j = 0; j < nels; j++) { +#line 225 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 225 IF (err) +#line 225 error("error in toMixedBase 1"); +#line 225 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT); +#line 225 if (inRange3(expect[j],var_type[i], NCT_SHORT)) { +#line 225 allInIntRange = allInIntRange && expect[j] >= short_min +#line 225 && expect[j] <= short_max; +#line 225 } else { +#line 225 allInExtRange = 0; +#line 225 } +#line 225 } +#line 225 err = nc_get_var_short(ncid, i, value); +#line 225 if (canConvert) { +#line 225 if (allInExtRange) { +#line 225 if (allInIntRange) { +#line 225 IF (err) +#line 225 error("%s", nc_strerror(err)); +#line 225 } else { +#line 225 IF (err != NC_ERANGE) +#line 225 error("Range error: status = %d", err); +#line 225 } +#line 225 } else { +#line 225 IF (err != 0 && err != NC_ERANGE) +#line 225 error("OK or Range error: status = %d", err); +#line 225 } +#line 225 for (j = 0; j < nels; j++) { +#line 225 if (inRange3(expect[j],var_type[i],NCT_SHORT) +#line 225 && expect[j] >= short_min && expect[j] <= short_max) { +#line 225 IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){ +#line 225 error("value read not that expected"); +#line 225 if (verbose) { +#line 225 error("\n"); +#line 225 error("varid: %d, ", i); +#line 225 error("var_name: %s, ", var_name[i]); +#line 225 error("element number: %d ", j); +#line 225 error("expect: %g", expect[j]); +#line 225 error("got: %g", (double) value[j]); +#line 225 } +#line 225 } else { +#line 225 nok++; +#line 225 } +#line 225 } +#line 225 } +#line 225 } else { +#line 225 IF (nels > 0 && err != NC_ECHAR) +#line 225 error("wrong type: status = %d", err); +#line 225 } +#line 225 } +#line 225 err = nc_close(ncid); +#line 225 IF (err) +#line 225 error("nc_close: %s", nc_strerror(err)); +#line 225 print_nok(nok); +#line 225 } +#line 225 void +#line 226 test_nc_get_var_int(void) +#line 226 { +#line 226 int ncid; +#line 226 int i; +#line 226 int j; +#line 226 int err; +#line 226 int allInExtRange; /* all values within external range? */ +#line 226 int allInIntRange; /* all values within internal range? */ +#line 226 int nels; +#line 226 int nok = 0; /* count of valid comparisons */ +#line 226 size_t index[MAX_RANK]; +#line 226 int canConvert; /* Both text or both numeric */ +#line 226 int value[MAX_NELS]; +#line 226 double expect[MAX_NELS]; +#line 226 +#line 226 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 226 IF (err) +#line 226 error("nc_open: %s", nc_strerror(err)); +#line 226 for (i = 0; i < NVARS; i++) { +#line 226 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 226 assert(var_rank[i] <= MAX_RANK); +#line 226 assert(var_nels[i] <= MAX_NELS); +#line 226 err = nc_get_var_int(BAD_ID, i, value); +#line 226 IF (err != NC_EBADID) +#line 226 error("bad ncid: status = %d", err); +#line 226 err = nc_get_var_int(ncid, BAD_VARID, value); +#line 226 IF (err != NC_ENOTVAR) +#line 226 error("bad var id: status = %d", err); +#line 226 +#line 226 nels = 1; +#line 226 for (j = 0; j < var_rank[i]; j++) { +#line 226 nels *= var_shape[i][j]; +#line 226 } +#line 226 allInExtRange = allInIntRange = 1; +#line 226 for (j = 0; j < nels; j++) { +#line 226 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 226 IF (err) +#line 226 error("error in toMixedBase 1"); +#line 226 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT); +#line 226 if (inRange3(expect[j],var_type[i], NCT_INT)) { +#line 226 allInIntRange = allInIntRange && expect[j] >= int_min +#line 226 && expect[j] <= int_max; +#line 226 } else { +#line 226 allInExtRange = 0; +#line 226 } +#line 226 } +#line 226 err = nc_get_var_int(ncid, i, value); +#line 226 if (canConvert) { +#line 226 if (allInExtRange) { +#line 226 if (allInIntRange) { +#line 226 IF (err) +#line 226 error("%s", nc_strerror(err)); +#line 226 } else { +#line 226 IF (err != NC_ERANGE) +#line 226 error("Range error: status = %d", err); +#line 226 } +#line 226 } else { +#line 226 IF (err != 0 && err != NC_ERANGE) +#line 226 error("OK or Range error: status = %d", err); +#line 226 } +#line 226 for (j = 0; j < nels; j++) { +#line 226 if (inRange3(expect[j],var_type[i],NCT_INT) +#line 226 && expect[j] >= int_min && expect[j] <= int_max) { +#line 226 IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){ +#line 226 error("value read not that expected"); +#line 226 if (verbose) { +#line 226 error("\n"); +#line 226 error("varid: %d, ", i); +#line 226 error("var_name: %s, ", var_name[i]); +#line 226 error("element number: %d ", j); +#line 226 error("expect: %g", expect[j]); +#line 226 error("got: %g", (double) value[j]); +#line 226 } +#line 226 } else { +#line 226 nok++; +#line 226 } +#line 226 } +#line 226 } +#line 226 } else { +#line 226 IF (nels > 0 && err != NC_ECHAR) +#line 226 error("wrong type: status = %d", err); +#line 226 } +#line 226 } +#line 226 err = nc_close(ncid); +#line 226 IF (err) +#line 226 error("nc_close: %s", nc_strerror(err)); +#line 226 print_nok(nok); +#line 226 } +#line 226 void +#line 227 test_nc_get_var_long(void) +#line 227 { +#line 227 int ncid; +#line 227 int i; +#line 227 int j; +#line 227 int err; +#line 227 int allInExtRange; /* all values within external range? */ +#line 227 int allInIntRange; /* all values within internal range? */ +#line 227 int nels; +#line 227 int nok = 0; /* count of valid comparisons */ +#line 227 size_t index[MAX_RANK]; +#line 227 int canConvert; /* Both text or both numeric */ +#line 227 long value[MAX_NELS]; +#line 227 double expect[MAX_NELS]; +#line 227 +#line 227 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 227 IF (err) +#line 227 error("nc_open: %s", nc_strerror(err)); +#line 227 for (i = 0; i < NVARS; i++) { +#line 227 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 227 assert(var_rank[i] <= MAX_RANK); +#line 227 assert(var_nels[i] <= MAX_NELS); +#line 227 err = nc_get_var_long(BAD_ID, i, value); +#line 227 IF (err != NC_EBADID) +#line 227 error("bad ncid: status = %d", err); +#line 227 err = nc_get_var_long(ncid, BAD_VARID, value); +#line 227 IF (err != NC_ENOTVAR) +#line 227 error("bad var id: status = %d", err); +#line 227 +#line 227 nels = 1; +#line 227 for (j = 0; j < var_rank[i]; j++) { +#line 227 nels *= var_shape[i][j]; +#line 227 } +#line 227 allInExtRange = allInIntRange = 1; +#line 227 for (j = 0; j < nels; j++) { +#line 227 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 227 IF (err) +#line 227 error("error in toMixedBase 1"); +#line 227 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG); +#line 227 if (inRange3(expect[j],var_type[i], NCT_LONG)) { +#line 227 allInIntRange = allInIntRange && expect[j] >= long_min +#line 227 && expect[j] <= long_max; +#line 227 } else { +#line 227 allInExtRange = 0; +#line 227 } +#line 227 } +#line 227 err = nc_get_var_long(ncid, i, value); +#line 227 if (canConvert) { +#line 227 if (allInExtRange) { +#line 227 if (allInIntRange) { +#line 227 IF (err) +#line 227 error("%s", nc_strerror(err)); +#line 227 } else { +#line 227 IF (err != NC_ERANGE) +#line 227 error("Range error: status = %d", err); +#line 227 } +#line 227 } else { +#line 227 IF (err != 0 && err != NC_ERANGE) +#line 227 error("OK or Range error: status = %d", err); +#line 227 } +#line 227 for (j = 0; j < nels; j++) { +#line 227 if (inRange3(expect[j],var_type[i],NCT_LONG) +#line 227 && expect[j] >= long_min && expect[j] <= long_max) { +#line 227 IF (!equal(value[j],expect[j],var_type[i],NCT_LONG)){ +#line 227 error("value read not that expected"); +#line 227 if (verbose) { +#line 227 error("\n"); +#line 227 error("varid: %d, ", i); +#line 227 error("var_name: %s, ", var_name[i]); +#line 227 error("element number: %d ", j); +#line 227 error("expect: %g", expect[j]); +#line 227 error("got: %g", (double) value[j]); +#line 227 } +#line 227 } else { +#line 227 nok++; +#line 227 } +#line 227 } +#line 227 } +#line 227 } else { +#line 227 IF (nels > 0 && err != NC_ECHAR) +#line 227 error("wrong type: status = %d", err); +#line 227 } +#line 227 } +#line 227 err = nc_close(ncid); +#line 227 IF (err) +#line 227 error("nc_close: %s", nc_strerror(err)); +#line 227 print_nok(nok); +#line 227 } +#line 227 void +#line 228 test_nc_get_var_float(void) +#line 228 { +#line 228 int ncid; +#line 228 int i; +#line 228 int j; +#line 228 int err; +#line 228 int allInExtRange; /* all values within external range? */ +#line 228 int allInIntRange; /* all values within internal range? */ +#line 228 int nels; +#line 228 int nok = 0; /* count of valid comparisons */ +#line 228 size_t index[MAX_RANK]; +#line 228 int canConvert; /* Both text or both numeric */ +#line 228 float value[MAX_NELS]; +#line 228 double expect[MAX_NELS]; +#line 228 +#line 228 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 228 IF (err) +#line 228 error("nc_open: %s", nc_strerror(err)); +#line 228 for (i = 0; i < NVARS; i++) { +#line 228 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 228 assert(var_rank[i] <= MAX_RANK); +#line 228 assert(var_nels[i] <= MAX_NELS); +#line 228 err = nc_get_var_float(BAD_ID, i, value); +#line 228 IF (err != NC_EBADID) +#line 228 error("bad ncid: status = %d", err); +#line 228 err = nc_get_var_float(ncid, BAD_VARID, value); +#line 228 IF (err != NC_ENOTVAR) +#line 228 error("bad var id: status = %d", err); +#line 228 +#line 228 nels = 1; +#line 228 for (j = 0; j < var_rank[i]; j++) { +#line 228 nels *= var_shape[i][j]; +#line 228 } +#line 228 allInExtRange = allInIntRange = 1; +#line 228 for (j = 0; j < nels; j++) { +#line 228 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 228 IF (err) +#line 228 error("error in toMixedBase 1"); +#line 228 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT); +#line 228 if (inRange3(expect[j],var_type[i], NCT_FLOAT)) { +#line 228 allInIntRange = allInIntRange && expect[j] >= float_min +#line 228 && expect[j] <= float_max; +#line 228 } else { +#line 228 allInExtRange = 0; +#line 228 } +#line 228 } +#line 228 err = nc_get_var_float(ncid, i, value); +#line 228 if (canConvert) { +#line 228 if (allInExtRange) { +#line 228 if (allInIntRange) { +#line 228 IF (err) +#line 228 error("%s", nc_strerror(err)); +#line 228 } else { +#line 228 IF (err != NC_ERANGE) +#line 228 error("Range error: status = %d", err); +#line 228 } +#line 228 } else { +#line 228 IF (err != 0 && err != NC_ERANGE) +#line 228 error("OK or Range error: status = %d", err); +#line 228 } +#line 228 for (j = 0; j < nels; j++) { +#line 228 if (inRange3(expect[j],var_type[i],NCT_FLOAT) +#line 228 && expect[j] >= float_min && expect[j] <= float_max) { +#line 228 IF (!equal(value[j],expect[j],var_type[i],NCT_FLOAT)){ +#line 228 error("value read not that expected"); +#line 228 if (verbose) { +#line 228 error("\n"); +#line 228 error("varid: %d, ", i); +#line 228 error("var_name: %s, ", var_name[i]); +#line 228 error("element number: %d ", j); +#line 228 error("expect: %g", expect[j]); +#line 228 error("got: %g", (double) value[j]); +#line 228 } +#line 228 } else { +#line 228 nok++; +#line 228 } +#line 228 } +#line 228 } +#line 228 } else { +#line 228 IF (nels > 0 && err != NC_ECHAR) +#line 228 error("wrong type: status = %d", err); +#line 228 } +#line 228 } +#line 228 err = nc_close(ncid); +#line 228 IF (err) +#line 228 error("nc_close: %s", nc_strerror(err)); +#line 228 print_nok(nok); +#line 228 } +#line 228 void +#line 229 test_nc_get_var_double(void) +#line 229 { +#line 229 int ncid; +#line 229 int i; +#line 229 int j; +#line 229 int err; +#line 229 int allInExtRange; /* all values within external range? */ +#line 229 int allInIntRange; /* all values within internal range? */ +#line 229 int nels; +#line 229 int nok = 0; /* count of valid comparisons */ +#line 229 size_t index[MAX_RANK]; +#line 229 int canConvert; /* Both text or both numeric */ +#line 229 double value[MAX_NELS]; +#line 229 double expect[MAX_NELS]; +#line 229 +#line 229 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 229 IF (err) +#line 229 error("nc_open: %s", nc_strerror(err)); +#line 229 for (i = 0; i < NVARS; i++) { +#line 229 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 229 assert(var_rank[i] <= MAX_RANK); +#line 229 assert(var_nels[i] <= MAX_NELS); +#line 229 err = nc_get_var_double(BAD_ID, i, value); +#line 229 IF (err != NC_EBADID) +#line 229 error("bad ncid: status = %d", err); +#line 229 err = nc_get_var_double(ncid, BAD_VARID, value); +#line 229 IF (err != NC_ENOTVAR) +#line 229 error("bad var id: status = %d", err); +#line 229 +#line 229 nels = 1; +#line 229 for (j = 0; j < var_rank[i]; j++) { +#line 229 nels *= var_shape[i][j]; +#line 229 } +#line 229 allInExtRange = allInIntRange = 1; +#line 229 for (j = 0; j < nels; j++) { +#line 229 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 229 IF (err) +#line 229 error("error in toMixedBase 1"); +#line 229 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 229 if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) { +#line 229 allInIntRange = allInIntRange && expect[j] >= double_min +#line 229 && expect[j] <= double_max; +#line 229 } else { +#line 229 allInExtRange = 0; +#line 229 } +#line 229 } +#line 229 err = nc_get_var_double(ncid, i, value); +#line 229 if (canConvert) { +#line 229 if (allInExtRange) { +#line 229 if (allInIntRange) { +#line 229 IF (err) +#line 229 error("%s", nc_strerror(err)); +#line 229 } else { +#line 229 IF (err != NC_ERANGE) +#line 229 error("Range error: status = %d", err); +#line 229 } +#line 229 } else { +#line 229 IF (err != 0 && err != NC_ERANGE) +#line 229 error("OK or Range error: status = %d", err); +#line 229 } +#line 229 for (j = 0; j < nels; j++) { +#line 229 if (inRange3(expect[j],var_type[i],NCT_DOUBLE) +#line 229 && expect[j] >= double_min && expect[j] <= double_max) { +#line 229 IF (!equal(value[j],expect[j],var_type[i],NCT_DOUBLE)){ +#line 229 error("value read not that expected"); +#line 229 if (verbose) { +#line 229 error("\n"); +#line 229 error("varid: %d, ", i); +#line 229 error("var_name: %s, ", var_name[i]); +#line 229 error("element number: %d ", j); +#line 229 error("expect: %g", expect[j]); +#line 229 error("got: %g", (double) value[j]); +#line 229 } +#line 229 } else { +#line 229 nok++; +#line 229 } +#line 229 } +#line 229 } +#line 229 } else { +#line 229 IF (nels > 0 && err != NC_ECHAR) +#line 229 error("wrong type: status = %d", err); +#line 229 } +#line 229 } +#line 229 err = nc_close(ncid); +#line 229 IF (err) +#line 229 error("nc_close: %s", nc_strerror(err)); +#line 229 print_nok(nok); +#line 229 } +#line 229 +#line 401 void +#line 402 test_nc_get_vara_text(void) +#line 402 { +#line 402 int ncid; +#line 402 int d; +#line 402 int i; +#line 402 int j; +#line 402 int k; +#line 402 int err; +#line 402 int allInExtRange; /* all values within external range? */ +#line 402 int allInIntRange; /* all values within internal range? */ +#line 402 int nels; +#line 402 int nslabs; +#line 402 int nok = 0; /* count of valid comparisons */ +#line 402 size_t start[MAX_RANK]; +#line 402 size_t edge[MAX_RANK]; +#line 402 size_t index[MAX_RANK]; +#line 402 size_t mid[MAX_RANK]; +#line 402 int canConvert; /* Both text or both numeric */ +#line 402 text value[MAX_NELS]; +#line 402 double expect[MAX_NELS]; +#line 402 +#line 402 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 402 IF (err) +#line 402 error("nc_open: %s", nc_strerror(err)); +#line 402 for (i = 0; i < NVARS; i++) { +#line 402 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 402 assert(var_rank[i] <= MAX_RANK); +#line 402 assert(var_nels[i] <= MAX_NELS); +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 start[j] = 0; +#line 402 edge[j] = 1; +#line 402 } +#line 402 err = nc_get_vara_text(BAD_ID, i, start, edge, value); +#line 402 IF (err != NC_EBADID) +#line 402 error("bad ncid: status = %d", err); +#line 402 err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value); +#line 402 IF (err != NC_ENOTVAR) +#line 402 error("bad var id: status = %d", err); +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 start[j] = var_shape[i][j]; +#line 402 err = nc_get_vara_text(ncid, i, start, edge, value); +#line 402 IF (canConvert && err != NC_EINVALCOORDS) +#line 402 error("bad index: status = %d", err); +#line 402 start[j] = 0; +#line 402 edge[j] = var_shape[i][j] + 1; +#line 402 err = nc_get_vara_text(ncid, i, start, edge, value); +#line 402 IF (canConvert && err != NC_EEDGE) +#line 402 error("bad edge: status = %d", err); +#line 402 edge[j] = 1; +#line 402 } +#line 402 /* Check non-scalars for correct error returned even when */ +#line 402 /* there is nothing to get (edge[j]==0) */ +#line 402 if(var_rank[i] > 0) { +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 edge[j] = 0; +#line 402 } +#line 402 err = nc_get_vara_text(BAD_ID, i, start, edge, value); +#line 402 IF (err != NC_EBADID) +#line 402 error("bad ncid: status = %d", err); +#line 402 err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value); +#line 402 IF (err != NC_ENOTVAR) +#line 402 error("bad var id: status = %d", err); +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 402 start[j] = var_shape[i][j]; +#line 402 err = nc_get_vara_text(ncid, i, start, edge, value); +#line 402 IF (canConvert && err != NC_EINVALCOORDS) +#line 402 error("bad start: status = %d", err); +#line 402 start[j] = 0; +#line 402 } +#line 402 } +#line 402 err = nc_get_vara_text(ncid, i, start, edge, value); +#line 402 if (canConvert) { +#line 402 IF (err) +#line 402 error("%s", nc_strerror(err)); +#line 402 } else { +#line 402 IF (err != NC_ECHAR) +#line 402 error("wrong type: status = %d", err); +#line 402 } +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 edge[j] = 1; +#line 402 } +#line 402 } /* Choose a random point dividing each dim into 2 parts */ +#line 402 /* get 2^rank (nslabs) slabs so defined */ +#line 402 nslabs = 1; +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 mid[j] = roll( var_shape[i][j] ); +#line 402 nslabs *= 2; +#line 402 } +#line 402 /* bits of k determine whether to get lower or upper part of dim */ +#line 402 for (k = 0; k < nslabs; k++) { +#line 402 nels = 1; +#line 402 for (j = 0; j < var_rank[i]; j++) { +#line 402 if ((k >> j) & 1) { +#line 402 start[j] = 0; +#line 402 edge[j] = mid[j]; +#line 402 }else{ +#line 402 start[j] = mid[j]; +#line 402 edge[j] = var_shape[i][j] - mid[j]; +#line 402 } +#line 402 nels *= edge[j]; +#line 402 } +#line 402 allInExtRange = allInIntRange = 1; +#line 402 for (j = 0; j < nels; j++) { +#line 402 err = toMixedBase(j, var_rank[i], edge, index); +#line 402 IF (err) +#line 402 error("error in toMixedBase 1"); +#line 402 for (d = 0; d < var_rank[i]; d++) +#line 402 index[d] += start[d]; +#line 402 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT); +#line 402 if (inRange3(expect[j],var_type[i], NCT_TEXT)) { +#line 402 allInIntRange = allInIntRange && expect[j] >= text_min +#line 402 && expect[j] <= text_max; +#line 402 } else { +#line 402 allInExtRange = 0; +#line 402 } +#line 402 } +#line 402 if (var_rank[i] == 0 && i%2) +#line 402 err = nc_get_vara_text(ncid, i, NULL, NULL, value); +#line 402 else +#line 402 err = nc_get_vara_text(ncid, i, start, edge, value); +#line 402 if (canConvert) { +#line 402 if (allInExtRange) { +#line 402 if (allInIntRange) { +#line 402 IF (err) +#line 402 error("%s", nc_strerror(err)); +#line 402 } else { +#line 402 IF (err != NC_ERANGE) +#line 402 error("Range error: status = %d", err); +#line 402 } +#line 402 } else { +#line 402 IF (err != 0 && err != NC_ERANGE) +#line 402 error("OK or Range error: status = %d", err); +#line 402 } +#line 402 for (j = 0; j < nels; j++) { +#line 402 if (inRange3(expect[j],var_type[i],NCT_TEXT) +#line 402 && expect[j] >= text_min && expect[j] <= text_max) { +#line 402 IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){ +#line 402 error("value read not that expected"); +#line 402 if (verbose) { +#line 402 error("\n"); +#line 402 error("varid: %d, ", i); +#line 402 error("var_name: %s, ", var_name[i]); +#line 402 error("element number: %d ", j); +#line 402 error("expect: %g", expect[j]); +#line 402 error("got: %g", (double) value[j]); +#line 402 } +#line 402 } else { +#line 402 nok++; +#line 402 } +#line 402 } +#line 402 } +#line 402 } else { +#line 402 IF (nels > 0 && err != NC_ECHAR) +#line 402 error("wrong type: status = %d", err); +#line 402 } +#line 402 } +#line 402 } +#line 402 err = nc_close(ncid); +#line 402 IF (err) +#line 402 error("nc_close: %s", nc_strerror(err)); +#line 402 print_nok(nok); +#line 402 } +#line 402 void +#line 403 test_nc_get_vara_uchar(void) +#line 403 { +#line 403 int ncid; +#line 403 int d; +#line 403 int i; +#line 403 int j; +#line 403 int k; +#line 403 int err; +#line 403 int allInExtRange; /* all values within external range? */ +#line 403 int allInIntRange; /* all values within internal range? */ +#line 403 int nels; +#line 403 int nslabs; +#line 403 int nok = 0; /* count of valid comparisons */ +#line 403 size_t start[MAX_RANK]; +#line 403 size_t edge[MAX_RANK]; +#line 403 size_t index[MAX_RANK]; +#line 403 size_t mid[MAX_RANK]; +#line 403 int canConvert; /* Both text or both numeric */ +#line 403 uchar value[MAX_NELS]; +#line 403 double expect[MAX_NELS]; +#line 403 +#line 403 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 403 IF (err) +#line 403 error("nc_open: %s", nc_strerror(err)); +#line 403 for (i = 0; i < NVARS; i++) { +#line 403 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 403 assert(var_rank[i] <= MAX_RANK); +#line 403 assert(var_nels[i] <= MAX_NELS); +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 start[j] = 0; +#line 403 edge[j] = 1; +#line 403 } +#line 403 err = nc_get_vara_uchar(BAD_ID, i, start, edge, value); +#line 403 IF (err != NC_EBADID) +#line 403 error("bad ncid: status = %d", err); +#line 403 err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value); +#line 403 IF (err != NC_ENOTVAR) +#line 403 error("bad var id: status = %d", err); +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 start[j] = var_shape[i][j]; +#line 403 err = nc_get_vara_uchar(ncid, i, start, edge, value); +#line 403 IF (canConvert && err != NC_EINVALCOORDS) +#line 403 error("bad index: status = %d", err); +#line 403 start[j] = 0; +#line 403 edge[j] = var_shape[i][j] + 1; +#line 403 err = nc_get_vara_uchar(ncid, i, start, edge, value); +#line 403 IF (canConvert && err != NC_EEDGE) +#line 403 error("bad edge: status = %d", err); +#line 403 edge[j] = 1; +#line 403 } +#line 403 /* Check non-scalars for correct error returned even when */ +#line 403 /* there is nothing to get (edge[j]==0) */ +#line 403 if(var_rank[i] > 0) { +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 edge[j] = 0; +#line 403 } +#line 403 err = nc_get_vara_uchar(BAD_ID, i, start, edge, value); +#line 403 IF (err != NC_EBADID) +#line 403 error("bad ncid: status = %d", err); +#line 403 err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value); +#line 403 IF (err != NC_ENOTVAR) +#line 403 error("bad var id: status = %d", err); +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 403 start[j] = var_shape[i][j]; +#line 403 err = nc_get_vara_uchar(ncid, i, start, edge, value); +#line 403 IF (canConvert && err != NC_EINVALCOORDS) +#line 403 error("bad start: status = %d", err); +#line 403 start[j] = 0; +#line 403 } +#line 403 } +#line 403 err = nc_get_vara_uchar(ncid, i, start, edge, value); +#line 403 if (canConvert) { +#line 403 IF (err) +#line 403 error("%s", nc_strerror(err)); +#line 403 } else { +#line 403 IF (err != NC_ECHAR) +#line 403 error("wrong type: status = %d", err); +#line 403 } +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 edge[j] = 1; +#line 403 } +#line 403 } /* Choose a random point dividing each dim into 2 parts */ +#line 403 /* get 2^rank (nslabs) slabs so defined */ +#line 403 nslabs = 1; +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 mid[j] = roll( var_shape[i][j] ); +#line 403 nslabs *= 2; +#line 403 } +#line 403 /* bits of k determine whether to get lower or upper part of dim */ +#line 403 for (k = 0; k < nslabs; k++) { +#line 403 nels = 1; +#line 403 for (j = 0; j < var_rank[i]; j++) { +#line 403 if ((k >> j) & 1) { +#line 403 start[j] = 0; +#line 403 edge[j] = mid[j]; +#line 403 }else{ +#line 403 start[j] = mid[j]; +#line 403 edge[j] = var_shape[i][j] - mid[j]; +#line 403 } +#line 403 nels *= edge[j]; +#line 403 } +#line 403 allInExtRange = allInIntRange = 1; +#line 403 for (j = 0; j < nels; j++) { +#line 403 err = toMixedBase(j, var_rank[i], edge, index); +#line 403 IF (err) +#line 403 error("error in toMixedBase 1"); +#line 403 for (d = 0; d < var_rank[i]; d++) +#line 403 index[d] += start[d]; +#line 403 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR); +#line 403 if (inRange3(expect[j],var_type[i], NCT_UCHAR)) { +#line 403 allInIntRange = allInIntRange && expect[j] >= uchar_min +#line 403 && expect[j] <= uchar_max; +#line 403 } else { +#line 403 allInExtRange = 0; +#line 403 } +#line 403 } +#line 403 if (var_rank[i] == 0 && i%2) +#line 403 err = nc_get_vara_uchar(ncid, i, NULL, NULL, value); +#line 403 else +#line 403 err = nc_get_vara_uchar(ncid, i, start, edge, value); +#line 403 if (canConvert) { +#line 403 if (allInExtRange) { +#line 403 if (allInIntRange) { +#line 403 IF (err) +#line 403 error("%s", nc_strerror(err)); +#line 403 } else { +#line 403 IF (err != NC_ERANGE) +#line 403 error("Range error: status = %d", err); +#line 403 } +#line 403 } else { +#line 403 IF (err != 0 && err != NC_ERANGE) +#line 403 error("OK or Range error: status = %d", err); +#line 403 } +#line 403 for (j = 0; j < nels; j++) { +#line 403 if (inRange3(expect[j],var_type[i],NCT_UCHAR) +#line 403 && expect[j] >= uchar_min && expect[j] <= uchar_max) { +#line 403 IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){ +#line 403 error("value read not that expected"); +#line 403 if (verbose) { +#line 403 error("\n"); +#line 403 error("varid: %d, ", i); +#line 403 error("var_name: %s, ", var_name[i]); +#line 403 error("element number: %d ", j); +#line 403 error("expect: %g", expect[j]); +#line 403 error("got: %g", (double) value[j]); +#line 403 } +#line 403 } else { +#line 403 nok++; +#line 403 } +#line 403 } +#line 403 } +#line 403 } else { +#line 403 IF (nels > 0 && err != NC_ECHAR) +#line 403 error("wrong type: status = %d", err); +#line 403 } +#line 403 } +#line 403 } +#line 403 err = nc_close(ncid); +#line 403 IF (err) +#line 403 error("nc_close: %s", nc_strerror(err)); +#line 403 print_nok(nok); +#line 403 } +#line 403 void +#line 404 test_nc_get_vara_schar(void) +#line 404 { +#line 404 int ncid; +#line 404 int d; +#line 404 int i; +#line 404 int j; +#line 404 int k; +#line 404 int err; +#line 404 int allInExtRange; /* all values within external range? */ +#line 404 int allInIntRange; /* all values within internal range? */ +#line 404 int nels; +#line 404 int nslabs; +#line 404 int nok = 0; /* count of valid comparisons */ +#line 404 size_t start[MAX_RANK]; +#line 404 size_t edge[MAX_RANK]; +#line 404 size_t index[MAX_RANK]; +#line 404 size_t mid[MAX_RANK]; +#line 404 int canConvert; /* Both text or both numeric */ +#line 404 schar value[MAX_NELS]; +#line 404 double expect[MAX_NELS]; +#line 404 +#line 404 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 404 IF (err) +#line 404 error("nc_open: %s", nc_strerror(err)); +#line 404 for (i = 0; i < NVARS; i++) { +#line 404 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 404 assert(var_rank[i] <= MAX_RANK); +#line 404 assert(var_nels[i] <= MAX_NELS); +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 start[j] = 0; +#line 404 edge[j] = 1; +#line 404 } +#line 404 err = nc_get_vara_schar(BAD_ID, i, start, edge, value); +#line 404 IF (err != NC_EBADID) +#line 404 error("bad ncid: status = %d", err); +#line 404 err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value); +#line 404 IF (err != NC_ENOTVAR) +#line 404 error("bad var id: status = %d", err); +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 start[j] = var_shape[i][j]; +#line 404 err = nc_get_vara_schar(ncid, i, start, edge, value); +#line 404 IF (canConvert && err != NC_EINVALCOORDS) +#line 404 error("bad index: status = %d", err); +#line 404 start[j] = 0; +#line 404 edge[j] = var_shape[i][j] + 1; +#line 404 err = nc_get_vara_schar(ncid, i, start, edge, value); +#line 404 IF (canConvert && err != NC_EEDGE) +#line 404 error("bad edge: status = %d", err); +#line 404 edge[j] = 1; +#line 404 } +#line 404 /* Check non-scalars for correct error returned even when */ +#line 404 /* there is nothing to get (edge[j]==0) */ +#line 404 if(var_rank[i] > 0) { +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 edge[j] = 0; +#line 404 } +#line 404 err = nc_get_vara_schar(BAD_ID, i, start, edge, value); +#line 404 IF (err != NC_EBADID) +#line 404 error("bad ncid: status = %d", err); +#line 404 err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value); +#line 404 IF (err != NC_ENOTVAR) +#line 404 error("bad var id: status = %d", err); +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 404 start[j] = var_shape[i][j]; +#line 404 err = nc_get_vara_schar(ncid, i, start, edge, value); +#line 404 IF (canConvert && err != NC_EINVALCOORDS) +#line 404 error("bad start: status = %d", err); +#line 404 start[j] = 0; +#line 404 } +#line 404 } +#line 404 err = nc_get_vara_schar(ncid, i, start, edge, value); +#line 404 if (canConvert) { +#line 404 IF (err) +#line 404 error("%s", nc_strerror(err)); +#line 404 } else { +#line 404 IF (err != NC_ECHAR) +#line 404 error("wrong type: status = %d", err); +#line 404 } +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 edge[j] = 1; +#line 404 } +#line 404 } /* Choose a random point dividing each dim into 2 parts */ +#line 404 /* get 2^rank (nslabs) slabs so defined */ +#line 404 nslabs = 1; +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 mid[j] = roll( var_shape[i][j] ); +#line 404 nslabs *= 2; +#line 404 } +#line 404 /* bits of k determine whether to get lower or upper part of dim */ +#line 404 for (k = 0; k < nslabs; k++) { +#line 404 nels = 1; +#line 404 for (j = 0; j < var_rank[i]; j++) { +#line 404 if ((k >> j) & 1) { +#line 404 start[j] = 0; +#line 404 edge[j] = mid[j]; +#line 404 }else{ +#line 404 start[j] = mid[j]; +#line 404 edge[j] = var_shape[i][j] - mid[j]; +#line 404 } +#line 404 nels *= edge[j]; +#line 404 } +#line 404 allInExtRange = allInIntRange = 1; +#line 404 for (j = 0; j < nels; j++) { +#line 404 err = toMixedBase(j, var_rank[i], edge, index); +#line 404 IF (err) +#line 404 error("error in toMixedBase 1"); +#line 404 for (d = 0; d < var_rank[i]; d++) +#line 404 index[d] += start[d]; +#line 404 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR); +#line 404 if (inRange3(expect[j],var_type[i], NCT_SCHAR)) { +#line 404 allInIntRange = allInIntRange && expect[j] >= schar_min +#line 404 && expect[j] <= schar_max; +#line 404 } else { +#line 404 allInExtRange = 0; +#line 404 } +#line 404 } +#line 404 if (var_rank[i] == 0 && i%2) +#line 404 err = nc_get_vara_schar(ncid, i, NULL, NULL, value); +#line 404 else +#line 404 err = nc_get_vara_schar(ncid, i, start, edge, value); +#line 404 if (canConvert) { +#line 404 if (allInExtRange) { +#line 404 if (allInIntRange) { +#line 404 IF (err) +#line 404 error("%s", nc_strerror(err)); +#line 404 } else { +#line 404 IF (err != NC_ERANGE) +#line 404 error("Range error: status = %d", err); +#line 404 } +#line 404 } else { +#line 404 IF (err != 0 && err != NC_ERANGE) +#line 404 error("OK or Range error: status = %d", err); +#line 404 } +#line 404 for (j = 0; j < nels; j++) { +#line 404 if (inRange3(expect[j],var_type[i],NCT_SCHAR) +#line 404 && expect[j] >= schar_min && expect[j] <= schar_max) { +#line 404 IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){ +#line 404 error("value read not that expected"); +#line 404 if (verbose) { +#line 404 error("\n"); +#line 404 error("varid: %d, ", i); +#line 404 error("var_name: %s, ", var_name[i]); +#line 404 error("element number: %d ", j); +#line 404 error("expect: %g", expect[j]); +#line 404 error("got: %g", (double) value[j]); +#line 404 } +#line 404 } else { +#line 404 nok++; +#line 404 } +#line 404 } +#line 404 } +#line 404 } else { +#line 404 IF (nels > 0 && err != NC_ECHAR) +#line 404 error("wrong type: status = %d", err); +#line 404 } +#line 404 } +#line 404 } +#line 404 err = nc_close(ncid); +#line 404 IF (err) +#line 404 error("nc_close: %s", nc_strerror(err)); +#line 404 print_nok(nok); +#line 404 } +#line 404 void +#line 405 test_nc_get_vara_short(void) +#line 405 { +#line 405 int ncid; +#line 405 int d; +#line 405 int i; +#line 405 int j; +#line 405 int k; +#line 405 int err; +#line 405 int allInExtRange; /* all values within external range? */ +#line 405 int allInIntRange; /* all values within internal range? */ +#line 405 int nels; +#line 405 int nslabs; +#line 405 int nok = 0; /* count of valid comparisons */ +#line 405 size_t start[MAX_RANK]; +#line 405 size_t edge[MAX_RANK]; +#line 405 size_t index[MAX_RANK]; +#line 405 size_t mid[MAX_RANK]; +#line 405 int canConvert; /* Both text or both numeric */ +#line 405 short value[MAX_NELS]; +#line 405 double expect[MAX_NELS]; +#line 405 +#line 405 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 405 IF (err) +#line 405 error("nc_open: %s", nc_strerror(err)); +#line 405 for (i = 0; i < NVARS; i++) { +#line 405 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 405 assert(var_rank[i] <= MAX_RANK); +#line 405 assert(var_nels[i] <= MAX_NELS); +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 start[j] = 0; +#line 405 edge[j] = 1; +#line 405 } +#line 405 err = nc_get_vara_short(BAD_ID, i, start, edge, value); +#line 405 IF (err != NC_EBADID) +#line 405 error("bad ncid: status = %d", err); +#line 405 err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value); +#line 405 IF (err != NC_ENOTVAR) +#line 405 error("bad var id: status = %d", err); +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 start[j] = var_shape[i][j]; +#line 405 err = nc_get_vara_short(ncid, i, start, edge, value); +#line 405 IF (canConvert && err != NC_EINVALCOORDS) +#line 405 error("bad index: status = %d", err); +#line 405 start[j] = 0; +#line 405 edge[j] = var_shape[i][j] + 1; +#line 405 err = nc_get_vara_short(ncid, i, start, edge, value); +#line 405 IF (canConvert && err != NC_EEDGE) +#line 405 error("bad edge: status = %d", err); +#line 405 edge[j] = 1; +#line 405 } +#line 405 /* Check non-scalars for correct error returned even when */ +#line 405 /* there is nothing to get (edge[j]==0) */ +#line 405 if(var_rank[i] > 0) { +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 edge[j] = 0; +#line 405 } +#line 405 err = nc_get_vara_short(BAD_ID, i, start, edge, value); +#line 405 IF (err != NC_EBADID) +#line 405 error("bad ncid: status = %d", err); +#line 405 err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value); +#line 405 IF (err != NC_ENOTVAR) +#line 405 error("bad var id: status = %d", err); +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 405 start[j] = var_shape[i][j]; +#line 405 err = nc_get_vara_short(ncid, i, start, edge, value); +#line 405 IF (canConvert && err != NC_EINVALCOORDS) +#line 405 error("bad start: status = %d", err); +#line 405 start[j] = 0; +#line 405 } +#line 405 } +#line 405 err = nc_get_vara_short(ncid, i, start, edge, value); +#line 405 if (canConvert) { +#line 405 IF (err) +#line 405 error("%s", nc_strerror(err)); +#line 405 } else { +#line 405 IF (err != NC_ECHAR) +#line 405 error("wrong type: status = %d", err); +#line 405 } +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 edge[j] = 1; +#line 405 } +#line 405 } /* Choose a random point dividing each dim into 2 parts */ +#line 405 /* get 2^rank (nslabs) slabs so defined */ +#line 405 nslabs = 1; +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 mid[j] = roll( var_shape[i][j] ); +#line 405 nslabs *= 2; +#line 405 } +#line 405 /* bits of k determine whether to get lower or upper part of dim */ +#line 405 for (k = 0; k < nslabs; k++) { +#line 405 nels = 1; +#line 405 for (j = 0; j < var_rank[i]; j++) { +#line 405 if ((k >> j) & 1) { +#line 405 start[j] = 0; +#line 405 edge[j] = mid[j]; +#line 405 }else{ +#line 405 start[j] = mid[j]; +#line 405 edge[j] = var_shape[i][j] - mid[j]; +#line 405 } +#line 405 nels *= edge[j]; +#line 405 } +#line 405 allInExtRange = allInIntRange = 1; +#line 405 for (j = 0; j < nels; j++) { +#line 405 err = toMixedBase(j, var_rank[i], edge, index); +#line 405 IF (err) +#line 405 error("error in toMixedBase 1"); +#line 405 for (d = 0; d < var_rank[i]; d++) +#line 405 index[d] += start[d]; +#line 405 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT); +#line 405 if (inRange3(expect[j],var_type[i], NCT_SHORT)) { +#line 405 allInIntRange = allInIntRange && expect[j] >= short_min +#line 405 && expect[j] <= short_max; +#line 405 } else { +#line 405 allInExtRange = 0; +#line 405 } +#line 405 } +#line 405 if (var_rank[i] == 0 && i%2) +#line 405 err = nc_get_vara_short(ncid, i, NULL, NULL, value); +#line 405 else +#line 405 err = nc_get_vara_short(ncid, i, start, edge, value); +#line 405 if (canConvert) { +#line 405 if (allInExtRange) { +#line 405 if (allInIntRange) { +#line 405 IF (err) +#line 405 error("%s", nc_strerror(err)); +#line 405 } else { +#line 405 IF (err != NC_ERANGE) +#line 405 error("Range error: status = %d", err); +#line 405 } +#line 405 } else { +#line 405 IF (err != 0 && err != NC_ERANGE) +#line 405 error("OK or Range error: status = %d", err); +#line 405 } +#line 405 for (j = 0; j < nels; j++) { +#line 405 if (inRange3(expect[j],var_type[i],NCT_SHORT) +#line 405 && expect[j] >= short_min && expect[j] <= short_max) { +#line 405 IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){ +#line 405 error("value read not that expected"); +#line 405 if (verbose) { +#line 405 error("\n"); +#line 405 error("varid: %d, ", i); +#line 405 error("var_name: %s, ", var_name[i]); +#line 405 error("element number: %d ", j); +#line 405 error("expect: %g", expect[j]); +#line 405 error("got: %g", (double) value[j]); +#line 405 } +#line 405 } else { +#line 405 nok++; +#line 405 } +#line 405 } +#line 405 } +#line 405 } else { +#line 405 IF (nels > 0 && err != NC_ECHAR) +#line 405 error("wrong type: status = %d", err); +#line 405 } +#line 405 } +#line 405 } +#line 405 err = nc_close(ncid); +#line 405 IF (err) +#line 405 error("nc_close: %s", nc_strerror(err)); +#line 405 print_nok(nok); +#line 405 } +#line 405 void +#line 406 test_nc_get_vara_int(void) +#line 406 { +#line 406 int ncid; +#line 406 int d; +#line 406 int i; +#line 406 int j; +#line 406 int k; +#line 406 int err; +#line 406 int allInExtRange; /* all values within external range? */ +#line 406 int allInIntRange; /* all values within internal range? */ +#line 406 int nels; +#line 406 int nslabs; +#line 406 int nok = 0; /* count of valid comparisons */ +#line 406 size_t start[MAX_RANK]; +#line 406 size_t edge[MAX_RANK]; +#line 406 size_t index[MAX_RANK]; +#line 406 size_t mid[MAX_RANK]; +#line 406 int canConvert; /* Both text or both numeric */ +#line 406 int value[MAX_NELS]; +#line 406 double expect[MAX_NELS]; +#line 406 +#line 406 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 406 IF (err) +#line 406 error("nc_open: %s", nc_strerror(err)); +#line 406 for (i = 0; i < NVARS; i++) { +#line 406 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 406 assert(var_rank[i] <= MAX_RANK); +#line 406 assert(var_nels[i] <= MAX_NELS); +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 start[j] = 0; +#line 406 edge[j] = 1; +#line 406 } +#line 406 err = nc_get_vara_int(BAD_ID, i, start, edge, value); +#line 406 IF (err != NC_EBADID) +#line 406 error("bad ncid: status = %d", err); +#line 406 err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value); +#line 406 IF (err != NC_ENOTVAR) +#line 406 error("bad var id: status = %d", err); +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 start[j] = var_shape[i][j]; +#line 406 err = nc_get_vara_int(ncid, i, start, edge, value); +#line 406 IF (canConvert && err != NC_EINVALCOORDS) +#line 406 error("bad index: status = %d", err); +#line 406 start[j] = 0; +#line 406 edge[j] = var_shape[i][j] + 1; +#line 406 err = nc_get_vara_int(ncid, i, start, edge, value); +#line 406 IF (canConvert && err != NC_EEDGE) +#line 406 error("bad edge: status = %d", err); +#line 406 edge[j] = 1; +#line 406 } +#line 406 /* Check non-scalars for correct error returned even when */ +#line 406 /* there is nothing to get (edge[j]==0) */ +#line 406 if(var_rank[i] > 0) { +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 edge[j] = 0; +#line 406 } +#line 406 err = nc_get_vara_int(BAD_ID, i, start, edge, value); +#line 406 IF (err != NC_EBADID) +#line 406 error("bad ncid: status = %d", err); +#line 406 err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value); +#line 406 IF (err != NC_ENOTVAR) +#line 406 error("bad var id: status = %d", err); +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 406 start[j] = var_shape[i][j]; +#line 406 err = nc_get_vara_int(ncid, i, start, edge, value); +#line 406 IF (canConvert && err != NC_EINVALCOORDS) +#line 406 error("bad start: status = %d", err); +#line 406 start[j] = 0; +#line 406 } +#line 406 } +#line 406 err = nc_get_vara_int(ncid, i, start, edge, value); +#line 406 if (canConvert) { +#line 406 IF (err) +#line 406 error("%s", nc_strerror(err)); +#line 406 } else { +#line 406 IF (err != NC_ECHAR) +#line 406 error("wrong type: status = %d", err); +#line 406 } +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 edge[j] = 1; +#line 406 } +#line 406 } /* Choose a random point dividing each dim into 2 parts */ +#line 406 /* get 2^rank (nslabs) slabs so defined */ +#line 406 nslabs = 1; +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 mid[j] = roll( var_shape[i][j] ); +#line 406 nslabs *= 2; +#line 406 } +#line 406 /* bits of k determine whether to get lower or upper part of dim */ +#line 406 for (k = 0; k < nslabs; k++) { +#line 406 nels = 1; +#line 406 for (j = 0; j < var_rank[i]; j++) { +#line 406 if ((k >> j) & 1) { +#line 406 start[j] = 0; +#line 406 edge[j] = mid[j]; +#line 406 }else{ +#line 406 start[j] = mid[j]; +#line 406 edge[j] = var_shape[i][j] - mid[j]; +#line 406 } +#line 406 nels *= edge[j]; +#line 406 } +#line 406 allInExtRange = allInIntRange = 1; +#line 406 for (j = 0; j < nels; j++) { +#line 406 err = toMixedBase(j, var_rank[i], edge, index); +#line 406 IF (err) +#line 406 error("error in toMixedBase 1"); +#line 406 for (d = 0; d < var_rank[i]; d++) +#line 406 index[d] += start[d]; +#line 406 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT); +#line 406 if (inRange3(expect[j],var_type[i], NCT_INT)) { +#line 406 allInIntRange = allInIntRange && expect[j] >= int_min +#line 406 && expect[j] <= int_max; +#line 406 } else { +#line 406 allInExtRange = 0; +#line 406 } +#line 406 } +#line 406 if (var_rank[i] == 0 && i%2) +#line 406 err = nc_get_vara_int(ncid, i, NULL, NULL, value); +#line 406 else +#line 406 err = nc_get_vara_int(ncid, i, start, edge, value); +#line 406 if (canConvert) { +#line 406 if (allInExtRange) { +#line 406 if (allInIntRange) { +#line 406 IF (err) +#line 406 error("%s", nc_strerror(err)); +#line 406 } else { +#line 406 IF (err != NC_ERANGE) +#line 406 error("Range error: status = %d", err); +#line 406 } +#line 406 } else { +#line 406 IF (err != 0 && err != NC_ERANGE) +#line 406 error("OK or Range error: status = %d", err); +#line 406 } +#line 406 for (j = 0; j < nels; j++) { +#line 406 if (inRange3(expect[j],var_type[i],NCT_INT) +#line 406 && expect[j] >= int_min && expect[j] <= int_max) { +#line 406 IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){ +#line 406 error("value read not that expected"); +#line 406 if (verbose) { +#line 406 error("\n"); +#line 406 error("varid: %d, ", i); +#line 406 error("var_name: %s, ", var_name[i]); +#line 406 error("element number: %d ", j); +#line 406 error("expect: %g", expect[j]); +#line 406 error("got: %g", (double) value[j]); +#line 406 } +#line 406 } else { +#line 406 nok++; +#line 406 } +#line 406 } +#line 406 } +#line 406 } else { +#line 406 IF (nels > 0 && err != NC_ECHAR) +#line 406 error("wrong type: status = %d", err); +#line 406 } +#line 406 } +#line 406 } +#line 406 err = nc_close(ncid); +#line 406 IF (err) +#line 406 error("nc_close: %s", nc_strerror(err)); +#line 406 print_nok(nok); +#line 406 } +#line 406 void +#line 407 test_nc_get_vara_long(void) +#line 407 { +#line 407 int ncid; +#line 407 int d; +#line 407 int i; +#line 407 int j; +#line 407 int k; +#line 407 int err; +#line 407 int allInExtRange; /* all values within external range? */ +#line 407 int allInIntRange; /* all values within internal range? */ +#line 407 int nels; +#line 407 int nslabs; +#line 407 int nok = 0; /* count of valid comparisons */ +#line 407 size_t start[MAX_RANK]; +#line 407 size_t edge[MAX_RANK]; +#line 407 size_t index[MAX_RANK]; +#line 407 size_t mid[MAX_RANK]; +#line 407 int canConvert; /* Both text or both numeric */ +#line 407 long value[MAX_NELS]; +#line 407 double expect[MAX_NELS]; +#line 407 +#line 407 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 407 IF (err) +#line 407 error("nc_open: %s", nc_strerror(err)); +#line 407 for (i = 0; i < NVARS; i++) { +#line 407 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 407 assert(var_rank[i] <= MAX_RANK); +#line 407 assert(var_nels[i] <= MAX_NELS); +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 start[j] = 0; +#line 407 edge[j] = 1; +#line 407 } +#line 407 err = nc_get_vara_long(BAD_ID, i, start, edge, value); +#line 407 IF (err != NC_EBADID) +#line 407 error("bad ncid: status = %d", err); +#line 407 err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value); +#line 407 IF (err != NC_ENOTVAR) +#line 407 error("bad var id: status = %d", err); +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 start[j] = var_shape[i][j]; +#line 407 err = nc_get_vara_long(ncid, i, start, edge, value); +#line 407 IF (canConvert && err != NC_EINVALCOORDS) +#line 407 error("bad index: status = %d", err); +#line 407 start[j] = 0; +#line 407 edge[j] = var_shape[i][j] + 1; +#line 407 err = nc_get_vara_long(ncid, i, start, edge, value); +#line 407 IF (canConvert && err != NC_EEDGE) +#line 407 error("bad edge: status = %d", err); +#line 407 edge[j] = 1; +#line 407 } +#line 407 /* Check non-scalars for correct error returned even when */ +#line 407 /* there is nothing to get (edge[j]==0) */ +#line 407 if(var_rank[i] > 0) { +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 edge[j] = 0; +#line 407 } +#line 407 err = nc_get_vara_long(BAD_ID, i, start, edge, value); +#line 407 IF (err != NC_EBADID) +#line 407 error("bad ncid: status = %d", err); +#line 407 err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value); +#line 407 IF (err != NC_ENOTVAR) +#line 407 error("bad var id: status = %d", err); +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 407 start[j] = var_shape[i][j]; +#line 407 err = nc_get_vara_long(ncid, i, start, edge, value); +#line 407 IF (canConvert && err != NC_EINVALCOORDS) +#line 407 error("bad start: status = %d", err); +#line 407 start[j] = 0; +#line 407 } +#line 407 } +#line 407 err = nc_get_vara_long(ncid, i, start, edge, value); +#line 407 if (canConvert) { +#line 407 IF (err) +#line 407 error("%s", nc_strerror(err)); +#line 407 } else { +#line 407 IF (err != NC_ECHAR) +#line 407 error("wrong type: status = %d", err); +#line 407 } +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 edge[j] = 1; +#line 407 } +#line 407 } /* Choose a random point dividing each dim into 2 parts */ +#line 407 /* get 2^rank (nslabs) slabs so defined */ +#line 407 nslabs = 1; +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 mid[j] = roll( var_shape[i][j] ); +#line 407 nslabs *= 2; +#line 407 } +#line 407 /* bits of k determine whether to get lower or upper part of dim */ +#line 407 for (k = 0; k < nslabs; k++) { +#line 407 nels = 1; +#line 407 for (j = 0; j < var_rank[i]; j++) { +#line 407 if ((k >> j) & 1) { +#line 407 start[j] = 0; +#line 407 edge[j] = mid[j]; +#line 407 }else{ +#line 407 start[j] = mid[j]; +#line 407 edge[j] = var_shape[i][j] - mid[j]; +#line 407 } +#line 407 nels *= edge[j]; +#line 407 } +#line 407 allInExtRange = allInIntRange = 1; +#line 407 for (j = 0; j < nels; j++) { +#line 407 err = toMixedBase(j, var_rank[i], edge, index); +#line 407 IF (err) +#line 407 error("error in toMixedBase 1"); +#line 407 for (d = 0; d < var_rank[i]; d++) +#line 407 index[d] += start[d]; +#line 407 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG); +#line 407 if (inRange3(expect[j],var_type[i], NCT_LONG)) { +#line 407 allInIntRange = allInIntRange && expect[j] >= long_min +#line 407 && expect[j] <= long_max; +#line 407 } else { +#line 407 allInExtRange = 0; +#line 407 } +#line 407 } +#line 407 if (var_rank[i] == 0 && i%2) +#line 407 err = nc_get_vara_long(ncid, i, NULL, NULL, value); +#line 407 else +#line 407 err = nc_get_vara_long(ncid, i, start, edge, value); +#line 407 if (canConvert) { +#line 407 if (allInExtRange) { +#line 407 if (allInIntRange) { +#line 407 IF (err) +#line 407 error("%s", nc_strerror(err)); +#line 407 } else { +#line 407 IF (err != NC_ERANGE) +#line 407 error("Range error: status = %d", err); +#line 407 } +#line 407 } else { +#line 407 IF (err != 0 && err != NC_ERANGE) +#line 407 error("OK or Range error: status = %d", err); +#line 407 } +#line 407 for (j = 0; j < nels; j++) { +#line 407 if (inRange3(expect[j],var_type[i],NCT_LONG) +#line 407 && expect[j] >= long_min && expect[j] <= long_max) { +#line 407 IF (!equal(value[j],expect[j],var_type[i],NCT_LONG)){ +#line 407 error("value read not that expected"); +#line 407 if (verbose) { +#line 407 error("\n"); +#line 407 error("varid: %d, ", i); +#line 407 error("var_name: %s, ", var_name[i]); +#line 407 error("element number: %d ", j); +#line 407 error("expect: %g", expect[j]); +#line 407 error("got: %g", (double) value[j]); +#line 407 } +#line 407 } else { +#line 407 nok++; +#line 407 } +#line 407 } +#line 407 } +#line 407 } else { +#line 407 IF (nels > 0 && err != NC_ECHAR) +#line 407 error("wrong type: status = %d", err); +#line 407 } +#line 407 } +#line 407 } +#line 407 err = nc_close(ncid); +#line 407 IF (err) +#line 407 error("nc_close: %s", nc_strerror(err)); +#line 407 print_nok(nok); +#line 407 } +#line 407 void +#line 408 test_nc_get_vara_float(void) +#line 408 { +#line 408 int ncid; +#line 408 int d; +#line 408 int i; +#line 408 int j; +#line 408 int k; +#line 408 int err; +#line 408 int allInExtRange; /* all values within external range? */ +#line 408 int allInIntRange; /* all values within internal range? */ +#line 408 int nels; +#line 408 int nslabs; +#line 408 int nok = 0; /* count of valid comparisons */ +#line 408 size_t start[MAX_RANK]; +#line 408 size_t edge[MAX_RANK]; +#line 408 size_t index[MAX_RANK]; +#line 408 size_t mid[MAX_RANK]; +#line 408 int canConvert; /* Both text or both numeric */ +#line 408 float value[MAX_NELS]; +#line 408 double expect[MAX_NELS]; +#line 408 +#line 408 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 408 IF (err) +#line 408 error("nc_open: %s", nc_strerror(err)); +#line 408 for (i = 0; i < NVARS; i++) { +#line 408 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 408 assert(var_rank[i] <= MAX_RANK); +#line 408 assert(var_nels[i] <= MAX_NELS); +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 start[j] = 0; +#line 408 edge[j] = 1; +#line 408 } +#line 408 err = nc_get_vara_float(BAD_ID, i, start, edge, value); +#line 408 IF (err != NC_EBADID) +#line 408 error("bad ncid: status = %d", err); +#line 408 err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value); +#line 408 IF (err != NC_ENOTVAR) +#line 408 error("bad var id: status = %d", err); +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 start[j] = var_shape[i][j]; +#line 408 err = nc_get_vara_float(ncid, i, start, edge, value); +#line 408 IF (canConvert && err != NC_EINVALCOORDS) +#line 408 error("bad index: status = %d", err); +#line 408 start[j] = 0; +#line 408 edge[j] = var_shape[i][j] + 1; +#line 408 err = nc_get_vara_float(ncid, i, start, edge, value); +#line 408 IF (canConvert && err != NC_EEDGE) +#line 408 error("bad edge: status = %d", err); +#line 408 edge[j] = 1; +#line 408 } +#line 408 /* Check non-scalars for correct error returned even when */ +#line 408 /* there is nothing to get (edge[j]==0) */ +#line 408 if(var_rank[i] > 0) { +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 edge[j] = 0; +#line 408 } +#line 408 err = nc_get_vara_float(BAD_ID, i, start, edge, value); +#line 408 IF (err != NC_EBADID) +#line 408 error("bad ncid: status = %d", err); +#line 408 err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value); +#line 408 IF (err != NC_ENOTVAR) +#line 408 error("bad var id: status = %d", err); +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 408 start[j] = var_shape[i][j]; +#line 408 err = nc_get_vara_float(ncid, i, start, edge, value); +#line 408 IF (canConvert && err != NC_EINVALCOORDS) +#line 408 error("bad start: status = %d", err); +#line 408 start[j] = 0; +#line 408 } +#line 408 } +#line 408 err = nc_get_vara_float(ncid, i, start, edge, value); +#line 408 if (canConvert) { +#line 408 IF (err) +#line 408 error("%s", nc_strerror(err)); +#line 408 } else { +#line 408 IF (err != NC_ECHAR) +#line 408 error("wrong type: status = %d", err); +#line 408 } +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 edge[j] = 1; +#line 408 } +#line 408 } /* Choose a random point dividing each dim into 2 parts */ +#line 408 /* get 2^rank (nslabs) slabs so defined */ +#line 408 nslabs = 1; +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 mid[j] = roll( var_shape[i][j] ); +#line 408 nslabs *= 2; +#line 408 } +#line 408 /* bits of k determine whether to get lower or upper part of dim */ +#line 408 for (k = 0; k < nslabs; k++) { +#line 408 nels = 1; +#line 408 for (j = 0; j < var_rank[i]; j++) { +#line 408 if ((k >> j) & 1) { +#line 408 start[j] = 0; +#line 408 edge[j] = mid[j]; +#line 408 }else{ +#line 408 start[j] = mid[j]; +#line 408 edge[j] = var_shape[i][j] - mid[j]; +#line 408 } +#line 408 nels *= edge[j]; +#line 408 } +#line 408 allInExtRange = allInIntRange = 1; +#line 408 for (j = 0; j < nels; j++) { +#line 408 err = toMixedBase(j, var_rank[i], edge, index); +#line 408 IF (err) +#line 408 error("error in toMixedBase 1"); +#line 408 for (d = 0; d < var_rank[i]; d++) +#line 408 index[d] += start[d]; +#line 408 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT); +#line 408 if (inRange3(expect[j],var_type[i], NCT_FLOAT)) { +#line 408 allInIntRange = allInIntRange && expect[j] >= float_min +#line 408 && expect[j] <= float_max; +#line 408 } else { +#line 408 allInExtRange = 0; +#line 408 } +#line 408 } +#line 408 if (var_rank[i] == 0 && i%2) +#line 408 err = nc_get_vara_float(ncid, i, NULL, NULL, value); +#line 408 else +#line 408 err = nc_get_vara_float(ncid, i, start, edge, value); +#line 408 if (canConvert) { +#line 408 if (allInExtRange) { +#line 408 if (allInIntRange) { +#line 408 IF (err) +#line 408 error("%s", nc_strerror(err)); +#line 408 } else { +#line 408 IF (err != NC_ERANGE) +#line 408 error("Range error: status = %d", err); +#line 408 } +#line 408 } else { +#line 408 IF (err != 0 && err != NC_ERANGE) +#line 408 error("OK or Range error: status = %d", err); +#line 408 } +#line 408 for (j = 0; j < nels; j++) { +#line 408 if (inRange3(expect[j],var_type[i],NCT_FLOAT) +#line 408 && expect[j] >= float_min && expect[j] <= float_max) { +#line 408 IF (!equal(value[j],expect[j],var_type[i],NCT_FLOAT)){ +#line 408 error("value read not that expected"); +#line 408 if (verbose) { +#line 408 error("\n"); +#line 408 error("varid: %d, ", i); +#line 408 error("var_name: %s, ", var_name[i]); +#line 408 error("element number: %d ", j); +#line 408 error("expect: %g", expect[j]); +#line 408 error("got: %g", (double) value[j]); +#line 408 } +#line 408 } else { +#line 408 nok++; +#line 408 } +#line 408 } +#line 408 } +#line 408 } else { +#line 408 IF (nels > 0 && err != NC_ECHAR) +#line 408 error("wrong type: status = %d", err); +#line 408 } +#line 408 } +#line 408 } +#line 408 err = nc_close(ncid); +#line 408 IF (err) +#line 408 error("nc_close: %s", nc_strerror(err)); +#line 408 print_nok(nok); +#line 408 } +#line 408 void +#line 409 test_nc_get_vara_double(void) +#line 409 { +#line 409 int ncid; +#line 409 int d; +#line 409 int i; +#line 409 int j; +#line 409 int k; +#line 409 int err; +#line 409 int allInExtRange; /* all values within external range? */ +#line 409 int allInIntRange; /* all values within internal range? */ +#line 409 int nels; +#line 409 int nslabs; +#line 409 int nok = 0; /* count of valid comparisons */ +#line 409 size_t start[MAX_RANK]; +#line 409 size_t edge[MAX_RANK]; +#line 409 size_t index[MAX_RANK]; +#line 409 size_t mid[MAX_RANK]; +#line 409 int canConvert; /* Both text or both numeric */ +#line 409 double value[MAX_NELS]; +#line 409 double expect[MAX_NELS]; +#line 409 +#line 409 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 409 IF (err) +#line 409 error("nc_open: %s", nc_strerror(err)); +#line 409 for (i = 0; i < NVARS; i++) { +#line 409 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 409 assert(var_rank[i] <= MAX_RANK); +#line 409 assert(var_nels[i] <= MAX_NELS); +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 start[j] = 0; +#line 409 edge[j] = 1; +#line 409 } +#line 409 err = nc_get_vara_double(BAD_ID, i, start, edge, value); +#line 409 IF (err != NC_EBADID) +#line 409 error("bad ncid: status = %d", err); +#line 409 err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value); +#line 409 IF (err != NC_ENOTVAR) +#line 409 error("bad var id: status = %d", err); +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 start[j] = var_shape[i][j]; +#line 409 err = nc_get_vara_double(ncid, i, start, edge, value); +#line 409 IF (canConvert && err != NC_EINVALCOORDS) +#line 409 error("bad index: status = %d", err); +#line 409 start[j] = 0; +#line 409 edge[j] = var_shape[i][j] + 1; +#line 409 err = nc_get_vara_double(ncid, i, start, edge, value); +#line 409 IF (canConvert && err != NC_EEDGE) +#line 409 error("bad edge: status = %d", err); +#line 409 edge[j] = 1; +#line 409 } +#line 409 /* Check non-scalars for correct error returned even when */ +#line 409 /* there is nothing to get (edge[j]==0) */ +#line 409 if(var_rank[i] > 0) { +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 edge[j] = 0; +#line 409 } +#line 409 err = nc_get_vara_double(BAD_ID, i, start, edge, value); +#line 409 IF (err != NC_EBADID) +#line 409 error("bad ncid: status = %d", err); +#line 409 err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value); +#line 409 IF (err != NC_ENOTVAR) +#line 409 error("bad var id: status = %d", err); +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 409 start[j] = var_shape[i][j]; +#line 409 err = nc_get_vara_double(ncid, i, start, edge, value); +#line 409 IF (canConvert && err != NC_EINVALCOORDS) +#line 409 error("bad start: status = %d", err); +#line 409 start[j] = 0; +#line 409 } +#line 409 } +#line 409 err = nc_get_vara_double(ncid, i, start, edge, value); +#line 409 if (canConvert) { +#line 409 IF (err) +#line 409 error("%s", nc_strerror(err)); +#line 409 } else { +#line 409 IF (err != NC_ECHAR) +#line 409 error("wrong type: status = %d", err); +#line 409 } +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 edge[j] = 1; +#line 409 } +#line 409 } /* Choose a random point dividing each dim into 2 parts */ +#line 409 /* get 2^rank (nslabs) slabs so defined */ +#line 409 nslabs = 1; +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 mid[j] = roll( var_shape[i][j] ); +#line 409 nslabs *= 2; +#line 409 } +#line 409 /* bits of k determine whether to get lower or upper part of dim */ +#line 409 for (k = 0; k < nslabs; k++) { +#line 409 nels = 1; +#line 409 for (j = 0; j < var_rank[i]; j++) { +#line 409 if ((k >> j) & 1) { +#line 409 start[j] = 0; +#line 409 edge[j] = mid[j]; +#line 409 }else{ +#line 409 start[j] = mid[j]; +#line 409 edge[j] = var_shape[i][j] - mid[j]; +#line 409 } +#line 409 nels *= edge[j]; +#line 409 } +#line 409 allInExtRange = allInIntRange = 1; +#line 409 for (j = 0; j < nels; j++) { +#line 409 err = toMixedBase(j, var_rank[i], edge, index); +#line 409 IF (err) +#line 409 error("error in toMixedBase 1"); +#line 409 for (d = 0; d < var_rank[i]; d++) +#line 409 index[d] += start[d]; +#line 409 expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 409 if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) { +#line 409 allInIntRange = allInIntRange && expect[j] >= double_min +#line 409 && expect[j] <= double_max; +#line 409 } else { +#line 409 allInExtRange = 0; +#line 409 } +#line 409 } +#line 409 if (var_rank[i] == 0 && i%2) +#line 409 err = nc_get_vara_double(ncid, i, NULL, NULL, value); +#line 409 else +#line 409 err = nc_get_vara_double(ncid, i, start, edge, value); +#line 409 if (canConvert) { +#line 409 if (allInExtRange) { +#line 409 if (allInIntRange) { +#line 409 IF (err) +#line 409 error("%s", nc_strerror(err)); +#line 409 } else { +#line 409 IF (err != NC_ERANGE) +#line 409 error("Range error: status = %d", err); +#line 409 } +#line 409 } else { +#line 409 IF (err != 0 && err != NC_ERANGE) +#line 409 error("OK or Range error: status = %d", err); +#line 409 } +#line 409 for (j = 0; j < nels; j++) { +#line 409 if (inRange3(expect[j],var_type[i],NCT_DOUBLE) +#line 409 && expect[j] >= double_min && expect[j] <= double_max) { +#line 409 IF (!equal(value[j],expect[j],var_type[i],NCT_DOUBLE)){ +#line 409 error("value read not that expected"); +#line 409 if (verbose) { +#line 409 error("\n"); +#line 409 error("varid: %d, ", i); +#line 409 error("var_name: %s, ", var_name[i]); +#line 409 error("element number: %d ", j); +#line 409 error("expect: %g", expect[j]); +#line 409 error("got: %g", (double) value[j]); +#line 409 } +#line 409 } else { +#line 409 nok++; +#line 409 } +#line 409 } +#line 409 } +#line 409 } else { +#line 409 IF (nels > 0 && err != NC_ECHAR) +#line 409 error("wrong type: status = %d", err); +#line 409 } +#line 409 } +#line 409 } +#line 409 err = nc_close(ncid); +#line 409 IF (err) +#line 409 error("nc_close: %s", nc_strerror(err)); +#line 409 print_nok(nok); +#line 409 } +#line 409 +#line 590 void +#line 591 test_nc_get_vars_text(void) +#line 591 { +#line 591 int ncid; +#line 591 int d; +#line 591 int i; +#line 591 int j; +#line 591 int k; +#line 591 int m; +#line 591 int err; +#line 591 int allInExtRange; /* all values within external range? */ +#line 591 int allInIntRange; /* all values within internal range? */ +#line 591 int nels; +#line 591 int nslabs; +#line 591 int nstarts; /* number of different starts */ +#line 591 int nok = 0; /* count of valid comparisons */ +#line 591 size_t start[MAX_RANK]; +#line 591 size_t edge[MAX_RANK]; +#line 591 size_t index[MAX_RANK]; +#line 591 size_t index2[MAX_RANK]; +#line 591 size_t mid[MAX_RANK]; +#line 591 size_t count[MAX_RANK]; +#line 591 size_t sstride[MAX_RANK]; +#line 591 ptrdiff_t stride[MAX_RANK]; +#line 591 int canConvert; /* Both text or both numeric */ +#line 591 text value[MAX_NELS]; +#line 591 double expect[MAX_NELS]; +#line 591 +#line 591 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 591 IF (err) +#line 591 error("nc_open: %s", nc_strerror(err)); +#line 591 for (i = 0; i < NVARS; i++) { +#line 591 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 591 assert(var_rank[i] <= MAX_RANK); +#line 591 assert(var_nels[i] <= MAX_NELS); +#line 591 for (j = 0; j < var_rank[i]; j++) { +#line 591 start[j] = 0; +#line 591 edge[j] = 1; +#line 591 stride[j] = 1; +#line 591 } +#line 591 err = nc_get_vars_text(BAD_ID, i, start, edge, stride, value); +#line 591 IF (err != NC_EBADID) +#line 591 error("bad ncid: status = %d", err); +#line 591 err = nc_get_vars_text(ncid, BAD_VARID, start, edge, stride, value); +#line 591 IF (err != NC_ENOTVAR) +#line 591 error("bad var id: status = %d", err); +#line 591 for (j = 0; j < var_rank[i]; j++) { +#line 591 start[j] = var_shape[i][j]; +#line 591 err = nc_get_vars_text(ncid, i, start, edge, stride, value); +#line 591 if(!canConvert) { +#line 591 IF (err != NC_ECHAR) +#line 591 error("conversion: status = %d", err); +#line 591 } else { +#line 591 IF (err != NC_EINVALCOORDS) +#line 591 error("bad index: status = %d", err); +#line 591 start[j] = 0; +#line 591 edge[j] = var_shape[i][j] + 1; +#line 591 err = nc_get_vars_text(ncid, i, start, edge, stride, value); +#line 591 IF (err != NC_EEDGE) +#line 591 error("bad edge: status = %d", err); +#line 591 edge[j] = 1; +#line 591 stride[j] = 0; +#line 591 err = nc_get_vars_text(ncid, i, start, edge, stride, value); +#line 591 IF (err != NC_ESTRIDE) +#line 591 error("bad stride: status = %d", err); +#line 591 stride[j] = 1; +#line 591 } +#line 591 } +#line 591 /* Choose a random point dividing each dim into 2 parts */ +#line 591 /* get 2^rank (nslabs) slabs so defined */ +#line 591 nslabs = 1; +#line 591 for (j = 0; j < var_rank[i]; j++) { +#line 591 mid[j] = roll( var_shape[i][j] ); +#line 591 nslabs *= 2; +#line 591 } +#line 591 /* bits of k determine whether to get lower or upper part of dim */ +#line 591 /* choose random stride from 1 to edge */ +#line 591 for (k = 0; k < nslabs; k++) { +#line 591 nstarts = 1; +#line 591 for (j = 0; j < var_rank[i]; j++) { +#line 591 if ((k >> j) & 1) { +#line 591 start[j] = 0; +#line 591 edge[j] = mid[j]; +#line 591 }else{ +#line 591 start[j] = mid[j]; +#line 591 edge[j] = var_shape[i][j] - mid[j]; +#line 591 } +#line 591 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 591 nstarts *= stride[j]; +#line 591 } +#line 591 for (m = 0; m < nstarts; m++) { +#line 591 err = toMixedBase(m, var_rank[i], sstride, index); +#line 591 IF (err) +#line 591 error("error in toMixedBase"); +#line 591 nels = 1; +#line 591 for (j = 0; j < var_rank[i]; j++) { +#line 591 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 591 nels *= count[j]; +#line 591 index[j] += start[j]; +#line 591 } +#line 591 /* Random choice of forward or backward */ +#line 591 /* TODO +#line 591 if ( roll(2) ) { +#line 591 for (j = 0; j < var_rank[i]; j++) { +#line 591 index[j] += (count[j] - 1) * stride[j]; +#line 591 stride[j] = -stride[j]; +#line 591 } +#line 591 } +#line 591 */ +#line 591 allInExtRange = allInIntRange = 1; +#line 591 for (j = 0; j < nels; j++) { +#line 591 err = toMixedBase(j, var_rank[i], count, index2); +#line 591 IF (err) +#line 591 error("error in toMixedBase 1"); +#line 591 for (d = 0; d < var_rank[i]; d++) +#line 591 index2[d] = index[d] + index2[d] * stride[d]; +#line 591 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 591 NCT_TEXT); +#line 591 if (inRange3(expect[j],var_type[i],NCT_TEXT)) { +#line 591 allInIntRange = allInIntRange && expect[j] >= text_min +#line 591 && expect[j] <= text_max; +#line 591 } else { +#line 591 allInExtRange = 0; +#line 591 } +#line 591 } +#line 591 if (var_rank[i] == 0 && i%2 ) +#line 591 err = nc_get_vars_text(ncid, i, NULL, NULL, NULL, value); +#line 591 else +#line 591 err = nc_get_vars_text(ncid, i, index, count, stride, value); +#line 591 if (canConvert) { +#line 591 if (allInExtRange) { +#line 591 if (allInIntRange) { +#line 591 IF (err) +#line 591 error("%s", nc_strerror(err)); +#line 591 } else { +#line 591 IF (err != NC_ERANGE) +#line 591 error("Range error: status = %d", err); +#line 591 } +#line 591 } else { +#line 591 IF (err != 0 && err != NC_ERANGE) +#line 591 error("OK or Range error: status = %d", err); +#line 591 } +#line 591 for (j = 0; j < nels; j++) { +#line 591 if (inRange3(expect[j],var_type[i],NCT_TEXT) +#line 591 && expect[j] >= text_min && expect[j] <= text_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_TEXT)){ +#line 591 + IF (!equal(value[j],expect[j],var_type[i], NCT_TEXT)){ +#line 591 error("value read not that expected"); +#line 591 if (verbose) { +#line 591 error("\n"); +#line 591 error("varid: %d, ", i); +#line 591 error("var_name: %s, ", var_name[i]); +#line 591 error("element number: %d ", j); +#line 591 error("expect: %g, ", expect[j]); +#line 591 error("got: %g", (double) value[j]); +#line 591 } +#line 591 } else { +#line 591 nok++; +#line 591 } +#line 591 } +#line 591 } +#line 591 } else { +#line 591 IF (nels > 0 && err != NC_ECHAR) +#line 591 error("wrong type: status = %d", err); +#line 591 } +#line 591 } +#line 591 } +#line 591 +#line 591 } +#line 591 err = nc_close(ncid); +#line 591 IF (err) +#line 591 error("nc_close: %s", nc_strerror(err)); +#line 591 print_nok(nok); +#line 591 } +#line 591 void +#line 592 test_nc_get_vars_uchar(void) +#line 592 { +#line 592 int ncid; +#line 592 int d; +#line 592 int i; +#line 592 int j; +#line 592 int k; +#line 592 int m; +#line 592 int err; +#line 592 int allInExtRange; /* all values within external range? */ +#line 592 int allInIntRange; /* all values within internal range? */ +#line 592 int nels; +#line 592 int nslabs; +#line 592 int nstarts; /* number of different starts */ +#line 592 int nok = 0; /* count of valid comparisons */ +#line 592 size_t start[MAX_RANK]; +#line 592 size_t edge[MAX_RANK]; +#line 592 size_t index[MAX_RANK]; +#line 592 size_t index2[MAX_RANK]; +#line 592 size_t mid[MAX_RANK]; +#line 592 size_t count[MAX_RANK]; +#line 592 size_t sstride[MAX_RANK]; +#line 592 ptrdiff_t stride[MAX_RANK]; +#line 592 int canConvert; /* Both text or both numeric */ +#line 592 uchar value[MAX_NELS]; +#line 592 double expect[MAX_NELS]; +#line 592 +#line 592 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 592 IF (err) +#line 592 error("nc_open: %s", nc_strerror(err)); +#line 592 for (i = 0; i < NVARS; i++) { +#line 592 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 592 assert(var_rank[i] <= MAX_RANK); +#line 592 assert(var_nels[i] <= MAX_NELS); +#line 592 for (j = 0; j < var_rank[i]; j++) { +#line 592 start[j] = 0; +#line 592 edge[j] = 1; +#line 592 stride[j] = 1; +#line 592 } +#line 592 err = nc_get_vars_uchar(BAD_ID, i, start, edge, stride, value); +#line 592 IF (err != NC_EBADID) +#line 592 error("bad ncid: status = %d", err); +#line 592 err = nc_get_vars_uchar(ncid, BAD_VARID, start, edge, stride, value); +#line 592 IF (err != NC_ENOTVAR) +#line 592 error("bad var id: status = %d", err); +#line 592 for (j = 0; j < var_rank[i]; j++) { +#line 592 start[j] = var_shape[i][j]; +#line 592 err = nc_get_vars_uchar(ncid, i, start, edge, stride, value); +#line 592 if(!canConvert) { +#line 592 IF (err != NC_ECHAR) +#line 592 error("conversion: status = %d", err); +#line 592 } else { +#line 592 IF (err != NC_EINVALCOORDS) +#line 592 error("bad index: status = %d", err); +#line 592 start[j] = 0; +#line 592 edge[j] = var_shape[i][j] + 1; +#line 592 err = nc_get_vars_uchar(ncid, i, start, edge, stride, value); +#line 592 IF (err != NC_EEDGE) +#line 592 error("bad edge: status = %d", err); +#line 592 edge[j] = 1; +#line 592 stride[j] = 0; +#line 592 err = nc_get_vars_uchar(ncid, i, start, edge, stride, value); +#line 592 IF (err != NC_ESTRIDE) +#line 592 error("bad stride: status = %d", err); +#line 592 stride[j] = 1; +#line 592 } +#line 592 } +#line 592 /* Choose a random point dividing each dim into 2 parts */ +#line 592 /* get 2^rank (nslabs) slabs so defined */ +#line 592 nslabs = 1; +#line 592 for (j = 0; j < var_rank[i]; j++) { +#line 592 mid[j] = roll( var_shape[i][j] ); +#line 592 nslabs *= 2; +#line 592 } +#line 592 /* bits of k determine whether to get lower or upper part of dim */ +#line 592 /* choose random stride from 1 to edge */ +#line 592 for (k = 0; k < nslabs; k++) { +#line 592 nstarts = 1; +#line 592 for (j = 0; j < var_rank[i]; j++) { +#line 592 if ((k >> j) & 1) { +#line 592 start[j] = 0; +#line 592 edge[j] = mid[j]; +#line 592 }else{ +#line 592 start[j] = mid[j]; +#line 592 edge[j] = var_shape[i][j] - mid[j]; +#line 592 } +#line 592 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 592 nstarts *= stride[j]; +#line 592 } +#line 592 for (m = 0; m < nstarts; m++) { +#line 592 err = toMixedBase(m, var_rank[i], sstride, index); +#line 592 IF (err) +#line 592 error("error in toMixedBase"); +#line 592 nels = 1; +#line 592 for (j = 0; j < var_rank[i]; j++) { +#line 592 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 592 nels *= count[j]; +#line 592 index[j] += start[j]; +#line 592 } +#line 592 /* Random choice of forward or backward */ +#line 592 /* TODO +#line 592 if ( roll(2) ) { +#line 592 for (j = 0; j < var_rank[i]; j++) { +#line 592 index[j] += (count[j] - 1) * stride[j]; +#line 592 stride[j] = -stride[j]; +#line 592 } +#line 592 } +#line 592 */ +#line 592 allInExtRange = allInIntRange = 1; +#line 592 for (j = 0; j < nels; j++) { +#line 592 err = toMixedBase(j, var_rank[i], count, index2); +#line 592 IF (err) +#line 592 error("error in toMixedBase 1"); +#line 592 for (d = 0; d < var_rank[i]; d++) +#line 592 index2[d] = index[d] + index2[d] * stride[d]; +#line 592 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 592 NCT_UCHAR); +#line 592 if (inRange3(expect[j],var_type[i],NCT_UCHAR)) { +#line 592 allInIntRange = allInIntRange && expect[j] >= uchar_min +#line 592 && expect[j] <= uchar_max; +#line 592 } else { +#line 592 allInExtRange = 0; +#line 592 } +#line 592 } +#line 592 if (var_rank[i] == 0 && i%2 ) +#line 592 err = nc_get_vars_uchar(ncid, i, NULL, NULL, NULL, value); +#line 592 else +#line 592 err = nc_get_vars_uchar(ncid, i, index, count, stride, value); +#line 592 if (canConvert) { +#line 592 if (allInExtRange) { +#line 592 if (allInIntRange) { +#line 592 IF (err) +#line 592 error("%s", nc_strerror(err)); +#line 592 } else { +#line 592 IF (err != NC_ERANGE) +#line 592 error("Range error: status = %d", err); +#line 592 } +#line 592 } else { +#line 592 IF (err != 0 && err != NC_ERANGE) +#line 592 error("OK or Range error: status = %d", err); +#line 592 } +#line 592 for (j = 0; j < nels; j++) { +#line 592 if (inRange3(expect[j],var_type[i],NCT_UCHAR) +#line 592 && expect[j] >= uchar_min && expect[j] <= uchar_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_UCHAR)){ +#line 592 + IF (!equal(value[j],expect[j],var_type[i], NCT_UCHAR)){ +#line 592 error("value read not that expected"); +#line 592 if (verbose) { +#line 592 error("\n"); +#line 592 error("varid: %d, ", i); +#line 592 error("var_name: %s, ", var_name[i]); +#line 592 error("element number: %d ", j); +#line 592 error("expect: %g, ", expect[j]); +#line 592 error("got: %g", (double) value[j]); +#line 592 } +#line 592 } else { +#line 592 nok++; +#line 592 } +#line 592 } +#line 592 } +#line 592 } else { +#line 592 IF (nels > 0 && err != NC_ECHAR) +#line 592 error("wrong type: status = %d", err); +#line 592 } +#line 592 } +#line 592 } +#line 592 +#line 592 } +#line 592 err = nc_close(ncid); +#line 592 IF (err) +#line 592 error("nc_close: %s", nc_strerror(err)); +#line 592 print_nok(nok); +#line 592 } +#line 592 void +#line 593 test_nc_get_vars_schar(void) +#line 593 { +#line 593 int ncid; +#line 593 int d; +#line 593 int i; +#line 593 int j; +#line 593 int k; +#line 593 int m; +#line 593 int err; +#line 593 int allInExtRange; /* all values within external range? */ +#line 593 int allInIntRange; /* all values within internal range? */ +#line 593 int nels; +#line 593 int nslabs; +#line 593 int nstarts; /* number of different starts */ +#line 593 int nok = 0; /* count of valid comparisons */ +#line 593 size_t start[MAX_RANK]; +#line 593 size_t edge[MAX_RANK]; +#line 593 size_t index[MAX_RANK]; +#line 593 size_t index2[MAX_RANK]; +#line 593 size_t mid[MAX_RANK]; +#line 593 size_t count[MAX_RANK]; +#line 593 size_t sstride[MAX_RANK]; +#line 593 ptrdiff_t stride[MAX_RANK]; +#line 593 int canConvert; /* Both text or both numeric */ +#line 593 schar value[MAX_NELS]; +#line 593 double expect[MAX_NELS]; +#line 593 +#line 593 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 593 IF (err) +#line 593 error("nc_open: %s", nc_strerror(err)); +#line 593 for (i = 0; i < NVARS; i++) { +#line 593 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 593 assert(var_rank[i] <= MAX_RANK); +#line 593 assert(var_nels[i] <= MAX_NELS); +#line 593 for (j = 0; j < var_rank[i]; j++) { +#line 593 start[j] = 0; +#line 593 edge[j] = 1; +#line 593 stride[j] = 1; +#line 593 } +#line 593 err = nc_get_vars_schar(BAD_ID, i, start, edge, stride, value); +#line 593 IF (err != NC_EBADID) +#line 593 error("bad ncid: status = %d", err); +#line 593 err = nc_get_vars_schar(ncid, BAD_VARID, start, edge, stride, value); +#line 593 IF (err != NC_ENOTVAR) +#line 593 error("bad var id: status = %d", err); +#line 593 for (j = 0; j < var_rank[i]; j++) { +#line 593 start[j] = var_shape[i][j]; +#line 593 err = nc_get_vars_schar(ncid, i, start, edge, stride, value); +#line 593 if(!canConvert) { +#line 593 IF (err != NC_ECHAR) +#line 593 error("conversion: status = %d", err); +#line 593 } else { +#line 593 IF (err != NC_EINVALCOORDS) +#line 593 error("bad index: status = %d", err); +#line 593 start[j] = 0; +#line 593 edge[j] = var_shape[i][j] + 1; +#line 593 err = nc_get_vars_schar(ncid, i, start, edge, stride, value); +#line 593 IF (err != NC_EEDGE) +#line 593 error("bad edge: status = %d", err); +#line 593 edge[j] = 1; +#line 593 stride[j] = 0; +#line 593 err = nc_get_vars_schar(ncid, i, start, edge, stride, value); +#line 593 IF (err != NC_ESTRIDE) +#line 593 error("bad stride: status = %d", err); +#line 593 stride[j] = 1; +#line 593 } +#line 593 } +#line 593 /* Choose a random point dividing each dim into 2 parts */ +#line 593 /* get 2^rank (nslabs) slabs so defined */ +#line 593 nslabs = 1; +#line 593 for (j = 0; j < var_rank[i]; j++) { +#line 593 mid[j] = roll( var_shape[i][j] ); +#line 593 nslabs *= 2; +#line 593 } +#line 593 /* bits of k determine whether to get lower or upper part of dim */ +#line 593 /* choose random stride from 1 to edge */ +#line 593 for (k = 0; k < nslabs; k++) { +#line 593 nstarts = 1; +#line 593 for (j = 0; j < var_rank[i]; j++) { +#line 593 if ((k >> j) & 1) { +#line 593 start[j] = 0; +#line 593 edge[j] = mid[j]; +#line 593 }else{ +#line 593 start[j] = mid[j]; +#line 593 edge[j] = var_shape[i][j] - mid[j]; +#line 593 } +#line 593 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 593 nstarts *= stride[j]; +#line 593 } +#line 593 for (m = 0; m < nstarts; m++) { +#line 593 err = toMixedBase(m, var_rank[i], sstride, index); +#line 593 IF (err) +#line 593 error("error in toMixedBase"); +#line 593 nels = 1; +#line 593 for (j = 0; j < var_rank[i]; j++) { +#line 593 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 593 nels *= count[j]; +#line 593 index[j] += start[j]; +#line 593 } +#line 593 /* Random choice of forward or backward */ +#line 593 /* TODO +#line 593 if ( roll(2) ) { +#line 593 for (j = 0; j < var_rank[i]; j++) { +#line 593 index[j] += (count[j] - 1) * stride[j]; +#line 593 stride[j] = -stride[j]; +#line 593 } +#line 593 } +#line 593 */ +#line 593 allInExtRange = allInIntRange = 1; +#line 593 for (j = 0; j < nels; j++) { +#line 593 err = toMixedBase(j, var_rank[i], count, index2); +#line 593 IF (err) +#line 593 error("error in toMixedBase 1"); +#line 593 for (d = 0; d < var_rank[i]; d++) +#line 593 index2[d] = index[d] + index2[d] * stride[d]; +#line 593 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 593 NCT_SCHAR); +#line 593 if (inRange3(expect[j],var_type[i],NCT_SCHAR)) { +#line 593 allInIntRange = allInIntRange && expect[j] >= schar_min +#line 593 && expect[j] <= schar_max; +#line 593 } else { +#line 593 allInExtRange = 0; +#line 593 } +#line 593 } +#line 593 if (var_rank[i] == 0 && i%2 ) +#line 593 err = nc_get_vars_schar(ncid, i, NULL, NULL, NULL, value); +#line 593 else +#line 593 err = nc_get_vars_schar(ncid, i, index, count, stride, value); +#line 593 if (canConvert) { +#line 593 if (allInExtRange) { +#line 593 if (allInIntRange) { +#line 593 IF (err) +#line 593 error("%s", nc_strerror(err)); +#line 593 } else { +#line 593 IF (err != NC_ERANGE) +#line 593 error("Range error: status = %d", err); +#line 593 } +#line 593 } else { +#line 593 IF (err != 0 && err != NC_ERANGE) +#line 593 error("OK or Range error: status = %d", err); +#line 593 } +#line 593 for (j = 0; j < nels; j++) { +#line 593 if (inRange3(expect[j],var_type[i],NCT_SCHAR) +#line 593 && expect[j] >= schar_min && expect[j] <= schar_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_SCHAR)){ +#line 593 + IF (!equal(value[j],expect[j],var_type[i], NCT_SCHAR)){ +#line 593 error("value read not that expected"); +#line 593 if (verbose) { +#line 593 error("\n"); +#line 593 error("varid: %d, ", i); +#line 593 error("var_name: %s, ", var_name[i]); +#line 593 error("element number: %d ", j); +#line 593 error("expect: %g, ", expect[j]); +#line 593 error("got: %g", (double) value[j]); +#line 593 } +#line 593 } else { +#line 593 nok++; +#line 593 } +#line 593 } +#line 593 } +#line 593 } else { +#line 593 IF (nels > 0 && err != NC_ECHAR) +#line 593 error("wrong type: status = %d", err); +#line 593 } +#line 593 } +#line 593 } +#line 593 +#line 593 } +#line 593 err = nc_close(ncid); +#line 593 IF (err) +#line 593 error("nc_close: %s", nc_strerror(err)); +#line 593 print_nok(nok); +#line 593 } +#line 593 void +#line 594 test_nc_get_vars_short(void) +#line 594 { +#line 594 int ncid; +#line 594 int d; +#line 594 int i; +#line 594 int j; +#line 594 int k; +#line 594 int m; +#line 594 int err; +#line 594 int allInExtRange; /* all values within external range? */ +#line 594 int allInIntRange; /* all values within internal range? */ +#line 594 int nels; +#line 594 int nslabs; +#line 594 int nstarts; /* number of different starts */ +#line 594 int nok = 0; /* count of valid comparisons */ +#line 594 size_t start[MAX_RANK]; +#line 594 size_t edge[MAX_RANK]; +#line 594 size_t index[MAX_RANK]; +#line 594 size_t index2[MAX_RANK]; +#line 594 size_t mid[MAX_RANK]; +#line 594 size_t count[MAX_RANK]; +#line 594 size_t sstride[MAX_RANK]; +#line 594 ptrdiff_t stride[MAX_RANK]; +#line 594 int canConvert; /* Both text or both numeric */ +#line 594 short value[MAX_NELS]; +#line 594 double expect[MAX_NELS]; +#line 594 +#line 594 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 594 IF (err) +#line 594 error("nc_open: %s", nc_strerror(err)); +#line 594 for (i = 0; i < NVARS; i++) { +#line 594 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 594 assert(var_rank[i] <= MAX_RANK); +#line 594 assert(var_nels[i] <= MAX_NELS); +#line 594 for (j = 0; j < var_rank[i]; j++) { +#line 594 start[j] = 0; +#line 594 edge[j] = 1; +#line 594 stride[j] = 1; +#line 594 } +#line 594 err = nc_get_vars_short(BAD_ID, i, start, edge, stride, value); +#line 594 IF (err != NC_EBADID) +#line 594 error("bad ncid: status = %d", err); +#line 594 err = nc_get_vars_short(ncid, BAD_VARID, start, edge, stride, value); +#line 594 IF (err != NC_ENOTVAR) +#line 594 error("bad var id: status = %d", err); +#line 594 for (j = 0; j < var_rank[i]; j++) { +#line 594 start[j] = var_shape[i][j]; +#line 594 err = nc_get_vars_short(ncid, i, start, edge, stride, value); +#line 594 if(!canConvert) { +#line 594 IF (err != NC_ECHAR) +#line 594 error("conversion: status = %d", err); +#line 594 } else { +#line 594 IF (err != NC_EINVALCOORDS) +#line 594 error("bad index: status = %d", err); +#line 594 start[j] = 0; +#line 594 edge[j] = var_shape[i][j] + 1; +#line 594 err = nc_get_vars_short(ncid, i, start, edge, stride, value); +#line 594 IF (err != NC_EEDGE) +#line 594 error("bad edge: status = %d", err); +#line 594 edge[j] = 1; +#line 594 stride[j] = 0; +#line 594 err = nc_get_vars_short(ncid, i, start, edge, stride, value); +#line 594 IF (err != NC_ESTRIDE) +#line 594 error("bad stride: status = %d", err); +#line 594 stride[j] = 1; +#line 594 } +#line 594 } +#line 594 /* Choose a random point dividing each dim into 2 parts */ +#line 594 /* get 2^rank (nslabs) slabs so defined */ +#line 594 nslabs = 1; +#line 594 for (j = 0; j < var_rank[i]; j++) { +#line 594 mid[j] = roll( var_shape[i][j] ); +#line 594 nslabs *= 2; +#line 594 } +#line 594 /* bits of k determine whether to get lower or upper part of dim */ +#line 594 /* choose random stride from 1 to edge */ +#line 594 for (k = 0; k < nslabs; k++) { +#line 594 nstarts = 1; +#line 594 for (j = 0; j < var_rank[i]; j++) { +#line 594 if ((k >> j) & 1) { +#line 594 start[j] = 0; +#line 594 edge[j] = mid[j]; +#line 594 }else{ +#line 594 start[j] = mid[j]; +#line 594 edge[j] = var_shape[i][j] - mid[j]; +#line 594 } +#line 594 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 594 nstarts *= stride[j]; +#line 594 } +#line 594 for (m = 0; m < nstarts; m++) { +#line 594 err = toMixedBase(m, var_rank[i], sstride, index); +#line 594 IF (err) +#line 594 error("error in toMixedBase"); +#line 594 nels = 1; +#line 594 for (j = 0; j < var_rank[i]; j++) { +#line 594 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 594 nels *= count[j]; +#line 594 index[j] += start[j]; +#line 594 } +#line 594 /* Random choice of forward or backward */ +#line 594 /* TODO +#line 594 if ( roll(2) ) { +#line 594 for (j = 0; j < var_rank[i]; j++) { +#line 594 index[j] += (count[j] - 1) * stride[j]; +#line 594 stride[j] = -stride[j]; +#line 594 } +#line 594 } +#line 594 */ +#line 594 allInExtRange = allInIntRange = 1; +#line 594 for (j = 0; j < nels; j++) { +#line 594 err = toMixedBase(j, var_rank[i], count, index2); +#line 594 IF (err) +#line 594 error("error in toMixedBase 1"); +#line 594 for (d = 0; d < var_rank[i]; d++) +#line 594 index2[d] = index[d] + index2[d] * stride[d]; +#line 594 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 594 NCT_SHORT); +#line 594 if (inRange3(expect[j],var_type[i],NCT_SHORT)) { +#line 594 allInIntRange = allInIntRange && expect[j] >= short_min +#line 594 && expect[j] <= short_max; +#line 594 } else { +#line 594 allInExtRange = 0; +#line 594 } +#line 594 } +#line 594 if (var_rank[i] == 0 && i%2 ) +#line 594 err = nc_get_vars_short(ncid, i, NULL, NULL, NULL, value); +#line 594 else +#line 594 err = nc_get_vars_short(ncid, i, index, count, stride, value); +#line 594 if (canConvert) { +#line 594 if (allInExtRange) { +#line 594 if (allInIntRange) { +#line 594 IF (err) +#line 594 error("%s", nc_strerror(err)); +#line 594 } else { +#line 594 IF (err != NC_ERANGE) +#line 594 error("Range error: status = %d", err); +#line 594 } +#line 594 } else { +#line 594 IF (err != 0 && err != NC_ERANGE) +#line 594 error("OK or Range error: status = %d", err); +#line 594 } +#line 594 for (j = 0; j < nels; j++) { +#line 594 if (inRange3(expect[j],var_type[i],NCT_SHORT) +#line 594 && expect[j] >= short_min && expect[j] <= short_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_SHORT)){ +#line 594 + IF (!equal(value[j],expect[j],var_type[i], NCT_SHORT)){ +#line 594 error("value read not that expected"); +#line 594 if (verbose) { +#line 594 error("\n"); +#line 594 error("varid: %d, ", i); +#line 594 error("var_name: %s, ", var_name[i]); +#line 594 error("element number: %d ", j); +#line 594 error("expect: %g, ", expect[j]); +#line 594 error("got: %g", (double) value[j]); +#line 594 } +#line 594 } else { +#line 594 nok++; +#line 594 } +#line 594 } +#line 594 } +#line 594 } else { +#line 594 IF (nels > 0 && err != NC_ECHAR) +#line 594 error("wrong type: status = %d", err); +#line 594 } +#line 594 } +#line 594 } +#line 594 +#line 594 } +#line 594 err = nc_close(ncid); +#line 594 IF (err) +#line 594 error("nc_close: %s", nc_strerror(err)); +#line 594 print_nok(nok); +#line 594 } +#line 594 void +#line 595 test_nc_get_vars_int(void) +#line 595 { +#line 595 int ncid; +#line 595 int d; +#line 595 int i; +#line 595 int j; +#line 595 int k; +#line 595 int m; +#line 595 int err; +#line 595 int allInExtRange; /* all values within external range? */ +#line 595 int allInIntRange; /* all values within internal range? */ +#line 595 int nels; +#line 595 int nslabs; +#line 595 int nstarts; /* number of different starts */ +#line 595 int nok = 0; /* count of valid comparisons */ +#line 595 size_t start[MAX_RANK]; +#line 595 size_t edge[MAX_RANK]; +#line 595 size_t index[MAX_RANK]; +#line 595 size_t index2[MAX_RANK]; +#line 595 size_t mid[MAX_RANK]; +#line 595 size_t count[MAX_RANK]; +#line 595 size_t sstride[MAX_RANK]; +#line 595 ptrdiff_t stride[MAX_RANK]; +#line 595 int canConvert; /* Both text or both numeric */ +#line 595 int value[MAX_NELS]; +#line 595 double expect[MAX_NELS]; +#line 595 +#line 595 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 595 IF (err) +#line 595 error("nc_open: %s", nc_strerror(err)); +#line 595 for (i = 0; i < NVARS; i++) { +#line 595 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 595 assert(var_rank[i] <= MAX_RANK); +#line 595 assert(var_nels[i] <= MAX_NELS); +#line 595 for (j = 0; j < var_rank[i]; j++) { +#line 595 start[j] = 0; +#line 595 edge[j] = 1; +#line 595 stride[j] = 1; +#line 595 } +#line 595 err = nc_get_vars_int(BAD_ID, i, start, edge, stride, value); +#line 595 IF (err != NC_EBADID) +#line 595 error("bad ncid: status = %d", err); +#line 595 err = nc_get_vars_int(ncid, BAD_VARID, start, edge, stride, value); +#line 595 IF (err != NC_ENOTVAR) +#line 595 error("bad var id: status = %d", err); +#line 595 for (j = 0; j < var_rank[i]; j++) { +#line 595 start[j] = var_shape[i][j]; +#line 595 err = nc_get_vars_int(ncid, i, start, edge, stride, value); +#line 595 if(!canConvert) { +#line 595 IF (err != NC_ECHAR) +#line 595 error("conversion: status = %d", err); +#line 595 } else { +#line 595 IF (err != NC_EINVALCOORDS) +#line 595 error("bad index: status = %d", err); +#line 595 start[j] = 0; +#line 595 edge[j] = var_shape[i][j] + 1; +#line 595 err = nc_get_vars_int(ncid, i, start, edge, stride, value); +#line 595 IF (err != NC_EEDGE) +#line 595 error("bad edge: status = %d", err); +#line 595 edge[j] = 1; +#line 595 stride[j] = 0; +#line 595 err = nc_get_vars_int(ncid, i, start, edge, stride, value); +#line 595 IF (err != NC_ESTRIDE) +#line 595 error("bad stride: status = %d", err); +#line 595 stride[j] = 1; +#line 595 } +#line 595 } +#line 595 /* Choose a random point dividing each dim into 2 parts */ +#line 595 /* get 2^rank (nslabs) slabs so defined */ +#line 595 nslabs = 1; +#line 595 for (j = 0; j < var_rank[i]; j++) { +#line 595 mid[j] = roll( var_shape[i][j] ); +#line 595 nslabs *= 2; +#line 595 } +#line 595 /* bits of k determine whether to get lower or upper part of dim */ +#line 595 /* choose random stride from 1 to edge */ +#line 595 for (k = 0; k < nslabs; k++) { +#line 595 nstarts = 1; +#line 595 for (j = 0; j < var_rank[i]; j++) { +#line 595 if ((k >> j) & 1) { +#line 595 start[j] = 0; +#line 595 edge[j] = mid[j]; +#line 595 }else{ +#line 595 start[j] = mid[j]; +#line 595 edge[j] = var_shape[i][j] - mid[j]; +#line 595 } +#line 595 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 595 nstarts *= stride[j]; +#line 595 } +#line 595 for (m = 0; m < nstarts; m++) { +#line 595 err = toMixedBase(m, var_rank[i], sstride, index); +#line 595 IF (err) +#line 595 error("error in toMixedBase"); +#line 595 nels = 1; +#line 595 for (j = 0; j < var_rank[i]; j++) { +#line 595 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 595 nels *= count[j]; +#line 595 index[j] += start[j]; +#line 595 } +#line 595 /* Random choice of forward or backward */ +#line 595 /* TODO +#line 595 if ( roll(2) ) { +#line 595 for (j = 0; j < var_rank[i]; j++) { +#line 595 index[j] += (count[j] - 1) * stride[j]; +#line 595 stride[j] = -stride[j]; +#line 595 } +#line 595 } +#line 595 */ +#line 595 allInExtRange = allInIntRange = 1; +#line 595 for (j = 0; j < nels; j++) { +#line 595 err = toMixedBase(j, var_rank[i], count, index2); +#line 595 IF (err) +#line 595 error("error in toMixedBase 1"); +#line 595 for (d = 0; d < var_rank[i]; d++) +#line 595 index2[d] = index[d] + index2[d] * stride[d]; +#line 595 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 595 NCT_INT); +#line 595 if (inRange3(expect[j],var_type[i],NCT_INT)) { +#line 595 allInIntRange = allInIntRange && expect[j] >= int_min +#line 595 && expect[j] <= int_max; +#line 595 } else { +#line 595 allInExtRange = 0; +#line 595 } +#line 595 } +#line 595 if (var_rank[i] == 0 && i%2 ) +#line 595 err = nc_get_vars_int(ncid, i, NULL, NULL, NULL, value); +#line 595 else +#line 595 err = nc_get_vars_int(ncid, i, index, count, stride, value); +#line 595 if (canConvert) { +#line 595 if (allInExtRange) { +#line 595 if (allInIntRange) { +#line 595 IF (err) +#line 595 error("%s", nc_strerror(err)); +#line 595 } else { +#line 595 IF (err != NC_ERANGE) +#line 595 error("Range error: status = %d", err); +#line 595 } +#line 595 } else { +#line 595 IF (err != 0 && err != NC_ERANGE) +#line 595 error("OK or Range error: status = %d", err); +#line 595 } +#line 595 for (j = 0; j < nels; j++) { +#line 595 if (inRange3(expect[j],var_type[i],NCT_INT) +#line 595 && expect[j] >= int_min && expect[j] <= int_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_INT)){ +#line 595 + IF (!equal(value[j],expect[j],var_type[i], NCT_INT)){ +#line 595 error("value read not that expected"); +#line 595 if (verbose) { +#line 595 error("\n"); +#line 595 error("varid: %d, ", i); +#line 595 error("var_name: %s, ", var_name[i]); +#line 595 error("element number: %d ", j); +#line 595 error("expect: %g, ", expect[j]); +#line 595 error("got: %g", (double) value[j]); +#line 595 } +#line 595 } else { +#line 595 nok++; +#line 595 } +#line 595 } +#line 595 } +#line 595 } else { +#line 595 IF (nels > 0 && err != NC_ECHAR) +#line 595 error("wrong type: status = %d", err); +#line 595 } +#line 595 } +#line 595 } +#line 595 +#line 595 } +#line 595 err = nc_close(ncid); +#line 595 IF (err) +#line 595 error("nc_close: %s", nc_strerror(err)); +#line 595 print_nok(nok); +#line 595 } +#line 595 void +#line 596 test_nc_get_vars_long(void) +#line 596 { +#line 596 int ncid; +#line 596 int d; +#line 596 int i; +#line 596 int j; +#line 596 int k; +#line 596 int m; +#line 596 int err; +#line 596 int allInExtRange; /* all values within external range? */ +#line 596 int allInIntRange; /* all values within internal range? */ +#line 596 int nels; +#line 596 int nslabs; +#line 596 int nstarts; /* number of different starts */ +#line 596 int nok = 0; /* count of valid comparisons */ +#line 596 size_t start[MAX_RANK]; +#line 596 size_t edge[MAX_RANK]; +#line 596 size_t index[MAX_RANK]; +#line 596 size_t index2[MAX_RANK]; +#line 596 size_t mid[MAX_RANK]; +#line 596 size_t count[MAX_RANK]; +#line 596 size_t sstride[MAX_RANK]; +#line 596 ptrdiff_t stride[MAX_RANK]; +#line 596 int canConvert; /* Both text or both numeric */ +#line 596 long value[MAX_NELS]; +#line 596 double expect[MAX_NELS]; +#line 596 +#line 596 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 596 IF (err) +#line 596 error("nc_open: %s", nc_strerror(err)); +#line 596 for (i = 0; i < NVARS; i++) { +#line 596 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 596 assert(var_rank[i] <= MAX_RANK); +#line 596 assert(var_nels[i] <= MAX_NELS); +#line 596 for (j = 0; j < var_rank[i]; j++) { +#line 596 start[j] = 0; +#line 596 edge[j] = 1; +#line 596 stride[j] = 1; +#line 596 } +#line 596 err = nc_get_vars_long(BAD_ID, i, start, edge, stride, value); +#line 596 IF (err != NC_EBADID) +#line 596 error("bad ncid: status = %d", err); +#line 596 err = nc_get_vars_long(ncid, BAD_VARID, start, edge, stride, value); +#line 596 IF (err != NC_ENOTVAR) +#line 596 error("bad var id: status = %d", err); +#line 596 for (j = 0; j < var_rank[i]; j++) { +#line 596 start[j] = var_shape[i][j]; +#line 596 err = nc_get_vars_long(ncid, i, start, edge, stride, value); +#line 596 if(!canConvert) { +#line 596 IF (err != NC_ECHAR) +#line 596 error("conversion: status = %d", err); +#line 596 } else { +#line 596 IF (err != NC_EINVALCOORDS) +#line 596 error("bad index: status = %d", err); +#line 596 start[j] = 0; +#line 596 edge[j] = var_shape[i][j] + 1; +#line 596 err = nc_get_vars_long(ncid, i, start, edge, stride, value); +#line 596 IF (err != NC_EEDGE) +#line 596 error("bad edge: status = %d", err); +#line 596 edge[j] = 1; +#line 596 stride[j] = 0; +#line 596 err = nc_get_vars_long(ncid, i, start, edge, stride, value); +#line 596 IF (err != NC_ESTRIDE) +#line 596 error("bad stride: status = %d", err); +#line 596 stride[j] = 1; +#line 596 } +#line 596 } +#line 596 /* Choose a random point dividing each dim into 2 parts */ +#line 596 /* get 2^rank (nslabs) slabs so defined */ +#line 596 nslabs = 1; +#line 596 for (j = 0; j < var_rank[i]; j++) { +#line 596 mid[j] = roll( var_shape[i][j] ); +#line 596 nslabs *= 2; +#line 596 } +#line 596 /* bits of k determine whether to get lower or upper part of dim */ +#line 596 /* choose random stride from 1 to edge */ +#line 596 for (k = 0; k < nslabs; k++) { +#line 596 nstarts = 1; +#line 596 for (j = 0; j < var_rank[i]; j++) { +#line 596 if ((k >> j) & 1) { +#line 596 start[j] = 0; +#line 596 edge[j] = mid[j]; +#line 596 }else{ +#line 596 start[j] = mid[j]; +#line 596 edge[j] = var_shape[i][j] - mid[j]; +#line 596 } +#line 596 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 596 nstarts *= stride[j]; +#line 596 } +#line 596 for (m = 0; m < nstarts; m++) { +#line 596 err = toMixedBase(m, var_rank[i], sstride, index); +#line 596 IF (err) +#line 596 error("error in toMixedBase"); +#line 596 nels = 1; +#line 596 for (j = 0; j < var_rank[i]; j++) { +#line 596 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 596 nels *= count[j]; +#line 596 index[j] += start[j]; +#line 596 } +#line 596 /* Random choice of forward or backward */ +#line 596 /* TODO +#line 596 if ( roll(2) ) { +#line 596 for (j = 0; j < var_rank[i]; j++) { +#line 596 index[j] += (count[j] - 1) * stride[j]; +#line 596 stride[j] = -stride[j]; +#line 596 } +#line 596 } +#line 596 */ +#line 596 allInExtRange = allInIntRange = 1; +#line 596 for (j = 0; j < nels; j++) { +#line 596 err = toMixedBase(j, var_rank[i], count, index2); +#line 596 IF (err) +#line 596 error("error in toMixedBase 1"); +#line 596 for (d = 0; d < var_rank[i]; d++) +#line 596 index2[d] = index[d] + index2[d] * stride[d]; +#line 596 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 596 NCT_LONG); +#line 596 if (inRange3(expect[j],var_type[i],NCT_LONG)) { +#line 596 allInIntRange = allInIntRange && expect[j] >= long_min +#line 596 && expect[j] <= long_max; +#line 596 } else { +#line 596 allInExtRange = 0; +#line 596 } +#line 596 } +#line 596 if (var_rank[i] == 0 && i%2 ) +#line 596 err = nc_get_vars_long(ncid, i, NULL, NULL, NULL, value); +#line 596 else +#line 596 err = nc_get_vars_long(ncid, i, index, count, stride, value); +#line 596 if (canConvert) { +#line 596 if (allInExtRange) { +#line 596 if (allInIntRange) { +#line 596 IF (err) +#line 596 error("%s", nc_strerror(err)); +#line 596 } else { +#line 596 IF (err != NC_ERANGE) +#line 596 error("Range error: status = %d", err); +#line 596 } +#line 596 } else { +#line 596 IF (err != 0 && err != NC_ERANGE) +#line 596 error("OK or Range error: status = %d", err); +#line 596 } +#line 596 for (j = 0; j < nels; j++) { +#line 596 if (inRange3(expect[j],var_type[i],NCT_LONG) +#line 596 && expect[j] >= long_min && expect[j] <= long_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_LONG)){ +#line 596 + IF (!equal(value[j],expect[j],var_type[i], NCT_LONG)){ +#line 596 error("value read not that expected"); +#line 596 if (verbose) { +#line 596 error("\n"); +#line 596 error("varid: %d, ", i); +#line 596 error("var_name: %s, ", var_name[i]); +#line 596 error("element number: %d ", j); +#line 596 error("expect: %g, ", expect[j]); +#line 596 error("got: %g", (double) value[j]); +#line 596 } +#line 596 } else { +#line 596 nok++; +#line 596 } +#line 596 } +#line 596 } +#line 596 } else { +#line 596 IF (nels > 0 && err != NC_ECHAR) +#line 596 error("wrong type: status = %d", err); +#line 596 } +#line 596 } +#line 596 } +#line 596 +#line 596 } +#line 596 err = nc_close(ncid); +#line 596 IF (err) +#line 596 error("nc_close: %s", nc_strerror(err)); +#line 596 print_nok(nok); +#line 596 } +#line 596 void +#line 597 test_nc_get_vars_float(void) +#line 597 { +#line 597 int ncid; +#line 597 int d; +#line 597 int i; +#line 597 int j; +#line 597 int k; +#line 597 int m; +#line 597 int err; +#line 597 int allInExtRange; /* all values within external range? */ +#line 597 int allInIntRange; /* all values within internal range? */ +#line 597 int nels; +#line 597 int nslabs; +#line 597 int nstarts; /* number of different starts */ +#line 597 int nok = 0; /* count of valid comparisons */ +#line 597 size_t start[MAX_RANK]; +#line 597 size_t edge[MAX_RANK]; +#line 597 size_t index[MAX_RANK]; +#line 597 size_t index2[MAX_RANK]; +#line 597 size_t mid[MAX_RANK]; +#line 597 size_t count[MAX_RANK]; +#line 597 size_t sstride[MAX_RANK]; +#line 597 ptrdiff_t stride[MAX_RANK]; +#line 597 int canConvert; /* Both text or both numeric */ +#line 597 float value[MAX_NELS]; +#line 597 double expect[MAX_NELS]; +#line 597 +#line 597 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 597 IF (err) +#line 597 error("nc_open: %s", nc_strerror(err)); +#line 597 for (i = 0; i < NVARS; i++) { +#line 597 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 597 assert(var_rank[i] <= MAX_RANK); +#line 597 assert(var_nels[i] <= MAX_NELS); +#line 597 for (j = 0; j < var_rank[i]; j++) { +#line 597 start[j] = 0; +#line 597 edge[j] = 1; +#line 597 stride[j] = 1; +#line 597 } +#line 597 err = nc_get_vars_float(BAD_ID, i, start, edge, stride, value); +#line 597 IF (err != NC_EBADID) +#line 597 error("bad ncid: status = %d", err); +#line 597 err = nc_get_vars_float(ncid, BAD_VARID, start, edge, stride, value); +#line 597 IF (err != NC_ENOTVAR) +#line 597 error("bad var id: status = %d", err); +#line 597 for (j = 0; j < var_rank[i]; j++) { +#line 597 start[j] = var_shape[i][j]; +#line 597 err = nc_get_vars_float(ncid, i, start, edge, stride, value); +#line 597 if(!canConvert) { +#line 597 IF (err != NC_ECHAR) +#line 597 error("conversion: status = %d", err); +#line 597 } else { +#line 597 IF (err != NC_EINVALCOORDS) +#line 597 error("bad index: status = %d", err); +#line 597 start[j] = 0; +#line 597 edge[j] = var_shape[i][j] + 1; +#line 597 err = nc_get_vars_float(ncid, i, start, edge, stride, value); +#line 597 IF (err != NC_EEDGE) +#line 597 error("bad edge: status = %d", err); +#line 597 edge[j] = 1; +#line 597 stride[j] = 0; +#line 597 err = nc_get_vars_float(ncid, i, start, edge, stride, value); +#line 597 IF (err != NC_ESTRIDE) +#line 597 error("bad stride: status = %d", err); +#line 597 stride[j] = 1; +#line 597 } +#line 597 } +#line 597 /* Choose a random point dividing each dim into 2 parts */ +#line 597 /* get 2^rank (nslabs) slabs so defined */ +#line 597 nslabs = 1; +#line 597 for (j = 0; j < var_rank[i]; j++) { +#line 597 mid[j] = roll( var_shape[i][j] ); +#line 597 nslabs *= 2; +#line 597 } +#line 597 /* bits of k determine whether to get lower or upper part of dim */ +#line 597 /* choose random stride from 1 to edge */ +#line 597 for (k = 0; k < nslabs; k++) { +#line 597 nstarts = 1; +#line 597 for (j = 0; j < var_rank[i]; j++) { +#line 597 if ((k >> j) & 1) { +#line 597 start[j] = 0; +#line 597 edge[j] = mid[j]; +#line 597 }else{ +#line 597 start[j] = mid[j]; +#line 597 edge[j] = var_shape[i][j] - mid[j]; +#line 597 } +#line 597 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 597 nstarts *= stride[j]; +#line 597 } +#line 597 for (m = 0; m < nstarts; m++) { +#line 597 err = toMixedBase(m, var_rank[i], sstride, index); +#line 597 IF (err) +#line 597 error("error in toMixedBase"); +#line 597 nels = 1; +#line 597 for (j = 0; j < var_rank[i]; j++) { +#line 597 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 597 nels *= count[j]; +#line 597 index[j] += start[j]; +#line 597 } +#line 597 /* Random choice of forward or backward */ +#line 597 /* TODO +#line 597 if ( roll(2) ) { +#line 597 for (j = 0; j < var_rank[i]; j++) { +#line 597 index[j] += (count[j] - 1) * stride[j]; +#line 597 stride[j] = -stride[j]; +#line 597 } +#line 597 } +#line 597 */ +#line 597 allInExtRange = allInIntRange = 1; +#line 597 for (j = 0; j < nels; j++) { +#line 597 err = toMixedBase(j, var_rank[i], count, index2); +#line 597 IF (err) +#line 597 error("error in toMixedBase 1"); +#line 597 for (d = 0; d < var_rank[i]; d++) +#line 597 index2[d] = index[d] + index2[d] * stride[d]; +#line 597 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 597 NCT_FLOAT); +#line 597 if (inRange3(expect[j],var_type[i],NCT_FLOAT)) { +#line 597 allInIntRange = allInIntRange && expect[j] >= float_min +#line 597 && expect[j] <= float_max; +#line 597 } else { +#line 597 allInExtRange = 0; +#line 597 } +#line 597 } +#line 597 if (var_rank[i] == 0 && i%2 ) +#line 597 err = nc_get_vars_float(ncid, i, NULL, NULL, NULL, value); +#line 597 else +#line 597 err = nc_get_vars_float(ncid, i, index, count, stride, value); +#line 597 if (canConvert) { +#line 597 if (allInExtRange) { +#line 597 if (allInIntRange) { +#line 597 IF (err) +#line 597 error("%s", nc_strerror(err)); +#line 597 } else { +#line 597 IF (err != NC_ERANGE) +#line 597 error("Range error: status = %d", err); +#line 597 } +#line 597 } else { +#line 597 IF (err != 0 && err != NC_ERANGE) +#line 597 error("OK or Range error: status = %d", err); +#line 597 } +#line 597 for (j = 0; j < nels; j++) { +#line 597 if (inRange3(expect[j],var_type[i],NCT_FLOAT) +#line 597 && expect[j] >= float_min && expect[j] <= float_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_FLOAT)){ +#line 597 + IF (!equal(value[j],expect[j],var_type[i], NCT_FLOAT)){ +#line 597 error("value read not that expected"); +#line 597 if (verbose) { +#line 597 error("\n"); +#line 597 error("varid: %d, ", i); +#line 597 error("var_name: %s, ", var_name[i]); +#line 597 error("element number: %d ", j); +#line 597 error("expect: %g, ", expect[j]); +#line 597 error("got: %g", (double) value[j]); +#line 597 } +#line 597 } else { +#line 597 nok++; +#line 597 } +#line 597 } +#line 597 } +#line 597 } else { +#line 597 IF (nels > 0 && err != NC_ECHAR) +#line 597 error("wrong type: status = %d", err); +#line 597 } +#line 597 } +#line 597 } +#line 597 +#line 597 } +#line 597 err = nc_close(ncid); +#line 597 IF (err) +#line 597 error("nc_close: %s", nc_strerror(err)); +#line 597 print_nok(nok); +#line 597 } +#line 597 void +#line 598 test_nc_get_vars_double(void) +#line 598 { +#line 598 int ncid; +#line 598 int d; +#line 598 int i; +#line 598 int j; +#line 598 int k; +#line 598 int m; +#line 598 int err; +#line 598 int allInExtRange; /* all values within external range? */ +#line 598 int allInIntRange; /* all values within internal range? */ +#line 598 int nels; +#line 598 int nslabs; +#line 598 int nstarts; /* number of different starts */ +#line 598 int nok = 0; /* count of valid comparisons */ +#line 598 size_t start[MAX_RANK]; +#line 598 size_t edge[MAX_RANK]; +#line 598 size_t index[MAX_RANK]; +#line 598 size_t index2[MAX_RANK]; +#line 598 size_t mid[MAX_RANK]; +#line 598 size_t count[MAX_RANK]; +#line 598 size_t sstride[MAX_RANK]; +#line 598 ptrdiff_t stride[MAX_RANK]; +#line 598 int canConvert; /* Both text or both numeric */ +#line 598 double value[MAX_NELS]; +#line 598 double expect[MAX_NELS]; +#line 598 +#line 598 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 598 IF (err) +#line 598 error("nc_open: %s", nc_strerror(err)); +#line 598 for (i = 0; i < NVARS; i++) { +#line 598 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 598 assert(var_rank[i] <= MAX_RANK); +#line 598 assert(var_nels[i] <= MAX_NELS); +#line 598 for (j = 0; j < var_rank[i]; j++) { +#line 598 start[j] = 0; +#line 598 edge[j] = 1; +#line 598 stride[j] = 1; +#line 598 } +#line 598 err = nc_get_vars_double(BAD_ID, i, start, edge, stride, value); +#line 598 IF (err != NC_EBADID) +#line 598 error("bad ncid: status = %d", err); +#line 598 err = nc_get_vars_double(ncid, BAD_VARID, start, edge, stride, value); +#line 598 IF (err != NC_ENOTVAR) +#line 598 error("bad var id: status = %d", err); +#line 598 for (j = 0; j < var_rank[i]; j++) { +#line 598 start[j] = var_shape[i][j]; +#line 598 err = nc_get_vars_double(ncid, i, start, edge, stride, value); +#line 598 if(!canConvert) { +#line 598 IF (err != NC_ECHAR) +#line 598 error("conversion: status = %d", err); +#line 598 } else { +#line 598 IF (err != NC_EINVALCOORDS) +#line 598 error("bad index: status = %d", err); +#line 598 start[j] = 0; +#line 598 edge[j] = var_shape[i][j] + 1; +#line 598 err = nc_get_vars_double(ncid, i, start, edge, stride, value); +#line 598 IF (err != NC_EEDGE) +#line 598 error("bad edge: status = %d", err); +#line 598 edge[j] = 1; +#line 598 stride[j] = 0; +#line 598 err = nc_get_vars_double(ncid, i, start, edge, stride, value); +#line 598 IF (err != NC_ESTRIDE) +#line 598 error("bad stride: status = %d", err); +#line 598 stride[j] = 1; +#line 598 } +#line 598 } +#line 598 /* Choose a random point dividing each dim into 2 parts */ +#line 598 /* get 2^rank (nslabs) slabs so defined */ +#line 598 nslabs = 1; +#line 598 for (j = 0; j < var_rank[i]; j++) { +#line 598 mid[j] = roll( var_shape[i][j] ); +#line 598 nslabs *= 2; +#line 598 } +#line 598 /* bits of k determine whether to get lower or upper part of dim */ +#line 598 /* choose random stride from 1 to edge */ +#line 598 for (k = 0; k < nslabs; k++) { +#line 598 nstarts = 1; +#line 598 for (j = 0; j < var_rank[i]; j++) { +#line 598 if ((k >> j) & 1) { +#line 598 start[j] = 0; +#line 598 edge[j] = mid[j]; +#line 598 }else{ +#line 598 start[j] = mid[j]; +#line 598 edge[j] = var_shape[i][j] - mid[j]; +#line 598 } +#line 598 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 598 nstarts *= stride[j]; +#line 598 } +#line 598 for (m = 0; m < nstarts; m++) { +#line 598 err = toMixedBase(m, var_rank[i], sstride, index); +#line 598 IF (err) +#line 598 error("error in toMixedBase"); +#line 598 nels = 1; +#line 598 for (j = 0; j < var_rank[i]; j++) { +#line 598 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 598 nels *= count[j]; +#line 598 index[j] += start[j]; +#line 598 } +#line 598 /* Random choice of forward or backward */ +#line 598 /* TODO +#line 598 if ( roll(2) ) { +#line 598 for (j = 0; j < var_rank[i]; j++) { +#line 598 index[j] += (count[j] - 1) * stride[j]; +#line 598 stride[j] = -stride[j]; +#line 598 } +#line 598 } +#line 598 */ +#line 598 allInExtRange = allInIntRange = 1; +#line 598 for (j = 0; j < nels; j++) { +#line 598 err = toMixedBase(j, var_rank[i], count, index2); +#line 598 IF (err) +#line 598 error("error in toMixedBase 1"); +#line 598 for (d = 0; d < var_rank[i]; d++) +#line 598 index2[d] = index[d] + index2[d] * stride[d]; +#line 598 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 598 NCT_DOUBLE); +#line 598 if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) { +#line 598 allInIntRange = allInIntRange && expect[j] >= double_min +#line 598 && expect[j] <= double_max; +#line 598 } else { +#line 598 allInExtRange = 0; +#line 598 } +#line 598 } +#line 598 if (var_rank[i] == 0 && i%2 ) +#line 598 err = nc_get_vars_double(ncid, i, NULL, NULL, NULL, value); +#line 598 else +#line 598 err = nc_get_vars_double(ncid, i, index, count, stride, value); +#line 598 if (canConvert) { +#line 598 if (allInExtRange) { +#line 598 if (allInIntRange) { +#line 598 IF (err) +#line 598 error("%s", nc_strerror(err)); +#line 598 } else { +#line 598 IF (err != NC_ERANGE) +#line 598 error("Range error: status = %d", err); +#line 598 } +#line 598 } else { +#line 598 IF (err != 0 && err != NC_ERANGE) +#line 598 error("OK or Range error: status = %d", err); +#line 598 } +#line 598 for (j = 0; j < nels; j++) { +#line 598 if (inRange3(expect[j],var_type[i],NCT_DOUBLE) +#line 598 && expect[j] >= double_min && expect[j] <= double_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_DOUBLE)){ +#line 598 + IF (!equal(value[j],expect[j],var_type[i], NCT_DOUBLE)){ +#line 598 error("value read not that expected"); +#line 598 if (verbose) { +#line 598 error("\n"); +#line 598 error("varid: %d, ", i); +#line 598 error("var_name: %s, ", var_name[i]); +#line 598 error("element number: %d ", j); +#line 598 error("expect: %g, ", expect[j]); +#line 598 error("got: %g", (double) value[j]); +#line 598 } +#line 598 } else { +#line 598 nok++; +#line 598 } +#line 598 } +#line 598 } +#line 598 } else { +#line 598 IF (nels > 0 && err != NC_ECHAR) +#line 598 error("wrong type: status = %d", err); +#line 598 } +#line 598 } +#line 598 } +#line 598 +#line 598 } +#line 598 err = nc_close(ncid); +#line 598 IF (err) +#line 598 error("nc_close: %s", nc_strerror(err)); +#line 598 print_nok(nok); +#line 598 } +#line 598 +#line 787 void +#line 788 test_nc_get_varm_text(void) +#line 788 { +#line 788 int ncid; +#line 788 int d; +#line 788 int i; +#line 788 int j; +#line 788 int k; +#line 788 int m; +#line 788 int err; +#line 788 int allInExtRange; /* all values within external range? */ +#line 788 int allInIntRange; /* all values within internal range? */ +#line 788 int nels; +#line 788 int nslabs; +#line 788 int nstarts; /* number of different starts */ +#line 788 int nok = 0; /* count of valid comparisons */ +#line 788 size_t start[MAX_RANK]; +#line 788 size_t edge[MAX_RANK]; +#line 788 size_t index[MAX_RANK]; +#line 788 size_t index2[MAX_RANK]; +#line 788 size_t mid[MAX_RANK]; +#line 788 size_t count[MAX_RANK]; +#line 788 size_t sstride[MAX_RANK]; +#line 788 ptrdiff_t stride[MAX_RANK]; +#line 788 ptrdiff_t imap[MAX_RANK]; +#line 788 int canConvert; /* Both text or both numeric */ +#line 788 text value[MAX_NELS]; +#line 788 double expect[MAX_NELS]; +#line 788 +#line 788 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 788 IF (err) +#line 788 error("nc_open: %s", nc_strerror(err)); +#line 788 for (i = 0; i < NVARS; i++) { +#line 788 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 788 assert(var_rank[i] <= MAX_RANK); +#line 788 assert(var_nels[i] <= MAX_NELS); +#line 788 for (j = 0; j < var_rank[i]; j++) { +#line 788 start[j] = 0; +#line 788 edge[j] = 1; +#line 788 stride[j] = 1; +#line 788 imap[j] = 1; +#line 788 } +#line 788 err = nc_get_varm_text(BAD_ID, i, start, edge, stride, imap, value); +#line 788 IF (err != NC_EBADID) +#line 788 error("bad ncid: status = %d", err); +#line 788 err = nc_get_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 788 IF (err != NC_ENOTVAR) +#line 788 error("bad var id: status = %d", err); +#line 788 for (j = 0; j < var_rank[i]; j++) { +#line 788 start[j] = var_shape[i][j]; +#line 788 err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value); +#line 788 if(!canConvert) { +#line 788 IF (err != NC_ECHAR) +#line 788 error("conversion: status = %d", err); +#line 788 } else { +#line 788 IF (err != NC_EINVALCOORDS) +#line 788 error("bad index: status = %d", err); +#line 788 start[j] = 0; +#line 788 edge[j] = var_shape[i][j] + 1; +#line 788 err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value); +#line 788 IF (err != NC_EEDGE) +#line 788 error("bad edge: status = %d", err); +#line 788 edge[j] = 1; +#line 788 stride[j] = 0; +#line 788 err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value); +#line 788 IF (err != NC_ESTRIDE) +#line 788 error("bad stride: status = %d", err); +#line 788 stride[j] = 1; +#line 788 } +#line 788 } +#line 788 /* Choose a random point dividing each dim into 2 parts */ +#line 788 /* get 2^rank (nslabs) slabs so defined */ +#line 788 nslabs = 1; +#line 788 for (j = 0; j < var_rank[i]; j++) { +#line 788 mid[j] = roll( var_shape[i][j] ); +#line 788 nslabs *= 2; +#line 788 } +#line 788 /* bits of k determine whether to get lower or upper part of dim */ +#line 788 /* choose random stride from 1 to edge */ +#line 788 for (k = 0; k < nslabs; k++) { +#line 788 nstarts = 1; +#line 788 for (j = 0; j < var_rank[i]; j++) { +#line 788 if ((k >> j) & 1) { +#line 788 start[j] = 0; +#line 788 edge[j] = mid[j]; +#line 788 }else{ +#line 788 start[j] = mid[j]; +#line 788 edge[j] = var_shape[i][j] - mid[j]; +#line 788 } +#line 788 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 788 nstarts *= stride[j]; +#line 788 } +#line 788 for (m = 0; m < nstarts; m++) { +#line 788 err = toMixedBase(m, var_rank[i], sstride, index); +#line 788 IF (err) +#line 788 error("error in toMixedBase"); +#line 788 nels = 1; +#line 788 for (j = 0; j < var_rank[i]; j++) { +#line 788 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 788 nels *= count[j]; +#line 788 index[j] += start[j]; +#line 788 } +#line 788 /* Random choice of forward or backward */ +#line 788 /* TODO +#line 788 if ( roll(2) ) { +#line 788 for (j = 0; j < var_rank[i]; j++) { +#line 788 index[j] += (count[j] - 1) * stride[j]; +#line 788 stride[j] = -stride[j]; +#line 788 } +#line 788 } +#line 788 */ +#line 788 if (var_rank[i] > 0) { +#line 788 j = var_rank[i] - 1; +#line 788 imap[j] = 1; +#line 788 for (; j > 0; j--) +#line 788 imap[j-1] = imap[j] * count[j]; +#line 788 } +#line 788 allInExtRange = allInIntRange = 1; +#line 788 for (j = 0; j < nels; j++) { +#line 788 err = toMixedBase(j, var_rank[i], count, index2); +#line 788 IF (err) +#line 788 error("error in toMixedBase 1"); +#line 788 for (d = 0; d < var_rank[i]; d++) +#line 788 index2[d] = index[d] + index2[d] * stride[d]; +#line 788 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 788 NCT_TEXT); +#line 788 if (inRange3(expect[j],var_type[i],NCT_TEXT)) { +#line 788 allInIntRange = allInIntRange && expect[j] >= text_min +#line 788 && expect[j] <= text_max; +#line 788 } else { +#line 788 allInExtRange = 0; +#line 788 } +#line 788 } +#line 788 if (var_rank[i] == 0 && i%2 ) +#line 788 err = nc_get_varm_text(ncid,i,NULL,NULL,NULL,NULL,value); +#line 788 else +#line 788 err = nc_get_varm_text(ncid,i,index,count,stride,imap,value); +#line 788 if (canConvert) { +#line 788 if (allInExtRange) { +#line 788 if (allInIntRange) { +#line 788 IF (err) +#line 788 error("%s", nc_strerror(err)); +#line 788 } else { +#line 788 IF (err != NC_ERANGE) +#line 788 error("Range error: status = %d", err); +#line 788 } +#line 788 } else { +#line 788 IF (err != 0 && err != NC_ERANGE) +#line 788 error("OK or Range error: status = %d", err); +#line 788 } +#line 788 for (j = 0; j < nels; j++) { +#line 788 if (inRange3(expect[j],var_type[i],NCT_TEXT) +#line 788 && expect[j] >= text_min +#line 788 && expect[j] <= text_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_TEXT)){ +#line 788 + IF (!equal(value[j],expect[j],var_type[i], NCT_TEXT)){ +#line 788 error("value read not that expected"); +#line 788 if (verbose) { +#line 788 error("\n"); +#line 788 error("varid: %d, ", i); +#line 788 error("var_name: %s, ", var_name[i]); +#line 788 error("element number: %d ", j); +#line 788 error("expect: %g, ", expect[j]); +#line 788 error("got: %g", (double) value[j]); +#line 788 } +#line 788 } else { +#line 788 nok++; +#line 788 } +#line 788 } +#line 788 } +#line 788 } else { +#line 788 IF (nels > 0 && err != NC_ECHAR) +#line 788 error("wrong type: status = %d", err); +#line 788 } +#line 788 } +#line 788 } +#line 788 } +#line 788 err = nc_close(ncid); +#line 788 IF (err) +#line 788 error("nc_close: %s", nc_strerror(err)); +#line 788 print_nok(nok); +#line 788 } +#line 788 void +#line 789 test_nc_get_varm_uchar(void) +#line 789 { +#line 789 int ncid; +#line 789 int d; +#line 789 int i; +#line 789 int j; +#line 789 int k; +#line 789 int m; +#line 789 int err; +#line 789 int allInExtRange; /* all values within external range? */ +#line 789 int allInIntRange; /* all values within internal range? */ +#line 789 int nels; +#line 789 int nslabs; +#line 789 int nstarts; /* number of different starts */ +#line 789 int nok = 0; /* count of valid comparisons */ +#line 789 size_t start[MAX_RANK]; +#line 789 size_t edge[MAX_RANK]; +#line 789 size_t index[MAX_RANK]; +#line 789 size_t index2[MAX_RANK]; +#line 789 size_t mid[MAX_RANK]; +#line 789 size_t count[MAX_RANK]; +#line 789 size_t sstride[MAX_RANK]; +#line 789 ptrdiff_t stride[MAX_RANK]; +#line 789 ptrdiff_t imap[MAX_RANK]; +#line 789 int canConvert; /* Both text or both numeric */ +#line 789 uchar value[MAX_NELS]; +#line 789 double expect[MAX_NELS]; +#line 789 +#line 789 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 789 IF (err) +#line 789 error("nc_open: %s", nc_strerror(err)); +#line 789 for (i = 0; i < NVARS; i++) { +#line 789 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 789 assert(var_rank[i] <= MAX_RANK); +#line 789 assert(var_nels[i] <= MAX_NELS); +#line 789 for (j = 0; j < var_rank[i]; j++) { +#line 789 start[j] = 0; +#line 789 edge[j] = 1; +#line 789 stride[j] = 1; +#line 789 imap[j] = 1; +#line 789 } +#line 789 err = nc_get_varm_uchar(BAD_ID, i, start, edge, stride, imap, value); +#line 789 IF (err != NC_EBADID) +#line 789 error("bad ncid: status = %d", err); +#line 789 err = nc_get_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 789 IF (err != NC_ENOTVAR) +#line 789 error("bad var id: status = %d", err); +#line 789 for (j = 0; j < var_rank[i]; j++) { +#line 789 start[j] = var_shape[i][j]; +#line 789 err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value); +#line 789 if(!canConvert) { +#line 789 IF (err != NC_ECHAR) +#line 789 error("conversion: status = %d", err); +#line 789 } else { +#line 789 IF (err != NC_EINVALCOORDS) +#line 789 error("bad index: status = %d", err); +#line 789 start[j] = 0; +#line 789 edge[j] = var_shape[i][j] + 1; +#line 789 err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value); +#line 789 IF (err != NC_EEDGE) +#line 789 error("bad edge: status = %d", err); +#line 789 edge[j] = 1; +#line 789 stride[j] = 0; +#line 789 err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value); +#line 789 IF (err != NC_ESTRIDE) +#line 789 error("bad stride: status = %d", err); +#line 789 stride[j] = 1; +#line 789 } +#line 789 } +#line 789 /* Choose a random point dividing each dim into 2 parts */ +#line 789 /* get 2^rank (nslabs) slabs so defined */ +#line 789 nslabs = 1; +#line 789 for (j = 0; j < var_rank[i]; j++) { +#line 789 mid[j] = roll( var_shape[i][j] ); +#line 789 nslabs *= 2; +#line 789 } +#line 789 /* bits of k determine whether to get lower or upper part of dim */ +#line 789 /* choose random stride from 1 to edge */ +#line 789 for (k = 0; k < nslabs; k++) { +#line 789 nstarts = 1; +#line 789 for (j = 0; j < var_rank[i]; j++) { +#line 789 if ((k >> j) & 1) { +#line 789 start[j] = 0; +#line 789 edge[j] = mid[j]; +#line 789 }else{ +#line 789 start[j] = mid[j]; +#line 789 edge[j] = var_shape[i][j] - mid[j]; +#line 789 } +#line 789 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 789 nstarts *= stride[j]; +#line 789 } +#line 789 for (m = 0; m < nstarts; m++) { +#line 789 err = toMixedBase(m, var_rank[i], sstride, index); +#line 789 IF (err) +#line 789 error("error in toMixedBase"); +#line 789 nels = 1; +#line 789 for (j = 0; j < var_rank[i]; j++) { +#line 789 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 789 nels *= count[j]; +#line 789 index[j] += start[j]; +#line 789 } +#line 789 /* Random choice of forward or backward */ +#line 789 /* TODO +#line 789 if ( roll(2) ) { +#line 789 for (j = 0; j < var_rank[i]; j++) { +#line 789 index[j] += (count[j] - 1) * stride[j]; +#line 789 stride[j] = -stride[j]; +#line 789 } +#line 789 } +#line 789 */ +#line 789 if (var_rank[i] > 0) { +#line 789 j = var_rank[i] - 1; +#line 789 imap[j] = 1; +#line 789 for (; j > 0; j--) +#line 789 imap[j-1] = imap[j] * count[j]; +#line 789 } +#line 789 allInExtRange = allInIntRange = 1; +#line 789 for (j = 0; j < nels; j++) { +#line 789 err = toMixedBase(j, var_rank[i], count, index2); +#line 789 IF (err) +#line 789 error("error in toMixedBase 1"); +#line 789 for (d = 0; d < var_rank[i]; d++) +#line 789 index2[d] = index[d] + index2[d] * stride[d]; +#line 789 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 789 NCT_UCHAR); +#line 789 if (inRange3(expect[j],var_type[i],NCT_UCHAR)) { +#line 789 allInIntRange = allInIntRange && expect[j] >= uchar_min +#line 789 && expect[j] <= uchar_max; +#line 789 } else { +#line 789 allInExtRange = 0; +#line 789 } +#line 789 } +#line 789 if (var_rank[i] == 0 && i%2 ) +#line 789 err = nc_get_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value); +#line 789 else +#line 789 err = nc_get_varm_uchar(ncid,i,index,count,stride,imap,value); +#line 789 if (canConvert) { +#line 789 if (allInExtRange) { +#line 789 if (allInIntRange) { +#line 789 IF (err) +#line 789 error("%s", nc_strerror(err)); +#line 789 } else { +#line 789 IF (err != NC_ERANGE) +#line 789 error("Range error: status = %d", err); +#line 789 } +#line 789 } else { +#line 789 IF (err != 0 && err != NC_ERANGE) +#line 789 error("OK or Range error: status = %d", err); +#line 789 } +#line 789 for (j = 0; j < nels; j++) { +#line 789 if (inRange3(expect[j],var_type[i],NCT_UCHAR) +#line 789 && expect[j] >= uchar_min +#line 789 && expect[j] <= uchar_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_UCHAR)){ +#line 789 + IF (!equal(value[j],expect[j],var_type[i], NCT_UCHAR)){ +#line 789 error("value read not that expected"); +#line 789 if (verbose) { +#line 789 error("\n"); +#line 789 error("varid: %d, ", i); +#line 789 error("var_name: %s, ", var_name[i]); +#line 789 error("element number: %d ", j); +#line 789 error("expect: %g, ", expect[j]); +#line 789 error("got: %g", (double) value[j]); +#line 789 } +#line 789 } else { +#line 789 nok++; +#line 789 } +#line 789 } +#line 789 } +#line 789 } else { +#line 789 IF (nels > 0 && err != NC_ECHAR) +#line 789 error("wrong type: status = %d", err); +#line 789 } +#line 789 } +#line 789 } +#line 789 } +#line 789 err = nc_close(ncid); +#line 789 IF (err) +#line 789 error("nc_close: %s", nc_strerror(err)); +#line 789 print_nok(nok); +#line 789 } +#line 789 void +#line 790 test_nc_get_varm_schar(void) +#line 790 { +#line 790 int ncid; +#line 790 int d; +#line 790 int i; +#line 790 int j; +#line 790 int k; +#line 790 int m; +#line 790 int err; +#line 790 int allInExtRange; /* all values within external range? */ +#line 790 int allInIntRange; /* all values within internal range? */ +#line 790 int nels; +#line 790 int nslabs; +#line 790 int nstarts; /* number of different starts */ +#line 790 int nok = 0; /* count of valid comparisons */ +#line 790 size_t start[MAX_RANK]; +#line 790 size_t edge[MAX_RANK]; +#line 790 size_t index[MAX_RANK]; +#line 790 size_t index2[MAX_RANK]; +#line 790 size_t mid[MAX_RANK]; +#line 790 size_t count[MAX_RANK]; +#line 790 size_t sstride[MAX_RANK]; +#line 790 ptrdiff_t stride[MAX_RANK]; +#line 790 ptrdiff_t imap[MAX_RANK]; +#line 790 int canConvert; /* Both text or both numeric */ +#line 790 schar value[MAX_NELS]; +#line 790 double expect[MAX_NELS]; +#line 790 +#line 790 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 790 IF (err) +#line 790 error("nc_open: %s", nc_strerror(err)); +#line 790 for (i = 0; i < NVARS; i++) { +#line 790 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 790 assert(var_rank[i] <= MAX_RANK); +#line 790 assert(var_nels[i] <= MAX_NELS); +#line 790 for (j = 0; j < var_rank[i]; j++) { +#line 790 start[j] = 0; +#line 790 edge[j] = 1; +#line 790 stride[j] = 1; +#line 790 imap[j] = 1; +#line 790 } +#line 790 err = nc_get_varm_schar(BAD_ID, i, start, edge, stride, imap, value); +#line 790 IF (err != NC_EBADID) +#line 790 error("bad ncid: status = %d", err); +#line 790 err = nc_get_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 790 IF (err != NC_ENOTVAR) +#line 790 error("bad var id: status = %d", err); +#line 790 for (j = 0; j < var_rank[i]; j++) { +#line 790 start[j] = var_shape[i][j]; +#line 790 err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value); +#line 790 if(!canConvert) { +#line 790 IF (err != NC_ECHAR) +#line 790 error("conversion: status = %d", err); +#line 790 } else { +#line 790 IF (err != NC_EINVALCOORDS) +#line 790 error("bad index: status = %d", err); +#line 790 start[j] = 0; +#line 790 edge[j] = var_shape[i][j] + 1; +#line 790 err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value); +#line 790 IF (err != NC_EEDGE) +#line 790 error("bad edge: status = %d", err); +#line 790 edge[j] = 1; +#line 790 stride[j] = 0; +#line 790 err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value); +#line 790 IF (err != NC_ESTRIDE) +#line 790 error("bad stride: status = %d", err); +#line 790 stride[j] = 1; +#line 790 } +#line 790 } +#line 790 /* Choose a random point dividing each dim into 2 parts */ +#line 790 /* get 2^rank (nslabs) slabs so defined */ +#line 790 nslabs = 1; +#line 790 for (j = 0; j < var_rank[i]; j++) { +#line 790 mid[j] = roll( var_shape[i][j] ); +#line 790 nslabs *= 2; +#line 790 } +#line 790 /* bits of k determine whether to get lower or upper part of dim */ +#line 790 /* choose random stride from 1 to edge */ +#line 790 for (k = 0; k < nslabs; k++) { +#line 790 nstarts = 1; +#line 790 for (j = 0; j < var_rank[i]; j++) { +#line 790 if ((k >> j) & 1) { +#line 790 start[j] = 0; +#line 790 edge[j] = mid[j]; +#line 790 }else{ +#line 790 start[j] = mid[j]; +#line 790 edge[j] = var_shape[i][j] - mid[j]; +#line 790 } +#line 790 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 790 nstarts *= stride[j]; +#line 790 } +#line 790 for (m = 0; m < nstarts; m++) { +#line 790 err = toMixedBase(m, var_rank[i], sstride, index); +#line 790 IF (err) +#line 790 error("error in toMixedBase"); +#line 790 nels = 1; +#line 790 for (j = 0; j < var_rank[i]; j++) { +#line 790 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 790 nels *= count[j]; +#line 790 index[j] += start[j]; +#line 790 } +#line 790 /* Random choice of forward or backward */ +#line 790 /* TODO +#line 790 if ( roll(2) ) { +#line 790 for (j = 0; j < var_rank[i]; j++) { +#line 790 index[j] += (count[j] - 1) * stride[j]; +#line 790 stride[j] = -stride[j]; +#line 790 } +#line 790 } +#line 790 */ +#line 790 if (var_rank[i] > 0) { +#line 790 j = var_rank[i] - 1; +#line 790 imap[j] = 1; +#line 790 for (; j > 0; j--) +#line 790 imap[j-1] = imap[j] * count[j]; +#line 790 } +#line 790 allInExtRange = allInIntRange = 1; +#line 790 for (j = 0; j < nels; j++) { +#line 790 err = toMixedBase(j, var_rank[i], count, index2); +#line 790 IF (err) +#line 790 error("error in toMixedBase 1"); +#line 790 for (d = 0; d < var_rank[i]; d++) +#line 790 index2[d] = index[d] + index2[d] * stride[d]; +#line 790 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 790 NCT_SCHAR); +#line 790 if (inRange3(expect[j],var_type[i],NCT_SCHAR)) { +#line 790 allInIntRange = allInIntRange && expect[j] >= schar_min +#line 790 && expect[j] <= schar_max; +#line 790 } else { +#line 790 allInExtRange = 0; +#line 790 } +#line 790 } +#line 790 if (var_rank[i] == 0 && i%2 ) +#line 790 err = nc_get_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value); +#line 790 else +#line 790 err = nc_get_varm_schar(ncid,i,index,count,stride,imap,value); +#line 790 if (canConvert) { +#line 790 if (allInExtRange) { +#line 790 if (allInIntRange) { +#line 790 IF (err) +#line 790 error("%s", nc_strerror(err)); +#line 790 } else { +#line 790 IF (err != NC_ERANGE) +#line 790 error("Range error: status = %d", err); +#line 790 } +#line 790 } else { +#line 790 IF (err != 0 && err != NC_ERANGE) +#line 790 error("OK or Range error: status = %d", err); +#line 790 } +#line 790 for (j = 0; j < nels; j++) { +#line 790 if (inRange3(expect[j],var_type[i],NCT_SCHAR) +#line 790 && expect[j] >= schar_min +#line 790 && expect[j] <= schar_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_SCHAR)){ +#line 790 + IF (!equal(value[j],expect[j],var_type[i], NCT_SCHAR)){ +#line 790 error("value read not that expected"); +#line 790 if (verbose) { +#line 790 error("\n"); +#line 790 error("varid: %d, ", i); +#line 790 error("var_name: %s, ", var_name[i]); +#line 790 error("element number: %d ", j); +#line 790 error("expect: %g, ", expect[j]); +#line 790 error("got: %g", (double) value[j]); +#line 790 } +#line 790 } else { +#line 790 nok++; +#line 790 } +#line 790 } +#line 790 } +#line 790 } else { +#line 790 IF (nels > 0 && err != NC_ECHAR) +#line 790 error("wrong type: status = %d", err); +#line 790 } +#line 790 } +#line 790 } +#line 790 } +#line 790 err = nc_close(ncid); +#line 790 IF (err) +#line 790 error("nc_close: %s", nc_strerror(err)); +#line 790 print_nok(nok); +#line 790 } +#line 790 void +#line 791 test_nc_get_varm_short(void) +#line 791 { +#line 791 int ncid; +#line 791 int d; +#line 791 int i; +#line 791 int j; +#line 791 int k; +#line 791 int m; +#line 791 int err; +#line 791 int allInExtRange; /* all values within external range? */ +#line 791 int allInIntRange; /* all values within internal range? */ +#line 791 int nels; +#line 791 int nslabs; +#line 791 int nstarts; /* number of different starts */ +#line 791 int nok = 0; /* count of valid comparisons */ +#line 791 size_t start[MAX_RANK]; +#line 791 size_t edge[MAX_RANK]; +#line 791 size_t index[MAX_RANK]; +#line 791 size_t index2[MAX_RANK]; +#line 791 size_t mid[MAX_RANK]; +#line 791 size_t count[MAX_RANK]; +#line 791 size_t sstride[MAX_RANK]; +#line 791 ptrdiff_t stride[MAX_RANK]; +#line 791 ptrdiff_t imap[MAX_RANK]; +#line 791 int canConvert; /* Both text or both numeric */ +#line 791 short value[MAX_NELS]; +#line 791 double expect[MAX_NELS]; +#line 791 +#line 791 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 791 IF (err) +#line 791 error("nc_open: %s", nc_strerror(err)); +#line 791 for (i = 0; i < NVARS; i++) { +#line 791 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 791 assert(var_rank[i] <= MAX_RANK); +#line 791 assert(var_nels[i] <= MAX_NELS); +#line 791 for (j = 0; j < var_rank[i]; j++) { +#line 791 start[j] = 0; +#line 791 edge[j] = 1; +#line 791 stride[j] = 1; +#line 791 imap[j] = 1; +#line 791 } +#line 791 err = nc_get_varm_short(BAD_ID, i, start, edge, stride, imap, value); +#line 791 IF (err != NC_EBADID) +#line 791 error("bad ncid: status = %d", err); +#line 791 err = nc_get_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 791 IF (err != NC_ENOTVAR) +#line 791 error("bad var id: status = %d", err); +#line 791 for (j = 0; j < var_rank[i]; j++) { +#line 791 start[j] = var_shape[i][j]; +#line 791 err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value); +#line 791 if(!canConvert) { +#line 791 IF (err != NC_ECHAR) +#line 791 error("conversion: status = %d", err); +#line 791 } else { +#line 791 IF (err != NC_EINVALCOORDS) +#line 791 error("bad index: status = %d", err); +#line 791 start[j] = 0; +#line 791 edge[j] = var_shape[i][j] + 1; +#line 791 err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value); +#line 791 IF (err != NC_EEDGE) +#line 791 error("bad edge: status = %d", err); +#line 791 edge[j] = 1; +#line 791 stride[j] = 0; +#line 791 err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value); +#line 791 IF (err != NC_ESTRIDE) +#line 791 error("bad stride: status = %d", err); +#line 791 stride[j] = 1; +#line 791 } +#line 791 } +#line 791 /* Choose a random point dividing each dim into 2 parts */ +#line 791 /* get 2^rank (nslabs) slabs so defined */ +#line 791 nslabs = 1; +#line 791 for (j = 0; j < var_rank[i]; j++) { +#line 791 mid[j] = roll( var_shape[i][j] ); +#line 791 nslabs *= 2; +#line 791 } +#line 791 /* bits of k determine whether to get lower or upper part of dim */ +#line 791 /* choose random stride from 1 to edge */ +#line 791 for (k = 0; k < nslabs; k++) { +#line 791 nstarts = 1; +#line 791 for (j = 0; j < var_rank[i]; j++) { +#line 791 if ((k >> j) & 1) { +#line 791 start[j] = 0; +#line 791 edge[j] = mid[j]; +#line 791 }else{ +#line 791 start[j] = mid[j]; +#line 791 edge[j] = var_shape[i][j] - mid[j]; +#line 791 } +#line 791 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 791 nstarts *= stride[j]; +#line 791 } +#line 791 for (m = 0; m < nstarts; m++) { +#line 791 err = toMixedBase(m, var_rank[i], sstride, index); +#line 791 IF (err) +#line 791 error("error in toMixedBase"); +#line 791 nels = 1; +#line 791 for (j = 0; j < var_rank[i]; j++) { +#line 791 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 791 nels *= count[j]; +#line 791 index[j] += start[j]; +#line 791 } +#line 791 /* Random choice of forward or backward */ +#line 791 /* TODO +#line 791 if ( roll(2) ) { +#line 791 for (j = 0; j < var_rank[i]; j++) { +#line 791 index[j] += (count[j] - 1) * stride[j]; +#line 791 stride[j] = -stride[j]; +#line 791 } +#line 791 } +#line 791 */ +#line 791 if (var_rank[i] > 0) { +#line 791 j = var_rank[i] - 1; +#line 791 imap[j] = 1; +#line 791 for (; j > 0; j--) +#line 791 imap[j-1] = imap[j] * count[j]; +#line 791 } +#line 791 allInExtRange = allInIntRange = 1; +#line 791 for (j = 0; j < nels; j++) { +#line 791 err = toMixedBase(j, var_rank[i], count, index2); +#line 791 IF (err) +#line 791 error("error in toMixedBase 1"); +#line 791 for (d = 0; d < var_rank[i]; d++) +#line 791 index2[d] = index[d] + index2[d] * stride[d]; +#line 791 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 791 NCT_SHORT); +#line 791 if (inRange3(expect[j],var_type[i],NCT_SHORT)) { +#line 791 allInIntRange = allInIntRange && expect[j] >= short_min +#line 791 && expect[j] <= short_max; +#line 791 } else { +#line 791 allInExtRange = 0; +#line 791 } +#line 791 } +#line 791 if (var_rank[i] == 0 && i%2 ) +#line 791 err = nc_get_varm_short(ncid,i,NULL,NULL,NULL,NULL,value); +#line 791 else +#line 791 err = nc_get_varm_short(ncid,i,index,count,stride,imap,value); +#line 791 if (canConvert) { +#line 791 if (allInExtRange) { +#line 791 if (allInIntRange) { +#line 791 IF (err) +#line 791 error("%s", nc_strerror(err)); +#line 791 } else { +#line 791 IF (err != NC_ERANGE) +#line 791 error("Range error: status = %d", err); +#line 791 } +#line 791 } else { +#line 791 IF (err != 0 && err != NC_ERANGE) +#line 791 error("OK or Range error: status = %d", err); +#line 791 } +#line 791 for (j = 0; j < nels; j++) { +#line 791 if (inRange3(expect[j],var_type[i],NCT_SHORT) +#line 791 && expect[j] >= short_min +#line 791 && expect[j] <= short_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_SHORT)){ +#line 791 + IF (!equal(value[j],expect[j],var_type[i], NCT_SHORT)){ +#line 791 error("value read not that expected"); +#line 791 if (verbose) { +#line 791 error("\n"); +#line 791 error("varid: %d, ", i); +#line 791 error("var_name: %s, ", var_name[i]); +#line 791 error("element number: %d ", j); +#line 791 error("expect: %g, ", expect[j]); +#line 791 error("got: %g", (double) value[j]); +#line 791 } +#line 791 } else { +#line 791 nok++; +#line 791 } +#line 791 } +#line 791 } +#line 791 } else { +#line 791 IF (nels > 0 && err != NC_ECHAR) +#line 791 error("wrong type: status = %d", err); +#line 791 } +#line 791 } +#line 791 } +#line 791 } +#line 791 err = nc_close(ncid); +#line 791 IF (err) +#line 791 error("nc_close: %s", nc_strerror(err)); +#line 791 print_nok(nok); +#line 791 } +#line 791 void +#line 792 test_nc_get_varm_int(void) +#line 792 { +#line 792 int ncid; +#line 792 int d; +#line 792 int i; +#line 792 int j; +#line 792 int k; +#line 792 int m; +#line 792 int err; +#line 792 int allInExtRange; /* all values within external range? */ +#line 792 int allInIntRange; /* all values within internal range? */ +#line 792 int nels; +#line 792 int nslabs; +#line 792 int nstarts; /* number of different starts */ +#line 792 int nok = 0; /* count of valid comparisons */ +#line 792 size_t start[MAX_RANK]; +#line 792 size_t edge[MAX_RANK]; +#line 792 size_t index[MAX_RANK]; +#line 792 size_t index2[MAX_RANK]; +#line 792 size_t mid[MAX_RANK]; +#line 792 size_t count[MAX_RANK]; +#line 792 size_t sstride[MAX_RANK]; +#line 792 ptrdiff_t stride[MAX_RANK]; +#line 792 ptrdiff_t imap[MAX_RANK]; +#line 792 int canConvert; /* Both text or both numeric */ +#line 792 int value[MAX_NELS]; +#line 792 double expect[MAX_NELS]; +#line 792 +#line 792 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 792 IF (err) +#line 792 error("nc_open: %s", nc_strerror(err)); +#line 792 for (i = 0; i < NVARS; i++) { +#line 792 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 792 assert(var_rank[i] <= MAX_RANK); +#line 792 assert(var_nels[i] <= MAX_NELS); +#line 792 for (j = 0; j < var_rank[i]; j++) { +#line 792 start[j] = 0; +#line 792 edge[j] = 1; +#line 792 stride[j] = 1; +#line 792 imap[j] = 1; +#line 792 } +#line 792 err = nc_get_varm_int(BAD_ID, i, start, edge, stride, imap, value); +#line 792 IF (err != NC_EBADID) +#line 792 error("bad ncid: status = %d", err); +#line 792 err = nc_get_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 792 IF (err != NC_ENOTVAR) +#line 792 error("bad var id: status = %d", err); +#line 792 for (j = 0; j < var_rank[i]; j++) { +#line 792 start[j] = var_shape[i][j]; +#line 792 err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value); +#line 792 if(!canConvert) { +#line 792 IF (err != NC_ECHAR) +#line 792 error("conversion: status = %d", err); +#line 792 } else { +#line 792 IF (err != NC_EINVALCOORDS) +#line 792 error("bad index: status = %d", err); +#line 792 start[j] = 0; +#line 792 edge[j] = var_shape[i][j] + 1; +#line 792 err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value); +#line 792 IF (err != NC_EEDGE) +#line 792 error("bad edge: status = %d", err); +#line 792 edge[j] = 1; +#line 792 stride[j] = 0; +#line 792 err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value); +#line 792 IF (err != NC_ESTRIDE) +#line 792 error("bad stride: status = %d", err); +#line 792 stride[j] = 1; +#line 792 } +#line 792 } +#line 792 /* Choose a random point dividing each dim into 2 parts */ +#line 792 /* get 2^rank (nslabs) slabs so defined */ +#line 792 nslabs = 1; +#line 792 for (j = 0; j < var_rank[i]; j++) { +#line 792 mid[j] = roll( var_shape[i][j] ); +#line 792 nslabs *= 2; +#line 792 } +#line 792 /* bits of k determine whether to get lower or upper part of dim */ +#line 792 /* choose random stride from 1 to edge */ +#line 792 for (k = 0; k < nslabs; k++) { +#line 792 nstarts = 1; +#line 792 for (j = 0; j < var_rank[i]; j++) { +#line 792 if ((k >> j) & 1) { +#line 792 start[j] = 0; +#line 792 edge[j] = mid[j]; +#line 792 }else{ +#line 792 start[j] = mid[j]; +#line 792 edge[j] = var_shape[i][j] - mid[j]; +#line 792 } +#line 792 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 792 nstarts *= stride[j]; +#line 792 } +#line 792 for (m = 0; m < nstarts; m++) { +#line 792 err = toMixedBase(m, var_rank[i], sstride, index); +#line 792 IF (err) +#line 792 error("error in toMixedBase"); +#line 792 nels = 1; +#line 792 for (j = 0; j < var_rank[i]; j++) { +#line 792 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 792 nels *= count[j]; +#line 792 index[j] += start[j]; +#line 792 } +#line 792 /* Random choice of forward or backward */ +#line 792 /* TODO +#line 792 if ( roll(2) ) { +#line 792 for (j = 0; j < var_rank[i]; j++) { +#line 792 index[j] += (count[j] - 1) * stride[j]; +#line 792 stride[j] = -stride[j]; +#line 792 } +#line 792 } +#line 792 */ +#line 792 if (var_rank[i] > 0) { +#line 792 j = var_rank[i] - 1; +#line 792 imap[j] = 1; +#line 792 for (; j > 0; j--) +#line 792 imap[j-1] = imap[j] * count[j]; +#line 792 } +#line 792 allInExtRange = allInIntRange = 1; +#line 792 for (j = 0; j < nels; j++) { +#line 792 err = toMixedBase(j, var_rank[i], count, index2); +#line 792 IF (err) +#line 792 error("error in toMixedBase 1"); +#line 792 for (d = 0; d < var_rank[i]; d++) +#line 792 index2[d] = index[d] + index2[d] * stride[d]; +#line 792 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 792 NCT_INT); +#line 792 if (inRange3(expect[j],var_type[i],NCT_INT)) { +#line 792 allInIntRange = allInIntRange && expect[j] >= int_min +#line 792 && expect[j] <= int_max; +#line 792 } else { +#line 792 allInExtRange = 0; +#line 792 } +#line 792 } +#line 792 if (var_rank[i] == 0 && i%2 ) +#line 792 err = nc_get_varm_int(ncid,i,NULL,NULL,NULL,NULL,value); +#line 792 else +#line 792 err = nc_get_varm_int(ncid,i,index,count,stride,imap,value); +#line 792 if (canConvert) { +#line 792 if (allInExtRange) { +#line 792 if (allInIntRange) { +#line 792 IF (err) +#line 792 error("%s", nc_strerror(err)); +#line 792 } else { +#line 792 IF (err != NC_ERANGE) +#line 792 error("Range error: status = %d", err); +#line 792 } +#line 792 } else { +#line 792 IF (err != 0 && err != NC_ERANGE) +#line 792 error("OK or Range error: status = %d", err); +#line 792 } +#line 792 for (j = 0; j < nels; j++) { +#line 792 if (inRange3(expect[j],var_type[i],NCT_INT) +#line 792 && expect[j] >= int_min +#line 792 && expect[j] <= int_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_INT)){ +#line 792 + IF (!equal(value[j],expect[j],var_type[i], NCT_INT)){ +#line 792 error("value read not that expected"); +#line 792 if (verbose) { +#line 792 error("\n"); +#line 792 error("varid: %d, ", i); +#line 792 error("var_name: %s, ", var_name[i]); +#line 792 error("element number: %d ", j); +#line 792 error("expect: %g, ", expect[j]); +#line 792 error("got: %g", (double) value[j]); +#line 792 } +#line 792 } else { +#line 792 nok++; +#line 792 } +#line 792 } +#line 792 } +#line 792 } else { +#line 792 IF (nels > 0 && err != NC_ECHAR) +#line 792 error("wrong type: status = %d", err); +#line 792 } +#line 792 } +#line 792 } +#line 792 } +#line 792 err = nc_close(ncid); +#line 792 IF (err) +#line 792 error("nc_close: %s", nc_strerror(err)); +#line 792 print_nok(nok); +#line 792 } +#line 792 void +#line 793 test_nc_get_varm_long(void) +#line 793 { +#line 793 int ncid; +#line 793 int d; +#line 793 int i; +#line 793 int j; +#line 793 int k; +#line 793 int m; +#line 793 int err; +#line 793 int allInExtRange; /* all values within external range? */ +#line 793 int allInIntRange; /* all values within internal range? */ +#line 793 int nels; +#line 793 int nslabs; +#line 793 int nstarts; /* number of different starts */ +#line 793 int nok = 0; /* count of valid comparisons */ +#line 793 size_t start[MAX_RANK]; +#line 793 size_t edge[MAX_RANK]; +#line 793 size_t index[MAX_RANK]; +#line 793 size_t index2[MAX_RANK]; +#line 793 size_t mid[MAX_RANK]; +#line 793 size_t count[MAX_RANK]; +#line 793 size_t sstride[MAX_RANK]; +#line 793 ptrdiff_t stride[MAX_RANK]; +#line 793 ptrdiff_t imap[MAX_RANK]; +#line 793 int canConvert; /* Both text or both numeric */ +#line 793 long value[MAX_NELS]; +#line 793 double expect[MAX_NELS]; +#line 793 +#line 793 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 793 IF (err) +#line 793 error("nc_open: %s", nc_strerror(err)); +#line 793 for (i = 0; i < NVARS; i++) { +#line 793 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 793 assert(var_rank[i] <= MAX_RANK); +#line 793 assert(var_nels[i] <= MAX_NELS); +#line 793 for (j = 0; j < var_rank[i]; j++) { +#line 793 start[j] = 0; +#line 793 edge[j] = 1; +#line 793 stride[j] = 1; +#line 793 imap[j] = 1; +#line 793 } +#line 793 err = nc_get_varm_long(BAD_ID, i, start, edge, stride, imap, value); +#line 793 IF (err != NC_EBADID) +#line 793 error("bad ncid: status = %d", err); +#line 793 err = nc_get_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 793 IF (err != NC_ENOTVAR) +#line 793 error("bad var id: status = %d", err); +#line 793 for (j = 0; j < var_rank[i]; j++) { +#line 793 start[j] = var_shape[i][j]; +#line 793 err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value); +#line 793 if(!canConvert) { +#line 793 IF (err != NC_ECHAR) +#line 793 error("conversion: status = %d", err); +#line 793 } else { +#line 793 IF (err != NC_EINVALCOORDS) +#line 793 error("bad index: status = %d", err); +#line 793 start[j] = 0; +#line 793 edge[j] = var_shape[i][j] + 1; +#line 793 err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value); +#line 793 IF (err != NC_EEDGE) +#line 793 error("bad edge: status = %d", err); +#line 793 edge[j] = 1; +#line 793 stride[j] = 0; +#line 793 err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value); +#line 793 IF (err != NC_ESTRIDE) +#line 793 error("bad stride: status = %d", err); +#line 793 stride[j] = 1; +#line 793 } +#line 793 } +#line 793 /* Choose a random point dividing each dim into 2 parts */ +#line 793 /* get 2^rank (nslabs) slabs so defined */ +#line 793 nslabs = 1; +#line 793 for (j = 0; j < var_rank[i]; j++) { +#line 793 mid[j] = roll( var_shape[i][j] ); +#line 793 nslabs *= 2; +#line 793 } +#line 793 /* bits of k determine whether to get lower or upper part of dim */ +#line 793 /* choose random stride from 1 to edge */ +#line 793 for (k = 0; k < nslabs; k++) { +#line 793 nstarts = 1; +#line 793 for (j = 0; j < var_rank[i]; j++) { +#line 793 if ((k >> j) & 1) { +#line 793 start[j] = 0; +#line 793 edge[j] = mid[j]; +#line 793 }else{ +#line 793 start[j] = mid[j]; +#line 793 edge[j] = var_shape[i][j] - mid[j]; +#line 793 } +#line 793 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 793 nstarts *= stride[j]; +#line 793 } +#line 793 for (m = 0; m < nstarts; m++) { +#line 793 err = toMixedBase(m, var_rank[i], sstride, index); +#line 793 IF (err) +#line 793 error("error in toMixedBase"); +#line 793 nels = 1; +#line 793 for (j = 0; j < var_rank[i]; j++) { +#line 793 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 793 nels *= count[j]; +#line 793 index[j] += start[j]; +#line 793 } +#line 793 /* Random choice of forward or backward */ +#line 793 /* TODO +#line 793 if ( roll(2) ) { +#line 793 for (j = 0; j < var_rank[i]; j++) { +#line 793 index[j] += (count[j] - 1) * stride[j]; +#line 793 stride[j] = -stride[j]; +#line 793 } +#line 793 } +#line 793 */ +#line 793 if (var_rank[i] > 0) { +#line 793 j = var_rank[i] - 1; +#line 793 imap[j] = 1; +#line 793 for (; j > 0; j--) +#line 793 imap[j-1] = imap[j] * count[j]; +#line 793 } +#line 793 allInExtRange = allInIntRange = 1; +#line 793 for (j = 0; j < nels; j++) { +#line 793 err = toMixedBase(j, var_rank[i], count, index2); +#line 793 IF (err) +#line 793 error("error in toMixedBase 1"); +#line 793 for (d = 0; d < var_rank[i]; d++) +#line 793 index2[d] = index[d] + index2[d] * stride[d]; +#line 793 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 793 NCT_LONG); +#line 793 if (inRange3(expect[j],var_type[i],NCT_LONG)) { +#line 793 allInIntRange = allInIntRange && expect[j] >= long_min +#line 793 && expect[j] <= long_max; +#line 793 } else { +#line 793 allInExtRange = 0; +#line 793 } +#line 793 } +#line 793 if (var_rank[i] == 0 && i%2 ) +#line 793 err = nc_get_varm_long(ncid,i,NULL,NULL,NULL,NULL,value); +#line 793 else +#line 793 err = nc_get_varm_long(ncid,i,index,count,stride,imap,value); +#line 793 if (canConvert) { +#line 793 if (allInExtRange) { +#line 793 if (allInIntRange) { +#line 793 IF (err) +#line 793 error("%s", nc_strerror(err)); +#line 793 } else { +#line 793 IF (err != NC_ERANGE) +#line 793 error("Range error: status = %d", err); +#line 793 } +#line 793 } else { +#line 793 IF (err != 0 && err != NC_ERANGE) +#line 793 error("OK or Range error: status = %d", err); +#line 793 } +#line 793 for (j = 0; j < nels; j++) { +#line 793 if (inRange3(expect[j],var_type[i],NCT_LONG) +#line 793 && expect[j] >= long_min +#line 793 && expect[j] <= long_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_LONG)){ +#line 793 + IF (!equal(value[j],expect[j],var_type[i], NCT_LONG)){ +#line 793 error("value read not that expected"); +#line 793 if (verbose) { +#line 793 error("\n"); +#line 793 error("varid: %d, ", i); +#line 793 error("var_name: %s, ", var_name[i]); +#line 793 error("element number: %d ", j); +#line 793 error("expect: %g, ", expect[j]); +#line 793 error("got: %g", (double) value[j]); +#line 793 } +#line 793 } else { +#line 793 nok++; +#line 793 } +#line 793 } +#line 793 } +#line 793 } else { +#line 793 IF (nels > 0 && err != NC_ECHAR) +#line 793 error("wrong type: status = %d", err); +#line 793 } +#line 793 } +#line 793 } +#line 793 } +#line 793 err = nc_close(ncid); +#line 793 IF (err) +#line 793 error("nc_close: %s", nc_strerror(err)); +#line 793 print_nok(nok); +#line 793 } +#line 793 void +#line 794 test_nc_get_varm_float(void) +#line 794 { +#line 794 int ncid; +#line 794 int d; +#line 794 int i; +#line 794 int j; +#line 794 int k; +#line 794 int m; +#line 794 int err; +#line 794 int allInExtRange; /* all values within external range? */ +#line 794 int allInIntRange; /* all values within internal range? */ +#line 794 int nels; +#line 794 int nslabs; +#line 794 int nstarts; /* number of different starts */ +#line 794 int nok = 0; /* count of valid comparisons */ +#line 794 size_t start[MAX_RANK]; +#line 794 size_t edge[MAX_RANK]; +#line 794 size_t index[MAX_RANK]; +#line 794 size_t index2[MAX_RANK]; +#line 794 size_t mid[MAX_RANK]; +#line 794 size_t count[MAX_RANK]; +#line 794 size_t sstride[MAX_RANK]; +#line 794 ptrdiff_t stride[MAX_RANK]; +#line 794 ptrdiff_t imap[MAX_RANK]; +#line 794 int canConvert; /* Both text or both numeric */ +#line 794 float value[MAX_NELS]; +#line 794 double expect[MAX_NELS]; +#line 794 +#line 794 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 794 IF (err) +#line 794 error("nc_open: %s", nc_strerror(err)); +#line 794 for (i = 0; i < NVARS; i++) { +#line 794 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 794 assert(var_rank[i] <= MAX_RANK); +#line 794 assert(var_nels[i] <= MAX_NELS); +#line 794 for (j = 0; j < var_rank[i]; j++) { +#line 794 start[j] = 0; +#line 794 edge[j] = 1; +#line 794 stride[j] = 1; +#line 794 imap[j] = 1; +#line 794 } +#line 794 err = nc_get_varm_float(BAD_ID, i, start, edge, stride, imap, value); +#line 794 IF (err != NC_EBADID) +#line 794 error("bad ncid: status = %d", err); +#line 794 err = nc_get_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 794 IF (err != NC_ENOTVAR) +#line 794 error("bad var id: status = %d", err); +#line 794 for (j = 0; j < var_rank[i]; j++) { +#line 794 start[j] = var_shape[i][j]; +#line 794 err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value); +#line 794 if(!canConvert) { +#line 794 IF (err != NC_ECHAR) +#line 794 error("conversion: status = %d", err); +#line 794 } else { +#line 794 IF (err != NC_EINVALCOORDS) +#line 794 error("bad index: status = %d", err); +#line 794 start[j] = 0; +#line 794 edge[j] = var_shape[i][j] + 1; +#line 794 err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value); +#line 794 IF (err != NC_EEDGE) +#line 794 error("bad edge: status = %d", err); +#line 794 edge[j] = 1; +#line 794 stride[j] = 0; +#line 794 err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value); +#line 794 IF (err != NC_ESTRIDE) +#line 794 error("bad stride: status = %d", err); +#line 794 stride[j] = 1; +#line 794 } +#line 794 } +#line 794 /* Choose a random point dividing each dim into 2 parts */ +#line 794 /* get 2^rank (nslabs) slabs so defined */ +#line 794 nslabs = 1; +#line 794 for (j = 0; j < var_rank[i]; j++) { +#line 794 mid[j] = roll( var_shape[i][j] ); +#line 794 nslabs *= 2; +#line 794 } +#line 794 /* bits of k determine whether to get lower or upper part of dim */ +#line 794 /* choose random stride from 1 to edge */ +#line 794 for (k = 0; k < nslabs; k++) { +#line 794 nstarts = 1; +#line 794 for (j = 0; j < var_rank[i]; j++) { +#line 794 if ((k >> j) & 1) { +#line 794 start[j] = 0; +#line 794 edge[j] = mid[j]; +#line 794 }else{ +#line 794 start[j] = mid[j]; +#line 794 edge[j] = var_shape[i][j] - mid[j]; +#line 794 } +#line 794 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 794 nstarts *= stride[j]; +#line 794 } +#line 794 for (m = 0; m < nstarts; m++) { +#line 794 err = toMixedBase(m, var_rank[i], sstride, index); +#line 794 IF (err) +#line 794 error("error in toMixedBase"); +#line 794 nels = 1; +#line 794 for (j = 0; j < var_rank[i]; j++) { +#line 794 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 794 nels *= count[j]; +#line 794 index[j] += start[j]; +#line 794 } +#line 794 /* Random choice of forward or backward */ +#line 794 /* TODO +#line 794 if ( roll(2) ) { +#line 794 for (j = 0; j < var_rank[i]; j++) { +#line 794 index[j] += (count[j] - 1) * stride[j]; +#line 794 stride[j] = -stride[j]; +#line 794 } +#line 794 } +#line 794 */ +#line 794 if (var_rank[i] > 0) { +#line 794 j = var_rank[i] - 1; +#line 794 imap[j] = 1; +#line 794 for (; j > 0; j--) +#line 794 imap[j-1] = imap[j] * count[j]; +#line 794 } +#line 794 allInExtRange = allInIntRange = 1; +#line 794 for (j = 0; j < nels; j++) { +#line 794 err = toMixedBase(j, var_rank[i], count, index2); +#line 794 IF (err) +#line 794 error("error in toMixedBase 1"); +#line 794 for (d = 0; d < var_rank[i]; d++) +#line 794 index2[d] = index[d] + index2[d] * stride[d]; +#line 794 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 794 NCT_FLOAT); +#line 794 if (inRange3(expect[j],var_type[i],NCT_FLOAT)) { +#line 794 allInIntRange = allInIntRange && expect[j] >= float_min +#line 794 && expect[j] <= float_max; +#line 794 } else { +#line 794 allInExtRange = 0; +#line 794 } +#line 794 } +#line 794 if (var_rank[i] == 0 && i%2 ) +#line 794 err = nc_get_varm_float(ncid,i,NULL,NULL,NULL,NULL,value); +#line 794 else +#line 794 err = nc_get_varm_float(ncid,i,index,count,stride,imap,value); +#line 794 if (canConvert) { +#line 794 if (allInExtRange) { +#line 794 if (allInIntRange) { +#line 794 IF (err) +#line 794 error("%s", nc_strerror(err)); +#line 794 } else { +#line 794 IF (err != NC_ERANGE) +#line 794 error("Range error: status = %d", err); +#line 794 } +#line 794 } else { +#line 794 IF (err != 0 && err != NC_ERANGE) +#line 794 error("OK or Range error: status = %d", err); +#line 794 } +#line 794 for (j = 0; j < nels; j++) { +#line 794 if (inRange3(expect[j],var_type[i],NCT_FLOAT) +#line 794 && expect[j] >= float_min +#line 794 && expect[j] <= float_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_FLOAT)){ +#line 794 + IF (!equal(value[j],expect[j],var_type[i], NCT_FLOAT)){ +#line 794 error("value read not that expected"); +#line 794 if (verbose) { +#line 794 error("\n"); +#line 794 error("varid: %d, ", i); +#line 794 error("var_name: %s, ", var_name[i]); +#line 794 error("element number: %d ", j); +#line 794 error("expect: %g, ", expect[j]); +#line 794 error("got: %g", (double) value[j]); +#line 794 } +#line 794 } else { +#line 794 nok++; +#line 794 } +#line 794 } +#line 794 } +#line 794 } else { +#line 794 IF (nels > 0 && err != NC_ECHAR) +#line 794 error("wrong type: status = %d", err); +#line 794 } +#line 794 } +#line 794 } +#line 794 } +#line 794 err = nc_close(ncid); +#line 794 IF (err) +#line 794 error("nc_close: %s", nc_strerror(err)); +#line 794 print_nok(nok); +#line 794 } +#line 794 void +#line 795 test_nc_get_varm_double(void) +#line 795 { +#line 795 int ncid; +#line 795 int d; +#line 795 int i; +#line 795 int j; +#line 795 int k; +#line 795 int m; +#line 795 int err; +#line 795 int allInExtRange; /* all values within external range? */ +#line 795 int allInIntRange; /* all values within internal range? */ +#line 795 int nels; +#line 795 int nslabs; +#line 795 int nstarts; /* number of different starts */ +#line 795 int nok = 0; /* count of valid comparisons */ +#line 795 size_t start[MAX_RANK]; +#line 795 size_t edge[MAX_RANK]; +#line 795 size_t index[MAX_RANK]; +#line 795 size_t index2[MAX_RANK]; +#line 795 size_t mid[MAX_RANK]; +#line 795 size_t count[MAX_RANK]; +#line 795 size_t sstride[MAX_RANK]; +#line 795 ptrdiff_t stride[MAX_RANK]; +#line 795 ptrdiff_t imap[MAX_RANK]; +#line 795 int canConvert; /* Both text or both numeric */ +#line 795 double value[MAX_NELS]; +#line 795 double expect[MAX_NELS]; +#line 795 +#line 795 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 795 IF (err) +#line 795 error("nc_open: %s", nc_strerror(err)); +#line 795 for (i = 0; i < NVARS; i++) { +#line 795 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 795 assert(var_rank[i] <= MAX_RANK); +#line 795 assert(var_nels[i] <= MAX_NELS); +#line 795 for (j = 0; j < var_rank[i]; j++) { +#line 795 start[j] = 0; +#line 795 edge[j] = 1; +#line 795 stride[j] = 1; +#line 795 imap[j] = 1; +#line 795 } +#line 795 err = nc_get_varm_double(BAD_ID, i, start, edge, stride, imap, value); +#line 795 IF (err != NC_EBADID) +#line 795 error("bad ncid: status = %d", err); +#line 795 err = nc_get_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 795 IF (err != NC_ENOTVAR) +#line 795 error("bad var id: status = %d", err); +#line 795 for (j = 0; j < var_rank[i]; j++) { +#line 795 start[j] = var_shape[i][j]; +#line 795 err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value); +#line 795 if(!canConvert) { +#line 795 IF (err != NC_ECHAR) +#line 795 error("conversion: status = %d", err); +#line 795 } else { +#line 795 IF (err != NC_EINVALCOORDS) +#line 795 error("bad index: status = %d", err); +#line 795 start[j] = 0; +#line 795 edge[j] = var_shape[i][j] + 1; +#line 795 err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value); +#line 795 IF (err != NC_EEDGE) +#line 795 error("bad edge: status = %d", err); +#line 795 edge[j] = 1; +#line 795 stride[j] = 0; +#line 795 err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value); +#line 795 IF (err != NC_ESTRIDE) +#line 795 error("bad stride: status = %d", err); +#line 795 stride[j] = 1; +#line 795 } +#line 795 } +#line 795 /* Choose a random point dividing each dim into 2 parts */ +#line 795 /* get 2^rank (nslabs) slabs so defined */ +#line 795 nslabs = 1; +#line 795 for (j = 0; j < var_rank[i]; j++) { +#line 795 mid[j] = roll( var_shape[i][j] ); +#line 795 nslabs *= 2; +#line 795 } +#line 795 /* bits of k determine whether to get lower or upper part of dim */ +#line 795 /* choose random stride from 1 to edge */ +#line 795 for (k = 0; k < nslabs; k++) { +#line 795 nstarts = 1; +#line 795 for (j = 0; j < var_rank[i]; j++) { +#line 795 if ((k >> j) & 1) { +#line 795 start[j] = 0; +#line 795 edge[j] = mid[j]; +#line 795 }else{ +#line 795 start[j] = mid[j]; +#line 795 edge[j] = var_shape[i][j] - mid[j]; +#line 795 } +#line 795 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 795 nstarts *= stride[j]; +#line 795 } +#line 795 for (m = 0; m < nstarts; m++) { +#line 795 err = toMixedBase(m, var_rank[i], sstride, index); +#line 795 IF (err) +#line 795 error("error in toMixedBase"); +#line 795 nels = 1; +#line 795 for (j = 0; j < var_rank[i]; j++) { +#line 795 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 795 nels *= count[j]; +#line 795 index[j] += start[j]; +#line 795 } +#line 795 /* Random choice of forward or backward */ +#line 795 /* TODO +#line 795 if ( roll(2) ) { +#line 795 for (j = 0; j < var_rank[i]; j++) { +#line 795 index[j] += (count[j] - 1) * stride[j]; +#line 795 stride[j] = -stride[j]; +#line 795 } +#line 795 } +#line 795 */ +#line 795 if (var_rank[i] > 0) { +#line 795 j = var_rank[i] - 1; +#line 795 imap[j] = 1; +#line 795 for (; j > 0; j--) +#line 795 imap[j-1] = imap[j] * count[j]; +#line 795 } +#line 795 allInExtRange = allInIntRange = 1; +#line 795 for (j = 0; j < nels; j++) { +#line 795 err = toMixedBase(j, var_rank[i], count, index2); +#line 795 IF (err) +#line 795 error("error in toMixedBase 1"); +#line 795 for (d = 0; d < var_rank[i]; d++) +#line 795 index2[d] = index[d] + index2[d] * stride[d]; +#line 795 expect[j] = hash4(var_type[i], var_rank[i], index2, +#line 795 NCT_DOUBLE); +#line 795 if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) { +#line 795 allInIntRange = allInIntRange && expect[j] >= double_min +#line 795 && expect[j] <= double_max; +#line 795 } else { +#line 795 allInExtRange = 0; +#line 795 } +#line 795 } +#line 795 if (var_rank[i] == 0 && i%2 ) +#line 795 err = nc_get_varm_double(ncid,i,NULL,NULL,NULL,NULL,value); +#line 795 else +#line 795 err = nc_get_varm_double(ncid,i,index,count,stride,imap,value); +#line 795 if (canConvert) { +#line 795 if (allInExtRange) { +#line 795 if (allInIntRange) { +#line 795 IF (err) +#line 795 error("%s", nc_strerror(err)); +#line 795 } else { +#line 795 IF (err != NC_ERANGE) +#line 795 error("Range error: status = %d", err); +#line 795 } +#line 795 } else { +#line 795 IF (err != 0 && err != NC_ERANGE) +#line 795 error("OK or Range error: status = %d", err); +#line 795 } +#line 795 for (j = 0; j < nels; j++) { +#line 795 if (inRange3(expect[j],var_type[i],NCT_DOUBLE) +#line 795 && expect[j] >= double_min +#line 795 && expect[j] <= double_max) { - IF (!equal(value[j],expect[j],var_type[i], - NCT_DOUBLE)){ +#line 795 + IF (!equal(value[j],expect[j],var_type[i], NCT_DOUBLE)){ +#line 795 error("value read not that expected"); +#line 795 if (verbose) { +#line 795 error("\n"); +#line 795 error("varid: %d, ", i); +#line 795 error("var_name: %s, ", var_name[i]); +#line 795 error("element number: %d ", j); +#line 795 error("expect: %g, ", expect[j]); +#line 795 error("got: %g", (double) value[j]); +#line 795 } +#line 795 } else { +#line 795 nok++; +#line 795 } +#line 795 } +#line 795 } +#line 795 } else { +#line 795 IF (nels > 0 && err != NC_ECHAR) +#line 795 error("wrong type: status = %d", err); +#line 795 } +#line 795 } +#line 795 } +#line 795 } +#line 795 err = nc_close(ncid); +#line 795 IF (err) +#line 795 error("nc_close: %s", nc_strerror(err)); +#line 795 print_nok(nok); +#line 795 } +#line 795 +#line 888 void +#line 889 test_nc_get_att_text(void) +#line 889 { +#line 889 int ncid; +#line 889 int i; +#line 889 int j; +#line 889 size_t k; +#line 889 int err; +#line 889 int allInExtRange; +#line 889 int allInIntRange; +#line 889 int canConvert; /* Both text or both numeric */ +#line 889 text value[MAX_NELS]; +#line 889 double expect[MAX_NELS]; +#line 889 int nok = 0; /* count of valid comparisons */ +#line 889 +#line 889 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 889 IF (err) +#line 889 error("nc_open: %s", nc_strerror(err)); +#line 889 +#line 889 for (i = -1; i < NVARS; i++) { +#line 889 for (j = 0; j < NATTS(i); j++) { +#line 889 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 889 err = nc_get_att_text(BAD_ID, i, ATT_NAME(i,j), value); +#line 889 IF (err != NC_EBADID) +#line 889 error("bad ncid: status = %d", err); +#line 889 err = nc_get_att_text(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 889 IF (err != NC_ENOTVAR) +#line 889 error("bad var id: status = %d", err); +#line 889 err = nc_get_att_text(ncid, i, "noSuch", value); +#line 889 IF (err != NC_ENOTATT) +#line 889 error("Bad attribute name: status = %d", err); +#line 889 allInExtRange = allInIntRange = 1; +#line 889 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 889 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_TEXT); +#line 889 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)) { +#line 889 allInIntRange = allInIntRange && expect[k] >= text_min +#line 889 && expect[k] <= text_max; +#line 889 } else { +#line 889 allInExtRange = 0; +#line 889 } +#line 889 } +#line 889 err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value); +#line 889 if (canConvert || ATT_LEN(i,j) == 0) { +#line 889 if (allInExtRange) { +#line 889 if (allInIntRange) { +#line 889 IF (err) +#line 889 error("%s", nc_strerror(err)); +#line 889 } else { +#line 889 IF (err != NC_ERANGE) +#line 889 error("Range error: status = %d", err); +#line 889 } +#line 889 } else { +#line 889 IF (err != 0 && err != NC_ERANGE) +#line 889 error("OK or Range error: status = %d", err); +#line 889 } +#line 889 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 889 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT) +#line 889 && expect[k] >= text_min && expect[k] <= text_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_TEXT)){ +#line 889 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_TEXT)){ +#line 889 error("value read not that expected"); +#line 889 if (verbose) { +#line 889 error("\n"); +#line 889 error("varid: %d, ", i); +#line 889 error("att_name: %s, ", ATT_NAME(i,j)); +#line 889 error("element number: %d ", k); +#line 889 error("expect: %g", expect[k]); +#line 889 error("got: %g", (double) value[k]); +#line 889 } +#line 889 } else { +#line 889 nok++; +#line 889 } +#line 889 } +#line 889 } +#line 889 } else { +#line 889 IF (err != NC_ECHAR) +#line 889 error("wrong type: status = %d", err); +#line 889 } +#line 889 } +#line 889 } +#line 889 +#line 889 err = nc_close(ncid); +#line 889 IF (err) +#line 889 error("nc_close: %s", nc_strerror(err)); +#line 889 print_nok(nok); +#line 889 } +#line 889 void +#line 890 test_nc_get_att_uchar(void) +#line 890 { +#line 890 int ncid; +#line 890 int i; +#line 890 int j; +#line 890 size_t k; +#line 890 int err; +#line 890 int allInExtRange; +#line 890 int allInIntRange; +#line 890 int canConvert; /* Both text or both numeric */ +#line 890 uchar value[MAX_NELS]; +#line 890 double expect[MAX_NELS]; +#line 890 int nok = 0; /* count of valid comparisons */ +#line 890 +#line 890 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 890 IF (err) +#line 890 error("nc_open: %s", nc_strerror(err)); +#line 890 +#line 890 for (i = -1; i < NVARS; i++) { +#line 890 for (j = 0; j < NATTS(i); j++) { +#line 890 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 890 err = nc_get_att_uchar(BAD_ID, i, ATT_NAME(i,j), value); +#line 890 IF (err != NC_EBADID) +#line 890 error("bad ncid: status = %d", err); +#line 890 err = nc_get_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 890 IF (err != NC_ENOTVAR) +#line 890 error("bad var id: status = %d", err); +#line 890 err = nc_get_att_uchar(ncid, i, "noSuch", value); +#line 890 IF (err != NC_ENOTATT) +#line 890 error("Bad attribute name: status = %d", err); +#line 890 allInExtRange = allInIntRange = 1; +#line 890 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 890 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_UCHAR); +#line 890 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)) { +#line 890 allInIntRange = allInIntRange && expect[k] >= uchar_min +#line 890 && expect[k] <= uchar_max; +#line 890 } else { +#line 890 allInExtRange = 0; +#line 890 } +#line 890 } +#line 890 err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value); +#line 890 if (canConvert || ATT_LEN(i,j) == 0) { +#line 890 if (allInExtRange) { +#line 890 if (allInIntRange) { +#line 890 IF (err) +#line 890 error("%s", nc_strerror(err)); +#line 890 } else { +#line 890 IF (err != NC_ERANGE) +#line 890 error("Range error: status = %d", err); +#line 890 } +#line 890 } else { +#line 890 IF (err != 0 && err != NC_ERANGE) +#line 890 error("OK or Range error: status = %d", err); +#line 890 } +#line 890 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 890 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR) +#line 890 && expect[k] >= uchar_min && expect[k] <= uchar_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_UCHAR)){ +#line 890 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_UCHAR)){ +#line 890 error("value read not that expected"); +#line 890 if (verbose) { +#line 890 error("\n"); +#line 890 error("varid: %d, ", i); +#line 890 error("att_name: %s, ", ATT_NAME(i,j)); +#line 890 error("element number: %d ", k); +#line 890 error("expect: %g", expect[k]); +#line 890 error("got: %g", (double) value[k]); +#line 890 } +#line 890 } else { +#line 890 nok++; +#line 890 } +#line 890 } +#line 890 } +#line 890 } else { +#line 890 IF (err != NC_ECHAR) +#line 890 error("wrong type: status = %d", err); +#line 890 } +#line 890 } +#line 890 } +#line 890 +#line 890 err = nc_close(ncid); +#line 890 IF (err) +#line 890 error("nc_close: %s", nc_strerror(err)); +#line 890 print_nok(nok); +#line 890 } +#line 890 void +#line 891 test_nc_get_att_schar(void) +#line 891 { +#line 891 int ncid; +#line 891 int i; +#line 891 int j; +#line 891 size_t k; +#line 891 int err; +#line 891 int allInExtRange; +#line 891 int allInIntRange; +#line 891 int canConvert; /* Both text or both numeric */ +#line 891 schar value[MAX_NELS]; +#line 891 double expect[MAX_NELS]; +#line 891 int nok = 0; /* count of valid comparisons */ +#line 891 +#line 891 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 891 IF (err) +#line 891 error("nc_open: %s", nc_strerror(err)); +#line 891 +#line 891 for (i = -1; i < NVARS; i++) { +#line 891 for (j = 0; j < NATTS(i); j++) { +#line 891 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 891 err = nc_get_att_schar(BAD_ID, i, ATT_NAME(i,j), value); +#line 891 IF (err != NC_EBADID) +#line 891 error("bad ncid: status = %d", err); +#line 891 err = nc_get_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 891 IF (err != NC_ENOTVAR) +#line 891 error("bad var id: status = %d", err); +#line 891 err = nc_get_att_schar(ncid, i, "noSuch", value); +#line 891 IF (err != NC_ENOTATT) +#line 891 error("Bad attribute name: status = %d", err); +#line 891 allInExtRange = allInIntRange = 1; +#line 891 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 891 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SCHAR); +#line 891 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)) { +#line 891 allInIntRange = allInIntRange && expect[k] >= schar_min +#line 891 && expect[k] <= schar_max; +#line 891 } else { +#line 891 allInExtRange = 0; +#line 891 } +#line 891 } +#line 891 err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value); +#line 891 if (canConvert || ATT_LEN(i,j) == 0) { +#line 891 if (allInExtRange) { +#line 891 if (allInIntRange) { +#line 891 IF (err) +#line 891 error("%s", nc_strerror(err)); +#line 891 } else { +#line 891 IF (err != NC_ERANGE) +#line 891 error("Range error: status = %d", err); +#line 891 } +#line 891 } else { +#line 891 IF (err != 0 && err != NC_ERANGE) +#line 891 error("OK or Range error: status = %d", err); +#line 891 } +#line 891 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 891 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR) +#line 891 && expect[k] >= schar_min && expect[k] <= schar_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_SCHAR)){ +#line 891 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_SCHAR)){ +#line 891 error("value read not that expected"); +#line 891 if (verbose) { +#line 891 error("\n"); +#line 891 error("varid: %d, ", i); +#line 891 error("att_name: %s, ", ATT_NAME(i,j)); +#line 891 error("element number: %d ", k); +#line 891 error("expect: %g", expect[k]); +#line 891 error("got: %g", (double) value[k]); +#line 891 } +#line 891 } else { +#line 891 nok++; +#line 891 } +#line 891 } +#line 891 } +#line 891 } else { +#line 891 IF (err != NC_ECHAR) +#line 891 error("wrong type: status = %d", err); +#line 891 } +#line 891 } +#line 891 } +#line 891 +#line 891 err = nc_close(ncid); +#line 891 IF (err) +#line 891 error("nc_close: %s", nc_strerror(err)); +#line 891 print_nok(nok); +#line 891 } +#line 891 void +#line 892 test_nc_get_att_short(void) +#line 892 { +#line 892 int ncid; +#line 892 int i; +#line 892 int j; +#line 892 size_t k; +#line 892 int err; +#line 892 int allInExtRange; +#line 892 int allInIntRange; +#line 892 int canConvert; /* Both text or both numeric */ +#line 892 short value[MAX_NELS]; +#line 892 double expect[MAX_NELS]; +#line 892 int nok = 0; /* count of valid comparisons */ +#line 892 +#line 892 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 892 IF (err) +#line 892 error("nc_open: %s", nc_strerror(err)); +#line 892 +#line 892 for (i = -1; i < NVARS; i++) { +#line 892 for (j = 0; j < NATTS(i); j++) { +#line 892 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 892 err = nc_get_att_short(BAD_ID, i, ATT_NAME(i,j), value); +#line 892 IF (err != NC_EBADID) +#line 892 error("bad ncid: status = %d", err); +#line 892 err = nc_get_att_short(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 892 IF (err != NC_ENOTVAR) +#line 892 error("bad var id: status = %d", err); +#line 892 err = nc_get_att_short(ncid, i, "noSuch", value); +#line 892 IF (err != NC_ENOTATT) +#line 892 error("Bad attribute name: status = %d", err); +#line 892 allInExtRange = allInIntRange = 1; +#line 892 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 892 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SHORT); +#line 892 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)) { +#line 892 allInIntRange = allInIntRange && expect[k] >= short_min +#line 892 && expect[k] <= short_max; +#line 892 } else { +#line 892 allInExtRange = 0; +#line 892 } +#line 892 } +#line 892 err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value); +#line 892 if (canConvert || ATT_LEN(i,j) == 0) { +#line 892 if (allInExtRange) { +#line 892 if (allInIntRange) { +#line 892 IF (err) +#line 892 error("%s", nc_strerror(err)); +#line 892 } else { +#line 892 IF (err != NC_ERANGE) +#line 892 error("Range error: status = %d", err); +#line 892 } +#line 892 } else { +#line 892 IF (err != 0 && err != NC_ERANGE) +#line 892 error("OK or Range error: status = %d", err); +#line 892 } +#line 892 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 892 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT) +#line 892 && expect[k] >= short_min && expect[k] <= short_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_SHORT)){ +#line 892 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_SHORT)){ +#line 892 error("value read not that expected"); +#line 892 if (verbose) { +#line 892 error("\n"); +#line 892 error("varid: %d, ", i); +#line 892 error("att_name: %s, ", ATT_NAME(i,j)); +#line 892 error("element number: %d ", k); +#line 892 error("expect: %g", expect[k]); +#line 892 error("got: %g", (double) value[k]); +#line 892 } +#line 892 } else { +#line 892 nok++; +#line 892 } +#line 892 } +#line 892 } +#line 892 } else { +#line 892 IF (err != NC_ECHAR) +#line 892 error("wrong type: status = %d", err); +#line 892 } +#line 892 } +#line 892 } +#line 892 +#line 892 err = nc_close(ncid); +#line 892 IF (err) +#line 892 error("nc_close: %s", nc_strerror(err)); +#line 892 print_nok(nok); +#line 892 } +#line 892 void +#line 893 test_nc_get_att_int(void) +#line 893 { +#line 893 int ncid; +#line 893 int i; +#line 893 int j; +#line 893 size_t k; +#line 893 int err; +#line 893 int allInExtRange; +#line 893 int allInIntRange; +#line 893 int canConvert; /* Both text or both numeric */ +#line 893 int value[MAX_NELS]; +#line 893 double expect[MAX_NELS]; +#line 893 int nok = 0; /* count of valid comparisons */ +#line 893 +#line 893 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 893 IF (err) +#line 893 error("nc_open: %s", nc_strerror(err)); +#line 893 +#line 893 for (i = -1; i < NVARS; i++) { +#line 893 for (j = 0; j < NATTS(i); j++) { +#line 893 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 893 err = nc_get_att_int(BAD_ID, i, ATT_NAME(i,j), value); +#line 893 IF (err != NC_EBADID) +#line 893 error("bad ncid: status = %d", err); +#line 893 err = nc_get_att_int(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 893 IF (err != NC_ENOTVAR) +#line 893 error("bad var id: status = %d", err); +#line 893 err = nc_get_att_int(ncid, i, "noSuch", value); +#line 893 IF (err != NC_ENOTATT) +#line 893 error("Bad attribute name: status = %d", err); +#line 893 allInExtRange = allInIntRange = 1; +#line 893 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 893 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_INT); +#line 893 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)) { +#line 893 allInIntRange = allInIntRange && expect[k] >= int_min +#line 893 && expect[k] <= int_max; +#line 893 } else { +#line 893 allInExtRange = 0; +#line 893 } +#line 893 } +#line 893 err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value); +#line 893 if (canConvert || ATT_LEN(i,j) == 0) { +#line 893 if (allInExtRange) { +#line 893 if (allInIntRange) { +#line 893 IF (err) +#line 893 error("%s", nc_strerror(err)); +#line 893 } else { +#line 893 IF (err != NC_ERANGE) +#line 893 error("Range error: status = %d", err); +#line 893 } +#line 893 } else { +#line 893 IF (err != 0 && err != NC_ERANGE) +#line 893 error("OK or Range error: status = %d", err); +#line 893 } +#line 893 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 893 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT) +#line 893 && expect[k] >= int_min && expect[k] <= int_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_INT)){ +#line 893 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_INT)){ +#line 893 error("value read not that expected"); +#line 893 if (verbose) { +#line 893 error("\n"); +#line 893 error("varid: %d, ", i); +#line 893 error("att_name: %s, ", ATT_NAME(i,j)); +#line 893 error("element number: %d ", k); +#line 893 error("expect: %g", expect[k]); +#line 893 error("got: %g", (double) value[k]); +#line 893 } +#line 893 } else { +#line 893 nok++; +#line 893 } +#line 893 } +#line 893 } +#line 893 } else { +#line 893 IF (err != NC_ECHAR) +#line 893 error("wrong type: status = %d", err); +#line 893 } +#line 893 } +#line 893 } +#line 893 +#line 893 err = nc_close(ncid); +#line 893 IF (err) +#line 893 error("nc_close: %s", nc_strerror(err)); +#line 893 print_nok(nok); +#line 893 } +#line 893 void +#line 894 test_nc_get_att_long(void) +#line 894 { +#line 894 int ncid; +#line 894 int i; +#line 894 int j; +#line 894 size_t k; +#line 894 int err; +#line 894 int allInExtRange; +#line 894 int allInIntRange; +#line 894 int canConvert; /* Both text or both numeric */ +#line 894 long value[MAX_NELS]; +#line 894 double expect[MAX_NELS]; +#line 894 int nok = 0; /* count of valid comparisons */ +#line 894 +#line 894 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 894 IF (err) +#line 894 error("nc_open: %s", nc_strerror(err)); +#line 894 +#line 894 for (i = -1; i < NVARS; i++) { +#line 894 for (j = 0; j < NATTS(i); j++) { +#line 894 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 894 err = nc_get_att_long(BAD_ID, i, ATT_NAME(i,j), value); +#line 894 IF (err != NC_EBADID) +#line 894 error("bad ncid: status = %d", err); +#line 894 err = nc_get_att_long(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 894 IF (err != NC_ENOTVAR) +#line 894 error("bad var id: status = %d", err); +#line 894 err = nc_get_att_long(ncid, i, "noSuch", value); +#line 894 IF (err != NC_ENOTATT) +#line 894 error("Bad attribute name: status = %d", err); +#line 894 allInExtRange = allInIntRange = 1; +#line 894 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 894 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_LONG); +#line 894 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)) { +#line 894 allInIntRange = allInIntRange && expect[k] >= long_min +#line 894 && expect[k] <= long_max; +#line 894 } else { +#line 894 allInExtRange = 0; +#line 894 } +#line 894 } +#line 894 err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value); +#line 894 if (canConvert || ATT_LEN(i,j) == 0) { +#line 894 if (allInExtRange) { +#line 894 if (allInIntRange) { +#line 894 IF (err) +#line 894 error("%s", nc_strerror(err)); +#line 894 } else { +#line 894 IF (err != NC_ERANGE) +#line 894 error("Range error: status = %d", err); +#line 894 } +#line 894 } else { +#line 894 IF (err != 0 && err != NC_ERANGE) +#line 894 error("OK or Range error: status = %d", err); +#line 894 } +#line 894 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 894 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG) +#line 894 && expect[k] >= long_min && expect[k] <= long_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_LONG)){ +#line 894 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_LONG)){ +#line 894 error("value read not that expected"); +#line 894 if (verbose) { +#line 894 error("\n"); +#line 894 error("varid: %d, ", i); +#line 894 error("att_name: %s, ", ATT_NAME(i,j)); +#line 894 error("element number: %d ", k); +#line 894 error("expect: %g", expect[k]); +#line 894 error("got: %g", (double) value[k]); +#line 894 } +#line 894 } else { +#line 894 nok++; +#line 894 } +#line 894 } +#line 894 } +#line 894 } else { +#line 894 IF (err != NC_ECHAR) +#line 894 error("wrong type: status = %d", err); +#line 894 } +#line 894 } +#line 894 } +#line 894 +#line 894 err = nc_close(ncid); +#line 894 IF (err) +#line 894 error("nc_close: %s", nc_strerror(err)); +#line 894 print_nok(nok); +#line 894 } +#line 894 void +#line 895 test_nc_get_att_float(void) +#line 895 { +#line 895 int ncid; +#line 895 int i; +#line 895 int j; +#line 895 size_t k; +#line 895 int err; +#line 895 int allInExtRange; +#line 895 int allInIntRange; +#line 895 int canConvert; /* Both text or both numeric */ +#line 895 float value[MAX_NELS]; +#line 895 double expect[MAX_NELS]; +#line 895 int nok = 0; /* count of valid comparisons */ +#line 895 +#line 895 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 895 IF (err) +#line 895 error("nc_open: %s", nc_strerror(err)); +#line 895 +#line 895 for (i = -1; i < NVARS; i++) { +#line 895 for (j = 0; j < NATTS(i); j++) { +#line 895 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 895 err = nc_get_att_float(BAD_ID, i, ATT_NAME(i,j), value); +#line 895 IF (err != NC_EBADID) +#line 895 error("bad ncid: status = %d", err); +#line 895 err = nc_get_att_float(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 895 IF (err != NC_ENOTVAR) +#line 895 error("bad var id: status = %d", err); +#line 895 err = nc_get_att_float(ncid, i, "noSuch", value); +#line 895 IF (err != NC_ENOTATT) +#line 895 error("Bad attribute name: status = %d", err); +#line 895 allInExtRange = allInIntRange = 1; +#line 895 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 895 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_FLOAT); +#line 895 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)) { +#line 895 allInIntRange = allInIntRange && expect[k] >= float_min +#line 895 && expect[k] <= float_max; +#line 895 } else { +#line 895 allInExtRange = 0; +#line 895 } +#line 895 } +#line 895 err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value); +#line 895 if (canConvert || ATT_LEN(i,j) == 0) { +#line 895 if (allInExtRange) { +#line 895 if (allInIntRange) { +#line 895 IF (err) +#line 895 error("%s", nc_strerror(err)); +#line 895 } else { +#line 895 IF (err != NC_ERANGE) +#line 895 error("Range error: status = %d", err); +#line 895 } +#line 895 } else { +#line 895 IF (err != 0 && err != NC_ERANGE) +#line 895 error("OK or Range error: status = %d", err); +#line 895 } +#line 895 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 895 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT) +#line 895 && expect[k] >= float_min && expect[k] <= float_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_FLOAT)){ +#line 895 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_FLOAT)){ +#line 895 error("value read not that expected"); +#line 895 if (verbose) { +#line 895 error("\n"); +#line 895 error("varid: %d, ", i); +#line 895 error("att_name: %s, ", ATT_NAME(i,j)); +#line 895 error("element number: %d ", k); +#line 895 error("expect: %g", expect[k]); +#line 895 error("got: %g", (double) value[k]); +#line 895 } +#line 895 } else { +#line 895 nok++; +#line 895 } +#line 895 } +#line 895 } +#line 895 } else { +#line 895 IF (err != NC_ECHAR) +#line 895 error("wrong type: status = %d", err); +#line 895 } +#line 895 } +#line 895 } +#line 895 +#line 895 err = nc_close(ncid); +#line 895 IF (err) +#line 895 error("nc_close: %s", nc_strerror(err)); +#line 895 print_nok(nok); +#line 895 } +#line 895 void +#line 896 test_nc_get_att_double(void) +#line 896 { +#line 896 int ncid; +#line 896 int i; +#line 896 int j; +#line 896 size_t k; +#line 896 int err; +#line 896 int allInExtRange; +#line 896 int allInIntRange; +#line 896 int canConvert; /* Both text or both numeric */ +#line 896 double value[MAX_NELS]; +#line 896 double expect[MAX_NELS]; +#line 896 int nok = 0; /* count of valid comparisons */ +#line 896 +#line 896 err = nc_open(testfile, NC_NOWRITE, &ncid); +#line 896 IF (err) +#line 896 error("nc_open: %s", nc_strerror(err)); +#line 896 +#line 896 for (i = -1; i < NVARS; i++) { +#line 896 for (j = 0; j < NATTS(i); j++) { +#line 896 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 896 err = nc_get_att_double(BAD_ID, i, ATT_NAME(i,j), value); +#line 896 IF (err != NC_EBADID) +#line 896 error("bad ncid: status = %d", err); +#line 896 err = nc_get_att_double(ncid, BAD_VARID, ATT_NAME(i,j), value); +#line 896 IF (err != NC_ENOTVAR) +#line 896 error("bad var id: status = %d", err); +#line 896 err = nc_get_att_double(ncid, i, "noSuch", value); +#line 896 IF (err != NC_ENOTATT) +#line 896 error("Bad attribute name: status = %d", err); +#line 896 allInExtRange = allInIntRange = 1; +#line 896 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 896 expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE); +#line 896 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)) { +#line 896 allInIntRange = allInIntRange && expect[k] >= double_min +#line 896 && expect[k] <= double_max; +#line 896 } else { +#line 896 allInExtRange = 0; +#line 896 } +#line 896 } +#line 896 err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value); +#line 896 if (canConvert || ATT_LEN(i,j) == 0) { +#line 896 if (allInExtRange) { +#line 896 if (allInIntRange) { +#line 896 IF (err) +#line 896 error("%s", nc_strerror(err)); +#line 896 } else { +#line 896 IF (err != NC_ERANGE) +#line 896 error("Range error: status = %d", err); +#line 896 } +#line 896 } else { +#line 896 IF (err != 0 && err != NC_ERANGE) +#line 896 error("OK or Range error: status = %d", err); +#line 896 } +#line 896 for (k = 0; k < ATT_LEN(i,j); k++) { +#line 896 if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE) +#line 896 && expect[k] >= double_min && expect[k] <= double_max) { - IF (!equal(value[k],expect[k],ATT_TYPE(i,j), - NCT_DOUBLE)){ +#line 896 + IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_DOUBLE)){ +#line 896 error("value read not that expected"); +#line 896 if (verbose) { +#line 896 error("\n"); +#line 896 error("varid: %d, ", i); +#line 896 error("att_name: %s, ", ATT_NAME(i,j)); +#line 896 error("element number: %d ", k); +#line 896 error("expect: %g", expect[k]); +#line 896 error("got: %g", (double) value[k]); +#line 896 } +#line 896 } else { +#line 896 nok++; +#line 896 } +#line 896 } +#line 896 } +#line 896 } else { +#line 896 IF (err != NC_ECHAR) +#line 896 error("wrong type: status = %d", err); +#line 896 } +#line 896 } +#line 896 } +#line 896 +#line 896 err = nc_close(ncid); +#line 896 IF (err) +#line 896 error("nc_close: %s", nc_strerror(err)); +#line 896 print_nok(nok); +#line 896 } +#line 896 diff --git a/nc_test/test_put.c b/nc_test/test_put.c index d24cc128d..a40e3be6e 100644 --- a/nc_test/test_put.c +++ b/nc_test/test_put.c @@ -1,6858 +1,13629 @@ +#line 5 "../../nc_test/test_put.m4" /* Do not edit this file. It is produced from the corresponding .m4 source */ +#line 7 /********************************************************************* * Copyright 1996, UCAR/Unidata * See netcdf/COPYRIGHT file for copying and redistribution conditions. * $Id: test_put.m4,v 1.25 2005/03/08 03:04:19 ed Exp $ *********************************************************************/ +#line 31 #include "tests.h" +#line 55 /* +#line 56 * ensure hash value within range for internal TYPE +#line 56 */ +#line 56 static +#line 56 double +#line 56 hash_text( +#line 56 const nc_type type, +#line 56 const int rank, +#line 56 const size_t *index, +#line 56 const nct_itype itype) +#line 56 { +#line 56 const double min = text_min; +#line 56 const double max = text_max; +#line 56 +#line 56 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 56 } +#line 56 /* +#line 57 * ensure hash value within range for internal TYPE +#line 57 */ +#line 57 static +#line 57 double +#line 57 hash_uchar( +#line 57 const nc_type type, +#line 57 const int rank, +#line 57 const size_t *index, +#line 57 const nct_itype itype) +#line 57 { +#line 57 const double min = uchar_min; +#line 57 const double max = uchar_max; +#line 57 +#line 57 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 57 } +#line 57 /* +#line 58 * ensure hash value within range for internal TYPE +#line 58 */ +#line 58 static +#line 58 double +#line 58 hash_schar( +#line 58 const nc_type type, +#line 58 const int rank, +#line 58 const size_t *index, +#line 58 const nct_itype itype) +#line 58 { +#line 58 const double min = schar_min; +#line 58 const double max = schar_max; +#line 58 +#line 58 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 58 } +#line 58 /* +#line 59 * ensure hash value within range for internal TYPE +#line 59 */ +#line 59 static +#line 59 double +#line 59 hash_short( +#line 59 const nc_type type, +#line 59 const int rank, +#line 59 const size_t *index, +#line 59 const nct_itype itype) +#line 59 { +#line 59 const double min = short_min; +#line 59 const double max = short_max; +#line 59 +#line 59 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 59 } +#line 59 /* +#line 60 * ensure hash value within range for internal TYPE +#line 60 */ +#line 60 static +#line 60 double +#line 60 hash_int( +#line 60 const nc_type type, +#line 60 const int rank, +#line 60 const size_t *index, +#line 60 const nct_itype itype) +#line 60 { +#line 60 const double min = int_min; +#line 60 const double max = int_max; +#line 60 +#line 60 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 60 } +#line 60 /* +#line 61 * ensure hash value within range for internal TYPE +#line 61 */ +#line 61 static +#line 61 double +#line 61 hash_long( +#line 61 const nc_type type, +#line 61 const int rank, +#line 61 const size_t *index, +#line 61 const nct_itype itype) +#line 61 { +#line 61 const double min = long_min; +#line 61 const double max = long_max; +#line 61 +#line 61 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 61 } +#line 61 /* +#line 62 * ensure hash value within range for internal TYPE +#line 62 */ +#line 62 static +#line 62 double +#line 62 hash_float( +#line 62 const nc_type type, +#line 62 const int rank, +#line 62 const size_t *index, +#line 62 const nct_itype itype) +#line 62 { +#line 62 const double min = float_min; +#line 62 const double max = float_max; +#line 62 +#line 62 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 62 } +#line 62 /* +#line 63 * ensure hash value within range for internal TYPE +#line 63 */ +#line 63 static +#line 63 double +#line 63 hash_double( +#line 63 const nc_type type, +#line 63 const int rank, +#line 63 const size_t *index, +#line 63 const nct_itype itype) +#line 63 { +#line 63 const double min = double_min; +#line 63 const double max = double_max; +#line 63 +#line 63 return MAX(min, MIN(max, hash4( type, rank, index, itype))); +#line 63 } +#line 63 +#line 154 /* +#line 155 * check all vars in file which are (text/numeric) compatible with TYPE +#line 155 */ +#line 155 static +#line 155 void +#line 155 check_vars_text(const char *filename) +#line 155 { +#line 155 int ncid; /* netCDF id */ +#line 155 size_t index[MAX_RANK]; +#line 155 int err; /* status */ +#line 155 int d; +#line 155 int i; +#line 155 size_t j; +#line 155 text value; +#line 155 nc_type datatype; +#line 155 int ndims; +#line 155 int dimids[MAX_RANK]; +#line 155 double expect; +#line 155 char name[NC_MAX_NAME]; +#line 155 size_t length; +#line 155 int canConvert; /* Both text or both numeric */ +#line 155 int nok = 0; /* count of valid comparisons */ +#line 155 +#line 155 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 155 IF (err) +#line 155 error("nc_open: %s", nc_strerror(err)); +#line 155 +#line 155 for (i = 0; i < NVARS; i++) { +#line 155 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 155 if (canConvert) { +#line 155 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 155 IF (err) +#line 155 error("nc_inq_var: %s", nc_strerror(err)); +#line 155 IF (strcmp(name, var_name[i]) != 0) +#line 155 error("Unexpected var_name"); +#line 155 IF (datatype != var_type[i]) +#line 155 error("Unexpected type"); +#line 155 IF (ndims != var_rank[i]) +#line 155 error("Unexpected rank"); +#line 155 for (j = 0; j < ndims; j++) { +#line 155 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 155 IF (err) +#line 155 error("nc_inq_dim: %s", nc_strerror(err)); +#line 155 IF (length != var_shape[i][j]) +#line 155 error("Unexpected shape"); +#line 155 } +#line 155 for (j = 0; j < var_nels[i]; j++) { +#line 155 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 155 IF (err) +#line 155 error("error in toMixedBase 2"); +#line 155 expect = hash4( var_type[i], var_rank[i], index, NCT_TEXT); +#line 155 err = nc_get_var1_text(ncid, i, index, &value); +#line 155 if (inRange3(expect,datatype,NCT_TEXT)) { +#line 155 if (expect >= text_min && expect <= text_max) { +#line 155 IF (err) { +#line 155 error("nc_get_var1_text: %s", nc_strerror(err)); +#line 155 } else { +#line 155 IF (!equal(value,expect,var_type[i],NCT_TEXT)) { +#line 155 error("Var value read not that expected"); +#line 155 if (verbose) { +#line 155 error("\n"); +#line 155 error("varid: %d, ", i); +#line 155 error("var_name: %s, ", var_name[i]); +#line 155 error("index:"); +#line 155 for (d = 0; d < var_rank[i]; d++) +#line 155 error(" %d", index[d]); +#line 155 error(", expect: %g, ", expect); +#line 155 error("got: %g", (double) value); +#line 155 } +#line 155 } else { +#line 155 ++nok; +#line 155 } +#line 155 } +#line 155 } +#line 155 } +#line 155 } +#line 155 } +#line 155 } +#line 155 err = nc_close (ncid); +#line 155 IF (err) +#line 155 error("nc_close: %s", nc_strerror(err)); +#line 155 print_nok(nok); +#line 155 } +#line 155 /* +#line 156 * check all vars in file which are (text/numeric) compatible with TYPE +#line 156 */ +#line 156 static +#line 156 void +#line 156 check_vars_uchar(const char *filename) +#line 156 { +#line 156 int ncid; /* netCDF id */ +#line 156 size_t index[MAX_RANK]; +#line 156 int err; /* status */ +#line 156 int d; +#line 156 int i; +#line 156 size_t j; +#line 156 uchar value; +#line 156 nc_type datatype; +#line 156 int ndims; +#line 156 int dimids[MAX_RANK]; +#line 156 double expect; +#line 156 char name[NC_MAX_NAME]; +#line 156 size_t length; +#line 156 int canConvert; /* Both text or both numeric */ +#line 156 int nok = 0; /* count of valid comparisons */ +#line 156 +#line 156 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 156 IF (err) +#line 156 error("nc_open: %s", nc_strerror(err)); +#line 156 +#line 156 for (i = 0; i < NVARS; i++) { +#line 156 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 156 if (canConvert) { +#line 156 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 156 IF (err) +#line 156 error("nc_inq_var: %s", nc_strerror(err)); +#line 156 IF (strcmp(name, var_name[i]) != 0) +#line 156 error("Unexpected var_name"); +#line 156 IF (datatype != var_type[i]) +#line 156 error("Unexpected type"); +#line 156 IF (ndims != var_rank[i]) +#line 156 error("Unexpected rank"); +#line 156 for (j = 0; j < ndims; j++) { +#line 156 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 156 IF (err) +#line 156 error("nc_inq_dim: %s", nc_strerror(err)); +#line 156 IF (length != var_shape[i][j]) +#line 156 error("Unexpected shape"); +#line 156 } +#line 156 for (j = 0; j < var_nels[i]; j++) { +#line 156 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 156 IF (err) +#line 156 error("error in toMixedBase 2"); +#line 156 expect = hash4( var_type[i], var_rank[i], index, NCT_UCHAR); +#line 156 err = nc_get_var1_uchar(ncid, i, index, &value); +#line 156 if (inRange3(expect,datatype,NCT_UCHAR)) { +#line 156 if (expect >= uchar_min && expect <= uchar_max) { +#line 156 IF (err) { +#line 156 error("nc_get_var1_uchar: %s", nc_strerror(err)); +#line 156 } else { +#line 156 IF (!equal(value,expect,var_type[i],NCT_UCHAR)) { +#line 156 error("Var value read not that expected"); +#line 156 if (verbose) { +#line 156 error("\n"); +#line 156 error("varid: %d, ", i); +#line 156 error("var_name: %s, ", var_name[i]); +#line 156 error("index:"); +#line 156 for (d = 0; d < var_rank[i]; d++) +#line 156 error(" %d", index[d]); +#line 156 error(", expect: %g, ", expect); +#line 156 error("got: %g", (double) value); +#line 156 } +#line 156 } else { +#line 156 ++nok; +#line 156 } +#line 156 } +#line 156 } +#line 156 } +#line 156 } +#line 156 } +#line 156 } +#line 156 err = nc_close (ncid); +#line 156 IF (err) +#line 156 error("nc_close: %s", nc_strerror(err)); +#line 156 print_nok(nok); +#line 156 } +#line 156 /* +#line 157 * check all vars in file which are (text/numeric) compatible with TYPE +#line 157 */ +#line 157 static +#line 157 void +#line 157 check_vars_schar(const char *filename) +#line 157 { +#line 157 int ncid; /* netCDF id */ +#line 157 size_t index[MAX_RANK]; +#line 157 int err; /* status */ +#line 157 int d; +#line 157 int i; +#line 157 size_t j; +#line 157 schar value; +#line 157 nc_type datatype; +#line 157 int ndims; +#line 157 int dimids[MAX_RANK]; +#line 157 double expect; +#line 157 char name[NC_MAX_NAME]; +#line 157 size_t length; +#line 157 int canConvert; /* Both text or both numeric */ +#line 157 int nok = 0; /* count of valid comparisons */ +#line 157 +#line 157 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 157 IF (err) +#line 157 error("nc_open: %s", nc_strerror(err)); +#line 157 +#line 157 for (i = 0; i < NVARS; i++) { +#line 157 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 157 if (canConvert) { +#line 157 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 157 IF (err) +#line 157 error("nc_inq_var: %s", nc_strerror(err)); +#line 157 IF (strcmp(name, var_name[i]) != 0) +#line 157 error("Unexpected var_name"); +#line 157 IF (datatype != var_type[i]) +#line 157 error("Unexpected type"); +#line 157 IF (ndims != var_rank[i]) +#line 157 error("Unexpected rank"); +#line 157 for (j = 0; j < ndims; j++) { +#line 157 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 157 IF (err) +#line 157 error("nc_inq_dim: %s", nc_strerror(err)); +#line 157 IF (length != var_shape[i][j]) +#line 157 error("Unexpected shape"); +#line 157 } +#line 157 for (j = 0; j < var_nels[i]; j++) { +#line 157 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 157 IF (err) +#line 157 error("error in toMixedBase 2"); +#line 157 expect = hash4( var_type[i], var_rank[i], index, NCT_SCHAR); +#line 157 err = nc_get_var1_schar(ncid, i, index, &value); +#line 157 if (inRange3(expect,datatype,NCT_SCHAR)) { +#line 157 if (expect >= schar_min && expect <= schar_max) { +#line 157 IF (err) { +#line 157 error("nc_get_var1_schar: %s", nc_strerror(err)); +#line 157 } else { +#line 157 IF (!equal(value,expect,var_type[i],NCT_SCHAR)) { +#line 157 error("Var value read not that expected"); +#line 157 if (verbose) { +#line 157 error("\n"); +#line 157 error("varid: %d, ", i); +#line 157 error("var_name: %s, ", var_name[i]); +#line 157 error("index:"); +#line 157 for (d = 0; d < var_rank[i]; d++) +#line 157 error(" %d", index[d]); +#line 157 error(", expect: %g, ", expect); +#line 157 error("got: %g", (double) value); +#line 157 } +#line 157 } else { +#line 157 ++nok; +#line 157 } +#line 157 } +#line 157 } +#line 157 } +#line 157 } +#line 157 } +#line 157 } +#line 157 err = nc_close (ncid); +#line 157 IF (err) +#line 157 error("nc_close: %s", nc_strerror(err)); +#line 157 print_nok(nok); +#line 157 } +#line 157 /* +#line 158 * check all vars in file which are (text/numeric) compatible with TYPE +#line 158 */ +#line 158 static +#line 158 void +#line 158 check_vars_short(const char *filename) +#line 158 { +#line 158 int ncid; /* netCDF id */ +#line 158 size_t index[MAX_RANK]; +#line 158 int err; /* status */ +#line 158 int d; +#line 158 int i; +#line 158 size_t j; +#line 158 short value; +#line 158 nc_type datatype; +#line 158 int ndims; +#line 158 int dimids[MAX_RANK]; +#line 158 double expect; +#line 158 char name[NC_MAX_NAME]; +#line 158 size_t length; +#line 158 int canConvert; /* Both text or both numeric */ +#line 158 int nok = 0; /* count of valid comparisons */ +#line 158 +#line 158 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 158 IF (err) +#line 158 error("nc_open: %s", nc_strerror(err)); +#line 158 +#line 158 for (i = 0; i < NVARS; i++) { +#line 158 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 158 if (canConvert) { +#line 158 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 158 IF (err) +#line 158 error("nc_inq_var: %s", nc_strerror(err)); +#line 158 IF (strcmp(name, var_name[i]) != 0) +#line 158 error("Unexpected var_name"); +#line 158 IF (datatype != var_type[i]) +#line 158 error("Unexpected type"); +#line 158 IF (ndims != var_rank[i]) +#line 158 error("Unexpected rank"); +#line 158 for (j = 0; j < ndims; j++) { +#line 158 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 158 IF (err) +#line 158 error("nc_inq_dim: %s", nc_strerror(err)); +#line 158 IF (length != var_shape[i][j]) +#line 158 error("Unexpected shape"); +#line 158 } +#line 158 for (j = 0; j < var_nels[i]; j++) { +#line 158 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 158 IF (err) +#line 158 error("error in toMixedBase 2"); +#line 158 expect = hash4( var_type[i], var_rank[i], index, NCT_SHORT); +#line 158 err = nc_get_var1_short(ncid, i, index, &value); +#line 158 if (inRange3(expect,datatype,NCT_SHORT)) { +#line 158 if (expect >= short_min && expect <= short_max) { +#line 158 IF (err) { +#line 158 error("nc_get_var1_short: %s", nc_strerror(err)); +#line 158 } else { +#line 158 IF (!equal(value,expect,var_type[i],NCT_SHORT)) { +#line 158 error("Var value read not that expected"); +#line 158 if (verbose) { +#line 158 error("\n"); +#line 158 error("varid: %d, ", i); +#line 158 error("var_name: %s, ", var_name[i]); +#line 158 error("index:"); +#line 158 for (d = 0; d < var_rank[i]; d++) +#line 158 error(" %d", index[d]); +#line 158 error(", expect: %g, ", expect); +#line 158 error("got: %g", (double) value); +#line 158 } +#line 158 } else { +#line 158 ++nok; +#line 158 } +#line 158 } +#line 158 } +#line 158 } +#line 158 } +#line 158 } +#line 158 } +#line 158 err = nc_close (ncid); +#line 158 IF (err) +#line 158 error("nc_close: %s", nc_strerror(err)); +#line 158 print_nok(nok); +#line 158 } +#line 158 /* +#line 159 * check all vars in file which are (text/numeric) compatible with TYPE +#line 159 */ +#line 159 static +#line 159 void +#line 159 check_vars_int(const char *filename) +#line 159 { +#line 159 int ncid; /* netCDF id */ +#line 159 size_t index[MAX_RANK]; +#line 159 int err; /* status */ +#line 159 int d; +#line 159 int i; +#line 159 size_t j; +#line 159 int value; +#line 159 nc_type datatype; +#line 159 int ndims; +#line 159 int dimids[MAX_RANK]; +#line 159 double expect; +#line 159 char name[NC_MAX_NAME]; +#line 159 size_t length; +#line 159 int canConvert; /* Both text or both numeric */ +#line 159 int nok = 0; /* count of valid comparisons */ +#line 159 +#line 159 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 159 IF (err) +#line 159 error("nc_open: %s", nc_strerror(err)); +#line 159 +#line 159 for (i = 0; i < NVARS; i++) { +#line 159 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 159 if (canConvert) { +#line 159 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 159 IF (err) +#line 159 error("nc_inq_var: %s", nc_strerror(err)); +#line 159 IF (strcmp(name, var_name[i]) != 0) +#line 159 error("Unexpected var_name"); +#line 159 IF (datatype != var_type[i]) +#line 159 error("Unexpected type"); +#line 159 IF (ndims != var_rank[i]) +#line 159 error("Unexpected rank"); +#line 159 for (j = 0; j < ndims; j++) { +#line 159 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 159 IF (err) +#line 159 error("nc_inq_dim: %s", nc_strerror(err)); +#line 159 IF (length != var_shape[i][j]) +#line 159 error("Unexpected shape"); +#line 159 } +#line 159 for (j = 0; j < var_nels[i]; j++) { +#line 159 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 159 IF (err) +#line 159 error("error in toMixedBase 2"); +#line 159 expect = hash4( var_type[i], var_rank[i], index, NCT_INT); +#line 159 err = nc_get_var1_int(ncid, i, index, &value); +#line 159 if (inRange3(expect,datatype,NCT_INT)) { +#line 159 if (expect >= int_min && expect <= int_max) { +#line 159 IF (err) { +#line 159 error("nc_get_var1_int: %s", nc_strerror(err)); +#line 159 } else { +#line 159 IF (!equal(value,expect,var_type[i],NCT_INT)) { +#line 159 error("Var value read not that expected"); +#line 159 if (verbose) { +#line 159 error("\n"); +#line 159 error("varid: %d, ", i); +#line 159 error("var_name: %s, ", var_name[i]); +#line 159 error("index:"); +#line 159 for (d = 0; d < var_rank[i]; d++) +#line 159 error(" %d", index[d]); +#line 159 error(", expect: %g, ", expect); +#line 159 error("got: %g", (double) value); +#line 159 } +#line 159 } else { +#line 159 ++nok; +#line 159 } +#line 159 } +#line 159 } +#line 159 } +#line 159 } +#line 159 } +#line 159 } +#line 159 err = nc_close (ncid); +#line 159 IF (err) +#line 159 error("nc_close: %s", nc_strerror(err)); +#line 159 print_nok(nok); +#line 159 } +#line 159 /* +#line 160 * check all vars in file which are (text/numeric) compatible with TYPE +#line 160 */ +#line 160 static +#line 160 void +#line 160 check_vars_long(const char *filename) +#line 160 { +#line 160 int ncid; /* netCDF id */ +#line 160 size_t index[MAX_RANK]; +#line 160 int err; /* status */ +#line 160 int d; +#line 160 int i; +#line 160 size_t j; +#line 160 long value; +#line 160 nc_type datatype; +#line 160 int ndims; +#line 160 int dimids[MAX_RANK]; +#line 160 double expect; +#line 160 char name[NC_MAX_NAME]; +#line 160 size_t length; +#line 160 int canConvert; /* Both text or both numeric */ +#line 160 int nok = 0; /* count of valid comparisons */ +#line 160 +#line 160 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 160 IF (err) +#line 160 error("nc_open: %s", nc_strerror(err)); +#line 160 +#line 160 for (i = 0; i < NVARS; i++) { +#line 160 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 160 if (canConvert) { +#line 160 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 160 IF (err) +#line 160 error("nc_inq_var: %s", nc_strerror(err)); +#line 160 IF (strcmp(name, var_name[i]) != 0) +#line 160 error("Unexpected var_name"); +#line 160 IF (datatype != var_type[i]) +#line 160 error("Unexpected type"); +#line 160 IF (ndims != var_rank[i]) +#line 160 error("Unexpected rank"); +#line 160 for (j = 0; j < ndims; j++) { +#line 160 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 160 IF (err) +#line 160 error("nc_inq_dim: %s", nc_strerror(err)); +#line 160 IF (length != var_shape[i][j]) +#line 160 error("Unexpected shape"); +#line 160 } +#line 160 for (j = 0; j < var_nels[i]; j++) { +#line 160 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 160 IF (err) +#line 160 error("error in toMixedBase 2"); +#line 160 expect = hash4( var_type[i], var_rank[i], index, NCT_LONG); +#line 160 err = nc_get_var1_long(ncid, i, index, &value); +#line 160 if (inRange3(expect,datatype,NCT_LONG)) { +#line 160 if (expect >= long_min && expect <= long_max) { +#line 160 IF (err) { +#line 160 error("nc_get_var1_long: %s", nc_strerror(err)); +#line 160 } else { +#line 160 IF (!equal(value,expect,var_type[i],NCT_LONG)) { +#line 160 error("Var value read not that expected"); +#line 160 if (verbose) { +#line 160 error("\n"); +#line 160 error("varid: %d, ", i); +#line 160 error("var_name: %s, ", var_name[i]); +#line 160 error("index:"); +#line 160 for (d = 0; d < var_rank[i]; d++) +#line 160 error(" %d", index[d]); +#line 160 error(", expect: %g, ", expect); +#line 160 error("got: %g", (double) value); +#line 160 } +#line 160 } else { +#line 160 ++nok; +#line 160 } +#line 160 } +#line 160 } +#line 160 } +#line 160 } +#line 160 } +#line 160 } +#line 160 err = nc_close (ncid); +#line 160 IF (err) +#line 160 error("nc_close: %s", nc_strerror(err)); +#line 160 print_nok(nok); +#line 160 } +#line 160 /* +#line 161 * check all vars in file which are (text/numeric) compatible with TYPE +#line 161 */ +#line 161 static +#line 161 void +#line 161 check_vars_float(const char *filename) +#line 161 { +#line 161 int ncid; /* netCDF id */ +#line 161 size_t index[MAX_RANK]; +#line 161 int err; /* status */ +#line 161 int d; +#line 161 int i; +#line 161 size_t j; +#line 161 float value; +#line 161 nc_type datatype; +#line 161 int ndims; +#line 161 int dimids[MAX_RANK]; +#line 161 double expect; +#line 161 char name[NC_MAX_NAME]; +#line 161 size_t length; +#line 161 int canConvert; /* Both text or both numeric */ +#line 161 int nok = 0; /* count of valid comparisons */ +#line 161 +#line 161 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 161 IF (err) +#line 161 error("nc_open: %s", nc_strerror(err)); +#line 161 +#line 161 for (i = 0; i < NVARS; i++) { +#line 161 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 161 if (canConvert) { +#line 161 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 161 IF (err) +#line 161 error("nc_inq_var: %s", nc_strerror(err)); +#line 161 IF (strcmp(name, var_name[i]) != 0) +#line 161 error("Unexpected var_name"); +#line 161 IF (datatype != var_type[i]) +#line 161 error("Unexpected type"); +#line 161 IF (ndims != var_rank[i]) +#line 161 error("Unexpected rank"); +#line 161 for (j = 0; j < ndims; j++) { +#line 161 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 161 IF (err) +#line 161 error("nc_inq_dim: %s", nc_strerror(err)); +#line 161 IF (length != var_shape[i][j]) +#line 161 error("Unexpected shape"); +#line 161 } +#line 161 for (j = 0; j < var_nels[i]; j++) { +#line 161 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 161 IF (err) +#line 161 error("error in toMixedBase 2"); +#line 161 expect = hash4( var_type[i], var_rank[i], index, NCT_FLOAT); +#line 161 err = nc_get_var1_float(ncid, i, index, &value); +#line 161 if (inRange3(expect,datatype,NCT_FLOAT)) { +#line 161 if (expect >= float_min && expect <= float_max) { +#line 161 IF (err) { +#line 161 error("nc_get_var1_float: %s", nc_strerror(err)); +#line 161 } else { +#line 161 IF (!equal(value,expect,var_type[i],NCT_FLOAT)) { +#line 161 error("Var value read not that expected"); +#line 161 if (verbose) { +#line 161 error("\n"); +#line 161 error("varid: %d, ", i); +#line 161 error("var_name: %s, ", var_name[i]); +#line 161 error("index:"); +#line 161 for (d = 0; d < var_rank[i]; d++) +#line 161 error(" %d", index[d]); +#line 161 error(", expect: %g, ", expect); +#line 161 error("got: %g", (double) value); +#line 161 } +#line 161 } else { +#line 161 ++nok; +#line 161 } +#line 161 } +#line 161 } +#line 161 } +#line 161 } +#line 161 } +#line 161 } +#line 161 err = nc_close (ncid); +#line 161 IF (err) +#line 161 error("nc_close: %s", nc_strerror(err)); +#line 161 print_nok(nok); +#line 161 } +#line 161 /* +#line 162 * check all vars in file which are (text/numeric) compatible with TYPE +#line 162 */ +#line 162 static +#line 162 void +#line 162 check_vars_double(const char *filename) +#line 162 { +#line 162 int ncid; /* netCDF id */ +#line 162 size_t index[MAX_RANK]; +#line 162 int err; /* status */ +#line 162 int d; +#line 162 int i; +#line 162 size_t j; +#line 162 double value; +#line 162 nc_type datatype; +#line 162 int ndims; +#line 162 int dimids[MAX_RANK]; +#line 162 double expect; +#line 162 char name[NC_MAX_NAME]; +#line 162 size_t length; +#line 162 int canConvert; /* Both text or both numeric */ +#line 162 int nok = 0; /* count of valid comparisons */ +#line 162 +#line 162 err = nc_open(filename, NC_NOWRITE, &ncid); +#line 162 IF (err) +#line 162 error("nc_open: %s", nc_strerror(err)); +#line 162 +#line 162 for (i = 0; i < NVARS; i++) { +#line 162 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 162 if (canConvert) { +#line 162 err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL); +#line 162 IF (err) +#line 162 error("nc_inq_var: %s", nc_strerror(err)); +#line 162 IF (strcmp(name, var_name[i]) != 0) +#line 162 error("Unexpected var_name"); +#line 162 IF (datatype != var_type[i]) +#line 162 error("Unexpected type"); +#line 162 IF (ndims != var_rank[i]) +#line 162 error("Unexpected rank"); +#line 162 for (j = 0; j < ndims; j++) { +#line 162 err = nc_inq_dim(ncid, dimids[j], 0, &length); +#line 162 IF (err) +#line 162 error("nc_inq_dim: %s", nc_strerror(err)); +#line 162 IF (length != var_shape[i][j]) +#line 162 error("Unexpected shape"); +#line 162 } +#line 162 for (j = 0; j < var_nels[i]; j++) { +#line 162 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 162 IF (err) +#line 162 error("error in toMixedBase 2"); +#line 162 expect = hash4( var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 162 err = nc_get_var1_double(ncid, i, index, &value); +#line 162 if (inRange3(expect,datatype,NCT_DOUBLE)) { +#line 162 if (expect >= double_min && expect <= double_max) { +#line 162 IF (err) { +#line 162 error("nc_get_var1_double: %s", nc_strerror(err)); +#line 162 } else { +#line 162 IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) { +#line 162 error("Var value read not that expected"); +#line 162 if (verbose) { +#line 162 error("\n"); +#line 162 error("varid: %d, ", i); +#line 162 error("var_name: %s, ", var_name[i]); +#line 162 error("index:"); +#line 162 for (d = 0; d < var_rank[i]; d++) +#line 162 error(" %d", index[d]); +#line 162 error(", expect: %g, ", expect); +#line 162 error("got: %g", (double) value); +#line 162 } +#line 162 } else { +#line 162 ++nok; +#line 162 } +#line 162 } +#line 162 } +#line 162 } +#line 162 } +#line 162 } +#line 162 } +#line 162 err = nc_close (ncid); +#line 162 IF (err) +#line 162 error("nc_close: %s", nc_strerror(err)); +#line 162 print_nok(nok); +#line 162 } +#line 162 +#line 244 /* +#line 245 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 245 * ignore any attributes containing values outside range of TYPE +#line 245 */ +#line 245 static +#line 245 void +#line 245 check_atts_text(int ncid) +#line 245 { +#line 245 int err; /* status */ +#line 245 int i; +#line 245 int j; +#line 245 size_t k; +#line 245 text value[MAX_NELS]; +#line 245 nc_type datatype; +#line 245 double expect[MAX_NELS]; +#line 245 size_t length; +#line 245 size_t nInExtRange; /* number values within external range */ +#line 245 size_t nInIntRange; /* number values within internal range */ +#line 245 int canConvert; /* Both text or both numeric */ +#line 245 int nok = 0; /* count of valid comparisons */ +#line 245 +#line 245 for (i = -1; i < NVARS; i++) { +#line 245 for (j = 0; j < NATTS(i); j++) { +#line 245 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 245 if (canConvert) { +#line 245 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 245 IF (err) +#line 245 error("nc_inq_att: %s", nc_strerror(err)); +#line 245 IF (datatype != ATT_TYPE(i,j)) +#line 245 error("nc_inq_att: unexpected type"); +#line 245 IF (length != ATT_LEN(i,j)) +#line 245 error("nc_inq_att: unexpected length"); +#line 245 assert(length <= MAX_NELS); +#line 245 nInIntRange = nInExtRange = 0; +#line 245 for (k = 0; k < length; k++) { +#line 245 expect[k] = hash4( datatype, -1, &k, NCT_TEXT); +#line 245 if (inRange3(expect[k], datatype, NCT_TEXT)) { +#line 245 ++nInExtRange; +#line 245 if (expect[k] >= text_min && expect[k] <= text_max) +#line 245 ++nInIntRange; +#line 245 } +#line 245 } +#line 245 err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value); +#line 245 if (nInExtRange == length && nInIntRange == length) { +#line 245 IF (err) +#line 245 error("%s", nc_strerror(err)); +#line 245 } else { +#line 245 IF (err != 0 && err != NC_ERANGE) +#line 245 error("OK or Range error: status = %d", err); +#line 245 } +#line 245 for (k = 0; k < length; k++) { +#line 245 if (inRange3(expect[k],datatype,NCT_TEXT) +#line 245 && expect[k] >= text_min && expect[k] <= text_max) { +#line 245 IF (!equal(value[k],expect[k],datatype,NCT_TEXT)) { +#line 245 error("att. value read not that expected"); +#line 245 if (verbose) { +#line 245 error("\n"); +#line 245 error("varid: %d, ", i); +#line 245 error("att_name: %s, ", ATT_NAME(i,j)); +#line 245 error("element number: %d ", k); +#line 245 error("expect: %g, ", expect[k]); +#line 245 error("got: %g", (double) value[k]); +#line 245 } +#line 245 } else { +#line 245 nok++; +#line 245 } +#line 245 } +#line 245 } +#line 245 } +#line 245 } +#line 245 } +#line 245 +#line 245 print_nok(nok); +#line 245 } +#line 245 /* +#line 246 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 246 * ignore any attributes containing values outside range of TYPE +#line 246 */ +#line 246 static +#line 246 void +#line 246 check_atts_uchar(int ncid) +#line 246 { +#line 246 int err; /* status */ +#line 246 int i; +#line 246 int j; +#line 246 size_t k; +#line 246 uchar value[MAX_NELS]; +#line 246 nc_type datatype; +#line 246 double expect[MAX_NELS]; +#line 246 size_t length; +#line 246 size_t nInExtRange; /* number values within external range */ +#line 246 size_t nInIntRange; /* number values within internal range */ +#line 246 int canConvert; /* Both text or both numeric */ +#line 246 int nok = 0; /* count of valid comparisons */ +#line 246 +#line 246 for (i = -1; i < NVARS; i++) { +#line 246 for (j = 0; j < NATTS(i); j++) { +#line 246 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 246 if (canConvert) { +#line 246 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 246 IF (err) +#line 246 error("nc_inq_att: %s", nc_strerror(err)); +#line 246 IF (datatype != ATT_TYPE(i,j)) +#line 246 error("nc_inq_att: unexpected type"); +#line 246 IF (length != ATT_LEN(i,j)) +#line 246 error("nc_inq_att: unexpected length"); +#line 246 assert(length <= MAX_NELS); +#line 246 nInIntRange = nInExtRange = 0; +#line 246 for (k = 0; k < length; k++) { +#line 246 expect[k] = hash4( datatype, -1, &k, NCT_UCHAR); +#line 246 if (inRange3(expect[k], datatype, NCT_UCHAR)) { +#line 246 ++nInExtRange; +#line 246 if (expect[k] >= uchar_min && expect[k] <= uchar_max) +#line 246 ++nInIntRange; +#line 246 } +#line 246 } +#line 246 err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value); +#line 246 if (nInExtRange == length && nInIntRange == length) { +#line 246 IF (err) +#line 246 error("%s", nc_strerror(err)); +#line 246 } else { +#line 246 IF (err != 0 && err != NC_ERANGE) +#line 246 error("OK or Range error: status = %d", err); +#line 246 } +#line 246 for (k = 0; k < length; k++) { +#line 246 if (inRange3(expect[k],datatype,NCT_UCHAR) +#line 246 && expect[k] >= uchar_min && expect[k] <= uchar_max) { +#line 246 IF (!equal(value[k],expect[k],datatype,NCT_UCHAR)) { +#line 246 error("att. value read not that expected"); +#line 246 if (verbose) { +#line 246 error("\n"); +#line 246 error("varid: %d, ", i); +#line 246 error("att_name: %s, ", ATT_NAME(i,j)); +#line 246 error("element number: %d ", k); +#line 246 error("expect: %g, ", expect[k]); +#line 246 error("got: %g", (double) value[k]); +#line 246 } +#line 246 } else { +#line 246 nok++; +#line 246 } +#line 246 } +#line 246 } +#line 246 } +#line 246 } +#line 246 } +#line 246 +#line 246 print_nok(nok); +#line 246 } +#line 246 /* +#line 247 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 247 * ignore any attributes containing values outside range of TYPE +#line 247 */ +#line 247 static +#line 247 void +#line 247 check_atts_schar(int ncid) +#line 247 { +#line 247 int err; /* status */ +#line 247 int i; +#line 247 int j; +#line 247 size_t k; +#line 247 schar value[MAX_NELS]; +#line 247 nc_type datatype; +#line 247 double expect[MAX_NELS]; +#line 247 size_t length; +#line 247 size_t nInExtRange; /* number values within external range */ +#line 247 size_t nInIntRange; /* number values within internal range */ +#line 247 int canConvert; /* Both text or both numeric */ +#line 247 int nok = 0; /* count of valid comparisons */ +#line 247 +#line 247 for (i = -1; i < NVARS; i++) { +#line 247 for (j = 0; j < NATTS(i); j++) { +#line 247 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 247 if (canConvert) { +#line 247 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 247 IF (err) +#line 247 error("nc_inq_att: %s", nc_strerror(err)); +#line 247 IF (datatype != ATT_TYPE(i,j)) +#line 247 error("nc_inq_att: unexpected type"); +#line 247 IF (length != ATT_LEN(i,j)) +#line 247 error("nc_inq_att: unexpected length"); +#line 247 assert(length <= MAX_NELS); +#line 247 nInIntRange = nInExtRange = 0; +#line 247 for (k = 0; k < length; k++) { +#line 247 expect[k] = hash4( datatype, -1, &k, NCT_SCHAR); +#line 247 if (inRange3(expect[k], datatype, NCT_SCHAR)) { +#line 247 ++nInExtRange; +#line 247 if (expect[k] >= schar_min && expect[k] <= schar_max) +#line 247 ++nInIntRange; +#line 247 } +#line 247 } +#line 247 err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value); +#line 247 if (nInExtRange == length && nInIntRange == length) { +#line 247 IF (err) +#line 247 error("%s", nc_strerror(err)); +#line 247 } else { +#line 247 IF (err != 0 && err != NC_ERANGE) +#line 247 error("OK or Range error: status = %d", err); +#line 247 } +#line 247 for (k = 0; k < length; k++) { +#line 247 if (inRange3(expect[k],datatype,NCT_SCHAR) +#line 247 && expect[k] >= schar_min && expect[k] <= schar_max) { +#line 247 IF (!equal(value[k],expect[k],datatype,NCT_SCHAR)) { +#line 247 error("att. value read not that expected"); +#line 247 if (verbose) { +#line 247 error("\n"); +#line 247 error("varid: %d, ", i); +#line 247 error("att_name: %s, ", ATT_NAME(i,j)); +#line 247 error("element number: %d ", k); +#line 247 error("expect: %g, ", expect[k]); +#line 247 error("got: %g", (double) value[k]); +#line 247 } +#line 247 } else { +#line 247 nok++; +#line 247 } +#line 247 } +#line 247 } +#line 247 } +#line 247 } +#line 247 } +#line 247 +#line 247 print_nok(nok); +#line 247 } +#line 247 /* +#line 248 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 248 * ignore any attributes containing values outside range of TYPE +#line 248 */ +#line 248 static +#line 248 void +#line 248 check_atts_short(int ncid) +#line 248 { +#line 248 int err; /* status */ +#line 248 int i; +#line 248 int j; +#line 248 size_t k; +#line 248 short value[MAX_NELS]; +#line 248 nc_type datatype; +#line 248 double expect[MAX_NELS]; +#line 248 size_t length; +#line 248 size_t nInExtRange; /* number values within external range */ +#line 248 size_t nInIntRange; /* number values within internal range */ +#line 248 int canConvert; /* Both text or both numeric */ +#line 248 int nok = 0; /* count of valid comparisons */ +#line 248 +#line 248 for (i = -1; i < NVARS; i++) { +#line 248 for (j = 0; j < NATTS(i); j++) { +#line 248 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 248 if (canConvert) { +#line 248 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 248 IF (err) +#line 248 error("nc_inq_att: %s", nc_strerror(err)); +#line 248 IF (datatype != ATT_TYPE(i,j)) +#line 248 error("nc_inq_att: unexpected type"); +#line 248 IF (length != ATT_LEN(i,j)) +#line 248 error("nc_inq_att: unexpected length"); +#line 248 assert(length <= MAX_NELS); +#line 248 nInIntRange = nInExtRange = 0; +#line 248 for (k = 0; k < length; k++) { +#line 248 expect[k] = hash4( datatype, -1, &k, NCT_SHORT); +#line 248 if (inRange3(expect[k], datatype, NCT_SHORT)) { +#line 248 ++nInExtRange; +#line 248 if (expect[k] >= short_min && expect[k] <= short_max) +#line 248 ++nInIntRange; +#line 248 } +#line 248 } +#line 248 err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value); +#line 248 if (nInExtRange == length && nInIntRange == length) { +#line 248 IF (err) +#line 248 error("%s", nc_strerror(err)); +#line 248 } else { +#line 248 IF (err != 0 && err != NC_ERANGE) +#line 248 error("OK or Range error: status = %d", err); +#line 248 } +#line 248 for (k = 0; k < length; k++) { +#line 248 if (inRange3(expect[k],datatype,NCT_SHORT) +#line 248 && expect[k] >= short_min && expect[k] <= short_max) { +#line 248 IF (!equal(value[k],expect[k],datatype,NCT_SHORT)) { +#line 248 error("att. value read not that expected"); +#line 248 if (verbose) { +#line 248 error("\n"); +#line 248 error("varid: %d, ", i); +#line 248 error("att_name: %s, ", ATT_NAME(i,j)); +#line 248 error("element number: %d ", k); +#line 248 error("expect: %g, ", expect[k]); +#line 248 error("got: %g", (double) value[k]); +#line 248 } +#line 248 } else { +#line 248 nok++; +#line 248 } +#line 248 } +#line 248 } +#line 248 } +#line 248 } +#line 248 } +#line 248 +#line 248 print_nok(nok); +#line 248 } +#line 248 /* +#line 249 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 249 * ignore any attributes containing values outside range of TYPE +#line 249 */ +#line 249 static +#line 249 void +#line 249 check_atts_int(int ncid) +#line 249 { +#line 249 int err; /* status */ +#line 249 int i; +#line 249 int j; +#line 249 size_t k; +#line 249 int value[MAX_NELS]; +#line 249 nc_type datatype; +#line 249 double expect[MAX_NELS]; +#line 249 size_t length; +#line 249 size_t nInExtRange; /* number values within external range */ +#line 249 size_t nInIntRange; /* number values within internal range */ +#line 249 int canConvert; /* Both text or both numeric */ +#line 249 int nok = 0; /* count of valid comparisons */ +#line 249 +#line 249 for (i = -1; i < NVARS; i++) { +#line 249 for (j = 0; j < NATTS(i); j++) { +#line 249 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 249 if (canConvert) { +#line 249 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 249 IF (err) +#line 249 error("nc_inq_att: %s", nc_strerror(err)); +#line 249 IF (datatype != ATT_TYPE(i,j)) +#line 249 error("nc_inq_att: unexpected type"); +#line 249 IF (length != ATT_LEN(i,j)) +#line 249 error("nc_inq_att: unexpected length"); +#line 249 assert(length <= MAX_NELS); +#line 249 nInIntRange = nInExtRange = 0; +#line 249 for (k = 0; k < length; k++) { +#line 249 expect[k] = hash4( datatype, -1, &k, NCT_INT); +#line 249 if (inRange3(expect[k], datatype, NCT_INT)) { +#line 249 ++nInExtRange; +#line 249 if (expect[k] >= int_min && expect[k] <= int_max) +#line 249 ++nInIntRange; +#line 249 } +#line 249 } +#line 249 err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value); +#line 249 if (nInExtRange == length && nInIntRange == length) { +#line 249 IF (err) +#line 249 error("%s", nc_strerror(err)); +#line 249 } else { +#line 249 IF (err != 0 && err != NC_ERANGE) +#line 249 error("OK or Range error: status = %d", err); +#line 249 } +#line 249 for (k = 0; k < length; k++) { +#line 249 if (inRange3(expect[k],datatype,NCT_INT) +#line 249 && expect[k] >= int_min && expect[k] <= int_max) { +#line 249 IF (!equal(value[k],expect[k],datatype,NCT_INT)) { +#line 249 error("att. value read not that expected"); +#line 249 if (verbose) { +#line 249 error("\n"); +#line 249 error("varid: %d, ", i); +#line 249 error("att_name: %s, ", ATT_NAME(i,j)); +#line 249 error("element number: %d ", k); +#line 249 error("expect: %g, ", expect[k]); +#line 249 error("got: %g", (double) value[k]); +#line 249 } +#line 249 } else { +#line 249 nok++; +#line 249 } +#line 249 } +#line 249 } +#line 249 } +#line 249 } +#line 249 } +#line 249 +#line 249 print_nok(nok); +#line 249 } +#line 249 /* +#line 250 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 250 * ignore any attributes containing values outside range of TYPE +#line 250 */ +#line 250 static +#line 250 void +#line 250 check_atts_long(int ncid) +#line 250 { +#line 250 int err; /* status */ +#line 250 int i; +#line 250 int j; +#line 250 size_t k; +#line 250 long value[MAX_NELS]; +#line 250 nc_type datatype; +#line 250 double expect[MAX_NELS]; +#line 250 size_t length; +#line 250 size_t nInExtRange; /* number values within external range */ +#line 250 size_t nInIntRange; /* number values within internal range */ +#line 250 int canConvert; /* Both text or both numeric */ +#line 250 int nok = 0; /* count of valid comparisons */ +#line 250 +#line 250 for (i = -1; i < NVARS; i++) { +#line 250 for (j = 0; j < NATTS(i); j++) { +#line 250 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 250 if (canConvert) { +#line 250 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 250 IF (err) +#line 250 error("nc_inq_att: %s", nc_strerror(err)); +#line 250 IF (datatype != ATT_TYPE(i,j)) +#line 250 error("nc_inq_att: unexpected type"); +#line 250 IF (length != ATT_LEN(i,j)) +#line 250 error("nc_inq_att: unexpected length"); +#line 250 assert(length <= MAX_NELS); +#line 250 nInIntRange = nInExtRange = 0; +#line 250 for (k = 0; k < length; k++) { +#line 250 expect[k] = hash4( datatype, -1, &k, NCT_LONG); +#line 250 if (inRange3(expect[k], datatype, NCT_LONG)) { +#line 250 ++nInExtRange; +#line 250 if (expect[k] >= long_min && expect[k] <= long_max) +#line 250 ++nInIntRange; +#line 250 } +#line 250 } +#line 250 err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value); +#line 250 if (nInExtRange == length && nInIntRange == length) { +#line 250 IF (err) +#line 250 error("%s", nc_strerror(err)); +#line 250 } else { +#line 250 IF (err != 0 && err != NC_ERANGE) +#line 250 error("OK or Range error: status = %d", err); +#line 250 } +#line 250 for (k = 0; k < length; k++) { +#line 250 if (inRange3(expect[k],datatype,NCT_LONG) +#line 250 && expect[k] >= long_min && expect[k] <= long_max) { +#line 250 IF (!equal(value[k],expect[k],datatype,NCT_LONG)) { +#line 250 error("att. value read not that expected"); +#line 250 if (verbose) { +#line 250 error("\n"); +#line 250 error("varid: %d, ", i); +#line 250 error("att_name: %s, ", ATT_NAME(i,j)); +#line 250 error("element number: %d ", k); +#line 250 error("expect: %g, ", expect[k]); +#line 250 error("got: %g", (double) value[k]); +#line 250 } +#line 250 } else { +#line 250 nok++; +#line 250 } +#line 250 } +#line 250 } +#line 250 } +#line 250 } +#line 250 } +#line 250 +#line 250 print_nok(nok); +#line 250 } +#line 250 /* +#line 251 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 251 * ignore any attributes containing values outside range of TYPE +#line 251 */ +#line 251 static +#line 251 void +#line 251 check_atts_float(int ncid) +#line 251 { +#line 251 int err; /* status */ +#line 251 int i; +#line 251 int j; +#line 251 size_t k; +#line 251 float value[MAX_NELS]; +#line 251 nc_type datatype; +#line 251 double expect[MAX_NELS]; +#line 251 size_t length; +#line 251 size_t nInExtRange; /* number values within external range */ +#line 251 size_t nInIntRange; /* number values within internal range */ +#line 251 int canConvert; /* Both text or both numeric */ +#line 251 int nok = 0; /* count of valid comparisons */ +#line 251 +#line 251 for (i = -1; i < NVARS; i++) { +#line 251 for (j = 0; j < NATTS(i); j++) { +#line 251 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 251 if (canConvert) { +#line 251 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 251 IF (err) +#line 251 error("nc_inq_att: %s", nc_strerror(err)); +#line 251 IF (datatype != ATT_TYPE(i,j)) +#line 251 error("nc_inq_att: unexpected type"); +#line 251 IF (length != ATT_LEN(i,j)) +#line 251 error("nc_inq_att: unexpected length"); +#line 251 assert(length <= MAX_NELS); +#line 251 nInIntRange = nInExtRange = 0; +#line 251 for (k = 0; k < length; k++) { +#line 251 expect[k] = hash4( datatype, -1, &k, NCT_FLOAT); +#line 251 if (inRange3(expect[k], datatype, NCT_FLOAT)) { +#line 251 ++nInExtRange; +#line 251 if (expect[k] >= float_min && expect[k] <= float_max) +#line 251 ++nInIntRange; +#line 251 } +#line 251 } +#line 251 err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value); +#line 251 if (nInExtRange == length && nInIntRange == length) { +#line 251 IF (err) +#line 251 error("%s", nc_strerror(err)); +#line 251 } else { +#line 251 IF (err != 0 && err != NC_ERANGE) +#line 251 error("OK or Range error: status = %d", err); +#line 251 } +#line 251 for (k = 0; k < length; k++) { +#line 251 if (inRange3(expect[k],datatype,NCT_FLOAT) +#line 251 && expect[k] >= float_min && expect[k] <= float_max) { +#line 251 IF (!equal(value[k],expect[k],datatype,NCT_FLOAT)) { +#line 251 error("att. value read not that expected"); +#line 251 if (verbose) { +#line 251 error("\n"); +#line 251 error("varid: %d, ", i); +#line 251 error("att_name: %s, ", ATT_NAME(i,j)); +#line 251 error("element number: %d ", k); +#line 251 error("expect: %g, ", expect[k]); +#line 251 error("got: %g", (double) value[k]); +#line 251 } +#line 251 } else { +#line 251 nok++; +#line 251 } +#line 251 } +#line 251 } +#line 251 } +#line 251 } +#line 251 } +#line 251 +#line 251 print_nok(nok); +#line 251 } +#line 251 /* +#line 252 * check all attributes in file which are (text/numeric) compatible with TYPE +#line 252 * ignore any attributes containing values outside range of TYPE +#line 252 */ +#line 252 static +#line 252 void +#line 252 check_atts_double(int ncid) +#line 252 { +#line 252 int err; /* status */ +#line 252 int i; +#line 252 int j; +#line 252 size_t k; +#line 252 double value[MAX_NELS]; +#line 252 nc_type datatype; +#line 252 double expect[MAX_NELS]; +#line 252 size_t length; +#line 252 size_t nInExtRange; /* number values within external range */ +#line 252 size_t nInIntRange; /* number values within internal range */ +#line 252 int canConvert; /* Both text or both numeric */ +#line 252 int nok = 0; /* count of valid comparisons */ +#line 252 +#line 252 for (i = -1; i < NVARS; i++) { +#line 252 for (j = 0; j < NATTS(i); j++) { +#line 252 canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 252 if (canConvert) { +#line 252 err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length); +#line 252 IF (err) +#line 252 error("nc_inq_att: %s", nc_strerror(err)); +#line 252 IF (datatype != ATT_TYPE(i,j)) +#line 252 error("nc_inq_att: unexpected type"); +#line 252 IF (length != ATT_LEN(i,j)) +#line 252 error("nc_inq_att: unexpected length"); +#line 252 assert(length <= MAX_NELS); +#line 252 nInIntRange = nInExtRange = 0; +#line 252 for (k = 0; k < length; k++) { +#line 252 expect[k] = hash4( datatype, -1, &k, NCT_DOUBLE); +#line 252 if (inRange3(expect[k], datatype, NCT_DOUBLE)) { +#line 252 ++nInExtRange; +#line 252 if (expect[k] >= double_min && expect[k] <= double_max) +#line 252 ++nInIntRange; +#line 252 } +#line 252 } +#line 252 err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value); +#line 252 if (nInExtRange == length && nInIntRange == length) { +#line 252 IF (err) +#line 252 error("%s", nc_strerror(err)); +#line 252 } else { +#line 252 IF (err != 0 && err != NC_ERANGE) +#line 252 error("OK or Range error: status = %d", err); +#line 252 } +#line 252 for (k = 0; k < length; k++) { +#line 252 if (inRange3(expect[k],datatype,NCT_DOUBLE) +#line 252 && expect[k] >= double_min && expect[k] <= double_max) { +#line 252 IF (!equal(value[k],expect[k],datatype,NCT_DOUBLE)) { +#line 252 error("att. value read not that expected"); +#line 252 if (verbose) { +#line 252 error("\n"); +#line 252 error("varid: %d, ", i); +#line 252 error("att_name: %s, ", ATT_NAME(i,j)); +#line 252 error("element number: %d ", k); +#line 252 error("expect: %g, ", expect[k]); +#line 252 error("got: %g", (double) value[k]); +#line 252 } +#line 252 } else { +#line 252 nok++; +#line 252 } +#line 252 } +#line 252 } +#line 252 } +#line 252 } +#line 252 } +#line 252 +#line 252 print_nok(nok); +#line 252 } +#line 252 +#line 339 void +#line 340 test_nc_put_var1_text(void) +#line 340 { +#line 340 int ncid; +#line 340 int i; +#line 340 int j; +#line 340 int err; +#line 340 size_t index[MAX_RANK]; +#line 340 int canConvert; /* Both text or both numeric */ +#line 340 text value = 5; /* any value would do - only for error cases */ +#line 340 +#line 340 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 340 IF (err) { +#line 340 error("nc_create: %s", nc_strerror(err)); +#line 340 return; +#line 340 } +#line 340 def_dims(ncid); +#line 340 def_vars(ncid); +#line 340 err = nc_enddef(ncid); +#line 340 IF (err) +#line 340 error("nc_enddef: %s", nc_strerror(err)); +#line 340 +#line 340 for (i = 0; i < NVARS; i++) { +#line 340 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 340 for (j = 0; j < var_rank[i]; j++) +#line 340 index[j] = 0; +#line 340 err = nc_put_var1_text(BAD_ID, i, index, &value); +#line 340 IF (err != NC_EBADID) +#line 340 error("bad ncid: status = %d", err); +#line 340 err = nc_put_var1_text(ncid, BAD_VARID, index, &value); +#line 340 IF (err != NC_ENOTVAR) +#line 340 error("bad var id: status = %d", err); +#line 340 for (j = 0; j < var_rank[i]; j++) { +#line 340 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 340 index[j] = var_shape[i][j]; +#line 340 err = nc_put_var1_text(ncid, i, index, &value); +#line 340 IF (canConvert && err != NC_EINVALCOORDS) +#line 340 error("bad index: status = %d", err); +#line 340 index[j] = 0; +#line 340 } +#line 340 } +#line 340 for (j = 0; j < var_nels[i]; j++) { +#line 340 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 340 IF (err) +#line 340 error("error in toMixedBase 1"); +#line 340 value = hash_text( var_type[i], var_rank[i], index, NCT_TEXT); +#line 340 if (var_rank[i] == 0 && i%2 == 0) +#line 340 err = nc_put_var1_text(ncid, i, NULL, &value); +#line 340 else +#line 340 err = nc_put_var1_text(ncid, i, index, &value); +#line 340 if (canConvert) { +#line 340 if (inRange3(value, var_type[i],NCT_TEXT)) { +#line 340 IF (err) +#line 340 error("%s", nc_strerror(err)); +#line 340 } else { +#line 340 IF (err != NC_ERANGE) { +#line 340 error("Range error: status = %d", err); +#line 340 error("\n\t\tfor type %s value %.17e %ld", +#line 340 s_nc_type(var_type[i]), +#line 340 (double)value, (long)value); +#line 340 } +#line 340 } +#line 340 } else { +#line 340 IF (err != NC_ECHAR) +#line 340 error("wrong type: status = %d", err); +#line 340 } +#line 340 } +#line 340 } +#line 340 +#line 340 err = nc_close(ncid); +#line 340 IF (err) +#line 340 error("nc_close: %s", nc_strerror(err)); +#line 340 +#line 340 check_vars_text(scratch); +#line 340 +#line 340 err = remove(scratch); +#line 340 IF (err) +#line 340 error("remove of %s failed", scratch); +#line 340 } +#line 340 void +#line 341 test_nc_put_var1_uchar(void) +#line 341 { +#line 341 int ncid; +#line 341 int i; +#line 341 int j; +#line 341 int err; +#line 341 size_t index[MAX_RANK]; +#line 341 int canConvert; /* Both text or both numeric */ +#line 341 uchar value = 5; /* any value would do - only for error cases */ +#line 341 +#line 341 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 341 IF (err) { +#line 341 error("nc_create: %s", nc_strerror(err)); +#line 341 return; +#line 341 } +#line 341 def_dims(ncid); +#line 341 def_vars(ncid); +#line 341 err = nc_enddef(ncid); +#line 341 IF (err) +#line 341 error("nc_enddef: %s", nc_strerror(err)); +#line 341 +#line 341 for (i = 0; i < NVARS; i++) { +#line 341 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 341 for (j = 0; j < var_rank[i]; j++) +#line 341 index[j] = 0; +#line 341 err = nc_put_var1_uchar(BAD_ID, i, index, &value); +#line 341 IF (err != NC_EBADID) +#line 341 error("bad ncid: status = %d", err); +#line 341 err = nc_put_var1_uchar(ncid, BAD_VARID, index, &value); +#line 341 IF (err != NC_ENOTVAR) +#line 341 error("bad var id: status = %d", err); +#line 341 for (j = 0; j < var_rank[i]; j++) { +#line 341 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 341 index[j] = var_shape[i][j]; +#line 341 err = nc_put_var1_uchar(ncid, i, index, &value); +#line 341 IF (canConvert && err != NC_EINVALCOORDS) +#line 341 error("bad index: status = %d", err); +#line 341 index[j] = 0; +#line 341 } +#line 341 } +#line 341 for (j = 0; j < var_nels[i]; j++) { +#line 341 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 341 IF (err) +#line 341 error("error in toMixedBase 1"); +#line 341 value = hash_uchar( var_type[i], var_rank[i], index, NCT_UCHAR); +#line 341 if (var_rank[i] == 0 && i%2 == 0) +#line 341 err = nc_put_var1_uchar(ncid, i, NULL, &value); +#line 341 else +#line 341 err = nc_put_var1_uchar(ncid, i, index, &value); +#line 341 if (canConvert) { +#line 341 if (inRange3(value, var_type[i],NCT_UCHAR)) { +#line 341 IF (err) +#line 341 error("%s", nc_strerror(err)); +#line 341 } else { +#line 341 IF (err != NC_ERANGE) { +#line 341 error("Range error: status = %d", err); +#line 341 error("\n\t\tfor type %s value %.17e %ld", +#line 341 s_nc_type(var_type[i]), +#line 341 (double)value, (long)value); +#line 341 } +#line 341 } +#line 341 } else { +#line 341 IF (err != NC_ECHAR) +#line 341 error("wrong type: status = %d", err); +#line 341 } +#line 341 } +#line 341 } +#line 341 +#line 341 err = nc_close(ncid); +#line 341 IF (err) +#line 341 error("nc_close: %s", nc_strerror(err)); +#line 341 +#line 341 check_vars_uchar(scratch); +#line 341 +#line 341 err = remove(scratch); +#line 341 IF (err) +#line 341 error("remove of %s failed", scratch); +#line 341 } +#line 341 void +#line 342 test_nc_put_var1_schar(void) +#line 342 { +#line 342 int ncid; +#line 342 int i; +#line 342 int j; +#line 342 int err; +#line 342 size_t index[MAX_RANK]; +#line 342 int canConvert; /* Both text or both numeric */ +#line 342 schar value = 5; /* any value would do - only for error cases */ +#line 342 +#line 342 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 342 IF (err) { +#line 342 error("nc_create: %s", nc_strerror(err)); +#line 342 return; +#line 342 } +#line 342 def_dims(ncid); +#line 342 def_vars(ncid); +#line 342 err = nc_enddef(ncid); +#line 342 IF (err) +#line 342 error("nc_enddef: %s", nc_strerror(err)); +#line 342 +#line 342 for (i = 0; i < NVARS; i++) { +#line 342 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 342 for (j = 0; j < var_rank[i]; j++) +#line 342 index[j] = 0; +#line 342 err = nc_put_var1_schar(BAD_ID, i, index, &value); +#line 342 IF (err != NC_EBADID) +#line 342 error("bad ncid: status = %d", err); +#line 342 err = nc_put_var1_schar(ncid, BAD_VARID, index, &value); +#line 342 IF (err != NC_ENOTVAR) +#line 342 error("bad var id: status = %d", err); +#line 342 for (j = 0; j < var_rank[i]; j++) { +#line 342 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 342 index[j] = var_shape[i][j]; +#line 342 err = nc_put_var1_schar(ncid, i, index, &value); +#line 342 IF (canConvert && err != NC_EINVALCOORDS) +#line 342 error("bad index: status = %d", err); +#line 342 index[j] = 0; +#line 342 } +#line 342 } +#line 342 for (j = 0; j < var_nels[i]; j++) { +#line 342 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 342 IF (err) +#line 342 error("error in toMixedBase 1"); +#line 342 value = hash_schar( var_type[i], var_rank[i], index, NCT_SCHAR); +#line 342 if (var_rank[i] == 0 && i%2 == 0) +#line 342 err = nc_put_var1_schar(ncid, i, NULL, &value); +#line 342 else +#line 342 err = nc_put_var1_schar(ncid, i, index, &value); +#line 342 if (canConvert) { +#line 342 if (inRange3(value, var_type[i],NCT_SCHAR)) { +#line 342 IF (err) +#line 342 error("%s", nc_strerror(err)); +#line 342 } else { +#line 342 IF (err != NC_ERANGE) { +#line 342 error("Range error: status = %d", err); +#line 342 error("\n\t\tfor type %s value %.17e %ld", +#line 342 s_nc_type(var_type[i]), +#line 342 (double)value, (long)value); +#line 342 } +#line 342 } +#line 342 } else { +#line 342 IF (err != NC_ECHAR) +#line 342 error("wrong type: status = %d", err); +#line 342 } +#line 342 } +#line 342 } +#line 342 +#line 342 err = nc_close(ncid); +#line 342 IF (err) +#line 342 error("nc_close: %s", nc_strerror(err)); +#line 342 +#line 342 check_vars_schar(scratch); +#line 342 +#line 342 err = remove(scratch); +#line 342 IF (err) +#line 342 error("remove of %s failed", scratch); +#line 342 } +#line 342 void +#line 343 test_nc_put_var1_short(void) +#line 343 { +#line 343 int ncid; +#line 343 int i; +#line 343 int j; +#line 343 int err; +#line 343 size_t index[MAX_RANK]; +#line 343 int canConvert; /* Both text or both numeric */ +#line 343 short value = 5; /* any value would do - only for error cases */ +#line 343 +#line 343 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 343 IF (err) { +#line 343 error("nc_create: %s", nc_strerror(err)); +#line 343 return; +#line 343 } +#line 343 def_dims(ncid); +#line 343 def_vars(ncid); +#line 343 err = nc_enddef(ncid); +#line 343 IF (err) +#line 343 error("nc_enddef: %s", nc_strerror(err)); +#line 343 +#line 343 for (i = 0; i < NVARS; i++) { +#line 343 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 343 for (j = 0; j < var_rank[i]; j++) +#line 343 index[j] = 0; +#line 343 err = nc_put_var1_short(BAD_ID, i, index, &value); +#line 343 IF (err != NC_EBADID) +#line 343 error("bad ncid: status = %d", err); +#line 343 err = nc_put_var1_short(ncid, BAD_VARID, index, &value); +#line 343 IF (err != NC_ENOTVAR) +#line 343 error("bad var id: status = %d", err); +#line 343 for (j = 0; j < var_rank[i]; j++) { +#line 343 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 343 index[j] = var_shape[i][j]; +#line 343 err = nc_put_var1_short(ncid, i, index, &value); +#line 343 IF (canConvert && err != NC_EINVALCOORDS) +#line 343 error("bad index: status = %d", err); +#line 343 index[j] = 0; +#line 343 } +#line 343 } +#line 343 for (j = 0; j < var_nels[i]; j++) { +#line 343 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 343 IF (err) +#line 343 error("error in toMixedBase 1"); +#line 343 value = hash_short( var_type[i], var_rank[i], index, NCT_SHORT); +#line 343 if (var_rank[i] == 0 && i%2 == 0) +#line 343 err = nc_put_var1_short(ncid, i, NULL, &value); +#line 343 else +#line 343 err = nc_put_var1_short(ncid, i, index, &value); +#line 343 if (canConvert) { +#line 343 if (inRange3(value, var_type[i],NCT_SHORT)) { +#line 343 IF (err) +#line 343 error("%s", nc_strerror(err)); +#line 343 } else { +#line 343 IF (err != NC_ERANGE) { +#line 343 error("Range error: status = %d", err); +#line 343 error("\n\t\tfor type %s value %.17e %ld", +#line 343 s_nc_type(var_type[i]), +#line 343 (double)value, (long)value); +#line 343 } +#line 343 } +#line 343 } else { +#line 343 IF (err != NC_ECHAR) +#line 343 error("wrong type: status = %d", err); +#line 343 } +#line 343 } +#line 343 } +#line 343 +#line 343 err = nc_close(ncid); +#line 343 IF (err) +#line 343 error("nc_close: %s", nc_strerror(err)); +#line 343 +#line 343 check_vars_short(scratch); +#line 343 +#line 343 err = remove(scratch); +#line 343 IF (err) +#line 343 error("remove of %s failed", scratch); +#line 343 } +#line 343 void +#line 344 test_nc_put_var1_int(void) +#line 344 { +#line 344 int ncid; +#line 344 int i; +#line 344 int j; +#line 344 int err; +#line 344 size_t index[MAX_RANK]; +#line 344 int canConvert; /* Both text or both numeric */ +#line 344 int value = 5; /* any value would do - only for error cases */ +#line 344 +#line 344 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 344 IF (err) { +#line 344 error("nc_create: %s", nc_strerror(err)); +#line 344 return; +#line 344 } +#line 344 def_dims(ncid); +#line 344 def_vars(ncid); +#line 344 err = nc_enddef(ncid); +#line 344 IF (err) +#line 344 error("nc_enddef: %s", nc_strerror(err)); +#line 344 +#line 344 for (i = 0; i < NVARS; i++) { +#line 344 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 344 for (j = 0; j < var_rank[i]; j++) +#line 344 index[j] = 0; +#line 344 err = nc_put_var1_int(BAD_ID, i, index, &value); +#line 344 IF (err != NC_EBADID) +#line 344 error("bad ncid: status = %d", err); +#line 344 err = nc_put_var1_int(ncid, BAD_VARID, index, &value); +#line 344 IF (err != NC_ENOTVAR) +#line 344 error("bad var id: status = %d", err); +#line 344 for (j = 0; j < var_rank[i]; j++) { +#line 344 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 344 index[j] = var_shape[i][j]; +#line 344 err = nc_put_var1_int(ncid, i, index, &value); +#line 344 IF (canConvert && err != NC_EINVALCOORDS) +#line 344 error("bad index: status = %d", err); +#line 344 index[j] = 0; +#line 344 } +#line 344 } +#line 344 for (j = 0; j < var_nels[i]; j++) { +#line 344 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 344 IF (err) +#line 344 error("error in toMixedBase 1"); +#line 344 value = hash_int( var_type[i], var_rank[i], index, NCT_INT); +#line 344 if (var_rank[i] == 0 && i%2 == 0) +#line 344 err = nc_put_var1_int(ncid, i, NULL, &value); +#line 344 else +#line 344 err = nc_put_var1_int(ncid, i, index, &value); +#line 344 if (canConvert) { +#line 344 if (inRange3(value, var_type[i],NCT_INT)) { +#line 344 IF (err) +#line 344 error("%s", nc_strerror(err)); +#line 344 } else { +#line 344 IF (err != NC_ERANGE) { +#line 344 error("Range error: status = %d", err); +#line 344 error("\n\t\tfor type %s value %.17e %ld", +#line 344 s_nc_type(var_type[i]), +#line 344 (double)value, (long)value); +#line 344 } +#line 344 } +#line 344 } else { +#line 344 IF (err != NC_ECHAR) +#line 344 error("wrong type: status = %d", err); +#line 344 } +#line 344 } +#line 344 } +#line 344 +#line 344 err = nc_close(ncid); +#line 344 IF (err) +#line 344 error("nc_close: %s", nc_strerror(err)); +#line 344 +#line 344 check_vars_int(scratch); +#line 344 +#line 344 err = remove(scratch); +#line 344 IF (err) +#line 344 error("remove of %s failed", scratch); +#line 344 } +#line 344 void +#line 345 test_nc_put_var1_long(void) +#line 345 { +#line 345 int ncid; +#line 345 int i; +#line 345 int j; +#line 345 int err; +#line 345 size_t index[MAX_RANK]; +#line 345 int canConvert; /* Both text or both numeric */ +#line 345 long value = 5; /* any value would do - only for error cases */ +#line 345 +#line 345 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 345 IF (err) { +#line 345 error("nc_create: %s", nc_strerror(err)); +#line 345 return; +#line 345 } +#line 345 def_dims(ncid); +#line 345 def_vars(ncid); +#line 345 err = nc_enddef(ncid); +#line 345 IF (err) +#line 345 error("nc_enddef: %s", nc_strerror(err)); +#line 345 +#line 345 for (i = 0; i < NVARS; i++) { +#line 345 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 345 for (j = 0; j < var_rank[i]; j++) +#line 345 index[j] = 0; +#line 345 err = nc_put_var1_long(BAD_ID, i, index, &value); +#line 345 IF (err != NC_EBADID) +#line 345 error("bad ncid: status = %d", err); +#line 345 err = nc_put_var1_long(ncid, BAD_VARID, index, &value); +#line 345 IF (err != NC_ENOTVAR) +#line 345 error("bad var id: status = %d", err); +#line 345 for (j = 0; j < var_rank[i]; j++) { +#line 345 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 345 index[j] = var_shape[i][j]; +#line 345 err = nc_put_var1_long(ncid, i, index, &value); +#line 345 IF (canConvert && err != NC_EINVALCOORDS) +#line 345 error("bad index: status = %d", err); +#line 345 index[j] = 0; +#line 345 } +#line 345 } +#line 345 for (j = 0; j < var_nels[i]; j++) { +#line 345 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 345 IF (err) +#line 345 error("error in toMixedBase 1"); +#line 345 value = hash_long( var_type[i], var_rank[i], index, NCT_LONG); +#line 345 if (var_rank[i] == 0 && i%2 == 0) +#line 345 err = nc_put_var1_long(ncid, i, NULL, &value); +#line 345 else +#line 345 err = nc_put_var1_long(ncid, i, index, &value); +#line 345 if (canConvert) { +#line 345 if (inRange3(value, var_type[i],NCT_LONG)) { +#line 345 IF (err) +#line 345 error("%s", nc_strerror(err)); +#line 345 } else { +#line 345 IF (err != NC_ERANGE) { +#line 345 error("Range error: status = %d", err); +#line 345 error("\n\t\tfor type %s value %.17e %ld", +#line 345 s_nc_type(var_type[i]), +#line 345 (double)value, (long)value); +#line 345 } +#line 345 } +#line 345 } else { +#line 345 IF (err != NC_ECHAR) +#line 345 error("wrong type: status = %d", err); +#line 345 } +#line 345 } +#line 345 } +#line 345 +#line 345 err = nc_close(ncid); +#line 345 IF (err) +#line 345 error("nc_close: %s", nc_strerror(err)); +#line 345 +#line 345 check_vars_long(scratch); +#line 345 +#line 345 err = remove(scratch); +#line 345 IF (err) +#line 345 error("remove of %s failed", scratch); +#line 345 } +#line 345 void +#line 346 test_nc_put_var1_float(void) +#line 346 { +#line 346 int ncid; +#line 346 int i; +#line 346 int j; +#line 346 int err; +#line 346 size_t index[MAX_RANK]; +#line 346 int canConvert; /* Both text or both numeric */ +#line 346 float value = 5; /* any value would do - only for error cases */ +#line 346 +#line 346 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 346 IF (err) { +#line 346 error("nc_create: %s", nc_strerror(err)); +#line 346 return; +#line 346 } +#line 346 def_dims(ncid); +#line 346 def_vars(ncid); +#line 346 err = nc_enddef(ncid); +#line 346 IF (err) +#line 346 error("nc_enddef: %s", nc_strerror(err)); +#line 346 +#line 346 for (i = 0; i < NVARS; i++) { +#line 346 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 346 for (j = 0; j < var_rank[i]; j++) +#line 346 index[j] = 0; +#line 346 err = nc_put_var1_float(BAD_ID, i, index, &value); +#line 346 IF (err != NC_EBADID) +#line 346 error("bad ncid: status = %d", err); +#line 346 err = nc_put_var1_float(ncid, BAD_VARID, index, &value); +#line 346 IF (err != NC_ENOTVAR) +#line 346 error("bad var id: status = %d", err); +#line 346 for (j = 0; j < var_rank[i]; j++) { +#line 346 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 346 index[j] = var_shape[i][j]; +#line 346 err = nc_put_var1_float(ncid, i, index, &value); +#line 346 IF (canConvert && err != NC_EINVALCOORDS) +#line 346 error("bad index: status = %d", err); +#line 346 index[j] = 0; +#line 346 } +#line 346 } +#line 346 for (j = 0; j < var_nels[i]; j++) { +#line 346 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 346 IF (err) +#line 346 error("error in toMixedBase 1"); +#line 346 value = hash_float( var_type[i], var_rank[i], index, NCT_FLOAT); +#line 346 if (var_rank[i] == 0 && i%2 == 0) +#line 346 err = nc_put_var1_float(ncid, i, NULL, &value); +#line 346 else +#line 346 err = nc_put_var1_float(ncid, i, index, &value); +#line 346 if (canConvert) { +#line 346 if (inRange3(value, var_type[i],NCT_FLOAT)) { +#line 346 IF (err) +#line 346 error("%s", nc_strerror(err)); +#line 346 } else { +#line 346 IF (err != NC_ERANGE) { +#line 346 error("Range error: status = %d", err); +#line 346 error("\n\t\tfor type %s value %.17e %ld", +#line 346 s_nc_type(var_type[i]), +#line 346 (double)value, (long)value); +#line 346 } +#line 346 } +#line 346 } else { +#line 346 IF (err != NC_ECHAR) +#line 346 error("wrong type: status = %d", err); +#line 346 } +#line 346 } +#line 346 } +#line 346 +#line 346 err = nc_close(ncid); +#line 346 IF (err) +#line 346 error("nc_close: %s", nc_strerror(err)); +#line 346 +#line 346 check_vars_float(scratch); +#line 346 +#line 346 err = remove(scratch); +#line 346 IF (err) +#line 346 error("remove of %s failed", scratch); +#line 346 } +#line 346 void +#line 347 test_nc_put_var1_double(void) +#line 347 { +#line 347 int ncid; +#line 347 int i; +#line 347 int j; +#line 347 int err; +#line 347 size_t index[MAX_RANK]; +#line 347 int canConvert; /* Both text or both numeric */ +#line 347 double value = 5; /* any value would do - only for error cases */ +#line 347 +#line 347 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 347 IF (err) { +#line 347 error("nc_create: %s", nc_strerror(err)); +#line 347 return; +#line 347 } +#line 347 def_dims(ncid); +#line 347 def_vars(ncid); +#line 347 err = nc_enddef(ncid); +#line 347 IF (err) +#line 347 error("nc_enddef: %s", nc_strerror(err)); +#line 347 +#line 347 for (i = 0; i < NVARS; i++) { +#line 347 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 347 for (j = 0; j < var_rank[i]; j++) +#line 347 index[j] = 0; +#line 347 err = nc_put_var1_double(BAD_ID, i, index, &value); +#line 347 IF (err != NC_EBADID) +#line 347 error("bad ncid: status = %d", err); +#line 347 err = nc_put_var1_double(ncid, BAD_VARID, index, &value); +#line 347 IF (err != NC_ENOTVAR) +#line 347 error("bad var id: status = %d", err); +#line 347 for (j = 0; j < var_rank[i]; j++) { +#line 347 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 347 index[j] = var_shape[i][j]; +#line 347 err = nc_put_var1_double(ncid, i, index, &value); +#line 347 IF (canConvert && err != NC_EINVALCOORDS) +#line 347 error("bad index: status = %d", err); +#line 347 index[j] = 0; +#line 347 } +#line 347 } +#line 347 for (j = 0; j < var_nels[i]; j++) { +#line 347 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 347 IF (err) +#line 347 error("error in toMixedBase 1"); +#line 347 value = hash_double( var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 347 if (var_rank[i] == 0 && i%2 == 0) +#line 347 err = nc_put_var1_double(ncid, i, NULL, &value); +#line 347 else +#line 347 err = nc_put_var1_double(ncid, i, index, &value); +#line 347 if (canConvert) { +#line 347 if (inRange3(value, var_type[i],NCT_DOUBLE)) { +#line 347 IF (err) +#line 347 error("%s", nc_strerror(err)); +#line 347 } else { +#line 347 IF (err != NC_ERANGE) { +#line 347 error("Range error: status = %d", err); +#line 347 error("\n\t\tfor type %s value %.17e %ld", +#line 347 s_nc_type(var_type[i]), +#line 347 (double)value, (long)value); +#line 347 } +#line 347 } +#line 347 } else { +#line 347 IF (err != NC_ECHAR) +#line 347 error("wrong type: status = %d", err); +#line 347 } +#line 347 } +#line 347 } +#line 347 +#line 347 err = nc_close(ncid); +#line 347 IF (err) +#line 347 error("nc_close: %s", nc_strerror(err)); +#line 347 +#line 347 check_vars_double(scratch); +#line 347 +#line 347 err = remove(scratch); +#line 347 IF (err) +#line 347 error("remove of %s failed", scratch); +#line 347 } +#line 347 +#line 477 void +#line 478 test_nc_put_var_text(void) +#line 478 { +#line 478 int ncid; +#line 478 int varid; +#line 478 int i; +#line 478 int j; +#line 478 int err; +#line 478 int nels; +#line 478 size_t index[MAX_RANK]; +#line 478 int canConvert; /* Both text or both numeric */ +#line 478 int allInExtRange; /* all values within external range? */ +#line 478 text value[MAX_NELS]; +#line 478 +#line 478 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 478 IF (err) { +#line 478 error("nc_create: %s", nc_strerror(err)); +#line 478 return; +#line 478 } +#line 478 def_dims(ncid); +#line 478 def_vars(ncid); +#line 478 err = nc_enddef(ncid); +#line 478 IF (err) +#line 478 error("nc_enddef: %s", nc_strerror(err)); +#line 478 +#line 478 for (i = 0; i < NVARS; i++) { +#line 478 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 478 assert(var_rank[i] <= MAX_RANK); +#line 478 assert(var_nels[i] <= MAX_NELS); +#line 478 err = nc_put_var_text(BAD_ID, i, value); +#line 478 IF (err != NC_EBADID) +#line 478 error("bad ncid: status = %d", err); +#line 478 err = nc_put_var_text(ncid, BAD_VARID, value); +#line 478 IF (err != NC_ENOTVAR) +#line 478 error("bad var id: status = %d", err); +#line 478 +#line 478 nels = 1; +#line 478 for (j = 0; j < var_rank[i]; j++) { +#line 478 nels *= var_shape[i][j]; +#line 478 } +#line 478 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 478 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 478 IF (err) +#line 478 error("error in toMixedBase 1"); +#line 478 value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT); +#line 478 allInExtRange = allInExtRange +#line 478 && inRange3(value[j], var_type[i], NCT_TEXT); +#line 478 } +#line 478 err = nc_put_var_text(ncid, i, value); +#line 478 if (canConvert) { +#line 478 if (allInExtRange) { +#line 478 IF (err) +#line 478 error("%s", nc_strerror(err)); +#line 478 } else { +#line 478 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 478 error("range error: status = %d", err); +#line 478 } +#line 478 } else { /* should flag wrong type even if nothing to write */ +#line 478 IF (nels > 0 && err != NC_ECHAR) +#line 478 error("wrong type: status = %d", err); +#line 478 } +#line 478 } +#line 478 +#line 478 /* Preceeding has written nothing for record variables, now try */ +#line 478 /* again with more than 0 records */ +#line 478 +#line 478 /* Write record number NRECS to force writing of preceding records */ +#line 478 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 478 err = nc_inq_varid(ncid, "cr", &varid); +#line 478 IF (err) +#line 478 error("nc_inq_varid: %s", nc_strerror(err)); +#line 478 index[0] = NRECS-1; +#line 478 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 478 IF (err) +#line 478 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 478 +#line 478 for (i = 0; i < NVARS; i++) { +#line 478 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 478 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 478 assert(var_rank[i] <= MAX_RANK); +#line 478 assert(var_nels[i] <= MAX_NELS); +#line 478 err = nc_put_var_text(BAD_ID, i, value); +#line 478 IF (err != NC_EBADID) +#line 478 error("bad ncid: status = %d", err); +#line 478 nels = 1; +#line 478 for (j = 0; j < var_rank[i]; j++) { +#line 478 nels *= var_shape[i][j]; +#line 478 } +#line 478 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 478 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 478 IF (err) +#line 478 error("error in toMixedBase 1"); +#line 478 value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT); +#line 478 allInExtRange = allInExtRange +#line 478 && inRange3(value[j], var_type[i], NCT_TEXT); +#line 478 } +#line 478 err = nc_put_var_text(ncid, i, value); +#line 478 if (canConvert) { +#line 478 if (allInExtRange) { +#line 478 IF (err) +#line 478 error("%s", nc_strerror(err)); +#line 478 } else { +#line 478 IF (err != NC_ERANGE) +#line 478 error("range error: status = %d", err); +#line 478 } +#line 478 } else { +#line 478 IF (nels > 0 && err != NC_ECHAR) +#line 478 error("wrong type: status = %d", err); +#line 478 } +#line 478 } +#line 478 } +#line 478 +#line 478 err = nc_close(ncid); +#line 478 IF (err) +#line 478 error("nc_close: %s", nc_strerror(err)); +#line 478 +#line 478 check_vars_text(scratch); +#line 478 +#line 478 err = remove(scratch); +#line 478 IF (err) +#line 478 error("remove of %s failed", scratch); +#line 478 } +#line 478 void +#line 479 test_nc_put_var_uchar(void) +#line 479 { +#line 479 int ncid; +#line 479 int varid; +#line 479 int i; +#line 479 int j; +#line 479 int err; +#line 479 int nels; +#line 479 size_t index[MAX_RANK]; +#line 479 int canConvert; /* Both text or both numeric */ +#line 479 int allInExtRange; /* all values within external range? */ +#line 479 uchar value[MAX_NELS]; +#line 479 +#line 479 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 479 IF (err) { +#line 479 error("nc_create: %s", nc_strerror(err)); +#line 479 return; +#line 479 } +#line 479 def_dims(ncid); +#line 479 def_vars(ncid); +#line 479 err = nc_enddef(ncid); +#line 479 IF (err) +#line 479 error("nc_enddef: %s", nc_strerror(err)); +#line 479 +#line 479 for (i = 0; i < NVARS; i++) { +#line 479 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 479 assert(var_rank[i] <= MAX_RANK); +#line 479 assert(var_nels[i] <= MAX_NELS); +#line 479 err = nc_put_var_uchar(BAD_ID, i, value); +#line 479 IF (err != NC_EBADID) +#line 479 error("bad ncid: status = %d", err); +#line 479 err = nc_put_var_uchar(ncid, BAD_VARID, value); +#line 479 IF (err != NC_ENOTVAR) +#line 479 error("bad var id: status = %d", err); +#line 479 +#line 479 nels = 1; +#line 479 for (j = 0; j < var_rank[i]; j++) { +#line 479 nels *= var_shape[i][j]; +#line 479 } +#line 479 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 479 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 479 IF (err) +#line 479 error("error in toMixedBase 1"); +#line 479 value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR); +#line 479 allInExtRange = allInExtRange +#line 479 && inRange3(value[j], var_type[i], NCT_UCHAR); +#line 479 } +#line 479 err = nc_put_var_uchar(ncid, i, value); +#line 479 if (canConvert) { +#line 479 if (allInExtRange) { +#line 479 IF (err) +#line 479 error("%s", nc_strerror(err)); +#line 479 } else { +#line 479 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 479 error("range error: status = %d", err); +#line 479 } +#line 479 } else { /* should flag wrong type even if nothing to write */ +#line 479 IF (nels > 0 && err != NC_ECHAR) +#line 479 error("wrong type: status = %d", err); +#line 479 } +#line 479 } +#line 479 +#line 479 /* Preceeding has written nothing for record variables, now try */ +#line 479 /* again with more than 0 records */ +#line 479 +#line 479 /* Write record number NRECS to force writing of preceding records */ +#line 479 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 479 err = nc_inq_varid(ncid, "cr", &varid); +#line 479 IF (err) +#line 479 error("nc_inq_varid: %s", nc_strerror(err)); +#line 479 index[0] = NRECS-1; +#line 479 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 479 IF (err) +#line 479 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 479 +#line 479 for (i = 0; i < NVARS; i++) { +#line 479 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 479 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 479 assert(var_rank[i] <= MAX_RANK); +#line 479 assert(var_nels[i] <= MAX_NELS); +#line 479 err = nc_put_var_uchar(BAD_ID, i, value); +#line 479 IF (err != NC_EBADID) +#line 479 error("bad ncid: status = %d", err); +#line 479 nels = 1; +#line 479 for (j = 0; j < var_rank[i]; j++) { +#line 479 nels *= var_shape[i][j]; +#line 479 } +#line 479 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 479 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 479 IF (err) +#line 479 error("error in toMixedBase 1"); +#line 479 value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR); +#line 479 allInExtRange = allInExtRange +#line 479 && inRange3(value[j], var_type[i], NCT_UCHAR); +#line 479 } +#line 479 err = nc_put_var_uchar(ncid, i, value); +#line 479 if (canConvert) { +#line 479 if (allInExtRange) { +#line 479 IF (err) +#line 479 error("%s", nc_strerror(err)); +#line 479 } else { +#line 479 IF (err != NC_ERANGE) +#line 479 error("range error: status = %d", err); +#line 479 } +#line 479 } else { +#line 479 IF (nels > 0 && err != NC_ECHAR) +#line 479 error("wrong type: status = %d", err); +#line 479 } +#line 479 } +#line 479 } +#line 479 +#line 479 err = nc_close(ncid); +#line 479 IF (err) +#line 479 error("nc_close: %s", nc_strerror(err)); +#line 479 +#line 479 check_vars_uchar(scratch); +#line 479 +#line 479 err = remove(scratch); +#line 479 IF (err) +#line 479 error("remove of %s failed", scratch); +#line 479 } +#line 479 void +#line 480 test_nc_put_var_schar(void) +#line 480 { +#line 480 int ncid; +#line 480 int varid; +#line 480 int i; +#line 480 int j; +#line 480 int err; +#line 480 int nels; +#line 480 size_t index[MAX_RANK]; +#line 480 int canConvert; /* Both text or both numeric */ +#line 480 int allInExtRange; /* all values within external range? */ +#line 480 schar value[MAX_NELS]; +#line 480 +#line 480 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 480 IF (err) { +#line 480 error("nc_create: %s", nc_strerror(err)); +#line 480 return; +#line 480 } +#line 480 def_dims(ncid); +#line 480 def_vars(ncid); +#line 480 err = nc_enddef(ncid); +#line 480 IF (err) +#line 480 error("nc_enddef: %s", nc_strerror(err)); +#line 480 +#line 480 for (i = 0; i < NVARS; i++) { +#line 480 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 480 assert(var_rank[i] <= MAX_RANK); +#line 480 assert(var_nels[i] <= MAX_NELS); +#line 480 err = nc_put_var_schar(BAD_ID, i, value); +#line 480 IF (err != NC_EBADID) +#line 480 error("bad ncid: status = %d", err); +#line 480 err = nc_put_var_schar(ncid, BAD_VARID, value); +#line 480 IF (err != NC_ENOTVAR) +#line 480 error("bad var id: status = %d", err); +#line 480 +#line 480 nels = 1; +#line 480 for (j = 0; j < var_rank[i]; j++) { +#line 480 nels *= var_shape[i][j]; +#line 480 } +#line 480 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 480 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 480 IF (err) +#line 480 error("error in toMixedBase 1"); +#line 480 value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR); +#line 480 allInExtRange = allInExtRange +#line 480 && inRange3(value[j], var_type[i], NCT_SCHAR); +#line 480 } +#line 480 err = nc_put_var_schar(ncid, i, value); +#line 480 if (canConvert) { +#line 480 if (allInExtRange) { +#line 480 IF (err) +#line 480 error("%s", nc_strerror(err)); +#line 480 } else { +#line 480 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 480 error("range error: status = %d", err); +#line 480 } +#line 480 } else { /* should flag wrong type even if nothing to write */ +#line 480 IF (nels > 0 && err != NC_ECHAR) +#line 480 error("wrong type: status = %d", err); +#line 480 } +#line 480 } +#line 480 +#line 480 /* Preceeding has written nothing for record variables, now try */ +#line 480 /* again with more than 0 records */ +#line 480 +#line 480 /* Write record number NRECS to force writing of preceding records */ +#line 480 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 480 err = nc_inq_varid(ncid, "cr", &varid); +#line 480 IF (err) +#line 480 error("nc_inq_varid: %s", nc_strerror(err)); +#line 480 index[0] = NRECS-1; +#line 480 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 480 IF (err) +#line 480 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 480 +#line 480 for (i = 0; i < NVARS; i++) { +#line 480 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 480 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 480 assert(var_rank[i] <= MAX_RANK); +#line 480 assert(var_nels[i] <= MAX_NELS); +#line 480 err = nc_put_var_schar(BAD_ID, i, value); +#line 480 IF (err != NC_EBADID) +#line 480 error("bad ncid: status = %d", err); +#line 480 nels = 1; +#line 480 for (j = 0; j < var_rank[i]; j++) { +#line 480 nels *= var_shape[i][j]; +#line 480 } +#line 480 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 480 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 480 IF (err) +#line 480 error("error in toMixedBase 1"); +#line 480 value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR); +#line 480 allInExtRange = allInExtRange +#line 480 && inRange3(value[j], var_type[i], NCT_SCHAR); +#line 480 } +#line 480 err = nc_put_var_schar(ncid, i, value); +#line 480 if (canConvert) { +#line 480 if (allInExtRange) { +#line 480 IF (err) +#line 480 error("%s", nc_strerror(err)); +#line 480 } else { +#line 480 IF (err != NC_ERANGE) +#line 480 error("range error: status = %d", err); +#line 480 } +#line 480 } else { +#line 480 IF (nels > 0 && err != NC_ECHAR) +#line 480 error("wrong type: status = %d", err); +#line 480 } +#line 480 } +#line 480 } +#line 480 +#line 480 err = nc_close(ncid); +#line 480 IF (err) +#line 480 error("nc_close: %s", nc_strerror(err)); +#line 480 +#line 480 check_vars_schar(scratch); +#line 480 +#line 480 err = remove(scratch); +#line 480 IF (err) +#line 480 error("remove of %s failed", scratch); +#line 480 } +#line 480 void +#line 481 test_nc_put_var_short(void) +#line 481 { +#line 481 int ncid; +#line 481 int varid; +#line 481 int i; +#line 481 int j; +#line 481 int err; +#line 481 int nels; +#line 481 size_t index[MAX_RANK]; +#line 481 int canConvert; /* Both text or both numeric */ +#line 481 int allInExtRange; /* all values within external range? */ +#line 481 short value[MAX_NELS]; +#line 481 +#line 481 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 481 IF (err) { +#line 481 error("nc_create: %s", nc_strerror(err)); +#line 481 return; +#line 481 } +#line 481 def_dims(ncid); +#line 481 def_vars(ncid); +#line 481 err = nc_enddef(ncid); +#line 481 IF (err) +#line 481 error("nc_enddef: %s", nc_strerror(err)); +#line 481 +#line 481 for (i = 0; i < NVARS; i++) { +#line 481 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 481 assert(var_rank[i] <= MAX_RANK); +#line 481 assert(var_nels[i] <= MAX_NELS); +#line 481 err = nc_put_var_short(BAD_ID, i, value); +#line 481 IF (err != NC_EBADID) +#line 481 error("bad ncid: status = %d", err); +#line 481 err = nc_put_var_short(ncid, BAD_VARID, value); +#line 481 IF (err != NC_ENOTVAR) +#line 481 error("bad var id: status = %d", err); +#line 481 +#line 481 nels = 1; +#line 481 for (j = 0; j < var_rank[i]; j++) { +#line 481 nels *= var_shape[i][j]; +#line 481 } +#line 481 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 481 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 481 IF (err) +#line 481 error("error in toMixedBase 1"); +#line 481 value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT); +#line 481 allInExtRange = allInExtRange +#line 481 && inRange3(value[j], var_type[i], NCT_SHORT); +#line 481 } +#line 481 err = nc_put_var_short(ncid, i, value); +#line 481 if (canConvert) { +#line 481 if (allInExtRange) { +#line 481 IF (err) +#line 481 error("%s", nc_strerror(err)); +#line 481 } else { +#line 481 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 481 error("range error: status = %d", err); +#line 481 } +#line 481 } else { /* should flag wrong type even if nothing to write */ +#line 481 IF (nels > 0 && err != NC_ECHAR) +#line 481 error("wrong type: status = %d", err); +#line 481 } +#line 481 } +#line 481 +#line 481 /* Preceeding has written nothing for record variables, now try */ +#line 481 /* again with more than 0 records */ +#line 481 +#line 481 /* Write record number NRECS to force writing of preceding records */ +#line 481 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 481 err = nc_inq_varid(ncid, "cr", &varid); +#line 481 IF (err) +#line 481 error("nc_inq_varid: %s", nc_strerror(err)); +#line 481 index[0] = NRECS-1; +#line 481 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 481 IF (err) +#line 481 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 481 +#line 481 for (i = 0; i < NVARS; i++) { +#line 481 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 481 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 481 assert(var_rank[i] <= MAX_RANK); +#line 481 assert(var_nels[i] <= MAX_NELS); +#line 481 err = nc_put_var_short(BAD_ID, i, value); +#line 481 IF (err != NC_EBADID) +#line 481 error("bad ncid: status = %d", err); +#line 481 nels = 1; +#line 481 for (j = 0; j < var_rank[i]; j++) { +#line 481 nels *= var_shape[i][j]; +#line 481 } +#line 481 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 481 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 481 IF (err) +#line 481 error("error in toMixedBase 1"); +#line 481 value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT); +#line 481 allInExtRange = allInExtRange +#line 481 && inRange3(value[j], var_type[i], NCT_SHORT); +#line 481 } +#line 481 err = nc_put_var_short(ncid, i, value); +#line 481 if (canConvert) { +#line 481 if (allInExtRange) { +#line 481 IF (err) +#line 481 error("%s", nc_strerror(err)); +#line 481 } else { +#line 481 IF (err != NC_ERANGE) +#line 481 error("range error: status = %d", err); +#line 481 } +#line 481 } else { +#line 481 IF (nels > 0 && err != NC_ECHAR) +#line 481 error("wrong type: status = %d", err); +#line 481 } +#line 481 } +#line 481 } +#line 481 +#line 481 err = nc_close(ncid); +#line 481 IF (err) +#line 481 error("nc_close: %s", nc_strerror(err)); +#line 481 +#line 481 check_vars_short(scratch); +#line 481 +#line 481 err = remove(scratch); +#line 481 IF (err) +#line 481 error("remove of %s failed", scratch); +#line 481 } +#line 481 void +#line 482 test_nc_put_var_int(void) +#line 482 { +#line 482 int ncid; +#line 482 int varid; +#line 482 int i; +#line 482 int j; +#line 482 int err; +#line 482 int nels; +#line 482 size_t index[MAX_RANK]; +#line 482 int canConvert; /* Both text or both numeric */ +#line 482 int allInExtRange; /* all values within external range? */ +#line 482 int value[MAX_NELS]; +#line 482 +#line 482 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 482 IF (err) { +#line 482 error("nc_create: %s", nc_strerror(err)); +#line 482 return; +#line 482 } +#line 482 def_dims(ncid); +#line 482 def_vars(ncid); +#line 482 err = nc_enddef(ncid); +#line 482 IF (err) +#line 482 error("nc_enddef: %s", nc_strerror(err)); +#line 482 +#line 482 for (i = 0; i < NVARS; i++) { +#line 482 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 482 assert(var_rank[i] <= MAX_RANK); +#line 482 assert(var_nels[i] <= MAX_NELS); +#line 482 err = nc_put_var_int(BAD_ID, i, value); +#line 482 IF (err != NC_EBADID) +#line 482 error("bad ncid: status = %d", err); +#line 482 err = nc_put_var_int(ncid, BAD_VARID, value); +#line 482 IF (err != NC_ENOTVAR) +#line 482 error("bad var id: status = %d", err); +#line 482 +#line 482 nels = 1; +#line 482 for (j = 0; j < var_rank[i]; j++) { +#line 482 nels *= var_shape[i][j]; +#line 482 } +#line 482 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 482 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 482 IF (err) +#line 482 error("error in toMixedBase 1"); +#line 482 value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT); +#line 482 allInExtRange = allInExtRange +#line 482 && inRange3(value[j], var_type[i], NCT_INT); +#line 482 } +#line 482 err = nc_put_var_int(ncid, i, value); +#line 482 if (canConvert) { +#line 482 if (allInExtRange) { +#line 482 IF (err) +#line 482 error("%s", nc_strerror(err)); +#line 482 } else { +#line 482 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 482 error("range error: status = %d", err); +#line 482 } +#line 482 } else { /* should flag wrong type even if nothing to write */ +#line 482 IF (nels > 0 && err != NC_ECHAR) +#line 482 error("wrong type: status = %d", err); +#line 482 } +#line 482 } +#line 482 +#line 482 /* Preceeding has written nothing for record variables, now try */ +#line 482 /* again with more than 0 records */ +#line 482 +#line 482 /* Write record number NRECS to force writing of preceding records */ +#line 482 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 482 err = nc_inq_varid(ncid, "cr", &varid); +#line 482 IF (err) +#line 482 error("nc_inq_varid: %s", nc_strerror(err)); +#line 482 index[0] = NRECS-1; +#line 482 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 482 IF (err) +#line 482 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 482 +#line 482 for (i = 0; i < NVARS; i++) { +#line 482 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 482 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 482 assert(var_rank[i] <= MAX_RANK); +#line 482 assert(var_nels[i] <= MAX_NELS); +#line 482 err = nc_put_var_int(BAD_ID, i, value); +#line 482 IF (err != NC_EBADID) +#line 482 error("bad ncid: status = %d", err); +#line 482 nels = 1; +#line 482 for (j = 0; j < var_rank[i]; j++) { +#line 482 nels *= var_shape[i][j]; +#line 482 } +#line 482 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 482 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 482 IF (err) +#line 482 error("error in toMixedBase 1"); +#line 482 value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT); +#line 482 allInExtRange = allInExtRange +#line 482 && inRange3(value[j], var_type[i], NCT_INT); +#line 482 } +#line 482 err = nc_put_var_int(ncid, i, value); +#line 482 if (canConvert) { +#line 482 if (allInExtRange) { +#line 482 IF (err) +#line 482 error("%s", nc_strerror(err)); +#line 482 } else { +#line 482 IF (err != NC_ERANGE) +#line 482 error("range error: status = %d", err); +#line 482 } +#line 482 } else { +#line 482 IF (nels > 0 && err != NC_ECHAR) +#line 482 error("wrong type: status = %d", err); +#line 482 } +#line 482 } +#line 482 } +#line 482 +#line 482 err = nc_close(ncid); +#line 482 IF (err) +#line 482 error("nc_close: %s", nc_strerror(err)); +#line 482 +#line 482 check_vars_int(scratch); +#line 482 +#line 482 err = remove(scratch); +#line 482 IF (err) +#line 482 error("remove of %s failed", scratch); +#line 482 } +#line 482 void +#line 483 test_nc_put_var_long(void) +#line 483 { +#line 483 int ncid; +#line 483 int varid; +#line 483 int i; +#line 483 int j; +#line 483 int err; +#line 483 int nels; +#line 483 size_t index[MAX_RANK]; +#line 483 int canConvert; /* Both text or both numeric */ +#line 483 int allInExtRange; /* all values within external range? */ +#line 483 long value[MAX_NELS]; +#line 483 +#line 483 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 483 IF (err) { +#line 483 error("nc_create: %s", nc_strerror(err)); +#line 483 return; +#line 483 } +#line 483 def_dims(ncid); +#line 483 def_vars(ncid); +#line 483 err = nc_enddef(ncid); +#line 483 IF (err) +#line 483 error("nc_enddef: %s", nc_strerror(err)); +#line 483 +#line 483 for (i = 0; i < NVARS; i++) { +#line 483 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 483 assert(var_rank[i] <= MAX_RANK); +#line 483 assert(var_nels[i] <= MAX_NELS); +#line 483 err = nc_put_var_long(BAD_ID, i, value); +#line 483 IF (err != NC_EBADID) +#line 483 error("bad ncid: status = %d", err); +#line 483 err = nc_put_var_long(ncid, BAD_VARID, value); +#line 483 IF (err != NC_ENOTVAR) +#line 483 error("bad var id: status = %d", err); +#line 483 +#line 483 nels = 1; +#line 483 for (j = 0; j < var_rank[i]; j++) { +#line 483 nels *= var_shape[i][j]; +#line 483 } +#line 483 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 483 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 483 IF (err) +#line 483 error("error in toMixedBase 1"); +#line 483 value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG); +#line 483 allInExtRange = allInExtRange +#line 483 && inRange3(value[j], var_type[i], NCT_LONG); +#line 483 } +#line 483 err = nc_put_var_long(ncid, i, value); +#line 483 if (canConvert) { +#line 483 if (allInExtRange) { +#line 483 IF (err) +#line 483 error("%s", nc_strerror(err)); +#line 483 } else { +#line 483 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 483 error("range error: status = %d", err); +#line 483 } +#line 483 } else { /* should flag wrong type even if nothing to write */ +#line 483 IF (nels > 0 && err != NC_ECHAR) +#line 483 error("wrong type: status = %d", err); +#line 483 } +#line 483 } +#line 483 +#line 483 /* Preceeding has written nothing for record variables, now try */ +#line 483 /* again with more than 0 records */ +#line 483 +#line 483 /* Write record number NRECS to force writing of preceding records */ +#line 483 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 483 err = nc_inq_varid(ncid, "cr", &varid); +#line 483 IF (err) +#line 483 error("nc_inq_varid: %s", nc_strerror(err)); +#line 483 index[0] = NRECS-1; +#line 483 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 483 IF (err) +#line 483 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 483 +#line 483 for (i = 0; i < NVARS; i++) { +#line 483 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 483 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 483 assert(var_rank[i] <= MAX_RANK); +#line 483 assert(var_nels[i] <= MAX_NELS); +#line 483 err = nc_put_var_long(BAD_ID, i, value); +#line 483 IF (err != NC_EBADID) +#line 483 error("bad ncid: status = %d", err); +#line 483 nels = 1; +#line 483 for (j = 0; j < var_rank[i]; j++) { +#line 483 nels *= var_shape[i][j]; +#line 483 } +#line 483 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 483 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 483 IF (err) +#line 483 error("error in toMixedBase 1"); +#line 483 value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG); +#line 483 allInExtRange = allInExtRange +#line 483 && inRange3(value[j], var_type[i], NCT_LONG); +#line 483 } +#line 483 err = nc_put_var_long(ncid, i, value); +#line 483 if (canConvert) { +#line 483 if (allInExtRange) { +#line 483 IF (err) +#line 483 error("%s", nc_strerror(err)); +#line 483 } else { +#line 483 IF (err != NC_ERANGE) +#line 483 error("range error: status = %d", err); +#line 483 } +#line 483 } else { +#line 483 IF (nels > 0 && err != NC_ECHAR) +#line 483 error("wrong type: status = %d", err); +#line 483 } +#line 483 } +#line 483 } +#line 483 +#line 483 err = nc_close(ncid); +#line 483 IF (err) +#line 483 error("nc_close: %s", nc_strerror(err)); +#line 483 +#line 483 check_vars_long(scratch); +#line 483 +#line 483 err = remove(scratch); +#line 483 IF (err) +#line 483 error("remove of %s failed", scratch); +#line 483 } +#line 483 void +#line 484 test_nc_put_var_float(void) +#line 484 { +#line 484 int ncid; +#line 484 int varid; +#line 484 int i; +#line 484 int j; +#line 484 int err; +#line 484 int nels; +#line 484 size_t index[MAX_RANK]; +#line 484 int canConvert; /* Both text or both numeric */ +#line 484 int allInExtRange; /* all values within external range? */ +#line 484 float value[MAX_NELS]; +#line 484 +#line 484 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 484 IF (err) { +#line 484 error("nc_create: %s", nc_strerror(err)); +#line 484 return; +#line 484 } +#line 484 def_dims(ncid); +#line 484 def_vars(ncid); +#line 484 err = nc_enddef(ncid); +#line 484 IF (err) +#line 484 error("nc_enddef: %s", nc_strerror(err)); +#line 484 +#line 484 for (i = 0; i < NVARS; i++) { +#line 484 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 484 assert(var_rank[i] <= MAX_RANK); +#line 484 assert(var_nels[i] <= MAX_NELS); +#line 484 err = nc_put_var_float(BAD_ID, i, value); +#line 484 IF (err != NC_EBADID) +#line 484 error("bad ncid: status = %d", err); +#line 484 err = nc_put_var_float(ncid, BAD_VARID, value); +#line 484 IF (err != NC_ENOTVAR) +#line 484 error("bad var id: status = %d", err); +#line 484 +#line 484 nels = 1; +#line 484 for (j = 0; j < var_rank[i]; j++) { +#line 484 nels *= var_shape[i][j]; +#line 484 } +#line 484 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 484 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 484 IF (err) +#line 484 error("error in toMixedBase 1"); +#line 484 value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT); +#line 484 allInExtRange = allInExtRange +#line 484 && inRange3(value[j], var_type[i], NCT_FLOAT); +#line 484 } +#line 484 err = nc_put_var_float(ncid, i, value); +#line 484 if (canConvert) { +#line 484 if (allInExtRange) { +#line 484 IF (err) +#line 484 error("%s", nc_strerror(err)); +#line 484 } else { +#line 484 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 484 error("range error: status = %d", err); +#line 484 } +#line 484 } else { /* should flag wrong type even if nothing to write */ +#line 484 IF (nels > 0 && err != NC_ECHAR) +#line 484 error("wrong type: status = %d", err); +#line 484 } +#line 484 } +#line 484 +#line 484 /* Preceeding has written nothing for record variables, now try */ +#line 484 /* again with more than 0 records */ +#line 484 +#line 484 /* Write record number NRECS to force writing of preceding records */ +#line 484 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 484 err = nc_inq_varid(ncid, "cr", &varid); +#line 484 IF (err) +#line 484 error("nc_inq_varid: %s", nc_strerror(err)); +#line 484 index[0] = NRECS-1; +#line 484 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 484 IF (err) +#line 484 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 484 +#line 484 for (i = 0; i < NVARS; i++) { +#line 484 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 484 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 484 assert(var_rank[i] <= MAX_RANK); +#line 484 assert(var_nels[i] <= MAX_NELS); +#line 484 err = nc_put_var_float(BAD_ID, i, value); +#line 484 IF (err != NC_EBADID) +#line 484 error("bad ncid: status = %d", err); +#line 484 nels = 1; +#line 484 for (j = 0; j < var_rank[i]; j++) { +#line 484 nels *= var_shape[i][j]; +#line 484 } +#line 484 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 484 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 484 IF (err) +#line 484 error("error in toMixedBase 1"); +#line 484 value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT); +#line 484 allInExtRange = allInExtRange +#line 484 && inRange3(value[j], var_type[i], NCT_FLOAT); +#line 484 } +#line 484 err = nc_put_var_float(ncid, i, value); +#line 484 if (canConvert) { +#line 484 if (allInExtRange) { +#line 484 IF (err) +#line 484 error("%s", nc_strerror(err)); +#line 484 } else { +#line 484 IF (err != NC_ERANGE) +#line 484 error("range error: status = %d", err); +#line 484 } +#line 484 } else { +#line 484 IF (nels > 0 && err != NC_ECHAR) +#line 484 error("wrong type: status = %d", err); +#line 484 } +#line 484 } +#line 484 } +#line 484 +#line 484 err = nc_close(ncid); +#line 484 IF (err) +#line 484 error("nc_close: %s", nc_strerror(err)); +#line 484 +#line 484 check_vars_float(scratch); +#line 484 +#line 484 err = remove(scratch); +#line 484 IF (err) +#line 484 error("remove of %s failed", scratch); +#line 484 } +#line 484 void +#line 485 test_nc_put_var_double(void) +#line 485 { +#line 485 int ncid; +#line 485 int varid; +#line 485 int i; +#line 485 int j; +#line 485 int err; +#line 485 int nels; +#line 485 size_t index[MAX_RANK]; +#line 485 int canConvert; /* Both text or both numeric */ +#line 485 int allInExtRange; /* all values within external range? */ +#line 485 double value[MAX_NELS]; +#line 485 +#line 485 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 485 IF (err) { +#line 485 error("nc_create: %s", nc_strerror(err)); +#line 485 return; +#line 485 } +#line 485 def_dims(ncid); +#line 485 def_vars(ncid); +#line 485 err = nc_enddef(ncid); +#line 485 IF (err) +#line 485 error("nc_enddef: %s", nc_strerror(err)); +#line 485 +#line 485 for (i = 0; i < NVARS; i++) { +#line 485 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 485 assert(var_rank[i] <= MAX_RANK); +#line 485 assert(var_nels[i] <= MAX_NELS); +#line 485 err = nc_put_var_double(BAD_ID, i, value); +#line 485 IF (err != NC_EBADID) +#line 485 error("bad ncid: status = %d", err); +#line 485 err = nc_put_var_double(ncid, BAD_VARID, value); +#line 485 IF (err != NC_ENOTVAR) +#line 485 error("bad var id: status = %d", err); +#line 485 +#line 485 nels = 1; +#line 485 for (j = 0; j < var_rank[i]; j++) { +#line 485 nels *= var_shape[i][j]; +#line 485 } +#line 485 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 485 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 485 IF (err) +#line 485 error("error in toMixedBase 1"); +#line 485 value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 485 allInExtRange = allInExtRange +#line 485 && inRange3(value[j], var_type[i], NCT_DOUBLE); +#line 485 } +#line 485 err = nc_put_var_double(ncid, i, value); +#line 485 if (canConvert) { +#line 485 if (allInExtRange) { +#line 485 IF (err) +#line 485 error("%s", nc_strerror(err)); +#line 485 } else { +#line 485 IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM) +#line 485 error("range error: status = %d", err); +#line 485 } +#line 485 } else { /* should flag wrong type even if nothing to write */ +#line 485 IF (nels > 0 && err != NC_ECHAR) +#line 485 error("wrong type: status = %d", err); +#line 485 } +#line 485 } +#line 485 +#line 485 /* Preceeding has written nothing for record variables, now try */ +#line 485 /* again with more than 0 records */ +#line 485 +#line 485 /* Write record number NRECS to force writing of preceding records */ +#line 485 /* Assumes variable cr is char vector with UNLIMITED dimension */ +#line 485 err = nc_inq_varid(ncid, "cr", &varid); +#line 485 IF (err) +#line 485 error("nc_inq_varid: %s", nc_strerror(err)); +#line 485 index[0] = NRECS-1; +#line 485 err = nc_put_var1_text(ncid, varid, index, "x"); +#line 485 IF (err) +#line 485 error("nc_put_var1_text: %s", nc_strerror(err)); +#line 485 +#line 485 for (i = 0; i < NVARS; i++) { +#line 485 if (var_dimid[i][0] == RECDIM) { /* only test record variables here */ +#line 485 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 485 assert(var_rank[i] <= MAX_RANK); +#line 485 assert(var_nels[i] <= MAX_NELS); +#line 485 err = nc_put_var_double(BAD_ID, i, value); +#line 485 IF (err != NC_EBADID) +#line 485 error("bad ncid: status = %d", err); +#line 485 nels = 1; +#line 485 for (j = 0; j < var_rank[i]; j++) { +#line 485 nels *= var_shape[i][j]; +#line 485 } +#line 485 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 485 err = toMixedBase(j, var_rank[i], var_shape[i], index); +#line 485 IF (err) +#line 485 error("error in toMixedBase 1"); +#line 485 value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 485 allInExtRange = allInExtRange +#line 485 && inRange3(value[j], var_type[i], NCT_DOUBLE); +#line 485 } +#line 485 err = nc_put_var_double(ncid, i, value); +#line 485 if (canConvert) { +#line 485 if (allInExtRange) { +#line 485 IF (err) +#line 485 error("%s", nc_strerror(err)); +#line 485 } else { +#line 485 IF (err != NC_ERANGE) +#line 485 error("range error: status = %d", err); +#line 485 } +#line 485 } else { +#line 485 IF (nels > 0 && err != NC_ECHAR) +#line 485 error("wrong type: status = %d", err); +#line 485 } +#line 485 } +#line 485 } +#line 485 +#line 485 err = nc_close(ncid); +#line 485 IF (err) +#line 485 error("nc_close: %s", nc_strerror(err)); +#line 485 +#line 485 check_vars_double(scratch); +#line 485 +#line 485 err = remove(scratch); +#line 485 IF (err) +#line 485 error("remove of %s failed", scratch); +#line 485 } +#line 485 +#line 642 void +#line 643 test_nc_put_vara_text(void) +#line 643 { +#line 643 int ncid; +#line 643 int d; +#line 643 int i; +#line 643 int j; +#line 643 int k; +#line 643 int err; +#line 643 int nslabs; +#line 643 int nels; +#line 643 size_t start[MAX_RANK]; +#line 643 size_t edge[MAX_RANK]; +#line 643 size_t mid[MAX_RANK]; +#line 643 size_t index[MAX_RANK]; +#line 643 int canConvert; /* Both text or both numeric */ +#line 643 int allInExtRange; /* all values within external range? */ +#line 643 text value[MAX_NELS]; +#line 643 +#line 643 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 643 IF (err) { +#line 643 error("nc_create: %s", nc_strerror(err)); +#line 643 return; +#line 643 } +#line 643 def_dims(ncid); +#line 643 def_vars(ncid); +#line 643 err = nc_enddef(ncid); +#line 643 IF (err) +#line 643 error("nc_enddef: %s", nc_strerror(err)); +#line 643 +#line 643 value[0] = 0; +#line 643 for (i = 0; i < NVARS; i++) { +#line 643 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 643 assert(var_rank[i] <= MAX_RANK); +#line 643 assert(var_nels[i] <= MAX_NELS); +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 start[j] = 0; +#line 643 edge[j] = 1; +#line 643 } +#line 643 err = nc_put_vara_text(BAD_ID, i, start, edge, value); +#line 643 IF (err != NC_EBADID) +#line 643 error("bad ncid: status = %d", err); +#line 643 err = nc_put_vara_text(ncid, BAD_VARID, start, edge, value); +#line 643 IF (err != NC_ENOTVAR) +#line 643 error("bad var id: status = %d", err); +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 643 start[j] = var_shape[i][j]; +#line 643 err = nc_put_vara_text(ncid, i, start, edge, value); +#line 643 IF (canConvert && err != NC_EINVALCOORDS) +#line 643 error("bad start: status = %d", err); +#line 643 start[j] = 0; +#line 643 edge[j] = var_shape[i][j] + 1; +#line 643 err = nc_put_vara_text(ncid, i, start, edge, value); +#line 643 IF (canConvert && err != NC_EEDGE) +#line 643 error("bad edge: status = %d", err); +#line 643 edge[j] = 1; +#line 643 } +#line 643 } +#line 643 /* Check correct error returned even when nothing to put */ +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 edge[j] = 0; +#line 643 } +#line 643 err = nc_put_vara_text(BAD_ID, i, start, edge, value); +#line 643 IF (err != NC_EBADID) +#line 643 error("bad ncid: status = %d", err); +#line 643 err = nc_put_vara_text(ncid, BAD_VARID, start, edge, value); +#line 643 IF (err != NC_ENOTVAR) +#line 643 error("bad var id: status = %d", err); +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 643 start[j] = var_shape[i][j]; +#line 643 err = nc_put_vara_text(ncid, i, start, edge, value); +#line 643 IF (canConvert && err != NC_EINVALCOORDS) +#line 643 error("bad start: status = %d", err); +#line 643 start[j] = 0; +#line 643 } +#line 643 } +#line 643 err = nc_put_vara_text(ncid, i, start, edge, value); +#line 643 if (canConvert) { +#line 643 IF (err) +#line 643 error("%s", nc_strerror(err)); +#line 643 } else { +#line 643 IF (err != NC_ECHAR) +#line 643 error("wrong type: status = %d", err); +#line 643 } +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 edge[j] = 1; +#line 643 } +#line 643 +#line 643 /* Choose a random point dividing each dim into 2 parts */ +#line 643 /* Put 2^rank (nslabs) slabs so defined */ +#line 643 nslabs = 1; +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 mid[j] = roll( var_shape[i][j] ); +#line 643 nslabs *= 2; +#line 643 } +#line 643 /* bits of k determine whether to put lower or upper part of dim */ +#line 643 for (k = 0; k < nslabs; k++) { +#line 643 nels = 1; +#line 643 for (j = 0; j < var_rank[i]; j++) { +#line 643 if ((k >> j) & 1) { +#line 643 start[j] = 0; +#line 643 edge[j] = mid[j]; +#line 643 }else{ +#line 643 start[j] = mid[j]; +#line 643 edge[j] = var_shape[i][j] - mid[j]; +#line 643 } +#line 643 nels *= edge[j]; +#line 643 } +#line 643 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 643 err = toMixedBase(j, var_rank[i], edge, index); +#line 643 IF (err) +#line 643 error("error in toMixedBase 1"); +#line 643 for (d = 0; d < var_rank[i]; d++) +#line 643 index[d] += start[d]; +#line 643 value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT); +#line 643 allInExtRange = allInExtRange +#line 643 && inRange3(value[j], var_type[i], NCT_TEXT); +#line 643 } +#line 643 if (var_rank[i] == 0 && i%2 == 0) +#line 643 err = nc_put_vara_text(ncid, i, NULL, NULL, value); +#line 643 else +#line 643 err = nc_put_vara_text(ncid, i, start, edge, value); +#line 643 if (canConvert) { +#line 643 if (allInExtRange) { +#line 643 IF (err) +#line 643 error("%s", nc_strerror(err)); +#line 643 } else { +#line 643 IF (err != NC_ERANGE) +#line 643 error("range error: status = %d", err); +#line 643 } +#line 643 } else { +#line 643 IF (nels > 0 && err != NC_ECHAR) +#line 643 error("wrong type: status = %d", err); +#line 643 } +#line 643 } +#line 643 } +#line 643 +#line 643 err = nc_close(ncid); +#line 643 IF (err) +#line 643 error("nc_close: %s", nc_strerror(err)); +#line 643 +#line 643 check_vars_text(scratch); +#line 643 +#line 643 err = remove(scratch); +#line 643 IF (err) +#line 643 error("remove of %s failed", scratch); +#line 643 } +#line 643 void +#line 644 test_nc_put_vara_uchar(void) +#line 644 { +#line 644 int ncid; +#line 644 int d; +#line 644 int i; +#line 644 int j; +#line 644 int k; +#line 644 int err; +#line 644 int nslabs; +#line 644 int nels; +#line 644 size_t start[MAX_RANK]; +#line 644 size_t edge[MAX_RANK]; +#line 644 size_t mid[MAX_RANK]; +#line 644 size_t index[MAX_RANK]; +#line 644 int canConvert; /* Both text or both numeric */ +#line 644 int allInExtRange; /* all values within external range? */ +#line 644 uchar value[MAX_NELS]; +#line 644 +#line 644 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 644 IF (err) { +#line 644 error("nc_create: %s", nc_strerror(err)); +#line 644 return; +#line 644 } +#line 644 def_dims(ncid); +#line 644 def_vars(ncid); +#line 644 err = nc_enddef(ncid); +#line 644 IF (err) +#line 644 error("nc_enddef: %s", nc_strerror(err)); +#line 644 +#line 644 value[0] = 0; +#line 644 for (i = 0; i < NVARS; i++) { +#line 644 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 644 assert(var_rank[i] <= MAX_RANK); +#line 644 assert(var_nels[i] <= MAX_NELS); +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 start[j] = 0; +#line 644 edge[j] = 1; +#line 644 } +#line 644 err = nc_put_vara_uchar(BAD_ID, i, start, edge, value); +#line 644 IF (err != NC_EBADID) +#line 644 error("bad ncid: status = %d", err); +#line 644 err = nc_put_vara_uchar(ncid, BAD_VARID, start, edge, value); +#line 644 IF (err != NC_ENOTVAR) +#line 644 error("bad var id: status = %d", err); +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 644 start[j] = var_shape[i][j]; +#line 644 err = nc_put_vara_uchar(ncid, i, start, edge, value); +#line 644 IF (canConvert && err != NC_EINVALCOORDS) +#line 644 error("bad start: status = %d", err); +#line 644 start[j] = 0; +#line 644 edge[j] = var_shape[i][j] + 1; +#line 644 err = nc_put_vara_uchar(ncid, i, start, edge, value); +#line 644 IF (canConvert && err != NC_EEDGE) +#line 644 error("bad edge: status = %d", err); +#line 644 edge[j] = 1; +#line 644 } +#line 644 } +#line 644 /* Check correct error returned even when nothing to put */ +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 edge[j] = 0; +#line 644 } +#line 644 err = nc_put_vara_uchar(BAD_ID, i, start, edge, value); +#line 644 IF (err != NC_EBADID) +#line 644 error("bad ncid: status = %d", err); +#line 644 err = nc_put_vara_uchar(ncid, BAD_VARID, start, edge, value); +#line 644 IF (err != NC_ENOTVAR) +#line 644 error("bad var id: status = %d", err); +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 644 start[j] = var_shape[i][j]; +#line 644 err = nc_put_vara_uchar(ncid, i, start, edge, value); +#line 644 IF (canConvert && err != NC_EINVALCOORDS) +#line 644 error("bad start: status = %d", err); +#line 644 start[j] = 0; +#line 644 } +#line 644 } +#line 644 err = nc_put_vara_uchar(ncid, i, start, edge, value); +#line 644 if (canConvert) { +#line 644 IF (err) +#line 644 error("%s", nc_strerror(err)); +#line 644 } else { +#line 644 IF (err != NC_ECHAR) +#line 644 error("wrong type: status = %d", err); +#line 644 } +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 edge[j] = 1; +#line 644 } +#line 644 +#line 644 /* Choose a random point dividing each dim into 2 parts */ +#line 644 /* Put 2^rank (nslabs) slabs so defined */ +#line 644 nslabs = 1; +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 mid[j] = roll( var_shape[i][j] ); +#line 644 nslabs *= 2; +#line 644 } +#line 644 /* bits of k determine whether to put lower or upper part of dim */ +#line 644 for (k = 0; k < nslabs; k++) { +#line 644 nels = 1; +#line 644 for (j = 0; j < var_rank[i]; j++) { +#line 644 if ((k >> j) & 1) { +#line 644 start[j] = 0; +#line 644 edge[j] = mid[j]; +#line 644 }else{ +#line 644 start[j] = mid[j]; +#line 644 edge[j] = var_shape[i][j] - mid[j]; +#line 644 } +#line 644 nels *= edge[j]; +#line 644 } +#line 644 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 644 err = toMixedBase(j, var_rank[i], edge, index); +#line 644 IF (err) +#line 644 error("error in toMixedBase 1"); +#line 644 for (d = 0; d < var_rank[i]; d++) +#line 644 index[d] += start[d]; +#line 644 value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR); +#line 644 allInExtRange = allInExtRange +#line 644 && inRange3(value[j], var_type[i], NCT_UCHAR); +#line 644 } +#line 644 if (var_rank[i] == 0 && i%2 == 0) +#line 644 err = nc_put_vara_uchar(ncid, i, NULL, NULL, value); +#line 644 else +#line 644 err = nc_put_vara_uchar(ncid, i, start, edge, value); +#line 644 if (canConvert) { +#line 644 if (allInExtRange) { +#line 644 IF (err) +#line 644 error("%s", nc_strerror(err)); +#line 644 } else { +#line 644 IF (err != NC_ERANGE) +#line 644 error("range error: status = %d", err); +#line 644 } +#line 644 } else { +#line 644 IF (nels > 0 && err != NC_ECHAR) +#line 644 error("wrong type: status = %d", err); +#line 644 } +#line 644 } +#line 644 } +#line 644 +#line 644 err = nc_close(ncid); +#line 644 IF (err) +#line 644 error("nc_close: %s", nc_strerror(err)); +#line 644 +#line 644 check_vars_uchar(scratch); +#line 644 +#line 644 err = remove(scratch); +#line 644 IF (err) +#line 644 error("remove of %s failed", scratch); +#line 644 } +#line 644 void +#line 645 test_nc_put_vara_schar(void) +#line 645 { +#line 645 int ncid; +#line 645 int d; +#line 645 int i; +#line 645 int j; +#line 645 int k; +#line 645 int err; +#line 645 int nslabs; +#line 645 int nels; +#line 645 size_t start[MAX_RANK]; +#line 645 size_t edge[MAX_RANK]; +#line 645 size_t mid[MAX_RANK]; +#line 645 size_t index[MAX_RANK]; +#line 645 int canConvert; /* Both text or both numeric */ +#line 645 int allInExtRange; /* all values within external range? */ +#line 645 schar value[MAX_NELS]; +#line 645 +#line 645 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 645 IF (err) { +#line 645 error("nc_create: %s", nc_strerror(err)); +#line 645 return; +#line 645 } +#line 645 def_dims(ncid); +#line 645 def_vars(ncid); +#line 645 err = nc_enddef(ncid); +#line 645 IF (err) +#line 645 error("nc_enddef: %s", nc_strerror(err)); +#line 645 +#line 645 value[0] = 0; +#line 645 for (i = 0; i < NVARS; i++) { +#line 645 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 645 assert(var_rank[i] <= MAX_RANK); +#line 645 assert(var_nels[i] <= MAX_NELS); +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 start[j] = 0; +#line 645 edge[j] = 1; +#line 645 } +#line 645 err = nc_put_vara_schar(BAD_ID, i, start, edge, value); +#line 645 IF (err != NC_EBADID) +#line 645 error("bad ncid: status = %d", err); +#line 645 err = nc_put_vara_schar(ncid, BAD_VARID, start, edge, value); +#line 645 IF (err != NC_ENOTVAR) +#line 645 error("bad var id: status = %d", err); +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 645 start[j] = var_shape[i][j]; +#line 645 err = nc_put_vara_schar(ncid, i, start, edge, value); +#line 645 IF (canConvert && err != NC_EINVALCOORDS) +#line 645 error("bad start: status = %d", err); +#line 645 start[j] = 0; +#line 645 edge[j] = var_shape[i][j] + 1; +#line 645 err = nc_put_vara_schar(ncid, i, start, edge, value); +#line 645 IF (canConvert && err != NC_EEDGE) +#line 645 error("bad edge: status = %d", err); +#line 645 edge[j] = 1; +#line 645 } +#line 645 } +#line 645 /* Check correct error returned even when nothing to put */ +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 edge[j] = 0; +#line 645 } +#line 645 err = nc_put_vara_schar(BAD_ID, i, start, edge, value); +#line 645 IF (err != NC_EBADID) +#line 645 error("bad ncid: status = %d", err); +#line 645 err = nc_put_vara_schar(ncid, BAD_VARID, start, edge, value); +#line 645 IF (err != NC_ENOTVAR) +#line 645 error("bad var id: status = %d", err); +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 645 start[j] = var_shape[i][j]; +#line 645 err = nc_put_vara_schar(ncid, i, start, edge, value); +#line 645 IF (canConvert && err != NC_EINVALCOORDS) +#line 645 error("bad start: status = %d", err); +#line 645 start[j] = 0; +#line 645 } +#line 645 } +#line 645 err = nc_put_vara_schar(ncid, i, start, edge, value); +#line 645 if (canConvert) { +#line 645 IF (err) +#line 645 error("%s", nc_strerror(err)); +#line 645 } else { +#line 645 IF (err != NC_ECHAR) +#line 645 error("wrong type: status = %d", err); +#line 645 } +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 edge[j] = 1; +#line 645 } +#line 645 +#line 645 /* Choose a random point dividing each dim into 2 parts */ +#line 645 /* Put 2^rank (nslabs) slabs so defined */ +#line 645 nslabs = 1; +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 mid[j] = roll( var_shape[i][j] ); +#line 645 nslabs *= 2; +#line 645 } +#line 645 /* bits of k determine whether to put lower or upper part of dim */ +#line 645 for (k = 0; k < nslabs; k++) { +#line 645 nels = 1; +#line 645 for (j = 0; j < var_rank[i]; j++) { +#line 645 if ((k >> j) & 1) { +#line 645 start[j] = 0; +#line 645 edge[j] = mid[j]; +#line 645 }else{ +#line 645 start[j] = mid[j]; +#line 645 edge[j] = var_shape[i][j] - mid[j]; +#line 645 } +#line 645 nels *= edge[j]; +#line 645 } +#line 645 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 645 err = toMixedBase(j, var_rank[i], edge, index); +#line 645 IF (err) +#line 645 error("error in toMixedBase 1"); +#line 645 for (d = 0; d < var_rank[i]; d++) +#line 645 index[d] += start[d]; +#line 645 value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR); +#line 645 allInExtRange = allInExtRange +#line 645 && inRange3(value[j], var_type[i], NCT_SCHAR); +#line 645 } +#line 645 if (var_rank[i] == 0 && i%2 == 0) +#line 645 err = nc_put_vara_schar(ncid, i, NULL, NULL, value); +#line 645 else +#line 645 err = nc_put_vara_schar(ncid, i, start, edge, value); +#line 645 if (canConvert) { +#line 645 if (allInExtRange) { +#line 645 IF (err) +#line 645 error("%s", nc_strerror(err)); +#line 645 } else { +#line 645 IF (err != NC_ERANGE) +#line 645 error("range error: status = %d", err); +#line 645 } +#line 645 } else { +#line 645 IF (nels > 0 && err != NC_ECHAR) +#line 645 error("wrong type: status = %d", err); +#line 645 } +#line 645 } +#line 645 } +#line 645 +#line 645 err = nc_close(ncid); +#line 645 IF (err) +#line 645 error("nc_close: %s", nc_strerror(err)); +#line 645 +#line 645 check_vars_schar(scratch); +#line 645 +#line 645 err = remove(scratch); +#line 645 IF (err) +#line 645 error("remove of %s failed", scratch); +#line 645 } +#line 645 void +#line 646 test_nc_put_vara_short(void) +#line 646 { +#line 646 int ncid; +#line 646 int d; +#line 646 int i; +#line 646 int j; +#line 646 int k; +#line 646 int err; +#line 646 int nslabs; +#line 646 int nels; +#line 646 size_t start[MAX_RANK]; +#line 646 size_t edge[MAX_RANK]; +#line 646 size_t mid[MAX_RANK]; +#line 646 size_t index[MAX_RANK]; +#line 646 int canConvert; /* Both text or both numeric */ +#line 646 int allInExtRange; /* all values within external range? */ +#line 646 short value[MAX_NELS]; +#line 646 +#line 646 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 646 IF (err) { +#line 646 error("nc_create: %s", nc_strerror(err)); +#line 646 return; +#line 646 } +#line 646 def_dims(ncid); +#line 646 def_vars(ncid); +#line 646 err = nc_enddef(ncid); +#line 646 IF (err) +#line 646 error("nc_enddef: %s", nc_strerror(err)); +#line 646 +#line 646 value[0] = 0; +#line 646 for (i = 0; i < NVARS; i++) { +#line 646 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 646 assert(var_rank[i] <= MAX_RANK); +#line 646 assert(var_nels[i] <= MAX_NELS); +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 start[j] = 0; +#line 646 edge[j] = 1; +#line 646 } +#line 646 err = nc_put_vara_short(BAD_ID, i, start, edge, value); +#line 646 IF (err != NC_EBADID) +#line 646 error("bad ncid: status = %d", err); +#line 646 err = nc_put_vara_short(ncid, BAD_VARID, start, edge, value); +#line 646 IF (err != NC_ENOTVAR) +#line 646 error("bad var id: status = %d", err); +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 646 start[j] = var_shape[i][j]; +#line 646 err = nc_put_vara_short(ncid, i, start, edge, value); +#line 646 IF (canConvert && err != NC_EINVALCOORDS) +#line 646 error("bad start: status = %d", err); +#line 646 start[j] = 0; +#line 646 edge[j] = var_shape[i][j] + 1; +#line 646 err = nc_put_vara_short(ncid, i, start, edge, value); +#line 646 IF (canConvert && err != NC_EEDGE) +#line 646 error("bad edge: status = %d", err); +#line 646 edge[j] = 1; +#line 646 } +#line 646 } +#line 646 /* Check correct error returned even when nothing to put */ +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 edge[j] = 0; +#line 646 } +#line 646 err = nc_put_vara_short(BAD_ID, i, start, edge, value); +#line 646 IF (err != NC_EBADID) +#line 646 error("bad ncid: status = %d", err); +#line 646 err = nc_put_vara_short(ncid, BAD_VARID, start, edge, value); +#line 646 IF (err != NC_ENOTVAR) +#line 646 error("bad var id: status = %d", err); +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 646 start[j] = var_shape[i][j]; +#line 646 err = nc_put_vara_short(ncid, i, start, edge, value); +#line 646 IF (canConvert && err != NC_EINVALCOORDS) +#line 646 error("bad start: status = %d", err); +#line 646 start[j] = 0; +#line 646 } +#line 646 } +#line 646 err = nc_put_vara_short(ncid, i, start, edge, value); +#line 646 if (canConvert) { +#line 646 IF (err) +#line 646 error("%s", nc_strerror(err)); +#line 646 } else { +#line 646 IF (err != NC_ECHAR) +#line 646 error("wrong type: status = %d", err); +#line 646 } +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 edge[j] = 1; +#line 646 } +#line 646 +#line 646 /* Choose a random point dividing each dim into 2 parts */ +#line 646 /* Put 2^rank (nslabs) slabs so defined */ +#line 646 nslabs = 1; +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 mid[j] = roll( var_shape[i][j] ); +#line 646 nslabs *= 2; +#line 646 } +#line 646 /* bits of k determine whether to put lower or upper part of dim */ +#line 646 for (k = 0; k < nslabs; k++) { +#line 646 nels = 1; +#line 646 for (j = 0; j < var_rank[i]; j++) { +#line 646 if ((k >> j) & 1) { +#line 646 start[j] = 0; +#line 646 edge[j] = mid[j]; +#line 646 }else{ +#line 646 start[j] = mid[j]; +#line 646 edge[j] = var_shape[i][j] - mid[j]; +#line 646 } +#line 646 nels *= edge[j]; +#line 646 } +#line 646 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 646 err = toMixedBase(j, var_rank[i], edge, index); +#line 646 IF (err) +#line 646 error("error in toMixedBase 1"); +#line 646 for (d = 0; d < var_rank[i]; d++) +#line 646 index[d] += start[d]; +#line 646 value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT); +#line 646 allInExtRange = allInExtRange +#line 646 && inRange3(value[j], var_type[i], NCT_SHORT); +#line 646 } +#line 646 if (var_rank[i] == 0 && i%2 == 0) +#line 646 err = nc_put_vara_short(ncid, i, NULL, NULL, value); +#line 646 else +#line 646 err = nc_put_vara_short(ncid, i, start, edge, value); +#line 646 if (canConvert) { +#line 646 if (allInExtRange) { +#line 646 IF (err) +#line 646 error("%s", nc_strerror(err)); +#line 646 } else { +#line 646 IF (err != NC_ERANGE) +#line 646 error("range error: status = %d", err); +#line 646 } +#line 646 } else { +#line 646 IF (nels > 0 && err != NC_ECHAR) +#line 646 error("wrong type: status = %d", err); +#line 646 } +#line 646 } +#line 646 } +#line 646 +#line 646 err = nc_close(ncid); +#line 646 IF (err) +#line 646 error("nc_close: %s", nc_strerror(err)); +#line 646 +#line 646 check_vars_short(scratch); +#line 646 +#line 646 err = remove(scratch); +#line 646 IF (err) +#line 646 error("remove of %s failed", scratch); +#line 646 } +#line 646 void +#line 647 test_nc_put_vara_int(void) +#line 647 { +#line 647 int ncid; +#line 647 int d; +#line 647 int i; +#line 647 int j; +#line 647 int k; +#line 647 int err; +#line 647 int nslabs; +#line 647 int nels; +#line 647 size_t start[MAX_RANK]; +#line 647 size_t edge[MAX_RANK]; +#line 647 size_t mid[MAX_RANK]; +#line 647 size_t index[MAX_RANK]; +#line 647 int canConvert; /* Both text or both numeric */ +#line 647 int allInExtRange; /* all values within external range? */ +#line 647 int value[MAX_NELS]; +#line 647 +#line 647 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 647 IF (err) { +#line 647 error("nc_create: %s", nc_strerror(err)); +#line 647 return; +#line 647 } +#line 647 def_dims(ncid); +#line 647 def_vars(ncid); +#line 647 err = nc_enddef(ncid); +#line 647 IF (err) +#line 647 error("nc_enddef: %s", nc_strerror(err)); +#line 647 +#line 647 value[0] = 0; +#line 647 for (i = 0; i < NVARS; i++) { +#line 647 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 647 assert(var_rank[i] <= MAX_RANK); +#line 647 assert(var_nels[i] <= MAX_NELS); +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 start[j] = 0; +#line 647 edge[j] = 1; +#line 647 } +#line 647 err = nc_put_vara_int(BAD_ID, i, start, edge, value); +#line 647 IF (err != NC_EBADID) +#line 647 error("bad ncid: status = %d", err); +#line 647 err = nc_put_vara_int(ncid, BAD_VARID, start, edge, value); +#line 647 IF (err != NC_ENOTVAR) +#line 647 error("bad var id: status = %d", err); +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 647 start[j] = var_shape[i][j]; +#line 647 err = nc_put_vara_int(ncid, i, start, edge, value); +#line 647 IF (canConvert && err != NC_EINVALCOORDS) +#line 647 error("bad start: status = %d", err); +#line 647 start[j] = 0; +#line 647 edge[j] = var_shape[i][j] + 1; +#line 647 err = nc_put_vara_int(ncid, i, start, edge, value); +#line 647 IF (canConvert && err != NC_EEDGE) +#line 647 error("bad edge: status = %d", err); +#line 647 edge[j] = 1; +#line 647 } +#line 647 } +#line 647 /* Check correct error returned even when nothing to put */ +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 edge[j] = 0; +#line 647 } +#line 647 err = nc_put_vara_int(BAD_ID, i, start, edge, value); +#line 647 IF (err != NC_EBADID) +#line 647 error("bad ncid: status = %d", err); +#line 647 err = nc_put_vara_int(ncid, BAD_VARID, start, edge, value); +#line 647 IF (err != NC_ENOTVAR) +#line 647 error("bad var id: status = %d", err); +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 647 start[j] = var_shape[i][j]; +#line 647 err = nc_put_vara_int(ncid, i, start, edge, value); +#line 647 IF (canConvert && err != NC_EINVALCOORDS) +#line 647 error("bad start: status = %d", err); +#line 647 start[j] = 0; +#line 647 } +#line 647 } +#line 647 err = nc_put_vara_int(ncid, i, start, edge, value); +#line 647 if (canConvert) { +#line 647 IF (err) +#line 647 error("%s", nc_strerror(err)); +#line 647 } else { +#line 647 IF (err != NC_ECHAR) +#line 647 error("wrong type: status = %d", err); +#line 647 } +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 edge[j] = 1; +#line 647 } +#line 647 +#line 647 /* Choose a random point dividing each dim into 2 parts */ +#line 647 /* Put 2^rank (nslabs) slabs so defined */ +#line 647 nslabs = 1; +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 mid[j] = roll( var_shape[i][j] ); +#line 647 nslabs *= 2; +#line 647 } +#line 647 /* bits of k determine whether to put lower or upper part of dim */ +#line 647 for (k = 0; k < nslabs; k++) { +#line 647 nels = 1; +#line 647 for (j = 0; j < var_rank[i]; j++) { +#line 647 if ((k >> j) & 1) { +#line 647 start[j] = 0; +#line 647 edge[j] = mid[j]; +#line 647 }else{ +#line 647 start[j] = mid[j]; +#line 647 edge[j] = var_shape[i][j] - mid[j]; +#line 647 } +#line 647 nels *= edge[j]; +#line 647 } +#line 647 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 647 err = toMixedBase(j, var_rank[i], edge, index); +#line 647 IF (err) +#line 647 error("error in toMixedBase 1"); +#line 647 for (d = 0; d < var_rank[i]; d++) +#line 647 index[d] += start[d]; +#line 647 value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT); +#line 647 allInExtRange = allInExtRange +#line 647 && inRange3(value[j], var_type[i], NCT_INT); +#line 647 } +#line 647 if (var_rank[i] == 0 && i%2 == 0) +#line 647 err = nc_put_vara_int(ncid, i, NULL, NULL, value); +#line 647 else +#line 647 err = nc_put_vara_int(ncid, i, start, edge, value); +#line 647 if (canConvert) { +#line 647 if (allInExtRange) { +#line 647 IF (err) +#line 647 error("%s", nc_strerror(err)); +#line 647 } else { +#line 647 IF (err != NC_ERANGE) +#line 647 error("range error: status = %d", err); +#line 647 } +#line 647 } else { +#line 647 IF (nels > 0 && err != NC_ECHAR) +#line 647 error("wrong type: status = %d", err); +#line 647 } +#line 647 } +#line 647 } +#line 647 +#line 647 err = nc_close(ncid); +#line 647 IF (err) +#line 647 error("nc_close: %s", nc_strerror(err)); +#line 647 +#line 647 check_vars_int(scratch); +#line 647 +#line 647 err = remove(scratch); +#line 647 IF (err) +#line 647 error("remove of %s failed", scratch); +#line 647 } +#line 647 void +#line 648 test_nc_put_vara_long(void) +#line 648 { +#line 648 int ncid; +#line 648 int d; +#line 648 int i; +#line 648 int j; +#line 648 int k; +#line 648 int err; +#line 648 int nslabs; +#line 648 int nels; +#line 648 size_t start[MAX_RANK]; +#line 648 size_t edge[MAX_RANK]; +#line 648 size_t mid[MAX_RANK]; +#line 648 size_t index[MAX_RANK]; +#line 648 int canConvert; /* Both text or both numeric */ +#line 648 int allInExtRange; /* all values within external range? */ +#line 648 long value[MAX_NELS]; +#line 648 +#line 648 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 648 IF (err) { +#line 648 error("nc_create: %s", nc_strerror(err)); +#line 648 return; +#line 648 } +#line 648 def_dims(ncid); +#line 648 def_vars(ncid); +#line 648 err = nc_enddef(ncid); +#line 648 IF (err) +#line 648 error("nc_enddef: %s", nc_strerror(err)); +#line 648 +#line 648 value[0] = 0; +#line 648 for (i = 0; i < NVARS; i++) { +#line 648 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 648 assert(var_rank[i] <= MAX_RANK); +#line 648 assert(var_nels[i] <= MAX_NELS); +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 start[j] = 0; +#line 648 edge[j] = 1; +#line 648 } +#line 648 err = nc_put_vara_long(BAD_ID, i, start, edge, value); +#line 648 IF (err != NC_EBADID) +#line 648 error("bad ncid: status = %d", err); +#line 648 err = nc_put_vara_long(ncid, BAD_VARID, start, edge, value); +#line 648 IF (err != NC_ENOTVAR) +#line 648 error("bad var id: status = %d", err); +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 648 start[j] = var_shape[i][j]; +#line 648 err = nc_put_vara_long(ncid, i, start, edge, value); +#line 648 IF (canConvert && err != NC_EINVALCOORDS) +#line 648 error("bad start: status = %d", err); +#line 648 start[j] = 0; +#line 648 edge[j] = var_shape[i][j] + 1; +#line 648 err = nc_put_vara_long(ncid, i, start, edge, value); +#line 648 IF (canConvert && err != NC_EEDGE) +#line 648 error("bad edge: status = %d", err); +#line 648 edge[j] = 1; +#line 648 } +#line 648 } +#line 648 /* Check correct error returned even when nothing to put */ +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 edge[j] = 0; +#line 648 } +#line 648 err = nc_put_vara_long(BAD_ID, i, start, edge, value); +#line 648 IF (err != NC_EBADID) +#line 648 error("bad ncid: status = %d", err); +#line 648 err = nc_put_vara_long(ncid, BAD_VARID, start, edge, value); +#line 648 IF (err != NC_ENOTVAR) +#line 648 error("bad var id: status = %d", err); +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 648 start[j] = var_shape[i][j]; +#line 648 err = nc_put_vara_long(ncid, i, start, edge, value); +#line 648 IF (canConvert && err != NC_EINVALCOORDS) +#line 648 error("bad start: status = %d", err); +#line 648 start[j] = 0; +#line 648 } +#line 648 } +#line 648 err = nc_put_vara_long(ncid, i, start, edge, value); +#line 648 if (canConvert) { +#line 648 IF (err) +#line 648 error("%s", nc_strerror(err)); +#line 648 } else { +#line 648 IF (err != NC_ECHAR) +#line 648 error("wrong type: status = %d", err); +#line 648 } +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 edge[j] = 1; +#line 648 } +#line 648 +#line 648 /* Choose a random point dividing each dim into 2 parts */ +#line 648 /* Put 2^rank (nslabs) slabs so defined */ +#line 648 nslabs = 1; +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 mid[j] = roll( var_shape[i][j] ); +#line 648 nslabs *= 2; +#line 648 } +#line 648 /* bits of k determine whether to put lower or upper part of dim */ +#line 648 for (k = 0; k < nslabs; k++) { +#line 648 nels = 1; +#line 648 for (j = 0; j < var_rank[i]; j++) { +#line 648 if ((k >> j) & 1) { +#line 648 start[j] = 0; +#line 648 edge[j] = mid[j]; +#line 648 }else{ +#line 648 start[j] = mid[j]; +#line 648 edge[j] = var_shape[i][j] - mid[j]; +#line 648 } +#line 648 nels *= edge[j]; +#line 648 } +#line 648 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 648 err = toMixedBase(j, var_rank[i], edge, index); +#line 648 IF (err) +#line 648 error("error in toMixedBase 1"); +#line 648 for (d = 0; d < var_rank[i]; d++) +#line 648 index[d] += start[d]; +#line 648 value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG); +#line 648 allInExtRange = allInExtRange +#line 648 && inRange3(value[j], var_type[i], NCT_LONG); +#line 648 } +#line 648 if (var_rank[i] == 0 && i%2 == 0) +#line 648 err = nc_put_vara_long(ncid, i, NULL, NULL, value); +#line 648 else +#line 648 err = nc_put_vara_long(ncid, i, start, edge, value); +#line 648 if (canConvert) { +#line 648 if (allInExtRange) { +#line 648 IF (err) +#line 648 error("%s", nc_strerror(err)); +#line 648 } else { +#line 648 IF (err != NC_ERANGE) +#line 648 error("range error: status = %d", err); +#line 648 } +#line 648 } else { +#line 648 IF (nels > 0 && err != NC_ECHAR) +#line 648 error("wrong type: status = %d", err); +#line 648 } +#line 648 } +#line 648 } +#line 648 +#line 648 err = nc_close(ncid); +#line 648 IF (err) +#line 648 error("nc_close: %s", nc_strerror(err)); +#line 648 +#line 648 check_vars_long(scratch); +#line 648 +#line 648 err = remove(scratch); +#line 648 IF (err) +#line 648 error("remove of %s failed", scratch); +#line 648 } +#line 648 void +#line 649 test_nc_put_vara_float(void) +#line 649 { +#line 649 int ncid; +#line 649 int d; +#line 649 int i; +#line 649 int j; +#line 649 int k; +#line 649 int err; +#line 649 int nslabs; +#line 649 int nels; +#line 649 size_t start[MAX_RANK]; +#line 649 size_t edge[MAX_RANK]; +#line 649 size_t mid[MAX_RANK]; +#line 649 size_t index[MAX_RANK]; +#line 649 int canConvert; /* Both text or both numeric */ +#line 649 int allInExtRange; /* all values within external range? */ +#line 649 float value[MAX_NELS]; +#line 649 +#line 649 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 649 IF (err) { +#line 649 error("nc_create: %s", nc_strerror(err)); +#line 649 return; +#line 649 } +#line 649 def_dims(ncid); +#line 649 def_vars(ncid); +#line 649 err = nc_enddef(ncid); +#line 649 IF (err) +#line 649 error("nc_enddef: %s", nc_strerror(err)); +#line 649 +#line 649 value[0] = 0; +#line 649 for (i = 0; i < NVARS; i++) { +#line 649 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 649 assert(var_rank[i] <= MAX_RANK); +#line 649 assert(var_nels[i] <= MAX_NELS); +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 start[j] = 0; +#line 649 edge[j] = 1; +#line 649 } +#line 649 err = nc_put_vara_float(BAD_ID, i, start, edge, value); +#line 649 IF (err != NC_EBADID) +#line 649 error("bad ncid: status = %d", err); +#line 649 err = nc_put_vara_float(ncid, BAD_VARID, start, edge, value); +#line 649 IF (err != NC_ENOTVAR) +#line 649 error("bad var id: status = %d", err); +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 649 start[j] = var_shape[i][j]; +#line 649 err = nc_put_vara_float(ncid, i, start, edge, value); +#line 649 IF (canConvert && err != NC_EINVALCOORDS) +#line 649 error("bad start: status = %d", err); +#line 649 start[j] = 0; +#line 649 edge[j] = var_shape[i][j] + 1; +#line 649 err = nc_put_vara_float(ncid, i, start, edge, value); +#line 649 IF (canConvert && err != NC_EEDGE) +#line 649 error("bad edge: status = %d", err); +#line 649 edge[j] = 1; +#line 649 } +#line 649 } +#line 649 /* Check correct error returned even when nothing to put */ +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 edge[j] = 0; +#line 649 } +#line 649 err = nc_put_vara_float(BAD_ID, i, start, edge, value); +#line 649 IF (err != NC_EBADID) +#line 649 error("bad ncid: status = %d", err); +#line 649 err = nc_put_vara_float(ncid, BAD_VARID, start, edge, value); +#line 649 IF (err != NC_ENOTVAR) +#line 649 error("bad var id: status = %d", err); +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 649 start[j] = var_shape[i][j]; +#line 649 err = nc_put_vara_float(ncid, i, start, edge, value); +#line 649 IF (canConvert && err != NC_EINVALCOORDS) +#line 649 error("bad start: status = %d", err); +#line 649 start[j] = 0; +#line 649 } +#line 649 } +#line 649 err = nc_put_vara_float(ncid, i, start, edge, value); +#line 649 if (canConvert) { +#line 649 IF (err) +#line 649 error("%s", nc_strerror(err)); +#line 649 } else { +#line 649 IF (err != NC_ECHAR) +#line 649 error("wrong type: status = %d", err); +#line 649 } +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 edge[j] = 1; +#line 649 } +#line 649 +#line 649 /* Choose a random point dividing each dim into 2 parts */ +#line 649 /* Put 2^rank (nslabs) slabs so defined */ +#line 649 nslabs = 1; +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 mid[j] = roll( var_shape[i][j] ); +#line 649 nslabs *= 2; +#line 649 } +#line 649 /* bits of k determine whether to put lower or upper part of dim */ +#line 649 for (k = 0; k < nslabs; k++) { +#line 649 nels = 1; +#line 649 for (j = 0; j < var_rank[i]; j++) { +#line 649 if ((k >> j) & 1) { +#line 649 start[j] = 0; +#line 649 edge[j] = mid[j]; +#line 649 }else{ +#line 649 start[j] = mid[j]; +#line 649 edge[j] = var_shape[i][j] - mid[j]; +#line 649 } +#line 649 nels *= edge[j]; +#line 649 } +#line 649 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 649 err = toMixedBase(j, var_rank[i], edge, index); +#line 649 IF (err) +#line 649 error("error in toMixedBase 1"); +#line 649 for (d = 0; d < var_rank[i]; d++) +#line 649 index[d] += start[d]; +#line 649 value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT); +#line 649 allInExtRange = allInExtRange +#line 649 && inRange3(value[j], var_type[i], NCT_FLOAT); +#line 649 } +#line 649 if (var_rank[i] == 0 && i%2 == 0) +#line 649 err = nc_put_vara_float(ncid, i, NULL, NULL, value); +#line 649 else +#line 649 err = nc_put_vara_float(ncid, i, start, edge, value); +#line 649 if (canConvert) { +#line 649 if (allInExtRange) { +#line 649 IF (err) +#line 649 error("%s", nc_strerror(err)); +#line 649 } else { +#line 649 IF (err != NC_ERANGE) +#line 649 error("range error: status = %d", err); +#line 649 } +#line 649 } else { +#line 649 IF (nels > 0 && err != NC_ECHAR) +#line 649 error("wrong type: status = %d", err); +#line 649 } +#line 649 } +#line 649 } +#line 649 +#line 649 err = nc_close(ncid); +#line 649 IF (err) +#line 649 error("nc_close: %s", nc_strerror(err)); +#line 649 +#line 649 check_vars_float(scratch); +#line 649 +#line 649 err = remove(scratch); +#line 649 IF (err) +#line 649 error("remove of %s failed", scratch); +#line 649 } +#line 649 void +#line 650 test_nc_put_vara_double(void) +#line 650 { +#line 650 int ncid; +#line 650 int d; +#line 650 int i; +#line 650 int j; +#line 650 int k; +#line 650 int err; +#line 650 int nslabs; +#line 650 int nels; +#line 650 size_t start[MAX_RANK]; +#line 650 size_t edge[MAX_RANK]; +#line 650 size_t mid[MAX_RANK]; +#line 650 size_t index[MAX_RANK]; +#line 650 int canConvert; /* Both text or both numeric */ +#line 650 int allInExtRange; /* all values within external range? */ +#line 650 double value[MAX_NELS]; +#line 650 +#line 650 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 650 IF (err) { +#line 650 error("nc_create: %s", nc_strerror(err)); +#line 650 return; +#line 650 } +#line 650 def_dims(ncid); +#line 650 def_vars(ncid); +#line 650 err = nc_enddef(ncid); +#line 650 IF (err) +#line 650 error("nc_enddef: %s", nc_strerror(err)); +#line 650 +#line 650 value[0] = 0; +#line 650 for (i = 0; i < NVARS; i++) { +#line 650 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 650 assert(var_rank[i] <= MAX_RANK); +#line 650 assert(var_nels[i] <= MAX_NELS); +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 start[j] = 0; +#line 650 edge[j] = 1; +#line 650 } +#line 650 err = nc_put_vara_double(BAD_ID, i, start, edge, value); +#line 650 IF (err != NC_EBADID) +#line 650 error("bad ncid: status = %d", err); +#line 650 err = nc_put_vara_double(ncid, BAD_VARID, start, edge, value); +#line 650 IF (err != NC_ENOTVAR) +#line 650 error("bad var id: status = %d", err); +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 650 start[j] = var_shape[i][j]; +#line 650 err = nc_put_vara_double(ncid, i, start, edge, value); +#line 650 IF (canConvert && err != NC_EINVALCOORDS) +#line 650 error("bad start: status = %d", err); +#line 650 start[j] = 0; +#line 650 edge[j] = var_shape[i][j] + 1; +#line 650 err = nc_put_vara_double(ncid, i, start, edge, value); +#line 650 IF (canConvert && err != NC_EEDGE) +#line 650 error("bad edge: status = %d", err); +#line 650 edge[j] = 1; +#line 650 } +#line 650 } +#line 650 /* Check correct error returned even when nothing to put */ +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 edge[j] = 0; +#line 650 } +#line 650 err = nc_put_vara_double(BAD_ID, i, start, edge, value); +#line 650 IF (err != NC_EBADID) +#line 650 error("bad ncid: status = %d", err); +#line 650 err = nc_put_vara_double(ncid, BAD_VARID, start, edge, value); +#line 650 IF (err != NC_ENOTVAR) +#line 650 error("bad var id: status = %d", err); +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 650 start[j] = var_shape[i][j]; +#line 650 err = nc_put_vara_double(ncid, i, start, edge, value); +#line 650 IF (canConvert && err != NC_EINVALCOORDS) +#line 650 error("bad start: status = %d", err); +#line 650 start[j] = 0; +#line 650 } +#line 650 } +#line 650 err = nc_put_vara_double(ncid, i, start, edge, value); +#line 650 if (canConvert) { +#line 650 IF (err) +#line 650 error("%s", nc_strerror(err)); +#line 650 } else { +#line 650 IF (err != NC_ECHAR) +#line 650 error("wrong type: status = %d", err); +#line 650 } +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 edge[j] = 1; +#line 650 } +#line 650 +#line 650 /* Choose a random point dividing each dim into 2 parts */ +#line 650 /* Put 2^rank (nslabs) slabs so defined */ +#line 650 nslabs = 1; +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 mid[j] = roll( var_shape[i][j] ); +#line 650 nslabs *= 2; +#line 650 } +#line 650 /* bits of k determine whether to put lower or upper part of dim */ +#line 650 for (k = 0; k < nslabs; k++) { +#line 650 nels = 1; +#line 650 for (j = 0; j < var_rank[i]; j++) { +#line 650 if ((k >> j) & 1) { +#line 650 start[j] = 0; +#line 650 edge[j] = mid[j]; +#line 650 }else{ +#line 650 start[j] = mid[j]; +#line 650 edge[j] = var_shape[i][j] - mid[j]; +#line 650 } +#line 650 nels *= edge[j]; +#line 650 } +#line 650 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 650 err = toMixedBase(j, var_rank[i], edge, index); +#line 650 IF (err) +#line 650 error("error in toMixedBase 1"); +#line 650 for (d = 0; d < var_rank[i]; d++) +#line 650 index[d] += start[d]; +#line 650 value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE); +#line 650 allInExtRange = allInExtRange +#line 650 && inRange3(value[j], var_type[i], NCT_DOUBLE); +#line 650 } +#line 650 if (var_rank[i] == 0 && i%2 == 0) +#line 650 err = nc_put_vara_double(ncid, i, NULL, NULL, value); +#line 650 else +#line 650 err = nc_put_vara_double(ncid, i, start, edge, value); +#line 650 if (canConvert) { +#line 650 if (allInExtRange) { +#line 650 IF (err) +#line 650 error("%s", nc_strerror(err)); +#line 650 } else { +#line 650 IF (err != NC_ERANGE) +#line 650 error("range error: status = %d", err); +#line 650 } +#line 650 } else { +#line 650 IF (nels > 0 && err != NC_ECHAR) +#line 650 error("wrong type: status = %d", err); +#line 650 } +#line 650 } +#line 650 } +#line 650 +#line 650 err = nc_close(ncid); +#line 650 IF (err) +#line 650 error("nc_close: %s", nc_strerror(err)); +#line 650 +#line 650 check_vars_double(scratch); +#line 650 +#line 650 err = remove(scratch); +#line 650 IF (err) +#line 650 error("remove of %s failed", scratch); +#line 650 } +#line 650 +#line 815 void +#line 816 test_nc_put_vars_text(void) +#line 816 { +#line 816 int ncid; +#line 816 int d; +#line 816 int i; +#line 816 int j; +#line 816 int k; +#line 816 int m; +#line 816 int err; +#line 816 int nels; +#line 816 int nslabs; +#line 816 int nstarts; /* number of different starts */ +#line 816 size_t start[MAX_RANK]; +#line 816 size_t edge[MAX_RANK]; +#line 816 size_t index[MAX_RANK]; +#line 816 size_t index2[MAX_RANK]; +#line 816 size_t mid[MAX_RANK]; +#line 816 size_t count[MAX_RANK]; +#line 816 size_t sstride[MAX_RANK]; +#line 816 ptrdiff_t stride[MAX_RANK]; +#line 816 int canConvert; /* Both text or both numeric */ +#line 816 int allInExtRange; /* all values within external range? */ +#line 816 text value[MAX_NELS]; +#line 816 +#line 816 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 816 IF (err) { +#line 816 error("nc_create: %s", nc_strerror(err)); +#line 816 return; +#line 816 } +#line 816 def_dims(ncid); +#line 816 def_vars(ncid); +#line 816 err = nc_enddef(ncid); +#line 816 IF (err) +#line 816 error("nc_enddef: %s", nc_strerror(err)); +#line 816 +#line 816 for (i = 0; i < NVARS; i++) { +#line 816 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 816 assert(var_rank[i] <= MAX_RANK); +#line 816 assert(var_nels[i] <= MAX_NELS); +#line 816 for (j = 0; j < var_rank[i]; j++) { +#line 816 start[j] = 0; +#line 816 edge[j] = 1; +#line 816 stride[j] = 1; +#line 816 } +#line 816 err = nc_put_vars_text(BAD_ID, i, start, edge, stride, value); +#line 816 IF (err != NC_EBADID) +#line 816 error("bad ncid: status = %d", err); +#line 816 err = nc_put_vars_text(ncid, BAD_VARID, start, edge, stride, value); +#line 816 IF (err != NC_ENOTVAR) +#line 816 error("bad var id: status = %d", err); +#line 816 for (j = 0; j < var_rank[i]; j++) { +#line 816 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 816 start[j] = var_shape[i][j] + 1; +#line 816 err = nc_put_vars_text(ncid, i, start, edge, stride, value); +#line 816 if(!canConvert) { +#line 816 IF(err != NC_ECHAR) +#line 816 error("conversion: status = %d", err); +#line 816 } else { +#line 816 IF(err != NC_EINVALCOORDS) +#line 816 error("bad start: status = %d", err); +#line 816 start[j] = 0; +#line 816 edge[j] = var_shape[i][j] + 1; +#line 816 err = nc_put_vars_text(ncid, i, start, edge, stride, value); +#line 816 IF (err != NC_EEDGE) +#line 816 error("bad edge: status = %d", err); +#line 816 edge[j] = 1; +#line 816 stride[j] = 0; +#line 816 err = nc_put_vars_text(ncid, i, start, edge, stride, value); +#line 816 IF (err != NC_ESTRIDE) +#line 816 error("bad stride: status = %d", err); +#line 816 stride[j] = 1; +#line 816 } +#line 816 } +#line 816 } +#line 816 /* Choose a random point dividing each dim into 2 parts */ +#line 816 /* Put 2^rank (nslabs) slabs so defined */ +#line 816 nslabs = 1; +#line 816 for (j = 0; j < var_rank[i]; j++) { +#line 816 mid[j] = roll( var_shape[i][j] ); +#line 816 nslabs *= 2; +#line 816 } +#line 816 /* bits of k determine whether to put lower or upper part of dim */ +#line 816 /* choose random stride from 1 to edge */ +#line 816 for (k = 0; k < nslabs; k++) { +#line 816 nstarts = 1; +#line 816 for (j = 0; j < var_rank[i]; j++) { +#line 816 if ((k >> j) & 1) { +#line 816 start[j] = 0; +#line 816 edge[j] = mid[j]; +#line 816 }else{ +#line 816 start[j] = mid[j]; +#line 816 edge[j] = var_shape[i][j] - mid[j]; +#line 816 } +#line 816 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 816 nstarts *= stride[j]; +#line 816 } +#line 816 for (m = 0; m < nstarts; m++) { +#line 816 err = toMixedBase(m, var_rank[i], sstride, index); +#line 816 IF (err) +#line 816 error("error in toMixedBase"); +#line 816 nels = 1; +#line 816 for (j = 0; j < var_rank[i]; j++) { +#line 816 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 816 nels *= count[j]; +#line 816 index[j] += start[j]; +#line 816 } +#line 816 /* Random choice of forward or backward */ +#line 816 /* TODO +#line 816 if ( roll(2) ) { +#line 816 for (j = 0; j < var_rank[i]; j++) { +#line 816 index[j] += (count[j] - 1) * stride[j]; +#line 816 stride[j] = -stride[j]; +#line 816 } +#line 816 } +#line 816 */ +#line 816 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 816 err = toMixedBase(j, var_rank[i], count, index2); +#line 816 IF (err) +#line 816 error("error in toMixedBase"); +#line 816 for (d = 0; d < var_rank[i]; d++) +#line 816 index2[d] = index[d] + index2[d] * stride[d]; +#line 816 value[j] = hash_text(var_type[i], var_rank[i], index2, +#line 816 NCT_TEXT); +#line 816 allInExtRange = allInExtRange +#line 816 && inRange3(value[j], var_type[i], NCT_TEXT); +#line 816 } +#line 816 if (var_rank[i] == 0 && i%2 == 0) +#line 816 err = nc_put_vars_text(ncid, i, NULL, NULL, stride, value); +#line 816 else +#line 816 err = nc_put_vars_text(ncid, i, index, count, stride, value); +#line 816 if (canConvert) { +#line 816 if (allInExtRange) { +#line 816 IF (err) +#line 816 error("%s", nc_strerror(err)); +#line 816 } else { +#line 816 IF (err != NC_ERANGE) +#line 816 error("range error: status = %d", err); +#line 816 } +#line 816 } else { +#line 816 IF (nels > 0 && err != NC_ECHAR) +#line 816 error("wrong type: status = %d", err); +#line 816 } +#line 816 } +#line 816 } +#line 816 } +#line 816 +#line 816 err = nc_close(ncid); +#line 816 IF (err) +#line 816 error("nc_close: %s", nc_strerror(err)); +#line 816 +#line 816 check_vars_text(scratch); +#line 816 +#line 816 err = remove(scratch); +#line 816 IF (err) +#line 816 error("remove of %s failed", scratch); +#line 816 } +#line 816 void +#line 817 test_nc_put_vars_uchar(void) +#line 817 { +#line 817 int ncid; +#line 817 int d; +#line 817 int i; +#line 817 int j; +#line 817 int k; +#line 817 int m; +#line 817 int err; +#line 817 int nels; +#line 817 int nslabs; +#line 817 int nstarts; /* number of different starts */ +#line 817 size_t start[MAX_RANK]; +#line 817 size_t edge[MAX_RANK]; +#line 817 size_t index[MAX_RANK]; +#line 817 size_t index2[MAX_RANK]; +#line 817 size_t mid[MAX_RANK]; +#line 817 size_t count[MAX_RANK]; +#line 817 size_t sstride[MAX_RANK]; +#line 817 ptrdiff_t stride[MAX_RANK]; +#line 817 int canConvert; /* Both text or both numeric */ +#line 817 int allInExtRange; /* all values within external range? */ +#line 817 uchar value[MAX_NELS]; +#line 817 +#line 817 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 817 IF (err) { +#line 817 error("nc_create: %s", nc_strerror(err)); +#line 817 return; +#line 817 } +#line 817 def_dims(ncid); +#line 817 def_vars(ncid); +#line 817 err = nc_enddef(ncid); +#line 817 IF (err) +#line 817 error("nc_enddef: %s", nc_strerror(err)); +#line 817 +#line 817 for (i = 0; i < NVARS; i++) { +#line 817 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 817 assert(var_rank[i] <= MAX_RANK); +#line 817 assert(var_nels[i] <= MAX_NELS); +#line 817 for (j = 0; j < var_rank[i]; j++) { +#line 817 start[j] = 0; +#line 817 edge[j] = 1; +#line 817 stride[j] = 1; +#line 817 } +#line 817 err = nc_put_vars_uchar(BAD_ID, i, start, edge, stride, value); +#line 817 IF (err != NC_EBADID) +#line 817 error("bad ncid: status = %d", err); +#line 817 err = nc_put_vars_uchar(ncid, BAD_VARID, start, edge, stride, value); +#line 817 IF (err != NC_ENOTVAR) +#line 817 error("bad var id: status = %d", err); +#line 817 for (j = 0; j < var_rank[i]; j++) { +#line 817 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 817 start[j] = var_shape[i][j] + 1; +#line 817 err = nc_put_vars_uchar(ncid, i, start, edge, stride, value); +#line 817 if(!canConvert) { +#line 817 IF(err != NC_ECHAR) +#line 817 error("conversion: status = %d", err); +#line 817 } else { +#line 817 IF(err != NC_EINVALCOORDS) +#line 817 error("bad start: status = %d", err); +#line 817 start[j] = 0; +#line 817 edge[j] = var_shape[i][j] + 1; +#line 817 err = nc_put_vars_uchar(ncid, i, start, edge, stride, value); +#line 817 IF (err != NC_EEDGE) +#line 817 error("bad edge: status = %d", err); +#line 817 edge[j] = 1; +#line 817 stride[j] = 0; +#line 817 err = nc_put_vars_uchar(ncid, i, start, edge, stride, value); +#line 817 IF (err != NC_ESTRIDE) +#line 817 error("bad stride: status = %d", err); +#line 817 stride[j] = 1; +#line 817 } +#line 817 } +#line 817 } +#line 817 /* Choose a random point dividing each dim into 2 parts */ +#line 817 /* Put 2^rank (nslabs) slabs so defined */ +#line 817 nslabs = 1; +#line 817 for (j = 0; j < var_rank[i]; j++) { +#line 817 mid[j] = roll( var_shape[i][j] ); +#line 817 nslabs *= 2; +#line 817 } +#line 817 /* bits of k determine whether to put lower or upper part of dim */ +#line 817 /* choose random stride from 1 to edge */ +#line 817 for (k = 0; k < nslabs; k++) { +#line 817 nstarts = 1; +#line 817 for (j = 0; j < var_rank[i]; j++) { +#line 817 if ((k >> j) & 1) { +#line 817 start[j] = 0; +#line 817 edge[j] = mid[j]; +#line 817 }else{ +#line 817 start[j] = mid[j]; +#line 817 edge[j] = var_shape[i][j] - mid[j]; +#line 817 } +#line 817 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 817 nstarts *= stride[j]; +#line 817 } +#line 817 for (m = 0; m < nstarts; m++) { +#line 817 err = toMixedBase(m, var_rank[i], sstride, index); +#line 817 IF (err) +#line 817 error("error in toMixedBase"); +#line 817 nels = 1; +#line 817 for (j = 0; j < var_rank[i]; j++) { +#line 817 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 817 nels *= count[j]; +#line 817 index[j] += start[j]; +#line 817 } +#line 817 /* Random choice of forward or backward */ +#line 817 /* TODO +#line 817 if ( roll(2) ) { +#line 817 for (j = 0; j < var_rank[i]; j++) { +#line 817 index[j] += (count[j] - 1) * stride[j]; +#line 817 stride[j] = -stride[j]; +#line 817 } +#line 817 } +#line 817 */ +#line 817 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 817 err = toMixedBase(j, var_rank[i], count, index2); +#line 817 IF (err) +#line 817 error("error in toMixedBase"); +#line 817 for (d = 0; d < var_rank[i]; d++) +#line 817 index2[d] = index[d] + index2[d] * stride[d]; +#line 817 value[j] = hash_uchar(var_type[i], var_rank[i], index2, +#line 817 NCT_UCHAR); +#line 817 allInExtRange = allInExtRange +#line 817 && inRange3(value[j], var_type[i], NCT_UCHAR); +#line 817 } +#line 817 if (var_rank[i] == 0 && i%2 == 0) +#line 817 err = nc_put_vars_uchar(ncid, i, NULL, NULL, stride, value); +#line 817 else +#line 817 err = nc_put_vars_uchar(ncid, i, index, count, stride, value); +#line 817 if (canConvert) { +#line 817 if (allInExtRange) { +#line 817 IF (err) +#line 817 error("%s", nc_strerror(err)); +#line 817 } else { +#line 817 IF (err != NC_ERANGE) +#line 817 error("range error: status = %d", err); +#line 817 } +#line 817 } else { +#line 817 IF (nels > 0 && err != NC_ECHAR) +#line 817 error("wrong type: status = %d", err); +#line 817 } +#line 817 } +#line 817 } +#line 817 } +#line 817 +#line 817 err = nc_close(ncid); +#line 817 IF (err) +#line 817 error("nc_close: %s", nc_strerror(err)); +#line 817 +#line 817 check_vars_uchar(scratch); +#line 817 +#line 817 err = remove(scratch); +#line 817 IF (err) +#line 817 error("remove of %s failed", scratch); +#line 817 } +#line 817 void +#line 818 test_nc_put_vars_schar(void) +#line 818 { +#line 818 int ncid; +#line 818 int d; +#line 818 int i; +#line 818 int j; +#line 818 int k; +#line 818 int m; +#line 818 int err; +#line 818 int nels; +#line 818 int nslabs; +#line 818 int nstarts; /* number of different starts */ +#line 818 size_t start[MAX_RANK]; +#line 818 size_t edge[MAX_RANK]; +#line 818 size_t index[MAX_RANK]; +#line 818 size_t index2[MAX_RANK]; +#line 818 size_t mid[MAX_RANK]; +#line 818 size_t count[MAX_RANK]; +#line 818 size_t sstride[MAX_RANK]; +#line 818 ptrdiff_t stride[MAX_RANK]; +#line 818 int canConvert; /* Both text or both numeric */ +#line 818 int allInExtRange; /* all values within external range? */ +#line 818 schar value[MAX_NELS]; +#line 818 +#line 818 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 818 IF (err) { +#line 818 error("nc_create: %s", nc_strerror(err)); +#line 818 return; +#line 818 } +#line 818 def_dims(ncid); +#line 818 def_vars(ncid); +#line 818 err = nc_enddef(ncid); +#line 818 IF (err) +#line 818 error("nc_enddef: %s", nc_strerror(err)); +#line 818 +#line 818 for (i = 0; i < NVARS; i++) { +#line 818 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 818 assert(var_rank[i] <= MAX_RANK); +#line 818 assert(var_nels[i] <= MAX_NELS); +#line 818 for (j = 0; j < var_rank[i]; j++) { +#line 818 start[j] = 0; +#line 818 edge[j] = 1; +#line 818 stride[j] = 1; +#line 818 } +#line 818 err = nc_put_vars_schar(BAD_ID, i, start, edge, stride, value); +#line 818 IF (err != NC_EBADID) +#line 818 error("bad ncid: status = %d", err); +#line 818 err = nc_put_vars_schar(ncid, BAD_VARID, start, edge, stride, value); +#line 818 IF (err != NC_ENOTVAR) +#line 818 error("bad var id: status = %d", err); +#line 818 for (j = 0; j < var_rank[i]; j++) { +#line 818 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 818 start[j] = var_shape[i][j] + 1; +#line 818 err = nc_put_vars_schar(ncid, i, start, edge, stride, value); +#line 818 if(!canConvert) { +#line 818 IF(err != NC_ECHAR) +#line 818 error("conversion: status = %d", err); +#line 818 } else { +#line 818 IF(err != NC_EINVALCOORDS) +#line 818 error("bad start: status = %d", err); +#line 818 start[j] = 0; +#line 818 edge[j] = var_shape[i][j] + 1; +#line 818 err = nc_put_vars_schar(ncid, i, start, edge, stride, value); +#line 818 IF (err != NC_EEDGE) +#line 818 error("bad edge: status = %d", err); +#line 818 edge[j] = 1; +#line 818 stride[j] = 0; +#line 818 err = nc_put_vars_schar(ncid, i, start, edge, stride, value); +#line 818 IF (err != NC_ESTRIDE) +#line 818 error("bad stride: status = %d", err); +#line 818 stride[j] = 1; +#line 818 } +#line 818 } +#line 818 } +#line 818 /* Choose a random point dividing each dim into 2 parts */ +#line 818 /* Put 2^rank (nslabs) slabs so defined */ +#line 818 nslabs = 1; +#line 818 for (j = 0; j < var_rank[i]; j++) { +#line 818 mid[j] = roll( var_shape[i][j] ); +#line 818 nslabs *= 2; +#line 818 } +#line 818 /* bits of k determine whether to put lower or upper part of dim */ +#line 818 /* choose random stride from 1 to edge */ +#line 818 for (k = 0; k < nslabs; k++) { +#line 818 nstarts = 1; +#line 818 for (j = 0; j < var_rank[i]; j++) { +#line 818 if ((k >> j) & 1) { +#line 818 start[j] = 0; +#line 818 edge[j] = mid[j]; +#line 818 }else{ +#line 818 start[j] = mid[j]; +#line 818 edge[j] = var_shape[i][j] - mid[j]; +#line 818 } +#line 818 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 818 nstarts *= stride[j]; +#line 818 } +#line 818 for (m = 0; m < nstarts; m++) { +#line 818 err = toMixedBase(m, var_rank[i], sstride, index); +#line 818 IF (err) +#line 818 error("error in toMixedBase"); +#line 818 nels = 1; +#line 818 for (j = 0; j < var_rank[i]; j++) { +#line 818 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 818 nels *= count[j]; +#line 818 index[j] += start[j]; +#line 818 } +#line 818 /* Random choice of forward or backward */ +#line 818 /* TODO +#line 818 if ( roll(2) ) { +#line 818 for (j = 0; j < var_rank[i]; j++) { +#line 818 index[j] += (count[j] - 1) * stride[j]; +#line 818 stride[j] = -stride[j]; +#line 818 } +#line 818 } +#line 818 */ +#line 818 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 818 err = toMixedBase(j, var_rank[i], count, index2); +#line 818 IF (err) +#line 818 error("error in toMixedBase"); +#line 818 for (d = 0; d < var_rank[i]; d++) +#line 818 index2[d] = index[d] + index2[d] * stride[d]; +#line 818 value[j] = hash_schar(var_type[i], var_rank[i], index2, +#line 818 NCT_SCHAR); +#line 818 allInExtRange = allInExtRange +#line 818 && inRange3(value[j], var_type[i], NCT_SCHAR); +#line 818 } +#line 818 if (var_rank[i] == 0 && i%2 == 0) +#line 818 err = nc_put_vars_schar(ncid, i, NULL, NULL, stride, value); +#line 818 else +#line 818 err = nc_put_vars_schar(ncid, i, index, count, stride, value); +#line 818 if (canConvert) { +#line 818 if (allInExtRange) { +#line 818 IF (err) +#line 818 error("%s", nc_strerror(err)); +#line 818 } else { +#line 818 IF (err != NC_ERANGE) +#line 818 error("range error: status = %d", err); +#line 818 } +#line 818 } else { +#line 818 IF (nels > 0 && err != NC_ECHAR) +#line 818 error("wrong type: status = %d", err); +#line 818 } +#line 818 } +#line 818 } +#line 818 } +#line 818 +#line 818 err = nc_close(ncid); +#line 818 IF (err) +#line 818 error("nc_close: %s", nc_strerror(err)); +#line 818 +#line 818 check_vars_schar(scratch); +#line 818 +#line 818 err = remove(scratch); +#line 818 IF (err) +#line 818 error("remove of %s failed", scratch); +#line 818 } +#line 818 void +#line 819 test_nc_put_vars_short(void) +#line 819 { +#line 819 int ncid; +#line 819 int d; +#line 819 int i; +#line 819 int j; +#line 819 int k; +#line 819 int m; +#line 819 int err; +#line 819 int nels; +#line 819 int nslabs; +#line 819 int nstarts; /* number of different starts */ +#line 819 size_t start[MAX_RANK]; +#line 819 size_t edge[MAX_RANK]; +#line 819 size_t index[MAX_RANK]; +#line 819 size_t index2[MAX_RANK]; +#line 819 size_t mid[MAX_RANK]; +#line 819 size_t count[MAX_RANK]; +#line 819 size_t sstride[MAX_RANK]; +#line 819 ptrdiff_t stride[MAX_RANK]; +#line 819 int canConvert; /* Both text or both numeric */ +#line 819 int allInExtRange; /* all values within external range? */ +#line 819 short value[MAX_NELS]; +#line 819 +#line 819 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 819 IF (err) { +#line 819 error("nc_create: %s", nc_strerror(err)); +#line 819 return; +#line 819 } +#line 819 def_dims(ncid); +#line 819 def_vars(ncid); +#line 819 err = nc_enddef(ncid); +#line 819 IF (err) +#line 819 error("nc_enddef: %s", nc_strerror(err)); +#line 819 +#line 819 for (i = 0; i < NVARS; i++) { +#line 819 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 819 assert(var_rank[i] <= MAX_RANK); +#line 819 assert(var_nels[i] <= MAX_NELS); +#line 819 for (j = 0; j < var_rank[i]; j++) { +#line 819 start[j] = 0; +#line 819 edge[j] = 1; +#line 819 stride[j] = 1; +#line 819 } +#line 819 err = nc_put_vars_short(BAD_ID, i, start, edge, stride, value); +#line 819 IF (err != NC_EBADID) +#line 819 error("bad ncid: status = %d", err); +#line 819 err = nc_put_vars_short(ncid, BAD_VARID, start, edge, stride, value); +#line 819 IF (err != NC_ENOTVAR) +#line 819 error("bad var id: status = %d", err); +#line 819 for (j = 0; j < var_rank[i]; j++) { +#line 819 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 819 start[j] = var_shape[i][j] + 1; +#line 819 err = nc_put_vars_short(ncid, i, start, edge, stride, value); +#line 819 if(!canConvert) { +#line 819 IF(err != NC_ECHAR) +#line 819 error("conversion: status = %d", err); +#line 819 } else { +#line 819 IF(err != NC_EINVALCOORDS) +#line 819 error("bad start: status = %d", err); +#line 819 start[j] = 0; +#line 819 edge[j] = var_shape[i][j] + 1; +#line 819 err = nc_put_vars_short(ncid, i, start, edge, stride, value); +#line 819 IF (err != NC_EEDGE) +#line 819 error("bad edge: status = %d", err); +#line 819 edge[j] = 1; +#line 819 stride[j] = 0; +#line 819 err = nc_put_vars_short(ncid, i, start, edge, stride, value); +#line 819 IF (err != NC_ESTRIDE) +#line 819 error("bad stride: status = %d", err); +#line 819 stride[j] = 1; +#line 819 } +#line 819 } +#line 819 } +#line 819 /* Choose a random point dividing each dim into 2 parts */ +#line 819 /* Put 2^rank (nslabs) slabs so defined */ +#line 819 nslabs = 1; +#line 819 for (j = 0; j < var_rank[i]; j++) { +#line 819 mid[j] = roll( var_shape[i][j] ); +#line 819 nslabs *= 2; +#line 819 } +#line 819 /* bits of k determine whether to put lower or upper part of dim */ +#line 819 /* choose random stride from 1 to edge */ +#line 819 for (k = 0; k < nslabs; k++) { +#line 819 nstarts = 1; +#line 819 for (j = 0; j < var_rank[i]; j++) { +#line 819 if ((k >> j) & 1) { +#line 819 start[j] = 0; +#line 819 edge[j] = mid[j]; +#line 819 }else{ +#line 819 start[j] = mid[j]; +#line 819 edge[j] = var_shape[i][j] - mid[j]; +#line 819 } +#line 819 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 819 nstarts *= stride[j]; +#line 819 } +#line 819 for (m = 0; m < nstarts; m++) { +#line 819 err = toMixedBase(m, var_rank[i], sstride, index); +#line 819 IF (err) +#line 819 error("error in toMixedBase"); +#line 819 nels = 1; +#line 819 for (j = 0; j < var_rank[i]; j++) { +#line 819 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 819 nels *= count[j]; +#line 819 index[j] += start[j]; +#line 819 } +#line 819 /* Random choice of forward or backward */ +#line 819 /* TODO +#line 819 if ( roll(2) ) { +#line 819 for (j = 0; j < var_rank[i]; j++) { +#line 819 index[j] += (count[j] - 1) * stride[j]; +#line 819 stride[j] = -stride[j]; +#line 819 } +#line 819 } +#line 819 */ +#line 819 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 819 err = toMixedBase(j, var_rank[i], count, index2); +#line 819 IF (err) +#line 819 error("error in toMixedBase"); +#line 819 for (d = 0; d < var_rank[i]; d++) +#line 819 index2[d] = index[d] + index2[d] * stride[d]; +#line 819 value[j] = hash_short(var_type[i], var_rank[i], index2, +#line 819 NCT_SHORT); +#line 819 allInExtRange = allInExtRange +#line 819 && inRange3(value[j], var_type[i], NCT_SHORT); +#line 819 } +#line 819 if (var_rank[i] == 0 && i%2 == 0) +#line 819 err = nc_put_vars_short(ncid, i, NULL, NULL, stride, value); +#line 819 else +#line 819 err = nc_put_vars_short(ncid, i, index, count, stride, value); +#line 819 if (canConvert) { +#line 819 if (allInExtRange) { +#line 819 IF (err) +#line 819 error("%s", nc_strerror(err)); +#line 819 } else { +#line 819 IF (err != NC_ERANGE) +#line 819 error("range error: status = %d", err); +#line 819 } +#line 819 } else { +#line 819 IF (nels > 0 && err != NC_ECHAR) +#line 819 error("wrong type: status = %d", err); +#line 819 } +#line 819 } +#line 819 } +#line 819 } +#line 819 +#line 819 err = nc_close(ncid); +#line 819 IF (err) +#line 819 error("nc_close: %s", nc_strerror(err)); +#line 819 +#line 819 check_vars_short(scratch); +#line 819 +#line 819 err = remove(scratch); +#line 819 IF (err) +#line 819 error("remove of %s failed", scratch); +#line 819 } +#line 819 void +#line 820 test_nc_put_vars_int(void) +#line 820 { +#line 820 int ncid; +#line 820 int d; +#line 820 int i; +#line 820 int j; +#line 820 int k; +#line 820 int m; +#line 820 int err; +#line 820 int nels; +#line 820 int nslabs; +#line 820 int nstarts; /* number of different starts */ +#line 820 size_t start[MAX_RANK]; +#line 820 size_t edge[MAX_RANK]; +#line 820 size_t index[MAX_RANK]; +#line 820 size_t index2[MAX_RANK]; +#line 820 size_t mid[MAX_RANK]; +#line 820 size_t count[MAX_RANK]; +#line 820 size_t sstride[MAX_RANK]; +#line 820 ptrdiff_t stride[MAX_RANK]; +#line 820 int canConvert; /* Both text or both numeric */ +#line 820 int allInExtRange; /* all values within external range? */ +#line 820 int value[MAX_NELS]; +#line 820 +#line 820 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 820 IF (err) { +#line 820 error("nc_create: %s", nc_strerror(err)); +#line 820 return; +#line 820 } +#line 820 def_dims(ncid); +#line 820 def_vars(ncid); +#line 820 err = nc_enddef(ncid); +#line 820 IF (err) +#line 820 error("nc_enddef: %s", nc_strerror(err)); +#line 820 +#line 820 for (i = 0; i < NVARS; i++) { +#line 820 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 820 assert(var_rank[i] <= MAX_RANK); +#line 820 assert(var_nels[i] <= MAX_NELS); +#line 820 for (j = 0; j < var_rank[i]; j++) { +#line 820 start[j] = 0; +#line 820 edge[j] = 1; +#line 820 stride[j] = 1; +#line 820 } +#line 820 err = nc_put_vars_int(BAD_ID, i, start, edge, stride, value); +#line 820 IF (err != NC_EBADID) +#line 820 error("bad ncid: status = %d", err); +#line 820 err = nc_put_vars_int(ncid, BAD_VARID, start, edge, stride, value); +#line 820 IF (err != NC_ENOTVAR) +#line 820 error("bad var id: status = %d", err); +#line 820 for (j = 0; j < var_rank[i]; j++) { +#line 820 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 820 start[j] = var_shape[i][j] + 1; +#line 820 err = nc_put_vars_int(ncid, i, start, edge, stride, value); +#line 820 if(!canConvert) { +#line 820 IF(err != NC_ECHAR) +#line 820 error("conversion: status = %d", err); +#line 820 } else { +#line 820 IF(err != NC_EINVALCOORDS) +#line 820 error("bad start: status = %d", err); +#line 820 start[j] = 0; +#line 820 edge[j] = var_shape[i][j] + 1; +#line 820 err = nc_put_vars_int(ncid, i, start, edge, stride, value); +#line 820 IF (err != NC_EEDGE) +#line 820 error("bad edge: status = %d", err); +#line 820 edge[j] = 1; +#line 820 stride[j] = 0; +#line 820 err = nc_put_vars_int(ncid, i, start, edge, stride, value); +#line 820 IF (err != NC_ESTRIDE) +#line 820 error("bad stride: status = %d", err); +#line 820 stride[j] = 1; +#line 820 } +#line 820 } +#line 820 } +#line 820 /* Choose a random point dividing each dim into 2 parts */ +#line 820 /* Put 2^rank (nslabs) slabs so defined */ +#line 820 nslabs = 1; +#line 820 for (j = 0; j < var_rank[i]; j++) { +#line 820 mid[j] = roll( var_shape[i][j] ); +#line 820 nslabs *= 2; +#line 820 } +#line 820 /* bits of k determine whether to put lower or upper part of dim */ +#line 820 /* choose random stride from 1 to edge */ +#line 820 for (k = 0; k < nslabs; k++) { +#line 820 nstarts = 1; +#line 820 for (j = 0; j < var_rank[i]; j++) { +#line 820 if ((k >> j) & 1) { +#line 820 start[j] = 0; +#line 820 edge[j] = mid[j]; +#line 820 }else{ +#line 820 start[j] = mid[j]; +#line 820 edge[j] = var_shape[i][j] - mid[j]; +#line 820 } +#line 820 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 820 nstarts *= stride[j]; +#line 820 } +#line 820 for (m = 0; m < nstarts; m++) { +#line 820 err = toMixedBase(m, var_rank[i], sstride, index); +#line 820 IF (err) +#line 820 error("error in toMixedBase"); +#line 820 nels = 1; +#line 820 for (j = 0; j < var_rank[i]; j++) { +#line 820 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 820 nels *= count[j]; +#line 820 index[j] += start[j]; +#line 820 } +#line 820 /* Random choice of forward or backward */ +#line 820 /* TODO +#line 820 if ( roll(2) ) { +#line 820 for (j = 0; j < var_rank[i]; j++) { +#line 820 index[j] += (count[j] - 1) * stride[j]; +#line 820 stride[j] = -stride[j]; +#line 820 } +#line 820 } +#line 820 */ +#line 820 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 820 err = toMixedBase(j, var_rank[i], count, index2); +#line 820 IF (err) +#line 820 error("error in toMixedBase"); +#line 820 for (d = 0; d < var_rank[i]; d++) +#line 820 index2[d] = index[d] + index2[d] * stride[d]; +#line 820 value[j] = hash_int(var_type[i], var_rank[i], index2, +#line 820 NCT_INT); +#line 820 allInExtRange = allInExtRange +#line 820 && inRange3(value[j], var_type[i], NCT_INT); +#line 820 } +#line 820 if (var_rank[i] == 0 && i%2 == 0) +#line 820 err = nc_put_vars_int(ncid, i, NULL, NULL, stride, value); +#line 820 else +#line 820 err = nc_put_vars_int(ncid, i, index, count, stride, value); +#line 820 if (canConvert) { +#line 820 if (allInExtRange) { +#line 820 IF (err) +#line 820 error("%s", nc_strerror(err)); +#line 820 } else { +#line 820 IF (err != NC_ERANGE) +#line 820 error("range error: status = %d", err); +#line 820 } +#line 820 } else { +#line 820 IF (nels > 0 && err != NC_ECHAR) +#line 820 error("wrong type: status = %d", err); +#line 820 } +#line 820 } +#line 820 } +#line 820 } +#line 820 +#line 820 err = nc_close(ncid); +#line 820 IF (err) +#line 820 error("nc_close: %s", nc_strerror(err)); +#line 820 +#line 820 check_vars_int(scratch); +#line 820 +#line 820 err = remove(scratch); +#line 820 IF (err) +#line 820 error("remove of %s failed", scratch); +#line 820 } +#line 820 void +#line 821 test_nc_put_vars_long(void) +#line 821 { +#line 821 int ncid; +#line 821 int d; +#line 821 int i; +#line 821 int j; +#line 821 int k; +#line 821 int m; +#line 821 int err; +#line 821 int nels; +#line 821 int nslabs; +#line 821 int nstarts; /* number of different starts */ +#line 821 size_t start[MAX_RANK]; +#line 821 size_t edge[MAX_RANK]; +#line 821 size_t index[MAX_RANK]; +#line 821 size_t index2[MAX_RANK]; +#line 821 size_t mid[MAX_RANK]; +#line 821 size_t count[MAX_RANK]; +#line 821 size_t sstride[MAX_RANK]; +#line 821 ptrdiff_t stride[MAX_RANK]; +#line 821 int canConvert; /* Both text or both numeric */ +#line 821 int allInExtRange; /* all values within external range? */ +#line 821 long value[MAX_NELS]; +#line 821 +#line 821 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 821 IF (err) { +#line 821 error("nc_create: %s", nc_strerror(err)); +#line 821 return; +#line 821 } +#line 821 def_dims(ncid); +#line 821 def_vars(ncid); +#line 821 err = nc_enddef(ncid); +#line 821 IF (err) +#line 821 error("nc_enddef: %s", nc_strerror(err)); +#line 821 +#line 821 for (i = 0; i < NVARS; i++) { +#line 821 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 821 assert(var_rank[i] <= MAX_RANK); +#line 821 assert(var_nels[i] <= MAX_NELS); +#line 821 for (j = 0; j < var_rank[i]; j++) { +#line 821 start[j] = 0; +#line 821 edge[j] = 1; +#line 821 stride[j] = 1; +#line 821 } +#line 821 err = nc_put_vars_long(BAD_ID, i, start, edge, stride, value); +#line 821 IF (err != NC_EBADID) +#line 821 error("bad ncid: status = %d", err); +#line 821 err = nc_put_vars_long(ncid, BAD_VARID, start, edge, stride, value); +#line 821 IF (err != NC_ENOTVAR) +#line 821 error("bad var id: status = %d", err); +#line 821 for (j = 0; j < var_rank[i]; j++) { +#line 821 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 821 start[j] = var_shape[i][j] + 1; +#line 821 err = nc_put_vars_long(ncid, i, start, edge, stride, value); +#line 821 if(!canConvert) { +#line 821 IF(err != NC_ECHAR) +#line 821 error("conversion: status = %d", err); +#line 821 } else { +#line 821 IF(err != NC_EINVALCOORDS) +#line 821 error("bad start: status = %d", err); +#line 821 start[j] = 0; +#line 821 edge[j] = var_shape[i][j] + 1; +#line 821 err = nc_put_vars_long(ncid, i, start, edge, stride, value); +#line 821 IF (err != NC_EEDGE) +#line 821 error("bad edge: status = %d", err); +#line 821 edge[j] = 1; +#line 821 stride[j] = 0; +#line 821 err = nc_put_vars_long(ncid, i, start, edge, stride, value); +#line 821 IF (err != NC_ESTRIDE) +#line 821 error("bad stride: status = %d", err); +#line 821 stride[j] = 1; +#line 821 } +#line 821 } +#line 821 } +#line 821 /* Choose a random point dividing each dim into 2 parts */ +#line 821 /* Put 2^rank (nslabs) slabs so defined */ +#line 821 nslabs = 1; +#line 821 for (j = 0; j < var_rank[i]; j++) { +#line 821 mid[j] = roll( var_shape[i][j] ); +#line 821 nslabs *= 2; +#line 821 } +#line 821 /* bits of k determine whether to put lower or upper part of dim */ +#line 821 /* choose random stride from 1 to edge */ +#line 821 for (k = 0; k < nslabs; k++) { +#line 821 nstarts = 1; +#line 821 for (j = 0; j < var_rank[i]; j++) { +#line 821 if ((k >> j) & 1) { +#line 821 start[j] = 0; +#line 821 edge[j] = mid[j]; +#line 821 }else{ +#line 821 start[j] = mid[j]; +#line 821 edge[j] = var_shape[i][j] - mid[j]; +#line 821 } +#line 821 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 821 nstarts *= stride[j]; +#line 821 } +#line 821 for (m = 0; m < nstarts; m++) { +#line 821 err = toMixedBase(m, var_rank[i], sstride, index); +#line 821 IF (err) +#line 821 error("error in toMixedBase"); +#line 821 nels = 1; +#line 821 for (j = 0; j < var_rank[i]; j++) { +#line 821 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 821 nels *= count[j]; +#line 821 index[j] += start[j]; +#line 821 } +#line 821 /* Random choice of forward or backward */ +#line 821 /* TODO +#line 821 if ( roll(2) ) { +#line 821 for (j = 0; j < var_rank[i]; j++) { +#line 821 index[j] += (count[j] - 1) * stride[j]; +#line 821 stride[j] = -stride[j]; +#line 821 } +#line 821 } +#line 821 */ +#line 821 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 821 err = toMixedBase(j, var_rank[i], count, index2); +#line 821 IF (err) +#line 821 error("error in toMixedBase"); +#line 821 for (d = 0; d < var_rank[i]; d++) +#line 821 index2[d] = index[d] + index2[d] * stride[d]; +#line 821 value[j] = hash_long(var_type[i], var_rank[i], index2, +#line 821 NCT_LONG); +#line 821 allInExtRange = allInExtRange +#line 821 && inRange3(value[j], var_type[i], NCT_LONG); +#line 821 } +#line 821 if (var_rank[i] == 0 && i%2 == 0) +#line 821 err = nc_put_vars_long(ncid, i, NULL, NULL, stride, value); +#line 821 else +#line 821 err = nc_put_vars_long(ncid, i, index, count, stride, value); +#line 821 if (canConvert) { +#line 821 if (allInExtRange) { +#line 821 IF (err) +#line 821 error("%s", nc_strerror(err)); +#line 821 } else { +#line 821 IF (err != NC_ERANGE) +#line 821 error("range error: status = %d", err); +#line 821 } +#line 821 } else { +#line 821 IF (nels > 0 && err != NC_ECHAR) +#line 821 error("wrong type: status = %d", err); +#line 821 } +#line 821 } +#line 821 } +#line 821 } +#line 821 +#line 821 err = nc_close(ncid); +#line 821 IF (err) +#line 821 error("nc_close: %s", nc_strerror(err)); +#line 821 +#line 821 check_vars_long(scratch); +#line 821 +#line 821 err = remove(scratch); +#line 821 IF (err) +#line 821 error("remove of %s failed", scratch); +#line 821 } +#line 821 void +#line 822 test_nc_put_vars_float(void) +#line 822 { +#line 822 int ncid; +#line 822 int d; +#line 822 int i; +#line 822 int j; +#line 822 int k; +#line 822 int m; +#line 822 int err; +#line 822 int nels; +#line 822 int nslabs; +#line 822 int nstarts; /* number of different starts */ +#line 822 size_t start[MAX_RANK]; +#line 822 size_t edge[MAX_RANK]; +#line 822 size_t index[MAX_RANK]; +#line 822 size_t index2[MAX_RANK]; +#line 822 size_t mid[MAX_RANK]; +#line 822 size_t count[MAX_RANK]; +#line 822 size_t sstride[MAX_RANK]; +#line 822 ptrdiff_t stride[MAX_RANK]; +#line 822 int canConvert; /* Both text or both numeric */ +#line 822 int allInExtRange; /* all values within external range? */ +#line 822 float value[MAX_NELS]; +#line 822 +#line 822 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 822 IF (err) { +#line 822 error("nc_create: %s", nc_strerror(err)); +#line 822 return; +#line 822 } +#line 822 def_dims(ncid); +#line 822 def_vars(ncid); +#line 822 err = nc_enddef(ncid); +#line 822 IF (err) +#line 822 error("nc_enddef: %s", nc_strerror(err)); +#line 822 +#line 822 for (i = 0; i < NVARS; i++) { +#line 822 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 822 assert(var_rank[i] <= MAX_RANK); +#line 822 assert(var_nels[i] <= MAX_NELS); +#line 822 for (j = 0; j < var_rank[i]; j++) { +#line 822 start[j] = 0; +#line 822 edge[j] = 1; +#line 822 stride[j] = 1; +#line 822 } +#line 822 err = nc_put_vars_float(BAD_ID, i, start, edge, stride, value); +#line 822 IF (err != NC_EBADID) +#line 822 error("bad ncid: status = %d", err); +#line 822 err = nc_put_vars_float(ncid, BAD_VARID, start, edge, stride, value); +#line 822 IF (err != NC_ENOTVAR) +#line 822 error("bad var id: status = %d", err); +#line 822 for (j = 0; j < var_rank[i]; j++) { +#line 822 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 822 start[j] = var_shape[i][j] + 1; +#line 822 err = nc_put_vars_float(ncid, i, start, edge, stride, value); +#line 822 if(!canConvert) { +#line 822 IF(err != NC_ECHAR) +#line 822 error("conversion: status = %d", err); +#line 822 } else { +#line 822 IF(err != NC_EINVALCOORDS) +#line 822 error("bad start: status = %d", err); +#line 822 start[j] = 0; +#line 822 edge[j] = var_shape[i][j] + 1; +#line 822 err = nc_put_vars_float(ncid, i, start, edge, stride, value); +#line 822 IF (err != NC_EEDGE) +#line 822 error("bad edge: status = %d", err); +#line 822 edge[j] = 1; +#line 822 stride[j] = 0; +#line 822 err = nc_put_vars_float(ncid, i, start, edge, stride, value); +#line 822 IF (err != NC_ESTRIDE) +#line 822 error("bad stride: status = %d", err); +#line 822 stride[j] = 1; +#line 822 } +#line 822 } +#line 822 } +#line 822 /* Choose a random point dividing each dim into 2 parts */ +#line 822 /* Put 2^rank (nslabs) slabs so defined */ +#line 822 nslabs = 1; +#line 822 for (j = 0; j < var_rank[i]; j++) { +#line 822 mid[j] = roll( var_shape[i][j] ); +#line 822 nslabs *= 2; +#line 822 } +#line 822 /* bits of k determine whether to put lower or upper part of dim */ +#line 822 /* choose random stride from 1 to edge */ +#line 822 for (k = 0; k < nslabs; k++) { +#line 822 nstarts = 1; +#line 822 for (j = 0; j < var_rank[i]; j++) { +#line 822 if ((k >> j) & 1) { +#line 822 start[j] = 0; +#line 822 edge[j] = mid[j]; +#line 822 }else{ +#line 822 start[j] = mid[j]; +#line 822 edge[j] = var_shape[i][j] - mid[j]; +#line 822 } +#line 822 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 822 nstarts *= stride[j]; +#line 822 } +#line 822 for (m = 0; m < nstarts; m++) { +#line 822 err = toMixedBase(m, var_rank[i], sstride, index); +#line 822 IF (err) +#line 822 error("error in toMixedBase"); +#line 822 nels = 1; +#line 822 for (j = 0; j < var_rank[i]; j++) { +#line 822 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 822 nels *= count[j]; +#line 822 index[j] += start[j]; +#line 822 } +#line 822 /* Random choice of forward or backward */ +#line 822 /* TODO +#line 822 if ( roll(2) ) { +#line 822 for (j = 0; j < var_rank[i]; j++) { +#line 822 index[j] += (count[j] - 1) * stride[j]; +#line 822 stride[j] = -stride[j]; +#line 822 } +#line 822 } +#line 822 */ +#line 822 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 822 err = toMixedBase(j, var_rank[i], count, index2); +#line 822 IF (err) +#line 822 error("error in toMixedBase"); +#line 822 for (d = 0; d < var_rank[i]; d++) +#line 822 index2[d] = index[d] + index2[d] * stride[d]; +#line 822 value[j] = hash_float(var_type[i], var_rank[i], index2, +#line 822 NCT_FLOAT); +#line 822 allInExtRange = allInExtRange +#line 822 && inRange3(value[j], var_type[i], NCT_FLOAT); +#line 822 } +#line 822 if (var_rank[i] == 0 && i%2 == 0) +#line 822 err = nc_put_vars_float(ncid, i, NULL, NULL, stride, value); +#line 822 else +#line 822 err = nc_put_vars_float(ncid, i, index, count, stride, value); +#line 822 if (canConvert) { +#line 822 if (allInExtRange) { +#line 822 IF (err) +#line 822 error("%s", nc_strerror(err)); +#line 822 } else { +#line 822 IF (err != NC_ERANGE) +#line 822 error("range error: status = %d", err); +#line 822 } +#line 822 } else { +#line 822 IF (nels > 0 && err != NC_ECHAR) +#line 822 error("wrong type: status = %d", err); +#line 822 } +#line 822 } +#line 822 } +#line 822 } +#line 822 +#line 822 err = nc_close(ncid); +#line 822 IF (err) +#line 822 error("nc_close: %s", nc_strerror(err)); +#line 822 +#line 822 check_vars_float(scratch); +#line 822 +#line 822 err = remove(scratch); +#line 822 IF (err) +#line 822 error("remove of %s failed", scratch); +#line 822 } +#line 822 void +#line 823 test_nc_put_vars_double(void) +#line 823 { +#line 823 int ncid; +#line 823 int d; +#line 823 int i; +#line 823 int j; +#line 823 int k; +#line 823 int m; +#line 823 int err; +#line 823 int nels; +#line 823 int nslabs; +#line 823 int nstarts; /* number of different starts */ +#line 823 size_t start[MAX_RANK]; +#line 823 size_t edge[MAX_RANK]; +#line 823 size_t index[MAX_RANK]; +#line 823 size_t index2[MAX_RANK]; +#line 823 size_t mid[MAX_RANK]; +#line 823 size_t count[MAX_RANK]; +#line 823 size_t sstride[MAX_RANK]; +#line 823 ptrdiff_t stride[MAX_RANK]; +#line 823 int canConvert; /* Both text or both numeric */ +#line 823 int allInExtRange; /* all values within external range? */ +#line 823 double value[MAX_NELS]; +#line 823 +#line 823 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 823 IF (err) { +#line 823 error("nc_create: %s", nc_strerror(err)); +#line 823 return; +#line 823 } +#line 823 def_dims(ncid); +#line 823 def_vars(ncid); +#line 823 err = nc_enddef(ncid); +#line 823 IF (err) +#line 823 error("nc_enddef: %s", nc_strerror(err)); +#line 823 +#line 823 for (i = 0; i < NVARS; i++) { +#line 823 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 823 assert(var_rank[i] <= MAX_RANK); +#line 823 assert(var_nels[i] <= MAX_NELS); +#line 823 for (j = 0; j < var_rank[i]; j++) { +#line 823 start[j] = 0; +#line 823 edge[j] = 1; +#line 823 stride[j] = 1; +#line 823 } +#line 823 err = nc_put_vars_double(BAD_ID, i, start, edge, stride, value); +#line 823 IF (err != NC_EBADID) +#line 823 error("bad ncid: status = %d", err); +#line 823 err = nc_put_vars_double(ncid, BAD_VARID, start, edge, stride, value); +#line 823 IF (err != NC_ENOTVAR) +#line 823 error("bad var id: status = %d", err); +#line 823 for (j = 0; j < var_rank[i]; j++) { +#line 823 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 823 start[j] = var_shape[i][j] + 1; +#line 823 err = nc_put_vars_double(ncid, i, start, edge, stride, value); +#line 823 if(!canConvert) { +#line 823 IF(err != NC_ECHAR) +#line 823 error("conversion: status = %d", err); +#line 823 } else { +#line 823 IF(err != NC_EINVALCOORDS) +#line 823 error("bad start: status = %d", err); +#line 823 start[j] = 0; +#line 823 edge[j] = var_shape[i][j] + 1; +#line 823 err = nc_put_vars_double(ncid, i, start, edge, stride, value); +#line 823 IF (err != NC_EEDGE) +#line 823 error("bad edge: status = %d", err); +#line 823 edge[j] = 1; +#line 823 stride[j] = 0; +#line 823 err = nc_put_vars_double(ncid, i, start, edge, stride, value); +#line 823 IF (err != NC_ESTRIDE) +#line 823 error("bad stride: status = %d", err); +#line 823 stride[j] = 1; +#line 823 } +#line 823 } +#line 823 } +#line 823 /* Choose a random point dividing each dim into 2 parts */ +#line 823 /* Put 2^rank (nslabs) slabs so defined */ +#line 823 nslabs = 1; +#line 823 for (j = 0; j < var_rank[i]; j++) { +#line 823 mid[j] = roll( var_shape[i][j] ); +#line 823 nslabs *= 2; +#line 823 } +#line 823 /* bits of k determine whether to put lower or upper part of dim */ +#line 823 /* choose random stride from 1 to edge */ +#line 823 for (k = 0; k < nslabs; k++) { +#line 823 nstarts = 1; +#line 823 for (j = 0; j < var_rank[i]; j++) { +#line 823 if ((k >> j) & 1) { +#line 823 start[j] = 0; +#line 823 edge[j] = mid[j]; +#line 823 }else{ +#line 823 start[j] = mid[j]; +#line 823 edge[j] = var_shape[i][j] - mid[j]; +#line 823 } +#line 823 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 823 nstarts *= stride[j]; +#line 823 } +#line 823 for (m = 0; m < nstarts; m++) { +#line 823 err = toMixedBase(m, var_rank[i], sstride, index); +#line 823 IF (err) +#line 823 error("error in toMixedBase"); +#line 823 nels = 1; +#line 823 for (j = 0; j < var_rank[i]; j++) { +#line 823 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 823 nels *= count[j]; +#line 823 index[j] += start[j]; +#line 823 } +#line 823 /* Random choice of forward or backward */ +#line 823 /* TODO +#line 823 if ( roll(2) ) { +#line 823 for (j = 0; j < var_rank[i]; j++) { +#line 823 index[j] += (count[j] - 1) * stride[j]; +#line 823 stride[j] = -stride[j]; +#line 823 } +#line 823 } +#line 823 */ +#line 823 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 823 err = toMixedBase(j, var_rank[i], count, index2); +#line 823 IF (err) +#line 823 error("error in toMixedBase"); +#line 823 for (d = 0; d < var_rank[i]; d++) +#line 823 index2[d] = index[d] + index2[d] * stride[d]; +#line 823 value[j] = hash_double(var_type[i], var_rank[i], index2, +#line 823 NCT_DOUBLE); +#line 823 allInExtRange = allInExtRange +#line 823 && inRange3(value[j], var_type[i], NCT_DOUBLE); +#line 823 } +#line 823 if (var_rank[i] == 0 && i%2 == 0) +#line 823 err = nc_put_vars_double(ncid, i, NULL, NULL, stride, value); +#line 823 else +#line 823 err = nc_put_vars_double(ncid, i, index, count, stride, value); +#line 823 if (canConvert) { +#line 823 if (allInExtRange) { +#line 823 IF (err) +#line 823 error("%s", nc_strerror(err)); +#line 823 } else { +#line 823 IF (err != NC_ERANGE) +#line 823 error("range error: status = %d", err); +#line 823 } +#line 823 } else { +#line 823 IF (nels > 0 && err != NC_ECHAR) +#line 823 error("wrong type: status = %d", err); +#line 823 } +#line 823 } +#line 823 } +#line 823 } +#line 823 +#line 823 err = nc_close(ncid); +#line 823 IF (err) +#line 823 error("nc_close: %s", nc_strerror(err)); +#line 823 +#line 823 check_vars_double(scratch); +#line 823 +#line 823 err = remove(scratch); +#line 823 IF (err) +#line 823 error("remove of %s failed", scratch); +#line 823 } +#line 823 +#line 996 void +#line 997 test_nc_put_varm_text(void) +#line 997 { +#line 997 int ncid; +#line 997 int d; +#line 997 int i; +#line 997 int j; +#line 997 int k; +#line 997 int m; +#line 997 int err; +#line 997 int nels; +#line 997 int nslabs; +#line 997 int nstarts; /* number of different starts */ +#line 997 size_t start[MAX_RANK]; +#line 997 size_t edge[MAX_RANK]; +#line 997 size_t index[MAX_RANK]; +#line 997 size_t index2[MAX_RANK]; +#line 997 size_t mid[MAX_RANK]; +#line 997 size_t count[MAX_RANK]; +#line 997 size_t sstride[MAX_RANK]; +#line 997 ptrdiff_t stride[MAX_RANK]; +#line 997 ptrdiff_t imap[MAX_RANK]; +#line 997 int canConvert; /* Both text or both numeric */ +#line 997 int allInExtRange; /* all values within external range? */ +#line 997 text value[MAX_NELS]; +#line 997 +#line 997 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 997 IF (err) { +#line 997 error("nc_create: %s", nc_strerror(err)); +#line 997 return; +#line 997 } +#line 997 def_dims(ncid); +#line 997 def_vars(ncid); +#line 997 err = nc_enddef(ncid); +#line 997 IF (err) +#line 997 error("nc_enddef: %s", nc_strerror(err)); +#line 997 +#line 997 for (i = 0; i < NVARS; i++) { +#line 997 canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT); +#line 997 assert(var_rank[i] <= MAX_RANK); +#line 997 assert(var_nels[i] <= MAX_NELS); +#line 997 for (j = 0; j < var_rank[i]; j++) { +#line 997 start[j] = 0; +#line 997 edge[j] = 1; +#line 997 stride[j] = 1; +#line 997 imap[j] = 1; +#line 997 } +#line 997 err = nc_put_varm_text(BAD_ID, i, start, edge, stride, imap, value); +#line 997 IF (err != NC_EBADID) +#line 997 error("bad ncid: status = %d", err); +#line 997 err = nc_put_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 997 IF (err != NC_ENOTVAR) +#line 997 error("bad var id: status = %d", err); +#line 997 for (j = 0; j < var_rank[i]; j++) { +#line 997 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 997 start[j] = var_shape[i][j] + 1; +#line 997 err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value); +#line 997 if (!canConvert) { +#line 997 IF(err != NC_ECHAR) +#line 997 error("conversion: status = %d", err); +#line 997 } else { +#line 997 IF (err != NC_EINVALCOORDS) +#line 997 error("bad start: status = %d", err); +#line 997 start[j] = 0; +#line 997 edge[j] = var_shape[i][j] + 1; +#line 997 err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value); +#line 997 IF (err != NC_EEDGE) +#line 997 error("bad edge: status = %d", err); +#line 997 edge[j] = 1; +#line 997 stride[j] = 0; +#line 997 err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value); +#line 997 IF (err != NC_ESTRIDE) +#line 997 error("bad stride: status = %d", err); +#line 997 stride[j] = 1; +#line 997 } +#line 997 } +#line 997 } +#line 997 /* Choose a random point dividing each dim into 2 parts */ +#line 997 /* Put 2^rank (nslabs) slabs so defined */ +#line 997 nslabs = 1; +#line 997 for (j = 0; j < var_rank[i]; j++) { +#line 997 mid[j] = roll( var_shape[i][j] ); +#line 997 nslabs *= 2; +#line 997 } +#line 997 /* bits of k determine whether to put lower or upper part of dim */ +#line 997 /* choose random stride from 1 to edge */ +#line 997 for (k = 0; k < nslabs; k++) { +#line 997 nstarts = 1; +#line 997 for (j = 0; j < var_rank[i]; j++) { +#line 997 if ((k >> j) & 1) { +#line 997 start[j] = 0; +#line 997 edge[j] = mid[j]; +#line 997 }else{ +#line 997 start[j] = mid[j]; +#line 997 edge[j] = var_shape[i][j] - mid[j]; +#line 997 } +#line 997 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 997 nstarts *= stride[j]; +#line 997 } +#line 997 for (m = 0; m < nstarts; m++) { +#line 997 err = toMixedBase(m, var_rank[i], sstride, index); +#line 997 IF (err) +#line 997 error("error in toMixedBase"); +#line 997 nels = 1; +#line 997 for (j = 0; j < var_rank[i]; j++) { +#line 997 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 997 nels *= count[j]; +#line 997 index[j] += start[j]; +#line 997 } +#line 997 /* Random choice of forward or backward */ +#line 997 /* TODO +#line 997 if ( roll(2) ) { +#line 997 for (j = 0; j < var_rank[i]; j++) { +#line 997 index[j] += (count[j] - 1) * stride[j]; +#line 997 stride[j] = -stride[j]; +#line 997 } +#line 997 } +#line 997 */ +#line 997 if (var_rank[i] > 0) { +#line 997 j = var_rank[i] - 1; +#line 997 imap[j] = 1; +#line 997 for (; j > 0; j--) +#line 997 imap[j-1] = imap[j] * count[j]; +#line 997 } +#line 997 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 997 err = toMixedBase(j, var_rank[i], count, index2); +#line 997 IF (err) +#line 997 error("error in toMixedBase"); +#line 997 for (d = 0; d < var_rank[i]; d++) +#line 997 index2[d] = index[d] + index2[d] * stride[d]; +#line 997 value[j] = hash_text(var_type[i], var_rank[i], index2, +#line 997 NCT_TEXT); +#line 997 allInExtRange = allInExtRange +#line 997 && inRange3(value[j], var_type[i], NCT_TEXT); +#line 997 } +#line 997 if (var_rank[i] == 0 && i%2 == 0) +#line 997 err = nc_put_varm_text(ncid,i,NULL,NULL,NULL,NULL,value); +#line 997 else +#line 997 err = nc_put_varm_text(ncid,i,index,count,stride,imap,value); +#line 997 if (canConvert) { +#line 997 if (allInExtRange) { +#line 997 IF (err) +#line 997 error("%s", nc_strerror(err)); +#line 997 } else { +#line 997 IF (err != NC_ERANGE) +#line 997 error("range error: status = %d", err); +#line 997 } +#line 997 } else { +#line 997 IF (nels > 0 && err != NC_ECHAR) +#line 997 error("wrong type: status = %d", err); +#line 997 } +#line 997 } +#line 997 } +#line 997 } +#line 997 +#line 997 err = nc_close(ncid); +#line 997 IF (err) +#line 997 error("nc_close: %s", nc_strerror(err)); +#line 997 +#line 997 check_vars_text(scratch); +#line 997 +#line 997 err = remove(scratch); +#line 997 IF (err) +#line 997 error("remove of %s failed", scratch); +#line 997 } +#line 997 void +#line 998 test_nc_put_varm_uchar(void) +#line 998 { +#line 998 int ncid; +#line 998 int d; +#line 998 int i; +#line 998 int j; +#line 998 int k; +#line 998 int m; +#line 998 int err; +#line 998 int nels; +#line 998 int nslabs; +#line 998 int nstarts; /* number of different starts */ +#line 998 size_t start[MAX_RANK]; +#line 998 size_t edge[MAX_RANK]; +#line 998 size_t index[MAX_RANK]; +#line 998 size_t index2[MAX_RANK]; +#line 998 size_t mid[MAX_RANK]; +#line 998 size_t count[MAX_RANK]; +#line 998 size_t sstride[MAX_RANK]; +#line 998 ptrdiff_t stride[MAX_RANK]; +#line 998 ptrdiff_t imap[MAX_RANK]; +#line 998 int canConvert; /* Both text or both numeric */ +#line 998 int allInExtRange; /* all values within external range? */ +#line 998 uchar value[MAX_NELS]; +#line 998 +#line 998 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 998 IF (err) { +#line 998 error("nc_create: %s", nc_strerror(err)); +#line 998 return; +#line 998 } +#line 998 def_dims(ncid); +#line 998 def_vars(ncid); +#line 998 err = nc_enddef(ncid); +#line 998 IF (err) +#line 998 error("nc_enddef: %s", nc_strerror(err)); +#line 998 +#line 998 for (i = 0; i < NVARS; i++) { +#line 998 canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT); +#line 998 assert(var_rank[i] <= MAX_RANK); +#line 998 assert(var_nels[i] <= MAX_NELS); +#line 998 for (j = 0; j < var_rank[i]; j++) { +#line 998 start[j] = 0; +#line 998 edge[j] = 1; +#line 998 stride[j] = 1; +#line 998 imap[j] = 1; +#line 998 } +#line 998 err = nc_put_varm_uchar(BAD_ID, i, start, edge, stride, imap, value); +#line 998 IF (err != NC_EBADID) +#line 998 error("bad ncid: status = %d", err); +#line 998 err = nc_put_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 998 IF (err != NC_ENOTVAR) +#line 998 error("bad var id: status = %d", err); +#line 998 for (j = 0; j < var_rank[i]; j++) { +#line 998 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 998 start[j] = var_shape[i][j] + 1; +#line 998 err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value); +#line 998 if (!canConvert) { +#line 998 IF(err != NC_ECHAR) +#line 998 error("conversion: status = %d", err); +#line 998 } else { +#line 998 IF (err != NC_EINVALCOORDS) +#line 998 error("bad start: status = %d", err); +#line 998 start[j] = 0; +#line 998 edge[j] = var_shape[i][j] + 1; +#line 998 err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value); +#line 998 IF (err != NC_EEDGE) +#line 998 error("bad edge: status = %d", err); +#line 998 edge[j] = 1; +#line 998 stride[j] = 0; +#line 998 err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value); +#line 998 IF (err != NC_ESTRIDE) +#line 998 error("bad stride: status = %d", err); +#line 998 stride[j] = 1; +#line 998 } +#line 998 } +#line 998 } +#line 998 /* Choose a random point dividing each dim into 2 parts */ +#line 998 /* Put 2^rank (nslabs) slabs so defined */ +#line 998 nslabs = 1; +#line 998 for (j = 0; j < var_rank[i]; j++) { +#line 998 mid[j] = roll( var_shape[i][j] ); +#line 998 nslabs *= 2; +#line 998 } +#line 998 /* bits of k determine whether to put lower or upper part of dim */ +#line 998 /* choose random stride from 1 to edge */ +#line 998 for (k = 0; k < nslabs; k++) { +#line 998 nstarts = 1; +#line 998 for (j = 0; j < var_rank[i]; j++) { +#line 998 if ((k >> j) & 1) { +#line 998 start[j] = 0; +#line 998 edge[j] = mid[j]; +#line 998 }else{ +#line 998 start[j] = mid[j]; +#line 998 edge[j] = var_shape[i][j] - mid[j]; +#line 998 } +#line 998 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 998 nstarts *= stride[j]; +#line 998 } +#line 998 for (m = 0; m < nstarts; m++) { +#line 998 err = toMixedBase(m, var_rank[i], sstride, index); +#line 998 IF (err) +#line 998 error("error in toMixedBase"); +#line 998 nels = 1; +#line 998 for (j = 0; j < var_rank[i]; j++) { +#line 998 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 998 nels *= count[j]; +#line 998 index[j] += start[j]; +#line 998 } +#line 998 /* Random choice of forward or backward */ +#line 998 /* TODO +#line 998 if ( roll(2) ) { +#line 998 for (j = 0; j < var_rank[i]; j++) { +#line 998 index[j] += (count[j] - 1) * stride[j]; +#line 998 stride[j] = -stride[j]; +#line 998 } +#line 998 } +#line 998 */ +#line 998 if (var_rank[i] > 0) { +#line 998 j = var_rank[i] - 1; +#line 998 imap[j] = 1; +#line 998 for (; j > 0; j--) +#line 998 imap[j-1] = imap[j] * count[j]; +#line 998 } +#line 998 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 998 err = toMixedBase(j, var_rank[i], count, index2); +#line 998 IF (err) +#line 998 error("error in toMixedBase"); +#line 998 for (d = 0; d < var_rank[i]; d++) +#line 998 index2[d] = index[d] + index2[d] * stride[d]; +#line 998 value[j] = hash_uchar(var_type[i], var_rank[i], index2, +#line 998 NCT_UCHAR); +#line 998 allInExtRange = allInExtRange +#line 998 && inRange3(value[j], var_type[i], NCT_UCHAR); +#line 998 } +#line 998 if (var_rank[i] == 0 && i%2 == 0) +#line 998 err = nc_put_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value); +#line 998 else +#line 998 err = nc_put_varm_uchar(ncid,i,index,count,stride,imap,value); +#line 998 if (canConvert) { +#line 998 if (allInExtRange) { +#line 998 IF (err) +#line 998 error("%s", nc_strerror(err)); +#line 998 } else { +#line 998 IF (err != NC_ERANGE) +#line 998 error("range error: status = %d", err); +#line 998 } +#line 998 } else { +#line 998 IF (nels > 0 && err != NC_ECHAR) +#line 998 error("wrong type: status = %d", err); +#line 998 } +#line 998 } +#line 998 } +#line 998 } +#line 998 +#line 998 err = nc_close(ncid); +#line 998 IF (err) +#line 998 error("nc_close: %s", nc_strerror(err)); +#line 998 +#line 998 check_vars_uchar(scratch); +#line 998 +#line 998 err = remove(scratch); +#line 998 IF (err) +#line 998 error("remove of %s failed", scratch); +#line 998 } +#line 998 void +#line 999 test_nc_put_varm_schar(void) +#line 999 { +#line 999 int ncid; +#line 999 int d; +#line 999 int i; +#line 999 int j; +#line 999 int k; +#line 999 int m; +#line 999 int err; +#line 999 int nels; +#line 999 int nslabs; +#line 999 int nstarts; /* number of different starts */ +#line 999 size_t start[MAX_RANK]; +#line 999 size_t edge[MAX_RANK]; +#line 999 size_t index[MAX_RANK]; +#line 999 size_t index2[MAX_RANK]; +#line 999 size_t mid[MAX_RANK]; +#line 999 size_t count[MAX_RANK]; +#line 999 size_t sstride[MAX_RANK]; +#line 999 ptrdiff_t stride[MAX_RANK]; +#line 999 ptrdiff_t imap[MAX_RANK]; +#line 999 int canConvert; /* Both text or both numeric */ +#line 999 int allInExtRange; /* all values within external range? */ +#line 999 schar value[MAX_NELS]; +#line 999 +#line 999 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 999 IF (err) { +#line 999 error("nc_create: %s", nc_strerror(err)); +#line 999 return; +#line 999 } +#line 999 def_dims(ncid); +#line 999 def_vars(ncid); +#line 999 err = nc_enddef(ncid); +#line 999 IF (err) +#line 999 error("nc_enddef: %s", nc_strerror(err)); +#line 999 +#line 999 for (i = 0; i < NVARS; i++) { +#line 999 canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT); +#line 999 assert(var_rank[i] <= MAX_RANK); +#line 999 assert(var_nels[i] <= MAX_NELS); +#line 999 for (j = 0; j < var_rank[i]; j++) { +#line 999 start[j] = 0; +#line 999 edge[j] = 1; +#line 999 stride[j] = 1; +#line 999 imap[j] = 1; +#line 999 } +#line 999 err = nc_put_varm_schar(BAD_ID, i, start, edge, stride, imap, value); +#line 999 IF (err != NC_EBADID) +#line 999 error("bad ncid: status = %d", err); +#line 999 err = nc_put_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 999 IF (err != NC_ENOTVAR) +#line 999 error("bad var id: status = %d", err); +#line 999 for (j = 0; j < var_rank[i]; j++) { +#line 999 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 999 start[j] = var_shape[i][j] + 1; +#line 999 err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value); +#line 999 if (!canConvert) { +#line 999 IF(err != NC_ECHAR) +#line 999 error("conversion: status = %d", err); +#line 999 } else { +#line 999 IF (err != NC_EINVALCOORDS) +#line 999 error("bad start: status = %d", err); +#line 999 start[j] = 0; +#line 999 edge[j] = var_shape[i][j] + 1; +#line 999 err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value); +#line 999 IF (err != NC_EEDGE) +#line 999 error("bad edge: status = %d", err); +#line 999 edge[j] = 1; +#line 999 stride[j] = 0; +#line 999 err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value); +#line 999 IF (err != NC_ESTRIDE) +#line 999 error("bad stride: status = %d", err); +#line 999 stride[j] = 1; +#line 999 } +#line 999 } +#line 999 } +#line 999 /* Choose a random point dividing each dim into 2 parts */ +#line 999 /* Put 2^rank (nslabs) slabs so defined */ +#line 999 nslabs = 1; +#line 999 for (j = 0; j < var_rank[i]; j++) { +#line 999 mid[j] = roll( var_shape[i][j] ); +#line 999 nslabs *= 2; +#line 999 } +#line 999 /* bits of k determine whether to put lower or upper part of dim */ +#line 999 /* choose random stride from 1 to edge */ +#line 999 for (k = 0; k < nslabs; k++) { +#line 999 nstarts = 1; +#line 999 for (j = 0; j < var_rank[i]; j++) { +#line 999 if ((k >> j) & 1) { +#line 999 start[j] = 0; +#line 999 edge[j] = mid[j]; +#line 999 }else{ +#line 999 start[j] = mid[j]; +#line 999 edge[j] = var_shape[i][j] - mid[j]; +#line 999 } +#line 999 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 999 nstarts *= stride[j]; +#line 999 } +#line 999 for (m = 0; m < nstarts; m++) { +#line 999 err = toMixedBase(m, var_rank[i], sstride, index); +#line 999 IF (err) +#line 999 error("error in toMixedBase"); +#line 999 nels = 1; +#line 999 for (j = 0; j < var_rank[i]; j++) { +#line 999 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 999 nels *= count[j]; +#line 999 index[j] += start[j]; +#line 999 } +#line 999 /* Random choice of forward or backward */ +#line 999 /* TODO +#line 999 if ( roll(2) ) { +#line 999 for (j = 0; j < var_rank[i]; j++) { +#line 999 index[j] += (count[j] - 1) * stride[j]; +#line 999 stride[j] = -stride[j]; +#line 999 } +#line 999 } +#line 999 */ +#line 999 if (var_rank[i] > 0) { +#line 999 j = var_rank[i] - 1; +#line 999 imap[j] = 1; +#line 999 for (; j > 0; j--) +#line 999 imap[j-1] = imap[j] * count[j]; +#line 999 } +#line 999 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 999 err = toMixedBase(j, var_rank[i], count, index2); +#line 999 IF (err) +#line 999 error("error in toMixedBase"); +#line 999 for (d = 0; d < var_rank[i]; d++) +#line 999 index2[d] = index[d] + index2[d] * stride[d]; +#line 999 value[j] = hash_schar(var_type[i], var_rank[i], index2, +#line 999 NCT_SCHAR); +#line 999 allInExtRange = allInExtRange +#line 999 && inRange3(value[j], var_type[i], NCT_SCHAR); +#line 999 } +#line 999 if (var_rank[i] == 0 && i%2 == 0) +#line 999 err = nc_put_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value); +#line 999 else +#line 999 err = nc_put_varm_schar(ncid,i,index,count,stride,imap,value); +#line 999 if (canConvert) { +#line 999 if (allInExtRange) { +#line 999 IF (err) +#line 999 error("%s", nc_strerror(err)); +#line 999 } else { +#line 999 IF (err != NC_ERANGE) +#line 999 error("range error: status = %d", err); +#line 999 } +#line 999 } else { +#line 999 IF (nels > 0 && err != NC_ECHAR) +#line 999 error("wrong type: status = %d", err); +#line 999 } +#line 999 } +#line 999 } +#line 999 } +#line 999 +#line 999 err = nc_close(ncid); +#line 999 IF (err) +#line 999 error("nc_close: %s", nc_strerror(err)); +#line 999 +#line 999 check_vars_schar(scratch); +#line 999 +#line 999 err = remove(scratch); +#line 999 IF (err) +#line 999 error("remove of %s failed", scratch); +#line 999 } +#line 999 void +#line 1000 test_nc_put_varm_short(void) +#line 1000 { +#line 1000 int ncid; +#line 1000 int d; +#line 1000 int i; +#line 1000 int j; +#line 1000 int k; +#line 1000 int m; +#line 1000 int err; +#line 1000 int nels; +#line 1000 int nslabs; +#line 1000 int nstarts; /* number of different starts */ +#line 1000 size_t start[MAX_RANK]; +#line 1000 size_t edge[MAX_RANK]; +#line 1000 size_t index[MAX_RANK]; +#line 1000 size_t index2[MAX_RANK]; +#line 1000 size_t mid[MAX_RANK]; +#line 1000 size_t count[MAX_RANK]; +#line 1000 size_t sstride[MAX_RANK]; +#line 1000 ptrdiff_t stride[MAX_RANK]; +#line 1000 ptrdiff_t imap[MAX_RANK]; +#line 1000 int canConvert; /* Both text or both numeric */ +#line 1000 int allInExtRange; /* all values within external range? */ +#line 1000 short value[MAX_NELS]; +#line 1000 +#line 1000 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 1000 IF (err) { +#line 1000 error("nc_create: %s", nc_strerror(err)); +#line 1000 return; +#line 1000 } +#line 1000 def_dims(ncid); +#line 1000 def_vars(ncid); +#line 1000 err = nc_enddef(ncid); +#line 1000 IF (err) +#line 1000 error("nc_enddef: %s", nc_strerror(err)); +#line 1000 +#line 1000 for (i = 0; i < NVARS; i++) { +#line 1000 canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT); +#line 1000 assert(var_rank[i] <= MAX_RANK); +#line 1000 assert(var_nels[i] <= MAX_NELS); +#line 1000 for (j = 0; j < var_rank[i]; j++) { +#line 1000 start[j] = 0; +#line 1000 edge[j] = 1; +#line 1000 stride[j] = 1; +#line 1000 imap[j] = 1; +#line 1000 } +#line 1000 err = nc_put_varm_short(BAD_ID, i, start, edge, stride, imap, value); +#line 1000 IF (err != NC_EBADID) +#line 1000 error("bad ncid: status = %d", err); +#line 1000 err = nc_put_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 1000 IF (err != NC_ENOTVAR) +#line 1000 error("bad var id: status = %d", err); +#line 1000 for (j = 0; j < var_rank[i]; j++) { +#line 1000 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 1000 start[j] = var_shape[i][j] + 1; +#line 1000 err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value); +#line 1000 if (!canConvert) { +#line 1000 IF(err != NC_ECHAR) +#line 1000 error("conversion: status = %d", err); +#line 1000 } else { +#line 1000 IF (err != NC_EINVALCOORDS) +#line 1000 error("bad start: status = %d", err); +#line 1000 start[j] = 0; +#line 1000 edge[j] = var_shape[i][j] + 1; +#line 1000 err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value); +#line 1000 IF (err != NC_EEDGE) +#line 1000 error("bad edge: status = %d", err); +#line 1000 edge[j] = 1; +#line 1000 stride[j] = 0; +#line 1000 err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value); +#line 1000 IF (err != NC_ESTRIDE) +#line 1000 error("bad stride: status = %d", err); +#line 1000 stride[j] = 1; +#line 1000 } +#line 1000 } +#line 1000 } +#line 1000 /* Choose a random point dividing each dim into 2 parts */ +#line 1000 /* Put 2^rank (nslabs) slabs so defined */ +#line 1000 nslabs = 1; +#line 1000 for (j = 0; j < var_rank[i]; j++) { +#line 1000 mid[j] = roll( var_shape[i][j] ); +#line 1000 nslabs *= 2; +#line 1000 } +#line 1000 /* bits of k determine whether to put lower or upper part of dim */ +#line 1000 /* choose random stride from 1 to edge */ +#line 1000 for (k = 0; k < nslabs; k++) { +#line 1000 nstarts = 1; +#line 1000 for (j = 0; j < var_rank[i]; j++) { +#line 1000 if ((k >> j) & 1) { +#line 1000 start[j] = 0; +#line 1000 edge[j] = mid[j]; +#line 1000 }else{ +#line 1000 start[j] = mid[j]; +#line 1000 edge[j] = var_shape[i][j] - mid[j]; +#line 1000 } +#line 1000 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 1000 nstarts *= stride[j]; +#line 1000 } +#line 1000 for (m = 0; m < nstarts; m++) { +#line 1000 err = toMixedBase(m, var_rank[i], sstride, index); +#line 1000 IF (err) +#line 1000 error("error in toMixedBase"); +#line 1000 nels = 1; +#line 1000 for (j = 0; j < var_rank[i]; j++) { +#line 1000 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 1000 nels *= count[j]; +#line 1000 index[j] += start[j]; +#line 1000 } +#line 1000 /* Random choice of forward or backward */ +#line 1000 /* TODO +#line 1000 if ( roll(2) ) { +#line 1000 for (j = 0; j < var_rank[i]; j++) { +#line 1000 index[j] += (count[j] - 1) * stride[j]; +#line 1000 stride[j] = -stride[j]; +#line 1000 } +#line 1000 } +#line 1000 */ +#line 1000 if (var_rank[i] > 0) { +#line 1000 j = var_rank[i] - 1; +#line 1000 imap[j] = 1; +#line 1000 for (; j > 0; j--) +#line 1000 imap[j-1] = imap[j] * count[j]; +#line 1000 } +#line 1000 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 1000 err = toMixedBase(j, var_rank[i], count, index2); +#line 1000 IF (err) +#line 1000 error("error in toMixedBase"); +#line 1000 for (d = 0; d < var_rank[i]; d++) +#line 1000 index2[d] = index[d] + index2[d] * stride[d]; +#line 1000 value[j] = hash_short(var_type[i], var_rank[i], index2, +#line 1000 NCT_SHORT); +#line 1000 allInExtRange = allInExtRange +#line 1000 && inRange3(value[j], var_type[i], NCT_SHORT); +#line 1000 } +#line 1000 if (var_rank[i] == 0 && i%2 == 0) +#line 1000 err = nc_put_varm_short(ncid,i,NULL,NULL,NULL,NULL,value); +#line 1000 else +#line 1000 err = nc_put_varm_short(ncid,i,index,count,stride,imap,value); +#line 1000 if (canConvert) { +#line 1000 if (allInExtRange) { +#line 1000 IF (err) +#line 1000 error("%s", nc_strerror(err)); +#line 1000 } else { +#line 1000 IF (err != NC_ERANGE) +#line 1000 error("range error: status = %d", err); +#line 1000 } +#line 1000 } else { +#line 1000 IF (nels > 0 && err != NC_ECHAR) +#line 1000 error("wrong type: status = %d", err); +#line 1000 } +#line 1000 } +#line 1000 } +#line 1000 } +#line 1000 +#line 1000 err = nc_close(ncid); +#line 1000 IF (err) +#line 1000 error("nc_close: %s", nc_strerror(err)); +#line 1000 +#line 1000 check_vars_short(scratch); +#line 1000 +#line 1000 err = remove(scratch); +#line 1000 IF (err) +#line 1000 error("remove of %s failed", scratch); +#line 1000 } +#line 1000 void +#line 1001 test_nc_put_varm_int(void) +#line 1001 { +#line 1001 int ncid; +#line 1001 int d; +#line 1001 int i; +#line 1001 int j; +#line 1001 int k; +#line 1001 int m; +#line 1001 int err; +#line 1001 int nels; +#line 1001 int nslabs; +#line 1001 int nstarts; /* number of different starts */ +#line 1001 size_t start[MAX_RANK]; +#line 1001 size_t edge[MAX_RANK]; +#line 1001 size_t index[MAX_RANK]; +#line 1001 size_t index2[MAX_RANK]; +#line 1001 size_t mid[MAX_RANK]; +#line 1001 size_t count[MAX_RANK]; +#line 1001 size_t sstride[MAX_RANK]; +#line 1001 ptrdiff_t stride[MAX_RANK]; +#line 1001 ptrdiff_t imap[MAX_RANK]; +#line 1001 int canConvert; /* Both text or both numeric */ +#line 1001 int allInExtRange; /* all values within external range? */ +#line 1001 int value[MAX_NELS]; +#line 1001 +#line 1001 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 1001 IF (err) { +#line 1001 error("nc_create: %s", nc_strerror(err)); +#line 1001 return; +#line 1001 } +#line 1001 def_dims(ncid); +#line 1001 def_vars(ncid); +#line 1001 err = nc_enddef(ncid); +#line 1001 IF (err) +#line 1001 error("nc_enddef: %s", nc_strerror(err)); +#line 1001 +#line 1001 for (i = 0; i < NVARS; i++) { +#line 1001 canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT); +#line 1001 assert(var_rank[i] <= MAX_RANK); +#line 1001 assert(var_nels[i] <= MAX_NELS); +#line 1001 for (j = 0; j < var_rank[i]; j++) { +#line 1001 start[j] = 0; +#line 1001 edge[j] = 1; +#line 1001 stride[j] = 1; +#line 1001 imap[j] = 1; +#line 1001 } +#line 1001 err = nc_put_varm_int(BAD_ID, i, start, edge, stride, imap, value); +#line 1001 IF (err != NC_EBADID) +#line 1001 error("bad ncid: status = %d", err); +#line 1001 err = nc_put_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 1001 IF (err != NC_ENOTVAR) +#line 1001 error("bad var id: status = %d", err); +#line 1001 for (j = 0; j < var_rank[i]; j++) { +#line 1001 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 1001 start[j] = var_shape[i][j] + 1; +#line 1001 err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value); +#line 1001 if (!canConvert) { +#line 1001 IF(err != NC_ECHAR) +#line 1001 error("conversion: status = %d", err); +#line 1001 } else { +#line 1001 IF (err != NC_EINVALCOORDS) +#line 1001 error("bad start: status = %d", err); +#line 1001 start[j] = 0; +#line 1001 edge[j] = var_shape[i][j] + 1; +#line 1001 err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value); +#line 1001 IF (err != NC_EEDGE) +#line 1001 error("bad edge: status = %d", err); +#line 1001 edge[j] = 1; +#line 1001 stride[j] = 0; +#line 1001 err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value); +#line 1001 IF (err != NC_ESTRIDE) +#line 1001 error("bad stride: status = %d", err); +#line 1001 stride[j] = 1; +#line 1001 } +#line 1001 } +#line 1001 } +#line 1001 /* Choose a random point dividing each dim into 2 parts */ +#line 1001 /* Put 2^rank (nslabs) slabs so defined */ +#line 1001 nslabs = 1; +#line 1001 for (j = 0; j < var_rank[i]; j++) { +#line 1001 mid[j] = roll( var_shape[i][j] ); +#line 1001 nslabs *= 2; +#line 1001 } +#line 1001 /* bits of k determine whether to put lower or upper part of dim */ +#line 1001 /* choose random stride from 1 to edge */ +#line 1001 for (k = 0; k < nslabs; k++) { +#line 1001 nstarts = 1; +#line 1001 for (j = 0; j < var_rank[i]; j++) { +#line 1001 if ((k >> j) & 1) { +#line 1001 start[j] = 0; +#line 1001 edge[j] = mid[j]; +#line 1001 }else{ +#line 1001 start[j] = mid[j]; +#line 1001 edge[j] = var_shape[i][j] - mid[j]; +#line 1001 } +#line 1001 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 1001 nstarts *= stride[j]; +#line 1001 } +#line 1001 for (m = 0; m < nstarts; m++) { +#line 1001 err = toMixedBase(m, var_rank[i], sstride, index); +#line 1001 IF (err) +#line 1001 error("error in toMixedBase"); +#line 1001 nels = 1; +#line 1001 for (j = 0; j < var_rank[i]; j++) { +#line 1001 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 1001 nels *= count[j]; +#line 1001 index[j] += start[j]; +#line 1001 } +#line 1001 /* Random choice of forward or backward */ +#line 1001 /* TODO +#line 1001 if ( roll(2) ) { +#line 1001 for (j = 0; j < var_rank[i]; j++) { +#line 1001 index[j] += (count[j] - 1) * stride[j]; +#line 1001 stride[j] = -stride[j]; +#line 1001 } +#line 1001 } +#line 1001 */ +#line 1001 if (var_rank[i] > 0) { +#line 1001 j = var_rank[i] - 1; +#line 1001 imap[j] = 1; +#line 1001 for (; j > 0; j--) +#line 1001 imap[j-1] = imap[j] * count[j]; +#line 1001 } +#line 1001 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 1001 err = toMixedBase(j, var_rank[i], count, index2); +#line 1001 IF (err) +#line 1001 error("error in toMixedBase"); +#line 1001 for (d = 0; d < var_rank[i]; d++) +#line 1001 index2[d] = index[d] + index2[d] * stride[d]; +#line 1001 value[j] = hash_int(var_type[i], var_rank[i], index2, +#line 1001 NCT_INT); +#line 1001 allInExtRange = allInExtRange +#line 1001 && inRange3(value[j], var_type[i], NCT_INT); +#line 1001 } +#line 1001 if (var_rank[i] == 0 && i%2 == 0) +#line 1001 err = nc_put_varm_int(ncid,i,NULL,NULL,NULL,NULL,value); +#line 1001 else +#line 1001 err = nc_put_varm_int(ncid,i,index,count,stride,imap,value); +#line 1001 if (canConvert) { +#line 1001 if (allInExtRange) { +#line 1001 IF (err) +#line 1001 error("%s", nc_strerror(err)); +#line 1001 } else { +#line 1001 IF (err != NC_ERANGE) +#line 1001 error("range error: status = %d", err); +#line 1001 } +#line 1001 } else { +#line 1001 IF (nels > 0 && err != NC_ECHAR) +#line 1001 error("wrong type: status = %d", err); +#line 1001 } +#line 1001 } +#line 1001 } +#line 1001 } +#line 1001 +#line 1001 err = nc_close(ncid); +#line 1001 IF (err) +#line 1001 error("nc_close: %s", nc_strerror(err)); +#line 1001 +#line 1001 check_vars_int(scratch); +#line 1001 +#line 1001 err = remove(scratch); +#line 1001 IF (err) +#line 1001 error("remove of %s failed", scratch); +#line 1001 } +#line 1001 void +#line 1002 test_nc_put_varm_long(void) +#line 1002 { +#line 1002 int ncid; +#line 1002 int d; +#line 1002 int i; +#line 1002 int j; +#line 1002 int k; +#line 1002 int m; +#line 1002 int err; +#line 1002 int nels; +#line 1002 int nslabs; +#line 1002 int nstarts; /* number of different starts */ +#line 1002 size_t start[MAX_RANK]; +#line 1002 size_t edge[MAX_RANK]; +#line 1002 size_t index[MAX_RANK]; +#line 1002 size_t index2[MAX_RANK]; +#line 1002 size_t mid[MAX_RANK]; +#line 1002 size_t count[MAX_RANK]; +#line 1002 size_t sstride[MAX_RANK]; +#line 1002 ptrdiff_t stride[MAX_RANK]; +#line 1002 ptrdiff_t imap[MAX_RANK]; +#line 1002 int canConvert; /* Both text or both numeric */ +#line 1002 int allInExtRange; /* all values within external range? */ +#line 1002 long value[MAX_NELS]; +#line 1002 +#line 1002 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 1002 IF (err) { +#line 1002 error("nc_create: %s", nc_strerror(err)); +#line 1002 return; +#line 1002 } +#line 1002 def_dims(ncid); +#line 1002 def_vars(ncid); +#line 1002 err = nc_enddef(ncid); +#line 1002 IF (err) +#line 1002 error("nc_enddef: %s", nc_strerror(err)); +#line 1002 +#line 1002 for (i = 0; i < NVARS; i++) { +#line 1002 canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT); +#line 1002 assert(var_rank[i] <= MAX_RANK); +#line 1002 assert(var_nels[i] <= MAX_NELS); +#line 1002 for (j = 0; j < var_rank[i]; j++) { +#line 1002 start[j] = 0; +#line 1002 edge[j] = 1; +#line 1002 stride[j] = 1; +#line 1002 imap[j] = 1; +#line 1002 } +#line 1002 err = nc_put_varm_long(BAD_ID, i, start, edge, stride, imap, value); +#line 1002 IF (err != NC_EBADID) +#line 1002 error("bad ncid: status = %d", err); +#line 1002 err = nc_put_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 1002 IF (err != NC_ENOTVAR) +#line 1002 error("bad var id: status = %d", err); +#line 1002 for (j = 0; j < var_rank[i]; j++) { +#line 1002 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 1002 start[j] = var_shape[i][j] + 1; +#line 1002 err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value); +#line 1002 if (!canConvert) { +#line 1002 IF(err != NC_ECHAR) +#line 1002 error("conversion: status = %d", err); +#line 1002 } else { +#line 1002 IF (err != NC_EINVALCOORDS) +#line 1002 error("bad start: status = %d", err); +#line 1002 start[j] = 0; +#line 1002 edge[j] = var_shape[i][j] + 1; +#line 1002 err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value); +#line 1002 IF (err != NC_EEDGE) +#line 1002 error("bad edge: status = %d", err); +#line 1002 edge[j] = 1; +#line 1002 stride[j] = 0; +#line 1002 err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value); +#line 1002 IF (err != NC_ESTRIDE) +#line 1002 error("bad stride: status = %d", err); +#line 1002 stride[j] = 1; +#line 1002 } +#line 1002 } +#line 1002 } +#line 1002 /* Choose a random point dividing each dim into 2 parts */ +#line 1002 /* Put 2^rank (nslabs) slabs so defined */ +#line 1002 nslabs = 1; +#line 1002 for (j = 0; j < var_rank[i]; j++) { +#line 1002 mid[j] = roll( var_shape[i][j] ); +#line 1002 nslabs *= 2; +#line 1002 } +#line 1002 /* bits of k determine whether to put lower or upper part of dim */ +#line 1002 /* choose random stride from 1 to edge */ +#line 1002 for (k = 0; k < nslabs; k++) { +#line 1002 nstarts = 1; +#line 1002 for (j = 0; j < var_rank[i]; j++) { +#line 1002 if ((k >> j) & 1) { +#line 1002 start[j] = 0; +#line 1002 edge[j] = mid[j]; +#line 1002 }else{ +#line 1002 start[j] = mid[j]; +#line 1002 edge[j] = var_shape[i][j] - mid[j]; +#line 1002 } +#line 1002 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 1002 nstarts *= stride[j]; +#line 1002 } +#line 1002 for (m = 0; m < nstarts; m++) { +#line 1002 err = toMixedBase(m, var_rank[i], sstride, index); +#line 1002 IF (err) +#line 1002 error("error in toMixedBase"); +#line 1002 nels = 1; +#line 1002 for (j = 0; j < var_rank[i]; j++) { +#line 1002 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 1002 nels *= count[j]; +#line 1002 index[j] += start[j]; +#line 1002 } +#line 1002 /* Random choice of forward or backward */ +#line 1002 /* TODO +#line 1002 if ( roll(2) ) { +#line 1002 for (j = 0; j < var_rank[i]; j++) { +#line 1002 index[j] += (count[j] - 1) * stride[j]; +#line 1002 stride[j] = -stride[j]; +#line 1002 } +#line 1002 } +#line 1002 */ +#line 1002 if (var_rank[i] > 0) { +#line 1002 j = var_rank[i] - 1; +#line 1002 imap[j] = 1; +#line 1002 for (; j > 0; j--) +#line 1002 imap[j-1] = imap[j] * count[j]; +#line 1002 } +#line 1002 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 1002 err = toMixedBase(j, var_rank[i], count, index2); +#line 1002 IF (err) +#line 1002 error("error in toMixedBase"); +#line 1002 for (d = 0; d < var_rank[i]; d++) +#line 1002 index2[d] = index[d] + index2[d] * stride[d]; +#line 1002 value[j] = hash_long(var_type[i], var_rank[i], index2, +#line 1002 NCT_LONG); +#line 1002 allInExtRange = allInExtRange +#line 1002 && inRange3(value[j], var_type[i], NCT_LONG); +#line 1002 } +#line 1002 if (var_rank[i] == 0 && i%2 == 0) +#line 1002 err = nc_put_varm_long(ncid,i,NULL,NULL,NULL,NULL,value); +#line 1002 else +#line 1002 err = nc_put_varm_long(ncid,i,index,count,stride,imap,value); +#line 1002 if (canConvert) { +#line 1002 if (allInExtRange) { +#line 1002 IF (err) +#line 1002 error("%s", nc_strerror(err)); +#line 1002 } else { +#line 1002 IF (err != NC_ERANGE) +#line 1002 error("range error: status = %d", err); +#line 1002 } +#line 1002 } else { +#line 1002 IF (nels > 0 && err != NC_ECHAR) +#line 1002 error("wrong type: status = %d", err); +#line 1002 } +#line 1002 } +#line 1002 } +#line 1002 } +#line 1002 +#line 1002 err = nc_close(ncid); +#line 1002 IF (err) +#line 1002 error("nc_close: %s", nc_strerror(err)); +#line 1002 +#line 1002 check_vars_long(scratch); +#line 1002 +#line 1002 err = remove(scratch); +#line 1002 IF (err) +#line 1002 error("remove of %s failed", scratch); +#line 1002 } +#line 1002 void +#line 1003 test_nc_put_varm_float(void) +#line 1003 { +#line 1003 int ncid; +#line 1003 int d; +#line 1003 int i; +#line 1003 int j; +#line 1003 int k; +#line 1003 int m; +#line 1003 int err; +#line 1003 int nels; +#line 1003 int nslabs; +#line 1003 int nstarts; /* number of different starts */ +#line 1003 size_t start[MAX_RANK]; +#line 1003 size_t edge[MAX_RANK]; +#line 1003 size_t index[MAX_RANK]; +#line 1003 size_t index2[MAX_RANK]; +#line 1003 size_t mid[MAX_RANK]; +#line 1003 size_t count[MAX_RANK]; +#line 1003 size_t sstride[MAX_RANK]; +#line 1003 ptrdiff_t stride[MAX_RANK]; +#line 1003 ptrdiff_t imap[MAX_RANK]; +#line 1003 int canConvert; /* Both text or both numeric */ +#line 1003 int allInExtRange; /* all values within external range? */ +#line 1003 float value[MAX_NELS]; +#line 1003 +#line 1003 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 1003 IF (err) { +#line 1003 error("nc_create: %s", nc_strerror(err)); +#line 1003 return; +#line 1003 } +#line 1003 def_dims(ncid); +#line 1003 def_vars(ncid); +#line 1003 err = nc_enddef(ncid); +#line 1003 IF (err) +#line 1003 error("nc_enddef: %s", nc_strerror(err)); +#line 1003 +#line 1003 for (i = 0; i < NVARS; i++) { +#line 1003 canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT); +#line 1003 assert(var_rank[i] <= MAX_RANK); +#line 1003 assert(var_nels[i] <= MAX_NELS); +#line 1003 for (j = 0; j < var_rank[i]; j++) { +#line 1003 start[j] = 0; +#line 1003 edge[j] = 1; +#line 1003 stride[j] = 1; +#line 1003 imap[j] = 1; +#line 1003 } +#line 1003 err = nc_put_varm_float(BAD_ID, i, start, edge, stride, imap, value); +#line 1003 IF (err != NC_EBADID) +#line 1003 error("bad ncid: status = %d", err); +#line 1003 err = nc_put_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 1003 IF (err != NC_ENOTVAR) +#line 1003 error("bad var id: status = %d", err); +#line 1003 for (j = 0; j < var_rank[i]; j++) { +#line 1003 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 1003 start[j] = var_shape[i][j] + 1; +#line 1003 err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value); +#line 1003 if (!canConvert) { +#line 1003 IF(err != NC_ECHAR) +#line 1003 error("conversion: status = %d", err); +#line 1003 } else { +#line 1003 IF (err != NC_EINVALCOORDS) +#line 1003 error("bad start: status = %d", err); +#line 1003 start[j] = 0; +#line 1003 edge[j] = var_shape[i][j] + 1; +#line 1003 err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value); +#line 1003 IF (err != NC_EEDGE) +#line 1003 error("bad edge: status = %d", err); +#line 1003 edge[j] = 1; +#line 1003 stride[j] = 0; +#line 1003 err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value); +#line 1003 IF (err != NC_ESTRIDE) +#line 1003 error("bad stride: status = %d", err); +#line 1003 stride[j] = 1; +#line 1003 } +#line 1003 } +#line 1003 } +#line 1003 /* Choose a random point dividing each dim into 2 parts */ +#line 1003 /* Put 2^rank (nslabs) slabs so defined */ +#line 1003 nslabs = 1; +#line 1003 for (j = 0; j < var_rank[i]; j++) { +#line 1003 mid[j] = roll( var_shape[i][j] ); +#line 1003 nslabs *= 2; +#line 1003 } +#line 1003 /* bits of k determine whether to put lower or upper part of dim */ +#line 1003 /* choose random stride from 1 to edge */ +#line 1003 for (k = 0; k < nslabs; k++) { +#line 1003 nstarts = 1; +#line 1003 for (j = 0; j < var_rank[i]; j++) { +#line 1003 if ((k >> j) & 1) { +#line 1003 start[j] = 0; +#line 1003 edge[j] = mid[j]; +#line 1003 }else{ +#line 1003 start[j] = mid[j]; +#line 1003 edge[j] = var_shape[i][j] - mid[j]; +#line 1003 } +#line 1003 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 1003 nstarts *= stride[j]; +#line 1003 } +#line 1003 for (m = 0; m < nstarts; m++) { +#line 1003 err = toMixedBase(m, var_rank[i], sstride, index); +#line 1003 IF (err) +#line 1003 error("error in toMixedBase"); +#line 1003 nels = 1; +#line 1003 for (j = 0; j < var_rank[i]; j++) { +#line 1003 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 1003 nels *= count[j]; +#line 1003 index[j] += start[j]; +#line 1003 } +#line 1003 /* Random choice of forward or backward */ +#line 1003 /* TODO +#line 1003 if ( roll(2) ) { +#line 1003 for (j = 0; j < var_rank[i]; j++) { +#line 1003 index[j] += (count[j] - 1) * stride[j]; +#line 1003 stride[j] = -stride[j]; +#line 1003 } +#line 1003 } +#line 1003 */ +#line 1003 if (var_rank[i] > 0) { +#line 1003 j = var_rank[i] - 1; +#line 1003 imap[j] = 1; +#line 1003 for (; j > 0; j--) +#line 1003 imap[j-1] = imap[j] * count[j]; +#line 1003 } +#line 1003 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 1003 err = toMixedBase(j, var_rank[i], count, index2); +#line 1003 IF (err) +#line 1003 error("error in toMixedBase"); +#line 1003 for (d = 0; d < var_rank[i]; d++) +#line 1003 index2[d] = index[d] + index2[d] * stride[d]; +#line 1003 value[j] = hash_float(var_type[i], var_rank[i], index2, +#line 1003 NCT_FLOAT); +#line 1003 allInExtRange = allInExtRange +#line 1003 && inRange3(value[j], var_type[i], NCT_FLOAT); +#line 1003 } +#line 1003 if (var_rank[i] == 0 && i%2 == 0) +#line 1003 err = nc_put_varm_float(ncid,i,NULL,NULL,NULL,NULL,value); +#line 1003 else +#line 1003 err = nc_put_varm_float(ncid,i,index,count,stride,imap,value); +#line 1003 if (canConvert) { +#line 1003 if (allInExtRange) { +#line 1003 IF (err) +#line 1003 error("%s", nc_strerror(err)); +#line 1003 } else { +#line 1003 IF (err != NC_ERANGE) +#line 1003 error("range error: status = %d", err); +#line 1003 } +#line 1003 } else { +#line 1003 IF (nels > 0 && err != NC_ECHAR) +#line 1003 error("wrong type: status = %d", err); +#line 1003 } +#line 1003 } +#line 1003 } +#line 1003 } +#line 1003 +#line 1003 err = nc_close(ncid); +#line 1003 IF (err) +#line 1003 error("nc_close: %s", nc_strerror(err)); +#line 1003 +#line 1003 check_vars_float(scratch); +#line 1003 +#line 1003 err = remove(scratch); +#line 1003 IF (err) +#line 1003 error("remove of %s failed", scratch); +#line 1003 } +#line 1003 void +#line 1004 test_nc_put_varm_double(void) +#line 1004 { +#line 1004 int ncid; +#line 1004 int d; +#line 1004 int i; +#line 1004 int j; +#line 1004 int k; +#line 1004 int m; +#line 1004 int err; +#line 1004 int nels; +#line 1004 int nslabs; +#line 1004 int nstarts; /* number of different starts */ +#line 1004 size_t start[MAX_RANK]; +#line 1004 size_t edge[MAX_RANK]; +#line 1004 size_t index[MAX_RANK]; +#line 1004 size_t index2[MAX_RANK]; +#line 1004 size_t mid[MAX_RANK]; +#line 1004 size_t count[MAX_RANK]; +#line 1004 size_t sstride[MAX_RANK]; +#line 1004 ptrdiff_t stride[MAX_RANK]; +#line 1004 ptrdiff_t imap[MAX_RANK]; +#line 1004 int canConvert; /* Both text or both numeric */ +#line 1004 int allInExtRange; /* all values within external range? */ +#line 1004 double value[MAX_NELS]; +#line 1004 +#line 1004 err = nc_create(scratch, NC_CLOBBER, &ncid); +#line 1004 IF (err) { +#line 1004 error("nc_create: %s", nc_strerror(err)); +#line 1004 return; +#line 1004 } +#line 1004 def_dims(ncid); +#line 1004 def_vars(ncid); +#line 1004 err = nc_enddef(ncid); +#line 1004 IF (err) +#line 1004 error("nc_enddef: %s", nc_strerror(err)); +#line 1004 +#line 1004 for (i = 0; i < NVARS; i++) { +#line 1004 canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT); +#line 1004 assert(var_rank[i] <= MAX_RANK); +#line 1004 assert(var_nels[i] <= MAX_NELS); +#line 1004 for (j = 0; j < var_rank[i]; j++) { +#line 1004 start[j] = 0; +#line 1004 edge[j] = 1; +#line 1004 stride[j] = 1; +#line 1004 imap[j] = 1; +#line 1004 } +#line 1004 err = nc_put_varm_double(BAD_ID, i, start, edge, stride, imap, value); +#line 1004 IF (err != NC_EBADID) +#line 1004 error("bad ncid: status = %d", err); +#line 1004 err = nc_put_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value); +#line 1004 IF (err != NC_ENOTVAR) +#line 1004 error("bad var id: status = %d", err); +#line 1004 for (j = 0; j < var_rank[i]; j++) { +#line 1004 if (var_dimid[i][j] > 0) { /* skip record dim */ +#line 1004 start[j] = var_shape[i][j] + 1; +#line 1004 err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value); +#line 1004 if (!canConvert) { +#line 1004 IF(err != NC_ECHAR) +#line 1004 error("conversion: status = %d", err); +#line 1004 } else { +#line 1004 IF (err != NC_EINVALCOORDS) +#line 1004 error("bad start: status = %d", err); +#line 1004 start[j] = 0; +#line 1004 edge[j] = var_shape[i][j] + 1; +#line 1004 err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value); +#line 1004 IF (err != NC_EEDGE) +#line 1004 error("bad edge: status = %d", err); +#line 1004 edge[j] = 1; +#line 1004 stride[j] = 0; +#line 1004 err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value); +#line 1004 IF (err != NC_ESTRIDE) +#line 1004 error("bad stride: status = %d", err); +#line 1004 stride[j] = 1; +#line 1004 } +#line 1004 } +#line 1004 } +#line 1004 /* Choose a random point dividing each dim into 2 parts */ +#line 1004 /* Put 2^rank (nslabs) slabs so defined */ +#line 1004 nslabs = 1; +#line 1004 for (j = 0; j < var_rank[i]; j++) { +#line 1004 mid[j] = roll( var_shape[i][j] ); +#line 1004 nslabs *= 2; +#line 1004 } +#line 1004 /* bits of k determine whether to put lower or upper part of dim */ +#line 1004 /* choose random stride from 1 to edge */ +#line 1004 for (k = 0; k < nslabs; k++) { +#line 1004 nstarts = 1; +#line 1004 for (j = 0; j < var_rank[i]; j++) { +#line 1004 if ((k >> j) & 1) { +#line 1004 start[j] = 0; +#line 1004 edge[j] = mid[j]; +#line 1004 }else{ +#line 1004 start[j] = mid[j]; +#line 1004 edge[j] = var_shape[i][j] - mid[j]; +#line 1004 } +#line 1004 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1; +#line 1004 nstarts *= stride[j]; +#line 1004 } +#line 1004 for (m = 0; m < nstarts; m++) { +#line 1004 err = toMixedBase(m, var_rank[i], sstride, index); +#line 1004 IF (err) +#line 1004 error("error in toMixedBase"); +#line 1004 nels = 1; +#line 1004 for (j = 0; j < var_rank[i]; j++) { +#line 1004 count[j] = 1 + (edge[j] - index[j] - 1) / stride[j]; +#line 1004 nels *= count[j]; +#line 1004 index[j] += start[j]; +#line 1004 } +#line 1004 /* Random choice of forward or backward */ +#line 1004 /* TODO +#line 1004 if ( roll(2) ) { +#line 1004 for (j = 0; j < var_rank[i]; j++) { +#line 1004 index[j] += (count[j] - 1) * stride[j]; +#line 1004 stride[j] = -stride[j]; +#line 1004 } +#line 1004 } +#line 1004 */ +#line 1004 if (var_rank[i] > 0) { +#line 1004 j = var_rank[i] - 1; +#line 1004 imap[j] = 1; +#line 1004 for (; j > 0; j--) +#line 1004 imap[j-1] = imap[j] * count[j]; +#line 1004 } +#line 1004 for (allInExtRange = 1, j = 0; j < nels; j++) { +#line 1004 err = toMixedBase(j, var_rank[i], count, index2); +#line 1004 IF (err) +#line 1004 error("error in toMixedBase"); +#line 1004 for (d = 0; d < var_rank[i]; d++) +#line 1004 index2[d] = index[d] + index2[d] * stride[d]; +#line 1004 value[j] = hash_double(var_type[i], var_rank[i], index2, +#line 1004 NCT_DOUBLE); +#line 1004 allInExtRange = allInExtRange +#line 1004 && inRange3(value[j], var_type[i], NCT_DOUBLE); +#line 1004 } +#line 1004 if (var_rank[i] == 0 && i%2 == 0) +#line 1004 err = nc_put_varm_double(ncid,i,NULL,NULL,NULL,NULL,value); +#line 1004 else +#line 1004 err = nc_put_varm_double(ncid,i,index,count,stride,imap,value); +#line 1004 if (canConvert) { +#line 1004 if (allInExtRange) { +#line 1004 IF (err) +#line 1004 error("%s", nc_strerror(err)); +#line 1004 } else { +#line 1004 IF (err != NC_ERANGE) +#line 1004 error("range error: status = %d", err); +#line 1004 } +#line 1004 } else { +#line 1004 IF (nels > 0 && err != NC_ECHAR) +#line 1004 error("wrong type: status = %d", err); +#line 1004 } +#line 1004 } +#line 1004 } +#line 1004 } +#line 1004 +#line 1004 err = nc_close(ncid); +#line 1004 IF (err) +#line 1004 error("nc_close: %s", nc_strerror(err)); +#line 1004 +#line 1004 check_vars_double(scratch); +#line 1004 +#line 1004 err = remove(scratch); +#line 1004 IF (err) +#line 1004 error("remove of %s failed", scratch); +#line 1004 } +#line 1004 @@ -6917,446 +13688,881 @@ test_nc_put_att_text(void) } +#line 1135 void +#line 1136 test_nc_put_att_uchar(void) +#line 1136 { +#line 1136 int ncid; +#line 1136 int i; +#line 1136 int j; +#line 1136 size_t k; +#line 1136 int err; +#line 1136 uchar value[MAX_NELS]; +#line 1136 int allInExtRange; /* all values within external range? */ +#line 1136 +#line 1136 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1136 IF (err) { +#line 1136 error("nc_create: %s", nc_strerror(err)); +#line 1136 return; +#line 1136 } +#line 1136 def_dims(ncid); +#line 1136 def_vars(ncid); +#line 1136 +#line 1136 for (i = -1; i < NVARS; i++) { +#line 1136 for (j = 0; j < NATTS(i); j++) { +#line 1136 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1136 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1136 err = nc_put_att_uchar(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1136 ATT_LEN(i,j), value); +#line 1136 IF (err != NC_EBADID) +#line 1136 error("bad ncid: status = %d", err); +#line 1136 err = nc_put_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1136 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1136 IF (err != NC_ENOTVAR) +#line 1136 error("bad var id: status = %d", err); +#line 1136 err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1136 ATT_LEN(i,j), value); +#line 1136 IF (err != NC_EBADTYPE) +#line 1136 error("bad type: status = %d", err); +#line 1136 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1136 value[k] = hash_uchar(ATT_TYPE(i,j), -1, &k, NCT_UCHAR); +#line 1136 allInExtRange = allInExtRange +#line 1136 && inRange3(value[k], ATT_TYPE(i,j), NCT_UCHAR); +#line 1136 } +#line 1136 err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1136 ATT_LEN(i,j), value); +#line 1136 if (allInExtRange) { +#line 1136 IF (err) +#line 1136 error("%s", nc_strerror(err)); +#line 1136 } else { +#line 1136 IF (err != NC_ERANGE) +#line 1136 error("range error: status = %d", err); +#line 1136 } +#line 1136 } +#line 1136 } +#line 1136 } +#line 1136 +#line 1136 check_atts_uchar(ncid); +#line 1136 err = nc_close(ncid); +#line 1136 IF (err) +#line 1136 error("nc_close: %s", nc_strerror(err)); +#line 1136 +#line 1136 err = remove(scratch); +#line 1136 IF (err) +#line 1136 error("remove of %s failed", scratch); +#line 1136 } +#line 1136 void +#line 1137 test_nc_put_att_schar(void) +#line 1137 { +#line 1137 int ncid; +#line 1137 int i; +#line 1137 int j; +#line 1137 size_t k; +#line 1137 int err; +#line 1137 schar value[MAX_NELS]; +#line 1137 int allInExtRange; /* all values within external range? */ +#line 1137 +#line 1137 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1137 IF (err) { +#line 1137 error("nc_create: %s", nc_strerror(err)); +#line 1137 return; +#line 1137 } +#line 1137 def_dims(ncid); +#line 1137 def_vars(ncid); +#line 1137 +#line 1137 for (i = -1; i < NVARS; i++) { +#line 1137 for (j = 0; j < NATTS(i); j++) { +#line 1137 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1137 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1137 err = nc_put_att_schar(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1137 ATT_LEN(i,j), value); +#line 1137 IF (err != NC_EBADID) +#line 1137 error("bad ncid: status = %d", err); +#line 1137 err = nc_put_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1137 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1137 IF (err != NC_ENOTVAR) +#line 1137 error("bad var id: status = %d", err); +#line 1137 err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1137 ATT_LEN(i,j), value); +#line 1137 IF (err != NC_EBADTYPE) +#line 1137 error("bad type: status = %d", err); +#line 1137 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1137 value[k] = hash_schar(ATT_TYPE(i,j), -1, &k, NCT_SCHAR); +#line 1137 allInExtRange = allInExtRange +#line 1137 && inRange3(value[k], ATT_TYPE(i,j), NCT_SCHAR); +#line 1137 } +#line 1137 err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1137 ATT_LEN(i,j), value); +#line 1137 if (allInExtRange) { +#line 1137 IF (err) +#line 1137 error("%s", nc_strerror(err)); +#line 1137 } else { +#line 1137 IF (err != NC_ERANGE) +#line 1137 error("range error: status = %d", err); +#line 1137 } +#line 1137 } +#line 1137 } +#line 1137 } +#line 1137 +#line 1137 check_atts_schar(ncid); +#line 1137 err = nc_close(ncid); +#line 1137 IF (err) +#line 1137 error("nc_close: %s", nc_strerror(err)); +#line 1137 +#line 1137 err = remove(scratch); +#line 1137 IF (err) +#line 1137 error("remove of %s failed", scratch); +#line 1137 } +#line 1137 void +#line 1138 test_nc_put_att_short(void) +#line 1138 { +#line 1138 int ncid; +#line 1138 int i; +#line 1138 int j; +#line 1138 size_t k; +#line 1138 int err; +#line 1138 short value[MAX_NELS]; +#line 1138 int allInExtRange; /* all values within external range? */ +#line 1138 +#line 1138 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1138 IF (err) { +#line 1138 error("nc_create: %s", nc_strerror(err)); +#line 1138 return; +#line 1138 } +#line 1138 def_dims(ncid); +#line 1138 def_vars(ncid); +#line 1138 +#line 1138 for (i = -1; i < NVARS; i++) { +#line 1138 for (j = 0; j < NATTS(i); j++) { +#line 1138 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1138 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1138 err = nc_put_att_short(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1138 ATT_LEN(i,j), value); +#line 1138 IF (err != NC_EBADID) +#line 1138 error("bad ncid: status = %d", err); +#line 1138 err = nc_put_att_short(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1138 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1138 IF (err != NC_ENOTVAR) +#line 1138 error("bad var id: status = %d", err); +#line 1138 err = nc_put_att_short(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1138 ATT_LEN(i,j), value); +#line 1138 IF (err != NC_EBADTYPE) +#line 1138 error("bad type: status = %d", err); +#line 1138 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1138 value[k] = hash_short(ATT_TYPE(i,j), -1, &k, NCT_SHORT); +#line 1138 allInExtRange = allInExtRange +#line 1138 && inRange3(value[k], ATT_TYPE(i,j), NCT_SHORT); +#line 1138 } +#line 1138 err = nc_put_att_short(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1138 ATT_LEN(i,j), value); +#line 1138 if (allInExtRange) { +#line 1138 IF (err) +#line 1138 error("%s", nc_strerror(err)); +#line 1138 } else { +#line 1138 IF (err != NC_ERANGE) +#line 1138 error("range error: status = %d", err); +#line 1138 } +#line 1138 } +#line 1138 } +#line 1138 } +#line 1138 +#line 1138 check_atts_short(ncid); +#line 1138 err = nc_close(ncid); +#line 1138 IF (err) +#line 1138 error("nc_close: %s", nc_strerror(err)); +#line 1138 +#line 1138 err = remove(scratch); +#line 1138 IF (err) +#line 1138 error("remove of %s failed", scratch); +#line 1138 } +#line 1138 void +#line 1139 test_nc_put_att_int(void) +#line 1139 { +#line 1139 int ncid; +#line 1139 int i; +#line 1139 int j; +#line 1139 size_t k; +#line 1139 int err; +#line 1139 int value[MAX_NELS]; +#line 1139 int allInExtRange; /* all values within external range? */ +#line 1139 +#line 1139 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1139 IF (err) { +#line 1139 error("nc_create: %s", nc_strerror(err)); +#line 1139 return; +#line 1139 } +#line 1139 def_dims(ncid); +#line 1139 def_vars(ncid); +#line 1139 +#line 1139 for (i = -1; i < NVARS; i++) { +#line 1139 for (j = 0; j < NATTS(i); j++) { +#line 1139 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1139 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1139 err = nc_put_att_int(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1139 ATT_LEN(i,j), value); +#line 1139 IF (err != NC_EBADID) +#line 1139 error("bad ncid: status = %d", err); +#line 1139 err = nc_put_att_int(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1139 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1139 IF (err != NC_ENOTVAR) +#line 1139 error("bad var id: status = %d", err); +#line 1139 err = nc_put_att_int(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1139 ATT_LEN(i,j), value); +#line 1139 IF (err != NC_EBADTYPE) +#line 1139 error("bad type: status = %d", err); +#line 1139 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1139 value[k] = hash_int(ATT_TYPE(i,j), -1, &k, NCT_INT); +#line 1139 allInExtRange = allInExtRange +#line 1139 && inRange3(value[k], ATT_TYPE(i,j), NCT_INT); +#line 1139 } +#line 1139 err = nc_put_att_int(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1139 ATT_LEN(i,j), value); +#line 1139 if (allInExtRange) { +#line 1139 IF (err) +#line 1139 error("%s", nc_strerror(err)); +#line 1139 } else { +#line 1139 IF (err != NC_ERANGE) +#line 1139 error("range error: status = %d", err); +#line 1139 } +#line 1139 } +#line 1139 } +#line 1139 } +#line 1139 +#line 1139 check_atts_int(ncid); +#line 1139 err = nc_close(ncid); +#line 1139 IF (err) +#line 1139 error("nc_close: %s", nc_strerror(err)); +#line 1139 +#line 1139 err = remove(scratch); +#line 1139 IF (err) +#line 1139 error("remove of %s failed", scratch); +#line 1139 } +#line 1139 void +#line 1140 test_nc_put_att_long(void) +#line 1140 { +#line 1140 int ncid; +#line 1140 int i; +#line 1140 int j; +#line 1140 size_t k; +#line 1140 int err; +#line 1140 long value[MAX_NELS]; +#line 1140 int allInExtRange; /* all values within external range? */ +#line 1140 +#line 1140 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1140 IF (err) { +#line 1140 error("nc_create: %s", nc_strerror(err)); +#line 1140 return; +#line 1140 } +#line 1140 def_dims(ncid); +#line 1140 def_vars(ncid); +#line 1140 +#line 1140 for (i = -1; i < NVARS; i++) { +#line 1140 for (j = 0; j < NATTS(i); j++) { +#line 1140 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1140 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1140 err = nc_put_att_long(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1140 ATT_LEN(i,j), value); +#line 1140 IF (err != NC_EBADID) +#line 1140 error("bad ncid: status = %d", err); +#line 1140 err = nc_put_att_long(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1140 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1140 IF (err != NC_ENOTVAR) +#line 1140 error("bad var id: status = %d", err); +#line 1140 err = nc_put_att_long(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1140 ATT_LEN(i,j), value); +#line 1140 IF (err != NC_EBADTYPE) +#line 1140 error("bad type: status = %d", err); +#line 1140 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1140 value[k] = hash_long(ATT_TYPE(i,j), -1, &k, NCT_LONG); +#line 1140 allInExtRange = allInExtRange +#line 1140 && inRange3(value[k], ATT_TYPE(i,j), NCT_LONG); +#line 1140 } +#line 1140 err = nc_put_att_long(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1140 ATT_LEN(i,j), value); +#line 1140 if (allInExtRange) { +#line 1140 IF (err) +#line 1140 error("%s", nc_strerror(err)); +#line 1140 } else { +#line 1140 IF (err != NC_ERANGE) +#line 1140 error("range error: status = %d", err); +#line 1140 } +#line 1140 } +#line 1140 } +#line 1140 } +#line 1140 +#line 1140 check_atts_long(ncid); +#line 1140 err = nc_close(ncid); +#line 1140 IF (err) +#line 1140 error("nc_close: %s", nc_strerror(err)); +#line 1140 +#line 1140 err = remove(scratch); +#line 1140 IF (err) +#line 1140 error("remove of %s failed", scratch); +#line 1140 } +#line 1140 void +#line 1141 test_nc_put_att_float(void) +#line 1141 { +#line 1141 int ncid; +#line 1141 int i; +#line 1141 int j; +#line 1141 size_t k; +#line 1141 int err; +#line 1141 float value[MAX_NELS]; +#line 1141 int allInExtRange; /* all values within external range? */ +#line 1141 +#line 1141 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1141 IF (err) { +#line 1141 error("nc_create: %s", nc_strerror(err)); +#line 1141 return; +#line 1141 } +#line 1141 def_dims(ncid); +#line 1141 def_vars(ncid); +#line 1141 +#line 1141 for (i = -1; i < NVARS; i++) { +#line 1141 for (j = 0; j < NATTS(i); j++) { +#line 1141 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1141 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1141 err = nc_put_att_float(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1141 ATT_LEN(i,j), value); +#line 1141 IF (err != NC_EBADID) +#line 1141 error("bad ncid: status = %d", err); +#line 1141 err = nc_put_att_float(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1141 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1141 IF (err != NC_ENOTVAR) +#line 1141 error("bad var id: status = %d", err); +#line 1141 err = nc_put_att_float(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1141 ATT_LEN(i,j), value); +#line 1141 IF (err != NC_EBADTYPE) +#line 1141 error("bad type: status = %d", err); +#line 1141 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1141 value[k] = hash_float(ATT_TYPE(i,j), -1, &k, NCT_FLOAT); +#line 1141 allInExtRange = allInExtRange +#line 1141 && inRange3(value[k], ATT_TYPE(i,j), NCT_FLOAT); +#line 1141 } +#line 1141 err = nc_put_att_float(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1141 ATT_LEN(i,j), value); +#line 1141 if (allInExtRange) { +#line 1141 IF (err) +#line 1141 error("%s", nc_strerror(err)); +#line 1141 } else { +#line 1141 IF (err != NC_ERANGE) +#line 1141 error("range error: status = %d", err); +#line 1141 } +#line 1141 } +#line 1141 } +#line 1141 } +#line 1141 +#line 1141 check_atts_float(ncid); +#line 1141 err = nc_close(ncid); +#line 1141 IF (err) +#line 1141 error("nc_close: %s", nc_strerror(err)); +#line 1141 +#line 1141 err = remove(scratch); +#line 1141 IF (err) +#line 1141 error("remove of %s failed", scratch); +#line 1141 } +#line 1141 void +#line 1142 test_nc_put_att_double(void) +#line 1142 { +#line 1142 int ncid; +#line 1142 int i; +#line 1142 int j; +#line 1142 size_t k; +#line 1142 int err; +#line 1142 double value[MAX_NELS]; +#line 1142 int allInExtRange; /* all values within external range? */ +#line 1142 +#line 1142 err = nc_create(scratch, NC_NOCLOBBER, &ncid); +#line 1142 IF (err) { +#line 1142 error("nc_create: %s", nc_strerror(err)); +#line 1142 return; +#line 1142 } +#line 1142 def_dims(ncid); +#line 1142 def_vars(ncid); +#line 1142 +#line 1142 for (i = -1; i < NVARS; i++) { +#line 1142 for (j = 0; j < NATTS(i); j++) { +#line 1142 if (!(ATT_TYPE(i,j) == NC_CHAR)) { +#line 1142 assert(ATT_LEN(i,j) <= MAX_NELS); +#line 1142 err = nc_put_att_double(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1142 ATT_LEN(i,j), value); +#line 1142 IF (err != NC_EBADID) +#line 1142 error("bad ncid: status = %d", err); +#line 1142 err = nc_put_att_double(ncid, BAD_VARID, ATT_NAME(i,j), +#line 1142 ATT_TYPE(i,j), ATT_LEN(i,j), value); +#line 1142 IF (err != NC_ENOTVAR) +#line 1142 error("bad var id: status = %d", err); +#line 1142 err = nc_put_att_double(ncid, i, ATT_NAME(i,j), BAD_TYPE, +#line 1142 ATT_LEN(i,j), value); +#line 1142 IF (err != NC_EBADTYPE) +#line 1142 error("bad type: status = %d", err); +#line 1142 for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) { +#line 1142 value[k] = hash_double(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE); +#line 1142 allInExtRange = allInExtRange +#line 1142 && inRange3(value[k], ATT_TYPE(i,j), NCT_DOUBLE); +#line 1142 } +#line 1142 err = nc_put_att_double(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), +#line 1142 ATT_LEN(i,j), value); +#line 1142 if (allInExtRange) { +#line 1142 IF (err) +#line 1142 error("%s", nc_strerror(err)); +#line 1142 } else { +#line 1142 IF (err != NC_ERANGE) +#line 1142 error("range error: status = %d", err); +#line 1142 } +#line 1142 } +#line 1142 } +#line 1142 } +#line 1142 +#line 1142 check_atts_double(ncid); +#line 1142 err = nc_close(ncid); +#line 1142 IF (err) +#line 1142 error("nc_close: %s", nc_strerror(err)); +#line 1142 +#line 1142 err = remove(scratch); +#line 1142 IF (err) +#line 1142 error("remove of %s failed", scratch); +#line 1142 } +#line 1142