[netcdf] 01/08: New upstream version 4.5.0~rc3
Bas Couwenberg
sebastic at debian.org
Sat Sep 30 08:43:55 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository netcdf.
commit a1dc2b99cfe260d4784ef25374de58afde91e5ad
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Sat Sep 30 10:08:45 2017 +0200
New upstream version 4.5.0~rc3
---
CMakeLists.txt | 32 +-
Makefile.in | 5 +-
RELEASE_NOTES.md | 10 +
config.h.cmake.in | 11 +-
config.h.in | 9 +
configure | 157 +-
configure.ac | 36 +-
dap4_test/Makefile.am | 4 +-
dap4_test/Makefile.in | 9 +-
docs/.gitignore | 2 -
docs/Doxyfile.developer | 2 +-
docs/Doxyfile.in | 2 +-
docs/Makefile.am | 14 +-
docs/Makefile.in | 19 +-
docs/OPeNDAP.dox | 2 +-
docs/attribute_conventions.md | 8 +-
docs/auth.html | 4 +
docs/auth.md | 491 +
docs/guide.dox | 158 +-
docs/images/Makefile.in | 5 +-
docs/static-pages/software.html | 10 +
docs/types.dox | 5 +-
docs/windows-binaries.md | 26 +-
examples/C/Makefile.in | 5 +-
examples/CDL/Makefile.in | 5 +-
examples/Makefile.in | 5 +-
h5_test/Makefile.in | 5 +-
include/Makefile.in | 5 +-
include/nctestserver.h | 4 +
include/ncuri.h | 18 +-
include/netcdf_meta.h.in | 6 +-
libdap2/Makefile.in | 5 +-
libdap4/Makefile.in | 5 +-
libdap4/d4curlflags.c | 2 +
libdap4/d4curlfunctions.c | 16 +-
libdap4/d4curlfunctions.h | 9 +-
libdap4/d4file.c | 23 +-
libdap4/d4http.c | 6 +-
libdap4/d4parser.c | 66 +-
libdap4/d4rc.c | 149 +-
libdap4/d4util.c | 19 +-
libdap4/ncd4.h | 1 -
libdap4/ncd4types.h | 6 +-
libdispatch/Makefile.in | 5 +-
libdispatch/dfile.c | 12 +-
libdispatch/drc.c | 8 +-
libdispatch/nchashmap.c | 21 +-
libdispatch/ncuri.c | 102 +-
liblib/Makefile.in | 5 +-
libnetcdf.settings.in | 1 +
libsrc/Makefile.in | 5 +-
libsrc/nc3internal.c | 17 +-
libsrc/ncx.c | 37157 ++++++++++++++++--------------
libsrc/ncx.m4 | 114 +-
libsrc/putget.c | 7066 +++---
libsrc/putget.m4 | 8 +-
libsrc/v1hpg.c | 3 +-
libsrc4/Makefile.in | 5 +-
libsrc4/nc4internal.c | 7 +-
libsrcp/Makefile.in | 5 +-
nc-config.cmake.in | 46 +-
nc-config.in | 12 +-
nc_test/CMakeLists.txt | 2 +-
nc_test/Makefile.am | 5 +-
nc_test/Makefile.in | 46 +-
nc_test/nc_test.c | 9 +-
nc_test/t_nc.c | 46 +-
nc_test/test_get.c | 12203 ++++++++++
nc_test/test_put.c | 13742 +++++++++++
nc_test/test_read.c | 1950 ++
nc_test/{test_write.m4 => test_write.c} | 1425 +-
nc_test/test_write.m4 | 12 +-
nc_test/tst_formatx_pnetcdf.c | 5 +-
nc_test/tst_large_cdf5.c | 201 +
nc_test/tst_small.c | 12 +-
nc_test4/Makefile.in | 5 +-
ncdap_test/Makefile.am | 6 +-
ncdap_test/Makefile.in | 26 +-
ncdap_test/expected3/Makefile.in | 5 +-
ncdap_test/expectremote3/Makefile.in | 5 +-
ncdap_test/testbasicauth.sh | 293 +
ncdap_test/testcontainerauth.sh | 69 +
ncdap_test/testdata3/Makefile.in | 5 +-
ncdump/CMakeLists.txt | 1 +
ncdump/Makefile.am | 21 +-
ncdump/Makefile.in | 77 +-
ncdump/cdl/Makefile.in | 5 +-
ncdump/expected/Makefile.in | 5 +-
ncdump/nccopy.c | 163 +-
ncdump/ref_inttags4.cdl | 4 +-
ncdump/ref_nccopy3_subset.nc | Bin 0 -> 65284 bytes
ncdump/run_ncgen_tests.sh | 27 +-
ncdump/run_tests.sh | 20 +-
ncdump/tst_64bit.sh | 55 +-
ncdump/tst_dimsizes.c | 6 +
ncdump/tst_formatx3.sh | 36 +-
ncdump/tst_inttags4.sh | 4 +-
ncdump/tst_lengths.sh | 117 +-
ncdump/tst_nccopy3.sh | 21 +-
ncdump/tst_nccopy3_subset.sh | 41 +
ncgen/Makefile.in | 5 +-
ncgen/main.c | 23 +-
ncgen/ncgen.y | 14 +-
ncgen/ncgenl.c | 8 +-
ncgen/ncgeny.c | 258 +-
ncgen/ncgeny.h | 2 +-
ncgen3/Makefile.in | 5 +-
nctest/Makefile.in | 5 +-
oc2/Makefile.in | 5 +-
oc2/daplex.c | 13 +-
oc2/occurlflags.c | 204 +-
oc2/occurlfunctions.c | 31 +-
oc2/occurlfunctions.h | 10 +-
oc2/ochttp.c | 4 -
oc2/ocinternal.c | 7 +-
oc2/ocinternal.h | 6 +-
oc2/ocrc.c | 104 +-
117 files changed, 54823 insertions(+), 22536 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16faacb..403ae59 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ set(PACKAGE "netCDF" CACHE STRING "")
SET(NC_VERSION_MAJOR 4)
SET(NC_VERSION_MINOR 5)
SET(NC_VERSION_PATCH 0)
-SET(NC_VERSION_NOTE "-rc2")
+SET(NC_VERSION_NOTE "-rc3")
SET(netCDF_VERSION ${NC_VERSION_MAJOR}.${NC_VERSION_MINOR}.${NC_VERSION_PATCH}${NC_VERSION_NOTE})
SET(VERSION ${netCDF_VERSION})
SET(NC_VERSION ${netCDF_VERSION})
@@ -757,16 +757,25 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF(USE_HDF5 OR ENABLE_NETCDF_4)
+# Option to turn on CDF5 support.
+OPTION(ENABLE_CDF5 "Enable CDF5 Support." OFF)
+IF(ENABLE_CDF5)
+ SET(USE_CDF5 ON CACHE BOOL "")
+ENDIF(ENABLE_CDF5)
# Option to Build DAP2+DAP4 Clients
OPTION(ENABLE_DAP "Enable DAP2 and DAP4 Client." ON)
IF(ENABLE_DAP)
- SET(USE_DAP ON)
- SET(ENABLE_DAP2 ON)
- SET(ENABLE_DAP4 ON)
- IF(NOT ENABLE_NETCDF_4)
- SET(ENABLE_DAP4 OFF)
- ENDIF()
+ SET(USE_DAP ON CACHE BOOL "")
+ SET(ENABLE_DAP2 ON CACHE BOOL "")
+
+
+ IF(ENABLE_NETCDF_4)
+ SET(ENABLE_DAP4 ON CACHE BOOL "")
+ ELSE(ENABLE_NETCDF_4)
+ SET(ENABLE_DAP4 OFF CACHE BOOL "")
+ ENDIF(ENABLE_NETCDF_4)
+
FIND_PACKAGE(CURL)
IF(NOT CURL_LIBRARY)
MESSAGE(FATAL_ERROR "DAP Support specified, CURL libraries are not found.")
@@ -805,6 +814,12 @@ IF(ENABLE_DAP)
#include <curl/curl.h>
int main() {int x = CURLOPT_CHUNK_BGN_FUNCTION;}" HAVE_CURLOPT_CHUNK_BGN_FUNCTION)
+ # Check to see if CURLINFO_HTTP_CONNECTCODE is defined.
+ # It showed up in curl 7.10.7.
+ CHECK_C_SOURCE_COMPILES("
+ #include <curl/curl.h>
+ int main() {int x = CURLINFO_HTTP_CONNECTCODE;}" HAVE_CURLINFO_HTTP_CONNECTCODE)
+
ELSE()
SET(ENABLE_DAP2 OFF)
SET(ENABLE_DAP4 OFF)
@@ -1027,6 +1042,7 @@ SET(STATUS_ERANGE_FILL "OFF")
OPTION(ENABLE_ERANGE_FILL "Enable use of fill value when out-of-range type conversion causes NC_ERANGE error." OF)
IF(ENABLE_ERANGE_FILL)
SET(STATUS_ERANGE_FILL "ON")
+ ADD_DEFINITIONS(-DERANGE_FILL)
ENDIF()
# Options to use a more relaxed coordinate argument boundary check
@@ -1885,11 +1901,13 @@ is_enabled(STATUS_PNETCDF HAS_PNETCDF)
is_enabled(STATUS_PARALLEL HAS_PARALLEL)
is_enabled(ENABLE_PARALLEL4 HAS_PARALLEL4)
is_enabled(ENABLE_DAP HAS_DAP)
+is_enabled(ENABLE_DAP HAS_DAP2)
is_enabled(ENABLE_DAP4 HAS_DAP4)
is_enabled(USE_DISKLESS HAS_DISKLESS)
is_enabled(USE_MMAP HAS_MMAP)
is_enabled(JNA HAS_JNA)
is_enabled(STATUS_RELAX_COORD_BOUND RELAX_COORD_BOUND)
+is_enabled(USE_CDF5 HAS_CDF5)
# Generate file from template.
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"
diff --git a/Makefile.in b/Makefile.in
index 8d1f09e..4b5a6ad 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -302,7 +302,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -337,7 +339,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 57c0ca3..c3c85d4 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -7,6 +7,16 @@ This file contains a high-level description of this package's evolution. Release
## 4.5.0 - TBD
+### 4.5.0-rc3 - September 29, 2017
+
+* [Update] Due to ongoing issues, native CDF5 support has been disabled by **default**. You can use the options mentioned below (`--enable-cdf5` or `-DENABLE_CDF5=TRUE` for `configure` or `cmake`, respectively). Just be aware that for the time being, Reading/Writing CDF5 files on 32-bit platforms may result in unexpected behavior when using extremely large variables. For 32-bit platforms it is best to continue using `NC_FORMAT_64BIT_OFFSET`.
+* [Bug] Corrected an issue where older versions of curl might fail. See [GitHub #487](https://github.com/Unidata/netcdf-c/issues/487) for more information.
+* [Enhancement] Added options to enable/disable `CDF5` support at configure time for autotools and cmake-based builds. The options are `--enable/disable-cdf5` and `ENABLE_CDF5`, respectively. See [Github #484](https://github.com/Unidata/netcdf-c/issues/484) for more information.
+* [Bug Fix] Corrected an issue when subsetting a netcdf3 file via `nccopy -v/-V`. See [Github #425](https://github.com/Unidata/netcdf-c/issues/425) and [Github #463](https://github.com/Unidata/netcdf-c/issues/463) for more information.
+* [Bug Fix] Corrected `--has-dap` and `--has-dap4` output for cmake-based builds. See [GitHub #473](https://github.com/Unidata/netcdf-c/pull/473) for more information.
+* [Bug Fix] Corrected an issue where `NC_64BIT_DATA` files were being read incorrectly by ncdump, despite the data having been written correctly. See [GitHub #457](https://github.com/Unidata/netcdf-c/issues/457) for more information.
+* [Bug Fix] Corrected a potential stack buffer overflow. See [GitHub #450](https://github.com/Unidata/netcdf-c/pull/450) for more information.
+
### 4.5.0-rc2 - August 7, 2017
* [Bug Fix] Addressed an issue with how cmake was implementing large file support on 32-bit systems. See [GitHub #385](https://github.com/Unidata/netcdf-c/issues/385) for more information.
diff --git a/config.h.cmake.in b/config.h.cmake.in
index df62631..1fffe0a 100644
--- a/config.h.cmake.in
+++ b/config.h.cmake.in
@@ -14,12 +14,12 @@
*/
-#cmakedefine HAVE_WINSOCK2_H
+/* #cmakedefine HAVE_WINSOCK2_H
#ifdef HAVE_WINSOCK2_H
#define _WINSOCKAPI_
#endif
-
+*/
#if _MSC_VER>=1900
#define STDC99
#endif
@@ -107,6 +107,10 @@ are set when opening a binary file on Windows. */
/* set this only when building a DLL under MinGW */
#cmakedefine DLL_NETCDF 1
+/* if true, enable CDF5 Support */
+#cmakedefine ENABLE_CDF5 1
+#cmakedefine USE_CDF5 1
+
/* if true, build DAP2 and DAP4 Client */
#cmakedefine ENABLE_DAP 1
@@ -147,6 +151,9 @@ are set when opening a binary file on Windows. */
/* Is CURLINFO_RESPONSE_CODE defined */
#cmakedefine HAVE_CURLINFO_RESPONSE_CODE 1
+/* Is CURLINFO_HTTP_CODE defined */
+#cmakedefine HAVE_CURLINFO_HTTP_CONNECTCODE 1
+
/* Is CURLOPT_CHUNK_BGN_FUNCTION defined */
#cmakedefine HAVE_CURLOPT_CHUNK_BGN_FUNCTION 1
diff --git a/config.h.in b/config.h.in
index f1a11ee..b5694f4 100644
--- a/config.h.in
+++ b/config.h.in
@@ -35,6 +35,9 @@
/* set this only when building a DLL under MinGW */
#undef DLL_NETCDF
+/* if true, enable CDF5 Support */
+#undef ENABLE_CDF5
+
/* if true, build DAP Client */
#undef ENABLE_DAP
@@ -47,6 +50,9 @@
/* if true, do remote tests */
#undef ENABLE_DAP_REMOTE_TESTS
+/* if true, use _FillValue for NC_ERANGE data elements */
+#undef ERANGE_FILL
+
/* if true, run extra tests which may not work yet */
#undef EXTRA_TESTS
@@ -491,6 +497,9 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
+/* if true, enable CDF5 Support */
+#undef USE_CDF5
+
/* if true, build DAP Client */
#undef USE_DAP
diff --git a/configure b/configure
index 24f3cb9..ed6b2b7 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac Id: configure.ac,v 1.450 2010/05/28 19:42:47 dmh Exp .
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for netCDF 4.5.0-rc2.
+# Generated by GNU Autoconf 2.69 for netCDF 4.5.0-rc3.
#
# Report bugs to <support-netcdf at unidata.ucar.edu>.
#
@@ -591,8 +591,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='netCDF'
PACKAGE_TARNAME='netcdf'
-PACKAGE_VERSION='4.5.0-rc2'
-PACKAGE_STRING='netCDF 4.5.0-rc2'
+PACKAGE_VERSION='4.5.0-rc3'
+PACKAGE_STRING='netCDF 4.5.0-rc3'
PACKAGE_BUGREPORT='support-netcdf at unidata.ucar.edu'
PACKAGE_URL=''
@@ -638,6 +638,7 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
+NC_HAS_CDF5
NC_HAS_PARALLEL4
NC_HAS_PARALLEL
NC_HAS_PNETCDF
@@ -645,7 +646,7 @@ NC_HAS_JNA
NC_HAS_MMAP
NC_HAS_DISKLESS
NC_HAS_DAP4
-NC_HAS_DAP
+NC_HAS_DAP2
NC_HAS_SZIP
NC_HAS_HDF5
NC_HAS_HDF4
@@ -669,9 +670,11 @@ HAS_LOGGING
HAS_HDF5
HAS_PNETCDF
HAS_HDF4
+HAS_CDF5
HAS_NC4
HAS_NC2
HAS_DAP4
+HAS_DAP2
HAS_DAP
NC_LIBS
BINFILE_NAME
@@ -774,6 +777,10 @@ USE_FFIO_FALSE
USE_FFIO_TRUE
EXTRA_TESTS_FALSE
EXTRA_TESTS_TRUE
+ENABLE_CDF5_FALSE
+ENABLE_CDF5_TRUE
+USE_CDF5_FALSE
+USE_CDF5_TRUE
INTERNAL_OCLIB_FALSE
INTERNAL_OCLIB_TRUE
am__fastdepCC_FALSE
@@ -932,6 +939,7 @@ enable_dap_auth_tests
enable_dap_groups
with_testservers
enable_dap_long_tests
+enable_cdf5
enable_extra_tests
enable_ffio
enable_stdio
@@ -1509,7 +1517,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures netCDF 4.5.0-rc2 to adapt to many kinds of systems.
+\`configure' configures netCDF 4.5.0-rc3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1580,7 +1588,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of netCDF 4.5.0-rc2:";;
+ short | recursive ) echo "Configuration of netCDF 4.5.0-rc3:";;
esac
cat <<\_ACEOF
@@ -1645,6 +1653,7 @@ Optional Features:
--enable-dap-auth-tests enable dap remote authorization tests
--disable-dap-groups disable [netcdf4] DAP2 group names
--enable-dap-long-tests enable dap long tests
+ --enable-cdf5 build with CDF5 support.
--enable-extra-tests enable some extra tests that may not pass because of
known issues
--enable-ffio use ffio instead of posixio (ex. on the Cray)
@@ -1807,7 +1816,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-netCDF configure 4.5.0-rc2
+netCDF configure 4.5.0-rc3
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2516,7 +2525,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by netCDF $as_me 4.5.0-rc2, which was
+It was created by netCDF $as_me 4.5.0-rc3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2878,7 +2887,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
NC_VERSION_MAJOR=4
NC_VERSION_MINOR=5
NC_VERSION_PATCH=0
- NC_VERSION_NOTE="-rc2"
+ NC_VERSION_NOTE="-rc3"
#####
# Set some variables used to generate a libnetcdf.settings file,
@@ -2887,11 +2896,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Create the VERSION file, which contains the package version from
# AC_INIT.
-echo 4.5.0-rc2>VERSION
+echo 4.5.0-rc3>VERSION
-{ $as_echo "$as_me:${as_lineno-$LINENO}: netCDF 4.5.0-rc2" >&5
-$as_echo "$as_me: netCDF 4.5.0-rc2" >&6;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: netCDF 4.5.0-rc3" >&5
+$as_echo "$as_me: netCDF 4.5.0-rc3" >&6;}
# Keep libtool macros in an m4 directory.
@@ -3556,7 +3565,7 @@ fi
# Define the identity of the package.
PACKAGE='netcdf'
- VERSION='4.5.0-rc2'
+ VERSION='4.5.0-rc3'
cat >>confdefs.h <<_ACEOF
@@ -5406,6 +5415,44 @@ else
fi
+# Check whether we want to enable CDF5 support.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether CDF5 support should be enabled (default off)" >&5
+$as_echo_n "checking whether CDF5 support should be enabled (default off)... " >&6; }
+# Check whether --enable-cdf5 was given.
+if test "${enable_cdf5+set}" = set; then :
+ enableval=$enable_cdf5;
+fi
+
+test "x$enable_cdf5" = xyes || enable_cdf5=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_cdf5" >&5
+$as_echo "$enable_cdf5" >&6; }
+
+if test "x$enable_cdf5" = xyes; then
+
+$as_echo "#define USE_CDF5 1" >>confdefs.h
+
+
+$as_echo "#define ENABLE_CDF5 1" >>confdefs.h
+
+fi
+
+ if test x$enable_cdf5 = xyes ; then
+ USE_CDF5_TRUE=
+ USE_CDF5_FALSE='#'
+else
+ USE_CDF5_TRUE='#'
+ USE_CDF5_FALSE=
+fi
+
+ if test x$enable_cdf5 = xyes ; then
+ ENABLE_CDF5_TRUE=
+ ENABLE_CDF5_FALSE='#'
+else
+ ENABLE_CDF5_TRUE='#'
+ ENABLE_CDF5_FALSE=
+fi
+
+
# Does the user want to do some extra tests?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether netCDF extra tests should be run (developers only)" >&5
$as_echo_n "checking whether netCDF extra tests should be run (developers only)... " >&6; }
@@ -16035,13 +16082,12 @@ test "x$enable_diskless" = xno || enable_diskless=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_diskless" >&5
$as_echo "$enable_diskless" >&6; }
-# Check for enable DAP
-if test "x$enable_dap" = "xyes" -a "xenable_diskless" = xno ; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: --enable-dap requires --enable-diskless" >&5
-$as_echo "$as_me: --enable-dap requires --enable-diskless" >&6;}
-{ $as_echo "$as_me:${as_lineno-$LINENO}: dap support disabled" >&5
-$as_echo "$as_me: dap support disabled" >&6;}
-enable_dap=no
+# If DAP enabled and diskless not enabled, then warn of consequences
+if test "x$enable_dap" = "xyes" -a "x$enable_diskless" = xno ; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: Warning: DAP support is enabled but diskless support is disabled." >&5
+$as_echo "$as_me: Warning: DAP support is enabled but diskless support is disabled." >&6;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: => temporary files will be created + reclaimed when using DAP." >&5
+$as_echo "$as_me: => temporary files will be created + reclaimed when using DAP." >&6;}
fi
# disable dap4 if netcdf-4 is disabled
@@ -18183,10 +18229,12 @@ $as_echo "#define USE_ZLIB 1" >>confdefs.h
fi
# The user may have built HDF5 with the SZLIB library.
+ enable_szlib=no
if test "x$ac_cv_func_H5Z_SZIP" = xyes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SZ_Compress" >&5
-$as_echo_n "checking for library containing SZ_Compress... " >&6; }
-if ${ac_cv_search_SZ_Compress+:} false; then :
+ enable_szlib=yes
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SZ_Compress" >&5
+$as_echo_n "checking for library containing SZ_Compress... " >&6; }
+if ${ac_cv_search__SZ_Compress+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
@@ -18199,11 +18247,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus
extern "C"
#endif
-char SZ_Compress ();
+char SZ_Compress ();
int
main ()
{
-return SZ_Compress ();
+return SZ_Compress ();
;
return 0;
}
@@ -18216,25 +18264,25 @@ for ac_lib in '' szip sz; do
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_SZ_Compress=$ac_res
+ ac_cv_search__SZ_Compress=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
- if ${ac_cv_search_SZ_Compress+:} false; then :
+ if ${ac_cv_search__SZ_Compress+:} false; then :
break
fi
done
-if ${ac_cv_search_SZ_Compress+:} false; then :
+if ${ac_cv_search__SZ_Compress+:} false; then :
else
- ac_cv_search_SZ_Compress=no
+ ac_cv_search__SZ_Compress=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SZ_Compress" >&5
-$as_echo "$ac_cv_search_SZ_Compress" >&6; }
-ac_res=$ac_cv_search_SZ_Compress
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__SZ_Compress" >&5
+$as_echo "$ac_cv_search__SZ_Compress" >&6; }
+ac_res=$ac_cv_search__SZ_Compress
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
@@ -18245,6 +18293,8 @@ $as_echo "#define USE_SZIP 1" >>confdefs.h
fi
+
+
if test "x$ac_cv_func_H5free_memory" = xyes; then
$as_echo "#define HDF5_HAS_H5FREE 1" >>confdefs.h
@@ -18722,6 +18772,9 @@ if test "x$enable_erange_fill" = xyes ; then
else
M4FLAGS="$M4FLAGS -DERANGE_FILL"
fi
+
+$as_echo "#define ERANGE_FILL 1" >>confdefs.h
+
fi
@@ -18826,6 +18879,13 @@ else
ENABLE_DAP4_FALSE=
fi
+ if test "x$enable_cdf5" = xyes; then
+ ENABLE_CDF5_TRUE=
+ ENABLE_CDF5_FALSE='#'
+else
+ ENABLE_CDF5_TRUE='#'
+ ENABLE_CDF5_FALSE=
+fi
if test "x$enable_dap_remote_tests" = xyes; then
ENABLE_DAP_REMOTE_TESTS_TRUE=
@@ -19260,12 +19320,16 @@ NC_LIBS=$NC_LIBS
HAS_DAP=$enable_dap
+HAS_DAP2=$enable_dap
+
HAS_DAP4=$enable_dap4
HAS_NC2=$nc_build_v2
HAS_NC4=$enable_netcdf_4
+HAS_CDF5=$enable_cdf5
+
HAS_HDF4=$enable_hdf4
HAS_PNETCDF=$enable_pnetcdf
@@ -19274,7 +19338,7 @@ HAS_HDF5=$enable_netcdf_4
HAS_LOGGING=$enable_logging
-HAS_SZLIB=$ac_cv_func_H4Z_SZIP
+HAS_SZLIB=$enable_szlib
HAS_PARALLEL=$enable_parallel
@@ -19366,9 +19430,9 @@ RELAX_COORD_BOUND=$enable_relax_coord_bound
if test "x$enable_dap" = xyes ; then
- NC_HAS_DAP=1
+ NC_HAS_DAP2=1
else
- NC_HAS_DAP=0
+ NC_HAS_DAP2=0
fi
@@ -19421,6 +19485,13 @@ RELAX_COORD_BOUND=$enable_relax_coord_bound
fi
+ if test "x$enable_cdf5" = xyes ; then
+ NC_HAS_CDF5=1
+ else
+ NC_HAS_CDF5=0
+ fi
+
+
# Automake says that this is always run in top_builddir
# and that srcdir is defined (== top_srcdir)
abs_top_builddir=`pwd`
@@ -19602,6 +19673,14 @@ if test -z "${INTERNAL_OCLIB_TRUE}" && test -z "${INTERNAL_OCLIB_FALSE}"; then
as_fn_error $? "conditional \"INTERNAL_OCLIB\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${USE_CDF5_TRUE}" && test -z "${USE_CDF5_FALSE}"; then
+ as_fn_error $? "conditional \"USE_CDF5\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${ENABLE_CDF5_TRUE}" && test -z "${ENABLE_CDF5_FALSE}"; then
+ as_fn_error $? "conditional \"ENABLE_CDF5\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${EXTRA_TESTS_TRUE}" && test -z "${EXTRA_TESTS_FALSE}"; then
as_fn_error $? "conditional \"EXTRA_TESTS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -19671,6 +19750,10 @@ if test -z "${ENABLE_DAP4_TRUE}" && test -z "${ENABLE_DAP4_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_DAP4\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${ENABLE_CDF5_TRUE}" && test -z "${ENABLE_CDF5_FALSE}"; then
+ as_fn_error $? "conditional \"ENABLE_CDF5\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${ENABLE_DAP_REMOTE_TESTS_TRUE}" && test -z "${ENABLE_DAP_REMOTE_TESTS_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_DAP_REMOTE_TESTS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -20148,7 +20231,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by netCDF $as_me 4.5.0-rc2, which was
+This file was extended by netCDF $as_me 4.5.0-rc3, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -20218,7 +20301,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-netCDF config.status 4.5.0-rc2
+netCDF config.status 4.5.0-rc3
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 8bfe223..8dde323 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@ AC_REVISION([$Id: configure.ac,v 1.450 2010/05/28 19:42:47 dmh Exp $])
AC_PREREQ([2.59])
# Initialize with name, version, and support email address.
-AC_INIT([netCDF], [4.5.0-rc2], [support-netcdf at unidata.ucar.edu])
+AC_INIT([netCDF], [4.5.0-rc3], [support-netcdf at unidata.ucar.edu])
##
# Prefer an empty CFLAGS variable instead of the default -g -O2.
@@ -27,7 +27,7 @@ AC_INIT([netCDF], [4.5.0-rc2], [support-netcdf at unidata.ucar.edu])
AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4
AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=5
AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=0
-AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-rc2"
+AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-rc3"
#####
# Set some variables used to generate a libnetcdf.settings file,
@@ -442,6 +442,22 @@ AC_MSG_RESULT([$enable_dap_long_tests])
AM_CONDITIONAL(INTERNAL_OCLIB,[test "x" = "x"])
+# Check whether we want to enable CDF5 support.
+AC_MSG_CHECKING([whether CDF5 support should be enabled (default off)])
+AC_ARG_ENABLE([cdf5],
+ [AS_HELP_STRING([--enable-cdf5],
+ [build with CDF5 support.])])
+test "x$enable_cdf5" = xyes || enable_cdf5=no
+AC_MSG_RESULT($enable_cdf5)
+
+if test "x$enable_cdf5" = xyes; then
+ AC_DEFINE([USE_CDF5], [1], [if true, enable CDF5 Support])
+ AC_DEFINE([ENABLE_CDF5], [1], [if true, enable CDF5 Support])
+fi
+
+AM_CONDITIONAL(USE_CDF5, [test x$enable_cdf5 = xyes ])
+AM_CONDITIONAL(ENABLE_CDF5, [test x$enable_cdf5 = xyes ])
+
# Does the user want to do some extra tests?
AC_MSG_CHECKING([whether netCDF extra tests should be run (developers only)])
AC_ARG_ENABLE([extra-tests],
@@ -1001,11 +1017,15 @@ if test "x$enable_netcdf_4" = xyes; then
fi
# The user may have built HDF5 with the SZLIB library.
+ enable_szlib=no
if test "x$ac_cv_func_H5Z_SZIP" = xyes; then
- AC_SEARCH_LIBS([SZ_Compress], [szip sz], [], [])
+ enable_szlib=yes
+ AC_SEARCH_LIBS([ SZ_Compress], [szip sz], [], [])
AC_DEFINE([USE_SZIP], [1], [if true, compile in szip compression in netCDF-4 variables])
fi
+
+
if test "x$ac_cv_func_H5free_memory" = xyes; then
AC_DEFINE([HDF5_HAS_H5FREE], [1], [if true, H5free_memory() will be used to free hdf5-allocated memory in nc4file.])
fi
@@ -1193,6 +1213,7 @@ if test "x$enable_erange_fill" = xyes ; then
else
M4FLAGS="$M4FLAGS -DERANGE_FILL"
fi
+ AC_DEFINE([ERANGE_FILL], [1], [if true, use _FillValue for NC_ERANGE data elements])
fi
AC_SUBST(M4FLAGS)
@@ -1249,7 +1270,7 @@ AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias
# Provide protocol specific flags
AM_CONDITIONAL(ENABLE_DAP, [test "x$enable_dap" = xyes])
AM_CONDITIONAL(ENABLE_DAP4, [test "x$enable_dap4" = xyes])
-
+AM_CONDITIONAL(ENABLE_CDF5, [test "x$enable_cdf5" = xyes])
AM_CONDITIONAL(ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes])
AM_CONDITIONAL(ENABLE_DAP_AUTH_TESTS, [test "x$enable_dap_auth_tests" = xyes])
AM_CONDITIONAL(ENABLE_DAP_LONG_TESTS, [test "x$enable_dap_long_tests" = xyes])
@@ -1359,14 +1380,16 @@ fi
AC_SUBST(NC_LIBS,[$NC_LIBS])
AC_SUBST(HAS_DAP,[$enable_dap])
+AC_SUBST(HAS_DAP2,[$enable_dap])
AC_SUBST(HAS_DAP4,[$enable_dap4])
AC_SUBST(HAS_NC2,[$nc_build_v2])
AC_SUBST(HAS_NC4,[$enable_netcdf_4])
+AC_SUBST(HAS_CDF5,[$enable_cdf5])
AC_SUBST(HAS_HDF4,[$enable_hdf4])
AC_SUBST(HAS_PNETCDF,[$enable_pnetcdf])
AC_SUBST(HAS_HDF5,[$enable_netcdf_4])
AC_SUBST(HAS_LOGGING, [$enable_logging])
-AC_SUBST(HAS_SZLIB,[$ac_cv_func_H4Z_SZIP])
+AC_SUBST(HAS_SZLIB,[$enable_szlib])
AC_SUBST(HAS_PARALLEL,[$enable_parallel])
AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
AC_SUBST(HAS_DISKLESS,[$enable_diskless])
@@ -1430,7 +1453,7 @@ AX_SET_META([NC_HAS_NC4],[$enable_netcdf_4],[yes])
AX_SET_META([NC_HAS_HDF4],[$enable_hdf4],[yes])
AX_SET_META([NC_HAS_HDF5],[$enable_netcdf_4],[yes])
AX_SET_META([NC_HAS_SZIP],[$ac_cv_func_H5Z_SZIP],[yes])
-AX_SET_META([NC_HAS_DAP],[$enable_dap],[yes])
+AX_SET_META([NC_HAS_DAP2],[$enable_dap],[yes])
AX_SET_META([NC_HAS_DAP4],[$enable_dap4],[yes])
AX_SET_META([NC_HAS_DISKLESS],[$enable_diskless],[yes])
AX_SET_META([NC_HAS_MMAP],[$enable_mmap],[yes])
@@ -1438,6 +1461,7 @@ AX_SET_META([NC_HAS_JNA],[$enable_jna],[yes])
AX_SET_META([NC_HAS_PNETCDF],[$enable_pnetcdf],[yes])
AX_SET_META([NC_HAS_PARALLEL],[$enable_parallel],[yes])
AX_SET_META([NC_HAS_PARALLEL4],[$enable_parallel4],[yes])
+AX_SET_META([NC_HAS_CDF5],[$enable_cdf5],[yes])
# Automake says that this is always run in top_builddir
# and that srcdir is defined (== top_srcdir)
diff --git a/dap4_test/Makefile.am b/dap4_test/Makefile.am
index be5ba4e..7534768 100644
--- a/dap4_test/Makefile.am
+++ b/dap4_test/Makefile.am
@@ -51,7 +51,7 @@ EXTRA_DIST = test_parse.sh test_meta.sh test_data.sh \
test_raw.sh test_remote.sh test_hyrax.sh \
d4test_common.sh \
daptestfiles dmrtestfiles cdltestfiles nctestfiles \
- baseline baselineraw baselineremote
+ baseline baselineraw baselineremote CMakeLists.txt
CLEANFILES = *.exe
@@ -68,8 +68,6 @@ clean-local: clean-local-check
clean-local-check:
-rm -rf results
-rm -f .dodsrc .daprc
- -rm -f tmp_*
- #-find . -name 'tmp_*' -exec rm {} \;
# The shell file maketests.sh is used to build the testdata
# for dap4 testing. It creates and fills the directories
diff --git a/dap4_test/Makefile.in b/dap4_test/Makefile.in
index a7a7c02..59f1782 100644
--- a/dap4_test/Makefile.in
+++ b/dap4_test/Makefile.in
@@ -469,7 +469,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -504,7 +506,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
@@ -622,7 +625,7 @@ EXTRA_DIST = test_parse.sh test_meta.sh test_data.sh \
test_raw.sh test_remote.sh test_hyrax.sh \
d4test_common.sh \
daptestfiles dmrtestfiles cdltestfiles nctestfiles \
- baseline baselineraw baselineremote
+ baseline baselineraw baselineremote CMakeLists.txt
CLEANFILES = *.exe
@@ -1141,8 +1144,6 @@ clean-local: clean-local-check
clean-local-check:
-rm -rf results
-rm -f .dodsrc .daprc
- -rm -f tmp_*
- #-find . -name 'tmp_*' -exec rm {} \;
# The shell file maketests.sh is used to build the testdata
# for dap4 testing. It creates and fills the directories
diff --git a/docs/.gitignore b/docs/.gitignore
index fb2e3bf..e69de29 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -1,2 +0,0 @@
-auth.md
-auth.html
diff --git a/docs/Doxyfile.developer b/docs/Doxyfile.developer
index 68e8b66..f531576 100644
--- a/docs/Doxyfile.developer
+++ b/docs/Doxyfile.developer
@@ -38,7 +38,7 @@ PROJECT_NAME = netCDF-C
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 4.5.0-rc2
+PROJECT_NUMBER = 4.5.0-rc3
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
index 3a0b762..e748900 100644
--- a/docs/Doxyfile.in
+++ b/docs/Doxyfile.in
@@ -759,7 +759,7 @@ INPUT = \
@abs_top_srcdir@/docs/file_format_specifications.md \
@abs_top_srcdir@/docs/tutorial.dox \
@abs_top_srcdir@/docs/notes.md \
- @abs_top_srcdir@/docs/esg.md \
+ @abs_top_srcdir@/docs/auth.md \
@abs_top_srcdir@/docs/all-error-codes.md \
@abs_top_srcdir@/docs/FAQ.md \
@abs_top_srcdir@/docs/known_problems.md \
diff --git a/docs/Makefile.am b/docs/Makefile.am
index fcf6be6..59a0971 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -11,7 +11,7 @@ EXTRA_DIST = netcdf.m4 DoxygenLayout.xml Doxyfile.in footer.html \
building-with-cmake.md CMakeLists.txt \
groups.dox install.md notes.md install-fortran.md \
all-error-codes.md cmake_faq.md credits.md \
- auth.html obsolete/fan_utils.html bestpractices.md
+ auth.md obsolete/fan_utils.html bestpractices.md
# Turn off parallel builds in this directory.
.NOTPARALLEL:
@@ -51,7 +51,7 @@ endif
doxyfile.stamp:
$(DOXYGEN) Doxyfile \
- cp auth.html obsolete/fan_utils.html html
+ cp auth.md obsolete/fan_utils.html html
CLEANFILES = doxyfile.stamp html latex man
@@ -62,13 +62,3 @@ CLEANFILES = doxyfile.stamp html latex man
web-tarball: doxyfile.stamp
cd html; tar cf ../netcdf_docs.tar *
gzip -f netcdf_docs.tar
-
-# When oc2/auth.html.in is changed, you should generate auth.html
-# using the following process.
-oc2-auth:
- cat ${top_srcdir}/oc2/auth.html.in \
- | sed -e '/<OC>/d' \
- | sed -e 's|^<NC>||' \
- | sed -e 's|zz|netcdf|g' -e 's|ZZ|netCDF|g' \
- | sed -e '/stylesheet/r${top_srcdir}/oc2/oc.css' -e '/stylesheet/d' \
- > auth.html
diff --git a/docs/Makefile.in b/docs/Makefile.in
index 31c6362..8eabe65 100644
--- a/docs/Makefile.in
+++ b/docs/Makefile.in
@@ -226,7 +226,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -261,7 +263,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
@@ -371,7 +374,7 @@ EXTRA_DIST = netcdf.m4 DoxygenLayout.xml Doxyfile.in footer.html \
building-with-cmake.md CMakeLists.txt \
groups.dox install.md notes.md install-fortran.md \
all-error-codes.md cmake_faq.md credits.md \
- auth.html obsolete/fan_utils.html bestpractices.md
+ auth.md obsolete/fan_utils.html bestpractices.md
# To build documentation you must have M4 in their path.
@@ -726,7 +729,7 @@ uninstall-am:
doxyfile.stamp:
$(DOXYGEN) Doxyfile \
- cp auth.html obsolete/fan_utils.html html
+ cp auth.md obsolete/fan_utils.html html
# This builds the docs from source, if necessary, and tars up
# everything needed for the website. Run this and copy the resulting
@@ -736,16 +739,6 @@ web-tarball: doxyfile.stamp
cd html; tar cf ../netcdf_docs.tar *
gzip -f netcdf_docs.tar
-# When oc2/auth.html.in is changed, you should generate auth.html
-# using the following process.
-oc2-auth:
- cat ${top_srcdir}/oc2/auth.html.in \
- | sed -e '/<OC>/d' \
- | sed -e 's|^<NC>||' \
- | sed -e 's|zz|netcdf|g' -e 's|ZZ|netCDF|g' \
- | sed -e '/stylesheet/r${top_srcdir}/oc2/oc.css' -e '/stylesheet/d' \
- > auth.html
-
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/docs/OPeNDAP.dox b/docs/OPeNDAP.dox
index f4de888..59f3839 100644
--- a/docs/OPeNDAP.dox
+++ b/docs/OPeNDAP.dox
@@ -29,7 +29,7 @@ DDS and DAS, refer to the OPeNDAP web site http://opendap.org.
See the following pages for more information.
- \subpage dap_accessing_data
-- <a href="auth.html">netCDF Authorization Support</a>
+- <a href="auth.md">netCDF Authorization Support</a>
- \subpage dap_to_netcdf
- \subpage dap2_reserved_keywords
- \subpage var_dim_trans
diff --git a/docs/attribute_conventions.md b/docs/attribute_conventions.md
index c589ac7..52c5426 100644
--- a/docs/attribute_conventions.md
+++ b/docs/attribute_conventions.md
@@ -25,11 +25,14 @@ It is strongly recommended that applicable conventions be followed unless there
<p>
-> It is not necessary to define your own _FillValue attribute for a variable if the default fill value for the type of the variable is adequate. However, use of the default fill value for data type byte is not recommended. Note that if you change the value of this attribute, the changed value applies only to subsequent writes; previously written data are not changed.
+> If _FillValue is undefined, it is assumed that there are no unwritten data-values. Generic applications needing to write a value to represent undefined or missing values may use either `_FillValue` or `missing_value` for this purpose. It is legal (but not recommended) for the fill value to be within the valid range of the data.
<p>
-> Generic applications often need to write a value to represent undefined or missing values. The fill value provides an appropriate value for this purpose because it is normally outside the valid range and therefore treated as missing when read by generic applications. It is legal (but not recommended) for the fill value to be within the valid range.
+> Generic applications often need to write a value to represent undefined or missing values. The fill value provides an appropriate value for this purpose because it is normally outside the valid range and therefore treated as missing when read by generic applications. It is legal (but not recommended) for the fill value to be within the valid range.
+
+> **Note that if you change the value of this attribute, the changed value applies only to subsequent writes; previously written data are not changed.**
+
`missing_value`
@@ -183,4 +186,3 @@ Using the following API calls will fail.
> The type of this attribute is NC_INT.
> This attribute is computed by using the HDF5 API to walk the file to look for attributes specific to netcdf-4. False negatives are possible for a small subset of netcdf-4 files, especially those not containing dimensions. False positives are only possible by deliberate modifications to an existing HDF5 file thru the HDF5 API. For files with the _NCProperties attribute, this attribute is redundant. For files created prior to the introduction of the _NCProperties attribute, this may be [...]
-
diff --git a/docs/auth.html b/docs/auth.html
index c617e86..de78602 100644
--- a/docs/auth.html
+++ b/docs/auth.html
@@ -69,6 +69,10 @@ netCDF can support user authorization using the facilities provided by the curl
library. This includes basic password authentication as well as
certificate-based authorization.
<p>
+At the moment, this document only applies to DAP2 and DAP4 access
+because they are (for now) the only parts of the netCDF-C library
+that uses libcurl.
+<p>
With some exceptions (e.g. see the section on <a href="#REDIR">redirection</a>)
The libcurl authorization mechanisms can be accessed in two ways
<ol>
diff --git a/docs/auth.md b/docs/auth.md
new file mode 100644
index 0000000..93d836b
--- /dev/null
+++ b/docs/auth.md
@@ -0,0 +1,491 @@
+netCDF Authorization Support
+======================================
+<!-- double header is needed to workaround doxygen bug -->
+
+# netCDF Authorization Support {#Header}
+
+__Author__: Dennis Heimbigner<br>
+__Initial Version__: 11/21/2014<br>
+__Last Revised__: 08/24/2017
+
+[TOC]
+
+## Introduction {#Introduction}
+
+netCDF can support user authorization using the facilities provided by the curl
+library. This includes basic password authentication as well as
+certificate-based authorization.
+
+At the moment, this document only applies to DAP2 and DAP4 access
+because they are (for now) the only parts of the netCDF-C library
+that uses libcurl.
+
+With some exceptions (e.g. see the section on <a href="#REDIR">redirection</a>)
+The libcurl authorization mechanisms can be accessed in two ways
+
+1. Inserting the username and password into the url, or
+2. Accessing information from a so-called _rc_ file named either
+ `.daprc` or `.dodsrc`
+
+## URL-Based Authentication {#URLAUTH}
+
+For simple password based authentication, it is possible to
+directly insert the username and the password into a url in this form.
+
+ http://username:password@host/...
+
+This username and password will be used if the server asks for
+authentication. Note that only simple password authentication
+is supported in this format.
+
+Specifically note that [redirection-based](#REDIR)
+authorization may work with this but it is a security risk.
+This is because the username and password
+may be sent to each server in the redirection chain.
+
+Note also that the `user:password` form may contain characters that must be
+escaped. See the <a href="#USERPWDESCAPE">password escaping</a> section to see
+how to properly escape the user and password.
+
+## RC File Authentication {#DODSRC}
+The netcdf library supports an _rc_ file mechanism to allow the passing
+of a number of parameters to libnetcdf and libcurl.
+Locating the _rc_ file is a multi-step process.
+
+### Search Order
+
+The file must be called one of the following names:
+".daprc" or ".dodsrc".
+If both ".daprc" and ".dodsrc" exist, then
+the ".daprc" file will take precedence.
+
+It is strongly suggested that you pick one of the two names
+and use it always. Otherwise you may observe unexpected results
+when the netcdf-c library finds one that you did not intend.
+
+The search for an _rc_ file looks in the following places in this order.
+
+1. Check for the environment variable named _DAPRCFILE_.
+ This will specify the full path for the _rc_ file
+ (not just the containing directory).
+2. Search the current working directory (`./`) looking
+ for (in order) .daprc or .dodsrc.
+3. Search the HOME directory (`$HOME`) looking
+ for (in order) .daprc or .dodsrc. The HOME environment
+ variable is used to define the directory in which to search.
+
+It is strongly suggested that you pick a uniform location
+and use it always. Otherwise you may observe unexpected results
+when the netcdf-c library get an rc file you did not expect.
+
+### RC File Format
+
+The rc file format is a series of lines of the general form:
+
+ [<host:port>]<key>=<value>
+
+where the bracket-enclosed host:port is optional.
+
+### URL Constrained RC File Entries
+
+Each line of the rc file can begin with
+a host+port enclosed in square brackets.
+The form is "host:port".
+If the port is not specified
+then the form is just "host".
+The reason that more of the url is not used is that
+libcurl's authorization grain is not any finer than host level.
+
+Examples.
+
+ [remotetest.unidata.ucar.edu]HTTP.VERBOSE=1
+
+or
+
+ [fake.ucar.edu:9090]HTTP.VERBOSE=0
+
+If the url request from, say, the _netcdf_open_ method
+has a host+port matching one of the prefixes in the rc file, then
+the corresponding entry will be used, otherwise ignored.
+This means that an entry with a matching host+port will take
+precedence over an entry without a host+port.
+
+For example, the URL
+
+ http://remotetest.unidata.ucar.edu/thredds/dodsC/testdata/testData.nc
+
+will have HTTP.VERBOSE set to 1 because its host matches the example above.
+
+Similarly,
+
+ http://fake.ucar.edu:9090/dts/test.01
+
+will have HTTP.VERBOSE set to 0 because its host+port matches the example above.
+
+## Authorization-Related Keys {#AUTHKEYS}
+
+The currently defined set of authorization-related keys are as follows.
+The second column is the affected curl_easy_setopt option(s), if any.
+<table>
+<tr><th>Key</th><th>Affected curl_easy_setopt Options</th><th>Notes</th>
+<tr><td>HTTP.COOKIEJAR</td><td>CURLOPT_COOKIEJAR</td>
+<tr><td>HTTP.COOKIEFILE</td><td>CURLOPT_COOKIEJAR</td><td>Alias for CURLOPT_COOKIEJAR</td>
+<tr><td>HTTP.PROXY_SERVER</td><td>CURLOPT_PROXY, CURLOPT_PROXYPORT, CURLOPT_PROXYUSERPWD</td>
+<tr><td>HTTP.SSL.CERTIFICATE</td><td>CURLOPT_SSLCERT</td>
+<tr><td>HTTP.SSL.KEY</td><td>CURLOPT_SSLKEY</td>
+<tr><td>HTTP.SSL.KEYPASSWORD</td><td>CURLOPT_KEYPASSWORD</td>
+<tr><td>HTTP.SSL.CAINFO</td><td>CURLOPT_CAINFO</td>
+<tr><td>HTTP.SSL.CAPATH</td><td>CURLOPT_CAPATH</td>
+<tr><td>HTTP.SSL.VERIFYPEER</td><td>CURLOPT_SSL_VERIFYPEER</td>
+<tr><td>HTTP.SSL.VALIDATE</td><td>CURLOPT_SSL_VERIFYPEER, CURLOPT_SSL_VERIFYHOST</td>
+<tr><td>HTTP.CREDENTIALS.USERPASSWORD</td><td>CURLOPT_USERPASSWORD</td>
+<tr><td>HTTP.NETRC</td><td>CURLOPT_NETRC,CURLOPT_NETRC_FILE</td>
+</table>
+
+### Password Authentication
+
+The key
+HTTP.CREDENTIALS.USERPASSWORD
+can be used to set the simple password authentication.
+This is an alternative to setting it in the url.
+The value must be of the form "username:password".
+See the <a href="#USERPWDESCAPE">password escaping</a> section
+to see how this value must escape certain characters.
+Also see <a href="#REDIR">redirection authorization</a>
+for important additional information.
+
+### Cookie Jar
+
+The HTTP.COOKIEJAR key
+specifies the name of file from which
+to read cookies (CURLOPT_COOKIEJAR) and also
+the file into which to store cookies (CURLOPT_COOKIEFILE).
+The same value is used for both CURLOPT values.
+It defaults to in-memory storage.
+See [redirection authorization](#REDIR)
+for important additional information.
+
+### Certificate Authentication
+
+HTTP.SSL.CERTIFICATE
+specifies a file path for a file containing a PEM cerficate.
+This is typically used for client-side authentication.
+
+HTTP.SSL.KEY is essentially the same as HTTP.SSL.CERTIFICATE
+and should always have the same value.
+
+HTTP.SSL.KEYPASSWORD
+specifies the password for accessing the HTTP.SSL.CERTIFICAT/HTTP.SSL.key file.
+
+HTTP.SSL.CAPATH
+specifies the path to a directory containing
+trusted certificates for validating server sertificates.
+
+HTTP.SSL.VALIDATE
+is a boolean (1/0) value that if true (1)
+specifies that the client should verify the server's presented certificate.
+
+HTTP.PROXY_SERVER
+specifies the url for accessing the proxy:
+e.g. *http://[username:password@]host[:port]*
+
+HTTP.NETRC
+specifies the absolute path of the .netrc file.
+See [redirection authorization](#REDIR)
+for information about using .netrc.
+
+## Password Escaping {#USERPWDESCAPE}
+
+With current password rules, it is is not unlikely that the password
+will contain characters that need to be escaped. Similarly, the user
+may contain characters such as '@' that need to be escaped. To support this,
+it is assumed that all occurrences of `user:password` use URL (i.e. %%XX)
+escaping for at least the characters in the table below.
+
+The minimum set of characters that must be escaped depends on the location.
+If the user+pwd is embedded in the URL, then '@' and ':' __must__ be escaped.
+If the user+pwd is the value for
+the HTTP.CREDENTIALS.USERPASSWORD key in the _rc_ file, then
+':' __must__ be escaped.
+Escaping should __not__ be used in the `.netrc` file.
+
+The relevant escape codes are as follows.
+<table>
+<tr><th>Character</th><th>Escaped Form</th>
+<tr><td>'@'</td><td>%40</td>
+<tr><td>':'</td><td>%3a</td>
+</table>
+Additional characters can be escaped if desired.
+
+## Redirection-Based Authentication {#REDIR}
+
+Some sites provide authentication by using a third party site
+to do the authentication. Examples include ESG, URS, RDA, and most oauth2-based
+systems.
+
+The process is usually as follows.
+
+1. The client contacts the server of interest (SOI), the actual data provider
+using, typically _http_ protocol.
+2. The SOI sends a redirect to the client to connect to the e.g. URS system
+using the _https_ protocol (note the use of _https_ instead of _http_).
+3. The client authenticates with URS.
+4. URS sends a redirect (with authorization information) to send
+the client back to the SOI to actually obtain the data.
+
+It turns out that libcurl, by default, uses the password in the
+`.daprc` file (or from the url) for all connections that request
+a password. This causes problems because only the the specific
+redirected connection is the one that actually requires the password.
+This is where the `.netrc` file comes in. Libcurl will use `.netrc`
+for the redirected connection. It is possible to cause libcurl
+to use the `.daprc` password always, but this introduces a
+security hole because it may send the initial user+pwd to every
+server in the redirection chain.
+In summary, if you are using redirection, then you are
+''strongly'' encouraged to create a `.netrc` file to hold the
+password for the site to which the redirection is sent.
+
+The format of this `.netrc` file will contain lines that
+typically look like this.
+
+ machine mmmmmm login xxxxxx password yyyyyy
+
+where the machine, mmmmmm, is the hostname of the machine to
+which the client is redirected for authorization, and the
+login and password are those needed to authenticate on that machine.
+
+The location of the `.netrc` file can be specified by
+putting the following line in your `.daprc`/`.dodsrc` file.
+
+ HTTP.NETRC=<path to netrc file>
+
+If not specified, then libcurl will look first in the current
+directory, and then in the HOME directory.
+
+One final note. In using this, you MUST
+to specify a real file in the file system to act as the
+cookie jar file (HTTP.COOKIEJAR) so that the
+redirect site can properly pass back authorization information.
+
+## Client-Side Certificates {#CLIENTCERTS}
+
+Some systems, notably ESG (Earth System Grid), requires
+the use of client-side certificates, as well as being
+[re-direction based](#REDIR).
+This requires setting the following entries:
+
+- HTTP.COOKIEJAR — a file path for storing cookies across re-direction.
+- HTTP.NETRC — the path to the netrc file.
+- HTTP.SSL.CERTIFICATE — the file path for the client side certificate file.
+- HTTP.SSL.KEY — this should have the same value as HTTP.SSL.CERTIFICATE.
+- HTTP.SSL.CAPATH — the path to a "certificates" directory.
+- HTTP.SSL.VALIDATE — force validation of the server certificate.
+
+Note that the first two are there to support re-direction based authentication.
+
+## Appendix A. All RC-File Keys {#allkeys}
+
+For completeness, this is the list of all rc-file keys.
+If this documentation is out of date with respect to the actual code,
+the code is definitive.
+<table>
+<tr><th>Key</th><th>curl_easy_setopt Option</th>
+<tr valign="top"><td>HTTP.DEFLATE</td><td>CUROPT_DEFLATE<br>with value "deflate,gzip"</td>
+<tr><td>HTTP.VERBOSE</td><td>CUROPT_VERBOSE</td>
+<tr><td>HTTP.TIMEOUT</td><td>CUROPT_TIMEOUT</td>
+<tr><td>HTTP.USERAGENT</td><td>CUROPT_USERAGENT</td>
+<tr><td>HTTP.COOKIEJAR</td><td>CUROPT_COOKIEJAR</td>
+<tr><td>HTTP.COOKIE_JAR</td><td>CUROPT_COOKIEJAR</td>
+<tr valign="top"><td>HTTP.PROXY_SERVER</td><td>CURLOPT_PROXY,<br>CURLOPT_PROXYPORT,<br>CURLOPT_PROXYUSERPWD</td>
+<tr><td>HTTP.SSL.CERTIFICATE</td><td>CUROPT_SSLCERT</td>
+<tr><td>HTTP.SSL.KEY</td><td>CUROPT_SSLKEY</td>
+<tr><td>HTTP.SSL.KEYPASSWORD</td><td>CUROPT_KEYPASSWORD</td>
+<tr><td>HTTP.SSL.CAINFO</td><td>CUROPT_CAINFO</td>
+<tr><td>HTTP.SSL.CAPATH</td><td>CUROPT_CAPATH</td>
+<tr><td>HTTP.SSL.VERIFYPEER</td><td>CUROPT_SSL_VERIFYPEER</td>
+<tr><td>HTTP.CREDENTIALS.USERPASSWORD</td><td>CUROPT_USERPASSWORD</td>
+<tr><td>HTTP.NETRC</td><td>CURLOPT_NETRC,CURLOPT_NETRC_FILE</td>
+</table>
+
+## Appendix B. URS Access in Detail {#URSDETAIL}
+
+It is possible to use the NASA Earthdata Login System (URS)
+with netcdf by using using the process specified in the
+[redirection based authorization section](#REDIR).
+In order to access URS controlled datasets, however, it is necessary to
+register as a user with NASA at this website (subject to change):
+
+ https://uat.urs.earthdata.nasa.gov/
+
+## Appendix C. ESG Access in Detail {#ESGDETAIL}
+
+It is possible to access Earth Systems Grid (ESG) datasets
+from ESG servers through the netCDF API using the techniques
+described in the section on [Client-Side Certificates](#CLIENTCERTS).
+
+In order to access ESG datasets, however, it is necessary to
+register as a user with ESG and to setup your environment
+so that proper authentication is established between an netcdf
+client program and the ESG data server. Specifically, it
+is necessary to use what is called "client-side keys" to
+enable this authentication. Normally, when a client accesses
+a server in a secure fashion (using "https"), the server
+provides an authentication certificate to the client.
+With client-side keys, the client must also provide a
+certificate to the server so that the server can know with
+whom it is communicating. Note that this section is subject
+to change as ESG changes its procedures.
+
+The netcdf library uses the _curl_ library and it is that
+underlying library that must be properly configured.
+
+### Terminology
+
+The key elements for client-side keys requires the constructions of
+two "stores" on the client side.
+
+* Keystore - a repository to hold the client side key.
+* Truststore - a repository to hold a chain of certificates
+that can be used to validate the certificate
+sent by the server to the client.
+
+The server actually has a similar set of stores, but the client
+need not be concerned with those.
+
+### Initial Steps
+
+The first step is to obtain authorization from ESG.
+Note that this information may evolve over time, and
+may be out of date.
+This discussion is in terms of BADC and NCSA. You will need
+to substitute as necessary.
+
+1. Register at http://badc.nerc.ac.uk/register
+ to obtain access to badc and to obtain an openid,
+ which will looks something like:
+ <pre>https://ceda.ac.uk/openid/Firstname.Lastname</pre>
+
+2. Ask BADC for access to whatever datasets are of interest.
+
+3. Obtain short term credentials at
+ _http://grid.ncsa.illinois.edu/myproxy/MyProxyLogon/_
+ You will need to download and run the MyProxyLogon program.
+ This will create a keyfile in, typically, the directory ".globus".
+ The keyfile will have a name similar to this: "x509up_u13615"
+ The other elements in ".globus" are certificates to use in
+ validating the certificate your client gets from the server.
+
+4. Obtain the program source ImportKey.java
+ from this location: _http://www.agentbob.info/agentbob/79-AB.html_
+ (read the whole page, it will help you understand the remaining steps).
+
+### Building the KeyStore
+
+You will have to modify the keyfile in the previous step
+and then create a keystore and install the key and a certificate.
+The commands are these:
+
+ openssl pkcs8 -topk8 -nocrypt -in x509up_u13615 -inform PEM -out key.der -outform DER
+ openssl x509 -in x509up_u13615 -inform PEM -out cert.der -outform DER
+ java -classpath <path to ImportKey.class> -Dkeypassword="<password>" -Dkeystore=./<keystorefilename> key.der cert.der
+
+Note, the file names "key.der" and "cert.der" can be whatever you choose.
+It is probably best to leave the .der extension, though.
+
+### Building the TrustStore
+
+Building the truststore is a bit tricky because as provided, the
+certificates in ".globus" need some massaging. See the script below
+for the details. The primary command is this, which is executed for every
+certificate, c, in globus. It sticks the certificate into the file
+named "truststore"
+
+ keytool -trustcacerts -storepass "password" -v -keystore "truststore" -importcert -file "${c}"
+
+### Running the C Client
+
+Refer to the section on [Client-Side Certificates](#CLIENTCERTS).
+The keys specified there must be set in the rc file to support ESG access.
+
+- HTTP.COOKIEJAR=~/.dods_cookies
+- HTTP.NETRC=~/.netrc
+- HTTP.SSL.CERTIFICATE=~/esgkeystore
+- HTTP.SSL.KEY=~/esgkeystore
+- HTTP.SSL.CAPATH=~/.globus
+- HTTP.SSL.VALIDATE=1
+
+Of course, the file paths above are suggestions only;
+you can modify as needed.
+The HTTP.SSL.CERTIFICATE and HTTP.SSL.KEY
+entries should have same value, which is the file path for the
+certificate produced by MyProxyLogon. The HTTP.SSL.CAPATH entry
+should be the path to the "certificates" directory produced by
+MyProxyLogon.
+
+As noted, ESG also uses re-direction based authentication.
+So, when it receives an initial connection from a client, it
+redirects to a separate authentication server. When that
+server has authenticated the client, it redirects back to
+the original url to complete the request.
+
+### Script for creating Stores
+
+The following script shows in detail how to actually construct the key
+and trust stores. It is specific to the format of the globus file
+as it was when ESG support was first added. It may have changed
+since then, in which case, you will need to seek some help
+in fixing this script. It would help if you communicated
+what you changed to the author so this document can be updated.
+
+ #!/bin/sh -x
+ KEYSTORE="esgkeystore"
+ TRUSTSTORE="esgtruststore"
+ GLOBUS="globus"
+ TRUSTROOT="certificates"
+ CERT="x509up_u13615"
+ TRUSTROOTPATH="$GLOBUS/$TRUSTROOT"
+ CERTFILE="$GLOBUS/$CERT"
+ PWD="password"
+
+ D="-Dglobus=$GLOBUS"
+ CCP="bcprov-jdk16-145.jar"
+ CP="./build:${CCP}"
+ JAR="myproxy.jar"
+
+ # Initialize needed directories
+ rm -fr build
+ mkdir build
+ rm -fr $GLOBUS
+ mkdir $GLOBUS
+ rm -f $KEYSTORE
+ rm -f $TRUSTSTORE
+
+ # Compile MyProxyCmd and ImportKey
+ javac -d ./build -classpath "$CCP" *.java
+ javac -d ./build ImportKey.java
+
+ # Execute MyProxyCmd
+ java -cp "$CP myproxy.MyProxyCmd
+
+ # Build the keystore
+ openssl pkcs8 -topk8 -nocrypt -in $CERTFILE -inform PEM -out key.der -outform DER
+ openssl x509 -in $CERTFILE -inform PEM -out cert.der -outform DER
+ java -Dkeypassword=$PWD -Dkeystore=./${KEYSTORE} -cp ./build ImportKey key.der cert.der
+
+ # Clean up the certificates in the globus directory
+ for c in ${TRUSTROOTPATH}/*.0 ; do
+ alias=`basename $c .0`
+ sed -e '0,/---/d' <$c >/tmp/${alias}
+ echo "-----BEGIN CERTIFICATE-----" >$c
+ cat /tmp/${alias} >>$c
+ done
+
+ # Build the truststore
+ for c in ${TRUSTROOTPATH}/*.0 ; do
+ alias=`basename $c .0`
+ echo "adding: $TRUSTROOTPATH/${c}"
+ echo "alias: $alias"
+ yes | keytool -trustcacerts -storepass "$PWD" -v -keystore ./$TRUSTSTORE -alias $alias -importcert -file "${c}"
+ done
+ exit
diff --git a/docs/guide.dox b/docs/guide.dox
index 0a8dcf6..7f57f19 100644
--- a/docs/guide.dox
+++ b/docs/guide.dox
@@ -84,7 +84,15 @@ affecting existing programs. The physical representation of netCDF
data is designed to be independent of the computer on which the data
were written.
-Unidata supports the netCDF interfaces for C (see <a href="http://www.unidata.ucar.edu/netcdf/docs/" >NetCDF-C User's Guide</a>), FORTRAN 77 (see <a href="http://www.unidata.ucar.edu/netcdf/documentation/historic/netcdf-f77/index.html#Top" >NetCDF Fortran 77 Interface Guide</a>), FORTRAN 90 (see <a href="http://www.unidata.ucar.edu/netcdf/documentation/historic/netcdf-f90/index.html" >NetCDF Fortran 90 Interface Guide</a>), and C++ (see <a href="http://www.unidata.ucar.edu/netcdf/documen [...]
+Unidata supports the netCDF interfaces for C (see <a
+href="http://www.unidata.ucar.edu/netcdf/docs/" >NetCDF-C User's
+Guide</a>), FORTRAN 77 (see <a
+href="http://www.unidata.ucar.edu/netcdf/documentation/historic/netcdf-f77/index.html#Top"
+>NetCDF Fortran 77 Interface Guide</a>), FORTRAN 90 (see <a
+href="http://www.unidata.ucar.edu/netcdf/documentation/historic/netcdf-f90/index.html"
+>NetCDF Fortran 90 Interface Guide</a>), and C++ (see <a
+href="http://www.unidata.ucar.edu/netcdf/documentation/historic/cxx4/index.html"
+>NetCDF C++ Interface Guide</a>).
The netCDF library is supported for various UNIX operating systems. A
MS Windows port is also available. The software is also ported and
@@ -128,10 +136,11 @@ floating-point standard is used for floating-point data
representation.
Descriptions of the overall structure of netCDF classic and 64-bit
-offset files are provided later in this manual. See Structure.
+offset files are provided later in this manual. See
+\ref file_structure_and_performance.
The details of the classic and 64-bit offset formats are described in
-an appendix. See File Format. However, users are discouraged from
+an appendix. See \ref netcdf_format. However, users are discouraged from
using the format specification to develop independent low-level
software for reading and writing netCDF files, because this could lead
to compatibility problems if the format is ever modified.
@@ -154,15 +163,14 @@ Users are encouraged to use netCDF classic format to distribute data,
for maximum portability.
To select 64-bit offset or netCDF-4 format files, C programmers should
-use flag NC_64BIT_OFFSET or NC_NETCDF4 in function nc_create. See
-nc_create.
+use flag NC_64BIT_OFFSET or NC_NETCDF4 in function nc_create().
In Fortran, use flag nf_64bit_offset or nf_format_netcdf4 in function
NF_CREATE. See NF_CREATE.
It is also possible to change the default creation format, to convert
a large body of code without changing every create call. C programmers
-see nc_set_default_format. Fortran programs see NF_SET_DEFAULT_FORMAT.
+see nc_set_default_format(). Fortran programs see NF_SET_DEFAULT_FORMAT.
\subsection classic_format NetCDF Classic Format
@@ -176,12 +184,13 @@ previous version of netCDF. It has maximum portability, and is still
the default netCDF format.
For some users, the various 2 GiB format limitations of the classic
-format become a problem. (see Classic Limitations). 1.4.2 NetCDF
-64-bit Offset Format
+format become a problem. (see \ref limitations).
+
+\subsection netcdf_64bit_offset_format NetCDF 64-bit Offset Format
For these users, 64-bit offset format is a natural choice. It greatly
-eases the size restrictions of netCDF classic files (see 64 bit Offset
-Limitations).
+eases the size restrictions of netCDF classic files (see \ref
+limitations).
Files with the 64-bit offsets are identified with a “CDF\002” at the
beginning of the file. In this documentation this format is called
@@ -211,7 +220,9 @@ NetCDF-4 files can't be read by any version of the netCDF library
previous to 4.0. (But they can be read by HDF5, version 1.8.0 or
better).
-For more discussion of format issues see The NetCDF Tutorial.
+For more discussion of format issues see <a
+href="http://www.unidata.ucar.edu/software/netcdf/docs/tutorial_8dox.html">The
+NetCDF Tutorial</a>.
\section architecture NetCDF Library Architecture
@@ -250,7 +261,7 @@ designing and implementing netCDF, it is still possible to use the
netCDF interface to access data in inefficient ways: for example, by
requesting a slice of data that requires a single value from each
record. Advice on how to use the interface efficiently is provided in
-Structure.
+\ref file_structure_and_performance.
The use of HDF5 as a data format adds significant overhead in metadata
operations, less so in data access operations. We continue to study
@@ -269,7 +280,7 @@ Attributes play a vital role in providing ancillary information. It is
important to use all the relevant standard attributes using the
relevant conventions. For a description of reserved attributes (used
by the netCDF library) and attribute conventions for generic
-application software, see Attribute Conventions.
+application software, see \ref attribute_conventions.
A number of groups have defined their own additional conventions and
styles for netCDF data. Descriptions of these conventions, as well as
@@ -303,19 +314,19 @@ COMPOUND types allow users to organize data in new ways.
With the classic netCDF file format, there are constraints that limit
how a dataset is structured to store more than 2 GiBytes (a GiByte is
2^30 or 1,073,741,824 bytes, as compared to a Gbyte, which is
-1,000,000,000 bytes.) of data in a single netCDF dataset. (see Classic
-Limitations). This limitation is a result of 32-bit offsets used for
+1,000,000,000 bytes.) of data in a single netCDF dataset. (see \ref
+limitations). This limitation is a result of 32-bit offsets used for
storing relative offsets within a classic netCDF format file. Since
one of the goals of netCDF is portable data, and some file systems
still can't deal with files larger than 2 GiB, it is best to keep
files that must be portable below this limit. Nevertheless, it is
possible to create and access netCDF files larger than 2 GiB on
-platforms that provide support for such files (see Large File
-Support).
+platforms that provide support for such files (see
+\ref large_file_support).
The new 64-bit offset format allows large files, and makes it easy to
create to create fixed variables of about 4 GiB, and record variables
-of about 4 GiB per record. (see 64 bit Offset Limitations). However,
+of about 4 GiB per record. (see \ref netcdf_64bit_offset_format). However,
old netCDF applications will not be able to read the 64-bit offset
files until they are upgraded to at least version 3.6.0 of netCDF
(i.e. the version in which 64-bit offset format was introduced).
@@ -543,17 +554,17 @@ for variables with dimensions, or
for scalar variables.
In the above CDL example there are six variables. As discussed below,
-four of these are coordinate variables (See coordinate_variables). The
-remaining variables (sometimes called primary variables), temp and rh,
-contain what is usually thought of as the data. Each of these
-variables has the unlimited dimension time as its first dimension, so
-they are called record variables. A variable that is not a record
-variable has a fixed length (number of data values) given by the
-product of its dimension lengths. The length of a record variable is
-also the product of its dimension lengths, but in this case the
-product is variable because it involves the length of the unlimited
-dimension, which can vary. The length of the unlimited dimension is
-the number of records.
+four of these are coordinate variables (See \ref
+coordinate_variables). The remaining variables (sometimes called
+primary variables), temp and rh, contain what is usually thought of as
+the data. Each of these variables has the unlimited dimension time as
+its first dimension, so they are called record variables. A variable
+that is not a record variable has a fixed length (number of data
+values) given by the product of its dimension lengths. The length of a
+record variable is also the product of its dimension lengths, but in
+this case the product is variable because it involves the length of
+the unlimited dimension, which can vary. The length of the unlimited
+dimension is the number of records.
\section coordinate_variables Coordinate Variables
@@ -653,7 +664,7 @@ For the netCDF classic model, the type and length of each attribute
are not explicitly declared in CDL; they are derived from the values
assigned to the attribute. All values of an attribute must be of the
same type. The notation used for constant values of the various netCDF
-types is discussed later (see CDL Constants).
+types is discussed later (see \ref cdl_syntax).
The extended CDL syntax for the enhanced data model supported by
netCDF-4 allows optional type specifications, including user-defined
@@ -677,13 +688,13 @@ attribute conventions and it is strongly recommended that these be
followed unless there are good reasons for not doing so. For
information about units, long_name, valid_min, valid_max, valid_range,
scale_factor, add_offset, _FillValue, and other conventional
-attributes, see Attribute Conventions.
+attributes, see \ref attribute_conventions.
Attributes may be added to a netCDF dataset long after it is first
defined, so you don't have to anticipate all potentially useful
attributes. However adding new attributes to an existing classic or
64-bit offset format dataset can incur the same expense as copying the
-dataset. For a more extensive discussion see Structure.
+dataset. For a more extensive discussion see \ref file_structure_and_performance.
\section differences_atts_vars Differences between Attributes and Variables
@@ -751,7 +762,10 @@ characters.
Some widely used conventions restrict names to only alphanumeric
characters or underscores.
-\note Note that, when using the DAP2 protocol to access netCDF data, there are \em reserved keywords, the use of which may result in undefined behavior. See \ref dap2_reserved_keywords for more information.
+\note Note that, when using the DAP2 protocol to access netCDF data,
+there are \em reserved keywords, the use of which may result in
+undefined behavior. See \ref dap2_reserved_keywords for more
+information.
\section archival Is NetCDF a Good Archive Format?
@@ -1082,11 +1096,11 @@ access.
\section c_array_section_access A C Example of Array-Section Access
-Assume that in our earlier example of a netCDF dataset (see Network
-Common Data Form Language (CDL)), we wish to read a cross-section of
-all the data for the temp variable at one level (say, the second), and
-assume that there are currently three records (time values) in the
-netCDF dataset. Recall that the dimensions are defined as
+Assume that in our earlier example of a netCDF dataset, we wish to
+read a cross-section of all the data for the temp variable at one
+level (say, the second), and assume that there are currently three
+records (time values) in the netCDF dataset. Recall that the
+dimensions are defined as
\code
lat = 5, lon = 10, level = 4, time = unlimited;
@@ -1251,24 +1265,22 @@ datasets self-describing. A disadvantage of this organization is that
any operation on a netCDF dataset that requires the header to grow
(or, less likely, to shrink), for example adding new dimensions or new
variables, requires moving the data by copying it. This expense is
-incurred when the enddef function is called: nc_enddef in C (see
-nc_enddef), NF_ENDDEF in Fortran (see NF_ENDDEF), after a previous
-call to the redef function: nc_redef in C (see nc_redef) or NF_REDEF
-in Fortran (see NF_REDEF). If you create all necessary dimensions,
-variables, and attributes before writing data, and avoid later
-additions and renamings of netCDF components that require more space
-in the header part of the file, you avoid the cost associated with
-later changing the header.
+incurred when the enddef function is called: nc_enddef() in C,
+NF_ENDDEF() in Fortran, after a previous call to the redef function:
+nc_redef() in C or NF_REDEF() in Fortran. If you create all necessary
+dimensions, variables, and attributes before writing data, and avoid
+later additions and renamings of netCDF components that require more
+space in the header part of the file, you avoid the cost associated
+with later changing the header.
Alternatively, you can use an alternative version of the enddef
function with two underbar characters instead of one to explicitly
reserve extra space in the file header when the file is created: in C
-nc__enddef (see nc__enddef), in Fortran NF__ENDDEF (see NF__ENDDEF),
-after a previous call to the redef function. This avoids the expense
-of moving all the data later by reserving enough extra space in the
-header to accommodate anticipated changes, such as the addition of new
-attributes or the extension of existing string attributes to hold
-longer strings.
+nc__enddef(), in Fortran NF__ENDDEF(), after a previous call to the
+redef function. This avoids the expense of moving all the data later
+by reserving enough extra space in the header to accommodate
+anticipated changes, such as the addition of new attributes or the
+extension of existing string attributes to hold longer strings.
When the size of the header is changed, data in the file is moved, and
the location of data values in the file changes. If another program is
@@ -1352,13 +1364,13 @@ this section applies only to systems with LFS.
The original binary format of netCDF (classic format) limits the size
of data files by using a signed 32-bit offset within its internal
structure. Files larger than 2 GiB can be created, with certain
-limitations. See Classic Limitations.
+limitations. See \ref limitations.
In version 3.6.0, netCDF included its first-ever variant of the
underlying data format. The new format introduced in 3.6.0 uses 64-bit
file offsets in place of the 32-bit offsets. There are still some
limits on the sizes of variables, but the new format can create very
-large datasets. See 64 bit Offset Limitations.
+large datasets. See \ref netcdf_64bit_offset_format.
NetCDF-4 variables and files can be any size supported by the
underlying file system.
@@ -1373,20 +1385,16 @@ about 1.15e+18 bytes. Note also that all sizes are really 4 bytes less
than the ones given below. For example the maximum size of a fixed
variable in netCDF 3.6 classic format is really 2 GiB - 4 bytes.
-Limit No LFS v3.5 v3.6/classic v3.6/64-bit offset v4.0/netCDF-4
-
-Max File Size 2 GiB 8 EiB 8 EiB 8 EiB ??
-
-Max Number of Fixed Vars > 2 GiB 0 1 (last) 1 (last) 2^32 ??
-
-Max Record Vars w/ Rec Size > 2 GiB 0 1 (last) 1 (last) 2^32 ??
-
-Max Size of Fixed/Record Size of Record Var 2 GiB 2 GiB 2 GiB 4 GiB ??
-
-Max Record Size 2 GiB/nrecs 4 GiB 8 EiB/nrecs 8 EiB/nrecs ??
+Limits | No LFS | v3.5 | v3.6/classic | v3.6/64-bit offset | v4.0/netCDF-4
+-------------------------------------------|------------|---------|---------------|---------------------|-----------------
+Max File Size | 2 GiB | 8 EiB | 8 EiB | 8 EiB | unlimited
+Max Number of Fixed Vars > 2 GiB | 0 | 1 (last)| 1 (last) | 2^32 | unlimited
+Max Record Vars w/ Rec Size > 2 GiB | 0 | 1 (last)| 1 (last) | 2^32 | unlimited
+Max Size of Fixed/Record Size of Record Var| 2 GiB | 2 GiB | 2 GiB | 4 GiB | unlimited
+Max Record Size | 2 GiB/nrecs| 4 GiB | 8 EiB/nrecs | 8 EiB/nrecs | unlimited
-For more information about the different file formats of netCDF See
-Which Format.
+For more information about the different file formats of netCDF see
+\ref select_format "How to Select the Format".
\section offset_format_limitations NetCDF 64-bit Offset Format Limitations
@@ -1496,8 +1504,8 @@ dataset while other processes read it.
Data reads and writes are no more atomic than calls to stdio fread()
and fwrite(). An nc_sync/NF_SYNC call is analogous to the fflush call
in the C standard I/O library, writing unwritten buffered data so
-other processes can read it; The C function nc_sync (see nc_sync), or
-the Fortran function NF_SYNC (see NF_SYNC), also brings header changes
+other processes can read it; The C function nc_sync(), or
+the Fortran function NF_SYNC(), also brings header changes
up-to-date (for example, changes to attribute values). Opening the
file with the NC_SHARE (in C) or the NF_SHARE (in Fortran) is
analogous to setting a stdio stream to be unbuffered with the _IONBF
@@ -1611,7 +1619,7 @@ script. Currently they are set to 10 and 64 MB.)
To change the default chunk cache size, use the set_chunk_cache
function before opening the file with nc_set_chunk_cache(). Fortran 77
-programmers see NF_SET_CHUNK_CACHE). Fortran 90 programmers use the
+programmers see NF_SET_CHUNK_CACHE()). Fortran 90 programmers use the
optional cache_size, cache_nelems, and cache_preemption parameters to
nf90_open/nf90_create to change the chunk size before opening the
file.
@@ -1619,11 +1627,17 @@ file.
To change the per-variable cache size, use the set_var_chunk_cache
function at any time on an open file. C programmers see
nc_set_var_chunk_cache(), Fortran 77 programmers see
-NF_SET_VAR_CHUNK_CACHE, ).
+NF_SET_VAR_CHUNK_CACHE().
\section default_chunking_4_1 The Default Chunking Scheme
-Unfortunately, there are no general-purpose chunking defaults that are optimal for all uses. Different patterns of access lead to different chunk shapes and sizes for optimum access. Optimizing for a single specific pattern of access can degrade performance for other access patterns. By creating or rewriting datasets using appropriate chunking, it is sometimes possible to support efficient access for multiple patterns of access.
+Unfortunately, there are no general-purpose chunking defaults that are
+optimal for all uses. Different patterns of access lead to different
+chunk shapes and sizes for optimum access. Optimizing for a single
+specific pattern of access can degrade performance for other access
+patterns. By creating or rewriting datasets using appropriate
+chunking, it is sometimes possible to support efficient access for
+multiple patterns of access.
If you don't know or can't anticipate what access patterns will be most common, or you want to store a variable in a way that will support reasonable access along any of its dimensions, you can use the library's default chunking strategy.
diff --git a/docs/images/Makefile.in b/docs/images/Makefile.in
index 01a5d7c..3910a09 100644
--- a/docs/images/Makefile.in
+++ b/docs/images/Makefile.in
@@ -163,7 +163,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -198,7 +200,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/docs/static-pages/software.html b/docs/static-pages/software.html
index 7198892..2190b7e 100644
--- a/docs/static-pages/software.html
+++ b/docs/static-pages/software.html
@@ -301,6 +301,9 @@
<a href="#ArcGIS">ArcGIS Pro - Space Time Pattern Mining Toolbox
</li>
<li>
+ <a href="#Agrimetsoft"> AgriMetSoft - Netcdf-Extractor
+ </li>
+ <li>
<a href="#ViewNcDap" >ASA ViewNcDap</a>
</li>
<li>
@@ -2994,6 +2997,13 @@ or using ECMWF reanalysis on a reduced grid
</p>
<p></p>
+ <h2><a id="Agrimetsoft" name="Agrimetsoft">AgriMetSoft Netcdf-Extractor</a></h2>
+ There are different software packages or various codes that may be used for manipulating or displaying NetCDF data. Some of them such as MATLAB programming language needs to enough information about provide codes in MATLAB as well as to know run codes and statements. Furthermore, user should have to pay for MATLAB programming and install it in her/his system. Also, another of them are related to other programming languages such as R, NCL (NCAR Command Language), and etc. It has bee [...]
+ <p>
+
+
+ <p></p>
+
<h2><a id="ViewNcDap" name="ViewNcDap">ASA ViewNcDap</a></h2>
<p>
Applied Science Associates, Inc. has made the ASA View NC/Dap
diff --git a/docs/types.dox b/docs/types.dox
index d6f1f15..c09c17a 100644
--- a/docs/types.dox
+++ b/docs/types.dox
@@ -22,9 +22,10 @@ The atomic external types supported by the netCDF interface are:
- ::NC_UINT64 64-bit unsigned integer *
- ::NC_FLOAT 32-bit floating point
- ::NC_DOUBLE 64-bit floating point
-- ::NC_STRING variable length character string *
+- ::NC_STRING variable length character string +
-\remark{* These types are available only for CDF5 (NC_CDF5) and netCDF-4 format (NC_NETCDF4) files. All the unsigned ints (except \ref NC_CHAR), the 64-bit ints, and string type are for CDF5 or netCDF-4 files only.}
+\remark * These types are available only for CDF5 (NC_CDF5) and netCDF-4 format (NC_NETCDF4) files. All the unsigned ints (except \ref NC_CHAR) and the 64-bit ints are for CDF5 or netCDF-4 files only.
+\remark + These types are available only for netCDF-4 (NC_NETCDF4) files.
These types were chosen to provide a reasonably wide range of
trade-offs between data precision and number of bits required for each
diff --git a/docs/windows-binaries.md b/docs/windows-binaries.md
index bebfa7b..d3b9df1 100644
--- a/docs/windows-binaries.md
+++ b/docs/windows-binaries.md
@@ -32,14 +32,14 @@ The included dependencies and versions are as follows:
* `libcurl`: 7.35.0
* `zlib`: 1.2.8
-## Latest Release (netCDF-C 4.5.0-rc2) {#msvc-latest-release}
+## Latest Release (netCDF-C 4.5.0-rc3) {#msvc-latest-release}
Configuration | 32-bit | 64-bit |
:-------------------|:-------- |:-------|
-netCDF 3 | [netCDF4.5.0-rc2-NC3-32.exe][r1] | [netCDF4.5.0-rc2-NC3-64.exe][r6]
-netCDF3+DAP | [netCDF4.5.0-rc2-NC3-DAP-32.exe][r2] | [netCDF4.5.0-rc2-NC3-DAP-64.exe][r6]
-netCDF4 | [netCDF4.5.0-rc2-NC4-32.exe][r3] | [netCDF4.5.0-rc2-NC4-64.exe][r7]
-netCDF4+DAP | [netCDF4.5.0-rc2-NC4-DAP-32.exe][r4] | [netCDF4.5.0-rc2-NC4-DAP-64.exe][r8]
+netCDF 3 | [netCDF4.5.0-rc3-NC3-32.exe][r1] | [netCDF4.5.0-rc3-NC3-64.exe][r6]
+netCDF3+DAP | [netCDF4.5.0-rc3-NC3-DAP-32.exe][r2] | [netCDF4.5.0-rc3-NC3-DAP-64.exe][r6]
+netCDF4 | [netCDF4.5.0-rc3-NC4-32.exe][r3] | [netCDF4.5.0-rc3-NC4-64.exe][r7]
+netCDF4+DAP | [netCDF4.5.0-rc3-NC4-DAP-32.exe][r4] | [netCDF4.5.0-rc3-NC4-DAP-64.exe][r8]
# Using the netCDF-C Libraries with Visual Studio {#msvc-using}
@@ -60,11 +60,11 @@ When installed, the netCDF libraries are placed in the specified locations, alon
1. When building the netCDF-C libraries with netCDF4 support, using the `Debug` libraries may cause extraneous warnings. These warnings are related to cross-dll memory management, and appear to be harmless. You can safely ignore them by using the `Release` libraries. [NCF-220]
-[r1]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC3-32.exe
-[r2]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC3-DAP-32.exe
-[r3]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC4-32.exe
-[r4]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC4-DAP-32.exe
-[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC3-64.exe
-[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC3-DAP-64.exe
-[r7]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC4-64.exe
-[r8]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc2-NC4-DAP-64.exe
+[r1]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC3-32.exe
+[r2]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC3-DAP-32.exe
+[r3]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC4-32.exe
+[r4]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC4-DAP-32.exe
+[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC3-64.exe
+[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC3-DAP-64.exe
+[r7]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC4-64.exe
+[r8]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.5.0-rc3-NC4-DAP-64.exe
diff --git a/examples/C/Makefile.in b/examples/C/Makefile.in
index 6bc305c..7d3c8df 100644
--- a/examples/C/Makefile.in
+++ b/examples/C/Makefile.in
@@ -494,7 +494,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -529,7 +531,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/examples/CDL/Makefile.in b/examples/CDL/Makefile.in
index e295081..477a24d 100644
--- a/examples/CDL/Makefile.in
+++ b/examples/CDL/Makefile.in
@@ -373,7 +373,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -408,7 +410,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 753cc7d..2652d3f 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -229,7 +229,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -264,7 +266,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/h5_test/Makefile.in b/h5_test/Makefile.in
index e94d847..2aac05e 100644
--- a/h5_test/Makefile.in
+++ b/h5_test/Makefile.in
@@ -559,7 +559,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -594,7 +596,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/include/Makefile.in b/include/Makefile.in
index 8baca2a..224794f 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -230,7 +230,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -265,7 +267,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/include/nctestserver.h b/include/nctestserver.h
index 2bd8eae..e8cdbcc 100644
--- a/include/nctestserver.h
+++ b/include/nctestserver.h
@@ -9,6 +9,10 @@
#define TIMEOUT 10 /*seconds*/
#define BUFSIZE 8192 /*bytes*/
+#ifndef HAVE_CURLINFO_RESPONSE_CODE
+#define CURLINFO_RESPONSE_CODE CURLINFO_HTTP_CODE
+#endif
+
static int ping(const char* url);
static char**
diff --git a/include/ncuri.h b/include/ncuri.h
index 62e2739..72fbe1a 100644
--- a/include/ncuri.h
+++ b/include/ncuri.h
@@ -21,11 +21,11 @@
#define NCU_ECONSTRAINTS (11)
/* Define flags to control what is included by ncuribuild*/
-#define NCURIPATH 1
-#define NCURIPWD 2
-#define NCURIQUERY 4
-#define NCURIFRAG 8
-#define NCURIENCODE 16 /* If output should be encoded */
+#define NCURIPATH 1
+#define NCURIPWD 2
+#define NCURIQUERY 4
+#define NCURIFRAG 8
+#define NCURIENCODE 16 /* If output should be encoded */
#define NCURIBASE (NCURIPWD|NCURIPATH)
#define NCURISVC (NCURIQUERY|NCURIBASE) /* for sending to server */
#define NCURIALL (NCURIPATH|NCURIPWD|NCURIQUERY|NCURIFRAG) /* for rebuilding after changes */
@@ -81,9 +81,13 @@ extern const char* ncurilookup(NCURI*, const char* param);
extern const char* ncuriquerylookup(NCURI*, const char* param);
/* URL Encode/Decode */
-extern char* ncuriencode(char* s, char* allowable);
extern char* ncuridecode(char* s);
-extern char* ncuridecodeonly(char* s, char*);
+/* Partial decode */
+extern char* ncuridecodepartial(char* s, const char* decodeset);
+/* Encode using specified character set */
+extern char* ncuriencodeonly(char* s, char* allowable);
+/* Encode user or pwd */
+extern char* ncuriencodeuserpwd(char* s);
#if defined(_CPLUSPLUS_) || defined(__CPLUSPLUS__) || defined(__CPLUSPLUS)
}
diff --git a/include/netcdf_meta.h.in b/include/netcdf_meta.h.in
index a50d0ae..0326d0f 100644
--- a/include/netcdf_meta.h.in
+++ b/include/netcdf_meta.h.in
@@ -48,6 +48,10 @@
#define NC_HAS_MMAP @NC_HAS_MMAP@ /*!< mmap support. */
#define NC_HAS_JNA @NC_HAS_JNA@ /*!< jna support. */
#define NC_HAS_PNETCDF @NC_HAS_PNETCDF@ /*!< pnetcdf support. */
-#define NC_HAS_PARALLEL @NC_HAS_PARALLEL@ /*!< parallel IO support via hdf5 and/or pnetcdf. */
+#define NC_HAS_PARALLEL @NC_HAS_PARALLEL@ /*!< parallel IO support via hdf5 and
+/or pnetcdf. */
+
+#define NC_HAS_CDF5 @NC_HAS_CDF5@ /*!< CDF5 support. */
+
#endif
diff --git a/libdap2/Makefile.in b/libdap2/Makefile.in
index 8af356b..a7d68d0 100644
--- a/libdap2/Makefile.in
+++ b/libdap2/Makefile.in
@@ -252,7 +252,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -287,7 +289,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/libdap4/Makefile.in b/libdap4/Makefile.in
index 8ae31f3..8453e4e 100644
--- a/libdap4/Makefile.in
+++ b/libdap4/Makefile.in
@@ -253,7 +253,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -288,7 +290,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/libdap4/d4curlflags.c b/libdap4/d4curlflags.c
index 56e36ba..641fa51 100644
--- a/libdap4/d4curlflags.c
+++ b/libdap4/d4curlflags.c
@@ -11,7 +11,9 @@ struct CURLFLAG curlopts[] = {
{"CURLOPT_PROXYUSERPWD",CURLOPT_PROXYUSERPWD,10006,CF_STRING},
{"CURLOPT_SSLCERT",CURLOPT_SSLCERT,10025,CF_STRING},
{"CURLOPT_SSLKEY",CURLOPT_SSLKEY,10087,CF_STRING},
+#ifdef HAVE_CURLOPT_KEYPASSWD
{"CURLOPT_SSLKEYPASSWD",CURLOPT_SSLKEYPASSWD,CURLOPT_KEYPASSWD,CF_STRING},
+#endif
{"CURLOPT_SSL_VERIFYHOST",CURLOPT_SSL_VERIFYHOST,81,CF_LONG},
{"CURLOPT_SSL_VERIFYPEER",CURLOPT_SSL_VERIFYPEER,64,CF_LONG},
{"CURLOPT_TIMEOUT",CURLOPT_TIMEOUT,13,CF_LONG},
diff --git a/libdap4/d4curlfunctions.c b/libdap4/d4curlfunctions.c
index 4fba4ad..df198d4 100644
--- a/libdap4/d4curlfunctions.c
+++ b/libdap4/d4curlfunctions.c
@@ -56,9 +56,11 @@ set_curlflag(NCD4INFO* state, int flag)
{
int ret = NC_NOERR;
switch (flag) {
- case CURLOPT_USERPWD:
- if(state->curl->creds.userpwd != NULL) {
- CHECK(state, CURLOPT_USERPWD, state->curl->creds.userpwd);
+ case CURLOPT_USERPWD: /* Do both user and pwd */
+ if(state->curl->creds.user != NULL
+ && state->curl->creds.pwd != NULL) {
+ CHECK(state, CURLOPT_USERNAME, state->curl->creds.user);
+ CHECK(state, CURLOPT_PASSWORD, state->curl->creds.pwd);
CHECK(state, CURLOPT_HTTPAUTH, (OPTARG)CURLAUTH_ANY);
}
break;
@@ -107,8 +109,10 @@ set_curlflag(NCD4INFO* state, int flag)
if(state->curl->proxy.host != NULL) {
CHECK(state, CURLOPT_PROXY, state->curl->proxy.host);
CHECK(state, CURLOPT_PROXYPORT, (OPTARG)(long)state->curl->proxy.port);
- if(state->curl->proxy.userpwd) {
- CHECK(state, CURLOPT_PROXYUSERPWD, state->curl->proxy.userpwd);
+ if(state->curl->proxy.user != NULL
+ && state->curl->proxy.pwd != NULL) {
+ CHECK(state, CURLOPT_PROXYUSERNAME, state->curl->proxy.user);
+ CHECK(state, CURLOPT_PROXYPASSWORD, state->curl->proxy.pwd);
#ifdef CURLOPT_PROXYAUTH
CHECK(state, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
#endif
@@ -264,6 +268,7 @@ NCD4_curl_protocols(NCD4globalstate* state)
}
+#if 0
/*
"Inverse" of set_curlflag;
Given a flag and value, it updates state.
@@ -349,6 +354,7 @@ NCD4_set_curlstate(NCD4INFO* state, int flag, void* value)
done:
return THROW(ret);
}
+#endif
void
NCD4_curl_printerror(NCD4INFO* state)
diff --git a/libdap4/d4curlfunctions.h b/libdap4/d4curlfunctions.h
index 0bfa739..cadecf5 100644
--- a/libdap4/d4curlfunctions.h
+++ b/libdap4/d4curlfunctions.h
@@ -6,6 +6,14 @@
#ifndef D4CURLFUNCTIONS_H
#define D4CURLFUNCTIONS_H
+/* Aliases to older names */
+#ifndef HAVE_CURLOPT_KEYPASSWD
+#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
+#endif
+#ifndef HAVE_CURLINFO_RESPONSE_CODE
+#define CURLINFO_RESPONSE_CODE CURLINFO_HTTP_CODE
+#endif
+
enum CURLFLAGTYPE {CF_UNKNOWN=0,CF_OTHER=1,CF_STRING=2,CF_LONG=3};
struct CURLFLAG {
const char* name;
@@ -20,7 +28,6 @@ extern ncerror NCD4_set_flags_perfetch(NCD4INFO*);
extern ncerror NCD4_set_flags_perlink(NCD4INFO*);
extern ncerror NCD4_set_curlflag(NCD4INFO*,int);
-extern ncerror NCD4_set_curlstate(NCD4INFO* state, int flag, void* value);
extern void NCD4_curl_debug(NCD4INFO* state);
diff --git a/libdap4/d4file.c b/libdap4/d4file.c
index 62f6a6e..058648a 100644
--- a/libdap4/d4file.c
+++ b/libdap4/d4file.c
@@ -115,25 +115,24 @@ NCD4_open(const char * path, int mode,
}
nc_set_default_format(new,&old); /* save and change */
ret = nc_create(tmpname,ncflags,&ncid);
-
nc_set_default_format(old,&new); /* restore */
d4info->substrate.realfile = ((ncflags & NC_DISKLESS) == 0);
d4info->substrate.filename = strdup(tmpname);
if(tmpname == NULL) ret = NC_ENOMEM;
d4info->substrate.nc4id = ncid;
}
- if(ret != NC_NOERR) goto done;
+ if(ret != NC_NOERR) goto done;
/* Avoid fill */
nc_set_fill(getnc4id(nc),NC_NOFILL,NULL);
}
/* Turn on logging; only do this after oc_open*/
if((value = ncurilookup(d4info->uri,"log")) != NULL) {
- ncloginit();
- if(nclogopen(value))
+ ncloginit();
+ if(nclogopen(value))
ncsetlogging(1);
- ncloginit();
- if(nclogopen(value))
+ ncloginit();
+ if(nclogopen(value))
ncsetlogging(1);
}
@@ -146,7 +145,7 @@ NCD4_open(const char * path, int mode,
/* create the connection */
if((ret=NCD4_curlopen(&curl))!= NC_NOERR) goto done;
d4info->curl->curl = curl;
- if((ret=set_curl_properties(d4info))!= NC_NOERR) goto done;
+ if((ret=set_curl_properties(d4info))!= NC_NOERR) goto done;
/* Set the one-time curl flags */
if((ret=NCD4_set_flags_perlink(d4info))!= NC_NOERR) goto done;
#if 1 /* temporarily make per-link */
@@ -309,7 +308,7 @@ freeInfo(NCD4INFO* d4info)
}
nullfree(d4info->substrate.filename); /* always reclaim */
NCD4_reclaimMeta(d4info->substrate.metadata);
- free(d4info);
+ free(d4info);
}
static void
@@ -328,8 +327,10 @@ freeCurl(NCD4curl* curl)
nullfree(curl->ssl.cainfo);
nullfree(curl->ssl.capath);
nullfree(curl->proxy.host);
- nullfree(curl->proxy.userpwd);
- nullfree(curl->creds.userpwd);
+ nullfree(curl->proxy.user);
+ nullfree(curl->proxy.pwd);
+ nullfree(curl->creds.user);
+ nullfree(curl->creds.pwd);
if(curl->curlflags.createdflags & COOKIECREATED)
d4removecookies(curl->curlflags.cookiejar);
nullfree(curl->curlflags.cookiejar);
@@ -471,7 +472,7 @@ applyclientparamcontrols(NCD4INFO* info)
}
static void
-applyclientmetacontrols(NCD4meta* meta)
+applyclientmetacontrols(NCD4meta* meta)
{
NCD4INFO* info = meta->controller;
const char* value = getparam(info,"checksummode");
diff --git a/libdap4/d4http.c b/libdap4/d4http.c
index e966de8..2b260f3 100644
--- a/libdap4/d4http.c
+++ b/libdap4/d4http.c
@@ -24,7 +24,7 @@ NCD4_fetchhttpcode(CURL* curl)
#ifdef HAVE_CURLINFO_RESPONSE_CODE
cstat = curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&httpcode);
#else
- cstat = curl_easy_getinfo(curl,CURLINFO_HTTP_CODE,&httpcode);
+ cstat = curl_easy_getinfo(curl,CURLINFO_HTTP_CONNECTCODE,&httpcode);
#endif
if(cstat != CURLE_OK) {
httpcode = 0;
@@ -321,7 +321,7 @@ curlerrtoncerr(CURLcode cstat)
switch (cstat) {
case CURLE_OK: return THROW(NC_NOERR);
case CURLE_URL_MALFORMAT:
- return THROW(NC_EURL);
+ return THROW(NC_EURL);
case CURLE_COULDNT_RESOLVE_HOST:
case CURLE_COULDNT_CONNECT:
case CURLE_REMOTE_ACCESS_DENIED:
@@ -338,5 +338,5 @@ curlerrtoncerr(CURLcode cstat)
case CURLE_SSL_CACERT_BADFILE:
default: break;
}
- return THROW(NC_ECURL);
+ return THROW(NC_ECURL);
}
diff --git a/libdap4/d4parser.c b/libdap4/d4parser.c
index 67f2b8e..dc56568 100644
--- a/libdap4/d4parser.c
+++ b/libdap4/d4parser.c
@@ -10,7 +10,7 @@
/**
* Implement the Dap4 Parser Using a DOM Parser
- *
+ *
* This code creates in internal representation of the netcdf-4 metadata
* to avoid having to make so many calls into the netcdf library.
*/
@@ -167,7 +167,7 @@ NCD4_parse(NCD4meta* metadata)
parser->vars = nclistnew();
#ifdef D4DEBUG
parser->debuglevel = 1;
-#endif
+#endif
/*Walk the DOM tree */
ret = traverse(parser,dom);
@@ -240,7 +240,7 @@ fillgroup(NCD4parser* parser, NCD4node* group, ezxml_t xml)
/* Extract subgroups*/
if((ret = parseGroups(parser,group,xml))) goto done;
/* Parse group level attributes */
- if((ret = parseAttributes(parser,group,xml))) goto done;
+ if((ret = parseAttributes(parser,group,xml))) goto done;
done:
return THROW(ret);
}
@@ -264,7 +264,7 @@ parseDimensions(NCD4parser* parser, NCD4node* group, ezxml_t xml)
dimnode->dim.size = (long long)size;
dimnode->dim.isunlimited = (unlimstr != NULL);
/* Process attributes */
- if((ret = parseAttributes(parser,dimnode,x))) goto done;
+ if((ret = parseAttributes(parser,dimnode,x))) goto done;
classify(group,dimnode);
}
done:
@@ -321,7 +321,7 @@ parseEconsts(NCD4parser* parser, NCD4node* en, ezxml_t xml)
FAIL(NC_EINVAL,"Enumeration Constant has no value");
if((ret=convertString(&ec->en.ecvalue,en->basetype,svalue)))
FAIL(NC_EINVAL,"Non-numeric Enumeration Constant: %s->%s",ec->name,svalue);
- PUSH(econsts,ec);
+ PUSH(econsts,ec);
}
en->en.econsts = econsts;
done:
@@ -377,9 +377,9 @@ parseMetaData(NCD4parser* parser, NCD4node* container, ezxml_t xml)
/* Process dimrefs */
if((ret=parseDimRefs(parser,container,xml))) goto done;
/* Process attributes */
- if((ret = parseAttributes(parser,container,xml))) goto done;
+ if((ret = parseAttributes(parser,container,xml))) goto done;
/* Process maps */
- if((ret = parseMaps(parser,container,xml))) goto done;
+ if((ret = parseMaps(parser,container,xml))) goto done;
done:
return THROW(ret);
}
@@ -411,7 +411,7 @@ parseStructure(NCD4parser* parser, NCD4node* container, ezxml_t xml, NCD4node**
SETNAME(type,fqnname);
/* Parse Fields into the type */
- if((ret = parseFields(parser,type,xml))) goto done;
+ if((ret = parseFields(parser,type,xml))) goto done;
/* Parse attributes, dims, and maps into the var */
if((ret = parseMetaData(parser,var,xml))) goto done;
@@ -505,7 +505,7 @@ parseSequence(NCD4parser* parser, NCD4node* container, ezxml_t xml, NCD4node** n
*/
if(parser->metadata->controller->controls.translation == NCD4_TRANSNC4) {
const char* vlentag = ezxml_attr(xml,UCARTAGVLEN);
- if(vlentag != NULL)
+ if(vlentag != NULL)
usevlen = 1;
} else
usevlen = 0;
@@ -525,7 +525,7 @@ parseSequence(NCD4parser* parser, NCD4node* container, ezxml_t xml, NCD4node** n
vlentype->basetype = var->basetype;
/* Use name <fqnname>_t */
strncpy(name,fqnname,sizeof(name));
- strncat(name,"_t",sizeof(name));
+ strncat(name,"_t",sizeof(name)-strlen(name));
SETNAME(vlentype,name);
/* Set the basetype */
var->basetype = vlentype;
@@ -540,16 +540,16 @@ parseSequence(NCD4parser* parser, NCD4node* container, ezxml_t xml, NCD4node** n
classify(group,structtype);
/* Use name <fqnname>_base */
strncpy(name,fqnname,sizeof(name));
- strncat(name,"_base",sizeof(name));
+ strncat(name,"_base",sizeof(name)-strlen(name));
SETNAME(structtype,name);
/* Parse Fields into type */
- if((ret = parseFields(parser,structtype,xml))) goto done;
+ if((ret = parseFields(parser,structtype,xml))) goto done;
/* Create a seq type whose basetype is the compound type */
if((ret=makeNode(parser,group,xml,NCD4_TYPE,NC_SEQ,&vlentype))) goto done;
classify(group,vlentype);
/* Use name <xname>_t */
strncpy(name,fqnname,sizeof(name));
- strncat(name,"_t",sizeof(name));
+ strncat(name,"_t",sizeof(name)-strlen(name));
SETNAME(vlentype,name);
vlentype->basetype = structtype;
/* Set the basetype */
@@ -589,7 +589,7 @@ parseGroups(NCD4parser* parser, NCD4node* parent, ezxml_t xml)
group->group.varbyid = nclistnew();
if((ret = fillgroup(parser,group,x))) goto done;
/* Parse group attributes */
- if((ret = parseAttributes(parser,group,x))) goto done;
+ if((ret = parseAttributes(parser,group,x))) goto done;
PUSH(parent->groups,group);
}
done:
@@ -605,13 +605,13 @@ parseAtomicVar(NCD4parser* parser, NCD4node* container, ezxml_t xml, NCD4node**
const char* typename;
KEYWORDINFO* info;
NCD4node* group;
-
+
/* Check for aliases */
for(typename=xml->name;;) {
info = keyword(typename);
if(info->aliasfor == NULL) break;
typename = info->aliasfor;
- }
+ }
group = NCD4_groupFor(container);
/* Locate its basetype; handle opaque and enum separately */
if(info->subsort == NC_ENUM) {
@@ -633,7 +633,7 @@ parseAtomicVar(NCD4parser* parser, NCD4node* container, ezxml_t xml, NCD4node**
classify(container,node);
node->basetype = base;
/* Parse attributes, dims, and maps */
- if((ret = parseMetaData(parser,node,xml))) goto done;
+ if((ret = parseMetaData(parser,node,xml))) goto done;
/* See if this var has UCARTAGORIGTYPE attribute */
if(parser->metadata->controller->controls.translation == NCD4_TRANSNC4) {
const char* typetag = ezxml_attr(xml,UCARTAGORIGTYPE);
@@ -719,7 +719,7 @@ parseAttributes(NCD4parser* parser, NCD4node* container, ezxml_t xml)
nclistpush(container->xmlattributes,strdup(p[0]));
nclistpush(container->xmlattributes,strdup(p[1]));
}
- }
+ }
}
}
@@ -818,7 +818,7 @@ getOpaque(NCD4parser* parser, ezxml_t varxml, NCD4node* group)
if((ret=defineBytestringType(parser)))
goto done;
assert(parser->metadata->_bytestring != NULL);
- opaquetype = parser->metadata->_bytestring;
+ opaquetype = parser->metadata->_bytestring;
} else {//(len > 0)
/* Try to locate existing opaque type with this length */
for(i=0;i<nclistlength(parser->types); i++) {
@@ -836,7 +836,7 @@ getOpaque(NCD4parser* parser, ezxml_t varxml, NCD4node* group)
SETNAME(opaquetype,name);
opaquetype->opaque.size = len;
if(opaquetype != NULL)
- record(parser,opaquetype);
+ record(parser,opaquetype);
}
}
done:
@@ -859,7 +859,7 @@ getValueStrings(NCD4parser* parser, NCD4node* type, ezxml_t xattr, NClist* svalu
char* ds;
/* We assume that either their is a single xml attribute called "value",
or there is a single chunk of text containing possibly multiple values.
- */
+ */
s = ezxml_attr(x,"value");
if(s == NULL) {/* See if there is a text part. */
s = x->txt;
@@ -920,7 +920,7 @@ splitOrigType(NCD4parser* parser, const char* fqn, NCD4node* type)
name = (char*)nclistpop(pieces);
if((ret = lookupFQNList(parser,pieces,NCD4_GROUP,&group))) goto done;
if(group == NULL) {
- FAIL(NC_ENOGRP,"Non-existent group in FQN: ",fqn);
+ FAIL(NC_ENOGRP,"Non-existent group in FQN: ",fqn);
}
type->nc4.orig.name = strdup(name+1); /* plus 1 to skip the leading separator */
type->nc4.orig.group = group;
@@ -941,7 +941,7 @@ NCD4_findAttr(NCD4node* container, const char* attrname)
NCD4node* attr = (NCD4node*)nclistget(container->attributes,i);
if(strcmp(attr->name,attrname)!=0) continue;
return attr;
- }
+ }
return NULL;
}
@@ -1016,13 +1016,13 @@ lookupFQNList(NCD4parser* parser, NClist* fqn, NCD4sort sort, NCD4node** result)
nsteps = nclistlength(fqn);
for(i=1;i<nsteps;i++) { /* start at 1 to side-step root name */
assert(ISGROUP(current->sort));
- name = (char*)nclistget(fqn,i);
+ name = (char*)nclistget(fqn,i);
/* See if we can find a matching subgroup */
node = lookFor(current->group.elements,name,NCD4_GROUP);
if(node == NULL)
break; /* reached the end of the group part of the fqn */
current = node;
- }
+ }
/* Invariant:
1. i == nsteps => node != null => last node was a group:
it must be our target
@@ -1058,11 +1058,11 @@ lookupFQNList(NCD4parser* parser, NClist* fqn, NCD4sort sort, NCD4node** result)
if(strcmp(field->name,name)==0)
{node = field; break;}
}
- if(node == NULL)
+ if(node == NULL)
goto sortfail; /* no match, so failed */
if(i == (nsteps - 1))
break;
- if(!ISCMPD(node->basetype->subsort))
+ if(!ISCMPD(node->basetype->subsort))
goto fail; /* more steps, but no compound field, so failed */
current = node->basetype;
}
@@ -1087,7 +1087,7 @@ lookFor(NClist* elems, const char* name, NCD4sort sort)
NCD4node* node = (NCD4node*)nclistget(elems,i);
if(strcmp(node->name,name) == 0 && (sort == node->sort))
return node;
- }
+ }
return NULL;
}
@@ -1103,7 +1103,7 @@ NCD4_printElems(NCD4node* group)
NCD4node* node = (NCD4node*)nclistget(elems,i);
fprintf(stderr,"name=%s sort=%d subsort=%d\n",
node->name,node->sort,node->subsort);
- }
+ }
fflush(stderr);
}
@@ -1163,7 +1163,7 @@ defineBytestringType(NCD4parser* parser)
parser->metadata->_bytestring = bstring;
} else
bstring = parser->metadata->_bytestring;
-done:
+done:
return THROW(ret);
}
@@ -1173,7 +1173,7 @@ defineAtomicTypes(NCD4parser* parser)
int ret = NC_NOERR;
NCD4node* node;
struct ATOMICTYPEINFO* ati;
-
+
parser->atomictypes = nclistnew();
if(parser->atomictypes == NULL)
return THROW(NC_ENOMEM);
@@ -1475,7 +1475,7 @@ valueParse(NCD4node* type, const char* values0, NClist* vlist)
*p++ = '\0';
if(*q == '\r') {*q = '\0';}
nclistpush(vlist,strdup(line));
- }
+ }
break;
case NC_CHAR:
p = values;
@@ -1494,7 +1494,7 @@ valueParse(NCD4node* type, const char* values0, NClist* vlist)
c[1] = '\0';
nclistpush(vlist,strdup(c));
}
- }
+ }
break;
default:
p = values;
diff --git a/libdap4/d4rc.c b/libdap4/d4rc.c
index 93a4443..4788099 100644
--- a/libdap4/d4rc.c
+++ b/libdap4/d4rc.c
@@ -16,15 +16,17 @@
#define MEMCHECK(x) if((x)==NULL) {goto nomem;} else {}
/* Forward */
-static char* extract_credentials(NCURI*);
static int rccompile(const char* path);
static struct NCD4triple* rclocate(char* key, char* hostport);
-static void rcorder(NClist* rc);
+static NClist* rcorder(NClist* rc);
static char* rcreadline(char**);
static int rcsearch(const char* prefix, const char* rcname, char** pathp);
static void rctrim(char* text);
-static void storedump(char* msg, NClist* triples);
static int rcsetinfocurlflag(NCD4INFO*, const char* flag, const char* value);
+static int parsecredentials(const char* userpwd, char** userp, char** pwdp);
+#ifdef D4DEBUG
+static void storedump(char* msg, NClist* triples);
+#endif
/* Define default rc files and aliases, also defines search order*/
static char* rcfilenames[] = {".daprc",".dodsrc",NULL};
@@ -78,28 +80,35 @@ rctrim(char* text)
}
}
-/* Order the triples: put all those with urls first */
-static void
+/* Order the triples: those with urls must be first,
+ but otherwise relative order does not matter.
+*/
+static NClist*
rcorder(NClist* rc)
{
int i,j;
int len = nclistlength(rc);
- if(rc == NULL || len == 0) return;
+ NClist* newrc = nclistnew();
+ if(rc == NULL || len == 0) return newrc;
+ /* Two passes: 1) pull triples with host */
+ for(i=0;i<len;i++) {
+ NCD4triple* ti = nclistget(rc,i);
+ if(ti->host == NULL) continue;
+ nclistpush(newrc,ti);
+ }
+ /* pass 2 pull triples without host*/
for(i=0;i<len;i++) {
- NCD4triple* ti = nclistget(rc,i);
+ NCD4triple* ti = nclistget(rc,i);
if(ti->host != NULL) continue;
- for(j=i;j<len;j++) {
- NCD4triple* tj = nclistget(rc,j);
- if(tj->host != NULL) {/*swap*/
- NCD4triple* t = ti;
- nclistset(rc,i,tj);
- nclistset(rc,j,t);
- }
- }
+ nclistpush(newrc,ti);
}
- storedump("reorder:",rc);
-}
+#ifdef D4DEBUG
+ storedump("reorder:",newrc);
+#endif
+ return newrc;
+
+}
/* Create a triple store from a file */
static int
@@ -369,10 +378,15 @@ rcsetinfocurlflag(NCD4INFO* info, const char* flag, const char* value)
#endif
}
- if(strcmp(flag,"HTTP.CREDENTIALS.USERPASSWORD")==0) {
- nullfree(info->curl->creds.userpwd);
- info->curl->creds.userpwd = strdup(value);
- MEMCHECK(info->curl->creds.userpwd);
+ if(strcmp(flag,"HTTP.CREDENTIALS.USERNAME")==0) {
+ nullfree(info->curl->creds.user);
+ info->curl->creds.user = strdup(value);
+ MEMCHECK(info->curl->creds.user);
+ }
+ if(strcmp(flag,"HTTP.CREDENTIALS.PASSWORD")==0) {
+ nullfree(info->curl->creds.pwd);
+ info->curl->creds.pwd = strdup(value);
+ MEMCHECK(info->curl->creds.pwd);
}
done:
@@ -386,9 +400,7 @@ int
NCD4_rcprocess(NCD4INFO* info)
{
int ret = NC_NOERR;
- char userpwd[NC_MAX_PATH];
char hostport[NC_MAX_PATH];
- char* url_userpwd = userpwd; /* WATCH OUT: points to previous variable */
char* url_hostport = hostport; /* WATCH OUT: points to previous variable */
NCURI* uri = info->uri;
@@ -399,15 +411,12 @@ NCD4_rcprocess(NCD4INFO* info)
/* Note, we still must do this function even if
NCD4_globalstate->rc.ignore is set in order
- to getinfo e.g. user:pwd from url
+ to getinfo e.g. host+port from url
*/
+ url_hostport = NULL;
if(uri != NULL) {
- NCD4_userpwd(uri,url_userpwd,sizeof(userpwd));
NCD4_hostport(uri,url_hostport,sizeof(hostport));
- } else {
- url_hostport = NULL;
- url_userpwd = NULL;
}
rcsetinfocurlflag(info,"HTTP.DEFLATE",
@@ -446,29 +455,38 @@ NCD4_rcprocess(NCD4INFO* info)
NCD4_rclookup("HTTP.NETRC",url_hostport));
{ /* Handle various cases for user + password */
/* First, see if the user+pwd was in the original url */
- char* userpwd = NULL;
char* user = NULL;
char* pwd = NULL;
- if(url_userpwd != NULL)
- userpwd = url_userpwd;
- else {
+ if(uri->user != NULL && uri->password != NULL) {
+ user = uri->user;
+ pwd = uri->password;
+ } else {
user = NCD4_rclookup("HTTP.CREDENTIALS.USER",url_hostport);
pwd = NCD4_rclookup("HTTP.CREDENTIALS.PASSWORD",url_hostport);
- userpwd = NCD4_rclookup("HTTP.CREDENTIALS.USERPASSWORD",url_hostport);
}
- if(userpwd == NULL && user != NULL && pwd != NULL) {
- char creds[NC_MAX_PATH];
- strncpy(creds,user,sizeof(creds));
- strncat(creds,":",sizeof(creds));
- strncat(creds,pwd,sizeof(creds));
- rcsetinfocurlflag(info,"HTTP.USERPASSWORD",creds);
- } else if(userpwd != NULL)
- rcsetinfocurlflag(info,"HTTP.USERPASSWORD",userpwd);
+ if(user != NULL && pwd != NULL) {
+ user = strdup(user); /* so we can consistently reclaim */
+ pwd = strdup(pwd);
+ } else {
+ /* Could not get user and pwd, so try USERPASSWORD */
+ const char* userpwd = NCD4_rclookup("HTTP.CREDENTIALS.USERPASSWORD",url_hostport);
+ if(userpwd != NULL) {
+ ret = parsecredentials(userpwd,&user,&pwd);
+ if(ret) return ret;
+ }
+ }
+ rcsetinfocurlflag(info,"HTTP.USERNAME",user);
+ rcsetinfocurlflag(info,"HTTP.PASSWORD",pwd);
+ nullfree(user);
+ nullfree(pwd);
}
-
return THROW(ret);
}
+/**
+ * (Internal) Locate a triple by property key and host+port (may be null or "").
+ * If duplicate keys, first takes precedence.
+ */
static struct NCD4triple*
rclocate(char* key, char* hostport)
{
@@ -499,6 +517,10 @@ rclocate(char* key, char* hostport)
return (found?triple:NULL);
}
+/**
+ * Locate a triple by property key and host+port (may be null|"")
+ * If duplicate keys, first takes precedence.
+ */
char*
NCD4_rclookup(char* key, char* hostport)
{
@@ -506,6 +528,7 @@ NCD4_rclookup(char* key, char* hostport)
return (triple == NULL ? NULL : triple->value);
}
+#ifdef D4DEBUG
static void
storedump(char* msg, NClist* triples)
{
@@ -519,12 +542,16 @@ storedump(char* msg, NClist* triples)
for(i=0;i<nclistlength(triples);i++) {
NCD4triple* t = (NCD4triple*)nclistget(triples,i);
fprintf(stderr,"\t%s\t%s\t%s\n",
- (strlen(t->host)==0?"--":t->host),t->key,t->value);
+
+ ((t->host == NULL || strlen(t->host)==0)?"--":t->host),t->key,t->value);
+
}
fflush(stderr);
}
+#endif
/**
+ * Locate rc file by searching in directory prefix.
* Prefix must end in '/'
*/
static
@@ -586,7 +613,8 @@ NCD4_parseproxy(NCD4INFO* info, const char* surl)
return THROW(NC_NOERR); /* nothing there*/
if(ncuriparse(surl,&uri) != NCU_OK)
return THROW(NC_EURL);
- info->curl->proxy.userpwd = extract_credentials(uri);
+ info->curl->proxy.user = uri->user;
+ info->curl->proxy.pwd = uri->password;
info->curl->proxy.host = strdup(uri->host);
if(uri->port != NULL)
info->curl->proxy.port = atoi(uri->port);
@@ -595,15 +623,32 @@ NCD4_parseproxy(NCD4INFO* info, const char* surl)
return THROW(ret);
}
-/* Caller must free result_url */
-static char*
-extract_credentials(NCURI* url)
+/*
+Given form user:pwd, parse into user and pwd
+and do %xx unescaping
+*/
+static int
+parsecredentials(const char* userpwd, char** userp, char** pwdp)
{
- char tmp[NC_MAX_PATH];
- if(url->user == NULL || url->password == NULL)
- return NULL;
- NCD4_userpwd(url,tmp,sizeof(tmp));
- return strdup(tmp);
+ char* user = NULL;
+ char* pwd = NULL;
+
+ if(userpwd == NULL)
+ return NC_EINVAL;
+ user = strdup(userpwd);
+ if(user == NULL)
+ return NC_ENOMEM;
+ pwd = strchr(user,':');
+ if(pwd == NULL)
+ return NC_EINVAL;
+ *pwd = '\0';
+ pwd++;
+ if(userp)
+ *userp = ncuridecode(user);
+ if(pwdp)
+ *pwdp = ncuridecode(pwd);
+ free(user);
+ return NC_NOERR;
}
int
diff --git a/libdap4/d4util.c b/libdap4/d4util.c
index 1f09cea..59e6c65 100644
--- a/libdap4/d4util.c
+++ b/libdap4/d4util.c
@@ -108,7 +108,7 @@ NCD4_makeFQN(NCD4node* node)
size_t estimate;
for(estimate=0;g != NULL;g=g->container) {
- estimate += strlen(g->name);
+ estimate += strlen(g->name);
nclistinsert(path,0,g);
}
estimate = (estimate*2) + 2*nclistlength(path);
@@ -132,7 +132,7 @@ NCD4_makeFQN(NCD4node* node)
int last = nclistlength(path)-1;
NCD4node* n = (NCD4node*)nclistget(path,last);
char* name = NCD4_makeName(n,".");
- strcat(fqn,"/");
+ strcat(fqn,"/");
strcat(fqn,name);
nullfree(name);
}
@@ -162,7 +162,7 @@ NCD4_makeName(NCD4node* elem, const char* sep)
}
fqn = (char*)malloc(estimate+1);
- if(fqn == NULL) goto done;
+ if(fqn == NULL) goto done;
fqn[0] = '\0';
for(i=0;i<nclistlength(path);i++) {
@@ -247,7 +247,7 @@ NCD4_parseFQN(const char* fqn0, NClist* pieces)
p+=2;
break;
case '.': /*capture the piece name */
- *p++ = '\0';
+ *p++ = '\0';
start = p;
count++;
break;
@@ -263,7 +263,7 @@ NCD4_parseFQN(const char* fqn0, NClist* pieces)
char* descaped = NCD4_deescape(p);
nclistpush(pieces,descaped);
p = p + strlen(p) + 1; /* skip past the terminating nul */
- }
+ }
if(fqn != NULL) free(fqn);
return THROW(ret);
}
@@ -363,7 +363,7 @@ NCD4_mktmp(const char* base, char** tmpnamep)
strncpy(tmp,base,sizeof(tmp));
#ifdef HAVE_MKSTEMP
- strncat(tmp,"XXXXXX",sizeof(tmp));
+ strncat(tmp,"XXXXXX",sizeof(tmp)-strlen(tmp));
/* Note Potential problem: old versions of this function
leave the file in mode 0666 instead of 0600 */
mask=umask(0077);
@@ -376,7 +376,7 @@ NCD4_mktmp(const char* base, char** tmpnamep)
char spid[7];
if(rno < 0) rno = -rno;
snprintf(spid,sizeof(spid),"%06d",rno);
- strncat(tmp,spid,sizeof(tmp));
+ strncat(tmp,spid,sizeof(tmp));
#if defined(_WIN32) || defined(_WIN64)
fd=open(tmp,O_RDWR|O_BINARY|O_CREAT, _S_IREAD|_S_IWRITE);
# else
@@ -385,7 +385,7 @@ NCD4_mktmp(const char* base, char** tmpnamep)
}
#endif /* !HAVE_MKSTEMP */
if(fd < 0) {
- nclog(NCLOGERR, "Could not create temp file: %s",tmp);
+ nclog(NCLOGERR, "Could not create temp file: %s",tmp);
return THROW(NC_EPERM);
} else
close(fd);
@@ -408,6 +408,7 @@ NCD4_hostport(NCURI* uri, char* space, size_t len)
}
}
+#if 0
void
NCD4_userpwd(NCURI* uri, char* space, size_t len)
{
@@ -420,6 +421,7 @@ NCD4_userpwd(NCURI* uri, char* space, size_t len)
}
}
}
+#endif
#ifdef BLOB
void
@@ -451,4 +453,3 @@ NCD4_errorNC(int code, const int line, const char* file)
{
return NCD4_error(code,line,file,nc_strerror(code));
}
-
diff --git a/libdap4/ncd4.h b/libdap4/ncd4.h
index 92b680e..2c47e55 100644
--- a/libdap4/ncd4.h
+++ b/libdap4/ncd4.h
@@ -129,7 +129,6 @@ extern int NCD4_getToplevelVars(NCD4meta* meta, NCD4node* group, NClist* topleve
/* From d4util.c */
extern d4size_t NCD4_dimproduct(NCD4node* node);
extern void NCD4_hostport(NCURI* uri, char* space, size_t len);
-extern void NCD4_userpwd(NCURI* uri, char* space, size_t len);
extern size_t NCD4_typesize(nc_type tid);
extern int NCD4_isLittleEndian(void);/* Return 1 if this machine is little endian */
extern int NCD4_errorNC(int code, const int line, const char* file);
diff --git a/libdap4/ncd4types.h b/libdap4/ncd4types.h
index d77578a..1043758 100644
--- a/libdap4/ncd4types.h
+++ b/libdap4/ncd4types.h
@@ -325,10 +325,12 @@ struct NCD4curl {
struct proxy {
char *host; /*CURLOPT_PROXY*/
int port; /*CURLOPT_PROXYPORT*/
- char* userpwd; /*CURLOPT_PROXYUSERPWD*/
+ char* user; /*CURLOPT_PROXYUSERNAME*/
+ char* pwd; /*CURLOPT_PROXYPASSWORD*/
} proxy;
struct credentials {
- char *userpwd; /*CURLOPT_USERPWD*/
+ char *user; /*CURLOPT_USERNAME*/
+ char *pwd; /*CURLOPT_PASSWORD*/
} creds;
};
diff --git a/libdispatch/Makefile.in b/libdispatch/Makefile.in
index ca8a2f4..5a1bc52 100644
--- a/libdispatch/Makefile.in
+++ b/libdispatch/Makefile.in
@@ -493,7 +493,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -528,7 +530,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c
index 2ac53d9..7f95c31 100644
--- a/libdispatch/dfile.c
+++ b/libdispatch/dfile.c
@@ -104,10 +104,12 @@ NC_interpret_magic_number(char* magic, int* model, int* version, int use_paralle
} else if(magic[3] == '\002') {
*version = 2; /* netcdf classic version 2 */
*model = NC_FORMATX_NC3;
- } else if(magic[3] == '\005') {
- *version = 5; /* cdf5 (including pnetcdf) file */
+#ifdef USE_CDF5
+ } else if(magic[3] == '\005') {
+ *version = 5; /* cdf5 (including pnetcdf) file */
*model = NC_FORMATX_NC3;
- } else
+#endif
+ } else
{status = NC_ENOTNC; goto done;}
} else
{status = NC_ENOTNC; goto done;}
@@ -1720,11 +1722,13 @@ fprintf(stderr,"XXX: path0=%s path=%s\n",path0,path); fflush(stderr);
model = NC_FORMATX_NC4;
break;
#endif
+#ifdef USE_CDF5
case NC_FORMAT_CDF5:
xcmode |= NC_64BIT_DATA;
model = NC_FORMATX_NC3;
break;
- case NC_FORMAT_64BIT_OFFSET:
+#endif
+ case NC_FORMAT_64BIT_OFFSET:
xcmode |= NC_64BIT_OFFSET;
model = NC_FORMATX_NC3;
break;
diff --git a/libdispatch/drc.c b/libdispatch/drc.c
index f47ef46..b953042 100644
--- a/libdispatch/drc.c
+++ b/libdispatch/drc.c
@@ -1,7 +1,7 @@
-/*********************************************************************
- * Copyright 2016, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *********************************************************************/
+/*
+Copyright (c) 1998-2017 University Corporation for Atmospheric Research/Unidata
+See LICENSE.txt for license information.
+*/
#include "config.h"
#ifdef HAVE_UNISTD_H
diff --git a/libdispatch/nchashmap.c b/libdispatch/nchashmap.c
index 1ab610a..cd8b71c 100644
--- a/libdispatch/nchashmap.c
+++ b/libdispatch/nchashmap.c
@@ -65,14 +65,14 @@ nchashinsert(NChashmap* hm, nchashid hash, void* value)
NClist* seq;
void** list;
- offset = (hash % hm->alloc);
+ offset = (hash % hm->alloc);
seq = hm->table[offset];
if(seq == NULL) {seq = nclistnew(); hm->table[offset] = seq;}
len = nclistlength(seq);
list = nclistcontents(seq);
for(i=0;i<len;i+=2,list+=2) {
if(hash==(nchashid)(*list)) return FALSE;
- }
+ }
nclistpush(seq,(void*)hash);
nclistpush(seq,value);
hm->size++;
@@ -89,14 +89,14 @@ nchashreplace(NChashmap* hm, nchashid hash, void* value)
NClist* seq;
void** list;
- offset = (hash % hm->alloc);
+ offset = (hash % hm->alloc);
seq = hm->table[offset];
if(seq == NULL) {seq = nclistnew(); hm->table[offset] = seq;}
len = nclistlength(seq);
list = nclistcontents(seq);
for(i=0;i<len;i+=2,list+=2) {
if(hash==(nchashid)(*list)) {list[1] = value; return TRUE;}
- }
+ }
nclistpush(seq,(void*)hash);
nclistpush(seq,value);
hm->size++;
@@ -113,7 +113,7 @@ nchashremove(NChashmap* hm, nchashid hash)
NClist* seq;
void** list;
- offset = (hash % hm->alloc);
+ offset = (hash % hm->alloc);
seq = hm->table[offset];
if(seq == NULL) return TRUE;
len = nclistlength(seq);
@@ -126,7 +126,7 @@ nchashremove(NChashmap* hm, nchashid hash)
if(nclistlength(seq) == 0) {nclistfree(seq); hm->table[offset] = NULL;}
return TRUE;
}
- }
+ }
return FALSE;
}
@@ -135,7 +135,7 @@ nchashremove(NChashmap* hm, nchashid hash)
void*
nchashget(NChashmap* hm, nchashid hash)
{
- void* value;
+ void* value = NULL;
if(!nchashlookup(hm,hash,&value)) return NULL;
return value;
}
@@ -148,7 +148,7 @@ nchashlookup(NChashmap* hm, nchashid hash, void** valuep)
NClist* seq;
void** list;
- offset = (hash % hm->alloc);
+ offset = (hash % hm->alloc);
seq = hm->table[offset];
if(seq == NULL) return TRUE;
len = nclistlength(seq);
@@ -194,14 +194,13 @@ nchashkeys(NChashmap* hm, nchashid** keylist)
keys = (nchashid*)malloc(sizeof(nchashid)*hm->size);
for(index=0,i=0;i<hm->alloc;i++) {
NClist* seq = hm->table[i];
- for(j=0;j<nclistlength(seq);j+=2) {
+ for(j=0;j<nclistlength(seq);j+=2) {
keys[index++] = (nchashid)nclistget(seq,j);
}
}
}
if(keylist) {*keylist = keys;}
else {free(keys);}
-
+
return TRUE;
}
-
diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c
index 7acf16e..fe80097 100644
--- a/libdispatch/ncuri.c
+++ b/libdispatch/ncuri.c
@@ -63,6 +63,10 @@ static char* pathallow =
static char* queryallow =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$&'()*+,-./:;=?@_~";
+/* user+pwd allow = path allow - "@:" */
+static char* userpwdallow =
+"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!$&'()*+,-.;=_~?#/";
+
#ifndef HAVE_STRNCMP
#define strndup ncstrndup
/* Not all systems have strndup, so provide one*/
@@ -345,8 +349,13 @@ ncuriparse(const char* uri0, NCURI** durip)
/* save original uri */
duri->uri = strdup(uri0);
duri->protocol = nulldup(tmp.protocol);
- duri->user = nulldup(tmp.user);
- duri->password = nulldup(tmp.password);
+ /* before saving, we need to decode the user+pwd */
+ duri->user = NULL;
+ duri->password = NULL;
+ if(tmp.user != NULL)
+ duri->user = ncuridecode(tmp.user);
+ if(tmp.password != NULL)
+ duri->password = ncuridecode(tmp.password);
duri->host = nulldup(tmp.host);
duri->port = nulldup(tmp.port);
if(tmp.path != NULL) {
@@ -530,9 +539,14 @@ ncuribuild(NCURI* duri, const char* prefix, const char* suffix, int flags)
ncbytescat(buf,"://"); /* this will produce file:///... */
if((flags & NCURIPWD) && duri->user != NULL && duri->password != NULL) {
- ncbytescat(buf,duri->user);
+ /* The user and password must be encoded */
+ char* encoded = ncuriencodeonly(duri->user,userpwdallow);
+ ncbytescat(buf,encoded);
+ nullfree(encoded);
ncbytescat(buf,":");
- ncbytescat(buf,duri->password);
+ encoded = ncuriencodeonly(duri->password,userpwdallow);
+ ncbytescat(buf,encoded);
+ nullfree(encoded);
ncbytescat(buf,"@");
}
if(duri->host != NULL) ncbytescat(buf,duri->host);
@@ -544,7 +558,7 @@ ncuribuild(NCURI* duri, const char* prefix, const char* suffix, int flags)
if(duri->path == NULL)
ncbytescat(buf,"/");
else if(encode) {
- char* encoded = ncuriencode(duri->path,pathallow);
+ char* encoded = ncuriencodeonly(duri->path,pathallow);
ncbytescat(buf,encoded);
nullfree(encoded);
} else
@@ -566,7 +580,7 @@ ncuribuild(NCURI* duri, const char* prefix, const char* suffix, int flags)
if(p[1] != NULL && strlen(p[1]) > 0) {
ncbytescat(buf,"=");
if(encode) {
- char* encoded = ncuriencode(p[1],queryallow);
+ char* encoded = ncuriencodeonly(p[1],queryallow);
ncbytescat(buf,encoded);
nullfree(encoded);
} else
@@ -583,7 +597,7 @@ ncuribuild(NCURI* duri, const char* prefix, const char* suffix, int flags)
if(p[1] != NULL && strlen(p[1]) > 0) {
ncbytescat(buf,"=");
if(encode) {
- char* encoded = ncuriencode(p[1],queryallow);
+ char* encoded = ncuriencodeonly(p[1],queryallow);
ncbytescat(buf,encoded);
nullfree(encoded);
} else
@@ -720,8 +734,8 @@ static char* hexchars = "0123456789abcdefABCDEF";
static void
toHex(unsigned int b, char hex[2])
{
- hex[0] = hexchars[(b >> 4) & 0xff];
- hex[1] = hexchars[(b) & 0xff];
+ hex[0] = hexchars[(b >> 4) & 0xf];
+ hex[1] = hexchars[(b) & 0xf];
}
@@ -734,6 +748,14 @@ fromHex(int c)
return 0;
}
+/*
+Support encode of user and password fields
+*/
+char*
+ncuriencodeuserpwd(char* s)
+{
+ return ncuriencodeonly(s,userpwdallow);
+}
/* Return a string representing encoding of input; caller must free;
watch out: will encode whole string, so watch what you give it.
@@ -741,7 +763,7 @@ fromHex(int c)
*/
char*
-ncuriencode(char* s, char* allowable)
+ncuriencodeonly(char* s, char* allowable)
{
size_t slen;
char* encoded;
@@ -760,12 +782,10 @@ ncuriencode(char* s, char* allowable)
} else {
/* search allowable */
int c2;
- char* a = allowable;
- while((c2=*a++)) {
- if(c == c2) break;
- }
- if(c2) {*outptr++ = (char)c;}
- else {
+ char* p = strchr(allowable,c);
+ if(p != NULL) {
+ *outptr++ = (char)c;
+ } else {
char hex[2];
toHex(c,hex);
*outptr++ = '%';
@@ -782,14 +802,43 @@ ncuriencode(char* s, char* allowable)
char*
ncuridecode(char* s)
{
- return ncuridecodeonly(s,NULL);
+ size_t slen;
+ char* decoded;
+ char* outptr;
+ char* inptr;
+ unsigned int c;
+
+ if (s == NULL) return NULL;
+
+ slen = strlen(s);
+ decoded = (char*)malloc(slen+1); /* Should be max we need */
+
+ outptr = decoded;
+ inptr = s;
+ while((c = (unsigned int)*inptr++)) {
+ if(c == '%') {
+ /* try to pull two hex more characters */
+ if(inptr[0] != EOFCHAR && inptr[1] != EOFCHAR
+ && strchr(hexchars,inptr[0]) != NULL
+ && strchr(hexchars,inptr[1]) != NULL) {
+ /* test conversion */
+ int xc = (fromHex(inptr[0]) << 4) | (fromHex(inptr[1]));
+ inptr += 2; /* decode it */
+ c = (unsigned int)xc;
+ }
+ }
+ *outptr++ = (char)c;
+ }
+ *outptr = EOFCHAR;
+ return decoded;
}
-/* Return a string representing decoding of input only for specified
- characters; caller must free
+/*
+Partially decode a string. Only characters in 'decodeset'
+are decoded. Return decoded string; caller must free.
*/
char*
-ncuridecodeonly(char* s, char* only)
+ncuridecodepartial(char* s, const char* decodeset)
{
size_t slen;
char* decoded;
@@ -797,7 +846,7 @@ ncuridecodeonly(char* s, char* only)
char* inptr;
unsigned int c;
- if (s == NULL) return NULL;
+ if (s == NULL || decodeset == NULL) return NULL;
slen = strlen(s);
decoded = (char*)malloc(slen+1); /* Should be max we need */
@@ -805,7 +854,7 @@ ncuridecodeonly(char* s, char* only)
outptr = decoded;
inptr = s;
while((c = (unsigned int)*inptr++)) {
- if(c == '+' && only != NULL && strchr(only,'+') != NULL)
+ if(c == '+' && strchr(decodeset,'+') != NULL)
*outptr++ = ' ';
else if(c == '%') {
/* try to pull two hex more characters */
@@ -814,13 +863,14 @@ ncuridecodeonly(char* s, char* only)
&& strchr(hexchars,inptr[1]) != NULL) {
/* test conversion */
int xc = (fromHex(inptr[0]) << 4) | (fromHex(inptr[1]));
- if(only == NULL || strchr(only,xc) != NULL) {
+ if(strchr(decodeset,xc) != NULL) {
inptr += 2; /* decode it */
c = (unsigned int)xc;
- }
+ }
}
- }
- *outptr++ = (char)c;
+ *outptr++ = (char)c; /* pass either the % or decoded char */
+ } else /* Not a % char */
+ *outptr++ = (char)c;
}
*outptr = EOFCHAR;
return decoded;
diff --git a/liblib/Makefile.in b/liblib/Makefile.in
index b3d8f34..4c25a90 100644
--- a/liblib/Makefile.in
+++ b/liblib/Makefile.in
@@ -296,7 +296,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -331,7 +333,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/libnetcdf.settings.in b/libnetcdf.settings.in
index 7284fdf..6983922 100644
--- a/libnetcdf.settings.in
+++ b/libnetcdf.settings.in
@@ -34,3 +34,4 @@ DAP4 Support: @HAS_DAP4@
Diskless Support: @HAS_DISKLESS@
MMap Support: @HAS_MMAP@
JNA Support: @HAS_JNA@
+CDF5 Support: @HAS_CDF5@
diff --git a/libsrc/Makefile.in b/libsrc/Makefile.in
index 02b54b3..63a2b7a 100644
--- a/libsrc/Makefile.in
+++ b/libsrc/Makefile.in
@@ -293,7 +293,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -328,7 +330,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c
index 03a4835..da58f35 100644
--- a/libsrc/nc3internal.c
+++ b/libsrc/nc3internal.c
@@ -95,9 +95,12 @@ err:
int
nc3_cktype(int mode, nc_type type)
{
+#ifdef USE_CDF5
if (mode & NC_CDF5) { /* CDF-5 format */
if (type >= NC_BYTE && type < NC_STRING) return NC_NOERR;
- } else if (mode & NC_64BIT_OFFSET) { /* CDF-2 format */
+ } else
+#endif
+ if (mode & NC_64BIT_OFFSET) { /* CDF-2 format */
if (type >= NC_BYTE && type <= NC_DOUBLE) return NC_NOERR;
} else if ((mode & NC_64BIT_OFFSET) == 0) { /* CDF-1 format */
if (type >= NC_BYTE && type <= NC_DOUBLE) return NC_NOERR;
@@ -1086,8 +1089,11 @@ nc_set_default_format(int format, int *old_formatp)
format != NC_FORMAT_NETCDF4 && format != NC_FORMAT_NETCDF4_CLASSIC)
return NC_EINVAL;
#else
- if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET &&
- format != NC_FORMAT_CDF5)
+ if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET
+#ifdef USE_CDF5
+ && format != NC_FORMAT_CDF5
+#endif
+ )
return NC_EINVAL;
#endif
default_create_format = format;
@@ -1582,9 +1588,12 @@ NC3_inq_format(int ncid, int *formatp)
nc3 = NC3_DATA(nc);
/* only need to check for netCDF-3 variants, since this is never called for netCDF-4 files */
+#ifdef USE_CDF5
if (fIsSet(nc3->flags, NC_64BIT_DATA))
*formatp = NC_FORMAT_CDF5;
- else if (fIsSet(nc3->flags, NC_64BIT_OFFSET))
+ else
+#endif
+ if (fIsSet(nc3->flags, NC_64BIT_OFFSET))
*formatp = NC_FORMAT_64BIT_OFFSET;
else
*formatp = NC_FORMAT_CLASSIC;
diff --git a/libsrc/ncx.c b/libsrc/ncx.c
index 6033f8d..78208c4 100644
--- a/libsrc/ncx.c
+++ b/libsrc/ncx.c
@@ -13,17 +13,18 @@
#line 22
+#line 26
-#line 31
+#line 34
-#line 38
+#line 41
-#line 38
+#line 41
#if HAVE_CONFIG_H
-#line 38
+#line 41
#include <config.h>
-#line 38
+#line 41
#endif
#include <stdio.h>
@@ -31,16 +32,16 @@
#include <string.h>
#include <limits.h>
-#line 50
+#line 53
-#line 50
+#line 53
#pragma GCC diagnostic ignored "-Wdeprecated"
-#line 50
+#line 53
#include "ncx.h"
-#line 50
+#line 53
#include "nc3dispatch.h"
-#line 69
+#line 72
@@ -51,9 +52,9 @@
#include <stdint.h> /* uint16_t, uint32_t, uint64_t */
#endif
-#line 97
+#line 103
-#line 115
+#line 121
/*
* The only error code returned from subroutines in this file is NC_ERANGE,
@@ -532,26 +533,26 @@ swapn8b(void *dst, const void *src, size_t nn)
#endif /* LITTLE_ENDIAN */
-#line 616
+#line 622
-#line 620
+#line 626
-#line 630
+#line 638
-#line 643
+#line 653
/*
* Primitive numeric conversion functions.
*/
-#line 671
+#line 681
-#line 715
+#line 729
-#line 742
+#line 762
-#line 782
+#line 808
/* x_schar */
/* x_uchar */
@@ -605,427 +606,531 @@ put_ix_short(void *xp, const ix_short *ip)
}
static int
-#line 834
+#line 860
ncx_get_short_schar(const void *xp, schar *ip)
-#line 834
+#line 860
{
-#line 834
+#line 860
int err=NC_NOERR;
-#line 834
+#line 860
ix_short xx;
-#line 834
+#line 860
get_ix_short(xp, &xx);
-#line 834
+#line 860
-#line 834
+#line 860
#if IX_SHORT_MAX > SCHAR_MAX
-#line 834
+#line 860
if (xx > SCHAR_MAX || xx < SCHAR_MIN) {
-#line 834
-
-#line 834
+#line 860
+#ifdef ERANGE_FILL
+#line 860
+ *ip = NC_FILL_BYTE;
+#line 860
+ return NC_ERANGE;
+#line 860
+#else
+#line 860
err = NC_ERANGE;
-#line 834
+#line 860
+#endif
+#line 860
}
-#line 834
+#line 860
#endif
-#line 834
+#line 860
-#line 834
+#line 860
-#line 834
+#line 860
*ip = (schar) xx;
-#line 834
+#line 860
return err;
-#line 834
+#line 860
}
-#line 834
+#line 860
static int
-#line 835
+#line 861
ncx_get_short_short(const void *xp, short *ip)
-#line 835
+#line 861
{
-#line 835
+#line 861
int err=NC_NOERR;
-#line 835
+#line 861
#if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
-#line 835
+#line 861
get_ix_short(xp, (ix_short *)ip);
-#line 835
+#line 861
#else
-#line 835
+#line 861
ix_short xx;
-#line 835
+#line 861
get_ix_short(xp, &xx);
-#line 835
+#line 861
-#line 835
+#line 861
#if IX_SHORT_MAX > SHORT_MAX
-#line 835
+#line 861
if (xx > SHORT_MAX || xx < SHORT_MIN) {
-#line 835
-
-#line 835
+#line 861
+#ifdef ERANGE_FILL
+#line 861
+ *ip = NC_FILL_SHORT;
+#line 861
+ return NC_ERANGE;
+#line 861
+#else
+#line 861
err = NC_ERANGE;
-#line 835
+#line 861
+#endif
+#line 861
}
-#line 835
+#line 861
#endif
-#line 835
+#line 861
-#line 835
+#line 861
-#line 835
+#line 861
*ip = (short) xx;
-#line 835
+#line 861
#endif
-#line 835
+#line 861
return err;
-#line 835
+#line 861
}
-#line 835
+#line 861
static int
-#line 836
+#line 862
ncx_get_short_int(const void *xp, int *ip)
-#line 836
+#line 862
{
-#line 836
+#line 862
int err=NC_NOERR;
-#line 836
+#line 862
#if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
-#line 836
+#line 862
get_ix_short(xp, (ix_short *)ip);
-#line 836
+#line 862
#else
-#line 836
+#line 862
ix_short xx;
-#line 836
+#line 862
get_ix_short(xp, &xx);
-#line 836
+#line 862
-#line 836
+#line 862
#if IX_SHORT_MAX > INT_MAX
-#line 836
+#line 862
if (xx > INT_MAX || xx < INT_MIN) {
-#line 836
-
-#line 836
+#line 862
+#ifdef ERANGE_FILL
+#line 862
+ *ip = NC_FILL_INT;
+#line 862
+ return NC_ERANGE;
+#line 862
+#else
+#line 862
err = NC_ERANGE;
-#line 836
+#line 862
+#endif
+#line 862
}
-#line 836
+#line 862
#endif
-#line 836
+#line 862
-#line 836
+#line 862
-#line 836
+#line 862
*ip = (int) xx;
-#line 836
+#line 862
#endif
-#line 836
+#line 862
return err;
-#line 836
+#line 862
}
-#line 836
+#line 862
static int
-#line 837
+#line 863
ncx_get_short_long(const void *xp, long *ip)
-#line 837
+#line 863
{
-#line 837
+#line 863
int err=NC_NOERR;
-#line 837
+#line 863
#if SIZEOF_IX_SHORT == SIZEOF_LONG && IX_SHORT_MAX == LONG_MAX
-#line 837
+#line 863
get_ix_short(xp, (ix_short *)ip);
-#line 837
+#line 863
#else
-#line 837
+#line 863
ix_short xx;
-#line 837
+#line 863
get_ix_short(xp, &xx);
-#line 837
+#line 863
-#line 837
+#line 863
#if IX_SHORT_MAX > LONG_MAX
-#line 837
+#line 863
if (xx > LONG_MAX || xx < LONG_MIN) {
-#line 837
-
-#line 837
+#line 863
+#ifdef ERANGE_FILL
+#line 863
+ *ip = NC_FILL_INT;
+#line 863
+ return NC_ERANGE;
+#line 863
+#else
+#line 863
err = NC_ERANGE;
-#line 837
+#line 863
+#endif
+#line 863
}
-#line 837
+#line 863
#endif
-#line 837
+#line 863
-#line 837
+#line 863
-#line 837
+#line 863
*ip = (long) xx;
-#line 837
+#line 863
#endif
-#line 837
+#line 863
return err;
-#line 837
+#line 863
}
-#line 837
+#line 863
static int
-#line 838
+#line 864
ncx_get_short_longlong(const void *xp, longlong *ip)
-#line 838
+#line 864
{
-#line 838
+#line 864
int err=NC_NOERR;
-#line 838
+#line 864
#if SIZEOF_IX_SHORT == SIZEOF_LONGLONG && IX_SHORT_MAX == LONGLONG_MAX
-#line 838
+#line 864
get_ix_short(xp, (ix_short *)ip);
-#line 838
+#line 864
#else
-#line 838
+#line 864
ix_short xx;
-#line 838
+#line 864
get_ix_short(xp, &xx);
-#line 838
+#line 864
-#line 838
+#line 864
#if IX_SHORT_MAX > LONGLONG_MAX
-#line 838
+#line 864
if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) {
-#line 838
-
-#line 838
+#line 864
+#ifdef ERANGE_FILL
+#line 864
+ *ip = NC_FILL_INT64;
+#line 864
+ return NC_ERANGE;
+#line 864
+#else
+#line 864
err = NC_ERANGE;
-#line 838
+#line 864
+#endif
+#line 864
}
-#line 838
+#line 864
#endif
-#line 838
+#line 864
-#line 838
+#line 864
-#line 838
+#line 864
*ip = (longlong) xx;
-#line 838
+#line 864
#endif
-#line 838
+#line 864
return err;
-#line 838
+#line 864
}
-#line 838
+#line 864
static int
-#line 839
+#line 865
ncx_get_short_ushort(const void *xp, ushort *ip)
-#line 839
+#line 865
{
-#line 839
+#line 865
int err=NC_NOERR;
-#line 839
+#line 865
ix_short xx;
-#line 839
+#line 865
get_ix_short(xp, &xx);
-#line 839
+#line 865
-#line 839
+#line 865
#if IX_SHORT_MAX > USHORT_MAX
-#line 839
+#line 865
if (xx > USHORT_MAX) {
-#line 839
-
-#line 839
+#line 865
+#ifdef ERANGE_FILL
+#line 865
+ *ip = NC_FILL_USHORT;
+#line 865
+ return NC_ERANGE;
+#line 865
+#else
+#line 865
err = NC_ERANGE;
-#line 839
+#line 865
+#endif
+#line 865
}
-#line 839
+#line 865
#endif
-#line 839
+#line 865
-#line 839
+#line 865
if (xx < 0) {
-#line 839
-
-#line 839
+#line 865
+#ifdef ERANGE_FILL
+#line 865
+ *ip = NC_FILL_USHORT;
+#line 865
+ return NC_ERANGE;
+#line 865
+#else
+#line 865
err = NC_ERANGE; /* because ip is unsigned */
-#line 839
+#line 865
+#endif
+#line 865
}
-#line 839
+#line 865
*ip = (ushort) xx;
-#line 839
+#line 865
return err;
-#line 839
+#line 865
}
-#line 839
+#line 865
static int
-#line 840
+#line 866
ncx_get_short_uchar(const void *xp, uchar *ip)
-#line 840
+#line 866
{
-#line 840
+#line 866
int err=NC_NOERR;
-#line 840
+#line 866
ix_short xx;
-#line 840
+#line 866
get_ix_short(xp, &xx);
-#line 840
+#line 866
-#line 840
+#line 866
#if IX_SHORT_MAX > UCHAR_MAX
-#line 840
+#line 866
if (xx > UCHAR_MAX) {
-#line 840
-
-#line 840
+#line 866
+#ifdef ERANGE_FILL
+#line 866
+ *ip = NC_FILL_UBYTE;
+#line 866
+ return NC_ERANGE;
+#line 866
+#else
+#line 866
err = NC_ERANGE;
-#line 840
+#line 866
+#endif
+#line 866
}
-#line 840
+#line 866
#endif
-#line 840
+#line 866
-#line 840
+#line 866
if (xx < 0) {
-#line 840
-
-#line 840
+#line 866
+#ifdef ERANGE_FILL
+#line 866
+ *ip = NC_FILL_UBYTE;
+#line 866
+ return NC_ERANGE;
+#line 866
+#else
+#line 866
err = NC_ERANGE; /* because ip is unsigned */
-#line 840
+#line 866
+#endif
+#line 866
}
-#line 840
+#line 866
*ip = (uchar) xx;
-#line 840
+#line 866
return err;
-#line 840
+#line 866
}
-#line 840
+#line 866
static int
-#line 841
+#line 867
ncx_get_short_uint(const void *xp, uint *ip)
-#line 841
+#line 867
{
-#line 841
+#line 867
int err=NC_NOERR;
-#line 841
+#line 867
ix_short xx;
-#line 841
+#line 867
get_ix_short(xp, &xx);
-#line 841
+#line 867
-#line 841
+#line 867
#if IX_SHORT_MAX > UINT_MAX
-#line 841
+#line 867
if (xx > UINT_MAX) {
-#line 841
-
-#line 841
+#line 867
+#ifdef ERANGE_FILL
+#line 867
+ *ip = NC_FILL_UINT;
+#line 867
+ return NC_ERANGE;
+#line 867
+#else
+#line 867
err = NC_ERANGE;
-#line 841
+#line 867
+#endif
+#line 867
}
-#line 841
+#line 867
#endif
-#line 841
+#line 867
-#line 841
+#line 867
if (xx < 0) {
-#line 841
-
-#line 841
+#line 867
+#ifdef ERANGE_FILL
+#line 867
+ *ip = NC_FILL_UINT;
+#line 867
+ return NC_ERANGE;
+#line 867
+#else
+#line 867
err = NC_ERANGE; /* because ip is unsigned */
-#line 841
+#line 867
+#endif
+#line 867
}
-#line 841
+#line 867
*ip = (uint) xx;
-#line 841
+#line 867
return err;
-#line 841
+#line 867
}
-#line 841
+#line 867
static int
-#line 842
+#line 868
ncx_get_short_ulonglong(const void *xp, ulonglong *ip)
-#line 842
+#line 868
{
-#line 842
+#line 868
int err=NC_NOERR;
-#line 842
+#line 868
ix_short xx;
-#line 842
+#line 868
get_ix_short(xp, &xx);
-#line 842
+#line 868
-#line 842
+#line 868
#if IX_SHORT_MAX > ULONGLONG_MAX
-#line 842
+#line 868
if (xx > ULONGLONG_MAX) {
-#line 842
-
-#line 842
+#line 868
+#ifdef ERANGE_FILL
+#line 868
+ *ip = NC_FILL_UINT64;
+#line 868
+ return NC_ERANGE;
+#line 868
+#else
+#line 868
err = NC_ERANGE;
-#line 842
+#line 868
+#endif
+#line 868
}
-#line 842
+#line 868
#endif
-#line 842
+#line 868
-#line 842
+#line 868
if (xx < 0) {
-#line 842
-
-#line 842
+#line 868
+#ifdef ERANGE_FILL
+#line 868
+ *ip = NC_FILL_UINT64;
+#line 868
+ return NC_ERANGE;
+#line 868
+#else
+#line 868
err = NC_ERANGE; /* because ip is unsigned */
-#line 842
+#line 868
+#endif
+#line 868
}
-#line 842
+#line 868
*ip = (ulonglong) xx;
-#line 842
+#line 868
return err;
-#line 842
+#line 868
}
-#line 842
+#line 868
static int
-#line 843
+#line 869
ncx_get_short_float(const void *xp, float *ip)
-#line 843
+#line 869
{
-#line 843
+#line 869
ix_short xx;
-#line 843
+#line 869
get_ix_short(xp, &xx);
-#line 843
+#line 869
*ip = (float)xx;
-#line 843
+#line 869
return NC_NOERR;
-#line 843
+#line 869
}
-#line 843
+#line 869
static int
-#line 844
+#line 870
ncx_get_short_double(const void *xp, double *ip)
-#line 844
+#line 870
{
-#line 844
+#line 870
ix_short xx;
-#line 844
+#line 870
get_ix_short(xp, &xx);
-#line 844
+#line 870
*ip = (double)xx;
-#line 844
+#line 870
return NC_NOERR;
-#line 844
+#line 870
}
-#line 844
+#line 870
static int
@@ -1050,343 +1155,451 @@ ncx_put_short_uchar(void *xp, const uchar *ip, void *fillp)
}
static int
-#line 867
+#line 893
ncx_put_short_short(void *xp, const short *ip, void *fillp)
-#line 867
+#line 893
{
-#line 867
+#line 893
int err=NC_NOERR;
-#line 867
+#line 893
#if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
-#line 867
+#line 893
put_ix_short(xp, (const ix_short *)ip);
-#line 867
+#line 893
#else
-#line 867
+#line 893
ix_short xx = NC_FILL_SHORT;
-#line 867
+#line 893
-#line 867
+#line 893
#if IX_SHORT_MAX < SHORT_MAX
-#line 867
+#line 893
if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
-#line 867
+#line 893
-#line 867
+#line 893
+#ifdef ERANGE_FILL
+#line 893
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 893
+#endif
+#line 893
err = NC_ERANGE;
-#line 867
- }
-#line 867
+#line 893
+ }
+#line 893
+#ifdef ERANGE_FILL
+#line 893
+ else
+#line 893
#endif
-#line 867
+#line 893
+#endif
+#line 893
xx = (ix_short)*ip;
-#line 867
+#line 893
-#line 867
+#line 893
put_ix_short(xp, &xx);
-#line 867
+#line 893
#endif
-#line 867
+#line 893
return err;
-#line 867
+#line 893
}
-#line 867
+#line 893
static int
-#line 868
+#line 894
ncx_put_short_int(void *xp, const int *ip, void *fillp)
-#line 868
+#line 894
{
-#line 868
+#line 894
int err=NC_NOERR;
-#line 868
+#line 894
#if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
-#line 868
+#line 894
put_ix_short(xp, (const ix_short *)ip);
-#line 868
+#line 894
#else
-#line 868
+#line 894
ix_short xx = NC_FILL_SHORT;
-#line 868
+#line 894
-#line 868
+#line 894
#if IX_SHORT_MAX < INT_MAX
-#line 868
+#line 894
if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
-#line 868
+#line 894
-#line 868
+#line 894
+#ifdef ERANGE_FILL
+#line 894
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 894
+#endif
+#line 894
err = NC_ERANGE;
-#line 868
- }
-#line 868
+#line 894
+ }
+#line 894
+#ifdef ERANGE_FILL
+#line 894
+ else
+#line 894
#endif
-#line 868
+#line 894
+#endif
+#line 894
xx = (ix_short)*ip;
-#line 868
+#line 894
-#line 868
+#line 894
put_ix_short(xp, &xx);
-#line 868
+#line 894
#endif
-#line 868
+#line 894
return err;
-#line 868
+#line 894
}
-#line 868
+#line 894
static int
-#line 869
+#line 895
ncx_put_short_long(void *xp, const long *ip, void *fillp)
-#line 869
+#line 895
{
-#line 869
+#line 895
int err=NC_NOERR;
-#line 869
+#line 895
#if SIZEOF_IX_SHORT == SIZEOF_LONG && IX_SHORT_MAX == LONG_MAX
-#line 869
+#line 895
put_ix_short(xp, (const ix_short *)ip);
-#line 869
+#line 895
#else
-#line 869
+#line 895
ix_short xx = NC_FILL_SHORT;
-#line 869
+#line 895
-#line 869
+#line 895
#if IX_SHORT_MAX < LONG_MAX
-#line 869
+#line 895
if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
-#line 869
+#line 895
-#line 869
+#line 895
+#ifdef ERANGE_FILL
+#line 895
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 895
+#endif
+#line 895
err = NC_ERANGE;
-#line 869
- }
-#line 869
+#line 895
+ }
+#line 895
+#ifdef ERANGE_FILL
+#line 895
+ else
+#line 895
#endif
-#line 869
+#line 895
+#endif
+#line 895
xx = (ix_short)*ip;
-#line 869
+#line 895
-#line 869
+#line 895
put_ix_short(xp, &xx);
-#line 869
+#line 895
#endif
-#line 869
+#line 895
return err;
-#line 869
+#line 895
}
-#line 869
+#line 895
static int
-#line 870
+#line 896
ncx_put_short_longlong(void *xp, const longlong *ip, void *fillp)
-#line 870
+#line 896
{
-#line 870
+#line 896
int err=NC_NOERR;
-#line 870
+#line 896
#if SIZEOF_IX_SHORT == SIZEOF_LONGLONG && IX_SHORT_MAX == LONGLONG_MAX
-#line 870
+#line 896
put_ix_short(xp, (const ix_short *)ip);
-#line 870
+#line 896
#else
-#line 870
+#line 896
ix_short xx = NC_FILL_SHORT;
-#line 870
+#line 896
-#line 870
+#line 896
#if IX_SHORT_MAX < LONGLONG_MAX
-#line 870
+#line 896
if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) {
-#line 870
+#line 896
-#line 870
+#line 896
+#ifdef ERANGE_FILL
+#line 896
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 896
+#endif
+#line 896
err = NC_ERANGE;
-#line 870
- }
-#line 870
+#line 896
+ }
+#line 896
+#ifdef ERANGE_FILL
+#line 896
+ else
+#line 896
#endif
-#line 870
+#line 896
+#endif
+#line 896
xx = (ix_short)*ip;
-#line 870
+#line 896
-#line 870
+#line 896
put_ix_short(xp, &xx);
-#line 870
+#line 896
#endif
-#line 870
+#line 896
return err;
-#line 870
+#line 896
}
-#line 870
+#line 896
static int
-#line 871
+#line 897
ncx_put_short_ushort(void *xp, const ushort *ip, void *fillp)
-#line 871
+#line 897
{
-#line 871
+#line 897
int err=NC_NOERR;
-#line 871
+#line 897
ix_short xx = NC_FILL_SHORT;
-#line 871
+#line 897
-#line 871
+#line 897
#if IX_SHORT_MAX < USHORT_MAX
-#line 871
+#line 897
if (*ip > IX_SHORT_MAX) {
-#line 871
+#line 897
-#line 871
+#line 897
+#ifdef ERANGE_FILL
+#line 897
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 897
+#endif
+#line 897
err = NC_ERANGE;
-#line 871
- }
-#line 871
+#line 897
+ }
+#line 897
+#ifdef ERANGE_FILL
+#line 897
+ else
+#line 897
+#endif
+#line 897
#endif
-#line 871
+#line 897
xx = (ix_short)*ip;
-#line 871
+#line 897
-#line 871
+#line 897
put_ix_short(xp, &xx);
-#line 871
+#line 897
return err;
-#line 871
+#line 897
}
-#line 871
+#line 897
static int
-#line 872
+#line 898
ncx_put_short_uint(void *xp, const uint *ip, void *fillp)
-#line 872
+#line 898
{
-#line 872
+#line 898
int err=NC_NOERR;
-#line 872
+#line 898
ix_short xx = NC_FILL_SHORT;
-#line 872
+#line 898
-#line 872
+#line 898
#if IX_SHORT_MAX < UINT_MAX
-#line 872
+#line 898
if (*ip > IX_SHORT_MAX) {
-#line 872
+#line 898
-#line 872
+#line 898
+#ifdef ERANGE_FILL
+#line 898
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 898
+#endif
+#line 898
err = NC_ERANGE;
-#line 872
- }
-#line 872
+#line 898
+ }
+#line 898
+#ifdef ERANGE_FILL
+#line 898
+ else
+#line 898
+#endif
+#line 898
#endif
-#line 872
+#line 898
xx = (ix_short)*ip;
-#line 872
+#line 898
-#line 872
+#line 898
put_ix_short(xp, &xx);
-#line 872
+#line 898
return err;
-#line 872
+#line 898
}
-#line 872
+#line 898
static int
-#line 873
+#line 899
ncx_put_short_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 873
+#line 899
{
-#line 873
+#line 899
int err=NC_NOERR;
-#line 873
+#line 899
ix_short xx = NC_FILL_SHORT;
-#line 873
+#line 899
-#line 873
+#line 899
#if IX_SHORT_MAX < ULONGLONG_MAX
-#line 873
+#line 899
if (*ip > IX_SHORT_MAX) {
-#line 873
+#line 899
-#line 873
+#line 899
+#ifdef ERANGE_FILL
+#line 899
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 899
+#endif
+#line 899
err = NC_ERANGE;
-#line 873
- }
-#line 873
+#line 899
+ }
+#line 899
+#ifdef ERANGE_FILL
+#line 899
+ else
+#line 899
+#endif
+#line 899
#endif
-#line 873
+#line 899
xx = (ix_short)*ip;
-#line 873
+#line 899
-#line 873
+#line 899
put_ix_short(xp, &xx);
-#line 873
+#line 899
return err;
-#line 873
+#line 899
}
-#line 873
+#line 899
static int
-#line 874
+#line 900
ncx_put_short_float(void *xp, const float *ip, void *fillp)
-#line 874
+#line 900
{
-#line 874
+#line 900
int err=NC_NOERR;
-#line 874
+#line 900
ix_short xx = NC_FILL_SHORT;
-#line 874
+#line 900
-#line 874
+#line 900
if (*ip > (double)X_SHORT_MAX || *ip < (double)X_SHORT_MIN) {
-#line 874
+#line 900
-#line 874
+#line 900
+#ifdef ERANGE_FILL
+#line 900
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 900
+#endif
+#line 900
err = NC_ERANGE;
-#line 874
- }
-#line 874
+#line 900
+ }
+#line 900
+#ifdef ERANGE_FILL
+#line 900
+ else
+#line 900
+#endif
+#line 900
xx = (ix_short)*ip;
-#line 874
+#line 900
-#line 874
+#line 900
put_ix_short(xp, &xx);
-#line 874
+#line 900
return err;
-#line 874
+#line 900
}
-#line 874
+#line 900
static int
-#line 875
+#line 901
ncx_put_short_double(void *xp, const double *ip, void *fillp)
-#line 875
+#line 901
{
-#line 875
+#line 901
int err=NC_NOERR;
-#line 875
+#line 901
ix_short xx = NC_FILL_SHORT;
-#line 875
+#line 901
-#line 875
+#line 901
if (*ip > X_SHORT_MAX || *ip < X_SHORT_MIN) {
-#line 875
+#line 901
-#line 875
+#line 901
+#ifdef ERANGE_FILL
+#line 901
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 901
+#endif
+#line 901
err = NC_ERANGE;
-#line 875
- }
-#line 875
+#line 901
+ }
+#line 901
+#ifdef ERANGE_FILL
+#line 901
+ else
+#line 901
+#endif
+#line 901
xx = (ix_short)*ip;
-#line 875
+#line 901
-#line 875
+#line 901
put_ix_short(xp, &xx);
-#line 875
+#line 901
return err;
-#line 875
+#line 901
}
-#line 875
+#line 901
/* external NC_USHORT -------------------------------------------------------*/
@@ -1435,403 +1648,475 @@ put_ix_ushort(void *xp, const ix_ushort *ip)
}
static int
-#line 922
+#line 948
ncx_get_ushort_schar(const void *xp, schar *ip)
-#line 922
+#line 948
{
-#line 922
+#line 948
int err=NC_NOERR;
-#line 922
+#line 948
ix_ushort xx;
-#line 922
+#line 948
get_ix_ushort(xp, &xx);
-#line 922
+#line 948
-#line 922
+#line 948
#if IX_USHORT_MAX > SCHAR_MAX
-#line 922
+#line 948
if (xx > SCHAR_MAX) {
-#line 922
-
-#line 922
+#line 948
+#ifdef ERANGE_FILL
+#line 948
+ *ip = NC_FILL_BYTE;
+#line 948
+ return NC_ERANGE;
+#line 948
+#else
+#line 948
err = NC_ERANGE;
-#line 922
+#line 948
+#endif
+#line 948
}
-#line 922
+#line 948
#endif
-#line 922
+#line 948
-#line 922
+#line 948
-#line 922
+#line 948
*ip = (schar) xx;
-#line 922
+#line 948
return err;
-#line 922
+#line 948
}
-#line 922
+#line 948
static int
-#line 923
+#line 949
ncx_get_ushort_short(const void *xp, short *ip)
-#line 923
+#line 949
{
-#line 923
+#line 949
int err=NC_NOERR;
-#line 923
+#line 949
ix_ushort xx;
-#line 923
+#line 949
get_ix_ushort(xp, &xx);
-#line 923
+#line 949
-#line 923
+#line 949
#if IX_USHORT_MAX > SHORT_MAX
-#line 923
+#line 949
if (xx > SHORT_MAX) {
-#line 923
-
-#line 923
+#line 949
+#ifdef ERANGE_FILL
+#line 949
+ *ip = NC_FILL_SHORT;
+#line 949
+ return NC_ERANGE;
+#line 949
+#else
+#line 949
err = NC_ERANGE;
-#line 923
+#line 949
+#endif
+#line 949
}
-#line 923
+#line 949
#endif
-#line 923
+#line 949
-#line 923
+#line 949
-#line 923
+#line 949
*ip = (short) xx;
-#line 923
+#line 949
return err;
-#line 923
+#line 949
}
-#line 923
+#line 949
static int
-#line 924
+#line 950
ncx_get_ushort_int(const void *xp, int *ip)
-#line 924
+#line 950
{
-#line 924
+#line 950
int err=NC_NOERR;
-#line 924
+#line 950
ix_ushort xx;
-#line 924
+#line 950
get_ix_ushort(xp, &xx);
-#line 924
+#line 950
-#line 924
+#line 950
#if IX_USHORT_MAX > INT_MAX
-#line 924
+#line 950
if (xx > INT_MAX) {
-#line 924
-
-#line 924
- err = NC_ERANGE;
-#line 924
+#line 950
+#ifdef ERANGE_FILL
+#line 950
+ *ip = NC_FILL_INT;
+#line 950
+ return NC_ERANGE;
+#line 950
+#else
+#line 950
+ err = NC_ERANGE;
+#line 950
+#endif
+#line 950
}
-#line 924
+#line 950
#endif
-#line 924
+#line 950
-#line 924
+#line 950
-#line 924
+#line 950
*ip = (int) xx;
-#line 924
+#line 950
return err;
-#line 924
+#line 950
}
-#line 924
+#line 950
static int
-#line 925
+#line 951
ncx_get_ushort_long(const void *xp, long *ip)
-#line 925
+#line 951
{
-#line 925
+#line 951
int err=NC_NOERR;
-#line 925
+#line 951
ix_ushort xx;
-#line 925
+#line 951
get_ix_ushort(xp, &xx);
-#line 925
+#line 951
-#line 925
+#line 951
#if IX_USHORT_MAX > LONG_MAX
-#line 925
+#line 951
if (xx > LONG_MAX) {
-#line 925
-
-#line 925
+#line 951
+#ifdef ERANGE_FILL
+#line 951
+ *ip = NC_FILL_INT;
+#line 951
+ return NC_ERANGE;
+#line 951
+#else
+#line 951
err = NC_ERANGE;
-#line 925
+#line 951
+#endif
+#line 951
}
-#line 925
+#line 951
#endif
-#line 925
+#line 951
-#line 925
+#line 951
-#line 925
+#line 951
*ip = (long) xx;
-#line 925
+#line 951
return err;
-#line 925
+#line 951
}
-#line 925
+#line 951
static int
-#line 926
+#line 952
ncx_get_ushort_longlong(const void *xp, longlong *ip)
-#line 926
+#line 952
{
-#line 926
+#line 952
int err=NC_NOERR;
-#line 926
+#line 952
ix_ushort xx;
-#line 926
+#line 952
get_ix_ushort(xp, &xx);
-#line 926
+#line 952
-#line 926
+#line 952
#if IX_USHORT_MAX > LONGLONG_MAX
-#line 926
+#line 952
if (xx > LONGLONG_MAX) {
-#line 926
-
-#line 926
+#line 952
+#ifdef ERANGE_FILL
+#line 952
+ *ip = NC_FILL_INT64;
+#line 952
+ return NC_ERANGE;
+#line 952
+#else
+#line 952
err = NC_ERANGE;
-#line 926
+#line 952
+#endif
+#line 952
}
-#line 926
+#line 952
#endif
-#line 926
+#line 952
-#line 926
+#line 952
-#line 926
+#line 952
*ip = (longlong) xx;
-#line 926
+#line 952
return err;
-#line 926
+#line 952
}
-#line 926
+#line 952
static int
-#line 927
+#line 953
ncx_get_ushort_ushort(const void *xp, ushort *ip)
-#line 927
+#line 953
{
-#line 927
+#line 953
int err=NC_NOERR;
-#line 927
+#line 953
#if SIZEOF_IX_USHORT == SIZEOF_USHORT && IX_USHORT_MAX == USHORT_MAX
-#line 927
+#line 953
get_ix_ushort(xp, (ix_ushort *)ip);
-#line 927
+#line 953
#else
-#line 927
+#line 953
ix_ushort xx;
-#line 927
+#line 953
get_ix_ushort(xp, &xx);
-#line 927
+#line 953
-#line 927
+#line 953
#if IX_USHORT_MAX > USHORT_MAX
-#line 927
+#line 953
if (xx > USHORT_MAX) {
-#line 927
-
-#line 927
+#line 953
+#ifdef ERANGE_FILL
+#line 953
+ *ip = NC_FILL_USHORT;
+#line 953
+ return NC_ERANGE;
+#line 953
+#else
+#line 953
err = NC_ERANGE;
-#line 927
+#line 953
+#endif
+#line 953
}
-#line 927
+#line 953
#endif
-#line 927
+#line 953
-#line 927
+#line 953
-#line 927
+#line 953
*ip = (ushort) xx;
-#line 927
+#line 953
#endif
-#line 927
+#line 953
return err;
-#line 927
+#line 953
}
-#line 927
+#line 953
static int
-#line 928
+#line 954
ncx_get_ushort_uchar(const void *xp, uchar *ip)
-#line 928
+#line 954
{
-#line 928
+#line 954
int err=NC_NOERR;
-#line 928
+#line 954
#if SIZEOF_IX_USHORT == SIZEOF_UCHAR && IX_USHORT_MAX == UCHAR_MAX
-#line 928
+#line 954
get_ix_ushort(xp, (ix_ushort *)ip);
-#line 928
+#line 954
#else
-#line 928
+#line 954
ix_ushort xx;
-#line 928
+#line 954
get_ix_ushort(xp, &xx);
-#line 928
+#line 954
-#line 928
+#line 954
#if IX_USHORT_MAX > UCHAR_MAX
-#line 928
+#line 954
if (xx > UCHAR_MAX) {
-#line 928
-
-#line 928
+#line 954
+#ifdef ERANGE_FILL
+#line 954
+ *ip = NC_FILL_UBYTE;
+#line 954
+ return NC_ERANGE;
+#line 954
+#else
+#line 954
err = NC_ERANGE;
-#line 928
+#line 954
+#endif
+#line 954
}
-#line 928
+#line 954
#endif
-#line 928
+#line 954
-#line 928
+#line 954
-#line 928
+#line 954
*ip = (uchar) xx;
-#line 928
+#line 954
#endif
-#line 928
+#line 954
return err;
-#line 928
+#line 954
}
-#line 928
+#line 954
static int
-#line 929
+#line 955
ncx_get_ushort_uint(const void *xp, uint *ip)
-#line 929
+#line 955
{
-#line 929
+#line 955
int err=NC_NOERR;
-#line 929
+#line 955
#if SIZEOF_IX_USHORT == SIZEOF_UINT && IX_USHORT_MAX == UINT_MAX
-#line 929
+#line 955
get_ix_ushort(xp, (ix_ushort *)ip);
-#line 929
+#line 955
#else
-#line 929
+#line 955
ix_ushort xx;
-#line 929
+#line 955
get_ix_ushort(xp, &xx);
-#line 929
+#line 955
-#line 929
+#line 955
#if IX_USHORT_MAX > UINT_MAX
-#line 929
+#line 955
if (xx > UINT_MAX) {
-#line 929
-
-#line 929
+#line 955
+#ifdef ERANGE_FILL
+#line 955
+ *ip = NC_FILL_UINT;
+#line 955
+ return NC_ERANGE;
+#line 955
+#else
+#line 955
err = NC_ERANGE;
-#line 929
+#line 955
+#endif
+#line 955
}
-#line 929
+#line 955
#endif
-#line 929
+#line 955
-#line 929
+#line 955
-#line 929
+#line 955
*ip = (uint) xx;
-#line 929
+#line 955
#endif
-#line 929
+#line 955
return err;
-#line 929
+#line 955
}
-#line 929
+#line 955
static int
-#line 930
+#line 956
ncx_get_ushort_ulonglong(const void *xp, ulonglong *ip)
-#line 930
+#line 956
{
-#line 930
+#line 956
int err=NC_NOERR;
-#line 930
+#line 956
#if SIZEOF_IX_USHORT == SIZEOF_ULONGLONG && IX_USHORT_MAX == ULONGLONG_MAX
-#line 930
+#line 956
get_ix_ushort(xp, (ix_ushort *)ip);
-#line 930
+#line 956
#else
-#line 930
+#line 956
ix_ushort xx;
-#line 930
+#line 956
get_ix_ushort(xp, &xx);
-#line 930
+#line 956
-#line 930
+#line 956
#if IX_USHORT_MAX > ULONGLONG_MAX
-#line 930
+#line 956
if (xx > ULONGLONG_MAX) {
-#line 930
-
-#line 930
+#line 956
+#ifdef ERANGE_FILL
+#line 956
+ *ip = NC_FILL_UINT64;
+#line 956
+ return NC_ERANGE;
+#line 956
+#else
+#line 956
err = NC_ERANGE;
-#line 930
+#line 956
+#endif
+#line 956
}
-#line 930
+#line 956
#endif
-#line 930
+#line 956
-#line 930
+#line 956
-#line 930
+#line 956
*ip = (ulonglong) xx;
-#line 930
+#line 956
#endif
-#line 930
+#line 956
return err;
-#line 930
+#line 956
}
-#line 930
+#line 956
static int
-#line 931
+#line 957
ncx_get_ushort_float(const void *xp, float *ip)
-#line 931
+#line 957
{
-#line 931
+#line 957
ix_ushort xx;
-#line 931
+#line 957
get_ix_ushort(xp, &xx);
-#line 931
+#line 957
*ip = (float)xx;
-#line 931
+#line 957
return NC_NOERR;
-#line 931
+#line 957
}
-#line 931
+#line 957
static int
-#line 932
+#line 958
ncx_get_ushort_double(const void *xp, double *ip)
-#line 932
+#line 958
{
-#line 932
+#line 958
ix_ushort xx;
-#line 932
+#line 958
get_ix_ushort(xp, &xx);
-#line 932
+#line 958
*ip = (double)xx;
-#line 932
+#line 958
return NC_NOERR;
-#line 932
+#line 958
}
-#line 932
+#line 958
static int
@@ -1840,8 +2125,15 @@ ncx_put_ushort_schar(void *xp, const schar *ip, void *fillp)
int err=NC_NOERR;
uchar *cp;
if (*ip < 0) {
-#line 946
+#ifdef ERANGE_FILL
+ if (fillp != NULL) memcpy(xp, fillp, 2);
+#ifndef WORDS_BIGENDIAN
+ swapn2b(xp, xp, 1);
+#endif
+ return NC_ERANGE;
+#else
err = NC_ERANGE;
+#endif
}
cp = (uchar *) xp;
@@ -1864,367 +2156,523 @@ ncx_put_ushort_uchar(void *xp, const uchar *ip, void *fillp)
}
static int
-#line 968
+#line 996
ncx_put_ushort_short(void *xp, const short *ip, void *fillp)
-#line 968
+#line 996
{
-#line 968
+#line 996
int err=NC_NOERR;
-#line 968
+#line 996
ix_ushort xx = NC_FILL_USHORT;
-#line 968
+#line 996
-#line 968
+#line 996
#if IX_USHORT_MAX < SHORT_MAX
-#line 968
+#line 996
if (*ip > IX_USHORT_MAX) {
-#line 968
+#line 996
-#line 968
+#line 996
+#ifdef ERANGE_FILL
+#line 996
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 996
+#endif
+#line 996
err = NC_ERANGE;
-#line 968
- }
-#line 968
+#line 996
+ }
+#line 996
+#ifdef ERANGE_FILL
+#line 996
+ else
+#line 996
#endif
-#line 968
+#line 996
+#endif
+#line 996
if (*ip < 0) {
-#line 968
+#line 996
-#line 968
+#line 996
+#ifdef ERANGE_FILL
+#line 996
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 996
+#endif
+#line 996
err = NC_ERANGE; /* because xp is unsigned */
-#line 968
- }
-#line 968
+#line 996
+ }
+#line 996
+#ifdef ERANGE_FILL
+#line 996
+ else
+#line 996
+#endif
+#line 996
xx = (ix_ushort)*ip;
-#line 968
+#line 996
-#line 968
+#line 996
put_ix_ushort(xp, &xx);
-#line 968
+#line 996
return err;
-#line 968
+#line 996
}
-#line 968
+#line 996
static int
-#line 969
+#line 997
ncx_put_ushort_int(void *xp, const int *ip, void *fillp)
-#line 969
+#line 997
{
-#line 969
+#line 997
int err=NC_NOERR;
-#line 969
+#line 997
ix_ushort xx = NC_FILL_USHORT;
-#line 969
+#line 997
-#line 969
+#line 997
#if IX_USHORT_MAX < INT_MAX
-#line 969
+#line 997
if (*ip > IX_USHORT_MAX) {
-#line 969
+#line 997
-#line 969
+#line 997
+#ifdef ERANGE_FILL
+#line 997
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 997
+#endif
+#line 997
err = NC_ERANGE;
-#line 969
- }
-#line 969
+#line 997
+ }
+#line 997
+#ifdef ERANGE_FILL
+#line 997
+ else
+#line 997
#endif
-#line 969
+#line 997
+#endif
+#line 997
if (*ip < 0) {
-#line 969
+#line 997
-#line 969
+#line 997
+#ifdef ERANGE_FILL
+#line 997
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 997
+#endif
+#line 997
err = NC_ERANGE; /* because xp is unsigned */
-#line 969
- }
-#line 969
+#line 997
+ }
+#line 997
+#ifdef ERANGE_FILL
+#line 997
+ else
+#line 997
+#endif
+#line 997
xx = (ix_ushort)*ip;
-#line 969
+#line 997
-#line 969
+#line 997
put_ix_ushort(xp, &xx);
-#line 969
+#line 997
return err;
-#line 969
+#line 997
}
-#line 969
+#line 997
static int
-#line 970
+#line 998
ncx_put_ushort_long(void *xp, const long *ip, void *fillp)
-#line 970
+#line 998
{
-#line 970
+#line 998
int err=NC_NOERR;
-#line 970
+#line 998
ix_ushort xx = NC_FILL_USHORT;
-#line 970
+#line 998
-#line 970
+#line 998
#if IX_USHORT_MAX < LONG_MAX
-#line 970
+#line 998
if (*ip > IX_USHORT_MAX) {
-#line 970
+#line 998
-#line 970
+#line 998
+#ifdef ERANGE_FILL
+#line 998
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 998
+#endif
+#line 998
err = NC_ERANGE;
-#line 970
- }
-#line 970
+#line 998
+ }
+#line 998
+#ifdef ERANGE_FILL
+#line 998
+ else
+#line 998
#endif
-#line 970
+#line 998
+#endif
+#line 998
if (*ip < 0) {
-#line 970
+#line 998
-#line 970
+#line 998
+#ifdef ERANGE_FILL
+#line 998
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 998
+#endif
+#line 998
err = NC_ERANGE; /* because xp is unsigned */
-#line 970
- }
-#line 970
+#line 998
+ }
+#line 998
+#ifdef ERANGE_FILL
+#line 998
+ else
+#line 998
+#endif
+#line 998
xx = (ix_ushort)*ip;
-#line 970
+#line 998
-#line 970
+#line 998
put_ix_ushort(xp, &xx);
-#line 970
+#line 998
return err;
-#line 970
+#line 998
}
-#line 970
+#line 998
static int
-#line 971
+#line 999
ncx_put_ushort_longlong(void *xp, const longlong *ip, void *fillp)
-#line 971
+#line 999
{
-#line 971
+#line 999
int err=NC_NOERR;
-#line 971
+#line 999
ix_ushort xx = NC_FILL_USHORT;
-#line 971
+#line 999
-#line 971
+#line 999
#if IX_USHORT_MAX < LONGLONG_MAX
-#line 971
+#line 999
if (*ip > IX_USHORT_MAX) {
-#line 971
+#line 999
-#line 971
+#line 999
+#ifdef ERANGE_FILL
+#line 999
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 999
+#endif
+#line 999
err = NC_ERANGE;
-#line 971
- }
-#line 971
+#line 999
+ }
+#line 999
+#ifdef ERANGE_FILL
+#line 999
+ else
+#line 999
#endif
-#line 971
+#line 999
+#endif
+#line 999
if (*ip < 0) {
-#line 971
+#line 999
-#line 971
+#line 999
+#ifdef ERANGE_FILL
+#line 999
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 999
+#endif
+#line 999
err = NC_ERANGE; /* because xp is unsigned */
-#line 971
- }
-#line 971
+#line 999
+ }
+#line 999
+#ifdef ERANGE_FILL
+#line 999
+ else
+#line 999
+#endif
+#line 999
xx = (ix_ushort)*ip;
-#line 971
+#line 999
-#line 971
+#line 999
put_ix_ushort(xp, &xx);
-#line 971
+#line 999
return err;
-#line 971
+#line 999
}
-#line 971
+#line 999
static int
-#line 972
+#line 1000
ncx_put_ushort_ushort(void *xp, const ushort *ip, void *fillp)
-#line 972
+#line 1000
{
-#line 972
+#line 1000
int err=NC_NOERR;
-#line 972
+#line 1000
#if SIZEOF_IX_USHORT == SIZEOF_USHORT && IX_USHORT_MAX == USHORT_MAX
-#line 972
+#line 1000
put_ix_ushort(xp, (const ix_ushort *)ip);
-#line 972
+#line 1000
#else
-#line 972
+#line 1000
ix_ushort xx = NC_FILL_USHORT;
-#line 972
+#line 1000
-#line 972
+#line 1000
#if IX_USHORT_MAX < USHORT_MAX
-#line 972
+#line 1000
if (*ip > IX_USHORT_MAX) {
-#line 972
+#line 1000
-#line 972
+#line 1000
+#ifdef ERANGE_FILL
+#line 1000
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 1000
+#endif
+#line 1000
err = NC_ERANGE;
-#line 972
- }
-#line 972
+#line 1000
+ }
+#line 1000
+#ifdef ERANGE_FILL
+#line 1000
+ else
+#line 1000
#endif
-#line 972
+#line 1000
+#endif
+#line 1000
xx = (ix_ushort)*ip;
-#line 972
+#line 1000
-#line 972
+#line 1000
put_ix_ushort(xp, &xx);
-#line 972
+#line 1000
#endif
-#line 972
+#line 1000
return err;
-#line 972
+#line 1000
}
-#line 972
+#line 1000
static int
-#line 973
+#line 1001
ncx_put_ushort_uint(void *xp, const uint *ip, void *fillp)
-#line 973
+#line 1001
{
-#line 973
+#line 1001
int err=NC_NOERR;
-#line 973
+#line 1001
#if SIZEOF_IX_USHORT == SIZEOF_UINT && IX_USHORT_MAX == UINT_MAX
-#line 973
+#line 1001
put_ix_ushort(xp, (const ix_ushort *)ip);
-#line 973
+#line 1001
#else
-#line 973
+#line 1001
ix_ushort xx = NC_FILL_USHORT;
-#line 973
+#line 1001
-#line 973
+#line 1001
#if IX_USHORT_MAX < UINT_MAX
-#line 973
+#line 1001
if (*ip > IX_USHORT_MAX) {
-#line 973
+#line 1001
-#line 973
+#line 1001
+#ifdef ERANGE_FILL
+#line 1001
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 1001
+#endif
+#line 1001
err = NC_ERANGE;
-#line 973
- }
-#line 973
+#line 1001
+ }
+#line 1001
+#ifdef ERANGE_FILL
+#line 1001
+ else
+#line 1001
#endif
-#line 973
+#line 1001
+#endif
+#line 1001
xx = (ix_ushort)*ip;
-#line 973
+#line 1001
-#line 973
+#line 1001
put_ix_ushort(xp, &xx);
-#line 973
+#line 1001
#endif
-#line 973
+#line 1001
return err;
-#line 973
+#line 1001
}
-#line 973
+#line 1001
static int
-#line 974
+#line 1002
ncx_put_ushort_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 974
+#line 1002
{
-#line 974
+#line 1002
int err=NC_NOERR;
-#line 974
+#line 1002
#if SIZEOF_IX_USHORT == SIZEOF_ULONGLONG && IX_USHORT_MAX == ULONGLONG_MAX
-#line 974
+#line 1002
put_ix_ushort(xp, (const ix_ushort *)ip);
-#line 974
+#line 1002
#else
-#line 974
+#line 1002
ix_ushort xx = NC_FILL_USHORT;
-#line 974
+#line 1002
-#line 974
+#line 1002
#if IX_USHORT_MAX < ULONGLONG_MAX
-#line 974
+#line 1002
if (*ip > IX_USHORT_MAX) {
-#line 974
+#line 1002
-#line 974
+#line 1002
+#ifdef ERANGE_FILL
+#line 1002
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 1002
+#endif
+#line 1002
err = NC_ERANGE;
-#line 974
- }
-#line 974
+#line 1002
+ }
+#line 1002
+#ifdef ERANGE_FILL
+#line 1002
+ else
+#line 1002
#endif
-#line 974
+#line 1002
+#endif
+#line 1002
xx = (ix_ushort)*ip;
-#line 974
+#line 1002
-#line 974
+#line 1002
put_ix_ushort(xp, &xx);
-#line 974
+#line 1002
#endif
-#line 974
+#line 1002
return err;
-#line 974
+#line 1002
}
-#line 974
+#line 1002
static int
-#line 975
+#line 1003
ncx_put_ushort_float(void *xp, const float *ip, void *fillp)
-#line 975
+#line 1003
{
-#line 975
+#line 1003
int err=NC_NOERR;
-#line 975
+#line 1003
ix_ushort xx = NC_FILL_USHORT;
-#line 975
+#line 1003
-#line 975
+#line 1003
if (*ip > (double)X_USHORT_MAX || *ip < 0) {
-#line 975
+#line 1003
-#line 975
+#line 1003
+#ifdef ERANGE_FILL
+#line 1003
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 1003
+#endif
+#line 1003
err = NC_ERANGE;
-#line 975
- }
-#line 975
+#line 1003
+ }
+#line 1003
+#ifdef ERANGE_FILL
+#line 1003
+ else
+#line 1003
+#endif
+#line 1003
xx = (ix_ushort)*ip;
-#line 975
+#line 1003
-#line 975
+#line 1003
put_ix_ushort(xp, &xx);
-#line 975
+#line 1003
return err;
-#line 975
+#line 1003
}
-#line 975
+#line 1003
static int
-#line 976
+#line 1004
ncx_put_ushort_double(void *xp, const double *ip, void *fillp)
-#line 976
+#line 1004
{
-#line 976
+#line 1004
int err=NC_NOERR;
-#line 976
+#line 1004
ix_ushort xx = NC_FILL_USHORT;
-#line 976
+#line 1004
-#line 976
+#line 1004
if (*ip > X_USHORT_MAX || *ip < 0) {
-#line 976
+#line 1004
-#line 976
+#line 1004
+#ifdef ERANGE_FILL
+#line 1004
+ if (fillp != NULL) memcpy(&xx, fillp, 2);
+#line 1004
+#endif
+#line 1004
err = NC_ERANGE;
-#line 976
- }
-#line 976
+#line 1004
+ }
+#line 1004
+#ifdef ERANGE_FILL
+#line 1004
+ else
+#line 1004
+#endif
+#line 1004
xx = (ix_ushort)*ip;
-#line 976
+#line 1004
-#line 976
+#line 1004
put_ix_ushort(xp, &xx);
-#line 976
+#line 1004
return err;
-#line 976
+#line 1004
}
-#line 976
+#line 1004
/* external NC_INT ----------------------------------------------------------*/
@@ -2281,428 +2729,532 @@ put_ix_int(void *xp, const ix_int *ip)
#if X_SIZEOF_INT != SIZEOF_INT
static int
-#line 1031
+#line 1059
ncx_get_int_int(const void *xp, int *ip)
-#line 1031
+#line 1059
{
-#line 1031
+#line 1059
int err=NC_NOERR;
-#line 1031
+#line 1059
#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-#line 1031
+#line 1059
get_ix_int(xp, (ix_int *)ip);
-#line 1031
+#line 1059
#else
-#line 1031
+#line 1059
ix_int xx;
-#line 1031
+#line 1059
get_ix_int(xp, &xx);
-#line 1031
+#line 1059
-#line 1031
+#line 1059
#if IX_INT_MAX > INT_MAX
-#line 1031
+#line 1059
if (xx > INT_MAX || xx < INT_MIN) {
-#line 1031
-
-#line 1031
+#line 1059
+#ifdef ERANGE_FILL
+#line 1059
+ *ip = NC_FILL_INT;
+#line 1059
+ return NC_ERANGE;
+#line 1059
+#else
+#line 1059
err = NC_ERANGE;
-#line 1031
+#line 1059
+#endif
+#line 1059
}
-#line 1031
+#line 1059
#endif
-#line 1031
+#line 1059
-#line 1031
+#line 1059
-#line 1031
+#line 1059
*ip = (int) xx;
-#line 1031
+#line 1059
#endif
-#line 1031
+#line 1059
return err;
-#line 1031
+#line 1059
}
-#line 1031
+#line 1059
#endif
static int
-#line 1033
+#line 1061
ncx_get_int_schar(const void *xp, schar *ip)
-#line 1033
+#line 1061
{
-#line 1033
+#line 1061
int err=NC_NOERR;
-#line 1033
+#line 1061
ix_int xx;
-#line 1033
+#line 1061
get_ix_int(xp, &xx);
-#line 1033
+#line 1061
-#line 1033
+#line 1061
#if IX_INT_MAX > SCHAR_MAX
-#line 1033
+#line 1061
if (xx > SCHAR_MAX || xx < SCHAR_MIN) {
-#line 1033
-
-#line 1033
+#line 1061
+#ifdef ERANGE_FILL
+#line 1061
+ *ip = NC_FILL_BYTE;
+#line 1061
+ return NC_ERANGE;
+#line 1061
+#else
+#line 1061
err = NC_ERANGE;
-#line 1033
+#line 1061
+#endif
+#line 1061
}
-#line 1033
+#line 1061
#endif
-#line 1033
+#line 1061
-#line 1033
+#line 1061
-#line 1033
+#line 1061
*ip = (schar) xx;
-#line 1033
+#line 1061
return err;
-#line 1033
+#line 1061
}
-#line 1033
+#line 1061
static int
-#line 1034
+#line 1062
ncx_get_int_short(const void *xp, short *ip)
-#line 1034
+#line 1062
{
-#line 1034
+#line 1062
int err=NC_NOERR;
-#line 1034
+#line 1062
#if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
-#line 1034
+#line 1062
get_ix_int(xp, (ix_int *)ip);
-#line 1034
+#line 1062
#else
-#line 1034
+#line 1062
ix_int xx;
-#line 1034
+#line 1062
get_ix_int(xp, &xx);
-#line 1034
+#line 1062
-#line 1034
+#line 1062
#if IX_INT_MAX > SHORT_MAX
-#line 1034
+#line 1062
if (xx > SHORT_MAX || xx < SHORT_MIN) {
-#line 1034
-
-#line 1034
+#line 1062
+#ifdef ERANGE_FILL
+#line 1062
+ *ip = NC_FILL_SHORT;
+#line 1062
+ return NC_ERANGE;
+#line 1062
+#else
+#line 1062
err = NC_ERANGE;
-#line 1034
+#line 1062
+#endif
+#line 1062
}
-#line 1034
+#line 1062
#endif
-#line 1034
+#line 1062
-#line 1034
+#line 1062
-#line 1034
+#line 1062
*ip = (short) xx;
-#line 1034
+#line 1062
#endif
-#line 1034
+#line 1062
return err;
-#line 1034
+#line 1062
}
-#line 1034
+#line 1062
static int
-#line 1035
+#line 1063
ncx_get_int_long(const void *xp, long *ip)
-#line 1035
+#line 1063
{
-#line 1035
+#line 1063
int err=NC_NOERR;
-#line 1035
+#line 1063
#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
-#line 1035
+#line 1063
get_ix_int(xp, (ix_int *)ip);
-#line 1035
+#line 1063
#else
-#line 1035
+#line 1063
ix_int xx;
-#line 1035
+#line 1063
get_ix_int(xp, &xx);
-#line 1035
+#line 1063
-#line 1035
+#line 1063
#if IX_INT_MAX > LONG_MAX
-#line 1035
+#line 1063
if (xx > LONG_MAX || xx < LONG_MIN) {
-#line 1035
-
-#line 1035
+#line 1063
+#ifdef ERANGE_FILL
+#line 1063
+ *ip = NC_FILL_INT;
+#line 1063
+ return NC_ERANGE;
+#line 1063
+#else
+#line 1063
err = NC_ERANGE;
-#line 1035
+#line 1063
+#endif
+#line 1063
}
-#line 1035
+#line 1063
#endif
-#line 1035
+#line 1063
-#line 1035
+#line 1063
-#line 1035
+#line 1063
*ip = (long) xx;
-#line 1035
+#line 1063
#endif
-#line 1035
+#line 1063
return err;
-#line 1035
+#line 1063
}
-#line 1035
+#line 1063
static int
-#line 1036
+#line 1064
ncx_get_int_longlong(const void *xp, longlong *ip)
-#line 1036
+#line 1064
{
-#line 1036
+#line 1064
int err=NC_NOERR;
-#line 1036
+#line 1064
#if SIZEOF_IX_INT == SIZEOF_LONGLONG && IX_INT_MAX == LONGLONG_MAX
-#line 1036
+#line 1064
get_ix_int(xp, (ix_int *)ip);
-#line 1036
+#line 1064
#else
-#line 1036
+#line 1064
ix_int xx;
-#line 1036
+#line 1064
get_ix_int(xp, &xx);
-#line 1036
+#line 1064
-#line 1036
+#line 1064
#if IX_INT_MAX > LONGLONG_MAX
-#line 1036
+#line 1064
if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) {
-#line 1036
-
-#line 1036
+#line 1064
+#ifdef ERANGE_FILL
+#line 1064
+ *ip = NC_FILL_INT64;
+#line 1064
+ return NC_ERANGE;
+#line 1064
+#else
+#line 1064
err = NC_ERANGE;
-#line 1036
+#line 1064
+#endif
+#line 1064
}
-#line 1036
+#line 1064
#endif
-#line 1036
+#line 1064
-#line 1036
+#line 1064
-#line 1036
+#line 1064
*ip = (longlong) xx;
-#line 1036
+#line 1064
#endif
-#line 1036
+#line 1064
return err;
-#line 1036
+#line 1064
}
-#line 1036
+#line 1064
static int
-#line 1037
+#line 1065
ncx_get_int_ushort(const void *xp, ushort *ip)
-#line 1037
+#line 1065
{
-#line 1037
+#line 1065
int err=NC_NOERR;
-#line 1037
+#line 1065
ix_int xx;
-#line 1037
+#line 1065
get_ix_int(xp, &xx);
-#line 1037
+#line 1065
-#line 1037
+#line 1065
#if IX_INT_MAX > USHORT_MAX
-#line 1037
+#line 1065
if (xx > USHORT_MAX) {
-#line 1037
-
-#line 1037
+#line 1065
+#ifdef ERANGE_FILL
+#line 1065
+ *ip = NC_FILL_USHORT;
+#line 1065
+ return NC_ERANGE;
+#line 1065
+#else
+#line 1065
err = NC_ERANGE;
-#line 1037
+#line 1065
+#endif
+#line 1065
}
-#line 1037
+#line 1065
#endif
-#line 1037
+#line 1065
-#line 1037
+#line 1065
if (xx < 0) {
-#line 1037
-
-#line 1037
+#line 1065
+#ifdef ERANGE_FILL
+#line 1065
+ *ip = NC_FILL_USHORT;
+#line 1065
+ return NC_ERANGE;
+#line 1065
+#else
+#line 1065
err = NC_ERANGE; /* because ip is unsigned */
-#line 1037
+#line 1065
+#endif
+#line 1065
}
-#line 1037
+#line 1065
*ip = (ushort) xx;
-#line 1037
+#line 1065
return err;
-#line 1037
+#line 1065
}
-#line 1037
+#line 1065
static int
-#line 1038
+#line 1066
ncx_get_int_uchar(const void *xp, uchar *ip)
-#line 1038
+#line 1066
{
-#line 1038
+#line 1066
int err=NC_NOERR;
-#line 1038
+#line 1066
ix_int xx;
-#line 1038
+#line 1066
get_ix_int(xp, &xx);
-#line 1038
+#line 1066
-#line 1038
+#line 1066
#if IX_INT_MAX > UCHAR_MAX
-#line 1038
+#line 1066
if (xx > UCHAR_MAX) {
-#line 1038
-
-#line 1038
+#line 1066
+#ifdef ERANGE_FILL
+#line 1066
+ *ip = NC_FILL_UBYTE;
+#line 1066
+ return NC_ERANGE;
+#line 1066
+#else
+#line 1066
err = NC_ERANGE;
-#line 1038
+#line 1066
+#endif
+#line 1066
}
-#line 1038
+#line 1066
#endif
-#line 1038
+#line 1066
-#line 1038
+#line 1066
if (xx < 0) {
-#line 1038
-
-#line 1038
+#line 1066
+#ifdef ERANGE_FILL
+#line 1066
+ *ip = NC_FILL_UBYTE;
+#line 1066
+ return NC_ERANGE;
+#line 1066
+#else
+#line 1066
err = NC_ERANGE; /* because ip is unsigned */
-#line 1038
+#line 1066
+#endif
+#line 1066
}
-#line 1038
+#line 1066
*ip = (uchar) xx;
-#line 1038
+#line 1066
return err;
-#line 1038
+#line 1066
}
-#line 1038
+#line 1066
static int
-#line 1039
+#line 1067
ncx_get_int_uint(const void *xp, uint *ip)
-#line 1039
+#line 1067
{
-#line 1039
+#line 1067
int err=NC_NOERR;
-#line 1039
+#line 1067
ix_int xx;
-#line 1039
+#line 1067
get_ix_int(xp, &xx);
-#line 1039
+#line 1067
-#line 1039
+#line 1067
#if IX_INT_MAX > UINT_MAX
-#line 1039
+#line 1067
if (xx > UINT_MAX) {
-#line 1039
-
-#line 1039
+#line 1067
+#ifdef ERANGE_FILL
+#line 1067
+ *ip = NC_FILL_UINT;
+#line 1067
+ return NC_ERANGE;
+#line 1067
+#else
+#line 1067
err = NC_ERANGE;
-#line 1039
+#line 1067
+#endif
+#line 1067
}
-#line 1039
+#line 1067
#endif
-#line 1039
+#line 1067
-#line 1039
+#line 1067
if (xx < 0) {
-#line 1039
-
-#line 1039
+#line 1067
+#ifdef ERANGE_FILL
+#line 1067
+ *ip = NC_FILL_UINT;
+#line 1067
+ return NC_ERANGE;
+#line 1067
+#else
+#line 1067
err = NC_ERANGE; /* because ip is unsigned */
-#line 1039
+#line 1067
+#endif
+#line 1067
}
-#line 1039
+#line 1067
*ip = (uint) xx;
-#line 1039
+#line 1067
return err;
-#line 1039
+#line 1067
}
-#line 1039
+#line 1067
static int
-#line 1040
+#line 1068
ncx_get_int_ulonglong(const void *xp, ulonglong *ip)
-#line 1040
+#line 1068
{
-#line 1040
+#line 1068
int err=NC_NOERR;
-#line 1040
+#line 1068
ix_int xx;
-#line 1040
+#line 1068
get_ix_int(xp, &xx);
-#line 1040
+#line 1068
-#line 1040
+#line 1068
#if IX_INT_MAX > ULONGLONG_MAX
-#line 1040
+#line 1068
if (xx > ULONGLONG_MAX) {
-#line 1040
-
-#line 1040
+#line 1068
+#ifdef ERANGE_FILL
+#line 1068
+ *ip = NC_FILL_UINT64;
+#line 1068
+ return NC_ERANGE;
+#line 1068
+#else
+#line 1068
err = NC_ERANGE;
-#line 1040
+#line 1068
+#endif
+#line 1068
}
-#line 1040
+#line 1068
#endif
-#line 1040
+#line 1068
-#line 1040
+#line 1068
if (xx < 0) {
-#line 1040
-
-#line 1040
+#line 1068
+#ifdef ERANGE_FILL
+#line 1068
+ *ip = NC_FILL_UINT64;
+#line 1068
+ return NC_ERANGE;
+#line 1068
+#else
+#line 1068
err = NC_ERANGE; /* because ip is unsigned */
-#line 1040
+#line 1068
+#endif
+#line 1068
}
-#line 1040
+#line 1068
*ip = (ulonglong) xx;
-#line 1040
+#line 1068
return err;
-#line 1040
+#line 1068
}
-#line 1040
+#line 1068
static int
-#line 1041
+#line 1069
ncx_get_int_float(const void *xp, float *ip)
-#line 1041
+#line 1069
{
-#line 1041
+#line 1069
ix_int xx;
-#line 1041
+#line 1069
get_ix_int(xp, &xx);
-#line 1041
+#line 1069
*ip = (float)xx;
-#line 1041
+#line 1069
return NC_NOERR;
-#line 1041
+#line 1069
}
-#line 1041
+#line 1069
static int
-#line 1042
+#line 1070
ncx_get_int_double(const void *xp, double *ip)
-#line 1042
+#line 1070
{
-#line 1042
+#line 1070
ix_int xx;
-#line 1042
+#line 1070
get_ix_int(xp, &xx);
-#line 1042
+#line 1070
*ip = (double)xx;
-#line 1042
+#line 1070
return NC_NOERR;
-#line 1042
+#line 1070
}
-#line 1042
+#line 1070
static int
@@ -2738,344 +3290,452 @@ ncx_put_int_uchar(void *xp, const uchar *ip, void *fillp)
#if X_SIZEOF_INT != SIZEOF_INT
static int
-#line 1076
+#line 1104
ncx_put_int_int(void *xp, const int *ip, void *fillp)
-#line 1076
+#line 1104
{
-#line 1076
+#line 1104
int err=NC_NOERR;
-#line 1076
+#line 1104
#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-#line 1076
+#line 1104
put_ix_int(xp, (const ix_int *)ip);
-#line 1076
+#line 1104
#else
-#line 1076
+#line 1104
ix_int xx = NC_FILL_INT;
-#line 1076
+#line 1104
-#line 1076
+#line 1104
#if IX_INT_MAX < INT_MAX
-#line 1076
+#line 1104
if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
-#line 1076
+#line 1104
-#line 1076
+#line 1104
+#ifdef ERANGE_FILL
+#line 1104
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1104
+#endif
+#line 1104
err = NC_ERANGE;
-#line 1076
- }
-#line 1076
+#line 1104
+ }
+#line 1104
+#ifdef ERANGE_FILL
+#line 1104
+ else
+#line 1104
#endif
-#line 1076
+#line 1104
+#endif
+#line 1104
xx = (ix_int)*ip;
-#line 1076
+#line 1104
-#line 1076
+#line 1104
put_ix_int(xp, &xx);
-#line 1076
+#line 1104
#endif
-#line 1076
+#line 1104
return err;
-#line 1076
+#line 1104
}
-#line 1076
+#line 1104
#endif
static int
-#line 1078
+#line 1106
ncx_put_int_short(void *xp, const short *ip, void *fillp)
-#line 1078
+#line 1106
{
-#line 1078
+#line 1106
int err=NC_NOERR;
-#line 1078
+#line 1106
#if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
-#line 1078
+#line 1106
put_ix_int(xp, (const ix_int *)ip);
-#line 1078
+#line 1106
#else
-#line 1078
+#line 1106
ix_int xx = NC_FILL_INT;
-#line 1078
+#line 1106
-#line 1078
+#line 1106
#if IX_INT_MAX < SHORT_MAX
-#line 1078
+#line 1106
if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
-#line 1078
+#line 1106
-#line 1078
+#line 1106
+#ifdef ERANGE_FILL
+#line 1106
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1106
+#endif
+#line 1106
err = NC_ERANGE;
-#line 1078
- }
-#line 1078
+#line 1106
+ }
+#line 1106
+#ifdef ERANGE_FILL
+#line 1106
+ else
+#line 1106
#endif
-#line 1078
+#line 1106
+#endif
+#line 1106
xx = (ix_int)*ip;
-#line 1078
+#line 1106
-#line 1078
+#line 1106
put_ix_int(xp, &xx);
-#line 1078
+#line 1106
#endif
-#line 1078
+#line 1106
return err;
-#line 1078
+#line 1106
}
-#line 1078
+#line 1106
static int
-#line 1079
+#line 1107
ncx_put_int_long(void *xp, const long *ip, void *fillp)
-#line 1079
+#line 1107
{
-#line 1079
+#line 1107
int err=NC_NOERR;
-#line 1079
+#line 1107
#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
-#line 1079
+#line 1107
put_ix_int(xp, (const ix_int *)ip);
-#line 1079
+#line 1107
#else
-#line 1079
+#line 1107
ix_int xx = NC_FILL_INT;
-#line 1079
+#line 1107
-#line 1079
+#line 1107
#if IX_INT_MAX < LONG_MAX
-#line 1079
+#line 1107
if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
-#line 1079
+#line 1107
-#line 1079
+#line 1107
+#ifdef ERANGE_FILL
+#line 1107
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1107
+#endif
+#line 1107
err = NC_ERANGE;
-#line 1079
- }
-#line 1079
+#line 1107
+ }
+#line 1107
+#ifdef ERANGE_FILL
+#line 1107
+ else
+#line 1107
#endif
-#line 1079
+#line 1107
+#endif
+#line 1107
xx = (ix_int)*ip;
-#line 1079
+#line 1107
-#line 1079
+#line 1107
put_ix_int(xp, &xx);
-#line 1079
+#line 1107
#endif
-#line 1079
+#line 1107
return err;
-#line 1079
+#line 1107
}
-#line 1079
+#line 1107
static int
-#line 1080
+#line 1108
ncx_put_int_longlong(void *xp, const longlong *ip, void *fillp)
-#line 1080
+#line 1108
{
-#line 1080
+#line 1108
int err=NC_NOERR;
-#line 1080
+#line 1108
#if SIZEOF_IX_INT == SIZEOF_LONGLONG && IX_INT_MAX == LONGLONG_MAX
-#line 1080
+#line 1108
put_ix_int(xp, (const ix_int *)ip);
-#line 1080
+#line 1108
#else
-#line 1080
+#line 1108
ix_int xx = NC_FILL_INT;
-#line 1080
+#line 1108
-#line 1080
+#line 1108
#if IX_INT_MAX < LONGLONG_MAX
-#line 1080
+#line 1108
if (*ip > IX_INT_MAX || *ip < X_INT_MIN) {
-#line 1080
+#line 1108
-#line 1080
+#line 1108
+#ifdef ERANGE_FILL
+#line 1108
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1108
+#endif
+#line 1108
err = NC_ERANGE;
-#line 1080
- }
-#line 1080
+#line 1108
+ }
+#line 1108
+#ifdef ERANGE_FILL
+#line 1108
+ else
+#line 1108
#endif
-#line 1080
+#line 1108
+#endif
+#line 1108
xx = (ix_int)*ip;
-#line 1080
+#line 1108
-#line 1080
+#line 1108
put_ix_int(xp, &xx);
-#line 1080
+#line 1108
#endif
-#line 1080
+#line 1108
return err;
-#line 1080
+#line 1108
}
-#line 1080
+#line 1108
static int
-#line 1081
+#line 1109
ncx_put_int_ushort(void *xp, const ushort *ip, void *fillp)
-#line 1081
+#line 1109
{
-#line 1081
+#line 1109
int err=NC_NOERR;
-#line 1081
+#line 1109
ix_int xx = NC_FILL_INT;
-#line 1081
+#line 1109
-#line 1081
+#line 1109
#if IX_INT_MAX < USHORT_MAX
-#line 1081
+#line 1109
if (*ip > IX_INT_MAX) {
-#line 1081
+#line 1109
-#line 1081
+#line 1109
+#ifdef ERANGE_FILL
+#line 1109
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1109
+#endif
+#line 1109
err = NC_ERANGE;
-#line 1081
- }
-#line 1081
+#line 1109
+ }
+#line 1109
+#ifdef ERANGE_FILL
+#line 1109
+ else
+#line 1109
#endif
-#line 1081
+#line 1109
+#endif
+#line 1109
xx = (ix_int)*ip;
-#line 1081
+#line 1109
-#line 1081
+#line 1109
put_ix_int(xp, &xx);
-#line 1081
+#line 1109
return err;
-#line 1081
+#line 1109
}
-#line 1081
+#line 1109
static int
-#line 1082
+#line 1110
ncx_put_int_uint(void *xp, const uint *ip, void *fillp)
-#line 1082
+#line 1110
{
-#line 1082
+#line 1110
int err=NC_NOERR;
-#line 1082
+#line 1110
ix_int xx = NC_FILL_INT;
-#line 1082
+#line 1110
-#line 1082
+#line 1110
#if IX_INT_MAX < UINT_MAX
-#line 1082
+#line 1110
if (*ip > IX_INT_MAX) {
-#line 1082
+#line 1110
-#line 1082
+#line 1110
+#ifdef ERANGE_FILL
+#line 1110
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1110
+#endif
+#line 1110
err = NC_ERANGE;
-#line 1082
- }
-#line 1082
+#line 1110
+ }
+#line 1110
+#ifdef ERANGE_FILL
+#line 1110
+ else
+#line 1110
#endif
-#line 1082
+#line 1110
+#endif
+#line 1110
xx = (ix_int)*ip;
-#line 1082
+#line 1110
-#line 1082
+#line 1110
put_ix_int(xp, &xx);
-#line 1082
+#line 1110
return err;
-#line 1082
+#line 1110
}
-#line 1082
+#line 1110
static int
-#line 1083
+#line 1111
ncx_put_int_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 1083
+#line 1111
{
-#line 1083
+#line 1111
int err=NC_NOERR;
-#line 1083
+#line 1111
ix_int xx = NC_FILL_INT;
-#line 1083
+#line 1111
-#line 1083
+#line 1111
#if IX_INT_MAX < ULONGLONG_MAX
-#line 1083
+#line 1111
if (*ip > IX_INT_MAX) {
-#line 1083
+#line 1111
-#line 1083
+#line 1111
+#ifdef ERANGE_FILL
+#line 1111
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1111
+#endif
+#line 1111
err = NC_ERANGE;
-#line 1083
- }
-#line 1083
+#line 1111
+ }
+#line 1111
+#ifdef ERANGE_FILL
+#line 1111
+ else
+#line 1111
#endif
-#line 1083
+#line 1111
+#endif
+#line 1111
xx = (ix_int)*ip;
-#line 1083
+#line 1111
-#line 1083
+#line 1111
put_ix_int(xp, &xx);
-#line 1083
+#line 1111
return err;
-#line 1083
+#line 1111
}
-#line 1083
+#line 1111
static int
-#line 1084
+#line 1112
ncx_put_int_float(void *xp, const float *ip, void *fillp)
-#line 1084
+#line 1112
{
-#line 1084
+#line 1112
int err=NC_NOERR;
-#line 1084
+#line 1112
ix_int xx = NC_FILL_INT;
-#line 1084
+#line 1112
-#line 1084
+#line 1112
if (*ip > (double)X_INT_MAX || *ip < (double)X_INT_MIN) {
-#line 1084
+#line 1112
-#line 1084
+#line 1112
+#ifdef ERANGE_FILL
+#line 1112
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1112
+#endif
+#line 1112
err = NC_ERANGE;
-#line 1084
- }
-#line 1084
+#line 1112
+ }
+#line 1112
+#ifdef ERANGE_FILL
+#line 1112
+ else
+#line 1112
+#endif
+#line 1112
xx = (ix_int)*ip;
-#line 1084
+#line 1112
-#line 1084
+#line 1112
put_ix_int(xp, &xx);
-#line 1084
+#line 1112
return err;
-#line 1084
+#line 1112
}
-#line 1084
+#line 1112
static int
-#line 1085
+#line 1113
ncx_put_int_double(void *xp, const double *ip, void *fillp)
-#line 1085
+#line 1113
{
-#line 1085
+#line 1113
int err=NC_NOERR;
-#line 1085
+#line 1113
ix_int xx = NC_FILL_INT;
-#line 1085
+#line 1113
-#line 1085
+#line 1113
if (*ip > X_INT_MAX || *ip < X_INT_MIN) {
-#line 1085
+#line 1113
-#line 1085
+#line 1113
+#ifdef ERANGE_FILL
+#line 1113
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1113
+#endif
+#line 1113
err = NC_ERANGE;
-#line 1085
- }
-#line 1085
+#line 1113
+ }
+#line 1113
+#ifdef ERANGE_FILL
+#line 1113
+ else
+#line 1113
+#endif
+#line 1113
xx = (ix_int)*ip;
-#line 1085
+#line 1113
-#line 1085
+#line 1113
put_ix_int(xp, &xx);
-#line 1085
+#line 1113
return err;
-#line 1085
+#line 1113
}
-#line 1085
+#line 1113
@@ -3122,405 +3782,477 @@ put_ix_uint(void *xp, const ix_uint *ip)
#if X_SIZEOF_UINT != SIZEOF_UINT
static int
-#line 1130
+#line 1158
ncx_get_uint_uint(const void *xp, uint *ip)
-#line 1130
+#line 1158
{
-#line 1130
+#line 1158
int err=NC_NOERR;
-#line 1130
+#line 1158
#if SIZEOF_IX_UINT == SIZEOF_UINT && IX_UINT_MAX == UINT_MAX
-#line 1130
+#line 1158
get_ix_uint(xp, (ix_uint *)ip);
-#line 1130
+#line 1158
#else
-#line 1130
+#line 1158
ix_uint xx;
-#line 1130
+#line 1158
get_ix_uint(xp, &xx);
-#line 1130
+#line 1158
-#line 1130
+#line 1158
#if IX_UINT_MAX > UINT_MAX
-#line 1130
+#line 1158
if (xx > UINT_MAX) {
-#line 1130
-
-#line 1130
+#line 1158
+#ifdef ERANGE_FILL
+#line 1158
+ *ip = NC_FILL_UINT;
+#line 1158
+ return NC_ERANGE;
+#line 1158
+#else
+#line 1158
err = NC_ERANGE;
-#line 1130
+#line 1158
+#endif
+#line 1158
}
-#line 1130
+#line 1158
#endif
-#line 1130
+#line 1158
-#line 1130
+#line 1158
-#line 1130
+#line 1158
*ip = (uint) xx;
-#line 1130
+#line 1158
#endif
-#line 1130
+#line 1158
return err;
-#line 1130
+#line 1158
}
-#line 1130
+#line 1158
#endif
static int
-#line 1133
+#line 1161
ncx_get_uint_schar(const void *xp, schar *ip)
-#line 1133
+#line 1161
{
-#line 1133
+#line 1161
int err=NC_NOERR;
-#line 1133
+#line 1161
ix_uint xx;
-#line 1133
+#line 1161
get_ix_uint(xp, &xx);
-#line 1133
+#line 1161
-#line 1133
+#line 1161
#if IX_UINT_MAX > SCHAR_MAX
-#line 1133
+#line 1161
if (xx > SCHAR_MAX) {
-#line 1133
-
-#line 1133
+#line 1161
+#ifdef ERANGE_FILL
+#line 1161
+ *ip = NC_FILL_BYTE;
+#line 1161
+ return NC_ERANGE;
+#line 1161
+#else
+#line 1161
err = NC_ERANGE;
-#line 1133
+#line 1161
+#endif
+#line 1161
}
-#line 1133
+#line 1161
#endif
-#line 1133
+#line 1161
-#line 1133
+#line 1161
-#line 1133
+#line 1161
*ip = (schar) xx;
-#line 1133
+#line 1161
return err;
-#line 1133
+#line 1161
}
-#line 1133
+#line 1161
static int
-#line 1134
+#line 1162
ncx_get_uint_short(const void *xp, short *ip)
-#line 1134
+#line 1162
{
-#line 1134
+#line 1162
int err=NC_NOERR;
-#line 1134
+#line 1162
ix_uint xx;
-#line 1134
+#line 1162
get_ix_uint(xp, &xx);
-#line 1134
+#line 1162
-#line 1134
+#line 1162
#if IX_UINT_MAX > SHORT_MAX
-#line 1134
+#line 1162
if (xx > SHORT_MAX) {
-#line 1134
-
-#line 1134
+#line 1162
+#ifdef ERANGE_FILL
+#line 1162
+ *ip = NC_FILL_SHORT;
+#line 1162
+ return NC_ERANGE;
+#line 1162
+#else
+#line 1162
err = NC_ERANGE;
-#line 1134
+#line 1162
+#endif
+#line 1162
}
-#line 1134
+#line 1162
#endif
-#line 1134
+#line 1162
-#line 1134
+#line 1162
-#line 1134
+#line 1162
*ip = (short) xx;
-#line 1134
+#line 1162
return err;
-#line 1134
+#line 1162
}
-#line 1134
+#line 1162
static int
-#line 1135
+#line 1163
ncx_get_uint_int(const void *xp, int *ip)
-#line 1135
+#line 1163
{
-#line 1135
+#line 1163
int err=NC_NOERR;
-#line 1135
+#line 1163
ix_uint xx;
-#line 1135
+#line 1163
get_ix_uint(xp, &xx);
-#line 1135
+#line 1163
-#line 1135
+#line 1163
#if IX_UINT_MAX > INT_MAX
-#line 1135
+#line 1163
if (xx > INT_MAX) {
-#line 1135
-
-#line 1135
+#line 1163
+#ifdef ERANGE_FILL
+#line 1163
+ *ip = NC_FILL_INT;
+#line 1163
+ return NC_ERANGE;
+#line 1163
+#else
+#line 1163
err = NC_ERANGE;
-#line 1135
+#line 1163
+#endif
+#line 1163
}
-#line 1135
+#line 1163
#endif
-#line 1135
+#line 1163
-#line 1135
+#line 1163
-#line 1135
+#line 1163
*ip = (int) xx;
-#line 1135
+#line 1163
return err;
-#line 1135
+#line 1163
}
-#line 1135
+#line 1163
static int
-#line 1136
+#line 1164
ncx_get_uint_long(const void *xp, long *ip)
-#line 1136
+#line 1164
{
-#line 1136
+#line 1164
int err=NC_NOERR;
-#line 1136
+#line 1164
ix_uint xx;
-#line 1136
+#line 1164
get_ix_uint(xp, &xx);
-#line 1136
+#line 1164
-#line 1136
+#line 1164
#if IX_UINT_MAX > LONG_MAX
-#line 1136
+#line 1164
if (xx > LONG_MAX) {
-#line 1136
-
-#line 1136
+#line 1164
+#ifdef ERANGE_FILL
+#line 1164
+ *ip = NC_FILL_INT;
+#line 1164
+ return NC_ERANGE;
+#line 1164
+#else
+#line 1164
err = NC_ERANGE;
-#line 1136
+#line 1164
+#endif
+#line 1164
}
-#line 1136
+#line 1164
#endif
-#line 1136
+#line 1164
-#line 1136
+#line 1164
-#line 1136
+#line 1164
*ip = (long) xx;
-#line 1136
+#line 1164
return err;
-#line 1136
+#line 1164
}
-#line 1136
+#line 1164
static int
-#line 1137
+#line 1165
ncx_get_uint_longlong(const void *xp, longlong *ip)
-#line 1137
+#line 1165
{
-#line 1137
+#line 1165
int err=NC_NOERR;
-#line 1137
+#line 1165
ix_uint xx;
-#line 1137
+#line 1165
get_ix_uint(xp, &xx);
-#line 1137
+#line 1165
-#line 1137
+#line 1165
#if IX_UINT_MAX > LONGLONG_MAX
-#line 1137
+#line 1165
if (xx > LONGLONG_MAX) {
-#line 1137
-
-#line 1137
+#line 1165
+#ifdef ERANGE_FILL
+#line 1165
+ *ip = NC_FILL_INT64;
+#line 1165
+ return NC_ERANGE;
+#line 1165
+#else
+#line 1165
err = NC_ERANGE;
-#line 1137
+#line 1165
+#endif
+#line 1165
}
-#line 1137
+#line 1165
#endif
-#line 1137
+#line 1165
-#line 1137
+#line 1165
-#line 1137
+#line 1165
*ip = (longlong) xx;
-#line 1137
+#line 1165
return err;
-#line 1137
+#line 1165
}
-#line 1137
+#line 1165
static int
-#line 1138
+#line 1166
ncx_get_uint_ushort(const void *xp, ushort *ip)
-#line 1138
+#line 1166
{
-#line 1138
+#line 1166
int err=NC_NOERR;
-#line 1138
+#line 1166
#if SIZEOF_IX_UINT == SIZEOF_USHORT && IX_UINT_MAX == USHORT_MAX
-#line 1138
+#line 1166
get_ix_uint(xp, (ix_uint *)ip);
-#line 1138
+#line 1166
#else
-#line 1138
+#line 1166
ix_uint xx;
-#line 1138
+#line 1166
get_ix_uint(xp, &xx);
-#line 1138
+#line 1166
-#line 1138
+#line 1166
#if IX_UINT_MAX > USHORT_MAX
-#line 1138
+#line 1166
if (xx > USHORT_MAX) {
-#line 1138
-
-#line 1138
+#line 1166
+#ifdef ERANGE_FILL
+#line 1166
+ *ip = NC_FILL_USHORT;
+#line 1166
+ return NC_ERANGE;
+#line 1166
+#else
+#line 1166
err = NC_ERANGE;
-#line 1138
+#line 1166
+#endif
+#line 1166
}
-#line 1138
+#line 1166
#endif
-#line 1138
+#line 1166
-#line 1138
+#line 1166
-#line 1138
+#line 1166
*ip = (ushort) xx;
-#line 1138
+#line 1166
#endif
-#line 1138
+#line 1166
return err;
-#line 1138
+#line 1166
}
-#line 1138
+#line 1166
static int
-#line 1139
+#line 1167
ncx_get_uint_uchar(const void *xp, uchar *ip)
-#line 1139
+#line 1167
{
-#line 1139
+#line 1167
int err=NC_NOERR;
-#line 1139
+#line 1167
#if SIZEOF_IX_UINT == SIZEOF_UCHAR && IX_UINT_MAX == UCHAR_MAX
-#line 1139
+#line 1167
get_ix_uint(xp, (ix_uint *)ip);
-#line 1139
+#line 1167
#else
-#line 1139
+#line 1167
ix_uint xx;
-#line 1139
+#line 1167
get_ix_uint(xp, &xx);
-#line 1139
+#line 1167
-#line 1139
+#line 1167
#if IX_UINT_MAX > UCHAR_MAX
-#line 1139
+#line 1167
if (xx > UCHAR_MAX) {
-#line 1139
-
-#line 1139
+#line 1167
+#ifdef ERANGE_FILL
+#line 1167
+ *ip = NC_FILL_UBYTE;
+#line 1167
+ return NC_ERANGE;
+#line 1167
+#else
+#line 1167
err = NC_ERANGE;
-#line 1139
+#line 1167
+#endif
+#line 1167
}
-#line 1139
+#line 1167
#endif
-#line 1139
+#line 1167
-#line 1139
+#line 1167
-#line 1139
+#line 1167
*ip = (uchar) xx;
-#line 1139
+#line 1167
#endif
-#line 1139
+#line 1167
return err;
-#line 1139
+#line 1167
}
-#line 1139
+#line 1167
static int
-#line 1140
+#line 1168
ncx_get_uint_ulonglong(const void *xp, ulonglong *ip)
-#line 1140
+#line 1168
{
-#line 1140
+#line 1168
int err=NC_NOERR;
-#line 1140
+#line 1168
#if SIZEOF_IX_UINT == SIZEOF_ULONGLONG && IX_UINT_MAX == ULONGLONG_MAX
-#line 1140
+#line 1168
get_ix_uint(xp, (ix_uint *)ip);
-#line 1140
+#line 1168
#else
-#line 1140
+#line 1168
ix_uint xx;
-#line 1140
+#line 1168
get_ix_uint(xp, &xx);
-#line 1140
+#line 1168
-#line 1140
+#line 1168
#if IX_UINT_MAX > ULONGLONG_MAX
-#line 1140
+#line 1168
if (xx > ULONGLONG_MAX) {
-#line 1140
-
-#line 1140
+#line 1168
+#ifdef ERANGE_FILL
+#line 1168
+ *ip = NC_FILL_UINT64;
+#line 1168
+ return NC_ERANGE;
+#line 1168
+#else
+#line 1168
err = NC_ERANGE;
-#line 1140
+#line 1168
+#endif
+#line 1168
}
-#line 1140
+#line 1168
#endif
-#line 1140
+#line 1168
-#line 1140
+#line 1168
-#line 1140
+#line 1168
*ip = (ulonglong) xx;
-#line 1140
+#line 1168
#endif
-#line 1140
+#line 1168
return err;
-#line 1140
+#line 1168
}
-#line 1140
+#line 1168
static int
-#line 1141
+#line 1169
ncx_get_uint_float(const void *xp, float *ip)
-#line 1141
+#line 1169
{
-#line 1141
+#line 1169
ix_uint xx;
-#line 1141
+#line 1169
get_ix_uint(xp, &xx);
-#line 1141
+#line 1169
*ip = (float)xx;
-#line 1141
+#line 1169
return NC_NOERR;
-#line 1141
+#line 1169
}
-#line 1141
+#line 1169
static int
-#line 1142
+#line 1170
ncx_get_uint_double(const void *xp, double *ip)
-#line 1142
+#line 1170
{
-#line 1142
+#line 1170
ix_uint xx;
-#line 1142
+#line 1170
get_ix_uint(xp, &xx);
-#line 1142
+#line 1170
*ip = (double)xx;
-#line 1142
+#line 1170
return NC_NOERR;
-#line 1142
+#line 1170
}
-#line 1142
+#line 1170
static int
@@ -3528,8 +4260,12 @@ ncx_put_uint_schar(void *xp, const schar *ip, void *fillp)
{
uchar *cp;
if (*ip < 0) {
-#line 1153
-
+#ifdef ERANGE_FILL
+ if (fillp != NULL) memcpy(xp, fillp, 4);
+#ifndef WORDS_BIGENDIAN
+ swapn4b(xp, xp, 1);
+#endif
+#endif
return NC_ERANGE;
}
@@ -3555,369 +4291,525 @@ ncx_put_uint_uchar(void *xp, const uchar *ip, void *fillp)
#if X_SIZEOF_UINT != SIZEOF_UINT
static int
-#line 1178
+#line 1207
ncx_put_uint_uint(void *xp, const uint *ip, void *fillp)
-#line 1178
+#line 1207
{
-#line 1178
+#line 1207
int err=NC_NOERR;
-#line 1178
+#line 1207
#if SIZEOF_IX_UINT == SIZEOF_UINT && IX_UINT_MAX == UINT_MAX
-#line 1178
+#line 1207
put_ix_uint(xp, (const ix_uint *)ip);
-#line 1178
+#line 1207
#else
-#line 1178
+#line 1207
ix_uint xx = NC_FILL_UINT;
-#line 1178
+#line 1207
-#line 1178
+#line 1207
#if IX_UINT_MAX < UINT_MAX
-#line 1178
+#line 1207
if (*ip > IX_UINT_MAX) {
-#line 1178
+#line 1207
-#line 1178
+#line 1207
+#ifdef ERANGE_FILL
+#line 1207
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1207
+#endif
+#line 1207
err = NC_ERANGE;
-#line 1178
- }
-#line 1178
+#line 1207
+ }
+#line 1207
+#ifdef ERANGE_FILL
+#line 1207
+ else
+#line 1207
#endif
-#line 1178
+#line 1207
+#endif
+#line 1207
xx = (ix_uint)*ip;
-#line 1178
+#line 1207
-#line 1178
+#line 1207
put_ix_uint(xp, &xx);
-#line 1178
+#line 1207
#endif
-#line 1178
+#line 1207
return err;
-#line 1178
+#line 1207
}
-#line 1178
+#line 1207
#endif
static int
-#line 1181
+#line 1210
ncx_put_uint_short(void *xp, const short *ip, void *fillp)
-#line 1181
+#line 1210
{
-#line 1181
+#line 1210
int err=NC_NOERR;
-#line 1181
+#line 1210
ix_uint xx = NC_FILL_UINT;
-#line 1181
+#line 1210
-#line 1181
+#line 1210
#if IX_UINT_MAX < SHORT_MAX
-#line 1181
+#line 1210
if (*ip > IX_UINT_MAX) {
-#line 1181
+#line 1210
-#line 1181
+#line 1210
+#ifdef ERANGE_FILL
+#line 1210
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1210
+#endif
+#line 1210
err = NC_ERANGE;
-#line 1181
- }
-#line 1181
+#line 1210
+ }
+#line 1210
+#ifdef ERANGE_FILL
+#line 1210
+ else
+#line 1210
#endif
-#line 1181
+#line 1210
+#endif
+#line 1210
if (*ip < 0) {
-#line 1181
+#line 1210
-#line 1181
+#line 1210
+#ifdef ERANGE_FILL
+#line 1210
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1210
+#endif
+#line 1210
err = NC_ERANGE; /* because xp is unsigned */
-#line 1181
- }
-#line 1181
+#line 1210
+ }
+#line 1210
+#ifdef ERANGE_FILL
+#line 1210
+ else
+#line 1210
+#endif
+#line 1210
xx = (ix_uint)*ip;
-#line 1181
+#line 1210
-#line 1181
+#line 1210
put_ix_uint(xp, &xx);
-#line 1181
+#line 1210
return err;
-#line 1181
+#line 1210
}
-#line 1181
+#line 1210
static int
-#line 1182
+#line 1211
ncx_put_uint_int(void *xp, const int *ip, void *fillp)
-#line 1182
+#line 1211
{
-#line 1182
+#line 1211
int err=NC_NOERR;
-#line 1182
+#line 1211
ix_uint xx = NC_FILL_UINT;
-#line 1182
+#line 1211
-#line 1182
+#line 1211
#if IX_UINT_MAX < INT_MAX
-#line 1182
+#line 1211
if (*ip > IX_UINT_MAX) {
-#line 1182
+#line 1211
-#line 1182
+#line 1211
+#ifdef ERANGE_FILL
+#line 1211
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1211
+#endif
+#line 1211
err = NC_ERANGE;
-#line 1182
- }
-#line 1182
+#line 1211
+ }
+#line 1211
+#ifdef ERANGE_FILL
+#line 1211
+ else
+#line 1211
#endif
-#line 1182
+#line 1211
+#endif
+#line 1211
if (*ip < 0) {
-#line 1182
+#line 1211
-#line 1182
+#line 1211
+#ifdef ERANGE_FILL
+#line 1211
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1211
+#endif
+#line 1211
err = NC_ERANGE; /* because xp is unsigned */
-#line 1182
- }
-#line 1182
+#line 1211
+ }
+#line 1211
+#ifdef ERANGE_FILL
+#line 1211
+ else
+#line 1211
+#endif
+#line 1211
xx = (ix_uint)*ip;
-#line 1182
+#line 1211
-#line 1182
+#line 1211
put_ix_uint(xp, &xx);
-#line 1182
+#line 1211
return err;
-#line 1182
+#line 1211
}
-#line 1182
+#line 1211
static int
-#line 1183
+#line 1212
ncx_put_uint_long(void *xp, const long *ip, void *fillp)
-#line 1183
+#line 1212
{
-#line 1183
+#line 1212
int err=NC_NOERR;
-#line 1183
+#line 1212
ix_uint xx = NC_FILL_UINT;
-#line 1183
+#line 1212
-#line 1183
+#line 1212
#if IX_UINT_MAX < LONG_MAX
-#line 1183
+#line 1212
if (*ip > IX_UINT_MAX) {
-#line 1183
+#line 1212
-#line 1183
+#line 1212
+#ifdef ERANGE_FILL
+#line 1212
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1212
+#endif
+#line 1212
err = NC_ERANGE;
-#line 1183
- }
-#line 1183
+#line 1212
+ }
+#line 1212
+#ifdef ERANGE_FILL
+#line 1212
+ else
+#line 1212
#endif
-#line 1183
+#line 1212
+#endif
+#line 1212
if (*ip < 0) {
-#line 1183
+#line 1212
-#line 1183
+#line 1212
+#ifdef ERANGE_FILL
+#line 1212
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1212
+#endif
+#line 1212
err = NC_ERANGE; /* because xp is unsigned */
-#line 1183
- }
-#line 1183
+#line 1212
+ }
+#line 1212
+#ifdef ERANGE_FILL
+#line 1212
+ else
+#line 1212
+#endif
+#line 1212
xx = (ix_uint)*ip;
-#line 1183
+#line 1212
-#line 1183
+#line 1212
put_ix_uint(xp, &xx);
-#line 1183
+#line 1212
return err;
-#line 1183
+#line 1212
}
-#line 1183
+#line 1212
static int
-#line 1184
+#line 1213
ncx_put_uint_longlong(void *xp, const longlong *ip, void *fillp)
-#line 1184
+#line 1213
{
-#line 1184
+#line 1213
int err=NC_NOERR;
-#line 1184
+#line 1213
ix_uint xx = NC_FILL_UINT;
-#line 1184
+#line 1213
-#line 1184
+#line 1213
#if IX_UINT_MAX < LONGLONG_MAX
-#line 1184
+#line 1213
if (*ip > IX_UINT_MAX) {
-#line 1184
+#line 1213
-#line 1184
+#line 1213
+#ifdef ERANGE_FILL
+#line 1213
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1213
+#endif
+#line 1213
err = NC_ERANGE;
-#line 1184
- }
-#line 1184
+#line 1213
+ }
+#line 1213
+#ifdef ERANGE_FILL
+#line 1213
+ else
+#line 1213
#endif
-#line 1184
+#line 1213
+#endif
+#line 1213
if (*ip < 0) {
-#line 1184
+#line 1213
-#line 1184
+#line 1213
+#ifdef ERANGE_FILL
+#line 1213
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1213
+#endif
+#line 1213
err = NC_ERANGE; /* because xp is unsigned */
-#line 1184
- }
-#line 1184
+#line 1213
+ }
+#line 1213
+#ifdef ERANGE_FILL
+#line 1213
+ else
+#line 1213
+#endif
+#line 1213
xx = (ix_uint)*ip;
-#line 1184
+#line 1213
-#line 1184
+#line 1213
put_ix_uint(xp, &xx);
-#line 1184
+#line 1213
return err;
-#line 1184
+#line 1213
}
-#line 1184
+#line 1213
static int
-#line 1185
+#line 1214
ncx_put_uint_ushort(void *xp, const ushort *ip, void *fillp)
-#line 1185
+#line 1214
{
-#line 1185
+#line 1214
int err=NC_NOERR;
-#line 1185
+#line 1214
#if SIZEOF_IX_UINT == SIZEOF_USHORT && IX_UINT_MAX == USHORT_MAX
-#line 1185
+#line 1214
put_ix_uint(xp, (const ix_uint *)ip);
-#line 1185
+#line 1214
#else
-#line 1185
+#line 1214
ix_uint xx = NC_FILL_UINT;
-#line 1185
+#line 1214
-#line 1185
+#line 1214
#if IX_UINT_MAX < USHORT_MAX
-#line 1185
+#line 1214
if (*ip > IX_UINT_MAX) {
-#line 1185
+#line 1214
-#line 1185
+#line 1214
+#ifdef ERANGE_FILL
+#line 1214
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1214
+#endif
+#line 1214
err = NC_ERANGE;
-#line 1185
- }
-#line 1185
+#line 1214
+ }
+#line 1214
+#ifdef ERANGE_FILL
+#line 1214
+ else
+#line 1214
#endif
-#line 1185
+#line 1214
+#endif
+#line 1214
xx = (ix_uint)*ip;
-#line 1185
+#line 1214
-#line 1185
+#line 1214
put_ix_uint(xp, &xx);
-#line 1185
+#line 1214
#endif
-#line 1185
+#line 1214
return err;
-#line 1185
+#line 1214
}
-#line 1185
+#line 1214
static int
-#line 1186
+#line 1215
ncx_put_uint_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 1186
+#line 1215
{
-#line 1186
+#line 1215
int err=NC_NOERR;
-#line 1186
+#line 1215
#if SIZEOF_IX_UINT == SIZEOF_ULONGLONG && IX_UINT_MAX == ULONGLONG_MAX
-#line 1186
+#line 1215
put_ix_uint(xp, (const ix_uint *)ip);
-#line 1186
+#line 1215
#else
-#line 1186
+#line 1215
ix_uint xx = NC_FILL_UINT;
-#line 1186
+#line 1215
-#line 1186
+#line 1215
#if IX_UINT_MAX < ULONGLONG_MAX
-#line 1186
+#line 1215
if (*ip > IX_UINT_MAX) {
-#line 1186
+#line 1215
-#line 1186
+#line 1215
+#ifdef ERANGE_FILL
+#line 1215
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1215
+#endif
+#line 1215
err = NC_ERANGE;
-#line 1186
- }
-#line 1186
+#line 1215
+ }
+#line 1215
+#ifdef ERANGE_FILL
+#line 1215
+ else
+#line 1215
#endif
-#line 1186
+#line 1215
+#endif
+#line 1215
xx = (ix_uint)*ip;
-#line 1186
+#line 1215
-#line 1186
+#line 1215
put_ix_uint(xp, &xx);
-#line 1186
+#line 1215
#endif
-#line 1186
+#line 1215
return err;
-#line 1186
+#line 1215
}
-#line 1186
+#line 1215
static int
-#line 1187
+#line 1216
ncx_put_uint_float(void *xp, const float *ip, void *fillp)
-#line 1187
+#line 1216
{
-#line 1187
+#line 1216
int err=NC_NOERR;
-#line 1187
+#line 1216
ix_uint xx = NC_FILL_UINT;
-#line 1187
+#line 1216
-#line 1187
+#line 1216
if (*ip > (double)X_UINT_MAX || *ip < 0) {
-#line 1187
+#line 1216
-#line 1187
+#line 1216
+#ifdef ERANGE_FILL
+#line 1216
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1216
+#endif
+#line 1216
err = NC_ERANGE;
-#line 1187
- }
-#line 1187
+#line 1216
+ }
+#line 1216
+#ifdef ERANGE_FILL
+#line 1216
+ else
+#line 1216
+#endif
+#line 1216
xx = (ix_uint)*ip;
-#line 1187
+#line 1216
-#line 1187
+#line 1216
put_ix_uint(xp, &xx);
-#line 1187
+#line 1216
return err;
-#line 1187
+#line 1216
}
-#line 1187
+#line 1216
static int
-#line 1188
+#line 1217
ncx_put_uint_double(void *xp, const double *ip, void *fillp)
-#line 1188
+#line 1217
{
-#line 1188
+#line 1217
int err=NC_NOERR;
-#line 1188
+#line 1217
ix_uint xx = NC_FILL_UINT;
-#line 1188
+#line 1217
-#line 1188
+#line 1217
if (*ip > X_UINT_MAX || *ip < 0) {
-#line 1188
+#line 1217
-#line 1188
+#line 1217
+#ifdef ERANGE_FILL
+#line 1217
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1217
+#endif
+#line 1217
err = NC_ERANGE;
-#line 1188
- }
-#line 1188
+#line 1217
+ }
+#line 1217
+#ifdef ERANGE_FILL
+#line 1217
+ else
+#line 1217
+#endif
+#line 1217
xx = (ix_uint)*ip;
-#line 1188
+#line 1217
-#line 1188
+#line 1217
put_ix_uint(xp, &xx);
-#line 1188
+#line 1217
return err;
-#line 1188
+#line 1217
}
-#line 1188
+#line 1217
@@ -3980,196 +4872,196 @@ static struct sgl_limits min = {
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } /* Min IEEE */
};
-#line 1302
+#line 1331
static void
get_ix_float(const void *xp, float *ip)
{
struct vax_single *const vsp = (struct vax_single *) ip;
-#line 1305
+#line 1334
const struct ieee_single *const isp =
-#line 1305
+#line 1334
(const struct ieee_single *) xp;
-#line 1305
+#line 1334
unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
-#line 1305
+#line 1334
-#line 1305
+#line 1334
switch(exp) {
-#line 1305
+#line 1334
case 0 :
-#line 1305
+#line 1334
/* ieee subnormal */
-#line 1305
+#line 1334
if (isp->mant_hi == min.ieee.mant_hi
-#line 1305
+#line 1334
&& isp->mant_lo_hi == min.ieee.mant_lo_hi
-#line 1305
+#line 1334
&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
-#line 1305
+#line 1334
{
-#line 1305
+#line 1334
*vsp = min.s;
-#line 1305
+#line 1334
}
-#line 1305
+#line 1334
else
-#line 1305
+#line 1334
{
-#line 1305
+#line 1334
unsigned mantissa = (isp->mant_hi << 16)
-#line 1305
+#line 1334
| isp->mant_lo_hi << 8
-#line 1305
+#line 1334
| isp->mant_lo_lo;
-#line 1305
+#line 1334
unsigned tmp = mantissa >> 20;
-#line 1305
+#line 1334
if (tmp >= 4) {
-#line 1305
+#line 1334
vsp->exp = 2;
-#line 1305
+#line 1334
} else if (tmp >= 2) {
-#line 1305
+#line 1334
vsp->exp = 1;
-#line 1305
+#line 1334
} else {
-#line 1305
+#line 1334
*vsp = min.s;
-#line 1305
+#line 1334
break;
-#line 1305
+#line 1334
} /* else */
-#line 1305
+#line 1334
tmp = mantissa - (1 << (20 + vsp->exp ));
-#line 1305
+#line 1334
tmp <<= 3 - vsp->exp;
-#line 1305
+#line 1334
vsp->mantissa2 = tmp;
-#line 1305
+#line 1334
vsp->mantissa1 = (tmp >> 16);
-#line 1305
+#line 1334
}
-#line 1305
+#line 1334
break;
-#line 1305
+#line 1334
case 0xfe :
-#line 1305
+#line 1334
case 0xff :
-#line 1305
+#line 1334
*vsp = max.s;
-#line 1305
+#line 1334
break;
-#line 1305
+#line 1334
default :
-#line 1305
+#line 1334
vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
-#line 1305
+#line 1334
vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
-#line 1305
+#line 1334
vsp->mantissa1 = isp->mant_hi;
-#line 1305
+#line 1334
}
-#line 1305
+#line 1334
-#line 1305
+#line 1334
vsp->sign = isp->sign;
-#line 1305
+#line 1334
}
-#line 1359
+#line 1388
static void
put_ix_float(void *xp, const float *ip)
{
const struct vax_single *const vsp =
-#line 1363
+#line 1392
(const struct vax_single *)ip;
-#line 1363
+#line 1392
struct ieee_single *const isp = (struct ieee_single *) xp;
-#line 1363
+#line 1392
-#line 1363
+#line 1392
switch(vsp->exp){
-#line 1363
+#line 1392
case 0 :
-#line 1363
+#line 1392
/* all vax float with zero exponent map to zero */
-#line 1363
+#line 1392
*isp = min.ieee;
-#line 1363
+#line 1392
break;
-#line 1363
+#line 1392
case 2 :
-#line 1363
+#line 1392
case 1 :
-#line 1363
+#line 1392
{
-#line 1363
+#line 1392
/* These will map to subnormals */
-#line 1363
+#line 1392
unsigned mantissa = (vsp->mantissa1 << 16)
-#line 1363
+#line 1392
| vsp->mantissa2;
-#line 1363
+#line 1392
mantissa >>= 3 - vsp->exp;
-#line 1363
+#line 1392
mantissa += (1 << (20 + vsp->exp));
-#line 1363
+#line 1392
isp->mant_lo_lo = mantissa;
-#line 1363
+#line 1392
isp->mant_lo_hi = mantissa >> 8;
-#line 1363
+#line 1392
isp->mant_hi = mantissa >> 16;
-#line 1363
+#line 1392
isp->exp_lo = 0;
-#line 1363
+#line 1392
isp->exp_hi = 0;
-#line 1363
+#line 1392
}
-#line 1363
+#line 1392
break;
-#line 1363
+#line 1392
case 0xff : /* max.s.exp */
-#line 1363
+#line 1392
if (vsp->mantissa2 == max.s.mantissa2 &&
-#line 1363
+#line 1392
vsp->mantissa1 == max.s.mantissa1)
-#line 1363
+#line 1392
{
-#line 1363
+#line 1392
/* map largest vax float to ieee infinity */
-#line 1363
+#line 1392
*isp = max.ieee;
-#line 1363
+#line 1392
break;
-#line 1363
+#line 1392
} /* else, fall thru */
-#line 1363
+#line 1392
default :
-#line 1363
+#line 1392
{
-#line 1363
+#line 1392
unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
-#line 1363
+#line 1392
isp->exp_hi = exp >> 1;
-#line 1363
+#line 1392
isp->exp_lo = exp;
-#line 1363
+#line 1392
isp->mant_lo_lo = vsp->mantissa2;
-#line 1363
+#line 1392
isp->mant_lo_hi = vsp->mantissa2 >> 8;
-#line 1363
+#line 1392
isp->mant_hi = vsp->mantissa1;
-#line 1363
+#line 1392
}
-#line 1363
+#line 1392
}
-#line 1363
+#line 1392
-#line 1363
+#line 1392
isp->sign = vsp->sign;
-#line 1363
+#line 1392
}
@@ -4229,7 +5121,7 @@ static const int cs_ieis_bias = 0x4000 - 0x7f;
static const int cs_id_bias = 0x4000 - 0x3ff;
-#line 1498
+#line 1527
static void
get_ix_float(const void *xp, float *ip)
@@ -4239,86 +5131,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 1506
+#line 1535
-#line 1506
+#line 1535
if (isp->exp == 0)
-#line 1506
+#line 1535
{
-#line 1506
+#line 1535
/* ieee subnormal */
-#line 1506
+#line 1535
*ip = (double)isp->mant;
-#line 1506
+#line 1535
if (isp->mant != 0)
-#line 1506
+#line 1535
{
-#line 1506
+#line 1535
csp->exp -= (ieee_single_bias + 22);
-#line 1506
+#line 1535
}
-#line 1506
+#line 1535
}
-#line 1506
+#line 1535
else
-#line 1506
+#line 1535
{
-#line 1506
+#line 1535
csp->exp = isp->exp + cs_ieis_bias + 1;
-#line 1506
+#line 1535
csp->mant = isp->mant << (48 - 1 - 23);
-#line 1506
+#line 1535
csp->mant |= (1 << (48 - 1));
-#line 1506
+#line 1535
}
-#line 1506
+#line 1535
csp->sign = isp->sign;
-#line 1506
+#line 1535
-#line 1506
+#line 1535
}
else
{
const ieee_single_lo *isp = (const ieee_single_lo *) xp;
cray_single *csp = (cray_single *) ip;
-#line 1511
+#line 1540
-#line 1511
+#line 1540
if (isp->exp == 0)
-#line 1511
+#line 1540
{
-#line 1511
+#line 1540
/* ieee subnormal */
-#line 1511
+#line 1540
*ip = (double)isp->mant;
-#line 1511
+#line 1540
if (isp->mant != 0)
-#line 1511
+#line 1540
{
-#line 1511
+#line 1540
csp->exp -= (ieee_single_bias + 22);
-#line 1511
+#line 1540
}
-#line 1511
+#line 1540
}
-#line 1511
+#line 1540
else
-#line 1511
+#line 1540
{
-#line 1511
+#line 1540
csp->exp = isp->exp + cs_ieis_bias + 1;
-#line 1511
+#line 1540
csp->mant = isp->mant << (48 - 1 - 23);
-#line 1511
+#line 1540
csp->mant |= (1 << (48 - 1));
-#line 1511
+#line 1540
}
-#line 1511
+#line 1540
csp->sign = isp->sign;
-#line 1511
+#line 1540
-#line 1511
+#line 1540
}
}
@@ -4330,182 +5222,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 1521
+#line 1550
int ieee_exp = csp->exp - cs_ieis_bias -1;
-#line 1521
+#line 1550
-#line 1521
+#line 1550
isp->sign = csp->sign;
-#line 1521
+#line 1550
-#line 1521
+#line 1550
if (ieee_exp >= 0xff)
-#line 1521
+#line 1550
{
-#line 1521
+#line 1550
/* NC_ERANGE => ieee Inf */
-#line 1521
+#line 1550
isp->exp = 0xff;
-#line 1521
+#line 1550
isp->mant = 0x0;
-#line 1521
+#line 1550
}
-#line 1521
+#line 1550
else if (ieee_exp > 0)
-#line 1521
+#line 1550
{
-#line 1521
+#line 1550
/* normal ieee representation */
-#line 1521
+#line 1550
isp->exp = ieee_exp;
-#line 1521
+#line 1550
/* assumes cray rep is in normal form */
-#line 1521
+#line 1550
assert(csp->mant & 0x800000000000);
-#line 1521
+#line 1550
isp->mant = (((csp->mant << 1) &
-#line 1521
+#line 1550
0xffffffffffff) >> (48 - 23));
-#line 1521
+#line 1550
}
-#line 1521
+#line 1550
else if (ieee_exp > -23)
-#line 1521
+#line 1550
{
-#line 1521
+#line 1550
/* ieee subnormal, right shift */
-#line 1521
+#line 1550
const int rshift = (48 - 23 - ieee_exp);
-#line 1521
+#line 1550
-#line 1521
+#line 1550
isp->mant = csp->mant >> rshift;
-#line 1521
+#line 1550
-#line 1521
+#line 1550
#if 0
-#line 1521
+#line 1550
if (csp->mant & (1 << (rshift -1)))
-#line 1521
+#line 1550
{
-#line 1521
+#line 1550
/* round up */
-#line 1521
+#line 1550
isp->mant++;
-#line 1521
+#line 1550
}
-#line 1521
+#line 1550
#endif
-#line 1521
+#line 1550
-#line 1521
+#line 1550
isp->exp = 0;
-#line 1521
+#line 1550
}
-#line 1521
+#line 1550
else
-#line 1521
+#line 1550
{
-#line 1521
+#line 1550
/* smaller than ieee can represent */
-#line 1521
+#line 1550
isp->exp = 0;
-#line 1521
+#line 1550
isp->mant = 0;
-#line 1521
+#line 1550
}
-#line 1521
+#line 1550
}
else
{
ieee_single_lo *isp = (ieee_single_lo*)xp;
const cray_single *csp = (const cray_single *) ip;
-#line 1526
+#line 1555
int ieee_exp = csp->exp - cs_ieis_bias -1;
-#line 1526
+#line 1555
-#line 1526
+#line 1555
isp->sign = csp->sign;
-#line 1526
+#line 1555
-#line 1526
+#line 1555
if (ieee_exp >= 0xff)
-#line 1526
+#line 1555
{
-#line 1526
+#line 1555
/* NC_ERANGE => ieee Inf */
-#line 1526
+#line 1555
isp->exp = 0xff;
-#line 1526
+#line 1555
isp->mant = 0x0;
-#line 1526
+#line 1555
}
-#line 1526
+#line 1555
else if (ieee_exp > 0)
-#line 1526
+#line 1555
{
-#line 1526
+#line 1555
/* normal ieee representation */
-#line 1526
+#line 1555
isp->exp = ieee_exp;
-#line 1526
+#line 1555
/* assumes cray rep is in normal form */
-#line 1526
+#line 1555
assert(csp->mant & 0x800000000000);
-#line 1526
+#line 1555
isp->mant = (((csp->mant << 1) &
-#line 1526
+#line 1555
0xffffffffffff) >> (48 - 23));
-#line 1526
+#line 1555
}
-#line 1526
+#line 1555
else if (ieee_exp > -23)
-#line 1526
+#line 1555
{
-#line 1526
+#line 1555
/* ieee subnormal, right shift */
-#line 1526
+#line 1555
const int rshift = (48 - 23 - ieee_exp);
-#line 1526
+#line 1555
-#line 1526
+#line 1555
isp->mant = csp->mant >> rshift;
-#line 1526
+#line 1555
-#line 1526
+#line 1555
#if 0
-#line 1526
+#line 1555
if (csp->mant & (1 << (rshift -1)))
-#line 1526
+#line 1555
{
-#line 1526
+#line 1555
/* round up */
-#line 1526
+#line 1555
isp->mant++;
-#line 1526
+#line 1555
}
-#line 1526
+#line 1555
#endif
-#line 1526
+#line 1555
-#line 1526
+#line 1555
isp->exp = 0;
-#line 1526
+#line 1555
}
-#line 1526
+#line 1555
else
-#line 1526
+#line 1555
{
-#line 1526
+#line 1555
/* smaller than ieee can represent */
-#line 1526
+#line 1555
isp->exp = 0;
-#line 1526
+#line 1555
isp->mant = 0;
-#line 1526
+#line 1555
}
-#line 1526
+#line 1555
}
}
@@ -4594,252 +5486,288 @@ ncx_get_float_float(const void *xp, float *ip, void *fillp)
#define ix_float float
static int
-#line 1613
+#line 1642
ncx_get_float_schar(const void *xp, schar *ip)
-#line 1613
+#line 1642
{
-#line 1613
+#line 1642
ix_float xx;
-#line 1613
+#line 1642
get_ix_float(xp, &xx);
-#line 1613
+#line 1642
if (xx > (double)SCHAR_MAX || xx < (double)SCHAR_MIN) {
-#line 1613
-
-#line 1613
+#line 1642
+#ifdef ERANGE_FILL
+#line 1642
+ *ip = NC_FILL_BYTE;
+#line 1642
+#endif
+#line 1642
return NC_ERANGE;
-#line 1613
+#line 1642
}
-#line 1613
+#line 1642
*ip = (schar)xx;
-#line 1613
+#line 1642
return NC_NOERR;
-#line 1613
+#line 1642
}
-#line 1613
+#line 1642
static int
-#line 1614
+#line 1643
ncx_get_float_short(const void *xp, short *ip)
-#line 1614
+#line 1643
{
-#line 1614
+#line 1643
ix_float xx;
-#line 1614
+#line 1643
get_ix_float(xp, &xx);
-#line 1614
+#line 1643
if (xx > (double)SHORT_MAX || xx < (double)SHORT_MIN) {
-#line 1614
-
-#line 1614
+#line 1643
+#ifdef ERANGE_FILL
+#line 1643
+ *ip = NC_FILL_SHORT;
+#line 1643
+#endif
+#line 1643
return NC_ERANGE;
-#line 1614
+#line 1643
}
-#line 1614
+#line 1643
*ip = (short)xx;
-#line 1614
+#line 1643
return NC_NOERR;
-#line 1614
+#line 1643
}
-#line 1614
+#line 1643
static int
-#line 1615
+#line 1644
ncx_get_float_int(const void *xp, int *ip)
-#line 1615
+#line 1644
{
-#line 1615
+#line 1644
ix_float xx;
-#line 1615
+#line 1644
get_ix_float(xp, &xx);
-#line 1615
+#line 1644
if (xx > (double)INT_MAX || xx < (double)INT_MIN) {
-#line 1615
-
-#line 1615
+#line 1644
+#ifdef ERANGE_FILL
+#line 1644
+ *ip = NC_FILL_INT;
+#line 1644
+#endif
+#line 1644
return NC_ERANGE;
-#line 1615
+#line 1644
}
-#line 1615
+#line 1644
*ip = (int)xx;
-#line 1615
+#line 1644
return NC_NOERR;
-#line 1615
+#line 1644
}
-#line 1615
+#line 1644
static int
-#line 1616
+#line 1645
ncx_get_float_long(const void *xp, long *ip)
-#line 1616
+#line 1645
{
-#line 1616
+#line 1645
ix_float xx;
-#line 1616
+#line 1645
get_ix_float(xp, &xx);
-#line 1616
+#line 1645
if (xx > (double)LONG_MAX || xx < (double)LONG_MIN) {
-#line 1616
-
-#line 1616
+#line 1645
+#ifdef ERANGE_FILL
+#line 1645
+ *ip = NC_FILL_INT;
+#line 1645
+#endif
+#line 1645
return NC_ERANGE;
-#line 1616
+#line 1645
}
-#line 1616
+#line 1645
*ip = (long)xx;
-#line 1616
+#line 1645
return NC_NOERR;
-#line 1616
+#line 1645
}
-#line 1616
+#line 1645
static int
-#line 1617
+#line 1646
ncx_get_float_double(const void *xp, double *ip)
-#line 1617
+#line 1646
{
-#line 1617
+#line 1646
ix_float xx;
-#line 1617
+#line 1646
get_ix_float(xp, &xx);
-#line 1617
+#line 1646
*ip = (double)xx;
-#line 1617
+#line 1646
return NC_NOERR;
-#line 1617
+#line 1646
}
-#line 1617
+#line 1646
static int
-#line 1618
+#line 1647
ncx_get_float_longlong(const void *xp, longlong *ip)
-#line 1618
+#line 1647
{
-#line 1618
+#line 1647
ix_float xx;
-#line 1618
+#line 1647
get_ix_float(xp, &xx);
-#line 1618
+#line 1647
if (xx == LONGLONG_MAX) *ip = LONGLONG_MAX;
-#line 1618
+#line 1647
else if (xx == LONGLONG_MIN) *ip = LONGLONG_MIN;
-#line 1618
+#line 1647
else if (xx > (double)LONGLONG_MAX || xx < (double)LONGLONG_MIN) {
-#line 1618
-
-#line 1618
+#line 1647
+#ifdef ERANGE_FILL
+#line 1647
+ *ip = NC_FILL_INT64;
+#line 1647
+#endif
+#line 1647
return NC_ERANGE;
-#line 1618
+#line 1647
}
-#line 1618
+#line 1647
else *ip = (longlong)xx;
-#line 1618
+#line 1647
return NC_NOERR;
-#line 1618
+#line 1647
}
-#line 1618
+#line 1647
static int
-#line 1619
+#line 1648
ncx_get_float_uchar(const void *xp, uchar *ip)
-#line 1619
+#line 1648
{
-#line 1619
+#line 1648
ix_float xx;
-#line 1619
+#line 1648
get_ix_float(xp, &xx);
-#line 1619
+#line 1648
if (xx > (double)UCHAR_MAX || xx < 0) {
-#line 1619
-
-#line 1619
+#line 1648
+#ifdef ERANGE_FILL
+#line 1648
+ *ip = NC_FILL_UBYTE;
+#line 1648
+#endif
+#line 1648
return NC_ERANGE;
-#line 1619
+#line 1648
}
-#line 1619
+#line 1648
*ip = (uchar)xx;
-#line 1619
+#line 1648
return NC_NOERR;
-#line 1619
+#line 1648
}
-#line 1619
+#line 1648
static int
-#line 1620
+#line 1649
ncx_get_float_ushort(const void *xp, ushort *ip)
-#line 1620
+#line 1649
{
-#line 1620
+#line 1649
ix_float xx;
-#line 1620
+#line 1649
get_ix_float(xp, &xx);
-#line 1620
+#line 1649
if (xx > (double)USHORT_MAX || xx < 0) {
-#line 1620
-
-#line 1620
+#line 1649
+#ifdef ERANGE_FILL
+#line 1649
+ *ip = NC_FILL_USHORT;
+#line 1649
+#endif
+#line 1649
return NC_ERANGE;
-#line 1620
+#line 1649
}
-#line 1620
+#line 1649
*ip = (ushort)xx;
-#line 1620
+#line 1649
return NC_NOERR;
-#line 1620
+#line 1649
}
-#line 1620
+#line 1649
static int
-#line 1621
+#line 1650
ncx_get_float_uint(const void *xp, uint *ip)
-#line 1621
+#line 1650
{
-#line 1621
+#line 1650
ix_float xx;
-#line 1621
+#line 1650
get_ix_float(xp, &xx);
-#line 1621
+#line 1650
if (xx > (double)UINT_MAX || xx < 0) {
-#line 1621
-
-#line 1621
+#line 1650
+#ifdef ERANGE_FILL
+#line 1650
+ *ip = NC_FILL_UINT;
+#line 1650
+#endif
+#line 1650
return NC_ERANGE;
-#line 1621
+#line 1650
}
-#line 1621
+#line 1650
*ip = (uint)xx;
-#line 1621
+#line 1650
return NC_NOERR;
-#line 1621
+#line 1650
}
-#line 1621
+#line 1650
static int
-#line 1622
+#line 1651
ncx_get_float_ulonglong(const void *xp, ulonglong *ip)
-#line 1622
+#line 1651
{
-#line 1622
+#line 1651
ix_float xx;
-#line 1622
+#line 1651
get_ix_float(xp, &xx);
-#line 1622
+#line 1651
if (xx == ULONGLONG_MAX) *ip = ULONGLONG_MAX;
-#line 1622
+#line 1651
else if (xx > (double)ULONGLONG_MAX || xx < 0) {
-#line 1622
-
-#line 1622
+#line 1651
+#ifdef ERANGE_FILL
+#line 1651
+ *ip = NC_FILL_UINT64;
+#line 1651
+#endif
+#line 1651
return NC_ERANGE;
-#line 1622
+#line 1651
}
-#line 1622
+#line 1651
else *ip = (ulonglong)xx;
-#line 1622
+#line 1651
return NC_NOERR;
-#line 1622
+#line 1651
}
-#line 1622
+#line 1651
#if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
@@ -4849,10 +5777,20 @@ ncx_put_float_float(void *xp, const float *ip, void *fillp)
int err=NC_NOERR;
float *_ip=ip;
#ifdef NO_IEEE_FLOAT
-
+#ifdef ERANGE_FILL
+ float tmp;
+#endif
if (*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN) {
-
+#line 1664
+#ifdef ERANGE_FILL
+#line 1664
+ if (fillp != NULL) memcpy(&tmp, fillp, 4);
+#line 1664
+#endif
+#ifdef ERANGE_FILL
+ _ip = &tmp;
+#endif
err = NC_ERANGE;
}
#endif
@@ -4862,260 +5800,272 @@ ncx_put_float_float(void *xp, const float *ip, void *fillp)
#endif
static int
-#line 1643
+#line 1676
ncx_put_float_schar(void *xp, const schar *ip, void *fillp)
-#line 1643
+#line 1676
{
-#line 1643
+#line 1676
int err=NC_NOERR;
-#line 1643
+#line 1676
ix_float xx = NC_FILL_FLOAT;
-#line 1643
+#line 1676
-#line 1643
+#line 1676
-#line 1643
+#line 1676
xx = (ix_float)*ip;
-#line 1643
+#line 1676
-#line 1643
+#line 1676
put_ix_float(xp, &xx);
-#line 1643
+#line 1676
return err;
-#line 1643
+#line 1676
}
-#line 1643
+#line 1676
static int
-#line 1644
+#line 1677
ncx_put_float_short(void *xp, const short *ip, void *fillp)
-#line 1644
+#line 1677
{
-#line 1644
+#line 1677
int err=NC_NOERR;
-#line 1644
+#line 1677
ix_float xx = NC_FILL_FLOAT;
-#line 1644
+#line 1677
-#line 1644
+#line 1677
-#line 1644
+#line 1677
xx = (ix_float)*ip;
-#line 1644
+#line 1677
-#line 1644
+#line 1677
put_ix_float(xp, &xx);
-#line 1644
+#line 1677
return err;
-#line 1644
+#line 1677
}
-#line 1644
+#line 1677
static int
-#line 1645
+#line 1678
ncx_put_float_int(void *xp, const int *ip, void *fillp)
-#line 1645
+#line 1678
{
-#line 1645
+#line 1678
int err=NC_NOERR;
-#line 1645
+#line 1678
ix_float xx = NC_FILL_FLOAT;
-#line 1645
+#line 1678
-#line 1645
+#line 1678
-#line 1645
+#line 1678
xx = (ix_float)*ip;
-#line 1645
+#line 1678
-#line 1645
+#line 1678
put_ix_float(xp, &xx);
-#line 1645
+#line 1678
return err;
-#line 1645
+#line 1678
}
-#line 1645
+#line 1678
static int
-#line 1646
+#line 1679
ncx_put_float_long(void *xp, const long *ip, void *fillp)
-#line 1646
+#line 1679
{
-#line 1646
+#line 1679
int err=NC_NOERR;
-#line 1646
+#line 1679
ix_float xx = NC_FILL_FLOAT;
-#line 1646
+#line 1679
-#line 1646
+#line 1679
-#line 1646
+#line 1679
xx = (ix_float)*ip;
-#line 1646
+#line 1679
-#line 1646
+#line 1679
put_ix_float(xp, &xx);
-#line 1646
+#line 1679
return err;
-#line 1646
+#line 1679
}
-#line 1646
+#line 1679
static int
-#line 1647
+#line 1680
ncx_put_float_double(void *xp, const double *ip, void *fillp)
-#line 1647
+#line 1680
{
-#line 1647
+#line 1680
int err=NC_NOERR;
-#line 1647
+#line 1680
ix_float xx = NC_FILL_FLOAT;
-#line 1647
+#line 1680
-#line 1647
+#line 1680
if (*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN) {
-#line 1647
+#line 1680
-#line 1647
+#line 1680
+#ifdef ERANGE_FILL
+#line 1680
+ if (fillp != NULL) memcpy(&xx, fillp, 4);
+#line 1680
+#endif
+#line 1680
err = NC_ERANGE;
-#line 1647
- }
-#line 1647
+#line 1680
+ }
+#line 1680
+#ifdef ERANGE_FILL
+#line 1680
+ else
+#line 1680
+#endif
+#line 1680
xx = (ix_float)*ip;
-#line 1647
+#line 1680
-#line 1647
+#line 1680
put_ix_float(xp, &xx);
-#line 1647
+#line 1680
return err;
-#line 1647
+#line 1680
}
-#line 1647
+#line 1680
static int
-#line 1648
+#line 1681
ncx_put_float_longlong(void *xp, const longlong *ip, void *fillp)
-#line 1648
+#line 1681
{
-#line 1648
+#line 1681
int err=NC_NOERR;
-#line 1648
+#line 1681
ix_float xx = NC_FILL_FLOAT;
-#line 1648
+#line 1681
-#line 1648
+#line 1681
-#line 1648
+#line 1681
xx = (ix_float)*ip;
-#line 1648
+#line 1681
-#line 1648
+#line 1681
put_ix_float(xp, &xx);
-#line 1648
+#line 1681
return err;
-#line 1648
+#line 1681
}
-#line 1648
+#line 1681
static int
-#line 1649
+#line 1682
ncx_put_float_uchar(void *xp, const uchar *ip, void *fillp)
-#line 1649
+#line 1682
{
-#line 1649
+#line 1682
int err=NC_NOERR;
-#line 1649
+#line 1682
ix_float xx = NC_FILL_FLOAT;
-#line 1649
+#line 1682
-#line 1649
+#line 1682
-#line 1649
+#line 1682
xx = (ix_float)*ip;
-#line 1649
+#line 1682
-#line 1649
+#line 1682
put_ix_float(xp, &xx);
-#line 1649
+#line 1682
return err;
-#line 1649
+#line 1682
}
-#line 1649
+#line 1682
static int
-#line 1650
+#line 1683
ncx_put_float_ushort(void *xp, const ushort *ip, void *fillp)
-#line 1650
+#line 1683
{
-#line 1650
+#line 1683
int err=NC_NOERR;
-#line 1650
+#line 1683
ix_float xx = NC_FILL_FLOAT;
-#line 1650
+#line 1683
-#line 1650
+#line 1683
-#line 1650
+#line 1683
xx = (ix_float)*ip;
-#line 1650
+#line 1683
-#line 1650
+#line 1683
put_ix_float(xp, &xx);
-#line 1650
+#line 1683
return err;
-#line 1650
+#line 1683
}
-#line 1650
+#line 1683
static int
-#line 1651
+#line 1684
ncx_put_float_uint(void *xp, const uint *ip, void *fillp)
-#line 1651
+#line 1684
{
-#line 1651
+#line 1684
int err=NC_NOERR;
-#line 1651
+#line 1684
ix_float xx = NC_FILL_FLOAT;
-#line 1651
+#line 1684
-#line 1651
+#line 1684
-#line 1651
+#line 1684
xx = (ix_float)*ip;
-#line 1651
+#line 1684
-#line 1651
+#line 1684
put_ix_float(xp, &xx);
-#line 1651
+#line 1684
return err;
-#line 1651
+#line 1684
}
-#line 1651
+#line 1684
static int
-#line 1652
+#line 1685
ncx_put_float_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 1652
+#line 1685
{
-#line 1652
+#line 1685
int err=NC_NOERR;
-#line 1652
+#line 1685
ix_float xx = NC_FILL_FLOAT;
-#line 1652
+#line 1685
-#line 1652
+#line 1685
-#line 1652
+#line 1685
xx = (ix_float)*ip;
-#line 1652
+#line 1685
-#line 1652
+#line 1685
put_ix_float(xp, &xx);
-#line 1652
+#line 1685
return err;
-#line 1652
+#line 1685
}
-#line 1652
+#line 1685
@@ -5182,218 +6132,218 @@ static const struct dbl_limits {
};
-#line 1766
+#line 1799
static void
get_ix_double(const void *xp, double *ip)
{
struct vax_double *const vdp =
-#line 1769
+#line 1802
(struct vax_double *)ip;
-#line 1769
+#line 1802
const struct ieee_double *const idp =
-#line 1769
+#line 1802
(const struct ieee_double *) xp;
-#line 1769
+#line 1802
{
-#line 1769
+#line 1802
const struct dbl_limits *lim;
-#line 1769
+#line 1802
int ii;
-#line 1769
+#line 1802
for (ii = 0, lim = dbl_limits;
-#line 1769
+#line 1802
ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
-#line 1769
+#line 1802
ii++, lim++)
-#line 1769
+#line 1802
{
-#line 1769
+#line 1802
if ((idp->mant_lo == lim->ieee.mant_lo)
-#line 1769
+#line 1802
&& (idp->mant_4 == lim->ieee.mant_4)
-#line 1769
+#line 1802
&& (idp->mant_5 == lim->ieee.mant_5)
-#line 1769
+#line 1802
&& (idp->mant_6 == lim->ieee.mant_6)
-#line 1769
+#line 1802
&& (idp->exp_lo == lim->ieee.exp_lo)
-#line 1769
+#line 1802
&& (idp->exp_hi == lim->ieee.exp_hi)
-#line 1769
+#line 1802
)
-#line 1769
+#line 1802
{
-#line 1769
+#line 1802
*vdp = lim->d;
-#line 1769
+#line 1802
goto doneit;
-#line 1769
+#line 1802
}
-#line 1769
+#line 1802
}
-#line 1769
+#line 1802
}
-#line 1769
+#line 1802
{
-#line 1769
+#line 1802
unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
-#line 1769
+#line 1802
vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
-#line 1769
+#line 1802
}
-#line 1769
+#line 1802
{
-#line 1769
+#line 1802
unsigned mant_hi = ((idp->mant_6 << 16)
-#line 1769
+#line 1802
| (idp->mant_5 << 8)
-#line 1769
+#line 1802
| idp->mant_4);
-#line 1769
+#line 1802
unsigned mant_lo = SWAP4(idp->mant_lo);
-#line 1769
+#line 1802
vdp->mantissa1 = (mant_hi >> 13);
-#line 1769
+#line 1802
vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
-#line 1769
+#line 1802
| (mant_lo >> 29);
-#line 1769
+#line 1802
vdp->mantissa3 = (mant_lo >> 13);
-#line 1769
+#line 1802
vdp->mantissa4 = (mant_lo << 3);
-#line 1769
+#line 1802
}
-#line 1769
+#line 1802
doneit:
-#line 1769
+#line 1802
vdp->sign = idp->sign;
-#line 1769
+#line 1802
}
-#line 1839
+#line 1872
static void
put_ix_double(void *xp, const double *ip)
{
const struct vax_double *const vdp =
-#line 1842
+#line 1875
(const struct vax_double *)ip;
-#line 1842
+#line 1875
struct ieee_double *const idp =
-#line 1842
+#line 1875
(struct ieee_double *) xp;
-#line 1842
+#line 1875
-#line 1842
+#line 1875
if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
-#line 1842
+#line 1875
(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
-#line 1842
+#line 1875
(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
-#line 1842
+#line 1875
(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
-#line 1842
+#line 1875
(vdp->exp == dbl_limits[0].d.exp))
-#line 1842
+#line 1875
{
-#line 1842
+#line 1875
*idp = dbl_limits[0].ieee;
-#line 1842
+#line 1875
goto shipit;
-#line 1842
+#line 1875
}
-#line 1842
+#line 1875
if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
-#line 1842
+#line 1875
(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
-#line 1842
+#line 1875
(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
-#line 1842
+#line 1875
(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
-#line 1842
+#line 1875
(vdp->exp == dbl_limits[1].d.exp))
-#line 1842
+#line 1875
{
-#line 1842
+#line 1875
*idp = dbl_limits[1].ieee;
-#line 1842
+#line 1875
goto shipit;
-#line 1842
+#line 1875
}
-#line 1842
+#line 1875
-#line 1842
+#line 1875
{
-#line 1842
+#line 1875
unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
-#line 1842
+#line 1875
-#line 1842
+#line 1875
unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
-#line 1842
+#line 1875
(vdp->mantissa3 << 13) |
-#line 1842
+#line 1875
((vdp->mantissa4 >> 3) & MASK(13));
-#line 1842
+#line 1875
-#line 1842
+#line 1875
unsigned mant_hi = (vdp->mantissa1 << 13)
-#line 1842
+#line 1875
| (vdp->mantissa2 >> 3);
-#line 1842
+#line 1875
-#line 1842
+#line 1875
if ((vdp->mantissa4 & 7) > 4)
-#line 1842
+#line 1875
{
-#line 1842
+#line 1875
/* round up */
-#line 1842
+#line 1875
mant_lo++;
-#line 1842
+#line 1875
if (mant_lo == 0)
-#line 1842
+#line 1875
{
-#line 1842
+#line 1875
mant_hi++;
-#line 1842
+#line 1875
if (mant_hi > 0xffffff)
-#line 1842
+#line 1875
{
-#line 1842
+#line 1875
mant_hi = 0;
-#line 1842
+#line 1875
exp++;
-#line 1842
+#line 1875
}
-#line 1842
+#line 1875
}
-#line 1842
+#line 1875
}
-#line 1842
+#line 1875
-#line 1842
+#line 1875
idp->mant_lo = SWAP4(mant_lo);
-#line 1842
+#line 1875
idp->mant_6 = mant_hi >> 16;
-#line 1842
+#line 1875
idp->mant_5 = (mant_hi & 0xff00) >> 8;
-#line 1842
+#line 1875
idp->mant_4 = mant_hi;
-#line 1842
+#line 1875
idp->exp_hi = exp >> 4;
-#line 1842
+#line 1875
idp->exp_lo = exp;
-#line 1842
+#line 1875
}
-#line 1842
+#line 1875
-#line 1842
+#line 1875
shipit:
-#line 1842
+#line 1875
idp->sign = vdp->sign;
-#line 1842
+#line 1875
}
@@ -5487,235 +6437,271 @@ put_ix_double(void *xp, const double *ip)
#define ix_double double
static int
-#line 1934
+#line 1967
ncx_get_double_schar(const void *xp, schar *ip)
-#line 1934
+#line 1967
{
-#line 1934
+#line 1967
ix_double xx;
-#line 1934
+#line 1967
get_ix_double(xp, &xx);
-#line 1934
+#line 1967
if (xx > (double)SCHAR_MAX || xx < (double)SCHAR_MIN) {
-#line 1934
-
-#line 1934
+#line 1967
+#ifdef ERANGE_FILL
+#line 1967
+ *ip = NC_FILL_BYTE;
+#line 1967
+#endif
+#line 1967
return NC_ERANGE;
-#line 1934
+#line 1967
}
-#line 1934
+#line 1967
*ip = (schar)xx;
-#line 1934
+#line 1967
return NC_NOERR;
-#line 1934
+#line 1967
}
-#line 1934
+#line 1967
static int
-#line 1935
+#line 1968
ncx_get_double_short(const void *xp, short *ip)
-#line 1935
+#line 1968
{
-#line 1935
+#line 1968
ix_double xx;
-#line 1935
+#line 1968
get_ix_double(xp, &xx);
-#line 1935
+#line 1968
if (xx > (double)SHORT_MAX || xx < (double)SHORT_MIN) {
-#line 1935
-
-#line 1935
+#line 1968
+#ifdef ERANGE_FILL
+#line 1968
+ *ip = NC_FILL_SHORT;
+#line 1968
+#endif
+#line 1968
return NC_ERANGE;
-#line 1935
+#line 1968
}
-#line 1935
+#line 1968
*ip = (short)xx;
-#line 1935
+#line 1968
return NC_NOERR;
-#line 1935
+#line 1968
}
-#line 1935
+#line 1968
static int
-#line 1936
+#line 1969
ncx_get_double_int(const void *xp, int *ip)
-#line 1936
+#line 1969
{
-#line 1936
+#line 1969
ix_double xx;
-#line 1936
+#line 1969
get_ix_double(xp, &xx);
-#line 1936
+#line 1969
if (xx > (double)INT_MAX || xx < (double)INT_MIN) {
-#line 1936
-
-#line 1936
+#line 1969
+#ifdef ERANGE_FILL
+#line 1969
+ *ip = NC_FILL_INT;
+#line 1969
+#endif
+#line 1969
return NC_ERANGE;
-#line 1936
+#line 1969
}
-#line 1936
+#line 1969
*ip = (int)xx;
-#line 1936
+#line 1969
return NC_NOERR;
-#line 1936
+#line 1969
}
-#line 1936
+#line 1969
static int
-#line 1937
+#line 1970
ncx_get_double_long(const void *xp, long *ip)
-#line 1937
+#line 1970
{
-#line 1937
+#line 1970
ix_double xx;
-#line 1937
+#line 1970
get_ix_double(xp, &xx);
-#line 1937
+#line 1970
if (xx > (double)LONG_MAX || xx < (double)LONG_MIN) {
-#line 1937
-
-#line 1937
+#line 1970
+#ifdef ERANGE_FILL
+#line 1970
+ *ip = NC_FILL_INT;
+#line 1970
+#endif
+#line 1970
return NC_ERANGE;
-#line 1937
+#line 1970
}
-#line 1937
+#line 1970
*ip = (long)xx;
-#line 1937
+#line 1970
return NC_NOERR;
-#line 1937
+#line 1970
}
-#line 1937
+#line 1970
static int
-#line 1938
+#line 1971
ncx_get_double_longlong(const void *xp, longlong *ip)
-#line 1938
+#line 1971
{
-#line 1938
+#line 1971
ix_double xx;
-#line 1938
+#line 1971
get_ix_double(xp, &xx);
-#line 1938
+#line 1971
if (xx == LONGLONG_MAX) *ip = LONGLONG_MAX;
-#line 1938
+#line 1971
else if (xx == LONGLONG_MIN) *ip = LONGLONG_MIN;
-#line 1938
+#line 1971
else if (xx > (double)LONGLONG_MAX || xx < (double)LONGLONG_MIN) {
-#line 1938
-
-#line 1938
+#line 1971
+#ifdef ERANGE_FILL
+#line 1971
+ *ip = NC_FILL_INT64;
+#line 1971
+#endif
+#line 1971
return NC_ERANGE;
-#line 1938
+#line 1971
}
-#line 1938
+#line 1971
else *ip = (longlong)xx;
-#line 1938
+#line 1971
return NC_NOERR;
-#line 1938
+#line 1971
}
-#line 1938
+#line 1971
static int
-#line 1939
+#line 1972
ncx_get_double_uchar(const void *xp, uchar *ip)
-#line 1939
+#line 1972
{
-#line 1939
+#line 1972
ix_double xx;
-#line 1939
+#line 1972
get_ix_double(xp, &xx);
-#line 1939
+#line 1972
if (xx > (double)UCHAR_MAX || xx < 0) {
-#line 1939
-
-#line 1939
+#line 1972
+#ifdef ERANGE_FILL
+#line 1972
+ *ip = NC_FILL_UBYTE;
+#line 1972
+#endif
+#line 1972
return NC_ERANGE;
-#line 1939
+#line 1972
}
-#line 1939
+#line 1972
*ip = (uchar)xx;
-#line 1939
+#line 1972
return NC_NOERR;
-#line 1939
+#line 1972
}
-#line 1939
+#line 1972
static int
-#line 1940
+#line 1973
ncx_get_double_ushort(const void *xp, ushort *ip)
-#line 1940
+#line 1973
{
-#line 1940
+#line 1973
ix_double xx;
-#line 1940
+#line 1973
get_ix_double(xp, &xx);
-#line 1940
+#line 1973
if (xx > (double)USHORT_MAX || xx < 0) {
-#line 1940
-
-#line 1940
+#line 1973
+#ifdef ERANGE_FILL
+#line 1973
+ *ip = NC_FILL_USHORT;
+#line 1973
+#endif
+#line 1973
return NC_ERANGE;
-#line 1940
+#line 1973
}
-#line 1940
+#line 1973
*ip = (ushort)xx;
-#line 1940
+#line 1973
return NC_NOERR;
-#line 1940
+#line 1973
}
-#line 1940
+#line 1973
static int
-#line 1941
+#line 1974
ncx_get_double_uint(const void *xp, uint *ip)
-#line 1941
+#line 1974
{
-#line 1941
+#line 1974
ix_double xx;
-#line 1941
+#line 1974
get_ix_double(xp, &xx);
-#line 1941
+#line 1974
if (xx > (double)UINT_MAX || xx < 0) {
-#line 1941
-
-#line 1941
+#line 1974
+#ifdef ERANGE_FILL
+#line 1974
+ *ip = NC_FILL_UINT;
+#line 1974
+#endif
+#line 1974
return NC_ERANGE;
-#line 1941
+#line 1974
}
-#line 1941
+#line 1974
*ip = (uint)xx;
-#line 1941
+#line 1974
return NC_NOERR;
-#line 1941
+#line 1974
}
-#line 1941
+#line 1974
static int
-#line 1942
+#line 1975
ncx_get_double_ulonglong(const void *xp, ulonglong *ip)
-#line 1942
+#line 1975
{
-#line 1942
+#line 1975
ix_double xx;
-#line 1942
+#line 1975
get_ix_double(xp, &xx);
-#line 1942
+#line 1975
if (xx == ULONGLONG_MAX) *ip = ULONGLONG_MAX;
-#line 1942
+#line 1975
else if (xx > (double)ULONGLONG_MAX || xx < 0) {
-#line 1942
-
-#line 1942
+#line 1975
+#ifdef ERANGE_FILL
+#line 1975
+ *ip = NC_FILL_UINT64;
+#line 1975
+#endif
+#line 1975
return NC_ERANGE;
-#line 1942
+#line 1975
}
-#line 1942
+#line 1975
else *ip = (ulonglong)xx;
-#line 1942
+#line 1975
return NC_NOERR;
-#line 1942
+#line 1975
}
-#line 1942
+#line 1975
static int
@@ -5724,11 +6710,19 @@ ncx_get_double_float(const void *xp, float *ip)
double xx;
get_ix_double(xp, &xx);
if (xx > FLT_MAX) {
+#ifdef ERANGE_FILL
+ *ip = NC_FILL_FLOAT;
+#else
*ip = FLT_MAX;
+#endif
return NC_ERANGE;
}
if (xx < (-FLT_MAX)) {
+#ifdef ERANGE_FILL
+ *ip = NC_FILL_FLOAT;
+#else
*ip = (-FLT_MAX);
+#endif
return NC_ERANGE;
}
*ip = (float) xx;
@@ -5746,229 +6740,229 @@ ncx_get_double_double(const void *xp, double *ip, void *fillp)
#endif
static int
-#line 1971
+#line 2012
ncx_put_double_schar(void *xp, const schar *ip, void *fillp)
-#line 1971
+#line 2012
{
-#line 1971
+#line 2012
int err=NC_NOERR;
-#line 1971
+#line 2012
ix_double xx = NC_FILL_DOUBLE;
-#line 1971
+#line 2012
-#line 1971
+#line 2012
-#line 1971
+#line 2012
xx = (ix_double)*ip;
-#line 1971
+#line 2012
-#line 1971
+#line 2012
put_ix_double(xp, &xx);
-#line 1971
+#line 2012
return err;
-#line 1971
+#line 2012
}
-#line 1971
+#line 2012
static int
-#line 1972
+#line 2013
ncx_put_double_uchar(void *xp, const uchar *ip, void *fillp)
-#line 1972
+#line 2013
{
-#line 1972
+#line 2013
int err=NC_NOERR;
-#line 1972
+#line 2013
ix_double xx = NC_FILL_DOUBLE;
-#line 1972
+#line 2013
-#line 1972
+#line 2013
-#line 1972
+#line 2013
xx = (ix_double)*ip;
-#line 1972
+#line 2013
-#line 1972
+#line 2013
put_ix_double(xp, &xx);
-#line 1972
+#line 2013
return err;
-#line 1972
+#line 2013
}
-#line 1972
+#line 2013
static int
-#line 1973
+#line 2014
ncx_put_double_short(void *xp, const short *ip, void *fillp)
-#line 1973
+#line 2014
{
-#line 1973
+#line 2014
int err=NC_NOERR;
-#line 1973
+#line 2014
ix_double xx = NC_FILL_DOUBLE;
-#line 1973
+#line 2014
-#line 1973
+#line 2014
-#line 1973
+#line 2014
xx = (ix_double)*ip;
-#line 1973
+#line 2014
-#line 1973
+#line 2014
put_ix_double(xp, &xx);
-#line 1973
+#line 2014
return err;
-#line 1973
+#line 2014
}
-#line 1973
+#line 2014
static int
-#line 1974
+#line 2015
ncx_put_double_ushort(void *xp, const ushort *ip, void *fillp)
-#line 1974
+#line 2015
{
-#line 1974
+#line 2015
int err=NC_NOERR;
-#line 1974
+#line 2015
ix_double xx = NC_FILL_DOUBLE;
-#line 1974
+#line 2015
-#line 1974
+#line 2015
-#line 1974
+#line 2015
xx = (ix_double)*ip;
-#line 1974
+#line 2015
-#line 1974
+#line 2015
put_ix_double(xp, &xx);
-#line 1974
+#line 2015
return err;
-#line 1974
+#line 2015
}
-#line 1974
+#line 2015
static int
-#line 1975
+#line 2016
ncx_put_double_int(void *xp, const int *ip, void *fillp)
-#line 1975
+#line 2016
{
-#line 1975
+#line 2016
int err=NC_NOERR;
-#line 1975
+#line 2016
ix_double xx = NC_FILL_DOUBLE;
-#line 1975
+#line 2016
-#line 1975
+#line 2016
-#line 1975
+#line 2016
xx = (ix_double)*ip;
-#line 1975
+#line 2016
-#line 1975
+#line 2016
put_ix_double(xp, &xx);
-#line 1975
+#line 2016
return err;
-#line 1975
+#line 2016
}
-#line 1975
+#line 2016
static int
-#line 1976
+#line 2017
ncx_put_double_long(void *xp, const long *ip, void *fillp)
-#line 1976
+#line 2017
{
-#line 1976
+#line 2017
int err=NC_NOERR;
-#line 1976
+#line 2017
ix_double xx = NC_FILL_DOUBLE;
-#line 1976
+#line 2017
-#line 1976
+#line 2017
-#line 1976
+#line 2017
xx = (ix_double)*ip;
-#line 1976
+#line 2017
-#line 1976
+#line 2017
put_ix_double(xp, &xx);
-#line 1976
+#line 2017
return err;
-#line 1976
+#line 2017
}
-#line 1976
+#line 2017
static int
-#line 1977
+#line 2018
ncx_put_double_uint(void *xp, const uint *ip, void *fillp)
-#line 1977
+#line 2018
{
-#line 1977
+#line 2018
int err=NC_NOERR;
-#line 1977
+#line 2018
ix_double xx = NC_FILL_DOUBLE;
-#line 1977
+#line 2018
-#line 1977
+#line 2018
-#line 1977
+#line 2018
xx = (ix_double)*ip;
-#line 1977
+#line 2018
-#line 1977
+#line 2018
put_ix_double(xp, &xx);
-#line 1977
+#line 2018
return err;
-#line 1977
+#line 2018
}
-#line 1977
+#line 2018
static int
-#line 1978
+#line 2019
ncx_put_double_longlong(void *xp, const longlong *ip, void *fillp)
-#line 1978
+#line 2019
{
-#line 1978
+#line 2019
int err=NC_NOERR;
-#line 1978
+#line 2019
ix_double xx = NC_FILL_DOUBLE;
-#line 1978
+#line 2019
-#line 1978
+#line 2019
-#line 1978
+#line 2019
xx = (ix_double)*ip;
-#line 1978
+#line 2019
-#line 1978
+#line 2019
put_ix_double(xp, &xx);
-#line 1978
+#line 2019
return err;
-#line 1978
+#line 2019
}
-#line 1978
+#line 2019
static int
-#line 1979
+#line 2020
ncx_put_double_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 1979
+#line 2020
{
-#line 1979
+#line 2020
int err=NC_NOERR;
-#line 1979
+#line 2020
ix_double xx = NC_FILL_DOUBLE;
-#line 1979
+#line 2020
-#line 1979
+#line 2020
-#line 1979
+#line 2020
xx = (ix_double)*ip;
-#line 1979
+#line 2020
-#line 1979
+#line 2020
put_ix_double(xp, &xx);
-#line 1979
+#line 2020
return err;
-#line 1979
+#line 2020
}
-#line 1979
+#line 2020
static int
@@ -5979,8 +6973,17 @@ ncx_put_double_float(void *xp, const float *ip, void *fillp)
#if 1 /* TODO: figure this out (if condition below will never be true)*/
if ((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN) {
+#line 2029
+#ifdef ERANGE_FILL
+#line 2029
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2029
+#endif
err = NC_ERANGE;
- }
+ }
+#ifdef ERANGE_FILL
+ else
+#endif
#endif
xx = (double) *ip;
@@ -5995,10 +6998,20 @@ ncx_put_double_double(void *xp, const double *ip, void *fillp)
int err=NC_NOERR;
double *_ip = ip;
#ifdef NO_IEEE_FLOAT
-
+#ifdef ERANGE_FILL
+ double tmp=NC_FILL_DOUBLE;
+#endif
if (*ip > X_DOUBLE_MAX || *ip < X_DOUBLE_MIN) {
-
+#line 2053
+#ifdef ERANGE_FILL
+#line 2053
+ if (fillp != NULL) memcpy(&tmp, fillp, 8);
+#line 2053
+#endif
+#ifdef ERANGE_FILL
+ _ip = &tmp;
+#endif
err = NC_ERANGE;
}
#endif
@@ -6059,840 +7072,1076 @@ put_ix_int64(void *xp, const ix_int64 *ip)
#if X_SIZEOF_INT64 != SIZEOF_LONGLONG
static int
-#line 2068
+#line 2116
ncx_get_longlong_longlong(const void *xp, longlong *ip)
-#line 2068
+#line 2116
{
-#line 2068
+#line 2116
int err=NC_NOERR;
-#line 2068
+#line 2116
#if SIZEOF_IX_INT64 == SIZEOF_LONGLONG && IX_INT64_MAX == LONGLONG_MAX
-#line 2068
+#line 2116
get_ix_int64(xp, (ix_int64 *)ip);
-#line 2068
+#line 2116
#else
-#line 2068
+#line 2116
ix_int64 xx;
-#line 2068
+#line 2116
get_ix_int64(xp, &xx);
-#line 2068
+#line 2116
-#line 2068
+#line 2116
#if IX_INT64_MAX > LONGLONG_MAX
-#line 2068
+#line 2116
if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) {
-#line 2068
-
-#line 2068
+#line 2116
+#ifdef ERANGE_FILL
+#line 2116
+ *ip = NC_FILL_INT64;
+#line 2116
+ return NC_ERANGE;
+#line 2116
+#else
+#line 2116
err = NC_ERANGE;
-#line 2068
+#line 2116
+#endif
+#line 2116
}
-#line 2068
+#line 2116
#endif
-#line 2068
+#line 2116
-#line 2068
+#line 2116
-#line 2068
+#line 2116
*ip = (longlong) xx;
-#line 2068
+#line 2116
#endif
-#line 2068
+#line 2116
return err;
-#line 2068
+#line 2116
}
-#line 2068
+#line 2116
#endif
static int
-#line 2070
+#line 2118
ncx_get_longlong_schar(const void *xp, schar *ip)
-#line 2070
+#line 2118
{
-#line 2070
+#line 2118
int err=NC_NOERR;
-#line 2070
+#line 2118
ix_int64 xx;
-#line 2070
+#line 2118
get_ix_int64(xp, &xx);
-#line 2070
+#line 2118
-#line 2070
+#line 2118
#if IX_INT64_MAX > SCHAR_MAX
-#line 2070
+#line 2118
if (xx > SCHAR_MAX || xx < SCHAR_MIN) {
-#line 2070
-
-#line 2070
+#line 2118
+#ifdef ERANGE_FILL
+#line 2118
+ *ip = NC_FILL_BYTE;
+#line 2118
+ return NC_ERANGE;
+#line 2118
+#else
+#line 2118
err = NC_ERANGE;
-#line 2070
+#line 2118
+#endif
+#line 2118
}
-#line 2070
+#line 2118
#endif
-#line 2070
+#line 2118
-#line 2070
+#line 2118
-#line 2070
+#line 2118
*ip = (schar) xx;
-#line 2070
+#line 2118
return err;
-#line 2070
+#line 2118
}
-#line 2070
+#line 2118
static int
-#line 2071
+#line 2119
ncx_get_longlong_short(const void *xp, short *ip)
-#line 2071
+#line 2119
{
-#line 2071
+#line 2119
int err=NC_NOERR;
-#line 2071
+#line 2119
#if SIZEOF_IX_INT64 == SIZEOF_SHORT && IX_INT64_MAX == SHORT_MAX
-#line 2071
+#line 2119
get_ix_int64(xp, (ix_int64 *)ip);
-#line 2071
+#line 2119
#else
-#line 2071
+#line 2119
ix_int64 xx;
-#line 2071
+#line 2119
get_ix_int64(xp, &xx);
-#line 2071
+#line 2119
-#line 2071
+#line 2119
#if IX_INT64_MAX > SHORT_MAX
-#line 2071
+#line 2119
if (xx > SHORT_MAX || xx < SHORT_MIN) {
-#line 2071
-
-#line 2071
+#line 2119
+#ifdef ERANGE_FILL
+#line 2119
+ *ip = NC_FILL_SHORT;
+#line 2119
+ return NC_ERANGE;
+#line 2119
+#else
+#line 2119
err = NC_ERANGE;
-#line 2071
+#line 2119
+#endif
+#line 2119
}
-#line 2071
+#line 2119
#endif
-#line 2071
+#line 2119
-#line 2071
+#line 2119
-#line 2071
+#line 2119
*ip = (short) xx;
-#line 2071
+#line 2119
#endif
-#line 2071
+#line 2119
return err;
-#line 2071
+#line 2119
}
-#line 2071
+#line 2119
static int
-#line 2072
+#line 2120
ncx_get_longlong_int(const void *xp, int *ip)
-#line 2072
+#line 2120
{
-#line 2072
+#line 2120
int err=NC_NOERR;
-#line 2072
+#line 2120
#if SIZEOF_IX_INT64 == SIZEOF_INT && IX_INT64_MAX == INT_MAX
-#line 2072
+#line 2120
get_ix_int64(xp, (ix_int64 *)ip);
-#line 2072
+#line 2120
#else
-#line 2072
+#line 2120
ix_int64 xx;
-#line 2072
+#line 2120
get_ix_int64(xp, &xx);
-#line 2072
+#line 2120
-#line 2072
+#line 2120
#if IX_INT64_MAX > INT_MAX
-#line 2072
+#line 2120
if (xx > INT_MAX || xx < INT_MIN) {
-#line 2072
-
-#line 2072
+#line 2120
+#ifdef ERANGE_FILL
+#line 2120
+ *ip = NC_FILL_INT;
+#line 2120
+ return NC_ERANGE;
+#line 2120
+#else
+#line 2120
err = NC_ERANGE;
-#line 2072
+#line 2120
+#endif
+#line 2120
}
-#line 2072
+#line 2120
#endif
-#line 2072
+#line 2120
-#line 2072
+#line 2120
-#line 2072
+#line 2120
*ip = (int) xx;
-#line 2072
+#line 2120
#endif
-#line 2072
+#line 2120
return err;
-#line 2072
+#line 2120
}
-#line 2072
+#line 2120
static int
-#line 2073
+#line 2121
ncx_get_longlong_long(const void *xp, long *ip)
-#line 2073
+#line 2121
{
-#line 2073
+#line 2121
int err=NC_NOERR;
-#line 2073
+#line 2121
#if SIZEOF_IX_INT64 == SIZEOF_LONG && IX_INT64_MAX == LONG_MAX
-#line 2073
+#line 2121
get_ix_int64(xp, (ix_int64 *)ip);
-#line 2073
+#line 2121
#else
-#line 2073
+#line 2121
ix_int64 xx;
-#line 2073
+#line 2121
get_ix_int64(xp, &xx);
-#line 2073
+#line 2121
-#line 2073
+#line 2121
#if IX_INT64_MAX > LONG_MAX
-#line 2073
+#line 2121
if (xx > LONG_MAX || xx < LONG_MIN) {
-#line 2073
-
-#line 2073
+#line 2121
+#ifdef ERANGE_FILL
+#line 2121
+ *ip = NC_FILL_INT;
+#line 2121
+ return NC_ERANGE;
+#line 2121
+#else
+#line 2121
err = NC_ERANGE;
-#line 2073
+#line 2121
+#endif
+#line 2121
}
-#line 2073
+#line 2121
#endif
-#line 2073
+#line 2121
-#line 2073
+#line 2121
-#line 2073
+#line 2121
*ip = (long) xx;
-#line 2073
+#line 2121
#endif
-#line 2073
+#line 2121
return err;
-#line 2073
+#line 2121
}
-#line 2073
+#line 2121
static int
-#line 2074
+#line 2122
ncx_get_longlong_ushort(const void *xp, ushort *ip)
-#line 2074
+#line 2122
{
-#line 2074
+#line 2122
int err=NC_NOERR;
-#line 2074
+#line 2122
ix_int64 xx;
-#line 2074
+#line 2122
get_ix_int64(xp, &xx);
-#line 2074
+#line 2122
-#line 2074
+#line 2122
#if IX_INT64_MAX > USHORT_MAX
-#line 2074
+#line 2122
if (xx > USHORT_MAX) {
-#line 2074
-
-#line 2074
+#line 2122
+#ifdef ERANGE_FILL
+#line 2122
+ *ip = NC_FILL_USHORT;
+#line 2122
+ return NC_ERANGE;
+#line 2122
+#else
+#line 2122
err = NC_ERANGE;
-#line 2074
+#line 2122
+#endif
+#line 2122
}
-#line 2074
+#line 2122
#endif
-#line 2074
+#line 2122
-#line 2074
+#line 2122
if (xx < 0) {
-#line 2074
-
-#line 2074
+#line 2122
+#ifdef ERANGE_FILL
+#line 2122
+ *ip = NC_FILL_USHORT;
+#line 2122
+ return NC_ERANGE;
+#line 2122
+#else
+#line 2122
err = NC_ERANGE; /* because ip is unsigned */
-#line 2074
+#line 2122
+#endif
+#line 2122
}
-#line 2074
+#line 2122
*ip = (ushort) xx;
-#line 2074
+#line 2122
return err;
-#line 2074
+#line 2122
}
-#line 2074
+#line 2122
static int
-#line 2075
+#line 2123
ncx_get_longlong_uchar(const void *xp, uchar *ip)
-#line 2075
+#line 2123
{
-#line 2075
+#line 2123
int err=NC_NOERR;
-#line 2075
+#line 2123
ix_int64 xx;
-#line 2075
+#line 2123
get_ix_int64(xp, &xx);
-#line 2075
+#line 2123
-#line 2075
+#line 2123
#if IX_INT64_MAX > UCHAR_MAX
-#line 2075
+#line 2123
if (xx > UCHAR_MAX) {
-#line 2075
-
-#line 2075
+#line 2123
+#ifdef ERANGE_FILL
+#line 2123
+ *ip = NC_FILL_UBYTE;
+#line 2123
+ return NC_ERANGE;
+#line 2123
+#else
+#line 2123
err = NC_ERANGE;
-#line 2075
+#line 2123
+#endif
+#line 2123
}
-#line 2075
+#line 2123
#endif
-#line 2075
+#line 2123
-#line 2075
+#line 2123
if (xx < 0) {
-#line 2075
-
-#line 2075
+#line 2123
+#ifdef ERANGE_FILL
+#line 2123
+ *ip = NC_FILL_UBYTE;
+#line 2123
+ return NC_ERANGE;
+#line 2123
+#else
+#line 2123
err = NC_ERANGE; /* because ip is unsigned */
-#line 2075
+#line 2123
+#endif
+#line 2123
}
-#line 2075
+#line 2123
*ip = (uchar) xx;
-#line 2075
+#line 2123
return err;
-#line 2075
+#line 2123
}
-#line 2075
+#line 2123
static int
-#line 2076
+#line 2124
ncx_get_longlong_uint(const void *xp, uint *ip)
-#line 2076
+#line 2124
{
-#line 2076
+#line 2124
int err=NC_NOERR;
-#line 2076
+#line 2124
ix_int64 xx;
-#line 2076
+#line 2124
get_ix_int64(xp, &xx);
-#line 2076
+#line 2124
-#line 2076
+#line 2124
#if IX_INT64_MAX > UINT_MAX
-#line 2076
+#line 2124
if (xx > UINT_MAX) {
-#line 2076
-
-#line 2076
+#line 2124
+#ifdef ERANGE_FILL
+#line 2124
+ *ip = NC_FILL_UINT;
+#line 2124
+ return NC_ERANGE;
+#line 2124
+#else
+#line 2124
err = NC_ERANGE;
-#line 2076
+#line 2124
+#endif
+#line 2124
}
-#line 2076
+#line 2124
#endif
-#line 2076
+#line 2124
-#line 2076
+#line 2124
if (xx < 0) {
-#line 2076
-
-#line 2076
+#line 2124
+#ifdef ERANGE_FILL
+#line 2124
+ *ip = NC_FILL_UINT;
+#line 2124
+ return NC_ERANGE;
+#line 2124
+#else
+#line 2124
err = NC_ERANGE; /* because ip is unsigned */
-#line 2076
+#line 2124
+#endif
+#line 2124
}
-#line 2076
+#line 2124
*ip = (uint) xx;
-#line 2076
+#line 2124
return err;
-#line 2076
+#line 2124
}
-#line 2076
+#line 2124
static int
-#line 2077
+#line 2125
ncx_get_longlong_ulonglong(const void *xp, ulonglong *ip)
-#line 2077
+#line 2125
{
-#line 2077
+#line 2125
int err=NC_NOERR;
-#line 2077
+#line 2125
ix_int64 xx;
-#line 2077
+#line 2125
get_ix_int64(xp, &xx);
-#line 2077
+#line 2125
-#line 2077
+#line 2125
#if IX_INT64_MAX > ULONGLONG_MAX
-#line 2077
+#line 2125
if (xx > ULONGLONG_MAX) {
-#line 2077
-
-#line 2077
+#line 2125
+#ifdef ERANGE_FILL
+#line 2125
+ *ip = NC_FILL_UINT64;
+#line 2125
+ return NC_ERANGE;
+#line 2125
+#else
+#line 2125
err = NC_ERANGE;
-#line 2077
+#line 2125
+#endif
+#line 2125
}
-#line 2077
+#line 2125
#endif
-#line 2077
+#line 2125
-#line 2077
+#line 2125
if (xx < 0) {
-#line 2077
-
-#line 2077
+#line 2125
+#ifdef ERANGE_FILL
+#line 2125
+ *ip = NC_FILL_UINT64;
+#line 2125
+ return NC_ERANGE;
+#line 2125
+#else
+#line 2125
err = NC_ERANGE; /* because ip is unsigned */
-#line 2077
+#line 2125
+#endif
+#line 2125
}
-#line 2077
+#line 2125
*ip = (ulonglong) xx;
-#line 2077
+#line 2125
return err;
-#line 2077
+#line 2125
}
-#line 2077
+#line 2125
static int
-#line 2078
+#line 2126
ncx_get_longlong_float(const void *xp, float *ip)
-#line 2078
+#line 2126
{
-#line 2078
+#line 2126
ix_int64 xx;
-#line 2078
+#line 2126
get_ix_int64(xp, &xx);
-#line 2078
+#line 2126
*ip = (float)xx;
-#line 2078
+#line 2126
return NC_NOERR;
-#line 2078
+#line 2126
}
-#line 2078
+#line 2126
static int
-#line 2079
+#line 2127
ncx_get_longlong_double(const void *xp, double *ip)
-#line 2079
+#line 2127
{
-#line 2079
+#line 2127
ix_int64 xx;
-#line 2079
+#line 2127
get_ix_int64(xp, &xx);
-#line 2079
+#line 2127
*ip = (double)xx;
-#line 2079
+#line 2127
return NC_NOERR;
-#line 2079
+#line 2127
}
-#line 2079
+#line 2127
#if X_SIZEOF_INT64 != SIZEOF_LONGLONG
static int
-#line 2082
+#line 2130
ncx_put_longlong_longlong(void *xp, const longlong *ip, void *fillp)
-#line 2082
+#line 2130
{
-#line 2082
+#line 2130
int err=NC_NOERR;
-#line 2082
+#line 2130
#if SIZEOF_IX_INT64 == SIZEOF_LONGLONG && IX_INT64_MAX == LONGLONG_MAX
-#line 2082
+#line 2130
put_ix_int64(xp, (const ix_int64 *)ip);
-#line 2082
+#line 2130
#else
-#line 2082
+#line 2130
ix_int64 xx = NC_FILL_INT64;
-#line 2082
+#line 2130
-#line 2082
+#line 2130
#if IX_INT64_MAX < LONGLONG_MAX
-#line 2082
+#line 2130
if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
-#line 2082
+#line 2130
-#line 2082
+#line 2130
+#ifdef ERANGE_FILL
+#line 2130
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2130
+#endif
+#line 2130
err = NC_ERANGE;
-#line 2082
- }
-#line 2082
+#line 2130
+ }
+#line 2130
+#ifdef ERANGE_FILL
+#line 2130
+ else
+#line 2130
+#endif
+#line 2130
#endif
-#line 2082
+#line 2130
xx = (ix_int64)*ip;
-#line 2082
+#line 2130
-#line 2082
+#line 2130
put_ix_int64(xp, &xx);
-#line 2082
+#line 2130
#endif
-#line 2082
+#line 2130
return err;
-#line 2082
+#line 2130
}
-#line 2082
+#line 2130
#endif
static int
-#line 2084
+#line 2132
ncx_put_longlong_schar(void *xp, const schar *ip, void *fillp)
-#line 2084
+#line 2132
{
-#line 2084
+#line 2132
int err=NC_NOERR;
-#line 2084
+#line 2132
ix_int64 xx = NC_FILL_INT64;
-#line 2084
+#line 2132
-#line 2084
+#line 2132
#if IX_INT64_MAX < SCHAR_MAX
-#line 2084
+#line 2132
if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
-#line 2084
+#line 2132
-#line 2084
+#line 2132
+#ifdef ERANGE_FILL
+#line 2132
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2132
+#endif
+#line 2132
err = NC_ERANGE;
-#line 2084
- }
-#line 2084
+#line 2132
+ }
+#line 2132
+#ifdef ERANGE_FILL
+#line 2132
+ else
+#line 2132
+#endif
+#line 2132
#endif
-#line 2084
+#line 2132
xx = (ix_int64)*ip;
-#line 2084
+#line 2132
-#line 2084
+#line 2132
put_ix_int64(xp, &xx);
-#line 2084
+#line 2132
return err;
-#line 2084
+#line 2132
}
-#line 2084
+#line 2132
static int
-#line 2085
+#line 2133
ncx_put_longlong_short(void *xp, const short *ip, void *fillp)
-#line 2085
+#line 2133
{
-#line 2085
+#line 2133
int err=NC_NOERR;
-#line 2085
+#line 2133
#if SIZEOF_IX_INT64 == SIZEOF_SHORT && IX_INT64_MAX == SHORT_MAX
-#line 2085
+#line 2133
put_ix_int64(xp, (const ix_int64 *)ip);
-#line 2085
+#line 2133
#else
-#line 2085
+#line 2133
ix_int64 xx = NC_FILL_INT64;
-#line 2085
+#line 2133
-#line 2085
+#line 2133
#if IX_INT64_MAX < SHORT_MAX
-#line 2085
+#line 2133
if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
-#line 2085
+#line 2133
-#line 2085
+#line 2133
+#ifdef ERANGE_FILL
+#line 2133
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2133
+#endif
+#line 2133
err = NC_ERANGE;
-#line 2085
- }
-#line 2085
+#line 2133
+ }
+#line 2133
+#ifdef ERANGE_FILL
+#line 2133
+ else
+#line 2133
+#endif
+#line 2133
#endif
-#line 2085
+#line 2133
xx = (ix_int64)*ip;
-#line 2085
+#line 2133
-#line 2085
+#line 2133
put_ix_int64(xp, &xx);
-#line 2085
+#line 2133
#endif
-#line 2085
+#line 2133
return err;
-#line 2085
+#line 2133
}
-#line 2085
+#line 2133
static int
-#line 2086
+#line 2134
ncx_put_longlong_int(void *xp, const int *ip, void *fillp)
-#line 2086
+#line 2134
{
-#line 2086
+#line 2134
int err=NC_NOERR;
-#line 2086
+#line 2134
#if SIZEOF_IX_INT64 == SIZEOF_INT && IX_INT64_MAX == INT_MAX
-#line 2086
+#line 2134
put_ix_int64(xp, (const ix_int64 *)ip);
-#line 2086
+#line 2134
#else
-#line 2086
+#line 2134
ix_int64 xx = NC_FILL_INT64;
-#line 2086
+#line 2134
-#line 2086
+#line 2134
#if IX_INT64_MAX < INT_MAX
-#line 2086
+#line 2134
if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
-#line 2086
+#line 2134
-#line 2086
+#line 2134
+#ifdef ERANGE_FILL
+#line 2134
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2134
+#endif
+#line 2134
err = NC_ERANGE;
-#line 2086
- }
-#line 2086
+#line 2134
+ }
+#line 2134
+#ifdef ERANGE_FILL
+#line 2134
+ else
+#line 2134
+#endif
+#line 2134
#endif
-#line 2086
+#line 2134
xx = (ix_int64)*ip;
-#line 2086
+#line 2134
-#line 2086
+#line 2134
put_ix_int64(xp, &xx);
-#line 2086
+#line 2134
#endif
-#line 2086
+#line 2134
return err;
-#line 2086
+#line 2134
}
-#line 2086
+#line 2134
static int
-#line 2087
+#line 2135
ncx_put_longlong_long(void *xp, const long *ip, void *fillp)
-#line 2087
+#line 2135
{
-#line 2087
+#line 2135
int err=NC_NOERR;
-#line 2087
+#line 2135
#if SIZEOF_IX_INT64 == SIZEOF_LONG && IX_INT64_MAX == LONG_MAX
-#line 2087
+#line 2135
put_ix_int64(xp, (const ix_int64 *)ip);
-#line 2087
+#line 2135
#else
-#line 2087
+#line 2135
ix_int64 xx = NC_FILL_INT64;
-#line 2087
+#line 2135
-#line 2087
+#line 2135
#if IX_INT64_MAX < LONG_MAX
-#line 2087
+#line 2135
if (*ip > IX_INT64_MAX || *ip < X_INT64_MIN) {
-#line 2087
+#line 2135
-#line 2087
+#line 2135
+#ifdef ERANGE_FILL
+#line 2135
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2135
+#endif
+#line 2135
err = NC_ERANGE;
-#line 2087
- }
-#line 2087
+#line 2135
+ }
+#line 2135
+#ifdef ERANGE_FILL
+#line 2135
+ else
+#line 2135
+#endif
+#line 2135
#endif
-#line 2087
+#line 2135
xx = (ix_int64)*ip;
-#line 2087
+#line 2135
-#line 2087
+#line 2135
put_ix_int64(xp, &xx);
-#line 2087
+#line 2135
#endif
-#line 2087
+#line 2135
return err;
-#line 2087
+#line 2135
}
-#line 2087
+#line 2135
static int
-#line 2088
+#line 2136
ncx_put_longlong_ushort(void *xp, const ushort *ip, void *fillp)
-#line 2088
+#line 2136
{
-#line 2088
+#line 2136
int err=NC_NOERR;
-#line 2088
+#line 2136
ix_int64 xx = NC_FILL_INT64;
-#line 2088
+#line 2136
-#line 2088
+#line 2136
#if IX_INT64_MAX < USHORT_MAX
-#line 2088
+#line 2136
if (*ip > IX_INT64_MAX) {
-#line 2088
+#line 2136
-#line 2088
+#line 2136
+#ifdef ERANGE_FILL
+#line 2136
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2136
+#endif
+#line 2136
err = NC_ERANGE;
-#line 2088
- }
-#line 2088
+#line 2136
+ }
+#line 2136
+#ifdef ERANGE_FILL
+#line 2136
+ else
+#line 2136
+#endif
+#line 2136
#endif
-#line 2088
+#line 2136
xx = (ix_int64)*ip;
-#line 2088
+#line 2136
-#line 2088
+#line 2136
put_ix_int64(xp, &xx);
-#line 2088
+#line 2136
return err;
-#line 2088
+#line 2136
}
-#line 2088
+#line 2136
static int
-#line 2089
+#line 2137
ncx_put_longlong_uchar(void *xp, const uchar *ip, void *fillp)
-#line 2089
+#line 2137
{
-#line 2089
+#line 2137
int err=NC_NOERR;
-#line 2089
+#line 2137
ix_int64 xx = NC_FILL_INT64;
-#line 2089
+#line 2137
-#line 2089
+#line 2137
#if IX_INT64_MAX < UCHAR_MAX
-#line 2089
+#line 2137
if (*ip > IX_INT64_MAX) {
-#line 2089
+#line 2137
-#line 2089
- err = NC_ERANGE;
-#line 2089
- }
-#line 2089
+#line 2137
+#ifdef ERANGE_FILL
+#line 2137
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2137
#endif
-#line 2089
- xx = (ix_int64)*ip;
-#line 2089
+#line 2137
+ err = NC_ERANGE;
+#line 2137
+ }
+#line 2137
+#ifdef ERANGE_FILL
+#line 2137
+ else
+#line 2137
+#endif
+#line 2137
+#endif
+#line 2137
+ xx = (ix_int64)*ip;
+#line 2137
-#line 2089
+#line 2137
put_ix_int64(xp, &xx);
-#line 2089
+#line 2137
return err;
-#line 2089
+#line 2137
}
-#line 2089
+#line 2137
static int
-#line 2090
+#line 2138
ncx_put_longlong_uint(void *xp, const uint *ip, void *fillp)
-#line 2090
+#line 2138
{
-#line 2090
+#line 2138
int err=NC_NOERR;
-#line 2090
+#line 2138
ix_int64 xx = NC_FILL_INT64;
-#line 2090
+#line 2138
-#line 2090
+#line 2138
#if IX_INT64_MAX < UINT_MAX
-#line 2090
+#line 2138
if (*ip > IX_INT64_MAX) {
-#line 2090
+#line 2138
-#line 2090
+#line 2138
+#ifdef ERANGE_FILL
+#line 2138
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2138
+#endif
+#line 2138
err = NC_ERANGE;
-#line 2090
- }
-#line 2090
+#line 2138
+ }
+#line 2138
+#ifdef ERANGE_FILL
+#line 2138
+ else
+#line 2138
+#endif
+#line 2138
#endif
-#line 2090
+#line 2138
xx = (ix_int64)*ip;
-#line 2090
+#line 2138
-#line 2090
+#line 2138
put_ix_int64(xp, &xx);
-#line 2090
+#line 2138
return err;
-#line 2090
+#line 2138
}
-#line 2090
+#line 2138
static int
-#line 2091
+#line 2139
ncx_put_longlong_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 2091
+#line 2139
{
-#line 2091
+#line 2139
int err=NC_NOERR;
-#line 2091
+#line 2139
ix_int64 xx = NC_FILL_INT64;
-#line 2091
+#line 2139
-#line 2091
+#line 2139
#if IX_INT64_MAX < ULONGLONG_MAX
-#line 2091
+#line 2139
if (*ip > IX_INT64_MAX) {
-#line 2091
+#line 2139
-#line 2091
+#line 2139
+#ifdef ERANGE_FILL
+#line 2139
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2139
+#endif
+#line 2139
err = NC_ERANGE;
-#line 2091
- }
-#line 2091
+#line 2139
+ }
+#line 2139
+#ifdef ERANGE_FILL
+#line 2139
+ else
+#line 2139
+#endif
+#line 2139
#endif
-#line 2091
+#line 2139
xx = (ix_int64)*ip;
-#line 2091
+#line 2139
-#line 2091
+#line 2139
put_ix_int64(xp, &xx);
-#line 2091
+#line 2139
return err;
-#line 2091
+#line 2139
}
-#line 2091
+#line 2139
static int
-#line 2092
+#line 2140
ncx_put_longlong_float(void *xp, const float *ip, void *fillp)
-#line 2092
+#line 2140
{
-#line 2092
+#line 2140
int err=NC_NOERR;
-#line 2092
+#line 2140
ix_int64 xx = NC_FILL_INT64;
-#line 2092
+#line 2140
-#line 2092
+#line 2140
if (*ip > (double)X_INT64_MAX || *ip < (double)X_INT64_MIN) {
-#line 2092
+#line 2140
-#line 2092
+#line 2140
+#ifdef ERANGE_FILL
+#line 2140
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2140
+#endif
+#line 2140
err = NC_ERANGE;
-#line 2092
- }
-#line 2092
+#line 2140
+ }
+#line 2140
+#ifdef ERANGE_FILL
+#line 2140
+ else
+#line 2140
+#endif
+#line 2140
xx = (ix_int64)*ip;
-#line 2092
+#line 2140
-#line 2092
+#line 2140
put_ix_int64(xp, &xx);
-#line 2092
+#line 2140
return err;
-#line 2092
+#line 2140
}
-#line 2092
+#line 2140
static int
-#line 2093
+#line 2141
ncx_put_longlong_double(void *xp, const double *ip, void *fillp)
-#line 2093
+#line 2141
{
-#line 2093
+#line 2141
int err=NC_NOERR;
-#line 2093
+#line 2141
ix_int64 xx = NC_FILL_INT64;
-#line 2093
+#line 2141
-#line 2093
+#line 2141
if (*ip > X_INT64_MAX || *ip < X_INT64_MIN) {
-#line 2093
+#line 2141
-#line 2093
+#line 2141
+#ifdef ERANGE_FILL
+#line 2141
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2141
+#endif
+#line 2141
err = NC_ERANGE;
-#line 2093
- }
-#line 2093
+#line 2141
+ }
+#line 2141
+#ifdef ERANGE_FILL
+#line 2141
+ else
+#line 2141
+#endif
+#line 2141
xx = (ix_int64)*ip;
-#line 2093
+#line 2141
-#line 2093
+#line 2141
put_ix_int64(xp, &xx);
-#line 2093
+#line 2141
return err;
-#line 2093
+#line 2141
}
-#line 2093
+#line 2141
@@ -6947,856 +8196,1120 @@ put_ix_uint64(void *xp, const ix_uint64 *ip)
#if X_SIZEOF_UINT64 != SIZEOF_ULONGLONG
static int
-#line 2146
+#line 2194
ncx_get_ulonglong_ulonglong(const void *xp, ulonglong *ip)
-#line 2146
+#line 2194
{
-#line 2146
+#line 2194
int err=NC_NOERR;
-#line 2146
+#line 2194
#if SIZEOF_IX_UINT64 == SIZEOF_ULONGLONG && IX_UINT64_MAX == ULONGLONG_MAX
-#line 2146
+#line 2194
get_ix_uint64(xp, (ix_uint64 *)ip);
-#line 2146
+#line 2194
#else
-#line 2146
+#line 2194
ix_uint64 xx;
-#line 2146
+#line 2194
get_ix_uint64(xp, &xx);
-#line 2146
+#line 2194
-#line 2146
+#line 2194
#if IX_UINT64_MAX > ULONGLONG_MAX
-#line 2146
+#line 2194
if (xx > ULONGLONG_MAX) {
-#line 2146
-
-#line 2146
+#line 2194
+#ifdef ERANGE_FILL
+#line 2194
+ *ip = NC_FILL_UINT64;
+#line 2194
+ return NC_ERANGE;
+#line 2194
+#else
+#line 2194
err = NC_ERANGE;
-#line 2146
+#line 2194
+#endif
+#line 2194
}
-#line 2146
+#line 2194
#endif
-#line 2146
+#line 2194
-#line 2146
+#line 2194
-#line 2146
+#line 2194
*ip = (ulonglong) xx;
-#line 2146
+#line 2194
#endif
-#line 2146
+#line 2194
return err;
-#line 2146
+#line 2194
}
-#line 2146
+#line 2194
#endif
static int
-#line 2148
+#line 2196
ncx_get_ulonglong_schar(const void *xp, schar *ip)
-#line 2148
+#line 2196
{
-#line 2148
+#line 2196
int err=NC_NOERR;
-#line 2148
+#line 2196
ix_uint64 xx;
-#line 2148
+#line 2196
get_ix_uint64(xp, &xx);
-#line 2148
+#line 2196
-#line 2148
+#line 2196
#if IX_UINT64_MAX > SCHAR_MAX
-#line 2148
+#line 2196
if (xx > SCHAR_MAX) {
-#line 2148
-
-#line 2148
+#line 2196
+#ifdef ERANGE_FILL
+#line 2196
+ *ip = NC_FILL_BYTE;
+#line 2196
+ return NC_ERANGE;
+#line 2196
+#else
+#line 2196
err = NC_ERANGE;
-#line 2148
+#line 2196
+#endif
+#line 2196
}
-#line 2148
+#line 2196
#endif
-#line 2148
+#line 2196
-#line 2148
+#line 2196
-#line 2148
+#line 2196
*ip = (schar) xx;
-#line 2148
+#line 2196
return err;
-#line 2148
+#line 2196
}
-#line 2148
+#line 2196
static int
-#line 2149
+#line 2197
ncx_get_ulonglong_short(const void *xp, short *ip)
-#line 2149
+#line 2197
{
-#line 2149
+#line 2197
int err=NC_NOERR;
-#line 2149
+#line 2197
ix_uint64 xx;
-#line 2149
+#line 2197
get_ix_uint64(xp, &xx);
-#line 2149
+#line 2197
-#line 2149
+#line 2197
#if IX_UINT64_MAX > SHORT_MAX
-#line 2149
+#line 2197
if (xx > SHORT_MAX) {
-#line 2149
-
-#line 2149
+#line 2197
+#ifdef ERANGE_FILL
+#line 2197
+ *ip = NC_FILL_SHORT;
+#line 2197
+ return NC_ERANGE;
+#line 2197
+#else
+#line 2197
err = NC_ERANGE;
-#line 2149
+#line 2197
+#endif
+#line 2197
}
-#line 2149
+#line 2197
#endif
-#line 2149
+#line 2197
-#line 2149
+#line 2197
-#line 2149
+#line 2197
*ip = (short) xx;
-#line 2149
+#line 2197
return err;
-#line 2149
+#line 2197
}
-#line 2149
+#line 2197
static int
-#line 2150
+#line 2198
ncx_get_ulonglong_int(const void *xp, int *ip)
-#line 2150
+#line 2198
{
-#line 2150
+#line 2198
int err=NC_NOERR;
-#line 2150
+#line 2198
ix_uint64 xx;
-#line 2150
+#line 2198
get_ix_uint64(xp, &xx);
-#line 2150
+#line 2198
-#line 2150
+#line 2198
#if IX_UINT64_MAX > INT_MAX
-#line 2150
+#line 2198
if (xx > INT_MAX) {
-#line 2150
-
-#line 2150
+#line 2198
+#ifdef ERANGE_FILL
+#line 2198
+ *ip = NC_FILL_INT;
+#line 2198
+ return NC_ERANGE;
+#line 2198
+#else
+#line 2198
err = NC_ERANGE;
-#line 2150
+#line 2198
+#endif
+#line 2198
}
-#line 2150
+#line 2198
#endif
-#line 2150
+#line 2198
-#line 2150
+#line 2198
-#line 2150
+#line 2198
*ip = (int) xx;
-#line 2150
+#line 2198
return err;
-#line 2150
+#line 2198
}
-#line 2150
+#line 2198
static int
-#line 2151
+#line 2199
ncx_get_ulonglong_long(const void *xp, long *ip)
-#line 2151
+#line 2199
{
-#line 2151
+#line 2199
int err=NC_NOERR;
-#line 2151
+#line 2199
ix_uint64 xx;
-#line 2151
+#line 2199
get_ix_uint64(xp, &xx);
-#line 2151
+#line 2199
-#line 2151
+#line 2199
#if IX_UINT64_MAX > LONG_MAX
-#line 2151
+#line 2199
if (xx > LONG_MAX) {
-#line 2151
-
-#line 2151
+#line 2199
+#ifdef ERANGE_FILL
+#line 2199
+ *ip = NC_FILL_INT;
+#line 2199
+ return NC_ERANGE;
+#line 2199
+#else
+#line 2199
err = NC_ERANGE;
-#line 2151
+#line 2199
+#endif
+#line 2199
}
-#line 2151
+#line 2199
#endif
-#line 2151
+#line 2199
-#line 2151
+#line 2199
-#line 2151
+#line 2199
*ip = (long) xx;
-#line 2151
+#line 2199
return err;
-#line 2151
+#line 2199
}
-#line 2151
+#line 2199
static int
-#line 2152
+#line 2200
ncx_get_ulonglong_longlong(const void *xp, longlong *ip)
-#line 2152
+#line 2200
{
-#line 2152
+#line 2200
int err=NC_NOERR;
-#line 2152
+#line 2200
ix_uint64 xx;
-#line 2152
+#line 2200
get_ix_uint64(xp, &xx);
-#line 2152
+#line 2200
-#line 2152
+#line 2200
#if IX_UINT64_MAX > LONGLONG_MAX
-#line 2152
+#line 2200
if (xx > LONGLONG_MAX) {
-#line 2152
-
-#line 2152
+#line 2200
+#ifdef ERANGE_FILL
+#line 2200
+ *ip = NC_FILL_INT64;
+#line 2200
+ return NC_ERANGE;
+#line 2200
+#else
+#line 2200
err = NC_ERANGE;
-#line 2152
+#line 2200
+#endif
+#line 2200
}
-#line 2152
+#line 2200
#endif
-#line 2152
+#line 2200
-#line 2152
+#line 2200
-#line 2152
+#line 2200
*ip = (longlong) xx;
-#line 2152
+#line 2200
return err;
-#line 2152
+#line 2200
}
-#line 2152
+#line 2200
static int
-#line 2153
+#line 2201
ncx_get_ulonglong_ushort(const void *xp, ushort *ip)
-#line 2153
+#line 2201
{
-#line 2153
+#line 2201
int err=NC_NOERR;
-#line 2153
+#line 2201
#if SIZEOF_IX_UINT64 == SIZEOF_USHORT && IX_UINT64_MAX == USHORT_MAX
-#line 2153
+#line 2201
get_ix_uint64(xp, (ix_uint64 *)ip);
-#line 2153
+#line 2201
#else
-#line 2153
+#line 2201
ix_uint64 xx;
-#line 2153
+#line 2201
get_ix_uint64(xp, &xx);
-#line 2153
+#line 2201
-#line 2153
+#line 2201
#if IX_UINT64_MAX > USHORT_MAX
-#line 2153
+#line 2201
if (xx > USHORT_MAX) {
-#line 2153
-
-#line 2153
+#line 2201
+#ifdef ERANGE_FILL
+#line 2201
+ *ip = NC_FILL_USHORT;
+#line 2201
+ return NC_ERANGE;
+#line 2201
+#else
+#line 2201
err = NC_ERANGE;
-#line 2153
+#line 2201
+#endif
+#line 2201
}
-#line 2153
+#line 2201
#endif
-#line 2153
+#line 2201
-#line 2153
+#line 2201
-#line 2153
+#line 2201
*ip = (ushort) xx;
-#line 2153
+#line 2201
#endif
-#line 2153
+#line 2201
return err;
-#line 2153
+#line 2201
}
-#line 2153
+#line 2201
static int
-#line 2154
+#line 2202
ncx_get_ulonglong_uchar(const void *xp, uchar *ip)
-#line 2154
+#line 2202
{
-#line 2154
+#line 2202
int err=NC_NOERR;
-#line 2154
+#line 2202
#if SIZEOF_IX_UINT64 == SIZEOF_UCHAR && IX_UINT64_MAX == UCHAR_MAX
-#line 2154
+#line 2202
get_ix_uint64(xp, (ix_uint64 *)ip);
-#line 2154
+#line 2202
#else
-#line 2154
+#line 2202
ix_uint64 xx;
-#line 2154
+#line 2202
get_ix_uint64(xp, &xx);
-#line 2154
+#line 2202
-#line 2154
+#line 2202
#if IX_UINT64_MAX > UCHAR_MAX
-#line 2154
+#line 2202
if (xx > UCHAR_MAX) {
-#line 2154
-
-#line 2154
+#line 2202
+#ifdef ERANGE_FILL
+#line 2202
+ *ip = NC_FILL_UBYTE;
+#line 2202
+ return NC_ERANGE;
+#line 2202
+#else
+#line 2202
err = NC_ERANGE;
-#line 2154
+#line 2202
+#endif
+#line 2202
}
-#line 2154
+#line 2202
#endif
-#line 2154
+#line 2202
-#line 2154
+#line 2202
-#line 2154
+#line 2202
*ip = (uchar) xx;
-#line 2154
+#line 2202
#endif
-#line 2154
+#line 2202
return err;
-#line 2154
+#line 2202
}
-#line 2154
+#line 2202
static int
-#line 2155
+#line 2203
ncx_get_ulonglong_uint(const void *xp, uint *ip)
-#line 2155
+#line 2203
{
-#line 2155
+#line 2203
int err=NC_NOERR;
-#line 2155
+#line 2203
#if SIZEOF_IX_UINT64 == SIZEOF_UINT && IX_UINT64_MAX == UINT_MAX
-#line 2155
+#line 2203
get_ix_uint64(xp, (ix_uint64 *)ip);
-#line 2155
+#line 2203
#else
-#line 2155
+#line 2203
ix_uint64 xx;
-#line 2155
+#line 2203
get_ix_uint64(xp, &xx);
-#line 2155
+#line 2203
-#line 2155
+#line 2203
#if IX_UINT64_MAX > UINT_MAX
-#line 2155
+#line 2203
if (xx > UINT_MAX) {
-#line 2155
-
-#line 2155
+#line 2203
+#ifdef ERANGE_FILL
+#line 2203
+ *ip = NC_FILL_UINT;
+#line 2203
+ return NC_ERANGE;
+#line 2203
+#else
+#line 2203
err = NC_ERANGE;
-#line 2155
+#line 2203
+#endif
+#line 2203
}
-#line 2155
+#line 2203
#endif
-#line 2155
+#line 2203
-#line 2155
+#line 2203
-#line 2155
+#line 2203
*ip = (uint) xx;
-#line 2155
+#line 2203
#endif
-#line 2155
+#line 2203
return err;
-#line 2155
+#line 2203
}
-#line 2155
+#line 2203
static int
-#line 2156
+#line 2204
ncx_get_ulonglong_float(const void *xp, float *ip)
-#line 2156
+#line 2204
{
-#line 2156
+#line 2204
ix_uint64 xx;
-#line 2156
+#line 2204
get_ix_uint64(xp, &xx);
-#line 2156
+#line 2204
*ip = (float)xx;
-#line 2156
+#line 2204
return NC_NOERR;
-#line 2156
+#line 2204
}
-#line 2156
+#line 2204
static int
-#line 2157
+#line 2205
ncx_get_ulonglong_double(const void *xp, double *ip)
-#line 2157
+#line 2205
{
-#line 2157
+#line 2205
ix_uint64 xx;
-#line 2157
+#line 2205
get_ix_uint64(xp, &xx);
-#line 2157
+#line 2205
*ip = (double)xx;
-#line 2157
+#line 2205
return NC_NOERR;
-#line 2157
+#line 2205
}
-#line 2157
+#line 2205
#if X_SIZEOF_UINT64 != SIZEOF_ULONGLONG
static int
-#line 2160
+#line 2208
ncx_put_ulonglong_ulonglong(void *xp, const ulonglong *ip, void *fillp)
-#line 2160
+#line 2208
{
-#line 2160
+#line 2208
int err=NC_NOERR;
-#line 2160
+#line 2208
#if SIZEOF_IX_UINT64 == SIZEOF_ULONGLONG && IX_UINT64_MAX == ULONGLONG_MAX
-#line 2160
+#line 2208
put_ix_uint64(xp, (const ix_uint64 *)ip);
-#line 2160
+#line 2208
#else
-#line 2160
+#line 2208
ix_uint64 xx = NC_FILL_UINT64;
-#line 2160
+#line 2208
-#line 2160
+#line 2208
#if IX_UINT64_MAX < ULONGLONG_MAX
-#line 2160
+#line 2208
if (*ip > IX_UINT64_MAX) {
-#line 2160
+#line 2208
-#line 2160
+#line 2208
+#ifdef ERANGE_FILL
+#line 2208
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2208
+#endif
+#line 2208
err = NC_ERANGE;
-#line 2160
- }
-#line 2160
+#line 2208
+ }
+#line 2208
+#ifdef ERANGE_FILL
+#line 2208
+ else
+#line 2208
+#endif
+#line 2208
#endif
-#line 2160
+#line 2208
xx = (ix_uint64)*ip;
-#line 2160
+#line 2208
-#line 2160
+#line 2208
put_ix_uint64(xp, &xx);
-#line 2160
+#line 2208
#endif
-#line 2160
+#line 2208
return err;
-#line 2160
+#line 2208
}
-#line 2160
+#line 2208
#endif
static int
-#line 2162
+#line 2210
ncx_put_ulonglong_schar(void *xp, const schar *ip, void *fillp)
-#line 2162
+#line 2210
{
-#line 2162
+#line 2210
int err=NC_NOERR;
-#line 2162
+#line 2210
ix_uint64 xx = NC_FILL_UINT64;
-#line 2162
+#line 2210
-#line 2162
+#line 2210
#if IX_UINT64_MAX < SCHAR_MAX
-#line 2162
+#line 2210
if (*ip > IX_UINT64_MAX) {
-#line 2162
+#line 2210
-#line 2162
+#line 2210
+#ifdef ERANGE_FILL
+#line 2210
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2210
+#endif
+#line 2210
err = NC_ERANGE;
-#line 2162
- }
-#line 2162
+#line 2210
+ }
+#line 2210
+#ifdef ERANGE_FILL
+#line 2210
+ else
+#line 2210
+#endif
+#line 2210
#endif
-#line 2162
+#line 2210
if (*ip < 0) {
-#line 2162
+#line 2210
-#line 2162
+#line 2210
+#ifdef ERANGE_FILL
+#line 2210
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2210
+#endif
+#line 2210
err = NC_ERANGE; /* because xp is unsigned */
-#line 2162
- }
-#line 2162
+#line 2210
+ }
+#line 2210
+#ifdef ERANGE_FILL
+#line 2210
+ else
+#line 2210
+#endif
+#line 2210
xx = (ix_uint64)*ip;
-#line 2162
+#line 2210
-#line 2162
+#line 2210
put_ix_uint64(xp, &xx);
-#line 2162
+#line 2210
return err;
-#line 2162
+#line 2210
}
-#line 2162
+#line 2210
static int
-#line 2163
+#line 2211
ncx_put_ulonglong_short(void *xp, const short *ip, void *fillp)
-#line 2163
+#line 2211
{
-#line 2163
+#line 2211
int err=NC_NOERR;
-#line 2163
+#line 2211
ix_uint64 xx = NC_FILL_UINT64;
-#line 2163
+#line 2211
-#line 2163
+#line 2211
#if IX_UINT64_MAX < SHORT_MAX
-#line 2163
+#line 2211
if (*ip > IX_UINT64_MAX) {
-#line 2163
+#line 2211
-#line 2163
+#line 2211
+#ifdef ERANGE_FILL
+#line 2211
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2211
+#endif
+#line 2211
err = NC_ERANGE;
-#line 2163
- }
-#line 2163
+#line 2211
+ }
+#line 2211
+#ifdef ERANGE_FILL
+#line 2211
+ else
+#line 2211
+#endif
+#line 2211
#endif
-#line 2163
+#line 2211
if (*ip < 0) {
-#line 2163
+#line 2211
-#line 2163
+#line 2211
+#ifdef ERANGE_FILL
+#line 2211
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2211
+#endif
+#line 2211
err = NC_ERANGE; /* because xp is unsigned */
-#line 2163
- }
-#line 2163
+#line 2211
+ }
+#line 2211
+#ifdef ERANGE_FILL
+#line 2211
+ else
+#line 2211
+#endif
+#line 2211
xx = (ix_uint64)*ip;
-#line 2163
+#line 2211
-#line 2163
+#line 2211
put_ix_uint64(xp, &xx);
-#line 2163
+#line 2211
return err;
-#line 2163
+#line 2211
}
-#line 2163
+#line 2211
static int
-#line 2164
+#line 2212
ncx_put_ulonglong_int(void *xp, const int *ip, void *fillp)
-#line 2164
+#line 2212
{
-#line 2164
+#line 2212
int err=NC_NOERR;
-#line 2164
+#line 2212
ix_uint64 xx = NC_FILL_UINT64;
-#line 2164
+#line 2212
-#line 2164
+#line 2212
#if IX_UINT64_MAX < INT_MAX
-#line 2164
+#line 2212
if (*ip > IX_UINT64_MAX) {
-#line 2164
+#line 2212
-#line 2164
+#line 2212
+#ifdef ERANGE_FILL
+#line 2212
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2212
+#endif
+#line 2212
err = NC_ERANGE;
-#line 2164
- }
-#line 2164
+#line 2212
+ }
+#line 2212
+#ifdef ERANGE_FILL
+#line 2212
+ else
+#line 2212
+#endif
+#line 2212
#endif
-#line 2164
+#line 2212
if (*ip < 0) {
-#line 2164
+#line 2212
-#line 2164
+#line 2212
+#ifdef ERANGE_FILL
+#line 2212
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2212
+#endif
+#line 2212
err = NC_ERANGE; /* because xp is unsigned */
-#line 2164
- }
-#line 2164
+#line 2212
+ }
+#line 2212
+#ifdef ERANGE_FILL
+#line 2212
+ else
+#line 2212
+#endif
+#line 2212
xx = (ix_uint64)*ip;
-#line 2164
+#line 2212
-#line 2164
+#line 2212
put_ix_uint64(xp, &xx);
-#line 2164
+#line 2212
return err;
-#line 2164
+#line 2212
}
-#line 2164
+#line 2212
static int
-#line 2165
+#line 2213
ncx_put_ulonglong_long(void *xp, const long *ip, void *fillp)
-#line 2165
+#line 2213
{
-#line 2165
+#line 2213
int err=NC_NOERR;
-#line 2165
+#line 2213
ix_uint64 xx = NC_FILL_UINT64;
-#line 2165
+#line 2213
-#line 2165
+#line 2213
#if IX_UINT64_MAX < LONG_MAX
-#line 2165
+#line 2213
if (*ip > IX_UINT64_MAX) {
-#line 2165
+#line 2213
-#line 2165
+#line 2213
+#ifdef ERANGE_FILL
+#line 2213
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2213
+#endif
+#line 2213
err = NC_ERANGE;
-#line 2165
- }
-#line 2165
+#line 2213
+ }
+#line 2213
+#ifdef ERANGE_FILL
+#line 2213
+ else
+#line 2213
+#endif
+#line 2213
#endif
-#line 2165
+#line 2213
if (*ip < 0) {
-#line 2165
+#line 2213
-#line 2165
+#line 2213
+#ifdef ERANGE_FILL
+#line 2213
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2213
+#endif
+#line 2213
err = NC_ERANGE; /* because xp is unsigned */
-#line 2165
- }
-#line 2165
+#line 2213
+ }
+#line 2213
+#ifdef ERANGE_FILL
+#line 2213
+ else
+#line 2213
+#endif
+#line 2213
xx = (ix_uint64)*ip;
-#line 2165
+#line 2213
-#line 2165
+#line 2213
put_ix_uint64(xp, &xx);
-#line 2165
+#line 2213
return err;
-#line 2165
+#line 2213
}
-#line 2165
+#line 2213
static int
-#line 2166
+#line 2214
ncx_put_ulonglong_longlong(void *xp, const longlong *ip, void *fillp)
-#line 2166
+#line 2214
{
-#line 2166
+#line 2214
int err=NC_NOERR;
-#line 2166
+#line 2214
ix_uint64 xx = NC_FILL_UINT64;
-#line 2166
+#line 2214
-#line 2166
+#line 2214
#if IX_UINT64_MAX < LONGLONG_MAX
-#line 2166
+#line 2214
if (*ip > IX_UINT64_MAX) {
-#line 2166
+#line 2214
-#line 2166
+#line 2214
+#ifdef ERANGE_FILL
+#line 2214
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2214
+#endif
+#line 2214
err = NC_ERANGE;
-#line 2166
- }
-#line 2166
+#line 2214
+ }
+#line 2214
+#ifdef ERANGE_FILL
+#line 2214
+ else
+#line 2214
+#endif
+#line 2214
#endif
-#line 2166
+#line 2214
if (*ip < 0) {
-#line 2166
+#line 2214
-#line 2166
+#line 2214
+#ifdef ERANGE_FILL
+#line 2214
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2214
+#endif
+#line 2214
err = NC_ERANGE; /* because xp is unsigned */
-#line 2166
- }
-#line 2166
+#line 2214
+ }
+#line 2214
+#ifdef ERANGE_FILL
+#line 2214
+ else
+#line 2214
+#endif
+#line 2214
xx = (ix_uint64)*ip;
-#line 2166
+#line 2214
-#line 2166
+#line 2214
put_ix_uint64(xp, &xx);
-#line 2166
+#line 2214
return err;
-#line 2166
+#line 2214
}
-#line 2166
+#line 2214
static int
-#line 2167
+#line 2215
ncx_put_ulonglong_uchar(void *xp, const uchar *ip, void *fillp)
-#line 2167
+#line 2215
{
-#line 2167
+#line 2215
int err=NC_NOERR;
-#line 2167
+#line 2215
#if SIZEOF_IX_UINT64 == SIZEOF_UCHAR && IX_UINT64_MAX == UCHAR_MAX
-#line 2167
+#line 2215
put_ix_uint64(xp, (const ix_uint64 *)ip);
-#line 2167
+#line 2215
#else
-#line 2167
+#line 2215
ix_uint64 xx = NC_FILL_UINT64;
-#line 2167
+#line 2215
-#line 2167
+#line 2215
#if IX_UINT64_MAX < UCHAR_MAX
-#line 2167
+#line 2215
if (*ip > IX_UINT64_MAX) {
-#line 2167
+#line 2215
-#line 2167
+#line 2215
+#ifdef ERANGE_FILL
+#line 2215
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2215
+#endif
+#line 2215
err = NC_ERANGE;
-#line 2167
- }
-#line 2167
+#line 2215
+ }
+#line 2215
+#ifdef ERANGE_FILL
+#line 2215
+ else
+#line 2215
+#endif
+#line 2215
#endif
-#line 2167
+#line 2215
xx = (ix_uint64)*ip;
-#line 2167
+#line 2215
-#line 2167
+#line 2215
put_ix_uint64(xp, &xx);
-#line 2167
+#line 2215
#endif
-#line 2167
+#line 2215
return err;
-#line 2167
+#line 2215
}
-#line 2167
+#line 2215
static int
-#line 2168
+#line 2216
ncx_put_ulonglong_ushort(void *xp, const ushort *ip, void *fillp)
-#line 2168
+#line 2216
{
-#line 2168
+#line 2216
int err=NC_NOERR;
-#line 2168
+#line 2216
#if SIZEOF_IX_UINT64 == SIZEOF_USHORT && IX_UINT64_MAX == USHORT_MAX
-#line 2168
+#line 2216
put_ix_uint64(xp, (const ix_uint64 *)ip);
-#line 2168
+#line 2216
#else
-#line 2168
+#line 2216
ix_uint64 xx = NC_FILL_UINT64;
-#line 2168
+#line 2216
-#line 2168
+#line 2216
#if IX_UINT64_MAX < USHORT_MAX
-#line 2168
+#line 2216
if (*ip > IX_UINT64_MAX) {
-#line 2168
+#line 2216
-#line 2168
+#line 2216
+#ifdef ERANGE_FILL
+#line 2216
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2216
+#endif
+#line 2216
err = NC_ERANGE;
-#line 2168
- }
-#line 2168
+#line 2216
+ }
+#line 2216
+#ifdef ERANGE_FILL
+#line 2216
+ else
+#line 2216
+#endif
+#line 2216
#endif
-#line 2168
+#line 2216
xx = (ix_uint64)*ip;
-#line 2168
+#line 2216
-#line 2168
+#line 2216
put_ix_uint64(xp, &xx);
-#line 2168
+#line 2216
#endif
-#line 2168
+#line 2216
return err;
-#line 2168
+#line 2216
}
-#line 2168
+#line 2216
static int
-#line 2169
+#line 2217
ncx_put_ulonglong_uint(void *xp, const uint *ip, void *fillp)
-#line 2169
+#line 2217
{
-#line 2169
+#line 2217
int err=NC_NOERR;
-#line 2169
+#line 2217
#if SIZEOF_IX_UINT64 == SIZEOF_UINT && IX_UINT64_MAX == UINT_MAX
-#line 2169
+#line 2217
put_ix_uint64(xp, (const ix_uint64 *)ip);
-#line 2169
+#line 2217
#else
-#line 2169
+#line 2217
ix_uint64 xx = NC_FILL_UINT64;
-#line 2169
+#line 2217
-#line 2169
+#line 2217
#if IX_UINT64_MAX < UINT_MAX
-#line 2169
+#line 2217
if (*ip > IX_UINT64_MAX) {
-#line 2169
+#line 2217
-#line 2169
+#line 2217
+#ifdef ERANGE_FILL
+#line 2217
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2217
+#endif
+#line 2217
err = NC_ERANGE;
-#line 2169
- }
-#line 2169
+#line 2217
+ }
+#line 2217
+#ifdef ERANGE_FILL
+#line 2217
+ else
+#line 2217
+#endif
+#line 2217
#endif
-#line 2169
+#line 2217
xx = (ix_uint64)*ip;
-#line 2169
+#line 2217
-#line 2169
+#line 2217
put_ix_uint64(xp, &xx);
-#line 2169
+#line 2217
#endif
-#line 2169
+#line 2217
return err;
-#line 2169
+#line 2217
}
-#line 2169
+#line 2217
static int
-#line 2170
+#line 2218
ncx_put_ulonglong_float(void *xp, const float *ip, void *fillp)
-#line 2170
+#line 2218
{
-#line 2170
+#line 2218
int err=NC_NOERR;
-#line 2170
+#line 2218
ix_uint64 xx = NC_FILL_UINT64;
-#line 2170
+#line 2218
-#line 2170
+#line 2218
if (*ip > (double)X_UINT64_MAX || *ip < 0) {
-#line 2170
+#line 2218
-#line 2170
+#line 2218
+#ifdef ERANGE_FILL
+#line 2218
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2218
+#endif
+#line 2218
err = NC_ERANGE;
-#line 2170
- }
-#line 2170
+#line 2218
+ }
+#line 2218
+#ifdef ERANGE_FILL
+#line 2218
+ else
+#line 2218
+#endif
+#line 2218
xx = (ix_uint64)*ip;
-#line 2170
+#line 2218
-#line 2170
+#line 2218
put_ix_uint64(xp, &xx);
-#line 2170
+#line 2218
return err;
-#line 2170
+#line 2218
}
-#line 2170
+#line 2218
static int
-#line 2171
+#line 2219
ncx_put_ulonglong_double(void *xp, const double *ip, void *fillp)
-#line 2171
+#line 2219
{
-#line 2171
+#line 2219
int err=NC_NOERR;
-#line 2171
+#line 2219
ix_uint64 xx = NC_FILL_UINT64;
-#line 2171
+#line 2219
-#line 2171
+#line 2219
if (*ip > X_UINT64_MAX || *ip < 0) {
-#line 2171
+#line 2219
-#line 2171
+#line 2219
+#ifdef ERANGE_FILL
+#line 2219
+ if (fillp != NULL) memcpy(&xx, fillp, 8);
+#line 2219
+#endif
+#line 2219
err = NC_ERANGE;
-#line 2171
- }
-#line 2171
+#line 2219
+ }
+#line 2219
+#ifdef ERANGE_FILL
+#line 2219
+ else
+#line 2219
+#endif
+#line 2219
xx = (ix_uint64)*ip;
-#line 2171
+#line 2219
-#line 2171
+#line 2219
put_ix_uint64(xp, &xx);
-#line 2171
+#line 2219
return err;
-#line 2171
+#line 2219
}
-#line 2171
+#line 2219
@@ -8050,1767 +9563,2087 @@ ncx_put_uint64(void **xpp, const unsigned long long ip)
/*
* Aggregate numeric conversion functions.
*/
-#line 2427
+#line 2475
-#line 2826
+#line 2878
-#line 2832
+#line 2884
/* schar ---------------------------------------------------------------------*/
-#line 2836
+#line 2888
int
ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
{
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 2839
+#line 2891
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2839
+#line 2891
return NC_NOERR;
-#line 2839
+#line 2891
}
int
-#line 2841
+#line 2893
ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2841
+#line 2893
{
-#line 2841
+#line 2893
int status = NC_NOERR;
-#line 2841
+#line 2893
schar *xp = (schar *)(*xpp);
-#line 2841
+#line 2893
-#line 2841
+#line 2893
while (nelems-- != 0) {
-#line 2841
+#line 2893
-#line 2841
+#line 2893
if (*xp < 0) {
-#line 2841
-
-#line 2841
+#line 2893
+#ifdef ERANGE_FILL
+#line 2893
+ *tp = NC_FILL_UBYTE;
+#line 2893
+#endif
+#line 2893
status = NC_ERANGE; /* because tp is unsigned */
-#line 2841
+#line 2893
-#line 2841
+#line 2893
+#ifdef ERANGE_FILL
+#line 2893
+ xp++; tp++; continue;
+#line 2893
+#endif
+#line 2893
}
-#line 2841
+#line 2893
*tp++ = (uchar) (signed) (*xp++); /* type cast from schar to uchar */
-#line 2841
+#line 2893
}
-#line 2841
+#line 2893
-#line 2841
+#line 2893
*xpp = (const void *)xp;
-#line 2841
+#line 2893
return status;
-#line 2841
+#line 2893
}
-#line 2841
+#line 2893
int
-#line 2842
+#line 2894
ncx_getn_schar_short(const void **xpp, size_t nelems, short *tp)
-#line 2842
+#line 2894
{
-#line 2842
+#line 2894
int status = NC_NOERR;
-#line 2842
+#line 2894
schar *xp = (schar *)(*xpp);
-#line 2842
+#line 2894
-#line 2842
+#line 2894
while (nelems-- != 0) {
-#line 2842
+#line 2894
-#line 2842
+#line 2894
*tp++ = (short) (*xp++); /* type cast from schar to short */
-#line 2842
+#line 2894
}
-#line 2842
+#line 2894
-#line 2842
+#line 2894
*xpp = (const void *)xp;
-#line 2842
+#line 2894
return status;
-#line 2842
+#line 2894
}
-#line 2842
+#line 2894
int
-#line 2843
+#line 2895
ncx_getn_schar_int(const void **xpp, size_t nelems, int *tp)
-#line 2843
+#line 2895
{
-#line 2843
+#line 2895
int status = NC_NOERR;
-#line 2843
+#line 2895
schar *xp = (schar *)(*xpp);
-#line 2843
+#line 2895
-#line 2843
+#line 2895
while (nelems-- != 0) {
-#line 2843
+#line 2895
-#line 2843
+#line 2895
*tp++ = (int) (*xp++); /* type cast from schar to int */
-#line 2843
+#line 2895
}
-#line 2843
+#line 2895
-#line 2843
+#line 2895
*xpp = (const void *)xp;
-#line 2843
+#line 2895
return status;
-#line 2843
+#line 2895
}
-#line 2843
+#line 2895
int
-#line 2844
+#line 2896
ncx_getn_schar_long(const void **xpp, size_t nelems, long *tp)
-#line 2844
+#line 2896
{
-#line 2844
+#line 2896
int status = NC_NOERR;
-#line 2844
+#line 2896
schar *xp = (schar *)(*xpp);
-#line 2844
+#line 2896
-#line 2844
+#line 2896
while (nelems-- != 0) {
-#line 2844
+#line 2896
-#line 2844
+#line 2896
*tp++ = (long) (*xp++); /* type cast from schar to long */
-#line 2844
+#line 2896
}
-#line 2844
+#line 2896
-#line 2844
+#line 2896
*xpp = (const void *)xp;
-#line 2844
+#line 2896
return status;
-#line 2844
+#line 2896
}
-#line 2844
+#line 2896
int
-#line 2845
+#line 2897
ncx_getn_schar_float(const void **xpp, size_t nelems, float *tp)
-#line 2845
+#line 2897
{
-#line 2845
+#line 2897
int status = NC_NOERR;
-#line 2845
+#line 2897
schar *xp = (schar *)(*xpp);
-#line 2845
+#line 2897
-#line 2845
+#line 2897
while (nelems-- != 0) {
-#line 2845
+#line 2897
-#line 2845
+#line 2897
*tp++ = (float) (*xp++); /* type cast from schar to float */
-#line 2845
+#line 2897
}
-#line 2845
+#line 2897
-#line 2845
+#line 2897
*xpp = (const void *)xp;
-#line 2845
+#line 2897
return status;
-#line 2845
+#line 2897
}
-#line 2845
+#line 2897
int
-#line 2846
+#line 2898
ncx_getn_schar_double(const void **xpp, size_t nelems, double *tp)
-#line 2846
+#line 2898
{
-#line 2846
+#line 2898
int status = NC_NOERR;
-#line 2846
+#line 2898
schar *xp = (schar *)(*xpp);
-#line 2846
+#line 2898
-#line 2846
+#line 2898
while (nelems-- != 0) {
-#line 2846
+#line 2898
-#line 2846
+#line 2898
*tp++ = (double) (*xp++); /* type cast from schar to double */
-#line 2846
+#line 2898
}
-#line 2846
+#line 2898
-#line 2846
+#line 2898
*xpp = (const void *)xp;
-#line 2846
+#line 2898
return status;
-#line 2846
+#line 2898
}
-#line 2846
+#line 2898
int
-#line 2847
+#line 2899
ncx_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2847
+#line 2899
{
-#line 2847
+#line 2899
int status = NC_NOERR;
-#line 2847
+#line 2899
schar *xp = (schar *)(*xpp);
-#line 2847
+#line 2899
-#line 2847
+#line 2899
while (nelems-- != 0) {
-#line 2847
+#line 2899
-#line 2847
+#line 2899
*tp++ = (longlong) (*xp++); /* type cast from schar to longlong */
-#line 2847
+#line 2899
}
-#line 2847
+#line 2899
-#line 2847
+#line 2899
*xpp = (const void *)xp;
-#line 2847
+#line 2899
return status;
-#line 2847
+#line 2899
}
-#line 2847
+#line 2899
int
-#line 2848
+#line 2900
ncx_getn_schar_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 2848
+#line 2900
{
-#line 2848
+#line 2900
int status = NC_NOERR;
-#line 2848
+#line 2900
schar *xp = (schar *)(*xpp);
-#line 2848
+#line 2900
-#line 2848
+#line 2900
while (nelems-- != 0) {
-#line 2848
+#line 2900
-#line 2848
+#line 2900
if (*xp < 0) {
-#line 2848
-
-#line 2848
+#line 2900
+#ifdef ERANGE_FILL
+#line 2900
+ *tp = NC_FILL_USHORT;
+#line 2900
+#endif
+#line 2900
status = NC_ERANGE; /* because tp is unsigned */
-#line 2848
+#line 2900
-#line 2848
+#line 2900
+#ifdef ERANGE_FILL
+#line 2900
+ xp++; tp++; continue;
+#line 2900
+#endif
+#line 2900
}
-#line 2848
+#line 2900
*tp++ = (ushort) (signed) (*xp++); /* type cast from schar to ushort */
-#line 2848
+#line 2900
}
-#line 2848
+#line 2900
-#line 2848
+#line 2900
*xpp = (const void *)xp;
-#line 2848
+#line 2900
return status;
-#line 2848
+#line 2900
}
-#line 2848
+#line 2900
int
-#line 2849
+#line 2901
ncx_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2849
+#line 2901
{
-#line 2849
+#line 2901
int status = NC_NOERR;
-#line 2849
+#line 2901
schar *xp = (schar *)(*xpp);
-#line 2849
+#line 2901
-#line 2849
+#line 2901
while (nelems-- != 0) {
-#line 2849
+#line 2901
-#line 2849
+#line 2901
if (*xp < 0) {
-#line 2849
-
-#line 2849
+#line 2901
+#ifdef ERANGE_FILL
+#line 2901
+ *tp = NC_FILL_UINT;
+#line 2901
+#endif
+#line 2901
status = NC_ERANGE; /* because tp is unsigned */
-#line 2849
+#line 2901
-#line 2849
+#line 2901
+#ifdef ERANGE_FILL
+#line 2901
+ xp++; tp++; continue;
+#line 2901
+#endif
+#line 2901
}
-#line 2849
+#line 2901
*tp++ = (uint) (signed) (*xp++); /* type cast from schar to uint */
-#line 2849
+#line 2901
}
-#line 2849
+#line 2901
-#line 2849
+#line 2901
*xpp = (const void *)xp;
-#line 2849
+#line 2901
return status;
-#line 2849
+#line 2901
}
-#line 2849
+#line 2901
int
-#line 2850
+#line 2902
ncx_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2850
+#line 2902
{
-#line 2850
+#line 2902
int status = NC_NOERR;
-#line 2850
+#line 2902
schar *xp = (schar *)(*xpp);
-#line 2850
+#line 2902
-#line 2850
+#line 2902
while (nelems-- != 0) {
-#line 2850
+#line 2902
-#line 2850
+#line 2902
if (*xp < 0) {
-#line 2850
-
-#line 2850
+#line 2902
+#ifdef ERANGE_FILL
+#line 2902
+ *tp = NC_FILL_UINT64;
+#line 2902
+#endif
+#line 2902
status = NC_ERANGE; /* because tp is unsigned */
-#line 2850
+#line 2902
-#line 2850
+#line 2902
+#ifdef ERANGE_FILL
+#line 2902
+ xp++; tp++; continue;
+#line 2902
+#endif
+#line 2902
}
-#line 2850
+#line 2902
*tp++ = (ulonglong) (signed) (*xp++); /* type cast from schar to ulonglong */
-#line 2850
+#line 2902
}
-#line 2850
+#line 2902
-#line 2850
+#line 2902
*xpp = (const void *)xp;
-#line 2850
+#line 2902
return status;
-#line 2850
+#line 2902
}
-#line 2850
+#line 2902
-#line 2853
+#line 2905
int
ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
{
size_t rndup = nelems % X_ALIGN;
-#line 2856
+#line 2908
-#line 2856
+#line 2908
if (rndup)
-#line 2856
+#line 2908
rndup = X_ALIGN - rndup;
-#line 2856
+#line 2908
-#line 2856
+#line 2908
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 2856
+#line 2908
*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 2856
+#line 2908
-#line 2856
+#line 2908
return NC_NOERR;
-#line 2856
+#line 2908
}
int
-#line 2858
+#line 2910
ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2858
+#line 2910
{
-#line 2858
+#line 2910
int status = NC_NOERR;
-#line 2858
+#line 2910
size_t rndup = nelems % X_ALIGN;
-#line 2858
+#line 2910
schar *xp = (schar *) *xpp;
-#line 2858
+#line 2910
-#line 2858
+#line 2910
if (rndup)
-#line 2858
+#line 2910
rndup = X_ALIGN - rndup;
-#line 2858
+#line 2910
-#line 2858
+#line 2910
while (nelems-- != 0) {
-#line 2858
+#line 2910
-#line 2858
+#line 2910
if (*xp < 0) {
-#line 2858
-
-#line 2858
+#line 2910
+#ifdef ERANGE_FILL
+#line 2910
+ *tp = NC_FILL_UBYTE;
+#line 2910
+#endif
+#line 2910
status = NC_ERANGE; /* because tp is unsigned */
-#line 2858
+#line 2910
-#line 2858
+#line 2910
+#ifdef ERANGE_FILL
+#line 2910
+ xp++; tp++; continue;
+#line 2910
+#endif
+#line 2910
}
-#line 2858
+#line 2910
*tp++ = (uchar) (signed) (*xp++); /* type cast from schar to uchar */
-#line 2858
+#line 2910
}
-#line 2858
+#line 2910
-#line 2858
+#line 2910
*xpp = (void *)(xp + rndup);
-#line 2858
+#line 2910
return status;
-#line 2858
+#line 2910
}
-#line 2858
+#line 2910
int
-#line 2859
+#line 2911
ncx_pad_getn_schar_short(const void **xpp, size_t nelems, short *tp)
-#line 2859
+#line 2911
{
-#line 2859
+#line 2911
int status = NC_NOERR;
-#line 2859
+#line 2911
size_t rndup = nelems % X_ALIGN;
-#line 2859
+#line 2911
schar *xp = (schar *) *xpp;
-#line 2859
+#line 2911
-#line 2859
+#line 2911
if (rndup)
-#line 2859
+#line 2911
rndup = X_ALIGN - rndup;
-#line 2859
+#line 2911
-#line 2859
+#line 2911
while (nelems-- != 0) {
-#line 2859
+#line 2911
-#line 2859
+#line 2911
*tp++ = (short) (*xp++); /* type cast from schar to short */
-#line 2859
+#line 2911
}
-#line 2859
+#line 2911
-#line 2859
+#line 2911
*xpp = (void *)(xp + rndup);
-#line 2859
+#line 2911
return status;
-#line 2859
+#line 2911
}
-#line 2859
+#line 2911
int
-#line 2860
+#line 2912
ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp)
-#line 2860
+#line 2912
{
-#line 2860
+#line 2912
int status = NC_NOERR;
-#line 2860
+#line 2912
size_t rndup = nelems % X_ALIGN;
-#line 2860
+#line 2912
schar *xp = (schar *) *xpp;
-#line 2860
+#line 2912
-#line 2860
+#line 2912
if (rndup)
-#line 2860
+#line 2912
rndup = X_ALIGN - rndup;
-#line 2860
+#line 2912
-#line 2860
+#line 2912
while (nelems-- != 0) {
-#line 2860
+#line 2912
-#line 2860
+#line 2912
*tp++ = (int) (*xp++); /* type cast from schar to int */
-#line 2860
+#line 2912
}
-#line 2860
+#line 2912
-#line 2860
+#line 2912
*xpp = (void *)(xp + rndup);
-#line 2860
+#line 2912
return status;
-#line 2860
+#line 2912
}
-#line 2860
+#line 2912
int
-#line 2861
+#line 2913
ncx_pad_getn_schar_long(const void **xpp, size_t nelems, long *tp)
-#line 2861
+#line 2913
{
-#line 2861
+#line 2913
int status = NC_NOERR;
-#line 2861
+#line 2913
size_t rndup = nelems % X_ALIGN;
-#line 2861
+#line 2913
schar *xp = (schar *) *xpp;
-#line 2861
+#line 2913
-#line 2861
+#line 2913
if (rndup)
-#line 2861
+#line 2913
rndup = X_ALIGN - rndup;
-#line 2861
+#line 2913
-#line 2861
+#line 2913
while (nelems-- != 0) {
-#line 2861
+#line 2913
-#line 2861
+#line 2913
*tp++ = (long) (*xp++); /* type cast from schar to long */
-#line 2861
+#line 2913
}
-#line 2861
+#line 2913
-#line 2861
+#line 2913
*xpp = (void *)(xp + rndup);
-#line 2861
+#line 2913
return status;
-#line 2861
+#line 2913
}
-#line 2861
+#line 2913
int
-#line 2862
+#line 2914
ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp)
-#line 2862
+#line 2914
{
-#line 2862
+#line 2914
int status = NC_NOERR;
-#line 2862
+#line 2914
size_t rndup = nelems % X_ALIGN;
-#line 2862
+#line 2914
schar *xp = (schar *) *xpp;
-#line 2862
+#line 2914
-#line 2862
+#line 2914
if (rndup)
-#line 2862
+#line 2914
rndup = X_ALIGN - rndup;
-#line 2862
+#line 2914
-#line 2862
+#line 2914
while (nelems-- != 0) {
-#line 2862
+#line 2914
-#line 2862
+#line 2914
*tp++ = (float) (*xp++); /* type cast from schar to float */
-#line 2862
+#line 2914
}
-#line 2862
+#line 2914
-#line 2862
+#line 2914
*xpp = (void *)(xp + rndup);
-#line 2862
+#line 2914
return status;
-#line 2862
+#line 2914
}
-#line 2862
+#line 2914
int
-#line 2863
+#line 2915
ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp)
-#line 2863
+#line 2915
{
-#line 2863
+#line 2915
int status = NC_NOERR;
-#line 2863
+#line 2915
size_t rndup = nelems % X_ALIGN;
-#line 2863
+#line 2915
schar *xp = (schar *) *xpp;
-#line 2863
+#line 2915
-#line 2863
+#line 2915
if (rndup)
-#line 2863
+#line 2915
rndup = X_ALIGN - rndup;
-#line 2863
+#line 2915
-#line 2863
+#line 2915
while (nelems-- != 0) {
-#line 2863
+#line 2915
-#line 2863
+#line 2915
*tp++ = (double) (*xp++); /* type cast from schar to double */
-#line 2863
+#line 2915
}
-#line 2863
+#line 2915
-#line 2863
+#line 2915
*xpp = (void *)(xp + rndup);
-#line 2863
+#line 2915
return status;
-#line 2863
+#line 2915
}
-#line 2863
+#line 2915
int
-#line 2864
+#line 2916
ncx_pad_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2864
+#line 2916
{
-#line 2864
+#line 2916
int status = NC_NOERR;
-#line 2864
+#line 2916
size_t rndup = nelems % X_ALIGN;
-#line 2864
+#line 2916
schar *xp = (schar *) *xpp;
-#line 2864
+#line 2916
-#line 2864
+#line 2916
if (rndup)
-#line 2864
+#line 2916
rndup = X_ALIGN - rndup;
-#line 2864
+#line 2916
-#line 2864
+#line 2916
while (nelems-- != 0) {
-#line 2864
+#line 2916
-#line 2864
+#line 2916
*tp++ = (longlong) (*xp++); /* type cast from schar to longlong */
-#line 2864
+#line 2916
}
-#line 2864
+#line 2916
-#line 2864
+#line 2916
*xpp = (void *)(xp + rndup);
-#line 2864
+#line 2916
return status;
-#line 2864
+#line 2916
}
-#line 2864
+#line 2916
int
-#line 2865
+#line 2917
ncx_pad_getn_schar_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 2865
+#line 2917
{
-#line 2865
+#line 2917
int status = NC_NOERR;
-#line 2865
+#line 2917
size_t rndup = nelems % X_ALIGN;
-#line 2865
+#line 2917
schar *xp = (schar *) *xpp;
-#line 2865
+#line 2917
-#line 2865
+#line 2917
if (rndup)
-#line 2865
+#line 2917
rndup = X_ALIGN - rndup;
-#line 2865
+#line 2917
-#line 2865
+#line 2917
while (nelems-- != 0) {
-#line 2865
+#line 2917
-#line 2865
+#line 2917
if (*xp < 0) {
-#line 2865
-
-#line 2865
+#line 2917
+#ifdef ERANGE_FILL
+#line 2917
+ *tp = NC_FILL_USHORT;
+#line 2917
+#endif
+#line 2917
status = NC_ERANGE; /* because tp is unsigned */
-#line 2865
+#line 2917
-#line 2865
+#line 2917
+#ifdef ERANGE_FILL
+#line 2917
+ xp++; tp++; continue;
+#line 2917
+#endif
+#line 2917
}
-#line 2865
+#line 2917
*tp++ = (ushort) (signed) (*xp++); /* type cast from schar to ushort */
-#line 2865
+#line 2917
}
-#line 2865
+#line 2917
-#line 2865
+#line 2917
*xpp = (void *)(xp + rndup);
-#line 2865
+#line 2917
return status;
-#line 2865
+#line 2917
}
-#line 2865
+#line 2917
int
-#line 2866
+#line 2918
ncx_pad_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2866
+#line 2918
{
-#line 2866
+#line 2918
int status = NC_NOERR;
-#line 2866
+#line 2918
size_t rndup = nelems % X_ALIGN;
-#line 2866
+#line 2918
schar *xp = (schar *) *xpp;
-#line 2866
+#line 2918
-#line 2866
+#line 2918
if (rndup)
-#line 2866
+#line 2918
rndup = X_ALIGN - rndup;
-#line 2866
+#line 2918
-#line 2866
+#line 2918
while (nelems-- != 0) {
-#line 2866
+#line 2918
-#line 2866
+#line 2918
if (*xp < 0) {
-#line 2866
-
-#line 2866
+#line 2918
+#ifdef ERANGE_FILL
+#line 2918
+ *tp = NC_FILL_UINT;
+#line 2918
+#endif
+#line 2918
status = NC_ERANGE; /* because tp is unsigned */
-#line 2866
+#line 2918
-#line 2866
+#line 2918
+#ifdef ERANGE_FILL
+#line 2918
+ xp++; tp++; continue;
+#line 2918
+#endif
+#line 2918
}
-#line 2866
+#line 2918
*tp++ = (uint) (signed) (*xp++); /* type cast from schar to uint */
-#line 2866
+#line 2918
}
-#line 2866
+#line 2918
-#line 2866
+#line 2918
*xpp = (void *)(xp + rndup);
-#line 2866
+#line 2918
return status;
-#line 2866
+#line 2918
}
-#line 2866
+#line 2918
int
-#line 2867
+#line 2919
ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2867
+#line 2919
{
-#line 2867
+#line 2919
int status = NC_NOERR;
-#line 2867
+#line 2919
size_t rndup = nelems % X_ALIGN;
-#line 2867
+#line 2919
schar *xp = (schar *) *xpp;
-#line 2867
+#line 2919
-#line 2867
+#line 2919
if (rndup)
-#line 2867
+#line 2919
rndup = X_ALIGN - rndup;
-#line 2867
+#line 2919
-#line 2867
+#line 2919
while (nelems-- != 0) {
-#line 2867
+#line 2919
-#line 2867
+#line 2919
if (*xp < 0) {
-#line 2867
-
-#line 2867
+#line 2919
+#ifdef ERANGE_FILL
+#line 2919
+ *tp = NC_FILL_UINT64;
+#line 2919
+#endif
+#line 2919
status = NC_ERANGE; /* because tp is unsigned */
-#line 2867
+#line 2919
-#line 2867
+#line 2919
+#ifdef ERANGE_FILL
+#line 2919
+ xp++; tp++; continue;
+#line 2919
+#endif
+#line 2919
}
-#line 2867
+#line 2919
*tp++ = (ulonglong) (signed) (*xp++); /* type cast from schar to ulonglong */
-#line 2867
+#line 2919
}
-#line 2867
+#line 2919
-#line 2867
+#line 2919
*xpp = (void *)(xp + rndup);
-#line 2867
+#line 2919
return status;
-#line 2867
+#line 2919
}
-#line 2867
+#line 2919
-#line 2870
+#line 2922
int
ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
{
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 2873
+#line 2925
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2873
+#line 2925
-#line 2873
+#line 2925
return NC_NOERR;
-#line 2873
+#line 2925
}
int
-#line 2875
+#line 2927
ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 2875
+#line 2927
{
-#line 2875
+#line 2927
int status = NC_NOERR;
-#line 2875
+#line 2927
schar *xp = (schar *) *xpp;
-#line 2875
+#line 2927
-#line 2875
+#line 2927
while (nelems-- != 0) {
-#line 2875
+#line 2927
if (*tp > (uchar)X_SCHAR_MAX ) {
-#line 2875
+#line 2927
-#line 2875
+#line 2927
+#ifdef ERANGE_FILL
+#line 2927
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2927
+#endif
+#line 2927
status = NC_ERANGE;
-#line 2875
+#line 2927
-#line 2875
+#line 2927
+#ifdef ERANGE_FILL
+#line 2927
+ xp++; tp++; continue;
+#line 2927
+#endif
+#line 2927
}
-#line 2875
+#line 2927
*xp++ = (schar) *tp++; /* type cast from uchar to schar */
-#line 2875
+#line 2927
}
-#line 2875
+#line 2927
-#line 2875
+#line 2927
*xpp = (void *)xp;
-#line 2875
+#line 2927
return status;
-#line 2875
+#line 2927
}
-#line 2875
+#line 2927
int
-#line 2876
+#line 2928
ncx_putn_schar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 2876
+#line 2928
{
-#line 2876
+#line 2928
int status = NC_NOERR;
-#line 2876
+#line 2928
schar *xp = (schar *) *xpp;
-#line 2876
+#line 2928
-#line 2876
+#line 2928
while (nelems-- != 0) {
-#line 2876
+#line 2928
if (*tp > (short)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2876
+#line 2928
-#line 2876
+#line 2928
+#ifdef ERANGE_FILL
+#line 2928
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2928
+#endif
+#line 2928
status = NC_ERANGE;
-#line 2876
+#line 2928
-#line 2876
+#line 2928
+#ifdef ERANGE_FILL
+#line 2928
+ xp++; tp++; continue;
+#line 2928
+#endif
+#line 2928
}
-#line 2876
+#line 2928
*xp++ = (schar) *tp++; /* type cast from short to schar */
-#line 2876
+#line 2928
}
-#line 2876
+#line 2928
-#line 2876
+#line 2928
*xpp = (void *)xp;
-#line 2876
+#line 2928
return status;
-#line 2876
+#line 2928
}
-#line 2876
+#line 2928
int
-#line 2877
+#line 2929
ncx_putn_schar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 2877
+#line 2929
{
-#line 2877
+#line 2929
int status = NC_NOERR;
-#line 2877
+#line 2929
schar *xp = (schar *) *xpp;
-#line 2877
+#line 2929
-#line 2877
+#line 2929
while (nelems-- != 0) {
-#line 2877
+#line 2929
if (*tp > (int)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2877
+#line 2929
-#line 2877
+#line 2929
+#ifdef ERANGE_FILL
+#line 2929
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2929
+#endif
+#line 2929
status = NC_ERANGE;
-#line 2877
+#line 2929
-#line 2877
+#line 2929
+#ifdef ERANGE_FILL
+#line 2929
+ xp++; tp++; continue;
+#line 2929
+#endif
+#line 2929
}
-#line 2877
+#line 2929
*xp++ = (schar) *tp++; /* type cast from int to schar */
-#line 2877
+#line 2929
}
-#line 2877
+#line 2929
-#line 2877
+#line 2929
*xpp = (void *)xp;
-#line 2877
+#line 2929
return status;
-#line 2877
+#line 2929
}
-#line 2877
+#line 2929
int
-#line 2878
+#line 2930
ncx_putn_schar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 2878
+#line 2930
{
-#line 2878
+#line 2930
int status = NC_NOERR;
-#line 2878
+#line 2930
schar *xp = (schar *) *xpp;
-#line 2878
+#line 2930
-#line 2878
+#line 2930
while (nelems-- != 0) {
-#line 2878
+#line 2930
if (*tp > (long)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2878
+#line 2930
-#line 2878
+#line 2930
+#ifdef ERANGE_FILL
+#line 2930
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2930
+#endif
+#line 2930
status = NC_ERANGE;
-#line 2878
+#line 2930
-#line 2878
+#line 2930
+#ifdef ERANGE_FILL
+#line 2930
+ xp++; tp++; continue;
+#line 2930
+#endif
+#line 2930
}
-#line 2878
+#line 2930
*xp++ = (schar) *tp++; /* type cast from long to schar */
-#line 2878
+#line 2930
}
-#line 2878
+#line 2930
-#line 2878
+#line 2930
*xpp = (void *)xp;
-#line 2878
+#line 2930
return status;
-#line 2878
+#line 2930
}
-#line 2878
+#line 2930
int
-#line 2879
+#line 2931
ncx_putn_schar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 2879
+#line 2931
{
-#line 2879
+#line 2931
int status = NC_NOERR;
-#line 2879
+#line 2931
schar *xp = (schar *) *xpp;
-#line 2879
+#line 2931
-#line 2879
+#line 2931
while (nelems-- != 0) {
-#line 2879
+#line 2931
if (*tp > (float)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2879
+#line 2931
-#line 2879
+#line 2931
+#ifdef ERANGE_FILL
+#line 2931
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2931
+#endif
+#line 2931
status = NC_ERANGE;
-#line 2879
+#line 2931
-#line 2879
+#line 2931
+#ifdef ERANGE_FILL
+#line 2931
+ xp++; tp++; continue;
+#line 2931
+#endif
+#line 2931
}
-#line 2879
+#line 2931
*xp++ = (schar) *tp++; /* type cast from float to schar */
-#line 2879
+#line 2931
}
-#line 2879
+#line 2931
-#line 2879
+#line 2931
*xpp = (void *)xp;
-#line 2879
+#line 2931
return status;
-#line 2879
+#line 2931
}
-#line 2879
+#line 2931
int
-#line 2880
+#line 2932
ncx_putn_schar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 2880
+#line 2932
{
-#line 2880
+#line 2932
int status = NC_NOERR;
-#line 2880
+#line 2932
schar *xp = (schar *) *xpp;
-#line 2880
+#line 2932
-#line 2880
+#line 2932
while (nelems-- != 0) {
-#line 2880
+#line 2932
if (*tp > (double)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2880
+#line 2932
-#line 2880
+#line 2932
+#ifdef ERANGE_FILL
+#line 2932
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2932
+#endif
+#line 2932
status = NC_ERANGE;
-#line 2880
+#line 2932
-#line 2880
+#line 2932
+#ifdef ERANGE_FILL
+#line 2932
+ xp++; tp++; continue;
+#line 2932
+#endif
+#line 2932
}
-#line 2880
+#line 2932
*xp++ = (schar) *tp++; /* type cast from double to schar */
-#line 2880
+#line 2932
}
-#line 2880
+#line 2932
-#line 2880
+#line 2932
*xpp = (void *)xp;
-#line 2880
+#line 2932
return status;
-#line 2880
+#line 2932
}
-#line 2880
+#line 2932
int
-#line 2881
+#line 2933
ncx_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 2881
+#line 2933
{
-#line 2881
+#line 2933
int status = NC_NOERR;
-#line 2881
+#line 2933
schar *xp = (schar *) *xpp;
-#line 2881
+#line 2933
-#line 2881
+#line 2933
while (nelems-- != 0) {
-#line 2881
+#line 2933
if (*tp > (longlong)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2881
+#line 2933
-#line 2881
+#line 2933
+#ifdef ERANGE_FILL
+#line 2933
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2933
+#endif
+#line 2933
status = NC_ERANGE;
-#line 2881
+#line 2933
-#line 2881
+#line 2933
+#ifdef ERANGE_FILL
+#line 2933
+ xp++; tp++; continue;
+#line 2933
+#endif
+#line 2933
}
-#line 2881
+#line 2933
*xp++ = (schar) *tp++; /* type cast from longlong to schar */
-#line 2881
+#line 2933
}
-#line 2881
+#line 2933
-#line 2881
+#line 2933
*xpp = (void *)xp;
-#line 2881
+#line 2933
return status;
-#line 2881
+#line 2933
}
-#line 2881
+#line 2933
int
-#line 2882
+#line 2934
ncx_putn_schar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 2882
+#line 2934
{
-#line 2882
+#line 2934
int status = NC_NOERR;
-#line 2882
+#line 2934
schar *xp = (schar *) *xpp;
-#line 2882
+#line 2934
-#line 2882
+#line 2934
while (nelems-- != 0) {
-#line 2882
+#line 2934
if (*tp > (ushort)X_SCHAR_MAX ) {
-#line 2882
+#line 2934
-#line 2882
+#line 2934
+#ifdef ERANGE_FILL
+#line 2934
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2934
+#endif
+#line 2934
status = NC_ERANGE;
-#line 2882
+#line 2934
-#line 2882
+#line 2934
+#ifdef ERANGE_FILL
+#line 2934
+ xp++; tp++; continue;
+#line 2934
+#endif
+#line 2934
}
-#line 2882
+#line 2934
*xp++ = (schar) *tp++; /* type cast from ushort to schar */
-#line 2882
+#line 2934
}
-#line 2882
+#line 2934
-#line 2882
+#line 2934
*xpp = (void *)xp;
-#line 2882
+#line 2934
return status;
-#line 2882
+#line 2934
}
-#line 2882
+#line 2934
int
-#line 2883
+#line 2935
ncx_putn_schar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 2883
+#line 2935
{
-#line 2883
+#line 2935
int status = NC_NOERR;
-#line 2883
+#line 2935
schar *xp = (schar *) *xpp;
-#line 2883
+#line 2935
-#line 2883
+#line 2935
while (nelems-- != 0) {
-#line 2883
+#line 2935
if (*tp > (uint)X_SCHAR_MAX ) {
-#line 2883
+#line 2935
-#line 2883
+#line 2935
+#ifdef ERANGE_FILL
+#line 2935
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2935
+#endif
+#line 2935
status = NC_ERANGE;
-#line 2883
+#line 2935
-#line 2883
+#line 2935
+#ifdef ERANGE_FILL
+#line 2935
+ xp++; tp++; continue;
+#line 2935
+#endif
+#line 2935
}
-#line 2883
+#line 2935
*xp++ = (schar) *tp++; /* type cast from uint to schar */
-#line 2883
+#line 2935
}
-#line 2883
+#line 2935
-#line 2883
+#line 2935
*xpp = (void *)xp;
-#line 2883
+#line 2935
return status;
-#line 2883
+#line 2935
}
-#line 2883
+#line 2935
int
-#line 2884
+#line 2936
ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 2884
+#line 2936
{
-#line 2884
+#line 2936
int status = NC_NOERR;
-#line 2884
+#line 2936
schar *xp = (schar *) *xpp;
-#line 2884
+#line 2936
-#line 2884
+#line 2936
while (nelems-- != 0) {
-#line 2884
+#line 2936
if (*tp > (ulonglong)X_SCHAR_MAX ) {
-#line 2884
+#line 2936
-#line 2884
+#line 2936
+#ifdef ERANGE_FILL
+#line 2936
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2936
+#endif
+#line 2936
status = NC_ERANGE;
-#line 2884
+#line 2936
-#line 2884
- }
-#line 2884
- *xp++ = (schar) *tp++; /* type cast from ulonglong to schar */
-#line 2884
+#line 2936
+#ifdef ERANGE_FILL
+#line 2936
+ xp++; tp++; continue;
+#line 2936
+#endif
+#line 2936
+ }
+#line 2936
+ *xp++ = (schar) *tp++; /* type cast from ulonglong to schar */
+#line 2936
}
-#line 2884
+#line 2936
-#line 2884
+#line 2936
*xpp = (void *)xp;
-#line 2884
+#line 2936
return status;
-#line 2884
+#line 2936
}
-#line 2884
+#line 2936
-#line 2887
+#line 2939
int
ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
{
size_t rndup = nelems % X_ALIGN;
-#line 2890
+#line 2942
-#line 2890
+#line 2942
if (rndup)
-#line 2890
+#line 2942
rndup = X_ALIGN - rndup;
-#line 2890
+#line 2942
-#line 2890
+#line 2942
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 2890
+#line 2942
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2890
+#line 2942
-#line 2890
+#line 2942
if (rndup)
-#line 2890
+#line 2942
{
-#line 2890
+#line 2942
(void) memcpy(*xpp, nada, (size_t)rndup);
-#line 2890
+#line 2942
*xpp = (void *)((char *)(*xpp) + rndup);
-#line 2890
+#line 2942
}
-#line 2890
+#line 2942
-#line 2890
+#line 2942
return NC_NOERR;
-#line 2890
+#line 2942
}
int
-#line 2892
+#line 2944
ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 2892
+#line 2944
{
-#line 2892
+#line 2944
int status = NC_NOERR;
-#line 2892
+#line 2944
size_t rndup = nelems % X_ALIGN;
-#line 2892
+#line 2944
schar *xp = (schar *) *xpp;
-#line 2892
+#line 2944
-#line 2892
+#line 2944
if (rndup) rndup = X_ALIGN - rndup;
-#line 2892
+#line 2944
-#line 2892
+#line 2944
while (nelems-- != 0) {
-#line 2892
+#line 2944
if (*tp > (uchar)X_SCHAR_MAX ) {
-#line 2892
+#line 2944
-#line 2892
+#line 2944
+#ifdef ERANGE_FILL
+#line 2944
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2944
+#endif
+#line 2944
status = NC_ERANGE;
-#line 2892
+#line 2944
-#line 2892
+#line 2944
+#ifdef ERANGE_FILL
+#line 2944
+ xp++; tp++; continue;
+#line 2944
+#endif
+#line 2944
}
-#line 2892
+#line 2944
*xp++ = (schar) *tp++; /* type cast from uchar to schar */
-#line 2892
+#line 2944
}
-#line 2892
+#line 2944
-#line 2892
+#line 2944
-#line 2892
+#line 2944
if (rndup) {
-#line 2892
+#line 2944
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2892
+#line 2944
xp += rndup;
-#line 2892
+#line 2944
}
-#line 2892
+#line 2944
-#line 2892
+#line 2944
*xpp = (void *)xp;
-#line 2892
+#line 2944
return status;
-#line 2892
+#line 2944
}
-#line 2892
+#line 2944
int
-#line 2893
+#line 2945
ncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 2893
+#line 2945
{
-#line 2893
+#line 2945
int status = NC_NOERR;
-#line 2893
+#line 2945
size_t rndup = nelems % X_ALIGN;
-#line 2893
+#line 2945
schar *xp = (schar *) *xpp;
-#line 2893
+#line 2945
-#line 2893
+#line 2945
if (rndup) rndup = X_ALIGN - rndup;
-#line 2893
+#line 2945
-#line 2893
+#line 2945
while (nelems-- != 0) {
-#line 2893
+#line 2945
if (*tp > (short)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2893
+#line 2945
-#line 2893
+#line 2945
+#ifdef ERANGE_FILL
+#line 2945
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2945
+#endif
+#line 2945
status = NC_ERANGE;
-#line 2893
+#line 2945
-#line 2893
+#line 2945
+#ifdef ERANGE_FILL
+#line 2945
+ xp++; tp++; continue;
+#line 2945
+#endif
+#line 2945
}
-#line 2893
+#line 2945
*xp++ = (schar) *tp++; /* type cast from short to schar */
-#line 2893
+#line 2945
}
-#line 2893
+#line 2945
-#line 2893
+#line 2945
-#line 2893
+#line 2945
if (rndup) {
-#line 2893
+#line 2945
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2893
+#line 2945
xp += rndup;
-#line 2893
+#line 2945
}
-#line 2893
+#line 2945
-#line 2893
+#line 2945
*xpp = (void *)xp;
-#line 2893
+#line 2945
return status;
-#line 2893
+#line 2945
}
-#line 2893
+#line 2945
int
-#line 2894
+#line 2946
ncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 2894
+#line 2946
{
-#line 2894
+#line 2946
int status = NC_NOERR;
-#line 2894
+#line 2946
size_t rndup = nelems % X_ALIGN;
-#line 2894
+#line 2946
schar *xp = (schar *) *xpp;
-#line 2894
+#line 2946
-#line 2894
+#line 2946
if (rndup) rndup = X_ALIGN - rndup;
-#line 2894
+#line 2946
-#line 2894
+#line 2946
while (nelems-- != 0) {
-#line 2894
+#line 2946
if (*tp > (int)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2894
+#line 2946
-#line 2894
+#line 2946
+#ifdef ERANGE_FILL
+#line 2946
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2946
+#endif
+#line 2946
status = NC_ERANGE;
-#line 2894
+#line 2946
-#line 2894
+#line 2946
+#ifdef ERANGE_FILL
+#line 2946
+ xp++; tp++; continue;
+#line 2946
+#endif
+#line 2946
}
-#line 2894
+#line 2946
*xp++ = (schar) *tp++; /* type cast from int to schar */
-#line 2894
+#line 2946
}
-#line 2894
+#line 2946
-#line 2894
+#line 2946
-#line 2894
+#line 2946
if (rndup) {
-#line 2894
+#line 2946
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2894
+#line 2946
xp += rndup;
-#line 2894
+#line 2946
}
-#line 2894
+#line 2946
-#line 2894
+#line 2946
*xpp = (void *)xp;
-#line 2894
+#line 2946
return status;
-#line 2894
+#line 2946
}
-#line 2894
+#line 2946
int
-#line 2895
+#line 2947
ncx_pad_putn_schar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 2895
+#line 2947
{
-#line 2895
+#line 2947
int status = NC_NOERR;
-#line 2895
+#line 2947
size_t rndup = nelems % X_ALIGN;
-#line 2895
+#line 2947
schar *xp = (schar *) *xpp;
-#line 2895
+#line 2947
-#line 2895
+#line 2947
if (rndup) rndup = X_ALIGN - rndup;
-#line 2895
+#line 2947
-#line 2895
+#line 2947
while (nelems-- != 0) {
-#line 2895
+#line 2947
if (*tp > (long)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2895
+#line 2947
-#line 2895
+#line 2947
+#ifdef ERANGE_FILL
+#line 2947
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2947
+#endif
+#line 2947
status = NC_ERANGE;
-#line 2895
+#line 2947
-#line 2895
+#line 2947
+#ifdef ERANGE_FILL
+#line 2947
+ xp++; tp++; continue;
+#line 2947
+#endif
+#line 2947
}
-#line 2895
+#line 2947
*xp++ = (schar) *tp++; /* type cast from long to schar */
-#line 2895
+#line 2947
}
-#line 2895
+#line 2947
-#line 2895
+#line 2947
-#line 2895
+#line 2947
if (rndup) {
-#line 2895
+#line 2947
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2895
+#line 2947
xp += rndup;
-#line 2895
+#line 2947
}
-#line 2895
+#line 2947
-#line 2895
+#line 2947
*xpp = (void *)xp;
-#line 2895
+#line 2947
return status;
-#line 2895
+#line 2947
}
-#line 2895
+#line 2947
int
-#line 2896
+#line 2948
ncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 2896
+#line 2948
{
-#line 2896
+#line 2948
int status = NC_NOERR;
-#line 2896
+#line 2948
size_t rndup = nelems % X_ALIGN;
-#line 2896
+#line 2948
schar *xp = (schar *) *xpp;
-#line 2896
+#line 2948
-#line 2896
+#line 2948
if (rndup) rndup = X_ALIGN - rndup;
-#line 2896
+#line 2948
-#line 2896
+#line 2948
while (nelems-- != 0) {
-#line 2896
+#line 2948
if (*tp > (float)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2896
+#line 2948
-#line 2896
+#line 2948
+#ifdef ERANGE_FILL
+#line 2948
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2948
+#endif
+#line 2948
status = NC_ERANGE;
-#line 2896
+#line 2948
-#line 2896
+#line 2948
+#ifdef ERANGE_FILL
+#line 2948
+ xp++; tp++; continue;
+#line 2948
+#endif
+#line 2948
}
-#line 2896
+#line 2948
*xp++ = (schar) *tp++; /* type cast from float to schar */
-#line 2896
+#line 2948
}
-#line 2896
+#line 2948
-#line 2896
+#line 2948
-#line 2896
+#line 2948
if (rndup) {
-#line 2896
+#line 2948
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2896
+#line 2948
xp += rndup;
-#line 2896
+#line 2948
}
-#line 2896
+#line 2948
-#line 2896
+#line 2948
*xpp = (void *)xp;
-#line 2896
+#line 2948
return status;
-#line 2896
+#line 2948
}
-#line 2896
+#line 2948
int
-#line 2897
+#line 2949
ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 2897
+#line 2949
{
-#line 2897
+#line 2949
int status = NC_NOERR;
-#line 2897
+#line 2949
size_t rndup = nelems % X_ALIGN;
-#line 2897
+#line 2949
schar *xp = (schar *) *xpp;
-#line 2897
+#line 2949
-#line 2897
+#line 2949
if (rndup) rndup = X_ALIGN - rndup;
-#line 2897
+#line 2949
-#line 2897
+#line 2949
while (nelems-- != 0) {
-#line 2897
+#line 2949
if (*tp > (double)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2897
+#line 2949
-#line 2897
+#line 2949
+#ifdef ERANGE_FILL
+#line 2949
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2949
+#endif
+#line 2949
status = NC_ERANGE;
-#line 2897
+#line 2949
-#line 2897
+#line 2949
+#ifdef ERANGE_FILL
+#line 2949
+ xp++; tp++; continue;
+#line 2949
+#endif
+#line 2949
}
-#line 2897
+#line 2949
*xp++ = (schar) *tp++; /* type cast from double to schar */
-#line 2897
+#line 2949
}
-#line 2897
+#line 2949
-#line 2897
+#line 2949
-#line 2897
+#line 2949
if (rndup) {
-#line 2897
+#line 2949
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2897
+#line 2949
xp += rndup;
-#line 2897
+#line 2949
}
-#line 2897
+#line 2949
-#line 2897
+#line 2949
*xpp = (void *)xp;
-#line 2897
+#line 2949
return status;
-#line 2897
+#line 2949
}
-#line 2897
+#line 2949
int
-#line 2898
+#line 2950
ncx_pad_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 2898
+#line 2950
{
-#line 2898
+#line 2950
int status = NC_NOERR;
-#line 2898
+#line 2950
size_t rndup = nelems % X_ALIGN;
-#line 2898
+#line 2950
schar *xp = (schar *) *xpp;
-#line 2898
+#line 2950
-#line 2898
+#line 2950
if (rndup) rndup = X_ALIGN - rndup;
-#line 2898
+#line 2950
-#line 2898
+#line 2950
while (nelems-- != 0) {
-#line 2898
+#line 2950
if (*tp > (longlong)X_SCHAR_MAX || *tp < X_SCHAR_MIN) {
-#line 2898
+#line 2950
-#line 2898
+#line 2950
+#ifdef ERANGE_FILL
+#line 2950
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2950
+#endif
+#line 2950
status = NC_ERANGE;
-#line 2898
+#line 2950
-#line 2898
+#line 2950
+#ifdef ERANGE_FILL
+#line 2950
+ xp++; tp++; continue;
+#line 2950
+#endif
+#line 2950
}
-#line 2898
+#line 2950
*xp++ = (schar) *tp++; /* type cast from longlong to schar */
-#line 2898
+#line 2950
}
-#line 2898
+#line 2950
-#line 2898
+#line 2950
-#line 2898
+#line 2950
if (rndup) {
-#line 2898
+#line 2950
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2898
+#line 2950
xp += rndup;
-#line 2898
+#line 2950
}
-#line 2898
+#line 2950
-#line 2898
+#line 2950
*xpp = (void *)xp;
-#line 2898
+#line 2950
return status;
-#line 2898
+#line 2950
}
-#line 2898
+#line 2950
int
-#line 2899
+#line 2951
ncx_pad_putn_schar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 2899
+#line 2951
{
-#line 2899
+#line 2951
int status = NC_NOERR;
-#line 2899
+#line 2951
size_t rndup = nelems % X_ALIGN;
-#line 2899
+#line 2951
schar *xp = (schar *) *xpp;
-#line 2899
+#line 2951
-#line 2899
+#line 2951
if (rndup) rndup = X_ALIGN - rndup;
-#line 2899
+#line 2951
-#line 2899
+#line 2951
while (nelems-- != 0) {
-#line 2899
+#line 2951
if (*tp > (ushort)X_SCHAR_MAX ) {
-#line 2899
+#line 2951
-#line 2899
+#line 2951
+#ifdef ERANGE_FILL
+#line 2951
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2951
+#endif
+#line 2951
status = NC_ERANGE;
-#line 2899
+#line 2951
-#line 2899
+#line 2951
+#ifdef ERANGE_FILL
+#line 2951
+ xp++; tp++; continue;
+#line 2951
+#endif
+#line 2951
}
-#line 2899
+#line 2951
*xp++ = (schar) *tp++; /* type cast from ushort to schar */
-#line 2899
+#line 2951
}
-#line 2899
+#line 2951
-#line 2899
+#line 2951
-#line 2899
+#line 2951
if (rndup) {
-#line 2899
+#line 2951
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2899
+#line 2951
xp += rndup;
-#line 2899
+#line 2951
}
-#line 2899
+#line 2951
-#line 2899
+#line 2951
*xpp = (void *)xp;
-#line 2899
+#line 2951
return status;
-#line 2899
+#line 2951
}
-#line 2899
+#line 2951
int
-#line 2900
+#line 2952
ncx_pad_putn_schar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 2900
+#line 2952
{
-#line 2900
+#line 2952
int status = NC_NOERR;
-#line 2900
+#line 2952
size_t rndup = nelems % X_ALIGN;
-#line 2900
+#line 2952
schar *xp = (schar *) *xpp;
-#line 2900
+#line 2952
-#line 2900
+#line 2952
if (rndup) rndup = X_ALIGN - rndup;
-#line 2900
+#line 2952
-#line 2900
+#line 2952
while (nelems-- != 0) {
-#line 2900
+#line 2952
if (*tp > (uint)X_SCHAR_MAX ) {
-#line 2900
+#line 2952
-#line 2900
+#line 2952
+#ifdef ERANGE_FILL
+#line 2952
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2952
+#endif
+#line 2952
status = NC_ERANGE;
-#line 2900
+#line 2952
-#line 2900
+#line 2952
+#ifdef ERANGE_FILL
+#line 2952
+ xp++; tp++; continue;
+#line 2952
+#endif
+#line 2952
}
-#line 2900
+#line 2952
*xp++ = (schar) *tp++; /* type cast from uint to schar */
-#line 2900
+#line 2952
}
-#line 2900
+#line 2952
-#line 2900
+#line 2952
-#line 2900
+#line 2952
if (rndup) {
-#line 2900
+#line 2952
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2900
+#line 2952
xp += rndup;
-#line 2900
+#line 2952
}
-#line 2900
+#line 2952
-#line 2900
+#line 2952
*xpp = (void *)xp;
-#line 2900
+#line 2952
return status;
-#line 2900
+#line 2952
}
-#line 2900
+#line 2952
int
-#line 2901
+#line 2953
ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 2901
+#line 2953
{
-#line 2901
+#line 2953
int status = NC_NOERR;
-#line 2901
+#line 2953
size_t rndup = nelems % X_ALIGN;
-#line 2901
+#line 2953
schar *xp = (schar *) *xpp;
-#line 2901
+#line 2953
-#line 2901
+#line 2953
if (rndup) rndup = X_ALIGN - rndup;
-#line 2901
+#line 2953
-#line 2901
+#line 2953
while (nelems-- != 0) {
-#line 2901
+#line 2953
if (*tp > (ulonglong)X_SCHAR_MAX ) {
-#line 2901
+#line 2953
-#line 2901
+#line 2953
+#ifdef ERANGE_FILL
+#line 2953
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 2953
+#endif
+#line 2953
status = NC_ERANGE;
-#line 2901
+#line 2953
-#line 2901
+#line 2953
+#ifdef ERANGE_FILL
+#line 2953
+ xp++; tp++; continue;
+#line 2953
+#endif
+#line 2953
}
-#line 2901
+#line 2953
*xp++ = (schar) *tp++; /* type cast from ulonglong to schar */
-#line 2901
+#line 2953
}
-#line 2901
+#line 2953
-#line 2901
+#line 2953
-#line 2901
+#line 2953
if (rndup) {
-#line 2901
+#line 2953
(void) memcpy(xp, nada, (size_t)rndup);
-#line 2901
+#line 2953
xp += rndup;
-#line 2901
+#line 2953
}
-#line 2901
+#line 2953
-#line 2901
+#line 2953
*xpp = (void *)xp;
-#line 2901
+#line 2953
return status;
-#line 2901
+#line 2953
}
-#line 2901
+#line 2953
/* uchar ---------------------------------------------------------------------*/
-#line 2907
+#line 2959
int
ncx_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
{
@@ -9822,6 +11655,12 @@ ncx_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
*tp = NC_FILL_BYTE;
status = NC_ERANGE;
+#line 2969
+#ifdef ERANGE_FILL
+#line 2969
+ xp++; tp++; continue;
+#line 2969
+#endif
}
*tp++ = (schar) *xp++; /* type cast from uchar to schar */
}
@@ -9829,281 +11668,281 @@ ncx_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
*xpp = (const void *)xp;
return status;
}
-#line 2926
+#line 2978
int
ncx_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
{
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 2929
+#line 2981
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2929
+#line 2981
return NC_NOERR;
-#line 2929
+#line 2981
}
int
-#line 2931
+#line 2983
ncx_getn_uchar_short(const void **xpp, size_t nelems, short *tp)
-#line 2931
+#line 2983
{
-#line 2931
+#line 2983
int status = NC_NOERR;
-#line 2931
+#line 2983
uchar *xp = (uchar *)(*xpp);
-#line 2931
+#line 2983
-#line 2931
+#line 2983
while (nelems-- != 0) {
-#line 2931
+#line 2983
-#line 2931
+#line 2983
*tp++ = (short) (*xp++); /* type cast from uchar to short */
-#line 2931
+#line 2983
}
-#line 2931
+#line 2983
-#line 2931
+#line 2983
*xpp = (const void *)xp;
-#line 2931
+#line 2983
return status;
-#line 2931
+#line 2983
}
-#line 2931
+#line 2983
int
-#line 2932
+#line 2984
ncx_getn_uchar_int(const void **xpp, size_t nelems, int *tp)
-#line 2932
+#line 2984
{
-#line 2932
+#line 2984
int status = NC_NOERR;
-#line 2932
+#line 2984
uchar *xp = (uchar *)(*xpp);
-#line 2932
+#line 2984
-#line 2932
+#line 2984
while (nelems-- != 0) {
-#line 2932
+#line 2984
-#line 2932
+#line 2984
*tp++ = (int) (*xp++); /* type cast from uchar to int */
-#line 2932
+#line 2984
}
-#line 2932
+#line 2984
-#line 2932
+#line 2984
*xpp = (const void *)xp;
-#line 2932
+#line 2984
return status;
-#line 2932
+#line 2984
}
-#line 2932
+#line 2984
int
-#line 2933
+#line 2985
ncx_getn_uchar_long(const void **xpp, size_t nelems, long *tp)
-#line 2933
+#line 2985
{
-#line 2933
+#line 2985
int status = NC_NOERR;
-#line 2933
+#line 2985
uchar *xp = (uchar *)(*xpp);
-#line 2933
+#line 2985
-#line 2933
+#line 2985
while (nelems-- != 0) {
-#line 2933
+#line 2985
-#line 2933
+#line 2985
*tp++ = (long) (*xp++); /* type cast from uchar to long */
-#line 2933
+#line 2985
}
-#line 2933
+#line 2985
-#line 2933
+#line 2985
*xpp = (const void *)xp;
-#line 2933
+#line 2985
return status;
-#line 2933
+#line 2985
}
-#line 2933
+#line 2985
int
-#line 2934
+#line 2986
ncx_getn_uchar_float(const void **xpp, size_t nelems, float *tp)
-#line 2934
+#line 2986
{
-#line 2934
+#line 2986
int status = NC_NOERR;
-#line 2934
+#line 2986
uchar *xp = (uchar *)(*xpp);
-#line 2934
+#line 2986
-#line 2934
+#line 2986
while (nelems-- != 0) {
-#line 2934
+#line 2986
-#line 2934
+#line 2986
*tp++ = (float) (*xp++); /* type cast from uchar to float */
-#line 2934
+#line 2986
}
-#line 2934
+#line 2986
-#line 2934
+#line 2986
*xpp = (const void *)xp;
-#line 2934
+#line 2986
return status;
-#line 2934
+#line 2986
}
-#line 2934
+#line 2986
int
-#line 2935
+#line 2987
ncx_getn_uchar_double(const void **xpp, size_t nelems, double *tp)
-#line 2935
+#line 2987
{
-#line 2935
+#line 2987
int status = NC_NOERR;
-#line 2935
+#line 2987
uchar *xp = (uchar *)(*xpp);
-#line 2935
+#line 2987
-#line 2935
+#line 2987
while (nelems-- != 0) {
-#line 2935
+#line 2987
-#line 2935
+#line 2987
*tp++ = (double) (*xp++); /* type cast from uchar to double */
-#line 2935
+#line 2987
}
-#line 2935
+#line 2987
-#line 2935
+#line 2987
*xpp = (const void *)xp;
-#line 2935
+#line 2987
return status;
-#line 2935
+#line 2987
}
-#line 2935
+#line 2987
int
-#line 2936
+#line 2988
ncx_getn_uchar_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2936
+#line 2988
{
-#line 2936
+#line 2988
int status = NC_NOERR;
-#line 2936
+#line 2988
uchar *xp = (uchar *)(*xpp);
-#line 2936
+#line 2988
-#line 2936
+#line 2988
while (nelems-- != 0) {
-#line 2936
+#line 2988
-#line 2936
+#line 2988
*tp++ = (longlong) (*xp++); /* type cast from uchar to longlong */
-#line 2936
+#line 2988
}
-#line 2936
+#line 2988
-#line 2936
+#line 2988
*xpp = (const void *)xp;
-#line 2936
+#line 2988
return status;
-#line 2936
+#line 2988
}
-#line 2936
+#line 2988
int
-#line 2937
+#line 2989
ncx_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 2937
+#line 2989
{
-#line 2937
+#line 2989
int status = NC_NOERR;
-#line 2937
+#line 2989
uchar *xp = (uchar *)(*xpp);
-#line 2937
+#line 2989
-#line 2937
+#line 2989
while (nelems-- != 0) {
-#line 2937
+#line 2989
-#line 2937
+#line 2989
*tp++ = (ushort) (*xp++); /* type cast from uchar to ushort */
-#line 2937
+#line 2989
}
-#line 2937
+#line 2989
-#line 2937
+#line 2989
*xpp = (const void *)xp;
-#line 2937
+#line 2989
return status;
-#line 2937
+#line 2989
}
-#line 2937
+#line 2989
int
-#line 2938
+#line 2990
ncx_getn_uchar_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2938
+#line 2990
{
-#line 2938
+#line 2990
int status = NC_NOERR;
-#line 2938
+#line 2990
uchar *xp = (uchar *)(*xpp);
-#line 2938
+#line 2990
-#line 2938
+#line 2990
while (nelems-- != 0) {
-#line 2938
+#line 2990
-#line 2938
+#line 2990
*tp++ = (uint) (*xp++); /* type cast from uchar to uint */
-#line 2938
+#line 2990
}
-#line 2938
+#line 2990
-#line 2938
+#line 2990
*xpp = (const void *)xp;
-#line 2938
+#line 2990
return status;
-#line 2938
+#line 2990
}
-#line 2938
+#line 2990
int
-#line 2939
+#line 2991
ncx_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2939
+#line 2991
{
-#line 2939
+#line 2991
int status = NC_NOERR;
-#line 2939
+#line 2991
uchar *xp = (uchar *)(*xpp);
-#line 2939
+#line 2991
-#line 2939
+#line 2991
while (nelems-- != 0) {
-#line 2939
+#line 2991
-#line 2939
+#line 2991
*tp++ = (ulonglong) (*xp++); /* type cast from uchar to ulonglong */
-#line 2939
+#line 2991
}
-#line 2939
+#line 2991
-#line 2939
+#line 2991
*xpp = (const void *)xp;
-#line 2939
+#line 2991
return status;
-#line 2939
+#line 2991
}
-#line 2939
+#line 2991
-#line 2942
+#line 2994
int
ncx_pad_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
{
@@ -10118,6 +11957,12 @@ ncx_pad_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
*tp = NC_FILL_BYTE;
status = NC_ERANGE;
+#line 3007
+#ifdef ERANGE_FILL
+#line 3007
+ xp++; tp++; continue;
+#line 3007
+#endif
}
*tp++ = (schar) *xp++; /* type cast from uchar to schar */
}
@@ -10125,365 +11970,365 @@ ncx_pad_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
*xpp = (void *)(xp + rndup);
return status;
}
-#line 2964
+#line 3016
int
ncx_pad_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
{
size_t rndup = nelems % X_ALIGN;
-#line 2967
+#line 3019
-#line 2967
+#line 3019
if (rndup)
-#line 2967
+#line 3019
rndup = X_ALIGN - rndup;
-#line 2967
+#line 3019
-#line 2967
+#line 3019
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 2967
+#line 3019
*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 2967
+#line 3019
-#line 2967
+#line 3019
return NC_NOERR;
-#line 2967
+#line 3019
}
int
-#line 2969
+#line 3021
ncx_pad_getn_uchar_short(const void **xpp, size_t nelems, short *tp)
-#line 2969
+#line 3021
{
-#line 2969
+#line 3021
int status = NC_NOERR;
-#line 2969
+#line 3021
size_t rndup = nelems % X_ALIGN;
-#line 2969
+#line 3021
uchar *xp = (uchar *) *xpp;
-#line 2969
+#line 3021
-#line 2969
+#line 3021
if (rndup)
-#line 2969
+#line 3021
rndup = X_ALIGN - rndup;
-#line 2969
+#line 3021
-#line 2969
+#line 3021
while (nelems-- != 0) {
-#line 2969
+#line 3021
-#line 2969
+#line 3021
*tp++ = (short) (*xp++); /* type cast from uchar to short */
-#line 2969
+#line 3021
}
-#line 2969
+#line 3021
-#line 2969
+#line 3021
*xpp = (void *)(xp + rndup);
-#line 2969
+#line 3021
return status;
-#line 2969
+#line 3021
}
-#line 2969
+#line 3021
int
-#line 2970
+#line 3022
ncx_pad_getn_uchar_int(const void **xpp, size_t nelems, int *tp)
-#line 2970
+#line 3022
{
-#line 2970
+#line 3022
int status = NC_NOERR;
-#line 2970
+#line 3022
size_t rndup = nelems % X_ALIGN;
-#line 2970
+#line 3022
uchar *xp = (uchar *) *xpp;
-#line 2970
+#line 3022
-#line 2970
+#line 3022
if (rndup)
-#line 2970
+#line 3022
rndup = X_ALIGN - rndup;
-#line 2970
+#line 3022
-#line 2970
+#line 3022
while (nelems-- != 0) {
-#line 2970
+#line 3022
-#line 2970
+#line 3022
*tp++ = (int) (*xp++); /* type cast from uchar to int */
-#line 2970
+#line 3022
}
-#line 2970
+#line 3022
-#line 2970
+#line 3022
*xpp = (void *)(xp + rndup);
-#line 2970
+#line 3022
return status;
-#line 2970
+#line 3022
}
-#line 2970
+#line 3022
int
-#line 2971
+#line 3023
ncx_pad_getn_uchar_long(const void **xpp, size_t nelems, long *tp)
-#line 2971
+#line 3023
{
-#line 2971
+#line 3023
int status = NC_NOERR;
-#line 2971
+#line 3023
size_t rndup = nelems % X_ALIGN;
-#line 2971
+#line 3023
uchar *xp = (uchar *) *xpp;
-#line 2971
+#line 3023
-#line 2971
+#line 3023
if (rndup)
-#line 2971
+#line 3023
rndup = X_ALIGN - rndup;
-#line 2971
+#line 3023
-#line 2971
+#line 3023
while (nelems-- != 0) {
-#line 2971
+#line 3023
-#line 2971
+#line 3023
*tp++ = (long) (*xp++); /* type cast from uchar to long */
-#line 2971
+#line 3023
}
-#line 2971
+#line 3023
-#line 2971
+#line 3023
*xpp = (void *)(xp + rndup);
-#line 2971
+#line 3023
return status;
-#line 2971
+#line 3023
}
-#line 2971
+#line 3023
int
-#line 2972
+#line 3024
ncx_pad_getn_uchar_float(const void **xpp, size_t nelems, float *tp)
-#line 2972
+#line 3024
{
-#line 2972
+#line 3024
int status = NC_NOERR;
-#line 2972
+#line 3024
size_t rndup = nelems % X_ALIGN;
-#line 2972
+#line 3024
uchar *xp = (uchar *) *xpp;
-#line 2972
+#line 3024
-#line 2972
+#line 3024
if (rndup)
-#line 2972
+#line 3024
rndup = X_ALIGN - rndup;
-#line 2972
+#line 3024
-#line 2972
+#line 3024
while (nelems-- != 0) {
-#line 2972
+#line 3024
-#line 2972
+#line 3024
*tp++ = (float) (*xp++); /* type cast from uchar to float */
-#line 2972
+#line 3024
}
-#line 2972
+#line 3024
-#line 2972
+#line 3024
*xpp = (void *)(xp + rndup);
-#line 2972
+#line 3024
return status;
-#line 2972
+#line 3024
}
-#line 2972
+#line 3024
int
-#line 2973
+#line 3025
ncx_pad_getn_uchar_double(const void **xpp, size_t nelems, double *tp)
-#line 2973
+#line 3025
{
-#line 2973
+#line 3025
int status = NC_NOERR;
-#line 2973
+#line 3025
size_t rndup = nelems % X_ALIGN;
-#line 2973
+#line 3025
uchar *xp = (uchar *) *xpp;
-#line 2973
+#line 3025
-#line 2973
+#line 3025
if (rndup)
-#line 2973
+#line 3025
rndup = X_ALIGN - rndup;
-#line 2973
+#line 3025
-#line 2973
+#line 3025
while (nelems-- != 0) {
-#line 2973
+#line 3025
-#line 2973
+#line 3025
*tp++ = (double) (*xp++); /* type cast from uchar to double */
-#line 2973
+#line 3025
}
-#line 2973
+#line 3025
-#line 2973
+#line 3025
*xpp = (void *)(xp + rndup);
-#line 2973
+#line 3025
return status;
-#line 2973
+#line 3025
}
-#line 2973
+#line 3025
int
-#line 2974
+#line 3026
ncx_pad_getn_uchar_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2974
+#line 3026
{
-#line 2974
+#line 3026
int status = NC_NOERR;
-#line 2974
+#line 3026
size_t rndup = nelems % X_ALIGN;
-#line 2974
+#line 3026
uchar *xp = (uchar *) *xpp;
-#line 2974
+#line 3026
-#line 2974
+#line 3026
if (rndup)
-#line 2974
+#line 3026
rndup = X_ALIGN - rndup;
-#line 2974
+#line 3026
-#line 2974
+#line 3026
while (nelems-- != 0) {
-#line 2974
+#line 3026
-#line 2974
+#line 3026
*tp++ = (longlong) (*xp++); /* type cast from uchar to longlong */
-#line 2974
+#line 3026
}
-#line 2974
+#line 3026
-#line 2974
+#line 3026
*xpp = (void *)(xp + rndup);
-#line 2974
+#line 3026
return status;
-#line 2974
+#line 3026
}
-#line 2974
+#line 3026
int
-#line 2975
+#line 3027
ncx_pad_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 2975
+#line 3027
{
-#line 2975
+#line 3027
int status = NC_NOERR;
-#line 2975
+#line 3027
size_t rndup = nelems % X_ALIGN;
-#line 2975
+#line 3027
uchar *xp = (uchar *) *xpp;
-#line 2975
+#line 3027
-#line 2975
+#line 3027
if (rndup)
-#line 2975
+#line 3027
rndup = X_ALIGN - rndup;
-#line 2975
+#line 3027
-#line 2975
+#line 3027
while (nelems-- != 0) {
-#line 2975
+#line 3027
-#line 2975
+#line 3027
*tp++ = (ushort) (*xp++); /* type cast from uchar to ushort */
-#line 2975
+#line 3027
}
-#line 2975
+#line 3027
-#line 2975
+#line 3027
*xpp = (void *)(xp + rndup);
-#line 2975
+#line 3027
return status;
-#line 2975
+#line 3027
}
-#line 2975
+#line 3027
int
-#line 2976
+#line 3028
ncx_pad_getn_uchar_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2976
+#line 3028
{
-#line 2976
+#line 3028
int status = NC_NOERR;
-#line 2976
+#line 3028
size_t rndup = nelems % X_ALIGN;
-#line 2976
+#line 3028
uchar *xp = (uchar *) *xpp;
-#line 2976
+#line 3028
-#line 2976
+#line 3028
if (rndup)
-#line 2976
+#line 3028
rndup = X_ALIGN - rndup;
-#line 2976
+#line 3028
-#line 2976
+#line 3028
while (nelems-- != 0) {
-#line 2976
+#line 3028
-#line 2976
+#line 3028
*tp++ = (uint) (*xp++); /* type cast from uchar to uint */
-#line 2976
+#line 3028
}
-#line 2976
+#line 3028
-#line 2976
+#line 3028
*xpp = (void *)(xp + rndup);
-#line 2976
+#line 3028
return status;
-#line 2976
+#line 3028
}
-#line 2976
+#line 3028
int
-#line 2977
+#line 3029
ncx_pad_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2977
+#line 3029
{
-#line 2977
+#line 3029
int status = NC_NOERR;
-#line 2977
+#line 3029
size_t rndup = nelems % X_ALIGN;
-#line 2977
+#line 3029
uchar *xp = (uchar *) *xpp;
-#line 2977
+#line 3029
-#line 2977
+#line 3029
if (rndup)
-#line 2977
+#line 3029
rndup = X_ALIGN - rndup;
-#line 2977
+#line 3029
-#line 2977
+#line 3029
while (nelems-- != 0) {
-#line 2977
+#line 3029
-#line 2977
+#line 3029
*tp++ = (ulonglong) (*xp++); /* type cast from uchar to ulonglong */
-#line 2977
+#line 3029
}
-#line 2977
+#line 3029
-#line 2977
+#line 3029
*xpp = (void *)(xp + rndup);
-#line 2977
+#line 3029
return status;
-#line 2977
+#line 3029
}
-#line 2977
+#line 3029
-#line 2980
+#line 3032
int
ncx_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
{
@@ -10493,8 +12338,20 @@ ncx_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
while (nelems-- != 0) {
if (*tp < 0) {
+#line 3040
+#ifdef ERANGE_FILL
+#line 3040
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3040
+#endif
status = NC_ERANGE;
+#line 3042
+#ifdef ERANGE_FILL
+#line 3042
+ xp++; tp++; continue;
+#line 3042
+#endif
}
*xp++ = (uchar) (signed) *tp++; /* type cast from schar to uchar */
}
@@ -10502,355 +12359,463 @@ ncx_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
*xpp = (void *)xp;
return status;
}
-#line 2999
+#line 3051
int
ncx_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
{
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 3002
+#line 3054
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3002
+#line 3054
-#line 3002
+#line 3054
return NC_NOERR;
-#line 3002
+#line 3054
}
int
-#line 3004
+#line 3056
ncx_putn_uchar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3004
+#line 3056
{
-#line 3004
+#line 3056
int status = NC_NOERR;
-#line 3004
+#line 3056
uchar *xp = (uchar *) *xpp;
-#line 3004
+#line 3056
-#line 3004
+#line 3056
while (nelems-- != 0) {
-#line 3004
+#line 3056
if (*tp > (short)X_UCHAR_MAX || *tp < 0) {
-#line 3004
+#line 3056
-#line 3004
+#line 3056
+#ifdef ERANGE_FILL
+#line 3056
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3056
+#endif
+#line 3056
status = NC_ERANGE;
-#line 3004
+#line 3056
-#line 3004
+#line 3056
+#ifdef ERANGE_FILL
+#line 3056
+ xp++; tp++; continue;
+#line 3056
+#endif
+#line 3056
}
-#line 3004
+#line 3056
*xp++ = (uchar) (signed) *tp++; /* type cast from short to uchar */
-#line 3004
+#line 3056
}
-#line 3004
+#line 3056
-#line 3004
+#line 3056
*xpp = (void *)xp;
-#line 3004
+#line 3056
return status;
-#line 3004
+#line 3056
}
-#line 3004
+#line 3056
int
-#line 3005
+#line 3057
ncx_putn_uchar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3005
+#line 3057
{
-#line 3005
+#line 3057
int status = NC_NOERR;
-#line 3005
+#line 3057
uchar *xp = (uchar *) *xpp;
-#line 3005
+#line 3057
-#line 3005
+#line 3057
while (nelems-- != 0) {
-#line 3005
+#line 3057
if (*tp > (int)X_UCHAR_MAX || *tp < 0) {
-#line 3005
+#line 3057
-#line 3005
+#line 3057
+#ifdef ERANGE_FILL
+#line 3057
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3057
+#endif
+#line 3057
status = NC_ERANGE;
-#line 3005
+#line 3057
-#line 3005
+#line 3057
+#ifdef ERANGE_FILL
+#line 3057
+ xp++; tp++; continue;
+#line 3057
+#endif
+#line 3057
}
-#line 3005
+#line 3057
*xp++ = (uchar) (signed) *tp++; /* type cast from int to uchar */
-#line 3005
+#line 3057
}
-#line 3005
+#line 3057
-#line 3005
+#line 3057
*xpp = (void *)xp;
-#line 3005
+#line 3057
return status;
-#line 3005
+#line 3057
}
-#line 3005
+#line 3057
int
-#line 3006
+#line 3058
ncx_putn_uchar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3006
+#line 3058
{
-#line 3006
+#line 3058
int status = NC_NOERR;
-#line 3006
+#line 3058
uchar *xp = (uchar *) *xpp;
-#line 3006
+#line 3058
-#line 3006
+#line 3058
while (nelems-- != 0) {
-#line 3006
+#line 3058
if (*tp > (long)X_UCHAR_MAX || *tp < 0) {
-#line 3006
+#line 3058
-#line 3006
+#line 3058
+#ifdef ERANGE_FILL
+#line 3058
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3058
+#endif
+#line 3058
status = NC_ERANGE;
-#line 3006
+#line 3058
-#line 3006
+#line 3058
+#ifdef ERANGE_FILL
+#line 3058
+ xp++; tp++; continue;
+#line 3058
+#endif
+#line 3058
}
-#line 3006
+#line 3058
*xp++ = (uchar) (signed) *tp++; /* type cast from long to uchar */
-#line 3006
+#line 3058
}
-#line 3006
+#line 3058
-#line 3006
+#line 3058
*xpp = (void *)xp;
-#line 3006
+#line 3058
return status;
-#line 3006
+#line 3058
}
-#line 3006
+#line 3058
int
-#line 3007
+#line 3059
ncx_putn_uchar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3007
+#line 3059
{
-#line 3007
+#line 3059
int status = NC_NOERR;
-#line 3007
+#line 3059
uchar *xp = (uchar *) *xpp;
-#line 3007
+#line 3059
-#line 3007
+#line 3059
while (nelems-- != 0) {
-#line 3007
+#line 3059
if (*tp > (float)X_UCHAR_MAX || *tp < 0) {
-#line 3007
+#line 3059
-#line 3007
+#line 3059
+#ifdef ERANGE_FILL
+#line 3059
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3059
+#endif
+#line 3059
status = NC_ERANGE;
-#line 3007
+#line 3059
-#line 3007
+#line 3059
+#ifdef ERANGE_FILL
+#line 3059
+ xp++; tp++; continue;
+#line 3059
+#endif
+#line 3059
}
-#line 3007
+#line 3059
*xp++ = (uchar) (signed) *tp++; /* type cast from float to uchar */
-#line 3007
+#line 3059
}
-#line 3007
+#line 3059
-#line 3007
+#line 3059
*xpp = (void *)xp;
-#line 3007
+#line 3059
return status;
-#line 3007
+#line 3059
}
-#line 3007
+#line 3059
int
-#line 3008
+#line 3060
ncx_putn_uchar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3008
+#line 3060
{
-#line 3008
+#line 3060
int status = NC_NOERR;
-#line 3008
+#line 3060
uchar *xp = (uchar *) *xpp;
-#line 3008
+#line 3060
-#line 3008
+#line 3060
while (nelems-- != 0) {
-#line 3008
+#line 3060
if (*tp > (double)X_UCHAR_MAX || *tp < 0) {
-#line 3008
+#line 3060
-#line 3008
+#line 3060
+#ifdef ERANGE_FILL
+#line 3060
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3060
+#endif
+#line 3060
status = NC_ERANGE;
-#line 3008
+#line 3060
-#line 3008
+#line 3060
+#ifdef ERANGE_FILL
+#line 3060
+ xp++; tp++; continue;
+#line 3060
+#endif
+#line 3060
}
-#line 3008
+#line 3060
*xp++ = (uchar) (signed) *tp++; /* type cast from double to uchar */
-#line 3008
+#line 3060
}
-#line 3008
+#line 3060
-#line 3008
+#line 3060
*xpp = (void *)xp;
-#line 3008
+#line 3060
return status;
-#line 3008
+#line 3060
}
-#line 3008
+#line 3060
int
-#line 3009
+#line 3061
ncx_putn_uchar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3009
+#line 3061
{
-#line 3009
+#line 3061
int status = NC_NOERR;
-#line 3009
+#line 3061
uchar *xp = (uchar *) *xpp;
-#line 3009
+#line 3061
-#line 3009
+#line 3061
while (nelems-- != 0) {
-#line 3009
+#line 3061
if (*tp > (longlong)X_UCHAR_MAX || *tp < 0) {
-#line 3009
+#line 3061
-#line 3009
+#line 3061
+#ifdef ERANGE_FILL
+#line 3061
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3061
+#endif
+#line 3061
status = NC_ERANGE;
-#line 3009
+#line 3061
-#line 3009
+#line 3061
+#ifdef ERANGE_FILL
+#line 3061
+ xp++; tp++; continue;
+#line 3061
+#endif
+#line 3061
}
-#line 3009
+#line 3061
*xp++ = (uchar) (signed) *tp++; /* type cast from longlong to uchar */
-#line 3009
+#line 3061
}
-#line 3009
+#line 3061
-#line 3009
+#line 3061
*xpp = (void *)xp;
-#line 3009
+#line 3061
return status;
-#line 3009
+#line 3061
}
-#line 3009
+#line 3061
int
-#line 3010
+#line 3062
ncx_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3010
+#line 3062
{
-#line 3010
+#line 3062
int status = NC_NOERR;
-#line 3010
+#line 3062
uchar *xp = (uchar *) *xpp;
-#line 3010
+#line 3062
-#line 3010
+#line 3062
while (nelems-- != 0) {
-#line 3010
+#line 3062
if (*tp > (ushort)X_UCHAR_MAX ) {
-#line 3010
+#line 3062
-#line 3010
+#line 3062
+#ifdef ERANGE_FILL
+#line 3062
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3062
+#endif
+#line 3062
status = NC_ERANGE;
-#line 3010
+#line 3062
-#line 3010
+#line 3062
+#ifdef ERANGE_FILL
+#line 3062
+ xp++; tp++; continue;
+#line 3062
+#endif
+#line 3062
}
-#line 3010
+#line 3062
*xp++ = (uchar) *tp++; /* type cast from ushort to uchar */
-#line 3010
+#line 3062
}
-#line 3010
+#line 3062
-#line 3010
+#line 3062
*xpp = (void *)xp;
-#line 3010
+#line 3062
return status;
-#line 3010
+#line 3062
}
-#line 3010
+#line 3062
int
-#line 3011
+#line 3063
ncx_putn_uchar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3011
+#line 3063
{
-#line 3011
+#line 3063
int status = NC_NOERR;
-#line 3011
+#line 3063
uchar *xp = (uchar *) *xpp;
-#line 3011
+#line 3063
-#line 3011
+#line 3063
while (nelems-- != 0) {
-#line 3011
+#line 3063
if (*tp > (uint)X_UCHAR_MAX ) {
-#line 3011
+#line 3063
-#line 3011
+#line 3063
+#ifdef ERANGE_FILL
+#line 3063
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3063
+#endif
+#line 3063
status = NC_ERANGE;
-#line 3011
+#line 3063
-#line 3011
+#line 3063
+#ifdef ERANGE_FILL
+#line 3063
+ xp++; tp++; continue;
+#line 3063
+#endif
+#line 3063
}
-#line 3011
+#line 3063
*xp++ = (uchar) *tp++; /* type cast from uint to uchar */
-#line 3011
+#line 3063
}
-#line 3011
+#line 3063
-#line 3011
+#line 3063
*xpp = (void *)xp;
-#line 3011
+#line 3063
return status;
-#line 3011
+#line 3063
}
-#line 3011
+#line 3063
int
-#line 3012
+#line 3064
ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3012
+#line 3064
{
-#line 3012
+#line 3064
int status = NC_NOERR;
-#line 3012
+#line 3064
uchar *xp = (uchar *) *xpp;
-#line 3012
+#line 3064
-#line 3012
+#line 3064
while (nelems-- != 0) {
-#line 3012
+#line 3064
if (*tp > (ulonglong)X_UCHAR_MAX ) {
-#line 3012
+#line 3064
-#line 3012
+#line 3064
+#ifdef ERANGE_FILL
+#line 3064
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3064
+#endif
+#line 3064
status = NC_ERANGE;
-#line 3012
+#line 3064
-#line 3012
+#line 3064
+#ifdef ERANGE_FILL
+#line 3064
+ xp++; tp++; continue;
+#line 3064
+#endif
+#line 3064
}
-#line 3012
+#line 3064
*xp++ = (uchar) *tp++; /* type cast from ulonglong to uchar */
-#line 3012
+#line 3064
}
-#line 3012
+#line 3064
-#line 3012
+#line 3064
*xpp = (void *)xp;
-#line 3012
+#line 3064
return status;
-#line 3012
+#line 3064
}
-#line 3012
+#line 3064
-#line 3015
+#line 3067
int
ncx_pad_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
{
@@ -10863,8 +12828,20 @@ ncx_pad_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp
while (nelems-- != 0) {
if (*tp < 0) {
+#line 3078
+#ifdef ERANGE_FILL
+#line 3078
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3078
+#endif
status = NC_ERANGE;
+#line 3080
+#ifdef ERANGE_FILL
+#line 3080
+ xp++; tp++; continue;
+#line 3080
+#endif
}
*xp++ = (uchar) (signed) *tp++; /* type cast from schar to uchar */
}
@@ -10877,536 +12854,644 @@ ncx_pad_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp, void *fillp
*xpp = (void *)xp;
return status;
}
-#line 3042
+#line 3094
int
ncx_pad_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
{
size_t rndup = nelems % X_ALIGN;
-#line 3045
+#line 3097
-#line 3045
+#line 3097
if (rndup)
-#line 3045
+#line 3097
rndup = X_ALIGN - rndup;
-#line 3045
+#line 3097
-#line 3045
+#line 3097
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 3045
+#line 3097
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3045
+#line 3097
-#line 3045
+#line 3097
if (rndup)
-#line 3045
+#line 3097
{
-#line 3045
+#line 3097
(void) memcpy(*xpp, nada, (size_t)rndup);
-#line 3045
+#line 3097
*xpp = (void *)((char *)(*xpp) + rndup);
-#line 3045
+#line 3097
}
-#line 3045
+#line 3097
-#line 3045
+#line 3097
return NC_NOERR;
-#line 3045
+#line 3097
}
int
-#line 3047
+#line 3099
ncx_pad_putn_uchar_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3047
+#line 3099
{
-#line 3047
+#line 3099
int status = NC_NOERR;
-#line 3047
+#line 3099
size_t rndup = nelems % X_ALIGN;
-#line 3047
+#line 3099
uchar *xp = (uchar *) *xpp;
-#line 3047
+#line 3099
-#line 3047
+#line 3099
if (rndup) rndup = X_ALIGN - rndup;
-#line 3047
+#line 3099
-#line 3047
+#line 3099
while (nelems-- != 0) {
-#line 3047
+#line 3099
if (*tp > (short)X_UCHAR_MAX || *tp < 0) {
-#line 3047
+#line 3099
-#line 3047
+#line 3099
+#ifdef ERANGE_FILL
+#line 3099
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3099
+#endif
+#line 3099
status = NC_ERANGE;
-#line 3047
+#line 3099
-#line 3047
+#line 3099
+#ifdef ERANGE_FILL
+#line 3099
+ xp++; tp++; continue;
+#line 3099
+#endif
+#line 3099
}
-#line 3047
+#line 3099
*xp++ = (uchar) (signed) *tp++; /* type cast from short to uchar */
-#line 3047
+#line 3099
}
-#line 3047
+#line 3099
-#line 3047
+#line 3099
-#line 3047
+#line 3099
if (rndup) {
-#line 3047
+#line 3099
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3047
+#line 3099
xp += rndup;
-#line 3047
+#line 3099
}
-#line 3047
+#line 3099
-#line 3047
+#line 3099
*xpp = (void *)xp;
-#line 3047
+#line 3099
return status;
-#line 3047
+#line 3099
}
-#line 3047
+#line 3099
int
-#line 3048
+#line 3100
ncx_pad_putn_uchar_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3048
+#line 3100
{
-#line 3048
+#line 3100
int status = NC_NOERR;
-#line 3048
+#line 3100
size_t rndup = nelems % X_ALIGN;
-#line 3048
+#line 3100
uchar *xp = (uchar *) *xpp;
-#line 3048
+#line 3100
-#line 3048
+#line 3100
if (rndup) rndup = X_ALIGN - rndup;
-#line 3048
+#line 3100
-#line 3048
+#line 3100
while (nelems-- != 0) {
-#line 3048
+#line 3100
if (*tp > (int)X_UCHAR_MAX || *tp < 0) {
-#line 3048
+#line 3100
-#line 3048
+#line 3100
+#ifdef ERANGE_FILL
+#line 3100
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3100
+#endif
+#line 3100
status = NC_ERANGE;
-#line 3048
+#line 3100
-#line 3048
+#line 3100
+#ifdef ERANGE_FILL
+#line 3100
+ xp++; tp++; continue;
+#line 3100
+#endif
+#line 3100
}
-#line 3048
+#line 3100
*xp++ = (uchar) (signed) *tp++; /* type cast from int to uchar */
-#line 3048
+#line 3100
}
-#line 3048
+#line 3100
-#line 3048
+#line 3100
-#line 3048
+#line 3100
if (rndup) {
-#line 3048
+#line 3100
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3048
+#line 3100
xp += rndup;
-#line 3048
+#line 3100
}
-#line 3048
+#line 3100
-#line 3048
+#line 3100
*xpp = (void *)xp;
-#line 3048
+#line 3100
return status;
-#line 3048
+#line 3100
}
-#line 3048
+#line 3100
int
-#line 3049
+#line 3101
ncx_pad_putn_uchar_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3049
+#line 3101
{
-#line 3049
+#line 3101
int status = NC_NOERR;
-#line 3049
+#line 3101
size_t rndup = nelems % X_ALIGN;
-#line 3049
+#line 3101
uchar *xp = (uchar *) *xpp;
-#line 3049
+#line 3101
-#line 3049
+#line 3101
if (rndup) rndup = X_ALIGN - rndup;
-#line 3049
+#line 3101
-#line 3049
+#line 3101
while (nelems-- != 0) {
-#line 3049
+#line 3101
if (*tp > (long)X_UCHAR_MAX || *tp < 0) {
-#line 3049
+#line 3101
-#line 3049
+#line 3101
+#ifdef ERANGE_FILL
+#line 3101
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3101
+#endif
+#line 3101
status = NC_ERANGE;
-#line 3049
+#line 3101
-#line 3049
+#line 3101
+#ifdef ERANGE_FILL
+#line 3101
+ xp++; tp++; continue;
+#line 3101
+#endif
+#line 3101
}
-#line 3049
+#line 3101
*xp++ = (uchar) (signed) *tp++; /* type cast from long to uchar */
-#line 3049
+#line 3101
}
-#line 3049
+#line 3101
-#line 3049
+#line 3101
-#line 3049
+#line 3101
if (rndup) {
-#line 3049
+#line 3101
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3049
+#line 3101
xp += rndup;
-#line 3049
+#line 3101
}
-#line 3049
+#line 3101
-#line 3049
+#line 3101
*xpp = (void *)xp;
-#line 3049
+#line 3101
return status;
-#line 3049
+#line 3101
}
-#line 3049
+#line 3101
int
-#line 3050
+#line 3102
ncx_pad_putn_uchar_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3050
+#line 3102
{
-#line 3050
+#line 3102
int status = NC_NOERR;
-#line 3050
+#line 3102
size_t rndup = nelems % X_ALIGN;
-#line 3050
+#line 3102
uchar *xp = (uchar *) *xpp;
-#line 3050
+#line 3102
-#line 3050
+#line 3102
if (rndup) rndup = X_ALIGN - rndup;
-#line 3050
+#line 3102
-#line 3050
+#line 3102
while (nelems-- != 0) {
-#line 3050
+#line 3102
if (*tp > (float)X_UCHAR_MAX || *tp < 0) {
-#line 3050
+#line 3102
-#line 3050
+#line 3102
+#ifdef ERANGE_FILL
+#line 3102
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3102
+#endif
+#line 3102
status = NC_ERANGE;
-#line 3050
+#line 3102
-#line 3050
+#line 3102
+#ifdef ERANGE_FILL
+#line 3102
+ xp++; tp++; continue;
+#line 3102
+#endif
+#line 3102
}
-#line 3050
+#line 3102
*xp++ = (uchar) (signed) *tp++; /* type cast from float to uchar */
-#line 3050
+#line 3102
}
-#line 3050
+#line 3102
-#line 3050
+#line 3102
-#line 3050
+#line 3102
if (rndup) {
-#line 3050
+#line 3102
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3050
+#line 3102
xp += rndup;
-#line 3050
+#line 3102
}
-#line 3050
+#line 3102
-#line 3050
+#line 3102
*xpp = (void *)xp;
-#line 3050
+#line 3102
return status;
-#line 3050
+#line 3102
}
-#line 3050
+#line 3102
int
-#line 3051
+#line 3103
ncx_pad_putn_uchar_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3051
+#line 3103
{
-#line 3051
+#line 3103
int status = NC_NOERR;
-#line 3051
+#line 3103
size_t rndup = nelems % X_ALIGN;
-#line 3051
+#line 3103
uchar *xp = (uchar *) *xpp;
-#line 3051
+#line 3103
-#line 3051
+#line 3103
if (rndup) rndup = X_ALIGN - rndup;
-#line 3051
+#line 3103
-#line 3051
+#line 3103
while (nelems-- != 0) {
-#line 3051
+#line 3103
if (*tp > (double)X_UCHAR_MAX || *tp < 0) {
-#line 3051
+#line 3103
-#line 3051
+#line 3103
+#ifdef ERANGE_FILL
+#line 3103
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3103
+#endif
+#line 3103
status = NC_ERANGE;
-#line 3051
+#line 3103
-#line 3051
+#line 3103
+#ifdef ERANGE_FILL
+#line 3103
+ xp++; tp++; continue;
+#line 3103
+#endif
+#line 3103
}
-#line 3051
+#line 3103
*xp++ = (uchar) (signed) *tp++; /* type cast from double to uchar */
-#line 3051
+#line 3103
}
-#line 3051
+#line 3103
-#line 3051
+#line 3103
-#line 3051
+#line 3103
if (rndup) {
-#line 3051
+#line 3103
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3051
+#line 3103
xp += rndup;
-#line 3051
+#line 3103
}
-#line 3051
+#line 3103
-#line 3051
+#line 3103
*xpp = (void *)xp;
-#line 3051
+#line 3103
return status;
-#line 3051
+#line 3103
}
-#line 3051
+#line 3103
int
-#line 3052
+#line 3104
ncx_pad_putn_uchar_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3052
+#line 3104
{
-#line 3052
+#line 3104
int status = NC_NOERR;
-#line 3052
+#line 3104
size_t rndup = nelems % X_ALIGN;
-#line 3052
+#line 3104
uchar *xp = (uchar *) *xpp;
-#line 3052
+#line 3104
-#line 3052
+#line 3104
if (rndup) rndup = X_ALIGN - rndup;
-#line 3052
+#line 3104
-#line 3052
+#line 3104
while (nelems-- != 0) {
-#line 3052
+#line 3104
if (*tp > (longlong)X_UCHAR_MAX || *tp < 0) {
-#line 3052
+#line 3104
-#line 3052
+#line 3104
+#ifdef ERANGE_FILL
+#line 3104
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3104
+#endif
+#line 3104
status = NC_ERANGE;
-#line 3052
+#line 3104
-#line 3052
+#line 3104
+#ifdef ERANGE_FILL
+#line 3104
+ xp++; tp++; continue;
+#line 3104
+#endif
+#line 3104
}
-#line 3052
+#line 3104
*xp++ = (uchar) (signed) *tp++; /* type cast from longlong to uchar */
-#line 3052
+#line 3104
}
-#line 3052
+#line 3104
-#line 3052
+#line 3104
-#line 3052
+#line 3104
if (rndup) {
-#line 3052
+#line 3104
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3052
+#line 3104
xp += rndup;
-#line 3052
+#line 3104
}
-#line 3052
+#line 3104
-#line 3052
+#line 3104
*xpp = (void *)xp;
-#line 3052
+#line 3104
return status;
-#line 3052
+#line 3104
}
-#line 3052
+#line 3104
int
-#line 3053
+#line 3105
ncx_pad_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3053
+#line 3105
{
-#line 3053
+#line 3105
int status = NC_NOERR;
-#line 3053
+#line 3105
size_t rndup = nelems % X_ALIGN;
-#line 3053
+#line 3105
uchar *xp = (uchar *) *xpp;
-#line 3053
+#line 3105
-#line 3053
+#line 3105
if (rndup) rndup = X_ALIGN - rndup;
-#line 3053
+#line 3105
-#line 3053
+#line 3105
while (nelems-- != 0) {
-#line 3053
+#line 3105
if (*tp > (ushort)X_UCHAR_MAX ) {
-#line 3053
+#line 3105
-#line 3053
+#line 3105
+#ifdef ERANGE_FILL
+#line 3105
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3105
+#endif
+#line 3105
status = NC_ERANGE;
-#line 3053
+#line 3105
-#line 3053
+#line 3105
+#ifdef ERANGE_FILL
+#line 3105
+ xp++; tp++; continue;
+#line 3105
+#endif
+#line 3105
}
-#line 3053
+#line 3105
*xp++ = (uchar) *tp++; /* type cast from ushort to uchar */
-#line 3053
+#line 3105
}
-#line 3053
+#line 3105
-#line 3053
+#line 3105
-#line 3053
+#line 3105
if (rndup) {
-#line 3053
+#line 3105
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3053
+#line 3105
xp += rndup;
-#line 3053
+#line 3105
}
-#line 3053
+#line 3105
-#line 3053
+#line 3105
*xpp = (void *)xp;
-#line 3053
+#line 3105
return status;
-#line 3053
+#line 3105
}
-#line 3053
+#line 3105
int
-#line 3054
+#line 3106
ncx_pad_putn_uchar_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3054
+#line 3106
{
-#line 3054
+#line 3106
int status = NC_NOERR;
-#line 3054
+#line 3106
size_t rndup = nelems % X_ALIGN;
-#line 3054
+#line 3106
uchar *xp = (uchar *) *xpp;
-#line 3054
+#line 3106
-#line 3054
+#line 3106
if (rndup) rndup = X_ALIGN - rndup;
-#line 3054
+#line 3106
-#line 3054
+#line 3106
while (nelems-- != 0) {
-#line 3054
+#line 3106
if (*tp > (uint)X_UCHAR_MAX ) {
-#line 3054
+#line 3106
-#line 3054
+#line 3106
+#ifdef ERANGE_FILL
+#line 3106
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3106
+#endif
+#line 3106
status = NC_ERANGE;
-#line 3054
+#line 3106
-#line 3054
+#line 3106
+#ifdef ERANGE_FILL
+#line 3106
+ xp++; tp++; continue;
+#line 3106
+#endif
+#line 3106
}
-#line 3054
+#line 3106
*xp++ = (uchar) *tp++; /* type cast from uint to uchar */
-#line 3054
+#line 3106
}
-#line 3054
+#line 3106
-#line 3054
+#line 3106
-#line 3054
+#line 3106
if (rndup) {
-#line 3054
+#line 3106
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3054
+#line 3106
xp += rndup;
-#line 3054
+#line 3106
}
-#line 3054
+#line 3106
-#line 3054
+#line 3106
*xpp = (void *)xp;
-#line 3054
+#line 3106
return status;
-#line 3054
+#line 3106
}
-#line 3054
+#line 3106
int
-#line 3055
+#line 3107
ncx_pad_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3055
+#line 3107
{
-#line 3055
+#line 3107
int status = NC_NOERR;
-#line 3055
+#line 3107
size_t rndup = nelems % X_ALIGN;
-#line 3055
+#line 3107
uchar *xp = (uchar *) *xpp;
-#line 3055
+#line 3107
-#line 3055
+#line 3107
if (rndup) rndup = X_ALIGN - rndup;
-#line 3055
+#line 3107
-#line 3055
+#line 3107
while (nelems-- != 0) {
-#line 3055
+#line 3107
if (*tp > (ulonglong)X_UCHAR_MAX ) {
-#line 3055
+#line 3107
-#line 3055
+#line 3107
+#ifdef ERANGE_FILL
+#line 3107
+ if (fillp != NULL) memcpy(xp, fillp, 1);
+#line 3107
+#endif
+#line 3107
status = NC_ERANGE;
-#line 3055
+#line 3107
-#line 3055
+#line 3107
+#ifdef ERANGE_FILL
+#line 3107
+ xp++; tp++; continue;
+#line 3107
+#endif
+#line 3107
}
-#line 3055
+#line 3107
*xp++ = (uchar) *tp++; /* type cast from ulonglong to uchar */
-#line 3055
+#line 3107
}
-#line 3055
+#line 3107
-#line 3055
+#line 3107
-#line 3055
+#line 3107
if (rndup) {
-#line 3055
+#line 3107
(void) memcpy(xp, nada, (size_t)rndup);
-#line 3055
+#line 3107
xp += rndup;
-#line 3055
+#line 3107
}
-#line 3055
+#line 3107
-#line 3055
+#line 3107
*xpp = (void *)xp;
-#line 3055
+#line 3107
return status;
-#line 3055
+#line 3107
}
-#line 3055
+#line 3107
/* short ---------------------------------------------------------------------*/
@@ -11426,1898 +13511,1898 @@ ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
}
#else
int
-#line 3073
+#line 3125
ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
-#line 3073
+#line 3125
{
-#line 3073
+#line 3125
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3073
+#line 3125
-#line 3073
+#line 3125
/* basic algorithm is:
-#line 3073
+#line 3125
* - ensure sane alignment of input data
-#line 3073
+#line 3125
* - copy (conversion happens automatically) input data
-#line 3073
+#line 3125
* to output
-#line 3073
+#line 3125
* - update xpp to point at next unconverted input, and tp to point
-#line 3073
+#line 3125
* at next location for converted output
-#line 3073
+#line 3125
*/
-#line 3073
+#line 3125
long i, j, ni;
-#line 3073
+#line 3125
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3073
+#line 3125
short *xp;
-#line 3073
+#line 3125
int nrange = 0; /* number of range errors */
-#line 3073
+#line 3125
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3073
+#line 3125
long cxp = (long) *((char**)xpp);
-#line 3073
+#line 3125
-#line 3073
+#line 3125
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3073
+#line 3125
/* sjl: manually stripmine so we can limit amount of
-#line 3073
+#line 3125
* vector work space reserved to LOOPCNT elements. Also
-#line 3073
+#line 3125
* makes vectorisation easy */
-#line 3073
+#line 3125
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3073
+#line 3125
ni=Min(nelems-j,LOOPCNT);
-#line 3073
+#line 3125
if (realign) {
-#line 3073
+#line 3125
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3073
+#line 3125
xp = tmp;
-#line 3073
+#line 3125
} else {
-#line 3073
+#line 3125
xp = (short *) *xpp;
-#line 3073
+#line 3125
}
-#line 3073
+#line 3125
/* copy the next block */
-#line 3073
+#line 3125
#pragma cdir loopcnt=LOOPCNT
-#line 3073
+#line 3125
#pragma cdir shortloop
-#line 3073
+#line 3125
for (i=0; i<ni; i++) {
-#line 3073
+#line 3125
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3073
+#line 3125
/* test for range errors (not always needed but do it anyway) */
-#line 3073
+#line 3125
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3073
+#line 3125
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3073
+#line 3125
nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
-#line 3073
+#line 3125
}
-#line 3073
+#line 3125
/* update xpp and tp */
-#line 3073
+#line 3125
if (realign) xp = (short *) *xpp;
-#line 3073
+#line 3125
xp += ni;
-#line 3073
+#line 3125
tp += ni;
-#line 3073
+#line 3125
*xpp = (void*)xp;
-#line 3073
+#line 3125
}
-#line 3073
+#line 3125
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3073
+#line 3125
-#line 3073
+#line 3125
#else /* not SX */
-#line 3073
+#line 3125
const char *xp = (const char *) *xpp;
-#line 3073
+#line 3125
int status = NC_NOERR;
-#line 3073
+#line 3125
-#line 3073
+#line 3125
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3073
+#line 3125
{
-#line 3073
+#line 3125
const int lstatus = ncx_get_short_short(xp, tp);
-#line 3073
+#line 3125
if (status == NC_NOERR) /* report the first encountered error */
-#line 3073
+#line 3125
status = lstatus;
-#line 3073
+#line 3125
}
-#line 3073
+#line 3125
-#line 3073
+#line 3125
*xpp = (const void *)xp;
-#line 3073
+#line 3125
return status;
-#line 3073
+#line 3125
#endif
-#line 3073
+#line 3125
}
-#line 3073
+#line 3125
#endif
int
-#line 3075
+#line 3127
ncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3075
+#line 3127
{
-#line 3075
+#line 3127
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3075
+#line 3127
-#line 3075
+#line 3127
/* basic algorithm is:
-#line 3075
+#line 3127
* - ensure sane alignment of input data
-#line 3075
+#line 3127
* - copy (conversion happens automatically) input data
-#line 3075
+#line 3127
* to output
-#line 3075
+#line 3127
* - update xpp to point at next unconverted input, and tp to point
-#line 3075
+#line 3127
* at next location for converted output
-#line 3075
+#line 3127
*/
-#line 3075
+#line 3127
long i, j, ni;
-#line 3075
+#line 3127
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3075
+#line 3127
short *xp;
-#line 3075
+#line 3127
int nrange = 0; /* number of range errors */
-#line 3075
+#line 3127
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3075
+#line 3127
long cxp = (long) *((char**)xpp);
-#line 3075
+#line 3127
-#line 3075
+#line 3127
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3075
+#line 3127
/* sjl: manually stripmine so we can limit amount of
-#line 3075
+#line 3127
* vector work space reserved to LOOPCNT elements. Also
-#line 3075
+#line 3127
* makes vectorisation easy */
-#line 3075
+#line 3127
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3075
+#line 3127
ni=Min(nelems-j,LOOPCNT);
-#line 3075
+#line 3127
if (realign) {
-#line 3075
+#line 3127
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3075
+#line 3127
xp = tmp;
-#line 3075
+#line 3127
} else {
-#line 3075
+#line 3127
xp = (short *) *xpp;
-#line 3075
+#line 3127
}
-#line 3075
+#line 3127
/* copy the next block */
-#line 3075
+#line 3127
#pragma cdir loopcnt=LOOPCNT
-#line 3075
+#line 3127
#pragma cdir shortloop
-#line 3075
+#line 3127
for (i=0; i<ni; i++) {
-#line 3075
+#line 3127
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3075
+#line 3127
/* test for range errors (not always needed but do it anyway) */
-#line 3075
+#line 3127
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3075
+#line 3127
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3075
+#line 3127
nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
-#line 3075
+#line 3127
}
-#line 3075
+#line 3127
/* update xpp and tp */
-#line 3075
+#line 3127
if (realign) xp = (short *) *xpp;
-#line 3075
+#line 3127
xp += ni;
-#line 3075
+#line 3127
tp += ni;
-#line 3075
+#line 3127
*xpp = (void*)xp;
-#line 3075
+#line 3127
}
-#line 3075
+#line 3127
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3075
+#line 3127
-#line 3075
+#line 3127
#else /* not SX */
-#line 3075
+#line 3127
const char *xp = (const char *) *xpp;
-#line 3075
+#line 3127
int status = NC_NOERR;
-#line 3075
+#line 3127
-#line 3075
+#line 3127
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3075
+#line 3127
{
-#line 3075
+#line 3127
const int lstatus = ncx_get_short_schar(xp, tp);
-#line 3075
+#line 3127
if (status == NC_NOERR) /* report the first encountered error */
-#line 3075
+#line 3127
status = lstatus;
-#line 3075
+#line 3127
}
-#line 3075
+#line 3127
-#line 3075
+#line 3127
*xpp = (const void *)xp;
-#line 3075
+#line 3127
return status;
-#line 3075
+#line 3127
#endif
-#line 3075
+#line 3127
}
-#line 3075
+#line 3127
int
-#line 3076
+#line 3128
ncx_getn_short_int(const void **xpp, size_t nelems, int *tp)
-#line 3076
+#line 3128
{
-#line 3076
+#line 3128
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3076
+#line 3128
-#line 3076
+#line 3128
/* basic algorithm is:
-#line 3076
+#line 3128
* - ensure sane alignment of input data
-#line 3076
+#line 3128
* - copy (conversion happens automatically) input data
-#line 3076
+#line 3128
* to output
-#line 3076
+#line 3128
* - update xpp to point at next unconverted input, and tp to point
-#line 3076
+#line 3128
* at next location for converted output
-#line 3076
+#line 3128
*/
-#line 3076
+#line 3128
long i, j, ni;
-#line 3076
+#line 3128
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3076
+#line 3128
short *xp;
-#line 3076
+#line 3128
int nrange = 0; /* number of range errors */
-#line 3076
+#line 3128
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3076
+#line 3128
long cxp = (long) *((char**)xpp);
-#line 3076
+#line 3128
-#line 3076
+#line 3128
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3076
+#line 3128
/* sjl: manually stripmine so we can limit amount of
-#line 3076
+#line 3128
* vector work space reserved to LOOPCNT elements. Also
-#line 3076
+#line 3128
* makes vectorisation easy */
-#line 3076
+#line 3128
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3076
+#line 3128
ni=Min(nelems-j,LOOPCNT);
-#line 3076
+#line 3128
if (realign) {
-#line 3076
+#line 3128
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3076
+#line 3128
xp = tmp;
-#line 3076
+#line 3128
} else {
-#line 3076
+#line 3128
xp = (short *) *xpp;
-#line 3076
+#line 3128
}
-#line 3076
+#line 3128
/* copy the next block */
-#line 3076
+#line 3128
#pragma cdir loopcnt=LOOPCNT
-#line 3076
+#line 3128
#pragma cdir shortloop
-#line 3076
+#line 3128
for (i=0; i<ni; i++) {
-#line 3076
+#line 3128
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3076
+#line 3128
/* test for range errors (not always needed but do it anyway) */
-#line 3076
+#line 3128
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3076
+#line 3128
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3076
+#line 3128
nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
-#line 3076
+#line 3128
}
-#line 3076
+#line 3128
/* update xpp and tp */
-#line 3076
+#line 3128
if (realign) xp = (short *) *xpp;
-#line 3076
+#line 3128
xp += ni;
-#line 3076
+#line 3128
tp += ni;
-#line 3076
+#line 3128
*xpp = (void*)xp;
-#line 3076
+#line 3128
}
-#line 3076
+#line 3128
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3076
+#line 3128
-#line 3076
+#line 3128
#else /* not SX */
-#line 3076
+#line 3128
const char *xp = (const char *) *xpp;
-#line 3076
+#line 3128
int status = NC_NOERR;
-#line 3076
+#line 3128
-#line 3076
+#line 3128
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3076
+#line 3128
{
-#line 3076
+#line 3128
const int lstatus = ncx_get_short_int(xp, tp);
-#line 3076
+#line 3128
if (status == NC_NOERR) /* report the first encountered error */
-#line 3076
+#line 3128
status = lstatus;
-#line 3076
+#line 3128
}
-#line 3076
+#line 3128
-#line 3076
+#line 3128
*xpp = (const void *)xp;
-#line 3076
+#line 3128
return status;
-#line 3076
+#line 3128
#endif
-#line 3076
+#line 3128
}
-#line 3076
+#line 3128
int
-#line 3077
+#line 3129
ncx_getn_short_long(const void **xpp, size_t nelems, long *tp)
-#line 3077
+#line 3129
{
-#line 3077
+#line 3129
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3077
+#line 3129
-#line 3077
+#line 3129
/* basic algorithm is:
-#line 3077
+#line 3129
* - ensure sane alignment of input data
-#line 3077
+#line 3129
* - copy (conversion happens automatically) input data
-#line 3077
+#line 3129
* to output
-#line 3077
+#line 3129
* - update xpp to point at next unconverted input, and tp to point
-#line 3077
+#line 3129
* at next location for converted output
-#line 3077
+#line 3129
*/
-#line 3077
+#line 3129
long i, j, ni;
-#line 3077
+#line 3129
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3077
+#line 3129
short *xp;
-#line 3077
+#line 3129
int nrange = 0; /* number of range errors */
-#line 3077
+#line 3129
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3077
+#line 3129
long cxp = (long) *((char**)xpp);
-#line 3077
+#line 3129
-#line 3077
+#line 3129
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3077
+#line 3129
/* sjl: manually stripmine so we can limit amount of
-#line 3077
+#line 3129
* vector work space reserved to LOOPCNT elements. Also
-#line 3077
+#line 3129
* makes vectorisation easy */
-#line 3077
+#line 3129
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3077
+#line 3129
ni=Min(nelems-j,LOOPCNT);
-#line 3077
+#line 3129
if (realign) {
-#line 3077
+#line 3129
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3077
+#line 3129
xp = tmp;
-#line 3077
+#line 3129
} else {
-#line 3077
+#line 3129
xp = (short *) *xpp;
-#line 3077
+#line 3129
}
-#line 3077
+#line 3129
/* copy the next block */
-#line 3077
+#line 3129
#pragma cdir loopcnt=LOOPCNT
-#line 3077
+#line 3129
#pragma cdir shortloop
-#line 3077
+#line 3129
for (i=0; i<ni; i++) {
-#line 3077
+#line 3129
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3077
+#line 3129
/* test for range errors (not always needed but do it anyway) */
-#line 3077
+#line 3129
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3077
+#line 3129
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3077
+#line 3129
nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
-#line 3077
+#line 3129
}
-#line 3077
+#line 3129
/* update xpp and tp */
-#line 3077
+#line 3129
if (realign) xp = (short *) *xpp;
-#line 3077
+#line 3129
xp += ni;
-#line 3077
+#line 3129
tp += ni;
-#line 3077
+#line 3129
*xpp = (void*)xp;
-#line 3077
+#line 3129
}
-#line 3077
+#line 3129
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3077
+#line 3129
-#line 3077
+#line 3129
#else /* not SX */
-#line 3077
+#line 3129
const char *xp = (const char *) *xpp;
-#line 3077
+#line 3129
int status = NC_NOERR;
-#line 3077
+#line 3129
-#line 3077
+#line 3129
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3077
+#line 3129
{
-#line 3077
+#line 3129
const int lstatus = ncx_get_short_long(xp, tp);
-#line 3077
+#line 3129
if (status == NC_NOERR) /* report the first encountered error */
-#line 3077
+#line 3129
status = lstatus;
-#line 3077
+#line 3129
}
-#line 3077
+#line 3129
-#line 3077
+#line 3129
*xpp = (const void *)xp;
-#line 3077
+#line 3129
return status;
-#line 3077
+#line 3129
#endif
-#line 3077
+#line 3129
}
-#line 3077
+#line 3129
int
-#line 3078
+#line 3130
ncx_getn_short_float(const void **xpp, size_t nelems, float *tp)
-#line 3078
+#line 3130
{
-#line 3078
+#line 3130
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3078
+#line 3130
-#line 3078
+#line 3130
/* basic algorithm is:
-#line 3078
+#line 3130
* - ensure sane alignment of input data
-#line 3078
+#line 3130
* - copy (conversion happens automatically) input data
-#line 3078
+#line 3130
* to output
-#line 3078
+#line 3130
* - update xpp to point at next unconverted input, and tp to point
-#line 3078
+#line 3130
* at next location for converted output
-#line 3078
+#line 3130
*/
-#line 3078
+#line 3130
long i, j, ni;
-#line 3078
+#line 3130
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3078
+#line 3130
short *xp;
-#line 3078
+#line 3130
int nrange = 0; /* number of range errors */
-#line 3078
+#line 3130
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3078
+#line 3130
long cxp = (long) *((char**)xpp);
-#line 3078
+#line 3130
-#line 3078
+#line 3130
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3078
+#line 3130
/* sjl: manually stripmine so we can limit amount of
-#line 3078
+#line 3130
* vector work space reserved to LOOPCNT elements. Also
-#line 3078
+#line 3130
* makes vectorisation easy */
-#line 3078
+#line 3130
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3078
+#line 3130
ni=Min(nelems-j,LOOPCNT);
-#line 3078
+#line 3130
if (realign) {
-#line 3078
+#line 3130
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3078
+#line 3130
xp = tmp;
-#line 3078
+#line 3130
} else {
-#line 3078
+#line 3130
xp = (short *) *xpp;
-#line 3078
+#line 3130
}
-#line 3078
+#line 3130
/* copy the next block */
-#line 3078
+#line 3130
#pragma cdir loopcnt=LOOPCNT
-#line 3078
+#line 3130
#pragma cdir shortloop
-#line 3078
+#line 3130
for (i=0; i<ni; i++) {
-#line 3078
+#line 3130
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3078
+#line 3130
/* test for range errors (not always needed but do it anyway) */
-#line 3078
+#line 3130
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3078
+#line 3130
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3078
+#line 3130
nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
-#line 3078
+#line 3130
}
-#line 3078
+#line 3130
/* update xpp and tp */
-#line 3078
+#line 3130
if (realign) xp = (short *) *xpp;
-#line 3078
+#line 3130
xp += ni;
-#line 3078
+#line 3130
tp += ni;
-#line 3078
+#line 3130
*xpp = (void*)xp;
-#line 3078
+#line 3130
}
-#line 3078
+#line 3130
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3078
+#line 3130
-#line 3078
+#line 3130
#else /* not SX */
-#line 3078
+#line 3130
const char *xp = (const char *) *xpp;
-#line 3078
+#line 3130
int status = NC_NOERR;
-#line 3078
+#line 3130
-#line 3078
+#line 3130
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3078
+#line 3130
{
-#line 3078
+#line 3130
const int lstatus = ncx_get_short_float(xp, tp);
-#line 3078
+#line 3130
if (status == NC_NOERR) /* report the first encountered error */
-#line 3078
+#line 3130
status = lstatus;
-#line 3078
+#line 3130
}
-#line 3078
+#line 3130
-#line 3078
+#line 3130
*xpp = (const void *)xp;
-#line 3078
+#line 3130
return status;
-#line 3078
+#line 3130
#endif
-#line 3078
+#line 3130
}
-#line 3078
+#line 3130
int
-#line 3079
+#line 3131
ncx_getn_short_double(const void **xpp, size_t nelems, double *tp)
-#line 3079
+#line 3131
{
-#line 3079
+#line 3131
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3079
+#line 3131
-#line 3079
+#line 3131
/* basic algorithm is:
-#line 3079
+#line 3131
* - ensure sane alignment of input data
-#line 3079
+#line 3131
* - copy (conversion happens automatically) input data
-#line 3079
+#line 3131
* to output
-#line 3079
+#line 3131
* - update xpp to point at next unconverted input, and tp to point
-#line 3079
+#line 3131
* at next location for converted output
-#line 3079
+#line 3131
*/
-#line 3079
+#line 3131
long i, j, ni;
-#line 3079
+#line 3131
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3079
+#line 3131
short *xp;
-#line 3079
+#line 3131
int nrange = 0; /* number of range errors */
-#line 3079
+#line 3131
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3079
+#line 3131
long cxp = (long) *((char**)xpp);
-#line 3079
+#line 3131
-#line 3079
+#line 3131
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3079
+#line 3131
/* sjl: manually stripmine so we can limit amount of
-#line 3079
+#line 3131
* vector work space reserved to LOOPCNT elements. Also
-#line 3079
+#line 3131
* makes vectorisation easy */
-#line 3079
+#line 3131
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3079
+#line 3131
ni=Min(nelems-j,LOOPCNT);
-#line 3079
+#line 3131
if (realign) {
-#line 3079
+#line 3131
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3079
+#line 3131
xp = tmp;
-#line 3079
+#line 3131
} else {
-#line 3079
+#line 3131
xp = (short *) *xpp;
-#line 3079
+#line 3131
}
-#line 3079
+#line 3131
/* copy the next block */
-#line 3079
+#line 3131
#pragma cdir loopcnt=LOOPCNT
-#line 3079
+#line 3131
#pragma cdir shortloop
-#line 3079
+#line 3131
for (i=0; i<ni; i++) {
-#line 3079
+#line 3131
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3079
+#line 3131
/* test for range errors (not always needed but do it anyway) */
-#line 3079
+#line 3131
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3079
+#line 3131
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3079
+#line 3131
nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
-#line 3079
+#line 3131
}
-#line 3079
+#line 3131
/* update xpp and tp */
-#line 3079
+#line 3131
if (realign) xp = (short *) *xpp;
-#line 3079
+#line 3131
xp += ni;
-#line 3079
+#line 3131
tp += ni;
-#line 3079
+#line 3131
*xpp = (void*)xp;
-#line 3079
+#line 3131
}
-#line 3079
+#line 3131
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3079
+#line 3131
-#line 3079
+#line 3131
#else /* not SX */
-#line 3079
+#line 3131
const char *xp = (const char *) *xpp;
-#line 3079
+#line 3131
int status = NC_NOERR;
-#line 3079
+#line 3131
-#line 3079
+#line 3131
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3079
+#line 3131
{
-#line 3079
+#line 3131
const int lstatus = ncx_get_short_double(xp, tp);
-#line 3079
+#line 3131
if (status == NC_NOERR) /* report the first encountered error */
-#line 3079
+#line 3131
status = lstatus;
-#line 3079
+#line 3131
}
-#line 3079
+#line 3131
-#line 3079
+#line 3131
*xpp = (const void *)xp;
-#line 3079
+#line 3131
return status;
-#line 3079
+#line 3131
#endif
-#line 3079
+#line 3131
}
-#line 3079
+#line 3131
int
-#line 3080
+#line 3132
ncx_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3080
+#line 3132
{
-#line 3080
+#line 3132
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3080
+#line 3132
-#line 3080
+#line 3132
/* basic algorithm is:
-#line 3080
+#line 3132
* - ensure sane alignment of input data
-#line 3080
+#line 3132
* - copy (conversion happens automatically) input data
-#line 3080
+#line 3132
* to output
-#line 3080
+#line 3132
* - update xpp to point at next unconverted input, and tp to point
-#line 3080
+#line 3132
* at next location for converted output
-#line 3080
+#line 3132
*/
-#line 3080
+#line 3132
long i, j, ni;
-#line 3080
+#line 3132
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3080
+#line 3132
short *xp;
-#line 3080
+#line 3132
int nrange = 0; /* number of range errors */
-#line 3080
+#line 3132
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3080
+#line 3132
long cxp = (long) *((char**)xpp);
-#line 3080
+#line 3132
-#line 3080
+#line 3132
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3080
+#line 3132
/* sjl: manually stripmine so we can limit amount of
-#line 3080
+#line 3132
* vector work space reserved to LOOPCNT elements. Also
-#line 3080
+#line 3132
* makes vectorisation easy */
-#line 3080
+#line 3132
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3080
+#line 3132
ni=Min(nelems-j,LOOPCNT);
-#line 3080
+#line 3132
if (realign) {
-#line 3080
+#line 3132
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3080
+#line 3132
xp = tmp;
-#line 3080
+#line 3132
} else {
-#line 3080
+#line 3132
xp = (short *) *xpp;
-#line 3080
+#line 3132
}
-#line 3080
+#line 3132
/* copy the next block */
-#line 3080
+#line 3132
#pragma cdir loopcnt=LOOPCNT
-#line 3080
+#line 3132
#pragma cdir shortloop
-#line 3080
+#line 3132
for (i=0; i<ni; i++) {
-#line 3080
+#line 3132
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3080
+#line 3132
/* test for range errors (not always needed but do it anyway) */
-#line 3080
+#line 3132
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3080
+#line 3132
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3080
+#line 3132
nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
-#line 3080
+#line 3132
}
-#line 3080
+#line 3132
/* update xpp and tp */
-#line 3080
+#line 3132
if (realign) xp = (short *) *xpp;
-#line 3080
+#line 3132
xp += ni;
-#line 3080
+#line 3132
tp += ni;
-#line 3080
+#line 3132
*xpp = (void*)xp;
-#line 3080
+#line 3132
}
-#line 3080
+#line 3132
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3080
+#line 3132
-#line 3080
+#line 3132
#else /* not SX */
-#line 3080
+#line 3132
const char *xp = (const char *) *xpp;
-#line 3080
+#line 3132
int status = NC_NOERR;
-#line 3080
+#line 3132
-#line 3080
+#line 3132
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3080
+#line 3132
{
-#line 3080
+#line 3132
const int lstatus = ncx_get_short_longlong(xp, tp);
-#line 3080
+#line 3132
if (status == NC_NOERR) /* report the first encountered error */
-#line 3080
+#line 3132
status = lstatus;
-#line 3080
+#line 3132
}
-#line 3080
+#line 3132
-#line 3080
+#line 3132
*xpp = (const void *)xp;
-#line 3080
+#line 3132
return status;
-#line 3080
+#line 3132
#endif
-#line 3080
+#line 3132
}
-#line 3080
+#line 3132
int
-#line 3081
+#line 3133
ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3081
+#line 3133
{
-#line 3081
+#line 3133
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3081
+#line 3133
-#line 3081
+#line 3133
/* basic algorithm is:
-#line 3081
+#line 3133
* - ensure sane alignment of input data
-#line 3081
+#line 3133
* - copy (conversion happens automatically) input data
-#line 3081
+#line 3133
* to output
-#line 3081
+#line 3133
* - update xpp to point at next unconverted input, and tp to point
-#line 3081
+#line 3133
* at next location for converted output
-#line 3081
+#line 3133
*/
-#line 3081
+#line 3133
long i, j, ni;
-#line 3081
+#line 3133
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3081
+#line 3133
short *xp;
-#line 3081
+#line 3133
int nrange = 0; /* number of range errors */
-#line 3081
+#line 3133
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3081
+#line 3133
long cxp = (long) *((char**)xpp);
-#line 3081
+#line 3133
-#line 3081
+#line 3133
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3081
+#line 3133
/* sjl: manually stripmine so we can limit amount of
-#line 3081
+#line 3133
* vector work space reserved to LOOPCNT elements. Also
-#line 3081
+#line 3133
* makes vectorisation easy */
-#line 3081
+#line 3133
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3081
+#line 3133
ni=Min(nelems-j,LOOPCNT);
-#line 3081
+#line 3133
if (realign) {
-#line 3081
+#line 3133
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3081
+#line 3133
xp = tmp;
-#line 3081
+#line 3133
} else {
-#line 3081
+#line 3133
xp = (short *) *xpp;
-#line 3081
+#line 3133
}
-#line 3081
+#line 3133
/* copy the next block */
-#line 3081
+#line 3133
#pragma cdir loopcnt=LOOPCNT
-#line 3081
+#line 3133
#pragma cdir shortloop
-#line 3081
+#line 3133
for (i=0; i<ni; i++) {
-#line 3081
+#line 3133
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3081
+#line 3133
/* test for range errors (not always needed but do it anyway) */
-#line 3081
+#line 3133
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3081
+#line 3133
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3081
+#line 3133
nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
-#line 3081
+#line 3133
}
-#line 3081
+#line 3133
/* update xpp and tp */
-#line 3081
+#line 3133
if (realign) xp = (short *) *xpp;
-#line 3081
+#line 3133
xp += ni;
-#line 3081
+#line 3133
tp += ni;
-#line 3081
+#line 3133
*xpp = (void*)xp;
-#line 3081
+#line 3133
}
-#line 3081
+#line 3133
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3081
+#line 3133
-#line 3081
+#line 3133
#else /* not SX */
-#line 3081
+#line 3133
const char *xp = (const char *) *xpp;
-#line 3081
+#line 3133
int status = NC_NOERR;
-#line 3081
+#line 3133
-#line 3081
+#line 3133
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3081
+#line 3133
{
-#line 3081
+#line 3133
const int lstatus = ncx_get_short_uchar(xp, tp);
-#line 3081
+#line 3133
if (status == NC_NOERR) /* report the first encountered error */
-#line 3081
+#line 3133
status = lstatus;
-#line 3081
+#line 3133
}
-#line 3081
+#line 3133
-#line 3081
+#line 3133
*xpp = (const void *)xp;
-#line 3081
+#line 3133
return status;
-#line 3081
+#line 3133
#endif
-#line 3081
+#line 3133
}
-#line 3081
+#line 3133
int
-#line 3082
+#line 3134
ncx_getn_short_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3082
+#line 3134
{
-#line 3082
+#line 3134
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3082
+#line 3134
-#line 3082
+#line 3134
/* basic algorithm is:
-#line 3082
+#line 3134
* - ensure sane alignment of input data
-#line 3082
+#line 3134
* - copy (conversion happens automatically) input data
-#line 3082
+#line 3134
* to output
-#line 3082
+#line 3134
* - update xpp to point at next unconverted input, and tp to point
-#line 3082
+#line 3134
* at next location for converted output
-#line 3082
+#line 3134
*/
-#line 3082
+#line 3134
long i, j, ni;
-#line 3082
+#line 3134
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3082
+#line 3134
short *xp;
-#line 3082
+#line 3134
int nrange = 0; /* number of range errors */
-#line 3082
+#line 3134
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3082
+#line 3134
long cxp = (long) *((char**)xpp);
-#line 3082
+#line 3134
-#line 3082
+#line 3134
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3082
+#line 3134
/* sjl: manually stripmine so we can limit amount of
-#line 3082
+#line 3134
* vector work space reserved to LOOPCNT elements. Also
-#line 3082
+#line 3134
* makes vectorisation easy */
-#line 3082
+#line 3134
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3082
+#line 3134
ni=Min(nelems-j,LOOPCNT);
-#line 3082
+#line 3134
if (realign) {
-#line 3082
+#line 3134
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3082
+#line 3134
xp = tmp;
-#line 3082
+#line 3134
} else {
-#line 3082
+#line 3134
xp = (short *) *xpp;
-#line 3082
+#line 3134
}
-#line 3082
+#line 3134
/* copy the next block */
-#line 3082
+#line 3134
#pragma cdir loopcnt=LOOPCNT
-#line 3082
+#line 3134
#pragma cdir shortloop
-#line 3082
+#line 3134
for (i=0; i<ni; i++) {
-#line 3082
+#line 3134
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3082
+#line 3134
/* test for range errors (not always needed but do it anyway) */
-#line 3082
+#line 3134
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3082
+#line 3134
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3082
+#line 3134
nrange += xp[i] > USHORT_MAX || xp[i] < 0;
-#line 3082
+#line 3134
}
-#line 3082
+#line 3134
/* update xpp and tp */
-#line 3082
+#line 3134
if (realign) xp = (short *) *xpp;
-#line 3082
+#line 3134
xp += ni;
-#line 3082
+#line 3134
tp += ni;
-#line 3082
+#line 3134
*xpp = (void*)xp;
-#line 3082
+#line 3134
}
-#line 3082
+#line 3134
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3082
+#line 3134
-#line 3082
+#line 3134
#else /* not SX */
-#line 3082
+#line 3134
const char *xp = (const char *) *xpp;
-#line 3082
+#line 3134
int status = NC_NOERR;
-#line 3082
+#line 3134
-#line 3082
+#line 3134
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3082
+#line 3134
{
-#line 3082
+#line 3134
const int lstatus = ncx_get_short_ushort(xp, tp);
-#line 3082
+#line 3134
if (status == NC_NOERR) /* report the first encountered error */
-#line 3082
+#line 3134
status = lstatus;
-#line 3082
+#line 3134
}
-#line 3082
+#line 3134
-#line 3082
+#line 3134
*xpp = (const void *)xp;
-#line 3082
+#line 3134
return status;
-#line 3082
+#line 3134
#endif
-#line 3082
+#line 3134
}
-#line 3082
+#line 3134
int
-#line 3083
+#line 3135
ncx_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3083
+#line 3135
{
-#line 3083
+#line 3135
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3083
+#line 3135
-#line 3083
+#line 3135
/* basic algorithm is:
-#line 3083
+#line 3135
* - ensure sane alignment of input data
-#line 3083
+#line 3135
* - copy (conversion happens automatically) input data
-#line 3083
+#line 3135
* to output
-#line 3083
+#line 3135
* - update xpp to point at next unconverted input, and tp to point
-#line 3083
+#line 3135
* at next location for converted output
-#line 3083
+#line 3135
*/
-#line 3083
+#line 3135
long i, j, ni;
-#line 3083
+#line 3135
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3083
+#line 3135
short *xp;
-#line 3083
+#line 3135
int nrange = 0; /* number of range errors */
-#line 3083
+#line 3135
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3083
+#line 3135
long cxp = (long) *((char**)xpp);
-#line 3083
+#line 3135
-#line 3083
+#line 3135
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3083
+#line 3135
/* sjl: manually stripmine so we can limit amount of
-#line 3083
+#line 3135
* vector work space reserved to LOOPCNT elements. Also
-#line 3083
+#line 3135
* makes vectorisation easy */
-#line 3083
+#line 3135
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3083
+#line 3135
ni=Min(nelems-j,LOOPCNT);
-#line 3083
+#line 3135
if (realign) {
-#line 3083
+#line 3135
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3083
+#line 3135
xp = tmp;
-#line 3083
+#line 3135
} else {
-#line 3083
+#line 3135
xp = (short *) *xpp;
-#line 3083
+#line 3135
}
-#line 3083
+#line 3135
/* copy the next block */
-#line 3083
+#line 3135
#pragma cdir loopcnt=LOOPCNT
-#line 3083
+#line 3135
#pragma cdir shortloop
-#line 3083
+#line 3135
for (i=0; i<ni; i++) {
-#line 3083
+#line 3135
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3083
+#line 3135
/* test for range errors (not always needed but do it anyway) */
-#line 3083
+#line 3135
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3083
+#line 3135
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3083
+#line 3135
nrange += xp[i] > UINT_MAX || xp[i] < 0;
-#line 3083
+#line 3135
}
-#line 3083
+#line 3135
/* update xpp and tp */
-#line 3083
+#line 3135
if (realign) xp = (short *) *xpp;
-#line 3083
+#line 3135
xp += ni;
-#line 3083
+#line 3135
tp += ni;
-#line 3083
+#line 3135
*xpp = (void*)xp;
-#line 3083
+#line 3135
}
-#line 3083
+#line 3135
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3083
+#line 3135
-#line 3083
+#line 3135
#else /* not SX */
-#line 3083
+#line 3135
const char *xp = (const char *) *xpp;
-#line 3083
+#line 3135
int status = NC_NOERR;
-#line 3083
+#line 3135
-#line 3083
+#line 3135
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3083
+#line 3135
{
-#line 3083
+#line 3135
const int lstatus = ncx_get_short_uint(xp, tp);
-#line 3083
+#line 3135
if (status == NC_NOERR) /* report the first encountered error */
-#line 3083
+#line 3135
status = lstatus;
-#line 3083
+#line 3135
}
-#line 3083
+#line 3135
-#line 3083
+#line 3135
*xpp = (const void *)xp;
-#line 3083
+#line 3135
return status;
-#line 3083
+#line 3135
#endif
-#line 3083
+#line 3135
}
-#line 3083
+#line 3135
int
-#line 3084
+#line 3136
ncx_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3084
+#line 3136
{
-#line 3084
+#line 3136
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3084
+#line 3136
-#line 3084
+#line 3136
/* basic algorithm is:
-#line 3084
+#line 3136
* - ensure sane alignment of input data
-#line 3084
+#line 3136
* - copy (conversion happens automatically) input data
-#line 3084
+#line 3136
* to output
-#line 3084
+#line 3136
* - update xpp to point at next unconverted input, and tp to point
-#line 3084
+#line 3136
* at next location for converted output
-#line 3084
+#line 3136
*/
-#line 3084
+#line 3136
long i, j, ni;
-#line 3084
+#line 3136
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3084
+#line 3136
short *xp;
-#line 3084
+#line 3136
int nrange = 0; /* number of range errors */
-#line 3084
+#line 3136
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3084
+#line 3136
long cxp = (long) *((char**)xpp);
-#line 3084
+#line 3136
-#line 3084
+#line 3136
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3084
+#line 3136
/* sjl: manually stripmine so we can limit amount of
-#line 3084
+#line 3136
* vector work space reserved to LOOPCNT elements. Also
-#line 3084
+#line 3136
* makes vectorisation easy */
-#line 3084
+#line 3136
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3084
+#line 3136
ni=Min(nelems-j,LOOPCNT);
-#line 3084
+#line 3136
if (realign) {
-#line 3084
+#line 3136
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_SHORT));
-#line 3084
+#line 3136
xp = tmp;
-#line 3084
+#line 3136
} else {
-#line 3084
+#line 3136
xp = (short *) *xpp;
-#line 3084
+#line 3136
}
-#line 3084
+#line 3136
/* copy the next block */
-#line 3084
+#line 3136
#pragma cdir loopcnt=LOOPCNT
-#line 3084
+#line 3136
#pragma cdir shortloop
-#line 3084
+#line 3136
for (i=0; i<ni; i++) {
-#line 3084
+#line 3136
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3084
+#line 3136
/* test for range errors (not always needed but do it anyway) */
-#line 3084
+#line 3136
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3084
+#line 3136
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3084
+#line 3136
nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
-#line 3084
+#line 3136
}
-#line 3084
+#line 3136
/* update xpp and tp */
-#line 3084
+#line 3136
if (realign) xp = (short *) *xpp;
-#line 3084
+#line 3136
xp += ni;
-#line 3084
+#line 3136
tp += ni;
-#line 3084
+#line 3136
*xpp = (void*)xp;
-#line 3084
+#line 3136
}
-#line 3084
+#line 3136
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3084
+#line 3136
-#line 3084
+#line 3136
#else /* not SX */
-#line 3084
+#line 3136
const char *xp = (const char *) *xpp;
-#line 3084
+#line 3136
int status = NC_NOERR;
-#line 3084
+#line 3136
-#line 3084
+#line 3136
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3084
+#line 3136
{
-#line 3084
+#line 3136
const int lstatus = ncx_get_short_ulonglong(xp, tp);
-#line 3084
+#line 3136
if (status == NC_NOERR) /* report the first encountered error */
-#line 3084
+#line 3136
status = lstatus;
-#line 3084
+#line 3136
}
-#line 3084
+#line 3136
-#line 3084
+#line 3136
*xpp = (const void *)xp;
-#line 3084
+#line 3136
return status;
-#line 3084
+#line 3136
#endif
-#line 3084
+#line 3136
}
-#line 3084
+#line 3136
int
-#line 3086
+#line 3138
ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3086
+#line 3138
{
-#line 3086
+#line 3138
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3086
+#line 3138
-#line 3086
+#line 3138
const char *xp = (const char *) *xpp;
-#line 3086
+#line 3138
int status = NC_NOERR;
-#line 3086
+#line 3138
-#line 3086
+#line 3138
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3086
+#line 3138
{
-#line 3086
+#line 3138
const int lstatus = ncx_get_short_schar(xp, tp);
-#line 3086
+#line 3138
if (status == NC_NOERR) /* report the first encountered error */
-#line 3086
+#line 3138
status = lstatus;
-#line 3086
+#line 3138
}
-#line 3086
+#line 3138
-#line 3086
+#line 3138
if (rndup != 0)
-#line 3086
+#line 3138
xp += X_SIZEOF_SHORT;
-#line 3086
+#line 3138
-#line 3086
+#line 3138
*xpp = (void *)xp;
-#line 3086
+#line 3138
return status;
-#line 3086
+#line 3138
}
-#line 3086
+#line 3138
int
-#line 3087
+#line 3139
ncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3087
+#line 3139
{
-#line 3087
+#line 3139
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3087
+#line 3139
-#line 3087
+#line 3139
const char *xp = (const char *) *xpp;
-#line 3087
+#line 3139
int status = NC_NOERR;
-#line 3087
+#line 3139
-#line 3087
+#line 3139
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3087
+#line 3139
{
-#line 3087
+#line 3139
const int lstatus = ncx_get_short_uchar(xp, tp);
-#line 3087
+#line 3139
if (status == NC_NOERR) /* report the first encountered error */
-#line 3087
+#line 3139
status = lstatus;
-#line 3087
+#line 3139
}
-#line 3087
+#line 3139
-#line 3087
+#line 3139
if (rndup != 0)
-#line 3087
+#line 3139
xp += X_SIZEOF_SHORT;
-#line 3087
+#line 3139
-#line 3087
+#line 3139
*xpp = (void *)xp;
-#line 3087
+#line 3139
return status;
-#line 3087
+#line 3139
}
-#line 3087
+#line 3139
int
-#line 3088
+#line 3140
ncx_pad_getn_short_short(const void **xpp, size_t nelems, short *tp)
-#line 3088
+#line 3140
{
-#line 3088
+#line 3140
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3088
+#line 3140
-#line 3088
+#line 3140
const char *xp = (const char *) *xpp;
-#line 3088
+#line 3140
int status = NC_NOERR;
-#line 3088
+#line 3140
-#line 3088
+#line 3140
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3088
+#line 3140
{
-#line 3088
+#line 3140
const int lstatus = ncx_get_short_short(xp, tp);
-#line 3088
+#line 3140
if (status == NC_NOERR) /* report the first encountered error */
-#line 3088
+#line 3140
status = lstatus;
-#line 3088
+#line 3140
}
-#line 3088
+#line 3140
-#line 3088
+#line 3140
if (rndup != 0)
-#line 3088
+#line 3140
xp += X_SIZEOF_SHORT;
-#line 3088
+#line 3140
-#line 3088
+#line 3140
*xpp = (void *)xp;
-#line 3088
+#line 3140
return status;
-#line 3088
+#line 3140
}
-#line 3088
+#line 3140
int
-#line 3089
+#line 3141
ncx_pad_getn_short_int(const void **xpp, size_t nelems, int *tp)
-#line 3089
+#line 3141
{
-#line 3089
+#line 3141
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3089
+#line 3141
-#line 3089
+#line 3141
const char *xp = (const char *) *xpp;
-#line 3089
+#line 3141
int status = NC_NOERR;
-#line 3089
+#line 3141
-#line 3089
+#line 3141
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3089
+#line 3141
{
-#line 3089
+#line 3141
const int lstatus = ncx_get_short_int(xp, tp);
-#line 3089
+#line 3141
if (status == NC_NOERR) /* report the first encountered error */
-#line 3089
+#line 3141
status = lstatus;
-#line 3089
+#line 3141
}
-#line 3089
+#line 3141
-#line 3089
+#line 3141
if (rndup != 0)
-#line 3089
+#line 3141
xp += X_SIZEOF_SHORT;
-#line 3089
+#line 3141
-#line 3089
+#line 3141
*xpp = (void *)xp;
-#line 3089
+#line 3141
return status;
-#line 3089
+#line 3141
}
-#line 3089
+#line 3141
int
-#line 3090
+#line 3142
ncx_pad_getn_short_long(const void **xpp, size_t nelems, long *tp)
-#line 3090
+#line 3142
{
-#line 3090
+#line 3142
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3090
+#line 3142
-#line 3090
+#line 3142
const char *xp = (const char *) *xpp;
-#line 3090
+#line 3142
int status = NC_NOERR;
-#line 3090
+#line 3142
-#line 3090
+#line 3142
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3090
+#line 3142
{
-#line 3090
+#line 3142
const int lstatus = ncx_get_short_long(xp, tp);
-#line 3090
+#line 3142
if (status == NC_NOERR) /* report the first encountered error */
-#line 3090
+#line 3142
status = lstatus;
-#line 3090
+#line 3142
}
-#line 3090
+#line 3142
-#line 3090
+#line 3142
if (rndup != 0)
-#line 3090
+#line 3142
xp += X_SIZEOF_SHORT;
-#line 3090
+#line 3142
-#line 3090
+#line 3142
*xpp = (void *)xp;
-#line 3090
+#line 3142
return status;
-#line 3090
+#line 3142
}
-#line 3090
+#line 3142
int
-#line 3091
+#line 3143
ncx_pad_getn_short_float(const void **xpp, size_t nelems, float *tp)
-#line 3091
+#line 3143
{
-#line 3091
+#line 3143
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3091
+#line 3143
-#line 3091
+#line 3143
const char *xp = (const char *) *xpp;
-#line 3091
+#line 3143
int status = NC_NOERR;
-#line 3091
+#line 3143
-#line 3091
+#line 3143
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3091
+#line 3143
{
-#line 3091
+#line 3143
const int lstatus = ncx_get_short_float(xp, tp);
-#line 3091
+#line 3143
if (status == NC_NOERR) /* report the first encountered error */
-#line 3091
+#line 3143
status = lstatus;
-#line 3091
+#line 3143
}
-#line 3091
+#line 3143
-#line 3091
+#line 3143
if (rndup != 0)
-#line 3091
+#line 3143
xp += X_SIZEOF_SHORT;
-#line 3091
+#line 3143
-#line 3091
+#line 3143
*xpp = (void *)xp;
-#line 3091
+#line 3143
return status;
-#line 3091
+#line 3143
}
-#line 3091
+#line 3143
int
-#line 3092
+#line 3144
ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *tp)
-#line 3092
+#line 3144
{
-#line 3092
+#line 3144
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3092
+#line 3144
-#line 3092
+#line 3144
const char *xp = (const char *) *xpp;
-#line 3092
+#line 3144
int status = NC_NOERR;
-#line 3092
+#line 3144
-#line 3092
+#line 3144
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3092
+#line 3144
{
-#line 3092
+#line 3144
const int lstatus = ncx_get_short_double(xp, tp);
-#line 3092
+#line 3144
if (status == NC_NOERR) /* report the first encountered error */
-#line 3092
+#line 3144
status = lstatus;
-#line 3092
+#line 3144
}
-#line 3092
+#line 3144
-#line 3092
+#line 3144
if (rndup != 0)
-#line 3092
+#line 3144
xp += X_SIZEOF_SHORT;
-#line 3092
+#line 3144
-#line 3092
+#line 3144
*xpp = (void *)xp;
-#line 3092
+#line 3144
return status;
-#line 3092
+#line 3144
}
-#line 3092
+#line 3144
int
-#line 3093
+#line 3145
ncx_pad_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3093
+#line 3145
{
-#line 3093
+#line 3145
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3093
+#line 3145
-#line 3093
+#line 3145
const char *xp = (const char *) *xpp;
-#line 3093
+#line 3145
int status = NC_NOERR;
-#line 3093
+#line 3145
-#line 3093
+#line 3145
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3093
+#line 3145
{
-#line 3093
+#line 3145
const int lstatus = ncx_get_short_uint(xp, tp);
-#line 3093
+#line 3145
if (status == NC_NOERR) /* report the first encountered error */
-#line 3093
+#line 3145
status = lstatus;
-#line 3093
+#line 3145
}
-#line 3093
+#line 3145
-#line 3093
+#line 3145
if (rndup != 0)
-#line 3093
+#line 3145
xp += X_SIZEOF_SHORT;
-#line 3093
+#line 3145
-#line 3093
+#line 3145
*xpp = (void *)xp;
-#line 3093
+#line 3145
return status;
-#line 3093
+#line 3145
}
-#line 3093
+#line 3145
int
-#line 3094
+#line 3146
ncx_pad_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3094
+#line 3146
{
-#line 3094
+#line 3146
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3094
+#line 3146
-#line 3094
+#line 3146
const char *xp = (const char *) *xpp;
-#line 3094
+#line 3146
int status = NC_NOERR;
-#line 3094
+#line 3146
-#line 3094
+#line 3146
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3094
+#line 3146
{
-#line 3094
+#line 3146
const int lstatus = ncx_get_short_longlong(xp, tp);
-#line 3094
+#line 3146
if (status == NC_NOERR) /* report the first encountered error */
-#line 3094
+#line 3146
status = lstatus;
-#line 3094
+#line 3146
}
-#line 3094
+#line 3146
-#line 3094
+#line 3146
if (rndup != 0)
-#line 3094
+#line 3146
xp += X_SIZEOF_SHORT;
-#line 3094
+#line 3146
-#line 3094
+#line 3146
*xpp = (void *)xp;
-#line 3094
+#line 3146
return status;
-#line 3094
+#line 3146
}
-#line 3094
+#line 3146
int
-#line 3095
+#line 3147
ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3095
+#line 3147
{
-#line 3095
+#line 3147
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3095
+#line 3147
-#line 3095
+#line 3147
const char *xp = (const char *) *xpp;
-#line 3095
+#line 3147
int status = NC_NOERR;
-#line 3095
+#line 3147
-#line 3095
+#line 3147
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3095
+#line 3147
{
-#line 3095
+#line 3147
const int lstatus = ncx_get_short_ulonglong(xp, tp);
-#line 3095
+#line 3147
if (status == NC_NOERR) /* report the first encountered error */
-#line 3095
+#line 3147
status = lstatus;
-#line 3095
+#line 3147
}
-#line 3095
+#line 3147
-#line 3095
+#line 3147
if (rndup != 0)
-#line 3095
+#line 3147
xp += X_SIZEOF_SHORT;
-#line 3095
+#line 3147
-#line 3095
+#line 3147
*xpp = (void *)xp;
-#line 3095
+#line 3147
return status;
-#line 3095
+#line 3147
}
-#line 3095
+#line 3147
int
-#line 3096
+#line 3148
ncx_pad_getn_short_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3096
+#line 3148
{
-#line 3096
+#line 3148
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3096
+#line 3148
-#line 3096
+#line 3148
const char *xp = (const char *) *xpp;
-#line 3096
+#line 3148
int status = NC_NOERR;
-#line 3096
+#line 3148
-#line 3096
+#line 3148
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3096
+#line 3148
{
-#line 3096
+#line 3148
const int lstatus = ncx_get_short_ushort(xp, tp);
-#line 3096
+#line 3148
if (status == NC_NOERR) /* report the first encountered error */
-#line 3096
+#line 3148
status = lstatus;
-#line 3096
+#line 3148
}
-#line 3096
+#line 3148
-#line 3096
+#line 3148
if (rndup != 0)
-#line 3096
+#line 3148
xp += X_SIZEOF_SHORT;
-#line 3096
+#line 3148
-#line 3096
+#line 3148
*xpp = (void *)xp;
-#line 3096
+#line 3148
return status;
-#line 3096
+#line 3148
}
-#line 3096
+#line 3148
#if X_SIZEOF_SHORT == SIZEOF_SHORT
@@ -13335,2074 +15420,2074 @@ ncx_putn_short_short(void **xpp, size_t nelems, const short *tp, void *fillp)
}
#else
int
-#line 3112
+#line 3164
ncx_putn_short_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3112
+#line 3164
{
-#line 3112
+#line 3164
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3112
+#line 3164
-#line 3112
+#line 3164
/* basic algorithm is:
-#line 3112
+#line 3164
* - ensure sane alignment of output data
-#line 3112
+#line 3164
* - copy (conversion happens automatically) input data
-#line 3112
+#line 3164
* to output
-#line 3112
+#line 3164
* - update tp to point at next unconverted input, and xpp to point
-#line 3112
+#line 3164
* at next location for converted output
-#line 3112
+#line 3164
*/
-#line 3112
+#line 3164
long i, j, ni;
-#line 3112
+#line 3164
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3112
+#line 3164
short *xp;
-#line 3112
+#line 3164
int nrange = 0; /* number of range errors */
-#line 3112
+#line 3164
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3112
+#line 3164
long cxp = (long) *((char**)xpp);
-#line 3112
+#line 3164
-#line 3112
+#line 3164
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3112
+#line 3164
/* sjl: manually stripmine so we can limit amount of
-#line 3112
+#line 3164
* vector work space reserved to LOOPCNT elements. Also
-#line 3112
+#line 3164
* makes vectorisation easy */
-#line 3112
+#line 3164
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3112
+#line 3164
ni=Min(nelems-j,LOOPCNT);
-#line 3112
+#line 3164
if (realign) {
-#line 3112
+#line 3164
xp = tmp;
-#line 3112
+#line 3164
} else {
-#line 3112
+#line 3164
xp = (short *) *xpp;
-#line 3112
+#line 3164
}
-#line 3112
+#line 3164
/* copy the next block */
-#line 3112
+#line 3164
#pragma cdir loopcnt=LOOPCNT
-#line 3112
+#line 3164
#pragma cdir shortloop
-#line 3112
+#line 3164
for (i=0; i<ni; i++) {
-#line 3112
+#line 3164
/* the normal case: */
-#line 3112
+#line 3164
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3112
+#line 3164
/* test for range errors (not always needed but do it anyway) */
-#line 3112
+#line 3164
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3112
+#line 3164
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3112
+#line 3164
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3112
+#line 3164
}
-#line 3112
+#line 3164
/* copy workspace back if necessary */
-#line 3112
+#line 3164
if (realign) {
-#line 3112
+#line 3164
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3112
+#line 3164
xp = (short *) *xpp;
-#line 3112
+#line 3164
}
-#line 3112
+#line 3164
/* update xpp and tp */
-#line 3112
+#line 3164
xp += ni;
-#line 3112
+#line 3164
tp += ni;
-#line 3112
+#line 3164
*xpp = (void*)xp;
-#line 3112
+#line 3164
}
-#line 3112
+#line 3164
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3112
+#line 3164
-#line 3112
+#line 3164
#else /* not SX */
-#line 3112
+#line 3164
-#line 3112
+#line 3164
char *xp = (char *) *xpp;
-#line 3112
+#line 3164
int status = NC_NOERR;
-#line 3112
+#line 3164
-#line 3112
+#line 3164
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3112
+#line 3164
{
-#line 3112
+#line 3164
int lstatus = ncx_put_short_short(xp, tp, fillp);
-#line 3112
+#line 3164
if (status == NC_NOERR) /* report the first encountered error */
-#line 3112
+#line 3164
status = lstatus;
-#line 3112
+#line 3164
}
-#line 3112
+#line 3164
-#line 3112
+#line 3164
*xpp = (void *)xp;
-#line 3112
+#line 3164
return status;
-#line 3112
+#line 3164
#endif
-#line 3112
+#line 3164
}
-#line 3112
+#line 3164
#endif
int
-#line 3114
+#line 3166
ncx_putn_short_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3114
+#line 3166
{
-#line 3114
+#line 3166
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3114
+#line 3166
-#line 3114
+#line 3166
/* basic algorithm is:
-#line 3114
+#line 3166
* - ensure sane alignment of output data
-#line 3114
+#line 3166
* - copy (conversion happens automatically) input data
-#line 3114
+#line 3166
* to output
-#line 3114
+#line 3166
* - update tp to point at next unconverted input, and xpp to point
-#line 3114
+#line 3166
* at next location for converted output
-#line 3114
+#line 3166
*/
-#line 3114
+#line 3166
long i, j, ni;
-#line 3114
+#line 3166
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3114
+#line 3166
short *xp;
-#line 3114
+#line 3166
int nrange = 0; /* number of range errors */
-#line 3114
+#line 3166
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3114
+#line 3166
long cxp = (long) *((char**)xpp);
-#line 3114
+#line 3166
-#line 3114
+#line 3166
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3114
+#line 3166
/* sjl: manually stripmine so we can limit amount of
-#line 3114
+#line 3166
* vector work space reserved to LOOPCNT elements. Also
-#line 3114
+#line 3166
* makes vectorisation easy */
-#line 3114
+#line 3166
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3114
+#line 3166
ni=Min(nelems-j,LOOPCNT);
-#line 3114
+#line 3166
if (realign) {
-#line 3114
+#line 3166
xp = tmp;
-#line 3114
+#line 3166
} else {
-#line 3114
+#line 3166
xp = (short *) *xpp;
-#line 3114
+#line 3166
}
-#line 3114
+#line 3166
/* copy the next block */
-#line 3114
+#line 3166
#pragma cdir loopcnt=LOOPCNT
-#line 3114
+#line 3166
#pragma cdir shortloop
-#line 3114
+#line 3166
for (i=0; i<ni; i++) {
-#line 3114
+#line 3166
/* the normal case: */
-#line 3114
+#line 3166
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3114
+#line 3166
/* test for range errors (not always needed but do it anyway) */
-#line 3114
+#line 3166
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3114
+#line 3166
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3114
+#line 3166
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3114
+#line 3166
}
-#line 3114
+#line 3166
/* copy workspace back if necessary */
-#line 3114
+#line 3166
if (realign) {
-#line 3114
+#line 3166
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3114
+#line 3166
xp = (short *) *xpp;
-#line 3114
+#line 3166
}
-#line 3114
+#line 3166
/* update xpp and tp */
-#line 3114
+#line 3166
xp += ni;
-#line 3114
+#line 3166
tp += ni;
-#line 3114
+#line 3166
*xpp = (void*)xp;
-#line 3114
+#line 3166
}
-#line 3114
+#line 3166
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3114
+#line 3166
-#line 3114
+#line 3166
#else /* not SX */
-#line 3114
+#line 3166
-#line 3114
+#line 3166
char *xp = (char *) *xpp;
-#line 3114
+#line 3166
int status = NC_NOERR;
-#line 3114
+#line 3166
-#line 3114
+#line 3166
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3114
+#line 3166
{
-#line 3114
+#line 3166
int lstatus = ncx_put_short_schar(xp, tp, fillp);
-#line 3114
+#line 3166
if (status == NC_NOERR) /* report the first encountered error */
-#line 3114
+#line 3166
status = lstatus;
-#line 3114
+#line 3166
}
-#line 3114
+#line 3166
-#line 3114
+#line 3166
*xpp = (void *)xp;
-#line 3114
+#line 3166
return status;
-#line 3114
+#line 3166
#endif
-#line 3114
+#line 3166
}
-#line 3114
+#line 3166
int
-#line 3115
+#line 3167
ncx_putn_short_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3115
+#line 3167
{
-#line 3115
+#line 3167
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3115
+#line 3167
-#line 3115
+#line 3167
/* basic algorithm is:
-#line 3115
+#line 3167
* - ensure sane alignment of output data
-#line 3115
+#line 3167
* - copy (conversion happens automatically) input data
-#line 3115
+#line 3167
* to output
-#line 3115
+#line 3167
* - update tp to point at next unconverted input, and xpp to point
-#line 3115
+#line 3167
* at next location for converted output
-#line 3115
+#line 3167
*/
-#line 3115
+#line 3167
long i, j, ni;
-#line 3115
+#line 3167
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3115
+#line 3167
short *xp;
-#line 3115
+#line 3167
int nrange = 0; /* number of range errors */
-#line 3115
+#line 3167
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3115
+#line 3167
long cxp = (long) *((char**)xpp);
-#line 3115
+#line 3167
-#line 3115
+#line 3167
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3115
+#line 3167
/* sjl: manually stripmine so we can limit amount of
-#line 3115
+#line 3167
* vector work space reserved to LOOPCNT elements. Also
-#line 3115
+#line 3167
* makes vectorisation easy */
-#line 3115
+#line 3167
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3115
+#line 3167
ni=Min(nelems-j,LOOPCNT);
-#line 3115
+#line 3167
if (realign) {
-#line 3115
+#line 3167
xp = tmp;
-#line 3115
+#line 3167
} else {
-#line 3115
+#line 3167
xp = (short *) *xpp;
-#line 3115
+#line 3167
}
-#line 3115
+#line 3167
/* copy the next block */
-#line 3115
+#line 3167
#pragma cdir loopcnt=LOOPCNT
-#line 3115
+#line 3167
#pragma cdir shortloop
-#line 3115
+#line 3167
for (i=0; i<ni; i++) {
-#line 3115
+#line 3167
/* the normal case: */
-#line 3115
+#line 3167
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3115
+#line 3167
/* test for range errors (not always needed but do it anyway) */
-#line 3115
+#line 3167
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3115
+#line 3167
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3115
+#line 3167
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3115
+#line 3167
}
-#line 3115
+#line 3167
/* copy workspace back if necessary */
-#line 3115
+#line 3167
if (realign) {
-#line 3115
+#line 3167
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3115
+#line 3167
xp = (short *) *xpp;
-#line 3115
+#line 3167
}
-#line 3115
+#line 3167
/* update xpp and tp */
-#line 3115
+#line 3167
xp += ni;
-#line 3115
+#line 3167
tp += ni;
-#line 3115
+#line 3167
*xpp = (void*)xp;
-#line 3115
+#line 3167
}
-#line 3115
+#line 3167
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3115
+#line 3167
-#line 3115
+#line 3167
#else /* not SX */
-#line 3115
+#line 3167
-#line 3115
+#line 3167
char *xp = (char *) *xpp;
-#line 3115
+#line 3167
int status = NC_NOERR;
-#line 3115
+#line 3167
-#line 3115
+#line 3167
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3115
+#line 3167
{
-#line 3115
+#line 3167
int lstatus = ncx_put_short_int(xp, tp, fillp);
-#line 3115
+#line 3167
if (status == NC_NOERR) /* report the first encountered error */
-#line 3115
+#line 3167
status = lstatus;
-#line 3115
+#line 3167
}
-#line 3115
+#line 3167
-#line 3115
+#line 3167
*xpp = (void *)xp;
-#line 3115
+#line 3167
return status;
-#line 3115
+#line 3167
#endif
-#line 3115
+#line 3167
}
-#line 3115
+#line 3167
int
-#line 3116
+#line 3168
ncx_putn_short_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3116
+#line 3168
{
-#line 3116
+#line 3168
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3116
+#line 3168
-#line 3116
+#line 3168
/* basic algorithm is:
-#line 3116
+#line 3168
* - ensure sane alignment of output data
-#line 3116
+#line 3168
* - copy (conversion happens automatically) input data
-#line 3116
+#line 3168
* to output
-#line 3116
+#line 3168
* - update tp to point at next unconverted input, and xpp to point
-#line 3116
+#line 3168
* at next location for converted output
-#line 3116
+#line 3168
*/
-#line 3116
+#line 3168
long i, j, ni;
-#line 3116
+#line 3168
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3116
+#line 3168
short *xp;
-#line 3116
+#line 3168
int nrange = 0; /* number of range errors */
-#line 3116
+#line 3168
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3116
+#line 3168
long cxp = (long) *((char**)xpp);
-#line 3116
+#line 3168
-#line 3116
+#line 3168
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3116
+#line 3168
/* sjl: manually stripmine so we can limit amount of
-#line 3116
+#line 3168
* vector work space reserved to LOOPCNT elements. Also
-#line 3116
+#line 3168
* makes vectorisation easy */
-#line 3116
+#line 3168
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3116
+#line 3168
ni=Min(nelems-j,LOOPCNT);
-#line 3116
+#line 3168
if (realign) {
-#line 3116
+#line 3168
xp = tmp;
-#line 3116
+#line 3168
} else {
-#line 3116
+#line 3168
xp = (short *) *xpp;
-#line 3116
+#line 3168
}
-#line 3116
+#line 3168
/* copy the next block */
-#line 3116
+#line 3168
#pragma cdir loopcnt=LOOPCNT
-#line 3116
+#line 3168
#pragma cdir shortloop
-#line 3116
+#line 3168
for (i=0; i<ni; i++) {
-#line 3116
+#line 3168
/* the normal case: */
-#line 3116
+#line 3168
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3116
+#line 3168
/* test for range errors (not always needed but do it anyway) */
-#line 3116
+#line 3168
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3116
+#line 3168
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3116
+#line 3168
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3116
+#line 3168
}
-#line 3116
+#line 3168
/* copy workspace back if necessary */
-#line 3116
+#line 3168
if (realign) {
-#line 3116
+#line 3168
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3116
+#line 3168
xp = (short *) *xpp;
-#line 3116
+#line 3168
}
-#line 3116
+#line 3168
/* update xpp and tp */
-#line 3116
+#line 3168
xp += ni;
-#line 3116
+#line 3168
tp += ni;
-#line 3116
+#line 3168
*xpp = (void*)xp;
-#line 3116
+#line 3168
}
-#line 3116
+#line 3168
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3116
+#line 3168
-#line 3116
+#line 3168
#else /* not SX */
-#line 3116
+#line 3168
-#line 3116
+#line 3168
char *xp = (char *) *xpp;
-#line 3116
+#line 3168
int status = NC_NOERR;
-#line 3116
+#line 3168
-#line 3116
+#line 3168
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3116
+#line 3168
{
-#line 3116
+#line 3168
int lstatus = ncx_put_short_long(xp, tp, fillp);
-#line 3116
+#line 3168
if (status == NC_NOERR) /* report the first encountered error */
-#line 3116
+#line 3168
status = lstatus;
-#line 3116
+#line 3168
}
-#line 3116
+#line 3168
-#line 3116
+#line 3168
*xpp = (void *)xp;
-#line 3116
+#line 3168
return status;
-#line 3116
+#line 3168
#endif
-#line 3116
+#line 3168
}
-#line 3116
+#line 3168
int
-#line 3117
+#line 3169
ncx_putn_short_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3117
+#line 3169
{
-#line 3117
+#line 3169
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3117
+#line 3169
-#line 3117
+#line 3169
/* basic algorithm is:
-#line 3117
+#line 3169
* - ensure sane alignment of output data
-#line 3117
+#line 3169
* - copy (conversion happens automatically) input data
-#line 3117
+#line 3169
* to output
-#line 3117
+#line 3169
* - update tp to point at next unconverted input, and xpp to point
-#line 3117
+#line 3169
* at next location for converted output
-#line 3117
+#line 3169
*/
-#line 3117
+#line 3169
long i, j, ni;
-#line 3117
+#line 3169
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3117
+#line 3169
short *xp;
-#line 3117
+#line 3169
int nrange = 0; /* number of range errors */
-#line 3117
+#line 3169
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3117
+#line 3169
long cxp = (long) *((char**)xpp);
-#line 3117
+#line 3169
-#line 3117
+#line 3169
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3117
+#line 3169
/* sjl: manually stripmine so we can limit amount of
-#line 3117
+#line 3169
* vector work space reserved to LOOPCNT elements. Also
-#line 3117
+#line 3169
* makes vectorisation easy */
-#line 3117
+#line 3169
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3117
+#line 3169
ni=Min(nelems-j,LOOPCNT);
-#line 3117
+#line 3169
if (realign) {
-#line 3117
+#line 3169
xp = tmp;
-#line 3117
+#line 3169
} else {
-#line 3117
+#line 3169
xp = (short *) *xpp;
-#line 3117
+#line 3169
}
-#line 3117
+#line 3169
/* copy the next block */
-#line 3117
+#line 3169
#pragma cdir loopcnt=LOOPCNT
-#line 3117
+#line 3169
#pragma cdir shortloop
-#line 3117
+#line 3169
for (i=0; i<ni; i++) {
-#line 3117
+#line 3169
/* the normal case: */
-#line 3117
+#line 3169
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3117
+#line 3169
/* test for range errors (not always needed but do it anyway) */
-#line 3117
+#line 3169
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3117
+#line 3169
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3117
+#line 3169
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3117
+#line 3169
}
-#line 3117
+#line 3169
/* copy workspace back if necessary */
-#line 3117
+#line 3169
if (realign) {
-#line 3117
+#line 3169
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3117
+#line 3169
xp = (short *) *xpp;
-#line 3117
+#line 3169
}
-#line 3117
+#line 3169
/* update xpp and tp */
-#line 3117
+#line 3169
xp += ni;
-#line 3117
+#line 3169
tp += ni;
-#line 3117
+#line 3169
*xpp = (void*)xp;
-#line 3117
+#line 3169
}
-#line 3117
+#line 3169
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3117
+#line 3169
-#line 3117
+#line 3169
#else /* not SX */
-#line 3117
+#line 3169
-#line 3117
+#line 3169
char *xp = (char *) *xpp;
-#line 3117
+#line 3169
int status = NC_NOERR;
-#line 3117
+#line 3169
-#line 3117
+#line 3169
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3117
+#line 3169
{
-#line 3117
+#line 3169
int lstatus = ncx_put_short_float(xp, tp, fillp);
-#line 3117
+#line 3169
if (status == NC_NOERR) /* report the first encountered error */
-#line 3117
+#line 3169
status = lstatus;
-#line 3117
+#line 3169
}
-#line 3117
+#line 3169
-#line 3117
+#line 3169
*xpp = (void *)xp;
-#line 3117
+#line 3169
return status;
-#line 3117
+#line 3169
#endif
-#line 3117
+#line 3169
}
-#line 3117
+#line 3169
int
-#line 3118
+#line 3170
ncx_putn_short_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3118
+#line 3170
{
-#line 3118
+#line 3170
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3118
+#line 3170
-#line 3118
+#line 3170
/* basic algorithm is:
-#line 3118
+#line 3170
* - ensure sane alignment of output data
-#line 3118
+#line 3170
* - copy (conversion happens automatically) input data
-#line 3118
+#line 3170
* to output
-#line 3118
+#line 3170
* - update tp to point at next unconverted input, and xpp to point
-#line 3118
+#line 3170
* at next location for converted output
-#line 3118
+#line 3170
*/
-#line 3118
+#line 3170
long i, j, ni;
-#line 3118
+#line 3170
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3118
+#line 3170
short *xp;
-#line 3118
+#line 3170
int nrange = 0; /* number of range errors */
-#line 3118
+#line 3170
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3118
+#line 3170
long cxp = (long) *((char**)xpp);
-#line 3118
+#line 3170
-#line 3118
+#line 3170
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3118
+#line 3170
/* sjl: manually stripmine so we can limit amount of
-#line 3118
+#line 3170
* vector work space reserved to LOOPCNT elements. Also
-#line 3118
+#line 3170
* makes vectorisation easy */
-#line 3118
+#line 3170
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3118
+#line 3170
ni=Min(nelems-j,LOOPCNT);
-#line 3118
+#line 3170
if (realign) {
-#line 3118
+#line 3170
xp = tmp;
-#line 3118
+#line 3170
} else {
-#line 3118
+#line 3170
xp = (short *) *xpp;
-#line 3118
+#line 3170
}
-#line 3118
+#line 3170
/* copy the next block */
-#line 3118
+#line 3170
#pragma cdir loopcnt=LOOPCNT
-#line 3118
+#line 3170
#pragma cdir shortloop
-#line 3118
+#line 3170
for (i=0; i<ni; i++) {
-#line 3118
+#line 3170
/* the normal case: */
-#line 3118
+#line 3170
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3118
+#line 3170
/* test for range errors (not always needed but do it anyway) */
-#line 3118
+#line 3170
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3118
+#line 3170
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3118
+#line 3170
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3118
+#line 3170
}
-#line 3118
+#line 3170
/* copy workspace back if necessary */
-#line 3118
+#line 3170
if (realign) {
-#line 3118
+#line 3170
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3118
+#line 3170
xp = (short *) *xpp;
-#line 3118
+#line 3170
}
-#line 3118
+#line 3170
/* update xpp and tp */
-#line 3118
+#line 3170
xp += ni;
-#line 3118
+#line 3170
tp += ni;
-#line 3118
+#line 3170
*xpp = (void*)xp;
-#line 3118
+#line 3170
}
-#line 3118
+#line 3170
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3118
+#line 3170
-#line 3118
+#line 3170
#else /* not SX */
-#line 3118
+#line 3170
-#line 3118
+#line 3170
char *xp = (char *) *xpp;
-#line 3118
+#line 3170
int status = NC_NOERR;
-#line 3118
+#line 3170
-#line 3118
+#line 3170
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3118
+#line 3170
{
-#line 3118
+#line 3170
int lstatus = ncx_put_short_double(xp, tp, fillp);
-#line 3118
+#line 3170
if (status == NC_NOERR) /* report the first encountered error */
-#line 3118
+#line 3170
status = lstatus;
-#line 3118
+#line 3170
}
-#line 3118
+#line 3170
-#line 3118
+#line 3170
*xpp = (void *)xp;
-#line 3118
+#line 3170
return status;
-#line 3118
+#line 3170
#endif
-#line 3118
+#line 3170
}
-#line 3118
+#line 3170
int
-#line 3119
+#line 3171
ncx_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3119
+#line 3171
{
-#line 3119
+#line 3171
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3119
+#line 3171
-#line 3119
+#line 3171
/* basic algorithm is:
-#line 3119
+#line 3171
* - ensure sane alignment of output data
-#line 3119
+#line 3171
* - copy (conversion happens automatically) input data
-#line 3119
+#line 3171
* to output
-#line 3119
+#line 3171
* - update tp to point at next unconverted input, and xpp to point
-#line 3119
+#line 3171
* at next location for converted output
-#line 3119
+#line 3171
*/
-#line 3119
+#line 3171
long i, j, ni;
-#line 3119
+#line 3171
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3119
+#line 3171
short *xp;
-#line 3119
+#line 3171
int nrange = 0; /* number of range errors */
-#line 3119
+#line 3171
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3119
+#line 3171
long cxp = (long) *((char**)xpp);
-#line 3119
+#line 3171
-#line 3119
+#line 3171
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3119
+#line 3171
/* sjl: manually stripmine so we can limit amount of
-#line 3119
+#line 3171
* vector work space reserved to LOOPCNT elements. Also
-#line 3119
+#line 3171
* makes vectorisation easy */
-#line 3119
+#line 3171
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3119
+#line 3171
ni=Min(nelems-j,LOOPCNT);
-#line 3119
+#line 3171
if (realign) {
-#line 3119
+#line 3171
xp = tmp;
-#line 3119
+#line 3171
} else {
-#line 3119
+#line 3171
xp = (short *) *xpp;
-#line 3119
+#line 3171
}
-#line 3119
+#line 3171
/* copy the next block */
-#line 3119
+#line 3171
#pragma cdir loopcnt=LOOPCNT
-#line 3119
+#line 3171
#pragma cdir shortloop
-#line 3119
+#line 3171
for (i=0; i<ni; i++) {
-#line 3119
+#line 3171
/* the normal case: */
-#line 3119
+#line 3171
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3119
+#line 3171
/* test for range errors (not always needed but do it anyway) */
-#line 3119
+#line 3171
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3119
+#line 3171
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3119
+#line 3171
nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
-#line 3119
+#line 3171
}
-#line 3119
+#line 3171
/* copy workspace back if necessary */
-#line 3119
+#line 3171
if (realign) {
-#line 3119
+#line 3171
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3119
+#line 3171
xp = (short *) *xpp;
-#line 3119
+#line 3171
}
-#line 3119
+#line 3171
/* update xpp and tp */
-#line 3119
+#line 3171
xp += ni;
-#line 3119
+#line 3171
tp += ni;
-#line 3119
+#line 3171
*xpp = (void*)xp;
-#line 3119
+#line 3171
}
-#line 3119
+#line 3171
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3119
+#line 3171
-#line 3119
+#line 3171
#else /* not SX */
-#line 3119
+#line 3171
-#line 3119
+#line 3171
char *xp = (char *) *xpp;
-#line 3119
+#line 3171
int status = NC_NOERR;
-#line 3119
+#line 3171
-#line 3119
+#line 3171
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3119
+#line 3171
{
-#line 3119
+#line 3171
int lstatus = ncx_put_short_longlong(xp, tp, fillp);
-#line 3119
+#line 3171
if (status == NC_NOERR) /* report the first encountered error */
-#line 3119
+#line 3171
status = lstatus;
-#line 3119
+#line 3171
}
-#line 3119
+#line 3171
-#line 3119
+#line 3171
*xpp = (void *)xp;
-#line 3119
+#line 3171
return status;
-#line 3119
+#line 3171
#endif
-#line 3119
+#line 3171
}
-#line 3119
+#line 3171
int
-#line 3120
+#line 3172
ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3120
+#line 3172
{
-#line 3120
+#line 3172
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3120
+#line 3172
-#line 3120
+#line 3172
/* basic algorithm is:
-#line 3120
+#line 3172
* - ensure sane alignment of output data
-#line 3120
+#line 3172
* - copy (conversion happens automatically) input data
-#line 3120
+#line 3172
* to output
-#line 3120
+#line 3172
* - update tp to point at next unconverted input, and xpp to point
-#line 3120
+#line 3172
* at next location for converted output
-#line 3120
+#line 3172
*/
-#line 3120
+#line 3172
long i, j, ni;
-#line 3120
+#line 3172
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3120
+#line 3172
short *xp;
-#line 3120
+#line 3172
int nrange = 0; /* number of range errors */
-#line 3120
+#line 3172
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3120
+#line 3172
long cxp = (long) *((char**)xpp);
-#line 3120
+#line 3172
-#line 3120
+#line 3172
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3120
+#line 3172
/* sjl: manually stripmine so we can limit amount of
-#line 3120
+#line 3172
* vector work space reserved to LOOPCNT elements. Also
-#line 3120
+#line 3172
* makes vectorisation easy */
-#line 3120
+#line 3172
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3120
+#line 3172
ni=Min(nelems-j,LOOPCNT);
-#line 3120
+#line 3172
if (realign) {
-#line 3120
+#line 3172
xp = tmp;
-#line 3120
+#line 3172
} else {
-#line 3120
+#line 3172
xp = (short *) *xpp;
-#line 3120
+#line 3172
}
-#line 3120
+#line 3172
/* copy the next block */
-#line 3120
+#line 3172
#pragma cdir loopcnt=LOOPCNT
-#line 3120
+#line 3172
#pragma cdir shortloop
-#line 3120
+#line 3172
for (i=0; i<ni; i++) {
-#line 3120
+#line 3172
/* the normal case: */
-#line 3120
+#line 3172
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3120
+#line 3172
/* test for range errors (not always needed but do it anyway) */
-#line 3120
+#line 3172
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3120
+#line 3172
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3120
+#line 3172
nrange += tp[i] > X_SHORT_MAX ;
-#line 3120
+#line 3172
}
-#line 3120
+#line 3172
/* copy workspace back if necessary */
-#line 3120
+#line 3172
if (realign) {
-#line 3120
+#line 3172
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3120
+#line 3172
xp = (short *) *xpp;
-#line 3120
+#line 3172
}
-#line 3120
+#line 3172
/* update xpp and tp */
-#line 3120
+#line 3172
xp += ni;
-#line 3120
+#line 3172
tp += ni;
-#line 3120
+#line 3172
*xpp = (void*)xp;
-#line 3120
+#line 3172
}
-#line 3120
+#line 3172
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3120
+#line 3172
-#line 3120
+#line 3172
#else /* not SX */
-#line 3120
+#line 3172
-#line 3120
+#line 3172
char *xp = (char *) *xpp;
-#line 3120
+#line 3172
int status = NC_NOERR;
-#line 3120
+#line 3172
-#line 3120
+#line 3172
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3120
+#line 3172
{
-#line 3120
+#line 3172
int lstatus = ncx_put_short_uchar(xp, tp, fillp);
-#line 3120
+#line 3172
if (status == NC_NOERR) /* report the first encountered error */
-#line 3120
+#line 3172
status = lstatus;
-#line 3120
+#line 3172
}
-#line 3120
+#line 3172
-#line 3120
+#line 3172
*xpp = (void *)xp;
-#line 3120
+#line 3172
return status;
-#line 3120
+#line 3172
#endif
-#line 3120
+#line 3172
}
-#line 3120
+#line 3172
int
-#line 3121
+#line 3173
ncx_putn_short_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3121
+#line 3173
{
-#line 3121
+#line 3173
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3121
+#line 3173
-#line 3121
+#line 3173
/* basic algorithm is:
-#line 3121
+#line 3173
* - ensure sane alignment of output data
-#line 3121
+#line 3173
* - copy (conversion happens automatically) input data
-#line 3121
+#line 3173
* to output
-#line 3121
+#line 3173
* - update tp to point at next unconverted input, and xpp to point
-#line 3121
+#line 3173
* at next location for converted output
-#line 3121
+#line 3173
*/
-#line 3121
+#line 3173
long i, j, ni;
-#line 3121
+#line 3173
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3121
+#line 3173
short *xp;
-#line 3121
+#line 3173
int nrange = 0; /* number of range errors */
-#line 3121
+#line 3173
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3121
+#line 3173
long cxp = (long) *((char**)xpp);
-#line 3121
+#line 3173
-#line 3121
+#line 3173
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3121
+#line 3173
/* sjl: manually stripmine so we can limit amount of
-#line 3121
+#line 3173
* vector work space reserved to LOOPCNT elements. Also
-#line 3121
+#line 3173
* makes vectorisation easy */
-#line 3121
+#line 3173
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3121
+#line 3173
ni=Min(nelems-j,LOOPCNT);
-#line 3121
+#line 3173
if (realign) {
-#line 3121
+#line 3173
xp = tmp;
-#line 3121
+#line 3173
} else {
-#line 3121
+#line 3173
xp = (short *) *xpp;
-#line 3121
+#line 3173
}
-#line 3121
+#line 3173
/* copy the next block */
-#line 3121
+#line 3173
#pragma cdir loopcnt=LOOPCNT
-#line 3121
+#line 3173
#pragma cdir shortloop
-#line 3121
+#line 3173
for (i=0; i<ni; i++) {
-#line 3121
+#line 3173
/* the normal case: */
-#line 3121
+#line 3173
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3121
+#line 3173
/* test for range errors (not always needed but do it anyway) */
-#line 3121
+#line 3173
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3121
+#line 3173
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3121
+#line 3173
nrange += tp[i] > X_SHORT_MAX ;
-#line 3121
+#line 3173
}
-#line 3121
+#line 3173
/* copy workspace back if necessary */
-#line 3121
+#line 3173
if (realign) {
-#line 3121
+#line 3173
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3121
+#line 3173
xp = (short *) *xpp;
-#line 3121
+#line 3173
}
-#line 3121
+#line 3173
/* update xpp and tp */
-#line 3121
+#line 3173
xp += ni;
-#line 3121
+#line 3173
tp += ni;
-#line 3121
+#line 3173
*xpp = (void*)xp;
-#line 3121
+#line 3173
}
-#line 3121
+#line 3173
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3121
+#line 3173
-#line 3121
+#line 3173
#else /* not SX */
-#line 3121
+#line 3173
-#line 3121
+#line 3173
char *xp = (char *) *xpp;
-#line 3121
+#line 3173
int status = NC_NOERR;
-#line 3121
+#line 3173
-#line 3121
+#line 3173
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3121
+#line 3173
{
-#line 3121
+#line 3173
int lstatus = ncx_put_short_uint(xp, tp, fillp);
-#line 3121
+#line 3173
if (status == NC_NOERR) /* report the first encountered error */
-#line 3121
+#line 3173
status = lstatus;
-#line 3121
+#line 3173
}
-#line 3121
+#line 3173
-#line 3121
+#line 3173
*xpp = (void *)xp;
-#line 3121
+#line 3173
return status;
-#line 3121
+#line 3173
#endif
-#line 3121
+#line 3173
}
-#line 3121
+#line 3173
int
-#line 3122
+#line 3174
ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3122
+#line 3174
{
-#line 3122
+#line 3174
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3122
+#line 3174
-#line 3122
+#line 3174
/* basic algorithm is:
-#line 3122
+#line 3174
* - ensure sane alignment of output data
-#line 3122
+#line 3174
* - copy (conversion happens automatically) input data
-#line 3122
+#line 3174
* to output
-#line 3122
+#line 3174
* - update tp to point at next unconverted input, and xpp to point
-#line 3122
+#line 3174
* at next location for converted output
-#line 3122
+#line 3174
*/
-#line 3122
+#line 3174
long i, j, ni;
-#line 3122
+#line 3174
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3122
+#line 3174
short *xp;
-#line 3122
+#line 3174
int nrange = 0; /* number of range errors */
-#line 3122
+#line 3174
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3122
+#line 3174
long cxp = (long) *((char**)xpp);
-#line 3122
+#line 3174
-#line 3122
+#line 3174
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3122
+#line 3174
/* sjl: manually stripmine so we can limit amount of
-#line 3122
+#line 3174
* vector work space reserved to LOOPCNT elements. Also
-#line 3122
+#line 3174
* makes vectorisation easy */
-#line 3122
+#line 3174
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3122
+#line 3174
ni=Min(nelems-j,LOOPCNT);
-#line 3122
+#line 3174
if (realign) {
-#line 3122
+#line 3174
xp = tmp;
-#line 3122
+#line 3174
} else {
-#line 3122
+#line 3174
xp = (short *) *xpp;
-#line 3122
+#line 3174
}
-#line 3122
+#line 3174
/* copy the next block */
-#line 3122
+#line 3174
#pragma cdir loopcnt=LOOPCNT
-#line 3122
+#line 3174
#pragma cdir shortloop
-#line 3122
+#line 3174
for (i=0; i<ni; i++) {
-#line 3122
+#line 3174
/* the normal case: */
-#line 3122
+#line 3174
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3122
+#line 3174
/* test for range errors (not always needed but do it anyway) */
-#line 3122
+#line 3174
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3122
+#line 3174
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3122
+#line 3174
nrange += tp[i] > X_SHORT_MAX ;
-#line 3122
+#line 3174
}
-#line 3122
+#line 3174
/* copy workspace back if necessary */
-#line 3122
+#line 3174
if (realign) {
-#line 3122
+#line 3174
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3122
+#line 3174
xp = (short *) *xpp;
-#line 3122
+#line 3174
}
-#line 3122
+#line 3174
/* update xpp and tp */
-#line 3122
+#line 3174
xp += ni;
-#line 3122
+#line 3174
tp += ni;
-#line 3122
+#line 3174
*xpp = (void*)xp;
-#line 3122
+#line 3174
}
-#line 3122
+#line 3174
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3122
+#line 3174
-#line 3122
+#line 3174
#else /* not SX */
-#line 3122
+#line 3174
-#line 3122
+#line 3174
char *xp = (char *) *xpp;
-#line 3122
+#line 3174
int status = NC_NOERR;
-#line 3122
+#line 3174
-#line 3122
+#line 3174
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3122
+#line 3174
{
-#line 3122
+#line 3174
int lstatus = ncx_put_short_ulonglong(xp, tp, fillp);
-#line 3122
+#line 3174
if (status == NC_NOERR) /* report the first encountered error */
-#line 3122
+#line 3174
status = lstatus;
-#line 3122
+#line 3174
}
-#line 3122
+#line 3174
-#line 3122
+#line 3174
*xpp = (void *)xp;
-#line 3122
+#line 3174
return status;
-#line 3122
+#line 3174
#endif
-#line 3122
+#line 3174
}
-#line 3122
+#line 3174
int
-#line 3123
+#line 3175
ncx_putn_short_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3123
+#line 3175
{
-#line 3123
+#line 3175
#if defined(_SX) && _SX != 0 && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 3123
+#line 3175
-#line 3123
+#line 3175
/* basic algorithm is:
-#line 3123
+#line 3175
* - ensure sane alignment of output data
-#line 3123
+#line 3175
* - copy (conversion happens automatically) input data
-#line 3123
+#line 3175
* to output
-#line 3123
+#line 3175
* - update tp to point at next unconverted input, and xpp to point
-#line 3123
+#line 3175
* at next location for converted output
-#line 3123
+#line 3175
*/
-#line 3123
+#line 3175
long i, j, ni;
-#line 3123
+#line 3175
short tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3123
+#line 3175
short *xp;
-#line 3123
+#line 3175
int nrange = 0; /* number of range errors */
-#line 3123
+#line 3175
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3123
+#line 3175
long cxp = (long) *((char**)xpp);
-#line 3123
+#line 3175
-#line 3123
+#line 3175
realign = (cxp & 7) % SIZEOF_SHORT;
-#line 3123
+#line 3175
/* sjl: manually stripmine so we can limit amount of
-#line 3123
+#line 3175
* vector work space reserved to LOOPCNT elements. Also
-#line 3123
+#line 3175
* makes vectorisation easy */
-#line 3123
+#line 3175
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3123
+#line 3175
ni=Min(nelems-j,LOOPCNT);
-#line 3123
+#line 3175
if (realign) {
-#line 3123
+#line 3175
xp = tmp;
-#line 3123
+#line 3175
} else {
-#line 3123
+#line 3175
xp = (short *) *xpp;
-#line 3123
+#line 3175
}
-#line 3123
+#line 3175
/* copy the next block */
-#line 3123
+#line 3175
#pragma cdir loopcnt=LOOPCNT
-#line 3123
+#line 3175
#pragma cdir shortloop
-#line 3123
+#line 3175
for (i=0; i<ni; i++) {
-#line 3123
+#line 3175
/* the normal case: */
-#line 3123
+#line 3175
xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 3123
+#line 3175
/* test for range errors (not always needed but do it anyway) */
-#line 3123
+#line 3175
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3123
+#line 3175
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3123
+#line 3175
nrange += tp[i] > X_SHORT_MAX ;
-#line 3123
+#line 3175
}
-#line 3123
+#line 3175
/* copy workspace back if necessary */
-#line 3123
+#line 3175
if (realign) {
-#line 3123
+#line 3175
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_SHORT);
-#line 3123
+#line 3175
xp = (short *) *xpp;
-#line 3123
+#line 3175
}
-#line 3123
+#line 3175
/* update xpp and tp */
-#line 3123
+#line 3175
xp += ni;
-#line 3123
+#line 3175
tp += ni;
-#line 3123
+#line 3175
*xpp = (void*)xp;
-#line 3123
+#line 3175
}
-#line 3123
+#line 3175
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3123
+#line 3175
-#line 3123
+#line 3175
#else /* not SX */
-#line 3123
+#line 3175
-#line 3123
+#line 3175
char *xp = (char *) *xpp;
-#line 3123
+#line 3175
int status = NC_NOERR;
-#line 3123
+#line 3175
-#line 3123
+#line 3175
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3123
+#line 3175
{
-#line 3123
+#line 3175
int lstatus = ncx_put_short_ushort(xp, tp, fillp);
-#line 3123
+#line 3175
if (status == NC_NOERR) /* report the first encountered error */
-#line 3123
+#line 3175
status = lstatus;
-#line 3123
+#line 3175
}
-#line 3123
+#line 3175
-#line 3123
+#line 3175
*xpp = (void *)xp;
-#line 3123
+#line 3175
return status;
-#line 3123
+#line 3175
#endif
-#line 3123
+#line 3175
}
-#line 3123
+#line 3175
int
-#line 3125
+#line 3177
ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3125
+#line 3177
{
-#line 3125
+#line 3177
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3125
+#line 3177
-#line 3125
+#line 3177
char *xp = (char *) *xpp;
-#line 3125
+#line 3177
int status = NC_NOERR;
-#line 3125
+#line 3177
-#line 3125
+#line 3177
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3125
+#line 3177
{
-#line 3125
+#line 3177
int lstatus = ncx_put_short_schar(xp, tp, fillp);
-#line 3125
+#line 3177
if (status == NC_NOERR) /* report the first encountered error */
-#line 3125
+#line 3177
status = lstatus;
-#line 3125
+#line 3177
}
-#line 3125
+#line 3177
-#line 3125
+#line 3177
if (rndup != 0)
-#line 3125
+#line 3177
{
-#line 3125
+#line 3177
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3125
+#line 3177
xp += X_SIZEOF_SHORT;
-#line 3125
+#line 3177
}
-#line 3125
+#line 3177
-#line 3125
+#line 3177
*xpp = (void *)xp;
-#line 3125
+#line 3177
return status;
-#line 3125
+#line 3177
}
-#line 3125
+#line 3177
int
-#line 3126
+#line 3178
ncx_pad_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3126
+#line 3178
{
-#line 3126
+#line 3178
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3126
+#line 3178
-#line 3126
+#line 3178
char *xp = (char *) *xpp;
-#line 3126
+#line 3178
int status = NC_NOERR;
-#line 3126
+#line 3178
-#line 3126
+#line 3178
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3126
+#line 3178
{
-#line 3126
+#line 3178
int lstatus = ncx_put_short_uchar(xp, tp, fillp);
-#line 3126
+#line 3178
if (status == NC_NOERR) /* report the first encountered error */
-#line 3126
+#line 3178
status = lstatus;
-#line 3126
+#line 3178
}
-#line 3126
+#line 3178
-#line 3126
+#line 3178
if (rndup != 0)
-#line 3126
+#line 3178
{
-#line 3126
+#line 3178
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3126
+#line 3178
xp += X_SIZEOF_SHORT;
-#line 3126
+#line 3178
}
-#line 3126
+#line 3178
-#line 3126
+#line 3178
*xpp = (void *)xp;
-#line 3126
+#line 3178
return status;
-#line 3126
+#line 3178
}
-#line 3126
+#line 3178
int
-#line 3127
+#line 3179
ncx_pad_putn_short_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3127
+#line 3179
{
-#line 3127
+#line 3179
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3127
+#line 3179
-#line 3127
+#line 3179
char *xp = (char *) *xpp;
-#line 3127
+#line 3179
int status = NC_NOERR;
-#line 3127
+#line 3179
-#line 3127
+#line 3179
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3127
+#line 3179
{
-#line 3127
+#line 3179
int lstatus = ncx_put_short_short(xp, tp, fillp);
-#line 3127
+#line 3179
if (status == NC_NOERR) /* report the first encountered error */
-#line 3127
+#line 3179
status = lstatus;
-#line 3127
+#line 3179
}
-#line 3127
+#line 3179
-#line 3127
+#line 3179
if (rndup != 0)
-#line 3127
+#line 3179
{
-#line 3127
+#line 3179
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3127
+#line 3179
xp += X_SIZEOF_SHORT;
-#line 3127
+#line 3179
}
-#line 3127
+#line 3179
-#line 3127
+#line 3179
*xpp = (void *)xp;
-#line 3127
+#line 3179
return status;
-#line 3127
+#line 3179
}
-#line 3127
+#line 3179
int
-#line 3128
+#line 3180
ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3128
+#line 3180
{
-#line 3128
+#line 3180
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3128
+#line 3180
-#line 3128
+#line 3180
char *xp = (char *) *xpp;
-#line 3128
+#line 3180
int status = NC_NOERR;
-#line 3128
+#line 3180
-#line 3128
+#line 3180
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3128
+#line 3180
{
-#line 3128
+#line 3180
int lstatus = ncx_put_short_int(xp, tp, fillp);
-#line 3128
+#line 3180
if (status == NC_NOERR) /* report the first encountered error */
-#line 3128
+#line 3180
status = lstatus;
-#line 3128
+#line 3180
}
-#line 3128
+#line 3180
-#line 3128
+#line 3180
if (rndup != 0)
-#line 3128
+#line 3180
{
-#line 3128
+#line 3180
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3128
+#line 3180
xp += X_SIZEOF_SHORT;
-#line 3128
+#line 3180
}
-#line 3128
+#line 3180
-#line 3128
+#line 3180
*xpp = (void *)xp;
-#line 3128
+#line 3180
return status;
-#line 3128
+#line 3180
}
-#line 3128
+#line 3180
int
-#line 3129
+#line 3181
ncx_pad_putn_short_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3129
+#line 3181
{
-#line 3129
+#line 3181
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3129
+#line 3181
-#line 3129
+#line 3181
char *xp = (char *) *xpp;
-#line 3129
+#line 3181
int status = NC_NOERR;
-#line 3129
+#line 3181
-#line 3129
+#line 3181
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3129
+#line 3181
{
-#line 3129
+#line 3181
int lstatus = ncx_put_short_long(xp, tp, fillp);
-#line 3129
+#line 3181
if (status == NC_NOERR) /* report the first encountered error */
-#line 3129
+#line 3181
status = lstatus;
-#line 3129
+#line 3181
}
-#line 3129
+#line 3181
-#line 3129
+#line 3181
if (rndup != 0)
-#line 3129
+#line 3181
{
-#line 3129
+#line 3181
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3129
+#line 3181
xp += X_SIZEOF_SHORT;
-#line 3129
+#line 3181
}
-#line 3129
+#line 3181
-#line 3129
+#line 3181
*xpp = (void *)xp;
-#line 3129
+#line 3181
return status;
-#line 3129
+#line 3181
}
-#line 3129
+#line 3181
int
-#line 3130
+#line 3182
ncx_pad_putn_short_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3130
+#line 3182
{
-#line 3130
+#line 3182
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3130
+#line 3182
-#line 3130
+#line 3182
char *xp = (char *) *xpp;
-#line 3130
+#line 3182
int status = NC_NOERR;
-#line 3130
+#line 3182
-#line 3130
+#line 3182
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3130
+#line 3182
{
-#line 3130
+#line 3182
int lstatus = ncx_put_short_float(xp, tp, fillp);
-#line 3130
+#line 3182
if (status == NC_NOERR) /* report the first encountered error */
-#line 3130
+#line 3182
status = lstatus;
-#line 3130
+#line 3182
}
-#line 3130
+#line 3182
-#line 3130
+#line 3182
if (rndup != 0)
-#line 3130
+#line 3182
{
-#line 3130
+#line 3182
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3130
+#line 3182
xp += X_SIZEOF_SHORT;
-#line 3130
+#line 3182
}
-#line 3130
+#line 3182
-#line 3130
+#line 3182
*xpp = (void *)xp;
-#line 3130
+#line 3182
return status;
-#line 3130
+#line 3182
}
-#line 3130
+#line 3182
int
-#line 3131
+#line 3183
ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3131
+#line 3183
{
-#line 3131
+#line 3183
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3131
+#line 3183
-#line 3131
+#line 3183
char *xp = (char *) *xpp;
-#line 3131
+#line 3183
int status = NC_NOERR;
-#line 3131
+#line 3183
-#line 3131
+#line 3183
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3131
+#line 3183
{
-#line 3131
+#line 3183
int lstatus = ncx_put_short_double(xp, tp, fillp);
-#line 3131
+#line 3183
if (status == NC_NOERR) /* report the first encountered error */
-#line 3131
+#line 3183
status = lstatus;
-#line 3131
+#line 3183
}
-#line 3131
+#line 3183
-#line 3131
+#line 3183
if (rndup != 0)
-#line 3131
+#line 3183
{
-#line 3131
+#line 3183
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3131
+#line 3183
xp += X_SIZEOF_SHORT;
-#line 3131
+#line 3183
}
-#line 3131
+#line 3183
-#line 3131
+#line 3183
*xpp = (void *)xp;
-#line 3131
+#line 3183
return status;
-#line 3131
+#line 3183
}
-#line 3131
+#line 3183
int
-#line 3132
+#line 3184
ncx_pad_putn_short_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3132
+#line 3184
{
-#line 3132
+#line 3184
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3132
+#line 3184
-#line 3132
+#line 3184
char *xp = (char *) *xpp;
-#line 3132
+#line 3184
int status = NC_NOERR;
-#line 3132
+#line 3184
-#line 3132
+#line 3184
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3132
+#line 3184
{
-#line 3132
+#line 3184
int lstatus = ncx_put_short_uint(xp, tp, fillp);
-#line 3132
+#line 3184
if (status == NC_NOERR) /* report the first encountered error */
-#line 3132
+#line 3184
status = lstatus;
-#line 3132
+#line 3184
}
-#line 3132
+#line 3184
-#line 3132
+#line 3184
if (rndup != 0)
-#line 3132
+#line 3184
{
-#line 3132
+#line 3184
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3132
+#line 3184
xp += X_SIZEOF_SHORT;
-#line 3132
+#line 3184
}
-#line 3132
+#line 3184
-#line 3132
+#line 3184
*xpp = (void *)xp;
-#line 3132
+#line 3184
return status;
-#line 3132
+#line 3184
}
-#line 3132
+#line 3184
int
-#line 3133
+#line 3185
ncx_pad_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3133
+#line 3185
{
-#line 3133
+#line 3185
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3133
+#line 3185
-#line 3133
+#line 3185
char *xp = (char *) *xpp;
-#line 3133
+#line 3185
int status = NC_NOERR;
-#line 3133
+#line 3185
-#line 3133
+#line 3185
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3133
+#line 3185
{
-#line 3133
+#line 3185
int lstatus = ncx_put_short_longlong(xp, tp, fillp);
-#line 3133
+#line 3185
if (status == NC_NOERR) /* report the first encountered error */
-#line 3133
+#line 3185
status = lstatus;
-#line 3133
+#line 3185
}
-#line 3133
+#line 3185
-#line 3133
+#line 3185
if (rndup != 0)
-#line 3133
+#line 3185
{
-#line 3133
+#line 3185
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3133
+#line 3185
xp += X_SIZEOF_SHORT;
-#line 3133
+#line 3185
}
-#line 3133
+#line 3185
-#line 3133
+#line 3185
*xpp = (void *)xp;
-#line 3133
+#line 3185
return status;
-#line 3133
+#line 3185
}
-#line 3133
+#line 3185
int
-#line 3134
+#line 3186
ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3134
+#line 3186
{
-#line 3134
+#line 3186
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3134
+#line 3186
-#line 3134
+#line 3186
char *xp = (char *) *xpp;
-#line 3134
+#line 3186
int status = NC_NOERR;
-#line 3134
+#line 3186
-#line 3134
+#line 3186
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3134
+#line 3186
{
-#line 3134
+#line 3186
int lstatus = ncx_put_short_ulonglong(xp, tp, fillp);
-#line 3134
+#line 3186
if (status == NC_NOERR) /* report the first encountered error */
-#line 3134
+#line 3186
status = lstatus;
-#line 3134
+#line 3186
}
-#line 3134
+#line 3186
-#line 3134
+#line 3186
if (rndup != 0)
-#line 3134
+#line 3186
{
-#line 3134
+#line 3186
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3134
+#line 3186
xp += X_SIZEOF_SHORT;
-#line 3134
+#line 3186
}
-#line 3134
+#line 3186
-#line 3134
+#line 3186
*xpp = (void *)xp;
-#line 3134
+#line 3186
return status;
-#line 3134
+#line 3186
}
-#line 3134
+#line 3186
int
-#line 3135
+#line 3187
ncx_pad_putn_short_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3135
+#line 3187
{
-#line 3135
+#line 3187
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3135
+#line 3187
-#line 3135
+#line 3187
char *xp = (char *) *xpp;
-#line 3135
+#line 3187
int status = NC_NOERR;
-#line 3135
+#line 3187
-#line 3135
+#line 3187
for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 3135
+#line 3187
{
-#line 3135
+#line 3187
int lstatus = ncx_put_short_ushort(xp, tp, fillp);
-#line 3135
+#line 3187
if (status == NC_NOERR) /* report the first encountered error */
-#line 3135
+#line 3187
status = lstatus;
-#line 3135
+#line 3187
}
-#line 3135
+#line 3187
-#line 3135
+#line 3187
if (rndup != 0)
-#line 3135
+#line 3187
{
-#line 3135
+#line 3187
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_SHORT));
-#line 3135
+#line 3187
xp += X_SIZEOF_SHORT;
-#line 3135
+#line 3187
}
-#line 3135
+#line 3187
-#line 3135
+#line 3187
*xpp = (void *)xp;
-#line 3135
+#line 3187
return status;
-#line 3135
+#line 3187
}
-#line 3135
+#line 3187
@@ -15423,1898 +17508,1898 @@ ncx_getn_ushort_ushort(const void **xpp, size_t nelems, unsigned short *tp)
}
#else
int
-#line 3154
+#line 3206
ncx_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3154
+#line 3206
{
-#line 3154
+#line 3206
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3154
+#line 3206
-#line 3154
+#line 3206
/* basic algorithm is:
-#line 3154
+#line 3206
* - ensure sane alignment of input data
-#line 3154
+#line 3206
* - copy (conversion happens automatically) input data
-#line 3154
+#line 3206
* to output
-#line 3154
+#line 3206
* - update xpp to point at next unconverted input, and tp to point
-#line 3154
+#line 3206
* at next location for converted output
-#line 3154
+#line 3206
*/
-#line 3154
+#line 3206
long i, j, ni;
-#line 3154
+#line 3206
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3154
+#line 3206
ushort *xp;
-#line 3154
+#line 3206
int nrange = 0; /* number of range errors */
-#line 3154
+#line 3206
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3154
+#line 3206
long cxp = (long) *((char**)xpp);
-#line 3154
+#line 3206
-#line 3154
+#line 3206
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3154
+#line 3206
/* sjl: manually stripmine so we can limit amount of
-#line 3154
+#line 3206
* vector work space reserved to LOOPCNT elements. Also
-#line 3154
+#line 3206
* makes vectorisation easy */
-#line 3154
+#line 3206
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3154
+#line 3206
ni=Min(nelems-j,LOOPCNT);
-#line 3154
+#line 3206
if (realign) {
-#line 3154
+#line 3206
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3154
+#line 3206
xp = tmp;
-#line 3154
+#line 3206
} else {
-#line 3154
+#line 3206
xp = (ushort *) *xpp;
-#line 3154
+#line 3206
}
-#line 3154
+#line 3206
/* copy the next block */
-#line 3154
+#line 3206
#pragma cdir loopcnt=LOOPCNT
-#line 3154
+#line 3206
#pragma cdir shortloop
-#line 3154
+#line 3206
for (i=0; i<ni; i++) {
-#line 3154
+#line 3206
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3154
+#line 3206
/* test for range errors (not always needed but do it anyway) */
-#line 3154
+#line 3206
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3154
+#line 3206
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3154
+#line 3206
nrange += xp[i] > USHORT_MAX ;
-#line 3154
+#line 3206
}
-#line 3154
+#line 3206
/* update xpp and tp */
-#line 3154
+#line 3206
if (realign) xp = (ushort *) *xpp;
-#line 3154
+#line 3206
xp += ni;
-#line 3154
+#line 3206
tp += ni;
-#line 3154
+#line 3206
*xpp = (void*)xp;
-#line 3154
+#line 3206
}
-#line 3154
+#line 3206
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3154
+#line 3206
-#line 3154
+#line 3206
#else /* not SX */
-#line 3154
+#line 3206
const char *xp = (const char *) *xpp;
-#line 3154
+#line 3206
int status = NC_NOERR;
-#line 3154
+#line 3206
-#line 3154
+#line 3206
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3154
+#line 3206
{
-#line 3154
+#line 3206
const int lstatus = ncx_get_ushort_ushort(xp, tp);
-#line 3154
+#line 3206
if (status == NC_NOERR) /* report the first encountered error */
-#line 3154
+#line 3206
status = lstatus;
-#line 3154
+#line 3206
}
-#line 3154
+#line 3206
-#line 3154
+#line 3206
*xpp = (const void *)xp;
-#line 3154
+#line 3206
return status;
-#line 3154
+#line 3206
#endif
-#line 3154
+#line 3206
}
-#line 3154
+#line 3206
#endif
int
-#line 3156
+#line 3208
ncx_getn_ushort_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3156
+#line 3208
{
-#line 3156
+#line 3208
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3156
+#line 3208
-#line 3156
+#line 3208
/* basic algorithm is:
-#line 3156
+#line 3208
* - ensure sane alignment of input data
-#line 3156
+#line 3208
* - copy (conversion happens automatically) input data
-#line 3156
+#line 3208
* to output
-#line 3156
+#line 3208
* - update xpp to point at next unconverted input, and tp to point
-#line 3156
+#line 3208
* at next location for converted output
-#line 3156
+#line 3208
*/
-#line 3156
+#line 3208
long i, j, ni;
-#line 3156
+#line 3208
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3156
+#line 3208
ushort *xp;
-#line 3156
+#line 3208
int nrange = 0; /* number of range errors */
-#line 3156
+#line 3208
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3156
+#line 3208
long cxp = (long) *((char**)xpp);
-#line 3156
+#line 3208
-#line 3156
+#line 3208
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3156
+#line 3208
/* sjl: manually stripmine so we can limit amount of
-#line 3156
+#line 3208
* vector work space reserved to LOOPCNT elements. Also
-#line 3156
+#line 3208
* makes vectorisation easy */
-#line 3156
+#line 3208
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3156
+#line 3208
ni=Min(nelems-j,LOOPCNT);
-#line 3156
+#line 3208
if (realign) {
-#line 3156
+#line 3208
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3156
+#line 3208
xp = tmp;
-#line 3156
+#line 3208
} else {
-#line 3156
+#line 3208
xp = (ushort *) *xpp;
-#line 3156
+#line 3208
}
-#line 3156
+#line 3208
/* copy the next block */
-#line 3156
+#line 3208
#pragma cdir loopcnt=LOOPCNT
-#line 3156
+#line 3208
#pragma cdir shortloop
-#line 3156
+#line 3208
for (i=0; i<ni; i++) {
-#line 3156
+#line 3208
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3156
+#line 3208
/* test for range errors (not always needed but do it anyway) */
-#line 3156
+#line 3208
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3156
+#line 3208
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3156
+#line 3208
nrange += xp[i] > SCHAR_MAX ;
-#line 3156
+#line 3208
}
-#line 3156
+#line 3208
/* update xpp and tp */
-#line 3156
+#line 3208
if (realign) xp = (ushort *) *xpp;
-#line 3156
+#line 3208
xp += ni;
-#line 3156
+#line 3208
tp += ni;
-#line 3156
+#line 3208
*xpp = (void*)xp;
-#line 3156
+#line 3208
}
-#line 3156
+#line 3208
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3156
+#line 3208
-#line 3156
+#line 3208
#else /* not SX */
-#line 3156
+#line 3208
const char *xp = (const char *) *xpp;
-#line 3156
+#line 3208
int status = NC_NOERR;
-#line 3156
+#line 3208
-#line 3156
+#line 3208
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3156
+#line 3208
{
-#line 3156
+#line 3208
const int lstatus = ncx_get_ushort_schar(xp, tp);
-#line 3156
+#line 3208
if (status == NC_NOERR) /* report the first encountered error */
-#line 3156
+#line 3208
status = lstatus;
-#line 3156
+#line 3208
}
-#line 3156
+#line 3208
-#line 3156
+#line 3208
*xpp = (const void *)xp;
-#line 3156
+#line 3208
return status;
-#line 3156
+#line 3208
#endif
-#line 3156
+#line 3208
}
-#line 3156
+#line 3208
int
-#line 3157
+#line 3209
ncx_getn_ushort_short(const void **xpp, size_t nelems, short *tp)
-#line 3157
+#line 3209
{
-#line 3157
+#line 3209
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3157
+#line 3209
-#line 3157
+#line 3209
/* basic algorithm is:
-#line 3157
+#line 3209
* - ensure sane alignment of input data
-#line 3157
+#line 3209
* - copy (conversion happens automatically) input data
-#line 3157
+#line 3209
* to output
-#line 3157
+#line 3209
* - update xpp to point at next unconverted input, and tp to point
-#line 3157
+#line 3209
* at next location for converted output
-#line 3157
+#line 3209
*/
-#line 3157
+#line 3209
long i, j, ni;
-#line 3157
+#line 3209
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3157
+#line 3209
ushort *xp;
-#line 3157
+#line 3209
int nrange = 0; /* number of range errors */
-#line 3157
+#line 3209
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3157
+#line 3209
long cxp = (long) *((char**)xpp);
-#line 3157
+#line 3209
-#line 3157
+#line 3209
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3157
+#line 3209
/* sjl: manually stripmine so we can limit amount of
-#line 3157
+#line 3209
* vector work space reserved to LOOPCNT elements. Also
-#line 3157
+#line 3209
* makes vectorisation easy */
-#line 3157
+#line 3209
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3157
+#line 3209
ni=Min(nelems-j,LOOPCNT);
-#line 3157
+#line 3209
if (realign) {
-#line 3157
+#line 3209
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3157
+#line 3209
xp = tmp;
-#line 3157
+#line 3209
} else {
-#line 3157
+#line 3209
xp = (ushort *) *xpp;
-#line 3157
+#line 3209
}
-#line 3157
+#line 3209
/* copy the next block */
-#line 3157
+#line 3209
#pragma cdir loopcnt=LOOPCNT
-#line 3157
+#line 3209
#pragma cdir shortloop
-#line 3157
+#line 3209
for (i=0; i<ni; i++) {
-#line 3157
+#line 3209
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3157
+#line 3209
/* test for range errors (not always needed but do it anyway) */
-#line 3157
+#line 3209
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3157
+#line 3209
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3157
+#line 3209
nrange += xp[i] > SHORT_MAX ;
-#line 3157
+#line 3209
}
-#line 3157
+#line 3209
/* update xpp and tp */
-#line 3157
+#line 3209
if (realign) xp = (ushort *) *xpp;
-#line 3157
+#line 3209
xp += ni;
-#line 3157
+#line 3209
tp += ni;
-#line 3157
+#line 3209
*xpp = (void*)xp;
-#line 3157
+#line 3209
}
-#line 3157
+#line 3209
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3157
+#line 3209
-#line 3157
+#line 3209
#else /* not SX */
-#line 3157
+#line 3209
const char *xp = (const char *) *xpp;
-#line 3157
+#line 3209
int status = NC_NOERR;
-#line 3157
+#line 3209
-#line 3157
+#line 3209
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3157
+#line 3209
{
-#line 3157
+#line 3209
const int lstatus = ncx_get_ushort_short(xp, tp);
-#line 3157
+#line 3209
if (status == NC_NOERR) /* report the first encountered error */
-#line 3157
+#line 3209
status = lstatus;
-#line 3157
+#line 3209
}
-#line 3157
+#line 3209
-#line 3157
+#line 3209
*xpp = (const void *)xp;
-#line 3157
+#line 3209
return status;
-#line 3157
+#line 3209
#endif
-#line 3157
+#line 3209
}
-#line 3157
+#line 3209
int
-#line 3158
+#line 3210
ncx_getn_ushort_int(const void **xpp, size_t nelems, int *tp)
-#line 3158
+#line 3210
{
-#line 3158
+#line 3210
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3158
+#line 3210
-#line 3158
+#line 3210
/* basic algorithm is:
-#line 3158
+#line 3210
* - ensure sane alignment of input data
-#line 3158
+#line 3210
* - copy (conversion happens automatically) input data
-#line 3158
+#line 3210
* to output
-#line 3158
+#line 3210
* - update xpp to point at next unconverted input, and tp to point
-#line 3158
+#line 3210
* at next location for converted output
-#line 3158
+#line 3210
*/
-#line 3158
+#line 3210
long i, j, ni;
-#line 3158
+#line 3210
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3158
+#line 3210
ushort *xp;
-#line 3158
+#line 3210
int nrange = 0; /* number of range errors */
-#line 3158
+#line 3210
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3158
+#line 3210
long cxp = (long) *((char**)xpp);
-#line 3158
+#line 3210
-#line 3158
+#line 3210
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3158
+#line 3210
/* sjl: manually stripmine so we can limit amount of
-#line 3158
+#line 3210
* vector work space reserved to LOOPCNT elements. Also
-#line 3158
+#line 3210
* makes vectorisation easy */
-#line 3158
+#line 3210
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3158
+#line 3210
ni=Min(nelems-j,LOOPCNT);
-#line 3158
+#line 3210
if (realign) {
-#line 3158
+#line 3210
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3158
+#line 3210
xp = tmp;
-#line 3158
+#line 3210
} else {
-#line 3158
+#line 3210
xp = (ushort *) *xpp;
-#line 3158
+#line 3210
}
-#line 3158
+#line 3210
/* copy the next block */
-#line 3158
+#line 3210
#pragma cdir loopcnt=LOOPCNT
-#line 3158
+#line 3210
#pragma cdir shortloop
-#line 3158
+#line 3210
for (i=0; i<ni; i++) {
-#line 3158
+#line 3210
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3158
+#line 3210
/* test for range errors (not always needed but do it anyway) */
-#line 3158
+#line 3210
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3158
+#line 3210
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3158
+#line 3210
nrange += xp[i] > INT_MAX ;
-#line 3158
+#line 3210
}
-#line 3158
+#line 3210
/* update xpp and tp */
-#line 3158
+#line 3210
if (realign) xp = (ushort *) *xpp;
-#line 3158
+#line 3210
xp += ni;
-#line 3158
+#line 3210
tp += ni;
-#line 3158
+#line 3210
*xpp = (void*)xp;
-#line 3158
+#line 3210
}
-#line 3158
+#line 3210
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3158
+#line 3210
-#line 3158
+#line 3210
#else /* not SX */
-#line 3158
+#line 3210
const char *xp = (const char *) *xpp;
-#line 3158
+#line 3210
int status = NC_NOERR;
-#line 3158
+#line 3210
-#line 3158
+#line 3210
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3158
+#line 3210
{
-#line 3158
+#line 3210
const int lstatus = ncx_get_ushort_int(xp, tp);
-#line 3158
+#line 3210
if (status == NC_NOERR) /* report the first encountered error */
-#line 3158
+#line 3210
status = lstatus;
-#line 3158
+#line 3210
}
-#line 3158
+#line 3210
-#line 3158
+#line 3210
*xpp = (const void *)xp;
-#line 3158
+#line 3210
return status;
-#line 3158
+#line 3210
#endif
-#line 3158
+#line 3210
}
-#line 3158
+#line 3210
int
-#line 3159
+#line 3211
ncx_getn_ushort_long(const void **xpp, size_t nelems, long *tp)
-#line 3159
+#line 3211
{
-#line 3159
+#line 3211
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3159
+#line 3211
-#line 3159
+#line 3211
/* basic algorithm is:
-#line 3159
+#line 3211
* - ensure sane alignment of input data
-#line 3159
+#line 3211
* - copy (conversion happens automatically) input data
-#line 3159
+#line 3211
* to output
-#line 3159
+#line 3211
* - update xpp to point at next unconverted input, and tp to point
-#line 3159
+#line 3211
* at next location for converted output
-#line 3159
+#line 3211
*/
-#line 3159
+#line 3211
long i, j, ni;
-#line 3159
+#line 3211
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3159
+#line 3211
ushort *xp;
-#line 3159
+#line 3211
int nrange = 0; /* number of range errors */
-#line 3159
+#line 3211
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3159
+#line 3211
long cxp = (long) *((char**)xpp);
-#line 3159
+#line 3211
-#line 3159
+#line 3211
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3159
+#line 3211
/* sjl: manually stripmine so we can limit amount of
-#line 3159
+#line 3211
* vector work space reserved to LOOPCNT elements. Also
-#line 3159
+#line 3211
* makes vectorisation easy */
-#line 3159
+#line 3211
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3159
+#line 3211
ni=Min(nelems-j,LOOPCNT);
-#line 3159
+#line 3211
if (realign) {
-#line 3159
+#line 3211
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3159
+#line 3211
xp = tmp;
-#line 3159
+#line 3211
} else {
-#line 3159
+#line 3211
xp = (ushort *) *xpp;
-#line 3159
+#line 3211
}
-#line 3159
+#line 3211
/* copy the next block */
-#line 3159
+#line 3211
#pragma cdir loopcnt=LOOPCNT
-#line 3159
+#line 3211
#pragma cdir shortloop
-#line 3159
+#line 3211
for (i=0; i<ni; i++) {
-#line 3159
+#line 3211
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3159
+#line 3211
/* test for range errors (not always needed but do it anyway) */
-#line 3159
+#line 3211
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3159
+#line 3211
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3159
+#line 3211
nrange += xp[i] > LONG_MAX ;
-#line 3159
+#line 3211
}
-#line 3159
+#line 3211
/* update xpp and tp */
-#line 3159
+#line 3211
if (realign) xp = (ushort *) *xpp;
-#line 3159
+#line 3211
xp += ni;
-#line 3159
+#line 3211
tp += ni;
-#line 3159
+#line 3211
*xpp = (void*)xp;
-#line 3159
+#line 3211
}
-#line 3159
+#line 3211
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3159
+#line 3211
-#line 3159
+#line 3211
#else /* not SX */
-#line 3159
+#line 3211
const char *xp = (const char *) *xpp;
-#line 3159
+#line 3211
int status = NC_NOERR;
-#line 3159
+#line 3211
-#line 3159
+#line 3211
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3159
+#line 3211
{
-#line 3159
+#line 3211
const int lstatus = ncx_get_ushort_long(xp, tp);
-#line 3159
+#line 3211
if (status == NC_NOERR) /* report the first encountered error */
-#line 3159
+#line 3211
status = lstatus;
-#line 3159
+#line 3211
}
-#line 3159
+#line 3211
-#line 3159
+#line 3211
*xpp = (const void *)xp;
-#line 3159
+#line 3211
return status;
-#line 3159
+#line 3211
#endif
-#line 3159
+#line 3211
}
-#line 3159
+#line 3211
int
-#line 3160
+#line 3212
ncx_getn_ushort_float(const void **xpp, size_t nelems, float *tp)
-#line 3160
+#line 3212
{
-#line 3160
+#line 3212
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3160
+#line 3212
-#line 3160
+#line 3212
/* basic algorithm is:
-#line 3160
+#line 3212
* - ensure sane alignment of input data
-#line 3160
+#line 3212
* - copy (conversion happens automatically) input data
-#line 3160
+#line 3212
* to output
-#line 3160
+#line 3212
* - update xpp to point at next unconverted input, and tp to point
-#line 3160
+#line 3212
* at next location for converted output
-#line 3160
+#line 3212
*/
-#line 3160
+#line 3212
long i, j, ni;
-#line 3160
+#line 3212
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3160
+#line 3212
ushort *xp;
-#line 3160
+#line 3212
int nrange = 0; /* number of range errors */
-#line 3160
+#line 3212
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3160
+#line 3212
long cxp = (long) *((char**)xpp);
-#line 3160
+#line 3212
-#line 3160
+#line 3212
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3160
+#line 3212
/* sjl: manually stripmine so we can limit amount of
-#line 3160
+#line 3212
* vector work space reserved to LOOPCNT elements. Also
-#line 3160
+#line 3212
* makes vectorisation easy */
-#line 3160
+#line 3212
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3160
+#line 3212
ni=Min(nelems-j,LOOPCNT);
-#line 3160
+#line 3212
if (realign) {
-#line 3160
+#line 3212
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3160
+#line 3212
xp = tmp;
-#line 3160
+#line 3212
} else {
-#line 3160
+#line 3212
xp = (ushort *) *xpp;
-#line 3160
+#line 3212
}
-#line 3160
+#line 3212
/* copy the next block */
-#line 3160
+#line 3212
#pragma cdir loopcnt=LOOPCNT
-#line 3160
+#line 3212
#pragma cdir shortloop
-#line 3160
+#line 3212
for (i=0; i<ni; i++) {
-#line 3160
+#line 3212
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3160
+#line 3212
/* test for range errors (not always needed but do it anyway) */
-#line 3160
+#line 3212
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3160
+#line 3212
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3160
+#line 3212
nrange += xp[i] > FLOAT_MAX ;
-#line 3160
+#line 3212
}
-#line 3160
+#line 3212
/* update xpp and tp */
-#line 3160
+#line 3212
if (realign) xp = (ushort *) *xpp;
-#line 3160
+#line 3212
xp += ni;
-#line 3160
+#line 3212
tp += ni;
-#line 3160
+#line 3212
*xpp = (void*)xp;
-#line 3160
+#line 3212
}
-#line 3160
+#line 3212
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3160
+#line 3212
-#line 3160
+#line 3212
#else /* not SX */
-#line 3160
+#line 3212
const char *xp = (const char *) *xpp;
-#line 3160
+#line 3212
int status = NC_NOERR;
-#line 3160
+#line 3212
-#line 3160
+#line 3212
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3160
+#line 3212
{
-#line 3160
+#line 3212
const int lstatus = ncx_get_ushort_float(xp, tp);
-#line 3160
+#line 3212
if (status == NC_NOERR) /* report the first encountered error */
-#line 3160
+#line 3212
status = lstatus;
-#line 3160
+#line 3212
}
-#line 3160
+#line 3212
-#line 3160
+#line 3212
*xpp = (const void *)xp;
-#line 3160
+#line 3212
return status;
-#line 3160
+#line 3212
#endif
-#line 3160
+#line 3212
}
-#line 3160
+#line 3212
int
-#line 3161
+#line 3213
ncx_getn_ushort_double(const void **xpp, size_t nelems, double *tp)
-#line 3161
+#line 3213
{
-#line 3161
+#line 3213
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3161
+#line 3213
-#line 3161
+#line 3213
/* basic algorithm is:
-#line 3161
+#line 3213
* - ensure sane alignment of input data
-#line 3161
+#line 3213
* - copy (conversion happens automatically) input data
-#line 3161
+#line 3213
* to output
-#line 3161
+#line 3213
* - update xpp to point at next unconverted input, and tp to point
-#line 3161
+#line 3213
* at next location for converted output
-#line 3161
+#line 3213
*/
-#line 3161
+#line 3213
long i, j, ni;
-#line 3161
+#line 3213
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3161
+#line 3213
ushort *xp;
-#line 3161
+#line 3213
int nrange = 0; /* number of range errors */
-#line 3161
+#line 3213
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3161
+#line 3213
long cxp = (long) *((char**)xpp);
-#line 3161
+#line 3213
-#line 3161
+#line 3213
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3161
+#line 3213
/* sjl: manually stripmine so we can limit amount of
-#line 3161
+#line 3213
* vector work space reserved to LOOPCNT elements. Also
-#line 3161
+#line 3213
* makes vectorisation easy */
-#line 3161
+#line 3213
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3161
+#line 3213
ni=Min(nelems-j,LOOPCNT);
-#line 3161
+#line 3213
if (realign) {
-#line 3161
+#line 3213
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3161
+#line 3213
xp = tmp;
-#line 3161
+#line 3213
} else {
-#line 3161
+#line 3213
xp = (ushort *) *xpp;
-#line 3161
+#line 3213
}
-#line 3161
+#line 3213
/* copy the next block */
-#line 3161
+#line 3213
#pragma cdir loopcnt=LOOPCNT
-#line 3161
+#line 3213
#pragma cdir shortloop
-#line 3161
+#line 3213
for (i=0; i<ni; i++) {
-#line 3161
+#line 3213
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3161
+#line 3213
/* test for range errors (not always needed but do it anyway) */
-#line 3161
+#line 3213
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3161
+#line 3213
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3161
+#line 3213
nrange += xp[i] > DOUBLE_MAX ;
-#line 3161
+#line 3213
}
-#line 3161
+#line 3213
/* update xpp and tp */
-#line 3161
+#line 3213
if (realign) xp = (ushort *) *xpp;
-#line 3161
+#line 3213
xp += ni;
-#line 3161
+#line 3213
tp += ni;
-#line 3161
+#line 3213
*xpp = (void*)xp;
-#line 3161
+#line 3213
}
-#line 3161
+#line 3213
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3161
+#line 3213
-#line 3161
+#line 3213
#else /* not SX */
-#line 3161
+#line 3213
const char *xp = (const char *) *xpp;
-#line 3161
+#line 3213
int status = NC_NOERR;
-#line 3161
+#line 3213
-#line 3161
+#line 3213
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3161
+#line 3213
{
-#line 3161
+#line 3213
const int lstatus = ncx_get_ushort_double(xp, tp);
-#line 3161
+#line 3213
if (status == NC_NOERR) /* report the first encountered error */
-#line 3161
+#line 3213
status = lstatus;
-#line 3161
+#line 3213
}
-#line 3161
+#line 3213
-#line 3161
+#line 3213
*xpp = (const void *)xp;
-#line 3161
+#line 3213
return status;
-#line 3161
+#line 3213
#endif
-#line 3161
+#line 3213
}
-#line 3161
+#line 3213
int
-#line 3162
+#line 3214
ncx_getn_ushort_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3162
+#line 3214
{
-#line 3162
+#line 3214
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3162
+#line 3214
-#line 3162
+#line 3214
/* basic algorithm is:
-#line 3162
+#line 3214
* - ensure sane alignment of input data
-#line 3162
+#line 3214
* - copy (conversion happens automatically) input data
-#line 3162
+#line 3214
* to output
-#line 3162
+#line 3214
* - update xpp to point at next unconverted input, and tp to point
-#line 3162
+#line 3214
* at next location for converted output
-#line 3162
+#line 3214
*/
-#line 3162
+#line 3214
long i, j, ni;
-#line 3162
+#line 3214
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3162
+#line 3214
ushort *xp;
-#line 3162
+#line 3214
int nrange = 0; /* number of range errors */
-#line 3162
+#line 3214
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3162
+#line 3214
long cxp = (long) *((char**)xpp);
-#line 3162
+#line 3214
-#line 3162
+#line 3214
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3162
+#line 3214
/* sjl: manually stripmine so we can limit amount of
-#line 3162
+#line 3214
* vector work space reserved to LOOPCNT elements. Also
-#line 3162
+#line 3214
* makes vectorisation easy */
-#line 3162
+#line 3214
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3162
+#line 3214
ni=Min(nelems-j,LOOPCNT);
-#line 3162
+#line 3214
if (realign) {
-#line 3162
+#line 3214
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3162
+#line 3214
xp = tmp;
-#line 3162
+#line 3214
} else {
-#line 3162
+#line 3214
xp = (ushort *) *xpp;
-#line 3162
+#line 3214
}
-#line 3162
+#line 3214
/* copy the next block */
-#line 3162
+#line 3214
#pragma cdir loopcnt=LOOPCNT
-#line 3162
+#line 3214
#pragma cdir shortloop
-#line 3162
+#line 3214
for (i=0; i<ni; i++) {
-#line 3162
+#line 3214
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3162
+#line 3214
/* test for range errors (not always needed but do it anyway) */
-#line 3162
+#line 3214
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3162
+#line 3214
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3162
+#line 3214
nrange += xp[i] > LONGLONG_MAX ;
-#line 3162
+#line 3214
}
-#line 3162
+#line 3214
/* update xpp and tp */
-#line 3162
+#line 3214
if (realign) xp = (ushort *) *xpp;
-#line 3162
+#line 3214
xp += ni;
-#line 3162
+#line 3214
tp += ni;
-#line 3162
+#line 3214
*xpp = (void*)xp;
-#line 3162
+#line 3214
}
-#line 3162
+#line 3214
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3162
+#line 3214
-#line 3162
+#line 3214
#else /* not SX */
-#line 3162
+#line 3214
const char *xp = (const char *) *xpp;
-#line 3162
+#line 3214
int status = NC_NOERR;
-#line 3162
+#line 3214
-#line 3162
+#line 3214
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3162
+#line 3214
{
-#line 3162
+#line 3214
const int lstatus = ncx_get_ushort_longlong(xp, tp);
-#line 3162
+#line 3214
if (status == NC_NOERR) /* report the first encountered error */
-#line 3162
+#line 3214
status = lstatus;
-#line 3162
+#line 3214
}
-#line 3162
+#line 3214
-#line 3162
+#line 3214
*xpp = (const void *)xp;
-#line 3162
+#line 3214
return status;
-#line 3162
+#line 3214
#endif
-#line 3162
+#line 3214
}
-#line 3162
+#line 3214
int
-#line 3163
+#line 3215
ncx_getn_ushort_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3163
+#line 3215
{
-#line 3163
+#line 3215
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3163
+#line 3215
-#line 3163
+#line 3215
/* basic algorithm is:
-#line 3163
+#line 3215
* - ensure sane alignment of input data
-#line 3163
+#line 3215
* - copy (conversion happens automatically) input data
-#line 3163
+#line 3215
* to output
-#line 3163
+#line 3215
* - update xpp to point at next unconverted input, and tp to point
-#line 3163
+#line 3215
* at next location for converted output
-#line 3163
+#line 3215
*/
-#line 3163
+#line 3215
long i, j, ni;
-#line 3163
+#line 3215
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3163
+#line 3215
ushort *xp;
-#line 3163
+#line 3215
int nrange = 0; /* number of range errors */
-#line 3163
+#line 3215
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3163
+#line 3215
long cxp = (long) *((char**)xpp);
-#line 3163
+#line 3215
-#line 3163
+#line 3215
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3163
+#line 3215
/* sjl: manually stripmine so we can limit amount of
-#line 3163
+#line 3215
* vector work space reserved to LOOPCNT elements. Also
-#line 3163
+#line 3215
* makes vectorisation easy */
-#line 3163
+#line 3215
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3163
+#line 3215
ni=Min(nelems-j,LOOPCNT);
-#line 3163
+#line 3215
if (realign) {
-#line 3163
+#line 3215
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3163
+#line 3215
xp = tmp;
-#line 3163
+#line 3215
} else {
-#line 3163
+#line 3215
xp = (ushort *) *xpp;
-#line 3163
+#line 3215
}
-#line 3163
+#line 3215
/* copy the next block */
-#line 3163
+#line 3215
#pragma cdir loopcnt=LOOPCNT
-#line 3163
+#line 3215
#pragma cdir shortloop
-#line 3163
+#line 3215
for (i=0; i<ni; i++) {
-#line 3163
+#line 3215
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3163
+#line 3215
/* test for range errors (not always needed but do it anyway) */
-#line 3163
+#line 3215
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3163
+#line 3215
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3163
+#line 3215
nrange += xp[i] > UCHAR_MAX ;
-#line 3163
+#line 3215
}
-#line 3163
+#line 3215
/* update xpp and tp */
-#line 3163
+#line 3215
if (realign) xp = (ushort *) *xpp;
-#line 3163
+#line 3215
xp += ni;
-#line 3163
+#line 3215
tp += ni;
-#line 3163
+#line 3215
*xpp = (void*)xp;
-#line 3163
+#line 3215
}
-#line 3163
+#line 3215
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3163
+#line 3215
-#line 3163
+#line 3215
#else /* not SX */
-#line 3163
+#line 3215
const char *xp = (const char *) *xpp;
-#line 3163
+#line 3215
int status = NC_NOERR;
-#line 3163
+#line 3215
-#line 3163
+#line 3215
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3163
+#line 3215
{
-#line 3163
+#line 3215
const int lstatus = ncx_get_ushort_uchar(xp, tp);
-#line 3163
+#line 3215
if (status == NC_NOERR) /* report the first encountered error */
-#line 3163
+#line 3215
status = lstatus;
-#line 3163
+#line 3215
}
-#line 3163
+#line 3215
-#line 3163
+#line 3215
*xpp = (const void *)xp;
-#line 3163
+#line 3215
return status;
-#line 3163
+#line 3215
#endif
-#line 3163
+#line 3215
}
-#line 3163
+#line 3215
int
-#line 3164
+#line 3216
ncx_getn_ushort_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3164
+#line 3216
{
-#line 3164
+#line 3216
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3164
+#line 3216
-#line 3164
+#line 3216
/* basic algorithm is:
-#line 3164
+#line 3216
* - ensure sane alignment of input data
-#line 3164
+#line 3216
* - copy (conversion happens automatically) input data
-#line 3164
+#line 3216
* to output
-#line 3164
+#line 3216
* - update xpp to point at next unconverted input, and tp to point
-#line 3164
+#line 3216
* at next location for converted output
-#line 3164
+#line 3216
*/
-#line 3164
+#line 3216
long i, j, ni;
-#line 3164
+#line 3216
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3164
+#line 3216
ushort *xp;
-#line 3164
+#line 3216
int nrange = 0; /* number of range errors */
-#line 3164
+#line 3216
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3164
+#line 3216
long cxp = (long) *((char**)xpp);
-#line 3164
+#line 3216
-#line 3164
+#line 3216
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3164
+#line 3216
/* sjl: manually stripmine so we can limit amount of
-#line 3164
+#line 3216
* vector work space reserved to LOOPCNT elements. Also
-#line 3164
+#line 3216
* makes vectorisation easy */
-#line 3164
+#line 3216
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3164
+#line 3216
ni=Min(nelems-j,LOOPCNT);
-#line 3164
+#line 3216
if (realign) {
-#line 3164
+#line 3216
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3164
+#line 3216
xp = tmp;
-#line 3164
+#line 3216
} else {
-#line 3164
+#line 3216
xp = (ushort *) *xpp;
-#line 3164
+#line 3216
}
-#line 3164
+#line 3216
/* copy the next block */
-#line 3164
+#line 3216
#pragma cdir loopcnt=LOOPCNT
-#line 3164
+#line 3216
#pragma cdir shortloop
-#line 3164
+#line 3216
for (i=0; i<ni; i++) {
-#line 3164
+#line 3216
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3164
+#line 3216
/* test for range errors (not always needed but do it anyway) */
-#line 3164
+#line 3216
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3164
+#line 3216
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3164
+#line 3216
nrange += xp[i] > UINT_MAX ;
-#line 3164
+#line 3216
}
-#line 3164
+#line 3216
/* update xpp and tp */
-#line 3164
+#line 3216
if (realign) xp = (ushort *) *xpp;
-#line 3164
+#line 3216
xp += ni;
-#line 3164
+#line 3216
tp += ni;
-#line 3164
+#line 3216
*xpp = (void*)xp;
-#line 3164
+#line 3216
}
-#line 3164
+#line 3216
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3164
+#line 3216
-#line 3164
+#line 3216
#else /* not SX */
-#line 3164
+#line 3216
const char *xp = (const char *) *xpp;
-#line 3164
+#line 3216
int status = NC_NOERR;
-#line 3164
+#line 3216
-#line 3164
+#line 3216
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3164
+#line 3216
{
-#line 3164
+#line 3216
const int lstatus = ncx_get_ushort_uint(xp, tp);
-#line 3164
+#line 3216
if (status == NC_NOERR) /* report the first encountered error */
-#line 3164
+#line 3216
status = lstatus;
-#line 3164
+#line 3216
}
-#line 3164
+#line 3216
-#line 3164
+#line 3216
*xpp = (const void *)xp;
-#line 3164
+#line 3216
return status;
-#line 3164
+#line 3216
#endif
-#line 3164
+#line 3216
}
-#line 3164
+#line 3216
int
-#line 3165
+#line 3217
ncx_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3165
+#line 3217
{
-#line 3165
+#line 3217
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3165
+#line 3217
-#line 3165
+#line 3217
/* basic algorithm is:
-#line 3165
+#line 3217
* - ensure sane alignment of input data
-#line 3165
+#line 3217
* - copy (conversion happens automatically) input data
-#line 3165
+#line 3217
* to output
-#line 3165
+#line 3217
* - update xpp to point at next unconverted input, and tp to point
-#line 3165
+#line 3217
* at next location for converted output
-#line 3165
+#line 3217
*/
-#line 3165
+#line 3217
long i, j, ni;
-#line 3165
+#line 3217
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3165
+#line 3217
ushort *xp;
-#line 3165
+#line 3217
int nrange = 0; /* number of range errors */
-#line 3165
+#line 3217
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3165
+#line 3217
long cxp = (long) *((char**)xpp);
-#line 3165
+#line 3217
-#line 3165
+#line 3217
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3165
+#line 3217
/* sjl: manually stripmine so we can limit amount of
-#line 3165
+#line 3217
* vector work space reserved to LOOPCNT elements. Also
-#line 3165
+#line 3217
* makes vectorisation easy */
-#line 3165
+#line 3217
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3165
+#line 3217
ni=Min(nelems-j,LOOPCNT);
-#line 3165
+#line 3217
if (realign) {
-#line 3165
+#line 3217
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_USHORT));
-#line 3165
+#line 3217
xp = tmp;
-#line 3165
+#line 3217
} else {
-#line 3165
+#line 3217
xp = (ushort *) *xpp;
-#line 3165
+#line 3217
}
-#line 3165
+#line 3217
/* copy the next block */
-#line 3165
+#line 3217
#pragma cdir loopcnt=LOOPCNT
-#line 3165
+#line 3217
#pragma cdir shortloop
-#line 3165
+#line 3217
for (i=0; i<ni; i++) {
-#line 3165
+#line 3217
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3165
+#line 3217
/* test for range errors (not always needed but do it anyway) */
-#line 3165
+#line 3217
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3165
+#line 3217
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3165
+#line 3217
nrange += xp[i] > ULONGLONG_MAX ;
-#line 3165
+#line 3217
}
-#line 3165
+#line 3217
/* update xpp and tp */
-#line 3165
+#line 3217
if (realign) xp = (ushort *) *xpp;
-#line 3165
+#line 3217
xp += ni;
-#line 3165
+#line 3217
tp += ni;
-#line 3165
+#line 3217
*xpp = (void*)xp;
-#line 3165
+#line 3217
}
-#line 3165
+#line 3217
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3165
+#line 3217
-#line 3165
+#line 3217
#else /* not SX */
-#line 3165
+#line 3217
const char *xp = (const char *) *xpp;
-#line 3165
+#line 3217
int status = NC_NOERR;
-#line 3165
+#line 3217
-#line 3165
+#line 3217
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3165
+#line 3217
{
-#line 3165
+#line 3217
const int lstatus = ncx_get_ushort_ulonglong(xp, tp);
-#line 3165
+#line 3217
if (status == NC_NOERR) /* report the first encountered error */
-#line 3165
+#line 3217
status = lstatus;
-#line 3165
+#line 3217
}
-#line 3165
+#line 3217
-#line 3165
+#line 3217
*xpp = (const void *)xp;
-#line 3165
+#line 3217
return status;
-#line 3165
+#line 3217
#endif
-#line 3165
+#line 3217
}
-#line 3165
+#line 3217
int
-#line 3167
+#line 3219
ncx_pad_getn_ushort_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3167
+#line 3219
{
-#line 3167
+#line 3219
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3167
+#line 3219
-#line 3167
+#line 3219
const char *xp = (const char *) *xpp;
-#line 3167
+#line 3219
int status = NC_NOERR;
-#line 3167
+#line 3219
-#line 3167
+#line 3219
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3167
+#line 3219
{
-#line 3167
+#line 3219
const int lstatus = ncx_get_ushort_schar(xp, tp);
-#line 3167
+#line 3219
if (status == NC_NOERR) /* report the first encountered error */
-#line 3167
+#line 3219
status = lstatus;
-#line 3167
+#line 3219
}
-#line 3167
+#line 3219
-#line 3167
+#line 3219
if (rndup != 0)
-#line 3167
+#line 3219
xp += X_SIZEOF_USHORT;
-#line 3167
+#line 3219
-#line 3167
+#line 3219
*xpp = (void *)xp;
-#line 3167
+#line 3219
return status;
-#line 3167
+#line 3219
}
-#line 3167
+#line 3219
int
-#line 3168
+#line 3220
ncx_pad_getn_ushort_short(const void **xpp, size_t nelems, short *tp)
-#line 3168
+#line 3220
{
-#line 3168
+#line 3220
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3168
+#line 3220
-#line 3168
+#line 3220
const char *xp = (const char *) *xpp;
-#line 3168
+#line 3220
int status = NC_NOERR;
-#line 3168
+#line 3220
-#line 3168
+#line 3220
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3168
+#line 3220
{
-#line 3168
+#line 3220
const int lstatus = ncx_get_ushort_short(xp, tp);
-#line 3168
+#line 3220
if (status == NC_NOERR) /* report the first encountered error */
-#line 3168
+#line 3220
status = lstatus;
-#line 3168
+#line 3220
}
-#line 3168
+#line 3220
-#line 3168
+#line 3220
if (rndup != 0)
-#line 3168
+#line 3220
xp += X_SIZEOF_USHORT;
-#line 3168
+#line 3220
-#line 3168
+#line 3220
*xpp = (void *)xp;
-#line 3168
+#line 3220
return status;
-#line 3168
+#line 3220
}
-#line 3168
+#line 3220
int
-#line 3169
+#line 3221
ncx_pad_getn_ushort_int(const void **xpp, size_t nelems, int *tp)
-#line 3169
+#line 3221
{
-#line 3169
+#line 3221
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3169
+#line 3221
-#line 3169
+#line 3221
const char *xp = (const char *) *xpp;
-#line 3169
+#line 3221
int status = NC_NOERR;
-#line 3169
+#line 3221
-#line 3169
+#line 3221
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3169
+#line 3221
{
-#line 3169
+#line 3221
const int lstatus = ncx_get_ushort_int(xp, tp);
-#line 3169
+#line 3221
if (status == NC_NOERR) /* report the first encountered error */
-#line 3169
+#line 3221
status = lstatus;
-#line 3169
+#line 3221
}
-#line 3169
+#line 3221
-#line 3169
+#line 3221
if (rndup != 0)
-#line 3169
+#line 3221
xp += X_SIZEOF_USHORT;
-#line 3169
+#line 3221
-#line 3169
+#line 3221
*xpp = (void *)xp;
-#line 3169
+#line 3221
return status;
-#line 3169
+#line 3221
}
-#line 3169
+#line 3221
int
-#line 3170
+#line 3222
ncx_pad_getn_ushort_long(const void **xpp, size_t nelems, long *tp)
-#line 3170
+#line 3222
{
-#line 3170
+#line 3222
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3170
+#line 3222
-#line 3170
+#line 3222
const char *xp = (const char *) *xpp;
-#line 3170
+#line 3222
int status = NC_NOERR;
-#line 3170
+#line 3222
-#line 3170
+#line 3222
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3170
+#line 3222
{
-#line 3170
+#line 3222
const int lstatus = ncx_get_ushort_long(xp, tp);
-#line 3170
+#line 3222
if (status == NC_NOERR) /* report the first encountered error */
-#line 3170
+#line 3222
status = lstatus;
-#line 3170
+#line 3222
}
-#line 3170
+#line 3222
-#line 3170
+#line 3222
if (rndup != 0)
-#line 3170
+#line 3222
xp += X_SIZEOF_USHORT;
-#line 3170
+#line 3222
-#line 3170
+#line 3222
*xpp = (void *)xp;
-#line 3170
+#line 3222
return status;
-#line 3170
+#line 3222
}
-#line 3170
+#line 3222
int
-#line 3171
+#line 3223
ncx_pad_getn_ushort_float(const void **xpp, size_t nelems, float *tp)
-#line 3171
+#line 3223
{
-#line 3171
+#line 3223
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3171
+#line 3223
-#line 3171
+#line 3223
const char *xp = (const char *) *xpp;
-#line 3171
+#line 3223
int status = NC_NOERR;
-#line 3171
+#line 3223
-#line 3171
+#line 3223
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3171
+#line 3223
{
-#line 3171
+#line 3223
const int lstatus = ncx_get_ushort_float(xp, tp);
-#line 3171
+#line 3223
if (status == NC_NOERR) /* report the first encountered error */
-#line 3171
+#line 3223
status = lstatus;
-#line 3171
+#line 3223
}
-#line 3171
+#line 3223
-#line 3171
+#line 3223
if (rndup != 0)
-#line 3171
+#line 3223
xp += X_SIZEOF_USHORT;
-#line 3171
+#line 3223
-#line 3171
+#line 3223
*xpp = (void *)xp;
-#line 3171
+#line 3223
return status;
-#line 3171
+#line 3223
}
-#line 3171
+#line 3223
int
-#line 3172
+#line 3224
ncx_pad_getn_ushort_double(const void **xpp, size_t nelems, double *tp)
-#line 3172
+#line 3224
{
-#line 3172
+#line 3224
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3172
+#line 3224
-#line 3172
+#line 3224
const char *xp = (const char *) *xpp;
-#line 3172
+#line 3224
int status = NC_NOERR;
-#line 3172
+#line 3224
-#line 3172
+#line 3224
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3172
+#line 3224
{
-#line 3172
+#line 3224
const int lstatus = ncx_get_ushort_double(xp, tp);
-#line 3172
+#line 3224
if (status == NC_NOERR) /* report the first encountered error */
-#line 3172
+#line 3224
status = lstatus;
-#line 3172
+#line 3224
}
-#line 3172
+#line 3224
-#line 3172
+#line 3224
if (rndup != 0)
-#line 3172
+#line 3224
xp += X_SIZEOF_USHORT;
-#line 3172
+#line 3224
-#line 3172
+#line 3224
*xpp = (void *)xp;
-#line 3172
+#line 3224
return status;
-#line 3172
+#line 3224
}
-#line 3172
+#line 3224
int
-#line 3173
+#line 3225
ncx_pad_getn_ushort_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3173
+#line 3225
{
-#line 3173
+#line 3225
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3173
+#line 3225
-#line 3173
+#line 3225
const char *xp = (const char *) *xpp;
-#line 3173
+#line 3225
int status = NC_NOERR;
-#line 3173
+#line 3225
-#line 3173
+#line 3225
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3173
+#line 3225
{
-#line 3173
+#line 3225
const int lstatus = ncx_get_ushort_uchar(xp, tp);
-#line 3173
+#line 3225
if (status == NC_NOERR) /* report the first encountered error */
-#line 3173
+#line 3225
status = lstatus;
-#line 3173
+#line 3225
}
-#line 3173
+#line 3225
-#line 3173
+#line 3225
if (rndup != 0)
-#line 3173
+#line 3225
xp += X_SIZEOF_USHORT;
-#line 3173
+#line 3225
-#line 3173
+#line 3225
*xpp = (void *)xp;
-#line 3173
+#line 3225
return status;
-#line 3173
+#line 3225
}
-#line 3173
+#line 3225
int
-#line 3174
+#line 3226
ncx_pad_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3174
+#line 3226
{
-#line 3174
+#line 3226
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3174
+#line 3226
-#line 3174
+#line 3226
const char *xp = (const char *) *xpp;
-#line 3174
+#line 3226
int status = NC_NOERR;
-#line 3174
+#line 3226
-#line 3174
+#line 3226
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3174
+#line 3226
{
-#line 3174
+#line 3226
const int lstatus = ncx_get_ushort_ushort(xp, tp);
-#line 3174
+#line 3226
if (status == NC_NOERR) /* report the first encountered error */
-#line 3174
+#line 3226
status = lstatus;
-#line 3174
+#line 3226
}
-#line 3174
+#line 3226
-#line 3174
+#line 3226
if (rndup != 0)
-#line 3174
+#line 3226
xp += X_SIZEOF_USHORT;
-#line 3174
+#line 3226
-#line 3174
+#line 3226
*xpp = (void *)xp;
-#line 3174
+#line 3226
return status;
-#line 3174
+#line 3226
}
-#line 3174
+#line 3226
int
-#line 3175
+#line 3227
ncx_pad_getn_ushort_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3175
+#line 3227
{
-#line 3175
+#line 3227
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3175
+#line 3227
-#line 3175
+#line 3227
const char *xp = (const char *) *xpp;
-#line 3175
+#line 3227
int status = NC_NOERR;
-#line 3175
+#line 3227
-#line 3175
+#line 3227
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3175
+#line 3227
{
-#line 3175
+#line 3227
const int lstatus = ncx_get_ushort_uint(xp, tp);
-#line 3175
+#line 3227
if (status == NC_NOERR) /* report the first encountered error */
-#line 3175
+#line 3227
status = lstatus;
-#line 3175
+#line 3227
}
-#line 3175
+#line 3227
-#line 3175
+#line 3227
if (rndup != 0)
-#line 3175
+#line 3227
xp += X_SIZEOF_USHORT;
-#line 3175
+#line 3227
-#line 3175
+#line 3227
*xpp = (void *)xp;
-#line 3175
+#line 3227
return status;
-#line 3175
+#line 3227
}
-#line 3175
+#line 3227
int
-#line 3176
+#line 3228
ncx_pad_getn_ushort_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3176
+#line 3228
{
-#line 3176
+#line 3228
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3176
+#line 3228
-#line 3176
+#line 3228
const char *xp = (const char *) *xpp;
-#line 3176
+#line 3228
int status = NC_NOERR;
-#line 3176
+#line 3228
-#line 3176
+#line 3228
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3176
+#line 3228
{
-#line 3176
+#line 3228
const int lstatus = ncx_get_ushort_longlong(xp, tp);
-#line 3176
+#line 3228
if (status == NC_NOERR) /* report the first encountered error */
-#line 3176
+#line 3228
status = lstatus;
-#line 3176
+#line 3228
}
-#line 3176
+#line 3228
-#line 3176
+#line 3228
if (rndup != 0)
-#line 3176
+#line 3228
xp += X_SIZEOF_USHORT;
-#line 3176
+#line 3228
-#line 3176
+#line 3228
*xpp = (void *)xp;
-#line 3176
+#line 3228
return status;
-#line 3176
+#line 3228
}
-#line 3176
+#line 3228
int
-#line 3177
+#line 3229
ncx_pad_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3177
+#line 3229
{
-#line 3177
+#line 3229
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3177
+#line 3229
-#line 3177
+#line 3229
const char *xp = (const char *) *xpp;
-#line 3177
+#line 3229
int status = NC_NOERR;
-#line 3177
+#line 3229
-#line 3177
+#line 3229
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3177
+#line 3229
{
-#line 3177
+#line 3229
const int lstatus = ncx_get_ushort_ulonglong(xp, tp);
-#line 3177
+#line 3229
if (status == NC_NOERR) /* report the first encountered error */
-#line 3177
+#line 3229
status = lstatus;
-#line 3177
+#line 3229
}
-#line 3177
+#line 3229
-#line 3177
+#line 3229
if (rndup != 0)
-#line 3177
+#line 3229
xp += X_SIZEOF_USHORT;
-#line 3177
+#line 3229
-#line 3177
+#line 3229
*xpp = (void *)xp;
-#line 3177
+#line 3229
return status;
-#line 3177
+#line 3229
}
-#line 3177
+#line 3229
#if X_SIZEOF_USHORT == SIZEOF_USHORT
@@ -17332,2074 +19417,2074 @@ ncx_putn_ushort_ushort(void **xpp, size_t nelems, const unsigned short *tp, void
}
#else
int
-#line 3193
+#line 3245
ncx_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3193
+#line 3245
{
-#line 3193
+#line 3245
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3193
+#line 3245
-#line 3193
+#line 3245
/* basic algorithm is:
-#line 3193
+#line 3245
* - ensure sane alignment of output data
-#line 3193
+#line 3245
* - copy (conversion happens automatically) input data
-#line 3193
+#line 3245
* to output
-#line 3193
+#line 3245
* - update tp to point at next unconverted input, and xpp to point
-#line 3193
+#line 3245
* at next location for converted output
-#line 3193
+#line 3245
*/
-#line 3193
+#line 3245
long i, j, ni;
-#line 3193
+#line 3245
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3193
+#line 3245
ushort *xp;
-#line 3193
+#line 3245
int nrange = 0; /* number of range errors */
-#line 3193
+#line 3245
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3193
+#line 3245
long cxp = (long) *((char**)xpp);
-#line 3193
+#line 3245
-#line 3193
+#line 3245
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3193
+#line 3245
/* sjl: manually stripmine so we can limit amount of
-#line 3193
+#line 3245
* vector work space reserved to LOOPCNT elements. Also
-#line 3193
+#line 3245
* makes vectorisation easy */
-#line 3193
+#line 3245
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3193
+#line 3245
ni=Min(nelems-j,LOOPCNT);
-#line 3193
+#line 3245
if (realign) {
-#line 3193
+#line 3245
xp = tmp;
-#line 3193
+#line 3245
} else {
-#line 3193
+#line 3245
xp = (ushort *) *xpp;
-#line 3193
+#line 3245
}
-#line 3193
+#line 3245
/* copy the next block */
-#line 3193
+#line 3245
#pragma cdir loopcnt=LOOPCNT
-#line 3193
+#line 3245
#pragma cdir shortloop
-#line 3193
+#line 3245
for (i=0; i<ni; i++) {
-#line 3193
+#line 3245
/* the normal case: */
-#line 3193
+#line 3245
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3193
+#line 3245
/* test for range errors (not always needed but do it anyway) */
-#line 3193
+#line 3245
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3193
+#line 3245
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3193
+#line 3245
nrange += tp[i] > X_USHORT_MAX ;
-#line 3193
+#line 3245
}
-#line 3193
+#line 3245
/* copy workspace back if necessary */
-#line 3193
+#line 3245
if (realign) {
-#line 3193
+#line 3245
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3193
+#line 3245
xp = (ushort *) *xpp;
-#line 3193
+#line 3245
}
-#line 3193
+#line 3245
/* update xpp and tp */
-#line 3193
+#line 3245
xp += ni;
-#line 3193
+#line 3245
tp += ni;
-#line 3193
+#line 3245
*xpp = (void*)xp;
-#line 3193
+#line 3245
}
-#line 3193
+#line 3245
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3193
+#line 3245
-#line 3193
+#line 3245
#else /* not SX */
-#line 3193
+#line 3245
-#line 3193
+#line 3245
char *xp = (char *) *xpp;
-#line 3193
+#line 3245
int status = NC_NOERR;
-#line 3193
+#line 3245
-#line 3193
+#line 3245
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3193
+#line 3245
{
-#line 3193
+#line 3245
int lstatus = ncx_put_ushort_ushort(xp, tp, fillp);
-#line 3193
+#line 3245
if (status == NC_NOERR) /* report the first encountered error */
-#line 3193
+#line 3245
status = lstatus;
-#line 3193
+#line 3245
}
-#line 3193
+#line 3245
-#line 3193
+#line 3245
*xpp = (void *)xp;
-#line 3193
+#line 3245
return status;
-#line 3193
+#line 3245
#endif
-#line 3193
+#line 3245
}
-#line 3193
+#line 3245
#endif
int
-#line 3195
+#line 3247
ncx_putn_ushort_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3195
+#line 3247
{
-#line 3195
+#line 3247
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3195
+#line 3247
-#line 3195
+#line 3247
/* basic algorithm is:
-#line 3195
+#line 3247
* - ensure sane alignment of output data
-#line 3195
+#line 3247
* - copy (conversion happens automatically) input data
-#line 3195
+#line 3247
* to output
-#line 3195
+#line 3247
* - update tp to point at next unconverted input, and xpp to point
-#line 3195
+#line 3247
* at next location for converted output
-#line 3195
+#line 3247
*/
-#line 3195
+#line 3247
long i, j, ni;
-#line 3195
+#line 3247
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3195
+#line 3247
ushort *xp;
-#line 3195
+#line 3247
int nrange = 0; /* number of range errors */
-#line 3195
+#line 3247
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3195
+#line 3247
long cxp = (long) *((char**)xpp);
-#line 3195
+#line 3247
-#line 3195
+#line 3247
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3195
+#line 3247
/* sjl: manually stripmine so we can limit amount of
-#line 3195
+#line 3247
* vector work space reserved to LOOPCNT elements. Also
-#line 3195
+#line 3247
* makes vectorisation easy */
-#line 3195
+#line 3247
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3195
+#line 3247
ni=Min(nelems-j,LOOPCNT);
-#line 3195
+#line 3247
if (realign) {
-#line 3195
+#line 3247
xp = tmp;
-#line 3195
+#line 3247
} else {
-#line 3195
+#line 3247
xp = (ushort *) *xpp;
-#line 3195
+#line 3247
}
-#line 3195
+#line 3247
/* copy the next block */
-#line 3195
+#line 3247
#pragma cdir loopcnt=LOOPCNT
-#line 3195
+#line 3247
#pragma cdir shortloop
-#line 3195
+#line 3247
for (i=0; i<ni; i++) {
-#line 3195
+#line 3247
/* the normal case: */
-#line 3195
+#line 3247
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3195
+#line 3247
/* test for range errors (not always needed but do it anyway) */
-#line 3195
+#line 3247
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3195
+#line 3247
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3195
+#line 3247
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3195
+#line 3247
}
-#line 3195
+#line 3247
/* copy workspace back if necessary */
-#line 3195
+#line 3247
if (realign) {
-#line 3195
+#line 3247
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3195
+#line 3247
xp = (ushort *) *xpp;
-#line 3195
+#line 3247
}
-#line 3195
+#line 3247
/* update xpp and tp */
-#line 3195
+#line 3247
xp += ni;
-#line 3195
+#line 3247
tp += ni;
-#line 3195
+#line 3247
*xpp = (void*)xp;
-#line 3195
+#line 3247
}
-#line 3195
+#line 3247
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3195
+#line 3247
-#line 3195
+#line 3247
#else /* not SX */
-#line 3195
+#line 3247
-#line 3195
+#line 3247
char *xp = (char *) *xpp;
-#line 3195
+#line 3247
int status = NC_NOERR;
-#line 3195
+#line 3247
-#line 3195
+#line 3247
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3195
+#line 3247
{
-#line 3195
+#line 3247
int lstatus = ncx_put_ushort_schar(xp, tp, fillp);
-#line 3195
+#line 3247
if (status == NC_NOERR) /* report the first encountered error */
-#line 3195
+#line 3247
status = lstatus;
-#line 3195
+#line 3247
}
-#line 3195
+#line 3247
-#line 3195
+#line 3247
*xpp = (void *)xp;
-#line 3195
+#line 3247
return status;
-#line 3195
+#line 3247
#endif
-#line 3195
+#line 3247
}
-#line 3195
+#line 3247
int
-#line 3196
+#line 3248
ncx_putn_ushort_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3196
+#line 3248
{
-#line 3196
+#line 3248
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3196
+#line 3248
-#line 3196
+#line 3248
/* basic algorithm is:
-#line 3196
+#line 3248
* - ensure sane alignment of output data
-#line 3196
+#line 3248
* - copy (conversion happens automatically) input data
-#line 3196
+#line 3248
* to output
-#line 3196
+#line 3248
* - update tp to point at next unconverted input, and xpp to point
-#line 3196
+#line 3248
* at next location for converted output
-#line 3196
+#line 3248
*/
-#line 3196
+#line 3248
long i, j, ni;
-#line 3196
+#line 3248
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3196
+#line 3248
ushort *xp;
-#line 3196
+#line 3248
int nrange = 0; /* number of range errors */
-#line 3196
+#line 3248
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3196
+#line 3248
long cxp = (long) *((char**)xpp);
-#line 3196
+#line 3248
-#line 3196
+#line 3248
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3196
+#line 3248
/* sjl: manually stripmine so we can limit amount of
-#line 3196
+#line 3248
* vector work space reserved to LOOPCNT elements. Also
-#line 3196
+#line 3248
* makes vectorisation easy */
-#line 3196
+#line 3248
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3196
+#line 3248
ni=Min(nelems-j,LOOPCNT);
-#line 3196
+#line 3248
if (realign) {
-#line 3196
+#line 3248
xp = tmp;
-#line 3196
+#line 3248
} else {
-#line 3196
+#line 3248
xp = (ushort *) *xpp;
-#line 3196
+#line 3248
}
-#line 3196
+#line 3248
/* copy the next block */
-#line 3196
+#line 3248
#pragma cdir loopcnt=LOOPCNT
-#line 3196
+#line 3248
#pragma cdir shortloop
-#line 3196
+#line 3248
for (i=0; i<ni; i++) {
-#line 3196
+#line 3248
/* the normal case: */
-#line 3196
+#line 3248
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3196
+#line 3248
/* test for range errors (not always needed but do it anyway) */
-#line 3196
+#line 3248
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3196
+#line 3248
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3196
+#line 3248
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3196
+#line 3248
}
-#line 3196
+#line 3248
/* copy workspace back if necessary */
-#line 3196
+#line 3248
if (realign) {
-#line 3196
+#line 3248
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3196
+#line 3248
xp = (ushort *) *xpp;
-#line 3196
+#line 3248
}
-#line 3196
+#line 3248
/* update xpp and tp */
-#line 3196
+#line 3248
xp += ni;
-#line 3196
+#line 3248
tp += ni;
-#line 3196
+#line 3248
*xpp = (void*)xp;
-#line 3196
+#line 3248
}
-#line 3196
+#line 3248
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3196
+#line 3248
-#line 3196
+#line 3248
#else /* not SX */
-#line 3196
+#line 3248
-#line 3196
+#line 3248
char *xp = (char *) *xpp;
-#line 3196
+#line 3248
int status = NC_NOERR;
-#line 3196
+#line 3248
-#line 3196
+#line 3248
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3196
+#line 3248
{
-#line 3196
+#line 3248
int lstatus = ncx_put_ushort_short(xp, tp, fillp);
-#line 3196
+#line 3248
if (status == NC_NOERR) /* report the first encountered error */
-#line 3196
+#line 3248
status = lstatus;
-#line 3196
+#line 3248
}
-#line 3196
+#line 3248
-#line 3196
+#line 3248
*xpp = (void *)xp;
-#line 3196
+#line 3248
return status;
-#line 3196
+#line 3248
#endif
-#line 3196
+#line 3248
}
-#line 3196
+#line 3248
int
-#line 3197
+#line 3249
ncx_putn_ushort_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3197
+#line 3249
{
-#line 3197
+#line 3249
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3197
+#line 3249
-#line 3197
+#line 3249
/* basic algorithm is:
-#line 3197
+#line 3249
* - ensure sane alignment of output data
-#line 3197
+#line 3249
* - copy (conversion happens automatically) input data
-#line 3197
+#line 3249
* to output
-#line 3197
+#line 3249
* - update tp to point at next unconverted input, and xpp to point
-#line 3197
+#line 3249
* at next location for converted output
-#line 3197
+#line 3249
*/
-#line 3197
+#line 3249
long i, j, ni;
-#line 3197
+#line 3249
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3197
+#line 3249
ushort *xp;
-#line 3197
+#line 3249
int nrange = 0; /* number of range errors */
-#line 3197
+#line 3249
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3197
+#line 3249
long cxp = (long) *((char**)xpp);
-#line 3197
+#line 3249
-#line 3197
+#line 3249
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3197
+#line 3249
/* sjl: manually stripmine so we can limit amount of
-#line 3197
+#line 3249
* vector work space reserved to LOOPCNT elements. Also
-#line 3197
+#line 3249
* makes vectorisation easy */
-#line 3197
+#line 3249
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3197
+#line 3249
ni=Min(nelems-j,LOOPCNT);
-#line 3197
+#line 3249
if (realign) {
-#line 3197
+#line 3249
xp = tmp;
-#line 3197
+#line 3249
} else {
-#line 3197
+#line 3249
xp = (ushort *) *xpp;
-#line 3197
+#line 3249
}
-#line 3197
+#line 3249
/* copy the next block */
-#line 3197
+#line 3249
#pragma cdir loopcnt=LOOPCNT
-#line 3197
+#line 3249
#pragma cdir shortloop
-#line 3197
+#line 3249
for (i=0; i<ni; i++) {
-#line 3197
+#line 3249
/* the normal case: */
-#line 3197
+#line 3249
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3197
+#line 3249
/* test for range errors (not always needed but do it anyway) */
-#line 3197
+#line 3249
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3197
+#line 3249
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3197
+#line 3249
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3197
+#line 3249
}
-#line 3197
+#line 3249
/* copy workspace back if necessary */
-#line 3197
+#line 3249
if (realign) {
-#line 3197
+#line 3249
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3197
+#line 3249
xp = (ushort *) *xpp;
-#line 3197
+#line 3249
}
-#line 3197
+#line 3249
/* update xpp and tp */
-#line 3197
+#line 3249
xp += ni;
-#line 3197
+#line 3249
tp += ni;
-#line 3197
+#line 3249
*xpp = (void*)xp;
-#line 3197
+#line 3249
}
-#line 3197
+#line 3249
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3197
+#line 3249
-#line 3197
+#line 3249
#else /* not SX */
-#line 3197
+#line 3249
-#line 3197
+#line 3249
char *xp = (char *) *xpp;
-#line 3197
+#line 3249
int status = NC_NOERR;
-#line 3197
+#line 3249
-#line 3197
+#line 3249
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3197
+#line 3249
{
-#line 3197
+#line 3249
int lstatus = ncx_put_ushort_int(xp, tp, fillp);
-#line 3197
+#line 3249
if (status == NC_NOERR) /* report the first encountered error */
-#line 3197
+#line 3249
status = lstatus;
-#line 3197
+#line 3249
}
-#line 3197
+#line 3249
-#line 3197
+#line 3249
*xpp = (void *)xp;
-#line 3197
+#line 3249
return status;
-#line 3197
+#line 3249
#endif
-#line 3197
+#line 3249
}
-#line 3197
+#line 3249
int
-#line 3198
+#line 3250
ncx_putn_ushort_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3198
+#line 3250
{
-#line 3198
+#line 3250
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3198
+#line 3250
-#line 3198
+#line 3250
/* basic algorithm is:
-#line 3198
+#line 3250
* - ensure sane alignment of output data
-#line 3198
+#line 3250
* - copy (conversion happens automatically) input data
-#line 3198
+#line 3250
* to output
-#line 3198
+#line 3250
* - update tp to point at next unconverted input, and xpp to point
-#line 3198
+#line 3250
* at next location for converted output
-#line 3198
+#line 3250
*/
-#line 3198
+#line 3250
long i, j, ni;
-#line 3198
+#line 3250
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3198
+#line 3250
ushort *xp;
-#line 3198
+#line 3250
int nrange = 0; /* number of range errors */
-#line 3198
+#line 3250
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3198
+#line 3250
long cxp = (long) *((char**)xpp);
-#line 3198
+#line 3250
-#line 3198
+#line 3250
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3198
+#line 3250
/* sjl: manually stripmine so we can limit amount of
-#line 3198
+#line 3250
* vector work space reserved to LOOPCNT elements. Also
-#line 3198
+#line 3250
* makes vectorisation easy */
-#line 3198
+#line 3250
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3198
+#line 3250
ni=Min(nelems-j,LOOPCNT);
-#line 3198
+#line 3250
if (realign) {
-#line 3198
+#line 3250
xp = tmp;
-#line 3198
+#line 3250
} else {
-#line 3198
+#line 3250
xp = (ushort *) *xpp;
-#line 3198
+#line 3250
}
-#line 3198
+#line 3250
/* copy the next block */
-#line 3198
+#line 3250
#pragma cdir loopcnt=LOOPCNT
-#line 3198
+#line 3250
#pragma cdir shortloop
-#line 3198
+#line 3250
for (i=0; i<ni; i++) {
-#line 3198
+#line 3250
/* the normal case: */
-#line 3198
+#line 3250
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3198
+#line 3250
/* test for range errors (not always needed but do it anyway) */
-#line 3198
+#line 3250
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3198
+#line 3250
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3198
+#line 3250
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3198
+#line 3250
}
-#line 3198
+#line 3250
/* copy workspace back if necessary */
-#line 3198
+#line 3250
if (realign) {
-#line 3198
+#line 3250
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3198
+#line 3250
xp = (ushort *) *xpp;
-#line 3198
+#line 3250
}
-#line 3198
+#line 3250
/* update xpp and tp */
-#line 3198
+#line 3250
xp += ni;
-#line 3198
+#line 3250
tp += ni;
-#line 3198
+#line 3250
*xpp = (void*)xp;
-#line 3198
+#line 3250
}
-#line 3198
+#line 3250
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3198
+#line 3250
-#line 3198
+#line 3250
#else /* not SX */
-#line 3198
+#line 3250
-#line 3198
+#line 3250
char *xp = (char *) *xpp;
-#line 3198
+#line 3250
int status = NC_NOERR;
-#line 3198
+#line 3250
-#line 3198
+#line 3250
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3198
+#line 3250
{
-#line 3198
+#line 3250
int lstatus = ncx_put_ushort_long(xp, tp, fillp);
-#line 3198
+#line 3250
if (status == NC_NOERR) /* report the first encountered error */
-#line 3198
+#line 3250
status = lstatus;
-#line 3198
+#line 3250
}
-#line 3198
+#line 3250
-#line 3198
+#line 3250
*xpp = (void *)xp;
-#line 3198
+#line 3250
return status;
-#line 3198
+#line 3250
#endif
-#line 3198
+#line 3250
}
-#line 3198
+#line 3250
int
-#line 3199
+#line 3251
ncx_putn_ushort_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3199
+#line 3251
{
-#line 3199
+#line 3251
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3199
+#line 3251
-#line 3199
+#line 3251
/* basic algorithm is:
-#line 3199
+#line 3251
* - ensure sane alignment of output data
-#line 3199
+#line 3251
* - copy (conversion happens automatically) input data
-#line 3199
+#line 3251
* to output
-#line 3199
+#line 3251
* - update tp to point at next unconverted input, and xpp to point
-#line 3199
+#line 3251
* at next location for converted output
-#line 3199
+#line 3251
*/
-#line 3199
+#line 3251
long i, j, ni;
-#line 3199
+#line 3251
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3199
+#line 3251
ushort *xp;
-#line 3199
+#line 3251
int nrange = 0; /* number of range errors */
-#line 3199
+#line 3251
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3199
+#line 3251
long cxp = (long) *((char**)xpp);
-#line 3199
+#line 3251
-#line 3199
+#line 3251
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3199
+#line 3251
/* sjl: manually stripmine so we can limit amount of
-#line 3199
+#line 3251
* vector work space reserved to LOOPCNT elements. Also
-#line 3199
+#line 3251
* makes vectorisation easy */
-#line 3199
+#line 3251
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3199
+#line 3251
ni=Min(nelems-j,LOOPCNT);
-#line 3199
+#line 3251
if (realign) {
-#line 3199
+#line 3251
xp = tmp;
-#line 3199
+#line 3251
} else {
-#line 3199
+#line 3251
xp = (ushort *) *xpp;
-#line 3199
+#line 3251
}
-#line 3199
+#line 3251
/* copy the next block */
-#line 3199
+#line 3251
#pragma cdir loopcnt=LOOPCNT
-#line 3199
+#line 3251
#pragma cdir shortloop
-#line 3199
+#line 3251
for (i=0; i<ni; i++) {
-#line 3199
+#line 3251
/* the normal case: */
-#line 3199
+#line 3251
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3199
+#line 3251
/* test for range errors (not always needed but do it anyway) */
-#line 3199
+#line 3251
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3199
+#line 3251
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3199
+#line 3251
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3199
+#line 3251
}
-#line 3199
+#line 3251
/* copy workspace back if necessary */
-#line 3199
+#line 3251
if (realign) {
-#line 3199
+#line 3251
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3199
+#line 3251
xp = (ushort *) *xpp;
-#line 3199
+#line 3251
}
-#line 3199
+#line 3251
/* update xpp and tp */
-#line 3199
+#line 3251
xp += ni;
-#line 3199
+#line 3251
tp += ni;
-#line 3199
+#line 3251
*xpp = (void*)xp;
-#line 3199
+#line 3251
}
-#line 3199
+#line 3251
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3199
+#line 3251
-#line 3199
+#line 3251
#else /* not SX */
-#line 3199
+#line 3251
-#line 3199
+#line 3251
char *xp = (char *) *xpp;
-#line 3199
+#line 3251
int status = NC_NOERR;
-#line 3199
+#line 3251
-#line 3199
+#line 3251
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3199
+#line 3251
{
-#line 3199
+#line 3251
int lstatus = ncx_put_ushort_float(xp, tp, fillp);
-#line 3199
+#line 3251
if (status == NC_NOERR) /* report the first encountered error */
-#line 3199
+#line 3251
status = lstatus;
-#line 3199
+#line 3251
}
-#line 3199
+#line 3251
-#line 3199
+#line 3251
*xpp = (void *)xp;
-#line 3199
+#line 3251
return status;
-#line 3199
+#line 3251
#endif
-#line 3199
+#line 3251
}
-#line 3199
+#line 3251
int
-#line 3200
+#line 3252
ncx_putn_ushort_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3200
+#line 3252
{
-#line 3200
+#line 3252
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3200
+#line 3252
-#line 3200
+#line 3252
/* basic algorithm is:
-#line 3200
+#line 3252
* - ensure sane alignment of output data
-#line 3200
+#line 3252
* - copy (conversion happens automatically) input data
-#line 3200
+#line 3252
* to output
-#line 3200
+#line 3252
* - update tp to point at next unconverted input, and xpp to point
-#line 3200
+#line 3252
* at next location for converted output
-#line 3200
+#line 3252
*/
-#line 3200
+#line 3252
long i, j, ni;
-#line 3200
+#line 3252
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3200
+#line 3252
ushort *xp;
-#line 3200
+#line 3252
int nrange = 0; /* number of range errors */
-#line 3200
+#line 3252
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3200
+#line 3252
long cxp = (long) *((char**)xpp);
-#line 3200
+#line 3252
-#line 3200
+#line 3252
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3200
+#line 3252
/* sjl: manually stripmine so we can limit amount of
-#line 3200
+#line 3252
* vector work space reserved to LOOPCNT elements. Also
-#line 3200
+#line 3252
* makes vectorisation easy */
-#line 3200
+#line 3252
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3200
+#line 3252
ni=Min(nelems-j,LOOPCNT);
-#line 3200
+#line 3252
if (realign) {
-#line 3200
+#line 3252
xp = tmp;
-#line 3200
+#line 3252
} else {
-#line 3200
+#line 3252
xp = (ushort *) *xpp;
-#line 3200
+#line 3252
}
-#line 3200
+#line 3252
/* copy the next block */
-#line 3200
+#line 3252
#pragma cdir loopcnt=LOOPCNT
-#line 3200
+#line 3252
#pragma cdir shortloop
-#line 3200
+#line 3252
for (i=0; i<ni; i++) {
-#line 3200
+#line 3252
/* the normal case: */
-#line 3200
+#line 3252
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3200
+#line 3252
/* test for range errors (not always needed but do it anyway) */
-#line 3200
+#line 3252
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3200
+#line 3252
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3200
+#line 3252
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3200
+#line 3252
}
-#line 3200
+#line 3252
/* copy workspace back if necessary */
-#line 3200
+#line 3252
if (realign) {
-#line 3200
+#line 3252
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3200
+#line 3252
xp = (ushort *) *xpp;
-#line 3200
+#line 3252
}
-#line 3200
+#line 3252
/* update xpp and tp */
-#line 3200
+#line 3252
xp += ni;
-#line 3200
+#line 3252
tp += ni;
-#line 3200
+#line 3252
*xpp = (void*)xp;
-#line 3200
+#line 3252
}
-#line 3200
+#line 3252
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3200
+#line 3252
-#line 3200
+#line 3252
#else /* not SX */
-#line 3200
+#line 3252
-#line 3200
+#line 3252
char *xp = (char *) *xpp;
-#line 3200
+#line 3252
int status = NC_NOERR;
-#line 3200
+#line 3252
-#line 3200
+#line 3252
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3200
+#line 3252
{
-#line 3200
+#line 3252
int lstatus = ncx_put_ushort_double(xp, tp, fillp);
-#line 3200
+#line 3252
if (status == NC_NOERR) /* report the first encountered error */
-#line 3200
+#line 3252
status = lstatus;
-#line 3200
+#line 3252
}
-#line 3200
+#line 3252
-#line 3200
+#line 3252
*xpp = (void *)xp;
-#line 3200
+#line 3252
return status;
-#line 3200
+#line 3252
#endif
-#line 3200
+#line 3252
}
-#line 3200
+#line 3252
int
-#line 3201
+#line 3253
ncx_putn_ushort_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3201
+#line 3253
{
-#line 3201
+#line 3253
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3201
+#line 3253
-#line 3201
+#line 3253
/* basic algorithm is:
-#line 3201
+#line 3253
* - ensure sane alignment of output data
-#line 3201
+#line 3253
* - copy (conversion happens automatically) input data
-#line 3201
+#line 3253
* to output
-#line 3201
+#line 3253
* - update tp to point at next unconverted input, and xpp to point
-#line 3201
+#line 3253
* at next location for converted output
-#line 3201
+#line 3253
*/
-#line 3201
+#line 3253
long i, j, ni;
-#line 3201
+#line 3253
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3201
+#line 3253
ushort *xp;
-#line 3201
+#line 3253
int nrange = 0; /* number of range errors */
-#line 3201
+#line 3253
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3201
+#line 3253
long cxp = (long) *((char**)xpp);
-#line 3201
+#line 3253
-#line 3201
+#line 3253
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3201
+#line 3253
/* sjl: manually stripmine so we can limit amount of
-#line 3201
+#line 3253
* vector work space reserved to LOOPCNT elements. Also
-#line 3201
+#line 3253
* makes vectorisation easy */
-#line 3201
+#line 3253
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3201
+#line 3253
ni=Min(nelems-j,LOOPCNT);
-#line 3201
+#line 3253
if (realign) {
-#line 3201
+#line 3253
xp = tmp;
-#line 3201
+#line 3253
} else {
-#line 3201
+#line 3253
xp = (ushort *) *xpp;
-#line 3201
+#line 3253
}
-#line 3201
+#line 3253
/* copy the next block */
-#line 3201
+#line 3253
#pragma cdir loopcnt=LOOPCNT
-#line 3201
+#line 3253
#pragma cdir shortloop
-#line 3201
+#line 3253
for (i=0; i<ni; i++) {
-#line 3201
+#line 3253
/* the normal case: */
-#line 3201
+#line 3253
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3201
+#line 3253
/* test for range errors (not always needed but do it anyway) */
-#line 3201
+#line 3253
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3201
+#line 3253
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3201
+#line 3253
nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
-#line 3201
+#line 3253
}
-#line 3201
+#line 3253
/* copy workspace back if necessary */
-#line 3201
+#line 3253
if (realign) {
-#line 3201
+#line 3253
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3201
+#line 3253
xp = (ushort *) *xpp;
-#line 3201
+#line 3253
}
-#line 3201
+#line 3253
/* update xpp and tp */
-#line 3201
+#line 3253
xp += ni;
-#line 3201
+#line 3253
tp += ni;
-#line 3201
+#line 3253
*xpp = (void*)xp;
-#line 3201
+#line 3253
}
-#line 3201
+#line 3253
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3201
+#line 3253
-#line 3201
+#line 3253
#else /* not SX */
-#line 3201
+#line 3253
-#line 3201
+#line 3253
char *xp = (char *) *xpp;
-#line 3201
+#line 3253
int status = NC_NOERR;
-#line 3201
+#line 3253
-#line 3201
+#line 3253
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3201
+#line 3253
{
-#line 3201
+#line 3253
int lstatus = ncx_put_ushort_longlong(xp, tp, fillp);
-#line 3201
+#line 3253
if (status == NC_NOERR) /* report the first encountered error */
-#line 3201
+#line 3253
status = lstatus;
-#line 3201
+#line 3253
}
-#line 3201
+#line 3253
-#line 3201
+#line 3253
*xpp = (void *)xp;
-#line 3201
+#line 3253
return status;
-#line 3201
+#line 3253
#endif
-#line 3201
+#line 3253
}
-#line 3201
+#line 3253
int
-#line 3202
+#line 3254
ncx_putn_ushort_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3202
+#line 3254
{
-#line 3202
+#line 3254
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3202
+#line 3254
-#line 3202
+#line 3254
/* basic algorithm is:
-#line 3202
+#line 3254
* - ensure sane alignment of output data
-#line 3202
+#line 3254
* - copy (conversion happens automatically) input data
-#line 3202
+#line 3254
* to output
-#line 3202
+#line 3254
* - update tp to point at next unconverted input, and xpp to point
-#line 3202
+#line 3254
* at next location for converted output
-#line 3202
+#line 3254
*/
-#line 3202
+#line 3254
long i, j, ni;
-#line 3202
+#line 3254
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3202
+#line 3254
ushort *xp;
-#line 3202
+#line 3254
int nrange = 0; /* number of range errors */
-#line 3202
+#line 3254
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3202
+#line 3254
long cxp = (long) *((char**)xpp);
-#line 3202
+#line 3254
-#line 3202
+#line 3254
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3202
+#line 3254
/* sjl: manually stripmine so we can limit amount of
-#line 3202
+#line 3254
* vector work space reserved to LOOPCNT elements. Also
-#line 3202
+#line 3254
* makes vectorisation easy */
-#line 3202
+#line 3254
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3202
+#line 3254
ni=Min(nelems-j,LOOPCNT);
-#line 3202
+#line 3254
if (realign) {
-#line 3202
+#line 3254
xp = tmp;
-#line 3202
+#line 3254
} else {
-#line 3202
+#line 3254
xp = (ushort *) *xpp;
-#line 3202
+#line 3254
}
-#line 3202
+#line 3254
/* copy the next block */
-#line 3202
+#line 3254
#pragma cdir loopcnt=LOOPCNT
-#line 3202
+#line 3254
#pragma cdir shortloop
-#line 3202
+#line 3254
for (i=0; i<ni; i++) {
-#line 3202
+#line 3254
/* the normal case: */
-#line 3202
+#line 3254
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3202
+#line 3254
/* test for range errors (not always needed but do it anyway) */
-#line 3202
+#line 3254
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3202
+#line 3254
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3202
+#line 3254
nrange += tp[i] > X_USHORT_MAX ;
-#line 3202
+#line 3254
}
-#line 3202
+#line 3254
/* copy workspace back if necessary */
-#line 3202
+#line 3254
if (realign) {
-#line 3202
+#line 3254
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3202
+#line 3254
xp = (ushort *) *xpp;
-#line 3202
+#line 3254
}
-#line 3202
+#line 3254
/* update xpp and tp */
-#line 3202
+#line 3254
xp += ni;
-#line 3202
+#line 3254
tp += ni;
-#line 3202
+#line 3254
*xpp = (void*)xp;
-#line 3202
+#line 3254
}
-#line 3202
+#line 3254
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3202
+#line 3254
-#line 3202
+#line 3254
#else /* not SX */
-#line 3202
+#line 3254
-#line 3202
+#line 3254
char *xp = (char *) *xpp;
-#line 3202
+#line 3254
int status = NC_NOERR;
-#line 3202
+#line 3254
-#line 3202
+#line 3254
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3202
+#line 3254
{
-#line 3202
+#line 3254
int lstatus = ncx_put_ushort_uchar(xp, tp, fillp);
-#line 3202
+#line 3254
if (status == NC_NOERR) /* report the first encountered error */
-#line 3202
+#line 3254
status = lstatus;
-#line 3202
+#line 3254
}
-#line 3202
+#line 3254
-#line 3202
+#line 3254
*xpp = (void *)xp;
-#line 3202
+#line 3254
return status;
-#line 3202
+#line 3254
#endif
-#line 3202
+#line 3254
}
-#line 3202
+#line 3254
int
-#line 3203
+#line 3255
ncx_putn_ushort_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3203
+#line 3255
{
-#line 3203
+#line 3255
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3203
+#line 3255
-#line 3203
+#line 3255
/* basic algorithm is:
-#line 3203
+#line 3255
* - ensure sane alignment of output data
-#line 3203
+#line 3255
* - copy (conversion happens automatically) input data
-#line 3203
+#line 3255
* to output
-#line 3203
+#line 3255
* - update tp to point at next unconverted input, and xpp to point
-#line 3203
+#line 3255
* at next location for converted output
-#line 3203
+#line 3255
*/
-#line 3203
+#line 3255
long i, j, ni;
-#line 3203
+#line 3255
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3203
+#line 3255
ushort *xp;
-#line 3203
+#line 3255
int nrange = 0; /* number of range errors */
-#line 3203
+#line 3255
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3203
+#line 3255
long cxp = (long) *((char**)xpp);
-#line 3203
+#line 3255
-#line 3203
+#line 3255
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3203
+#line 3255
/* sjl: manually stripmine so we can limit amount of
-#line 3203
+#line 3255
* vector work space reserved to LOOPCNT elements. Also
-#line 3203
+#line 3255
* makes vectorisation easy */
-#line 3203
+#line 3255
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3203
+#line 3255
ni=Min(nelems-j,LOOPCNT);
-#line 3203
+#line 3255
if (realign) {
-#line 3203
+#line 3255
xp = tmp;
-#line 3203
+#line 3255
} else {
-#line 3203
+#line 3255
xp = (ushort *) *xpp;
-#line 3203
+#line 3255
}
-#line 3203
+#line 3255
/* copy the next block */
-#line 3203
+#line 3255
#pragma cdir loopcnt=LOOPCNT
-#line 3203
+#line 3255
#pragma cdir shortloop
-#line 3203
+#line 3255
for (i=0; i<ni; i++) {
-#line 3203
+#line 3255
/* the normal case: */
-#line 3203
+#line 3255
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3203
+#line 3255
/* test for range errors (not always needed but do it anyway) */
-#line 3203
+#line 3255
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3203
+#line 3255
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3203
+#line 3255
nrange += tp[i] > X_USHORT_MAX ;
-#line 3203
+#line 3255
}
-#line 3203
+#line 3255
/* copy workspace back if necessary */
-#line 3203
+#line 3255
if (realign) {
-#line 3203
+#line 3255
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3203
+#line 3255
xp = (ushort *) *xpp;
-#line 3203
+#line 3255
}
-#line 3203
+#line 3255
/* update xpp and tp */
-#line 3203
+#line 3255
xp += ni;
-#line 3203
+#line 3255
tp += ni;
-#line 3203
+#line 3255
*xpp = (void*)xp;
-#line 3203
+#line 3255
}
-#line 3203
+#line 3255
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3203
+#line 3255
-#line 3203
+#line 3255
#else /* not SX */
-#line 3203
+#line 3255
-#line 3203
+#line 3255
char *xp = (char *) *xpp;
-#line 3203
+#line 3255
int status = NC_NOERR;
-#line 3203
+#line 3255
-#line 3203
+#line 3255
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3203
+#line 3255
{
-#line 3203
+#line 3255
int lstatus = ncx_put_ushort_uint(xp, tp, fillp);
-#line 3203
+#line 3255
if (status == NC_NOERR) /* report the first encountered error */
-#line 3203
+#line 3255
status = lstatus;
-#line 3203
+#line 3255
}
-#line 3203
+#line 3255
-#line 3203
+#line 3255
*xpp = (void *)xp;
-#line 3203
+#line 3255
return status;
-#line 3203
+#line 3255
#endif
-#line 3203
+#line 3255
}
-#line 3203
+#line 3255
int
-#line 3204
+#line 3256
ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3204
+#line 3256
{
-#line 3204
+#line 3256
#if defined(_SX) && _SX != 0 && X_SIZEOF_USHORT == SIZEOF_USHORT
-#line 3204
+#line 3256
-#line 3204
+#line 3256
/* basic algorithm is:
-#line 3204
+#line 3256
* - ensure sane alignment of output data
-#line 3204
+#line 3256
* - copy (conversion happens automatically) input data
-#line 3204
+#line 3256
* to output
-#line 3204
+#line 3256
* - update tp to point at next unconverted input, and xpp to point
-#line 3204
+#line 3256
* at next location for converted output
-#line 3204
+#line 3256
*/
-#line 3204
+#line 3256
long i, j, ni;
-#line 3204
+#line 3256
ushort tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3204
+#line 3256
ushort *xp;
-#line 3204
+#line 3256
int nrange = 0; /* number of range errors */
-#line 3204
+#line 3256
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3204
+#line 3256
long cxp = (long) *((char**)xpp);
-#line 3204
+#line 3256
-#line 3204
+#line 3256
realign = (cxp & 7) % SIZEOF_USHORT;
-#line 3204
+#line 3256
/* sjl: manually stripmine so we can limit amount of
-#line 3204
+#line 3256
* vector work space reserved to LOOPCNT elements. Also
-#line 3204
+#line 3256
* makes vectorisation easy */
-#line 3204
+#line 3256
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3204
+#line 3256
ni=Min(nelems-j,LOOPCNT);
-#line 3204
+#line 3256
if (realign) {
-#line 3204
+#line 3256
xp = tmp;
-#line 3204
+#line 3256
} else {
-#line 3204
+#line 3256
xp = (ushort *) *xpp;
-#line 3204
+#line 3256
}
-#line 3204
+#line 3256
/* copy the next block */
-#line 3204
+#line 3256
#pragma cdir loopcnt=LOOPCNT
-#line 3204
+#line 3256
#pragma cdir shortloop
-#line 3204
+#line 3256
for (i=0; i<ni; i++) {
-#line 3204
+#line 3256
/* the normal case: */
-#line 3204
+#line 3256
xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
-#line 3204
+#line 3256
/* test for range errors (not always needed but do it anyway) */
-#line 3204
+#line 3256
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3204
+#line 3256
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3204
+#line 3256
nrange += tp[i] > X_USHORT_MAX ;
-#line 3204
+#line 3256
}
-#line 3204
+#line 3256
/* copy workspace back if necessary */
-#line 3204
+#line 3256
if (realign) {
-#line 3204
+#line 3256
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_USHORT);
-#line 3204
+#line 3256
xp = (ushort *) *xpp;
-#line 3204
+#line 3256
}
-#line 3204
+#line 3256
/* update xpp and tp */
-#line 3204
+#line 3256
xp += ni;
-#line 3204
+#line 3256
tp += ni;
-#line 3204
+#line 3256
*xpp = (void*)xp;
-#line 3204
+#line 3256
}
-#line 3204
+#line 3256
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3204
+#line 3256
-#line 3204
+#line 3256
#else /* not SX */
-#line 3204
+#line 3256
-#line 3204
+#line 3256
char *xp = (char *) *xpp;
-#line 3204
+#line 3256
int status = NC_NOERR;
-#line 3204
+#line 3256
-#line 3204
+#line 3256
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3204
+#line 3256
{
-#line 3204
+#line 3256
int lstatus = ncx_put_ushort_ulonglong(xp, tp, fillp);
-#line 3204
+#line 3256
if (status == NC_NOERR) /* report the first encountered error */
-#line 3204
+#line 3256
status = lstatus;
-#line 3204
+#line 3256
}
-#line 3204
+#line 3256
-#line 3204
+#line 3256
*xpp = (void *)xp;
-#line 3204
+#line 3256
return status;
-#line 3204
+#line 3256
#endif
-#line 3204
+#line 3256
}
-#line 3204
+#line 3256
int
-#line 3206
+#line 3258
ncx_pad_putn_ushort_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3206
+#line 3258
{
-#line 3206
+#line 3258
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3206
+#line 3258
-#line 3206
+#line 3258
char *xp = (char *) *xpp;
-#line 3206
+#line 3258
int status = NC_NOERR;
-#line 3206
+#line 3258
-#line 3206
+#line 3258
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3206
+#line 3258
{
-#line 3206
+#line 3258
int lstatus = ncx_put_ushort_schar(xp, tp, fillp);
-#line 3206
+#line 3258
if (status == NC_NOERR) /* report the first encountered error */
-#line 3206
+#line 3258
status = lstatus;
-#line 3206
+#line 3258
}
-#line 3206
+#line 3258
-#line 3206
+#line 3258
if (rndup != 0)
-#line 3206
+#line 3258
{
-#line 3206
+#line 3258
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3206
+#line 3258
xp += X_SIZEOF_USHORT;
-#line 3206
+#line 3258
}
-#line 3206
+#line 3258
-#line 3206
+#line 3258
*xpp = (void *)xp;
-#line 3206
+#line 3258
return status;
-#line 3206
+#line 3258
}
-#line 3206
+#line 3258
int
-#line 3207
+#line 3259
ncx_pad_putn_ushort_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3207
+#line 3259
{
-#line 3207
+#line 3259
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3207
+#line 3259
-#line 3207
+#line 3259
char *xp = (char *) *xpp;
-#line 3207
+#line 3259
int status = NC_NOERR;
-#line 3207
+#line 3259
-#line 3207
+#line 3259
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3207
+#line 3259
{
-#line 3207
+#line 3259
int lstatus = ncx_put_ushort_uchar(xp, tp, fillp);
-#line 3207
+#line 3259
if (status == NC_NOERR) /* report the first encountered error */
-#line 3207
+#line 3259
status = lstatus;
-#line 3207
+#line 3259
}
-#line 3207
+#line 3259
-#line 3207
+#line 3259
if (rndup != 0)
-#line 3207
+#line 3259
{
-#line 3207
+#line 3259
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3207
+#line 3259
xp += X_SIZEOF_USHORT;
-#line 3207
+#line 3259
}
-#line 3207
+#line 3259
-#line 3207
+#line 3259
*xpp = (void *)xp;
-#line 3207
+#line 3259
return status;
-#line 3207
+#line 3259
}
-#line 3207
+#line 3259
int
-#line 3208
+#line 3260
ncx_pad_putn_ushort_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3208
+#line 3260
{
-#line 3208
+#line 3260
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3208
+#line 3260
-#line 3208
+#line 3260
char *xp = (char *) *xpp;
-#line 3208
+#line 3260
int status = NC_NOERR;
-#line 3208
+#line 3260
-#line 3208
+#line 3260
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3208
+#line 3260
{
-#line 3208
+#line 3260
int lstatus = ncx_put_ushort_short(xp, tp, fillp);
-#line 3208
+#line 3260
if (status == NC_NOERR) /* report the first encountered error */
-#line 3208
+#line 3260
status = lstatus;
-#line 3208
+#line 3260
}
-#line 3208
+#line 3260
-#line 3208
+#line 3260
if (rndup != 0)
-#line 3208
+#line 3260
{
-#line 3208
+#line 3260
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3208
+#line 3260
xp += X_SIZEOF_USHORT;
-#line 3208
+#line 3260
}
-#line 3208
+#line 3260
-#line 3208
+#line 3260
*xpp = (void *)xp;
-#line 3208
+#line 3260
return status;
-#line 3208
+#line 3260
}
-#line 3208
+#line 3260
int
-#line 3209
+#line 3261
ncx_pad_putn_ushort_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3209
+#line 3261
{
-#line 3209
+#line 3261
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3209
+#line 3261
-#line 3209
+#line 3261
char *xp = (char *) *xpp;
-#line 3209
+#line 3261
int status = NC_NOERR;
-#line 3209
+#line 3261
-#line 3209
+#line 3261
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3209
+#line 3261
{
-#line 3209
+#line 3261
int lstatus = ncx_put_ushort_int(xp, tp, fillp);
-#line 3209
+#line 3261
if (status == NC_NOERR) /* report the first encountered error */
-#line 3209
+#line 3261
status = lstatus;
-#line 3209
+#line 3261
}
-#line 3209
+#line 3261
-#line 3209
+#line 3261
if (rndup != 0)
-#line 3209
+#line 3261
{
-#line 3209
+#line 3261
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3209
+#line 3261
xp += X_SIZEOF_USHORT;
-#line 3209
+#line 3261
}
-#line 3209
+#line 3261
-#line 3209
+#line 3261
*xpp = (void *)xp;
-#line 3209
+#line 3261
return status;
-#line 3209
+#line 3261
}
-#line 3209
+#line 3261
int
-#line 3210
+#line 3262
ncx_pad_putn_ushort_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3210
+#line 3262
{
-#line 3210
+#line 3262
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3210
+#line 3262
-#line 3210
+#line 3262
char *xp = (char *) *xpp;
-#line 3210
+#line 3262
int status = NC_NOERR;
-#line 3210
+#line 3262
-#line 3210
+#line 3262
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3210
+#line 3262
{
-#line 3210
+#line 3262
int lstatus = ncx_put_ushort_long(xp, tp, fillp);
-#line 3210
+#line 3262
if (status == NC_NOERR) /* report the first encountered error */
-#line 3210
+#line 3262
status = lstatus;
-#line 3210
+#line 3262
}
-#line 3210
+#line 3262
-#line 3210
+#line 3262
if (rndup != 0)
-#line 3210
+#line 3262
{
-#line 3210
+#line 3262
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3210
+#line 3262
xp += X_SIZEOF_USHORT;
-#line 3210
+#line 3262
}
-#line 3210
+#line 3262
-#line 3210
+#line 3262
*xpp = (void *)xp;
-#line 3210
+#line 3262
return status;
-#line 3210
+#line 3262
}
-#line 3210
+#line 3262
int
-#line 3211
+#line 3263
ncx_pad_putn_ushort_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3211
+#line 3263
{
-#line 3211
+#line 3263
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3211
+#line 3263
-#line 3211
+#line 3263
char *xp = (char *) *xpp;
-#line 3211
+#line 3263
int status = NC_NOERR;
-#line 3211
+#line 3263
-#line 3211
+#line 3263
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3211
+#line 3263
{
-#line 3211
+#line 3263
int lstatus = ncx_put_ushort_float(xp, tp, fillp);
-#line 3211
+#line 3263
if (status == NC_NOERR) /* report the first encountered error */
-#line 3211
+#line 3263
status = lstatus;
-#line 3211
+#line 3263
}
-#line 3211
+#line 3263
-#line 3211
+#line 3263
if (rndup != 0)
-#line 3211
+#line 3263
{
-#line 3211
+#line 3263
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3211
+#line 3263
xp += X_SIZEOF_USHORT;
-#line 3211
+#line 3263
}
-#line 3211
+#line 3263
-#line 3211
+#line 3263
*xpp = (void *)xp;
-#line 3211
+#line 3263
return status;
-#line 3211
+#line 3263
}
-#line 3211
+#line 3263
int
-#line 3212
+#line 3264
ncx_pad_putn_ushort_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3212
+#line 3264
{
-#line 3212
+#line 3264
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3212
+#line 3264
-#line 3212
+#line 3264
char *xp = (char *) *xpp;
-#line 3212
+#line 3264
int status = NC_NOERR;
-#line 3212
+#line 3264
-#line 3212
+#line 3264
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3212
+#line 3264
{
-#line 3212
+#line 3264
int lstatus = ncx_put_ushort_double(xp, tp, fillp);
-#line 3212
+#line 3264
if (status == NC_NOERR) /* report the first encountered error */
-#line 3212
+#line 3264
status = lstatus;
-#line 3212
+#line 3264
}
-#line 3212
+#line 3264
-#line 3212
+#line 3264
if (rndup != 0)
-#line 3212
+#line 3264
{
-#line 3212
+#line 3264
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3212
+#line 3264
xp += X_SIZEOF_USHORT;
-#line 3212
+#line 3264
}
-#line 3212
+#line 3264
-#line 3212
+#line 3264
*xpp = (void *)xp;
-#line 3212
+#line 3264
return status;
-#line 3212
+#line 3264
}
-#line 3212
+#line 3264
int
-#line 3213
+#line 3265
ncx_pad_putn_ushort_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3213
+#line 3265
{
-#line 3213
+#line 3265
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3213
+#line 3265
-#line 3213
+#line 3265
char *xp = (char *) *xpp;
-#line 3213
+#line 3265
int status = NC_NOERR;
-#line 3213
+#line 3265
-#line 3213
+#line 3265
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3213
+#line 3265
{
-#line 3213
+#line 3265
int lstatus = ncx_put_ushort_uint(xp, tp, fillp);
-#line 3213
+#line 3265
if (status == NC_NOERR) /* report the first encountered error */
-#line 3213
+#line 3265
status = lstatus;
-#line 3213
+#line 3265
}
-#line 3213
+#line 3265
-#line 3213
+#line 3265
if (rndup != 0)
-#line 3213
+#line 3265
{
-#line 3213
+#line 3265
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3213
+#line 3265
xp += X_SIZEOF_USHORT;
-#line 3213
+#line 3265
}
-#line 3213
+#line 3265
-#line 3213
+#line 3265
*xpp = (void *)xp;
-#line 3213
+#line 3265
return status;
-#line 3213
+#line 3265
}
-#line 3213
+#line 3265
int
-#line 3214
+#line 3266
ncx_pad_putn_ushort_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3214
+#line 3266
{
-#line 3214
+#line 3266
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3214
+#line 3266
-#line 3214
+#line 3266
char *xp = (char *) *xpp;
-#line 3214
+#line 3266
int status = NC_NOERR;
-#line 3214
+#line 3266
-#line 3214
+#line 3266
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3214
+#line 3266
{
-#line 3214
+#line 3266
int lstatus = ncx_put_ushort_longlong(xp, tp, fillp);
-#line 3214
+#line 3266
if (status == NC_NOERR) /* report the first encountered error */
-#line 3214
+#line 3266
status = lstatus;
-#line 3214
+#line 3266
}
-#line 3214
+#line 3266
-#line 3214
+#line 3266
if (rndup != 0)
-#line 3214
+#line 3266
{
-#line 3214
+#line 3266
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3214
+#line 3266
xp += X_SIZEOF_USHORT;
-#line 3214
+#line 3266
}
-#line 3214
+#line 3266
-#line 3214
+#line 3266
*xpp = (void *)xp;
-#line 3214
+#line 3266
return status;
-#line 3214
+#line 3266
}
-#line 3214
+#line 3266
int
-#line 3215
+#line 3267
ncx_pad_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3215
+#line 3267
{
-#line 3215
+#line 3267
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3215
+#line 3267
-#line 3215
+#line 3267
char *xp = (char *) *xpp;
-#line 3215
+#line 3267
int status = NC_NOERR;
-#line 3215
+#line 3267
-#line 3215
+#line 3267
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3215
+#line 3267
{
-#line 3215
+#line 3267
int lstatus = ncx_put_ushort_ulonglong(xp, tp, fillp);
-#line 3215
+#line 3267
if (status == NC_NOERR) /* report the first encountered error */
-#line 3215
+#line 3267
status = lstatus;
-#line 3215
+#line 3267
}
-#line 3215
+#line 3267
-#line 3215
+#line 3267
if (rndup != 0)
-#line 3215
+#line 3267
{
-#line 3215
+#line 3267
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3215
+#line 3267
xp += X_SIZEOF_USHORT;
-#line 3215
+#line 3267
}
-#line 3215
+#line 3267
-#line 3215
+#line 3267
*xpp = (void *)xp;
-#line 3215
+#line 3267
return status;
-#line 3215
+#line 3267
}
-#line 3215
+#line 3267
int
-#line 3216
+#line 3268
ncx_pad_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3216
+#line 3268
{
-#line 3216
+#line 3268
const size_t rndup = nelems % X_SIZEOF_SHORT;
-#line 3216
+#line 3268
-#line 3216
+#line 3268
char *xp = (char *) *xpp;
-#line 3216
+#line 3268
int status = NC_NOERR;
-#line 3216
+#line 3268
-#line 3216
+#line 3268
for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
-#line 3216
+#line 3268
{
-#line 3216
+#line 3268
int lstatus = ncx_put_ushort_ushort(xp, tp, fillp);
-#line 3216
+#line 3268
if (status == NC_NOERR) /* report the first encountered error */
-#line 3216
+#line 3268
status = lstatus;
-#line 3216
+#line 3268
}
-#line 3216
+#line 3268
-#line 3216
+#line 3268
if (rndup != 0)
-#line 3216
+#line 3268
{
-#line 3216
+#line 3268
(void) memcpy(xp, nada, (size_t)(X_SIZEOF_USHORT));
-#line 3216
+#line 3268
xp += X_SIZEOF_USHORT;
-#line 3216
+#line 3268
}
-#line 3216
+#line 3268
-#line 3216
+#line 3268
*xpp = (void *)xp;
-#line 3216
+#line 3268
return status;
-#line 3216
+#line 3268
}
-#line 3216
+#line 3268
@@ -19420,1424 +21505,1424 @@ ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
}
#else
int
-#line 3235
+#line 3287
ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
-#line 3235
+#line 3287
{
-#line 3235
+#line 3287
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3235
+#line 3287
-#line 3235
+#line 3287
/* basic algorithm is:
-#line 3235
+#line 3287
* - ensure sane alignment of input data
-#line 3235
+#line 3287
* - copy (conversion happens automatically) input data
-#line 3235
+#line 3287
* to output
-#line 3235
+#line 3287
* - update xpp to point at next unconverted input, and tp to point
-#line 3235
+#line 3287
* at next location for converted output
-#line 3235
+#line 3287
*/
-#line 3235
+#line 3287
long i, j, ni;
-#line 3235
+#line 3287
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3235
+#line 3287
int *xp;
-#line 3235
+#line 3287
int nrange = 0; /* number of range errors */
-#line 3235
+#line 3287
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3235
+#line 3287
long cxp = (long) *((char**)xpp);
-#line 3235
+#line 3287
-#line 3235
+#line 3287
realign = (cxp & 7) % SIZEOF_INT;
-#line 3235
+#line 3287
/* sjl: manually stripmine so we can limit amount of
-#line 3235
+#line 3287
* vector work space reserved to LOOPCNT elements. Also
-#line 3235
+#line 3287
* makes vectorisation easy */
-#line 3235
+#line 3287
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3235
+#line 3287
ni=Min(nelems-j,LOOPCNT);
-#line 3235
+#line 3287
if (realign) {
-#line 3235
+#line 3287
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3235
+#line 3287
xp = tmp;
-#line 3235
+#line 3287
} else {
-#line 3235
+#line 3287
xp = (int *) *xpp;
-#line 3235
+#line 3287
}
-#line 3235
+#line 3287
/* copy the next block */
-#line 3235
+#line 3287
#pragma cdir loopcnt=LOOPCNT
-#line 3235
+#line 3287
#pragma cdir shortloop
-#line 3235
+#line 3287
for (i=0; i<ni; i++) {
-#line 3235
+#line 3287
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3235
+#line 3287
/* test for range errors (not always needed but do it anyway) */
-#line 3235
+#line 3287
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3235
+#line 3287
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3235
+#line 3287
nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
-#line 3235
+#line 3287
}
-#line 3235
+#line 3287
/* update xpp and tp */
-#line 3235
+#line 3287
if (realign) xp = (int *) *xpp;
-#line 3235
+#line 3287
xp += ni;
-#line 3235
+#line 3287
tp += ni;
-#line 3235
+#line 3287
*xpp = (void*)xp;
-#line 3235
+#line 3287
}
-#line 3235
+#line 3287
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3235
+#line 3287
-#line 3235
+#line 3287
#else /* not SX */
-#line 3235
+#line 3287
const char *xp = (const char *) *xpp;
-#line 3235
+#line 3287
int status = NC_NOERR;
-#line 3235
+#line 3287
-#line 3235
+#line 3287
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3235
+#line 3287
{
-#line 3235
+#line 3287
const int lstatus = ncx_get_int_int(xp, tp);
-#line 3235
+#line 3287
if (status == NC_NOERR) /* report the first encountered error */
-#line 3235
+#line 3287
status = lstatus;
-#line 3235
+#line 3287
}
-#line 3235
+#line 3287
-#line 3235
+#line 3287
*xpp = (const void *)xp;
-#line 3235
+#line 3287
return status;
-#line 3235
+#line 3287
#endif
-#line 3235
+#line 3287
}
-#line 3235
+#line 3287
#endif
int
-#line 3237
+#line 3289
ncx_getn_int_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3237
+#line 3289
{
-#line 3237
+#line 3289
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3237
+#line 3289
-#line 3237
+#line 3289
/* basic algorithm is:
-#line 3237
+#line 3289
* - ensure sane alignment of input data
-#line 3237
+#line 3289
* - copy (conversion happens automatically) input data
-#line 3237
+#line 3289
* to output
-#line 3237
+#line 3289
* - update xpp to point at next unconverted input, and tp to point
-#line 3237
+#line 3289
* at next location for converted output
-#line 3237
+#line 3289
*/
-#line 3237
+#line 3289
long i, j, ni;
-#line 3237
+#line 3289
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3237
+#line 3289
int *xp;
-#line 3237
+#line 3289
int nrange = 0; /* number of range errors */
-#line 3237
+#line 3289
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3237
+#line 3289
long cxp = (long) *((char**)xpp);
-#line 3237
+#line 3289
-#line 3237
+#line 3289
realign = (cxp & 7) % SIZEOF_INT;
-#line 3237
+#line 3289
/* sjl: manually stripmine so we can limit amount of
-#line 3237
+#line 3289
* vector work space reserved to LOOPCNT elements. Also
-#line 3237
+#line 3289
* makes vectorisation easy */
-#line 3237
+#line 3289
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3237
+#line 3289
ni=Min(nelems-j,LOOPCNT);
-#line 3237
+#line 3289
if (realign) {
-#line 3237
+#line 3289
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3237
+#line 3289
xp = tmp;
-#line 3237
+#line 3289
} else {
-#line 3237
+#line 3289
xp = (int *) *xpp;
-#line 3237
+#line 3289
}
-#line 3237
+#line 3289
/* copy the next block */
-#line 3237
+#line 3289
#pragma cdir loopcnt=LOOPCNT
-#line 3237
+#line 3289
#pragma cdir shortloop
-#line 3237
+#line 3289
for (i=0; i<ni; i++) {
-#line 3237
+#line 3289
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3237
+#line 3289
/* test for range errors (not always needed but do it anyway) */
-#line 3237
+#line 3289
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3237
+#line 3289
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3237
+#line 3289
nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
-#line 3237
+#line 3289
}
-#line 3237
+#line 3289
/* update xpp and tp */
-#line 3237
+#line 3289
if (realign) xp = (int *) *xpp;
-#line 3237
+#line 3289
xp += ni;
-#line 3237
+#line 3289
tp += ni;
-#line 3237
+#line 3289
*xpp = (void*)xp;
-#line 3237
+#line 3289
}
-#line 3237
+#line 3289
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3237
+#line 3289
-#line 3237
+#line 3289
#else /* not SX */
-#line 3237
+#line 3289
const char *xp = (const char *) *xpp;
-#line 3237
+#line 3289
int status = NC_NOERR;
-#line 3237
+#line 3289
-#line 3237
+#line 3289
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3237
+#line 3289
{
-#line 3237
+#line 3289
const int lstatus = ncx_get_int_schar(xp, tp);
-#line 3237
+#line 3289
if (status == NC_NOERR) /* report the first encountered error */
-#line 3237
+#line 3289
status = lstatus;
-#line 3237
+#line 3289
}
-#line 3237
+#line 3289
-#line 3237
+#line 3289
*xpp = (const void *)xp;
-#line 3237
+#line 3289
return status;
-#line 3237
+#line 3289
#endif
-#line 3237
+#line 3289
}
-#line 3237
+#line 3289
int
-#line 3238
+#line 3290
ncx_getn_int_short(const void **xpp, size_t nelems, short *tp)
-#line 3238
+#line 3290
{
-#line 3238
+#line 3290
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3238
+#line 3290
-#line 3238
+#line 3290
/* basic algorithm is:
-#line 3238
+#line 3290
* - ensure sane alignment of input data
-#line 3238
+#line 3290
* - copy (conversion happens automatically) input data
-#line 3238
+#line 3290
* to output
-#line 3238
+#line 3290
* - update xpp to point at next unconverted input, and tp to point
-#line 3238
+#line 3290
* at next location for converted output
-#line 3238
+#line 3290
*/
-#line 3238
+#line 3290
long i, j, ni;
-#line 3238
+#line 3290
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3238
+#line 3290
int *xp;
-#line 3238
+#line 3290
int nrange = 0; /* number of range errors */
-#line 3238
+#line 3290
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3238
+#line 3290
long cxp = (long) *((char**)xpp);
-#line 3238
+#line 3290
-#line 3238
+#line 3290
realign = (cxp & 7) % SIZEOF_INT;
-#line 3238
+#line 3290
/* sjl: manually stripmine so we can limit amount of
-#line 3238
+#line 3290
* vector work space reserved to LOOPCNT elements. Also
-#line 3238
+#line 3290
* makes vectorisation easy */
-#line 3238
+#line 3290
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3238
+#line 3290
ni=Min(nelems-j,LOOPCNT);
-#line 3238
+#line 3290
if (realign) {
-#line 3238
+#line 3290
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3238
+#line 3290
xp = tmp;
-#line 3238
+#line 3290
} else {
-#line 3238
+#line 3290
xp = (int *) *xpp;
-#line 3238
+#line 3290
}
-#line 3238
+#line 3290
/* copy the next block */
-#line 3238
+#line 3290
#pragma cdir loopcnt=LOOPCNT
-#line 3238
+#line 3290
#pragma cdir shortloop
-#line 3238
+#line 3290
for (i=0; i<ni; i++) {
-#line 3238
+#line 3290
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3238
+#line 3290
/* test for range errors (not always needed but do it anyway) */
-#line 3238
+#line 3290
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3238
+#line 3290
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3238
+#line 3290
nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
-#line 3238
+#line 3290
}
-#line 3238
+#line 3290
/* update xpp and tp */
-#line 3238
+#line 3290
if (realign) xp = (int *) *xpp;
-#line 3238
+#line 3290
xp += ni;
-#line 3238
+#line 3290
tp += ni;
-#line 3238
+#line 3290
*xpp = (void*)xp;
-#line 3238
+#line 3290
}
-#line 3238
+#line 3290
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3238
+#line 3290
-#line 3238
+#line 3290
#else /* not SX */
-#line 3238
+#line 3290
const char *xp = (const char *) *xpp;
-#line 3238
+#line 3290
int status = NC_NOERR;
-#line 3238
+#line 3290
-#line 3238
+#line 3290
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3238
+#line 3290
{
-#line 3238
+#line 3290
const int lstatus = ncx_get_int_short(xp, tp);
-#line 3238
+#line 3290
if (status == NC_NOERR) /* report the first encountered error */
-#line 3238
+#line 3290
status = lstatus;
-#line 3238
+#line 3290
}
-#line 3238
+#line 3290
-#line 3238
+#line 3290
*xpp = (const void *)xp;
-#line 3238
+#line 3290
return status;
-#line 3238
+#line 3290
#endif
-#line 3238
+#line 3290
}
-#line 3238
+#line 3290
int
-#line 3239
+#line 3291
ncx_getn_int_long(const void **xpp, size_t nelems, long *tp)
-#line 3239
+#line 3291
{
-#line 3239
+#line 3291
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3239
+#line 3291
-#line 3239
+#line 3291
/* basic algorithm is:
-#line 3239
+#line 3291
* - ensure sane alignment of input data
-#line 3239
+#line 3291
* - copy (conversion happens automatically) input data
-#line 3239
+#line 3291
* to output
-#line 3239
+#line 3291
* - update xpp to point at next unconverted input, and tp to point
-#line 3239
+#line 3291
* at next location for converted output
-#line 3239
+#line 3291
*/
-#line 3239
+#line 3291
long i, j, ni;
-#line 3239
+#line 3291
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3239
+#line 3291
int *xp;
-#line 3239
+#line 3291
int nrange = 0; /* number of range errors */
-#line 3239
+#line 3291
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3239
+#line 3291
long cxp = (long) *((char**)xpp);
-#line 3239
+#line 3291
-#line 3239
+#line 3291
realign = (cxp & 7) % SIZEOF_INT;
-#line 3239
+#line 3291
/* sjl: manually stripmine so we can limit amount of
-#line 3239
+#line 3291
* vector work space reserved to LOOPCNT elements. Also
-#line 3239
+#line 3291
* makes vectorisation easy */
-#line 3239
+#line 3291
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3239
+#line 3291
ni=Min(nelems-j,LOOPCNT);
-#line 3239
+#line 3291
if (realign) {
-#line 3239
+#line 3291
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3239
+#line 3291
xp = tmp;
-#line 3239
+#line 3291
} else {
-#line 3239
+#line 3291
xp = (int *) *xpp;
-#line 3239
+#line 3291
}
-#line 3239
+#line 3291
/* copy the next block */
-#line 3239
+#line 3291
#pragma cdir loopcnt=LOOPCNT
-#line 3239
+#line 3291
#pragma cdir shortloop
-#line 3239
+#line 3291
for (i=0; i<ni; i++) {
-#line 3239
+#line 3291
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3239
+#line 3291
/* test for range errors (not always needed but do it anyway) */
-#line 3239
+#line 3291
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3239
+#line 3291
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3239
+#line 3291
nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
-#line 3239
+#line 3291
}
-#line 3239
+#line 3291
/* update xpp and tp */
-#line 3239
+#line 3291
if (realign) xp = (int *) *xpp;
-#line 3239
+#line 3291
xp += ni;
-#line 3239
+#line 3291
tp += ni;
-#line 3239
+#line 3291
*xpp = (void*)xp;
-#line 3239
+#line 3291
}
-#line 3239
+#line 3291
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3239
+#line 3291
-#line 3239
+#line 3291
#else /* not SX */
-#line 3239
+#line 3291
const char *xp = (const char *) *xpp;
-#line 3239
+#line 3291
int status = NC_NOERR;
-#line 3239
+#line 3291
-#line 3239
+#line 3291
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3239
+#line 3291
{
-#line 3239
+#line 3291
const int lstatus = ncx_get_int_long(xp, tp);
-#line 3239
+#line 3291
if (status == NC_NOERR) /* report the first encountered error */
-#line 3239
+#line 3291
status = lstatus;
-#line 3239
+#line 3291
}
-#line 3239
+#line 3291
-#line 3239
+#line 3291
*xpp = (const void *)xp;
-#line 3239
+#line 3291
return status;
-#line 3239
+#line 3291
#endif
-#line 3239
+#line 3291
}
-#line 3239
+#line 3291
int
-#line 3240
+#line 3292
ncx_getn_int_float(const void **xpp, size_t nelems, float *tp)
-#line 3240
+#line 3292
{
-#line 3240
+#line 3292
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3240
+#line 3292
-#line 3240
+#line 3292
/* basic algorithm is:
-#line 3240
+#line 3292
* - ensure sane alignment of input data
-#line 3240
+#line 3292
* - copy (conversion happens automatically) input data
-#line 3240
+#line 3292
* to output
-#line 3240
+#line 3292
* - update xpp to point at next unconverted input, and tp to point
-#line 3240
+#line 3292
* at next location for converted output
-#line 3240
+#line 3292
*/
-#line 3240
+#line 3292
long i, j, ni;
-#line 3240
+#line 3292
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3240
+#line 3292
int *xp;
-#line 3240
+#line 3292
int nrange = 0; /* number of range errors */
-#line 3240
+#line 3292
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3240
+#line 3292
long cxp = (long) *((char**)xpp);
-#line 3240
+#line 3292
-#line 3240
+#line 3292
realign = (cxp & 7) % SIZEOF_INT;
-#line 3240
+#line 3292
/* sjl: manually stripmine so we can limit amount of
-#line 3240
+#line 3292
* vector work space reserved to LOOPCNT elements. Also
-#line 3240
+#line 3292
* makes vectorisation easy */
-#line 3240
+#line 3292
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3240
+#line 3292
ni=Min(nelems-j,LOOPCNT);
-#line 3240
+#line 3292
if (realign) {
-#line 3240
+#line 3292
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3240
+#line 3292
xp = tmp;
-#line 3240
+#line 3292
} else {
-#line 3240
+#line 3292
xp = (int *) *xpp;
-#line 3240
+#line 3292
}
-#line 3240
+#line 3292
/* copy the next block */
-#line 3240
+#line 3292
#pragma cdir loopcnt=LOOPCNT
-#line 3240
+#line 3292
#pragma cdir shortloop
-#line 3240
+#line 3292
for (i=0; i<ni; i++) {
-#line 3240
+#line 3292
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3240
+#line 3292
/* test for range errors (not always needed but do it anyway) */
-#line 3240
+#line 3292
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3240
+#line 3292
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3240
+#line 3292
nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
-#line 3240
+#line 3292
}
-#line 3240
+#line 3292
/* update xpp and tp */
-#line 3240
+#line 3292
if (realign) xp = (int *) *xpp;
-#line 3240
+#line 3292
xp += ni;
-#line 3240
+#line 3292
tp += ni;
-#line 3240
+#line 3292
*xpp = (void*)xp;
-#line 3240
+#line 3292
}
-#line 3240
+#line 3292
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3240
+#line 3292
-#line 3240
+#line 3292
#else /* not SX */
-#line 3240
+#line 3292
const char *xp = (const char *) *xpp;
-#line 3240
+#line 3292
int status = NC_NOERR;
-#line 3240
+#line 3292
-#line 3240
+#line 3292
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3240
+#line 3292
{
-#line 3240
+#line 3292
const int lstatus = ncx_get_int_float(xp, tp);
-#line 3240
+#line 3292
if (status == NC_NOERR) /* report the first encountered error */
-#line 3240
+#line 3292
status = lstatus;
-#line 3240
+#line 3292
}
-#line 3240
+#line 3292
-#line 3240
+#line 3292
*xpp = (const void *)xp;
-#line 3240
+#line 3292
return status;
-#line 3240
+#line 3292
#endif
-#line 3240
+#line 3292
}
-#line 3240
+#line 3292
int
-#line 3241
+#line 3293
ncx_getn_int_double(const void **xpp, size_t nelems, double *tp)
-#line 3241
+#line 3293
{
-#line 3241
+#line 3293
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3241
+#line 3293
-#line 3241
+#line 3293
/* basic algorithm is:
-#line 3241
+#line 3293
* - ensure sane alignment of input data
-#line 3241
+#line 3293
* - copy (conversion happens automatically) input data
-#line 3241
+#line 3293
* to output
-#line 3241
+#line 3293
* - update xpp to point at next unconverted input, and tp to point
-#line 3241
+#line 3293
* at next location for converted output
-#line 3241
+#line 3293
*/
-#line 3241
+#line 3293
long i, j, ni;
-#line 3241
+#line 3293
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3241
+#line 3293
int *xp;
-#line 3241
+#line 3293
int nrange = 0; /* number of range errors */
-#line 3241
+#line 3293
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3241
+#line 3293
long cxp = (long) *((char**)xpp);
-#line 3241
+#line 3293
-#line 3241
+#line 3293
realign = (cxp & 7) % SIZEOF_INT;
-#line 3241
+#line 3293
/* sjl: manually stripmine so we can limit amount of
-#line 3241
+#line 3293
* vector work space reserved to LOOPCNT elements. Also
-#line 3241
+#line 3293
* makes vectorisation easy */
-#line 3241
+#line 3293
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3241
+#line 3293
ni=Min(nelems-j,LOOPCNT);
-#line 3241
+#line 3293
if (realign) {
-#line 3241
+#line 3293
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3241
+#line 3293
xp = tmp;
-#line 3241
+#line 3293
} else {
-#line 3241
+#line 3293
xp = (int *) *xpp;
-#line 3241
+#line 3293
}
-#line 3241
+#line 3293
/* copy the next block */
-#line 3241
+#line 3293
#pragma cdir loopcnt=LOOPCNT
-#line 3241
+#line 3293
#pragma cdir shortloop
-#line 3241
+#line 3293
for (i=0; i<ni; i++) {
-#line 3241
+#line 3293
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3241
+#line 3293
/* test for range errors (not always needed but do it anyway) */
-#line 3241
+#line 3293
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3241
+#line 3293
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3241
+#line 3293
nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
-#line 3241
+#line 3293
}
-#line 3241
+#line 3293
/* update xpp and tp */
-#line 3241
+#line 3293
if (realign) xp = (int *) *xpp;
-#line 3241
+#line 3293
xp += ni;
-#line 3241
+#line 3293
tp += ni;
-#line 3241
+#line 3293
*xpp = (void*)xp;
-#line 3241
+#line 3293
}
-#line 3241
+#line 3293
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3241
+#line 3293
-#line 3241
+#line 3293
#else /* not SX */
-#line 3241
+#line 3293
const char *xp = (const char *) *xpp;
-#line 3241
+#line 3293
int status = NC_NOERR;
-#line 3241
+#line 3293
-#line 3241
+#line 3293
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3241
+#line 3293
{
-#line 3241
+#line 3293
const int lstatus = ncx_get_int_double(xp, tp);
-#line 3241
+#line 3293
if (status == NC_NOERR) /* report the first encountered error */
-#line 3241
+#line 3293
status = lstatus;
-#line 3241
+#line 3293
}
-#line 3241
+#line 3293
-#line 3241
+#line 3293
*xpp = (const void *)xp;
-#line 3241
+#line 3293
return status;
-#line 3241
+#line 3293
#endif
-#line 3241
+#line 3293
}
-#line 3241
+#line 3293
int
-#line 3242
+#line 3294
ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3242
+#line 3294
{
-#line 3242
+#line 3294
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3242
+#line 3294
-#line 3242
+#line 3294
/* basic algorithm is:
-#line 3242
+#line 3294
* - ensure sane alignment of input data
-#line 3242
+#line 3294
* - copy (conversion happens automatically) input data
-#line 3242
+#line 3294
* to output
-#line 3242
+#line 3294
* - update xpp to point at next unconverted input, and tp to point
-#line 3242
+#line 3294
* at next location for converted output
-#line 3242
+#line 3294
*/
-#line 3242
+#line 3294
long i, j, ni;
-#line 3242
+#line 3294
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3242
+#line 3294
int *xp;
-#line 3242
+#line 3294
int nrange = 0; /* number of range errors */
-#line 3242
+#line 3294
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3242
+#line 3294
long cxp = (long) *((char**)xpp);
-#line 3242
+#line 3294
-#line 3242
+#line 3294
realign = (cxp & 7) % SIZEOF_INT;
-#line 3242
+#line 3294
/* sjl: manually stripmine so we can limit amount of
-#line 3242
+#line 3294
* vector work space reserved to LOOPCNT elements. Also
-#line 3242
+#line 3294
* makes vectorisation easy */
-#line 3242
+#line 3294
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3242
+#line 3294
ni=Min(nelems-j,LOOPCNT);
-#line 3242
+#line 3294
if (realign) {
-#line 3242
+#line 3294
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3242
+#line 3294
xp = tmp;
-#line 3242
+#line 3294
} else {
-#line 3242
+#line 3294
xp = (int *) *xpp;
-#line 3242
+#line 3294
}
-#line 3242
+#line 3294
/* copy the next block */
-#line 3242
+#line 3294
#pragma cdir loopcnt=LOOPCNT
-#line 3242
+#line 3294
#pragma cdir shortloop
-#line 3242
+#line 3294
for (i=0; i<ni; i++) {
-#line 3242
+#line 3294
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3242
+#line 3294
/* test for range errors (not always needed but do it anyway) */
-#line 3242
+#line 3294
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3242
+#line 3294
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3242
+#line 3294
nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
-#line 3242
+#line 3294
}
-#line 3242
+#line 3294
/* update xpp and tp */
-#line 3242
+#line 3294
if (realign) xp = (int *) *xpp;
-#line 3242
+#line 3294
xp += ni;
-#line 3242
+#line 3294
tp += ni;
-#line 3242
+#line 3294
*xpp = (void*)xp;
-#line 3242
+#line 3294
}
-#line 3242
+#line 3294
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3242
+#line 3294
-#line 3242
+#line 3294
#else /* not SX */
-#line 3242
+#line 3294
const char *xp = (const char *) *xpp;
-#line 3242
+#line 3294
int status = NC_NOERR;
-#line 3242
+#line 3294
-#line 3242
+#line 3294
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3242
+#line 3294
{
-#line 3242
+#line 3294
const int lstatus = ncx_get_int_longlong(xp, tp);
-#line 3242
+#line 3294
if (status == NC_NOERR) /* report the first encountered error */
-#line 3242
+#line 3294
status = lstatus;
-#line 3242
+#line 3294
}
-#line 3242
+#line 3294
-#line 3242
+#line 3294
*xpp = (const void *)xp;
-#line 3242
+#line 3294
return status;
-#line 3242
+#line 3294
#endif
-#line 3242
+#line 3294
}
-#line 3242
+#line 3294
int
-#line 3243
+#line 3295
ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3243
+#line 3295
{
-#line 3243
+#line 3295
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3243
+#line 3295
-#line 3243
+#line 3295
/* basic algorithm is:
-#line 3243
+#line 3295
* - ensure sane alignment of input data
-#line 3243
+#line 3295
* - copy (conversion happens automatically) input data
-#line 3243
+#line 3295
* to output
-#line 3243
+#line 3295
* - update xpp to point at next unconverted input, and tp to point
-#line 3243
+#line 3295
* at next location for converted output
-#line 3243
+#line 3295
*/
-#line 3243
+#line 3295
long i, j, ni;
-#line 3243
+#line 3295
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3243
+#line 3295
int *xp;
-#line 3243
+#line 3295
int nrange = 0; /* number of range errors */
-#line 3243
+#line 3295
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3243
+#line 3295
long cxp = (long) *((char**)xpp);
-#line 3243
+#line 3295
-#line 3243
+#line 3295
realign = (cxp & 7) % SIZEOF_INT;
-#line 3243
+#line 3295
/* sjl: manually stripmine so we can limit amount of
-#line 3243
+#line 3295
* vector work space reserved to LOOPCNT elements. Also
-#line 3243
+#line 3295
* makes vectorisation easy */
-#line 3243
+#line 3295
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3243
+#line 3295
ni=Min(nelems-j,LOOPCNT);
-#line 3243
+#line 3295
if (realign) {
-#line 3243
+#line 3295
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3243
+#line 3295
xp = tmp;
-#line 3243
+#line 3295
} else {
-#line 3243
+#line 3295
xp = (int *) *xpp;
-#line 3243
+#line 3295
}
-#line 3243
+#line 3295
/* copy the next block */
-#line 3243
+#line 3295
#pragma cdir loopcnt=LOOPCNT
-#line 3243
+#line 3295
#pragma cdir shortloop
-#line 3243
+#line 3295
for (i=0; i<ni; i++) {
-#line 3243
+#line 3295
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3243
+#line 3295
/* test for range errors (not always needed but do it anyway) */
-#line 3243
+#line 3295
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3243
+#line 3295
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3243
+#line 3295
nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
-#line 3243
+#line 3295
}
-#line 3243
+#line 3295
/* update xpp and tp */
-#line 3243
+#line 3295
if (realign) xp = (int *) *xpp;
-#line 3243
+#line 3295
xp += ni;
-#line 3243
+#line 3295
tp += ni;
-#line 3243
+#line 3295
*xpp = (void*)xp;
-#line 3243
+#line 3295
}
-#line 3243
+#line 3295
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3243
+#line 3295
-#line 3243
+#line 3295
#else /* not SX */
-#line 3243
+#line 3295
const char *xp = (const char *) *xpp;
-#line 3243
+#line 3295
int status = NC_NOERR;
-#line 3243
+#line 3295
-#line 3243
+#line 3295
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3243
+#line 3295
{
-#line 3243
+#line 3295
const int lstatus = ncx_get_int_uchar(xp, tp);
-#line 3243
+#line 3295
if (status == NC_NOERR) /* report the first encountered error */
-#line 3243
+#line 3295
status = lstatus;
-#line 3243
+#line 3295
}
-#line 3243
+#line 3295
-#line 3243
+#line 3295
*xpp = (const void *)xp;
-#line 3243
+#line 3295
return status;
-#line 3243
+#line 3295
#endif
-#line 3243
+#line 3295
}
-#line 3243
+#line 3295
int
-#line 3244
+#line 3296
ncx_getn_int_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3244
+#line 3296
{
-#line 3244
+#line 3296
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3244
+#line 3296
-#line 3244
+#line 3296
/* basic algorithm is:
-#line 3244
+#line 3296
* - ensure sane alignment of input data
-#line 3244
+#line 3296
* - copy (conversion happens automatically) input data
-#line 3244
+#line 3296
* to output
-#line 3244
+#line 3296
* - update xpp to point at next unconverted input, and tp to point
-#line 3244
+#line 3296
* at next location for converted output
-#line 3244
+#line 3296
*/
-#line 3244
+#line 3296
long i, j, ni;
-#line 3244
+#line 3296
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3244
+#line 3296
int *xp;
-#line 3244
+#line 3296
int nrange = 0; /* number of range errors */
-#line 3244
+#line 3296
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3244
+#line 3296
long cxp = (long) *((char**)xpp);
-#line 3244
+#line 3296
-#line 3244
+#line 3296
realign = (cxp & 7) % SIZEOF_INT;
-#line 3244
+#line 3296
/* sjl: manually stripmine so we can limit amount of
-#line 3244
+#line 3296
* vector work space reserved to LOOPCNT elements. Also
-#line 3244
+#line 3296
* makes vectorisation easy */
-#line 3244
+#line 3296
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3244
+#line 3296
ni=Min(nelems-j,LOOPCNT);
-#line 3244
+#line 3296
if (realign) {
-#line 3244
+#line 3296
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3244
+#line 3296
xp = tmp;
-#line 3244
+#line 3296
} else {
-#line 3244
+#line 3296
xp = (int *) *xpp;
-#line 3244
+#line 3296
}
-#line 3244
+#line 3296
/* copy the next block */
-#line 3244
+#line 3296
#pragma cdir loopcnt=LOOPCNT
-#line 3244
+#line 3296
#pragma cdir shortloop
-#line 3244
+#line 3296
for (i=0; i<ni; i++) {
-#line 3244
+#line 3296
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3244
+#line 3296
/* test for range errors (not always needed but do it anyway) */
-#line 3244
+#line 3296
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3244
+#line 3296
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3244
+#line 3296
nrange += xp[i] > USHORT_MAX || xp[i] < 0;
-#line 3244
+#line 3296
}
-#line 3244
+#line 3296
/* update xpp and tp */
-#line 3244
+#line 3296
if (realign) xp = (int *) *xpp;
-#line 3244
+#line 3296
xp += ni;
-#line 3244
+#line 3296
tp += ni;
-#line 3244
+#line 3296
*xpp = (void*)xp;
-#line 3244
+#line 3296
}
-#line 3244
+#line 3296
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3244
+#line 3296
-#line 3244
+#line 3296
#else /* not SX */
-#line 3244
+#line 3296
const char *xp = (const char *) *xpp;
-#line 3244
+#line 3296
int status = NC_NOERR;
-#line 3244
+#line 3296
-#line 3244
+#line 3296
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3244
+#line 3296
{
-#line 3244
+#line 3296
const int lstatus = ncx_get_int_ushort(xp, tp);
-#line 3244
+#line 3296
if (status == NC_NOERR) /* report the first encountered error */
-#line 3244
+#line 3296
status = lstatus;
-#line 3244
+#line 3296
}
-#line 3244
+#line 3296
-#line 3244
+#line 3296
*xpp = (const void *)xp;
-#line 3244
+#line 3296
return status;
-#line 3244
+#line 3296
#endif
-#line 3244
+#line 3296
}
-#line 3244
+#line 3296
int
-#line 3245
+#line 3297
ncx_getn_int_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3245
+#line 3297
{
-#line 3245
+#line 3297
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3245
+#line 3297
-#line 3245
+#line 3297
/* basic algorithm is:
-#line 3245
+#line 3297
* - ensure sane alignment of input data
-#line 3245
+#line 3297
* - copy (conversion happens automatically) input data
-#line 3245
+#line 3297
* to output
-#line 3245
+#line 3297
* - update xpp to point at next unconverted input, and tp to point
-#line 3245
+#line 3297
* at next location for converted output
-#line 3245
+#line 3297
*/
-#line 3245
+#line 3297
long i, j, ni;
-#line 3245
+#line 3297
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3245
+#line 3297
int *xp;
-#line 3245
+#line 3297
int nrange = 0; /* number of range errors */
-#line 3245
+#line 3297
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3245
+#line 3297
long cxp = (long) *((char**)xpp);
-#line 3245
+#line 3297
-#line 3245
+#line 3297
realign = (cxp & 7) % SIZEOF_INT;
-#line 3245
+#line 3297
/* sjl: manually stripmine so we can limit amount of
-#line 3245
+#line 3297
* vector work space reserved to LOOPCNT elements. Also
-#line 3245
+#line 3297
* makes vectorisation easy */
-#line 3245
+#line 3297
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3245
+#line 3297
ni=Min(nelems-j,LOOPCNT);
-#line 3245
+#line 3297
if (realign) {
-#line 3245
+#line 3297
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3245
+#line 3297
xp = tmp;
-#line 3245
+#line 3297
} else {
-#line 3245
+#line 3297
xp = (int *) *xpp;
-#line 3245
+#line 3297
}
-#line 3245
+#line 3297
/* copy the next block */
-#line 3245
+#line 3297
#pragma cdir loopcnt=LOOPCNT
-#line 3245
+#line 3297
#pragma cdir shortloop
-#line 3245
+#line 3297
for (i=0; i<ni; i++) {
-#line 3245
+#line 3297
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3245
+#line 3297
/* test for range errors (not always needed but do it anyway) */
-#line 3245
+#line 3297
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3245
+#line 3297
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3245
+#line 3297
nrange += xp[i] > UINT_MAX || xp[i] < 0;
-#line 3245
+#line 3297
}
-#line 3245
+#line 3297
/* update xpp and tp */
-#line 3245
+#line 3297
if (realign) xp = (int *) *xpp;
-#line 3245
+#line 3297
xp += ni;
-#line 3245
+#line 3297
tp += ni;
-#line 3245
+#line 3297
*xpp = (void*)xp;
-#line 3245
+#line 3297
}
-#line 3245
+#line 3297
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3245
+#line 3297
-#line 3245
+#line 3297
#else /* not SX */
-#line 3245
+#line 3297
const char *xp = (const char *) *xpp;
-#line 3245
+#line 3297
int status = NC_NOERR;
-#line 3245
+#line 3297
-#line 3245
+#line 3297
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3245
+#line 3297
{
-#line 3245
+#line 3297
const int lstatus = ncx_get_int_uint(xp, tp);
-#line 3245
+#line 3297
if (status == NC_NOERR) /* report the first encountered error */
-#line 3245
+#line 3297
status = lstatus;
-#line 3245
+#line 3297
}
-#line 3245
+#line 3297
-#line 3245
+#line 3297
*xpp = (const void *)xp;
-#line 3245
+#line 3297
return status;
-#line 3245
+#line 3297
#endif
-#line 3245
+#line 3297
}
-#line 3245
+#line 3297
int
-#line 3246
+#line 3298
ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3246
+#line 3298
{
-#line 3246
+#line 3298
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3246
+#line 3298
-#line 3246
+#line 3298
/* basic algorithm is:
-#line 3246
+#line 3298
* - ensure sane alignment of input data
-#line 3246
+#line 3298
* - copy (conversion happens automatically) input data
-#line 3246
+#line 3298
* to output
-#line 3246
+#line 3298
* - update xpp to point at next unconverted input, and tp to point
-#line 3246
+#line 3298
* at next location for converted output
-#line 3246
+#line 3298
*/
-#line 3246
+#line 3298
long i, j, ni;
-#line 3246
+#line 3298
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3246
+#line 3298
int *xp;
-#line 3246
+#line 3298
int nrange = 0; /* number of range errors */
-#line 3246
+#line 3298
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3246
+#line 3298
long cxp = (long) *((char**)xpp);
-#line 3246
+#line 3298
-#line 3246
+#line 3298
realign = (cxp & 7) % SIZEOF_INT;
-#line 3246
+#line 3298
/* sjl: manually stripmine so we can limit amount of
-#line 3246
+#line 3298
* vector work space reserved to LOOPCNT elements. Also
-#line 3246
+#line 3298
* makes vectorisation easy */
-#line 3246
+#line 3298
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3246
+#line 3298
ni=Min(nelems-j,LOOPCNT);
-#line 3246
+#line 3298
if (realign) {
-#line 3246
+#line 3298
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT));
-#line 3246
+#line 3298
xp = tmp;
-#line 3246
+#line 3298
} else {
-#line 3246
+#line 3298
xp = (int *) *xpp;
-#line 3246
+#line 3298
}
-#line 3246
+#line 3298
/* copy the next block */
-#line 3246
+#line 3298
#pragma cdir loopcnt=LOOPCNT
-#line 3246
+#line 3298
#pragma cdir shortloop
-#line 3246
+#line 3298
for (i=0; i<ni; i++) {
-#line 3246
+#line 3298
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3246
+#line 3298
/* test for range errors (not always needed but do it anyway) */
-#line 3246
+#line 3298
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3246
+#line 3298
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3246
+#line 3298
nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
-#line 3246
+#line 3298
}
-#line 3246
+#line 3298
/* update xpp and tp */
-#line 3246
+#line 3298
if (realign) xp = (int *) *xpp;
-#line 3246
+#line 3298
xp += ni;
-#line 3246
+#line 3298
tp += ni;
-#line 3246
+#line 3298
*xpp = (void*)xp;
-#line 3246
+#line 3298
}
-#line 3246
+#line 3298
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3246
+#line 3298
-#line 3246
+#line 3298
#else /* not SX */
-#line 3246
+#line 3298
const char *xp = (const char *) *xpp;
-#line 3246
+#line 3298
int status = NC_NOERR;
-#line 3246
+#line 3298
-#line 3246
+#line 3298
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3246
+#line 3298
{
-#line 3246
+#line 3298
const int lstatus = ncx_get_int_ulonglong(xp, tp);
-#line 3246
+#line 3298
if (status == NC_NOERR) /* report the first encountered error */
-#line 3246
+#line 3298
status = lstatus;
-#line 3246
+#line 3298
}
-#line 3246
+#line 3298
-#line 3246
+#line 3298
*xpp = (const void *)xp;
-#line 3246
+#line 3298
return status;
-#line 3246
+#line 3298
#endif
-#line 3246
+#line 3298
}
-#line 3246
+#line 3298
#if X_SIZEOF_INT == SIZEOF_INT
@@ -20855,1532 +22940,1532 @@ ncx_putn_int_int(void **xpp, size_t nelems, const int *tp, void *fillp)
}
#else
int
-#line 3262
+#line 3314
ncx_putn_int_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3262
+#line 3314
{
-#line 3262
+#line 3314
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3262
+#line 3314
-#line 3262
+#line 3314
/* basic algorithm is:
-#line 3262
+#line 3314
* - ensure sane alignment of output data
-#line 3262
+#line 3314
* - copy (conversion happens automatically) input data
-#line 3262
+#line 3314
* to output
-#line 3262
+#line 3314
* - update tp to point at next unconverted input, and xpp to point
-#line 3262
+#line 3314
* at next location for converted output
-#line 3262
+#line 3314
*/
-#line 3262
+#line 3314
long i, j, ni;
-#line 3262
+#line 3314
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3262
+#line 3314
int *xp;
-#line 3262
+#line 3314
int nrange = 0; /* number of range errors */
-#line 3262
+#line 3314
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3262
+#line 3314
long cxp = (long) *((char**)xpp);
-#line 3262
+#line 3314
-#line 3262
+#line 3314
realign = (cxp & 7) % SIZEOF_INT;
-#line 3262
+#line 3314
/* sjl: manually stripmine so we can limit amount of
-#line 3262
+#line 3314
* vector work space reserved to LOOPCNT elements. Also
-#line 3262
+#line 3314
* makes vectorisation easy */
-#line 3262
+#line 3314
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3262
+#line 3314
ni=Min(nelems-j,LOOPCNT);
-#line 3262
+#line 3314
if (realign) {
-#line 3262
+#line 3314
xp = tmp;
-#line 3262
+#line 3314
} else {
-#line 3262
+#line 3314
xp = (int *) *xpp;
-#line 3262
+#line 3314
}
-#line 3262
+#line 3314
/* copy the next block */
-#line 3262
+#line 3314
#pragma cdir loopcnt=LOOPCNT
-#line 3262
+#line 3314
#pragma cdir shortloop
-#line 3262
+#line 3314
for (i=0; i<ni; i++) {
-#line 3262
+#line 3314
/* the normal case: */
-#line 3262
+#line 3314
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3262
+#line 3314
/* test for range errors (not always needed but do it anyway) */
-#line 3262
+#line 3314
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3262
+#line 3314
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3262
+#line 3314
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3262
+#line 3314
}
-#line 3262
+#line 3314
/* copy workspace back if necessary */
-#line 3262
+#line 3314
if (realign) {
-#line 3262
+#line 3314
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3262
+#line 3314
xp = (int *) *xpp;
-#line 3262
+#line 3314
}
-#line 3262
+#line 3314
/* update xpp and tp */
-#line 3262
+#line 3314
xp += ni;
-#line 3262
+#line 3314
tp += ni;
-#line 3262
+#line 3314
*xpp = (void*)xp;
-#line 3262
+#line 3314
}
-#line 3262
+#line 3314
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3262
+#line 3314
-#line 3262
+#line 3314
#else /* not SX */
-#line 3262
+#line 3314
-#line 3262
+#line 3314
char *xp = (char *) *xpp;
-#line 3262
+#line 3314
int status = NC_NOERR;
-#line 3262
+#line 3314
-#line 3262
+#line 3314
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3262
+#line 3314
{
-#line 3262
+#line 3314
int lstatus = ncx_put_int_int(xp, tp, fillp);
-#line 3262
+#line 3314
if (status == NC_NOERR) /* report the first encountered error */
-#line 3262
+#line 3314
status = lstatus;
-#line 3262
+#line 3314
}
-#line 3262
+#line 3314
-#line 3262
+#line 3314
*xpp = (void *)xp;
-#line 3262
+#line 3314
return status;
-#line 3262
+#line 3314
#endif
-#line 3262
+#line 3314
}
-#line 3262
+#line 3314
#endif
int
-#line 3264
+#line 3316
ncx_putn_int_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3264
+#line 3316
{
-#line 3264
+#line 3316
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3264
+#line 3316
-#line 3264
+#line 3316
/* basic algorithm is:
-#line 3264
+#line 3316
* - ensure sane alignment of output data
-#line 3264
+#line 3316
* - copy (conversion happens automatically) input data
-#line 3264
+#line 3316
* to output
-#line 3264
+#line 3316
* - update tp to point at next unconverted input, and xpp to point
-#line 3264
+#line 3316
* at next location for converted output
-#line 3264
+#line 3316
*/
-#line 3264
+#line 3316
long i, j, ni;
-#line 3264
+#line 3316
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3264
+#line 3316
int *xp;
-#line 3264
+#line 3316
int nrange = 0; /* number of range errors */
-#line 3264
+#line 3316
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3264
+#line 3316
long cxp = (long) *((char**)xpp);
-#line 3264
+#line 3316
-#line 3264
+#line 3316
realign = (cxp & 7) % SIZEOF_INT;
-#line 3264
+#line 3316
/* sjl: manually stripmine so we can limit amount of
-#line 3264
+#line 3316
* vector work space reserved to LOOPCNT elements. Also
-#line 3264
+#line 3316
* makes vectorisation easy */
-#line 3264
+#line 3316
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3264
+#line 3316
ni=Min(nelems-j,LOOPCNT);
-#line 3264
+#line 3316
if (realign) {
-#line 3264
+#line 3316
xp = tmp;
-#line 3264
+#line 3316
} else {
-#line 3264
+#line 3316
xp = (int *) *xpp;
-#line 3264
+#line 3316
}
-#line 3264
+#line 3316
/* copy the next block */
-#line 3264
+#line 3316
#pragma cdir loopcnt=LOOPCNT
-#line 3264
+#line 3316
#pragma cdir shortloop
-#line 3264
+#line 3316
for (i=0; i<ni; i++) {
-#line 3264
+#line 3316
/* the normal case: */
-#line 3264
+#line 3316
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3264
+#line 3316
/* test for range errors (not always needed but do it anyway) */
-#line 3264
+#line 3316
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3264
+#line 3316
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3264
+#line 3316
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3264
+#line 3316
}
-#line 3264
+#line 3316
/* copy workspace back if necessary */
-#line 3264
+#line 3316
if (realign) {
-#line 3264
+#line 3316
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3264
+#line 3316
xp = (int *) *xpp;
-#line 3264
+#line 3316
}
-#line 3264
+#line 3316
/* update xpp and tp */
-#line 3264
+#line 3316
xp += ni;
-#line 3264
+#line 3316
tp += ni;
-#line 3264
+#line 3316
*xpp = (void*)xp;
-#line 3264
+#line 3316
}
-#line 3264
+#line 3316
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3264
+#line 3316
-#line 3264
+#line 3316
#else /* not SX */
-#line 3264
+#line 3316
-#line 3264
+#line 3316
char *xp = (char *) *xpp;
-#line 3264
+#line 3316
int status = NC_NOERR;
-#line 3264
+#line 3316
-#line 3264
+#line 3316
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3264
+#line 3316
{
-#line 3264
+#line 3316
int lstatus = ncx_put_int_schar(xp, tp, fillp);
-#line 3264
+#line 3316
if (status == NC_NOERR) /* report the first encountered error */
-#line 3264
+#line 3316
status = lstatus;
-#line 3264
+#line 3316
}
-#line 3264
+#line 3316
-#line 3264
+#line 3316
*xpp = (void *)xp;
-#line 3264
+#line 3316
return status;
-#line 3264
+#line 3316
#endif
-#line 3264
+#line 3316
}
-#line 3264
+#line 3316
int
-#line 3265
+#line 3317
ncx_putn_int_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3265
+#line 3317
{
-#line 3265
+#line 3317
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3265
+#line 3317
-#line 3265
+#line 3317
/* basic algorithm is:
-#line 3265
+#line 3317
* - ensure sane alignment of output data
-#line 3265
+#line 3317
* - copy (conversion happens automatically) input data
-#line 3265
+#line 3317
* to output
-#line 3265
+#line 3317
* - update tp to point at next unconverted input, and xpp to point
-#line 3265
+#line 3317
* at next location for converted output
-#line 3265
+#line 3317
*/
-#line 3265
+#line 3317
long i, j, ni;
-#line 3265
+#line 3317
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3265
+#line 3317
int *xp;
-#line 3265
+#line 3317
int nrange = 0; /* number of range errors */
-#line 3265
+#line 3317
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3265
+#line 3317
long cxp = (long) *((char**)xpp);
-#line 3265
+#line 3317
-#line 3265
+#line 3317
realign = (cxp & 7) % SIZEOF_INT;
-#line 3265
+#line 3317
/* sjl: manually stripmine so we can limit amount of
-#line 3265
+#line 3317
* vector work space reserved to LOOPCNT elements. Also
-#line 3265
+#line 3317
* makes vectorisation easy */
-#line 3265
+#line 3317
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3265
+#line 3317
ni=Min(nelems-j,LOOPCNT);
-#line 3265
+#line 3317
if (realign) {
-#line 3265
+#line 3317
xp = tmp;
-#line 3265
+#line 3317
} else {
-#line 3265
+#line 3317
xp = (int *) *xpp;
-#line 3265
+#line 3317
}
-#line 3265
+#line 3317
/* copy the next block */
-#line 3265
+#line 3317
#pragma cdir loopcnt=LOOPCNT
-#line 3265
+#line 3317
#pragma cdir shortloop
-#line 3265
+#line 3317
for (i=0; i<ni; i++) {
-#line 3265
+#line 3317
/* the normal case: */
-#line 3265
+#line 3317
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3265
+#line 3317
/* test for range errors (not always needed but do it anyway) */
-#line 3265
+#line 3317
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3265
+#line 3317
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3265
+#line 3317
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3265
+#line 3317
}
-#line 3265
+#line 3317
/* copy workspace back if necessary */
-#line 3265
+#line 3317
if (realign) {
-#line 3265
+#line 3317
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3265
+#line 3317
xp = (int *) *xpp;
-#line 3265
+#line 3317
}
-#line 3265
+#line 3317
/* update xpp and tp */
-#line 3265
+#line 3317
xp += ni;
-#line 3265
+#line 3317
tp += ni;
-#line 3265
+#line 3317
*xpp = (void*)xp;
-#line 3265
+#line 3317
}
-#line 3265
+#line 3317
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3265
+#line 3317
-#line 3265
+#line 3317
#else /* not SX */
-#line 3265
+#line 3317
-#line 3265
+#line 3317
char *xp = (char *) *xpp;
-#line 3265
+#line 3317
int status = NC_NOERR;
-#line 3265
+#line 3317
-#line 3265
+#line 3317
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3265
+#line 3317
{
-#line 3265
+#line 3317
int lstatus = ncx_put_int_short(xp, tp, fillp);
-#line 3265
+#line 3317
if (status == NC_NOERR) /* report the first encountered error */
-#line 3265
+#line 3317
status = lstatus;
-#line 3265
+#line 3317
}
-#line 3265
+#line 3317
-#line 3265
+#line 3317
*xpp = (void *)xp;
-#line 3265
+#line 3317
return status;
-#line 3265
+#line 3317
#endif
-#line 3265
+#line 3317
}
-#line 3265
+#line 3317
int
-#line 3266
+#line 3318
ncx_putn_int_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3266
+#line 3318
{
-#line 3266
+#line 3318
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3266
+#line 3318
-#line 3266
+#line 3318
/* basic algorithm is:
-#line 3266
+#line 3318
* - ensure sane alignment of output data
-#line 3266
+#line 3318
* - copy (conversion happens automatically) input data
-#line 3266
+#line 3318
* to output
-#line 3266
+#line 3318
* - update tp to point at next unconverted input, and xpp to point
-#line 3266
+#line 3318
* at next location for converted output
-#line 3266
+#line 3318
*/
-#line 3266
+#line 3318
long i, j, ni;
-#line 3266
+#line 3318
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3266
+#line 3318
int *xp;
-#line 3266
+#line 3318
int nrange = 0; /* number of range errors */
-#line 3266
+#line 3318
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3266
+#line 3318
long cxp = (long) *((char**)xpp);
-#line 3266
+#line 3318
-#line 3266
+#line 3318
realign = (cxp & 7) % SIZEOF_INT;
-#line 3266
+#line 3318
/* sjl: manually stripmine so we can limit amount of
-#line 3266
+#line 3318
* vector work space reserved to LOOPCNT elements. Also
-#line 3266
+#line 3318
* makes vectorisation easy */
-#line 3266
+#line 3318
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3266
+#line 3318
ni=Min(nelems-j,LOOPCNT);
-#line 3266
+#line 3318
if (realign) {
-#line 3266
+#line 3318
xp = tmp;
-#line 3266
+#line 3318
} else {
-#line 3266
+#line 3318
xp = (int *) *xpp;
-#line 3266
+#line 3318
}
-#line 3266
+#line 3318
/* copy the next block */
-#line 3266
+#line 3318
#pragma cdir loopcnt=LOOPCNT
-#line 3266
+#line 3318
#pragma cdir shortloop
-#line 3266
+#line 3318
for (i=0; i<ni; i++) {
-#line 3266
+#line 3318
/* the normal case: */
-#line 3266
+#line 3318
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3266
+#line 3318
/* test for range errors (not always needed but do it anyway) */
-#line 3266
+#line 3318
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3266
+#line 3318
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3266
+#line 3318
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3266
+#line 3318
}
-#line 3266
+#line 3318
/* copy workspace back if necessary */
-#line 3266
+#line 3318
if (realign) {
-#line 3266
+#line 3318
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3266
+#line 3318
xp = (int *) *xpp;
-#line 3266
+#line 3318
}
-#line 3266
+#line 3318
/* update xpp and tp */
-#line 3266
+#line 3318
xp += ni;
-#line 3266
+#line 3318
tp += ni;
-#line 3266
+#line 3318
*xpp = (void*)xp;
-#line 3266
+#line 3318
}
-#line 3266
+#line 3318
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3266
+#line 3318
-#line 3266
+#line 3318
#else /* not SX */
-#line 3266
+#line 3318
-#line 3266
+#line 3318
char *xp = (char *) *xpp;
-#line 3266
+#line 3318
int status = NC_NOERR;
-#line 3266
+#line 3318
-#line 3266
+#line 3318
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3266
+#line 3318
{
-#line 3266
+#line 3318
int lstatus = ncx_put_int_long(xp, tp, fillp);
-#line 3266
+#line 3318
if (status == NC_NOERR) /* report the first encountered error */
-#line 3266
+#line 3318
status = lstatus;
-#line 3266
+#line 3318
}
-#line 3266
+#line 3318
-#line 3266
+#line 3318
*xpp = (void *)xp;
-#line 3266
+#line 3318
return status;
-#line 3266
+#line 3318
#endif
-#line 3266
+#line 3318
}
-#line 3266
+#line 3318
int
-#line 3267
+#line 3319
ncx_putn_int_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3267
+#line 3319
{
-#line 3267
+#line 3319
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3267
+#line 3319
-#line 3267
+#line 3319
/* basic algorithm is:
-#line 3267
+#line 3319
* - ensure sane alignment of output data
-#line 3267
+#line 3319
* - copy (conversion happens automatically) input data
-#line 3267
+#line 3319
* to output
-#line 3267
+#line 3319
* - update tp to point at next unconverted input, and xpp to point
-#line 3267
+#line 3319
* at next location for converted output
-#line 3267
+#line 3319
*/
-#line 3267
+#line 3319
long i, j, ni;
-#line 3267
+#line 3319
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3267
+#line 3319
int *xp;
-#line 3267
+#line 3319
double d; /* special case for ncx_putn_int_float */
-#line 3267
+#line 3319
int nrange = 0; /* number of range errors */
-#line 3267
+#line 3319
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3267
+#line 3319
long cxp = (long) *((char**)xpp);
-#line 3267
+#line 3319
-#line 3267
+#line 3319
realign = (cxp & 7) % SIZEOF_INT;
-#line 3267
+#line 3319
/* sjl: manually stripmine so we can limit amount of
-#line 3267
+#line 3319
* vector work space reserved to LOOPCNT elements. Also
-#line 3267
+#line 3319
* makes vectorisation easy */
-#line 3267
+#line 3319
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3267
+#line 3319
ni=Min(nelems-j,LOOPCNT);
-#line 3267
+#line 3319
if (realign) {
-#line 3267
+#line 3319
xp = tmp;
-#line 3267
+#line 3319
} else {
-#line 3267
+#line 3319
xp = (int *) *xpp;
-#line 3267
+#line 3319
}
-#line 3267
+#line 3319
/* copy the next block */
-#line 3267
+#line 3319
#pragma cdir loopcnt=LOOPCNT
-#line 3267
+#line 3319
#pragma cdir shortloop
-#line 3267
+#line 3319
for (i=0; i<ni; i++) {
-#line 3267
+#line 3319
/* for some reason int to float, for putn, requires a special case */
-#line 3267
+#line 3319
d = tp[i];
-#line 3267
+#line 3319
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) d));
-#line 3267
+#line 3319
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3267
+#line 3319
}
-#line 3267
+#line 3319
/* copy workspace back if necessary */
-#line 3267
+#line 3319
if (realign) {
-#line 3267
+#line 3319
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3267
+#line 3319
xp = (int *) *xpp;
-#line 3267
+#line 3319
}
-#line 3267
+#line 3319
/* update xpp and tp */
-#line 3267
+#line 3319
xp += ni;
-#line 3267
+#line 3319
tp += ni;
-#line 3267
+#line 3319
*xpp = (void*)xp;
-#line 3267
+#line 3319
}
-#line 3267
+#line 3319
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3267
+#line 3319
-#line 3267
+#line 3319
#else /* not SX */
-#line 3267
+#line 3319
-#line 3267
+#line 3319
char *xp = (char *) *xpp;
-#line 3267
+#line 3319
int status = NC_NOERR;
-#line 3267
+#line 3319
-#line 3267
+#line 3319
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3267
+#line 3319
{
-#line 3267
+#line 3319
int lstatus = ncx_put_int_float(xp, tp, fillp);
-#line 3267
+#line 3319
if (status == NC_NOERR) /* report the first encountered error */
-#line 3267
+#line 3319
status = lstatus;
-#line 3267
+#line 3319
}
-#line 3267
+#line 3319
-#line 3267
+#line 3319
*xpp = (void *)xp;
-#line 3267
+#line 3319
return status;
-#line 3267
+#line 3319
#endif
-#line 3267
+#line 3319
}
-#line 3267
+#line 3319
int
-#line 3268
+#line 3320
ncx_putn_int_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3268
+#line 3320
{
-#line 3268
+#line 3320
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3268
+#line 3320
-#line 3268
+#line 3320
/* basic algorithm is:
-#line 3268
+#line 3320
* - ensure sane alignment of output data
-#line 3268
+#line 3320
* - copy (conversion happens automatically) input data
-#line 3268
+#line 3320
* to output
-#line 3268
+#line 3320
* - update tp to point at next unconverted input, and xpp to point
-#line 3268
+#line 3320
* at next location for converted output
-#line 3268
+#line 3320
*/
-#line 3268
+#line 3320
long i, j, ni;
-#line 3268
+#line 3320
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3268
+#line 3320
int *xp;
-#line 3268
+#line 3320
int nrange = 0; /* number of range errors */
-#line 3268
+#line 3320
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3268
+#line 3320
long cxp = (long) *((char**)xpp);
-#line 3268
+#line 3320
-#line 3268
+#line 3320
realign = (cxp & 7) % SIZEOF_INT;
-#line 3268
+#line 3320
/* sjl: manually stripmine so we can limit amount of
-#line 3268
+#line 3320
* vector work space reserved to LOOPCNT elements. Also
-#line 3268
+#line 3320
* makes vectorisation easy */
-#line 3268
+#line 3320
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3268
+#line 3320
ni=Min(nelems-j,LOOPCNT);
-#line 3268
+#line 3320
if (realign) {
-#line 3268
+#line 3320
xp = tmp;
-#line 3268
+#line 3320
} else {
-#line 3268
+#line 3320
xp = (int *) *xpp;
-#line 3268
+#line 3320
}
-#line 3268
+#line 3320
/* copy the next block */
-#line 3268
+#line 3320
#pragma cdir loopcnt=LOOPCNT
-#line 3268
+#line 3320
#pragma cdir shortloop
-#line 3268
+#line 3320
for (i=0; i<ni; i++) {
-#line 3268
+#line 3320
/* the normal case: */
-#line 3268
+#line 3320
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3268
+#line 3320
/* test for range errors (not always needed but do it anyway) */
-#line 3268
+#line 3320
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3268
+#line 3320
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3268
+#line 3320
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3268
+#line 3320
}
-#line 3268
+#line 3320
/* copy workspace back if necessary */
-#line 3268
+#line 3320
if (realign) {
-#line 3268
+#line 3320
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3268
+#line 3320
xp = (int *) *xpp;
-#line 3268
+#line 3320
}
-#line 3268
+#line 3320
/* update xpp and tp */
-#line 3268
+#line 3320
xp += ni;
-#line 3268
+#line 3320
tp += ni;
-#line 3268
+#line 3320
*xpp = (void*)xp;
-#line 3268
+#line 3320
}
-#line 3268
+#line 3320
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3268
+#line 3320
-#line 3268
+#line 3320
#else /* not SX */
-#line 3268
+#line 3320
-#line 3268
+#line 3320
char *xp = (char *) *xpp;
-#line 3268
+#line 3320
int status = NC_NOERR;
-#line 3268
+#line 3320
-#line 3268
+#line 3320
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3268
+#line 3320
{
-#line 3268
+#line 3320
int lstatus = ncx_put_int_double(xp, tp, fillp);
-#line 3268
+#line 3320
if (status == NC_NOERR) /* report the first encountered error */
-#line 3268
+#line 3320
status = lstatus;
-#line 3268
+#line 3320
}
-#line 3268
+#line 3320
-#line 3268
+#line 3320
*xpp = (void *)xp;
-#line 3268
+#line 3320
return status;
-#line 3268
+#line 3320
#endif
-#line 3268
+#line 3320
}
-#line 3268
+#line 3320
int
-#line 3269
+#line 3321
ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3269
+#line 3321
{
-#line 3269
+#line 3321
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3269
+#line 3321
-#line 3269
+#line 3321
/* basic algorithm is:
-#line 3269
+#line 3321
* - ensure sane alignment of output data
-#line 3269
+#line 3321
* - copy (conversion happens automatically) input data
-#line 3269
+#line 3321
* to output
-#line 3269
+#line 3321
* - update tp to point at next unconverted input, and xpp to point
-#line 3269
+#line 3321
* at next location for converted output
-#line 3269
+#line 3321
*/
-#line 3269
+#line 3321
long i, j, ni;
-#line 3269
+#line 3321
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3269
+#line 3321
int *xp;
-#line 3269
+#line 3321
int nrange = 0; /* number of range errors */
-#line 3269
+#line 3321
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3269
+#line 3321
long cxp = (long) *((char**)xpp);
-#line 3269
+#line 3321
-#line 3269
+#line 3321
realign = (cxp & 7) % SIZEOF_INT;
-#line 3269
+#line 3321
/* sjl: manually stripmine so we can limit amount of
-#line 3269
+#line 3321
* vector work space reserved to LOOPCNT elements. Also
-#line 3269
+#line 3321
* makes vectorisation easy */
-#line 3269
+#line 3321
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3269
+#line 3321
ni=Min(nelems-j,LOOPCNT);
-#line 3269
+#line 3321
if (realign) {
-#line 3269
+#line 3321
xp = tmp;
-#line 3269
+#line 3321
} else {
-#line 3269
+#line 3321
xp = (int *) *xpp;
-#line 3269
+#line 3321
}
-#line 3269
+#line 3321
/* copy the next block */
-#line 3269
+#line 3321
#pragma cdir loopcnt=LOOPCNT
-#line 3269
+#line 3321
#pragma cdir shortloop
-#line 3269
+#line 3321
for (i=0; i<ni; i++) {
-#line 3269
+#line 3321
/* the normal case: */
-#line 3269
+#line 3321
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3269
+#line 3321
/* test for range errors (not always needed but do it anyway) */
-#line 3269
+#line 3321
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3269
+#line 3321
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3269
+#line 3321
nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
-#line 3269
+#line 3321
}
-#line 3269
+#line 3321
/* copy workspace back if necessary */
-#line 3269
+#line 3321
if (realign) {
-#line 3269
+#line 3321
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3269
+#line 3321
xp = (int *) *xpp;
-#line 3269
+#line 3321
}
-#line 3269
+#line 3321
/* update xpp and tp */
-#line 3269
+#line 3321
xp += ni;
-#line 3269
+#line 3321
tp += ni;
-#line 3269
+#line 3321
*xpp = (void*)xp;
-#line 3269
+#line 3321
}
-#line 3269
+#line 3321
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3269
+#line 3321
-#line 3269
+#line 3321
#else /* not SX */
-#line 3269
+#line 3321
-#line 3269
+#line 3321
char *xp = (char *) *xpp;
-#line 3269
+#line 3321
int status = NC_NOERR;
-#line 3269
+#line 3321
-#line 3269
+#line 3321
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3269
+#line 3321
{
-#line 3269
+#line 3321
int lstatus = ncx_put_int_longlong(xp, tp, fillp);
-#line 3269
+#line 3321
if (status == NC_NOERR) /* report the first encountered error */
-#line 3269
+#line 3321
status = lstatus;
-#line 3269
+#line 3321
}
-#line 3269
+#line 3321
-#line 3269
+#line 3321
*xpp = (void *)xp;
-#line 3269
+#line 3321
return status;
-#line 3269
+#line 3321
#endif
-#line 3269
+#line 3321
}
-#line 3269
+#line 3321
int
-#line 3270
+#line 3322
ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3270
+#line 3322
{
-#line 3270
+#line 3322
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3270
+#line 3322
-#line 3270
+#line 3322
/* basic algorithm is:
-#line 3270
+#line 3322
* - ensure sane alignment of output data
-#line 3270
+#line 3322
* - copy (conversion happens automatically) input data
-#line 3270
+#line 3322
* to output
-#line 3270
+#line 3322
* - update tp to point at next unconverted input, and xpp to point
-#line 3270
+#line 3322
* at next location for converted output
-#line 3270
+#line 3322
*/
-#line 3270
+#line 3322
long i, j, ni;
-#line 3270
+#line 3322
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3270
+#line 3322
int *xp;
-#line 3270
+#line 3322
int nrange = 0; /* number of range errors */
-#line 3270
+#line 3322
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3270
+#line 3322
long cxp = (long) *((char**)xpp);
-#line 3270
+#line 3322
-#line 3270
+#line 3322
realign = (cxp & 7) % SIZEOF_INT;
-#line 3270
+#line 3322
/* sjl: manually stripmine so we can limit amount of
-#line 3270
+#line 3322
* vector work space reserved to LOOPCNT elements. Also
-#line 3270
+#line 3322
* makes vectorisation easy */
-#line 3270
+#line 3322
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3270
+#line 3322
ni=Min(nelems-j,LOOPCNT);
-#line 3270
+#line 3322
if (realign) {
-#line 3270
+#line 3322
xp = tmp;
-#line 3270
+#line 3322
} else {
-#line 3270
+#line 3322
xp = (int *) *xpp;
-#line 3270
+#line 3322
}
-#line 3270
+#line 3322
/* copy the next block */
-#line 3270
+#line 3322
#pragma cdir loopcnt=LOOPCNT
-#line 3270
+#line 3322
#pragma cdir shortloop
-#line 3270
+#line 3322
for (i=0; i<ni; i++) {
-#line 3270
+#line 3322
/* the normal case: */
-#line 3270
+#line 3322
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3270
+#line 3322
/* test for range errors (not always needed but do it anyway) */
-#line 3270
+#line 3322
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3270
+#line 3322
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3270
+#line 3322
nrange += tp[i] > X_INT_MAX ;
-#line 3270
+#line 3322
}
-#line 3270
+#line 3322
/* copy workspace back if necessary */
-#line 3270
+#line 3322
if (realign) {
-#line 3270
+#line 3322
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3270
+#line 3322
xp = (int *) *xpp;
-#line 3270
+#line 3322
}
-#line 3270
+#line 3322
/* update xpp and tp */
-#line 3270
+#line 3322
xp += ni;
-#line 3270
+#line 3322
tp += ni;
-#line 3270
+#line 3322
*xpp = (void*)xp;
-#line 3270
+#line 3322
}
-#line 3270
+#line 3322
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3270
+#line 3322
-#line 3270
+#line 3322
#else /* not SX */
-#line 3270
+#line 3322
-#line 3270
+#line 3322
char *xp = (char *) *xpp;
-#line 3270
+#line 3322
int status = NC_NOERR;
-#line 3270
+#line 3322
-#line 3270
+#line 3322
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3270
+#line 3322
{
-#line 3270
+#line 3322
int lstatus = ncx_put_int_uchar(xp, tp, fillp);
-#line 3270
+#line 3322
if (status == NC_NOERR) /* report the first encountered error */
-#line 3270
+#line 3322
status = lstatus;
-#line 3270
+#line 3322
}
-#line 3270
+#line 3322
-#line 3270
+#line 3322
*xpp = (void *)xp;
-#line 3270
+#line 3322
return status;
-#line 3270
+#line 3322
#endif
-#line 3270
+#line 3322
}
-#line 3270
+#line 3322
int
-#line 3271
+#line 3323
ncx_putn_int_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3271
+#line 3323
{
-#line 3271
+#line 3323
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3271
+#line 3323
-#line 3271
+#line 3323
/* basic algorithm is:
-#line 3271
+#line 3323
* - ensure sane alignment of output data
-#line 3271
+#line 3323
* - copy (conversion happens automatically) input data
-#line 3271
+#line 3323
* to output
-#line 3271
+#line 3323
* - update tp to point at next unconverted input, and xpp to point
-#line 3271
+#line 3323
* at next location for converted output
-#line 3271
+#line 3323
*/
-#line 3271
+#line 3323
long i, j, ni;
-#line 3271
+#line 3323
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3271
+#line 3323
int *xp;
-#line 3271
+#line 3323
int nrange = 0; /* number of range errors */
-#line 3271
+#line 3323
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3271
+#line 3323
long cxp = (long) *((char**)xpp);
-#line 3271
+#line 3323
-#line 3271
+#line 3323
realign = (cxp & 7) % SIZEOF_INT;
-#line 3271
+#line 3323
/* sjl: manually stripmine so we can limit amount of
-#line 3271
+#line 3323
* vector work space reserved to LOOPCNT elements. Also
-#line 3271
+#line 3323
* makes vectorisation easy */
-#line 3271
+#line 3323
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3271
+#line 3323
ni=Min(nelems-j,LOOPCNT);
-#line 3271
+#line 3323
if (realign) {
-#line 3271
+#line 3323
xp = tmp;
-#line 3271
+#line 3323
} else {
-#line 3271
+#line 3323
xp = (int *) *xpp;
-#line 3271
+#line 3323
}
-#line 3271
+#line 3323
/* copy the next block */
-#line 3271
+#line 3323
#pragma cdir loopcnt=LOOPCNT
-#line 3271
+#line 3323
#pragma cdir shortloop
-#line 3271
+#line 3323
for (i=0; i<ni; i++) {
-#line 3271
+#line 3323
/* the normal case: */
-#line 3271
+#line 3323
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3271
+#line 3323
/* test for range errors (not always needed but do it anyway) */
-#line 3271
+#line 3323
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3271
+#line 3323
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3271
+#line 3323
nrange += tp[i] > X_INT_MAX ;
-#line 3271
+#line 3323
}
-#line 3271
+#line 3323
/* copy workspace back if necessary */
-#line 3271
+#line 3323
if (realign) {
-#line 3271
+#line 3323
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3271
+#line 3323
xp = (int *) *xpp;
-#line 3271
+#line 3323
}
-#line 3271
+#line 3323
/* update xpp and tp */
-#line 3271
+#line 3323
xp += ni;
-#line 3271
+#line 3323
tp += ni;
-#line 3271
+#line 3323
*xpp = (void*)xp;
-#line 3271
+#line 3323
}
-#line 3271
+#line 3323
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3271
+#line 3323
-#line 3271
+#line 3323
#else /* not SX */
-#line 3271
+#line 3323
-#line 3271
+#line 3323
char *xp = (char *) *xpp;
-#line 3271
+#line 3323
int status = NC_NOERR;
-#line 3271
+#line 3323
-#line 3271
+#line 3323
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3271
+#line 3323
{
-#line 3271
+#line 3323
int lstatus = ncx_put_int_ushort(xp, tp, fillp);
-#line 3271
+#line 3323
if (status == NC_NOERR) /* report the first encountered error */
-#line 3271
+#line 3323
status = lstatus;
-#line 3271
+#line 3323
}
-#line 3271
+#line 3323
-#line 3271
+#line 3323
*xpp = (void *)xp;
-#line 3271
+#line 3323
return status;
-#line 3271
+#line 3323
#endif
-#line 3271
+#line 3323
}
-#line 3271
+#line 3323
int
-#line 3272
+#line 3324
ncx_putn_int_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3272
+#line 3324
{
-#line 3272
+#line 3324
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3272
+#line 3324
-#line 3272
+#line 3324
/* basic algorithm is:
-#line 3272
+#line 3324
* - ensure sane alignment of output data
-#line 3272
+#line 3324
* - copy (conversion happens automatically) input data
-#line 3272
+#line 3324
* to output
-#line 3272
+#line 3324
* - update tp to point at next unconverted input, and xpp to point
-#line 3272
+#line 3324
* at next location for converted output
-#line 3272
+#line 3324
*/
-#line 3272
+#line 3324
long i, j, ni;
-#line 3272
+#line 3324
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3272
+#line 3324
int *xp;
-#line 3272
+#line 3324
int nrange = 0; /* number of range errors */
-#line 3272
+#line 3324
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3272
+#line 3324
long cxp = (long) *((char**)xpp);
-#line 3272
+#line 3324
-#line 3272
+#line 3324
realign = (cxp & 7) % SIZEOF_INT;
-#line 3272
+#line 3324
/* sjl: manually stripmine so we can limit amount of
-#line 3272
+#line 3324
* vector work space reserved to LOOPCNT elements. Also
-#line 3272
+#line 3324
* makes vectorisation easy */
-#line 3272
+#line 3324
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3272
+#line 3324
ni=Min(nelems-j,LOOPCNT);
-#line 3272
+#line 3324
if (realign) {
-#line 3272
+#line 3324
xp = tmp;
-#line 3272
+#line 3324
} else {
-#line 3272
+#line 3324
xp = (int *) *xpp;
-#line 3272
+#line 3324
}
-#line 3272
+#line 3324
/* copy the next block */
-#line 3272
+#line 3324
#pragma cdir loopcnt=LOOPCNT
-#line 3272
+#line 3324
#pragma cdir shortloop
-#line 3272
+#line 3324
for (i=0; i<ni; i++) {
-#line 3272
+#line 3324
/* the normal case: */
-#line 3272
+#line 3324
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3272
+#line 3324
/* test for range errors (not always needed but do it anyway) */
-#line 3272
+#line 3324
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3272
+#line 3324
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3272
+#line 3324
nrange += tp[i] > X_INT_MAX ;
-#line 3272
+#line 3324
}
-#line 3272
+#line 3324
/* copy workspace back if necessary */
-#line 3272
+#line 3324
if (realign) {
-#line 3272
+#line 3324
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3272
+#line 3324
xp = (int *) *xpp;
-#line 3272
+#line 3324
}
-#line 3272
+#line 3324
/* update xpp and tp */
-#line 3272
+#line 3324
xp += ni;
-#line 3272
+#line 3324
tp += ni;
-#line 3272
+#line 3324
*xpp = (void*)xp;
-#line 3272
+#line 3324
}
-#line 3272
+#line 3324
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3272
+#line 3324
-#line 3272
+#line 3324
#else /* not SX */
-#line 3272
+#line 3324
-#line 3272
+#line 3324
char *xp = (char *) *xpp;
-#line 3272
+#line 3324
int status = NC_NOERR;
-#line 3272
+#line 3324
-#line 3272
+#line 3324
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3272
+#line 3324
{
-#line 3272
+#line 3324
int lstatus = ncx_put_int_uint(xp, tp, fillp);
-#line 3272
+#line 3324
if (status == NC_NOERR) /* report the first encountered error */
-#line 3272
+#line 3324
status = lstatus;
-#line 3272
+#line 3324
}
-#line 3272
+#line 3324
-#line 3272
+#line 3324
*xpp = (void *)xp;
-#line 3272
+#line 3324
return status;
-#line 3272
+#line 3324
#endif
-#line 3272
+#line 3324
}
-#line 3272
+#line 3324
int
-#line 3273
+#line 3325
ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3273
+#line 3325
{
-#line 3273
+#line 3325
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT == SIZEOF_INT
-#line 3273
+#line 3325
-#line 3273
+#line 3325
/* basic algorithm is:
-#line 3273
+#line 3325
* - ensure sane alignment of output data
-#line 3273
+#line 3325
* - copy (conversion happens automatically) input data
-#line 3273
+#line 3325
* to output
-#line 3273
+#line 3325
* - update tp to point at next unconverted input, and xpp to point
-#line 3273
+#line 3325
* at next location for converted output
-#line 3273
+#line 3325
*/
-#line 3273
+#line 3325
long i, j, ni;
-#line 3273
+#line 3325
int tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3273
+#line 3325
int *xp;
-#line 3273
+#line 3325
int nrange = 0; /* number of range errors */
-#line 3273
+#line 3325
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3273
+#line 3325
long cxp = (long) *((char**)xpp);
-#line 3273
+#line 3325
-#line 3273
+#line 3325
realign = (cxp & 7) % SIZEOF_INT;
-#line 3273
+#line 3325
/* sjl: manually stripmine so we can limit amount of
-#line 3273
+#line 3325
* vector work space reserved to LOOPCNT elements. Also
-#line 3273
+#line 3325
* makes vectorisation easy */
-#line 3273
+#line 3325
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3273
+#line 3325
ni=Min(nelems-j,LOOPCNT);
-#line 3273
+#line 3325
if (realign) {
-#line 3273
+#line 3325
xp = tmp;
-#line 3273
+#line 3325
} else {
-#line 3273
+#line 3325
xp = (int *) *xpp;
-#line 3273
+#line 3325
}
-#line 3273
+#line 3325
/* copy the next block */
-#line 3273
+#line 3325
#pragma cdir loopcnt=LOOPCNT
-#line 3273
+#line 3325
#pragma cdir shortloop
-#line 3273
+#line 3325
for (i=0; i<ni; i++) {
-#line 3273
+#line 3325
/* the normal case: */
-#line 3273
+#line 3325
xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 3273
+#line 3325
/* test for range errors (not always needed but do it anyway) */
-#line 3273
+#line 3325
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3273
+#line 3325
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3273
+#line 3325
nrange += tp[i] > X_INT_MAX ;
-#line 3273
+#line 3325
}
-#line 3273
+#line 3325
/* copy workspace back if necessary */
-#line 3273
+#line 3325
if (realign) {
-#line 3273
+#line 3325
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT);
-#line 3273
+#line 3325
xp = (int *) *xpp;
-#line 3273
+#line 3325
}
-#line 3273
+#line 3325
/* update xpp and tp */
-#line 3273
+#line 3325
xp += ni;
-#line 3273
+#line 3325
tp += ni;
-#line 3273
+#line 3325
*xpp = (void*)xp;
-#line 3273
+#line 3325
}
-#line 3273
+#line 3325
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3273
+#line 3325
-#line 3273
+#line 3325
#else /* not SX */
-#line 3273
+#line 3325
-#line 3273
+#line 3325
char *xp = (char *) *xpp;
-#line 3273
+#line 3325
int status = NC_NOERR;
-#line 3273
+#line 3325
-#line 3273
+#line 3325
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 3273
+#line 3325
{
-#line 3273
+#line 3325
int lstatus = ncx_put_int_ulonglong(xp, tp, fillp);
-#line 3273
+#line 3325
if (status == NC_NOERR) /* report the first encountered error */
-#line 3273
+#line 3325
status = lstatus;
-#line 3273
+#line 3325
}
-#line 3273
+#line 3325
-#line 3273
+#line 3325
*xpp = (void *)xp;
-#line 3273
+#line 3325
return status;
-#line 3273
+#line 3325
#endif
-#line 3273
+#line 3325
}
-#line 3273
+#line 3325
/* uint ----------------------------------------------------------------------*/
@@ -22400,1424 +24485,1424 @@ ncx_getn_uint_uint(const void **xpp, size_t nelems, unsigned int *tp)
}
#else
int
-#line 3291
+#line 3343
ncx_getn_uint_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3291
+#line 3343
{
-#line 3291
+#line 3343
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3291
+#line 3343
-#line 3291
+#line 3343
/* basic algorithm is:
-#line 3291
+#line 3343
* - ensure sane alignment of input data
-#line 3291
+#line 3343
* - copy (conversion happens automatically) input data
-#line 3291
+#line 3343
* to output
-#line 3291
+#line 3343
* - update xpp to point at next unconverted input, and tp to point
-#line 3291
+#line 3343
* at next location for converted output
-#line 3291
+#line 3343
*/
-#line 3291
+#line 3343
long i, j, ni;
-#line 3291
+#line 3343
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3291
+#line 3343
uint *xp;
-#line 3291
+#line 3343
int nrange = 0; /* number of range errors */
-#line 3291
+#line 3343
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3291
+#line 3343
long cxp = (long) *((char**)xpp);
-#line 3291
+#line 3343
-#line 3291
+#line 3343
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3291
+#line 3343
/* sjl: manually stripmine so we can limit amount of
-#line 3291
+#line 3343
* vector work space reserved to LOOPCNT elements. Also
-#line 3291
+#line 3343
* makes vectorisation easy */
-#line 3291
+#line 3343
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3291
+#line 3343
ni=Min(nelems-j,LOOPCNT);
-#line 3291
+#line 3343
if (realign) {
-#line 3291
+#line 3343
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3291
+#line 3343
xp = tmp;
-#line 3291
+#line 3343
} else {
-#line 3291
+#line 3343
xp = (uint *) *xpp;
-#line 3291
+#line 3343
}
-#line 3291
+#line 3343
/* copy the next block */
-#line 3291
+#line 3343
#pragma cdir loopcnt=LOOPCNT
-#line 3291
+#line 3343
#pragma cdir shortloop
-#line 3291
+#line 3343
for (i=0; i<ni; i++) {
-#line 3291
+#line 3343
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3291
+#line 3343
/* test for range errors (not always needed but do it anyway) */
-#line 3291
+#line 3343
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3291
+#line 3343
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3291
+#line 3343
nrange += xp[i] > UINT_MAX ;
-#line 3291
+#line 3343
}
-#line 3291
+#line 3343
/* update xpp and tp */
-#line 3291
+#line 3343
if (realign) xp = (uint *) *xpp;
-#line 3291
+#line 3343
xp += ni;
-#line 3291
+#line 3343
tp += ni;
-#line 3291
+#line 3343
*xpp = (void*)xp;
-#line 3291
+#line 3343
}
-#line 3291
+#line 3343
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3291
+#line 3343
-#line 3291
+#line 3343
#else /* not SX */
-#line 3291
+#line 3343
const char *xp = (const char *) *xpp;
-#line 3291
+#line 3343
int status = NC_NOERR;
-#line 3291
+#line 3343
-#line 3291
+#line 3343
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3291
+#line 3343
{
-#line 3291
+#line 3343
const int lstatus = ncx_get_uint_uint(xp, tp);
-#line 3291
+#line 3343
if (status == NC_NOERR) /* report the first encountered error */
-#line 3291
+#line 3343
status = lstatus;
-#line 3291
+#line 3343
}
-#line 3291
+#line 3343
-#line 3291
+#line 3343
*xpp = (const void *)xp;
-#line 3291
+#line 3343
return status;
-#line 3291
+#line 3343
#endif
-#line 3291
+#line 3343
}
-#line 3291
+#line 3343
#endif
int
-#line 3293
+#line 3345
ncx_getn_uint_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3293
+#line 3345
{
-#line 3293
+#line 3345
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3293
+#line 3345
-#line 3293
+#line 3345
/* basic algorithm is:
-#line 3293
+#line 3345
* - ensure sane alignment of input data
-#line 3293
+#line 3345
* - copy (conversion happens automatically) input data
-#line 3293
+#line 3345
* to output
-#line 3293
+#line 3345
* - update xpp to point at next unconverted input, and tp to point
-#line 3293
+#line 3345
* at next location for converted output
-#line 3293
+#line 3345
*/
-#line 3293
+#line 3345
long i, j, ni;
-#line 3293
+#line 3345
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3293
+#line 3345
uint *xp;
-#line 3293
+#line 3345
int nrange = 0; /* number of range errors */
-#line 3293
+#line 3345
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3293
+#line 3345
long cxp = (long) *((char**)xpp);
-#line 3293
+#line 3345
-#line 3293
+#line 3345
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3293
+#line 3345
/* sjl: manually stripmine so we can limit amount of
-#line 3293
+#line 3345
* vector work space reserved to LOOPCNT elements. Also
-#line 3293
+#line 3345
* makes vectorisation easy */
-#line 3293
+#line 3345
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3293
+#line 3345
ni=Min(nelems-j,LOOPCNT);
-#line 3293
+#line 3345
if (realign) {
-#line 3293
+#line 3345
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3293
+#line 3345
xp = tmp;
-#line 3293
+#line 3345
} else {
-#line 3293
+#line 3345
xp = (uint *) *xpp;
-#line 3293
+#line 3345
}
-#line 3293
+#line 3345
/* copy the next block */
-#line 3293
+#line 3345
#pragma cdir loopcnt=LOOPCNT
-#line 3293
+#line 3345
#pragma cdir shortloop
-#line 3293
+#line 3345
for (i=0; i<ni; i++) {
-#line 3293
+#line 3345
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3293
+#line 3345
/* test for range errors (not always needed but do it anyway) */
-#line 3293
+#line 3345
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3293
+#line 3345
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3293
+#line 3345
nrange += xp[i] > SCHAR_MAX ;
-#line 3293
+#line 3345
}
-#line 3293
+#line 3345
/* update xpp and tp */
-#line 3293
+#line 3345
if (realign) xp = (uint *) *xpp;
-#line 3293
+#line 3345
xp += ni;
-#line 3293
+#line 3345
tp += ni;
-#line 3293
+#line 3345
*xpp = (void*)xp;
-#line 3293
+#line 3345
}
-#line 3293
+#line 3345
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3293
+#line 3345
-#line 3293
+#line 3345
#else /* not SX */
-#line 3293
+#line 3345
const char *xp = (const char *) *xpp;
-#line 3293
+#line 3345
int status = NC_NOERR;
-#line 3293
+#line 3345
-#line 3293
+#line 3345
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3293
+#line 3345
{
-#line 3293
+#line 3345
const int lstatus = ncx_get_uint_schar(xp, tp);
-#line 3293
+#line 3345
if (status == NC_NOERR) /* report the first encountered error */
-#line 3293
+#line 3345
status = lstatus;
-#line 3293
+#line 3345
}
-#line 3293
+#line 3345
-#line 3293
+#line 3345
*xpp = (const void *)xp;
-#line 3293
+#line 3345
return status;
-#line 3293
+#line 3345
#endif
-#line 3293
+#line 3345
}
-#line 3293
+#line 3345
int
-#line 3294
+#line 3346
ncx_getn_uint_short(const void **xpp, size_t nelems, short *tp)
-#line 3294
+#line 3346
{
-#line 3294
+#line 3346
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3294
+#line 3346
-#line 3294
+#line 3346
/* basic algorithm is:
-#line 3294
+#line 3346
* - ensure sane alignment of input data
-#line 3294
+#line 3346
* - copy (conversion happens automatically) input data
-#line 3294
+#line 3346
* to output
-#line 3294
+#line 3346
* - update xpp to point at next unconverted input, and tp to point
-#line 3294
+#line 3346
* at next location for converted output
-#line 3294
+#line 3346
*/
-#line 3294
+#line 3346
long i, j, ni;
-#line 3294
+#line 3346
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3294
+#line 3346
uint *xp;
-#line 3294
+#line 3346
int nrange = 0; /* number of range errors */
-#line 3294
+#line 3346
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3294
+#line 3346
long cxp = (long) *((char**)xpp);
-#line 3294
+#line 3346
-#line 3294
+#line 3346
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3294
+#line 3346
/* sjl: manually stripmine so we can limit amount of
-#line 3294
+#line 3346
* vector work space reserved to LOOPCNT elements. Also
-#line 3294
+#line 3346
* makes vectorisation easy */
-#line 3294
+#line 3346
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3294
+#line 3346
ni=Min(nelems-j,LOOPCNT);
-#line 3294
+#line 3346
if (realign) {
-#line 3294
+#line 3346
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3294
+#line 3346
xp = tmp;
-#line 3294
+#line 3346
} else {
-#line 3294
+#line 3346
xp = (uint *) *xpp;
-#line 3294
+#line 3346
}
-#line 3294
+#line 3346
/* copy the next block */
-#line 3294
+#line 3346
#pragma cdir loopcnt=LOOPCNT
-#line 3294
+#line 3346
#pragma cdir shortloop
-#line 3294
+#line 3346
for (i=0; i<ni; i++) {
-#line 3294
+#line 3346
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3294
+#line 3346
/* test for range errors (not always needed but do it anyway) */
-#line 3294
+#line 3346
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3294
+#line 3346
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3294
+#line 3346
nrange += xp[i] > SHORT_MAX ;
-#line 3294
+#line 3346
}
-#line 3294
+#line 3346
/* update xpp and tp */
-#line 3294
+#line 3346
if (realign) xp = (uint *) *xpp;
-#line 3294
+#line 3346
xp += ni;
-#line 3294
+#line 3346
tp += ni;
-#line 3294
+#line 3346
*xpp = (void*)xp;
-#line 3294
+#line 3346
}
-#line 3294
+#line 3346
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3294
+#line 3346
-#line 3294
+#line 3346
#else /* not SX */
-#line 3294
+#line 3346
const char *xp = (const char *) *xpp;
-#line 3294
+#line 3346
int status = NC_NOERR;
-#line 3294
+#line 3346
-#line 3294
+#line 3346
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3294
+#line 3346
{
-#line 3294
+#line 3346
const int lstatus = ncx_get_uint_short(xp, tp);
-#line 3294
+#line 3346
if (status == NC_NOERR) /* report the first encountered error */
-#line 3294
+#line 3346
status = lstatus;
-#line 3294
+#line 3346
}
-#line 3294
+#line 3346
-#line 3294
+#line 3346
*xpp = (const void *)xp;
-#line 3294
+#line 3346
return status;
-#line 3294
+#line 3346
#endif
-#line 3294
+#line 3346
}
-#line 3294
+#line 3346
int
-#line 3295
+#line 3347
ncx_getn_uint_int(const void **xpp, size_t nelems, int *tp)
-#line 3295
+#line 3347
{
-#line 3295
+#line 3347
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3295
+#line 3347
-#line 3295
+#line 3347
/* basic algorithm is:
-#line 3295
+#line 3347
* - ensure sane alignment of input data
-#line 3295
+#line 3347
* - copy (conversion happens automatically) input data
-#line 3295
+#line 3347
* to output
-#line 3295
+#line 3347
* - update xpp to point at next unconverted input, and tp to point
-#line 3295
+#line 3347
* at next location for converted output
-#line 3295
+#line 3347
*/
-#line 3295
+#line 3347
long i, j, ni;
-#line 3295
+#line 3347
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3295
+#line 3347
uint *xp;
-#line 3295
+#line 3347
int nrange = 0; /* number of range errors */
-#line 3295
+#line 3347
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3295
+#line 3347
long cxp = (long) *((char**)xpp);
-#line 3295
+#line 3347
-#line 3295
+#line 3347
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3295
+#line 3347
/* sjl: manually stripmine so we can limit amount of
-#line 3295
+#line 3347
* vector work space reserved to LOOPCNT elements. Also
-#line 3295
+#line 3347
* makes vectorisation easy */
-#line 3295
+#line 3347
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3295
+#line 3347
ni=Min(nelems-j,LOOPCNT);
-#line 3295
+#line 3347
if (realign) {
-#line 3295
+#line 3347
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3295
+#line 3347
xp = tmp;
-#line 3295
+#line 3347
} else {
-#line 3295
+#line 3347
xp = (uint *) *xpp;
-#line 3295
+#line 3347
}
-#line 3295
+#line 3347
/* copy the next block */
-#line 3295
+#line 3347
#pragma cdir loopcnt=LOOPCNT
-#line 3295
+#line 3347
#pragma cdir shortloop
-#line 3295
+#line 3347
for (i=0; i<ni; i++) {
-#line 3295
+#line 3347
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3295
+#line 3347
/* test for range errors (not always needed but do it anyway) */
-#line 3295
+#line 3347
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3295
+#line 3347
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3295
+#line 3347
nrange += xp[i] > INT_MAX ;
-#line 3295
+#line 3347
}
-#line 3295
+#line 3347
/* update xpp and tp */
-#line 3295
+#line 3347
if (realign) xp = (uint *) *xpp;
-#line 3295
+#line 3347
xp += ni;
-#line 3295
+#line 3347
tp += ni;
-#line 3295
+#line 3347
*xpp = (void*)xp;
-#line 3295
+#line 3347
}
-#line 3295
+#line 3347
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3295
+#line 3347
-#line 3295
+#line 3347
#else /* not SX */
-#line 3295
+#line 3347
const char *xp = (const char *) *xpp;
-#line 3295
+#line 3347
int status = NC_NOERR;
-#line 3295
+#line 3347
-#line 3295
+#line 3347
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3295
+#line 3347
{
-#line 3295
+#line 3347
const int lstatus = ncx_get_uint_int(xp, tp);
-#line 3295
+#line 3347
if (status == NC_NOERR) /* report the first encountered error */
-#line 3295
+#line 3347
status = lstatus;
-#line 3295
+#line 3347
}
-#line 3295
+#line 3347
-#line 3295
+#line 3347
*xpp = (const void *)xp;
-#line 3295
+#line 3347
return status;
-#line 3295
+#line 3347
#endif
-#line 3295
+#line 3347
}
-#line 3295
+#line 3347
int
-#line 3296
+#line 3348
ncx_getn_uint_long(const void **xpp, size_t nelems, long *tp)
-#line 3296
+#line 3348
{
-#line 3296
+#line 3348
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3296
+#line 3348
-#line 3296
+#line 3348
/* basic algorithm is:
-#line 3296
+#line 3348
* - ensure sane alignment of input data
-#line 3296
+#line 3348
* - copy (conversion happens automatically) input data
-#line 3296
+#line 3348
* to output
-#line 3296
+#line 3348
* - update xpp to point at next unconverted input, and tp to point
-#line 3296
+#line 3348
* at next location for converted output
-#line 3296
+#line 3348
*/
-#line 3296
+#line 3348
long i, j, ni;
-#line 3296
+#line 3348
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3296
+#line 3348
uint *xp;
-#line 3296
+#line 3348
int nrange = 0; /* number of range errors */
-#line 3296
+#line 3348
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3296
+#line 3348
long cxp = (long) *((char**)xpp);
-#line 3296
+#line 3348
-#line 3296
+#line 3348
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3296
+#line 3348
/* sjl: manually stripmine so we can limit amount of
-#line 3296
+#line 3348
* vector work space reserved to LOOPCNT elements. Also
-#line 3296
+#line 3348
* makes vectorisation easy */
-#line 3296
+#line 3348
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3296
+#line 3348
ni=Min(nelems-j,LOOPCNT);
-#line 3296
+#line 3348
if (realign) {
-#line 3296
+#line 3348
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3296
+#line 3348
xp = tmp;
-#line 3296
+#line 3348
} else {
-#line 3296
+#line 3348
xp = (uint *) *xpp;
-#line 3296
+#line 3348
}
-#line 3296
+#line 3348
/* copy the next block */
-#line 3296
+#line 3348
#pragma cdir loopcnt=LOOPCNT
-#line 3296
+#line 3348
#pragma cdir shortloop
-#line 3296
+#line 3348
for (i=0; i<ni; i++) {
-#line 3296
+#line 3348
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3296
+#line 3348
/* test for range errors (not always needed but do it anyway) */
-#line 3296
+#line 3348
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3296
+#line 3348
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3296
+#line 3348
nrange += xp[i] > LONG_MAX ;
-#line 3296
+#line 3348
}
-#line 3296
+#line 3348
/* update xpp and tp */
-#line 3296
+#line 3348
if (realign) xp = (uint *) *xpp;
-#line 3296
+#line 3348
xp += ni;
-#line 3296
+#line 3348
tp += ni;
-#line 3296
+#line 3348
*xpp = (void*)xp;
-#line 3296
+#line 3348
}
-#line 3296
+#line 3348
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3296
+#line 3348
-#line 3296
+#line 3348
#else /* not SX */
-#line 3296
+#line 3348
const char *xp = (const char *) *xpp;
-#line 3296
+#line 3348
int status = NC_NOERR;
-#line 3296
+#line 3348
-#line 3296
+#line 3348
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3296
+#line 3348
{
-#line 3296
+#line 3348
const int lstatus = ncx_get_uint_long(xp, tp);
-#line 3296
+#line 3348
if (status == NC_NOERR) /* report the first encountered error */
-#line 3296
+#line 3348
status = lstatus;
-#line 3296
+#line 3348
}
-#line 3296
+#line 3348
-#line 3296
+#line 3348
*xpp = (const void *)xp;
-#line 3296
+#line 3348
return status;
-#line 3296
+#line 3348
#endif
-#line 3296
+#line 3348
}
-#line 3296
+#line 3348
int
-#line 3297
+#line 3349
ncx_getn_uint_float(const void **xpp, size_t nelems, float *tp)
-#line 3297
+#line 3349
{
-#line 3297
+#line 3349
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3297
+#line 3349
-#line 3297
+#line 3349
/* basic algorithm is:
-#line 3297
+#line 3349
* - ensure sane alignment of input data
-#line 3297
+#line 3349
* - copy (conversion happens automatically) input data
-#line 3297
+#line 3349
* to output
-#line 3297
+#line 3349
* - update xpp to point at next unconverted input, and tp to point
-#line 3297
+#line 3349
* at next location for converted output
-#line 3297
+#line 3349
*/
-#line 3297
+#line 3349
long i, j, ni;
-#line 3297
+#line 3349
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3297
+#line 3349
uint *xp;
-#line 3297
+#line 3349
int nrange = 0; /* number of range errors */
-#line 3297
+#line 3349
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3297
+#line 3349
long cxp = (long) *((char**)xpp);
-#line 3297
+#line 3349
-#line 3297
+#line 3349
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3297
+#line 3349
/* sjl: manually stripmine so we can limit amount of
-#line 3297
+#line 3349
* vector work space reserved to LOOPCNT elements. Also
-#line 3297
+#line 3349
* makes vectorisation easy */
-#line 3297
+#line 3349
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3297
+#line 3349
ni=Min(nelems-j,LOOPCNT);
-#line 3297
+#line 3349
if (realign) {
-#line 3297
+#line 3349
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3297
+#line 3349
xp = tmp;
-#line 3297
+#line 3349
} else {
-#line 3297
+#line 3349
xp = (uint *) *xpp;
-#line 3297
+#line 3349
}
-#line 3297
+#line 3349
/* copy the next block */
-#line 3297
+#line 3349
#pragma cdir loopcnt=LOOPCNT
-#line 3297
+#line 3349
#pragma cdir shortloop
-#line 3297
+#line 3349
for (i=0; i<ni; i++) {
-#line 3297
+#line 3349
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3297
+#line 3349
/* test for range errors (not always needed but do it anyway) */
-#line 3297
+#line 3349
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3297
+#line 3349
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3297
+#line 3349
nrange += xp[i] > FLOAT_MAX ;
-#line 3297
+#line 3349
}
-#line 3297
+#line 3349
/* update xpp and tp */
-#line 3297
+#line 3349
if (realign) xp = (uint *) *xpp;
-#line 3297
+#line 3349
xp += ni;
-#line 3297
+#line 3349
tp += ni;
-#line 3297
+#line 3349
*xpp = (void*)xp;
-#line 3297
+#line 3349
}
-#line 3297
+#line 3349
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3297
+#line 3349
-#line 3297
+#line 3349
#else /* not SX */
-#line 3297
+#line 3349
const char *xp = (const char *) *xpp;
-#line 3297
+#line 3349
int status = NC_NOERR;
-#line 3297
+#line 3349
-#line 3297
+#line 3349
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3297
+#line 3349
{
-#line 3297
+#line 3349
const int lstatus = ncx_get_uint_float(xp, tp);
-#line 3297
+#line 3349
if (status == NC_NOERR) /* report the first encountered error */
-#line 3297
+#line 3349
status = lstatus;
-#line 3297
+#line 3349
}
-#line 3297
+#line 3349
-#line 3297
+#line 3349
*xpp = (const void *)xp;
-#line 3297
+#line 3349
return status;
-#line 3297
+#line 3349
#endif
-#line 3297
+#line 3349
}
-#line 3297
+#line 3349
int
-#line 3298
+#line 3350
ncx_getn_uint_double(const void **xpp, size_t nelems, double *tp)
-#line 3298
+#line 3350
{
-#line 3298
+#line 3350
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3298
+#line 3350
-#line 3298
+#line 3350
/* basic algorithm is:
-#line 3298
+#line 3350
* - ensure sane alignment of input data
-#line 3298
+#line 3350
* - copy (conversion happens automatically) input data
-#line 3298
+#line 3350
* to output
-#line 3298
+#line 3350
* - update xpp to point at next unconverted input, and tp to point
-#line 3298
+#line 3350
* at next location for converted output
-#line 3298
+#line 3350
*/
-#line 3298
+#line 3350
long i, j, ni;
-#line 3298
+#line 3350
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3298
+#line 3350
uint *xp;
-#line 3298
+#line 3350
int nrange = 0; /* number of range errors */
-#line 3298
+#line 3350
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3298
+#line 3350
long cxp = (long) *((char**)xpp);
-#line 3298
+#line 3350
-#line 3298
+#line 3350
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3298
+#line 3350
/* sjl: manually stripmine so we can limit amount of
-#line 3298
+#line 3350
* vector work space reserved to LOOPCNT elements. Also
-#line 3298
+#line 3350
* makes vectorisation easy */
-#line 3298
+#line 3350
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3298
+#line 3350
ni=Min(nelems-j,LOOPCNT);
-#line 3298
+#line 3350
if (realign) {
-#line 3298
+#line 3350
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3298
+#line 3350
xp = tmp;
-#line 3298
+#line 3350
} else {
-#line 3298
+#line 3350
xp = (uint *) *xpp;
-#line 3298
+#line 3350
}
-#line 3298
+#line 3350
/* copy the next block */
-#line 3298
+#line 3350
#pragma cdir loopcnt=LOOPCNT
-#line 3298
+#line 3350
#pragma cdir shortloop
-#line 3298
+#line 3350
for (i=0; i<ni; i++) {
-#line 3298
+#line 3350
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3298
+#line 3350
/* test for range errors (not always needed but do it anyway) */
-#line 3298
+#line 3350
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3298
+#line 3350
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3298
+#line 3350
nrange += xp[i] > DOUBLE_MAX ;
-#line 3298
+#line 3350
}
-#line 3298
+#line 3350
/* update xpp and tp */
-#line 3298
+#line 3350
if (realign) xp = (uint *) *xpp;
-#line 3298
+#line 3350
xp += ni;
-#line 3298
+#line 3350
tp += ni;
-#line 3298
+#line 3350
*xpp = (void*)xp;
-#line 3298
+#line 3350
}
-#line 3298
+#line 3350
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3298
+#line 3350
-#line 3298
+#line 3350
#else /* not SX */
-#line 3298
+#line 3350
const char *xp = (const char *) *xpp;
-#line 3298
+#line 3350
int status = NC_NOERR;
-#line 3298
+#line 3350
-#line 3298
+#line 3350
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3298
+#line 3350
{
-#line 3298
+#line 3350
const int lstatus = ncx_get_uint_double(xp, tp);
-#line 3298
+#line 3350
if (status == NC_NOERR) /* report the first encountered error */
-#line 3298
+#line 3350
status = lstatus;
-#line 3298
+#line 3350
}
-#line 3298
+#line 3350
-#line 3298
+#line 3350
*xpp = (const void *)xp;
-#line 3298
+#line 3350
return status;
-#line 3298
+#line 3350
#endif
-#line 3298
+#line 3350
}
-#line 3298
+#line 3350
int
-#line 3299
+#line 3351
ncx_getn_uint_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3299
+#line 3351
{
-#line 3299
+#line 3351
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3299
+#line 3351
-#line 3299
+#line 3351
/* basic algorithm is:
-#line 3299
+#line 3351
* - ensure sane alignment of input data
-#line 3299
+#line 3351
* - copy (conversion happens automatically) input data
-#line 3299
+#line 3351
* to output
-#line 3299
+#line 3351
* - update xpp to point at next unconverted input, and tp to point
-#line 3299
+#line 3351
* at next location for converted output
-#line 3299
+#line 3351
*/
-#line 3299
+#line 3351
long i, j, ni;
-#line 3299
+#line 3351
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3299
+#line 3351
uint *xp;
-#line 3299
+#line 3351
int nrange = 0; /* number of range errors */
-#line 3299
+#line 3351
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3299
+#line 3351
long cxp = (long) *((char**)xpp);
-#line 3299
+#line 3351
-#line 3299
+#line 3351
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3299
+#line 3351
/* sjl: manually stripmine so we can limit amount of
-#line 3299
+#line 3351
* vector work space reserved to LOOPCNT elements. Also
-#line 3299
+#line 3351
* makes vectorisation easy */
-#line 3299
+#line 3351
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3299
+#line 3351
ni=Min(nelems-j,LOOPCNT);
-#line 3299
+#line 3351
if (realign) {
-#line 3299
+#line 3351
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3299
+#line 3351
xp = tmp;
-#line 3299
+#line 3351
} else {
-#line 3299
+#line 3351
xp = (uint *) *xpp;
-#line 3299
+#line 3351
}
-#line 3299
+#line 3351
/* copy the next block */
-#line 3299
+#line 3351
#pragma cdir loopcnt=LOOPCNT
-#line 3299
+#line 3351
#pragma cdir shortloop
-#line 3299
+#line 3351
for (i=0; i<ni; i++) {
-#line 3299
+#line 3351
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3299
+#line 3351
/* test for range errors (not always needed but do it anyway) */
-#line 3299
+#line 3351
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3299
+#line 3351
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3299
+#line 3351
nrange += xp[i] > LONGLONG_MAX ;
-#line 3299
+#line 3351
}
-#line 3299
+#line 3351
/* update xpp and tp */
-#line 3299
+#line 3351
if (realign) xp = (uint *) *xpp;
-#line 3299
+#line 3351
xp += ni;
-#line 3299
+#line 3351
tp += ni;
-#line 3299
+#line 3351
*xpp = (void*)xp;
-#line 3299
+#line 3351
}
-#line 3299
+#line 3351
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3299
+#line 3351
-#line 3299
+#line 3351
#else /* not SX */
-#line 3299
+#line 3351
const char *xp = (const char *) *xpp;
-#line 3299
+#line 3351
int status = NC_NOERR;
-#line 3299
+#line 3351
-#line 3299
+#line 3351
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3299
+#line 3351
{
-#line 3299
+#line 3351
const int lstatus = ncx_get_uint_longlong(xp, tp);
-#line 3299
+#line 3351
if (status == NC_NOERR) /* report the first encountered error */
-#line 3299
+#line 3351
status = lstatus;
-#line 3299
+#line 3351
}
-#line 3299
+#line 3351
-#line 3299
+#line 3351
*xpp = (const void *)xp;
-#line 3299
+#line 3351
return status;
-#line 3299
+#line 3351
#endif
-#line 3299
+#line 3351
}
-#line 3299
+#line 3351
int
-#line 3300
+#line 3352
ncx_getn_uint_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3300
+#line 3352
{
-#line 3300
+#line 3352
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3300
+#line 3352
-#line 3300
+#line 3352
/* basic algorithm is:
-#line 3300
+#line 3352
* - ensure sane alignment of input data
-#line 3300
+#line 3352
* - copy (conversion happens automatically) input data
-#line 3300
+#line 3352
* to output
-#line 3300
+#line 3352
* - update xpp to point at next unconverted input, and tp to point
-#line 3300
+#line 3352
* at next location for converted output
-#line 3300
+#line 3352
*/
-#line 3300
+#line 3352
long i, j, ni;
-#line 3300
+#line 3352
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3300
+#line 3352
uint *xp;
-#line 3300
+#line 3352
int nrange = 0; /* number of range errors */
-#line 3300
+#line 3352
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3300
+#line 3352
long cxp = (long) *((char**)xpp);
-#line 3300
+#line 3352
-#line 3300
+#line 3352
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3300
+#line 3352
/* sjl: manually stripmine so we can limit amount of
-#line 3300
+#line 3352
* vector work space reserved to LOOPCNT elements. Also
-#line 3300
+#line 3352
* makes vectorisation easy */
-#line 3300
+#line 3352
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3300
+#line 3352
ni=Min(nelems-j,LOOPCNT);
-#line 3300
+#line 3352
if (realign) {
-#line 3300
+#line 3352
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3300
+#line 3352
xp = tmp;
-#line 3300
+#line 3352
} else {
-#line 3300
+#line 3352
xp = (uint *) *xpp;
-#line 3300
+#line 3352
}
-#line 3300
+#line 3352
/* copy the next block */
-#line 3300
+#line 3352
#pragma cdir loopcnt=LOOPCNT
-#line 3300
+#line 3352
#pragma cdir shortloop
-#line 3300
+#line 3352
for (i=0; i<ni; i++) {
-#line 3300
+#line 3352
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3300
+#line 3352
/* test for range errors (not always needed but do it anyway) */
-#line 3300
+#line 3352
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3300
+#line 3352
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3300
+#line 3352
nrange += xp[i] > UCHAR_MAX ;
-#line 3300
+#line 3352
}
-#line 3300
+#line 3352
/* update xpp and tp */
-#line 3300
+#line 3352
if (realign) xp = (uint *) *xpp;
-#line 3300
+#line 3352
xp += ni;
-#line 3300
+#line 3352
tp += ni;
-#line 3300
+#line 3352
*xpp = (void*)xp;
-#line 3300
+#line 3352
}
-#line 3300
+#line 3352
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3300
+#line 3352
-#line 3300
+#line 3352
#else /* not SX */
-#line 3300
+#line 3352
const char *xp = (const char *) *xpp;
-#line 3300
+#line 3352
int status = NC_NOERR;
-#line 3300
+#line 3352
-#line 3300
+#line 3352
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3300
+#line 3352
{
-#line 3300
+#line 3352
const int lstatus = ncx_get_uint_uchar(xp, tp);
-#line 3300
+#line 3352
if (status == NC_NOERR) /* report the first encountered error */
-#line 3300
+#line 3352
status = lstatus;
-#line 3300
+#line 3352
}
-#line 3300
+#line 3352
-#line 3300
+#line 3352
*xpp = (const void *)xp;
-#line 3300
+#line 3352
return status;
-#line 3300
+#line 3352
#endif
-#line 3300
+#line 3352
}
-#line 3300
+#line 3352
int
-#line 3301
+#line 3353
ncx_getn_uint_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3301
+#line 3353
{
-#line 3301
+#line 3353
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3301
+#line 3353
-#line 3301
+#line 3353
/* basic algorithm is:
-#line 3301
+#line 3353
* - ensure sane alignment of input data
-#line 3301
+#line 3353
* - copy (conversion happens automatically) input data
-#line 3301
+#line 3353
* to output
-#line 3301
+#line 3353
* - update xpp to point at next unconverted input, and tp to point
-#line 3301
+#line 3353
* at next location for converted output
-#line 3301
+#line 3353
*/
-#line 3301
+#line 3353
long i, j, ni;
-#line 3301
+#line 3353
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3301
+#line 3353
uint *xp;
-#line 3301
+#line 3353
int nrange = 0; /* number of range errors */
-#line 3301
+#line 3353
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3301
+#line 3353
long cxp = (long) *((char**)xpp);
-#line 3301
+#line 3353
-#line 3301
+#line 3353
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3301
+#line 3353
/* sjl: manually stripmine so we can limit amount of
-#line 3301
+#line 3353
* vector work space reserved to LOOPCNT elements. Also
-#line 3301
+#line 3353
* makes vectorisation easy */
-#line 3301
+#line 3353
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3301
+#line 3353
ni=Min(nelems-j,LOOPCNT);
-#line 3301
+#line 3353
if (realign) {
-#line 3301
+#line 3353
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3301
+#line 3353
xp = tmp;
-#line 3301
+#line 3353
} else {
-#line 3301
+#line 3353
xp = (uint *) *xpp;
-#line 3301
+#line 3353
}
-#line 3301
+#line 3353
/* copy the next block */
-#line 3301
+#line 3353
#pragma cdir loopcnt=LOOPCNT
-#line 3301
+#line 3353
#pragma cdir shortloop
-#line 3301
+#line 3353
for (i=0; i<ni; i++) {
-#line 3301
+#line 3353
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3301
+#line 3353
/* test for range errors (not always needed but do it anyway) */
-#line 3301
+#line 3353
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3301
+#line 3353
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3301
+#line 3353
nrange += xp[i] > USHORT_MAX ;
-#line 3301
+#line 3353
}
-#line 3301
+#line 3353
/* update xpp and tp */
-#line 3301
+#line 3353
if (realign) xp = (uint *) *xpp;
-#line 3301
+#line 3353
xp += ni;
-#line 3301
+#line 3353
tp += ni;
-#line 3301
+#line 3353
*xpp = (void*)xp;
-#line 3301
+#line 3353
}
-#line 3301
+#line 3353
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3301
+#line 3353
-#line 3301
+#line 3353
#else /* not SX */
-#line 3301
+#line 3353
const char *xp = (const char *) *xpp;
-#line 3301
+#line 3353
int status = NC_NOERR;
-#line 3301
+#line 3353
-#line 3301
+#line 3353
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3301
+#line 3353
{
-#line 3301
+#line 3353
const int lstatus = ncx_get_uint_ushort(xp, tp);
-#line 3301
+#line 3353
if (status == NC_NOERR) /* report the first encountered error */
-#line 3301
+#line 3353
status = lstatus;
-#line 3301
+#line 3353
}
-#line 3301
+#line 3353
-#line 3301
+#line 3353
*xpp = (const void *)xp;
-#line 3301
+#line 3353
return status;
-#line 3301
+#line 3353
#endif
-#line 3301
+#line 3353
}
-#line 3301
+#line 3353
int
-#line 3302
+#line 3354
ncx_getn_uint_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3302
+#line 3354
{
-#line 3302
+#line 3354
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3302
+#line 3354
-#line 3302
+#line 3354
/* basic algorithm is:
-#line 3302
+#line 3354
* - ensure sane alignment of input data
-#line 3302
+#line 3354
* - copy (conversion happens automatically) input data
-#line 3302
+#line 3354
* to output
-#line 3302
+#line 3354
* - update xpp to point at next unconverted input, and tp to point
-#line 3302
+#line 3354
* at next location for converted output
-#line 3302
+#line 3354
*/
-#line 3302
+#line 3354
long i, j, ni;
-#line 3302
+#line 3354
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3302
+#line 3354
uint *xp;
-#line 3302
+#line 3354
int nrange = 0; /* number of range errors */
-#line 3302
+#line 3354
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3302
+#line 3354
long cxp = (long) *((char**)xpp);
-#line 3302
+#line 3354
-#line 3302
+#line 3354
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3302
+#line 3354
/* sjl: manually stripmine so we can limit amount of
-#line 3302
+#line 3354
* vector work space reserved to LOOPCNT elements. Also
-#line 3302
+#line 3354
* makes vectorisation easy */
-#line 3302
+#line 3354
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3302
+#line 3354
ni=Min(nelems-j,LOOPCNT);
-#line 3302
+#line 3354
if (realign) {
-#line 3302
+#line 3354
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT));
-#line 3302
+#line 3354
xp = tmp;
-#line 3302
+#line 3354
} else {
-#line 3302
+#line 3354
xp = (uint *) *xpp;
-#line 3302
+#line 3354
}
-#line 3302
+#line 3354
/* copy the next block */
-#line 3302
+#line 3354
#pragma cdir loopcnt=LOOPCNT
-#line 3302
+#line 3354
#pragma cdir shortloop
-#line 3302
+#line 3354
for (i=0; i<ni; i++) {
-#line 3302
+#line 3354
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3302
+#line 3354
/* test for range errors (not always needed but do it anyway) */
-#line 3302
+#line 3354
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3302
+#line 3354
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3302
+#line 3354
nrange += xp[i] > ULONGLONG_MAX ;
-#line 3302
+#line 3354
}
-#line 3302
+#line 3354
/* update xpp and tp */
-#line 3302
+#line 3354
if (realign) xp = (uint *) *xpp;
-#line 3302
+#line 3354
xp += ni;
-#line 3302
+#line 3354
tp += ni;
-#line 3302
+#line 3354
*xpp = (void*)xp;
-#line 3302
+#line 3354
}
-#line 3302
+#line 3354
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3302
+#line 3354
-#line 3302
+#line 3354
#else /* not SX */
-#line 3302
+#line 3354
const char *xp = (const char *) *xpp;
-#line 3302
+#line 3354
int status = NC_NOERR;
-#line 3302
+#line 3354
-#line 3302
+#line 3354
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3302
+#line 3354
{
-#line 3302
+#line 3354
const int lstatus = ncx_get_uint_ulonglong(xp, tp);
-#line 3302
+#line 3354
if (status == NC_NOERR) /* report the first encountered error */
-#line 3302
+#line 3354
status = lstatus;
-#line 3302
+#line 3354
}
-#line 3302
+#line 3354
-#line 3302
+#line 3354
*xpp = (const void *)xp;
-#line 3302
+#line 3354
return status;
-#line 3302
+#line 3354
#endif
-#line 3302
+#line 3354
}
-#line 3302
+#line 3354
#if X_SIZEOF_UINT == SIZEOF_UINT
@@ -23835,1534 +25920,1534 @@ ncx_putn_uint_uint(void **xpp, size_t nelems, const unsigned int *tp, void *fill
}
#else
int
-#line 3318
+#line 3370
ncx_putn_uint_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3318
+#line 3370
{
-#line 3318
+#line 3370
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3318
+#line 3370
-#line 3318
+#line 3370
/* basic algorithm is:
-#line 3318
+#line 3370
* - ensure sane alignment of output data
-#line 3318
+#line 3370
* - copy (conversion happens automatically) input data
-#line 3318
+#line 3370
* to output
-#line 3318
+#line 3370
* - update tp to point at next unconverted input, and xpp to point
-#line 3318
+#line 3370
* at next location for converted output
-#line 3318
+#line 3370
*/
-#line 3318
+#line 3370
long i, j, ni;
-#line 3318
+#line 3370
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3318
+#line 3370
uint *xp;
-#line 3318
+#line 3370
int nrange = 0; /* number of range errors */
-#line 3318
+#line 3370
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3318
+#line 3370
long cxp = (long) *((char**)xpp);
-#line 3318
+#line 3370
-#line 3318
+#line 3370
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3318
+#line 3370
/* sjl: manually stripmine so we can limit amount of
-#line 3318
+#line 3370
* vector work space reserved to LOOPCNT elements. Also
-#line 3318
+#line 3370
* makes vectorisation easy */
-#line 3318
+#line 3370
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3318
+#line 3370
ni=Min(nelems-j,LOOPCNT);
-#line 3318
+#line 3370
if (realign) {
-#line 3318
+#line 3370
xp = tmp;
-#line 3318
+#line 3370
} else {
-#line 3318
+#line 3370
xp = (uint *) *xpp;
-#line 3318
+#line 3370
}
-#line 3318
+#line 3370
/* copy the next block */
-#line 3318
+#line 3370
#pragma cdir loopcnt=LOOPCNT
-#line 3318
+#line 3370
#pragma cdir shortloop
-#line 3318
+#line 3370
for (i=0; i<ni; i++) {
-#line 3318
+#line 3370
/* the normal case: */
-#line 3318
+#line 3370
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3318
+#line 3370
/* test for range errors (not always needed but do it anyway) */
-#line 3318
+#line 3370
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3318
+#line 3370
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3318
+#line 3370
nrange += tp[i] > X_UINT_MAX ;
-#line 3318
+#line 3370
}
-#line 3318
+#line 3370
/* copy workspace back if necessary */
-#line 3318
+#line 3370
if (realign) {
-#line 3318
+#line 3370
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3318
+#line 3370
xp = (uint *) *xpp;
-#line 3318
+#line 3370
}
-#line 3318
+#line 3370
/* update xpp and tp */
-#line 3318
+#line 3370
xp += ni;
-#line 3318
+#line 3370
tp += ni;
-#line 3318
+#line 3370
*xpp = (void*)xp;
-#line 3318
+#line 3370
}
-#line 3318
+#line 3370
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3318
+#line 3370
-#line 3318
+#line 3370
#else /* not SX */
-#line 3318
+#line 3370
-#line 3318
+#line 3370
char *xp = (char *) *xpp;
-#line 3318
+#line 3370
int status = NC_NOERR;
-#line 3318
+#line 3370
-#line 3318
+#line 3370
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3318
+#line 3370
{
-#line 3318
+#line 3370
int lstatus = ncx_put_uint_uint(xp, tp, fillp);
-#line 3318
+#line 3370
if (status == NC_NOERR) /* report the first encountered error */
-#line 3318
+#line 3370
status = lstatus;
-#line 3318
+#line 3370
}
-#line 3318
+#line 3370
-#line 3318
+#line 3370
*xpp = (void *)xp;
-#line 3318
+#line 3370
return status;
-#line 3318
+#line 3370
#endif
-#line 3318
+#line 3370
}
-#line 3318
+#line 3370
#endif
int
-#line 3320
+#line 3372
ncx_putn_uint_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3320
+#line 3372
{
-#line 3320
+#line 3372
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3320
+#line 3372
-#line 3320
+#line 3372
/* basic algorithm is:
-#line 3320
+#line 3372
* - ensure sane alignment of output data
-#line 3320
+#line 3372
* - copy (conversion happens automatically) input data
-#line 3320
+#line 3372
* to output
-#line 3320
+#line 3372
* - update tp to point at next unconverted input, and xpp to point
-#line 3320
+#line 3372
* at next location for converted output
-#line 3320
+#line 3372
*/
-#line 3320
+#line 3372
long i, j, ni;
-#line 3320
+#line 3372
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3320
+#line 3372
uint *xp;
-#line 3320
+#line 3372
int nrange = 0; /* number of range errors */
-#line 3320
+#line 3372
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3320
+#line 3372
long cxp = (long) *((char**)xpp);
-#line 3320
+#line 3372
-#line 3320
+#line 3372
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3320
+#line 3372
/* sjl: manually stripmine so we can limit amount of
-#line 3320
+#line 3372
* vector work space reserved to LOOPCNT elements. Also
-#line 3320
+#line 3372
* makes vectorisation easy */
-#line 3320
+#line 3372
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3320
+#line 3372
ni=Min(nelems-j,LOOPCNT);
-#line 3320
+#line 3372
if (realign) {
-#line 3320
+#line 3372
xp = tmp;
-#line 3320
+#line 3372
} else {
-#line 3320
+#line 3372
xp = (uint *) *xpp;
-#line 3320
+#line 3372
}
-#line 3320
+#line 3372
/* copy the next block */
-#line 3320
+#line 3372
#pragma cdir loopcnt=LOOPCNT
-#line 3320
+#line 3372
#pragma cdir shortloop
-#line 3320
+#line 3372
for (i=0; i<ni; i++) {
-#line 3320
+#line 3372
/* the normal case: */
-#line 3320
+#line 3372
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3320
+#line 3372
/* test for range errors (not always needed but do it anyway) */
-#line 3320
+#line 3372
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3320
+#line 3372
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3320
+#line 3372
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3320
+#line 3372
}
-#line 3320
+#line 3372
/* copy workspace back if necessary */
-#line 3320
+#line 3372
if (realign) {
-#line 3320
+#line 3372
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3320
+#line 3372
xp = (uint *) *xpp;
-#line 3320
+#line 3372
}
-#line 3320
+#line 3372
/* update xpp and tp */
-#line 3320
+#line 3372
xp += ni;
-#line 3320
+#line 3372
tp += ni;
-#line 3320
+#line 3372
*xpp = (void*)xp;
-#line 3320
+#line 3372
}
-#line 3320
+#line 3372
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3320
+#line 3372
-#line 3320
+#line 3372
#else /* not SX */
-#line 3320
+#line 3372
-#line 3320
+#line 3372
char *xp = (char *) *xpp;
-#line 3320
+#line 3372
int status = NC_NOERR;
-#line 3320
+#line 3372
-#line 3320
+#line 3372
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3320
+#line 3372
{
-#line 3320
+#line 3372
int lstatus = ncx_put_uint_schar(xp, tp, fillp);
-#line 3320
+#line 3372
if (status == NC_NOERR) /* report the first encountered error */
-#line 3320
+#line 3372
status = lstatus;
-#line 3320
+#line 3372
}
-#line 3320
+#line 3372
-#line 3320
+#line 3372
*xpp = (void *)xp;
-#line 3320
+#line 3372
return status;
-#line 3320
+#line 3372
#endif
-#line 3320
+#line 3372
}
-#line 3320
+#line 3372
int
-#line 3321
+#line 3373
ncx_putn_uint_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3321
+#line 3373
{
-#line 3321
+#line 3373
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3321
+#line 3373
-#line 3321
+#line 3373
/* basic algorithm is:
-#line 3321
+#line 3373
* - ensure sane alignment of output data
-#line 3321
+#line 3373
* - copy (conversion happens automatically) input data
-#line 3321
+#line 3373
* to output
-#line 3321
+#line 3373
* - update tp to point at next unconverted input, and xpp to point
-#line 3321
+#line 3373
* at next location for converted output
-#line 3321
+#line 3373
*/
-#line 3321
+#line 3373
long i, j, ni;
-#line 3321
+#line 3373
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3321
+#line 3373
uint *xp;
-#line 3321
+#line 3373
int nrange = 0; /* number of range errors */
-#line 3321
+#line 3373
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3321
+#line 3373
long cxp = (long) *((char**)xpp);
-#line 3321
+#line 3373
-#line 3321
+#line 3373
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3321
+#line 3373
/* sjl: manually stripmine so we can limit amount of
-#line 3321
+#line 3373
* vector work space reserved to LOOPCNT elements. Also
-#line 3321
+#line 3373
* makes vectorisation easy */
-#line 3321
+#line 3373
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3321
+#line 3373
ni=Min(nelems-j,LOOPCNT);
-#line 3321
+#line 3373
if (realign) {
-#line 3321
+#line 3373
xp = tmp;
-#line 3321
+#line 3373
} else {
-#line 3321
+#line 3373
xp = (uint *) *xpp;
-#line 3321
+#line 3373
}
-#line 3321
+#line 3373
/* copy the next block */
-#line 3321
+#line 3373
#pragma cdir loopcnt=LOOPCNT
-#line 3321
+#line 3373
#pragma cdir shortloop
-#line 3321
+#line 3373
for (i=0; i<ni; i++) {
-#line 3321
+#line 3373
/* the normal case: */
-#line 3321
+#line 3373
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3321
+#line 3373
/* test for range errors (not always needed but do it anyway) */
-#line 3321
+#line 3373
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3321
+#line 3373
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3321
+#line 3373
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3321
+#line 3373
}
-#line 3321
+#line 3373
/* copy workspace back if necessary */
-#line 3321
+#line 3373
if (realign) {
-#line 3321
+#line 3373
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3321
+#line 3373
xp = (uint *) *xpp;
-#line 3321
+#line 3373
}
-#line 3321
+#line 3373
/* update xpp and tp */
-#line 3321
+#line 3373
xp += ni;
-#line 3321
+#line 3373
tp += ni;
-#line 3321
+#line 3373
*xpp = (void*)xp;
-#line 3321
+#line 3373
}
-#line 3321
+#line 3373
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3321
+#line 3373
-#line 3321
+#line 3373
#else /* not SX */
-#line 3321
+#line 3373
-#line 3321
+#line 3373
char *xp = (char *) *xpp;
-#line 3321
+#line 3373
int status = NC_NOERR;
-#line 3321
+#line 3373
-#line 3321
+#line 3373
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3321
+#line 3373
{
-#line 3321
+#line 3373
int lstatus = ncx_put_uint_short(xp, tp, fillp);
-#line 3321
+#line 3373
if (status == NC_NOERR) /* report the first encountered error */
-#line 3321
+#line 3373
status = lstatus;
-#line 3321
+#line 3373
}
-#line 3321
+#line 3373
-#line 3321
+#line 3373
*xpp = (void *)xp;
-#line 3321
+#line 3373
return status;
-#line 3321
+#line 3373
#endif
-#line 3321
+#line 3373
}
-#line 3321
+#line 3373
int
-#line 3322
+#line 3374
ncx_putn_uint_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3322
+#line 3374
{
-#line 3322
+#line 3374
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3322
+#line 3374
-#line 3322
+#line 3374
/* basic algorithm is:
-#line 3322
+#line 3374
* - ensure sane alignment of output data
-#line 3322
+#line 3374
* - copy (conversion happens automatically) input data
-#line 3322
+#line 3374
* to output
-#line 3322
+#line 3374
* - update tp to point at next unconverted input, and xpp to point
-#line 3322
+#line 3374
* at next location for converted output
-#line 3322
+#line 3374
*/
-#line 3322
+#line 3374
long i, j, ni;
-#line 3322
+#line 3374
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3322
+#line 3374
uint *xp;
-#line 3322
+#line 3374
int nrange = 0; /* number of range errors */
-#line 3322
+#line 3374
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3322
+#line 3374
long cxp = (long) *((char**)xpp);
-#line 3322
+#line 3374
-#line 3322
+#line 3374
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3322
+#line 3374
/* sjl: manually stripmine so we can limit amount of
-#line 3322
+#line 3374
* vector work space reserved to LOOPCNT elements. Also
-#line 3322
+#line 3374
* makes vectorisation easy */
-#line 3322
+#line 3374
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3322
+#line 3374
ni=Min(nelems-j,LOOPCNT);
-#line 3322
+#line 3374
if (realign) {
-#line 3322
+#line 3374
xp = tmp;
-#line 3322
+#line 3374
} else {
-#line 3322
+#line 3374
xp = (uint *) *xpp;
-#line 3322
+#line 3374
}
-#line 3322
+#line 3374
/* copy the next block */
-#line 3322
+#line 3374
#pragma cdir loopcnt=LOOPCNT
-#line 3322
+#line 3374
#pragma cdir shortloop
-#line 3322
+#line 3374
for (i=0; i<ni; i++) {
-#line 3322
+#line 3374
/* the normal case: */
-#line 3322
+#line 3374
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3322
+#line 3374
/* test for range errors (not always needed but do it anyway) */
-#line 3322
+#line 3374
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3322
+#line 3374
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3322
+#line 3374
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3322
+#line 3374
}
-#line 3322
+#line 3374
/* copy workspace back if necessary */
-#line 3322
+#line 3374
if (realign) {
-#line 3322
+#line 3374
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3322
+#line 3374
xp = (uint *) *xpp;
-#line 3322
+#line 3374
}
-#line 3322
+#line 3374
/* update xpp and tp */
-#line 3322
+#line 3374
xp += ni;
-#line 3322
+#line 3374
tp += ni;
-#line 3322
+#line 3374
*xpp = (void*)xp;
-#line 3322
+#line 3374
}
-#line 3322
+#line 3374
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3322
+#line 3374
-#line 3322
+#line 3374
#else /* not SX */
-#line 3322
+#line 3374
-#line 3322
+#line 3374
char *xp = (char *) *xpp;
-#line 3322
+#line 3374
int status = NC_NOERR;
-#line 3322
+#line 3374
-#line 3322
+#line 3374
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3322
+#line 3374
{
-#line 3322
+#line 3374
int lstatus = ncx_put_uint_int(xp, tp, fillp);
-#line 3322
+#line 3374
if (status == NC_NOERR) /* report the first encountered error */
-#line 3322
+#line 3374
status = lstatus;
-#line 3322
+#line 3374
}
-#line 3322
+#line 3374
-#line 3322
+#line 3374
*xpp = (void *)xp;
-#line 3322
+#line 3374
return status;
-#line 3322
+#line 3374
#endif
-#line 3322
+#line 3374
}
-#line 3322
+#line 3374
int
-#line 3323
+#line 3375
ncx_putn_uint_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3323
+#line 3375
{
-#line 3323
+#line 3375
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3323
+#line 3375
-#line 3323
+#line 3375
/* basic algorithm is:
-#line 3323
+#line 3375
* - ensure sane alignment of output data
-#line 3323
+#line 3375
* - copy (conversion happens automatically) input data
-#line 3323
+#line 3375
* to output
-#line 3323
+#line 3375
* - update tp to point at next unconverted input, and xpp to point
-#line 3323
+#line 3375
* at next location for converted output
-#line 3323
+#line 3375
*/
-#line 3323
+#line 3375
long i, j, ni;
-#line 3323
+#line 3375
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3323
+#line 3375
uint *xp;
-#line 3323
+#line 3375
int nrange = 0; /* number of range errors */
-#line 3323
+#line 3375
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3323
+#line 3375
long cxp = (long) *((char**)xpp);
-#line 3323
+#line 3375
-#line 3323
+#line 3375
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3323
+#line 3375
/* sjl: manually stripmine so we can limit amount of
-#line 3323
+#line 3375
* vector work space reserved to LOOPCNT elements. Also
-#line 3323
+#line 3375
* makes vectorisation easy */
-#line 3323
+#line 3375
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3323
+#line 3375
ni=Min(nelems-j,LOOPCNT);
-#line 3323
+#line 3375
if (realign) {
-#line 3323
+#line 3375
xp = tmp;
-#line 3323
+#line 3375
} else {
-#line 3323
+#line 3375
xp = (uint *) *xpp;
-#line 3323
+#line 3375
}
-#line 3323
+#line 3375
/* copy the next block */
-#line 3323
+#line 3375
#pragma cdir loopcnt=LOOPCNT
-#line 3323
+#line 3375
#pragma cdir shortloop
-#line 3323
+#line 3375
for (i=0; i<ni; i++) {
-#line 3323
+#line 3375
/* the normal case: */
-#line 3323
+#line 3375
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3323
+#line 3375
/* test for range errors (not always needed but do it anyway) */
-#line 3323
+#line 3375
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3323
+#line 3375
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3323
+#line 3375
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3323
+#line 3375
}
-#line 3323
+#line 3375
/* copy workspace back if necessary */
-#line 3323
+#line 3375
if (realign) {
-#line 3323
+#line 3375
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3323
+#line 3375
xp = (uint *) *xpp;
-#line 3323
+#line 3375
}
-#line 3323
+#line 3375
/* update xpp and tp */
-#line 3323
+#line 3375
xp += ni;
-#line 3323
+#line 3375
tp += ni;
-#line 3323
+#line 3375
*xpp = (void*)xp;
-#line 3323
+#line 3375
}
-#line 3323
+#line 3375
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3323
+#line 3375
-#line 3323
+#line 3375
#else /* not SX */
-#line 3323
+#line 3375
-#line 3323
+#line 3375
char *xp = (char *) *xpp;
-#line 3323
+#line 3375
int status = NC_NOERR;
-#line 3323
+#line 3375
-#line 3323
+#line 3375
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3323
+#line 3375
{
-#line 3323
+#line 3375
int lstatus = ncx_put_uint_long(xp, tp, fillp);
-#line 3323
+#line 3375
if (status == NC_NOERR) /* report the first encountered error */
-#line 3323
+#line 3375
status = lstatus;
-#line 3323
+#line 3375
}
-#line 3323
+#line 3375
-#line 3323
+#line 3375
*xpp = (void *)xp;
-#line 3323
+#line 3375
return status;
-#line 3323
+#line 3375
#endif
-#line 3323
+#line 3375
}
-#line 3323
+#line 3375
int
-#line 3324
+#line 3376
ncx_putn_uint_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3324
+#line 3376
{
-#line 3324
+#line 3376
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3324
+#line 3376
-#line 3324
+#line 3376
/* basic algorithm is:
-#line 3324
+#line 3376
* - ensure sane alignment of output data
-#line 3324
+#line 3376
* - copy (conversion happens automatically) input data
-#line 3324
+#line 3376
* to output
-#line 3324
+#line 3376
* - update tp to point at next unconverted input, and xpp to point
-#line 3324
+#line 3376
* at next location for converted output
-#line 3324
+#line 3376
*/
-#line 3324
+#line 3376
long i, j, ni;
-#line 3324
+#line 3376
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3324
+#line 3376
uint *xp;
-#line 3324
+#line 3376
int nrange = 0; /* number of range errors */
-#line 3324
+#line 3376
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3324
+#line 3376
long cxp = (long) *((char**)xpp);
-#line 3324
+#line 3376
-#line 3324
+#line 3376
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3324
+#line 3376
/* sjl: manually stripmine so we can limit amount of
-#line 3324
+#line 3376
* vector work space reserved to LOOPCNT elements. Also
-#line 3324
+#line 3376
* makes vectorisation easy */
-#line 3324
+#line 3376
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3324
+#line 3376
ni=Min(nelems-j,LOOPCNT);
-#line 3324
+#line 3376
if (realign) {
-#line 3324
+#line 3376
xp = tmp;
-#line 3324
+#line 3376
} else {
-#line 3324
+#line 3376
xp = (uint *) *xpp;
-#line 3324
+#line 3376
}
-#line 3324
+#line 3376
/* copy the next block */
-#line 3324
+#line 3376
#pragma cdir loopcnt=LOOPCNT
-#line 3324
+#line 3376
#pragma cdir shortloop
-#line 3324
+#line 3376
for (i=0; i<ni; i++) {
-#line 3324
+#line 3376
/* the normal case: */
-#line 3324
+#line 3376
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3324
+#line 3376
/* test for range errors (not always needed but do it anyway) */
-#line 3324
+#line 3376
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3324
+#line 3376
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3324
+#line 3376
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3324
+#line 3376
}
-#line 3324
+#line 3376
/* copy workspace back if necessary */
-#line 3324
+#line 3376
if (realign) {
-#line 3324
+#line 3376
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3324
+#line 3376
xp = (uint *) *xpp;
-#line 3324
+#line 3376
}
-#line 3324
+#line 3376
/* update xpp and tp */
-#line 3324
+#line 3376
xp += ni;
-#line 3324
+#line 3376
tp += ni;
-#line 3324
+#line 3376
*xpp = (void*)xp;
-#line 3324
+#line 3376
}
-#line 3324
+#line 3376
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3324
+#line 3376
-#line 3324
+#line 3376
#else /* not SX */
-#line 3324
+#line 3376
-#line 3324
+#line 3376
char *xp = (char *) *xpp;
-#line 3324
+#line 3376
int status = NC_NOERR;
-#line 3324
+#line 3376
-#line 3324
+#line 3376
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3324
+#line 3376
{
-#line 3324
+#line 3376
int lstatus = ncx_put_uint_float(xp, tp, fillp);
-#line 3324
+#line 3376
if (status == NC_NOERR) /* report the first encountered error */
-#line 3324
+#line 3376
status = lstatus;
-#line 3324
+#line 3376
}
-#line 3324
+#line 3376
-#line 3324
+#line 3376
*xpp = (void *)xp;
-#line 3324
+#line 3376
return status;
-#line 3324
+#line 3376
#endif
-#line 3324
+#line 3376
}
-#line 3324
+#line 3376
int
-#line 3325
+#line 3377
ncx_putn_uint_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3325
+#line 3377
{
-#line 3325
+#line 3377
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3325
+#line 3377
-#line 3325
+#line 3377
/* basic algorithm is:
-#line 3325
+#line 3377
* - ensure sane alignment of output data
-#line 3325
+#line 3377
* - copy (conversion happens automatically) input data
-#line 3325
+#line 3377
* to output
-#line 3325
+#line 3377
* - update tp to point at next unconverted input, and xpp to point
-#line 3325
+#line 3377
* at next location for converted output
-#line 3325
+#line 3377
*/
-#line 3325
+#line 3377
long i, j, ni;
-#line 3325
+#line 3377
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3325
+#line 3377
uint *xp;
-#line 3325
+#line 3377
int nrange = 0; /* number of range errors */
-#line 3325
+#line 3377
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3325
+#line 3377
long cxp = (long) *((char**)xpp);
-#line 3325
+#line 3377
-#line 3325
+#line 3377
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3325
+#line 3377
/* sjl: manually stripmine so we can limit amount of
-#line 3325
+#line 3377
* vector work space reserved to LOOPCNT elements. Also
-#line 3325
+#line 3377
* makes vectorisation easy */
-#line 3325
+#line 3377
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3325
+#line 3377
ni=Min(nelems-j,LOOPCNT);
-#line 3325
+#line 3377
if (realign) {
-#line 3325
+#line 3377
xp = tmp;
-#line 3325
+#line 3377
} else {
-#line 3325
+#line 3377
xp = (uint *) *xpp;
-#line 3325
+#line 3377
}
-#line 3325
+#line 3377
/* copy the next block */
-#line 3325
+#line 3377
#pragma cdir loopcnt=LOOPCNT
-#line 3325
+#line 3377
#pragma cdir shortloop
-#line 3325
+#line 3377
for (i=0; i<ni; i++) {
-#line 3325
+#line 3377
/* the normal case: */
-#line 3325
+#line 3377
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3325
+#line 3377
/* test for range errors (not always needed but do it anyway) */
-#line 3325
+#line 3377
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3325
+#line 3377
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3325
+#line 3377
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3325
+#line 3377
}
-#line 3325
+#line 3377
/* copy workspace back if necessary */
-#line 3325
+#line 3377
if (realign) {
-#line 3325
+#line 3377
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3325
+#line 3377
xp = (uint *) *xpp;
-#line 3325
+#line 3377
}
-#line 3325
+#line 3377
/* update xpp and tp */
-#line 3325
+#line 3377
xp += ni;
-#line 3325
+#line 3377
tp += ni;
-#line 3325
+#line 3377
*xpp = (void*)xp;
-#line 3325
+#line 3377
}
-#line 3325
+#line 3377
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3325
+#line 3377
-#line 3325
+#line 3377
#else /* not SX */
-#line 3325
+#line 3377
-#line 3325
+#line 3377
char *xp = (char *) *xpp;
-#line 3325
+#line 3377
int status = NC_NOERR;
-#line 3325
+#line 3377
-#line 3325
+#line 3377
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3325
+#line 3377
{
-#line 3325
+#line 3377
int lstatus = ncx_put_uint_double(xp, tp, fillp);
-#line 3325
+#line 3377
if (status == NC_NOERR) /* report the first encountered error */
-#line 3325
+#line 3377
status = lstatus;
-#line 3325
+#line 3377
}
-#line 3325
+#line 3377
-#line 3325
+#line 3377
*xpp = (void *)xp;
-#line 3325
+#line 3377
return status;
-#line 3325
+#line 3377
#endif
-#line 3325
+#line 3377
}
-#line 3325
+#line 3377
int
-#line 3326
+#line 3378
ncx_putn_uint_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3326
+#line 3378
{
-#line 3326
+#line 3378
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3326
+#line 3378
-#line 3326
+#line 3378
/* basic algorithm is:
-#line 3326
+#line 3378
* - ensure sane alignment of output data
-#line 3326
+#line 3378
* - copy (conversion happens automatically) input data
-#line 3326
+#line 3378
* to output
-#line 3326
+#line 3378
* - update tp to point at next unconverted input, and xpp to point
-#line 3326
+#line 3378
* at next location for converted output
-#line 3326
+#line 3378
*/
-#line 3326
+#line 3378
long i, j, ni;
-#line 3326
+#line 3378
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3326
+#line 3378
uint *xp;
-#line 3326
+#line 3378
int nrange = 0; /* number of range errors */
-#line 3326
+#line 3378
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3326
+#line 3378
long cxp = (long) *((char**)xpp);
-#line 3326
+#line 3378
-#line 3326
+#line 3378
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3326
+#line 3378
/* sjl: manually stripmine so we can limit amount of
-#line 3326
+#line 3378
* vector work space reserved to LOOPCNT elements. Also
-#line 3326
+#line 3378
* makes vectorisation easy */
-#line 3326
+#line 3378
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3326
+#line 3378
ni=Min(nelems-j,LOOPCNT);
-#line 3326
+#line 3378
if (realign) {
-#line 3326
+#line 3378
xp = tmp;
-#line 3326
+#line 3378
} else {
-#line 3326
+#line 3378
xp = (uint *) *xpp;
-#line 3326
+#line 3378
}
-#line 3326
+#line 3378
/* copy the next block */
-#line 3326
+#line 3378
#pragma cdir loopcnt=LOOPCNT
-#line 3326
+#line 3378
#pragma cdir shortloop
-#line 3326
+#line 3378
for (i=0; i<ni; i++) {
-#line 3326
+#line 3378
/* the normal case: */
-#line 3326
+#line 3378
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3326
+#line 3378
/* test for range errors (not always needed but do it anyway) */
-#line 3326
+#line 3378
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3326
+#line 3378
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3326
+#line 3378
nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
-#line 3326
+#line 3378
}
-#line 3326
+#line 3378
/* copy workspace back if necessary */
-#line 3326
+#line 3378
if (realign) {
-#line 3326
+#line 3378
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3326
+#line 3378
xp = (uint *) *xpp;
-#line 3326
+#line 3378
}
-#line 3326
+#line 3378
/* update xpp and tp */
-#line 3326
+#line 3378
xp += ni;
-#line 3326
+#line 3378
tp += ni;
-#line 3326
+#line 3378
*xpp = (void*)xp;
-#line 3326
+#line 3378
}
-#line 3326
+#line 3378
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3326
+#line 3378
-#line 3326
+#line 3378
#else /* not SX */
-#line 3326
+#line 3378
-#line 3326
+#line 3378
char *xp = (char *) *xpp;
-#line 3326
+#line 3378
int status = NC_NOERR;
-#line 3326
+#line 3378
-#line 3326
+#line 3378
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3326
+#line 3378
{
-#line 3326
+#line 3378
int lstatus = ncx_put_uint_longlong(xp, tp, fillp);
-#line 3326
+#line 3378
if (status == NC_NOERR) /* report the first encountered error */
-#line 3326
+#line 3378
status = lstatus;
-#line 3326
+#line 3378
}
-#line 3326
+#line 3378
-#line 3326
+#line 3378
*xpp = (void *)xp;
-#line 3326
+#line 3378
return status;
-#line 3326
+#line 3378
#endif
-#line 3326
+#line 3378
}
-#line 3326
+#line 3378
int
-#line 3327
+#line 3379
ncx_putn_uint_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3327
+#line 3379
{
-#line 3327
+#line 3379
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3327
+#line 3379
-#line 3327
+#line 3379
/* basic algorithm is:
-#line 3327
+#line 3379
* - ensure sane alignment of output data
-#line 3327
+#line 3379
* - copy (conversion happens automatically) input data
-#line 3327
+#line 3379
* to output
-#line 3327
+#line 3379
* - update tp to point at next unconverted input, and xpp to point
-#line 3327
+#line 3379
* at next location for converted output
-#line 3327
+#line 3379
*/
-#line 3327
+#line 3379
long i, j, ni;
-#line 3327
+#line 3379
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3327
+#line 3379
uint *xp;
-#line 3327
+#line 3379
int nrange = 0; /* number of range errors */
-#line 3327
+#line 3379
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3327
+#line 3379
long cxp = (long) *((char**)xpp);
-#line 3327
+#line 3379
-#line 3327
+#line 3379
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3327
+#line 3379
/* sjl: manually stripmine so we can limit amount of
-#line 3327
+#line 3379
* vector work space reserved to LOOPCNT elements. Also
-#line 3327
+#line 3379
* makes vectorisation easy */
-#line 3327
+#line 3379
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3327
+#line 3379
ni=Min(nelems-j,LOOPCNT);
-#line 3327
+#line 3379
if (realign) {
-#line 3327
+#line 3379
xp = tmp;
-#line 3327
+#line 3379
} else {
-#line 3327
+#line 3379
xp = (uint *) *xpp;
-#line 3327
+#line 3379
}
-#line 3327
+#line 3379
/* copy the next block */
-#line 3327
+#line 3379
#pragma cdir loopcnt=LOOPCNT
-#line 3327
+#line 3379
#pragma cdir shortloop
-#line 3327
+#line 3379
for (i=0; i<ni; i++) {
-#line 3327
+#line 3379
/* the normal case: */
-#line 3327
+#line 3379
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3327
+#line 3379
/* test for range errors (not always needed but do it anyway) */
-#line 3327
+#line 3379
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3327
+#line 3379
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3327
+#line 3379
nrange += tp[i] > X_UINT_MAX ;
-#line 3327
+#line 3379
}
-#line 3327
+#line 3379
/* copy workspace back if necessary */
-#line 3327
+#line 3379
if (realign) {
-#line 3327
+#line 3379
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3327
+#line 3379
xp = (uint *) *xpp;
-#line 3327
+#line 3379
}
-#line 3327
+#line 3379
/* update xpp and tp */
-#line 3327
+#line 3379
xp += ni;
-#line 3327
+#line 3379
tp += ni;
-#line 3327
+#line 3379
*xpp = (void*)xp;
-#line 3327
+#line 3379
}
-#line 3327
+#line 3379
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3327
+#line 3379
-#line 3327
+#line 3379
#else /* not SX */
-#line 3327
+#line 3379
-#line 3327
+#line 3379
char *xp = (char *) *xpp;
-#line 3327
+#line 3379
int status = NC_NOERR;
-#line 3327
+#line 3379
-#line 3327
+#line 3379
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3327
+#line 3379
{
-#line 3327
+#line 3379
int lstatus = ncx_put_uint_uchar(xp, tp, fillp);
-#line 3327
+#line 3379
if (status == NC_NOERR) /* report the first encountered error */
-#line 3327
+#line 3379
status = lstatus;
-#line 3327
+#line 3379
}
-#line 3327
+#line 3379
-#line 3327
+#line 3379
*xpp = (void *)xp;
-#line 3327
+#line 3379
return status;
-#line 3327
+#line 3379
#endif
-#line 3327
+#line 3379
}
-#line 3327
+#line 3379
int
-#line 3328
+#line 3380
ncx_putn_uint_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3328
+#line 3380
{
-#line 3328
+#line 3380
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3328
+#line 3380
-#line 3328
+#line 3380
/* basic algorithm is:
-#line 3328
+#line 3380
* - ensure sane alignment of output data
-#line 3328
+#line 3380
* - copy (conversion happens automatically) input data
-#line 3328
+#line 3380
* to output
-#line 3328
+#line 3380
* - update tp to point at next unconverted input, and xpp to point
-#line 3328
+#line 3380
* at next location for converted output
-#line 3328
+#line 3380
*/
-#line 3328
+#line 3380
long i, j, ni;
-#line 3328
+#line 3380
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3328
+#line 3380
uint *xp;
-#line 3328
+#line 3380
int nrange = 0; /* number of range errors */
-#line 3328
+#line 3380
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3328
+#line 3380
long cxp = (long) *((char**)xpp);
-#line 3328
+#line 3380
-#line 3328
+#line 3380
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3328
+#line 3380
/* sjl: manually stripmine so we can limit amount of
-#line 3328
+#line 3380
* vector work space reserved to LOOPCNT elements. Also
-#line 3328
+#line 3380
* makes vectorisation easy */
-#line 3328
+#line 3380
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3328
+#line 3380
ni=Min(nelems-j,LOOPCNT);
-#line 3328
+#line 3380
if (realign) {
-#line 3328
+#line 3380
xp = tmp;
-#line 3328
+#line 3380
} else {
-#line 3328
+#line 3380
xp = (uint *) *xpp;
-#line 3328
+#line 3380
}
-#line 3328
+#line 3380
/* copy the next block */
-#line 3328
+#line 3380
#pragma cdir loopcnt=LOOPCNT
-#line 3328
+#line 3380
#pragma cdir shortloop
-#line 3328
+#line 3380
for (i=0; i<ni; i++) {
-#line 3328
+#line 3380
/* the normal case: */
-#line 3328
+#line 3380
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3328
+#line 3380
/* test for range errors (not always needed but do it anyway) */
-#line 3328
+#line 3380
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3328
+#line 3380
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3328
+#line 3380
nrange += tp[i] > X_UINT_MAX ;
-#line 3328
+#line 3380
}
-#line 3328
+#line 3380
/* copy workspace back if necessary */
-#line 3328
+#line 3380
if (realign) {
-#line 3328
+#line 3380
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3328
+#line 3380
xp = (uint *) *xpp;
-#line 3328
+#line 3380
}
-#line 3328
+#line 3380
/* update xpp and tp */
-#line 3328
+#line 3380
xp += ni;
-#line 3328
+#line 3380
tp += ni;
-#line 3328
+#line 3380
*xpp = (void*)xp;
-#line 3328
+#line 3380
}
-#line 3328
+#line 3380
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3328
+#line 3380
-#line 3328
+#line 3380
#else /* not SX */
-#line 3328
+#line 3380
-#line 3328
+#line 3380
char *xp = (char *) *xpp;
-#line 3328
+#line 3380
int status = NC_NOERR;
-#line 3328
+#line 3380
-#line 3328
+#line 3380
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3328
+#line 3380
{
-#line 3328
+#line 3380
int lstatus = ncx_put_uint_ushort(xp, tp, fillp);
-#line 3328
+#line 3380
if (status == NC_NOERR) /* report the first encountered error */
-#line 3328
+#line 3380
status = lstatus;
-#line 3328
+#line 3380
}
-#line 3328
+#line 3380
-#line 3328
+#line 3380
*xpp = (void *)xp;
-#line 3328
+#line 3380
return status;
-#line 3328
+#line 3380
#endif
-#line 3328
+#line 3380
}
-#line 3328
+#line 3380
int
-#line 3329
+#line 3381
ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3329
+#line 3381
{
-#line 3329
+#line 3381
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT == SIZEOF_UINT
-#line 3329
+#line 3381
-#line 3329
+#line 3381
/* basic algorithm is:
-#line 3329
+#line 3381
* - ensure sane alignment of output data
-#line 3329
+#line 3381
* - copy (conversion happens automatically) input data
-#line 3329
+#line 3381
* to output
-#line 3329
+#line 3381
* - update tp to point at next unconverted input, and xpp to point
-#line 3329
+#line 3381
* at next location for converted output
-#line 3329
+#line 3381
*/
-#line 3329
+#line 3381
long i, j, ni;
-#line 3329
+#line 3381
uint tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3329
+#line 3381
uint *xp;
-#line 3329
+#line 3381
int nrange = 0; /* number of range errors */
-#line 3329
+#line 3381
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3329
+#line 3381
long cxp = (long) *((char**)xpp);
-#line 3329
+#line 3381
-#line 3329
+#line 3381
realign = (cxp & 7) % SIZEOF_UINT;
-#line 3329
+#line 3381
/* sjl: manually stripmine so we can limit amount of
-#line 3329
+#line 3381
* vector work space reserved to LOOPCNT elements. Also
-#line 3329
+#line 3381
* makes vectorisation easy */
-#line 3329
+#line 3381
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3329
+#line 3381
ni=Min(nelems-j,LOOPCNT);
-#line 3329
+#line 3381
if (realign) {
-#line 3329
+#line 3381
xp = tmp;
-#line 3329
+#line 3381
} else {
-#line 3329
+#line 3381
xp = (uint *) *xpp;
-#line 3329
+#line 3381
}
-#line 3329
+#line 3381
/* copy the next block */
-#line 3329
+#line 3381
#pragma cdir loopcnt=LOOPCNT
-#line 3329
+#line 3381
#pragma cdir shortloop
-#line 3329
+#line 3381
for (i=0; i<ni; i++) {
-#line 3329
+#line 3381
/* the normal case: */
-#line 3329
+#line 3381
xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
-#line 3329
+#line 3381
/* test for range errors (not always needed but do it anyway) */
-#line 3329
+#line 3381
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3329
+#line 3381
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3329
+#line 3381
nrange += tp[i] > X_UINT_MAX ;
-#line 3329
+#line 3381
}
-#line 3329
+#line 3381
/* copy workspace back if necessary */
-#line 3329
+#line 3381
if (realign) {
-#line 3329
+#line 3381
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT);
-#line 3329
+#line 3381
xp = (uint *) *xpp;
-#line 3329
+#line 3381
}
-#line 3329
+#line 3381
/* update xpp and tp */
-#line 3329
+#line 3381
xp += ni;
-#line 3329
+#line 3381
tp += ni;
-#line 3329
+#line 3381
*xpp = (void*)xp;
-#line 3329
+#line 3381
}
-#line 3329
+#line 3381
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3329
+#line 3381
-#line 3329
+#line 3381
#else /* not SX */
-#line 3329
+#line 3381
-#line 3329
+#line 3381
char *xp = (char *) *xpp;
-#line 3329
+#line 3381
int status = NC_NOERR;
-#line 3329
+#line 3381
-#line 3329
+#line 3381
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
-#line 3329
+#line 3381
{
-#line 3329
+#line 3381
int lstatus = ncx_put_uint_ulonglong(xp, tp, fillp);
-#line 3329
+#line 3381
if (status == NC_NOERR) /* report the first encountered error */
-#line 3329
+#line 3381
status = lstatus;
-#line 3329
+#line 3381
}
-#line 3329
+#line 3381
-#line 3329
+#line 3381
*xpp = (void *)xp;
-#line 3329
+#line 3381
return status;
-#line 3329
+#line 3381
#endif
-#line 3329
+#line 3381
}
-#line 3329
+#line 3381
@@ -25390,95 +27475,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 3355
+#line 3407
const struct ieee_single *const isp =
-#line 3355
+#line 3407
(const struct ieee_single *) (*xpp);
-#line 3355
+#line 3407
unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
-#line 3355
+#line 3407
-#line 3355
+#line 3407
switch(exp) {
-#line 3355
+#line 3407
case 0 :
-#line 3355
+#line 3407
/* ieee subnormal */
-#line 3355
+#line 3407
if (isp->mant_hi == min.ieee.mant_hi
-#line 3355
+#line 3407
&& isp->mant_lo_hi == min.ieee.mant_lo_hi
-#line 3355
+#line 3407
&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
-#line 3355
+#line 3407
{
-#line 3355
+#line 3407
*vsp = min.s;
-#line 3355
+#line 3407
}
-#line 3355
+#line 3407
else
-#line 3355
+#line 3407
{
-#line 3355
+#line 3407
unsigned mantissa = (isp->mant_hi << 16)
-#line 3355
+#line 3407
| isp->mant_lo_hi << 8
-#line 3355
+#line 3407
| isp->mant_lo_lo;
-#line 3355
+#line 3407
unsigned tmp = mantissa >> 20;
-#line 3355
+#line 3407
if (tmp >= 4) {
-#line 3355
+#line 3407
vsp->exp = 2;
-#line 3355
+#line 3407
} else if (tmp >= 2) {
-#line 3355
+#line 3407
vsp->exp = 1;
-#line 3355
+#line 3407
} else {
-#line 3355
+#line 3407
*vsp = min.s;
-#line 3355
+#line 3407
break;
-#line 3355
+#line 3407
} /* else */
-#line 3355
+#line 3407
tmp = mantissa - (1 << (20 + vsp->exp ));
-#line 3355
+#line 3407
tmp <<= 3 - vsp->exp;
-#line 3355
+#line 3407
vsp->mantissa2 = tmp;
-#line 3355
+#line 3407
vsp->mantissa1 = (tmp >> 16);
-#line 3355
+#line 3407
}
-#line 3355
+#line 3407
break;
-#line 3355
+#line 3407
case 0xfe :
-#line 3355
+#line 3407
case 0xff :
-#line 3355
+#line 3407
*vsp = max.s;
-#line 3355
+#line 3407
break;
-#line 3355
+#line 3407
default :
-#line 3355
+#line 3407
vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
-#line 3355
+#line 3407
vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
-#line 3355
+#line 3407
vsp->mantissa1 = isp->mant_hi;
-#line 3355
+#line 3407
}
-#line 3355
+#line 3407
-#line 3355
+#line 3407
vsp->sign = isp->sign;
-#line 3355
+#line 3407
ip++;
@@ -25506,1294 +27591,1294 @@ ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
#endif
int
-#line 3381
+#line 3433
ncx_getn_float_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3381
+#line 3433
{
-#line 3381
+#line 3433
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3381
+#line 3433
-#line 3381
+#line 3433
/* basic algorithm is:
-#line 3381
+#line 3433
* - ensure sane alignment of input data
-#line 3381
+#line 3433
* - copy (conversion happens automatically) input data
-#line 3381
+#line 3433
* to output
-#line 3381
+#line 3433
* - update xpp to point at next unconverted input, and tp to point
-#line 3381
+#line 3433
* at next location for converted output
-#line 3381
+#line 3433
*/
-#line 3381
+#line 3433
long i, j, ni;
-#line 3381
+#line 3433
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3381
+#line 3433
float *xp;
-#line 3381
+#line 3433
int nrange = 0; /* number of range errors */
-#line 3381
+#line 3433
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3381
+#line 3433
long cxp = (long) *((char**)xpp);
-#line 3381
+#line 3433
-#line 3381
+#line 3433
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3381
+#line 3433
/* sjl: manually stripmine so we can limit amount of
-#line 3381
+#line 3433
* vector work space reserved to LOOPCNT elements. Also
-#line 3381
+#line 3433
* makes vectorisation easy */
-#line 3381
+#line 3433
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3381
+#line 3433
ni=Min(nelems-j,LOOPCNT);
-#line 3381
+#line 3433
if (realign) {
-#line 3381
+#line 3433
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3381
+#line 3433
xp = tmp;
-#line 3381
+#line 3433
} else {
-#line 3381
+#line 3433
xp = (float *) *xpp;
-#line 3381
+#line 3433
}
-#line 3381
+#line 3433
/* copy the next block */
-#line 3381
+#line 3433
#pragma cdir loopcnt=LOOPCNT
-#line 3381
+#line 3433
#pragma cdir shortloop
-#line 3381
+#line 3433
for (i=0; i<ni; i++) {
-#line 3381
+#line 3433
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3381
+#line 3433
/* test for range errors (not always needed but do it anyway) */
-#line 3381
+#line 3433
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3381
+#line 3433
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3381
+#line 3433
nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
-#line 3381
+#line 3433
}
-#line 3381
+#line 3433
/* update xpp and tp */
-#line 3381
+#line 3433
if (realign) xp = (float *) *xpp;
-#line 3381
+#line 3433
xp += ni;
-#line 3381
+#line 3433
tp += ni;
-#line 3381
+#line 3433
*xpp = (void*)xp;
-#line 3381
+#line 3433
}
-#line 3381
+#line 3433
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3381
+#line 3433
-#line 3381
+#line 3433
#else /* not SX */
-#line 3381
+#line 3433
const char *xp = (const char *) *xpp;
-#line 3381
+#line 3433
int status = NC_NOERR;
-#line 3381
+#line 3433
-#line 3381
+#line 3433
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3381
+#line 3433
{
-#line 3381
+#line 3433
const int lstatus = ncx_get_float_schar(xp, tp);
-#line 3381
+#line 3433
if (status == NC_NOERR) /* report the first encountered error */
-#line 3381
+#line 3433
status = lstatus;
-#line 3381
+#line 3433
}
-#line 3381
+#line 3433
-#line 3381
+#line 3433
*xpp = (const void *)xp;
-#line 3381
+#line 3433
return status;
-#line 3381
+#line 3433
#endif
-#line 3381
+#line 3433
}
-#line 3381
+#line 3433
int
-#line 3382
+#line 3434
ncx_getn_float_short(const void **xpp, size_t nelems, short *tp)
-#line 3382
+#line 3434
{
-#line 3382
+#line 3434
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3382
+#line 3434
-#line 3382
+#line 3434
/* basic algorithm is:
-#line 3382
+#line 3434
* - ensure sane alignment of input data
-#line 3382
+#line 3434
* - copy (conversion happens automatically) input data
-#line 3382
+#line 3434
* to output
-#line 3382
+#line 3434
* - update xpp to point at next unconverted input, and tp to point
-#line 3382
+#line 3434
* at next location for converted output
-#line 3382
+#line 3434
*/
-#line 3382
+#line 3434
long i, j, ni;
-#line 3382
+#line 3434
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3382
+#line 3434
float *xp;
-#line 3382
+#line 3434
int nrange = 0; /* number of range errors */
-#line 3382
+#line 3434
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3382
+#line 3434
long cxp = (long) *((char**)xpp);
-#line 3382
+#line 3434
-#line 3382
+#line 3434
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3382
+#line 3434
/* sjl: manually stripmine so we can limit amount of
-#line 3382
+#line 3434
* vector work space reserved to LOOPCNT elements. Also
-#line 3382
+#line 3434
* makes vectorisation easy */
-#line 3382
+#line 3434
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3382
+#line 3434
ni=Min(nelems-j,LOOPCNT);
-#line 3382
+#line 3434
if (realign) {
-#line 3382
+#line 3434
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3382
+#line 3434
xp = tmp;
-#line 3382
+#line 3434
} else {
-#line 3382
+#line 3434
xp = (float *) *xpp;
-#line 3382
+#line 3434
}
-#line 3382
+#line 3434
/* copy the next block */
-#line 3382
+#line 3434
#pragma cdir loopcnt=LOOPCNT
-#line 3382
+#line 3434
#pragma cdir shortloop
-#line 3382
+#line 3434
for (i=0; i<ni; i++) {
-#line 3382
+#line 3434
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3382
+#line 3434
/* test for range errors (not always needed but do it anyway) */
-#line 3382
+#line 3434
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3382
+#line 3434
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3382
+#line 3434
nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
-#line 3382
+#line 3434
}
-#line 3382
+#line 3434
/* update xpp and tp */
-#line 3382
+#line 3434
if (realign) xp = (float *) *xpp;
-#line 3382
+#line 3434
xp += ni;
-#line 3382
+#line 3434
tp += ni;
-#line 3382
+#line 3434
*xpp = (void*)xp;
-#line 3382
+#line 3434
}
-#line 3382
+#line 3434
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3382
+#line 3434
-#line 3382
+#line 3434
#else /* not SX */
-#line 3382
+#line 3434
const char *xp = (const char *) *xpp;
-#line 3382
+#line 3434
int status = NC_NOERR;
-#line 3382
+#line 3434
-#line 3382
+#line 3434
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3382
+#line 3434
{
-#line 3382
+#line 3434
const int lstatus = ncx_get_float_short(xp, tp);
-#line 3382
+#line 3434
if (status == NC_NOERR) /* report the first encountered error */
-#line 3382
+#line 3434
status = lstatus;
-#line 3382
+#line 3434
}
-#line 3382
+#line 3434
-#line 3382
+#line 3434
*xpp = (const void *)xp;
-#line 3382
+#line 3434
return status;
-#line 3382
+#line 3434
#endif
-#line 3382
+#line 3434
}
-#line 3382
+#line 3434
int
-#line 3383
+#line 3435
ncx_getn_float_int(const void **xpp, size_t nelems, int *tp)
-#line 3383
+#line 3435
{
-#line 3383
+#line 3435
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3383
+#line 3435
-#line 3383
+#line 3435
/* basic algorithm is:
-#line 3383
+#line 3435
* - ensure sane alignment of input data
-#line 3383
+#line 3435
* - copy (conversion happens automatically) input data
-#line 3383
+#line 3435
* to output
-#line 3383
+#line 3435
* - update xpp to point at next unconverted input, and tp to point
-#line 3383
+#line 3435
* at next location for converted output
-#line 3383
+#line 3435
*/
-#line 3383
+#line 3435
long i, j, ni;
-#line 3383
+#line 3435
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3383
+#line 3435
float *xp;
-#line 3383
+#line 3435
int nrange = 0; /* number of range errors */
-#line 3383
+#line 3435
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3383
+#line 3435
long cxp = (long) *((char**)xpp);
-#line 3383
+#line 3435
-#line 3383
+#line 3435
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3383
+#line 3435
/* sjl: manually stripmine so we can limit amount of
-#line 3383
+#line 3435
* vector work space reserved to LOOPCNT elements. Also
-#line 3383
+#line 3435
* makes vectorisation easy */
-#line 3383
+#line 3435
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3383
+#line 3435
ni=Min(nelems-j,LOOPCNT);
-#line 3383
+#line 3435
if (realign) {
-#line 3383
+#line 3435
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3383
+#line 3435
xp = tmp;
-#line 3383
+#line 3435
} else {
-#line 3383
+#line 3435
xp = (float *) *xpp;
-#line 3383
+#line 3435
}
-#line 3383
+#line 3435
/* copy the next block */
-#line 3383
+#line 3435
#pragma cdir loopcnt=LOOPCNT
-#line 3383
+#line 3435
#pragma cdir shortloop
-#line 3383
+#line 3435
for (i=0; i<ni; i++) {
-#line 3383
+#line 3435
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3383
+#line 3435
/* test for range errors (not always needed but do it anyway) */
-#line 3383
+#line 3435
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3383
+#line 3435
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3383
+#line 3435
nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
-#line 3383
+#line 3435
}
-#line 3383
+#line 3435
/* update xpp and tp */
-#line 3383
+#line 3435
if (realign) xp = (float *) *xpp;
-#line 3383
+#line 3435
xp += ni;
-#line 3383
+#line 3435
tp += ni;
-#line 3383
+#line 3435
*xpp = (void*)xp;
-#line 3383
+#line 3435
}
-#line 3383
+#line 3435
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3383
+#line 3435
-#line 3383
+#line 3435
#else /* not SX */
-#line 3383
+#line 3435
const char *xp = (const char *) *xpp;
-#line 3383
+#line 3435
int status = NC_NOERR;
-#line 3383
+#line 3435
-#line 3383
+#line 3435
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3383
+#line 3435
{
-#line 3383
+#line 3435
const int lstatus = ncx_get_float_int(xp, tp);
-#line 3383
+#line 3435
if (status == NC_NOERR) /* report the first encountered error */
-#line 3383
+#line 3435
status = lstatus;
-#line 3383
+#line 3435
}
-#line 3383
+#line 3435
-#line 3383
+#line 3435
*xpp = (const void *)xp;
-#line 3383
+#line 3435
return status;
-#line 3383
+#line 3435
#endif
-#line 3383
+#line 3435
}
-#line 3383
+#line 3435
int
-#line 3384
+#line 3436
ncx_getn_float_long(const void **xpp, size_t nelems, long *tp)
-#line 3384
+#line 3436
{
-#line 3384
+#line 3436
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3384
+#line 3436
-#line 3384
+#line 3436
/* basic algorithm is:
-#line 3384
+#line 3436
* - ensure sane alignment of input data
-#line 3384
+#line 3436
* - copy (conversion happens automatically) input data
-#line 3384
+#line 3436
* to output
-#line 3384
+#line 3436
* - update xpp to point at next unconverted input, and tp to point
-#line 3384
+#line 3436
* at next location for converted output
-#line 3384
+#line 3436
*/
-#line 3384
+#line 3436
long i, j, ni;
-#line 3384
+#line 3436
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3384
+#line 3436
float *xp;
-#line 3384
+#line 3436
int nrange = 0; /* number of range errors */
-#line 3384
+#line 3436
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3384
+#line 3436
long cxp = (long) *((char**)xpp);
-#line 3384
+#line 3436
-#line 3384
+#line 3436
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3384
+#line 3436
/* sjl: manually stripmine so we can limit amount of
-#line 3384
+#line 3436
* vector work space reserved to LOOPCNT elements. Also
-#line 3384
+#line 3436
* makes vectorisation easy */
-#line 3384
+#line 3436
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3384
+#line 3436
ni=Min(nelems-j,LOOPCNT);
-#line 3384
+#line 3436
if (realign) {
-#line 3384
+#line 3436
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3384
+#line 3436
xp = tmp;
-#line 3384
+#line 3436
} else {
-#line 3384
+#line 3436
xp = (float *) *xpp;
-#line 3384
+#line 3436
}
-#line 3384
+#line 3436
/* copy the next block */
-#line 3384
+#line 3436
#pragma cdir loopcnt=LOOPCNT
-#line 3384
+#line 3436
#pragma cdir shortloop
-#line 3384
+#line 3436
for (i=0; i<ni; i++) {
-#line 3384
+#line 3436
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3384
+#line 3436
/* test for range errors (not always needed but do it anyway) */
-#line 3384
+#line 3436
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3384
+#line 3436
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3384
+#line 3436
nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
-#line 3384
+#line 3436
}
-#line 3384
+#line 3436
/* update xpp and tp */
-#line 3384
+#line 3436
if (realign) xp = (float *) *xpp;
-#line 3384
+#line 3436
xp += ni;
-#line 3384
+#line 3436
tp += ni;
-#line 3384
+#line 3436
*xpp = (void*)xp;
-#line 3384
+#line 3436
}
-#line 3384
+#line 3436
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3384
+#line 3436
-#line 3384
+#line 3436
#else /* not SX */
-#line 3384
+#line 3436
const char *xp = (const char *) *xpp;
-#line 3384
+#line 3436
int status = NC_NOERR;
-#line 3384
+#line 3436
-#line 3384
+#line 3436
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3384
+#line 3436
{
-#line 3384
+#line 3436
const int lstatus = ncx_get_float_long(xp, tp);
-#line 3384
+#line 3436
if (status == NC_NOERR) /* report the first encountered error */
-#line 3384
+#line 3436
status = lstatus;
-#line 3384
+#line 3436
}
-#line 3384
+#line 3436
-#line 3384
+#line 3436
*xpp = (const void *)xp;
-#line 3384
+#line 3436
return status;
-#line 3384
+#line 3436
#endif
-#line 3384
+#line 3436
}
-#line 3384
+#line 3436
int
-#line 3385
+#line 3437
ncx_getn_float_double(const void **xpp, size_t nelems, double *tp)
-#line 3385
+#line 3437
{
-#line 3385
+#line 3437
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3385
+#line 3437
-#line 3385
+#line 3437
/* basic algorithm is:
-#line 3385
+#line 3437
* - ensure sane alignment of input data
-#line 3385
+#line 3437
* - copy (conversion happens automatically) input data
-#line 3385
+#line 3437
* to output
-#line 3385
+#line 3437
* - update xpp to point at next unconverted input, and tp to point
-#line 3385
+#line 3437
* at next location for converted output
-#line 3385
+#line 3437
*/
-#line 3385
+#line 3437
long i, j, ni;
-#line 3385
+#line 3437
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3385
+#line 3437
float *xp;
-#line 3385
+#line 3437
int nrange = 0; /* number of range errors */
-#line 3385
+#line 3437
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3385
+#line 3437
long cxp = (long) *((char**)xpp);
-#line 3385
+#line 3437
-#line 3385
+#line 3437
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3385
+#line 3437
/* sjl: manually stripmine so we can limit amount of
-#line 3385
+#line 3437
* vector work space reserved to LOOPCNT elements. Also
-#line 3385
+#line 3437
* makes vectorisation easy */
-#line 3385
+#line 3437
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3385
+#line 3437
ni=Min(nelems-j,LOOPCNT);
-#line 3385
+#line 3437
if (realign) {
-#line 3385
+#line 3437
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3385
+#line 3437
xp = tmp;
-#line 3385
+#line 3437
} else {
-#line 3385
+#line 3437
xp = (float *) *xpp;
-#line 3385
+#line 3437
}
-#line 3385
+#line 3437
/* copy the next block */
-#line 3385
+#line 3437
#pragma cdir loopcnt=LOOPCNT
-#line 3385
+#line 3437
#pragma cdir shortloop
-#line 3385
+#line 3437
for (i=0; i<ni; i++) {
-#line 3385
+#line 3437
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3385
+#line 3437
/* test for range errors (not always needed but do it anyway) */
-#line 3385
+#line 3437
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3385
+#line 3437
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3385
+#line 3437
nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
-#line 3385
+#line 3437
}
-#line 3385
+#line 3437
/* update xpp and tp */
-#line 3385
+#line 3437
if (realign) xp = (float *) *xpp;
-#line 3385
+#line 3437
xp += ni;
-#line 3385
+#line 3437
tp += ni;
-#line 3385
+#line 3437
*xpp = (void*)xp;
-#line 3385
+#line 3437
}
-#line 3385
+#line 3437
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3385
+#line 3437
-#line 3385
+#line 3437
#else /* not SX */
-#line 3385
+#line 3437
const char *xp = (const char *) *xpp;
-#line 3385
+#line 3437
int status = NC_NOERR;
-#line 3385
+#line 3437
-#line 3385
+#line 3437
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3385
+#line 3437
{
-#line 3385
+#line 3437
const int lstatus = ncx_get_float_double(xp, tp);
-#line 3385
+#line 3437
if (status == NC_NOERR) /* report the first encountered error */
-#line 3385
+#line 3437
status = lstatus;
-#line 3385
+#line 3437
}
-#line 3385
+#line 3437
-#line 3385
+#line 3437
*xpp = (const void *)xp;
-#line 3385
+#line 3437
return status;
-#line 3385
+#line 3437
#endif
-#line 3385
+#line 3437
}
-#line 3385
+#line 3437
int
-#line 3386
+#line 3438
ncx_getn_float_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3386
+#line 3438
{
-#line 3386
+#line 3438
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3386
+#line 3438
-#line 3386
+#line 3438
/* basic algorithm is:
-#line 3386
+#line 3438
* - ensure sane alignment of input data
-#line 3386
+#line 3438
* - copy (conversion happens automatically) input data
-#line 3386
+#line 3438
* to output
-#line 3386
+#line 3438
* - update xpp to point at next unconverted input, and tp to point
-#line 3386
+#line 3438
* at next location for converted output
-#line 3386
+#line 3438
*/
-#line 3386
+#line 3438
long i, j, ni;
-#line 3386
+#line 3438
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3386
+#line 3438
float *xp;
-#line 3386
+#line 3438
int nrange = 0; /* number of range errors */
-#line 3386
+#line 3438
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3386
+#line 3438
long cxp = (long) *((char**)xpp);
-#line 3386
+#line 3438
-#line 3386
+#line 3438
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3386
+#line 3438
/* sjl: manually stripmine so we can limit amount of
-#line 3386
+#line 3438
* vector work space reserved to LOOPCNT elements. Also
-#line 3386
+#line 3438
* makes vectorisation easy */
-#line 3386
+#line 3438
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3386
+#line 3438
ni=Min(nelems-j,LOOPCNT);
-#line 3386
+#line 3438
if (realign) {
-#line 3386
+#line 3438
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3386
+#line 3438
xp = tmp;
-#line 3386
+#line 3438
} else {
-#line 3386
+#line 3438
xp = (float *) *xpp;
-#line 3386
+#line 3438
}
-#line 3386
+#line 3438
/* copy the next block */
-#line 3386
+#line 3438
#pragma cdir loopcnt=LOOPCNT
-#line 3386
+#line 3438
#pragma cdir shortloop
-#line 3386
+#line 3438
for (i=0; i<ni; i++) {
-#line 3386
+#line 3438
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3386
+#line 3438
/* test for range errors (not always needed but do it anyway) */
-#line 3386
+#line 3438
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3386
+#line 3438
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3386
+#line 3438
nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
-#line 3386
+#line 3438
}
-#line 3386
+#line 3438
/* update xpp and tp */
-#line 3386
+#line 3438
if (realign) xp = (float *) *xpp;
-#line 3386
+#line 3438
xp += ni;
-#line 3386
+#line 3438
tp += ni;
-#line 3386
+#line 3438
*xpp = (void*)xp;
-#line 3386
+#line 3438
}
-#line 3386
+#line 3438
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3386
+#line 3438
-#line 3386
+#line 3438
#else /* not SX */
-#line 3386
+#line 3438
const char *xp = (const char *) *xpp;
-#line 3386
+#line 3438
int status = NC_NOERR;
-#line 3386
+#line 3438
-#line 3386
+#line 3438
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3386
+#line 3438
{
-#line 3386
+#line 3438
const int lstatus = ncx_get_float_longlong(xp, tp);
-#line 3386
+#line 3438
if (status == NC_NOERR) /* report the first encountered error */
-#line 3386
+#line 3438
status = lstatus;
-#line 3386
+#line 3438
}
-#line 3386
+#line 3438
-#line 3386
+#line 3438
*xpp = (const void *)xp;
-#line 3386
+#line 3438
return status;
-#line 3386
+#line 3438
#endif
-#line 3386
+#line 3438
}
-#line 3386
+#line 3438
int
-#line 3387
+#line 3439
ncx_getn_float_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3387
+#line 3439
{
-#line 3387
+#line 3439
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3387
+#line 3439
-#line 3387
+#line 3439
/* basic algorithm is:
-#line 3387
+#line 3439
* - ensure sane alignment of input data
-#line 3387
+#line 3439
* - copy (conversion happens automatically) input data
-#line 3387
+#line 3439
* to output
-#line 3387
+#line 3439
* - update xpp to point at next unconverted input, and tp to point
-#line 3387
+#line 3439
* at next location for converted output
-#line 3387
+#line 3439
*/
-#line 3387
+#line 3439
long i, j, ni;
-#line 3387
+#line 3439
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3387
+#line 3439
float *xp;
-#line 3387
+#line 3439
int nrange = 0; /* number of range errors */
-#line 3387
+#line 3439
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3387
+#line 3439
long cxp = (long) *((char**)xpp);
-#line 3387
+#line 3439
-#line 3387
+#line 3439
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3387
+#line 3439
/* sjl: manually stripmine so we can limit amount of
-#line 3387
+#line 3439
* vector work space reserved to LOOPCNT elements. Also
-#line 3387
+#line 3439
* makes vectorisation easy */
-#line 3387
+#line 3439
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3387
+#line 3439
ni=Min(nelems-j,LOOPCNT);
-#line 3387
+#line 3439
if (realign) {
-#line 3387
+#line 3439
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3387
+#line 3439
xp = tmp;
-#line 3387
+#line 3439
} else {
-#line 3387
+#line 3439
xp = (float *) *xpp;
-#line 3387
+#line 3439
}
-#line 3387
+#line 3439
/* copy the next block */
-#line 3387
+#line 3439
#pragma cdir loopcnt=LOOPCNT
-#line 3387
+#line 3439
#pragma cdir shortloop
-#line 3387
+#line 3439
for (i=0; i<ni; i++) {
-#line 3387
+#line 3439
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3387
+#line 3439
/* test for range errors (not always needed but do it anyway) */
-#line 3387
+#line 3439
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3387
+#line 3439
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3387
+#line 3439
nrange += xp[i] > USHORT_MAX || xp[i] < 0;
-#line 3387
+#line 3439
}
-#line 3387
+#line 3439
/* update xpp and tp */
-#line 3387
+#line 3439
if (realign) xp = (float *) *xpp;
-#line 3387
+#line 3439
xp += ni;
-#line 3387
+#line 3439
tp += ni;
-#line 3387
+#line 3439
*xpp = (void*)xp;
-#line 3387
+#line 3439
}
-#line 3387
+#line 3439
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3387
+#line 3439
-#line 3387
+#line 3439
#else /* not SX */
-#line 3387
+#line 3439
const char *xp = (const char *) *xpp;
-#line 3387
+#line 3439
int status = NC_NOERR;
-#line 3387
+#line 3439
-#line 3387
+#line 3439
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3387
+#line 3439
{
-#line 3387
+#line 3439
const int lstatus = ncx_get_float_ushort(xp, tp);
-#line 3387
+#line 3439
if (status == NC_NOERR) /* report the first encountered error */
-#line 3387
+#line 3439
status = lstatus;
-#line 3387
+#line 3439
}
-#line 3387
+#line 3439
-#line 3387
+#line 3439
*xpp = (const void *)xp;
-#line 3387
+#line 3439
return status;
-#line 3387
+#line 3439
#endif
-#line 3387
+#line 3439
}
-#line 3387
+#line 3439
int
-#line 3388
+#line 3440
ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3388
+#line 3440
{
-#line 3388
+#line 3440
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3388
+#line 3440
-#line 3388
+#line 3440
/* basic algorithm is:
-#line 3388
+#line 3440
* - ensure sane alignment of input data
-#line 3388
+#line 3440
* - copy (conversion happens automatically) input data
-#line 3388
+#line 3440
* to output
-#line 3388
+#line 3440
* - update xpp to point at next unconverted input, and tp to point
-#line 3388
+#line 3440
* at next location for converted output
-#line 3388
+#line 3440
*/
-#line 3388
+#line 3440
long i, j, ni;
-#line 3388
+#line 3440
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3388
+#line 3440
float *xp;
-#line 3388
+#line 3440
int nrange = 0; /* number of range errors */
-#line 3388
+#line 3440
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3388
+#line 3440
long cxp = (long) *((char**)xpp);
-#line 3388
+#line 3440
-#line 3388
+#line 3440
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3388
+#line 3440
/* sjl: manually stripmine so we can limit amount of
-#line 3388
+#line 3440
* vector work space reserved to LOOPCNT elements. Also
-#line 3388
+#line 3440
* makes vectorisation easy */
-#line 3388
+#line 3440
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3388
+#line 3440
ni=Min(nelems-j,LOOPCNT);
-#line 3388
+#line 3440
if (realign) {
-#line 3388
+#line 3440
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3388
+#line 3440
xp = tmp;
-#line 3388
+#line 3440
} else {
-#line 3388
+#line 3440
xp = (float *) *xpp;
-#line 3388
+#line 3440
}
-#line 3388
+#line 3440
/* copy the next block */
-#line 3388
+#line 3440
#pragma cdir loopcnt=LOOPCNT
-#line 3388
+#line 3440
#pragma cdir shortloop
-#line 3388
+#line 3440
for (i=0; i<ni; i++) {
-#line 3388
+#line 3440
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3388
+#line 3440
/* test for range errors (not always needed but do it anyway) */
-#line 3388
+#line 3440
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3388
+#line 3440
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3388
+#line 3440
nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
-#line 3388
+#line 3440
}
-#line 3388
+#line 3440
/* update xpp and tp */
-#line 3388
+#line 3440
if (realign) xp = (float *) *xpp;
-#line 3388
+#line 3440
xp += ni;
-#line 3388
+#line 3440
tp += ni;
-#line 3388
+#line 3440
*xpp = (void*)xp;
-#line 3388
+#line 3440
}
-#line 3388
+#line 3440
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3388
+#line 3440
-#line 3388
+#line 3440
#else /* not SX */
-#line 3388
+#line 3440
const char *xp = (const char *) *xpp;
-#line 3388
+#line 3440
int status = NC_NOERR;
-#line 3388
+#line 3440
-#line 3388
+#line 3440
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3388
+#line 3440
{
-#line 3388
+#line 3440
const int lstatus = ncx_get_float_uchar(xp, tp);
-#line 3388
+#line 3440
if (status == NC_NOERR) /* report the first encountered error */
-#line 3388
+#line 3440
status = lstatus;
-#line 3388
+#line 3440
}
-#line 3388
+#line 3440
-#line 3388
+#line 3440
*xpp = (const void *)xp;
-#line 3388
+#line 3440
return status;
-#line 3388
+#line 3440
#endif
-#line 3388
+#line 3440
}
-#line 3388
+#line 3440
int
-#line 3389
+#line 3441
ncx_getn_float_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3389
+#line 3441
{
-#line 3389
+#line 3441
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3389
+#line 3441
-#line 3389
+#line 3441
/* basic algorithm is:
-#line 3389
+#line 3441
* - ensure sane alignment of input data
-#line 3389
+#line 3441
* - copy (conversion happens automatically) input data
-#line 3389
+#line 3441
* to output
-#line 3389
+#line 3441
* - update xpp to point at next unconverted input, and tp to point
-#line 3389
+#line 3441
* at next location for converted output
-#line 3389
+#line 3441
*/
-#line 3389
+#line 3441
long i, j, ni;
-#line 3389
+#line 3441
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3389
+#line 3441
float *xp;
-#line 3389
+#line 3441
int nrange = 0; /* number of range errors */
-#line 3389
+#line 3441
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3389
+#line 3441
long cxp = (long) *((char**)xpp);
-#line 3389
+#line 3441
-#line 3389
+#line 3441
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3389
+#line 3441
/* sjl: manually stripmine so we can limit amount of
-#line 3389
+#line 3441
* vector work space reserved to LOOPCNT elements. Also
-#line 3389
+#line 3441
* makes vectorisation easy */
-#line 3389
+#line 3441
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3389
+#line 3441
ni=Min(nelems-j,LOOPCNT);
-#line 3389
+#line 3441
if (realign) {
-#line 3389
+#line 3441
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3389
+#line 3441
xp = tmp;
-#line 3389
+#line 3441
} else {
-#line 3389
+#line 3441
xp = (float *) *xpp;
-#line 3389
+#line 3441
}
-#line 3389
+#line 3441
/* copy the next block */
-#line 3389
+#line 3441
#pragma cdir loopcnt=LOOPCNT
-#line 3389
+#line 3441
#pragma cdir shortloop
-#line 3389
+#line 3441
for (i=0; i<ni; i++) {
-#line 3389
+#line 3441
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3389
+#line 3441
/* test for range errors (not always needed but do it anyway) */
-#line 3389
+#line 3441
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3389
+#line 3441
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3389
+#line 3441
nrange += xp[i] > UINT_MAX || xp[i] < 0;
-#line 3389
+#line 3441
}
-#line 3389
+#line 3441
/* update xpp and tp */
-#line 3389
+#line 3441
if (realign) xp = (float *) *xpp;
-#line 3389
+#line 3441
xp += ni;
-#line 3389
+#line 3441
tp += ni;
-#line 3389
+#line 3441
*xpp = (void*)xp;
-#line 3389
+#line 3441
}
-#line 3389
+#line 3441
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3389
+#line 3441
-#line 3389
+#line 3441
#else /* not SX */
-#line 3389
+#line 3441
const char *xp = (const char *) *xpp;
-#line 3389
+#line 3441
int status = NC_NOERR;
-#line 3389
+#line 3441
-#line 3389
+#line 3441
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3389
+#line 3441
{
-#line 3389
+#line 3441
const int lstatus = ncx_get_float_uint(xp, tp);
-#line 3389
+#line 3441
if (status == NC_NOERR) /* report the first encountered error */
-#line 3389
+#line 3441
status = lstatus;
-#line 3389
+#line 3441
}
-#line 3389
+#line 3441
-#line 3389
+#line 3441
*xpp = (const void *)xp;
-#line 3389
+#line 3441
return status;
-#line 3389
+#line 3441
#endif
-#line 3389
+#line 3441
}
-#line 3389
+#line 3441
int
-#line 3390
+#line 3442
ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3390
+#line 3442
{
-#line 3390
+#line 3442
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3390
+#line 3442
-#line 3390
+#line 3442
/* basic algorithm is:
-#line 3390
+#line 3442
* - ensure sane alignment of input data
-#line 3390
+#line 3442
* - copy (conversion happens automatically) input data
-#line 3390
+#line 3442
* to output
-#line 3390
+#line 3442
* - update xpp to point at next unconverted input, and tp to point
-#line 3390
+#line 3442
* at next location for converted output
-#line 3390
+#line 3442
*/
-#line 3390
+#line 3442
long i, j, ni;
-#line 3390
+#line 3442
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3390
+#line 3442
float *xp;
-#line 3390
+#line 3442
int nrange = 0; /* number of range errors */
-#line 3390
+#line 3442
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3390
+#line 3442
long cxp = (long) *((char**)xpp);
-#line 3390
+#line 3442
-#line 3390
+#line 3442
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3390
+#line 3442
/* sjl: manually stripmine so we can limit amount of
-#line 3390
+#line 3442
* vector work space reserved to LOOPCNT elements. Also
-#line 3390
+#line 3442
* makes vectorisation easy */
-#line 3390
+#line 3442
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3390
+#line 3442
ni=Min(nelems-j,LOOPCNT);
-#line 3390
+#line 3442
if (realign) {
-#line 3390
+#line 3442
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_FLOAT));
-#line 3390
+#line 3442
xp = tmp;
-#line 3390
+#line 3442
} else {
-#line 3390
+#line 3442
xp = (float *) *xpp;
-#line 3390
+#line 3442
}
-#line 3390
+#line 3442
/* copy the next block */
-#line 3390
+#line 3442
#pragma cdir loopcnt=LOOPCNT
-#line 3390
+#line 3442
#pragma cdir shortloop
-#line 3390
+#line 3442
for (i=0; i<ni; i++) {
-#line 3390
+#line 3442
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3390
+#line 3442
/* test for range errors (not always needed but do it anyway) */
-#line 3390
+#line 3442
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3390
+#line 3442
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3390
+#line 3442
nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
-#line 3390
+#line 3442
}
-#line 3390
+#line 3442
/* update xpp and tp */
-#line 3390
+#line 3442
if (realign) xp = (float *) *xpp;
-#line 3390
+#line 3442
xp += ni;
-#line 3390
+#line 3442
tp += ni;
-#line 3390
+#line 3442
*xpp = (void*)xp;
-#line 3390
+#line 3442
}
-#line 3390
+#line 3442
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3390
+#line 3442
-#line 3390
+#line 3442
#else /* not SX */
-#line 3390
+#line 3442
const char *xp = (const char *) *xpp;
-#line 3390
+#line 3442
int status = NC_NOERR;
-#line 3390
+#line 3442
-#line 3390
+#line 3442
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3390
+#line 3442
{
-#line 3390
+#line 3442
const int lstatus = ncx_get_float_ulonglong(xp, tp);
-#line 3390
+#line 3442
if (status == NC_NOERR) /* report the first encountered error */
-#line 3390
+#line 3442
status = lstatus;
-#line 3390
+#line 3442
}
-#line 3390
+#line 3442
-#line 3390
+#line 3442
*xpp = (const void *)xp;
-#line 3390
+#line 3442
return status;
-#line 3390
+#line 3442
#endif
-#line 3390
+#line 3442
}
-#line 3390
+#line 3442
int
@@ -26815,93 +28900,93 @@ ncx_putn_float_float(void **xpp, size_t nelems, const float *tp, void *fillp)
while (tp < end) {
const struct vax_single *const vsp =
-#line 3410
+#line 3462
(const struct vax_single *)ip;
-#line 3410
+#line 3462
struct ieee_single *const isp = (struct ieee_single *) (*xpp);
-#line 3410
+#line 3462
-#line 3410
+#line 3462
switch(vsp->exp){
-#line 3410
+#line 3462
case 0 :
-#line 3410
+#line 3462
/* all vax float with zero exponent map to zero */
-#line 3410
+#line 3462
*isp = min.ieee;
-#line 3410
+#line 3462
break;
-#line 3410
+#line 3462
case 2 :
-#line 3410
+#line 3462
case 1 :
-#line 3410
+#line 3462
{
-#line 3410
+#line 3462
/* These will map to subnormals */
-#line 3410
+#line 3462
unsigned mantissa = (vsp->mantissa1 << 16)
-#line 3410
+#line 3462
| vsp->mantissa2;
-#line 3410
+#line 3462
mantissa >>= 3 - vsp->exp;
-#line 3410
+#line 3462
mantissa += (1 << (20 + vsp->exp));
-#line 3410
+#line 3462
isp->mant_lo_lo = mantissa;
-#line 3410
+#line 3462
isp->mant_lo_hi = mantissa >> 8;
-#line 3410
+#line 3462
isp->mant_hi = mantissa >> 16;
-#line 3410
+#line 3462
isp->exp_lo = 0;
-#line 3410
+#line 3462
isp->exp_hi = 0;
-#line 3410
+#line 3462
}
-#line 3410
+#line 3462
break;
-#line 3410
+#line 3462
case 0xff : /* max.s.exp */
-#line 3410
+#line 3462
if (vsp->mantissa2 == max.s.mantissa2 &&
-#line 3410
+#line 3462
vsp->mantissa1 == max.s.mantissa1)
-#line 3410
+#line 3462
{
-#line 3410
+#line 3462
/* map largest vax float to ieee infinity */
-#line 3410
+#line 3462
*isp = max.ieee;
-#line 3410
+#line 3462
break;
-#line 3410
+#line 3462
} /* else, fall thru */
-#line 3410
+#line 3462
default :
-#line 3410
+#line 3462
{
-#line 3410
+#line 3462
unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
-#line 3410
+#line 3462
isp->exp_hi = exp >> 1;
-#line 3410
+#line 3462
isp->exp_lo = exp;
-#line 3410
+#line 3462
isp->mant_lo_lo = vsp->mantissa2;
-#line 3410
+#line 3462
isp->mant_lo_hi = vsp->mantissa2 >> 8;
-#line 3410
+#line 3462
isp->mant_hi = vsp->mantissa1;
-#line 3410
+#line 3462
}
-#line 3410
+#line 3462
}
-#line 3410
+#line 3462
-#line 3410
+#line 3462
isp->sign = vsp->sign;
-#line 3410
+#line 3462
tp++;
*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
@@ -26924,1394 +29009,1394 @@ ncx_putn_float_float(void **xpp, size_t nelems, const float *tp, void *fillp)
}
#endif
int
-#line 3431
+#line 3483
ncx_putn_float_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3431
+#line 3483
{
-#line 3431
+#line 3483
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3431
+#line 3483
-#line 3431
+#line 3483
/* basic algorithm is:
-#line 3431
+#line 3483
* - ensure sane alignment of output data
-#line 3431
+#line 3483
* - copy (conversion happens automatically) input data
-#line 3431
+#line 3483
* to output
-#line 3431
+#line 3483
* - update tp to point at next unconverted input, and xpp to point
-#line 3431
+#line 3483
* at next location for converted output
-#line 3431
+#line 3483
*/
-#line 3431
+#line 3483
long i, j, ni;
-#line 3431
+#line 3483
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3431
+#line 3483
float *xp;
-#line 3431
+#line 3483
int nrange = 0; /* number of range errors */
-#line 3431
+#line 3483
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3431
+#line 3483
long cxp = (long) *((char**)xpp);
-#line 3431
+#line 3483
-#line 3431
+#line 3483
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3431
+#line 3483
/* sjl: manually stripmine so we can limit amount of
-#line 3431
+#line 3483
* vector work space reserved to LOOPCNT elements. Also
-#line 3431
+#line 3483
* makes vectorisation easy */
-#line 3431
+#line 3483
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3431
+#line 3483
ni=Min(nelems-j,LOOPCNT);
-#line 3431
+#line 3483
if (realign) {
-#line 3431
+#line 3483
xp = tmp;
-#line 3431
+#line 3483
} else {
-#line 3431
+#line 3483
xp = (float *) *xpp;
-#line 3431
+#line 3483
}
-#line 3431
+#line 3483
/* copy the next block */
-#line 3431
+#line 3483
#pragma cdir loopcnt=LOOPCNT
-#line 3431
+#line 3483
#pragma cdir shortloop
-#line 3431
+#line 3483
for (i=0; i<ni; i++) {
-#line 3431
+#line 3483
/* the normal case: */
-#line 3431
+#line 3483
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3431
+#line 3483
/* test for range errors (not always needed but do it anyway) */
-#line 3431
+#line 3483
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3431
+#line 3483
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3431
+#line 3483
nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
-#line 3431
+#line 3483
}
-#line 3431
+#line 3483
/* copy workspace back if necessary */
-#line 3431
+#line 3483
if (realign) {
-#line 3431
+#line 3483
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3431
+#line 3483
xp = (float *) *xpp;
-#line 3431
+#line 3483
}
-#line 3431
+#line 3483
/* update xpp and tp */
-#line 3431
+#line 3483
xp += ni;
-#line 3431
+#line 3483
tp += ni;
-#line 3431
+#line 3483
*xpp = (void*)xp;
-#line 3431
+#line 3483
}
-#line 3431
+#line 3483
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3431
+#line 3483
-#line 3431
+#line 3483
#else /* not SX */
-#line 3431
+#line 3483
-#line 3431
+#line 3483
char *xp = (char *) *xpp;
-#line 3431
+#line 3483
int status = NC_NOERR;
-#line 3431
+#line 3483
-#line 3431
+#line 3483
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3431
+#line 3483
{
-#line 3431
+#line 3483
int lstatus = ncx_put_float_schar(xp, tp, fillp);
-#line 3431
+#line 3483
if (status == NC_NOERR) /* report the first encountered error */
-#line 3431
+#line 3483
status = lstatus;
-#line 3431
+#line 3483
}
-#line 3431
+#line 3483
-#line 3431
+#line 3483
*xpp = (void *)xp;
-#line 3431
+#line 3483
return status;
-#line 3431
+#line 3483
#endif
-#line 3431
+#line 3483
}
-#line 3431
+#line 3483
int
-#line 3432
+#line 3484
ncx_putn_float_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3432
+#line 3484
{
-#line 3432
+#line 3484
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3432
+#line 3484
-#line 3432
+#line 3484
/* basic algorithm is:
-#line 3432
+#line 3484
* - ensure sane alignment of output data
-#line 3432
+#line 3484
* - copy (conversion happens automatically) input data
-#line 3432
+#line 3484
* to output
-#line 3432
+#line 3484
* - update tp to point at next unconverted input, and xpp to point
-#line 3432
+#line 3484
* at next location for converted output
-#line 3432
+#line 3484
*/
-#line 3432
+#line 3484
long i, j, ni;
-#line 3432
+#line 3484
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3432
+#line 3484
float *xp;
-#line 3432
+#line 3484
int nrange = 0; /* number of range errors */
-#line 3432
+#line 3484
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3432
+#line 3484
long cxp = (long) *((char**)xpp);
-#line 3432
+#line 3484
-#line 3432
+#line 3484
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3432
+#line 3484
/* sjl: manually stripmine so we can limit amount of
-#line 3432
+#line 3484
* vector work space reserved to LOOPCNT elements. Also
-#line 3432
+#line 3484
* makes vectorisation easy */
-#line 3432
+#line 3484
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3432
+#line 3484
ni=Min(nelems-j,LOOPCNT);
-#line 3432
+#line 3484
if (realign) {
-#line 3432
+#line 3484
xp = tmp;
-#line 3432
+#line 3484
} else {
-#line 3432
+#line 3484
xp = (float *) *xpp;
-#line 3432
+#line 3484
}
-#line 3432
+#line 3484
/* copy the next block */
-#line 3432
+#line 3484
#pragma cdir loopcnt=LOOPCNT
-#line 3432
+#line 3484
#pragma cdir shortloop
-#line 3432
+#line 3484
for (i=0; i<ni; i++) {
-#line 3432
+#line 3484
/* the normal case: */
-#line 3432
+#line 3484
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3432
+#line 3484
/* test for range errors (not always needed but do it anyway) */
-#line 3432
+#line 3484
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3432
+#line 3484
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3432
+#line 3484
nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
-#line 3432
+#line 3484
}
-#line 3432
+#line 3484
/* copy workspace back if necessary */
-#line 3432
+#line 3484
if (realign) {
-#line 3432
+#line 3484
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3432
+#line 3484
xp = (float *) *xpp;
-#line 3432
+#line 3484
}
-#line 3432
+#line 3484
/* update xpp and tp */
-#line 3432
+#line 3484
xp += ni;
-#line 3432
+#line 3484
tp += ni;
-#line 3432
+#line 3484
*xpp = (void*)xp;
-#line 3432
+#line 3484
}
-#line 3432
+#line 3484
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3432
+#line 3484
-#line 3432
+#line 3484
#else /* not SX */
-#line 3432
+#line 3484
-#line 3432
+#line 3484
char *xp = (char *) *xpp;
-#line 3432
+#line 3484
int status = NC_NOERR;
-#line 3432
+#line 3484
-#line 3432
+#line 3484
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3432
+#line 3484
{
-#line 3432
+#line 3484
int lstatus = ncx_put_float_short(xp, tp, fillp);
-#line 3432
+#line 3484
if (status == NC_NOERR) /* report the first encountered error */
-#line 3432
+#line 3484
status = lstatus;
-#line 3432
+#line 3484
}
-#line 3432
+#line 3484
-#line 3432
+#line 3484
*xpp = (void *)xp;
-#line 3432
+#line 3484
return status;
-#line 3432
+#line 3484
#endif
-#line 3432
+#line 3484
}
-#line 3432
+#line 3484
int
-#line 3433
+#line 3485
ncx_putn_float_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3433
+#line 3485
{
-#line 3433
+#line 3485
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3433
+#line 3485
-#line 3433
+#line 3485
/* basic algorithm is:
-#line 3433
+#line 3485
* - ensure sane alignment of output data
-#line 3433
+#line 3485
* - copy (conversion happens automatically) input data
-#line 3433
+#line 3485
* to output
-#line 3433
+#line 3485
* - update tp to point at next unconverted input, and xpp to point
-#line 3433
+#line 3485
* at next location for converted output
-#line 3433
+#line 3485
*/
-#line 3433
+#line 3485
long i, j, ni;
-#line 3433
+#line 3485
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3433
+#line 3485
float *xp;
-#line 3433
+#line 3485
int nrange = 0; /* number of range errors */
-#line 3433
+#line 3485
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3433
+#line 3485
long cxp = (long) *((char**)xpp);
-#line 3433
+#line 3485
-#line 3433
+#line 3485
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3433
+#line 3485
/* sjl: manually stripmine so we can limit amount of
-#line 3433
+#line 3485
* vector work space reserved to LOOPCNT elements. Also
-#line 3433
+#line 3485
* makes vectorisation easy */
-#line 3433
+#line 3485
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3433
+#line 3485
ni=Min(nelems-j,LOOPCNT);
-#line 3433
+#line 3485
if (realign) {
-#line 3433
+#line 3485
xp = tmp;
-#line 3433
+#line 3485
} else {
-#line 3433
+#line 3485
xp = (float *) *xpp;
-#line 3433
+#line 3485
}
-#line 3433
+#line 3485
/* copy the next block */
-#line 3433
+#line 3485
#pragma cdir loopcnt=LOOPCNT
-#line 3433
+#line 3485
#pragma cdir shortloop
-#line 3433
+#line 3485
for (i=0; i<ni; i++) {
-#line 3433
+#line 3485
/* the normal case: */
-#line 3433
+#line 3485
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3433
+#line 3485
/* test for range errors (not always needed but do it anyway) */
-#line 3433
+#line 3485
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3433
+#line 3485
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3433
+#line 3485
nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
-#line 3433
+#line 3485
}
-#line 3433
+#line 3485
/* copy workspace back if necessary */
-#line 3433
+#line 3485
if (realign) {
-#line 3433
+#line 3485
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3433
+#line 3485
xp = (float *) *xpp;
-#line 3433
+#line 3485
}
-#line 3433
+#line 3485
/* update xpp and tp */
-#line 3433
+#line 3485
xp += ni;
-#line 3433
+#line 3485
tp += ni;
-#line 3433
+#line 3485
*xpp = (void*)xp;
-#line 3433
+#line 3485
}
-#line 3433
+#line 3485
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3433
+#line 3485
-#line 3433
+#line 3485
#else /* not SX */
-#line 3433
+#line 3485
-#line 3433
+#line 3485
char *xp = (char *) *xpp;
-#line 3433
+#line 3485
int status = NC_NOERR;
-#line 3433
+#line 3485
-#line 3433
+#line 3485
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3433
+#line 3485
{
-#line 3433
+#line 3485
int lstatus = ncx_put_float_int(xp, tp, fillp);
-#line 3433
+#line 3485
if (status == NC_NOERR) /* report the first encountered error */
-#line 3433
+#line 3485
status = lstatus;
-#line 3433
+#line 3485
}
-#line 3433
+#line 3485
-#line 3433
+#line 3485
*xpp = (void *)xp;
-#line 3433
+#line 3485
return status;
-#line 3433
+#line 3485
#endif
-#line 3433
+#line 3485
}
-#line 3433
+#line 3485
int
-#line 3434
+#line 3486
ncx_putn_float_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3434
+#line 3486
{
-#line 3434
+#line 3486
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3434
+#line 3486
-#line 3434
+#line 3486
/* basic algorithm is:
-#line 3434
+#line 3486
* - ensure sane alignment of output data
-#line 3434
+#line 3486
* - copy (conversion happens automatically) input data
-#line 3434
+#line 3486
* to output
-#line 3434
+#line 3486
* - update tp to point at next unconverted input, and xpp to point
-#line 3434
+#line 3486
* at next location for converted output
-#line 3434
+#line 3486
*/
-#line 3434
+#line 3486
long i, j, ni;
-#line 3434
+#line 3486
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3434
+#line 3486
float *xp;
-#line 3434
+#line 3486
int nrange = 0; /* number of range errors */
-#line 3434
+#line 3486
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3434
+#line 3486
long cxp = (long) *((char**)xpp);
-#line 3434
+#line 3486
-#line 3434
+#line 3486
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3434
+#line 3486
/* sjl: manually stripmine so we can limit amount of
-#line 3434
+#line 3486
* vector work space reserved to LOOPCNT elements. Also
-#line 3434
+#line 3486
* makes vectorisation easy */
-#line 3434
+#line 3486
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3434
+#line 3486
ni=Min(nelems-j,LOOPCNT);
-#line 3434
+#line 3486
if (realign) {
-#line 3434
+#line 3486
xp = tmp;
-#line 3434
+#line 3486
} else {
-#line 3434
+#line 3486
xp = (float *) *xpp;
-#line 3434
+#line 3486
}
-#line 3434
+#line 3486
/* copy the next block */
-#line 3434
+#line 3486
#pragma cdir loopcnt=LOOPCNT
-#line 3434
+#line 3486
#pragma cdir shortloop
-#line 3434
+#line 3486
for (i=0; i<ni; i++) {
-#line 3434
+#line 3486
/* the normal case: */
-#line 3434
+#line 3486
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3434
+#line 3486
/* test for range errors (not always needed but do it anyway) */
-#line 3434
+#line 3486
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3434
+#line 3486
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3434
+#line 3486
nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
-#line 3434
+#line 3486
}
-#line 3434
+#line 3486
/* copy workspace back if necessary */
-#line 3434
+#line 3486
if (realign) {
-#line 3434
+#line 3486
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3434
+#line 3486
xp = (float *) *xpp;
-#line 3434
+#line 3486
}
-#line 3434
+#line 3486
/* update xpp and tp */
-#line 3434
+#line 3486
xp += ni;
-#line 3434
+#line 3486
tp += ni;
-#line 3434
+#line 3486
*xpp = (void*)xp;
-#line 3434
+#line 3486
}
-#line 3434
+#line 3486
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3434
+#line 3486
-#line 3434
+#line 3486
#else /* not SX */
-#line 3434
+#line 3486
-#line 3434
+#line 3486
char *xp = (char *) *xpp;
-#line 3434
+#line 3486
int status = NC_NOERR;
-#line 3434
+#line 3486
-#line 3434
+#line 3486
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3434
+#line 3486
{
-#line 3434
+#line 3486
int lstatus = ncx_put_float_long(xp, tp, fillp);
-#line 3434
+#line 3486
if (status == NC_NOERR) /* report the first encountered error */
-#line 3434
+#line 3486
status = lstatus;
-#line 3434
+#line 3486
}
-#line 3434
+#line 3486
-#line 3434
+#line 3486
*xpp = (void *)xp;
-#line 3434
+#line 3486
return status;
-#line 3434
+#line 3486
#endif
-#line 3434
+#line 3486
}
-#line 3434
+#line 3486
int
-#line 3435
+#line 3487
ncx_putn_float_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3435
+#line 3487
{
-#line 3435
+#line 3487
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3435
+#line 3487
-#line 3435
+#line 3487
/* basic algorithm is:
-#line 3435
+#line 3487
* - ensure sane alignment of output data
-#line 3435
+#line 3487
* - copy (conversion happens automatically) input data
-#line 3435
+#line 3487
* to output
-#line 3435
+#line 3487
* - update tp to point at next unconverted input, and xpp to point
-#line 3435
+#line 3487
* at next location for converted output
-#line 3435
+#line 3487
*/
-#line 3435
+#line 3487
long i, j, ni;
-#line 3435
+#line 3487
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3435
+#line 3487
float *xp;
-#line 3435
+#line 3487
int nrange = 0; /* number of range errors */
-#line 3435
+#line 3487
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3435
+#line 3487
long cxp = (long) *((char**)xpp);
-#line 3435
+#line 3487
-#line 3435
+#line 3487
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3435
+#line 3487
/* sjl: manually stripmine so we can limit amount of
-#line 3435
+#line 3487
* vector work space reserved to LOOPCNT elements. Also
-#line 3435
+#line 3487
* makes vectorisation easy */
-#line 3435
+#line 3487
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3435
+#line 3487
ni=Min(nelems-j,LOOPCNT);
-#line 3435
+#line 3487
if (realign) {
-#line 3435
+#line 3487
xp = tmp;
-#line 3435
+#line 3487
} else {
-#line 3435
+#line 3487
xp = (float *) *xpp;
-#line 3435
+#line 3487
}
-#line 3435
+#line 3487
/* copy the next block */
-#line 3435
+#line 3487
#pragma cdir loopcnt=LOOPCNT
-#line 3435
+#line 3487
#pragma cdir shortloop
-#line 3435
+#line 3487
for (i=0; i<ni; i++) {
-#line 3435
+#line 3487
/* the normal case: */
-#line 3435
+#line 3487
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3435
+#line 3487
/* test for range errors (not always needed but do it anyway) */
-#line 3435
+#line 3487
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3435
+#line 3487
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3435
+#line 3487
nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
-#line 3435
+#line 3487
}
-#line 3435
+#line 3487
/* copy workspace back if necessary */
-#line 3435
+#line 3487
if (realign) {
-#line 3435
+#line 3487
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3435
+#line 3487
xp = (float *) *xpp;
-#line 3435
+#line 3487
}
-#line 3435
+#line 3487
/* update xpp and tp */
-#line 3435
+#line 3487
xp += ni;
-#line 3435
+#line 3487
tp += ni;
-#line 3435
+#line 3487
*xpp = (void*)xp;
-#line 3435
+#line 3487
}
-#line 3435
+#line 3487
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3435
+#line 3487
-#line 3435
+#line 3487
#else /* not SX */
-#line 3435
+#line 3487
-#line 3435
+#line 3487
char *xp = (char *) *xpp;
-#line 3435
+#line 3487
int status = NC_NOERR;
-#line 3435
+#line 3487
-#line 3435
+#line 3487
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3435
+#line 3487
{
-#line 3435
+#line 3487
int lstatus = ncx_put_float_double(xp, tp, fillp);
-#line 3435
+#line 3487
if (status == NC_NOERR) /* report the first encountered error */
-#line 3435
+#line 3487
status = lstatus;
-#line 3435
+#line 3487
}
-#line 3435
+#line 3487
-#line 3435
+#line 3487
*xpp = (void *)xp;
-#line 3435
+#line 3487
return status;
-#line 3435
+#line 3487
#endif
-#line 3435
+#line 3487
}
-#line 3435
+#line 3487
int
-#line 3436
+#line 3488
ncx_putn_float_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3436
+#line 3488
{
-#line 3436
+#line 3488
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3436
+#line 3488
-#line 3436
+#line 3488
/* basic algorithm is:
-#line 3436
+#line 3488
* - ensure sane alignment of output data
-#line 3436
+#line 3488
* - copy (conversion happens automatically) input data
-#line 3436
+#line 3488
* to output
-#line 3436
+#line 3488
* - update tp to point at next unconverted input, and xpp to point
-#line 3436
+#line 3488
* at next location for converted output
-#line 3436
+#line 3488
*/
-#line 3436
+#line 3488
long i, j, ni;
-#line 3436
+#line 3488
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3436
+#line 3488
float *xp;
-#line 3436
+#line 3488
int nrange = 0; /* number of range errors */
-#line 3436
+#line 3488
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3436
+#line 3488
long cxp = (long) *((char**)xpp);
-#line 3436
+#line 3488
-#line 3436
+#line 3488
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3436
+#line 3488
/* sjl: manually stripmine so we can limit amount of
-#line 3436
+#line 3488
* vector work space reserved to LOOPCNT elements. Also
-#line 3436
+#line 3488
* makes vectorisation easy */
-#line 3436
+#line 3488
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3436
+#line 3488
ni=Min(nelems-j,LOOPCNT);
-#line 3436
+#line 3488
if (realign) {
-#line 3436
+#line 3488
xp = tmp;
-#line 3436
+#line 3488
} else {
-#line 3436
+#line 3488
xp = (float *) *xpp;
-#line 3436
+#line 3488
}
-#line 3436
+#line 3488
/* copy the next block */
-#line 3436
+#line 3488
#pragma cdir loopcnt=LOOPCNT
-#line 3436
+#line 3488
#pragma cdir shortloop
-#line 3436
+#line 3488
for (i=0; i<ni; i++) {
-#line 3436
+#line 3488
/* the normal case: */
-#line 3436
+#line 3488
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3436
+#line 3488
/* test for range errors (not always needed but do it anyway) */
-#line 3436
+#line 3488
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3436
+#line 3488
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3436
+#line 3488
nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
-#line 3436
+#line 3488
}
-#line 3436
+#line 3488
/* copy workspace back if necessary */
-#line 3436
+#line 3488
if (realign) {
-#line 3436
+#line 3488
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3436
+#line 3488
xp = (float *) *xpp;
-#line 3436
+#line 3488
}
-#line 3436
+#line 3488
/* update xpp and tp */
-#line 3436
+#line 3488
xp += ni;
-#line 3436
+#line 3488
tp += ni;
-#line 3436
+#line 3488
*xpp = (void*)xp;
-#line 3436
+#line 3488
}
-#line 3436
+#line 3488
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3436
+#line 3488
-#line 3436
+#line 3488
#else /* not SX */
-#line 3436
+#line 3488
-#line 3436
+#line 3488
char *xp = (char *) *xpp;
-#line 3436
+#line 3488
int status = NC_NOERR;
-#line 3436
+#line 3488
-#line 3436
+#line 3488
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3436
+#line 3488
{
-#line 3436
+#line 3488
int lstatus = ncx_put_float_longlong(xp, tp, fillp);
-#line 3436
+#line 3488
if (status == NC_NOERR) /* report the first encountered error */
-#line 3436
+#line 3488
status = lstatus;
-#line 3436
+#line 3488
}
-#line 3436
+#line 3488
-#line 3436
+#line 3488
*xpp = (void *)xp;
-#line 3436
+#line 3488
return status;
-#line 3436
+#line 3488
#endif
-#line 3436
+#line 3488
}
-#line 3436
+#line 3488
int
-#line 3437
+#line 3489
ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3437
+#line 3489
{
-#line 3437
+#line 3489
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3437
+#line 3489
-#line 3437
+#line 3489
/* basic algorithm is:
-#line 3437
+#line 3489
* - ensure sane alignment of output data
-#line 3437
+#line 3489
* - copy (conversion happens automatically) input data
-#line 3437
+#line 3489
* to output
-#line 3437
+#line 3489
* - update tp to point at next unconverted input, and xpp to point
-#line 3437
+#line 3489
* at next location for converted output
-#line 3437
+#line 3489
*/
-#line 3437
+#line 3489
long i, j, ni;
-#line 3437
+#line 3489
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3437
+#line 3489
float *xp;
-#line 3437
+#line 3489
int nrange = 0; /* number of range errors */
-#line 3437
+#line 3489
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3437
+#line 3489
long cxp = (long) *((char**)xpp);
-#line 3437
+#line 3489
-#line 3437
+#line 3489
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3437
+#line 3489
/* sjl: manually stripmine so we can limit amount of
-#line 3437
+#line 3489
* vector work space reserved to LOOPCNT elements. Also
-#line 3437
+#line 3489
* makes vectorisation easy */
-#line 3437
+#line 3489
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3437
+#line 3489
ni=Min(nelems-j,LOOPCNT);
-#line 3437
+#line 3489
if (realign) {
-#line 3437
+#line 3489
xp = tmp;
-#line 3437
+#line 3489
} else {
-#line 3437
+#line 3489
xp = (float *) *xpp;
-#line 3437
+#line 3489
}
-#line 3437
+#line 3489
/* copy the next block */
-#line 3437
+#line 3489
#pragma cdir loopcnt=LOOPCNT
-#line 3437
+#line 3489
#pragma cdir shortloop
-#line 3437
+#line 3489
for (i=0; i<ni; i++) {
-#line 3437
+#line 3489
/* the normal case: */
-#line 3437
+#line 3489
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3437
+#line 3489
/* test for range errors (not always needed but do it anyway) */
-#line 3437
+#line 3489
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3437
+#line 3489
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3437
+#line 3489
nrange += tp[i] > X_FLOAT_MAX ;
-#line 3437
+#line 3489
}
-#line 3437
+#line 3489
/* copy workspace back if necessary */
-#line 3437
+#line 3489
if (realign) {
-#line 3437
+#line 3489
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3437
+#line 3489
xp = (float *) *xpp;
-#line 3437
+#line 3489
}
-#line 3437
+#line 3489
/* update xpp and tp */
-#line 3437
+#line 3489
xp += ni;
-#line 3437
+#line 3489
tp += ni;
-#line 3437
+#line 3489
*xpp = (void*)xp;
-#line 3437
+#line 3489
}
-#line 3437
+#line 3489
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3437
+#line 3489
-#line 3437
+#line 3489
#else /* not SX */
-#line 3437
+#line 3489
-#line 3437
+#line 3489
char *xp = (char *) *xpp;
-#line 3437
+#line 3489
int status = NC_NOERR;
-#line 3437
+#line 3489
-#line 3437
+#line 3489
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3437
+#line 3489
{
-#line 3437
+#line 3489
int lstatus = ncx_put_float_uchar(xp, tp, fillp);
-#line 3437
+#line 3489
if (status == NC_NOERR) /* report the first encountered error */
-#line 3437
+#line 3489
status = lstatus;
-#line 3437
+#line 3489
}
-#line 3437
+#line 3489
-#line 3437
+#line 3489
*xpp = (void *)xp;
-#line 3437
+#line 3489
return status;
-#line 3437
+#line 3489
#endif
-#line 3437
+#line 3489
}
-#line 3437
+#line 3489
int
-#line 3438
+#line 3490
ncx_putn_float_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3438
+#line 3490
{
-#line 3438
+#line 3490
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3438
+#line 3490
-#line 3438
+#line 3490
/* basic algorithm is:
-#line 3438
+#line 3490
* - ensure sane alignment of output data
-#line 3438
+#line 3490
* - copy (conversion happens automatically) input data
-#line 3438
+#line 3490
* to output
-#line 3438
+#line 3490
* - update tp to point at next unconverted input, and xpp to point
-#line 3438
+#line 3490
* at next location for converted output
-#line 3438
+#line 3490
*/
-#line 3438
+#line 3490
long i, j, ni;
-#line 3438
+#line 3490
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3438
+#line 3490
float *xp;
-#line 3438
+#line 3490
int nrange = 0; /* number of range errors */
-#line 3438
+#line 3490
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3438
+#line 3490
long cxp = (long) *((char**)xpp);
-#line 3438
+#line 3490
-#line 3438
+#line 3490
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3438
+#line 3490
/* sjl: manually stripmine so we can limit amount of
-#line 3438
+#line 3490
* vector work space reserved to LOOPCNT elements. Also
-#line 3438
+#line 3490
* makes vectorisation easy */
-#line 3438
+#line 3490
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3438
+#line 3490
ni=Min(nelems-j,LOOPCNT);
-#line 3438
+#line 3490
if (realign) {
-#line 3438
+#line 3490
xp = tmp;
-#line 3438
+#line 3490
} else {
-#line 3438
+#line 3490
xp = (float *) *xpp;
-#line 3438
+#line 3490
}
-#line 3438
+#line 3490
/* copy the next block */
-#line 3438
+#line 3490
#pragma cdir loopcnt=LOOPCNT
-#line 3438
+#line 3490
#pragma cdir shortloop
-#line 3438
+#line 3490
for (i=0; i<ni; i++) {
-#line 3438
+#line 3490
/* the normal case: */
-#line 3438
+#line 3490
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3438
+#line 3490
/* test for range errors (not always needed but do it anyway) */
-#line 3438
+#line 3490
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3438
+#line 3490
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3438
+#line 3490
nrange += tp[i] > X_FLOAT_MAX ;
-#line 3438
+#line 3490
}
-#line 3438
+#line 3490
/* copy workspace back if necessary */
-#line 3438
+#line 3490
if (realign) {
-#line 3438
+#line 3490
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3438
+#line 3490
xp = (float *) *xpp;
-#line 3438
+#line 3490
}
-#line 3438
+#line 3490
/* update xpp and tp */
-#line 3438
+#line 3490
xp += ni;
-#line 3438
+#line 3490
tp += ni;
-#line 3438
+#line 3490
*xpp = (void*)xp;
-#line 3438
+#line 3490
}
-#line 3438
+#line 3490
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3438
+#line 3490
-#line 3438
+#line 3490
#else /* not SX */
-#line 3438
+#line 3490
-#line 3438
+#line 3490
char *xp = (char *) *xpp;
-#line 3438
+#line 3490
int status = NC_NOERR;
-#line 3438
+#line 3490
-#line 3438
+#line 3490
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3438
+#line 3490
{
-#line 3438
+#line 3490
int lstatus = ncx_put_float_ushort(xp, tp, fillp);
-#line 3438
+#line 3490
if (status == NC_NOERR) /* report the first encountered error */
-#line 3438
+#line 3490
status = lstatus;
-#line 3438
+#line 3490
}
-#line 3438
+#line 3490
-#line 3438
+#line 3490
*xpp = (void *)xp;
-#line 3438
+#line 3490
return status;
-#line 3438
+#line 3490
#endif
-#line 3438
+#line 3490
}
-#line 3438
+#line 3490
int
-#line 3439
+#line 3491
ncx_putn_float_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3439
+#line 3491
{
-#line 3439
+#line 3491
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3439
+#line 3491
-#line 3439
+#line 3491
/* basic algorithm is:
-#line 3439
+#line 3491
* - ensure sane alignment of output data
-#line 3439
+#line 3491
* - copy (conversion happens automatically) input data
-#line 3439
+#line 3491
* to output
-#line 3439
+#line 3491
* - update tp to point at next unconverted input, and xpp to point
-#line 3439
+#line 3491
* at next location for converted output
-#line 3439
+#line 3491
*/
-#line 3439
+#line 3491
long i, j, ni;
-#line 3439
+#line 3491
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3439
+#line 3491
float *xp;
-#line 3439
+#line 3491
int nrange = 0; /* number of range errors */
-#line 3439
+#line 3491
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3439
+#line 3491
long cxp = (long) *((char**)xpp);
-#line 3439
+#line 3491
-#line 3439
+#line 3491
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3439
+#line 3491
/* sjl: manually stripmine so we can limit amount of
-#line 3439
+#line 3491
* vector work space reserved to LOOPCNT elements. Also
-#line 3439
+#line 3491
* makes vectorisation easy */
-#line 3439
+#line 3491
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3439
+#line 3491
ni=Min(nelems-j,LOOPCNT);
-#line 3439
+#line 3491
if (realign) {
-#line 3439
+#line 3491
xp = tmp;
-#line 3439
+#line 3491
} else {
-#line 3439
+#line 3491
xp = (float *) *xpp;
-#line 3439
+#line 3491
}
-#line 3439
+#line 3491
/* copy the next block */
-#line 3439
+#line 3491
#pragma cdir loopcnt=LOOPCNT
-#line 3439
+#line 3491
#pragma cdir shortloop
-#line 3439
+#line 3491
for (i=0; i<ni; i++) {
-#line 3439
+#line 3491
/* the normal case: */
-#line 3439
+#line 3491
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3439
+#line 3491
/* test for range errors (not always needed but do it anyway) */
-#line 3439
+#line 3491
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3439
+#line 3491
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3439
+#line 3491
nrange += tp[i] > X_FLOAT_MAX ;
-#line 3439
+#line 3491
}
-#line 3439
+#line 3491
/* copy workspace back if necessary */
-#line 3439
+#line 3491
if (realign) {
-#line 3439
+#line 3491
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3439
+#line 3491
xp = (float *) *xpp;
-#line 3439
+#line 3491
}
-#line 3439
+#line 3491
/* update xpp and tp */
-#line 3439
+#line 3491
xp += ni;
-#line 3439
+#line 3491
tp += ni;
-#line 3439
+#line 3491
*xpp = (void*)xp;
-#line 3439
+#line 3491
}
-#line 3439
+#line 3491
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3439
+#line 3491
-#line 3439
+#line 3491
#else /* not SX */
-#line 3439
+#line 3491
-#line 3439
+#line 3491
char *xp = (char *) *xpp;
-#line 3439
+#line 3491
int status = NC_NOERR;
-#line 3439
+#line 3491
-#line 3439
+#line 3491
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3439
+#line 3491
{
-#line 3439
+#line 3491
int lstatus = ncx_put_float_uint(xp, tp, fillp);
-#line 3439
+#line 3491
if (status == NC_NOERR) /* report the first encountered error */
-#line 3439
+#line 3491
status = lstatus;
-#line 3439
+#line 3491
}
-#line 3439
+#line 3491
-#line 3439
+#line 3491
*xpp = (void *)xp;
-#line 3439
+#line 3491
return status;
-#line 3439
+#line 3491
#endif
-#line 3439
+#line 3491
}
-#line 3439
+#line 3491
int
-#line 3440
+#line 3492
ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3440
+#line 3492
{
-#line 3440
+#line 3492
#if defined(_SX) && _SX != 0 && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 3440
+#line 3492
-#line 3440
+#line 3492
/* basic algorithm is:
-#line 3440
+#line 3492
* - ensure sane alignment of output data
-#line 3440
+#line 3492
* - copy (conversion happens automatically) input data
-#line 3440
+#line 3492
* to output
-#line 3440
+#line 3492
* - update tp to point at next unconverted input, and xpp to point
-#line 3440
+#line 3492
* at next location for converted output
-#line 3440
+#line 3492
*/
-#line 3440
+#line 3492
long i, j, ni;
-#line 3440
+#line 3492
float tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3440
+#line 3492
float *xp;
-#line 3440
+#line 3492
int nrange = 0; /* number of range errors */
-#line 3440
+#line 3492
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3440
+#line 3492
long cxp = (long) *((char**)xpp);
-#line 3440
+#line 3492
-#line 3440
+#line 3492
realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 3440
+#line 3492
/* sjl: manually stripmine so we can limit amount of
-#line 3440
+#line 3492
* vector work space reserved to LOOPCNT elements. Also
-#line 3440
+#line 3492
* makes vectorisation easy */
-#line 3440
+#line 3492
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3440
+#line 3492
ni=Min(nelems-j,LOOPCNT);
-#line 3440
+#line 3492
if (realign) {
-#line 3440
+#line 3492
xp = tmp;
-#line 3440
+#line 3492
} else {
-#line 3440
+#line 3492
xp = (float *) *xpp;
-#line 3440
+#line 3492
}
-#line 3440
+#line 3492
/* copy the next block */
-#line 3440
+#line 3492
#pragma cdir loopcnt=LOOPCNT
-#line 3440
+#line 3492
#pragma cdir shortloop
-#line 3440
+#line 3492
for (i=0; i<ni; i++) {
-#line 3440
+#line 3492
/* the normal case: */
-#line 3440
+#line 3492
xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 3440
+#line 3492
/* test for range errors (not always needed but do it anyway) */
-#line 3440
+#line 3492
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3440
+#line 3492
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3440
+#line 3492
nrange += tp[i] > X_FLOAT_MAX ;
-#line 3440
+#line 3492
}
-#line 3440
+#line 3492
/* copy workspace back if necessary */
-#line 3440
+#line 3492
if (realign) {
-#line 3440
+#line 3492
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_FLOAT);
-#line 3440
+#line 3492
xp = (float *) *xpp;
-#line 3440
+#line 3492
}
-#line 3440
+#line 3492
/* update xpp and tp */
-#line 3440
+#line 3492
xp += ni;
-#line 3440
+#line 3492
tp += ni;
-#line 3440
+#line 3492
*xpp = (void*)xp;
-#line 3440
+#line 3492
}
-#line 3440
+#line 3492
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3440
+#line 3492
-#line 3440
+#line 3492
#else /* not SX */
-#line 3440
+#line 3492
-#line 3440
+#line 3492
char *xp = (char *) *xpp;
-#line 3440
+#line 3492
int status = NC_NOERR;
-#line 3440
+#line 3492
-#line 3440
+#line 3492
for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 3440
+#line 3492
{
-#line 3440
+#line 3492
int lstatus = ncx_put_float_ulonglong(xp, tp, fillp);
-#line 3440
+#line 3492
if (status == NC_NOERR) /* report the first encountered error */
-#line 3440
+#line 3492
status = lstatus;
-#line 3440
+#line 3492
}
-#line 3440
+#line 3492
-#line 3440
+#line 3492
*xpp = (void *)xp;
-#line 3440
+#line 3492
return status;
-#line 3440
+#line 3492
#endif
-#line 3440
+#line 3492
}
-#line 3440
+#line 3492
/* double --------------------------------------------------------------------*/
@@ -28338,87 +30423,87 @@ ncx_getn_double_double(const void **xpp, size_t ndoubles, double *ip)
while (ip < end)
{
struct vax_double *const vdp =
-#line 3465
+#line 3517
(struct vax_double *)ip;
-#line 3465
+#line 3517
const struct ieee_double *const idp =
-#line 3465
+#line 3517
(const struct ieee_double *) (*xpp);
-#line 3465
+#line 3517
{
-#line 3465
+#line 3517
const struct dbl_limits *lim;
-#line 3465
+#line 3517
int ii;
-#line 3465
+#line 3517
for (ii = 0, lim = dbl_limits;
-#line 3465
+#line 3517
ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
-#line 3465
+#line 3517
ii++, lim++)
-#line 3465
+#line 3517
{
-#line 3465
+#line 3517
if ((idp->mant_lo == lim->ieee.mant_lo)
-#line 3465
+#line 3517
&& (idp->mant_4 == lim->ieee.mant_4)
-#line 3465
+#line 3517
&& (idp->mant_5 == lim->ieee.mant_5)
-#line 3465
+#line 3517
&& (idp->mant_6 == lim->ieee.mant_6)
-#line 3465
+#line 3517
&& (idp->exp_lo == lim->ieee.exp_lo)
-#line 3465
+#line 3517
&& (idp->exp_hi == lim->ieee.exp_hi)
-#line 3465
+#line 3517
)
-#line 3465
+#line 3517
{
-#line 3465
+#line 3517
*vdp = lim->d;
-#line 3465
+#line 3517
goto doneit;
-#line 3465
+#line 3517
}
-#line 3465
+#line 3517
}
-#line 3465
+#line 3517
}
-#line 3465
+#line 3517
{
-#line 3465
+#line 3517
unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
-#line 3465
+#line 3517
vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
-#line 3465
+#line 3517
}
-#line 3465
+#line 3517
{
-#line 3465
+#line 3517
unsigned mant_hi = ((idp->mant_6 << 16)
-#line 3465
+#line 3517
| (idp->mant_5 << 8)
-#line 3465
+#line 3517
| idp->mant_4);
-#line 3465
+#line 3517
unsigned mant_lo = SWAP4(idp->mant_lo);
-#line 3465
+#line 3517
vdp->mantissa1 = (mant_hi >> 13);
-#line 3465
+#line 3517
vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
-#line 3465
+#line 3517
| (mant_lo >> 29);
-#line 3465
+#line 3517
vdp->mantissa3 = (mant_lo >> 13);
-#line 3465
+#line 3517
vdp->mantissa4 = (mant_lo << 3);
-#line 3465
+#line 3517
}
-#line 3465
+#line 3517
doneit:
-#line 3465
+#line 3517
vdp->sign = idp->sign;
-#line 3465
+#line 3517
ip++;
*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
@@ -28445,1294 +30530,1294 @@ ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
}
#endif
int
-#line 3490
+#line 3542
ncx_getn_double_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3490
+#line 3542
{
-#line 3490
+#line 3542
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3490
+#line 3542
-#line 3490
+#line 3542
/* basic algorithm is:
-#line 3490
+#line 3542
* - ensure sane alignment of input data
-#line 3490
+#line 3542
* - copy (conversion happens automatically) input data
-#line 3490
+#line 3542
* to output
-#line 3490
+#line 3542
* - update xpp to point at next unconverted input, and tp to point
-#line 3490
+#line 3542
* at next location for converted output
-#line 3490
+#line 3542
*/
-#line 3490
+#line 3542
long i, j, ni;
-#line 3490
+#line 3542
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3490
+#line 3542
double *xp;
-#line 3490
+#line 3542
int nrange = 0; /* number of range errors */
-#line 3490
+#line 3542
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3490
+#line 3542
long cxp = (long) *((char**)xpp);
-#line 3490
+#line 3542
-#line 3490
+#line 3542
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3490
+#line 3542
/* sjl: manually stripmine so we can limit amount of
-#line 3490
+#line 3542
* vector work space reserved to LOOPCNT elements. Also
-#line 3490
+#line 3542
* makes vectorisation easy */
-#line 3490
+#line 3542
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3490
+#line 3542
ni=Min(nelems-j,LOOPCNT);
-#line 3490
+#line 3542
if (realign) {
-#line 3490
+#line 3542
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3490
+#line 3542
xp = tmp;
-#line 3490
+#line 3542
} else {
-#line 3490
+#line 3542
xp = (double *) *xpp;
-#line 3490
+#line 3542
}
-#line 3490
+#line 3542
/* copy the next block */
-#line 3490
+#line 3542
#pragma cdir loopcnt=LOOPCNT
-#line 3490
+#line 3542
#pragma cdir shortloop
-#line 3490
+#line 3542
for (i=0; i<ni; i++) {
-#line 3490
+#line 3542
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3490
+#line 3542
/* test for range errors (not always needed but do it anyway) */
-#line 3490
+#line 3542
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3490
+#line 3542
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3490
+#line 3542
nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
-#line 3490
+#line 3542
}
-#line 3490
+#line 3542
/* update xpp and tp */
-#line 3490
+#line 3542
if (realign) xp = (double *) *xpp;
-#line 3490
+#line 3542
xp += ni;
-#line 3490
+#line 3542
tp += ni;
-#line 3490
+#line 3542
*xpp = (void*)xp;
-#line 3490
+#line 3542
}
-#line 3490
+#line 3542
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3490
+#line 3542
-#line 3490
+#line 3542
#else /* not SX */
-#line 3490
+#line 3542
const char *xp = (const char *) *xpp;
-#line 3490
+#line 3542
int status = NC_NOERR;
-#line 3490
+#line 3542
-#line 3490
+#line 3542
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3490
+#line 3542
{
-#line 3490
+#line 3542
const int lstatus = ncx_get_double_schar(xp, tp);
-#line 3490
+#line 3542
if (status == NC_NOERR) /* report the first encountered error */
-#line 3490
+#line 3542
status = lstatus;
-#line 3490
+#line 3542
}
-#line 3490
+#line 3542
-#line 3490
+#line 3542
*xpp = (const void *)xp;
-#line 3490
+#line 3542
return status;
-#line 3490
+#line 3542
#endif
-#line 3490
+#line 3542
}
-#line 3490
+#line 3542
int
-#line 3491
+#line 3543
ncx_getn_double_short(const void **xpp, size_t nelems, short *tp)
-#line 3491
+#line 3543
{
-#line 3491
+#line 3543
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3491
+#line 3543
-#line 3491
+#line 3543
/* basic algorithm is:
-#line 3491
+#line 3543
* - ensure sane alignment of input data
-#line 3491
+#line 3543
* - copy (conversion happens automatically) input data
-#line 3491
+#line 3543
* to output
-#line 3491
+#line 3543
* - update xpp to point at next unconverted input, and tp to point
-#line 3491
+#line 3543
* at next location for converted output
-#line 3491
+#line 3543
*/
-#line 3491
+#line 3543
long i, j, ni;
-#line 3491
+#line 3543
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3491
+#line 3543
double *xp;
-#line 3491
+#line 3543
int nrange = 0; /* number of range errors */
-#line 3491
+#line 3543
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3491
+#line 3543
long cxp = (long) *((char**)xpp);
-#line 3491
+#line 3543
-#line 3491
+#line 3543
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3491
+#line 3543
/* sjl: manually stripmine so we can limit amount of
-#line 3491
+#line 3543
* vector work space reserved to LOOPCNT elements. Also
-#line 3491
+#line 3543
* makes vectorisation easy */
-#line 3491
+#line 3543
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3491
+#line 3543
ni=Min(nelems-j,LOOPCNT);
-#line 3491
+#line 3543
if (realign) {
-#line 3491
+#line 3543
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3491
+#line 3543
xp = tmp;
-#line 3491
+#line 3543
} else {
-#line 3491
+#line 3543
xp = (double *) *xpp;
-#line 3491
+#line 3543
}
-#line 3491
+#line 3543
/* copy the next block */
-#line 3491
+#line 3543
#pragma cdir loopcnt=LOOPCNT
-#line 3491
+#line 3543
#pragma cdir shortloop
-#line 3491
+#line 3543
for (i=0; i<ni; i++) {
-#line 3491
+#line 3543
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3491
+#line 3543
/* test for range errors (not always needed but do it anyway) */
-#line 3491
+#line 3543
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3491
+#line 3543
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3491
+#line 3543
nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
-#line 3491
+#line 3543
}
-#line 3491
+#line 3543
/* update xpp and tp */
-#line 3491
+#line 3543
if (realign) xp = (double *) *xpp;
-#line 3491
+#line 3543
xp += ni;
-#line 3491
+#line 3543
tp += ni;
-#line 3491
+#line 3543
*xpp = (void*)xp;
-#line 3491
+#line 3543
}
-#line 3491
+#line 3543
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3491
+#line 3543
-#line 3491
+#line 3543
#else /* not SX */
-#line 3491
+#line 3543
const char *xp = (const char *) *xpp;
-#line 3491
+#line 3543
int status = NC_NOERR;
-#line 3491
+#line 3543
-#line 3491
+#line 3543
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3491
+#line 3543
{
-#line 3491
+#line 3543
const int lstatus = ncx_get_double_short(xp, tp);
-#line 3491
+#line 3543
if (status == NC_NOERR) /* report the first encountered error */
-#line 3491
+#line 3543
status = lstatus;
-#line 3491
+#line 3543
}
-#line 3491
+#line 3543
-#line 3491
+#line 3543
*xpp = (const void *)xp;
-#line 3491
+#line 3543
return status;
-#line 3491
+#line 3543
#endif
-#line 3491
+#line 3543
}
-#line 3491
+#line 3543
int
-#line 3492
+#line 3544
ncx_getn_double_int(const void **xpp, size_t nelems, int *tp)
-#line 3492
+#line 3544
{
-#line 3492
+#line 3544
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3492
+#line 3544
-#line 3492
+#line 3544
/* basic algorithm is:
-#line 3492
+#line 3544
* - ensure sane alignment of input data
-#line 3492
+#line 3544
* - copy (conversion happens automatically) input data
-#line 3492
+#line 3544
* to output
-#line 3492
+#line 3544
* - update xpp to point at next unconverted input, and tp to point
-#line 3492
+#line 3544
* at next location for converted output
-#line 3492
+#line 3544
*/
-#line 3492
+#line 3544
long i, j, ni;
-#line 3492
+#line 3544
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3492
+#line 3544
double *xp;
-#line 3492
+#line 3544
int nrange = 0; /* number of range errors */
-#line 3492
+#line 3544
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3492
+#line 3544
long cxp = (long) *((char**)xpp);
-#line 3492
+#line 3544
-#line 3492
+#line 3544
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3492
+#line 3544
/* sjl: manually stripmine so we can limit amount of
-#line 3492
+#line 3544
* vector work space reserved to LOOPCNT elements. Also
-#line 3492
+#line 3544
* makes vectorisation easy */
-#line 3492
+#line 3544
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3492
+#line 3544
ni=Min(nelems-j,LOOPCNT);
-#line 3492
+#line 3544
if (realign) {
-#line 3492
+#line 3544
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3492
+#line 3544
xp = tmp;
-#line 3492
+#line 3544
} else {
-#line 3492
+#line 3544
xp = (double *) *xpp;
-#line 3492
+#line 3544
}
-#line 3492
+#line 3544
/* copy the next block */
-#line 3492
+#line 3544
#pragma cdir loopcnt=LOOPCNT
-#line 3492
+#line 3544
#pragma cdir shortloop
-#line 3492
+#line 3544
for (i=0; i<ni; i++) {
-#line 3492
+#line 3544
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3492
+#line 3544
/* test for range errors (not always needed but do it anyway) */
-#line 3492
+#line 3544
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3492
+#line 3544
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3492
+#line 3544
nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
-#line 3492
+#line 3544
}
-#line 3492
+#line 3544
/* update xpp and tp */
-#line 3492
+#line 3544
if (realign) xp = (double *) *xpp;
-#line 3492
+#line 3544
xp += ni;
-#line 3492
+#line 3544
tp += ni;
-#line 3492
+#line 3544
*xpp = (void*)xp;
-#line 3492
+#line 3544
}
-#line 3492
+#line 3544
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3492
+#line 3544
-#line 3492
+#line 3544
#else /* not SX */
-#line 3492
+#line 3544
const char *xp = (const char *) *xpp;
-#line 3492
+#line 3544
int status = NC_NOERR;
-#line 3492
+#line 3544
-#line 3492
+#line 3544
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3492
+#line 3544
{
-#line 3492
+#line 3544
const int lstatus = ncx_get_double_int(xp, tp);
-#line 3492
+#line 3544
if (status == NC_NOERR) /* report the first encountered error */
-#line 3492
+#line 3544
status = lstatus;
-#line 3492
+#line 3544
}
-#line 3492
+#line 3544
-#line 3492
+#line 3544
*xpp = (const void *)xp;
-#line 3492
+#line 3544
return status;
-#line 3492
+#line 3544
#endif
-#line 3492
+#line 3544
}
-#line 3492
+#line 3544
int
-#line 3493
+#line 3545
ncx_getn_double_long(const void **xpp, size_t nelems, long *tp)
-#line 3493
+#line 3545
{
-#line 3493
+#line 3545
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3493
+#line 3545
-#line 3493
+#line 3545
/* basic algorithm is:
-#line 3493
+#line 3545
* - ensure sane alignment of input data
-#line 3493
+#line 3545
* - copy (conversion happens automatically) input data
-#line 3493
+#line 3545
* to output
-#line 3493
+#line 3545
* - update xpp to point at next unconverted input, and tp to point
-#line 3493
+#line 3545
* at next location for converted output
-#line 3493
+#line 3545
*/
-#line 3493
+#line 3545
long i, j, ni;
-#line 3493
+#line 3545
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3493
+#line 3545
double *xp;
-#line 3493
+#line 3545
int nrange = 0; /* number of range errors */
-#line 3493
+#line 3545
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3493
+#line 3545
long cxp = (long) *((char**)xpp);
-#line 3493
+#line 3545
-#line 3493
+#line 3545
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3493
+#line 3545
/* sjl: manually stripmine so we can limit amount of
-#line 3493
+#line 3545
* vector work space reserved to LOOPCNT elements. Also
-#line 3493
+#line 3545
* makes vectorisation easy */
-#line 3493
+#line 3545
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3493
+#line 3545
ni=Min(nelems-j,LOOPCNT);
-#line 3493
+#line 3545
if (realign) {
-#line 3493
+#line 3545
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3493
+#line 3545
xp = tmp;
-#line 3493
+#line 3545
} else {
-#line 3493
+#line 3545
xp = (double *) *xpp;
-#line 3493
+#line 3545
}
-#line 3493
+#line 3545
/* copy the next block */
-#line 3493
+#line 3545
#pragma cdir loopcnt=LOOPCNT
-#line 3493
+#line 3545
#pragma cdir shortloop
-#line 3493
+#line 3545
for (i=0; i<ni; i++) {
-#line 3493
+#line 3545
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3493
+#line 3545
/* test for range errors (not always needed but do it anyway) */
-#line 3493
+#line 3545
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3493
+#line 3545
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3493
+#line 3545
nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
-#line 3493
+#line 3545
}
-#line 3493
+#line 3545
/* update xpp and tp */
-#line 3493
+#line 3545
if (realign) xp = (double *) *xpp;
-#line 3493
+#line 3545
xp += ni;
-#line 3493
+#line 3545
tp += ni;
-#line 3493
+#line 3545
*xpp = (void*)xp;
-#line 3493
+#line 3545
}
-#line 3493
+#line 3545
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3493
+#line 3545
-#line 3493
+#line 3545
#else /* not SX */
-#line 3493
+#line 3545
const char *xp = (const char *) *xpp;
-#line 3493
+#line 3545
int status = NC_NOERR;
-#line 3493
+#line 3545
-#line 3493
+#line 3545
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3493
+#line 3545
{
-#line 3493
+#line 3545
const int lstatus = ncx_get_double_long(xp, tp);
-#line 3493
+#line 3545
if (status == NC_NOERR) /* report the first encountered error */
-#line 3493
+#line 3545
status = lstatus;
-#line 3493
+#line 3545
}
-#line 3493
+#line 3545
-#line 3493
+#line 3545
*xpp = (const void *)xp;
-#line 3493
+#line 3545
return status;
-#line 3493
+#line 3545
#endif
-#line 3493
+#line 3545
}
-#line 3493
+#line 3545
int
-#line 3494
+#line 3546
ncx_getn_double_float(const void **xpp, size_t nelems, float *tp)
-#line 3494
+#line 3546
{
-#line 3494
+#line 3546
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3494
+#line 3546
-#line 3494
+#line 3546
/* basic algorithm is:
-#line 3494
+#line 3546
* - ensure sane alignment of input data
-#line 3494
+#line 3546
* - copy (conversion happens automatically) input data
-#line 3494
+#line 3546
* to output
-#line 3494
+#line 3546
* - update xpp to point at next unconverted input, and tp to point
-#line 3494
+#line 3546
* at next location for converted output
-#line 3494
+#line 3546
*/
-#line 3494
+#line 3546
long i, j, ni;
-#line 3494
+#line 3546
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3494
+#line 3546
double *xp;
-#line 3494
+#line 3546
int nrange = 0; /* number of range errors */
-#line 3494
+#line 3546
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3494
+#line 3546
long cxp = (long) *((char**)xpp);
-#line 3494
+#line 3546
-#line 3494
+#line 3546
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3494
+#line 3546
/* sjl: manually stripmine so we can limit amount of
-#line 3494
+#line 3546
* vector work space reserved to LOOPCNT elements. Also
-#line 3494
+#line 3546
* makes vectorisation easy */
-#line 3494
+#line 3546
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3494
+#line 3546
ni=Min(nelems-j,LOOPCNT);
-#line 3494
+#line 3546
if (realign) {
-#line 3494
+#line 3546
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3494
+#line 3546
xp = tmp;
-#line 3494
+#line 3546
} else {
-#line 3494
+#line 3546
xp = (double *) *xpp;
-#line 3494
+#line 3546
}
-#line 3494
+#line 3546
/* copy the next block */
-#line 3494
+#line 3546
#pragma cdir loopcnt=LOOPCNT
-#line 3494
+#line 3546
#pragma cdir shortloop
-#line 3494
+#line 3546
for (i=0; i<ni; i++) {
-#line 3494
+#line 3546
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3494
+#line 3546
/* test for range errors (not always needed but do it anyway) */
-#line 3494
+#line 3546
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3494
+#line 3546
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3494
+#line 3546
nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
-#line 3494
+#line 3546
}
-#line 3494
+#line 3546
/* update xpp and tp */
-#line 3494
+#line 3546
if (realign) xp = (double *) *xpp;
-#line 3494
+#line 3546
xp += ni;
-#line 3494
+#line 3546
tp += ni;
-#line 3494
+#line 3546
*xpp = (void*)xp;
-#line 3494
+#line 3546
}
-#line 3494
+#line 3546
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3494
+#line 3546
-#line 3494
+#line 3546
#else /* not SX */
-#line 3494
+#line 3546
const char *xp = (const char *) *xpp;
-#line 3494
+#line 3546
int status = NC_NOERR;
-#line 3494
+#line 3546
-#line 3494
+#line 3546
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3494
+#line 3546
{
-#line 3494
+#line 3546
const int lstatus = ncx_get_double_float(xp, tp);
-#line 3494
+#line 3546
if (status == NC_NOERR) /* report the first encountered error */
-#line 3494
+#line 3546
status = lstatus;
-#line 3494
+#line 3546
}
-#line 3494
+#line 3546
-#line 3494
+#line 3546
*xpp = (const void *)xp;
-#line 3494
+#line 3546
return status;
-#line 3494
+#line 3546
#endif
-#line 3494
+#line 3546
}
-#line 3494
+#line 3546
int
-#line 3495
+#line 3547
ncx_getn_double_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3495
+#line 3547
{
-#line 3495
+#line 3547
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3495
+#line 3547
-#line 3495
+#line 3547
/* basic algorithm is:
-#line 3495
+#line 3547
* - ensure sane alignment of input data
-#line 3495
+#line 3547
* - copy (conversion happens automatically) input data
-#line 3495
+#line 3547
* to output
-#line 3495
+#line 3547
* - update xpp to point at next unconverted input, and tp to point
-#line 3495
+#line 3547
* at next location for converted output
-#line 3495
+#line 3547
*/
-#line 3495
+#line 3547
long i, j, ni;
-#line 3495
+#line 3547
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3495
+#line 3547
double *xp;
-#line 3495
+#line 3547
int nrange = 0; /* number of range errors */
-#line 3495
+#line 3547
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3495
+#line 3547
long cxp = (long) *((char**)xpp);
-#line 3495
+#line 3547
-#line 3495
+#line 3547
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3495
+#line 3547
/* sjl: manually stripmine so we can limit amount of
-#line 3495
+#line 3547
* vector work space reserved to LOOPCNT elements. Also
-#line 3495
+#line 3547
* makes vectorisation easy */
-#line 3495
+#line 3547
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3495
+#line 3547
ni=Min(nelems-j,LOOPCNT);
-#line 3495
+#line 3547
if (realign) {
-#line 3495
+#line 3547
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3495
+#line 3547
xp = tmp;
-#line 3495
+#line 3547
} else {
-#line 3495
+#line 3547
xp = (double *) *xpp;
-#line 3495
+#line 3547
}
-#line 3495
+#line 3547
/* copy the next block */
-#line 3495
+#line 3547
#pragma cdir loopcnt=LOOPCNT
-#line 3495
+#line 3547
#pragma cdir shortloop
-#line 3495
+#line 3547
for (i=0; i<ni; i++) {
-#line 3495
+#line 3547
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3495
+#line 3547
/* test for range errors (not always needed but do it anyway) */
-#line 3495
+#line 3547
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3495
+#line 3547
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3495
+#line 3547
nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
-#line 3495
+#line 3547
}
-#line 3495
+#line 3547
/* update xpp and tp */
-#line 3495
+#line 3547
if (realign) xp = (double *) *xpp;
-#line 3495
+#line 3547
xp += ni;
-#line 3495
+#line 3547
tp += ni;
-#line 3495
+#line 3547
*xpp = (void*)xp;
-#line 3495
+#line 3547
}
-#line 3495
+#line 3547
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3495
+#line 3547
-#line 3495
+#line 3547
#else /* not SX */
-#line 3495
+#line 3547
const char *xp = (const char *) *xpp;
-#line 3495
+#line 3547
int status = NC_NOERR;
-#line 3495
+#line 3547
-#line 3495
+#line 3547
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3495
+#line 3547
{
-#line 3495
+#line 3547
const int lstatus = ncx_get_double_longlong(xp, tp);
-#line 3495
+#line 3547
if (status == NC_NOERR) /* report the first encountered error */
-#line 3495
+#line 3547
status = lstatus;
-#line 3495
+#line 3547
}
-#line 3495
+#line 3547
-#line 3495
+#line 3547
*xpp = (const void *)xp;
-#line 3495
+#line 3547
return status;
-#line 3495
+#line 3547
#endif
-#line 3495
+#line 3547
}
-#line 3495
+#line 3547
int
-#line 3496
+#line 3548
ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3496
+#line 3548
{
-#line 3496
+#line 3548
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3496
+#line 3548
-#line 3496
+#line 3548
/* basic algorithm is:
-#line 3496
+#line 3548
* - ensure sane alignment of input data
-#line 3496
+#line 3548
* - copy (conversion happens automatically) input data
-#line 3496
+#line 3548
* to output
-#line 3496
+#line 3548
* - update xpp to point at next unconverted input, and tp to point
-#line 3496
+#line 3548
* at next location for converted output
-#line 3496
+#line 3548
*/
-#line 3496
+#line 3548
long i, j, ni;
-#line 3496
+#line 3548
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3496
+#line 3548
double *xp;
-#line 3496
+#line 3548
int nrange = 0; /* number of range errors */
-#line 3496
+#line 3548
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3496
+#line 3548
long cxp = (long) *((char**)xpp);
-#line 3496
+#line 3548
-#line 3496
+#line 3548
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3496
+#line 3548
/* sjl: manually stripmine so we can limit amount of
-#line 3496
+#line 3548
* vector work space reserved to LOOPCNT elements. Also
-#line 3496
+#line 3548
* makes vectorisation easy */
-#line 3496
+#line 3548
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3496
+#line 3548
ni=Min(nelems-j,LOOPCNT);
-#line 3496
+#line 3548
if (realign) {
-#line 3496
+#line 3548
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3496
+#line 3548
xp = tmp;
-#line 3496
+#line 3548
} else {
-#line 3496
+#line 3548
xp = (double *) *xpp;
-#line 3496
+#line 3548
}
-#line 3496
+#line 3548
/* copy the next block */
-#line 3496
+#line 3548
#pragma cdir loopcnt=LOOPCNT
-#line 3496
+#line 3548
#pragma cdir shortloop
-#line 3496
+#line 3548
for (i=0; i<ni; i++) {
-#line 3496
+#line 3548
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3496
+#line 3548
/* test for range errors (not always needed but do it anyway) */
-#line 3496
+#line 3548
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3496
+#line 3548
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3496
+#line 3548
nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
-#line 3496
+#line 3548
}
-#line 3496
+#line 3548
/* update xpp and tp */
-#line 3496
+#line 3548
if (realign) xp = (double *) *xpp;
-#line 3496
+#line 3548
xp += ni;
-#line 3496
+#line 3548
tp += ni;
-#line 3496
+#line 3548
*xpp = (void*)xp;
-#line 3496
+#line 3548
}
-#line 3496
+#line 3548
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3496
+#line 3548
-#line 3496
+#line 3548
#else /* not SX */
-#line 3496
+#line 3548
const char *xp = (const char *) *xpp;
-#line 3496
+#line 3548
int status = NC_NOERR;
-#line 3496
+#line 3548
-#line 3496
+#line 3548
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3496
+#line 3548
{
-#line 3496
+#line 3548
const int lstatus = ncx_get_double_uchar(xp, tp);
-#line 3496
+#line 3548
if (status == NC_NOERR) /* report the first encountered error */
-#line 3496
+#line 3548
status = lstatus;
-#line 3496
+#line 3548
}
-#line 3496
+#line 3548
-#line 3496
+#line 3548
*xpp = (const void *)xp;
-#line 3496
+#line 3548
return status;
-#line 3496
+#line 3548
#endif
-#line 3496
+#line 3548
}
-#line 3496
+#line 3548
int
-#line 3497
+#line 3549
ncx_getn_double_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3497
+#line 3549
{
-#line 3497
+#line 3549
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3497
+#line 3549
-#line 3497
+#line 3549
/* basic algorithm is:
-#line 3497
+#line 3549
* - ensure sane alignment of input data
-#line 3497
+#line 3549
* - copy (conversion happens automatically) input data
-#line 3497
+#line 3549
* to output
-#line 3497
+#line 3549
* - update xpp to point at next unconverted input, and tp to point
-#line 3497
+#line 3549
* at next location for converted output
-#line 3497
+#line 3549
*/
-#line 3497
+#line 3549
long i, j, ni;
-#line 3497
+#line 3549
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3497
+#line 3549
double *xp;
-#line 3497
+#line 3549
int nrange = 0; /* number of range errors */
-#line 3497
+#line 3549
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3497
+#line 3549
long cxp = (long) *((char**)xpp);
-#line 3497
+#line 3549
-#line 3497
+#line 3549
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3497
+#line 3549
/* sjl: manually stripmine so we can limit amount of
-#line 3497
+#line 3549
* vector work space reserved to LOOPCNT elements. Also
-#line 3497
+#line 3549
* makes vectorisation easy */
-#line 3497
+#line 3549
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3497
+#line 3549
ni=Min(nelems-j,LOOPCNT);
-#line 3497
+#line 3549
if (realign) {
-#line 3497
+#line 3549
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3497
+#line 3549
xp = tmp;
-#line 3497
+#line 3549
} else {
-#line 3497
+#line 3549
xp = (double *) *xpp;
-#line 3497
+#line 3549
}
-#line 3497
+#line 3549
/* copy the next block */
-#line 3497
+#line 3549
#pragma cdir loopcnt=LOOPCNT
-#line 3497
+#line 3549
#pragma cdir shortloop
-#line 3497
+#line 3549
for (i=0; i<ni; i++) {
-#line 3497
+#line 3549
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3497
+#line 3549
/* test for range errors (not always needed but do it anyway) */
-#line 3497
+#line 3549
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3497
+#line 3549
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3497
+#line 3549
nrange += xp[i] > USHORT_MAX || xp[i] < 0;
-#line 3497
+#line 3549
}
-#line 3497
+#line 3549
/* update xpp and tp */
-#line 3497
+#line 3549
if (realign) xp = (double *) *xpp;
-#line 3497
+#line 3549
xp += ni;
-#line 3497
+#line 3549
tp += ni;
-#line 3497
+#line 3549
*xpp = (void*)xp;
-#line 3497
+#line 3549
}
-#line 3497
+#line 3549
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3497
+#line 3549
-#line 3497
+#line 3549
#else /* not SX */
-#line 3497
+#line 3549
const char *xp = (const char *) *xpp;
-#line 3497
+#line 3549
int status = NC_NOERR;
-#line 3497
+#line 3549
-#line 3497
+#line 3549
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3497
+#line 3549
{
-#line 3497
+#line 3549
const int lstatus = ncx_get_double_ushort(xp, tp);
-#line 3497
+#line 3549
if (status == NC_NOERR) /* report the first encountered error */
-#line 3497
+#line 3549
status = lstatus;
-#line 3497
+#line 3549
}
-#line 3497
+#line 3549
-#line 3497
+#line 3549
*xpp = (const void *)xp;
-#line 3497
+#line 3549
return status;
-#line 3497
+#line 3549
#endif
-#line 3497
+#line 3549
}
-#line 3497
+#line 3549
int
-#line 3498
+#line 3550
ncx_getn_double_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3498
+#line 3550
{
-#line 3498
+#line 3550
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3498
+#line 3550
-#line 3498
+#line 3550
/* basic algorithm is:
-#line 3498
+#line 3550
* - ensure sane alignment of input data
-#line 3498
+#line 3550
* - copy (conversion happens automatically) input data
-#line 3498
+#line 3550
* to output
-#line 3498
+#line 3550
* - update xpp to point at next unconverted input, and tp to point
-#line 3498
+#line 3550
* at next location for converted output
-#line 3498
+#line 3550
*/
-#line 3498
+#line 3550
long i, j, ni;
-#line 3498
+#line 3550
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3498
+#line 3550
double *xp;
-#line 3498
+#line 3550
int nrange = 0; /* number of range errors */
-#line 3498
+#line 3550
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3498
+#line 3550
long cxp = (long) *((char**)xpp);
-#line 3498
+#line 3550
-#line 3498
+#line 3550
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3498
+#line 3550
/* sjl: manually stripmine so we can limit amount of
-#line 3498
+#line 3550
* vector work space reserved to LOOPCNT elements. Also
-#line 3498
+#line 3550
* makes vectorisation easy */
-#line 3498
+#line 3550
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3498
+#line 3550
ni=Min(nelems-j,LOOPCNT);
-#line 3498
+#line 3550
if (realign) {
-#line 3498
+#line 3550
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3498
+#line 3550
xp = tmp;
-#line 3498
+#line 3550
} else {
-#line 3498
+#line 3550
xp = (double *) *xpp;
-#line 3498
+#line 3550
}
-#line 3498
+#line 3550
/* copy the next block */
-#line 3498
+#line 3550
#pragma cdir loopcnt=LOOPCNT
-#line 3498
+#line 3550
#pragma cdir shortloop
-#line 3498
+#line 3550
for (i=0; i<ni; i++) {
-#line 3498
+#line 3550
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3498
+#line 3550
/* test for range errors (not always needed but do it anyway) */
-#line 3498
+#line 3550
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3498
+#line 3550
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3498
+#line 3550
nrange += xp[i] > UINT_MAX || xp[i] < 0;
-#line 3498
+#line 3550
}
-#line 3498
+#line 3550
/* update xpp and tp */
-#line 3498
+#line 3550
if (realign) xp = (double *) *xpp;
-#line 3498
+#line 3550
xp += ni;
-#line 3498
+#line 3550
tp += ni;
-#line 3498
+#line 3550
*xpp = (void*)xp;
-#line 3498
+#line 3550
}
-#line 3498
+#line 3550
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3498
+#line 3550
-#line 3498
+#line 3550
#else /* not SX */
-#line 3498
+#line 3550
const char *xp = (const char *) *xpp;
-#line 3498
+#line 3550
int status = NC_NOERR;
-#line 3498
+#line 3550
-#line 3498
+#line 3550
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3498
+#line 3550
{
-#line 3498
+#line 3550
const int lstatus = ncx_get_double_uint(xp, tp);
-#line 3498
+#line 3550
if (status == NC_NOERR) /* report the first encountered error */
-#line 3498
+#line 3550
status = lstatus;
-#line 3498
+#line 3550
}
-#line 3498
+#line 3550
-#line 3498
+#line 3550
*xpp = (const void *)xp;
-#line 3498
+#line 3550
return status;
-#line 3498
+#line 3550
#endif
-#line 3498
+#line 3550
}
-#line 3498
+#line 3550
int
-#line 3499
+#line 3551
ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3499
+#line 3551
{
-#line 3499
+#line 3551
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3499
+#line 3551
-#line 3499
+#line 3551
/* basic algorithm is:
-#line 3499
+#line 3551
* - ensure sane alignment of input data
-#line 3499
+#line 3551
* - copy (conversion happens automatically) input data
-#line 3499
+#line 3551
* to output
-#line 3499
+#line 3551
* - update xpp to point at next unconverted input, and tp to point
-#line 3499
+#line 3551
* at next location for converted output
-#line 3499
+#line 3551
*/
-#line 3499
+#line 3551
long i, j, ni;
-#line 3499
+#line 3551
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3499
+#line 3551
double *xp;
-#line 3499
+#line 3551
int nrange = 0; /* number of range errors */
-#line 3499
+#line 3551
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3499
+#line 3551
long cxp = (long) *((char**)xpp);
-#line 3499
+#line 3551
-#line 3499
+#line 3551
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3499
+#line 3551
/* sjl: manually stripmine so we can limit amount of
-#line 3499
+#line 3551
* vector work space reserved to LOOPCNT elements. Also
-#line 3499
+#line 3551
* makes vectorisation easy */
-#line 3499
+#line 3551
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3499
+#line 3551
ni=Min(nelems-j,LOOPCNT);
-#line 3499
+#line 3551
if (realign) {
-#line 3499
+#line 3551
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_DOUBLE));
-#line 3499
+#line 3551
xp = tmp;
-#line 3499
+#line 3551
} else {
-#line 3499
+#line 3551
xp = (double *) *xpp;
-#line 3499
+#line 3551
}
-#line 3499
+#line 3551
/* copy the next block */
-#line 3499
+#line 3551
#pragma cdir loopcnt=LOOPCNT
-#line 3499
+#line 3551
#pragma cdir shortloop
-#line 3499
+#line 3551
for (i=0; i<ni; i++) {
-#line 3499
+#line 3551
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3499
+#line 3551
/* test for range errors (not always needed but do it anyway) */
-#line 3499
+#line 3551
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3499
+#line 3551
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3499
+#line 3551
nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
-#line 3499
+#line 3551
}
-#line 3499
+#line 3551
/* update xpp and tp */
-#line 3499
+#line 3551
if (realign) xp = (double *) *xpp;
-#line 3499
+#line 3551
xp += ni;
-#line 3499
+#line 3551
tp += ni;
-#line 3499
+#line 3551
*xpp = (void*)xp;
-#line 3499
+#line 3551
}
-#line 3499
+#line 3551
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3499
+#line 3551
-#line 3499
+#line 3551
#else /* not SX */
-#line 3499
+#line 3551
const char *xp = (const char *) *xpp;
-#line 3499
+#line 3551
int status = NC_NOERR;
-#line 3499
+#line 3551
-#line 3499
+#line 3551
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3499
+#line 3551
{
-#line 3499
+#line 3551
const int lstatus = ncx_get_double_ulonglong(xp, tp);
-#line 3499
+#line 3551
if (status == NC_NOERR) /* report the first encountered error */
-#line 3499
+#line 3551
status = lstatus;
-#line 3499
+#line 3551
}
-#line 3499
+#line 3551
-#line 3499
+#line 3551
*xpp = (const void *)xp;
-#line 3499
+#line 3551
return status;
-#line 3499
+#line 3551
#endif
-#line 3499
+#line 3551
}
-#line 3499
+#line 3551
#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
@@ -29757,123 +31842,123 @@ ncx_putn_double_double(void **xpp, size_t ndoubles, const double *ip, void *fill
while (ip < end)
{
const struct vax_double *const vdp =
-#line 3522
+#line 3574
(const struct vax_double *)ip;
-#line 3522
+#line 3574
struct ieee_double *const idp =
-#line 3522
+#line 3574
(struct ieee_double *) (*xpp);
-#line 3522
+#line 3574
-#line 3522
+#line 3574
if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
-#line 3522
+#line 3574
(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
-#line 3522
+#line 3574
(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
-#line 3522
+#line 3574
(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
-#line 3522
+#line 3574
(vdp->exp == dbl_limits[0].d.exp))
-#line 3522
+#line 3574
{
-#line 3522
+#line 3574
*idp = dbl_limits[0].ieee;
-#line 3522
+#line 3574
goto shipit;
-#line 3522
+#line 3574
}
-#line 3522
+#line 3574
if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
-#line 3522
+#line 3574
(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
-#line 3522
+#line 3574
(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
-#line 3522
+#line 3574
(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
-#line 3522
+#line 3574
(vdp->exp == dbl_limits[1].d.exp))
-#line 3522
+#line 3574
{
-#line 3522
+#line 3574
*idp = dbl_limits[1].ieee;
-#line 3522
+#line 3574
goto shipit;
-#line 3522
+#line 3574
}
-#line 3522
+#line 3574
-#line 3522
+#line 3574
{
-#line 3522
+#line 3574
unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
-#line 3522
+#line 3574
-#line 3522
+#line 3574
unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
-#line 3522
+#line 3574
(vdp->mantissa3 << 13) |
-#line 3522
+#line 3574
((vdp->mantissa4 >> 3) & MASK(13));
-#line 3522
+#line 3574
-#line 3522
+#line 3574
unsigned mant_hi = (vdp->mantissa1 << 13)
-#line 3522
+#line 3574
| (vdp->mantissa2 >> 3);
-#line 3522
+#line 3574
-#line 3522
+#line 3574
if ((vdp->mantissa4 & 7) > 4)
-#line 3522
+#line 3574
{
-#line 3522
+#line 3574
/* round up */
-#line 3522
+#line 3574
mant_lo++;
-#line 3522
+#line 3574
if (mant_lo == 0)
-#line 3522
+#line 3574
{
-#line 3522
+#line 3574
mant_hi++;
-#line 3522
+#line 3574
if (mant_hi > 0xffffff)
-#line 3522
+#line 3574
{
-#line 3522
+#line 3574
mant_hi = 0;
-#line 3522
+#line 3574
exp++;
-#line 3522
+#line 3574
}
-#line 3522
+#line 3574
}
-#line 3522
+#line 3574
}
-#line 3522
+#line 3574
-#line 3522
+#line 3574
idp->mant_lo = SWAP4(mant_lo);
-#line 3522
+#line 3574
idp->mant_6 = mant_hi >> 16;
-#line 3522
+#line 3574
idp->mant_5 = (mant_hi & 0xff00) >> 8;
-#line 3522
+#line 3574
idp->mant_4 = mant_hi;
-#line 3522
+#line 3574
idp->exp_hi = exp >> 4;
-#line 3522
+#line 3574
idp->exp_lo = exp;
-#line 3522
+#line 3574
}
-#line 3522
+#line 3574
-#line 3522
+#line 3574
shipit:
-#line 3522
+#line 3574
idp->sign = vdp->sign;
-#line 3522
+#line 3574
ip++;
*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
@@ -29900,1394 +31985,1394 @@ ncx_putn_double_double(void **xpp, size_t nelems, const double *tp, void *fillp)
}
#endif
int
-#line 3547
+#line 3599
ncx_putn_double_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3547
+#line 3599
{
-#line 3547
+#line 3599
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3547
+#line 3599
-#line 3547
+#line 3599
/* basic algorithm is:
-#line 3547
+#line 3599
* - ensure sane alignment of output data
-#line 3547
+#line 3599
* - copy (conversion happens automatically) input data
-#line 3547
+#line 3599
* to output
-#line 3547
+#line 3599
* - update tp to point at next unconverted input, and xpp to point
-#line 3547
+#line 3599
* at next location for converted output
-#line 3547
+#line 3599
*/
-#line 3547
+#line 3599
long i, j, ni;
-#line 3547
+#line 3599
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3547
+#line 3599
double *xp;
-#line 3547
+#line 3599
int nrange = 0; /* number of range errors */
-#line 3547
+#line 3599
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3547
+#line 3599
long cxp = (long) *((char**)xpp);
-#line 3547
+#line 3599
-#line 3547
+#line 3599
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3547
+#line 3599
/* sjl: manually stripmine so we can limit amount of
-#line 3547
+#line 3599
* vector work space reserved to LOOPCNT elements. Also
-#line 3547
+#line 3599
* makes vectorisation easy */
-#line 3547
+#line 3599
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3547
+#line 3599
ni=Min(nelems-j,LOOPCNT);
-#line 3547
+#line 3599
if (realign) {
-#line 3547
+#line 3599
xp = tmp;
-#line 3547
+#line 3599
} else {
-#line 3547
+#line 3599
xp = (double *) *xpp;
-#line 3547
+#line 3599
}
-#line 3547
+#line 3599
/* copy the next block */
-#line 3547
+#line 3599
#pragma cdir loopcnt=LOOPCNT
-#line 3547
+#line 3599
#pragma cdir shortloop
-#line 3547
+#line 3599
for (i=0; i<ni; i++) {
-#line 3547
+#line 3599
/* the normal case: */
-#line 3547
+#line 3599
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3547
+#line 3599
/* test for range errors (not always needed but do it anyway) */
-#line 3547
+#line 3599
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3547
+#line 3599
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3547
+#line 3599
nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
-#line 3547
+#line 3599
}
-#line 3547
+#line 3599
/* copy workspace back if necessary */
-#line 3547
+#line 3599
if (realign) {
-#line 3547
+#line 3599
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3547
+#line 3599
xp = (double *) *xpp;
-#line 3547
+#line 3599
}
-#line 3547
+#line 3599
/* update xpp and tp */
-#line 3547
+#line 3599
xp += ni;
-#line 3547
+#line 3599
tp += ni;
-#line 3547
+#line 3599
*xpp = (void*)xp;
-#line 3547
+#line 3599
}
-#line 3547
+#line 3599
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3547
+#line 3599
-#line 3547
+#line 3599
#else /* not SX */
-#line 3547
+#line 3599
-#line 3547
+#line 3599
char *xp = (char *) *xpp;
-#line 3547
+#line 3599
int status = NC_NOERR;
-#line 3547
+#line 3599
-#line 3547
+#line 3599
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3547
+#line 3599
{
-#line 3547
+#line 3599
int lstatus = ncx_put_double_schar(xp, tp, fillp);
-#line 3547
+#line 3599
if (status == NC_NOERR) /* report the first encountered error */
-#line 3547
+#line 3599
status = lstatus;
-#line 3547
+#line 3599
}
-#line 3547
+#line 3599
-#line 3547
+#line 3599
*xpp = (void *)xp;
-#line 3547
+#line 3599
return status;
-#line 3547
+#line 3599
#endif
-#line 3547
+#line 3599
}
-#line 3547
+#line 3599
int
-#line 3548
+#line 3600
ncx_putn_double_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3548
+#line 3600
{
-#line 3548
+#line 3600
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3548
+#line 3600
-#line 3548
+#line 3600
/* basic algorithm is:
-#line 3548
+#line 3600
* - ensure sane alignment of output data
-#line 3548
+#line 3600
* - copy (conversion happens automatically) input data
-#line 3548
+#line 3600
* to output
-#line 3548
+#line 3600
* - update tp to point at next unconverted input, and xpp to point
-#line 3548
+#line 3600
* at next location for converted output
-#line 3548
+#line 3600
*/
-#line 3548
+#line 3600
long i, j, ni;
-#line 3548
+#line 3600
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3548
+#line 3600
double *xp;
-#line 3548
+#line 3600
int nrange = 0; /* number of range errors */
-#line 3548
+#line 3600
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3548
+#line 3600
long cxp = (long) *((char**)xpp);
-#line 3548
+#line 3600
-#line 3548
+#line 3600
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3548
+#line 3600
/* sjl: manually stripmine so we can limit amount of
-#line 3548
+#line 3600
* vector work space reserved to LOOPCNT elements. Also
-#line 3548
+#line 3600
* makes vectorisation easy */
-#line 3548
+#line 3600
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3548
+#line 3600
ni=Min(nelems-j,LOOPCNT);
-#line 3548
+#line 3600
if (realign) {
-#line 3548
+#line 3600
xp = tmp;
-#line 3548
+#line 3600
} else {
-#line 3548
+#line 3600
xp = (double *) *xpp;
-#line 3548
+#line 3600
}
-#line 3548
+#line 3600
/* copy the next block */
-#line 3548
+#line 3600
#pragma cdir loopcnt=LOOPCNT
-#line 3548
+#line 3600
#pragma cdir shortloop
-#line 3548
+#line 3600
for (i=0; i<ni; i++) {
-#line 3548
+#line 3600
/* the normal case: */
-#line 3548
+#line 3600
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3548
+#line 3600
/* test for range errors (not always needed but do it anyway) */
-#line 3548
+#line 3600
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3548
+#line 3600
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3548
+#line 3600
nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
-#line 3548
+#line 3600
}
-#line 3548
+#line 3600
/* copy workspace back if necessary */
-#line 3548
+#line 3600
if (realign) {
-#line 3548
+#line 3600
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3548
+#line 3600
xp = (double *) *xpp;
-#line 3548
+#line 3600
}
-#line 3548
+#line 3600
/* update xpp and tp */
-#line 3548
+#line 3600
xp += ni;
-#line 3548
+#line 3600
tp += ni;
-#line 3548
+#line 3600
*xpp = (void*)xp;
-#line 3548
+#line 3600
}
-#line 3548
+#line 3600
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3548
+#line 3600
-#line 3548
+#line 3600
#else /* not SX */
-#line 3548
+#line 3600
-#line 3548
+#line 3600
char *xp = (char *) *xpp;
-#line 3548
+#line 3600
int status = NC_NOERR;
-#line 3548
+#line 3600
-#line 3548
+#line 3600
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3548
+#line 3600
{
-#line 3548
+#line 3600
int lstatus = ncx_put_double_short(xp, tp, fillp);
-#line 3548
+#line 3600
if (status == NC_NOERR) /* report the first encountered error */
-#line 3548
+#line 3600
status = lstatus;
-#line 3548
+#line 3600
}
-#line 3548
+#line 3600
-#line 3548
+#line 3600
*xpp = (void *)xp;
-#line 3548
+#line 3600
return status;
-#line 3548
+#line 3600
#endif
-#line 3548
+#line 3600
}
-#line 3548
+#line 3600
int
-#line 3549
+#line 3601
ncx_putn_double_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3549
+#line 3601
{
-#line 3549
+#line 3601
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3549
+#line 3601
-#line 3549
+#line 3601
/* basic algorithm is:
-#line 3549
+#line 3601
* - ensure sane alignment of output data
-#line 3549
+#line 3601
* - copy (conversion happens automatically) input data
-#line 3549
+#line 3601
* to output
-#line 3549
+#line 3601
* - update tp to point at next unconverted input, and xpp to point
-#line 3549
+#line 3601
* at next location for converted output
-#line 3549
+#line 3601
*/
-#line 3549
+#line 3601
long i, j, ni;
-#line 3549
+#line 3601
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3549
+#line 3601
double *xp;
-#line 3549
+#line 3601
int nrange = 0; /* number of range errors */
-#line 3549
+#line 3601
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3549
+#line 3601
long cxp = (long) *((char**)xpp);
-#line 3549
+#line 3601
-#line 3549
+#line 3601
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3549
+#line 3601
/* sjl: manually stripmine so we can limit amount of
-#line 3549
+#line 3601
* vector work space reserved to LOOPCNT elements. Also
-#line 3549
+#line 3601
* makes vectorisation easy */
-#line 3549
+#line 3601
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3549
+#line 3601
ni=Min(nelems-j,LOOPCNT);
-#line 3549
+#line 3601
if (realign) {
-#line 3549
+#line 3601
xp = tmp;
-#line 3549
+#line 3601
} else {
-#line 3549
+#line 3601
xp = (double *) *xpp;
-#line 3549
+#line 3601
}
-#line 3549
+#line 3601
/* copy the next block */
-#line 3549
+#line 3601
#pragma cdir loopcnt=LOOPCNT
-#line 3549
+#line 3601
#pragma cdir shortloop
-#line 3549
+#line 3601
for (i=0; i<ni; i++) {
-#line 3549
+#line 3601
/* the normal case: */
-#line 3549
+#line 3601
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3549
+#line 3601
/* test for range errors (not always needed but do it anyway) */
-#line 3549
+#line 3601
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3549
+#line 3601
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3549
+#line 3601
nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
-#line 3549
+#line 3601
}
-#line 3549
+#line 3601
/* copy workspace back if necessary */
-#line 3549
+#line 3601
if (realign) {
-#line 3549
+#line 3601
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3549
+#line 3601
xp = (double *) *xpp;
-#line 3549
+#line 3601
}
-#line 3549
+#line 3601
/* update xpp and tp */
-#line 3549
+#line 3601
xp += ni;
-#line 3549
+#line 3601
tp += ni;
-#line 3549
+#line 3601
*xpp = (void*)xp;
-#line 3549
+#line 3601
}
-#line 3549
+#line 3601
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3549
+#line 3601
-#line 3549
+#line 3601
#else /* not SX */
-#line 3549
+#line 3601
-#line 3549
+#line 3601
char *xp = (char *) *xpp;
-#line 3549
+#line 3601
int status = NC_NOERR;
-#line 3549
+#line 3601
-#line 3549
+#line 3601
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3549
+#line 3601
{
-#line 3549
+#line 3601
int lstatus = ncx_put_double_int(xp, tp, fillp);
-#line 3549
+#line 3601
if (status == NC_NOERR) /* report the first encountered error */
-#line 3549
+#line 3601
status = lstatus;
-#line 3549
+#line 3601
}
-#line 3549
+#line 3601
-#line 3549
+#line 3601
*xpp = (void *)xp;
-#line 3549
+#line 3601
return status;
-#line 3549
+#line 3601
#endif
-#line 3549
+#line 3601
}
-#line 3549
+#line 3601
int
-#line 3550
+#line 3602
ncx_putn_double_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3550
+#line 3602
{
-#line 3550
+#line 3602
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3550
+#line 3602
-#line 3550
+#line 3602
/* basic algorithm is:
-#line 3550
+#line 3602
* - ensure sane alignment of output data
-#line 3550
+#line 3602
* - copy (conversion happens automatically) input data
-#line 3550
+#line 3602
* to output
-#line 3550
+#line 3602
* - update tp to point at next unconverted input, and xpp to point
-#line 3550
+#line 3602
* at next location for converted output
-#line 3550
+#line 3602
*/
-#line 3550
+#line 3602
long i, j, ni;
-#line 3550
+#line 3602
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3550
+#line 3602
double *xp;
-#line 3550
+#line 3602
int nrange = 0; /* number of range errors */
-#line 3550
+#line 3602
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3550
+#line 3602
long cxp = (long) *((char**)xpp);
-#line 3550
+#line 3602
-#line 3550
+#line 3602
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3550
+#line 3602
/* sjl: manually stripmine so we can limit amount of
-#line 3550
+#line 3602
* vector work space reserved to LOOPCNT elements. Also
-#line 3550
+#line 3602
* makes vectorisation easy */
-#line 3550
+#line 3602
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3550
+#line 3602
ni=Min(nelems-j,LOOPCNT);
-#line 3550
+#line 3602
if (realign) {
-#line 3550
+#line 3602
xp = tmp;
-#line 3550
+#line 3602
} else {
-#line 3550
+#line 3602
xp = (double *) *xpp;
-#line 3550
+#line 3602
}
-#line 3550
+#line 3602
/* copy the next block */
-#line 3550
+#line 3602
#pragma cdir loopcnt=LOOPCNT
-#line 3550
+#line 3602
#pragma cdir shortloop
-#line 3550
+#line 3602
for (i=0; i<ni; i++) {
-#line 3550
+#line 3602
/* the normal case: */
-#line 3550
+#line 3602
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3550
+#line 3602
/* test for range errors (not always needed but do it anyway) */
-#line 3550
+#line 3602
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3550
+#line 3602
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3550
+#line 3602
nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
-#line 3550
+#line 3602
}
-#line 3550
+#line 3602
/* copy workspace back if necessary */
-#line 3550
+#line 3602
if (realign) {
-#line 3550
+#line 3602
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3550
+#line 3602
xp = (double *) *xpp;
-#line 3550
+#line 3602
}
-#line 3550
+#line 3602
/* update xpp and tp */
-#line 3550
+#line 3602
xp += ni;
-#line 3550
+#line 3602
tp += ni;
-#line 3550
+#line 3602
*xpp = (void*)xp;
-#line 3550
+#line 3602
}
-#line 3550
+#line 3602
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3550
+#line 3602
-#line 3550
+#line 3602
#else /* not SX */
-#line 3550
+#line 3602
-#line 3550
+#line 3602
char *xp = (char *) *xpp;
-#line 3550
+#line 3602
int status = NC_NOERR;
-#line 3550
+#line 3602
-#line 3550
+#line 3602
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3550
+#line 3602
{
-#line 3550
+#line 3602
int lstatus = ncx_put_double_long(xp, tp, fillp);
-#line 3550
+#line 3602
if (status == NC_NOERR) /* report the first encountered error */
-#line 3550
+#line 3602
status = lstatus;
-#line 3550
+#line 3602
}
-#line 3550
+#line 3602
-#line 3550
+#line 3602
*xpp = (void *)xp;
-#line 3550
+#line 3602
return status;
-#line 3550
+#line 3602
#endif
-#line 3550
+#line 3602
}
-#line 3550
+#line 3602
int
-#line 3551
+#line 3603
ncx_putn_double_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3551
+#line 3603
{
-#line 3551
+#line 3603
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3551
+#line 3603
-#line 3551
+#line 3603
/* basic algorithm is:
-#line 3551
+#line 3603
* - ensure sane alignment of output data
-#line 3551
+#line 3603
* - copy (conversion happens automatically) input data
-#line 3551
+#line 3603
* to output
-#line 3551
+#line 3603
* - update tp to point at next unconverted input, and xpp to point
-#line 3551
+#line 3603
* at next location for converted output
-#line 3551
+#line 3603
*/
-#line 3551
+#line 3603
long i, j, ni;
-#line 3551
+#line 3603
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3551
+#line 3603
double *xp;
-#line 3551
+#line 3603
int nrange = 0; /* number of range errors */
-#line 3551
+#line 3603
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3551
+#line 3603
long cxp = (long) *((char**)xpp);
-#line 3551
+#line 3603
-#line 3551
+#line 3603
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3551
+#line 3603
/* sjl: manually stripmine so we can limit amount of
-#line 3551
+#line 3603
* vector work space reserved to LOOPCNT elements. Also
-#line 3551
+#line 3603
* makes vectorisation easy */
-#line 3551
+#line 3603
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3551
+#line 3603
ni=Min(nelems-j,LOOPCNT);
-#line 3551
+#line 3603
if (realign) {
-#line 3551
+#line 3603
xp = tmp;
-#line 3551
+#line 3603
} else {
-#line 3551
+#line 3603
xp = (double *) *xpp;
-#line 3551
+#line 3603
}
-#line 3551
+#line 3603
/* copy the next block */
-#line 3551
+#line 3603
#pragma cdir loopcnt=LOOPCNT
-#line 3551
+#line 3603
#pragma cdir shortloop
-#line 3551
+#line 3603
for (i=0; i<ni; i++) {
-#line 3551
+#line 3603
/* the normal case: */
-#line 3551
+#line 3603
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3551
+#line 3603
/* test for range errors (not always needed but do it anyway) */
-#line 3551
+#line 3603
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3551
+#line 3603
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3551
+#line 3603
nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
-#line 3551
+#line 3603
}
-#line 3551
+#line 3603
/* copy workspace back if necessary */
-#line 3551
+#line 3603
if (realign) {
-#line 3551
+#line 3603
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3551
+#line 3603
xp = (double *) *xpp;
-#line 3551
+#line 3603
}
-#line 3551
+#line 3603
/* update xpp and tp */
-#line 3551
+#line 3603
xp += ni;
-#line 3551
+#line 3603
tp += ni;
-#line 3551
+#line 3603
*xpp = (void*)xp;
-#line 3551
+#line 3603
}
-#line 3551
+#line 3603
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3551
+#line 3603
-#line 3551
+#line 3603
#else /* not SX */
-#line 3551
+#line 3603
-#line 3551
+#line 3603
char *xp = (char *) *xpp;
-#line 3551
+#line 3603
int status = NC_NOERR;
-#line 3551
+#line 3603
-#line 3551
+#line 3603
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3551
+#line 3603
{
-#line 3551
+#line 3603
int lstatus = ncx_put_double_float(xp, tp, fillp);
-#line 3551
+#line 3603
if (status == NC_NOERR) /* report the first encountered error */
-#line 3551
+#line 3603
status = lstatus;
-#line 3551
+#line 3603
}
-#line 3551
+#line 3603
-#line 3551
+#line 3603
*xpp = (void *)xp;
-#line 3551
+#line 3603
return status;
-#line 3551
+#line 3603
#endif
-#line 3551
+#line 3603
}
-#line 3551
+#line 3603
int
-#line 3552
+#line 3604
ncx_putn_double_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3552
+#line 3604
{
-#line 3552
+#line 3604
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3552
+#line 3604
-#line 3552
+#line 3604
/* basic algorithm is:
-#line 3552
+#line 3604
* - ensure sane alignment of output data
-#line 3552
+#line 3604
* - copy (conversion happens automatically) input data
-#line 3552
+#line 3604
* to output
-#line 3552
+#line 3604
* - update tp to point at next unconverted input, and xpp to point
-#line 3552
+#line 3604
* at next location for converted output
-#line 3552
+#line 3604
*/
-#line 3552
+#line 3604
long i, j, ni;
-#line 3552
+#line 3604
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3552
+#line 3604
double *xp;
-#line 3552
+#line 3604
int nrange = 0; /* number of range errors */
-#line 3552
+#line 3604
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3552
+#line 3604
long cxp = (long) *((char**)xpp);
-#line 3552
+#line 3604
-#line 3552
+#line 3604
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3552
+#line 3604
/* sjl: manually stripmine so we can limit amount of
-#line 3552
+#line 3604
* vector work space reserved to LOOPCNT elements. Also
-#line 3552
+#line 3604
* makes vectorisation easy */
-#line 3552
+#line 3604
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3552
+#line 3604
ni=Min(nelems-j,LOOPCNT);
-#line 3552
+#line 3604
if (realign) {
-#line 3552
+#line 3604
xp = tmp;
-#line 3552
+#line 3604
} else {
-#line 3552
+#line 3604
xp = (double *) *xpp;
-#line 3552
+#line 3604
}
-#line 3552
+#line 3604
/* copy the next block */
-#line 3552
+#line 3604
#pragma cdir loopcnt=LOOPCNT
-#line 3552
+#line 3604
#pragma cdir shortloop
-#line 3552
+#line 3604
for (i=0; i<ni; i++) {
-#line 3552
+#line 3604
/* the normal case: */
-#line 3552
+#line 3604
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3552
+#line 3604
/* test for range errors (not always needed but do it anyway) */
-#line 3552
+#line 3604
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3552
+#line 3604
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3552
+#line 3604
nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
-#line 3552
+#line 3604
}
-#line 3552
+#line 3604
/* copy workspace back if necessary */
-#line 3552
+#line 3604
if (realign) {
-#line 3552
+#line 3604
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3552
+#line 3604
xp = (double *) *xpp;
-#line 3552
+#line 3604
}
-#line 3552
+#line 3604
/* update xpp and tp */
-#line 3552
+#line 3604
xp += ni;
-#line 3552
+#line 3604
tp += ni;
-#line 3552
+#line 3604
*xpp = (void*)xp;
-#line 3552
+#line 3604
}
-#line 3552
+#line 3604
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3552
+#line 3604
-#line 3552
+#line 3604
#else /* not SX */
-#line 3552
+#line 3604
-#line 3552
+#line 3604
char *xp = (char *) *xpp;
-#line 3552
+#line 3604
int status = NC_NOERR;
-#line 3552
+#line 3604
-#line 3552
+#line 3604
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3552
+#line 3604
{
-#line 3552
+#line 3604
int lstatus = ncx_put_double_longlong(xp, tp, fillp);
-#line 3552
+#line 3604
if (status == NC_NOERR) /* report the first encountered error */
-#line 3552
+#line 3604
status = lstatus;
-#line 3552
+#line 3604
}
-#line 3552
+#line 3604
-#line 3552
+#line 3604
*xpp = (void *)xp;
-#line 3552
+#line 3604
return status;
-#line 3552
+#line 3604
#endif
-#line 3552
+#line 3604
}
-#line 3552
+#line 3604
int
-#line 3553
+#line 3605
ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3553
+#line 3605
{
-#line 3553
+#line 3605
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3553
+#line 3605
-#line 3553
+#line 3605
/* basic algorithm is:
-#line 3553
+#line 3605
* - ensure sane alignment of output data
-#line 3553
+#line 3605
* - copy (conversion happens automatically) input data
-#line 3553
+#line 3605
* to output
-#line 3553
+#line 3605
* - update tp to point at next unconverted input, and xpp to point
-#line 3553
+#line 3605
* at next location for converted output
-#line 3553
+#line 3605
*/
-#line 3553
+#line 3605
long i, j, ni;
-#line 3553
+#line 3605
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3553
+#line 3605
double *xp;
-#line 3553
+#line 3605
int nrange = 0; /* number of range errors */
-#line 3553
+#line 3605
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3553
+#line 3605
long cxp = (long) *((char**)xpp);
-#line 3553
+#line 3605
-#line 3553
+#line 3605
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3553
+#line 3605
/* sjl: manually stripmine so we can limit amount of
-#line 3553
+#line 3605
* vector work space reserved to LOOPCNT elements. Also
-#line 3553
+#line 3605
* makes vectorisation easy */
-#line 3553
+#line 3605
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3553
+#line 3605
ni=Min(nelems-j,LOOPCNT);
-#line 3553
+#line 3605
if (realign) {
-#line 3553
+#line 3605
xp = tmp;
-#line 3553
+#line 3605
} else {
-#line 3553
+#line 3605
xp = (double *) *xpp;
-#line 3553
+#line 3605
}
-#line 3553
+#line 3605
/* copy the next block */
-#line 3553
+#line 3605
#pragma cdir loopcnt=LOOPCNT
-#line 3553
+#line 3605
#pragma cdir shortloop
-#line 3553
+#line 3605
for (i=0; i<ni; i++) {
-#line 3553
+#line 3605
/* the normal case: */
-#line 3553
+#line 3605
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3553
+#line 3605
/* test for range errors (not always needed but do it anyway) */
-#line 3553
+#line 3605
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3553
+#line 3605
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3553
+#line 3605
nrange += tp[i] > X_DOUBLE_MAX ;
-#line 3553
+#line 3605
}
-#line 3553
+#line 3605
/* copy workspace back if necessary */
-#line 3553
+#line 3605
if (realign) {
-#line 3553
+#line 3605
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3553
+#line 3605
xp = (double *) *xpp;
-#line 3553
+#line 3605
}
-#line 3553
+#line 3605
/* update xpp and tp */
-#line 3553
+#line 3605
xp += ni;
-#line 3553
+#line 3605
tp += ni;
-#line 3553
+#line 3605
*xpp = (void*)xp;
-#line 3553
+#line 3605
}
-#line 3553
+#line 3605
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3553
+#line 3605
-#line 3553
+#line 3605
#else /* not SX */
-#line 3553
+#line 3605
-#line 3553
+#line 3605
char *xp = (char *) *xpp;
-#line 3553
+#line 3605
int status = NC_NOERR;
-#line 3553
+#line 3605
-#line 3553
+#line 3605
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3553
+#line 3605
{
-#line 3553
+#line 3605
int lstatus = ncx_put_double_uchar(xp, tp, fillp);
-#line 3553
+#line 3605
if (status == NC_NOERR) /* report the first encountered error */
-#line 3553
+#line 3605
status = lstatus;
-#line 3553
+#line 3605
}
-#line 3553
+#line 3605
-#line 3553
+#line 3605
*xpp = (void *)xp;
-#line 3553
+#line 3605
return status;
-#line 3553
+#line 3605
#endif
-#line 3553
+#line 3605
}
-#line 3553
+#line 3605
int
-#line 3554
+#line 3606
ncx_putn_double_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3554
+#line 3606
{
-#line 3554
+#line 3606
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3554
+#line 3606
-#line 3554
+#line 3606
/* basic algorithm is:
-#line 3554
+#line 3606
* - ensure sane alignment of output data
-#line 3554
+#line 3606
* - copy (conversion happens automatically) input data
-#line 3554
+#line 3606
* to output
-#line 3554
+#line 3606
* - update tp to point at next unconverted input, and xpp to point
-#line 3554
+#line 3606
* at next location for converted output
-#line 3554
+#line 3606
*/
-#line 3554
+#line 3606
long i, j, ni;
-#line 3554
+#line 3606
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3554
+#line 3606
double *xp;
-#line 3554
+#line 3606
int nrange = 0; /* number of range errors */
-#line 3554
+#line 3606
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3554
+#line 3606
long cxp = (long) *((char**)xpp);
-#line 3554
+#line 3606
-#line 3554
+#line 3606
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3554
+#line 3606
/* sjl: manually stripmine so we can limit amount of
-#line 3554
+#line 3606
* vector work space reserved to LOOPCNT elements. Also
-#line 3554
+#line 3606
* makes vectorisation easy */
-#line 3554
+#line 3606
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3554
+#line 3606
ni=Min(nelems-j,LOOPCNT);
-#line 3554
+#line 3606
if (realign) {
-#line 3554
+#line 3606
xp = tmp;
-#line 3554
+#line 3606
} else {
-#line 3554
+#line 3606
xp = (double *) *xpp;
-#line 3554
+#line 3606
}
-#line 3554
+#line 3606
/* copy the next block */
-#line 3554
+#line 3606
#pragma cdir loopcnt=LOOPCNT
-#line 3554
+#line 3606
#pragma cdir shortloop
-#line 3554
+#line 3606
for (i=0; i<ni; i++) {
-#line 3554
+#line 3606
/* the normal case: */
-#line 3554
+#line 3606
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3554
+#line 3606
/* test for range errors (not always needed but do it anyway) */
-#line 3554
+#line 3606
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3554
+#line 3606
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3554
+#line 3606
nrange += tp[i] > X_DOUBLE_MAX ;
-#line 3554
+#line 3606
}
-#line 3554
+#line 3606
/* copy workspace back if necessary */
-#line 3554
+#line 3606
if (realign) {
-#line 3554
+#line 3606
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3554
+#line 3606
xp = (double *) *xpp;
-#line 3554
+#line 3606
}
-#line 3554
+#line 3606
/* update xpp and tp */
-#line 3554
+#line 3606
xp += ni;
-#line 3554
+#line 3606
tp += ni;
-#line 3554
+#line 3606
*xpp = (void*)xp;
-#line 3554
+#line 3606
}
-#line 3554
+#line 3606
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3554
+#line 3606
-#line 3554
+#line 3606
#else /* not SX */
-#line 3554
+#line 3606
-#line 3554
+#line 3606
char *xp = (char *) *xpp;
-#line 3554
+#line 3606
int status = NC_NOERR;
-#line 3554
+#line 3606
-#line 3554
+#line 3606
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3554
+#line 3606
{
-#line 3554
+#line 3606
int lstatus = ncx_put_double_ushort(xp, tp, fillp);
-#line 3554
+#line 3606
if (status == NC_NOERR) /* report the first encountered error */
-#line 3554
+#line 3606
status = lstatus;
-#line 3554
+#line 3606
}
-#line 3554
+#line 3606
-#line 3554
+#line 3606
*xpp = (void *)xp;
-#line 3554
+#line 3606
return status;
-#line 3554
+#line 3606
#endif
-#line 3554
+#line 3606
}
-#line 3554
+#line 3606
int
-#line 3555
+#line 3607
ncx_putn_double_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3555
+#line 3607
{
-#line 3555
+#line 3607
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3555
+#line 3607
-#line 3555
+#line 3607
/* basic algorithm is:
-#line 3555
+#line 3607
* - ensure sane alignment of output data
-#line 3555
+#line 3607
* - copy (conversion happens automatically) input data
-#line 3555
+#line 3607
* to output
-#line 3555
+#line 3607
* - update tp to point at next unconverted input, and xpp to point
-#line 3555
+#line 3607
* at next location for converted output
-#line 3555
+#line 3607
*/
-#line 3555
+#line 3607
long i, j, ni;
-#line 3555
+#line 3607
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3555
+#line 3607
double *xp;
-#line 3555
+#line 3607
int nrange = 0; /* number of range errors */
-#line 3555
+#line 3607
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3555
+#line 3607
long cxp = (long) *((char**)xpp);
-#line 3555
+#line 3607
-#line 3555
+#line 3607
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3555
+#line 3607
/* sjl: manually stripmine so we can limit amount of
-#line 3555
+#line 3607
* vector work space reserved to LOOPCNT elements. Also
-#line 3555
+#line 3607
* makes vectorisation easy */
-#line 3555
+#line 3607
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3555
+#line 3607
ni=Min(nelems-j,LOOPCNT);
-#line 3555
+#line 3607
if (realign) {
-#line 3555
+#line 3607
xp = tmp;
-#line 3555
+#line 3607
} else {
-#line 3555
+#line 3607
xp = (double *) *xpp;
-#line 3555
+#line 3607
}
-#line 3555
+#line 3607
/* copy the next block */
-#line 3555
+#line 3607
#pragma cdir loopcnt=LOOPCNT
-#line 3555
+#line 3607
#pragma cdir shortloop
-#line 3555
+#line 3607
for (i=0; i<ni; i++) {
-#line 3555
+#line 3607
/* the normal case: */
-#line 3555
+#line 3607
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3555
+#line 3607
/* test for range errors (not always needed but do it anyway) */
-#line 3555
+#line 3607
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3555
+#line 3607
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3555
+#line 3607
nrange += tp[i] > X_DOUBLE_MAX ;
-#line 3555
+#line 3607
}
-#line 3555
+#line 3607
/* copy workspace back if necessary */
-#line 3555
+#line 3607
if (realign) {
-#line 3555
+#line 3607
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3555
+#line 3607
xp = (double *) *xpp;
-#line 3555
+#line 3607
}
-#line 3555
+#line 3607
/* update xpp and tp */
-#line 3555
+#line 3607
xp += ni;
-#line 3555
+#line 3607
tp += ni;
-#line 3555
+#line 3607
*xpp = (void*)xp;
-#line 3555
+#line 3607
}
-#line 3555
+#line 3607
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3555
+#line 3607
-#line 3555
+#line 3607
#else /* not SX */
-#line 3555
+#line 3607
-#line 3555
+#line 3607
char *xp = (char *) *xpp;
-#line 3555
+#line 3607
int status = NC_NOERR;
-#line 3555
+#line 3607
-#line 3555
+#line 3607
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3555
+#line 3607
{
-#line 3555
+#line 3607
int lstatus = ncx_put_double_uint(xp, tp, fillp);
-#line 3555
+#line 3607
if (status == NC_NOERR) /* report the first encountered error */
-#line 3555
+#line 3607
status = lstatus;
-#line 3555
+#line 3607
}
-#line 3555
+#line 3607
-#line 3555
+#line 3607
*xpp = (void *)xp;
-#line 3555
+#line 3607
return status;
-#line 3555
+#line 3607
#endif
-#line 3555
+#line 3607
}
-#line 3555
+#line 3607
int
-#line 3556
+#line 3608
ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3556
+#line 3608
{
-#line 3556
+#line 3608
#if defined(_SX) && _SX != 0 && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3556
+#line 3608
-#line 3556
+#line 3608
/* basic algorithm is:
-#line 3556
+#line 3608
* - ensure sane alignment of output data
-#line 3556
+#line 3608
* - copy (conversion happens automatically) input data
-#line 3556
+#line 3608
* to output
-#line 3556
+#line 3608
* - update tp to point at next unconverted input, and xpp to point
-#line 3556
+#line 3608
* at next location for converted output
-#line 3556
+#line 3608
*/
-#line 3556
+#line 3608
long i, j, ni;
-#line 3556
+#line 3608
double tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3556
+#line 3608
double *xp;
-#line 3556
+#line 3608
int nrange = 0; /* number of range errors */
-#line 3556
+#line 3608
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3556
+#line 3608
long cxp = (long) *((char**)xpp);
-#line 3556
+#line 3608
-#line 3556
+#line 3608
realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3556
+#line 3608
/* sjl: manually stripmine so we can limit amount of
-#line 3556
+#line 3608
* vector work space reserved to LOOPCNT elements. Also
-#line 3556
+#line 3608
* makes vectorisation easy */
-#line 3556
+#line 3608
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3556
+#line 3608
ni=Min(nelems-j,LOOPCNT);
-#line 3556
+#line 3608
if (realign) {
-#line 3556
+#line 3608
xp = tmp;
-#line 3556
+#line 3608
} else {
-#line 3556
+#line 3608
xp = (double *) *xpp;
-#line 3556
+#line 3608
}
-#line 3556
+#line 3608
/* copy the next block */
-#line 3556
+#line 3608
#pragma cdir loopcnt=LOOPCNT
-#line 3556
+#line 3608
#pragma cdir shortloop
-#line 3556
+#line 3608
for (i=0; i<ni; i++) {
-#line 3556
+#line 3608
/* the normal case: */
-#line 3556
+#line 3608
xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3556
+#line 3608
/* test for range errors (not always needed but do it anyway) */
-#line 3556
+#line 3608
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3556
+#line 3608
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3556
+#line 3608
nrange += tp[i] > X_DOUBLE_MAX ;
-#line 3556
+#line 3608
}
-#line 3556
+#line 3608
/* copy workspace back if necessary */
-#line 3556
+#line 3608
if (realign) {
-#line 3556
+#line 3608
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_DOUBLE);
-#line 3556
+#line 3608
xp = (double *) *xpp;
-#line 3556
+#line 3608
}
-#line 3556
+#line 3608
/* update xpp and tp */
-#line 3556
+#line 3608
xp += ni;
-#line 3556
+#line 3608
tp += ni;
-#line 3556
+#line 3608
*xpp = (void*)xp;
-#line 3556
+#line 3608
}
-#line 3556
+#line 3608
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3556
+#line 3608
-#line 3556
+#line 3608
#else /* not SX */
-#line 3556
+#line 3608
-#line 3556
+#line 3608
char *xp = (char *) *xpp;
-#line 3556
+#line 3608
int status = NC_NOERR;
-#line 3556
+#line 3608
-#line 3556
+#line 3608
for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3556
+#line 3608
{
-#line 3556
+#line 3608
int lstatus = ncx_put_double_ulonglong(xp, tp, fillp);
-#line 3556
+#line 3608
if (status == NC_NOERR) /* report the first encountered error */
-#line 3556
+#line 3608
status = lstatus;
-#line 3556
+#line 3608
}
-#line 3556
+#line 3608
-#line 3556
+#line 3608
*xpp = (void *)xp;
-#line 3556
+#line 3608
return status;
-#line 3556
+#line 3608
#endif
-#line 3556
+#line 3608
}
-#line 3556
+#line 3608
@@ -31308,1424 +33393,1424 @@ ncx_getn_longlong_longlong(const void **xpp, size_t nelems, long long *tp)
}
#else
int
-#line 3575
+#line 3627
ncx_getn_longlong_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3575
+#line 3627
{
-#line 3575
+#line 3627
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3575
+#line 3627
-#line 3575
+#line 3627
/* basic algorithm is:
-#line 3575
+#line 3627
* - ensure sane alignment of input data
-#line 3575
+#line 3627
* - copy (conversion happens automatically) input data
-#line 3575
+#line 3627
* to output
-#line 3575
+#line 3627
* - update xpp to point at next unconverted input, and tp to point
-#line 3575
+#line 3627
* at next location for converted output
-#line 3575
+#line 3627
*/
-#line 3575
+#line 3627
long i, j, ni;
-#line 3575
+#line 3627
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3575
+#line 3627
int64 *xp;
-#line 3575
+#line 3627
int nrange = 0; /* number of range errors */
-#line 3575
+#line 3627
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3575
+#line 3627
long cxp = (long) *((char**)xpp);
-#line 3575
+#line 3627
-#line 3575
+#line 3627
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3575
+#line 3627
/* sjl: manually stripmine so we can limit amount of
-#line 3575
+#line 3627
* vector work space reserved to LOOPCNT elements. Also
-#line 3575
+#line 3627
* makes vectorisation easy */
-#line 3575
+#line 3627
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3575
+#line 3627
ni=Min(nelems-j,LOOPCNT);
-#line 3575
+#line 3627
if (realign) {
-#line 3575
+#line 3627
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3575
+#line 3627
xp = tmp;
-#line 3575
+#line 3627
} else {
-#line 3575
+#line 3627
xp = (int64 *) *xpp;
-#line 3575
+#line 3627
}
-#line 3575
+#line 3627
/* copy the next block */
-#line 3575
+#line 3627
#pragma cdir loopcnt=LOOPCNT
-#line 3575
+#line 3627
#pragma cdir shortloop
-#line 3575
+#line 3627
for (i=0; i<ni; i++) {
-#line 3575
+#line 3627
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3575
+#line 3627
/* test for range errors (not always needed but do it anyway) */
-#line 3575
+#line 3627
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3575
+#line 3627
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3575
+#line 3627
nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
-#line 3575
+#line 3627
}
-#line 3575
+#line 3627
/* update xpp and tp */
-#line 3575
+#line 3627
if (realign) xp = (int64 *) *xpp;
-#line 3575
+#line 3627
xp += ni;
-#line 3575
+#line 3627
tp += ni;
-#line 3575
+#line 3627
*xpp = (void*)xp;
-#line 3575
+#line 3627
}
-#line 3575
+#line 3627
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3575
+#line 3627
-#line 3575
+#line 3627
#else /* not SX */
-#line 3575
+#line 3627
const char *xp = (const char *) *xpp;
-#line 3575
+#line 3627
int status = NC_NOERR;
-#line 3575
+#line 3627
-#line 3575
+#line 3627
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3575
+#line 3627
{
-#line 3575
+#line 3627
const int lstatus = ncx_get_longlong_longlong(xp, tp);
-#line 3575
+#line 3627
if (status == NC_NOERR) /* report the first encountered error */
-#line 3575
+#line 3627
status = lstatus;
-#line 3575
+#line 3627
}
-#line 3575
+#line 3627
-#line 3575
+#line 3627
*xpp = (const void *)xp;
-#line 3575
+#line 3627
return status;
-#line 3575
+#line 3627
#endif
-#line 3575
+#line 3627
}
-#line 3575
+#line 3627
#endif
int
-#line 3577
+#line 3629
ncx_getn_longlong_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3577
+#line 3629
{
-#line 3577
+#line 3629
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3577
+#line 3629
-#line 3577
+#line 3629
/* basic algorithm is:
-#line 3577
+#line 3629
* - ensure sane alignment of input data
-#line 3577
+#line 3629
* - copy (conversion happens automatically) input data
-#line 3577
+#line 3629
* to output
-#line 3577
+#line 3629
* - update xpp to point at next unconverted input, and tp to point
-#line 3577
+#line 3629
* at next location for converted output
-#line 3577
+#line 3629
*/
-#line 3577
+#line 3629
long i, j, ni;
-#line 3577
+#line 3629
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3577
+#line 3629
int64 *xp;
-#line 3577
+#line 3629
int nrange = 0; /* number of range errors */
-#line 3577
+#line 3629
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3577
+#line 3629
long cxp = (long) *((char**)xpp);
-#line 3577
+#line 3629
-#line 3577
+#line 3629
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3577
+#line 3629
/* sjl: manually stripmine so we can limit amount of
-#line 3577
+#line 3629
* vector work space reserved to LOOPCNT elements. Also
-#line 3577
+#line 3629
* makes vectorisation easy */
-#line 3577
+#line 3629
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3577
+#line 3629
ni=Min(nelems-j,LOOPCNT);
-#line 3577
+#line 3629
if (realign) {
-#line 3577
+#line 3629
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3577
+#line 3629
xp = tmp;
-#line 3577
+#line 3629
} else {
-#line 3577
+#line 3629
xp = (int64 *) *xpp;
-#line 3577
+#line 3629
}
-#line 3577
+#line 3629
/* copy the next block */
-#line 3577
+#line 3629
#pragma cdir loopcnt=LOOPCNT
-#line 3577
+#line 3629
#pragma cdir shortloop
-#line 3577
+#line 3629
for (i=0; i<ni; i++) {
-#line 3577
+#line 3629
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3577
+#line 3629
/* test for range errors (not always needed but do it anyway) */
-#line 3577
+#line 3629
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3577
+#line 3629
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3577
+#line 3629
nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
-#line 3577
+#line 3629
}
-#line 3577
+#line 3629
/* update xpp and tp */
-#line 3577
+#line 3629
if (realign) xp = (int64 *) *xpp;
-#line 3577
+#line 3629
xp += ni;
-#line 3577
+#line 3629
tp += ni;
-#line 3577
+#line 3629
*xpp = (void*)xp;
-#line 3577
+#line 3629
}
-#line 3577
+#line 3629
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3577
+#line 3629
-#line 3577
+#line 3629
#else /* not SX */
-#line 3577
+#line 3629
const char *xp = (const char *) *xpp;
-#line 3577
+#line 3629
int status = NC_NOERR;
-#line 3577
+#line 3629
-#line 3577
+#line 3629
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3577
+#line 3629
{
-#line 3577
+#line 3629
const int lstatus = ncx_get_longlong_schar(xp, tp);
-#line 3577
+#line 3629
if (status == NC_NOERR) /* report the first encountered error */
-#line 3577
+#line 3629
status = lstatus;
-#line 3577
+#line 3629
}
-#line 3577
+#line 3629
-#line 3577
+#line 3629
*xpp = (const void *)xp;
-#line 3577
+#line 3629
return status;
-#line 3577
+#line 3629
#endif
-#line 3577
+#line 3629
}
-#line 3577
+#line 3629
int
-#line 3578
+#line 3630
ncx_getn_longlong_short(const void **xpp, size_t nelems, short *tp)
-#line 3578
+#line 3630
{
-#line 3578
+#line 3630
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3578
+#line 3630
-#line 3578
+#line 3630
/* basic algorithm is:
-#line 3578
+#line 3630
* - ensure sane alignment of input data
-#line 3578
+#line 3630
* - copy (conversion happens automatically) input data
-#line 3578
+#line 3630
* to output
-#line 3578
+#line 3630
* - update xpp to point at next unconverted input, and tp to point
-#line 3578
+#line 3630
* at next location for converted output
-#line 3578
+#line 3630
*/
-#line 3578
+#line 3630
long i, j, ni;
-#line 3578
+#line 3630
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3578
+#line 3630
int64 *xp;
-#line 3578
+#line 3630
int nrange = 0; /* number of range errors */
-#line 3578
+#line 3630
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3578
+#line 3630
long cxp = (long) *((char**)xpp);
-#line 3578
+#line 3630
-#line 3578
+#line 3630
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3578
+#line 3630
/* sjl: manually stripmine so we can limit amount of
-#line 3578
+#line 3630
* vector work space reserved to LOOPCNT elements. Also
-#line 3578
+#line 3630
* makes vectorisation easy */
-#line 3578
+#line 3630
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3578
+#line 3630
ni=Min(nelems-j,LOOPCNT);
-#line 3578
+#line 3630
if (realign) {
-#line 3578
+#line 3630
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3578
+#line 3630
xp = tmp;
-#line 3578
+#line 3630
} else {
-#line 3578
+#line 3630
xp = (int64 *) *xpp;
-#line 3578
+#line 3630
}
-#line 3578
+#line 3630
/* copy the next block */
-#line 3578
+#line 3630
#pragma cdir loopcnt=LOOPCNT
-#line 3578
+#line 3630
#pragma cdir shortloop
-#line 3578
+#line 3630
for (i=0; i<ni; i++) {
-#line 3578
+#line 3630
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3578
+#line 3630
/* test for range errors (not always needed but do it anyway) */
-#line 3578
+#line 3630
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3578
+#line 3630
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3578
+#line 3630
nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
-#line 3578
+#line 3630
}
-#line 3578
+#line 3630
/* update xpp and tp */
-#line 3578
+#line 3630
if (realign) xp = (int64 *) *xpp;
-#line 3578
+#line 3630
xp += ni;
-#line 3578
+#line 3630
tp += ni;
-#line 3578
+#line 3630
*xpp = (void*)xp;
-#line 3578
+#line 3630
}
-#line 3578
+#line 3630
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3578
+#line 3630
-#line 3578
+#line 3630
#else /* not SX */
-#line 3578
+#line 3630
const char *xp = (const char *) *xpp;
-#line 3578
+#line 3630
int status = NC_NOERR;
-#line 3578
+#line 3630
-#line 3578
+#line 3630
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3578
+#line 3630
{
-#line 3578
+#line 3630
const int lstatus = ncx_get_longlong_short(xp, tp);
-#line 3578
+#line 3630
if (status == NC_NOERR) /* report the first encountered error */
-#line 3578
+#line 3630
status = lstatus;
-#line 3578
+#line 3630
}
-#line 3578
+#line 3630
-#line 3578
+#line 3630
*xpp = (const void *)xp;
-#line 3578
+#line 3630
return status;
-#line 3578
+#line 3630
#endif
-#line 3578
+#line 3630
}
-#line 3578
+#line 3630
int
-#line 3579
+#line 3631
ncx_getn_longlong_int(const void **xpp, size_t nelems, int *tp)
-#line 3579
+#line 3631
{
-#line 3579
+#line 3631
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3579
+#line 3631
-#line 3579
+#line 3631
/* basic algorithm is:
-#line 3579
+#line 3631
* - ensure sane alignment of input data
-#line 3579
+#line 3631
* - copy (conversion happens automatically) input data
-#line 3579
+#line 3631
* to output
-#line 3579
+#line 3631
* - update xpp to point at next unconverted input, and tp to point
-#line 3579
+#line 3631
* at next location for converted output
-#line 3579
+#line 3631
*/
-#line 3579
+#line 3631
long i, j, ni;
-#line 3579
+#line 3631
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3579
+#line 3631
int64 *xp;
-#line 3579
+#line 3631
int nrange = 0; /* number of range errors */
-#line 3579
+#line 3631
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3579
+#line 3631
long cxp = (long) *((char**)xpp);
-#line 3579
+#line 3631
-#line 3579
+#line 3631
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3579
+#line 3631
/* sjl: manually stripmine so we can limit amount of
-#line 3579
+#line 3631
* vector work space reserved to LOOPCNT elements. Also
-#line 3579
+#line 3631
* makes vectorisation easy */
-#line 3579
+#line 3631
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3579
+#line 3631
ni=Min(nelems-j,LOOPCNT);
-#line 3579
+#line 3631
if (realign) {
-#line 3579
+#line 3631
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3579
+#line 3631
xp = tmp;
-#line 3579
+#line 3631
} else {
-#line 3579
+#line 3631
xp = (int64 *) *xpp;
-#line 3579
+#line 3631
}
-#line 3579
+#line 3631
/* copy the next block */
-#line 3579
+#line 3631
#pragma cdir loopcnt=LOOPCNT
-#line 3579
+#line 3631
#pragma cdir shortloop
-#line 3579
+#line 3631
for (i=0; i<ni; i++) {
-#line 3579
+#line 3631
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3579
+#line 3631
/* test for range errors (not always needed but do it anyway) */
-#line 3579
+#line 3631
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3579
+#line 3631
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3579
+#line 3631
nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
-#line 3579
+#line 3631
}
-#line 3579
+#line 3631
/* update xpp and tp */
-#line 3579
+#line 3631
if (realign) xp = (int64 *) *xpp;
-#line 3579
+#line 3631
xp += ni;
-#line 3579
+#line 3631
tp += ni;
-#line 3579
+#line 3631
*xpp = (void*)xp;
-#line 3579
+#line 3631
}
-#line 3579
+#line 3631
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3579
+#line 3631
-#line 3579
+#line 3631
#else /* not SX */
-#line 3579
+#line 3631
const char *xp = (const char *) *xpp;
-#line 3579
+#line 3631
int status = NC_NOERR;
-#line 3579
+#line 3631
-#line 3579
+#line 3631
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3579
+#line 3631
{
-#line 3579
+#line 3631
const int lstatus = ncx_get_longlong_int(xp, tp);
-#line 3579
+#line 3631
if (status == NC_NOERR) /* report the first encountered error */
-#line 3579
+#line 3631
status = lstatus;
-#line 3579
+#line 3631
}
-#line 3579
+#line 3631
-#line 3579
+#line 3631
*xpp = (const void *)xp;
-#line 3579
+#line 3631
return status;
-#line 3579
+#line 3631
#endif
-#line 3579
+#line 3631
}
-#line 3579
+#line 3631
int
-#line 3580
+#line 3632
ncx_getn_longlong_long(const void **xpp, size_t nelems, long *tp)
-#line 3580
+#line 3632
{
-#line 3580
+#line 3632
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3580
+#line 3632
-#line 3580
+#line 3632
/* basic algorithm is:
-#line 3580
+#line 3632
* - ensure sane alignment of input data
-#line 3580
+#line 3632
* - copy (conversion happens automatically) input data
-#line 3580
+#line 3632
* to output
-#line 3580
+#line 3632
* - update xpp to point at next unconverted input, and tp to point
-#line 3580
+#line 3632
* at next location for converted output
-#line 3580
+#line 3632
*/
-#line 3580
+#line 3632
long i, j, ni;
-#line 3580
+#line 3632
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3580
+#line 3632
int64 *xp;
-#line 3580
+#line 3632
int nrange = 0; /* number of range errors */
-#line 3580
+#line 3632
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3580
+#line 3632
long cxp = (long) *((char**)xpp);
-#line 3580
+#line 3632
-#line 3580
+#line 3632
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3580
+#line 3632
/* sjl: manually stripmine so we can limit amount of
-#line 3580
+#line 3632
* vector work space reserved to LOOPCNT elements. Also
-#line 3580
+#line 3632
* makes vectorisation easy */
-#line 3580
+#line 3632
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3580
+#line 3632
ni=Min(nelems-j,LOOPCNT);
-#line 3580
+#line 3632
if (realign) {
-#line 3580
+#line 3632
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3580
+#line 3632
xp = tmp;
-#line 3580
+#line 3632
} else {
-#line 3580
+#line 3632
xp = (int64 *) *xpp;
-#line 3580
+#line 3632
}
-#line 3580
+#line 3632
/* copy the next block */
-#line 3580
+#line 3632
#pragma cdir loopcnt=LOOPCNT
-#line 3580
+#line 3632
#pragma cdir shortloop
-#line 3580
+#line 3632
for (i=0; i<ni; i++) {
-#line 3580
+#line 3632
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3580
+#line 3632
/* test for range errors (not always needed but do it anyway) */
-#line 3580
+#line 3632
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3580
+#line 3632
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3580
+#line 3632
nrange += xp[i] > LONG_MAX || xp[i] < LONG_MIN;
-#line 3580
+#line 3632
}
-#line 3580
+#line 3632
/* update xpp and tp */
-#line 3580
+#line 3632
if (realign) xp = (int64 *) *xpp;
-#line 3580
+#line 3632
xp += ni;
-#line 3580
+#line 3632
tp += ni;
-#line 3580
+#line 3632
*xpp = (void*)xp;
-#line 3580
+#line 3632
}
-#line 3580
+#line 3632
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3580
+#line 3632
-#line 3580
+#line 3632
#else /* not SX */
-#line 3580
+#line 3632
const char *xp = (const char *) *xpp;
-#line 3580
+#line 3632
int status = NC_NOERR;
-#line 3580
+#line 3632
-#line 3580
+#line 3632
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3580
+#line 3632
{
-#line 3580
+#line 3632
const int lstatus = ncx_get_longlong_long(xp, tp);
-#line 3580
+#line 3632
if (status == NC_NOERR) /* report the first encountered error */
-#line 3580
+#line 3632
status = lstatus;
-#line 3580
+#line 3632
}
-#line 3580
+#line 3632
-#line 3580
+#line 3632
*xpp = (const void *)xp;
-#line 3580
+#line 3632
return status;
-#line 3580
+#line 3632
#endif
-#line 3580
+#line 3632
}
-#line 3580
+#line 3632
int
-#line 3581
+#line 3633
ncx_getn_longlong_float(const void **xpp, size_t nelems, float *tp)
-#line 3581
+#line 3633
{
-#line 3581
+#line 3633
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3581
+#line 3633
-#line 3581
+#line 3633
/* basic algorithm is:
-#line 3581
+#line 3633
* - ensure sane alignment of input data
-#line 3581
+#line 3633
* - copy (conversion happens automatically) input data
-#line 3581
+#line 3633
* to output
-#line 3581
+#line 3633
* - update xpp to point at next unconverted input, and tp to point
-#line 3581
+#line 3633
* at next location for converted output
-#line 3581
+#line 3633
*/
-#line 3581
+#line 3633
long i, j, ni;
-#line 3581
+#line 3633
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3581
+#line 3633
int64 *xp;
-#line 3581
+#line 3633
int nrange = 0; /* number of range errors */
-#line 3581
+#line 3633
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3581
+#line 3633
long cxp = (long) *((char**)xpp);
-#line 3581
+#line 3633
-#line 3581
+#line 3633
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3581
+#line 3633
/* sjl: manually stripmine so we can limit amount of
-#line 3581
+#line 3633
* vector work space reserved to LOOPCNT elements. Also
-#line 3581
+#line 3633
* makes vectorisation easy */
-#line 3581
+#line 3633
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3581
+#line 3633
ni=Min(nelems-j,LOOPCNT);
-#line 3581
+#line 3633
if (realign) {
-#line 3581
+#line 3633
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3581
+#line 3633
xp = tmp;
-#line 3581
+#line 3633
} else {
-#line 3581
+#line 3633
xp = (int64 *) *xpp;
-#line 3581
+#line 3633
}
-#line 3581
+#line 3633
/* copy the next block */
-#line 3581
+#line 3633
#pragma cdir loopcnt=LOOPCNT
-#line 3581
+#line 3633
#pragma cdir shortloop
-#line 3581
+#line 3633
for (i=0; i<ni; i++) {
-#line 3581
+#line 3633
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3581
+#line 3633
/* test for range errors (not always needed but do it anyway) */
-#line 3581
+#line 3633
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3581
+#line 3633
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3581
+#line 3633
nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
-#line 3581
+#line 3633
}
-#line 3581
+#line 3633
/* update xpp and tp */
-#line 3581
+#line 3633
if (realign) xp = (int64 *) *xpp;
-#line 3581
+#line 3633
xp += ni;
-#line 3581
+#line 3633
tp += ni;
-#line 3581
+#line 3633
*xpp = (void*)xp;
-#line 3581
+#line 3633
}
-#line 3581
+#line 3633
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3581
+#line 3633
-#line 3581
+#line 3633
#else /* not SX */
-#line 3581
+#line 3633
const char *xp = (const char *) *xpp;
-#line 3581
+#line 3633
int status = NC_NOERR;
-#line 3581
+#line 3633
-#line 3581
+#line 3633
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3581
+#line 3633
{
-#line 3581
+#line 3633
const int lstatus = ncx_get_longlong_float(xp, tp);
-#line 3581
+#line 3633
if (status == NC_NOERR) /* report the first encountered error */
-#line 3581
+#line 3633
status = lstatus;
-#line 3581
+#line 3633
}
-#line 3581
+#line 3633
-#line 3581
+#line 3633
*xpp = (const void *)xp;
-#line 3581
+#line 3633
return status;
-#line 3581
+#line 3633
#endif
-#line 3581
+#line 3633
}
-#line 3581
+#line 3633
int
-#line 3582
+#line 3634
ncx_getn_longlong_double(const void **xpp, size_t nelems, double *tp)
-#line 3582
+#line 3634
{
-#line 3582
+#line 3634
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3582
+#line 3634
-#line 3582
+#line 3634
/* basic algorithm is:
-#line 3582
+#line 3634
* - ensure sane alignment of input data
-#line 3582
+#line 3634
* - copy (conversion happens automatically) input data
-#line 3582
+#line 3634
* to output
-#line 3582
+#line 3634
* - update xpp to point at next unconverted input, and tp to point
-#line 3582
+#line 3634
* at next location for converted output
-#line 3582
+#line 3634
*/
-#line 3582
+#line 3634
long i, j, ni;
-#line 3582
+#line 3634
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3582
+#line 3634
int64 *xp;
-#line 3582
+#line 3634
int nrange = 0; /* number of range errors */
-#line 3582
+#line 3634
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3582
+#line 3634
long cxp = (long) *((char**)xpp);
-#line 3582
+#line 3634
-#line 3582
+#line 3634
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3582
+#line 3634
/* sjl: manually stripmine so we can limit amount of
-#line 3582
+#line 3634
* vector work space reserved to LOOPCNT elements. Also
-#line 3582
+#line 3634
* makes vectorisation easy */
-#line 3582
+#line 3634
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3582
+#line 3634
ni=Min(nelems-j,LOOPCNT);
-#line 3582
+#line 3634
if (realign) {
-#line 3582
+#line 3634
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3582
+#line 3634
xp = tmp;
-#line 3582
+#line 3634
} else {
-#line 3582
+#line 3634
xp = (int64 *) *xpp;
-#line 3582
+#line 3634
}
-#line 3582
+#line 3634
/* copy the next block */
-#line 3582
+#line 3634
#pragma cdir loopcnt=LOOPCNT
-#line 3582
+#line 3634
#pragma cdir shortloop
-#line 3582
+#line 3634
for (i=0; i<ni; i++) {
-#line 3582
+#line 3634
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3582
+#line 3634
/* test for range errors (not always needed but do it anyway) */
-#line 3582
+#line 3634
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3582
+#line 3634
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3582
+#line 3634
nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
-#line 3582
+#line 3634
}
-#line 3582
+#line 3634
/* update xpp and tp */
-#line 3582
+#line 3634
if (realign) xp = (int64 *) *xpp;
-#line 3582
+#line 3634
xp += ni;
-#line 3582
+#line 3634
tp += ni;
-#line 3582
+#line 3634
*xpp = (void*)xp;
-#line 3582
+#line 3634
}
-#line 3582
+#line 3634
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3582
+#line 3634
-#line 3582
+#line 3634
#else /* not SX */
-#line 3582
+#line 3634
const char *xp = (const char *) *xpp;
-#line 3582
+#line 3634
int status = NC_NOERR;
-#line 3582
+#line 3634
-#line 3582
+#line 3634
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3582
+#line 3634
{
-#line 3582
+#line 3634
const int lstatus = ncx_get_longlong_double(xp, tp);
-#line 3582
+#line 3634
if (status == NC_NOERR) /* report the first encountered error */
-#line 3582
+#line 3634
status = lstatus;
-#line 3582
+#line 3634
}
-#line 3582
+#line 3634
-#line 3582
+#line 3634
*xpp = (const void *)xp;
-#line 3582
+#line 3634
return status;
-#line 3582
+#line 3634
#endif
-#line 3582
+#line 3634
}
-#line 3582
+#line 3634
int
-#line 3583
+#line 3635
ncx_getn_longlong_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3583
+#line 3635
{
-#line 3583
+#line 3635
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3583
+#line 3635
-#line 3583
+#line 3635
/* basic algorithm is:
-#line 3583
+#line 3635
* - ensure sane alignment of input data
-#line 3583
+#line 3635
* - copy (conversion happens automatically) input data
-#line 3583
+#line 3635
* to output
-#line 3583
+#line 3635
* - update xpp to point at next unconverted input, and tp to point
-#line 3583
+#line 3635
* at next location for converted output
-#line 3583
+#line 3635
*/
-#line 3583
+#line 3635
long i, j, ni;
-#line 3583
+#line 3635
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3583
+#line 3635
int64 *xp;
-#line 3583
+#line 3635
int nrange = 0; /* number of range errors */
-#line 3583
+#line 3635
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3583
+#line 3635
long cxp = (long) *((char**)xpp);
-#line 3583
+#line 3635
-#line 3583
+#line 3635
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3583
+#line 3635
/* sjl: manually stripmine so we can limit amount of
-#line 3583
+#line 3635
* vector work space reserved to LOOPCNT elements. Also
-#line 3583
+#line 3635
* makes vectorisation easy */
-#line 3583
+#line 3635
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3583
+#line 3635
ni=Min(nelems-j,LOOPCNT);
-#line 3583
+#line 3635
if (realign) {
-#line 3583
+#line 3635
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3583
+#line 3635
xp = tmp;
-#line 3583
+#line 3635
} else {
-#line 3583
+#line 3635
xp = (int64 *) *xpp;
-#line 3583
+#line 3635
}
-#line 3583
+#line 3635
/* copy the next block */
-#line 3583
+#line 3635
#pragma cdir loopcnt=LOOPCNT
-#line 3583
+#line 3635
#pragma cdir shortloop
-#line 3583
+#line 3635
for (i=0; i<ni; i++) {
-#line 3583
+#line 3635
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3583
+#line 3635
/* test for range errors (not always needed but do it anyway) */
-#line 3583
+#line 3635
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3583
+#line 3635
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3583
+#line 3635
nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
-#line 3583
+#line 3635
}
-#line 3583
+#line 3635
/* update xpp and tp */
-#line 3583
+#line 3635
if (realign) xp = (int64 *) *xpp;
-#line 3583
+#line 3635
xp += ni;
-#line 3583
+#line 3635
tp += ni;
-#line 3583
+#line 3635
*xpp = (void*)xp;
-#line 3583
+#line 3635
}
-#line 3583
+#line 3635
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3583
+#line 3635
-#line 3583
+#line 3635
#else /* not SX */
-#line 3583
+#line 3635
const char *xp = (const char *) *xpp;
-#line 3583
+#line 3635
int status = NC_NOERR;
-#line 3583
+#line 3635
-#line 3583
+#line 3635
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3583
+#line 3635
{
-#line 3583
+#line 3635
const int lstatus = ncx_get_longlong_uchar(xp, tp);
-#line 3583
+#line 3635
if (status == NC_NOERR) /* report the first encountered error */
-#line 3583
+#line 3635
status = lstatus;
-#line 3583
+#line 3635
}
-#line 3583
+#line 3635
-#line 3583
+#line 3635
*xpp = (const void *)xp;
-#line 3583
+#line 3635
return status;
-#line 3583
+#line 3635
#endif
-#line 3583
+#line 3635
}
-#line 3583
+#line 3635
int
-#line 3584
+#line 3636
ncx_getn_longlong_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3584
+#line 3636
{
-#line 3584
+#line 3636
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3584
+#line 3636
-#line 3584
+#line 3636
/* basic algorithm is:
-#line 3584
+#line 3636
* - ensure sane alignment of input data
-#line 3584
+#line 3636
* - copy (conversion happens automatically) input data
-#line 3584
+#line 3636
* to output
-#line 3584
+#line 3636
* - update xpp to point at next unconverted input, and tp to point
-#line 3584
+#line 3636
* at next location for converted output
-#line 3584
+#line 3636
*/
-#line 3584
+#line 3636
long i, j, ni;
-#line 3584
+#line 3636
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3584
+#line 3636
int64 *xp;
-#line 3584
+#line 3636
int nrange = 0; /* number of range errors */
-#line 3584
+#line 3636
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3584
+#line 3636
long cxp = (long) *((char**)xpp);
-#line 3584
+#line 3636
-#line 3584
+#line 3636
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3584
+#line 3636
/* sjl: manually stripmine so we can limit amount of
-#line 3584
+#line 3636
* vector work space reserved to LOOPCNT elements. Also
-#line 3584
+#line 3636
* makes vectorisation easy */
-#line 3584
+#line 3636
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3584
+#line 3636
ni=Min(nelems-j,LOOPCNT);
-#line 3584
+#line 3636
if (realign) {
-#line 3584
+#line 3636
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3584
+#line 3636
xp = tmp;
-#line 3584
+#line 3636
} else {
-#line 3584
+#line 3636
xp = (int64 *) *xpp;
-#line 3584
+#line 3636
}
-#line 3584
+#line 3636
/* copy the next block */
-#line 3584
+#line 3636
#pragma cdir loopcnt=LOOPCNT
-#line 3584
+#line 3636
#pragma cdir shortloop
-#line 3584
+#line 3636
for (i=0; i<ni; i++) {
-#line 3584
+#line 3636
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3584
+#line 3636
/* test for range errors (not always needed but do it anyway) */
-#line 3584
+#line 3636
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3584
+#line 3636
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3584
+#line 3636
nrange += xp[i] > USHORT_MAX || xp[i] < 0;
-#line 3584
+#line 3636
}
-#line 3584
+#line 3636
/* update xpp and tp */
-#line 3584
+#line 3636
if (realign) xp = (int64 *) *xpp;
-#line 3584
+#line 3636
xp += ni;
-#line 3584
+#line 3636
tp += ni;
-#line 3584
+#line 3636
*xpp = (void*)xp;
-#line 3584
+#line 3636
}
-#line 3584
+#line 3636
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3584
+#line 3636
-#line 3584
+#line 3636
#else /* not SX */
-#line 3584
+#line 3636
const char *xp = (const char *) *xpp;
-#line 3584
+#line 3636
int status = NC_NOERR;
-#line 3584
+#line 3636
-#line 3584
+#line 3636
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3584
+#line 3636
{
-#line 3584
+#line 3636
const int lstatus = ncx_get_longlong_ushort(xp, tp);
-#line 3584
+#line 3636
if (status == NC_NOERR) /* report the first encountered error */
-#line 3584
+#line 3636
status = lstatus;
-#line 3584
+#line 3636
}
-#line 3584
+#line 3636
-#line 3584
+#line 3636
*xpp = (const void *)xp;
-#line 3584
+#line 3636
return status;
-#line 3584
+#line 3636
#endif
-#line 3584
+#line 3636
}
-#line 3584
+#line 3636
int
-#line 3585
+#line 3637
ncx_getn_longlong_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3585
+#line 3637
{
-#line 3585
+#line 3637
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3585
+#line 3637
-#line 3585
+#line 3637
/* basic algorithm is:
-#line 3585
+#line 3637
* - ensure sane alignment of input data
-#line 3585
+#line 3637
* - copy (conversion happens automatically) input data
-#line 3585
+#line 3637
* to output
-#line 3585
+#line 3637
* - update xpp to point at next unconverted input, and tp to point
-#line 3585
+#line 3637
* at next location for converted output
-#line 3585
+#line 3637
*/
-#line 3585
+#line 3637
long i, j, ni;
-#line 3585
+#line 3637
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3585
+#line 3637
int64 *xp;
-#line 3585
+#line 3637
int nrange = 0; /* number of range errors */
-#line 3585
+#line 3637
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3585
+#line 3637
long cxp = (long) *((char**)xpp);
-#line 3585
+#line 3637
-#line 3585
+#line 3637
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3585
+#line 3637
/* sjl: manually stripmine so we can limit amount of
-#line 3585
+#line 3637
* vector work space reserved to LOOPCNT elements. Also
-#line 3585
+#line 3637
* makes vectorisation easy */
-#line 3585
+#line 3637
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3585
+#line 3637
ni=Min(nelems-j,LOOPCNT);
-#line 3585
+#line 3637
if (realign) {
-#line 3585
+#line 3637
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3585
+#line 3637
xp = tmp;
-#line 3585
+#line 3637
} else {
-#line 3585
+#line 3637
xp = (int64 *) *xpp;
-#line 3585
+#line 3637
}
-#line 3585
+#line 3637
/* copy the next block */
-#line 3585
+#line 3637
#pragma cdir loopcnt=LOOPCNT
-#line 3585
+#line 3637
#pragma cdir shortloop
-#line 3585
+#line 3637
for (i=0; i<ni; i++) {
-#line 3585
+#line 3637
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3585
+#line 3637
/* test for range errors (not always needed but do it anyway) */
-#line 3585
+#line 3637
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3585
+#line 3637
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3585
+#line 3637
nrange += xp[i] > UINT_MAX || xp[i] < 0;
-#line 3585
+#line 3637
}
-#line 3585
+#line 3637
/* update xpp and tp */
-#line 3585
+#line 3637
if (realign) xp = (int64 *) *xpp;
-#line 3585
+#line 3637
xp += ni;
-#line 3585
+#line 3637
tp += ni;
-#line 3585
+#line 3637
*xpp = (void*)xp;
-#line 3585
+#line 3637
}
-#line 3585
+#line 3637
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3585
+#line 3637
-#line 3585
+#line 3637
#else /* not SX */
-#line 3585
+#line 3637
const char *xp = (const char *) *xpp;
-#line 3585
+#line 3637
int status = NC_NOERR;
-#line 3585
+#line 3637
-#line 3585
+#line 3637
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3585
+#line 3637
{
-#line 3585
+#line 3637
const int lstatus = ncx_get_longlong_uint(xp, tp);
-#line 3585
+#line 3637
if (status == NC_NOERR) /* report the first encountered error */
-#line 3585
+#line 3637
status = lstatus;
-#line 3585
+#line 3637
}
-#line 3585
+#line 3637
-#line 3585
+#line 3637
*xpp = (const void *)xp;
-#line 3585
+#line 3637
return status;
-#line 3585
+#line 3637
#endif
-#line 3585
+#line 3637
}
-#line 3585
+#line 3637
int
-#line 3586
+#line 3638
ncx_getn_longlong_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3586
+#line 3638
{
-#line 3586
+#line 3638
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3586
+#line 3638
-#line 3586
+#line 3638
/* basic algorithm is:
-#line 3586
+#line 3638
* - ensure sane alignment of input data
-#line 3586
+#line 3638
* - copy (conversion happens automatically) input data
-#line 3586
+#line 3638
* to output
-#line 3586
+#line 3638
* - update xpp to point at next unconverted input, and tp to point
-#line 3586
+#line 3638
* at next location for converted output
-#line 3586
+#line 3638
*/
-#line 3586
+#line 3638
long i, j, ni;
-#line 3586
+#line 3638
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3586
+#line 3638
int64 *xp;
-#line 3586
+#line 3638
int nrange = 0; /* number of range errors */
-#line 3586
+#line 3638
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3586
+#line 3638
long cxp = (long) *((char**)xpp);
-#line 3586
+#line 3638
-#line 3586
+#line 3638
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3586
+#line 3638
/* sjl: manually stripmine so we can limit amount of
-#line 3586
+#line 3638
* vector work space reserved to LOOPCNT elements. Also
-#line 3586
+#line 3638
* makes vectorisation easy */
-#line 3586
+#line 3638
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3586
+#line 3638
ni=Min(nelems-j,LOOPCNT);
-#line 3586
+#line 3638
if (realign) {
-#line 3586
+#line 3638
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_INT64));
-#line 3586
+#line 3638
xp = tmp;
-#line 3586
+#line 3638
} else {
-#line 3586
+#line 3638
xp = (int64 *) *xpp;
-#line 3586
+#line 3638
}
-#line 3586
+#line 3638
/* copy the next block */
-#line 3586
+#line 3638
#pragma cdir loopcnt=LOOPCNT
-#line 3586
+#line 3638
#pragma cdir shortloop
-#line 3586
+#line 3638
for (i=0; i<ni; i++) {
-#line 3586
+#line 3638
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3586
+#line 3638
/* test for range errors (not always needed but do it anyway) */
-#line 3586
+#line 3638
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3586
+#line 3638
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3586
+#line 3638
nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
-#line 3586
+#line 3638
}
-#line 3586
+#line 3638
/* update xpp and tp */
-#line 3586
+#line 3638
if (realign) xp = (int64 *) *xpp;
-#line 3586
+#line 3638
xp += ni;
-#line 3586
+#line 3638
tp += ni;
-#line 3586
+#line 3638
*xpp = (void*)xp;
-#line 3586
+#line 3638
}
-#line 3586
+#line 3638
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3586
+#line 3638
-#line 3586
+#line 3638
#else /* not SX */
-#line 3586
+#line 3638
const char *xp = (const char *) *xpp;
-#line 3586
+#line 3638
int status = NC_NOERR;
-#line 3586
+#line 3638
-#line 3586
+#line 3638
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3586
+#line 3638
{
-#line 3586
+#line 3638
const int lstatus = ncx_get_longlong_ulonglong(xp, tp);
-#line 3586
+#line 3638
if (status == NC_NOERR) /* report the first encountered error */
-#line 3586
+#line 3638
status = lstatus;
-#line 3586
+#line 3638
}
-#line 3586
+#line 3638
-#line 3586
+#line 3638
*xpp = (const void *)xp;
-#line 3586
+#line 3638
return status;
-#line 3586
+#line 3638
#endif
-#line 3586
+#line 3638
}
-#line 3586
+#line 3638
#if X_SIZEOF_INT64 == SIZEOF_LONGLONG
@@ -32743,1534 +34828,1534 @@ ncx_putn_longlong_longlong(void **xpp, size_t nelems, const long long *tp, void
}
#else
int
-#line 3602
+#line 3654
ncx_putn_longlong_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3602
+#line 3654
{
-#line 3602
+#line 3654
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3602
+#line 3654
-#line 3602
+#line 3654
/* basic algorithm is:
-#line 3602
+#line 3654
* - ensure sane alignment of output data
-#line 3602
+#line 3654
* - copy (conversion happens automatically) input data
-#line 3602
+#line 3654
* to output
-#line 3602
+#line 3654
* - update tp to point at next unconverted input, and xpp to point
-#line 3602
+#line 3654
* at next location for converted output
-#line 3602
+#line 3654
*/
-#line 3602
+#line 3654
long i, j, ni;
-#line 3602
+#line 3654
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3602
+#line 3654
int64 *xp;
-#line 3602
+#line 3654
int nrange = 0; /* number of range errors */
-#line 3602
+#line 3654
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3602
+#line 3654
long cxp = (long) *((char**)xpp);
-#line 3602
+#line 3654
-#line 3602
+#line 3654
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3602
+#line 3654
/* sjl: manually stripmine so we can limit amount of
-#line 3602
+#line 3654
* vector work space reserved to LOOPCNT elements. Also
-#line 3602
+#line 3654
* makes vectorisation easy */
-#line 3602
+#line 3654
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3602
+#line 3654
ni=Min(nelems-j,LOOPCNT);
-#line 3602
+#line 3654
if (realign) {
-#line 3602
+#line 3654
xp = tmp;
-#line 3602
+#line 3654
} else {
-#line 3602
+#line 3654
xp = (int64 *) *xpp;
-#line 3602
+#line 3654
}
-#line 3602
+#line 3654
/* copy the next block */
-#line 3602
+#line 3654
#pragma cdir loopcnt=LOOPCNT
-#line 3602
+#line 3654
#pragma cdir shortloop
-#line 3602
+#line 3654
for (i=0; i<ni; i++) {
-#line 3602
+#line 3654
/* the normal case: */
-#line 3602
+#line 3654
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3602
+#line 3654
/* test for range errors (not always needed but do it anyway) */
-#line 3602
+#line 3654
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3602
+#line 3654
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3602
+#line 3654
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3602
+#line 3654
}
-#line 3602
+#line 3654
/* copy workspace back if necessary */
-#line 3602
+#line 3654
if (realign) {
-#line 3602
+#line 3654
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3602
+#line 3654
xp = (int64 *) *xpp;
-#line 3602
+#line 3654
}
-#line 3602
+#line 3654
/* update xpp and tp */
-#line 3602
+#line 3654
xp += ni;
-#line 3602
+#line 3654
tp += ni;
-#line 3602
+#line 3654
*xpp = (void*)xp;
-#line 3602
+#line 3654
}
-#line 3602
+#line 3654
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3602
+#line 3654
-#line 3602
+#line 3654
#else /* not SX */
-#line 3602
+#line 3654
-#line 3602
+#line 3654
char *xp = (char *) *xpp;
-#line 3602
+#line 3654
int status = NC_NOERR;
-#line 3602
+#line 3654
-#line 3602
+#line 3654
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3602
+#line 3654
{
-#line 3602
+#line 3654
int lstatus = ncx_put_longlong_longlong(xp, tp, fillp);
-#line 3602
+#line 3654
if (status == NC_NOERR) /* report the first encountered error */
-#line 3602
+#line 3654
status = lstatus;
-#line 3602
+#line 3654
}
-#line 3602
+#line 3654
-#line 3602
+#line 3654
*xpp = (void *)xp;
-#line 3602
+#line 3654
return status;
-#line 3602
+#line 3654
#endif
-#line 3602
+#line 3654
}
-#line 3602
+#line 3654
#endif
int
-#line 3604
+#line 3656
ncx_putn_longlong_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3604
+#line 3656
{
-#line 3604
+#line 3656
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3604
+#line 3656
-#line 3604
+#line 3656
/* basic algorithm is:
-#line 3604
+#line 3656
* - ensure sane alignment of output data
-#line 3604
+#line 3656
* - copy (conversion happens automatically) input data
-#line 3604
+#line 3656
* to output
-#line 3604
+#line 3656
* - update tp to point at next unconverted input, and xpp to point
-#line 3604
+#line 3656
* at next location for converted output
-#line 3604
+#line 3656
*/
-#line 3604
+#line 3656
long i, j, ni;
-#line 3604
+#line 3656
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3604
+#line 3656
int64 *xp;
-#line 3604
+#line 3656
int nrange = 0; /* number of range errors */
-#line 3604
+#line 3656
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3604
+#line 3656
long cxp = (long) *((char**)xpp);
-#line 3604
+#line 3656
-#line 3604
+#line 3656
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3604
+#line 3656
/* sjl: manually stripmine so we can limit amount of
-#line 3604
+#line 3656
* vector work space reserved to LOOPCNT elements. Also
-#line 3604
+#line 3656
* makes vectorisation easy */
-#line 3604
+#line 3656
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3604
+#line 3656
ni=Min(nelems-j,LOOPCNT);
-#line 3604
+#line 3656
if (realign) {
-#line 3604
+#line 3656
xp = tmp;
-#line 3604
+#line 3656
} else {
-#line 3604
+#line 3656
xp = (int64 *) *xpp;
-#line 3604
+#line 3656
}
-#line 3604
+#line 3656
/* copy the next block */
-#line 3604
+#line 3656
#pragma cdir loopcnt=LOOPCNT
-#line 3604
+#line 3656
#pragma cdir shortloop
-#line 3604
+#line 3656
for (i=0; i<ni; i++) {
-#line 3604
+#line 3656
/* the normal case: */
-#line 3604
+#line 3656
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3604
+#line 3656
/* test for range errors (not always needed but do it anyway) */
-#line 3604
+#line 3656
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3604
+#line 3656
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3604
+#line 3656
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3604
+#line 3656
}
-#line 3604
+#line 3656
/* copy workspace back if necessary */
-#line 3604
+#line 3656
if (realign) {
-#line 3604
+#line 3656
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3604
+#line 3656
xp = (int64 *) *xpp;
-#line 3604
+#line 3656
}
-#line 3604
+#line 3656
/* update xpp and tp */
-#line 3604
+#line 3656
xp += ni;
-#line 3604
+#line 3656
tp += ni;
-#line 3604
+#line 3656
*xpp = (void*)xp;
-#line 3604
+#line 3656
}
-#line 3604
+#line 3656
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3604
+#line 3656
-#line 3604
+#line 3656
#else /* not SX */
-#line 3604
+#line 3656
-#line 3604
+#line 3656
char *xp = (char *) *xpp;
-#line 3604
+#line 3656
int status = NC_NOERR;
-#line 3604
+#line 3656
-#line 3604
+#line 3656
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3604
+#line 3656
{
-#line 3604
+#line 3656
int lstatus = ncx_put_longlong_schar(xp, tp, fillp);
-#line 3604
+#line 3656
if (status == NC_NOERR) /* report the first encountered error */
-#line 3604
+#line 3656
status = lstatus;
-#line 3604
+#line 3656
}
-#line 3604
+#line 3656
-#line 3604
+#line 3656
*xpp = (void *)xp;
-#line 3604
+#line 3656
return status;
-#line 3604
+#line 3656
#endif
-#line 3604
+#line 3656
}
-#line 3604
+#line 3656
int
-#line 3605
+#line 3657
ncx_putn_longlong_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3605
+#line 3657
{
-#line 3605
+#line 3657
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3605
+#line 3657
-#line 3605
+#line 3657
/* basic algorithm is:
-#line 3605
+#line 3657
* - ensure sane alignment of output data
-#line 3605
+#line 3657
* - copy (conversion happens automatically) input data
-#line 3605
+#line 3657
* to output
-#line 3605
+#line 3657
* - update tp to point at next unconverted input, and xpp to point
-#line 3605
+#line 3657
* at next location for converted output
-#line 3605
+#line 3657
*/
-#line 3605
+#line 3657
long i, j, ni;
-#line 3605
+#line 3657
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3605
+#line 3657
int64 *xp;
-#line 3605
+#line 3657
int nrange = 0; /* number of range errors */
-#line 3605
+#line 3657
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3605
+#line 3657
long cxp = (long) *((char**)xpp);
-#line 3605
+#line 3657
-#line 3605
+#line 3657
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3605
+#line 3657
/* sjl: manually stripmine so we can limit amount of
-#line 3605
+#line 3657
* vector work space reserved to LOOPCNT elements. Also
-#line 3605
+#line 3657
* makes vectorisation easy */
-#line 3605
+#line 3657
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3605
+#line 3657
ni=Min(nelems-j,LOOPCNT);
-#line 3605
+#line 3657
if (realign) {
-#line 3605
+#line 3657
xp = tmp;
-#line 3605
+#line 3657
} else {
-#line 3605
+#line 3657
xp = (int64 *) *xpp;
-#line 3605
+#line 3657
}
-#line 3605
+#line 3657
/* copy the next block */
-#line 3605
+#line 3657
#pragma cdir loopcnt=LOOPCNT
-#line 3605
+#line 3657
#pragma cdir shortloop
-#line 3605
+#line 3657
for (i=0; i<ni; i++) {
-#line 3605
+#line 3657
/* the normal case: */
-#line 3605
+#line 3657
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3605
+#line 3657
/* test for range errors (not always needed but do it anyway) */
-#line 3605
+#line 3657
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3605
+#line 3657
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3605
+#line 3657
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3605
+#line 3657
}
-#line 3605
+#line 3657
/* copy workspace back if necessary */
-#line 3605
+#line 3657
if (realign) {
-#line 3605
+#line 3657
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3605
+#line 3657
xp = (int64 *) *xpp;
-#line 3605
+#line 3657
}
-#line 3605
+#line 3657
/* update xpp and tp */
-#line 3605
+#line 3657
xp += ni;
-#line 3605
+#line 3657
tp += ni;
-#line 3605
+#line 3657
*xpp = (void*)xp;
-#line 3605
+#line 3657
}
-#line 3605
+#line 3657
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3605
+#line 3657
-#line 3605
+#line 3657
#else /* not SX */
-#line 3605
+#line 3657
-#line 3605
+#line 3657
char *xp = (char *) *xpp;
-#line 3605
+#line 3657
int status = NC_NOERR;
-#line 3605
+#line 3657
-#line 3605
+#line 3657
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3605
+#line 3657
{
-#line 3605
+#line 3657
int lstatus = ncx_put_longlong_short(xp, tp, fillp);
-#line 3605
+#line 3657
if (status == NC_NOERR) /* report the first encountered error */
-#line 3605
+#line 3657
status = lstatus;
-#line 3605
+#line 3657
}
-#line 3605
+#line 3657
-#line 3605
+#line 3657
*xpp = (void *)xp;
-#line 3605
+#line 3657
return status;
-#line 3605
+#line 3657
#endif
-#line 3605
+#line 3657
}
-#line 3605
+#line 3657
int
-#line 3606
+#line 3658
ncx_putn_longlong_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3606
+#line 3658
{
-#line 3606
+#line 3658
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3606
+#line 3658
-#line 3606
+#line 3658
/* basic algorithm is:
-#line 3606
+#line 3658
* - ensure sane alignment of output data
-#line 3606
+#line 3658
* - copy (conversion happens automatically) input data
-#line 3606
+#line 3658
* to output
-#line 3606
+#line 3658
* - update tp to point at next unconverted input, and xpp to point
-#line 3606
+#line 3658
* at next location for converted output
-#line 3606
+#line 3658
*/
-#line 3606
+#line 3658
long i, j, ni;
-#line 3606
+#line 3658
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3606
+#line 3658
int64 *xp;
-#line 3606
+#line 3658
int nrange = 0; /* number of range errors */
-#line 3606
+#line 3658
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3606
+#line 3658
long cxp = (long) *((char**)xpp);
-#line 3606
+#line 3658
-#line 3606
+#line 3658
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3606
+#line 3658
/* sjl: manually stripmine so we can limit amount of
-#line 3606
+#line 3658
* vector work space reserved to LOOPCNT elements. Also
-#line 3606
+#line 3658
* makes vectorisation easy */
-#line 3606
+#line 3658
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3606
+#line 3658
ni=Min(nelems-j,LOOPCNT);
-#line 3606
+#line 3658
if (realign) {
-#line 3606
+#line 3658
xp = tmp;
-#line 3606
+#line 3658
} else {
-#line 3606
+#line 3658
xp = (int64 *) *xpp;
-#line 3606
+#line 3658
}
-#line 3606
+#line 3658
/* copy the next block */
-#line 3606
+#line 3658
#pragma cdir loopcnt=LOOPCNT
-#line 3606
+#line 3658
#pragma cdir shortloop
-#line 3606
+#line 3658
for (i=0; i<ni; i++) {
-#line 3606
+#line 3658
/* the normal case: */
-#line 3606
+#line 3658
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3606
+#line 3658
/* test for range errors (not always needed but do it anyway) */
-#line 3606
+#line 3658
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3606
+#line 3658
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3606
+#line 3658
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3606
+#line 3658
}
-#line 3606
+#line 3658
/* copy workspace back if necessary */
-#line 3606
+#line 3658
if (realign) {
-#line 3606
+#line 3658
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3606
+#line 3658
xp = (int64 *) *xpp;
-#line 3606
+#line 3658
}
-#line 3606
+#line 3658
/* update xpp and tp */
-#line 3606
+#line 3658
xp += ni;
-#line 3606
+#line 3658
tp += ni;
-#line 3606
+#line 3658
*xpp = (void*)xp;
-#line 3606
+#line 3658
}
-#line 3606
+#line 3658
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3606
+#line 3658
-#line 3606
+#line 3658
#else /* not SX */
-#line 3606
+#line 3658
-#line 3606
+#line 3658
char *xp = (char *) *xpp;
-#line 3606
+#line 3658
int status = NC_NOERR;
-#line 3606
+#line 3658
-#line 3606
+#line 3658
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3606
+#line 3658
{
-#line 3606
+#line 3658
int lstatus = ncx_put_longlong_int(xp, tp, fillp);
-#line 3606
+#line 3658
if (status == NC_NOERR) /* report the first encountered error */
-#line 3606
+#line 3658
status = lstatus;
-#line 3606
+#line 3658
}
-#line 3606
+#line 3658
-#line 3606
+#line 3658
*xpp = (void *)xp;
-#line 3606
+#line 3658
return status;
-#line 3606
+#line 3658
#endif
-#line 3606
+#line 3658
}
-#line 3606
+#line 3658
int
-#line 3607
+#line 3659
ncx_putn_longlong_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3607
+#line 3659
{
-#line 3607
+#line 3659
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3607
+#line 3659
-#line 3607
+#line 3659
/* basic algorithm is:
-#line 3607
+#line 3659
* - ensure sane alignment of output data
-#line 3607
+#line 3659
* - copy (conversion happens automatically) input data
-#line 3607
+#line 3659
* to output
-#line 3607
+#line 3659
* - update tp to point at next unconverted input, and xpp to point
-#line 3607
+#line 3659
* at next location for converted output
-#line 3607
+#line 3659
*/
-#line 3607
+#line 3659
long i, j, ni;
-#line 3607
+#line 3659
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3607
+#line 3659
int64 *xp;
-#line 3607
+#line 3659
int nrange = 0; /* number of range errors */
-#line 3607
+#line 3659
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3607
+#line 3659
long cxp = (long) *((char**)xpp);
-#line 3607
+#line 3659
-#line 3607
+#line 3659
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3607
+#line 3659
/* sjl: manually stripmine so we can limit amount of
-#line 3607
+#line 3659
* vector work space reserved to LOOPCNT elements. Also
-#line 3607
+#line 3659
* makes vectorisation easy */
-#line 3607
+#line 3659
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3607
+#line 3659
ni=Min(nelems-j,LOOPCNT);
-#line 3607
+#line 3659
if (realign) {
-#line 3607
+#line 3659
xp = tmp;
-#line 3607
+#line 3659
} else {
-#line 3607
+#line 3659
xp = (int64 *) *xpp;
-#line 3607
+#line 3659
}
-#line 3607
+#line 3659
/* copy the next block */
-#line 3607
+#line 3659
#pragma cdir loopcnt=LOOPCNT
-#line 3607
+#line 3659
#pragma cdir shortloop
-#line 3607
+#line 3659
for (i=0; i<ni; i++) {
-#line 3607
+#line 3659
/* the normal case: */
-#line 3607
+#line 3659
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3607
+#line 3659
/* test for range errors (not always needed but do it anyway) */
-#line 3607
+#line 3659
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3607
+#line 3659
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3607
+#line 3659
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3607
+#line 3659
}
-#line 3607
+#line 3659
/* copy workspace back if necessary */
-#line 3607
+#line 3659
if (realign) {
-#line 3607
+#line 3659
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3607
+#line 3659
xp = (int64 *) *xpp;
-#line 3607
+#line 3659
}
-#line 3607
+#line 3659
/* update xpp and tp */
-#line 3607
+#line 3659
xp += ni;
-#line 3607
+#line 3659
tp += ni;
-#line 3607
+#line 3659
*xpp = (void*)xp;
-#line 3607
+#line 3659
}
-#line 3607
+#line 3659
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3607
+#line 3659
-#line 3607
+#line 3659
#else /* not SX */
-#line 3607
+#line 3659
-#line 3607
+#line 3659
char *xp = (char *) *xpp;
-#line 3607
+#line 3659
int status = NC_NOERR;
-#line 3607
+#line 3659
-#line 3607
+#line 3659
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3607
+#line 3659
{
-#line 3607
+#line 3659
int lstatus = ncx_put_longlong_long(xp, tp, fillp);
-#line 3607
+#line 3659
if (status == NC_NOERR) /* report the first encountered error */
-#line 3607
+#line 3659
status = lstatus;
-#line 3607
+#line 3659
}
-#line 3607
+#line 3659
-#line 3607
+#line 3659
*xpp = (void *)xp;
-#line 3607
+#line 3659
return status;
-#line 3607
+#line 3659
#endif
-#line 3607
+#line 3659
}
-#line 3607
+#line 3659
int
-#line 3608
+#line 3660
ncx_putn_longlong_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3608
+#line 3660
{
-#line 3608
+#line 3660
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3608
+#line 3660
-#line 3608
+#line 3660
/* basic algorithm is:
-#line 3608
+#line 3660
* - ensure sane alignment of output data
-#line 3608
+#line 3660
* - copy (conversion happens automatically) input data
-#line 3608
+#line 3660
* to output
-#line 3608
+#line 3660
* - update tp to point at next unconverted input, and xpp to point
-#line 3608
+#line 3660
* at next location for converted output
-#line 3608
+#line 3660
*/
-#line 3608
+#line 3660
long i, j, ni;
-#line 3608
+#line 3660
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3608
+#line 3660
int64 *xp;
-#line 3608
+#line 3660
int nrange = 0; /* number of range errors */
-#line 3608
+#line 3660
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3608
+#line 3660
long cxp = (long) *((char**)xpp);
-#line 3608
+#line 3660
-#line 3608
+#line 3660
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3608
+#line 3660
/* sjl: manually stripmine so we can limit amount of
-#line 3608
+#line 3660
* vector work space reserved to LOOPCNT elements. Also
-#line 3608
+#line 3660
* makes vectorisation easy */
-#line 3608
+#line 3660
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3608
+#line 3660
ni=Min(nelems-j,LOOPCNT);
-#line 3608
+#line 3660
if (realign) {
-#line 3608
+#line 3660
xp = tmp;
-#line 3608
+#line 3660
} else {
-#line 3608
+#line 3660
xp = (int64 *) *xpp;
-#line 3608
+#line 3660
}
-#line 3608
+#line 3660
/* copy the next block */
-#line 3608
+#line 3660
#pragma cdir loopcnt=LOOPCNT
-#line 3608
+#line 3660
#pragma cdir shortloop
-#line 3608
+#line 3660
for (i=0; i<ni; i++) {
-#line 3608
+#line 3660
/* the normal case: */
-#line 3608
+#line 3660
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3608
+#line 3660
/* test for range errors (not always needed but do it anyway) */
-#line 3608
+#line 3660
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3608
+#line 3660
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3608
+#line 3660
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3608
+#line 3660
}
-#line 3608
+#line 3660
/* copy workspace back if necessary */
-#line 3608
+#line 3660
if (realign) {
-#line 3608
+#line 3660
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3608
+#line 3660
xp = (int64 *) *xpp;
-#line 3608
+#line 3660
}
-#line 3608
+#line 3660
/* update xpp and tp */
-#line 3608
+#line 3660
xp += ni;
-#line 3608
+#line 3660
tp += ni;
-#line 3608
+#line 3660
*xpp = (void*)xp;
-#line 3608
+#line 3660
}
-#line 3608
+#line 3660
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3608
+#line 3660
-#line 3608
+#line 3660
#else /* not SX */
-#line 3608
+#line 3660
-#line 3608
+#line 3660
char *xp = (char *) *xpp;
-#line 3608
+#line 3660
int status = NC_NOERR;
-#line 3608
+#line 3660
-#line 3608
+#line 3660
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3608
+#line 3660
{
-#line 3608
+#line 3660
int lstatus = ncx_put_longlong_float(xp, tp, fillp);
-#line 3608
+#line 3660
if (status == NC_NOERR) /* report the first encountered error */
-#line 3608
+#line 3660
status = lstatus;
-#line 3608
+#line 3660
}
-#line 3608
+#line 3660
-#line 3608
+#line 3660
*xpp = (void *)xp;
-#line 3608
+#line 3660
return status;
-#line 3608
+#line 3660
#endif
-#line 3608
+#line 3660
}
-#line 3608
+#line 3660
int
-#line 3609
+#line 3661
ncx_putn_longlong_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3609
+#line 3661
{
-#line 3609
+#line 3661
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3609
+#line 3661
-#line 3609
+#line 3661
/* basic algorithm is:
-#line 3609
+#line 3661
* - ensure sane alignment of output data
-#line 3609
+#line 3661
* - copy (conversion happens automatically) input data
-#line 3609
+#line 3661
* to output
-#line 3609
+#line 3661
* - update tp to point at next unconverted input, and xpp to point
-#line 3609
+#line 3661
* at next location for converted output
-#line 3609
+#line 3661
*/
-#line 3609
+#line 3661
long i, j, ni;
-#line 3609
+#line 3661
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3609
+#line 3661
int64 *xp;
-#line 3609
+#line 3661
int nrange = 0; /* number of range errors */
-#line 3609
+#line 3661
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3609
+#line 3661
long cxp = (long) *((char**)xpp);
-#line 3609
+#line 3661
-#line 3609
+#line 3661
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3609
+#line 3661
/* sjl: manually stripmine so we can limit amount of
-#line 3609
+#line 3661
* vector work space reserved to LOOPCNT elements. Also
-#line 3609
+#line 3661
* makes vectorisation easy */
-#line 3609
+#line 3661
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3609
+#line 3661
ni=Min(nelems-j,LOOPCNT);
-#line 3609
+#line 3661
if (realign) {
-#line 3609
+#line 3661
xp = tmp;
-#line 3609
+#line 3661
} else {
-#line 3609
+#line 3661
xp = (int64 *) *xpp;
-#line 3609
+#line 3661
}
-#line 3609
+#line 3661
/* copy the next block */
-#line 3609
+#line 3661
#pragma cdir loopcnt=LOOPCNT
-#line 3609
+#line 3661
#pragma cdir shortloop
-#line 3609
+#line 3661
for (i=0; i<ni; i++) {
-#line 3609
+#line 3661
/* the normal case: */
-#line 3609
+#line 3661
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3609
+#line 3661
/* test for range errors (not always needed but do it anyway) */
-#line 3609
+#line 3661
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3609
+#line 3661
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3609
+#line 3661
nrange += tp[i] > X_INT64_MAX || tp[i] < X_INT64_MIN;
-#line 3609
+#line 3661
}
-#line 3609
+#line 3661
/* copy workspace back if necessary */
-#line 3609
+#line 3661
if (realign) {
-#line 3609
+#line 3661
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3609
+#line 3661
xp = (int64 *) *xpp;
-#line 3609
+#line 3661
}
-#line 3609
+#line 3661
/* update xpp and tp */
-#line 3609
+#line 3661
xp += ni;
-#line 3609
+#line 3661
tp += ni;
-#line 3609
+#line 3661
*xpp = (void*)xp;
-#line 3609
+#line 3661
}
-#line 3609
+#line 3661
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3609
+#line 3661
-#line 3609
+#line 3661
#else /* not SX */
-#line 3609
+#line 3661
-#line 3609
+#line 3661
char *xp = (char *) *xpp;
-#line 3609
+#line 3661
int status = NC_NOERR;
-#line 3609
+#line 3661
-#line 3609
+#line 3661
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3609
+#line 3661
{
-#line 3609
+#line 3661
int lstatus = ncx_put_longlong_double(xp, tp, fillp);
-#line 3609
+#line 3661
if (status == NC_NOERR) /* report the first encountered error */
-#line 3609
+#line 3661
status = lstatus;
-#line 3609
+#line 3661
}
-#line 3609
+#line 3661
-#line 3609
+#line 3661
*xpp = (void *)xp;
-#line 3609
+#line 3661
return status;
-#line 3609
+#line 3661
#endif
-#line 3609
+#line 3661
}
-#line 3609
+#line 3661
int
-#line 3610
+#line 3662
ncx_putn_longlong_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3610
+#line 3662
{
-#line 3610
+#line 3662
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3610
+#line 3662
-#line 3610
+#line 3662
/* basic algorithm is:
-#line 3610
+#line 3662
* - ensure sane alignment of output data
-#line 3610
+#line 3662
* - copy (conversion happens automatically) input data
-#line 3610
+#line 3662
* to output
-#line 3610
+#line 3662
* - update tp to point at next unconverted input, and xpp to point
-#line 3610
+#line 3662
* at next location for converted output
-#line 3610
+#line 3662
*/
-#line 3610
+#line 3662
long i, j, ni;
-#line 3610
+#line 3662
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3610
+#line 3662
int64 *xp;
-#line 3610
+#line 3662
int nrange = 0; /* number of range errors */
-#line 3610
+#line 3662
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3610
+#line 3662
long cxp = (long) *((char**)xpp);
-#line 3610
+#line 3662
-#line 3610
+#line 3662
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3610
+#line 3662
/* sjl: manually stripmine so we can limit amount of
-#line 3610
+#line 3662
* vector work space reserved to LOOPCNT elements. Also
-#line 3610
+#line 3662
* makes vectorisation easy */
-#line 3610
+#line 3662
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3610
+#line 3662
ni=Min(nelems-j,LOOPCNT);
-#line 3610
+#line 3662
if (realign) {
-#line 3610
+#line 3662
xp = tmp;
-#line 3610
+#line 3662
} else {
-#line 3610
+#line 3662
xp = (int64 *) *xpp;
-#line 3610
+#line 3662
}
-#line 3610
+#line 3662
/* copy the next block */
-#line 3610
+#line 3662
#pragma cdir loopcnt=LOOPCNT
-#line 3610
+#line 3662
#pragma cdir shortloop
-#line 3610
+#line 3662
for (i=0; i<ni; i++) {
-#line 3610
+#line 3662
/* the normal case: */
-#line 3610
+#line 3662
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3610
+#line 3662
/* test for range errors (not always needed but do it anyway) */
-#line 3610
+#line 3662
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3610
+#line 3662
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3610
+#line 3662
nrange += tp[i] > X_INT64_MAX ;
-#line 3610
+#line 3662
}
-#line 3610
+#line 3662
/* copy workspace back if necessary */
-#line 3610
+#line 3662
if (realign) {
-#line 3610
+#line 3662
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3610
+#line 3662
xp = (int64 *) *xpp;
-#line 3610
+#line 3662
}
-#line 3610
+#line 3662
/* update xpp and tp */
-#line 3610
+#line 3662
xp += ni;
-#line 3610
+#line 3662
tp += ni;
-#line 3610
+#line 3662
*xpp = (void*)xp;
-#line 3610
+#line 3662
}
-#line 3610
+#line 3662
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3610
+#line 3662
-#line 3610
+#line 3662
#else /* not SX */
-#line 3610
+#line 3662
-#line 3610
+#line 3662
char *xp = (char *) *xpp;
-#line 3610
+#line 3662
int status = NC_NOERR;
-#line 3610
+#line 3662
-#line 3610
+#line 3662
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3610
+#line 3662
{
-#line 3610
+#line 3662
int lstatus = ncx_put_longlong_uchar(xp, tp, fillp);
-#line 3610
+#line 3662
if (status == NC_NOERR) /* report the first encountered error */
-#line 3610
+#line 3662
status = lstatus;
-#line 3610
+#line 3662
}
-#line 3610
+#line 3662
-#line 3610
+#line 3662
*xpp = (void *)xp;
-#line 3610
+#line 3662
return status;
-#line 3610
+#line 3662
#endif
-#line 3610
+#line 3662
}
-#line 3610
+#line 3662
int
-#line 3611
+#line 3663
ncx_putn_longlong_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3611
+#line 3663
{
-#line 3611
+#line 3663
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3611
+#line 3663
-#line 3611
+#line 3663
/* basic algorithm is:
-#line 3611
+#line 3663
* - ensure sane alignment of output data
-#line 3611
+#line 3663
* - copy (conversion happens automatically) input data
-#line 3611
+#line 3663
* to output
-#line 3611
+#line 3663
* - update tp to point at next unconverted input, and xpp to point
-#line 3611
+#line 3663
* at next location for converted output
-#line 3611
+#line 3663
*/
-#line 3611
+#line 3663
long i, j, ni;
-#line 3611
+#line 3663
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3611
+#line 3663
int64 *xp;
-#line 3611
+#line 3663
int nrange = 0; /* number of range errors */
-#line 3611
+#line 3663
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3611
+#line 3663
long cxp = (long) *((char**)xpp);
-#line 3611
+#line 3663
-#line 3611
+#line 3663
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3611
+#line 3663
/* sjl: manually stripmine so we can limit amount of
-#line 3611
+#line 3663
* vector work space reserved to LOOPCNT elements. Also
-#line 3611
+#line 3663
* makes vectorisation easy */
-#line 3611
+#line 3663
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3611
+#line 3663
ni=Min(nelems-j,LOOPCNT);
-#line 3611
+#line 3663
if (realign) {
-#line 3611
+#line 3663
xp = tmp;
-#line 3611
+#line 3663
} else {
-#line 3611
+#line 3663
xp = (int64 *) *xpp;
-#line 3611
+#line 3663
}
-#line 3611
+#line 3663
/* copy the next block */
-#line 3611
+#line 3663
#pragma cdir loopcnt=LOOPCNT
-#line 3611
+#line 3663
#pragma cdir shortloop
-#line 3611
+#line 3663
for (i=0; i<ni; i++) {
-#line 3611
+#line 3663
/* the normal case: */
-#line 3611
+#line 3663
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3611
+#line 3663
/* test for range errors (not always needed but do it anyway) */
-#line 3611
+#line 3663
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3611
+#line 3663
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3611
+#line 3663
nrange += tp[i] > X_INT64_MAX ;
-#line 3611
+#line 3663
}
-#line 3611
+#line 3663
/* copy workspace back if necessary */
-#line 3611
+#line 3663
if (realign) {
-#line 3611
+#line 3663
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3611
+#line 3663
xp = (int64 *) *xpp;
-#line 3611
+#line 3663
}
-#line 3611
+#line 3663
/* update xpp and tp */
-#line 3611
+#line 3663
xp += ni;
-#line 3611
+#line 3663
tp += ni;
-#line 3611
+#line 3663
*xpp = (void*)xp;
-#line 3611
+#line 3663
}
-#line 3611
+#line 3663
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3611
+#line 3663
-#line 3611
+#line 3663
#else /* not SX */
-#line 3611
+#line 3663
-#line 3611
+#line 3663
char *xp = (char *) *xpp;
-#line 3611
+#line 3663
int status = NC_NOERR;
-#line 3611
+#line 3663
-#line 3611
+#line 3663
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3611
+#line 3663
{
-#line 3611
+#line 3663
int lstatus = ncx_put_longlong_ushort(xp, tp, fillp);
-#line 3611
+#line 3663
if (status == NC_NOERR) /* report the first encountered error */
-#line 3611
+#line 3663
status = lstatus;
-#line 3611
+#line 3663
}
-#line 3611
+#line 3663
-#line 3611
+#line 3663
*xpp = (void *)xp;
-#line 3611
+#line 3663
return status;
-#line 3611
+#line 3663
#endif
-#line 3611
+#line 3663
}
-#line 3611
+#line 3663
int
-#line 3612
+#line 3664
ncx_putn_longlong_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3612
+#line 3664
{
-#line 3612
+#line 3664
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3612
+#line 3664
-#line 3612
+#line 3664
/* basic algorithm is:
-#line 3612
+#line 3664
* - ensure sane alignment of output data
-#line 3612
+#line 3664
* - copy (conversion happens automatically) input data
-#line 3612
+#line 3664
* to output
-#line 3612
+#line 3664
* - update tp to point at next unconverted input, and xpp to point
-#line 3612
+#line 3664
* at next location for converted output
-#line 3612
+#line 3664
*/
-#line 3612
+#line 3664
long i, j, ni;
-#line 3612
+#line 3664
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3612
+#line 3664
int64 *xp;
-#line 3612
+#line 3664
int nrange = 0; /* number of range errors */
-#line 3612
+#line 3664
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3612
+#line 3664
long cxp = (long) *((char**)xpp);
-#line 3612
+#line 3664
-#line 3612
+#line 3664
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3612
+#line 3664
/* sjl: manually stripmine so we can limit amount of
-#line 3612
+#line 3664
* vector work space reserved to LOOPCNT elements. Also
-#line 3612
+#line 3664
* makes vectorisation easy */
-#line 3612
+#line 3664
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3612
+#line 3664
ni=Min(nelems-j,LOOPCNT);
-#line 3612
+#line 3664
if (realign) {
-#line 3612
+#line 3664
xp = tmp;
-#line 3612
+#line 3664
} else {
-#line 3612
+#line 3664
xp = (int64 *) *xpp;
-#line 3612
+#line 3664
}
-#line 3612
+#line 3664
/* copy the next block */
-#line 3612
+#line 3664
#pragma cdir loopcnt=LOOPCNT
-#line 3612
+#line 3664
#pragma cdir shortloop
-#line 3612
+#line 3664
for (i=0; i<ni; i++) {
-#line 3612
+#line 3664
/* the normal case: */
-#line 3612
+#line 3664
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3612
+#line 3664
/* test for range errors (not always needed but do it anyway) */
-#line 3612
+#line 3664
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3612
+#line 3664
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3612
+#line 3664
nrange += tp[i] > X_INT64_MAX ;
-#line 3612
+#line 3664
}
-#line 3612
+#line 3664
/* copy workspace back if necessary */
-#line 3612
+#line 3664
if (realign) {
-#line 3612
+#line 3664
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3612
+#line 3664
xp = (int64 *) *xpp;
-#line 3612
+#line 3664
}
-#line 3612
+#line 3664
/* update xpp and tp */
-#line 3612
+#line 3664
xp += ni;
-#line 3612
+#line 3664
tp += ni;
-#line 3612
+#line 3664
*xpp = (void*)xp;
-#line 3612
+#line 3664
}
-#line 3612
+#line 3664
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3612
+#line 3664
-#line 3612
+#line 3664
#else /* not SX */
-#line 3612
+#line 3664
-#line 3612
+#line 3664
char *xp = (char *) *xpp;
-#line 3612
+#line 3664
int status = NC_NOERR;
-#line 3612
+#line 3664
-#line 3612
+#line 3664
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3612
+#line 3664
{
-#line 3612
+#line 3664
int lstatus = ncx_put_longlong_uint(xp, tp, fillp);
-#line 3612
+#line 3664
if (status == NC_NOERR) /* report the first encountered error */
-#line 3612
+#line 3664
status = lstatus;
-#line 3612
+#line 3664
}
-#line 3612
+#line 3664
-#line 3612
+#line 3664
*xpp = (void *)xp;
-#line 3612
+#line 3664
return status;
-#line 3612
+#line 3664
#endif
-#line 3612
+#line 3664
}
-#line 3612
+#line 3664
int
-#line 3613
+#line 3665
ncx_putn_longlong_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3613
+#line 3665
{
-#line 3613
+#line 3665
#if defined(_SX) && _SX != 0 && X_SIZEOF_INT64 == SIZEOF_INT64
-#line 3613
+#line 3665
-#line 3613
+#line 3665
/* basic algorithm is:
-#line 3613
+#line 3665
* - ensure sane alignment of output data
-#line 3613
+#line 3665
* - copy (conversion happens automatically) input data
-#line 3613
+#line 3665
* to output
-#line 3613
+#line 3665
* - update tp to point at next unconverted input, and xpp to point
-#line 3613
+#line 3665
* at next location for converted output
-#line 3613
+#line 3665
*/
-#line 3613
+#line 3665
long i, j, ni;
-#line 3613
+#line 3665
int64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3613
+#line 3665
int64 *xp;
-#line 3613
+#line 3665
int nrange = 0; /* number of range errors */
-#line 3613
+#line 3665
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3613
+#line 3665
long cxp = (long) *((char**)xpp);
-#line 3613
+#line 3665
-#line 3613
+#line 3665
realign = (cxp & 7) % SIZEOF_INT64;
-#line 3613
+#line 3665
/* sjl: manually stripmine so we can limit amount of
-#line 3613
+#line 3665
* vector work space reserved to LOOPCNT elements. Also
-#line 3613
+#line 3665
* makes vectorisation easy */
-#line 3613
+#line 3665
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3613
+#line 3665
ni=Min(nelems-j,LOOPCNT);
-#line 3613
+#line 3665
if (realign) {
-#line 3613
+#line 3665
xp = tmp;
-#line 3613
+#line 3665
} else {
-#line 3613
+#line 3665
xp = (int64 *) *xpp;
-#line 3613
+#line 3665
}
-#line 3613
+#line 3665
/* copy the next block */
-#line 3613
+#line 3665
#pragma cdir loopcnt=LOOPCNT
-#line 3613
+#line 3665
#pragma cdir shortloop
-#line 3613
+#line 3665
for (i=0; i<ni; i++) {
-#line 3613
+#line 3665
/* the normal case: */
-#line 3613
+#line 3665
xp[i] = (int64) Max( X_INT64_MIN, Min(X_INT64_MAX, (int64) tp[i]));
-#line 3613
+#line 3665
/* test for range errors (not always needed but do it anyway) */
-#line 3613
+#line 3665
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3613
+#line 3665
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3613
+#line 3665
nrange += tp[i] > X_INT64_MAX ;
-#line 3613
+#line 3665
}
-#line 3613
+#line 3665
/* copy workspace back if necessary */
-#line 3613
+#line 3665
if (realign) {
-#line 3613
+#line 3665
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_INT64);
-#line 3613
+#line 3665
xp = (int64 *) *xpp;
-#line 3613
+#line 3665
}
-#line 3613
+#line 3665
/* update xpp and tp */
-#line 3613
+#line 3665
xp += ni;
-#line 3613
+#line 3665
tp += ni;
-#line 3613
+#line 3665
*xpp = (void*)xp;
-#line 3613
+#line 3665
}
-#line 3613
+#line 3665
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3613
+#line 3665
-#line 3613
+#line 3665
#else /* not SX */
-#line 3613
+#line 3665
-#line 3613
+#line 3665
char *xp = (char *) *xpp;
-#line 3613
+#line 3665
int status = NC_NOERR;
-#line 3613
+#line 3665
-#line 3613
+#line 3665
for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT64, tp++)
-#line 3613
+#line 3665
{
-#line 3613
+#line 3665
int lstatus = ncx_put_longlong_ulonglong(xp, tp, fillp);
-#line 3613
+#line 3665
if (status == NC_NOERR) /* report the first encountered error */
-#line 3613
+#line 3665
status = lstatus;
-#line 3613
+#line 3665
}
-#line 3613
+#line 3665
-#line 3613
+#line 3665
*xpp = (void *)xp;
-#line 3613
+#line 3665
return status;
-#line 3613
+#line 3665
#endif
-#line 3613
+#line 3665
}
-#line 3613
+#line 3665
/* uint64 --------------------------------------------------------------------*/
@@ -34290,1424 +36375,1424 @@ ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, unsigned long long
}
#else
int
-#line 3631
+#line 3683
ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 3631
+#line 3683
{
-#line 3631
+#line 3683
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3631
+#line 3683
-#line 3631
+#line 3683
/* basic algorithm is:
-#line 3631
+#line 3683
* - ensure sane alignment of input data
-#line 3631
+#line 3683
* - copy (conversion happens automatically) input data
-#line 3631
+#line 3683
* to output
-#line 3631
+#line 3683
* - update xpp to point at next unconverted input, and tp to point
-#line 3631
+#line 3683
* at next location for converted output
-#line 3631
+#line 3683
*/
-#line 3631
+#line 3683
long i, j, ni;
-#line 3631
+#line 3683
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3631
+#line 3683
uint64 *xp;
-#line 3631
+#line 3683
int nrange = 0; /* number of range errors */
-#line 3631
+#line 3683
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3631
+#line 3683
long cxp = (long) *((char**)xpp);
-#line 3631
+#line 3683
-#line 3631
+#line 3683
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3631
+#line 3683
/* sjl: manually stripmine so we can limit amount of
-#line 3631
+#line 3683
* vector work space reserved to LOOPCNT elements. Also
-#line 3631
+#line 3683
* makes vectorisation easy */
-#line 3631
+#line 3683
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3631
+#line 3683
ni=Min(nelems-j,LOOPCNT);
-#line 3631
+#line 3683
if (realign) {
-#line 3631
+#line 3683
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3631
+#line 3683
xp = tmp;
-#line 3631
+#line 3683
} else {
-#line 3631
+#line 3683
xp = (uint64 *) *xpp;
-#line 3631
+#line 3683
}
-#line 3631
+#line 3683
/* copy the next block */
-#line 3631
+#line 3683
#pragma cdir loopcnt=LOOPCNT
-#line 3631
+#line 3683
#pragma cdir shortloop
-#line 3631
+#line 3683
for (i=0; i<ni; i++) {
-#line 3631
+#line 3683
tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 3631
+#line 3683
/* test for range errors (not always needed but do it anyway) */
-#line 3631
+#line 3683
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3631
+#line 3683
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3631
+#line 3683
nrange += xp[i] > ULONGLONG_MAX ;
-#line 3631
+#line 3683
}
-#line 3631
+#line 3683
/* update xpp and tp */
-#line 3631
+#line 3683
if (realign) xp = (uint64 *) *xpp;
-#line 3631
+#line 3683
xp += ni;
-#line 3631
+#line 3683
tp += ni;
-#line 3631
+#line 3683
*xpp = (void*)xp;
-#line 3631
+#line 3683
}
-#line 3631
+#line 3683
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3631
+#line 3683
-#line 3631
+#line 3683
#else /* not SX */
-#line 3631
+#line 3683
const char *xp = (const char *) *xpp;
-#line 3631
+#line 3683
int status = NC_NOERR;
-#line 3631
+#line 3683
-#line 3631
+#line 3683
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3631
+#line 3683
{
-#line 3631
+#line 3683
const int lstatus = ncx_get_ulonglong_ulonglong(xp, tp);
-#line 3631
+#line 3683
if (status == NC_NOERR) /* report the first encountered error */
-#line 3631
+#line 3683
status = lstatus;
-#line 3631
+#line 3683
}
-#line 3631
+#line 3683
-#line 3631
+#line 3683
*xpp = (const void *)xp;
-#line 3631
+#line 3683
return status;
-#line 3631
+#line 3683
#endif
-#line 3631
+#line 3683
}
-#line 3631
+#line 3683
#endif
int
-#line 3633
+#line 3685
ncx_getn_ulonglong_schar(const void **xpp, size_t nelems, schar *tp)
-#line 3633
+#line 3685
{
-#line 3633
+#line 3685
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3633
+#line 3685
-#line 3633
+#line 3685
/* basic algorithm is:
-#line 3633
+#line 3685
* - ensure sane alignment of input data
-#line 3633
+#line 3685
* - copy (conversion happens automatically) input data
-#line 3633
+#line 3685
* to output
-#line 3633
+#line 3685
* - update xpp to point at next unconverted input, and tp to point
-#line 3633
+#line 3685
* at next location for converted output
-#line 3633
+#line 3685
*/
-#line 3633
+#line 3685
long i, j, ni;
-#line 3633
+#line 3685
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3633
+#line 3685
uint64 *xp;
-#line 3633
+#line 3685
int nrange = 0; /* number of range errors */
-#line 3633
+#line 3685
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3633
+#line 3685
long cxp = (long) *((char**)xpp);
-#line 3633
+#line 3685
-#line 3633
+#line 3685
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3633
+#line 3685
/* sjl: manually stripmine so we can limit amount of
-#line 3633
+#line 3685
* vector work space reserved to LOOPCNT elements. Also
-#line 3633
+#line 3685
* makes vectorisation easy */
-#line 3633
+#line 3685
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3633
+#line 3685
ni=Min(nelems-j,LOOPCNT);
-#line 3633
+#line 3685
if (realign) {
-#line 3633
+#line 3685
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3633
+#line 3685
xp = tmp;
-#line 3633
+#line 3685
} else {
-#line 3633
+#line 3685
xp = (uint64 *) *xpp;
-#line 3633
+#line 3685
}
-#line 3633
+#line 3685
/* copy the next block */
-#line 3633
+#line 3685
#pragma cdir loopcnt=LOOPCNT
-#line 3633
+#line 3685
#pragma cdir shortloop
-#line 3633
+#line 3685
for (i=0; i<ni; i++) {
-#line 3633
+#line 3685
tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 3633
+#line 3685
/* test for range errors (not always needed but do it anyway) */
-#line 3633
+#line 3685
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3633
+#line 3685
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3633
+#line 3685
nrange += xp[i] > SCHAR_MAX ;
-#line 3633
+#line 3685
}
-#line 3633
+#line 3685
/* update xpp and tp */
-#line 3633
+#line 3685
if (realign) xp = (uint64 *) *xpp;
-#line 3633
+#line 3685
xp += ni;
-#line 3633
+#line 3685
tp += ni;
-#line 3633
+#line 3685
*xpp = (void*)xp;
-#line 3633
+#line 3685
}
-#line 3633
+#line 3685
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3633
+#line 3685
-#line 3633
+#line 3685
#else /* not SX */
-#line 3633
+#line 3685
const char *xp = (const char *) *xpp;
-#line 3633
+#line 3685
int status = NC_NOERR;
-#line 3633
+#line 3685
-#line 3633
+#line 3685
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3633
+#line 3685
{
-#line 3633
+#line 3685
const int lstatus = ncx_get_ulonglong_schar(xp, tp);
-#line 3633
+#line 3685
if (status == NC_NOERR) /* report the first encountered error */
-#line 3633
+#line 3685
status = lstatus;
-#line 3633
+#line 3685
}
-#line 3633
+#line 3685
-#line 3633
+#line 3685
*xpp = (const void *)xp;
-#line 3633
+#line 3685
return status;
-#line 3633
+#line 3685
#endif
-#line 3633
+#line 3685
}
-#line 3633
+#line 3685
int
-#line 3634
+#line 3686
ncx_getn_ulonglong_short(const void **xpp, size_t nelems, short *tp)
-#line 3634
+#line 3686
{
-#line 3634
+#line 3686
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3634
+#line 3686
-#line 3634
+#line 3686
/* basic algorithm is:
-#line 3634
+#line 3686
* - ensure sane alignment of input data
-#line 3634
+#line 3686
* - copy (conversion happens automatically) input data
-#line 3634
+#line 3686
* to output
-#line 3634
+#line 3686
* - update xpp to point at next unconverted input, and tp to point
-#line 3634
+#line 3686
* at next location for converted output
-#line 3634
+#line 3686
*/
-#line 3634
+#line 3686
long i, j, ni;
-#line 3634
+#line 3686
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3634
+#line 3686
uint64 *xp;
-#line 3634
+#line 3686
int nrange = 0; /* number of range errors */
-#line 3634
+#line 3686
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3634
+#line 3686
long cxp = (long) *((char**)xpp);
-#line 3634
+#line 3686
-#line 3634
+#line 3686
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3634
+#line 3686
/* sjl: manually stripmine so we can limit amount of
-#line 3634
+#line 3686
* vector work space reserved to LOOPCNT elements. Also
-#line 3634
+#line 3686
* makes vectorisation easy */
-#line 3634
+#line 3686
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3634
+#line 3686
ni=Min(nelems-j,LOOPCNT);
-#line 3634
+#line 3686
if (realign) {
-#line 3634
+#line 3686
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3634
+#line 3686
xp = tmp;
-#line 3634
+#line 3686
} else {
-#line 3634
+#line 3686
xp = (uint64 *) *xpp;
-#line 3634
+#line 3686
}
-#line 3634
+#line 3686
/* copy the next block */
-#line 3634
+#line 3686
#pragma cdir loopcnt=LOOPCNT
-#line 3634
+#line 3686
#pragma cdir shortloop
-#line 3634
+#line 3686
for (i=0; i<ni; i++) {
-#line 3634
+#line 3686
tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 3634
+#line 3686
/* test for range errors (not always needed but do it anyway) */
-#line 3634
+#line 3686
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3634
+#line 3686
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3634
+#line 3686
nrange += xp[i] > SHORT_MAX ;
-#line 3634
+#line 3686
}
-#line 3634
+#line 3686
/* update xpp and tp */
-#line 3634
+#line 3686
if (realign) xp = (uint64 *) *xpp;
-#line 3634
+#line 3686
xp += ni;
-#line 3634
+#line 3686
tp += ni;
-#line 3634
+#line 3686
*xpp = (void*)xp;
-#line 3634
+#line 3686
}
-#line 3634
+#line 3686
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3634
+#line 3686
-#line 3634
+#line 3686
#else /* not SX */
-#line 3634
+#line 3686
const char *xp = (const char *) *xpp;
-#line 3634
+#line 3686
int status = NC_NOERR;
-#line 3634
+#line 3686
-#line 3634
+#line 3686
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3634
+#line 3686
{
-#line 3634
+#line 3686
const int lstatus = ncx_get_ulonglong_short(xp, tp);
-#line 3634
+#line 3686
if (status == NC_NOERR) /* report the first encountered error */
-#line 3634
+#line 3686
status = lstatus;
-#line 3634
+#line 3686
}
-#line 3634
+#line 3686
-#line 3634
+#line 3686
*xpp = (const void *)xp;
-#line 3634
+#line 3686
return status;
-#line 3634
+#line 3686
#endif
-#line 3634
+#line 3686
}
-#line 3634
+#line 3686
int
-#line 3635
+#line 3687
ncx_getn_ulonglong_int(const void **xpp, size_t nelems, int *tp)
-#line 3635
+#line 3687
{
-#line 3635
+#line 3687
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3635
+#line 3687
-#line 3635
+#line 3687
/* basic algorithm is:
-#line 3635
+#line 3687
* - ensure sane alignment of input data
-#line 3635
+#line 3687
* - copy (conversion happens automatically) input data
-#line 3635
+#line 3687
* to output
-#line 3635
+#line 3687
* - update xpp to point at next unconverted input, and tp to point
-#line 3635
+#line 3687
* at next location for converted output
-#line 3635
+#line 3687
*/
-#line 3635
+#line 3687
long i, j, ni;
-#line 3635
+#line 3687
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3635
+#line 3687
uint64 *xp;
-#line 3635
+#line 3687
int nrange = 0; /* number of range errors */
-#line 3635
+#line 3687
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3635
+#line 3687
long cxp = (long) *((char**)xpp);
-#line 3635
+#line 3687
-#line 3635
+#line 3687
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3635
+#line 3687
/* sjl: manually stripmine so we can limit amount of
-#line 3635
+#line 3687
* vector work space reserved to LOOPCNT elements. Also
-#line 3635
+#line 3687
* makes vectorisation easy */
-#line 3635
+#line 3687
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3635
+#line 3687
ni=Min(nelems-j,LOOPCNT);
-#line 3635
+#line 3687
if (realign) {
-#line 3635
+#line 3687
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3635
+#line 3687
xp = tmp;
-#line 3635
+#line 3687
} else {
-#line 3635
+#line 3687
xp = (uint64 *) *xpp;
-#line 3635
+#line 3687
}
-#line 3635
+#line 3687
/* copy the next block */
-#line 3635
+#line 3687
#pragma cdir loopcnt=LOOPCNT
-#line 3635
+#line 3687
#pragma cdir shortloop
-#line 3635
+#line 3687
for (i=0; i<ni; i++) {
-#line 3635
+#line 3687
tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 3635
+#line 3687
/* test for range errors (not always needed but do it anyway) */
-#line 3635
+#line 3687
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3635
+#line 3687
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3635
+#line 3687
nrange += xp[i] > INT_MAX ;
-#line 3635
+#line 3687
}
-#line 3635
+#line 3687
/* update xpp and tp */
-#line 3635
+#line 3687
if (realign) xp = (uint64 *) *xpp;
-#line 3635
+#line 3687
xp += ni;
-#line 3635
+#line 3687
tp += ni;
-#line 3635
+#line 3687
*xpp = (void*)xp;
-#line 3635
+#line 3687
}
-#line 3635
+#line 3687
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3635
+#line 3687
-#line 3635
+#line 3687
#else /* not SX */
-#line 3635
+#line 3687
const char *xp = (const char *) *xpp;
-#line 3635
+#line 3687
int status = NC_NOERR;
-#line 3635
+#line 3687
-#line 3635
+#line 3687
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3635
+#line 3687
{
-#line 3635
+#line 3687
const int lstatus = ncx_get_ulonglong_int(xp, tp);
-#line 3635
+#line 3687
if (status == NC_NOERR) /* report the first encountered error */
-#line 3635
+#line 3687
status = lstatus;
-#line 3635
+#line 3687
}
-#line 3635
+#line 3687
-#line 3635
+#line 3687
*xpp = (const void *)xp;
-#line 3635
+#line 3687
return status;
-#line 3635
+#line 3687
#endif
-#line 3635
+#line 3687
}
-#line 3635
+#line 3687
int
-#line 3636
+#line 3688
ncx_getn_ulonglong_long(const void **xpp, size_t nelems, long *tp)
-#line 3636
+#line 3688
{
-#line 3636
+#line 3688
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3636
+#line 3688
-#line 3636
+#line 3688
/* basic algorithm is:
-#line 3636
+#line 3688
* - ensure sane alignment of input data
-#line 3636
+#line 3688
* - copy (conversion happens automatically) input data
-#line 3636
+#line 3688
* to output
-#line 3636
+#line 3688
* - update xpp to point at next unconverted input, and tp to point
-#line 3636
+#line 3688
* at next location for converted output
-#line 3636
+#line 3688
*/
-#line 3636
+#line 3688
long i, j, ni;
-#line 3636
+#line 3688
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3636
+#line 3688
uint64 *xp;
-#line 3636
+#line 3688
int nrange = 0; /* number of range errors */
-#line 3636
+#line 3688
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3636
+#line 3688
long cxp = (long) *((char**)xpp);
-#line 3636
+#line 3688
-#line 3636
+#line 3688
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3636
+#line 3688
/* sjl: manually stripmine so we can limit amount of
-#line 3636
+#line 3688
* vector work space reserved to LOOPCNT elements. Also
-#line 3636
+#line 3688
* makes vectorisation easy */
-#line 3636
+#line 3688
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3636
+#line 3688
ni=Min(nelems-j,LOOPCNT);
-#line 3636
+#line 3688
if (realign) {
-#line 3636
+#line 3688
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3636
+#line 3688
xp = tmp;
-#line 3636
+#line 3688
} else {
-#line 3636
+#line 3688
xp = (uint64 *) *xpp;
-#line 3636
+#line 3688
}
-#line 3636
+#line 3688
/* copy the next block */
-#line 3636
+#line 3688
#pragma cdir loopcnt=LOOPCNT
-#line 3636
+#line 3688
#pragma cdir shortloop
-#line 3636
+#line 3688
for (i=0; i<ni; i++) {
-#line 3636
+#line 3688
tp[i] = (long) Max( LONG_MIN, Min(LONG_MAX, (long) xp[i]));
-#line 3636
+#line 3688
/* test for range errors (not always needed but do it anyway) */
-#line 3636
+#line 3688
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3636
+#line 3688
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3636
+#line 3688
nrange += xp[i] > LONG_MAX ;
-#line 3636
+#line 3688
}
-#line 3636
+#line 3688
/* update xpp and tp */
-#line 3636
+#line 3688
if (realign) xp = (uint64 *) *xpp;
-#line 3636
+#line 3688
xp += ni;
-#line 3636
+#line 3688
tp += ni;
-#line 3636
+#line 3688
*xpp = (void*)xp;
-#line 3636
+#line 3688
}
-#line 3636
+#line 3688
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3636
+#line 3688
-#line 3636
+#line 3688
#else /* not SX */
-#line 3636
+#line 3688
const char *xp = (const char *) *xpp;
-#line 3636
+#line 3688
int status = NC_NOERR;
-#line 3636
+#line 3688
-#line 3636
+#line 3688
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3636
+#line 3688
{
-#line 3636
+#line 3688
const int lstatus = ncx_get_ulonglong_long(xp, tp);
-#line 3636
+#line 3688
if (status == NC_NOERR) /* report the first encountered error */
-#line 3636
+#line 3688
status = lstatus;
-#line 3636
+#line 3688
}
-#line 3636
+#line 3688
-#line 3636
+#line 3688
*xpp = (const void *)xp;
-#line 3636
+#line 3688
return status;
-#line 3636
+#line 3688
#endif
-#line 3636
+#line 3688
}
-#line 3636
+#line 3688
int
-#line 3637
+#line 3689
ncx_getn_ulonglong_float(const void **xpp, size_t nelems, float *tp)
-#line 3637
+#line 3689
{
-#line 3637
+#line 3689
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3637
+#line 3689
-#line 3637
+#line 3689
/* basic algorithm is:
-#line 3637
+#line 3689
* - ensure sane alignment of input data
-#line 3637
+#line 3689
* - copy (conversion happens automatically) input data
-#line 3637
+#line 3689
* to output
-#line 3637
+#line 3689
* - update xpp to point at next unconverted input, and tp to point
-#line 3637
+#line 3689
* at next location for converted output
-#line 3637
+#line 3689
*/
-#line 3637
+#line 3689
long i, j, ni;
-#line 3637
+#line 3689
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3637
+#line 3689
uint64 *xp;
-#line 3637
+#line 3689
int nrange = 0; /* number of range errors */
-#line 3637
+#line 3689
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3637
+#line 3689
long cxp = (long) *((char**)xpp);
-#line 3637
+#line 3689
-#line 3637
+#line 3689
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3637
+#line 3689
/* sjl: manually stripmine so we can limit amount of
-#line 3637
+#line 3689
* vector work space reserved to LOOPCNT elements. Also
-#line 3637
+#line 3689
* makes vectorisation easy */
-#line 3637
+#line 3689
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3637
+#line 3689
ni=Min(nelems-j,LOOPCNT);
-#line 3637
+#line 3689
if (realign) {
-#line 3637
+#line 3689
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3637
+#line 3689
xp = tmp;
-#line 3637
+#line 3689
} else {
-#line 3637
+#line 3689
xp = (uint64 *) *xpp;
-#line 3637
+#line 3689
}
-#line 3637
+#line 3689
/* copy the next block */
-#line 3637
+#line 3689
#pragma cdir loopcnt=LOOPCNT
-#line 3637
+#line 3689
#pragma cdir shortloop
-#line 3637
+#line 3689
for (i=0; i<ni; i++) {
-#line 3637
+#line 3689
tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 3637
+#line 3689
/* test for range errors (not always needed but do it anyway) */
-#line 3637
+#line 3689
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3637
+#line 3689
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3637
+#line 3689
nrange += xp[i] > FLOAT_MAX ;
-#line 3637
+#line 3689
}
-#line 3637
+#line 3689
/* update xpp and tp */
-#line 3637
+#line 3689
if (realign) xp = (uint64 *) *xpp;
-#line 3637
+#line 3689
xp += ni;
-#line 3637
+#line 3689
tp += ni;
-#line 3637
+#line 3689
*xpp = (void*)xp;
-#line 3637
+#line 3689
}
-#line 3637
+#line 3689
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3637
+#line 3689
-#line 3637
+#line 3689
#else /* not SX */
-#line 3637
+#line 3689
const char *xp = (const char *) *xpp;
-#line 3637
+#line 3689
int status = NC_NOERR;
-#line 3637
+#line 3689
-#line 3637
+#line 3689
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3637
+#line 3689
{
-#line 3637
+#line 3689
const int lstatus = ncx_get_ulonglong_float(xp, tp);
-#line 3637
+#line 3689
if (status == NC_NOERR) /* report the first encountered error */
-#line 3637
+#line 3689
status = lstatus;
-#line 3637
+#line 3689
}
-#line 3637
+#line 3689
-#line 3637
+#line 3689
*xpp = (const void *)xp;
-#line 3637
+#line 3689
return status;
-#line 3637
+#line 3689
#endif
-#line 3637
+#line 3689
}
-#line 3637
+#line 3689
int
-#line 3638
+#line 3690
ncx_getn_ulonglong_double(const void **xpp, size_t nelems, double *tp)
-#line 3638
+#line 3690
{
-#line 3638
+#line 3690
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3638
+#line 3690
-#line 3638
+#line 3690
/* basic algorithm is:
-#line 3638
+#line 3690
* - ensure sane alignment of input data
-#line 3638
+#line 3690
* - copy (conversion happens automatically) input data
-#line 3638
+#line 3690
* to output
-#line 3638
+#line 3690
* - update xpp to point at next unconverted input, and tp to point
-#line 3638
+#line 3690
* at next location for converted output
-#line 3638
+#line 3690
*/
-#line 3638
+#line 3690
long i, j, ni;
-#line 3638
+#line 3690
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3638
+#line 3690
uint64 *xp;
-#line 3638
+#line 3690
int nrange = 0; /* number of range errors */
-#line 3638
+#line 3690
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3638
+#line 3690
long cxp = (long) *((char**)xpp);
-#line 3638
+#line 3690
-#line 3638
+#line 3690
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3638
+#line 3690
/* sjl: manually stripmine so we can limit amount of
-#line 3638
+#line 3690
* vector work space reserved to LOOPCNT elements. Also
-#line 3638
+#line 3690
* makes vectorisation easy */
-#line 3638
+#line 3690
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3638
+#line 3690
ni=Min(nelems-j,LOOPCNT);
-#line 3638
+#line 3690
if (realign) {
-#line 3638
+#line 3690
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3638
+#line 3690
xp = tmp;
-#line 3638
+#line 3690
} else {
-#line 3638
+#line 3690
xp = (uint64 *) *xpp;
-#line 3638
+#line 3690
}
-#line 3638
+#line 3690
/* copy the next block */
-#line 3638
+#line 3690
#pragma cdir loopcnt=LOOPCNT
-#line 3638
+#line 3690
#pragma cdir shortloop
-#line 3638
+#line 3690
for (i=0; i<ni; i++) {
-#line 3638
+#line 3690
tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 3638
+#line 3690
/* test for range errors (not always needed but do it anyway) */
-#line 3638
+#line 3690
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3638
+#line 3690
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3638
+#line 3690
nrange += xp[i] > DOUBLE_MAX ;
-#line 3638
+#line 3690
}
-#line 3638
+#line 3690
/* update xpp and tp */
-#line 3638
+#line 3690
if (realign) xp = (uint64 *) *xpp;
-#line 3638
+#line 3690
xp += ni;
-#line 3638
+#line 3690
tp += ni;
-#line 3638
+#line 3690
*xpp = (void*)xp;
-#line 3638
+#line 3690
}
-#line 3638
+#line 3690
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3638
+#line 3690
-#line 3638
+#line 3690
#else /* not SX */
-#line 3638
+#line 3690
const char *xp = (const char *) *xpp;
-#line 3638
+#line 3690
int status = NC_NOERR;
-#line 3638
+#line 3690
-#line 3638
+#line 3690
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3638
+#line 3690
{
-#line 3638
+#line 3690
const int lstatus = ncx_get_ulonglong_double(xp, tp);
-#line 3638
+#line 3690
if (status == NC_NOERR) /* report the first encountered error */
-#line 3638
+#line 3690
status = lstatus;
-#line 3638
+#line 3690
}
-#line 3638
+#line 3690
-#line 3638
+#line 3690
*xpp = (const void *)xp;
-#line 3638
+#line 3690
return status;
-#line 3638
+#line 3690
#endif
-#line 3638
+#line 3690
}
-#line 3638
+#line 3690
int
-#line 3639
+#line 3691
ncx_getn_ulonglong_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 3639
+#line 3691
{
-#line 3639
+#line 3691
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3639
+#line 3691
-#line 3639
+#line 3691
/* basic algorithm is:
-#line 3639
+#line 3691
* - ensure sane alignment of input data
-#line 3639
+#line 3691
* - copy (conversion happens automatically) input data
-#line 3639
+#line 3691
* to output
-#line 3639
+#line 3691
* - update xpp to point at next unconverted input, and tp to point
-#line 3639
+#line 3691
* at next location for converted output
-#line 3639
+#line 3691
*/
-#line 3639
+#line 3691
long i, j, ni;
-#line 3639
+#line 3691
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3639
+#line 3691
uint64 *xp;
-#line 3639
+#line 3691
int nrange = 0; /* number of range errors */
-#line 3639
+#line 3691
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3639
+#line 3691
long cxp = (long) *((char**)xpp);
-#line 3639
+#line 3691
-#line 3639
+#line 3691
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3639
+#line 3691
/* sjl: manually stripmine so we can limit amount of
-#line 3639
+#line 3691
* vector work space reserved to LOOPCNT elements. Also
-#line 3639
+#line 3691
* makes vectorisation easy */
-#line 3639
+#line 3691
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3639
+#line 3691
ni=Min(nelems-j,LOOPCNT);
-#line 3639
+#line 3691
if (realign) {
-#line 3639
+#line 3691
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3639
+#line 3691
xp = tmp;
-#line 3639
+#line 3691
} else {
-#line 3639
+#line 3691
xp = (uint64 *) *xpp;
-#line 3639
+#line 3691
}
-#line 3639
+#line 3691
/* copy the next block */
-#line 3639
+#line 3691
#pragma cdir loopcnt=LOOPCNT
-#line 3639
+#line 3691
#pragma cdir shortloop
-#line 3639
+#line 3691
for (i=0; i<ni; i++) {
-#line 3639
+#line 3691
tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 3639
+#line 3691
/* test for range errors (not always needed but do it anyway) */
-#line 3639
+#line 3691
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3639
+#line 3691
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3639
+#line 3691
nrange += xp[i] > LONGLONG_MAX ;
-#line 3639
+#line 3691
}
-#line 3639
+#line 3691
/* update xpp and tp */
-#line 3639
+#line 3691
if (realign) xp = (uint64 *) *xpp;
-#line 3639
+#line 3691
xp += ni;
-#line 3639
+#line 3691
tp += ni;
-#line 3639
+#line 3691
*xpp = (void*)xp;
-#line 3639
+#line 3691
}
-#line 3639
+#line 3691
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3639
+#line 3691
-#line 3639
+#line 3691
#else /* not SX */
-#line 3639
+#line 3691
const char *xp = (const char *) *xpp;
-#line 3639
+#line 3691
int status = NC_NOERR;
-#line 3639
+#line 3691
-#line 3639
+#line 3691
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3639
+#line 3691
{
-#line 3639
+#line 3691
const int lstatus = ncx_get_ulonglong_longlong(xp, tp);
-#line 3639
+#line 3691
if (status == NC_NOERR) /* report the first encountered error */
-#line 3639
+#line 3691
status = lstatus;
-#line 3639
+#line 3691
}
-#line 3639
+#line 3691
-#line 3639
+#line 3691
*xpp = (const void *)xp;
-#line 3639
+#line 3691
return status;
-#line 3639
+#line 3691
#endif
-#line 3639
+#line 3691
}
-#line 3639
+#line 3691
int
-#line 3640
+#line 3692
ncx_getn_ulonglong_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 3640
+#line 3692
{
-#line 3640
+#line 3692
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3640
+#line 3692
-#line 3640
+#line 3692
/* basic algorithm is:
-#line 3640
+#line 3692
* - ensure sane alignment of input data
-#line 3640
+#line 3692
* - copy (conversion happens automatically) input data
-#line 3640
+#line 3692
* to output
-#line 3640
+#line 3692
* - update xpp to point at next unconverted input, and tp to point
-#line 3640
+#line 3692
* at next location for converted output
-#line 3640
+#line 3692
*/
-#line 3640
+#line 3692
long i, j, ni;
-#line 3640
+#line 3692
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3640
+#line 3692
uint64 *xp;
-#line 3640
+#line 3692
int nrange = 0; /* number of range errors */
-#line 3640
+#line 3692
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3640
+#line 3692
long cxp = (long) *((char**)xpp);
-#line 3640
+#line 3692
-#line 3640
+#line 3692
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3640
+#line 3692
/* sjl: manually stripmine so we can limit amount of
-#line 3640
+#line 3692
* vector work space reserved to LOOPCNT elements. Also
-#line 3640
+#line 3692
* makes vectorisation easy */
-#line 3640
+#line 3692
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3640
+#line 3692
ni=Min(nelems-j,LOOPCNT);
-#line 3640
+#line 3692
if (realign) {
-#line 3640
+#line 3692
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3640
+#line 3692
xp = tmp;
-#line 3640
+#line 3692
} else {
-#line 3640
+#line 3692
xp = (uint64 *) *xpp;
-#line 3640
+#line 3692
}
-#line 3640
+#line 3692
/* copy the next block */
-#line 3640
+#line 3692
#pragma cdir loopcnt=LOOPCNT
-#line 3640
+#line 3692
#pragma cdir shortloop
-#line 3640
+#line 3692
for (i=0; i<ni; i++) {
-#line 3640
+#line 3692
tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 3640
+#line 3692
/* test for range errors (not always needed but do it anyway) */
-#line 3640
+#line 3692
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3640
+#line 3692
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3640
+#line 3692
nrange += xp[i] > UCHAR_MAX ;
-#line 3640
+#line 3692
}
-#line 3640
+#line 3692
/* update xpp and tp */
-#line 3640
+#line 3692
if (realign) xp = (uint64 *) *xpp;
-#line 3640
+#line 3692
xp += ni;
-#line 3640
+#line 3692
tp += ni;
-#line 3640
+#line 3692
*xpp = (void*)xp;
-#line 3640
+#line 3692
}
-#line 3640
+#line 3692
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3640
+#line 3692
-#line 3640
+#line 3692
#else /* not SX */
-#line 3640
+#line 3692
const char *xp = (const char *) *xpp;
-#line 3640
+#line 3692
int status = NC_NOERR;
-#line 3640
+#line 3692
-#line 3640
+#line 3692
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3640
+#line 3692
{
-#line 3640
+#line 3692
const int lstatus = ncx_get_ulonglong_uchar(xp, tp);
-#line 3640
+#line 3692
if (status == NC_NOERR) /* report the first encountered error */
-#line 3640
+#line 3692
status = lstatus;
-#line 3640
+#line 3692
}
-#line 3640
+#line 3692
-#line 3640
+#line 3692
*xpp = (const void *)xp;
-#line 3640
+#line 3692
return status;
-#line 3640
+#line 3692
#endif
-#line 3640
+#line 3692
}
-#line 3640
+#line 3692
int
-#line 3641
+#line 3693
ncx_getn_ulonglong_ushort(const void **xpp, size_t nelems, ushort *tp)
-#line 3641
+#line 3693
{
-#line 3641
+#line 3693
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3641
+#line 3693
-#line 3641
+#line 3693
/* basic algorithm is:
-#line 3641
+#line 3693
* - ensure sane alignment of input data
-#line 3641
+#line 3693
* - copy (conversion happens automatically) input data
-#line 3641
+#line 3693
* to output
-#line 3641
+#line 3693
* - update xpp to point at next unconverted input, and tp to point
-#line 3641
+#line 3693
* at next location for converted output
-#line 3641
+#line 3693
*/
-#line 3641
+#line 3693
long i, j, ni;
-#line 3641
+#line 3693
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3641
+#line 3693
uint64 *xp;
-#line 3641
+#line 3693
int nrange = 0; /* number of range errors */
-#line 3641
+#line 3693
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3641
+#line 3693
long cxp = (long) *((char**)xpp);
-#line 3641
+#line 3693
-#line 3641
+#line 3693
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3641
+#line 3693
/* sjl: manually stripmine so we can limit amount of
-#line 3641
+#line 3693
* vector work space reserved to LOOPCNT elements. Also
-#line 3641
+#line 3693
* makes vectorisation easy */
-#line 3641
+#line 3693
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3641
+#line 3693
ni=Min(nelems-j,LOOPCNT);
-#line 3641
+#line 3693
if (realign) {
-#line 3641
+#line 3693
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3641
+#line 3693
xp = tmp;
-#line 3641
+#line 3693
} else {
-#line 3641
+#line 3693
xp = (uint64 *) *xpp;
-#line 3641
+#line 3693
}
-#line 3641
+#line 3693
/* copy the next block */
-#line 3641
+#line 3693
#pragma cdir loopcnt=LOOPCNT
-#line 3641
+#line 3693
#pragma cdir shortloop
-#line 3641
+#line 3693
for (i=0; i<ni; i++) {
-#line 3641
+#line 3693
tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
-#line 3641
+#line 3693
/* test for range errors (not always needed but do it anyway) */
-#line 3641
+#line 3693
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3641
+#line 3693
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3641
+#line 3693
nrange += xp[i] > USHORT_MAX ;
-#line 3641
+#line 3693
}
-#line 3641
+#line 3693
/* update xpp and tp */
-#line 3641
+#line 3693
if (realign) xp = (uint64 *) *xpp;
-#line 3641
+#line 3693
xp += ni;
-#line 3641
+#line 3693
tp += ni;
-#line 3641
+#line 3693
*xpp = (void*)xp;
-#line 3641
+#line 3693
}
-#line 3641
+#line 3693
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3641
+#line 3693
-#line 3641
+#line 3693
#else /* not SX */
-#line 3641
+#line 3693
const char *xp = (const char *) *xpp;
-#line 3641
+#line 3693
int status = NC_NOERR;
-#line 3641
+#line 3693
-#line 3641
+#line 3693
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3641
+#line 3693
{
-#line 3641
+#line 3693
const int lstatus = ncx_get_ulonglong_ushort(xp, tp);
-#line 3641
+#line 3693
if (status == NC_NOERR) /* report the first encountered error */
-#line 3641
+#line 3693
status = lstatus;
-#line 3641
+#line 3693
}
-#line 3641
+#line 3693
-#line 3641
+#line 3693
*xpp = (const void *)xp;
-#line 3641
+#line 3693
return status;
-#line 3641
+#line 3693
#endif
-#line 3641
+#line 3693
}
-#line 3641
+#line 3693
int
-#line 3642
+#line 3694
ncx_getn_ulonglong_uint(const void **xpp, size_t nelems, uint *tp)
-#line 3642
+#line 3694
{
-#line 3642
+#line 3694
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3642
+#line 3694
-#line 3642
+#line 3694
/* basic algorithm is:
-#line 3642
+#line 3694
* - ensure sane alignment of input data
-#line 3642
+#line 3694
* - copy (conversion happens automatically) input data
-#line 3642
+#line 3694
* to output
-#line 3642
+#line 3694
* - update xpp to point at next unconverted input, and tp to point
-#line 3642
+#line 3694
* at next location for converted output
-#line 3642
+#line 3694
*/
-#line 3642
+#line 3694
long i, j, ni;
-#line 3642
+#line 3694
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3642
+#line 3694
uint64 *xp;
-#line 3642
+#line 3694
int nrange = 0; /* number of range errors */
-#line 3642
+#line 3694
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3642
+#line 3694
long cxp = (long) *((char**)xpp);
-#line 3642
+#line 3694
-#line 3642
+#line 3694
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3642
+#line 3694
/* sjl: manually stripmine so we can limit amount of
-#line 3642
+#line 3694
* vector work space reserved to LOOPCNT elements. Also
-#line 3642
+#line 3694
* makes vectorisation easy */
-#line 3642
+#line 3694
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3642
+#line 3694
ni=Min(nelems-j,LOOPCNT);
-#line 3642
+#line 3694
if (realign) {
-#line 3642
+#line 3694
memcpy(tmp, *xpp, (size_t)(ni*SIZEOF_UINT64));
-#line 3642
+#line 3694
xp = tmp;
-#line 3642
+#line 3694
} else {
-#line 3642
+#line 3694
xp = (uint64 *) *xpp;
-#line 3642
+#line 3694
}
-#line 3642
+#line 3694
/* copy the next block */
-#line 3642
+#line 3694
#pragma cdir loopcnt=LOOPCNT
-#line 3642
+#line 3694
#pragma cdir shortloop
-#line 3642
+#line 3694
for (i=0; i<ni; i++) {
-#line 3642
+#line 3694
tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 3642
+#line 3694
/* test for range errors (not always needed but do it anyway) */
-#line 3642
+#line 3694
/* if xpp is unsigned, we need not check if xp[i] < _MIN */
-#line 3642
+#line 3694
/* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
-#line 3642
+#line 3694
nrange += xp[i] > UINT_MAX ;
-#line 3642
+#line 3694
}
-#line 3642
+#line 3694
/* update xpp and tp */
-#line 3642
+#line 3694
if (realign) xp = (uint64 *) *xpp;
-#line 3642
+#line 3694
xp += ni;
-#line 3642
+#line 3694
tp += ni;
-#line 3642
+#line 3694
*xpp = (void*)xp;
-#line 3642
+#line 3694
}
-#line 3642
+#line 3694
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3642
+#line 3694
-#line 3642
+#line 3694
#else /* not SX */
-#line 3642
+#line 3694
const char *xp = (const char *) *xpp;
-#line 3642
+#line 3694
int status = NC_NOERR;
-#line 3642
+#line 3694
-#line 3642
+#line 3694
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3642
+#line 3694
{
-#line 3642
+#line 3694
const int lstatus = ncx_get_ulonglong_uint(xp, tp);
-#line 3642
+#line 3694
if (status == NC_NOERR) /* report the first encountered error */
-#line 3642
+#line 3694
status = lstatus;
-#line 3642
+#line 3694
}
-#line 3642
+#line 3694
-#line 3642
+#line 3694
*xpp = (const void *)xp;
-#line 3642
+#line 3694
return status;
-#line 3642
+#line 3694
#endif
-#line 3642
+#line 3694
}
-#line 3642
+#line 3694
#if X_SIZEOF_UINT64 == SIZEOF_ULONGLONG
@@ -35725,1534 +37810,1534 @@ ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const unsigned long long
}
#else
int
-#line 3658
+#line 3710
ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *tp, void *fillp)
-#line 3658
+#line 3710
{
-#line 3658
+#line 3710
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3658
+#line 3710
-#line 3658
+#line 3710
/* basic algorithm is:
-#line 3658
+#line 3710
* - ensure sane alignment of output data
-#line 3658
+#line 3710
* - copy (conversion happens automatically) input data
-#line 3658
+#line 3710
* to output
-#line 3658
+#line 3710
* - update tp to point at next unconverted input, and xpp to point
-#line 3658
+#line 3710
* at next location for converted output
-#line 3658
+#line 3710
*/
-#line 3658
+#line 3710
long i, j, ni;
-#line 3658
+#line 3710
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3658
+#line 3710
uint64 *xp;
-#line 3658
+#line 3710
int nrange = 0; /* number of range errors */
-#line 3658
+#line 3710
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3658
+#line 3710
long cxp = (long) *((char**)xpp);
-#line 3658
+#line 3710
-#line 3658
+#line 3710
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3658
+#line 3710
/* sjl: manually stripmine so we can limit amount of
-#line 3658
+#line 3710
* vector work space reserved to LOOPCNT elements. Also
-#line 3658
+#line 3710
* makes vectorisation easy */
-#line 3658
+#line 3710
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3658
+#line 3710
ni=Min(nelems-j,LOOPCNT);
-#line 3658
+#line 3710
if (realign) {
-#line 3658
+#line 3710
xp = tmp;
-#line 3658
+#line 3710
} else {
-#line 3658
+#line 3710
xp = (uint64 *) *xpp;
-#line 3658
+#line 3710
}
-#line 3658
+#line 3710
/* copy the next block */
-#line 3658
+#line 3710
#pragma cdir loopcnt=LOOPCNT
-#line 3658
+#line 3710
#pragma cdir shortloop
-#line 3658
+#line 3710
for (i=0; i<ni; i++) {
-#line 3658
+#line 3710
/* the normal case: */
-#line 3658
+#line 3710
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3658
+#line 3710
/* test for range errors (not always needed but do it anyway) */
-#line 3658
+#line 3710
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3658
+#line 3710
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3658
+#line 3710
nrange += tp[i] > X_UINT64_MAX ;
-#line 3658
+#line 3710
}
-#line 3658
+#line 3710
/* copy workspace back if necessary */
-#line 3658
+#line 3710
if (realign) {
-#line 3658
+#line 3710
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3658
+#line 3710
xp = (uint64 *) *xpp;
-#line 3658
+#line 3710
}
-#line 3658
+#line 3710
/* update xpp and tp */
-#line 3658
+#line 3710
xp += ni;
-#line 3658
+#line 3710
tp += ni;
-#line 3658
+#line 3710
*xpp = (void*)xp;
-#line 3658
+#line 3710
}
-#line 3658
+#line 3710
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3658
+#line 3710
-#line 3658
+#line 3710
#else /* not SX */
-#line 3658
+#line 3710
-#line 3658
+#line 3710
char *xp = (char *) *xpp;
-#line 3658
+#line 3710
int status = NC_NOERR;
-#line 3658
+#line 3710
-#line 3658
+#line 3710
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3658
+#line 3710
{
-#line 3658
+#line 3710
int lstatus = ncx_put_ulonglong_ulonglong(xp, tp, fillp);
-#line 3658
+#line 3710
if (status == NC_NOERR) /* report the first encountered error */
-#line 3658
+#line 3710
status = lstatus;
-#line 3658
+#line 3710
}
-#line 3658
+#line 3710
-#line 3658
+#line 3710
*xpp = (void *)xp;
-#line 3658
+#line 3710
return status;
-#line 3658
+#line 3710
#endif
-#line 3658
+#line 3710
}
-#line 3658
+#line 3710
#endif
int
-#line 3660
+#line 3712
ncx_putn_ulonglong_schar(void **xpp, size_t nelems, const schar *tp, void *fillp)
-#line 3660
+#line 3712
{
-#line 3660
+#line 3712
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3660
+#line 3712
-#line 3660
+#line 3712
/* basic algorithm is:
-#line 3660
+#line 3712
* - ensure sane alignment of output data
-#line 3660
+#line 3712
* - copy (conversion happens automatically) input data
-#line 3660
+#line 3712
* to output
-#line 3660
+#line 3712
* - update tp to point at next unconverted input, and xpp to point
-#line 3660
+#line 3712
* at next location for converted output
-#line 3660
+#line 3712
*/
-#line 3660
+#line 3712
long i, j, ni;
-#line 3660
+#line 3712
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3660
+#line 3712
uint64 *xp;
-#line 3660
+#line 3712
int nrange = 0; /* number of range errors */
-#line 3660
+#line 3712
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3660
+#line 3712
long cxp = (long) *((char**)xpp);
-#line 3660
+#line 3712
-#line 3660
+#line 3712
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3660
+#line 3712
/* sjl: manually stripmine so we can limit amount of
-#line 3660
+#line 3712
* vector work space reserved to LOOPCNT elements. Also
-#line 3660
+#line 3712
* makes vectorisation easy */
-#line 3660
+#line 3712
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3660
+#line 3712
ni=Min(nelems-j,LOOPCNT);
-#line 3660
+#line 3712
if (realign) {
-#line 3660
+#line 3712
xp = tmp;
-#line 3660
+#line 3712
} else {
-#line 3660
+#line 3712
xp = (uint64 *) *xpp;
-#line 3660
+#line 3712
}
-#line 3660
+#line 3712
/* copy the next block */
-#line 3660
+#line 3712
#pragma cdir loopcnt=LOOPCNT
-#line 3660
+#line 3712
#pragma cdir shortloop
-#line 3660
+#line 3712
for (i=0; i<ni; i++) {
-#line 3660
+#line 3712
/* the normal case: */
-#line 3660
+#line 3712
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3660
+#line 3712
/* test for range errors (not always needed but do it anyway) */
-#line 3660
+#line 3712
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3660
+#line 3712
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3660
+#line 3712
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3660
+#line 3712
}
-#line 3660
+#line 3712
/* copy workspace back if necessary */
-#line 3660
+#line 3712
if (realign) {
-#line 3660
+#line 3712
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3660
+#line 3712
xp = (uint64 *) *xpp;
-#line 3660
+#line 3712
}
-#line 3660
+#line 3712
/* update xpp and tp */
-#line 3660
+#line 3712
xp += ni;
-#line 3660
+#line 3712
tp += ni;
-#line 3660
+#line 3712
*xpp = (void*)xp;
-#line 3660
+#line 3712
}
-#line 3660
+#line 3712
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3660
+#line 3712
-#line 3660
+#line 3712
#else /* not SX */
-#line 3660
+#line 3712
-#line 3660
+#line 3712
char *xp = (char *) *xpp;
-#line 3660
+#line 3712
int status = NC_NOERR;
-#line 3660
+#line 3712
-#line 3660
+#line 3712
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3660
+#line 3712
{
-#line 3660
+#line 3712
int lstatus = ncx_put_ulonglong_schar(xp, tp, fillp);
-#line 3660
+#line 3712
if (status == NC_NOERR) /* report the first encountered error */
-#line 3660
+#line 3712
status = lstatus;
-#line 3660
+#line 3712
}
-#line 3660
+#line 3712
-#line 3660
+#line 3712
*xpp = (void *)xp;
-#line 3660
+#line 3712
return status;
-#line 3660
+#line 3712
#endif
-#line 3660
+#line 3712
}
-#line 3660
+#line 3712
int
-#line 3661
+#line 3713
ncx_putn_ulonglong_short(void **xpp, size_t nelems, const short *tp, void *fillp)
-#line 3661
+#line 3713
{
-#line 3661
+#line 3713
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3661
+#line 3713
-#line 3661
+#line 3713
/* basic algorithm is:
-#line 3661
+#line 3713
* - ensure sane alignment of output data
-#line 3661
+#line 3713
* - copy (conversion happens automatically) input data
-#line 3661
+#line 3713
* to output
-#line 3661
+#line 3713
* - update tp to point at next unconverted input, and xpp to point
-#line 3661
+#line 3713
* at next location for converted output
-#line 3661
+#line 3713
*/
-#line 3661
+#line 3713
long i, j, ni;
-#line 3661
+#line 3713
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3661
+#line 3713
uint64 *xp;
-#line 3661
+#line 3713
int nrange = 0; /* number of range errors */
-#line 3661
+#line 3713
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3661
+#line 3713
long cxp = (long) *((char**)xpp);
-#line 3661
+#line 3713
-#line 3661
+#line 3713
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3661
+#line 3713
/* sjl: manually stripmine so we can limit amount of
-#line 3661
+#line 3713
* vector work space reserved to LOOPCNT elements. Also
-#line 3661
+#line 3713
* makes vectorisation easy */
-#line 3661
+#line 3713
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3661
+#line 3713
ni=Min(nelems-j,LOOPCNT);
-#line 3661
+#line 3713
if (realign) {
-#line 3661
+#line 3713
xp = tmp;
-#line 3661
+#line 3713
} else {
-#line 3661
+#line 3713
xp = (uint64 *) *xpp;
-#line 3661
+#line 3713
}
-#line 3661
+#line 3713
/* copy the next block */
-#line 3661
+#line 3713
#pragma cdir loopcnt=LOOPCNT
-#line 3661
+#line 3713
#pragma cdir shortloop
-#line 3661
+#line 3713
for (i=0; i<ni; i++) {
-#line 3661
+#line 3713
/* the normal case: */
-#line 3661
+#line 3713
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3661
+#line 3713
/* test for range errors (not always needed but do it anyway) */
-#line 3661
+#line 3713
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3661
+#line 3713
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3661
+#line 3713
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3661
+#line 3713
}
-#line 3661
+#line 3713
/* copy workspace back if necessary */
-#line 3661
+#line 3713
if (realign) {
-#line 3661
+#line 3713
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3661
+#line 3713
xp = (uint64 *) *xpp;
-#line 3661
+#line 3713
}
-#line 3661
+#line 3713
/* update xpp and tp */
-#line 3661
+#line 3713
xp += ni;
-#line 3661
+#line 3713
tp += ni;
-#line 3661
+#line 3713
*xpp = (void*)xp;
-#line 3661
+#line 3713
}
-#line 3661
+#line 3713
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3661
+#line 3713
-#line 3661
+#line 3713
#else /* not SX */
-#line 3661
+#line 3713
-#line 3661
+#line 3713
char *xp = (char *) *xpp;
-#line 3661
+#line 3713
int status = NC_NOERR;
-#line 3661
+#line 3713
-#line 3661
+#line 3713
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3661
+#line 3713
{
-#line 3661
+#line 3713
int lstatus = ncx_put_ulonglong_short(xp, tp, fillp);
-#line 3661
+#line 3713
if (status == NC_NOERR) /* report the first encountered error */
-#line 3661
+#line 3713
status = lstatus;
-#line 3661
+#line 3713
}
-#line 3661
+#line 3713
-#line 3661
+#line 3713
*xpp = (void *)xp;
-#line 3661
+#line 3713
return status;
-#line 3661
+#line 3713
#endif
-#line 3661
+#line 3713
}
-#line 3661
+#line 3713
int
-#line 3662
+#line 3714
ncx_putn_ulonglong_int(void **xpp, size_t nelems, const int *tp, void *fillp)
-#line 3662
+#line 3714
{
-#line 3662
+#line 3714
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3662
+#line 3714
-#line 3662
+#line 3714
/* basic algorithm is:
-#line 3662
+#line 3714
* - ensure sane alignment of output data
-#line 3662
+#line 3714
* - copy (conversion happens automatically) input data
-#line 3662
+#line 3714
* to output
-#line 3662
+#line 3714
* - update tp to point at next unconverted input, and xpp to point
-#line 3662
+#line 3714
* at next location for converted output
-#line 3662
+#line 3714
*/
-#line 3662
+#line 3714
long i, j, ni;
-#line 3662
+#line 3714
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3662
+#line 3714
uint64 *xp;
-#line 3662
+#line 3714
int nrange = 0; /* number of range errors */
-#line 3662
+#line 3714
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3662
+#line 3714
long cxp = (long) *((char**)xpp);
-#line 3662
+#line 3714
-#line 3662
+#line 3714
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3662
+#line 3714
/* sjl: manually stripmine so we can limit amount of
-#line 3662
+#line 3714
* vector work space reserved to LOOPCNT elements. Also
-#line 3662
+#line 3714
* makes vectorisation easy */
-#line 3662
+#line 3714
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3662
+#line 3714
ni=Min(nelems-j,LOOPCNT);
-#line 3662
+#line 3714
if (realign) {
-#line 3662
+#line 3714
xp = tmp;
-#line 3662
+#line 3714
} else {
-#line 3662
+#line 3714
xp = (uint64 *) *xpp;
-#line 3662
+#line 3714
}
-#line 3662
+#line 3714
/* copy the next block */
-#line 3662
+#line 3714
#pragma cdir loopcnt=LOOPCNT
-#line 3662
+#line 3714
#pragma cdir shortloop
-#line 3662
+#line 3714
for (i=0; i<ni; i++) {
-#line 3662
+#line 3714
/* the normal case: */
-#line 3662
+#line 3714
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3662
+#line 3714
/* test for range errors (not always needed but do it anyway) */
-#line 3662
+#line 3714
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3662
+#line 3714
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3662
+#line 3714
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3662
+#line 3714
}
-#line 3662
+#line 3714
/* copy workspace back if necessary */
-#line 3662
+#line 3714
if (realign) {
-#line 3662
+#line 3714
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3662
+#line 3714
xp = (uint64 *) *xpp;
-#line 3662
+#line 3714
}
-#line 3662
+#line 3714
/* update xpp and tp */
-#line 3662
+#line 3714
xp += ni;
-#line 3662
+#line 3714
tp += ni;
-#line 3662
+#line 3714
*xpp = (void*)xp;
-#line 3662
+#line 3714
}
-#line 3662
+#line 3714
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3662
+#line 3714
-#line 3662
+#line 3714
#else /* not SX */
-#line 3662
+#line 3714
-#line 3662
+#line 3714
char *xp = (char *) *xpp;
-#line 3662
+#line 3714
int status = NC_NOERR;
-#line 3662
+#line 3714
-#line 3662
+#line 3714
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3662
+#line 3714
{
-#line 3662
+#line 3714
int lstatus = ncx_put_ulonglong_int(xp, tp, fillp);
-#line 3662
+#line 3714
if (status == NC_NOERR) /* report the first encountered error */
-#line 3662
+#line 3714
status = lstatus;
-#line 3662
+#line 3714
}
-#line 3662
+#line 3714
-#line 3662
+#line 3714
*xpp = (void *)xp;
-#line 3662
+#line 3714
return status;
-#line 3662
+#line 3714
#endif
-#line 3662
+#line 3714
}
-#line 3662
+#line 3714
int
-#line 3663
+#line 3715
ncx_putn_ulonglong_long(void **xpp, size_t nelems, const long *tp, void *fillp)
-#line 3663
+#line 3715
{
-#line 3663
+#line 3715
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3663
+#line 3715
-#line 3663
+#line 3715
/* basic algorithm is:
-#line 3663
+#line 3715
* - ensure sane alignment of output data
-#line 3663
+#line 3715
* - copy (conversion happens automatically) input data
-#line 3663
+#line 3715
* to output
-#line 3663
+#line 3715
* - update tp to point at next unconverted input, and xpp to point
-#line 3663
+#line 3715
* at next location for converted output
-#line 3663
+#line 3715
*/
-#line 3663
+#line 3715
long i, j, ni;
-#line 3663
+#line 3715
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3663
+#line 3715
uint64 *xp;
-#line 3663
+#line 3715
int nrange = 0; /* number of range errors */
-#line 3663
+#line 3715
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3663
+#line 3715
long cxp = (long) *((char**)xpp);
-#line 3663
+#line 3715
-#line 3663
+#line 3715
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3663
+#line 3715
/* sjl: manually stripmine so we can limit amount of
-#line 3663
+#line 3715
* vector work space reserved to LOOPCNT elements. Also
-#line 3663
+#line 3715
* makes vectorisation easy */
-#line 3663
+#line 3715
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3663
+#line 3715
ni=Min(nelems-j,LOOPCNT);
-#line 3663
+#line 3715
if (realign) {
-#line 3663
+#line 3715
xp = tmp;
-#line 3663
+#line 3715
} else {
-#line 3663
+#line 3715
xp = (uint64 *) *xpp;
-#line 3663
+#line 3715
}
-#line 3663
+#line 3715
/* copy the next block */
-#line 3663
+#line 3715
#pragma cdir loopcnt=LOOPCNT
-#line 3663
+#line 3715
#pragma cdir shortloop
-#line 3663
+#line 3715
for (i=0; i<ni; i++) {
-#line 3663
+#line 3715
/* the normal case: */
-#line 3663
+#line 3715
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3663
+#line 3715
/* test for range errors (not always needed but do it anyway) */
-#line 3663
+#line 3715
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3663
+#line 3715
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3663
+#line 3715
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3663
+#line 3715
}
-#line 3663
+#line 3715
/* copy workspace back if necessary */
-#line 3663
+#line 3715
if (realign) {
-#line 3663
+#line 3715
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3663
+#line 3715
xp = (uint64 *) *xpp;
-#line 3663
+#line 3715
}
-#line 3663
+#line 3715
/* update xpp and tp */
-#line 3663
+#line 3715
xp += ni;
-#line 3663
+#line 3715
tp += ni;
-#line 3663
+#line 3715
*xpp = (void*)xp;
-#line 3663
+#line 3715
}
-#line 3663
+#line 3715
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3663
+#line 3715
-#line 3663
+#line 3715
#else /* not SX */
-#line 3663
+#line 3715
-#line 3663
+#line 3715
char *xp = (char *) *xpp;
-#line 3663
+#line 3715
int status = NC_NOERR;
-#line 3663
+#line 3715
-#line 3663
+#line 3715
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3663
+#line 3715
{
-#line 3663
+#line 3715
int lstatus = ncx_put_ulonglong_long(xp, tp, fillp);
-#line 3663
+#line 3715
if (status == NC_NOERR) /* report the first encountered error */
-#line 3663
+#line 3715
status = lstatus;
-#line 3663
+#line 3715
}
-#line 3663
+#line 3715
-#line 3663
+#line 3715
*xpp = (void *)xp;
-#line 3663
+#line 3715
return status;
-#line 3663
+#line 3715
#endif
-#line 3663
+#line 3715
}
-#line 3663
+#line 3715
int
-#line 3664
+#line 3716
ncx_putn_ulonglong_float(void **xpp, size_t nelems, const float *tp, void *fillp)
-#line 3664
+#line 3716
{
-#line 3664
+#line 3716
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3664
+#line 3716
-#line 3664
+#line 3716
/* basic algorithm is:
-#line 3664
+#line 3716
* - ensure sane alignment of output data
-#line 3664
+#line 3716
* - copy (conversion happens automatically) input data
-#line 3664
+#line 3716
* to output
-#line 3664
+#line 3716
* - update tp to point at next unconverted input, and xpp to point
-#line 3664
+#line 3716
* at next location for converted output
-#line 3664
+#line 3716
*/
-#line 3664
+#line 3716
long i, j, ni;
-#line 3664
+#line 3716
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3664
+#line 3716
uint64 *xp;
-#line 3664
+#line 3716
int nrange = 0; /* number of range errors */
-#line 3664
+#line 3716
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3664
+#line 3716
long cxp = (long) *((char**)xpp);
-#line 3664
+#line 3716
-#line 3664
+#line 3716
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3664
+#line 3716
/* sjl: manually stripmine so we can limit amount of
-#line 3664
+#line 3716
* vector work space reserved to LOOPCNT elements. Also
-#line 3664
+#line 3716
* makes vectorisation easy */
-#line 3664
+#line 3716
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3664
+#line 3716
ni=Min(nelems-j,LOOPCNT);
-#line 3664
+#line 3716
if (realign) {
-#line 3664
+#line 3716
xp = tmp;
-#line 3664
+#line 3716
} else {
-#line 3664
+#line 3716
xp = (uint64 *) *xpp;
-#line 3664
+#line 3716
}
-#line 3664
+#line 3716
/* copy the next block */
-#line 3664
+#line 3716
#pragma cdir loopcnt=LOOPCNT
-#line 3664
+#line 3716
#pragma cdir shortloop
-#line 3664
+#line 3716
for (i=0; i<ni; i++) {
-#line 3664
+#line 3716
/* the normal case: */
-#line 3664
+#line 3716
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3664
+#line 3716
/* test for range errors (not always needed but do it anyway) */
-#line 3664
+#line 3716
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3664
+#line 3716
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3664
+#line 3716
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3664
+#line 3716
}
-#line 3664
+#line 3716
/* copy workspace back if necessary */
-#line 3664
+#line 3716
if (realign) {
-#line 3664
+#line 3716
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3664
+#line 3716
xp = (uint64 *) *xpp;
-#line 3664
+#line 3716
}
-#line 3664
+#line 3716
/* update xpp and tp */
-#line 3664
+#line 3716
xp += ni;
-#line 3664
+#line 3716
tp += ni;
-#line 3664
+#line 3716
*xpp = (void*)xp;
-#line 3664
+#line 3716
}
-#line 3664
+#line 3716
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3664
+#line 3716
-#line 3664
+#line 3716
#else /* not SX */
-#line 3664
+#line 3716
-#line 3664
+#line 3716
char *xp = (char *) *xpp;
-#line 3664
+#line 3716
int status = NC_NOERR;
-#line 3664
+#line 3716
-#line 3664
+#line 3716
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3664
+#line 3716
{
-#line 3664
+#line 3716
int lstatus = ncx_put_ulonglong_float(xp, tp, fillp);
-#line 3664
+#line 3716
if (status == NC_NOERR) /* report the first encountered error */
-#line 3664
+#line 3716
status = lstatus;
-#line 3664
+#line 3716
}
-#line 3664
+#line 3716
-#line 3664
+#line 3716
*xpp = (void *)xp;
-#line 3664
+#line 3716
return status;
-#line 3664
+#line 3716
#endif
-#line 3664
+#line 3716
}
-#line 3664
+#line 3716
int
-#line 3665
+#line 3717
ncx_putn_ulonglong_double(void **xpp, size_t nelems, const double *tp, void *fillp)
-#line 3665
+#line 3717
{
-#line 3665
+#line 3717
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3665
+#line 3717
-#line 3665
+#line 3717
/* basic algorithm is:
-#line 3665
+#line 3717
* - ensure sane alignment of output data
-#line 3665
+#line 3717
* - copy (conversion happens automatically) input data
-#line 3665
+#line 3717
* to output
-#line 3665
+#line 3717
* - update tp to point at next unconverted input, and xpp to point
-#line 3665
+#line 3717
* at next location for converted output
-#line 3665
+#line 3717
*/
-#line 3665
+#line 3717
long i, j, ni;
-#line 3665
+#line 3717
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3665
+#line 3717
uint64 *xp;
-#line 3665
+#line 3717
int nrange = 0; /* number of range errors */
-#line 3665
+#line 3717
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3665
+#line 3717
long cxp = (long) *((char**)xpp);
-#line 3665
+#line 3717
-#line 3665
+#line 3717
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3665
+#line 3717
/* sjl: manually stripmine so we can limit amount of
-#line 3665
+#line 3717
* vector work space reserved to LOOPCNT elements. Also
-#line 3665
+#line 3717
* makes vectorisation easy */
-#line 3665
+#line 3717
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3665
+#line 3717
ni=Min(nelems-j,LOOPCNT);
-#line 3665
+#line 3717
if (realign) {
-#line 3665
+#line 3717
xp = tmp;
-#line 3665
+#line 3717
} else {
-#line 3665
+#line 3717
xp = (uint64 *) *xpp;
-#line 3665
+#line 3717
}
-#line 3665
+#line 3717
/* copy the next block */
-#line 3665
+#line 3717
#pragma cdir loopcnt=LOOPCNT
-#line 3665
+#line 3717
#pragma cdir shortloop
-#line 3665
+#line 3717
for (i=0; i<ni; i++) {
-#line 3665
+#line 3717
/* the normal case: */
-#line 3665
+#line 3717
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3665
+#line 3717
/* test for range errors (not always needed but do it anyway) */
-#line 3665
+#line 3717
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3665
+#line 3717
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3665
+#line 3717
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3665
+#line 3717
}
-#line 3665
+#line 3717
/* copy workspace back if necessary */
-#line 3665
+#line 3717
if (realign) {
-#line 3665
+#line 3717
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3665
+#line 3717
xp = (uint64 *) *xpp;
-#line 3665
+#line 3717
}
-#line 3665
+#line 3717
/* update xpp and tp */
-#line 3665
+#line 3717
xp += ni;
-#line 3665
+#line 3717
tp += ni;
-#line 3665
+#line 3717
*xpp = (void*)xp;
-#line 3665
+#line 3717
}
-#line 3665
+#line 3717
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3665
+#line 3717
-#line 3665
+#line 3717
#else /* not SX */
-#line 3665
+#line 3717
-#line 3665
+#line 3717
char *xp = (char *) *xpp;
-#line 3665
+#line 3717
int status = NC_NOERR;
-#line 3665
+#line 3717
-#line 3665
+#line 3717
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3665
+#line 3717
{
-#line 3665
+#line 3717
int lstatus = ncx_put_ulonglong_double(xp, tp, fillp);
-#line 3665
+#line 3717
if (status == NC_NOERR) /* report the first encountered error */
-#line 3665
+#line 3717
status = lstatus;
-#line 3665
+#line 3717
}
-#line 3665
+#line 3717
-#line 3665
+#line 3717
*xpp = (void *)xp;
-#line 3665
+#line 3717
return status;
-#line 3665
+#line 3717
#endif
-#line 3665
+#line 3717
}
-#line 3665
+#line 3717
int
-#line 3666
+#line 3718
ncx_putn_ulonglong_longlong(void **xpp, size_t nelems, const longlong *tp, void *fillp)
-#line 3666
+#line 3718
{
-#line 3666
+#line 3718
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3666
+#line 3718
-#line 3666
+#line 3718
/* basic algorithm is:
-#line 3666
+#line 3718
* - ensure sane alignment of output data
-#line 3666
+#line 3718
* - copy (conversion happens automatically) input data
-#line 3666
+#line 3718
* to output
-#line 3666
+#line 3718
* - update tp to point at next unconverted input, and xpp to point
-#line 3666
+#line 3718
* at next location for converted output
-#line 3666
+#line 3718
*/
-#line 3666
+#line 3718
long i, j, ni;
-#line 3666
+#line 3718
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3666
+#line 3718
uint64 *xp;
-#line 3666
+#line 3718
int nrange = 0; /* number of range errors */
-#line 3666
+#line 3718
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3666
+#line 3718
long cxp = (long) *((char**)xpp);
-#line 3666
+#line 3718
-#line 3666
+#line 3718
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3666
+#line 3718
/* sjl: manually stripmine so we can limit amount of
-#line 3666
+#line 3718
* vector work space reserved to LOOPCNT elements. Also
-#line 3666
+#line 3718
* makes vectorisation easy */
-#line 3666
+#line 3718
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3666
+#line 3718
ni=Min(nelems-j,LOOPCNT);
-#line 3666
+#line 3718
if (realign) {
-#line 3666
+#line 3718
xp = tmp;
-#line 3666
+#line 3718
} else {
-#line 3666
+#line 3718
xp = (uint64 *) *xpp;
-#line 3666
+#line 3718
}
-#line 3666
+#line 3718
/* copy the next block */
-#line 3666
+#line 3718
#pragma cdir loopcnt=LOOPCNT
-#line 3666
+#line 3718
#pragma cdir shortloop
-#line 3666
+#line 3718
for (i=0; i<ni; i++) {
-#line 3666
+#line 3718
/* the normal case: */
-#line 3666
+#line 3718
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3666
+#line 3718
/* test for range errors (not always needed but do it anyway) */
-#line 3666
+#line 3718
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3666
+#line 3718
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3666
+#line 3718
nrange += tp[i] > X_UINT64_MAX || tp[i] < 0;
-#line 3666
+#line 3718
}
-#line 3666
+#line 3718
/* copy workspace back if necessary */
-#line 3666
+#line 3718
if (realign) {
-#line 3666
+#line 3718
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3666
+#line 3718
xp = (uint64 *) *xpp;
-#line 3666
+#line 3718
}
-#line 3666
+#line 3718
/* update xpp and tp */
-#line 3666
+#line 3718
xp += ni;
-#line 3666
+#line 3718
tp += ni;
-#line 3666
+#line 3718
*xpp = (void*)xp;
-#line 3666
+#line 3718
}
-#line 3666
+#line 3718
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3666
+#line 3718
-#line 3666
+#line 3718
#else /* not SX */
-#line 3666
+#line 3718
-#line 3666
+#line 3718
char *xp = (char *) *xpp;
-#line 3666
+#line 3718
int status = NC_NOERR;
-#line 3666
+#line 3718
-#line 3666
+#line 3718
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3666
+#line 3718
{
-#line 3666
+#line 3718
int lstatus = ncx_put_ulonglong_longlong(xp, tp, fillp);
-#line 3666
+#line 3718
if (status == NC_NOERR) /* report the first encountered error */
-#line 3666
+#line 3718
status = lstatus;
-#line 3666
+#line 3718
}
-#line 3666
+#line 3718
-#line 3666
+#line 3718
*xpp = (void *)xp;
-#line 3666
+#line 3718
return status;
-#line 3666
+#line 3718
#endif
-#line 3666
+#line 3718
}
-#line 3666
+#line 3718
int
-#line 3667
+#line 3719
ncx_putn_ulonglong_uchar(void **xpp, size_t nelems, const uchar *tp, void *fillp)
-#line 3667
+#line 3719
{
-#line 3667
+#line 3719
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3667
+#line 3719
-#line 3667
+#line 3719
/* basic algorithm is:
-#line 3667
+#line 3719
* - ensure sane alignment of output data
-#line 3667
+#line 3719
* - copy (conversion happens automatically) input data
-#line 3667
+#line 3719
* to output
-#line 3667
+#line 3719
* - update tp to point at next unconverted input, and xpp to point
-#line 3667
+#line 3719
* at next location for converted output
-#line 3667
+#line 3719
*/
-#line 3667
+#line 3719
long i, j, ni;
-#line 3667
+#line 3719
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3667
+#line 3719
uint64 *xp;
-#line 3667
+#line 3719
int nrange = 0; /* number of range errors */
-#line 3667
+#line 3719
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3667
+#line 3719
long cxp = (long) *((char**)xpp);
-#line 3667
+#line 3719
-#line 3667
+#line 3719
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3667
+#line 3719
/* sjl: manually stripmine so we can limit amount of
-#line 3667
+#line 3719
* vector work space reserved to LOOPCNT elements. Also
-#line 3667
+#line 3719
* makes vectorisation easy */
-#line 3667
+#line 3719
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3667
+#line 3719
ni=Min(nelems-j,LOOPCNT);
-#line 3667
+#line 3719
if (realign) {
-#line 3667
+#line 3719
xp = tmp;
-#line 3667
+#line 3719
} else {
-#line 3667
+#line 3719
xp = (uint64 *) *xpp;
-#line 3667
+#line 3719
}
-#line 3667
+#line 3719
/* copy the next block */
-#line 3667
+#line 3719
#pragma cdir loopcnt=LOOPCNT
-#line 3667
+#line 3719
#pragma cdir shortloop
-#line 3667
+#line 3719
for (i=0; i<ni; i++) {
-#line 3667
+#line 3719
/* the normal case: */
-#line 3667
+#line 3719
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3667
+#line 3719
/* test for range errors (not always needed but do it anyway) */
-#line 3667
+#line 3719
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3667
+#line 3719
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3667
+#line 3719
nrange += tp[i] > X_UINT64_MAX ;
-#line 3667
+#line 3719
}
-#line 3667
+#line 3719
/* copy workspace back if necessary */
-#line 3667
+#line 3719
if (realign) {
-#line 3667
+#line 3719
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3667
+#line 3719
xp = (uint64 *) *xpp;
-#line 3667
+#line 3719
}
-#line 3667
+#line 3719
/* update xpp and tp */
-#line 3667
+#line 3719
xp += ni;
-#line 3667
+#line 3719
tp += ni;
-#line 3667
+#line 3719
*xpp = (void*)xp;
-#line 3667
+#line 3719
}
-#line 3667
+#line 3719
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3667
+#line 3719
-#line 3667
+#line 3719
#else /* not SX */
-#line 3667
+#line 3719
-#line 3667
+#line 3719
char *xp = (char *) *xpp;
-#line 3667
+#line 3719
int status = NC_NOERR;
-#line 3667
+#line 3719
-#line 3667
+#line 3719
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3667
+#line 3719
{
-#line 3667
+#line 3719
int lstatus = ncx_put_ulonglong_uchar(xp, tp, fillp);
-#line 3667
+#line 3719
if (status == NC_NOERR) /* report the first encountered error */
-#line 3667
+#line 3719
status = lstatus;
-#line 3667
+#line 3719
}
-#line 3667
+#line 3719
-#line 3667
+#line 3719
*xpp = (void *)xp;
-#line 3667
+#line 3719
return status;
-#line 3667
+#line 3719
#endif
-#line 3667
+#line 3719
}
-#line 3667
+#line 3719
int
-#line 3668
+#line 3720
ncx_putn_ulonglong_ushort(void **xpp, size_t nelems, const ushort *tp, void *fillp)
-#line 3668
+#line 3720
{
-#line 3668
+#line 3720
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3668
+#line 3720
-#line 3668
+#line 3720
/* basic algorithm is:
-#line 3668
+#line 3720
* - ensure sane alignment of output data
-#line 3668
+#line 3720
* - copy (conversion happens automatically) input data
-#line 3668
+#line 3720
* to output
-#line 3668
+#line 3720
* - update tp to point at next unconverted input, and xpp to point
-#line 3668
+#line 3720
* at next location for converted output
-#line 3668
+#line 3720
*/
-#line 3668
+#line 3720
long i, j, ni;
-#line 3668
+#line 3720
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3668
+#line 3720
uint64 *xp;
-#line 3668
+#line 3720
int nrange = 0; /* number of range errors */
-#line 3668
+#line 3720
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3668
+#line 3720
long cxp = (long) *((char**)xpp);
-#line 3668
+#line 3720
-#line 3668
+#line 3720
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3668
+#line 3720
/* sjl: manually stripmine so we can limit amount of
-#line 3668
+#line 3720
* vector work space reserved to LOOPCNT elements. Also
-#line 3668
+#line 3720
* makes vectorisation easy */
-#line 3668
+#line 3720
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3668
+#line 3720
ni=Min(nelems-j,LOOPCNT);
-#line 3668
+#line 3720
if (realign) {
-#line 3668
+#line 3720
xp = tmp;
-#line 3668
+#line 3720
} else {
-#line 3668
+#line 3720
xp = (uint64 *) *xpp;
-#line 3668
+#line 3720
}
-#line 3668
+#line 3720
/* copy the next block */
-#line 3668
+#line 3720
#pragma cdir loopcnt=LOOPCNT
-#line 3668
+#line 3720
#pragma cdir shortloop
-#line 3668
+#line 3720
for (i=0; i<ni; i++) {
-#line 3668
+#line 3720
/* the normal case: */
-#line 3668
+#line 3720
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3668
+#line 3720
/* test for range errors (not always needed but do it anyway) */
-#line 3668
+#line 3720
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3668
+#line 3720
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3668
+#line 3720
nrange += tp[i] > X_UINT64_MAX ;
-#line 3668
+#line 3720
}
-#line 3668
+#line 3720
/* copy workspace back if necessary */
-#line 3668
+#line 3720
if (realign) {
-#line 3668
+#line 3720
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3668
+#line 3720
xp = (uint64 *) *xpp;
-#line 3668
+#line 3720
}
-#line 3668
+#line 3720
/* update xpp and tp */
-#line 3668
+#line 3720
xp += ni;
-#line 3668
+#line 3720
tp += ni;
-#line 3668
+#line 3720
*xpp = (void*)xp;
-#line 3668
+#line 3720
}
-#line 3668
+#line 3720
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3668
+#line 3720
-#line 3668
+#line 3720
#else /* not SX */
-#line 3668
+#line 3720
-#line 3668
+#line 3720
char *xp = (char *) *xpp;
-#line 3668
+#line 3720
int status = NC_NOERR;
-#line 3668
+#line 3720
-#line 3668
+#line 3720
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3668
+#line 3720
{
-#line 3668
+#line 3720
int lstatus = ncx_put_ulonglong_ushort(xp, tp, fillp);
-#line 3668
+#line 3720
if (status == NC_NOERR) /* report the first encountered error */
-#line 3668
+#line 3720
status = lstatus;
-#line 3668
+#line 3720
}
-#line 3668
+#line 3720
-#line 3668
+#line 3720
*xpp = (void *)xp;
-#line 3668
+#line 3720
return status;
-#line 3668
+#line 3720
#endif
-#line 3668
+#line 3720
}
-#line 3668
+#line 3720
int
-#line 3669
+#line 3721
ncx_putn_ulonglong_uint(void **xpp, size_t nelems, const uint *tp, void *fillp)
-#line 3669
+#line 3721
{
-#line 3669
+#line 3721
#if defined(_SX) && _SX != 0 && X_SIZEOF_UINT64 == SIZEOF_UINT64
-#line 3669
+#line 3721
-#line 3669
+#line 3721
/* basic algorithm is:
-#line 3669
+#line 3721
* - ensure sane alignment of output data
-#line 3669
+#line 3721
* - copy (conversion happens automatically) input data
-#line 3669
+#line 3721
* to output
-#line 3669
+#line 3721
* - update tp to point at next unconverted input, and xpp to point
-#line 3669
+#line 3721
* at next location for converted output
-#line 3669
+#line 3721
*/
-#line 3669
+#line 3721
long i, j, ni;
-#line 3669
+#line 3721
uint64 tmp[LOOPCNT]; /* in case input is misaligned */
-#line 3669
+#line 3721
uint64 *xp;
-#line 3669
+#line 3721
int nrange = 0; /* number of range errors */
-#line 3669
+#line 3721
int realign = 0; /* "do we need to fix input data alignment?" */
-#line 3669
+#line 3721
long cxp = (long) *((char**)xpp);
-#line 3669
+#line 3721
-#line 3669
+#line 3721
realign = (cxp & 7) % SIZEOF_UINT64;
-#line 3669
+#line 3721
/* sjl: manually stripmine so we can limit amount of
-#line 3669
+#line 3721
* vector work space reserved to LOOPCNT elements. Also
-#line 3669
+#line 3721
* makes vectorisation easy */
-#line 3669
+#line 3721
for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3669
+#line 3721
ni=Min(nelems-j,LOOPCNT);
-#line 3669
+#line 3721
if (realign) {
-#line 3669
+#line 3721
xp = tmp;
-#line 3669
+#line 3721
} else {
-#line 3669
+#line 3721
xp = (uint64 *) *xpp;
-#line 3669
+#line 3721
}
-#line 3669
+#line 3721
/* copy the next block */
-#line 3669
+#line 3721
#pragma cdir loopcnt=LOOPCNT
-#line 3669
+#line 3721
#pragma cdir shortloop
-#line 3669
+#line 3721
for (i=0; i<ni; i++) {
-#line 3669
+#line 3721
/* the normal case: */
-#line 3669
+#line 3721
xp[i] = (uint64) Max( X_UINT64_MIN, Min(X_UINT64_MAX, (uint64) tp[i]));
-#line 3669
+#line 3721
/* test for range errors (not always needed but do it anyway) */
-#line 3669
+#line 3721
/* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
-#line 3669
+#line 3721
/* if tp is unsigned, we need not check if tp[i] < X__MIN */
-#line 3669
+#line 3721
nrange += tp[i] > X_UINT64_MAX ;
-#line 3669
+#line 3721
}
-#line 3669
+#line 3721
/* copy workspace back if necessary */
-#line 3669
+#line 3721
if (realign) {
-#line 3669
+#line 3721
memcpy(*xpp, tmp, (size_t)*ni*X_SIZEOF_UINT64);
-#line 3669
+#line 3721
xp = (uint64 *) *xpp;
-#line 3669
+#line 3721
}
-#line 3669
+#line 3721
/* update xpp and tp */
-#line 3669
+#line 3721
xp += ni;
-#line 3669
+#line 3721
tp += ni;
-#line 3669
+#line 3721
*xpp = (void*)xp;
-#line 3669
+#line 3721
}
-#line 3669
+#line 3721
return nrange == 0 ? NC_NOERR : NC_ERANGE;
-#line 3669
+#line 3721
-#line 3669
+#line 3721
#else /* not SX */
-#line 3669
+#line 3721
-#line 3669
+#line 3721
char *xp = (char *) *xpp;
-#line 3669
+#line 3721
int status = NC_NOERR;
-#line 3669
+#line 3721
-#line 3669
+#line 3721
for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT64, tp++)
-#line 3669
+#line 3721
{
-#line 3669
+#line 3721
int lstatus = ncx_put_ulonglong_uint(xp, tp, fillp);
-#line 3669
+#line 3721
if (status == NC_NOERR) /* report the first encountered error */
-#line 3669
+#line 3721
status = lstatus;
-#line 3669
+#line 3721
}
-#line 3669
+#line 3721
-#line 3669
+#line 3721
*xpp = (void *)xp;
-#line 3669
+#line 3721
return status;
-#line 3669
+#line 3721
#endif
-#line 3669
+#line 3721
}
-#line 3669
+#line 3721
@@ -37266,11 +39351,11 @@ int
ncx_getn_text(const void **xpp, size_t nelems, char *tp)
{
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 3681
+#line 3733
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3681
+#line 3733
return NC_NOERR;
-#line 3681
+#line 3733
}
@@ -37278,23 +39363,23 @@ int
ncx_pad_getn_text(const void **xpp, size_t nelems, char *tp)
{
size_t rndup = nelems % X_ALIGN;
-#line 3687
+#line 3739
-#line 3687
+#line 3739
if (rndup)
-#line 3687
+#line 3739
rndup = X_ALIGN - rndup;
-#line 3687
+#line 3739
-#line 3687
+#line 3739
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 3687
+#line 3739
*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 3687
+#line 3739
-#line 3687
+#line 3739
return NC_NOERR;
-#line 3687
+#line 3739
}
@@ -37302,13 +39387,13 @@ int
ncx_putn_text(void **xpp, size_t nelems, const char *tp)
{
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 3693
+#line 3745
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3693
+#line 3745
-#line 3693
+#line 3745
return NC_NOERR;
-#line 3693
+#line 3745
}
@@ -37316,35 +39401,35 @@ int
ncx_pad_putn_text(void **xpp, size_t nelems, const char *tp)
{
size_t rndup = nelems % X_ALIGN;
-#line 3699
+#line 3751
-#line 3699
+#line 3751
if (rndup)
-#line 3699
+#line 3751
rndup = X_ALIGN - rndup;
-#line 3699
+#line 3751
-#line 3699
+#line 3751
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 3699
+#line 3751
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3699
+#line 3751
-#line 3699
+#line 3751
if (rndup)
-#line 3699
+#line 3751
{
-#line 3699
+#line 3751
(void) memcpy(*xpp, nada, (size_t)rndup);
-#line 3699
+#line 3751
*xpp = (void *)((char *)(*xpp) + rndup);
-#line 3699
+#line 3751
}
-#line 3699
+#line 3751
-#line 3699
+#line 3751
return NC_NOERR;
-#line 3699
+#line 3751
}
@@ -37355,11 +39440,11 @@ int
ncx_getn_void(const void **xpp, size_t nelems, void *tp)
{
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 3708
+#line 3760
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3708
+#line 3760
return NC_NOERR;
-#line 3708
+#line 3760
}
@@ -37367,23 +39452,23 @@ int
ncx_pad_getn_void(const void **xpp, size_t nelems, void *tp)
{
size_t rndup = nelems % X_ALIGN;
-#line 3714
+#line 3766
-#line 3714
+#line 3766
if (rndup)
-#line 3714
+#line 3766
rndup = X_ALIGN - rndup;
-#line 3714
+#line 3766
-#line 3714
+#line 3766
(void) memcpy(tp, *xpp, (size_t)nelems);
-#line 3714
+#line 3766
*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 3714
+#line 3766
-#line 3714
+#line 3766
return NC_NOERR;
-#line 3714
+#line 3766
}
@@ -37391,13 +39476,13 @@ int
ncx_putn_void(void **xpp, size_t nelems, const void *tp)
{
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 3720
+#line 3772
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3720
+#line 3772
-#line 3720
+#line 3772
return NC_NOERR;
-#line 3720
+#line 3772
}
@@ -37405,34 +39490,34 @@ int
ncx_pad_putn_void(void **xpp, size_t nelems, const void *tp)
{
size_t rndup = nelems % X_ALIGN;
-#line 3726
+#line 3778
-#line 3726
+#line 3778
if (rndup)
-#line 3726
+#line 3778
rndup = X_ALIGN - rndup;
-#line 3726
+#line 3778
-#line 3726
+#line 3778
(void) memcpy(*xpp, tp, (size_t)nelems);
-#line 3726
+#line 3778
*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3726
+#line 3778
-#line 3726
+#line 3778
if (rndup)
-#line 3726
+#line 3778
{
-#line 3726
+#line 3778
(void) memcpy(*xpp, nada, (size_t)rndup);
-#line 3726
+#line 3778
*xpp = (void *)((char *)(*xpp) + rndup);
-#line 3726
+#line 3778
}
-#line 3726
+#line 3778
-#line 3726
+#line 3778
return NC_NOERR;
-#line 3726
+#line 3778
}
diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4
index 319cdb3..f28aa9a 100644
--- a/libsrc/ncx.m4
+++ b/libsrc/ncx.m4
@@ -16,11 +16,14 @@ dnl
#endif
dnl
-dnl If the m4 macro "ERANGE_FILL" is defined, the I/O to data elements
-dnl that cause NC_ERANGE will be filled with the NC default fill values.
+dnl If "ERANGE_FILL" is defined, the data elements that cause NC_ERANGE will
+dnl be filled with the NC default fill values.
dnl
-define(`SKIP_LOOP', `ifdef(`ERANGE_FILL', `$1++; $2++; continue;')')
+define(`SKIP_LOOP', `
+#ifdef ERANGE_FILL
+ $1++; $2++; continue;
+#endif')
dnl
dnl The command-line m4 macro "PNETCDF" is to differentiate PnetCDF and netCDF
@@ -79,7 +82,9 @@ ifdef(`PNETCDF',,`define(`DEBUG_ASSIGN_ERROR',`$1 = $2;')')
dnl
dnl *fillp is the fill value in internal representation
dnl
-define(`FillValue', `ifdef(`ERANGE_FILL', `ifelse(
+define(`FillValue', `
+#ifdef ERANGE_FILL
+ ifelse(
`$1', `schar', `if (fillp != NULL) memcpy($2, fillp, 1);',dnl
`$1', `uchar', `if (fillp != NULL) memcpy($2, fillp, 1);',dnl
`$1', `short', `if (fillp != NULL) memcpy($2, fillp, 2);',dnl
@@ -93,7 +98,8 @@ define(`FillValue', `ifdef(`ERANGE_FILL', `ifelse(
`$1', `longlong', `if (fillp != NULL) memcpy($2, fillp, 8);',dnl
`$1', `int64', `if (fillp != NULL) memcpy($2, fillp, 8);',dnl
`$1', `ulonglong', `if (fillp != NULL) memcpy($2, fillp, 8);',dnl
-`$1', `uint64', `if (fillp != NULL) memcpy($2, fillp, 8);')')')dnl
+`$1', `uint64', `if (fillp != NULL) memcpy($2, fillp, 8);')
+#endif')dnl
dnl
dnl
@@ -623,7 +629,9 @@ dnl For GET APIs boundary check
dnl
define(`GETF_CheckBND',
`if (xx > (double)Upcase($1)_MAX || xx < Dmin($1)) {
- ifdef(`ERANGE_FILL',`*ip = FillDefaultValue($1);')
+#ifdef ERANGE_FILL
+ *ip = FillDefaultValue($1);
+#endif
DEBUG_RETURN_ERROR(NC_ERANGE)
}
*ip = ($1)xx;')dnl
@@ -637,7 +645,9 @@ define(`GETF_CheckBND2',
`if (xx == Upcase($1)_MAX) *ip = Upcase($1)_MAX;
else if (xx == Upcase($1)_MIN) *ip = Upcase($1)_MIN;')
else if (xx > (double)Upcase($1)_MAX || xx < Dmin($1)) {
- ifdef(`ERANGE_FILL',`*ip = FillDefaultValue($1);')
+#ifdef ERANGE_FILL
+ *ip = FillDefaultValue($1);
+#endif
DEBUG_RETURN_ERROR(NC_ERANGE)
}
else *ip = ($1)xx;')
@@ -691,19 +701,23 @@ ifelse(`$3', `1',
if (xx > Imax($2)'`ifelse(index(`$1',`u'), 0, ,
index(`$2',`u'), 0, ,
` || xx < Imin($2)')'`) {
-ifdef(`ERANGE_FILL',`dnl
+#ifdef ERANGE_FILL
*ip = FillDefaultValue($2);
- DEBUG_RETURN_ERROR(NC_ERANGE)',`
- DEBUG_ASSIGN_ERROR(err, NC_ERANGE)')
+ DEBUG_RETURN_ERROR(NC_ERANGE)
+#else
+ DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
+#endif
}'
`#'endif
`ifelse(index(`$1',`u'), 0, , index(`$2',`u'), 0,`dnl
if (xx < 0) {
-ifdef(`ERANGE_FILL',`dnl
+#ifdef ERANGE_FILL
*ip = FillDefaultValue($2);
- DEBUG_RETURN_ERROR(NC_ERANGE)',`
- DEBUG_ASSIGN_ERROR(err, NC_ERANGE)') /* because ip is unsigned */
+ DEBUG_RETURN_ERROR(NC_ERANGE)
+#else
+ DEBUG_ASSIGN_ERROR(err, NC_ERANGE) /* because ip is unsigned */
+#endif
}')'dnl
*ip = ($2) xx;
@@ -728,11 +742,17 @@ APIPrefix`x_put_'NC_TYPE($1)_$2(void *xp, const $2 *ip, void *fillp)
ifelse(`$2', `double', `if (*ip > Xmax($1) || *ip < DXmin($1)) {
FillValue($1, &xx)
DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
- } ifdef(`ERANGE_FILL',`else')',
+ }
+#ifdef ERANGE_FILL
+ else
+#endif',
`$2', `float', `if (*ip > (double)Xmax($1) || *ip < FXmin($1)) {
FillValue($1, &xx)
DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
- } ifdef(`ERANGE_FILL',`else')')
+ }
+#ifdef ERANGE_FILL
+ else
+#endif')
xx = (ix_$1)*ip;
put_ix_$1(xp, &xx);
@@ -763,13 +783,19 @@ ifelse(`$3', `1',
` || *ip < Xmin($1)')'`) {
FillValue($1, &xx)
DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
- } ifdef(`ERANGE_FILL',`else')
+ }
+#ifdef ERANGE_FILL
+ else
+#endif
`#'endif
ifelse(index(`$1',`u'), 0, `ifelse(index(`$2',`u'), 0, ,`dnl
if (*ip < 0) {
FillValue($1, &xx)
DEBUG_ASSIGN_ERROR(err, NC_ERANGE) /* because xp is unsigned */
- } ifdef(`ERANGE_FILL',`else')
+ }
+#ifdef ERANGE_FILL
+ else
+#endif
')')dnl
xx = (ix_$1)*ip;
@@ -937,13 +963,15 @@ APIPrefix`x_put_'NC_TYPE(ushort)_schar(void *xp, const schar *ip, void *fillp)
int err=NC_NOERR;
uchar *cp;
if (*ip < 0) {
-ifdef(`ERANGE_FILL', `dnl
+#ifdef ERANGE_FILL
if (fillp != NULL) memcpy(xp, fillp, 2);
#ifndef WORDS_BIGENDIAN
swapn2b(xp, xp, 1);
#endif
- DEBUG_RETURN_ERROR(NC_ERANGE)',`dnl
- DEBUG_ASSIGN_ERROR(err, NC_ERANGE)')
+ DEBUG_RETURN_ERROR(NC_ERANGE)
+#else
+ DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
+#endif
}
cp = (uchar *) xp;
@@ -1146,11 +1174,12 @@ APIPrefix`x_put_'NC_TYPE(uint)_schar(void *xp, const schar *ip, void *fillp)
{
uchar *cp;
if (*ip < 0) {
-ifdef(`ERANGE_FILL', `dnl
+#ifdef ERANGE_FILL
if (fillp != NULL) memcpy(xp, fillp, 4);
#ifndef WORDS_BIGENDIAN
swapn4b(xp, xp, 1);
-#endif')
+#endif
+#endif
DEBUG_RETURN_ERROR(NC_ERANGE)
}
@@ -1628,10 +1657,14 @@ APIPrefix`x_put_'NC_TYPE(float)_float(void *xp, const float *ip, void *fillp)
int err=NC_NOERR;
float *_ip=ip;
#ifdef NO_IEEE_FLOAT
- ifdef(`ERANGE_FILL',`float tmp;')
+#ifdef ERANGE_FILL
+ float tmp;
+#endif
if (*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN) {
FillValue(float, &tmp)
- ifdef(`ERANGE_FILL',`_ip = &tmp;')
+#ifdef ERANGE_FILL
+ _ip = &tmp;
+#endif
DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
}
#endif
@@ -1947,11 +1980,19 @@ APIPrefix`x_get_'NC_TYPE(double)_float(const void *xp, float *ip)
double xx;
get_ix_double(xp, &xx);
if (xx > FLT_MAX) {
- ifdef(`ERANGE_FILL', `*ip = NC_FILL_FLOAT;', `*ip = FLT_MAX;')
+#ifdef ERANGE_FILL
+ *ip = NC_FILL_FLOAT;
+#else
+ *ip = FLT_MAX;
+#endif
DEBUG_RETURN_ERROR(NC_ERANGE)
}
if (xx < (-FLT_MAX)) {
- ifdef(`ERANGE_FILL', `*ip = NC_FILL_FLOAT;', `*ip = (-FLT_MAX);')
+#ifdef ERANGE_FILL
+ *ip = NC_FILL_FLOAT;
+#else
+ *ip = (-FLT_MAX);
+#endif
DEBUG_RETURN_ERROR(NC_ERANGE)
}
*ip = (float) xx;
@@ -1987,7 +2028,10 @@ APIPrefix`x_put_'NC_TYPE(double)_float(void *xp, const float *ip, void *fillp)
if ((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN) {
FillValue(double, &xx)
DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
- } ifdef(`ERANGE_FILL',`else')
+ }
+#ifdef ERANGE_FILL
+ else
+#endif
#endif
xx = (double) *ip;
@@ -2002,10 +2046,14 @@ APIPrefix`x_put_'NC_TYPE(double)_double(void *xp, const double *ip, void *fillp)
int err=NC_NOERR;
double *_ip = ip;
#ifdef NO_IEEE_FLOAT
- ifdef(`ERANGE_FILL',`double tmp=NC_FILL_DOUBLE;')
+#ifdef ERANGE_FILL
+ double tmp=NC_FILL_DOUBLE;
+#endif
if (*ip > X_DOUBLE_MAX || *ip < X_DOUBLE_MIN) {
FillValue(double, &tmp)
- ifdef(`ERANGE_FILL',`_ip = &tmp;')
+#ifdef ERANGE_FILL
+ _ip = &tmp;
+#endif
DEBUG_ASSIGN_ERROR(err, NC_ERANGE)
}
#endif
@@ -2468,7 +2516,9 @@ APIPrefix`x_getn_'NC_TYPE($1)_$2(const void **xpp, IntType nelems, $2 *tp)
ifelse(index(`$1',`u'), 0, ,
index(`$2',`u'), 0, `
if (*xp < 0) {
- ifdef(`ERANGE_FILL',`*tp = FillDefaultValue($2);')
+#ifdef ERANGE_FILL
+ *tp = FillDefaultValue($2);
+#endif
DEBUG_ASSIGN_ERROR(status, NC_ERANGE) /* because tp is unsigned */
SKIP_LOOP(xp, tp)
}')dnl
@@ -2500,7 +2550,9 @@ APIPrefix`x_pad_getn_'NC_TYPE($1)_$2(const void **xpp, IntType nelems, $2 *tp)
ifelse(index(`$1',`u'), 0, ,
index(`$2',`u'), 0, `
if (*xp < 0) {
- ifdef(`ERANGE_FILL', `*tp = FillDefaultValue($2);')
+#ifdef ERANGE_FILL
+ *tp = FillDefaultValue($2);
+#endif
DEBUG_ASSIGN_ERROR(status, NC_ERANGE) /* because tp is unsigned */
SKIP_LOOP(xp, tp)
}')dnl
diff --git a/libsrc/putget.c b/libsrc/putget.c
index 96966be..c2d582d 100644
--- a/libsrc/putget.c
+++ b/libsrc/putget.c
@@ -1111,311 +1111,13 @@ NC_varoffset(const NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
}
-#line 749
-
-static int
-#line 750
-putNCvx_char_char(NC3_INFO* ncp, const NC_var *varp,
-#line 750
- const size_t *start, size_t nelems, const char *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
- void *fillp;
-#line 750
-
-#line 750
- if(nelems == 0)
-#line 750
- return NC_NOERR;
-#line 750
-
-#line 750
- assert(value != NULL);
-#line 750
-
-#line 750
- fillp = malloc(varp->xsz);
-#line 750
- status = NC3_inq_var_fill(varp, fillp);
-#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_char_char(&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 += (off_t)extent;
-#line 750
- value += nput;
-#line 750
-
-#line 750
- }
-#line 750
- free(fillp);
-#line 750
-
-#line 750
- return status;
-#line 750
-}
-#line 750
-
-
-static int
-#line 752
-putNCvx_schar_schar(NC3_INFO* ncp, const NC_var *varp,
-#line 752
- const size_t *start, size_t nelems, const schar *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
- void *fillp;
-#line 752
-
-#line 752
- if(nelems == 0)
-#line 752
- return NC_NOERR;
-#line 752
-
-#line 752
- assert(value != NULL);
-#line 752
-
-#line 752
- fillp = malloc(varp->xsz);
-#line 752
- status = NC3_inq_var_fill(varp, fillp);
-#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_schar_schar(&xp, nput, value ,fillp);
-#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 += (off_t)extent;
-#line 752
- value += nput;
-#line 752
-
-#line 752
- }
-#line 752
- free(fillp);
-#line 752
-
-#line 752
- return status;
-#line 752
-}
-#line 752
-
-static int
-#line 753
-putNCvx_schar_uchar(NC3_INFO* ncp, const NC_var *varp,
-#line 753
- const size_t *start, size_t nelems, const uchar *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
- void *fillp;
-#line 753
-
-#line 753
- if(nelems == 0)
-#line 753
- return NC_NOERR;
-#line 753
-
-#line 753
- assert(value != NULL);
-#line 753
-
-#line 753
- fillp = malloc(varp->xsz);
-#line 753
- status = NC3_inq_var_fill(varp, fillp);
-#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_schar_uchar(&xp, nput, value ,fillp);
-#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 += (off_t)extent;
-#line 753
- value += nput;
-#line 753
-
-#line 753
- }
-#line 753
- free(fillp);
-#line 753
-
-#line 753
- return status;
-#line 753
-}
#line 753
static int
#line 754
-putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_char_char(NC3_INFO* ncp, const NC_var *varp,
#line 754
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const char *value)
#line 754
{
#line 754
@@ -1427,7 +1129,7 @@ putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
#line 754
void *xp;
#line 754
- void *fillp;
+ void *fillp=NULL;
#line 754
#line 754
@@ -1441,9 +1143,13 @@ putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
#line 754
#line 754
+#ifdef ERANGE_FILL
+#line 754
fillp = malloc(varp->xsz);
#line 754
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 754
+#endif
#line 754
#line 754
@@ -1467,7 +1173,7 @@ putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
#line 754
#line 754
- lstatus = ncx_putn_schar_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_char_char(&xp, nput, value );
#line 754
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 754
@@ -1501,8 +1207,12 @@ putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
#line 754
}
#line 754
+#ifdef ERANGE_FILL
+#line 754
free(fillp);
#line 754
+#endif
+#line 754
#line 754
return status;
@@ -1510,110 +1220,12 @@ putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 754
-static int
-#line 755
-putNCvx_schar_int(NC3_INFO* ncp, const NC_var *varp,
-#line 755
- const size_t *start, size_t nelems, const int *value)
-#line 755
-{
-#line 755
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 755
- size_t remaining = varp->xsz * nelems;
-#line 755
- int status = NC_NOERR;
-#line 755
- void *xp;
-#line 755
- void *fillp;
-#line 755
-
-#line 755
- if(nelems == 0)
-#line 755
- return NC_NOERR;
-#line 755
-
-#line 755
- assert(value != NULL);
-#line 755
-
-#line 755
- fillp = malloc(varp->xsz);
-#line 755
- status = NC3_inq_var_fill(varp, fillp);
-#line 755
-
-#line 755
- for(;;)
-#line 755
- {
-#line 755
- size_t extent = MIN(remaining, ncp->chunk);
-#line 755
- size_t nput = ncx_howmany(varp->type, extent);
-#line 755
-
-#line 755
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 755
- RGN_WRITE, &xp);
-#line 755
- if(lstatus != NC_NOERR)
-#line 755
- return lstatus;
-#line 755
-
-#line 755
- lstatus = ncx_putn_schar_int(&xp, nput, value ,fillp);
-#line 755
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 755
- {
-#line 755
- /* not fatal to the loop */
-#line 755
- status = lstatus;
-#line 755
- }
-#line 755
-
-#line 755
- (void) ncio_rel(ncp->nciop, offset,
-#line 755
- RGN_MODIFIED);
-#line 755
-
-#line 755
- remaining -= extent;
-#line 755
- if(remaining == 0)
-#line 755
- break; /* normal loop exit */
-#line 755
- offset += (off_t)extent;
-#line 755
- value += nput;
-#line 755
-
-#line 755
- }
-#line 755
- free(fillp);
-#line 755
-
-#line 755
- return status;
-#line 755
-}
-#line 755
static int
#line 756
-putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_schar(NC3_INFO* ncp, const NC_var *varp,
#line 756
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 756
{
#line 756
@@ -1625,7 +1237,7 @@ putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
#line 756
void *xp;
#line 756
- void *fillp;
+ void *fillp=NULL;
#line 756
#line 756
@@ -1639,9 +1251,13 @@ putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
#line 756
#line 756
+#ifdef ERANGE_FILL
+#line 756
fillp = malloc(varp->xsz);
#line 756
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 756
+#endif
#line 756
#line 756
@@ -1665,7 +1281,7 @@ putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
#line 756
#line 756
- lstatus = ncx_putn_schar_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_schar(&xp, nput, value ,fillp);
#line 756
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 756
@@ -1699,8 +1315,12 @@ putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
#line 756
}
#line 756
+#ifdef ERANGE_FILL
+#line 756
free(fillp);
#line 756
+#endif
+#line 756
#line 756
return status;
@@ -1710,9 +1330,9 @@ putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 757
-putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 757
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 757
{
#line 757
@@ -1724,7 +1344,7 @@ putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
#line 757
void *xp;
#line 757
- void *fillp;
+ void *fillp=NULL;
#line 757
#line 757
@@ -1738,9 +1358,13 @@ putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
#line 757
#line 757
+#ifdef ERANGE_FILL
+#line 757
fillp = malloc(varp->xsz);
#line 757
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 757
+#endif
#line 757
#line 757
@@ -1764,7 +1388,7 @@ putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
#line 757
#line 757
- lstatus = ncx_putn_schar_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_uchar(&xp, nput, value ,fillp);
#line 757
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 757
@@ -1798,8 +1422,12 @@ putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
#line 757
}
#line 757
+#ifdef ERANGE_FILL
+#line 757
free(fillp);
#line 757
+#endif
+#line 757
#line 757
return status;
@@ -1809,9 +1437,9 @@ putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 758
-putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_short(NC3_INFO* ncp, const NC_var *varp,
#line 758
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 758
{
#line 758
@@ -1823,7 +1451,7 @@ putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 758
void *xp;
#line 758
- void *fillp;
+ void *fillp=NULL;
#line 758
#line 758
@@ -1837,9 +1465,13 @@ putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 758
#line 758
+#ifdef ERANGE_FILL
+#line 758
fillp = malloc(varp->xsz);
#line 758
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 758
+#endif
#line 758
#line 758
@@ -1863,7 +1495,7 @@ putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 758
#line 758
- lstatus = ncx_putn_schar_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_short(&xp, nput, value ,fillp);
#line 758
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 758
@@ -1897,8 +1529,12 @@ putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 758
}
#line 758
+#ifdef ERANGE_FILL
+#line 758
free(fillp);
#line 758
+#endif
+#line 758
#line 758
return status;
@@ -1908,9 +1544,9 @@ putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 759
-putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_int(NC3_INFO* ncp, const NC_var *varp,
#line 759
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 759
{
#line 759
@@ -1922,7 +1558,7 @@ putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 759
void *xp;
#line 759
- void *fillp;
+ void *fillp=NULL;
#line 759
#line 759
@@ -1936,9 +1572,13 @@ putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 759
#line 759
+#ifdef ERANGE_FILL
+#line 759
fillp = malloc(varp->xsz);
#line 759
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 759
+#endif
#line 759
#line 759
@@ -1962,7 +1602,7 @@ putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 759
#line 759
- lstatus = ncx_putn_schar_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_int(&xp, nput, value ,fillp);
#line 759
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 759
@@ -1996,8 +1636,12 @@ putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 759
}
#line 759
+#ifdef ERANGE_FILL
+#line 759
free(fillp);
#line 759
+#endif
+#line 759
#line 759
return status;
@@ -2007,9 +1651,9 @@ putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 760
-putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_float(NC3_INFO* ncp, const NC_var *varp,
#line 760
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 760
{
#line 760
@@ -2021,7 +1665,7 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 760
void *xp;
#line 760
- void *fillp;
+ void *fillp=NULL;
#line 760
#line 760
@@ -2035,9 +1679,13 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 760
#line 760
+#ifdef ERANGE_FILL
+#line 760
fillp = malloc(varp->xsz);
#line 760
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 760
+#endif
#line 760
#line 760
@@ -2061,7 +1709,7 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 760
#line 760
- lstatus = ncx_putn_schar_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_float(&xp, nput, value ,fillp);
#line 760
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 760
@@ -2095,8 +1743,12 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 760
}
#line 760
+#ifdef ERANGE_FILL
+#line 760
free(fillp);
#line 760
+#endif
+#line 760
#line 760
return status;
@@ -2106,9 +1758,9 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 761
-putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_double(NC3_INFO* ncp, const NC_var *varp,
#line 761
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 761
{
#line 761
@@ -2120,7 +1772,7 @@ putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 761
void *xp;
#line 761
- void *fillp;
+ void *fillp=NULL;
#line 761
#line 761
@@ -2134,81 +1786,195 @@ putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 761
#line 761
+#ifdef ERANGE_FILL
+#line 761
fillp = malloc(varp->xsz);
#line 761
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 761
+#endif
+#line 761
+
+#line 761
+ for(;;)
+#line 761
+ {
+#line 761
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 761
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 761
+
+#line 761
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 761
+ RGN_WRITE, &xp);
+#line 761
+ if(lstatus != NC_NOERR)
+#line 761
+ return lstatus;
+#line 761
+
+#line 761
+ lstatus = ncx_putn_schar_double(&xp, nput, value ,fillp);
+#line 761
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 761
+ {
+#line 761
+ /* not fatal to the loop */
+#line 761
+ status = lstatus;
+#line 761
+ }
+#line 761
+
+#line 761
+ (void) ncio_rel(ncp->nciop, offset,
+#line 761
+ RGN_MODIFIED);
+#line 761
+
+#line 761
+ remaining -= extent;
+#line 761
+ if(remaining == 0)
+#line 761
+ break; /* normal loop exit */
+#line 761
+ offset += (off_t)extent;
+#line 761
+ value += nput;
+#line 761
+
+#line 761
+ }
+#line 761
+#ifdef ERANGE_FILL
+#line 761
+ free(fillp);
+#line 761
+#endif
#line 761
#line 761
+ return status;
+#line 761
+}
+#line 761
+
+static int
+#line 762
+putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 762
+ const size_t *start, size_t nelems, const longlong *value)
+#line 762
+{
+#line 762
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 762
+ size_t remaining = varp->xsz * nelems;
+#line 762
+ int status = NC_NOERR;
+#line 762
+ void *xp;
+#line 762
+ void *fillp=NULL;
+#line 762
+
+#line 762
+ if(nelems == 0)
+#line 762
+ return NC_NOERR;
+#line 762
+
+#line 762
+ assert(value != NULL);
+#line 762
+
+#line 762
+#ifdef ERANGE_FILL
+#line 762
+ fillp = malloc(varp->xsz);
+#line 762
+ status = NC3_inq_var_fill(varp, fillp);
+#line 762
+#endif
+#line 762
+
+#line 762
for(;;)
-#line 761
+#line 762
{
-#line 761
+#line 762
size_t extent = MIN(remaining, ncp->chunk);
-#line 761
+#line 762
size_t nput = ncx_howmany(varp->type, extent);
-#line 761
+#line 762
-#line 761
+#line 762
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 761
+#line 762
RGN_WRITE, &xp);
-#line 761
+#line 762
if(lstatus != NC_NOERR)
-#line 761
+#line 762
return lstatus;
-#line 761
+#line 762
-#line 761
- lstatus = ncx_putn_schar_ulonglong(&xp, nput, value ,fillp);
-#line 761
+#line 762
+ lstatus = ncx_putn_schar_longlong(&xp, nput, value ,fillp);
+#line 762
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 761
+#line 762
{
-#line 761
+#line 762
/* not fatal to the loop */
-#line 761
+#line 762
status = lstatus;
-#line 761
+#line 762
}
-#line 761
+#line 762
-#line 761
+#line 762
(void) ncio_rel(ncp->nciop, offset,
-#line 761
+#line 762
RGN_MODIFIED);
-#line 761
+#line 762
-#line 761
+#line 762
remaining -= extent;
-#line 761
+#line 762
if(remaining == 0)
-#line 761
+#line 762
break; /* normal loop exit */
-#line 761
+#line 762
offset += (off_t)extent;
-#line 761
+#line 762
value += nput;
-#line 761
+#line 762
-#line 761
+#line 762
}
-#line 761
+#line 762
+#ifdef ERANGE_FILL
+#line 762
free(fillp);
-#line 761
+#line 762
+#endif
+#line 762
-#line 761
+#line 762
return status;
-#line 761
+#line 762
}
-#line 761
-
+#line 762
static int
#line 763
-putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 763
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 763
{
#line 763
@@ -2220,7 +1986,7 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
#line 763
void *xp;
#line 763
- void *fillp;
+ void *fillp=NULL;
#line 763
#line 763
@@ -2234,9 +2000,13 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
#line 763
#line 763
+#ifdef ERANGE_FILL
+#line 763
fillp = malloc(varp->xsz);
#line 763
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 763
+#endif
#line 763
#line 763
@@ -2260,7 +2030,7 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
#line 763
#line 763
- lstatus = ncx_putn_short_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_ushort(&xp, nput, value ,fillp);
#line 763
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 763
@@ -2294,8 +2064,12 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
#line 763
}
#line 763
+#ifdef ERANGE_FILL
+#line 763
free(fillp);
#line 763
+#endif
+#line 763
#line 763
return status;
@@ -2305,9 +2079,9 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 764
-putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 764
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 764
{
#line 764
@@ -2319,7 +2093,7 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 764
void *xp;
#line 764
- void *fillp;
+ void *fillp=NULL;
#line 764
#line 764
@@ -2333,9 +2107,13 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 764
#line 764
+#ifdef ERANGE_FILL
+#line 764
fillp = malloc(varp->xsz);
#line 764
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 764
+#endif
#line 764
#line 764
@@ -2359,7 +2137,7 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 764
#line 764
- lstatus = ncx_putn_short_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_uint(&xp, nput, value ,fillp);
#line 764
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 764
@@ -2393,8 +2171,12 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 764
}
#line 764
+#ifdef ERANGE_FILL
+#line 764
free(fillp);
#line 764
+#endif
+#line 764
#line 764
return status;
@@ -2404,9 +2186,9 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 765
-putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 765
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 765
{
#line 765
@@ -2418,7 +2200,7 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
#line 765
void *xp;
#line 765
- void *fillp;
+ void *fillp=NULL;
#line 765
#line 765
@@ -2432,9 +2214,13 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
#line 765
#line 765
+#ifdef ERANGE_FILL
+#line 765
fillp = malloc(varp->xsz);
#line 765
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 765
+#endif
#line 765
#line 765
@@ -2458,7 +2244,7 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
#line 765
#line 765
- lstatus = ncx_putn_short_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_schar_ulonglong(&xp, nput, value ,fillp);
#line 765
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 765
@@ -2492,8 +2278,12 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
#line 765
}
#line 765
+#ifdef ERANGE_FILL
+#line 765
free(fillp);
#line 765
+#endif
+#line 765
#line 765
return status;
@@ -2501,110 +2291,12 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 765
-static int
-#line 766
-putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
-#line 766
- const size_t *start, size_t nelems, const int *value)
-#line 766
-{
-#line 766
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 766
- size_t remaining = varp->xsz * nelems;
-#line 766
- int status = NC_NOERR;
-#line 766
- void *xp;
-#line 766
- void *fillp;
-#line 766
-
-#line 766
- if(nelems == 0)
-#line 766
- return NC_NOERR;
-#line 766
-
-#line 766
- assert(value != NULL);
-#line 766
-
-#line 766
- fillp = malloc(varp->xsz);
-#line 766
- status = NC3_inq_var_fill(varp, fillp);
-#line 766
-
-#line 766
- for(;;)
-#line 766
- {
-#line 766
- size_t extent = MIN(remaining, ncp->chunk);
-#line 766
- size_t nput = ncx_howmany(varp->type, extent);
-#line 766
-
-#line 766
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 766
- RGN_WRITE, &xp);
-#line 766
- if(lstatus != NC_NOERR)
-#line 766
- return lstatus;
-#line 766
-
-#line 766
- lstatus = ncx_putn_short_int(&xp, nput, value ,fillp);
-#line 766
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 766
- {
-#line 766
- /* not fatal to the loop */
-#line 766
- status = lstatus;
-#line 766
- }
-#line 766
-
-#line 766
- (void) ncio_rel(ncp->nciop, offset,
-#line 766
- RGN_MODIFIED);
-#line 766
-
-#line 766
- remaining -= extent;
-#line 766
- if(remaining == 0)
-#line 766
- break; /* normal loop exit */
-#line 766
- offset += (off_t)extent;
-#line 766
- value += nput;
-#line 766
-
-#line 766
- }
-#line 766
- free(fillp);
-#line 766
-
-#line 766
- return status;
-#line 766
-}
-#line 766
static int
#line 767
-putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
#line 767
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 767
{
#line 767
@@ -2616,7 +2308,7 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
#line 767
void *xp;
#line 767
- void *fillp;
+ void *fillp=NULL;
#line 767
#line 767
@@ -2630,9 +2322,13 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
#line 767
#line 767
+#ifdef ERANGE_FILL
+#line 767
fillp = malloc(varp->xsz);
#line 767
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 767
+#endif
#line 767
#line 767
@@ -2656,7 +2352,7 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
#line 767
#line 767
- lstatus = ncx_putn_short_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_schar(&xp, nput, value ,fillp);
#line 767
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 767
@@ -2690,8 +2386,12 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
#line 767
}
#line 767
+#ifdef ERANGE_FILL
+#line 767
free(fillp);
#line 767
+#endif
+#line 767
#line 767
return status;
@@ -2701,9 +2401,9 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 768
-putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 768
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 768
{
#line 768
@@ -2715,7 +2415,7 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
#line 768
void *xp;
#line 768
- void *fillp;
+ void *fillp=NULL;
#line 768
#line 768
@@ -2729,9 +2429,13 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
#line 768
#line 768
+#ifdef ERANGE_FILL
+#line 768
fillp = malloc(varp->xsz);
#line 768
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 768
+#endif
#line 768
#line 768
@@ -2755,7 +2459,7 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
#line 768
#line 768
- lstatus = ncx_putn_short_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_uchar(&xp, nput, value ,fillp);
#line 768
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 768
@@ -2789,8 +2493,12 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
#line 768
}
#line 768
+#ifdef ERANGE_FILL
+#line 768
free(fillp);
#line 768
+#endif
+#line 768
#line 768
return status;
@@ -2800,9 +2508,9 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 769
-putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
#line 769
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 769
{
#line 769
@@ -2814,7 +2522,7 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 769
void *xp;
#line 769
- void *fillp;
+ void *fillp=NULL;
#line 769
#line 769
@@ -2828,9 +2536,13 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 769
#line 769
+#ifdef ERANGE_FILL
+#line 769
fillp = malloc(varp->xsz);
#line 769
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 769
+#endif
#line 769
#line 769
@@ -2854,7 +2566,7 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 769
#line 769
- lstatus = ncx_putn_short_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_short(&xp, nput, value ,fillp);
#line 769
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 769
@@ -2888,8 +2600,12 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 769
}
#line 769
+#ifdef ERANGE_FILL
+#line 769
free(fillp);
#line 769
+#endif
+#line 769
#line 769
return status;
@@ -2899,9 +2615,9 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 770
-putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
#line 770
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 770
{
#line 770
@@ -2913,7 +2629,7 @@ putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 770
void *xp;
#line 770
- void *fillp;
+ void *fillp=NULL;
#line 770
#line 770
@@ -2927,9 +2643,13 @@ putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 770
#line 770
+#ifdef ERANGE_FILL
+#line 770
fillp = malloc(varp->xsz);
#line 770
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 770
+#endif
#line 770
#line 770
@@ -2953,7 +2673,7 @@ putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 770
#line 770
- lstatus = ncx_putn_short_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_int(&xp, nput, value ,fillp);
#line 770
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 770
@@ -2987,8 +2707,12 @@ putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 770
}
#line 770
+#ifdef ERANGE_FILL
+#line 770
free(fillp);
#line 770
+#endif
+#line 770
#line 770
return status;
@@ -2998,9 +2722,9 @@ putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 771
-putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
#line 771
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 771
{
#line 771
@@ -3012,7 +2736,7 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
#line 771
void *xp;
#line 771
- void *fillp;
+ void *fillp=NULL;
#line 771
#line 771
@@ -3026,9 +2750,13 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
#line 771
#line 771
+#ifdef ERANGE_FILL
+#line 771
fillp = malloc(varp->xsz);
#line 771
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 771
+#endif
#line 771
#line 771
@@ -3052,7 +2780,7 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
#line 771
#line 771
- lstatus = ncx_putn_short_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_float(&xp, nput, value ,fillp);
#line 771
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 771
@@ -3086,8 +2814,12 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
#line 771
}
#line 771
+#ifdef ERANGE_FILL
+#line 771
free(fillp);
#line 771
+#endif
+#line 771
#line 771
return status;
@@ -3097,9 +2829,9 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 772
-putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
#line 772
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 772
{
#line 772
@@ -3111,7 +2843,7 @@ putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 772
void *xp;
#line 772
- void *fillp;
+ void *fillp=NULL;
#line 772
#line 772
@@ -3125,9 +2857,13 @@ putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 772
#line 772
+#ifdef ERANGE_FILL
+#line 772
fillp = malloc(varp->xsz);
#line 772
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 772
+#endif
#line 772
#line 772
@@ -3151,55 +2887,165 @@ putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 772
#line 772
- lstatus = ncx_putn_short_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_double(&xp, nput, value ,fillp);
+#line 772
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 772
+ {
+#line 772
+ /* not fatal to the loop */
+#line 772
+ status = lstatus;
+#line 772
+ }
+#line 772
+
+#line 772
+ (void) ncio_rel(ncp->nciop, offset,
+#line 772
+ RGN_MODIFIED);
+#line 772
+
+#line 772
+ remaining -= extent;
+#line 772
+ if(remaining == 0)
+#line 772
+ break; /* normal loop exit */
+#line 772
+ offset += (off_t)extent;
+#line 772
+ value += nput;
+#line 772
+
+#line 772
+ }
+#line 772
+#ifdef ERANGE_FILL
+#line 772
+ free(fillp);
+#line 772
+#endif
#line 772
+
+#line 772
+ return status;
+#line 772
+}
+#line 772
+
+static int
+#line 773
+putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 773
+ const size_t *start, size_t nelems, const longlong *value)
+#line 773
+{
+#line 773
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 773
+ size_t remaining = varp->xsz * nelems;
+#line 773
+ int status = NC_NOERR;
+#line 773
+ void *xp;
+#line 773
+ void *fillp=NULL;
+#line 773
+
+#line 773
+ if(nelems == 0)
+#line 773
+ return NC_NOERR;
+#line 773
+
+#line 773
+ assert(value != NULL);
+#line 773
+
+#line 773
+#ifdef ERANGE_FILL
+#line 773
+ fillp = malloc(varp->xsz);
+#line 773
+ status = NC3_inq_var_fill(varp, fillp);
+#line 773
+#endif
+#line 773
+
+#line 773
+ for(;;)
+#line 773
+ {
+#line 773
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 773
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 773
+
+#line 773
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 773
+ RGN_WRITE, &xp);
+#line 773
+ if(lstatus != NC_NOERR)
+#line 773
+ return lstatus;
+#line 773
+
+#line 773
+ lstatus = ncx_putn_short_longlong(&xp, nput, value ,fillp);
+#line 773
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 772
+#line 773
{
-#line 772
+#line 773
/* not fatal to the loop */
-#line 772
+#line 773
status = lstatus;
-#line 772
+#line 773
}
-#line 772
+#line 773
-#line 772
+#line 773
(void) ncio_rel(ncp->nciop, offset,
-#line 772
+#line 773
RGN_MODIFIED);
-#line 772
+#line 773
-#line 772
+#line 773
remaining -= extent;
-#line 772
+#line 773
if(remaining == 0)
-#line 772
+#line 773
break; /* normal loop exit */
-#line 772
+#line 773
offset += (off_t)extent;
-#line 772
+#line 773
value += nput;
-#line 772
+#line 773
-#line 772
+#line 773
}
-#line 772
+#line 773
+#ifdef ERANGE_FILL
+#line 773
free(fillp);
-#line 772
+#line 773
+#endif
+#line 773
-#line 772
+#line 773
return status;
-#line 772
+#line 773
}
-#line 772
-
+#line 773
static int
#line 774
-putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 774
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 774
{
#line 774
@@ -3211,7 +3057,7 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
#line 774
void *xp;
#line 774
- void *fillp;
+ void *fillp=NULL;
#line 774
#line 774
@@ -3225,9 +3071,13 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
#line 774
#line 774
+#ifdef ERANGE_FILL
+#line 774
fillp = malloc(varp->xsz);
#line 774
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 774
+#endif
#line 774
#line 774
@@ -3251,7 +3101,7 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
#line 774
#line 774
- lstatus = ncx_putn_int_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_ushort(&xp, nput, value ,fillp);
#line 774
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 774
@@ -3285,8 +3135,12 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
#line 774
}
#line 774
+#ifdef ERANGE_FILL
+#line 774
free(fillp);
#line 774
+#endif
+#line 774
#line 774
return status;
@@ -3296,9 +3150,9 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 775
-putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
#line 775
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 775
{
#line 775
@@ -3310,7 +3164,7 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 775
void *xp;
#line 775
- void *fillp;
+ void *fillp=NULL;
#line 775
#line 775
@@ -3324,9 +3178,13 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 775
#line 775
+#ifdef ERANGE_FILL
+#line 775
fillp = malloc(varp->xsz);
#line 775
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 775
+#endif
#line 775
#line 775
@@ -3350,7 +3208,7 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 775
#line 775
- lstatus = ncx_putn_int_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_uint(&xp, nput, value ,fillp);
#line 775
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 775
@@ -3384,8 +3242,12 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 775
}
#line 775
+#ifdef ERANGE_FILL
+#line 775
free(fillp);
#line 775
+#endif
+#line 775
#line 775
return status;
@@ -3395,9 +3257,9 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 776
-putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 776
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 776
{
#line 776
@@ -3409,7 +3271,7 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
#line 776
void *xp;
#line 776
- void *fillp;
+ void *fillp=NULL;
#line 776
#line 776
@@ -3423,9 +3285,13 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
#line 776
#line 776
+#ifdef ERANGE_FILL
+#line 776
fillp = malloc(varp->xsz);
#line 776
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 776
+#endif
#line 776
#line 776
@@ -3449,7 +3315,7 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
#line 776
#line 776
- lstatus = ncx_putn_int_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_short_ulonglong(&xp, nput, value ,fillp);
#line 776
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 776
@@ -3483,8 +3349,12 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
#line 776
}
#line 776
+#ifdef ERANGE_FILL
+#line 776
free(fillp);
#line 776
+#endif
+#line 776
#line 776
return status;
@@ -3492,110 +3362,12 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 776
-static int
-#line 777
-putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
-#line 777
- const size_t *start, size_t nelems, const int *value)
-#line 777
-{
-#line 777
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 777
- size_t remaining = varp->xsz * nelems;
-#line 777
- int status = NC_NOERR;
-#line 777
- void *xp;
-#line 777
- void *fillp;
-#line 777
-
-#line 777
- if(nelems == 0)
-#line 777
- return NC_NOERR;
-#line 777
-
-#line 777
- assert(value != NULL);
-#line 777
-
-#line 777
- fillp = malloc(varp->xsz);
-#line 777
- status = NC3_inq_var_fill(varp, fillp);
-#line 777
-
-#line 777
- for(;;)
-#line 777
- {
-#line 777
- size_t extent = MIN(remaining, ncp->chunk);
-#line 777
- size_t nput = ncx_howmany(varp->type, extent);
-#line 777
-
-#line 777
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 777
- RGN_WRITE, &xp);
-#line 777
- if(lstatus != NC_NOERR)
-#line 777
- return lstatus;
-#line 777
-
-#line 777
- lstatus = ncx_putn_int_int(&xp, nput, value ,fillp);
-#line 777
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 777
- {
-#line 777
- /* not fatal to the loop */
-#line 777
- status = lstatus;
-#line 777
- }
-#line 777
-
-#line 777
- (void) ncio_rel(ncp->nciop, offset,
-#line 777
- RGN_MODIFIED);
-#line 777
-
-#line 777
- remaining -= extent;
-#line 777
- if(remaining == 0)
-#line 777
- break; /* normal loop exit */
-#line 777
- offset += (off_t)extent;
-#line 777
- value += nput;
-#line 777
-
-#line 777
- }
-#line 777
- free(fillp);
-#line 777
-
-#line 777
- return status;
-#line 777
-}
-#line 777
static int
#line 778
-putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
#line 778
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 778
{
#line 778
@@ -3607,7 +3379,7 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
#line 778
void *xp;
#line 778
- void *fillp;
+ void *fillp=NULL;
#line 778
#line 778
@@ -3621,9 +3393,13 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
#line 778
#line 778
+#ifdef ERANGE_FILL
+#line 778
fillp = malloc(varp->xsz);
#line 778
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 778
+#endif
#line 778
#line 778
@@ -3647,7 +3423,7 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
#line 778
#line 778
- lstatus = ncx_putn_int_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_schar(&xp, nput, value ,fillp);
#line 778
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 778
@@ -3681,8 +3457,12 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
#line 778
}
#line 778
+#ifdef ERANGE_FILL
+#line 778
free(fillp);
#line 778
+#endif
+#line 778
#line 778
return status;
@@ -3692,9 +3472,9 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 779
-putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 779
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 779
{
#line 779
@@ -3706,7 +3486,7 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
#line 779
void *xp;
#line 779
- void *fillp;
+ void *fillp=NULL;
#line 779
#line 779
@@ -3720,9 +3500,13 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
#line 779
#line 779
+#ifdef ERANGE_FILL
+#line 779
fillp = malloc(varp->xsz);
#line 779
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 779
+#endif
#line 779
#line 779
@@ -3746,7 +3530,7 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
#line 779
#line 779
- lstatus = ncx_putn_int_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_uchar(&xp, nput, value ,fillp);
#line 779
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 779
@@ -3780,8 +3564,12 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
#line 779
}
#line 779
+#ifdef ERANGE_FILL
+#line 779
free(fillp);
#line 779
+#endif
+#line 779
#line 779
return status;
@@ -3791,9 +3579,9 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 780
-putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
#line 780
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 780
{
#line 780
@@ -3805,7 +3593,7 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 780
void *xp;
#line 780
- void *fillp;
+ void *fillp=NULL;
#line 780
#line 780
@@ -3819,9 +3607,13 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 780
#line 780
+#ifdef ERANGE_FILL
+#line 780
fillp = malloc(varp->xsz);
#line 780
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 780
+#endif
#line 780
#line 780
@@ -3845,7 +3637,7 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 780
#line 780
- lstatus = ncx_putn_int_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_short(&xp, nput, value ,fillp);
#line 780
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 780
@@ -3879,8 +3671,12 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 780
}
#line 780
+#ifdef ERANGE_FILL
+#line 780
free(fillp);
#line 780
+#endif
+#line 780
#line 780
return status;
@@ -3890,9 +3686,9 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 781
-putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
#line 781
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 781
{
#line 781
@@ -3904,7 +3700,7 @@ putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 781
void *xp;
#line 781
- void *fillp;
+ void *fillp=NULL;
#line 781
#line 781
@@ -3918,9 +3714,13 @@ putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 781
#line 781
+#ifdef ERANGE_FILL
+#line 781
fillp = malloc(varp->xsz);
#line 781
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 781
+#endif
#line 781
#line 781
@@ -3944,7 +3744,7 @@ putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 781
#line 781
- lstatus = ncx_putn_int_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_int(&xp, nput, value ,fillp);
#line 781
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 781
@@ -3978,8 +3778,12 @@ putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 781
}
#line 781
+#ifdef ERANGE_FILL
+#line 781
free(fillp);
#line 781
+#endif
+#line 781
#line 781
return status;
@@ -3989,9 +3793,9 @@ putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 782
-putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
#line 782
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 782
{
#line 782
@@ -4003,7 +3807,7 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
#line 782
void *xp;
#line 782
- void *fillp;
+ void *fillp=NULL;
#line 782
#line 782
@@ -4017,9 +3821,13 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
#line 782
#line 782
+#ifdef ERANGE_FILL
+#line 782
fillp = malloc(varp->xsz);
#line 782
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 782
+#endif
#line 782
#line 782
@@ -4043,7 +3851,7 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
#line 782
#line 782
- lstatus = ncx_putn_int_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_float(&xp, nput, value ,fillp);
#line 782
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 782
@@ -4077,8 +3885,12 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
#line 782
}
#line 782
+#ifdef ERANGE_FILL
+#line 782
free(fillp);
#line 782
+#endif
+#line 782
#line 782
return status;
@@ -4088,9 +3900,9 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 783
-putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
#line 783
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 783
{
#line 783
@@ -4102,7 +3914,7 @@ putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 783
void *xp;
#line 783
- void *fillp;
+ void *fillp=NULL;
#line 783
#line 783
@@ -4116,9 +3928,13 @@ putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 783
#line 783
+#ifdef ERANGE_FILL
+#line 783
fillp = malloc(varp->xsz);
#line 783
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 783
+#endif
#line 783
#line 783
@@ -4127,70 +3943,180 @@ putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
{
#line 783
size_t extent = MIN(remaining, ncp->chunk);
-#line 783
+#line 783
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 783
+
+#line 783
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 783
+ RGN_WRITE, &xp);
+#line 783
+ if(lstatus != NC_NOERR)
+#line 783
+ return lstatus;
+#line 783
+
+#line 783
+ lstatus = ncx_putn_int_double(&xp, nput, value ,fillp);
+#line 783
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 783
+ {
+#line 783
+ /* not fatal to the loop */
+#line 783
+ status = lstatus;
+#line 783
+ }
+#line 783
+
+#line 783
+ (void) ncio_rel(ncp->nciop, offset,
+#line 783
+ RGN_MODIFIED);
+#line 783
+
+#line 783
+ remaining -= extent;
+#line 783
+ if(remaining == 0)
+#line 783
+ break; /* normal loop exit */
+#line 783
+ offset += (off_t)extent;
+#line 783
+ value += nput;
+#line 783
+
+#line 783
+ }
+#line 783
+#ifdef ERANGE_FILL
+#line 783
+ free(fillp);
+#line 783
+#endif
+#line 783
+
+#line 783
+ return status;
+#line 783
+}
+#line 783
+
+static int
+#line 784
+putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 784
+ const size_t *start, size_t nelems, const longlong *value)
+#line 784
+{
+#line 784
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 784
+ size_t remaining = varp->xsz * nelems;
+#line 784
+ int status = NC_NOERR;
+#line 784
+ void *xp;
+#line 784
+ void *fillp=NULL;
+#line 784
+
+#line 784
+ if(nelems == 0)
+#line 784
+ return NC_NOERR;
+#line 784
+
+#line 784
+ assert(value != NULL);
+#line 784
+
+#line 784
+#ifdef ERANGE_FILL
+#line 784
+ fillp = malloc(varp->xsz);
+#line 784
+ status = NC3_inq_var_fill(varp, fillp);
+#line 784
+#endif
+#line 784
+
+#line 784
+ for(;;)
+#line 784
+ {
+#line 784
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 784
size_t nput = ncx_howmany(varp->type, extent);
-#line 783
+#line 784
-#line 783
+#line 784
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 783
+#line 784
RGN_WRITE, &xp);
-#line 783
+#line 784
if(lstatus != NC_NOERR)
-#line 783
+#line 784
return lstatus;
-#line 783
+#line 784
-#line 783
- lstatus = ncx_putn_int_ulonglong(&xp, nput, value ,fillp);
-#line 783
+#line 784
+ lstatus = ncx_putn_int_longlong(&xp, nput, value ,fillp);
+#line 784
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 783
+#line 784
{
-#line 783
+#line 784
/* not fatal to the loop */
-#line 783
+#line 784
status = lstatus;
-#line 783
+#line 784
}
-#line 783
+#line 784
-#line 783
+#line 784
(void) ncio_rel(ncp->nciop, offset,
-#line 783
+#line 784
RGN_MODIFIED);
-#line 783
+#line 784
-#line 783
+#line 784
remaining -= extent;
-#line 783
+#line 784
if(remaining == 0)
-#line 783
+#line 784
break; /* normal loop exit */
-#line 783
+#line 784
offset += (off_t)extent;
-#line 783
+#line 784
value += nput;
-#line 783
+#line 784
-#line 783
+#line 784
}
-#line 783
+#line 784
+#ifdef ERANGE_FILL
+#line 784
free(fillp);
-#line 783
+#line 784
+#endif
+#line 784
-#line 783
+#line 784
return status;
-#line 783
+#line 784
}
-#line 783
-
+#line 784
static int
#line 785
-putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 785
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 785
{
#line 785
@@ -4202,7 +4128,7 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
#line 785
void *xp;
#line 785
- void *fillp;
+ void *fillp=NULL;
#line 785
#line 785
@@ -4216,9 +4142,13 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
#line 785
#line 785
+#ifdef ERANGE_FILL
+#line 785
fillp = malloc(varp->xsz);
#line 785
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 785
+#endif
#line 785
#line 785
@@ -4242,7 +4172,7 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
#line 785
#line 785
- lstatus = ncx_putn_float_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_ushort(&xp, nput, value ,fillp);
#line 785
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 785
@@ -4276,8 +4206,12 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
#line 785
}
#line 785
+#ifdef ERANGE_FILL
+#line 785
free(fillp);
#line 785
+#endif
+#line 785
#line 785
return status;
@@ -4287,9 +4221,9 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 786
-putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
#line 786
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 786
{
#line 786
@@ -4301,7 +4235,7 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 786
void *xp;
#line 786
- void *fillp;
+ void *fillp=NULL;
#line 786
#line 786
@@ -4315,9 +4249,13 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 786
#line 786
+#ifdef ERANGE_FILL
+#line 786
fillp = malloc(varp->xsz);
#line 786
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 786
+#endif
#line 786
#line 786
@@ -4341,7 +4279,7 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 786
#line 786
- lstatus = ncx_putn_float_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_uint(&xp, nput, value ,fillp);
#line 786
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 786
@@ -4375,8 +4313,12 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 786
}
#line 786
+#ifdef ERANGE_FILL
+#line 786
free(fillp);
#line 786
+#endif
+#line 786
#line 786
return status;
@@ -4386,9 +4328,9 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 787
-putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 787
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 787
{
#line 787
@@ -4400,7 +4342,7 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
#line 787
void *xp;
#line 787
- void *fillp;
+ void *fillp=NULL;
#line 787
#line 787
@@ -4414,9 +4356,13 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
#line 787
#line 787
+#ifdef ERANGE_FILL
+#line 787
fillp = malloc(varp->xsz);
#line 787
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 787
+#endif
#line 787
#line 787
@@ -4440,7 +4386,7 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
#line 787
#line 787
- lstatus = ncx_putn_float_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_int_ulonglong(&xp, nput, value ,fillp);
#line 787
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 787
@@ -4474,8 +4420,12 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
#line 787
}
#line 787
+#ifdef ERANGE_FILL
+#line 787
free(fillp);
#line 787
+#endif
+#line 787
#line 787
return status;
@@ -4483,110 +4433,12 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 787
-static int
-#line 788
-putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
-#line 788
- const size_t *start, size_t nelems, const int *value)
-#line 788
-{
-#line 788
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 788
- size_t remaining = varp->xsz * nelems;
-#line 788
- int status = NC_NOERR;
-#line 788
- void *xp;
-#line 788
- void *fillp;
-#line 788
-
-#line 788
- if(nelems == 0)
-#line 788
- return NC_NOERR;
-#line 788
-
-#line 788
- assert(value != NULL);
-#line 788
-
-#line 788
- fillp = malloc(varp->xsz);
-#line 788
- status = NC3_inq_var_fill(varp, fillp);
-#line 788
-
-#line 788
- for(;;)
-#line 788
- {
-#line 788
- size_t extent = MIN(remaining, ncp->chunk);
-#line 788
- size_t nput = ncx_howmany(varp->type, extent);
-#line 788
-
-#line 788
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 788
- RGN_WRITE, &xp);
-#line 788
- if(lstatus != NC_NOERR)
-#line 788
- return lstatus;
-#line 788
-
-#line 788
- lstatus = ncx_putn_float_int(&xp, nput, value ,fillp);
-#line 788
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 788
- {
-#line 788
- /* not fatal to the loop */
-#line 788
- status = lstatus;
-#line 788
- }
-#line 788
-
-#line 788
- (void) ncio_rel(ncp->nciop, offset,
-#line 788
- RGN_MODIFIED);
-#line 788
-
-#line 788
- remaining -= extent;
-#line 788
- if(remaining == 0)
-#line 788
- break; /* normal loop exit */
-#line 788
- offset += (off_t)extent;
-#line 788
- value += nput;
-#line 788
-
-#line 788
- }
-#line 788
- free(fillp);
-#line 788
-
-#line 788
- return status;
-#line 788
-}
-#line 788
static int
#line 789
-putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
#line 789
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 789
{
#line 789
@@ -4598,7 +4450,7 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
#line 789
void *xp;
#line 789
- void *fillp;
+ void *fillp=NULL;
#line 789
#line 789
@@ -4612,9 +4464,13 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
#line 789
#line 789
+#ifdef ERANGE_FILL
+#line 789
fillp = malloc(varp->xsz);
#line 789
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 789
+#endif
#line 789
#line 789
@@ -4638,7 +4494,7 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
#line 789
#line 789
- lstatus = ncx_putn_float_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_schar(&xp, nput, value ,fillp);
#line 789
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 789
@@ -4672,8 +4528,12 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
#line 789
}
#line 789
+#ifdef ERANGE_FILL
+#line 789
free(fillp);
#line 789
+#endif
+#line 789
#line 789
return status;
@@ -4683,9 +4543,9 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 790
-putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 790
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 790
{
#line 790
@@ -4697,7 +4557,7 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
#line 790
void *xp;
#line 790
- void *fillp;
+ void *fillp=NULL;
#line 790
#line 790
@@ -4711,9 +4571,13 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
#line 790
#line 790
+#ifdef ERANGE_FILL
+#line 790
fillp = malloc(varp->xsz);
#line 790
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 790
+#endif
#line 790
#line 790
@@ -4737,7 +4601,7 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
#line 790
#line 790
- lstatus = ncx_putn_float_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_uchar(&xp, nput, value ,fillp);
#line 790
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 790
@@ -4771,8 +4635,12 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
#line 790
}
#line 790
+#ifdef ERANGE_FILL
+#line 790
free(fillp);
#line 790
+#endif
+#line 790
#line 790
return status;
@@ -4782,9 +4650,9 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 791
-putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
#line 791
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 791
{
#line 791
@@ -4796,7 +4664,7 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 791
void *xp;
#line 791
- void *fillp;
+ void *fillp=NULL;
#line 791
#line 791
@@ -4810,9 +4678,13 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 791
#line 791
+#ifdef ERANGE_FILL
+#line 791
fillp = malloc(varp->xsz);
#line 791
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 791
+#endif
#line 791
#line 791
@@ -4836,7 +4708,7 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 791
#line 791
- lstatus = ncx_putn_float_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_short(&xp, nput, value ,fillp);
#line 791
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 791
@@ -4870,8 +4742,12 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 791
}
#line 791
+#ifdef ERANGE_FILL
+#line 791
free(fillp);
#line 791
+#endif
+#line 791
#line 791
return status;
@@ -4881,9 +4757,9 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 792
-putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
#line 792
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 792
{
#line 792
@@ -4895,7 +4771,7 @@ putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 792
void *xp;
#line 792
- void *fillp;
+ void *fillp=NULL;
#line 792
#line 792
@@ -4909,9 +4785,13 @@ putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 792
#line 792
+#ifdef ERANGE_FILL
+#line 792
fillp = malloc(varp->xsz);
#line 792
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 792
+#endif
#line 792
#line 792
@@ -4935,7 +4815,7 @@ putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 792
#line 792
- lstatus = ncx_putn_float_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_int(&xp, nput, value ,fillp);
#line 792
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 792
@@ -4969,8 +4849,12 @@ putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 792
}
#line 792
+#ifdef ERANGE_FILL
+#line 792
free(fillp);
#line 792
+#endif
+#line 792
#line 792
return status;
@@ -4980,9 +4864,9 @@ putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 793
-putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
#line 793
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 793
{
#line 793
@@ -4994,7 +4878,7 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
#line 793
void *xp;
#line 793
- void *fillp;
+ void *fillp=NULL;
#line 793
#line 793
@@ -5008,9 +4892,13 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
#line 793
#line 793
+#ifdef ERANGE_FILL
+#line 793
fillp = malloc(varp->xsz);
#line 793
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 793
+#endif
#line 793
#line 793
@@ -5034,7 +4922,7 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
#line 793
#line 793
- lstatus = ncx_putn_float_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_float(&xp, nput, value ,fillp);
#line 793
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 793
@@ -5068,8 +4956,12 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
#line 793
}
#line 793
+#ifdef ERANGE_FILL
+#line 793
free(fillp);
#line 793
+#endif
+#line 793
#line 793
return status;
@@ -5079,9 +4971,9 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 794
-putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
#line 794
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 794
{
#line 794
@@ -5093,7 +4985,7 @@ putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 794
void *xp;
#line 794
- void *fillp;
+ void *fillp=NULL;
#line 794
#line 794
@@ -5107,9 +4999,13 @@ putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 794
#line 794
+#ifdef ERANGE_FILL
+#line 794
fillp = malloc(varp->xsz);
#line 794
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 794
+#endif
#line 794
#line 794
@@ -5133,55 +5029,165 @@ putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 794
#line 794
- lstatus = ncx_putn_float_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_double(&xp, nput, value ,fillp);
+#line 794
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 794
+ {
+#line 794
+ /* not fatal to the loop */
+#line 794
+ status = lstatus;
+#line 794
+ }
+#line 794
+
+#line 794
+ (void) ncio_rel(ncp->nciop, offset,
+#line 794
+ RGN_MODIFIED);
+#line 794
+
+#line 794
+ remaining -= extent;
+#line 794
+ if(remaining == 0)
+#line 794
+ break; /* normal loop exit */
+#line 794
+ offset += (off_t)extent;
+#line 794
+ value += nput;
+#line 794
+
+#line 794
+ }
+#line 794
+#ifdef ERANGE_FILL
+#line 794
+ free(fillp);
+#line 794
+#endif
+#line 794
+
#line 794
+ return status;
+#line 794
+}
+#line 794
+
+static int
+#line 795
+putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 795
+ const size_t *start, size_t nelems, const longlong *value)
+#line 795
+{
+#line 795
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 795
+ size_t remaining = varp->xsz * nelems;
+#line 795
+ int status = NC_NOERR;
+#line 795
+ void *xp;
+#line 795
+ void *fillp=NULL;
+#line 795
+
+#line 795
+ if(nelems == 0)
+#line 795
+ return NC_NOERR;
+#line 795
+
+#line 795
+ assert(value != NULL);
+#line 795
+
+#line 795
+#ifdef ERANGE_FILL
+#line 795
+ fillp = malloc(varp->xsz);
+#line 795
+ status = NC3_inq_var_fill(varp, fillp);
+#line 795
+#endif
+#line 795
+
+#line 795
+ for(;;)
+#line 795
+ {
+#line 795
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 795
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 795
+
+#line 795
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 795
+ RGN_WRITE, &xp);
+#line 795
+ if(lstatus != NC_NOERR)
+#line 795
+ return lstatus;
+#line 795
+
+#line 795
+ lstatus = ncx_putn_float_longlong(&xp, nput, value ,fillp);
+#line 795
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 794
+#line 795
{
-#line 794
+#line 795
/* not fatal to the loop */
-#line 794
+#line 795
status = lstatus;
-#line 794
+#line 795
}
-#line 794
+#line 795
-#line 794
+#line 795
(void) ncio_rel(ncp->nciop, offset,
-#line 794
+#line 795
RGN_MODIFIED);
-#line 794
+#line 795
-#line 794
+#line 795
remaining -= extent;
-#line 794
+#line 795
if(remaining == 0)
-#line 794
+#line 795
break; /* normal loop exit */
-#line 794
+#line 795
offset += (off_t)extent;
-#line 794
+#line 795
value += nput;
-#line 794
+#line 795
-#line 794
+#line 795
}
-#line 794
+#line 795
+#ifdef ERANGE_FILL
+#line 795
free(fillp);
-#line 794
+#line 795
+#endif
+#line 795
-#line 794
+#line 795
return status;
-#line 794
+#line 795
}
-#line 794
-
+#line 795
static int
#line 796
-putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 796
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 796
{
#line 796
@@ -5193,7 +5199,7 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
#line 796
void *xp;
#line 796
- void *fillp;
+ void *fillp=NULL;
#line 796
#line 796
@@ -5207,9 +5213,13 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
#line 796
#line 796
+#ifdef ERANGE_FILL
+#line 796
fillp = malloc(varp->xsz);
#line 796
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 796
+#endif
#line 796
#line 796
@@ -5233,7 +5243,7 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
#line 796
#line 796
- lstatus = ncx_putn_double_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_ushort(&xp, nput, value ,fillp);
#line 796
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 796
@@ -5267,8 +5277,12 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
#line 796
}
#line 796
+#ifdef ERANGE_FILL
+#line 796
free(fillp);
#line 796
+#endif
+#line 796
#line 796
return status;
@@ -5278,9 +5292,9 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 797
-putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
#line 797
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 797
{
#line 797
@@ -5292,7 +5306,7 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 797
void *xp;
#line 797
- void *fillp;
+ void *fillp=NULL;
#line 797
#line 797
@@ -5306,9 +5320,13 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 797
#line 797
+#ifdef ERANGE_FILL
+#line 797
fillp = malloc(varp->xsz);
#line 797
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 797
+#endif
#line 797
#line 797
@@ -5332,7 +5350,7 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 797
#line 797
- lstatus = ncx_putn_double_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_uint(&xp, nput, value ,fillp);
#line 797
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 797
@@ -5366,8 +5384,12 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 797
}
#line 797
+#ifdef ERANGE_FILL
+#line 797
free(fillp);
#line 797
+#endif
+#line 797
#line 797
return status;
@@ -5377,9 +5399,9 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 798
-putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 798
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 798
{
#line 798
@@ -5391,7 +5413,7 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
#line 798
void *xp;
#line 798
- void *fillp;
+ void *fillp=NULL;
#line 798
#line 798
@@ -5405,9 +5427,13 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
#line 798
#line 798
+#ifdef ERANGE_FILL
+#line 798
fillp = malloc(varp->xsz);
#line 798
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 798
+#endif
#line 798
#line 798
@@ -5431,7 +5457,7 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
#line 798
#line 798
- lstatus = ncx_putn_double_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_float_ulonglong(&xp, nput, value ,fillp);
#line 798
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 798
@@ -5465,8 +5491,12 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
#line 798
}
#line 798
+#ifdef ERANGE_FILL
+#line 798
free(fillp);
#line 798
+#endif
+#line 798
#line 798
return status;
@@ -5474,110 +5504,12 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 798
-static int
-#line 799
-putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
-#line 799
- const size_t *start, size_t nelems, const int *value)
-#line 799
-{
-#line 799
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 799
- size_t remaining = varp->xsz * nelems;
-#line 799
- int status = NC_NOERR;
-#line 799
- void *xp;
-#line 799
- void *fillp;
-#line 799
-
-#line 799
- if(nelems == 0)
-#line 799
- return NC_NOERR;
-#line 799
-
-#line 799
- assert(value != NULL);
-#line 799
-
-#line 799
- fillp = malloc(varp->xsz);
-#line 799
- status = NC3_inq_var_fill(varp, fillp);
-#line 799
-
-#line 799
- for(;;)
-#line 799
- {
-#line 799
- size_t extent = MIN(remaining, ncp->chunk);
-#line 799
- size_t nput = ncx_howmany(varp->type, extent);
-#line 799
-
-#line 799
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 799
- RGN_WRITE, &xp);
-#line 799
- if(lstatus != NC_NOERR)
-#line 799
- return lstatus;
-#line 799
-
-#line 799
- lstatus = ncx_putn_double_int(&xp, nput, value ,fillp);
-#line 799
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 799
- {
-#line 799
- /* not fatal to the loop */
-#line 799
- status = lstatus;
-#line 799
- }
-#line 799
-
-#line 799
- (void) ncio_rel(ncp->nciop, offset,
-#line 799
- RGN_MODIFIED);
-#line 799
-
-#line 799
- remaining -= extent;
-#line 799
- if(remaining == 0)
-#line 799
- break; /* normal loop exit */
-#line 799
- offset += (off_t)extent;
-#line 799
- value += nput;
-#line 799
-
-#line 799
- }
-#line 799
- free(fillp);
-#line 799
-
-#line 799
- return status;
-#line 799
-}
-#line 799
static int
#line 800
-putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
#line 800
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 800
{
#line 800
@@ -5589,7 +5521,7 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
#line 800
void *xp;
#line 800
- void *fillp;
+ void *fillp=NULL;
#line 800
#line 800
@@ -5603,9 +5535,13 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
#line 800
#line 800
+#ifdef ERANGE_FILL
+#line 800
fillp = malloc(varp->xsz);
#line 800
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 800
+#endif
#line 800
#line 800
@@ -5629,7 +5565,7 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
#line 800
#line 800
- lstatus = ncx_putn_double_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_schar(&xp, nput, value ,fillp);
#line 800
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 800
@@ -5663,8 +5599,12 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
#line 800
}
#line 800
+#ifdef ERANGE_FILL
+#line 800
free(fillp);
#line 800
+#endif
+#line 800
#line 800
return status;
@@ -5674,9 +5614,9 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 801
-putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 801
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 801
{
#line 801
@@ -5688,7 +5628,7 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
#line 801
void *xp;
#line 801
- void *fillp;
+ void *fillp=NULL;
#line 801
#line 801
@@ -5702,9 +5642,13 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
#line 801
#line 801
+#ifdef ERANGE_FILL
+#line 801
fillp = malloc(varp->xsz);
#line 801
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 801
+#endif
#line 801
#line 801
@@ -5728,7 +5672,7 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
#line 801
#line 801
- lstatus = ncx_putn_double_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_uchar(&xp, nput, value ,fillp);
#line 801
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 801
@@ -5762,8 +5706,12 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
#line 801
}
#line 801
+#ifdef ERANGE_FILL
+#line 801
free(fillp);
#line 801
+#endif
+#line 801
#line 801
return status;
@@ -5773,9 +5721,9 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 802
-putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
#line 802
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 802
{
#line 802
@@ -5787,7 +5735,7 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 802
void *xp;
#line 802
- void *fillp;
+ void *fillp=NULL;
#line 802
#line 802
@@ -5801,9 +5749,13 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 802
#line 802
+#ifdef ERANGE_FILL
+#line 802
fillp = malloc(varp->xsz);
#line 802
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 802
+#endif
#line 802
#line 802
@@ -5827,7 +5779,7 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 802
#line 802
- lstatus = ncx_putn_double_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_short(&xp, nput, value ,fillp);
#line 802
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 802
@@ -5861,8 +5813,12 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 802
}
#line 802
+#ifdef ERANGE_FILL
+#line 802
free(fillp);
#line 802
+#endif
+#line 802
#line 802
return status;
@@ -5872,9 +5828,9 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 803
-putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
#line 803
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 803
{
#line 803
@@ -5886,7 +5842,7 @@ putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 803
void *xp;
#line 803
- void *fillp;
+ void *fillp=NULL;
#line 803
#line 803
@@ -5900,9 +5856,13 @@ putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 803
#line 803
+#ifdef ERANGE_FILL
+#line 803
fillp = malloc(varp->xsz);
#line 803
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 803
+#endif
#line 803
#line 803
@@ -5926,7 +5886,7 @@ putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 803
#line 803
- lstatus = ncx_putn_double_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_int(&xp, nput, value ,fillp);
#line 803
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 803
@@ -5960,8 +5920,12 @@ putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 803
}
#line 803
+#ifdef ERANGE_FILL
+#line 803
free(fillp);
#line 803
+#endif
+#line 803
#line 803
return status;
@@ -5971,9 +5935,9 @@ putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 804
-putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
#line 804
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 804
{
#line 804
@@ -5985,7 +5949,7 @@ putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
#line 804
void *xp;
#line 804
- void *fillp;
+ void *fillp=NULL;
#line 804
#line 804
@@ -5999,9 +5963,13 @@ putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
#line 804
#line 804
+#ifdef ERANGE_FILL
+#line 804
fillp = malloc(varp->xsz);
#line 804
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 804
+#endif
#line 804
#line 804
@@ -6025,7 +5993,7 @@ putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
#line 804
#line 804
- lstatus = ncx_putn_double_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_float(&xp, nput, value ,fillp);
#line 804
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 804
@@ -6059,8 +6027,12 @@ putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
#line 804
}
#line 804
+#ifdef ERANGE_FILL
+#line 804
free(fillp);
#line 804
+#endif
+#line 804
#line 804
return status;
@@ -6070,9 +6042,9 @@ putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 805
-putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
#line 805
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 805
{
#line 805
@@ -6084,7 +6056,7 @@ putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 805
void *xp;
#line 805
- void *fillp;
+ void *fillp=NULL;
#line 805
#line 805
@@ -6098,81 +6070,195 @@ putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 805
#line 805
+#ifdef ERANGE_FILL
+#line 805
fillp = malloc(varp->xsz);
#line 805
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 805
+#endif
+#line 805
+
+#line 805
+ for(;;)
+#line 805
+ {
+#line 805
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 805
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 805
+
+#line 805
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 805
+ RGN_WRITE, &xp);
+#line 805
+ if(lstatus != NC_NOERR)
+#line 805
+ return lstatus;
+#line 805
+
+#line 805
+ lstatus = ncx_putn_double_double(&xp, nput, value ,fillp);
+#line 805
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 805
+ {
+#line 805
+ /* not fatal to the loop */
+#line 805
+ status = lstatus;
+#line 805
+ }
+#line 805
+
+#line 805
+ (void) ncio_rel(ncp->nciop, offset,
+#line 805
+ RGN_MODIFIED);
+#line 805
+
+#line 805
+ remaining -= extent;
+#line 805
+ if(remaining == 0)
+#line 805
+ break; /* normal loop exit */
+#line 805
+ offset += (off_t)extent;
+#line 805
+ value += nput;
+#line 805
+
+#line 805
+ }
+#line 805
+#ifdef ERANGE_FILL
+#line 805
+ free(fillp);
+#line 805
+#endif
#line 805
#line 805
+ return status;
+#line 805
+}
+#line 805
+
+static int
+#line 806
+putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 806
+ const size_t *start, size_t nelems, const longlong *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
+ void *xp;
+#line 806
+ void *fillp=NULL;
+#line 806
+
+#line 806
+ if(nelems == 0)
+#line 806
+ return NC_NOERR;
+#line 806
+
+#line 806
+ assert(value != NULL);
+#line 806
+
+#line 806
+#ifdef ERANGE_FILL
+#line 806
+ fillp = malloc(varp->xsz);
+#line 806
+ status = NC3_inq_var_fill(varp, fillp);
+#line 806
+#endif
+#line 806
+
+#line 806
for(;;)
-#line 805
+#line 806
{
-#line 805
+#line 806
size_t extent = MIN(remaining, ncp->chunk);
-#line 805
+#line 806
size_t nput = ncx_howmany(varp->type, extent);
-#line 805
+#line 806
-#line 805
+#line 806
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 805
+#line 806
RGN_WRITE, &xp);
-#line 805
+#line 806
if(lstatus != NC_NOERR)
-#line 805
+#line 806
return lstatus;
-#line 805
+#line 806
-#line 805
- lstatus = ncx_putn_double_ulonglong(&xp, nput, value ,fillp);
-#line 805
+#line 806
+ lstatus = ncx_putn_double_longlong(&xp, nput, value ,fillp);
+#line 806
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 805
+#line 806
{
-#line 805
+#line 806
/* not fatal to the loop */
-#line 805
+#line 806
status = lstatus;
-#line 805
+#line 806
}
-#line 805
+#line 806
-#line 805
+#line 806
(void) ncio_rel(ncp->nciop, offset,
-#line 805
+#line 806
RGN_MODIFIED);
-#line 805
+#line 806
-#line 805
+#line 806
remaining -= extent;
-#line 805
+#line 806
if(remaining == 0)
-#line 805
+#line 806
break; /* normal loop exit */
-#line 805
+#line 806
offset += (off_t)extent;
-#line 805
+#line 806
value += nput;
-#line 805
+#line 806
-#line 805
+#line 806
}
-#line 805
+#line 806
+#ifdef ERANGE_FILL
+#line 806
free(fillp);
-#line 805
+#line 806
+#endif
+#line 806
-#line 805
+#line 806
return status;
-#line 805
+#line 806
}
-#line 805
-
+#line 806
static int
#line 807
-putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 807
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 807
{
#line 807
@@ -6184,7 +6270,7 @@ putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
#line 807
void *xp;
#line 807
- void *fillp;
+ void *fillp=NULL;
#line 807
#line 807
@@ -6198,9 +6284,13 @@ putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
#line 807
#line 807
+#ifdef ERANGE_FILL
+#line 807
fillp = malloc(varp->xsz);
#line 807
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 807
+#endif
#line 807
#line 807
@@ -6224,7 +6314,7 @@ putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
#line 807
#line 807
- lstatus = ncx_putn_uchar_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_ushort(&xp, nput, value ,fillp);
#line 807
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 807
@@ -6258,8 +6348,12 @@ putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
#line 807
}
#line 807
+#ifdef ERANGE_FILL
+#line 807
free(fillp);
#line 807
+#endif
+#line 807
#line 807
return status;
@@ -6269,9 +6363,9 @@ putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 808
-putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
#line 808
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 808
{
#line 808
@@ -6283,7 +6377,7 @@ putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 808
void *xp;
#line 808
- void *fillp;
+ void *fillp=NULL;
#line 808
#line 808
@@ -6297,9 +6391,13 @@ putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 808
#line 808
+#ifdef ERANGE_FILL
+#line 808
fillp = malloc(varp->xsz);
#line 808
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 808
+#endif
#line 808
#line 808
@@ -6323,7 +6421,7 @@ putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 808
#line 808
- lstatus = ncx_putn_uchar_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_uint(&xp, nput, value ,fillp);
#line 808
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 808
@@ -6357,8 +6455,12 @@ putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 808
}
#line 808
+#ifdef ERANGE_FILL
+#line 808
free(fillp);
#line 808
+#endif
+#line 808
#line 808
return status;
@@ -6368,9 +6470,9 @@ putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 809
-putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 809
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 809
{
#line 809
@@ -6382,7 +6484,7 @@ putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
#line 809
void *xp;
#line 809
- void *fillp;
+ void *fillp=NULL;
#line 809
#line 809
@@ -6396,9 +6498,13 @@ putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
#line 809
#line 809
+#ifdef ERANGE_FILL
+#line 809
fillp = malloc(varp->xsz);
#line 809
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 809
+#endif
#line 809
#line 809
@@ -6422,7 +6528,7 @@ putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
#line 809
#line 809
- lstatus = ncx_putn_uchar_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_double_ulonglong(&xp, nput, value ,fillp);
#line 809
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 809
@@ -6456,8 +6562,12 @@ putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
#line 809
}
#line 809
+#ifdef ERANGE_FILL
+#line 809
free(fillp);
#line 809
+#endif
+#line 809
#line 809
return status;
@@ -6465,110 +6575,12 @@ putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 809
-static int
-#line 810
-putNCvx_uchar_int(NC3_INFO* ncp, const NC_var *varp,
-#line 810
- const size_t *start, size_t nelems, const int *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
- void *xp;
-#line 810
- void *fillp;
-#line 810
-
-#line 810
- if(nelems == 0)
-#line 810
- return NC_NOERR;
-#line 810
-
-#line 810
- assert(value != NULL);
-#line 810
-
-#line 810
- fillp = malloc(varp->xsz);
-#line 810
- status = NC3_inq_var_fill(varp, fillp);
-#line 810
-
-#line 810
- for(;;)
-#line 810
- {
-#line 810
- size_t extent = MIN(remaining, ncp->chunk);
-#line 810
- size_t nput = ncx_howmany(varp->type, extent);
-#line 810
-
-#line 810
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 810
- RGN_WRITE, &xp);
-#line 810
- if(lstatus != NC_NOERR)
-#line 810
- return lstatus;
-#line 810
-
-#line 810
- lstatus = ncx_putn_uchar_int(&xp, nput, value ,fillp);
-#line 810
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 810
- {
-#line 810
- /* not fatal to the loop */
-#line 810
- status = lstatus;
-#line 810
- }
-#line 810
-
-#line 810
- (void) ncio_rel(ncp->nciop, offset,
-#line 810
- RGN_MODIFIED);
-#line 810
-
-#line 810
- remaining -= extent;
-#line 810
- if(remaining == 0)
-#line 810
- break; /* normal loop exit */
-#line 810
- offset += (off_t)extent;
-#line 810
- value += nput;
-#line 810
-
-#line 810
- }
-#line 810
- free(fillp);
-#line 810
-
-#line 810
- return status;
-#line 810
-}
-#line 810
static int
#line 811
-putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
#line 811
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 811
{
#line 811
@@ -6580,7 +6592,7 @@ putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
#line 811
void *xp;
#line 811
- void *fillp;
+ void *fillp=NULL;
#line 811
#line 811
@@ -6594,9 +6606,13 @@ putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
#line 811
#line 811
+#ifdef ERANGE_FILL
+#line 811
fillp = malloc(varp->xsz);
#line 811
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 811
+#endif
#line 811
#line 811
@@ -6620,7 +6636,7 @@ putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
#line 811
#line 811
- lstatus = ncx_putn_uchar_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_schar(&xp, nput, value ,fillp);
#line 811
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 811
@@ -6654,8 +6670,12 @@ putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
#line 811
}
#line 811
+#ifdef ERANGE_FILL
+#line 811
free(fillp);
#line 811
+#endif
+#line 811
#line 811
return status;
@@ -6665,9 +6685,9 @@ putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 812
-putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 812
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 812
{
#line 812
@@ -6679,7 +6699,7 @@ putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
#line 812
void *xp;
#line 812
- void *fillp;
+ void *fillp=NULL;
#line 812
#line 812
@@ -6693,9 +6713,13 @@ putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
#line 812
#line 812
+#ifdef ERANGE_FILL
+#line 812
fillp = malloc(varp->xsz);
#line 812
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 812
+#endif
#line 812
#line 812
@@ -6719,7 +6743,7 @@ putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
#line 812
#line 812
- lstatus = ncx_putn_uchar_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_uchar(&xp, nput, value ,fillp);
#line 812
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 812
@@ -6753,8 +6777,12 @@ putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
#line 812
}
#line 812
+#ifdef ERANGE_FILL
+#line 812
free(fillp);
#line 812
+#endif
+#line 812
#line 812
return status;
@@ -6764,9 +6792,9 @@ putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 813
-putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
#line 813
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 813
{
#line 813
@@ -6778,7 +6806,7 @@ putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 813
void *xp;
#line 813
- void *fillp;
+ void *fillp=NULL;
#line 813
#line 813
@@ -6792,9 +6820,13 @@ putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 813
#line 813
+#ifdef ERANGE_FILL
+#line 813
fillp = malloc(varp->xsz);
#line 813
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 813
+#endif
#line 813
#line 813
@@ -6818,7 +6850,7 @@ putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 813
#line 813
- lstatus = ncx_putn_uchar_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_short(&xp, nput, value ,fillp);
#line 813
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 813
@@ -6852,8 +6884,12 @@ putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 813
}
#line 813
+#ifdef ERANGE_FILL
+#line 813
free(fillp);
#line 813
+#endif
+#line 813
#line 813
return status;
@@ -6863,9 +6899,9 @@ putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 814
-putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_int(NC3_INFO* ncp, const NC_var *varp,
#line 814
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 814
{
#line 814
@@ -6877,7 +6913,7 @@ putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 814
void *xp;
#line 814
- void *fillp;
+ void *fillp=NULL;
#line 814
#line 814
@@ -6891,9 +6927,13 @@ putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 814
#line 814
+#ifdef ERANGE_FILL
+#line 814
fillp = malloc(varp->xsz);
#line 814
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 814
+#endif
#line 814
#line 814
@@ -6917,7 +6957,7 @@ putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 814
#line 814
- lstatus = ncx_putn_uchar_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_int(&xp, nput, value ,fillp);
#line 814
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 814
@@ -6951,8 +6991,12 @@ putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 814
}
#line 814
+#ifdef ERANGE_FILL
+#line 814
free(fillp);
#line 814
+#endif
+#line 814
#line 814
return status;
@@ -6962,9 +7006,9 @@ putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 815
-putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
#line 815
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 815
{
#line 815
@@ -6976,7 +7020,7 @@ putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 815
void *xp;
#line 815
- void *fillp;
+ void *fillp=NULL;
#line 815
#line 815
@@ -6990,9 +7034,13 @@ putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 815
#line 815
+#ifdef ERANGE_FILL
+#line 815
fillp = malloc(varp->xsz);
#line 815
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 815
+#endif
#line 815
#line 815
@@ -7016,7 +7064,7 @@ putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 815
#line 815
- lstatus = ncx_putn_uchar_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_float(&xp, nput, value ,fillp);
#line 815
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 815
@@ -7050,8 +7098,12 @@ putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 815
}
#line 815
+#ifdef ERANGE_FILL
+#line 815
free(fillp);
#line 815
+#endif
+#line 815
#line 815
return status;
@@ -7061,9 +7113,9 @@ putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 816
-putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
#line 816
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 816
{
#line 816
@@ -7075,7 +7127,7 @@ putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 816
void *xp;
#line 816
- void *fillp;
+ void *fillp=NULL;
#line 816
#line 816
@@ -7089,9 +7141,13 @@ putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 816
#line 816
+#ifdef ERANGE_FILL
+#line 816
fillp = malloc(varp->xsz);
#line 816
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 816
+#endif
#line 816
#line 816
@@ -7115,7 +7171,7 @@ putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 816
#line 816
- lstatus = ncx_putn_uchar_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_double(&xp, nput, value ,fillp);
#line 816
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 816
@@ -7124,46 +7180,156 @@ putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
/* not fatal to the loop */
#line 816
status = lstatus;
-#line 816
+#line 816
+ }
+#line 816
+
+#line 816
+ (void) ncio_rel(ncp->nciop, offset,
+#line 816
+ RGN_MODIFIED);
+#line 816
+
+#line 816
+ remaining -= extent;
+#line 816
+ if(remaining == 0)
+#line 816
+ break; /* normal loop exit */
+#line 816
+ offset += (off_t)extent;
+#line 816
+ value += nput;
+#line 816
+
+#line 816
+ }
+#line 816
+#ifdef ERANGE_FILL
+#line 816
+ free(fillp);
+#line 816
+#endif
+#line 816
+
+#line 816
+ return status;
+#line 816
+}
+#line 816
+
+static int
+#line 817
+putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 817
+ const size_t *start, size_t nelems, const longlong *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
+ void *xp;
+#line 817
+ void *fillp=NULL;
+#line 817
+
+#line 817
+ if(nelems == 0)
+#line 817
+ return NC_NOERR;
+#line 817
+
+#line 817
+ assert(value != NULL);
+#line 817
+
+#line 817
+#ifdef ERANGE_FILL
+#line 817
+ fillp = malloc(varp->xsz);
+#line 817
+ status = NC3_inq_var_fill(varp, fillp);
+#line 817
+#endif
+#line 817
+
+#line 817
+ for(;;)
+#line 817
+ {
+#line 817
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 817
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 817
+
+#line 817
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 817
+ RGN_WRITE, &xp);
+#line 817
+ if(lstatus != NC_NOERR)
+#line 817
+ return lstatus;
+#line 817
+
+#line 817
+ lstatus = ncx_putn_uchar_longlong(&xp, nput, value ,fillp);
+#line 817
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 817
+ {
+#line 817
+ /* not fatal to the loop */
+#line 817
+ status = lstatus;
+#line 817
}
-#line 816
+#line 817
-#line 816
+#line 817
(void) ncio_rel(ncp->nciop, offset,
-#line 816
+#line 817
RGN_MODIFIED);
-#line 816
+#line 817
-#line 816
+#line 817
remaining -= extent;
-#line 816
+#line 817
if(remaining == 0)
-#line 816
+#line 817
break; /* normal loop exit */
-#line 816
+#line 817
offset += (off_t)extent;
-#line 816
+#line 817
value += nput;
-#line 816
+#line 817
-#line 816
+#line 817
}
-#line 816
+#line 817
+#ifdef ERANGE_FILL
+#line 817
free(fillp);
-#line 816
+#line 817
+#endif
+#line 817
-#line 816
+#line 817
return status;
-#line 816
+#line 817
}
-#line 816
-
+#line 817
static int
#line 818
-putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 818
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 818
{
#line 818
@@ -7175,7 +7341,7 @@ putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
#line 818
void *xp;
#line 818
- void *fillp;
+ void *fillp=NULL;
#line 818
#line 818
@@ -7189,9 +7355,13 @@ putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
#line 818
#line 818
+#ifdef ERANGE_FILL
+#line 818
fillp = malloc(varp->xsz);
#line 818
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 818
+#endif
#line 818
#line 818
@@ -7215,7 +7385,7 @@ putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
#line 818
#line 818
- lstatus = ncx_putn_ushort_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_ushort(&xp, nput, value ,fillp);
#line 818
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 818
@@ -7249,8 +7419,12 @@ putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
#line 818
}
#line 818
+#ifdef ERANGE_FILL
+#line 818
free(fillp);
#line 818
+#endif
+#line 818
#line 818
return status;
@@ -7260,9 +7434,9 @@ putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 819
-putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
#line 819
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 819
{
#line 819
@@ -7274,7 +7448,7 @@ putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 819
void *xp;
#line 819
- void *fillp;
+ void *fillp=NULL;
#line 819
#line 819
@@ -7288,9 +7462,13 @@ putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 819
#line 819
+#ifdef ERANGE_FILL
+#line 819
fillp = malloc(varp->xsz);
#line 819
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 819
+#endif
#line 819
#line 819
@@ -7314,7 +7492,7 @@ putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 819
#line 819
- lstatus = ncx_putn_ushort_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_uint(&xp, nput, value ,fillp);
#line 819
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 819
@@ -7348,8 +7526,12 @@ putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 819
}
#line 819
+#ifdef ERANGE_FILL
+#line 819
free(fillp);
#line 819
+#endif
+#line 819
#line 819
return status;
@@ -7359,9 +7541,9 @@ putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 820
-putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 820
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 820
{
#line 820
@@ -7373,7 +7555,7 @@ putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
#line 820
void *xp;
#line 820
- void *fillp;
+ void *fillp=NULL;
#line 820
#line 820
@@ -7387,9 +7569,13 @@ putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
#line 820
#line 820
+#ifdef ERANGE_FILL
+#line 820
fillp = malloc(varp->xsz);
#line 820
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 820
+#endif
#line 820
#line 820
@@ -7413,7 +7599,7 @@ putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
#line 820
#line 820
- lstatus = ncx_putn_ushort_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uchar_ulonglong(&xp, nput, value ,fillp);
#line 820
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 820
@@ -7447,8 +7633,12 @@ putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
#line 820
}
#line 820
+#ifdef ERANGE_FILL
+#line 820
free(fillp);
#line 820
+#endif
+#line 820
#line 820
return status;
@@ -7456,110 +7646,12 @@ putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 820
-static int
-#line 821
-putNCvx_ushort_int(NC3_INFO* ncp, const NC_var *varp,
-#line 821
- const size_t *start, size_t nelems, const int *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
- void *xp;
-#line 821
- void *fillp;
-#line 821
-
-#line 821
- if(nelems == 0)
-#line 821
- return NC_NOERR;
-#line 821
-
-#line 821
- assert(value != NULL);
-#line 821
-
-#line 821
- fillp = malloc(varp->xsz);
-#line 821
- status = NC3_inq_var_fill(varp, fillp);
-#line 821
-
-#line 821
- for(;;)
-#line 821
- {
-#line 821
- size_t extent = MIN(remaining, ncp->chunk);
-#line 821
- size_t nput = ncx_howmany(varp->type, extent);
-#line 821
-
-#line 821
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 821
- RGN_WRITE, &xp);
-#line 821
- if(lstatus != NC_NOERR)
-#line 821
- return lstatus;
-#line 821
-
-#line 821
- lstatus = ncx_putn_ushort_int(&xp, nput, value ,fillp);
-#line 821
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 821
- {
-#line 821
- /* not fatal to the loop */
-#line 821
- status = lstatus;
-#line 821
- }
-#line 821
-
-#line 821
- (void) ncio_rel(ncp->nciop, offset,
-#line 821
- RGN_MODIFIED);
-#line 821
-
-#line 821
- remaining -= extent;
-#line 821
- if(remaining == 0)
-#line 821
- break; /* normal loop exit */
-#line 821
- offset += (off_t)extent;
-#line 821
- value += nput;
-#line 821
-
-#line 821
- }
-#line 821
- free(fillp);
-#line 821
-
-#line 821
- return status;
-#line 821
-}
-#line 821
static int
#line 822
-putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
#line 822
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 822
{
#line 822
@@ -7571,7 +7663,7 @@ putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
#line 822
void *xp;
#line 822
- void *fillp;
+ void *fillp=NULL;
#line 822
#line 822
@@ -7585,9 +7677,13 @@ putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
#line 822
#line 822
+#ifdef ERANGE_FILL
+#line 822
fillp = malloc(varp->xsz);
#line 822
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 822
+#endif
#line 822
#line 822
@@ -7611,7 +7707,7 @@ putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
#line 822
#line 822
- lstatus = ncx_putn_ushort_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_schar(&xp, nput, value ,fillp);
#line 822
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 822
@@ -7645,8 +7741,12 @@ putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
#line 822
}
#line 822
+#ifdef ERANGE_FILL
+#line 822
free(fillp);
#line 822
+#endif
+#line 822
#line 822
return status;
@@ -7656,9 +7756,9 @@ putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 823
-putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 823
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 823
{
#line 823
@@ -7670,7 +7770,7 @@ putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
#line 823
void *xp;
#line 823
- void *fillp;
+ void *fillp=NULL;
#line 823
#line 823
@@ -7684,9 +7784,13 @@ putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
#line 823
#line 823
+#ifdef ERANGE_FILL
+#line 823
fillp = malloc(varp->xsz);
#line 823
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 823
+#endif
#line 823
#line 823
@@ -7710,7 +7814,7 @@ putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
#line 823
#line 823
- lstatus = ncx_putn_ushort_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_uchar(&xp, nput, value ,fillp);
#line 823
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 823
@@ -7744,8 +7848,12 @@ putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
#line 823
}
#line 823
+#ifdef ERANGE_FILL
+#line 823
free(fillp);
#line 823
+#endif
+#line 823
#line 823
return status;
@@ -7755,9 +7863,9 @@ putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 824
-putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
#line 824
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 824
{
#line 824
@@ -7769,7 +7877,7 @@ putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 824
void *xp;
#line 824
- void *fillp;
+ void *fillp=NULL;
#line 824
#line 824
@@ -7783,9 +7891,13 @@ putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 824
#line 824
+#ifdef ERANGE_FILL
+#line 824
fillp = malloc(varp->xsz);
#line 824
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 824
+#endif
#line 824
#line 824
@@ -7809,7 +7921,7 @@ putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 824
#line 824
- lstatus = ncx_putn_ushort_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_short(&xp, nput, value ,fillp);
#line 824
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 824
@@ -7843,8 +7955,12 @@ putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 824
}
#line 824
+#ifdef ERANGE_FILL
+#line 824
free(fillp);
#line 824
+#endif
+#line 824
#line 824
return status;
@@ -7854,9 +7970,9 @@ putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 825
-putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_int(NC3_INFO* ncp, const NC_var *varp,
#line 825
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 825
{
#line 825
@@ -7868,7 +7984,7 @@ putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 825
void *xp;
#line 825
- void *fillp;
+ void *fillp=NULL;
#line 825
#line 825
@@ -7882,9 +7998,13 @@ putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 825
#line 825
+#ifdef ERANGE_FILL
+#line 825
fillp = malloc(varp->xsz);
#line 825
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 825
+#endif
#line 825
#line 825
@@ -7908,7 +8028,7 @@ putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 825
#line 825
- lstatus = ncx_putn_ushort_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_int(&xp, nput, value ,fillp);
#line 825
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 825
@@ -7942,8 +8062,12 @@ putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 825
}
#line 825
+#ifdef ERANGE_FILL
+#line 825
free(fillp);
#line 825
+#endif
+#line 825
#line 825
return status;
@@ -7953,9 +8077,9 @@ putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 826
-putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
#line 826
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 826
{
#line 826
@@ -7967,7 +8091,7 @@ putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
#line 826
void *xp;
#line 826
- void *fillp;
+ void *fillp=NULL;
#line 826
#line 826
@@ -7981,9 +8105,13 @@ putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
#line 826
#line 826
+#ifdef ERANGE_FILL
+#line 826
fillp = malloc(varp->xsz);
#line 826
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 826
+#endif
#line 826
#line 826
@@ -8007,7 +8135,7 @@ putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
#line 826
#line 826
- lstatus = ncx_putn_ushort_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_float(&xp, nput, value ,fillp);
#line 826
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 826
@@ -8041,8 +8169,12 @@ putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
#line 826
}
#line 826
+#ifdef ERANGE_FILL
+#line 826
free(fillp);
#line 826
+#endif
+#line 826
#line 826
return status;
@@ -8052,9 +8184,9 @@ putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 827
-putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
#line 827
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 827
{
#line 827
@@ -8066,7 +8198,7 @@ putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 827
void *xp;
#line 827
- void *fillp;
+ void *fillp=NULL;
#line 827
#line 827
@@ -8080,9 +8212,13 @@ putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 827
#line 827
+#ifdef ERANGE_FILL
+#line 827
fillp = malloc(varp->xsz);
#line 827
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 827
+#endif
#line 827
#line 827
@@ -8106,7 +8242,7 @@ putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 827
#line 827
- lstatus = ncx_putn_ushort_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_double(&xp, nput, value ,fillp);
#line 827
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 827
@@ -8140,8 +8276,12 @@ putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 827
}
#line 827
+#ifdef ERANGE_FILL
+#line 827
free(fillp);
#line 827
+#endif
+#line 827
#line 827
return status;
@@ -8149,12 +8289,118 @@ putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
}
#line 827
+static int
+#line 828
+putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 828
+ const size_t *start, size_t nelems, const longlong *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
+ void *xp;
+#line 828
+ void *fillp=NULL;
+#line 828
+
+#line 828
+ if(nelems == 0)
+#line 828
+ return NC_NOERR;
+#line 828
+
+#line 828
+ assert(value != NULL);
+#line 828
+
+#line 828
+#ifdef ERANGE_FILL
+#line 828
+ fillp = malloc(varp->xsz);
+#line 828
+ status = NC3_inq_var_fill(varp, fillp);
+#line 828
+#endif
+#line 828
+
+#line 828
+ for(;;)
+#line 828
+ {
+#line 828
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 828
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 828
+
+#line 828
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 828
+ RGN_WRITE, &xp);
+#line 828
+ if(lstatus != NC_NOERR)
+#line 828
+ return lstatus;
+#line 828
+
+#line 828
+ lstatus = ncx_putn_ushort_longlong(&xp, nput, value ,fillp);
+#line 828
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 828
+ {
+#line 828
+ /* not fatal to the loop */
+#line 828
+ status = lstatus;
+#line 828
+ }
+#line 828
+
+#line 828
+ (void) ncio_rel(ncp->nciop, offset,
+#line 828
+ RGN_MODIFIED);
+#line 828
+
+#line 828
+ remaining -= extent;
+#line 828
+ if(remaining == 0)
+#line 828
+ break; /* normal loop exit */
+#line 828
+ offset += (off_t)extent;
+#line 828
+ value += nput;
+#line 828
+
+#line 828
+ }
+#line 828
+#ifdef ERANGE_FILL
+#line 828
+ free(fillp);
+#line 828
+#endif
+#line 828
+
+#line 828
+ return status;
+#line 828
+}
+#line 828
static int
#line 829
-putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 829
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 829
{
#line 829
@@ -8166,7 +8412,7 @@ putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
#line 829
void *xp;
#line 829
- void *fillp;
+ void *fillp=NULL;
#line 829
#line 829
@@ -8180,9 +8426,13 @@ putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
#line 829
#line 829
+#ifdef ERANGE_FILL
+#line 829
fillp = malloc(varp->xsz);
#line 829
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 829
+#endif
#line 829
#line 829
@@ -8206,7 +8456,7 @@ putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
#line 829
#line 829
- lstatus = ncx_putn_uint_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_ushort(&xp, nput, value ,fillp);
#line 829
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 829
@@ -8240,8 +8490,12 @@ putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
#line 829
}
#line 829
+#ifdef ERANGE_FILL
+#line 829
free(fillp);
#line 829
+#endif
+#line 829
#line 829
return status;
@@ -8251,9 +8505,9 @@ putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 830
-putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
#line 830
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 830
{
#line 830
@@ -8265,7 +8519,7 @@ putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 830
void *xp;
#line 830
- void *fillp;
+ void *fillp=NULL;
#line 830
#line 830
@@ -8279,9 +8533,13 @@ putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 830
#line 830
+#ifdef ERANGE_FILL
+#line 830
fillp = malloc(varp->xsz);
#line 830
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 830
+#endif
#line 830
#line 830
@@ -8305,7 +8563,7 @@ putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 830
#line 830
- lstatus = ncx_putn_uint_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_uint(&xp, nput, value ,fillp);
#line 830
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 830
@@ -8339,8 +8597,12 @@ putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 830
}
#line 830
+#ifdef ERANGE_FILL
+#line 830
free(fillp);
#line 830
+#endif
+#line 830
#line 830
return status;
@@ -8350,9 +8612,9 @@ putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 831
-putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 831
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 831
{
#line 831
@@ -8364,7 +8626,7 @@ putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
#line 831
void *xp;
#line 831
- void *fillp;
+ void *fillp=NULL;
#line 831
#line 831
@@ -8378,9 +8640,13 @@ putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
#line 831
#line 831
+#ifdef ERANGE_FILL
+#line 831
fillp = malloc(varp->xsz);
#line 831
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 831
+#endif
#line 831
#line 831
@@ -8404,7 +8670,7 @@ putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
#line 831
#line 831
- lstatus = ncx_putn_uint_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ushort_ulonglong(&xp, nput, value ,fillp);
#line 831
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 831
@@ -8438,8 +8704,12 @@ putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
#line 831
}
#line 831
+#ifdef ERANGE_FILL
+#line 831
free(fillp);
#line 831
+#endif
+#line 831
#line 831
return status;
@@ -8447,110 +8717,12 @@ putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 831
-static int
-#line 832
-putNCvx_uint_int(NC3_INFO* ncp, const NC_var *varp,
-#line 832
- const size_t *start, size_t nelems, const int *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
- void *xp;
-#line 832
- void *fillp;
-#line 832
-
-#line 832
- if(nelems == 0)
-#line 832
- return NC_NOERR;
-#line 832
-
-#line 832
- assert(value != NULL);
-#line 832
-
-#line 832
- fillp = malloc(varp->xsz);
-#line 832
- status = NC3_inq_var_fill(varp, fillp);
-#line 832
-
-#line 832
- for(;;)
-#line 832
- {
-#line 832
- size_t extent = MIN(remaining, ncp->chunk);
-#line 832
- size_t nput = ncx_howmany(varp->type, extent);
-#line 832
-
-#line 832
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 832
- RGN_WRITE, &xp);
-#line 832
- if(lstatus != NC_NOERR)
-#line 832
- return lstatus;
-#line 832
-
-#line 832
- lstatus = ncx_putn_uint_int(&xp, nput, value ,fillp);
-#line 832
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 832
- {
-#line 832
- /* not fatal to the loop */
-#line 832
- status = lstatus;
-#line 832
- }
-#line 832
-
-#line 832
- (void) ncio_rel(ncp->nciop, offset,
-#line 832
- RGN_MODIFIED);
-#line 832
-
-#line 832
- remaining -= extent;
-#line 832
- if(remaining == 0)
-#line 832
- break; /* normal loop exit */
-#line 832
- offset += (off_t)extent;
-#line 832
- value += nput;
-#line 832
-
-#line 832
- }
-#line 832
- free(fillp);
-#line 832
-
-#line 832
- return status;
-#line 832
-}
-#line 832
static int
#line 833
-putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
#line 833
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 833
{
#line 833
@@ -8562,7 +8734,7 @@ putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
#line 833
void *xp;
#line 833
- void *fillp;
+ void *fillp=NULL;
#line 833
#line 833
@@ -8576,9 +8748,13 @@ putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
#line 833
#line 833
+#ifdef ERANGE_FILL
+#line 833
fillp = malloc(varp->xsz);
#line 833
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 833
+#endif
#line 833
#line 833
@@ -8602,7 +8778,7 @@ putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
#line 833
#line 833
- lstatus = ncx_putn_uint_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_schar(&xp, nput, value ,fillp);
#line 833
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 833
@@ -8636,8 +8812,12 @@ putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
#line 833
}
#line 833
+#ifdef ERANGE_FILL
+#line 833
free(fillp);
#line 833
+#endif
+#line 833
#line 833
return status;
@@ -8647,9 +8827,9 @@ putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 834
-putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 834
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 834
{
#line 834
@@ -8661,7 +8841,7 @@ putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
#line 834
void *xp;
#line 834
- void *fillp;
+ void *fillp=NULL;
#line 834
#line 834
@@ -8675,9 +8855,13 @@ putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
#line 834
#line 834
+#ifdef ERANGE_FILL
+#line 834
fillp = malloc(varp->xsz);
#line 834
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 834
+#endif
#line 834
#line 834
@@ -8701,7 +8885,7 @@ putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
#line 834
#line 834
- lstatus = ncx_putn_uint_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_uchar(&xp, nput, value ,fillp);
#line 834
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 834
@@ -8735,8 +8919,12 @@ putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
#line 834
}
#line 834
+#ifdef ERANGE_FILL
+#line 834
free(fillp);
#line 834
+#endif
+#line 834
#line 834
return status;
@@ -8746,9 +8934,9 @@ putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 835
-putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
#line 835
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 835
{
#line 835
@@ -8760,7 +8948,7 @@ putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 835
void *xp;
#line 835
- void *fillp;
+ void *fillp=NULL;
#line 835
#line 835
@@ -8774,9 +8962,13 @@ putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 835
#line 835
+#ifdef ERANGE_FILL
+#line 835
fillp = malloc(varp->xsz);
#line 835
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 835
+#endif
#line 835
#line 835
@@ -8800,7 +8992,7 @@ putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 835
#line 835
- lstatus = ncx_putn_uint_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_short(&xp, nput, value ,fillp);
#line 835
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 835
@@ -8834,8 +9026,12 @@ putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 835
}
#line 835
+#ifdef ERANGE_FILL
+#line 835
free(fillp);
#line 835
+#endif
+#line 835
#line 835
return status;
@@ -8845,9 +9041,9 @@ putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 836
-putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_int(NC3_INFO* ncp, const NC_var *varp,
#line 836
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 836
{
#line 836
@@ -8859,7 +9055,7 @@ putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 836
void *xp;
#line 836
- void *fillp;
+ void *fillp=NULL;
#line 836
#line 836
@@ -8873,9 +9069,13 @@ putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 836
#line 836
+#ifdef ERANGE_FILL
+#line 836
fillp = malloc(varp->xsz);
#line 836
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 836
+#endif
#line 836
#line 836
@@ -8899,7 +9099,7 @@ putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 836
#line 836
- lstatus = ncx_putn_uint_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_int(&xp, nput, value ,fillp);
#line 836
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 836
@@ -8933,8 +9133,12 @@ putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 836
}
#line 836
+#ifdef ERANGE_FILL
+#line 836
free(fillp);
#line 836
+#endif
+#line 836
#line 836
return status;
@@ -8944,9 +9148,9 @@ putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 837
-putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
#line 837
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 837
{
#line 837
@@ -8958,7 +9162,7 @@ putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
#line 837
void *xp;
#line 837
- void *fillp;
+ void *fillp=NULL;
#line 837
#line 837
@@ -8972,9 +9176,13 @@ putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
#line 837
#line 837
+#ifdef ERANGE_FILL
+#line 837
fillp = malloc(varp->xsz);
#line 837
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 837
+#endif
#line 837
#line 837
@@ -8998,7 +9206,7 @@ putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
#line 837
#line 837
- lstatus = ncx_putn_uint_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_float(&xp, nput, value ,fillp);
#line 837
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 837
@@ -9032,8 +9240,12 @@ putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
#line 837
}
#line 837
+#ifdef ERANGE_FILL
+#line 837
free(fillp);
#line 837
+#endif
+#line 837
#line 837
return status;
@@ -9043,9 +9255,9 @@ putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 838
-putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
#line 838
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 838
{
#line 838
@@ -9057,7 +9269,7 @@ putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 838
void *xp;
#line 838
- void *fillp;
+ void *fillp=NULL;
#line 838
#line 838
@@ -9071,9 +9283,13 @@ putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 838
#line 838
+#ifdef ERANGE_FILL
+#line 838
fillp = malloc(varp->xsz);
#line 838
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 838
+#endif
#line 838
#line 838
@@ -9097,7 +9313,7 @@ putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 838
#line 838
- lstatus = ncx_putn_uint_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_double(&xp, nput, value ,fillp);
#line 838
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 838
@@ -9131,8 +9347,12 @@ putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 838
}
#line 838
+#ifdef ERANGE_FILL
+#line 838
free(fillp);
#line 838
+#endif
+#line 838
#line 838
return status;
@@ -9140,12 +9360,118 @@ putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
}
#line 838
+static int
+#line 839
+putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 839
+ const size_t *start, size_t nelems, const longlong *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
+ void *xp;
+#line 839
+ void *fillp=NULL;
+#line 839
+
+#line 839
+ if(nelems == 0)
+#line 839
+ return NC_NOERR;
+#line 839
+
+#line 839
+ assert(value != NULL);
+#line 839
+
+#line 839
+#ifdef ERANGE_FILL
+#line 839
+ fillp = malloc(varp->xsz);
+#line 839
+ status = NC3_inq_var_fill(varp, fillp);
+#line 839
+#endif
+#line 839
+
+#line 839
+ for(;;)
+#line 839
+ {
+#line 839
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 839
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 839
+
+#line 839
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 839
+ RGN_WRITE, &xp);
+#line 839
+ if(lstatus != NC_NOERR)
+#line 839
+ return lstatus;
+#line 839
+
+#line 839
+ lstatus = ncx_putn_uint_longlong(&xp, nput, value ,fillp);
+#line 839
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 839
+ {
+#line 839
+ /* not fatal to the loop */
+#line 839
+ status = lstatus;
+#line 839
+ }
+#line 839
+
+#line 839
+ (void) ncio_rel(ncp->nciop, offset,
+#line 839
+ RGN_MODIFIED);
+#line 839
+
+#line 839
+ remaining -= extent;
+#line 839
+ if(remaining == 0)
+#line 839
+ break; /* normal loop exit */
+#line 839
+ offset += (off_t)extent;
+#line 839
+ value += nput;
+#line 839
+
+#line 839
+ }
+#line 839
+#ifdef ERANGE_FILL
+#line 839
+ free(fillp);
+#line 839
+#endif
+#line 839
+
+#line 839
+ return status;
+#line 839
+}
+#line 839
static int
#line 840
-putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 840
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 840
{
#line 840
@@ -9157,7 +9483,7 @@ putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 840
void *xp;
#line 840
- void *fillp;
+ void *fillp=NULL;
#line 840
#line 840
@@ -9171,9 +9497,13 @@ putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 840
#line 840
+#ifdef ERANGE_FILL
+#line 840
fillp = malloc(varp->xsz);
#line 840
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 840
+#endif
#line 840
#line 840
@@ -9197,7 +9527,7 @@ putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 840
#line 840
- lstatus = ncx_putn_longlong_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_ushort(&xp, nput, value ,fillp);
#line 840
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 840
@@ -9231,8 +9561,12 @@ putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 840
}
#line 840
+#ifdef ERANGE_FILL
+#line 840
free(fillp);
#line 840
+#endif
+#line 840
#line 840
return status;
@@ -9242,9 +9576,9 @@ putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 841
-putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
#line 841
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 841
{
#line 841
@@ -9256,7 +9590,7 @@ putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 841
void *xp;
#line 841
- void *fillp;
+ void *fillp=NULL;
#line 841
#line 841
@@ -9270,9 +9604,13 @@ putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 841
#line 841
+#ifdef ERANGE_FILL
+#line 841
fillp = malloc(varp->xsz);
#line 841
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 841
+#endif
#line 841
#line 841
@@ -9296,7 +9634,7 @@ putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 841
#line 841
- lstatus = ncx_putn_longlong_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_uint(&xp, nput, value ,fillp);
#line 841
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 841
@@ -9330,8 +9668,12 @@ putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 841
}
#line 841
+#ifdef ERANGE_FILL
+#line 841
free(fillp);
#line 841
+#endif
+#line 841
#line 841
return status;
@@ -9341,9 +9683,9 @@ putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 842
-putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 842
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 842
{
#line 842
@@ -9355,7 +9697,7 @@ putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
#line 842
void *xp;
#line 842
- void *fillp;
+ void *fillp=NULL;
#line 842
#line 842
@@ -9369,9 +9711,13 @@ putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
#line 842
#line 842
+#ifdef ERANGE_FILL
+#line 842
fillp = malloc(varp->xsz);
#line 842
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 842
+#endif
#line 842
#line 842
@@ -9395,7 +9741,7 @@ putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
#line 842
#line 842
- lstatus = ncx_putn_longlong_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_uint_ulonglong(&xp, nput, value ,fillp);
#line 842
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 842
@@ -9429,119 +9775,25 @@ putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
#line 842
}
#line 842
+#ifdef ERANGE_FILL
+#line 842
free(fillp);
#line 842
+#endif
+#line 842
#line 842
return status;
#line 842
}
-#line 842
-
-static int
-#line 843
-putNCvx_longlong_int(NC3_INFO* ncp, const NC_var *varp,
-#line 843
- const size_t *start, size_t nelems, const int *value)
-#line 843
-{
-#line 843
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 843
- size_t remaining = varp->xsz * nelems;
-#line 843
- int status = NC_NOERR;
-#line 843
- void *xp;
-#line 843
- void *fillp;
-#line 843
-
-#line 843
- if(nelems == 0)
-#line 843
- return NC_NOERR;
-#line 843
-
-#line 843
- assert(value != NULL);
-#line 843
-
-#line 843
- fillp = malloc(varp->xsz);
-#line 843
- status = NC3_inq_var_fill(varp, fillp);
-#line 843
-
-#line 843
- for(;;)
-#line 843
- {
-#line 843
- size_t extent = MIN(remaining, ncp->chunk);
-#line 843
- size_t nput = ncx_howmany(varp->type, extent);
-#line 843
-
-#line 843
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 843
- RGN_WRITE, &xp);
-#line 843
- if(lstatus != NC_NOERR)
-#line 843
- return lstatus;
-#line 843
-
-#line 843
- lstatus = ncx_putn_longlong_int(&xp, nput, value ,fillp);
-#line 843
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 843
- {
-#line 843
- /* not fatal to the loop */
-#line 843
- status = lstatus;
-#line 843
- }
-#line 843
-
-#line 843
- (void) ncio_rel(ncp->nciop, offset,
-#line 843
- RGN_MODIFIED);
-#line 843
-
-#line 843
- remaining -= extent;
-#line 843
- if(remaining == 0)
-#line 843
- break; /* normal loop exit */
-#line 843
- offset += (off_t)extent;
-#line 843
- value += nput;
-#line 843
-
-#line 843
- }
-#line 843
- free(fillp);
-#line 843
-
-#line 843
- return status;
-#line 843
-}
-#line 843
+#line 842
+
static int
#line 844
-putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 844
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 844
{
#line 844
@@ -9553,7 +9805,7 @@ putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
#line 844
void *xp;
#line 844
- void *fillp;
+ void *fillp=NULL;
#line 844
#line 844
@@ -9567,9 +9819,13 @@ putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
#line 844
#line 844
+#ifdef ERANGE_FILL
+#line 844
fillp = malloc(varp->xsz);
#line 844
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 844
+#endif
#line 844
#line 844
@@ -9593,7 +9849,7 @@ putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
#line 844
#line 844
- lstatus = ncx_putn_longlong_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_schar(&xp, nput, value ,fillp);
#line 844
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 844
@@ -9627,8 +9883,12 @@ putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
#line 844
}
#line 844
+#ifdef ERANGE_FILL
+#line 844
free(fillp);
#line 844
+#endif
+#line 844
#line 844
return status;
@@ -9638,9 +9898,9 @@ putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 845
-putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 845
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 845
{
#line 845
@@ -9652,7 +9912,7 @@ putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
#line 845
void *xp;
#line 845
- void *fillp;
+ void *fillp=NULL;
#line 845
#line 845
@@ -9666,9 +9926,13 @@ putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
#line 845
#line 845
+#ifdef ERANGE_FILL
+#line 845
fillp = malloc(varp->xsz);
#line 845
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 845
+#endif
#line 845
#line 845
@@ -9692,7 +9956,7 @@ putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
#line 845
#line 845
- lstatus = ncx_putn_longlong_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_uchar(&xp, nput, value ,fillp);
#line 845
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 845
@@ -9726,8 +9990,12 @@ putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
#line 845
}
#line 845
+#ifdef ERANGE_FILL
+#line 845
free(fillp);
#line 845
+#endif
+#line 845
#line 845
return status;
@@ -9737,9 +10005,9 @@ putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 846
-putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
#line 846
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 846
{
#line 846
@@ -9751,7 +10019,7 @@ putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 846
void *xp;
#line 846
- void *fillp;
+ void *fillp=NULL;
#line 846
#line 846
@@ -9765,9 +10033,13 @@ putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 846
#line 846
+#ifdef ERANGE_FILL
+#line 846
fillp = malloc(varp->xsz);
#line 846
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 846
+#endif
#line 846
#line 846
@@ -9791,7 +10063,7 @@ putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 846
#line 846
- lstatus = ncx_putn_longlong_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_short(&xp, nput, value ,fillp);
#line 846
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 846
@@ -9825,8 +10097,12 @@ putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 846
}
#line 846
+#ifdef ERANGE_FILL
+#line 846
free(fillp);
#line 846
+#endif
+#line 846
#line 846
return status;
@@ -9836,9 +10112,9 @@ putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 847
-putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_int(NC3_INFO* ncp, const NC_var *varp,
#line 847
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 847
{
#line 847
@@ -9850,7 +10126,7 @@ putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 847
void *xp;
#line 847
- void *fillp;
+ void *fillp=NULL;
#line 847
#line 847
@@ -9864,9 +10140,13 @@ putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 847
#line 847
+#ifdef ERANGE_FILL
+#line 847
fillp = malloc(varp->xsz);
#line 847
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 847
+#endif
#line 847
#line 847
@@ -9890,7 +10170,7 @@ putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 847
#line 847
- lstatus = ncx_putn_longlong_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_int(&xp, nput, value ,fillp);
#line 847
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 847
@@ -9924,8 +10204,12 @@ putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 847
}
#line 847
+#ifdef ERANGE_FILL
+#line 847
free(fillp);
#line 847
+#endif
+#line 847
#line 847
return status;
@@ -9935,9 +10219,9 @@ putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 848
-putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
#line 848
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 848
{
#line 848
@@ -9949,7 +10233,7 @@ putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 848
void *xp;
#line 848
- void *fillp;
+ void *fillp=NULL;
#line 848
#line 848
@@ -9963,9 +10247,13 @@ putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 848
#line 848
+#ifdef ERANGE_FILL
+#line 848
fillp = malloc(varp->xsz);
#line 848
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 848
+#endif
#line 848
#line 848
@@ -9989,7 +10277,7 @@ putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 848
#line 848
- lstatus = ncx_putn_longlong_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_float(&xp, nput, value ,fillp);
#line 848
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 848
@@ -10023,8 +10311,12 @@ putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 848
}
#line 848
+#ifdef ERANGE_FILL
+#line 848
free(fillp);
#line 848
+#endif
+#line 848
#line 848
return status;
@@ -10034,9 +10326,9 @@ putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 849
-putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
#line 849
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 849
{
#line 849
@@ -10048,7 +10340,7 @@ putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 849
void *xp;
#line 849
- void *fillp;
+ void *fillp=NULL;
#line 849
#line 849
@@ -10062,9 +10354,13 @@ putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 849
#line 849
+#ifdef ERANGE_FILL
+#line 849
fillp = malloc(varp->xsz);
#line 849
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 849
+#endif
#line 849
#line 849
@@ -10088,7 +10384,7 @@ putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 849
#line 849
- lstatus = ncx_putn_longlong_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_double(&xp, nput, value ,fillp);
#line 849
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 849
@@ -10122,8 +10418,12 @@ putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 849
}
#line 849
+#ifdef ERANGE_FILL
+#line 849
free(fillp);
#line 849
+#endif
+#line 849
#line 849
return status;
@@ -10131,12 +10431,118 @@ putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
}
#line 849
+static int
+#line 850
+putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 850
+ const size_t *start, size_t nelems, const 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
+ void *xp;
+#line 850
+ void *fillp=NULL;
+#line 850
+
+#line 850
+ if(nelems == 0)
+#line 850
+ return NC_NOERR;
+#line 850
+
+#line 850
+ assert(value != NULL);
+#line 850
+
+#line 850
+#ifdef ERANGE_FILL
+#line 850
+ fillp = malloc(varp->xsz);
+#line 850
+ status = NC3_inq_var_fill(varp, fillp);
+#line 850
+#endif
+#line 850
+
+#line 850
+ for(;;)
+#line 850
+ {
+#line 850
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 850
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 850
+
+#line 850
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 850
+ RGN_WRITE, &xp);
+#line 850
+ if(lstatus != NC_NOERR)
+#line 850
+ return lstatus;
+#line 850
+
+#line 850
+ lstatus = ncx_putn_longlong_longlong(&xp, nput, value ,fillp);
+#line 850
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 850
+ {
+#line 850
+ /* not fatal to the loop */
+#line 850
+ status = lstatus;
+#line 850
+ }
+#line 850
+
+#line 850
+ (void) ncio_rel(ncp->nciop, offset,
+#line 850
+ RGN_MODIFIED);
+#line 850
+
+#line 850
+ remaining -= extent;
+#line 850
+ if(remaining == 0)
+#line 850
+ break; /* normal loop exit */
+#line 850
+ offset += (off_t)extent;
+#line 850
+ value += nput;
+#line 850
+
+#line 850
+ }
+#line 850
+#ifdef ERANGE_FILL
+#line 850
+ free(fillp);
+#line 850
+#endif
+#line 850
+
+#line 850
+ return status;
+#line 850
+}
+#line 850
static int
#line 851
-putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 851
- const size_t *start, size_t nelems, const schar *value)
+ const size_t *start, size_t nelems, const ushort *value)
#line 851
{
#line 851
@@ -10148,7 +10554,7 @@ putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 851
void *xp;
#line 851
- void *fillp;
+ void *fillp=NULL;
#line 851
#line 851
@@ -10162,9 +10568,13 @@ putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 851
#line 851
+#ifdef ERANGE_FILL
+#line 851
fillp = malloc(varp->xsz);
#line 851
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 851
+#endif
#line 851
#line 851
@@ -10188,7 +10598,7 @@ putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 851
#line 851
- lstatus = ncx_putn_ulonglong_schar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_ushort(&xp, nput, value ,fillp);
#line 851
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 851
@@ -10222,8 +10632,12 @@ putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 851
}
#line 851
+#ifdef ERANGE_FILL
+#line 851
free(fillp);
#line 851
+#endif
+#line 851
#line 851
return status;
@@ -10233,9 +10647,9 @@ putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 852
-putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 852
- const size_t *start, size_t nelems, const uchar *value)
+ const size_t *start, size_t nelems, const uint *value)
#line 852
{
#line 852
@@ -10247,7 +10661,7 @@ putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 852
void *xp;
#line 852
- void *fillp;
+ void *fillp=NULL;
#line 852
#line 852
@@ -10261,9 +10675,13 @@ putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 852
#line 852
+#ifdef ERANGE_FILL
+#line 852
fillp = malloc(varp->xsz);
#line 852
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 852
+#endif
#line 852
#line 852
@@ -10287,7 +10705,7 @@ putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 852
#line 852
- lstatus = ncx_putn_ulonglong_uchar(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_uint(&xp, nput, value ,fillp);
#line 852
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 852
@@ -10321,8 +10739,12 @@ putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 852
}
#line 852
+#ifdef ERANGE_FILL
+#line 852
free(fillp);
#line 852
+#endif
+#line 852
#line 852
return status;
@@ -10332,9 +10754,9 @@ putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
static int
#line 853
-putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 853
- const size_t *start, size_t nelems, const short *value)
+ const size_t *start, size_t nelems, const ulonglong *value)
#line 853
{
#line 853
@@ -10346,7 +10768,7 @@ putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
#line 853
void *xp;
#line 853
- void *fillp;
+ void *fillp=NULL;
#line 853
#line 853
@@ -10360,9 +10782,13 @@ putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
#line 853
#line 853
+#ifdef ERANGE_FILL
+#line 853
fillp = malloc(varp->xsz);
#line 853
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 853
+#endif
#line 853
#line 853
@@ -10386,7 +10812,7 @@ putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
#line 853
#line 853
- lstatus = ncx_putn_ulonglong_short(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_longlong_ulonglong(&xp, nput, value ,fillp);
#line 853
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 853
@@ -10420,8 +10846,12 @@ putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
#line 853
}
#line 853
+#ifdef ERANGE_FILL
+#line 853
free(fillp);
#line 853
+#endif
+#line 853
#line 853
return status;
@@ -10429,110 +10859,12 @@ putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
}
#line 853
-static int
-#line 854
-putNCvx_ulonglong_int(NC3_INFO* ncp, const NC_var *varp,
-#line 854
- const size_t *start, size_t nelems, const int *value)
-#line 854
-{
-#line 854
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 854
- size_t remaining = varp->xsz * nelems;
-#line 854
- int status = NC_NOERR;
-#line 854
- void *xp;
-#line 854
- void *fillp;
-#line 854
-
-#line 854
- if(nelems == 0)
-#line 854
- return NC_NOERR;
-#line 854
-
-#line 854
- assert(value != NULL);
-#line 854
-
-#line 854
- fillp = malloc(varp->xsz);
-#line 854
- status = NC3_inq_var_fill(varp, fillp);
-#line 854
-
-#line 854
- for(;;)
-#line 854
- {
-#line 854
- size_t extent = MIN(remaining, ncp->chunk);
-#line 854
- size_t nput = ncx_howmany(varp->type, extent);
-#line 854
-
-#line 854
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 854
- RGN_WRITE, &xp);
-#line 854
- if(lstatus != NC_NOERR)
-#line 854
- return lstatus;
-#line 854
-
-#line 854
- lstatus = ncx_putn_ulonglong_int(&xp, nput, value ,fillp);
-#line 854
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 854
- {
-#line 854
- /* not fatal to the loop */
-#line 854
- status = lstatus;
-#line 854
- }
-#line 854
-
-#line 854
- (void) ncio_rel(ncp->nciop, offset,
-#line 854
- RGN_MODIFIED);
-#line 854
-
-#line 854
- remaining -= extent;
-#line 854
- if(remaining == 0)
-#line 854
- break; /* normal loop exit */
-#line 854
- offset += (off_t)extent;
-#line 854
- value += nput;
-#line 854
-
-#line 854
- }
-#line 854
- free(fillp);
-#line 854
-
-#line 854
- return status;
-#line 854
-}
-#line 854
static int
#line 855
-putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
#line 855
- const size_t *start, size_t nelems, const float *value)
+ const size_t *start, size_t nelems, const schar *value)
#line 855
{
#line 855
@@ -10544,7 +10876,7 @@ putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
#line 855
void *xp;
#line 855
- void *fillp;
+ void *fillp=NULL;
#line 855
#line 855
@@ -10558,9 +10890,13 @@ putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
#line 855
#line 855
+#ifdef ERANGE_FILL
+#line 855
fillp = malloc(varp->xsz);
#line 855
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 855
+#endif
#line 855
#line 855
@@ -10584,7 +10920,7 @@ putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
#line 855
#line 855
- lstatus = ncx_putn_ulonglong_float(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ulonglong_schar(&xp, nput, value ,fillp);
#line 855
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 855
@@ -10618,8 +10954,12 @@ putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
#line 855
}
#line 855
+#ifdef ERANGE_FILL
+#line 855
free(fillp);
#line 855
+#endif
+#line 855
#line 855
return status;
@@ -10629,9 +10969,9 @@ putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
static int
#line 856
-putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
#line 856
- const size_t *start, size_t nelems, const double *value)
+ const size_t *start, size_t nelems, const uchar *value)
#line 856
{
#line 856
@@ -10643,7 +10983,7 @@ putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
#line 856
void *xp;
#line 856
- void *fillp;
+ void *fillp=NULL;
#line 856
#line 856
@@ -10657,9 +10997,13 @@ putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
#line 856
#line 856
+#ifdef ERANGE_FILL
+#line 856
fillp = malloc(varp->xsz);
#line 856
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 856
+#endif
#line 856
#line 856
@@ -10683,7 +11027,7 @@ putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
#line 856
#line 856
- lstatus = ncx_putn_ulonglong_double(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ulonglong_uchar(&xp, nput, value ,fillp);
#line 856
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 856
@@ -10717,8 +11061,12 @@ putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
#line 856
}
#line 856
+#ifdef ERANGE_FILL
+#line 856
free(fillp);
#line 856
+#endif
+#line 856
#line 856
return status;
@@ -10728,9 +11076,9 @@ putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
static int
#line 857
-putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
#line 857
- const size_t *start, size_t nelems, const longlong *value)
+ const size_t *start, size_t nelems, const short *value)
#line 857
{
#line 857
@@ -10742,7 +11090,7 @@ putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 857
void *xp;
#line 857
- void *fillp;
+ void *fillp=NULL;
#line 857
#line 857
@@ -10756,9 +11104,13 @@ putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 857
#line 857
+#ifdef ERANGE_FILL
+#line 857
fillp = malloc(varp->xsz);
#line 857
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 857
+#endif
#line 857
#line 857
@@ -10782,7 +11134,7 @@ putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 857
#line 857
- lstatus = ncx_putn_ulonglong_longlong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ulonglong_short(&xp, nput, value ,fillp);
#line 857
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 857
@@ -10816,8 +11168,12 @@ putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
#line 857
}
#line 857
+#ifdef ERANGE_FILL
+#line 857
free(fillp);
#line 857
+#endif
+#line 857
#line 857
return status;
@@ -10827,9 +11183,9 @@ putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
static int
#line 858
-putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ulonglong_int(NC3_INFO* ncp, const NC_var *varp,
#line 858
- const size_t *start, size_t nelems, const ushort *value)
+ const size_t *start, size_t nelems, const int *value)
#line 858
{
#line 858
@@ -10841,7 +11197,7 @@ putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 858
void *xp;
#line 858
- void *fillp;
+ void *fillp=NULL;
#line 858
#line 858
@@ -10855,9 +11211,13 @@ putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 858
#line 858
+#ifdef ERANGE_FILL
+#line 858
fillp = malloc(varp->xsz);
#line 858
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 858
+#endif
#line 858
#line 858
@@ -10881,7 +11241,7 @@ putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 858
#line 858
- lstatus = ncx_putn_ulonglong_ushort(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ulonglong_int(&xp, nput, value ,fillp);
#line 858
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 858
@@ -10915,8 +11275,12 @@ putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
#line 858
}
#line 858
+#ifdef ERANGE_FILL
+#line 858
free(fillp);
#line 858
+#endif
+#line 858
#line 858
return status;
@@ -10926,9 +11290,9 @@ putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
static int
#line 859
-putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
#line 859
- const size_t *start, size_t nelems, const uint *value)
+ const size_t *start, size_t nelems, const float *value)
#line 859
{
#line 859
@@ -10940,7 +11304,7 @@ putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 859
void *xp;
#line 859
- void *fillp;
+ void *fillp=NULL;
#line 859
#line 859
@@ -10954,9 +11318,13 @@ putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 859
#line 859
+#ifdef ERANGE_FILL
+#line 859
fillp = malloc(varp->xsz);
#line 859
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 859
+#endif
#line 859
#line 859
@@ -10980,7 +11348,7 @@ putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 859
#line 859
- lstatus = ncx_putn_ulonglong_uint(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ulonglong_float(&xp, nput, value ,fillp);
#line 859
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 859
@@ -11014,8 +11382,12 @@ putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
#line 859
}
#line 859
+#ifdef ERANGE_FILL
+#line 859
free(fillp);
#line 859
+#endif
+#line 859
#line 859
return status;
@@ -11025,9 +11397,9 @@ putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
static int
#line 860
-putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
#line 860
- const size_t *start, size_t nelems, const ulonglong *value)
+ const size_t *start, size_t nelems, const double *value)
#line 860
{
#line 860
@@ -11039,7 +11411,7 @@ putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 860
void *xp;
#line 860
- void *fillp;
+ void *fillp=NULL;
#line 860
#line 860
@@ -11053,9 +11425,13 @@ putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 860
#line 860
+#ifdef ERANGE_FILL
+#line 860
fillp = malloc(varp->xsz);
#line 860
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#line 860
+#endif
#line 860
#line 860
@@ -11079,7 +11455,7 @@ putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 860
#line 860
- lstatus = ncx_putn_ulonglong_ulonglong(&xp, nput, value ,fillp);
+ lstatus = ncx_putn_ulonglong_double(&xp, nput, value ,fillp);
#line 860
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 860
@@ -11113,8 +11489,12 @@ putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
#line 860
}
#line 860
+#ifdef ERANGE_FILL
+#line 860
free(fillp);
#line 860
+#endif
+#line 860
#line 860
return status;
@@ -11122,252 +11502,442 @@ putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
}
#line 860
+static int
+#line 861
+putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
+#line 861
+ const size_t *start, size_t nelems, const longlong *value)
+#line 861
+{
+#line 861
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 861
+ size_t remaining = varp->xsz * nelems;
+#line 861
+ int status = NC_NOERR;
+#line 861
+ void *xp;
+#line 861
+ void *fillp=NULL;
+#line 861
+
+#line 861
+ if(nelems == 0)
+#line 861
+ return NC_NOERR;
+#line 861
+
+#line 861
+ assert(value != NULL);
+#line 861
+
+#line 861
+#ifdef ERANGE_FILL
+#line 861
+ fillp = malloc(varp->xsz);
+#line 861
+ status = NC3_inq_var_fill(varp, fillp);
+#line 861
+#endif
+#line 861
+
+#line 861
+ for(;;)
+#line 861
+ {
+#line 861
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 861
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 861
+
+#line 861
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 861
+ RGN_WRITE, &xp);
+#line 861
+ if(lstatus != NC_NOERR)
+#line 861
+ return lstatus;
+#line 861
+
+#line 861
+ lstatus = ncx_putn_ulonglong_longlong(&xp, nput, value ,fillp);
+#line 861
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 861
+ {
+#line 861
+ /* not fatal to the loop */
+#line 861
+ status = lstatus;
+#line 861
+ }
+#line 861
+
+#line 861
+ (void) ncio_rel(ncp->nciop, offset,
+#line 861
+ RGN_MODIFIED);
+#line 861
+
+#line 861
+ remaining -= extent;
+#line 861
+ if(remaining == 0)
+#line 861
+ break; /* normal loop exit */
+#line 861
+ offset += (off_t)extent;
+#line 861
+ value += nput;
+#line 861
+
+#line 861
+ }
+#line 861
+#ifdef ERANGE_FILL
+#line 861
+ free(fillp);
+#line 861
+#endif
+#line 861
-#line 907
+#line 861
+ return status;
+#line 861
+}
+#line 861
static int
-#line 908
-getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
-#line 908
- const size_t *start, size_t nelems, char *value)
-#line 908
+#line 862
+putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
+#line 862
+ const size_t *start, size_t nelems, const ushort *value)
+#line 862
{
-#line 908
+#line 862
off_t offset = NC_varoffset(ncp, varp, start);
-#line 908
+#line 862
size_t remaining = varp->xsz * nelems;
-#line 908
+#line 862
int status = NC_NOERR;
-#line 908
- const void *xp;
-#line 908
+#line 862
+ void *xp;
+#line 862
+ void *fillp=NULL;
+#line 862
-#line 908
+#line 862
if(nelems == 0)
-#line 908
+#line 862
return NC_NOERR;
-#line 908
+#line 862
-#line 908
+#line 862
assert(value != NULL);
-#line 908
+#line 862
-#line 908
+#line 862
+#ifdef ERANGE_FILL
+#line 862
+ fillp = malloc(varp->xsz);
+#line 862
+ status = NC3_inq_var_fill(varp, fillp);
+#line 862
+#endif
+#line 862
+
+#line 862
for(;;)
-#line 908
+#line 862
{
-#line 908
+#line 862
size_t extent = MIN(remaining, ncp->chunk);
-#line 908
- size_t nget = ncx_howmany(varp->type, extent);
-#line 908
+#line 862
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 862
-#line 908
+#line 862
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 908
- 0, (void **)&xp); /* cast away const */
-#line 908
+#line 862
+ RGN_WRITE, &xp);
+#line 862
if(lstatus != NC_NOERR)
-#line 908
+#line 862
return lstatus;
-#line 908
+#line 862
-#line 908
- lstatus = ncx_getn_char_char(&xp, nget, value);
-#line 908
+#line 862
+ lstatus = ncx_putn_ulonglong_ushort(&xp, nput, value ,fillp);
+#line 862
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 908
+#line 862
+ {
+#line 862
+ /* not fatal to the loop */
+#line 862
status = lstatus;
-#line 908
+#line 862
+ }
+#line 862
-#line 908
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 908
+#line 862
+ (void) ncio_rel(ncp->nciop, offset,
+#line 862
+ RGN_MODIFIED);
+#line 862
-#line 908
+#line 862
remaining -= extent;
-#line 908
+#line 862
if(remaining == 0)
-#line 908
+#line 862
break; /* normal loop exit */
-#line 908
+#line 862
offset += (off_t)extent;
-#line 908
- value += nget;
-#line 908
+#line 862
+ value += nput;
+#line 862
+
+#line 862
}
-#line 908
+#line 862
+#ifdef ERANGE_FILL
+#line 862
+ free(fillp);
+#line 862
+#endif
+#line 862
-#line 908
+#line 862
return status;
-#line 908
+#line 862
}
-#line 908
-
+#line 862
static int
-#line 910
-getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
-#line 910
- const size_t *start, size_t nelems, schar *value)
-#line 910
+#line 863
+putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
+#line 863
+ const size_t *start, size_t nelems, const uint *value)
+#line 863
{
-#line 910
+#line 863
off_t offset = NC_varoffset(ncp, varp, start);
-#line 910
+#line 863
size_t remaining = varp->xsz * nelems;
-#line 910
+#line 863
int status = NC_NOERR;
-#line 910
- const void *xp;
-#line 910
+#line 863
+ void *xp;
+#line 863
+ void *fillp=NULL;
+#line 863
-#line 910
+#line 863
if(nelems == 0)
-#line 910
+#line 863
return NC_NOERR;
-#line 910
+#line 863
-#line 910
+#line 863
assert(value != NULL);
-#line 910
+#line 863
+
+#line 863
+#ifdef ERANGE_FILL
+#line 863
+ fillp = malloc(varp->xsz);
+#line 863
+ status = NC3_inq_var_fill(varp, fillp);
+#line 863
+#endif
+#line 863
-#line 910
+#line 863
for(;;)
-#line 910
+#line 863
{
-#line 910
+#line 863
size_t extent = MIN(remaining, ncp->chunk);
-#line 910
- size_t nget = ncx_howmany(varp->type, extent);
-#line 910
+#line 863
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 863
-#line 910
+#line 863
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 910
- 0, (void **)&xp); /* cast away const */
-#line 910
+#line 863
+ RGN_WRITE, &xp);
+#line 863
if(lstatus != NC_NOERR)
-#line 910
+#line 863
return lstatus;
-#line 910
+#line 863
-#line 910
- lstatus = ncx_getn_schar_schar(&xp, nget, value);
-#line 910
+#line 863
+ lstatus = ncx_putn_ulonglong_uint(&xp, nput, value ,fillp);
+#line 863
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 910
+#line 863
+ {
+#line 863
+ /* not fatal to the loop */
+#line 863
status = lstatus;
-#line 910
+#line 863
+ }
+#line 863
-#line 910
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 910
+#line 863
+ (void) ncio_rel(ncp->nciop, offset,
+#line 863
+ RGN_MODIFIED);
+#line 863
-#line 910
+#line 863
remaining -= extent;
-#line 910
+#line 863
if(remaining == 0)
-#line 910
+#line 863
break; /* normal loop exit */
-#line 910
+#line 863
offset += (off_t)extent;
-#line 910
- value += nget;
-#line 910
+#line 863
+ value += nput;
+#line 863
+
+#line 863
}
-#line 910
+#line 863
+#ifdef ERANGE_FILL
+#line 863
+ free(fillp);
+#line 863
+#endif
+#line 863
-#line 910
+#line 863
return status;
-#line 910
+#line 863
}
-#line 910
+#line 863
static int
-#line 911
-getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
-#line 911
- const size_t *start, size_t nelems, short *value)
-#line 911
+#line 864
+putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+#line 864
+ const size_t *start, size_t nelems, const ulonglong *value)
+#line 864
{
-#line 911
+#line 864
off_t offset = NC_varoffset(ncp, varp, start);
-#line 911
+#line 864
size_t remaining = varp->xsz * nelems;
-#line 911
+#line 864
int status = NC_NOERR;
-#line 911
- const void *xp;
-#line 911
+#line 864
+ void *xp;
+#line 864
+ void *fillp=NULL;
+#line 864
-#line 911
+#line 864
if(nelems == 0)
-#line 911
+#line 864
return NC_NOERR;
-#line 911
+#line 864
-#line 911
+#line 864
assert(value != NULL);
-#line 911
+#line 864
-#line 911
+#line 864
+#ifdef ERANGE_FILL
+#line 864
+ fillp = malloc(varp->xsz);
+#line 864
+ status = NC3_inq_var_fill(varp, fillp);
+#line 864
+#endif
+#line 864
+
+#line 864
for(;;)
-#line 911
+#line 864
{
-#line 911
+#line 864
size_t extent = MIN(remaining, ncp->chunk);
-#line 911
- size_t nget = ncx_howmany(varp->type, extent);
-#line 911
+#line 864
+ size_t nput = ncx_howmany(varp->type, extent);
+#line 864
-#line 911
+#line 864
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 911
- 0, (void **)&xp); /* cast away const */
-#line 911
+#line 864
+ RGN_WRITE, &xp);
+#line 864
if(lstatus != NC_NOERR)
-#line 911
+#line 864
return lstatus;
-#line 911
+#line 864
-#line 911
- lstatus = ncx_getn_schar_short(&xp, nget, value);
-#line 911
+#line 864
+ lstatus = ncx_putn_ulonglong_ulonglong(&xp, nput, value ,fillp);
+#line 864
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 911
+#line 864
+ {
+#line 864
+ /* not fatal to the loop */
+#line 864
status = lstatus;
-#line 911
+#line 864
+ }
+#line 864
-#line 911
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 911
+#line 864
+ (void) ncio_rel(ncp->nciop, offset,
+#line 864
+ RGN_MODIFIED);
+#line 864
-#line 911
+#line 864
remaining -= extent;
-#line 911
+#line 864
if(remaining == 0)
-#line 911
+#line 864
break; /* normal loop exit */
-#line 911
+#line 864
offset += (off_t)extent;
-#line 911
- value += nget;
-#line 911
+#line 864
+ value += nput;
+#line 864
+
+#line 864
}
-#line 911
+#line 864
+#ifdef ERANGE_FILL
+#line 864
+ free(fillp);
+#line 864
+#endif
+#line 864
-#line 911
+#line 864
return status;
-#line 911
+#line 864
}
+#line 864
+
+
#line 911
static int
#line 912
-getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
#line 912
- const size_t *start, size_t nelems, int *value)
+ const size_t *start, size_t nelems, char *value)
#line 912
{
#line 912
@@ -11411,7 +11981,7 @@ getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
#line 912
#line 912
- lstatus = ncx_getn_schar_int(&xp, nget, value);
+ lstatus = ncx_getn_char_char(&xp, nget, value);
#line 912
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 912
@@ -11442,90 +12012,12 @@ getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
}
#line 912
-static int
-#line 913
-getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
-#line 913
- const size_t *start, size_t nelems, float *value)
-#line 913
-{
-#line 913
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 913
- size_t remaining = varp->xsz * nelems;
-#line 913
- int status = NC_NOERR;
-#line 913
- const void *xp;
-#line 913
-
-#line 913
- if(nelems == 0)
-#line 913
- return NC_NOERR;
-#line 913
-
-#line 913
- assert(value != NULL);
-#line 913
-
-#line 913
- for(;;)
-#line 913
- {
-#line 913
- size_t extent = MIN(remaining, ncp->chunk);
-#line 913
- size_t nget = ncx_howmany(varp->type, extent);
-#line 913
-
-#line 913
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 913
- 0, (void **)&xp); /* cast away const */
-#line 913
- if(lstatus != NC_NOERR)
-#line 913
- return lstatus;
-#line 913
-
-#line 913
- lstatus = ncx_getn_schar_float(&xp, nget, value);
-#line 913
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 913
- status = lstatus;
-#line 913
-
-#line 913
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 913
-
-#line 913
- remaining -= extent;
-#line 913
- if(remaining == 0)
-#line 913
- break; /* normal loop exit */
-#line 913
- offset += (off_t)extent;
-#line 913
- value += nget;
-#line 913
- }
-#line 913
-
-#line 913
- return status;
-#line 913
-}
-#line 913
static int
#line 914
-getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 914
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, schar *value)
#line 914
{
#line 914
@@ -11569,7 +12061,7 @@ getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
#line 914
#line 914
- lstatus = ncx_getn_schar_double(&xp, nget, value);
+ lstatus = ncx_getn_schar_schar(&xp, nget, value);
#line 914
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 914
@@ -11602,9 +12094,9 @@ getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 915
-getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
#line 915
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 915
{
#line 915
@@ -11648,7 +12140,7 @@ getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 915
#line 915
- lstatus = ncx_getn_schar_longlong(&xp, nget, value);
+ lstatus = ncx_getn_schar_short(&xp, nget, value);
#line 915
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 915
@@ -11681,9 +12173,9 @@ getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 916
-getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
#line 916
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 916
{
#line 916
@@ -11727,7 +12219,7 @@ getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 916
#line 916
- lstatus = ncx_getn_schar_uint(&xp, nget, value);
+ lstatus = ncx_getn_schar_int(&xp, nget, value);
#line 916
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 916
@@ -11760,9 +12252,9 @@ getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 917
-getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
#line 917
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 917
{
#line 917
@@ -11806,7 +12298,7 @@ getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 917
#line 917
- lstatus = ncx_getn_schar_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_schar_float(&xp, nget, value);
#line 917
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 917
@@ -11839,9 +12331,9 @@ getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 918
-getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
#line 918
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, double *value)
#line 918
{
#line 918
@@ -11885,7 +12377,7 @@ getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 918
#line 918
- lstatus = ncx_getn_schar_uchar(&xp, nget, value);
+ lstatus = ncx_getn_schar_double(&xp, nget, value);
#line 918
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 918
@@ -11918,9 +12410,9 @@ getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 919
-getNCvx_schar_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 919
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, longlong *value)
#line 919
{
#line 919
@@ -11964,7 +12456,7 @@ getNCvx_schar_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 919
#line 919
- lstatus = ncx_getn_schar_ushort(&xp, nget, value);
+ lstatus = ncx_getn_schar_longlong(&xp, nget, value);
#line 919
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 919
@@ -11995,12 +12487,90 @@ getNCvx_schar_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 919
+static int
+#line 920
+getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
+#line 920
+ const size_t *start, size_t nelems, uint *value)
+#line 920
+{
+#line 920
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 920
+ size_t remaining = varp->xsz * nelems;
+#line 920
+ int status = NC_NOERR;
+#line 920
+ const void *xp;
+#line 920
+
+#line 920
+ if(nelems == 0)
+#line 920
+ return NC_NOERR;
+#line 920
+
+#line 920
+ assert(value != NULL);
+#line 920
+
+#line 920
+ for(;;)
+#line 920
+ {
+#line 920
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 920
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 920
+
+#line 920
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 920
+ 0, (void **)&xp); /* cast away const */
+#line 920
+ if(lstatus != NC_NOERR)
+#line 920
+ return lstatus;
+#line 920
+
+#line 920
+ lstatus = ncx_getn_schar_uint(&xp, nget, value);
+#line 920
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 920
+ status = lstatus;
+#line 920
+
+#line 920
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 920
+
+#line 920
+ remaining -= extent;
+#line 920
+ if(remaining == 0)
+#line 920
+ break; /* normal loop exit */
+#line 920
+ offset += (off_t)extent;
+#line 920
+ value += nget;
+#line 920
+ }
+#line 920
+
+#line 920
+ return status;
+#line 920
+}
+#line 920
static int
#line 921
-getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 921
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 921
{
#line 921
@@ -12044,7 +12614,7 @@ getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 921
#line 921
- lstatus = ncx_getn_short_schar(&xp, nget, value);
+ lstatus = ncx_getn_schar_ulonglong(&xp, nget, value);
#line 921
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 921
@@ -12077,7 +12647,7 @@ getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 922
-getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 922
const size_t *start, size_t nelems, uchar *value)
#line 922
@@ -12123,7 +12693,7 @@ getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 922
#line 922
- lstatus = ncx_getn_short_uchar(&xp, nget, value);
+ lstatus = ncx_getn_schar_uchar(&xp, nget, value);
#line 922
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 922
@@ -12156,9 +12726,9 @@ getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 923
-getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_schar_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 923
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 923
{
#line 923
@@ -12202,7 +12772,7 @@ getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
#line 923
#line 923
- lstatus = ncx_getn_short_short(&xp, nget, value);
+ lstatus = ncx_getn_schar_ushort(&xp, nget, value);
#line 923
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 923
@@ -12233,90 +12803,12 @@ getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 923
-static int
-#line 924
-getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 924
- const size_t *start, size_t nelems, int *value)
-#line 924
-{
-#line 924
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 924
- size_t remaining = varp->xsz * nelems;
-#line 924
- int status = NC_NOERR;
-#line 924
- const void *xp;
-#line 924
-
-#line 924
- if(nelems == 0)
-#line 924
- return NC_NOERR;
-#line 924
-
-#line 924
- assert(value != NULL);
-#line 924
-
-#line 924
- for(;;)
-#line 924
- {
-#line 924
- size_t extent = MIN(remaining, ncp->chunk);
-#line 924
- size_t nget = ncx_howmany(varp->type, extent);
-#line 924
-
-#line 924
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 924
- 0, (void **)&xp); /* cast away const */
-#line 924
- if(lstatus != NC_NOERR)
-#line 924
- return lstatus;
-#line 924
-
-#line 924
- lstatus = ncx_getn_short_int(&xp, nget, value);
-#line 924
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 924
- status = lstatus;
-#line 924
-
-#line 924
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 924
-
-#line 924
- remaining -= extent;
-#line 924
- if(remaining == 0)
-#line 924
- break; /* normal loop exit */
-#line 924
- offset += (off_t)extent;
-#line 924
- value += nget;
-#line 924
- }
-#line 924
-
-#line 924
- return status;
-#line 924
-}
-#line 924
static int
#line 925
-getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 925
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 925
{
#line 925
@@ -12360,7 +12852,7 @@ getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
#line 925
#line 925
- lstatus = ncx_getn_short_float(&xp, nget, value);
+ lstatus = ncx_getn_short_schar(&xp, nget, value);
#line 925
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 925
@@ -12393,9 +12885,9 @@ getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 926
-getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 926
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 926
{
#line 926
@@ -12439,7 +12931,7 @@ getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
#line 926
#line 926
- lstatus = ncx_getn_short_double(&xp, nget, value);
+ lstatus = ncx_getn_short_uchar(&xp, nget, value);
#line 926
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 926
@@ -12472,9 +12964,9 @@ getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 927
-getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
#line 927
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 927
{
#line 927
@@ -12518,7 +13010,7 @@ getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 927
#line 927
- lstatus = ncx_getn_short_longlong(&xp, nget, value);
+ lstatus = ncx_getn_short_short(&xp, nget, value);
#line 927
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 927
@@ -12551,9 +13043,9 @@ getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 928
-getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
#line 928
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 928
{
#line 928
@@ -12597,7 +13089,7 @@ getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 928
#line 928
- lstatus = ncx_getn_short_uint(&xp, nget, value);
+ lstatus = ncx_getn_short_int(&xp, nget, value);
#line 928
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 928
@@ -12630,9 +13122,9 @@ getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 929
-getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
#line 929
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 929
{
#line 929
@@ -12676,7 +13168,7 @@ getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 929
#line 929
- lstatus = ncx_getn_short_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_short_float(&xp, nget, value);
#line 929
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 929
@@ -12709,9 +13201,9 @@ getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 930
-getNCvx_short_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
#line 930
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 930
{
#line 930
@@ -12755,7 +13247,7 @@ getNCvx_short_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 930
#line 930
- lstatus = ncx_getn_short_ushort(&xp, nget, value);
+ lstatus = ncx_getn_short_double(&xp, nget, value);
#line 930
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 930
@@ -12786,12 +13278,90 @@ getNCvx_short_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 930
+static int
+#line 931
+getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 931
+ const size_t *start, size_t nelems, longlong *value)
+#line 931
+{
+#line 931
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 931
+ size_t remaining = varp->xsz * nelems;
+#line 931
+ int status = NC_NOERR;
+#line 931
+ const void *xp;
+#line 931
+
+#line 931
+ if(nelems == 0)
+#line 931
+ return NC_NOERR;
+#line 931
+
+#line 931
+ assert(value != NULL);
+#line 931
+
+#line 931
+ for(;;)
+#line 931
+ {
+#line 931
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 931
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 931
+
+#line 931
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 931
+ 0, (void **)&xp); /* cast away const */
+#line 931
+ if(lstatus != NC_NOERR)
+#line 931
+ return lstatus;
+#line 931
+
+#line 931
+ lstatus = ncx_getn_short_longlong(&xp, nget, value);
+#line 931
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 931
+ status = lstatus;
+#line 931
+
+#line 931
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 931
+
+#line 931
+ remaining -= extent;
+#line 931
+ if(remaining == 0)
+#line 931
+ break; /* normal loop exit */
+#line 931
+ offset += (off_t)extent;
+#line 931
+ value += nget;
+#line 931
+ }
+#line 931
+
+#line 931
+ return status;
+#line 931
+}
+#line 931
static int
#line 932
-getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 932
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 932
{
#line 932
@@ -12835,7 +13405,7 @@ getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 932
#line 932
- lstatus = ncx_getn_int_schar(&xp, nget, value);
+ lstatus = ncx_getn_short_uint(&xp, nget, value);
#line 932
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 932
@@ -12868,9 +13438,9 @@ getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 933
-getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 933
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 933
{
#line 933
@@ -12914,7 +13484,7 @@ getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 933
#line 933
- lstatus = ncx_getn_int_uchar(&xp, nget, value);
+ lstatus = ncx_getn_short_ulonglong(&xp, nget, value);
#line 933
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 933
@@ -12947,9 +13517,9 @@ getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 934
-getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_short_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 934
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 934
{
#line 934
@@ -12993,121 +13563,43 @@ getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
#line 934
#line 934
- lstatus = ncx_getn_int_short(&xp, nget, value);
-#line 934
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 934
- status = lstatus;
-#line 934
-
-#line 934
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 934
-
-#line 934
- remaining -= extent;
-#line 934
- if(remaining == 0)
-#line 934
- break; /* normal loop exit */
-#line 934
- offset += (off_t)extent;
-#line 934
- value += nget;
-#line 934
- }
-#line 934
-
-#line 934
- return status;
-#line 934
-}
-#line 934
-
-static int
-#line 935
-getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 935
- const size_t *start, size_t nelems, int *value)
-#line 935
-{
-#line 935
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 935
- size_t remaining = varp->xsz * nelems;
-#line 935
- int status = NC_NOERR;
-#line 935
- const void *xp;
-#line 935
-
-#line 935
- if(nelems == 0)
-#line 935
- return NC_NOERR;
-#line 935
-
-#line 935
- assert(value != NULL);
-#line 935
-
-#line 935
- for(;;)
-#line 935
- {
-#line 935
- size_t extent = MIN(remaining, ncp->chunk);
-#line 935
- size_t nget = ncx_howmany(varp->type, extent);
-#line 935
-
-#line 935
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 935
- 0, (void **)&xp); /* cast away const */
-#line 935
- if(lstatus != NC_NOERR)
-#line 935
- return lstatus;
-#line 935
-
-#line 935
- lstatus = ncx_getn_int_int(&xp, nget, value);
-#line 935
+ lstatus = ncx_getn_short_ushort(&xp, nget, value);
+#line 934
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 935
+#line 934
status = lstatus;
-#line 935
+#line 934
-#line 935
+#line 934
(void) ncio_rel(ncp->nciop, offset, 0);
-#line 935
+#line 934
-#line 935
+#line 934
remaining -= extent;
-#line 935
+#line 934
if(remaining == 0)
-#line 935
+#line 934
break; /* normal loop exit */
-#line 935
+#line 934
offset += (off_t)extent;
-#line 935
+#line 934
value += nget;
-#line 935
+#line 934
}
-#line 935
+#line 934
-#line 935
+#line 934
return status;
-#line 935
+#line 934
}
-#line 935
+#line 934
+
static int
#line 936
-getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 936
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 936
{
#line 936
@@ -13151,7 +13643,7 @@ getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
#line 936
#line 936
- lstatus = ncx_getn_int_float(&xp, nget, value);
+ lstatus = ncx_getn_int_schar(&xp, nget, value);
#line 936
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 936
@@ -13184,9 +13676,9 @@ getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 937
-getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 937
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 937
{
#line 937
@@ -13230,7 +13722,7 @@ getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
#line 937
#line 937
- lstatus = ncx_getn_int_double(&xp, nget, value);
+ lstatus = ncx_getn_int_uchar(&xp, nget, value);
#line 937
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 937
@@ -13263,9 +13755,9 @@ getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 938
-getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
#line 938
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 938
{
#line 938
@@ -13309,7 +13801,7 @@ getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 938
#line 938
- lstatus = ncx_getn_int_longlong(&xp, nget, value);
+ lstatus = ncx_getn_int_short(&xp, nget, value);
#line 938
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 938
@@ -13342,9 +13834,9 @@ getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 939
-getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
#line 939
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 939
{
#line 939
@@ -13388,7 +13880,7 @@ getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 939
#line 939
- lstatus = ncx_getn_int_uint(&xp, nget, value);
+ lstatus = ncx_getn_int_int(&xp, nget, value);
#line 939
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 939
@@ -13421,9 +13913,9 @@ getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 940
-getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
#line 940
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 940
{
#line 940
@@ -13467,7 +13959,7 @@ getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 940
#line 940
- lstatus = ncx_getn_int_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_int_float(&xp, nget, value);
#line 940
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 940
@@ -13500,9 +13992,9 @@ getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 941
-getNCvx_int_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
#line 941
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 941
{
#line 941
@@ -13546,7 +14038,7 @@ getNCvx_int_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 941
#line 941
- lstatus = ncx_getn_int_ushort(&xp, nget, value);
+ lstatus = ncx_getn_int_double(&xp, nget, value);
#line 941
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 941
@@ -13577,12 +14069,90 @@ getNCvx_int_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 941
+static int
+#line 942
+getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 942
+ const size_t *start, size_t nelems, longlong *value)
+#line 942
+{
+#line 942
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 942
+ size_t remaining = varp->xsz * nelems;
+#line 942
+ int status = NC_NOERR;
+#line 942
+ const void *xp;
+#line 942
+
+#line 942
+ if(nelems == 0)
+#line 942
+ return NC_NOERR;
+#line 942
+
+#line 942
+ assert(value != NULL);
+#line 942
+
+#line 942
+ for(;;)
+#line 942
+ {
+#line 942
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 942
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 942
+
+#line 942
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 942
+ 0, (void **)&xp); /* cast away const */
+#line 942
+ if(lstatus != NC_NOERR)
+#line 942
+ return lstatus;
+#line 942
+
+#line 942
+ lstatus = ncx_getn_int_longlong(&xp, nget, value);
+#line 942
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 942
+ status = lstatus;
+#line 942
+
+#line 942
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 942
+
+#line 942
+ remaining -= extent;
+#line 942
+ if(remaining == 0)
+#line 942
+ break; /* normal loop exit */
+#line 942
+ offset += (off_t)extent;
+#line 942
+ value += nget;
+#line 942
+ }
+#line 942
+
+#line 942
+ return status;
+#line 942
+}
+#line 942
static int
#line 943
-getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 943
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 943
{
#line 943
@@ -13626,7 +14196,7 @@ getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 943
#line 943
- lstatus = ncx_getn_float_schar(&xp, nget, value);
+ lstatus = ncx_getn_int_uint(&xp, nget, value);
#line 943
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 943
@@ -13659,9 +14229,9 @@ getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 944
-getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 944
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 944
{
#line 944
@@ -13705,7 +14275,7 @@ getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 944
#line 944
- lstatus = ncx_getn_float_uchar(&xp, nget, value);
+ lstatus = ncx_getn_int_ulonglong(&xp, nget, value);
#line 944
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 944
@@ -13738,9 +14308,9 @@ getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 945
-getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_int_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 945
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 945
{
#line 945
@@ -13784,7 +14354,7 @@ getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
#line 945
#line 945
- lstatus = ncx_getn_float_short(&xp, nget, value);
+ lstatus = ncx_getn_int_ushort(&xp, nget, value);
#line 945
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 945
@@ -13815,90 +14385,12 @@ getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 945
-static int
-#line 946
-getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 946
- const size_t *start, size_t nelems, int *value)
-#line 946
-{
-#line 946
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 946
- size_t remaining = varp->xsz * nelems;
-#line 946
- int status = NC_NOERR;
-#line 946
- const void *xp;
-#line 946
-
-#line 946
- if(nelems == 0)
-#line 946
- return NC_NOERR;
-#line 946
-
-#line 946
- assert(value != NULL);
-#line 946
-
-#line 946
- for(;;)
-#line 946
- {
-#line 946
- size_t extent = MIN(remaining, ncp->chunk);
-#line 946
- size_t nget = ncx_howmany(varp->type, extent);
-#line 946
-
-#line 946
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 946
- 0, (void **)&xp); /* cast away const */
-#line 946
- if(lstatus != NC_NOERR)
-#line 946
- return lstatus;
-#line 946
-
-#line 946
- lstatus = ncx_getn_float_int(&xp, nget, value);
-#line 946
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 946
- status = lstatus;
-#line 946
-
-#line 946
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 946
-
-#line 946
- remaining -= extent;
-#line 946
- if(remaining == 0)
-#line 946
- break; /* normal loop exit */
-#line 946
- offset += (off_t)extent;
-#line 946
- value += nget;
-#line 946
- }
-#line 946
-
-#line 946
- return status;
-#line 946
-}
-#line 946
static int
#line 947
-getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 947
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 947
{
#line 947
@@ -13942,7 +14434,7 @@ getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
#line 947
#line 947
- lstatus = ncx_getn_float_float(&xp, nget, value);
+ lstatus = ncx_getn_float_schar(&xp, nget, value);
#line 947
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 947
@@ -13975,9 +14467,9 @@ getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 948
-getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 948
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 948
{
#line 948
@@ -14021,7 +14513,7 @@ getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
#line 948
#line 948
- lstatus = ncx_getn_float_double(&xp, nget, value);
+ lstatus = ncx_getn_float_uchar(&xp, nget, value);
#line 948
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 948
@@ -14054,9 +14546,9 @@ getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 949
-getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
#line 949
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 949
{
#line 949
@@ -14100,7 +14592,7 @@ getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 949
#line 949
- lstatus = ncx_getn_float_longlong(&xp, nget, value);
+ lstatus = ncx_getn_float_short(&xp, nget, value);
#line 949
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 949
@@ -14133,9 +14625,9 @@ getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 950
-getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
#line 950
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 950
{
#line 950
@@ -14179,7 +14671,7 @@ getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 950
#line 950
- lstatus = ncx_getn_float_uint(&xp, nget, value);
+ lstatus = ncx_getn_float_int(&xp, nget, value);
#line 950
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 950
@@ -14212,9 +14704,9 @@ getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 951
-getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
#line 951
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 951
{
#line 951
@@ -14258,7 +14750,7 @@ getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 951
#line 951
- lstatus = ncx_getn_float_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_float_float(&xp, nget, value);
#line 951
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 951
@@ -14291,89 +14783,167 @@ getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 952
-getNCvx_float_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
#line 952
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 952
{
#line 952
off_t offset = NC_varoffset(ncp, varp, start);
#line 952
size_t remaining = varp->xsz * nelems;
-#line 952
+#line 952
+ int status = NC_NOERR;
+#line 952
+ const void *xp;
+#line 952
+
+#line 952
+ if(nelems == 0)
+#line 952
+ return NC_NOERR;
+#line 952
+
+#line 952
+ assert(value != NULL);
+#line 952
+
+#line 952
+ for(;;)
+#line 952
+ {
+#line 952
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 952
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 952
+
+#line 952
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 952
+ 0, (void **)&xp); /* cast away const */
+#line 952
+ if(lstatus != NC_NOERR)
+#line 952
+ return lstatus;
+#line 952
+
+#line 952
+ lstatus = ncx_getn_float_double(&xp, nget, value);
+#line 952
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 952
+ status = lstatus;
+#line 952
+
+#line 952
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 952
+
+#line 952
+ remaining -= extent;
+#line 952
+ if(remaining == 0)
+#line 952
+ break; /* normal loop exit */
+#line 952
+ offset += (off_t)extent;
+#line 952
+ value += nget;
+#line 952
+ }
+#line 952
+
+#line 952
+ return status;
+#line 952
+}
+#line 952
+
+static int
+#line 953
+getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 953
+ const size_t *start, size_t nelems, longlong *value)
+#line 953
+{
+#line 953
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 953
+ size_t remaining = varp->xsz * nelems;
+#line 953
int status = NC_NOERR;
-#line 952
+#line 953
const void *xp;
-#line 952
+#line 953
-#line 952
+#line 953
if(nelems == 0)
-#line 952
+#line 953
return NC_NOERR;
-#line 952
+#line 953
-#line 952
+#line 953
assert(value != NULL);
-#line 952
+#line 953
-#line 952
+#line 953
for(;;)
-#line 952
+#line 953
{
-#line 952
+#line 953
size_t extent = MIN(remaining, ncp->chunk);
-#line 952
+#line 953
size_t nget = ncx_howmany(varp->type, extent);
-#line 952
+#line 953
-#line 952
+#line 953
int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 952
+#line 953
0, (void **)&xp); /* cast away const */
-#line 952
+#line 953
if(lstatus != NC_NOERR)
-#line 952
+#line 953
return lstatus;
-#line 952
+#line 953
-#line 952
- lstatus = ncx_getn_float_ushort(&xp, nget, value);
-#line 952
+#line 953
+ lstatus = ncx_getn_float_longlong(&xp, nget, value);
+#line 953
if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 952
+#line 953
status = lstatus;
-#line 952
+#line 953
-#line 952
+#line 953
(void) ncio_rel(ncp->nciop, offset, 0);
-#line 952
+#line 953
-#line 952
+#line 953
remaining -= extent;
-#line 952
+#line 953
if(remaining == 0)
-#line 952
+#line 953
break; /* normal loop exit */
-#line 952
+#line 953
offset += (off_t)extent;
-#line 952
+#line 953
value += nget;
-#line 952
+#line 953
}
-#line 952
+#line 953
-#line 952
+#line 953
return status;
-#line 952
+#line 953
}
-#line 952
-
+#line 953
static int
#line 954
-getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 954
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 954
{
#line 954
@@ -14417,7 +14987,7 @@ getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 954
#line 954
- lstatus = ncx_getn_double_schar(&xp, nget, value);
+ lstatus = ncx_getn_float_uint(&xp, nget, value);
#line 954
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 954
@@ -14450,9 +15020,9 @@ getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 955
-getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 955
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 955
{
#line 955
@@ -14496,7 +15066,7 @@ getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 955
#line 955
- lstatus = ncx_getn_double_uchar(&xp, nget, value);
+ lstatus = ncx_getn_float_ulonglong(&xp, nget, value);
#line 955
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 955
@@ -14529,9 +15099,9 @@ getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 956
-getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_float_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 956
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 956
{
#line 956
@@ -14575,7 +15145,7 @@ getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
#line 956
#line 956
- lstatus = ncx_getn_double_short(&xp, nget, value);
+ lstatus = ncx_getn_float_ushort(&xp, nget, value);
#line 956
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 956
@@ -14606,90 +15176,12 @@ getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 956
-static int
-#line 957
-getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 957
- const size_t *start, size_t nelems, int *value)
-#line 957
-{
-#line 957
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 957
- size_t remaining = varp->xsz * nelems;
-#line 957
- int status = NC_NOERR;
-#line 957
- const void *xp;
-#line 957
-
-#line 957
- if(nelems == 0)
-#line 957
- return NC_NOERR;
-#line 957
-
-#line 957
- assert(value != NULL);
-#line 957
-
-#line 957
- for(;;)
-#line 957
- {
-#line 957
- size_t extent = MIN(remaining, ncp->chunk);
-#line 957
- size_t nget = ncx_howmany(varp->type, extent);
-#line 957
-
-#line 957
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 957
- 0, (void **)&xp); /* cast away const */
-#line 957
- if(lstatus != NC_NOERR)
-#line 957
- return lstatus;
-#line 957
-
-#line 957
- lstatus = ncx_getn_double_int(&xp, nget, value);
-#line 957
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 957
- status = lstatus;
-#line 957
-
-#line 957
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 957
-
-#line 957
- remaining -= extent;
-#line 957
- if(remaining == 0)
-#line 957
- break; /* normal loop exit */
-#line 957
- offset += (off_t)extent;
-#line 957
- value += nget;
-#line 957
- }
-#line 957
-
-#line 957
- return status;
-#line 957
-}
-#line 957
static int
#line 958
-getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 958
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 958
{
#line 958
@@ -14733,7 +15225,7 @@ getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
#line 958
#line 958
- lstatus = ncx_getn_double_float(&xp, nget, value);
+ lstatus = ncx_getn_double_schar(&xp, nget, value);
#line 958
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 958
@@ -14766,9 +15258,9 @@ getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 959
-getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 959
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 959
{
#line 959
@@ -14812,7 +15304,7 @@ getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
#line 959
#line 959
- lstatus = ncx_getn_double_double(&xp, nget, value);
+ lstatus = ncx_getn_double_uchar(&xp, nget, value);
#line 959
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 959
@@ -14845,9 +15337,9 @@ getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 960
-getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
#line 960
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 960
{
#line 960
@@ -14891,7 +15383,7 @@ getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 960
#line 960
- lstatus = ncx_getn_double_longlong(&xp, nget, value);
+ lstatus = ncx_getn_double_short(&xp, nget, value);
#line 960
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 960
@@ -14924,9 +15416,9 @@ getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 961
-getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
#line 961
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 961
{
#line 961
@@ -14970,7 +15462,7 @@ getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 961
#line 961
- lstatus = ncx_getn_double_uint(&xp, nget, value);
+ lstatus = ncx_getn_double_int(&xp, nget, value);
#line 961
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 961
@@ -15003,9 +15495,9 @@ getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 962
-getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
#line 962
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 962
{
#line 962
@@ -15049,7 +15541,7 @@ getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 962
#line 962
- lstatus = ncx_getn_double_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_double_float(&xp, nget, value);
#line 962
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 962
@@ -15082,9 +15574,9 @@ getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 963
-getNCvx_double_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
#line 963
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 963
{
#line 963
@@ -15128,7 +15620,7 @@ getNCvx_double_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 963
#line 963
- lstatus = ncx_getn_double_ushort(&xp, nget, value);
+ lstatus = ncx_getn_double_double(&xp, nget, value);
#line 963
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 963
@@ -15159,12 +15651,90 @@ getNCvx_double_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 963
+static int
+#line 964
+getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 964
+ const size_t *start, size_t nelems, longlong *value)
+#line 964
+{
+#line 964
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 964
+ size_t remaining = varp->xsz * nelems;
+#line 964
+ int status = NC_NOERR;
+#line 964
+ const void *xp;
+#line 964
+
+#line 964
+ if(nelems == 0)
+#line 964
+ return NC_NOERR;
+#line 964
+
+#line 964
+ assert(value != NULL);
+#line 964
+
+#line 964
+ for(;;)
+#line 964
+ {
+#line 964
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 964
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 964
+
+#line 964
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 964
+ 0, (void **)&xp); /* cast away const */
+#line 964
+ if(lstatus != NC_NOERR)
+#line 964
+ return lstatus;
+#line 964
+
+#line 964
+ lstatus = ncx_getn_double_longlong(&xp, nget, value);
+#line 964
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 964
+ status = lstatus;
+#line 964
+
+#line 964
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 964
+
+#line 964
+ remaining -= extent;
+#line 964
+ if(remaining == 0)
+#line 964
+ break; /* normal loop exit */
+#line 964
+ offset += (off_t)extent;
+#line 964
+ value += nget;
+#line 964
+ }
+#line 964
+
+#line 964
+ return status;
+#line 964
+}
+#line 964
static int
#line 965
-getNCvx_uchar_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 965
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 965
{
#line 965
@@ -15208,7 +15778,7 @@ getNCvx_uchar_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 965
#line 965
- lstatus = ncx_getn_uchar_schar(&xp, nget, value);
+ lstatus = ncx_getn_double_uint(&xp, nget, value);
#line 965
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 965
@@ -15241,9 +15811,9 @@ getNCvx_uchar_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 966
-getNCvx_uchar_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 966
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 966
{
#line 966
@@ -15287,7 +15857,7 @@ getNCvx_uchar_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 966
#line 966
- lstatus = ncx_getn_uchar_uchar(&xp, nget, value);
+ lstatus = ncx_getn_double_ulonglong(&xp, nget, value);
#line 966
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 966
@@ -15320,9 +15890,9 @@ getNCvx_uchar_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 967
-getNCvx_uchar_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_double_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 967
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 967
{
#line 967
@@ -15366,7 +15936,7 @@ getNCvx_uchar_short(const NC3_INFO* ncp, const NC_var *varp,
#line 967
#line 967
- lstatus = ncx_getn_uchar_short(&xp, nget, value);
+ lstatus = ncx_getn_double_ushort(&xp, nget, value);
#line 967
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 967
@@ -15397,90 +15967,12 @@ getNCvx_uchar_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 967
-static int
-#line 968
-getNCvx_uchar_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 968
- const size_t *start, size_t nelems, int *value)
-#line 968
-{
-#line 968
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 968
- size_t remaining = varp->xsz * nelems;
-#line 968
- int status = NC_NOERR;
-#line 968
- const void *xp;
-#line 968
-
-#line 968
- if(nelems == 0)
-#line 968
- return NC_NOERR;
-#line 968
-
-#line 968
- assert(value != NULL);
-#line 968
-
-#line 968
- for(;;)
-#line 968
- {
-#line 968
- size_t extent = MIN(remaining, ncp->chunk);
-#line 968
- size_t nget = ncx_howmany(varp->type, extent);
-#line 968
-
-#line 968
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 968
- 0, (void **)&xp); /* cast away const */
-#line 968
- if(lstatus != NC_NOERR)
-#line 968
- return lstatus;
-#line 968
-
-#line 968
- lstatus = ncx_getn_uchar_int(&xp, nget, value);
-#line 968
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 968
- status = lstatus;
-#line 968
-
-#line 968
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 968
-
-#line 968
- remaining -= extent;
-#line 968
- if(remaining == 0)
-#line 968
- break; /* normal loop exit */
-#line 968
- offset += (off_t)extent;
-#line 968
- value += nget;
-#line 968
- }
-#line 968
-
-#line 968
- return status;
-#line 968
-}
-#line 968
static int
#line 969
-getNCvx_uchar_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 969
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 969
{
#line 969
@@ -15524,7 +16016,7 @@ getNCvx_uchar_float(const NC3_INFO* ncp, const NC_var *varp,
#line 969
#line 969
- lstatus = ncx_getn_uchar_float(&xp, nget, value);
+ lstatus = ncx_getn_uchar_schar(&xp, nget, value);
#line 969
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 969
@@ -15557,9 +16049,9 @@ getNCvx_uchar_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 970
-getNCvx_uchar_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 970
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 970
{
#line 970
@@ -15603,7 +16095,7 @@ getNCvx_uchar_double(const NC3_INFO* ncp, const NC_var *varp,
#line 970
#line 970
- lstatus = ncx_getn_uchar_double(&xp, nget, value);
+ lstatus = ncx_getn_uchar_uchar(&xp, nget, value);
#line 970
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 970
@@ -15636,9 +16128,9 @@ getNCvx_uchar_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 971
-getNCvx_uchar_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_short(const NC3_INFO* ncp, const NC_var *varp,
#line 971
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 971
{
#line 971
@@ -15682,7 +16174,7 @@ getNCvx_uchar_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 971
#line 971
- lstatus = ncx_getn_uchar_longlong(&xp, nget, value);
+ lstatus = ncx_getn_uchar_short(&xp, nget, value);
#line 971
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 971
@@ -15715,9 +16207,9 @@ getNCvx_uchar_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 972
-getNCvx_uchar_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_int(const NC3_INFO* ncp, const NC_var *varp,
#line 972
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 972
{
#line 972
@@ -15761,7 +16253,7 @@ getNCvx_uchar_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 972
#line 972
- lstatus = ncx_getn_uchar_uint(&xp, nget, value);
+ lstatus = ncx_getn_uchar_int(&xp, nget, value);
#line 972
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 972
@@ -15794,9 +16286,9 @@ getNCvx_uchar_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 973
-getNCvx_uchar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_float(const NC3_INFO* ncp, const NC_var *varp,
#line 973
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 973
{
#line 973
@@ -15840,7 +16332,7 @@ getNCvx_uchar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 973
#line 973
- lstatus = ncx_getn_uchar_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_uchar_float(&xp, nget, value);
#line 973
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 973
@@ -15873,9 +16365,9 @@ getNCvx_uchar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 974
-getNCvx_uchar_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_double(const NC3_INFO* ncp, const NC_var *varp,
#line 974
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 974
{
#line 974
@@ -15919,7 +16411,7 @@ getNCvx_uchar_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 974
#line 974
- lstatus = ncx_getn_uchar_ushort(&xp, nget, value);
+ lstatus = ncx_getn_uchar_double(&xp, nget, value);
#line 974
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 974
@@ -15950,12 +16442,90 @@ getNCvx_uchar_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 974
+static int
+#line 975
+getNCvx_uchar_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 975
+ const size_t *start, size_t nelems, longlong *value)
+#line 975
+{
+#line 975
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 975
+ size_t remaining = varp->xsz * nelems;
+#line 975
+ int status = NC_NOERR;
+#line 975
+ const void *xp;
+#line 975
+
+#line 975
+ if(nelems == 0)
+#line 975
+ return NC_NOERR;
+#line 975
+
+#line 975
+ assert(value != NULL);
+#line 975
+
+#line 975
+ for(;;)
+#line 975
+ {
+#line 975
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 975
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 975
+
+#line 975
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 975
+ 0, (void **)&xp); /* cast away const */
+#line 975
+ if(lstatus != NC_NOERR)
+#line 975
+ return lstatus;
+#line 975
+
+#line 975
+ lstatus = ncx_getn_uchar_longlong(&xp, nget, value);
+#line 975
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 975
+ status = lstatus;
+#line 975
+
+#line 975
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 975
+
+#line 975
+ remaining -= extent;
+#line 975
+ if(remaining == 0)
+#line 975
+ break; /* normal loop exit */
+#line 975
+ offset += (off_t)extent;
+#line 975
+ value += nget;
+#line 975
+ }
+#line 975
+
+#line 975
+ return status;
+#line 975
+}
+#line 975
static int
#line 976
-getNCvx_ushort_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 976
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 976
{
#line 976
@@ -15999,7 +16569,7 @@ getNCvx_ushort_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 976
#line 976
- lstatus = ncx_getn_ushort_schar(&xp, nget, value);
+ lstatus = ncx_getn_uchar_uint(&xp, nget, value);
#line 976
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 976
@@ -16032,9 +16602,9 @@ getNCvx_ushort_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 977
-getNCvx_ushort_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 977
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 977
{
#line 977
@@ -16078,7 +16648,7 @@ getNCvx_ushort_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 977
#line 977
- lstatus = ncx_getn_ushort_uchar(&xp, nget, value);
+ lstatus = ncx_getn_uchar_ulonglong(&xp, nget, value);
#line 977
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 977
@@ -16111,9 +16681,9 @@ getNCvx_ushort_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 978
-getNCvx_ushort_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uchar_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 978
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 978
{
#line 978
@@ -16157,7 +16727,7 @@ getNCvx_ushort_short(const NC3_INFO* ncp, const NC_var *varp,
#line 978
#line 978
- lstatus = ncx_getn_ushort_short(&xp, nget, value);
+ lstatus = ncx_getn_uchar_ushort(&xp, nget, value);
#line 978
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 978
@@ -16188,90 +16758,12 @@ getNCvx_ushort_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 978
-static int
-#line 979
-getNCvx_ushort_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 979
- const size_t *start, size_t nelems, int *value)
-#line 979
-{
-#line 979
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 979
- size_t remaining = varp->xsz * nelems;
-#line 979
- int status = NC_NOERR;
-#line 979
- const void *xp;
-#line 979
-
-#line 979
- if(nelems == 0)
-#line 979
- return NC_NOERR;
-#line 979
-
-#line 979
- assert(value != NULL);
-#line 979
-
-#line 979
- for(;;)
-#line 979
- {
-#line 979
- size_t extent = MIN(remaining, ncp->chunk);
-#line 979
- size_t nget = ncx_howmany(varp->type, extent);
-#line 979
-
-#line 979
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 979
- 0, (void **)&xp); /* cast away const */
-#line 979
- if(lstatus != NC_NOERR)
-#line 979
- return lstatus;
-#line 979
-
-#line 979
- lstatus = ncx_getn_ushort_int(&xp, nget, value);
-#line 979
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 979
- status = lstatus;
-#line 979
-
-#line 979
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 979
-
-#line 979
- remaining -= extent;
-#line 979
- if(remaining == 0)
-#line 979
- break; /* normal loop exit */
-#line 979
- offset += (off_t)extent;
-#line 979
- value += nget;
-#line 979
- }
-#line 979
-
-#line 979
- return status;
-#line 979
-}
-#line 979
static int
#line 980
-getNCvx_ushort_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 980
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 980
{
#line 980
@@ -16315,7 +16807,7 @@ getNCvx_ushort_float(const NC3_INFO* ncp, const NC_var *varp,
#line 980
#line 980
- lstatus = ncx_getn_ushort_float(&xp, nget, value);
+ lstatus = ncx_getn_ushort_schar(&xp, nget, value);
#line 980
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 980
@@ -16348,9 +16840,9 @@ getNCvx_ushort_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 981
-getNCvx_ushort_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 981
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 981
{
#line 981
@@ -16394,7 +16886,7 @@ getNCvx_ushort_double(const NC3_INFO* ncp, const NC_var *varp,
#line 981
#line 981
- lstatus = ncx_getn_ushort_double(&xp, nget, value);
+ lstatus = ncx_getn_ushort_uchar(&xp, nget, value);
#line 981
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 981
@@ -16427,9 +16919,9 @@ getNCvx_ushort_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 982
-getNCvx_ushort_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_short(const NC3_INFO* ncp, const NC_var *varp,
#line 982
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 982
{
#line 982
@@ -16473,7 +16965,7 @@ getNCvx_ushort_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 982
#line 982
- lstatus = ncx_getn_ushort_longlong(&xp, nget, value);
+ lstatus = ncx_getn_ushort_short(&xp, nget, value);
#line 982
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 982
@@ -16506,9 +16998,9 @@ getNCvx_ushort_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 983
-getNCvx_ushort_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_int(const NC3_INFO* ncp, const NC_var *varp,
#line 983
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 983
{
#line 983
@@ -16552,7 +17044,7 @@ getNCvx_ushort_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 983
#line 983
- lstatus = ncx_getn_ushort_uint(&xp, nget, value);
+ lstatus = ncx_getn_ushort_int(&xp, nget, value);
#line 983
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 983
@@ -16585,9 +17077,9 @@ getNCvx_ushort_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 984
-getNCvx_ushort_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_float(const NC3_INFO* ncp, const NC_var *varp,
#line 984
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 984
{
#line 984
@@ -16631,7 +17123,7 @@ getNCvx_ushort_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 984
#line 984
- lstatus = ncx_getn_ushort_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_ushort_float(&xp, nget, value);
#line 984
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 984
@@ -16664,9 +17156,9 @@ getNCvx_ushort_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 985
-getNCvx_ushort_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_double(const NC3_INFO* ncp, const NC_var *varp,
#line 985
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 985
{
#line 985
@@ -16710,7 +17202,7 @@ getNCvx_ushort_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 985
#line 985
- lstatus = ncx_getn_ushort_ushort(&xp, nget, value);
+ lstatus = ncx_getn_ushort_double(&xp, nget, value);
#line 985
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 985
@@ -16741,12 +17233,90 @@ getNCvx_ushort_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 985
+static int
+#line 986
+getNCvx_ushort_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 986
+ const size_t *start, size_t nelems, longlong *value)
+#line 986
+{
+#line 986
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 986
+ size_t remaining = varp->xsz * nelems;
+#line 986
+ int status = NC_NOERR;
+#line 986
+ const void *xp;
+#line 986
+
+#line 986
+ if(nelems == 0)
+#line 986
+ return NC_NOERR;
+#line 986
+
+#line 986
+ assert(value != NULL);
+#line 986
+
+#line 986
+ for(;;)
+#line 986
+ {
+#line 986
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 986
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 986
+
+#line 986
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 986
+ 0, (void **)&xp); /* cast away const */
+#line 986
+ if(lstatus != NC_NOERR)
+#line 986
+ return lstatus;
+#line 986
+
+#line 986
+ lstatus = ncx_getn_ushort_longlong(&xp, nget, value);
+#line 986
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 986
+ status = lstatus;
+#line 986
+
+#line 986
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 986
+
+#line 986
+ remaining -= extent;
+#line 986
+ if(remaining == 0)
+#line 986
+ break; /* normal loop exit */
+#line 986
+ offset += (off_t)extent;
+#line 986
+ value += nget;
+#line 986
+ }
+#line 986
+
+#line 986
+ return status;
+#line 986
+}
+#line 986
static int
#line 987
-getNCvx_uint_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 987
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 987
{
#line 987
@@ -16790,7 +17360,7 @@ getNCvx_uint_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 987
#line 987
- lstatus = ncx_getn_uint_schar(&xp, nget, value);
+ lstatus = ncx_getn_ushort_uint(&xp, nget, value);
#line 987
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 987
@@ -16823,9 +17393,9 @@ getNCvx_uint_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 988
-getNCvx_uint_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 988
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 988
{
#line 988
@@ -16869,7 +17439,7 @@ getNCvx_uint_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 988
#line 988
- lstatus = ncx_getn_uint_uchar(&xp, nget, value);
+ lstatus = ncx_getn_ushort_ulonglong(&xp, nget, value);
#line 988
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 988
@@ -16902,9 +17472,9 @@ getNCvx_uint_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 989
-getNCvx_uint_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ushort_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 989
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 989
{
#line 989
@@ -16948,7 +17518,7 @@ getNCvx_uint_short(const NC3_INFO* ncp, const NC_var *varp,
#line 989
#line 989
- lstatus = ncx_getn_uint_short(&xp, nget, value);
+ lstatus = ncx_getn_ushort_ushort(&xp, nget, value);
#line 989
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 989
@@ -16979,90 +17549,12 @@ getNCvx_uint_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 989
-static int
-#line 990
-getNCvx_uint_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 990
- const size_t *start, size_t nelems, int *value)
-#line 990
-{
-#line 990
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 990
- size_t remaining = varp->xsz * nelems;
-#line 990
- int status = NC_NOERR;
-#line 990
- const void *xp;
-#line 990
-
-#line 990
- if(nelems == 0)
-#line 990
- return NC_NOERR;
-#line 990
-
-#line 990
- assert(value != NULL);
-#line 990
-
-#line 990
- for(;;)
-#line 990
- {
-#line 990
- size_t extent = MIN(remaining, ncp->chunk);
-#line 990
- size_t nget = ncx_howmany(varp->type, extent);
-#line 990
-
-#line 990
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 990
- 0, (void **)&xp); /* cast away const */
-#line 990
- if(lstatus != NC_NOERR)
-#line 990
- return lstatus;
-#line 990
-
-#line 990
- lstatus = ncx_getn_uint_int(&xp, nget, value);
-#line 990
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 990
- status = lstatus;
-#line 990
-
-#line 990
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 990
-
-#line 990
- remaining -= extent;
-#line 990
- if(remaining == 0)
-#line 990
- break; /* normal loop exit */
-#line 990
- offset += (off_t)extent;
-#line 990
- value += nget;
-#line 990
- }
-#line 990
-
-#line 990
- return status;
-#line 990
-}
-#line 990
static int
#line 991
-getNCvx_uint_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 991
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 991
{
#line 991
@@ -17106,7 +17598,7 @@ getNCvx_uint_float(const NC3_INFO* ncp, const NC_var *varp,
#line 991
#line 991
- lstatus = ncx_getn_uint_float(&xp, nget, value);
+ lstatus = ncx_getn_uint_schar(&xp, nget, value);
#line 991
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 991
@@ -17139,9 +17631,9 @@ getNCvx_uint_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 992
-getNCvx_uint_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 992
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 992
{
#line 992
@@ -17185,7 +17677,7 @@ getNCvx_uint_double(const NC3_INFO* ncp, const NC_var *varp,
#line 992
#line 992
- lstatus = ncx_getn_uint_double(&xp, nget, value);
+ lstatus = ncx_getn_uint_uchar(&xp, nget, value);
#line 992
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 992
@@ -17218,9 +17710,9 @@ getNCvx_uint_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 993
-getNCvx_uint_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_short(const NC3_INFO* ncp, const NC_var *varp,
#line 993
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 993
{
#line 993
@@ -17264,7 +17756,7 @@ getNCvx_uint_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 993
#line 993
- lstatus = ncx_getn_uint_longlong(&xp, nget, value);
+ lstatus = ncx_getn_uint_short(&xp, nget, value);
#line 993
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 993
@@ -17297,9 +17789,9 @@ getNCvx_uint_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 994
-getNCvx_uint_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_int(const NC3_INFO* ncp, const NC_var *varp,
#line 994
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 994
{
#line 994
@@ -17343,7 +17835,7 @@ getNCvx_uint_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 994
#line 994
- lstatus = ncx_getn_uint_uint(&xp, nget, value);
+ lstatus = ncx_getn_uint_int(&xp, nget, value);
#line 994
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 994
@@ -17376,9 +17868,9 @@ getNCvx_uint_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 995
-getNCvx_uint_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_float(const NC3_INFO* ncp, const NC_var *varp,
#line 995
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 995
{
#line 995
@@ -17422,7 +17914,7 @@ getNCvx_uint_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 995
#line 995
- lstatus = ncx_getn_uint_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_uint_float(&xp, nget, value);
#line 995
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 995
@@ -17455,9 +17947,9 @@ getNCvx_uint_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 996
-getNCvx_uint_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_double(const NC3_INFO* ncp, const NC_var *varp,
#line 996
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 996
{
#line 996
@@ -17501,7 +17993,7 @@ getNCvx_uint_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 996
#line 996
- lstatus = ncx_getn_uint_ushort(&xp, nget, value);
+ lstatus = ncx_getn_uint_double(&xp, nget, value);
#line 996
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 996
@@ -17532,12 +18024,90 @@ getNCvx_uint_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 996
+static int
+#line 997
+getNCvx_uint_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 997
+ const size_t *start, size_t nelems, longlong *value)
+#line 997
+{
+#line 997
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 997
+ size_t remaining = varp->xsz * nelems;
+#line 997
+ int status = NC_NOERR;
+#line 997
+ const void *xp;
+#line 997
+
+#line 997
+ if(nelems == 0)
+#line 997
+ return NC_NOERR;
+#line 997
+
+#line 997
+ assert(value != NULL);
+#line 997
+
+#line 997
+ for(;;)
+#line 997
+ {
+#line 997
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 997
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 997
+
+#line 997
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 997
+ 0, (void **)&xp); /* cast away const */
+#line 997
+ if(lstatus != NC_NOERR)
+#line 997
+ return lstatus;
+#line 997
+
+#line 997
+ lstatus = ncx_getn_uint_longlong(&xp, nget, value);
+#line 997
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 997
+ status = lstatus;
+#line 997
+
+#line 997
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 997
+
+#line 997
+ remaining -= extent;
+#line 997
+ if(remaining == 0)
+#line 997
+ break; /* normal loop exit */
+#line 997
+ offset += (off_t)extent;
+#line 997
+ value += nget;
+#line 997
+ }
+#line 997
+
+#line 997
+ return status;
+#line 997
+}
+#line 997
static int
#line 998
-getNCvx_longlong_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 998
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 998
{
#line 998
@@ -17581,7 +18151,7 @@ getNCvx_longlong_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 998
#line 998
- lstatus = ncx_getn_longlong_schar(&xp, nget, value);
+ lstatus = ncx_getn_uint_uint(&xp, nget, value);
#line 998
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 998
@@ -17614,9 +18184,9 @@ getNCvx_longlong_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 999
-getNCvx_longlong_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 999
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 999
{
#line 999
@@ -17660,7 +18230,7 @@ getNCvx_longlong_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 999
#line 999
- lstatus = ncx_getn_longlong_uchar(&xp, nget, value);
+ lstatus = ncx_getn_uint_ulonglong(&xp, nget, value);
#line 999
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 999
@@ -17693,9 +18263,9 @@ getNCvx_longlong_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1000
-getNCvx_longlong_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_uint_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 1000
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 1000
{
#line 1000
@@ -17739,7 +18309,7 @@ getNCvx_longlong_short(const NC3_INFO* ncp, const NC_var *varp,
#line 1000
#line 1000
- lstatus = ncx_getn_longlong_short(&xp, nget, value);
+ lstatus = ncx_getn_uint_ushort(&xp, nget, value);
#line 1000
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1000
@@ -17770,90 +18340,12 @@ getNCvx_longlong_short(const NC3_INFO* ncp, const NC_var *varp,
}
#line 1000
-static int
-#line 1001
-getNCvx_longlong_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 1001
- const size_t *start, size_t nelems, int *value)
-#line 1001
-{
-#line 1001
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 1001
- size_t remaining = varp->xsz * nelems;
-#line 1001
- int status = NC_NOERR;
-#line 1001
- const void *xp;
-#line 1001
-
-#line 1001
- if(nelems == 0)
-#line 1001
- return NC_NOERR;
-#line 1001
-
-#line 1001
- assert(value != NULL);
-#line 1001
-
-#line 1001
- for(;;)
-#line 1001
- {
-#line 1001
- size_t extent = MIN(remaining, ncp->chunk);
-#line 1001
- size_t nget = ncx_howmany(varp->type, extent);
-#line 1001
-
-#line 1001
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 1001
- 0, (void **)&xp); /* cast away const */
-#line 1001
- if(lstatus != NC_NOERR)
-#line 1001
- return lstatus;
-#line 1001
-
-#line 1001
- lstatus = ncx_getn_longlong_int(&xp, nget, value);
-#line 1001
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 1001
- status = lstatus;
-#line 1001
-
-#line 1001
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 1001
-
-#line 1001
- remaining -= extent;
-#line 1001
- if(remaining == 0)
-#line 1001
- break; /* normal loop exit */
-#line 1001
- offset += (off_t)extent;
-#line 1001
- value += nget;
-#line 1001
- }
-#line 1001
-
-#line 1001
- return status;
-#line 1001
-}
-#line 1001
static int
#line 1002
-getNCvx_longlong_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 1002
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 1002
{
#line 1002
@@ -17897,7 +18389,7 @@ getNCvx_longlong_float(const NC3_INFO* ncp, const NC_var *varp,
#line 1002
#line 1002
- lstatus = ncx_getn_longlong_float(&xp, nget, value);
+ lstatus = ncx_getn_longlong_schar(&xp, nget, value);
#line 1002
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1002
@@ -17930,9 +18422,9 @@ getNCvx_longlong_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1003
-getNCvx_longlong_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 1003
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 1003
{
#line 1003
@@ -17976,7 +18468,7 @@ getNCvx_longlong_double(const NC3_INFO* ncp, const NC_var *varp,
#line 1003
#line 1003
- lstatus = ncx_getn_longlong_double(&xp, nget, value);
+ lstatus = ncx_getn_longlong_uchar(&xp, nget, value);
#line 1003
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1003
@@ -18009,9 +18501,9 @@ getNCvx_longlong_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1004
-getNCvx_longlong_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_short(const NC3_INFO* ncp, const NC_var *varp,
#line 1004
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 1004
{
#line 1004
@@ -18055,7 +18547,7 @@ getNCvx_longlong_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 1004
#line 1004
- lstatus = ncx_getn_longlong_longlong(&xp, nget, value);
+ lstatus = ncx_getn_longlong_short(&xp, nget, value);
#line 1004
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1004
@@ -18088,9 +18580,9 @@ getNCvx_longlong_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1005
-getNCvx_longlong_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_int(const NC3_INFO* ncp, const NC_var *varp,
#line 1005
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 1005
{
#line 1005
@@ -18134,7 +18626,7 @@ getNCvx_longlong_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 1005
#line 1005
- lstatus = ncx_getn_longlong_uint(&xp, nget, value);
+ lstatus = ncx_getn_longlong_int(&xp, nget, value);
#line 1005
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1005
@@ -18167,9 +18659,9 @@ getNCvx_longlong_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1006
-getNCvx_longlong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_float(const NC3_INFO* ncp, const NC_var *varp,
#line 1006
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 1006
{
#line 1006
@@ -18213,7 +18705,7 @@ getNCvx_longlong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 1006
#line 1006
- lstatus = ncx_getn_longlong_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_longlong_float(&xp, nget, value);
#line 1006
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1006
@@ -18246,9 +18738,9 @@ getNCvx_longlong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1007
-getNCvx_longlong_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_double(const NC3_INFO* ncp, const NC_var *varp,
#line 1007
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 1007
{
#line 1007
@@ -18292,7 +18784,7 @@ getNCvx_longlong_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 1007
#line 1007
- lstatus = ncx_getn_longlong_ushort(&xp, nget, value);
+ lstatus = ncx_getn_longlong_double(&xp, nget, value);
#line 1007
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1007
@@ -18323,12 +18815,90 @@ getNCvx_longlong_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 1007
+static int
+#line 1008
+getNCvx_longlong_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 1008
+ const size_t *start, size_t nelems, longlong *value)
+#line 1008
+{
+#line 1008
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 1008
+ size_t remaining = varp->xsz * nelems;
+#line 1008
+ int status = NC_NOERR;
+#line 1008
+ const void *xp;
+#line 1008
+
+#line 1008
+ if(nelems == 0)
+#line 1008
+ return NC_NOERR;
+#line 1008
+
+#line 1008
+ assert(value != NULL);
+#line 1008
+
+#line 1008
+ for(;;)
+#line 1008
+ {
+#line 1008
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 1008
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 1008
+
+#line 1008
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 1008
+ 0, (void **)&xp); /* cast away const */
+#line 1008
+ if(lstatus != NC_NOERR)
+#line 1008
+ return lstatus;
+#line 1008
+
+#line 1008
+ lstatus = ncx_getn_longlong_longlong(&xp, nget, value);
+#line 1008
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 1008
+ status = lstatus;
+#line 1008
+
+#line 1008
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 1008
+
+#line 1008
+ remaining -= extent;
+#line 1008
+ if(remaining == 0)
+#line 1008
+ break; /* normal loop exit */
+#line 1008
+ offset += (off_t)extent;
+#line 1008
+ value += nget;
+#line 1008
+ }
+#line 1008
+
+#line 1008
+ return status;
+#line 1008
+}
+#line 1008
static int
#line 1009
-getNCvx_ulonglong_schar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 1009
- const size_t *start, size_t nelems, schar *value)
+ const size_t *start, size_t nelems, uint *value)
#line 1009
{
#line 1009
@@ -18372,7 +18942,7 @@ getNCvx_ulonglong_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 1009
#line 1009
- lstatus = ncx_getn_ulonglong_schar(&xp, nget, value);
+ lstatus = ncx_getn_longlong_uint(&xp, nget, value);
#line 1009
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1009
@@ -18405,9 +18975,9 @@ getNCvx_ulonglong_schar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1010
-getNCvx_ulonglong_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 1010
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ulonglong *value)
#line 1010
{
#line 1010
@@ -18451,7 +19021,7 @@ getNCvx_ulonglong_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 1010
#line 1010
- lstatus = ncx_getn_ulonglong_uchar(&xp, nget, value);
+ lstatus = ncx_getn_longlong_ulonglong(&xp, nget, value);
#line 1010
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1010
@@ -18484,9 +19054,9 @@ getNCvx_ulonglong_uchar(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1011
-getNCvx_ulonglong_short(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_longlong_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 1011
- const size_t *start, size_t nelems, short *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 1011
{
#line 1011
@@ -18530,121 +19100,43 @@ getNCvx_ulonglong_short(const NC3_INFO* ncp, const NC_var *varp,
#line 1011
#line 1011
- lstatus = ncx_getn_ulonglong_short(&xp, nget, value);
+ lstatus = ncx_getn_longlong_ushort(&xp, nget, value);
#line 1011
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1011
status = lstatus;
-#line 1011
-
-#line 1011
- (void) ncio_rel(ncp->nciop, offset, 0);
-#line 1011
-
-#line 1011
- remaining -= extent;
-#line 1011
- if(remaining == 0)
-#line 1011
- break; /* normal loop exit */
-#line 1011
- offset += (off_t)extent;
-#line 1011
- value += nget;
-#line 1011
- }
-#line 1011
-
-#line 1011
- return status;
-#line 1011
-}
-#line 1011
-
-static int
-#line 1012
-getNCvx_ulonglong_int(const NC3_INFO* ncp, const NC_var *varp,
-#line 1012
- const size_t *start, size_t nelems, int *value)
-#line 1012
-{
-#line 1012
- off_t offset = NC_varoffset(ncp, varp, start);
-#line 1012
- size_t remaining = varp->xsz * nelems;
-#line 1012
- int status = NC_NOERR;
-#line 1012
- const void *xp;
-#line 1012
-
-#line 1012
- if(nelems == 0)
-#line 1012
- return NC_NOERR;
-#line 1012
-
-#line 1012
- assert(value != NULL);
-#line 1012
-
-#line 1012
- for(;;)
-#line 1012
- {
-#line 1012
- size_t extent = MIN(remaining, ncp->chunk);
-#line 1012
- size_t nget = ncx_howmany(varp->type, extent);
-#line 1012
-
-#line 1012
- int lstatus = ncio_get(ncp->nciop, offset, extent,
-#line 1012
- 0, (void **)&xp); /* cast away const */
-#line 1012
- if(lstatus != NC_NOERR)
-#line 1012
- return lstatus;
-#line 1012
-
-#line 1012
- lstatus = ncx_getn_ulonglong_int(&xp, nget, value);
-#line 1012
- if(lstatus != NC_NOERR && status == NC_NOERR)
-#line 1012
- status = lstatus;
-#line 1012
+#line 1011
-#line 1012
+#line 1011
(void) ncio_rel(ncp->nciop, offset, 0);
-#line 1012
+#line 1011
-#line 1012
+#line 1011
remaining -= extent;
-#line 1012
+#line 1011
if(remaining == 0)
-#line 1012
+#line 1011
break; /* normal loop exit */
-#line 1012
+#line 1011
offset += (off_t)extent;
-#line 1012
+#line 1011
value += nget;
-#line 1012
+#line 1011
}
-#line 1012
+#line 1011
-#line 1012
+#line 1011
return status;
-#line 1012
+#line 1011
}
-#line 1012
+#line 1011
+
static int
#line 1013
-getNCvx_ulonglong_float(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_schar(const NC3_INFO* ncp, const NC_var *varp,
#line 1013
- const size_t *start, size_t nelems, float *value)
+ const size_t *start, size_t nelems, schar *value)
#line 1013
{
#line 1013
@@ -18688,7 +19180,7 @@ getNCvx_ulonglong_float(const NC3_INFO* ncp, const NC_var *varp,
#line 1013
#line 1013
- lstatus = ncx_getn_ulonglong_float(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_schar(&xp, nget, value);
#line 1013
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1013
@@ -18721,9 +19213,9 @@ getNCvx_ulonglong_float(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1014
-getNCvx_ulonglong_double(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 1014
- const size_t *start, size_t nelems, double *value)
+ const size_t *start, size_t nelems, uchar *value)
#line 1014
{
#line 1014
@@ -18767,7 +19259,7 @@ getNCvx_ulonglong_double(const NC3_INFO* ncp, const NC_var *varp,
#line 1014
#line 1014
- lstatus = ncx_getn_ulonglong_double(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_uchar(&xp, nget, value);
#line 1014
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1014
@@ -18800,9 +19292,9 @@ getNCvx_ulonglong_double(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1015
-getNCvx_ulonglong_longlong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_short(const NC3_INFO* ncp, const NC_var *varp,
#line 1015
- const size_t *start, size_t nelems, longlong *value)
+ const size_t *start, size_t nelems, short *value)
#line 1015
{
#line 1015
@@ -18846,7 +19338,7 @@ getNCvx_ulonglong_longlong(const NC3_INFO* ncp, const NC_var *varp,
#line 1015
#line 1015
- lstatus = ncx_getn_ulonglong_longlong(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_short(&xp, nget, value);
#line 1015
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1015
@@ -18879,9 +19371,9 @@ getNCvx_ulonglong_longlong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1016
-getNCvx_ulonglong_uint(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_int(const NC3_INFO* ncp, const NC_var *varp,
#line 1016
- const size_t *start, size_t nelems, uint *value)
+ const size_t *start, size_t nelems, int *value)
#line 1016
{
#line 1016
@@ -18925,7 +19417,7 @@ getNCvx_ulonglong_uint(const NC3_INFO* ncp, const NC_var *varp,
#line 1016
#line 1016
- lstatus = ncx_getn_ulonglong_uint(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_int(&xp, nget, value);
#line 1016
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1016
@@ -18958,9 +19450,9 @@ getNCvx_ulonglong_uint(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1017
-getNCvx_ulonglong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_float(const NC3_INFO* ncp, const NC_var *varp,
#line 1017
- const size_t *start, size_t nelems, ulonglong *value)
+ const size_t *start, size_t nelems, float *value)
#line 1017
{
#line 1017
@@ -19004,7 +19496,7 @@ getNCvx_ulonglong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
#line 1017
#line 1017
- lstatus = ncx_getn_ulonglong_ulonglong(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_float(&xp, nget, value);
#line 1017
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1017
@@ -19037,9 +19529,9 @@ getNCvx_ulonglong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
static int
#line 1018
-getNCvx_ulonglong_ushort(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_double(const NC3_INFO* ncp, const NC_var *varp,
#line 1018
- const size_t *start, size_t nelems, ushort *value)
+ const size_t *start, size_t nelems, double *value)
#line 1018
{
#line 1018
@@ -19083,7 +19575,7 @@ getNCvx_ulonglong_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 1018
#line 1018
- lstatus = ncx_getn_ulonglong_ushort(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_double(&xp, nget, value);
#line 1018
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1018
@@ -19114,14 +19606,248 @@ getNCvx_ulonglong_ushort(const NC3_INFO* ncp, const NC_var *varp,
}
#line 1018
+static int
+#line 1019
+getNCvx_ulonglong_longlong(const NC3_INFO* ncp, const NC_var *varp,
+#line 1019
+ const size_t *start, size_t nelems, longlong *value)
+#line 1019
+{
+#line 1019
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 1019
+ size_t remaining = varp->xsz * nelems;
+#line 1019
+ int status = NC_NOERR;
+#line 1019
+ const void *xp;
+#line 1019
+
+#line 1019
+ if(nelems == 0)
+#line 1019
+ return NC_NOERR;
+#line 1019
+
+#line 1019
+ assert(value != NULL);
+#line 1019
+
+#line 1019
+ for(;;)
+#line 1019
+ {
+#line 1019
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 1019
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 1019
+
+#line 1019
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 1019
+ 0, (void **)&xp); /* cast away const */
+#line 1019
+ if(lstatus != NC_NOERR)
+#line 1019
+ return lstatus;
+#line 1019
+
+#line 1019
+ lstatus = ncx_getn_ulonglong_longlong(&xp, nget, value);
+#line 1019
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 1019
+ status = lstatus;
+#line 1019
+
+#line 1019
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 1019
+
+#line 1019
+ remaining -= extent;
+#line 1019
+ if(remaining == 0)
+#line 1019
+ break; /* normal loop exit */
+#line 1019
+ offset += (off_t)extent;
+#line 1019
+ value += nget;
+#line 1019
+ }
+#line 1019
+
+#line 1019
+ return status;
+#line 1019
+}
+#line 1019
+
+static int
+#line 1020
+getNCvx_ulonglong_uint(const NC3_INFO* ncp, const NC_var *varp,
+#line 1020
+ const size_t *start, size_t nelems, uint *value)
+#line 1020
+{
+#line 1020
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 1020
+ size_t remaining = varp->xsz * nelems;
+#line 1020
+ int status = NC_NOERR;
+#line 1020
+ const void *xp;
+#line 1020
+
+#line 1020
+ if(nelems == 0)
+#line 1020
+ return NC_NOERR;
+#line 1020
+
+#line 1020
+ assert(value != NULL);
+#line 1020
+
+#line 1020
+ for(;;)
+#line 1020
+ {
+#line 1020
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 1020
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 1020
+
+#line 1020
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 1020
+ 0, (void **)&xp); /* cast away const */
+#line 1020
+ if(lstatus != NC_NOERR)
+#line 1020
+ return lstatus;
+#line 1020
+
+#line 1020
+ lstatus = ncx_getn_ulonglong_uint(&xp, nget, value);
+#line 1020
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 1020
+ status = lstatus;
+#line 1020
+
+#line 1020
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 1020
+
+#line 1020
+ remaining -= extent;
+#line 1020
+ if(remaining == 0)
+#line 1020
+ break; /* normal loop exit */
+#line 1020
+ offset += (off_t)extent;
+#line 1020
+ value += nget;
+#line 1020
+ }
+#line 1020
+
+#line 1020
+ return status;
+#line 1020
+}
+#line 1020
+
+static int
+#line 1021
+getNCvx_ulonglong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+#line 1021
+ const size_t *start, size_t nelems, ulonglong *value)
+#line 1021
+{
+#line 1021
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 1021
+ size_t remaining = varp->xsz * nelems;
+#line 1021
+ int status = NC_NOERR;
+#line 1021
+ const void *xp;
+#line 1021
+
+#line 1021
+ if(nelems == 0)
+#line 1021
+ return NC_NOERR;
+#line 1021
+
+#line 1021
+ assert(value != NULL);
+#line 1021
#line 1021
-#ifdef NOTUSED
+ for(;;)
+#line 1021
+ {
+#line 1021
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 1021
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 1021
+
+#line 1021
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 1021
+ 0, (void **)&xp); /* cast away const */
+#line 1021
+ if(lstatus != NC_NOERR)
+#line 1021
+ return lstatus;
+#line 1021
+
+#line 1021
+ lstatus = ncx_getn_ulonglong_ulonglong(&xp, nget, value);
+#line 1021
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 1021
+ status = lstatus;
+#line 1021
+
+#line 1021
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 1021
+
+#line 1021
+ remaining -= extent;
+#line 1021
+ if(remaining == 0)
+#line 1021
+ break; /* normal loop exit */
+#line 1021
+ offset += (off_t)extent;
+#line 1021
+ value += nget;
+#line 1021
+ }
+#line 1021
+
+#line 1021
+ return status;
+#line 1021
+}
+#line 1021
+
static int
#line 1022
-getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
+getNCvx_ulonglong_ushort(const NC3_INFO* ncp, const NC_var *varp,
#line 1022
- const size_t *start, size_t nelems, uchar *value)
+ const size_t *start, size_t nelems, ushort *value)
#line 1022
{
#line 1022
@@ -19165,7 +19891,7 @@ getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
#line 1022
#line 1022
- lstatus = ncx_getn_schar_uchar(&xp, nget, value);
+ lstatus = ncx_getn_ulonglong_ushort(&xp, nget, value);
#line 1022
if(lstatus != NC_NOERR && status == NC_NOERR)
#line 1022
@@ -19196,6 +19922,88 @@ getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
}
#line 1022
+
+#line 1025
+#ifdef NOTUSED
+static int
+#line 1026
+getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
+#line 1026
+ const size_t *start, size_t nelems, uchar *value)
+#line 1026
+{
+#line 1026
+ off_t offset = NC_varoffset(ncp, varp, start);
+#line 1026
+ size_t remaining = varp->xsz * nelems;
+#line 1026
+ int status = NC_NOERR;
+#line 1026
+ const void *xp;
+#line 1026
+
+#line 1026
+ if(nelems == 0)
+#line 1026
+ return NC_NOERR;
+#line 1026
+
+#line 1026
+ assert(value != NULL);
+#line 1026
+
+#line 1026
+ for(;;)
+#line 1026
+ {
+#line 1026
+ size_t extent = MIN(remaining, ncp->chunk);
+#line 1026
+ size_t nget = ncx_howmany(varp->type, extent);
+#line 1026
+
+#line 1026
+ int lstatus = ncio_get(ncp->nciop, offset, extent,
+#line 1026
+ 0, (void **)&xp); /* cast away const */
+#line 1026
+ if(lstatus != NC_NOERR)
+#line 1026
+ return lstatus;
+#line 1026
+
+#line 1026
+ lstatus = ncx_getn_schar_uchar(&xp, nget, value);
+#line 1026
+ if(lstatus != NC_NOERR && status == NC_NOERR)
+#line 1026
+ status = lstatus;
+#line 1026
+
+#line 1026
+ (void) ncio_rel(ncp->nciop, offset, 0);
+#line 1026
+
+#line 1026
+ remaining -= extent;
+#line 1026
+ if(remaining == 0)
+#line 1026
+ break; /* normal loop exit */
+#line 1026
+ offset += (off_t)extent;
+#line 1026
+ value += nget;
+#line 1026
+ }
+#line 1026
+
+#line 1026
+ return status;
+#line 1026
+}
+#line 1026
+
#endif /*NOTUSED*/
/*
@@ -19341,7 +20149,7 @@ odo1(const size_t *const start, const size_t *const upper,
#endif
-#line 1184
+#line 1188
/* Define a macro to allow hash on two type values */
#define CASE(nc1,nc2) (nc1*256+nc2)
diff --git a/libsrc/putget.m4 b/libsrc/putget.m4
index bf37fb0..70987ba 100644
--- a/libsrc/putget.m4
+++ b/libsrc/putget.m4
@@ -704,15 +704,17 @@ putNCvx_$1_$2(NC3_INFO* ncp, const NC_var *varp,
size_t remaining = varp->xsz * nelems;
int status = NC_NOERR;
void *xp;
- void *fillp;
+ void *fillp=NULL;
if(nelems == 0)
return NC_NOERR;
assert(value != NULL);
+#ifdef ERANGE_FILL
fillp = malloc(varp->xsz);
- status = NC3_inq_var_fill(varp, fillp);
+ status = NC3_inq_var_fill(varp, fillp);
+#endif
for(;;)
{
@@ -741,7 +743,9 @@ putNCvx_$1_$2(NC3_INFO* ncp, const NC_var *varp,
value += nput;
}
+#ifdef ERANGE_FILL
free(fillp);
+#endif
return status;
}
diff --git a/libsrc/v1hpg.c b/libsrc/v1hpg.c
index e464c09..07c322c 100644
--- a/libsrc/v1hpg.c
+++ b/libsrc/v1hpg.c
@@ -1220,7 +1220,8 @@ NC_computeshapes(NC3_INFO* ncp)
if(first_rec == NULL)
first_rec = *vpp;
if((*vpp)->len == UINT32_MAX &&
- fIsSet(ncp->flags, NC_64BIT_OFFSET)) /* Flag for large last record */
+ (fIsSet(ncp->flags, NC_64BIT_OFFSET) ||
+ fIsSet(ncp->flags, NC_64BIT_DATA))) /* Flag for large last record */
ncp->recsize += (*vpp)->dsizes[0] * (*vpp)->xsz;
else
ncp->recsize += (*vpp)->len;
diff --git a/libsrc4/Makefile.in b/libsrc4/Makefile.in
index c73a022..e34375b 100644
--- a/libsrc4/Makefile.in
+++ b/libsrc4/Makefile.in
@@ -239,7 +239,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -274,7 +276,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c
index fe6e2f6..89526d8 100644
--- a/libsrc4/nc4internal.c
+++ b/libsrc4/nc4internal.c
@@ -102,6 +102,12 @@ nc4_check_name(const char *name, char *norm_name)
retval = nc_utf8_normalize((const unsigned char *)name,(unsigned char**)&temp);
if(retval != NC_NOERR)
return retval;
+
+ if(strlen(temp) > NC_MAX_NAME) {
+ free(temp);
+ return NC_EMAXNAME;
+ }
+
strcpy(norm_name, temp);
free(temp);
@@ -1603,4 +1609,3 @@ NC4_show_metadata(int ncid)
#endif /*LOGGING*/
return retval;
}
-
diff --git a/libsrcp/Makefile.in b/libsrcp/Makefile.in
index 4a35ab6..77814f1 100644
--- a/libsrcp/Makefile.in
+++ b/libsrcp/Makefile.in
@@ -236,7 +236,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -271,7 +273,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/nc-config.cmake.in b/nc-config.cmake.in
index f065e62..bd9bfee 100644
--- a/nc-config.cmake.in
+++ b/nc-config.cmake.in
@@ -13,68 +13,78 @@ cc="@CMAKE_C_COMPILER@"
cflags="-I at CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@"
libs="-L at CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ @NC_LIBS@"
-if [ -z "@USE_DAP@" -o -z "@ENABLE_DAP2@" ] ; then
-has_dap2=ON
-fi
-if [ -z $has_dap2 ]; then
+has_dap2="@ENABLE_DAP2@"
+if [ -z $has_dap2 -o "$has_dap2" = "OFF" ]; then
has_dap2="no"
else
has_dap2="yes"
fi
-has_dap4="@ENABLE_DAP4"
+has_dap4="@ENABLE_DAP4@"
+if [ -z $has_dap4 -o "$has_dap4" = "OFF" ]; then
+ has_dap4="no"
+else
+ has_dap4="yes"
+fi
has_nc2="@BUILD_V2@"
-if [ -z $has_nc2 -o "$has_nc2" = "OFF" ]; then
+if [ -z "$has_nc2" -o "$has_nc2" = "OFF" ]; then
has_nc2="no"
else
has_nc2="yes"
fi
has_nc4="@USE_NETCDF4@"
-if [ -z $has_nc4 ]; then
+if [ -z "$has_nc4" -o "$has_nc4" = "OFF" ]; then
has_nc4="no"
else
has_nc4="yes"
fi
has_logging="@ENABLE_LOGGING@"
-if [ -z $has_logging ]; then
+if [ -z "$has_logging" -o "$has_logging" = "OFF" ]; then
has_logging="no"
else
has_logging="yes"
fi
has_hdf4="@USE_HDF4@"
-if [ -z $has_hdf4 ]; then
+if [ -z "$has_hdf4" -o "$has_hdf4" = "OFF" ]; then
has_hdf4="no"
else
has_hdf4="yes"
fi
has_pnetcdf="@USE_PNETCDF@"
-if [ -z $has_pnetcdf ]; then
+if [ -z "$has_pnetcdf" -o "$has_pnetcdf" = "OFF" ]; then
has_pnetcdf="no"
else
has_pnetcdf="yes"
fi
has_hdf5="@USE_HDF5@"
-if [ -z $has_hdf5 -o "$has_hdf5" = "OFF" ]; then
+if [ -z "$has_hdf5" -o "$has_hdf5" = "OFF" ]; then
has_hdf5="no"
else
has_hdf5="yes"
fi
has_szlib="@USE_SZLIB@"
-if [ -z $has_szlib ]; then
+if [ -z "$has_szlib" -o "$has_szlib" = "OFF" ]; then
has_szlib="no"
else
has_szlib="yes"
fi
+has_cdf5="@ENABLE_CDF5@"
+if [ -z "has_cdf5" -o "$has_cdf5" = "OFF" -o "$has_cdf5" = "FALSE" ]; then
+ has_cdf5="no"
+else
+ has_cdf5="yes"
+fi
+
version="@PACKAGE@ @VERSION@"
@@ -128,7 +138,7 @@ Available values for OPTION include:
--has-fortran whether Fortran API is installed
--has-dap2 whether OPeNDAP (DAP2) is enabled in this build
--has-dap4 whether DAP4 is enabled in this build
- --has-dap same as --has-dp (Deprecated)
+ --has-dap same as --has-dap2 (Deprecated)
--has-nc2 whether NetCDF-2 API is enabled
--has-nc4 whether NetCDF-4/HDF-5 is enabled in this build
--has-hdf5 whether HDF5 is used in build (always the same as --has-nc4)
@@ -136,6 +146,7 @@ Available values for OPTION include:
--has-logging whether logging is enabled with --enable-logging.
--has-pnetcdf whether parallel-netcdf (a.k.a. pnetcdf) was used in build
--has-szlib whether szlib is included in build
+ --has-cdf5 whether cdf5 support is included in build
--libs library linking information for netcdf
--prefix Install prefix
--includedir Include directory
@@ -202,7 +213,7 @@ if [ -f "$nfconf" ]; then
echo " --has-f03 -> $has_f03"
echo
fi
- echo " --has-dap -> $has_dap"
+ echo " --has-dap -> $has_dap2"
echo " --has-dap2 -> $has_dap2"
echo " --has-dap4 -> $has_dap4"
echo " --has-nc2 -> $has_nc2"
@@ -212,6 +223,7 @@ fi
echo " --has-logging-> $has_logging"
echo " --has-pnetcdf-> $has_pnetcdf"
echo " --has-szlib -> $has_szlib"
+ echo " --has-cdf5 -> $has_cdf5"
echo
echo " --prefix -> $prefix"
echo " --includedir-> $includedir"
@@ -252,7 +264,7 @@ while test $# -gt 0; do
;;
--has-dap)
- echo $has_dap2 $has_dap4
+ echo $has_dap2
;;
--has-dap2)
@@ -291,6 +303,10 @@ while test $# -gt 0; do
echo $has_szlib
;;
+ --has-cdf5)
+ echo $has_cdf5
+ ;;
+
--libs)
echo $libs
;;
diff --git a/nc-config.in b/nc-config.in
index 9e3e57f..b0d8fd7 100644
--- a/nc-config.in
+++ b/nc-config.in
@@ -21,8 +21,12 @@ has_hdf4="@HAS_HDF4@"
has_pnetcdf="@HAS_PNETCDF@"
has_hdf5="@HAS_HDF5@"
has_logging="@HAS_LOGGING@"
+has_cdf5="@HAS_CDF5@"
+has_szlib="@HAS_SZLIB@"
version="@PACKAGE_NAME@ @PACKAGE_VERSION@"
+
+
has_fortran="no"
has_f90="no"
has_f03="no"
@@ -79,8 +83,9 @@ Available values for OPTION include:
--has-logging whether logging is enabled with --enable-logging.
--has-pnetcdf whether parallel-netcdf (a.k.a. pnetcdf) was used in build
--has-szlib whether szlib is included in build
+ --has-cdf5 whether cdf5 support is included in build
--libs library linking information for netcdf
- --prefix Install prefix
+ --prefix Install prefixx
--includedir Include directory
--libdir Library directory
--version Library version
@@ -154,6 +159,7 @@ fi
echo " --has-logging-> $has_logging"
echo " --has-pnetcdf-> $has_pnetcdf"
echo " --has-szlib -> $has_szlib"
+ echo " --has-cdf5 -> $has_cdf5"
echo
echo " --prefix -> $prefix"
echo " --includedir-> $includedir"
@@ -229,6 +235,10 @@ while test $# -gt 0; do
echo $has_szlib
;;
+ --has-cdf5)
+ echo $has_cdf5
+ ;;
+
--libs)
echo $libs
;;
diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt
index 209bacd..a081aa3 100644
--- a/nc_test/CMakeLists.txt
+++ b/nc_test/CMakeLists.txt
@@ -51,7 +51,7 @@ IF(USE_PNETCDF)
ENDIF()
IF(LARGE_FILE_TESTS)
- SET(TESTS ${TESTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large)
+ SET(TESTS ${TESTS} quick_large_files tst_big_var6 tst_big_var2 tst_big_rvar tst_big_var tst_large tst_large_cdf5)
IF(NOT MSVC)
SET(TESTS ${TESTS} large_files)
ENDIF()
diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am
index 8e03ff3..87d074e 100644
--- a/nc_test/Makefile.am
+++ b/nc_test/Makefile.am
@@ -16,7 +16,8 @@ tst_*.nc t_nc.nc large_files.nc quick_large_files.nc \
tst_diskless.nc tst_diskless2.nc \
tst_diskless3.nc tst_diskless3_file.cdl tst_diskless3_memory.cdl \
tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc nc_test_cdf5.nc \
-unlim.nc tst_inq_type.nc tst_elatefill.nc tst_global_fillval.nc
+unlim.nc tst_inq_type.nc tst_elatefill.nc tst_global_fillval.nc \
+tst_large_cdf5.nc
check_PROGRAMS =
@@ -45,7 +46,7 @@ AM_CPPFLAGS += -I$(top_builddir)/liblib -I$(top_builddir)/include -I$(top_srcdir
# If the user asked for large file tests, then add them.
if LARGE_FILE_TESTS
TESTPROGRAMS += quick_large_files tst_big_var6 tst_big_var2 \
-tst_big_rvar tst_big_var tst_large large_files
+tst_big_rvar tst_big_var tst_large large_files tst_large_cdf5
endif # LARGE_FILE_TESTS
if BUILD_BENCHMARKS
diff --git a/nc_test/Makefile.in b/nc_test/Makefile.in
index cbc8dda..b7afcee 100644
--- a/nc_test/Makefile.in
+++ b/nc_test/Makefile.in
@@ -111,7 +111,7 @@ check_PROGRAMS = $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7)
# If the user asked for large file tests, then add them.
@LARGE_FILE_TESTS_TRUE at am__append_5 = quick_large_files tst_big_var6 tst_big_var2 \
- at LARGE_FILE_TESTS_TRUE@tst_big_rvar tst_big_var tst_large large_files
+ at LARGE_FILE_TESTS_TRUE@tst_big_rvar tst_big_var tst_large large_files tst_large_cdf5
@BUILD_BENCHMARKS_TRUE at am__append_6 = testnc3perf
@BUILD_BENCHMARKS_TRUE at am__append_7 = benchmark.nc
@@ -149,7 +149,8 @@ CONFIG_CLEAN_VPATH_FILES =
@LARGE_FILE_TESTS_TRUE@ tst_big_var2$(EXEEXT) \
@LARGE_FILE_TESTS_TRUE@ tst_big_rvar$(EXEEXT) \
@LARGE_FILE_TESTS_TRUE@ tst_big_var$(EXEEXT) tst_large$(EXEEXT) \
- at LARGE_FILE_TESTS_TRUE@ large_files$(EXEEXT)
+ at LARGE_FILE_TESTS_TRUE@ large_files$(EXEEXT) \
+ at LARGE_FILE_TESTS_TRUE@ tst_large_cdf5$(EXEEXT)
@BUILD_BENCHMARKS_TRUE at am__EXEEXT_4 = testnc3perf$(EXEEXT)
am__EXEEXT_5 = t_nc$(EXEEXT) tst_small$(EXEEXT) nc_test$(EXEEXT) \
tst_misc$(EXEEXT) tst_norm$(EXEEXT) tst_names$(EXEEXT) \
@@ -260,6 +261,10 @@ tst_large_SOURCES = tst_large.c
tst_large_OBJECTS = tst_large.$(OBJEXT)
tst_large_LDADD = $(LDADD)
tst_large_DEPENDENCIES = ${top_builddir}/liblib/libnetcdf.la
+tst_large_cdf5_SOURCES = tst_large_cdf5.c
+tst_large_cdf5_OBJECTS = tst_large_cdf5.$(OBJEXT)
+tst_large_cdf5_LDADD = $(LDADD)
+tst_large_cdf5_DEPENDENCIES = ${top_builddir}/liblib/libnetcdf.la
tst_meta_SOURCES = tst_meta.c
tst_meta_OBJECTS = tst_meta.$(OBJEXT)
tst_meta_LDADD = $(LDADD)
@@ -351,21 +356,21 @@ SOURCES = large_files.c $(nc_test_SOURCES) quick_large_files.c t_nc.c \
tst_big_rvar.c tst_big_var.c tst_big_var2.c tst_big_var6.c \
tst_diskless.c tst_diskless2.c tst_diskless3.c tst_diskless4.c \
tst_diskless5.c tst_elatefill.c tst_formatx_pnetcdf.c \
- tst_global_fillval.c tst_inq_type.c tst_large.c tst_meta.c \
- tst_misc.c tst_names.c tst_nofill.c tst_nofill2.c \
- tst_nofill3.c tst_norm.c tst_parallel2.c tst_pnetcdf.c \
- tst_put_vars.c tst_small.c tst_utf8_phrases.c \
- tst_utf8_validate.c
+ tst_global_fillval.c tst_inq_type.c tst_large.c \
+ tst_large_cdf5.c tst_meta.c tst_misc.c tst_names.c \
+ tst_nofill.c tst_nofill2.c tst_nofill3.c tst_norm.c \
+ tst_parallel2.c tst_pnetcdf.c tst_put_vars.c tst_small.c \
+ tst_utf8_phrases.c tst_utf8_validate.c
DIST_SOURCES = large_files.c $(nc_test_SOURCES) quick_large_files.c \
t_nc.c $(am__testnc3perf_SOURCES_DIST) tst_addvar.c tst_atts.c \
tst_atts3.c tst_big_rvar.c tst_big_var.c tst_big_var2.c \
tst_big_var6.c tst_diskless.c tst_diskless2.c tst_diskless3.c \
tst_diskless4.c tst_diskless5.c tst_elatefill.c \
tst_formatx_pnetcdf.c tst_global_fillval.c tst_inq_type.c \
- tst_large.c tst_meta.c tst_misc.c tst_names.c tst_nofill.c \
- tst_nofill2.c tst_nofill3.c tst_norm.c tst_parallel2.c \
- tst_pnetcdf.c tst_put_vars.c tst_small.c tst_utf8_phrases.c \
- tst_utf8_validate.c
+ tst_large.c tst_large_cdf5.c tst_meta.c tst_misc.c tst_names.c \
+ tst_nofill.c tst_nofill2.c tst_nofill3.c tst_norm.c \
+ tst_parallel2.c tst_pnetcdf.c tst_put_vars.c tst_small.c \
+ tst_utf8_phrases.c tst_utf8_validate.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -642,7 +647,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -677,7 +684,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
@@ -787,7 +795,7 @@ CLEANFILES = nc_test_classic.nc nc_test_64bit.nc nc_test_netcdf4.nc \
tst_diskless3_file.cdl tst_diskless3_memory.cdl \
tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc \
nc_test_cdf5.nc unlim.nc tst_inq_type.nc tst_elatefill.nc \
- tst_global_fillval.nc $(am__append_7) ncx.c
+ tst_global_fillval.nc tst_large_cdf5.nc $(am__append_7) ncx.c
# These are the tests which are always run.
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm tst_names \
@@ -949,6 +957,10 @@ tst_large$(EXEEXT): $(tst_large_OBJECTS) $(tst_large_DEPENDENCIES) $(EXTRA_tst_l
@rm -f tst_large$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tst_large_OBJECTS) $(tst_large_LDADD) $(LIBS)
+tst_large_cdf5$(EXEEXT): $(tst_large_cdf5_OBJECTS) $(tst_large_cdf5_DEPENDENCIES) $(EXTRA_tst_large_cdf5_DEPENDENCIES)
+ @rm -f tst_large_cdf5$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(tst_large_cdf5_OBJECTS) $(tst_large_cdf5_LDADD) $(LIBS)
+
tst_meta$(EXEEXT): $(tst_meta_OBJECTS) $(tst_meta_DEPENDENCIES) $(EXTRA_tst_meta_DEPENDENCIES)
@rm -f tst_meta$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(tst_meta_OBJECTS) $(tst_meta_LDADD) $(LIBS)
@@ -1034,6 +1046,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_global_fillval.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_inq_type.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_large.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_large_cdf5.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_meta.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_misc.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_names.Po at am__quote@
@@ -1475,6 +1488,13 @@ large_files.log: large_files$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+tst_large_cdf5.log: tst_large_cdf5$(EXEEXT)
+ @p='tst_large_cdf5$(EXEEXT)'; \
+ b='tst_large_cdf5'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
testnc3perf.log: testnc3perf$(EXEEXT)
@p='testnc3perf$(EXEEXT)'; \
b='testnc3perf'; \
diff --git a/nc_test/nc_test.c b/nc_test/nc_test.c
index f4c27e4..dbb03b0 100644
--- a/nc_test/nc_test.c
+++ b/nc_test/nc_test.c
@@ -9,6 +9,8 @@ int numVars; /* number of variables */
int numTypes; /* number of netCDF data types to test */
#include "tests.h"
+#include "config.h"
+
/*
* Test driver for netCDF-3 interface. This program performs tests against
@@ -130,14 +132,19 @@ main(int argc, char *argv[])
fprintf(stderr, "\n\nSwitching to 64-bit offset format.\n");
strcpy(testfile, "nc_test_64bit.nc");
break;
+
case NC_FORMAT_CDF5:
- nc_set_default_format(NC_FORMAT_CDF5, NULL);
+#ifdef USE_CDF5
+ nc_set_default_format(NC_FORMAT_CDF5, NULL);
fprintf(stderr, "\n\nSwitching to 64-bit data format.\n");
strcpy(testfile, "nc_test_cdf5.nc");
numGatts = NGATTS;
numVars = NVARS;
numTypes = NTYPES;
break;
+#else
+ continue;
+#endif
case NC_FORMAT_NETCDF4_CLASSIC:
case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */
#ifdef USE_NETCDF4
diff --git a/nc_test/t_nc.c b/nc_test/t_nc.c
index 09cd49c..a134af8 100644
--- a/nc_test/t_nc.c
+++ b/nc_test/t_nc.c
@@ -5,11 +5,11 @@
Program to create a cdf, exercise all cdf functions. Creates cdf,
stuff it full of numbers, closes it. Then reopens it, and checks
for consistency. Leaves the file around afterwards.
-
+
Based on a program to test the nasa look-alike program, so not the
most appropropriate test. See ../nctest for a complete spec test.
*/
-
+
#define REDEF
/* #define SYNCDEBUG */
@@ -199,32 +199,32 @@ createtestvars(int id, const struct tcdfvar *testvars, size_t count)
{
assert(nc_def_var(id, vp->mnem, vp->type, vp->ndims, vp->dims,
&varid)
- == NC_NOERR );
+ == NC_NOERR );
assert(
nc_put_att_text(id,ii,reqattr[0],strlen(vp->units),
vp->units)
- == NC_NOERR);
+ == NC_NOERR);
assert(
nc_put_att_double(id,ii,reqattr[1],NC_DOUBLE,1,
&vp->validmin)
- == NC_NOERR);
+ == NC_NOERR);
assert(
nc_put_att_double(id,ii,reqattr[2],NC_DOUBLE,1,
&vp->validmax)
- == NC_NOERR);
+ == NC_NOERR);
assert(
nc_put_att_double(id,ii,reqattr[3],NC_DOUBLE,1,
&vp->scalemin)
- == NC_NOERR);
+ == NC_NOERR);
assert(
nc_put_att_double(id,ii,reqattr[4],NC_DOUBLE,1,
&vp->scalemax)
- == NC_NOERR);
+ == NC_NOERR);
assert(
nc_put_att_text(id,ii,reqattr[5],strlen(vp->fieldnam),
vp->fieldnam)
- == NC_NOERR);
+ == NC_NOERR);
}
}
@@ -256,7 +256,7 @@ fill_seq(int id)
{
size_t *cc = vindices;
while (cc < &vindices[num_dims])
- *cc++ = 0;
+ *cc++ = 0;
}
sizes[0] = NUM_RECS;
@@ -277,7 +277,7 @@ check_fill_seq(int id)
sizes[0] = NUM_RECS;
cc = vindices;
while (cc < &vindices[num_dims])
- *cc++ = 0;
+ *cc++ = 0;
/* ripple counter */
cc = vindices;
@@ -288,7 +288,7 @@ check_fill_seq(int id)
{
if (mm == &sizes[num_dims - 1])
{
- if(nc_get_var1_float(id, Float_id, vindices, &got.fl[0]) == -1)
+ if(nc_get_var1_float(id, Float_id, vindices, &got.fl[0]) == -1)
goto bad_ret;
/* val = (float) ii; */
/* if(val != got.fl[0]) */
@@ -360,8 +360,10 @@ main(int argc, char *argv[])
#ifdef USE_PNETCDF
MPI_Init(&argc, &argv);
- cmode |= (NC_PNETCDF);
+ cmode |= (NC_PNETCDF);
+#ifdef USE_CDF5
cmode |= (NC_64BIT_DATA);
+#endif
ret = nc_create_par(fname,cmode, MPI_COMM_WORLD, MPI_INFO_NULL, &id);
#else
ret = nc__create(fname,cmode, initialsz, &chunksz, &id);
@@ -374,7 +376,7 @@ main(int argc, char *argv[])
fprintf(stderr,"Error %s in file %s at line %d\n",nc_strerror(ret),__FILE__,__LINE__);
exit(ret);
}
-
+
assert( nc_put_att_text(id, NC_GLOBAL,
"TITLE", 12, "another name") == NC_NOERR);
assert( nc_get_att_text(id, NC_GLOBAL,
@@ -391,7 +393,7 @@ main(int argc, char *argv[])
createtestdims(id, NUM_DIMS, sizes, dim_names);
testdims(id, NUM_DIMS, sizes, dim_names);
- createtestvars(id, testvars, NUM_TESTVARS);
+ createtestvars(id, testvars, NUM_TESTVARS);
{
int ifill = -1; double dfill = -9999;
@@ -403,7 +405,7 @@ main(int argc, char *argv[])
#ifdef REDEF
assert( nc__enddef(id, 0, align, 0, 2*align) == NC_NOERR );
- assert( nc_put_var1_int(id, Long_id, indices[3], &birthday)
+ assert( nc_put_var1_int(id, Long_id, indices[3], &birthday)
== NC_NOERR );
fill_seq(id);
assert( nc_redef(id) == NC_NOERR );
@@ -487,7 +489,7 @@ main(int argc, char *argv[])
/* (void) printf("reopen id = %d for filename %s\n", */
/* id, fname); */
- /* NC */
+ /* NC */
/* (void) printf("NC "); */
assert( nc_inq(id, &(cdesc->num_dims), &(cdesc->num_vars),
&(cdesc->num_attrs), &(cdesc->xtendim) ) == NC_NOERR);
@@ -495,7 +497,7 @@ main(int argc, char *argv[])
assert(cdesc->num_attrs == 1);
assert(cdesc->num_vars == NUM_TESTVARS);
/* (void) printf("done\n"); */
-
+
/* GATTR */
/* (void) printf("GATTR "); */
@@ -512,7 +514,7 @@ main(int argc, char *argv[])
/* (void) printf("VAR "); */
assert( cdesc->num_vars == NUM_TESTVARS );
- for(ii = 0; ii < cdesc->num_vars; ii++, tvp++ )
+ for(ii = 0; ii < cdesc->num_vars; ii++, tvp++ )
{
int jj;
assert( nc_inq_var(id, ii,
@@ -546,7 +548,7 @@ main(int argc, char *argv[])
/* VATTR */
/* (void) printf("VATTR\n"); */
- for(jj=0; jj<vdesc->num_attrs; jj++ )
+ for(jj=0; jj<vdesc->num_attrs; jj++ )
{
assert( nc_inq_attname(id, ii, jj, adesc->mnem) == NC_NOERR);
if( strcmp(adesc->mnem, reqattr[jj]) != 0 )
@@ -561,7 +563,7 @@ main(int argc, char *argv[])
!= -1) {
assert( adesc->type == NC_CHAR );
assert( adesc->len == strlen(tvp->units) );
- assert( nc_get_att_text(id,ii,reqattr[0],buf)== NC_NOERR);
+ assert( nc_get_att_text(id,ii,reqattr[0],buf)== NC_NOERR);
buf[adesc->len] = 0;
assert( strcmp(tvp->units, buf) == 0);
}
@@ -610,7 +612,7 @@ main(int argc, char *argv[])
{
assert( adesc->type == NC_CHAR );
assert( adesc->len == strlen(tvp->fieldnam) );
- assert( nc_get_att_text(id,ii,reqattr[5],buf)== NC_NOERR);
+ assert( nc_get_att_text(id,ii,reqattr[5],buf)== NC_NOERR);
buf[adesc->len] = 0;
assert( strcmp(tvp->fieldnam, buf) == 0);
}
diff --git a/nc_test/test_get.c b/nc_test/test_get.c
new file mode 100644
index 0000000..f9629d4
--- /dev/null
+++ b/nc_test/test_get.c
@@ -0,0 +1,12203 @@
+/* Do not edit this file. It is produced from the corresponding .m4 source */
+/*
+ * Copyright (C) 2003, Northwestern University and Argonne National Laboratory
+ * See COPYRIGHT notice in top-level directory.
+ */
+/* $Id: test_get.m4 2672 2016-12-03 19:23:53Z wkliao $ */
+
+
+#include "tests.h"
+
+#ifdef USE_PNETCDF
+#include <pnetcdf.h>
+#ifndef PNETCDF_VERSION_MAJOR
+#error("PNETCDF_VERSION_MAJOR is not defined in pnetcdf.h")
+#endif
+#ifndef PNETCDF_VERSION_MINOR
+#error("PNETCDF_VERSION_MAJOR is not defined in pnetcdf.h")
+#endif
+#endif
+
+
+
+
+
+
+
+
+
+
+int
+test_nc_get_var1_text(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ text value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_text(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_text(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_text(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_text(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ err = nc_get_var1_text(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_TEXT)) {
+ if (1) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_TEXT)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_schar(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ schar value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_schar(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_schar(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_schar(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_schar(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+ err = nc_get_var1_schar(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_SCHAR)) {
+ if ((expect >= schar_min && expect <= schar_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_SCHAR)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_uchar(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ uchar value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_uchar(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_uchar(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_uchar(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_uchar(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+ err = nc_get_var1_uchar(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_UCHAR)) {
+ if ((expect >= uchar_min && expect <= uchar_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ /* in put_vars(), API _put_vara_double() is used to
+ * write the NC_BYTE variables to files. In this
+ * case, NC_BYTE variables are treated as signed
+ * for CDF-1 and 2 formats. Thus, we must skip the
+ * equal test below for uchar.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 && var_type[i] == NC_BYTE && expect > schar_max) continue;
+ IF (!equal((double)value[0], expect, var_type[i], NCT_UCHAR)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_short(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ short value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_short(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_short(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_short(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_short(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SHORT);
+ err = nc_get_var1_short(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_SHORT)) {
+ if ((expect >= short_min && expect <= short_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_SHORT)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_int(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ int value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_int(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_int(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_int(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_int(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_INT);
+ err = nc_get_var1_int(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_INT)) {
+ if ((expect >= int_min && expect <= int_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_INT)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_long(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ long value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_long(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_long(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_long(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_long(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONG);
+ err = nc_get_var1_long(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_LONG)) {
+ if ((expect >= long_min && expect <= long_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_LONG)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_float(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ float value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_float(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_float(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_float(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_float(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+ err = nc_get_var1_float(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_FLOAT)) {
+ if ((expect >= float_min && expect <= float_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_FLOAT)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_double(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ double value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_double(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_double(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_double(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_double(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+ err = nc_get_var1_double(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_DOUBLE)) {
+ if ((expect >= double_min && expect <= double_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_DOUBLE)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_ushort(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ ushort value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_ushort(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_ushort(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_ushort(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_ushort(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_USHORT);
+ err = nc_get_var1_ushort(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_USHORT)) {
+ if ((expect >= ushort_min && expect <= ushort_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_USHORT)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_uint(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ uint value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_uint(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_uint(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_uint(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_uint(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UINT);
+ err = nc_get_var1_uint(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_UINT)) {
+ if ((expect >= uint_min && expect <= uint_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_UINT)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_longlong(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ longlong value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_longlong(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_longlong(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_longlong(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_longlong(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+ err = nc_get_var1_longlong(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_LONGLONG)) {
+ if ((expect >= longlong_min && expect <= longlong_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_LONGLONG)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var1_ulonglong(void)
+{
+ int i, err, ncid, cdf_format;
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect;
+ ulonglong value[1];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_ulonglong(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1_ulonglong(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1_ulonglong(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_get_var1_ulonglong(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ /* when file is created the variable contents are generated by
+ * hash functions */
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+ err = nc_get_var1_ulonglong(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, expect,var_type[i], NCT_ULONGLONG)) {
+ if ((expect >= ulonglong_min && expect <= ulonglong_max)) {
+ IF (err != NC_NOERR) {
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+
+ IF (!equal((double)value[0], expect, var_type[i], NCT_ULONGLONG)) {
+ error("expected: %G, got: %G", expect, (double)value[0]);
+ }
+ ELSE_NOK
+ }
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+
+
+int
+test_nc_get_var_text(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ text value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_text(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_text(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_text(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_TEXT)) {
+ if (var_type[i] != NC_CHAR)
+ allInIntRange &= 1;
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_text(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (1) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_TEXT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_uchar(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ uchar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_uchar(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_uchar(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_uchar(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_UCHAR)) {
+
+ allInIntRange &= (expect[j] >= uchar_min && expect[j] <= uchar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_uchar(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR) && (expect[j] >= uchar_min && expect[j] <= uchar_max)) {
+
+ /* in put_vars(), API _put_vara_double() is used to
+ * write the NC_BYTE variables to files. In this
+ * case, NC_BYTE variables are treated as signed
+ * for CDF-1 and 2 formats. Thus, we must skip the
+ * equal test below for uchar.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 && var_type[i] == NC_BYTE && expect[j] > schar_max) continue;
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_UCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_schar(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ schar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_schar(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_schar(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_schar(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_SCHAR)) {
+
+ allInIntRange &= (expect[j] >= schar_min && expect[j] <= schar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_schar(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR) && (expect[j] >= schar_min && expect[j] <= schar_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_SCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_short(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ short value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_short(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_short(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_short(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_SHORT)) {
+
+ allInIntRange &= (expect[j] >= short_min && expect[j] <= short_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_short(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT) && (expect[j] >= short_min && expect[j] <= short_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_SHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_int(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ int value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_int(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_int(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_int(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_INT);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_INT)) {
+
+ allInIntRange &= (expect[j] >= int_min && expect[j] <= int_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_int(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT) && (expect[j] >= int_min && expect[j] <= int_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_INT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_long(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ long value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_long(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_long(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_long(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONG);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_LONG)) {
+
+ allInIntRange &= (expect[j] >= long_min && expect[j] <= long_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_long(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG) && (expect[j] >= long_min && expect[j] <= long_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_LONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_float(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ float value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_float(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_float(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_float(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_FLOAT)) {
+
+ allInIntRange &= (expect[j] >= float_min && expect[j] <= float_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_float(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT) && (expect[j] >= float_min && expect[j] <= float_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_FLOAT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_double(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ double value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_double(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_double(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_double(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_DOUBLE)) {
+
+ allInIntRange &= (expect[j] >= double_min && expect[j] <= double_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_double(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE) && (expect[j] >= double_min && expect[j] <= double_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_DOUBLE)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_ushort(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ ushort value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_ushort(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_ushort(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_ushort(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_USHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_USHORT)) {
+
+ allInIntRange &= (expect[j] >= ushort_min && expect[j] <= ushort_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_ushort(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT) && (expect[j] >= ushort_min && expect[j] <= ushort_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_USHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_uint(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ uint value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_uint(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_uint(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_uint(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UINT);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_UINT)) {
+
+ allInIntRange &= (expect[j] >= uint_min && expect[j] <= uint_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_uint(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT) && (expect[j] >= uint_min && expect[j] <= uint_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_UINT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_longlong(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ longlong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_longlong(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_longlong(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_longlong(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_LONGLONG)) {
+
+ allInIntRange &= (expect[j] >= longlong_min && expect[j] <= longlong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_longlong(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG) && (expect[j] >= longlong_min && expect[j] <= longlong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_LONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_var_ulonglong(void)
+{
+ int i, err, ncid, cdf_format;
+ int allInExtRange; /* all values within range of external data type */
+ int allInIntRange; /* all values within range of internal data type */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double expect[MAX_NELS];
+ ulonglong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_ulonglong(BAD_ID, 0, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var_ulonglong(ncid, BAD_VARID, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var_ulonglong(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i], NCT_ULONGLONG)) {
+
+ allInIntRange &= (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_var_ulonglong(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG) && (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_ULONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+
+
+int
+test_nc_get_vara_text(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ text value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_text(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_text(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_text(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_text(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_text(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_text(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_text(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_text(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_TEXT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_TEXT) &&
+ 1) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_TEXT)) {
+ if (var_type[i] != NC_CHAR)
+ allInIntRange &= 1;
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_text(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (1) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_TEXT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_uchar(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ uchar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_uchar(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_uchar(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_uchar(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_uchar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_uchar(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_uchar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_uchar(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_uchar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_UCHAR) &&
+ (expect[0] >= uchar_min && expect[0] <= uchar_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+#endif
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR)) {
+
+ allInIntRange &= (expect[j] >= uchar_min && expect[j] <= uchar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_uchar(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR) && (expect[j] >= uchar_min && expect[j] <= uchar_max)) {
+
+ /* in put_vars(), API _put_vara_double() is used to
+ * write the NC_BYTE variables to files. In this
+ * case, NC_BYTE variables are treated as signed
+ * for CDF-1 and 2 formats. Thus, we must skip the
+ * equal test below for uchar.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 && var_type[i] == NC_BYTE && expect[j] > schar_max) continue;
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_UCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_schar(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ schar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_schar(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_schar(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_schar(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_schar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_schar(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_schar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_schar(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_schar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_SCHAR) &&
+ (expect[0] >= schar_min && expect[0] <= schar_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR)) {
+
+ allInIntRange &= (expect[j] >= schar_min && expect[j] <= schar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_schar(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR) && (expect[j] >= schar_min && expect[j] <= schar_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_SCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_short(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ short value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_short(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_short(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_short(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_short(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_short(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_short(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_short(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_short(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_SHORT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_SHORT) &&
+ (expect[0] >= short_min && expect[0] <= short_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT)) {
+
+ allInIntRange &= (expect[j] >= short_min && expect[j] <= short_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_short(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT) && (expect[j] >= short_min && expect[j] <= short_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_SHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_int(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ int value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_int(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_int(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_int(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_int(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_int(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_int(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_int(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_int(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_INT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_INT) &&
+ (expect[0] >= int_min && expect[0] <= int_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_INT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT)) {
+
+ allInIntRange &= (expect[j] >= int_min && expect[j] <= int_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_int(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT) && (expect[j] >= int_min && expect[j] <= int_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_INT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_long(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ long value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_long(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_long(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_long(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_long(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_long(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_long(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_long(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_long(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_LONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_LONG) &&
+ (expect[0] >= long_min && expect[0] <= long_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG)) {
+
+ allInIntRange &= (expect[j] >= long_min && expect[j] <= long_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_long(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG) && (expect[j] >= long_min && expect[j] <= long_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_LONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_float(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ float value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_float(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_float(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_float(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_float(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_float(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_float(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_float(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_float(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_FLOAT) &&
+ (expect[0] >= float_min && expect[0] <= float_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT)) {
+
+ allInIntRange &= (expect[j] >= float_min && expect[j] <= float_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_float(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT) && (expect[j] >= float_min && expect[j] <= float_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_FLOAT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_double(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ double value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_double(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_double(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_double(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_double(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_double(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_double(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_double(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_double(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_DOUBLE) &&
+ (expect[0] >= double_min && expect[0] <= double_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE)) {
+
+ allInIntRange &= (expect[j] >= double_min && expect[j] <= double_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_double(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE) && (expect[j] >= double_min && expect[j] <= double_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_DOUBLE)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_ushort(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ ushort value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_ushort(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_ushort(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_ushort(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_ushort(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_ushort(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_ushort(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_ushort(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_ushort(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_USHORT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_USHORT) &&
+ (expect[0] >= ushort_min && expect[0] <= ushort_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_USHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT)) {
+
+ allInIntRange &= (expect[j] >= ushort_min && expect[j] <= ushort_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_ushort(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT) && (expect[j] >= ushort_min && expect[j] <= ushort_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_USHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_uint(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ uint value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_uint(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_uint(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_uint(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_uint(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_uint(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_uint(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_uint(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_uint(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_UINT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_UINT) &&
+ (expect[0] >= uint_min && expect[0] <= uint_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UINT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT)) {
+
+ allInIntRange &= (expect[j] >= uint_min && expect[j] <= uint_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_uint(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT) && (expect[j] >= uint_min && expect[j] <= uint_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_UINT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_longlong(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ longlong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_longlong(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_longlong(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_longlong(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_longlong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_longlong(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_longlong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_longlong(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_longlong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_LONGLONG) &&
+ (expect[0] >= longlong_min && expect[0] <= longlong_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG)) {
+
+ allInIntRange &= (expect[j] >= longlong_min && expect[j] <= longlong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_longlong(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG) && (expect[j] >= longlong_min && expect[j] <= longlong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_LONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vara_ulonglong(void)
+{
+ int i, k, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK], mid[MAX_RANK];
+ double expect[MAX_NELS];
+ ulonglong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vara_ulonglong(BAD_ID, 0, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vara_ulonglong(ncid, BAD_VARID, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara_ulonglong(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j]; /* causes NC_EINVALCOORDS */
+ err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* causes NC_EEDGE */
+ err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[*]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_rank[i] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ }
+
+ err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_ULONGLONG) &&
+ (expect[0] >= ulonglong_min && expect[0] <= ulonglong_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ size_t nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ int d;
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG)) {
+
+ allInIntRange &= (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG) && (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i],NCT_ULONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+
+
+int
+test_nc_get_vars_text(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ text value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_text(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_text(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_text(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_TEXT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_TEXT) &&
+ 1) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_TEXT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_TEXT)) {
+ if (var_type[i] != NC_CHAR)
+ allInIntRange &= 1;
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_text(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (1) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_TEXT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_uchar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ uchar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_uchar(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_uchar(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_uchar(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_UCHAR) &&
+ (expect[0] >= uchar_min && expect[0] <= uchar_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+#endif
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR)) {
+
+ allInIntRange &= (expect[j] >= uchar_min && expect[j] <= uchar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_uchar(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR) && (expect[j] >= uchar_min && expect[j] <= uchar_max)) {
+
+ /* in put_vars(), API _put_vara_double() is used to
+ * write the NC_BYTE variables to files. In this
+ * case, NC_BYTE variables are treated as signed
+ * for CDF-1 and 2 formats. Thus, we must skip the
+ * equal test below for uchar.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 && var_type[i] == NC_BYTE && expect[j] > schar_max) continue;
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_UCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_schar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ schar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_schar(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_schar(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_schar(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_SCHAR) &&
+ (expect[0] >= schar_min && expect[0] <= schar_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR)) {
+
+ allInIntRange &= (expect[j] >= schar_min && expect[j] <= schar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_schar(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR) && (expect[j] >= schar_min && expect[j] <= schar_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_SCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_short(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ short value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_short(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_short(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_short(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_SHORT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_SHORT) &&
+ (expect[0] >= short_min && expect[0] <= short_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_SHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT)) {
+
+ allInIntRange &= (expect[j] >= short_min && expect[j] <= short_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_short(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT) && (expect[j] >= short_min && expect[j] <= short_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_SHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_int(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ int value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_int(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_int(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_int(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_INT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_INT) &&
+ (expect[0] >= int_min && expect[0] <= int_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_INT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT)) {
+
+ allInIntRange &= (expect[j] >= int_min && expect[j] <= int_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_int(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT) && (expect[j] >= int_min && expect[j] <= int_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_INT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_long(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ long value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_long(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_long(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_long(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_LONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_LONG) &&
+ (expect[0] >= long_min && expect[0] <= long_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_LONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG)) {
+
+ allInIntRange &= (expect[j] >= long_min && expect[j] <= long_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_long(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG) && (expect[j] >= long_min && expect[j] <= long_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_LONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_float(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ float value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_float(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_float(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_float(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_FLOAT) &&
+ (expect[0] >= float_min && expect[0] <= float_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT)) {
+
+ allInIntRange &= (expect[j] >= float_min && expect[j] <= float_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_float(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT) && (expect[j] >= float_min && expect[j] <= float_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_FLOAT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_double(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ double value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_double(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_double(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_double(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_DOUBLE) &&
+ (expect[0] >= double_min && expect[0] <= double_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE)) {
+
+ allInIntRange &= (expect[j] >= double_min && expect[j] <= double_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_double(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE) && (expect[j] >= double_min && expect[j] <= double_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_DOUBLE)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_ushort(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ ushort value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_ushort(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_ushort(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_ushort(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_USHORT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_USHORT) &&
+ (expect[0] >= ushort_min && expect[0] <= ushort_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_USHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT)) {
+
+ allInIntRange &= (expect[j] >= ushort_min && expect[j] <= ushort_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_ushort(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT) && (expect[j] >= ushort_min && expect[j] <= ushort_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_USHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_uint(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ uint value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_uint(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_uint(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_uint(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_UINT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_UINT) &&
+ (expect[0] >= uint_min && expect[0] <= uint_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_UINT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT)) {
+
+ allInIntRange &= (expect[j] >= uint_min && expect[j] <= uint_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_uint(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT) && (expect[j] >= uint_min && expect[j] <= uint_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_UINT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_longlong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ longlong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_longlong(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_longlong(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_longlong(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_LONGLONG) &&
+ (expect[0] >= longlong_min && expect[0] <= longlong_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG)) {
+
+ allInIntRange &= (expect[j] >= longlong_min && expect[j] <= longlong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_longlong(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG) && (expect[j] >= longlong_min && expect[j] <= longlong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_LONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_vars_ulonglong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ double expect[MAX_NELS];
+ ulonglong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_vars_ulonglong(BAD_ID, 0, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_vars_ulonglong(ncid, BAD_VARID, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_ulonglong(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_ULONGLONG) &&
+ (expect[0] >= ulonglong_min && expect[0] <= ulonglong_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG)) {
+
+ allInIntRange &= (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_vars_ulonglong(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG) && (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_ULONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+
+
+int
+test_nc_get_varm_text(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ text value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_text(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_text(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_text(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_TEXT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_TEXT) &&
+ 1) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_TEXT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_TEXT)) {
+ if (var_type[i] != NC_CHAR)
+ allInIntRange &= 1;
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_text(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (1) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_TEXT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_uchar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ uchar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_uchar(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_uchar(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_uchar(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_UCHAR) &&
+ (expect[0] >= uchar_min && expect[0] <= uchar_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+#endif
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR)) {
+
+ allInIntRange &= (expect[j] >= uchar_min && expect[j] <= uchar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_uchar(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UCHAR) && (expect[j] >= uchar_min && expect[j] <= uchar_max)) {
+
+ /* in put_vars(), API _put_vara_double() is used to
+ * write the NC_BYTE variables to files. In this
+ * case, NC_BYTE variables are treated as signed
+ * for CDF-1 and 2 formats. Thus, we must skip the
+ * equal test below for uchar.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 && var_type[i] == NC_BYTE && expect[j] > schar_max) continue;
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_UCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_schar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ schar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_schar(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_schar(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_schar(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_SCHAR) &&
+ (expect[0] >= schar_min && expect[0] <= schar_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR)) {
+
+ allInIntRange &= (expect[j] >= schar_min && expect[j] <= schar_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_schar(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SCHAR) && (expect[j] >= schar_min && expect[j] <= schar_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_SCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_short(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ short value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_short(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_short(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_short(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_SHORT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_SHORT) &&
+ (expect[0] >= short_min && expect[0] <= short_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_SHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT)) {
+
+ allInIntRange &= (expect[j] >= short_min && expect[j] <= short_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_short(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_SHORT) && (expect[j] >= short_min && expect[j] <= short_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_SHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_int(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ int value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_int(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_int(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_int(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_INT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_INT) &&
+ (expect[0] >= int_min && expect[0] <= int_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_INT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT)) {
+
+ allInIntRange &= (expect[j] >= int_min && expect[j] <= int_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_int(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_INT) && (expect[j] >= int_min && expect[j] <= int_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_INT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_long(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ long value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_long(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_long(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_long(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_LONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_LONG) &&
+ (expect[0] >= long_min && expect[0] <= long_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_LONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG)) {
+
+ allInIntRange &= (expect[j] >= long_min && expect[j] <= long_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_long(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONG) && (expect[j] >= long_min && expect[j] <= long_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_LONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_float(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ float value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_float(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_float(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_float(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_FLOAT) &&
+ (expect[0] >= float_min && expect[0] <= float_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT)) {
+
+ allInIntRange &= (expect[j] >= float_min && expect[j] <= float_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_float(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_FLOAT) && (expect[j] >= float_min && expect[j] <= float_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_FLOAT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_double(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ double value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_double(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_double(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_double(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_DOUBLE) &&
+ (expect[0] >= double_min && expect[0] <= double_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE)) {
+
+ allInIntRange &= (expect[j] >= double_min && expect[j] <= double_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_double(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_DOUBLE) && (expect[j] >= double_min && expect[j] <= double_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_DOUBLE)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_ushort(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ ushort value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_ushort(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_ushort(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_ushort(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_USHORT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_USHORT) &&
+ (expect[0] >= ushort_min && expect[0] <= ushort_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_USHORT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT)) {
+
+ allInIntRange &= (expect[j] >= ushort_min && expect[j] <= ushort_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_ushort(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_USHORT) && (expect[j] >= ushort_min && expect[j] <= ushort_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_USHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_uint(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ uint value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_uint(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_uint(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_uint(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_UINT);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_UINT) &&
+ (expect[0] >= uint_min && expect[0] <= uint_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_UINT);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT)) {
+
+ allInIntRange &= (expect[j] >= uint_min && expect[j] <= uint_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_uint(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_UINT) && (expect[j] >= uint_min && expect[j] <= uint_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_UINT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_longlong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ longlong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_longlong(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_longlong(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_longlong(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_LONGLONG) &&
+ (expect[0] >= longlong_min && expect[0] <= longlong_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG)) {
+
+ allInIntRange &= (expect[j] >= longlong_min && expect[j] <= longlong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_longlong(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_LONGLONG) && (expect[j] >= longlong_min && expect[j] <= longlong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_LONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_varm_ulonglong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format;
+ int allInExtRange; /* all values within external range? */
+ int allInIntRange; /* all values within internal range? */
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* count of valid comparisons */
+ int canConvert; /* Both text or both numeric */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double expect[MAX_NELS];
+ ulonglong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_varm_ulonglong(BAD_ID, 0, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_varm_ulonglong(ncid, BAD_VARID, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars_ulonglong(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ start[j] = var_shape[i][j]+1; /* should cause NC_EINVALCOORDS */
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ start[j] = 0;
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=7)
+ stride[j] = 0;
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ stride[j] = 1;
+#endif
+ }
+
+ err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ } else if (var_rank[i] == 0) {
+ expect[0] = hash4(cdf_format, var_type[i], 0, index, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[0], var_type[i], NCT_ULONGLONG) &&
+ (expect[0] >= ulonglong_min && expect[0] <= ulonglong_max)) {
+ IF (err != NC_NOERR) error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else IF (err != NC_ERANGE) error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j]-index[j]-1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ allInExtRange = allInIntRange = 1;
+ for (j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect[j] = hash4(cdf_format, var_type[i], var_rank[i],
+ index2, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG)) {
+
+ allInIntRange &= (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max);
+ } else
+ allInExtRange = 0;
+ }
+ err = nc_get_varm_ulonglong(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (j = 0; j < nels; j++) {
+ if (inRange3(cdf_format, expect[j],var_type[i],NCT_ULONGLONG) && (expect[j] >= ulonglong_min && expect[j] <= ulonglong_max)) {
+
+ IF (!equal((double)value[j],expect[j],var_type[i], NCT_ULONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("element number: %d, ", j);
+ error("expect: %g, ", expect[j]);
+ error("got: %g", (double) value[j]);
+ }
+ }
+ ELSE_NOK
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+
+
+int
+test_nc_get_att_text(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ text value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_text(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_text(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) ;
+
+ err = nc_get_att_text(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_text(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_text(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_TEXT);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_TEXT)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+ if (ATT_TYPE(i,j) != NC_CHAR)
+
+ allInIntRange &= 1;
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (1) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_TEXT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_uchar(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ uchar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_uchar(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_uchar(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ err = nc_get_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_uchar(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_uchar(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_UCHAR)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+ if (cdf_format > NC_FORMAT_64BIT_OFFSET || (cdf_format < NC_FORMAT_CDF5 && ATT_TYPE(i,j) != NC_BYTE))
+ allInIntRange &= (expect[k] >= uchar_min && expect[k] <= uchar_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+#endif
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_UCHAR) && (expect[k] >= uchar_min && expect[k] <= uchar_max)) {
+
+ /* in put_vars(), API _put_vara_double() is used to
+ * write the NC_BYTE variables to files. In this
+ * case, NC_BYTE variables are treated as signed
+ * for CDF-1 and 2 formats. Thus, we must skip the
+ * equal test below for uchar.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 && ATT_TYPE(i,j) == NC_BYTE && expect[k] > schar_max) continue;
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_UCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_schar(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ schar value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_schar(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_schar(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ err = nc_get_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_schar(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_schar(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_SCHAR)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= schar_min && expect[k] <= schar_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_SCHAR) && (expect[k] >= schar_min && expect[k] <= schar_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_SCHAR)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_short(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ short value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_short(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_short(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ err = nc_get_att_short(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_short(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_short(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_SHORT);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_SHORT)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= short_min && expect[k] <= short_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_SHORT) && (expect[k] >= short_min && expect[k] <= short_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_SHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_int(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ int value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_int(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_int(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ err = nc_get_att_int(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_int(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_int(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_INT);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_INT)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= int_min && expect[k] <= int_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_INT) && (expect[k] >= int_min && expect[k] <= int_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_INT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_long(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ long value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_long(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_long(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ err = nc_get_att_long(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_long(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_long(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_LONG);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_LONG)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= long_min && expect[k] <= long_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_LONG) && (expect[k] >= long_min && expect[k] <= long_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_LONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_float(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ float value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_float(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_float(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ err = nc_get_att_float(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_float(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_float(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_FLOAT)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= float_min && expect[k] <= float_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_FLOAT) && (expect[k] >= float_min && expect[k] <= float_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_FLOAT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_double(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ double value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_double(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_double(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ err = nc_get_att_double(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_double(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_double(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_DOUBLE)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= double_min && expect[k] <= double_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_DOUBLE) && (expect[k] >= double_min && expect[k] <= double_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_DOUBLE)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_ushort(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ ushort value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_ushort(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_ushort(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ err = nc_get_att_ushort(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_ushort(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_ushort(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_USHORT);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_USHORT)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= ushort_min && expect[k] <= ushort_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_ushort(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_USHORT) && (expect[k] >= ushort_min && expect[k] <= ushort_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_USHORT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_uint(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ uint value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_uint(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_uint(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ err = nc_get_att_uint(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_uint(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_uint(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_UINT);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_UINT)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= uint_min && expect[k] <= uint_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_uint(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_UINT) && (expect[k] >= uint_min && expect[k] <= uint_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_UINT)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_longlong(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ longlong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_longlong(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_longlong(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ err = nc_get_att_longlong(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_longlong(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_longlong(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_LONGLONG)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= longlong_min && expect[k] <= longlong_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_longlong(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_LONGLONG) && (expect[k] >= longlong_min && expect[k] <= longlong_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_LONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+int
+test_nc_get_att_ulonglong(void)
+{
+ int i, j, err, ncid, cdf_format;
+ size_t k, ndx[1];
+ int allInExtRange;
+ int allInIntRange;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ double expect[MAX_NELS];
+ ulonglong value[MAX_NELS];
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ err = nc_get_att_ulonglong(BAD_ID, 0, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_get_att_ulonglong(ncid, BAD_VARID, NULL, value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ err = nc_get_att_ulonglong(ncid, BAD_VARID, ATT_NAME(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>7)
+ /* check if can detect a bad name */
+ err = nc_get_att_ulonglong(ncid, i, NULL, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+#endif
+
+ err = nc_get_att_ulonglong(ncid, i, "noSuch", value);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ allInExtRange = allInIntRange = 1;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, ATT_TYPE(i,j), -1, ndx, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_ULONGLONG)) {
+ /* netCDF specification make a special case for type
+ * conversion between uchar and scahr: do not check for
+ * range error. See
+ * http://www.unidata.ucar.edu/software/netcdf/docs/data_type.html#type_conversion
+ */
+
+
+ allInIntRange &= (expect[k] >= ulonglong_min && expect[k] <= ulonglong_max);
+ } else {
+ allInExtRange = 0;
+ }
+ }
+ err = nc_get_att_ulonglong(ncid, i, ATT_NAME(i,j), value);
+ if (canConvert || ATT_LEN(i,j) == 0) {
+ if (allInExtRange) {
+ if (allInIntRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+
+ }
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ if (inRange3(cdf_format, expect[k],ATT_TYPE(i,j),NCT_ULONGLONG) && (expect[k] >= ulonglong_min && expect[k] <= ulonglong_max)) {
+
+ IF (!equal((double)value[k],expect[k],ATT_TYPE(i,j), NCT_ULONGLONG)){
+ error("value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ if (i == -1)
+ error("var_type: GLOBAL, ");
+ else
+ error("var_name: %s var_type: %s, ", var_name[i],s_nc_type(var_type[i]));
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d, ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
diff --git a/nc_test/test_put.c b/nc_test/test_put.c
new file mode 100644
index 0000000..24a0c89
--- /dev/null
+++ b/nc_test/test_put.c
@@ -0,0 +1,13742 @@
+/* Do not edit this file. It is produced from the corresponding .m4 source */
+/*
+ * Copyright (C) 2003, Northwestern University and Argonne National Laboratory
+ * See COPYRIGHT notice in top-level directory.
+ */
+/* $Id: test_put.m4 2672 2016-12-03 19:23:53Z wkliao $ */
+
+
+#include "tests.h"
+
+#ifdef USE_PNETCDF
+#include <pnetcdf.h>
+#ifndef PNETCDF_VERSION_MAJOR
+#error("PNETCDF_VERSION_MAJOR is not defined in pnetcdf.h")
+#endif
+#ifndef PNETCDF_VERSION_MINOR
+#error("PNETCDF_VERSION_MAJOR is not defined in pnetcdf.h")
+#endif
+#endif
+
+
+
+
+
+
+
+
+
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+text
+hash_text(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+ return (text)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+uchar
+hash_uchar(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > uchar_max) return uchar_max;
+ else if (value < uchar_min) return uchar_min;
+ else return (uchar)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+schar
+hash_schar(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > schar_max) return schar_max;
+ else if (value < schar_min) return schar_min;
+ else return (schar)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+short
+hash_short(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > short_max) return short_max;
+ else if (value < short_min) return short_min;
+ else return (short)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+int
+hash_int(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > int_max) return int_max;
+ else if (value < int_min) return int_min;
+ else return (int)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+long
+hash_long(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > long_max) return long_max;
+ else if (value < long_min) return long_min;
+ else return (long)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+float
+hash_float(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > float_max) return float_max;
+ else if (value < float_min) return float_min;
+ else return (float)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+double
+hash_double(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > double_max) return double_max;
+ else if (value < double_min) return double_min;
+ else return (double)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+ushort
+hash_ushort(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > ushort_max) return ushort_max;
+ else if (value < ushort_min) return ushort_min;
+ else return (ushort)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+uint
+hash_uint(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > uint_max) return uint_max;
+ else if (value < uint_min) return uint_min;
+ else return (uint)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+longlong
+hash_longlong(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > longlong_max) return longlong_max;
+ else if (value < longlong_min) return longlong_min;
+ else return (longlong)value;
+}
+
+/*
+ * ensure hash value within range for internal TYPE
+ */
+ulonglong
+hash_ulonglong(const int cdf_format,
+ const nc_type type,
+ const int rank,
+ const size_t *index,
+ const nct_itype itype)
+{
+ double value;
+
+ value = hash4(cdf_format, type, rank, index, itype);
+
+ if (value > ulonglong_max) return ulonglong_max;
+ else if (value < ulonglong_min) return ulonglong_min;
+ else return (ulonglong)value;
+}
+
+
+
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_text(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ text value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) ;
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ err = nc_get_var1_text(ncid, i, index, &value);
+ if (1) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_text: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_TEXT)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_uchar(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ uchar value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+ err = nc_get_var1_uchar(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_UCHAR) && (expect >= uchar_min && expect <= uchar_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_uchar: %s", nc_strerror(err));
+ } else {
+
+ /* In put_vars(), nc_put_vara_double() is used to write
+ * variables of type NC_BYTE to files. For uchar APIs,
+ * NC_BYTE variables are treated as unsigned for CDF-1 and 2
+ * formats. Thus, we skip the equal test for out-of-bound
+ * values below for uchar APIs.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 &&
+ var_type[i] == NC_BYTE && expect > schar_max)
+ continue;
+ IF (!equal((double)value,expect,var_type[i],NCT_UCHAR)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_schar(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ schar value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+ err = nc_get_var1_schar(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_SCHAR) && (expect >= schar_min && expect <= schar_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_schar: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_SCHAR)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_short(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ short value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SHORT);
+ err = nc_get_var1_short(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_SHORT) && (expect >= short_min && expect <= short_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_short: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_SHORT)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_int(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ int value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_INT);
+ err = nc_get_var1_int(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_INT) && (expect >= int_min && expect <= int_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_int: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_INT)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_long(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ long value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONG);
+ err = nc_get_var1_long(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_LONG) && (expect >= long_min && expect <= long_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_long: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_LONG)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_float(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ float value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+ err = nc_get_var1_float(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_FLOAT) && (expect >= float_min && expect <= float_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_float: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_FLOAT)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_double(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ double value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+ err = nc_get_var1_double(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_DOUBLE) && (expect >= double_min && expect <= double_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_double: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_DOUBLE)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_ushort(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ ushort value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_USHORT);
+ err = nc_get_var1_ushort(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_USHORT) && (expect >= ushort_min && expect <= ushort_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_ushort: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_USHORT)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_uint(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ uint value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UINT);
+ err = nc_get_var1_uint(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_UINT) && (expect >= uint_min && expect <= uint_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_uint: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_UINT)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_longlong(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ longlong value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+ err = nc_get_var1_longlong(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_LONGLONG) && (expect >= longlong_min && expect <= longlong_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_longlong: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_LONGLONG)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+/*
+ * check all vars in file which are (text/numeric) compatible with TYPE
+ */
+int
+check_vars_ulonglong(const char *filename, int numVars)
+{
+ int i, d, err, ncid, cdf_format, ndims;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ int dimids[MAX_RANK];
+ nc_type datatype;
+ char name[NC_MAX_NAME];
+ size_t j, length, index[MAX_RANK];
+ double expect;
+ ulonglong value;
+
+ err = file_open(filename, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR) error("inq_format: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ IF (strcmp(name, var_name[i]) != 0)
+ error("Unexpected var_name");
+ IF (datatype != var_type[i])
+ error("Unexpected type");
+ IF (ndims != var_rank[i])
+ error("Unexpected rank");
+ for (j = 0; j < ndims; j++) {
+ err = nc_inq_dim(ncid, dimids[j], 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ IF (length != var_shape[i][j])
+ error("Unexpected shape");
+ }
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash4(cdf_format, var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+ err = nc_get_var1_ulonglong(ncid, i, index, &value);
+ if (inRange3(cdf_format, (double)expect,datatype,NCT_ULONGLONG) && (expect >= ulonglong_min && expect <= ulonglong_max)) {
+ IF (err != NC_NOERR) {
+ error("nc_get_var1_ulonglong: %s", nc_strerror(err));
+ } else {
+
+ IF (!equal((double)value,expect,var_type[i],NCT_ULONGLONG)){
+ error("Var value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("var_type: %s, ", s_nc_type(var_type[i]));
+ error("index:");
+ for (d = 0; d < var_rank[i]; d++)
+ error(" %d", index[d]);
+ error(", expect: %g, ", expect);
+ error("got: %g", (double) value);
+ }
+ } else {
+ ++nok;
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type text
+ */
+int
+check_atts_text(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ text value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) ;
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_TEXT);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_TEXT)) {
+ ++nInExtRange;
+ if (0)
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (1) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_TEXT)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type uchar
+ */
+int
+check_atts_uchar(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ uchar value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_UCHAR);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_UCHAR)) {
+ ++nInExtRange;
+ if ((expect[k] >= uchar_min && expect[k] <= uchar_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_UCHAR) && (expect[k] >= uchar_min && expect[k] <= uchar_max)) {
+
+ /* In put_vars(), nc_put_vara_double() is used to write
+ * variables of type NC_BYTE to files. For uchar APIs,
+ * NC_BYTE variables are treated as unsigned for CDF-1 and 2
+ * formats. Thus, we skip the equal test for out-of-bound
+ * values below for uchar APIs.
+ */
+ if (cdf_format < NC_FORMAT_CDF5 &&
+ ATT_TYPE(i,j) == NC_BYTE && expect[k] > schar_max)
+ continue;
+ IF (!equal((double)value[k],expect[k],datatype,NCT_UCHAR)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type schar
+ */
+int
+check_atts_schar(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ schar value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_SCHAR);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_SCHAR)) {
+ ++nInExtRange;
+ if ((expect[k] >= schar_min && expect[k] <= schar_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_SCHAR) && (expect[k] >= schar_min && expect[k] <= schar_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_SCHAR)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type short
+ */
+int
+check_atts_short(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ short value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_SHORT);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_SHORT)) {
+ ++nInExtRange;
+ if ((expect[k] >= short_min && expect[k] <= short_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_SHORT) && (expect[k] >= short_min && expect[k] <= short_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_SHORT)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type int
+ */
+int
+check_atts_int(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ int value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_INT);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_INT)) {
+ ++nInExtRange;
+ if ((expect[k] >= int_min && expect[k] <= int_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_INT) && (expect[k] >= int_min && expect[k] <= int_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_INT)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type long
+ */
+int
+check_atts_long(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ long value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_LONG);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_LONG)) {
+ ++nInExtRange;
+ if ((expect[k] >= long_min && expect[k] <= long_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_LONG) && (expect[k] >= long_min && expect[k] <= long_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_LONG)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type float
+ */
+int
+check_atts_float(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ float value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_FLOAT);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_FLOAT)) {
+ ++nInExtRange;
+ if ((expect[k] >= float_min && expect[k] <= float_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_FLOAT) && (expect[k] >= float_min && expect[k] <= float_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_FLOAT)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type double
+ */
+int
+check_atts_double(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ double value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_DOUBLE);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_DOUBLE)) {
+ ++nInExtRange;
+ if ((expect[k] >= double_min && expect[k] <= double_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_DOUBLE) && (expect[k] >= double_min && expect[k] <= double_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_DOUBLE)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type ushort
+ */
+int
+check_atts_ushort(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ ushort value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_USHORT);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_USHORT)) {
+ ++nInExtRange;
+ if ((expect[k] >= ushort_min && expect[k] <= ushort_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_ushort(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_USHORT) && (expect[k] >= ushort_min && expect[k] <= ushort_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_USHORT)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type uint
+ */
+int
+check_atts_uint(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ uint value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_UINT);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_UINT)) {
+ ++nInExtRange;
+ if ((expect[k] >= uint_min && expect[k] <= uint_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_uint(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_UINT) && (expect[k] >= uint_min && expect[k] <= uint_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_UINT)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type longlong
+ */
+int
+check_atts_longlong(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ longlong value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_LONGLONG);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_LONGLONG)) {
+ ++nInExtRange;
+ if ((expect[k] >= longlong_min && expect[k] <= longlong_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_longlong(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_LONGLONG) && (expect[k] >= longlong_min && expect[k] <= longlong_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_LONGLONG)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+/*
+ * for _text tests, check all attributes in file which are of text type
+ * Note no NC_ERANGE check for text attributes as text is not convertible to
+ * any other numerical data types (i.e. NC_ECHAR)
+ *
+ * for other tests, check all numerical attributes in file against values
+ * outside range of type ulonglong
+ */
+int
+check_atts_ulonglong(int ncid, int numGatts, int numVars)
+{
+ int i, j, cdf_format, err;
+ int canConvert; /* Both text or both numeric */
+ int nok = 0; /* count of valid comparisons */
+ size_t k, length, ndx[1];
+ nc_type datatype;
+ size_t nInExtRange; /* number values within external range */
+ size_t nInIntRange; /* number values within internal range */
+ double expect[MAX_NELS];
+ ulonglong value[MAX_NELS];
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+ if (!canConvert) continue;
+
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+ IF (err != NC_NOERR)
+ error("inq_att: %s", nc_strerror(err));
+ IF (datatype != ATT_TYPE(i,j))
+ error("inq_att: unexpected type");
+ IF (length != ATT_LEN(i,j))
+ error("inq_att: unexpected length");
+ assert(length <= MAX_NELS);
+ nInIntRange = nInExtRange = 0;
+ for (k = 0; k < length; k++) {
+ ndx[0] = k;
+ expect[k] = hash4(cdf_format, datatype, -1, ndx, NCT_ULONGLONG);
+ if (inRange3(cdf_format, expect[k], datatype, NCT_ULONGLONG)) {
+ ++nInExtRange;
+ if ((expect[k] >= ulonglong_min && expect[k] <= ulonglong_max))
+ ++nInIntRange;
+ }
+ }
+ err = nc_get_att_ulonglong(ncid, i, ATT_NAME(i,j), value);
+ if (nInExtRange == length && nInIntRange == length) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ } else {
+ IF (err != NC_NOERR && err != NC_ERANGE)
+ error("expecting NC_NOERR or NC_ERANGE but got %s",nc_err_code_name(err));
+ }
+ for (k = 0; k < length; k++) {
+ if (inRange3(cdf_format, (double)expect[k],datatype,NCT_ULONGLONG) && (expect[k] >= ulonglong_min && expect[k] <= ulonglong_max)) {
+
+ IF (!equal((double)value[k],expect[k],datatype,NCT_ULONGLONG)) {
+ error("att. value read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("att_type: %s, ", s_nc_type(ATT_TYPE(i,j)));
+ error("element number: %d ", k);
+ error("expect: %g, ", expect[k]);
+ error("got: %g", (double) value[k]);
+ }
+ } else {
+ nok++;
+ }
+ }
+ }
+ }
+ }
+ return nok;
+}
+
+
+
+
+int
+test_nc_put_var1_text(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ text value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_text(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_text(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_text(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_text(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_text(cdf_format, var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ err = nc_put_var1_text(ncid, i, index, value);
+ if (canConvert) {
+ if (1) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_text(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_uchar(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ uchar value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_uchar(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_uchar(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_uchar(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_uchar(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_uchar(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+ err = nc_put_var1_uchar(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_UCHAR)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uchar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_schar(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ schar value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_schar(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_schar(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_schar(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_schar(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_schar(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+ err = nc_put_var1_schar(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_SCHAR)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_schar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_short(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ short value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_short(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_short(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_short(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_short(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_short(cdf_format, var_type[i], var_rank[i], index,
+ NCT_SHORT);
+ err = nc_put_var1_short(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_SHORT)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_short(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_int(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ int value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_int(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_int(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_int(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_int(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_int(cdf_format, var_type[i], var_rank[i], index,
+ NCT_INT);
+ err = nc_put_var1_int(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_INT)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_int(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_long(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ long value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_long(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_long(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_long(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_long(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_long(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONG);
+ err = nc_put_var1_long(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_LONG)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_long(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_float(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ float value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_float(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_float(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_float(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_float(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_float(cdf_format, var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+ err = nc_put_var1_float(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_FLOAT)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_float(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_double(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ double value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_double(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_double(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_double(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_double(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_double(cdf_format, var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+ err = nc_put_var1_double(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_DOUBLE)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_double(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_ushort(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ ushort value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_ushort(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_ushort(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_ushort(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_ushort(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_ushort(cdf_format, var_type[i], var_rank[i], index,
+ NCT_USHORT);
+ err = nc_put_var1_ushort(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_USHORT)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ushort(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_uint(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ uint value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_uint(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_uint(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_uint(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_uint(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_uint(cdf_format, var_type[i], var_rank[i], index,
+ NCT_UINT);
+ err = nc_put_var1_uint(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_UINT)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uint(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_longlong(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ longlong value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_longlong(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_longlong(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_longlong(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_longlong(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_longlong(cdf_format, var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+ err = nc_put_var1_longlong(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_LONGLONG)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_longlong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var1_ulonglong(void)
+{
+ int i, err, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ size_t j, index[MAX_RANK];
+ ulonglong value[1];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_ulonglong(BAD_ID, 0, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var1_ulonglong(ncid, BAD_VARID, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var1_ulonglong(BAD_ID, i, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) index[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ index[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_var1_ulonglong(ncid, i, index, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[0] = hash_ulonglong(cdf_format, var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+ err = nc_put_var1_ulonglong(ncid, i, index, value);
+ if (canConvert) {
+ if (inRange3(cdf_format, (double)value[0],var_type[i],NCT_ULONGLONG)) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ulonglong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
+
+
+int
+test_nc_put_var_text(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ text value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_text(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_text(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_text(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_text(cdf_format,var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ if (var_type[i] != NC_CHAR)
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_TEXT);
+ }
+ err = nc_put_var_text(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_text(cdf_format,var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ if (var_type[i] != NC_CHAR)
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_TEXT);
+ }
+ err = nc_put_var_text(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_text(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_uchar(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ uchar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_uchar(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_uchar(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_uchar(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_uchar(cdf_format,var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UCHAR);
+ }
+ err = nc_put_var_uchar(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_uchar(cdf_format,var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UCHAR);
+ }
+ err = nc_put_var_uchar(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uchar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_schar(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ schar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_schar(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_schar(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_schar(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_schar(cdf_format,var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SCHAR);
+ }
+ err = nc_put_var_schar(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_schar(cdf_format,var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SCHAR);
+ }
+ err = nc_put_var_schar(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_schar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_short(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ short value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_short(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_short(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_short(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_short(cdf_format,var_type[i], var_rank[i], index,
+ NCT_SHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SHORT);
+ }
+ err = nc_put_var_short(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_short(cdf_format,var_type[i], var_rank[i], index,
+ NCT_SHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SHORT);
+ }
+ err = nc_put_var_short(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_short(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_int(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ int value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_int(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_int(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_int(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_int(cdf_format,var_type[i], var_rank[i], index,
+ NCT_INT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_INT);
+ }
+ err = nc_put_var_int(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_int(cdf_format,var_type[i], var_rank[i], index,
+ NCT_INT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_INT);
+ }
+ err = nc_put_var_int(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_int(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_long(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ long value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_long(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_long(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_long(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_long(cdf_format,var_type[i], var_rank[i], index,
+ NCT_LONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONG);
+ }
+ err = nc_put_var_long(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_long(cdf_format,var_type[i], var_rank[i], index,
+ NCT_LONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONG);
+ }
+ err = nc_put_var_long(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_long(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_float(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ float value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_float(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_float(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_float(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_float(cdf_format,var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_FLOAT);
+ }
+ err = nc_put_var_float(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_float(cdf_format,var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_FLOAT);
+ }
+ err = nc_put_var_float(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_float(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_double(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ double value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_double(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_double(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_double(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_double(cdf_format,var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_DOUBLE);
+ }
+ err = nc_put_var_double(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_double(cdf_format,var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_DOUBLE);
+ }
+ err = nc_put_var_double(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_double(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_ushort(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ ushort value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_ushort(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_ushort(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_ushort(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_ushort(cdf_format,var_type[i], var_rank[i], index,
+ NCT_USHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_USHORT);
+ }
+ err = nc_put_var_ushort(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_ushort(cdf_format,var_type[i], var_rank[i], index,
+ NCT_USHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_USHORT);
+ }
+ err = nc_put_var_ushort(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ushort(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_uint(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ uint value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_uint(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_uint(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_uint(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_uint(cdf_format,var_type[i], var_rank[i], index,
+ NCT_UINT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UINT);
+ }
+ err = nc_put_var_uint(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_uint(cdf_format,var_type[i], var_rank[i], index,
+ NCT_UINT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UINT);
+ }
+ err = nc_put_var_uint(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uint(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_longlong(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ longlong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_longlong(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_longlong(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_longlong(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_longlong(cdf_format,var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONGLONG);
+ }
+ err = nc_put_var_longlong(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_longlong(cdf_format,var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONGLONG);
+ }
+ err = nc_put_var_longlong(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_longlong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_var_ulonglong(void)
+{
+ int i, err, ncid, varid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, index[MAX_RANK];
+ ulonglong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_ulonglong(BAD_ID, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_var_ulonglong(ncid, BAD_VARID, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ if (var_dimid[i][0] == RECDIM) continue; /* fixed-size variables only */
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_var_ulonglong(BAD_ID, i, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_ulonglong(cdf_format,var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_ULONGLONG);
+ }
+ err = nc_put_var_ulonglong(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else { /* should flag wrong type even if nothing to write */
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ /* Preceding has written nothing for record variables, now try */
+ /* again with more than 0 records */
+
+ /* Write record number NRECS to force writing of preceding records */
+ /* Assumes variable cr is char vector with UNLIMITED dimension */
+ err = nc_inq_varid(ncid, "cr", &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ index[0] = NRECS-1;
+ err = nc_put_var1_text(ncid, varid, index, "x");
+ IF (err != NC_NOERR)
+ error("put_var1_text: %s", nc_strerror(err));
+
+ for (i = 0; i < numVars; i++) {
+ if (var_dimid[i][0] != RECDIM) continue; /* only record variables here */
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (allInExtRange = 1, j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ value[j]= hash_ulonglong(cdf_format,var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_ULONGLONG);
+ }
+ err = nc_put_var_ulonglong(ncid, i, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ } else {
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ulonglong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
+
+
+int
+test_nc_put_vara_text(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ text value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_text(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_text(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_text(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_text(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_text(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_text(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_text(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_text(cdf_format,var_type[i], var_rank[i], index,
+ NCT_TEXT);
+ if (var_type[i] != NC_CHAR)
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_TEXT);
+ }
+ err = nc_put_vara_text(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_text(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_uchar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ uchar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_uchar(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_uchar(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_uchar(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_uchar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_uchar(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_uchar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_uchar(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_uchar(cdf_format,var_type[i], var_rank[i], index,
+ NCT_UCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UCHAR);
+ }
+ err = nc_put_vara_uchar(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uchar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_schar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ schar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_schar(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_schar(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_schar(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_schar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_schar(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_schar(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_schar(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_schar(cdf_format,var_type[i], var_rank[i], index,
+ NCT_SCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SCHAR);
+ }
+ err = nc_put_vara_schar(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_schar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_short(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ short value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_short(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_short(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_short(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_short(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_short(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_short(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_short(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_short(cdf_format,var_type[i], var_rank[i], index,
+ NCT_SHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SHORT);
+ }
+ err = nc_put_vara_short(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_short(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_int(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ int value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_int(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_int(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_int(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_int(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_int(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_int(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_int(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_int(cdf_format,var_type[i], var_rank[i], index,
+ NCT_INT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_INT);
+ }
+ err = nc_put_vara_int(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_int(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_long(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ long value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_long(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_long(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_long(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_long(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_long(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_long(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_long(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_long(cdf_format,var_type[i], var_rank[i], index,
+ NCT_LONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONG);
+ }
+ err = nc_put_vara_long(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_long(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_float(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ float value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_float(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_float(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_float(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_float(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_float(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_float(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_float(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_float(cdf_format,var_type[i], var_rank[i], index,
+ NCT_FLOAT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_FLOAT);
+ }
+ err = nc_put_vara_float(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_float(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_double(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ double value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_double(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_double(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_double(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_double(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_double(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_double(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_double(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_double(cdf_format,var_type[i], var_rank[i], index,
+ NCT_DOUBLE);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_DOUBLE);
+ }
+ err = nc_put_vara_double(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_double(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_ushort(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ ushort value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_ushort(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_ushort(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_ushort(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_ushort(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_ushort(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_ushort(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_ushort(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_ushort(cdf_format,var_type[i], var_rank[i], index,
+ NCT_USHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_USHORT);
+ }
+ err = nc_put_vara_ushort(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ushort(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_uint(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ uint value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_uint(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_uint(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_uint(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_uint(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_uint(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_uint(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_uint(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_uint(cdf_format,var_type[i], var_rank[i], index,
+ NCT_UINT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UINT);
+ }
+ err = nc_put_vara_uint(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uint(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_longlong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ longlong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_longlong(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_longlong(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_longlong(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_longlong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_longlong(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_longlong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_longlong(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_longlong(cdf_format,var_type[i], var_rank[i], index,
+ NCT_LONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONGLONG);
+ }
+ err = nc_put_vara_longlong(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_longlong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vara_ulonglong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK];
+ size_t mid[MAX_RANK], index[MAX_RANK];
+ ulonglong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_ulonglong(BAD_ID, 0, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vara_ulonglong(ncid, BAD_VARID, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vara_ulonglong(BAD_ID, i, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check correct error returned when nothing to put, when edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ value[j]= hash_ulonglong(cdf_format,var_type[i], var_rank[i], index,
+ NCT_ULONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_ULONGLONG);
+ }
+ err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ulonglong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
+
+
+int
+test_nc_put_vars_text(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ text value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_text(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_text(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_text(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_text(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_TEXT);
+ if (var_type[i] != NC_CHAR)
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_TEXT);
+ }
+ err = nc_put_vars_text(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_text(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_uchar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ uchar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_uchar(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_uchar(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_uchar(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_uchar(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_UCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UCHAR);
+ }
+ err = nc_put_vars_uchar(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uchar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_schar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ schar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_schar(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_schar(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_schar(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_schar(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_SCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SCHAR);
+ }
+ err = nc_put_vars_schar(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_schar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_short(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ short value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_short(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_short(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_short(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_short(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_SHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SHORT);
+ }
+ err = nc_put_vars_short(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_short(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_int(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ int value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_int(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_int(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_int(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_int(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_INT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_INT);
+ }
+ err = nc_put_vars_int(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_int(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_long(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ long value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_long(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_long(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_long(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_long(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_LONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONG);
+ }
+ err = nc_put_vars_long(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_long(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_float(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ float value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_float(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_float(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_float(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_float(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_FLOAT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_FLOAT);
+ }
+ err = nc_put_vars_float(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_float(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_double(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ double value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_double(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_double(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_double(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_double(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_DOUBLE);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_DOUBLE);
+ }
+ err = nc_put_vars_double(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_double(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_ushort(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ ushort value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_ushort(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_ushort(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_ushort(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_ushort(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_USHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_USHORT);
+ }
+ err = nc_put_vars_ushort(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ushort(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_uint(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ uint value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_uint(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_uint(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_uint(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_uint(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_UINT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UINT);
+ }
+ err = nc_put_vars_uint(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uint(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_longlong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ longlong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_longlong(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_longlong(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_longlong(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_longlong(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_LONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONGLONG);
+ }
+ err = nc_put_vars_longlong(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_longlong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_vars_ulonglong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK];
+ ulonglong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_ulonglong(BAD_ID, 0, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_vars_ulonglong(ncid, BAD_VARID, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_vars_ulonglong(BAD_ID, i, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned even when nothing to put */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_ulonglong(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_ULONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_ULONGLONG);
+ }
+ err = nc_put_vars_ulonglong(ncid, i, index, count, stride, value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ulonglong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
+
+
+int
+test_nc_put_varm_text(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ text value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_text(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_text(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_text(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) ;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_text(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_TEXT);
+ if (var_type[i] != NC_CHAR)
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_TEXT);
+ }
+ err = nc_put_varm_text(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_text(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_uchar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ uchar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_uchar(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_uchar(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_uchar(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_uchar(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_UCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UCHAR);
+ }
+ err = nc_put_varm_uchar(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uchar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_schar(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ schar value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_schar(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_schar(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_schar(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_schar(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_SCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SCHAR);
+ }
+ err = nc_put_varm_schar(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_schar(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_short(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ short value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_short(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_short(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_short(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_short(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_SHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_SHORT);
+ }
+ err = nc_put_varm_short(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_short(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_int(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ int value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_int(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_int(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_int(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_int(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_INT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_INT);
+ }
+ err = nc_put_varm_int(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_int(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_long(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ long value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_long(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_long(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_long(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_long(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_LONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONG);
+ }
+ err = nc_put_varm_long(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_long(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_float(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ float value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_float(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_float(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_float(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_float(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_FLOAT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_FLOAT);
+ }
+ err = nc_put_varm_float(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_float(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_double(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ double value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_double(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_double(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_double(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_double(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_DOUBLE);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_DOUBLE);
+ }
+ err = nc_put_varm_double(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_double(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_ushort(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ ushort value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_ushort(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_ushort(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_ushort(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_ushort(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_USHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_USHORT);
+ }
+ err = nc_put_varm_ushort(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ushort(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_uint(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ uint value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_uint(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_uint(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_uint(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_uint(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_UINT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_UINT);
+ }
+ err = nc_put_varm_uint(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_uint(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_longlong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ longlong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_longlong(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_longlong(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_longlong(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_longlong(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_LONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_LONGLONG);
+ }
+ err = nc_put_varm_longlong(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_longlong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_varm_ulonglong(void)
+{
+ int i, k, d, err, nslabs, ncid, cdf_format, nok=0;
+ int canConvert; /* Both text or both numeric */
+ int allInExtRange; /* all values within external range? */
+ size_t j, m, nels;
+ size_t start[MAX_RANK], edge[MAX_RANK], index[MAX_RANK];
+ size_t index2[MAX_RANK], mid[MAX_RANK], count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ ptrdiff_t stride[MAX_RANK], imap[MAX_RANK];
+ ulonglong value[MAX_NELS];
+
+ err = file_create(scratch, NC_CLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_ulonglong(BAD_ID, 0, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_varm_ulonglong(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ value[0] = 5; /* reset to a value within bounds */
+
+ /* check if can detect a bad file ID */
+ err = nc_put_varm_ulonglong(BAD_ID, i, NULL, NULL, NULL, NULL, value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* first test when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j]; /* out of boundary check */
+ err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check correct error returned when nothing to put, i.e. edge[*]==0 */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ if (!canConvert) {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ continue;
+ }
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* Put 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to put lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ } else {
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+*/
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ imap[jj] = 1;
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)count[jj];
+ }
+ for (allInExtRange = 1, j = 0; j < nels; j++) {
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ value[j] = hash_ulonglong(cdf_format,var_type[i], var_rank[i],
+ index2, NCT_ULONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[j],
+ var_type[i], NCT_ULONGLONG);
+ }
+ err = nc_put_varm_ulonglong(ncid,i,index,count,stride,imap,value);
+ if (canConvert) {
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ } else {
+ IF (err != NC_ECHAR)
+ error("expecting NC_ECHAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ nok += check_vars_ulonglong(scratch, numVars);
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
+
+int
+test_nc_put_att_text(void)
+{
+ int i, j, err, ncid, nok=0;
+ size_t k, ndx[1];
+ text value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_text(BAD_ID, 0, NULL, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_text(ncid, BAD_VARID, NULL, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ {
+ const char *const tval = "value for bad name";
+ const size_t tval_len = (size_t)strlen(tval);
+
+ err = nc_put_att_text(ncid, 0, "", tval_len, tval);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (ATT_TYPE(i,j) == NC_CHAR) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_text(ncid, BAD_VARID, ATT_NAME(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ double dtmp = hash(ATT_TYPE(i,j), -1, ndx);
+ value[k] = (text)dtmp;
+ }
+ err = nc_put_att_text(ncid, i, ATT_NAME(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+ }
+ }
+
+ nok += check_atts_text(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
+
+int
+test_nc_put_att_uchar(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ uchar value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_uchar(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_uchar(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_uchar(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_uchar(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_UCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_UCHAR);
+ }
+ err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if !defined(USE_PNETCDF) || (PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR>=8)
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+#endif
+
+ }
+ }
+ }
+
+ nok += check_atts_uchar(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_schar(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ schar value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_schar(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_schar(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_schar(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_schar(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_SCHAR);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_SCHAR);
+ }
+ err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+#if defined(USE_PNETCDF) && PNETCDF_VERSION_MAJOR==1 && PNETCDF_VERSION_MINOR<7
+ else if (cdf_format < NC_FORMAT_CDF5) {
+#else
+ else {
+#endif
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_schar(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_short(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ short value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_short(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_short(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_short(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_short(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_short(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_short(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_SHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_SHORT);
+ }
+ err = nc_put_att_short(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_short(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_int(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ int value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_int(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_int(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_int(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_int(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_int(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_int(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_INT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_INT);
+ }
+ err = nc_put_att_int(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_int(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_long(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ long value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_long(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_long(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_long(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_long(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_long(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_long(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_LONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_LONG);
+ }
+ err = nc_put_att_long(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_long(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_float(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ float value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_float(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_float(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_float(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_float(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_float(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_float(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_FLOAT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_FLOAT);
+ }
+ err = nc_put_att_float(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_float(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_double(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ double value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_double(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_double(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_double(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_double(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_double(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_double(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_DOUBLE);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_DOUBLE);
+ }
+ err = nc_put_att_double(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_double(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_ushort(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ ushort value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_ushort(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_ushort(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_ushort(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_ushort(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_ushort(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_ushort(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_USHORT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_USHORT);
+ }
+ err = nc_put_att_ushort(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_ushort(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_uint(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ uint value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_uint(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_uint(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_uint(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_uint(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_uint(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_uint(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_UINT);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_UINT);
+ }
+ err = nc_put_att_uint(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_uint(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_longlong(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ longlong value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_longlong(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_longlong(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_longlong(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_longlong(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_longlong(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_longlong(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_LONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_LONGLONG);
+ }
+ err = nc_put_att_longlong(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_longlong(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+int
+test_nc_put_att_ulonglong(void)
+{
+ int i, j, err, ncid, cdf_format, nok=0;
+ int allInExtRange; /* all values within external range? */
+ size_t k, ndx[1];
+ ulonglong value[MAX_NELS];
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ return nok;
+ }
+
+ err = nc_inq_format(ncid, &cdf_format);
+ IF (err != NC_NOERR)
+ error("inq_format: %s", nc_strerror(err));
+
+ def_dims(ncid);
+ def_vars(ncid);
+
+ /* check if can detect a bad file ID */
+ err = nc_put_att_ulonglong(BAD_ID, 0, NULL, 0, 0, NULL);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad variable ID */
+ err = nc_put_att_ulonglong(ncid, BAD_VARID, NULL, 0, 0, NULL);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ if (!(ATT_TYPE(i,j) == NC_CHAR)) {
+ assert(ATT_LEN(i,j) <= MAX_NELS);
+
+ err = nc_put_att_ulonglong(ncid, BAD_VARID, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if can detect a bad name */
+ err = nc_put_att_ulonglong(ncid, i, NULL, 0, 0, NULL);
+ IF (err != NC_EBADNAME)
+ error("expecting NC_EBADNAME but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_put_att_ulonglong(ncid, i, ATT_NAME(i,j), BAD_TYPE, ATT_LEN(i,j), value);
+ IF (err != NC_EBADTYPE)
+ error("expecting NC_EBADTYPE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ value[k] = hash_ulonglong(cdf_format,ATT_TYPE(i,j), -1, ndx, NCT_ULONGLONG);
+
+ allInExtRange &= inRange3(cdf_format, (double)value[k], ATT_TYPE(i,j), NCT_ULONGLONG);
+ }
+ err = nc_put_att_ulonglong(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j), ATT_LEN(i,j), value);
+ if (allInExtRange) {
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+ else {
+
+ IF (err != NC_ERANGE)
+ error("expecting NC_ERANGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ }
+
+
+ }
+ }
+ }
+
+ nok += check_atts_ulonglong(ncid, numGatts, numVars);
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("delete file %s failed", scratch);
+ return nok;
+}
+
+
diff --git a/nc_test/test_read.c b/nc_test/test_read.c
new file mode 100644
index 0000000..9df36fb
--- /dev/null
+++ b/nc_test/test_read.c
@@ -0,0 +1,1950 @@
+/* Do not edit this file. It is produced from the corresponding .m4 source */
+/*
+ * Copyright (C) 2003, Northwestern University and Argonne National Laboratory
+ * See COPYRIGHT notice in top-level directory.
+ */
+/* $Id: test_read.m4 2861 2017-02-09 19:38:02Z wkliao $ */
+
+
+#if defined (_WIN32) || defined (_WIN64)
+#include <io.h>
+#endif
+
+#include <sys/types.h> /* open() */
+#include <sys/stat.h> /* open() */
+#include <fcntl.h> /* open() */
+#ifdef _MSC_VER
+#include <io.h>
+#else
+#include <unistd.h> /* unlink(), write() */
+#endif
+#include <errno.h> /* errno, strerror() */
+
+#include "tests.h"
+
+
+
+
+
+
+/*
+ * Test nc_strerror.
+ * Try on a bad error status.
+ * Test for each defined error status.
+ */
+int
+test_nc_strerror(void)
+{
+ int i;
+ const char *message, *expected_msg;
+ int nok=0;
+
+ static const struct {
+ int status;
+ const char *msg;
+ } ncerrs[] = {
+ {NC_NOERR, "No error"},
+ {NC_EBADID, "NetCDF: Not a valid ID"},
+ {NC_ENFILE, "NetCDF: Too many files open"},
+ {NC_EEXIST, "NetCDF: File exists && NC_NOCLOBBER"},
+ {NC_EINVAL, "NetCDF: Invalid argument"},
+ {NC_EPERM, "NetCDF: Write to read only"},
+ {NC_ENOTINDEFINE, "NetCDF: Operation not allowed in data mode"},
+ {NC_EINDEFINE, "NetCDF: Operation not allowed in define mode"},
+ {NC_EINVALCOORDS, "NetCDF: Index exceeds dimension bound"},
+ {NC_EMAXDIMS, "NetCDF: NC_MAX_DIMS exceeded"},
+ {NC_ENAMEINUSE, "NetCDF: String match to name in use"},
+ {NC_ENOTATT, "NetCDF: Attribute not found"},
+ {NC_EMAXATTS, "NetCDF: NC_MAX_ATTRS exceeded"},
+ {NC_EBADTYPE, "NetCDF: Not a valid data type or _FillValue type mismatch"},
+ {NC_EBADDIM, "NetCDF: Invalid dimension ID or name"},
+ {NC_EUNLIMPOS, "NetCDF: NC_UNLIMITED in the wrong index"},
+ {NC_EMAXVARS, "NetCDF: NC_MAX_VARS exceeded"},
+ {NC_ENOTVAR, "NetCDF: Variable not found"},
+ {NC_EGLOBAL, "NetCDF: Action prohibited on NC_GLOBAL varid"},
+ {NC_ENOTNC, "NetCDF: Unknown file format"},
+ {NC_ESTS, "NetCDF: In Fortran, string too short"},
+ {NC_EMAXNAME, "NetCDF: NC_MAX_NAME exceeded"},
+ {NC_EUNLIMIT, "NetCDF: NC_UNLIMITED size already in use"},
+ {NC_ENORECVARS, "NetCDF: nc_rec op when there are no record vars"},
+ {NC_ECHAR, "NetCDF: Attempt to convert between text & numbers"},
+ {NC_EEDGE, "NetCDF: Start+count exceeds dimension bound"},
+ {NC_ESTRIDE, "NetCDF: Illegal stride"},
+ {NC_EBADNAME, "NetCDF: Name contains illegal characters"},
+ {NC_ERANGE, "NetCDF: Numeric conversion not representable"},
+ {NC_ENOMEM, "NetCDF: Memory allocation (malloc) failure"},
+ {NC_EVARSIZE, "NetCDF: One or more variable sizes violate format constraints"},
+ {NC_EDIMSIZE, "NetCDF: Invalid dimension size"}
+ };
+
+ /* Try on a bad error status */
+ message = nc_strerror(-666);/* should fail */
+ expected_msg = "Unknown Error";
+ IF (strncmp(message, expected_msg, strlen(expected_msg)) != 0)
+ error(" nc_strerror on bad error status returned: %s", message);
+ ELSE_NOK
+
+ /* Try on each legitimate error status */
+ for (i=0; i<LEN_OF(ncerrs); i++) {
+ const char *message = nc_strerror(ncerrs[i].status);
+ IF (strcmp(message, ncerrs[i].msg) != 0)
+ error(" nc_strerror(%d) should return %s, not %s",
+ ncerrs[i].status, ncerrs[i].msg, message);
+ ELSE_NOK
+ }
+ return nok;
+}
+
+
+/*
+ * Test nc_open.
+ * If in read-only section of tests,
+ * Try to open a non-existent netCDF file, check error return.
+ * Open a file that is not a netCDF file, check error return.
+ * Open a netCDF file with a bad mode argument, check error return.
+ * Open a netCDF file with NC_NOWRITE, read-only mode, try to write, check error.
+ * Try to open a netcdf twice, check whether returned netcdf ids different.
+ * If in writable section of tests,
+ * Open a netCDF file with NC_WRITE mode, write something, close it.
+ * On exit, any open netCDF files are closed.
+ */
+#define NOT_NC_FILE "dummy_not_nc_file"
+int
+test_nc_open(void)
+{
+ int err, ncid, ncid2, nok=0;
+#if 0
+ int fd;
+ ssize_t w_len;
+#endif
+
+ /* Try to open a nonexistent file */
+ err = file_open("tooth-fairy.nc", NC_NOWRITE, &ncid); /* should fail */
+
+ /* on some systems (such as Lustre), opening an nonexisting file will
+ * actually create the file. In this case, we print the error messages on
+ * screen and move on to the next test, instead of aborting the entire test.
+ * The created file will be of zero-length and PnetCDF should complain it
+ * is not an NC file, i.e. NC_ENOTNC.
+ */
+ IF (err == NC_NOERR) {
+ error("opening a nonexistent file expects to fail, but got NC_NOERR\n");
+ }
+
+#ifndef USE_PARALLEL
+ IF (! NC_ISSYSERR(err))
+ error("nc_open of nonexistent file should have returned system error");
+#endif
+
+ /* Open a file that is not a netCDF file. But need a portable
+ * test that also works for cross-compiles ... */
+ /* err = nc_open("nc_test.o", NC_NOWRITE, &ncid);/\* should fail *\/ */
+ /* IF (err != NC_ENOTNC) */
+ /* error("nc_open of non-netCDF file: status = %d", err); */
+
+#if 0
+ /* create a not-nc file */
+ fd = open(NOT_NC_FILE, O_CREAT|O_WRONLY, 0600);
+ IF (fd == -1) {
+ error("Error: creating a non-CDF file (%s)", strerror(errno));
+ }
+ else {
+ w_len = write(fd, "0123456789abcdefghijklmnopqrstuvwxyz", 36);
+ assert(w_len >= 0);
+ close(fd);
+ }
+
+ /* Open a file that is not a netCDF file. */
+ err = file_open(NOT_NC_FILE, NC_NOWRITE, &ncid); /* should fail */
+ IF (err != NC_ENOTNC)
+ error("expecting NC_ENOTNC or NC_EFILE but got %s", nc_err_code_name(err));
+ ELSE_NOK
+
+ /* delete the not-nc file */
+ unlink(NOT_NC_FILE);
+#endif
+
+ /* Open a netCDF file in read-only mode, check that write fails */
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ ELSE_NOK
+ err = nc_redef(ncid); /* should fail */
+ IF (err != NC_EPERM)
+ error("expecting NC_EPERM but got %s", nc_err_code_name(err));
+ /* Opened OK, see if can open again and get a different netCDF ID */
+ err = file_open(testfile, NC_NOWRITE, &ncid2);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ else {
+ nc_close(ncid2);
+ nok++;
+ }
+ IF (ncid2 == ncid)
+ error("netCDF IDs for first and second open calls should differ");
+
+
+ { /* tests using netCDF scratch file */
+ err = file_create(scratch, NC_NOCLOBBER, &ncid2);
+ IF (err != NC_NOERR)
+ error("create: %s", nc_strerror(err));
+ else
+ nc_close(ncid2);
+ err = file_open(scratch, NC_WRITE, &ncid2);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ else {
+ nc_close(ncid2);
+ nok++;
+ }
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("remove of %s failed", scratch);
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+/*
+ * Test nc_close.
+ * Try to close a netCDF file twice, check whether second close fails.
+ * Try on bad handle, check error return.
+ * Try in define mode and data mode.
+ */
+int
+test_nc_close(void)
+{
+ int ncid, nok=0;
+ int err = file_open(testfile, NC_NOWRITE, &ncid);
+
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ /* Close a netCDF file twice, second time should fail */
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close failed: %s", nc_strerror(err));
+ ELSE_NOK
+ err = nc_close(ncid);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+
+ /* Try with a bad netCDF ID */
+ err = nc_close(BAD_ID);/* should fail */
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+
+ /* Close in data mode */
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close in data mode failed: %s", nc_strerror(err));
+ ELSE_NOK
+
+
+ { /* tests using netCDF scratch file */
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
+ IF (err != NC_NOERR)
+ error("create: %s", nc_strerror(err));
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close in define mode: %s", nc_strerror(err));
+ ELSE_NOK
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("remove of %s failed", scratch);
+ }
+ return nok;
+}
+
+
+/*
+ * Test nc_inq
+ * Try on bad handle, check error return.
+ * Try in data mode, check returned values.
+ * Try asking for subsets of info.
+ * If in writable section of tests,
+ * Try in define mode, after adding an unlimited dimension, variable.
+ * On exit, any open netCDF files are closed.
+ */
+int
+test_nc_inq(void)
+{
+ int ncid;
+ int ndims; /* number of dimensions */
+ int nvars; /* number of variables */
+ int ngatts; /* number of global attributes */
+ int recdim; /* id of unlimited dimension */
+ int err;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ /* Try on bad handle */
+ err = nc_inq(BAD_ID, 0, 0, 0, 0);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+
+ err = nc_inq(ncid, &ndims, &nvars, &ngatts, &recdim);
+ IF (err != NC_NOERR)
+ error("inq: %s", nc_strerror(err));
+ else IF (ndims != NDIMS)
+ error("inq: wrong number of dimensions returned, %d", ndims);
+ else IF (nvars != numVars)
+ error("inq: wrong number of variables returned, %d", nvars);
+ else IF (ngatts != numGatts)
+ error("inq: wrong number of global atts returned, %d", ngatts);
+ else IF (recdim != RECDIM)
+ error("inq: wrong record dimension ID returned, %d", recdim);
+ ELSE_NOK
+
+ /* Inguire for no info (useless, but should still work) */
+ err = nc_inq(ncid, 0, 0, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq for no info failed: %s", nc_strerror(err));
+ ELSE_NOK
+
+ /* Inguire for subsets of info */
+ ngatts = numGatts - 1; /* wipe out previous correct value */
+ err = nc_inq(ncid, 0, 0, &ngatts, 0);
+ IF (err != NC_NOERR)
+ error("inq for one item failed: %s", nc_strerror(err));
+ else IF (ngatts != numGatts)
+ error("inq subset: wrong number of global atts returned, %d", ngatts);
+ ELSE_NOK
+ ndims = NDIMS - 1;
+ nvars = numVars - 1;
+ err = nc_inq(ncid, &ndims, &nvars, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq for two items failed: %s", nc_strerror(err));
+ else IF (ndims != NDIMS)
+ error("inq subset: wrong number of dimensions returned, %d", ndims);
+ else IF (nvars != numVars)
+ error("inq subset: wrong number of variables returned, %d", nvars);
+ ELSE_NOK
+
+
+ { /* tests using netCDF scratch file */
+ int ncid2; /* for scratch netCDF dataset */
+
+ err = file_create(scratch, NC_NOCLOBBER, &ncid2);
+ IF (err != NC_NOERR) {
+ error("create: %s", nc_strerror(err));
+ } else { /* add dim, var, gatt, check inq */
+ int ndims0;
+ int nvars0;
+ int ngatts0;
+ int recdim0;
+ err = nc_enddef(ncid2); /* enter data mode */
+ err = nc_inq(ncid2, &ndims0, &nvars0, &ngatts0, &recdim0);
+ IF (err != NC_NOERR)
+ error("inq: %s", nc_strerror(err));
+ ELSE_NOK
+ err = nc_redef(ncid2); /* enter define mode */
+ /* Check that inquire still works in define mode */
+ err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim);
+ IF (err != NC_NOERR)
+ error("inq in define mode: %s", nc_strerror(err));
+ else IF (ndims != ndims0)
+ error("inq in define mode: ndims wrong, %d", ndims);
+ else IF (nvars != nvars0)
+ error("inq in define mode: nvars wrong, %d", nvars);
+ else IF (ngatts != ngatts0)
+ error("inq in define mode: ngatts wrong, %d", ngatts);
+ else IF (recdim != recdim0)
+ error("inq in define mode: recdim wrong, %d", recdim);
+ ELSE_NOK
+
+ {
+ int did, vid;
+ /* Add dim, var, global att */
+ err = nc_def_dim(ncid2, "inqd", 1L, &did);
+ IF (err != NC_NOERR)
+ error("def_dim: %s", nc_strerror(err));
+ err = nc_def_var(ncid2, "inqv", NC_FLOAT, 0, 0, &vid);
+ IF (err != NC_NOERR)
+ error("def_var: %s", nc_strerror(err));
+ }
+ err = nc_put_att_text(ncid2, NC_GLOBAL, "inqa", 1+strlen("stuff"),
+ "stuff");
+ IF (err != NC_NOERR)
+ error("put_att_text: %s", nc_strerror(err));
+
+ /* Make sure nc_inq sees the additions while in define mode */
+ err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim);
+ IF (err != NC_NOERR)
+ error("inq in define mode: %s", nc_strerror(err));
+ else IF (ndims != ndims0 + 1)
+ error("inq in define mode: ndims wrong, %d", ndims);
+ else IF (nvars != nvars0 + 1)
+ error("inq in define mode: nvars wrong, %d", nvars);
+ else IF (ngatts != ngatts0 + 1)
+ error("inq in define mode: ngatts wrong, %d", ngatts);
+ ELSE_NOK
+ err = nc_enddef(ncid2);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+
+ /* Make sure nc_inq stills sees additions in data mode */
+ err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim);
+ IF (err != NC_NOERR)
+ error("inq failed in data mode: %s", nc_strerror(err));
+ else IF (ndims != ndims0 + 1)
+ error("inq in define mode: ndims wrong, %d", ndims);
+ else IF (nvars != nvars0 + 1)
+ error("inq in define mode: nvars wrong, %d", nvars);
+ else IF (ngatts != ngatts0 + 1)
+ error("inq in define mode: ngatts wrong, %d", ngatts);
+ ELSE_NOK
+ nc_close(ncid2);
+ err = nc_delete(scratch);
+ IF (err != NC_NOERR)
+ error("remove of %s failed", scratch);
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_natts(void)
+{
+ int ncid;
+ int ngatts; /* number of global attributes */
+ int err, nok=0;
+
+ err = nc_inq_natts(BAD_ID, &ngatts);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_natts(ncid, &ngatts);
+ IF (err != NC_NOERR)
+ error("inq_natts: %s", nc_strerror(err));
+ else IF (ngatts != numGatts)
+ error("inq_natts: wrong number of global atts returned, %d", ngatts);
+ ELSE_NOK
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_ndims(void)
+{
+ int ncid;
+ int ndims;
+ int err;
+ int nok=0;
+
+ err = nc_inq_ndims(BAD_ID, &ndims);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_ndims(ncid, &ndims);
+ IF (err != NC_NOERR)
+ error("inq_ndims: %s", nc_strerror(err));
+ else IF (ndims != NDIMS)
+ error("inq_ndims: wrong number returned, %d", ndims);
+ ELSE_NOK
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_nvars(void)
+{
+ int ncid;
+ int nvars;
+ int err;
+ int nok=0;
+
+ err = nc_inq_nvars(BAD_ID, &nvars);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_nvars(ncid, &nvars);
+ IF (err != NC_NOERR)
+ error("inq_nvars: %s", nc_strerror(err));
+ else IF (nvars != numVars)
+ error("inq_nvars: wrong number returned, %d", nvars);
+ ELSE_NOK
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_unlimdim(void)
+{
+ int ncid;
+ int unlimdim;
+ int err;
+ int nok=0;
+
+ err = nc_inq_unlimdim(BAD_ID, &unlimdim);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_unlimdim(ncid, &unlimdim);
+ IF (err != NC_NOERR)
+ error("inq_unlimdim: %s", nc_strerror(err));
+ else IF (unlimdim != RECDIM)
+ error("inq_unlimdim: wrong number returned, %d", unlimdim);
+ ELSE_NOK
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_dimid(void)
+{
+ int ncid;
+ int dimid;
+ int i;
+ int err;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_dimid(ncid, "noSuch", &dimid);
+ IF (err != NC_EBADDIM)
+ error("expecting NC_EBADDIM but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ for (i = 0; i < NDIMS; i++) {
+ err = nc_inq_dimid(BAD_ID, dim_name[i], &dimid);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dimid(ncid, dim_name[i], &dimid);
+ IF (err != NC_NOERR)
+ error("inq_dimid: %s", nc_strerror(err));
+ else IF (dimid != i)
+ error("expected %d, got %d", i, dimid);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_dim(void)
+{
+ int ncid;
+ int i;
+ int err;
+ char name[NC_MAX_NAME];
+ size_t length;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < NDIMS; i++) {
+ err = nc_inq_dim(BAD_ID, i, name, &length);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dim(ncid, BAD_DIMID, name, &length);
+ IF (err != NC_EBADDIM)
+ error("expecting NC_EBADDIM but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dim(ncid, i, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ ELSE_NOK
+ err = nc_inq_dim(ncid, i, name, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ else IF (strcmp(dim_name[i],name))
+ error("name expected: %s, got: %s",dim_name[i],name);
+ else IF (dim_len[i] != length)
+ error("size expected: %d, got: %d",dim_len[i],length);
+ ELSE_NOK
+ err = nc_inq_dim(ncid, i, name, 0);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ else IF (strcmp(dim_name[i],name))
+ error("name expected: %s, got: %s",dim_name[i],name);
+ ELSE_NOK
+ err = nc_inq_dim(ncid, i, 0, &length);
+ IF (err != NC_NOERR)
+ error("inq_dim: %s", nc_strerror(err));
+ else IF (dim_len[i] != length)
+ error("size expected: %d, got: %d",dim_len[i],length);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_dimlen(void)
+{
+ int ncid;
+ int i;
+ int err;
+ size_t length;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < NDIMS; i++) {
+ err = nc_inq_dimlen(BAD_ID, i, &length);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dimlen(ncid, BAD_DIMID, &length);
+ IF (err != NC_EBADDIM)
+ error("expecting NC_EBADDIM but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dimlen(ncid, i, &length);
+ IF (err != NC_NOERR)
+ error("inq_dimlen: %s", nc_strerror(err));
+ else IF (dim_len[i] != length)
+ error("size expected: %d, got: %d",dim_len[i],length);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_dimname(void)
+{
+ int ncid;
+ int i;
+ int err;
+ char name[NC_MAX_NAME];
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < NDIMS; i++) {
+ err = nc_inq_dimname(BAD_ID, i, name);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dimname(ncid, BAD_DIMID, name);
+ IF (err != NC_EBADDIM)
+ error("expecting NC_EBADDIM but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_dimname(ncid, i, name);
+ IF (err != NC_NOERR)
+ error("inq_dimname: %s", nc_strerror(err));
+ else IF (strcmp(dim_name[i],name))
+ error("name expected: %s, got: %s",dim_name[i],name);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_varid(void)
+{
+ int ncid;
+ int varid;
+ int i;
+ int err;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ err = nc_inq_varid(ncid, "noSuch", &varid);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+
+ for (i = 0; i < numVars; i++) {
+ err = nc_inq_varid(BAD_ID, var_name[i], &varid);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_varid(ncid, var_name[i], &varid);
+ IF (err != NC_NOERR)
+ error("inq_varid: %s", nc_strerror(err));
+ else IF (varid != i)
+ error("expected %d, got %d", i, varid);
+ ELSE_NOK
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_var(void)
+{
+ int ncid;
+ int i;
+ int err;
+ char name[NC_MAX_NAME];
+ nc_type datatype;
+ int ndims;
+ int dimids[MAX_RANK];
+ int natts;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < numVars; i++) {
+ err = nc_inq_var(BAD_ID, i, name, &datatype, &ndims, dimids, &natts);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_var(ncid,BAD_VARID,name,&datatype,&ndims,dimids,&natts);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, 0, 0, 0, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, &natts);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ else IF (strcmp(var_name[i],name))
+ error("name expected: %s, got: %s",var_name[i],name);
+ else IF (var_type[i] != datatype)
+ error("type expected: %d, got: %d",var_type[i],datatype);
+ else IF (var_rank[i] != ndims)
+ error("ndims expected: %d, got: %d",var_rank[i],ndims);
+ else IF (!int_vec_eq(var_dimid[i],dimids,ndims))
+ error("unexpected dimid");
+ else IF (var_natts[i] != natts)
+ error("natts expected: %d, got: %d",var_natts[i],natts);
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, name, 0, 0, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ else IF (strcmp(var_name[i],name))
+ error("name expected: %s, got: %s",var_name[i],name);
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, 0, &datatype, 0, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ else IF (var_type[i] != datatype)
+ error("type expected: %d, got: %d",var_type[i],datatype);
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, 0, 0, &ndims, 0, 0);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ else IF (var_rank[i] != ndims)
+ error("ndims expected: %d, got: %d",var_rank[i],ndims);
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, 0, 0, 0, dimids, 0);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ else IF (!int_vec_eq(var_dimid[i],dimids,ndims))
+ error("unexpected dimid");
+ ELSE_NOK
+ err = nc_inq_var(ncid, i, 0, 0, 0, 0, &natts);
+ IF (err != NC_NOERR)
+ error("inq_var: %s", nc_strerror(err));
+ else IF (var_natts[i] != natts)
+ error("natts expected: %d, got: %d",var_natts[i],natts);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_vardimid(void)
+{
+ int ncid;
+ int i;
+ int err;
+ int dimids[MAX_RANK];
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < numVars; i++) {
+ err = nc_inq_vardimid(BAD_ID, i, dimids);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_vardimid(ncid, BAD_VARID, dimids);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_vardimid(ncid, i, dimids);
+ IF (err != NC_NOERR)
+ error("inq_vardimid: %s", nc_strerror(err));
+ else IF (!int_vec_eq(var_dimid[i], dimids, var_rank[i]))
+ error("unexpected dimid");
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_varname(void)
+{
+ int ncid;
+ int i;
+ int err;
+ char name[NC_MAX_NAME];
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < numVars; i++) {
+ err = nc_inq_varname(BAD_ID, i, name);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ nok++;
+ err = nc_inq_varname(ncid, BAD_VARID, name);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_varname(ncid, i, name);
+ IF (err != NC_NOERR)
+ error("inq_varname: %s", nc_strerror(err));
+ else IF (strcmp(var_name[i],name))
+ error("name expected: %s, got: %s",var_name[i],name);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_varnatts(void)
+{
+ int ncid;
+ int i;
+ int err;
+ int natts;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = -1; i < numVars; i++) {
+ err = nc_inq_varnatts(BAD_ID, i, &natts);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_varnatts(ncid, BAD_VARID, &natts);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_varnatts(ncid, VARID(i), &natts);
+ IF (err != NC_NOERR)
+ error("inq_varnatts: %s", nc_strerror(err));
+ else IF (NATTS(i) != natts)
+ error("natts expected: %d, got: %d",NATTS(i),natts);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_varndims(void)
+{
+ int ncid;
+ int i;
+ int err;
+ int ndims;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < numVars; i++) {
+ err = nc_inq_varndims(BAD_ID, i, &ndims);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_varndims(ncid, BAD_VARID, &ndims);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_varndims(ncid, i, &ndims);
+ IF (err != NC_NOERR)
+ error("inq_varndims: %s", nc_strerror(err));
+ else IF (var_rank[i] != ndims)
+ error("ndims expected: %d, got: %d",var_rank[i],ndims);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_vartype(void)
+{
+ int ncid;
+ int i;
+ int err;
+ nc_type datatype;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+ for (i = 0; i < numVars; i++) {
+ err = nc_inq_vartype(BAD_ID, i, &datatype);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_vartype(ncid, BAD_VARID, &datatype);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_vartype(ncid, i, &datatype);
+ IF (err != NC_NOERR)
+ error("inq_vartype: %s", nc_strerror(err));
+ else IF (var_type[i] != datatype)
+ error("type expected: %d, got: %d", var_type[i], datatype);
+ ELSE_NOK
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+/*
+ * Test nc_get_var1(,,,)
+ */
+int
+test_nc_get_var1(void)
+{
+ int ncid;
+ int i;
+ int err;
+ double expect;
+ int nok = 0; /* count of valid comparisons */
+ double buf[1]; /* (void *) buffer */
+ double value[1];
+ size_t j, index[MAX_RANK];
+
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR) error("open: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1(BAD_ID,0,NULL,NULL);
+ IF (err != NC_EBADID) error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_var1(ncid,BAD_VARID,NULL,NULL);
+ IF (err != NC_ENOTVAR) error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_var1(BAD_ID,i,NULL,value);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+
+
+
+ /* test NC_EINVALCOORDS */
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] = var_shape[i][j];
+ err = nc_get_var1(ncid,i,index,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ }
+ err = nc_get_var1(ncid,i,index,value);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* check if the contents are supposed to be */
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash( var_type[i], var_rank[i], index );
+ err = nc_get_var1(ncid,i,index,buf);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ err = nc2dbl( var_type[i], buf, &value[0]);
+ IF (err)
+ error("error in nc2dbl");
+ if (inRange(expect,var_type[i])) {
+ IF (!equal2(value[0],expect,var_type[i]))
+ error("expected: %G, got: %G", expect, value[0]);
+ ELSE_NOK
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+/*
+ * Test nc_get_vara(,,,,)
+ * Choose a random point dividing each dim into 2 parts
+ * Get 2^rank (nslabs) slabs so defined
+ * Each get overwrites buffer, so check after each get.
+ */
+int
+test_nc_get_vara(void)
+{
+ int ncid, d, i, k, err, nslabs;
+ int nok = 0; /* count of valid comparisons */
+ size_t j, nels;
+ size_t start[MAX_RANK];
+ size_t edge[MAX_RANK];
+ size_t index[MAX_RANK];
+ size_t mid[MAX_RANK];
+
+ double buf[MAX_NELS]; /* (void *) buffer */
+ double expect;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara(BAD_ID,0,NULL,NULL,NULL);
+ IF (err != NC_EBADID) error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_vara(ncid,BAD_VARID,NULL,NULL,NULL);
+ IF (err != NC_ENOTVAR) error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vara(BAD_ID,i,NULL,NULL,buf);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ }
+
+
+ /* test NC_EINVALCOORDS, first when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] = var_shape[i][j];
+ err = nc_get_vara(ncid,i,index,edge,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ index[j] = 0;
+ edge[j] = var_shape[i][j] + 1; /* edge error check */
+ err = nc_get_vara(ncid,i,start,edge,buf);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ }
+
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vara(ncid,i,start,edge,buf);
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_get_vara(ncid,i,start,edge,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ err = nc_get_vara(ncid,i,start,edge,buf);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ for (k = 0; k < nslabs; k++) {
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ }else{
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ nels *= edge[j];
+ }
+ err = nc_get_vara(ncid,i,start,edge,buf);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ for (j = 0; j < nels; j++) {
+ double got;
+ char *p = (char *) buf;
+ p += j * (size_t)nctypelen(var_type[i]);
+ err = nc2dbl( var_type[i], p, & got );
+ IF (err) error("error in nc2dbl");
+ err = toMixedBase(j, var_rank[i], edge, index);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index[d] += start[d];
+ expect = hash(var_type[i], var_rank[i], index);
+ if (inRange(expect,var_type[i])) {
+ IF (!equal2(got,expect,var_type[i])) {
+ error("buf read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("element number: %d ", j);
+ error("expect: %g", expect);
+ error("got: %g", got);
+ }
+ }
+ }
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+/*
+ * Test nc_get_vars(,,,,,)
+ * Choose a random point dividing each dim into 2 parts
+ * Get 2^rank (nslabs) slabs so defined
+ * Each get overwrites buffer, so check after each get.
+ */
+int
+test_nc_get_vars(void)
+{
+ int ncid;
+ int d;
+ int i;
+ int k;
+ int err;
+ int nslabs;
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* total count of valid comparisons */
+ int n; /* count of valid comparisons within var */
+ size_t j, m, nels;
+ size_t start[MAX_RANK];
+ size_t edge[MAX_RANK];
+ size_t index[MAX_RANK];
+ size_t index2[MAX_RANK];
+ size_t mid[MAX_RANK];
+ size_t count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+
+ double buf[MAX_NELS]; /* (void *) buffer */
+ char *p; /* (void *) pointer */
+ double expect;
+ double got;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars(BAD_ID,0,NULL,NULL,NULL,NULL);
+ IF (err != NC_EBADID) error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_vars(ncid,BAD_VARID,NULL,NULL,NULL,NULL);
+ IF (err != NC_ENOTVAR) error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_vars(BAD_ID,i,NULL,NULL,NULL,buf);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ }
+
+
+ /* test NC_EINVALCOORDS, first when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_vars(ncid,i,start,edge,stride,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_vars(ncid,i,start,edge,stride,buf);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_vars(ncid,i,start,edge,stride,buf);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_vars(ncid,i,start,edge,stride,buf);
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_get_vars(ncid,i,start,edge,stride,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ err = nc_get_vars(ncid,i,start,edge,stride,buf);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ n = 0;
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ }else{
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ nels *= count[j];
+ index[j] += start[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ err = nc_get_vars(ncid,i,index,count,stride,buf);
+ IF (err != NC_NOERR)
+ error("%s", nc_strerror(err));
+ ELSE_NOK
+
+ for (j = 0; j < nels; j++) {
+ p = (char *) buf;
+ p += j * (size_t)nctypelen(var_type[i]);
+ err = nc2dbl( var_type[i], p, & got );
+ IF (err != NC_NOERR)
+ error("error in nc2dbl");
+ err = toMixedBase(j, var_rank[i], count, index2);
+ IF (err != 0) error("error in toMixedBase");
+ for (d = 0; d < var_rank[i]; d++)
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
+ expect = hash(var_type[i], var_rank[i], index2);
+ if (inRange(expect,var_type[i])) {
+ IF (!equal2(got,expect,var_type[i])) {
+ error("buf read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("element number: %d ", j);
+ error("expect: %g, ", expect);
+ error("got: %g ", got);
+ }
+ }
+ ELSE_NOK
+ }
+ n++;
+ }
+ }
+ }
+ IF (n != var_nels[i]) {
+ error("count != nels");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("count: %d, ", n);
+ error("nels: %d ", var_nels[i]);
+ }
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+/*
+ * Test nc_get_varm(,,,,,,)
+ * Choose a random point dividing each dim into 2 parts
+ * Get 2^rank (nslabs) slabs so defined
+ * Choose random stride from 1 to edge
+ * Buffer should end up being bit image of external variable.
+ * So all gets for a variable store in different elements of buffer
+ */
+int
+test_nc_get_varm(void)
+{
+ int ncid;
+ int i;
+ int k;
+ int err;
+ int nslabs;
+ ptrdiff_t nstarts; /* number of different starts */
+ int nok = 0; /* total count of valid comparisons */
+ size_t j, m, nels;
+ size_t start[MAX_RANK];
+ size_t edge[MAX_RANK];
+ size_t index[MAX_RANK];
+ size_t mid[MAX_RANK];
+ size_t count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ ptrdiff_t imap[MAX_RANK];
+ ptrdiff_t imap2[MAX_RANK];
+
+ double buf[MAX_NELS]; /* (void *) buffer */
+ char *p; /* (void *) pointer */
+ double expect;
+ double got;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ /* check if can detect a bad file ID */
+ err = nc_get_varm(BAD_ID,0,NULL,NULL,NULL,NULL,NULL);
+ IF (err != NC_EBADID) error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+
+ /* check if can detect a bad variable ID */
+ err = nc_get_varm(ncid,BAD_VARID,NULL,NULL,NULL,NULL,NULL);
+ IF (err != NC_ENOTVAR) error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
+
+ for (i = 0; i < numVars; i++) {
+ assert(var_rank[i] <= MAX_RANK);
+ assert(var_nels[i] <= MAX_NELS);
+
+ /* check if can detect a bad file ID */
+ err = nc_get_varm(BAD_ID,i,NULL,NULL,NULL,NULL,buf);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+
+
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = 0;
+ edge[j] = 1;
+ stride[j] = 1;
+ imap[j] = 1;
+ }
+
+
+ /* test NC_EINVALCOORDS, first when edge[*] > 0 */
+ for (j = 0; j < var_rank[i]; j++) {
+ start[j] = var_shape[i][j];
+ err = nc_get_varm(ncid,i,start,edge,stride,imap,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ edge[j] = var_shape[i][j] + 1;
+ err = nc_get_varm(ncid,i,start,edge,stride,imap,buf);
+ IF (err != NC_EEDGE)
+ error("expecting NC_EEDGE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ edge[j] = 1;
+ stride[j] = 0;
+ err = nc_get_varm(ncid,i,start,edge,stride,imap,buf);
+ IF (err != NC_ESTRIDE)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ stride[j] = 1;
+ }
+ /* Check non-scalars for correct error returned even when there is
+ * nothing to get (edge[j]==0) */
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 0;
+
+ for (j = 0; j < var_rank[i]; j++) {
+ if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
+ start[j] = var_shape[i][j];
+ err = nc_get_varm(ncid,i,start,edge,stride,imap,buf);
+#ifdef RELAX_COORD_BOUND
+ IF (err != NC_NOERR) /* allowed when edge[j]==0 */
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+#else
+ IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+#endif
+ ELSE_NOK
+ start[j] = var_shape[i][j]+1; /* out of boundary check */
+ err = nc_get_varm(ncid,i,start,edge,stride,imap,buf);
+ IF (err != NC_EINVALCOORDS)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
+ ELSE_NOK
+ start[j] = 0;
+ }
+ for (j = 0; j < var_rank[i]; j++) edge[j] = 1;
+
+ err = nc_get_varm(ncid,i,start,edge,stride,imap,buf);
+ IF (err != NC_NOERR)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
+ ELSE_NOK
+
+ if (var_rank[i] > 0) {
+ int jj = var_rank[i] - 1;
+ /* imap[jj] = nctypelen(var_type[i]); */
+ imap[jj] = 1; /* in numbers of elements */
+ for (; jj > 0; jj--)
+ imap[jj-1] = imap[jj] * (ptrdiff_t)var_shape[i][jj];
+ }
+
+ /* Choose a random point dividing each dim into 2 parts */
+ /* get 2^rank (nslabs) slabs so defined */
+ nslabs = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ mid[j] = roll( var_shape[i][j] );
+ nslabs *= 2;
+ }
+ /* bits of k determine whether to get lower or upper part of dim */
+ /* choose random stride from 1 to edge */
+ for (k = 0; k < nslabs; k++) {
+ nstarts = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ if ((k >> j) & 1) {
+ start[j] = 0;
+ edge[j] = mid[j];
+ }else{
+ start[j] = mid[j];
+ edge[j] = var_shape[i][j] - mid[j];
+ }
+ sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+ stride[j] = (ptrdiff_t)sstride[j];
+ imap2[j] = imap[j] * stride[j];
+ nstarts *= stride[j];
+ }
+ for (m = 0; m < nstarts; m++) {
+ if (var_rank[i] == 0 && i%2 ) {
+ err = nc_get_varm(ncid,i,NULL,NULL,NULL,NULL,buf);
+ } else {
+ err = toMixedBase(m, var_rank[i], sstride, index);
+ IF (err != 0) error("error in toMixedBase");
+ nels = 1;
+ for (j = 0; j < var_rank[i]; j++) {
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
+ index[j] += start[j];
+ nels *= count[j];
+ }
+ /* Random choice of forward or backward */
+/* TODO
+ if ( roll(2) ) {
+ for (j = 0; j < var_rank[i]; j++) {
+ index[j] += (count[j] - 1) * (size_t)stride[j];
+ stride[j] = -stride[j];
+ }
+ }
+ */
+ j = fromMixedBase(var_rank[i], index, var_shape[i]);
+ p = (char *) buf + j * (size_t)nctypelen(var_type[i]);
+ err = nc_get_varm(ncid,i,index,count,stride,imap2,p);
+ }
+ IF (err != NC_NOERR)
+ error("%s", nc_strerror(err));
+ ELSE_NOK
+ }
+ }
+ p = (char *) buf;
+ for (j = 0; j < var_nels[i]; j++) {
+ err = toMixedBase(j, var_rank[i], var_shape[i], index);
+ IF (err != 0) error("error in toMixedBase");
+ expect = hash( var_type[i], var_rank[i], index);
+ err = nc2dbl( var_type[i], p, & got );
+ IF (err != NC_NOERR)
+ error("error in nc2dbl");
+ if (inRange(expect,var_type[i])) {
+ IF (!equal2(got,expect,var_type[i])) {
+ error("buf read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ", var_name[i]);
+ error("element number: %d ", j);
+ error("expect: %g, ", expect);
+ error("got: %g ", got);
+ }
+ }
+ ELSE_NOK
+ }
+ p += nctypelen(var_type[i]);
+ }
+ }
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_get_att(void)
+{
+ int ncid;
+ int i;
+ int j;
+ size_t k, ndx[1];
+ int err;
+ double buf[MAX_NELS]; /* (void *) buffer */
+ char *p; /* (void *) pointer */
+ double expect;
+ double got;
+ int nok = 0; /* count of valid comparisons */
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ err = nc_get_att(BAD_ID, i, ATT_NAME(i,j), buf);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_get_att(ncid, BAD_VARID, ATT_NAME(i,j), buf);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_get_att(ncid, i, "noSuch", buf);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_get_att(ncid, i, ATT_NAME(i,j), buf);
+ IF (err != NC_NOERR) {
+ error("%s", nc_strerror(err));
+ } else {
+ nok++;
+ for (k = 0; k < ATT_LEN(i,j); k++) {
+ ndx[0] = k;
+ expect = hash(ATT_TYPE(i,j), -1, ndx);
+ p = (char *) buf;
+ p += k * (size_t)nctypelen(ATT_TYPE(i,j));
+ err = nc2dbl( ATT_TYPE(i,j), p, &got );
+ IF (err != NC_NOERR)
+ error("error in nc2dbl");
+ if (inRange(expect,ATT_TYPE(i,j))) {
+ IF (!equal2(got,expect,ATT_TYPE(i,j))) {
+ error("buf read not that expected");
+ if (verbose) {
+ error("\n");
+ error("varid: %d, ", i);
+ error("var_name: %s, ",
+ i >= 0 ? var_name[i] : "Global");
+ error("att_name: %s, ", ATT_NAME(i,j));
+ error("element number: %d\n", k);
+ error("expect: %-23.16e\n", expect);
+ error(" got: %-23.16e", got);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_att(void)
+{
+ int ncid;
+ int i;
+ int j;
+ int err;
+ nc_type t;
+ size_t n;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ for (j = 0; j < NATTS(i); j++) {
+ err = nc_inq_att(BAD_ID, i, ATT_NAME(i,j), &t, &n);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_att(ncid, BAD_VARID, ATT_NAME(i,j), &t, &n);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_att(ncid, i, "noSuch", &t, &n);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_att(ncid, i, ATT_NAME(i,j), &t, &n);
+ IF (err != NC_NOERR) {
+ error("%s", nc_strerror(err));
+ } else {
+ IF (t != ATT_TYPE(i,j))
+ error("type not that expected");
+ ELSE_NOK
+ IF (n != ATT_LEN(i,j))
+ error("length not that expected");
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_attlen(void)
+{
+ int ncid;
+ int i;
+ int j;
+ int err;
+ size_t len;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ err = nc_inq_attlen(ncid, i, "noSuch", &len);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ for (j = 0; j < NATTS(i); j++) {
+ err = nc_inq_attlen(BAD_ID, i, ATT_NAME(i,j), &len);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attlen(ncid, BAD_VARID, ATT_NAME(i,j), &len);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attlen(ncid, i, ATT_NAME(i,j), &len);
+ IF (err != NC_NOERR) {
+ error("%s", nc_strerror(err));
+ } else {
+ IF (len != ATT_LEN(i,j))
+ error("len not that expected");
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_atttype(void)
+{
+ int ncid;
+ int i;
+ int j;
+ int err;
+ nc_type datatype;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ err = nc_inq_atttype(ncid, i, "noSuch", &datatype);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ for (j = 0; j < NATTS(i); j++) {
+ err = nc_inq_atttype(BAD_ID, i, ATT_NAME(i,j), &datatype);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_atttype(ncid, BAD_VARID, ATT_NAME(i,j), &datatype);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_atttype(ncid, i, ATT_NAME(i,j), &datatype);
+ IF (err != NC_NOERR) {
+ error("%s", nc_strerror(err));
+ } else {
+ IF (datatype != ATT_TYPE(i,j))
+ error("type not that expected");
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_attname(void)
+{
+ int ncid;
+ int i;
+ int j;
+ int err;
+ char name[NC_MAX_NAME];
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ err = nc_inq_attname(ncid, i, BAD_ATTNUM, name);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attname(ncid, i, NATTS(i), name);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ for (j = 0; j < NATTS(i); j++) {
+ err = nc_inq_attname(BAD_ID, i, j, name);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attname(ncid, BAD_VARID, j, name);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attname(ncid, i, j, name);
+ IF (err != NC_NOERR) {
+ error("%s", nc_strerror(err));
+ } else {
+ IF (strcmp(ATT_NAME(i,j), name) != 0)
+ error("name not that expected");
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
+
+
+int
+test_nc_inq_attid(void)
+{
+ int ncid;
+ int i;
+ int j;
+ int err;
+ int attnum;
+ int nok=0;
+
+ err = file_open(testfile, NC_NOWRITE, &ncid);
+ IF (err != NC_NOERR)
+ error("open: %s", nc_strerror(err));
+
+ for (i = -1; i < numVars; i++) {
+ err = nc_inq_attid(ncid, i, "noSuch", &attnum);
+ IF (err != NC_ENOTATT)
+ error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ for (j = 0; j < NATTS(i); j++) {
+ err = nc_inq_attid(BAD_ID, i, ATT_NAME(i,j), &attnum);
+ IF (err != NC_EBADID)
+ error("expecting NC_EBADID but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attid(ncid, BAD_VARID, ATT_NAME(i,j), &attnum);
+ IF (err != NC_ENOTVAR)
+ error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
+ ELSE_NOK
+ err = nc_inq_attid(ncid, i, ATT_NAME(i,j), &attnum);
+ IF (err != NC_NOERR) {
+ error("%s", nc_strerror(err));
+ } else {
+ IF (attnum != j)
+ error("attnum not that expected");
+ ELSE_NOK
+ }
+ }
+ }
+
+ err = nc_close(ncid);
+ IF (err != NC_NOERR)
+ error("close: %s", nc_strerror(err));
+ return nok;
+}
diff --git a/nc_test/test_write.m4 b/nc_test/test_write.c
similarity index 56%
copy from nc_test/test_write.m4
copy to nc_test/test_write.c
index f43294f..8cf116a 100644
--- a/nc_test/test_write.m4
+++ b/nc_test/test_write.c
@@ -1,23 +1,10 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-dnl This file is supposed to be the same as PnetCDF's test_write.m4
-dnl
-dnl If you see this line, you can ignore the next one.
/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
/*
* Copyright (C) 2003, Northwestern University and Argonne National Laboratory
* See COPYRIGHT notice in top-level directory.
*/
/* $Id: test_write.m4 2687 2016-12-08 18:32:13Z wkliao $ */
-dnl
-dnl The command-line m4 macro "PNETCDF" is to differentiate PnetCDF and netCDF
-dnl in terms of function prefix names (ncmpi_ vs. nc_), integer data types
-dnl (MPI_Offset vs. size_t), and function name substrings for external data
-dnl types.
-dnl
#if defined (_WIN32) || defined (_WIN64)
#include <io.h>
@@ -33,48 +20,26 @@ dnl
#endif
#include "tests.h"
+#include "config.h"
#include "math.h"
-define(`EXPECT_ERR',`error("expecting $1 but got %s",nc_err_code_name($2));')dnl
-define(`IntType', `ifdef(`PNETCDF',`MPI_Offset',`size_t')')dnl
-define(`PTRDType',`ifdef(`PNETCDF',`MPI_Offset',`ptrdiff_t')')dnl
-define(`TestFunc',`ifdef(`PNETCDF',`test_ncmpi_$1',`test_nc_$1')')dnl
-define(`APIFunc', `ifdef(`PNETCDF',`ncmpi_$1',`nc_$1')')dnl
-define(`FileOpen', `ifdef(`PNETCDF',`ncmpi_open(comm, $1, $2, info, $3)', `file_open($1, $2, $3)')')dnl
-define(`FileCreate',`ifdef(`PNETCDF',`ncmpi_create(comm, $1, $2, info, $3)', `file_create($1, $2, $3)')')dnl
-define(`FileDelete',`ifdef(`PNETCDF',`ncmpi_delete($1,$2)',`nc_delete($1)')')dnl
-define(`Def_Vars', `ifdef(`PNETCDF',`def_vars($1,$2)',`def_vars($1)')')dnl
-define(`Put_Atts', `ifdef(`PNETCDF',`put_atts($1,$2,$3)',`put_atts($1)')')dnl
-define(`Put_Vars', `ifdef(`PNETCDF',`put_vars($1,$2)',`put_vars($1)')')dnl
-define(`Check_File',`ifdef(`PNETCDF',`check_file($1,$2,$3)',`check_file($1)')')dnl
-define(`Check_Atts',`ifdef(`PNETCDF',`check_atts($1,$2,$3)',`check_atts($1)')')dnl
-define(`Check_Vars',`ifdef(`PNETCDF',`check_vars($1,$2)',`check_vars($1)')')dnl
-define(`VarArgs', `ifdef(`PNETCDF',`int numVars',`void')')dnl
-define(`AttVarArgs',`ifdef(`PNETCDF',`int numGatts, int numVars',`void')')dnl
-define(`GetVar1TYPE',`ifdef(`PNETCDF',`ncmpi_get_var1_$1_all',`nc_get_var1_$1')')dnl
-define(`PutVar1TYPE',`ifdef(`PNETCDF',`ncmpi_put_var1_$1_all',`nc_put_var1_$1')')dnl
-define(`PutVar1', `ifdef(`PNETCDF',`ncmpi_put_var1_all($1,$2,$3,$4,$5,$6)', `nc_put_var1($1,$2,$3,$4)')')dnl
-define(`PutVar', `ifdef(`PNETCDF',`ncmpi_put_var_all( $1,$2,$3,$4,$5)', `nc_put_var( $1,$2,$3)')')dnl
-define(`PutVara', `ifdef(`PNETCDF',`ncmpi_put_vara_all($1,$2,$3,$4,$5,$6,$7)', `nc_put_vara($1,$2,$3,$4,$5)')')dnl
-define(`PutVars', `ifdef(`PNETCDF',`ncmpi_put_vars_all($1,$2,$3,$4,$5,$6,$7,$8)', `nc_put_vars($1,$2,$3,$4,$5,$6)')')dnl
-define(`PutVarm', `ifdef(`PNETCDF',`ncmpi_put_varm_all($1,$2,$3,$4,$5,$6,$7,$8,$9)', `nc_put_varm($1,$2,$3,$4,$5,$6,$7)')')dnl
/*
- * Test APIFunc(create)
+ * Test nc_create
* For mode in NC_NOCLOBBER, NC_CLOBBER do:
* create netcdf file 'scratch.nc' with no data, close it
- * test that it can be opened, do APIFunc(inq) to check nvars = 0, etc.
+ * test that it can be opened, do nc_inq to check nvars = 0, etc.
* Try again in NC_NOCLOBBER mode, check error return
* On exit, delete this file
*/
int
-TestFunc(create)(void)
+test_nc_create(void)
{
int clobber; /* 0 for NC_NOCLOBBER, 1 for NC_CLOBBER */
int err;
@@ -86,19 +51,19 @@ TestFunc(create)(void)
int nok=0;
for (clobber = 0; clobber < 2; clobber++) {
- err = FileCreate(scratch, clobber ? NC_CLOBBER : NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, clobber ? NC_CLOBBER : NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR)
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileOpen(scratch, NC_NOWRITE, &ncid);
+ error("close: %s", nc_strerror(err));
+ err = file_open(scratch, NC_NOWRITE, &ncid);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(inq)(ncid, &ndims, &nvars, &ngatts, &recdim);
+ error("open: %s", nc_strerror(err));
+ err = nc_inq(ncid, &ndims, &nvars, &ngatts, &recdim);
IF (err != NC_NOERR)
- error("inq: %s", APIFunc(strerror)(err));
+ error("inq: %s", nc_strerror(err));
else IF (ndims != 0)
error("inq: wrong number of dimensions returned, %d", ndims);
else IF (nvars != 0)
@@ -108,17 +73,17 @@ TestFunc(create)(void)
else IF (recdim != -1)
error("inq: wrong record dimension ID returned, %d", recdim);
ELSE_NOK
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
}
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_EEXIST)
error("expecting NC_EEXIST but got %s", nc_err_code_name(err));
ELSE_NOK
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -126,8 +91,8 @@ TestFunc(create)(void)
/*
- * Test APIFunc(redef)
- * (In fact also tests APIFunc(enddef) - called from TestFunc(enddef))
+ * Test nc_redef
+ * (In fact also tests nc_enddef - called from test_nc_enddef)
* BAD_ID
* attempt redef (error) & enddef on read-only file
* create file, define dims & vars.
@@ -145,11 +110,11 @@ TestFunc(create)(void)
* check reopening with NC_WRITE and adding new dims, atts, vars
*/
int
-TestFunc(redef)(AttVarArgs)
+test_nc_redef(void)
{
int ncid; /* netcdf id */
/* used to force effective test of ncio->move() in redef */
- IntType sizehint = 8192;
+ size_t sizehint = 8192;
int dimid; /* dimension id */
int varid; /* variable id */
int varid1; /* variable id */
@@ -157,199 +122,184 @@ TestFunc(redef)(AttVarArgs)
const char * title = "Not funny";
double var;
char name[NC_MAX_NAME];
- IntType length;
+ size_t length;
int fmt_variant1, fmt_variant2;
/* BAD_ID tests */
- err = APIFunc(redef)(BAD_ID);
+ err = nc_redef(BAD_ID);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(enddef)(BAD_ID);
+ err = nc_enddef(BAD_ID);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
/* read-only tests */
- err = FileOpen(testfile, NC_NOWRITE, &ncid);
+ err = file_open(testfile, NC_NOWRITE, &ncid);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(redef)(ncid);
+ error("open: %s", nc_strerror(err));
+ err = nc_redef(ncid);
IF (err != NC_EPERM)
error("expecting NC_EPERM but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
/* tests using scratch file */
-ifdef(`PNETCDF',`dnl
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);',`dnl
- err = file__create(scratch, NC_NOCLOBBER, 0, &sizehint, &ncid);')
+ err = file__create(scratch, NC_NOCLOBBER, 0, &sizehint, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
-ifdef(`PNETCDF',,`dnl
/* limit for ncio implementations which have infinite chunksize */
- if(sizehint > 32768) sizehint = 16384;')
+ if(sizehint > 32768) sizehint = 16384;
def_dims(ncid);
- Def_Vars(ncid, numVars);
- Put_Atts(ncid, numGatts, numVars);
- err = APIFunc(inq_varid)(ncid, "d", &varid);
+ def_vars(ncid);
+ put_atts(ncid);
+ err = nc_inq_varid(ncid, "d", &varid);
IF (err != NC_NOERR)
- error("inq_varid: %s", APIFunc(strerror)(err));
+ error("inq_varid: %s", nc_strerror(err));
var = 1.0;
-ifdef(`PNETCDF', `
- err = ncmpi_begin_indep_data(ncid);
- IF (err != NC_EINDEFINE)
- error("expecting NC_EINDEFINE but got %s", nc_err_code_name(err));')dnl
- err = PutVar1TYPE(double)(ncid, varid, NULL, &var);
+ err = nc_put_var1_double(ncid, varid, NULL, &var);
IF (err != NC_EINDEFINE)
error("expecting NC_EINDEFINE but got %s", nc_err_code_name(err));
-ifdef(`PNETCDF', `
- err = ncmpi_end_indep_data(ncid);
- IF (err != NC_ENOTINDEP)
- error("expecting NC_ENOTINDEP but got %s", nc_err_code_name(err));')dnl
- err = APIFunc(redef)(ncid);
+ err = nc_redef(ncid);
IF (err != NC_EINDEFINE)
error("expecting NC_EINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
ELSE_NOK
- Put_Vars(ncid, numVars);
- err = APIFunc(def_dim)(ncid, "abc", sizehint, &dimid);
+ put_vars(ncid);
+ err = nc_def_dim(ncid, "abc", sizehint, &dimid);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
- err = APIFunc(redef)(ncid);
+ err = nc_redef(ncid);
IF (err != NC_NOERR)
- error("redef: %s", APIFunc(strerror)(err));
+ error("redef: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(set_fill)(ncid, NC_NOFILL, NULL);
+ err = nc_set_fill(ncid, NC_NOFILL, NULL);
IF (err != NC_NOERR)
- error("set_fill: %s", APIFunc(strerror)(err));
+ error("set_fill: %s", nc_strerror(err));
- err = APIFunc(def_dim)(ncid, "abc", sizehint, &dimid);
+ err = nc_def_dim(ncid, "abc", sizehint, &dimid);
IF (err != NC_NOERR)
- error("def_dim: %s", APIFunc(strerror)(err));
- err = APIFunc(def_var)(ncid, "abcScalar", NC_INT, 0, NULL, &varid);
+ error("def_dim: %s", nc_strerror(err));
+ err = nc_def_var(ncid, "abcScalar", NC_INT, 0, NULL, &varid);
IF (err != NC_NOERR)
- error("def_var: %s", APIFunc(strerror)(err));
- err = APIFunc(def_var)(ncid, "abc", NC_INT, 1, &dimid, &varid1);
+ error("def_var: %s", nc_strerror(err));
+ err = nc_def_var(ncid, "abc", NC_INT, 1, &dimid, &varid1);
IF (err != NC_NOERR)
- error("def_var: %s", APIFunc(strerror)(err));
+ error("def_var: %s", nc_strerror(err));
{
int dimids[NDIMS +1];
int ii = 0;
for(ii = 0; ii < NDIMS; ii++) dimids[ii] = ii;
dimids[NDIMS] = dimid;
- err = APIFunc(def_var)(ncid, "abcRec", NC_INT, NDIMS, dimids, &varid1);
+ err = nc_def_var(ncid, "abcRec", NC_INT, NDIMS, dimids, &varid1);
IF (err != NC_NOERR)
- error("def_var: %s", APIFunc(strerror)(err));
+ error("def_var: %s", nc_strerror(err));
}
- err = APIFunc(put_att_text)(ncid, NC_GLOBAL, "title", 1+strlen(title), title);
+ err = nc_put_att_text(ncid, NC_GLOBAL, "title", 1+strlen(title), title);
IF (err != NC_NOERR)
- error("put_att_text: %s", APIFunc(strerror)(err));
- err = APIFunc(enddef)(ncid);
+ error("put_att_text: %s", nc_strerror(err));
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
ELSE_NOK
var = 1.0;
-ifdef(`PNETCDF', `
- err = ncmpi_end_indep_data(ncid);
- IF (err != NC_ENOTINDEP)
- error("expecting NC_ENOTINDEP but got %s", nc_err_code_name(err));')dnl
- err = PutVar1TYPE(double)(ncid, varid, NULL, &var);
+ err = nc_put_var1_double(ncid, varid, NULL, &var);
IF (err != NC_NOERR)
- error("put_var1_double: %s", APIFunc(strerror)(err));
- err = APIFunc(inq_format)(ncid, &fmt_variant1);
+ error("put_var1_double: %s", nc_strerror(err));
+ err = nc_inq_format(ncid, &fmt_variant1);
IF (err)
- error("inq_format: %s", APIFunc(strerror)(err));
- err = APIFunc(close)(ncid);
+ error("inq_format: %s", nc_strerror(err));
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
/* check scratch file written as expected */
- Check_File(scratch, numGatts, numVars); /* checks all except "abc" stuff added above */
+ check_file(scratch); /* checks all except "abc" stuff added above */
- IF ((err = FileOpen(scratch, NC_NOWRITE, &ncid)))
- error("open: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(inq_dim)(ncid, dimid, name, &length)))
- error("inq_dim: %s", APIFunc(strerror)(err));
+ IF ((err = file_open(scratch, NC_NOWRITE, &ncid)))
+ error("open: %s", nc_strerror(err));
+ IF ((err = nc_inq_dim(ncid, dimid, name, &length)))
+ error("inq_dim: %s", nc_strerror(err));
IF (strcmp(name, "abc") != 0)
error("Unexpected dim name");
IF (length != sizehint)
error("Unexpected dim length");
- IF ((err = GetVar1TYPE(double)(ncid, varid, NULL, &var)))
- error("get_var1_double: %s", APIFunc(strerror)(err));
+ IF ((err = nc_get_var1_double(ncid, varid, NULL, &var)))
+ error("get_var1_double: %s", nc_strerror(err));
IF (var != 1.0)
error("get_var1_double: unexpected value");
- IF ((err = APIFunc(close)(ncid)))
- error("close: %s", APIFunc(strerror)(err));
+ IF ((err = nc_close(ncid)))
+ error("close: %s", nc_strerror(err));
/* open scratch file for writing, add another dim, var, att, then check */
- IF ((err = FileOpen(scratch, NC_WRITE, &ncid)))
- error("open: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(redef)(ncid)))
- error("redef: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(def_dim)(ncid, "def", sizehint, &dimid)))
- error("def_dim: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(def_var)(ncid, "defScalar", NC_INT, 0, NULL, &varid)))
- error("def_var: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(def_var)(ncid, "def", NC_INT, 1, &dimid, &varid1)))
- error("def_var: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(put_att_text)(ncid, NC_GLOBAL, "Credits", 1+strlen("Thanks!"), "Thanks!")))
- error("put_att_text: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(enddef)(ncid)))
- error("enddef: %s", APIFunc(strerror)(err));
+ IF ((err = file_open(scratch, NC_WRITE, &ncid)))
+ error("open: %s", nc_strerror(err));
+ IF ((err = nc_redef(ncid)))
+ error("redef: %s", nc_strerror(err));
+ IF ((err = nc_def_dim(ncid, "def", sizehint, &dimid)))
+ error("def_dim: %s", nc_strerror(err));
+ IF ((err = nc_def_var(ncid, "defScalar", NC_INT, 0, NULL, &varid)))
+ error("def_var: %s", nc_strerror(err));
+ IF ((err = nc_def_var(ncid, "def", NC_INT, 1, &dimid, &varid1)))
+ error("def_var: %s", nc_strerror(err));
+ IF ((err = nc_put_att_text(ncid, NC_GLOBAL, "Credits", 1+strlen("Thanks!"), "Thanks!")))
+ error("put_att_text: %s", nc_strerror(err));
+ IF ((err = nc_enddef(ncid)))
+ error("enddef: %s", nc_strerror(err));
var = 2.0;
- IF ((err = PutVar1TYPE(double)(ncid, varid, NULL, &var)))
- error("put_var1_double: %s", APIFunc(strerror)(err));
- IF ((err = APIFunc(close)(ncid)))
- error("close: %s", APIFunc(strerror)(err));
+ IF ((err = nc_put_var1_double(ncid, varid, NULL, &var)))
+ error("put_var1_double: %s", nc_strerror(err));
+ IF ((err = nc_close(ncid)))
+ error("close: %s", nc_strerror(err));
/* check scratch file written as expected */
- Check_File(scratch, numGatts, numVars);
+ check_file(scratch);
- err = FileOpen(scratch, NC_NOWRITE, &ncid);
+ err = file_open(scratch, NC_NOWRITE, &ncid);
IF (err)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(inq_dim)(ncid, dimid, name, &length);
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_dim(ncid, dimid, name, &length);
IF (err)
- error("inq_dim: %s", APIFunc(strerror)(err));
+ error("inq_dim: %s", nc_strerror(err));
IF (strcmp(name, "def") != 0)
error("Unexpected dim name");
IF (length != sizehint)
error("Unexpected dim length");
- err = GetVar1TYPE(double)(ncid, varid, NULL, &var);
+ err = nc_get_var1_double(ncid, varid, NULL, &var);
IF (err)
- error("get_var1_double: %s", APIFunc(strerror)(err));
+ error("get_var1_double: %s", nc_strerror(err));
IF (var != 2.0)
error("get_var1_double: unexpected value");
/* make sure format variant hasn't changed from when created */
- err = APIFunc(inq_format)(ncid, &fmt_variant2);
+ err = nc_inq_format(ncid, &fmt_variant2);
IF (err)
- error("inq_format: %s", APIFunc(strerror)(err));
+ error("inq_format: %s", nc_strerror(err));
IF (fmt_variant1 != fmt_variant2)
error("enddef changed format variant");
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -357,82 +307,80 @@ ifdef(`PNETCDF', `
/*
- * Test APIFunc(enddef)
- * Simply calls TestFunc(redef) which tests both APIFunc(redef) & APIFunc(enddef)
+ * Test nc_enddef
+ * Simply calls test_nc_redef which tests both nc_redef & nc_enddef
*/
int
-TestFunc(enddef)(AttVarArgs)
+test_nc_enddef(void)
{
- ifdef(`PNETCDF',
- `return test_ncmpi_redef(numGatts, numVars);',
- `return test_nc_redef();')
+ return test_nc_redef();
}
/*
- * Test APIFunc(sync)
+ * Test nc_sync
* try with bad handle, check error
* try in define mode, check error
* try writing with one handle, reading with another on same netCDF
*/
int
-TestFunc(sync)(AttVarArgs)
+test_nc_sync(void)
{
int ncidw; /* netcdf id for writing */
int ncidr; /* netcdf id for reading */
int nok=0, err;
/* BAD_ID test */
- err = APIFunc(sync)(BAD_ID);
+ err = nc_sync(BAD_ID);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- /* create scratch file & try APIFunc(sync) in define mode */
- err = FileCreate(scratch, NC_NOCLOBBER, &ncidw);
+ /* create scratch file & try nc_sync in define mode */
+ err = file_create(scratch, NC_NOCLOBBER, &ncidw);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(sync)(ncidw);
+ err = nc_sync(ncidw);
IF (err != NC_EINDEFINE)
error("expecting NC_EINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
/* write using same handle */
def_dims(ncidw);
- Def_Vars(ncidw, numVars);
- Put_Atts(ncidw, numGatts, numVars);
- err = APIFunc(enddef)(ncidw);
+ def_vars(ncidw);
+ put_atts(ncidw);
+ err = nc_enddef(ncidw);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- Put_Vars(ncidw, numVars);
- err = APIFunc(sync)(ncidw);
+ error("enddef: %s", nc_strerror(err));
+ put_vars(ncidw);
+ err = nc_sync(ncidw);
IF (err != NC_NOERR)
- error("sync of ncidw failed: %s", APIFunc(strerror)(err));
+ error("sync of ncidw failed: %s", nc_strerror(err));
ELSE_NOK
- /* open another handle, APIFunc(sync), read (check) */
- err = FileOpen(scratch, NC_NOWRITE, &ncidr);
+ /* open another handle, nc_sync, read (check) */
+ err = file_open(scratch, NC_NOWRITE, &ncidr);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(sync)(ncidr);
+ error("open: %s", nc_strerror(err));
+ err = nc_sync(ncidr);
IF (err != NC_NOERR)
- error("sync of ncidr failed: %s", APIFunc(strerror)(err));
+ error("sync of ncidr failed: %s", nc_strerror(err));
ELSE_NOK
check_dims(ncidr);
- Check_Atts(ncidr, numGatts, numVars);
- Check_Vars(ncidr, numVars);
+ check_atts(ncidr);
+ check_vars(ncidr);
/* close both handles */
- err = APIFunc(close)(ncidr);
+ err = nc_close(ncidr);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = APIFunc(close)(ncidw);
+ error("close: %s", nc_strerror(err));
+ err = nc_close(ncidw);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -440,14 +388,14 @@ TestFunc(sync)(AttVarArgs)
/*
- * Test APIFunc(abort)
+ * Test nc_abort
* try with bad handle, check error
* try in define mode before anything written, check that file was deleted
- * try after APIFunc(enddef), APIFunc(redef), define new dims, vars, atts
+ * try after nc_enddef, nc_redef, define new dims, vars, atts
* try after writing variable
*/
int
-TestFunc(abort)(AttVarArgs)
+test_nc_abort(void)
{
int ncid; /* netcdf id */
int err;
@@ -457,99 +405,95 @@ TestFunc(abort)(AttVarArgs)
int nok=0;
/* BAD_ID test */
- err = APIFunc(abort)(BAD_ID);
+ err = nc_abort(BAD_ID);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- /* create scratch file & try APIFunc(abort) in define mode */
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ /* create scratch file & try nc_abort in define mode */
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
- Put_Atts(ncid, numGatts, numVars);
- err = APIFunc(abort)(ncid);
+ def_vars(ncid);
+ put_atts(ncid);
+ err = nc_abort(ncid);
IF (err != NC_NOERR)
- error("abort of ncid failed: %s", APIFunc(strerror)(err));
+ error("abort of ncid failed: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(close)(ncid); /* should already be closed */
+ err = nc_close(ncid); /* should already be closed */
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
- err = FileDelete(scratch, info); /* should already be deleted */
-ifdef(`PNETCDF',
- `IF (err != NC_ENOENT && err != NC_EFILE)
- error("expecting NC_ENOENT or NC_EFILE but got %s", nc_err_code_name(err));',
- `IF (err != ENOENT && err != NC_EIO)
- error("expecting ENOENT or NC_EIO but got %s", nc_err_code_name(err));')dnl
-
+ err = nc_delete(scratch); /* should already be deleted */
+IF (err != ENOENT && err != NC_EIO)
+ error("expecting ENOENT or NC_EIO but got %s", nc_err_code_name(err));
/*
* create scratch file
- * do APIFunc(enddef) & APIFunc(redef)
+ * do nc_enddef & nc_redef
* define new dims, vars, atts
- * try APIFunc(abort): should restore previous state (no dims, vars, atts)
+ * try nc_abort: should restore previous state (no dims, vars, atts)
*/
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- err = APIFunc(redef)(ncid);
+ error("enddef: %s", nc_strerror(err));
+ err = nc_redef(ncid);
IF (err != NC_NOERR)
- error("redef: %s", APIFunc(strerror)(err));
+ error("redef: %s", nc_strerror(err));
def_dims(ncid);
- Def_Vars(ncid, numVars);
- Put_Atts(ncid, numGatts, numVars);
- err = APIFunc(abort)(ncid);
+ def_vars(ncid);
+ put_atts(ncid);
+ err = nc_abort(ncid);
IF (err != NC_NOERR)
- error("abort of ncid failed: %s", APIFunc(strerror)(err));
+ error("abort of ncid failed: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(close)(ncid); /* should already be closed */
+ err = nc_close(ncid); /* should already be closed */
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
- err = FileOpen(scratch, NC_NOWRITE, &ncid);
+ err = file_open(scratch, NC_NOWRITE, &ncid);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(inq)(ncid, &ndims, &nvars, &ngatts, NULL);
+ error("open: %s", nc_strerror(err));
+ err = nc_inq(ncid, &ndims, &nvars, &ngatts, NULL);
IF (err != NC_NOERR)
- error("inq: %s", APIFunc(strerror)(err));
+ error("inq: %s", nc_strerror(err));
IF (ndims != 0)
error("ndims should be 0");
IF (nvars != 0)
error("nvars should be 0");
IF (ngatts != 0)
error("ngatts should be 0");
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- /* try APIFunc(abort) in data mode - should just close */
- err = FileCreate(scratch, NC_CLOBBER, &ncid);
+ /* try nc_abort in data mode - should just close */
+ err = file_create(scratch, NC_CLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
- Put_Atts(ncid, numGatts, numVars);
- err = APIFunc(enddef)(ncid);
+ def_vars(ncid);
+ put_atts(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- Put_Vars(ncid, numVars);
- err = APIFunc(abort)(ncid);
+ error("enddef: %s", nc_strerror(err));
+ put_vars(ncid);
+ err = nc_abort(ncid);
IF (err != NC_NOERR)
- error("abort of ncid failed: %s", APIFunc(strerror)(err));
+ error("abort of ncid failed: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(close)(ncid); /* should already be closed */
+ err = nc_close(ncid); /* should already be closed */
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
- Check_File(scratch, numGatts, numVars);
- err = FileDelete(scratch, info);
+ check_file(scratch);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -557,107 +501,107 @@ ifdef(`PNETCDF',
/*
- * Test APIFunc(def_dim)
+ * Test nc_def_dim
* try with bad netCDF handle, check error
* try in data mode, check error
* check that returned id is one more than previous id
* try adding same dimension twice, check error
* try with illegal sizes, check error
- * make sure unlimited size works, shows up in APIFunc(inq_unlimdim)
+ * make sure unlimited size works, shows up in nc_inq_unlimdim
* try to define a second unlimited dimension, check error
*/
int
-TestFunc(def_dim)(VarArgs)
+test_nc_def_dim(void)
{
int ncid;
int err; /* status */
int i, nok=0;
int dimid; /* dimension id */
- IntType length;
+ size_t length;
/* BAD_ID test */
- err = APIFunc(def_dim)(BAD_ID, "abc", 8, &dimid);
+ err = nc_def_dim(BAD_ID, "abc", 8, &dimid);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
/* data mode test */
- err = FileCreate(scratch, NC_CLOBBER, &ncid);
+ err = file_create(scratch, NC_CLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- err = APIFunc(def_dim)(ncid, "abc", 8, &dimid);
+ error("enddef: %s", nc_strerror(err));
+ err = nc_def_dim(ncid, "abc", 8, &dimid);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
/* define-mode tests: unlimited dim */
- err = APIFunc(redef)(ncid);
+ err = nc_redef(ncid);
IF (err != NC_NOERR)
- error("redef: %s", APIFunc(strerror)(err));
- err = APIFunc(def_dim)(ncid, dim_name[0], NC_UNLIMITED, &dimid);
+ error("redef: %s", nc_strerror(err));
+ err = nc_def_dim(ncid, dim_name[0], NC_UNLIMITED, &dimid);
IF (err != NC_NOERR)
- error("def_dim: %s", APIFunc(strerror)(err));
+ error("def_dim: %s", nc_strerror(err));
ELSE_NOK
IF (dimid != 0)
error("Unexpected dimid");
ELSE_NOK
- err = APIFunc(inq_unlimdim)(ncid, &dimid);
+ err = nc_inq_unlimdim(ncid, &dimid);
IF (err != NC_NOERR)
- error("inq_unlimdim: %s", APIFunc(strerror)(err));
+ error("inq_unlimdim: %s", nc_strerror(err));
IF (dimid != 0)
error("Unexpected recdim");
- err = APIFunc(inq_dimlen)(ncid, dimid, &length);
+ err = nc_inq_dimlen(ncid, dimid, &length);
IF (length != 0)
error("Unexpected length");
- err = APIFunc(def_dim)(ncid, "abc", NC_UNLIMITED, &dimid);
+ err = nc_def_dim(ncid, "abc", NC_UNLIMITED, &dimid);
IF (err != NC_EUNLIMIT)
error("expecting NC_EUNLIMIT but got %s", nc_err_code_name(err));
ELSE_NOK
/* define-mode tests: remaining dims */
for (i = 1; i < NDIMS; i++) {
- err = APIFunc(def_dim)(ncid, dim_name[i-1], dim_len[i], &dimid);
+ err = nc_def_dim(ncid, dim_name[i-1], dim_len[i], &dimid);
IF (err != NC_ENAMEINUSE)
error("expecting NC_ENAMEINUSE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(def_dim)(ncid, BAD_NAME, dim_len[i], &dimid);
+ err = nc_def_dim(ncid, BAD_NAME, dim_len[i], &dimid);
IF (err != NC_EBADNAME)
error("expecting NC_EBADNAME but got %s", nc_err_code_name(err));
ELSE_NOK
-ifdef(`PNETCDF', ,`if(sizeof(long) > 4) /* Fix: dmh 11/4/2011: works only if sizeof(long) > 4 */')
+if(sizeof(long) > 4) /* Fix: dmh 11/4/2011: works only if sizeof(long) > 4 */
{
- err = APIFunc(def_dim)(ncid, dim_name[i], (IntType)(NC_UNLIMITED-1), &dimid);
+ err = nc_def_dim(ncid, dim_name[i], (size_t)(NC_UNLIMITED-1), &dimid);
IF (err != NC_EDIMSIZE)
error("expecting NC_EDIMSIZE but got %s", nc_err_code_name(err));
ELSE_NOK
}
- err = APIFunc(def_dim)(ncid, dim_name[i], dim_len[i], &dimid);
+ err = nc_def_dim(ncid, dim_name[i], dim_len[i], &dimid);
IF (err != NC_NOERR)
- error("def_dim: %s", APIFunc(strerror)(err));
+ error("def_dim: %s", nc_strerror(err));
ELSE_NOK
IF (dimid != i)
error("Unexpected dimid");
}
/* Following just to expand unlimited dim */
- Def_Vars(ncid, numVars);
- err = APIFunc(enddef)(ncid);
+ def_vars(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- Put_Vars(ncid, numVars);
+ error("enddef: %s", nc_strerror(err));
+ put_vars(ncid);
/* Check all dims */
check_dims(ncid);
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -665,52 +609,52 @@ ifdef(`PNETCDF', ,`if(sizeof(long) > 4) /* Fix: dmh 11/4/2011: works only if siz
/*
- * Test APIFunc(rename_dim)
+ * Test nc_rename_dim
* try with bad netCDF handle, check error
- * check that proper rename worked with APIFunc(inq_dim)
+ * check that proper rename worked with nc_inq_dim
* try renaming to existing dimension name, check error
* try with bad dimension handle, check error
*/
int
-TestFunc(rename_dim)(void)
+test_nc_rename_dim(void)
{
int ncid;
int err, nok=0; /* status */
char name[NC_MAX_NAME];
/* BAD_ID test */
- err = APIFunc(rename_dim)(BAD_ID, 0, "abc");
+ err = nc_rename_dim(BAD_ID, 0, "abc");
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
/* main tests */
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- err = APIFunc(rename_dim)(ncid, BAD_DIMID, "abc");
+ err = nc_rename_dim(ncid, BAD_DIMID, "abc");
IF (err != NC_EBADDIM)
error("expecting NC_EBADDIM but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(rename_dim)(ncid, 2, "abc");
+ err = nc_rename_dim(ncid, 2, "abc");
IF (err != NC_NOERR)
- error("rename_dim: %s", APIFunc(strerror)(err));
+ error("rename_dim: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_dimname)(ncid, 2, name);
+ err = nc_inq_dimname(ncid, 2, name);
IF (strcmp(name, "abc") != 0)
error("Unexpected name: %s", name);
- err = APIFunc(rename_dim)(ncid, 0, "abc");
+ err = nc_rename_dim(ncid, 0, "abc");
IF (err != NC_ENAMEINUSE)
error("expecting NC_ENAMEINUSE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -718,11 +662,11 @@ TestFunc(rename_dim)(void)
/*
- * Test APIFunc(def_var)
+ * Test nc_def_var
* try with bad netCDF handle, check error
* try with bad name, check error
* scalar tests:
- * check that proper define worked with APIFunc(inq_var)
+ * check that proper define worked with nc_inq_var
* try redefining an existing variable, check error
* try with bad datatype, check error
* try with bad number of dimensions, check error
@@ -731,7 +675,7 @@ TestFunc(rename_dim)(void)
* try with bad dimension ids, check error
*/
int
-TestFunc(def_var)(VarArgs)
+test_nc_def_var(void)
{
int ncid;
int varid;
@@ -744,72 +688,72 @@ TestFunc(def_var)(VarArgs)
nc_type datatype;
/* BAD_ID test */
- err = APIFunc(def_var)(BAD_ID, "abc", NC_SHORT, 0, NULL, &varid);
+ err = nc_def_var(BAD_ID, "abc", NC_SHORT, 0, NULL, &varid);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
/* scalar tests */
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(def_var)(ncid, "abc", NC_SHORT, 0, NULL, &varid);
+ err = nc_def_var(ncid, "abc", NC_SHORT, 0, NULL, &varid);
IF (err != NC_NOERR)
- error("def_var: %s", APIFunc(strerror)(err));
+ error("def_var: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_var)(ncid, varid, name, &datatype, &ndims, dimids, &natts);
+ err = nc_inq_var(ncid, varid, name, &datatype, &ndims, dimids, &natts);
IF (err != NC_NOERR)
- error("inq_var: %s", APIFunc(strerror)(err));
+ error("inq_var: %s", nc_strerror(err));
IF (strcmp(name, "abc") != 0)
error("Unexpected name: %s", name);
IF (datatype != NC_SHORT)
error("Unexpected datatype");
IF (ndims != 0)
error("Unexpected rank");
- err = APIFunc(def_var)(ncid, BAD_NAME, NC_SHORT, 0, NULL, &varid);
+ err = nc_def_var(ncid, BAD_NAME, NC_SHORT, 0, NULL, &varid);
IF (err != NC_EBADNAME)
error("expecting NC_EBADNAME but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(def_var)(ncid, "abc", NC_SHORT, 0, NULL, &varid);
+ err = nc_def_var(ncid, "abc", NC_SHORT, 0, NULL, &varid);
IF (err != NC_ENAMEINUSE)
error("expecting NC_ENAMEINUSE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(def_var)(ncid, "ABC", BAD_TYPE, -1, dimids, &varid);
+ err = nc_def_var(ncid, "ABC", BAD_TYPE, -1, dimids, &varid);
IF (err != NC_EBADTYPE)
error("expecting NC_EBADTYPE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(def_var)(ncid, "ABC", NC_SHORT, -1, dimids, &varid);
+ err = nc_def_var(ncid, "ABC", NC_SHORT, -1, dimids, &varid);
IF (err != NC_EINVAL)
error("expecting NC_EINVAL but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- err = APIFunc(def_var)(ncid, "ABC", NC_SHORT, 0, dimids, &varid);
+ error("enddef: %s", nc_strerror(err));
+ err = nc_def_var(ncid, "ABC", NC_SHORT, 0, dimids, &varid);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
/* general tests using global vars */
- err = FileCreate(scratch, NC_CLOBBER, &ncid);
+ err = file_create(scratch, NC_CLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
for (i = 0; i < numVars; i++) {
- err = APIFunc(def_var)(ncid, var_name[i], var_type[i], var_rank[i],
+ err = nc_def_var(ncid, var_name[i], var_type[i], var_rank[i],
var_dimid[i], &varid);
IF (err != NC_NOERR)
- error("def_var: %s", APIFunc(strerror)(err));
+ error("def_var: %s", nc_strerror(err));
ELSE_NOK
IF (varid != i)
error("Unexpected varid");
@@ -818,15 +762,15 @@ TestFunc(def_var)(VarArgs)
/* try bad dim ids */
dimids[0] = BAD_DIMID;
- err = APIFunc(def_var)(ncid, "abc", NC_SHORT, 1, dimids, &varid);
+ err = nc_def_var(ncid, "abc", NC_SHORT, 1, dimids, &varid);
IF (err != NC_EBADDIM)
error("expecting NC_EBADDIM but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -834,40 +778,40 @@ TestFunc(def_var)(VarArgs)
/*
- * Test PutVar1
+ * Test nc_put_var1(,,,)
*/
int
-TestFunc(put_var1)(VarArgs)
+test_nc_put_var1(void)
{
int i, err, ncid, nok=0;
- IntType j, index[MAX_RANK];
+ size_t j, index[MAX_RANK];
double value[1];
double buf[1]; /* (void *) buffer */
- ifdef(`PNETCDF', `MPI_Datatype datatype;')
+
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
/* check if can detect a bad file ID */
- err = PutVar1(BAD_ID, 0, NULL, NULL, 1, MPI_DATATYPE_NULL);
+ err = nc_put_var1(BAD_ID,0,NULL,NULL);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
/* check if can detect a bad variable ID */
- err = PutVar1(ncid, BAD_VARID, NULL, NULL, 1, MPI_DATATYPE_NULL);
+ err = nc_put_var1(ncid,BAD_VARID,NULL,NULL);
IF (err != NC_ENOTVAR)
- EXPECT_ERR(NC_ENOTVAR, err)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
ELSE_NOK
for (i = 0; i < numVars; i++) {
@@ -876,19 +820,8 @@ TestFunc(put_var1)(VarArgs)
value[0] = 5; /* reset to a value within bounds */
- ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
+
-ifdef(`PNETCDF',`dnl
- /* for non-scalar variables, argument start cannot be NULL */
- err = PutVar1(ncid, i, NULL, value, 1, datatype);
- if (var_rank[i] == 0) { /* scalar variable */
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EINVALCOORDS) {
- EXPECT_ERR(NC_EINVALCOORDS, err)
- }
- ELSE_NOK
-')dnl
/* test NC_EINVALCOORDS */
for (j = 0; j < var_rank[i]; j++) index[j] = 0;
@@ -896,9 +829,9 @@ ifdef(`PNETCDF',`dnl
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
index[j] = var_shape[i][j]; /* out of boundary check */
- err = PutVar1(ncid, i, index, value, 1, datatype);
+ err = nc_put_var1(ncid,i,index,value);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
index[j] = 0;
}
@@ -912,20 +845,20 @@ ifdef(`PNETCDF',`dnl
IF (err != NC_NOERR)
error("error in dbl2nc var:%s type:%s",
var_name[i],s_nc_type(var_type[i]));
- err = PutVar1(ncid, i, index, buf, 1, datatype);
+ err = nc_put_var1(ncid,i,index,buf);
IF (err != NC_NOERR)
- EXPECT_ERR(NC_NOERR, err)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
ELSE_NOK
}
}
}
- Check_Vars(ncid, numVars);
- err = APIFunc(close)(ncid);
+ check_vars(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -933,49 +866,49 @@ ifdef(`PNETCDF',`dnl
/*
- * Test PutVara
+ * Test nc_put_vara(,,,,)
* Choose a random point dividing each dim into 2 parts
* Put 2^rank (nslabs) slabs so defined
* Redefine buffer for each put.
- * At end check all variables using Check_Vars
+ * At end check all variables using check_vars()
*/
int
-TestFunc(put_vara)(VarArgs)
+test_nc_put_vara(void)
{
int d, i, k, err, nslabs, ncid, nok=0;
- IntType j, nels;
- IntType start[MAX_RANK];
- IntType edge[MAX_RANK];
- IntType index[MAX_RANK];
- IntType mid[MAX_RANK];
+ size_t j, nels;
+ size_t start[MAX_RANK];
+ size_t edge[MAX_RANK];
+ size_t index[MAX_RANK];
+ size_t mid[MAX_RANK];
double buf[MAX_NELS]; /* (void *) buffer */
char *p; /* (void *) pointer */
double value;
- ifdef(`PNETCDF', `MPI_Datatype datatype;')
+
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
/* check if can detect a bad file ID */
- err = PutVara(BAD_ID, 0, start, edge, buf, 1, MPI_DATATYPE_NULL);
+ err = nc_put_vara(BAD_ID,0,start,edge,buf);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
/* check if can detect a bad variable ID */
- err = PutVara(ncid, BAD_VARID, start, edge, buf, 1, MPI_DATATYPE_NULL);
+ err = nc_put_vara(ncid,BAD_VARID,start,edge,buf);
IF (err != NC_ENOTVAR)
- EXPECT_ERR(NC_ENOTVAR, err)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
ELSE_NOK
for (i = 0; i < numVars; i++) {
@@ -985,53 +918,32 @@ TestFunc(put_vara)(VarArgs)
buf[0] = 5; /* reset to a value within bounds */
/* check if can detect a bad file ID */
- err = PutVara(BAD_ID, i, start, edge, buf, 1, MPI_DATATYPE_NULL);
+ err = nc_put_vara(BAD_ID,i,start,edge,buf);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
- ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
+
for (j = 0; j < var_rank[i]; j++) {
start[j] = 0;
edge[j] = 1;
}
-ifdef(`PNETCDF',`dnl
- /* for non-scalar variables, argument start cannot be NULL */
- err = PutVara(ncid, i, NULL, NULL, buf, 1, datatype);
- if (var_rank[i] == 0) { /* scalar variable */
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EINVALCOORDS) {
- EXPECT_ERR(NC_EINVALCOORDS, err)
- }
- ELSE_NOK
-
- /* for non-scalar variables, argument count cannot be NULL */
- err = PutVara(ncid, i, start, NULL, buf, 1, datatype);
- if (var_rank[i] == 0) {
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EEDGE) {
- EXPECT_ERR(NC_EEDGE, err)
- }
- ELSE_NOK
-')dnl
/* first test when edge[*] > 0 */
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
start[j] = var_shape[i][j];
- err = PutVara(ncid, i, start, edge, buf, 1, datatype);
+ err = nc_put_vara(ncid,i,start,edge,buf);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
start[j] = 0;
edge[j] = var_shape[i][j] + 1;
- err = PutVara(ncid, i, start, edge, buf, 1, datatype);
+ err = nc_put_vara(ncid,i,start,edge,buf);
IF (err != NC_EEDGE)
- EXPECT_ERR(NC_EEDG, err)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
ELSE_NOK
edge[j] = 1;
}
@@ -1041,19 +953,19 @@ ifdef(`PNETCDF',`dnl
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == RECDIM) continue; /* skip record dim */
start[j] = var_shape[i][j];
- err = PutVara(ncid, i, start, edge, buf, 0, datatype);
+ err = nc_put_vara(ncid,i,start,edge,buf);
#ifdef RELAX_COORD_BOUND
IF (err != NC_NOERR) /* allowed when edge[j]==0 */
- EXPECT_ERR(NC_NOERR, err)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
#else
IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
#endif
ELSE_NOK
start[j] = var_shape[i][j]+1; /* out of boundary check */
- err = PutVara(ncid, i, start, edge, buf, 1, datatype);
+ err = nc_put_vara(ncid,i,start,edge,buf);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
start[j] = 0;
}
@@ -1093,19 +1005,19 @@ ifdef(`PNETCDF',`dnl
error("error in dbl2nc");
p += nctypelen(var_type[i]);
}
- err = PutVara(ncid, i, start, edge, buf, nels, datatype);
+ err = nc_put_vara(ncid,i,start,edge,buf);
IF (err != NC_NOERR)
- error("%s", APIFunc(strerror)(err));
+ error("%s", nc_strerror(err));
ELSE_NOK
}
}
- Check_Vars(ncid, numVars);
- err = APIFunc(close)(ncid);
+ check_vars(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -1113,55 +1025,55 @@ ifdef(`PNETCDF',`dnl
/*
- * Test PutVars
+ * Test nc_put_vars(,,,,,)
* Choose a random point dividing each dim into 2 parts
* Put 2^rank (nslabs) slabs so defined
* Choose random stride from 1 to edge
* Redefine buffer for each put.
- * At end check all variables using Check_Vars
+ * At end check all variables using check_vars()
*/
int
-TestFunc(put_vars)(VarArgs)
+test_nc_put_vars(void)
{
int ncid, d, i, k, err, nslabs, nok=0;
- PTRDType nstarts; /* number of different starts */
- IntType j, m, nels;
- IntType start[MAX_RANK];
- IntType edge[MAX_RANK];
- IntType index[MAX_RANK];
- IntType index2[MAX_RANK];
- IntType mid[MAX_RANK];
- IntType count[MAX_RANK];
- IntType sstride[MAX_RANK];
- PTRDType stride[MAX_RANK];
+ ptrdiff_t nstarts; /* number of different starts */
+ size_t j, m, nels;
+ size_t start[MAX_RANK];
+ size_t edge[MAX_RANK];
+ size_t index[MAX_RANK];
+ size_t index2[MAX_RANK];
+ size_t mid[MAX_RANK];
+ size_t count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
double buf[MAX_NELS]; /* (void *) buffer */
char *p; /* (void *) pointer */
double value;
- ifdef(`PNETCDF', `MPI_Datatype datatype;')
+
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
/* check if can detect a bad file ID */
- err = PutVars(BAD_ID, 0, NULL, NULL, NULL, NULL, 1, MPI_DATATYPE_NULL);
+ err = nc_put_vars(BAD_ID,0,NULL,NULL,NULL,NULL);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
/* check if can detect a bad variable ID */
- err = PutVars(ncid, BAD_VARID, NULL, NULL, NULL, NULL, 1, MPI_DATATYPE_NULL);
+ err = nc_put_vars(ncid,BAD_VARID,NULL,NULL,NULL,NULL);
IF (err != NC_ENOTVAR)
- EXPECT_ERR(NC_ENOTVAR, err)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
ELSE_NOK
for (i = 0; i < numVars; i++) {
@@ -1171,12 +1083,12 @@ TestFunc(put_vars)(VarArgs)
buf[0] = 5; /* reset to a value within bounds */
/* check if can detect a bad file ID */
- err = PutVars(BAD_ID, i, NULL, NULL, NULL, buf, 1, MPI_DATATYPE_NULL);
+ err = nc_put_vars(BAD_ID,i,NULL,NULL,NULL,buf);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
- ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
+
for (j = 0; j < var_rank[i]; j++) {
start[j] = 0;
@@ -1184,47 +1096,26 @@ TestFunc(put_vars)(VarArgs)
stride[j] = 1;
}
-ifdef(`PNETCDF',`dnl
- /* for non-scalar variables, argument start cannot be NULL */
- err = PutVars(ncid, i, NULL, NULL, NULL, buf, 1, datatype);
- if (var_rank[i] == 0) { /* scalar variable */
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EINVALCOORDS) {
- EXPECT_ERR(NC_EINVALCOORDS, err)
- }
- ELSE_NOK
-
- /* for non-scalar variables, argument count cannot be NULL */
- err = PutVars(ncid, i, start, NULL, NULL, buf, 1, datatype);
- if (var_rank[i] == 0) {
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EEDGE) {
- EXPECT_ERR(NC_EEDGE, err)
- }
- ELSE_NOK
-')dnl
/* first test when edge[*] > 0 */
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == 0) continue; /* skip record dim */
start[j] = var_shape[i][j];
- err = PutVars(ncid, i, start, edge, stride, buf, 1, datatype);
+ err = nc_put_vars(ncid,i,start,edge,stride,buf);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
start[j] = 0;
edge[j] = var_shape[i][j] + 1; /* edge error check */
- err = PutVars(ncid, i, start, edge, stride, buf, 1, datatype);
+ err = nc_put_vars(ncid,i,start,edge,stride,buf);
IF (err != NC_EEDGE)
- EXPECT_ERR(NC_EEDG, err)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
ELSE_NOK
edge[j] = 1;
stride[j] = 0; /* strided edge error check */
- err = PutVars(ncid, i, start, edge, stride, buf, 1, datatype);
+ err = nc_put_vars(ncid,i,start,edge,stride,buf);
IF (err != NC_ESTRIDE)
- EXPECT_ERR(NC_ESTRIDE, err)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
ELSE_NOK
stride[j] = 1;
}
@@ -1234,19 +1125,19 @@ ifdef(`PNETCDF',`dnl
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == 0) continue; /* skip record dim */
start[j] = var_shape[i][j];
- err = PutVars(ncid, i, start, edge, stride, buf, 0, datatype);
+ err = nc_put_vars(ncid,i,start,edge,stride,buf);
#ifdef RELAX_COORD_BOUND
IF (err != NC_NOERR) /* allowed when edge[j]==0 */
- EXPECT_ERR(NC_NOERR, err)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
#else
IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
#endif
ELSE_NOK
start[j] = var_shape[i][j]+1; /* out of boundary check */
- err = PutVars(ncid, i, start, edge, stride, buf, 1, datatype);
+ err = nc_put_vars(ncid,i,start,edge,stride,buf);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
start[j] = 0;
}
@@ -1272,7 +1163,7 @@ ifdef(`PNETCDF',`dnl
edge[j] = var_shape[i][j] - mid[j];
}
sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
- stride[j] = (PTRDType)sstride[j];
+ stride[j] = (ptrdiff_t)sstride[j];
nstarts *= stride[j];
}
for (m = 0; m < nstarts; m++) {
@@ -1280,7 +1171,7 @@ ifdef(`PNETCDF',`dnl
IF (err != 0) error("error in toMixedBase");
nels = 1;
for (j = 0; j < var_rank[i]; j++) {
- count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
nels *= count[j];
index[j] += start[j];
}
@@ -1288,7 +1179,7 @@ ifdef(`PNETCDF',`dnl
/* TODO
if ( roll(2) ) {
for (j = 0; j < var_rank[i]; j++) {
- index[j] += (count[j] - 1) * (IntType)stride[j];
+ index[j] += (count[j] - 1) * (size_t)stride[j];
stride[j] = -stride[j];
}
}
@@ -1298,7 +1189,7 @@ ifdef(`PNETCDF',`dnl
err = toMixedBase(j, var_rank[i], count, index2);
IF (err != 0) error("error in toMixedBase");
for (d = 0; d < var_rank[i]; d++)
- index2[d] = index[d] + index2[d] * (IntType)stride[d];
+ index2[d] = index[d] + index2[d] * (size_t)stride[d];
value = hash(var_type[i], var_rank[i], index2);
if (!inRange(value, var_type[i]))
value = 0;
@@ -1307,20 +1198,20 @@ ifdef(`PNETCDF',`dnl
error("error in dbl2nc");
p += nctypelen(var_type[i]);
}
- err = PutVars(ncid, i, index, count, stride, buf, nels, datatype);
+ err = nc_put_vars(ncid,i,index,count,stride,buf);
IF (err != NC_NOERR)
- EXPECT_ERR(NC_NOERR, err)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
ELSE_NOK
}
}
}
- Check_Vars(ncid, numVars);
- err = APIFunc(close)(ncid);
+ check_vars(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -1328,62 +1219,62 @@ ifdef(`PNETCDF',`dnl
/*
- * Test PutVarm
+ * Test nc_put_varm(,,,,,,)
* Choose a random point dividing each dim into 2 parts
* Put 2^rank (nslabs) slabs so defined
* Choose random stride from 1 to edge
* Buffer is bit image of whole external variable.
* So all puts for a variable put different elements of buffer
- * At end check all variables using Check_Vars
+ * At end check all variables using check_vars()
*/
int
-TestFunc(put_varm)(VarArgs)
+test_nc_put_varm(void)
{
int ncid, nok=0;
int i;
int k;
int err;
int nslabs;
- IntType j, m;
- PTRDType nstarts; /* number of different starts */
- IntType start[MAX_RANK];
- IntType edge[MAX_RANK];
- IntType index[MAX_RANK];
- IntType mid[MAX_RANK];
- IntType count[MAX_RANK];
- IntType sstride[MAX_RANK];
- PTRDType stride[MAX_RANK];
- PTRDType imap[MAX_RANK];
- PTRDType imap2[MAX_RANK];
- ifdef(`PNETCDF', `IntType bufcount;')
+ size_t j, m;
+ ptrdiff_t nstarts; /* number of different starts */
+ size_t start[MAX_RANK];
+ size_t edge[MAX_RANK];
+ size_t index[MAX_RANK];
+ size_t mid[MAX_RANK];
+ size_t count[MAX_RANK];
+ size_t sstride[MAX_RANK];
+ ptrdiff_t stride[MAX_RANK];
+ ptrdiff_t imap[MAX_RANK];
+ ptrdiff_t imap2[MAX_RANK];
+
double buf[MAX_NELS]; /* (void *) buffer */
char *p; /* (void *) pointer */
double value;
- ifdef(`PNETCDF', `MPI_Datatype datatype;')
+
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
/* check if can detect a bad file ID */
- err = PutVarm(NC_EBADID, 0, NULL, NULL, NULL, NULL, NULL, 1, MPI_DATATYPE_NULL);
+ err = nc_put_varm(NC_EBADID,0,NULL,NULL,NULL,NULL,NULL);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
/* check if can detect a bad variable ID */
- err = PutVarm(ncid, BAD_VARID, NULL, NULL, NULL, NULL, NULL, 1, MPI_DATATYPE_NULL);
+ err = nc_put_varm(ncid,BAD_VARID,NULL,NULL,NULL,NULL,NULL);
IF (err != NC_ENOTVAR)
- EXPECT_ERR(NC_ENOTVAR, err)
+ error("expecting NC_ENOTVAR but got %s",nc_err_code_name(err));
ELSE_NOK
for (i = 0; i < numVars; i++) {
@@ -1393,12 +1284,12 @@ TestFunc(put_varm)(VarArgs)
buf[0] = 5; /* reset to a value within bounds */
/* check if can detect a bad file ID */
- err = PutVarm(BAD_ID, i, NULL, NULL, NULL, NULL, buf, 1, MPI_DATATYPE_NULL);
+ err = nc_put_varm(BAD_ID,i,NULL,NULL,NULL,NULL,buf);
IF (err != NC_EBADID)
- EXPECT_ERR(NC_EBADID, err)
+ error("expecting NC_EBADID but got %s",nc_err_code_name(err));
ELSE_NOK
- ifdef(`PNETCDF', `datatype = nc_mpi_type(var_type[i]);')
+
for (j = 0; j < var_rank[i]; j++) {
start[j] = 0;
@@ -1407,47 +1298,26 @@ TestFunc(put_varm)(VarArgs)
imap[j] = 1;
}
-ifdef(`PNETCDF',`dnl
- /* for non-scalar variables, argument start cannot be NULL */
- err = PutVarm(ncid, i, NULL, NULL, NULL, NULL, buf, 1, datatype);
- if (var_rank[i] == 0) { /* scalar variable */
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EINVALCOORDS) {
- EXPECT_ERR(NC_EINVALCOORDS, err)
- }
- ELSE_NOK
-
- /* for non-scalar variables, argument count cannot be NULL */
- err = PutVarm(ncid, i, start, NULL, NULL, NULL, buf, 1, datatype);
- if (var_rank[i] == 0) {
- IF (err != NC_NOERR) EXPECT_ERR(NC_NOERR, err)
- }
- else IF (err != NC_EEDGE) {
- EXPECT_ERR(NC_EEDGE, err)
- }
- ELSE_NOK
-')dnl
/* first test when edge[*] > 0 */
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == 0) continue; /* skip record dim */
start[j] = var_shape[i][j];
- err = PutVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
+ err = nc_put_varm(ncid,i,start,edge,stride,imap,buf);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
start[j] = 0;
edge[j] = var_shape[i][j] + 1; /* edge error check */
- err = PutVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
+ err = nc_put_varm(ncid,i,start,edge,stride,imap,buf);
IF (err != NC_EEDGE)
- EXPECT_ERR(NC_EEDG, err)
+ error("expecting NC_EEDG but got %s",nc_err_code_name(err));
ELSE_NOK
edge[j] = 1;
stride[j] = 0; /* strided edge error check */
- err = PutVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
+ err = nc_put_varm(ncid,i,start,edge,stride,imap,buf);
IF (err != NC_ESTRIDE)
- EXPECT_ERR(NC_ESTRIDE, err)
+ error("expecting NC_ESTRIDE but got %s",nc_err_code_name(err));
ELSE_NOK
stride[j] = 1;
}
@@ -1457,19 +1327,19 @@ ifdef(`PNETCDF',`dnl
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] == 0) continue; /* skip record dim */
start[j] = var_shape[i][j];
- err = PutVarm(ncid, i, start, edge, stride, imap, buf, 0, datatype);
+ err = nc_put_varm(ncid,i,start,edge,stride,imap,buf);
#ifdef RELAX_COORD_BOUND
IF (err != NC_NOERR) /* allowed when edge[j]==0 */
- EXPECT_ERR(NC_NOERR, err)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
#else
IF (err != NC_EINVALCOORDS) /* not allowed even when edge[j]==0 */
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
#endif
ELSE_NOK
start[j] = var_shape[i][j]+1; /* out of boundary check */
- err = PutVarm(ncid, i, start, edge, stride, imap, buf, 1, datatype);
+ err = nc_put_varm(ncid,i,start,edge,stride,imap,buf);
IF (err != NC_EINVALCOORDS)
- EXPECT_ERR(NC_EINVALCOORDS, err)
+ error("expecting NC_EINVALCOORDS but got %s",nc_err_code_name(err));
ELSE_NOK
start[j] = 0;
}
@@ -1480,7 +1350,7 @@ ifdef(`PNETCDF',`dnl
imap[jj] = nctypelen(var_type[i]); /* netCDF considers imap in bytes */
imap[jj] = 1; /* PnetCDF considers imap in elements */
for (; jj > 0; jj--)
- imap[jj-1] = imap[jj] * (PTRDType)var_shape[i][jj];
+ imap[jj-1] = imap[jj] * (ptrdiff_t)var_shape[i][jj];
}
p = (char *) buf;
for (j = 0; j < var_nels[i]; j++) {
@@ -1515,47 +1385,47 @@ ifdef(`PNETCDF',`dnl
edge[j] = var_shape[i][j] - mid[j];
}
sstride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
- stride[j] = (PTRDType)sstride[j];
- imap2[j] = imap[j] * (PTRDType)sstride[j];
+ stride[j] = (ptrdiff_t)sstride[j];
+ imap2[j] = imap[j] * (ptrdiff_t)sstride[j];
nstarts *= stride[j];
}
for (m = 0; m < nstarts; m++) {
if (var_rank[i] == 0 && i%2 == 0) {
- err = PutVarm(ncid, i, NULL, NULL, NULL, NULL, buf, 1, datatype);
+ err = nc_put_varm(ncid,i,NULL,NULL,NULL,NULL,buf);
} else {
err = toMixedBase(m, var_rank[i], sstride, index);
IF (err != 0) error("error in toMixedBase");
for (j = 0; j < var_rank[i]; j++) {
- count[j] = 1 + (edge[j] - index[j] - 1) / (IntType)stride[j];
+ count[j] = 1 + (edge[j] - index[j] - 1) / (size_t)stride[j];
index[j] += start[j];
}
/* Random choice of forward or backward */
/* TODO
if ( roll(2) ) {
for (j = 0; j < var_rank[i]; j++) {
- index[j] += (count[j] - 1) * (IntType)stride[j];
+ index[j] += (count[j] - 1) * (size_t)stride[j];
stride[j] = -stride[j];
}
}
*/
j = fromMixedBase(var_rank[i], index, var_shape[i]);
p = (char *) buf + (int)j * nctypelen(var_type[i]);
- ifdef(`PNETCDF', `for (bufcount=1,j=0; j<var_rank[i]; j++) bufcount *= count[j];')
- err = PutVarm(ncid, i, index, count, stride, imap2, p, bufcount, datatype);
+
+ err = nc_put_varm(ncid,i,index,count,stride,imap2,p);
}
IF (err != NC_NOERR)
- EXPECT_ERR(NC_NOERR, err)
+ error("expecting NC_NOERR but got %s",nc_err_code_name(err));
ELSE_NOK
}
}
}
- Check_Vars(ncid, numVars);
- err = APIFunc(close)(ncid);
+ check_vars(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -1563,15 +1433,15 @@ ifdef(`PNETCDF',`dnl
/*
- * Test APIFunc(rename_var)
+ * Test nc_rename_var
* try with bad netCDF handle, check error
* try with bad variable handle, check error
* try renaming to existing variable name, check error
- * check that proper rename worked with APIFunc(inq_varid)
+ * check that proper rename worked with nc_inq_varid
* try in data mode, check error
*/
int
-TestFunc(rename_var)(VarArgs)
+test_nc_rename_var(void)
{
int ncid;
int varid;
@@ -1579,72 +1449,72 @@ TestFunc(rename_var)(VarArgs)
int i;
char name[NC_MAX_NAME];
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(rename_var)(ncid, BAD_VARID, "newName");
+ err = nc_rename_var(ncid, BAD_VARID, "newName");
IF (err != NC_ENOTVAR)
error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
ELSE_NOK
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
/* Prefix "new_" to each name */
for (i = 0; i < numVars; i++) {
- err = APIFunc(rename_var)(BAD_ID, i, "newName");
+ err = nc_rename_var(BAD_ID, i, "newName");
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(rename_var)(ncid, i, var_name[numVars-1]);
+ err = nc_rename_var(ncid, i, var_name[numVars-1]);
IF (err != NC_ENAMEINUSE)
error("expecting NC_ENAMEINUSE but got %s", nc_err_code_name(err));
ELSE_NOK
strcpy(name, "new_");
strcat(name, var_name[i]);
- err = APIFunc(rename_var)(ncid, i, name);
+ err = nc_rename_var(ncid, i, name);
IF (err != NC_NOERR)
- error("rename_var: %s", APIFunc(strerror)(err));
+ error("rename_var: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_varid)(ncid, name, &varid);
+ err = nc_inq_varid(ncid, name, &varid);
IF (err != NC_NOERR)
- error("inq_varid: %s", APIFunc(strerror)(err));
+ error("inq_varid: %s", nc_strerror(err));
IF (varid != i)
error("Unexpected varid");
}
/* Change to data mode */
/* Try making names even longer. Then restore original names */
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
for (i = 0; i < numVars; i++) {
strcpy(name, "even_longer_");
strcat(name, var_name[i]);
- err = APIFunc(rename_var)(ncid, i, name);
+ err = nc_rename_var(ncid, i, name);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(rename_var)(ncid, i, var_name[i]);
+ err = nc_rename_var(ncid, i, var_name[i]);
IF (err != NC_NOERR)
- error("rename_var: %s", APIFunc(strerror)(err));
+ error("rename_var: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_varid)(ncid, var_name[i], &varid);
+ err = nc_inq_varid(ncid, var_name[i], &varid);
IF (err != NC_NOERR)
- error("inq_varid: %s", APIFunc(strerror)(err));
+ error("inq_varid: %s", nc_strerror(err));
IF (varid != i)
error("Unexpected varid");
}
- Put_Vars(ncid, numVars);
- Check_Vars(ncid, numVars);
+ put_vars(ncid);
+ check_vars(ncid);
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -1652,28 +1522,28 @@ TestFunc(rename_var)(VarArgs)
int
-TestFunc(put_att)(AttVarArgs)
+test_nc_put_att(void)
{
int ncid, nok=0;
int varid;
int i;
int j;
- IntType k, ndx[1];
+ size_t k, ndx[1];
int err;
double buf[MAX_NELS]; /* (void *) buffer */
char *p; /* (void *) pointer */
char *name; /* of att */
nc_type datatype; /* of att */
- IntType length; /* of att */
+ size_t length; /* of att */
double value;
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
for (i = -1; i < numVars; i++) {
varid = VARID(i);
@@ -1681,19 +1551,19 @@ TestFunc(put_att)(AttVarArgs)
name = ATT_NAME(i,j);
datatype = ATT_TYPE(i,j);
length = ATT_LEN(i,j);
- err = APIFunc(put_att)(BAD_ID, varid, name, datatype, length, buf);
+ err = nc_put_att(BAD_ID, varid, name, datatype, length, buf);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(put_att)(ncid, varid, BAD_NAME, datatype, length, buf);
+ err = nc_put_att(ncid, varid, BAD_NAME, datatype, length, buf);
IF (err != NC_EBADNAME)
error("expecting NC_EBADNAME but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(put_att)(ncid, BAD_VARID, name, datatype, length, buf);
+ err = nc_put_att(ncid, BAD_VARID, name, datatype, length, buf);
IF (err != NC_ENOTVAR)
error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(put_att)(ncid, varid, name, BAD_TYPE, length, buf);
+ err = nc_put_att(ncid, varid, name, BAD_TYPE, length, buf);
IF (err != NC_EBADTYPE)
error("expecting NC_EBADTYPE but got %s", nc_err_code_name(err));
ELSE_NOK
@@ -1708,19 +1578,19 @@ TestFunc(put_att)(AttVarArgs)
error("error in dbl2nc");
p += nctypelen(datatype);
}
- err = APIFunc(put_att)(ncid, varid, name, datatype, length, buf);
+ err = nc_put_att(ncid, varid, name, datatype, length, buf);
IF (err != NC_NOERR)
- error("%s", APIFunc(strerror)(err));
+ error("%s", nc_strerror(err));
ELSE_NOK
}
}
- Check_Atts(ncid, numGatts, numVars);
- err = APIFunc(close)(ncid);
+ check_atts(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -1728,7 +1598,7 @@ TestFunc(put_att)(AttVarArgs)
/*
- * Test APIFunc(copy_att)
+ * Test nc_copy_att
* try with bad source or target netCDF handles, check error
* try with bad source or target variable handle, check error
* try with nonexisting attribute, check error
@@ -1740,7 +1610,7 @@ TestFunc(put_att)(AttVarArgs)
* try with same ncid for source and target, same variable
*/
int
-TestFunc(copy_att)(AttVarArgs)
+test_nc_copy_att(void)
{
int ncid_in;
int ncid_out;
@@ -1750,79 +1620,79 @@ TestFunc(copy_att)(AttVarArgs)
int j=0;
char *name; /* of att */
nc_type datatype; /* of att */
- IntType length; /* of att */
+ size_t length; /* of att */
char value;
- err = FileOpen(testfile, NC_NOWRITE, &ncid_in);
+ err = file_open(testfile, NC_NOWRITE, &ncid_in);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid_out);
+ error("open: %s", nc_strerror(err));
+ err = file_create(scratch, NC_NOCLOBBER, &ncid_out);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid_out);
- Def_Vars(ncid_out, numVars);
+ def_vars(ncid_out);
for (i = -1; i < numVars; i++) {
varid = VARID(i);
for (j = 0; j < NATTS(i); j++) {
name = ATT_NAME(i,j);
- err = APIFunc(copy_att)(ncid_in, BAD_VARID, name, ncid_out, varid);
+ err = nc_copy_att(ncid_in, BAD_VARID, name, ncid_out, varid);
IF (err != NC_ENOTVAR)
error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(copy_att)(ncid_in, varid, name, ncid_out, BAD_VARID);
+ err = nc_copy_att(ncid_in, varid, name, ncid_out, BAD_VARID);
IF (err != NC_ENOTVAR)
error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(copy_att)(BAD_ID, varid, name, ncid_out, varid);
+ err = nc_copy_att(BAD_ID, varid, name, ncid_out, varid);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(copy_att)(ncid_in, varid, name, BAD_ID, varid);
+ err = nc_copy_att(ncid_in, varid, name, BAD_ID, varid);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(copy_att)(ncid_in, varid, "noSuch", ncid_out, varid);
+ err = nc_copy_att(ncid_in, varid, "noSuch", ncid_out, varid);
IF (err != NC_ENOTATT)
error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(copy_att)(ncid_in, varid, name, ncid_out, varid);
+ err = nc_copy_att(ncid_in, varid, name, ncid_out, varid);
IF (err != NC_NOERR)
- error("copy_att: %s", APIFunc(strerror)(err));
+ error("copy_att: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(copy_att)(ncid_out, varid, name, ncid_out, varid);
+ err = nc_copy_att(ncid_out, varid, name, ncid_out, varid);
IF (err != NC_NOERR)
- error("source = target: %s", APIFunc(strerror)(err));
+ error("source = target: %s", nc_strerror(err));
ELSE_NOK
}
}
- err = APIFunc(close)(ncid_in);
+ err = nc_close(ncid_in);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
/* Close scratch. Reopen & check attributes */
- err = APIFunc(close)(ncid_out);
+ err = nc_close(ncid_out);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileOpen(scratch, NC_WRITE, &ncid_out);
+ error("close: %s", nc_strerror(err));
+ err = file_open(scratch, NC_WRITE, &ncid_out);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- Check_Atts(ncid_out, numGatts, numVars);
+ error("open: %s", nc_strerror(err));
+ check_atts(ncid_out);
/*
* change to define mode
* define single char. global att. ':a' with value 'A'
* This will be used as source for following copies
*/
- err = APIFunc(redef)(ncid_out);
+ err = nc_redef(ncid_out);
IF (err != NC_NOERR)
- error("redef: %s", APIFunc(strerror)(err));
- err = APIFunc(put_att_text)(ncid_out, NC_GLOBAL, "a", 1, "A");
+ error("redef: %s", nc_strerror(err));
+ err = nc_put_att_text(ncid_out, NC_GLOBAL, "a", 1, "A");
IF (err != NC_NOERR)
- error("put_att_text: %s", APIFunc(strerror)(err));
+ error("put_att_text: %s", nc_strerror(err));
/*
* change to data mode
@@ -1831,49 +1701,49 @@ TestFunc(copy_att)(AttVarArgs)
* rename 1st existing att of each var (if any) 'a'
* if this att. exists them copy ':a' to it
*/
- err = APIFunc(enddef)(ncid_out);
+ err = nc_enddef(ncid_out);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
for (i = 0; i < numVars; i++) {
if (NATTS(i) > 0 && ATT_LEN(i,j) > 0) {
- err = APIFunc(rename_att)(ncid_out, i, att_name[i][0], "a");
+ err = nc_rename_att(ncid_out, i, att_name[i][0], "a");
IF (err != NC_NOERR)
- error("rename_att: %s", APIFunc(strerror)(err));
- err = APIFunc(copy_att)(ncid_out, NC_GLOBAL, "a", ncid_out, i);
+ error("rename_att: %s", nc_strerror(err));
+ err = nc_copy_att(ncid_out, NC_GLOBAL, "a", ncid_out, i);
IF (err != NC_NOERR)
- error("copy_att: %s", APIFunc(strerror)(err));
+ error("copy_att: %s", nc_strerror(err));
ELSE_NOK
}
}
- err = APIFunc(close)(ncid_out);
+ err = nc_close(ncid_out);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
/* Reopen & check */
- err = FileOpen(scratch, NC_WRITE, &ncid_out);
+ err = file_open(scratch, NC_WRITE, &ncid_out);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
+ error("open: %s", nc_strerror(err));
for (i = 0; i < numVars; i++) {
if (NATTS(i) > 0 && ATT_LEN(i,j) > 0) {
- err = APIFunc(inq_att)(ncid_out, i, "a", &datatype, &length);
+ err = nc_inq_att(ncid_out, i, "a", &datatype, &length);
IF (err != NC_NOERR)
- error("inq_att: %s", APIFunc(strerror)(err));
+ error("inq_att: %s", nc_strerror(err));
IF (datatype != NC_CHAR)
error("Unexpected type");
IF (length != 1)
error("Unexpected length");
- err = APIFunc(get_att_text)(ncid_out, i, "a", &value);
+ err = nc_get_att_text(ncid_out, i, "a", &value);
IF (err != NC_NOERR)
- error("get_att_text: %s", APIFunc(strerror)(err));
+ error("get_att_text: %s", nc_strerror(err));
IF (value != 'A')
error("Unexpected value");
}
}
- err = APIFunc(close)(ncid_out);
+ err = nc_close(ncid_out);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -1881,23 +1751,23 @@ TestFunc(copy_att)(AttVarArgs)
/*
- * Test APIFunc(rename_att)
+ * Test nc_rename_att
* try with bad netCDF handle, check error
* try with bad variable handle, check error
* try with nonexisting att name, check error
* try renaming to existing att name, check error
- * check that proper rename worked with APIFunc(inq_attid)
+ * check that proper rename worked with nc_inq_attid
* try in data mode, check error
*/
int
-TestFunc(rename_att)(AttVarArgs)
+test_nc_rename_att(void)
{
int ncid;
int varid;
int err;
int i;
int j;
- IntType k, ndx[1];
+ size_t k, ndx[1];
int attnum;
char *attname;
char name[NC_MAX_NAME];
@@ -1906,58 +1776,58 @@ TestFunc(rename_att)(AttVarArgs)
int nok = 0; /* count of valid comparisons */
nc_type datatype;
nc_type atttype;
- IntType length;
- IntType attlength;
+ size_t length;
+ size_t attlength;
char text[MAX_NELS];
double value[MAX_NELS];
double expect;
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(rename_att)(ncid, BAD_VARID, "abc", "newName");
+ err = nc_rename_att(ncid, BAD_VARID, "abc", "newName");
IF (err != NC_ENOTVAR)
error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
ELSE_NOK
def_dims(ncid);
- Def_Vars(ncid, numVars);
- Put_Atts(ncid, numGatts, numVars);
+ def_vars(ncid);
+ put_atts(ncid);
for (i = -1; i < numVars; i++) {
varid = VARID(i);
for (j = 0; j < NATTS(i); j++) {
attname = ATT_NAME(i,j);
- err = APIFunc(rename_att)(BAD_ID, varid, attname, "newName");
+ err = nc_rename_att(BAD_ID, varid, attname, "newName");
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(rename_att)(ncid, varid, "noSuch", "newName");
+ err = nc_rename_att(ncid, varid, "noSuch", "newName");
IF (err != NC_ENOTATT)
error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
ELSE_NOK
strcpy(newname, "new_");
strcat(newname, attname);
- err = APIFunc(rename_att)(ncid, varid, attname, newname);
+ err = nc_rename_att(ncid, varid, attname, newname);
IF (err != NC_NOERR)
- error("rename_att: %s", APIFunc(strerror)(err));
+ error("rename_att: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_attid)(ncid, varid, newname, &attnum);
+ err = nc_inq_attid(ncid, varid, newname, &attnum);
IF (err != NC_NOERR)
- error("inq_attid: %s", APIFunc(strerror)(err));
+ error("inq_attid: %s", nc_strerror(err));
IF (attnum != j)
error("Unexpected attnum");
}
}
/* Close. Reopen & check */
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileOpen(scratch, NC_WRITE, &ncid);
+ error("close: %s", nc_strerror(err));
+ err = file_open(scratch, NC_WRITE, &ncid);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
+ error("open: %s", nc_strerror(err));
for (i = -1; i < numVars; i++) {
varid = VARID(i);
@@ -1967,22 +1837,22 @@ TestFunc(rename_att)(AttVarArgs)
attlength = ATT_LEN(i,j);
strcpy(newname, "new_");
strcat(newname, attname);
- err = APIFunc(inq_attname)(ncid, varid, j, name);
+ err = nc_inq_attname(ncid, varid, j, name);
IF (err != NC_NOERR)
- error("inq_attname: %s", APIFunc(strerror)(err));
+ error("inq_attname: %s", nc_strerror(err));
IF (strcmp(name, newname) != 0)
error("inq_attname: unexpected name");
- err = APIFunc(inq_att)(ncid, varid, name, &datatype, &length);
+ err = nc_inq_att(ncid, varid, name, &datatype, &length);
IF (err != NC_NOERR)
- error("inq_att: %s", APIFunc(strerror)(err));
+ error("inq_att: %s", nc_strerror(err));
IF (datatype != atttype)
error("inq_att: unexpected type");
IF (length != attlength)
error("inq_att: unexpected length");
if (datatype == NC_CHAR) {
- err = APIFunc(get_att_text)(ncid, varid, name, text);
+ err = nc_get_att_text(ncid, varid, name, text);
IF (err != NC_NOERR)
- error("get_att_text: %s", APIFunc(strerror)(err));
+ error("get_att_text: %s", nc_strerror(err));
for (k = 0; k < attlength; k++) {
ndx[0] = k;
expect = hash(datatype, -1, ndx);
@@ -1990,9 +1860,9 @@ TestFunc(rename_att)(AttVarArgs)
error("get_att_text: unexpected value");
}
} else {
- err = APIFunc(get_att_double)(ncid, varid, name, value);
+ err = nc_get_att_double(ncid, varid, name, value);
IF (err != NC_NOERR)
- error("get_att_double: %s", APIFunc(strerror)(err));
+ error("get_att_double: %s", nc_strerror(err));
for (k = 0; k < attlength; k++) {
ndx[0] = k;
expect = hash(datatype, -1, ndx);
@@ -2016,27 +1886,27 @@ TestFunc(rename_att)(AttVarArgs)
strcat(oldname, attname);
strcpy(newname, "even_longer_");
strcat(newname, attname);
- err = APIFunc(rename_att)(ncid, varid, oldname, newname);
+ err = nc_rename_att(ncid, varid, oldname, newname);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(rename_att)(ncid, varid, oldname, attname);
+ err = nc_rename_att(ncid, varid, oldname, attname);
IF (err != NC_NOERR)
- error("rename_att: %s", APIFunc(strerror)(err));
+ error("rename_att: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_attid)(ncid, varid, attname, &attnum);
+ err = nc_inq_attid(ncid, varid, attname, &attnum);
IF (err != NC_NOERR)
- error("inq_attid: %s", APIFunc(strerror)(err));
+ error("inq_attid: %s", nc_strerror(err));
IF (attnum != j)
error("Unexpected attnum");
}
}
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -2044,15 +1914,15 @@ TestFunc(rename_att)(AttVarArgs)
/*
- * Test APIFunc(del_att)
+ * Test nc_del_att
* try with bad netCDF handle, check error
* try with bad variable handle, check error
* try with nonexisting att name, check error
* check that proper delete worked using:
- * APIFunc(inq_attid), APIFunc(inq_natts), APIFunc(inq_varnatts)
+ * nc_inq_attid, nc_inq_natts, nc_inq_varnatts
*/
int
-TestFunc(del_att)(AttVarArgs)
+test_nc_del_att(void)
{
int ncid;
int err, nok=0;
@@ -2064,100 +1934,100 @@ TestFunc(del_att)(AttVarArgs)
int varid;
char *name; /* of att */
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
- err = APIFunc(del_att)(ncid, BAD_VARID, "abc");
+ err = nc_del_att(ncid, BAD_VARID, "abc");
IF (err != NC_ENOTVAR)
error("expecting NC_ENOTVAR but got %s", nc_err_code_name(err));
ELSE_NOK
def_dims(ncid);
- Def_Vars(ncid, numVars);
- Put_Atts(ncid, numGatts, numVars);
+ def_vars(ncid);
+ put_atts(ncid);
for (i = -1; i < numVars; i++) {
varid = VARID(i);
numatts = NATTS(i);
for (j = 0; j < numatts; j++) {
name = ATT_NAME(i,j);
- err = APIFunc(del_att)(BAD_ID, varid, name);
+ err = nc_del_att(BAD_ID, varid, name);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(del_att)(ncid, varid, "noSuch");
+ err = nc_del_att(ncid, varid, "noSuch");
IF (err != NC_ENOTATT)
error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
ELSE_NOK
- err = APIFunc(del_att)(ncid, varid, name);
+ err = nc_del_att(ncid, varid, name);
IF (err != NC_NOERR)
- error("del_att: %s", APIFunc(strerror)(err));
+ error("del_att: %s", nc_strerror(err));
ELSE_NOK
- err = APIFunc(inq_attid)(ncid, varid, name, &attnum);
+ err = nc_inq_attid(ncid, varid, name, &attnum);
IF (err != NC_ENOTATT)
error("expecting NC_ENOTATT but got %s", nc_err_code_name(err));
if (i < 0) {
- err = APIFunc(inq_natts)(ncid, &natts);
+ err = nc_inq_natts(ncid, &natts);
IF (err != NC_NOERR)
- error("inq_natts: %s", APIFunc(strerror)(err));
+ error("inq_natts: %s", nc_strerror(err));
IF (natts != numatts-j-1)
error("natts: expected %d, got %d", numatts-j-1, natts);
}
- err = APIFunc(inq_varnatts)(ncid, varid, &natts);
+ err = nc_inq_varnatts(ncid, varid, &natts);
IF (err != NC_NOERR)
- error("inq_natts: %s", APIFunc(strerror)(err));
+ error("inq_natts: %s", nc_strerror(err));
IF (natts != numatts-j-1)
error("natts: expected %d, got %d", numatts-j-1, natts);
}
}
/* Close. Reopen & check no attributes left */
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileOpen(scratch, NC_WRITE, &ncid);
+ error("close: %s", nc_strerror(err));
+ err = file_open(scratch, NC_WRITE, &ncid);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(inq_natts)(ncid, &natts);
+ error("open: %s", nc_strerror(err));
+ err = nc_inq_natts(ncid, &natts);
IF (err != NC_NOERR)
- error("inq_natts: %s", APIFunc(strerror)(err));
+ error("inq_natts: %s", nc_strerror(err));
IF (natts != 0)
error("natts: expected %d, got %d", 0, natts);
for (i = -1; i < numVars; i++) {
varid = VARID(i);
- err = APIFunc(inq_varnatts)(ncid, varid, &natts);
+ err = nc_inq_varnatts(ncid, varid, &natts);
IF (err != NC_NOERR)
- error("inq_natts: %s", APIFunc(strerror)(err));
+ error("inq_natts: %s", nc_strerror(err));
IF (natts != 0)
error("natts: expected %d, got %d", 0, natts);
}
/* restore attributes. change to data mode. try to delete */
- err = APIFunc(redef)(ncid);
+ err = nc_redef(ncid);
IF (err != NC_NOERR)
- error("redef: %s", APIFunc(strerror)(err));
- Put_Atts(ncid, numGatts, numVars);
- err = APIFunc(enddef)(ncid);
+ error("redef: %s", nc_strerror(err));
+ put_atts(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
for (i = -1; i < numVars; i++) {
varid = VARID(i);
numatts = NATTS(i);
for (j = 0; j < numatts; j++) {
name = ATT_NAME(i,j);
- err = APIFunc(del_att)(ncid, varid, name);
+ err = nc_del_att(ncid, varid, name);
IF (err != NC_ENOTINDEFINE)
error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));
ELSE_NOK
}
}
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
return nok;
@@ -2165,7 +2035,7 @@ TestFunc(del_att)(AttVarArgs)
/*
- * Test APIFunc(set_fill)
+ * Test nc_set_fill
* try with bad netCDF handle, check error
* try in read-only mode, check error
* try with bad new_fillmode, check error
@@ -2175,95 +2045,88 @@ TestFunc(del_att)(AttVarArgs)
* close file & create again for test using attribute _FillValue
*/
int
-TestFunc(set_fill)(VarArgs)
+test_nc_set_fill(void)
{
int ncid;
int varid;
int err;
int i;
- IntType j;
+ size_t j;
int old_fillmode;
int nok = 0; /* count of valid comparisons */
char text = 0;
double value = 0;
double fill;
- IntType index[MAX_RANK];
+ size_t index[MAX_RANK];
/* bad ncid */
- err = APIFunc(set_fill)(BAD_ID, NC_NOFILL, &old_fillmode);
+ err = nc_set_fill(BAD_ID, NC_NOFILL, &old_fillmode);
IF (err != NC_EBADID)
error("expecting NC_EBADID but got %s", nc_err_code_name(err));
/* try in read-only mode */
- err = FileOpen(testfile, NC_NOWRITE, &ncid);
+ err = file_open(testfile, NC_NOWRITE, &ncid);
IF (err != NC_NOERR)
- error("open: %s", APIFunc(strerror)(err));
- err = APIFunc(set_fill)(ncid, NC_NOFILL, &old_fillmode);
+ error("open: %s", nc_strerror(err));
+ err = nc_set_fill(ncid, NC_NOFILL, &old_fillmode);
IF (err != NC_EPERM)
error("expecting NC_EPERM but got %s", nc_err_code_name(err));
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
+ error("close: %s", nc_strerror(err));
/* create scratch */
- err = FileCreate(scratch, NC_NOCLOBBER, &ncid);
+ err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
/* BAD_FILLMODE */
- err = APIFunc(set_fill)(ncid, BAD_FILLMODE, &old_fillmode);
+ err = nc_set_fill(ncid, BAD_FILLMODE, &old_fillmode);
IF (err != NC_EINVAL)
error("expecting NC_EINVAL but got %s", nc_err_code_name(err));
/* proper calls */
- err = APIFunc(set_fill)(ncid, NC_NOFILL, &old_fillmode);
+ err = nc_set_fill(ncid, NC_NOFILL, &old_fillmode);
IF (err != NC_NOERR)
- error("set_fill: %s", APIFunc(strerror)(err));
+ error("set_fill: %s", nc_strerror(err));
IF (old_fillmode != NC_NOFILL)
error("Unexpected old fill mode: %d", old_fillmode);
- err = APIFunc(set_fill)(ncid, NC_FILL, &old_fillmode);
+ err = nc_set_fill(ncid, NC_FILL, &old_fillmode);
IF (err != NC_NOERR)
- error("set_fill: %s", APIFunc(strerror)(err));
+ error("set_fill: %s", nc_strerror(err));
IF (old_fillmode != NC_NOFILL)
error("Unexpected old fill mode: %d", old_fillmode);
/* define dims & vars */
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
/* Change to data mode. Set fillmode again */
- err = APIFunc(enddef)(ncid);
- IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
- err = APIFunc(set_fill)(ncid, NC_FILL, &old_fillmode);
-ifdef(`PNETCDF',
- `IF (err != NC_ENOTINDEFINE)
- error("expecting NC_ENOTINDEFINE but got %s", nc_err_code_name(err));',
- `IF (err)
+ err = nc_enddef(ncid);
+ IF (err != NC_NOERR)
+ error("enddef: %s", nc_strerror(err));
+ err = nc_set_fill(ncid, NC_FILL, &old_fillmode);
+IF (err)
error("nc_set_fill: %s", nc_strerror(err));
IF (old_fillmode != NC_FILL)
- error("Unexpected old fill mode: %d", old_fillmode);')dnl
-
+ error("Unexpected old fill mode: %d", old_fillmode);
/* Write record number NRECS to force writing of preceding records */
/* Assumes variable cr is char vector with UNLIMITED dimension */
- err = APIFunc(inq_varid)(ncid, "cr", &varid);
+ err = nc_inq_varid(ncid, "cr", &varid);
IF (err != NC_NOERR)
- error("inq_varid: %s", APIFunc(strerror)(err));
+ error("inq_varid: %s", nc_strerror(err));
index[0] = NRECS;
-ifdef(`PNETCDF', `
- for (i=0; i<=index[0]; i++)
- err = APIFunc(fill_var_rec)(ncid, varid, i);')dnl
- err = PutVar1TYPE(text)(ncid, varid, index, &text);
+ err = nc_put_var1_text(ncid, varid, index, &text);
IF (err != NC_NOERR)
- error("put_var1_text_all: %s", APIFunc(strerror)(err));
+ error("put_var1_text_all: %s", nc_strerror(err));
/* get all variables & check all values equal default fill */
for (i = 0; i < numVars; i++) {
- ifdef(`PNETCDF', `if (var_dimid[i][0] == RECDIM) continue; /* skip record variables */')
+
switch (var_type[i]) {
case NC_CHAR: fill = (double)NC_FILL_CHAR; break;
case NC_BYTE: fill = (double)NC_FILL_BYTE; break;
@@ -2282,14 +2145,14 @@ ifdef(`PNETCDF', `
err = toMixedBase(j, var_rank[i], var_shape[i], index);
IF (err != 0) error("error in toMixedBase");
if (var_type[i] == NC_CHAR) {
- err = GetVar1TYPE(text)(ncid, i, index, &text);
+ err = nc_get_var1_text(ncid, i, index, &text);
IF (err != NC_NOERR)
- error("get_var1_text_all failed: %s", APIFunc(strerror)(err));
+ error("get_var1_text_all failed: %s", nc_strerror(err));
value = text;
} else {
- err = GetVar1TYPE(double)(ncid, i, index, &value);
+ err = nc_get_var1_double(ncid, i, index, &value);
IF (err != NC_NOERR)
- error("get_var1_double_all failed: %s", APIFunc(strerror)(err));
+ error("get_var1_double_all failed: %s", nc_strerror(err));
}
IF (value != fill && fabs((fill - value)/fill) > DBL_EPSILON)
error("\n\t\t%s Value expected: %-23.17e,\n\t\t read: %-23.17e\n",
@@ -2299,45 +2162,42 @@ ifdef(`PNETCDF', `
}
/* close scratch & create again for test using attribute _FillValue */
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileCreate(scratch, NC_CLOBBER, &ncid);
+ error("close: %s", nc_strerror(err));
+ err = file_create(scratch, NC_CLOBBER, &ncid);
IF (err != NC_NOERR) {
- error("create: %s", APIFunc(strerror)(err));
+ error("create: %s", nc_strerror(err));
return nok;
}
def_dims(ncid);
- Def_Vars(ncid, numVars);
+ def_vars(ncid);
/* set _FillValue = 42 for all vars */
fill = 42;
text = 42;
for (i = 0; i < numVars; i++) {
if (var_type[i] == NC_CHAR) {
- err = APIFunc(put_att_text)(ncid, i, "_FillValue", 1, &text);
+ err = nc_put_att_text(ncid, i, "_FillValue", 1, &text);
IF (err != NC_NOERR)
- error("put_att_text: %s", APIFunc(strerror)(err));
+ error("put_att_text: %s", nc_strerror(err));
} else {
- err = APIFunc(put_att_double)(ncid, i, "_FillValue",var_type[i],1,&fill);
+ err = nc_put_att_double(ncid, i, "_FillValue",var_type[i],1,&fill);
IF (err != NC_NOERR)
- error("put_att_double: %s", APIFunc(strerror)(err));
+ error("put_att_double: %s", nc_strerror(err));
}
}
/* data mode. write records */
- err = APIFunc(enddef)(ncid);
+ err = nc_enddef(ncid);
IF (err != NC_NOERR)
- error("enddef: %s", APIFunc(strerror)(err));
+ error("enddef: %s", nc_strerror(err));
index[0] = NRECS;
-ifdef(`PNETCDF', `
- for (i=0; i<=index[0]; i++)
- err = APIFunc(fill_var_rec)(ncid, varid, i);')dnl
- err = PutVar1TYPE(text)(ncid, varid, index, &text);
+ err = nc_put_var1_text(ncid, varid, index, &text);
IF (err != NC_NOERR)
- error("put_var1_text_all: %s", APIFunc(strerror)(err));
+ error("put_var1_text_all: %s", nc_strerror(err));
/* get all variables & check all values equal 42 */
for (i = 0; i < numVars; i++) {
@@ -2346,24 +2206,24 @@ ifdef(`PNETCDF', `
err = toMixedBase(j, var_rank[i], var_shape[i], index);
IF (err != 0) error("error in toMixedBase");
if (var_type[i] == NC_CHAR) {
- err = GetVar1TYPE(text)(ncid, i, index, &text);
+ err = nc_get_var1_text(ncid, i, index, &text);
IF (err != NC_NOERR)
- error("get_var1_text_all failed: %s", APIFunc(strerror)(err));
+ error("get_var1_text_all failed: %s", nc_strerror(err));
value = text;
} else {
- err = GetVar1TYPE(double)(ncid, i, index, &value);
+ err = nc_get_var1_double(ncid, i, index, &value);
IF (err != NC_NOERR)
- error("get_var1_double_all failed: %s", APIFunc(strerror)(err));
+ error("get_var1_double_all failed: %s", nc_strerror(err));
}
IF (value != fill)
error(" %s Value expected: %g, read: %g\n", var_name[i],fill, value);
ELSE_NOK
}
}
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
@@ -2378,7 +2238,7 @@ ifdef(`PNETCDF', `
#define MAGIC_NUM_LEN 4
static
int
-APIFunc(get_file_version)(char *path, int *version)
+nc_get_file_version(char *path, int *version)
{
int fd;
ssize_t read_len;
@@ -2405,8 +2265,11 @@ APIFunc(get_file_version)(char *path, int *version)
if (strncmp(magic, "CDF", MAGIC_NUM_LEN-1)==0) {
if (magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CLASSIC ||
- magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET ||
- magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5)
+ magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET
+#ifdef USE_CDF5
+ || magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5
+#endif
+)
*version = magic[MAGIC_NUM_LEN-1];
else
return NC_ENOTNC;
@@ -2419,7 +2282,7 @@ APIFunc(get_file_version)(char *path, int *version)
}
/*
- * Test APIFunc(set_default_format)
+ * Test nc_set_default_format
* try with bad default format
* try with NULL old_formatp
* try in data mode, check error
@@ -2428,7 +2291,7 @@ APIFunc(get_file_version)(char *path, int *version)
* close file & create again for test using attribute _FillValue
*/
int
-TestFunc(set_default_format)(void)
+test_nc_set_default_format(void)
{
int ncid, nok=0;
int err;
@@ -2437,35 +2300,35 @@ TestFunc(set_default_format)(void)
int old_format;
/* bad format */
- err = APIFunc(set_default_format)(BAD_DEFAULT_FORMAT, &old_format);
+ err = nc_set_default_format(BAD_DEFAULT_FORMAT, &old_format);
IF (err != NC_EINVAL)
error("expecting NC_EINVAL but got %s", nc_err_code_name(err));
ELSE_NOK
/* NULL old_formatp */
- err = APIFunc(set_default_format)(NC_FORMAT_64BIT_OFFSET, NULL);
+ err = nc_set_default_format(NC_FORMAT_64BIT_OFFSET, NULL);
IF (err != NC_NOERR)
error("null old_fortmatp: status = %d", err);
ELSE_NOK
/* Cycle through available formats. */
- for(i=NC_FORMAT_CLASSIC; i<NC_FORMAT_64BIT_DATA; i++)
- {
+
+ for(i=NC_FORMAT_CLASSIC; i<NC_FORMAT_64BIT_DATA; i++) {
if (i == NC_FORMAT_NETCDF4 || i == NC_FORMAT_NETCDF4_CLASSIC)
continue; /* test classic formats only */
- if ((err = APIFunc(set_default_format)(i, NULL)))
+ if ((err = nc_set_default_format(i, NULL)))
error("setting classic format: status = %d", err);
ELSE_NOK
- err = FileCreate(scratch, NC_CLOBBER, &ncid);
+ err = file_create(scratch, NC_CLOBBER, &ncid);
if (err != NC_NOERR)
error("bad nc_create: status = %d", err);
- err = APIFunc(put_att_text)(ncid, NC_GLOBAL, "testatt", sizeof("blah"), "blah");
+ err = nc_put_att_text(ncid, NC_GLOBAL, "testatt", sizeof("blah"), "blah");
if (err != NC_NOERR)
error("bad put_att: status = %d", err);
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
if (err != NC_NOERR)
error("bad close: status = %d", err);
- err = APIFunc(get_file_version)(scratch, &version);
+ err = nc_get_file_version(scratch, &version);
if (err != NC_NOERR)
error("bad file version = %d", err);
if (version != i) {
@@ -2482,7 +2345,7 @@ TestFunc(set_default_format)(void)
}
/* Remove the left-over file. */
- err = FileDelete(scratch, info);
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
@@ -2493,23 +2356,23 @@ TestFunc(set_default_format)(void)
/*
- * Test FileDelete
+ * Test nc_delete()
* create netcdf file 'scratch.nc' with no data, close it
* delete the file
*/
int
-TestFunc(delete)(void)
+test_nc_delete(void)
{
int err, nok=0;;
int ncid;
- err = FileCreate(scratch, NC_CLOBBER, &ncid);
+ err = file_create(scratch, NC_CLOBBER, &ncid);
IF (err != NC_NOERR)
error("error creating scratch file %s, status = %d\n", scratch,err);
- err = APIFunc(close)(ncid);
+ err = nc_close(ncid);
IF (err != NC_NOERR)
- error("close: %s", APIFunc(strerror)(err));
- err = FileDelete(scratch, info);
+ error("close: %s", nc_strerror(err));
+ err = nc_delete(scratch);
IF (err != NC_NOERR)
error("remove of %s failed", scratch);
ELSE_NOK
diff --git a/nc_test/test_write.m4 b/nc_test/test_write.m4
index f43294f..034d558 100644
--- a/nc_test/test_write.m4
+++ b/nc_test/test_write.m4
@@ -33,6 +33,7 @@ dnl
#endif
#include "tests.h"
+#include "config.h"
#include "math.h"
define(`EXPECT_ERR',`error("expecting $1 but got %s",nc_err_code_name($2));')dnl
@@ -2405,8 +2406,11 @@ APIFunc(get_file_version)(char *path, int *version)
if (strncmp(magic, "CDF", MAGIC_NUM_LEN-1)==0) {
if (magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CLASSIC ||
- magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET ||
- magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5)
+ magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET
+#ifdef USE_CDF5
+ || magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5
+#endif
+)
*version = magic[MAGIC_NUM_LEN-1];
else
return NC_ENOTNC;
@@ -2449,8 +2453,8 @@ TestFunc(set_default_format)(void)
ELSE_NOK
/* Cycle through available formats. */
- for(i=NC_FORMAT_CLASSIC; i<NC_FORMAT_64BIT_DATA; i++)
- {
+
+ for(i=NC_FORMAT_CLASSIC; i<NC_FORMAT_64BIT_DATA; i++) {
if (i == NC_FORMAT_NETCDF4 || i == NC_FORMAT_NETCDF4_CLASSIC)
continue; /* test classic formats only */
if ((err = APIFunc(set_default_format)(i, NULL)))
diff --git a/nc_test/tst_formatx_pnetcdf.c b/nc_test/tst_formatx_pnetcdf.c
index b11699f..99fa5c5 100644
--- a/nc_test/tst_formatx_pnetcdf.c
+++ b/nc_test/tst_formatx_pnetcdf.c
@@ -66,6 +66,7 @@ int main(int argc, char* argv[])
ecode = 1;
ERR;
}
+ if (nc_close(ncid)) ERR;
/* test CDF-2 file format */
cmode = NC_PNETCDF | NC_CLOBBER | NC_64BIT_OFFSET;
@@ -84,6 +85,7 @@ int main(int argc, char* argv[])
ecode = 1;
ERR;
}
+ if (nc_close(ncid)) ERR;
/* test CDF-5 file format */
cmode = NC_PNETCDF | NC_CLOBBER | NC_64BIT_DATA;
@@ -102,8 +104,7 @@ int main(int argc, char* argv[])
ecode = 1;
ERR;
}
-
- if (nc_abort(ncid)) ERR;
+ if (nc_close(ncid)) ERR;
fn_exit:
MPI_Finalize();
diff --git a/nc_test/tst_large_cdf5.c b/nc_test/tst_large_cdf5.c
new file mode 100644
index 0000000..ef8681f
--- /dev/null
+++ b/nc_test/tst_large_cdf5.c
@@ -0,0 +1,201 @@
+/*
+ Copyright 2017, UCAR/Unidata
+ See COPYRIGHT file for copying and redistribution conditions.
+
+ This program tests the large file bug in netCDF 3.6.2,
+ creating byte and short variables larger than 4 GiB.
+
+ This program is based on tst_large.c, and tests against
+ CDF5.
+
+ $Id: tst_large.c,v 1.16 2010/05/18 20:20:01 russ Exp $
+*/
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <nc_tests.h>
+#include "err_macros.h"
+#include <netcdf.h>
+
+/* Test with both classic and 64-bit offset files. If netcdf-4 is
+ * included, test with both netCDF-4 format variants also. */
+#ifdef USE_NETCDF4
+#define NUM_FORMATS (4)
+#else
+#define NUM_FORMATS (2)
+#endif
+
+#define NUMDIMS 2 /* rank of each variable in tests */
+#define DIM1 2048
+#define DIM2 2097153 /* DIM1*DIM2*sizeof(char) > 2**32 */
+#define DIM3 1024
+#define DIM4 2097153 /* DIM3*DIM4*sizeof(short) > 2**32 */
+
+/*
+ * In netCDF-3.6.2, a divide by zero occurs on 32-bit platforms when
+ * creating a variable for which the product of dimensions is exactly
+ * 2**32. Check that this bug has been fixed.
+ */
+static int
+test_big_var(const char *testfile) {
+ int ncid, varid, dimids[NUMDIMS];
+ int cflag = NC_CLOBBER;
+ nc_type type = NC_BYTE;
+ size_t index[NUMDIMS];
+ signed char nval = 99;
+ int nval_in;
+
+ /* Define the file with one large variable. */
+ if (nc_create(testfile, cflag, &ncid)) ERR;
+ if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
+ if (nc_def_dim(ncid, "dim1", DIM1, &dimids[0])) ERR;
+ if (nc_def_dim(ncid, "dim2", DIM2 - 1, &dimids[1])) ERR;
+ if (nc_def_var(ncid, "var", type, NUMDIMS, dimids, &varid)) ERR;
+ if (nc_enddef(ncid)) ERR;
+
+ /* Write one datum, near the end of the variable. */
+ index[0] = DIM1 - 1;
+ index[1] = DIM2 - 2;
+ if (nc_put_var1_schar(ncid, varid, index, &nval)) ERR;
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file and check that datum. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq_varid(ncid, "var", &varid)) ERR;
+ if (nc_get_var1_int(ncid, varid, index, &nval_in)) ERR;
+ if (nval != nval_in)
+ ERR;
+ if (nc_close(ncid)) ERR;
+ return 0;
+}
+
+static int
+test_large_byte_var(const char *testfile) {
+ int ncid, varid, dimids[NUMDIMS];
+ size_t index[NUMDIMS] = {0, 0};
+ signed char vals[DIM2];
+ signed char char_val_in;
+ size_t start[NUMDIMS], count[NUMDIMS];
+ int j;
+
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+ if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
+ if (nc_def_dim(ncid, "dim1", DIM1, &dimids[0])) ERR;
+ if (nc_def_dim(ncid, "dim2", DIM2, &dimids[1])) ERR;
+ if (nc_def_var(ncid, "var", NC_BYTE, NUMDIMS, dimids, &varid)) ERR;
+ if (nc_enddef(ncid)) ERR;
+
+ for (j = 0; j < DIM2; j++) {
+ vals[j] = 9 * (j + 11); /* note vals[j] is 99 when j==0 */
+ }
+ start[1] = 0;
+ count[0] = 1;
+ count[1] = DIM2;
+ for (start[0] = 0; start[0] < DIM1; start[0]++) {
+ if (nc_put_vara_schar(ncid, varid, start, count, vals))
+ {
+ ERR;
+ break;
+ }
+ }
+
+ if (nc_close(ncid)) ERR;
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq_varid(ncid, "var", &varid)) ERR;
+ if (nc_get_var1_schar(ncid, varid, index, &char_val_in)) ERR;
+ if (char_val_in != 99) /* see above, the value written when start[0]==0, j==0 */
+ ERR;
+ if (nc_close(ncid)) ERR;
+ return 0;
+}
+
+static int
+test_large_short_var(const char *testfile) {
+ int ncid, varid, dimids[NUMDIMS];
+ int int_val_in, int_val_out = 99;
+ size_t index[2];
+ int cflag = NC_CLOBBER;
+
+ if (nc_create(testfile, cflag, &ncid)) ERR;
+ if (nc_def_dim(ncid, "dim3", DIM3, &dimids[0])) ERR;
+ if (nc_def_dim(ncid, "dim4", DIM4, &dimids[1])) ERR;
+ if (nc_def_var(ncid, "var", NC_SHORT, NUMDIMS, dimids, &varid)) ERR;
+ if (nc_enddef(ncid)) ERR;
+ index[0] = 0;
+ index[1] = 1;
+ if (nc_put_var1_int(ncid, varid, index, &int_val_out)) ERR;
+ if (nc_close(ncid)) ERR;
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq_varid(ncid, "var", &varid)) ERR;
+ if (nc_get_var1_int(ncid, varid, index, &int_val_in)) ERR;
+ if (int_val_in != int_val_out)
+ ERR;
+#ifndef NOFILL
+ index[0] = 1;
+ index[1] = 2;
+ if (nc_get_var1_int(ncid, varid, index, &int_val_in)) ERR;
+ if (int_val_in != NC_FILL_SHORT)
+ ERR;
+#endif
+ if (nc_close(ncid)) ERR;
+ return 0;
+}
+
+#define FILE_NAME "tst_large_cdf5.nc"
+
+int
+main(int argc, char **argv) {
+ int i;
+ char testfile[NC_MAX_NAME + 1];
+
+ sprintf(testfile, "%s/%s", TEMP_LARGE, FILE_NAME);
+
+ printf("\n*** Testing fix for 3.6.2 large file bug in %s.\n",
+ testfile);
+ /* Go thru formats and run all tests for each of two (for netCDF-3
+ * only builds), or 4 (for netCDF-4 builds) different formats. */
+ for (i = NC_FORMAT_CLASSIC; i <= NUM_FORMATS; i++)
+ {
+ nc_set_default_format(i, NULL);
+
+ printf("*** testing format %d with a variable with 2**32 values...", i);
+ test_big_var(testfile);
+ (void) remove(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** testing format %d with a byte variable with > 2**32 values...", i);
+ test_large_byte_var(testfile);
+ (void) remove(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** testing format %d with a short variable with > 2**32 values...", i);
+ test_large_short_var(testfile);
+ (void) remove(testfile);
+ SUMMARIZE_ERR;
+ }
+
+ /* Test CDF5 */
+ {
+ i = NC_64BIT_DATA;
+ nc_set_default_format(i, NULL);
+
+ printf("*** testing format %d with a variable with 2**32 values...", i);
+ test_big_var(testfile);
+ (void) remove(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** testing format %d with a byte variable with > 2**32 values...", i);
+ test_large_byte_var(testfile);
+ (void) remove(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** testing format %d with a short variable with > 2**32 values...", i);
+ test_large_short_var(testfile);
+ (void) remove(testfile);
+ SUMMARIZE_ERR;
+
+ }
+
+ FINAL_RESULTS;
+}
diff --git a/nc_test/tst_small.c b/nc_test/tst_small.c
index 750baf5..114218f 100644
--- a/nc_test/tst_small.c
+++ b/nc_test/tst_small.c
@@ -54,8 +54,11 @@ static int file_create(const char *filename, int cmode, int *ncid)
#ifdef USE_PNETCDF
if (default_format == NC_FORMAT_CLASSIC ||
- default_format == NC_FORMAT_64BIT_OFFSET ||
- default_format == NC_FORMAT_64BIT_DATA)
+ default_format == NC_FORMAT_64BIT_OFFSET
+#ifdef USE_CDF5
+ || default_format == NC_FORMAT_64BIT_DATA
+#endif
+ )
err = nc_create_par(filename, cmode|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, ncid);
else
#endif
@@ -522,11 +525,16 @@ main(int argc, char **argv)
printf("Switching to 64-bit offset format.\n");
strcpy(testfile, "tst_small_64bit.nc");
break;
+#ifdef USE_CDF5
case NC_FORMAT_CDF5:
nc_set_default_format(NC_FORMAT_CDF5, NULL);
printf("Switching to 64-bit data format.\n");
strcpy(testfile, "tst_small_cdf5.nc");
break;
+#else
+ case NC_FORMAT_CDF5:
+ continue;
+#endif
#ifdef USE_NETCDF4
case NC_FORMAT_NETCDF4_CLASSIC:
nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL);
diff --git a/nc_test4/Makefile.in b/nc_test4/Makefile.in
index 3061379..0631ba9 100644
--- a/nc_test4/Makefile.in
+++ b/nc_test4/Makefile.in
@@ -906,7 +906,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -941,7 +943,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncdap_test/Makefile.am b/ncdap_test/Makefile.am
index 0338733..a8c7adf 100644
--- a/ncdap_test/Makefile.am
+++ b/ncdap_test/Makefile.am
@@ -50,7 +50,6 @@ test_partvar_SOURCES = test_partvar.c
test_varm3_SOURCES = test_varm3.c
test_nstride_cached_SOURCES = test_nstride_cached.c
-#t_auth_SOURCES = t_auth.c
t_misc_SOURCES = t_misc.c
TESTS += test_varm3
@@ -65,9 +64,8 @@ check_PROGRAMS += test_varm3
check_PROGRAMS += t_ncf330
if ENABLE_DAP_AUTH_TESTS
-#check_PROGRAMS += t_auth t_auth1
-#TESTS += t_auth
-TESTS += testauth.sh
+TESTS += testbasicauth.sh
+TESTS += testcontainerauth.sh
endif
endif #ENABLE_DAP_REMOTE_TESTS
diff --git a/ncdap_test/Makefile.in b/ncdap_test/Makefile.in
index cad91ee..8394551 100644
--- a/ncdap_test/Makefile.in
+++ b/ncdap_test/Makefile.in
@@ -130,10 +130,8 @@ TESTS = $(am__EXEEXT_3) $(am__append_6) $(am__EXEEXT_4) \
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE@ test_varm3 \
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE@ test_nstride_cached \
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE@ t_misc
-
-#check_PROGRAMS += t_auth t_auth1
-#TESTS += t_auth
- at ENABLE_DAP_AUTH_TESTS_TRUE@@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE at am__append_10 = testauth.sh
+ at ENABLE_DAP_AUTH_TESTS_TRUE@@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE at am__append_10 = testbasicauth.sh \
+ at ENABLE_DAP_AUTH_TESTS_TRUE@@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE@ testcontainerauth.sh
subdir = ncdap_test
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -565,7 +563,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -600,7 +600,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
@@ -715,8 +716,6 @@ test_vara_SOURCES = test_vara.c t_srcdir.h
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE at test_partvar_SOURCES = test_partvar.c
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE at test_varm3_SOURCES = test_varm3.c
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE at test_nstride_cached_SOURCES = test_nstride_cached.c
-
-#t_auth_SOURCES = t_auth.c
@ENABLE_DAP_REMOTE_TESTS_TRUE@@ENABLE_DAP_TRUE at t_misc_SOURCES = t_misc.c
# Need to add subdirs
@@ -1190,9 +1189,16 @@ t_misc.log: t_misc$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
-testauth.sh.log: testauth.sh
- @p='testauth.sh'; \
- b='testauth.sh'; \
+testbasicauth.sh.log: testbasicauth.sh
+ @p='testbasicauth.sh'; \
+ b='testbasicauth.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+testcontainerauth.sh.log: testcontainerauth.sh
+ @p='testcontainerauth.sh'; \
+ b='testcontainerauth.sh'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
diff --git a/ncdap_test/expected3/Makefile.in b/ncdap_test/expected3/Makefile.in
index 704a75c..7e1050c 100644
--- a/ncdap_test/expected3/Makefile.in
+++ b/ncdap_test/expected3/Makefile.in
@@ -169,7 +169,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -204,7 +206,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncdap_test/expectremote3/Makefile.in b/ncdap_test/expectremote3/Makefile.in
index 9b8b4e3..fc52ae8 100644
--- a/ncdap_test/expectremote3/Makefile.in
+++ b/ncdap_test/expectremote3/Makefile.in
@@ -169,7 +169,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -204,7 +206,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncdap_test/testbasicauth.sh b/ncdap_test/testbasicauth.sh
new file mode 100644
index 0000000..536a227
--- /dev/null
+++ b/ncdap_test/testbasicauth.sh
@@ -0,0 +1,293 @@
+#!/bin/sh
+
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+. ../test_common.sh
+
+RCEMBED=1
+RCLOCAL=1
+RCHOME=1
+RCENV=1
+RCPREC=1
+
+# Not currently testable in netcdf
+#RCSPEC=1
+
+#SHOW=1
+#DBG=1
+
+# Choose at most 1
+#GDB=1
+#VG=1
+
+NFL=1
+
+WD=`pwd`
+
+NETRCFILE=$WD/test_auth_netrc
+# This is the control variable; set when needed
+unset NETRC
+
+COOKIES="${WD}/test_auth_cookies"
+
+RC=.daprc
+
+OCLOGFILE=stderr
+if test "x$DBG" = x1 ; then
+SHOW=1
+fi
+
+# Major parameters
+
+BASICCOMBO="tiggeUser:tigge"
+BADCOMBO="tiggeUser:xxxxx"
+URLSERVER="remotetest.unidata.ucar.edu"
+#http://remotetest.unidata.ucar.edu/thredds/dodsC/restrict/testData.nc.html
+URLPATH="thredds/dodsC/restrict/testData.nc"
+PROTO=http
+
+# See if we need to override
+if test "x$URS" != "x" ; then
+#https://54.86.135.31/opendap/data/nc/fnoc1.nc.dds
+URLSERVER="54.86.135.31"
+URLPATH="opendap/data/nc/fnoc1.nc"
+BASICCOMBO="$URS"
+RCEMBED=0
+NETRC=$NETRCFILE
+PROTO=https
+fi
+
+if test "x$DBG" = x1 ; then
+URLPATH="${URLPATH}#log&show=fetch"
+fi
+
+# Split the combo
+BASICUSER=`echo $BASICCOMBO | cut -d: -f1`
+BASICPWD=`echo $BASICCOMBO | cut -d: -f2`
+
+OUTPUT="./.output"
+
+if test "x$TEMP" = x ; then
+ TEMP="/tmp"
+fi
+TEMP=`echo "$TEMP" | sed -e "s|/$||"`
+
+LOCALRC=./$RC
+HOMERC=${HOME}/$RC
+HOMERC=`echo "$HOMERC" | sed -e "s|//|/|g"`
+SPECRC="$TEMP/temprc"
+ENVRC="$WD/envrc"
+
+createrc() {
+ RCP="$1" ; shift
+ unset NOPWD
+ unset BADPWD
+ while [[ $# > 0 ]] ; do
+ case "$1" in
+ nopwd) NOPWD=1 ;;
+ badpwd) BADPWD=1 ;;
+ *) ;;
+ esac
+ shift
+ done
+ if test "x$RCP" != x ; then
+ rm -f $RCP
+ echo "Creating rc file $RCP"
+ else
+ echo "createrc: no rc specified"
+ exit 1
+ fi
+ if test "x${DBG}" != x ; then
+ echo "HTTP.VERBOSE=1" >>$RCP
+ fi
+ echo "HTTP.COOKIEJAR=${COOKIES}" >>$RCP
+ if test "x${URS}" = x ; then
+ if test "x${NOPWD}" = x ; then
+ if test "x${BADPWD}" = x ; then
+ echo "HTTP.CREDENTIALS.USERPASSWORD=${BASICCOMBO}" >>$RCP
+ else
+ echo "HTTP.CREDENTIALS.USERPASSWORD=${BADCOMBO}" >>$RCP
+ fi
+ fi
+ fi
+ if test "x${NETRC}" != x && test "x$NFL" = x ; then
+ echo "HTTP.NETRC=${NETRC}" >>$RCP
+ fi
+}
+
+createnetrc() {
+ NCP="$1" ; shift
+ unset NOPWD
+ unset BADPWD
+ while [[ $# > 0 ]] ; do
+ case "$1" in
+ nopwd) NOPWD=1 ;;
+ badpwd) BADPWD=1 ;;
+ *) ;;
+ esac
+ shift
+ done
+ if test "x$NCP" != x ; then
+ rm -f $NCP
+ echo "Creating netrc file $NCP"
+ else
+ echo "createnetrc: no rc specified"
+ exit 1
+ fi
+ if test "x$URS" != x ; then
+ echo "machine uat.urs.earthdata.nasa.gov login $BASICUSER password $BASICPWD" >>$NCP
+ #echo "machine 54.86.135.31 login $BASICUSER password $BASICPWD" >>$1
+ else
+ echo -n "${PROTO}://$URLSERVER/$URLPATH" >>$NCP
+ if test "x$NOPWD" = x ; then
+ if test "x$BADPWD" = x ; then
+ echo -n " login $BASICUSER password $BASICPWD" >>$NCP
+ else
+ echo -n " login $BASICUSER password xxxxxx" >>$NCP
+ fi
+ fi
+ echo "" >>$NCP
+ fi
+}
+
+reset() {
+ for f in ./$RC $HOME/$RC $SPECRC $ENVRC $COOKIES $NETRC $OUTPUT ; do
+ rm -f ${f}
+ done
+ unset DAPRCFILE
+}
+
+restore() {
+ reset
+ for f in ./$RC $HOME/$RC $SPECRC $ENVRC $COOKIES $NETRC ; do
+ if test -f ${f}.save ; then
+ echo "restoring old ${f}"
+ cp ${f}.save ${f}
+ fi
+ done
+}
+
+save() {
+ for f in ./$RC $HOME/$RC $SPECRC $ENVRC $COOKIES $NETRC ; do
+ if test -f $f ; then
+ if test -f ${f}.save ; then
+ ignore=1
+ else
+ echo "saving $f"
+ cp ${f} ${f}.save
+ fi
+ fi
+ done
+}
+
+show() {
+ if test "x$SHOW" = x1 ; then cat $OUTPUT; fi
+ if test "x$OUTPUT" != "x"; then rm -f $OUTPUT; fi
+}
+
+# Assemble the ncdump command
+if test "x$DBG" = x1; then
+NCDUMP="$NCDUMP -D1"
+fi
+
+if test "x$GDB" = x1 ; then
+ NCDUMP="gdb --args $NCDUMP"
+fi
+if test "x$VG" = x1 ; then
+NCDUMP="valgrind --leak-check=full $NCDUMP"
+fi
+
+# Initialize
+save
+reset
+
+if test "x$RCEMBED" = x1 ; then
+ echo "***Testing rc file with embedded user:pwd"
+ URL="${PROTO}://${BASICCOMBO}@${URLSERVER}/$URLPATH"
+ unset NETRC
+ # Invoke ncdump to extract a file the URL
+ echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+ ${NCDUMP} -h "$URL" > $OUTPUT
+ show
+fi
+
+# Rest of tests assume these defaults
+URL="${PROTO}://${URLSERVER}/$URLPATH"
+NETRC=$NETRCFILE
+
+if test "x$RCLOCAL" = x1 ; then
+ echo "***Testing rc file in local directory"
+ # Create the rc file and (optional) netrc fil in ./
+ reset
+ createnetrc $NETRC
+ createrc $LOCALRC
+
+ # Invoke ncdump to extract a file using the URL
+ echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+ ${NCDUMP} -h "$URL" > $OUTPUT
+ show
+fi
+
+if test "x$RCHOME" = x1 ; then
+ echo "***Testing rc file in home directory"
+ # Create the rc file and (optional) netrc file in ./
+ reset
+ createnetrc $NETRC
+ createrc $HOMERC
+
+ # Invoke ncdump to extract a file the URL
+ echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+ ${NCDUMP} -h "$URL" > $OUTPUT
+ show
+fi
+
+if test "x$RCSPEC" == x1 ; then
+ echo "*** Testing rc file in specified directory"
+ # Create the rc file and (optional) netrc file
+ reset
+ createnetrc $NETRC
+ createrc $SPECRC
+
+ # Invoke ncdump to extract a file the URL
+ echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+ ${NCDUMP} -h "$URL" > $OUTPUT
+ show
+fi
+
+if test "x$RCENV" = x1 ; then
+ echo "*** Testing rc file using env variable"
+ # Create the rc file and (optional) netrc file
+ reset
+ createnetrc $NETRC
+ echo "ENV: export DAPRCFILE=$ENVRC"
+ export DAPRCFILE=$ENVRC
+ createrc $DAPRCFILE
+
+ # Invoke ncdump to extract a file the URL
+ echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+ ${NCDUMP} -h "$URL" > $OUTPUT
+ show
+ export DAPRCFILE=
+fi
+
+# Test that .daprc overrides netcrc for password
+URL="${PROTO}://${URLSERVER}/$URLPATH"
+NETRC=$NETRCFILE
+if test "x$RCPREC" = x1 ; then
+ echo "***Testing rc vs netrc file precedence"
+ # Create the rc file and (optional) netrc file in ./
+ reset
+ createnetrc $NETRC badpwd
+ createrc $LOCALRC
+
+ # Invoke ncdump to extract a file using the URL
+ echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+ ${NCDUMP} -h "$URL" > $OUTPUT
+ ${NCDUMP} -h "$URL"
+ show
+fi
+
+reset
+restore
+
+exit
+
diff --git a/ncdap_test/testcontainerauth.sh b/ncdap_test/testcontainerauth.sh
new file mode 100644
index 0000000..82f26e6
--- /dev/null
+++ b/ncdap_test/testcontainerauth.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+. ../test_common.sh
+
+#SHOW=1
+#DBG=1
+# Choose at most 1
+#GDB=1
+#VG=1
+
+WD=`pwd`
+COOKIES="${WD}/test_auth_cookies"
+
+RC=.daprc
+
+OCLOGFILE=stderr
+if test "x$DBG" = x1 ; then
+SHOW=1
+fi
+
+# Major parameters
+
+PROTO=https
+URLSERVER="localhost:8081"
+URLPATH="/thredds/dodsC/containerauth/testData2.nc"
+
+if test "x$DBG" = x1 ; then
+PARAMS="#log&show=fetch"
+fi
+
+OUTPUT="./.output"
+if test "x$TEMP" = x ; then
+ TEMP="/tmp"
+fi
+TEMP=`echo "$TEMP" | sed -e "s|/$||"`
+
+show() {
+ if test "x$SHOW" = x1 ; then cat $OUTPUT; fi
+ if test "x$OUTPUT" != "x"; then rm -f $OUTPUT; fi
+}
+
+# Assemble the ncdump command
+if test "x$DBG" = x1; then
+NCDUMP="$NCDUMP -D1"
+fi
+
+if test "x$GDB" = x1 ; then
+ NCDUMP="gdb --args $NCDUMP"
+fi
+if test "x$VG" = x1 ; then
+ NCDUMP="valgrind --leak-check=full $NCDUMP"
+fi
+
+# Rest of tests assume these defaults
+URL="${PROTO}://${URLSERVER}/$URLPATH"
+
+if test "x$DBG" = x1 ; then
+URL="$URL$PARAMS"
+fi
+
+# Invoke ncdump to extract a file the URL
+echo "command: ${NCDUMP} -h ${URL} > $OUTPUT"
+${NCDUMP} -h "$URL" > $OUTPUT
+
+show
+
+exit
+
diff --git a/ncdap_test/testdata3/Makefile.in b/ncdap_test/testdata3/Makefile.in
index b03af8d..272b825 100644
--- a/ncdap_test/testdata3/Makefile.in
+++ b/ncdap_test/testdata3/Makefile.in
@@ -169,7 +169,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -204,7 +206,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncdump/CMakeLists.txt b/ncdump/CMakeLists.txt
index c9213ee..4f0aa12 100644
--- a/ncdump/CMakeLists.txt
+++ b/ncdump/CMakeLists.txt
@@ -131,6 +131,7 @@ ENDIF()
ENDIF(USE_NETCDF4)
add_sh_test(ncdump tst_nccopy3)
+ add_sh_test(ncdump tst_nccopy3_subset)
add_sh_test(ncdump tst_charfill)
add_sh_test(ncdump tst_formatx3)
diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am
index 991b3c6..a6eafb2 100644
--- a/ncdump/Makefile.am
+++ b/ncdump/Makefile.am
@@ -43,7 +43,7 @@ check_PROGRAMS = rewrite-scalar ctest ctest64 ncdump tst_utf8 bom tst_dimsizes n
TESTS = tst_inttags.sh run_tests.sh tst_64bit.sh ctest ctest64 tst_output.sh \
tst_lengths.sh tst_calendars.sh tst_utf8 run_utf8_tests.sh \
-tst_nccopy3.sh tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \
+tst_nccopy3.sh tst_nccopy3_subset.sh tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \
tst_dimsizes.sh run_ncgen_tests.sh
if USE_NETCDF4
@@ -63,13 +63,17 @@ endif
endif
if USE_NETCDF4
+TESTS += tst_inttags4.sh
+endif
+
+if USE_NETCDF4
# NetCDF-4 has some extra tests.
check_PROGRAMS += tst_create_files tst_h_rdc0 tst_group_data \
tst_enum_data tst_opaque_data tst_string_data tst_vlen_data tst_comp \
tst_comp2 tst_nans tst_special_atts tst_unicode tst_fillbug tst_compress \
tst_chunking tst_h_scalar tst_bug324
-TESTS += tst_inttags4.sh tst_create_files tst_group_data tst_enum_data tst_opaque_data \
+TESTS += tst_create_files tst_group_data tst_enum_data tst_opaque_data \
tst_string_data tst_vlen_data tst_comp tst_comp2 tst_nans \
tst_special_atts tst_netcdf4.sh tst_h_rdc0 tst_unicode tst_fillbug \
tst_fillbug.sh tst_netcdf4_4.sh tst_compress tst_nccopy4.sh \
@@ -110,7 +114,10 @@ endif
endif BUILD_TESTSETS
-CLEANFILES = test0.nc test1.cdl test1.nc test2.cdl ctest1.cdl \
+CLEANFILES = test0.nc test1_ncdump.cdl test1_ncdump.nc test2_ncdump.cdl \
+test1.cdl test0_ncdump.nc ctest1.cdl \
+test1_cdf5.nc test1_cdf5.cdl test0_cdf5.nc test2_cdf5.nc test2_cdf5.cdl \
+test0_offset.nc test1_offset.nc test1_offset.cdl test2_offset.nc test2_offset.cdl \
ctest0.nc ctest0_64.nc c1.cdl c1_4.cdl ctest1_64.cdl c0.nc c0_4.nc small.nc \
small2.nc c0tmp.nc c1.ncml utf8.cdl utf8_64.cdl utf8.nc utf8_64.nc \
tmp.cdl tst_vlen_data.nc tst_utf8.nc tst_special_atts.nc \
@@ -135,10 +142,10 @@ tst_dimsize_classic.nc tst_dimsize_64offset.nc tst_dimsize_64data.nc \
nc4_fileinfo.nc hdf5_fileinfo.hdf \
ref_hdf5_compat1.nc ref_hdf5_compat2.nc ref_hdf5_compat3.nc \
ref_tst_compounds.nc ref_tst_dims.nc ref_tst_interops4.nc \
-ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc
+ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc nccopy3_subset_out.nc
# These files all have to be included with the distribution.
-EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
+EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
ref_ctest1_nc4.cdl ref_ctest1_nc4c.cdl ref_tst_solar_1.cdl \
ref_tst_solar_2.cdl tst_netcdf4.sh tst_netcdf4_4.sh ref_tst_small.cdl \
tst_lengths.sh tst_ncml.cdl ref1.ncml ref_tst_group_data.cdl \
@@ -164,7 +171,7 @@ tst_formatx3.sh tst_formatx4.sh ref_tst_utf8_4.cdl \
tst_inttags.sh tst_inttags4.sh \
CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory_nc3.sh \
tst_dimsizes.sh tst_inmemory_nc4.sh tst_fileinfo.sh run_ncgen_tests.sh \
-run_ncgen_nc4_tests.sh
+run_ncgen_nc4_tests.sh tst_nccopy3_subset.sh ref_nccopy3_subset.nc
# CDL files and Expected results
SUBDIRS=cdl expected
@@ -177,7 +184,7 @@ CLEANFILES += results/*.nc results/*.dmp results/*.dmp2 tmp*.cdl \
tst_c0_64.cdl tst_compound_datasize_test.cdl \
tst_compound_datasize_test2.cdl tst_gattenum.nc \
tst_ncf199.cdl tst_tst_gattenum.cdl tst_tst_usuffix.cdl \
- tst_usuffix.nc tst_bug324.nc
+ tst_usuffix.nc tst_bug324.nc nccopy3_subset_out.nc
DISTCLEANFILES = results
diff --git a/ncdump/Makefile.in b/ncdump/Makefile.in
index a009b68..273641d 100644
--- a/ncdump/Makefile.in
+++ b/ncdump/Makefile.in
@@ -121,8 +121,8 @@ bin_PROGRAMS = ncdump$(EXEEXT) nccopy$(EXEEXT) $(am__EXEEXT_1)
@BUILD_TESTSETS_TRUE@ tst_output.sh tst_lengths.sh \
@BUILD_TESTSETS_TRUE@ tst_calendars.sh tst_utf8$(EXEEXT) \
@BUILD_TESTSETS_TRUE@ run_utf8_tests.sh tst_nccopy3.sh \
- at BUILD_TESTSETS_TRUE@ tst_charfill.sh tst_iter.sh \
- at BUILD_TESTSETS_TRUE@ tst_formatx3.sh tst_bom.sh \
+ at BUILD_TESTSETS_TRUE@ tst_nccopy3_subset.sh tst_charfill.sh \
+ at BUILD_TESTSETS_TRUE@ tst_iter.sh tst_formatx3.sh tst_bom.sh \
@BUILD_TESTSETS_TRUE@ tst_dimsizes.sh run_ncgen_tests.sh \
@BUILD_TESTSETS_TRUE@ $(am__append_5) $(am__append_6) \
@BUILD_TESTSETS_TRUE@ $(am__append_7) $(am__append_8) \
@@ -148,13 +148,28 @@ bin_PROGRAMS = ncdump$(EXEEXT) nccopy$(EXEEXT) $(am__EXEEXT_1)
@BUILD_TESTSETS_TRUE@@LARGE_FILE_TESTS_TRUE at am__append_6 = tst_iter.sh
@BUILD_DISKLESS_TRUE@@BUILD_TESTSETS_TRUE at am__append_7 = tst_inmemory_nc3.sh
@BUILD_DISKLESS_TRUE@@BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_8 = tst_inmemory_nc4.sh
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_9 = tst_inttags4.sh tst_create_files tst_group_data tst_enum_data tst_opaque_data \
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_string_data tst_vlen_data tst_comp tst_comp2 tst_nans \
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_special_atts tst_netcdf4.sh tst_h_rdc0 tst_unicode tst_fillbug \
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_fillbug.sh tst_netcdf4_4.sh tst_compress tst_nccopy4.sh \
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_grp_spec.sh tst_mud.sh tst_h_scalar tst_h_scalar.sh tst_formatx4.sh \
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_bug324 run_utf8_nc4_tests.sh
-
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_9 = tst_inttags4.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_create_files \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_group_data \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_enum_data \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_opaque_data \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_string_data \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_vlen_data tst_comp \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_comp2 tst_nans \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_special_atts \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_netcdf4.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_h_rdc0 tst_unicode \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_fillbug \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_fillbug.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_netcdf4_4.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_compress \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_nccopy4.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_grp_spec.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_mud.sh tst_h_scalar \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_h_scalar.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_formatx4.sh \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ tst_bug324 \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@ run_utf8_nc4_tests.sh
@BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE@@USE_NETCDF4_TRUE at am__append_10 = run_back_comp_tests.sh
@BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_11 = tst_ncgen4.sh
subdir = ncdump
@@ -708,7 +723,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -743,7 +760,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
@@ -868,11 +886,15 @@ man_MANS = ncdump.1 nccopy.1
# Can't run ncgen to generate ctest.c and ctest64.c on cross-compiles.
@BUILD_TESTSETS_TRUE at BUILT_SOURCES = ctest.c ctest64.c
#endif
-CLEANFILES = test0.nc test1.cdl test1.nc test2.cdl ctest1.cdl \
- ctest0.nc ctest0_64.nc c1.cdl c1_4.cdl ctest1_64.cdl c0.nc \
- c0_4.nc small.nc small2.nc c0tmp.nc c1.ncml utf8.cdl \
- utf8_64.cdl utf8.nc utf8_64.nc tmp.cdl tst_vlen_data.nc \
- tst_utf8.nc tst_special_atts.nc tst_unicode.nc tst_solar_2.nc \
+CLEANFILES = test0.nc test1_ncdump.cdl test1_ncdump.nc \
+ test2_ncdump.cdl test1.cdl test0_ncdump.nc ctest1.cdl \
+ test1_cdf5.nc test1_cdf5.cdl test0_cdf5.nc test2_cdf5.nc \
+ test2_cdf5.cdl test0_offset.nc test1_offset.nc \
+ test1_offset.cdl test2_offset.nc test2_offset.cdl ctest0.nc \
+ ctest0_64.nc c1.cdl c1_4.cdl ctest1_64.cdl c0.nc c0_4.nc \
+ small.nc small2.nc c0tmp.nc c1.ncml utf8.cdl utf8_64.cdl \
+ utf8.nc utf8_64.nc tmp.cdl tst_vlen_data.nc tst_utf8.nc \
+ tst_special_atts.nc tst_unicode.nc tst_solar_2.nc \
tst_string_data.nc tst_calendars.nc tst_nans.nc \
tst_opaque_data.nc tst_solar_cmp.nc tst_enum_data.nc \
tst_solar_1.nc tst_mslp_64.nc tst_mslp.nc tst_bug321.nc \
@@ -895,13 +917,14 @@ CLEANFILES = test0.nc test1.cdl test1.nc test2.cdl ctest1.cdl \
hdf5_fileinfo.hdf ref_hdf5_compat1.nc ref_hdf5_compat2.nc \
ref_hdf5_compat3.nc ref_tst_compounds.nc ref_tst_dims.nc \
ref_tst_interops4.nc ref_tst_xplatform2_1.nc \
- ref_tst_xplatform2_2.nc results/*.nc results/*.dmp \
- results/*.dmp2 tmp*.cdl c5.nc compound_datasize_test.nc \
- compound_datasize_test2.nc ncf199.nc ref_camrun.c tst_c0.cdl \
- tst_c0_4.cdl tst_c0_4c.cdl tst_c0_64.cdl \
- tst_compound_datasize_test.cdl tst_compound_datasize_test2.cdl \
- tst_gattenum.nc tst_ncf199.cdl tst_tst_gattenum.cdl \
- tst_tst_usuffix.cdl tst_usuffix.nc tst_bug324.nc
+ ref_tst_xplatform2_2.nc nccopy3_subset_out.nc results/*.nc \
+ results/*.dmp results/*.dmp2 tmp*.cdl c5.nc \
+ compound_datasize_test.nc compound_datasize_test2.nc ncf199.nc \
+ ref_camrun.c tst_c0.cdl tst_c0_4.cdl tst_c0_4c.cdl \
+ tst_c0_64.cdl tst_compound_datasize_test.cdl \
+ tst_compound_datasize_test2.cdl tst_gattenum.nc tst_ncf199.cdl \
+ tst_tst_gattenum.cdl tst_tst_usuffix.cdl tst_usuffix.nc \
+ tst_bug324.nc nccopy3_subset_out.nc
# These files all have to be included with the distribution.
EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
@@ -932,7 +955,8 @@ EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
tst_inttags.sh tst_inttags4.sh CMakeLists.txt XGetopt.c \
tst_bom.sh tst_inmemory_nc3.sh tst_dimsizes.sh \
tst_inmemory_nc4.sh tst_fileinfo.sh run_ncgen_tests.sh \
- run_ncgen_nc4_tests.sh tst_ncgen_shared.sh tst_ncgen4.sh \
+ run_ncgen_nc4_tests.sh tst_nccopy3_subset.sh \
+ ref_nccopy3_subset.nc tst_ncgen_shared.sh tst_ncgen4.sh \
tst_ncgen4_classic.sh tst_ncgen4_diff.sh tst_ncgen4_cycle.sh \
ref_ctest.c ref_ctest64.c
@@ -1606,6 +1630,13 @@ tst_nccopy3.sh.log: tst_nccopy3.sh
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+tst_nccopy3_subset.sh.log: tst_nccopy3_subset.sh
+ @p='tst_nccopy3_subset.sh'; \
+ b='tst_nccopy3_subset.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
tst_charfill.sh.log: tst_charfill.sh
@p='tst_charfill.sh'; \
b='tst_charfill.sh'; \
diff --git a/ncdump/cdl/Makefile.in b/ncdump/cdl/Makefile.in
index 588bdec..920e925 100644
--- a/ncdump/cdl/Makefile.in
+++ b/ncdump/cdl/Makefile.in
@@ -169,7 +169,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -204,7 +206,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncdump/expected/Makefile.in b/ncdump/expected/Makefile.in
index 4c6cb07..38bae1b 100644
--- a/ncdump/expected/Makefile.in
+++ b/ncdump/expected/Makefile.in
@@ -167,7 +167,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -202,7 +204,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncdump/nccopy.c b/ncdump/nccopy.c
index ed56eb0..7d1aef2 100644
--- a/ncdump/nccopy.c
+++ b/ncdump/nccopy.c
@@ -1,7 +1,7 @@
/*********************************************************************
* Copyright 2010, University Corporation for Atmospheric Research
* See netcdf/README file for copying and redistribution conditions.
- * Thanks to Philippe Poilbarbe and Antonio S. Cofiño for
+ * Thanks to Philippe Poilbarbe and Antonio S. Cofiño for
* compression additions.
* $Id: nccopy.c 400 2010-08-27 21:02:52Z russ $
*********************************************************************/
@@ -241,14 +241,14 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid,
/* Forward declaration, because copy_type, copy_vlen_type call each other */
static int copy_type(int igrp, nc_type typeid, int ogrp);
-/*
+/*
* copy a user-defined variable length type in the group igrp to the
* group ogrp
*/
static int
copy_vlen_type(int igrp, nc_type itype, int ogrp)
{
- int stat = NC_NOERR;
+ int stat = NC_NOERR;
nc_type ibasetype;
nc_type obasetype; /* base type in target group */
char name[NC_MAX_NAME];
@@ -275,13 +275,13 @@ copy_vlen_type(int igrp, nc_type itype, int ogrp)
return stat;
}
-/*
+/*
* copy a user-defined opaque type in the group igrp to the group ogrp
*/
static int
copy_opaque_type(int igrp, nc_type itype, int ogrp)
{
- int stat = NC_NOERR;
+ int stat = NC_NOERR;
nc_type otype;
char name[NC_MAX_NAME];
size_t size;
@@ -292,13 +292,13 @@ copy_opaque_type(int igrp, nc_type itype, int ogrp)
return stat;
}
-/*
+/*
* copy a user-defined enum type in the group igrp to the group ogrp
*/
static int
copy_enum_type(int igrp, nc_type itype, int ogrp)
{
- int stat = NC_NOERR;
+ int stat = NC_NOERR;
nc_type otype;
nc_type basetype;
size_t basesize;
@@ -317,13 +317,13 @@ copy_enum_type(int igrp, nc_type itype, int ogrp)
return stat;
}
-/*
+/*
* copy a user-defined compound type in the group igrp to the group ogrp
*/
static int
copy_compound_type(int igrp, nc_type itype, int ogrp)
{
- int stat = NC_NOERR;
+ int stat = NC_NOERR;
char name[NC_MAX_NAME];
size_t size;
size_t nfields;
@@ -351,7 +351,7 @@ copy_compound_type(int igrp, nc_type itype, int ogrp)
} else { /* field is array type */
int *fdimsizes;
fdimsizes = (int *) emalloc((fndims + 1) * sizeof(int));
- stat = nc_inq_compound_field(igrp, itype, fid, NULL, NULL, NULL,
+ stat = nc_inq_compound_field(igrp, itype, fid, NULL, NULL, NULL,
NULL, fdimsizes);
NC_CHECK(nc_insert_array_compound(ogrp, otype, fname, foff, oftype, fndims, fdimsizes));
free(fdimsizes);
@@ -361,13 +361,13 @@ copy_compound_type(int igrp, nc_type itype, int ogrp)
}
-/*
+/*
* copy a user-defined type in the group igrp to the group ogrp
*/
static int
copy_type(int igrp, nc_type typeid, int ogrp)
{
- int stat = NC_NOERR;
+ int stat = NC_NOERR;
nc_type type_class;
NC_CHECK(nc_inq_user_type(igrp, typeid, NULL, NULL, NULL, NULL, &type_class));
@@ -422,7 +422,7 @@ copy_groups(int iroot, int oroot)
NC_CHECK(nc_inq_grpname_full(grpids[i], &len_name, grpname_full));
/* Make sure, the parent group is also wanted (root group is always wanted) */
NC_CHECK(nc_inq_parid(iroot, grpname_full, &iparid));
- if (!option_grpstruct && !group_wanted(iparid, option_nlgrps, option_grpids)
+ if (!option_grpstruct && !group_wanted(iparid, option_nlgrps, option_grpids)
&& iparid != iroot) {
error("ERROR: trying to copy a group but not the parent: %s", grpname_full);
}
@@ -439,17 +439,17 @@ copy_groups(int iroot, int oroot)
}
free(grpids);
}
- return stat;
+ return stat;
}
-/*
+/*
* Copy the user-defined types in this group (igrp) and all its
* subgroups, recursively, to corresponding group in output (ogrp)
*/
static int
copy_types(int igrp, int ogrp)
{
- int stat = NC_NOERR;
+ int stat = NC_NOERR;
int ntypes;
nc_type *types = NULL;
int numgrps;
@@ -501,7 +501,7 @@ copy_var_specials(int igrp, int varid, int ogrp, int o_varid)
size_t *chunkp = (size_t *) emalloc(ndims * sizeof(size_t));
int *dimids = (int *) emalloc(ndims * sizeof(int));
int idim;
- /* size of a chunk: product of dimension chunksizes and size of value */
+ /* size of a chunk: product of dimension chunksizes and size of value */
size_t csprod = val_size(ogrp, o_varid);
int is_unlimited = 0;
NC_CHECK(nc_inq_var_chunking(igrp, varid, &contig, chunkp));
@@ -610,7 +610,7 @@ set_var_chunked(int ogrp, int o_varid)
size_t dimlen;
NC_CHECK(nc_inq_dimlen(ogrp, odimid, &dimlen));
if( (chunksize > 0) || dimmap_ounlim(odimid)) {
- chunked = 1;
+ chunked = 1;
}
if(dimlen > 0) { /* dimlen for unlimited dims is still 0 before copying data */
varsize *= dimlen;
@@ -702,7 +702,7 @@ copy_dims(int igrp, int ogrp)
int *unlimids;
#else
int unlimid;
-#endif /* USE_NETCDF4 */
+#endif /* USE_NETCDF4 */
NC_CHECK(nc_inq_ndims(igrp, &ndims));
@@ -739,7 +739,7 @@ copy_dims(int igrp, int ogrp)
if(idimid == unlimids[uld]) {
i_is_unlim = 1;
break;
- }
+ }
}
#else
idimid = dgrp;
@@ -751,7 +751,7 @@ copy_dims(int igrp, int ogrp)
stat = nc_inq_dim(igrp, idimid, name, &length);
if (stat == NC_EDIMSIZE && sizeof(size_t) < 8) {
error("dimension \"%s\" requires 64-bit platform", name);
- }
+ }
NC_CHECK(stat);
o_is_unlim = i_is_unlim;
if(i_is_unlim && !option_fix_unlimdims) {
@@ -766,7 +766,7 @@ copy_dims(int igrp, int ogrp)
#ifdef USE_NETCDF4
free(dimids);
free(unlimids);
-#endif /* USE_NETCDF4 */
+#endif /* USE_NETCDF4 */
return stat;
}
@@ -781,7 +781,7 @@ copy_atts(int igrp, int ivar, int ogrp, int ovar)
int stat = NC_NOERR;
NC_CHECK(nc_inq_varnatts(igrp, ivar, &natts));
-
+
for(iatt = 0; iatt < natts; iatt++) {
char name[NC_MAX_NAME];
NC_CHECK(nc_inq_attname(igrp, ivar, iatt, name));
@@ -832,7 +832,7 @@ copy_var(int igrp, int varid, int ogrp)
NC_CHECK(nc_def_var(ogrp, name, o_typeid, ndims, odimids, &o_varid));
/* attach the variable attributes to the output variable */
NC_CHECK(copy_atts(igrp, varid, ogrp, o_varid));
-#ifdef USE_NETCDF4
+#ifdef USE_NETCDF4
{
int inkind;
int outkind;
@@ -879,7 +879,7 @@ copy_vars(int igrp, int ogrp)
if(nc_inq_gvarid(igrp, option_lvars[iv], &varid) == NC_NOERR)
idadd(vlist, varid);
}
-
+
NC_CHECK(nc_inq_nvars(igrp, &nvars));
for (varid = 0; varid < nvars; varid++) {
if (!option_varstruct && option_nlvars > 0 && ! idmember(vlist, varid))
@@ -894,7 +894,7 @@ copy_vars(int igrp, int ogrp)
* group igrp in input to parent group ogrp in destination. Use
* dimmap array to map input dimids to output dimids. */
static int
-copy_schema(int igrp, int ogrp)
+copy_schema(int igrp, int ogrp)
{
int stat = NC_NOERR;
int ogid; /* like igrp but in output file */
@@ -906,7 +906,7 @@ copy_schema(int igrp, int ogrp)
NC_CHECK(copy_dims(igrp, ogid));
NC_CHECK(copy_atts(igrp, NC_GLOBAL, ogid, NC_GLOBAL));
NC_CHECK(copy_vars(igrp, ogid));
-#ifdef USE_NETCDF4
+#ifdef USE_NETCDF4
{
int numgrps;
int *grpids;
@@ -915,7 +915,7 @@ copy_schema(int igrp, int ogrp)
stat = nc_inq_grps(igrp, &numgrps, NULL);
grpids = (int *)emalloc((numgrps + 1) * sizeof(int));
NC_CHECK(nc_inq_grps(igrp, &numgrps, grpids));
-
+
for(i = 0; i < numgrps; i++) {
if (option_grpstruct || group_wanted(grpids[i], option_nlgrps, option_grpids)) {
NC_CHECK(copy_schema(grpids[i], ogid));
@@ -924,7 +924,7 @@ copy_schema(int igrp, int ogrp)
free(grpids);
}
#endif /* USE_NETCDF4 */
- return stat;
+ return stat;
}
/* Return number of values for a variable varid in a group igrp */
@@ -966,7 +966,7 @@ copy_var_data(int igrp, int varid, int ogrp) {
size_t *count;
nciter_t *iterp; /* opaque structure for iteration status */
int do_realloc = 0;
-#ifdef USE_NETCDF4
+#ifdef USE_NETCDF4
int okind;
size_t chunksize;
#endif
@@ -983,10 +983,10 @@ copy_var_data(int igrp, int varid, int ogrp) {
option_copy_buffer_size = value_size;
do_realloc = 1;
}
-#ifdef USE_NETCDF4
+#ifdef USE_NETCDF4
NC_CHECK(nc_inq_format(ogrp, &okind));
if(okind == NC_FORMAT_NETCDF4 || okind == NC_FORMAT_NETCDF4_CLASSIC) {
- /* if this variable chunked, set variable chunk cache size */
+ /* if this variable chunked, set variable chunk cache size */
int contig = 1;
NC_CHECK(nc_inq_var_chunking(ogrp, ovarid, &contig, NULL));
if(contig == 0) { /* chunked */
@@ -997,16 +997,16 @@ copy_var_data(int igrp, int varid, int ogrp) {
size_t chunkcache_size, chunkcache_nelems;
float chunkcache_preemption;
NC_CHECK(inq_var_chunking_params(igrp, varid, ogrp, ovarid,
- &chunkcache_size,
- &chunkcache_nelems,
+ &chunkcache_size,
+ &chunkcache_nelems,
&chunkcache_preemption));
- NC_CHECK(nc_set_var_chunk_cache(ogrp, ovarid,
- chunkcache_size,
- chunkcache_nelems,
- chunkcache_preemption));
- } else {
+ NC_CHECK(nc_set_var_chunk_cache(ogrp, ovarid,
+ chunkcache_size,
+ chunkcache_nelems,
+ chunkcache_preemption));
+ } else {
/* by default, use same chunk cache for all chunked variables */
- NC_CHECK(nc_set_var_chunk_cache(ogrp, ovarid,
+ NC_CHECK(nc_set_var_chunk_cache(ogrp, ovarid,
option_chunk_cache_size,
option_chunk_cache_nelems,
COPY_CHUNKCACHE_PREEMPTION));
@@ -1098,11 +1098,11 @@ copy_data(int igrp, int ogrp)
if(nc_inq_gvarid(igrp, option_lvars[iv], &varid) == NC_NOERR)
idadd(vlist, varid);
}
-
+
/* get groupid in output corresponding to group igrp in input,
* given parent group (or root group) ogrp in output */
NC_CHECK(get_grpid(igrp, ogrp, &ogid));
-
+
/* Copy data from this group */
NC_CHECK(nc_inq_nvars(igrp, &nvars));
@@ -1145,7 +1145,7 @@ count_dims(int ncid) {
for(igrp = 0; igrp < numgrps; igrp++) {
ndims += count_dims(grpids[igrp]);
}
- free(grpids);
+ free(grpids);
}
#endif /* USE_NETCDF4 */
return ndims;
@@ -1200,20 +1200,36 @@ classify_vars(
int **rvars) /* the array of record variable IDs, caller should free */
{
int varid;
+ int varindex = 0;
int nvars;
NC_CHECK(nc_inq_nvars(ncid, &nvars));
*nf = 0;
*fvars = (int *) emalloc(nvars * sizeof(int));
*nr = 0;
*rvars = (int *) emalloc(nvars * sizeof(int));
- for (varid = 0; varid < nvars; varid++) {
- if (isrecvar(ncid, varid)) {
- (*rvars)[*nr] = varid;
- (*nr)++;
- } else {
- (*fvars)[*nf] = varid;
- (*nf)++;
- }
+
+ if(option_nlvars > 0) {
+ for (varindex = 0; varindex < option_nlvars; varindex++) {
+ nc_inq_varid(ncid,option_lvars[varindex],&varid);
+
+ if (isrecvar(ncid, varid)) {
+ (*rvars)[*nr] = varid;
+ (*nr)++;
+ } else {
+ (*fvars)[*nf] = varid;
+ (*nf)++;
+ }
+ }
+ } else {
+ for (varid = 0; varid < nvars; varid++) {
+ if (isrecvar(ncid, varid)) {
+ (*rvars)[*nr] = varid;
+ (*nr)++;
+ } else {
+ (*fvars)[*nf] = varid;
+ (*nf)++;
+ }
+ }
}
return NC_NOERR;
}
@@ -1242,7 +1258,7 @@ copy_rec_var_data(int ncid, /* input */
size_t *start, /* start indices for record data */
size_t *count, /* edge lengths for record data */
void *buf /* buffer large enough to hold data */
- )
+ )
{
NC_CHECK(nc_get_vara(ncid, varid, start, count, buf));
NC_CHECK(nc_put_vara(ogrp, ovarid, start, count, buf));
@@ -1292,7 +1308,7 @@ copy_record_data(int ncid, int ogrp, size_t nrec_vars, int *rec_varids) {
start[ivar][ii] = 0;
count[ivar][ii] = dimlen;
}
- start[ivar][0] = 0;
+ start[ivar][0] = 0;
count[ivar][0] = 1; /* 1 record */
buf[ivar] = (void *) emalloc(nvals * value_size);
NC_CHECK(nc_inq_varname(ncid, varid, varname));
@@ -1308,7 +1324,7 @@ copy_record_data(int ncid, int ogrp, size_t nrec_vars, int *rec_varids) {
varid = rec_varids[ivar];
ovarid = rec_ovarids[ivar];
start[ivar][0] = irec;
- NC_CHECK(copy_rec_var_data(ncid, ogrp, irec, varid, ovarid,
+ NC_CHECK(copy_rec_var_data(ncid, ogrp, irec, varid, ovarid,
start[ivar], count[ivar], buf[ivar]));
}
}
@@ -1358,11 +1374,11 @@ copy(char* infile, char* outfile)
/* option_kind specifies which netCDF format for output, one of
*
- * SAME_AS_INPUT, NC_FORMAT_CLASSIC, NC_FORMAT_64BIT,
- * NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC
+ * SAME_AS_INPUT, NC_FORMAT_CLASSIC, NC_FORMAT_64BIT,
+ * NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC
*
* However, if compression or shuffling was specified and kind was SAME_AS_INPUT,
- * option_kind is changed to NC_FORMAT_NETCDF4_CLASSIC, if input format is
+ * option_kind is changed to NC_FORMAT_NETCDF4_CLASSIC, if input format is
* NC_FORMAT_CLASSIC or NC_FORMAT_64BIT .
*/
outkind = option_kind;
@@ -1370,11 +1386,11 @@ copy(char* infile, char* outfile)
outkind = inkind;
/* Deduce output kind if netCDF-4 features requested */
if (inkind == NC_FORMAT_CLASSIC || inkind == NC_FORMAT_64BIT_OFFSET
- || inkind == NC_FORMAT_CDF5) {
- if (option_deflate_level > 0 ||
- option_shuffle_vars == NC_SHUFFLE ||
- option_chunkspec)
- {
+ || inkind == NC_FORMAT_CDF5) {
+ if (option_deflate_level > 0 ||
+ option_shuffle_vars == NC_SHUFFLE ||
+ option_chunkspec)
+ {
outkind = NC_FORMAT_NETCDF4_CLASSIC;
}
}
@@ -1412,8 +1428,13 @@ copy(char* infile, char* outfile)
create_mode |= NC_64BIT_OFFSET;
break;
case NC_FORMAT_CDF5:
- create_mode |= NC_64BIT_DATA;
- break;
+#ifdef USE_CDF5
+ create_mode |= NC_64BIT_DATA;
+ break;
+#else
+ error("netCDF library built without CDF5 support, can't create CDF5 files");
+ break;
+#endif
#ifdef USE_NETCDF4
case NC_FORMAT_NETCDF4:
create_mode |= NC_NETCDF4;
@@ -1467,7 +1488,7 @@ copy(char* infile, char* outfile)
NC_CHECK(classify_vars(ogrp, &nfixed_vars, &fixed_varids, &nrec_vars, &rec_varids));
NC_CHECK(copy_fixed_size_data(igrp, ogrp, nfixed_vars, fixed_varids));
NC_CHECK(copy_record_data(igrp, ogrp, nrec_vars, rec_varids));
- } else {
+ } else {
NC_CHECK(copy_data(igrp, ogrp)); /* recursive, to handle nested groups */
}
@@ -1476,7 +1497,7 @@ copy(char* infile, char* outfile)
return stat;
}
-/*
+/*
* For non-negative numeric string with multiplier suffix K, M, G, T,
* or P (or lower-case equivalent), return corresponding value
* incorporating multiplier 1000, 1000000, 1.0d9, ... 1.0d15, or -1.0
@@ -1509,7 +1530,7 @@ double_with_suffix(char *str) {
break;
default:
dval = -1.0; /* error, suffix multiplier must be K, M, G, or T */
- }
+ }
}
return dval;
}
@@ -1565,13 +1586,13 @@ main(int argc, char**argv)
{"classic", NC_FORMAT_CLASSIC}, /* canonical format name */
{"nc3", NC_FORMAT_CLASSIC}, /* short format name */
{"1", NC_FORMAT_CLASSIC}, /* deprecated, use "-3" or "-k nc3" instead */
-
+
/* NetCDF-3 64-bit offset format */
{"64-bit offset", NC_FORMAT_64BIT_OFFSET}, /* canonical format name */
{"nc6", NC_FORMAT_64BIT_OFFSET}, /* short format name */
{"2", NC_FORMAT_64BIT_OFFSET}, /* deprecated, use "-6" or "-k nc6" instead */
{"64-bit-offset", NC_FORMAT_64BIT_OFFSET}, /* deprecated alias */
-
+
/* NetCDF-4 HDF5-based format */
{"netCDF-4", NC_FORMAT_NETCDF4}, /* canonical format name */
{"nc4", NC_FORMAT_NETCDF4}, /* short format name */
@@ -1611,7 +1632,7 @@ main(int argc, char**argv)
while ((c = getopt(argc, argv, "k:3467d:sum:c:h:e:rwxg:G:v:V:")) != -1) {
switch(c) {
- case 'k': /* for specifying variant of netCDF format to be generated
+ case 'k': /* for specifying variant of netCDF format to be generated
Format names:
"classic" or "nc3"
"64-bit offset" or "nc6"
@@ -1724,7 +1745,7 @@ main(int argc, char**argv)
make_lvars (optarg, &option_nlvars, &option_lvars);
option_varstruct = false;
break;
- default:
+ default:
usage();
}
}
diff --git a/ncdump/ref_inttags4.cdl b/ncdump/ref_inttags4.cdl
index 92eb333..4c330e0 100644
--- a/ncdump/ref_inttags4.cdl
+++ b/ncdump/ref_inttags4.cdl
@@ -5,7 +5,7 @@ variables:
ubyte ub(d) ;
ushort us(d) ;
uint ui(d) ;
- int i64(d) ;
+ int64 i64(d) ;
uint64 ui64(d) ;
// global attributes:
@@ -18,7 +18,7 @@ data:
ui = 4294967294, 4294967294, 4294967294 ;
- i64 = -1, -1, -1 ;
+ i64 = 9223372036854775807, 9223372036854775807, 9223372036854775807 ;
ui64 = 18446744073709551615, 18446744073709551615, 18446744073709551615 ;
}
diff --git a/ncdump/ref_nccopy3_subset.nc b/ncdump/ref_nccopy3_subset.nc
new file mode 100644
index 0000000..08f3a02
Binary files /dev/null and b/ncdump/ref_nccopy3_subset.nc differ
diff --git a/ncdump/run_ncgen_tests.sh b/ncdump/run_ncgen_tests.sh
index 9987c74..7238c20 100755
--- a/ncdump/run_ncgen_tests.sh
+++ b/ncdump/run_ncgen_tests.sh
@@ -8,6 +8,19 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
echo "*** Testing ncgen."
set -e
+# This shell script runs the ncdump tests.
+# get some config.h parameters
+if test -f ${top_builddir}/config.h ; then
+ if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
+ CDF5=1
+ else
+ CDF5=0
+ fi
+else
+ echo "Cannot locate config.h"
+ exit 1
+fi
+
#VALGRIND="valgrind -q --error-exitcode=2 --leak-check=full"
validateNC() {
@@ -37,11 +50,15 @@ echo "*** creating 64-bit offset file c0_64.nc from c0.cdl..."
validateNC c0 "c0_64" -k 64-bit-offset -b
-echo "*** creating 64-bit offset file c5.nc from c5.cdl..."
-${NCGEN} -k 64-bit-data -b -o c5.nc $top_srcdir/ncgen/c5.cdl
-if [ ! -f c5.nc ]; then
- echo "Failure."
- exit 1
+if test "x$USE_CDF5" = x1 ; then
+
+ echo "*** creating 64-bit data file c5.nc from c5.cdl..."
+ ${NCGEN} -k 64-bit-data -b -o c5.nc $top_srcdir/ncgen/c5.cdl
+ if [ ! -f c5.nc ]; then
+ echo "Failure."
+ exit 1
+ fi
+
fi
echo "*** Test successful!"
diff --git a/ncdump/run_tests.sh b/ncdump/run_tests.sh
index f192d8a..eb50747 100755
--- a/ncdump/run_tests.sh
+++ b/ncdump/run_tests.sh
@@ -15,16 +15,16 @@ echo "*** creating tst_small.cdl from tst_small.nc..."
${NCDUMP} tst_small.nc > tst_small.cdl
diff -b -w tst_small.cdl $srcdir/ref_tst_small.cdl
-echo "*** creating test0.nc from test0.cdl..."
-${NCGEN} -b $srcdir/test0.cdl
-echo "*** creating test1.cdl from test0.nc..."
-${NCDUMP} -n test1 test0.nc > test1.cdl
-echo "*** creating test1.nc from test1.cdl..."
-${NCGEN} -b test1.cdl
-echo "*** creating test2.cdl from test1.nc..."
-${NCDUMP} test1.nc > test2.cdl
-echo "*** checking that test1.cdl and test2.cdl are the same..."
-diff -b -w test1.cdl test2.cdl
+echo "*** creating test0_ncdump.nc from test0.cdl..."
+${NCGEN} -o test0_ncdump.nc -b $srcdir/test0.cdl
+echo "*** creating test1_ncdump.cdl from test0_ncdump.nc..."
+${NCDUMP} -n test1_ncdump test0_ncdump.nc > test1_ncdump.cdl
+echo "*** creating test1_ncdump.nc from test1_ncdump.cdl..."
+${NCGEN} -b test1_ncdump.cdl
+echo "*** creating test2_ncdump.cdl from test1_ncdump.nc..."
+${NCDUMP} test1_ncdump.nc > test2_ncdump.cdl
+echo "*** checking that test1_ncdump.cdl and test2_ncdump.cdl are the same..."
+diff -b -w test1_ncdump.cdl test2_ncdump.cdl
echo "*** All tests of ncgen and ncdump using test0.cdl passed!"
exit 0
diff --git a/ncdump/tst_64bit.sh b/ncdump/tst_64bit.sh
index 9baa2f4..838dabf 100755
--- a/ncdump/tst_64bit.sh
+++ b/ncdump/tst_64bit.sh
@@ -1,37 +1,52 @@
#!/bin/sh
-if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+set -e
+
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# This shell script runs the ncdump tests.
-
+# get some config.h parameters
+if test -f ${top_builddir}/config.h ; then
+ if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
+ CDF5=1
+ else
+ CDF5=0
+ fi
+else
+ echo "Cannot locate config.h"
+ exit 1
+fi
echo ""
echo "*** Testing ncgen and ncdump with 64-bit offset format."
set -e
-echo "*** creating test0.nc from test0.cdl..."
-${NCGEN} -b -k2 $srcdir/test0.cdl
-echo "*** creating test1.cdl from test0.nc..."
-${NCDUMP} -n test1 test0.nc > test1.cdl
-echo "*** creating test1.nc from test1.cdl..."
-${NCGEN} -b -k2 test1.cdl
-echo "*** creating test2.cdl from test1.nc..."
-${NCDUMP} test1.nc > test2.cdl
-cmp test1.cdl test2.cdl
+echo "*** creating test0_offset.nc from test0.cdl..."
+${NCGEN} -b -k2 -o test0_offset.nc $srcdir/test0.cdl
+echo "*** creating test1_offset.cdl from test0_offset.nc..."
+${NCDUMP} -n test1_offset test0_offset.nc > test1_offset.cdl
+echo "*** creating test1_offset.nc from test1_offset.cdl..."
+${NCGEN} -b -k2 -o test1_offset.nc test1_offset.cdl
+echo "*** creating test2_offset.cdl from test1.nc..."
+${NCDUMP} test1_offset.nc > test2_offset.cdl
+cmp test1_offset.cdl test2_offset.cdl
echo "*** All ncgen and ncdump with 64-bit offset format tests passed!"
+
+if test "x$CDF5" = x1 ; then
echo ""
echo "*** Testing ncgen and ncdump with CDF5 format."
set -e
-echo "*** creating test0.nc from test0.cdl..."
-${NCGEN} -b -k5 $srcdir/test0.cdl
-echo "*** creating test1.cdl from test0.nc..."
-${NCDUMP} -n test1 test0.nc > test1.cdl
-echo "*** creating test1.nc from test1.cdl..."
-${NCGEN} -b -k5 test1.cdl
-echo "*** creating test2.cdl from test1.nc..."
-${NCDUMP} test1.nc > test2.cdl
-cmp test1.cdl test2.cdl
+echo "*** creating test0_cdf5.nc from test0.cdl..."
+${NCGEN} -b -k5 -o test0_cdf5.nc $srcdir/test0.cdl
+echo "*** creating test1_cdf5.cdl from test0_cdf5.nc..."
+${NCDUMP} -n test1_cdf5 test0_cdf5.nc > test1_cdf5.cdl
+echo "*** creating test1_cdf5.nc from test1_cdf5.cdl..."
+${NCGEN} -b -k5 -o test1_cdf5.nc test1_cdf5.cdl
+echo "*** creating test2_cdf5.cdl from test1_cdf5.nc..."
+${NCDUMP} test1_cdf5.nc > test2_cdf5.cdl
+cmp test1_cdf5.cdl test2_cdf5.cdl
echo "*** All ncgen and ncdump with CDF5 format tests passed!"
+fi
exit 0
diff --git a/ncdump/tst_dimsizes.c b/ncdump/tst_dimsizes.c
index cb8fe81..edb0eb8 100644
--- a/ncdump/tst_dimsizes.c
+++ b/ncdump/tst_dimsizes.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
#include <stdio.h>
@@ -10,7 +11,10 @@
#define DIMMAXCLASSIC (NC_MAX_INT - 3)
#define DIMMAX64OFFSET (NC_MAX_UINT - 3)
+
+#ifdef USE_CDF5
#define DIMMAX64DATA (NC_MAX_UINT64 - 3)
+#endif
/*
Test that at least the meta-data works
@@ -62,6 +66,7 @@ main(int argc, char **argv)
if(dimsize != DIMMAX64OFFSET) ERR;
if ((stat=nc_close(ncid))) ERRSTAT(stat);
+#ifdef USE_CDF5
if(sizeof(size_t) == 8) {
printf("\n*** Writing Max Dimension Size (%llu) For NC_64BIT_DATA\n",DIMMAX64DATA);
if ((stat=nc_create(FILE64DATA, NC_CLOBBER | NC_64BIT_DATA, &ncid))) ERRSTAT(stat);
@@ -76,6 +81,7 @@ main(int argc, char **argv)
if(dimsize != DIMMAX64DATA) ERR;
if ((stat=nc_close(ncid))) ERRSTAT(stat);
}
+#endif /* USE_CDF5 */
SUMMARIZE_ERR;
FINAL_RESULTS;
diff --git a/ncdump/tst_formatx3.sh b/ncdump/tst_formatx3.sh
index 6021acc..9c00ca3 100755
--- a/ncdump/tst_formatx3.sh
+++ b/ncdump/tst_formatx3.sh
@@ -1,8 +1,21 @@
#!/bin/sh
-if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
+# This shell script runs the ncdump tests.
+# get some config.h parameters
+if test -f ${top_builddir}/config.h ; then
+ if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
+ USE_CDF5=1
+ else
+ USE_CDF5=0
+ fi
+else
+ echo "Cannot locate config.h"
+ exit 1
+fi
+
# This shell script tests the output several previous tests.
ECODE=0
@@ -28,17 +41,20 @@ echo "*** Fail: extended format for a 64-bit classic file"
ECODE=1
fi
-echo "Test extended format output for a 64-bit CDF-5 classic file"
-rm -f tmp
-${NCGEN} -k5 -b -o ./test.nc $srcdir/ref_tst_small.cdl
-${NCDUMP} -K test.nc >tmp
-if ! grep -F '64-bit data mode=00000020' <tmp ; then
-echo "*** Fail: extended format for a 64-bit CDF-5 classic file"
-ECODE=1
+
+# Only do following test if USE_CDF5 is true.
+
+if test "x$USE_CDF5" = x1 ; then
+ echo "Test extended format output for a 64-bit CDF-5 classic file"
+ rm -f tmp
+ ${NCGEN} -k5 -b -o ./test.nc $srcdir/ref_tst_small.cdl
+ ${NCDUMP} -K test.nc >tmp
+ if ! grep -F '64-bit data mode=00000020' <tmp ; then
+ echo "*** Fail: extended format for a 64-bit CDF-5 classic file"
+ ECODE=1
+ fi
fi
rm -f tmp test.nc
exit $ECODE
-
-
diff --git a/ncdump/tst_inttags4.sh b/ncdump/tst_inttags4.sh
index f62363c..ea92aa8 100755
--- a/ncdump/tst_inttags4.sh
+++ b/ncdump/tst_inttags4.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
@@ -8,7 +8,7 @@ set -e
echo "*** Test netcdf-4 integer constant suffixes"
echo "*** creating inttags4.nc from inttags4.cdl..."
-${NCGEN} -lb -o inttags4.nc $srcdir/inttags4.cdl
+${NCGEN} -lb -k nc4 -o inttags4.nc $srcdir/inttags4.cdl
echo "*** creating tst_inttags4.cdl from inttags4.nc..."
${NCDUMP} inttags4.nc > tst_inttags4.cdl
echo "*** comparing tst_inttags4.cdl to ref_inttags4.nc..."
diff --git a/ncdump/tst_lengths.sh b/ncdump/tst_lengths.sh
index 4520413..dbe5c68 100755
--- a/ncdump/tst_lengths.sh
+++ b/ncdump/tst_lengths.sh
@@ -1,8 +1,20 @@
#!/bin/sh
-if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
+# get some config.h parameters
+if test -f ${top_builddir}/config.h ; then
+ if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
+ HAVE_CDF5=1
+ else
+ HAVE_CDF5=0
+ fi
+else
+ echo "Cannot locate config.h"
+ exit 1
+fi
+
# It is unreasonable to test actual lengths of files
# (even netcdf-3 files).
#However, the files created in this script are used in later ones
@@ -10,7 +22,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
${NCGEN} -b ${srcdir}/small.cdl
${NCGEN} -b ${srcdir}/small2.cdl
-# This shell script tests lengths of small netcdf files and tests
+# This shell script tests lengths of small netcdf files and tests
# that rewriting a numeric value doesn't change file length
# $Id: tst_lengths.sh,v 1.10 2008/08/07 00:07:52 ed Exp $
@@ -93,39 +105,44 @@ ${NCGEN} -b -k64-bit-offset -x ${srcdir}/small.cdl && ${execdir}/rewrite-scalar
# exit 1
#fi
-echo "*** testing length of 64-bit data file"
-${NCGEN} -b -k64-bit-data ${srcdir}/small.cdl
-if test `wc -c < small.nc` != 104; then
- exit 1
-fi
-
-echo "*** testing length of 64-bit data file"
-${NCGEN} -b -5 ${srcdir}/small.cdl
-if test `wc -c < small.nc` != 104; then
- exit 1
-fi
-echo "*** testing length of 64-bit data file written with NOFILL"
-${NCGEN} -b -5 -x ${srcdir}/small.cdl
-#if test `wc -c < small.nc` != 104; then
-# exit 1
-#fi
-
-echo "*** testing length of rewritten 64-bit data file"
-${NCGEN} -b -5 ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
-# Watch out, it appears that the CDF-5 files are being rounded up to next page size
-# So, we need to truncate them wrt nul's in order to check size.
-# Bad hack, but what else can I do?
-if test `${execdir}/nctrunc <small.nc |wc -c` != 104; then
- exit 1
+# The following tests only occur if we have CDF5.
+if test "x$HAVE_CDF5" = x1 ; then
+
+ echo "*** testing length of 64-bit data file"
+ ${NCGEN} -b -k64-bit-data ${srcdir}/small.cdl
+ if test `wc -c < small.nc` != 104; then
+ exit 1
+ fi
+
+ echo "*** testing length of 64-bit data file"
+ ${NCGEN} -b -5 ${srcdir}/small.cdl
+ if test `wc -c < small.nc` != 104; then
+ exit 1
+ fi
+ echo "*** testing length of 64-bit data file written with NOFILL"
+ ${NCGEN} -b -5 -x ${srcdir}/small.cdl
+ #if test `wc -c < small.nc` != 104; then
+ # exit 1
+ #fi
+
+ echo "*** testing length of rewritten 64-bit data file"
+ ${NCGEN} -b -5 ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
+ # Watch out, it appears that the CDF-5 files are being rounded up to next page size
+ # So, we need to truncate them wrt nul's in order to check size.
+ # Bad hack, but what else can I do?
+ if test `${execdir}/nctrunc <small.nc |wc -c` != 104; then
+ exit 1
+ fi
+
+ echo "*** testing length of rewritten 64-bit data file written with NOFILL"
+ ${NCGEN} -b -5 -x ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
+ #if test `wc -c < small.nc` != 104; then
+ # exit 1
+ #fi
+
+ # End HAVE_CDF5 block.
fi
-echo "*** testing length of rewritten 64-bit data file written with NOFILL"
-${NCGEN} -b -5 -x ${srcdir}/small.cdl && ${execdir}/rewrite-scalar small.nc t
-#if test `wc -c < small.nc` != 104; then
-# exit 1
-#fi
-
-
# test with only one record variable of type byte or short, which need
# not be 4-byte aligned
echo "*** testing length of one-record-variable classic file"
@@ -134,22 +151,28 @@ ${NCGEN} -b ${srcdir}/small2.cdl
# exit 1
#fi
-echo "*** testing length of one-record-variable 64-bit data file"
-${NCGEN} -b -5 ${srcdir}/small2.cdl
-if test `wc -c < small2.nc` != 161; then
- exit 1
-fi
+# The following tests only occur if we have CDF5.
+if test "x$HAVE_CDF5" = x1 ; then
-echo "*** testing length of one-record-variable 64-bit data file"
-${NCGEN} -b -5 ${srcdir}/small2.cdl
-if test `wc -c < small2.nc` != 161; then
- exit 1
-fi
+ echo "*** testing length of one-record-variable 64-bit data file"
+ ${NCGEN} -b -5 ${srcdir}/small2.cdl
+ if test `wc -c < small2.nc` != 161; then
+ exit 1
+ fi
-echo "*** testing length of one-record-variable 64-bit data file written with NOFILL"
-${NCGEN} -b -5 -x ${srcdir}/small2.cdl
-if test `wc -c < small2.nc` != 161; then
- exit 1
+ echo "*** testing length of one-record-variable 64-bit data file"
+ ${NCGEN} -b -5 ${srcdir}/small2.cdl
+ if test `wc -c < small2.nc` != 161; then
+ exit 1
+ fi
+
+ echo "*** testing length of one-record-variable 64-bit data file written with NOFILL"
+ ${NCGEN} -b -5 -x ${srcdir}/small2.cdl
+ if test `wc -c < small2.nc` != 161; then
+ exit 1
+ fi
+
+ #end HAVE_CDF5 block
fi
echo "*** testing length of one-record-variable classic file written with NOFILL"
diff --git a/ncdump/tst_nccopy3.sh b/ncdump/tst_nccopy3.sh
index 28e9a4e..402d5e5 100755
--- a/ncdump/tst_nccopy3.sh
+++ b/ncdump/tst_nccopy3.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# For a netCDF-3 build, test nccopy on netCDF files in this directory
@@ -8,9 +8,26 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
set -e
echo ""
-TESTFILES='c0 c0tmp ctest0 ctest0_64 small small2 test0 test1
+# get some config.h parameters
+if test -f ${top_builddir}/config.h ; then
+ if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
+ HAVE_CDF5=1
+ else
+ HAVE_CDF5=0
+ fi
+else
+ echo "Cannot locate config.h"
+ exit 1
+fi
+
+TESTFILES='c0 c0tmp ctest0 ctest0_64 test0_offset test1_offset
tst_calendars tst_mslp tst_mslp_64 tst_ncml tst_small tst_utf8 utf8'
+if test "x$HAVE_CDF5" = x1 ; then
+ TESTFILES="$TESTFILES small small2"
+fi
+
+
echo "*** Testing netCDF-3 features of nccopy on ncdump/*.nc files"
for i in $TESTFILES ; do
echo "*** Testing nccopy $i.nc copy_of_$i.nc ..."
diff --git a/ncdump/tst_nccopy3_subset.sh b/ncdump/tst_nccopy3_subset.sh
new file mode 100755
index 0000000..16482ed
--- /dev/null
+++ b/ncdump/tst_nccopy3_subset.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Added in support of https://github.com/Unidata/netcdf-c/gh425 and
+# https://github.com/Unidata/netcdf-c/gh469
+#
+# The output isn't validated, but the regression it is fixing fails on nccopy.
+#
+
+if test "x$srcdir" = x ; then srcdir=`pwd`; fi
+. ../test_common.sh
+
+# For a netCDF-3 build, test nccopy on netCDF files in this directory
+
+set -e
+echo ""
+
+INFILE=${TOPSRCDIR}/ncdump/ref_nccopy3_subset.nc
+OUTFILE=nccopy3_subset_out.nc
+
+echo "*** Testing netCDF-3 nccopy -v/-V flags on $IN"
+
+echo "*** One Dimensional Tests"
+echo "*** Testing nccopy -v"
+
+${NCCOPY} -v lat ${INFILE} ${OUTFILE}
+
+echo "*** Testing nccopy -V"
+
+${NCCOPY} -V lat ${INFILE} ${OUTFILE}
+
+echo "*** Two Dimensional Tests"
+echo "*** Testing nccopy -v"
+
+${NCCOPY} -v lat_2D_rct ${INFILE} ${OUTFILE}
+
+echo "*** Testing nccopy -V"
+
+${NCCOPY} -V lat_2D_rct ${INFILE} ${OUTFILE}
+
+echo "nccopy passed!"
+exit 0
diff --git a/ncgen/Makefile.in b/ncgen/Makefile.in
index c2fe4de..c7d9a94 100644
--- a/ncgen/Makefile.in
+++ b/ncgen/Makefile.in
@@ -269,7 +269,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -304,7 +306,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/ncgen/main.c b/ncgen/main.c
index 50cb65e..dd6079c 100644
--- a/ncgen/main.c
+++ b/ncgen/main.c
@@ -498,6 +498,13 @@ main(
/* Compute the k_flag (1st pass) using rules in the man page (ncgen.1).*/
+#ifndef USE_CDF5
+ if(k_flag == NC_FORMAT_CDF5) {
+ derror("Output format CDF5 requested, but netcdf was built without cdf5 support.");
+ return 0;
+ }
+#endif
+
#ifndef USE_NETCDF4
if(enhanced_flag) {
derror("CDL input is enhanced mode, but --disable-netcdf4 was specified during build");
@@ -506,7 +513,7 @@ main(
#endif
if(l_flag == L_JAVA || l_flag == L_F77) {
- k_flag = 1;
+ k_flag = NC_FORMAT_CLASSIC;
if(enhanced_flag) {
derror("Java or Fortran requires classic model CDL input");
return 0;
@@ -517,12 +524,12 @@ main(
k_flag = globalspecials._Format;
if(cdf5_flag && !enhanced_flag && k_flag == 0)
- k_flag = 5;
+ k_flag = NC_FORMAT_64BIT_DATA;
if(enhanced_flag && k_flag == 0)
- k_flag = 3;
+ k_flag = NC_FORMAT_NETCDF4;
- if(enhanced_flag && k_flag != 3) {
- if(enhanced_flag && k_flag != 3 && k_flag != 5) {
+ if(enhanced_flag && k_flag != NC_FORMAT_NETCDF4) {
+ if(enhanced_flag && k_flag != NC_FORMAT_NETCDF4 && k_flag != NC_FORMAT_64BIT_DATA) {
derror("-k or _Format conflicts with enhanced CDL input");
return 0;
}
@@ -530,13 +537,13 @@ main(
if(specials_flag > 0 && k_flag == 0)
#ifdef USE_NETCDF4
- k_flag = 3;
+ k_flag = NC_FORMAT_NETCDF4;
#else
- k_flag = 1;
+ k_flag = NC_FORMAT_CLASSIC;
#endif
if(k_flag == 0)
- k_flag = 1;
+ k_flag = NC_FORMAT_CLASSIC;
/* Figure out usingclassic */
switch (k_flag) {
diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y
index 5ccaadd..48bacb0 100644
--- a/ncgen/ncgen.y
+++ b/ncgen/ncgen.y
@@ -1394,15 +1394,19 @@ datalistextend(Datalist* dl, NCConstant* con)
dlappend(dl,con);
}
+/*
+Try to infer the file type from the
+kinds of constructs used in the cdl file.
+*/
static void
vercheck(int tid)
{
switch (tid) {
- case NC_UBYTE: markcdf5("netCDF4/5 type: UBYTE"); break;
- case NC_USHORT: markcdf5("netCDF4/5 type: USHORT"); break;
- case NC_UINT: markcdf5("netCDF4/5 type: UINT"); break;
- case NC_INT64: markcdf5("netCDF4/5 type: INT64"); break;
- case NC_UINT64: markcdf5("netCDF4/5 type: UINT64"); break;
+ case NC_UBYTE: markcdf4("netCDF4/5 type: UBYTE"); break;
+ case NC_USHORT: markcdf4("netCDF4/5 type: USHORT"); break;
+ case NC_UINT: markcdf4("netCDF4/5 type: UINT"); break;
+ case NC_INT64: markcdf4("netCDF4/5 type: INT64"); break;
+ case NC_UINT64: markcdf4("netCDF4/5 type: UINT64"); break;
case NC_STRING: markcdf4("netCDF4 type: STRING"); break;
case NC_VLEN: markcdf4("netCDF4 type: VLEN"); break;
case NC_OPAQUE: markcdf4("netCDF4 type: OPAQUE"); break;
diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c
index 6e9e8b0..0680ecc 100644
--- a/ncgen/ncgenl.c
+++ b/ncgen/ncgenl.c
@@ -1,5 +1,5 @@
-#line 3 "ncgenl.c"
+#line 3 "lex.ncg.c"
#define YY_INT_ALIGNED short int
@@ -1335,7 +1335,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
-#line 1339 "ncgenl.c"
+#line 1339 "lex.ncg.c"
#define INITIAL 0
#define ST_C_COMMENT 1
@@ -1557,7 +1557,7 @@ YY_DECL
{
#line 217 "ncgen.l"
-#line 1561 "ncgenl.c"
+#line 1561 "lex.ncg.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -2144,7 +2144,7 @@ YY_RULE_SETUP
#line 570 "ncgen.l"
ECHO;
YY_BREAK
-#line 2148 "ncgenl.c"
+#line 2148 "lex.ncg.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c
index da81d60..9e21e44 100644
--- a/ncgen/ncgeny.c
+++ b/ncgen/ncgeny.c
@@ -195,7 +195,7 @@ static void yyerror(fmt,va_alist) const char* fmt; va_dcl;
extern int lex_init(void);
-#line 199 "ncgeny.c" /* yacc.c:339 */
+#line 199 "ncgen.tab.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
@@ -214,7 +214,7 @@ extern int lex_init(void);
#endif
/* In a future release of Bison, this section will be replaced
- by #include "ncgeny.h". */
+ by #include "ncgen.tab.h". */
#ifndef YY_NCG_NCGEN_TAB_H_INCLUDED
# define YY_NCG_NCGEN_TAB_H_INCLUDED
/* Debug traces. */
@@ -298,7 +298,7 @@ int nctype; /* for tracking attribute list type*/
Datalist* datalist;
NCConstant constant;
-#line 302 "ncgeny.c" /* yacc.c:355 */
+#line 302 "ncgen.tab.c" /* yacc.c:355 */
};
typedef union YYSTYPE YYSTYPE;
@@ -315,7 +315,7 @@ int ncgparse (void);
/* Copy the second part of user declarations. */
-#line 319 "ncgeny.c" /* yacc.c:358 */
+#line 319 "ncgen.tab.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -1619,13 +1619,13 @@ yyreduce:
case 2:
#line 221 "ncgen.y" /* yacc.c:1646 */
{if (error_count > 0) YYABORT;}
-#line 1623 "ncgeny.c" /* yacc.c:1646 */
+#line 1623 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 3:
#line 224 "ncgen.y" /* yacc.c:1646 */
{createrootgroup(datasetname);}
-#line 1629 "ncgeny.c" /* yacc.c:1646 */
+#line 1629 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 8:
@@ -1637,25 +1637,25 @@ yyreduce:
yyerror("duplicate group declaration within parent group for %s",
id->name);
}
-#line 1641 "ncgeny.c" /* yacc.c:1646 */
+#line 1641 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 9:
#line 252 "ncgen.y" /* yacc.c:1646 */
{listpop(groupstack);}
-#line 1647 "ncgeny.c" /* yacc.c:1646 */
+#line 1647 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 12:
#line 258 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1653 "ncgeny.c" /* yacc.c:1646 */
+#line 1653 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 13:
#line 260 "ncgen.y" /* yacc.c:1646 */
{markcdf4("Type specification");}
-#line 1659 "ncgeny.c" /* yacc.c:1646 */
+#line 1659 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 16:
@@ -1667,19 +1667,19 @@ yyreduce:
(yyvsp[0].sym)->name);
listpush(typdefs,(void*)(yyvsp[0].sym));
}
-#line 1671 "ncgeny.c" /* yacc.c:1646 */
+#line 1671 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 17:
#line 275 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1677 "ncgeny.c" /* yacc.c:1646 */
+#line 1677 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 18:
#line 275 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1683 "ncgeny.c" /* yacc.c:1646 */
+#line 1683 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 25:
@@ -1710,13 +1710,13 @@ yyreduce:
}
listsetlength(stack,stackbase);/* remove stack nodes*/
}
-#line 1714 "ncgeny.c" /* yacc.c:1646 */
+#line 1714 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 26:
#line 318 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 1720 "ncgeny.c" /* yacc.c:1646 */
+#line 1720 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 27:
@@ -1735,7 +1735,7 @@ yyreduce:
}
listpush(stack,(void*)(yyvsp[0].sym));
}
-#line 1739 "ncgeny.c" /* yacc.c:1646 */
+#line 1739 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 28:
@@ -1746,7 +1746,7 @@ yyreduce:
(yyvsp[-2].sym)->typ.econst=(yyvsp[0].constant);
(yyval.sym)=(yyvsp[-2].sym);
}
-#line 1750 "ncgeny.c" /* yacc.c:1646 */
+#line 1750 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 29:
@@ -1760,7 +1760,7 @@ yyreduce:
(yyvsp[0].sym)->typ.size=int32_val;
(yyvsp[0].sym)->typ.alignment=nctypealignment(NC_OPAQUE);
}
-#line 1764 "ncgeny.c" /* yacc.c:1646 */
+#line 1764 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 30:
@@ -1776,7 +1776,7 @@ yyreduce:
(yyvsp[0].sym)->typ.size=VLENSIZE;
(yyvsp[0].sym)->typ.alignment=nctypealignment(NC_VLEN);
}
-#line 1780 "ncgeny.c" /* yacc.c:1646 */
+#line 1780 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 31:
@@ -1810,19 +1810,19 @@ yyreduce:
}
listsetlength(stack,stackbase);/* remove stack nodes*/
}
-#line 1814 "ncgeny.c" /* yacc.c:1646 */
+#line 1814 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 32:
#line 404 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-1].mark);}
-#line 1820 "ncgeny.c" /* yacc.c:1646 */
+#line 1820 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 33:
#line 405 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-2].mark);}
-#line 1826 "ncgeny.c" /* yacc.c:1646 */
+#line 1826 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 34:
@@ -1838,97 +1838,97 @@ yyreduce:
f->typ.basetype = (yyvsp[-1].sym);
}
}
-#line 1842 "ncgeny.c" /* yacc.c:1646 */
+#line 1842 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 35:
#line 422 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym) = primsymbols[NC_CHAR]; }
-#line 1848 "ncgeny.c" /* yacc.c:1646 */
+#line 1848 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 36:
#line 423 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym) = primsymbols[NC_BYTE]; }
-#line 1854 "ncgeny.c" /* yacc.c:1646 */
+#line 1854 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 37:
#line 424 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym) = primsymbols[NC_SHORT]; }
-#line 1860 "ncgeny.c" /* yacc.c:1646 */
+#line 1860 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 38:
#line 425 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym) = primsymbols[NC_INT]; }
-#line 1866 "ncgeny.c" /* yacc.c:1646 */
+#line 1866 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 39:
#line 426 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym) = primsymbols[NC_FLOAT]; }
-#line 1872 "ncgeny.c" /* yacc.c:1646 */
+#line 1872 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 40:
#line 427 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym) = primsymbols[NC_DOUBLE]; }
-#line 1878 "ncgeny.c" /* yacc.c:1646 */
+#line 1878 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 41:
#line 428 "ncgen.y" /* yacc.c:1646 */
{ vercheck(NC_UBYTE); (yyval.sym) = primsymbols[NC_UBYTE]; }
-#line 1884 "ncgeny.c" /* yacc.c:1646 */
+#line 1884 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 42:
#line 429 "ncgen.y" /* yacc.c:1646 */
{ vercheck(NC_USHORT); (yyval.sym) = primsymbols[NC_USHORT]; }
-#line 1890 "ncgeny.c" /* yacc.c:1646 */
+#line 1890 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 43:
#line 430 "ncgen.y" /* yacc.c:1646 */
{ vercheck(NC_UINT); (yyval.sym) = primsymbols[NC_UINT]; }
-#line 1896 "ncgeny.c" /* yacc.c:1646 */
+#line 1896 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 44:
#line 431 "ncgen.y" /* yacc.c:1646 */
{ vercheck(NC_INT64); (yyval.sym) = primsymbols[NC_INT64]; }
-#line 1902 "ncgeny.c" /* yacc.c:1646 */
+#line 1902 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 45:
#line 432 "ncgen.y" /* yacc.c:1646 */
{ vercheck(NC_UINT64); (yyval.sym) = primsymbols[NC_UINT64]; }
-#line 1908 "ncgeny.c" /* yacc.c:1646 */
+#line 1908 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 47:
#line 436 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1914 "ncgeny.c" /* yacc.c:1646 */
+#line 1914 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 48:
#line 437 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1920 "ncgeny.c" /* yacc.c:1646 */
+#line 1920 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 51:
#line 444 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1926 "ncgeny.c" /* yacc.c:1646 */
+#line 1926 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 52:
#line 444 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1932 "ncgeny.c" /* yacc.c:1646 */
+#line 1932 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 55:
@@ -1939,7 +1939,7 @@ yyreduce:
fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long long)(yyvsp[-2].sym)->dim.declsize);
#endif
}
-#line 1943 "ncgeny.c" /* yacc.c:1646 */
+#line 1943 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 56:
@@ -1951,7 +1951,7 @@ fprintf(stderr,"dimension: %s = %llu\n",(yyvsp[-2].sym)->name,(unsigned long lon
fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
#endif
}
-#line 1955 "ncgeny.c" /* yacc.c:1646 */
+#line 1955 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 57:
@@ -1965,31 +1965,31 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
(yyval.sym)=(yyvsp[0].sym);
listpush(dimdefs,(void*)(yyvsp[0].sym));
}
-#line 1969 "ncgeny.c" /* yacc.c:1646 */
+#line 1969 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 59:
#line 481 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1975 "ncgeny.c" /* yacc.c:1646 */
+#line 1975 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 60:
#line 482 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1981 "ncgeny.c" /* yacc.c:1646 */
+#line 1981 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 63:
#line 489 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1987 "ncgeny.c" /* yacc.c:1646 */
+#line 1987 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 64:
#line 489 "ncgen.y" /* yacc.c:1646 */
{}
-#line 1993 "ncgeny.c" /* yacc.c:1646 */
+#line 1993 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 65:
@@ -2013,7 +2013,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
}
listsetlength(stack,stackbase);/* remove stack nodes*/
}
-#line 2017 "ncgeny.c" /* yacc.c:1646 */
+#line 2017 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 66:
@@ -2021,13 +2021,13 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
{(yyval.mark)=listlength(stack);
listpush(stack,(void*)(yyvsp[0].sym));
}
-#line 2025 "ncgeny.c" /* yacc.c:1646 */
+#line 2025 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 67:
#line 518 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 2031 "ncgeny.c" /* yacc.c:1646 */
+#line 2031 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 68:
@@ -2056,31 +2056,31 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
(yyvsp[-1].sym)->objectclass=NC_VAR;
listsetlength(stack,stackbase);/* remove stack nodes*/
}
-#line 2060 "ncgeny.c" /* yacc.c:1646 */
+#line 2060 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 69:
#line 548 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=listlength(stack);}
-#line 2066 "ncgeny.c" /* yacc.c:1646 */
+#line 2066 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 70:
#line 549 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-1].mark);}
-#line 2072 "ncgeny.c" /* yacc.c:1646 */
+#line 2072 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 71:
#line 552 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 2078 "ncgeny.c" /* yacc.c:1646 */
+#line 2078 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 72:
#line 554 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 2084 "ncgeny.c" /* yacc.c:1646 */
+#line 2084 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 73:
@@ -2095,7 +2095,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
}
(yyval.sym)=dimsym;
}
-#line 2099 "ncgeny.c" /* yacc.c:1646 */
+#line 2099 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 74:
@@ -2103,13 +2103,13 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
{(yyval.mark)=listlength(stack);
listpush(stack,(void*)(yyvsp[0].sym));
}
-#line 2107 "ncgeny.c" /* yacc.c:1646 */
+#line 2107 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 75:
#line 576 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 2113 "ncgeny.c" /* yacc.c:1646 */
+#line 2113 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 76:
@@ -2140,31 +2140,31 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
listsetlength(stack,stackbase);/* remove stack nodes*/
(yyval.sym) = (yyvsp[-1].sym);
}
-#line 2144 "ncgeny.c" /* yacc.c:1646 */
+#line 2144 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 77:
#line 609 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=listlength(stack);}
-#line 2150 "ncgeny.c" /* yacc.c:1646 */
+#line 2150 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 78:
#line 610 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-1].mark);}
-#line 2156 "ncgeny.c" /* yacc.c:1646 */
+#line 2156 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 79:
#line 614 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=listlength(stack); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 2162 "ncgeny.c" /* yacc.c:1646 */
+#line 2162 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 80:
#line 616 "ncgen.y" /* yacc.c:1646 */
{(yyval.mark)=(yyvsp[-2].mark); listpush(stack,(void*)(yyvsp[0].sym));}
-#line 2168 "ncgeny.c" /* yacc.c:1646 */
+#line 2168 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 81:
@@ -2178,7 +2178,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
(yyval.sym)->dim.isconstant = 1;
(yyval.sym)->dim.declsize = uint32_val;
}
-#line 2182 "ncgeny.c" /* yacc.c:1646 */
+#line 2182 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 82:
@@ -2196,7 +2196,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
(yyval.sym)->dim.isconstant = 1;
(yyval.sym)->dim.declsize = int32_val;
}
-#line 2200 "ncgeny.c" /* yacc.c:1646 */
+#line 2200 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 83:
@@ -2208,7 +2208,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
}
(yyval.sym)=vsym;
}
-#line 2212 "ncgeny.c" /* yacc.c:1646 */
+#line 2212 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 84:
@@ -2220,7 +2220,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
}
(yyval.sym)=tsym;
}
-#line 2224 "ncgeny.c" /* yacc.c:1646 */
+#line 2224 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 85:
@@ -2243,49 +2243,49 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
}
(yyval.sym)=tvsym;
}
-#line 2247 "ncgeny.c" /* yacc.c:1646 */
+#line 2247 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 86:
#line 691 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym)=(yyvsp[0].sym);}
-#line 2253 "ncgeny.c" /* yacc.c:1646 */
+#line 2253 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 87:
#line 698 "ncgen.y" /* yacc.c:1646 */
{}
-#line 2259 "ncgeny.c" /* yacc.c:1646 */
+#line 2259 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 88:
#line 698 "ncgen.y" /* yacc.c:1646 */
{}
-#line 2265 "ncgeny.c" /* yacc.c:1646 */
+#line 2265 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 89:
#line 702 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_NCPROPS_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);}
-#line 2271 "ncgeny.c" /* yacc.c:1646 */
+#line 2271 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 90:
#line 704 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_ISNETCDF4_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);}
-#line 2277 "ncgeny.c" /* yacc.c:1646 */
+#line 2277 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 91:
#line 706 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_SUPERBLOCK_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),ATTRGLOBAL);}
-#line 2283 "ncgeny.c" /* yacc.c:1646 */
+#line 2283 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 92:
#line 708 "ncgen.y" /* yacc.c:1646 */
{ (yyval.sym)=makeattribute((yyvsp[-2].sym),NULL,NULL,(yyvsp[0].datalist),ATTRGLOBAL);}
-#line 2289 "ncgeny.c" /* yacc.c:1646 */
+#line 2289 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 93:
@@ -2298,7 +2298,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
YYABORT;
}
}
-#line 2302 "ncgeny.c" /* yacc.c:1646 */
+#line 2302 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 94:
@@ -2313,67 +2313,67 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
YYABORT;
}
}
-#line 2317 "ncgeny.c" /* yacc.c:1646 */
+#line 2317 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 95:
#line 730 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);}
-#line 2323 "ncgeny.c" /* yacc.c:1646 */
+#line 2323 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 96:
#line 732 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_FILLVALUE_FLAG,(yyvsp[-4].sym),(yyvsp[-5].sym),(void*)(yyvsp[0].datalist),0);}
-#line 2329 "ncgeny.c" /* yacc.c:1646 */
+#line 2329 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 97:
#line 734 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_STORAGE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2335 "ncgeny.c" /* yacc.c:1646 */
+#line 2335 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 98:
#line 736 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_CHUNKSIZES_FLAG,(yyvsp[-4].sym),NULL,(void*)(yyvsp[0].datalist),0);}
-#line 2341 "ncgeny.c" /* yacc.c:1646 */
+#line 2341 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 99:
#line 738 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_FLETCHER32_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2347 "ncgeny.c" /* yacc.c:1646 */
+#line 2347 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 100:
#line 740 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_DEFLATE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2353 "ncgeny.c" /* yacc.c:1646 */
+#line 2353 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 101:
#line 742 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_SHUFFLE_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2359 "ncgeny.c" /* yacc.c:1646 */
+#line 2359 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 102:
#line 744 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_ENDIAN_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2365 "ncgeny.c" /* yacc.c:1646 */
+#line 2365 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 103:
#line 746 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_NOFILL_FLAG,(yyvsp[-4].sym),NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2371 "ncgeny.c" /* yacc.c:1646 */
+#line 2371 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 104:
#line 748 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym) = makespecial(_FORMAT_FLAG,NULL,NULL,(void*)&(yyvsp[0].constant),1);}
-#line 2377 "ncgeny.c" /* yacc.c:1646 */
+#line 2377 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 105:
@@ -2384,7 +2384,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
(yyvsp[0].sym)->is_prefixed=0;
setpathcurrent((yyvsp[0].sym));
}
-#line 2388 "ncgeny.c" /* yacc.c:1646 */
+#line 2388 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 106:
@@ -2395,257 +2395,257 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name);
(yyvsp[0].sym)->is_prefixed=1;
/* path is set in ncgen.l*/
}
-#line 2399 "ncgeny.c" /* yacc.c:1646 */
+#line 2399 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 108:
#line 769 "ncgen.y" /* yacc.c:1646 */
{}
-#line 2405 "ncgeny.c" /* yacc.c:1646 */
+#line 2405 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 109:
#line 770 "ncgen.y" /* yacc.c:1646 */
{}
-#line 2411 "ncgeny.c" /* yacc.c:1646 */
+#line 2411 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 112:
#line 778 "ncgen.y" /* yacc.c:1646 */
{(yyvsp[-2].sym)->data = (yyvsp[0].datalist);}
-#line 2417 "ncgeny.c" /* yacc.c:1646 */
+#line 2417 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 113:
#line 781 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist) = (yyvsp[0].datalist);}
-#line 2423 "ncgeny.c" /* yacc.c:1646 */
+#line 2423 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 114:
#line 782 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist) = (yyvsp[0].datalist);}
-#line 2429 "ncgeny.c" /* yacc.c:1646 */
+#line 2429 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 115:
#line 786 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist) = builddatalist(0);}
-#line 2435 "ncgeny.c" /* yacc.c:1646 */
+#line 2435 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 116:
#line 790 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));}
-#line 2441 "ncgeny.c" /* yacc.c:1646 */
+#line 2441 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 117:
#line 792 "ncgen.y" /* yacc.c:1646 */
{datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);}
-#line 2447 "ncgeny.c" /* yacc.c:1646 */
+#line 2447 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 118:
#line 796 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=(yyvsp[0].constant);}
-#line 2453 "ncgeny.c" /* yacc.c:1646 */
+#line 2453 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 119:
#line 797 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=builddatasublist((yyvsp[-1].datalist));}
-#line 2459 "ncgeny.c" /* yacc.c:1646 */
+#line 2459 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 120:
#line 801 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=(yyvsp[0].constant);}
-#line 2465 "ncgeny.c" /* yacc.c:1646 */
+#line 2465 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 121:
#line 802 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_OPAQUE);}
-#line 2471 "ncgeny.c" /* yacc.c:1646 */
+#line 2471 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 122:
#line 803 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_FILLVALUE);}
-#line 2477 "ncgeny.c" /* yacc.c:1646 */
+#line 2477 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 123:
#line 804 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_NIL);}
-#line 2483 "ncgeny.c" /* yacc.c:1646 */
+#line 2483 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 124:
#line 805 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=(yyvsp[0].constant);}
-#line 2489 "ncgeny.c" /* yacc.c:1646 */
+#line 2489 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 126:
#line 810 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant) = makeenumconstref((yyvsp[0].sym));}
-#line 2495 "ncgeny.c" /* yacc.c:1646 */
+#line 2495 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 127:
#line 814 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=evaluate((yyvsp[-3].sym),(yyvsp[-1].datalist));}
-#line 2501 "ncgeny.c" /* yacc.c:1646 */
+#line 2501 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 128:
#line 819 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));}
-#line 2507 "ncgeny.c" /* yacc.c:1646 */
+#line 2507 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 129:
#line 821 "ncgen.y" /* yacc.c:1646 */
{datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant))); (yyval.datalist)=(yyvsp[-2].datalist);}
-#line 2513 "ncgeny.c" /* yacc.c:1646 */
+#line 2513 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 130:
#line 825 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_CHAR);}
-#line 2519 "ncgeny.c" /* yacc.c:1646 */
+#line 2519 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 131:
#line 826 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_BYTE);}
-#line 2525 "ncgeny.c" /* yacc.c:1646 */
+#line 2525 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 132:
#line 827 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_SHORT);}
-#line 2531 "ncgeny.c" /* yacc.c:1646 */
+#line 2531 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 133:
#line 828 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_INT);}
-#line 2537 "ncgeny.c" /* yacc.c:1646 */
+#line 2537 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 134:
#line 829 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_INT64);}
-#line 2543 "ncgeny.c" /* yacc.c:1646 */
+#line 2543 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 135:
#line 830 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_UBYTE);}
-#line 2549 "ncgeny.c" /* yacc.c:1646 */
+#line 2549 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 136:
#line 831 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_USHORT);}
-#line 2555 "ncgeny.c" /* yacc.c:1646 */
+#line 2555 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 137:
#line 832 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_UINT);}
-#line 2561 "ncgeny.c" /* yacc.c:1646 */
+#line 2561 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 138:
#line 833 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_UINT64);}
-#line 2567 "ncgeny.c" /* yacc.c:1646 */
+#line 2567 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 139:
#line 834 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_FLOAT);}
-#line 2573 "ncgeny.c" /* yacc.c:1646 */
+#line 2573 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 140:
#line 835 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_DOUBLE);}
-#line 2579 "ncgeny.c" /* yacc.c:1646 */
+#line 2579 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 141:
#line 836 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_STRING);}
-#line 2585 "ncgeny.c" /* yacc.c:1646 */
+#line 2585 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 142:
#line 840 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist) = builddatalist(0); datalistextend((yyval.datalist),&((yyvsp[0].constant)));}
-#line 2591 "ncgeny.c" /* yacc.c:1646 */
+#line 2591 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 143:
#line 841 "ncgen.y" /* yacc.c:1646 */
{(yyval.datalist)=(yyvsp[-2].datalist); datalistextend((yyvsp[-2].datalist),&((yyvsp[0].constant)));}
-#line 2597 "ncgeny.c" /* yacc.c:1646 */
+#line 2597 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 144:
#line 846 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_INT);}
-#line 2603 "ncgeny.c" /* yacc.c:1646 */
+#line 2603 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 145:
#line 848 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_UINT);}
-#line 2609 "ncgeny.c" /* yacc.c:1646 */
+#line 2609 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 146:
#line 850 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_INT64);}
-#line 2615 "ncgeny.c" /* yacc.c:1646 */
+#line 2615 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 147:
#line 852 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_UINT64);}
-#line 2621 "ncgeny.c" /* yacc.c:1646 */
+#line 2621 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 148:
#line 856 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=makeconstdata(NC_STRING);}
-#line 2627 "ncgeny.c" /* yacc.c:1646 */
+#line 2627 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 149:
#line 860 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=(yyvsp[0].constant);}
-#line 2633 "ncgeny.c" /* yacc.c:1646 */
+#line 2633 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 150:
#line 861 "ncgen.y" /* yacc.c:1646 */
{(yyval.constant)=(yyvsp[0].constant);}
-#line 2639 "ncgeny.c" /* yacc.c:1646 */
+#line 2639 "ncgen.tab.c" /* yacc.c:1646 */
break;
case 151:
#line 867 "ncgen.y" /* yacc.c:1646 */
{(yyval.sym)=(yyvsp[0].sym);}
-#line 2645 "ncgeny.c" /* yacc.c:1646 */
+#line 2645 "ncgen.tab.c" /* yacc.c:1646 */
break;
-#line 2649 "ncgeny.c" /* yacc.c:1646 */
+#line 2649 "ncgen.tab.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
diff --git a/ncgen/ncgeny.h b/ncgen/ncgeny.h
index 4d09af5..a70994c 100644
--- a/ncgen/ncgeny.h
+++ b/ncgen/ncgeny.h
@@ -113,7 +113,7 @@ int nctype; /* for tracking attribute list type*/
Datalist* datalist;
NCConstant constant;
-#line 117 "ncgeny.h" /* yacc.c:1909 */
+#line 117 "ncgen.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
diff --git a/ncgen3/Makefile.in b/ncgen3/Makefile.in
index 16f7f52..474dbe2 100644
--- a/ncgen3/Makefile.in
+++ b/ncgen3/Makefile.in
@@ -443,7 +443,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -478,7 +480,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/nctest/Makefile.in b/nctest/Makefile.in
index 18acaaa..1d5ecca 100644
--- a/nctest/Makefile.in
+++ b/nctest/Makefile.in
@@ -450,7 +450,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -485,7 +487,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/oc2/Makefile.in b/oc2/Makefile.in
index 29d1ca9..aa5bdae 100644
--- a/oc2/Makefile.in
+++ b/oc2/Makefile.in
@@ -230,7 +230,9 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HAS_CDF5 = @HAS_CDF5@
HAS_DAP = @HAS_DAP@
+HAS_DAP2 = @HAS_DAP2@
HAS_DAP4 = @HAS_DAP4@
HAS_DISKLESS = @HAS_DISKLESS@
HAS_HDF4 = @HAS_HDF4@
@@ -265,7 +267,8 @@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NC_ENABLE_DOXYGEN_PDF_OUTPUT = @NC_ENABLE_DOXYGEN_PDF_OUTPUT@
-NC_HAS_DAP = @NC_HAS_DAP@
+NC_HAS_CDF5 = @NC_HAS_CDF5@
+NC_HAS_DAP2 = @NC_HAS_DAP2@
NC_HAS_DAP4 = @NC_HAS_DAP4@
NC_HAS_DISKLESS = @NC_HAS_DISKLESS@
NC_HAS_HDF4 = @NC_HAS_HDF4@
diff --git a/oc2/daplex.c b/oc2/daplex.c
index 00bd0b7..cf13282 100644
--- a/oc2/daplex.c
+++ b/oc2/daplex.c
@@ -11,6 +11,9 @@
#undef URLCVT /* NEVER turn this on */
+/* Do we %xx decode all or part of a DAP Identifer: see dapdecode() */
+#define DECODE_PARTIAL
+
#define DAP2ENCODE
#ifdef DAP2ENCODE
#define KEEPSLASH
@@ -355,8 +358,8 @@ daplexcleanup(DAPlexstate** lexstatep)
1. if the encoded character is in fact a legal DAP2 character
(alphanum+"_!~*'-\"") then it is decoded, otherwise not.
*/
-#ifndef DECODE_IDENTIFIERS
-static char* decodelist =
+#ifdef DECODE_PARTIAL
+static char* decodeset = /* Specify which characters are decoded */
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_!~*'-\"";
#endif
@@ -364,10 +367,10 @@ char*
dapdecode(DAPlexstate* lexstate, char* name)
{
char* decoded = NULL;
-#ifdef DECODE_IDENTIFIERS
- decoded = ncuridecode(name);
+#ifdef DECODE_PARTIAL
+ decoded = ncuridecodepartial(name,decodeset); /* Decode selected */
#else
- decoded = ncuridecodeonly(name,decodelist);
+ decoded = ncuridecode(name); /* Decode everything */
#endif
nclistpush(lexstate->reclaim,(void*)decoded);
return decoded;
diff --git a/oc2/occurlflags.c b/oc2/occurlflags.c
index d8eeb82..89d49b9 100644
--- a/oc2/occurlflags.c
+++ b/oc2/occurlflags.c
@@ -4,6 +4,7 @@
#include "config.h"
#include <curl/curl.h>
#include "ocinternal.h"
+#include "occurlfunctions.h"
#include "ocdebug.h"
static int nflags = 0;
@@ -22,7 +23,10 @@ static struct OCCURLFLAG oc_curlflags[] = {
{"CURLOPT_ERRORBUFFER",CURLOPT_ERRORBUFFER,10010,CF_STRING},
{"CURLOPT_FOLLOWLOCATION",CURLOPT_FOLLOWLOCATION,52,CF_LONG},
{"CURLOPT_HTTPAUTH",CURLOPT_HTTPAUTH,1007,CF_LONG},
+#ifdef HAVE_CURLOPT_KEYPASSWD
{"CURLOPT_KEYPASSWD",CURLOPT_KEYPASSWD,10026,CF_STRING},
+{"CURLOPT_SSLKEYPASSWD",CURLOPT_SSLKEYPASSWD,CURLOPT_KEYPASSWD,CF_STRING},
+#endif
{"CURLOPT_MAXREDIRS",CURLOPT_MAXREDIRS,68,CF_LONG},
{"CURLOPT_NETRC",CURLOPT_NETRC,51,CF_LONG},
{"CURLOPT_NETRC_FILE",CURLOPT_NETRC_FILE,10118,CF_STRING},
@@ -32,7 +36,6 @@ static struct OCCURLFLAG oc_curlflags[] = {
{"CURLOPT_PROXYUSERPWD",CURLOPT_PROXYUSERPWD,10006,CF_STRING},
{"CURLOPT_SSLCERT",CURLOPT_SSLCERT,10025,CF_STRING},
{"CURLOPT_SSLKEY",CURLOPT_SSLKEY,10087,CF_STRING},
-{"CURLOPT_SSLKEYPASSWD",CURLOPT_SSLKEYPASSWD,CURLOPT_KEYPASSWD,CF_STRING},
{"CURLOPT_SSL_VERIFYHOST",CURLOPT_SSL_VERIFYHOST,81,CF_LONG},
{"CURLOPT_SSL_VERIFYPEER",CURLOPT_SSL_VERIFYPEER,64,CF_LONG},
{"CURLOPT_TIMEOUT",CURLOPT_TIMEOUT,13,CF_LONG},
@@ -43,205 +46,6 @@ static struct OCCURLFLAG oc_curlflags[] = {
{NULL,0}
};
-#if 0
-static struct OCCURLFLAG oc_allcurlflags[] = {
-{"CURLOPT_ADDRESS_SCOPE",CURLOPT_ADDRESS_SCOPE,171,CF_UNKNOWN},
-{"CURLOPT_APPEND",CURLOPT_APPEND,50,CF_UNKNOWN},
-{"CURLOPT_AUTOREFERER",CURLOPT_AUTOREFERER,58,CF_UNKNOWN},
-{"CURLOPT_BUFFERSIZE",CURLOPT_BUFFERSIZE,98,CF_UNKNOWN},
-{"CURLOPT_CAINFO",CURLOPT_CAINFO,10065,CF_UNKNOWN},
-{"CURLOPT_CAPATH",CURLOPT_CAPATH,10097,CF_UNKNOWN},
-{"CURLOPT_CERTINFO",CURLOPT_CERTINFO,172,CF_UNKNOWN},
-{"CURLOPT_CHUNK_BGN_FUNCTION",CURLOPT_CHUNK_BGN_FUNCTION,20198,CF_UNKNOWN},
-{"CURLOPT_CHUNK_DATA",CURLOPT_CHUNK_DATA,10201,CF_UNKNOWN},
-{"CURLOPT_CHUNK_END_FUNCTION",CURLOPT_CHUNK_END_FUNCTION,20199,CF_UNKNOWN},
-{"CURLOPT_CLOSEPOLICY",CURLOPT_CLOSEPOLICY,72,CF_UNKNOWN},
-{"CURLOPT_CONNECT_ONLY",CURLOPT_CONNECT_ONLY,141,CF_UNKNOWN},
-{"CURLOPT_CONNECTTIMEOUT",CURLOPT_CONNECTTIMEOUT,78,CF_UNKNOWN},
-{"CURLOPT_CONNECTTIMEOUT_MS",CURLOPT_CONNECTTIMEOUT_MS,156,CF_UNKNOWN},
-{"CURLOPT_CONV_FROM_NETWORK_FUNCTION",CURLOPT_CONV_FROM_NETWORK_FUNCTION,20142,CF_UNKNOWN},
-{"CURLOPT_CONV_FROM_UTF8_FUNCTION",CURLOPT_CONV_FROM_UTF8_FUNCTION,20144,CF_UNKNOWN},
-{"CURLOPT_CONV_TO_NETWORK_FUNCTION",CURLOPT_CONV_TO_NETWORK_FUNCTION,20143,CF_UNKNOWN},
-{"CURLOPT_COOKIE",CURLOPT_COOKIE,10022,CF_UNKNOWN},
-{"CURLOPT_COOKIEFILE",CURLOPT_COOKIEFILE,10031,CF_UNKNOWN},
-{"CURLOPT_COOKIEJAR",CURLOPT_COOKIEJAR,10082,CF_UNKNOWN},
-{"CURLOPT_COOKIELIST",CURLOPT_COOKIELIST,10135,CF_UNKNOWN},
-{"CURLOPT_COOKIESESSION",CURLOPT_COOKIESESSION,96,CF_UNKNOWN},
-{"CURLOPT_COPYPOSTFIELDS",CURLOPT_COPYPOSTFIELDS,10165,CF_UNKNOWN},
-{"CURLOPT_CRLF",CURLOPT_CRLF,27,CF_UNKNOWN},
-{"CURLOPT_CRLFILE",CURLOPT_CRLFILE,10169,CF_UNKNOWN},
-{"CURLOPT_CUSTOMREQUEST",CURLOPT_CUSTOMREQUEST,10036,CF_UNKNOWN},
-{"CURLOPT_DEBUGDATA",CURLOPT_DEBUGDATA,10095,CF_UNKNOWN},
-{"CURLOPT_DEBUGFUNCTION",CURLOPT_DEBUGFUNCTION,20094,CF_UNKNOWN},
-{"CURLOPT_DIRLISTONLY",CURLOPT_DIRLISTONLY,48,CF_UNKNOWN},
-{"CURLOPT_DNS_CACHE_TIMEOUT",CURLOPT_DNS_CACHE_TIMEOUT,92,CF_UNKNOWN},
-{"CURLOPT_DNS_USE_GLOBAL_CACHE",CURLOPT_DNS_USE_GLOBAL_CACHE,91,CF_UNKNOWN},
-{"CURLOPT_EGDSOCKET",CURLOPT_EGDSOCKET,10077,CF_UNKNOWN},
-{"CURLOPT_ENCODING",CURLOPT_ENCODING,10102,CF_UNKNOWN},
-{"CURLOPT_ERRORBUFFER",CURLOPT_ERRORBUFFER,10010,CF_UNKNOWN},
-{"CURLOPT_FAILONERROR",CURLOPT_FAILONERROR,45,CF_UNKNOWN},
-{"CURLOPT_FILE",CURLOPT_FILE,10001,CF_UNKNOWN},
-{"CURLOPT_FILETIME",CURLOPT_FILETIME,69,CF_UNKNOWN},
-{"CURLOPT_FNMATCH_DATA",CURLOPT_FNMATCH_DATA,10202,CF_UNKNOWN},
-{"CURLOPT_FNMATCH_FUNCTION",CURLOPT_FNMATCH_FUNCTION,20200,CF_UNKNOWN},
-{"CURLOPT_FOLLOWLOCATION",CURLOPT_FOLLOWLOCATION,52,CF_UNKNOWN},
-{"CURLOPT_FORBID_REUSE",CURLOPT_FORBID_REUSE,75,CF_UNKNOWN},
-{"CURLOPT_FRESH_CONNECT",CURLOPT_FRESH_CONNECT,74,CF_UNKNOWN},
-{"CURLOPT_FTP_ACCOUNT",CURLOPT_FTP_ACCOUNT,10134,CF_UNKNOWN},
-{"CURLOPT_FTP_ALTERNATIVE_TO_USER",CURLOPT_FTP_ALTERNATIVE_TO_USER,10147,CF_UNKNOWN},
-{"CURLOPT_FTP_CREATE_MISSING_DIRS",CURLOPT_FTP_CREATE_MISSING_DIRS,110,CF_UNKNOWN},
-{"CURLOPT_FTP_FILEMETHOD",CURLOPT_FTP_FILEMETHOD,138,CF_UNKNOWN},
-{"CURLOPT_FTPPORT",CURLOPT_FTPPORT,10017,CF_UNKNOWN},
-{"CURLOPT_FTP_RESPONSE_TIMEOUT",CURLOPT_FTP_RESPONSE_TIMEOUT,112,CF_UNKNOWN},
-{"CURLOPT_FTP_SKIP_PASV_IP",CURLOPT_FTP_SKIP_PASV_IP,137,CF_UNKNOWN},
-{"CURLOPT_FTPSSLAUTH",CURLOPT_FTPSSLAUTH,129,CF_UNKNOWN},
-{"CURLOPT_FTP_SSL_CCC",CURLOPT_FTP_SSL_CCC,154,CF_UNKNOWN},
-{"CURLOPT_FTP_USE_EPRT",CURLOPT_FTP_USE_EPRT,106,CF_UNKNOWN},
-{"CURLOPT_FTP_USE_EPSV",CURLOPT_FTP_USE_EPSV,85,CF_UNKNOWN},
-{"CURLOPT_FTP_USE_PRET",CURLOPT_FTP_USE_PRET,188,CF_UNKNOWN},
-{"CURLOPT_GSSAPI_DELEGATION",CURLOPT_GSSAPI_DELEGATION,210,CF_UNKNOWN},
-{"CURLOPT_HEADER",CURLOPT_HEADER,42,CF_UNKNOWN},
-{"CURLOPT_HEADERFUNCTION",CURLOPT_HEADERFUNCTION,20079,CF_UNKNOWN},
-{"CURLOPT_HTTP200ALIASES",CURLOPT_HTTP200ALIASES,10104,CF_UNKNOWN},
-{"CURLOPT_HTTPAUTH",CURLOPT_HTTPAUTH,107,CF_UNKNOWN},
-{"CURLOPT_HTTP_CONTENT_DECODING",CURLOPT_HTTP_CONTENT_DECODING,158,CF_UNKNOWN},
-{"CURLOPT_HTTPGET",CURLOPT_HTTPGET,80,CF_UNKNOWN},
-{"CURLOPT_HTTPHEADER",CURLOPT_HTTPHEADER,10023,CF_UNKNOWN},
-{"CURLOPT_HTTPPOST",CURLOPT_HTTPPOST,10024,CF_UNKNOWN},
-{"CURLOPT_HTTPPROXYTUNNEL",CURLOPT_HTTPPROXYTUNNEL,61,CF_UNKNOWN},
-{"CURLOPT_HTTP_TRANSFER_DECODING",CURLOPT_HTTP_TRANSFER_DECODING,157,CF_UNKNOWN},
-{"CURLOPT_HTTP_VERSION",CURLOPT_HTTP_VERSION,84,CF_UNKNOWN},
-{"CURLOPT_IGNORE_CONTENT_LENGTH",CURLOPT_IGNORE_CONTENT_LENGTH,136,CF_UNKNOWN},
-{"CURLOPT_INFILE",CURLOPT_INFILE,10009,CF_UNKNOWN},
-{"CURLOPT_INFILESIZE",CURLOPT_INFILESIZE,14,CF_UNKNOWN},
-{"CURLOPT_INFILESIZE_LARGE",CURLOPT_INFILESIZE_LARGE,30115,CF_UNKNOWN},
-{"CURLOPT_INTERFACE",CURLOPT_INTERFACE,10062,CF_UNKNOWN},
-{"CURLOPT_INTERLEAVEDATA",CURLOPT_INTERLEAVEDATA,10195,CF_UNKNOWN},
-{"CURLOPT_INTERLEAVEFUNCTION",CURLOPT_INTERLEAVEFUNCTION,20196,CF_UNKNOWN},
-{"CURLOPT_IOCTLDATA",CURLOPT_IOCTLDATA,10131,CF_UNKNOWN},
-{"CURLOPT_IOCTLFUNCTION",CURLOPT_IOCTLFUNCTION,20130,CF_UNKNOWN},
-{"CURLOPT_IPRESOLVE",CURLOPT_IPRESOLVE,113,CF_UNKNOWN},
-{"CURLOPT_ISSUERCERT",CURLOPT_ISSUERCERT,10170,CF_UNKNOWN},
-{"CURLOPT_KEYPASSWD",CURLOPT_KEYPASSWD,10026,CF_UNKNOWN},
-{"CURLOPT_KRBLEVEL",CURLOPT_KRBLEVEL,10063,CF_UNKNOWN},
-{"CURLOPT_LOCALPORT",CURLOPT_LOCALPORT,139,CF_UNKNOWN},
-{"CURLOPT_LOCALPORTRANGE",CURLOPT_LOCALPORTRANGE,140,CF_UNKNOWN},
-{"CURLOPT_LOW_SPEED_LIMIT",CURLOPT_LOW_SPEED_LIMIT,19,CF_UNKNOWN},
-{"CURLOPT_LOW_SPEED_TIME",CURLOPT_LOW_SPEED_TIME,20,CF_UNKNOWN},
-{"CURLOPT_MAIL_FROM",CURLOPT_MAIL_FROM,10186,CF_UNKNOWN},
-{"CURLOPT_MAIL_RCPT",CURLOPT_MAIL_RCPT,10187,CF_UNKNOWN},
-{"CURLOPT_MAXCONNECTS",CURLOPT_MAXCONNECTS,71,CF_UNKNOWN},
-{"CURLOPT_MAXFILESIZE",CURLOPT_MAXFILESIZE,114,CF_UNKNOWN},
-{"CURLOPT_MAXFILESIZE_LARGE",CURLOPT_MAXFILESIZE_LARGE,30117,CF_UNKNOWN},
-{"CURLOPT_MAX_RECV_SPEED_LARGE",CURLOPT_MAX_RECV_SPEED_LARGE,30146,CF_UNKNOWN},
-{"CURLOPT_MAXREDIRS",CURLOPT_MAXREDIRS,68,CF_UNKNOWN},
-{"CURLOPT_MAX_SEND_SPEED_LARGE",CURLOPT_MAX_SEND_SPEED_LARGE,30145,CF_UNKNOWN},
-{"CURLOPT_NETRC",CURLOPT_NETRC,51,CF_UNKNOWN},
-{"CURLOPT_NETRC_FILE",CURLOPT_NETRC_FILE,10118,CF_UNKNOWN},
-{"CURLOPT_NEW_DIRECTORY_PERMS",CURLOPT_NEW_DIRECTORY_PERMS,160,CF_UNKNOWN},
-{"CURLOPT_NEW_FILE_PERMS",CURLOPT_NEW_FILE_PERMS,159,CF_UNKNOWN},
-{"CURLOPT_NOBODY",CURLOPT_NOBODY,44,CF_UNKNOWN},
-{"CURLOPT_NOPROGRESS",CURLOPT_NOPROGRESS,43,CF_UNKNOWN},
-{"CURLOPT_NOPROXY",CURLOPT_NOPROXY,10177,CF_UNKNOWN},
-{"CURLOPT_NOSIGNAL",CURLOPT_NOSIGNAL,99,CF_UNKNOWN},
-{"CURLOPT_OPENSOCKETDATA",CURLOPT_OPENSOCKETDATA,10164,CF_UNKNOWN},
-{"CURLOPT_OPENSOCKETFUNCTION",CURLOPT_OPENSOCKETFUNCTION,20163,CF_UNKNOWN},
-{"CURLOPT_PASSWORD",CURLOPT_PASSWORD,10174,CF_UNKNOWN},
-{"CURLOPT_PORT",CURLOPT_PORT,3,CF_UNKNOWN},
-{"CURLOPT_POST",CURLOPT_POST,47,CF_UNKNOWN},
-{"CURLOPT_POSTFIELDS",CURLOPT_POSTFIELDS,10015,CF_UNKNOWN},
-{"CURLOPT_POSTFIELDSIZE",CURLOPT_POSTFIELDSIZE,60,CF_UNKNOWN},
-{"CURLOPT_POSTFIELDSIZE_LARGE",CURLOPT_POSTFIELDSIZE_LARGE,30120,CF_UNKNOWN},
-{"CURLOPT_POSTQUOTE",CURLOPT_POSTQUOTE,10039,CF_UNKNOWN},
-{"CURLOPT_POSTREDIR",CURLOPT_POSTREDIR,161,CF_UNKNOWN},
-{"CURLOPT_PREQUOTE",CURLOPT_PREQUOTE,10093,CF_UNKNOWN},
-{"CURLOPT_PRIVATE",CURLOPT_PRIVATE,10103,CF_UNKNOWN},
-{"CURLOPT_PROGRESSDATA",CURLOPT_PROGRESSDATA,10057,CF_UNKNOWN},
-{"CURLOPT_PROGRESSFUNCTION",CURLOPT_PROGRESSFUNCTION,20056,CF_UNKNOWN},
-{"CURLOPT_PROTOCOLS",CURLOPT_PROTOCOLS,181,CF_UNKNOWN},
-{"CURLOPT_PROXY",CURLOPT_PROXY,10004,CF_UNKNOWN},
-{"CURLOPT_PROXYAUTH",CURLOPT_PROXYAUTH,111,CF_UNKNOWN},
-{"CURLOPT_PROXYPASSWORD",CURLOPT_PROXYPASSWORD,10176,CF_UNKNOWN},
-{"CURLOPT_PROXYPORT",CURLOPT_PROXYPORT,59,CF_UNKNOWN},
-{"CURLOPT_PROXY_TRANSFER_MODE",CURLOPT_PROXY_TRANSFER_MODE,166,CF_UNKNOWN},
-{"CURLOPT_PROXYTYPE",CURLOPT_PROXYTYPE,101,CF_UNKNOWN},
-{"CURLOPT_PROXYUSERNAME",CURLOPT_PROXYUSERNAME,10175,CF_UNKNOWN},
-{"CURLOPT_PROXYUSERPWD",CURLOPT_PROXYUSERPWD,10006,CF_UNKNOWN},
-{"CURLOPT_PUT",CURLOPT_PUT,54,CF_UNKNOWN},
-{"CURLOPT_QUOTE",CURLOPT_QUOTE,10028,CF_UNKNOWN},
-{"CURLOPT_RANDOM_FILE",CURLOPT_RANDOM_FILE,10076,CF_UNKNOWN},
-{"CURLOPT_RANGE",CURLOPT_RANGE,10007,CF_UNKNOWN},
-{"CURLOPT_READFUNCTION",CURLOPT_READFUNCTION,20012,CF_UNKNOWN},
-{"CURLOPT_REDIR_PROTOCOLS",CURLOPT_REDIR_PROTOCOLS,182,CF_UNKNOWN},
-{"CURLOPT_REFERER",CURLOPT_REFERER,10016,CF_UNKNOWN},
-{"CURLOPT_RESUME_FROM",CURLOPT_RESUME_FROM,21,CF_UNKNOWN},
-{"CURLOPT_RESUME_FROM_LARGE",CURLOPT_RESUME_FROM_LARGE,30116,CF_UNKNOWN},
-{"CURLOPT_RTSP_CLIENT_CSEQ",CURLOPT_RTSP_CLIENT_CSEQ,193,CF_UNKNOWN},
-{"CURLOPT_RTSP_REQUEST",CURLOPT_RTSP_REQUEST,189,CF_UNKNOWN},
-{"CURLOPT_RTSP_SERVER_CSEQ",CURLOPT_RTSP_SERVER_CSEQ,194,CF_UNKNOWN},
-{"CURLOPT_RTSP_SESSION_ID",CURLOPT_RTSP_SESSION_ID,10190,CF_UNKNOWN},
-{"CURLOPT_RTSP_STREAM_URI",CURLOPT_RTSP_STREAM_URI,10191,CF_UNKNOWN},
-{"CURLOPT_RTSP_TRANSPORT",CURLOPT_RTSP_TRANSPORT,10192,CF_UNKNOWN},
-{"CURLOPT_SEEKDATA",CURLOPT_SEEKDATA,10168,CF_UNKNOWN},
-{"CURLOPT_SEEKFUNCTION",CURLOPT_SEEKFUNCTION,20167,CF_UNKNOWN},
-{"CURLOPT_SHARE",CURLOPT_SHARE,10100,CF_UNKNOWN},
-{"CURLOPT_SOCKOPTDATA",CURLOPT_SOCKOPTDATA,10149,CF_UNKNOWN},
-{"CURLOPT_SOCKOPTFUNCTION",CURLOPT_SOCKOPTFUNCTION,20148,CF_UNKNOWN},
-{"CURLOPT_SOCKS5_GSSAPI_NEC",CURLOPT_SOCKS5_GSSAPI_NEC,180,CF_UNKNOWN},
-{"CURLOPT_SOCKS5_GSSAPI_SERVICE",CURLOPT_SOCKS5_GSSAPI_SERVICE,10179,CF_UNKNOWN},
-{"CURLOPT_SSH_AUTH_TYPES",CURLOPT_SSH_AUTH_TYPES,151,CF_UNKNOWN},
-{"CURLOPT_SSH_HOST_PUBLIC_KEY_MD5",CURLOPT_SSH_HOST_PUBLIC_KEY_MD5,10162,CF_UNKNOWN},
-{"CURLOPT_SSH_KEYDATA",CURLOPT_SSH_KEYDATA,10185,CF_UNKNOWN},
-{"CURLOPT_SSH_KEYFUNCTION",CURLOPT_SSH_KEYFUNCTION,20184,CF_UNKNOWN},
-{"CURLOPT_SSH_KNOWNHOSTS",CURLOPT_SSH_KNOWNHOSTS,10183,CF_UNKNOWN},
-{"CURLOPT_SSH_PRIVATE_KEYFILE",CURLOPT_SSH_PRIVATE_KEYFILE,10153,CF_UNKNOWN},
-{"CURLOPT_SSH_PUBLIC_KEYFILE",CURLOPT_SSH_PUBLIC_KEYFILE,10152,CF_UNKNOWN},
-{"CURLOPT_SSLCERT",CURLOPT_SSLCERT,10025,CF_UNKNOWN},
-{"CURLOPT_SSLCERTTYPE",CURLOPT_SSLCERTTYPE,10086,CF_UNKNOWN},
-{"CURLOPT_SSL_CIPHER_LIST",CURLOPT_SSL_CIPHER_LIST,10083,CF_UNKNOWN},
-{"CURLOPT_SSL_CTX_DATA",CURLOPT_SSL_CTX_DATA,10109,CF_UNKNOWN},
-{"CURLOPT_SSL_CTX_FUNCTION",CURLOPT_SSL_CTX_FUNCTION,20108,CF_UNKNOWN},
-{"CURLOPT_SSLENGINE",CURLOPT_SSLENGINE,10089,CF_UNKNOWN},
-{"CURLOPT_SSLENGINE_DEFAULT",CURLOPT_SSLENGINE_DEFAULT,90,CF_UNKNOWN},
-{"CURLOPT_SSLKEY",CURLOPT_SSLKEY,10087,CF_UNKNOWN},
-{"CURLOPT_SSLKEYTYPE",CURLOPT_SSLKEYTYPE,10088,CF_UNKNOWN},
-{"CURLOPT_SSL_SESSIONID_CACHE",CURLOPT_SSL_SESSIONID_CACHE,150,CF_UNKNOWN},
-{"CURLOPT_SSL_VERIFYHOST",CURLOPT_SSL_VERIFYHOST,81,CF_UNKNOWN},
-{"CURLOPT_SSL_VERIFYPEER",CURLOPT_SSL_VERIFYPEER,64,CF_UNKNOWN},
-{"CURLOPT_SSLVERSION",CURLOPT_SSLVERSION,32,CF_UNKNOWN},
-{"CURLOPT_STDERR",CURLOPT_STDERR,10037,CF_UNKNOWN},
-{"CURLOPT_TCP_NODELAY",CURLOPT_TCP_NODELAY,121,CF_UNKNOWN},
-{"CURLOPT_TELNETOPTIONS",CURLOPT_TELNETOPTIONS,10070,CF_UNKNOWN},
-{"CURLOPT_TFTP_BLKSIZE",CURLOPT_TFTP_BLKSIZE,178,CF_UNKNOWN},
-{"CURLOPT_TIMECONDITION",CURLOPT_TIMECONDITION,33,CF_UNKNOWN},
-{"CURLOPT_TIMEOUT",CURLOPT_TIMEOUT,13,CF_UNKNOWN},
-{"CURLOPT_TIMEOUT_MS",CURLOPT_TIMEOUT_MS,155,CF_UNKNOWN},
-{"CURLOPT_TIMEVALUE",CURLOPT_TIMEVALUE,34,CF_UNKNOWN},
-{"CURLOPT_TRANSFERTEXT",CURLOPT_TRANSFERTEXT,53,CF_UNKNOWN},
-{"CURLOPT_UNRESTRICTED_AUTH",CURLOPT_UNRESTRICTED_AUTH,105,CF_UNKNOWN},
-{"CURLOPT_UPLOAD",CURLOPT_UPLOAD,46,CF_UNKNOWN},
-{"CURLOPT_URL",CURLOPT_URL,10002,CF_UNKNOWN},
-{"CURLOPT_USERAGENT",CURLOPT_USERAGENT,10018,CF_UNKNOWN},
-{"CURLOPT_USERNAME",CURLOPT_USERNAME,10173,CF_UNKNOWN},
-{"CURLOPT_USERPWD",CURLOPT_USERPWD,10005,CF_UNKNOWN},
-{"CURLOPT_USE_SSL",CURLOPT_USE_SSL,119,CF_UNKNOWN},
-{"CURLOPT_VERBOSE",CURLOPT_VERBOSE,41,CF_UNKNOWN},
-{"CURLOPT_WILDCARDMATCH",CURLOPT_WILDCARDMATCH,197,CF_UNKNOWN},
-{"CURLOPT_WRITEFUNCTION",CURLOPT_WRITEFUNCTION,20011,CF_UNKNOWN},
-{"CURLOPT_WRITEHEADER",CURLOPT_WRITEHEADER,10029,CF_UNKNOWN},
-{"CURLOPT_WRITEINFO",CURLOPT_WRITEINFO,10040,CF_UNKNOWN},
-{NULL,0}
-};
-
-struct OCCURLFLAG*
-occurlflagsall(void)
-{
- if(nflags == 0) initialize();
- return oc_allcurlflags;
-}
-
-#endif
-
static int touppercase(int c)
{
if(c >= 'a' && c <= 'z')
diff --git a/oc2/occurlfunctions.c b/oc2/occurlfunctions.c
index c49077e..b721a3c 100644
--- a/oc2/occurlfunctions.c
+++ b/oc2/occurlfunctions.c
@@ -11,12 +11,6 @@
/* Mnemonic */
#define OPTARG void*
-/* Condition on libcurl version */
-/* Set up an alias as needed */
-#ifndef HAVE_CURLOPT_KEYPASSWD
-#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
-#endif
-
#define NETRCFILETAG "HTTP.NETRC"
#define CHECK(state,flag,value) {if(check(state,flag,(void*)value) != OC_NOERR) {goto done;}}
@@ -94,9 +88,10 @@ ocset_curlflag(OCstate* state, int flag)
switch (flag) {
- case CURLOPT_USERPWD:
- if(state->creds.userpwd != NULL) {
- CHECK(state, CURLOPT_USERPWD, state->creds.userpwd);
+ case CURLOPT_USERPWD: /* Does both user and pwd */
+ if(state->creds.user != NULL && state->creds.pwd != NULL) {
+ CHECK(state, CURLOPT_USERNAME, state->creds.user);
+ CHECK(state, CURLOPT_PASSWORD, state->creds.pwd);
CHECK(state, CURLOPT_HTTPAUTH, (OPTARG)CURLAUTH_ANY);
}
break;
@@ -155,8 +150,9 @@ ocset_curlflag(OCstate* state, int flag)
if(state->proxy.host != NULL) {
CHECK(state, CURLOPT_PROXY, state->proxy.host);
CHECK(state, CURLOPT_PROXYPORT, (OPTARG)(long)state->proxy.port);
- if(state->proxy.userpwd) {
- CHECK(state, CURLOPT_PROXYUSERPWD, state->proxy.userpwd);
+ if(state->proxy.user != NULL && state->proxy.pwd != NULL) {
+ CHECK(state, CURLOPT_PROXYUSERNAME, state->proxy.user);
+ CHECK(state, CURLOPT_PROXYPASSWORD, state->proxy.pwd);
#ifdef CURLOPT_PROXYAUTH
CHECK(state, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
#endif
@@ -340,6 +336,7 @@ oc_curl_protocols(struct OCGLOBALSTATE* state)
}
+#if 0
/*
"Inverse" of ocset_curlflag;
Given a flag and value, it updates state.
@@ -352,9 +349,14 @@ ocset_curlstate(OCstate* state, int flag, void* value)
switch (flag) {
- case CURLOPT_USERPWD:
- if(state->creds.userpwd != NULL) free(state->creds.userpwd);
- state->creds.userpwd = strdup((char*)value);
+ case CURLOPT_USERNAME:
+ if(state->creds.user != NULL) free(state->creds.user);
+ state->creds.user = strdup((char*)value);
+ break;
+
+ case CURLOPT_PASSWORD:
+ if(state->creds.pwd != NULL) free(state->creds.pwd);
+ state->creds.pwd = strdup((char*)value);
break;
case CURLOPT_COOKIEJAR: case CURLOPT_COOKIEFILE:
@@ -443,3 +445,4 @@ ocset_curlstate(OCstate* state, int flag, void* value)
done:
return stat;
}
+#endif
diff --git a/oc2/occurlfunctions.h b/oc2/occurlfunctions.h
index f4b00b5..1be5999 100644
--- a/oc2/occurlfunctions.h
+++ b/oc2/occurlfunctions.h
@@ -9,6 +9,15 @@
#define _CURLFUNCTION_H_
+/* Condition on libcurl version */
+/* Set up an alias as needed */
+#ifndef HAVE_CURLOPT_KEYPASSWD
+#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
+#endif
+#ifndef HAVE_CURLINFO_RESPONSE_CODE
+#define CURLINFO_RESPONSE_CODE CURLINFO_HTTP_CODE
+#endif
+
extern OCerror ocset_curlopt(OCstate* state, int flag, void* value);
struct OCCURLFLAG* occurlflagbyflag(int flag);
@@ -18,7 +27,6 @@ extern OCerror ocset_flags_perfetch(OCstate*);
extern OCerror ocset_flags_perlink(OCstate*);
extern OCerror ocset_curlflag(OCstate*,int);
-extern OCerror ocset_curlstate(OCstate* state, int flag, void* value);
extern void oc_curl_debug(OCstate* state);
diff --git a/oc2/ochttp.c b/oc2/ochttp.c
index f756c2d..4c3e850 100644
--- a/oc2/ochttp.c
+++ b/oc2/ochttp.c
@@ -23,11 +23,7 @@ ocfetchhttpcode(CURL* curl)
long httpcode = 200;
CURLcode cstat = CURLE_OK;
/* Extract the http code */
-#ifdef HAVE_CURLINFO_RESPONSE_CODE
cstat = CURLERR(curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&httpcode));
-#else
- cstat = curl_easy_getinfo(curl,CURLINFO_HTTP_CODE,&httpcode);
-#endif
if(cstat != CURLE_OK) httpcode = 0;
return httpcode;
}
diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c
index 29a74ed..9ca549d 100644
--- a/oc2/ocinternal.c
+++ b/oc2/ocinternal.c
@@ -427,8 +427,10 @@ occlose(OCstate* state)
ocfree(state->ssl.cainfo);
ocfree(state->ssl.capath);
ocfree(state->proxy.host);
- ocfree(state->proxy.userpwd);
- ocfree(state->creds.userpwd);
+ ocfree(state->proxy.user);
+ ocfree(state->proxy.pwd);
+ ocfree(state->creds.user);
+ ocfree(state->creds.pwd);
if(state->curl != NULL) occurlclose(state->curl);
ocfree(state);
}
@@ -606,7 +608,6 @@ ocset_curlproperties(OCstate* state)
if(path == NULL) return OC_ENOMEM;
occopycat(path,len,3,ocglobalstate.tempdir,"/","occookies");
stat = ocmktmp(path,&name);
-fprintf(stderr,"%s => %s\n",state->uri->uri,name); fflush(stderr);
free(path);
state->curlflags.cookiejar = name;
state->curlflags.createdflags |= COOKIECREATED;
diff --git a/oc2/ocinternal.h b/oc2/ocinternal.h
index a954c3c..b4995b3 100644
--- a/oc2/ocinternal.h
+++ b/oc2/ocinternal.h
@@ -217,10 +217,12 @@ struct OCstate {
struct OCproxy {
char *host; /*CURLOPT_PROXY*/
int port; /*CURLOPT_PROXYPORT*/
- char* userpwd; /*CURLOPT_PROXYUSERPWD*/
+ char* user; /*CURLOPT_PROXYUSERNAME*/
+ char* pwd; /*CURLOPT_PROXYPASSWORD*/
} proxy;
struct OCcredentials {
- char *userpwd; /*CURLOPT_USERPWD*/
+ char *user; /*CURLOPT_USERNAME*/
+ char *pwd; /*CURLOPT_PASSWORD*/
} creds;
void* usercurldata;
long ddslastmodified;
diff --git a/oc2/ocrc.c b/oc2/ocrc.c
index d000e75..d4ec4dc 100644
--- a/oc2/ocrc.c
+++ b/oc2/ocrc.c
@@ -26,7 +26,6 @@ static OCerror rc_search(const char* prefix, const char* rcfile, char** pathp);
static int rcreadline(FILE* f, char* more, int morelen);
static void rctrim(char* text);
-static char* combinecredentials(const char* user, const char* pwd);
static void storedump(char* msg, struct OCTriple*, int ntriples);
@@ -48,17 +47,49 @@ occredentials_in_url(const char *url)
return 0;
}
+/*
+Given form user:pwd, parse into user and pwd
+and do %xx unescaping
+*/
static OCerror
-ocextract_credentials(const char *url, char **userpwd, char **result_url)
+parsecredentials(const char* userpwd, char** userp, char** pwdp)
+{
+ char* user = NULL;
+ char* pwd = NULL;
+
+ if(userpwd == NULL)
+ return OC_EINVAL;
+ user = strdup(userpwd);
+ if(user == NULL)
+ return NC_ENOMEM;
+ pwd = strchr(user,':');
+ if(pwd == NULL)
+ return OC_EINVAL;
+ *pwd = '\0';
+ pwd++;
+ if(userp)
+ *userp = ncuridecode(user);
+ if(pwdp)
+ *pwdp = ncuridecode(pwd);
+ free(user);
+ return OC_NOERR;
+}
+
+static OCerror
+ocextract_credentials(const char *url, char **user, char** pwd, char **result_url)
{
NCURI* parsed = NULL;
- if(ncuriparse(url,&parsed) != NCU_OK)
+
+ if(url == NULL || ncuriparse(url,&parsed) != NCU_OK)
return OCTHROW(OC_EBADURL);
if(parsed->user != NULL || parsed->password == NULL) {
ncurifree(parsed);
return OCTHROW(OC_EBADURL);
}
- if(userpwd) *userpwd = combinecredentials(parsed->user,parsed->password);
+ if(user)
+ *user = parsed->user;
+ if(pwd)
+ *pwd = parsed->password;
ncurifree(parsed);
return OC_NOERR;
}
@@ -85,24 +116,40 @@ occombinehostport(const NCURI* uri)
return hp;
}
+#if 0
+/*
+Combine user and pwd into the user:pwd form.
+Note that we must %xx escape the user and the pwd
+*/
static char*
combinecredentials(const char* user, const char* pwd)
{
int userPassSize;
char *userPassword;
+ char *escapeduser = NULL;
+ char* escapedpwd = NULL;
- if(user == NULL) user = "";
- if(pwd == NULL) pwd = "";
-
- userPassSize = strlen(user) + strlen(pwd) + 2;
+ if(user == NULL || pwd == NULL)
+ return NULL;
+
+ userPassSize = 3*strlen(user) + 3*strlen(pwd) + 2; /* times 3 for escapes */
userPassword = malloc(sizeof(char) * userPassSize);
if (!userPassword) {
nclog(NCLOGERR,"Out of Memory\n");
return NULL;
}
- occopycat(userPassword,userPassSize-1,3,user,":",pwd);
+ escapeduser = ncuriencodeuserpwd(user);
+ escapedpwd = ncuriencodeuserpwd(pwd);
+ if(escapeduser == NULL || escapedpwd == NULL) {
+ nclog(NCLOGERR,"Out of Memory\n");
+ return NULL;
+ }
+ occopycat(userPassword,userPassSize-1,3,escapeduser,":",escapedpwd);
+ free(escapeduser);
+ free(escapedpwd);
return userPassword;
}
+#endif
static int
rcreadline(FILE* f, char* more, int morelen)
@@ -158,7 +205,7 @@ ocparseproxy(OCstate* state, char* v)
return OC_NOERR; /* nothing there*/
if (occredentials_in_url(v)) {
char *result_url = NULL;
- ocextract_credentials(v, &state->proxy.userpwd, &result_url);
+ ocextract_credentials(v, &state->proxy.user, &state->proxy.pwd, &result_url);
v = result_url;
}
/* allocating a bit more than likely needed ... */
@@ -208,7 +255,7 @@ ocparseproxy(OCstate* state, char* v)
if (ocdebug > 1) {
nclog(NCLOGNOTE,"host name: %s", state->proxy.host);
#ifdef INSECURE
- nclog(NCLOGNOTE,"user+pwd: %s", state->proxy.userpwd);
+ nclog(NCLOGNOTE,"user+pwd: %s+%s", state->proxy.user,state->proxy.pwd);
#endif
nclog(NCLOGNOTE,"port number: %d", state->proxy.port);
}
@@ -373,8 +420,8 @@ ocrc_load(void)
/* locate the configuration files in the following order:
1. specified by set_rcfile
2. set by DAPRCFILE env variable
- 3. '.'
- 4. $HOME
+ 3. '.'/<rcfile>
+ 4. $HOME/<rcfile>
*/
if(ocglobalstate.rc.rcfile != NULL) { /* always use this */
path = strdup(ocglobalstate.rc.rcfile);
@@ -416,7 +463,6 @@ ocrc_process(OCstate* state)
OCerror stat = OC_NOERR;
char* value = NULL;
NCURI* uri = state->uri;
- char* url_userpwd = NULL;
char* url_hostport = NULL;
if(!ocglobalstate.initialized)
@@ -428,7 +474,6 @@ ocrc_process(OCstate* state)
to getinfo e.g. user:pwd from url
*/
- url_userpwd = combinecredentials(uri->user,uri->password);
url_hostport = occombinehostport(uri);
if(url_hostport == NULL)
return OC_ENOMEM;
@@ -545,21 +590,28 @@ ocrc_process(OCstate* state)
{ /* Handle various cases for user + password */
/* First, see if the user+pwd was in the original url */
- char* userpwd = NULL;
char* user = NULL;
char* pwd = NULL;
- if(url_userpwd != NULL)
- userpwd = url_userpwd;
- else {
+ if(uri->user != NULL && uri->password != NULL) {
+ user = uri->user;
+ pwd = uri->password;
+ } else {
user = ocrc_lookup("HTTP.CREDENTIALS.USER",url_hostport);
pwd = ocrc_lookup("HTTP.CREDENTIALS.PASSWORD",url_hostport);
- userpwd = ocrc_lookup("HTTP.CREDENTIALS.USERPASSWORD",url_hostport);
}
- if(userpwd == NULL && user != NULL && pwd != NULL) {
- userpwd = combinecredentials(user,pwd);
- state->creds.userpwd = userpwd;
- } else if(userpwd != NULL)
- state->creds.userpwd = strdup(userpwd);
+ if(user != NULL && pwd != NULL) {
+ state->creds.user = strdup(user);
+ state->creds.pwd = strdup(pwd);
+ } else {
+ /* Could not get user and pwd, so try USERPASSWORD */
+ const char* userpwd = ocrc_lookup("HTTP.CREDENTIALS.USERPASSWORD",url_hostport);
+ if(userpwd != NULL) {
+ stat = parsecredentials(userpwd,&user,&pwd);
+ if(stat) goto done;
+ state->creds.user = user;
+ state->creds.pwd = pwd;
+ }
+ }
}
done:
@@ -624,7 +676,7 @@ storedump(char* msg, struct OCTriple* triples, int ntriples)
if(ntriples < 0 ) ntriples= ocrc->ntriples;
for(i=0;i<ntriples;i++) {
fprintf(stderr,"\t%s\t%s\t%s\n",
- (strlen(triples[i].host)==0?"--":triples[i].host),
+ (triples[i].host == NULL || strlen(triples[i].host)==0?"--":triples[i].host),
triples[i].key,
triples[i].value);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/netcdf.git
More information about the Pkg-grass-devel
mailing list