[netcdf] 01/07: Imported Upstream version 4.4.0~rc4

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Wed Nov 11 21:37:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository netcdf.

commit d48c02fcebf4a16d0086807c4ea2ad5b6b1e37eb
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed Nov 11 22:10:17 2015 +0100

    Imported Upstream version 4.4.0~rc4
---
 .travis.yml                                     |    45 +-
 CMakeLists.txt                                  |    88 +-
 Doxyfile.developer                              |     4 +-
 Makefile.am                                     |    15 +
 Makefile.in                                     |    17 +
 RELEASE_NOTES.md                                |    53 +-
 cf                                              |   121 +-
 cf.cmake                                        |    12 +-
 config.h.cmake.in                               |     1 +
 config.h.in                                     |    42 +-
 configure                                       |   795 +-
 configure.ac                                    |   249 +-
 docs/.gitignore                                 |     3 +-
 docs/CMakeLists.txt                             |    23 +-
 docs/Doxyfile.in                                |     5 +-
 docs/Makefile.am                                |    20 +-
 docs/Makefile.in                                |    23 +-
 docs/OPeNDAP.dox                                |     4 +-
 oc2/ocauth.html => docs/auth.html               |   196 +-
 docs/auth.md                                    |   489 -
 docs/auth.md.in                                 |    14 -
 docs/cmake_faq.md                               |    47 +-
 docs/esg.html                                   |     1 +
 docs/file_format_specifications.md              |     4 +-
 docs/guide.dox                                  |    39 +-
 docs/images/Makefile.in                         |     3 +
 docs/internal.dox                               |     2 +-
 docs/netcdf.m4                                  |    94 +-
 docs/ocauth.md                                  |   475 -
 docs/old/netcdf-cxx4.texi                       |     2 +-
 docs/old/netcdf-f77.texi                        |     6 +-
 docs/old/netcdf-f90.texi                        |     6 +-
 docs/old/netcdf-install.texi                    |     4 +-
 docs/old/netcdf-internal.texi                   |    16 +-
 docs/old/netcdf.texi                            |    10 +-
 docs/software.md                                |     4 +-
 docs/tutorial.dox                               |     2 +-
 docs/types.dox                                  |     2 +-
 docs/windows-binaries.md                        |    26 +-
 dods.m4                                         |     2 +-
 examples/C/Makefile.am                          |     7 +-
 examples/C/Makefile.in                          |    63 +-
 examples/C/parallel_vara.c                      |   191 +
 examples/C/quick_large_files.c                  |     2 +-
 examples/CDL/Makefile.in                        |     3 +
 examples/Makefile.in                            |     3 +
 extra.css                                       |    29 -
 h5_test/Makefile.am                             |     2 +-
 h5_test/Makefile.in                             |     9 +-
 include/Makefile.in                             |     3 +
 include/err_macros.h                            |    12 +
 include/nc3internal.h                           |     9 +-
 include/nc4internal.h                           |     4 +-
 include/nc_tests.h                              |     6 +
 include/ncconfigure.h                           |     4 +
 include/ncdispatch.h                            |    90 +-
 include/netcdf.h                                |    67 +-
 include/utf8proc.h                              |     2 +-
 libdap2/Makefile.in                             |     3 +
 libdap2/dceconstraints.c                        |     4 +-
 libdap2/ncd2dispatch.c                          |    10 +-
 libdispatch/Makefile.in                         |     3 +
 libdispatch/dcopy.c                             |     8 +-
 libdispatch/ddim.c                              |     2 +-
 libdispatch/ddispatch.c                         |    65 +-
 libdispatch/derror.c                            |    12 +
 libdispatch/dfile.c                             |   242 +-
 libdispatch/dparallel.c                         |     3 -
 libdispatch/dsubstrate.c                        |     7 +-
 libdispatch/dutf8proc.c                         |     4 +-
 libdispatch/dv2i.c                              |    48 +-
 libdispatch/dvar.c                              |     9 +-
 libdispatch/dvarget.c                           |    19 +-
 libdispatch/dvarput.c                           |    53 +-
 libdispatch/nc.c                                |    14 +-
 libdispatch/ncuri.c                             |     2 +-
 liblib/CMakeLists.txt                           |    39 +-
 liblib/Makefile.am                              |    11 +-
 liblib/Makefile.in                              |    37 +-
 liblib/liblib.c                                 |    15 -
 liblib/nc_initialize.c                          |   122 +
 liblib/stub.c                                   |    80 -
 libnetcdf.settings.in                           |     3 +-
 libsrc/CMakeLists.txt                           |     5 +-
 libsrc/Makefile.in                              |     3 +
 libsrc/attr.c                                   |   724 +-
 libsrc/attr.m4                                  |    59 +-
 libsrc/ffio.c                                   |     8 +-
 libsrc/lookup3.c                                |     6 +-
 libsrc/mmapio.c                                 |     3 +-
 libsrc/nc3dispatch.c                            |    12 +-
 libsrc/nc3dispatch.h                            |   189 +
 libsrc/nc3internal.c                            |   205 +-
 libsrc/ncx.c                                    | 20503 +++++++++++++---------
 libsrc/ncx.h                                    |   810 +-
 libsrc/ncx.m4                                   |  2180 +--
 libsrc/posixio.c                                |    10 +-
 libsrc/pstdint.h                                |     2 +-
 libsrc/putget.c                                 |  6126 ++++++-
 libsrc/putget.m4                                |   872 +-
 libsrc/v1hpg.c                                  |   190 +-
 libsrc/var.c                                    |    13 +-
 libsrc4/Makefile.in                             |     3 +
 libsrc4/nc4dim.c                                |     2 +-
 libsrc4/nc4dispatch.c                           |     8 +-
 libsrc4/nc4file.c                               |    60 +-
 libsrc4/nc4hdf.c                                |    18 +-
 libsrc4/nc4var.c                                |     8 +-
 libsrc4/ncfunc.c                                |     4 +-
 libsrcp/Makefile.in                             |     3 +
 libsrcp/ncpdispatch.c                           |   681 +-
 ljna                                            |    33 -
 nc_test/CMakeLists.txt                          |     2 +
 nc_test/Make0                                   |    32 +-
 nc_test/Makefile.am                             |    10 +-
 nc_test/Makefile.in                             |    55 +-
 nc_test/large_files.c                           |    10 +-
 nc_test/nc_sync.c                               |     2 +-
 nc_test/nc_test.c                               |    95 +-
 nc_test/quick_large_files.c                     |     2 +-
 nc_test/run_pnetcdf_test.sh                     |     3 +
 nc_test/t_nc.c                                  |    49 +-
 nc_test/{t_nc.c => t_nc_p5.c}                   |    38 +-
 nc_test/test_get.c                              | 14777 +++++++---------
 nc_test/test_get.m4                             |    54 +-
 nc_test/test_get_p5.c                           | 19215 ++++++++++++++++++++
 nc_test/{test_get.m4 => test_get_p5.m4}         |    74 +-
 nc_test/test_put.c                              | 15950 +++++++----------
 nc_test/test_put.m4                             |   156 +-
 nc_test/test_read.c                             |   134 +-
 nc_test/test_write.c                            |   147 +-
 nc_test/tests.h                                 |   143 +-
 nc_test/tst_addvar.c                            |    84 +
 nc_test/tst_atts.c                              |    36 +-
 nc_test/tst_atts3.c                             |   136 +-
 nc_test/tst_cdf5format.c                        |   228 +
 nc_test/tst_diskless3.c                         |    70 +-
 nc_test/tst_formatx_pnetcdf.c                   |    45 +-
 nc_test/tst_meta.c                              |     1 +
 nc_test/tst_misc.c                              |    21 +-
 nc_test/tst_names.c                             |    67 +-
 nc_test/tst_nofill.c                            |    18 +-
 nc_test/tst_norm.c                              |    28 +-
 nc_test/tst_small.c                             |   176 +-
 nc_test/util.c                                  |   277 +-
 nc_test4/Makefile.am                            |     8 +-
 nc_test4/Makefile.in                            |    23 +-
 nc_test4/bm_file.c                              |     9 +-
 nc_test4/run_bm.sh                              |     2 +-
 nc_test4/tst_camrun.c                           |    20 +-
 nc_test4/tst_chunks.c                           |    38 +
 nc_test4/tst_converts.c                         |     4 +-
 nc_test4/tst_create_files.c                     |    12 +-
 nc_test4/tst_files.c                            |    10 +-
 nc_test4/tst_h4_lendian.c                       |     4 +-
 nc_test4/tst_large.c                            |    12 +-
 nc_test4/tst_large2.c                           |    13 +-
 nc_test4/tst_large3.c                           |    10 +-
 nc_test4/tst_large5.c                           |    10 +-
 nc_test4/tst_rename.c                           |     2 +-
 nc_test4/tst_types.c                            |     8 +-
 nc_test4/tst_vars.c                             |     2 +-
 nc_test4/tst_vars2.c                            |     8 +-
 nc_test4/tst_vars3.c                            |     2 +-
 ncdap.m4                                        |   197 -
 ncdap_test/Makefile.in                          |     3 +
 ncdap_test/expected3/Makefile.in                |     3 +
 ncdap_test/expected4/Makefile.in                |     3 +
 ncdap_test/expectremote3/Makefile.in            |     3 +
 ncdap_test/expectremote4/Makefile.in            |     3 +
 ncdap_test/t_ncf330.c                           |    20 +-
 ncdap_test/testdata3/Makefile.in                |     3 +
 ncdump/CMakeLists.txt                           |    12 +-
 ncdump/Makefile.am                              |    14 +-
 ncdump/Makefile.in                              |    53 +-
 ncdump/cdl/Makefile.in                          |     3 +
 ncdump/chunkspec.c                              |     2 +-
 ncdump/ctests.sh                                |     2 +-
 ncdump/dumplib.c                                |    98 +-
 ncdump/expected/Makefile.in                     |     3 +
 ncdump/nccopy.c                                 |    38 +-
 ncdump/ncdump.c                                 |    42 +-
 ncdump/nctime0.c                                |     2 +-
 ncdump/run_utf8_nc4_tests.sh                    |    18 +
 ncdump/run_utf8_tests.sh                        |     7 -
 ncdump/tst_64bit.sh                             |    19 +-
 ncdump/tst_formatx3.sh                          |    11 +-
 ncdump/{tst_inmemory.sh => tst_inmemory_nc3.sh} |     3 -
 ncdump/{tst_inmemory.sh => tst_inmemory_nc4.sh} |    10 +-
 ncdump/tst_lengths.sh                           |    60 +
 ncdump/vardata.c                                |     2 +-
 ncgen/ConvertUTF.h                              |     2 +-
 ncgen/Makefile.am                               |     4 +-
 ncgen/Makefile.in                               |     7 +-
 ncgen/c0.cdl                                    |     3 +-
 ncgen3/c0.cdl => ncgen/c5.cdl                   |    72 +-
 ncgen/escapes.c                                 |     2 +-
 ncgen/genc.c                                    |     6 +-
 ncgen/genchar.c                                 |     4 +-
 ncgen/generate.c                                |     8 +-
 ncgen/generr.c                                  |    16 +
 ncgen/genlib.h                                  |     9 +-
 ncgen/main.c                                    |   116 +-
 ncgen/ncgen.1                                   |    18 +-
 ncgen/ncgen.h                                   |     2 +-
 ncgen/ncgen.l                                   |   461 +-
 ncgen/ncgen.y                                   |    28 +-
 ncgen/ncgentab.c                                |    28 +-
 ncgen/ncgenyy.c                                 |  1786 +-
 ncgen/run_tests.sh                              |    21 +
 ncgen/semantics.c                               |    11 +-
 ncgen3/Makefile.in                              |     3 +
 ncgen3/c0.cdl                                   |     3 +-
 ncgen3/escapes.c                                |     2 +-
 ncgen3/genlib.c                                 |     2 +-
 ncgen3/main.c                                   |     4 +-
 ncgen3/run_nc4_tests.sh                         |     4 +
 ncgen3/run_tests.sh                             |     5 +
 nctest/CMakeLists.txt                           |    18 +-
 nctest/Makefile.in                              |     3 +
 nctest/atttests.c                               |     2 +-
 nctest/compare_test_files.sh                    |     7 +-
 nctest/driver.c                                 |     8 +-
 nctest/ref_nctest_64bit_offset.nc               |   Bin 43504 -> 43696 bytes
 nctest/ref_nctest_classic.nc                    |   Bin 43392 -> 43584 bytes
 nctest/varputg.c                                |     2 +-
 nctest/vartests.c                               |     4 +-
 nctest/vputget.c                                |     4 +-
 nctest/vputgetg.c                               |     8 +-
 oc2/Make0                                       |     2 +-
 oc2/Makefile.am                                 |     2 +-
 oc2/Makefile.in                                 |     5 +-
 oc2/{ocauth.html => auth.html.in}               |   216 +-
 oc2/daplex.c                                    |    28 +-
 oc2/daptab.c                                    |   251 +-
 oc2/daptab.h                                    |     2 +-
 oc2/oc.css                                      |    39 +
 oc2/oc.h                                        |     2 +-
 oc2/occurlflags.c                               |     6 +-
 oc2/occurlfunctions.c                           |    26 +-
 oc2/ochttp.c                                    |     4 +-
 oc2/ocinternal.c                                |     9 +-
 oc2/ocrc.c                                      |     6 +-
 oc2/ocuri.c                                     |     2 +-
 244 files changed, 59423 insertions(+), 33851 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 0a61082..5c0001b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,25 +1,52 @@
+sudo: false
 language: c
 compiler:
   - gcc
   - clang
 
+addons:
+    apt:
+      packages:
+      - libcurl4-openssl-dev
+      - m4
+      - wget
+      - autoconf
+      - libtool
+      - gfortran
+      - git
+      - doxygen
+      - graphviz
+
 before_install:
-  - sudo apt-get update -qq
-  - sudo apt-get install -y -qq libcurl4-openssl-dev m4 wget autoconf libtool clang libjpeg8-dev
+
+before_script:
 
   ###
   # Install dependencies from a pre-built binary.
   ###
-  - cd /
-  - sudo wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/travisdeps.tar.bz2
-  - sudo tar -jxf travisdeps.tar.bz2
+  - cd $HOME
+  - wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/travisdeps.tar.bz2
+
+  - tar -jxf travisdeps.tar.bz2
+  - export LD_LIBRARY_PATH=$HOME/usr/lib
+  - export PATH=$HOME/usr/bin:$PATH
   - cd -
 
-before_script:
-  - mkdir build
-  - cd build
-  - cmake .. -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON
+  - mkdir build-all
+  - mkdir build-min
+
+  - cd build-min
+  - cmake .. -DENABLE_NETCDF_4=OFF -DENABLE_DAP=OFF -DCMAKE_PREFIX_PATH=$HOME/usr-min
+  - cd ..
+
+  - cd build-all
+  - cmake .. -DENABLE_MMAP=ON -DENABLE_DOXYGEN=ON -DENABLE_EXTRA_TESTS=ON -DENABLE_HDF4=ON -DCMAKE_PREFIX_PATH=$HOME/usr
+  - cd ..
 
 script:
+  - cd build-min
   - make -j 4
   - make test
+  - cd ../build-all
+  - make -j 4
+  - make test
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6cc03a..273d3e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,12 +1,13 @@
 ## This is a CMake file, part of Unidata's netCDF package.
 # Copyright 2012-2014, see the COPYRIGHT file for more information.
+#
 
 ##################################
 # Set Project Properties
 ##################################
 
 #Minimum required CMake Version
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 2.8.11)
 
 #Project Name
 project(netCDF C)
@@ -26,7 +27,7 @@ set(PACKAGE "netCDF" CACHE STRING "")
 SET(NC_VERSION_MAJOR 4)
 SET(NC_VERSION_MINOR 4)
 SET(NC_VERSION_PATCH 0)
-SET(NC_VERSION_NOTE "-rc3")
+SET(NC_VERSION_NOTE "-rc4")
 SET(netCDF_VERSION ${NC_VERSION_MAJOR}.${NC_VERSION_MINOR}.${NC_VERSION_PATCH}${NC_VERSION_NOTE})
 SET(VERSION ${netCDF_VERSION})
 SET(NC_VERSION ${netCDF_VERSION})
@@ -91,6 +92,7 @@ INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
 INCLUDE(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
 INCLUDE(${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
 INCLUDE(${CMAKE_ROOT}/Modules/CheckCSourceCompiles.cmake)
+INCLUDE(${CMAKE_ROOT}/Modules/CheckCSourceRuns.cmake)
 INCLUDE(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
 INCLUDE(${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
 INCLUDE(${CMAKE_ROOT}/Modules/GetPrerequisites.cmake)
@@ -225,7 +227,7 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
 
 ADD_DEFINITIONS()
 
-# Supress CRT Warnings.
+# Suppress CRT Warnings.
 # Only necessary for Windows
 IF(MSVC)
   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
@@ -444,6 +446,7 @@ IF(ENABLE_NETCDF_4)
   SET(USE_NETCDF4 ON CACHE BOOL "")
   SET(ENABLE_NETCDF_4 ON CACHE BOOL "")
   SET(ENABLE_NETCDF4 ON CACHE BOOL "")
+
 ENDIF()
 
 # Option for building RPC
@@ -458,7 +461,7 @@ OPTION(USE_HDF5 "Use HDF5." ${ENABLE_NETCDF_4})
 IF(USE_HDF5 OR ENABLE_NETCDF_4)
   SET(USE_HDF5 ON)
   SET(USE_NETCDF4 ON)
-  # Accomodate developers who have hdf5 libraries and
+  # Accommodate developers who have hdf5 libraries and
   # headers on their system, but do not have a the hdf
   # .cmake files.  If this is the case, they should
   # specify HDF5_HL_LIB, HDF5_LIB, HDF5_INCLUDE_DIR manually.
@@ -652,7 +655,7 @@ ENDIF()
 
 # Check to see if libtool supports
 
-# Check for the math library so it can be explicitely linked.
+# Check for the math library so it can be explicitly linked.
 IF(NOT WIN32)
   FIND_LIBRARY(HAVE_LIBM NAMES math m libm)
   MESSAGE(STATUS "Found Math library: ${HAVE_LIBM}")
@@ -694,6 +697,13 @@ ENDIF()
 
 SET(MATH "")
 IF(NOT WIN32)
+
+  # STDIO instead of posixio.
+  OPTION(ENABLE_STDIO "If true, use stdio instead of posixio (ex. on the Cray)" OFF)
+  IF(ENABLE_STDIO)
+    SET(USE_STDIO ON CACHE BOOL "")
+  ENDIF()
+
   # FFIO insteaad of PosixIO
   OPTION(ENABLE_FFIO "If true, use ffio instead of posixio" OFF)
   IF(ENABLE_FFIO)
@@ -822,13 +832,14 @@ ENDIF()
 
 # Enable Parallel (different than pnetcdf).
 SET(STATUS_PARALLEL "OFF")
-OPTION(ENABLE_PARALLEL "Build netCDF-4 with parallel IO" "${HDF5_IS_PARALLEL}")
-IF(ENABLE_PARALLEL AND ENABLE_NETCDF_4)
+OPTION(ENABLE_PARALLEL4 "Build netCDF-4 with parallel IO" "${HDF5_IS_PARALLEL}")
+IF(ENABLE_PARALLEL4 AND ENABLE_NETCDF_4)
   IF(NOT HDF5_IS_PARALLEL)
     SET(USE_PARALLEL OFF CACHE BOOL "")
     MESSAGE(STATUS "Cannot find HDF5 library built with parallel support. Disabling parallel build.")
   ELSE()
     SET(USE_PARALLEL ON CACHE BOOL "")
+    SET(USE_PARALLEL4 ON CACHE BOOL "")
     SET(STATUS_PARALLEL "ON")
   ENDIF()
 ENDIF()
@@ -836,6 +847,7 @@ ENDIF()
 # Options to enable parallel IO, tests.
 SET(STATUS_PNETCDF "OFF")
 OPTION(ENABLE_PNETCDF "Build with parallel I/O for classic and 64-bit offset files using parallel-netcdf." OFF)
+
 IF(ENABLE_PNETCDF)
   # Check for ncmpi_create in libpnetcdf, define USE_PNETCDF
   # Does the user want to turn on PNETCDF read ability?
@@ -845,14 +857,42 @@ IF(ENABLE_PNETCDF)
   IF(NOT PNETCDF)
     MESSAGE(STATUS "Cannot find pNetCDF library. Disabling pNetCDF support.")
     SET(USE_PNETCDF OFF CACHE BOOL "")
-  ELSE()
-    SET(STATUS_PNETCDF "ON")
-    INCLUDE_DIRECTORIES(${PNETCDF_INCLUDE_DIR})
-    SET(HAVE_LIBPNETCDF ON)
-    # pnetcdf => parallel
-    SET(STATUS_PARALLEL "ON")
-    SET(USE_PARALLEL ON)
-  ENDIF()
+  ELSE(NOT PNETCDF)
+    SET(USE_PARALLEL ON CACHE BOOL "")
+  ENDIF(NOT PNETCDF)
+#  ELSE()
+##	SET(TMP_INC ${CMAKE_REQUIRED_INCLUDES})
+#	SET(TMP_LB ${CMAKE_REQUIRED_LIBRARIES})
+#	SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PNETCDF})
+#	SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PNETCDF_INCLUDE_DIR})
+	# Check to see if version > 1.6.0
+	# CHECK_C_SOURCE_RUNS("
+		#include <stdio.h>
+      		#include <pnetcdf.h>
+    #  		int main() {
+    #  		int major = PNETCDF_VERSION_MAJOR;
+    #  		int minor = PNETCDF_VERSION_MINOR;
+    #  		int version = major*1000 + minor;
+    #  		int ok = (version >= (1*1000 + 6));
+    #  		return ok?0:1;}"
+    #  		HAVE_PNETCDF_16)
+
+#	SET(CMAKE_REQUIRED_INCLUDES ${TMP_INC})
+#	SET(CMAKE_REQUIRED_LIBRARIES ${TMP_LB})
+
+	#IF(HAVE_PNETCDF_16)
+	#	SET(ENABLE_PNETCDF "OFF")
+    #  		MESSAGE(WARNING "ENABLE_PNETCDF requires version 1.6.0 or later; disabled")
+    #	ELSE()
+
+   #	    SET(STATUS_PNETCDF "ON")
+    #	    INCLUDE_DIRECTORIES(${PNETCDF_INCLUDE_DIR})
+    #	    SET(HAVE_LIBPNETCDF ON)
+    	    # pnetcdf => parallel
+    #	    SET(STATUS_PARALLEL "ON")
+    #	    SET(USE_PARALLEL ON)
+  	#ENDIF()
+    #ENDIF()
 ENDIF()
 
 # Enable Parallel Tests.
@@ -883,10 +923,22 @@ IF(ENABLE_DOXYGEN)
     SET(DOXYGEN_CSS_FILE "${CMAKE_SOURCE_DIR}/docs/release.css" CACHE STRING "")
     SET(DOXYGEN_HEADER_FILE "${CMAKE_SOURCE_DIR}/docs/release_header.html" CACHE STRING "")
     SET(DOXYGEN_SEARCHENGINE "NO" CACHE STRING "")
+    SET(ENABLE_DOXYGEN_SERVER_BASED_SEARCH NO CACHE STRING "")
   ELSE()
     SET(DOXYGEN_CSS_FILE "" CACHE STRING "")
     SET(DOXYGEN_HEADER_FILE "" CACHE STRING "")
     SET(DOXYGEN_SEARCHENGINE "YES" CACHE STRING "")
+
+    # If not using release document configuration,
+    # provide an option for server-based search.
+    OPTION(ENABLE_DOXYGEN_SERVER_SIDE_SEARCH "Configure Doxygen with server-based search." OFF)
+    IF(ENABLE_DOXYGEN_SERVER_SIDE_SEARCH)
+      SET(DOXYGEN_SERVER_BASED_SEARCH "YES" CACHE STRING "")
+    ELSE()
+      SET(DOXYGEN_SERVER_BASED_SEARCH "NO" CACHE STRING "")
+    ENDIF(ENABLE_DOXYGEN_SERVER_SIDE_SEARCH)
+
+
   ENDIF(ENABLE_DOXYGEN_BUILD_RELEASE_DOCS)
   # Option to turn on the TODO list in the doxygen-generated documentation.
   OPTION(DOXYGEN_ENABLE_TASKS "Turn on test, todo, bug lists in documentation. This is of interest to developers only." OFF)
@@ -927,9 +979,9 @@ IF(MSVC)
 ENDIF()
 
 # Set some of the options as advanced.
-MARK_AS_ADVANCED(ENABLE_INTERNAL_DOCS VALGRIND_TESTS ENABLE_PNETCDF ENABLE_COVERAGE_TESTS)
+MARK_AS_ADVANCED(ENABLE_INTERNAL_DOCS VALGRIND_TESTS ENABLE_COVERAGE_TESTS )
 MARK_AS_ADVANCED(ENABLE_DAP_REMOTE_TESTS ENABLE_DAP_LONG_TESTS USE_REMOTE_CDASH)
-MARK_AS_ADVANCED(ENABLE_DOXYGEN_BUILD_RELEASE_DOCS DOXYGEN_ENABLE_TASKS)
+MARK_AS_ADVANCED(ENABLE_DOXYGEN_BUILD_RELEASE_DOCS DOXYGEN_ENABLE_TASKS ENABLE_DOXYGEN_SERVER_SIDE_SEARCH)
 ################################
 # Option checks
 ################################
@@ -1154,7 +1206,6 @@ ENDMACRO()
 # Binary tests which are used by a script looking for a specific name.
 MACRO(build_bin_test_no_prefix F)
   build_bin_test(${F})
-  ADD_TEST(${F} ${EXECUTABLE_OUTPUT_PATH}/${F})
   IF(MSVC)
     SET_PROPERTY(TEST ${F} PROPERTY FOLDER "tests/")
     SET_TARGET_PROPERTIES(${F} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
@@ -1168,7 +1219,6 @@ ENDMACRO()
 
 MACRO(add_bin_test prefix F)
   ADD_EXECUTABLE(${prefix}_${F} ${F}.c)
-
   TARGET_LINK_LIBRARIES(${prefix}_${F}
     ${ALL_TLL_LIBS}
     netcdf
diff --git a/Doxyfile.developer b/Doxyfile.developer
index 127d14c..b49d91d 100755
--- a/Doxyfile.developer
+++ b/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.4.0-rc3
+PROJECT_NUMBER         = 4.4.0-rc4
 
 # 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
@@ -1977,7 +1977,7 @@ PREDEFINED             =
 EXPAND_AS_DEFINED      =
 
 # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
-# remove all refrences to function-like macros that are alone on a line, have an
+# remove all references to function-like macros that are alone on a line, have an
 # all uppercase name, and do not end with a semicolon. Such function macros are
 # typically used for boiler-plate code, and will confuse the parser if not
 # removed.
diff --git a/Makefile.am b/Makefile.am
index 93fb69b..c1e9613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -122,6 +122,21 @@ endif # BUILD_DLL
 settingsdir=$(libdir)
 settings_DATA=libnetcdf.settings
 
+####
+# Provide an entry to rebuild all the m4 generated files
+# List of files to create: WARNING leave off the extension
+####
+
+MM4= ./nc_test/test_put ./nc_test/test_get \
+     ./libsrc/netcdf ./libsrc/putget ./libsrc/ncx \
+     ./libsrc/t_ncxx ./libsrc/attr
+
+mm4::
+	for m in ${MM4} ; do \
+	  b=`basename $$m` ; d=`dirname $$m`;\
+	  pushd $$d; m4 -s $${b}.m4 > $${b}.c ; popd; done
+
+
 #####
 # If ENABLE_FORTRAN was turned on,
 # we have new make targets, build-netcdf-fortran and
diff --git a/Makefile.in b/Makefile.in
index 7ba9d4a..b6fcf12 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -310,6 +310,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -342,6 +343,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -353,6 +355,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -522,6 +525,15 @@ ZIPBINFILES = ${prefix}/include/netcdf.h \
 # install libnetcdf.settings in lib directory.
 settingsdir = $(libdir)
 settings_DATA = libnetcdf.settings
+
+####
+# Provide an entry to rebuild all the m4 generated files
+# List of files to create: WARNING leave off the extension
+####
+MM4 = ./nc_test/test_put ./nc_test/test_get \
+     ./libsrc/netcdf ./libsrc/putget ./libsrc/ncx \
+     ./libsrc/t_ncxx ./libsrc/attr
+
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -1098,6 +1110,11 @@ uninstall-am: uninstall-binSCRIPTS uninstall-pkgconfigDATA \
 .PRECIOUS: Makefile
 
 
+mm4::
+	for m in ${MM4} ; do \
+	  b=`basename $$m` ; d=`dirname $$m`;\
+	  pushd $$d; m4 -s $${b}.m4 > $${b}.c ; popd; done
+
 #####
 # If ENABLE_FORTRAN was turned on,
 # we have new make targets, build-netcdf-fortran and
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 1e42a7a..0f4bb1d 100755
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -7,14 +7,55 @@ This file contains a high-level description of this package's evolution. Release
 
 ## 4.4.0 Released TBD
 
+### 4.4.0-RC4 Released - November 10, 2015
+
+* Added CDM-5 support via new mode flag called NC_64BIT_DATA (alias NC_CDF5).
+
+	Major kudos to Wei-Keng Liao for all the effort he put into getting this to work.
+
+    This cascaded into a number of other changes.
+  
+    1. Renamed libsrcp5 -> libsrcp because pnetcdf can do parallel io for CDF-1, CDF-2 and CDF-5, not just CDF-5.
+    2. Given #1, then the NC_PNETCDF mode flag becomes a subset of NC_MPIIO, so made NC_PNETCDF an alias for NC_MPII.
+    3. NC_FORMAT_64BIT is now deprecated.  Use NC_FORMAT_64BIT_OFFSET.
+
+Further information regarding the CDF-5 file format specifrication may be found here: http://cucis.ece.northwestern.edu/projects/PnetCDF/CDF-5.html
+
+* Modified configure.ac to provide finer control over parallel
+  support. Specifically, add flags for:
+  
+    1. HDF5_PARALLEL when hdf5 library has parallel enabled
+    2. --disable-parallel4 to be used when we do not want
+     netcdf-4 to use parallelism even if hdf5 has it enabled.
+
+
+* Deprecating various extended format flags.
+
+The various extended format flags of the format `NC_FORMAT_FOO` have been refactored into the form `NC_FORMATX_FOO`.  The old flags still exist but have been marked as deprecated and will be removed at some point.  This was done to avoid confusion between the extended format flags and the format flags `NC_FORMAT_CLASSIC`, `NC_FORMAT_64BIT_OFFSET`, etc.  The mapping of deprecated-to-new flags is as follows:
+
+Deprecated | Replaced with
+-----------|-------------
+NC\_FORMAT\_NC3       | NC\_FORMATX\_NC3
+NC\_FORMAT\_NC\_HDF5  | NC\_FORMATX\_NC\_HDF5
+NC\_FORMAT\_NC4       | NC\_FORMATX\_NC4
+NC\_FORMAT\_NC\_HDF4  | NC\_FORMATX\_NC\_HDF4
+NC\_FORMAT\_PNETCDF   | NC\_FORMATX\_PNETCDF
+NC\_FORMAT\_DAP2      | NC\_FORMATX\_DAP2 
+NC\_FORMAT\_DAP4      | NC\_FORMATX\_DAP4
+NC\_FORMAT\_UNDEFINED | NC\_FORMATX\_UNDEFINED
+
+* Reduced minimum cmake version to `2.8.11` from `2.8.12`. This will allow for cmake use on a broader set of popular linux platforms without having to do a custom cmake install.  See https://github.com/Unidata/netcdf-c/issues/135 for more information.
+
+* The documentation section `The Default Chunking Scheme` has been updated with more information.  This lives in the `guide.dox` file in the `docs/` directory, or can be found online in the appropriate location (typically http://www.unidata.ucar.edu/netcdf/docs), once this release has been published.
+
 ### 4.4.0-RC3 2015-10-08
 
 * Addressed an inefficiency in how bytes would be swapped when converting between `LITTLE` and `BIG` ENDIANNESS.  See [NCF-338](https://bugtracking.unidata.ucar.edu/browse/NCF-338) for more information.
+
 * Addressed an issue where an interrupted read on a `POSIX` system would return an error even if errno had been properly set to `EINTR`.  This issue was initially reported by David Knaak at Cray.  More information may be found at [NCF-337](https://bugtracking.unidata.ucar.edu/browse/NCF-337).
+
 * Added a note to the install directions pointing out that parallel make
 cannot be used for 'make check'.
-* Many miscellaneous bug fixes.
-
 
 ### 4.4.0-RC2 Released 2015-07-09
 
@@ -26,7 +67,7 @@ cannot be used for 'make check'.
 
 * Added support for opening in-memory file content. See `include/netcdf_mem.h` for the procedure signature. Basically, it allows one to fill a chunk of memory with the equivalent of some netCDF file and then open it and read from it as if it were any other file. See [NCF-328](https://bugtracking.unidata.ucar.edu/browse/NCF-328) for more information.
 
-* Addressed an issue when reading hdf4 files with explicit little-endian datatypes. This issue was [reported by Tim Burgess at GitHub](https://github.com/Unidata/netcdf-c/issues/113).  See [NCF-332](https://bugtracking.unidata.ucar.edu/browse/NCF-332) for more information.  
+* Addressed an issue when reading hdf4 files with explicit little-endian datatypes. This issue was [reported by Tim Burgess at GitHub](https://github.com/Unidata/netcdf-c/issues/113).  See [NCF-332](https://bugtracking.unidata.ucar.edu/browse/NCF-332) for more information.
 
 * Addressed an issue with IBM's `XL C` compiler on AIX and how it handled some calls to malloc.  Also, as suggested by Wolfgang Hayek, developers using this compiler may need to pass `CPPFLAGS=-D_LINUX_SOURCE_COMPAT` to avoid some test failures.
 
@@ -352,7 +393,7 @@ This is a bug-fix-only release for version 4.3.1.
 
 ### 4.3.1-rc1 Released 2013-08-09
 
-* Migrated from the netCDF-C `subversion` repository to a publically available GitHub repository available at https://github.com/Unidata/netCDF-C.  This repository may be checked out (cloned) with the following command:
+* Migrated from the netCDF-C `subversion` repository to a publicly available GitHub repository available at https://github.com/Unidata/netCDF-C.  This repository may be checked out (cloned) with the following command:
 
 	$ git clone https://github.com/Unidata/netCDF-C.git
 
@@ -393,7 +434,7 @@ This is a bug-fix-only release for version 4.3.1.
 ## 4.3.0 Released 2013-04-29
 
 * fsync: Changed default in autotools config file; fsync must now be
-explicitely enabled instead of explicitely disabled. [NCF-239]
+explicitly enabled instead of explicitly disabled. [NCF-239]
 
 [NCF-239]: https://bugtracking.unidata.ucar.edu/browse/NCF-239
 
@@ -1112,7 +1153,7 @@ Kent.
 * Fixed some cross-compile problems.
 
 * Rewrote code which placed bogus errors on the HDF5 error stack, trying
-to open non-existant attributes and variables. Now no HDF5 errors are
+to open non-existent attributes and variables. Now no HDF5 errors are
 seen.
 
 * Removed man subdirectory. Now man4 subdirectory is used for all builds.
diff --git a/cf b/cf
index abffb78..8594f83 100644
--- a/cf
+++ b/cf
@@ -1,31 +1,34 @@
 #!/bin/bash
-#X="-x"
 #NB=1
 DB=1
+#X=-x
+FAST=1
+#CYGWIN=1
 
-if test $# != 0 ; then
-cmds=$@
-fi
+FAST=1
 
-HDF5=1
-DAP=1
-#HDF4=1
+#HDF5=1
+#DAP=1
 #PNETCDF=1
+#PAR4=1
 
-#PAR=1
+if test $# != 0 ; then
+cmds=$@
+fi
 
-if test "x$PNETCDF" = x1 ; then
-PAR=1
+if test "x$PNETCDF" = x1 -o "x$PAR4" = x1 ; then
+MPIO=1
 fi
 
 #RPC=1
-#PGI=1
+
 #M32=1
 #M64=1
 
 CFLAGS=""
-#CFLAGS="-Wall -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}"
-CFLAGS="-Wall ${CFLAGS}"
+#CFLAGS="-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter -Wconversion ${CFLAGS}"
+CFLAGS="-Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-parameter ${CFLAGS}"
+#CFLAGS="-Wall ${CFLAGS}"
 #CFLAGS="-Wconversion"
 
 stddir="/usr/local"
@@ -46,13 +49,7 @@ if test "x$HDF4" = x1 ; then
 HDF5=1
 fi
 
-# Test pgi compiler
-if test "x$PGI" = x1 ; then
-PATH="/opt/pgi/linux86/11.1/bin:$PATH"
-CC=pgcc
-else
 CC=gcc
-fi
 
 MALLOC_CHECK=""
 
@@ -69,9 +66,7 @@ case "$HOST" in
 	CFLAGS="-std=c99 $CFLAGS"
 	;;
   spock)
-	if test "x$PGI" = x ; then
   	  CFLAGS="-Wdeclaration-after-statement -Wall $CFLAGS"
-	fi
 	;;
   spike)
 	CFLAGS="-Wall $CFLAGS"
@@ -133,25 +128,33 @@ FLAGS="$FLAGS --enable-dap-auth-tests"
 #FLAGS="$FLAGS --enable-valgrind-tests"
 FLAGS="$FLAGS --enable-jna"
 
+if test "x$PAR4" != x1 ; then
+FLAGS="$FLAGS --disable-parallel4"
+fi
+
+if test "x$CYGWIN" = x1 ; then
+FLAGS="$FLAGS --enable-workaround"
+fi
+
 if test "x${DB}" = x1 ; then
 FLAGS="$FLAGS --disable-shared"
 else
 FLAGS="$FLAGS --enable-shared"
 fi
 
-TMP=
-rm -f ./test_mpi.tmp
-if test -f $stddir/lib/libhdf5.a ; then
-  nm $stddir/lib/libhdf5.a | grep mpich_mpi_float$ >./test_mpi.tmp
-else
-  if test -f $stddir/lib/libhdf5.so ; then
-    nm $stddir/lib/libhdf5.so | grep mpich_mpi_float$ >./test_mpi.tmp
-  fi
-fi
-if test -s ./test_mpi.tmp ; then
-  PAR=1
-fi
-rm -f ./test_mpi.tmp
+#TMP=
+#rm -f ./test_mpi.tmp
+#if test -f $stddir/lib/libhdf5.a ; then
+#  nm $stddir/lib/libhdf5.a | grep mpich_mpi_float$ >./test_mpi.tmp
+#else
+#  if test -f $stddir/lib/libhdf5.so ; then
+#    nm $stddir/lib/libhdf5.so | grep mpich_mpi_float$ >./test_mpi.tmp
+#  fi
+#fi
+#if test -s ./test_mpi.tmp ; then
+#  PAR=1
+#fi
+#rm -f ./test_mpi.tmp
 
 if test "x${PAR}" != x ; then
 FLAGS="$FLAGS --enable-parallel"
@@ -166,30 +169,24 @@ fi
 if test "x$DAP" = "x" ; then
 FLAGS="$FLAGS --disable-dap"
 fi
-if test "x$CDMR" = "x1" ; then
-FLAGS="$FLAGS --enable-cdmremote"
-fi
-if test "x$RPC" = "x1" ; then
-FLAGS="$FLAGS --enable-rpc"
-fi
 
-if test "x$PAR" = x1 -o "x$PNETCDF" = x1 ; then
-if test -f /machine/local_mpich2 ; then
-MPI1=/machine/local_mpich2
-MPI2=/machine/local_par7
-MPI3=/machine/local_par
-else
-MPI1=/usr/local
-MPI2=${MPI1}
-MPI3=${MPI1}
-fi
-PATH=${PATH}:${MPI1}/bin
-CC="${MPI1}/bin/mpicc"
-CPPFLAGS="-I${MPI2}/include -I${MPI1}/include -I${MPI3}/include"
-LDFLAGS="-L${MPI2}/lib -L${MPI1}/lib -L${MPI3}/lib"
-LDLIBS="-lmpich"
-FLAGS="$FLAGS --enable-pnetcdf"
-FLAGS="$FLAGS --enable-parallel-tests"
+if test "x$MPIO" = x1 ; then
+  if test -f /machine/local_mpich2 ; then
+    MPI1=/machine/local_mpich2
+    MPI2=/machine/local_par7
+    MPI3=/machine/local_par
+  else
+    MPI1=/usr/local
+    MPI2=${MPI1}
+    MPI3=${MPI1}
+  fi
+  PATH=${PATH}:${MPI1}/bin
+  CC="${MPI1}/bin/mpicc"
+  CPPFLAGS="-I${MPI2}/include -I${MPI1}/include -I${MPI3}/include"
+  LDFLAGS="-L${MPI2}/lib -L${MPI1}/lib -L${MPI3}/lib"
+  LDLIBS="-lmpich"
+  FLAGS="$FLAGS --enable-pnetcdf"
+  FLAGS="$FLAGS --enable-parallel-tests"
 fi
 
 #FLAGS="${FLAGS} --enable-stdio"
@@ -206,12 +203,16 @@ export CXXFLAGS
 DISTCHECK_CONFIGURE_FLAGS="$FLAGS"
 export DISTCHECK_CONFIGURE_FLAGS
 
-if test -z "$NB" ; then
+if test "x$NB" != x -o "x$FAST" = x ; then
 ${MAKE} maintainer-clean >/dev/null 2>&1
-if autoreconf -i --force ; then ok=1; else exit ; fi
+fi
+if test -z "$NB" ; then
+  if autoreconf -i --force ; then ok=1; else exit ; fi
 fi
 
-if test -f Makefile ; then ${MAKE} distclean >/dev/null 2>&1 ; fi
+if test -z "$FAST" ; then
+  if test -f Makefile ; then ${MAKE} distclean >/dev/null 2>&1 ; fi
+fi
 sh $X ./configure ${FLAGS}
 for c in $cmds; do
 printenv LD_LIBRARY_PATH
diff --git a/cf.cmake b/cf.cmake
index 1267498..92358dc 100644
--- a/cf.cmake
+++ b/cf.cmake
@@ -3,12 +3,14 @@ mkdir build
 cd build
 UL=/usr/local
 PPATH="$UL"
+ZLIB="-DZLIB_LIBRARY=${UL}/lib/libz.so  -DZLIB_INCLUDE_DIR=${UL}/include"
 HDF5="-DHDF5_LIB=${UL}/lib/libhdf5.so -DHDF5_HL_LIB=${UL}/lib/libhdf5_hl.so -DHDF5_INCLUDE_DIR=${UL}/include"
+CURL="-DCURL_LIBRARY=${UL}/lib/libcurl.so  -DCURL_INCLUDE_DIR=${UL}/include"
 FLAGS="-DCMAKE_PREFIX_PATH=$PPATH"
 FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=${UL}"
-FLAGS="$FLAGS -DCMAKE_PREFIX_PATH="$PPATH"
-FLAGS="$FLAGS -DENABLE_DAP_REMOTE_TESTS=true
+FLAGS="$FLAGS -DCMAKE_PREFIX_PATH=$PPATH"
+FLAGS="$FLAGS -DENABLE_DAP_REMOTE_TESTS=true"
 FLAGS="$FLAGS -DENABLE_DAP_AUTH_TESTS=true"
-cmake $FLAGS ${HDF5} ..
-cmake --build .
-make test
+cmake $FLAGS ${ZLIB} ${HDF5} ${CURL} ..
+#cmake --build .
+#cmake --build . --target test
diff --git a/config.h.cmake.in b/config.h.cmake.in
index 07db7b5..a1c5948 100644
--- a/config.h.cmake.in
+++ b/config.h.cmake.in
@@ -90,6 +90,7 @@ are set when opening a binary file on Windows. */
 #cmakedefine USE_PARALLEL_MPIO 1
 #cmakedefine HDF5_HAS_H5FREE 1
 #cmakedefine USE_PARALLEL 1
+#cmakedefine USE_PARALLEL4 1
 #cmakedefine USE_PNETCDF 1
 #cmakedefine USE_MMAP 1
 #cmakedefine TEST_PARALLEL ${TEST_PARALLEL}
diff --git a/config.h.in b/config.h.in
index 5c5fb4c..4ec5c5f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -6,9 +6,6 @@
 /* If true, will attempt to download and build netcdf-fortran. */
 #undef BUILD_FORTRAN
 
-/* if true, build RPC Client and Server */
-#undef BUILD_RPC
-
 /* default file chunk cache nelems. */
 #undef CHUNK_CACHE_NELEMS
 
@@ -143,6 +140,9 @@
 /* Define to 1 if you have the <hdf5.h> header file. */
 #undef HAVE_HDF5_H
 
+/* Define to 1 if the system has the type `int64'. */
+#undef HAVE_INT64
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -311,12 +311,21 @@
 /* Define to 1 if the system has the type `uchar'. */
 #undef HAVE_UCHAR
 
+/* Define to 1 if the system has the type `uint'. */
+#undef HAVE_UINT
+
+/* Define to 1 if the system has the type `uint64'. */
+#undef HAVE_UINT64
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
 /* Define to 1 if the system has the type `unsigned long long int'. */
 #undef HAVE_UNSIGNED_LONG_LONG_INT
 
+/* Define to 1 if the system has the type `ushort'. */
+#undef HAVE_USHORT
+
 /* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
@@ -327,6 +336,9 @@
    nc4file. */
 #undef HDF5_HAS_H5FREE
 
+/* if true, hdf5 has parallelism enabled */
+#undef HDF5_PARALLEL
+
 /* if true, include JNA bug fix */
 #undef JNA
 
@@ -396,12 +408,30 @@
 /* The size of `off_t', as computed by sizeof. */
 #undef SIZEOF_OFF_T
 
+/* The size of `ptrdiff_t', as computed by sizeof. */
+#undef SIZEOF_PTRDIFF_T
+
 /* The size of `short', as computed by sizeof. */
 #undef SIZEOF_SHORT
 
 /* The size of `size_t', as computed by sizeof. */
 #undef SIZEOF_SIZE_T
 
+/* The size of `uint', as computed by sizeof. */
+#undef SIZEOF_UINT
+
+/* The size of `unsigned int', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_INT
+
+/* The size of `unsigned long long', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_LONG_LONG
+
+/* The size of `unsigned short int', as computed by sizeof. */
+#undef SIZEOF_UNSIGNED_SHORT_INT
+
+/* The size of `ushort', as computed by sizeof. */
+#undef SIZEOF_USHORT
+
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at runtime.
@@ -419,9 +449,6 @@
 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
 #undef TIME_WITH_SYS_TIME
 
-/* if true, build CDMREMOTE Client */
-#undef USE_CDMREMOTE
-
 /* if true, build DAP Client */
 #undef USE_DAP
 
@@ -459,6 +486,9 @@
 /* if true, pnetcdf or parallel netcdf-4 is in use */
 #undef USE_PARALLEL
 
+/* if true, parallel netcdf-4 is in use */
+#undef USE_PARALLEL4
+
 /* if true, compile in parallel netCDF-4 based on MPI/IO */
 #undef USE_PARALLEL_MPIO
 
diff --git a/configure b/configure
index 9a1a04e..c67399e 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.4.0-rc3.
+# Generated by GNU Autoconf 2.69 for netCDF 4.4.0-rc4.
 #
 # 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.4.0-rc3'
-PACKAGE_STRING='netCDF 4.4.0-rc3'
+PACKAGE_VERSION='4.4.0-rc4'
+PACKAGE_STRING='netCDF 4.4.0-rc4'
 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_PARALLEL4
 NC_HAS_PARALLEL
 NC_HAS_PNETCDF
 NC_HAS_JNA
@@ -650,6 +651,7 @@ NC_HAS_HDF4
 NC_HAS_NC4
 NC_HAS_NC2
 NC_VERSION
+NOUNDEFINED
 AM_LDFLAGS
 AM_CPPFLAGS
 AM_CFLAGS
@@ -658,6 +660,7 @@ enable_shared
 HAS_JNA
 HAS_MMAP
 HAS_DISKLESS
+HAS_PARALLEL4
 HAS_PARALLEL
 HAS_SZLIB
 HAS_HDF5
@@ -673,10 +676,6 @@ BUILD_MMAP_FALSE
 BUILD_MMAP_TRUE
 BUILD_DISKLESS_FALSE
 BUILD_DISKLESS_TRUE
-BUILD_RPC_FALSE
-BUILD_RPC_TRUE
-BUILD_CDMREMOTE_FALSE
-BUILD_CDMREMOTE_TRUE
 USE_DISPATCH_FALSE
 USE_DISPATCH_TRUE
 USE_PNETCDF_FALSE
@@ -713,8 +712,8 @@ USE_DAP_FALSE
 USE_DAP_TRUE
 BUILD_DAP_FALSE
 BUILD_DAP_TRUE
-TEST_PARALLEL_FALSE
-TEST_PARALLEL_TRUE
+TEST_PARALLEL4_FALSE
+TEST_PARALLEL4_TRUE
 BUILD_PARALLEL_FALSE
 BUILD_PARALLEL_TRUE
 ALLOCA
@@ -907,7 +906,6 @@ enable_dynamic_loading
 enable_hdf4
 enable_hdf4_file_tests
 enable_fortran
-enable_pnetcdf
 enable_extra_example_tests
 enable_parallel_tests
 with_default_chunk_size
@@ -917,7 +915,6 @@ with_chunk_cache_size
 with_chunk_cache_nelems
 with_chunk_cache_preemption
 enable_logging
-enable_cdmremote
 enable_dap
 enable_dependency_tracking
 enable_dap_remote_tests
@@ -946,6 +943,8 @@ enable_libtool_lock
 enable_largefile
 enable_diskless
 enable_mmap
+enable_parallel4
+enable_pnetcdf
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1497,7 +1496,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.4.0-rc3 to adapt to many kinds of systems.
+\`configure' configures netCDF 4.4.0-rc4 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1568,7 +1567,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of netCDF 4.4.0-rc3:";;
+     short | recursive ) echo "Configuration of netCDF 4.4.0-rc4:";;
    esac
   cat <<\_ACEOF
 
@@ -1600,8 +1599,9 @@ Optional Features:
   --enable-jna            enable jna bug workaround
   --enable-valgrind-tests build with valgrind-tests (valgrind is required,
                           static builds only)
-  --enable-netcdf-4       build with netcdf-4 (HDF5 and zlib required)
-  --enable-netcdf4        (just a synonym for enable-netcdf-4)
+  --disable-netcdf-4      do not build with netcdf-4 (else HDF5 and zlib
+                          required)
+  --disable-netcdf4       (just a synonym for --disable-netcdf-4)
   --enable-dynamic-loading
                           enable dynamic loading for use with supported hdf5
                           installs (libdl, HDF5 required)
@@ -1612,8 +1612,6 @@ Optional Features:
                           that they can be read
   --enable-remote-fortran-bootstrap
                           Download and install netcdf-fortran (EXPERIMENTAL)
-  --enable-pnetcdf        build with parallel I/O for classic and 64-bit
-                          offset files using parallel-netcdf
   --enable-extra-example-tests
                           Run extra example tests; requires GNU sed. Ignored
                           if netCDF-4 is not enabled.
@@ -1624,7 +1622,6 @@ Optional Features:
                           netCDF-4 is built). This debugging features is only
                           of interest to netCDF developers. Ignored if
                           netCDF-4 is not enabled.
-  --enable-cdmremote      build with cdmremote client support.
   --disable-dap           build without DAP client support.
   --enable-dependency-tracking
                           do not reject slow dependency extractors
@@ -1666,6 +1663,9 @@ Optional Features:
   --disable-largefile     omit support for large files
   --disable-diskless      disable support for in-memory (NC_DISKLESS) files
   --enable-mmap           allow mmap for in-memory files
+  --disable-parallel4     disable parallel I/O for netcdf-4, even if it's
+                          enabled in libhdf5
+  --enable-pnetcdf        build with parallel I/O for classic files
   --enable-jna            enable jna bug fix
 
 Optional Packages:
@@ -1784,7 +1784,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-netCDF configure 4.4.0-rc3
+netCDF configure 4.4.0-rc4
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2493,7 +2493,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.4.0-rc3, which was
+It was created by netCDF $as_me 4.4.0-rc4, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2848,7 +2848,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
  NC_VERSION_MAJOR=4
  NC_VERSION_MINOR=4
  NC_VERSION_PATCH=0
- NC_VERSION_NOTE="-rc3"
+ NC_VERSION_NOTE="-rc4"
 
 #####
 # Set some variables used to generate a libnetcdf.settings file,
@@ -2857,11 +2857,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 # Create the VERSION file, which contains the package version from
 # AC_INIT.
-echo 4.4.0-rc3>VERSION
+echo 4.4.0-rc4>VERSION
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: netCDF 4.4.0-rc3" >&5
-$as_echo "$as_me: netCDF 4.4.0-rc3" >&6;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: netCDF 4.4.0-rc4" >&5
+$as_echo "$as_me: netCDF 4.4.0-rc4" >&6;}
 
 # Keep libtool macros in an m4 directory.
 
@@ -3502,7 +3502,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='netcdf'
- VERSION='4.4.0-rc3'
+ VERSION='4.4.0-rc4'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3824,27 +3824,27 @@ test "x$enable_valgrind_tests" = xyes || enable_valgrind_tests=no
 $as_echo "$enable_valgrind_tests" >&6; }
 
 # Does the user want to build netcdf-4?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we should try to build netCDF-4" >&5
-$as_echo_n "checking whether we should try to build netCDF-4... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we should build netCDF-4" >&5
+$as_echo_n "checking whether we should build netCDF-4... " >&6; }
 # Check whether --enable-netcdf-4 was given.
 if test "${enable_netcdf_4+set}" = set; then :
   enableval=$enable_netcdf_4;
 fi
 
 test "x$enable_netcdf_4" = xno || enable_netcdf_4=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_netcdf_4" >&5
-$as_echo "$enable_netcdf_4" >&6; }
 
 # Synonym
-# --enable-netcdf-4 is the controlling enable switch
-if test "x$enable_netcdf_4" = "x" ; then
-  # Check whether --enable-netcdf4 was given.
+# Check whether --enable-netcdf4 was given.
 if test "${enable_netcdf4+set}" = set; then :
   enableval=$enable_netcdf4;
 fi
 
-  enable_netcdf_4="$enable_netcdf4"
+test "x$enable_netcdf4" = xno || enable_netcdf4=yesi
+if test "x$enable_netcdf4" = xno ; then
+enable_netcdf_4=no
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_netcdf_4" >&5
+$as_echo "$enable_netcdf_4" >&6; }
 
 # Does the user require dynamic loading?
 # This is only for those hdf5 installs that support it.
@@ -3901,18 +3901,6 @@ test "x$enable_remote_fortran_bootstrap" = xyes || enable_remote_fortran_bootstr
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_remote_fortran_bootstrap" >&5
 $as_echo "$enable_remote_fortran_bootstrap" >&6; }
 
-# Does the user want to turn on PNETCDF read ability?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether parallel I/O for classic and 64-bit offset files using parallel-netcdf is to be enabled" >&5
-$as_echo_n "checking whether parallel I/O for classic and 64-bit offset files using parallel-netcdf is to be enabled... " >&6; }
-# Check whether --enable-pnetcdf was given.
-if test "${enable_pnetcdf+set}" = set; then :
-  enableval=$enable_pnetcdf;
-fi
-
-test "x$enable_pnetcdf" = xyes || enable_pnetcdf=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_pnetcdf" >&5
-$as_echo "$enable_pnetcdf" >&6; }
-
 # Does the user want to run extra example tests
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether extra example tests should be run" >&5
 $as_echo_n "checking whether extra example tests should be run... " >&6; }
@@ -4063,20 +4051,6 @@ test "x$enable_logging" = xyes || enable_logging=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_logging" >&5
 $as_echo "$enable_logging" >&6; }
 
-# Capture the state of the --enable-cdmremote flag
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cdmremote client is to be built" >&5
-$as_echo_n "checking whether cdmremote client is to be built... " >&6; }
-# Check whether --enable-cdmremote was given.
-if test "${enable_cdmremote+set}" = set; then :
-  enableval=$enable_cdmremote;
-fi
-
-test "x$enable_cdmremote" = xyes || enable_cdmremote=no
-# CDMREMOTE requires netCDF-4
-if test "x$enable_netcdf_4" = "xno" ; then enable_cdmremote=no ; fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_cdmremote" >&5
-$as_echo "$enable_cdmremote" >&6; }
-
 ## Capture the state of the --enable-dap flag
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether DAP client is to be built" >&5
 $as_echo_n "checking whether DAP client is to be built... " >&6; }
@@ -4089,21 +4063,10 @@ test "x$enable_dap" = xno || enable_dap=yes
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_dap" >&5
 $as_echo "$enable_dap" >&6; }
 
-# OC now has its own version of rpc (really xdr), so no longer need the library
-## Capture the state of the --enable-rpc flag
-#AC_MSG_CHECKING([whether rpc client and server are to be built])
-#AC_ARG_ENABLE([rpc],
-#                 [AS_HELP_STRING([--enable-rpc],
-#                                 [build with rpc client and server support.])])
-#test "x$enable_rpc" = xyes || enable_rpc=no
-#AC_MSG_RESULT($enable_rpc)
-
 # Curl support is required if and only if any of these flags are set:
 # 1. --enable-dap
-# 2. --enable-cdmremote
-# 3. --enable-rpc
 
-if test "x$enable_dap" = "xyes" -o "x$enable_cdmremote" = "xyes" -o "x$enable_rpc" = "xyes" ; then
+if test "x$enable_dap" = "xyes" ; then
 require_curl=yes
 else
 require_curl=no
@@ -5204,8 +5167,6 @@ if test $require_curl = yes ; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: libcurl not found; disabling remote protocol(s) support" >&5
 $as_echo "$as_me: libcurl not found; disabling remote protocol(s) support" >&6;}
     enable_dap=no
-    enable_cdmremote=no
-    enable_rpc=no
   elif test $found_curl = yes ; then
     # Redo the check lib to actually add -lcurl
     #AC_CHECK_LIB([curl], [curl_easy_setopt])
@@ -5341,18 +5302,6 @@ $as_echo "#define ENABLE_DAP_REMOTE_TESTS 1" >>confdefs.h
 
 fi
 
-if test "x$enable_cdmremote" = xyes; then
-
-$as_echo "#define USE_CDMREMOTE 1" >>confdefs.h
-
-fi
-
-if test "x$enable_rpc" = xyes; then
-
-$as_echo "#define BUILD_RPC 1" >>confdefs.h
-
-fi
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the time-consuming dap tests should be enabled (default off)" >&5
 $as_echo_n "checking whether the time-consuming dap tests should be enabled (default off)... " >&6; }
 # Check whether --enable-dap-long-tests was given.
@@ -15977,19 +15926,18 @@ if test "${enable_diskless+set}" = set; then :
 fi
 
 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" -o "x$enable_cdmremote" = "xyes" -o "x$enable_rpc" = "xyes" ; then
+if test "x$enable_dap" = "xyes"; then
 enable_diskless=yes
 { $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;}
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_diskless" >&5
-$as_echo "$enable_diskless" >&6; }
-
-
 # check for useful, but not essential, memio support
 for ac_func in memmove getpagesize sysconf
 do :
@@ -16616,6 +16564,42 @@ _ACEOF
 
 
 fi
+ac_fn_c_check_type "$LINENO" "ushort" "ac_cv_type_ushort" "$ac_includes_default"
+if test "x$ac_cv_type_ushort" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_USHORT 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint" "ac_cv_type_uint" "$ac_includes_default"
+if test "x$ac_cv_type_uint" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int64" "ac_cv_type_int64" "$ac_includes_default"
+if test "x$ac_cv_type_int64" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT64 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint64" "ac_cv_type_uint64" "$ac_includes_default"
+if test "x$ac_cv_type_uint64" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT64 1
+_ACEOF
+
+
+fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5
 $as_echo_n "checking whether char is unsigned... " >&6; }
@@ -17159,6 +17143,391 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+$SLEEPCMD
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long long" >&5
+$as_echo_n "checking size of unsigned long long... " >&6; }
+if ${ac_cv_sizeof_unsigned_long_long+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long long))" "ac_cv_sizeof_unsigned_long_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_long_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned long long)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_long_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long_long" >&5
+$as_echo "$ac_cv_sizeof_unsigned_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_LONG_LONG $ac_cv_sizeof_unsigned_long_long
+_ACEOF
+
+
+$SLEEPCMD
+
+if test "$ac_cv_type_ushort" = yes ; then
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ushort" >&5
+$as_echo_n "checking size of ushort... " >&6; }
+if ${ac_cv_sizeof_ushort+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (ushort))" "ac_cv_sizeof_ushort"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_ushort" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (ushort)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_ushort=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ushort" >&5
+$as_echo "$ac_cv_sizeof_ushort" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_USHORT $ac_cv_sizeof_ushort
+_ACEOF
+
+
+else
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned short int" >&5
+$as_echo_n "checking size of unsigned short int... " >&6; }
+if ${ac_cv_sizeof_unsigned_short_int+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned short int))" "ac_cv_sizeof_unsigned_short_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_short_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned short int)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_short_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_short_int" >&5
+$as_echo "$ac_cv_sizeof_unsigned_short_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_SHORT_INT $ac_cv_sizeof_unsigned_short_int
+_ACEOF
+
+
+fi
+sleep 3
+if test "$ac_cv_type_uint" = yes ; then
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of uint" >&5
+$as_echo_n "checking size of uint... " >&6; }
+if ${ac_cv_sizeof_uint+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uint))" "ac_cv_sizeof_uint"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_uint" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (uint)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_uint=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_uint" >&5
+$as_echo "$ac_cv_sizeof_uint" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UINT $ac_cv_sizeof_uint
+_ACEOF
+
+
+else
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5
+$as_echo_n "checking size of unsigned int... " >&6; }
+if ${ac_cv_sizeof_unsigned_int+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned int)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5
+$as_echo "$ac_cv_sizeof_unsigned_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int
+_ACEOF
+
+
+fi
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long long" >&5
+$as_echo_n "checking size of unsigned long long... " >&6; }
+if ${ac_cv_sizeof_unsigned_long_long+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long long))" "ac_cv_sizeof_unsigned_long_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_long_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned long long)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_long_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long_long" >&5
+$as_echo "$ac_cv_sizeof_unsigned_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_LONG_LONG $ac_cv_sizeof_unsigned_long_long
+_ACEOF
+
+
+
+$SLEEPCMD
+if test "$ac_cv_type_ushort" = yes ; then
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ushort" >&5
+$as_echo_n "checking size of ushort... " >&6; }
+if ${ac_cv_sizeof_ushort+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (ushort))" "ac_cv_sizeof_ushort"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_ushort" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (ushort)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_ushort=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ushort" >&5
+$as_echo "$ac_cv_sizeof_ushort" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_USHORT $ac_cv_sizeof_ushort
+_ACEOF
+
+
+else
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned short int" >&5
+$as_echo_n "checking size of unsigned short int... " >&6; }
+if ${ac_cv_sizeof_unsigned_short_int+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned short int))" "ac_cv_sizeof_unsigned_short_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_short_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned short int)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_short_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_short_int" >&5
+$as_echo "$ac_cv_sizeof_unsigned_short_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_SHORT_INT $ac_cv_sizeof_unsigned_short_int
+_ACEOF
+
+
+fi
+$SLEEPCMD
+if test "$ac_cv_type_uint" = yes ; then
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of uint" >&5
+$as_echo_n "checking size of uint... " >&6; }
+if ${ac_cv_sizeof_uint+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uint))" "ac_cv_sizeof_uint"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_uint" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (uint)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_uint=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_uint" >&5
+$as_echo "$ac_cv_sizeof_uint" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UINT $ac_cv_sizeof_uint
+_ACEOF
+
+
+else
+   # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5
+$as_echo_n "checking size of unsigned int... " >&6; }
+if ${ac_cv_sizeof_unsigned_int+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_unsigned_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (unsigned int)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_unsigned_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5
+$as_echo "$ac_cv_sizeof_unsigned_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int
+_ACEOF
+
+
+fi
+$SLEEPCMD
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of ptrdiff_t" >&5
+$as_echo_n "checking size of ptrdiff_t... " >&6; }
+if ${ac_cv_sizeof_ptrdiff_t+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (ptrdiff_t))" "ac_cv_sizeof_ptrdiff_t"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_ptrdiff_t" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (ptrdiff_t)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_ptrdiff_t=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_ptrdiff_t" >&5
+$as_echo "$ac_cv_sizeof_ptrdiff_t" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_PTRDIFF_T $ac_cv_sizeof_ptrdiff_t
+_ACEOF
+
+
+
 
 if test "x$enable_netcdf_4" = xyes || test "x$enable_dap" = xyes; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing deflate" >&5
@@ -17512,19 +17881,15 @@ $as_echo "#define USE_PARALLEL_MPIO 1" >>confdefs.h
 
    fi
 
-   # If parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
-   enable_parallel=no
+   # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h.
+   hdf5_parallel=no
    if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then
-      enable_parallel=yes
-
-$as_echo "#define USE_PARALLEL 1" >>confdefs.h
-
+      hdf5_parallel=yes
    fi
-
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether parallel I/O features are to be included" >&5
-$as_echo_n "checking whether parallel I/O features are to be included... " >&6; }
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_parallel" >&5
-$as_echo "$enable_parallel" >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether parallel io is enabled in hdf5" >&5
+$as_echo_n "checking whether parallel io is enabled in hdf5... " >&6; }
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hdf5_parallel" >&5
+$as_echo "$hdf5_parallel" >&6; }
 
    # The user must have built HDF5 with the ZLIB library.
    if test "x$ac_cv_func_H5Pset_deflate" = xyes; then
@@ -17604,8 +17969,6 @@ $as_echo "#define HDF5_HAS_H5FREE 1" >>confdefs.h
 
    fi
 
-
-
    # If the user wants hdf4 built in, check it out.
    if test "x$enable_hdf4" = xyes; then
       for ac_header in mfhdf.h
@@ -17774,26 +18137,53 @@ $as_echo "#define USE_HDF4 1" >>confdefs.h
    fi
 fi
 
-# Check for downloading/building fortran via postinstall script.
-if test "x$enable_remote_fortran_bootstrap" = xyes; then
-
-$as_echo "#define BUILD_FORTRAN 1" >>confdefs.h
+# There are several cases for parallelism:
+# 1. pnetcdf enabled => we want to parallelism for CDF-1,CDF-2,and CDF-5
+# 2. hdf5 has mpio enabled
+#    a. do not want to use it for netcdf4
+#    b. do want to use it for netcdf4
 
+# Should we suppress parallel io for netcdf-4?
+if test "x$enable_netcdf_4" = xyes ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether parallel I/O is enabled for netcdf-4" >&5
+$as_echo_n "checking whether parallel I/O is enabled for netcdf-4... " >&6; }
+  # Check whether --enable-parallel4 was given.
+if test "${enable_parallel4+set}" = set; then :
+  enableval=$enable_parallel4;
 fi
 
+  test "x$enable_parallel4" = xno || enable_parallel4=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_parallel4" >&5
+$as_echo "$enable_parallel4" >&6; }
+else
+  enable_parallel4=no
+fi
+if test "x$hdf5_parallel" = xno; then
+  # hdf5 does not support parallel io, so disable parallel4
+  enable_parallel4=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Parallel io disabled for netcdf-4 because hdf5 does not support" >&5
+$as_echo "$as_me: WARNING: Parallel io disabled for netcdf-4 because hdf5 does not support" >&2;}
+fi
 
-# No logging for netcdf-3.
-if test "x$enable_netcdf_4" = xno; then
-   enable_logging=no
+# We have already tested for parallel io in netcdf4
+# Now do it for netcdf-3
+# Does the user want parallel I/O for classic and 64-bit offset files using parallel-netcdf (pnetcdf)?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether parallel I/O for classic files is to be enabled" >&5
+$as_echo_n "checking whether parallel I/O for classic files is to be enabled... " >&6; }
+# Check whether --enable-pnetcdf was given.
+if test "${enable_pnetcdf+set}" = set; then :
+  enableval=$enable_pnetcdf;
 fi
-if test "x$enable_logging" = xyes; then
 
-$as_echo "#define LOGGING 1" >>confdefs.h
+test "x$enable_pnetcdf" = xyes || enable_pnetcdf=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_pnetcdf" >&5
+$as_echo "$enable_pnetcdf" >&6; }
 
-fi
+# See if the pnetcdf lib is available and of the
+# right version (1.6.0 or later)
 
-# Using pnetcdf for classic parallel I/O?
 if test "x$enable_pnetcdf" = xyes; then
+  pnetcdf_conflict=no
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ncmpi_create in -lpnetcdf" >&5
 $as_echo_n "checking for ncmpi_create in -lpnetcdf... " >&6; }
 if ${ac_cv_lib_pnetcdf_ncmpi_create+:} false; then :
@@ -17838,21 +18228,117 @@ _ACEOF
   LIBS="-lpnetcdf $LIBS"
 
 else
-  as_fn_error $? "Cannot link to pnetcdf library, yet --enable-pnetcdf was used." "$LINENO" 5
+  pnetcdf_conflict=yes
+fi
+
+
+  # Pnetcdf did not support utf-8 until 1.6.0
+
+  # Save/restore CFLAGS
+  SAVELIBS=$LIBS
+  LIBS="$LIBS -lpnetcdf"
+  if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <pnetcdf.h>
+int
+main ()
+{
+
+                   int major = PNETCDF_VERSION_MAJOR;
+                   int minor = PNETCDF_VERSION_MINOR;
+                   int version = major*1000 + minor;
+                   int ok = (version >= (1*1000 + 6));
+                   return (ok?0:1);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  pnetcdf16=yes
+else
+  pnetcdf16=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+  CFLAGS="$SAVECFLAGS"
+  LIBS="$SAVELIBS"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking Is libpnetcdf version 1.6.0 or later?" >&5
+$as_echo_n "checking Is libpnetcdf version 1.6.0 or later?... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pnetcdf16" >&5
+$as_echo "$pnetcdf16" >&6; }
+  if test x$pnetcdf16 = xno; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-pnetcdf requires version 1.6.0 or later; disabling" >&5
+$as_echo "$as_me: WARNING: --enable-pnetcdf requires version 1.6.0 or later; disabling" >&2;}
+    pnetcdf_conflict=yes
+  fi
+fi
+
+if test "x$pnetcdf_conflict" = xyes ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot link to pnetcdf library, --enable-pnetcdf disabled." >&5
+$as_echo "$as_me: WARNING: Cannot link to pnetcdf library, --enable-pnetcdf disabled." >&2;}
+  enable_pnetcdf=no
+fi
+
+# Now, set enable_parallel if either pnetcdf or parallel4 is set
+if test "x$enable_pnetcdf" = xyes -o "x$enable_parallel4" = xyes; then
+enable_parallel=yes
+else
+enable_parallel=no
+fi
+
+if test "x$hdf5_parallel" = xyes; then
+  # Provide more precise parallel control
+
+$as_echo "#define HDF5_PARALLEL 1" >>confdefs.h
+
 fi
 
+# Set config flags
+if test "x$enable_parallel4" = xyes; then
+  # Provide more precise parallel control
+
+$as_echo "#define USE_PARALLEL4 1" >>confdefs.h
+
+fi
+
+if test "x$enable_pnetcdf" = xyes; then
 
 $as_echo "#define USE_PNETCDF 1" >>confdefs.h
 
+fi
 
-  # pnetcdf => parallel
-  # If parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
-  enable_parallel=yes
+# If enable_parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
+if test "x$enable_parallel" = xyes; then
 
 $as_echo "#define USE_PARALLEL 1" >>confdefs.h
 
 fi
 
+# Check for downloading/building fortran via postinstall script.
+if test "x$enable_remote_fortran_bootstrap" = xyes; then
+
+$as_echo "#define BUILD_FORTRAN 1" >>confdefs.h
+
+fi
+
+# No logging for netcdf-3.
+if test "x$enable_netcdf_4" = xno; then
+   enable_logging=no
+fi
+if test "x$enable_logging" = xyes; then
+
+$as_echo "#define LOGGING 1" >>confdefs.h
+
+fi
+
 
 # Like other libraries, udunits and libcf
 # are no long part of the netcdf distribution.
@@ -17890,12 +18376,12 @@ else
   BUILD_PARALLEL_FALSE=
 fi
 
- if test "x$enable_parallel" = xyes -a "x$enable_parallel_tests" = xyes; then
-  TEST_PARALLEL_TRUE=
-  TEST_PARALLEL_FALSE='#'
+ if test "x$enable_parallel4" = xyes -a "x$enable_parallel_tests" = xyes; then
+  TEST_PARALLEL4_TRUE=
+  TEST_PARALLEL4_FALSE='#'
 else
-  TEST_PARALLEL_TRUE='#'
-  TEST_PARALLEL_FALSE=
+  TEST_PARALLEL4_TRUE='#'
+  TEST_PARALLEL4_FALSE=
 fi
 
  if test "x$enable_dap" = xyes; then
@@ -18042,22 +18528,6 @@ else
   USE_DISPATCH_FALSE=
 fi
 
- if test "x$enable_cdmremote" = xyes; then
-  BUILD_CDMREMOTE_TRUE=
-  BUILD_CDMREMOTE_FALSE='#'
-else
-  BUILD_CDMREMOTE_TRUE='#'
-  BUILD_CDMREMOTE_FALSE=
-fi
- # Alias
- if test "x$enable_rpc" = xyes; then
-  BUILD_RPC_TRUE=
-  BUILD_RPC_FALSE='#'
-else
-  BUILD_RPC_TRUE='#'
-  BUILD_RPC_FALSE=
-fi
-
  if test x$enable_diskless = xyes; then
   BUILD_DISKLESS_TRUE=
   BUILD_DISKLESS_FALSE='#'
@@ -18286,7 +18756,24 @@ BINFILE_NAME=${BINFILE_NAME}.tar
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BINFILE_NAME $FC $CXX" >&5
 $as_echo "$BINFILE_NAME $FC $CXX" >&6; }
 
-#UD_FTPBINDIR
+##
+# Bugfix for Cygwin.
+##
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool needs -no-undefined flag to build shared libraries" >&5
+$as_echo_n "checking if libtool needs -no-undefined flag to build shared libraries... " >&6; }
+case "`uname`" in
+     CYGWIN*|MINGW*|AIX*)
+     ## Add in the -no-undefined flag to LDFLAGS for libtool.
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+     NOUNDEFINED=" -no-undefined"
+     ;;
+     *)
+     ## Don't add anything
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+     ;;
+esac
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking value of LIBS" >&5
 $as_echo_n "checking value of LIBS... " >&6; }
@@ -18363,6 +18850,8 @@ HAS_SZLIB=$nc_has_szlib
 
 HAS_PARALLEL=$enable_parallel
 
+HAS_PARALLEL4=$enable_parallel4
+
 HAS_DISKLESS=$enable_diskless
 
 HAS_MMAP=$enable_mmap
@@ -18396,6 +18885,7 @@ HAS_JNA=$enable_jna
 
 
 
+
 # Args:
 # 1. netcdf_meta.h variable
 # 2. conditional variable that is yes or no.
@@ -18487,6 +18977,13 @@ HAS_JNA=$enable_jna
   fi
 
 
+  if  test "x$enable_parallel4" = xyes ; then
+      NC_HAS_PARALLEL4=1
+  else
+      NC_HAS_PARALLEL4=0
+  fi
+
+
 #####
 # End netcdf_meta.h definitions.
 #####
@@ -18701,8 +19198,8 @@ if test -z "${BUILD_PARALLEL_TRUE}" && test -z "${BUILD_PARALLEL_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_PARALLEL\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${TEST_PARALLEL_TRUE}" && test -z "${TEST_PARALLEL_FALSE}"; then
-  as_fn_error $? "conditional \"TEST_PARALLEL\" was never defined.
+if test -z "${TEST_PARALLEL4_TRUE}" && test -z "${TEST_PARALLEL4_FALSE}"; then
+  as_fn_error $? "conditional \"TEST_PARALLEL4\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
 if test -z "${BUILD_DAP_TRUE}" && test -z "${BUILD_DAP_FALSE}"; then
@@ -18777,14 +19274,6 @@ if test -z "${USE_DISPATCH_TRUE}" && test -z "${USE_DISPATCH_FALSE}"; then
   as_fn_error $? "conditional \"USE_DISPATCH\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${BUILD_CDMREMOTE_TRUE}" && test -z "${BUILD_CDMREMOTE_FALSE}"; then
-  as_fn_error $? "conditional \"BUILD_CDMREMOTE\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${BUILD_RPC_TRUE}" && test -z "${BUILD_RPC_FALSE}"; then
-  as_fn_error $? "conditional \"BUILD_RPC\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 if test -z "${BUILD_DISKLESS_TRUE}" && test -z "${BUILD_DISKLESS_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_DISKLESS\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -19198,7 +19687,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.4.0-rc3, which was
+This file was extended by netCDF $as_me 4.4.0-rc4, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -19264,7 +19753,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.4.0-rc3
+netCDF config.status 4.4.0-rc4
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index d214b96..ede1552 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,12 +15,12 @@ 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.4.0-rc3], [support-netcdf at unidata.ucar.edu])
+AC_INIT([netCDF], [4.4.0-rc4], [support-netcdf at unidata.ucar.edu])
 
 AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4
 AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=4
 AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=0
-AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-rc3"
+AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-rc4"
 
 #####
 # Set some variables used to generate a libnetcdf.settings file,
@@ -168,19 +168,19 @@ test "x$enable_valgrind_tests" = xyes || enable_valgrind_tests=no
 AC_MSG_RESULT($enable_valgrind_tests)
 
 # Does the user want to build netcdf-4?
-AC_MSG_CHECKING([whether we should try to build netCDF-4])
-AC_ARG_ENABLE([netcdf-4], [AS_HELP_STRING([--enable-netcdf-4],
-              [build with netcdf-4 (HDF5 and zlib required)])])
+AC_MSG_CHECKING([whether we should build netCDF-4])
+AC_ARG_ENABLE([netcdf-4], [AS_HELP_STRING([--disable-netcdf-4],
+              [do not build with netcdf-4 (else HDF5 and zlib required)])])
 test "x$enable_netcdf_4" = xno || enable_netcdf_4=yes
-AC_MSG_RESULT([$enable_netcdf_4])
 
 # Synonym
-# --enable-netcdf-4 is the controlling enable switch
-if test "x$enable_netcdf_4" = "x" ; then
-  AC_ARG_ENABLE([netcdf4], [AS_HELP_STRING([--enable-netcdf4],
-              [(just a synonym for enable-netcdf-4)])])
-  enable_netcdf_4="$enable_netcdf4"
+AC_ARG_ENABLE([netcdf4], [AS_HELP_STRING([--disable-netcdf4],
+              [(just a synonym for --disable-netcdf-4)])])
+test "x$enable_netcdf4" = xno || enable_netcdf4=yesi
+if test "x$enable_netcdf4" = xno ; then
+enable_netcdf_4=no
 fi
+AC_MSG_RESULT([$enable_netcdf_4])
 
 # Does the user require dynamic loading?
 # This is only for those hdf5 installs that support it.
@@ -215,13 +215,6 @@ AC_ARG_ENABLE([fortran], [AS_HELP_STRING([--enable-remote-fortran-bootstrap],
 test "x$enable_remote_fortran_bootstrap" = xyes || enable_remote_fortran_bootstrap=no
 AC_MSG_RESULT([$enable_remote_fortran_bootstrap])
 
-# Does the user want to turn on PNETCDF read ability?
-AC_MSG_CHECKING([whether parallel I/O for classic and 64-bit offset files using parallel-netcdf is to be enabled])
-AC_ARG_ENABLE([pnetcdf], [AS_HELP_STRING([--enable-pnetcdf],
-              [build with parallel I/O for classic and 64-bit offset files using parallel-netcdf])])
-test "x$enable_pnetcdf" = xyes || enable_pnetcdf=no
-AC_MSG_RESULT($enable_pnetcdf)
-
 # Does the user want to run extra example tests
 AC_MSG_CHECKING([whether extra example tests should be run])
 AC_ARG_ENABLE([extra-example-tests],
@@ -305,16 +298,6 @@ AC_ARG_ENABLE([logging],
 test "x$enable_logging" = xyes || enable_logging=no
 AC_MSG_RESULT([$enable_logging])
 
-# Capture the state of the --enable-cdmremote flag
-AC_MSG_CHECKING([whether cdmremote client is to be built])
-AC_ARG_ENABLE([cdmremote],
-                 [AS_HELP_STRING([--enable-cdmremote],
-                                 [build with cdmremote client support.])])
-test "x$enable_cdmremote" = xyes || enable_cdmremote=no
-# CDMREMOTE requires netCDF-4
-if test "x$enable_netcdf_4" = "xno" ; then enable_cdmremote=no ; fi
-AC_MSG_RESULT($enable_cdmremote)
-
 ## Capture the state of the --enable-dap flag
 AC_MSG_CHECKING([whether DAP client is to be built])
 AC_ARG_ENABLE([dap],
@@ -323,21 +306,10 @@ AC_ARG_ENABLE([dap],
 test "x$enable_dap" = xno || enable_dap=yes
 AC_MSG_RESULT($enable_dap)
 
-# OC now has its own version of rpc (really xdr), so no longer need the library
-## Capture the state of the --enable-rpc flag
-#AC_MSG_CHECKING([whether rpc client and server are to be built])
-#AC_ARG_ENABLE([rpc],
-#                 [AS_HELP_STRING([--enable-rpc],
-#                                 [build with rpc client and server support.])])
-#test "x$enable_rpc" = xyes || enable_rpc=no
-#AC_MSG_RESULT($enable_rpc)
-
 # Curl support is required if and only if any of these flags are set:
 # 1. --enable-dap
-# 2. --enable-cdmremote
-# 3. --enable-rpc
 
-if test "x$enable_dap" = "xyes" -o "x$enable_cdmremote" = "xyes" -o "x$enable_rpc" = "xyes" ; then
+if test "x$enable_dap" = "xyes" ; then
 require_curl=yes
 else
 require_curl=no
@@ -356,8 +328,6 @@ if test $require_curl = yes ; then
   if test $found_curl = no ; then
     AC_MSG_NOTICE([libcurl not found; disabling remote protocol(s) support])
     enable_dap=no
-    enable_cdmremote=no
-    enable_rpc=no
   elif test $found_curl = yes ; then
     # Redo the check lib to actually add -lcurl
     #AC_CHECK_LIB([curl], [curl_easy_setopt])
@@ -417,14 +387,6 @@ if test "x$enable_dap_remote_tests" = xyes; then
    AC_DEFINE([ENABLE_DAP_REMOTE_TESTS], [1], [if true, do remote tests])
 fi
 
-if test "x$enable_cdmremote" = xyes; then
-   AC_DEFINE([USE_CDMREMOTE], [1], [if true, build CDMREMOTE Client])
-fi
-
-if test "x$enable_rpc" = xyes; then
-   AC_DEFINE([BUILD_RPC], [1], [if true, build RPC Client and Server])
-fi
-
 AC_MSG_CHECKING([whether the time-consuming dap tests should be enabled (default off)])
 AC_ARG_ENABLE([dap-long-tests],
               [AS_HELP_STRING([--enable-dap-long-tests],
@@ -798,17 +760,15 @@ AC_ARG_ENABLE([diskless],
               [AS_HELP_STRING([--disable-diskless],
                               [disable support for in-memory (NC_DISKLESS) files])])
 test "x$enable_diskless" = xno || enable_diskless=yes
-
+AC_MSG_RESULT($enable_diskless)
 
 # Check for enable DAP
-if test "x$enable_dap" = "xyes" -o "x$enable_cdmremote" = "xyes" -o "x$enable_rpc" = "xyes" ; then
+if test "x$enable_dap" = "xyes"; then
 enable_diskless=yes
 AC_MSG_NOTICE([--enable-dap requires --enable-diskless])
+AC_MSG_NOTICE([dap support disabled])
 fi
 
-AC_MSG_RESULT($enable_diskless)
-
-
 # check for useful, but not essential, memio support
 AC_CHECK_FUNCS([memmove getpagesize sysconf])
 
@@ -843,7 +803,7 @@ AC_STRUCT_ST_BLKSIZE
 UD_CHECK_IEEE
 AC_TYPE_SIZE_T
 AC_TYPE_OFF_T
-AC_CHECK_TYPES([ssize_t, ptrdiff_t, uchar, longlong])
+AC_CHECK_TYPES([ssize_t, ptrdiff_t, uchar, longlong, ushort, uint, int64, uint64])
 AC_C_CHAR_UNSIGNED
 AC_C_BIGENDIAN
 
@@ -874,6 +834,39 @@ $SLEEPCMD
 AC_CHECK_SIZEOF(off_t)
 $SLEEPCMD
 AC_CHECK_SIZEOF(size_t)
+$SLEEPCMD
+AC_CHECK_SIZEOF(unsigned long long)
+$SLEEPCMD
+
+if test "$ac_cv_type_ushort" = yes ; then
+   AC_CHECK_SIZEOF(ushort)
+else
+   AC_CHECK_SIZEOF(unsigned short int)
+fi
+sleep 3
+if test "$ac_cv_type_uint" = yes ; then
+   AC_CHECK_SIZEOF(uint)
+else
+   AC_CHECK_SIZEOF(unsigned int)
+fi
+
+AC_CHECK_SIZEOF(unsigned long long)
+
+$SLEEPCMD
+if test "$ac_cv_type_ushort" = yes ; then
+   AC_CHECK_SIZEOF(ushort)
+else
+   AC_CHECK_SIZEOF(unsigned short int)
+fi
+$SLEEPCMD
+if test "$ac_cv_type_uint" = yes ; then
+   AC_CHECK_SIZEOF(uint)
+else
+   AC_CHECK_SIZEOF(unsigned int)
+fi
+$SLEEPCMD
+AC_CHECK_SIZEOF(ptrdiff_t)
+
 
 if test "x$enable_netcdf_4" = xyes || test "x$enable_dap" = xyes; then
    AC_SEARCH_LIBS([deflate], [zlibwapi zlibstat zlib zlib1 z], [], [
@@ -920,15 +913,13 @@ if test "x$enable_netcdf_4" = xyes; then
       AC_DEFINE([USE_PARALLEL_MPIO], [1], [if true, compile in parallel netCDF-4 based on MPI/IO])
    fi
 
-   # If parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
-   enable_parallel=no
+   # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h.
+   hdf5_parallel=no
    if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then
-      enable_parallel=yes
-      AC_DEFINE([USE_PARALLEL], [1], [if true, parallel netCDF-4 is in use])
+      hdf5_parallel=yes
    fi
-
-   AC_MSG_CHECKING([whether parallel I/O features are to be included])
-   AC_MSG_RESULT([$enable_parallel])
+   AC_MSG_CHECKING([whether parallel io is enabled in hdf5])
+   AC_MSG_RESULT([$hdf5_parallel])
 
    # The user must have built HDF5 with the ZLIB library.
    if test "x$ac_cv_func_H5Pset_deflate" = xyes; then
@@ -947,8 +938,6 @@ if test "x$enable_netcdf_4" = xyes; then
       AC_DEFINE([HDF5_HAS_H5FREE], [1], [if true, H5free_memory() will be used to free hdf5-allocated memory in nc4file.])
    fi
 
-
-
    # If the user wants hdf4 built in, check it out.
    if test "x$enable_hdf4" = xyes; then
       AC_CHECK_HEADERS([mfhdf.h], [], [nc_mfhdf_h_missing=yes])
@@ -964,12 +953,105 @@ if test "x$enable_netcdf_4" = xyes; then
    fi
 fi
 
+# There are several cases for parallelism:
+# 1. pnetcdf enabled => we want to parallelism for CDF-1,CDF-2,and CDF-5
+# 2. hdf5 has mpio enabled
+#    a. do not want to use it for netcdf4
+#    b. do want to use it for netcdf4
+
+# Should we suppress parallel io for netcdf-4?
+if test "x$enable_netcdf_4" = xyes ; then
+  AC_MSG_CHECKING([whether parallel I/O is enabled for netcdf-4])
+  AC_ARG_ENABLE([parallel4], [AS_HELP_STRING([--disable-parallel4],
+                [disable parallel I/O for netcdf-4, even if it's enabled in libhdf5])])
+  test "x$enable_parallel4" = xno || enable_parallel4=yes
+  AC_MSG_RESULT($enable_parallel4)
+else
+  enable_parallel4=no
+fi
+if test "x$hdf5_parallel" = xno; then
+  # hdf5 does not support parallel io, so disable parallel4
+  enable_parallel4=no
+  AC_MSG_WARN([Parallel io disabled for netcdf-4 because hdf5 does not support])
+fi
+
+# We have already tested for parallel io in netcdf4
+# Now do it for netcdf-3
+# Does the user want parallel I/O for classic and 64-bit offset files using parallel-netcdf (pnetcdf)?
+AC_MSG_CHECKING([whether parallel I/O for classic files is to be enabled])
+AC_ARG_ENABLE([pnetcdf], [AS_HELP_STRING([--enable-pnetcdf],
+              [build with parallel I/O for classic files])])
+test "x$enable_pnetcdf" = xyes || enable_pnetcdf=no
+AC_MSG_RESULT($enable_pnetcdf)
+
+# See if the pnetcdf lib is available and of the
+# right version (1.6.0 or later)
+
+if test "x$enable_pnetcdf" = xyes; then
+  pnetcdf_conflict=no
+  AC_CHECK_LIB([pnetcdf], [ncmpi_create], [],[pnetcdf_conflict=yes])
+
+  # Pnetcdf did not support utf-8 until 1.6.0
+
+  # Save/restore CFLAGS
+  SAVELIBS=$LIBS
+  LIBS="$LIBS -lpnetcdf"
+  AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <pnetcdf.h>],
+                 [[
+                   int major = PNETCDF_VERSION_MAJOR;
+                   int minor = PNETCDF_VERSION_MINOR;
+                   int version = major*1000 + minor;
+                   int ok = (version >= (1*1000 + 6));
+                   return (ok?0:1);]])],
+                 [pnetcdf16=yes],
+                 [pnetcdf16=no])
+  CFLAGS="$SAVECFLAGS"
+  LIBS="$SAVELIBS"
+  AC_MSG_CHECKING([Is libpnetcdf version 1.6.0 or later?])
+  AC_MSG_RESULT([$pnetcdf16])
+  if test x$pnetcdf16 = xno; then
+    AC_MSG_WARN([--enable-pnetcdf requires version 1.6.0 or later; disabling])
+    pnetcdf_conflict=yes
+  fi
+fi
+
+if test "x$pnetcdf_conflict" = xyes ; then
+  AC_MSG_WARN([Cannot link to pnetcdf library, --enable-pnetcdf disabled.])
+  enable_pnetcdf=no
+fi
+
+# Now, set enable_parallel if either pnetcdf or parallel4 is set
+if test "x$enable_pnetcdf" = xyes -o "x$enable_parallel4" = xyes; then
+enable_parallel=yes
+else
+enable_parallel=no
+fi
+
+if test "x$hdf5_parallel" = xyes; then
+  # Provide more precise parallel control
+  AC_DEFINE([HDF5_PARALLEL], [1], [if true, hdf5 has parallelism enabled])
+fi
+
+# Set config flags
+if test "x$enable_parallel4" = xyes; then
+  # Provide more precise parallel control
+  AC_DEFINE([USE_PARALLEL4], [1], [if true, parallel netcdf-4 is in use])
+fi
+
+if test "x$enable_pnetcdf" = xyes; then
+  AC_DEFINE([USE_PNETCDF], [1], [if true, parallel netCDF is used])
+fi
+
+# If enable_parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
+if test "x$enable_parallel" = xyes; then
+  AC_DEFINE([USE_PARALLEL], [1], [if true, pnetcdf or parallel netcdf-4 is in use])
+fi
+
 # Check for downloading/building fortran via postinstall script.
 if test "x$enable_remote_fortran_bootstrap" = xyes; then
    AC_DEFINE([BUILD_FORTRAN], 1, [If true, will attempt to download and build netcdf-fortran.])
 fi
 
-
 # No logging for netcdf-3.
 if test "x$enable_netcdf_4" = xno; then
    enable_logging=no
@@ -978,18 +1060,6 @@ if test "x$enable_logging" = xyes; then
    AC_DEFINE([LOGGING], 1, [If true, turn on logging.])
 fi
 
-# Using pnetcdf for classic parallel I/O?
-if test "x$enable_pnetcdf" = xyes; then
-  AC_CHECK_LIB([pnetcdf], [ncmpi_create], [],
-  [AC_MSG_ERROR([Cannot link to pnetcdf library, yet --enable-pnetcdf was used.])])
-  AC_DEFINE([USE_PNETCDF], [1], [if true, parallel netCDF is used])
-
-  # pnetcdf => parallel
-  # If parallel is in use, enable it in the C code. Also add some stuff to netcdf.h.
-  enable_parallel=yes
-  AC_DEFINE([USE_PARALLEL], [1], [if true, pnetcdf or parallel netcdf-4 is in use])
-fi
-
 
 # Like other libraries, udunits and libcf
 # are no long part of the netcdf distribution.
@@ -1020,7 +1090,7 @@ fi
 # Automake conditionals need to be called, whether the answer is yes
 # or no.
 AM_CONDITIONAL(BUILD_PARALLEL, [test x$enable_parallel = xyes])
-AM_CONDITIONAL(TEST_PARALLEL, [test "x$enable_parallel" = xyes -a "x$enable_parallel_tests" = xyes])
+AM_CONDITIONAL(TEST_PARALLEL4, [test "x$enable_parallel4" = xyes -a "x$enable_parallel_tests" = xyes])
 AM_CONDITIONAL(BUILD_DAP, [test "x$enable_dap" = xyes])
 AM_CONDITIONAL(USE_DAP, [test "x$enable_dap" = xyes]) # Alias
 AM_CONDITIONAL(ENABLE_DAP_REMOTE_TESTS, [test "x$enable_dap_remote_tests" = xyes])
@@ -1039,8 +1109,6 @@ AM_CONDITIONAL(USE_RENAMEV3, [test x$enable_netcdf_4 = xyes -o x$enable_dap = xy
 AM_CONDITIONAL(BUILD_FORTRAN, [test x$enable_remote_fortran_bootstrap = xyes])
 AM_CONDITIONAL(USE_PNETCDF, [test x$enable_pnetcdf = xyes])
 AM_CONDITIONAL(USE_DISPATCH, [test x$enable_dispatch = xyes])
-AM_CONDITIONAL(BUILD_CDMREMOTE, [test "x$enable_cdmremote" = xyes]) # Alias
-AM_CONDITIONAL(BUILD_RPC, [test "x$enable_rpc" = xyes])
 AM_CONDITIONAL(BUILD_DISKLESS, [test x$enable_diskless = xyes])
 AM_CONDITIONAL(BUILD_MMAP, [test x$enable_mmap = xyes])
 AM_CONDITIONAL(BUILD_DOCS, [test x$enable_doxygen = xyes])
@@ -1070,7 +1138,21 @@ BINFILE_NAME=${BINFILE_NAME}.tar
 AC_SUBST(BINFILE_NAME)
 AC_MSG_RESULT([$BINFILE_NAME $FC $CXX])
 
-#UD_FTPBINDIR
+##
+# Bugfix for Cygwin.
+##
+AC_MSG_CHECKING([if libtool needs -no-undefined flag to build shared libraries])
+case "`uname`" in
+     CYGWIN*|MINGW*|AIX*)
+     ## Add in the -no-undefined flag to LDFLAGS for libtool.
+     AC_MSG_RESULT([yes])
+     NOUNDEFINED=" -no-undefined"
+     ;;
+     *)
+     ## Don't add anything
+     AC_MSG_RESULT([no])
+     ;;
+esac
 
 AC_MSG_CHECKING([value of LIBS])
 AC_MSG_RESULT([$LIBS])
@@ -1129,6 +1211,7 @@ AC_SUBST(HAS_PNETCDF,[$enable_pnetcdf])
 AC_SUBST(HAS_HDF5,[$enable_netcdf_4])
 AC_SUBST(HAS_SZLIB,[$nc_has_szlib])
 AC_SUBST(HAS_PARALLEL,[$enable_parallel])
+AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
 AC_SUBST(HAS_DISKLESS,[$enable_diskless])
 AC_SUBST(HAS_MMAP,[$enable_mmap])
 AC_SUBST(HAS_JNA,[$enable_jna])
@@ -1163,6 +1246,7 @@ AC_SUBST([LDFLAGS])
 AC_SUBST([AM_CFLAGS])
 AC_SUBST([AM_CPPFLAGS])
 AC_SUBST([AM_LDFLAGS])
+AC_SUBST([NOUNDEFINED])
 
 # Args:
 # 1. netcdf_meta.h variable
@@ -1194,6 +1278,7 @@ AX_SET_META([NC_HAS_MMAP],[$enable_mmap],[yes])
 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])
 
 #####
 # End netcdf_meta.h definitions.
diff --git a/docs/.gitignore b/docs/.gitignore
index e5b3c00..fb2e3bf 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -1 +1,2 @@
-auth.md
\ No newline at end of file
+auth.md
+auth.html
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index a3cd2f6..c1b59d3 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -4,11 +4,9 @@
 IF(ENABLE_DOXYGEN)
   # The following is redundant but does not hurt anything.
 
-  FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.html ${CMAKE_CURRENT_SOURCE_DIR}/images ${CMAKE_CURRENT_SOURCE_DIR}/*.doc ${CMAKE_CURRENT_SOURCE_DIR}/*.xml ${CMAKE_CURRENT_SOURCE_DIR}/*.m4 ${CMAKE_CURRENT_SOURCE_DIR}/*.texi)
+  FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.html ${CMAKE_CURRENT_SOURCE_DIR}/images ${CMAKE_CURRENT_SOURCE_DIR}/*.doc ${CMAKE_CURRENT_SOURCE_DIR}/*.xml ${CMAKE_CURRENT_SOURCE_DIR}/*.m4 ${CMAKE_CURRENT_SOURCE_DIR}/*.texi ${CMAKE_SOURCE_DIR}/oc2/auth.html.in)
   FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
 
-
-
   # Set abs_top_srcdir to work with the autotools
   # doxyfile template.
   SET(abs_top_srcdir ${CMAKE_SOURCE_DIR})
@@ -18,20 +16,22 @@ IF(ENABLE_DOXYGEN)
   CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
     ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
 
-  # Create auth.md by combining auth.md.in and oc2/ocauth.md
-
-  ADD_CUSTOM_TARGET(auth_doc ALL
-    cat ${CMAKE_SOURCE_DIR}/docs/auth.md.in ${CMAKE_SOURCE_DIR}/docs/ocauth.md > ${CMAKE_CURRENT_SOURCE_DIR}/auth.md
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-    VERBATIM
-    )
-
   # Generate User Documentation
   ADD_CUSTOM_TARGET(doc_all ALL
     ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+    COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/auth.html ${CMAKE_CURRENT_BINARY_DIR}/html
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     COMMENT "Generating API Documentation" VERBATIM)
 
+    # Create auth.html with some sed commands.
+  ADD_CUSTOM_TARGET(oc2-auth
+
+    cat ${CMAKE_SOURCE_DIR}/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${CMAKE_SOURCE_DIR}/oc2/oc.css" -e "/stylesheet/d" > ${CMAKE_CURRENT_SOURCE_DIR}/auth.html
+    COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/auth.html ${CMAKE_CURRENT_BINARY_DIR}/html
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+    VERBATIM
+    )
+
   # If ENABLE_DOXYGEN_LATEX_OUTPUT is true, automatically build
   # the PDF files.
   IF(ENABLE_DOXYGEN_PDF_OUTPUT)
@@ -52,6 +52,7 @@ IF(ENABLE_DOXYGEN)
 	"${CMAKE_CURRENT_BINARY_DIR}/netcdf-guide.pdf"
 	"${CMAKE_CURRENT_BINARY_DIR}/netcdf-tutorial.pdf"
 	DESTINATION "${CMAKE_INSTALL_DOCDIR}/pdf"
+
 	COMPONENT documentation)
 
     ENDIF()
diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
index 21656b6..ac90eb8 100644
--- a/docs/Doxyfile.in
+++ b/docs/Doxyfile.in
@@ -754,7 +754,6 @@ INPUT = \
     @abs_top_srcdir@/docs/windows-binaries.md \
     @abs_top_srcdir@/docs/guide.dox \
     @abs_top_srcdir@/docs/OPeNDAP.dox \
-    @abs_top_srcdir@/docs/auth.md \
     @abs_top_srcdir@/docs/attribute_conventions.md \
     @abs_top_srcdir@/docs/file_format_specifications.md \
     @abs_top_srcdir@/docs/tutorial.dox \
@@ -1563,7 +1562,7 @@ SEARCHENGINE           = @DOXYGEN_SEARCHENGINE@
 # The default value is: NO.
 # This tag requires that the tag SEARCHENGINE is set to YES.
 
-SERVER_BASED_SEARCH    = NO
+SERVER_BASED_SEARCH    = @DOXYGEN_SERVER_BASED_SEARCH@
 
 # When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
 # script for searching. Instead the search results are written to an XML file
@@ -2020,7 +2019,7 @@ PREDEFINED             = USE_NETCDF4
 EXPAND_AS_DEFINED      =
 
 # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
-# remove all refrences to function-like macros that are alone on a line, have an
+# remove all references to function-like macros that are alone on a line, have an
 # all uppercase name, and do not end with a semicolon. Such function macros are
 # typically used for boiler-plate code, and will confuse the parser if not
 # removed.
diff --git a/docs/Makefile.am b/docs/Makefile.am
index a800036..ee9ae41 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -10,8 +10,8 @@ EXTRA_DIST = netcdf.m4 DoxygenLayout.xml Doxyfile.in footer.html \
     architecture.dox internal.dox windows-binaries.md \
     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.md.in auth.md \
-	software.md ocauth.md
+    all-error-codes.md cmake_faq.md credits.md software.md \
+    auth.html
 
 # Turn off parallel builds in this directory.
 .NOTPARALLEL:
@@ -50,13 +50,11 @@ endif
 # includes them in the documentation.
 
 doxyfile.stamp:
-	$(DOXYGEN) Doxyfile
+	$(DOXYGEN) Doxyfile \
+	cp auth.html html
 
 CLEANFILES = doxyfile.stamp html latex man
 
-auth.md: auth.md.in ocauth.md
-	cat auth.md.in ocauth.md > auth.md
-
 # This builds the docs from source, if necessary, and tars up
 # everything needed for the website. Run this and copy the resulting
 # tarball to the /contents/netcdf/docs directory to update the on-line
@@ -64,3 +62,13 @@ auth.md: auth.md.in ocauth.md
 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 d5b6964..d8d92a4 100644
--- a/docs/Makefile.in
+++ b/docs/Makefile.in
@@ -235,6 +235,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -267,6 +268,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -278,6 +280,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -363,8 +366,8 @@ EXTRA_DIST = netcdf.m4 DoxygenLayout.xml Doxyfile.in footer.html \
     architecture.dox internal.dox windows-binaries.md \
     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.md.in auth.md \
-	software.md ocauth.md
+    all-error-codes.md cmake_faq.md credits.md software.md \
+    auth.html
 
 
 # To build documentation you must have M4 in their path.
@@ -718,10 +721,8 @@ uninstall-am:
 # includes them in the documentation.
 
 doxyfile.stamp:
-	$(DOXYGEN) Doxyfile
-
-auth.md: auth.md.in ocauth.md
-	cat auth.md.in ocauth.md > auth.md
+	$(DOXYGEN) Doxyfile \
+	cp auth.html html
 
 # This builds the docs from source, if necessary, and tars up
 # everything needed for the website. Run this and copy the resulting
@@ -731,6 +732,16 @@ 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 deee826..9ac2629 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
-- \subpage oc_auth
+- <a href="auth.html">netCDF Authorization Support</a>
 - \subpage dap_to_netcdf
 - \subpage var_dim_trans
 - \subpage var_name_trans
@@ -488,7 +488,7 @@ assumed that the cost is not prohibitive.
 
 In an effort to provide better performance for some access patterns,
 client-side caching of data is available. The default is no caching,
-but it may be enabled by prefixing the URL with the paramter "cache".
+but it may be enabled by prefixing the URL with the parameter "cache".
 
 Caching operates basically as follows.
 
diff --git a/oc2/ocauth.html b/docs/auth.html
similarity index 71%
copy from oc2/ocauth.html
copy to docs/auth.html
index d8e2537..c617e86 100644
--- a/oc2/ocauth.html
+++ b/docs/auth.html
@@ -1,14 +1,35 @@
-<!- Copyright 2014, UCAR/Unidata and OPeNDAP, Inc. --> 
+<!- Copyright 2015, UCAR/Unidata and OPeNDAP, Inc. --> 
 <!- See the COPYRIGHT file for more information. --> 
 <html> 
+<head>
 <style> 
 .break { page-break-before: always; } 
 body { counter-reset: H2; font-size: 12pt; } 
+h1.title {
+  font-size: 18pt;
+  text-decoration: underline;
+}
+div.subtitle {
+}
+.subtitle h1 {
+  font-size: 14pt;
+  margin-top: 0;
+  margin-bottom: 0;
+}
+
+h1.toc {
+  font-size: 16pt;
+  text-decoration: underline;
+}
+h1.appendix {
+  font-size: 14pt;
+}
+
 h2:before { 
   content: counter(H2) " "; 
   counter-increment: H2; 
 } 
-h2 { counter-reset: H3; } 
+h2 { counter-reset: H3; text-decoration: underline; } 
 h3:before { 
   content: counter(H2) "." counter(H3) " "; 
   counter-increment:H3; 
@@ -18,21 +39,20 @@ h4:before {
   content: counter(H2) "." counter(H3) "." counter(H4) " "; 
   counter-increment:H4; 
 } 
-h5 {font-size: 14pt; } /* For Appendices */ 
-h6 {font-size: 16pt; } /* For Subtitles */ 
+
 </style> 
+</head>
 <body> 
  
-<center> 
-<h1>OC Authorization Support</h1> 
-<h6>Author: Dennis Heimbigner<br>
-dmh at ucar dot edu</h6>
-<h6>Draft: 11/21/2014<br> 
-Last Revised: 12/23/2014<br> 
-OC Version 2.1</h6> 
-</center> 
+<h1 class="title">netCDF Authorization Support</h1> 
+<div class="subtitle">
+<h1>Author: Dennis Heimbigner</h1>
+<h1>Address: http://www.unidata.ucar.edu/staff/dmh/</h1>
+<h1>Draft: 11/21/2014</h1>
+<h1>Last Revised: 10/24/2015</h1>
+</div>
  
-<h6 class="break"><u>Table of Contents</u></h6> 
+<h1 class="toc">Table of Contents</h1> 
 <ol> 
 <li> <a href="#Introduction">Introduction</a> 
 <li> <a href="#URL-AUTH">URL-Based Authentication</a> 
@@ -44,8 +64,8 @@ OC Version 2.1</h6>
 <li> <a href="#ESGDETAIL">Appendix B. ESG Access in Detail</a>
 </ol> 
  
-<h2 class="break"><a name="Introduction"><u>Introduction</u></a></h2> 
-OC can support user authorization using those provided by the curl
+<h2><a name="Introduction">Introduction</a></h2> 
+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>
@@ -57,7 +77,7 @@ The libcurl authorization mechanisms can be accessed in two ways
 <i>.daprc</i> or <i>.dodsrc</i>
 </ol>
 
-<h2 class="break"><a name="URL-AUTH"><u>URL-Based Authentication</u></a></h2> 
+<h2><a name="URL-AUTH">URL-Based Authentication</a></h2> 
 For simple password based authentication, it is possible to
 directly insert the username and the password into a url in this form.
 <pre>
@@ -67,23 +87,21 @@ 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 <a href="#REDIR">redirection</a> based
-authorization will not work with this.
+authorization will not work with this because the username and password
+will only be used on the initial request, not the redirection
 
-<h2 class="break"><a name="DODSRC"><u>RC File Authentication</u></a></h2> 
-The oc library supports an <i>rc</i> file mechanism to allow the passing
-of a number of parameters to liboc and libcurl.
+<h2><a name="DODSRC">RC File Authentication</a></h2> 
+The netcdf library supports an <i>rc</i> file mechanism to allow the passing
+of a number of parameters to libnetcdf and libcurl.
 <p>
 The file must be called one of the following names:
-".daprc", ".dodsrc"
+".daprc" or ".dodsrc"
 If both .daprc and .dodsrc exist, then
 the .daprc file will take precedence.
 <p>
-Searching for the rc file first looks in the current directory
+The rc file is searched for first in the current directory
 and then in the home directory (as defined by the HOME environment
-variable). It is also possible to specify a direct path using
-the <i>-R</i> option to ocprint or using the <i>oc_set_rcfile</i>
-procedure (see oc.h). Note that for these latter cases, the path
-must be to the file itself, not to the containing directory.
+variable).
 <p>
 The rc file format is a series of lines of the general form:
 <pre>
@@ -93,10 +111,11 @@ where the bracket-enclosed host:port is optional and will be discussed
 subsequently.
 <p>
 The currently defined set of authorization-related keys are as follows.
-The second column is the affected curl_easy_setopt option(s).
+The second column is the affected curl_easy_setopt option(s), if any.
 <table>
-<tr><th>Key<th>curl_easy_setopt Option
-<tr><td>HTTP.COOKIEJAR<td>CURLOPT_COOKIEJAR, CURLOPT_COOKIEFILE
+<tr><th>Key<th>Affected curl_easy_setopt Options<th>Notes
+<tr><td>HTTP.COOKIEJAR<td>CURLOPT_COOKIEJAR
+<tr><td>HTTP.COOKIEFILE<td>CURLOPT_COOKIEJAR<td>Alias for CURLOPT_COOKIEJAR
 <tr><td>HTTP.PROXY_SERVER<td>CURLOPT_PROXY, CURLOPT_PROXYPORT, CURLOPT_PROXYUSERPWD
 <tr><td>HTTP.SSL.CERTIFICATE<td>CURLOPT_SSLCERT
 <tr><td>HTTP.SSL.KEY<td>CURLOPT_SSLKEY
@@ -104,36 +123,41 @@ The second column is the affected curl_easy_setopt option(s).
 <tr><td>HTTP.SSL.CAINFO<td>CURLOPT_SSLCAINFO
 <tr><td>HTTP.SSL.CAPATH<td>CURLOPT_SSLCAPATH
 <tr><td>HTTP.SSL.VERIFYPEER<td>CURLOPT_SSL_VERIFYPEER
+<tr><td>HTTP.SSL.VALIDATE<td>CURLOPT_SSL_VERIFYPEER, CURLOPT_SSL_VERIFYHOST
 <tr><td>HTTP.CREDENTIALS.USERPASSWORD<td>CURLOPT_USERPASSWORD
+<tr><td>HTTP.NETRC<td>N.A.<td>Specify path of the .netrc file
 </table>
 </ul>
 
-<h3><u>Password Authentication</u></h3> 
+<h3>Password Authentication</h3> 
 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 <a href="#REDIR">redirection authorization</a>
+for important additional information.
 
-<h3><u>Cookie Jar</u></h3> 
+<h3>Cookie Jar</h3> 
 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 <a href="#REDIR">redirection authorization</a>
+for important additional information.
 
-<h3><u>Certificate Authentication</u></h3> 
+<h3>Certificate Authentication</h3> 
 HTTP.SSL.CERTIFICATE
 specifies a file path for a file containing a PEM cerficate.
 This is typically used for client-side authentication.
 <p>
 HTTP.SSL.KEY is essentially the same as HTTP.SSL.CERTIFICATE
-and should usually have the same value.
+and should always have the same value.
 <p>
 HTTP.SSL.KEYPASSWORD
-specifies the password for accessing the HTTP.SSL.KEY/HTTP.SSL.CERTIFICATE
-file.
+specifies the password for accessing the HTTP.SSL.CERTIFICAT/HTTP.SSL.key file.
 <p>
 HTTP.SSL.CAPATH
 specifies the path to a directory containing
@@ -144,57 +168,64 @@ is a boolean (1/0) value that if true (1)
 specifies that the client should verify the server's presented certificate.
 <p>
 HTTP.PROXY_SERVER
-specified the url for accessing the proxy:
-(e.g.http://[username:password@]host[:port])
+specifies the url for accessing the proxy:
+e.g. <i>http://[username:password@]host[:port]</i>
+<p>
+HTTP.NETRC
+specifies the absolute path of the .netrc file.
+See <a href="#REDIR">redirection authorization</a>
+for information about using .netrc.
 
-<h2 class="break"><a name="REDIR"><u>Redirection-Based Authentication</u></a> </h2>
+<h2><a name="REDIR">Redirection-Based Authentication</a> </h2>
 Some sites provide authentication by using a third party site
-to to the authentication. One example is
-<a href="https://uat.urs.earthdata.nasa.gov">URS</a>,
-the EOSDIS User Registration System.
+to do the authentication. Examples include ESG and URS.
 <p>
 The process is usually as follows.
 <ol>
-<li>The client contacts the server of interest (SOI), the actual data provider.
-<li>The SOI sends a redirect to the client to connect to the URS system.
+<li>The client contacts the server of interest (SOI), the actual data provider
+using, typically http protocol.
+<li>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).
 <li>The client authenticates with URS.
 <li>URS sends a redirect (with authorization information) to send
 the client back to the SOI to actually obtain the data.
 </ol>
 <p>
-In order for this to work with libcurl, the client will usually need
-to provide a .netrc file so that the redirection will work correctly.
+It turns out that libcurl uses the password in the .daprc file — or from the url —
+only for the initial connection. This causes problems because
+the redirected connection is the one that actually requires the password.
+This is where .netrc 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 the redirection site.
+In summary, if you are using redirection, then you must create a .netrc
+file to hold the password for the site to which the redirection is sent.
+<p>
 The format of this .netrc file will contain content that
 typically look like this.
 <pre>
-machine uat.urs.earthdata.nasa.gov login xxxxxx password yyyyyy
+machine mmmmmm login xxxxxx password yyyyyy
 </pre>
-where the machine is the one to which the client is redirected
-for authorization, and the login and password are those
-needed to authenticate.
+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.
 <p>
-The .netrc file can be specified in two ways.
-<ol>
-<li> Specify the netrc file to liboc using the procedure in oc.h:
-<pre>
-oc_set_netrc(OClink* link, const char* file)
-</pre>
-(This is equivalent to the -N flag to ocprint). 
-<p>
-<li> Put the following line in your .daprc/.dodsrc file.
+The .netrc file can be specified by
+putting the following line in your .daprc/.dodsrc file.
 <pre>
 HTTP.NETRC=<path to netrc file>
 </pre>
-</ol>
+
 <p>
-One final note. In using this, it is probable that you will
-need to specify a cookie jar (HTTP.COOKIEJAR) so that the
+One final note. In using this, it is almost certain that you will
+need to specify a real cookie jar file (HTTP.COOKIEJAR) so that the
 redirect site can pass back authorization information.
 
-<h2 class="break"><a name="URLCONS"><u>URL Constrained RC File Entries</u></a></h2> 
+<h2><a name="URLCONS">URL Constrained RC File Entries</a></h2> 
 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
+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.
@@ -205,8 +236,8 @@ Examples.
 or
 [fake.ucar.edu:9090]HTTP.VERBOSE=0
 </pre>
-If the url request from, say, the <i>oc_open</i> method
-has a host+port matchine one of the prefixes in the rc file, then
+If the url request from, say, the <i>netcdf_open</i> method
+has a host+port matching one of the prefixes in the rc file, then
 the corresponding entry will be used, otherwise ignored.
 <p>
 For example, the URL
@@ -221,7 +252,7 @@ http://fake.ucar.edu:9090/dts/test.01
 </pre>
 will have HTTP.VERBOSE set to 0.
 
-<h2 class="break"><a name="CLIENTCERTS"><u>Client-Side Certificates</u></a></h2> 
+<h2><a name="CLIENTCERTS">Client-Side Certificates</a></h2> 
 Some systems, notably ESG (Earth System Grid), requires
 the use of client-side certificates, as well as being
 <a href="#REDIR">re-direction based</a>.
@@ -236,8 +267,10 @@ This requires setting the following entries:
 </ul>
 Note that the first two are to support re-direction based authentication.
 
-<h5 class="break"><a name="allkeys"><u>Appendix A. All RC-File Keys</u></a></h5> 
+<h1 class="appendix><a name="allkeys">Appendix A. All RC-File Keys</a></h1> 
 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>curl_easy_setopt Option
 <tr valign="top"><td>HTTP.DEFLATE<td>CUROPT_DEFLATE<br>with value "deflate,gzip"
@@ -258,14 +291,23 @@ For completeness, this is the list of all rc-file keys.
 </table>
 </ul>
 
-<h5 class="break"><a name="ESGDETAIL"><u>Appendix B. ESG Access in Detail</u></a></h5> 
+<h1 class="appendix"><a name="URSDETAIL">Appendix B. URS Access in Detail</a></h1>
+It is possible to use the NASA Earthdata Login System (URS)
+with netcdf by using using the process specified in the 
+<a href="#REDIR">redirection</a> based authorization section.
+In order to access URS controlled datasets, however, it is necessary to
+register as a user with NASA at the
+<i>https://uat.urs.earthdata.nasa.gov/</i>
+website.
+
+<h1 class="appendix"><a name="ESGDETAIL">Appendix C. ESG Access in Detail</a></h1>
 It is possible to access Earth Systems Grid (ESG) datasets
-from ESG servers through the OC API using the techniques
+from ESG servers through the netCDF API using the techniques
 described in the section on <a href="#CLIENTCERTS">Client-Side Certificates</a>.
 <p>
 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 oc
+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
@@ -275,10 +317,10 @@ 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.
 <p>
-The oc library uses the <i>curl</i> library and it is that
+The netcdf library uses the <i>curl</i> library and it is that
 underlying library that must be properly configured.
 
-<h3><u>Terminology</u></h3>
+<h3>Terminology</h3>
 The key elements for client-side keys requires the constructions of
 two "stores" on the client side.
 <ul>
@@ -290,7 +332,7 @@ two "stores" on the client side.
 The server actually has a similar set of stores, but the client
 need not be concerned with those.
 
-<h3><u>Initial Steps</u></h3>
+<h3>Initial Steps</h3>
 
 The first step is to obtain authorization from ESG.
 Note that this information may evolve over time, and
@@ -318,7 +360,7 @@ to substitute as necessary.
    (read the whole page, it will help you understand the remaining steps).
 </ol>
 
-<h3><u>Building the KeyStore</u></h3>
+<h3>Building the KeyStore</h3>
 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:
@@ -332,7 +374,7 @@ The commands are these:
 Note, the file names "key.der" and "cert.der" can be whatever you choose.
 It is probably best to leave the .der extension, though.
 
-<h3><u>Building the TrustStore</u></h3>
+<h3>Building the TrustStore</h3>
 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
@@ -342,7 +384,7 @@ named "truststore"
   keytool -trustcacerts -storepass "password" -v -keystore "truststore"  -importcert -file "${c}"
 </pre>
 
-<h3><u>Running the C Client</u></h3>
+<h3>Running the C Client</h3>
 
 Refer to the section on <a href="#CLIENTCERTS">Client-Side Certificates</a>.
 The keys specified there  must be set in the rc file to support
@@ -369,7 +411,7 @@ redirects to a separate authentication server. When that
 server has authenticated the client, it redirects back to
 the original url to complete the request.
 
-<h3><u>Script for creating Stores</u></h3>
+<h3>Script for creating Stores</h3>
 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
diff --git a/docs/auth.md b/docs/auth.md
deleted file mode 100644
index 036e0d4..0000000
--- a/docs/auth.md
+++ /dev/null
@@ -1,489 +0,0 @@
-Authorization Support in the netCDF-C Libraries {#oc_auth}
-==================================================
-
-\brief It is possible to support a number of authorization schemes
-in the netCDF-C library.
-
-With one exception, authorization in the netCDF-C library is
-delegated to the oc2 code, which in turn delegates it to the
-libcurl library. The exception is that the location of the rc
-file can be specified by setting the environment variable *NCRCFILE*.
-Note that the value of this environment variable should be the
-absolute path of the rc file, not the path to its containing directory.
-
-Following is the authorization documentation.
-<center>
-
-OC Authorization Support {#oc_auth_support}
-========================
-
-Author: Dennis Heimbigner<br>
-dmh at ucar dot edu
-
-Draft: 11/21/2014<br>
-Last Revised: 12/23/2014<br>
-OC Version 2.1
-</center>
-
-## Table of Contents {#auth_toc}
-
-1.  [Introduction](#Introduction)
-2.  [URL-Based Authentication](#URL-AUTH)
-3.  [RC File Authentication](#DODSRC)
-4.  [Redirection-Based Authentication](#REDIR)
-5.  [URL Constrained RC File Entries](#URLCONS)
-6.  [Client-Side Certificates](#CLIENTCERTS)
-7.  [Appendix A. All RC-File Keys](#allkeys)
-8.  [Appendix B. ESG Access in Detail](#ESGDETAIL)
-
-## Introduction {#Introduction}
-
-OC can support user authorization using those provided by the curl
-library. This includes basic password authentication as well as
-certificate-based authorization.
-
-With some exceptions (e.g. see the section on [redirection](#REDIR)) 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 {#URL-AUTH}
-
-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](#REDIR)
-based authorization will not work with this.
-
-## RC File Authentication {#DODSRC}
-
-The oc library supports an *rc* file mechanism to allow the passing of a
-number of parameters to liboc and libcurl.
-
-The file must be called one of the following names: ".daprc", ".dodsrc"
-If both .daprc and .dodsrc exist, then the .daprc file will take
-precedence.
-
-Searching for the rc file first looks in the current directory and then
-in the home directory (as defined by the HOME environment variable). It
-is also possible to specify a direct path using the *-R* option to
-ocprint or using the *oc\_set\_rcfile* procedure (see oc.h). Note that
-for these latter cases, the path must be to the file itself, not to the
-containing directory.
-
-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 and will be discussed
-subsequently.
-
-The currently defined set of authorization-related keys are as follows.
-The second column is the affected curl\_easy\_setopt option(s).
-
-Key
-
-curl\_easy\_setopt Option
-
-HTTP.COOKIEJAR
-
-CURLOPT\_COOKIEJAR, CURLOPT\_COOKIEFILE
-
-HTTP.PROXY\_SERVER
-
-CURLOPT\_PROXY, CURLOPT\_PROXYPORT, CURLOPT\_PROXYUSERPWD
-
-HTTP.SSL.CERTIFICATE
-
-CURLOPT\_SSLCERT
-
-HTTP.SSL.KEY
-
-CURLOPT\_SSLKEY
-
-HTTP.SSL.KEYPASSWORD
-
-CURLOPT\_KEYPASSWORD
-
-HTTP.SSL.CAINFO
-
-CURLOPT\_SSLCAINFO
-
-HTTP.SSL.CAPATH
-
-CURLOPT\_SSLCAPATH
-
-HTTP.SSL.VERIFYPEER
-
-CURLOPT\_SSL\_VERIFYPEER
-
-HTTP.CREDENTIALS.USERPASSWORD
-
-CURLOPT\_USERPASSWORD
-
-### 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".
-
-### 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.
-
-### 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
-usually have the same value.
-
-HTTP.SSL.KEYPASSWORD specifies the password for accessing the
-HTTP.SSL.KEY/HTTP.SSL.CERTIFICATE 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 specified the url for accessing the proxy:
-(e.g.http://\[username:password@\]host\[:port\])
-
-## Redirection-Based Authentication {#REDIR}
-
-
-Some sites provide authentication by using a third party site to to the
-authentication. One example is
-[URS](https://uat.urs.earthdata.nasa.gov), the EOSDIS User Registration
-System.
-
-The process is usually as follows.
-
-1.  The client contacts the server of interest (SOI), the actual
-    data provider.
-2.  The SOI sends a redirect to the client to connect to the URS system.
-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.
-
-In order for this to work with libcurl, the client will usually need to
-provide a .netrc file so that the redirection will work correctly. The
-format of this .netrc file will contain content that typically look like
-this.
-
-    machine uat.urs.earthdata.nasa.gov login xxxxxx password yyyyyy
-
-where the machine is the one to which the client is redirected for
-authorization, and the login and password are those needed to
-authenticate.
-
-The .netrc file can be specified in two ways.
-
-1.  Specify the netrc file to liboc using the procedure in oc.h:
-
-        oc_set_netrc(OClink* link, const char* file)
-
-    (This is equivalent to the -N flag to ocprint).
-
-2.  Put the following line in your .daprc/.dodsrc file.
-
-        HTTP.NETRC=<path to netrc file>
-
-One final note. In using this, it is probable that you will need to
-specify a cookie jar (HTTP.COOKIEJAR) so that the redirect site can pass
-back authorization information.
-
-## URL Constrained RC File Entries {#URLCONS}
-
-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 *oc\_open* method has a host+port
-matchine one of the prefixes in the rc file, then the corresponding
-entry will be used, otherwise ignored.
-
-For example, the URL
-
-    http://remotetest.unidata.ucar.edu/thredds/dodsC/testdata/testData.nc
-
-will have HTTP.VERBOSE set to 1.
-
-Similarly,
-
-    http://fake.ucar.edu:9090/dts/test.01
-
-will have HTTP.VERBOSE set to 0.
-
-## 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 to support re-direction based
-authentication.
-
-## Appendix A. All RC-File Keys {#allkeys}
-
-For completeness, this is the list of all rc-file keys.
-
-Key
-
-curl\_easy\_setopt Option
-
-HTTP.DEFLATE
-
-CUROPT\_DEFLATE\
-with value "deflate,gzip"
-
-HTTP.VERBOSE
-
-CUROPT\_VERBOSE
-
-HTTP.TIMEOUT
-
-CUROPT\_TIMEOUT
-
-HTTP.USERAGENT
-
-CUROPT\_USERAGENT
-
-HTTP.COOKIEJAR
-
-CUROPT\_COOKIEJAR
-
-HTTP.COOKIE\_JAR
-
-CUROPT\_COOKIEJAR
-
-HTTP.PROXY\_SERVER
-
-CURLOPT\_PROXY,\
-CURLOPT\_PROXYPORT,\
-CURLOPT\_PROXYUSERPWD
-
-HTTP.SSL.CERTIFICATE
-
-CUROPT\_SSLCERT
-
-HTTP.SSL.KEY
-
-CUROPT\_SSLKEY
-
-HTTP.SSL.KEYPASSWORD
-
-CUROPT\_KEYPASSWORD
-
-HTTP.SSL.CAINFO
-
-CUROPT\_SSLCAINFO
-
-HTTP.SSL.CAPATH
-
-CUROPT\_SSLCAPATH
-
-HTTP.SSL.VERIFYPEER
-
-CUROPT\_SSL\_VERIFYPEER
-
-HTTP.CREDENTIALS.USERPASSWORD
-
-CUROPT\_USERPASSWORD
-
-HTTP.NETRC
-
-CURLOPT\_NETRC,CURLOPT\_NETRC\_FILE
-
-## Appendix B. ESG Access in Detail {#ESGDETAIL}
-
-It is possible to access Earth Systems Grid (ESG) datasets from ESG
-servers through the OC 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 oc 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.
-
-The oc 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:
-
-        https://ceda.ac.uk/openid/Firstname.Lastname
-
-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  -Dkeypassword="" -Dkeystore=./ 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, 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/auth.md.in b/docs/auth.md.in
deleted file mode 100644
index 8df4b79..0000000
--- a/docs/auth.md.in
+++ /dev/null
@@ -1,14 +0,0 @@
-Authorization Support in the netCDF-C Libraries {#oc_auth}
-==================================================
-
-\brief It is possible to support a number of authorization schemes
-in the netCDF-C library.
-
-With one exception, authorization in the netCDF-C library is
-delegated to the oc2 code, which in turn delegates it to the
-libcurl library. The exception is that the location of the rc
-file can be specified by setting the environment variable *NCRCFILE*.
-Note that the value of this environment variable should be the
-absolute path of the rc file, not the path to its containing directory.
-
-Following is the authorization documentation.
diff --git a/docs/cmake_faq.md b/docs/cmake_faq.md
index 1a1621e..8bce789 100644
--- a/docs/cmake_faq.md
+++ b/docs/cmake_faq.md
@@ -14,55 +14,56 @@ Below are a list of commonly-asked questions regarding NetCDF and CMake.
     This is controlled with the internal `cmake` option, `BUILD_SHARED_LIBS`.
 
         $ cmake [Source Directory] -DBUILD_SHARED_LIBS=[ON/OFF]
-	
+
 
 ## Can I build both shared and static libraries at the same time with cmake? {#sharedstaticboth}
 
     Not at this time; it is required to instead build first one version, and then the other, if you need both.
 
+    ## What if I want to link against multiple libraries in a non-standard location? {#nonstdloc}
+
+        You can specify the path to search when looking for dependencies and header files using the `CMAKE_PREFIX_PATH` variable:
+
+    * Windows:
+
+            $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=c:\shared\libs\
+
+
+    * Linux/Unix/OSX:
+
+            $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=/usr/custom_library_locations/		
+
+
 ## How can I specify linking against a particular library? {#partlib}
 
     It depends on the library.  To specify a custom `ZLib`, for example, you would do the following:
-		
+
         $ cmake [Source Directory] -DZLIB_LIBRARY=/path/to/my/zlib.lib
-        
+
 
     `HDF5` is more complex, since it requires both the `hdf5` and `hdf5_hl` libraries. You would specify custom `HDF5` libraries as follows:
-		
+
         $ cmake [Source Directory] -DHDF5_LIB=/path/to/hdf5.lib \
             -DHDF5_HL_LIB=/path/to/hdf5_hl.lib \
             -DHDF5_INCLUDE_DIR=/path/to/hdf5/include
 
 
     Alternatively, you may specify:
-		
+
         $ cmake [Source Directory] \
             -DHDF5_LIBRARIES="/path/to/hdf5.lib;/path/to/hdf5_hl.lib" \
-            -DHDF5_INCLUDE_DIRS=/path/to/hdf5/include/
-		
-## What if I want to link against multiple libraries in a non-standard location? {#nonstdloc}
-
-    You can specify the path to search when looking for dependencies and header files using the `CMAKE_PREFIX_PATH` variable:
-	
-* Windows:	
-    
-        $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=c:\shared\libs\
-	
-		
-* Linux/Unix/OSX:
-
-        $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=/usr/custom_library_locations/		
-		
+            -DHDF5_INCLUDE_DIR=/path/to/hdf5/include/
+
 
 ## How can I specify a Parallel Build using HDF5 {#parallelhdf}
-	
+
     If cmake is having problems finding the parallel `HDF5` install, you can specify the location manually:
 
-	
+
         $ cmake [Source Directory] -DENABLE_PARALLEL=ON \
             -DHDF5_LIB=/usr/lib64/openmpi/lib/libhdf5.so \
             -DHDF5_HL_LIB=/usr/lib64/openmpi/lib/libhdf5.hl.so \
             -DHDF5_INCLUDE_DIR=/usr/include/openmpi-x86_64 \
-		
+
 
     You will, of course, need to use the location of the libraries specific to your development environment.
diff --git a/docs/esg.html b/docs/esg.html
index 6bef0a4..fe094dc 100644
--- a/docs/esg.html
+++ b/docs/esg.html
@@ -1,3 +1,4 @@
+<!-- obsolete -->
 <html><!-- InstanceBegin template="/Templates/MyUnidata.dwt" codeOutsideHTMLIsLocked="true" -->
 <!-- This document is kept in netcdf-c/docs;
      it is not normally included in the distribution.
diff --git a/docs/file_format_specifications.md b/docs/file_format_specifications.md
index 972e757..b00dd0c 100644
--- a/docs/file_format_specifications.md
+++ b/docs/file_format_specifications.md
@@ -477,7 +477,7 @@ sets these when creating a group.
 
 Each dataset in the HDF5 file must be created with a property list for
 which the attribute creation order has been set to creation
-ordering. The H5Pset_attr_creation_order funtion is used to set the
+ordering. The H5Pset_attr_creation_order function is used to set the
 creation ordering of attributes of a variable.
 
 The following example code (from libsrc4/nc4hdf.c) shows how the
@@ -511,7 +511,7 @@ Until version 1.8, HDF5 did not have any capability to represent
 shared dimensions. With the 1.8 release, HDF5 introduced the dimension
 scale feature to allow shared dimensions in HDF5 files.
 
-The dimension scale is unfortunately not exactly equivilent to the
+The dimension scale is unfortunately not exactly equivalent to the
 netCDF shared dimension, and this leads to a number of compromises in
 the design of netCDF-4.
 
diff --git a/docs/guide.dox b/docs/guide.dox
index a9c4362..581ffd2 100644
--- a/docs/guide.dox
+++ b/docs/guide.dox
@@ -1630,24 +1630,17 @@ NF_SET_VAR_CHUNK_CACHE, ).
 
 \section default_chunking_4_1 The Default Chunking Scheme
 
-When the data writer does not specify chunk sizes for variable, the
-netCDF library has to come up with some default values.
-
-For unlimited dimensions, a chunk size of one is always used. For
-large datasets, where the size of fixed dimensions is small compared
-to the unlimited dimensions, users are advised to avoid unlimited
-dimensions or to increase the chunk sizes of the unlimited
-dimensions. Be aware that an unlimited dimension with chunksize > 1
-may result in slower performance for record-oriented access patterns
-that where common with netcdf-3.
-
-For unlimited dimensions, a chunk size of one is always used. For
-large datasets, where the size of fixed dimensions is small compared
-to the unlimited dimensions, users are advised to avoid unlimited
-dimensions or to increase the chunk sizes of the unlimited
-dimensions. Be aware that an unlimited dimension with chunksize > 1
-may result in slower performance for record-oriented access patterns
-that where common with netcdf-3.
+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.
+
+The size and shape of chunks for each individual variable are determined at creation time by the size of each variable element and by the shape of the variable, specified by the ordered list of its dimensions and the lengths of each dimension, with special rules for unlimited dimensions.
+
+The best default chunk size would be as large as possible without exceeding the size of a physical disk access. However, block sizes differ for different file systems and platforms, and in particular may be different when the data is first written and later read. Currently the netCDF default chunk size is 4MiB, which is reasonable for filesystems on high-performance computing platforms. A different default may be specified at configuration time when building the library from source, for  [...]
+
+The current default chunking strategy of the netCDF library is to balance access time along any of a variable's dimensions, by using chunk shapes similar to the shape of the entire variable but small enough that the resulting chunk size is less than or equal to the default chunk size. This differs from an earlier default chunking strategy that always used one for the length of a chunk along any unlimited dimension, and otherwise divided up the number of chunks along fixed dimensions to k [...]
+
+A pragmatic exception to the default strategy is used for variables that only have a single unlimited dimension, for example time series with only a time dimension. In that case, in order to avoid chunks much larger than needed when there are only a small number of records, the chunk sizes for such variables are limited to 4KiB. This may be overridden by explicitly setting the chunk shapes for such variables.
 
 \section chunking_parallel_io Chunking and Parallel I/O
 
@@ -2755,6 +2748,7 @@ The -k file specifies the kind of netCDF file to generate. The
 arguments to the -k flag can be as follows.
         'classic', 'nc3' – Produce a netcdf classic file format file.
         '64-bit offset', 'nc6' – Produce a netcdf 64 bit classic file format file.
+        '64-bit data (CDF-5), 'nc5' – Produce a CDF-5 format file.
         'netCDF-4', 'nc4' – Produce a netcdf-4 format file.
         'netCDF-4 classic model', 'nc7' – Produce a netcdf-4 file format, but restricted to netcdf-3 classic CDL input.
 
@@ -2768,6 +2762,7 @@ still accepted but deprecated, due to easy confusion between format
 numbers and format names. Various old format name aliases are also
 accepted but deprecated, e.g. 'hdf5', 'enhanced-nc3', for 'netCDF-4'.
 
+
 -l
 The -l file specifies that ncgen should output (to standard output)
 the text of a program that, when compiled and executed, will produce
@@ -2821,7 +2816,7 @@ programs.
 UNIX syntax for invoking ncgen3:
 
 \code
-     ncgen3 [-b] [-o netcdf-file] [-c] [-f] [-v2|-v3] [-x] [input-file]
+     ncgen3 [-b] [-o netcdf-file] [-c] [-f] [-v2|-v3|-v5] [-x] [input-file]
 \endcode
 
 where:
@@ -2864,6 +2859,12 @@ The generated netCDF file will be in netCDF-4/HDF5 format. These files
 are not as portable as classic format netCDF files, because they
 require version 4.0 or later of the netCDF library.
 
+-v5
+The generated netCDF file or program will use the version of the
+format with 64-bit integers, to allow for the creation of very large
+variables. These files are not as portable as classic format netCDF files,
+because they require version 4.4.0 or later of the netCDF library.
+
 -x
 Use “no fill” mode, omitting the initialization of variable values
 with fill values. This can make the creation of large files much
diff --git a/docs/images/Makefile.in b/docs/images/Makefile.in
index 8370448..ed2d52f 100644
--- a/docs/images/Makefile.in
+++ b/docs/images/Makefile.in
@@ -172,6 +172,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -204,6 +205,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -215,6 +217,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/docs/internal.dox b/docs/internal.dox
index 3721b1a..0eda133 100644
--- a/docs/internal.dox
+++ b/docs/internal.dox
@@ -132,7 +132,7 @@ adding something like the following.
 
 \section dispatch_step7 Step 7.
 
-Modify the NC_intialize function in liblib/stub.c by adding
+Modify the NC_initialize function in liblib/stub.c by adding
 appropriate references to the NCM dispatch function.
 
 \code
diff --git a/docs/netcdf.m4 b/docs/netcdf.m4
index e37fb36..2baa478 100644
--- a/docs/netcdf.m4
+++ b/docs/netcdf.m4
@@ -7,12 +7,12 @@ define(<<CODE>>, <<\fB$1\fR>>)
 
 define(<<ARG>>, <<\fI$1\fP>>)
 
-define(<<HEADER_FILE>>, 
+define(<<HEADER_FILE>>,
     <<ifelse(API,C,
 	$1.h,
 	$1.inc)>>)
 
-define(<<INCLUDE>>, 
+define(<<INCLUDE>>,
     <<ifelse(API,C,
 	<<#include>> "HEADER_FILE($1)",
 	<<<<include>>>> HEADER_FILE($1))>>)
@@ -76,7 +76,7 @@ dnl CSTAR(io, rank)
 define(<<CSTAR>>, <<ifelse($1,input,,<<ifelse($2,0,*)>>)>>)
 
 dnl FTYPE(type, rank)
-define(<<FTYPE>>, 
+define(<<FTYPE>>,
     <<ifelse($1,text,<<character*ifelse($2,0,1,(*))>>,
     <<ifelse($1,schar,integer*1,
     <<ifelse($1,short,integer*2,
@@ -99,12 +99,12 @@ define(<<FTYPE>>,
 
 dnl ATYPE(io,rank,type)
 define(<<ATYPE>>, <<ifelse(API,C,
-    <<CTYPE($3)<<>>CSTAR($1,$2)>>, 
+    <<CTYPE($3)<<>>CSTAR($1,$2)>>,
     <<FTYPE($3,$2)>>)>>)
 
 dnl AID(name, rank, type)
 define(<<AID>>, <<ARG($1)<<>>ifelse(API,C,
-    <<ifelse($2,0,,[])>>, 
+    <<ifelse($2,0,,[])>>,
     <<ifelse($3,text,,<<ifelse($2,0,,(1))>>)>>)>>)
 
 dnl ADECL(io, rank, type, name)
@@ -206,7 +206,7 @@ define(<<OVOIDP>>,	<<ADECL(output,0,voidp,$1)>>)
 define(<<OVOIDPV>>,	<<ADECL(output,1,voidp,$1)>>)
 
 dnl CCOMP(type)
-define(<<CCOMP>>, 
+define(<<CCOMP>>,
     <<ifelse($1,text,text,
     <<ifelse($1,uchar,uchar,
     <<ifelse($1,schar,schar,
@@ -225,7 +225,7 @@ define(<<CCOMP>>,
 )>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)
 
 dnl FCOMP(type)
-define(<<FCOMP>>, 
+define(<<FCOMP>>,
     <<ifelse($1,text,text,
     <<ifelse($1,schar,int1,
     <<ifelse($1,short,int2,
@@ -244,7 +244,7 @@ dnl COMP(type)
 define(<<COMP>>, <<ifelse(API,C,<<CCOMP($1)>>,<<FCOMP($1)>>)>>)
 
 define(<<FDECL_TYPE>>,
-    <<ifelse(API,C, 
+    <<ifelse(API,C,
 	int,
 	integer function)>>)
 
@@ -345,7 +345,7 @@ define(<<VARIDIN>>, <<ARG(varid_in)>>)
 define(<<VARIDOUT>>, <<ARG(varid_out)>>)
 define(<<XTYPE>>, <<ARG(xtype)>>)
 
-define(<<UPCASE>>, 
+define(<<UPCASE>>,
 <<translit($1,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ)>>)
 
 dnl Variable "Put" Functions:
@@ -462,7 +462,7 @@ FREF(inq_libvers) and FREF(strerror)) return an integer status.
 
 If this returned status value is not equal to
 MACRO(NOERR) (zero), it
-indicates that an error occurred. The possible status values are defined in 
+indicates that an error occurred. The possible status values are defined in
 ifelse(API,C, system <<<<include>>>> file <errno.h> and in )<<>>dnl
 ifelse(API,C,")HEADER_FILE(netcdf)<<>>ifelse(API,C,").
 .HP
@@ -492,11 +492,11 @@ When a netCDF dataset is created, is is opened
 MACRO(WRITE).
 The new netCDF dataset is in <<define>> mode.
 MACRO(64BIT_OFFSET).
-to create a file in the 64-bit offset format 
-(as opposed to classic format, the default). 
+to create a file in the 64-bit offset format
+(as opposed to classic format, the default).
 ifelse(NETCDF4,TRUE,
-<<MACRO(NETCDF4) to create a netCDF-4/HDF5 file, 
-and MACRO(CLASSIC_MODEL) to guarantee that netCDF-4/HDF5 files maintain compatibility 
+<<MACRO(NETCDF4) to create a netCDF-4/HDF5 file,
+and MACRO(CLASSIC_MODEL) to guarantee that netCDF-4/HDF5 files maintain compatibility
 with the netCDF classic data model.>>,
 .
 )
@@ -549,7 +549,7 @@ The actual value chosen is returned by reference.
 Using the value MACRO(SIZEHINT_DEFAULT) causes the library to choose a
 default.
 How the system choses the default depends on the system.
-On many systems, the "preferred I/O block size" is available from the 
+On many systems, the "preferred I/O block size" is available from the
 CODE(stat()) system call, CODE(struct stat) member CODE(st_blksize).
 If this is available it is used. Lacking that, twice the system pagesize
 is used.
@@ -567,8 +567,8 @@ FDECL(redef, (INCID()))
 .sp
 (Corresponds to FOLD(redef, redf) in version 2)
 .sp
-Puts an open netCDF dataset into <<define>> mode, 
-so dimensions, variables, and attributes can be added or renamed and 
+Puts an open netCDF dataset into <<define>> mode,
+so dimensions, variables, and attributes can be added or renamed and
 attributes can be deleted.
 .HP
 FDECL(enddef, (INCID()))
@@ -706,7 +706,7 @@ UNLIMDIMID() will contain the
 dimension ID of the unlimited dimension if one exists, or
 ifelse(API,C, <<\-1>>, <<0>>) otherwise.
 FORMATN() will contain the version number of the dataset <format>, one of
-MACRO(FORMAT_CLASSIC), MACRO(FORMAT_64BIT), MACRO(FORMAT_NETCDF4), or
+MACRO(FORMAT_CLASSIC), MACRO(FORMAT_64BIT_OFFSET), MACRO(FORMAT_NETCDF4), or
 MACRO(FORMAT_NETCDF4_CLASSIC).
 ifelse(API,C,
 <<If any of the
@@ -717,7 +717,7 @@ FDECL(def_dim, (INCID(), INAME(), ILEN(), ODIMID()))
 .sp
 (Corresponds to FOLD(dimdef, ddef) in version 2)
 .sp
-Adds a new dimension to an open netCDF dataset, which must be 
+Adds a new dimension to an open netCDF dataset, which must be
 in <<define>> mode.
 NAME() is the dimension name.
 ifelse(API,C,dnl
@@ -743,7 +743,7 @@ FDECL(insert_compound, (INCID(), INCTYPE(), INAME(), ISIZET(offset), INCTYPE(fie
 Insert an element into a compound type. May not be done after type has been used, or after the type has been written by an enddef.
 .HP
 FDECL(insert_array_compound, (INCID(), INCTYPE(), INAME(), ISIZET(offset), INCTYPE(field_typeid), INDIMS(), IINTV(dim_sizes)))
-.sp 
+.sp
 Insert an array into a compound type.
 .HP
 FDECL(inq_type, (INCID(), INCTYPE(), ONAME(), OSIZET(sizep)))
@@ -894,7 +894,7 @@ FDECL(rename_dim, (INCID(), IDIMID(), INAME()))
 (Corresponds to FOLD(dimrename, dren) in version 2)
 .sp
 Renames an existing dimension in an open netCDF dataset.
-If the new name is longer than the old name, the netCDF dataset must be in 
+If the new name is longer than the old name, the netCDF dataset must be in
 <<define>> mode.
 You cannot rename a dimension to have the same name as another dimension.
 .SH "VARIABLES"
@@ -1004,7 +1004,7 @@ converted to integers.
 FUNC_FAMILY(<<GET_VAR>>)
 .sp
 Reads an entire netCDF variable (i.e. all the values).
-The netCDF dataset must be open and in data mode.  
+The netCDF dataset must be open and in data mode.
 The data is converted from the external type of the specified variable,
 if necessary, to the type specified in the function name.  If conversion is
 not possible, an MACRO(ERANGE) error is returned.
@@ -1020,7 +1020,7 @@ error is returned.
 FUNC_FAMILY(<<GET_VAR1>>)
 .sp
 Gets a single data value from a variable at the position INDEX()
-of an open netCDF dataset that is in data mode.  
+of an open netCDF dataset that is in data mode.
 The data is converted from the external type of the specified variable,
 if necessary, to the type specified in the function name.  If conversion is
 not possible, an MACRO(ERANGE) error is returned.
@@ -1058,7 +1058,7 @@ vector, see COMMON ARGUMENTS DESCRIPTIONS below.
 FUNC_FAMILY(<<GET_VARS>>)
 .sp
 These functions are used for \fIstrided input\fP, which is like the
-array section input described above, except that 
+array section input described above, except that
 the sampling stride (the interval between accessed values) is
 specified for each dimension.
 For an explanation of the sampling stride
@@ -1089,7 +1089,7 @@ FDECL(put_att, (INCID(), IVARID(), INAME(), INCTYPE(xtype), ISIZET(len), IVOIDP(
 .HP
 FDECL(get_att, (INCID(), IVARID(), INAME(), OVOIDP(ip)))
 .sp
-Unlike variables, attributes do not have 
+Unlike variables, attributes do not have
 separate functions for defining and writing values.
 This family of functions defines a new attribute with a value or changes
 the value of an existing attribute.
@@ -1106,7 +1106,7 @@ the in-memory type of the value, whereas the XTYPE() argument refers to the
 external type for storing the value.  An MACRO(ERANGE)
 error results if
 a conversion between these types is not possible.  In this case the value
-is represented with the appropriate fill-value for the associated 
+is represented with the appropriate fill-value for the associated
 external type.
 .HP
 FDECL(inq_attname, (INCID(), IVARID(), IATTNUM(), ONAME()))
@@ -1158,7 +1158,7 @@ for a global attribute.
 NAME()
 is the name of the attribute in the input netCDF dataset to be copied.
 NCIDOUT()
-is the netCDF ID of the output netCDF dataset to which the attribute will be 
+is the netCDF ID of the output netCDF dataset to which the attribute will be
 copied.
 It is permissible for the input and output netCDF ID's to be the same.  The
 output netCDF dataset should be in <<define>> mode if the attribute to be
@@ -1197,7 +1197,7 @@ FREF(inq_attlen)
 first to find out the length of the attribute.
 .SH "COMMON ARGUMENT DESCRIPTIONS"
 .LP
-In this section we <<define>> some common arguments which are used in the 
+In this section we <<define>> some common arguments which are used in the
 "FUNCTION DESCRIPTIONS" section.
 .TP
 INCID()
@@ -1205,23 +1205,23 @@ is the netCDF ID returned from a previous, successful call to
 FREF(open) or FREF(create)
 .TP
 ONAME()
-is the name of a dimension, variable, or attribute. The names of 
+is the name of a dimension, variable, or attribute. The names of
 dimensions, variables and attributes consist of arbitrary
 sequences of alphanumeric characters (as well as underscore '_',
 period '.' and hyphen '-'), beginning with a letter or
 underscore. (However names commencing with underscore are reserved for
 system use.) Case is significant in netCDF names. A zero-length name
 is not allowed.
-ifelse(API,C,<<As an input argument, 
-it shall be a pointer to a 0-terminated string; as an output argument, it 
+ifelse(API,C,<<As an input argument,
+it shall be a pointer to a 0-terminated string; as an output argument, it
 shall be the address of a buffer in which to hold such a string.>>)
-The maximum allowable number of characters 
+The maximum allowable number of characters
 ifelse(API,C,(excluding the terminating 0)) is MACRO(MAX_NAME).
 .TP
 IXTYPE()
 specifies the external data type of a netCDF variable or attribute and
 is one of the following:
-MACRO(BYTE), MACRO(CHAR), MACRO(SHORT), MACRO(INT), 
+MACRO(BYTE), MACRO(CHAR), MACRO(SHORT), MACRO(INT),
 MACRO(FLOAT), or MACRO(DOUBLE).
 These are used to specify 8-bit integers,
 characters, 16-bit integers, 32-bit integers, 32-bit IEEE floating point
@@ -1247,22 +1247,22 @@ MACRO(MAX_VAR_DIMS).
 .TP
 IDIMID()
 is the ID of a netCDF dimension.
-netCDF dimension ID's are allocated sequentially from the 
+netCDF dimension ID's are allocated sequentially from the
 ifelse(API,C,non-negative, positive)
 integers beginning with ifelse(API,C,0,1).
 .TP
 INDIMS()
 is either the total number of dimensions in a netCDF dataset or the rank
 (i.e. the number of dimensions) of a netCDF variable.
-The value shall not be negative or greater than the symbolic constant 
+The value shall not be negative or greater than the symbolic constant
 MACRO(MAX_VAR_DIMS).
 .TP
 IVARID()
-is the ID of a netCDF variable or (for the attribute-access functions) 
+is the ID of a netCDF variable or (for the attribute-access functions)
 the symbolic constant
 MACRO(GLOBAL),
 which is used to reference global attributes.
-netCDF variable ID's are allocated sequentially from the 
+netCDF variable ID's are allocated sequentially from the
 ifelse(API,C,non-negative,positive)
 integers beginning with ifelse(API,C,0,1).
 .TP
@@ -1286,7 +1286,7 @@ variable's dimensions.
 ISTART()
 specifies the starting point
 for accessing a netCDF variable's data values
-in terms of the indicial coordinates of 
+in terms of the indicial coordinates of
 the corner of the array section.
 The indices start at ifelse(API,C,0,1);
 thus, the first data
@@ -1301,7 +1301,7 @@ array section.
 Thus, to access a single value, for example, specify COUNT() as
 (1, 1, ..., 1).
 Note that, for strided I/O, this argument must be adjusted
-to be compatible with the STRIDE() and START() arguments so that 
+to be compatible with the STRIDE() and START() arguments so that
 the interaction of the
 three does not attempt to access an invalid data co-ordinate.
 The elements of the
@@ -1311,7 +1311,7 @@ ISTRIDE()
 specifies the sampling interval along each dimension of the netCDF
 variable.   The elements of the stride vector correspond, in order,
 to the netCDF variable's dimensions (ARG(stride)<<>>ifelse(API,C,[0],<<(1)>>))
-gives the sampling interval along the most ifelse(API,C,slowly,rapidly) 
+gives the sampling interval along the most ifelse(API,C,slowly,rapidly)
 varying dimension of the netCDF variable).  Sampling intervals are
 specified in type-independent units of elements (a value of 1 selects
 consecutive elements of the netCDF variable along the corresponding
@@ -1334,7 +1334,7 @@ the same structure as the associated netCDF variable.>>)
 .LP
 By default, the netCDF interface sets the values of
 all newly-defined variables of finite length (i.e. those that do not have
-an unlimited, dimension) to the type-dependent fill-value associated with each 
+an unlimited, dimension) to the type-dependent fill-value associated with each
 variable.  This is done when FREF(enddef)
 is called.  The
 fill-value for a variable may be changed from the default value by
@@ -1363,14 +1363,14 @@ For variables that
 use the unlimited dimension, this call
 may be made at any time.
 .LP
-One can obtain increased performance of the netCDF interface by using 
+One can obtain increased performance of the netCDF interface by using
 this feature, but only at the expense of requiring the application to set
 every single data value.  The performance
 enhancing behavior of this function is dependent on the particulars of
 the implementation and dataset <<format>>.
 The flag value controlled by FREF(set_fill)
 is per netCDF ID,
-not per variable or per write. 
+not per variable or per write.
 Allowing this to change affects the degree to which
 a program can be effectively parallelized.
 Given all of this, we state that the use
@@ -1383,7 +1383,7 @@ ifelse(API,C,
 <<.sp
 (Corresponds to FOLD(setfill) in version 2)>>)
 .sp
-Determines whether or not variable prefilling will be done (see 
+Determines whether or not variable prefilling will be done (see
 above).
 The netCDF dataset shall be writable.
 FILLMODE() is either MACRO(FILL)
@@ -1397,7 +1397,7 @@ ifelse(PARALLEL_IO,TRUE,
 .HP
 FDECL(create_par, (IPATH(), ICMODE(), MPI_Comm comm, MPI_Info info, ONCID()))
 .sp
-Like FREF(create) but creates for parallel I/O access. The mode must specify a 
+Like FREF(create) but creates for parallel I/O access. The mode must specify a
 netCDF-4/HDF5 dataset.
 .sp
 .HP
@@ -1458,8 +1458,8 @@ under only the most extreme cases.
 Specifies the Flexible File I/O buffers for netCDF I/O when executing
 under the UNICOS operating system (the variable is ignored on other
 operating systems).
-An appropriate specification can greatly increase the efficiency of 
-netCDF I/O -- to the extent that it can actually surpass FORTRAN binary 
+An appropriate specification can greatly increase the efficiency of
+netCDF I/O -- to the extent that it can actually surpass FORTRAN binary
 I/O.
 This environment variable has been made a little more generalized,
 such that other FFIO option specifications can now be added.
diff --git a/docs/ocauth.md b/docs/ocauth.md
deleted file mode 100644
index 5b04663..0000000
--- a/docs/ocauth.md
+++ /dev/null
@@ -1,475 +0,0 @@
-<center>
-
-OC Authorization Support {#oc_auth_support}
-========================
-
-Author: Dennis Heimbigner<br>
-dmh at ucar dot edu
-
-Draft: 11/21/2014<br>
-Last Revised: 12/23/2014<br>
-OC Version 2.1
-</center>
-
-## Table of Contents {#auth_toc}
-
-1.  [Introduction](#Introduction)
-2.  [URL-Based Authentication](#URL-AUTH)
-3.  [RC File Authentication](#DODSRC)
-4.  [Redirection-Based Authentication](#REDIR)
-5.  [URL Constrained RC File Entries](#URLCONS)
-6.  [Client-Side Certificates](#CLIENTCERTS)
-7.  [Appendix A. All RC-File Keys](#allkeys)
-8.  [Appendix B. ESG Access in Detail](#ESGDETAIL)
-
-## Introduction {#Introduction}
-
-OC can support user authorization using those provided by the curl
-library. This includes basic password authentication as well as
-certificate-based authorization.
-
-With some exceptions (e.g. see the section on [redirection](#REDIR)) 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 {#URL-AUTH}
-
-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](#REDIR)
-based authorization will not work with this.
-
-## RC File Authentication {#DODSRC}
-
-The oc library supports an *rc* file mechanism to allow the passing of a
-number of parameters to liboc and libcurl.
-
-The file must be called one of the following names: ".daprc", ".dodsrc"
-If both .daprc and .dodsrc exist, then the .daprc file will take
-precedence.
-
-Searching for the rc file first looks in the current directory and then
-in the home directory (as defined by the HOME environment variable). It
-is also possible to specify a direct path using the *-R* option to
-ocprint or using the *oc\_set\_rcfile* procedure (see oc.h). Note that
-for these latter cases, the path must be to the file itself, not to the
-containing directory.
-
-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 and will be discussed
-subsequently.
-
-The currently defined set of authorization-related keys are as follows.
-The second column is the affected curl\_easy\_setopt option(s).
-
-Key
-
-curl\_easy\_setopt Option
-
-HTTP.COOKIEJAR
-
-CURLOPT\_COOKIEJAR, CURLOPT\_COOKIEFILE
-
-HTTP.PROXY\_SERVER
-
-CURLOPT\_PROXY, CURLOPT\_PROXYPORT, CURLOPT\_PROXYUSERPWD
-
-HTTP.SSL.CERTIFICATE
-
-CURLOPT\_SSLCERT
-
-HTTP.SSL.KEY
-
-CURLOPT\_SSLKEY
-
-HTTP.SSL.KEYPASSWORD
-
-CURLOPT\_KEYPASSWORD
-
-HTTP.SSL.CAINFO
-
-CURLOPT\_SSLCAINFO
-
-HTTP.SSL.CAPATH
-
-CURLOPT\_SSLCAPATH
-
-HTTP.SSL.VERIFYPEER
-
-CURLOPT\_SSL\_VERIFYPEER
-
-HTTP.CREDENTIALS.USERPASSWORD
-
-CURLOPT\_USERPASSWORD
-
-### 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".
-
-### 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.
-
-### 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
-usually have the same value.
-
-HTTP.SSL.KEYPASSWORD specifies the password for accessing the
-HTTP.SSL.KEY/HTTP.SSL.CERTIFICATE 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 specified the url for accessing the proxy:
-(e.g.http://\[username:password@\]host\[:port\])
-
-## Redirection-Based Authentication {#REDIR}
-
-
-Some sites provide authentication by using a third party site to to the
-authentication. One example is
-[URS](https://uat.urs.earthdata.nasa.gov), the EOSDIS User Registration
-System.
-
-The process is usually as follows.
-
-1.  The client contacts the server of interest (SOI), the actual
-    data provider.
-2.  The SOI sends a redirect to the client to connect to the URS system.
-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.
-
-In order for this to work with libcurl, the client will usually need to
-provide a .netrc file so that the redirection will work correctly. The
-format of this .netrc file will contain content that typically look like
-this.
-
-    machine uat.urs.earthdata.nasa.gov login xxxxxx password yyyyyy
-
-where the machine is the one to which the client is redirected for
-authorization, and the login and password are those needed to
-authenticate.
-
-The .netrc file can be specified in two ways.
-
-1.  Specify the netrc file to liboc using the procedure in oc.h:
-
-        oc_set_netrc(OClink* link, const char* file)
-
-    (This is equivalent to the -N flag to ocprint).
-
-2.  Put the following line in your .daprc/.dodsrc file.
-
-        HTTP.NETRC=<path to netrc file>
-
-One final note. In using this, it is probable that you will need to
-specify a cookie jar (HTTP.COOKIEJAR) so that the redirect site can pass
-back authorization information.
-
-## URL Constrained RC File Entries {#URLCONS}
-
-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 *oc\_open* method has a host+port
-matchine one of the prefixes in the rc file, then the corresponding
-entry will be used, otherwise ignored.
-
-For example, the URL
-
-    http://remotetest.unidata.ucar.edu/thredds/dodsC/testdata/testData.nc
-
-will have HTTP.VERBOSE set to 1.
-
-Similarly,
-
-    http://fake.ucar.edu:9090/dts/test.01
-
-will have HTTP.VERBOSE set to 0.
-
-## 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 to support re-direction based
-authentication.
-
-## Appendix A. All RC-File Keys {#allkeys}
-
-For completeness, this is the list of all rc-file keys.
-
-Key
-
-curl\_easy\_setopt Option
-
-HTTP.DEFLATE
-
-CUROPT\_DEFLATE\
-with value "deflate,gzip"
-
-HTTP.VERBOSE
-
-CUROPT\_VERBOSE
-
-HTTP.TIMEOUT
-
-CUROPT\_TIMEOUT
-
-HTTP.USERAGENT
-
-CUROPT\_USERAGENT
-
-HTTP.COOKIEJAR
-
-CUROPT\_COOKIEJAR
-
-HTTP.COOKIE\_JAR
-
-CUROPT\_COOKIEJAR
-
-HTTP.PROXY\_SERVER
-
-CURLOPT\_PROXY,\
-CURLOPT\_PROXYPORT,\
-CURLOPT\_PROXYUSERPWD
-
-HTTP.SSL.CERTIFICATE
-
-CUROPT\_SSLCERT
-
-HTTP.SSL.KEY
-
-CUROPT\_SSLKEY
-
-HTTP.SSL.KEYPASSWORD
-
-CUROPT\_KEYPASSWORD
-
-HTTP.SSL.CAINFO
-
-CUROPT\_SSLCAINFO
-
-HTTP.SSL.CAPATH
-
-CUROPT\_SSLCAPATH
-
-HTTP.SSL.VERIFYPEER
-
-CUROPT\_SSL\_VERIFYPEER
-
-HTTP.CREDENTIALS.USERPASSWORD
-
-CUROPT\_USERPASSWORD
-
-HTTP.NETRC
-
-CURLOPT\_NETRC,CURLOPT\_NETRC\_FILE
-
-## Appendix B. ESG Access in Detail {#ESGDETAIL}
-
-It is possible to access Earth Systems Grid (ESG) datasets from ESG
-servers through the OC 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 oc 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.
-
-The oc 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:
-
-        https://ceda.ac.uk/openid/Firstname.Lastname
-
-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  -Dkeypassword="" -Dkeystore=./ 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, 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/old/netcdf-cxx4.texi b/docs/old/netcdf-cxx4.texi
index f409528..c5382a4 100755
--- a/docs/old/netcdf-cxx4.texi
+++ b/docs/old/netcdf-cxx4.texi
@@ -147,7 +147,7 @@ attributes are discussed.
 
 @node Class Hierarchy, Auxiliary Types and Constants, Introduction, Introduction
 @unnumberedsec Class Hierarchy
- at cindex class hierachy
+ at cindex class hierarchy
 
 The class for netCDF file objects is @code{NcFile}.
 
diff --git a/docs/old/netcdf-f77.texi b/docs/old/netcdf-f77.texi
index 8b4a685..7d57b95 100644
--- a/docs/old/netcdf-f77.texi
+++ b/docs/old/netcdf-f77.texi
@@ -2218,7 +2218,7 @@ group.
 
 Variable are only visible in the group in which they are defined. The
 same applies to attributes. ``Global'' attributes are defined in
-whichever group is refered to by the ncid. 
+whichever group is referred to by the ncid. 
 
 Dimensions are visible in their groups, and all child groups.
 
@@ -3775,7 +3775,7 @@ Insert a named field into a compound type.
 @heading Usage 
 
 @example
-INTEGER FUNTION NF_INSERT_COMPOUND(INTEGER TYPEID, CHARACTER*(*) NAME, INTEGER OFFSET, 
+INTEGER FUNCTION NF_INSERT_COMPOUND(INTEGER TYPEID, CHARACTER*(*) NAME, INTEGER OFFSET, 
         INTEGER FIELD_TYPEID)
 @end example
 
@@ -3959,7 +3959,7 @@ C     Include an array.
 Get the number of fields, length in bytes, and name of a compound
 type.
 
-In addtion to the NF_INQ_COMPOUND function, three additional functions
+In addition to the NF_INQ_COMPOUND function, three additional functions
 are provided which get only the name, size, and number of fields.
 
 @heading Usage 
diff --git a/docs/old/netcdf-f90.texi b/docs/old/netcdf-f90.texi
index dc10b4a..335132d 100755
--- a/docs/old/netcdf-f90.texi
+++ b/docs/old/netcdf-f90.texi
@@ -1731,7 +1731,7 @@ group.
 
 Variable are only visible in the group in which they are defined. The
 same applies to attributes. ``Global'' attributes are defined in
-whichever group is refered to by the ncid. 
+whichever group is referred to by the ncid. 
 
 Dimensions are visible in their groups, and all child groups.
 
@@ -3334,7 +3334,7 @@ Wyoming.
 
 Fortran users may use character buffers to read and write compound
 types. User are invited to try classic Fortran features such as the
-equivilence and the common block statment. 
+equivilence and the common block statement. 
 
 @heading Usage 
 
@@ -3590,7 +3590,7 @@ must do so before the compound type is committed.
 Get the number of fields, length in bytes, and name of a compound
 type.
 
-In addtion to the NF90_INQ_COMPOUND function, three additional functions
+In addition to the NF90_INQ_COMPOUND function, three additional functions
 are provided which get only the name, size, and number of fields.
 
 @heading Usage 
diff --git a/docs/old/netcdf-install.texi b/docs/old/netcdf-install.texi
index 7ce175a..7f3dccc 100755
--- a/docs/old/netcdf-install.texi
+++ b/docs/old/netcdf-install.texi
@@ -650,7 +650,7 @@ in which case this flag should be disabled.
 @item --enable-dap-long-tests
 If --enable-dap-remote-tests is enabled, then this
 flag can also be enabled to add extra tests that may
-take signficant time to execute. 
+take significant time to execute. 
 This flag is off by default.
 
 @item --enable-hdf4
@@ -760,7 +760,7 @@ Change the size (in bytes) that will be used as a target size when
 computing default chunksizes for netCDF-4/HDF5 chunked variables.
 
 @item --default-chunks-in-cache
-Change the number of chunks that are accomodated in the per-variable
+Change the number of chunks that are accommodated in the per-variable
 chunk caches that are used by default.
 
 @item --max-default-cache-size
diff --git a/docs/old/netcdf-internal.texi b/docs/old/netcdf-internal.texi
index be80f6a..f40f0d3 100755
--- a/docs/old/netcdf-internal.texi
+++ b/docs/old/netcdf-internal.texi
@@ -51,7 +51,7 @@ netcdf-f90, The NetCDF Users' Guide for FORTRAN 90}).
 
 @menu
 * C Code::                      
-* Derivitive Works::            
+* Derivative Works::            
 * Concept Index::               
 
 @detailmenu
@@ -71,7 +71,7 @@ C Code
 @end detailmenu
 @end menu
 
- at node C Code, Derivitive Works, Top, Top
+ at node C Code, Derivative Works, Top, Top
 @chapter C Code
 
 The netCDF library is implemented in C in a bunch of directories under
@@ -533,11 +533,11 @@ package involving cfortran.h, which defines a C function of the exact
 signature which will be produced by a fortran program calling a C
 function. So _nf_open will map to nc_open.
 
- at node Derivitive Works, Concept Index, C Code, Top
- at chapter Derivitive Works
+ at node Derivative Works, Concept Index, C Code, Top
+ at chapter Derivative Works
 
-At Unidata, the creative energies are simply enourmous. NetCDF has
-spawned a host of derivitive works, some samples of which are listed
+At Unidata, the creative energies are simply enormous. NetCDF has
+spawned a host of derivative works, some samples of which are listed
 below.
 
 @section From ``A Tale of Two Data Formats,'' the bestselling novel
@@ -654,7 +654,7 @@ it doesn't mean that I can't love you, you know?
 
 [Audience]: (sighing) Ahhhhhh...
 
-[Jerry]: Now we have a suprise guest, flow all the way here from
+[Jerry]: Now we have a surprise guest, flow all the way here from
 Champagne-Urbana, Illinois, to appear as a guest on this show. Her
 name is HDF5, and she's a professional data format.
 
@@ -671,7 +671,7 @@ someone gets hurt...
 @end example
 
 
- at node Concept Index,  , Derivitive Works, Top
+ at node Concept Index,  , Derivative Works, Top
 @chapter Concept Index
 
 @printindex cp
diff --git a/docs/old/netcdf.texi b/docs/old/netcdf.texi
index 4ff2e81..40d6106 100644
--- a/docs/old/netcdf.texi
+++ b/docs/old/netcdf.texi
@@ -1851,7 +1851,7 @@ write variables and attributes of any type. Use these functions to
 read and write variables and attributes of user defined type. In C use
 nc_put_att/nc_get_att and the nc_put_var/nc_get_var,
 nc_put_var1/nc_get_var1, nc_put_vara/nc_get_vara, or
-nc_put_vars/nc_get_vars functons to access attribute and variable data
+nc_put_vars/nc_get_vars functions to access attribute and variable data
 of user defined type.
 
 @subsection Compound Types
@@ -3237,7 +3237,7 @@ The DAS output from the web server should look like this.
 @verbatim
 Attributes {
     Facility {
-        String PrincipleInvestigator ``Mark Abbott'', ``Ph.D'';
+        String PrincipleInvestigator ``Mark Abort'', ``Ph.D'';
         String DataCenter ``COAS Environmental Computer Facility'';
         String DrifterType ``MetOcean WOCE/OCM'';
     }
@@ -5979,7 +5979,7 @@ sets these when creating a group.
 
 Each dataset in the HDF5 file must be created with a property list for
 which the attribute creation order has been set to creation
-ordering. The H5Pset_attr_creation_order funtion is used to set the
+ordering. The H5Pset_attr_creation_order function is used to set the
 creation ordering of attributes of a variable.
 
 The following example code (from libsrc4/nc4hdf.c) shows how the
@@ -6014,7 +6014,7 @@ Until version 1.8, HDF5 did not have any capability to represent
 shared dimensions. With the 1.8 release, HDF5 introduced the dimension
 scale feature to allow shared dimensions in HDF5 files.
 
-The dimension scale is unfortunately not exactly equivilent to the
+The dimension scale is unfortunately not exactly equivalent to the
 netCDF shared dimension, and this leads to a number of compromises in
 the design of netCDF-4.
 
@@ -6416,7 +6416,7 @@ endif
 @end example
 
 @unnumberedsec Step 7.
-Modify the NC_intialize function in liblib/stub.c by
+Modify the NC_initialize function in liblib/stub.c by
 adding appropriate references to the NCM dispatch function.
 @example
 #ifdef USE_NETCDFM
diff --git a/docs/software.md b/docs/software.md
index cabb313..2e100aa 100644
--- a/docs/software.md
+++ b/docs/software.md
@@ -173,7 +173,7 @@ categories.
 -   Missing values (setctomiss, setmisstoc, setrtomiss)
 -   Arithmetic (add, sub, mul, div, ...)
 -   Mathematical functions (sqrt, exp, log, sin, cos, ...)
--   Comparision (eq, ne, le, lt, ge, gt, ...)
+-   Comparison (eq, ne, le, lt, ge, gt, ...)
 -   Conditions (ifthen, ifnotthen, ifthenc, ifnotthenc)
 -   Field statistics (fldsum, fldavg, fldstd, fldmin, fldmax, ...)
 -   Vertical statistics (vertsum, vertavg, vertstd, vertmin, ...)
@@ -1857,7 +1857,7 @@ from a given file, URL, stream, or NetcdfFile object. SIS netCDF storage
 is intended to be a bridge between NetCDF Climate and Forecast (CF)
 conventions and ISO 19115 metadata.
 
-SIS is under developement as an Apache project. Release 0.3 is currently
+SIS is under development as an Apache project. Release 0.3 is currently
 available for download.
 
 Tcl/Tk interfaces {#TclTk}
diff --git a/docs/tutorial.dox b/docs/tutorial.dox
index 8ad8568..4b3adf6 100644
--- a/docs/tutorial.dox
+++ b/docs/tutorial.dox
@@ -7,7 +7,7 @@
 
 \section sec_tut Tutorial Documentation
 
-This page contains refrences to various other NetCDF background and tutorial pages.
+This page contains references to various other NetCDF background and tutorial pages.
 
 \subsection tutorial_pages Tutorial Pages
 
diff --git a/docs/types.dox b/docs/types.dox
index 699e1b3..ae5fb44 100644
--- a/docs/types.dox
+++ b/docs/types.dox
@@ -167,7 +167,7 @@ defining variables or attributes. Use functions
 - nc_put_vara() / nc_get_vara()
 - nc_put_vars() / nc_get_vars()
 
-functons to access attribute and variable data of user defined type.
+functions to access attribute and variable data of user defined type.
 
 \subsection types_compound_types Compound Types
 
diff --git a/docs/windows-binaries.md b/docs/windows-binaries.md
index 61fae65..5f37f95 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.4.0-rc3) {#msvc-latest-release}
+## Latest Release (netCDF-C 4.4.0-rc4) {#msvc-latest-release}
 
 Configuration		| 32-bit 						| 64-bit |
 :-------------------|:--------							|:-------|
-netCDF 3		| [netCDF4.4.0-rc3-NC3-32.exe][r1]		| [netCDF4.4.0-rc3-NC3-64.exe][r6]
-netCDF3+DAP		| [netCDF4.4.0-rc3-NC3-DAP-32.exe][r2]	| [netCDF4.4.0-rc3-NC3-DAP-64.exe][r6]
-netCDF4			| [netCDF4.4.0-rc3-NC4-32.exe][r3]		| [netCDF4.4.0-rc3-NC4-64.exe][r7]
-netCDF4+DAP		| [netCDF4.4.0-rc3-NC4-DAP-32.exe][r4]	| [netCDF4.4.0-rc3-NC4-DAP-64.exe][r8]
+netCDF 3		| [netCDF4.4.0-rc4-NC3-32.exe][r1]		| [netCDF4.4.0-rc4-NC3-64.exe][r6]
+netCDF3+DAP		| [netCDF4.4.0-rc4-NC3-DAP-32.exe][r2]	| [netCDF4.4.0-rc4-NC3-DAP-64.exe][r6]
+netCDF4			| [netCDF4.4.0-rc4-NC4-32.exe][r3]		| [netCDF4.4.0-rc4-NC4-64.exe][r7]
+netCDF4+DAP		| [netCDF4.4.0-rc4-NC4-DAP-32.exe][r4]	| [netCDF4.4.0-rc4-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.4.0-rc3-NC3-32.exe
-[r2]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC3-DAP-32.exe
-[r3]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC4-32.exe
-[r4]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC4-DAP-32.exe
-[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC3-64.exe
-[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC3-DAP-64.exe
-[r7]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC4-64.exe
-[r8]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc3-NC4-DAP-64.exe
+[r1]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC3-32.exe
+[r2]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC3-DAP-32.exe
+[r3]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC4-32.exe
+[r4]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC4-DAP-32.exe
+[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC3-64.exe
+[r6]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC3-DAP-64.exe
+[r7]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC4-64.exe
+[r8]: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netCDF4.4.0-rc4-NC4-DAP-64.exe
diff --git a/dods.m4 b/dods.m4
index c79b069..87a025b 100644
--- a/dods.m4
+++ b/dods.m4
@@ -509,7 +509,7 @@ AC_DEFUN([DODS_CHECK_SIZES], [dnl
     # there are 2 possibilities for the definition of dods_int32, ..., 
     # types. First possibility is that the C99 types are used and 
     # dods-datatypes-static.h is copied. In that case the following 
-    # definitions are not really usefull. In case the C99 types are 
+    # definitions are not really useful. In case the C99 types are 
     # not available, dods-datatypes-config.h.in is used to generate
     # dods-datatypes.h.
     # The code below makes dods-datatypes-config.h stand on its own. 
diff --git a/examples/C/Makefile.am b/examples/C/Makefile.am
index eebb250..72a84f4 100644
--- a/examples/C/Makefile.am
+++ b/examples/C/Makefile.am
@@ -20,6 +20,11 @@ TESTPROGRAMS += simple_nc4_wr simple_nc4_rd simple_xy_nc4_wr	\
 simple_xy_nc4_rd
 endif #USE_NETCDF4
 
+if USE_PNETCDF
+# These are the extra netCDF-4 examples. 
+TESTPROGRAMS += parallel_vara
+endif #USE_PNETCDF
+
 AM_CPPFLAGS += -I$(top_builddir)/liblib
 AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
 
@@ -39,6 +44,6 @@ endif # USE_NETCDF4
 
 # These files are created by the tests.
 CLEANFILES = sfc_pres_temp.nc simple_xy.nc pres_temp_4D.nc	\
-simple_nc4.nc simple_xy_nc4.nc
+simple_nc4.nc simple_xy_nc4.nc testfile.nc
 
 EXTRA_DIST = run_valgrind_tests.sh run_nc4_valgrind_tests.sh CMakeLists.txt
diff --git a/examples/C/Makefile.in b/examples/C/Makefile.in
index 12593b7..6b5fd4b 100644
--- a/examples/C/Makefile.in
+++ b/examples/C/Makefile.in
@@ -101,13 +101,16 @@ target_triplet = @target@
 @USE_NETCDF4_TRUE at am__append_1 = simple_nc4_wr simple_nc4_rd simple_xy_nc4_wr	\
 @USE_NETCDF4_TRUE at simple_xy_nc4_rd
 
-check_PROGRAMS = $(am__EXEEXT_2)
-TESTS = $(am__EXEEXT_2) $(am__append_2) $(am__append_3)
+
+# These are the extra netCDF-4 examples. 
+ at USE_PNETCDF_TRUE@am__append_2 = parallel_vara
+check_PROGRAMS = $(am__EXEEXT_3)
+TESTS = $(am__EXEEXT_3) $(am__append_3) $(am__append_4)
 
 # This will run a bunch of the test programs with valgrind, the memory
 # checking tool. (Valgrind must be present for this to work.)
- at USE_VALGRIND_TESTS_TRUE@am__append_2 = run_valgrind_tests.sh
- at USE_NETCDF4_TRUE@@USE_VALGRIND_TESTS_TRUE at am__append_3 = run_nc4_valgrind_tests.sh
+ at USE_VALGRIND_TESTS_TRUE@am__append_3 = run_valgrind_tests.sh
+ at USE_NETCDF4_TRUE@@USE_VALGRIND_TESTS_TRUE at am__append_4 = run_nc4_valgrind_tests.sh
 subdir = examples/C
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -125,18 +128,23 @@ CONFIG_CLEAN_VPATH_FILES =
 @USE_NETCDF4_TRUE@	simple_nc4_rd$(EXEEXT) \
 @USE_NETCDF4_TRUE@	simple_xy_nc4_wr$(EXEEXT) \
 @USE_NETCDF4_TRUE@	simple_xy_nc4_rd$(EXEEXT)
-am__EXEEXT_2 = simple_xy_wr$(EXEEXT) simple_xy_rd$(EXEEXT) \
+ at USE_PNETCDF_TRUE@am__EXEEXT_2 = parallel_vara$(EXEEXT)
+am__EXEEXT_3 = simple_xy_wr$(EXEEXT) simple_xy_rd$(EXEEXT) \
 	sfc_pres_temp_wr$(EXEEXT) sfc_pres_temp_rd$(EXEEXT) \
 	pres_temp_4D_wr$(EXEEXT) pres_temp_4D_rd$(EXEEXT) \
-	$(am__EXEEXT_1)
-pres_temp_4D_rd_SOURCES = pres_temp_4D_rd.c
-pres_temp_4D_rd_OBJECTS = pres_temp_4D_rd.$(OBJEXT)
-pres_temp_4D_rd_LDADD = $(LDADD)
-pres_temp_4D_rd_DEPENDENCIES =
+	$(am__EXEEXT_1) $(am__EXEEXT_2)
+parallel_vara_SOURCES = parallel_vara.c
+parallel_vara_OBJECTS = parallel_vara.$(OBJEXT)
+parallel_vara_LDADD = $(LDADD)
+parallel_vara_DEPENDENCIES =
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
+pres_temp_4D_rd_SOURCES = pres_temp_4D_rd.c
+pres_temp_4D_rd_OBJECTS = pres_temp_4D_rd.$(OBJEXT)
+pres_temp_4D_rd_LDADD = $(LDADD)
+pres_temp_4D_rd_DEPENDENCIES =
 pres_temp_4D_wr_SOURCES = pres_temp_4D_wr.c
 pres_temp_4D_wr_OBJECTS = pres_temp_4D_wr.$(OBJEXT)
 pres_temp_4D_wr_LDADD = $(LDADD)
@@ -207,14 +215,14 @@ AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-SOURCES = pres_temp_4D_rd.c pres_temp_4D_wr.c sfc_pres_temp_rd.c \
-	sfc_pres_temp_wr.c simple_nc4_rd.c simple_nc4_wr.c \
-	simple_xy_nc4_rd.c simple_xy_nc4_wr.c simple_xy_rd.c \
-	simple_xy_wr.c
-DIST_SOURCES = pres_temp_4D_rd.c pres_temp_4D_wr.c sfc_pres_temp_rd.c \
-	sfc_pres_temp_wr.c simple_nc4_rd.c simple_nc4_wr.c \
-	simple_xy_nc4_rd.c simple_xy_nc4_wr.c simple_xy_rd.c \
-	simple_xy_wr.c
+SOURCES = parallel_vara.c pres_temp_4D_rd.c pres_temp_4D_wr.c \
+	sfc_pres_temp_rd.c sfc_pres_temp_wr.c simple_nc4_rd.c \
+	simple_nc4_wr.c simple_xy_nc4_rd.c simple_xy_nc4_wr.c \
+	simple_xy_rd.c simple_xy_wr.c
+DIST_SOURCES = parallel_vara.c pres_temp_4D_rd.c pres_temp_4D_wr.c \
+	sfc_pres_temp_rd.c sfc_pres_temp_wr.c simple_nc4_rd.c \
+	simple_nc4_wr.c simple_xy_nc4_rd.c simple_xy_nc4_wr.c \
+	simple_xy_rd.c simple_xy_wr.c
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -495,6 +503,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -527,6 +536,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -538,6 +548,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -620,11 +631,11 @@ LDADD = -lm
 # These are the netCDF-3 examples. 
 TESTPROGRAMS = simple_xy_wr simple_xy_rd sfc_pres_temp_wr \
 	sfc_pres_temp_rd pres_temp_4D_wr pres_temp_4D_rd \
-	$(am__append_1)
+	$(am__append_1) $(am__append_2)
 
 # These files are created by the tests.
 CLEANFILES = sfc_pres_temp.nc simple_xy.nc pres_temp_4D.nc	\
-simple_nc4.nc simple_xy_nc4.nc
+simple_nc4.nc simple_xy_nc4.nc testfile.nc
 
 EXTRA_DIST = run_valgrind_tests.sh run_nc4_valgrind_tests.sh CMakeLists.txt
 all: all-am
@@ -670,6 +681,10 @@ clean-checkPROGRAMS:
 	echo " rm -f" $$list; \
 	rm -f $$list
 
+parallel_vara$(EXEEXT): $(parallel_vara_OBJECTS) $(parallel_vara_DEPENDENCIES) $(EXTRA_parallel_vara_DEPENDENCIES) 
+	@rm -f parallel_vara$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(parallel_vara_OBJECTS) $(parallel_vara_LDADD) $(LIBS)
+
 pres_temp_4D_rd$(EXEEXT): $(pres_temp_4D_rd_OBJECTS) $(pres_temp_4D_rd_DEPENDENCIES) $(EXTRA_pres_temp_4D_rd_DEPENDENCIES) 
 	@rm -f pres_temp_4D_rd$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(pres_temp_4D_rd_OBJECTS) $(pres_temp_4D_rd_LDADD) $(LIBS)
@@ -716,6 +731,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/parallel_vara.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pres_temp_4D_rd.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pres_temp_4D_wr.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sfc_pres_temp_rd.Po at am__quote@
@@ -1020,6 +1036,13 @@ simple_xy_nc4_rd.log: simple_xy_nc4_rd$(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)
+parallel_vara.log: parallel_vara$(EXEEXT)
+	@p='parallel_vara$(EXEEXT)'; \
+	b='parallel_vara'; \
+	$(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)
 run_valgrind_tests.sh.log: run_valgrind_tests.sh
 	@p='run_valgrind_tests.sh'; \
 	b='run_valgrind_tests.sh'; \
diff --git a/examples/C/parallel_vara.c b/examples/C/parallel_vara.c
new file mode 100644
index 0000000..7e8e18f
--- /dev/null
+++ b/examples/C/parallel_vara.c
@@ -0,0 +1,191 @@
+/*********************************************************************
+ *
+ *  Copyright (C) 2014, Northwestern University and Argonne National Laboratory
+ *  See COPYRIGHT notice in top-level directory.
+ *
+ *********************************************************************/
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * This example shows how to use nc_put_vara_int() to write a 2D 4-byte integer
+ * array in parallel and read it back using the same array partitioning pattern.
+ * It first defines a netCDF variable of size global_nx * global_ny where
+ *    global_ny == NY and
+ *    global_nx == (NX * number of MPI processes).
+ * The data partitioning pattern is a column-wise partitioning across all
+ * proceses. Each process writes a subarray of size ny * nx.
+ *
+ *    To compile:
+ *        mpicc -O2 parallel_vara.c -o parallel_vara -lnetcdf -lpnetcdf
+ *
+ * Example commands for MPI run and outputs from running ncdump on the
+ * NC file produced by this example program:
+ *
+ *    % mpiexec -n 4 ./parallel_vara /pvfs2/wkliao/testfile.nc
+ *
+ *    % ncdump /pvfs2/wkliao/testfile.nc
+ *    netcdf testfile {
+ *    dimensions:
+ *            y = 10 ;
+ *            x = 16 ;
+ *    variables:
+ *            int var(y, x) ;
+ *                var:str_att_name = "example attribute of type text." ;
+ *                var:float_att_name = 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f ;
+ *    // global attributes:
+ *                :history = "Wed Apr 30 11:18:58 2014\n",
+ *       "" ;
+ *    data:
+ *
+ *     var =
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
+ *         0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 ;
+ *    }
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> /* strcpy() */
+#include <unistd.h> /* getopt() */
+#include <time.h>   /* time() localtime(), asctime() */
+#include <assert.h>
+#include <mpi.h>
+#include <netcdf.h>
+#include <netcdf_par.h>
+
+#define NY 10
+#define NX 4
+
+#define FATAL_ERR {if(err!=NC_NOERR) {printf("Error at line=%d: %s Aborting ...\n", __LINE__, nc_strerror(err)); goto fn_exit;}}
+#define ERR {if(err!=NC_NOERR)printf("Error at line=%d: %s\n", __LINE__, nc_strerror(err));}
+
+static void
+usage(char *argv0)
+{
+    char *help =
+    "Usage: %s [-h] | [-q] [file_name]\n"
+    "       [-h] Print help\n"
+    "       [-q] Quiet mode (reports when fail)\n"
+    "       [filename] output netCDF file name\n";
+    fprintf(stderr, help, argv0);
+}
+
+int main(int argc, char** argv)
+{
+    extern int optind;
+    char filename[128];
+    int i, j, rank, nprocs, verbose=1, err;
+    int ncid, cmode, omode, varid, dimid[2], buf[NY][NX];
+    char str_att[128];
+    float float_att[100];
+    size_t global_ny, global_nx, start[2], count[2];
+
+    MPI_Init(&argc, &argv);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+    /* get command-line arguments */
+    while ((i = getopt(argc, argv, "hq")) != EOF)
+        switch(i) {
+            case 'q': verbose = 0;
+                      break;
+            case 'h':
+            default:  if (rank==0) usage(argv[0]);
+                      MPI_Finalize();
+                      return 0;
+        }
+    argc -= optind;
+    argv += optind;
+    if (argc == 1) strcpy(filename, argv[0]); /* optional argument */
+    else strcpy(filename, "testfile.nc");
+
+    MPI_Bcast(filename, 128, MPI_CHAR, 0, MPI_COMM_WORLD);
+
+    /* create a new file for writing ----------------------------------------*/
+    cmode = NC_CLOBBER | NC_PNETCDF;
+    err = nc_create_par(filename, cmode, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid); FATAL_ERR
+
+    /* the global array is NY * (NX * nprocs) */
+    global_ny = NY;
+    global_nx = NX * nprocs;
+
+    for (i=0; i<NY; i++)
+        for (j=0; j<NX; j++)
+             buf[i][j] = rank;
+
+    /* add a global attribute: a time stamp at rank 0 */
+    time_t ltime = time(NULL); /* get the current calendar time */
+    asctime_r(localtime(&ltime), str_att);
+
+    /* make sure the time string are consistent among all processes */
+    MPI_Bcast(str_att, strlen(str_att), MPI_CHAR, 0, MPI_COMM_WORLD);
+
+    err = nc_put_att_text(ncid, NC_GLOBAL, "history", strlen(str_att),
+                          &str_att[0]); ERR
+
+    /* define dimensions x and y */
+    err = nc_def_dim(ncid, "Y", global_ny, &dimid[0]); ERR
+    err = nc_def_dim(ncid, "X", global_nx, &dimid[1]); ERR
+
+    /* define a 2D variable of integer type */
+    err = nc_def_var(ncid, "var", NC_INT, 2, dimid, &varid); ERR
+
+    /* add attributes to the variable */
+    strcpy(str_att, "example attribute of type text.");
+    err = nc_put_att_text(ncid, varid, "str_att_name", strlen(str_att),
+                          &str_att[0]); ERR
+
+    for (i=0; i<8; i++) float_att[i] = i;
+    err = nc_put_att_float(ncid, varid, "float_att_name", NC_FLOAT, 8,
+                           &float_att[0]); ERR
+
+    /* do not forget to exit define mode */
+    err = nc_enddef(ncid); ERR
+
+    /* set to use MPI/PnetCDF collective I/O */
+    err = nc_var_par_access(ncid, varid, NC_COLLECTIVE); ERR
+
+    /* now we are in data mode */
+    start[0] = 0;
+    start[1] = NX * rank;
+    count[0] = NY;
+    count[1] = NX;
+
+    err = nc_put_vara_int(ncid, varid, start, count, &buf[0][0]); ERR
+
+    err = nc_close(ncid); ERR
+
+    omode = NC_PNETCDF | NC_NOWRITE;
+    err = nc_open_par(filename, omode, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid); FATAL_ERR
+
+    /* inquire dimension IDs and lengths */
+    err = nc_inq_dimid(ncid, "Y", &dimid[0]); ERR
+    err = nc_inq_dimid(ncid, "X", &dimid[1]); ERR
+
+    err = nc_inq_dimlen(ncid, dimid[0], &global_ny); ERR
+    err = nc_inq_dimlen(ncid, dimid[1], &global_nx); ERR
+
+    /* obtain variable ID */
+    err = nc_inq_varid(ncid, "var", &varid); ERR
+
+    /* set to use MPI/PnetCDF collective I/O */
+    err = nc_var_par_access(ncid, varid, NC_COLLECTIVE); ERR
+
+    /* each process reads its subarray from the file */
+    err = nc_get_vara_int(ncid, varid, start, count, &buf[0][0]); ERR
+
+    /* close the file */
+    err = nc_close(ncid); ERR
+
+fn_exit:
+    MPI_Finalize();
+    return 0;
+}
+
diff --git a/examples/C/quick_large_files.c b/examples/C/quick_large_files.c
index 294179e..4ba7a5b 100644
--- a/examples/C/quick_large_files.c
+++ b/examples/C/quick_large_files.c
@@ -1,7 +1,7 @@
 /* This example program is part of Unidata's netCDF library for
    scientific data access. 
 
-   This program (quickly, but not throughly) tests the large file
+   This program (quickly, but not thoroughly) tests the large file
    features.
 
    Ed Hartnett, 8/11/4
diff --git a/examples/CDL/Makefile.in b/examples/CDL/Makefile.in
index cc4d6f7..b046497 100644
--- a/examples/CDL/Makefile.in
+++ b/examples/CDL/Makefile.in
@@ -382,6 +382,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -414,6 +415,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -425,6 +427,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/examples/Makefile.in b/examples/Makefile.in
index adbd420..c2ed9b5 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -238,6 +238,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -270,6 +271,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -281,6 +283,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/extra.css b/extra.css
deleted file mode 100644
index 629b887..0000000
--- a/extra.css
+++ /dev/null
@@ -1,29 +0,0 @@
-.tabs {
- width: 100% !important;
-}
-
-.tabs ul.tablist {
- width: 100% !important;
-}
-
-.tabs ul.tablist li.linkMenu select#versions {
- vertical-align: middle;
- height: ;
- margin: 8px 0 0 10px !important;
- padding: 0;
-}
-
-.tabs ul.tablist li.searchForm {
- float: right;
- padding: 0;
- margin: 0;
-}
-
-.tabs ul.tablist li.searchForm form#cse-search-box {
- float: right;
- margin: 8px 10px 0 0;
-}
-.tabs ul.tablist li.searchForm form#cse-search-box input#search {
- border-radius: 5px;
- margin: 0 5px 0 0;
-}
diff --git a/h5_test/Makefile.am b/h5_test/Makefile.am
index eda33e7..a05b69c 100644
--- a/h5_test/Makefile.am
+++ b/h5_test/Makefile.am
@@ -32,7 +32,7 @@ check_PROGRAMS = $(H5TESTS)
 TESTS = $(H5TESTS)
 
 # The parallel program is run from a script.
-if TEST_PARALLEL
+if TEST_PARALLEL4
 check_PROGRAMS += tst_h_par
 TESTS += run_par_tests.sh
 endif
diff --git a/h5_test/Makefile.in b/h5_test/Makefile.in
index 530f0a8..5dd8e65 100644
--- a/h5_test/Makefile.in
+++ b/h5_test/Makefile.in
@@ -117,8 +117,8 @@ check_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3)
 TESTS = $(am__EXEEXT_2) $(am__append_5) $(am__append_6)
 
 # The parallel program is run from a script.
- at TEST_PARALLEL_TRUE@am__append_4 = tst_h_par
- at TEST_PARALLEL_TRUE@am__append_5 = run_par_tests.sh
+ at TEST_PARALLEL4_TRUE@am__append_4 = tst_h_par
+ at TEST_PARALLEL4_TRUE@am__append_5 = run_par_tests.sh
 
 # This will run a bunch of the test programs with valgrind, the memory
 # checking tool. (Valgrind must be present for this to work.)
@@ -149,7 +149,7 @@ am__EXEEXT_2 = tst_h_files$(EXEEXT) tst_h_files2$(EXEEXT) \
 	tst_h_dimscales1$(EXEEXT) tst_h_dimscales2$(EXEEXT) \
 	tst_h_dimscales3$(EXEEXT) tst_h_enums$(EXEEXT) \
 	tst_h_dimscales4$(EXEEXT) $(am__EXEEXT_1)
- at TEST_PARALLEL_TRUE@am__EXEEXT_3 = tst_h_par$(EXEEXT)
+ at TEST_PARALLEL4_TRUE@am__EXEEXT_3 = tst_h_par$(EXEEXT)
 tst_h_atts_SOURCES = tst_h_atts.c
 tst_h_atts_OBJECTS = tst_h_atts.$(OBJEXT)
 tst_h_atts_LDADD = $(LDADD)
@@ -568,6 +568,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -600,6 +601,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -611,6 +613,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/include/Makefile.in b/include/Makefile.in
index c5829ec..a8ab3b4 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -236,6 +236,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -268,6 +269,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -279,6 +281,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/include/err_macros.h b/include/err_macros.h
index d7071a6..5d52eb1 100644
--- a/include/err_macros.h
+++ b/include/err_macros.h
@@ -53,6 +53,18 @@ fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
 goto error;                                                 \
 } while (0)
 
+int ERR_report(int stat, const char* file, int line)
+{
+    fflush(stdout);
+    fprintf(stderr, "Sorry! Unexpected result, %s, line: %d; status=%d\n",
+	file,line,stat);
+    fflush(stdout);
+    return 1;
+}
+
+#define ERRSTAT(stat) {err+=ERR_report(stat,__FILE__,__LINE__);}
+
+
 /* After a set of tests, report the number of errors, and increment
  * total_err. */
 #define SUMMARIZE_ERR do { \
diff --git a/include/nc3internal.h b/include/nc3internal.h
index 646452f..73aa48b 100644
--- a/include/nc3internal.h
+++ b/include/nc3internal.h
@@ -38,7 +38,10 @@
  * netcdf version 1 file.
  * The initial value of ncp->xsz.
  */
-#define MIN_NC_XSZ 32
+/* For classic */
+#define MIN_NC3_XSZ 32
+/* For cdf5 */
+#define MIN_NC5_XSZ 48
 
 /* Forward */
 struct ncio;
@@ -58,7 +61,7 @@ typedef enum {
 
 
 /*
- * NC dimension stucture
+ * NC dimension structure
  */
 typedef struct {
 	/* all xdr'd */
@@ -327,7 +330,7 @@ struct NC3_INFO {
 /* Begin defined in nc.c */
 
 extern int
-nc_cktype(nc_type datatype);
+nc3_cktype(int mode, nc_type datatype);
 
 extern size_t
 ncx_howmany(nc_type type, size_t xbufsize);
diff --git a/include/nc4internal.h b/include/nc4internal.h
index 2f1fad9..0726ea8 100644
--- a/include/nc4internal.h
+++ b/include/nc4internal.h
@@ -290,7 +290,7 @@ typedef struct  NC_HDF5_FILE_INFO
 {
    NC* controller;
    hid_t hdfid;
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    MPI_Comm comm;    /* Copy of MPI Communicator used to open the file */
    MPI_Info info;    /* Copy of MPI Information Object used to open the file */
 #endif
@@ -315,7 +315,7 @@ typedef struct  NC_HDF5_FILE_INFO
 } NC_HDF5_FILE_INFO_T;
 
 
-/* These functions convert beteen netcdf and HDF5 types. */
+/* These functions convert between netcdf and HDF5 types. */
 int nc4_get_typelen_mem(NC_HDF5_FILE_INFO_T *h5, nc_type xtype, 
 			int is_long, size_t *len);
 int nc4_convert_type(const void *src, void *dest, 
diff --git a/include/nc_tests.h b/include/nc_tests.h
index 3904564..c923fae 100644
--- a/include/nc_tests.h
+++ b/include/nc_tests.h
@@ -34,4 +34,10 @@ for conditions of use.
 #define ONE_TWENTY_EIGHT_MEG (SIXTEEN_MEG * 8)
 /** \} */
 
+#ifdef USE_PNETCDF
+#define TEST_PNETCDF 1
+#else
+#undef TEST_PNETCDF
+#endif
+
 #endif /* _NC_TESTS_H */
diff --git a/include/ncconfigure.h b/include/ncconfigure.h
index c9cbe06..d1ef846 100644
--- a/include/ncconfigure.h
+++ b/include/ncconfigure.h
@@ -62,6 +62,10 @@ typedef long long longlong;
 typedef unsigned long long ulonglong;
 #endif
 
+#ifndef HAVE_USHORT
+typedef unsigned short ushort;
+#endif
+
 #ifndef HAVE_UINT
 typedef unsigned int uint;
 #endif
diff --git a/include/ncdispatch.h b/include/ncdispatch.h
index 32d985e..0cacd0f 100644
--- a/include/ncdispatch.h
+++ b/include/ncdispatch.h
@@ -14,6 +14,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#if defined(HDF5_PARALLEL) || defined(USE_PNETCDF)
+#include <mpi.h>
+#endif
 #ifdef USE_PARALLEL
 #include "netcdf_par.h"
 #endif
@@ -56,13 +59,14 @@
 #define T_ulong   ulongtype
 
 /**************************************************/
+#if 0
 /* Define the known classes of dispatchers */
 /* Flags may be or'd => powers of 2*/
 #define NC_DISPATCH_NC3    1
 #define NC_DISPATCH_NC4    2
 #define NC_DISPATCH_NCD    4
 #define NC_DISPATCH_NCP    8
-
+#endif
 
 /* Define a type for use when doing e.g. nc_get_vara_long, etc. */
 /* Should matche values in libsrc4/netcdf.h */
@@ -76,21 +80,19 @@
 #endif
 
 /* Define the range of Atomic types */
-#ifdef USE_NETCDF4
-#define ATOMICTYPEMAX NC_STRING
-#else
-#define ATOMICTYPEMAX NC_DOUBLE
-#endif
+#define ATOMICTYPEMAX4 NC_STRING
+#define ATOMICTYPEMAX3 NC_DOUBLE
+#define ATOMICTYPEMAX5 NC_UINT64
 
 /* Define an alias for int to indicate an error return */
 typedef int NCerror;
 
-#ifndef USE_PARALLEL
+#if !defined HDF5_PARALLEL && !defined USE_PNETCDF
 typedef int MPI_Comm;
 typedef int MPI_Info;
 #define MPI_COMM_WORLD 0
 #define MPI_INFO_NULL 0
-#endif /* USE_PARALLEL */
+#endif
 
 /* Define a struct to hold the MPI info so it can be passed down the
  * call stack. This is used internally by the netCDF library. It
@@ -110,44 +112,41 @@ typedef struct NC_MEM_INFO {
 /*Forward*/
 typedef struct NC_Dispatch NC_Dispatch;
 
-extern NC_Dispatch* NCSUBSTRATE_dispatch_table;
 extern int NCDISPATCH_initialize(void);
+extern int NCDISPATCH_finalize(void);
+
+extern NC_Dispatch* NCSUBSTRATE_dispatch_table;
+extern int NCSUBSTRATE_initialize(void);
+extern int NCSUBSTRATE_finalize(void);
 
 extern NC_Dispatch* NC3_dispatch_table;
 extern int NC3_initialize(void);
+extern int NC3_finalize(void);
 
 #ifdef USE_DAP
 extern NC_Dispatch* NCD2_dispatch_table;
 extern int NCD2_initialize(void);
+extern int NCD2_finalize(void);
 #endif
 
 #ifdef USE_PNETCDF
 extern NC_Dispatch* NCP_dispatch_table;
 extern int NCP_initialize(void);
+extern int NCP_finalize(void);
 #endif
 
 #ifdef USE_NETCDF4
-
 extern NC_Dispatch* NC4_dispatch_table;
 extern int NC4_initialize(void);
+extern int NC4_finalize(void);
+#endif
 
 #ifdef USE_DAP
 extern NC_Dispatch* NCD4_dispatch_table;
 extern int NCD4_initialize(void);
+extern int NCD4_finalize(void);
 #endif
 
-#ifdef USE_CDMREMOTE
-extern NC_Dispatch* NCCR_dispatch_table;
-extern int NCCR_initialize(void);
-#endif
-
-#ifdef BUILD_RPC
-extern NC_Dispatch* NCRPC_dispatch_table;
-extern int NCRPC_initialize(void);
-#endif
-
-#endif /*USE_NETCDF4*/
-
 /* Vectors of ones and zeros */
 extern size_t nc_sizevector0[NC_MAX_VAR_DIMS];
 extern size_t nc_sizevector1[NC_MAX_VAR_DIMS];
@@ -167,7 +166,7 @@ struct NC;
 
 
 int NC_create(const char *path, int cmode,
-	      size_t initialsz, int basepe, size_t *chunksizehintp, 
+	      size_t initialsz, int basepe, size_t *chunksizehintp,
 	      int useparallel, void* parameters,
 	      int *ncidp);
 int NC_open(const char *path, int cmode,
@@ -193,10 +192,10 @@ struct NCHDR;
 
 struct NC_Dispatch {
 
-int model; /* one of the NC_DISPATCH #'s above */
+int model; /* one of the NC_FORMATX #'s */
 
 int (*create)(const char *path, int cmode,
-	  size_t initialsz, int basepe, size_t *chunksizehintp, 
+	  size_t initialsz, int basepe, size_t *chunksizehintp,
 	  int use_parallel, void* parameters,
 	  struct NC_Dispatch* table, NC* ncp);
 int (*open)(const char *path, int mode,
@@ -246,12 +245,11 @@ int (*put_vars)(int, int, const size_t*, const size_t*, const ptrdiff_t*, const
 int (*get_varm)(int, int, const size_t*, const size_t*, const ptrdiff_t*, const ptrdiff_t*, void*, nc_type);
 int (*put_varm)(int, int, const size_t*, const size_t*, const ptrdiff_t*, const ptrdiff_t*, const void*, nc_type);
 
-
-int (*inq_var_all)(int ncid, int varid, char *name, nc_type *xtypep, 
-               int *ndimsp, int *dimidsp, int *nattsp, 
+int (*inq_var_all)(int ncid, int varid, char *name, nc_type *xtypep,
+               int *ndimsp, int *dimidsp, int *nattsp,
                int *shufflep, int *deflatep, int *deflate_levelp,
-               int *fletcher32p, int *contiguousp, size_t *chunksizesp, 
-               int *no_fill, void *fill_valuep, int *endiannessp, 
+               int *fletcher32p, int *contiguousp, size_t *chunksizesp,
+               int *no_fill, void *fill_valuep, int *endiannessp,
 	       int *options_maskp, int *pixels_per_blockp);
 
 int (*var_par_access)(int, int, int);
@@ -304,19 +302,21 @@ int (*get_var_chunk_cache)(int ncid, int varid, size_t *sizep, size_t *nelemsp,
 
 /* Following functions must be handled as non-dispatch */
 #ifdef NONDISPATCH
-void(*nc_advise)(const char*cdf_routine_name,interr,const char*fmt,...);
-void(*nc_set_log_level)(int);
+void (*nc_advise)(const char*cdf_routine_name,interr,const char*fmt,...);
+void (*nc_set_log_level)(int);
 const char* (*nc_inq_libvers)(void);
 const char* (*nc_strerror)(int);
-int(*nc_delete)(const char*path);
-int(*nc_delete_mp)(const char*path,intbasepe);
+int (*nc_delete)(const char*path);
+int (*nc_delete_mp)(const char*path,intbasepe);
+int (*nc_initialize)();
+int (*nc_finalize)();
 #endif /*NONDISPATCH*/
 
 /* Define the common fields for NC and NC_FILE_INFO_T etc */
 typedef struct NCcommon {
 	int ext_ncid; /* uid << 16 */
 	int int_ncid; /* unspecified other id */
-	struct NC_Dispatch* dispatch;	
+	struct NC_Dispatch* dispatch;
 	void* dispatchdata; /* per-protocol instance data */
 	char* path; /* as specified at open or create */
 	int   substrate; /* ncid for another protocol on which to build */
@@ -325,9 +325,6 @@ typedef struct NCcommon {
 extern size_t NC_atomictypelen(nc_type xtype);
 extern char* NC_atomictypename(nc_type xtype);
 
-/* Provide an initializer */
-extern int NC_initialize(void);
-
 /* Provide a dispatch table overlay facility */
 extern int NC_dispatch_overlay(const NC_Dispatch* overlay,
                                         const NC_Dispatch* base,
@@ -354,12 +351,16 @@ extern const char* NCDAP_urllookup(void* dapurl, const char* param);
 # else
 #  define MSC_NCDISPATCH_EXTRA __declspec(dllimport)
 # endif
-MSC_NCDISPATCH_EXTRA extern char* NC_findtestserver(const char*, const char**);
-MSC_NCDISPATCH_EXTRA extern int nc_open_mem(const char*, int, size_t, void*, int*);
 #else
-extern char* NC_findtestserver(const char*,const char**);
+#  define MSC_NCDISPATCH_EXTRA
 #endif
 
+#define NCD_EXTERNL MSC_NCDISPATCH_EXTRA extern
+
+NCD_EXTERNL char* NC_findtestserver(const char*, const char**);
+NCD_EXTERNL int nc_open_mem(const char*, int, size_t, void*, int*);
+NCD_EXTERNL int nc_finalize();
+
 /* Ping a specific server */
 extern int NCDAP_ping(const char*);
 
@@ -374,5 +375,10 @@ extern int NC_inq_recvar(int ncid, int varid, int* nrecdims, int* is_recdim);
 extern size_t NC_coord_zero[NC_MAX_VAR_DIMS];
 extern size_t NC_coord_one[NC_MAX_VAR_DIMS];
 
-#endif /* _DISPATCH_H */
+extern int NC_argc;
+extern char* NC_argv[];
+extern int NC_initialized;
+
+NCD_EXTERNL int nc_initialize();
 
+#endif /* _DISPATCH_H */
diff --git a/include/netcdf.h b/include/netcdf.h
index bf714e1..4dd1e94 100644
--- a/include/netcdf.h
+++ b/include/netcdf.h
@@ -134,9 +134,11 @@ extern "C" {
 
 #define NC_DISKLESS      0x0008  /**< Use diskless file. Mode flag for nc_open() or nc_create(). */
 #define NC_MMAP          0x0010  /**< Use diskless file with mmap. Mode flag for nc_open() or nc_create(). */
-#define NC_INMEMORY      0x0020  /**< Read from memory. Mode flag for nc_open() or nc_create(). */
 
-#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model. Mode flag for nc_create(). */
+#define NC_64BIT_DATA    0x0020  /**< CDF-5 format: classic model but 64 bit dimensions and sizes */
+#define NC_CDF5          NC_64BIT_DATA  /**< Alias NC_CDF5 to NC_64BIT_DATA */
+
+#define NC_CLASSIC_MODEL 0x0100 /**< Enforce classic model on netCDF-4. Mode flag for nc_create(). */
 #define NC_64BIT_OFFSET  0x0200  /**< Use large (64-bit) file offsets. Mode flag for nc_create(). */
 
 /** \deprecated The following flag currently is ignored, but use in
@@ -157,7 +159,10 @@ Use this in mode flags for both nc_create() and nc_open(). */
 /** Turn on MPI POSIX I/O.
 Use this in mode flags for both nc_create() and nc_open(). */
 #define NC_MPIPOSIX      0x4000 /**< \deprecated As of libhdf5 1.8.13. */
-#define NC_PNETCDF       0x8000	/**< Use parallel-netcdf library. Mode flag for nc_open(). */
+
+#define NC_INMEMORY      0x8000  /**< Read from memory. Mode flag for nc_open() or nc_create(). */
+
+#define NC_PNETCDF       (NC_MPIIO) /**< Use parallel-netcdf library; alias for NC_MPIIO. */
 
 /** Format specifier for nc_set_default_format() and returned
  *  by nc_inq_format. This returns the format as provided by
@@ -166,10 +171,20 @@ Use this in mode flags for both nc_create() and nc_open(). */
  *  4.0 introduces the third one. \see netcdf_format
  */
 /**@{*/
-#define NC_FORMAT_CLASSIC (1)
-#define NC_FORMAT_64BIT   (2)
-#define NC_FORMAT_NETCDF4 (3)
-#define NC_FORMAT_NETCDF4_CLASSIC  (4)
+#define NC_FORMAT_CLASSIC         (1)
+/* After adding CDF5 support, this flag
+   is somewhat confusing. So, it is renamed.
+   Note that the name in the contributed code
+   NC_FORMAT_64BIT was renamed to NC_FORMAT_CDF2
+*/
+#define NC_FORMAT_64BIT           (2) /**< \deprecated Saved for compatibility.  Use NC_FORMAT_64BIT_OFFSET or NC_FORMAT_64BIT_DATA, from netCDF 4.4.0 onwards. */
+#define NC_FORMAT_64BIT_OFFSET    (2)
+#define NC_FORMAT_NETCDF4         (3)
+#define NC_FORMAT_NETCDF4_CLASSIC (4)
+#define NC_FORMAT_64BIT_DATA      (5)
+
+/* Alias */
+#define NC_FORMAT_CDF5    NC_FORMAT_64BIT_DATA
 
 /**@}*/
 
@@ -187,15 +202,33 @@ Use this in mode flags for both nc_create() and nc_open(). */
  *    or nc_create.
  * More or less, the #1 values track the set of dispatch tables.
  * The #1 values are as follows.
+ * Note that CDF-5 returns NC_FORMAT_NC3, but sets the mode flag properly.
  */
 /**@{*/
-#define NC_FORMAT_NC3     (1)
-#define NC_FORMAT_NC_HDF5 (2) /* netCDF-4 subset of HDF5 */
-#define NC_FORMAT_NC_HDF4 (3) /* netCDF-4 subset of HDF4 */
-#define NC_FORMAT_PNETCDF (4)
-#define NC_FORMAT_DAP2    (5)
-#define NC_FORMAT_DAP4    (6)
-#define NC_FORMAT_UNDEFINED (0)
+
+#define NC_FORMATX_NC3       (1)
+#define NC_FORMATX_NC_HDF5   (2) /**< netCDF-4 subset of HDF5 */
+#define NC_FORMATX_NC4       NC_FORMATX_NC_HDF5 /**< alias */
+#define NC_FORMATX_NC_HDF4   (3) /**< netCDF-4 subset of HDF4 */
+#define NC_FORMATX_PNETCDF   (4)
+#define NC_FORMATX_DAP2      (5)
+#define NC_FORMATX_DAP4      (6)
+#define NC_FORMATX_UNDEFINED (0)
+
+  /* To avoid breaking compatibility (such as in the python library),
+   we need to retain the NC_FORMAT_xxx format as well. This may come
+  out eventually, as the NC_FORMATX is more clear that it's an extended
+  format specifier.*/
+
+#define NC_FORMAT_NC3       NC_FORMATX_NC3 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC3 */
+#define NC_FORMAT_NC_HDF5   NC_FORMATX_NC_HDF5 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC_HDF5 */
+#define NC_FORMAT_NC4       NC_FORMATX_NC4 /**< \deprecated As of 4.4.0, use NC_FORMATX_NC4 */
+#define NC_FORMAT_NC_HDF4   NC_FORMATX_NC_HDF4 /**< \deprecated As of 4.4.0, use NC_FORMATX_HDF4 */
+#define NC_FORMAT_PNETCDF   NC_FORMATX_PNETCDF /**< \deprecated As of 4.4.0, use NC_FORMATX_PNETCDF */
+#define NC_FORMAT_DAP2      NC_FORMATX_DAP2 /**< \deprecated As of 4.4.0, use NC_FORMATX_DAP2 */
+#define NC_FORMAT_DAP4      NC_FORMATX_DAP4 /**< \deprecated As of 4.4.0, use NC_FORMATX_DAP4 */
+#define NC_FORMAT_UNDEFINED NC_FORMATX_UNDEFINED /**< \deprecated As of 4.4.0, use NC_FORMATX_UNDEFINED */
+
 /**@}*/
 
 /** Let nc__create() or nc__open() figure out a suitable buffer size. */
@@ -834,7 +867,7 @@ EXTERNL int
 nc_set_fill(int ncid, int fillmode, int *old_modep);
 
 /* Set the default nc_create format to NC_FORMAT_CLASSIC,
- * NC_FORMAT_64BIT, NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC. */
+ * NC_FORMAT_64BIT, NC_FORMAT_NETCDF4, etc */
 EXTERNL int
 nc_set_default_format(int format, int *old_formatp);
 
@@ -859,7 +892,7 @@ nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp,
 EXTERNL int
 nc_redef(int ncid);
 
-/* Is this ever used? */
+/* Is this ever used? Convert to parameter form */
 EXTERNL int
 nc__enddef(int ncid, size_t h_minfree, size_t v_align,
 	size_t v_minfree, size_t r_align);
@@ -1910,6 +1943,8 @@ ncrecget(int ncid, long recnum, void **datap);
 EXTERNL int
 ncrecput(int ncid, long recnum, void *const *datap);
 
+  //EXTERNL int nc_finalize();
+
 /* End v2.4 backward compatibility */
 #endif /*!NO_NETCDF_2*/
 
diff --git a/include/utf8proc.h b/include/utf8proc.h
index 1ab94c4..9d9bf82 100644
--- a/include/utf8proc.h
+++ b/include/utf8proc.h
@@ -114,7 +114,7 @@ typedef unsigned char _Bool;
  *  Flags being regarded by several functions in the library:
  *  NULLTERM:  The given UTF-8 input is NULL terminated.
  *  STABLE:    Unicode Versioning Stability has to be respected.
- *  COMPAT:    Compatiblity decomposition
+ *  COMPAT:    Compatibility decomposition
  *             (i.e. formatting information is lost)
  *  COMPOSE:   Return a result with composed characters.
  *  DECOMPOSE: Return a result with decomposed characters.
diff --git a/libdap2/Makefile.in b/libdap2/Makefile.in
index 78016cd..abef9f7 100644
--- a/libdap2/Makefile.in
+++ b/libdap2/Makefile.in
@@ -262,6 +262,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -294,6 +295,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -305,6 +307,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/libdap2/dceconstraints.c b/libdap2/dceconstraints.c
index 0aba56d..67428e6 100644
--- a/libdap2/dceconstraints.c
+++ b/libdap2/dceconstraints.c
@@ -196,7 +196,7 @@ dceslicecompose(DCEslice* s1, DCEslice* s2, DCEslice* result)
 {
     int err = NC_NOERR;
     size_t lastx = 0;
-    DCEslice sr; /* For back compatability so s1 and result can be same object */
+    DCEslice sr; /* For back compatibility so s1 and result can be same object */
 #ifdef DEBUG1
 slicedump("compose: s1",s1);
 slicedump("compose: s2",s2);
@@ -997,7 +997,7 @@ dcesegmentsize(DCEsegment* seg, size_t start, size_t stop)
 }
 
 /* Return the index of the leftmost slice
-   starting at start and upto, but not including
+   starting at start and up to, but not including
    stop, such that it and all slices to the right
    are "safe". Safe means dceiswholeslice() is true.
    In effect, we can read the safe index set as a
diff --git a/libdap2/ncd2dispatch.c b/libdap2/ncd2dispatch.c
index 4445eb6..b33f211 100644
--- a/libdap2/ncd2dispatch.c
+++ b/libdap2/ncd2dispatch.c
@@ -94,7 +94,7 @@ static int NCD2_get_vars(int ncid, int varid,
 
 static NC_Dispatch NCD2_dispatch_base = {
 
-NC_DISPATCH_NC3 | NC_DISPATCH_NCD,
+NC_FORMATX_DAP2,
 
 NCD2_create,
 NCD2_open,
@@ -218,6 +218,12 @@ NCD2_initialize(void)
     return NC_NOERR;
 }
 
+int
+NCD2_finalize(void)
+{
+    return NC_NOERR;
+}
+
 static int
 NCD2_redef(int ncid)
 {
@@ -1000,7 +1006,7 @@ NCD2_inq_format_extended(int ncid, int* formatp, int* modep)
     int ncstatus = NC_check_id(ncid, (NC**)&nc);
     if(ncstatus != NC_NOERR) return THROW(ncstatus);
     if(modep) *modep = nc->mode;
-    if(formatp) *formatp = NC_FORMAT_DAP2;
+    if(formatp) *formatp = NC_FORMATX_DAP2;
     return NC_NOERR;
 }
 
diff --git a/libdispatch/Makefile.in b/libdispatch/Makefile.in
index 0bc27bf..edf9956 100644
--- a/libdispatch/Makefile.in
+++ b/libdispatch/Makefile.in
@@ -285,6 +285,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -317,6 +318,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -328,6 +330,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/libdispatch/dcopy.c b/libdispatch/dcopy.c
index f0a202f..ebf32fd 100644
--- a/libdispatch/dcopy.c
+++ b/libdispatch/dcopy.c
@@ -7,7 +7,7 @@
 */
 
 #include "ncdispatch.h"
-#include <nc_logging.h>
+#include "nc_logging.h"
 
 #ifdef USE_NETCDF4
 /* Compare two netcdf types for equality. Must have the ncids as well,
@@ -293,7 +293,9 @@ nc_copy_var(int ncid_in, int varid_in, int ncid_out)
       return retval;
    if ((retval = nc_inq_format(ncid_out, &dest_format)))
       return retval;
-   if ((dest_format == NC_FORMAT_CLASSIC || dest_format == NC_FORMAT_64BIT) &&
+   if ((dest_format == NC_FORMAT_CLASSIC
+        || dest_format == NC_FORMAT_64BIT_DATA
+        || dest_format == NC_FORMAT_64BIT_OFFSET) &&
        src_format == NC_FORMAT_NETCDF4 && xtype > NC_DOUBLE)
       return NC_ENOTNC4;
 
@@ -643,7 +645,7 @@ nc_copy_att(int ncid_in, int varid_in, const char *name,
 	 }
       }
       else
-	 return retval; /* Some other error occured. */
+	 return retval; /* Some other error occurred. */
    }
    else
       return NC_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
diff --git a/libdispatch/ddim.c b/libdispatch/ddim.c
index c791664..b66e876 100644
--- a/libdispatch/ddim.c
+++ b/libdispatch/ddim.c
@@ -284,7 +284,7 @@ nc_rename_dim(int ncid, int dimid, const char *name)
 /*!
 Find the number of dimensions.
 
-In a classic model netCDF file, this funtion returns the number of
+In a classic model netCDF file, this function returns the number of
 defined dimensions. In a netCDF-4/HDF5 file, this function returns the
 number of dimensions available in the group specified by ncid, which
 may be less than the total number of dimensions in a file. In a
diff --git a/libdispatch/ddispatch.c b/libdispatch/ddispatch.c
index 6d7b346..320576c 100644
--- a/libdispatch/ddispatch.c
+++ b/libdispatch/ddispatch.c
@@ -3,24 +3,27 @@
 
 #define MAXSERVERURL 4096
 
-extern int NCSUBSTRATE_intialize(void);
+extern int NCSUBSTRATE_initialize(void);
+extern int NCSUBSTRATE_finalize(void);
 
 /* Define vectors of zeros and ones for use with various nc_get_varX function*/
 size_t nc_sizevector0[NC_MAX_VAR_DIMS];
 size_t nc_sizevector1[NC_MAX_VAR_DIMS];
 ptrdiff_t nc_ptrdiffvector1[NC_MAX_VAR_DIMS];
+size_t NC_coord_zero[NC_MAX_VAR_DIMS];
+size_t NC_coord_one[NC_MAX_VAR_DIMS];
 
 /* Define the known protocols and their manipulations */
 static struct NCPROTOCOLLIST {
     char* protocol;
     char* substitute;
-    int   modelflags;
+    int   model;
 } ncprotolist[] = {
     {"http",NULL,0},
     {"https",NULL,0},
-    {"file",NULL,NC_DISPATCH_NCD},
-    {"dods","http",NC_DISPATCH_NCD},
-    {"dodss","https",NC_DISPATCH_NCD},
+    {"file",NULL,NC_FORMATX_DAP2},
+    {"dods","http",NC_FORMATX_DAP2},
+    {"dodss","https",NC_FORMATX_DAP2},
     {NULL,NULL,0} /* Terminate search */
 };
 
@@ -38,19 +41,30 @@ static nc_type longtype = (sizeof(long) == sizeof(int)?NC_INT:NC_INT64);
 static nc_type ulongtype = (sizeof(unsigned long) == sizeof(unsigned int)?NC_UINT:NC_UINT64);
 */
 
-/* Allow dispatch to do initialization */
+/* Allow dispatch to do general initialization and finalization */
 int
 NCDISPATCH_initialize(void)
 {
-    extern int NCSUBSTRATE_initialize(void);
+    int status = NC_NOERR;
     int i;
-    NCSUBSTRATE_initialize();
     for(i=0;i<NC_MAX_VAR_DIMS;i++) {
 	nc_sizevector0[i] = 0;
         nc_sizevector1[i] = 1;
         nc_ptrdiffvector1[i] = 1;
     }
-    return NC_NOERR;
+    for(i=0;i<NC_MAX_VAR_DIMS;i++) {
+	NC_coord_one[i] = 1;
+	NC_coord_zero[i] = 0;
+    }
+    return status;
+}
+
+int
+NCDISPATCH_finalize(void)
+{
+    int status = NC_NOERR;
+    int i;
+    return status;
 }
 
 /* search list of servers and return first that succeeds when
@@ -127,7 +141,7 @@ NC_testurl(const char* path)
 }
 
 /*
-Return the OR of some of the NC_DISPATCH flags
+Return an NC_FORMATX_... value.
 Assumes that the path is known to be a url
 */
 
@@ -138,36 +152,7 @@ NC_urlmodel(const char* path)
     NCURI* tmpurl = NULL;
     struct NCPROTOCOLLIST* protolist;
 
-    if(!ncuriparse(path,&tmpurl)) goto done;
-
-    /* Look at any prefixed parameters */
-    if(ncurilookup(tmpurl,"netcdf4",NULL)
-       || ncurilookup(tmpurl,"netcdf-4",NULL)) {
-	model = (NC_DISPATCH_NC4|NC_DISPATCH_NCD);
-    } else if(ncurilookup(tmpurl,"netcdf3",NULL)
-              || ncurilookup(tmpurl,"netcdf-3",NULL)) {
-	model = (NC_DISPATCH_NC3|NC_DISPATCH_NCD);
-    }
-
-    if(model == 0) {
-        for(protolist=ncprotolist;protolist->protocol;protolist++) {
-	    if(strcmp(tmpurl->protocol,protolist->protocol) == 0) {
-    	        model |= protolist->modelflags;
-    	        if(protolist->substitute) {
-		    free(tmpurl->protocol);
-    		    tmpurl->protocol = strdup(protolist->substitute);
-    	        }
-    	        break;
-	    }
-	}
-    }
-
-    /* Force NC_DISPATCH_NC3 if necessary */
-    if((model & NC_DISPATCH_NC4) == 0)
-	model |= (NC_DISPATCH_NC3 | NC_DISPATCH_NCD);
-
-done:
-    ncurifree(tmpurl);
+    model = NC_FORMATX_DAP2;
     return model;
 }
 
diff --git a/libdispatch/derror.c b/libdispatch/derror.c
index 1180cdf..be5b31d 100644
--- a/libdispatch/derror.c
+++ b/libdispatch/derror.c
@@ -8,6 +8,9 @@ Research/Unidata. See COPYRIGHT file for more info.
 */
 
 #include "ncdispatch.h"
+#ifdef USE_PNETCDF
+#include <pnetcdf.h>  /* for ncmpi_strerror() */
+#endif
 
 /* Tell the user the version of netCDF. */
 static const char nc_libvers[] = PACKAGE_VERSION " of "__DATE__" "__TIME__" $";
@@ -256,7 +259,16 @@ const char *nc_strerror(int ncerr1)
       case NC_EDISKLESS:
 	 return "NetCDF: Error in using diskless access";
       default:
+#ifdef USE_PNETCDF
+        /* The behavior of ncmpi_strerror here is to return
+           NULL, not a string.  This causes problems in (at least)
+           the fortran interface. */
+        return (ncmpi_strerror(ncerr1) ?
+                ncmpi_strerror(ncerr1) :
+                "Unknown Error");
+#else
 	 return "Unknown Error";
+#endif
    }
 }
 
diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c
index 1516224..b4e2804 100644
--- a/libdispatch/dfile.c
+++ b/libdispatch/dfile.c
@@ -24,7 +24,8 @@ Research/Unidata. See COPYRIGHT file for more info.
 #endif
 #include "ncdispatch.h"
 
-static int nc_initialized = 0;
+extern int NC_initialized;
+extern int NC_finalized;
 
 /** \defgroup datasets NetCDF Files
 
@@ -63,20 +64,6 @@ of the interfaces for these operations.
 */
 /**@{*/
 
-size_t NC_coord_zero[NC_MAX_VAR_DIMS];
-size_t NC_coord_one[NC_MAX_VAR_DIMS];
-
-static void
-nc_local_initialize(void)
-{
-    int i;
-
-    for(i=0;i<NC_MAX_VAR_DIMS;i++) {
-	NC_coord_one[i] = 1;
-	NC_coord_zero[i] = 0;
-    }
-}
-
 static int
 NC_interpret_magic_number(char* magic, int* model, int* version, int use_parallel)
 {
@@ -85,34 +72,39 @@ NC_interpret_magic_number(char* magic, int* model, int* version, int use_paralle
     /* Ignore the first byte for HDF */
 #ifdef USE_NETCDF4
     if(magic[1] == 'H' && magic[2] == 'D' && magic[3] == 'F') {
-	*model = NC_DISPATCH_NC4;
+	*model = NC_FORMATX_NC4;
 	*version = 5;
 #ifdef USE_HDF4
     } else if(magic[0] == '\016' && magic[1] == '\003'
               && magic[2] == '\023' && magic[3] == '\001') {
-	*model = NC_DISPATCH_NC4;
+	*model = NC_FORMATX_NC4;
 	*version = 4;
 #endif
     } else
 #endif
     if(magic[0] == 'C' && magic[1] == 'D' && magic[2] == 'F') {
-        if(magic[3] == '\001')
+        if(magic[3] == '\001') {
             *version = 1; /* netcdf classic version 1 */
-         else if(magic[3] == '\002')
+	    *model = NC_FORMATX_NC3;
+         } else if(magic[3] == '\002') {
             *version = 2; /* netcdf classic version 2 */
-#ifdef USE_PNETCDF
-         else if(magic[3] == '\005')
-            *version = 5; /* pnetcdf file */
-#endif
-	 else
+	    *model = NC_FORMATX_NC3;
+         } else if(magic[3] == '\005') {
+            *version = 5; /* cdf5 (including pnetcdf) file */
+	    *model = NC_FORMATX_NC3;
+	 } else
 	    {status = NC_ENOTNC; goto done;}
-	 *model = (use_parallel || *version == 5)?NC_DISPATCH_NCP:NC_DISPATCH_NC3;
      } else
         {status = NC_ENOTNC; goto done;}
 done:
      return status;
 }
 
+/**
+Given an existing file, figure out its format
+and return that format value (NC_FORMATX_XXX)
+in model arg.
+*/
 static int
 NC_check_file_type(const char *path, int flags, void *parameters,
 		   int* model, int* version)
@@ -120,10 +112,6 @@ NC_check_file_type(const char *path, int flags, void *parameters,
    char magic[MAGIC_NUMBER_LEN];
    int status = NC_NOERR;
    int diskless = ((flags & NC_DISKLESS) == NC_DISKLESS);
-
-   /* Unused, throws a 'value never read' in static analysis. */
-   //int persist = ((flags & NC_WRITE) == NC_WRITE);
-
    int use_parallel = ((flags & NC_MPIIO) == NC_MPIIO);
    int inmemory = (diskless && ((flags & NC_INMEMORY) == NC_INMEMORY));
 
@@ -215,14 +203,17 @@ and attributes.
 
 \param path The file name of the new netCDF dataset.
 
-\param cmode The creation mode flag. The following flags are
-available: NC_NOCLOBBER (do not overwrite existing file), NC_SHARE
-(limit write caching - netcdf classic files onlt), NC_64BIT_OFFSET
-(create 64-bit offset file), NC_NETCDF4 (create netCDF-4/HDF5 file),
-NC_CLASSIC_MODEL (enforce netCDF classic mode on netCDF-4/HDF5
-files), NC_DISKLESS (store data only in memory), NC_MMAP (use MMAP
-for NC_DISKLESS), and NC_WRITE.
-See discussion below.
+\param cmode The creation mode flag. The following flags are available:
+  NC_NOCLOBBER (do not overwrite existing file),
+  NC_SHARE (limit write caching - netcdf classic files only),
+  NC_64BIT_OFFSET (create 64-bit offset file),
+  NC_64BIT_DATA (Alias NC_CDF5) (create CDF-5 file),
+  NC_NETCDF4 (create netCDF-4/HDF5 file),
+  NC_CLASSIC_MODEL (enforce netCDF classic mode on netCDF-4/HDF5 files),
+  NC_DISKLESS (store data only in memory),
+  NC_MMAP (use MMAP for NC_DISKLESS),
+  and NC_WRITE.
+  See discussion below.
 
 \param ncidp Pointer to location where returned netCDF ID is to be
 stored.
@@ -249,6 +240,14 @@ file, instead of a netCDF classic format file. The 64-bit offset
 format imposes far fewer restrictions on very large (i.e. over 2 GB)
 data files. See Large File Support.
 
+Setting NC_64BIT_DATA (Alias NC_CDF5) causes netCDF to create a CDF-5
+file format that supports large files (i.e. over 2GB) and large
+variables (over 2B array elements.). See Large File Support.
+
+Note that the flag NC_PNETCDF also exists as the combination of
+NC_CDF5 or'd with NC_MPIIO to indicate that the pnetcdf library
+should be used.
+
 A zero value (defined for convenience as NC_CLOBBER) specifies the
 default behavior: overwrite any existing dataset with the same file
 name and buffer and cache accesses for efficiency. The dataset will be
@@ -666,6 +665,10 @@ int
 nc__open(const char *path, int mode,
 	 size_t *chunksizehintp, int *ncidp)
 {
+   /* this API is for non-parallel access: TODO check for illegal cmode
+    * flags, such as NC_PNETCDF, NC_MPIIO, or NC_MPIPOSIX, before entering
+    * NC_open()? Note nc_open_par() also calls NC_open().
+    */
    return NC_open(path, mode, 0, chunksizehintp, 0,
 		  NULL, ncidp);
 }
@@ -1352,7 +1355,7 @@ This function returns the (rarely needed) format version.
 nc_create().
 
 \param formatp Pointer to location for returned format version, one of
-NC_FORMAT_CLASSIC, NC_FORMAT_64BIT, NC_FORMAT_NETCDF4,
+NC_FORMAT_CLASSIC, NC_FORMAT_64BIT_OFFSET, NC_FORMAT_CDF5, NC_FORMAT_NETCDF4,
 NC_FORMAT_NETCDF4_CLASSIC.
 
 \returns ::NC_NOERR No error.
@@ -1534,18 +1537,37 @@ int
 nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
 {
    NC* ncp;
-   /* For compatibility, we need to allow inq about
-      atomic types, even if ncid is ill-defined */
-   if(xtype <= ATOMICTYPEMAX) {
-      if(xtype <= NC_NAT) return NC_EBADTYPE;
-      if(name) strncpy(name,NC_atomictypename(xtype),NC_MAX_NAME);
-      if(size) *size = NC_atomictypelen(xtype);
-      return NC_NOERR;
-   } else {
-      int stat = NC_check_id(ncid, &ncp);
-      if(stat != NC_NOERR) return NC_EBADTYPE; /* compatibility */
+   int stat;
+
+   /* Do a quick triage on xtype */
+   if(xtype <= NC_NAT) return NC_EBADTYPE;
+   /* See if the ncid is valid */
+   stat = NC_check_id(ncid, &ncp);
+   if(stat != NC_NOERR) { /* bad ncid; do what we can */
+       /* For compatibility, we need to allow inq about
+          atomic types, even if ncid is ill-defined */
+	if(xtype <= ATOMICTYPEMAX3) {
+            if(name) strncpy(name,NC_atomictypename(xtype),NC_MAX_NAME);
+            if(size) *size = NC_atomictypelen(xtype);
+            return NC_NOERR;
+	} else
+	    return NC_EBADTYPE;
+   } else { /* have good ncid */
       return ncp->dispatch->inq_type(ncid,xtype,name,size);
    }
+#if 0
+       int maxtype;
+       int format;
+   nc_inq_format(ncid, &format);
+   switch (format) {
+   case NC_FORMAT_NETCDF4_CLASSIC: /*fall thru*/
+   case NC_FORMAT_64BIT_OFFSET: /*fall thru*/
+   case NC_FORMAT_CLASSIC: maxtype = ATOMICTYPEMAX3; break;
+   case NC_FORMAT_NETCDF4: maxtype = ATOMICTYPEMAX4; break;
+   case NC_FORMAT_CDF5: maxtype = ATOMICTYPEMAX5; break;
+   default: return NC_EINVAL;
+   }
+#endif
 }
 /**@}*/
 
@@ -1592,20 +1614,17 @@ NC_create(const char *path, int cmode, size_t initialsz,
    NC* ncp = NULL;
    NC_Dispatch* dispatcher = NULL;
    /* Need three pieces of information for now */
-   int model = 0; /* one of the NC_DISPATCH_XXX values */
+   int model = NC_FORMATX_UNDEFINED; /* one of the NC_FORMATX values */
    int isurl = 0;   /* dap or cdmremote or neither */
    int xcmode = 0; /* for implied cmode flags */
 
    /* Initialize the dispatch table. The function pointers in the
     * dispatch table will depend on how netCDF was built
     * (with/without netCDF-4, DAP, CDMREMOTE). */
-   if(!nc_initialized)
+   if(!NC_initialized)
    {
-      if ((stat = NC_initialize()))
+      if ((stat = nc_initialize()))
 	 return stat;
-      /* Do local initialization */
-      nc_local_initialize();
-      nc_initialized = 1;
    }
 
 #ifdef USE_REFCOUNT
@@ -1619,41 +1638,47 @@ NC_create(const char *path, int cmode, size_t initialsz,
 	model = NC_urlmodel(path);
 
    /* Look to the incoming cmode for hints */
-   if(model == 0) {
+   if(model == NC_FORMATX_UNDEFINED) {
 #ifdef USE_NETCDF4
-      if(cmode & NC_NETCDF4)
-	model = NC_DISPATCH_NC4;
+      if((cmode & NC_NETCDF4) == NC_NETCDF4)
+	model = NC_FORMATX_NC4;
       else
 #endif
 #ifdef USE_PNETCDF
-      if(cmode & NC_PNETCDF)
-	model = NC_DISPATCH_NCP;
+      /* pnetcdf is used for parallel io on CDF-1, CDF-2, and CDF-5 */
+      if((cmode & NC_MPIIO) == NC_MPIIO)
+	model = NC_FORMATX_PNETCDF;
       else
 #endif
-      if(cmode & NC_CLASSIC_MODEL)
-	model = NC_DISPATCH_NC3;
-   }
-
-   if(model == 0) {
-      /* Check default format */
+	{}
+    }
+    if(model == NC_FORMATX_UNDEFINED) {
+      /* Check default format (not formatx) */
       int format = nc_get_default_format();
       switch (format) {
 #ifdef USE_NETCDF4
 	 case NC_FORMAT_NETCDF4:
 	    xcmode |= NC_NETCDF4;
-	    model = NC_DISPATCH_NC4;
+	    model = NC_FORMATX_NC4;
 	    break;
 	 case NC_FORMAT_NETCDF4_CLASSIC:
 	    xcmode |= NC_CLASSIC_MODEL;
-	    model = NC_DISPATCH_NC4;
+	    model = NC_FORMATX_NC4;
 	    break;
 #endif
-	 case NC_FORMAT_64BIT:
+	 case NC_FORMAT_CDF5:
+	    xcmode |= NC_64BIT_DATA;
+	    model = NC_FORMATX_NC3;
+	    break;
+	 case NC_FORMAT_64BIT_OFFSET:
 	    xcmode |= NC_64BIT_OFFSET;
-	    /* fall thru */
+	    model = NC_FORMATX_NC3;
+	    break;
 	 case NC_FORMAT_CLASSIC:
+	    model = NC_FORMATX_NC3;
+	    break;
 	 default:
-	    model = NC_DISPATCH_NC3;
+	    model = NC_FORMATX_NC3;
 	    break;
       }
    }
@@ -1661,36 +1686,28 @@ NC_create(const char *path, int cmode, size_t initialsz,
    /* Add inferred flags */
    cmode |= xcmode;
 
-#ifdef USE_NETCDF4
-   if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX))
+   /* Clean up illegal combinations */
+   if((cmode & (NC_64BIT_OFFSET|NC_64BIT_DATA)) == (NC_64BIT_OFFSET|NC_64BIT_DATA))
+	cmode &= ~(NC_64BIT_OFFSET); /*NC_64BIT_DATA=>NC_64BIT_OFFSET*/
+
+   if((cmode & NC_MPIIO) && (cmode & NC_MPIPOSIX))
       return  NC_EINVAL;
-#endif
 
    if (!(dispatcher = NC_get_dispatch_override()))
    {
 
       /* Figure out what dispatcher to use */
 #ifdef USE_NETCDF4
-#ifdef USE_CDMREMOTE
-      if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
-	 dispatcher = NCCR_dispatch_table;
-      else
-#endif
-      if(model == (NC_DISPATCH_NC4))
+      if(model == (NC_FORMATX_NC4))
  	dispatcher = NC4_dispatch_table;
       else
 #endif /*USE_NETCDF4*/
-#ifdef USE_DAP
-      if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
-	dispatcher = NCD2_dispatch_table;
-      else
-#endif
 #ifdef USE_PNETCDF
-      if(model == (NC_DISPATCH_NCP))
+      if(model == (NC_FORMATX_PNETCDF))
 	dispatcher = NCP_dispatch_table;
       else
 #endif
-      if(model == (NC_DISPATCH_NC3))
+      if(model == (NC_FORMATX_NC3))
  	dispatcher = NC3_dispatch_table;
       else
 	 return NC_ENOTNC;
@@ -1750,12 +1767,9 @@ NC_open(const char *path, int cmode,
    int version = 0;
    int flags = 0;
 
-   if(!nc_initialized) {
-      stat = NC_initialize();
+   if(!NC_initialized) {
+      stat = nc_initialize();
       if(stat) return stat;
-      /* Do local initialization */
-      nc_local_initialize();
-      nc_initialized = 1;
    }
 
 #ifdef USE_REFCOUNT
@@ -1792,25 +1806,37 @@ NC_open(const char *path, int cmode,
    }
 
    /* Force flag consistentcy */
-   if(model & NC_DISPATCH_NC4)
+   if(model == NC_FORMATX_NC4)
       cmode |= NC_NETCDF4;
-   else if(model & NC_DISPATCH_NC3) {
-      cmode &= ~NC_NETCDF4; /* must be netcdf-3 */
+   else if(model == NC_FORMATX_NC3) {
+      cmode &= ~NC_NETCDF4; /* must be netcdf-3 (CDF-1, CDF-2, CDF-5) */
+      /* User may want to open file using the pnetcdf library */
+      if(cmode & NC_PNETCDF) {
+         /* dispatch is determined by cmode, rather than file format */
+         model = NC_FORMATX_PNETCDF;
+      }
+      /* For opening an existing file, flags NC_64BIT_OFFSET and NC_64BIT_DATA
+       * will be ignored, as the file is already in either CDF-1, 2, or 5
+       * format. However, below we add the file format info to cmode so the
+       * internal netcdf file open subroutine knows what file format to open.
+       * The mode will be saved in ncp->mode, to be used by
+       * nc_inq_format_extended() to report the file format.
+       * See NC3_inq_format_extended() in libsrc/nc3internal.c for example.
+       */
       if(version == 2) cmode |= NC_64BIT_OFFSET;
-   } else if(model & NC_DISPATCH_NCP) {
-#if 0
-It appears that pnetcdf can read NC_64_BIT_OFFSET
-      cmode &= ~(NC_NETCDF4 | NC_64BIT_OFFSET); /* must be pnetcdf */
-#else
-      cmode &= ~(NC_NETCDF4);
-#endif
-      cmode |= NC_PNETCDF;
+      else if(version == 5) {
+        cmode |= NC_64BIT_DATA;
+        cmode &= ~(NC_64BIT_OFFSET); /*NC_64BIT_DATA=>NC_64BIT_OFFSET*/
+      }
+   } else if(model == NC_FORMATX_PNETCDF) {
+     cmode &= ~(NC_NETCDF4|NC_64BIT_OFFSET);
+     cmode |= NC_64BIT_DATA;
    }
 
    if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX))
-      return  NC_EINVAL;
+     return  NC_EINVAL;
 
-   /* override overrides any other table choice */
+   /* override any other table choice */
    dispatcher = NC_get_dispatch_override();
    if(dispatcher != NULL) goto havetable;
 
@@ -1821,21 +1847,21 @@ It appears that pnetcdf can read NC_64_BIT_OFFSET
    else
 #endif
 #if defined(USE_DAP)
-   if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
+   if(model == (NC_FORMATX_DAP2))
 	dispatcher = NCD2_dispatch_table;
    else
 #endif
 #if  defined(USE_PNETCDF)
-   if(model == (NC_DISPATCH_NCP))
+   if(model == (NC_FORMATX_PNETCDF))
 	dispatcher = NCP_dispatch_table;
    else
 #endif
 #if defined(USE_NETCDF4)
-   if(model == (NC_DISPATCH_NC4))
+   if(model == (NC_FORMATX_NC4))
 	dispatcher = NC4_dispatch_table;
    else
 #endif
-   if(model == (NC_DISPATCH_NC3))
+   if(model == (NC_FORMATX_NC3))
 	dispatcher = NC3_dispatch_table;
    else
       return  NC_ENOTNC;
diff --git a/libdispatch/dparallel.c b/libdispatch/dparallel.c
index 96a89eb..ab99eb6 100644
--- a/libdispatch/dparallel.c
+++ b/libdispatch/dparallel.c
@@ -6,9 +6,6 @@ Research/Unidata. See COPYRIGHT file for more info.
 */
 
 #include "config.h"
-#ifdef USE_PARALLEL
-#include "netcdf_f.h"
-#endif /* USE_PARALLEL */
 #include "ncdispatch.h"
 
 /* This function creates a file for use with parallel I/O. */
diff --git a/libdispatch/dsubstrate.c b/libdispatch/dsubstrate.c
index 6df6305..b1c0348 100644
--- a/libdispatch/dsubstrate.c
+++ b/libdispatch/dsubstrate.c
@@ -31,7 +31,6 @@ the abstraction and invoke the
 substrate dispatch table directly.
 */
 
-
 int
 NCSUBSTRATE_initialize(void)
 {
@@ -39,6 +38,12 @@ NCSUBSTRATE_initialize(void)
     return NC_NOERR;
 }
 
+int
+NCSUBSTRATE_finalize(void)
+{
+    return NC_NOERR;
+}
+
 static int
 NCSUB_redef(int ncid)
 {
diff --git a/libdispatch/dutf8proc.c b/libdispatch/dutf8proc.c
index c9edff0..f1e68a5 100644
--- a/libdispatch/dutf8proc.c
+++ b/libdispatch/dutf8proc.c
@@ -109,7 +109,7 @@ const char *utf8proc_errmsg(ssize_t errcode) {
     case UTF8PROC_ERROR_INVALIDOPTS:
     return "Invalid options for UTF-8 processing chosen.";
     default:
-    return "An unknown error occured while processing UTF-8 data.";
+    return "An unknown error occurred while processing UTF-8 data.";
   }
 }
 
@@ -367,7 +367,7 @@ ssize_t utf8proc_decompose(
     while (1) {
       if (options & UTF8PROC_NULLTERM) {
         rpos += utf8proc_iterate(str + rpos, -1, &uc);
-        /* checking of return value is not neccessary,
+        /* checking of return value is not necessary,
 	   as 'uc' is < 0 in case of error. */
         if (uc < 0) return UTF8PROC_ERROR_INVALIDUTF8;
         if (rpos < 0) return UTF8PROC_ERROR_OVERFLOW;
diff --git a/libdispatch/dv2i.c b/libdispatch/dv2i.c
index 48e83d9..925e81e 100644
--- a/libdispatch/dv2i.c
+++ b/libdispatch/dv2i.c
@@ -1,5 +1,5 @@
 /** \file 
-The V2 API Funtions.
+The V2 API Functions.
 
 Copyright 1996, University Corporation for Atmospheric Research
 See \ref copyright file for copying and redistribution conditions.
@@ -864,23 +864,37 @@ ncvarputg(
     const void* value
 )
 {
+	int ndims = 0;
 	if(map == NULL)
 		return ncvarputs(ncid, varid, start, count, stride, value);
 	/* else */
 	{
-	NDIMS_DECL
+	ptrdiff_t *imp=NULL;
+	if (map != NULL) {
+		int ret = NC_NOERR;
+		/* make map[ndims-1] number of elements instead of bytes */
+		int i, el_size;
+		nc_type type;
+		ret = nc_inq_varndims(ncid, varid, &ndims);
+		if(ret) return ret;
+		ret = nc_inq_vartype(ncid, varid, &type);
+		if(ret) return ret;
+				el_size = nctypelen(type);
+		imp = (ptrdiff_t*) malloc(ndims * sizeof(ptrdiff_t));
+		for (i=0; i<ndims; i++) imp[i] = map[i] / el_size;
+	}
+
+	{
 	A_DECL(stp, size_t, ndims, start);
 	A_DECL(cntp, size_t, ndims, count);
 	A_DECL(strdp, ptrdiff_t, ndims, stride);
-	A_DECL(imp, ptrdiff_t, ndims, map);
 	A_INIT(stp, size_t, ndims, start);
 	A_INIT(cntp, size_t, ndims, count);
 	A_INIT(strdp, ptrdiff_t, ndims, stride);
-	A_INIT(imp, ptrdiff_t, ndims, map);
 	{
 	const int status = nc_put_varm(ncid, varid,
 			 stp, cntp, strdp, imp, value);
-	A_FREE(imp);
+	if (imp!=NULL) free(imp);
 	A_FREE(strdp);
 	A_FREE(cntp);
 	A_FREE(stp);
@@ -892,6 +906,7 @@ ncvarputg(
 	}
 	return 0;
 	}
+	}
 }
 
 
@@ -906,23 +921,37 @@ ncvargetg(
     void*	value
 )
 {
+	int ndims = 0;
 	if(map == NULL)
 		return ncvargets(ncid, varid, start, count, stride, value);
 	/* else */
 	{
-	NDIMS_DECL
+	ptrdiff_t *imp=NULL;
+	if (map != NULL) {
+		int ret = NC_NOERR;
+		/* make map[ndims-1] number of elements instead of bytes */
+		int i, el_size;
+		nc_type type;
+		ret = nc_inq_varndims(ncid, varid, &ndims);
+		if(ret) return ret;
+		ret = nc_inq_vartype(ncid, varid, &type);
+		if(ret) return ret;
+		el_size = nctypelen(type);
+		imp = (ptrdiff_t*) malloc(ndims * sizeof(ptrdiff_t));
+		for (i=0; i<ndims; i++) imp[i] = map[i] / el_size;
+	}
+
+	{
 	A_DECL(stp, size_t, ndims, start);
 	A_DECL(cntp, size_t, ndims, count);
 	A_DECL(strdp, ptrdiff_t, ndims, stride);
-	A_DECL(imp, ptrdiff_t, ndims, map);
 	A_INIT(stp, size_t, ndims, start);
 	A_INIT(cntp, size_t, ndims, count);
 	A_INIT(strdp, ptrdiff_t, ndims, stride);
-	A_INIT(imp, ptrdiff_t, ndims, map);
 	{
 	const int status = nc_get_varm(ncid, varid,
 			stp, cntp, strdp, imp, value);
-	A_FREE(imp);
+	if (imp!=NULL) free(imp);
 	A_FREE(strdp);
 	A_FREE(cntp);
 	A_FREE(stp);
@@ -934,6 +963,7 @@ ncvargetg(
 	}
 	return 0;
 	}
+	}
 }
 
 
diff --git a/libdispatch/dvar.c b/libdispatch/dvar.c
index ec0d830..021f6a6 100644
--- a/libdispatch/dvar.c
+++ b/libdispatch/dvar.c
@@ -326,15 +326,15 @@ isrecvar = (nrecdims > 0);
 \endcode
  */
 int
-NC_inq_recvar(int ncid, int varid, int *nrecdims, int *is_recdim)
+NC_inq_recvar(int ncid, int varid, int* nrecdimsp, int *is_recdim)
 {
    int status = NC_NOERR;
    int unlimid;
    int nvardims;
    int dimset[NC_MAX_VAR_DIMS];
    int dim;
+   int nrecdims = 0;
     
-   *nrecdims = 0;
    status = nc_inq_varndims(ncid,varid,&nvardims);
    if(status != NC_NOERR) return status;
    if(nvardims == 0) return NC_NOERR; /* scalars have no dims */
@@ -357,7 +357,7 @@ NC_inq_recvar(int ncid, int varid, int *nrecdims, int *is_recdim)
        for(recdim = 0; recdim < nunlimdims; recdim++) {
 	 if(dimset[dim] == unlimids[recdim]) {
 	   is_recdim[dim] = 1;
-	   *nrecdims += 1;
+	   nrecdims++;
 	 }		
        }
      }
@@ -367,9 +367,10 @@ NC_inq_recvar(int ncid, int varid, int *nrecdims, int *is_recdim)
    if(status != NC_NOERR) return status;
    if(dimset[0] == unlimid) {
      is_recdim[0] = 1;
-     *nrecdims++;
+     nrecdims++;
    }
 #endif /* USE_NETCDF4 */
+   if(nrecdimsp) *nrecdimsp = nrecdims;
    return status;
 }
 
diff --git a/libdispatch/dvarget.c b/libdispatch/dvarget.c
index cd0e832..8b940c8 100644
--- a/libdispatch/dvarget.c
+++ b/libdispatch/dvarget.c
@@ -277,7 +277,6 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
    int varndims,maxidim;
    NC* ncp;
    int memtypelen;
-   ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
    char* value = (char*)value0;
 
    status = NC_check_id (ncid, &ncp);
@@ -297,21 +296,6 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
    if(status != NC_NOERR) return status;
 
    if(memtype == NC_NAT) {
-      if(imapp != NULL && varndims != 0) {
-	 /*
-	  * convert map units from bytes to units of sizeof(type)
-	  */
-	 size_t ii;
-	 const ptrdiff_t szof = (ptrdiff_t) nctypelen(vartype);
-	 for(ii = 0; ii < varndims; ii++) {
-	    if(imapp[ii] % szof != 0) {
-	       /*free(cvtmap);*/
-	       return NC_EINVAL;
-	    }
-	    cvtmap[ii] = imapp[ii] / szof;
-	 }
-	 imapp = cvtmap;
-      }
       memtype = vartype;
    }
 
@@ -424,7 +408,8 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
 	    ? stride[idim]
 	    : 1;
 
-	 /* Remember: imapp is byte oriented, not index oriented */
+	 /* Remember: in netCDF-2 imapp is byte oriented, not index oriented
+	  *           Starting from netCDF-3, imapp is index oriented */
 #ifdef COMPLEX
 	 mymap[idim] = (imapp != NULL
 			? imapp[idim]
diff --git a/libdispatch/dvarput.c b/libdispatch/dvarput.c
index 71958f0..f8341ac 100644
--- a/libdispatch/dvarput.c
+++ b/libdispatch/dvarput.c
@@ -122,7 +122,7 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
   /* Rebuilt put_vars code to simplify and avoid use of put_varm */
   
    int status = NC_NOERR;
-   int i,simplestride,isrecvar;
+   int i,isstride1,isrecvar;
    int rank;
    struct PUTodometer odom;
    nc_type vartype = NC_NAT;
@@ -131,13 +131,12 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
    int memtypelen;
    const char* value = (const char*)value0;
    size_t numrecs;
-   int nrecdims;		   /* number of record dims for a variable */
+   int nrecdims;                /* number of record dims for a variable */
    int is_recdim[NC_MAX_VAR_DIMS]; /* for variable's dimensions */
    size_t varshape[NC_MAX_VAR_DIMS];
    size_t mystart[NC_MAX_VAR_DIMS];
    size_t myedges[NC_MAX_VAR_DIMS];
    ptrdiff_t mystride[NC_MAX_VAR_DIMS];
-
    const char* memptr = value;
 
    status = NC_check_id (ncid, &ncp);
@@ -173,7 +172,9 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
    if(status != NC_NOERR) return status;
 
    /* Get variable dimension sizes */
-   /* isrecvar = NC_is_recvar(ncid,varid,&numrecs); */
+#if 0
+   isrecvar = NC_is_recvar(ncid,varid,&numrecs);
+#endif
    status = NC_inq_recvar(ncid,varid,&nrecdims,is_recdim);
    if(status != NC_NOERR) return status;
    isrecvar = (nrecdims > 0);
@@ -191,13 +192,18 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
    }
 
    /* Do various checks and fixups on start/edges/stride */
-   simplestride = 1; /* assume so */
+   isstride1 = 1; /* assume so */
    for(i=0;i<rank;i++) {
 	size_t dimlen;
 	mystart[i] = (start == NULL ? 0 : start[i]);
 	if(edges == NULL) {
+#if 0
+	   if(i == 0 && isrecvar)
+  	      myedges[i] = numrecs - start[i];
+#else
 	   if(is_recdim[i] && isrecvar)
   	      myedges[i] = varshape[i] - start[i];
+#endif
 	   else
 	      myedges[i] = varshape[i] - mystart[i];
 	} else
@@ -209,10 +215,15 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
 	   /* cast needed for braindead systems with signed size_t */
            || ((unsigned long) mystride[i] >= X_INT_MAX))
            return NC_ESTRIDE;
-  	if(mystride[i] != 1) simplestride = 0;	
+  	if(mystride[i] != 1) isstride1 = 0;	
         /* illegal value checks */
+#if 0
+	dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
+	if(i == 0 && isrecvar) {/*do nothing*/}
+#else
 	dimlen = varshape[i];
 	if(is_recdim[i]) {/*do nothing*/}
+#endif
         else {
 	  /* mystart is unsigned, will never be < 0 */
 	  if(mystart[i] > dimlen)
@@ -222,7 +233,7 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
 	    return NC_EEDGE;
        }
    }
-   if(simplestride) {
+   if(isstride1) {
       return NC_put_vara(ncid, varid, mystart, myedges, value, memtype);
    }
 
@@ -273,7 +284,6 @@ NCDEFAULT_put_varm(
    int maxidim = 0;
    NC* ncp;
    int memtypelen;
-   ptrdiff_t cvtmap[NC_MAX_VAR_DIMS];
    const char* value = (char*)value0;
 
    status = NC_check_id (ncid, &ncp);
@@ -295,21 +305,6 @@ NCDEFAULT_put_varm(
    if(status != NC_NOERR) return status;
 
    if(memtype == NC_NAT) {
-      if(imapp != NULL && varndims != 0) {
-	 /*
-	  * convert map units from bytes to units of sizeof(type)
-	  */
-	 size_t ii;
-	 const ptrdiff_t szof = (ptrdiff_t) nctypelen(vartype);
-	 for(ii = 0; ii < varndims; ii++) {
-	    if(imapp[ii] % szof != 0) {
-	       /*free(cvtmap);*/
-	       return NC_EINVAL;
-	    }
-	    cvtmap[ii] = imapp[ii] / szof;
-	 }
-	 imapp = cvtmap;
-      }
       memtype = vartype;
    }
 
@@ -340,12 +335,12 @@ NCDEFAULT_put_varm(
    {
       int idim;
       size_t *mystart = NULL;
-      size_t *myedges;
-      size_t *iocount;    /* count vector */
-      size_t *stop;   /* stop indexes */
-      size_t *length; /* edge lengths in bytes */
-      ptrdiff_t *mystride;
-      ptrdiff_t *mymap;
+      size_t *myedges = 0;
+      size_t *iocount= 0;    /* count vector */
+      size_t *stop = 0;   /* stop indexes */
+      size_t *length = 0; /* edge lengths in bytes */
+      ptrdiff_t *mystride = 0;
+      ptrdiff_t *mymap= 0;
       size_t varshape[NC_MAX_VAR_DIMS];
       int isrecvar;
       size_t numrecs;
diff --git a/libdispatch/nc.c b/libdispatch/nc.c
index 85ce226..a8c8ab5 100644
--- a/libdispatch/nc.c
+++ b/libdispatch/nc.c
@@ -85,13 +85,15 @@ nc_set_default_format(int format, int *old_formatp)
 
     /* Make sure only valid format is set. */
 #ifdef USE_NETCDF4
-    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT &&
-	format != NC_FORMAT_NETCDF4 && format != NC_FORMAT_NETCDF4_CLASSIC)
+    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET &&
+        format != NC_FORMAT_NETCDF4 && format != NC_FORMAT_NETCDF4_CLASSIC &&
+	format != NC_FORMAT_CDF5)
       return NC_EINVAL;
-#else
-    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT)
-      return NC_EINVAL;
-#endif
+ #else
+    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET &&
+        format != NC_FORMAT_CDF5)
+       return NC_EINVAL;
+ #endif
     default_create_format = format;
     return NC_NOERR;
 }
diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c
index 5858e5e..9d29685 100644
--- a/libdispatch/ncuri.c
+++ b/libdispatch/ncuri.c
@@ -592,7 +592,7 @@ than once, then the first occurrence is used; this is so
 that is possible to forcibly override user specified
 parameters by prefixing.  IMPORTANT: client parameter string
 is assumed to have blanks compressed out.  Returns 1 if parse
-suceeded, 0 otherwise; */
+succeeded, 0 otherwise; */
 
 int
 ncuridecodeparams(NCURI* ncuri)
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index 9f4b00e..cc39c19 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -17,15 +17,12 @@ IF(USE_DAP)
   SET(liblib_LIBS ${liblib_LIBS} oc2 dap2)
 ENDIF()
 
-IF(BUILD_CDMREMOTE)
-  SET(liblib_LIBS ${liblib_LIBS} cdmr)
-ENDIF()
 
 FOREACH(LIBS ${liblib_LIBS})
   SET(LARGS ${LARGS} $<TARGET_OBJECTS:${LIBS}>)
 ENDFOREACH()
 
-ADD_LIBRARY(netcdf stub.c ${LARGS} )
+ADD_LIBRARY(netcdf nc_initialize.c ${LARGS} )
 IF(MOD_NETCDF_NAME)
   SET_TARGET_PROPERTIES(netcdf PROPERTIES LIBRARY_OUTPUT_NAME ${NETCDF_LIB_NAME})
   SET_TARGET_PROPERTIES(netcdf PROPERTIES ARCHIVE_OUTPUT_NAME ${NETCDF_LIB_NAME})
@@ -102,16 +99,30 @@ SET_TARGET_PROPERTIES(netcdf PROPERTIES
   SOVERSION ${netCDF_SO_VERSION}
   )
 
-INSTALL(
-  TARGETS netcdf EXPORT netCDFTargets
-  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-    COMPONENT libraries
-  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-    COMPONENT libraries
-  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-    COMPONENT libraries
-  INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-  )
+###
+# The INCLUDES directive was introduced in 2.8.12.
+# However, 2.8.11 is still the default on some
+# popular linux distributions. See
+# https://github.com/Unidata/netcdf-c/issues/135
+# for more information.
+###
+IF(${CMAKE_VERSION} VERSION_LESS 2.8.12)
+  INSTALL(
+    TARGETS netcdf EXPORT netCDFTargets
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
+    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+    )
+ELSE()
+    INSTALL(
+    TARGETS netcdf EXPORT netCDFTargets
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
+    INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+    )
+ENDIF()
 
 SET(ALL_TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)
 SET(NC_LIBS ${NC_LIBS} PARENT_SCOPE)
diff --git a/liblib/Makefile.am b/liblib/Makefile.am
index b390d69..be53dab 100755
--- a/liblib/Makefile.am
+++ b/liblib/Makefile.am
@@ -19,7 +19,7 @@ lib_LTLIBRARIES = libnetcdf.la
 # for information regarding incrementing `-version-info`.
 ##
 
-libnetcdf_la_LDFLAGS = -version-info 10:0:3
+libnetcdf_la_LDFLAGS = -version-info 10:0:3 ${NOUNDEFINED}
 
 libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS}
 libnetcdf_la_LIBADD =
@@ -64,13 +64,8 @@ libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la
 # Not ready for prime time yet
 # libnetcdf_la_LIBADD += ${top_builddir}/libdiskless/libdiskless.la
 
-# netcdf4+cdmremote
-if BUILD_CDMREMOTE
-libnetcdf_la_LIBADD += ${top_builddir}/libcdmr/libnccr.la
-endif # BUILD_CDMREMOTE
-
 endif #USE_NETCDF4
 
 # We need at least one source file
-libnetcdf_la_SOURCES = stub.c
-EXTRA_DIST=CMakeLists.txt
+libnetcdf_la_SOURCES = nc_initialize.c
+EXTRA_DIST=CMakeLists.txt 
diff --git a/liblib/Makefile.in b/liblib/Makefile.in
index bd7464f..3897af4 100644
--- a/liblib/Makefile.in
+++ b/liblib/Makefile.in
@@ -128,12 +128,6 @@ target_triplet = @target@
 # NetCDF-4 ...
 @USE_NETCDF4_TRUE at am__append_10 = -I${top_srcdir}/libsrc4
 @USE_NETCDF4_TRUE at am__append_11 = ${top_builddir}/libsrc4/libnetcdf4.la
-
-# Not ready for prime time yet
-# libnetcdf_la_LIBADD += ${top_builddir}/libdiskless/libdiskless.la
-
-# netcdf4+cdmremote
- at BUILD_CDMREMOTE_TRUE@@USE_NETCDF4_TRUE at am__append_12 = ${top_builddir}/libcdmr/libnccr.la
 subdir = liblib
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -179,8 +173,8 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
 libnetcdf_la_DEPENDENCIES = $(am__append_5) \
 	${top_builddir}/libdispatch/libdispatch.la \
 	${top_builddir}/libsrc/libnetcdf3.la $(am__append_7) \
-	$(am__append_9) $(am__append_11) $(am__append_12)
-am_libnetcdf_la_OBJECTS = libnetcdf_la-stub.lo
+	$(am__append_9) $(am__append_11)
+am_libnetcdf_la_OBJECTS = libnetcdf_la-nc_initialize.lo
 libnetcdf_la_OBJECTS = $(am_libnetcdf_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
@@ -302,6 +296,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -334,6 +329,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -345,6 +341,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -432,7 +429,8 @@ lib_LTLIBRARIES = libnetcdf.la
 # Note: version-info of "9:0:2" results in soname of libnetcdf.so.7 -> libnetcdf.so.7.2.0
 # See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
 # for information regarding incrementing `-version-info`.
-libnetcdf_la_LDFLAGS = -version-info 10:0:3 $(am__append_3)
+libnetcdf_la_LDFLAGS = -version-info 10:0:3 ${NOUNDEFINED} \
+	$(am__append_3)
 libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS} $(am__append_4)
 
 # The output library will always include netcdf3 and dispatch
@@ -440,12 +438,15 @@ libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS} $(am__append_4)
 libnetcdf_la_LIBADD = $(am__append_5) \
 	${top_builddir}/libdispatch/libdispatch.la \
 	${top_builddir}/libsrc/libnetcdf3.la $(am__append_7) \
-	$(am__append_9) $(am__append_11) $(am__append_12)
+	$(am__append_9) $(am__append_11)
 CLEANFILES = 
 
+# Not ready for prime time yet
+# libnetcdf_la_LIBADD += ${top_builddir}/libdiskless/libdiskless.la
+
 # We need at least one source file
-libnetcdf_la_SOURCES = stub.c
-EXTRA_DIST = CMakeLists.txt
+libnetcdf_la_SOURCES = nc_initialize.c
+EXTRA_DIST = CMakeLists.txt 
 all: all-am
 
 .SUFFIXES:
@@ -525,7 +526,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnetcdf_la-stub.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnetcdf_la-nc_initialize.Plo at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -551,12 +552,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
-libnetcdf_la-stub.lo: stub.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnetcdf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnetcdf_la-stub.lo -MD -MP -MF $(DEPDIR)/libnetcdf_la-stub.Tpo -c -o libnetcdf_la-stub.lo `test -f 'stub.c' || echo '$(srcdir)/'`stub.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libnetcdf_la-stub.Tpo $(DEPDIR)/libnetcdf_la-stub.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stub.c' object='libnetcdf_la-stub.lo' libtool=yes @AMDEPBACKSLASH@
+libnetcdf_la-nc_initialize.lo: nc_initialize.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnetcdf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libnetcdf_la-nc_initialize.lo -MD -MP -MF $(DEPDIR)/libnetcdf_la-nc_initialize.Tpo -c -o libnetcdf_la-nc_initialize.lo `test -f 'nc_initialize.c' || echo '$(srcdir)/'`nc_initialize.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libnetcdf_la-nc_initialize.Tpo $(DEPDIR)/libnetcdf_la-nc_initialize.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='nc_initialize.c' object='libnetcdf_la-nc_initialize.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnetcdf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnetcdf_la-stub.lo `test -f 'stub.c' || echo '$(srcdir)/'`stub.c
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libnetcdf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libnetcdf_la-nc_initialize.lo `test -f 'nc_initialize.c' || echo '$(srcdir)/'`nc_initialize.c
 
 mostlyclean-libtool:
 	-rm -f *.lo
diff --git a/liblib/liblib.c b/liblib/liblib.c
deleted file mode 100644
index 2393c29..0000000
--- a/liblib/liblib.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*********************************************************************
- *   Copyright 2010, UCAR/Unidata
- *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *********************************************************************/
-
-/* $Id: liblib.c,v 1.2 2010/05/24 19:48:13 dmh Exp $ */
-/* $Header: /upc/share/CVS/netcdf-3/liblib/liblib.c,v 1.2 2010/05/24 19:48:13 dmh Exp $ */
-
-/* Only here to keep loader quiet */
-int
-liblib(void)
-{
-    return 1;
-}
-
diff --git a/liblib/nc_initialize.c b/liblib/nc_initialize.c
new file mode 100644
index 0000000..81f1a2c
--- /dev/null
+++ b/liblib/nc_initialize.c
@@ -0,0 +1,122 @@
+/*********************************************************************
+ *   Copyright 2010, UCAR/Unidata
+ *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
+ *********************************************************************/
+
+#include "config.h"
+
+#ifdef USE_PARALLEL
+#include <mpi.h>
+#endif
+
+#include "ncdispatch.h"
+
+extern int NC3_initialize(void);
+extern int NC3_finalize(void);
+
+#ifdef USE_NETCDF4
+extern int NC4_initialize(void);
+extern int NC4_finalize(void);
+#endif
+
+#ifdef USE_DAP
+extern int NCD2_initialize(void);
+extern int NCD2_finalize(void);
+#endif
+
+#ifdef USE_PNETCDF
+extern int NCP_initialize(void);
+extern int NCP_finalize(void);
+#endif
+
+int NC_argc = 1;
+char* NC_argv[] = {"nc_initialize",NULL};
+
+int NC_initialized = 0;
+int NC_finalized = 1;
+
+/**
+This procedure invokes all defined
+initializers, and there is an initializer
+for every known dispatch table.
+So if you modify the format of NC_Dispatch,
+then you need to fix it everywhere.
+It also initializes appropriate external libraries.
+*/
+
+int
+nc_initialize()
+{
+    int stat = NC_NOERR;
+
+    if(NC_initialized) return NC_NOERR;
+    NC_initialized = 1;
+    NC_finalized = 0;
+
+    /* Do general initialization */
+    if((stat = NCDISPATCH_initialize())) return stat;
+
+    /* Initialize each active protocol */
+
+    if((stat = NCSUBSTRATE_initialize())) return stat;
+
+    if((stat = NC3_initialize())) return stat;
+
+#ifdef USE_DAP
+    if((stat = NCD2_initialize())) return stat;
+#endif
+
+#ifdef USE_PNETCDF
+    if((stat = NCP_initialize())) return stat;
+#endif
+
+#ifdef USE_NETCDF4
+    if((stat = NC4_initialize())) return stat;
+#endif /* USE_NETCDF4 */
+
+    return NC_NOERR;
+}
+
+/**
+This procedure invokes all defined
+finalizers, and there should be one
+for every known dispatch table.
+So if you modify the format of NC_Dispatch,
+then you need to fix it everywhere.
+It also finalizes appropriate external libraries.
+*/
+
+int
+nc_finalize(void)
+{
+    int stat = NC_NOERR;
+
+    if(NC_finalized) return NC_NOERR;
+    NC_initialized = 0;
+    NC_finalized = 1;
+
+    /* Finalize each active protocol */
+
+#ifdef USE_DAP
+    if((stat = NCD2_finalize())) return stat;
+#endif
+
+#ifdef USE_PNETCDF
+    if((stat = NCP_finalize())) return stat;
+#endif
+
+#ifdef USE_NETCDF4
+    if((stat = NC4_finalize())) return stat;
+#endif /* USE_NETCDF4 */
+
+    if((stat = NC3_finalize())) return stat;
+
+    if((stat = NCSUBSTRATE_finalize())) return stat;
+
+    /* Do general finalization */
+    if((stat = NCDISPATCH_finalize())) return stat;
+
+    return NC_NOERR;
+}
+
+
diff --git a/liblib/stub.c b/liblib/stub.c
deleted file mode 100644
index 58c39fc..0000000
--- a/liblib/stub.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*********************************************************************
- *   Copyright 2010, UCAR/Unidata
- *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *********************************************************************/
-
-#include "config.h"
-#include "ncdispatch.h"
-
-extern int NC3_initialize(void);
-
-extern int NCSUBSTRATE_initialize(void);
-
-#ifdef USE_NETCDF4
-extern int NC4_initialize(void);
-#endif
-
-#ifdef USE_DAP
-extern int NCD2_initialize(void);
-#endif
-
-#ifdef USE_CDMREMOTE
-extern int NCCR_initialize(void);
-#endif
-
-#ifdef USE_PNETCDF
-extern int NCP_initialize(void);
-#endif
-
-/**
-This procedure invokes all defined
-initializers, and there is an initializer
-for every known dispatch table.
-So if you modify the format of NC_Dispatch,
-then you need to fix it everywhere.
-*/
-
-int
-NC_initialize(void)
-{
-    int stat = NC_NOERR;
-
-    /* Allow libdispatch to do initialization */
-    if((stat = NCDISPATCH_initialize())) return stat;
-
-    /* Initialize each active protocol */
-
-    if((stat = NC3_initialize())) return stat;
-
-#ifdef USE_DAP
-    if((stat = NCD2_initialize())) return stat;
-#endif
-
-#ifdef USE_PNETCDF
-    if((stat = NCP_initialize())) return stat;
-#endif
-
-#ifdef USE_NETCDF4
-    if((stat = NC4_initialize())) return stat;
-
-    /* if((stat = NCD_initialize())) return stat; */
-
-#ifdef USE_DAP
-#ifdef NOTUSED
-    if((stat = NCD4_initialize())) return stat;
-#endif
-#endif
-
-#ifdef USE_CDMREMOTE
-    if((stat = NCCR_initialize())) return stat;
-#endif
-
-#endif /* USE_NETCDF4 */
-
-    /* Finally, initialize the SUBSTRATE table (dsubstrate.c) */
-    if((stat = NCSUBSTRATE_initialize())) return stat;
-
-    return NC_NOERR;
-}
-
-
diff --git a/libnetcdf.settings.in b/libnetcdf.settings.in
index 7326692..32f565e 100644
--- a/libnetcdf.settings.in
+++ b/libnetcdf.settings.in
@@ -26,11 +26,12 @@ Extra libraries:	@LIBS@
 --------
 NetCDF-2 API:		@HAS_NC2@
 NetCDF-4 API:		@HAS_NC4@
+CDF-5 Support:		yes
 HDF4 Support:		@HAS_HDF4@
 HDF5 Support:		@HAS_HDF5@
 HDF5/SZIP Support:      @HAS_SZIP@
 PNetCDF Support:	@HAS_PNETCDF@
-Parallel Support:	@HAS_PARALLEL@
+NC-4 Parallel Support:	@HAS_PARALLEL4@
 DAP Support:		@HAS_DAP@
 Diskless Support:	@HAS_DISKLESS@
 MMap Support:		@HAS_MMAP@
diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt
index 6579773..ee41fc4 100644
--- a/libsrc/CMakeLists.txt
+++ b/libsrc/CMakeLists.txt
@@ -11,7 +11,8 @@ endforeach(f)
 
 SET(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c
   nc3internal.c var.c dim.c ncx.c lookup3.c ncio.c)
-SET(libsrc_SOURCES ${libsrc_SOURCES} pstdint.h)
+
+SET(libsrc_SOURCES ${libsrc_SOURCES} pstdint.h ncio.h ncx.h)
 
 IF (BUILD_DISKLESS)
   SET(libsrc_SOURCES ${libsrc_SOURCES} memio.c)
@@ -23,6 +24,8 @@ ENDIF (BUILD_DISKLESS)
 
 IF (USE_FFIO)
   SET(libsrc_SOURCES ${libsrc_SOURCES} ffio.c)
+ELSEIF (USE_STDIO)
+    SET(libsrc_SORUCES ${libsrc_SOURCES} ncstdio.c)
 ELSE (USE_FFIO)
   SET(libsrc_SOURCES ${libsrc_SOURCES} posixio.c)
 ENDIF (USE_FFIO)
diff --git a/libsrc/Makefile.in b/libsrc/Makefile.in
index 9c2d56f..bb29fcd 100644
--- a/libsrc/Makefile.in
+++ b/libsrc/Makefile.in
@@ -301,6 +301,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -333,6 +334,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -344,6 +346,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/libsrc/attr.c b/libsrc/attr.c
index 22a961d..f02d5b3 100644
--- a/libsrc/attr.c
+++ b/libsrc/attr.c
@@ -1,11 +1,8 @@
-#line 5 "attr.m4"
 /* Do not edit this file. It is produced from the corresponding .m4 source */
-#line 7
 /*
  *	Copyright 1996, University Corporation for Atmospheric Research
  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
-/* $Id: attr.m4,v 2.39 2010/05/26 18:11:08 dmh Exp $ */
 
 #include "nc3internal.h"
 #include "ncdispatch.h"
@@ -54,6 +51,16 @@ ncx_len_NC_attrV(nc_type type, size_t nelems)
 		return ncx_len_float(nelems);
 	case NC_DOUBLE:
 		return ncx_len_double(nelems);
+	case NC_UBYTE:
+		return ncx_len_ubyte(nelems);
+	case NC_USHORT:
+		return ncx_len_ushort(nelems);
+	case NC_UINT:
+		return ncx_len_uint(nelems);
+	case NC_INT64:
+		return ncx_len_int64(nelems);
+	case NC_UINT64:
+		return ncx_len_uint64(nelems);
 	default:
 	        assert("ncx_len_NC_attr bad type" == 0);
 	}
@@ -391,7 +398,7 @@ NC_lookupattr(int ncid,
 	if(attrpp != NULL)
 		*attrpp = *tmp;
 
-	return ENOERR;
+	return NC_NOERR;
 }
 
 /* Public */
@@ -613,704 +620,722 @@ NC3_del_att(int ncid, int varid, const char *uname)
 	return NC_NOERR;
 }
 
-#line 674
 
 static int
-#line 675
 ncx_pad_putn_Iuchar(void **xpp, size_t nelems, const uchar *tp, nc_type type)
-#line 675
 {
-#line 675
 	switch(type) {
-#line 675
 	case NC_CHAR:
-#line 675
 		return NC_ECHAR;
-#line 675
 	case NC_BYTE:
-#line 675
 		return ncx_pad_putn_schar_uchar(xpp, nelems, tp);
-#line 675
 	case NC_SHORT:
-#line 675
 		return ncx_pad_putn_short_uchar(xpp, nelems, tp);
-#line 675
 	case NC_INT:
-#line 675
 		return ncx_putn_int_uchar(xpp, nelems, tp);
-#line 675
 	case NC_FLOAT:
-#line 675
 		return ncx_putn_float_uchar(xpp, nelems, tp);
-#line 675
 	case NC_DOUBLE:
-#line 675
 		return ncx_putn_double_uchar(xpp, nelems, tp);
-#line 675
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_uchar(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_uchar(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_uchar(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_uchar(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_uchar(xpp, nelems, tp);
 	default:
-#line 675
                 assert("ncx_pad_putn_Iuchar invalid type" == 0);
-#line 675
 	}
-#line 675
 	return NC_EBADTYPE;
-#line 675
 }
-#line 675
 
 static int
-#line 676
 ncx_pad_getn_Iuchar(const void **xpp, size_t nelems, uchar *tp, nc_type type)
-#line 676
 {
-#line 676
 	switch(type) {
-#line 676
 	case NC_CHAR:
-#line 676
 		return NC_ECHAR;
-#line 676
 	case NC_BYTE:
-#line 676
 		return ncx_pad_getn_schar_uchar(xpp, nelems, tp);
-#line 676
 	case NC_SHORT:
-#line 676
 		return ncx_pad_getn_short_uchar(xpp, nelems, tp);
-#line 676
 	case NC_INT:
-#line 676
 		return ncx_getn_int_uchar(xpp, nelems, tp);
-#line 676
 	case NC_FLOAT:
-#line 676
 		return ncx_getn_float_uchar(xpp, nelems, tp);
-#line 676
 	case NC_DOUBLE:
-#line 676
 		return ncx_getn_double_uchar(xpp, nelems, tp);
-#line 676
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_uchar(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_uchar(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_uchar(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_uchar(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_uchar(xpp, nelems, tp);
 	default:
-#line 676
 	        assert("ncx_pad_getn_Iuchar invalid type" == 0);
-#line 676
 	}
-#line 676
 	return NC_EBADTYPE;
-#line 676
 }
-#line 676
 
 
 static int
-#line 678
 ncx_pad_putn_Ischar(void **xpp, size_t nelems, const schar *tp, nc_type type)
-#line 678
 {
-#line 678
 	switch(type) {
-#line 678
 	case NC_CHAR:
-#line 678
 		return NC_ECHAR;
-#line 678
 	case NC_BYTE:
-#line 678
 		return ncx_pad_putn_schar_schar(xpp, nelems, tp);
-#line 678
 	case NC_SHORT:
-#line 678
 		return ncx_pad_putn_short_schar(xpp, nelems, tp);
-#line 678
 	case NC_INT:
-#line 678
 		return ncx_putn_int_schar(xpp, nelems, tp);
-#line 678
 	case NC_FLOAT:
-#line 678
 		return ncx_putn_float_schar(xpp, nelems, tp);
-#line 678
 	case NC_DOUBLE:
-#line 678
 		return ncx_putn_double_schar(xpp, nelems, tp);
-#line 678
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_schar(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_schar(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_schar(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_schar(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_schar(xpp, nelems, tp);
 	default:
-#line 678
                 assert("ncx_pad_putn_Ischar invalid type" == 0);
-#line 678
 	}
-#line 678
 	return NC_EBADTYPE;
-#line 678
 }
-#line 678
 
 static int
-#line 679
 ncx_pad_getn_Ischar(const void **xpp, size_t nelems, schar *tp, nc_type type)
-#line 679
 {
-#line 679
 	switch(type) {
-#line 679
 	case NC_CHAR:
-#line 679
 		return NC_ECHAR;
-#line 679
 	case NC_BYTE:
-#line 679
 		return ncx_pad_getn_schar_schar(xpp, nelems, tp);
-#line 679
 	case NC_SHORT:
-#line 679
 		return ncx_pad_getn_short_schar(xpp, nelems, tp);
-#line 679
 	case NC_INT:
-#line 679
 		return ncx_getn_int_schar(xpp, nelems, tp);
-#line 679
 	case NC_FLOAT:
-#line 679
 		return ncx_getn_float_schar(xpp, nelems, tp);
-#line 679
 	case NC_DOUBLE:
-#line 679
 		return ncx_getn_double_schar(xpp, nelems, tp);
-#line 679
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_schar(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_schar(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_schar(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_schar(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_schar(xpp, nelems, tp);
 	default:
-#line 679
 	        assert("ncx_pad_getn_Ischar invalid type" == 0);
-#line 679
 	}
-#line 679
 	return NC_EBADTYPE;
-#line 679
 }
-#line 679
 
 
 static int
-#line 681
 ncx_pad_putn_Ishort(void **xpp, size_t nelems, const short *tp, nc_type type)
-#line 681
 {
-#line 681
 	switch(type) {
-#line 681
 	case NC_CHAR:
-#line 681
 		return NC_ECHAR;
-#line 681
 	case NC_BYTE:
-#line 681
 		return ncx_pad_putn_schar_short(xpp, nelems, tp);
-#line 681
 	case NC_SHORT:
-#line 681
 		return ncx_pad_putn_short_short(xpp, nelems, tp);
-#line 681
 	case NC_INT:
-#line 681
 		return ncx_putn_int_short(xpp, nelems, tp);
-#line 681
 	case NC_FLOAT:
-#line 681
 		return ncx_putn_float_short(xpp, nelems, tp);
-#line 681
 	case NC_DOUBLE:
-#line 681
 		return ncx_putn_double_short(xpp, nelems, tp);
-#line 681
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_short(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_short(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_short(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_short(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_short(xpp, nelems, tp);
 	default:
-#line 681
                 assert("ncx_pad_putn_Ishort invalid type" == 0);
-#line 681
 	}
-#line 681
 	return NC_EBADTYPE;
-#line 681
 }
-#line 681
 
 static int
-#line 682
 ncx_pad_getn_Ishort(const void **xpp, size_t nelems, short *tp, nc_type type)
-#line 682
 {
-#line 682
 	switch(type) {
-#line 682
 	case NC_CHAR:
-#line 682
 		return NC_ECHAR;
-#line 682
 	case NC_BYTE:
-#line 682
 		return ncx_pad_getn_schar_short(xpp, nelems, tp);
-#line 682
 	case NC_SHORT:
-#line 682
 		return ncx_pad_getn_short_short(xpp, nelems, tp);
-#line 682
 	case NC_INT:
-#line 682
 		return ncx_getn_int_short(xpp, nelems, tp);
-#line 682
 	case NC_FLOAT:
-#line 682
 		return ncx_getn_float_short(xpp, nelems, tp);
-#line 682
 	case NC_DOUBLE:
-#line 682
 		return ncx_getn_double_short(xpp, nelems, tp);
-#line 682
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_short(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_short(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_short(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_short(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_short(xpp, nelems, tp);
 	default:
-#line 682
 	        assert("ncx_pad_getn_Ishort invalid type" == 0);
-#line 682
 	}
-#line 682
 	return NC_EBADTYPE;
-#line 682
 }
-#line 682
 
 
 static int
-#line 684
 ncx_pad_putn_Iint(void **xpp, size_t nelems, const int *tp, nc_type type)
-#line 684
 {
-#line 684
 	switch(type) {
-#line 684
 	case NC_CHAR:
-#line 684
 		return NC_ECHAR;
-#line 684
 	case NC_BYTE:
-#line 684
 		return ncx_pad_putn_schar_int(xpp, nelems, tp);
-#line 684
 	case NC_SHORT:
-#line 684
 		return ncx_pad_putn_short_int(xpp, nelems, tp);
-#line 684
 	case NC_INT:
-#line 684
 		return ncx_putn_int_int(xpp, nelems, tp);
-#line 684
 	case NC_FLOAT:
-#line 684
 		return ncx_putn_float_int(xpp, nelems, tp);
-#line 684
 	case NC_DOUBLE:
-#line 684
 		return ncx_putn_double_int(xpp, nelems, tp);
-#line 684
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_int(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_int(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_int(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_int(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_int(xpp, nelems, tp);
 	default:
-#line 684
                 assert("ncx_pad_putn_Iint invalid type" == 0);
-#line 684
 	}
-#line 684
 	return NC_EBADTYPE;
-#line 684
 }
-#line 684
 
 static int
-#line 685
 ncx_pad_getn_Iint(const void **xpp, size_t nelems, int *tp, nc_type type)
-#line 685
 {
-#line 685
 	switch(type) {
-#line 685
 	case NC_CHAR:
-#line 685
 		return NC_ECHAR;
-#line 685
 	case NC_BYTE:
-#line 685
 		return ncx_pad_getn_schar_int(xpp, nelems, tp);
-#line 685
 	case NC_SHORT:
-#line 685
 		return ncx_pad_getn_short_int(xpp, nelems, tp);
-#line 685
 	case NC_INT:
-#line 685
 		return ncx_getn_int_int(xpp, nelems, tp);
-#line 685
 	case NC_FLOAT:
-#line 685
 		return ncx_getn_float_int(xpp, nelems, tp);
-#line 685
 	case NC_DOUBLE:
-#line 685
 		return ncx_getn_double_int(xpp, nelems, tp);
-#line 685
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_int(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_int(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_int(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_int(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_int(xpp, nelems, tp);
 	default:
-#line 685
 	        assert("ncx_pad_getn_Iint invalid type" == 0);
-#line 685
 	}
-#line 685
 	return NC_EBADTYPE;
-#line 685
 }
-#line 685
 
 
 static int
-#line 687
 ncx_pad_putn_Ifloat(void **xpp, size_t nelems, const float *tp, nc_type type)
-#line 687
 {
-#line 687
 	switch(type) {
-#line 687
 	case NC_CHAR:
-#line 687
 		return NC_ECHAR;
-#line 687
 	case NC_BYTE:
-#line 687
 		return ncx_pad_putn_schar_float(xpp, nelems, tp);
-#line 687
 	case NC_SHORT:
-#line 687
 		return ncx_pad_putn_short_float(xpp, nelems, tp);
-#line 687
 	case NC_INT:
-#line 687
 		return ncx_putn_int_float(xpp, nelems, tp);
-#line 687
 	case NC_FLOAT:
-#line 687
 		return ncx_putn_float_float(xpp, nelems, tp);
-#line 687
 	case NC_DOUBLE:
-#line 687
 		return ncx_putn_double_float(xpp, nelems, tp);
-#line 687
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_float(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_float(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_float(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_float(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_float(xpp, nelems, tp);
 	default:
-#line 687
                 assert("ncx_pad_putn_Ifloat invalid type" == 0);
-#line 687
 	}
-#line 687
 	return NC_EBADTYPE;
-#line 687
 }
-#line 687
 
 static int
-#line 688
 ncx_pad_getn_Ifloat(const void **xpp, size_t nelems, float *tp, nc_type type)
-#line 688
 {
-#line 688
 	switch(type) {
-#line 688
 	case NC_CHAR:
-#line 688
 		return NC_ECHAR;
-#line 688
 	case NC_BYTE:
-#line 688
 		return ncx_pad_getn_schar_float(xpp, nelems, tp);
-#line 688
 	case NC_SHORT:
-#line 688
 		return ncx_pad_getn_short_float(xpp, nelems, tp);
-#line 688
 	case NC_INT:
-#line 688
 		return ncx_getn_int_float(xpp, nelems, tp);
-#line 688
 	case NC_FLOAT:
-#line 688
 		return ncx_getn_float_float(xpp, nelems, tp);
-#line 688
 	case NC_DOUBLE:
-#line 688
 		return ncx_getn_double_float(xpp, nelems, tp);
-#line 688
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_float(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_float(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_float(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_float(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_float(xpp, nelems, tp);
 	default:
-#line 688
 	        assert("ncx_pad_getn_Ifloat invalid type" == 0);
-#line 688
 	}
-#line 688
 	return NC_EBADTYPE;
-#line 688
 }
-#line 688
 
 
 static int
-#line 690
 ncx_pad_putn_Idouble(void **xpp, size_t nelems, const double *tp, nc_type type)
-#line 690
 {
-#line 690
 	switch(type) {
-#line 690
 	case NC_CHAR:
-#line 690
 		return NC_ECHAR;
-#line 690
 	case NC_BYTE:
-#line 690
 		return ncx_pad_putn_schar_double(xpp, nelems, tp);
-#line 690
 	case NC_SHORT:
-#line 690
 		return ncx_pad_putn_short_double(xpp, nelems, tp);
-#line 690
 	case NC_INT:
-#line 690
 		return ncx_putn_int_double(xpp, nelems, tp);
-#line 690
 	case NC_FLOAT:
-#line 690
 		return ncx_putn_float_double(xpp, nelems, tp);
-#line 690
 	case NC_DOUBLE:
-#line 690
 		return ncx_putn_double_double(xpp, nelems, tp);
-#line 690
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_double(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_double(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_double(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_double(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_double(xpp, nelems, tp);
 	default:
-#line 690
                 assert("ncx_pad_putn_Idouble invalid type" == 0);
-#line 690
 	}
-#line 690
 	return NC_EBADTYPE;
-#line 690
 }
-#line 690
 
 static int
-#line 691
 ncx_pad_getn_Idouble(const void **xpp, size_t nelems, double *tp, nc_type type)
-#line 691
 {
-#line 691
 	switch(type) {
-#line 691
 	case NC_CHAR:
-#line 691
 		return NC_ECHAR;
-#line 691
 	case NC_BYTE:
-#line 691
 		return ncx_pad_getn_schar_double(xpp, nelems, tp);
-#line 691
 	case NC_SHORT:
-#line 691
 		return ncx_pad_getn_short_double(xpp, nelems, tp);
-#line 691
 	case NC_INT:
-#line 691
 		return ncx_getn_int_double(xpp, nelems, tp);
-#line 691
 	case NC_FLOAT:
-#line 691
 		return ncx_getn_float_double(xpp, nelems, tp);
-#line 691
 	case NC_DOUBLE:
-#line 691
 		return ncx_getn_double_double(xpp, nelems, tp);
-#line 691
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_double(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_double(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_double(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_double(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_double(xpp, nelems, tp);
 	default:
-#line 691
 	        assert("ncx_pad_getn_Idouble invalid type" == 0);
-#line 691
 	}
-#line 691
 	return NC_EBADTYPE;
-#line 691
 }
-#line 691
 
 
 #ifdef IGNORE
 static int
-#line 694
 ncx_pad_putn_Ilong(void **xpp, size_t nelems, const long *tp, nc_type type)
-#line 694
 {
-#line 694
 	switch(type) {
-#line 694
 	case NC_CHAR:
-#line 694
 		return NC_ECHAR;
-#line 694
 	case NC_BYTE:
-#line 694
 		return ncx_pad_putn_schar_long(xpp, nelems, tp);
-#line 694
 	case NC_SHORT:
-#line 694
 		return ncx_pad_putn_short_long(xpp, nelems, tp);
-#line 694
 	case NC_INT:
-#line 694
 		return ncx_putn_int_long(xpp, nelems, tp);
-#line 694
 	case NC_FLOAT:
-#line 694
 		return ncx_putn_float_long(xpp, nelems, tp);
-#line 694
 	case NC_DOUBLE:
-#line 694
 		return ncx_putn_double_long(xpp, nelems, tp);
-#line 694
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_long(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_long(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_long(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_long(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_long(xpp, nelems, tp);
 	default:
-#line 694
                 assert("ncx_pad_putn_Ilong invalid type" == 0);
-#line 694
 	}
-#line 694
 	return NC_EBADTYPE;
-#line 694
 }
-#line 694
 
 static int
-#line 695
 ncx_pad_getn_Ilong(const void **xpp, size_t nelems, long *tp, nc_type type)
-#line 695
 {
-#line 695
 	switch(type) {
-#line 695
 	case NC_CHAR:
-#line 695
 		return NC_ECHAR;
-#line 695
 	case NC_BYTE:
-#line 695
 		return ncx_pad_getn_schar_long(xpp, nelems, tp);
-#line 695
 	case NC_SHORT:
-#line 695
 		return ncx_pad_getn_short_long(xpp, nelems, tp);
-#line 695
 	case NC_INT:
-#line 695
 		return ncx_getn_int_long(xpp, nelems, tp);
-#line 695
 	case NC_FLOAT:
-#line 695
 		return ncx_getn_float_long(xpp, nelems, tp);
-#line 695
 	case NC_DOUBLE:
-#line 695
 		return ncx_getn_double_long(xpp, nelems, tp);
-#line 695
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_long(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_long(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_long(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_long(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_long(xpp, nelems, tp);
 	default:
-#line 695
 	        assert("ncx_pad_getn_Ilong invalid type" == 0);
-#line 695
 	}
-#line 695
 	return NC_EBADTYPE;
-#line 695
 }
-#line 695
 
 #endif
 
 static int
-#line 698
 ncx_pad_putn_Ilonglong(void **xpp, size_t nelems, const longlong *tp, nc_type type)
-#line 698
 {
-#line 698
 	switch(type) {
-#line 698
 	case NC_CHAR:
-#line 698
 		return NC_ECHAR;
-#line 698
 	case NC_BYTE:
-#line 698
 		return ncx_pad_putn_schar_longlong(xpp, nelems, tp);
-#line 698
 	case NC_SHORT:
-#line 698
 		return ncx_pad_putn_short_longlong(xpp, nelems, tp);
-#line 698
 	case NC_INT:
-#line 698
 		return ncx_putn_int_longlong(xpp, nelems, tp);
-#line 698
 	case NC_FLOAT:
-#line 698
 		return ncx_putn_float_longlong(xpp, nelems, tp);
-#line 698
 	case NC_DOUBLE:
-#line 698
 		return ncx_putn_double_longlong(xpp, nelems, tp);
-#line 698
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_longlong(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_longlong(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_longlong(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_longlong(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_longlong(xpp, nelems, tp);
 	default:
-#line 698
                 assert("ncx_pad_putn_Ilonglong invalid type" == 0);
-#line 698
 	}
-#line 698
 	return NC_EBADTYPE;
-#line 698
 }
-#line 698
 
 static int
-#line 699
 ncx_pad_getn_Ilonglong(const void **xpp, size_t nelems, longlong *tp, nc_type type)
-#line 699
 {
-#line 699
 	switch(type) {
-#line 699
 	case NC_CHAR:
-#line 699
 		return NC_ECHAR;
-#line 699
 	case NC_BYTE:
-#line 699
 		return ncx_pad_getn_schar_longlong(xpp, nelems, tp);
-#line 699
 	case NC_SHORT:
-#line 699
 		return ncx_pad_getn_short_longlong(xpp, nelems, tp);
-#line 699
 	case NC_INT:
-#line 699
 		return ncx_getn_int_longlong(xpp, nelems, tp);
-#line 699
 	case NC_FLOAT:
-#line 699
 		return ncx_getn_float_longlong(xpp, nelems, tp);
-#line 699
 	case NC_DOUBLE:
-#line 699
 		return ncx_getn_double_longlong(xpp, nelems, tp);
-#line 699
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_longlong(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_longlong(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_longlong(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_longlong(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_longlong(xpp, nelems, tp);
 	default:
-#line 699
 	        assert("ncx_pad_getn_Ilonglong invalid type" == 0);
-#line 699
 	}
-#line 699
 	return NC_EBADTYPE;
-#line 699
 }
-#line 699
+
+
+static int
+ncx_pad_putn_Iushort(void **xpp, size_t nelems, const ushort *tp, nc_type type)
+{
+	switch(type) {
+	case NC_CHAR:
+		return NC_ECHAR;
+	case NC_BYTE:
+		return ncx_pad_putn_schar_ushort(xpp, nelems, tp);
+	case NC_SHORT:
+		return ncx_pad_putn_short_ushort(xpp, nelems, tp);
+	case NC_INT:
+		return ncx_putn_int_ushort(xpp, nelems, tp);
+	case NC_FLOAT:
+		return ncx_putn_float_ushort(xpp, nelems, tp);
+	case NC_DOUBLE:
+		return ncx_putn_double_ushort(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_ushort(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_ushort(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_ushort(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_ushort(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_ushort(xpp, nelems, tp);
+	default:
+                assert("ncx_pad_putn_Iushort invalid type" == 0);
+	}
+	return NC_EBADTYPE;
+}
+
+static int
+ncx_pad_getn_Iushort(const void **xpp, size_t nelems, ushort *tp, nc_type type)
+{
+	switch(type) {
+	case NC_CHAR:
+		return NC_ECHAR;
+	case NC_BYTE:
+		return ncx_pad_getn_schar_ushort(xpp, nelems, tp);
+	case NC_SHORT:
+		return ncx_pad_getn_short_ushort(xpp, nelems, tp);
+	case NC_INT:
+		return ncx_getn_int_ushort(xpp, nelems, tp);
+	case NC_FLOAT:
+		return ncx_getn_float_ushort(xpp, nelems, tp);
+	case NC_DOUBLE:
+		return ncx_getn_double_ushort(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_ushort(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_ushort(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_ushort(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_ushort(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_ushort(xpp, nelems, tp);
+	default:
+	        assert("ncx_pad_getn_Iushort invalid type" == 0);
+	}
+	return NC_EBADTYPE;
+}
+
+
+static int
+ncx_pad_putn_Iuint(void **xpp, size_t nelems, const uint *tp, nc_type type)
+{
+	switch(type) {
+	case NC_CHAR:
+		return NC_ECHAR;
+	case NC_BYTE:
+		return ncx_pad_putn_schar_uint(xpp, nelems, tp);
+	case NC_SHORT:
+		return ncx_pad_putn_short_uint(xpp, nelems, tp);
+	case NC_INT:
+		return ncx_putn_int_uint(xpp, nelems, tp);
+	case NC_FLOAT:
+		return ncx_putn_float_uint(xpp, nelems, tp);
+	case NC_DOUBLE:
+		return ncx_putn_double_uint(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_uint(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_uint(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_uint(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_uint(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_uint(xpp, nelems, tp);
+	default:
+                assert("ncx_pad_putn_Iuint invalid type" == 0);
+	}
+	return NC_EBADTYPE;
+}
+
+static int
+ncx_pad_getn_Iuint(const void **xpp, size_t nelems, uint *tp, nc_type type)
+{
+	switch(type) {
+	case NC_CHAR:
+		return NC_ECHAR;
+	case NC_BYTE:
+		return ncx_pad_getn_schar_uint(xpp, nelems, tp);
+	case NC_SHORT:
+		return ncx_pad_getn_short_uint(xpp, nelems, tp);
+	case NC_INT:
+		return ncx_getn_int_uint(xpp, nelems, tp);
+	case NC_FLOAT:
+		return ncx_getn_float_uint(xpp, nelems, tp);
+	case NC_DOUBLE:
+		return ncx_getn_double_uint(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_uint(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_uint(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_uint(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_uint(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_uint(xpp, nelems, tp);
+	default:
+	        assert("ncx_pad_getn_Iuint invalid type" == 0);
+	}
+	return NC_EBADTYPE;
+}
+
+
+static int
+ncx_pad_putn_Iulonglong(void **xpp, size_t nelems, const ulonglong *tp, nc_type type)
+{
+	switch(type) {
+	case NC_CHAR:
+		return NC_ECHAR;
+	case NC_BYTE:
+		return ncx_pad_putn_schar_ulonglong(xpp, nelems, tp);
+	case NC_SHORT:
+		return ncx_pad_putn_short_ulonglong(xpp, nelems, tp);
+	case NC_INT:
+		return ncx_putn_int_ulonglong(xpp, nelems, tp);
+	case NC_FLOAT:
+		return ncx_putn_float_ulonglong(xpp, nelems, tp);
+	case NC_DOUBLE:
+		return ncx_putn_double_ulonglong(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_ulonglong(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_ulonglong(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_ulonglong(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_ulonglong(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_ulonglong(xpp, nelems, tp);
+	default:
+                assert("ncx_pad_putn_Iulonglong invalid type" == 0);
+	}
+	return NC_EBADTYPE;
+}
+
+static int
+ncx_pad_getn_Iulonglong(const void **xpp, size_t nelems, ulonglong *tp, nc_type type)
+{
+	switch(type) {
+	case NC_CHAR:
+		return NC_ECHAR;
+	case NC_BYTE:
+		return ncx_pad_getn_schar_ulonglong(xpp, nelems, tp);
+	case NC_SHORT:
+		return ncx_pad_getn_short_ulonglong(xpp, nelems, tp);
+	case NC_INT:
+		return ncx_getn_int_ulonglong(xpp, nelems, tp);
+	case NC_FLOAT:
+		return ncx_getn_float_ulonglong(xpp, nelems, tp);
+	case NC_DOUBLE:
+		return ncx_getn_double_ulonglong(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_ulonglong(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_ulonglong(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_ulonglong(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_ulonglong(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_ulonglong(xpp, nelems, tp);
+	default:
+	        assert("ncx_pad_getn_Iulonglong invalid type" == 0);
+	}
+	return NC_EBADTYPE;
+}
 
 
 
@@ -1336,6 +1361,12 @@ dispatchput(void **xpp, size_t nelems, const void* tp,
         return ncx_pad_putn_Iuchar(xpp,nelems, (uchar *)tp, atype);
     case NC_INT64:
           return ncx_pad_putn_Ilonglong(xpp, nelems, (longlong*)tp, atype);
+    case NC_USHORT:
+          return ncx_pad_putn_Iushort(xpp, nelems, (ushort*)tp, atype);
+    case NC_UINT:
+          return ncx_pad_putn_Iuint(xpp, nelems, (uint*)tp, atype);
+    case NC_UINT64:
+          return ncx_pad_putn_Iulonglong(xpp, nelems, (ulonglong*)tp, atype);
     case NC_NAT:
         return NC_EBADTYPE;
     default:
@@ -1374,7 +1405,7 @@ NC3_put_att(
     if(ncap == NULL)
 	return NC_ENOTVAR;
 
-    status = nc_cktype(type);
+    status = nc3_cktype(nc->mode, type);
     if(status != NC_NOERR)
 	return status;
 
@@ -1421,7 +1452,7 @@ NC3_put_att(
                  * N.B.: potentially overrides NC_ERANGE
                  * set by ncx_pad_putn_I$1
                  */
-                if(lstatus != ENOERR) return lstatus;
+                if(lstatus != NC_NOERR) return lstatus;
             }
 
             return status;
@@ -1505,6 +1536,13 @@ NC3_get_att(
           return ncx_pad_getn_Ilonglong(&xp,attrp->nelems,(longlong*)value,attrp->type);
     case NC_UBYTE: /* Synthetic */
         return ncx_pad_getn_Iuchar(&xp, attrp->nelems , (uchar *)value, attrp->type);
+    case NC_USHORT:
+          return ncx_pad_getn_Iushort(&xp,attrp->nelems,(ushort*)value,attrp->type);
+    case NC_UINT:
+          return ncx_pad_getn_Iuint(&xp,attrp->nelems,(uint*)value,attrp->type);
+    case NC_UINT64:
+          return ncx_pad_getn_Iulonglong(&xp,attrp->nelems,(ulonglong*)value,attrp->type);
+
     case NC_NAT:
         return NC_EBADTYPE;
     default:
diff --git a/libsrc/attr.m4 b/libsrc/attr.m4
index 65ad747..21f458d 100644
--- a/libsrc/attr.m4
+++ b/libsrc/attr.m4
@@ -8,7 +8,6 @@ dnl
  *	Copyright 1996, University Corporation for Atmospheric Research
  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
-/* $Id: attr.m4,v 2.39 2010/05/26 18:11:08 dmh Exp $ */
 
 #include "nc3internal.h"
 #include "ncdispatch.h"
@@ -57,6 +56,16 @@ ncx_len_NC_attrV(nc_type type, size_t nelems)
 		return ncx_len_float(nelems);
 	case NC_DOUBLE:
 		return ncx_len_double(nelems);
+	case NC_UBYTE:
+		return ncx_len_ubyte(nelems);
+	case NC_USHORT:
+		return ncx_len_ushort(nelems);
+	case NC_UINT:
+		return ncx_len_uint(nelems);
+	case NC_INT64:
+		return ncx_len_int64(nelems);
+	case NC_UINT64:
+		return ncx_len_uint64(nelems);
 	default:
 	        assert("ncx_len_NC_attr bad type" == 0);
 	}
@@ -394,7 +403,7 @@ NC_lookupattr(int ncid,
 	if(attrpp != NULL)
 		*attrpp = *tmp;
 
-	return ENOERR;
+	return NC_NOERR;
 }
 
 /* Public */
@@ -637,6 +646,16 @@ ncx_pad_putn_I$1(void **xpp, size_t nelems, const $1 *tp, nc_type type)
 		return ncx_putn_float_$1(xpp, nelems, tp);
 	case NC_DOUBLE:
 		return ncx_putn_double_$1(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_putn_uchar_$1(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_putn_ushort_$1(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_putn_uint_$1(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_putn_longlong_$1(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_putn_ulonglong_$1(xpp, nelems, tp);
 	default:
                 assert("ncx_pad_putn_I$1 invalid type" == 0);
 	}
@@ -664,6 +683,16 @@ ncx_pad_getn_I$1(const void **xpp, size_t nelems, $1 *tp, nc_type type)
 		return ncx_getn_float_$1(xpp, nelems, tp);
 	case NC_DOUBLE:
 		return ncx_getn_double_$1(xpp, nelems, tp);
+	case NC_UBYTE:
+		return ncx_pad_getn_uchar_$1(xpp, nelems, tp);
+	case NC_USHORT:
+		return ncx_getn_ushort_$1(xpp, nelems, tp);
+	case NC_UINT:
+		return ncx_getn_uint_$1(xpp, nelems, tp);
+	case NC_INT64:
+		return ncx_getn_longlong_$1(xpp, nelems, tp);
+	case NC_UINT64:
+		return ncx_getn_ulonglong_$1(xpp, nelems, tp);
 	default:
 	        assert("ncx_pad_getn_I$1 invalid type" == 0);
 	}
@@ -698,6 +727,15 @@ XNCX_PAD_GETN(long)
 XNCX_PAD_PUTN(longlong)
 XNCX_PAD_GETN(longlong)
 
+XNCX_PAD_PUTN(ushort)
+XNCX_PAD_GETN(ushort)
+
+XNCX_PAD_PUTN(uint)
+XNCX_PAD_GETN(uint)
+
+XNCX_PAD_PUTN(ulonglong)
+XNCX_PAD_GETN(ulonglong)
+
 
 /* Common dispatcher for put cases */
 static int
@@ -721,6 +759,12 @@ dispatchput(void **xpp, size_t nelems, const void* tp,
         return ncx_pad_putn_Iuchar(xpp,nelems, (uchar *)tp, atype);
     case NC_INT64:
           return ncx_pad_putn_Ilonglong(xpp, nelems, (longlong*)tp, atype);
+    case NC_USHORT:
+          return ncx_pad_putn_Iushort(xpp, nelems, (ushort*)tp, atype);
+    case NC_UINT:
+          return ncx_pad_putn_Iuint(xpp, nelems, (uint*)tp, atype);
+    case NC_UINT64:
+          return ncx_pad_putn_Iulonglong(xpp, nelems, (ulonglong*)tp, atype);
     case NC_NAT:
         return NC_EBADTYPE;
     default:
@@ -759,7 +803,7 @@ NC3_put_att(
     if(ncap == NULL)
 	return NC_ENOTVAR;
 
-    status = nc_cktype(type);
+    status = nc3_cktype(nc->mode, type);
     if(status != NC_NOERR)
 	return status;
 
@@ -806,7 +850,7 @@ NC3_put_att(
                  * N.B.: potentially overrides NC_ERANGE
                  * set by ncx_pad_putn_I$1
                  */
-                if(lstatus != ENOERR) return lstatus;
+                if(lstatus != NC_NOERR) return lstatus;
             }
 
             return status;
@@ -890,6 +934,13 @@ NC3_get_att(
           return ncx_pad_getn_Ilonglong(&xp,attrp->nelems,(longlong*)value,attrp->type);
     case NC_UBYTE: /* Synthetic */
         return ncx_pad_getn_Iuchar(&xp, attrp->nelems , (uchar *)value, attrp->type);
+    case NC_USHORT:
+          return ncx_pad_getn_Iushort(&xp,attrp->nelems,(ushort*)value,attrp->type);
+    case NC_UINT:
+          return ncx_pad_getn_Iuint(&xp,attrp->nelems,(uint*)value,attrp->type);
+    case NC_UINT64:
+          return ncx_pad_getn_Iulonglong(&xp,attrp->nelems,(ulonglong*)value,attrp->type);
+
     case NC_NAT:
         return NC_EBADTYPE;
     default:
diff --git a/libsrc/ffio.c b/libsrc/ffio.c
index 551640c..75dd03f 100644
--- a/libsrc/ffio.c
+++ b/libsrc/ffio.c
@@ -525,7 +525,7 @@ ncio_ffio_new(const char *path, int ioflags)
 /* put all the FFIO assign specific code here
  * returns a pointer to an internal static char location
  * which may change when the function is called again
- * if the returned pointer is NULL this indicates that an error occured
+ * if the returned pointer is NULL this indicates that an error occurred
  * check errno for the netCDF error value
  */
 /* prototype fortran subroutines */
@@ -565,7 +565,7 @@ ncio_ffio_assign(const char *filename) {
 #endif
 	if (istat == 0) {	/* user has already specified an assign */
 		return buffer;
-	} else if (istat > 0 || istat < -1) {	/* error occured */
+	} else if (istat > 0 || istat < -1) {	/* error occurred */
 		errno = EINVAL;
 		return (const char *) NULL;
 	} /* istat = -1 -> no assign for file */
@@ -635,7 +635,7 @@ ffio_create(const char *path, int ioflags,
 		return ENOMEM;
 
 	if ((ControlString = ncio_ffio_assign(path)) == (const char *)NULL) {
-		/* an error occured - just punt */
+		/* an error occurred - just punt */
 		status = errno;
 		goto unwind_new;
 	}
@@ -728,7 +728,7 @@ ffio_open(const char *path,
 		return ENOMEM;
 
 	if ((ControlString = ncio_ffio_assign(path)) == (const char *)NULL) {
-		/* an error occured - just punt */
+		/* an error occurred - just punt */
 		status = errno;
 		goto unwind_new;
 	}
diff --git a/libsrc/lookup3.c b/libsrc/lookup3.c
index 415dbb6..b970567 100644
--- a/libsrc/lookup3.c
+++ b/libsrc/lookup3.c
@@ -309,7 +309,7 @@ hashlittle2(
      * rest of the string.  Every machine with memory protection I've seen
      * does it on word boundaries, so is OK with this.  But VALGRIND will
      * still catch it and complain.  The masking trick does make the hash
-     * noticably faster for short strings (like English words).
+     * noticeably faster for short strings (like English words).
      */
 #ifndef VALGRIND
 
@@ -488,7 +488,7 @@ hashbig( const void *key, size_t length, uint32_t initval)
      * rest of the string.  Every machine with memory protection I've seen
      * does it on word boundaries, so is OK with this.  But VALGRIND will
      * still catch it and complain.  The masking trick does make the hash
-     * noticably faster for short strings (like English words).
+     * noticeably faster for short strings (like English words).
      */
 #ifndef VALGRIND
 
@@ -639,7 +639,7 @@ hashlittle( const void *key, size_t length, uint32_t initval)
      * rest of the string.  Every machine with memory protection I've seen
      * does it on word boundaries, so is OK with this.  But VALGRIND will
      * still catch it and complain.  The masking trick does make the hash
-     * noticably faster for short strings (like English words).
+     * noticeably faster for short strings (like English words).
      */
 #ifndef VALGRIND
 
diff --git a/libsrc/mmapio.c b/libsrc/mmapio.c
index 5f42b52..20eeacd 100644
--- a/libsrc/mmapio.c
+++ b/libsrc/mmapio.c
@@ -168,7 +168,8 @@ mmapio_new(const char* path, int ioflags, off_t initialsize, ncio** nciopp, NCMM
     mmapio->persist = fIsSet(ioflags,NC_WRITE);
 
     /* See if ok to use mmap */
-    if(sizeof(void*) < 8 && fIsSet(ioflags,NC_64BIT_OFFSET))
+    if(sizeof(void*) < 8 &&
+       (fIsSet(ioflags,NC_64BIT_OFFSET) || fIsSet(ioflags,NC_64BIT_DATA)))
 	return NC_DISKLESS; /* cannot support */
     mmapio->mapfd = -1;
 
diff --git a/libsrc/nc3dispatch.c b/libsrc/nc3dispatch.c
index 8025d3b..e66afe7 100644
--- a/libsrc/nc3dispatch.c
+++ b/libsrc/nc3dispatch.c
@@ -80,7 +80,7 @@ static int NC3_get_var_chunk_cache(int,int,size_t*,size_t*,float*);
 
 static NC_Dispatch NC3_dispatcher = {
 
-NC_DISPATCH_NC3,
+NC_FORMATX_NC3,
 
 NC3_create,
 NC3_open,
@@ -179,6 +179,12 @@ NC3_initialize(void)
     return NC_NOERR;
 }
 
+int
+NC3_finalize(void)
+{
+    return NC_NOERR;
+}
+
 static int
 NC3_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep, 
                int *ndimsp, int *dimidsp, int *nattsp, 
@@ -335,7 +341,7 @@ NC3_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, nc_type typeid2, int*
     }
     
     /* If both are atomic types, the answer is easy. */
-    if (typeid1 <= ATOMICTYPEMAX) {
+    if (typeid1 <= ATOMICTYPEMAX3) {
         if (equalp) {
             if (typeid1 == typeid2)
                 *equalp = 1;
@@ -351,7 +357,7 @@ static int
 NC3_inq_typeid(int ncid, const char *name, nc_type *typeidp)
 {
     int i;
-    for (i = 0; i <= ATOMICTYPEMAX; i++)
+    for (i = 0; i <= ATOMICTYPEMAX3; i++)
         if (!strcmp(name, NC_atomictypename(i))) {
             if (typeidp) *typeidp = i;
                 return NC_NOERR;
diff --git a/libsrc/nc3dispatch.h b/libsrc/nc3dispatch.h
new file mode 100644
index 0000000..aee43b3
--- /dev/null
+++ b/libsrc/nc3dispatch.h
@@ -0,0 +1,189 @@
+/*
+ * Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
+ * 
+ * Portions of this software were developed by the Unidata Program at the 
+ * University Corporation for Atmospheric Research.
+ * 
+ * Access and use of this software shall impose the following obligations
+ * and understandings on the user. The user is granted the right, without
+ * any fee or cost, to use, copy, modify, alter, enhance and distribute
+ * this software, and any derivative works thereof, and its supporting
+ * documentation for any purpose whatsoever, provided that this entire
+ * notice appears in all copies of the software, derivative works and
+ * supporting documentation.  Further, UCAR requests that the user credit
+ * UCAR/Unidata in any publications that result from the use of this
+ * software or in any product that includes this software. The names UCAR
+ * and/or Unidata, however, may not be used in any advertising or publicity
+ * to endorse or promote any products or commercial entity unless specific
+ * written permission is obtained from UCAR/Unidata. The user also
+ * understands that UCAR/Unidata is not obligated to provide the user with
+ * any support, consulting, training or assistance of any kind with regard
+ * to the use, operation and performance of this software nor to provide
+ * the user with any updates, revisions, new versions or "bug fixes."
+ * 
+ * THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* "$Id: nc3dispatch.h,v 2.8 2010/05/26 18:11:08 dmh Exp $" */
+
+#ifndef _NC3DISPATCH_H
+#define _NC3DISPATCH_H
+
+#include <stddef.h> /* size_t, ptrdiff_t */
+#include "netcdf.h"
+#include "ncdispatch.h"
+
+
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*
+ * The Interface
+ */
+
+/* WARNING: this signature differs from external nc_create API*/
+EXTERNL int
+NC3_create(const char *path, int cmode,
+           size_t initialsz, int basepe, size_t *chunksizehintp,
+	   int useparallel, void* mpidata,
+           struct NC_Dispatch*, NC* ncp);
+
+/* WARNING: this signature differs from external nc_open API*/
+EXTERNL int
+NC3_open(const char *path, int mode,
+         int basepe, size_t *chunksizehintp,
+         int use_parallel, void* mpidata,
+         NC_Dispatch*, NC* ncp);
+
+EXTERNL int
+NC3_new_nc(NC**);
+
+EXTERNL int
+NC3_redef(int ncid);
+
+EXTERNL int
+NC3__enddef(int ncid, size_t h_minfree, size_t v_align,
+	size_t v_minfree, size_t r_align);
+
+EXTERNL int
+NC3_sync(int ncid);
+
+EXTERNL int
+NC3_abort(int ncid);
+
+EXTERNL int
+NC3_close(int ncid);
+
+EXTERNL int
+NC3_set_fill(int ncid, int fillmode, int *old_modep);
+
+EXTERNL int
+NC3_set_base_pe(int ncid, int pe);
+
+EXTERNL int
+NC3_inq_base_pe(int ncid, int *pe);
+
+EXTERNL int
+NC3_inq_format(int ncid, int *formatp);
+
+EXTERNL int
+NC3_inq_format_extended(int ncid, int *formatp, int *modep);
+
+EXTERNL int
+NC3_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp);
+
+EXTERNL int
+NC3_inq_type(int, nc_type, char *, size_t *);
+
+/* Begin _dim */
+
+EXTERNL int
+NC3_def_dim(int ncid, const char *name, size_t len, int *idp);
+
+EXTERNL int
+NC3_inq_dimid(int ncid, const char *name, int *idp);
+
+EXTERNL int
+NC3_inq_dim(int ncid, int dimid, char *name, size_t *lenp);
+
+EXTERNL int
+NC3_inq_unlimdim(int ncid, int *unlimdimidp);
+
+EXTERNL int
+NC3_rename_dim(int ncid, int dimid, const char *name);
+
+/* End _dim */
+/* Begin _att */
+
+EXTERNL int
+NC3_inq_att(int ncid, int varid, const char *name,
+	 nc_type *xtypep, size_t *lenp);
+
+EXTERNL int 
+NC3_inq_attid(int ncid, int varid, const char *name, int *idp);
+
+EXTERNL int
+NC3_inq_attname(int ncid, int varid, int attnum, char *name);
+
+EXTERNL int
+NC3_rename_att(int ncid, int varid, const char *name, const char *newname);
+
+EXTERNL int
+NC3_del_att(int ncid, int varid, const char*);
+
+/* End _att */
+/* Begin {put,get}_att */
+
+EXTERNL int
+NC3_get_att(int ncid, int varid, const char *name, void *value, nc_type);
+
+EXTERNL int
+NC3_put_att(int ncid, int varid, const char *name, nc_type datatype,
+	   size_t len, const void *value, nc_type);
+
+/* End {put,get}_att */
+/* Begin _var */
+
+EXTERNL int
+NC3_def_var(int ncid, const char *name,
+	 nc_type xtype, int ndims, const int *dimidsp, int *varidp);
+
+EXTERNL int
+NC3_inq_var(int ncid, int varid, char *name,
+	 nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp);
+
+EXTERNL int
+NC3_inq_varid(int ncid, const char *name, int *varidp);
+
+EXTERNL int
+NC3_rename_var(int ncid, int varid, const char *name);
+
+
+EXTERNL int
+NC3_put_vara(int ncid, int varid,
+   	     const size_t *start, const size_t *count,
+             const void *value, nc_type);
+
+EXTERNL int
+NC3_get_vara(int ncid, int varid,
+	     const size_t *start, const size_t *count,
+             void *value, nc_type);
+
+/* End _var */
+
+extern int NC3_initialize();
+extern int NC3_finalize();
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /*_NC3DISPATCH_H*/
diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c
index d563f56..343d574 100644
--- a/libsrc/nc3internal.c
+++ b/libsrc/nc3internal.c
@@ -1,5 +1,5 @@
 /*
- *	Copyright 1996, University Corporation for Atmospheric Research
+ *	Copyright 1996, Unuiversity Corporation for Atmospheric Research
  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
 
@@ -25,6 +25,13 @@
 #define VER_64BIT_OFFSET 2
 #define VER_HDF5 3
 
+#define NC_NUMRECS_OFFSET 4
+
+/* For netcdf classic */
+#define NC_NUMRECS_EXTENT3 4
+/* For cdf5 */
+#define NC_NUMRECS_EXTENT5 8
+
 static void
 free_NC3INFO(NC3_INFO *nc3)
 {
@@ -46,9 +53,8 @@ new_NC3INFO(const size_t *chunkp)
 	NC3_INFO *ncp;
 	ncp = (NC3_INFO*)calloc(1,sizeof(NC3_INFO));
 	if(ncp == NULL) return ncp;
-	ncp->xsz = MIN_NC_XSZ;
-	assert(ncp->xsz == ncx_len_NC(ncp,0));
         ncp->chunk = chunkp != NULL ? *chunkp : NC_SIZEHINT_DEFAULT;
+	/* Note that ncp->xsz is not set yet because we do not know the file format */
 	return ncp;
 }
 
@@ -80,23 +86,20 @@ err:
 
 /*
  *  Verify that this is a user nc_type
- * Formerly
-NCcktype()
+ * Formerly NCcktype()
  * Sense of the return is changed.
  */
 int
-nc_cktype(nc_type type)
+nc3_cktype(int mode, nc_type type)
 {
-	switch((int)type){
-	case NC_BYTE:
-	case NC_CHAR:
-	case NC_SHORT:
-	case NC_INT:
-	case NC_FLOAT:
-	case NC_DOUBLE:
-		return(NC_NOERR);
-	}
-	return(NC_EBADTYPE);
+    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 */
+        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;
+    }
+    return(NC_EBADTYPE);
 }
 
 
@@ -119,6 +122,16 @@ ncx_howmany(nc_type type, size_t xbufsize)
 		return xbufsize/X_SIZEOF_FLOAT;
 	case NC_DOUBLE:
 		return xbufsize/X_SIZEOF_DOUBLE;
+	case NC_UBYTE:
+ 		return xbufsize;
+	case NC_USHORT:
+		return xbufsize/X_SIZEOF_USHORT;
+	case NC_UINT:
+		return xbufsize/X_SIZEOF_UINT;
+	case NC_INT64:
+		return xbufsize/X_SIZEOF_LONGLONG;
+	case NC_UINT64:
+		return xbufsize/X_SIZEOF_ULONGLONG;
 	default:
 	        assert("ncx_howmany: Bad type" == 0);
 		return(0);
@@ -149,7 +162,7 @@ NC_begins(NC3_INFO* ncp,
 	if(r_align == NC_ALIGN_CHUNK)
 		r_align = ncp->chunk;
 
-	if (fIsSet(ncp->flags, NC_64BIT_OFFSET)) {
+	if (fIsSet(ncp->flags, NC_64BIT_OFFSET) || fIsSet(ncp->flags, NC_64BIT_DATA)) {
 	  sizeof_off_t = 8;
 	} else {
 	  sizeof_off_t = 4;
@@ -203,18 +216,22 @@ fprintf(stderr, "    VAR %d %s: %ld\n", ii, (*vpp)->name->cp, (long)index);
 		(*vpp)->begin = index;
 
 		if (ncp->old != NULL) {
-		    /* move to the next fixed variable */
-		    for (; j<ncp->old->vars.nelems; j++)
-		        if (!IS_RECVAR(ncp->old->vars.value[j]))
-		            break;
-		    if (j < ncp->old->vars.nelems) {
-		        if ((*vpp)->begin < ncp->old->vars.value[j]->begin)
-		            /* the first ncp->vars.nelems fixed variables
-                               should be the same. If the new begin is smaller,
-                               reuse the old begin */
-                            (*vpp)->begin = ncp->old->vars.value[j]->begin;
-                        j++;
-		    }
+          /* move to the next fixed variable */
+          for (; j<ncp->old->vars.nelems; j++) {
+            if (!IS_RECVAR(ncp->old->vars.value[j]))
+              break;
+          }
+
+          if (j < ncp->old->vars.nelems) {
+            if ((*vpp)->begin < ncp->old->vars.value[j]->begin) {
+              /* the first ncp->vars.nelems fixed variables
+                 should be the same. If the new begin is smaller,
+                 reuse the old begin */
+              (*vpp)->begin = ncp->old->vars.value[j]->begin;
+              index = (*vpp)->begin;
+            }
+            j++;
+          }
 		}
 
 		index += (*vpp)->len;
@@ -319,25 +336,32 @@ read_numrecs(NC3_INFO *ncp)
 {
 	int status = NC_NOERR;
 	const void *xp = NULL;
-	size_t nrecs = NC_get_numrecs(ncp);
+	size_t new_nrecs = 0;
+	size_t  old_nrecs = NC_get_numrecs(ncp);
+	size_t nc_numrecs_extent = NC_NUMRECS_EXTENT3; /* CDF-1 and CDF-2 */
 
 	assert(!NC_indef(ncp));
 
-#define NC_NUMRECS_OFFSET 4
-#define NC_NUMRECS_EXTENT 4
+	if (fIsSet(ncp->flags, NC_64BIT_DATA))
+		nc_numrecs_extent = NC_NUMRECS_EXTENT5; /* CDF-5 */
+
 	status = ncio_get(ncp->nciop,
-		 NC_NUMRECS_OFFSET, NC_NUMRECS_EXTENT, 0, (void **)&xp);
-					/* cast away const */
+		 NC_NUMRECS_OFFSET, nc_numrecs_extent, 0, (void **)&xp);/* cast away const */
 	if(status != NC_NOERR)
 		return status;
 
-	status = ncx_get_size_t(&xp, &nrecs);
+	if (fIsSet(ncp->flags, NC_64BIT_DATA)) {
+	    long long tmp=0;
+	    status = ncx_get_int64(&xp, &tmp);
+	    new_nrecs = tmp;
+        } else
+	    status = ncx_get_size_t(&xp, &new_nrecs);
 
 	(void) ncio_rel(ncp->nciop, NC_NUMRECS_OFFSET, 0);
 
-	if(status == NC_NOERR)
+	if(status == NC_NOERR && old_nrecs != new_nrecs)
 	{
-		NC_set_numrecs(ncp, nrecs);
+		NC_set_numrecs(ncp, new_nrecs);
 		fClr(ncp->flags, NC_NDIRTY);
 	}
 
@@ -354,18 +378,25 @@ write_numrecs(NC3_INFO *ncp)
 {
 	int status = NC_NOERR;
 	void *xp = NULL;
+	size_t nc_numrecs_extent = NC_NUMRECS_EXTENT3; /* CDF-1 and CDF-2 */
 
 	assert(!NC_readonly(ncp));
 	assert(!NC_indef(ncp));
 
+	if (fIsSet(ncp->flags, NC_64BIT_DATA))
+	    nc_numrecs_extent = NC_NUMRECS_EXTENT5; /* CDF-5 */
+
 	status = ncio_get(ncp->nciop,
-		 NC_NUMRECS_OFFSET, NC_NUMRECS_EXTENT, RGN_WRITE, &xp);
+		 NC_NUMRECS_OFFSET, nc_numrecs_extent, RGN_WRITE, &xp);
 	if(status != NC_NOERR)
 		return status;
 
 	{
 		const size_t nrecs = NC_get_numrecs(ncp);
-		status = ncx_put_size_t(&xp, &nrecs);
+		if (fIsSet(ncp->flags, NC_64BIT_DATA))
+		    status = ncx_put_int64(&xp, nrecs);
+		else
+ 		    status = ncx_put_size_t(&xp, &nrecs);
 	}
 
 	(void) ncio_rel(ncp->nciop, NC_NUMRECS_OFFSET, RGN_MODIFIED);
@@ -665,7 +696,11 @@ NC_check_vlens(NC3_INFO *ncp)
     if(ncp->vars.nelems == 0)
 	return NC_NOERR;
 
-    if ((ncp->flags & NC_64BIT_OFFSET) && sizeof(off_t) > 4) {
+    if (fIsSet(ncp->flags,NC_64BIT_DATA)) {
+	/* CDF5 format allows many large vars */
+        return NC_NOERR;
+    } 
+    if (fIsSet(ncp->flags,NC_64BIT_OFFSET) && sizeof(off_t) > 4) {
 	/* CDF2 format and LFS */
 	vlen_max = X_UINT_MAX - 3; /* "- 3" handles rounded-up size */
     } else {
@@ -808,15 +843,16 @@ NC_endef(NC3_INFO *ncp,
 				return status;
 
 		}
-		else if(ncp->old != NULL && (ncp->vars.nelems > ncp->old->vars.nelems))
-		{
-			status = fill_added(ncp, ncp->old);
-			if(status != NC_NOERR)
-				return status;
-			status = fill_added_recs(ncp, ncp->old);
-			if(status != NC_NOERR)
-				return status;
-		}
+		else if(ncp->old == NULL ? 0
+                                         : (ncp->vars.nelems > ncp->old->vars.nelems))
+          {
+            status = fill_added(ncp, ncp->old);
+            if(status != NC_NOERR)
+              return status;
+            status = fill_added_recs(ncp, ncp->old);
+            if(status != NC_NOERR)
+              return status;
+          }
 	}
 
 	if(ncp->old != NULL)
@@ -878,8 +914,8 @@ NC_calcsize(const NC3_INFO *ncp, off_t *calcsizep)
 	    if(last_fix->len == X_UINT_MAX) { /* huge last fixed var */
 		int i;
 		varsize = 1;
-		    for(i = 0; i < last_fix->ndims; i++ ) {
-              varsize *= (last_fix->shape ? last_fix->shape[i] : 1);
+  	        for(i = 0; i < last_fix->ndims; i++ ) {
+                varsize *= (last_fix->shape ? last_fix->shape[i] : 1);
 		    }
 	    }
 	    *calcsizep = last_fix->begin + varsize;
@@ -954,12 +990,23 @@ NC3_create(const char *path, int ioflags,
 	assert(nc3->flags == 0);
 
 	/* Apply default create format. */
-	if (nc_get_default_format() == NC_FORMAT_64BIT)
+	if (nc_get_default_format() == NC_FORMAT_64BIT_OFFSET)
 	  ioflags |= NC_64BIT_OFFSET;
+	else if (nc_get_default_format() == NC_FORMAT_CDF5)
+	  ioflags |= NC_64BIT_DATA;
+
+	/* Now we can set min size */
+	if (fIsSet(ioflags, NC_64BIT_DATA))
+	    nc3->xsz = MIN_NC5_XSZ; /* CDF-5 has minimum 16 extra bytes */
+	else
+	    nc3->xsz = MIN_NC3_XSZ;
 
 	if (fIsSet(ioflags, NC_64BIT_OFFSET)) {
-	  fSet(nc3->flags, NC_64BIT_OFFSET);
-	  sizeof_off_t = 8;
+	    fSet(nc3->flags, NC_64BIT_OFFSET);
+	    sizeof_off_t = 8;
+	} else if (fIsSet(ioflags, NC_64BIT_DATA)) {
+	    fSet(nc3->flags, NC_64BIT_DATA);
+	    sizeof_off_t = 8;
 	} else {
 	  sizeof_off_t = 4;
 	}
@@ -1021,7 +1068,7 @@ unwind_alloc:
 /* This function sets a default create flag that will be logically
    or'd to whatever flags are passed into nc_create for all future
    calls to nc_create.
-   Valid default create flags are NC_64BIT_OFFSET, NC_CLOBBER,
+   Valid default create flags are NC_64BIT_OFFSET, NC_CDF5, NC_CLOBBER,
    NC_LOCK, NC_SHARE. */
 int
 nc_set_default_format(int format, int *old_formatp)
@@ -1032,11 +1079,12 @@ nc_set_default_format(int format, int *old_formatp)
 
     /* Make sure only valid format is set. */
 #ifdef USE_NETCDF4
-    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT &&
+    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET &&
 	format != NC_FORMAT_NETCDF4 && format != NC_FORMAT_NETCDF4_CLASSIC)
       return NC_EINVAL;
 #else
-    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT)
+    if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET &&
+        format != NC_FORMAT_CDF5)
       return NC_EINVAL;
 #endif
     default_create_format = format;
@@ -1064,7 +1112,7 @@ NC3_open(const char * path, int ioflags,
 	if (status = NC_init_pe(nc3, basepe)) {
 		return status;
 	}
-#else 
+#else
 	/*
 	 * !_CRAYMPP, only pe 0 is valid
 	 */
@@ -1218,18 +1266,18 @@ NC3_close(int ncid)
 	 * what it should be (due to previous use of NOFILL mode),
 	 * pad it to correct size, as reported by NC_calcsize().
 	 */
-	if (status == ENOERR) {
+	if (status == NC_NOERR) {
 	    off_t filesize; 	/* current size of open file */
 	    off_t calcsize;	/* calculated file size, from header */
 	    status = ncio_filesize(nc3->nciop, &filesize);
-	    if(status != ENOERR)
+	    if(status != NC_NOERR)
 		return status;
 	    status = NC_calcsize(nc3, &calcsize);
 	    if(status != NC_NOERR)
 		return status;
 	    if(filesize < calcsize && !NC_readonly(nc3)) {
 		status = ncio_pad_length(nc3->nciop, calcsize);
-		if(status != ENOERR)
+		if(status != NC_NOERR)
 		    return status;
 	    }
 	}
@@ -1474,7 +1522,7 @@ NC3_set_base_pe(int ncid, int pe)
 	/* update serving & lock values for a "smooth" transition */
 	/* note that the "real" server will being doing this as well */
 	/* as all the rest in the group */
-	/* must have syncronization before & after this step */
+	/* must have synchronization before & after this step */
 	shmem_short_get(
 		(shmem_t *) nc3->lock + LOCKNUMREC_SERVING,
 		(shmem_t *) nc3->lock + LOCKNUMREC_SERVING,
@@ -1528,10 +1576,13 @@ NC3_inq_format(int ncid, int *formatp)
 		return status;
 	nc3 = NC3_DATA(nc);
 
-	/* only need to check for netCDF-3 variants, since this is never called for netCDF-4
-	   files */
-	*formatp = fIsSet(nc3->flags, NC_64BIT_OFFSET) ? NC_FORMAT_64BIT
-	    : NC_FORMAT_CLASSIC;
+	/* only need to check for netCDF-3 variants, since this is never called for netCDF-4 files */
+	if (fIsSet(nc3->flags, NC_64BIT_DATA))
+	    *formatp = NC_FORMAT_CDF5;
+	else if (fIsSet(nc3->flags, NC_64BIT_OFFSET))
+	    *formatp = NC_FORMAT_64BIT_OFFSET;
+	else
+	    *formatp = NC_FORMAT_CLASSIC; 
 	return NC_NOERR;
 }
 
@@ -1544,7 +1595,7 @@ NC3_inq_format_extended(int ncid, int *formatp, int *modep)
 	status = NC_check_id(ncid, &nc);
 	if(status != NC_NOERR)
 		return status;
-        if(formatp) *formatp = NC_FORMAT_NC3;
+        if(formatp) *formatp = NC_FORMATX_NC3;
 	if(modep) *modep = nc->mode;
 	return NC_NOERR;
 }
@@ -1564,21 +1615,31 @@ NC3_inq_format_extended(int ncid, int *formatp, int *modep)
 int
 NC3_inq_type(int ncid, nc_type typeid, char *name, size_t *size)
 {
+#if 0
    int atomic_size[NUM_ATOMIC_TYPES] = {NC_BYTE_LEN, NC_CHAR_LEN, NC_SHORT_LEN,
 					NC_INT_LEN, NC_FLOAT_LEN, NC_DOUBLE_LEN};
    char atomic_name[NUM_ATOMIC_TYPES][NC_MAX_NAME + 1] = {"byte", "char", "short",
 							  "int", "float", "double"};
+#endif
 
-   /* Only netCDF classic model needs to be handled. */
-   if (typeid < NC_BYTE || typeid > NC_DOUBLE)
+   NC *ncp;
+   int stat = NC_check_id(ncid, &ncp);
+   if (stat != NC_NOERR)
+	return stat;
+
+   /* Only netCDF classic model and CDF-5 need to be handled. */
+   if((ncp->mode & NC_CDF5) != 0) {
+	if (typeid < NC_BYTE || typeid > NC_STRING)
+            return NC_EBADTYPE;
+   } else if (typeid < NC_BYTE || typeid > NC_DOUBLE)
       return NC_EBADTYPE;
 
    /* Give the user the values they want. Subtract one because types
     * are numbered starting at 1, not 0. */
    if (name)
-      strcpy(name, atomic_name[typeid - 1]);
+      strcpy(name, NC_atomictypename(typeid));
    if (size)
-      *size = atomic_size[typeid - 1];
+      *size = NC_atomictypelen(typeid);
 
    return NC_NOERR;
 }
@@ -1605,7 +1666,7 @@ NC3_set_content(int ncid, size_t size, void* memory)
     if(status != NC_NOERR) goto done;
 #else
     status = NC_EDISKLESS;
-#endif    				
+#endif
 
 done:
     return status;
diff --git a/libsrc/ncx.c b/libsrc/ncx.c
index 31f53f9..9272bfc 100644
--- a/libsrc/ncx.c
+++ b/libsrc/ncx.c
@@ -1,6 +1,4 @@
-#line 11 "ncx.m4"
 /* Do not edit this file. It is produced from the corresponding .m4 source */
-#line 13
 /*
  *	Copyright 1996, University Corporation for Atmospheric Research
  *	See netcdf/COPYRIGHT file for copying and redistribution conditions.
@@ -23,12 +21,14 @@
  *	they handle IEEE subnormals properly, and their "n" versions
  *	operate speedily on arrays.
  */
-/* $Id: ncx.m4,v 2.58 2010/05/26 18:11:08 dmh Exp $ */
+/* $Id: ncx.m4 2795 2014-10-27 23:12:51Z wkliao $ */
 
 /*
  * An external data representation interface.
  */
 
+#pragma GCC diagnostic ignored "-Wdeprecated"
+
 #include "ncx.h"
 #include "nc3dispatch.h"
 #include <string.h>
@@ -46,12 +46,21 @@
 #ifndef LONG_LONG_MAX
 #define LONG_LONG_MAX LLONG_MAX
 #endif
+#ifndef LONGLONG_MAX
+#define LONGLONG_MAX LONG_LONG_MAX
+#endif
 #ifndef LONG_LONG_MIN
 #define LONG_LONG_MIN LLONG_MIN
 #endif
+#ifndef LONGLONG_MIN
+#define LONGLONG_MIN LONG_LONG_MIN
+#endif
 #ifndef ULONG_LONG_MAX
 #define ULONG_LONG_MAX ULLONG_MAX
 #endif
+#ifndef ULONGLONG_MAX
+#define ULONGLONG_MAX ULONG_LONG_MAX
+#endif
 #include <float.h>
 #ifndef FLT_MAX /* This POSIX macro missing on some systems */
 # ifndef NO_IEEE_FLOAT
@@ -72,6 +81,16 @@
 #define Min(a,b) ((a) < (b) ? (a) : (b))
 #define Max(a,b) ((a) > (b) ? (a) : (b))
 
+#ifndef SIZEOF_USHORT
+#define SIZEOF_USHORT SIZEOF_UNSIGNED_SHORT_INT
+#endif
+#ifndef SIZEOF_UINT
+#define SIZEOF_UINT SIZEOF_UNSIGNED_INT
+#endif
+#ifndef SIZEOF_ULONG_LONG
+#define SIZEOF_ULONG_LONG SIZEOF_UNSIGNED_LONG_LONG
+#endif
+
 /*
  * If the machine's float domain is "smaller" than the external one
  * use the machine domain
@@ -149,7 +168,7 @@ swapn2b(void *dst, const void *src, size_t nn)
 		*op++ = *(ip++ -1);
 		nn -= 4;
 	}
-	while(nn-- != 0)
+	while(nn-- > 0)
 	{
 		*op++ = *(++ip);
 		*op++ = *(ip++ -1);
@@ -215,7 +234,7 @@ swapn4b(void *dst, const void *src, size_t nn)
 		ip += 16;
 		nn -= 4;
 	}
-	while(nn-- != 0)
+	while(nn-- > 0)
 	{
 		op[0] = ip[3];
 		op[1] = ip[2];
@@ -333,16 +352,31 @@ swapn8b(void *dst, const void *src, size_t nn)
 #endif /* LITTLE_ENDIAN */
 
 
+
+
+
+
+
+
+
+
+
+
 /*
  * Primitive numeric conversion functions.
  */
 
+
+
+
+
 /* x_schar */
+/* x_uchar */
 
-/* We don't implement any x_schar primitives. */
+/* We don't implement any x_schar and x_uchar primitives. */
 
 
-/* x_short */
+/* x_short -------------------------------------------------------------------*/
 
 #if SHORT_MAX == X_SHORT_MAX
 typedef short ix_short;
@@ -387,30 +421,20 @@ put_ix_short(void *xp, const ix_short *ip)
 	*cp = (*ip) & 0xff;
 }
 
-
-int
+static int
 ncx_get_short_schar(const void *xp, schar *ip)
 {
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
+	*ip = (schar) xx;
+#if IX_SHORT_MAX > SCHAR_MAX
+	if (xx > SCHAR_MAX || xx < SCHAR_MIN) return NC_ERANGE;
+#endif
 
-int
-ncx_get_short_uchar(const void *xp, uchar *ip)
-{
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_short_short(const void *xp, short *ip)
 {
 #if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
@@ -419,16 +443,16 @@ ncx_get_short_short(const void *xp, short *ip)
 #else
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-#   if IX_SHORT_MAX > SHORT_MAX
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+	*ip = (short) xx;
+#if IX_SHORT_MAX > SHORT_MAX
+	if (xx > SHORT_MAX || xx < SHORT_MIN) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
+static int
 ncx_get_short_int(const void *xp, int *ip)
 {
 #if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
@@ -437,89 +461,107 @@ ncx_get_short_int(const void *xp, int *ip)
 #else
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-#   if IX_SHORT_MAX > INT_MAX
-	if(xx > INT_MAX || xx < INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+	*ip = (int) xx;
+#if IX_SHORT_MAX > INT_MAX
+	if (xx > INT_MAX || xx < INT_MIN) return NC_ERANGE;
 #endif
+
+#endif
+	return ENOERR;
 }
 
-int
-ncx_get_short_uint(const void *xp, unsigned int *ip)
+static int
+ncx_get_short_longlong(const void *xp, longlong *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
+#if SIZEOF_IX_SHORT == SIZEOF_LONGLONG && IX_SHORT_MAX == LONGLONG_MAX
 	get_ix_short(xp, (ix_short *)ip);
 	return ENOERR;
 #else
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-#   if IX_SHORT_MAX > INT_MAX
-	if(xx > UINT_MAX || xx < 0)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+	*ip = (longlong) xx;
+#if IX_SHORT_MAX > LONGLONG_MAX
+	if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) return NC_ERANGE;
 #endif
+
+#endif
+	return ENOERR;
 }
 
-int
-ncx_get_short_longlong(const void *xp, long long *ip)
+static int
+ncx_get_short_ushort(const void *xp, ushort *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_LONG_LONG && IX_SHORT_MAX == LONG_LONG_MAX
-	get_ix_short(xp, (ix_short *)ip);
-	return ENOERR;
-#else
-	/* assert(LONG_LONG_MAX >= X_SHORT_MAX); */
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-	return ENOERR;
+	*ip = (ushort) xx;
+#if IX_SHORT_MAX > USHORT_MAX
+	if (xx > USHORT_MAX) return NC_ERANGE;
 #endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
 }
 
-int
-ncx_get_short_ulonglong(const void *xp, unsigned long long *ip)
+static int
+ncx_get_short_uchar(const void *xp, uchar *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_LONG && IX_SHORT_MAX == LONG_MAX
-	get_ix_short(xp, (ix_short *)ip);
+	ix_short xx;
+	get_ix_short(xp, &xx);
+	*ip = (uchar) xx;
+#if IX_SHORT_MAX > UCHAR_MAX
+	if (xx > UCHAR_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
 	return ENOERR;
-#else
-	/* assert(LONG_LONG_MAX >= X_SHORT_MAX); */
+}
+
+static int
+ncx_get_short_uint(const void *xp, uint *ip)
+{
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-	if(xx < 0)
-		return NC_ERANGE;
+	*ip = (uint) xx;
+#if IX_SHORT_MAX > UINT_MAX
+	if (xx > UINT_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
 	return ENOERR;
+}
+
+static int
+ncx_get_short_ulonglong(const void *xp, ulonglong *ip)
+{
+	ix_short xx;
+	get_ix_short(xp, &xx);
+	*ip = (ulonglong) xx;
+#if IX_SHORT_MAX > ULONGLONG_MAX
+	if (xx > ULONGLONG_MAX) return NC_ERANGE;
 #endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
 }
 
-int
+static int
 ncx_get_short_float(const void *xp, float *ip)
 {
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
-#if 0	/* TODO: determine when necessary */
-	if(xx > FLT_MAX || xx < (-FLT_MAX))
-		return NC_ERANGE;
-#endif
+	*ip = (float) xx;
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_short_double(const void *xp, double *ip)
 {
-	/* assert(DBL_MAX >= X_SHORT_MAX); */
 	ix_short xx;
 	get_ix_short(xp, &xx);
-	*ip = xx;
+	*ip = (double) xx;
+
 	return ENOERR;
 }
 
-int
+
+static int
 ncx_put_short_schar(void *xp, const schar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -531,7 +573,7 @@ ncx_put_short_schar(void *xp, const schar *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_short_uchar(void *xp, const uchar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -540,273 +582,620 @@ ncx_put_short_uchar(void *xp, const uchar *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_short_short(void *xp, const short *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_SHORT && X_SHORT_MAX == SHORT_MAX
+#if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
 	put_ix_short(xp, (const ix_short *)ip);
 	return ENOERR;
 #else
 	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < SHORT_MAX
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
+#if IX_SHORT_MAX < SHORT_MAX
+	if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
+static int
 ncx_put_short_int(void *xp, const int *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_INT && X_SHORT_MAX == INT_MAX
+#if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
 	put_ix_short(xp, (const ix_short *)ip);
 	return ENOERR;
 #else
 	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < INT_MAX
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
+#if IX_SHORT_MAX < INT_MAX
+	if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
-ncx_put_short_uint(void *xp, const unsigned int *ip)
+static int
+ncx_put_short_longlong(void *xp, const longlong *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_INT && X_SHORT_MAX == INT_MAX
+#if SIZEOF_IX_SHORT == SIZEOF_LONGLONG && IX_SHORT_MAX == LONGLONG_MAX
 	put_ix_short(xp, (const ix_short *)ip);
 	return ENOERR;
 #else
 	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < INT_MAX
-	if(*ip > X_SHORT_MAX)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
+#if IX_SHORT_MAX < LONGLONG_MAX
+	if (*ip > IX_SHORT_MAX || *ip < X_SHORT_MIN) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
-ncx_put_short_longlong(void *xp, const long long *ip)
+static int
+ncx_put_short_ushort(void *xp, const ushort *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_LONG_LONG && X_SHORT_MAX == LONG_LONG_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
-#else
 	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < LONG_LONG_MAX
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
+#if IX_SHORT_MAX < USHORT_MAX
+	if (*ip > IX_SHORT_MAX) return NC_ERANGE;
 #endif
+
+	return ENOERR;
 }
 
-int
-ncx_put_short_ulonglong(void *xp, const unsigned long long *ip)
+static int
+ncx_put_short_uint(void *xp, const uint *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_LONG_LONG && X_SHORT_MAX == LONG_LONG_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
-#else
 	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < LONG_LONG_MAX
-	if(*ip > X_SHORT_MAX)
-		return NC_ERANGE;
-# endif
+#if IX_SHORT_MAX < UINT_MAX
+	if (*ip > IX_SHORT_MAX) return NC_ERANGE;
+#endif
+
 	return ENOERR;
+}
+
+static int
+ncx_put_short_ulonglong(void *xp, const ulonglong *ip)
+{
+	ix_short xx = (ix_short)*ip;
+	put_ix_short(xp, &xx);
+#if IX_SHORT_MAX < ULONGLONG_MAX
+	if (*ip > IX_SHORT_MAX) return NC_ERANGE;
 #endif
+
+	return ENOERR;
 }
 
-int
+static int
 ncx_put_short_float(void *xp, const float *ip)
 {
-	ix_short xx = *ip;
+	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
+	if(*ip > (double)X_SHORT_MAX || *ip < (double)X_SHORT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_short_double(void *xp, const double *ip)
 {
-	ix_short xx = *ip;
+	ix_short xx = (ix_short)*ip;
 	put_ix_short(xp, &xx);
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
+	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-/* x_int */
 
-#if SHORT_MAX == X_INT_MAX
-typedef short ix_int;
-#define SIZEOF_IX_INT SIZEOF_SHORT
-#define IX_INT_MAX SHORT_MAX
-#elif INT_MAX  >= X_INT_MAX
-typedef int ix_int;
-#define SIZEOF_IX_INT SIZEOF_INT
-#define IX_INT_MAX INT_MAX
-#elif LONG_MAX  >= X_INT_MAX
-typedef long ix_int;
-#define SIZEOF_IX_INT SIZEOF_LONG
-#define IX_INT_MAX LONG_MAX
+/* x_ushort ------------------------------------------------------------------*/
+
+#if USHORT_MAX == X_USHORT_MAX
+typedef unsigned short ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_USHORT
+#define IX_USHORT_MAX USHORT_MAX
+#elif UINT_MAX >= X_USHORT_MAX
+typedef unsigned int ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_UINT
+#define IX_USHORT_MAX UINT_MAX
+#elif ULONG_MAX >= X_USHORT_MAX
+typedef unsigned long ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_ULONG
+#define IX_USHORT_MAX ULONG_MAX
+#elif ULLONG_MAX >= X_USHORT_MAX
+typedef unsigned long long ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_ULONG_LONG
+#define IX_USHORT_MAX ULLONG_MAX
 #else
-#error "ix_int implementation"
+#error "ix_ushort implementation"
 #endif
 
-
 static void
-get_ix_int(const void *xp, ix_int *ip)
+get_ix_ushort(const void *xp, ix_ushort *ip)
 {
 	const uchar *cp = (const uchar *) xp;
-
-	*ip = *cp++ << 24;
-#if SIZEOF_IX_INT > X_SIZEOF_INT
-	if(*ip & 0x80000000)
+	*ip = *cp++ << 8;
+#if SIZEOF_IX_SHORT > X_SIZEOF_SHORT
+	if(*ip & 0x8000)
 	{
 		/* extern is negative */
-		*ip |= (~(0xffffffff)); /* N.B. Assumes "twos complement" */
+		*ip |= (~(0xffff)); /* N.B. Assumes "twos complement" */
 	}
 #endif
-	*ip |= (*cp++ << 16);
-	*ip |= (*cp++ << 8);
-	*ip |= *cp;
+	*ip |= *cp; 
 }
 
 static void
-put_ix_int(void *xp, const ix_int *ip)
+put_ix_ushort(void *xp, const ix_ushort *ip)
 {
 	uchar *cp = (uchar *) xp;
+	*cp++ = (*ip) >> 8;
+	*cp = (*ip) & 0xff;
+}
 
-	*cp++ = (*ip) >> 24;
-	*cp++ = ((*ip) & 0x00ff0000) >> 16;
-	*cp++ = ((*ip) & 0x0000ff00) >>  8;
-	*cp   = ((*ip) & 0x000000ff);
+static int
+ncx_get_ushort_schar(const void *xp, schar *ip)
+{
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (schar) xx;
+#if IX_USHORT_MAX > SCHAR_MAX
+	if (xx > SCHAR_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
 }
 
+static int
+ncx_get_ushort_short(const void *xp, short *ip)
+{
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (short) xx;
+#if IX_USHORT_MAX > SHORT_MAX
+	if (xx > SHORT_MAX) return NC_ERANGE;
+#endif
 
-int
-ncx_get_int_schar(const void *xp, schar *ip)
+	return ENOERR;
+}
+
+static int
+ncx_get_ushort_int(const void *xp, int *ip)
 {
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (int) xx;
+#if IX_USHORT_MAX > INT_MAX
+	if (xx > INT_MAX) return NC_ERANGE;
+#endif
+
 	return ENOERR;
 }
 
-int
-ncx_get_int_uchar(const void *xp, uchar *ip)
+static int
+ncx_get_ushort_longlong(const void *xp, longlong *ip)
 {
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (longlong) xx;
+#if IX_USHORT_MAX > LONGLONG_MAX
+	if (xx > LONGLONG_MAX) return NC_ERANGE;
+#endif
+
 	return ENOERR;
 }
 
-int
-ncx_get_int_short(const void *xp, short *ip)
+static int
+ncx_get_ushort_ushort(const void *xp, ushort *ip)
 {
-#if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
-	get_ix_int(xp, (ix_int *)ip);
+#if SIZEOF_IX_USHORT == SIZEOF_USHORT && IX_USHORT_MAX == USHORT_MAX
+	get_ix_ushort(xp, (ix_ushort *)ip);
 	return ENOERR;
 #else
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-#  if IX_INT_MAX > SHORT_MAX
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
-#  endif
-	return ENOERR;
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (ushort) xx;
+#if IX_USHORT_MAX > USHORT_MAX
+	if (xx > USHORT_MAX) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
-ncx_get_int_int(const void *xp, int *ip)
+static int
+ncx_get_ushort_uchar(const void *xp, uchar *ip)
 {
-#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-	get_ix_int(xp, (ix_int *)ip);
+#if SIZEOF_IX_USHORT == SIZEOF_UCHAR && IX_USHORT_MAX == UCHAR_MAX
+	get_ix_ushort(xp, (ix_ushort *)ip);
 	return ENOERR;
 #else
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-#  if IX_INT_MAX > INT_MAX
-	if(xx > INT_MAX || xx < INT_MIN)
-		return NC_ERANGE;
-#  endif
-	return ENOERR;
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (uchar) xx;
+#if IX_USHORT_MAX > UCHAR_MAX
+	if (xx > UCHAR_MAX) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
-ncx_get_int_uint(const void *xp, unsigned int *ip)
+static int
+ncx_get_ushort_uint(const void *xp, uint *ip)
 {
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx < 0)
-		return NC_ERANGE;
+#if SIZEOF_IX_USHORT == SIZEOF_UINT && IX_USHORT_MAX == UINT_MAX
+	get_ix_ushort(xp, (ix_ushort *)ip);
+	return ENOERR;
+#else
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (uint) xx;
+#if IX_USHORT_MAX > UINT_MAX
+	if (xx > UINT_MAX) return NC_ERANGE;
+#endif
+
+#endif
 	return ENOERR;
 }
 
-int
-ncx_get_int_longlong(const void *xp, long long *ip)
+static int
+ncx_get_ushort_ulonglong(const void *xp, ulonglong *ip)
 {
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
+#if SIZEOF_IX_USHORT == SIZEOF_ULONGLONG && IX_USHORT_MAX == ULONGLONG_MAX
+	get_ix_ushort(xp, (ix_ushort *)ip);
+	return ENOERR;
+#else
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (ulonglong) xx;
+#if IX_USHORT_MAX > ULONGLONG_MAX
+	if (xx > ULONGLONG_MAX) return NC_ERANGE;
+#endif
+
+#endif
 	return ENOERR;
 }
 
-int
-ncx_get_int_ulonglong(const void *xp, unsigned long long *ip)
+static int
+ncx_get_ushort_float(const void *xp, float *ip)
 {
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx < 0)
-	      return NC_ERANGE;
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (float) xx;
+
 	return ENOERR;
 }
 
-int
-ncx_get_int_float(const void *xp, float *ip)
+static int
+ncx_get_ushort_double(const void *xp, double *ip)
+{
+	ix_ushort xx;
+	get_ix_ushort(xp, &xx);
+	*ip = (double) xx;
+
+	return ENOERR;
+}
+
+
+static int
+ncx_put_ushort_schar(void *xp, const schar *ip)
+{
+	uchar *cp = (uchar *) xp;
+	if(*ip & 0x80)
+		*cp++ = 0xff;
+	else
+		*cp++ = 0;
+	*cp = (uchar)*ip;
+        if (*ip < 0) return NC_ERANGE;
+
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_uchar(void *xp, const uchar *ip)
+{
+	uchar *cp = (uchar *) xp;
+	*cp++ = 0;
+	*cp = *ip;
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_short(void *xp, const short *ip)
+{
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+#if IX_USHORT_MAX < SHORT_MAX
+	if (*ip > IX_USHORT_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_int(void *xp, const int *ip)
+{
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+#if IX_USHORT_MAX < INT_MAX
+	if (*ip > IX_USHORT_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_longlong(void *xp, const longlong *ip)
+{
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+#if IX_USHORT_MAX < LONGLONG_MAX
+	if (*ip > IX_USHORT_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_ushort(void *xp, const ushort *ip)
+{
+#if SIZEOF_IX_USHORT == SIZEOF_USHORT && IX_USHORT_MAX == USHORT_MAX
+	put_ix_ushort(xp, (const ix_ushort *)ip);
+	return ENOERR;
+#else
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+#if IX_USHORT_MAX < USHORT_MAX
+	if (*ip > IX_USHORT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_uint(void *xp, const uint *ip)
+{
+#if SIZEOF_IX_USHORT == SIZEOF_UINT && IX_USHORT_MAX == UINT_MAX
+	put_ix_ushort(xp, (const ix_ushort *)ip);
+	return ENOERR;
+#else
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+#if IX_USHORT_MAX < UINT_MAX
+	if (*ip > IX_USHORT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_ulonglong(void *xp, const ulonglong *ip)
+{
+#if SIZEOF_IX_USHORT == SIZEOF_ULONGLONG && IX_USHORT_MAX == ULONGLONG_MAX
+	put_ix_ushort(xp, (const ix_ushort *)ip);
+	return ENOERR;
+#else
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+#if IX_USHORT_MAX < ULONGLONG_MAX
+	if (*ip > IX_USHORT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_float(void *xp, const float *ip)
+{
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+	if(*ip > (double)X_USHORT_MAX || *ip < 0) return NC_ERANGE;
+	return ENOERR;
+}
+
+static int
+ncx_put_ushort_double(void *xp, const double *ip)
+{
+	ix_ushort xx = (ix_ushort)*ip;
+	put_ix_ushort(xp, &xx);
+	if(*ip > X_USHORT_MAX || *ip < 0) return NC_ERANGE;
+	return ENOERR;
+}
+
+
+/* x_int ---------------------------------------------------------------------*/
+
+#if SHORT_MAX == X_INT_MAX
+typedef short ix_int;
+#define SIZEOF_IX_INT SIZEOF_SHORT
+#define IX_INT_MAX SHORT_MAX
+#elif INT_MAX  >= X_INT_MAX
+typedef int ix_int;
+#define SIZEOF_IX_INT SIZEOF_INT
+#define IX_INT_MAX INT_MAX
+#elif LONG_MAX  >= X_INT_MAX
+typedef long ix_int;
+#define SIZEOF_IX_INT SIZEOF_LONG
+#define IX_INT_MAX LONG_MAX
+#else
+#error "ix_int implementation"
+#endif
+
+
+static void
+get_ix_int(const void *xp, ix_int *ip)
+{
+	const uchar *cp = (const uchar *) xp;
+
+	*ip = *cp++ << 24;
+#if SIZEOF_IX_INT > X_SIZEOF_INT
+	if(*ip & 0x80000000)
+	{
+		/* extern is negative */
+		*ip |= (~(0xffffffff)); /* N.B. Assumes "twos complement" */
+	}
+#endif
+	*ip |= (*cp++ << 16);
+	*ip |= (*cp++ << 8);
+	*ip |= *cp;
+}
+
+static void
+put_ix_int(void *xp, const ix_int *ip)
+{
+	uchar *cp = (uchar *) xp;
+
+	*cp++ = (*ip) >> 24;
+	*cp++ = ((*ip) & 0x00ff0000) >> 16;
+	*cp++ = ((*ip) & 0x0000ff00) >>  8;
+	*cp   = ((*ip) & 0x000000ff);
+}
+
+static int
+ncx_get_int_schar(const void *xp, schar *ip)
 {
 	ix_int xx;
 	get_ix_int(xp, &xx);
-	*ip = xx;
-#if 0	/* TODO: determine when necessary */
-	if(xx > FLT_MAX || xx < (-FLT_MAX))
-		return NC_ERANGE;
+	*ip = (schar) xx;
+#if IX_INT_MAX > SCHAR_MAX
+	if (xx > SCHAR_MAX || xx < SCHAR_MIN) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_get_int_short(const void *xp, short *ip)
+{
+#if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
+	get_ix_int(xp, (ix_int *)ip);
+	return ENOERR;
+#else
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (short) xx;
+#if IX_INT_MAX > SHORT_MAX
+	if (xx > SHORT_MAX || xx < SHORT_MIN) return NC_ERANGE;
+#endif
+
 #endif
 	return ENOERR;
 }
 
-int
+       int
+ncx_get_int_int(const void *xp, int *ip)
+{
+#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
+	get_ix_int(xp, (ix_int *)ip);
+	return ENOERR;
+#else
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (int) xx;
+#if IX_INT_MAX > INT_MAX
+	if (xx > INT_MAX || xx < INT_MIN) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_get_int_longlong(const void *xp, longlong *ip)
+{
+#if SIZEOF_IX_INT == SIZEOF_LONGLONG && IX_INT_MAX == LONGLONG_MAX
+	get_ix_int(xp, (ix_int *)ip);
+	return ENOERR;
+#else
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (longlong) xx;
+#if IX_INT_MAX > LONGLONG_MAX
+	if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_get_int_ushort(const void *xp, ushort *ip)
+{
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (ushort) xx;
+#if IX_INT_MAX > USHORT_MAX
+	if (xx > USHORT_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_get_int_uchar(const void *xp, uchar *ip)
+{
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (uchar) xx;
+#if IX_INT_MAX > UCHAR_MAX
+	if (xx > UCHAR_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_get_int_uint(const void *xp, uint *ip)
+{
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (uint) xx;
+#if IX_INT_MAX > UINT_MAX
+	if (xx > UINT_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_get_int_ulonglong(const void *xp, ulonglong *ip)
+{
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (ulonglong) xx;
+#if IX_INT_MAX > ULONGLONG_MAX
+	if (xx > ULONGLONG_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_get_int_float(const void *xp, float *ip)
+{
+	ix_int xx;
+	get_ix_int(xp, &xx);
+	*ip = (float) xx;
+
+	return ENOERR;
+}
+
+static int
 ncx_get_int_double(const void *xp, double *ip)
 {
-	/* assert((DBL_MAX >= X_INT_MAX); */
 	ix_int xx;
 	get_ix_int(xp, &xx);
-	*ip = xx;
+	*ip = (double) xx;
+
 	return ENOERR;
 }
 
-int
+
+static int
 ncx_put_int_schar(void *xp, const schar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -826,7 +1215,7 @@ ncx_put_int_schar(void *xp, const schar *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_int_uchar(void *xp, const uchar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -837,111 +1226,437 @@ ncx_put_int_uchar(void *xp, const uchar *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_int_short(void *xp, const short *ip)
 {
 #if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
-	put_ix_int(xp, (ix_int *)ip);
+	put_ix_int(xp, (const ix_int *)ip);
 	return ENOERR;
 #else
-	ix_int xx = (ix_int)(*ip);
+	ix_int xx = (ix_int)*ip;
 	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < SHORT_MAX
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+#if IX_INT_MAX < SHORT_MAX
+	if (*ip > IX_INT_MAX || *ip < X_INT_MIN) return NC_ERANGE;
+#endif
+
 #endif
+	return ENOERR;
 }
 
-int
+       int
 ncx_put_int_int(void *xp, const int *ip)
 {
 #if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-	put_ix_int(xp, (ix_int *)ip);
+	put_ix_int(xp, (const ix_int *)ip);
 	return ENOERR;
 #else
-	ix_int xx = (ix_int)(*ip);
+	ix_int xx = (ix_int)*ip;
 	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < INT_MAX
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+#if IX_INT_MAX < INT_MAX
+	if (*ip > IX_INT_MAX || *ip < X_INT_MIN) return NC_ERANGE;
 #endif
-}
 
-int
-ncx_put_int_uint(void *xp, const unsigned int *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-	if(*ip > X_UINT_MAX)
-		return NC_ERANGE;
-	return ENOERR;
 #endif
+	return ENOERR;
 }
 
-int
+static int
 ncx_put_int_longlong(void *xp, const longlong *ip)
 {
-#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
-	put_ix_int(xp, (ix_int *)ip);
+#if SIZEOF_IX_INT == SIZEOF_LONGLONG && IX_INT_MAX == LONGLONG_MAX
+	put_ix_int(xp, (const ix_int *)ip);
 	return ENOERR;
 #else
-	ix_int xx = (ix_int)(*ip);
+	ix_int xx = (ix_int)*ip;
 	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < LONG_LONG_MAX
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+#if IX_INT_MAX < LONGLONG_MAX
+	if (*ip > IX_INT_MAX || *ip < X_INT_MIN) return NC_ERANGE;
 #endif
-}
 
-int
-ncx_put_int_ulonglong(void *xp, const unsigned long long *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < LONG_MAX
-	if(*ip > X_INT_MAX)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
 #endif
+	return ENOERR;
 }
 
-int
-ncx_put_int_float(void *xp, const float *ip)
+static int
+ncx_put_int_ushort(void *xp, const ushort *ip)
 {
-	ix_int xx = (ix_int)(*ip);
+	ix_int xx = (ix_int)*ip;
 	put_ix_int(xp, &xx);
-	if(*ip > (double)X_INT_MAX || *ip < (double)X_INT_MIN)
-		return NC_ERANGE;
+#if IX_INT_MAX < USHORT_MAX
+	if (*ip > IX_INT_MAX) return NC_ERANGE;
+#endif
+
 	return ENOERR;
 }
 
-int
-ncx_put_int_double(void *xp, const double *ip)
+static int
+ncx_put_int_uint(void *xp, const uint *ip)
 {
-	ix_int xx = (ix_int)(*ip);
+	ix_int xx = (ix_int)*ip;
 	put_ix_int(xp, &xx);
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
+#if IX_INT_MAX < UINT_MAX
+	if (*ip > IX_INT_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_put_int_ulonglong(void *xp, const ulonglong *ip)
+{
+	ix_int xx = (ix_int)*ip;
+	put_ix_int(xp, &xx);
+#if IX_INT_MAX < ULONGLONG_MAX
+	if (*ip > IX_INT_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_put_int_float(void *xp, const float *ip)
+{
+	ix_int xx = (ix_int)*ip;
+	put_ix_int(xp, &xx);
+	if(*ip > (double)X_INT_MAX || *ip < (double)X_INT_MIN) return NC_ERANGE;
+	return ENOERR;
+}
+
+static int
+ncx_put_int_double(void *xp, const double *ip)
+{
+	ix_int xx = (ix_int)*ip;
+	put_ix_int(xp, &xx);
+	if(*ip > X_INT_MAX || *ip < X_INT_MIN) return NC_ERANGE;
+	return ENOERR;
+}
+
+
+
+/* x_uint --------------------------------------------------------------------*/
+
+#if USHORT_MAX == X_UINT_MAX
+typedef ushort ix_uint;
+#define SIZEOF_IX_UINT SIZEOF_USHORT
+#define IX_UINT_MAX USHORT_MAX
+#elif UINT_MAX  >= X_UINT_MAX
+typedef uint ix_uint;
+#define SIZEOF_IX_UINT SIZEOF_UINT
+#define IX_UINT_MAX UINT_MAX
+#elif ULONG_MAX  >= X_UINT_MAX
+typedef ulong ix_uint;
+#define SIZEOF_IX_UINT SIZEOF_ULONG
+#define IX_UINT_MAX ULONG_MAX
+#else
+#error "ix_uint implementation"
+#endif
+
+
+static void
+get_ix_uint(const void *xp, ix_uint *ip)
+{
+	const uchar *cp = (const uchar *) xp;
+
+	*ip = *cp++ << 24;
+	*ip |= (*cp++ << 16);
+	*ip |= (*cp++ << 8);
+	*ip |= *cp; 
+}
+
+static void
+put_ix_uint(void *xp, const ix_uint *ip)
+{
+	uchar *cp = (uchar *) xp;
+
+	*cp++ = (*ip) >> 24;
+	*cp++ = ((*ip) & 0x00ff0000) >> 16;
+	*cp++ = ((*ip) & 0x0000ff00) >>  8;
+	*cp   = ((*ip) & 0x000000ff);
+}
+
+#if X_SIZEOF_UINT != SIZEOF_UINT
+static int
+ncx_get_uint_uint(const void *xp, uint *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_UINT && IX_UINT_MAX == UINT_MAX
+	get_ix_uint(xp, (ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (uint) xx;
+#if IX_UINT_MAX > UINT_MAX
+	if (xx > UINT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+#endif
+
+static int
+ncx_get_uint_schar(const void *xp, schar *ip)
+{
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (schar) xx;
+#if IX_UINT_MAX > SCHAR_MAX
+	if (xx > SCHAR_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_short(const void *xp, short *ip)
+{
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (short) xx;
+#if IX_UINT_MAX > SHORT_MAX
+	if (xx > SHORT_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_int(const void *xp, int *ip)
+{
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (int) xx;
+#if IX_UINT_MAX > INT_MAX
+	if (xx > INT_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_longlong(const void *xp, longlong *ip)
+{
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (longlong) xx;
+#if IX_UINT_MAX > LONGLONG_MAX
+	if (xx > LONGLONG_MAX) return NC_ERANGE;
+#endif
+
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_ushort(const void *xp, ushort *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_USHORT && IX_UINT_MAX == USHORT_MAX
+	get_ix_uint(xp, (ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (ushort) xx;
+#if IX_UINT_MAX > USHORT_MAX
+	if (xx > USHORT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_uchar(const void *xp, uchar *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_UCHAR && IX_UINT_MAX == UCHAR_MAX
+	get_ix_uint(xp, (ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (uchar) xx;
+#if IX_UINT_MAX > UCHAR_MAX
+	if (xx > UCHAR_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_ulonglong(const void *xp, ulonglong *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_ULONGLONG && IX_UINT_MAX == ULONGLONG_MAX
+	get_ix_uint(xp, (ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (ulonglong) xx;
+#if IX_UINT_MAX > ULONGLONG_MAX
+	if (xx > ULONGLONG_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_float(const void *xp, float *ip)
+{
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (float) xx;
+
+	return ENOERR;
+}
+
+static int
+ncx_get_uint_double(const void *xp, double *ip)
+{
+	ix_uint xx;
+	get_ix_uint(xp, &xx);
+	*ip = (double) xx;
+
+	return ENOERR;
+}
+
+
+static int
+ncx_put_uint_schar(void *xp, const schar *ip)
+{
+	uchar *cp = (uchar *) xp;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp = (uchar)*ip;
+
+	if (*ip < 0) return NC_ERANGE;
+
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_uchar(void *xp, const uchar *ip)
+{
+	uchar *cp = (uchar *) xp;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp   = *ip;
+	return ENOERR;
+}
+
+#if X_SIZEOF_UINT != SIZEOF_UINT
+static int
+ncx_put_uint_uint(void *xp, const uint *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_UINT && IX_UINT_MAX == UINT_MAX
+	put_ix_uint(xp, (const ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+#if IX_UINT_MAX < UINT_MAX
+	if (*ip > IX_UINT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+#endif
+
+static int
+ncx_put_uint_short(void *xp, const short *ip)
+{
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+#if IX_UINT_MAX < SHORT_MAX
+	if (*ip > IX_UINT_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_int(void *xp, const int *ip)
+{
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+#if IX_UINT_MAX < INT_MAX
+	if (*ip > IX_UINT_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_longlong(void *xp, const longlong *ip)
+{
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+#if IX_UINT_MAX < LONGLONG_MAX
+	if (*ip > IX_UINT_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_ushort(void *xp, const ushort *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_USHORT && IX_UINT_MAX == USHORT_MAX
+	put_ix_uint(xp, (const ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+#if IX_UINT_MAX < USHORT_MAX
+	if (*ip > IX_UINT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_ulonglong(void *xp, const ulonglong *ip)
+{
+#if SIZEOF_IX_UINT == SIZEOF_ULONGLONG && IX_UINT_MAX == ULONGLONG_MAX
+	put_ix_uint(xp, (const ix_uint *)ip);
+	return ENOERR;
+#else
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+#if IX_UINT_MAX < ULONGLONG_MAX
+	if (*ip > IX_UINT_MAX) return NC_ERANGE;
+#endif
+
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_float(void *xp, const float *ip)
+{
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+	if(*ip > (double)X_UINT_MAX || *ip < 0) return NC_ERANGE;
+	return ENOERR;
+}
+
+static int
+ncx_put_uint_double(void *xp, const double *ip)
+{
+	ix_uint xx = (ix_uint)*ip;
+	put_ix_uint(xp, &xx);
+	if(*ip > X_UINT_MAX || *ip < 0) return NC_ERANGE;
 	return ENOERR;
 }
 
 
-/* x_float */
+/* x_float -------------------------------------------------------------------*/
 
 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
 
@@ -1000,196 +1715,105 @@ static struct sgl_limits min = {
 	{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }		/* Min IEEE */
 };
 
-#line 1064
 static void
 get_ix_float(const void *xp, float *ip)
 {
 		struct vax_single *const vsp = (struct vax_single *) ip;
-#line 1067
 		const struct ieee_single *const isp =
-#line 1067
 			 (const struct ieee_single *) xp;
-#line 1067
 		unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
-#line 1067
 
-#line 1067
 		switch(exp) {
-#line 1067
 		case 0 :
-#line 1067
 			/* ieee subnormal */
-#line 1067
 			if(isp->mant_hi == min.ieee.mant_hi
-#line 1067
 				&& isp->mant_lo_hi == min.ieee.mant_lo_hi
-#line 1067
 				&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
-#line 1067
 			{
-#line 1067
 				*vsp = min.s;
-#line 1067
 			}
-#line 1067
 			else
-#line 1067
 			{
-#line 1067
 				unsigned mantissa = (isp->mant_hi << 16)
-#line 1067
 					 | isp->mant_lo_hi << 8
-#line 1067
 					 | isp->mant_lo_lo;
-#line 1067
 				unsigned tmp = mantissa >> 20;
-#line 1067
 				if(tmp >= 4) {
-#line 1067
 					vsp->exp = 2;
-#line 1067
 				} else if (tmp >= 2) {
-#line 1067
 					vsp->exp = 1;
-#line 1067
 				} else {
-#line 1067
 					*vsp = min.s;
-#line 1067
 					break;
-#line 1067
 				} /* else */
-#line 1067
 				tmp = mantissa - (1 << (20 + vsp->exp ));
-#line 1067
 				tmp <<= 3 - vsp->exp;
-#line 1067
 				vsp->mantissa2 = tmp;
-#line 1067
 				vsp->mantissa1 = (tmp >> 16);
-#line 1067
 			}
-#line 1067
 			break;
-#line 1067
 		case 0xfe :
-#line 1067
 		case 0xff :
-#line 1067
 			*vsp = max.s;
-#line 1067
 			break;
-#line 1067
 		default :
-#line 1067
 			vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
-#line 1067
 			vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
-#line 1067
 			vsp->mantissa1 = isp->mant_hi;
-#line 1067
 		}
-#line 1067
 
-#line 1067
 		vsp->sign = isp->sign;
-#line 1067
 
 }
 
-#line 1121
 
 static void
 put_ix_float(void *xp, const float *ip)
 {
 		const struct vax_single *const vsp =
-#line 1125
 			 (const struct vax_single *)ip;
-#line 1125
 		struct ieee_single *const isp = (struct ieee_single *) xp;
-#line 1125
 
-#line 1125
 		switch(vsp->exp){
-#line 1125
 		case 0 :
-#line 1125
 			/* all vax float with zero exponent map to zero */
-#line 1125
 			*isp = min.ieee;
-#line 1125
 			break;
-#line 1125
 		case 2 :
-#line 1125
 		case 1 :
-#line 1125
 		{
-#line 1125
 			/* These will map to subnormals */
-#line 1125
 			unsigned mantissa = (vsp->mantissa1 << 16)
-#line 1125
 					 | vsp->mantissa2;
-#line 1125
 			mantissa >>= 3 - vsp->exp;
-#line 1125
 			mantissa += (1 << (20 + vsp->exp));
-#line 1125
 			isp->mant_lo_lo = mantissa;
-#line 1125
 			isp->mant_lo_hi = mantissa >> 8;
-#line 1125
 			isp->mant_hi = mantissa >> 16;
-#line 1125
 			isp->exp_lo = 0;
-#line 1125
 			isp->exp_hi = 0;
-#line 1125
 		}
-#line 1125
 			break;
-#line 1125
 		case 0xff : /* max.s.exp */
-#line 1125
 			if( vsp->mantissa2 == max.s.mantissa2
-#line 1125
 				&& vsp->mantissa1 == max.s.mantissa1)
-#line 1125
 			{
-#line 1125
 				/* map largest vax float to ieee infinity */
-#line 1125
 				*isp = max.ieee;
-#line 1125
 				break;
-#line 1125
 			} /* else, fall thru */
-#line 1125
 		default :
-#line 1125
 		{
-#line 1125
 			unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
-#line 1125
 			isp->exp_hi = exp >> 1;
-#line 1125
 			isp->exp_lo = exp;
-#line 1125
 			isp->mant_lo_lo = vsp->mantissa2;
-#line 1125
 			isp->mant_lo_hi = vsp->mantissa2 >> 8;
-#line 1125
 			isp->mant_hi = vsp->mantissa1;
-#line 1125
 		}
-#line 1125
 		}
-#line 1125
 
-#line 1125
 		isp->sign = vsp->sign;
-#line 1125
 
 }
 
@@ -1198,7 +1822,7 @@ put_ix_float(void *xp, const float *ip)
 
 /*
  * Return the number of bytes until the next "word" boundary
- * N.B. This is based on the very wierd YMP address structure,
+ * N.B. This is based on the very weird YMP address structure,
  * which puts the address within a word in the leftmost 3 bits
  * of the address.
  */
@@ -1249,7 +1873,6 @@ static const int cs_ieis_bias = 0x4000 - 0x7f;
 
 static const int cs_id_bias = 0x4000 - 0x3ff;
 
-#line 1260
 
 static void
 get_ix_float(const void *xp, float *ip)
@@ -1259,86 +1882,48 @@ 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 1268
 
-#line 1268
 		if(isp->exp == 0)
-#line 1268
 		{
-#line 1268
 			/* ieee subnormal */
-#line 1268
 			*ip = (double)isp->mant;
-#line 1268
 			if(isp->mant != 0)
-#line 1268
 			{
-#line 1268
 				csp->exp -= (ieee_single_bias + 22);
-#line 1268
 			}
-#line 1268
 		}
-#line 1268
 		else
-#line 1268
 		{
-#line 1268
 			csp->exp  = isp->exp + cs_ieis_bias + 1;
-#line 1268
 			csp->mant = isp->mant << (48 - 1 - 23);
-#line 1268
 			csp->mant |= (1 << (48 - 1));
-#line 1268
 		}
-#line 1268
 		csp->sign = isp->sign;
-#line 1268
 
-#line 1268
 
 	}
 	else
 	{
 		const ieee_single_lo *isp = (const ieee_single_lo *) xp;
 		cray_single *csp = (cray_single *) ip;
-#line 1273
 
-#line 1273
 		if(isp->exp == 0)
-#line 1273
 		{
-#line 1273
 			/* ieee subnormal */
-#line 1273
 			*ip = (double)isp->mant;
-#line 1273
 			if(isp->mant != 0)
-#line 1273
 			{
-#line 1273
 				csp->exp -= (ieee_single_bias + 22);
-#line 1273
 			}
-#line 1273
 		}
-#line 1273
 		else
-#line 1273
 		{
-#line 1273
 			csp->exp  = isp->exp + cs_ieis_bias + 1;
-#line 1273
 			csp->mant = isp->mant << (48 - 1 - 23);
-#line 1273
 			csp->mant |= (1 << (48 - 1));
-#line 1273
 		}
-#line 1273
 		csp->sign = isp->sign;
-#line 1273
 
-#line 1273
 
 	}
 }
@@ -1350,182 +1935,96 @@ 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 1283
 	int ieee_exp = csp->exp - cs_ieis_bias -1;
-#line 1283
 
-#line 1283
 	isp->sign = csp->sign;
-#line 1283
 
-#line 1283
 	if(ieee_exp >= 0xff)
-#line 1283
 	{
-#line 1283
 		/* NC_ERANGE => ieee Inf */
-#line 1283
 		isp->exp = 0xff;
-#line 1283
 		isp->mant = 0x0;
-#line 1283
 	}
-#line 1283
 	else if(ieee_exp > 0)
-#line 1283
 	{
-#line 1283
 		/* normal ieee representation */
-#line 1283
 		isp->exp  = ieee_exp;
-#line 1283
 		/* assumes cray rep is in normal form */
-#line 1283
 		assert(csp->mant & 0x800000000000);
-#line 1283
 		isp->mant = (((csp->mant << 1) &
-#line 1283
 				0xffffffffffff) >> (48 - 23));
-#line 1283
 	}
-#line 1283
 	else if(ieee_exp > -23)
-#line 1283
 	{
-#line 1283
 		/* ieee subnormal, right shift */
-#line 1283
 		const int rshift = (48 - 23 - ieee_exp);
-#line 1283
 
-#line 1283
 		isp->mant = csp->mant >> rshift;
-#line 1283
 
-#line 1283
 #if 0
-#line 1283
 		if(csp->mant & (1 << (rshift -1)))
-#line 1283
 		{
-#line 1283
 			/* round up */
-#line 1283
 			isp->mant++;
-#line 1283
 		}
-#line 1283
 #endif
-#line 1283
 
-#line 1283
 		isp->exp  = 0;
-#line 1283
 	}
-#line 1283
 	else
-#line 1283
 	{
-#line 1283
 		/* smaller than ieee can represent */
-#line 1283
 		isp->exp = 0;
-#line 1283
 		isp->mant = 0;
-#line 1283
 	}
-#line 1283
 
 	}
 	else
 	{
 		ieee_single_lo *isp = (ieee_single_lo*)xp;
 	const cray_single *csp = (const cray_single *) ip;
-#line 1288
 	int ieee_exp = csp->exp - cs_ieis_bias -1;
-#line 1288
 
-#line 1288
 	isp->sign = csp->sign;
-#line 1288
 
-#line 1288
 	if(ieee_exp >= 0xff)
-#line 1288
 	{
-#line 1288
 		/* NC_ERANGE => ieee Inf */
-#line 1288
 		isp->exp = 0xff;
-#line 1288
 		isp->mant = 0x0;
-#line 1288
 	}
-#line 1288
 	else if(ieee_exp > 0)
-#line 1288
 	{
-#line 1288
 		/* normal ieee representation */
-#line 1288
 		isp->exp  = ieee_exp;
-#line 1288
 		/* assumes cray rep is in normal form */
-#line 1288
 		assert(csp->mant & 0x800000000000);
-#line 1288
 		isp->mant = (((csp->mant << 1) &
-#line 1288
 				0xffffffffffff) >> (48 - 23));
-#line 1288
 	}
-#line 1288
 	else if(ieee_exp > -23)
-#line 1288
 	{
-#line 1288
 		/* ieee subnormal, right shift */
-#line 1288
 		const int rshift = (48 - 23 - ieee_exp);
-#line 1288
 
-#line 1288
 		isp->mant = csp->mant >> rshift;
-#line 1288
 
-#line 1288
 #if 0
-#line 1288
 		if(csp->mant & (1 << (rshift -1)))
-#line 1288
 		{
-#line 1288
 			/* round up */
-#line 1288
 			isp->mant++;
-#line 1288
 		}
-#line 1288
 #endif
-#line 1288
 
-#line 1288
 		isp->exp  = 0;
-#line 1288
 	}
-#line 1288
 	else
-#line 1288
 	{
-#line 1288
 		/* smaller than ieee can represent */
-#line 1288
 		isp->exp = 0;
-#line 1288
 		isp->mant = 0;
-#line 1288
 	}
-#line 1288
 
 	}
 }
@@ -1601,201 +2100,206 @@ put_ix_float(void *xp, const float *ip)
 #error "ix_float implementation"
 #endif
 
-
-int
-ncx_get_float_schar(const void *xp, schar *ip)
+#if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
+static int
+ncx_get_float_float(const void *xp, float *ip)
 {
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (schar) xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
+	/* TODO */
+	get_ix_float(xp, ip);
 	return ENOERR;
 }
+#endif
 
-int
-ncx_get_float_uchar(const void *xp, uchar *ip)
+#define ix_float float
+
+static int
+ncx_get_float_schar(const void *xp, schar *ip)
 {
-	float xx;
+	ix_float xx;
 	get_ix_float(xp, &xx);
-	*ip = (uchar) xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
+	*ip = (schar) xx;
+	if(xx > (double)SCHAR_MAX || xx < (double)SCHAR_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_float_short(const void *xp, short *ip)
 {
-	float xx;
+	ix_float xx;
 	get_ix_float(xp, &xx);
 	*ip = (short) xx;
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
+	if(xx > (double)SHORT_MAX || xx < (double)SHORT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_float_int(const void *xp, int *ip)
 {
-	float xx;
+	ix_float xx;
 	get_ix_float(xp, &xx);
 	*ip = (int) xx;
-	if(xx > (double)INT_MAX || xx < (double)INT_MIN)
-		return NC_ERANGE;
+	if(xx > (double)INT_MAX || xx < (double)INT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_float_uint(const void *xp, unsigned int *ip)
+static int
+ncx_get_float_double(const void *xp, double *ip)
 {
-	float xx;
+	ix_float xx;
 	get_ix_float(xp, &xx);
-	*ip = (unsigned int) xx;
-	if(xx > (double)UINT_MAX || xx < 0)
-		return NC_ERANGE;
+	*ip = (double) xx;
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_float_longlong(const void *xp, longlong *ip)
 {
-	float xx;
+	ix_float xx;
 	get_ix_float(xp, &xx);
 	*ip = (longlong) xx;
-	if(xx > (double)LONG_LONG_MAX || xx < (double)LONG_LONG_MIN)
-		return NC_ERANGE;
+	if(xx > (double)LONGLONG_MAX || xx < (double)LONGLONG_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_float_ulonglong(const void *xp, unsigned long long *ip)
+static int
+ncx_get_float_uchar(const void *xp, uchar *ip)
 {
-	float xx;
+	ix_float xx;
 	get_ix_float(xp, &xx);
-	*ip = (longlong) xx;
-	if(xx > (double)ULONG_LONG_MAX || xx < 0)
-		return NC_ERANGE;
+	*ip = (uchar) xx;
+	if(xx > (double)UCHAR_MAX || xx < 0) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_float_float(const void *xp, float *ip)
+static int
+ncx_get_float_ushort(const void *xp, ushort *ip)
 {
-	/* TODO */
-	get_ix_float(xp, ip);
+	ix_float xx;
+	get_ix_float(xp, &xx);
+	*ip = (ushort) xx;
+	if(xx > (double)USHORT_MAX || xx < 0) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_float_double(const void *xp, double *ip)
+static int
+ncx_get_float_uint(const void *xp, uint *ip)
 {
-	/* TODO */
-	float xx;
+	ix_float xx;
+	get_ix_float(xp, &xx);
+	*ip = (uint) xx;
+	if(xx > (double)UINT_MAX || xx < 0) return NC_ERANGE;
+	return ENOERR;
+}
+
+static int
+ncx_get_float_ulonglong(const void *xp, ulonglong *ip)
+{
+	ix_float xx;
 	get_ix_float(xp, &xx);
-	*ip = xx;
+	*ip = (ulonglong) xx;
+	if(xx > (double)ULONGLONG_MAX || xx < 0) return NC_ERANGE;
 	return ENOERR;
 }
 
 
-int
-ncx_put_float_schar(void *xp, const schar *ip)
+#if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
+static int
+ncx_put_float_float(void *xp, const float *ip)
 {
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
+	put_ix_float(xp, ip);
+#ifdef NO_IEEE_FLOAT
+	if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
+		return NC_ERANGE;
+#endif
 	return ENOERR;
 }
+#endif
 
-int
-ncx_put_float_uchar(void *xp, const uchar *ip)
+static int
+ncx_put_float_schar(void *xp, const schar *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_float_short(void *xp, const short *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX || (float)(*ip) < X_FLOAT_MIN)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_float_int(void *xp, const int *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX || (float)(*ip) < X_FLOAT_MIN)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
-ncx_put_float_uint(void *xp, const unsigned int *ip)
+static int
+ncx_put_float_double(void *xp, const double *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX)
-		return NC_ERANGE;
-#endif
+	if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_float_longlong(void *xp, const longlong *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX || (float)(*ip) < X_FLOAT_MIN)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
-ncx_put_float_ulonglong(void *xp, const unsigned long long *ip)
+static int
+ncx_put_float_uchar(void *xp, const uchar *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
-ncx_put_float_float(void *xp, const float *ip)
+static int
+ncx_put_float_ushort(void *xp, const ushort *ip)
 {
-	put_ix_float(xp, ip);
-#ifdef NO_IEEE_FLOAT
-	if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
-		return NC_ERANGE;
-#endif
+	ix_float xx = (ix_float)*ip;
+	put_ix_float(xp, &xx);
+
 	return ENOERR;
 }
 
-int
-ncx_put_float_double(void *xp, const double *ip)
+static int
+ncx_put_float_uint(void *xp, const uint *ip)
 {
-	float xx = (float) *ip;
+	ix_float xx = (ix_float)*ip;
 	put_ix_float(xp, &xx);
-	if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
-		return NC_ERANGE;
+
+	return ENOERR;
+}
+
+static int
+ncx_put_float_ulonglong(void *xp, const ulonglong *ip)
+{
+	ix_float xx = (ix_float)*ip;
+	put_ix_float(xp, &xx);
+
 	return ENOERR;
 }
 
-/* x_double */
+
+
+/* x_double ------------------------------------------------------------------*/
 
 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE  && !defined(NO_IEEE_FLOAT)
 
@@ -1858,218 +2362,116 @@ static const struct dbl_limits {
 };
 
 
-#line 1668
 static void
 get_ix_double(const void *xp, double *ip)
 {
 	struct vax_double *const vdp =
-#line 1671
 			 (struct vax_double *)ip;
-#line 1671
 	const struct ieee_double *const idp =
-#line 1671
 			 (const struct ieee_double *) xp;
-#line 1671
 	{
-#line 1671
 		const struct dbl_limits *lim;
-#line 1671
 		int ii;
-#line 1671
 		for (ii = 0, lim = dbl_limits;
-#line 1671
 			ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
-#line 1671
 			ii++, lim++)
-#line 1671
 		{
-#line 1671
 			if ((idp->mant_lo == lim->ieee.mant_lo)
-#line 1671
 				&& (idp->mant_4 == lim->ieee.mant_4)
-#line 1671
 				&& (idp->mant_5 == lim->ieee.mant_5)
-#line 1671
 				&& (idp->mant_6 == lim->ieee.mant_6)
-#line 1671
 				&& (idp->exp_lo == lim->ieee.exp_lo)
-#line 1671
 				&& (idp->exp_hi == lim->ieee.exp_hi)
-#line 1671
 				)
-#line 1671
 			{
-#line 1671
 				*vdp = lim->d;
-#line 1671
 				goto doneit;
-#line 1671
 			}
-#line 1671
 		}
-#line 1671
 	}
-#line 1671
 	{
-#line 1671
 		unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
-#line 1671
 		vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
-#line 1671
 	}
-#line 1671
 	{
-#line 1671
 		unsigned mant_hi = ((idp->mant_6 << 16)
-#line 1671
 				 | (idp->mant_5 << 8)
-#line 1671
 				 | idp->mant_4);
-#line 1671
 		unsigned mant_lo = SWAP4(idp->mant_lo);
-#line 1671
 		vdp->mantissa1 = (mant_hi >> 13);
-#line 1671
 		vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
-#line 1671
 				| (mant_lo >> 29);
-#line 1671
 		vdp->mantissa3 = (mant_lo >> 13);
-#line 1671
 		vdp->mantissa4 = (mant_lo << 3);
-#line 1671
 	}
-#line 1671
 	doneit:
-#line 1671
 		vdp->sign = idp->sign;
-#line 1671
 
 }
 
 
-#line 1741
 static void
 put_ix_double(void *xp, const double *ip)
 {
 	const struct vax_double *const vdp =
-#line 1744
 			(const struct vax_double *)ip;
-#line 1744
 	struct ieee_double *const idp =
-#line 1744
 			 (struct ieee_double *) xp;
-#line 1744
 
-#line 1744
 	if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
-#line 1744
 		(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
-#line 1744
 		(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
-#line 1744
 		(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
-#line 1744
 		(vdp->exp == dbl_limits[0].d.exp))
-#line 1744
 	{
-#line 1744
 		*idp = dbl_limits[0].ieee;
-#line 1744
 		goto shipit;
-#line 1744
 	}
-#line 1744
 	if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
-#line 1744
 		(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
-#line 1744
 		(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
-#line 1744
 		(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
-#line 1744
 		(vdp->exp == dbl_limits[1].d.exp))
-#line 1744
 	{
-#line 1744
 		*idp = dbl_limits[1].ieee;
-#line 1744
 		goto shipit;
-#line 1744
 	}
-#line 1744
 
-#line 1744
 	{
-#line 1744
 		unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
-#line 1744
 
-#line 1744
 		unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
-#line 1744
 			(vdp->mantissa3 << 13) |
-#line 1744
 			((vdp->mantissa4 >> 3) & MASK(13));
-#line 1744
 
-#line 1744
 		unsigned mant_hi = (vdp->mantissa1 << 13)
-#line 1744
 				 | (vdp->mantissa2 >> 3);
-#line 1744
 
-#line 1744
 		if((vdp->mantissa4 & 7) > 4)
-#line 1744
 		{
-#line 1744
 			/* round up */
-#line 1744
 			mant_lo++;
-#line 1744
 			if(mant_lo == 0)
-#line 1744
 			{
-#line 1744
 				mant_hi++;
-#line 1744
 				if(mant_hi > 0xffffff)
-#line 1744
 				{
-#line 1744
 					mant_hi = 0;
-#line 1744
 					exp++;
-#line 1744
 				}
-#line 1744
 			}
-#line 1744
 		}
-#line 1744
 
-#line 1744
 		idp->mant_lo = SWAP4(mant_lo);
-#line 1744
 		idp->mant_6 = mant_hi >> 16;
-#line 1744
 		idp->mant_5 = (mant_hi & 0xff00) >> 8;
-#line 1744
 		idp->mant_4 = mant_hi;
-#line 1744
 		idp->exp_hi = exp >> 4;
-#line 1744
 		idp->exp_lo = exp;
-#line 1744
 	}
-#line 1744
 
-#line 1744
 	shipit:
-#line 1744
 		idp->sign = vdp->sign;
-#line 1744
 
 }
 
@@ -2160,72 +2562,79 @@ put_ix_double(void *xp, const double *ip)
 #error "ix_double implementation"
 #endif
 
-int
+#define ix_double double
+
+static int
 ncx_get_double_schar(const void *xp, schar *ip)
 {
-	double xx;
+	ix_double xx;
 	get_ix_double(xp, &xx);
 	*ip = (schar) xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
+	if(xx > SCHAR_MAX || xx < SCHAR_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_double_uchar(const void *xp, uchar *ip)
+static int
+ncx_get_double_short(const void *xp, short *ip)
 {
-	double xx;
+	ix_double xx;
 	get_ix_double(xp, &xx);
-	*ip = (uchar) xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
+	*ip = (short) xx;
+	if(xx > SHORT_MAX || xx < SHORT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_double_short(const void *xp, short *ip)
+static int
+ncx_get_double_int(const void *xp, int *ip)
 {
-	double xx;
+	ix_double xx;
 	get_ix_double(xp, &xx);
-	*ip = (short) xx;
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
+	*ip = (int) xx;
+	if(xx > INT_MAX || xx < INT_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_double_int(const void *xp, int *ip)
+static int
+ncx_get_double_longlong(const void *xp, longlong *ip)
 {
-	double xx;
+	ix_double xx;
 	get_ix_double(xp, &xx);
-	*ip = (int) xx;
-	if(xx > INT_MAX || xx < INT_MIN)
-		return NC_ERANGE;
+	*ip = (longlong) xx;
+	if(xx > LONGLONG_MAX || xx < LONGLONG_MIN) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_double_uint(const void *xp, unsigned int *ip)
+static int
+ncx_get_double_uchar(const void *xp, uchar *ip)
 {
-	double xx;
+	ix_double xx;
 	get_ix_double(xp, &xx);
-	*ip = (unsigned int) xx;
-	if(xx > UINT_MAX || xx < 0)
-		return NC_ERANGE;
+	*ip = (uchar) xx;
+	if(xx > UCHAR_MAX || xx < 0) return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_get_double_longlong(const void *xp, longlong *ip)
+static int
+ncx_get_double_ushort(const void *xp, ushort *ip)
 {
-	double xx;
+	ix_double xx;
 	get_ix_double(xp, &xx);
-	*ip = (longlong) xx;
-	if(xx > LONG_LONG_MAX || xx < LONG_LONG_MIN)
-		return NC_ERANGE;
+	*ip = (ushort) xx;
+	if(xx > USHORT_MAX || xx < 0) return NC_ERANGE;
+	return ENOERR;
+}
+
+static int
+ncx_get_double_uint(const void *xp, uint *ip)
+{
+	ix_double xx;
+	get_ix_double(xp, &xx);
+	*ip = (uint) xx;
+	if(xx > UINT_MAX || xx < 0) return NC_ERANGE;
 	return ENOERR;
 }
 
+
 int
 ncx_get_double_ulonglong(const void *xp, unsigned long long *ip)
 {
@@ -2237,7 +2646,7 @@ ncx_get_double_ulonglong(const void *xp, unsigned long long *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_double_float(const void *xp, float *ip)
 {
 	double xx;
@@ -2256,92 +2665,90 @@ ncx_get_double_float(const void *xp, float *ip)
 	return ENOERR;
 }
 
-int
+#if X_SIZEOF_DOUBLE != SIZEOF_DOUBLE  || defined(NO_IEEE_FLOAT)
+static int
 ncx_get_double_double(const void *xp, double *ip)
 {
 	/* TODO */
 	get_ix_double(xp, ip);
 	return ENOERR;
 }
+#endif
 
-
-int
+static int
 ncx_put_double_schar(void *xp, const schar *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_double_uchar(void *xp, const uchar *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_double_short(void *xp, const short *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
+static int
+ncx_put_double_ushort(void *xp, const ushort *ip)
+{
+	ix_double xx = (ix_double)*ip;
+	put_ix_double(xp, &xx);
+
+	return ENOERR;
+}
+
+static int
 ncx_put_double_int(void *xp, const int *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
-ncx_put_double_uint(void *xp, const unsigned int *ip)
+static int
+ncx_put_double_uint(void *xp, const uint *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_double_longlong(void *xp, const longlong *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
-ncx_put_double_ulonglong(void *xp, const unsigned long long *ip)
+static int
+ncx_put_double_ulonglong(void *xp, const ulonglong *ip)
 {
-	double xx = (double) *ip;
+	ix_double xx = (ix_double)*ip;
 	put_ix_double(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX)
-		return NC_ERANGE;
-#endif
+
 	return ENOERR;
 }
 
-int
+
+static int
 ncx_put_double_float(void *xp, const float *ip)
 {
 	double xx = (double) *ip;
@@ -2353,7 +2760,8 @@ ncx_put_double_float(void *xp, const float *ip)
 	return ENOERR;
 }
 
-int
+#if X_SIZEOF_DOUBLE != SIZEOF_DOUBLE  || defined(NO_IEEE_FLOAT)
+static int
 ncx_put_double_double(void *xp, const double *ip)
 {
 	put_ix_double(xp, ip);
@@ -2363,11744 +2771,14457 @@ ncx_put_double_double(void *xp, const double *ip)
 #endif
 	return ENOERR;
 }
+#endif
 
 
-/* x_size_t */
-
-#if SIZEOF_SIZE_T < X_SIZEOF_SIZE_T
-#error "x_size_t implementation"
-/* netcdf requires size_t which can hold a values from 0 to 2^32 -1 */
+/* x_longlong ---------------------------------------------------------------------*/
+
+#if SHORT_MAX == X_LONGLONG_MAX
+typedef short ix_longlong;
+#define SIZEOF_IX_LONGLONG SIZEOF_SHORT
+#define IX_LONGLONG_MAX SHORT_MAX
+#elif LONG_LONG_MAX  >= X_LONGLONG_MAX
+typedef longlong ix_longlong;
+#define SIZEOF_IX_LONGLONG SIZEOF_LONGLONG
+#define IX_LONGLONG_MAX LONG_LONG_MAX
+#elif LONG_MAX  >= X_LONGLONG_MAX
+typedef long ix_longlong;
+#define SIZEOF_IX_LONGLONG SIZEOF_LONG
+#define IX_LONGLONG_MAX LONG_MAX
+#else
+#error "ix_longlong implementation"
 #endif
 
-int
-ncx_put_size_t(void **xpp, const size_t *ulp)
+
+static void
+get_ix_longlong(const void *xp, ix_longlong *ip)
 {
-	/* similar to put_ix_int() */
-	uchar *cp = (uchar *) *xpp;
-	assert(*ulp <= X_SIZE_MAX);
+    const uchar *cp = (const uchar *) xp;
+
+    *ip  = ((long long)(*cp++) << 56);
+    *ip |= ((long long)(*cp++) << 48);
+    *ip |= ((long long)(*cp++) << 40);
+    *ip |= ((long long)(*cp++) << 32);
+    *ip |= ((long long)(*cp++) << 24);
+    *ip |= ((long long)(*cp++) << 16);
+    *ip |= ((long long)(*cp++) <<  8);
+    *ip |=  (long long)*cp;
+}
 
-	*cp++ = (uchar)((*ulp) >> 24);
-	*cp++ = (uchar)(((*ulp) & 0x00ff0000) >> 16);
-	*cp++ = (uchar)(((*ulp) & 0x0000ff00) >>  8);
-	*cp   = (uchar)((*ulp) & 0x000000ff);
+static void
+put_ix_longlong(void *xp, const ix_longlong *ip)
+{
+    uchar *cp = (uchar *) xp;
+
+    *cp++ = (*ip) >> 56;
+    *cp++ = ((*ip) & 0x00ff000000000000LL) >> 48;
+    *cp++ = ((*ip) & 0x0000ff0000000000LL) >> 40;
+    *cp++ = ((*ip) & 0x000000ff00000000LL) >> 32;
+    *cp++ = ((*ip) & 0x00000000ff000000LL) >> 24;
+    *cp++ = ((*ip) & 0x0000000000ff0000LL) >> 16;
+    *cp++ = ((*ip) & 0x000000000000ff00LL) >>  8;
+    *cp   = ((*ip) & 0x00000000000000ffLL);
+}
+
+static int
+ncx_get_longlong_schar(const void *xp, schar *ip)
+{
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (schar) xx;
+#if IX_LONGLONG_MAX > SCHAR_MAX
+	if (xx > SCHAR_MAX || xx < SCHAR_MIN) return NC_ERANGE;
+#endif
 
-	*xpp = (void *)((char *)(*xpp) + X_SIZEOF_SIZE_T);
 	return ENOERR;
 }
 
-int
-ncx_get_size_t(const void **xpp,  size_t *ulp)
+static int
+ncx_get_longlong_short(const void *xp, short *ip)
 {
-	/* similar to get_ix_int */
-	const uchar *cp = (const uchar *) *xpp;
+#if SIZEOF_IX_LONGLONG == SIZEOF_SHORT && IX_LONGLONG_MAX == SHORT_MAX
+	get_ix_longlong(xp, (ix_longlong *)ip);
+	return ENOERR;
+#else
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (short) xx;
+#if IX_LONGLONG_MAX > SHORT_MAX
+	if (xx > SHORT_MAX || xx < SHORT_MIN) return NC_ERANGE;
+#endif
 
-	*ulp = (unsigned)(*cp++ << 24);
-	*ulp |= (*cp++ << 16);
-	*ulp |= (*cp++ << 8);
-	*ulp |= *cp;
+#endif
+	return ENOERR;
+}
 
-	*xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_SIZE_T);
+static int
+ncx_get_longlong_int(const void *xp, int *ip)
+{
+#if SIZEOF_IX_LONGLONG == SIZEOF_INT && IX_LONGLONG_MAX == INT_MAX
+	get_ix_longlong(xp, (ix_longlong *)ip);
+	return ENOERR;
+#else
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (int) xx;
+#if IX_LONGLONG_MAX > INT_MAX
+	if (xx > INT_MAX || xx < INT_MIN) return NC_ERANGE;
+#endif
+
+#endif
 	return ENOERR;
 }
 
-/* x_off_t */
+static int
+ncx_get_longlong_longlong(const void *xp, longlong *ip)
+{
+#if SIZEOF_IX_LONGLONG == SIZEOF_LONGLONG && IX_LONGLONG_MAX == LONGLONG_MAX
+	get_ix_longlong(xp, (ix_longlong *)ip);
+	return ENOERR;
+#else
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (longlong) xx;
+#if IX_LONGLONG_MAX > LONGLONG_MAX
+	if (xx > LONGLONG_MAX || xx < LONGLONG_MIN) return NC_ERANGE;
+#endif
 
-int
-ncx_put_off_t(void **xpp, const off_t *lp, size_t sizeof_off_t)
+#endif
+	return ENOERR;
+}
+
+static int
+ncx_get_longlong_ushort(const void *xp, ushort *ip)
 {
-	/* similar to put_ix_int() */
-	uchar *cp = (uchar *) *xpp;
-		/* No negative offsets stored in netcdf */
-	if (*lp < 0) {
-	  /* Assume this is an overflow of a 32-bit int... */
-	  return ERANGE;
-	}
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (ushort) xx;
+#if IX_LONGLONG_MAX > USHORT_MAX
+	if (xx > USHORT_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
 
-	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
+static int
+ncx_get_longlong_uchar(const void *xp, uchar *ip)
+{
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (uchar) xx;
+#if IX_LONGLONG_MAX > UCHAR_MAX
+	if (xx > UCHAR_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
 
-	if (sizeof_off_t == 4) {
-		*cp++ = (uchar) ((*lp)               >> 24);
-		*cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
-		*cp++ = (uchar)(((*lp) & 0x0000ff00) >>  8);
-		*cp   = (uchar)( (*lp) & 0x000000ff);
-	} else {
-#if SIZEOF_OFF_T == 4
-/* Write a 64-bit offset on a system with only a 32-bit offset */
-		*cp++ = (uchar)0;
-		*cp++ = (uchar)0;
-		*cp++ = (uchar)0;
-		*cp++ = (uchar)0;
+static int
+ncx_get_longlong_uint(const void *xp, uint *ip)
+{
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (uint) xx;
+#if IX_LONGLONG_MAX > UINT_MAX
+	if (xx > UINT_MAX) return NC_ERANGE;
+#endif
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
+	return ENOERR;
+}
 
-		*cp++ = (uchar)(((*lp) & 0xff000000) >> 24);
-		*cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
-		*cp++ = (uchar)(((*lp) & 0x0000ff00) >>  8);
-		*cp   = (uchar)( (*lp) & 0x000000ff);
-#else
-		*cp++ = (uchar) ((*lp)                          >> 56);
-		*cp++ = (uchar)(((*lp) & 0x00ff000000000000ULL) >> 48);
-		*cp++ = (uchar)(((*lp) & 0x0000ff0000000000ULL) >> 40);
-		*cp++ = (uchar)(((*lp) & 0x000000ff00000000ULL) >> 32);
-		*cp++ = (uchar)(((*lp) & 0x00000000ff000000ULL) >> 24);
-		*cp++ = (uchar)(((*lp) & 0x0000000000ff0000ULL) >> 16);
-		*cp++ = (uchar)(((*lp) & 0x000000000000ff00ULL) >>  8);
-		*cp   = (uchar)( (*lp) & 0x00000000000000ffULL);
+static int
+ncx_get_longlong_ulonglong(const void *xp, ulonglong *ip)
+{
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (ulonglong) xx;
+#if IX_LONGLONG_MAX > ULONGLONG_MAX
+	if (xx > ULONGLONG_MAX) return NC_ERANGE;
 #endif
-	}
-	*xpp = (void *)((char *)(*xpp) + sizeof_off_t);
+	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */
 	return ENOERR;
 }
 
-int
-ncx_get_off_t(const void **xpp, off_t *lp, size_t sizeof_off_t)
+static int
+ncx_get_longlong_float(const void *xp, float *ip)
 {
-	/* similar to get_ix_int() */
-	const uchar *cp = (const uchar *) *xpp;
-	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (float) xx;
 
- 	if (sizeof_off_t == 4) {
-		*lp =  (off_t)(*cp++ << 24);
-		*lp |= (off_t)(*cp++ << 16);
-		*lp |= (off_t)(*cp++ <<  8);
-		*lp |= (off_t)*cp;
-	} else {
-#if SIZEOF_OFF_T == 4
-/* Read a 64-bit offset on a system with only a 32-bit offset */
-/* If the offset overflows, set an error code and return */
-		*lp =  ((off_t)(*cp++) << 24);
-		*lp |= ((off_t)(*cp++) << 16);
-		*lp |= ((off_t)(*cp++) <<  8);
-		*lp |= ((off_t)(*cp++));
-/*
- * lp now contains the upper 32-bits of the 64-bit offset.  if lp is
- * not zero, then the dataset is larger than can be represented
- * on this system.  Set an error code and return.
- */
-		if (*lp != 0) {
-		  return ERANGE;
-		}
-
-		*lp  = ((off_t)(*cp++) << 24);
-		*lp |= ((off_t)(*cp++) << 16);
-		*lp |= ((off_t)(*cp++) <<  8);
-		*lp |=  (off_t)*cp;
-
-		if (*lp < 0) {
-		  /*
-		   * If this fails, then the offset is >2^31, but less
-		   * than 2^32 which is not allowed, but is not caught
-		   * by the previous check
-		   */
-		  return ERANGE;
-		}
-#else
-		*lp =  ((off_t)(*cp++) << 56);
-		*lp |= ((off_t)(*cp++) << 48);
-		*lp |= ((off_t)(*cp++) << 40);
-		*lp |= ((off_t)(*cp++) << 32);
-		*lp |= ((off_t)(*cp++) << 24);
-		*lp |= ((off_t)(*cp++) << 16);
-		*lp |= ((off_t)(*cp++) <<  8);
-		*lp |=  (off_t)*cp;
-#endif
-	}
-	*xpp = (const void *)((const char *)(*xpp) + sizeof_off_t);
 	return ENOERR;
 }
 
+static int
+ncx_get_longlong_double(const void *xp, double *ip)
+{
+	ix_longlong xx;
+	get_ix_longlong(xp, &xx);
+	*ip = (double) xx;
 
-/*
- * Aggregate numeric conversion functions.
- */
-#line 2632
+	return ENOERR;
+}
 
 
-#line 2639
+static int
+ncx_put_longlong_schar(void *xp, const schar *ip)
+{
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < SCHAR_MAX
+	if (*ip > IX_LONGLONG_MAX || *ip < X_LONGLONG_MIN) return NC_ERANGE;
+#endif
 
-/* schar */
+	return ENOERR;
+}
 
-#line 2643
-int
-ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
+static int
+ncx_put_longlong_short(void *xp, const short *ip)
 {
-		(void) memcpy(tp, *xpp, nelems);
-#line 2646
-	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2646
+#if SIZEOF_IX_LONGLONG == SIZEOF_SHORT && IX_LONGLONG_MAX == SHORT_MAX
+	put_ix_longlong(xp, (const ix_longlong *)ip);
 	return ENOERR;
-#line 2646
+#else
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < SHORT_MAX
+	if (*ip > IX_LONGLONG_MAX || *ip < X_LONGLONG_MIN) return NC_ERANGE;
+#endif
 
+#endif
+	return ENOERR;
 }
-#line 2649
-int
-ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
+
+static int
+ncx_put_longlong_int(void *xp, const int *ip)
 {
-		(void) memcpy(tp, *xpp, nelems);
-#line 2652
-	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2652
+#if SIZEOF_IX_LONGLONG == SIZEOF_INT && IX_LONGLONG_MAX == INT_MAX
+	put_ix_longlong(xp, (const ix_longlong *)ip);
 	return ENOERR;
-#line 2652
+#else
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < INT_MAX
+	if (*ip > IX_LONGLONG_MAX || *ip < X_LONGLONG_MIN) return NC_ERANGE;
+#endif
 
+#endif
+	return ENOERR;
 }
-int
-#line 2654
-ncx_getn_schar_short(const void **xpp, size_t nelems, short *tp)
-#line 2654
-{
-#line 2654
-	schar *xp = (schar *)(*xpp);
-#line 2654
 
-#line 2654
-	while(nelems-- != 0)
-#line 2654
-	{
-#line 2654
-		*tp++ = *xp++;
-#line 2654
-	}
-#line 2654
+static int
+ncx_put_longlong_longlong(void *xp, const longlong *ip)
+{
+#if SIZEOF_IX_LONGLONG == SIZEOF_LONGLONG && IX_LONGLONG_MAX == LONGLONG_MAX
+	put_ix_longlong(xp, (const ix_longlong *)ip);
+	return ENOERR;
+#else
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < LONGLONG_MAX
+	if (*ip > IX_LONGLONG_MAX || *ip < X_LONGLONG_MIN) return NC_ERANGE;
+#endif
 
-#line 2654
-	*xpp = (const void *)xp;
-#line 2654
+#endif
 	return ENOERR;
-#line 2654
 }
-#line 2654
 
-int
-#line 2655
-ncx_getn_schar_int(const void **xpp, size_t nelems, int *tp)
-#line 2655
+static int
+ncx_put_longlong_ushort(void *xp, const ushort *ip)
 {
-#line 2655
-	schar *xp = (schar *)(*xpp);
-#line 2655
-
-#line 2655
-	while(nelems-- != 0)
-#line 2655
-	{
-#line 2655
-		*tp++ = *xp++;
-#line 2655
-	}
-#line 2655
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < USHORT_MAX
+	if (*ip > IX_LONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2655
-	*xpp = (const void *)xp;
-#line 2655
 	return ENOERR;
-#line 2655
 }
-#line 2655
 
-int
-#line 2656
-ncx_getn_schar_float(const void **xpp, size_t nelems, float *tp)
-#line 2656
+static int
+ncx_put_longlong_uchar(void *xp, const uchar *ip)
 {
-#line 2656
-	schar *xp = (schar *)(*xpp);
-#line 2656
-
-#line 2656
-	while(nelems-- != 0)
-#line 2656
-	{
-#line 2656
-		*tp++ = *xp++;
-#line 2656
-	}
-#line 2656
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < UCHAR_MAX
+	if (*ip > IX_LONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2656
-	*xpp = (const void *)xp;
-#line 2656
 	return ENOERR;
-#line 2656
 }
-#line 2656
 
-int
-#line 2657
-ncx_getn_schar_double(const void **xpp, size_t nelems, double *tp)
-#line 2657
+static int
+ncx_put_longlong_uint(void *xp, const uint *ip)
 {
-#line 2657
-	schar *xp = (schar *)(*xpp);
-#line 2657
-
-#line 2657
-	while(nelems-- != 0)
-#line 2657
-	{
-#line 2657
-		*tp++ = *xp++;
-#line 2657
-	}
-#line 2657
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < UINT_MAX
+	if (*ip > IX_LONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2657
-	*xpp = (const void *)xp;
-#line 2657
 	return ENOERR;
-#line 2657
 }
-#line 2657
 
-int
-#line 2658
-ncx_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2658
+static int
+ncx_put_longlong_ulonglong(void *xp, const ulonglong *ip)
 {
-#line 2658
-	schar *xp = (schar *)(*xpp);
-#line 2658
-
-#line 2658
-	while(nelems-- != 0)
-#line 2658
-	{
-#line 2658
-		*tp++ = *xp++;
-#line 2658
-	}
-#line 2658
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+#if IX_LONGLONG_MAX < ULONGLONG_MAX
+	if (*ip > IX_LONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2658
-	*xpp = (const void *)xp;
-#line 2658
 	return ENOERR;
-#line 2658
 }
-#line 2658
 
-int
-#line 2659
-ncx_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2659
+static int
+ncx_put_longlong_float(void *xp, const float *ip)
 {
-#line 2659
-	schar *xp = (schar *)(*xpp);
-#line 2659
-
-#line 2659
-	while(nelems-- != 0)
-#line 2659
-	{
-#line 2659
-		*tp++ = *xp++;
-#line 2659
-	}
-#line 2659
-
-#line 2659
-	*xpp = (const void *)xp;
-#line 2659
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+	if(*ip > (double)X_LONGLONG_MAX || *ip < (double)X_LONGLONG_MIN) return NC_ERANGE;
 	return ENOERR;
-#line 2659
 }
-#line 2659
 
-int
-#line 2660
-ncx_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2660
+static int
+ncx_put_longlong_double(void *xp, const double *ip)
 {
-#line 2660
-	schar *xp = (schar *)(*xpp);
-#line 2660
-
-#line 2660
-	while(nelems-- != 0)
-#line 2660
-	{
-#line 2660
-		*tp++ = *xp++;
-#line 2660
-	}
-#line 2660
-
-#line 2660
-	*xpp = (const void *)xp;
-#line 2660
+	ix_longlong xx = (ix_longlong)*ip;
+	put_ix_longlong(xp, &xx);
+	if(*ip > X_LONGLONG_MAX || *ip < X_LONGLONG_MIN) return NC_ERANGE;
 	return ENOERR;
-#line 2660
 }
-#line 2660
 
 
-#line 2663
-int
-ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
+/* x_ulonglong --------------------------------------------------------------------*/
+
+#if USHORT_MAX == X_ULONGLONG_MAX
+typedef ushort ix_ulonglong;
+#define SIZEOF_IX_ULONGLONG SIZEOF_USHORT
+#define IX_ULONGLONG_MAX USHORT_MAX
+#elif ULONG_LONG_MAX  >= X_ULONGLONG_MAX
+typedef ulonglong ix_ulonglong;
+#define SIZEOF_IX_ULONGLONG SIZEOF_ULONGLONG
+#define IX_ULONGLONG_MAX ULONG_LONG_MAX
+#elif ULONG_MAX  >= X_ULONGLONG_MAX
+typedef ulong ix_ulonglong;
+#define SIZEOF_IX_ULONGLONG SIZEOF_ULONG
+#define IX_ULONGLONG_MAX ULONG_MAX
+#else
+#error "ix_ulonglong implementation"
+#endif
+
+
+static void
+get_ix_ulonglong(const void *xp, ix_ulonglong *ip)
 {
-		size_t rndup = nelems % X_ALIGN;
-#line 2666
+    const uchar *cp = (const uchar *) xp;
+
+    *ip  = ((unsigned long long)(*cp++) << 56);
+    *ip |= ((unsigned long long)(*cp++) << 48);
+    *ip |= ((unsigned long long)(*cp++) << 40);
+    *ip |= ((unsigned long long)(*cp++) << 32);
+    *ip |= ((unsigned long long)(*cp++) << 24);
+    *ip |= ((unsigned long long)(*cp++) << 16);
+    *ip |= ((unsigned long long)(*cp++) <<  8);
+    *ip |=  (unsigned long long)*cp;
+}
 
-#line 2666
-	if(rndup)
-#line 2666
-		rndup = X_ALIGN - rndup;
-#line 2666
+static void
+put_ix_ulonglong(void *xp, const ix_ulonglong *ip)
+{
+    uchar *cp = (uchar *) xp;
+
+    *cp++ = (*ip) >> 56;
+    *cp++ = ((*ip) & 0x00ff000000000000ULL) >> 48;
+    *cp++ = ((*ip) & 0x0000ff0000000000ULL) >> 40;
+    *cp++ = ((*ip) & 0x000000ff00000000ULL) >> 32;
+    *cp++ = ((*ip) & 0x00000000ff000000ULL) >> 24;
+    *cp++ = ((*ip) & 0x0000000000ff0000ULL) >> 16;
+    *cp++ = ((*ip) & 0x000000000000ff00ULL) >>  8;
+    *cp   = ((*ip) & 0x00000000000000ffULL);
+}
 
-#line 2666
-	(void) memcpy(tp, *xpp, nelems);
-#line 2666
-	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 2666
+static int
+ncx_get_ulonglong_schar(const void *xp, schar *ip)
+{
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (schar) xx;
+#if IX_ULONGLONG_MAX > SCHAR_MAX
+	if (xx > SCHAR_MAX) return NC_ERANGE;
+#endif
 
-#line 2666
 	return ENOERR;
-#line 2666
-
 }
-#line 2669
-int
-ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
+
+static int
+ncx_get_ulonglong_short(const void *xp, short *ip)
 {
-		size_t rndup = nelems % X_ALIGN;
-#line 2672
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (short) xx;
+#if IX_ULONGLONG_MAX > SHORT_MAX
+	if (xx > SHORT_MAX) return NC_ERANGE;
+#endif
 
-#line 2672
-	if(rndup)
-#line 2672
-		rndup = X_ALIGN - rndup;
-#line 2672
+	return ENOERR;
+}
 
-#line 2672
-	(void) memcpy(tp, *xpp, nelems);
-#line 2672
-	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 2672
+static int
+ncx_get_ulonglong_int(const void *xp, int *ip)
+{
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (int) xx;
+#if IX_ULONGLONG_MAX > INT_MAX
+	if (xx > INT_MAX) return NC_ERANGE;
+#endif
 
-#line 2672
 	return ENOERR;
-#line 2672
-
 }
-int
-#line 2674
-ncx_pad_getn_schar_short(const void **xpp, size_t nelems, short *tp)
-#line 2674
+
+static int
+ncx_get_ulonglong_longlong(const void *xp, longlong *ip)
 {
-#line 2674
-	size_t rndup = nelems % X_ALIGN;
-#line 2674
-	schar *xp = (schar *) *xpp;
-#line 2674
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (longlong) xx;
+#if IX_ULONGLONG_MAX > LONGLONG_MAX
+	if (xx > LONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2674
-	if(rndup)
-#line 2674
-		rndup = X_ALIGN - rndup;
-#line 2674
+	return ENOERR;
+}
 
-#line 2674
-	while(nelems-- != 0)
-#line 2674
-	{
-#line 2674
-		*tp++ = *xp++;
-#line 2674
-	}
-#line 2674
+static int
+ncx_get_ulonglong_ushort(const void *xp, ushort *ip)
+{
+#if SIZEOF_IX_ULONGLONG == SIZEOF_USHORT && IX_ULONGLONG_MAX == USHORT_MAX
+	get_ix_ulonglong(xp, (ix_ulonglong *)ip);
+	return ENOERR;
+#else
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (ushort) xx;
+#if IX_ULONGLONG_MAX > USHORT_MAX
+	if (xx > USHORT_MAX) return NC_ERANGE;
+#endif
 
-#line 2674
-	*xpp = (void *)(xp + rndup);
-#line 2674
+#endif
 	return ENOERR;
-#line 2674
 }
-#line 2674
 
-int
-#line 2675
-ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp)
-#line 2675
+static int
+ncx_get_ulonglong_uchar(const void *xp, uchar *ip)
 {
-#line 2675
-	size_t rndup = nelems % X_ALIGN;
-#line 2675
-	schar *xp = (schar *) *xpp;
-#line 2675
+#if SIZEOF_IX_ULONGLONG == SIZEOF_UCHAR && IX_ULONGLONG_MAX == UCHAR_MAX
+	get_ix_ulonglong(xp, (ix_ulonglong *)ip);
+	return ENOERR;
+#else
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (uchar) xx;
+#if IX_ULONGLONG_MAX > UCHAR_MAX
+	if (xx > UCHAR_MAX) return NC_ERANGE;
+#endif
 
-#line 2675
-	if(rndup)
-#line 2675
-		rndup = X_ALIGN - rndup;
-#line 2675
+#endif
+	return ENOERR;
+}
 
-#line 2675
-	while(nelems-- != 0)
-#line 2675
-	{
-#line 2675
-		*tp++ = *xp++;
-#line 2675
-	}
-#line 2675
+static int
+ncx_get_ulonglong_uint(const void *xp, uint *ip)
+{
+#if SIZEOF_IX_ULONGLONG == SIZEOF_UINT && IX_ULONGLONG_MAX == UINT_MAX
+	get_ix_ulonglong(xp, (ix_ulonglong *)ip);
+	return ENOERR;
+#else
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (uint) xx;
+#if IX_ULONGLONG_MAX > UINT_MAX
+	if (xx > UINT_MAX) return NC_ERANGE;
+#endif
 
-#line 2675
-	*xpp = (void *)(xp + rndup);
-#line 2675
+#endif
 	return ENOERR;
-#line 2675
 }
-#line 2675
 
-int
-#line 2676
-ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp)
-#line 2676
+static int
+ncx_get_ulonglong_ulonglong(const void *xp, ulonglong *ip)
 {
-#line 2676
-	size_t rndup = nelems % X_ALIGN;
-#line 2676
-	schar *xp = (schar *) *xpp;
-#line 2676
+#if SIZEOF_IX_ULONGLONG == SIZEOF_ULONGLONG && IX_ULONGLONG_MAX == ULONGLONG_MAX
+	get_ix_ulonglong(xp, (ix_ulonglong *)ip);
+	return ENOERR;
+#else
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (ulonglong) xx;
+#if IX_ULONGLONG_MAX > ULONGLONG_MAX
+	if (xx > ULONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2676
-	if(rndup)
-#line 2676
-		rndup = X_ALIGN - rndup;
-#line 2676
+#endif
+	return ENOERR;
+}
 
-#line 2676
-	while(nelems-- != 0)
-#line 2676
-	{
-#line 2676
-		*tp++ = *xp++;
-#line 2676
-	}
-#line 2676
+static int
+ncx_get_ulonglong_float(const void *xp, float *ip)
+{
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (float) xx;
 
-#line 2676
-	*xpp = (void *)(xp + rndup);
-#line 2676
 	return ENOERR;
-#line 2676
 }
-#line 2676
 
-int
-#line 2677
-ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp)
-#line 2677
+static int
+ncx_get_ulonglong_double(const void *xp, double *ip)
 {
-#line 2677
-	size_t rndup = nelems % X_ALIGN;
-#line 2677
-	schar *xp = (schar *) *xpp;
-#line 2677
+	ix_ulonglong xx;
+	get_ix_ulonglong(xp, &xx);
+	*ip = (double) xx;
 
-#line 2677
-	if(rndup)
-#line 2677
-		rndup = X_ALIGN - rndup;
-#line 2677
+	return ENOERR;
+}
 
-#line 2677
-	while(nelems-- != 0)
-#line 2677
-	{
-#line 2677
-		*tp++ = *xp++;
-#line 2677
-	}
-#line 2677
 
-#line 2677
-	*xpp = (void *)(xp + rndup);
-#line 2677
+static int
+ncx_put_ulonglong_schar(void *xp, const schar *ip)
+{
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < SCHAR_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
 	return ENOERR;
-#line 2677
 }
-#line 2677
 
-int
-#line 2678
-ncx_pad_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2678
+static int
+ncx_put_ulonglong_short(void *xp, const short *ip)
 {
-#line 2678
-	size_t rndup = nelems % X_ALIGN;
-#line 2678
-	schar *xp = (schar *) *xpp;
-#line 2678
-
-#line 2678
-	if(rndup)
-#line 2678
-		rndup = X_ALIGN - rndup;
-#line 2678
-
-#line 2678
-	while(nelems-- != 0)
-#line 2678
-	{
-#line 2678
-		*tp++ = *xp++;
-#line 2678
-	}
-#line 2678
-
-#line 2678
-	*xpp = (void *)(xp + rndup);
-#line 2678
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < SHORT_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
 	return ENOERR;
-#line 2678
 }
-#line 2678
 
-int
-#line 2679
-ncx_pad_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2679
+static int
+ncx_put_ulonglong_int(void *xp, const int *ip)
 {
-#line 2679
-	size_t rndup = nelems % X_ALIGN;
-#line 2679
-	schar *xp = (schar *) *xpp;
-#line 2679
-
-#line 2679
-	if(rndup)
-#line 2679
-		rndup = X_ALIGN - rndup;
-#line 2679
-
-#line 2679
-	while(nelems-- != 0)
-#line 2679
-	{
-#line 2679
-		*tp++ = *xp++;
-#line 2679
-	}
-#line 2679
-
-#line 2679
-	*xpp = (void *)(xp + rndup);
-#line 2679
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < INT_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
 	return ENOERR;
-#line 2679
 }
-#line 2679
 
-int
-#line 2680
-ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2680
+static int
+ncx_put_ulonglong_longlong(void *xp, const longlong *ip)
 {
-#line 2680
-	size_t rndup = nelems % X_ALIGN;
-#line 2680
-	schar *xp = (schar *) *xpp;
-#line 2680
-
-#line 2680
-	if(rndup)
-#line 2680
-		rndup = X_ALIGN - rndup;
-#line 2680
-
-#line 2680
-	while(nelems-- != 0)
-#line 2680
-	{
-#line 2680
-		*tp++ = *xp++;
-#line 2680
-	}
-#line 2680
-
-#line 2680
-	*xpp = (void *)(xp + rndup);
-#line 2680
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < LONGLONG_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
+	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */
 	return ENOERR;
-#line 2680
 }
-#line 2680
 
-
-#line 2683
-int
-ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
+static int
+ncx_put_ulonglong_uchar(void *xp, const uchar *ip)
 {
-		(void) memcpy(*xpp, tp, nelems);
-#line 2686
-	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2686
-
-#line 2686
+#if SIZEOF_IX_ULONGLONG == SIZEOF_UCHAR && IX_ULONGLONG_MAX == UCHAR_MAX
+	put_ix_ulonglong(xp, (const ix_ulonglong *)ip);
 	return ENOERR;
-#line 2686
+#else
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < UCHAR_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
 
+#endif
+	return ENOERR;
 }
-#line 2689
-int
-ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp)
-{
-		(void) memcpy(*xpp, tp, nelems);
-#line 2692
-	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2692
 
-#line 2692
+static int
+ncx_put_ulonglong_ushort(void *xp, const ushort *ip)
+{
+#if SIZEOF_IX_ULONGLONG == SIZEOF_USHORT && IX_ULONGLONG_MAX == USHORT_MAX
+	put_ix_ulonglong(xp, (const ix_ulonglong *)ip);
 	return ENOERR;
-#line 2692
+#else
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < USHORT_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
 
+#endif
+	return ENOERR;
 }
-int
-#line 2694
-ncx_putn_schar_short(void **xpp, size_t nelems, const short *tp)
-#line 2694
-{
-#line 2694
-	int status = ENOERR;
-#line 2694
-	schar *xp = (schar *) *xpp;
-#line 2694
 
-#line 2694
-	while(nelems-- != 0)
-#line 2694
-	{
-#line 2694
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2694
-			status = NC_ERANGE;
-#line 2694
-		*xp++ = (schar) *tp++;
-#line 2694
-	}
-#line 2694
+static int
+ncx_put_ulonglong_uint(void *xp, const uint *ip)
+{
+#if SIZEOF_IX_ULONGLONG == SIZEOF_UINT && IX_ULONGLONG_MAX == UINT_MAX
+	put_ix_ulonglong(xp, (const ix_ulonglong *)ip);
+	return ENOERR;
+#else
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < UINT_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2694
-	*xpp = (void *)xp;
-#line 2694
-	return status;
-#line 2694
+#endif
+	return ENOERR;
 }
-#line 2694
 
-int
-#line 2695
-ncx_putn_schar_int(void **xpp, size_t nelems, const int *tp)
-#line 2695
+static int
+ncx_put_ulonglong_ulonglong(void *xp, const ulonglong *ip)
 {
-#line 2695
-	int status = ENOERR;
-#line 2695
-	schar *xp = (schar *) *xpp;
-#line 2695
-
-#line 2695
-	while(nelems-- != 0)
-#line 2695
-	{
-#line 2695
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2695
-			status = NC_ERANGE;
-#line 2695
-		*xp++ = (schar) *tp++;
-#line 2695
-	}
-#line 2695
+#if SIZEOF_IX_ULONGLONG == SIZEOF_ULONGLONG && IX_ULONGLONG_MAX == ULONGLONG_MAX
+	put_ix_ulonglong(xp, (const ix_ulonglong *)ip);
+	return ENOERR;
+#else
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+#if IX_ULONGLONG_MAX < ULONGLONG_MAX
+	if (*ip > IX_ULONGLONG_MAX) return NC_ERANGE;
+#endif
 
-#line 2695
-	*xpp = (void *)xp;
-#line 2695
-	return status;
-#line 2695
+#endif
+	return ENOERR;
 }
-#line 2695
 
-int
-#line 2696
-ncx_putn_schar_float(void **xpp, size_t nelems, const float *tp)
-#line 2696
+static int
+ncx_put_ulonglong_float(void *xp, const float *ip)
 {
-#line 2696
-	int status = ENOERR;
-#line 2696
-	schar *xp = (schar *) *xpp;
-#line 2696
-
-#line 2696
-	while(nelems-- != 0)
-#line 2696
-	{
-#line 2696
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2696
-			status = NC_ERANGE;
-#line 2696
-		*xp++ = (schar) *tp++;
-#line 2696
-	}
-#line 2696
-
-#line 2696
-	*xpp = (void *)xp;
-#line 2696
-	return status;
-#line 2696
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+	if(*ip > (double)X_ULONGLONG_MAX || *ip < 0) return NC_ERANGE;
+	return ENOERR;
 }
-#line 2696
 
-int
-#line 2697
-ncx_putn_schar_double(void **xpp, size_t nelems, const double *tp)
-#line 2697
+static int
+ncx_put_ulonglong_double(void *xp, const double *ip)
 {
-#line 2697
-	int status = ENOERR;
-#line 2697
-	schar *xp = (schar *) *xpp;
-#line 2697
-
-#line 2697
-	while(nelems-- != 0)
-#line 2697
-	{
-#line 2697
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2697
-			status = NC_ERANGE;
-#line 2697
-		*xp++ = (schar) *tp++;
-#line 2697
-	}
-#line 2697
-
-#line 2697
-	*xpp = (void *)xp;
-#line 2697
-	return status;
-#line 2697
+	ix_ulonglong xx = (ix_ulonglong)*ip;
+	put_ix_ulonglong(xp, &xx);
+	if(*ip > X_ULONGLONG_MAX || *ip < 0) return NC_ERANGE;
+	return ENOERR;
 }
-#line 2697
 
-int
-#line 2698
-ncx_putn_schar_uint(void **xpp, size_t nelems, const uint *tp)
-#line 2698
-{
-#line 2698
-	int status = ENOERR;
-#line 2698
-	schar *xp = (schar *) *xpp;
-#line 2698
 
-#line 2698
-	while(nelems-- != 0)
-#line 2698
-	{
-#line 2698
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2698
-			status = NC_ERANGE;
-#line 2698
-		*xp++ = (schar) *tp++;
-#line 2698
-	}
-#line 2698
+/* x_size_t */
 
-#line 2698
-	*xpp = (void *)xp;
-#line 2698
-	return status;
-#line 2698
-}
-#line 2698
+#if SIZEOF_SIZE_T < X_SIZEOF_SIZE_T
+#error "x_size_t implementation"
+/* netcdf requires size_t which can hold a values from 0 to 2^32 -1 */
+#endif
 
 int
-#line 2699
-ncx_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 2699
+ncx_put_size_t(void **xpp, const size_t *ulp)
 {
-#line 2699
-	int status = ENOERR;
-#line 2699
-	schar *xp = (schar *) *xpp;
-#line 2699
+	/* similar to put_ix_int() */
+	uchar *cp = (uchar *) *xpp;
+	assert(*ulp <= X_SIZE_MAX);
 
-#line 2699
-	while(nelems-- != 0)
-#line 2699
-	{
-#line 2699
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2699
-			status = NC_ERANGE;
-#line 2699
-		*xp++ = (schar) *tp++;
-#line 2699
-	}
-#line 2699
+	*cp++ = (uchar)((*ulp) >> 24);
+	*cp++ = (uchar)(((*ulp) & 0x00ff0000) >> 16);
+	*cp++ = (uchar)(((*ulp) & 0x0000ff00) >>  8);
+	*cp   = (uchar)((*ulp) & 0x000000ff);
 
-#line 2699
-	*xpp = (void *)xp;
-#line 2699
-	return status;
-#line 2699
+	*xpp = (void *)((char *)(*xpp) + X_SIZEOF_SIZE_T);
+	return ENOERR;
 }
-#line 2699
 
 int
-#line 2700
-ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 2700
+ncx_get_size_t(const void **xpp,  size_t *ulp)
 {
-#line 2700
-	int status = ENOERR;
-#line 2700
-	schar *xp = (schar *) *xpp;
-#line 2700
+	/* similar to get_ix_int */
+	const uchar *cp = (const uchar *) *xpp;
 
-#line 2700
-	while(nelems-- != 0)
-#line 2700
-	{
-#line 2700
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2700
-			status = NC_ERANGE;
-#line 2700
-		*xp++ = (schar) *tp++;
-#line 2700
-	}
-#line 2700
+	*ulp = (unsigned)(*cp++ << 24);
+	*ulp |= (*cp++ << 16);
+	*ulp |= (*cp++ << 8);
+	*ulp |= *cp;
 
-#line 2700
-	*xpp = (void *)xp;
-#line 2700
-	return status;
-#line 2700
+	*xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_SIZE_T);
+	return ENOERR;
 }
-#line 2700
 
+/* x_off_t */
 
-#line 2703
 int
-ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
+ncx_put_off_t(void **xpp, const off_t *lp, size_t sizeof_off_t)
 {
-		size_t rndup = nelems % X_ALIGN;
-#line 2706
+	/* similar to put_ix_int() */
+	uchar *cp = (uchar *) *xpp;
+		/* No negative offsets stored in netcdf */
+	if (*lp < 0) {
+	  /* Assume this is an overflow of a 32-bit int... */
+	  return NC_ERANGE;
+	}
 
-#line 2706
-	if(rndup)
-#line 2706
-		rndup = X_ALIGN - rndup;
-#line 2706
+	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
 
-#line 2706
-	(void) memcpy(*xpp, tp, nelems);
-#line 2706
-	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2706
+	if (sizeof_off_t == 4) {
+		*cp++ = (uchar) ((*lp)               >> 24);
+		*cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
+		*cp++ = (uchar)(((*lp) & 0x0000ff00) >>  8);
+		*cp   = (uchar)( (*lp) & 0x000000ff);
+	} else {
+#if SIZEOF_OFF_T == 4
+/* Write a 64-bit offset on a system with only a 32-bit offset */
+		*cp++ = (uchar)0;
+		*cp++ = (uchar)0;
+		*cp++ = (uchar)0;
+		*cp++ = (uchar)0;
 
-#line 2706
-	if(rndup)
-#line 2706
-	{
-#line 2706
-		(void) memcpy(*xpp, nada, rndup);
-#line 2706
-		*xpp = (void *)((char *)(*xpp) + rndup);
-#line 2706
+		*cp++ = (uchar)(((*lp) & 0xff000000) >> 24);
+		*cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
+		*cp++ = (uchar)(((*lp) & 0x0000ff00) >>  8);
+		*cp   = (uchar)( (*lp) & 0x000000ff);
+#else
+		*cp++ = (uchar) ((*lp)                          >> 56);
+		*cp++ = (uchar)(((*lp) & 0x00ff000000000000ULL) >> 48);
+		*cp++ = (uchar)(((*lp) & 0x0000ff0000000000ULL) >> 40);
+		*cp++ = (uchar)(((*lp) & 0x000000ff00000000ULL) >> 32);
+		*cp++ = (uchar)(((*lp) & 0x00000000ff000000ULL) >> 24);
+		*cp++ = (uchar)(((*lp) & 0x0000000000ff0000ULL) >> 16);
+		*cp++ = (uchar)(((*lp) & 0x000000000000ff00ULL) >>  8);
+		*cp   = (uchar)( (*lp) & 0x00000000000000ffULL);
+#endif
 	}
-#line 2706
-
-#line 2706
+	*xpp = (void *)((char *)(*xpp) + sizeof_off_t);
 	return ENOERR;
-#line 2706
-
 }
-#line 2709
+
 int
-ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp)
+ncx_get_off_t(const void **xpp, off_t *lp, size_t sizeof_off_t)
 {
-		size_t rndup = nelems % X_ALIGN;
-#line 2712
-
-#line 2712
-	if(rndup)
-#line 2712
-		rndup = X_ALIGN - rndup;
-#line 2712
-
-#line 2712
-	(void) memcpy(*xpp, tp, nelems);
-#line 2712
-	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 2712
+	/* similar to get_ix_int() */
+	const uchar *cp = (const uchar *) *xpp;
+	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
 
-#line 2712
-	if(rndup)
-#line 2712
-	{
-#line 2712
-		(void) memcpy(*xpp, nada, rndup);
-#line 2712
-		*xpp = (void *)((char *)(*xpp) + rndup);
-#line 2712
+ 	if (sizeof_off_t == 4) {
+		*lp =  (off_t)(*cp++ << 24);
+		*lp |= (off_t)(*cp++ << 16);
+		*lp |= (off_t)(*cp++ <<  8);
+		*lp |= (off_t)*cp;
+	} else {
+#if SIZEOF_OFF_T == 4
+/* Read a 64-bit offset on a system with only a 32-bit offset */
+/* If the offset overflows, set an error code and return */
+		*lp =  ((off_t)(*cp++) << 24);
+		*lp |= ((off_t)(*cp++) << 16);
+		*lp |= ((off_t)(*cp++) <<  8);
+		*lp |= ((off_t)(*cp++));
+/*
+ * lp now contains the upper 32-bits of the 64-bit offset.  if lp is
+ * not zero, then the dataset is larger than can be represented
+ * on this system.  Set an error code and return.
+ */
+		if (*lp != 0) {
+		  return NC_ERANGE;
+		}
+
+		*lp  = ((off_t)(*cp++) << 24);
+		*lp |= ((off_t)(*cp++) << 16);
+		*lp |= ((off_t)(*cp++) <<  8);
+		*lp |=  (off_t)*cp;
+
+		if (*lp < 0) {
+		  /*
+		   * If this fails, then the offset is >2^31, but less
+		   * than 2^32 which is not allowed, but is not caught
+		   * by the previous check
+		   */
+		  return NC_ERANGE;
+		}
+#else
+		*lp =  ((off_t)(*cp++) << 56);
+		*lp |= ((off_t)(*cp++) << 48);
+		*lp |= ((off_t)(*cp++) << 40);
+		*lp |= ((off_t)(*cp++) << 32);
+		*lp |= ((off_t)(*cp++) << 24);
+		*lp |= ((off_t)(*cp++) << 16);
+		*lp |= ((off_t)(*cp++) <<  8);
+		*lp |=  (off_t)*cp;
+#endif
 	}
-#line 2712
+	*xpp = (const void *)((const char *)(*xpp) + sizeof_off_t);
+	return ENOERR;
+}
+
+/*----< ncx_get_int32() >--------------------------------------------------*/
+int
+ncx_get_int32(const void **xpp,
+              int         *ip)
+{
+    const uchar *cp = (const uchar *) *xpp;
+
+    /* cannot call swap4b(), as lp is 8-byte */
+    *ip  = (*cp++ << 24);
+    *ip |= (*cp++ << 16);
+    *ip |= (*cp++ <<  8);
+    *ip |=  *cp;
+
+    /* advance *xpp 4 bytes */
+    *xpp = (void *)((const char *)(*xpp) + 4);
+
+    return NC_NOERR;
+}
+
+/*----< ncx_get_int64() >-------------------------------------------------*/
+int
+ncx_get_int64(const void **xpp,
+              long long   *llp)
+{
+    const uchar *cp = (const uchar *) *xpp;
+
+    /* below is the same as calling swap8b(llp, *xpp) */
+    *llp  = ((long long)(*cp++) << 56);
+    *llp |= ((long long)(*cp++) << 48);
+    *llp |= ((long long)(*cp++) << 40);
+    *llp |= ((long long)(*cp++) << 32);
+    *llp |= ((long long)(*cp++) << 24);
+    *llp |= ((long long)(*cp++) << 16);
+    *llp |= ((long long)(*cp++) <<  8);
+    *llp |=  (long long)*cp;
+
+    /* advance *xpp 8 bytes */
+    *xpp = (void *)((const char *)(*xpp) + 8);
+
+    return NC_NOERR;
+}
+
+/*---< ncx_put_int32() >-----------------------------------------------------*/
+/* copy the contents of lp (a signed 32-bit integer) to xpp in Big Endian
+ * form and advance *xpp 4 bytes
+ */
+int
+ncx_put_int32(void      **xpp,
+              const int   ip)
+{
+#ifdef WORDS_BIGENDIAN
+    int *ptr = (int*) (*xpp); /* typecast to 4-byte integer */
+    *ptr = ip;
+#else
+    /* bitwise shifts below are to produce an integer in Big Endian */
+    /* cannot call swap4b(), as lp is 8-byte */
+    uchar *cp = (uchar *) *xpp;
+    *cp++ = (uchar)((ip & 0xff000000) >> 24);
+    *cp++ = (uchar)((ip & 0x00ff0000) >> 16);
+    *cp++ = (uchar)((ip & 0x0000ff00) >>  8);
+    *cp   = (uchar)( ip & 0x000000ff);
+#endif
+    /* advance *xpp 4 bytes */
+    *xpp  = (void *)((char *)(*xpp) + 4);
 
-#line 2712
+    return NC_NOERR;
+}
+
+/*---< ncx_put_int64() >-----------------------------------------------------*/
+/* copy the contents of lp (a signed 64-bit integer) to xpp in Big Endian
+ * form and advance *xpp 8 bytes
+ */
+int
+ncx_put_int64(void             **xpp,
+              const long long    ip)
+{
+#ifdef WORDS_BIGENDIAN
+    long long *ptr = (long long*) (*xpp); /* typecast to 8-byte integer */
+    *ptr = ip;
+#else
+    uchar *cp = (uchar *) *xpp;
+    /* below is the same as calling swap8b(*xpp, &ip) */
+    *cp++ = (uchar)((ip & 0xff00000000000000ULL) >> 56);
+    *cp++ = (uchar)((ip & 0x00ff000000000000ULL) >> 48);
+    *cp++ = (uchar)((ip & 0x0000ff0000000000ULL) >> 40);
+    *cp++ = (uchar)((ip & 0x000000ff00000000ULL) >> 32);
+    *cp++ = (uchar)((ip & 0x00000000ff000000ULL) >> 24);
+    *cp++ = (uchar)((ip & 0x0000000000ff0000ULL) >> 16);
+    *cp++ = (uchar)((ip & 0x000000000000ff00ULL) >>  8);
+    *cp   = (uchar)( ip & 0x00000000000000ffULL);
+#endif
+    /* advance *xpp 8 bytes */
+    *xpp  = (void *)((char *)(*xpp) + 8);
+
+    return NC_NOERR;
+}
+
+
+/*
+ * Aggregate numeric conversion functions.
+ */
+
+
+
+/* schar ---------------------------------------------------------------------*/
+
+int
+ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
+{
+		(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
 	return ENOERR;
-#line 2712
 
 }
 int
-#line 2714
-ncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *tp)
-#line 2714
+ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
-#line 2714
-	int status = ENOERR;
-#line 2714
-	size_t rndup = nelems % X_ALIGN;
-#line 2714
-	schar *xp = (schar *) *xpp;
-#line 2714
+		(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+	return ENOERR;
 
-#line 2714
-	if(rndup)
-#line 2714
-		rndup = X_ALIGN - rndup;
-#line 2714
+}
+int
+ncx_getn_schar_short(const void **xpp, size_t nelems, short *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *)(*xpp);
 
-#line 2714
 	while(nelems-- != 0)
-#line 2714
 	{
-#line 2714
-		/* N.B. schar as signed */
-#line 2714
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2714
-			status = NC_ERANGE;
-#line 2714
-		*xp++ = (schar) *tp++;
-#line 2714
+
+		*tp++ = *xp++;
 	}
-#line 2714
 
-#line 2714
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_schar_int(const void **xpp, size_t nelems, int *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *)(*xpp);
 
-#line 2714
-	if(rndup)
-#line 2714
+	while(nelems-- != 0)
 	{
-#line 2714
-		(void) memcpy(xp, nada, rndup);
-#line 2714
-		xp += rndup;
-#line 2714
+
+		*tp++ = *xp++;
 	}
-#line 2714
 
-#line 2714
-	*xpp = (void *)xp;
-#line 2714
+	*xpp = (const void *)xp;
 	return status;
-#line 2714
 }
-#line 2714
 
 int
-#line 2715
-ncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *tp)
-#line 2715
+ncx_getn_schar_float(const void **xpp, size_t nelems, float *tp)
 {
-#line 2715
 	int status = ENOERR;
-#line 2715
-	size_t rndup = nelems % X_ALIGN;
-#line 2715
-	schar *xp = (schar *) *xpp;
-#line 2715
+	schar *xp = (schar *)(*xpp);
 
-#line 2715
-	if(rndup)
-#line 2715
-		rndup = X_ALIGN - rndup;
-#line 2715
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_schar_double(const void **xpp, size_t nelems, double *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *)(*xpp);
 
-#line 2715
 	while(nelems-- != 0)
-#line 2715
 	{
-#line 2715
-		/* N.B. schar as signed */
-#line 2715
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2715
-			status = NC_ERANGE;
-#line 2715
-		*xp++ = (schar) *tp++;
-#line 2715
+
+		*tp++ = *xp++;
 	}
-#line 2715
 
-#line 2715
+	*xpp = (const void *)xp;
+	return status;
+}
 
-#line 2715
-	if(rndup)
-#line 2715
+int
+ncx_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *)(*xpp);
+
+	while(nelems-- != 0)
 	{
-#line 2715
-		(void) memcpy(xp, nada, rndup);
-#line 2715
-		xp += rndup;
-#line 2715
+
+		*tp++ = *xp++;
 	}
-#line 2715
 
-#line 2715
-	*xpp = (void *)xp;
-#line 2715
+	*xpp = (const void *)xp;
 	return status;
-#line 2715
 }
-#line 2715
 
 int
-#line 2716
-ncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *tp)
-#line 2716
+ncx_getn_schar_ushort(const void **xpp, size_t nelems, ushort *tp)
 {
-#line 2716
 	int status = ENOERR;
-#line 2716
-	size_t rndup = nelems % X_ALIGN;
-#line 2716
-	schar *xp = (schar *) *xpp;
-#line 2716
+	schar *xp = (schar *)(*xpp);
 
-#line 2716
-	if(rndup)
-#line 2716
-		rndup = X_ALIGN - rndup;
-#line 2716
+	while(nelems-- != 0)
+	{
+		if (*xp < 0) status = NC_ERANGE;
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *)(*xpp);
 
-#line 2716
 	while(nelems-- != 0)
-#line 2716
 	{
-#line 2716
-		/* N.B. schar as signed */
-#line 2716
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2716
-			status = NC_ERANGE;
-#line 2716
-		*xp++ = (schar) *tp++;
-#line 2716
+		if (*xp < 0) status = NC_ERANGE;
+		*tp++ = *xp++;
 	}
-#line 2716
 
-#line 2716
+	*xpp = (const void *)xp;
+	return status;
+}
 
-#line 2716
-	if(rndup)
-#line 2716
+int
+ncx_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *)(*xpp);
+
+	while(nelems-- != 0)
 	{
-#line 2716
-		(void) memcpy(xp, nada, rndup);
-#line 2716
-		xp += rndup;
-#line 2716
+		if (*xp < 0) status = NC_ERANGE;
+		*tp++ = *xp++;
 	}
-#line 2716
 
-#line 2716
-	*xpp = (void *)xp;
-#line 2716
+	*xpp = (const void *)xp;
 	return status;
-#line 2716
 }
-#line 2716
+
 
 int
-#line 2717
-ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *tp)
-#line 2717
+ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
+
+	return ENOERR;
+
+}
+int
+ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
+
+	return ENOERR;
+
+}
+int
+ncx_pad_getn_schar_short(const void **xpp, size_t nelems, short *tp)
 {
-#line 2717
 	int status = ENOERR;
-#line 2717
 	size_t rndup = nelems % X_ALIGN;
-#line 2717
 	schar *xp = (schar *) *xpp;
-#line 2717
 
-#line 2717
 	if(rndup)
-#line 2717
 		rndup = X_ALIGN - rndup;
-#line 2717
 
-#line 2717
 	while(nelems-- != 0)
-#line 2717
 	{
-#line 2717
-		/* N.B. schar as signed */
-#line 2717
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2717
-			status = NC_ERANGE;
-#line 2717
-		*xp++ = (schar) *tp++;
-#line 2717
+
+		*tp++ = *xp++;
 	}
-#line 2717
 
-#line 2717
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if (*xp < 0) status = NC_ERANGE;
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_uint(const void **xpp, size_t nelems, uint *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if (*xp < 0) status = NC_ERANGE;
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if (*xp < 0) status = NC_ERANGE;
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+
+int
+ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
+{
+		(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	return ENOERR;
+
+}
+int
+ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+		(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	return ENOERR;
+
+}
+int
+ncx_putn_schar_short(void **xpp, size_t nelems, const short *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_int(void **xpp, size_t nelems, const int *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_float(void **xpp, size_t nelems, const float *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_double(void **xpp, size_t nelems, const double *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_uint(void **xpp, size_t nelems, const uint *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+	int status = ENOERR;
+	schar *xp = (schar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+int
+ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	if(rndup)
+	{
+		(void) memcpy(*xpp, nada, rndup);
+		*xpp = (void *)((char *)(*xpp) + rndup);
+	}
+
+	return ENOERR;
+
+}
+int
+ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	if(rndup)
+	{
+		(void) memcpy(*xpp, nada, rndup);
+		*xpp = (void *)((char *)(*xpp) + rndup);
+	}
+
+	return ENOERR;
+
+}
+int
+ncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_uint(void **xpp, size_t nelems, const uint *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	schar *xp = (schar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_SCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (schar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+
+/* uchar ---------------------------------------------------------------------*/
+int
+ncx_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
+{
+		(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+	return ENOERR;
+
+}
+int
+ncx_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+		(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+	return ENOERR;
+
+}
+int
+ncx_getn_uchar_short(const void **xpp, size_t nelems, short *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_int(const void **xpp, size_t nelems, int *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_float(const void **xpp, size_t nelems, float *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_double(const void **xpp, size_t nelems, double *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_uint(const void **xpp, size_t nelems, uint *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+int
+ncx_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *)(*xpp);
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+}
+
+
+int
+ncx_pad_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
+
+	return ENOERR;
+
+}
+int
+ncx_pad_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(tp, *xpp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
+
+	return ENOERR;
+
+}
+int
+ncx_pad_getn_uchar_short(const void **xpp, size_t nelems, short *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_int(const void **xpp, size_t nelems, int *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_float(const void **xpp, size_t nelems, float *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_double(const void **xpp, size_t nelems, double *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_uint(const void **xpp, size_t nelems, uint *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+int
+ncx_pad_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+
+		*tp++ = *xp++;
+	}
+
+	*xpp = (void *)(xp + rndup);
+	return status;
+}
+
+
+int
+ncx_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp)
+{
+		(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	return ENOERR;
+
+}
+int
+ncx_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+		(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	return ENOERR;
+
+}
+int
+ncx_putn_uchar_short(void **xpp, size_t nelems, const short *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_int(void **xpp, size_t nelems, const int *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_float(void **xpp, size_t nelems, const float *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_double(void **xpp, size_t nelems, const double *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_uint(void **xpp, size_t nelems, const uint *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+	int status = ENOERR;
+	uchar *xp = (uchar *) *xpp;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+int
+ncx_pad_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	if(rndup)
+	{
+		(void) memcpy(*xpp, nada, rndup);
+		*xpp = (void *)((char *)(*xpp) + rndup);
+	}
+
+	return ENOERR;
+
+}
+int
+ncx_pad_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+		size_t rndup = nelems % X_ALIGN;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	(void) memcpy(*xpp, tp, nelems);
+	*xpp = (void *)((char *)(*xpp) + nelems);
+
+	if(rndup)
+	{
+		(void) memcpy(*xpp, nada, rndup);
+		*xpp = (void *)((char *)(*xpp) + rndup);
+	}
+
+	return ENOERR;
+
+}
+int
+ncx_pad_putn_uchar_short(void **xpp, size_t nelems, const short *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_int(void **xpp, size_t nelems, const int *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_float(void **xpp, size_t nelems, const float *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_double(void **xpp, size_t nelems, const double *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX || *tp < 0)
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_uint(void **xpp, size_t nelems, const uint *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+	int status = ENOERR;
+	size_t rndup = nelems % X_ALIGN;
+	uchar *xp = (uchar *) *xpp;
+
+	if(rndup)
+		rndup = X_ALIGN - rndup;
+
+	while(nelems-- != 0)
+	{
+		if(*tp > X_UCHAR_MAX )
+			status = NC_ERANGE;
+		*xp++ = (uchar) *tp++;
+	}
+
+
+	if(rndup)
+	{
+		(void) memcpy(xp, nada, rndup);
+		xp += rndup;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+/* short ---------------------------------------------------------------------*/
+
+#if X_SIZEOF_SHORT == SIZEOF_SHORT
+/* optimized version */
+int
+ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(short));
+# else
+	swapn2b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_SHORT);
+	return ENOERR;
+}
+#else
+int
+ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+#endif
+int
+ncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_int(const void **xpp, size_t nelems, int *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_float(const void **xpp, size_t nelems, float *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_double(const void **xpp, size_t nelems, double *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (short *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+
+int
+ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_short(const void **xpp, size_t nelems, short *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_int(const void **xpp, size_t nelems, int *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_float(const void **xpp, size_t nelems, float *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_short_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		const int lstatus = ncx_get_short_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_SHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+#if X_SIZEOF_SHORT == SIZEOF_SHORT
+/* optimized version */
+int
+ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_SHORT);
+# else
+	swapn2b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_SHORT);
+	return ENOERR;
+}
+#else
+int
+ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+#endif
+int
+ncx_putn_short_schar(void **xpp, size_t nelems, const schar *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_int(void **xpp, size_t nelems, const int *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_float(void **xpp, size_t nelems, const float *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_double(void **xpp, size_t nelems, const double *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX || tp[i] < X_SHORT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_uint(void **xpp, size_t nelems, const uint *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_short_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  short tmp[LOOPCNT];        /* in case input is misaligned */
+  short *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_SHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (short *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_SHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
+      xp = (short *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+
+int
+ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_short(void **xpp, size_t nelems, const short *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_float(void **xpp, size_t nelems, const float *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_uint(void **xpp, size_t nelems, const uint *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_short_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	{
+		int lstatus = ncx_put_short_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
+		xp += X_SIZEOF_SHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+
+/* ushort --------------------------------------------------------------------*/
+
+#if X_SIZEOF_USHORT == SIZEOF_USHORT
+/* optimized version */
+int
+ncx_getn_ushort_ushort(const void **xpp, size_t nelems, unsigned short *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(unsigned short));
+# else
+	swapn2b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_USHORT);
+	return ENOERR;
+}
+#else
+int
+ncx_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+#endif
+int
+ncx_getn_ushort_schar(const void **xpp, size_t nelems, schar *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_short(const void **xpp, size_t nelems, short *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_int(const void **xpp, size_t nelems, int *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_float(const void **xpp, size_t nelems, float *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_double(const void **xpp, size_t nelems, double *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_uint(const void **xpp, size_t nelems, uint *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_USHORT);
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (ushort *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+
+int
+ncx_pad_getn_ushort_schar(const void **xpp, size_t nelems, schar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_short(const void **xpp, size_t nelems, short *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_int(const void **xpp, size_t nelems, int *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_uint(const void **xpp, size_t nelems, uint *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_float(const void **xpp, size_t nelems, float *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_double(const void **xpp, size_t nelems, double *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		const int lstatus = ncx_get_ushort_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+		xp += X_SIZEOF_USHORT;
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+#if X_SIZEOF_USHORT == SIZEOF_USHORT
+/* optimized version */
+int
+ncx_putn_ushort_ushort(void **xpp, size_t nelems, const unsigned short *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_USHORT);
+# else
+	swapn2b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_USHORT);
+	return ENOERR;
+}
+#else
+int
+ncx_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+#endif
+int
+ncx_putn_ushort_schar(void **xpp, size_t nelems, const schar *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_short(void **xpp, size_t nelems, const short *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_int(void **xpp, size_t nelems, const int *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_float(void **xpp, size_t nelems, const float *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_double(void **xpp, size_t nelems, const double *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_uint(void **xpp, size_t nelems, const uint *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+#if _SX && X_SIZEOF_USHORT == SIZEOF_USHORT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ushort tmp[LOOPCNT];        /* in case input is misaligned */
+  ushort *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_USHORT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ushort *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ushort) Max( X_USHORT_MIN, Min(X_USHORT_MAX, (ushort) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_USHORT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_USHORT);
+      xp = (ushort *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+
+int
+ncx_pad_putn_ushort_schar(void **xpp, size_t nelems, const schar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_short(void **xpp, size_t nelems, const short *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_int(void **xpp, size_t nelems, const int *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_float(void **xpp, size_t nelems, const float *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_double(void **xpp, size_t nelems, const double *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_uint(void **xpp, size_t nelems, const uint *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+int
+ncx_pad_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+	const size_t rndup = nelems % 2;
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_USHORT, tp++)
+	{
+		int lstatus = ncx_put_ushort_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	if(rndup != 0)
+	{
+		(void) memcpy(xp, nada, X_SIZEOF_USHORT);
+		xp += X_SIZEOF_USHORT;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+
+
+
+/* int -----------------------------------------------------------------------*/
+
+#if X_SIZEOF_INT == SIZEOF_INT
+/* optimized version */
+int
+ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(int));
+# else
+	swapn4b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
+	return ENOERR;
+}
+#else
+int
+ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+#endif
+int
+ncx_getn_int_schar(const void **xpp, size_t nelems, schar *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_short(const void **xpp, size_t nelems, short *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_float(const void **xpp, size_t nelems, float *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_double(const void **xpp, size_t nelems, double *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_uint(const void **xpp, size_t nelems, uint *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_INT);
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (int *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		const int lstatus = ncx_get_int_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+
+#if X_SIZEOF_INT == SIZEOF_INT
+/* optimized version */
+int
+ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_INT);
+# else
+	swapn4b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
+	return ENOERR;
+}
+#else
+int
+ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+#endif
+int
+ncx_putn_int_schar(void **xpp, size_t nelems, const schar *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_short(void **xpp, size_t nelems, const short *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_float(void **xpp, size_t nelems, const float *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  double d;               /* special case for ncx_putn_int_float */
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* for some reason int to float, for putn, requires a special case */
+      d = tp[i];
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) d));
+      nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_double(void **xpp, size_t nelems, const double *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX || tp[i] < X_INT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_uint(void **xpp, size_t nelems, const uint *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+#if _SX && X_SIZEOF_INT == SIZEOF_INT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  int tmp[LOOPCNT];        /* in case input is misaligned */
+  int *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_INT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (int *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_INT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
+      xp = (int *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
+	{
+		int lstatus = ncx_put_int_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+
+/* uint ----------------------------------------------------------------------*/
+
+#if X_SIZEOF_UINT == SIZEOF_UINT
+/* optimized version */
+int
+ncx_getn_uint_uint(const void **xpp, size_t nelems, unsigned int *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(uint));
+# else
+	swapn4b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_UINT);
+	return ENOERR;
+}
+#else
+int
+ncx_getn_uint_uint(const void **xpp, size_t nelems, uint *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+#endif
+int
+ncx_getn_uint_schar(const void **xpp, size_t nelems, schar *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_short(const void **xpp, size_t nelems, short *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_int(const void **xpp, size_t nelems, int *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_float(const void **xpp, size_t nelems, float *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_double(const void **xpp, size_t nelems, double *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_longlong(const void **xpp, size_t nelems, longlong *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_ushort(const void **xpp, size_t nelems, ushort *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+int
+ncx_getn_uint_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_UINT);
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX ;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (uint *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		const int lstatus = ncx_get_uint_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (const void *)xp;
+	return status;
+#  endif
+}
+
+
+#if X_SIZEOF_UINT == SIZEOF_UINT
+/* optimized version */
+int
+ncx_putn_uint_uint(void **xpp, size_t nelems, const unsigned int *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_UINT);
+# else
+	swapn4b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_UINT);
+	return ENOERR;
+}
+#else
+int
+ncx_putn_uint_uint(void **xpp, size_t nelems, const uint *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_uint(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+#endif
+int
+ncx_putn_uint_schar(void **xpp, size_t nelems, const schar *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_short(void **xpp, size_t nelems, const short *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_int(void **xpp, size_t nelems, const int *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_int(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_float(void **xpp, size_t nelems, const float *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_double(void **xpp, size_t nelems, const double *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX || tp[i] < 0;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_longlong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_uchar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_ushort(void **xpp, size_t nelems, const ushort *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
+	{
+		int lstatus = ncx_put_uint_ushort(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+int
+ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
+{
+#if _SX && X_SIZEOF_UINT == SIZEOF_UINT
+
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  uint tmp[LOOPCNT];        /* in case input is misaligned */
+  uint *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_UINT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (uint *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (uint) Max( X_UINT_MIN, Min(X_UINT_MAX, (uint) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_UINT_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_UINT);
+      xp = (uint *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
 
-#line 2717
-	if(rndup)
-#line 2717
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_UINT, tp++)
 	{
-#line 2717
-		(void) memcpy(xp, nada, rndup);
-#line 2717
-		xp += rndup;
-#line 2717
+		int lstatus = ncx_put_uint_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
 	}
-#line 2717
 
-#line 2717
 	*xpp = (void *)xp;
-#line 2717
 	return status;
-#line 2717
+#endif
 }
-#line 2717
 
+
+
+/* float ---------------------------------------------------------------------*/
+
+#if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
+/* optimized version */
 int
-#line 2718
-ncx_pad_putn_schar_uint(void **xpp, size_t nelems, const uint *tp)
-#line 2718
+ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
 {
-#line 2718
-	int status = ENOERR;
-#line 2718
-	size_t rndup = nelems % X_ALIGN;
-#line 2718
-	schar *xp = (schar *) *xpp;
-#line 2718
-
-#line 2718
-	if(rndup)
-#line 2718
-		rndup = X_ALIGN - rndup;
-#line 2718
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(float));
+# else
+	swapn4b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_FLOAT);
+	return ENOERR;
+}
+#elif vax
+int
+ncx_getn_float_float(const void **xpp, size_t nfloats, float *ip)
+{
+	float *const end = ip + nfloats;
 
-#line 2718
-	while(nelems-- != 0)
-#line 2718
+	while(ip < end)
 	{
-#line 2718
-		/* N.B. schar as signed */
-#line 2718
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2718
-			status = NC_ERANGE;
-#line 2718
-		*xp++ = (schar) *tp++;
-#line 2718
-	}
-#line 2718
+		struct vax_single *const vsp = (struct vax_single *) ip;
+		const struct ieee_single *const isp =
+			 (const struct ieee_single *) (*xpp);
+		unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
+
+		switch(exp) {
+		case 0 :
+			/* ieee subnormal */
+			if(isp->mant_hi == min.ieee.mant_hi
+				&& isp->mant_lo_hi == min.ieee.mant_lo_hi
+				&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
+			{
+				*vsp = min.s;
+			}
+			else
+			{
+				unsigned mantissa = (isp->mant_hi << 16)
+					 | isp->mant_lo_hi << 8
+					 | isp->mant_lo_lo;
+				unsigned tmp = mantissa >> 20;
+				if(tmp >= 4) {
+					vsp->exp = 2;
+				} else if (tmp >= 2) {
+					vsp->exp = 1;
+				} else {
+					*vsp = min.s;
+					break;
+				} /* else */
+				tmp = mantissa - (1 << (20 + vsp->exp ));
+				tmp <<= 3 - vsp->exp;
+				vsp->mantissa2 = tmp;
+				vsp->mantissa1 = (tmp >> 16);
+			}
+			break;
+		case 0xfe :
+		case 0xff :
+			*vsp = max.s;
+			break;
+		default :
+			vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
+			vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
+			vsp->mantissa1 = isp->mant_hi;
+		}
 
-#line 2718
+		vsp->sign = isp->sign;
 
-#line 2718
-	if(rndup)
-#line 2718
+
+		ip++;
+		*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
+	}
+	return ENOERR;
+}
+#else
+int
+ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
+{
+	const char *xp = *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2718
-		(void) memcpy(xp, nada, rndup);
-#line 2718
-		xp += rndup;
-#line 2718
+		const int lstatus = ncx_get_float_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
 	}
-#line 2718
 
-#line 2718
-	*xpp = (void *)xp;
-#line 2718
+	*xpp = (const void *)xp;
 	return status;
-#line 2718
 }
-#line 2718
 
+#endif
 int
-#line 2719
-ncx_pad_putn_schar_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 2719
+ncx_getn_float_schar(const void **xpp, size_t nelems, schar *tp)
 {
-#line 2719
-	int status = ENOERR;
-#line 2719
-	size_t rndup = nelems % X_ALIGN;
-#line 2719
-	schar *xp = (schar *) *xpp;
-#line 2719
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2719
-	if(rndup)
-#line 2719
-		rndup = X_ALIGN - rndup;
-#line 2719
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
 
-#line 2719
-	while(nelems-- != 0)
-#line 2719
-	{
-#line 2719
-		/* N.B. schar as signed */
-#line 2719
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2719
-			status = NC_ERANGE;
-#line 2719
-		*xp++ = (schar) *tp++;
-#line 2719
-	}
-#line 2719
+  realign = (cxp & 7) % SIZEOF_FLOAT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
+      xp = tmp;
+    } else {
+      xp = (float *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (float *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-#line 2719
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
 
-#line 2719
-	if(rndup)
-#line 2719
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2719
-		(void) memcpy(xp, nada, rndup);
-#line 2719
-		xp += rndup;
-#line 2719
+		const int lstatus = ncx_get_float_schar(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
 	}
-#line 2719
 
-#line 2719
-	*xpp = (void *)xp;
-#line 2719
+	*xpp = (const void *)xp;
 	return status;
-#line 2719
+#  endif
 }
-#line 2719
 
 int
-#line 2720
-ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 2720
+ncx_getn_float_short(const void **xpp, size_t nelems, short *tp)
 {
-#line 2720
-	int status = ENOERR;
-#line 2720
-	size_t rndup = nelems % X_ALIGN;
-#line 2720
-	schar *xp = (schar *) *xpp;
-#line 2720
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2720
-	if(rndup)
-#line 2720
-		rndup = X_ALIGN - rndup;
-#line 2720
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
 
-#line 2720
-	while(nelems-- != 0)
-#line 2720
-	{
-#line 2720
-		/* N.B. schar as signed */
-#line 2720
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
-#line 2720
-			status = NC_ERANGE;
-#line 2720
-		*xp++ = (schar) *tp++;
-#line 2720
-	}
-#line 2720
+  realign = (cxp & 7) % SIZEOF_FLOAT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
+      xp = tmp;
+    } else {
+      xp = (float *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (float *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-#line 2720
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
+	int status = ENOERR;
 
-#line 2720
-	if(rndup)
-#line 2720
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2720
-		(void) memcpy(xp, nada, rndup);
-#line 2720
-		xp += rndup;
-#line 2720
+		const int lstatus = ncx_get_float_short(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
 	}
-#line 2720
 
-#line 2720
-	*xpp = (void *)xp;
-#line 2720
+	*xpp = (const void *)xp;
 	return status;
-#line 2720
+#  endif
 }
-#line 2720
-
-
-
-/* short */
 
 int
-#line 2725
-ncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
-#line 2725
+ncx_getn_float_int(const void **xpp, size_t nelems, int *tp)
 {
-#line 2725
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2725
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2725
  /* basic algorithm is:
-#line 2725
   *   - ensure sane alignment of input data
-#line 2725
   *   - copy (conversion happens automatically) input data
-#line 2725
   *     to output
-#line 2725
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2725
   *     at next location for converted output
-#line 2725
   */
-#line 2725
   long i, j, ni;
-#line 2725
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2725
-  short *xp;
-#line 2725
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2725
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2725
   long cxp = (long) *((char**)xpp);
-#line 2725
 
-#line 2725
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2725
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2725
    * vector work space reserved to LOOPCNT elements. Also
-#line 2725
    * makes vectorisation easy */
-#line 2725
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2725
     ni=Min(nelems-j,LOOPCNT);
-#line 2725
     if (realign) {
-#line 2725
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2725
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2725
     } else {
-#line 2725
-      xp = (short *) *xpp;
-#line 2725
+      xp = (float *) *xpp;
     }
-#line 2725
    /* copy the next block */
-#line 2725
 #pragma cdir loopcnt=LOOPCNT
-#line 2725
 #pragma cdir shortloop
-#line 2725
     for (i=0; i<ni; i++) {
-#line 2725
-      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 2725
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2725
-      nrange += xp[i] < SCHAR_MIN || xp[i] > SCHAR_MAX;
-#line 2725
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
     }
-#line 2725
    /* update xpp and tp */
-#line 2725
-    if (realign) xp = (short *) *xpp;
-#line 2725
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2725
     tp += ni;
-#line 2725
     *xpp = (void*)xp;
-#line 2725
   }
-#line 2725
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2725
 
-#line 2725
 #else   /* not SX */
-#line 2725
 	const char *xp = (const char *) *xpp;
-#line 2725
 	int status = ENOERR;
-#line 2725
 
-#line 2725
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2725
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2725
-		const int lstatus = ncx_get_short_schar(xp, tp);
-#line 2725
+		const int lstatus = ncx_get_float_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2725
 			status = lstatus;
-#line 2725
 	}
-#line 2725
 
-#line 2725
 	*xpp = (const void *)xp;
-#line 2725
 	return status;
-#line 2725
 #  endif
-#line 2725
 }
-#line 2725
 
 int
-#line 2726
-ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2726
+ncx_getn_float_double(const void **xpp, size_t nelems, double *tp)
 {
-#line 2726
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2726
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2726
  /* basic algorithm is:
-#line 2726
   *   - ensure sane alignment of input data
-#line 2726
   *   - copy (conversion happens automatically) input data
-#line 2726
   *     to output
-#line 2726
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2726
   *     at next location for converted output
-#line 2726
   */
-#line 2726
   long i, j, ni;
-#line 2726
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2726
-  short *xp;
-#line 2726
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2726
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2726
   long cxp = (long) *((char**)xpp);
-#line 2726
 
-#line 2726
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2726
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2726
    * vector work space reserved to LOOPCNT elements. Also
-#line 2726
    * makes vectorisation easy */
-#line 2726
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2726
     ni=Min(nelems-j,LOOPCNT);
-#line 2726
     if (realign) {
-#line 2726
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2726
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2726
     } else {
-#line 2726
-      xp = (short *) *xpp;
-#line 2726
+      xp = (float *) *xpp;
     }
-#line 2726
    /* copy the next block */
-#line 2726
 #pragma cdir loopcnt=LOOPCNT
-#line 2726
 #pragma cdir shortloop
-#line 2726
     for (i=0; i<ni; i++) {
-#line 2726
-      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 2726
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2726
-      nrange += xp[i] < UCHAR_MIN || xp[i] > UCHAR_MAX;
-#line 2726
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
     }
-#line 2726
    /* update xpp and tp */
-#line 2726
-    if (realign) xp = (short *) *xpp;
-#line 2726
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2726
     tp += ni;
-#line 2726
     *xpp = (void*)xp;
-#line 2726
   }
-#line 2726
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2726
 
-#line 2726
 #else   /* not SX */
-#line 2726
 	const char *xp = (const char *) *xpp;
-#line 2726
 	int status = ENOERR;
-#line 2726
 
-#line 2726
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2726
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2726
-		const int lstatus = ncx_get_short_uchar(xp, tp);
-#line 2726
+		const int lstatus = ncx_get_float_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 2726
 			status = lstatus;
-#line 2726
 	}
-#line 2726
 
-#line 2726
 	*xpp = (const void *)xp;
-#line 2726
 	return status;
-#line 2726
 #  endif
-#line 2726
 }
-#line 2726
 
-#if X_SIZEOF_SHORT == SIZEOF_SHORT
-/* optimized version */
-int
-ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
-{
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(tp, *xpp, nelems * sizeof(short));
-# else
-	swapn2b(tp, *xpp, nelems);
-# endif
-	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_SHORT);
-	return ENOERR;
-}
-#else
 int
-#line 2741
-ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
-#line 2741
+ncx_getn_float_longlong(const void **xpp, size_t nelems, longlong *tp)
 {
-#line 2741
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2741
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2741
  /* basic algorithm is:
-#line 2741
   *   - ensure sane alignment of input data
-#line 2741
   *   - copy (conversion happens automatically) input data
-#line 2741
   *     to output
-#line 2741
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2741
   *     at next location for converted output
-#line 2741
   */
-#line 2741
   long i, j, ni;
-#line 2741
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2741
-  short *xp;
-#line 2741
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2741
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2741
   long cxp = (long) *((char**)xpp);
-#line 2741
 
-#line 2741
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2741
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2741
    * vector work space reserved to LOOPCNT elements. Also
-#line 2741
    * makes vectorisation easy */
-#line 2741
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2741
     ni=Min(nelems-j,LOOPCNT);
-#line 2741
     if (realign) {
-#line 2741
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2741
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2741
     } else {
-#line 2741
-      xp = (short *) *xpp;
-#line 2741
+      xp = (float *) *xpp;
     }
-#line 2741
    /* copy the next block */
-#line 2741
 #pragma cdir loopcnt=LOOPCNT
-#line 2741
 #pragma cdir shortloop
-#line 2741
     for (i=0; i<ni; i++) {
-#line 2741
-      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 2741
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2741
-      nrange += xp[i] < SHORT_MIN || xp[i] > SHORT_MAX;
-#line 2741
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
     }
-#line 2741
    /* update xpp and tp */
-#line 2741
-    if (realign) xp = (short *) *xpp;
-#line 2741
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2741
     tp += ni;
-#line 2741
     *xpp = (void*)xp;
-#line 2741
   }
-#line 2741
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2741
 
-#line 2741
 #else   /* not SX */
-#line 2741
 	const char *xp = (const char *) *xpp;
-#line 2741
 	int status = ENOERR;
-#line 2741
 
-#line 2741
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2741
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2741
-		const int lstatus = ncx_get_short_short(xp, tp);
-#line 2741
+		const int lstatus = ncx_get_float_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2741
 			status = lstatus;
-#line 2741
 	}
-#line 2741
 
-#line 2741
 	*xpp = (const void *)xp;
-#line 2741
 	return status;
-#line 2741
 #  endif
-#line 2741
 }
-#line 2741
 
-#endif
 int
-#line 2743
-ncx_getn_short_int(const void **xpp, size_t nelems, int *tp)
-#line 2743
+ncx_getn_float_ushort(const void **xpp, size_t nelems, ushort *tp)
 {
-#line 2743
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2743
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2743
  /* basic algorithm is:
-#line 2743
   *   - ensure sane alignment of input data
-#line 2743
   *   - copy (conversion happens automatically) input data
-#line 2743
   *     to output
-#line 2743
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2743
   *     at next location for converted output
-#line 2743
   */
-#line 2743
   long i, j, ni;
-#line 2743
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2743
-  short *xp;
-#line 2743
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2743
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2743
   long cxp = (long) *((char**)xpp);
-#line 2743
 
-#line 2743
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2743
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2743
    * vector work space reserved to LOOPCNT elements. Also
-#line 2743
    * makes vectorisation easy */
-#line 2743
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2743
     ni=Min(nelems-j,LOOPCNT);
-#line 2743
     if (realign) {
-#line 2743
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2743
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2743
     } else {
-#line 2743
-      xp = (short *) *xpp;
-#line 2743
+      xp = (float *) *xpp;
     }
-#line 2743
    /* copy the next block */
-#line 2743
 #pragma cdir loopcnt=LOOPCNT
-#line 2743
 #pragma cdir shortloop
-#line 2743
     for (i=0; i<ni; i++) {
-#line 2743
-      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 2743
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2743
-      nrange += xp[i] < INT_MIN || xp[i] > INT_MAX;
-#line 2743
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX || xp[i] < 0;
     }
-#line 2743
    /* update xpp and tp */
-#line 2743
-    if (realign) xp = (short *) *xpp;
-#line 2743
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2743
     tp += ni;
-#line 2743
     *xpp = (void*)xp;
-#line 2743
   }
-#line 2743
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2743
 
-#line 2743
 #else   /* not SX */
-#line 2743
 	const char *xp = (const char *) *xpp;
-#line 2743
 	int status = ENOERR;
-#line 2743
 
-#line 2743
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2743
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2743
-		const int lstatus = ncx_get_short_int(xp, tp);
-#line 2743
+		const int lstatus = ncx_get_float_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2743
 			status = lstatus;
-#line 2743
 	}
-#line 2743
 
-#line 2743
 	*xpp = (const void *)xp;
-#line 2743
 	return status;
-#line 2743
 #  endif
-#line 2743
 }
-#line 2743
 
 int
-#line 2744
-ncx_getn_short_float(const void **xpp, size_t nelems, float *tp)
-#line 2744
+ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
-#line 2744
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2744
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2744
  /* basic algorithm is:
-#line 2744
   *   - ensure sane alignment of input data
-#line 2744
   *   - copy (conversion happens automatically) input data
-#line 2744
   *     to output
-#line 2744
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2744
   *     at next location for converted output
-#line 2744
   */
-#line 2744
   long i, j, ni;
-#line 2744
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2744
-  short *xp;
-#line 2744
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2744
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2744
   long cxp = (long) *((char**)xpp);
-#line 2744
 
-#line 2744
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2744
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2744
    * vector work space reserved to LOOPCNT elements. Also
-#line 2744
    * makes vectorisation easy */
-#line 2744
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2744
     ni=Min(nelems-j,LOOPCNT);
-#line 2744
     if (realign) {
-#line 2744
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2744
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2744
     } else {
-#line 2744
-      xp = (short *) *xpp;
-#line 2744
+      xp = (float *) *xpp;
     }
-#line 2744
    /* copy the next block */
-#line 2744
 #pragma cdir loopcnt=LOOPCNT
-#line 2744
 #pragma cdir shortloop
-#line 2744
     for (i=0; i<ni; i++) {
-#line 2744
-      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 2744
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2744
-      nrange += xp[i] < FLOAT_MIN || xp[i] > FLOAT_MAX;
-#line 2744
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
     }
-#line 2744
    /* update xpp and tp */
-#line 2744
-    if (realign) xp = (short *) *xpp;
-#line 2744
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2744
     tp += ni;
-#line 2744
     *xpp = (void*)xp;
-#line 2744
   }
-#line 2744
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2744
 
-#line 2744
 #else   /* not SX */
-#line 2744
 	const char *xp = (const char *) *xpp;
-#line 2744
 	int status = ENOERR;
-#line 2744
 
-#line 2744
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2744
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2744
-		const int lstatus = ncx_get_short_float(xp, tp);
-#line 2744
+		const int lstatus = ncx_get_float_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2744
 			status = lstatus;
-#line 2744
 	}
-#line 2744
 
-#line 2744
 	*xpp = (const void *)xp;
-#line 2744
 	return status;
-#line 2744
 #  endif
-#line 2744
 }
-#line 2744
 
 int
-#line 2745
-ncx_getn_short_double(const void **xpp, size_t nelems, double *tp)
-#line 2745
+ncx_getn_float_uint(const void **xpp, size_t nelems, uint *tp)
 {
-#line 2745
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2745
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2745
  /* basic algorithm is:
-#line 2745
   *   - ensure sane alignment of input data
-#line 2745
   *   - copy (conversion happens automatically) input data
-#line 2745
   *     to output
-#line 2745
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2745
   *     at next location for converted output
-#line 2745
   */
-#line 2745
   long i, j, ni;
-#line 2745
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2745
-  short *xp;
-#line 2745
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2745
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2745
   long cxp = (long) *((char**)xpp);
-#line 2745
 
-#line 2745
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2745
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2745
    * vector work space reserved to LOOPCNT elements. Also
-#line 2745
    * makes vectorisation easy */
-#line 2745
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2745
     ni=Min(nelems-j,LOOPCNT);
-#line 2745
     if (realign) {
-#line 2745
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2745
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2745
     } else {
-#line 2745
-      xp = (short *) *xpp;
-#line 2745
+      xp = (float *) *xpp;
     }
-#line 2745
    /* copy the next block */
-#line 2745
 #pragma cdir loopcnt=LOOPCNT
-#line 2745
 #pragma cdir shortloop
-#line 2745
     for (i=0; i<ni; i++) {
-#line 2745
-      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 2745
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2745
-      nrange += xp[i] < DOUBLE_MIN || xp[i] > DOUBLE_MAX;
-#line 2745
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX || xp[i] < 0;
     }
-#line 2745
    /* update xpp and tp */
-#line 2745
-    if (realign) xp = (short *) *xpp;
-#line 2745
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2745
     tp += ni;
-#line 2745
     *xpp = (void*)xp;
-#line 2745
   }
-#line 2745
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2745
 
-#line 2745
 #else   /* not SX */
-#line 2745
 	const char *xp = (const char *) *xpp;
-#line 2745
 	int status = ENOERR;
-#line 2745
 
-#line 2745
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2745
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2745
-		const int lstatus = ncx_get_short_double(xp, tp);
-#line 2745
+		const int lstatus = ncx_get_float_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2745
 			status = lstatus;
-#line 2745
 	}
-#line 2745
 
-#line 2745
 	*xpp = (const void *)xp;
-#line 2745
 	return status;
-#line 2745
 #  endif
-#line 2745
 }
-#line 2745
 
 int
-#line 2746
-ncx_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2746
+ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
 {
-#line 2746
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2746
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2746
  /* basic algorithm is:
-#line 2746
   *   - ensure sane alignment of input data
-#line 2746
   *   - copy (conversion happens automatically) input data
-#line 2746
   *     to output
-#line 2746
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2746
   *     at next location for converted output
-#line 2746
   */
-#line 2746
   long i, j, ni;
-#line 2746
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2746
-  short *xp;
-#line 2746
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2746
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2746
   long cxp = (long) *((char**)xpp);
-#line 2746
 
-#line 2746
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2746
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2746
    * vector work space reserved to LOOPCNT elements. Also
-#line 2746
    * makes vectorisation easy */
-#line 2746
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2746
     ni=Min(nelems-j,LOOPCNT);
-#line 2746
     if (realign) {
-#line 2746
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2746
+      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
       xp = tmp;
-#line 2746
     } else {
-#line 2746
-      xp = (short *) *xpp;
-#line 2746
+      xp = (float *) *xpp;
     }
-#line 2746
    /* copy the next block */
-#line 2746
 #pragma cdir loopcnt=LOOPCNT
-#line 2746
 #pragma cdir shortloop
-#line 2746
     for (i=0; i<ni; i++) {
-#line 2746
-      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 2746
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2746
-      nrange += xp[i] < UINT_MIN || xp[i] > UINT_MAX;
-#line 2746
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
     }
-#line 2746
    /* update xpp and tp */
-#line 2746
-    if (realign) xp = (short *) *xpp;
-#line 2746
+    if (realign) xp = (float *) *xpp;
     xp += ni;
-#line 2746
     tp += ni;
-#line 2746
     *xpp = (void*)xp;
-#line 2746
   }
-#line 2746
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2746
 
-#line 2746
 #else   /* not SX */
-#line 2746
 	const char *xp = (const char *) *xpp;
-#line 2746
 	int status = ENOERR;
-#line 2746
 
-#line 2746
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2746
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2746
-		const int lstatus = ncx_get_short_uint(xp, tp);
-#line 2746
+		const int lstatus = ncx_get_float_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2746
 			status = lstatus;
-#line 2746
 	}
-#line 2746
 
-#line 2746
 	*xpp = (const void *)xp;
-#line 2746
 	return status;
-#line 2746
 #  endif
-#line 2746
 }
-#line 2746
 
+
+#if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
+/* optimized version */
 int
-#line 2747
-ncx_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2747
+ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
 {
-#line 2747
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2747
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_FLOAT);
+# else
+	swapn4b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_FLOAT);
+	return ENOERR;
+}
+#elif vax
+int
+ncx_putn_float_float(void **xpp, size_t nfloats, const float *ip)
+{
+	const float *const end = ip + nfloats;
+
+	while(ip < end)
+	{
+		const struct vax_single *const vsp =
+			 (const struct vax_single *)ip;
+		struct ieee_single *const isp = (struct ieee_single *) (*xpp);
+
+		switch(vsp->exp){
+		case 0 :
+			/* all vax float with zero exponent map to zero */
+			*isp = min.ieee;
+			break;
+		case 2 :
+		case 1 :
+		{
+			/* These will map to subnormals */
+			unsigned mantissa = (vsp->mantissa1 << 16)
+					 | vsp->mantissa2;
+			mantissa >>= 3 - vsp->exp;
+			mantissa += (1 << (20 + vsp->exp));
+			isp->mant_lo_lo = mantissa;
+			isp->mant_lo_hi = mantissa >> 8;
+			isp->mant_hi = mantissa >> 16;
+			isp->exp_lo = 0;
+			isp->exp_hi = 0;
+		}
+			break;
+		case 0xff : /* max.s.exp */
+			if( vsp->mantissa2 == max.s.mantissa2
+				&& vsp->mantissa1 == max.s.mantissa1)
+			{
+				/* map largest vax float to ieee infinity */
+				*isp = max.ieee;
+				break;
+			} /* else, fall thru */
+		default :
+		{
+			unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
+			isp->exp_hi = exp >> 1;
+			isp->exp_lo = exp;
+			isp->mant_lo_lo = vsp->mantissa2;
+			isp->mant_lo_hi = vsp->mantissa2 >> 8;
+			isp->mant_hi = vsp->mantissa1;
+		}
+		}
+
+		isp->sign = vsp->sign;
+
+
+		ip++;
+		*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
+	}
+	return ENOERR;
+}
+#else
+int
+ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
+{
+	char *xp = *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
+	{
+		int lstatus = ncx_put_float_float(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+#endif
+int
+ncx_putn_float_schar(void **xpp, size_t nelems, const schar *tp)
+{
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2747
  /* basic algorithm is:
-#line 2747
-  *   - ensure sane alignment of input data
-#line 2747
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2747
   *     to output
-#line 2747
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2747
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2747
   */
-#line 2747
   long i, j, ni;
-#line 2747
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2747
-  short *xp;
-#line 2747
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2747
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2747
   long cxp = (long) *((char**)xpp);
-#line 2747
 
-#line 2747
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2747
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2747
    * vector work space reserved to LOOPCNT elements. Also
-#line 2747
    * makes vectorisation easy */
-#line 2747
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2747
     ni=Min(nelems-j,LOOPCNT);
-#line 2747
     if (realign) {
-#line 2747
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2747
       xp = tmp;
-#line 2747
     } else {
-#line 2747
-      xp = (short *) *xpp;
-#line 2747
+      xp = (float *) *xpp;
     }
-#line 2747
    /* copy the next block */
-#line 2747
 #pragma cdir loopcnt=LOOPCNT
-#line 2747
 #pragma cdir shortloop
-#line 2747
     for (i=0; i<ni; i++) {
-#line 2747
-      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 2747
+      /* the normal case: */
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2747
-      nrange += xp[i] < LONGLONG_MIN || xp[i] > LONGLONG_MAX;
-#line 2747
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2747
    /* update xpp and tp */
-#line 2747
-    if (realign) xp = (short *) *xpp;
-#line 2747
     xp += ni;
-#line 2747
     tp += ni;
-#line 2747
     *xpp = (void*)xp;
-#line 2747
   }
-#line 2747
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2747
 
-#line 2747
 #else   /* not SX */
-#line 2747
-	const char *xp = (const char *) *xpp;
-#line 2747
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2747
 
-#line 2747
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2747
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2747
-		const int lstatus = ncx_get_short_longlong(xp, tp);
-#line 2747
+		int lstatus = ncx_put_float_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2747
 			status = lstatus;
-#line 2747
 	}
-#line 2747
 
-#line 2747
-	*xpp = (const void *)xp;
-#line 2747
+	*xpp = (void *)xp;
 	return status;
-#line 2747
-#  endif
-#line 2747
+#endif
 }
-#line 2747
 
 int
-#line 2748
-ncx_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2748
+ncx_putn_float_short(void **xpp, size_t nelems, const short *tp)
 {
-#line 2748
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2748
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2748
  /* basic algorithm is:
-#line 2748
-  *   - ensure sane alignment of input data
-#line 2748
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2748
   *     to output
-#line 2748
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2748
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2748
   */
-#line 2748
   long i, j, ni;
-#line 2748
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2748
-  short *xp;
-#line 2748
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2748
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2748
   long cxp = (long) *((char**)xpp);
-#line 2748
 
-#line 2748
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2748
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2748
    * vector work space reserved to LOOPCNT elements. Also
-#line 2748
    * makes vectorisation easy */
-#line 2748
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2748
     ni=Min(nelems-j,LOOPCNT);
-#line 2748
     if (realign) {
-#line 2748
-      memcpy(tmp, *xpp, ni*SIZEOF_SHORT);
-#line 2748
       xp = tmp;
-#line 2748
     } else {
-#line 2748
-      xp = (short *) *xpp;
-#line 2748
+      xp = (float *) *xpp;
     }
-#line 2748
    /* copy the next block */
-#line 2748
 #pragma cdir loopcnt=LOOPCNT
-#line 2748
 #pragma cdir shortloop
-#line 2748
     for (i=0; i<ni; i++) {
-#line 2748
-      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 2748
+      /* the normal case: */
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2748
-      nrange += xp[i] < ULONGLONG_MIN || xp[i] > ULONGLONG_MAX;
-#line 2748
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2748
    /* update xpp and tp */
-#line 2748
-    if (realign) xp = (short *) *xpp;
-#line 2748
     xp += ni;
-#line 2748
     tp += ni;
-#line 2748
     *xpp = (void*)xp;
-#line 2748
   }
-#line 2748
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2748
 
-#line 2748
 #else   /* not SX */
-#line 2748
-	const char *xp = (const char *) *xpp;
-#line 2748
-	int status = ENOERR;
-#line 2748
-
-#line 2748
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2748
-	{
-#line 2748
-		const int lstatus = ncx_get_short_ulonglong(xp, tp);
-#line 2748
-		if(lstatus != ENOERR)
-#line 2748
-			status = lstatus;
-#line 2748
-	}
-#line 2748
-
-#line 2748
-	*xpp = (const void *)xp;
-#line 2748
-	return status;
-#line 2748
-#  endif
-#line 2748
-}
-#line 2748
-
-
-int
-#line 2750
-ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
-#line 2750
-{
-#line 2750
-	const size_t rndup = nelems % 2;
-#line 2750
-
-#line 2750
-	const char *xp = (const char *) *xpp;
-#line 2750
-	int status = ENOERR;
-#line 2750
-
-#line 2750
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2750
-	{
-#line 2750
-		const int lstatus = ncx_get_short_schar(xp, tp);
-#line 2750
-		if(lstatus != ENOERR)
-#line 2750
-			status = lstatus;
-#line 2750
-	}
-#line 2750
-
-#line 2750
-	if(rndup != 0)
-#line 2750
-		xp += X_SIZEOF_SHORT;
-#line 2750
-
-#line 2750
-	*xpp = (void *)xp;
-#line 2750
-	return status;
-#line 2750
-}
-#line 2750
-
-int
-#line 2751
-ncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2751
-{
-#line 2751
-	const size_t rndup = nelems % 2;
-#line 2751
-
-#line 2751
-	const char *xp = (const char *) *xpp;
-#line 2751
-	int status = ENOERR;
-#line 2751
-
-#line 2751
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2751
-	{
-#line 2751
-		const int lstatus = ncx_get_short_uchar(xp, tp);
-#line 2751
-		if(lstatus != ENOERR)
-#line 2751
-			status = lstatus;
-#line 2751
-	}
-#line 2751
-
-#line 2751
-	if(rndup != 0)
-#line 2751
-		xp += X_SIZEOF_SHORT;
-#line 2751
-
-#line 2751
-	*xpp = (void *)xp;
-#line 2751
-	return status;
-#line 2751
-}
-#line 2751
-
-int
-#line 2752
-ncx_pad_getn_short_short(const void **xpp, size_t nelems, short *tp)
-#line 2752
-{
-#line 2752
-	const size_t rndup = nelems % 2;
-#line 2752
-
-#line 2752
-	const char *xp = (const char *) *xpp;
-#line 2752
-	int status = ENOERR;
-#line 2752
-
-#line 2752
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2752
-	{
-#line 2752
-		const int lstatus = ncx_get_short_short(xp, tp);
-#line 2752
-		if(lstatus != ENOERR)
-#line 2752
-			status = lstatus;
-#line 2752
-	}
-#line 2752
-
-#line 2752
-	if(rndup != 0)
-#line 2752
-		xp += X_SIZEOF_SHORT;
-#line 2752
-
-#line 2752
-	*xpp = (void *)xp;
-#line 2752
-	return status;
-#line 2752
-}
-#line 2752
-
-int
-#line 2753
-ncx_pad_getn_short_int(const void **xpp, size_t nelems, int *tp)
-#line 2753
-{
-#line 2753
-	const size_t rndup = nelems % 2;
-#line 2753
-
-#line 2753
-	const char *xp = (const char *) *xpp;
-#line 2753
-	int status = ENOERR;
-#line 2753
-
-#line 2753
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2753
-	{
-#line 2753
-		const int lstatus = ncx_get_short_int(xp, tp);
-#line 2753
-		if(lstatus != ENOERR)
-#line 2753
-			status = lstatus;
-#line 2753
-	}
-#line 2753
-
-#line 2753
-	if(rndup != 0)
-#line 2753
-		xp += X_SIZEOF_SHORT;
-#line 2753
-
-#line 2753
-	*xpp = (void *)xp;
-#line 2753
-	return status;
-#line 2753
-}
-#line 2753
-
-int
-#line 2754
-ncx_pad_getn_short_float(const void **xpp, size_t nelems, float *tp)
-#line 2754
-{
-#line 2754
-	const size_t rndup = nelems % 2;
-#line 2754
-
-#line 2754
-	const char *xp = (const char *) *xpp;
-#line 2754
-	int status = ENOERR;
-#line 2754
-
-#line 2754
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2754
-	{
-#line 2754
-		const int lstatus = ncx_get_short_float(xp, tp);
-#line 2754
-		if(lstatus != ENOERR)
-#line 2754
-			status = lstatus;
-#line 2754
-	}
-#line 2754
-
-#line 2754
-	if(rndup != 0)
-#line 2754
-		xp += X_SIZEOF_SHORT;
-#line 2754
-
-#line 2754
-	*xpp = (void *)xp;
-#line 2754
-	return status;
-#line 2754
-}
-#line 2754
-
-int
-#line 2755
-ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *tp)
-#line 2755
-{
-#line 2755
-	const size_t rndup = nelems % 2;
-#line 2755
-
-#line 2755
-	const char *xp = (const char *) *xpp;
-#line 2755
-	int status = ENOERR;
-#line 2755
-
-#line 2755
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2755
-	{
-#line 2755
-		const int lstatus = ncx_get_short_double(xp, tp);
-#line 2755
-		if(lstatus != ENOERR)
-#line 2755
-			status = lstatus;
-#line 2755
-	}
-#line 2755
-
-#line 2755
-	if(rndup != 0)
-#line 2755
-		xp += X_SIZEOF_SHORT;
-#line 2755
-
-#line 2755
-	*xpp = (void *)xp;
-#line 2755
-	return status;
-#line 2755
-}
-#line 2755
 
-int
-#line 2756
-ncx_pad_getn_short_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2756
-{
-#line 2756
-	const size_t rndup = nelems % 2;
-#line 2756
-
-#line 2756
-	const char *xp = (const char *) *xpp;
-#line 2756
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2756
 
-#line 2756
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2756
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2756
-		const int lstatus = ncx_get_short_uint(xp, tp);
-#line 2756
+		int lstatus = ncx_put_float_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 2756
 			status = lstatus;
-#line 2756
 	}
-#line 2756
-
-#line 2756
-	if(rndup != 0)
-#line 2756
-		xp += X_SIZEOF_SHORT;
-#line 2756
 
-#line 2756
 	*xpp = (void *)xp;
-#line 2756
 	return status;
-#line 2756
+#endif
 }
-#line 2756
 
 int
-#line 2757
-ncx_pad_getn_short_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2757
+ncx_putn_float_int(void **xpp, size_t nelems, const int *tp)
 {
-#line 2757
-	const size_t rndup = nelems % 2;
-#line 2757
-
-#line 2757
-	const char *xp = (const char *) *xpp;
-#line 2757
-	int status = ENOERR;
-#line 2757
-
-#line 2757
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2757
-	{
-#line 2757
-		const int lstatus = ncx_get_short_longlong(xp, tp);
-#line 2757
-		if(lstatus != ENOERR)
-#line 2757
-			status = lstatus;
-#line 2757
-	}
-#line 2757
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2757
-	if(rndup != 0)
-#line 2757
-		xp += X_SIZEOF_SHORT;
-#line 2757
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
 
-#line 2757
-	*xpp = (void *)xp;
-#line 2757
-	return status;
-#line 2757
-}
-#line 2757
+  realign = (cxp & 7) % SIZEOF_FLOAT;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (float *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-int
-#line 2758
-ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2758
-{
-#line 2758
-	const size_t rndup = nelems % 2;
-#line 2758
+#else   /* not SX */
 
-#line 2758
-	const char *xp = (const char *) *xpp;
-#line 2758
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2758
 
-#line 2758
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2758
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2758
-		const int lstatus = ncx_get_short_ulonglong(xp, tp);
-#line 2758
+		int lstatus = ncx_put_float_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2758
 			status = lstatus;
-#line 2758
 	}
-#line 2758
 
-#line 2758
-	if(rndup != 0)
-#line 2758
-		xp += X_SIZEOF_SHORT;
-#line 2758
-
-#line 2758
 	*xpp = (void *)xp;
-#line 2758
 	return status;
-#line 2758
+#endif
 }
-#line 2758
-
 
 int
-#line 2760
-ncx_putn_short_schar(void **xpp, size_t nelems, const schar *tp)
-#line 2760
+ncx_putn_float_double(void **xpp, size_t nelems, const double *tp)
 {
-#line 2760
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2760
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2760
  /* basic algorithm is:
-#line 2760
   *   - ensure sane alignment of output data
-#line 2760
   *   - copy (conversion happens automatically) input data
-#line 2760
   *     to output
-#line 2760
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2760
   *     at next location for converted output
-#line 2760
   */
-#line 2760
   long i, j, ni;
-#line 2760
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2760
-  short *xp;
-#line 2760
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2760
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2760
   long cxp = (long) *((char**)xpp);
-#line 2760
 
-#line 2760
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2760
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2760
    * vector work space reserved to LOOPCNT elements. Also
-#line 2760
    * makes vectorisation easy */
-#line 2760
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2760
     ni=Min(nelems-j,LOOPCNT);
-#line 2760
     if (realign) {
-#line 2760
       xp = tmp;
-#line 2760
     } else {
-#line 2760
-      xp = (short *) *xpp;
-#line 2760
+      xp = (float *) *xpp;
     }
-#line 2760
    /* copy the next block */
-#line 2760
 #pragma cdir loopcnt=LOOPCNT
-#line 2760
 #pragma cdir shortloop
-#line 2760
     for (i=0; i<ni; i++) {
-#line 2760
       /* the normal case: */
-#line 2760
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2760
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2760
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2760
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
     }
-#line 2760
    /* copy workspace back if necessary */
-#line 2760
     if (realign) {
-#line 2760
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2760
-      xp = (short *) *xpp;
-#line 2760
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2760
    /* update xpp and tp */
-#line 2760
     xp += ni;
-#line 2760
     tp += ni;
-#line 2760
     *xpp = (void*)xp;
-#line 2760
   }
-#line 2760
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2760
 
-#line 2760
 #else   /* not SX */
-#line 2760
 
-#line 2760
 	char *xp = (char *) *xpp;
-#line 2760
 	int status = ENOERR;
-#line 2760
 
-#line 2760
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2760
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2760
-		int lstatus = ncx_put_short_schar(xp, tp);
-#line 2760
+		int lstatus = ncx_put_float_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 2760
 			status = lstatus;
-#line 2760
 	}
-#line 2760
 
-#line 2760
 	*xpp = (void *)xp;
-#line 2760
 	return status;
-#line 2760
 #endif
-#line 2760
 }
-#line 2760
 
 int
-#line 2761
-ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp)
-#line 2761
+ncx_putn_float_longlong(void **xpp, size_t nelems, const longlong *tp)
 {
-#line 2761
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2761
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2761
  /* basic algorithm is:
-#line 2761
   *   - ensure sane alignment of output data
-#line 2761
   *   - copy (conversion happens automatically) input data
-#line 2761
   *     to output
-#line 2761
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2761
   *     at next location for converted output
-#line 2761
   */
-#line 2761
   long i, j, ni;
-#line 2761
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2761
-  short *xp;
-#line 2761
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2761
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2761
   long cxp = (long) *((char**)xpp);
-#line 2761
 
-#line 2761
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2761
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2761
    * vector work space reserved to LOOPCNT elements. Also
-#line 2761
    * makes vectorisation easy */
-#line 2761
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2761
     ni=Min(nelems-j,LOOPCNT);
-#line 2761
     if (realign) {
-#line 2761
       xp = tmp;
-#line 2761
     } else {
-#line 2761
-      xp = (short *) *xpp;
-#line 2761
+      xp = (float *) *xpp;
     }
-#line 2761
    /* copy the next block */
-#line 2761
 #pragma cdir loopcnt=LOOPCNT
-#line 2761
 #pragma cdir shortloop
-#line 2761
     for (i=0; i<ni; i++) {
-#line 2761
       /* the normal case: */
-#line 2761
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2761
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2761
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2761
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX || tp[i] < X_FLOAT_MIN;
     }
-#line 2761
    /* copy workspace back if necessary */
-#line 2761
     if (realign) {
-#line 2761
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2761
-      xp = (short *) *xpp;
-#line 2761
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2761
    /* update xpp and tp */
-#line 2761
     xp += ni;
-#line 2761
     tp += ni;
-#line 2761
     *xpp = (void*)xp;
-#line 2761
   }
-#line 2761
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2761
 
-#line 2761
 #else   /* not SX */
-#line 2761
 
-#line 2761
 	char *xp = (char *) *xpp;
-#line 2761
 	int status = ENOERR;
-#line 2761
 
-#line 2761
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2761
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2761
-		int lstatus = ncx_put_short_uchar(xp, tp);
-#line 2761
+		int lstatus = ncx_put_float_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2761
 			status = lstatus;
-#line 2761
 	}
-#line 2761
 
-#line 2761
 	*xpp = (void *)xp;
-#line 2761
 	return status;
-#line 2761
 #endif
-#line 2761
 }
-#line 2761
 
-#if X_SIZEOF_SHORT == SIZEOF_SHORT
-/* optimized version */
-int
-ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
-{
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_SHORT);
-# else
-	swapn2b(*xpp, tp, nelems);
-# endif
-	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_SHORT);
-	return ENOERR;
-}
-#else
 int
-#line 2776
-ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
-#line 2776
+ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *tp)
 {
-#line 2776
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2776
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2776
  /* basic algorithm is:
-#line 2776
   *   - ensure sane alignment of output data
-#line 2776
   *   - copy (conversion happens automatically) input data
-#line 2776
   *     to output
-#line 2776
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2776
   *     at next location for converted output
-#line 2776
   */
-#line 2776
   long i, j, ni;
-#line 2776
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2776
-  short *xp;
-#line 2776
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2776
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2776
   long cxp = (long) *((char**)xpp);
-#line 2776
 
-#line 2776
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2776
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2776
    * vector work space reserved to LOOPCNT elements. Also
-#line 2776
    * makes vectorisation easy */
-#line 2776
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2776
     ni=Min(nelems-j,LOOPCNT);
-#line 2776
     if (realign) {
-#line 2776
       xp = tmp;
-#line 2776
     } else {
-#line 2776
-      xp = (short *) *xpp;
-#line 2776
+      xp = (float *) *xpp;
     }
-#line 2776
    /* copy the next block */
-#line 2776
 #pragma cdir loopcnt=LOOPCNT
-#line 2776
 #pragma cdir shortloop
-#line 2776
     for (i=0; i<ni; i++) {
-#line 2776
       /* the normal case: */
-#line 2776
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2776
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2776
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2776
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX ;
     }
-#line 2776
    /* copy workspace back if necessary */
-#line 2776
     if (realign) {
-#line 2776
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2776
-      xp = (short *) *xpp;
-#line 2776
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2776
    /* update xpp and tp */
-#line 2776
     xp += ni;
-#line 2776
     tp += ni;
-#line 2776
     *xpp = (void*)xp;
-#line 2776
   }
-#line 2776
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2776
 
-#line 2776
 #else   /* not SX */
-#line 2776
 
-#line 2776
 	char *xp = (char *) *xpp;
-#line 2776
 	int status = ENOERR;
-#line 2776
 
-#line 2776
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2776
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2776
-		int lstatus = ncx_put_short_short(xp, tp);
-#line 2776
+		int lstatus = ncx_put_float_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2776
 			status = lstatus;
-#line 2776
 	}
-#line 2776
 
-#line 2776
 	*xpp = (void *)xp;
-#line 2776
 	return status;
-#line 2776
 #endif
-#line 2776
 }
-#line 2776
 
-#endif
 int
-#line 2778
-ncx_putn_short_int(void **xpp, size_t nelems, const int *tp)
-#line 2778
+ncx_putn_float_ushort(void **xpp, size_t nelems, const ushort *tp)
 {
-#line 2778
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2778
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2778
  /* basic algorithm is:
-#line 2778
   *   - ensure sane alignment of output data
-#line 2778
   *   - copy (conversion happens automatically) input data
-#line 2778
   *     to output
-#line 2778
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2778
   *     at next location for converted output
-#line 2778
   */
-#line 2778
   long i, j, ni;
-#line 2778
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2778
-  short *xp;
-#line 2778
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2778
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2778
   long cxp = (long) *((char**)xpp);
-#line 2778
 
-#line 2778
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2778
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2778
    * vector work space reserved to LOOPCNT elements. Also
-#line 2778
    * makes vectorisation easy */
-#line 2778
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2778
     ni=Min(nelems-j,LOOPCNT);
-#line 2778
     if (realign) {
-#line 2778
       xp = tmp;
-#line 2778
     } else {
-#line 2778
-      xp = (short *) *xpp;
-#line 2778
+      xp = (float *) *xpp;
     }
-#line 2778
    /* copy the next block */
-#line 2778
 #pragma cdir loopcnt=LOOPCNT
-#line 2778
 #pragma cdir shortloop
-#line 2778
     for (i=0; i<ni; i++) {
-#line 2778
       /* the normal case: */
-#line 2778
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2778
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2778
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2778
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX ;
     }
-#line 2778
    /* copy workspace back if necessary */
-#line 2778
     if (realign) {
-#line 2778
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2778
-      xp = (short *) *xpp;
-#line 2778
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2778
    /* update xpp and tp */
-#line 2778
     xp += ni;
-#line 2778
     tp += ni;
-#line 2778
     *xpp = (void*)xp;
-#line 2778
   }
-#line 2778
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2778
 
-#line 2778
 #else   /* not SX */
-#line 2778
 
-#line 2778
 	char *xp = (char *) *xpp;
-#line 2778
 	int status = ENOERR;
-#line 2778
 
-#line 2778
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2778
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2778
-		int lstatus = ncx_put_short_int(xp, tp);
-#line 2778
+		int lstatus = ncx_put_float_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2778
 			status = lstatus;
-#line 2778
 	}
-#line 2778
 
-#line 2778
 	*xpp = (void *)xp;
-#line 2778
 	return status;
-#line 2778
 #endif
-#line 2778
 }
-#line 2778
 
 int
-#line 2779
-ncx_putn_short_float(void **xpp, size_t nelems, const float *tp)
-#line 2779
+ncx_putn_float_uint(void **xpp, size_t nelems, const uint *tp)
 {
-#line 2779
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2779
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2779
  /* basic algorithm is:
-#line 2779
   *   - ensure sane alignment of output data
-#line 2779
   *   - copy (conversion happens automatically) input data
-#line 2779
   *     to output
-#line 2779
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2779
   *     at next location for converted output
-#line 2779
   */
-#line 2779
   long i, j, ni;
-#line 2779
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2779
-  short *xp;
-#line 2779
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2779
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2779
   long cxp = (long) *((char**)xpp);
-#line 2779
 
-#line 2779
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2779
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2779
    * vector work space reserved to LOOPCNT elements. Also
-#line 2779
    * makes vectorisation easy */
-#line 2779
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2779
     ni=Min(nelems-j,LOOPCNT);
-#line 2779
     if (realign) {
-#line 2779
       xp = tmp;
-#line 2779
     } else {
-#line 2779
-      xp = (short *) *xpp;
-#line 2779
+      xp = (float *) *xpp;
     }
-#line 2779
    /* copy the next block */
-#line 2779
 #pragma cdir loopcnt=LOOPCNT
-#line 2779
 #pragma cdir shortloop
-#line 2779
     for (i=0; i<ni; i++) {
-#line 2779
       /* the normal case: */
-#line 2779
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2779
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2779
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2779
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX ;
     }
-#line 2779
    /* copy workspace back if necessary */
-#line 2779
     if (realign) {
-#line 2779
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2779
-      xp = (short *) *xpp;
-#line 2779
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2779
    /* update xpp and tp */
-#line 2779
     xp += ni;
-#line 2779
     tp += ni;
-#line 2779
     *xpp = (void*)xp;
-#line 2779
   }
-#line 2779
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2779
 
-#line 2779
 #else   /* not SX */
-#line 2779
 
-#line 2779
 	char *xp = (char *) *xpp;
-#line 2779
 	int status = ENOERR;
-#line 2779
 
-#line 2779
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2779
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
 	{
-#line 2779
-		int lstatus = ncx_put_short_float(xp, tp);
-#line 2779
+		int lstatus = ncx_put_float_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2779
 			status = lstatus;
-#line 2779
 	}
-#line 2779
 
-#line 2779
 	*xpp = (void *)xp;
-#line 2779
 	return status;
-#line 2779
 #endif
-#line 2779
 }
-#line 2779
 
 int
-#line 2780
-ncx_putn_short_double(void **xpp, size_t nelems, const double *tp)
-#line 2780
+ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
 {
-#line 2780
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2780
+#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
 
-#line 2780
  /* basic algorithm is:
-#line 2780
   *   - ensure sane alignment of output data
-#line 2780
   *   - copy (conversion happens automatically) input data
-#line 2780
   *     to output
-#line 2780
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2780
   *     at next location for converted output
-#line 2780
   */
-#line 2780
   long i, j, ni;
-#line 2780
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2780
-  short *xp;
-#line 2780
+  float tmp[LOOPCNT];        /* in case input is misaligned */
+  float *xp;
   int nrange = 0;         /* number of range errors */
-#line 2780
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2780
   long cxp = (long) *((char**)xpp);
-#line 2780
 
-#line 2780
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2780
+  realign = (cxp & 7) % SIZEOF_FLOAT;
   /* sjl: manually stripmine so we can limit amount of
-#line 2780
    * vector work space reserved to LOOPCNT elements. Also
-#line 2780
    * makes vectorisation easy */
-#line 2780
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2780
     ni=Min(nelems-j,LOOPCNT);
-#line 2780
     if (realign) {
-#line 2780
       xp = tmp;
-#line 2780
     } else {
-#line 2780
-      xp = (short *) *xpp;
-#line 2780
+      xp = (float *) *xpp;
     }
-#line 2780
    /* copy the next block */
-#line 2780
 #pragma cdir loopcnt=LOOPCNT
-#line 2780
 #pragma cdir shortloop
-#line 2780
     for (i=0; i<ni; i++) {
-#line 2780
       /* the normal case: */
-#line 2780
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2780
+      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2780
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2780
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_FLOAT_MAX ;
     }
-#line 2780
    /* copy workspace back if necessary */
-#line 2780
     if (realign) {
-#line 2780
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2780
-      xp = (short *) *xpp;
-#line 2780
+      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
+      xp = (float *) *xpp;
     }
-#line 2780
    /* update xpp and tp */
-#line 2780
     xp += ni;
-#line 2780
     tp += ni;
-#line 2780
     *xpp = (void*)xp;
-#line 2780
   }
-#line 2780
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2780
 
-#line 2780
 #else   /* not SX */
-#line 2780
 
-#line 2780
-	char *xp = (char *) *xpp;
-#line 2780
+	char *xp = (char *) *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
+	{
+		int lstatus = ncx_put_float_ulonglong(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+#endif
+}
+
+
+/* double --------------------------------------------------------------------*/
+
+#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
+/* optimized version */
+int
+ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(double));
+# else
+	swapn8b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
+	return ENOERR;
+}
+#elif vax
+int
+ncx_getn_double_double(const void **xpp, size_t ndoubles, double *ip)
+{
+	double *const end = ip + ndoubles;
+
+	while(ip < end)
+	{
+	struct vax_double *const vdp =
+			 (struct vax_double *)ip;
+	const struct ieee_double *const idp =
+			 (const struct ieee_double *) (*xpp);
+	{
+		const struct dbl_limits *lim;
+		int ii;
+		for (ii = 0, lim = dbl_limits;
+			ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
+			ii++, lim++)
+		{
+			if ((idp->mant_lo == lim->ieee.mant_lo)
+				&& (idp->mant_4 == lim->ieee.mant_4)
+				&& (idp->mant_5 == lim->ieee.mant_5)
+				&& (idp->mant_6 == lim->ieee.mant_6)
+				&& (idp->exp_lo == lim->ieee.exp_lo)
+				&& (idp->exp_hi == lim->ieee.exp_hi)
+				)
+			{
+				*vdp = lim->d;
+				goto doneit;
+			}
+		}
+	}
+	{
+		unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
+		vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
+	}
+	{
+		unsigned mant_hi = ((idp->mant_6 << 16)
+				 | (idp->mant_5 << 8)
+				 | idp->mant_4);
+		unsigned mant_lo = SWAP4(idp->mant_lo);
+		vdp->mantissa1 = (mant_hi >> 13);
+		vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
+				| (mant_lo >> 29);
+		vdp->mantissa3 = (mant_lo >> 13);
+		vdp->mantissa4 = (mant_lo << 3);
+	}
+	doneit:
+		vdp->sign = idp->sign;
+
+		ip++;
+		*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
+	}
+	return ENOERR;
+}
+	/* vax */
+#else
+int
+ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
+{
+	const char *xp = *xpp;
 	int status = ENOERR;
-#line 2780
 
-#line 2780
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2780
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2780
-		int lstatus = ncx_put_short_double(xp, tp);
-#line 2780
+		const int lstatus = ncx_get_double_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 2780
 			status = lstatus;
-#line 2780
 	}
-#line 2780
 
-#line 2780
-	*xpp = (void *)xp;
-#line 2780
+	*xpp = (const void *)xp;
 	return status;
-#line 2780
-#endif
-#line 2780
 }
-#line 2780
-
+#endif
 int
-#line 2781
-ncx_putn_short_uint(void **xpp, size_t nelems, const uint *tp)
-#line 2781
+ncx_getn_double_schar(const void **xpp, size_t nelems, schar *tp)
 {
-#line 2781
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2781
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2781
  /* basic algorithm is:
-#line 2781
-  *   - ensure sane alignment of output data
-#line 2781
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2781
   *     to output
-#line 2781
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2781
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2781
   */
-#line 2781
   long i, j, ni;
-#line 2781
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2781
-  short *xp;
-#line 2781
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2781
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2781
   long cxp = (long) *((char**)xpp);
-#line 2781
 
-#line 2781
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2781
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2781
    * vector work space reserved to LOOPCNT elements. Also
-#line 2781
    * makes vectorisation easy */
-#line 2781
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2781
     ni=Min(nelems-j,LOOPCNT);
-#line 2781
     if (realign) {
-#line 2781
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
       xp = tmp;
-#line 2781
     } else {
-#line 2781
-      xp = (short *) *xpp;
-#line 2781
+      xp = (double *) *xpp;
     }
-#line 2781
    /* copy the next block */
-#line 2781
 #pragma cdir loopcnt=LOOPCNT
-#line 2781
 #pragma cdir shortloop
-#line 2781
     for (i=0; i<ni; i++) {
-#line 2781
-      /* the normal case: */
-#line 2781
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2781
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2781
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2781
-    }
-#line 2781
-   /* copy workspace back if necessary */
-#line 2781
-    if (realign) {
-#line 2781
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2781
-      xp = (short *) *xpp;
-#line 2781
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
     }
-#line 2781
    /* update xpp and tp */
-#line 2781
+    if (realign) xp = (double *) *xpp;
     xp += ni;
-#line 2781
     tp += ni;
-#line 2781
     *xpp = (void*)xp;
-#line 2781
   }
-#line 2781
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2781
 
-#line 2781
 #else   /* not SX */
-#line 2781
-
-#line 2781
-	char *xp = (char *) *xpp;
-#line 2781
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2781
 
-#line 2781
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2781
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2781
-		int lstatus = ncx_put_short_uint(xp, tp);
-#line 2781
+		const int lstatus = ncx_get_double_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2781
 			status = lstatus;
-#line 2781
 	}
-#line 2781
 
-#line 2781
-	*xpp = (void *)xp;
-#line 2781
+	*xpp = (const void *)xp;
 	return status;
-#line 2781
-#endif
-#line 2781
+#  endif
 }
-#line 2781
 
 int
-#line 2782
-ncx_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 2782
+ncx_getn_double_short(const void **xpp, size_t nelems, short *tp)
 {
-#line 2782
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2782
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2782
  /* basic algorithm is:
-#line 2782
-  *   - ensure sane alignment of output data
-#line 2782
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2782
   *     to output
-#line 2782
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2782
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2782
   */
-#line 2782
   long i, j, ni;
-#line 2782
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2782
-  short *xp;
-#line 2782
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2782
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2782
   long cxp = (long) *((char**)xpp);
-#line 2782
 
-#line 2782
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2782
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2782
    * vector work space reserved to LOOPCNT elements. Also
-#line 2782
    * makes vectorisation easy */
-#line 2782
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2782
     ni=Min(nelems-j,LOOPCNT);
-#line 2782
     if (realign) {
-#line 2782
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
       xp = tmp;
-#line 2782
     } else {
-#line 2782
-      xp = (short *) *xpp;
-#line 2782
+      xp = (double *) *xpp;
     }
-#line 2782
    /* copy the next block */
-#line 2782
 #pragma cdir loopcnt=LOOPCNT
-#line 2782
 #pragma cdir shortloop
-#line 2782
     for (i=0; i<ni; i++) {
-#line 2782
-      /* the normal case: */
-#line 2782
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2782
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2782
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2782
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
     }
-#line 2782
-   /* copy workspace back if necessary */
-#line 2782
-    if (realign) {
-#line 2782
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2782
-      xp = (short *) *xpp;
-#line 2782
-    }
-#line 2782
    /* update xpp and tp */
-#line 2782
+    if (realign) xp = (double *) *xpp;
     xp += ni;
-#line 2782
     tp += ni;
-#line 2782
     *xpp = (void*)xp;
-#line 2782
   }
-#line 2782
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2782
 
-#line 2782
 #else   /* not SX */
-#line 2782
-
-#line 2782
-	char *xp = (char *) *xpp;
-#line 2782
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2782
 
-#line 2782
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2782
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2782
-		int lstatus = ncx_put_short_longlong(xp, tp);
-#line 2782
+		const int lstatus = ncx_get_double_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 2782
 			status = lstatus;
-#line 2782
 	}
-#line 2782
 
-#line 2782
-	*xpp = (void *)xp;
-#line 2782
+	*xpp = (const void *)xp;
 	return status;
-#line 2782
-#endif
-#line 2782
+#  endif
 }
-#line 2782
 
 int
-#line 2783
-ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 2783
+ncx_getn_double_int(const void **xpp, size_t nelems, int *tp)
 {
-#line 2783
-#if _SX && X_SIZEOF_SHORT == SIZEOF_SHORT
-#line 2783
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2783
  /* basic algorithm is:
-#line 2783
-  *   - ensure sane alignment of output data
-#line 2783
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2783
   *     to output
-#line 2783
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2783
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2783
   */
-#line 2783
   long i, j, ni;
-#line 2783
-  short tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2783
-  short *xp;
-#line 2783
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2783
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2783
   long cxp = (long) *((char**)xpp);
-#line 2783
 
-#line 2783
-  realign = (cxp & 7) % SIZEOF_SHORT;
-#line 2783
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2783
    * vector work space reserved to LOOPCNT elements. Also
-#line 2783
    * makes vectorisation easy */
-#line 2783
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2783
     ni=Min(nelems-j,LOOPCNT);
-#line 2783
     if (realign) {
-#line 2783
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
       xp = tmp;
-#line 2783
     } else {
-#line 2783
-      xp = (short *) *xpp;
-#line 2783
-    }
-#line 2783
-   /* copy the next block */
-#line 2783
-#pragma cdir loopcnt=LOOPCNT
-#line 2783
-#pragma cdir shortloop
-#line 2783
-    for (i=0; i<ni; i++) {
-#line 2783
-      /* the normal case: */
-#line 2783
-      xp[i] = (short) Max( X_SHORT_MIN, Min(X_SHORT_MAX, (short) tp[i]));
-#line 2783
-     /* test for range errors (not always needed but do it anyway) */
-#line 2783
-      nrange += tp[i] < X_SHORT_MIN || tp[i] > X_SHORT_MAX;
-#line 2783
-    }
-#line 2783
-   /* copy workspace back if necessary */
-#line 2783
-    if (realign) {
-#line 2783
-      memcpy(*xpp, tmp, ni*X_SIZEOF_SHORT);
-#line 2783
-      xp = (short *) *xpp;
-#line 2783
-    }
-#line 2783
-   /* update xpp and tp */
-#line 2783
-    xp += ni;
-#line 2783
-    tp += ni;
-#line 2783
-    *xpp = (void*)xp;
-#line 2783
-  }
-#line 2783
-  return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2783
-
-#line 2783
-#else   /* not SX */
-#line 2783
-
-#line 2783
-	char *xp = (char *) *xpp;
-#line 2783
-	int status = ENOERR;
-#line 2783
-
-#line 2783
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2783
-	{
-#line 2783
-		int lstatus = ncx_put_short_ulonglong(xp, tp);
-#line 2783
-		if(lstatus != ENOERR)
-#line 2783
-			status = lstatus;
-#line 2783
-	}
-#line 2783
-
-#line 2783
-	*xpp = (void *)xp;
-#line 2783
-	return status;
-#line 2783
-#endif
-#line 2783
-}
-#line 2783
-
-
-int
-#line 2785
-ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *tp)
-#line 2785
-{
-#line 2785
-	const size_t rndup = nelems % 2;
-#line 2785
-
-#line 2785
-	char *xp = (char *) *xpp;
-#line 2785
-	int status = ENOERR;
-#line 2785
-
-#line 2785
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2785
-	{
-#line 2785
-		int lstatus = ncx_put_short_schar(xp, tp);
-#line 2785
-		if(lstatus != ENOERR)
-#line 2785
-			status = lstatus;
-#line 2785
-	}
-#line 2785
-
-#line 2785
-	if(rndup != 0)
-#line 2785
-	{
-#line 2785
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2785
-		xp += X_SIZEOF_SHORT;
-#line 2785
-	}
-#line 2785
-
-#line 2785
-	*xpp = (void *)xp;
-#line 2785
-	return status;
-#line 2785
-}
-#line 2785
-
-int
-#line 2786
-ncx_pad_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp)
-#line 2786
-{
-#line 2786
-	const size_t rndup = nelems % 2;
-#line 2786
-
-#line 2786
-	char *xp = (char *) *xpp;
-#line 2786
-	int status = ENOERR;
-#line 2786
-
-#line 2786
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2786
-	{
-#line 2786
-		int lstatus = ncx_put_short_uchar(xp, tp);
-#line 2786
-		if(lstatus != ENOERR)
-#line 2786
-			status = lstatus;
-#line 2786
-	}
-#line 2786
-
-#line 2786
-	if(rndup != 0)
-#line 2786
-	{
-#line 2786
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2786
-		xp += X_SIZEOF_SHORT;
-#line 2786
-	}
-#line 2786
-
-#line 2786
-	*xpp = (void *)xp;
-#line 2786
-	return status;
-#line 2786
-}
-#line 2786
-
-int
-#line 2787
-ncx_pad_putn_short_short(void **xpp, size_t nelems, const short *tp)
-#line 2787
-{
-#line 2787
-	const size_t rndup = nelems % 2;
-#line 2787
-
-#line 2787
-	char *xp = (char *) *xpp;
-#line 2787
-	int status = ENOERR;
-#line 2787
-
-#line 2787
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2787
-	{
-#line 2787
-		int lstatus = ncx_put_short_short(xp, tp);
-#line 2787
-		if(lstatus != ENOERR)
-#line 2787
-			status = lstatus;
-#line 2787
-	}
-#line 2787
-
-#line 2787
-	if(rndup != 0)
-#line 2787
-	{
-#line 2787
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2787
-		xp += X_SIZEOF_SHORT;
-#line 2787
-	}
-#line 2787
-
-#line 2787
-	*xpp = (void *)xp;
-#line 2787
-	return status;
-#line 2787
-}
-#line 2787
-
-int
-#line 2788
-ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *tp)
-#line 2788
-{
-#line 2788
-	const size_t rndup = nelems % 2;
-#line 2788
-
-#line 2788
-	char *xp = (char *) *xpp;
-#line 2788
-	int status = ENOERR;
-#line 2788
-
-#line 2788
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2788
-	{
-#line 2788
-		int lstatus = ncx_put_short_int(xp, tp);
-#line 2788
-		if(lstatus != ENOERR)
-#line 2788
-			status = lstatus;
-#line 2788
-	}
-#line 2788
-
-#line 2788
-	if(rndup != 0)
-#line 2788
-	{
-#line 2788
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2788
-		xp += X_SIZEOF_SHORT;
-#line 2788
-	}
-#line 2788
-
-#line 2788
-	*xpp = (void *)xp;
-#line 2788
-	return status;
-#line 2788
-}
-#line 2788
-
-int
-#line 2789
-ncx_pad_putn_short_float(void **xpp, size_t nelems, const float *tp)
-#line 2789
-{
-#line 2789
-	const size_t rndup = nelems % 2;
-#line 2789
+      xp = (double *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (double *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-#line 2789
-	char *xp = (char *) *xpp;
-#line 2789
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2789
 
-#line 2789
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2789
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2789
-		int lstatus = ncx_put_short_float(xp, tp);
-#line 2789
+		const int lstatus = ncx_get_double_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2789
 			status = lstatus;
-#line 2789
-	}
-#line 2789
-
-#line 2789
-	if(rndup != 0)
-#line 2789
-	{
-#line 2789
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2789
-		xp += X_SIZEOF_SHORT;
-#line 2789
 	}
-#line 2789
 
-#line 2789
-	*xpp = (void *)xp;
-#line 2789
+	*xpp = (const void *)xp;
 	return status;
-#line 2789
+#  endif
 }
-#line 2789
 
 int
-#line 2790
-ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *tp)
-#line 2790
+ncx_getn_double_float(const void **xpp, size_t nelems, float *tp)
 {
-#line 2790
-	const size_t rndup = nelems % 2;
-#line 2790
-
-#line 2790
-	char *xp = (char *) *xpp;
-#line 2790
-	int status = ENOERR;
-#line 2790
-
-#line 2790
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2790
-	{
-#line 2790
-		int lstatus = ncx_put_short_double(xp, tp);
-#line 2790
-		if(lstatus != ENOERR)
-#line 2790
-			status = lstatus;
-#line 2790
-	}
-#line 2790
-
-#line 2790
-	if(rndup != 0)
-#line 2790
-	{
-#line 2790
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2790
-		xp += X_SIZEOF_SHORT;
-#line 2790
-	}
-#line 2790
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2790
-	*xpp = (void *)xp;
-#line 2790
-	return status;
-#line 2790
-}
-#line 2790
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
 
-int
-#line 2791
-ncx_pad_putn_short_uint(void **xpp, size_t nelems, const uint *tp)
-#line 2791
-{
-#line 2791
-	const size_t rndup = nelems % 2;
-#line 2791
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
+      xp = tmp;
+    } else {
+      xp = (double *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (double *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-#line 2791
-	char *xp = (char *) *xpp;
-#line 2791
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2791
 
-#line 2791
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2791
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2791
-		int lstatus = ncx_put_short_uint(xp, tp);
-#line 2791
+		const int lstatus = ncx_get_double_float(xp, tp);
 		if(lstatus != ENOERR)
-#line 2791
 			status = lstatus;
-#line 2791
-	}
-#line 2791
-
-#line 2791
-	if(rndup != 0)
-#line 2791
-	{
-#line 2791
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2791
-		xp += X_SIZEOF_SHORT;
-#line 2791
 	}
-#line 2791
 
-#line 2791
-	*xpp = (void *)xp;
-#line 2791
+	*xpp = (const void *)xp;
 	return status;
-#line 2791
+#  endif
 }
-#line 2791
 
 int
-#line 2792
-ncx_pad_putn_short_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 2792
+ncx_getn_double_longlong(const void **xpp, size_t nelems, longlong *tp)
 {
-#line 2792
-	const size_t rndup = nelems % 2;
-#line 2792
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2792
-	char *xp = (char *) *xpp;
-#line 2792
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
+      xp = tmp;
+    } else {
+      xp = (double *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (double *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2792
 
-#line 2792
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2792
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2792
-		int lstatus = ncx_put_short_longlong(xp, tp);
-#line 2792
+		const int lstatus = ncx_get_double_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2792
 			status = lstatus;
-#line 2792
-	}
-#line 2792
-
-#line 2792
-	if(rndup != 0)
-#line 2792
-	{
-#line 2792
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2792
-		xp += X_SIZEOF_SHORT;
-#line 2792
 	}
-#line 2792
 
-#line 2792
-	*xpp = (void *)xp;
-#line 2792
+	*xpp = (const void *)xp;
 	return status;
-#line 2792
+#  endif
 }
-#line 2792
 
 int
-#line 2793
-ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 2793
+ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
-#line 2793
-	const size_t rndup = nelems % 2;
-#line 2793
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2793
-	char *xp = (char *) *xpp;
-#line 2793
+ /* basic algorithm is:
+  *   - ensure sane alignment of input data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update xpp to point at next unconverted input, and tp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
+      xp = tmp;
+    } else {
+      xp = (double *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
+    }
+   /* update xpp and tp */
+    if (realign) xp = (double *) *xpp;
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
+
+#else   /* not SX */
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2793
 
-#line 2793
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
-#line 2793
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2793
-		int lstatus = ncx_put_short_ulonglong(xp, tp);
-#line 2793
+		const int lstatus = ncx_get_double_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2793
 			status = lstatus;
-#line 2793
-	}
-#line 2793
-
-#line 2793
-	if(rndup != 0)
-#line 2793
-	{
-#line 2793
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-#line 2793
-		xp += X_SIZEOF_SHORT;
-#line 2793
 	}
-#line 2793
 
-#line 2793
-	*xpp = (void *)xp;
-#line 2793
+	*xpp = (const void *)xp;
 	return status;
-#line 2793
+#  endif
 }
-#line 2793
-
-
-
-/* int */
 
 int
-#line 2798
-ncx_getn_int_schar(const void **xpp, size_t nelems, schar *tp)
-#line 2798
+ncx_getn_double_ushort(const void **xpp, size_t nelems, ushort *tp)
 {
-#line 2798
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2798
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2798
  /* basic algorithm is:
-#line 2798
   *   - ensure sane alignment of input data
-#line 2798
   *   - copy (conversion happens automatically) input data
-#line 2798
   *     to output
-#line 2798
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2798
   *     at next location for converted output
-#line 2798
   */
-#line 2798
   long i, j, ni;
-#line 2798
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2798
-  int *xp;
-#line 2798
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2798
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2798
   long cxp = (long) *((char**)xpp);
-#line 2798
 
-#line 2798
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2798
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2798
    * vector work space reserved to LOOPCNT elements. Also
-#line 2798
    * makes vectorisation easy */
-#line 2798
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2798
     ni=Min(nelems-j,LOOPCNT);
-#line 2798
     if (realign) {
-#line 2798
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2798
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
       xp = tmp;
-#line 2798
     } else {
-#line 2798
-      xp = (int *) *xpp;
-#line 2798
+      xp = (double *) *xpp;
     }
-#line 2798
    /* copy the next block */
-#line 2798
 #pragma cdir loopcnt=LOOPCNT
-#line 2798
 #pragma cdir shortloop
-#line 2798
     for (i=0; i<ni; i++) {
-#line 2798
-      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 2798
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2798
-      nrange += xp[i] < SCHAR_MIN || xp[i] > SCHAR_MAX;
-#line 2798
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX || xp[i] < 0;
     }
-#line 2798
    /* update xpp and tp */
-#line 2798
-    if (realign) xp = (int *) *xpp;
-#line 2798
+    if (realign) xp = (double *) *xpp;
     xp += ni;
-#line 2798
     tp += ni;
-#line 2798
     *xpp = (void*)xp;
-#line 2798
   }
-#line 2798
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2798
 
-#line 2798
 #else   /* not SX */
-#line 2798
 	const char *xp = (const char *) *xpp;
-#line 2798
 	int status = ENOERR;
-#line 2798
 
-#line 2798
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2798
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2798
-		const int lstatus = ncx_get_int_schar(xp, tp);
-#line 2798
+		const int lstatus = ncx_get_double_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2798
 			status = lstatus;
-#line 2798
 	}
-#line 2798
 
-#line 2798
 	*xpp = (const void *)xp;
-#line 2798
 	return status;
-#line 2798
 #  endif
-#line 2798
 }
-#line 2798
 
 int
-#line 2799
-ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2799
+ncx_getn_double_uint(const void **xpp, size_t nelems, uint *tp)
 {
-#line 2799
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2799
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2799
  /* basic algorithm is:
-#line 2799
   *   - ensure sane alignment of input data
-#line 2799
   *   - copy (conversion happens automatically) input data
-#line 2799
   *     to output
-#line 2799
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2799
   *     at next location for converted output
-#line 2799
   */
-#line 2799
   long i, j, ni;
-#line 2799
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2799
-  int *xp;
-#line 2799
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2799
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2799
   long cxp = (long) *((char**)xpp);
-#line 2799
 
-#line 2799
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2799
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2799
    * vector work space reserved to LOOPCNT elements. Also
-#line 2799
    * makes vectorisation easy */
-#line 2799
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2799
     ni=Min(nelems-j,LOOPCNT);
-#line 2799
     if (realign) {
-#line 2799
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2799
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
       xp = tmp;
-#line 2799
     } else {
-#line 2799
-      xp = (int *) *xpp;
-#line 2799
+      xp = (double *) *xpp;
     }
-#line 2799
    /* copy the next block */
-#line 2799
 #pragma cdir loopcnt=LOOPCNT
-#line 2799
 #pragma cdir shortloop
-#line 2799
     for (i=0; i<ni; i++) {
-#line 2799
-      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 2799
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2799
-      nrange += xp[i] < UCHAR_MIN || xp[i] > UCHAR_MAX;
-#line 2799
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX || xp[i] < 0;
     }
-#line 2799
    /* update xpp and tp */
-#line 2799
-    if (realign) xp = (int *) *xpp;
-#line 2799
+    if (realign) xp = (double *) *xpp;
     xp += ni;
-#line 2799
     tp += ni;
-#line 2799
     *xpp = (void*)xp;
-#line 2799
   }
-#line 2799
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2799
 
-#line 2799
 #else   /* not SX */
-#line 2799
 	const char *xp = (const char *) *xpp;
-#line 2799
 	int status = ENOERR;
-#line 2799
 
-#line 2799
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2799
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2799
-		const int lstatus = ncx_get_int_uchar(xp, tp);
-#line 2799
+		const int lstatus = ncx_get_double_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2799
 			status = lstatus;
-#line 2799
 	}
-#line 2799
 
-#line 2799
 	*xpp = (const void *)xp;
-#line 2799
 	return status;
-#line 2799
 #  endif
-#line 2799
 }
-#line 2799
 
 int
-#line 2800
-ncx_getn_int_short(const void **xpp, size_t nelems, short *tp)
-#line 2800
+ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
 {
-#line 2800
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2800
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2800
  /* basic algorithm is:
-#line 2800
   *   - ensure sane alignment of input data
-#line 2800
   *   - copy (conversion happens automatically) input data
-#line 2800
   *     to output
-#line 2800
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2800
   *     at next location for converted output
-#line 2800
   */
-#line 2800
   long i, j, ni;
-#line 2800
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2800
-  int *xp;
-#line 2800
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2800
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2800
   long cxp = (long) *((char**)xpp);
-#line 2800
 
-#line 2800
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2800
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2800
    * vector work space reserved to LOOPCNT elements. Also
-#line 2800
    * makes vectorisation easy */
-#line 2800
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2800
     ni=Min(nelems-j,LOOPCNT);
-#line 2800
     if (realign) {
-#line 2800
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2800
+      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
       xp = tmp;
-#line 2800
     } else {
-#line 2800
-      xp = (int *) *xpp;
-#line 2800
+      xp = (double *) *xpp;
     }
-#line 2800
    /* copy the next block */
-#line 2800
 #pragma cdir loopcnt=LOOPCNT
-#line 2800
 #pragma cdir shortloop
-#line 2800
     for (i=0; i<ni; i++) {
-#line 2800
-      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 2800
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2800
-      nrange += xp[i] < SHORT_MIN || xp[i] > SHORT_MAX;
-#line 2800
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
     }
-#line 2800
    /* update xpp and tp */
-#line 2800
-    if (realign) xp = (int *) *xpp;
-#line 2800
+    if (realign) xp = (double *) *xpp;
     xp += ni;
-#line 2800
     tp += ni;
-#line 2800
     *xpp = (void*)xp;
-#line 2800
   }
-#line 2800
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2800
 
-#line 2800
 #else   /* not SX */
-#line 2800
 	const char *xp = (const char *) *xpp;
-#line 2800
 	int status = ENOERR;
-#line 2800
 
-#line 2800
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2800
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2800
-		const int lstatus = ncx_get_int_short(xp, tp);
-#line 2800
+		const int lstatus = ncx_get_double_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2800
 			status = lstatus;
-#line 2800
 	}
-#line 2800
 
-#line 2800
 	*xpp = (const void *)xp;
-#line 2800
 	return status;
-#line 2800
 #  endif
-#line 2800
 }
-#line 2800
 
-#if X_SIZEOF_INT == SIZEOF_INT
+
+#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
 /* optimized version */
 int
-ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
+ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
 {
 #ifdef WORDS_BIGENDIAN
-	(void) memcpy(tp, *xpp, nelems * sizeof(int));
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_DOUBLE);
 # else
-	swapn4b(tp, *xpp, nelems);
+	swapn8b(*xpp, tp, nelems);
 # endif
-	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
 	return ENOERR;
 }
+#elif vax
 int
-ncx_getn_int_uint(const void **xpp, size_t nelems, unsigned int *tp)
+ncx_putn_double_double(void **xpp, size_t ndoubles, const double *ip)
 {
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(tp, *xpp, nelems * sizeof(int));
-# else
-	swapn4b(tp, *xpp, nelems);
-# endif
-	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
+	const double *const end = ip + ndoubles;
+
+	while(ip < end)
+	{
+	const struct vax_double *const vdp =
+			(const struct vax_double *)ip;
+	struct ieee_double *const idp =
+			 (struct ieee_double *) (*xpp);
+
+	if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
+		(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
+		(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
+		(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
+		(vdp->exp == dbl_limits[0].d.exp))
+	{
+		*idp = dbl_limits[0].ieee;
+		goto shipit;
+	}
+	if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
+		(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
+		(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
+		(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
+		(vdp->exp == dbl_limits[1].d.exp))
+	{
+		*idp = dbl_limits[1].ieee;
+		goto shipit;
+	}
+
+	{
+		unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
+
+		unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
+			(vdp->mantissa3 << 13) |
+			((vdp->mantissa4 >> 3) & MASK(13));
+
+		unsigned mant_hi = (vdp->mantissa1 << 13)
+				 | (vdp->mantissa2 >> 3);
+
+		if((vdp->mantissa4 & 7) > 4)
+		{
+			/* round up */
+			mant_lo++;
+			if(mant_lo == 0)
+			{
+				mant_hi++;
+				if(mant_hi > 0xffffff)
+				{
+					mant_hi = 0;
+					exp++;
+				}
+			}
+		}
+
+		idp->mant_lo = SWAP4(mant_lo);
+		idp->mant_6 = mant_hi >> 16;
+		idp->mant_5 = (mant_hi & 0xff00) >> 8;
+		idp->mant_4 = mant_hi;
+		idp->exp_hi = exp >> 4;
+		idp->exp_lo = exp;
+	}
+
+	shipit:
+		idp->sign = vdp->sign;
+
+		ip++;
+		*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
+	}
 	return ENOERR;
 }
+	/* vax */
 #else
 int
-#line 2826
-ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
-#line 2826
+ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
 {
-#line 2826
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2826
+	char *xp = *xpp;
+	int status = ENOERR;
+
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
+	{
+		int lstatus = ncx_put_double_double(xp, tp);
+		if(lstatus != ENOERR)
+			status = lstatus;
+	}
+
+	*xpp = (void *)xp;
+	return status;
+}
+#endif
+int
+ncx_putn_double_schar(void **xpp, size_t nelems, const schar *tp)
+{
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2826
  /* basic algorithm is:
-#line 2826
-  *   - ensure sane alignment of input data
-#line 2826
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2826
   *     to output
-#line 2826
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2826
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2826
   */
-#line 2826
   long i, j, ni;
-#line 2826
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2826
-  int *xp;
-#line 2826
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2826
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2826
   long cxp = (long) *((char**)xpp);
-#line 2826
 
-#line 2826
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2826
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2826
    * vector work space reserved to LOOPCNT elements. Also
-#line 2826
    * makes vectorisation easy */
-#line 2826
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2826
     ni=Min(nelems-j,LOOPCNT);
-#line 2826
     if (realign) {
-#line 2826
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2826
       xp = tmp;
-#line 2826
     } else {
-#line 2826
-      xp = (int *) *xpp;
-#line 2826
+      xp = (double *) *xpp;
     }
-#line 2826
    /* copy the next block */
-#line 2826
 #pragma cdir loopcnt=LOOPCNT
-#line 2826
 #pragma cdir shortloop
-#line 2826
     for (i=0; i<ni; i++) {
-#line 2826
-      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 2826
+      /* the normal case: */
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2826
-      nrange += xp[i] < INT_MIN || xp[i] > INT_MAX;
-#line 2826
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2826
    /* update xpp and tp */
-#line 2826
-    if (realign) xp = (int *) *xpp;
-#line 2826
     xp += ni;
-#line 2826
     tp += ni;
-#line 2826
     *xpp = (void*)xp;
-#line 2826
   }
-#line 2826
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2826
 
-#line 2826
 #else   /* not SX */
-#line 2826
-	const char *xp = (const char *) *xpp;
-#line 2826
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2826
 
-#line 2826
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2826
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2826
-		const int lstatus = ncx_get_int_int(xp, tp);
-#line 2826
+		int lstatus = ncx_put_double_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2826
 			status = lstatus;
-#line 2826
 	}
-#line 2826
 
-#line 2826
-	*xpp = (const void *)xp;
-#line 2826
+	*xpp = (void *)xp;
 	return status;
-#line 2826
-#  endif
-#line 2826
+#endif
 }
-#line 2826
 
 int
-#line 2827
-ncx_getn_int_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2827
+ncx_putn_double_short(void **xpp, size_t nelems, const short *tp)
 {
-#line 2827
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2827
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2827
  /* basic algorithm is:
-#line 2827
-  *   - ensure sane alignment of input data
-#line 2827
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2827
   *     to output
-#line 2827
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2827
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2827
   */
-#line 2827
   long i, j, ni;
-#line 2827
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2827
-  int *xp;
-#line 2827
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2827
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2827
   long cxp = (long) *((char**)xpp);
-#line 2827
 
-#line 2827
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2827
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2827
    * vector work space reserved to LOOPCNT elements. Also
-#line 2827
    * makes vectorisation easy */
-#line 2827
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2827
     ni=Min(nelems-j,LOOPCNT);
-#line 2827
     if (realign) {
-#line 2827
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2827
       xp = tmp;
-#line 2827
     } else {
-#line 2827
-      xp = (int *) *xpp;
-#line 2827
+      xp = (double *) *xpp;
     }
-#line 2827
    /* copy the next block */
-#line 2827
 #pragma cdir loopcnt=LOOPCNT
-#line 2827
 #pragma cdir shortloop
-#line 2827
     for (i=0; i<ni; i++) {
-#line 2827
-      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 2827
+      /* the normal case: */
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2827
-      nrange += xp[i] < UINT_MIN || xp[i] > UINT_MAX;
-#line 2827
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2827
    /* update xpp and tp */
-#line 2827
-    if (realign) xp = (int *) *xpp;
-#line 2827
     xp += ni;
-#line 2827
     tp += ni;
-#line 2827
     *xpp = (void*)xp;
-#line 2827
   }
-#line 2827
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2827
 
-#line 2827
 #else   /* not SX */
-#line 2827
-	const char *xp = (const char *) *xpp;
-#line 2827
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2827
 
-#line 2827
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2827
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2827
-		const int lstatus = ncx_get_int_uint(xp, tp);
-#line 2827
+		int lstatus = ncx_put_double_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 2827
 			status = lstatus;
-#line 2827
 	}
-#line 2827
 
-#line 2827
-	*xpp = (const void *)xp;
-#line 2827
+	*xpp = (void *)xp;
 	return status;
-#line 2827
-#  endif
-#line 2827
-}
-#line 2827
-
 #endif
+}
 
 int
-#line 2830
-ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2830
+ncx_putn_double_int(void **xpp, size_t nelems, const int *tp)
 {
-#line 2830
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2830
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2830
  /* basic algorithm is:
-#line 2830
-  *   - ensure sane alignment of input data
-#line 2830
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2830
   *     to output
-#line 2830
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2830
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2830
   */
-#line 2830
   long i, j, ni;
-#line 2830
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2830
-  int *xp;
-#line 2830
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2830
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2830
   long cxp = (long) *((char**)xpp);
-#line 2830
 
-#line 2830
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2830
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2830
    * vector work space reserved to LOOPCNT elements. Also
-#line 2830
    * makes vectorisation easy */
-#line 2830
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2830
     ni=Min(nelems-j,LOOPCNT);
-#line 2830
     if (realign) {
-#line 2830
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2830
       xp = tmp;
-#line 2830
     } else {
-#line 2830
-      xp = (int *) *xpp;
-#line 2830
+      xp = (double *) *xpp;
     }
-#line 2830
    /* copy the next block */
-#line 2830
 #pragma cdir loopcnt=LOOPCNT
-#line 2830
 #pragma cdir shortloop
-#line 2830
     for (i=0; i<ni; i++) {
-#line 2830
-      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 2830
+      /* the normal case: */
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2830
-      nrange += xp[i] < LONGLONG_MIN || xp[i] > LONGLONG_MAX;
-#line 2830
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2830
    /* update xpp and tp */
-#line 2830
-    if (realign) xp = (int *) *xpp;
-#line 2830
     xp += ni;
-#line 2830
     tp += ni;
-#line 2830
     *xpp = (void*)xp;
-#line 2830
   }
-#line 2830
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2830
 
-#line 2830
 #else   /* not SX */
-#line 2830
-	const char *xp = (const char *) *xpp;
-#line 2830
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2830
 
-#line 2830
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2830
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2830
-		const int lstatus = ncx_get_int_longlong(xp, tp);
-#line 2830
+		int lstatus = ncx_put_double_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2830
 			status = lstatus;
-#line 2830
 	}
-#line 2830
 
-#line 2830
-	*xpp = (const void *)xp;
-#line 2830
+	*xpp = (void *)xp;
 	return status;
-#line 2830
-#  endif
-#line 2830
+#endif
 }
-#line 2830
 
 int
-#line 2831
-ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2831
+ncx_putn_double_float(void **xpp, size_t nelems, const float *tp)
 {
-#line 2831
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2831
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2831
  /* basic algorithm is:
-#line 2831
-  *   - ensure sane alignment of input data
-#line 2831
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2831
   *     to output
-#line 2831
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2831
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2831
   */
-#line 2831
   long i, j, ni;
-#line 2831
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2831
-  int *xp;
-#line 2831
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2831
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2831
   long cxp = (long) *((char**)xpp);
-#line 2831
 
-#line 2831
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2831
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2831
    * vector work space reserved to LOOPCNT elements. Also
-#line 2831
    * makes vectorisation easy */
-#line 2831
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2831
     ni=Min(nelems-j,LOOPCNT);
-#line 2831
     if (realign) {
-#line 2831
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2831
       xp = tmp;
-#line 2831
     } else {
-#line 2831
-      xp = (int *) *xpp;
-#line 2831
+      xp = (double *) *xpp;
     }
-#line 2831
    /* copy the next block */
-#line 2831
 #pragma cdir loopcnt=LOOPCNT
-#line 2831
 #pragma cdir shortloop
-#line 2831
     for (i=0; i<ni; i++) {
-#line 2831
-      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 2831
+      /* the normal case: */
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2831
-      nrange += xp[i] < ULONGLONG_MIN || xp[i] > ULONGLONG_MAX;
-#line 2831
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2831
    /* update xpp and tp */
-#line 2831
-    if (realign) xp = (int *) *xpp;
-#line 2831
     xp += ni;
-#line 2831
     tp += ni;
-#line 2831
     *xpp = (void*)xp;
-#line 2831
   }
-#line 2831
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2831
 
-#line 2831
 #else   /* not SX */
-#line 2831
-	const char *xp = (const char *) *xpp;
-#line 2831
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2831
 
-#line 2831
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2831
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2831
-		const int lstatus = ncx_get_int_ulonglong(xp, tp);
-#line 2831
+		int lstatus = ncx_put_double_float(xp, tp);
 		if(lstatus != ENOERR)
-#line 2831
 			status = lstatus;
-#line 2831
 	}
-#line 2831
 
-#line 2831
-	*xpp = (const void *)xp;
-#line 2831
+	*xpp = (void *)xp;
 	return status;
-#line 2831
-#  endif
-#line 2831
+#endif
 }
-#line 2831
-
 
 int
-#line 2833
-ncx_getn_int_float(const void **xpp, size_t nelems, float *tp)
-#line 2833
+ncx_putn_double_longlong(void **xpp, size_t nelems, const longlong *tp)
 {
-#line 2833
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2833
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2833
  /* basic algorithm is:
-#line 2833
-  *   - ensure sane alignment of input data
-#line 2833
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2833
   *     to output
-#line 2833
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2833
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2833
   */
-#line 2833
   long i, j, ni;
-#line 2833
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2833
-  int *xp;
-#line 2833
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2833
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2833
   long cxp = (long) *((char**)xpp);
-#line 2833
 
-#line 2833
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2833
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2833
    * vector work space reserved to LOOPCNT elements. Also
-#line 2833
    * makes vectorisation easy */
-#line 2833
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2833
     ni=Min(nelems-j,LOOPCNT);
-#line 2833
     if (realign) {
-#line 2833
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2833
       xp = tmp;
-#line 2833
     } else {
-#line 2833
-      xp = (int *) *xpp;
-#line 2833
+      xp = (double *) *xpp;
     }
-#line 2833
    /* copy the next block */
-#line 2833
 #pragma cdir loopcnt=LOOPCNT
-#line 2833
 #pragma cdir shortloop
-#line 2833
     for (i=0; i<ni; i++) {
-#line 2833
-      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 2833
+      /* the normal case: */
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2833
-      nrange += xp[i] < FLOAT_MIN || xp[i] > FLOAT_MAX;
-#line 2833
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX || tp[i] < X_DOUBLE_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2833
    /* update xpp and tp */
-#line 2833
-    if (realign) xp = (int *) *xpp;
-#line 2833
     xp += ni;
-#line 2833
     tp += ni;
-#line 2833
     *xpp = (void*)xp;
-#line 2833
   }
-#line 2833
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2833
 
-#line 2833
 #else   /* not SX */
-#line 2833
-	const char *xp = (const char *) *xpp;
-#line 2833
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2833
 
-#line 2833
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2833
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2833
-		const int lstatus = ncx_get_int_float(xp, tp);
-#line 2833
+		int lstatus = ncx_put_double_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2833
 			status = lstatus;
-#line 2833
 	}
-#line 2833
 
-#line 2833
-	*xpp = (const void *)xp;
-#line 2833
+	*xpp = (void *)xp;
 	return status;
-#line 2833
-#  endif
-#line 2833
+#endif
 }
-#line 2833
 
 int
-#line 2834
-ncx_getn_int_double(const void **xpp, size_t nelems, double *tp)
-#line 2834
+ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *tp)
 {
-#line 2834
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2834
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2834
  /* basic algorithm is:
-#line 2834
-  *   - ensure sane alignment of input data
-#line 2834
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2834
   *     to output
-#line 2834
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2834
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2834
   */
-#line 2834
   long i, j, ni;
-#line 2834
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2834
-  int *xp;
-#line 2834
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2834
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2834
   long cxp = (long) *((char**)xpp);
-#line 2834
 
-#line 2834
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2834
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2834
    * vector work space reserved to LOOPCNT elements. Also
-#line 2834
    * makes vectorisation easy */
-#line 2834
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2834
     ni=Min(nelems-j,LOOPCNT);
-#line 2834
     if (realign) {
-#line 2834
-      memcpy(tmp, *xpp, ni*SIZEOF_INT);
-#line 2834
       xp = tmp;
-#line 2834
     } else {
-#line 2834
-      xp = (int *) *xpp;
-#line 2834
+      xp = (double *) *xpp;
     }
-#line 2834
    /* copy the next block */
-#line 2834
 #pragma cdir loopcnt=LOOPCNT
-#line 2834
 #pragma cdir shortloop
-#line 2834
     for (i=0; i<ni; i++) {
-#line 2834
-      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 2834
+      /* the normal case: */
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2834
-      nrange += xp[i] < DOUBLE_MIN || xp[i] > DOUBLE_MAX;
-#line 2834
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2834
    /* update xpp and tp */
-#line 2834
-    if (realign) xp = (int *) *xpp;
-#line 2834
     xp += ni;
-#line 2834
     tp += ni;
-#line 2834
     *xpp = (void*)xp;
-#line 2834
   }
-#line 2834
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2834
 
-#line 2834
 #else   /* not SX */
-#line 2834
-	const char *xp = (const char *) *xpp;
-#line 2834
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2834
 
-#line 2834
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2834
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2834
-		const int lstatus = ncx_get_int_double(xp, tp);
-#line 2834
+		int lstatus = ncx_put_double_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2834
 			status = lstatus;
-#line 2834
 	}
-#line 2834
 
-#line 2834
-	*xpp = (const void *)xp;
-#line 2834
+	*xpp = (void *)xp;
 	return status;
-#line 2834
-#  endif
-#line 2834
+#endif
 }
-#line 2834
-
 
 int
-#line 2836
-ncx_putn_int_schar(void **xpp, size_t nelems, const schar *tp)
-#line 2836
+ncx_putn_double_ushort(void **xpp, size_t nelems, const ushort *tp)
 {
-#line 2836
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2836
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2836
  /* basic algorithm is:
-#line 2836
   *   - ensure sane alignment of output data
-#line 2836
   *   - copy (conversion happens automatically) input data
-#line 2836
   *     to output
-#line 2836
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2836
   *     at next location for converted output
-#line 2836
   */
-#line 2836
   long i, j, ni;
-#line 2836
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2836
-  int *xp;
-#line 2836
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2836
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2836
   long cxp = (long) *((char**)xpp);
-#line 2836
 
-#line 2836
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2836
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2836
    * vector work space reserved to LOOPCNT elements. Also
-#line 2836
    * makes vectorisation easy */
-#line 2836
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2836
     ni=Min(nelems-j,LOOPCNT);
-#line 2836
     if (realign) {
-#line 2836
       xp = tmp;
-#line 2836
     } else {
-#line 2836
-      xp = (int *) *xpp;
-#line 2836
+      xp = (double *) *xpp;
     }
-#line 2836
    /* copy the next block */
-#line 2836
 #pragma cdir loopcnt=LOOPCNT
-#line 2836
 #pragma cdir shortloop
-#line 2836
     for (i=0; i<ni; i++) {
-#line 2836
       /* the normal case: */
-#line 2836
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2836
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2836
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2836
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX ;
     }
-#line 2836
    /* copy workspace back if necessary */
-#line 2836
     if (realign) {
-#line 2836
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2836
-      xp = (int *) *xpp;
-#line 2836
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2836
    /* update xpp and tp */
-#line 2836
     xp += ni;
-#line 2836
     tp += ni;
-#line 2836
     *xpp = (void*)xp;
-#line 2836
   }
-#line 2836
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2836
 
-#line 2836
 #else   /* not SX */
-#line 2836
 
-#line 2836
 	char *xp = (char *) *xpp;
-#line 2836
 	int status = ENOERR;
-#line 2836
 
-#line 2836
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2836
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2836
-		int lstatus = ncx_put_int_schar(xp, tp);
-#line 2836
+		int lstatus = ncx_put_double_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2836
 			status = lstatus;
-#line 2836
 	}
-#line 2836
 
-#line 2836
 	*xpp = (void *)xp;
-#line 2836
 	return status;
-#line 2836
 #endif
-#line 2836
 }
-#line 2836
 
 int
-#line 2837
-ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *tp)
-#line 2837
+ncx_putn_double_uint(void **xpp, size_t nelems, const uint *tp)
 {
-#line 2837
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2837
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2837
  /* basic algorithm is:
-#line 2837
   *   - ensure sane alignment of output data
-#line 2837
   *   - copy (conversion happens automatically) input data
-#line 2837
   *     to output
-#line 2837
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2837
   *     at next location for converted output
-#line 2837
   */
-#line 2837
   long i, j, ni;
-#line 2837
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2837
-  int *xp;
-#line 2837
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2837
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2837
   long cxp = (long) *((char**)xpp);
-#line 2837
 
-#line 2837
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2837
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2837
    * vector work space reserved to LOOPCNT elements. Also
-#line 2837
    * makes vectorisation easy */
-#line 2837
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2837
     ni=Min(nelems-j,LOOPCNT);
-#line 2837
     if (realign) {
-#line 2837
       xp = tmp;
-#line 2837
     } else {
-#line 2837
-      xp = (int *) *xpp;
-#line 2837
+      xp = (double *) *xpp;
     }
-#line 2837
    /* copy the next block */
-#line 2837
 #pragma cdir loopcnt=LOOPCNT
-#line 2837
 #pragma cdir shortloop
-#line 2837
     for (i=0; i<ni; i++) {
-#line 2837
       /* the normal case: */
-#line 2837
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2837
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2837
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2837
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX ;
     }
-#line 2837
    /* copy workspace back if necessary */
-#line 2837
     if (realign) {
-#line 2837
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2837
-      xp = (int *) *xpp;
-#line 2837
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2837
    /* update xpp and tp */
-#line 2837
     xp += ni;
-#line 2837
     tp += ni;
-#line 2837
     *xpp = (void*)xp;
-#line 2837
   }
-#line 2837
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2837
 
-#line 2837
 #else   /* not SX */
-#line 2837
 
-#line 2837
 	char *xp = (char *) *xpp;
-#line 2837
 	int status = ENOERR;
-#line 2837
 
-#line 2837
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2837
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2837
-		int lstatus = ncx_put_int_uchar(xp, tp);
-#line 2837
+		int lstatus = ncx_put_double_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2837
 			status = lstatus;
-#line 2837
 	}
-#line 2837
 
-#line 2837
 	*xpp = (void *)xp;
-#line 2837
 	return status;
-#line 2837
 #endif
-#line 2837
 }
-#line 2837
 
 int
-#line 2838
-ncx_putn_int_short(void **xpp, size_t nelems, const short *tp)
-#line 2838
+ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
 {
-#line 2838
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2838
+#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
 
-#line 2838
  /* basic algorithm is:
-#line 2838
   *   - ensure sane alignment of output data
-#line 2838
   *   - copy (conversion happens automatically) input data
-#line 2838
   *     to output
-#line 2838
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2838
   *     at next location for converted output
-#line 2838
   */
-#line 2838
   long i, j, ni;
-#line 2838
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2838
-  int *xp;
-#line 2838
+  double tmp[LOOPCNT];        /* in case input is misaligned */
+  double *xp;
   int nrange = 0;         /* number of range errors */
-#line 2838
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2838
   long cxp = (long) *((char**)xpp);
-#line 2838
 
-#line 2838
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2838
+  realign = (cxp & 7) % SIZEOF_DOUBLE;
   /* sjl: manually stripmine so we can limit amount of
-#line 2838
    * vector work space reserved to LOOPCNT elements. Also
-#line 2838
    * makes vectorisation easy */
-#line 2838
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2838
     ni=Min(nelems-j,LOOPCNT);
-#line 2838
     if (realign) {
-#line 2838
       xp = tmp;
-#line 2838
     } else {
-#line 2838
-      xp = (int *) *xpp;
-#line 2838
+      xp = (double *) *xpp;
     }
-#line 2838
    /* copy the next block */
-#line 2838
 #pragma cdir loopcnt=LOOPCNT
-#line 2838
 #pragma cdir shortloop
-#line 2838
     for (i=0; i<ni; i++) {
-#line 2838
       /* the normal case: */
-#line 2838
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2838
+      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2838
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2838
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_DOUBLE_MAX ;
     }
-#line 2838
    /* copy workspace back if necessary */
-#line 2838
     if (realign) {
-#line 2838
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2838
-      xp = (int *) *xpp;
-#line 2838
+      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
+      xp = (double *) *xpp;
     }
-#line 2838
    /* update xpp and tp */
-#line 2838
     xp += ni;
-#line 2838
     tp += ni;
-#line 2838
     *xpp = (void*)xp;
-#line 2838
   }
-#line 2838
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2838
 
-#line 2838
 #else   /* not SX */
-#line 2838
 
-#line 2838
 	char *xp = (char *) *xpp;
-#line 2838
 	int status = ENOERR;
-#line 2838
 
-#line 2838
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2838
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
 	{
-#line 2838
-		int lstatus = ncx_put_int_short(xp, tp);
-#line 2838
+		int lstatus = ncx_put_double_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2838
 			status = lstatus;
-#line 2838
 	}
-#line 2838
 
-#line 2838
 	*xpp = (void *)xp;
-#line 2838
 	return status;
-#line 2838
 #endif
-#line 2838
 }
-#line 2838
 
-#if X_SIZEOF_INT == SIZEOF_INT
+
+
+/* longlong -----------------------------------------------------------------------*/
+
+#if X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 /* optimized version */
 int
-ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
-{
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_INT);
-# else
-	swapn4b(*xpp, tp, nelems);
-# endif
-	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
-	return ENOERR;
-}
-int
-ncx_putn_int_uint(void **xpp, size_t nelems, const unsigned int *tp)
+ncx_getn_longlong_longlong(const void **xpp, size_t nelems, long long *tp)
 {
 #ifdef WORDS_BIGENDIAN
-	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_INT);
+	(void) memcpy(tp, *xpp, nelems * sizeof(long long));
 # else
-	swapn4b(*xpp, tp, nelems);
+	swapn8b(tp, *xpp, nelems);
 # endif
-	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_LONGLONG);
 	return ENOERR;
 }
 #else
 int
-#line 2864
-ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
-#line 2864
+ncx_getn_longlong_longlong(const void **xpp, size_t nelems, longlong *tp)
 {
-#line 2864
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2864
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2864
  /* basic algorithm is:
-#line 2864
-  *   - ensure sane alignment of output data
-#line 2864
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2864
   *     to output
-#line 2864
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2864
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2864
   */
-#line 2864
   long i, j, ni;
-#line 2864
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2864
-  int *xp;
-#line 2864
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2864
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2864
   long cxp = (long) *((char**)xpp);
-#line 2864
 
-#line 2864
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2864
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2864
    * vector work space reserved to LOOPCNT elements. Also
-#line 2864
    * makes vectorisation easy */
-#line 2864
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2864
     ni=Min(nelems-j,LOOPCNT);
-#line 2864
     if (realign) {
-#line 2864
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2864
     } else {
-#line 2864
-      xp = (int *) *xpp;
-#line 2864
+      xp = (longlong *) *xpp;
     }
-#line 2864
    /* copy the next block */
-#line 2864
 #pragma cdir loopcnt=LOOPCNT
-#line 2864
 #pragma cdir shortloop
-#line 2864
     for (i=0; i<ni; i++) {
-#line 2864
-      /* the normal case: */
-#line 2864
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2864
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2864
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2864
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX || xp[i] < LONGLONG_MIN;
     }
-#line 2864
-   /* copy workspace back if necessary */
-#line 2864
-    if (realign) {
-#line 2864
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2864
-      xp = (int *) *xpp;
-#line 2864
-    }
-#line 2864
    /* update xpp and tp */
-#line 2864
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2864
     tp += ni;
-#line 2864
     *xpp = (void*)xp;
-#line 2864
   }
-#line 2864
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2864
 
-#line 2864
 #else   /* not SX */
-#line 2864
-
-#line 2864
-	char *xp = (char *) *xpp;
-#line 2864
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2864
 
-#line 2864
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2864
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2864
-		int lstatus = ncx_put_int_int(xp, tp);
-#line 2864
+		const int lstatus = ncx_get_longlong_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2864
 			status = lstatus;
-#line 2864
 	}
-#line 2864
 
-#line 2864
-	*xpp = (void *)xp;
-#line 2864
+	*xpp = (const void *)xp;
 	return status;
-#line 2864
-#endif
-#line 2864
+#  endif
 }
-#line 2864
 
+#endif
 int
-#line 2865
-ncx_putn_int_uint(void **xpp, size_t nelems, const uint *tp)
-#line 2865
+ncx_getn_longlong_schar(const void **xpp, size_t nelems, schar *tp)
 {
-#line 2865
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2865
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2865
  /* basic algorithm is:
-#line 2865
-  *   - ensure sane alignment of output data
-#line 2865
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2865
   *     to output
-#line 2865
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2865
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2865
   */
-#line 2865
   long i, j, ni;
-#line 2865
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2865
-  int *xp;
-#line 2865
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2865
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2865
   long cxp = (long) *((char**)xpp);
-#line 2865
 
-#line 2865
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2865
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2865
    * vector work space reserved to LOOPCNT elements. Also
-#line 2865
    * makes vectorisation easy */
-#line 2865
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2865
     ni=Min(nelems-j,LOOPCNT);
-#line 2865
     if (realign) {
-#line 2865
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2865
     } else {
-#line 2865
-      xp = (int *) *xpp;
-#line 2865
+      xp = (longlong *) *xpp;
     }
-#line 2865
    /* copy the next block */
-#line 2865
 #pragma cdir loopcnt=LOOPCNT
-#line 2865
 #pragma cdir shortloop
-#line 2865
     for (i=0; i<ni; i++) {
-#line 2865
-      /* the normal case: */
-#line 2865
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2865
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2865
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2865
-    }
-#line 2865
-   /* copy workspace back if necessary */
-#line 2865
-    if (realign) {
-#line 2865
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2865
-      xp = (int *) *xpp;
-#line 2865
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX || xp[i] < SCHAR_MIN;
     }
-#line 2865
    /* update xpp and tp */
-#line 2865
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2865
     tp += ni;
-#line 2865
     *xpp = (void*)xp;
-#line 2865
   }
-#line 2865
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2865
 
-#line 2865
 #else   /* not SX */
-#line 2865
-
-#line 2865
-	char *xp = (char *) *xpp;
-#line 2865
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2865
 
-#line 2865
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2865
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2865
-		int lstatus = ncx_put_int_uint(xp, tp);
-#line 2865
+		const int lstatus = ncx_get_longlong_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2865
 			status = lstatus;
-#line 2865
 	}
-#line 2865
 
-#line 2865
-	*xpp = (void *)xp;
-#line 2865
+	*xpp = (const void *)xp;
 	return status;
-#line 2865
-#endif
-#line 2865
+#  endif
 }
-#line 2865
-
-#endif
 
 int
-#line 2868
-ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 2868
+ncx_getn_longlong_short(const void **xpp, size_t nelems, short *tp)
 {
-#line 2868
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2868
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2868
  /* basic algorithm is:
-#line 2868
-  *   - ensure sane alignment of output data
-#line 2868
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2868
   *     to output
-#line 2868
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2868
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2868
   */
-#line 2868
   long i, j, ni;
-#line 2868
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2868
-  int *xp;
-#line 2868
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2868
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2868
   long cxp = (long) *((char**)xpp);
-#line 2868
 
-#line 2868
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2868
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2868
    * vector work space reserved to LOOPCNT elements. Also
-#line 2868
    * makes vectorisation easy */
-#line 2868
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2868
     ni=Min(nelems-j,LOOPCNT);
-#line 2868
     if (realign) {
-#line 2868
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2868
     } else {
-#line 2868
-      xp = (int *) *xpp;
-#line 2868
+      xp = (longlong *) *xpp;
     }
-#line 2868
    /* copy the next block */
-#line 2868
 #pragma cdir loopcnt=LOOPCNT
-#line 2868
 #pragma cdir shortloop
-#line 2868
     for (i=0; i<ni; i++) {
-#line 2868
-      /* the normal case: */
-#line 2868
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2868
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2868
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2868
-    }
-#line 2868
-   /* copy workspace back if necessary */
-#line 2868
-    if (realign) {
-#line 2868
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2868
-      xp = (int *) *xpp;
-#line 2868
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX || xp[i] < SHORT_MIN;
     }
-#line 2868
    /* update xpp and tp */
-#line 2868
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2868
     tp += ni;
-#line 2868
     *xpp = (void*)xp;
-#line 2868
   }
-#line 2868
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2868
 
-#line 2868
 #else   /* not SX */
-#line 2868
-
-#line 2868
-	char *xp = (char *) *xpp;
-#line 2868
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2868
 
-#line 2868
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2868
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2868
-		int lstatus = ncx_put_int_longlong(xp, tp);
-#line 2868
+		const int lstatus = ncx_get_longlong_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 2868
 			status = lstatus;
-#line 2868
 	}
-#line 2868
 
-#line 2868
-	*xpp = (void *)xp;
-#line 2868
+	*xpp = (const void *)xp;
 	return status;
-#line 2868
-#endif
-#line 2868
+#  endif
 }
-#line 2868
 
 int
-#line 2869
-ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 2869
+ncx_getn_longlong_int(const void **xpp, size_t nelems, int *tp)
 {
-#line 2869
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2869
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2869
  /* basic algorithm is:
-#line 2869
-  *   - ensure sane alignment of output data
-#line 2869
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2869
   *     to output
-#line 2869
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2869
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2869
   */
-#line 2869
   long i, j, ni;
-#line 2869
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2869
-  int *xp;
-#line 2869
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2869
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2869
   long cxp = (long) *((char**)xpp);
-#line 2869
 
-#line 2869
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2869
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2869
    * vector work space reserved to LOOPCNT elements. Also
-#line 2869
    * makes vectorisation easy */
-#line 2869
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2869
     ni=Min(nelems-j,LOOPCNT);
-#line 2869
     if (realign) {
-#line 2869
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2869
     } else {
-#line 2869
-      xp = (int *) *xpp;
-#line 2869
+      xp = (longlong *) *xpp;
     }
-#line 2869
    /* copy the next block */
-#line 2869
 #pragma cdir loopcnt=LOOPCNT
-#line 2869
 #pragma cdir shortloop
-#line 2869
     for (i=0; i<ni; i++) {
-#line 2869
-      /* the normal case: */
-#line 2869
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2869
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2869
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2869
-    }
-#line 2869
-   /* copy workspace back if necessary */
-#line 2869
-    if (realign) {
-#line 2869
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2869
-      xp = (int *) *xpp;
-#line 2869
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX || xp[i] < INT_MIN;
     }
-#line 2869
    /* update xpp and tp */
-#line 2869
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2869
     tp += ni;
-#line 2869
     *xpp = (void*)xp;
-#line 2869
   }
-#line 2869
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2869
 
-#line 2869
 #else   /* not SX */
-#line 2869
-
-#line 2869
-	char *xp = (char *) *xpp;
-#line 2869
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2869
 
-#line 2869
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2869
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2869
-		int lstatus = ncx_put_int_ulonglong(xp, tp);
-#line 2869
+		const int lstatus = ncx_get_longlong_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2869
 			status = lstatus;
-#line 2869
 	}
-#line 2869
 
-#line 2869
-	*xpp = (void *)xp;
-#line 2869
+	*xpp = (const void *)xp;
 	return status;
-#line 2869
-#endif
-#line 2869
+#  endif
 }
-#line 2869
 
 int
-#line 2870
-ncx_putn_int_float(void **xpp, size_t nelems, const float *tp)
-#line 2870
+ncx_getn_longlong_float(const void **xpp, size_t nelems, float *tp)
 {
-#line 2870
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2870
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2870
  /* basic algorithm is:
-#line 2870
-  *   - ensure sane alignment of output data
-#line 2870
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2870
   *     to output
-#line 2870
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2870
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2870
   */
-#line 2870
   long i, j, ni;
-#line 2870
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2870
-  int *xp;
-#line 2870
-  double d;               /* special case for ncx_putn_int_float */
-#line 2870
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2870
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2870
   long cxp = (long) *((char**)xpp);
-#line 2870
 
-#line 2870
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2870
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2870
    * vector work space reserved to LOOPCNT elements. Also
-#line 2870
    * makes vectorisation easy */
-#line 2870
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2870
     ni=Min(nelems-j,LOOPCNT);
-#line 2870
     if (realign) {
-#line 2870
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2870
     } else {
-#line 2870
-      xp = (int *) *xpp;
-#line 2870
+      xp = (longlong *) *xpp;
     }
-#line 2870
    /* copy the next block */
-#line 2870
 #pragma cdir loopcnt=LOOPCNT
-#line 2870
 #pragma cdir shortloop
-#line 2870
     for (i=0; i<ni; i++) {
-#line 2870
-      /* for some reason int to float, for putn, requires a special case */
-#line 2870
-      d = tp[i];
-#line 2870
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) d));
-#line 2870
-      nrange += d < X_INT_MIN || d > X_INT_MAX;
-#line 2870
-    }
-#line 2870
-   /* copy workspace back if necessary */
-#line 2870
-    if (realign) {
-#line 2870
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2870
-      xp = (int *) *xpp;
-#line 2870
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX || xp[i] < FLOAT_MIN;
     }
-#line 2870
    /* update xpp and tp */
-#line 2870
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2870
     tp += ni;
-#line 2870
     *xpp = (void*)xp;
-#line 2870
   }
-#line 2870
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2870
 
-#line 2870
 #else   /* not SX */
-#line 2870
-
-#line 2870
-	char *xp = (char *) *xpp;
-#line 2870
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2870
 
-#line 2870
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2870
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2870
-		int lstatus = ncx_put_int_float(xp, tp);
-#line 2870
+		const int lstatus = ncx_get_longlong_float(xp, tp);
 		if(lstatus != ENOERR)
-#line 2870
 			status = lstatus;
-#line 2870
 	}
-#line 2870
 
-#line 2870
-	*xpp = (void *)xp;
-#line 2870
+	*xpp = (const void *)xp;
 	return status;
-#line 2870
-#endif
-#line 2870
+#  endif
 }
-#line 2870
 
 int
-#line 2871
-ncx_putn_int_double(void **xpp, size_t nelems, const double *tp)
-#line 2871
+ncx_getn_longlong_double(const void **xpp, size_t nelems, double *tp)
 {
-#line 2871
-#if _SX && X_SIZEOF_INT == SIZEOF_INT
-#line 2871
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2871
  /* basic algorithm is:
-#line 2871
-  *   - ensure sane alignment of output data
-#line 2871
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2871
   *     to output
-#line 2871
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2871
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2871
   */
-#line 2871
   long i, j, ni;
-#line 2871
-  int tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2871
-  int *xp;
-#line 2871
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2871
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2871
   long cxp = (long) *((char**)xpp);
-#line 2871
 
-#line 2871
-  realign = (cxp & 7) % SIZEOF_INT;
-#line 2871
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2871
    * vector work space reserved to LOOPCNT elements. Also
-#line 2871
    * makes vectorisation easy */
-#line 2871
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2871
     ni=Min(nelems-j,LOOPCNT);
-#line 2871
     if (realign) {
-#line 2871
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2871
     } else {
-#line 2871
-      xp = (int *) *xpp;
-#line 2871
+      xp = (longlong *) *xpp;
     }
-#line 2871
    /* copy the next block */
-#line 2871
 #pragma cdir loopcnt=LOOPCNT
-#line 2871
 #pragma cdir shortloop
-#line 2871
     for (i=0; i<ni; i++) {
-#line 2871
-      /* the normal case: */
-#line 2871
-      xp[i] = (int) Max( X_INT_MIN, Min(X_INT_MAX, (int) tp[i]));
-#line 2871
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2871
-      nrange += tp[i] < X_INT_MIN || tp[i] > X_INT_MAX;
-#line 2871
-    }
-#line 2871
-   /* copy workspace back if necessary */
-#line 2871
-    if (realign) {
-#line 2871
-      memcpy(*xpp, tmp, ni*X_SIZEOF_INT);
-#line 2871
-      xp = (int *) *xpp;
-#line 2871
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX || xp[i] < DOUBLE_MIN;
     }
-#line 2871
    /* update xpp and tp */
-#line 2871
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2871
     tp += ni;
-#line 2871
     *xpp = (void*)xp;
-#line 2871
   }
-#line 2871
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2871
 
-#line 2871
 #else   /* not SX */
-#line 2871
-
-#line 2871
-	char *xp = (char *) *xpp;
-#line 2871
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2871
 
-#line 2871
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
-#line 2871
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2871
-		int lstatus = ncx_put_int_double(xp, tp);
-#line 2871
+		const int lstatus = ncx_get_longlong_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 2871
 			status = lstatus;
-#line 2871
 	}
-#line 2871
 
-#line 2871
-	*xpp = (void *)xp;
-#line 2871
+	*xpp = (const void *)xp;
 	return status;
-#line 2871
-#endif
-#line 2871
+#  endif
 }
-#line 2871
-
-
-
-/* float */
 
 int
-#line 2876
-ncx_getn_float_schar(const void **xpp, size_t nelems, schar *tp)
-#line 2876
+ncx_getn_longlong_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
-#line 2876
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2876
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2876
  /* basic algorithm is:
-#line 2876
   *   - ensure sane alignment of input data
-#line 2876
   *   - copy (conversion happens automatically) input data
-#line 2876
   *     to output
-#line 2876
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2876
   *     at next location for converted output
-#line 2876
   */
-#line 2876
   long i, j, ni;
-#line 2876
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2876
-  float *xp;
-#line 2876
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2876
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2876
   long cxp = (long) *((char**)xpp);
-#line 2876
 
-#line 2876
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2876
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2876
    * vector work space reserved to LOOPCNT elements. Also
-#line 2876
    * makes vectorisation easy */
-#line 2876
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2876
     ni=Min(nelems-j,LOOPCNT);
-#line 2876
     if (realign) {
-#line 2876
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2876
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2876
     } else {
-#line 2876
-      xp = (float *) *xpp;
-#line 2876
+      xp = (longlong *) *xpp;
     }
-#line 2876
    /* copy the next block */
-#line 2876
 #pragma cdir loopcnt=LOOPCNT
-#line 2876
 #pragma cdir shortloop
-#line 2876
     for (i=0; i<ni; i++) {
-#line 2876
-      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 2876
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2876
-      nrange += xp[i] < SCHAR_MIN || xp[i] > SCHAR_MAX;
-#line 2876
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX || xp[i] < 0;
     }
-#line 2876
    /* update xpp and tp */
-#line 2876
-    if (realign) xp = (float *) *xpp;
-#line 2876
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2876
     tp += ni;
-#line 2876
     *xpp = (void*)xp;
-#line 2876
   }
-#line 2876
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2876
 
-#line 2876
 #else   /* not SX */
-#line 2876
 	const char *xp = (const char *) *xpp;
-#line 2876
 	int status = ENOERR;
-#line 2876
 
-#line 2876
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2876
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2876
-		const int lstatus = ncx_get_float_schar(xp, tp);
-#line 2876
+		const int lstatus = ncx_get_longlong_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2876
 			status = lstatus;
-#line 2876
 	}
-#line 2876
 
-#line 2876
 	*xpp = (const void *)xp;
-#line 2876
 	return status;
-#line 2876
 #  endif
-#line 2876
 }
-#line 2876
 
 int
-#line 2877
-ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2877
+ncx_getn_longlong_ushort(const void **xpp, size_t nelems, ushort *tp)
 {
-#line 2877
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2877
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2877
  /* basic algorithm is:
-#line 2877
   *   - ensure sane alignment of input data
-#line 2877
   *   - copy (conversion happens automatically) input data
-#line 2877
   *     to output
-#line 2877
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2877
   *     at next location for converted output
-#line 2877
   */
-#line 2877
   long i, j, ni;
-#line 2877
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2877
-  float *xp;
-#line 2877
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2877
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2877
   long cxp = (long) *((char**)xpp);
-#line 2877
 
-#line 2877
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2877
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2877
    * vector work space reserved to LOOPCNT elements. Also
-#line 2877
    * makes vectorisation easy */
-#line 2877
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2877
     ni=Min(nelems-j,LOOPCNT);
-#line 2877
     if (realign) {
-#line 2877
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2877
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2877
     } else {
-#line 2877
-      xp = (float *) *xpp;
-#line 2877
+      xp = (longlong *) *xpp;
     }
-#line 2877
    /* copy the next block */
-#line 2877
 #pragma cdir loopcnt=LOOPCNT
-#line 2877
 #pragma cdir shortloop
-#line 2877
     for (i=0; i<ni; i++) {
-#line 2877
-      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 2877
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2877
-      nrange += xp[i] < UCHAR_MIN || xp[i] > UCHAR_MAX;
-#line 2877
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX || xp[i] < 0;
     }
-#line 2877
    /* update xpp and tp */
-#line 2877
-    if (realign) xp = (float *) *xpp;
-#line 2877
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2877
     tp += ni;
-#line 2877
     *xpp = (void*)xp;
-#line 2877
   }
-#line 2877
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2877
 
-#line 2877
 #else   /* not SX */
-#line 2877
 	const char *xp = (const char *) *xpp;
-#line 2877
 	int status = ENOERR;
-#line 2877
 
-#line 2877
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2877
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2877
-		const int lstatus = ncx_get_float_uchar(xp, tp);
-#line 2877
+		const int lstatus = ncx_get_longlong_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2877
 			status = lstatus;
-#line 2877
 	}
-#line 2877
 
-#line 2877
 	*xpp = (const void *)xp;
-#line 2877
 	return status;
-#line 2877
 #  endif
-#line 2877
 }
-#line 2877
 
 int
-#line 2878
-ncx_getn_float_short(const void **xpp, size_t nelems, short *tp)
-#line 2878
+ncx_getn_longlong_uint(const void **xpp, size_t nelems, uint *tp)
 {
-#line 2878
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2878
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2878
  /* basic algorithm is:
-#line 2878
   *   - ensure sane alignment of input data
-#line 2878
   *   - copy (conversion happens automatically) input data
-#line 2878
   *     to output
-#line 2878
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2878
   *     at next location for converted output
-#line 2878
   */
-#line 2878
   long i, j, ni;
-#line 2878
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2878
-  float *xp;
-#line 2878
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2878
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2878
   long cxp = (long) *((char**)xpp);
-#line 2878
 
-#line 2878
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2878
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2878
    * vector work space reserved to LOOPCNT elements. Also
-#line 2878
    * makes vectorisation easy */
-#line 2878
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2878
     ni=Min(nelems-j,LOOPCNT);
-#line 2878
     if (realign) {
-#line 2878
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2878
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2878
     } else {
-#line 2878
-      xp = (float *) *xpp;
-#line 2878
+      xp = (longlong *) *xpp;
     }
-#line 2878
    /* copy the next block */
-#line 2878
 #pragma cdir loopcnt=LOOPCNT
-#line 2878
 #pragma cdir shortloop
-#line 2878
     for (i=0; i<ni; i++) {
-#line 2878
-      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 2878
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2878
-      nrange += xp[i] < SHORT_MIN || xp[i] > SHORT_MAX;
-#line 2878
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX || xp[i] < 0;
     }
-#line 2878
    /* update xpp and tp */
-#line 2878
-    if (realign) xp = (float *) *xpp;
-#line 2878
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2878
     tp += ni;
-#line 2878
     *xpp = (void*)xp;
-#line 2878
   }
-#line 2878
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2878
 
-#line 2878
 #else   /* not SX */
-#line 2878
 	const char *xp = (const char *) *xpp;
-#line 2878
 	int status = ENOERR;
-#line 2878
 
-#line 2878
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2878
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2878
-		const int lstatus = ncx_get_float_short(xp, tp);
-#line 2878
+		const int lstatus = ncx_get_longlong_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2878
 			status = lstatus;
-#line 2878
 	}
-#line 2878
 
-#line 2878
 	*xpp = (const void *)xp;
-#line 2878
 	return status;
-#line 2878
 #  endif
-#line 2878
 }
-#line 2878
 
 int
-#line 2879
-ncx_getn_float_int(const void **xpp, size_t nelems, int *tp)
-#line 2879
+ncx_getn_longlong_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
 {
-#line 2879
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2879
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2879
  /* basic algorithm is:
-#line 2879
   *   - ensure sane alignment of input data
-#line 2879
   *   - copy (conversion happens automatically) input data
-#line 2879
   *     to output
-#line 2879
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2879
   *     at next location for converted output
-#line 2879
   */
-#line 2879
   long i, j, ni;
-#line 2879
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2879
-  float *xp;
-#line 2879
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2879
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2879
   long cxp = (long) *((char**)xpp);
-#line 2879
 
-#line 2879
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2879
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2879
    * vector work space reserved to LOOPCNT elements. Also
-#line 2879
    * makes vectorisation easy */
-#line 2879
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2879
     ni=Min(nelems-j,LOOPCNT);
-#line 2879
     if (realign) {
-#line 2879
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2879
+      memcpy(tmp, *xpp, ni*SIZEOF_LONGLONG);
       xp = tmp;
-#line 2879
     } else {
-#line 2879
-      xp = (float *) *xpp;
-#line 2879
+      xp = (longlong *) *xpp;
     }
-#line 2879
    /* copy the next block */
-#line 2879
 #pragma cdir loopcnt=LOOPCNT
-#line 2879
 #pragma cdir shortloop
-#line 2879
     for (i=0; i<ni; i++) {
-#line 2879
-      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 2879
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2879
-      nrange += xp[i] < INT_MIN || xp[i] > INT_MAX;
-#line 2879
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX || xp[i] < 0;
     }
-#line 2879
    /* update xpp and tp */
-#line 2879
-    if (realign) xp = (float *) *xpp;
-#line 2879
+    if (realign) xp = (longlong *) *xpp;
     xp += ni;
-#line 2879
     tp += ni;
-#line 2879
     *xpp = (void*)xp;
-#line 2879
   }
-#line 2879
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2879
 
-#line 2879
 #else   /* not SX */
-#line 2879
 	const char *xp = (const char *) *xpp;
-#line 2879
-	int status = ENOERR;
-#line 2879
-
-#line 2879
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2879
-	{
-#line 2879
-		const int lstatus = ncx_get_float_int(xp, tp);
-#line 2879
-		if(lstatus != ENOERR)
-#line 2879
-			status = lstatus;
-#line 2879
-	}
-#line 2879
-
-#line 2879
-	*xpp = (const void *)xp;
-#line 2879
-	return status;
-#line 2879
-#  endif
-#line 2879
-}
-#line 2879
-
-#if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
-/* optimized version */
-int
-ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
-{
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(tp, *xpp, nelems * sizeof(float));
-# else
-	swapn4b(tp, *xpp, nelems);
-# endif
-	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_FLOAT);
-	return ENOERR;
-}
-#elif vax
-int
-ncx_getn_float_float(const void **xpp, size_t nfloats, float *ip)
-{
-	float *const end = ip + nfloats;
-
-	while(ip < end)
-	{
-		struct vax_single *const vsp = (struct vax_single *) ip;
-#line 2901
-		const struct ieee_single *const isp =
-#line 2901
-			 (const struct ieee_single *) (*xpp);
-#line 2901
-		unsigned exp = isp->exp_hi << 1 | isp->exp_lo;
-#line 2901
-
-#line 2901
-		switch(exp) {
-#line 2901
-		case 0 :
-#line 2901
-			/* ieee subnormal */
-#line 2901
-			if(isp->mant_hi == min.ieee.mant_hi
-#line 2901
-				&& isp->mant_lo_hi == min.ieee.mant_lo_hi
-#line 2901
-				&& isp->mant_lo_lo == min.ieee.mant_lo_lo)
-#line 2901
-			{
-#line 2901
-				*vsp = min.s;
-#line 2901
-			}
-#line 2901
-			else
-#line 2901
-			{
-#line 2901
-				unsigned mantissa = (isp->mant_hi << 16)
-#line 2901
-					 | isp->mant_lo_hi << 8
-#line 2901
-					 | isp->mant_lo_lo;
-#line 2901
-				unsigned tmp = mantissa >> 20;
-#line 2901
-				if(tmp >= 4) {
-#line 2901
-					vsp->exp = 2;
-#line 2901
-				} else if (tmp >= 2) {
-#line 2901
-					vsp->exp = 1;
-#line 2901
-				} else {
-#line 2901
-					*vsp = min.s;
-#line 2901
-					break;
-#line 2901
-				} /* else */
-#line 2901
-				tmp = mantissa - (1 << (20 + vsp->exp ));
-#line 2901
-				tmp <<= 3 - vsp->exp;
-#line 2901
-				vsp->mantissa2 = tmp;
-#line 2901
-				vsp->mantissa1 = (tmp >> 16);
-#line 2901
-			}
-#line 2901
-			break;
-#line 2901
-		case 0xfe :
-#line 2901
-		case 0xff :
-#line 2901
-			*vsp = max.s;
-#line 2901
-			break;
-#line 2901
-		default :
-#line 2901
-			vsp->exp = exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
-#line 2901
-			vsp->mantissa2 = isp->mant_lo_hi << 8 | isp->mant_lo_lo;
-#line 2901
-			vsp->mantissa1 = isp->mant_hi;
-#line 2901
-		}
-#line 2901
-
-#line 2901
-		vsp->sign = isp->sign;
-#line 2901
-
-
-		ip++;
-		*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
-	}
-	return ENOERR;
-}
-#else
-int
-ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
-{
-	const char *xp = *xpp;
 	int status = ENOERR;
 
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-		const int lstatus = ncx_get_float_float(xp, tp);
+		const int lstatus = ncx_get_longlong_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
 			status = lstatus;
 	}
 
 	*xpp = (const void *)xp;
 	return status;
+#  endif
 }
 
-#endif
+
+#if X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
+/* optimized version */
 int
-#line 2927
-ncx_getn_float_double(const void **xpp, size_t nelems, double *tp)
-#line 2927
+ncx_putn_longlong_longlong(void **xpp, size_t nelems, const long long *tp)
 {
-#line 2927
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2927
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_LONGLONG);
+# else
+	swapn8b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_LONGLONG);
+	return ENOERR;
+}
+#else
+int
+ncx_putn_longlong_longlong(void **xpp, size_t nelems, const longlong *tp)
+{
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2927
  /* basic algorithm is:
-#line 2927
-  *   - ensure sane alignment of input data
-#line 2927
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2927
   *     to output
-#line 2927
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2927
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2927
   */
-#line 2927
   long i, j, ni;
-#line 2927
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2927
-  float *xp;
-#line 2927
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2927
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2927
   long cxp = (long) *((char**)xpp);
-#line 2927
 
-#line 2927
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2927
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2927
    * vector work space reserved to LOOPCNT elements. Also
-#line 2927
    * makes vectorisation easy */
-#line 2927
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2927
     ni=Min(nelems-j,LOOPCNT);
-#line 2927
     if (realign) {
-#line 2927
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2927
       xp = tmp;
-#line 2927
     } else {
-#line 2927
-      xp = (float *) *xpp;
-#line 2927
+      xp = (longlong *) *xpp;
     }
-#line 2927
    /* copy the next block */
-#line 2927
 #pragma cdir loopcnt=LOOPCNT
-#line 2927
 #pragma cdir shortloop
-#line 2927
     for (i=0; i<ni; i++) {
-#line 2927
-      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
-#line 2927
+      /* the normal case: */
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2927
-      nrange += xp[i] < DOUBLE_MIN || xp[i] > DOUBLE_MAX;
-#line 2927
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX || tp[i] < X_LONGLONG_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2927
    /* update xpp and tp */
-#line 2927
-    if (realign) xp = (float *) *xpp;
-#line 2927
     xp += ni;
-#line 2927
     tp += ni;
-#line 2927
     *xpp = (void*)xp;
-#line 2927
   }
-#line 2927
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2927
 
-#line 2927
 #else   /* not SX */
-#line 2927
-	const char *xp = (const char *) *xpp;
-#line 2927
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2927
 
-#line 2927
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2927
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2927
-		const int lstatus = ncx_get_float_double(xp, tp);
-#line 2927
+		int lstatus = ncx_put_longlong_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2927
 			status = lstatus;
-#line 2927
 	}
-#line 2927
 
-#line 2927
-	*xpp = (const void *)xp;
-#line 2927
+	*xpp = (void *)xp;
 	return status;
-#line 2927
-#  endif
-#line 2927
+#endif
 }
-#line 2927
 
+#endif
 int
-#line 2928
-ncx_getn_float_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2928
+ncx_putn_longlong_schar(void **xpp, size_t nelems, const schar *tp)
 {
-#line 2928
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2928
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2928
  /* basic algorithm is:
-#line 2928
-  *   - ensure sane alignment of input data
-#line 2928
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2928
   *     to output
-#line 2928
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2928
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2928
   */
-#line 2928
   long i, j, ni;
-#line 2928
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2928
-  float *xp;
-#line 2928
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2928
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2928
   long cxp = (long) *((char**)xpp);
-#line 2928
 
-#line 2928
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2928
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2928
    * vector work space reserved to LOOPCNT elements. Also
-#line 2928
    * makes vectorisation easy */
-#line 2928
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2928
     ni=Min(nelems-j,LOOPCNT);
-#line 2928
     if (realign) {
-#line 2928
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2928
       xp = tmp;
-#line 2928
     } else {
-#line 2928
-      xp = (float *) *xpp;
-#line 2928
+      xp = (longlong *) *xpp;
     }
-#line 2928
    /* copy the next block */
-#line 2928
 #pragma cdir loopcnt=LOOPCNT
-#line 2928
 #pragma cdir shortloop
-#line 2928
     for (i=0; i<ni; i++) {
-#line 2928
-      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 2928
+      /* the normal case: */
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2928
-      nrange += xp[i] < UINT_MIN || xp[i] > UINT_MAX;
-#line 2928
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX || tp[i] < X_LONGLONG_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2928
    /* update xpp and tp */
-#line 2928
-    if (realign) xp = (float *) *xpp;
-#line 2928
     xp += ni;
-#line 2928
     tp += ni;
-#line 2928
     *xpp = (void*)xp;
-#line 2928
   }
-#line 2928
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2928
 
-#line 2928
 #else   /* not SX */
-#line 2928
-	const char *xp = (const char *) *xpp;
-#line 2928
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2928
 
-#line 2928
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2928
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2928
-		const int lstatus = ncx_get_float_uint(xp, tp);
-#line 2928
+		int lstatus = ncx_put_longlong_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2928
 			status = lstatus;
-#line 2928
 	}
-#line 2928
 
-#line 2928
-	*xpp = (const void *)xp;
-#line 2928
+	*xpp = (void *)xp;
 	return status;
-#line 2928
-#  endif
-#line 2928
+#endif
 }
-#line 2928
 
 int
-#line 2929
-ncx_getn_float_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2929
+ncx_putn_longlong_short(void **xpp, size_t nelems, const short *tp)
 {
-#line 2929
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2929
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2929
  /* basic algorithm is:
-#line 2929
-  *   - ensure sane alignment of input data
-#line 2929
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2929
   *     to output
-#line 2929
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2929
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2929
   */
-#line 2929
   long i, j, ni;
-#line 2929
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2929
-  float *xp;
-#line 2929
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2929
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2929
   long cxp = (long) *((char**)xpp);
-#line 2929
 
-#line 2929
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2929
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2929
    * vector work space reserved to LOOPCNT elements. Also
-#line 2929
    * makes vectorisation easy */
-#line 2929
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2929
     ni=Min(nelems-j,LOOPCNT);
-#line 2929
     if (realign) {
-#line 2929
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2929
       xp = tmp;
-#line 2929
     } else {
-#line 2929
-      xp = (float *) *xpp;
-#line 2929
+      xp = (longlong *) *xpp;
     }
-#line 2929
    /* copy the next block */
-#line 2929
 #pragma cdir loopcnt=LOOPCNT
-#line 2929
 #pragma cdir shortloop
-#line 2929
     for (i=0; i<ni; i++) {
-#line 2929
-      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 2929
+      /* the normal case: */
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2929
-      nrange += xp[i] < LONGLONG_MIN || xp[i] > LONGLONG_MAX;
-#line 2929
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX || tp[i] < X_LONGLONG_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2929
    /* update xpp and tp */
-#line 2929
-    if (realign) xp = (float *) *xpp;
-#line 2929
     xp += ni;
-#line 2929
     tp += ni;
-#line 2929
     *xpp = (void*)xp;
-#line 2929
   }
-#line 2929
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2929
 
-#line 2929
 #else   /* not SX */
-#line 2929
-	const char *xp = (const char *) *xpp;
-#line 2929
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2929
 
-#line 2929
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2929
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2929
-		const int lstatus = ncx_get_float_longlong(xp, tp);
-#line 2929
+		int lstatus = ncx_put_longlong_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 2929
 			status = lstatus;
-#line 2929
 	}
-#line 2929
 
-#line 2929
-	*xpp = (const void *)xp;
-#line 2929
+	*xpp = (void *)xp;
 	return status;
-#line 2929
-#  endif
-#line 2929
+#endif
 }
-#line 2929
 
 int
-#line 2930
-ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2930
+ncx_putn_longlong_int(void **xpp, size_t nelems, const int *tp)
 {
-#line 2930
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2930
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2930
  /* basic algorithm is:
-#line 2930
-  *   - ensure sane alignment of input data
-#line 2930
+  *   - ensure sane alignment of output data
   *   - copy (conversion happens automatically) input data
-#line 2930
   *     to output
-#line 2930
-  *   - update xpp to point at next unconverted input, and tp to point
-#line 2930
+  *   - update tp to point at next unconverted input, and xpp to point
   *     at next location for converted output
-#line 2930
   */
-#line 2930
   long i, j, ni;
-#line 2930
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2930
-  float *xp;
-#line 2930
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2930
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2930
   long cxp = (long) *((char**)xpp);
-#line 2930
 
-#line 2930
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2930
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2930
    * vector work space reserved to LOOPCNT elements. Also
-#line 2930
    * makes vectorisation easy */
-#line 2930
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2930
     ni=Min(nelems-j,LOOPCNT);
-#line 2930
     if (realign) {
-#line 2930
-      memcpy(tmp, *xpp, ni*SIZEOF_FLOAT);
-#line 2930
       xp = tmp;
-#line 2930
     } else {
-#line 2930
-      xp = (float *) *xpp;
-#line 2930
+      xp = (longlong *) *xpp;
     }
-#line 2930
    /* copy the next block */
-#line 2930
 #pragma cdir loopcnt=LOOPCNT
-#line 2930
 #pragma cdir shortloop
-#line 2930
     for (i=0; i<ni; i++) {
-#line 2930
-      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 2930
+      /* the normal case: */
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2930
-      nrange += xp[i] < ULONGLONG_MIN || xp[i] > ULONGLONG_MAX;
-#line 2930
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX || tp[i] < X_LONGLONG_MIN;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2930
    /* update xpp and tp */
-#line 2930
-    if (realign) xp = (float *) *xpp;
-#line 2930
     xp += ni;
-#line 2930
     tp += ni;
-#line 2930
     *xpp = (void*)xp;
-#line 2930
   }
-#line 2930
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2930
 
-#line 2930
 #else   /* not SX */
-#line 2930
-	const char *xp = (const char *) *xpp;
-#line 2930
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
-#line 2930
 
-#line 2930
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2930
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2930
-		const int lstatus = ncx_get_float_ulonglong(xp, tp);
-#line 2930
+		int lstatus = ncx_put_longlong_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2930
 			status = lstatus;
-#line 2930
 	}
-#line 2930
 
-#line 2930
-	*xpp = (const void *)xp;
-#line 2930
+	*xpp = (void *)xp;
 	return status;
-#line 2930
-#  endif
-#line 2930
+#endif
 }
-#line 2930
-
 
 int
-#line 2932
-ncx_putn_float_schar(void **xpp, size_t nelems, const schar *tp)
-#line 2932
+ncx_putn_longlong_float(void **xpp, size_t nelems, const float *tp)
 {
-#line 2932
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2932
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2932
  /* basic algorithm is:
-#line 2932
   *   - ensure sane alignment of output data
-#line 2932
   *   - copy (conversion happens automatically) input data
-#line 2932
   *     to output
-#line 2932
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2932
   *     at next location for converted output
-#line 2932
   */
-#line 2932
   long i, j, ni;
-#line 2932
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2932
-  float *xp;
-#line 2932
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2932
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2932
   long cxp = (long) *((char**)xpp);
-#line 2932
 
-#line 2932
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2932
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2932
    * vector work space reserved to LOOPCNT elements. Also
-#line 2932
    * makes vectorisation easy */
-#line 2932
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2932
     ni=Min(nelems-j,LOOPCNT);
-#line 2932
     if (realign) {
-#line 2932
       xp = tmp;
-#line 2932
     } else {
-#line 2932
-      xp = (float *) *xpp;
-#line 2932
+      xp = (longlong *) *xpp;
     }
-#line 2932
    /* copy the next block */
-#line 2932
 #pragma cdir loopcnt=LOOPCNT
-#line 2932
 #pragma cdir shortloop
-#line 2932
     for (i=0; i<ni; i++) {
-#line 2932
       /* the normal case: */
-#line 2932
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2932
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2932
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2932
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX || tp[i] < X_LONGLONG_MIN;
     }
-#line 2932
    /* copy workspace back if necessary */
-#line 2932
     if (realign) {
-#line 2932
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2932
-      xp = (float *) *xpp;
-#line 2932
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2932
    /* update xpp and tp */
-#line 2932
     xp += ni;
-#line 2932
     tp += ni;
-#line 2932
     *xpp = (void*)xp;
-#line 2932
   }
-#line 2932
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2932
 
-#line 2932
 #else   /* not SX */
-#line 2932
 
-#line 2932
 	char *xp = (char *) *xpp;
-#line 2932
 	int status = ENOERR;
-#line 2932
 
-#line 2932
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2932
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2932
-		int lstatus = ncx_put_float_schar(xp, tp);
-#line 2932
+		int lstatus = ncx_put_longlong_float(xp, tp);
 		if(lstatus != ENOERR)
-#line 2932
 			status = lstatus;
-#line 2932
 	}
-#line 2932
 
-#line 2932
 	*xpp = (void *)xp;
-#line 2932
 	return status;
-#line 2932
 #endif
-#line 2932
 }
-#line 2932
 
 int
-#line 2933
-ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *tp)
-#line 2933
+ncx_putn_longlong_double(void **xpp, size_t nelems, const double *tp)
 {
-#line 2933
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2933
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2933
  /* basic algorithm is:
-#line 2933
   *   - ensure sane alignment of output data
-#line 2933
   *   - copy (conversion happens automatically) input data
-#line 2933
   *     to output
-#line 2933
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2933
   *     at next location for converted output
-#line 2933
   */
-#line 2933
   long i, j, ni;
-#line 2933
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2933
-  float *xp;
-#line 2933
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2933
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2933
   long cxp = (long) *((char**)xpp);
-#line 2933
 
-#line 2933
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2933
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2933
    * vector work space reserved to LOOPCNT elements. Also
-#line 2933
    * makes vectorisation easy */
-#line 2933
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2933
     ni=Min(nelems-j,LOOPCNT);
-#line 2933
     if (realign) {
-#line 2933
       xp = tmp;
-#line 2933
     } else {
-#line 2933
-      xp = (float *) *xpp;
-#line 2933
+      xp = (longlong *) *xpp;
     }
-#line 2933
    /* copy the next block */
-#line 2933
 #pragma cdir loopcnt=LOOPCNT
-#line 2933
 #pragma cdir shortloop
-#line 2933
     for (i=0; i<ni; i++) {
-#line 2933
       /* the normal case: */
-#line 2933
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2933
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2933
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2933
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX || tp[i] < X_LONGLONG_MIN;
     }
-#line 2933
    /* copy workspace back if necessary */
-#line 2933
     if (realign) {
-#line 2933
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2933
-      xp = (float *) *xpp;
-#line 2933
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2933
    /* update xpp and tp */
-#line 2933
     xp += ni;
-#line 2933
     tp += ni;
-#line 2933
     *xpp = (void*)xp;
-#line 2933
   }
-#line 2933
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2933
 
-#line 2933
 #else   /* not SX */
-#line 2933
 
-#line 2933
 	char *xp = (char *) *xpp;
-#line 2933
 	int status = ENOERR;
-#line 2933
 
-#line 2933
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2933
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2933
-		int lstatus = ncx_put_float_uchar(xp, tp);
-#line 2933
+		int lstatus = ncx_put_longlong_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 2933
 			status = lstatus;
-#line 2933
 	}
-#line 2933
 
-#line 2933
 	*xpp = (void *)xp;
-#line 2933
 	return status;
-#line 2933
 #endif
-#line 2933
 }
-#line 2933
 
 int
-#line 2934
-ncx_putn_float_short(void **xpp, size_t nelems, const short *tp)
-#line 2934
+ncx_putn_longlong_uchar(void **xpp, size_t nelems, const uchar *tp)
 {
-#line 2934
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2934
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2934
  /* basic algorithm is:
-#line 2934
   *   - ensure sane alignment of output data
-#line 2934
   *   - copy (conversion happens automatically) input data
-#line 2934
   *     to output
-#line 2934
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2934
   *     at next location for converted output
-#line 2934
   */
-#line 2934
   long i, j, ni;
-#line 2934
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2934
-  float *xp;
-#line 2934
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2934
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2934
   long cxp = (long) *((char**)xpp);
-#line 2934
 
-#line 2934
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2934
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2934
    * vector work space reserved to LOOPCNT elements. Also
-#line 2934
    * makes vectorisation easy */
-#line 2934
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2934
     ni=Min(nelems-j,LOOPCNT);
-#line 2934
     if (realign) {
-#line 2934
       xp = tmp;
-#line 2934
     } else {
-#line 2934
-      xp = (float *) *xpp;
-#line 2934
+      xp = (longlong *) *xpp;
     }
-#line 2934
    /* copy the next block */
-#line 2934
 #pragma cdir loopcnt=LOOPCNT
-#line 2934
 #pragma cdir shortloop
-#line 2934
     for (i=0; i<ni; i++) {
-#line 2934
       /* the normal case: */
-#line 2934
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2934
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2934
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2934
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX ;
     }
-#line 2934
    /* copy workspace back if necessary */
-#line 2934
     if (realign) {
-#line 2934
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2934
-      xp = (float *) *xpp;
-#line 2934
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2934
    /* update xpp and tp */
-#line 2934
     xp += ni;
-#line 2934
     tp += ni;
-#line 2934
     *xpp = (void*)xp;
-#line 2934
   }
-#line 2934
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2934
 
-#line 2934
 #else   /* not SX */
-#line 2934
 
-#line 2934
 	char *xp = (char *) *xpp;
-#line 2934
 	int status = ENOERR;
-#line 2934
 
-#line 2934
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2934
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2934
-		int lstatus = ncx_put_float_short(xp, tp);
-#line 2934
+		int lstatus = ncx_put_longlong_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2934
 			status = lstatus;
-#line 2934
 	}
-#line 2934
 
-#line 2934
 	*xpp = (void *)xp;
-#line 2934
 	return status;
-#line 2934
 #endif
-#line 2934
 }
-#line 2934
 
 int
-#line 2935
-ncx_putn_float_int(void **xpp, size_t nelems, const int *tp)
-#line 2935
+ncx_putn_longlong_ushort(void **xpp, size_t nelems, const ushort *tp)
 {
-#line 2935
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2935
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2935
  /* basic algorithm is:
-#line 2935
   *   - ensure sane alignment of output data
-#line 2935
   *   - copy (conversion happens automatically) input data
-#line 2935
   *     to output
-#line 2935
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2935
   *     at next location for converted output
-#line 2935
   */
-#line 2935
   long i, j, ni;
-#line 2935
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2935
-  float *xp;
-#line 2935
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2935
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2935
   long cxp = (long) *((char**)xpp);
-#line 2935
 
-#line 2935
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2935
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2935
    * vector work space reserved to LOOPCNT elements. Also
-#line 2935
    * makes vectorisation easy */
-#line 2935
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2935
     ni=Min(nelems-j,LOOPCNT);
-#line 2935
     if (realign) {
-#line 2935
       xp = tmp;
-#line 2935
     } else {
-#line 2935
-      xp = (float *) *xpp;
-#line 2935
+      xp = (longlong *) *xpp;
     }
-#line 2935
    /* copy the next block */
-#line 2935
 #pragma cdir loopcnt=LOOPCNT
-#line 2935
 #pragma cdir shortloop
-#line 2935
     for (i=0; i<ni; i++) {
-#line 2935
       /* the normal case: */
-#line 2935
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2935
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2935
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2935
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX ;
     }
-#line 2935
    /* copy workspace back if necessary */
-#line 2935
     if (realign) {
-#line 2935
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2935
-      xp = (float *) *xpp;
-#line 2935
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2935
    /* update xpp and tp */
-#line 2935
     xp += ni;
-#line 2935
     tp += ni;
-#line 2935
     *xpp = (void*)xp;
-#line 2935
   }
-#line 2935
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2935
 
-#line 2935
 #else   /* not SX */
-#line 2935
 
-#line 2935
 	char *xp = (char *) *xpp;
-#line 2935
 	int status = ENOERR;
-#line 2935
 
-#line 2935
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2935
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2935
-		int lstatus = ncx_put_float_int(xp, tp);
-#line 2935
+		int lstatus = ncx_put_longlong_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2935
 			status = lstatus;
-#line 2935
 	}
-#line 2935
 
-#line 2935
 	*xpp = (void *)xp;
-#line 2935
 	return status;
-#line 2935
 #endif
-#line 2935
-}
-#line 2935
-
-#if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
-/* optimized version */
-int
-ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
-{
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_FLOAT);
-# else
-	swapn4b(*xpp, tp, nelems);
-# endif
-	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_FLOAT);
-	return ENOERR;
-}
-#elif vax
-int
-ncx_putn_float_float(void **xpp, size_t nfloats, const float *ip)
-{
-	const float *const end = ip + nfloats;
-
-	while(ip < end)
-	{
-		const struct vax_single *const vsp =
-#line 2957
-			 (const struct vax_single *)ip;
-#line 2957
-		struct ieee_single *const isp = (struct ieee_single *) (*xpp);
-#line 2957
-
-#line 2957
-		switch(vsp->exp){
-#line 2957
-		case 0 :
-#line 2957
-			/* all vax float with zero exponent map to zero */
-#line 2957
-			*isp = min.ieee;
-#line 2957
-			break;
-#line 2957
-		case 2 :
-#line 2957
-		case 1 :
-#line 2957
-		{
-#line 2957
-			/* These will map to subnormals */
-#line 2957
-			unsigned mantissa = (vsp->mantissa1 << 16)
-#line 2957
-					 | vsp->mantissa2;
-#line 2957
-			mantissa >>= 3 - vsp->exp;
-#line 2957
-			mantissa += (1 << (20 + vsp->exp));
-#line 2957
-			isp->mant_lo_lo = mantissa;
-#line 2957
-			isp->mant_lo_hi = mantissa >> 8;
-#line 2957
-			isp->mant_hi = mantissa >> 16;
-#line 2957
-			isp->exp_lo = 0;
-#line 2957
-			isp->exp_hi = 0;
-#line 2957
-		}
-#line 2957
-			break;
-#line 2957
-		case 0xff : /* max.s.exp */
-#line 2957
-			if( vsp->mantissa2 == max.s.mantissa2
-#line 2957
-				&& vsp->mantissa1 == max.s.mantissa1)
-#line 2957
-			{
-#line 2957
-				/* map largest vax float to ieee infinity */
-#line 2957
-				*isp = max.ieee;
-#line 2957
-				break;
-#line 2957
-			} /* else, fall thru */
-#line 2957
-		default :
-#line 2957
-		{
-#line 2957
-			unsigned exp = vsp->exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
-#line 2957
-			isp->exp_hi = exp >> 1;
-#line 2957
-			isp->exp_lo = exp;
-#line 2957
-			isp->mant_lo_lo = vsp->mantissa2;
-#line 2957
-			isp->mant_lo_hi = vsp->mantissa2 >> 8;
-#line 2957
-			isp->mant_hi = vsp->mantissa1;
-#line 2957
-		}
-#line 2957
-		}
-#line 2957
-
-#line 2957
-		isp->sign = vsp->sign;
-#line 2957
-
-
-		ip++;
-		*xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
-	}
-	return ENOERR;
-}
-#else
-int
-ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
-{
-	char *xp = *xpp;
-	int status = ENOERR;
-
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-	{
-		int lstatus = ncx_put_float_float(xp, tp);
-		if(lstatus != ENOERR)
-			status = lstatus;
-	}
-
-	*xpp = (void *)xp;
-	return status;
 }
 
-#endif
 int
-#line 2983
-ncx_putn_float_double(void **xpp, size_t nelems, const double *tp)
-#line 2983
+ncx_putn_longlong_uint(void **xpp, size_t nelems, const uint *tp)
 {
-#line 2983
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2983
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2983
  /* basic algorithm is:
-#line 2983
   *   - ensure sane alignment of output data
-#line 2983
   *   - copy (conversion happens automatically) input data
-#line 2983
   *     to output
-#line 2983
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2983
   *     at next location for converted output
-#line 2983
   */
-#line 2983
   long i, j, ni;
-#line 2983
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2983
-  float *xp;
-#line 2983
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2983
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2983
   long cxp = (long) *((char**)xpp);
-#line 2983
 
-#line 2983
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2983
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2983
    * vector work space reserved to LOOPCNT elements. Also
-#line 2983
    * makes vectorisation easy */
-#line 2983
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2983
     ni=Min(nelems-j,LOOPCNT);
-#line 2983
     if (realign) {
-#line 2983
       xp = tmp;
-#line 2983
     } else {
-#line 2983
-      xp = (float *) *xpp;
-#line 2983
+      xp = (longlong *) *xpp;
     }
-#line 2983
    /* copy the next block */
-#line 2983
 #pragma cdir loopcnt=LOOPCNT
-#line 2983
 #pragma cdir shortloop
-#line 2983
     for (i=0; i<ni; i++) {
-#line 2983
       /* the normal case: */
-#line 2983
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2983
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2983
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2983
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX ;
     }
-#line 2983
    /* copy workspace back if necessary */
-#line 2983
     if (realign) {
-#line 2983
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2983
-      xp = (float *) *xpp;
-#line 2983
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2983
    /* update xpp and tp */
-#line 2983
     xp += ni;
-#line 2983
     tp += ni;
-#line 2983
     *xpp = (void*)xp;
-#line 2983
   }
-#line 2983
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2983
 
-#line 2983
 #else   /* not SX */
-#line 2983
 
-#line 2983
 	char *xp = (char *) *xpp;
-#line 2983
 	int status = ENOERR;
-#line 2983
 
-#line 2983
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2983
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2983
-		int lstatus = ncx_put_float_double(xp, tp);
-#line 2983
+		int lstatus = ncx_put_longlong_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2983
 			status = lstatus;
-#line 2983
 	}
-#line 2983
 
-#line 2983
 	*xpp = (void *)xp;
-#line 2983
 	return status;
-#line 2983
 #endif
-#line 2983
 }
-#line 2983
 
 int
-#line 2984
-ncx_putn_float_uint(void **xpp, size_t nelems, const uint *tp)
-#line 2984
+ncx_putn_longlong_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
 {
-#line 2984
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2984
+#if _SX && X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
 
-#line 2984
  /* basic algorithm is:
-#line 2984
   *   - ensure sane alignment of output data
-#line 2984
   *   - copy (conversion happens automatically) input data
-#line 2984
   *     to output
-#line 2984
   *   - update tp to point at next unconverted input, and xpp to point
-#line 2984
   *     at next location for converted output
-#line 2984
   */
-#line 2984
   long i, j, ni;
-#line 2984
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2984
-  float *xp;
-#line 2984
+  longlong tmp[LOOPCNT];        /* in case input is misaligned */
+  longlong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2984
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2984
   long cxp = (long) *((char**)xpp);
-#line 2984
 
-#line 2984
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2984
+  realign = (cxp & 7) % SIZEOF_LONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2984
    * vector work space reserved to LOOPCNT elements. Also
-#line 2984
    * makes vectorisation easy */
-#line 2984
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2984
     ni=Min(nelems-j,LOOPCNT);
-#line 2984
     if (realign) {
-#line 2984
       xp = tmp;
-#line 2984
     } else {
-#line 2984
-      xp = (float *) *xpp;
-#line 2984
+      xp = (longlong *) *xpp;
     }
-#line 2984
    /* copy the next block */
-#line 2984
 #pragma cdir loopcnt=LOOPCNT
-#line 2984
 #pragma cdir shortloop
-#line 2984
     for (i=0; i<ni; i++) {
-#line 2984
       /* the normal case: */
-#line 2984
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2984
+      xp[i] = (longlong) Max( X_LONGLONG_MIN, Min(X_LONGLONG_MAX, (longlong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2984
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2984
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_LONGLONG_MAX ;
     }
-#line 2984
    /* copy workspace back if necessary */
-#line 2984
     if (realign) {
-#line 2984
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2984
-      xp = (float *) *xpp;
-#line 2984
+      memcpy(*xpp, tmp, ni*X_SIZEOF_LONGLONG);
+      xp = (longlong *) *xpp;
     }
-#line 2984
    /* update xpp and tp */
-#line 2984
     xp += ni;
-#line 2984
     tp += ni;
-#line 2984
     *xpp = (void*)xp;
-#line 2984
   }
-#line 2984
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2984
 
-#line 2984
 #else   /* not SX */
-#line 2984
 
-#line 2984
 	char *xp = (char *) *xpp;
-#line 2984
 	int status = ENOERR;
-#line 2984
 
-#line 2984
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2984
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_LONGLONG, tp++)
 	{
-#line 2984
-		int lstatus = ncx_put_float_uint(xp, tp);
-#line 2984
+		int lstatus = ncx_put_longlong_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2984
 			status = lstatus;
-#line 2984
 	}
-#line 2984
 
-#line 2984
 	*xpp = (void *)xp;
-#line 2984
 	return status;
-#line 2984
 #endif
-#line 2984
 }
-#line 2984
 
+
+/* ulonglong ----------------------------------------------------------------------*/
+
+#if X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
+/* optimized version */
 int
-#line 2985
-ncx_putn_float_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 2985
+ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, unsigned long long *tp)
 {
-#line 2985
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2985
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(unsigned long long));
+# else
+	swapn8b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_ULONGLONG);
+	return ENOERR;
+}
+#else
+int
+ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
+{
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2985
  /* basic algorithm is:
-#line 2985
-  *   - ensure sane alignment of output data
-#line 2985
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2985
   *     to output
-#line 2985
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2985
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2985
   */
-#line 2985
   long i, j, ni;
-#line 2985
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2985
-  float *xp;
-#line 2985
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2985
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2985
   long cxp = (long) *((char**)xpp);
-#line 2985
 
-#line 2985
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2985
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2985
    * vector work space reserved to LOOPCNT elements. Also
-#line 2985
    * makes vectorisation easy */
-#line 2985
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2985
     ni=Min(nelems-j,LOOPCNT);
-#line 2985
     if (realign) {
-#line 2985
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2985
     } else {
-#line 2985
-      xp = (float *) *xpp;
-#line 2985
+      xp = (ulonglong *) *xpp;
     }
-#line 2985
    /* copy the next block */
-#line 2985
 #pragma cdir loopcnt=LOOPCNT
-#line 2985
 #pragma cdir shortloop
-#line 2985
     for (i=0; i<ni; i++) {
-#line 2985
-      /* the normal case: */
-#line 2985
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2985
+      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2985
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2985
-    }
-#line 2985
-   /* copy workspace back if necessary */
-#line 2985
-    if (realign) {
-#line 2985
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2985
-      xp = (float *) *xpp;
-#line 2985
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > ULONGLONG_MAX ;
     }
-#line 2985
    /* update xpp and tp */
-#line 2985
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2985
     tp += ni;
-#line 2985
     *xpp = (void*)xp;
-#line 2985
   }
-#line 2985
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2985
 
-#line 2985
 #else   /* not SX */
-#line 2985
-
-#line 2985
-	char *xp = (char *) *xpp;
-#line 2985
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2985
 
-#line 2985
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2985
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2985
-		int lstatus = ncx_put_float_longlong(xp, tp);
-#line 2985
+		const int lstatus = ncx_get_ulonglong_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2985
 			status = lstatus;
-#line 2985
 	}
-#line 2985
 
-#line 2985
-	*xpp = (void *)xp;
-#line 2985
+	*xpp = (const void *)xp;
 	return status;
-#line 2985
-#endif
-#line 2985
+#  endif
 }
-#line 2985
 
+#endif
 int
-#line 2986
-ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 2986
+ncx_getn_ulonglong_schar(const void **xpp, size_t nelems, schar *tp)
 {
-#line 2986
-#if _SX && X_SIZEOF_FLOAT == SIZEOF_FLOAT
-#line 2986
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2986
  /* basic algorithm is:
-#line 2986
-  *   - ensure sane alignment of output data
-#line 2986
+  *   - ensure sane alignment of input data
   *   - copy (conversion happens automatically) input data
-#line 2986
   *     to output
-#line 2986
-  *   - update tp to point at next unconverted input, and xpp to point
-#line 2986
+  *   - update xpp to point at next unconverted input, and tp to point
   *     at next location for converted output
-#line 2986
   */
-#line 2986
   long i, j, ni;
-#line 2986
-  float tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2986
-  float *xp;
-#line 2986
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2986
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2986
   long cxp = (long) *((char**)xpp);
-#line 2986
 
-#line 2986
-  realign = (cxp & 7) % SIZEOF_FLOAT;
-#line 2986
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2986
    * vector work space reserved to LOOPCNT elements. Also
-#line 2986
    * makes vectorisation easy */
-#line 2986
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2986
     ni=Min(nelems-j,LOOPCNT);
-#line 2986
     if (realign) {
-#line 2986
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2986
     } else {
-#line 2986
-      xp = (float *) *xpp;
-#line 2986
+      xp = (ulonglong *) *xpp;
     }
-#line 2986
    /* copy the next block */
-#line 2986
 #pragma cdir loopcnt=LOOPCNT
-#line 2986
 #pragma cdir shortloop
-#line 2986
     for (i=0; i<ni; i++) {
-#line 2986
-      /* the normal case: */
-#line 2986
-      xp[i] = (float) Max( X_FLOAT_MIN, Min(X_FLOAT_MAX, (float) tp[i]));
-#line 2986
+      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2986
-      nrange += tp[i] < X_FLOAT_MIN || tp[i] > X_FLOAT_MAX;
-#line 2986
-    }
-#line 2986
-   /* copy workspace back if necessary */
-#line 2986
-    if (realign) {
-#line 2986
-      memcpy(*xpp, tmp, ni*X_SIZEOF_FLOAT);
-#line 2986
-      xp = (float *) *xpp;
-#line 2986
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SCHAR_MAX ;
     }
-#line 2986
    /* update xpp and tp */
-#line 2986
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2986
     tp += ni;
-#line 2986
     *xpp = (void*)xp;
-#line 2986
   }
-#line 2986
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2986
 
-#line 2986
 #else   /* not SX */
-#line 2986
-
-#line 2986
-	char *xp = (char *) *xpp;
-#line 2986
+	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
-#line 2986
 
-#line 2986
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
-#line 2986
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2986
-		int lstatus = ncx_put_float_ulonglong(xp, tp);
-#line 2986
+		const int lstatus = ncx_get_ulonglong_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2986
 			status = lstatus;
-#line 2986
 	}
-#line 2986
 
-#line 2986
-	*xpp = (void *)xp;
-#line 2986
+	*xpp = (const void *)xp;
 	return status;
-#line 2986
-#endif
-#line 2986
+#  endif
 }
-#line 2986
-
-
-/* double */
 
 int
-#line 2990
-ncx_getn_double_schar(const void **xpp, size_t nelems, schar *tp)
-#line 2990
+ncx_getn_ulonglong_short(const void **xpp, size_t nelems, short *tp)
 {
-#line 2990
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2990
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2990
  /* basic algorithm is:
-#line 2990
   *   - ensure sane alignment of input data
-#line 2990
   *   - copy (conversion happens automatically) input data
-#line 2990
   *     to output
-#line 2990
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2990
   *     at next location for converted output
-#line 2990
   */
-#line 2990
   long i, j, ni;
-#line 2990
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2990
-  double *xp;
-#line 2990
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2990
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2990
   long cxp = (long) *((char**)xpp);
-#line 2990
 
-#line 2990
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2990
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2990
    * vector work space reserved to LOOPCNT elements. Also
-#line 2990
    * makes vectorisation easy */
-#line 2990
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2990
     ni=Min(nelems-j,LOOPCNT);
-#line 2990
     if (realign) {
-#line 2990
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2990
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2990
     } else {
-#line 2990
-      xp = (double *) *xpp;
-#line 2990
+      xp = (ulonglong *) *xpp;
     }
-#line 2990
    /* copy the next block */
-#line 2990
 #pragma cdir loopcnt=LOOPCNT
-#line 2990
 #pragma cdir shortloop
-#line 2990
     for (i=0; i<ni; i++) {
-#line 2990
-      tp[i] = (schar) Max( SCHAR_MIN, Min(SCHAR_MAX, (schar) xp[i]));
-#line 2990
+      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2990
-      nrange += xp[i] < SCHAR_MIN || xp[i] > SCHAR_MAX;
-#line 2990
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > SHORT_MAX ;
     }
-#line 2990
    /* update xpp and tp */
-#line 2990
-    if (realign) xp = (double *) *xpp;
-#line 2990
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2990
     tp += ni;
-#line 2990
     *xpp = (void*)xp;
-#line 2990
   }
-#line 2990
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2990
 
-#line 2990
 #else   /* not SX */
-#line 2990
 	const char *xp = (const char *) *xpp;
-#line 2990
 	int status = ENOERR;
-#line 2990
 
-#line 2990
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2990
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2990
-		const int lstatus = ncx_get_double_schar(xp, tp);
-#line 2990
+		const int lstatus = ncx_get_ulonglong_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 2990
 			status = lstatus;
-#line 2990
 	}
-#line 2990
 
-#line 2990
 	*xpp = (const void *)xp;
-#line 2990
 	return status;
-#line 2990
 #  endif
-#line 2990
 }
-#line 2990
 
 int
-#line 2991
-ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *tp)
-#line 2991
+ncx_getn_ulonglong_int(const void **xpp, size_t nelems, int *tp)
 {
-#line 2991
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2991
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2991
  /* basic algorithm is:
-#line 2991
   *   - ensure sane alignment of input data
-#line 2991
   *   - copy (conversion happens automatically) input data
-#line 2991
   *     to output
-#line 2991
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2991
   *     at next location for converted output
-#line 2991
   */
-#line 2991
   long i, j, ni;
-#line 2991
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2991
-  double *xp;
-#line 2991
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2991
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2991
   long cxp = (long) *((char**)xpp);
-#line 2991
 
-#line 2991
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2991
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2991
    * vector work space reserved to LOOPCNT elements. Also
-#line 2991
    * makes vectorisation easy */
-#line 2991
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2991
     ni=Min(nelems-j,LOOPCNT);
-#line 2991
     if (realign) {
-#line 2991
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2991
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2991
     } else {
-#line 2991
-      xp = (double *) *xpp;
-#line 2991
+      xp = (ulonglong *) *xpp;
     }
-#line 2991
    /* copy the next block */
-#line 2991
 #pragma cdir loopcnt=LOOPCNT
-#line 2991
 #pragma cdir shortloop
-#line 2991
     for (i=0; i<ni; i++) {
-#line 2991
-      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
-#line 2991
+      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2991
-      nrange += xp[i] < UCHAR_MIN || xp[i] > UCHAR_MAX;
-#line 2991
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > INT_MAX ;
     }
-#line 2991
    /* update xpp and tp */
-#line 2991
-    if (realign) xp = (double *) *xpp;
-#line 2991
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2991
     tp += ni;
-#line 2991
     *xpp = (void*)xp;
-#line 2991
   }
-#line 2991
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2991
 
-#line 2991
 #else   /* not SX */
-#line 2991
 	const char *xp = (const char *) *xpp;
-#line 2991
 	int status = ENOERR;
-#line 2991
 
-#line 2991
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2991
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2991
-		const int lstatus = ncx_get_double_uchar(xp, tp);
-#line 2991
+		const int lstatus = ncx_get_ulonglong_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 2991
 			status = lstatus;
-#line 2991
 	}
-#line 2991
 
-#line 2991
 	*xpp = (const void *)xp;
-#line 2991
 	return status;
-#line 2991
 #  endif
-#line 2991
 }
-#line 2991
 
 int
-#line 2992
-ncx_getn_double_short(const void **xpp, size_t nelems, short *tp)
-#line 2992
+ncx_getn_ulonglong_float(const void **xpp, size_t nelems, float *tp)
 {
-#line 2992
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2992
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2992
  /* basic algorithm is:
-#line 2992
   *   - ensure sane alignment of input data
-#line 2992
   *   - copy (conversion happens automatically) input data
-#line 2992
   *     to output
-#line 2992
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2992
   *     at next location for converted output
-#line 2992
   */
-#line 2992
   long i, j, ni;
-#line 2992
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2992
-  double *xp;
-#line 2992
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2992
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2992
   long cxp = (long) *((char**)xpp);
-#line 2992
 
-#line 2992
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2992
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2992
    * vector work space reserved to LOOPCNT elements. Also
-#line 2992
    * makes vectorisation easy */
-#line 2992
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2992
     ni=Min(nelems-j,LOOPCNT);
-#line 2992
     if (realign) {
-#line 2992
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2992
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2992
     } else {
-#line 2992
-      xp = (double *) *xpp;
-#line 2992
+      xp = (ulonglong *) *xpp;
     }
-#line 2992
    /* copy the next block */
-#line 2992
 #pragma cdir loopcnt=LOOPCNT
-#line 2992
 #pragma cdir shortloop
-#line 2992
     for (i=0; i<ni; i++) {
-#line 2992
-      tp[i] = (short) Max( SHORT_MIN, Min(SHORT_MAX, (short) xp[i]));
-#line 2992
+      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2992
-      nrange += xp[i] < SHORT_MIN || xp[i] > SHORT_MAX;
-#line 2992
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > FLOAT_MAX ;
     }
-#line 2992
    /* update xpp and tp */
-#line 2992
-    if (realign) xp = (double *) *xpp;
-#line 2992
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2992
     tp += ni;
-#line 2992
     *xpp = (void*)xp;
-#line 2992
   }
-#line 2992
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2992
 
-#line 2992
 #else   /* not SX */
-#line 2992
 	const char *xp = (const char *) *xpp;
-#line 2992
 	int status = ENOERR;
-#line 2992
 
-#line 2992
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2992
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2992
-		const int lstatus = ncx_get_double_short(xp, tp);
-#line 2992
+		const int lstatus = ncx_get_ulonglong_float(xp, tp);
 		if(lstatus != ENOERR)
-#line 2992
 			status = lstatus;
-#line 2992
 	}
-#line 2992
 
-#line 2992
 	*xpp = (const void *)xp;
-#line 2992
 	return status;
-#line 2992
 #  endif
-#line 2992
 }
-#line 2992
 
 int
-#line 2993
-ncx_getn_double_int(const void **xpp, size_t nelems, int *tp)
-#line 2993
+ncx_getn_ulonglong_double(const void **xpp, size_t nelems, double *tp)
 {
-#line 2993
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2993
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2993
  /* basic algorithm is:
-#line 2993
   *   - ensure sane alignment of input data
-#line 2993
   *   - copy (conversion happens automatically) input data
-#line 2993
   *     to output
-#line 2993
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2993
   *     at next location for converted output
-#line 2993
   */
-#line 2993
   long i, j, ni;
-#line 2993
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2993
-  double *xp;
-#line 2993
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2993
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2993
   long cxp = (long) *((char**)xpp);
-#line 2993
 
-#line 2993
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2993
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2993
    * vector work space reserved to LOOPCNT elements. Also
-#line 2993
    * makes vectorisation easy */
-#line 2993
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2993
     ni=Min(nelems-j,LOOPCNT);
-#line 2993
     if (realign) {
-#line 2993
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2993
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2993
     } else {
-#line 2993
-      xp = (double *) *xpp;
-#line 2993
+      xp = (ulonglong *) *xpp;
     }
-#line 2993
    /* copy the next block */
-#line 2993
 #pragma cdir loopcnt=LOOPCNT
-#line 2993
 #pragma cdir shortloop
-#line 2993
     for (i=0; i<ni; i++) {
-#line 2993
-      tp[i] = (int) Max( INT_MIN, Min(INT_MAX, (int) xp[i]));
-#line 2993
+      tp[i] = (double) Max( DOUBLE_MIN, Min(DOUBLE_MAX, (double) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2993
-      nrange += xp[i] < INT_MIN || xp[i] > INT_MAX;
-#line 2993
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > DOUBLE_MAX ;
     }
-#line 2993
    /* update xpp and tp */
-#line 2993
-    if (realign) xp = (double *) *xpp;
-#line 2993
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2993
     tp += ni;
-#line 2993
     *xpp = (void*)xp;
-#line 2993
   }
-#line 2993
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2993
 
-#line 2993
 #else   /* not SX */
-#line 2993
 	const char *xp = (const char *) *xpp;
-#line 2993
 	int status = ENOERR;
-#line 2993
 
-#line 2993
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2993
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2993
-		const int lstatus = ncx_get_double_int(xp, tp);
-#line 2993
+		const int lstatus = ncx_get_ulonglong_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 2993
 			status = lstatus;
-#line 2993
 	}
-#line 2993
 
-#line 2993
 	*xpp = (const void *)xp;
-#line 2993
 	return status;
-#line 2993
 #  endif
-#line 2993
 }
-#line 2993
 
 int
-#line 2994
-ncx_getn_double_float(const void **xpp, size_t nelems, float *tp)
-#line 2994
+ncx_getn_ulonglong_longlong(const void **xpp, size_t nelems, longlong *tp)
 {
-#line 2994
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2994
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2994
  /* basic algorithm is:
-#line 2994
   *   - ensure sane alignment of input data
-#line 2994
   *   - copy (conversion happens automatically) input data
-#line 2994
   *     to output
-#line 2994
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2994
   *     at next location for converted output
-#line 2994
   */
-#line 2994
   long i, j, ni;
-#line 2994
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2994
-  double *xp;
-#line 2994
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2994
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2994
   long cxp = (long) *((char**)xpp);
-#line 2994
 
-#line 2994
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2994
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2994
    * vector work space reserved to LOOPCNT elements. Also
-#line 2994
    * makes vectorisation easy */
-#line 2994
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2994
     ni=Min(nelems-j,LOOPCNT);
-#line 2994
     if (realign) {
-#line 2994
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2994
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2994
     } else {
-#line 2994
-      xp = (double *) *xpp;
-#line 2994
+      xp = (ulonglong *) *xpp;
     }
-#line 2994
    /* copy the next block */
-#line 2994
 #pragma cdir loopcnt=LOOPCNT
-#line 2994
 #pragma cdir shortloop
-#line 2994
     for (i=0; i<ni; i++) {
-#line 2994
-      tp[i] = (float) Max( FLOAT_MIN, Min(FLOAT_MAX, (float) xp[i]));
-#line 2994
+      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2994
-      nrange += xp[i] < FLOAT_MIN || xp[i] > FLOAT_MAX;
-#line 2994
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > LONGLONG_MAX ;
     }
-#line 2994
    /* update xpp and tp */
-#line 2994
-    if (realign) xp = (double *) *xpp;
-#line 2994
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2994
     tp += ni;
-#line 2994
     *xpp = (void*)xp;
-#line 2994
   }
-#line 2994
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2994
 
-#line 2994
 #else   /* not SX */
-#line 2994
 	const char *xp = (const char *) *xpp;
-#line 2994
 	int status = ENOERR;
-#line 2994
 
-#line 2994
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2994
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2994
-		const int lstatus = ncx_get_double_float(xp, tp);
-#line 2994
+		const int lstatus = ncx_get_ulonglong_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 2994
 			status = lstatus;
-#line 2994
 	}
-#line 2994
 
-#line 2994
 	*xpp = (const void *)xp;
-#line 2994
 	return status;
-#line 2994
 #  endif
-#line 2994
 }
-#line 2994
 
-#line 2996
 int
-#line 2996
-ncx_getn_double_uint(const void **xpp, size_t nelems, uint *tp)
-#line 2996
+ncx_getn_ulonglong_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
-#line 2996
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2996
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2996
  /* basic algorithm is:
-#line 2996
   *   - ensure sane alignment of input data
-#line 2996
   *   - copy (conversion happens automatically) input data
-#line 2996
   *     to output
-#line 2996
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2996
   *     at next location for converted output
-#line 2996
   */
-#line 2996
   long i, j, ni;
-#line 2996
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2996
-  double *xp;
-#line 2996
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2996
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2996
   long cxp = (long) *((char**)xpp);
-#line 2996
 
-#line 2996
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2996
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2996
    * vector work space reserved to LOOPCNT elements. Also
-#line 2996
    * makes vectorisation easy */
-#line 2996
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2996
     ni=Min(nelems-j,LOOPCNT);
-#line 2996
     if (realign) {
-#line 2996
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2996
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2996
     } else {
-#line 2996
-      xp = (double *) *xpp;
-#line 2996
+      xp = (ulonglong *) *xpp;
     }
-#line 2996
    /* copy the next block */
-#line 2996
 #pragma cdir loopcnt=LOOPCNT
-#line 2996
 #pragma cdir shortloop
-#line 2996
     for (i=0; i<ni; i++) {
-#line 2996
-      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
-#line 2996
+      tp[i] = (uchar) Max( UCHAR_MIN, Min(UCHAR_MAX, (uchar) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2996
-      nrange += xp[i] < UINT_MIN || xp[i] > UINT_MAX;
-#line 2996
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UCHAR_MAX ;
     }
-#line 2996
    /* update xpp and tp */
-#line 2996
-    if (realign) xp = (double *) *xpp;
-#line 2996
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2996
     tp += ni;
-#line 2996
     *xpp = (void*)xp;
-#line 2996
   }
-#line 2996
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2996
 
-#line 2996
 #else   /* not SX */
-#line 2996
 	const char *xp = (const char *) *xpp;
-#line 2996
 	int status = ENOERR;
-#line 2996
 
-#line 2996
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2996
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2996
-		const int lstatus = ncx_get_double_uint(xp, tp);
-#line 2996
+		const int lstatus = ncx_get_ulonglong_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 2996
 			status = lstatus;
-#line 2996
 	}
-#line 2996
 
-#line 2996
 	*xpp = (const void *)xp;
-#line 2996
 	return status;
-#line 2996
 #  endif
-#line 2996
 }
-#line 2996
 
 int
-#line 2997
-ncx_getn_double_longlong(const void **xpp, size_t nelems, longlong *tp)
-#line 2997
+ncx_getn_ulonglong_ushort(const void **xpp, size_t nelems, ushort *tp)
 {
-#line 2997
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2997
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2997
  /* basic algorithm is:
-#line 2997
   *   - ensure sane alignment of input data
-#line 2997
   *   - copy (conversion happens automatically) input data
-#line 2997
   *     to output
-#line 2997
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2997
   *     at next location for converted output
-#line 2997
   */
-#line 2997
   long i, j, ni;
-#line 2997
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2997
-  double *xp;
-#line 2997
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2997
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2997
   long cxp = (long) *((char**)xpp);
-#line 2997
 
-#line 2997
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2997
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2997
    * vector work space reserved to LOOPCNT elements. Also
-#line 2997
    * makes vectorisation easy */
-#line 2997
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2997
     ni=Min(nelems-j,LOOPCNT);
-#line 2997
     if (realign) {
-#line 2997
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2997
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2997
     } else {
-#line 2997
-      xp = (double *) *xpp;
-#line 2997
+      xp = (ulonglong *) *xpp;
     }
-#line 2997
    /* copy the next block */
-#line 2997
 #pragma cdir loopcnt=LOOPCNT
-#line 2997
 #pragma cdir shortloop
-#line 2997
     for (i=0; i<ni; i++) {
-#line 2997
-      tp[i] = (longlong) Max( LONGLONG_MIN, Min(LONGLONG_MAX, (longlong) xp[i]));
-#line 2997
+      tp[i] = (ushort) Max( USHORT_MIN, Min(USHORT_MAX, (ushort) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2997
-      nrange += xp[i] < LONGLONG_MIN || xp[i] > LONGLONG_MAX;
-#line 2997
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > USHORT_MAX ;
     }
-#line 2997
    /* update xpp and tp */
-#line 2997
-    if (realign) xp = (double *) *xpp;
-#line 2997
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2997
     tp += ni;
-#line 2997
     *xpp = (void*)xp;
-#line 2997
   }
-#line 2997
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2997
 
-#line 2997
 #else   /* not SX */
-#line 2997
 	const char *xp = (const char *) *xpp;
-#line 2997
 	int status = ENOERR;
-#line 2997
 
-#line 2997
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2997
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2997
-		const int lstatus = ncx_get_double_longlong(xp, tp);
-#line 2997
+		const int lstatus = ncx_get_ulonglong_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 2997
 			status = lstatus;
-#line 2997
 	}
-#line 2997
 
-#line 2997
 	*xpp = (const void *)xp;
-#line 2997
 	return status;
-#line 2997
 #  endif
-#line 2997
 }
-#line 2997
 
 int
-#line 2998
-ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *tp)
-#line 2998
+ncx_getn_ulonglong_uint(const void **xpp, size_t nelems, uint *tp)
 {
-#line 2998
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 2998
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 2998
  /* basic algorithm is:
-#line 2998
   *   - ensure sane alignment of input data
-#line 2998
   *   - copy (conversion happens automatically) input data
-#line 2998
   *     to output
-#line 2998
   *   - update xpp to point at next unconverted input, and tp to point
-#line 2998
   *     at next location for converted output
-#line 2998
   */
-#line 2998
   long i, j, ni;
-#line 2998
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 2998
-  double *xp;
-#line 2998
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 2998
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 2998
   long cxp = (long) *((char**)xpp);
-#line 2998
 
-#line 2998
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 2998
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 2998
    * vector work space reserved to LOOPCNT elements. Also
-#line 2998
    * makes vectorisation easy */
-#line 2998
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 2998
     ni=Min(nelems-j,LOOPCNT);
-#line 2998
     if (realign) {
-#line 2998
-      memcpy(tmp, *xpp, ni*SIZEOF_DOUBLE);
-#line 2998
+      memcpy(tmp, *xpp, ni*SIZEOF_ULONGLONG);
       xp = tmp;
-#line 2998
     } else {
-#line 2998
-      xp = (double *) *xpp;
-#line 2998
+      xp = (ulonglong *) *xpp;
     }
-#line 2998
    /* copy the next block */
-#line 2998
 #pragma cdir loopcnt=LOOPCNT
-#line 2998
 #pragma cdir shortloop
-#line 2998
     for (i=0; i<ni; i++) {
-#line 2998
-      tp[i] = (ulonglong) Max( ULONGLONG_MIN, Min(ULONGLONG_MAX, (ulonglong) xp[i]));
-#line 2998
+      tp[i] = (uint) Max( UINT_MIN, Min(UINT_MAX, (uint) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 2998
-      nrange += xp[i] < ULONGLONG_MIN || xp[i] > ULONGLONG_MAX;
-#line 2998
+     /* if xpp is unsigned, we need not check if xp[i] < _MIN */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > UINT_MAX ;
     }
-#line 2998
    /* update xpp and tp */
-#line 2998
-    if (realign) xp = (double *) *xpp;
-#line 2998
+    if (realign) xp = (ulonglong *) *xpp;
     xp += ni;
-#line 2998
     tp += ni;
-#line 2998
     *xpp = (void*)xp;
-#line 2998
   }
-#line 2998
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 2998
 
-#line 2998
 #else   /* not SX */
-#line 2998
 	const char *xp = (const char *) *xpp;
-#line 2998
 	int status = ENOERR;
-#line 2998
 
-#line 2998
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 2998
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 2998
-		const int lstatus = ncx_get_double_ulonglong(xp, tp);
-#line 2998
+		const int lstatus = ncx_get_ulonglong_uint(xp, tp);
 		if(lstatus != ENOERR)
-#line 2998
 			status = lstatus;
-#line 2998
 	}
-#line 2998
 
-#line 2998
 	*xpp = (const void *)xp;
-#line 2998
 	return status;
-#line 2998
 #  endif
-#line 2998
 }
-#line 2998
 
-#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
+
+#if X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 /* optimized version */
 int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
+ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const unsigned long long *tp)
 {
 #ifdef WORDS_BIGENDIAN
-	(void) memcpy(tp, *xpp, nelems * sizeof(double));
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_ULONGLONG);
 # else
-	swapn8b(tp, *xpp, nelems);
+	swapn8b(*xpp, tp, nelems);
 # endif
-	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_ULONGLONG);
 	return ENOERR;
 }
-#elif vax
+#else
 int
-ncx_getn_double_double(const void **xpp, size_t ndoubles, double *ip)
+ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
 {
-	double *const end = ip + ndoubles;
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-	while(ip < end)
-	{
-	struct vax_double *const vdp =
-#line 3020
-			 (struct vax_double *)ip;
-#line 3020
-	const struct ieee_double *const idp =
-#line 3020
-			 (const struct ieee_double *) (*xpp);
-#line 3020
-	{
-#line 3020
-		const struct dbl_limits *lim;
-#line 3020
-		int ii;
-#line 3020
-		for (ii = 0, lim = dbl_limits;
-#line 3020
-			ii < sizeof(dbl_limits)/sizeof(struct dbl_limits);
-#line 3020
-			ii++, lim++)
-#line 3020
-		{
-#line 3020
-			if ((idp->mant_lo == lim->ieee.mant_lo)
-#line 3020
-				&& (idp->mant_4 == lim->ieee.mant_4)
-#line 3020
-				&& (idp->mant_5 == lim->ieee.mant_5)
-#line 3020
-				&& (idp->mant_6 == lim->ieee.mant_6)
-#line 3020
-				&& (idp->exp_lo == lim->ieee.exp_lo)
-#line 3020
-				&& (idp->exp_hi == lim->ieee.exp_hi)
-#line 3020
-				)
-#line 3020
-			{
-#line 3020
-				*vdp = lim->d;
-#line 3020
-				goto doneit;
-#line 3020
-			}
-#line 3020
-		}
-#line 3020
-	}
-#line 3020
-	{
-#line 3020
-		unsigned exp = idp->exp_hi << 4 | idp->exp_lo;
-#line 3020
-		vdp->exp = exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
-#line 3020
-	}
-#line 3020
-	{
-#line 3020
-		unsigned mant_hi = ((idp->mant_6 << 16)
-#line 3020
-				 | (idp->mant_5 << 8)
-#line 3020
-				 | idp->mant_4);
-#line 3020
-		unsigned mant_lo = SWAP4(idp->mant_lo);
-#line 3020
-		vdp->mantissa1 = (mant_hi >> 13);
-#line 3020
-		vdp->mantissa2 = ((mant_hi & MASK(13)) << 3)
-#line 3020
-				| (mant_lo >> 29);
-#line 3020
-		vdp->mantissa3 = (mant_lo >> 13);
-#line 3020
-		vdp->mantissa4 = (mant_lo << 3);
-#line 3020
-	}
-#line 3020
-	doneit:
-#line 3020
-		vdp->sign = idp->sign;
-#line 3020
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
+
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ulonglong *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-		ip++;
-		*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
-	}
-	return ENOERR;
-}
-	/* vax */
-#else
-int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
-{
-	const char *xp = *xpp;
+#else   /* not SX */
+
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
 
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-		const int lstatus = ncx_get_double_double(xp, tp);
+		int lstatus = ncx_put_ulonglong_ulonglong(xp, tp);
 		if(lstatus != ENOERR)
 			status = lstatus;
 	}
 
-	*xpp = (const void *)xp;
+	*xpp = (void *)xp;
 	return status;
+#endif
 }
 
 #endif
-
 int
-#line 3047
-ncx_putn_double_schar(void **xpp, size_t nelems, const schar *tp)
-#line 3047
+ncx_putn_ulonglong_schar(void **xpp, size_t nelems, const schar *tp)
 {
-#line 3047
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3047
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3047
  /* basic algorithm is:
-#line 3047
   *   - ensure sane alignment of output data
-#line 3047
   *   - copy (conversion happens automatically) input data
-#line 3047
   *     to output
-#line 3047
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3047
   *     at next location for converted output
-#line 3047
   */
-#line 3047
   long i, j, ni;
-#line 3047
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3047
-  double *xp;
-#line 3047
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3047
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3047
   long cxp = (long) *((char**)xpp);
-#line 3047
 
-#line 3047
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3047
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3047
    * vector work space reserved to LOOPCNT elements. Also
-#line 3047
    * makes vectorisation easy */
-#line 3047
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3047
     ni=Min(nelems-j,LOOPCNT);
-#line 3047
     if (realign) {
-#line 3047
       xp = tmp;
-#line 3047
     } else {
-#line 3047
-      xp = (double *) *xpp;
-#line 3047
+      xp = (ulonglong *) *xpp;
     }
-#line 3047
    /* copy the next block */
-#line 3047
 #pragma cdir loopcnt=LOOPCNT
-#line 3047
 #pragma cdir shortloop
-#line 3047
     for (i=0; i<ni; i++) {
-#line 3047
       /* the normal case: */
-#line 3047
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3047
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3047
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3047
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX || tp[i] < 0;
     }
-#line 3047
    /* copy workspace back if necessary */
-#line 3047
     if (realign) {
-#line 3047
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3047
-      xp = (double *) *xpp;
-#line 3047
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3047
    /* update xpp and tp */
-#line 3047
     xp += ni;
-#line 3047
     tp += ni;
-#line 3047
     *xpp = (void*)xp;
-#line 3047
   }
-#line 3047
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3047
 
-#line 3047
 #else   /* not SX */
-#line 3047
 
-#line 3047
 	char *xp = (char *) *xpp;
-#line 3047
 	int status = ENOERR;
-#line 3047
 
-#line 3047
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3047
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3047
-		int lstatus = ncx_put_double_schar(xp, tp);
-#line 3047
+		int lstatus = ncx_put_ulonglong_schar(xp, tp);
 		if(lstatus != ENOERR)
-#line 3047
 			status = lstatus;
-#line 3047
 	}
-#line 3047
 
-#line 3047
 	*xpp = (void *)xp;
-#line 3047
 	return status;
-#line 3047
 #endif
-#line 3047
 }
-#line 3047
 
 int
-#line 3048
-ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *tp)
-#line 3048
+ncx_putn_ulonglong_short(void **xpp, size_t nelems, const short *tp)
 {
-#line 3048
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3048
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3048
  /* basic algorithm is:
-#line 3048
   *   - ensure sane alignment of output data
-#line 3048
   *   - copy (conversion happens automatically) input data
-#line 3048
   *     to output
-#line 3048
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3048
   *     at next location for converted output
-#line 3048
   */
-#line 3048
   long i, j, ni;
-#line 3048
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3048
-  double *xp;
-#line 3048
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3048
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3048
   long cxp = (long) *((char**)xpp);
-#line 3048
 
-#line 3048
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3048
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3048
    * vector work space reserved to LOOPCNT elements. Also
-#line 3048
    * makes vectorisation easy */
-#line 3048
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3048
     ni=Min(nelems-j,LOOPCNT);
-#line 3048
     if (realign) {
-#line 3048
       xp = tmp;
-#line 3048
     } else {
-#line 3048
-      xp = (double *) *xpp;
-#line 3048
+      xp = (ulonglong *) *xpp;
     }
-#line 3048
    /* copy the next block */
-#line 3048
 #pragma cdir loopcnt=LOOPCNT
-#line 3048
 #pragma cdir shortloop
-#line 3048
     for (i=0; i<ni; i++) {
-#line 3048
       /* the normal case: */
-#line 3048
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3048
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3048
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3048
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX || tp[i] < 0;
     }
-#line 3048
    /* copy workspace back if necessary */
-#line 3048
     if (realign) {
-#line 3048
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3048
-      xp = (double *) *xpp;
-#line 3048
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3048
    /* update xpp and tp */
-#line 3048
     xp += ni;
-#line 3048
     tp += ni;
-#line 3048
     *xpp = (void*)xp;
-#line 3048
   }
-#line 3048
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3048
 
-#line 3048
 #else   /* not SX */
-#line 3048
 
-#line 3048
 	char *xp = (char *) *xpp;
-#line 3048
 	int status = ENOERR;
-#line 3048
 
-#line 3048
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3048
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3048
-		int lstatus = ncx_put_double_uchar(xp, tp);
-#line 3048
+		int lstatus = ncx_put_ulonglong_short(xp, tp);
 		if(lstatus != ENOERR)
-#line 3048
 			status = lstatus;
-#line 3048
 	}
-#line 3048
 
-#line 3048
 	*xpp = (void *)xp;
-#line 3048
 	return status;
-#line 3048
 #endif
-#line 3048
 }
-#line 3048
 
 int
-#line 3049
-ncx_putn_double_short(void **xpp, size_t nelems, const short *tp)
-#line 3049
+ncx_putn_ulonglong_int(void **xpp, size_t nelems, const int *tp)
 {
-#line 3049
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3049
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3049
  /* basic algorithm is:
-#line 3049
   *   - ensure sane alignment of output data
-#line 3049
   *   - copy (conversion happens automatically) input data
-#line 3049
   *     to output
-#line 3049
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3049
   *     at next location for converted output
-#line 3049
   */
-#line 3049
   long i, j, ni;
-#line 3049
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3049
-  double *xp;
-#line 3049
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3049
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3049
   long cxp = (long) *((char**)xpp);
-#line 3049
 
-#line 3049
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3049
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3049
    * vector work space reserved to LOOPCNT elements. Also
-#line 3049
    * makes vectorisation easy */
-#line 3049
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3049
     ni=Min(nelems-j,LOOPCNT);
-#line 3049
     if (realign) {
-#line 3049
       xp = tmp;
-#line 3049
     } else {
-#line 3049
-      xp = (double *) *xpp;
-#line 3049
+      xp = (ulonglong *) *xpp;
     }
-#line 3049
    /* copy the next block */
-#line 3049
 #pragma cdir loopcnt=LOOPCNT
-#line 3049
 #pragma cdir shortloop
-#line 3049
     for (i=0; i<ni; i++) {
-#line 3049
       /* the normal case: */
-#line 3049
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3049
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3049
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3049
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX || tp[i] < 0;
     }
-#line 3049
    /* copy workspace back if necessary */
-#line 3049
     if (realign) {
-#line 3049
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3049
-      xp = (double *) *xpp;
-#line 3049
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3049
    /* update xpp and tp */
-#line 3049
     xp += ni;
-#line 3049
     tp += ni;
-#line 3049
     *xpp = (void*)xp;
-#line 3049
   }
-#line 3049
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3049
 
-#line 3049
 #else   /* not SX */
-#line 3049
 
-#line 3049
 	char *xp = (char *) *xpp;
-#line 3049
 	int status = ENOERR;
-#line 3049
 
-#line 3049
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3049
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3049
-		int lstatus = ncx_put_double_short(xp, tp);
-#line 3049
+		int lstatus = ncx_put_ulonglong_int(xp, tp);
 		if(lstatus != ENOERR)
-#line 3049
 			status = lstatus;
-#line 3049
 	}
-#line 3049
 
-#line 3049
 	*xpp = (void *)xp;
-#line 3049
 	return status;
-#line 3049
 #endif
-#line 3049
 }
-#line 3049
 
 int
-#line 3050
-ncx_putn_double_int(void **xpp, size_t nelems, const int *tp)
-#line 3050
+ncx_putn_ulonglong_float(void **xpp, size_t nelems, const float *tp)
 {
-#line 3050
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3050
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3050
  /* basic algorithm is:
-#line 3050
   *   - ensure sane alignment of output data
-#line 3050
   *   - copy (conversion happens automatically) input data
-#line 3050
   *     to output
-#line 3050
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3050
   *     at next location for converted output
-#line 3050
   */
-#line 3050
   long i, j, ni;
-#line 3050
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3050
-  double *xp;
-#line 3050
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3050
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3050
   long cxp = (long) *((char**)xpp);
-#line 3050
 
-#line 3050
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3050
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3050
    * vector work space reserved to LOOPCNT elements. Also
-#line 3050
    * makes vectorisation easy */
-#line 3050
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3050
     ni=Min(nelems-j,LOOPCNT);
-#line 3050
     if (realign) {
-#line 3050
       xp = tmp;
-#line 3050
     } else {
-#line 3050
-      xp = (double *) *xpp;
-#line 3050
+      xp = (ulonglong *) *xpp;
     }
-#line 3050
    /* copy the next block */
-#line 3050
 #pragma cdir loopcnt=LOOPCNT
-#line 3050
 #pragma cdir shortloop
-#line 3050
     for (i=0; i<ni; i++) {
-#line 3050
       /* the normal case: */
-#line 3050
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3050
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3050
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3050
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX || tp[i] < 0;
     }
-#line 3050
    /* copy workspace back if necessary */
-#line 3050
     if (realign) {
-#line 3050
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3050
-      xp = (double *) *xpp;
-#line 3050
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3050
    /* update xpp and tp */
-#line 3050
     xp += ni;
-#line 3050
     tp += ni;
-#line 3050
     *xpp = (void*)xp;
-#line 3050
   }
-#line 3050
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3050
 
-#line 3050
 #else   /* not SX */
-#line 3050
 
-#line 3050
 	char *xp = (char *) *xpp;
-#line 3050
 	int status = ENOERR;
-#line 3050
 
-#line 3050
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3050
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3050
-		int lstatus = ncx_put_double_int(xp, tp);
-#line 3050
+		int lstatus = ncx_put_ulonglong_float(xp, tp);
 		if(lstatus != ENOERR)
-#line 3050
 			status = lstatus;
-#line 3050
 	}
-#line 3050
 
-#line 3050
 	*xpp = (void *)xp;
-#line 3050
 	return status;
-#line 3050
 #endif
-#line 3050
 }
-#line 3050
 
 int
-#line 3051
-ncx_putn_double_float(void **xpp, size_t nelems, const float *tp)
-#line 3051
+ncx_putn_ulonglong_double(void **xpp, size_t nelems, const double *tp)
 {
-#line 3051
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3051
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3051
  /* basic algorithm is:
-#line 3051
   *   - ensure sane alignment of output data
-#line 3051
   *   - copy (conversion happens automatically) input data
-#line 3051
   *     to output
-#line 3051
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3051
   *     at next location for converted output
-#line 3051
   */
-#line 3051
   long i, j, ni;
-#line 3051
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3051
-  double *xp;
-#line 3051
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3051
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3051
   long cxp = (long) *((char**)xpp);
-#line 3051
 
-#line 3051
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3051
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3051
    * vector work space reserved to LOOPCNT elements. Also
-#line 3051
    * makes vectorisation easy */
-#line 3051
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3051
     ni=Min(nelems-j,LOOPCNT);
-#line 3051
     if (realign) {
-#line 3051
       xp = tmp;
-#line 3051
     } else {
-#line 3051
-      xp = (double *) *xpp;
-#line 3051
+      xp = (ulonglong *) *xpp;
     }
-#line 3051
    /* copy the next block */
-#line 3051
 #pragma cdir loopcnt=LOOPCNT
-#line 3051
 #pragma cdir shortloop
-#line 3051
     for (i=0; i<ni; i++) {
-#line 3051
       /* the normal case: */
-#line 3051
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3051
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3051
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3051
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX || tp[i] < 0;
     }
-#line 3051
    /* copy workspace back if necessary */
-#line 3051
     if (realign) {
-#line 3051
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3051
-      xp = (double *) *xpp;
-#line 3051
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3051
    /* update xpp and tp */
-#line 3051
     xp += ni;
-#line 3051
     tp += ni;
-#line 3051
     *xpp = (void*)xp;
-#line 3051
   }
-#line 3051
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3051
 
-#line 3051
 #else   /* not SX */
-#line 3051
 
-#line 3051
 	char *xp = (char *) *xpp;
-#line 3051
 	int status = ENOERR;
-#line 3051
 
-#line 3051
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3051
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3051
-		int lstatus = ncx_put_double_float(xp, tp);
-#line 3051
+		int lstatus = ncx_put_ulonglong_double(xp, tp);
 		if(lstatus != ENOERR)
-#line 3051
 			status = lstatus;
-#line 3051
 	}
-#line 3051
 
-#line 3051
 	*xpp = (void *)xp;
-#line 3051
 	return status;
-#line 3051
 #endif
-#line 3051
 }
-#line 3051
 
-#line 3053
 int
-#line 3053
-ncx_putn_double_uint(void **xpp, size_t nelems, const uint *tp)
-#line 3053
+ncx_putn_ulonglong_longlong(void **xpp, size_t nelems, const longlong *tp)
 {
-#line 3053
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3053
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3053
  /* basic algorithm is:
-#line 3053
   *   - ensure sane alignment of output data
-#line 3053
   *   - copy (conversion happens automatically) input data
-#line 3053
   *     to output
-#line 3053
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3053
   *     at next location for converted output
-#line 3053
   */
-#line 3053
   long i, j, ni;
-#line 3053
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3053
-  double *xp;
-#line 3053
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3053
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3053
   long cxp = (long) *((char**)xpp);
-#line 3053
 
-#line 3053
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3053
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3053
    * vector work space reserved to LOOPCNT elements. Also
-#line 3053
    * makes vectorisation easy */
-#line 3053
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3053
     ni=Min(nelems-j,LOOPCNT);
-#line 3053
     if (realign) {
-#line 3053
       xp = tmp;
-#line 3053
     } else {
-#line 3053
-      xp = (double *) *xpp;
-#line 3053
+      xp = (ulonglong *) *xpp;
     }
-#line 3053
    /* copy the next block */
-#line 3053
 #pragma cdir loopcnt=LOOPCNT
-#line 3053
 #pragma cdir shortloop
-#line 3053
     for (i=0; i<ni; i++) {
-#line 3053
       /* the normal case: */
-#line 3053
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3053
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3053
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3053
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX || tp[i] < 0;
     }
-#line 3053
    /* copy workspace back if necessary */
-#line 3053
     if (realign) {
-#line 3053
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3053
-      xp = (double *) *xpp;
-#line 3053
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3053
    /* update xpp and tp */
-#line 3053
     xp += ni;
-#line 3053
     tp += ni;
-#line 3053
     *xpp = (void*)xp;
-#line 3053
   }
-#line 3053
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3053
 
-#line 3053
 #else   /* not SX */
-#line 3053
 
-#line 3053
 	char *xp = (char *) *xpp;
-#line 3053
 	int status = ENOERR;
-#line 3053
 
-#line 3053
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3053
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3053
-		int lstatus = ncx_put_double_uint(xp, tp);
-#line 3053
+		int lstatus = ncx_put_ulonglong_longlong(xp, tp);
 		if(lstatus != ENOERR)
-#line 3053
 			status = lstatus;
-#line 3053
 	}
-#line 3053
 
-#line 3053
 	*xpp = (void *)xp;
-#line 3053
 	return status;
-#line 3053
 #endif
-#line 3053
 }
-#line 3053
 
 int
-#line 3054
-ncx_putn_double_longlong(void **xpp, size_t nelems, const longlong *tp)
-#line 3054
+ncx_putn_ulonglong_uchar(void **xpp, size_t nelems, const uchar *tp)
 {
-#line 3054
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3054
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3054
  /* basic algorithm is:
-#line 3054
   *   - ensure sane alignment of output data
-#line 3054
   *   - copy (conversion happens automatically) input data
-#line 3054
   *     to output
-#line 3054
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3054
   *     at next location for converted output
-#line 3054
   */
-#line 3054
   long i, j, ni;
-#line 3054
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3054
-  double *xp;
-#line 3054
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3054
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3054
   long cxp = (long) *((char**)xpp);
-#line 3054
 
-#line 3054
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3054
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3054
    * vector work space reserved to LOOPCNT elements. Also
-#line 3054
    * makes vectorisation easy */
-#line 3054
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3054
     ni=Min(nelems-j,LOOPCNT);
-#line 3054
     if (realign) {
-#line 3054
       xp = tmp;
-#line 3054
     } else {
-#line 3054
-      xp = (double *) *xpp;
-#line 3054
+      xp = (ulonglong *) *xpp;
     }
-#line 3054
    /* copy the next block */
-#line 3054
 #pragma cdir loopcnt=LOOPCNT
-#line 3054
 #pragma cdir shortloop
-#line 3054
     for (i=0; i<ni; i++) {
-#line 3054
       /* the normal case: */
-#line 3054
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3054
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3054
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3054
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX ;
     }
-#line 3054
    /* copy workspace back if necessary */
-#line 3054
     if (realign) {
-#line 3054
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3054
-      xp = (double *) *xpp;
-#line 3054
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3054
    /* update xpp and tp */
-#line 3054
     xp += ni;
-#line 3054
     tp += ni;
-#line 3054
     *xpp = (void*)xp;
-#line 3054
   }
-#line 3054
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3054
 
-#line 3054
 #else   /* not SX */
-#line 3054
 
-#line 3054
 	char *xp = (char *) *xpp;
-#line 3054
 	int status = ENOERR;
-#line 3054
 
-#line 3054
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3054
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3054
-		int lstatus = ncx_put_double_longlong(xp, tp);
-#line 3054
+		int lstatus = ncx_put_ulonglong_uchar(xp, tp);
 		if(lstatus != ENOERR)
-#line 3054
 			status = lstatus;
-#line 3054
 	}
-#line 3054
 
-#line 3054
 	*xpp = (void *)xp;
-#line 3054
 	return status;
-#line 3054
 #endif
-#line 3054
 }
-#line 3054
 
 int
-#line 3055
-ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *tp)
-#line 3055
+ncx_putn_ulonglong_ushort(void **xpp, size_t nelems, const ushort *tp)
 {
-#line 3055
-#if _SX && X_SIZEOF_DOUBLE == SIZEOF_DOUBLE
-#line 3055
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3055
  /* basic algorithm is:
-#line 3055
   *   - ensure sane alignment of output data
-#line 3055
   *   - copy (conversion happens automatically) input data
-#line 3055
   *     to output
-#line 3055
   *   - update tp to point at next unconverted input, and xpp to point
-#line 3055
   *     at next location for converted output
-#line 3055
   */
-#line 3055
   long i, j, ni;
-#line 3055
-  double tmp[LOOPCNT];        /* in case input is misaligned */
-#line 3055
-  double *xp;
-#line 3055
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
   int nrange = 0;         /* number of range errors */
-#line 3055
   int realign = 0;        /* "do we need to fix input data alignment?" */
-#line 3055
   long cxp = (long) *((char**)xpp);
-#line 3055
 
-#line 3055
-  realign = (cxp & 7) % SIZEOF_DOUBLE;
-#line 3055
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
   /* sjl: manually stripmine so we can limit amount of
-#line 3055
    * vector work space reserved to LOOPCNT elements. Also
-#line 3055
    * makes vectorisation easy */
-#line 3055
   for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
-#line 3055
     ni=Min(nelems-j,LOOPCNT);
-#line 3055
     if (realign) {
-#line 3055
       xp = tmp;
-#line 3055
     } else {
-#line 3055
-      xp = (double *) *xpp;
-#line 3055
+      xp = (ulonglong *) *xpp;
     }
-#line 3055
    /* copy the next block */
-#line 3055
 #pragma cdir loopcnt=LOOPCNT
-#line 3055
 #pragma cdir shortloop
-#line 3055
     for (i=0; i<ni; i++) {
-#line 3055
       /* the normal case: */
-#line 3055
-      xp[i] = (double) Max( X_DOUBLE_MIN, Min(X_DOUBLE_MAX, (double) tp[i]));
-#line 3055
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-#line 3055
-      nrange += tp[i] < X_DOUBLE_MIN || tp[i] > X_DOUBLE_MAX;
-#line 3055
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX ;
     }
-#line 3055
    /* copy workspace back if necessary */
-#line 3055
     if (realign) {
-#line 3055
-      memcpy(*xpp, tmp, ni*X_SIZEOF_DOUBLE);
-#line 3055
-      xp = (double *) *xpp;
-#line 3055
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
     }
-#line 3055
    /* update xpp and tp */
-#line 3055
     xp += ni;
-#line 3055
     tp += ni;
-#line 3055
     *xpp = (void*)xp;
-#line 3055
   }
-#line 3055
   return nrange == 0 ? ENOERR : NC_ERANGE;
-#line 3055
 
-#line 3055
 #else   /* not SX */
-#line 3055
 
-#line 3055
 	char *xp = (char *) *xpp;
-#line 3055
 	int status = ENOERR;
-#line 3055
 
-#line 3055
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
-#line 3055
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-#line 3055
-		int lstatus = ncx_put_double_ulonglong(xp, tp);
-#line 3055
+		int lstatus = ncx_put_ulonglong_ushort(xp, tp);
 		if(lstatus != ENOERR)
-#line 3055
 			status = lstatus;
-#line 3055
 	}
-#line 3055
 
-#line 3055
 	*xpp = (void *)xp;
-#line 3055
 	return status;
-#line 3055
 #endif
-#line 3055
 }
-#line 3055
 
-#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
-/* optimized version */
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
-#ifdef WORDS_BIGENDIAN
-	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_DOUBLE);
-# else
-	swapn8b(*xpp, tp, nelems);
-# endif
-	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
-	return ENOERR;
-}
-#elif vax
 int
-ncx_putn_double_double(void **xpp, size_t ndoubles, const double *ip)
+ncx_putn_ulonglong_uint(void **xpp, size_t nelems, const uint *tp)
 {
-	const double *const end = ip + ndoubles;
-
-	while(ip < end)
-	{
-	const struct vax_double *const vdp =
-#line 3077
-			(const struct vax_double *)ip;
-#line 3077
-	struct ieee_double *const idp =
-#line 3077
-			 (struct ieee_double *) (*xpp);
-#line 3077
-
-#line 3077
-	if ((vdp->mantissa4 > (dbl_limits[0].d.mantissa4 - 3)) &&
-#line 3077
-		(vdp->mantissa3 == dbl_limits[0].d.mantissa3) &&
-#line 3077
-		(vdp->mantissa2 == dbl_limits[0].d.mantissa2) &&
-#line 3077
-		(vdp->mantissa1 == dbl_limits[0].d.mantissa1) &&
-#line 3077
-		(vdp->exp == dbl_limits[0].d.exp))
-#line 3077
-	{
-#line 3077
-		*idp = dbl_limits[0].ieee;
-#line 3077
-		goto shipit;
-#line 3077
-	}
-#line 3077
-	if ((vdp->mantissa4 == dbl_limits[1].d.mantissa4) &&
-#line 3077
-		(vdp->mantissa3 == dbl_limits[1].d.mantissa3) &&
-#line 3077
-		(vdp->mantissa2 == dbl_limits[1].d.mantissa2) &&
-#line 3077
-		(vdp->mantissa1 == dbl_limits[1].d.mantissa1) &&
-#line 3077
-		(vdp->exp == dbl_limits[1].d.exp))
-#line 3077
-	{
-#line 3077
-		*idp = dbl_limits[1].ieee;
-#line 3077
-		goto shipit;
-#line 3077
-	}
-#line 3077
-
-#line 3077
-	{
-#line 3077
-		unsigned exp = vdp->exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
-#line 3077
-
-#line 3077
-		unsigned mant_lo = ((vdp->mantissa2 & MASK(3)) << 29) |
-#line 3077
-			(vdp->mantissa3 << 13) |
-#line 3077
-			((vdp->mantissa4 >> 3) & MASK(13));
-#line 3077
-
-#line 3077
-		unsigned mant_hi = (vdp->mantissa1 << 13)
-#line 3077
-				 | (vdp->mantissa2 >> 3);
-#line 3077
+#if _SX && X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
 
-#line 3077
-		if((vdp->mantissa4 & 7) > 4)
-#line 3077
-		{
-#line 3077
-			/* round up */
-#line 3077
-			mant_lo++;
-#line 3077
-			if(mant_lo == 0)
-#line 3077
-			{
-#line 3077
-				mant_hi++;
-#line 3077
-				if(mant_hi > 0xffffff)
-#line 3077
-				{
-#line 3077
-					mant_hi = 0;
-#line 3077
-					exp++;
-#line 3077
-				}
-#line 3077
-			}
-#line 3077
-		}
-#line 3077
+ /* basic algorithm is:
+  *   - ensure sane alignment of output data
+  *   - copy (conversion happens automatically) input data
+  *     to output
+  *   - update tp to point at next unconverted input, and xpp to point
+  *     at next location for converted output
+  */
+  long i, j, ni;
+  ulonglong tmp[LOOPCNT];        /* in case input is misaligned */
+  ulonglong *xp;
+  int nrange = 0;         /* number of range errors */
+  int realign = 0;        /* "do we need to fix input data alignment?" */
+  long cxp = (long) *((char**)xpp);
 
-#line 3077
-		idp->mant_lo = SWAP4(mant_lo);
-#line 3077
-		idp->mant_6 = mant_hi >> 16;
-#line 3077
-		idp->mant_5 = (mant_hi & 0xff00) >> 8;
-#line 3077
-		idp->mant_4 = mant_hi;
-#line 3077
-		idp->exp_hi = exp >> 4;
-#line 3077
-		idp->exp_lo = exp;
-#line 3077
-	}
-#line 3077
+  realign = (cxp & 7) % SIZEOF_ULONGLONG;
+  /* sjl: manually stripmine so we can limit amount of
+   * vector work space reserved to LOOPCNT elements. Also
+   * makes vectorisation easy */
+  for (j=0; j<nelems && nrange==0; j+=LOOPCNT) {
+    ni=Min(nelems-j,LOOPCNT);
+    if (realign) {
+      xp = tmp;
+    } else {
+      xp = (ulonglong *) *xpp;
+    }
+   /* copy the next block */
+#pragma cdir loopcnt=LOOPCNT
+#pragma cdir shortloop
+    for (i=0; i<ni; i++) {
+      /* the normal case: */
+      xp[i] = (ulonglong) Max( X_ULONGLONG_MIN, Min(X_ULONGLONG_MAX, (ulonglong) tp[i]));
+     /* test for range errors (not always needed but do it anyway) */
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < X__MIN */
+      nrange += tp[i] > X_ULONGLONG_MAX ;
+    }
+   /* copy workspace back if necessary */
+    if (realign) {
+      memcpy(*xpp, tmp, ni*X_SIZEOF_ULONGLONG);
+      xp = (ulonglong *) *xpp;
+    }
+   /* update xpp and tp */
+    xp += ni;
+    tp += ni;
+    *xpp = (void*)xp;
+  }
+  return nrange == 0 ? ENOERR : NC_ERANGE;
 
-#line 3077
-	shipit:
-#line 3077
-		idp->sign = vdp->sign;
-#line 3077
+#else   /* not SX */
 
-		ip++;
-		*xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
-	}
-	return ENOERR;
-}
-	/* vax */
-#else
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
-	char *xp = *xpp;
+	char *xp = (char *) *xpp;
 	int status = ENOERR;
 
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
+	for( ; nelems != 0; nelems--, xp += X_SIZEOF_ULONGLONG, tp++)
 	{
-		int lstatus = ncx_put_double_double(xp, tp);
+		int lstatus = ncx_put_ulonglong_uint(xp, tp);
 		if(lstatus != ENOERR)
 			status = lstatus;
 	}
 
 	*xpp = (void *)xp;
 	return status;
+#endif
 }
 
-#endif
 
 
 /*
@@ -14113,11 +17234,8 @@ int
 ncx_getn_text(const void **xpp, size_t nelems, char *tp)
 {
 	(void) memcpy(tp, *xpp, nelems);
-#line 3114
 	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3114
 	return ENOERR;
-#line 3114
 
 }
 
@@ -14125,23 +17243,14 @@ int
 ncx_pad_getn_text(const void **xpp, size_t nelems, char *tp)
 {
 	size_t rndup = nelems % X_ALIGN;
-#line 3120
 
-#line 3120
 	if(rndup)
-#line 3120
 		rndup = X_ALIGN - rndup;
-#line 3120
 
-#line 3120
 	(void) memcpy(tp, *xpp, nelems);
-#line 3120
 	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 3120
 
-#line 3120
 	return ENOERR;
-#line 3120
 
 }
 
@@ -14149,13 +17258,9 @@ int
 ncx_putn_text(void **xpp, size_t nelems, const char *tp)
 {
 	(void) memcpy(*xpp, tp, nelems);
-#line 3126
 	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3126
 
-#line 3126
 	return ENOERR;
-#line 3126
 
 }
 
@@ -14163,35 +17268,20 @@ int
 ncx_pad_putn_text(void **xpp, size_t nelems, const char *tp)
 {
 	size_t rndup = nelems % X_ALIGN;
-#line 3132
 
-#line 3132
 	if(rndup)
-#line 3132
 		rndup = X_ALIGN - rndup;
-#line 3132
 
-#line 3132
 	(void) memcpy(*xpp, tp, nelems);
-#line 3132
 	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3132
 
-#line 3132
 	if(rndup)
-#line 3132
 	{
-#line 3132
 		(void) memcpy(*xpp, nada, rndup);
-#line 3132
 		*xpp = (void *)((char *)(*xpp) + rndup);
-#line 3132
 	}
-#line 3132
 
-#line 3132
 	return ENOERR;
-#line 3132
 
 }
 
@@ -14202,11 +17292,8 @@ int
 ncx_getn_void(const void **xpp, size_t nelems, void *tp)
 {
 	(void) memcpy(tp, *xpp, nelems);
-#line 3141
 	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3141
 	return ENOERR;
-#line 3141
 
 }
 
@@ -14214,23 +17301,14 @@ int
 ncx_pad_getn_void(const void **xpp, size_t nelems, void *tp)
 {
 	size_t rndup = nelems % X_ALIGN;
-#line 3147
 
-#line 3147
 	if(rndup)
-#line 3147
 		rndup = X_ALIGN - rndup;
-#line 3147
 
-#line 3147
 	(void) memcpy(tp, *xpp, nelems);
-#line 3147
 	*xpp = (void *)((char *)(*xpp) + nelems + rndup);
-#line 3147
 
-#line 3147
 	return ENOERR;
-#line 3147
 
 }
 
@@ -14238,13 +17316,9 @@ int
 ncx_putn_void(void **xpp, size_t nelems, const void *tp)
 {
 	(void) memcpy(*xpp, tp, nelems);
-#line 3153
 	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3153
 
-#line 3153
 	return ENOERR;
-#line 3153
 
 }
 
@@ -14252,34 +17326,19 @@ int
 ncx_pad_putn_void(void **xpp, size_t nelems, const void *tp)
 {
 	size_t rndup = nelems % X_ALIGN;
-#line 3159
 
-#line 3159
 	if(rndup)
-#line 3159
 		rndup = X_ALIGN - rndup;
-#line 3159
 
-#line 3159
 	(void) memcpy(*xpp, tp, nelems);
-#line 3159
 	*xpp = (void *)((char *)(*xpp) + nelems);
-#line 3159
 
-#line 3159
 	if(rndup)
-#line 3159
 	{
-#line 3159
 		(void) memcpy(*xpp, nada, rndup);
-#line 3159
 		*xpp = (void *)((char *)(*xpp) + rndup);
-#line 3159
 	}
-#line 3159
 
-#line 3159
 	return ENOERR;
-#line 3159
 
 }
diff --git a/libsrc/ncx.h b/libsrc/ncx.h
index 746df5f..3e4d0b6 100644
--- a/libsrc/ncx.h
+++ b/libsrc/ncx.h
@@ -2,7 +2,6 @@
  *	Copyright 1996, University Corporation for Atmospheric Research
  *	See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
-/* "$Id: ncx.h,v 1.65 2010/05/26 18:11:08 dmh Exp $" */
 
 #ifndef _NCX_H_
 #define _NCX_H_
@@ -32,8 +31,7 @@
 #include <stddef.h> /* size_t */
 #include <errno.h>
 #include <sys/types.h> /* off_t */
-#include <ncdispatch.h>
-#define longlong long long
+#include "ncdispatch.h"
 
 #if defined(_CRAY) && !defined(_CRAYIEEE) && !defined(__crayx1)
 #define CRAYFLOAT 1 /* CRAY Floating point */
@@ -43,7 +41,7 @@
 
 /*
  * The integer return code for the conversion routines
- * is 0 (ENOERR) when no error occured, or NC_ERANGE as appropriate
+ * is 0 (ENOERR) when no error occurred, or NC_ERANGE as appropriate
  * for an overflow conversion.
  */
 #ifndef ENOERR
@@ -64,11 +62,20 @@
 #define X_SIZEOF_SHORT		2
 #define X_SIZEOF_INT		4	/* xdr_int */
 #if 0
-#define X_SIZEOF_LONG		8 */	/* xdr_long_long */
+#define X_SIZEOF_LONG		8 */	/* alias */
 #endif
 #define X_SIZEOF_FLOAT		4
 #define X_SIZEOF_DOUBLE		8
 
+/* additional data types in CDF-5 */
+#define X_SIZEOF_UBYTE		1
+#define X_SIZEOF_USHORT		2
+#define X_SIZEOF_UINT		4
+#define X_SIZEOF_LONGLONG	8
+#define X_SIZEOF_ULONGLONG	8
+#define X_SIZEOF_INT64		8
+#define X_SIZEOF_UINT64		8
+
 /*
  * For now, netcdf is limited to 32 bit sizes,
  * If compiled with support for "large files", then
@@ -141,6 +148,21 @@
 #define ncx_len_double(nelems) \
 	((nelems) * X_SIZEOF_DOUBLE)
 
+#define ncx_len_ubyte(nelems) \
+	_RNDUP((nelems), X_ALIGN)
+
+#define ncx_len_ushort(nelems) \
+	(((nelems) + (nelems)%2)  * X_SIZEOF_USHORT)
+
+#define ncx_len_uint(nelems) \
+	((nelems) * X_SIZEOF_UINT)
+
+#define ncx_len_int64(nelems) \
+	((nelems) * X_SIZEOF_INT64)
+
+#define ncx_len_uint64(nelems) \
+	((nelems) * X_SIZEOF_UINT64)
+
 /* End ncx_len */
 
 #if __CHAR_UNSIGNED__
@@ -170,16 +192,16 @@ typedef signed char schar;
  *	);
  * where
  *	`external_type' and `internal_type' chosen from
-		schar
-		uchar
-		short
-		ushort
-		int
-		uint
-		long
-		ulong
-		float
-		double
+ *		schar
+ *		uchar
+ *		short
+ *		ushort
+ *		int
+ *		uint
+ *		float
+ *		double
+ *		longlong == int64 
+ *	        ulonglong == uint64
  *
  * Not all combinations make sense.
  * We may not implement all combinations that make sense.
@@ -192,10 +214,10 @@ typedef signed char schar;
  *
  * Storage for a single element of internal type is at `ip' argument.
  *
- * These functions return 0 (ENOERR) when no error occured,
+ * These functions return 0 (ENOERR) when no error occurred,
  * or NC_ERANGE when the value being converted is too large.
  * When NC_ERANGE occurs, an undefined (implementation dependent)
- * conversion may have occured.
+ * conversion may have occurred.
  *
  * Note that loss of precision may occur silently.
  *
@@ -232,131 +254,6 @@ ncx_put_schar_float(void *xp, const float *ip);
 extern int
 ncx_put_schar_double(void *xp, const double *ip);
 #endif
- 
-
-extern int
-ncx_get_short_schar(const void *xp, schar *ip);
-extern int
-ncx_get_short_uchar(const void *xp, uchar *ip);
-extern int
-ncx_get_short_short(const void *xp, short *ip);
-extern int
-ncx_get_short_int(const void *xp, int *ip);
-extern int
-ncx_get_short_long(const void *xp, long *ip);
-extern int
-ncx_get_short_float(const void *xp, float *ip);
-extern int
-ncx_get_short_double(const void *xp, double *ip);
-
-extern int
-ncx_put_short_schar(void *xp, const schar *ip);
-extern int
-ncx_put_short_uchar(void *xp, const uchar *ip);
-extern int
-ncx_put_short_short(void *xp, const short *ip);
-extern int
-ncx_put_short_int(void *xp, const int *ip);
-extern int
-ncx_put_short_long(void *xp, const long *ip);
-extern int
-ncx_put_short_float(void *xp, const float *ip);
-extern int
-ncx_put_short_double(void *xp, const double *ip);
- 
-
-extern int
-ncx_get_int_schar(const void *xp, schar *ip);
-extern int
-ncx_get_int_uchar(const void *xp, uchar *ip);
-extern int
-ncx_get_int_short(const void *xp, short *ip);
-extern int
-ncx_get_int_int(const void *xp, int *ip);
-extern int
-ncx_get_int_long(const void *xp, long *ip);
-extern int
-ncx_get_int_float(const void *xp, float *ip);
-extern int
-ncx_get_int_double(const void *xp, double *ip);
-
-extern int
-ncx_put_int_schar(void *xp, const schar *ip);
-extern int
-ncx_put_int_uchar(void *xp, const uchar *ip);
-extern int
-ncx_put_int_short(void *xp, const short *ip);
-extern int
-ncx_put_int_int(void *xp, const int *ip);
-extern int
-ncx_put_int_long(void *xp, const long *ip);
-extern int
-ncx_put_int_float(void *xp, const float *ip);
-extern int
-ncx_put_int_double(void *xp, const double *ip);
- 
-
-extern int
-ncx_get_float_schar(const void *xp, schar *ip);
-extern int
-ncx_get_float_uchar(const void *xp, uchar *ip);
-extern int
-ncx_get_float_short(const void *xp, short *ip);
-extern int
-ncx_get_float_int(const void *xp, int *ip);
-extern int
-ncx_get_float_long(const void *xp, long *ip);
-extern int
-ncx_get_float_float(const void *xp, float *ip);
-extern int
-ncx_get_float_double(const void *xp, double *ip);
-
-extern int
-ncx_put_float_schar(void *xp, const schar *ip);
-extern int
-ncx_put_float_uchar(void *xp, const uchar *ip);
-extern int
-ncx_put_float_short(void *xp, const short *ip);
-extern int
-ncx_put_float_int(void *xp, const int *ip);
-extern int
-ncx_put_float_long(void *xp, const long *ip);
-extern int
-ncx_put_float_float(void *xp, const float *ip);
-extern int
-ncx_put_float_double(void *xp, const double *ip);
- 
-
-extern int
-ncx_get_double_schar(const void *xp, schar *ip);
-extern int
-ncx_get_double_uchar(const void *xp, uchar *ip);
-extern int
-ncx_get_double_short(const void *xp, short *ip);
-extern int
-ncx_get_double_int(const void *xp, int *ip);
-extern int
-ncx_get_double_long(const void *xp, long *ip);
-extern int
-ncx_get_double_float(const void *xp, float *ip);
-extern int
-ncx_get_double_double(const void *xp, double *ip);
-
-extern int
-ncx_put_double_schar(void *xp, const schar *ip);
-extern int
-ncx_put_double_uchar(void *xp, const uchar *ip);
-extern int
-ncx_put_double_short(void *xp, const short *ip);
-extern int
-ncx_put_double_int(void *xp, const int *ip);
-extern int
-ncx_put_double_long(void *xp, const long *ip);
-extern int
-ncx_put_double_float(void *xp, const float *ip);
-extern int
-ncx_put_double_double(void *xp, const double *ip);
- 
 
 /*
  * Other primitive conversion functions
@@ -378,6 +275,17 @@ ncx_put_size_t(void **xpp, const size_t *ulp);
 extern int
 ncx_put_off_t(void **xpp, const off_t *lp, size_t sizeof_off_t);
 
+extern int
+ncx_get_int32(const void **xpp, int *ip);
+extern int
+ncx_get_int64(const void **xpp, long long *ip);
+extern int
+ncx_put_int32(void **xpp, const int ip);
+extern int
+ncx_put_int64(void **xpp, const long long ip);
+
+extern int ncx_get_int_int(const void *xp, int *ip);
+extern int ncx_put_int_int(void *xp, const int *ip);
 
 /*
  * Aggregate numeric conversion functions.
@@ -419,303 +327,667 @@ ncx_put_off_t(void **xpp, const off_t *lp, size_t sizeof_off_t);
  *
  */
 
+/*---- schar ----------------------------------------------------------------*/
 extern int
-ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_getn_schar_schar (const void **xpp, size_t nelems, schar  *ip);
 extern int
-ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_getn_schar_uchar (const void **xpp, size_t nelems, uchar  *ip);
 extern int
-ncx_getn_schar_short(const void **xpp, size_t nelems, short *ip);
+ncx_getn_schar_short (const void **xpp, size_t nelems, short  *ip);
 extern int
-ncx_getn_schar_int(const void **xpp, size_t nelems, int *ip);
+ncx_getn_schar_ushort(const void **xpp, size_t nelems, ushort *ip);
 extern int
-ncx_getn_schar_long(const void **xpp, size_t nelems, long *ip);
+ncx_getn_schar_int   (const void **xpp, size_t nelems, int    *ip);
 extern int
-ncx_getn_schar_float(const void **xpp, size_t nelems, float *ip);
+ncx_getn_schar_uint  (const void **xpp, size_t nelems, uint   *ip);
 extern int
-ncx_getn_schar_double(const void **xpp, size_t nelems, double *ip);
+ncx_getn_schar_long  (const void **xpp, size_t nelems, long   *ip);
 extern int
-ncx_getn_schar_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_getn_schar_float (const void **xpp, size_t nelems, float  *ip);
 extern int
-ncx_getn_schar_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_getn_schar_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_schar_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_pad_getn_schar_schar (const void **xpp, size_t nelems, schar  *ip);
 extern int
-ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_pad_getn_schar_uchar (const void **xpp, size_t nelems, uchar  *ip);
 extern int
-ncx_pad_getn_schar_short(const void **xpp, size_t nelems, short *ip);
+ncx_pad_getn_schar_short (const void **xpp, size_t nelems, short  *ip);
 extern int
-ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *ip);
+ncx_pad_getn_schar_ushort(const void **xpp, size_t nelems, ushort *ip);
 extern int
-ncx_pad_getn_schar_long(const void **xpp, size_t nelems, long *ip);
+ncx_pad_getn_schar_int   (const void **xpp, size_t nelems, int    *ip);
 extern int
-ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *ip);
+ncx_pad_getn_schar_uint  (const void **xpp, size_t nelems, uint   *ip);
 extern int
-ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *ip);
+ncx_pad_getn_schar_long  (const void **xpp, size_t nelems, long   *ip);
 extern int
-ncx_pad_getn_schar_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_pad_getn_schar_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *ip);
 extern int
-ncx_pad_getn_schar_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_pad_getn_schar_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_putn_schar_schar (void **xpp, size_t nelems, const schar   *ip);
 extern int
-ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_putn_schar_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_putn_schar_short(void **xpp, size_t nelems, const short *ip);
+ncx_putn_schar_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_putn_schar_int(void **xpp, size_t nelems, const int *ip);
+ncx_putn_schar_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_putn_schar_long(void **xpp, size_t nelems, const long *ip);
+ncx_putn_schar_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_putn_schar_float(void **xpp, size_t nelems, const float *ip);
+ncx_putn_schar_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_putn_schar_double(void **xpp, size_t nelems, const double *ip);
+ncx_putn_schar_long  (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_putn_schar_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_putn_schar_float (void **xpp, size_t nelems, const float  *ip);
 extern int
-ncx_putn_schar_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_putn_schar_double(void **xpp, size_t nelems, const double  *ip);
+extern int
+ncx_putn_schar_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
  
 extern int
-ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_pad_putn_schar_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_pad_putn_schar_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *ip);
+ncx_pad_putn_schar_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *ip);
+ncx_pad_putn_schar_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_pad_putn_schar_long(void **xpp, size_t nelems, const long *ip);
+ncx_pad_putn_schar_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *ip);
+ncx_pad_putn_schar_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *ip);
+ncx_pad_putn_schar_long  (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_pad_putn_schar_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_pad_putn_schar_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *ip);
 extern int
-ncx_pad_putn_schar_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_pad_putn_schar_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
 
+/*---- uchar ----------------------------------------------------------------*/
+extern int
+ncx_getn_uchar_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_uchar_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_uchar_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *ip);
+extern int
+ncx_getn_uchar_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_uchar_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_uchar_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_uchar_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_uchar_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_uchar_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_getn_short_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_pad_getn_uchar_schar (const void **xpp, size_t nelems, schar  *ip);
 extern int
-ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_pad_getn_uchar_uchar (const void **xpp, size_t nelems, uchar  *ip);
 extern int
-ncx_getn_short_short(const void **xpp, size_t nelems, short *ip);
+ncx_pad_getn_uchar_short (const void **xpp, size_t nelems, short  *ip);
 extern int
-ncx_getn_short_int(const void **xpp, size_t nelems, int *ip);
+ncx_pad_getn_uchar_ushort(const void **xpp, size_t nelems, ushort *ip);
 extern int
-ncx_getn_short_long(const void **xpp, size_t nelems, long *ip);
+ncx_pad_getn_uchar_int   (const void **xpp, size_t nelems, int    *ip);
 extern int
-ncx_getn_short_float(const void **xpp, size_t nelems, float *ip);
+ncx_pad_getn_uchar_uint  (const void **xpp, size_t nelems, uint   *ip);
 extern int
-ncx_getn_short_double(const void **xpp, size_t nelems, double *ip);
+ncx_pad_getn_uchar_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_pad_getn_uchar_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_pad_getn_uchar_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_pad_getn_uchar_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_pad_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
+
+extern int
+ncx_putn_uchar_schar (void **xpp, size_t nelems, const schar   *ip);
 extern int
-ncx_getn_short_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_putn_uchar_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_getn_short_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_putn_uchar_short (void **xpp, size_t nelems, const short  *ip);
+extern int
+ncx_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *ip);
+extern int
+ncx_putn_uchar_int   (void **xpp, size_t nelems, const int    *ip);
+extern int
+ncx_putn_uchar_uint  (void **xpp, size_t nelems, const uint   *ip);
+extern int
+ncx_putn_uchar_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_putn_uchar_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_putn_uchar_double(void **xpp, size_t nelems, const double  *ip);
+extern int
+ncx_putn_uchar_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+ 
+extern int
+ncx_pad_putn_uchar_schar (void **xpp, size_t nelems, const schar  *ip);
+extern int
+ncx_pad_putn_uchar_uchar (void **xpp, size_t nelems, const uchar  *ip);
+extern int
+ncx_pad_putn_uchar_short (void **xpp, size_t nelems, const short  *ip);
+extern int
+ncx_pad_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *ip);
+extern int
+ncx_pad_putn_uchar_int   (void **xpp, size_t nelems, const int    *ip);
+extern int
+ncx_pad_putn_uchar_uint  (void **xpp, size_t nelems, const uint   *ip);
+extern int
+ncx_pad_putn_uchar_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_pad_putn_uchar_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_pad_putn_uchar_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_pad_putn_uchar_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_pad_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+
+/*---- short ----------------------------------------------------------------*/
+extern int
+ncx_getn_short_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_short_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_short_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_short_ushort(const void **xpp, size_t nelems, ushort *ip);
+extern int
+ncx_getn_short_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_short_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_short_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_short_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_short_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_short_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_pad_getn_short_schar (const void **xpp, size_t nelems, schar  *ip);
 extern int
-ncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_pad_getn_short_uchar (const void **xpp, size_t nelems, uchar  *ip);
 extern int
-ncx_pad_getn_short_short(const void **xpp, size_t nelems, short *ip);
+ncx_pad_getn_short_short (const void **xpp, size_t nelems, short  *ip);
 extern int
-ncx_pad_getn_short_int(const void **xpp, size_t nelems, int *ip);
+ncx_pad_getn_short_ushort(const void **xpp, size_t nelems, ushort *ip);
 extern int
-ncx_pad_getn_short_long(const void **xpp, size_t nelems, long *ip);
+ncx_pad_getn_short_int   (const void **xpp, size_t nelems, int    *ip);
 extern int
-ncx_pad_getn_short_float(const void **xpp, size_t nelems, float *ip);
+ncx_pad_getn_short_uint  (const void **xpp, size_t nelems, uint   *ip);
 extern int
-ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *ip);
+ncx_pad_getn_short_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_pad_getn_short_float (const void **xpp, size_t nelems, float  *ip);
 extern int
-ncx_pad_getn_short_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_pad_getn_short_double(const void **xpp, size_t nelems, double *ip);
 extern int
-ncx_pad_getn_short_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_pad_getn_short_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_putn_short_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_putn_short_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_putn_short_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_putn_short_short(void **xpp, size_t nelems, const short *ip);
+ncx_putn_short_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_putn_short_int(void **xpp, size_t nelems, const int *ip);
+ncx_putn_short_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_putn_short_long(void **xpp, size_t nelems, const long *ip);
+ncx_putn_short_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_putn_short_float(void **xpp, size_t nelems, const float *ip);
+ncx_putn_short_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_putn_short_double(void **xpp, size_t nelems, const double *ip);
+ncx_putn_short_long  (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_putn_short_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_putn_short_float (void **xpp, size_t nelems, const float  *ip);
 extern int
-ncx_putn_short_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_putn_short_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_putn_short_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
  
 extern int
-ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_pad_putn_short_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_pad_putn_short_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_pad_putn_short_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_pad_putn_short_short(void **xpp, size_t nelems, const short *ip);
+ncx_pad_putn_short_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *ip);
+ncx_pad_putn_short_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_pad_putn_short_long(void **xpp, size_t nelems, const long *ip);
+ncx_pad_putn_short_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_pad_putn_short_float(void **xpp, size_t nelems, const float *ip);
+ncx_pad_putn_short_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *ip);
+ncx_pad_putn_short_long  (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_pad_putn_short_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_pad_putn_short_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *ip);
 extern int
-ncx_pad_putn_short_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_pad_putn_short_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
 
+/*---- ushort ---------------------------------------------------------------*/
+extern int
+ncx_getn_ushort_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_ushort_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_ushort_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *ip);
+extern int
+ncx_getn_ushort_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_ushort_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_ushort_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_ushort_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_ushort_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_ushort_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_getn_int_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_pad_getn_ushort_schar (const void **xpp, size_t nelems, schar  *ip);
 extern int
-ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_pad_getn_ushort_uchar (const void **xpp, size_t nelems, uchar  *ip);
 extern int
-ncx_getn_int_short(const void **xpp, size_t nelems, short *ip);
+ncx_pad_getn_ushort_short (const void **xpp, size_t nelems, short  *ip);
 extern int
-ncx_getn_int_int(const void **xpp, size_t nelems, int *ip);
+ncx_pad_getn_ushort_ushort(const void **xpp, size_t nelems, ushort *ip);
 extern int
-ncx_getn_int_long(const void **xpp, size_t nelems, long *ip);
+ncx_pad_getn_ushort_int   (const void **xpp, size_t nelems, int    *ip);
 extern int
-ncx_getn_int_float(const void **xpp, size_t nelems, float *ip);
+ncx_pad_getn_ushort_uint  (const void **xpp, size_t nelems, uint   *ip);
 extern int
-ncx_getn_int_double(const void **xpp, size_t nelems, double *ip);
+ncx_pad_getn_ushort_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_pad_getn_ushort_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_pad_getn_ushort_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_pad_getn_ushort_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_pad_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
+
+extern int
+ncx_putn_ushort_schar (void **xpp, size_t nelems, const schar  *ip);
+extern int
+ncx_putn_ushort_uchar (void **xpp, size_t nelems, const uchar  *ip);
+extern int
+ncx_putn_ushort_short (void **xpp, size_t nelems, const short  *ip);
+extern int
+ncx_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *ip);
+extern int
+ncx_putn_ushort_int   (void **xpp, size_t nelems, const int    *ip);
+extern int
+ncx_putn_ushort_uint  (void **xpp, size_t nelems, const uint   *ip);
+extern int
+ncx_putn_ushort_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_putn_ushort_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_putn_ushort_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_putn_ushort_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+ 
+extern int
+ncx_pad_putn_ushort_schar (void **xpp, size_t nelems, const schar  *ip);
+extern int
+ncx_pad_putn_ushort_uchar (void **xpp, size_t nelems, const uchar  *ip);
+extern int
+ncx_pad_putn_ushort_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_getn_int_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_pad_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_getn_int_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_pad_putn_ushort_int   (void **xpp, size_t nelems, const int    *ip);
+extern int
+ncx_pad_putn_ushort_uint  (void **xpp, size_t nelems, const uint   *ip);
+extern int
+ncx_pad_putn_ushort_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_pad_putn_ushort_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_pad_putn_ushort_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_pad_putn_ushort_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_pad_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+
+/*---- int ------------------------------------------------------------------*/
+extern int
+ncx_getn_int_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_int_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_int_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_int_ushort(const void **xpp, size_t nelems, ushort *ip);
+extern int
+ncx_getn_int_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_int_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_int_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_long_long (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_int_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_int_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_int_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_putn_int_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_putn_int_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_putn_int_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_putn_int_short(void **xpp, size_t nelems, const short *ip);
+ncx_putn_int_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_putn_int_int(void **xpp, size_t nelems, const int *ip);
+ncx_putn_int_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_putn_int_long(void **xpp, size_t nelems, const long *ip);
+ncx_putn_int_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_putn_int_float(void **xpp, size_t nelems, const float *ip);
+ncx_putn_int_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_putn_int_double(void **xpp, size_t nelems, const double *ip);
+ncx_putn_int_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_putn_long_long (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_putn_int_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_putn_int_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_putn_int_double(void **xpp, size_t nelems, const double *ip);
 extern int
-ncx_putn_int_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_putn_int_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
  
+/*---- uint -----------------------------------------------------------------*/
+extern int
+ncx_getn_uint_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_uint_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_uint_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_uint_ushort(const void **xpp, size_t nelems, ushort *ip);
+extern int
+ncx_getn_uint_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_uint_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_uint_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_long_long (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_uint_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_uint_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_uint_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_getn_uint_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_getn_float_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_putn_uint_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_putn_uint_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_getn_float_short(const void **xpp, size_t nelems, short *ip);
+ncx_putn_uint_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_getn_float_int(const void **xpp, size_t nelems, int *ip);
+ncx_putn_uint_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_getn_float_long(const void **xpp, size_t nelems, long *ip);
+ncx_putn_uint_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_getn_float_float(const void **xpp, size_t nelems, float *ip);
+ncx_putn_uint_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_getn_float_double(const void **xpp, size_t nelems, double *ip);
+ncx_putn_uint_long  (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_getn_float_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_putn_long_long (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_getn_float_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_putn_uint_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_putn_uint_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_putn_uint_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+ 
+/*---- float ----------------------------------------------------------------*/
+extern int
+ncx_getn_float_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_float_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_float_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_float_ushort(const void **xpp, size_t nelems, ushort *ip);
+extern int
+ncx_getn_float_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_float_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_float_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_float_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_float_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_float_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_putn_float_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_putn_float_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_putn_float_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_putn_float_short(void **xpp, size_t nelems, const short *ip);
+ncx_putn_float_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_putn_float_int(void **xpp, size_t nelems, const int *ip);
+ncx_putn_float_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_putn_float_long(void **xpp, size_t nelems, const long *ip);
+ncx_putn_float_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_putn_float_float(void **xpp, size_t nelems, const float *ip);
+ncx_putn_float_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_putn_float_double(void **xpp, size_t nelems, const double *ip);
+ncx_putn_float_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_putn_float_float (void **xpp, size_t nelems, const float  *ip);
 extern int
-ncx_putn_float_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_putn_float_double(void **xpp, size_t nelems, const double *ip);
 extern int
-ncx_putn_float_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_putn_float_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
  
-
+/*---- double ---------------------------------------------------------------*/
 extern int
-ncx_getn_double_schar(const void **xpp, size_t nelems, schar *ip);
+ncx_getn_double_schar (const void **xpp, size_t nelems, schar  *ip);
 extern int
-ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *ip);
+ncx_getn_double_uchar (const void **xpp, size_t nelems, uchar  *ip);
 extern int
-ncx_getn_double_short(const void **xpp, size_t nelems, short *ip);
+ncx_getn_double_short (const void **xpp, size_t nelems, short  *ip);
 extern int
-ncx_getn_double_int(const void **xpp, size_t nelems, int *ip);
+ncx_getn_double_ushort(const void **xpp, size_t nelems, ushort  *ip);
 extern int
-ncx_getn_double_long(const void **xpp, size_t nelems, long *ip);
+ncx_getn_double_int   (const void **xpp, size_t nelems, int    *ip);
 extern int
-ncx_getn_double_float(const void **xpp, size_t nelems, float *ip);
+ncx_getn_double_uint  (const void **xpp, size_t nelems, uint   *ip);
 extern int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *ip);
+ncx_getn_double_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_double_float (const void **xpp, size_t nelems, float  *ip);
 extern int
-ncx_getn_double_uint(const void **xpp, size_t nelems, unsigned int *ip);
+ncx_getn_double_double(const void **xpp, size_t nelems, double *ip);
 extern int
-ncx_getn_double_longlong(const void **xpp, size_t nelems, longlong *ip);
+ncx_getn_double_longlong (const void **xpp, size_t nelems, longlong  *ip);
 extern int
 ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
 
 extern int
-ncx_putn_double_schar(void **xpp, size_t nelems, const schar *ip);
+ncx_putn_double_schar (void **xpp, size_t nelems, const schar  *ip);
 extern int
-ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *ip);
+ncx_putn_double_uchar (void **xpp, size_t nelems, const uchar  *ip);
 extern int
-ncx_putn_double_short(void **xpp, size_t nelems, const short *ip);
+ncx_putn_double_short (void **xpp, size_t nelems, const short  *ip);
 extern int
-ncx_putn_double_int(void **xpp, size_t nelems, const int *ip);
+ncx_putn_double_ushort(void **xpp, size_t nelems, const ushort *ip);
 extern int
-ncx_putn_double_long(void **xpp, size_t nelems, const long *ip);
+ncx_putn_double_int   (void **xpp, size_t nelems, const int    *ip);
 extern int
-ncx_putn_double_float(void **xpp, size_t nelems, const float *ip);
+ncx_putn_double_uint  (void **xpp, size_t nelems, const uint   *ip);
 extern int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *ip);
+ncx_putn_double_long  (void **xpp, size_t nelems, const long   *ip);
 extern int
-ncx_putn_double_uint(void **xpp, size_t nelems, const unsigned int *ip);
+ncx_putn_double_float (void **xpp, size_t nelems, const float  *ip);
 extern int
-ncx_putn_double_longlong(void **xpp, size_t nelems, const longlong *ip);
+ncx_putn_double_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_putn_double_longlong (void **xpp, size_t nelems, const longlong  *ip);
 extern int
 ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+
+/*---- longlong ----------------------------------------------------------------*/
+extern int
+ncx_getn_longlong_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_longlong_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_longlong_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_longlong_ushort(const void **xpp, size_t nelems, ushort  *ip);
+extern int
+ncx_getn_longlong_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_longlong_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_longlong_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_longlong_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_longlong_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_longlong_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_getn_longlong_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
+
+extern int
+ncx_putn_longlong_schar (void **xpp, size_t nelems, const schar  *ip);
+extern int
+ncx_putn_longlong_uchar (void **xpp, size_t nelems, const uchar  *ip);
+extern int
+ncx_putn_longlong_short (void **xpp, size_t nelems, const short  *ip);
+extern int
+ncx_putn_longlong_ushort(void **xpp, size_t nelems, const ushort *ip);
+extern int
+ncx_putn_longlong_int   (void **xpp, size_t nelems, const int    *ip);
+extern int
+ncx_putn_longlong_uint  (void **xpp, size_t nelems, const uint   *ip);
+extern int
+ncx_putn_longlong_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_putn_longlong_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_putn_longlong_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_putn_longlong_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_putn_longlong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
+
+/*---- ulonglong ---------------------------------------------------------------*/
+extern int
+ncx_getn_ulonglong_schar (const void **xpp, size_t nelems, schar  *ip);
+extern int
+ncx_getn_ulonglong_uchar (const void **xpp, size_t nelems, uchar  *ip);
+extern int
+ncx_getn_ulonglong_short (const void **xpp, size_t nelems, short  *ip);
+extern int
+ncx_getn_ulonglong_ushort(const void **xpp, size_t nelems, ushort  *ip);
+extern int
+ncx_getn_ulonglong_int   (const void **xpp, size_t nelems, int    *ip);
+extern int
+ncx_getn_ulonglong_uint  (const void **xpp, size_t nelems, uint   *ip);
+extern int
+ncx_getn_ulonglong_long  (const void **xpp, size_t nelems, long   *ip);
+extern int
+ncx_getn_ulonglong_float (const void **xpp, size_t nelems, float  *ip);
+extern int
+ncx_getn_ulonglong_double(const void **xpp, size_t nelems, double *ip);
+extern int
+ncx_getn_ulonglong_longlong (const void **xpp, size_t nelems, longlong  *ip);
+extern int
+ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
+
+extern int
+ncx_putn_ulonglong_schar (void **xpp, size_t nelems, const schar  *ip);
+extern int
+ncx_putn_ulonglong_uchar (void **xpp, size_t nelems, const uchar  *ip);
+extern int
+ncx_putn_ulonglong_short (void **xpp, size_t nelems, const short  *ip);
+extern int
+ncx_putn_ulonglong_ushort(void **xpp, size_t nelems, const ushort *ip);
+extern int
+ncx_putn_ulonglong_int   (void **xpp, size_t nelems, const int    *ip);
+extern int
+ncx_putn_ulonglong_uint  (void **xpp, size_t nelems, const uint   *ip);
+extern int
+ncx_putn_ulonglong_long  (void **xpp, size_t nelems, const long   *ip);
+extern int
+ncx_putn_ulonglong_float (void **xpp, size_t nelems, const float  *ip);
+extern int
+ncx_putn_ulonglong_double(void **xpp, size_t nelems, const double *ip);
+extern int
+ncx_putn_ulonglong_longlong (void **xpp, size_t nelems, const longlong  *ip);
+extern int
+ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
  
 
 /*
diff --git a/libsrc/ncx.m4 b/libsrc/ncx.m4
index 71668e4..986ebc6 100644
--- a/libsrc/ncx.m4
+++ b/libsrc/ncx.m4
@@ -1,7 +1,7 @@
 dnl
 dnl sjl: this version of ncx.m4 has SX-specific optimisations as per
 dnl      Harveys mods to earlier versions. However, I have removed
-dnl      support for FLOAT2 and attemped to tidy up the mods to
+dnl      support for FLOAT2 and attempted to tidy up the mods to
 dnl      reduce the complexity a bit
 dnl
 dnl This is m4 source.
@@ -32,12 +32,14 @@ dnl
  *	they handle IEEE subnormals properly, and their "n" versions
  *	operate speedily on arrays.
  */
-/* $Id: ncx.m4,v 2.58 2010/05/26 18:11:08 dmh Exp $ */
+/* $Id: ncx.m4 2795 2014-10-27 23:12:51Z wkliao $ */
 
 /*
  * An external data representation interface.
  */
 
+#pragma GCC diagnostic ignored "-Wdeprecated"
+
 #include "ncx.h"
 #include "nc3dispatch.h"
 #include <string.h>
@@ -55,12 +57,21 @@ dnl
 #ifndef LONG_LONG_MAX
 #define LONG_LONG_MAX LLONG_MAX
 #endif
+#ifndef LONGLONG_MAX
+#define LONGLONG_MAX LONG_LONG_MAX
+#endif
 #ifndef LONG_LONG_MIN
 #define LONG_LONG_MIN LLONG_MIN
 #endif
+#ifndef LONGLONG_MIN
+#define LONGLONG_MIN LONG_LONG_MIN
+#endif
 #ifndef ULONG_LONG_MAX
 #define ULONG_LONG_MAX ULLONG_MAX
 #endif
+#ifndef ULONGLONG_MAX
+#define ULONGLONG_MAX ULONG_LONG_MAX
+#endif
 #include <float.h>
 #ifndef FLT_MAX /* This POSIX macro missing on some systems */
 # ifndef NO_IEEE_FLOAT
@@ -81,6 +92,16 @@ dnl
 #define Min(a,b) ((a) < (b) ? (a) : (b))
 #define Max(a,b) ((a) > (b) ? (a) : (b))
 
+#ifndef SIZEOF_USHORT
+#define SIZEOF_USHORT SIZEOF_UNSIGNED_SHORT_INT
+#endif
+#ifndef SIZEOF_UINT
+#define SIZEOF_UINT SIZEOF_UNSIGNED_INT
+#endif
+#ifndef SIZEOF_ULONG_LONG
+#define SIZEOF_ULONG_LONG SIZEOF_UNSIGNED_LONG_LONG
+#endif
+
 /*
  * If the machine's float domain is "smaller" than the external one
  * use the machine domain
@@ -158,7 +179,7 @@ swapn2b(void *dst, const void *src, size_t nn)
 		*op++ = *(ip++ -1);
 		nn -= 4;
 	}
-	while(nn-- != 0)
+	while(nn-- > 0)
 	{
 		*op++ = *(++ip);
 		*op++ = *(ip++ -1);
@@ -224,7 +245,7 @@ swapn4b(void *dst, const void *src, size_t nn)
 		ip += 16;
 		nn -= 4;
 	}
-	while(nn-- != 0)
+	while(nn-- > 0)
 	{
 		op[0] = ip[3];
 		op[1] = ip[2];
@@ -341,17 +362,173 @@ swapn8b(void *dst, const void *src, size_t nn)
 
 #endif /* LITTLE_ENDIAN */
 
+dnl dnl dnl
+dnl
+dnl Upcase(str)
+dnl
+define(`Upcase',dnl
+`dnl
+translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)')dnl
+dnl
+dnl dnl dnl
+dnl
+define(`Isizeof',     ``SIZEOF_'Upcase($1)')dnl
+define(`Xsizeof',   ``X_SIZEOF_'Upcase($1)')dnl
+define(`IXsizeof', ``SIZEOF_IX_'Upcase($1)')dnl
+define(`Imax',                 `Upcase($1)`_MAX'')dnl
+define(`Imin',                 `Upcase($1)`_MIN'')dnl
+define(`Xmax',             ``X_'Upcase($1)`_MAX'')dnl
+define(`Xmin',             ``X_'Upcase($1)`_MIN'')dnl
+define(`IXmax',           ``IX_'Upcase($1)`_MAX'')dnl
+dnl
+define(`Fmin',  `ifelse(index(`$1',`u'), 0, `0', `(double)Imin($1)')')dnl
+define(`Dmin',  `ifelse(index(`$1',`u'), 0, `0',         `Imin($1)')')dnl
+define(`FXmin', `ifelse(index(`$1',`u'), 0, `0', `(double)Xmin($1)')')dnl
+define(`DXmin', `ifelse(index(`$1',`u'), 0, `0',         `Xmin($1)')')dnl
+
+dnl
+dnl For GET APIs:
+dnl       check for negative xx if xp is   signed && ip is unsigned
+dnl Don't check for negative xx if xp is   signed && ip is   signed
+dnl Don't check for negative xx if xp is unsigned
+dnl
+define(`GETI_CheckNeg', `ifelse(index(`$1',`u'), 0, , `ifelse(index(`$2',`u'), 0, `	if (xx < 0) return NC_ERANGE; /* because ip is unsigned */')')')dnl
+
+dnl
+dnl For PUT APIs:
+dnl       check for negative ip if xp is unsigned && ip is   signed
+dnl Don't check for negative ip if xp is unsigned && ip is unsigned
+dnl Don't check for negative ip if xp is   signed
+dnl
+define(`PUTI_CheckNeg', `ifelse(index(`$1',`u'), 0, `ifelse(index(`$2',`u'), 0, , `	if (*ip < 0) return NC_ERANGE; /* because xp is unsigned */')')')dnl
+
+dnl
+dnl For GET APIs and either $1 and $2 is float or double:
+dnl
+define(`GETF_CheckBND',
+`ifelse(`$1', `double', `	if(xx > Upcase($2)_MAX || xx < Dmin($2)) return NC_ERANGE;',
+		       `ifelse(`$1', `float', `ifelse(`$2', `double',,`	if(xx > (double)Upcase($2)_MAX || xx < Fmin($2)) return NC_ERANGE;')')'dnl
+)')
+
+dnl
+dnl For PUT APIs and either $1 and $2 is float or double:
+dnl
+define(`PUTF_CheckBND',
+`ifelse(`$2', `double', `	if(*ip > Xmax($1) || *ip < DXmin($1)) return NC_ERANGE;',
+		       `ifelse(`$2', `float', `	if(*ip > (double)Xmax($1) || *ip < FXmin($1)) return NC_ERANGE;')'dnl
+)')
+
+dnl
+dnl For GET APIs and $1 and $2 are not float or double
+dnl
+define(`GETI_CheckBND',
+``#'if IXmax($1) > Imax($2)
+	if (xx > Imax($2)'`ifelse(index(`$1',`u'), 0, , `ifelse(index(`$2',`u'), 0, , ` || xx < Imin($2)')')'`) return NC_ERANGE;'
+`#'endif)
+
+dnl
+dnl For PUT APIs and $1 and $2 are not float or double
+dnl
+define(`PUTI_CheckBND',
+``#'if IXmax($1) < Imax($2)
+	if (*ip > IXmax($1)'`ifelse(index(`$1',`u'), 0, , `ifelse(index(`$2',`u'), 0, , ` || *ip < Xmin($1)')')'`) return NC_ERANGE;'
+`#'endif)
 
 /*
  * Primitive numeric conversion functions.
  */
 
+dnl dnl dnl
+dnl
+dnl NCX_GET1F(xtype, itype) for floating-point types
+dnl
+define(`NCX_GET1F',dnl
+`dnl
+int
+ncx_get_$1_$2(const void *xp, $2 *ip)
+{
+	ix_$1 xx;
+	get_ix_$1(xp, &xx);
+	*ip = ($2) xx;
+GETF_CheckBND($1, $2)
+	return ENOERR;
+}
+')dnl
+
+dnl dnl dnl
+dnl
+dnl NCX_GET1I(xtype, itype, isComptable) for integral types
+dnl
+define(`NCX_GET1I',dnl
+`dnl
+int
+ncx_get_$1_$2(const void *xp, $2 *ip)
+{
+ifelse(`$3', `1',
+``#'if IXsizeof($1) == Isizeof($2) && IXmax($1) == Upcase($2)_MAX
+	get_ix_$1(xp, (ix_$1 *)ip);
+	return ENOERR;
+`#'else
+')dnl
+	ix_$1 xx;
+	get_ix_$1(xp, &xx);
+	*ip = ($2) xx;
+GETI_CheckBND($1, $2)
+GETI_CheckNeg($1, $2)
+ifelse(`$3', `1', ``#'endif
+')dnl
+	return ENOERR;
+}
+')dnl
+
+dnl dnl dnl
+dnl
+dnl NCX_PUT1F(xtype, itype) for floating-point types
+dnl
+define(`NCX_PUT1F',dnl
+`dnl
+int
+ncx_put_$1_$2(void *xp, const $2 *ip)
+{
+	ix_$1 xx = (ix_$1)*ip;
+	put_ix_$1(xp, &xx);
+PUTF_CheckBND($1, $2)
+	return ENOERR;
+}
+')dnl
+
+dnl dnl dnl
+dnl
+dnl NCX_PUT1I(xtype, itype, isComptable) for integral types
+dnl
+define(`NCX_PUT1I',dnl
+`dnl
+int
+ncx_put_$1_$2(void *xp, const $2 *ip)
+{
+ifelse(`$3', `1',
+``#'if IXsizeof($1) == Isizeof($2) && IXmax($1) == Upcase($2)_MAX
+	put_ix_$1(xp, (const ix_$1 *)ip);
+	return ENOERR;
+`#'else
+')dnl
+	ix_$1 xx = (ix_$1)*ip;
+	put_ix_$1(xp, &xx);
+PUTI_CheckBND($1, $2)
+PUTI_CheckNeg($1, $2)
+ifelse(`$3', `1', ``#'endif
+')dnl
+	return ENOERR;
+}
+')dnl
+
 /* x_schar */
+/* x_uchar */
 
-/* We don't implement any x_schar primitives. */
+/* We don't implement any x_schar and x_uchar primitives. */
 
 
-/* x_short */
+/* x_short -------------------------------------------------------------------*/
 
 #if SHORT_MAX == X_SHORT_MAX
 typedef short ix_short;
@@ -396,139 +573,18 @@ put_ix_short(void *xp, const ix_short *ip)
 	*cp = (*ip) & 0xff;
 }
 
+static NCX_GET1I(short, schar,     0)
+static NCX_GET1I(short, short,     1)
+static NCX_GET1I(short, int,       1)
+static NCX_GET1I(short, longlong,  1)
+static NCX_GET1I(short, ushort,    0)
+static NCX_GET1I(short, uchar,     0)
+static NCX_GET1I(short, uint,      0)
+static NCX_GET1I(short, ulonglong, 0)
+static NCX_GET1F(short, float)
+static NCX_GET1F(short, double)
 
-int
-ncx_get_short_schar(const void *xp, schar *ip)
-{
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_short_uchar(const void *xp, uchar *ip)
-{
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_short_short(const void *xp, short *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_SHORT && IX_SHORT_MAX == SHORT_MAX
-	get_ix_short(xp, (ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-#   if IX_SHORT_MAX > SHORT_MAX
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_short_int(const void *xp, int *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
-	get_ix_short(xp, (ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-#   if IX_SHORT_MAX > INT_MAX
-	if(xx > INT_MAX || xx < INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_short_uint(const void *xp, unsigned int *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_INT && IX_SHORT_MAX == INT_MAX
-	get_ix_short(xp, (ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-#   if IX_SHORT_MAX > INT_MAX
-	if(xx > UINT_MAX || xx < 0)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_short_longlong(const void *xp, long long *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_LONG_LONG && IX_SHORT_MAX == LONG_LONG_MAX
-	get_ix_short(xp, (ix_short *)ip);
-	return ENOERR;
-#else
-	/* assert(LONG_LONG_MAX >= X_SHORT_MAX); */
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_short_ulonglong(const void *xp, unsigned long long *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_LONG && IX_SHORT_MAX == LONG_MAX
-	get_ix_short(xp, (ix_short *)ip);
-	return ENOERR;
-#else
-	/* assert(LONG_LONG_MAX >= X_SHORT_MAX); */
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-	if(xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_short_float(const void *xp, float *ip)
-{
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-#if 0	/* TODO: determine when necessary */
-	if(xx > FLT_MAX || xx < (-FLT_MAX))
-		return NC_ERANGE;
-#endif
-	return ENOERR;
-}
-
-int
-ncx_get_short_double(const void *xp, double *ip)
-{
-	/* assert(DBL_MAX >= X_SHORT_MAX); */
-	ix_short xx;
-	get_ix_short(xp, &xx);
-	*ip = xx;
-	return ENOERR;
-}
-
-int
+static int
 ncx_put_short_schar(void *xp, const schar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -540,7 +596,7 @@ ncx_put_short_schar(void *xp, const schar *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_short_uchar(void *xp, const uchar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -549,112 +605,104 @@ ncx_put_short_uchar(void *xp, const uchar *ip)
 	return ENOERR;
 }
 
-int
-ncx_put_short_short(void *xp, const short *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_SHORT && X_SHORT_MAX == SHORT_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
+static NCX_PUT1I(short, short,     1)
+static NCX_PUT1I(short, int,       1)
+static NCX_PUT1I(short, longlong,  1)
+static NCX_PUT1I(short, ushort,    0)
+static NCX_PUT1I(short, uint,      0)
+static NCX_PUT1I(short, ulonglong, 0)
+static NCX_PUT1F(short, float)
+static NCX_PUT1F(short, double)
+
+/* x_ushort ------------------------------------------------------------------*/
+
+#if USHORT_MAX == X_USHORT_MAX
+typedef unsigned short ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_USHORT
+#define IX_USHORT_MAX USHORT_MAX
+#elif UINT_MAX >= X_USHORT_MAX
+typedef unsigned int ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_UINT
+#define IX_USHORT_MAX UINT_MAX
+#elif ULONG_MAX >= X_USHORT_MAX
+typedef unsigned long ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_ULONG
+#define IX_USHORT_MAX ULONG_MAX
+#elif ULLONG_MAX >= X_USHORT_MAX
+typedef unsigned long long ix_ushort;
+#define SIZEOF_IX_USHORT SIZEOF_ULONG_LONG
+#define IX_USHORT_MAX ULLONG_MAX
 #else
-	ix_short xx = (ix_short)*ip;
-	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < SHORT_MAX
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
+#error "ix_ushort implementation"
 #endif
-}
 
-int
-ncx_put_short_int(void *xp, const int *ip)
+static void
+get_ix_ushort(const void *xp, ix_ushort *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_INT && X_SHORT_MAX == INT_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx = (ix_short)*ip;
-	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < INT_MAX
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
+	const uchar *cp = (const uchar *) xp;
+	*ip = *cp++ << 8;
+#if SIZEOF_IX_SHORT > X_SIZEOF_SHORT
+	if(*ip & 0x8000)
+	{
+		/* extern is negative */
+		*ip |= (~(0xffff)); /* N.B. Assumes "twos complement" */
+	}
 #endif
+	*ip |= *cp; 
 }
 
-int
-ncx_put_short_uint(void *xp, const unsigned int *ip)
+static void
+put_ix_ushort(void *xp, const ix_ushort *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_INT && X_SHORT_MAX == INT_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx = (ix_short)*ip;
-	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < INT_MAX
-	if(*ip > X_SHORT_MAX)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
-#endif
+	uchar *cp = (uchar *) xp;
+	*cp++ = (*ip) >> 8;
+	*cp = (*ip) & 0xff;
 }
 
-int
-ncx_put_short_longlong(void *xp, const long long *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_LONG_LONG && X_SHORT_MAX == LONG_LONG_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx = (ix_short)*ip;
-	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < LONG_LONG_MAX
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
-#endif
-}
+static NCX_GET1I(ushort, schar,     0)
+static NCX_GET1I(ushort, short,     0)
+static NCX_GET1I(ushort, int,       0)
+static NCX_GET1I(ushort, longlong,  0)
+static NCX_GET1I(ushort, ushort,    1)
+static NCX_GET1I(ushort, uchar,     1)
+static NCX_GET1I(ushort, uint,      1)
+static NCX_GET1I(ushort, ulonglong, 1)
+static NCX_GET1F(ushort, float)
+static NCX_GET1F(ushort, double)
 
-int
-ncx_put_short_ulonglong(void *xp, const unsigned long long *ip)
+static int
+ncx_put_ushort_schar(void *xp, const schar *ip)
 {
-#if SIZEOF_IX_SHORT == SIZEOF_LONG_LONG && X_SHORT_MAX == LONG_LONG_MAX
-	put_ix_short(xp, (const ix_short *)ip);
-	return ENOERR;
-#else
-	ix_short xx = (ix_short)*ip;
-	put_ix_short(xp, &xx);
-# if X_SHORT_MAX < LONG_LONG_MAX
-	if(*ip > X_SHORT_MAX)
-		return NC_ERANGE;
-# endif
-	return ENOERR;
-#endif
-}
+	uchar *cp = (uchar *) xp;
+	if(*ip & 0x80)
+		*cp++ = 0xff;
+	else
+		*cp++ = 0;
+	*cp = (uchar)*ip;
+        if (*ip < 0) return NC_ERANGE;
 
-int
-ncx_put_short_float(void *xp, const float *ip)
-{
-	ix_short xx = *ip;
-	put_ix_short(xp, &xx);
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
 	return ENOERR;
 }
 
-int
-ncx_put_short_double(void *xp, const double *ip)
+static int
+ncx_put_ushort_uchar(void *xp, const uchar *ip)
 {
-	ix_short xx = *ip;
-	put_ix_short(xp, &xx);
-	if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
-		return NC_ERANGE;
+	uchar *cp = (uchar *) xp;
+	*cp++ = 0;
+	*cp = *ip;
 	return ENOERR;
 }
 
-/* x_int */
+static NCX_PUT1I(ushort, short,     0)
+static NCX_PUT1I(ushort, int,       0)
+static NCX_PUT1I(ushort, longlong,  0)
+static NCX_PUT1I(ushort, ushort,    1)
+static NCX_PUT1I(ushort, uint,      1)
+static NCX_PUT1I(ushort, ulonglong, 1)
+static NCX_PUT1F(ushort, float)
+static NCX_PUT1F(ushort, double)
+
+/* x_int ---------------------------------------------------------------------*/
 
 #if SHORT_MAX == X_INT_MAX
 typedef short ix_int;
@@ -702,120 +750,18 @@ put_ix_int(void *xp, const ix_int *ip)
 	*cp   = ((*ip) & 0x000000ff);
 }
 
+static NCX_GET1I(int, schar,     0)
+static NCX_GET1I(int, short,     1)
+       NCX_GET1I(int, int,       1)
+static NCX_GET1I(int, longlong,  1)
+static NCX_GET1I(int, ushort,    0)
+static NCX_GET1I(int, uchar,     0)
+static NCX_GET1I(int, uint,      0)
+static NCX_GET1I(int, ulonglong, 0)
+static NCX_GET1F(int, float)
+static NCX_GET1F(int, double)
 
-int
-ncx_get_int_schar(const void *xp, schar *ip)
-{
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_int_uchar(const void *xp, uchar *ip)
-{
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_int_short(const void *xp, short *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
-	get_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-#  if IX_INT_MAX > SHORT_MAX
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
-#  endif
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_int_int(const void *xp, int *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-	get_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-#  if IX_INT_MAX > INT_MAX
-	if(xx > INT_MAX || xx < INT_MIN)
-		return NC_ERANGE;
-#  endif
-	return ENOERR;
-#endif
-}
-
-int
-ncx_get_int_uint(const void *xp, unsigned int *ip)
-{
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_int_longlong(const void *xp, long long *ip)
-{
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	return ENOERR;
-}
-
-int
-ncx_get_int_ulonglong(const void *xp, unsigned long long *ip)
-{
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	if(xx < 0)
-	      return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_int_float(const void *xp, float *ip)
-{
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-#if 0	/* TODO: determine when necessary */
-	if(xx > FLT_MAX || xx < (-FLT_MAX))
-		return NC_ERANGE;
-#endif
-	return ENOERR;
-}
-
-int
-ncx_get_int_double(const void *xp, double *ip)
-{
-	/* assert((DBL_MAX >= X_INT_MAX); */
-	ix_int xx;
-	get_ix_int(xp, &xx);
-	*ip = xx;
-	return ENOERR;
-}
-
-int
+static int
 ncx_put_int_schar(void *xp, const schar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -835,7 +781,7 @@ ncx_put_int_schar(void *xp, const schar *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_put_int_uchar(void *xp, const uchar *ip)
 {
 	uchar *cp = (uchar *) xp;
@@ -846,111 +792,109 @@ ncx_put_int_uchar(void *xp, const uchar *ip)
 	return ENOERR;
 }
 
-int
-ncx_put_int_short(void *xp, const short *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_SHORT && IX_INT_MAX == SHORT_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < SHORT_MAX
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
-#endif
-}
+static NCX_PUT1I(int, short,     1)
+       NCX_PUT1I(int, int,       1)
+static NCX_PUT1I(int, longlong,  1)
+static NCX_PUT1I(int, ushort,    0)
+static NCX_PUT1I(int, uint,      0)
+static NCX_PUT1I(int, ulonglong, 0)
+static NCX_PUT1F(int, float)
+static NCX_PUT1F(int, double)
 
-int
-ncx_put_int_int(void *xp, const int *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
+
+/* x_uint --------------------------------------------------------------------*/
+
+#if USHORT_MAX == X_UINT_MAX
+typedef ushort ix_uint;
+#define SIZEOF_IX_UINT SIZEOF_USHORT
+#define IX_UINT_MAX USHORT_MAX
+#elif UINT_MAX  >= X_UINT_MAX
+typedef uint ix_uint;
+#define SIZEOF_IX_UINT SIZEOF_UINT
+#define IX_UINT_MAX UINT_MAX
+#elif ULONG_MAX  >= X_UINT_MAX
+typedef ulong ix_uint;
+#define SIZEOF_IX_UINT SIZEOF_ULONG
+#define IX_UINT_MAX ULONG_MAX
 #else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < INT_MAX
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+#error "ix_uint implementation"
 #endif
-}
 
-int
-ncx_put_int_uint(void *xp, const unsigned int *ip)
+
+static void
+get_ix_uint(const void *xp, ix_uint *ip)
 {
-#if SIZEOF_IX_INT == SIZEOF_INT && IX_INT_MAX == INT_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-	if(*ip > X_UINT_MAX)
-		return NC_ERANGE;
-	return ENOERR;
-#endif
+	const uchar *cp = (const uchar *) xp;
+
+	*ip = *cp++ << 24;
+	*ip |= (*cp++ << 16);
+	*ip |= (*cp++ << 8);
+	*ip |= *cp; 
 }
 
-int
-ncx_put_int_longlong(void *xp, const longlong *ip)
+static void
+put_ix_uint(void *xp, const ix_uint *ip)
 {
-#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < LONG_LONG_MAX
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
-#endif
+	uchar *cp = (uchar *) xp;
+
+	*cp++ = (*ip) >> 24;
+	*cp++ = ((*ip) & 0x00ff0000) >> 16;
+	*cp++ = ((*ip) & 0x0000ff00) >>  8;
+	*cp   = ((*ip) & 0x000000ff);
 }
 
-int
-ncx_put_int_ulonglong(void *xp, const unsigned long long *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_MAX
-	put_ix_int(xp, (ix_int *)ip);
-	return ENOERR;
-#else
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-#   if IX_INT_MAX < LONG_MAX
-	if(*ip > X_INT_MAX)
-		return NC_ERANGE;
-#   endif
-	return ENOERR;
+#if X_SIZEOF_UINT != SIZEOF_UINT
+static NCX_GET1I(uint, uint,      1)
 #endif
-}
 
-int
-ncx_put_int_float(void *xp, const float *ip)
+static NCX_GET1I(uint, schar,     0)
+static NCX_GET1I(uint, short,     0)
+static NCX_GET1I(uint, int,       0)
+static NCX_GET1I(uint, longlong,  0)
+static NCX_GET1I(uint, ushort,    1)
+static NCX_GET1I(uint, uchar,     1)
+static NCX_GET1I(uint, ulonglong, 1)
+static NCX_GET1F(uint, float)
+static NCX_GET1F(uint, double)
+
+static int
+ncx_put_uint_schar(void *xp, const schar *ip)
 {
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-	if(*ip > (double)X_INT_MAX || *ip < (double)X_INT_MIN)
-		return NC_ERANGE;
+	uchar *cp = (uchar *) xp;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp = (uchar)*ip;
+
+	if (*ip < 0) return NC_ERANGE;
+
 	return ENOERR;
 }
 
-int
-ncx_put_int_double(void *xp, const double *ip)
+static int
+ncx_put_uint_uchar(void *xp, const uchar *ip)
 {
-	ix_int xx = (ix_int)(*ip);
-	put_ix_int(xp, &xx);
-	if(*ip > X_INT_MAX || *ip < X_INT_MIN)
-		return NC_ERANGE;
+	uchar *cp = (uchar *) xp;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp++ = 0x00;
+	*cp   = *ip;
 	return ENOERR;
 }
 
+#if X_SIZEOF_UINT != SIZEOF_UINT
+static NCX_PUT1I(uint, uint,      1)
+#endif
+
+static NCX_PUT1I(uint, short,     0)
+static NCX_PUT1I(uint, int,       0)
+static NCX_PUT1I(uint, longlong,  0)
+static NCX_PUT1I(uint, ushort,    1)
+static NCX_PUT1I(uint, ulonglong, 1)
+static NCX_PUT1F(uint, float)
+static NCX_PUT1F(uint, double)
 
-/* x_float */
+/* x_float -------------------------------------------------------------------*/
 
 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
 
@@ -1130,7 +1074,7 @@ PUT_VAX_DFLOAT_Body(xp)
 
 /*
  * Return the number of bytes until the next "word" boundary
- * N.B. This is based on the very wierd YMP address structure,
+ * N.B. This is based on the very weird YMP address structure,
  * which puts the address within a word in the leftmost 3 bits
  * of the address.
  */
@@ -1308,232 +1252,82 @@ get_ix_float(const void *xp, float *ip)
 		else
 		{
 			idp->exp = isp->exp + (ieee_double_bias - ieee_single_bias);
-			idp->mant = isp->mant << (52 - 23);
-		}
-		idp->sign = isp->sign;
-	}
-	else
-	{
-		const ieee_single_lo *isp = (const ieee_single_lo *) xp;
-		if(isp->exp == 0 && isp->mant == 0)
-		{
-			idp->exp = 0;
-			idp->mant = 0;
-		}
-		else
-		{
-			idp->exp = isp->exp + (ieee_double_bias - ieee_single_bias);
-			idp->mant = isp->mant << (52 - 23);
-		}
-		idp->sign = isp->sign;
-	}
-}
-
-static void
-put_ix_float(void *xp, const float *ip)
-{
-	const ieee_double *idp = (const ieee_double *) ip;
-	if(word_align(xp) == 0)
-	{
-		ieee_single_hi *isp = (ieee_single_hi*)xp;
-		if(idp->exp > (ieee_double_bias - ieee_single_bias))
-			isp->exp = idp->exp - (ieee_double_bias - ieee_single_bias);
-		else
-			isp->exp = 0;
-		isp->mant = idp->mant >> (52 - 23);
-		isp->sign = idp->sign;
-	}
-	else
-	{
-		ieee_single_lo *isp = (ieee_single_lo*)xp;
-		if(idp->exp > (ieee_double_bias - ieee_single_bias))
-			isp->exp = idp->exp - (ieee_double_bias - ieee_single_bias);
-		else
-			isp->exp = 0;
-		isp->mant = idp->mant >> (52 - 23);
-		isp->sign = idp->sign;
-	}
-}
-#endif
-
-#else
-#error "ix_float implementation"
-#endif
-
-
-int
-ncx_get_float_schar(const void *xp, schar *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (schar) xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_uchar(const void *xp, uchar *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (uchar) xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_short(const void *xp, short *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (short) xx;
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_int(const void *xp, int *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (int) xx;
-	if(xx > (double)INT_MAX || xx < (double)INT_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_uint(const void *xp, unsigned int *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (unsigned int) xx;
-	if(xx > (double)UINT_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_longlong(const void *xp, longlong *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (longlong) xx;
-	if(xx > (double)LONG_LONG_MAX || xx < (double)LONG_LONG_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_ulonglong(const void *xp, unsigned long long *ip)
-{
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = (longlong) xx;
-	if(xx > (double)ULONG_LONG_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_float_float(const void *xp, float *ip)
-{
-	/* TODO */
-	get_ix_float(xp, ip);
-	return ENOERR;
-}
-
-int
-ncx_get_float_double(const void *xp, double *ip)
-{
-	/* TODO */
-	float xx;
-	get_ix_float(xp, &xx);
-	*ip = xx;
-	return ENOERR;
-}
-
-
-int
-ncx_put_float_schar(void *xp, const schar *ip)
-{
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-	return ENOERR;
+			idp->mant = isp->mant << (52 - 23);
+		}
+		idp->sign = isp->sign;
+	}
+	else
+	{
+		const ieee_single_lo *isp = (const ieee_single_lo *) xp;
+		if(isp->exp == 0 && isp->mant == 0)
+		{
+			idp->exp = 0;
+			idp->mant = 0;
+		}
+		else
+		{
+			idp->exp = isp->exp + (ieee_double_bias - ieee_single_bias);
+			idp->mant = isp->mant << (52 - 23);
+		}
+		idp->sign = isp->sign;
+	}
 }
 
-int
-ncx_put_float_uchar(void *xp, const uchar *ip)
+static void
+put_ix_float(void *xp, const float *ip)
 {
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-	return ENOERR;
+	const ieee_double *idp = (const ieee_double *) ip;
+	if(word_align(xp) == 0)
+	{
+		ieee_single_hi *isp = (ieee_single_hi*)xp;
+		if(idp->exp > (ieee_double_bias - ieee_single_bias))
+			isp->exp = idp->exp - (ieee_double_bias - ieee_single_bias);
+		else
+			isp->exp = 0;
+		isp->mant = idp->mant >> (52 - 23);
+		isp->sign = idp->sign;
+	}
+	else
+	{
+		ieee_single_lo *isp = (ieee_single_lo*)xp;
+		if(idp->exp > (ieee_double_bias - ieee_single_bias))
+			isp->exp = idp->exp - (ieee_double_bias - ieee_single_bias);
+		else
+			isp->exp = 0;
+		isp->mant = idp->mant >> (52 - 23);
+		isp->sign = idp->sign;
+	}
 }
-
-int
-ncx_put_float_short(void *xp, const short *ip)
-{
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX || (float)(*ip) < X_FLOAT_MIN)
-		return NC_ERANGE;
 #endif
-	return ENOERR;
-}
 
-int
-ncx_put_float_int(void *xp, const int *ip)
-{
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX || (float)(*ip) < X_FLOAT_MIN)
-		return NC_ERANGE;
+#else
+#error "ix_float implementation"
 #endif
-	return ENOERR;
-}
 
-int
-ncx_put_float_uint(void *xp, const unsigned int *ip)
+#if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
+static int
+ncx_get_float_float(const void *xp, float *ip)
 {
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX)
-		return NC_ERANGE;
-#endif
+	/* TODO */
+	get_ix_float(xp, ip);
 	return ENOERR;
 }
-
-int
-ncx_put_float_longlong(void *xp, const longlong *ip)
-{
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX || (float)(*ip) < X_FLOAT_MIN)
-		return NC_ERANGE;
 #endif
-	return ENOERR;
-}
 
-int
-ncx_put_float_ulonglong(void *xp, const unsigned long long *ip)
-{
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((float)(*ip) > X_FLOAT_MAX)
-		return NC_ERANGE;
-#endif
-	return ENOERR;
-}
+#define ix_float float
 
-int
+static NCX_GET1F(float, schar)
+static NCX_GET1F(float, short)
+static NCX_GET1F(float, int)
+static NCX_GET1F(float, double)
+static NCX_GET1F(float, longlong)
+static NCX_GET1F(float, uchar)
+static NCX_GET1F(float, ushort)
+static NCX_GET1F(float, uint)
+static NCX_GET1F(float, ulonglong)
+
+#if X_SIZEOF_FLOAT != SIZEOF_FLOAT || defined(NO_IEEE_FLOAT)
+static int
 ncx_put_float_float(void *xp, const float *ip)
 {
 	put_ix_float(xp, ip);
@@ -1543,18 +1337,20 @@ ncx_put_float_float(void *xp, const float *ip)
 #endif
 	return ENOERR;
 }
+#endif
 
-int
-ncx_put_float_double(void *xp, const double *ip)
-{
-	float xx = (float) *ip;
-	put_ix_float(xp, &xx);
-	if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
+static NCX_PUT1F(float, schar)
+static NCX_PUT1F(float, short)
+static NCX_PUT1F(float, int)
+static NCX_PUT1F(float, double)
+static NCX_PUT1F(float, longlong)
+static NCX_PUT1F(float, uchar)
+static NCX_PUT1F(float, ushort)
+static NCX_PUT1F(float, uint)
+static NCX_PUT1F(float, ulonglong)
 
-/* x_double */
+
+/* x_double ------------------------------------------------------------------*/
 
 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE  && !defined(NO_IEEE_FLOAT)
 
@@ -1831,71 +1627,15 @@ put_ix_double(void *xp, const double *ip)
 #error "ix_double implementation"
 #endif
 
-int
-ncx_get_double_schar(const void *xp, schar *ip)
-{
-	double xx;
-	get_ix_double(xp, &xx);
-	*ip = (schar) xx;
-	if(xx > SCHAR_MAX || xx < SCHAR_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_double_uchar(const void *xp, uchar *ip)
-{
-	double xx;
-	get_ix_double(xp, &xx);
-	*ip = (uchar) xx;
-	if(xx > UCHAR_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_double_short(const void *xp, short *ip)
-{
-	double xx;
-	get_ix_double(xp, &xx);
-	*ip = (short) xx;
-	if(xx > SHORT_MAX || xx < SHORT_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_double_int(const void *xp, int *ip)
-{
-	double xx;
-	get_ix_double(xp, &xx);
-	*ip = (int) xx;
-	if(xx > INT_MAX || xx < INT_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
-
-int
-ncx_get_double_uint(const void *xp, unsigned int *ip)
-{
-	double xx;
-	get_ix_double(xp, &xx);
-	*ip = (unsigned int) xx;
-	if(xx > UINT_MAX || xx < 0)
-		return NC_ERANGE;
-	return ENOERR;
-}
+#define ix_double double
 
-int
-ncx_get_double_longlong(const void *xp, longlong *ip)
-{
-	double xx;
-	get_ix_double(xp, &xx);
-	*ip = (longlong) xx;
-	if(xx > LONG_LONG_MAX || xx < LONG_LONG_MIN)
-		return NC_ERANGE;
-	return ENOERR;
-}
+static NCX_GET1F(double, schar)
+static NCX_GET1F(double, short)
+static NCX_GET1F(double, int)
+static NCX_GET1F(double, longlong)
+static NCX_GET1F(double, uchar)
+static NCX_GET1F(double, ushort)
+static NCX_GET1F(double, uint)
 
 int
 ncx_get_double_ulonglong(const void *xp, unsigned long long *ip)
@@ -1908,7 +1648,7 @@ ncx_get_double_ulonglong(const void *xp, unsigned long long *ip)
 	return ENOERR;
 }
 
-int
+static int
 ncx_get_double_float(const void *xp, float *ip)
 {
 	double xx;
@@ -1927,114 +1667,192 @@ ncx_get_double_float(const void *xp, float *ip)
 	return ENOERR;
 }
 
-int
+#if X_SIZEOF_DOUBLE != SIZEOF_DOUBLE  || defined(NO_IEEE_FLOAT)
+static int
 ncx_get_double_double(const void *xp, double *ip)
 {
 	/* TODO */
 	get_ix_double(xp, ip);
 	return ENOERR;
 }
+#endif
 
+static NCX_PUT1F(double, schar)
+static NCX_PUT1F(double, uchar)
+static NCX_PUT1F(double, short)
+static NCX_PUT1F(double, ushort)
+static NCX_PUT1F(double, int)
+static NCX_PUT1F(double, uint)
+static NCX_PUT1F(double, longlong)
+static NCX_PUT1F(double, ulonglong)
 
-int
-ncx_put_double_schar(void *xp, const schar *ip)
-{
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-	return ENOERR;
-}
-
-int
-ncx_put_double_uchar(void *xp, const uchar *ip)
-{
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-	return ENOERR;
-}
-
-int
-ncx_put_double_short(void *xp, const short *ip)
+static int
+ncx_put_double_float(void *xp, const float *ip)
 {
 	double xx = (double) *ip;
 	put_ix_double(xp, &xx);
-#if 0	/* TODO: figure this out */
+#if 1	/* TODO: figure this out */
 	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
 		return NC_ERANGE;
 #endif
 	return ENOERR;
 }
 
-int
-ncx_put_double_int(void *xp, const int *ip)
+#if X_SIZEOF_DOUBLE != SIZEOF_DOUBLE  || defined(NO_IEEE_FLOAT)
+static int
+ncx_put_double_double(void *xp, const double *ip)
 {
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
+	put_ix_double(xp, ip);
+#ifdef NO_IEEE_FLOAT
+	if(*ip > X_DOUBLE_MAX || *ip < X_DOUBLE_MIN)
 		return NC_ERANGE;
 #endif
 	return ENOERR;
 }
-
-int
-ncx_put_double_uint(void *xp, const unsigned int *ip)
-{
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-#if 0	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX)
-		return NC_ERANGE;
 #endif
-	return ENOERR;
-}
 
-int
-ncx_put_double_longlong(void *xp, const longlong *ip)
-{
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
-		return NC_ERANGE;
+
+/* x_longlong ---------------------------------------------------------------------*/
+
+#if SHORT_MAX == X_LONGLONG_MAX
+typedef short ix_longlong;
+#define SIZEOF_IX_LONGLONG SIZEOF_SHORT
+#define IX_LONGLONG_MAX SHORT_MAX
+#elif LONG_LONG_MAX  >= X_LONGLONG_MAX
+typedef longlong ix_longlong;
+#define SIZEOF_IX_LONGLONG SIZEOF_LONGLONG
+#define IX_LONGLONG_MAX LONG_LONG_MAX
+#elif LONG_MAX  >= X_LONGLONG_MAX
+typedef long ix_longlong;
+#define SIZEOF_IX_LONGLONG SIZEOF_LONG
+#define IX_LONGLONG_MAX LONG_MAX
+#else
+#error "ix_longlong implementation"
 #endif
-	return ENOERR;
-}
 
-int
-ncx_put_double_ulonglong(void *xp, const unsigned long long *ip)
+
+static void
+get_ix_longlong(const void *xp, ix_longlong *ip)
 {
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX)
-		return NC_ERANGE;
-#endif
-	return ENOERR;
+    const uchar *cp = (const uchar *) xp;
+
+    *ip  = ((long long)(*cp++) << 56);
+    *ip |= ((long long)(*cp++) << 48);
+    *ip |= ((long long)(*cp++) << 40);
+    *ip |= ((long long)(*cp++) << 32);
+    *ip |= ((long long)(*cp++) << 24);
+    *ip |= ((long long)(*cp++) << 16);
+    *ip |= ((long long)(*cp++) <<  8);
+    *ip |=  (long long)*cp;
 }
 
-int
-ncx_put_double_float(void *xp, const float *ip)
-{
-	double xx = (double) *ip;
-	put_ix_double(xp, &xx);
-#if 1	/* TODO: figure this out */
-	if((double)(*ip) > X_DOUBLE_MAX || (double)(*ip) < X_DOUBLE_MIN)
-		return NC_ERANGE;
+static void
+put_ix_longlong(void *xp, const ix_longlong *ip)
+{
+    uchar *cp = (uchar *) xp;
+
+    *cp++ = (*ip) >> 56;
+    *cp++ = ((*ip) & 0x00ff000000000000LL) >> 48;
+    *cp++ = ((*ip) & 0x0000ff0000000000LL) >> 40;
+    *cp++ = ((*ip) & 0x000000ff00000000LL) >> 32;
+    *cp++ = ((*ip) & 0x00000000ff000000LL) >> 24;
+    *cp++ = ((*ip) & 0x0000000000ff0000LL) >> 16;
+    *cp++ = ((*ip) & 0x000000000000ff00LL) >>  8;
+    *cp   = ((*ip) & 0x00000000000000ffLL);
+}
+
+static NCX_GET1I(longlong, schar,     0)
+static NCX_GET1I(longlong, short,     1)
+static NCX_GET1I(longlong, int,       1)
+static NCX_GET1I(longlong, longlong,  1)
+static NCX_GET1I(longlong, ushort,    0)
+static NCX_GET1I(longlong, uchar,     0)
+static NCX_GET1I(longlong, uint,      0)
+static NCX_GET1I(longlong, ulonglong, 0)
+static NCX_GET1F(longlong, float)
+static NCX_GET1F(longlong, double)
+
+static NCX_PUT1I(longlong, schar,     0)
+static NCX_PUT1I(longlong, short,     1)
+static NCX_PUT1I(longlong, int,       1)
+static NCX_PUT1I(longlong, longlong,  1)
+static NCX_PUT1I(longlong, ushort,    0)
+static NCX_PUT1I(longlong, uchar,     0)
+static NCX_PUT1I(longlong, uint,      0)
+static NCX_PUT1I(longlong, ulonglong, 0)
+static NCX_PUT1F(longlong, float)
+static NCX_PUT1F(longlong, double)
+
+/* x_ulonglong --------------------------------------------------------------------*/
+
+#if USHORT_MAX == X_ULONGLONG_MAX
+typedef ushort ix_ulonglong;
+#define SIZEOF_IX_ULONGLONG SIZEOF_USHORT
+#define IX_ULONGLONG_MAX USHORT_MAX
+#elif ULONG_LONG_MAX  >= X_ULONGLONG_MAX
+typedef ulonglong ix_ulonglong;
+#define SIZEOF_IX_ULONGLONG SIZEOF_ULONGLONG
+#define IX_ULONGLONG_MAX ULONG_LONG_MAX
+#elif ULONG_MAX  >= X_ULONGLONG_MAX
+typedef ulong ix_ulonglong;
+#define SIZEOF_IX_ULONGLONG SIZEOF_ULONG
+#define IX_ULONGLONG_MAX ULONG_MAX
+#else
+#error "ix_ulonglong implementation"
 #endif
-	return ENOERR;
-}
 
-int
-ncx_put_double_double(void *xp, const double *ip)
+
+static void
+get_ix_ulonglong(const void *xp, ix_ulonglong *ip)
 {
-	put_ix_double(xp, ip);
-#ifdef NO_IEEE_FLOAT
-	if(*ip > X_DOUBLE_MAX || *ip < X_DOUBLE_MIN)
-		return NC_ERANGE;
-#endif
-	return ENOERR;
+    const uchar *cp = (const uchar *) xp;
+
+    *ip  = ((unsigned long long)(*cp++) << 56);
+    *ip |= ((unsigned long long)(*cp++) << 48);
+    *ip |= ((unsigned long long)(*cp++) << 40);
+    *ip |= ((unsigned long long)(*cp++) << 32);
+    *ip |= ((unsigned long long)(*cp++) << 24);
+    *ip |= ((unsigned long long)(*cp++) << 16);
+    *ip |= ((unsigned long long)(*cp++) <<  8);
+    *ip |=  (unsigned long long)*cp;
 }
 
+static void
+put_ix_ulonglong(void *xp, const ix_ulonglong *ip)
+{
+    uchar *cp = (uchar *) xp;
+
+    *cp++ = (*ip) >> 56;
+    *cp++ = ((*ip) & 0x00ff000000000000ULL) >> 48;
+    *cp++ = ((*ip) & 0x0000ff0000000000ULL) >> 40;
+    *cp++ = ((*ip) & 0x000000ff00000000ULL) >> 32;
+    *cp++ = ((*ip) & 0x00000000ff000000ULL) >> 24;
+    *cp++ = ((*ip) & 0x0000000000ff0000ULL) >> 16;
+    *cp++ = ((*ip) & 0x000000000000ff00ULL) >>  8;
+    *cp   = ((*ip) & 0x00000000000000ffULL);
+}
+
+static NCX_GET1I(ulonglong, schar,     0)
+static NCX_GET1I(ulonglong, short,     0)
+static NCX_GET1I(ulonglong, int,       0)
+static NCX_GET1I(ulonglong, longlong,  0)
+static NCX_GET1I(ulonglong, ushort,    1)
+static NCX_GET1I(ulonglong, uchar,     1)
+static NCX_GET1I(ulonglong, uint,      1)
+static NCX_GET1I(ulonglong, ulonglong, 1)
+static NCX_GET1F(ulonglong, float)
+static NCX_GET1F(ulonglong, double)
+
+static NCX_PUT1I(ulonglong, schar,     0)
+static NCX_PUT1I(ulonglong, short,     0)
+static NCX_PUT1I(ulonglong, int,       0)
+static NCX_PUT1I(ulonglong, longlong,  0)
+static NCX_PUT1I(ulonglong, uchar,     1)
+static NCX_PUT1I(ulonglong, ushort,    1)
+static NCX_PUT1I(ulonglong, uint,      1)
+static NCX_PUT1I(ulonglong, ulonglong, 1)
+static NCX_PUT1F(ulonglong, float)
+static NCX_PUT1F(ulonglong, double)
 
 /* x_size_t */
 
@@ -2084,7 +1902,7 @@ ncx_put_off_t(void **xpp, const off_t *lp, size_t sizeof_off_t)
 		/* No negative offsets stored in netcdf */
 	if (*lp < 0) {
 	  /* Assume this is an overflow of a 32-bit int... */
-	  return ERANGE;
+	  return NC_ERANGE;
 	}
 
 	assert(sizeof_off_t == 4 || sizeof_off_t == 8);
@@ -2147,7 +1965,7 @@ ncx_get_off_t(const void **xpp, off_t *lp, size_t sizeof_off_t)
  * on this system.  Set an error code and return.
  */
 		if (*lp != 0) {
-		  return ERANGE;
+		  return NC_ERANGE;
 		}
 
 		*lp  = ((off_t)(*cp++) << 24);
@@ -2161,45 +1979,128 @@ ncx_get_off_t(const void **xpp, off_t *lp, size_t sizeof_off_t)
 		   * than 2^32 which is not allowed, but is not caught
 		   * by the previous check
 		   */
-		  return ERANGE;
+		  return NC_ERANGE;
 		}
 #else
-		*lp =  ((off_t)(*cp++) << 56);
-		*lp |= ((off_t)(*cp++) << 48);
-		*lp |= ((off_t)(*cp++) << 40);
-		*lp |= ((off_t)(*cp++) << 32);
-		*lp |= ((off_t)(*cp++) << 24);
-		*lp |= ((off_t)(*cp++) << 16);
-		*lp |= ((off_t)(*cp++) <<  8);
-		*lp |=  (off_t)*cp;
+		*lp =  ((off_t)(*cp++) << 56);
+		*lp |= ((off_t)(*cp++) << 48);
+		*lp |= ((off_t)(*cp++) << 40);
+		*lp |= ((off_t)(*cp++) << 32);
+		*lp |= ((off_t)(*cp++) << 24);
+		*lp |= ((off_t)(*cp++) << 16);
+		*lp |= ((off_t)(*cp++) <<  8);
+		*lp |=  (off_t)*cp;
+#endif
+	}
+	*xpp = (const void *)((const char *)(*xpp) + sizeof_off_t);
+	return ENOERR;
+}
+
+/*----< ncx_get_int32() >--------------------------------------------------*/
+int
+ncx_get_int32(const void **xpp,
+              int         *ip)
+{
+    const uchar *cp = (const uchar *) *xpp;
+
+    /* cannot call swap4b(), as lp is 8-byte */
+    *ip  = (*cp++ << 24);
+    *ip |= (*cp++ << 16);
+    *ip |= (*cp++ <<  8);
+    *ip |=  *cp;
+
+    /* advance *xpp 4 bytes */
+    *xpp = (void *)((const char *)(*xpp) + 4);
+
+    return NC_NOERR;
+}
+
+/*----< ncx_get_int64() >-------------------------------------------------*/
+int
+ncx_get_int64(const void **xpp,
+              long long   *llp)
+{
+    const uchar *cp = (const uchar *) *xpp;
+
+    /* below is the same as calling swap8b(llp, *xpp) */
+    *llp  = ((long long)(*cp++) << 56);
+    *llp |= ((long long)(*cp++) << 48);
+    *llp |= ((long long)(*cp++) << 40);
+    *llp |= ((long long)(*cp++) << 32);
+    *llp |= ((long long)(*cp++) << 24);
+    *llp |= ((long long)(*cp++) << 16);
+    *llp |= ((long long)(*cp++) <<  8);
+    *llp |=  (long long)*cp;
+
+    /* advance *xpp 8 bytes */
+    *xpp = (void *)((const char *)(*xpp) + 8);
+
+    return NC_NOERR;
+}
+
+/*---< ncx_put_int32() >-----------------------------------------------------*/
+/* copy the contents of lp (a signed 32-bit integer) to xpp in Big Endian
+ * form and advance *xpp 4 bytes
+ */
+int
+ncx_put_int32(void      **xpp,
+              const int   ip)
+{
+#ifdef WORDS_BIGENDIAN
+    int *ptr = (int*) (*xpp); /* typecast to 4-byte integer */
+    *ptr = ip;
+#else
+    /* bitwise shifts below are to produce an integer in Big Endian */
+    /* cannot call swap4b(), as lp is 8-byte */
+    uchar *cp = (uchar *) *xpp;
+    *cp++ = (uchar)((ip & 0xff000000) >> 24);
+    *cp++ = (uchar)((ip & 0x00ff0000) >> 16);
+    *cp++ = (uchar)((ip & 0x0000ff00) >>  8);
+    *cp   = (uchar)( ip & 0x000000ff);
+#endif
+    /* advance *xpp 4 bytes */
+    *xpp  = (void *)((char *)(*xpp) + 4);
+
+    return NC_NOERR;
+}
+
+/*---< ncx_put_int64() >-----------------------------------------------------*/
+/* copy the contents of lp (a signed 64-bit integer) to xpp in Big Endian
+ * form and advance *xpp 8 bytes
+ */
+int
+ncx_put_int64(void             **xpp,
+              const long long    ip)
+{
+#ifdef WORDS_BIGENDIAN
+    long long *ptr = (long long*) (*xpp); /* typecast to 8-byte integer */
+    *ptr = ip;
+#else
+    uchar *cp = (uchar *) *xpp;
+    /* below is the same as calling swap8b(*xpp, &ip) */
+    *cp++ = (uchar)((ip & 0xff00000000000000ULL) >> 56);
+    *cp++ = (uchar)((ip & 0x00ff000000000000ULL) >> 48);
+    *cp++ = (uchar)((ip & 0x0000ff0000000000ULL) >> 40);
+    *cp++ = (uchar)((ip & 0x000000ff00000000ULL) >> 32);
+    *cp++ = (uchar)((ip & 0x00000000ff000000ULL) >> 24);
+    *cp++ = (uchar)((ip & 0x0000000000ff0000ULL) >> 16);
+    *cp++ = (uchar)((ip & 0x000000000000ff00ULL) >>  8);
+    *cp   = (uchar)( ip & 0x00000000000000ffULL);
 #endif
-	}
-	*xpp = (const void *)((const char *)(*xpp) + sizeof_off_t);
-	return ENOERR;
+    /* advance *xpp 8 bytes */
+    *xpp  = (void *)((char *)(*xpp) + 8);
+
+    return NC_NOERR;
 }
 
 
 /*
  * Aggregate numeric conversion functions.
  */
-dnl dnl dnl
 dnl
-dnl Upcase(str)
-dnl
-define(`Upcase',dnl
-`dnl
-translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)')dnl
-dnl
-dnl dnl dnl
-dnl
-dnl  sjl: some macros used for putn/getn:
-define(`Isizeof', ``SIZEOF_'Upcase($1)')dnl
-define(`Xsizeof', ``X_SIZEOF_'Upcase($1)')dnl
-define(`Imax', `Upcase($1)`_MAX'')dnl
-define(`Imin', `Upcase($1)`_MIN'')dnl
-define(`Xmax', ``X_'Upcase($1)`_MAX'')dnl
-define(`Xmin', ``X_'Upcase($1)`_MIN'')dnl
-define(`ImaxExp', `Upcase($1)`_MAX_EXP'')dnl
+define(`GETN_CheckBND', `ifelse(index(`$1',`u'), 0, , `ifelse(index(`$2',`u'), 0, `|| xp[i] < 0', `|| xp[i] < Imin($2)')')')dnl
+define(`PUTN_CheckBND', `ifelse(index(`$2',`u'), 0, , `ifelse(index(`$1',`u'), 0, `|| tp[i] < 0', `|| tp[i] < Xmin($1)')')')dnl
+
 dnl
 dnl dnl dnl
 dnl
@@ -2229,46 +2130,50 @@ define(`NCX_PAD_GETN_Byte_Body',dnl
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_GETN_SCHAR(Type)
+dnl NCX_GETN_CHAR(Type)
 dnl
-define(`NCX_GETN_SCHAR',dnl
+define(`NCX_GETN_CHAR',dnl
 `dnl
 int
-ncx_getn_schar_$1(const void **xpp, size_t nelems, $1 *tp)
+ncx_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
 {
-	schar *xp = (schar *)(*xpp);
+	int status = ENOERR;
+	$1 *xp = ($1 *)(*xpp);
 
 	while(nelems-- != 0)
 	{
+ifelse(index(`$1',`u'), 0, , `ifelse(index(`$2',`u'), 0, `		if (*xp < 0) status = NC_ERANGE;')')
 		*tp++ = *xp++;
 	}
 
 	*xpp = (const void *)xp;
-	return ENOERR;
+	return status;
 }
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_PAD_GETN_SCHAR(Type)
+dnl NCX_PAD_GETN_CHAR(Type)
 dnl
-define(`NCX_PAD_GETN_SCHAR',dnl
+define(`NCX_PAD_GETN_CHAR',dnl
 `dnl
 int
-ncx_pad_getn_schar_$1(const void **xpp, size_t nelems, $1 *tp)
+ncx_pad_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
 {
+	int status = ENOERR;
 	size_t rndup = nelems % X_ALIGN;
-	schar *xp = (schar *) *xpp;
+	$1 *xp = ($1 *) *xpp;
 
 	if(rndup)
 		rndup = X_ALIGN - rndup;
 
 	while(nelems-- != 0)
 	{
+ifelse(index(`$1',`u'), 0, , `ifelse(index(`$2',`u'), 0, `		if (*xp < 0) status = NC_ERANGE;')')
 		*tp++ = *xp++;
 	}
 
 	*xpp = (void *)(xp + rndup);
-	return ENOERR;
+	return status;
 }
 ')dnl
 dnl dnl dnl
@@ -2298,7 +2203,7 @@ ncx_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_GETN(XType, Type)
+dnl NCX_GETN(XType, Type, condition)
 dnl
 define(`NCX_GETN',dnl
 `dnl
@@ -2339,7 +2244,9 @@ ncx_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
     for (i=0; i<ni; i++) {
       tp[i] = ($2) Max( Imin($2), Min(Imax($2), ($2) xp[i]));
      /* test for range errors (not always needed but do it anyway) */
-      nrange += xp[i] < Imin($2) || xp[i] > Imax($2);
+     /* if xpp is unsigned, we need not check if xp[i] < Imin */
+     /* if xpp is signed && tp is unsigned, we need check if xp[i] >= 0 */
+      nrange += xp[i] > Imax($2) GETN_CheckBND($1, $2);
     }
    /* update xpp and tp */
     if (realign) xp = ($1 *) *xpp;
@@ -2367,28 +2274,27 @@ ncx_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_PAD_GETN_SHORT( Type)
+dnl NCX_PAD_GETN_SHORT(xtype ttype)
 dnl
 define(`NCX_PAD_GETN_SHORT',dnl
 `dnl
 int
-ncx_pad_getn_short_$1(const void **xpp, size_t nelems, $1 *tp)
+ncx_pad_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
 {
 	const size_t rndup = nelems % 2;
 
 	const char *xp = (const char *) *xpp;
 	int status = ENOERR;
 
-	for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
+	for( ; nelems != 0; nelems--, xp += Xsizeof($1), tp++)
 	{
-		const int lstatus = ncx_get_short_$1(xp, tp);
+		const int lstatus = ncx_get_$1_$2(xp, tp);
 		if(lstatus != ENOERR)
 			status = lstatus;
 	}
 
 	if(rndup != 0)
-		xp += X_SIZEOF_SHORT;
-
+		xp += Xsizeof($1);
 	*xpp = (void *)xp;
 	return status;
 }
@@ -2428,21 +2334,21 @@ define(`NCX_PAD_PUTN_Byte_Body',dnl
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_PUTN_SCHAR(Type)
+dnl NCX_PUTN_CHAR(Type)
 dnl
-define(`NCX_PUTN_SCHAR',dnl
+define(`NCX_PUTN_CHAR',dnl
 `dnl
 int
-ncx_putn_schar_$1(void **xpp, size_t nelems, const $1 *tp)
+ncx_putn_$1_$2(void **xpp, size_t nelems, const $2 *tp)
 {
 	int status = ENOERR;
-	schar *xp = (schar *) *xpp;
+	$1 *xp = ($1 *) *xpp;
 
 	while(nelems-- != 0)
 	{
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+		if(*tp > Xmax($1) ifelse(index(`$2',`u'), 0, , `ifelse(index(`$1',`u'), 0, `|| *tp < 0',`|| *tp < Xmin(schar)')'))
 			status = NC_ERANGE;
-		*xp++ = (schar) *tp++;
+		*xp++ = ($1) *tp++;
 	}
 
 	*xpp = (void *)xp;
@@ -2451,26 +2357,25 @@ ncx_putn_schar_$1(void **xpp, size_t nelems, const $1 *tp)
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_PAD_PUTN_SCHAR(Type)
+dnl NCX_PAD_PUTN_CHAR(xtype, ttype)
 dnl
-define(`NCX_PAD_PUTN_SCHAR',dnl
+define(`NCX_PAD_PUTN_CHAR',dnl
 `dnl
 int
-ncx_pad_putn_schar_$1(void **xpp, size_t nelems, const $1 *tp)
+ncx_pad_putn_$1_$2(void **xpp, size_t nelems, const $2 *tp)
 {
 	int status = ENOERR;
 	size_t rndup = nelems % X_ALIGN;
-	schar *xp = (schar *) *xpp;
+	$1 *xp = ($1 *) *xpp;
 
 	if(rndup)
 		rndup = X_ALIGN - rndup;
 
 	while(nelems-- != 0)
 	{
-		/* N.B. schar as signed */
-		if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN)
+		if(*tp > Xmax($1) ifelse(index(`$2',`u'), 0, , `ifelse(index(`$1',`u'), 0, `|| *tp < 0',`|| *tp < Xmin(schar)')'))
 			status = NC_ERANGE;
-		*xp++ = (schar) *tp++;
+		*xp++ = ($1) *tp++;
 	}
 
 
@@ -2513,7 +2418,7 @@ ncx_putn_$1_$2(void **xpp, size_t nelems, const $2 *tp)
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_PUTN(XType, Type)
+dnl NCX_PUTN(XType, Type, condition)
 dnl
 define(`NCX_PUTN',dnl
 `dnl
@@ -2560,13 +2465,15 @@ ifelse( $1$2, intfloat,dnl
       /* for some reason int to float, for putn, requires a special case */
       d = tp[i];
       xp[i] = ($1) Max( Xmin($1), Min(Xmax($1), ($1) d));
-      nrange += d < Xmin($1) || d > Xmax($1);
+      nrange += tp[i] > Xmax($1) PUTN_CheckBND($1, $2);
 ',dnl
 `dnl
       /* the normal case: */
       xp[i] = ($1) Max( Xmin($1), Min(Xmax($1), ($1) tp[i]));
      /* test for range errors (not always needed but do it anyway) */
-      nrange += tp[i] < Xmin($1) || tp[i] > Xmax($1);
+     /* if xpp is unsigned && tp is signed, we need check if tp[i] >= 0 */
+     /* if tp is unsigned, we need not check if tp[i] < Xmin */
+      nrange += tp[i] > Xmax($1) PUTN_CheckBND($1, $2);
 ')dnl
     }
    /* copy workspace back if necessary */
@@ -2600,29 +2507,29 @@ ifelse( $1$2, intfloat,dnl
 ')dnl
 dnl dnl dnl
 dnl
-dnl NCX_PAD_PUTN_SHORT(Type)
+dnl NCX_PAD_PUTN_SHORT(xtype, ttype)
 dnl
 define(`NCX_PAD_PUTN_SHORT',dnl
 `dnl
 int
-ncx_pad_putn_short_$1(void **xpp, size_t nelems, const $1 *tp)
+ncx_pad_putn_$1_$2(void **xpp, size_t nelems, const $2 *tp)
 {
 	const size_t rndup = nelems % 2;
 
 	char *xp = (char *) *xpp;
 	int status = ENOERR;
 
-	for( ; nelems != 0; nelems--, xp += Xsizeof(short), tp++)
+	for( ; nelems != 0; nelems--, xp += Xsizeof($1), tp++)
 	{
-		int lstatus = ncx_put_short_$1(xp, tp);
+		int lstatus = ncx_put_$1_$2(xp, tp);
 		if(lstatus != ENOERR)
 			status = lstatus;
 	}
 
 	if(rndup != 0)
 	{
-		(void) memcpy(xp, nada, X_SIZEOF_SHORT);
-		xp += X_SIZEOF_SHORT;
+		(void) memcpy(xp, nada, Xsizeof($1));
+		xp += Xsizeof($1);
 	}
 
 	*xpp = (void *)xp;
@@ -2630,100 +2537,187 @@ ncx_pad_putn_short_$1(void **xpp, size_t nelems, const $1 *tp)
 }
 ')dnl
 
-
 dnl dnl dnl
 dnl
 dnl Declare & define routines
 dnl
 dnl dnl dnl
 
-/* schar */
+/* schar ---------------------------------------------------------------------*/
 
-dnl NCX_GETN_SCHAR(schar)
+dnl NCX_GETN_CHAR(schar, schar)
 int
 ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
 {
 	NCX_GETN_Byte_Body
 }
-dnl NCX_GETN_SCHAR(uchar)
+dnl NCX_GETN_CHAR(schar, uchar)
 int
 ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
 	NCX_GETN_Byte_Body
 }
-NCX_GETN_SCHAR(short)
-NCX_GETN_SCHAR(int)
-NCX_GETN_SCHAR(float)
-NCX_GETN_SCHAR(double)
-NCX_GETN_SCHAR(uint)
-NCX_GETN_SCHAR(longlong)
-NCX_GETN_SCHAR(ulonglong)
+NCX_GETN_CHAR(schar, short)
+NCX_GETN_CHAR(schar, int)
+NCX_GETN_CHAR(schar, float)
+NCX_GETN_CHAR(schar, double)
+NCX_GETN_CHAR(schar, longlong)
+NCX_GETN_CHAR(schar, ushort)
+NCX_GETN_CHAR(schar, uint)
+NCX_GETN_CHAR(schar, ulonglong)
 
-dnl NCX_PAD_GETN_SCHAR(schar)
+dnl NCX_PAD_GETN_CHAR(schar, schar)
 int
 ncx_pad_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
 {
 	NCX_PAD_GETN_Byte_Body
 }
-dnl NCX_PAD_GETN_SCHAR(uchar)
+dnl NCX_PAD_GETN_CHAR(schar, uchar)
 int
 ncx_pad_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
 {
 	NCX_PAD_GETN_Byte_Body
 }
-NCX_PAD_GETN_SCHAR(short)
-NCX_PAD_GETN_SCHAR(int)
-NCX_PAD_GETN_SCHAR(float)
-NCX_PAD_GETN_SCHAR(double)
-NCX_PAD_GETN_SCHAR(uint)
-NCX_PAD_GETN_SCHAR(longlong)
-NCX_PAD_GETN_SCHAR(ulonglong)
+NCX_PAD_GETN_CHAR(schar, short)
+NCX_PAD_GETN_CHAR(schar, int)
+NCX_PAD_GETN_CHAR(schar, float)
+NCX_PAD_GETN_CHAR(schar, double)
+NCX_PAD_GETN_CHAR(schar, longlong)
+NCX_PAD_GETN_CHAR(schar, ushort)
+NCX_PAD_GETN_CHAR(schar, uint)
+NCX_PAD_GETN_CHAR(schar, ulonglong)
 
-dnl NCX_PUTN_SCHAR(schar)
+dnl NCX_PUTN_CHAR(schar, schar)
 int
 ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
 {
 	NCX_PUTN_Byte_Body
 }
-dnl NCX_PUTN_SCHAR(uchar)
+dnl NCX_PUTN_CHAR(schar, uchar)
 int
 ncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp)
 {
 	NCX_PUTN_Byte_Body
 }
-NCX_PUTN_SCHAR(short)
-NCX_PUTN_SCHAR(int)
-NCX_PUTN_SCHAR(float)
-NCX_PUTN_SCHAR(double)
-NCX_PUTN_SCHAR(uint)
-NCX_PUTN_SCHAR(longlong)
-NCX_PUTN_SCHAR(ulonglong)
+NCX_PUTN_CHAR(schar, short)
+NCX_PUTN_CHAR(schar, int)
+NCX_PUTN_CHAR(schar, float)
+NCX_PUTN_CHAR(schar, double)
+NCX_PUTN_CHAR(schar, longlong)
+NCX_PUTN_CHAR(schar, ushort)
+NCX_PUTN_CHAR(schar, uint)
+NCX_PUTN_CHAR(schar, ulonglong)
 
-dnl NCX_PAD_PUTN_SCHAR(schar)
+dnl NCX_PAD_PUTN_CHAR(schar, schar)
 int
 ncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
 {
 	NCX_PAD_PUTN_Byte_Body
 }
-dnl NCX_PAD_PUTN_SCHAR(uchar)
+dnl NCX_PAD_PUTN_CHAR(schar, uchar)
 int
 ncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp)
 {
 	NCX_PAD_PUTN_Byte_Body
 }
-NCX_PAD_PUTN_SCHAR(short)
-NCX_PAD_PUTN_SCHAR(int)
-NCX_PAD_PUTN_SCHAR(float)
-NCX_PAD_PUTN_SCHAR(double)
-NCX_PAD_PUTN_SCHAR(uint)
-NCX_PAD_PUTN_SCHAR(longlong)
-NCX_PAD_PUTN_SCHAR(ulonglong)
+NCX_PAD_PUTN_CHAR(schar, short)
+NCX_PAD_PUTN_CHAR(schar, int)
+NCX_PAD_PUTN_CHAR(schar, float)
+NCX_PAD_PUTN_CHAR(schar, double)
+NCX_PAD_PUTN_CHAR(schar, longlong)
+NCX_PAD_PUTN_CHAR(schar, ushort)
+NCX_PAD_PUTN_CHAR(schar, uint)
+NCX_PAD_PUTN_CHAR(schar, ulonglong)
+
 
+/* uchar ---------------------------------------------------------------------*/
+dnl
+dnl NCX_GETN_CHAR(uchar, schar)
+int
+ncx_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
+{
+	NCX_GETN_Byte_Body
+}
+dnl NCX_GETN_CHAR(uchar, uchar)
+int
+ncx_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+	NCX_GETN_Byte_Body
+}
+NCX_GETN_CHAR(uchar, short)
+NCX_GETN_CHAR(uchar, int)
+NCX_GETN_CHAR(uchar, float)
+NCX_GETN_CHAR(uchar, double)
+NCX_GETN_CHAR(uchar, longlong)
+NCX_GETN_CHAR(uchar, ushort)
+NCX_GETN_CHAR(uchar, uint)
+NCX_GETN_CHAR(uchar, ulonglong)
 
-/* short */
+dnl NCX_PAD_GETN_CHAR(uchar, schar)
+int
+ncx_pad_getn_uchar_schar(const void **xpp, size_t nelems, schar *tp)
+{
+	NCX_PAD_GETN_Byte_Body
+}
+dnl NCX_PAD_GETN_CHAR(uchar, uchar)
+int
+ncx_pad_getn_uchar_uchar(const void **xpp, size_t nelems, uchar *tp)
+{
+	NCX_PAD_GETN_Byte_Body
+}
+NCX_PAD_GETN_CHAR(uchar, short)
+NCX_PAD_GETN_CHAR(uchar, int)
+NCX_PAD_GETN_CHAR(uchar, float)
+NCX_PAD_GETN_CHAR(uchar, double)
+NCX_PAD_GETN_CHAR(uchar, longlong)
+NCX_PAD_GETN_CHAR(uchar, ushort)
+NCX_PAD_GETN_CHAR(uchar, uint)
+NCX_PAD_GETN_CHAR(uchar, ulonglong)
+
+dnl NCX_PUTN_CHAR(uchar, schar)
+int
+ncx_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp)
+{
+	NCX_PUTN_Byte_Body
+}
+dnl NCX_PUTN_CHAR(uchar, uchar)
+int
+ncx_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+	NCX_PUTN_Byte_Body
+}
+NCX_PUTN_CHAR(uchar, short)
+NCX_PUTN_CHAR(uchar, int)
+NCX_PUTN_CHAR(uchar, float)
+NCX_PUTN_CHAR(uchar, double)
+NCX_PUTN_CHAR(uchar, longlong)
+NCX_PUTN_CHAR(uchar, ushort)
+NCX_PUTN_CHAR(uchar, uint)
+NCX_PUTN_CHAR(uchar, ulonglong)
+
+dnl NCX_PAD_PUTN_UCHAR(uchar, schar)
+int
+ncx_pad_putn_uchar_schar(void **xpp, size_t nelems, const schar *tp)
+{
+	NCX_PAD_PUTN_Byte_Body
+}
+dnl NCX_PAD_PUTN_UCHAR(uchar, uchar)
+int
+ncx_pad_putn_uchar_uchar(void **xpp, size_t nelems, const uchar *tp)
+{
+	NCX_PAD_PUTN_Byte_Body
+}
+NCX_PAD_PUTN_CHAR(uchar, short)
+NCX_PAD_PUTN_CHAR(uchar, int)
+NCX_PAD_PUTN_CHAR(uchar, float)
+NCX_PAD_PUTN_CHAR(uchar, double)
+NCX_PAD_PUTN_CHAR(uchar, longlong)
+NCX_PAD_PUTN_CHAR(uchar, ushort)
+NCX_PAD_PUTN_CHAR(uchar, uint)
+NCX_PAD_PUTN_CHAR(uchar, ulonglong)
+
+/* short ---------------------------------------------------------------------*/
 
-NCX_GETN(short, schar)
-NCX_GETN(short, uchar)
 #if X_SIZEOF_SHORT == SIZEOF_SHORT
 /* optimized version */
 int
@@ -2740,25 +2734,27 @@ ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
 #else
 NCX_GETN(short, short)
 #endif
+NCX_GETN(short, schar)
 NCX_GETN(short, int)
 NCX_GETN(short, float)
 NCX_GETN(short, double)
-NCX_GETN(short,uint)
-NCX_GETN(short,longlong)
-NCX_GETN(short,ulonglong)
-
-NCX_PAD_GETN_SHORT(schar)
-NCX_PAD_GETN_SHORT(uchar)
-NCX_PAD_GETN_SHORT(short)
-NCX_PAD_GETN_SHORT(int)
-NCX_PAD_GETN_SHORT(float)
-NCX_PAD_GETN_SHORT(double)
-NCX_PAD_GETN_SHORT(uint)
-NCX_PAD_GETN_SHORT(longlong)
-NCX_PAD_GETN_SHORT(ulonglong)
+NCX_GETN(short, longlong)
+NCX_GETN(short, uchar)
+NCX_GETN(short, ushort)
+NCX_GETN(short, uint)
+NCX_GETN(short, ulonglong)
+
+NCX_PAD_GETN_SHORT(short, schar)
+NCX_PAD_GETN_SHORT(short, uchar)
+NCX_PAD_GETN_SHORT(short, short)
+NCX_PAD_GETN_SHORT(short, int)
+NCX_PAD_GETN_SHORT(short, float)
+NCX_PAD_GETN_SHORT(short, double)
+NCX_PAD_GETN_SHORT(short, uint)
+NCX_PAD_GETN_SHORT(short, longlong)
+NCX_PAD_GETN_SHORT(short, ulonglong)
+NCX_PAD_GETN_SHORT(short, ushort)
 
-NCX_PUTN(short, schar)
-NCX_PUTN(short, uchar)
 #if X_SIZEOF_SHORT == SIZEOF_SHORT
 /* optimized version */
 int
@@ -2775,44 +2771,111 @@ ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
 #else
 NCX_PUTN(short, short)
 #endif
+NCX_PUTN(short, schar)
 NCX_PUTN(short, int)
 NCX_PUTN(short, float)
 NCX_PUTN(short, double)
-NCX_PUTN(short, uint)
 NCX_PUTN(short, longlong)
+NCX_PUTN(short, uchar)
+NCX_PUTN(short, uint)
 NCX_PUTN(short, ulonglong)
+NCX_PUTN(short, ushort)
 
-NCX_PAD_PUTN_SHORT(schar)
-NCX_PAD_PUTN_SHORT(uchar)
-NCX_PAD_PUTN_SHORT(short)
-NCX_PAD_PUTN_SHORT(int)
-NCX_PAD_PUTN_SHORT(float)
-NCX_PAD_PUTN_SHORT(double)
-NCX_PAD_PUTN_SHORT(uint)
-NCX_PAD_PUTN_SHORT(longlong)
-NCX_PAD_PUTN_SHORT(ulonglong)
+NCX_PAD_PUTN_SHORT(short, schar)
+NCX_PAD_PUTN_SHORT(short, uchar)
+NCX_PAD_PUTN_SHORT(short, short)
+NCX_PAD_PUTN_SHORT(short, int)
+NCX_PAD_PUTN_SHORT(short, float)
+NCX_PAD_PUTN_SHORT(short, double)
+NCX_PAD_PUTN_SHORT(short, uint)
+NCX_PAD_PUTN_SHORT(short, longlong)
+NCX_PAD_PUTN_SHORT(short, ulonglong)
+NCX_PAD_PUTN_SHORT(short, ushort)
 
 
-/* int */
+/* ushort --------------------------------------------------------------------*/
 
-NCX_GETN(int, schar)
-NCX_GETN(int, uchar)
-NCX_GETN(int, short)
-#if X_SIZEOF_INT == SIZEOF_INT
+#if X_SIZEOF_USHORT == SIZEOF_USHORT
 /* optimized version */
 int
-ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
+ncx_getn_ushort_ushort(const void **xpp, size_t nelems, unsigned short *tp)
 {
 #ifdef WORDS_BIGENDIAN
-	(void) memcpy(tp, *xpp, nelems * sizeof(int));
+	(void) memcpy(tp, *xpp, nelems * sizeof(unsigned short));
 # else
-	swapn4b(tp, *xpp, nelems);
+	swapn2b(tp, *xpp, nelems);
 # endif
-	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_USHORT);
+	return ENOERR;
+}
+#else
+NCX_GETN(ushort, ushort)
+#endif
+NCX_GETN(ushort, schar)
+NCX_GETN(ushort, short)
+NCX_GETN(ushort, int)
+NCX_GETN(ushort, float)
+NCX_GETN(ushort, double)
+NCX_GETN(ushort, longlong)
+NCX_GETN(ushort, uchar)
+NCX_GETN(ushort, uint)
+NCX_GETN(ushort, ulonglong)
+
+NCX_PAD_GETN_SHORT(ushort, schar)
+NCX_PAD_GETN_SHORT(ushort, uchar)
+NCX_PAD_GETN_SHORT(ushort, short)
+NCX_PAD_GETN_SHORT(ushort, ushort)
+NCX_PAD_GETN_SHORT(ushort, int)
+NCX_PAD_GETN_SHORT(ushort, uint)
+NCX_PAD_GETN_SHORT(ushort, float)
+NCX_PAD_GETN_SHORT(ushort, double)
+NCX_PAD_GETN_SHORT(ushort, longlong)
+NCX_PAD_GETN_SHORT(ushort, ulonglong)
+
+#if X_SIZEOF_USHORT == SIZEOF_USHORT
+/* optimized version */
+int
+ncx_putn_ushort_ushort(void **xpp, size_t nelems, const unsigned short *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_USHORT);
+# else
+	swapn2b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_USHORT);
 	return ENOERR;
 }
+#else
+NCX_PUTN(ushort, ushort)
+#endif
+NCX_PUTN(ushort, schar)
+NCX_PUTN(ushort, short)
+NCX_PUTN(ushort, int)
+NCX_PUTN(ushort, float)
+NCX_PUTN(ushort, double)
+NCX_PUTN(ushort, longlong)
+NCX_PUTN(ushort, uchar)
+NCX_PUTN(ushort, uint)
+NCX_PUTN(ushort, ulonglong)
+
+NCX_PAD_PUTN_SHORT(ushort, schar)
+NCX_PAD_PUTN_SHORT(ushort, uchar)
+NCX_PAD_PUTN_SHORT(ushort, short)
+NCX_PAD_PUTN_SHORT(ushort, int)
+NCX_PAD_PUTN_SHORT(ushort, float)
+NCX_PAD_PUTN_SHORT(ushort, double)
+NCX_PAD_PUTN_SHORT(ushort, uint)
+NCX_PAD_PUTN_SHORT(ushort, longlong)
+NCX_PAD_PUTN_SHORT(ushort, ulonglong)
+NCX_PAD_PUTN_SHORT(ushort, ushort)
+
+
+/* int -----------------------------------------------------------------------*/
+
+#if X_SIZEOF_INT == SIZEOF_INT
+/* optimized version */
 int
-ncx_getn_int_uint(const void **xpp, size_t nelems, unsigned int *tp)
+ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
 {
 #ifdef WORDS_BIGENDIAN
 	(void) memcpy(tp, *xpp, nelems * sizeof(int));
@@ -2824,18 +2887,17 @@ ncx_getn_int_uint(const void **xpp, size_t nelems, unsigned int *tp)
 }
 #else
 NCX_GETN(int, int)
-NCX_GETN(int, uint)
 #endif
-
-NCX_GETN(int, longlong)
-NCX_GETN(int, ulonglong)
-
+NCX_GETN(int, schar)
+NCX_GETN(int, short)
 NCX_GETN(int, float)
 NCX_GETN(int, double)
+NCX_GETN(int, longlong)
+NCX_GETN(int, uchar)
+NCX_GETN(int, ushort)
+NCX_GETN(int, uint)
+NCX_GETN(int, ulonglong)
 
-NCX_PUTN(int, schar)
-NCX_PUTN(int, uchar)
-NCX_PUTN(int, short)
 #if X_SIZEOF_INT == SIZEOF_INT
 /* optimized version */
 int
@@ -2849,34 +2911,76 @@ ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
 	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
 	return ENOERR;
 }
+#else
+NCX_PUTN(int, int)
+#endif
+NCX_PUTN(int, schar)
+NCX_PUTN(int, short)
+NCX_PUTN(int, float)
+NCX_PUTN(int, double)
+NCX_PUTN(int, longlong)
+NCX_PUTN(int, uchar)
+NCX_PUTN(int, ushort)
+NCX_PUTN(int, uint)
+NCX_PUTN(int, ulonglong)
+
+/* uint ----------------------------------------------------------------------*/
+
+#if X_SIZEOF_UINT == SIZEOF_UINT
+/* optimized version */
+int
+ncx_getn_uint_uint(const void **xpp, size_t nelems, unsigned int *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(uint));
+# else
+	swapn4b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_UINT);
+	return ENOERR;
+}
+#else
+NCX_GETN(uint, uint)
+#endif
+NCX_GETN(uint, schar)
+NCX_GETN(uint, short)
+NCX_GETN(uint, int)
+NCX_GETN(uint, float)
+NCX_GETN(uint, double)
+NCX_GETN(uint, longlong)
+NCX_GETN(uint, uchar)
+NCX_GETN(uint, ushort)
+NCX_GETN(uint, ulonglong)
+
+#if X_SIZEOF_UINT == SIZEOF_UINT
+/* optimized version */
 int
-ncx_putn_int_uint(void **xpp, size_t nelems, const unsigned int *tp)
+ncx_putn_uint_uint(void **xpp, size_t nelems, const unsigned int *tp)
 {
 #ifdef WORDS_BIGENDIAN
-	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_INT);
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_UINT);
 # else
 	swapn4b(*xpp, tp, nelems);
 # endif
-	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_INT);
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_UINT);
 	return ENOERR;
 }
 #else
-NCX_PUTN(int, int)
-NCX_PUTN(int, uint)
+NCX_PUTN(uint, uint)
 #endif
+NCX_PUTN(uint, schar)
+NCX_PUTN(uint, short)
+NCX_PUTN(uint, int)
+NCX_PUTN(uint, float)
+NCX_PUTN(uint, double)
+NCX_PUTN(uint, longlong)
+NCX_PUTN(uint, uchar)
+NCX_PUTN(uint, ushort)
+NCX_PUTN(uint, ulonglong)
 
-NCX_PUTN(int, longlong)
-NCX_PUTN(int, ulonglong)
-NCX_PUTN(int, float)
-NCX_PUTN(int, double)
 
+/* float ---------------------------------------------------------------------*/
 
-/* float */
-
-NCX_GETN(float, schar)
-NCX_GETN(float, uchar)
-NCX_GETN(float, short)
-NCX_GETN(float, int)
 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
 /* optimized version */
 int
@@ -2924,15 +3028,16 @@ ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
 }
 
 #endif
+NCX_GETN(float, schar)
+NCX_GETN(float, short)
+NCX_GETN(float, int)
 NCX_GETN(float, double)
-NCX_GETN(float, uint)
 NCX_GETN(float, longlong)
+NCX_GETN(float, ushort)
+NCX_GETN(float, uchar)
+NCX_GETN(float, uint)
 NCX_GETN(float, ulonglong)
 
-NCX_PUTN(float, schar)
-NCX_PUTN(float, uchar)
-NCX_PUTN(float, short)
-NCX_PUTN(float, int)
 #if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
 /* optimized version */
 int
@@ -2978,24 +3083,19 @@ ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
 	*xpp = (void *)xp;
 	return status;
 }
-
 #endif
+NCX_PUTN(float, schar)
+NCX_PUTN(float, short)
+NCX_PUTN(float, int)
 NCX_PUTN(float, double)
-NCX_PUTN(float, uint)
 NCX_PUTN(float, longlong)
+NCX_PUTN(float, uchar)
+NCX_PUTN(float, ushort)
+NCX_PUTN(float, uint)
 NCX_PUTN(float, ulonglong)
 
-/* double */
+/* double --------------------------------------------------------------------*/
 
-NCX_GETN(double, schar)
-NCX_GETN(double, uchar)
-NCX_GETN(double, short)
-NCX_GETN(double, int)
-NCX_GETN(double, float)
-dnl NCX_GETN(double, double)
-NCX_GETN(double, uint)
-NCX_GETN(double, longlong)
-NCX_GETN(double, ulonglong)
 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
 /* optimized version */
 int
@@ -3041,18 +3141,17 @@ ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
 	*xpp = (const void *)xp;
 	return status;
 }
-
 #endif
+NCX_GETN(double, schar)
+NCX_GETN(double, short)
+NCX_GETN(double, int)
+NCX_GETN(double, float)
+NCX_GETN(double, longlong)
+NCX_GETN(double, uchar)
+NCX_GETN(double, ushort)
+NCX_GETN(double, uint)
+NCX_GETN(double, ulonglong)
 
-NCX_PUTN(double, schar)
-NCX_PUTN(double, uchar)
-NCX_PUTN(double, short)
-NCX_PUTN(double, int)
-NCX_PUTN(double, float)
-dnl NCX_PUTN(double, double)
-NCX_PUTN(double, uint)
-NCX_PUTN(double, longlong)
-NCX_PUTN(double, ulonglong)
 #if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
 /* optimized version */
 int
@@ -3098,8 +3197,125 @@ ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
 	*xpp = (void *)xp;
 	return status;
 }
+#endif
+NCX_PUTN(double, schar)
+NCX_PUTN(double, short)
+NCX_PUTN(double, int)
+NCX_PUTN(double, float)
+NCX_PUTN(double, longlong)
+NCX_PUTN(double, uchar)
+NCX_PUTN(double, ushort)
+NCX_PUTN(double, uint)
+NCX_PUTN(double, ulonglong)
 
+
+/* longlong -----------------------------------------------------------------------*/
+
+#if X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
+/* optimized version */
+int
+ncx_getn_longlong_longlong(const void **xpp, size_t nelems, long long *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(long long));
+# else
+	swapn8b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_LONGLONG);
+	return ENOERR;
+}
+#else
+NCX_GETN(longlong, longlong)
+#endif
+NCX_GETN(longlong, schar)
+NCX_GETN(longlong, short)
+NCX_GETN(longlong, int)
+NCX_GETN(longlong, float)
+NCX_GETN(longlong, double)
+NCX_GETN(longlong, uchar)
+NCX_GETN(longlong, ushort)
+NCX_GETN(longlong, uint)
+NCX_GETN(longlong, ulonglong)
+
+#if X_SIZEOF_LONGLONG == SIZEOF_LONGLONG
+/* optimized version */
+int
+ncx_putn_longlong_longlong(void **xpp, size_t nelems, const long long *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_LONGLONG);
+# else
+	swapn8b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_LONGLONG);
+	return ENOERR;
+}
+#else
+NCX_PUTN(longlong, longlong)
 #endif
+NCX_PUTN(longlong, schar)
+NCX_PUTN(longlong, short)
+NCX_PUTN(longlong, int)
+NCX_PUTN(longlong, float)
+NCX_PUTN(longlong, double)
+NCX_PUTN(longlong, uchar)
+NCX_PUTN(longlong, ushort)
+NCX_PUTN(longlong, uint)
+NCX_PUTN(longlong, ulonglong)
+
+/* ulonglong ----------------------------------------------------------------------*/
+
+#if X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
+/* optimized version */
+int
+ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, unsigned long long *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(tp, *xpp, nelems * sizeof(unsigned long long));
+# else
+	swapn8b(tp, *xpp, nelems);
+# endif
+	*xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_ULONGLONG);
+	return ENOERR;
+}
+#else
+NCX_GETN(ulonglong, ulonglong)
+#endif
+NCX_GETN(ulonglong, schar)
+NCX_GETN(ulonglong, short)
+NCX_GETN(ulonglong, int)
+NCX_GETN(ulonglong, float)
+NCX_GETN(ulonglong, double)
+NCX_GETN(ulonglong, longlong)
+NCX_GETN(ulonglong, uchar)
+NCX_GETN(ulonglong, ushort)
+NCX_GETN(ulonglong, uint)
+
+#if X_SIZEOF_ULONGLONG == SIZEOF_ULONGLONG
+/* optimized version */
+int
+ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const unsigned long long *tp)
+{
+#ifdef WORDS_BIGENDIAN
+	(void) memcpy(*xpp, tp, nelems * X_SIZEOF_ULONGLONG);
+# else
+	swapn8b(*xpp, tp, nelems);
+# endif
+	*xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_ULONGLONG);
+	return ENOERR;
+}
+#else
+NCX_PUTN(ulonglong, ulonglong)
+#endif
+NCX_PUTN(ulonglong, schar)
+NCX_PUTN(ulonglong, short)
+NCX_PUTN(ulonglong, int)
+NCX_PUTN(ulonglong, float)
+NCX_PUTN(ulonglong, double)
+NCX_PUTN(ulonglong, longlong)
+NCX_PUTN(ulonglong, uchar)
+NCX_PUTN(ulonglong, ushort)
+NCX_PUTN(ulonglong, uint)
 
 
 /*
diff --git a/libsrc/posixio.c b/libsrc/posixio.c
index cf24ad6..24b52c2 100644
--- a/libsrc/posixio.c
+++ b/libsrc/posixio.c
@@ -387,7 +387,7 @@ typedef struct ncio_px {
    offset - file offset for beginning of to region to be
    released.
 
-   rflags - only RGN_MODIFIED is relevent to this function, others ignored
+   rflags - only RGN_MODIFIED is relevant to this function, others ignored
 */
 static int
 px_rel(ncio_px *const pxp, off_t offset, int rflags)
@@ -420,7 +420,7 @@ px_rel(ncio_px *const pxp, off_t offset, int rflags)
    nciop - pointer to ncio struct.
    offset - num bytes from beginning of buffer to region to be
    released.
-   rflags - only RGN_MODIFIED is relevent to this function, others ignored
+   rflags - only RGN_MODIFIED is relevant to this function, others ignored
 */
 static int
 ncio_px_rel(ncio *const nciop, off_t offset, int rflags)
@@ -444,7 +444,7 @@ ncio_px_rel(ncio *const nciop, off_t offset, int rflags)
    offset - start byte of region to get.
    extent - how many bytes to read.
    rflags - One of the RGN_* flags defined in ncio.h.
-   vpp - pointer to pointer that will recieve data.
+   vpp - pointer to pointer that will receive data.
 
    NOTES:
 
@@ -1517,7 +1517,7 @@ ncio_px_new(const char *path, int ioflags)
 #define NC_DEFAULT_CREAT_MODE 0666
 #endif
 
-/* Create a file, and the ncio struct to go with it. This funtion is
+/* Create a file, and the ncio struct to go with it. This function is
    only called from nc__create_mp.
 
    path - path of file to create.
@@ -1696,7 +1696,7 @@ posixio_open(const char *path,
 		return ENOMEM;
 
 #ifdef O_BINARY
-	//#if _MSC_VER
+	/*#if _MSC_VER*/
 	fSet(oflags, O_BINARY);
 #endif
 
diff --git a/libsrc/pstdint.h b/libsrc/pstdint.h
index 6a334ba..c5b0ed5 100644
--- a/libsrc/pstdint.h
+++ b/libsrc/pstdint.h
@@ -73,7 +73,7 @@
  *       include stdint.h.  The hope is that one or the other can be
  *       used with no real difference.
  *
- *    5) In the current verison, if your platform can't represent
+ *    5) In the current version, if your platform can't represent
  *       int32_t, int16_t and int8_t, it just dumps out with a compiler
  *       error.
  *
diff --git a/libsrc/putget.c b/libsrc/putget.c
index b308d8e..b2485b0 100644
--- a/libsrc/putget.c
+++ b/libsrc/putget.c
@@ -3,7 +3,7 @@
  *	Copyright 1996, University Corporation for Atmospheric Research
  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
-/* $Id: putget.m4,v 2.79 2010/05/29 22:25:01 russ Exp $ */
+/* $Id: putget.m4 2783 2014-10-26 05:19:35Z wkliao $ */
 
 #include "config.h"
 #include <string.h>
@@ -225,6 +225,106 @@ NC_fill_double(
 }
 
 
+static int
+NC_fill_uchar(
+	void **xpp,
+	size_t nelems)	/* how many */
+{
+	uchar fillp[NFILL * sizeof(double)/X_SIZEOF_UBYTE];
+
+	assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
+
+	{
+		uchar *vp = fillp;	/* lower bound of area to be filled */
+		const uchar *const end = vp + nelems;
+		while(vp < end)
+		{
+			*vp++ = NC_FILL_UBYTE;
+		}
+	}
+	return ncx_putn_uchar_uchar(xpp, nelems, fillp);
+}
+
+static int
+NC_fill_ushort(
+	void **xpp,
+	size_t nelems)	/* how many */
+{
+	ushort fillp[NFILL * sizeof(double)/X_SIZEOF_USHORT];
+
+	assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
+
+	{
+		ushort *vp = fillp;	/* lower bound of area to be filled */
+		const ushort *const end = vp + nelems;
+		while(vp < end)
+		{
+			*vp++ = NC_FILL_USHORT;
+		}
+	}
+	return ncx_putn_ushort_ushort(xpp, nelems, fillp);
+}
+
+static int
+NC_fill_uint(
+	void **xpp,
+	size_t nelems)	/* how many */
+{
+	uint fillp[NFILL * sizeof(double)/X_SIZEOF_UINT];
+
+	assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
+
+	{
+		uint *vp = fillp;	/* lower bound of area to be filled */
+		const uint *const end = vp + nelems;
+		while(vp < end)
+		{
+			*vp++ = NC_FILL_UINT;
+		}
+	}
+	return ncx_putn_uint_uint(xpp, nelems, fillp);
+}
+
+static int
+NC_fill_longlong(
+	void **xpp,
+	size_t nelems)	/* how many */
+{
+	longlong fillp[NFILL * sizeof(double)/X_SIZEOF_LONGLONG];
+
+	assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
+
+	{
+		longlong *vp = fillp;	/* lower bound of area to be filled */
+		const longlong *const end = vp + nelems;
+		while(vp < end)
+		{
+			*vp++ = NC_FILL_INT64;
+		}
+	}
+	return ncx_putn_longlong_longlong(xpp, nelems, fillp);
+}
+
+static int
+NC_fill_ulonglong(
+	void **xpp,
+	size_t nelems)	/* how many */
+{
+	ulonglong fillp[NFILL * sizeof(double)/X_SIZEOF_ULONGLONG];
+
+	assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
+
+	{
+		ulonglong *vp = fillp;	/* lower bound of area to be filled */
+		const ulonglong *const end = vp + nelems;
+		while(vp < end)
+		{
+			*vp++ = NC_FILL_UINT64;
+		}
+	}
+	return ncx_putn_ulonglong_ulonglong(xpp, nelems, fillp);
+}
+
 
 
 
@@ -304,6 +404,21 @@ fill_NC_var(NC3_INFO* ncp, const NC_var *varp, size_t varsize, size_t recno)
 		case NC_DOUBLE :
 			status = NC_fill_double(&xp, nelems);
 			break;
+                case NC_UBYTE :
+                        status = NC_fill_uchar(&xp, nelems);
+                        break;
+                case NC_USHORT :
+                        status = NC_fill_ushort(&xp, nelems);
+                        break;
+                case NC_UINT :
+                        status = NC_fill_uint(&xp, nelems);
+                        break;
+                case NC_INT64 :
+                        status = NC_fill_longlong(&xp, nelems);
+                        break;
+                case NC_UINT64 :
+                        status = NC_fill_ulonglong(&xp, nelems);
+                        break;
 		default :
 			assert("fill_NC_var invalid type" == 0);
 			status = NC_EBADTYPE;
@@ -473,7 +588,7 @@ NCtouchlast(NC3_INFO* ncp, const NC_var *const *varpp, size_t recno)
 
 /*
  * Ensure that the netcdf file has 'numrecs' records,
- * add records and fill as neccessary.
+ * add records and fill as necessary.
  */
 static int
 NCvnrecs(NC3_INFO* ncp, size_t numrecs)
@@ -1103,10 +1218,9 @@ putNCvx_schar_longlong(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const schar *value)
+putNCvx_schar_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1128,7 +1242,7 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_schar(&xp, nput, value);
+		lstatus = ncx_putn_schar_ushort(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1150,8 +1264,8 @@ putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uchar *value)
+putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1173,7 +1287,7 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_uchar(&xp, nput, value);
+		lstatus = ncx_putn_schar_uint(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1195,8 +1309,8 @@ putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const short *value)
+putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1218,7 +1332,7 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_short(&xp, nput, value);
+		lstatus = ncx_putn_schar_ulonglong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1239,9 +1353,10 @@ putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const int *value)
+putNCvx_short_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1263,7 +1378,7 @@ putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_int(&xp, nput, value);
+		lstatus = ncx_putn_short_schar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1285,8 +1400,8 @@ putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const float *value)
+putNCvx_short_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1308,7 +1423,7 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_float(&xp, nput, value);
+		lstatus = ncx_putn_short_uchar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1330,8 +1445,8 @@ putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const double *value)
+putNCvx_short_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1353,7 +1468,7 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_double(&xp, nput, value);
+		lstatus = ncx_putn_short_short(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1375,8 +1490,8 @@ putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const longlong *value)
+putNCvx_short_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1398,7 +1513,7 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_longlong(&xp, nput, value);
+		lstatus = ncx_putn_short_int(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1419,10 +1534,9 @@ putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const schar *value)
+putNCvx_short_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1444,7 +1558,7 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_schar(&xp, nput, value);
+		lstatus = ncx_putn_short_float(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1466,8 +1580,8 @@ putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uchar *value)
+putNCvx_short_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1489,7 +1603,7 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_uchar(&xp, nput, value);
+		lstatus = ncx_putn_short_double(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1511,8 +1625,8 @@ putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const short *value)
+putNCvx_short_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1534,7 +1648,7 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_short(&xp, nput, value);
+		lstatus = ncx_putn_short_longlong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1556,8 +1670,8 @@ putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const int *value)
+putNCvx_short_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1579,7 +1693,7 @@ putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_int(&xp, nput, value);
+		lstatus = ncx_putn_short_ushort(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1601,8 +1715,8 @@ putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const float *value)
+putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1624,7 +1738,7 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_float(&xp, nput, value);
+		lstatus = ncx_putn_short_uint(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1646,8 +1760,8 @@ putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const double *value)
+putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1669,7 +1783,7 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_double(&xp, nput, value);
+		lstatus = ncx_putn_short_ulonglong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1690,9 +1804,10 @@ putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const longlong *value)
+putNCvx_int_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1714,7 +1829,7 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_longlong(&xp, nput, value);
+		lstatus = ncx_putn_int_schar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1735,10 +1850,9 @@ putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const schar *value)
+putNCvx_int_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1760,7 +1874,7 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_schar(&xp, nput, value);
+		lstatus = ncx_putn_int_uchar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1782,8 +1896,8 @@ putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uchar *value)
+putNCvx_int_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1805,7 +1919,7 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_uchar(&xp, nput, value);
+		lstatus = ncx_putn_int_short(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1827,8 +1941,8 @@ putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const short *value)
+putNCvx_int_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1850,7 +1964,7 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_short(&xp, nput, value);
+		lstatus = ncx_putn_int_int(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1872,8 +1986,8 @@ putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const int *value)
+putNCvx_int_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1895,7 +2009,7 @@ putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_int(&xp, nput, value);
+		lstatus = ncx_putn_int_float(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1917,8 +2031,8 @@ putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const float *value)
+putNCvx_int_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1940,7 +2054,7 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_float(&xp, nput, value);
+		lstatus = ncx_putn_int_double(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -1962,8 +2076,8 @@ putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const double *value)
+putNCvx_int_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -1985,7 +2099,7 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_double(&xp, nput, value);
+		lstatus = ncx_putn_int_longlong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2007,8 +2121,8 @@ putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const longlong *value)
+putNCvx_int_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2030,7 +2144,7 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_longlong(&xp, nput, value);
+		lstatus = ncx_putn_int_ushort(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2051,10 +2165,9 @@ putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const schar *value)
+putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2076,7 +2189,7 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_schar(&xp, nput, value);
+		lstatus = ncx_putn_int_uint(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2098,8 +2211,8 @@ putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uchar *value)
+putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2121,7 +2234,7 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_uchar(&xp, nput, value);
+		lstatus = ncx_putn_int_ulonglong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2142,9 +2255,10 @@ putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const short *value)
+putNCvx_float_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2166,7 +2280,7 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_short(&xp, nput, value);
+		lstatus = ncx_putn_float_schar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2188,8 +2302,8 @@ putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const int *value)
+putNCvx_float_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2211,7 +2325,7 @@ putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_int(&xp, nput, value);
+		lstatus = ncx_putn_float_uchar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2233,8 +2347,8 @@ putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const float *value)
+putNCvx_float_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2256,7 +2370,7 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_float(&xp, nput, value);
+		lstatus = ncx_putn_float_short(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2278,8 +2392,8 @@ putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const double *value)
+putNCvx_float_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2301,7 +2415,7 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_double(&xp, nput, value);
+		lstatus = ncx_putn_float_int(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2323,8 +2437,8 @@ putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const longlong *value)
+putNCvx_float_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2346,7 +2460,7 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_longlong(&xp, nput, value);
+		lstatus = ncx_putn_float_float(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2367,11 +2481,9 @@ putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
-#ifdef NOTUSED
 static int
-putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uint *value)
+putNCvx_float_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2393,7 +2505,7 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_schar_uint(&xp, nput, value);
+		lstatus = ncx_putn_float_double(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2415,8 +2527,8 @@ putNCvx_schar_uint(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const ulonglong *value)
+putNCvx_float_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2438,7 +2550,7 @@ putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_schar_ulonglong(&xp, nput, value);
+		lstatus = ncx_putn_float_longlong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2460,8 +2572,8 @@ putNCvx_schar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uint *value)
+putNCvx_float_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2483,7 +2595,7 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_uint(&xp, nput, value);
+		lstatus = ncx_putn_float_ushort(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2505,9 +2617,9 @@ putNCvx_short_uint(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const ulonglong *value)
-{
+putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
 	int status = NC_NOERR;
@@ -2528,7 +2640,7 @@ putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_short_ulonglong(&xp, nput, value);
+		lstatus = ncx_putn_float_uint(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2550,8 +2662,8 @@ putNCvx_short_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uint *value)
+putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2573,7 +2685,7 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_uint(&xp, nput, value);
+		lstatus = ncx_putn_float_ulonglong(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2594,9 +2706,10 @@ putNCvx_int_uint(NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const ulonglong *value)
+putNCvx_double_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2618,7 +2731,7 @@ putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_int_ulonglong(&xp, nput, value);
+		lstatus = ncx_putn_double_schar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2640,8 +2753,8 @@ putNCvx_int_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uint *value)
+putNCvx_double_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2663,7 +2776,7 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_uint(&xp, nput, value);
+		lstatus = ncx_putn_double_uchar(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
@@ -2685,8 +2798,8 @@ putNCvx_float_uint(NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const ulonglong *value)
+putNCvx_double_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2708,35 +2821,4773 @@ putNCvx_float_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_float_ulonglong(&xp, nput, value);
+		lstatus = ncx_putn_double_short(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_int(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_float(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_double(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_longlong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_ushort(&xp, nput, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 		{
 			/* not fatal to the loop */
 			status = lstatus;
-		}
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_uint(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_double_ulonglong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+
+static int
+putNCvx_uchar_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_schar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_uchar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_short(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_int(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_float(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_double(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_longlong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_ushort(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_uint(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uchar_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uchar_ulonglong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+
+static int
+putNCvx_ushort_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_schar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_uchar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_short(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_int(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_float(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_double(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_longlong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_ushort(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_uint(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ushort_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ushort_ulonglong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+
+static int
+putNCvx_uint_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_schar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_uchar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_short(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_int(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_float(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_double(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_longlong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_ushort(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_uint(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_uint_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_uint_ulonglong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+
+static int
+putNCvx_longlong_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_schar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_uchar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_short(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_int(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_float(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_double(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_longlong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_ushort(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_uint(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_longlong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_longlong_ulonglong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+
+static int
+putNCvx_ulonglong_schar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_schar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_uchar(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_uchar(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_short(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_short(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_int(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_int(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_float(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_float(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_double(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_double(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_longlong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_longlong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_ushort(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_ushort(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_uint(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_uint(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+static int
+putNCvx_ulonglong_ulonglong(NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, const ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nput = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 RGN_WRITE, &xp);
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_putn_ulonglong_ulonglong(&xp, nput, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+		{
+			/* not fatal to the loop */
+			status = lstatus;
+		}
+
+		(void) ncio_rel(ncp->nciop, offset,
+				 RGN_MODIFIED);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nput;
+
+	}
+
+	return status;
+}
+
+
+
+static int
+getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, char *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_char_char(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+
+static int
+getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_schar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_short(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_int(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_float(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_double(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_longlong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_uint(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_ulonglong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_uchar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_schar_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_schar_ushort(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+
+static int
+getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_schar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_uchar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_short(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_int(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_float(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_double(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_longlong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_uint(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_ulonglong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_short_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_short_ushort(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+
+static int
+getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_schar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_uchar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_short(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_int(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_float(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_double(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_longlong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_uint(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_ulonglong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_int_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_int_ushort(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+
+static int
+getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_schar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_uchar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_short(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_int(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_float(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_double(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_longlong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_uint(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_ulonglong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_float_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_float_ushort(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+
+static int
+getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_schar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_uchar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_short(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_int(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_float(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_double(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_longlong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_uint(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_ulonglong(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_double_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_double_ushort(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+
+static int
+getNCvx_uchar_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_uchar_schar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_uchar_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_uchar_uchar(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
+
+		(void) ncio_rel(ncp->nciop, offset, 0);
+
+		remaining -= extent;
+		if(remaining == 0)
+			break; /* normal loop exit */
+		offset += extent;
+		value += nget;
+	}
+
+	return status;
+}
+
+static int
+getNCvx_uchar_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
+{
+	off_t offset = NC_varoffset(ncp, varp, start);
+	size_t remaining = varp->xsz * nelems;
+	int status = NC_NOERR;
+	const void *xp;
+
+	if(nelems == 0)
+		return NC_NOERR;
+
+	assert(value != NULL);
+
+	for(;;)
+	{
+		size_t extent = MIN(remaining, ncp->chunk);
+		size_t nget = ncx_howmany(varp->type, extent);
+
+		int lstatus = ncio_get(ncp->nciop, offset, extent,
+				 0, (void **)&xp);	/* cast away const */
+		if(lstatus != NC_NOERR)
+			return lstatus;
+
+		lstatus = ncx_getn_uchar_short(&xp, nget, value);
+		if(lstatus != NC_NOERR && status == NC_NOERR)
+			status = lstatus;
 
-		(void) ncio_rel(ncp->nciop, offset,
-				 RGN_MODIFIED);
+		(void) ncio_rel(ncp->nciop, offset, 0);
 
 		remaining -= extent;
 		if(remaining == 0)
 			break; /* normal loop exit */
 		offset += extent;
-		value += nput;
-
+		value += nget;
 	}
 
 	return status;
 }
 
 static int
-putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const uint *value)
+getNCvx_uchar_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
 	int status = NC_NOERR;
-	void *xp;
+	const void *xp;
 
 	if(nelems == 0)
 		return NC_NOERR;
@@ -2746,42 +7597,37 @@ putNCvx_double_uint(NC3_INFO* ncp, const NC_var *varp,
 	for(;;)
 	{
 		size_t extent = MIN(remaining, ncp->chunk);
-		size_t nput = ncx_howmany(varp->type, extent);
+		size_t nget = ncx_howmany(varp->type, extent);
 
 		int lstatus = ncio_get(ncp->nciop, offset, extent,
-				 RGN_WRITE, &xp);
+				 0, (void **)&xp);	/* cast away const */
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_uint(&xp, nput, value);
+		lstatus = ncx_getn_uchar_int(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
-		{
-			/* not fatal to the loop */
 			status = lstatus;
-		}
 
-		(void) ncio_rel(ncp->nciop, offset,
-				 RGN_MODIFIED);
+		(void) ncio_rel(ncp->nciop, offset, 0);
 
 		remaining -= extent;
 		if(remaining == 0)
 			break; /* normal loop exit */
 		offset += extent;
-		value += nput;
-
+		value += nget;
 	}
 
 	return status;
 }
 
 static int
-putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, const ulonglong *value)
+getNCvx_uchar_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
 	int status = NC_NOERR;
-	void *xp;
+	const void *xp;
 
 	if(nelems == 0)
 		return NC_NOERR;
@@ -2791,40 +7637,32 @@ putNCvx_double_ulonglong(NC3_INFO* ncp, const NC_var *varp,
 	for(;;)
 	{
 		size_t extent = MIN(remaining, ncp->chunk);
-		size_t nput = ncx_howmany(varp->type, extent);
+		size_t nget = ncx_howmany(varp->type, extent);
 
 		int lstatus = ncio_get(ncp->nciop, offset, extent,
-				 RGN_WRITE, &xp);
+				 0, (void **)&xp);	/* cast away const */
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_putn_double_ulonglong(&xp, nput, value);
+		lstatus = ncx_getn_uchar_float(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
-		{
-			/* not fatal to the loop */
 			status = lstatus;
-		}
 
-		(void) ncio_rel(ncp->nciop, offset,
-				 RGN_MODIFIED);
+		(void) ncio_rel(ncp->nciop, offset, 0);
 
 		remaining -= extent;
 		if(remaining == 0)
 			break; /* normal loop exit */
 		offset += extent;
-		value += nput;
-
+		value += nget;
 	}
 
 	return status;
 }
 
-#endif /*NOTUSED*/
-
-
 static int
-getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, char *value)
+getNCvx_uchar_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2846,7 +7684,7 @@ getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_char_char(&xp, nget, value);
+		lstatus = ncx_getn_uchar_double(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -2862,10 +7700,9 @@ getNCvx_char_char(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, schar *value)
+getNCvx_uchar_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2887,7 +7724,7 @@ getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_schar(&xp, nget, value);
+		lstatus = ncx_getn_uchar_longlong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -2904,8 +7741,8 @@ getNCvx_schar_schar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, short *value)
+getNCvx_uchar_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2927,7 +7764,7 @@ getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_short(&xp, nget, value);
+		lstatus = ncx_getn_uchar_uint(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -2944,8 +7781,8 @@ getNCvx_schar_short(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, int *value)
+getNCvx_uchar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -2967,7 +7804,7 @@ getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_int(&xp, nget, value);
+		lstatus = ncx_getn_uchar_ulonglong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -2984,8 +7821,8 @@ getNCvx_schar_int(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, float *value)
+getNCvx_uchar_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3007,7 +7844,7 @@ getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_float(&xp, nget, value);
+		lstatus = ncx_getn_uchar_ushort(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3023,9 +7860,10 @@ getNCvx_schar_float(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, double *value)
+getNCvx_ushort_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3047,7 +7885,7 @@ getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_double(&xp, nget, value);
+		lstatus = ncx_getn_ushort_schar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3064,8 +7902,8 @@ getNCvx_schar_double(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, longlong *value)
+getNCvx_ushort_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3087,7 +7925,7 @@ getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_longlong(&xp, nget, value);
+		lstatus = ncx_getn_ushort_uchar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3104,8 +7942,8 @@ getNCvx_schar_longlong(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uint *value)
+getNCvx_ushort_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3127,7 +7965,7 @@ getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_uint(&xp, nget, value);
+		lstatus = ncx_getn_ushort_short(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3144,8 +7982,8 @@ getNCvx_schar_uint(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, ulonglong *value)
+getNCvx_ushort_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3167,7 +8005,7 @@ getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_schar_ulonglong(&xp, nget, value);
+		lstatus = ncx_getn_ushort_int(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3183,10 +8021,9 @@ getNCvx_schar_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, schar *value)
+getNCvx_ushort_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3208,7 +8045,7 @@ getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_schar(&xp, nget, value);
+		lstatus = ncx_getn_ushort_float(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3225,8 +8062,8 @@ getNCvx_short_schar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uchar *value)
+getNCvx_ushort_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3248,7 +8085,7 @@ getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_uchar(&xp, nget, value);
+		lstatus = ncx_getn_ushort_double(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3265,8 +8102,8 @@ getNCvx_short_uchar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, short *value)
+getNCvx_ushort_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3288,7 +8125,7 @@ getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_short(&xp, nget, value);
+		lstatus = ncx_getn_ushort_longlong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3305,8 +8142,8 @@ getNCvx_short_short(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, int *value)
+getNCvx_ushort_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3328,7 +8165,7 @@ getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_int(&xp, nget, value);
+		lstatus = ncx_getn_ushort_uint(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3345,8 +8182,8 @@ getNCvx_short_int(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, float *value)
+getNCvx_ushort_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3368,7 +8205,7 @@ getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_float(&xp, nget, value);
+		lstatus = ncx_getn_ushort_ulonglong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3385,8 +8222,8 @@ getNCvx_short_float(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, double *value)
+getNCvx_ushort_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3408,7 +8245,7 @@ getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_double(&xp, nget, value);
+		lstatus = ncx_getn_ushort_ushort(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3424,9 +8261,10 @@ getNCvx_short_double(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, longlong *value)
+getNCvx_uint_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3448,7 +8286,7 @@ getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_longlong(&xp, nget, value);
+		lstatus = ncx_getn_uint_schar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3465,8 +8303,8 @@ getNCvx_short_longlong(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uint *value)
+getNCvx_uint_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3488,7 +8326,7 @@ getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_uint(&xp, nget, value);
+		lstatus = ncx_getn_uint_uchar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3505,8 +8343,8 @@ getNCvx_short_uint(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, ulonglong *value)
+getNCvx_uint_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3528,7 +8366,7 @@ getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_short_ulonglong(&xp, nget, value);
+		lstatus = ncx_getn_uint_short(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3544,10 +8382,9 @@ getNCvx_short_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, schar *value)
+getNCvx_uint_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3569,7 +8406,7 @@ getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_schar(&xp, nget, value);
+		lstatus = ncx_getn_uint_int(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3586,8 +8423,8 @@ getNCvx_int_schar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uchar *value)
+getNCvx_uint_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3609,7 +8446,7 @@ getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_uchar(&xp, nget, value);
+		lstatus = ncx_getn_uint_float(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3626,8 +8463,8 @@ getNCvx_int_uchar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, short *value)
+getNCvx_uint_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3649,7 +8486,7 @@ getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_short(&xp, nget, value);
+		lstatus = ncx_getn_uint_double(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3666,8 +8503,8 @@ getNCvx_int_short(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, int *value)
+getNCvx_uint_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3689,7 +8526,7 @@ getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_int(&xp, nget, value);
+		lstatus = ncx_getn_uint_longlong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3706,8 +8543,8 @@ getNCvx_int_int(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, float *value)
+getNCvx_uint_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3729,7 +8566,7 @@ getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_float(&xp, nget, value);
+		lstatus = ncx_getn_uint_uint(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3746,8 +8583,8 @@ getNCvx_int_float(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, double *value)
+getNCvx_uint_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3769,7 +8606,7 @@ getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_double(&xp, nget, value);
+		lstatus = ncx_getn_uint_ulonglong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3786,8 +8623,8 @@ getNCvx_int_double(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, longlong *value)
+getNCvx_uint_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3809,7 +8646,7 @@ getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_longlong(&xp, nget, value);
+		lstatus = ncx_getn_uint_ushort(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3825,9 +8662,10 @@ getNCvx_int_longlong(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uint *value)
+getNCvx_longlong_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3849,7 +8687,7 @@ getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_uint(&xp, nget, value);
+		lstatus = ncx_getn_longlong_schar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3866,8 +8704,8 @@ getNCvx_int_uint(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, ulonglong *value)
+getNCvx_longlong_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3889,7 +8727,7 @@ getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_int_ulonglong(&xp, nget, value);
+		lstatus = ncx_getn_longlong_uchar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3905,10 +8743,9 @@ getNCvx_int_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, schar *value)
+getNCvx_longlong_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3930,7 +8767,7 @@ getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_schar(&xp, nget, value);
+		lstatus = ncx_getn_longlong_short(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3947,8 +8784,8 @@ getNCvx_float_schar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uchar *value)
+getNCvx_longlong_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -3970,7 +8807,7 @@ getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_uchar(&xp, nget, value);
+		lstatus = ncx_getn_longlong_int(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -3987,8 +8824,8 @@ getNCvx_float_uchar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, short *value)
+getNCvx_longlong_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4010,7 +8847,7 @@ getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_short(&xp, nget, value);
+		lstatus = ncx_getn_longlong_float(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4027,8 +8864,8 @@ getNCvx_float_short(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, int *value)
+getNCvx_longlong_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4050,7 +8887,7 @@ getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_int(&xp, nget, value);
+		lstatus = ncx_getn_longlong_double(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4067,8 +8904,8 @@ getNCvx_float_int(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, float *value)
+getNCvx_longlong_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4090,7 +8927,7 @@ getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_float(&xp, nget, value);
+		lstatus = ncx_getn_longlong_longlong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4107,8 +8944,8 @@ getNCvx_float_float(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, double *value)
+getNCvx_longlong_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4130,7 +8967,7 @@ getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_double(&xp, nget, value);
+		lstatus = ncx_getn_longlong_uint(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4147,8 +8984,8 @@ getNCvx_float_double(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, longlong *value)
+getNCvx_longlong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4170,7 +9007,7 @@ getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_longlong(&xp, nget, value);
+		lstatus = ncx_getn_longlong_ulonglong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4187,8 +9024,8 @@ getNCvx_float_longlong(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uint *value)
+getNCvx_longlong_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4210,7 +9047,7 @@ getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_uint(&xp, nget, value);
+		lstatus = ncx_getn_longlong_ushort(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4226,9 +9063,10 @@ getNCvx_float_uint(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
+
 static int
-getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, ulonglong *value)
+getNCvx_ulonglong_schar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, schar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4250,7 +9088,7 @@ getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_float_ulonglong(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_schar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4266,10 +9104,9 @@ getNCvx_float_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 	return status;
 }
 
-
 static int
-getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, schar *value)
+getNCvx_ulonglong_uchar(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uchar *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4291,7 +9128,7 @@ getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_schar(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_uchar(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4308,8 +9145,8 @@ getNCvx_double_schar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uchar *value)
+getNCvx_ulonglong_short(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, short *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4331,7 +9168,7 @@ getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_uchar(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_short(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4348,8 +9185,8 @@ getNCvx_double_uchar(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, short *value)
+getNCvx_ulonglong_int(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, int *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4371,7 +9208,7 @@ getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_short(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_int(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4388,8 +9225,8 @@ getNCvx_double_short(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, int *value)
+getNCvx_ulonglong_float(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, float *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4411,7 +9248,7 @@ getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_int(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_float(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4428,8 +9265,8 @@ getNCvx_double_int(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, float *value)
+getNCvx_ulonglong_double(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, double *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4451,7 +9288,7 @@ getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_float(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_double(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4468,8 +9305,8 @@ getNCvx_double_float(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, double *value)
+getNCvx_ulonglong_longlong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, longlong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4491,7 +9328,7 @@ getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_double(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_longlong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4508,8 +9345,8 @@ getNCvx_double_double(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, longlong *value)
+getNCvx_ulonglong_uint(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, uint *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4531,7 +9368,7 @@ getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_longlong(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_uint(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4548,8 +9385,8 @@ getNCvx_double_longlong(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, uint *value)
+getNCvx_ulonglong_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ulonglong *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4571,7 +9408,7 @@ getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_uint(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_ulonglong(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4588,8 +9425,8 @@ getNCvx_double_uint(const NC3_INFO* ncp, const NC_var *varp,
 }
 
 static int
-getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
-		 const size_t *start, size_t nelems, ulonglong *value)
+getNCvx_ulonglong_ushort(const NC3_INFO* ncp, const NC_var *varp,
+		 const size_t *start, size_t nelems, ushort *value)
 {
 	off_t offset = NC_varoffset(ncp, varp, start);
 	size_t remaining = varp->xsz * nelems;
@@ -4611,7 +9448,7 @@ getNCvx_double_ulonglong(const NC3_INFO* ncp, const NC_var *varp,
 		if(lstatus != NC_NOERR)
 			return lstatus;
 
-		lstatus = ncx_getn_double_ulonglong(&xp, nget, value);
+		lstatus = ncx_getn_ulonglong_ushort(&xp, nget, value);
 		if(lstatus != NC_NOERR && status == NC_NOERR)
 			status = lstatus;
 
@@ -4824,154 +9661,323 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
 {
     int status = NC_NOERR;
     switch (CASE(varp->type,memtype)) {
+
     case CASE(NC_CHAR,NC_CHAR):
     case CASE(NC_CHAR,NC_UBYTE):
-        status = getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
-        break;
-
+        return getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
+	break;
     case CASE(NC_BYTE,NC_BYTE):
+        return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_BYTE,NC_UBYTE):
-        status = getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_BYTE,NC_SHORT):
-        status = getNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_BYTE,NC_INT):
-        status = getNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_BYTE,NC_FLOAT):
-        status = getNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_BYTE,NC_DOUBLE):
-        status = getNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
-        break;
+        return getNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
+	break;
     case CASE(NC_BYTE,NC_INT64):
-        status = getNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_BYTE,NC_UINT):
-        status = getNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_BYTE,NC_UINT64):
-        status = getNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+    	break;
+    case CASE(NC_BYTE,NC_USHORT):
+        return getNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_SHORT,NC_BYTE):
-        status = getNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_SHORT,NC_UBYTE):
-        status = getNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_SHORT,NC_SHORT):
-        status = getNCvx_short_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_short_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_SHORT,NC_INT):
-        status = getNCvx_short_int(ncp,varp,start,nelems,(int*)value);
-        break;
-    case CASE(NC_SHORT,NC_FLOAT):
-        status = getNCvx_short_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_short_int(ncp,varp,start,nelems,(int*)value);
+	break; 
+   case CASE(NC_SHORT,NC_FLOAT):
+        return getNCvx_short_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_SHORT,NC_DOUBLE):
-        status = getNCvx_short_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_short_double(ncp,varp,start,nelems,(double*)value);
+	break;	
     case CASE(NC_SHORT,NC_INT64):
-        status = getNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
+   	break;
     case CASE(NC_SHORT,NC_UINT):
-        status = getNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
+    	break;
     case CASE(NC_SHORT,NC_UINT64):
-        status = getNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_SHORT,NC_USHORT):
+        return getNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     case CASE(NC_INT,NC_BYTE):
-        status = getNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_INT,NC_UBYTE):
-        status = getNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_INT,NC_SHORT):
-        status = getNCvx_int_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_int_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_INT,NC_INT):
-        status = getNCvx_int_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_int_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_INT,NC_FLOAT):
-        status = getNCvx_int_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_int_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_INT,NC_DOUBLE):
-        status = getNCvx_int_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_int_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_INT,NC_INT64):
-        status = getNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_INT,NC_UINT):
-        status = getNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_INT,NC_UINT64):
-        status = getNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT,NC_USHORT):
+        return getNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     case CASE(NC_FLOAT,NC_BYTE):
-        status = getNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_FLOAT,NC_UBYTE):
-        status = getNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_FLOAT,NC_SHORT):
-        status = getNCvx_float_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_float_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT):
-        status = getNCvx_float_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_float_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_FLOAT,NC_FLOAT):
-        status = getNCvx_float_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_float_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_FLOAT,NC_DOUBLE):
-        status = getNCvx_float_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_float_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT64):
-        status = getNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_FLOAT,NC_UINT):
-        status = getNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_FLOAT,NC_UINT64):
-        status = getNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_FLOAT,NC_USHORT):
+        return getNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     case CASE(NC_DOUBLE,NC_BYTE):
-        status = getNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UBYTE):
-        status = getNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_SHORT):
-        status = getNCvx_double_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_double_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT):
-        status = getNCvx_double_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_double_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_DOUBLE,NC_FLOAT):
-        status = getNCvx_double_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_double_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_DOUBLE,NC_DOUBLE):
-        status = getNCvx_double_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_double_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT64):
-        status = getNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UINT):
-        status = getNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UINT64):
-        status = getNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
+        return getNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_USHORT):
+        return getNCvx_double_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_UBYTE,NC_UBYTE):
+        return getNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_BYTE):
+        return getNCvx_uchar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_SHORT):
+        return getNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT):
+        return getNCvx_uchar_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_FLOAT):
+        return getNCvx_uchar_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UBYTE,NC_DOUBLE):
+        return getNCvx_uchar_double(ncp,varp,start,nelems,(double *)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT64):
+        return getNCvx_uchar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT):
+        return getNCvx_uchar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT64):
+        return getNCvx_uchar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_USHORT):
+        return getNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_USHORT,NC_BYTE):
+        return getNCvx_ushort_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_USHORT,NC_UBYTE):
+        return getNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_USHORT,NC_SHORT):
+        return getNCvx_ushort_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT):
+        return getNCvx_ushort_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_USHORT,NC_FLOAT):
+        return getNCvx_ushort_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_USHORT,NC_DOUBLE):
+        return getNCvx_ushort_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT64):
+        return getNCvx_ushort_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT):
+        return getNCvx_ushort_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT64):
+        return getNCvx_ushort_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_USHORT):
+        return getNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_UINT,NC_BYTE):
+        return getNCvx_uint_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT,NC_UBYTE):
+        return getNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT,NC_SHORT):
+        return getNCvx_uint_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT,NC_INT):
+        return getNCvx_uint_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT,NC_FLOAT):
+        return getNCvx_uint_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT,NC_DOUBLE):
+        return getNCvx_uint_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT,NC_INT64):
+        return getNCvx_uint_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT):
+        return getNCvx_uint_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT64):
+        return getNCvx_uint_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT,NC_USHORT):
+        return getNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_INT64,NC_BYTE):
+        return getNCvx_longlong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_INT64,NC_UBYTE):
+        return getNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_INT64,NC_SHORT):
+        return getNCvx_longlong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_INT64,NC_INT):
+        return getNCvx_longlong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_INT64,NC_FLOAT):
+        return getNCvx_longlong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_INT64,NC_DOUBLE):
+        return getNCvx_longlong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_INT64,NC_INT64):
+        return getNCvx_longlong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT):
+        return getNCvx_longlong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT64):
+        return getNCvx_longlong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT64,NC_USHORT):
+        return getNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_UINT64,NC_BYTE):
+        return getNCvx_ulonglong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT64,NC_UBYTE):
+        return getNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT64,NC_SHORT):
+        return getNCvx_ulonglong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT):
+        return getNCvx_ulonglong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT64,NC_FLOAT):
+        return getNCvx_ulonglong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT64,NC_DOUBLE):
+        return getNCvx_ulonglong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT64):
+        return getNCvx_ulonglong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT):
+        return getNCvx_ulonglong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT64):
+        return getNCvx_ulonglong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_USHORT):
+        return getNCvx_ulonglong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     default:
 	return NC_EBADTYPE;
+	break;
     }
     return status;
 }
@@ -4983,123 +9989,315 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
 {
     int status = NC_NOERR;
     switch (CASE(varp->type,memtype)) {
+
     case CASE(NC_CHAR,NC_CHAR):
     case CASE(NC_CHAR,NC_UBYTE):
-        status = putNCvx_char_char(ncp,varp,start,nelems,(char*)value);
-        break;
-
+        return putNCvx_char_char(ncp,varp,start,nelems,(char*)value);
+	break;
     case CASE(NC_BYTE,NC_BYTE):
-        status = putNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_BYTE,NC_UBYTE):
-        status = putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_BYTE,NC_SHORT):
-        status = putNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_BYTE,NC_INT):
-        status = putNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_BYTE,NC_FLOAT):
-        status = putNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_BYTE,NC_DOUBLE):
-        status = putNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
-        break;
+        return putNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
+	break;
     case CASE(NC_BYTE,NC_INT64):
-        status = putNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_BYTE,NC_UINT):
+        return putNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_BYTE,NC_UINT64):
+        return putNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_BYTE,NC_USHORT):
+        return putNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_SHORT,NC_BYTE):
-        status = putNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_SHORT,NC_UBYTE):
-        status = putNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_SHORT,NC_SHORT):
-        status = putNCvx_short_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_short_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_SHORT,NC_INT):
-        status = putNCvx_short_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_short_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_SHORT,NC_FLOAT):
-        status = putNCvx_short_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_short_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_SHORT,NC_DOUBLE):
-        status = putNCvx_short_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_short_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_SHORT,NC_INT64):
-        status = putNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_SHORT,NC_UINT):
+        return putNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_SHORT,NC_UINT64):
+        return putNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_SHORT,NC_USHORT):
+        return putNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_INT,NC_BYTE):
-        status = putNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_INT,NC_UBYTE):
-        status = putNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_INT,NC_SHORT):
-        status = putNCvx_int_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_int_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_INT,NC_INT):
-        status = putNCvx_int_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_int_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_INT,NC_FLOAT):
-        status = putNCvx_int_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_int_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_INT,NC_DOUBLE):
-        status = putNCvx_int_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_int_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_INT,NC_INT64):
-        status = putNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_INT,NC_UINT):
+        return putNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_INT,NC_UINT64):
+        return putNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT,NC_USHORT):
+        return putNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_FLOAT,NC_BYTE):
-        status = putNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_FLOAT,NC_UBYTE):
-        status = putNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_FLOAT,NC_SHORT):
-        status = putNCvx_float_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_float_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT):
-        status = putNCvx_float_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_float_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_FLOAT,NC_FLOAT):
-        status = putNCvx_float_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_float_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_FLOAT,NC_DOUBLE):
-        status = putNCvx_float_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_float_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT64):
-        status = putNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_FLOAT,NC_UINT):
+        return putNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_FLOAT,NC_UINT64):
+        return putNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_FLOAT,NC_USHORT):
+        return putNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_DOUBLE,NC_BYTE):
-        status = putNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UBYTE):
-        status = putNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_SHORT):
-        status = putNCvx_double_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_double_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT):
-        status = putNCvx_double_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_double_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_DOUBLE,NC_FLOAT):
-        status = putNCvx_double_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_double_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_DOUBLE,NC_DOUBLE):
-        status = putNCvx_double_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_double_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT64):
-        status = putNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return putNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_UINT):
+        return putNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_UINT64):
+        return putNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_USHORT):
+        return putNCvx_double_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UBYTE):
+        return putNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_BYTE):
+        return putNCvx_uchar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_SHORT):
+        return putNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT):
+        return putNCvx_uchar_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_FLOAT):
+        return putNCvx_uchar_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UBYTE,NC_DOUBLE):
+        return putNCvx_uchar_double(ncp,varp,start,nelems,(double *)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT64):
+        return putNCvx_uchar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT):
+        return putNCvx_uchar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT64):
+        return putNCvx_uchar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_USHORT):
+        return putNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_USHORT,NC_BYTE):
+        return putNCvx_ushort_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_USHORT,NC_UBYTE):
+        return putNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_USHORT,NC_SHORT):
+        return putNCvx_ushort_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT):
+        return putNCvx_ushort_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_USHORT,NC_FLOAT):
+        return putNCvx_ushort_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_USHORT,NC_DOUBLE):
+        return putNCvx_ushort_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT64):
+        return putNCvx_ushort_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT):
+        return putNCvx_ushort_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT64):
+        return putNCvx_ushort_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_USHORT):
+        return putNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_UINT,NC_BYTE):
+        return putNCvx_uint_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT,NC_UBYTE):
+        return putNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT,NC_SHORT):
+        return putNCvx_uint_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT,NC_INT):
+        return putNCvx_uint_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT,NC_FLOAT):
+        return putNCvx_uint_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT,NC_DOUBLE):
+        return putNCvx_uint_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT,NC_INT64):
+        return putNCvx_uint_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT):
+        return putNCvx_uint_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT64):
+        return putNCvx_uint_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT,NC_USHORT):
+        return putNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_INT64,NC_BYTE):
+        return putNCvx_longlong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_INT64,NC_UBYTE):
+        return putNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_INT64,NC_SHORT):
+        return putNCvx_longlong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_INT64,NC_INT):
+        return putNCvx_longlong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_INT64,NC_FLOAT):
+        return putNCvx_longlong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_INT64,NC_DOUBLE):
+        return putNCvx_longlong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_INT64,NC_INT64):
+        return putNCvx_longlong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT):
+        return putNCvx_longlong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT64):
+        return putNCvx_longlong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT64,NC_USHORT):
+        return putNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_UINT64,NC_BYTE):
+        return putNCvx_ulonglong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT64,NC_UBYTE):
+        return putNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT64,NC_SHORT):
+        return putNCvx_ulonglong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT):
+        return putNCvx_ulonglong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT64,NC_FLOAT):
+        return putNCvx_ulonglong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT64,NC_DOUBLE):
+        return putNCvx_ulonglong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT64):
+        return putNCvx_ulonglong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT):
+        return putNCvx_ulonglong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT64):
+        return putNCvx_ulonglong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_USHORT):
+        return putNCvx_ulonglong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     default:
 	return NC_EBADTYPE;
+	break;
     }
     return status;
 }
diff --git a/libsrc/putget.m4 b/libsrc/putget.m4
index 9f4bc52..7b0d08b 100644
--- a/libsrc/putget.m4
+++ b/libsrc/putget.m4
@@ -12,7 +12,7 @@ dnl
  *	Copyright 1996, University Corporation for Atmospheric Research
  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
-/* $Id: putget.m4,v 2.79 2010/05/29 22:25:01 russ Exp $ */
+/* $Id: putget.m4 2783 2014-10-26 05:19:35Z wkliao $ */
 
 #include "config.h"
 #include <string.h>
@@ -126,6 +126,11 @@ NCFILL(long, int, X_SIZEOF_INT, NC_FILL_INT)
 NCFILL(float, float, X_SIZEOF_FLOAT, NC_FILL_FLOAT)
 NCFILL(double, double, X_SIZEOF_DOUBLE, NC_FILL_DOUBLE)
 
+NCFILL(uchar,     uchar,     X_SIZEOF_UBYTE,     NC_FILL_UBYTE)
+NCFILL(ushort,    ushort,    X_SIZEOF_USHORT,    NC_FILL_USHORT)
+NCFILL(uint,      uint,      X_SIZEOF_UINT,      NC_FILL_UINT)
+NCFILL(longlong,  longlong,  X_SIZEOF_LONGLONG,  NC_FILL_INT64)
+NCFILL(ulonglong, ulonglong, X_SIZEOF_ULONGLONG, NC_FILL_UINT64)
 
 
 
@@ -205,6 +210,21 @@ fill_NC_var(NC3_INFO* ncp, const NC_var *varp, size_t varsize, size_t recno)
 		case NC_DOUBLE :
 			status = NC_fill_double(&xp, nelems);
 			break;
+                case NC_UBYTE :
+                        status = NC_fill_uchar(&xp, nelems);
+                        break;
+                case NC_USHORT :
+                        status = NC_fill_ushort(&xp, nelems);
+                        break;
+                case NC_UINT :
+                        status = NC_fill_uint(&xp, nelems);
+                        break;
+                case NC_INT64 :
+                        status = NC_fill_longlong(&xp, nelems);
+                        break;
+                case NC_UINT64 :
+                        status = NC_fill_ulonglong(&xp, nelems);
+                        break;
 		default :
 			assert("fill_NC_var invalid type" == 0);
 			status = NC_EBADTYPE;
@@ -374,7 +394,7 @@ NCtouchlast(NC3_INFO* ncp, const NC_var *const *varpp, size_t recno)
 
 /*
  * Ensure that the netcdf file has 'numrecs' records,
- * add records and fill as neccessary.
+ * add records and fill as necessary.
  */
 static int
 NCvnrecs(NC3_INFO* ncp, size_t numrecs)
@@ -707,6 +727,9 @@ PUTNCVX(schar, int)
 PUTNCVX(schar, float)
 PUTNCVX(schar, double)
 PUTNCVX(schar, longlong)
+PUTNCVX(schar, ushort)
+PUTNCVX(schar, uint)
+PUTNCVX(schar, ulonglong)
 
 PUTNCVX(short, schar)
 PUTNCVX(short, uchar)
@@ -715,6 +738,9 @@ PUTNCVX(short, int)
 PUTNCVX(short, float)
 PUTNCVX(short, double)
 PUTNCVX(short, longlong)
+PUTNCVX(short, ushort)
+PUTNCVX(short, uint)
+PUTNCVX(short, ulonglong)
 
 PUTNCVX(int, schar)
 PUTNCVX(int, uchar)
@@ -723,6 +749,9 @@ PUTNCVX(int, int)
 PUTNCVX(int, float)
 PUTNCVX(int, double)
 PUTNCVX(int, longlong)
+PUTNCVX(int, ushort)
+PUTNCVX(int, uint)
+PUTNCVX(int, ulonglong)
 
 PUTNCVX(float, schar)
 PUTNCVX(float, uchar)
@@ -731,6 +760,9 @@ PUTNCVX(float, int)
 PUTNCVX(float, float)
 PUTNCVX(float, double)
 PUTNCVX(float, longlong)
+PUTNCVX(float, ushort)
+PUTNCVX(float, uint)
+PUTNCVX(float, ulonglong)
 
 PUTNCVX(double, schar)
 PUTNCVX(double, uchar)
@@ -739,20 +771,64 @@ PUTNCVX(double, int)
 PUTNCVX(double, float)
 PUTNCVX(double, double)
 PUTNCVX(double, longlong)
-
-dnl Following are not currently used
-#ifdef NOTUSED
-PUTNCVX(schar, uint)
-PUTNCVX(schar, ulonglong)
-PUTNCVX(short, uint)
-PUTNCVX(short, ulonglong)
-PUTNCVX(int, uint)
-PUTNCVX(int, ulonglong)
-PUTNCVX(float, uint)
-PUTNCVX(float, ulonglong)
+PUTNCVX(double, ushort)
 PUTNCVX(double, uint)
 PUTNCVX(double, ulonglong)
-#endif /*NOTUSED*/
+
+PUTNCVX(uchar, schar)
+PUTNCVX(uchar, uchar)
+PUTNCVX(uchar, short)
+PUTNCVX(uchar, int)
+PUTNCVX(uchar, float)
+PUTNCVX(uchar, double)
+PUTNCVX(uchar, longlong)
+PUTNCVX(uchar, ushort)
+PUTNCVX(uchar, uint)
+PUTNCVX(uchar, ulonglong)
+
+PUTNCVX(ushort, schar)
+PUTNCVX(ushort, uchar)
+PUTNCVX(ushort, short)
+PUTNCVX(ushort, int)
+PUTNCVX(ushort, float)
+PUTNCVX(ushort, double)
+PUTNCVX(ushort, longlong)
+PUTNCVX(ushort, ushort)
+PUTNCVX(ushort, uint)
+PUTNCVX(ushort, ulonglong)
+
+PUTNCVX(uint, schar)
+PUTNCVX(uint, uchar)
+PUTNCVX(uint, short)
+PUTNCVX(uint, int)
+PUTNCVX(uint, float)
+PUTNCVX(uint, double)
+PUTNCVX(uint, longlong)
+PUTNCVX(uint, ushort)
+PUTNCVX(uint, uint)
+PUTNCVX(uint, ulonglong)
+
+PUTNCVX(longlong, schar)
+PUTNCVX(longlong, uchar)
+PUTNCVX(longlong, short)
+PUTNCVX(longlong, int)
+PUTNCVX(longlong, float)
+PUTNCVX(longlong, double)
+PUTNCVX(longlong, longlong)
+PUTNCVX(longlong, ushort)
+PUTNCVX(longlong, uint)
+PUTNCVX(longlong, ulonglong)
+
+PUTNCVX(ulonglong, schar)
+PUTNCVX(ulonglong, uchar)
+PUTNCVX(ulonglong, short)
+PUTNCVX(ulonglong, int)
+PUTNCVX(ulonglong, float)
+PUTNCVX(ulonglong, double)
+PUTNCVX(ulonglong, longlong)
+PUTNCVX(ulonglong, ushort)
+PUTNCVX(ulonglong, uint)
+PUTNCVX(ulonglong, ulonglong)
 
 dnl
 dnl GETNCVX(XType, Type)
@@ -810,6 +886,8 @@ GETNCVX(schar, double)
 GETNCVX(schar, longlong)
 GETNCVX(schar, uint)
 GETNCVX(schar, ulonglong)
+GETNCVX(schar, uchar)
+GETNCVX(schar, ushort)
 
 GETNCVX(short, schar)
 GETNCVX(short, uchar)
@@ -820,6 +898,7 @@ GETNCVX(short, double)
 GETNCVX(short, longlong)
 GETNCVX(short, uint)
 GETNCVX(short, ulonglong)
+GETNCVX(short, ushort)
 
 GETNCVX(int, schar)
 GETNCVX(int, uchar)
@@ -830,6 +909,7 @@ GETNCVX(int, double)
 GETNCVX(int, longlong)
 GETNCVX(int, uint)
 GETNCVX(int, ulonglong)
+GETNCVX(int, ushort)
 
 GETNCVX(float, schar)
 GETNCVX(float, uchar)
@@ -840,6 +920,7 @@ GETNCVX(float, double)
 GETNCVX(float, longlong)
 GETNCVX(float, uint)
 GETNCVX(float, ulonglong)
+GETNCVX(float, ushort)
 
 GETNCVX(double, schar)
 GETNCVX(double, uchar)
@@ -850,6 +931,62 @@ GETNCVX(double, double)
 GETNCVX(double, longlong)
 GETNCVX(double, uint)
 GETNCVX(double, ulonglong)
+GETNCVX(double, ushort)
+
+GETNCVX(uchar, schar)
+GETNCVX(uchar, uchar)
+GETNCVX(uchar, short)
+GETNCVX(uchar, int)
+GETNCVX(uchar, float)
+GETNCVX(uchar, double)
+GETNCVX(uchar, longlong)
+GETNCVX(uchar, uint)
+GETNCVX(uchar, ulonglong)
+GETNCVX(uchar, ushort)
+
+GETNCVX(ushort, schar)
+GETNCVX(ushort, uchar)
+GETNCVX(ushort, short)
+GETNCVX(ushort, int)
+GETNCVX(ushort, float)
+GETNCVX(ushort, double)
+GETNCVX(ushort, longlong)
+GETNCVX(ushort, uint)
+GETNCVX(ushort, ulonglong)
+GETNCVX(ushort, ushort)
+
+GETNCVX(uint, schar)
+GETNCVX(uint, uchar)
+GETNCVX(uint, short)
+GETNCVX(uint, int)
+GETNCVX(uint, float)
+GETNCVX(uint, double)
+GETNCVX(uint, longlong)
+GETNCVX(uint, uint)
+GETNCVX(uint, ulonglong)
+GETNCVX(uint, ushort)
+
+GETNCVX(longlong, schar)
+GETNCVX(longlong, uchar)
+GETNCVX(longlong, short)
+GETNCVX(longlong, int)
+GETNCVX(longlong, float)
+GETNCVX(longlong, double)
+GETNCVX(longlong, longlong)
+GETNCVX(longlong, uint)
+GETNCVX(longlong, ulonglong)
+GETNCVX(longlong, ushort)
+
+GETNCVX(ulonglong, schar)
+GETNCVX(ulonglong, uchar)
+GETNCVX(ulonglong, short)
+GETNCVX(ulonglong, int)
+GETNCVX(ulonglong, float)
+GETNCVX(ulonglong, double)
+GETNCVX(ulonglong, longlong)
+GETNCVX(ulonglong, uint)
+GETNCVX(ulonglong, ulonglong)
+GETNCVX(ulonglong, ushort)
 
 dnl Following are not currently uses
 #ifdef NOTUSED
@@ -1025,154 +1162,323 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
 {
     int status = NC_NOERR;
     switch (CASE(varp->type,memtype)) {
+
     case CASE(NC_CHAR,NC_CHAR):
     case CASE(NC_CHAR,NC_UBYTE):
-        status = getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
-        break;
-
+        return getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
+	break;
     case CASE(NC_BYTE,NC_BYTE):
+        return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_BYTE,NC_UBYTE):
-        status = getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_BYTE,NC_SHORT):
-        status = getNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_BYTE,NC_INT):
-        status = getNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_BYTE,NC_FLOAT):
-        status = getNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_BYTE,NC_DOUBLE):
-        status = getNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
-        break;
+        return getNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
+	break;
     case CASE(NC_BYTE,NC_INT64):
-        status = getNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_BYTE,NC_UINT):
-        status = getNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_BYTE,NC_UINT64):
-        status = getNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+    	break;
+    case CASE(NC_BYTE,NC_USHORT):
+        return getNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_SHORT,NC_BYTE):
-        status = getNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_SHORT,NC_UBYTE):
-        status = getNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_SHORT,NC_SHORT):
-        status = getNCvx_short_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_short_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_SHORT,NC_INT):
-        status = getNCvx_short_int(ncp,varp,start,nelems,(int*)value);
-        break;
-    case CASE(NC_SHORT,NC_FLOAT):
-        status = getNCvx_short_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_short_int(ncp,varp,start,nelems,(int*)value);
+	break; 
+   case CASE(NC_SHORT,NC_FLOAT):
+        return getNCvx_short_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_SHORT,NC_DOUBLE):
-        status = getNCvx_short_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_short_double(ncp,varp,start,nelems,(double*)value);
+	break;	
     case CASE(NC_SHORT,NC_INT64):
-        status = getNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
+   	break;
     case CASE(NC_SHORT,NC_UINT):
-        status = getNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
+    	break;
     case CASE(NC_SHORT,NC_UINT64):
-        status = getNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_SHORT,NC_USHORT):
+        return getNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     case CASE(NC_INT,NC_BYTE):
-        status = getNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_INT,NC_UBYTE):
-        status = getNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_INT,NC_SHORT):
-        status = getNCvx_int_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_int_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_INT,NC_INT):
-        status = getNCvx_int_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_int_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_INT,NC_FLOAT):
-        status = getNCvx_int_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_int_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_INT,NC_DOUBLE):
-        status = getNCvx_int_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_int_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_INT,NC_INT64):
-        status = getNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_INT,NC_UINT):
-        status = getNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_INT,NC_UINT64):
-        status = getNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT,NC_USHORT):
+        return getNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     case CASE(NC_FLOAT,NC_BYTE):
-        status = getNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_FLOAT,NC_UBYTE):
-        status = getNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_FLOAT,NC_SHORT):
-        status = getNCvx_float_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_float_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT):
-        status = getNCvx_float_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_float_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_FLOAT,NC_FLOAT):
-        status = getNCvx_float_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_float_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_FLOAT,NC_DOUBLE):
-        status = getNCvx_float_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_float_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT64):
-        status = getNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_FLOAT,NC_UINT):
-        status = getNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_FLOAT,NC_UINT64):
-        status = getNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
-
+        return getNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_FLOAT,NC_USHORT):
+        return getNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     case CASE(NC_DOUBLE,NC_BYTE):
-        status = getNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return getNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UBYTE):
-        status = getNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return getNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_SHORT):
-        status = getNCvx_double_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return getNCvx_double_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT):
-        status = getNCvx_double_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return getNCvx_double_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_DOUBLE,NC_FLOAT):
-        status = getNCvx_double_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return getNCvx_double_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_DOUBLE,NC_DOUBLE):
-        status = getNCvx_double_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return getNCvx_double_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT64):
-        status = getNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return getNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UINT):
-        status = getNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
-        break;
+        return getNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UINT64):
-        status = getNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
-        break;
+        return getNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_USHORT):
+        return getNCvx_double_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_UBYTE,NC_UBYTE):
+        return getNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_BYTE):
+        return getNCvx_uchar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_SHORT):
+        return getNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT):
+        return getNCvx_uchar_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_FLOAT):
+        return getNCvx_uchar_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UBYTE,NC_DOUBLE):
+        return getNCvx_uchar_double(ncp,varp,start,nelems,(double *)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT64):
+        return getNCvx_uchar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT):
+        return getNCvx_uchar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT64):
+        return getNCvx_uchar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_USHORT):
+        return getNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_USHORT,NC_BYTE):
+        return getNCvx_ushort_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_USHORT,NC_UBYTE):
+        return getNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_USHORT,NC_SHORT):
+        return getNCvx_ushort_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT):
+        return getNCvx_ushort_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_USHORT,NC_FLOAT):
+        return getNCvx_ushort_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_USHORT,NC_DOUBLE):
+        return getNCvx_ushort_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT64):
+        return getNCvx_ushort_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT):
+        return getNCvx_ushort_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT64):
+        return getNCvx_ushort_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_USHORT):
+        return getNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_UINT,NC_BYTE):
+        return getNCvx_uint_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT,NC_UBYTE):
+        return getNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT,NC_SHORT):
+        return getNCvx_uint_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT,NC_INT):
+        return getNCvx_uint_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT,NC_FLOAT):
+        return getNCvx_uint_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT,NC_DOUBLE):
+        return getNCvx_uint_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT,NC_INT64):
+        return getNCvx_uint_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT):
+        return getNCvx_uint_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT64):
+        return getNCvx_uint_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT,NC_USHORT):
+        return getNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_INT64,NC_BYTE):
+        return getNCvx_longlong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_INT64,NC_UBYTE):
+        return getNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_INT64,NC_SHORT):
+        return getNCvx_longlong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_INT64,NC_INT):
+        return getNCvx_longlong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_INT64,NC_FLOAT):
+        return getNCvx_longlong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_INT64,NC_DOUBLE):
+        return getNCvx_longlong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_INT64,NC_INT64):
+        return getNCvx_longlong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT):
+        return getNCvx_longlong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT64):
+        return getNCvx_longlong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT64,NC_USHORT):
+        return getNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+
+    case CASE(NC_UINT64,NC_BYTE):
+        return getNCvx_ulonglong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT64,NC_UBYTE):
+        return getNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT64,NC_SHORT):
+        return getNCvx_ulonglong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT):
+        return getNCvx_ulonglong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT64,NC_FLOAT):
+        return getNCvx_ulonglong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT64,NC_DOUBLE):
+        return getNCvx_ulonglong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT64):
+        return getNCvx_ulonglong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT):
+        return getNCvx_ulonglong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT64):
+        return getNCvx_ulonglong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_USHORT):
+        return getNCvx_ulonglong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     default:
 	return NC_EBADTYPE;
+	break;
     }
     return status;
 }
@@ -1184,123 +1490,315 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
 {
     int status = NC_NOERR;
     switch (CASE(varp->type,memtype)) {
+
     case CASE(NC_CHAR,NC_CHAR):
     case CASE(NC_CHAR,NC_UBYTE):
-        status = putNCvx_char_char(ncp,varp,start,nelems,(char*)value);
-        break;
-
+        return putNCvx_char_char(ncp,varp,start,nelems,(char*)value);
+	break;
     case CASE(NC_BYTE,NC_BYTE):
-        status = putNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_BYTE,NC_UBYTE):
-        status = putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_BYTE,NC_SHORT):
-        status = putNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_BYTE,NC_INT):
-        status = putNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_schar_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_BYTE,NC_FLOAT):
-        status = putNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_schar_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_BYTE,NC_DOUBLE):
-        status = putNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
-        break;
+        return putNCvx_schar_double(ncp,varp,start,nelems,(double *)value);
+	break;
     case CASE(NC_BYTE,NC_INT64):
-        status = putNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_schar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_BYTE,NC_UINT):
+        return putNCvx_schar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_BYTE,NC_UINT64):
+        return putNCvx_schar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_BYTE,NC_USHORT):
+        return putNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_SHORT,NC_BYTE):
-        status = putNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_SHORT,NC_UBYTE):
-        status = putNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_SHORT,NC_SHORT):
-        status = putNCvx_short_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_short_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_SHORT,NC_INT):
-        status = putNCvx_short_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_short_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_SHORT,NC_FLOAT):
-        status = putNCvx_short_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_short_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_SHORT,NC_DOUBLE):
-        status = putNCvx_short_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_short_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_SHORT,NC_INT64):
-        status = putNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_SHORT,NC_UINT):
+        return putNCvx_short_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_SHORT,NC_UINT64):
+        return putNCvx_short_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_SHORT,NC_USHORT):
+        return putNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_INT,NC_BYTE):
-        status = putNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_INT,NC_UBYTE):
-        status = putNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_INT,NC_SHORT):
-        status = putNCvx_int_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_int_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_INT,NC_INT):
-        status = putNCvx_int_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_int_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_INT,NC_FLOAT):
-        status = putNCvx_int_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_int_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_INT,NC_DOUBLE):
-        status = putNCvx_int_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_int_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_INT,NC_INT64):
-        status = putNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_int_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_INT,NC_UINT):
+        return putNCvx_int_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_INT,NC_UINT64):
+        return putNCvx_int_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT,NC_USHORT):
+        return putNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_FLOAT,NC_BYTE):
-        status = putNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_FLOAT,NC_UBYTE):
-        status = putNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_FLOAT,NC_SHORT):
-        status = putNCvx_float_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_float_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT):
-        status = putNCvx_float_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_float_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_FLOAT,NC_FLOAT):
-        status = putNCvx_float_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_float_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_FLOAT,NC_DOUBLE):
-        status = putNCvx_float_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_float_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_FLOAT,NC_INT64):
-        status = putNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
-
+        return putNCvx_float_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_FLOAT,NC_UINT):
+        return putNCvx_float_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_FLOAT,NC_UINT64):
+        return putNCvx_float_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_FLOAT,NC_USHORT):
+        return putNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
     case CASE(NC_DOUBLE,NC_BYTE):
-        status = putNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
-        break;
+        return putNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_UBYTE):
-        status = putNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
-        break;
+        return putNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
     case CASE(NC_DOUBLE,NC_SHORT):
-        status = putNCvx_double_short(ncp,varp,start,nelems,(short*)value);
-        break;
+        return putNCvx_double_short(ncp,varp,start,nelems,(short*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT):
-        status = putNCvx_double_int(ncp,varp,start,nelems,(int*)value);
-        break;
+        return putNCvx_double_int(ncp,varp,start,nelems,(int*)value);
+	break;
     case CASE(NC_DOUBLE,NC_FLOAT):
-        status = putNCvx_double_float(ncp,varp,start,nelems,(float*)value);
-        break;
+        return putNCvx_double_float(ncp,varp,start,nelems,(float*)value);
+	break;
     case CASE(NC_DOUBLE,NC_DOUBLE):
-        status = putNCvx_double_double(ncp,varp,start,nelems,(double*)value);
-        break;
+        return putNCvx_double_double(ncp,varp,start,nelems,(double*)value);
+	break;
     case CASE(NC_DOUBLE,NC_INT64):
-        status = putNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
-        break;
+        return putNCvx_double_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_UINT):
+        return putNCvx_double_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_UINT64):
+        return putNCvx_double_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_DOUBLE,NC_USHORT):
+        return putNCvx_double_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UBYTE):
+        return putNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_BYTE):
+        return putNCvx_uchar_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UBYTE,NC_SHORT):
+        return putNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT):
+        return putNCvx_uchar_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_FLOAT):
+        return putNCvx_uchar_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UBYTE,NC_DOUBLE):
+        return putNCvx_uchar_double(ncp,varp,start,nelems,(double *)value);
+	break;
+    case CASE(NC_UBYTE,NC_INT64):
+        return putNCvx_uchar_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT):
+        return putNCvx_uchar_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UBYTE,NC_UINT64):
+        return putNCvx_uchar_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UBYTE,NC_USHORT):
+        return putNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_USHORT,NC_BYTE):
+        return putNCvx_ushort_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_USHORT,NC_UBYTE):
+        return putNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_USHORT,NC_SHORT):
+        return putNCvx_ushort_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT):
+        return putNCvx_ushort_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_USHORT,NC_FLOAT):
+        return putNCvx_ushort_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_USHORT,NC_DOUBLE):
+        return putNCvx_ushort_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_USHORT,NC_INT64):
+        return putNCvx_ushort_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT):
+        return putNCvx_ushort_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_USHORT,NC_UINT64):
+        return putNCvx_ushort_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_USHORT,NC_USHORT):
+        return putNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_UINT,NC_BYTE):
+        return putNCvx_uint_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT,NC_UBYTE):
+        return putNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT,NC_SHORT):
+        return putNCvx_uint_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT,NC_INT):
+        return putNCvx_uint_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT,NC_FLOAT):
+        return putNCvx_uint_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT,NC_DOUBLE):
+        return putNCvx_uint_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT,NC_INT64):
+        return putNCvx_uint_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT):
+        return putNCvx_uint_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT,NC_UINT64):
+        return putNCvx_uint_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT,NC_USHORT):
+        return putNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_INT64,NC_BYTE):
+        return putNCvx_longlong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_INT64,NC_UBYTE):
+        return putNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_INT64,NC_SHORT):
+        return putNCvx_longlong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_INT64,NC_INT):
+        return putNCvx_longlong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_INT64,NC_FLOAT):
+        return putNCvx_longlong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_INT64,NC_DOUBLE):
+        return putNCvx_longlong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_INT64,NC_INT64):
+        return putNCvx_longlong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT):
+        return putNCvx_longlong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_INT64,NC_UINT64):
+        return putNCvx_longlong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_INT64,NC_USHORT):
+        return putNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
+    case CASE(NC_UINT64,NC_BYTE):
+        return putNCvx_ulonglong_schar(ncp,varp,start,nelems,(signed char*)value);
+	break;
+    case CASE(NC_UINT64,NC_UBYTE):
+        return putNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
+	break;
+    case CASE(NC_UINT64,NC_SHORT):
+        return putNCvx_ulonglong_short(ncp,varp,start,nelems,(short*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT):
+        return putNCvx_ulonglong_int(ncp,varp,start,nelems,(int*)value);
+	break;
+    case CASE(NC_UINT64,NC_FLOAT):
+        return putNCvx_ulonglong_float(ncp,varp,start,nelems,(float*)value);
+	break;
+    case CASE(NC_UINT64,NC_DOUBLE):
+        return putNCvx_ulonglong_double(ncp,varp,start,nelems,(double*)value);
+	break;
+    case CASE(NC_UINT64,NC_INT64):
+        return putNCvx_ulonglong_longlong(ncp,varp,start,nelems,(long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT):
+        return putNCvx_ulonglong_uint(ncp,varp,start,nelems,(unsigned int*)value);
+	break;
+    case CASE(NC_UINT64,NC_UINT64):
+        return putNCvx_ulonglong_ulonglong(ncp,varp,start,nelems,(unsigned long long*)value);
+	break;
+    case CASE(NC_UINT64,NC_USHORT):
+        return putNCvx_ulonglong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
+	break;
 
     default:
 	return NC_EBADTYPE;
+	break;
     }
     return status;
 }
diff --git a/libsrc/v1hpg.c b/libsrc/v1hpg.c
index 75d6993..904ffc6 100644
--- a/libsrc/v1hpg.c
+++ b/libsrc/v1hpg.c
@@ -2,7 +2,6 @@
  *	Copyright 1996, University Corporation for Atmospheric Research
  *      See netcdf/COPYRIGHT file for copying and redistribution conditions.
  */
-/* $Id: v1hpg.c,v 1.70 2010/05/26 21:43:34 dmh Exp $ */
 
 #include "config.h"
 #include "nc3internal.h"
@@ -34,7 +33,7 @@
  */
 static const schar ncmagic[] = {'C', 'D', 'F', 0x02};
 static const schar ncmagic1[] = {'C', 'D', 'F', 0x01};
-
+static const schar ncmagic5[] = {'C', 'D', 'F', 0x05};
 
 /*
  * v1hs == "Version 1 Header Stream"
@@ -50,7 +49,7 @@ typedef struct v1hs {
 	off_t offset;	/* argument to nciop->get() */
 	size_t extent;	/* argument to nciop->get() */
 	int flags;	/* set to RGN_WRITE for write */
-        int version;    /* format variant: NC_FORMAT_CLASSIC or NC_FORMAT_64BIT */
+        int version;    /* format variant: NC_FORMAT_CLASSIC, NC_FORMAT_64BIT_OFFSET or NC_FORMAT_CDF5 */
 	void *base;	/* beginning of current buffer */
 	void *pos;	/* current position in buffer */
 	void *end;	/* end of current buffer = base + extent */
@@ -133,24 +132,40 @@ fprintf(stderr, "nextread %lu, remaining %lu\n",
 static int
 v1h_put_size_t(v1hs *psp, const size_t *sp)
 {
-	int status = check_v1hs(psp, X_SIZEOF_SIZE_T);
-	if(status != ENOERR)
-		return status;
-	return ncx_put_size_t(&psp->pos, sp);
+	int status;
+	if (psp->version == 5) /* all integers in CDF-5 are 64 bits */
+		status = check_v1hs(psp, X_SIZEOF_INT64);
+	else
+		status = check_v1hs(psp, X_SIZEOF_SIZE_T);
+ 	if(status != ENOERR)
+ 		return status;
+        if (psp->version == 5)
+		return ncx_put_int64(&psp->pos, *sp);
+        else
+	    return ncx_put_size_t(&psp->pos, sp);
 }
 
-
 /* Read a size_t from the header */
 static int
 v1h_get_size_t(v1hs *gsp, size_t *sp)
 {
-	int status = check_v1hs(gsp, X_SIZEOF_SIZE_T);
+	int status;
+	if (gsp->version == 5) /* all integers in CDF-5 are 64 bits */
+		status = check_v1hs(gsp, X_SIZEOF_INT64);
+	else
+		status = check_v1hs(gsp, X_SIZEOF_SIZE_T);
 	if(status != ENOERR)
 		return status;
-	return ncx_get_size_t((const void **)(&gsp->pos), sp);
+        if (gsp->version == 5) {
+		long long tmp=0;
+		status = ncx_get_int64((const void **)(&gsp->pos), &tmp);
+		*sp = (size_t)tmp;
+		return status;
+        }
+        else
+	    return ncx_get_size_t((const void **)(&gsp->pos), sp);
 }
 
-
 /* Begin nc_type */
 
 #define X_SIZEOF_NC_TYPE X_SIZEOF_INT
@@ -187,7 +202,13 @@ v1h_get_nc_type(v1hs *gsp, nc_type *typep)
 		|| type == NC_SHORT
 		|| type == NC_INT
 		|| type == NC_FLOAT
-		|| type == NC_DOUBLE);
+		|| type == NC_DOUBLE
+		|| type == NC_UBYTE
+		|| type == NC_USHORT
+		|| type == NC_UINT
+		|| type == NC_INT64
+		|| type == NC_UINT64
+		|| type == NC_STRING);
 
 	/* else */
 	*typep = (nc_type) type;
@@ -239,9 +260,9 @@ v1h_get_NCtype(v1hs *gsp, NCtype *typep)
 NC_xlen_string(cdfstr)
  */
 static size_t
-ncx_len_NC_string(const NC_string *ncstrp)
+ncx_len_NC_string(const NC_string *ncstrp, int version)
 {
-	size_t sz = X_SIZEOF_SIZE_T; /* nchars */
+	size_t sz = (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_INT; /* nchars */
 
 	assert(ncstrp != NULL);
 
@@ -336,14 +357,14 @@ unwind_alloc:
 NC_xlen_dim(dpp)
  */
 static size_t
-ncx_len_NC_dim(const NC_dim *dimp)
+ncx_len_NC_dim(const NC_dim *dimp, int version)
 {
 	size_t sz;
 
 	assert(dimp != NULL);
 
-	sz = ncx_len_NC_string(dimp->name);
-	sz += X_SIZEOF_SIZE_T;
+	sz = ncx_len_NC_string(dimp->name, version);
+	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T;
 
 	return(sz);
 }
@@ -404,10 +425,10 @@ unwind_name:
 
 /* How much space in the header is required for this NC_dimarray? */
 static size_t
-ncx_len_NC_dimarray(const NC_dimarray *ncap)
+ncx_len_NC_dimarray(const NC_dimarray *ncap, int version)
 {
 	size_t xlen = X_SIZEOF_NCTYPE;	/* type */
-	xlen += X_SIZEOF_SIZE_T;	/* count */
+	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
 	if(ncap == NULL)
 		return xlen;
 	/* else */
@@ -416,7 +437,7 @@ ncx_len_NC_dimarray(const NC_dimarray *ncap)
 		const NC_dim *const *const end = &dpp[ncap->nelems];
 		for(  /*NADA*/; dpp < end; dpp++)
 		{
-			xlen += ncx_len_NC_dim(*dpp);
+			xlen += ncx_len_NC_dim(*dpp,version);
 		}
 	}
 	return xlen;
@@ -537,15 +558,15 @@ v1h_get_NC_dimarray(v1hs *gsp, NC_dimarray *ncap)
 NC_xlen_attr(app)
  */
 static size_t
-ncx_len_NC_attr(const NC_attr *attrp)
+ncx_len_NC_attr(const NC_attr *attrp, int version)
 {
 	size_t sz;
 
 	assert(attrp != NULL);
 
-	sz = ncx_len_NC_string(attrp->name);
+	sz = ncx_len_NC_string(attrp->name, version);
 	sz += X_SIZEOF_NC_TYPE; /* type */
-	sz += X_SIZEOF_SIZE_T; /* nelems */
+	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* nelems */
 	sz += attrp->xsz;
 
 	return(sz);
@@ -696,10 +717,10 @@ unwind_name:
 
 /* How much space in the header is required for this NC_attrarray? */
 static size_t
-ncx_len_NC_attrarray(const NC_attrarray *ncap)
+ncx_len_NC_attrarray(const NC_attrarray *ncap, int version)
 {
 	size_t xlen = X_SIZEOF_NCTYPE;	/* type */
-	xlen += X_SIZEOF_SIZE_T;	/* count */
+	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
 	if(ncap == NULL)
 		return xlen;
 	/* else */
@@ -708,7 +729,7 @@ ncx_len_NC_attrarray(const NC_attrarray *ncap)
 		const NC_attr *const *const end = &app[ncap->nelems];
 		for( /*NADA*/; app < end; app++)
 		{
-			xlen += ncx_len_NC_attr(*app);
+			xlen += ncx_len_NC_attr(*app,version);
 		}
 	}
 	return xlen;
@@ -826,19 +847,25 @@ v1h_get_NC_attrarray(v1hs *gsp, NC_attrarray *ncap)
 NC_xlen_var(vpp)
  */
 static size_t
-ncx_len_NC_var(const NC_var *varp, size_t sizeof_off_t)
+ncx_len_NC_var(const NC_var *varp, size_t sizeof_off_t, int version)
 {
 	size_t sz;
 
 	assert(varp != NULL);
 	assert(sizeof_off_t != 0);
 
-	sz = ncx_len_NC_string(varp->name);
-	sz += X_SIZEOF_SIZE_T; /* ndims */
-	sz += ncx_len_int(varp->ndims); /* dimids */
-	sz += ncx_len_NC_attrarray(&varp->attrs);
-	sz += X_SIZEOF_NC_TYPE; /* type */
-	sz += X_SIZEOF_SIZE_T; /* len */
+	sz = ncx_len_NC_string(varp->name, version);
+        if (version == 5) {
+	    sz += X_SIZEOF_INT64; /* ndims */
+	    sz += ncx_len_int64(varp->ndims); /* dimids */
+        }
+        else {
+	    sz += X_SIZEOF_SIZE_T; /* ndims */
+	    sz += ncx_len_int(varp->ndims); /* dimids */
+	}
+	sz += ncx_len_NC_attrarray(&varp->attrs, version);
+	sz += X_SIZEOF_NC_TYPE; /* nc_type */
+	sz += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* vsize */
 	sz += sizeof_off_t; /* begin */
 
 	return(sz);
@@ -859,13 +886,24 @@ v1h_put_NC_var(v1hs *psp, const NC_var *varp)
 	if(status != ENOERR)
 		return status;
 
-	status = check_v1hs(psp, ncx_len_int(varp->ndims));
-	if(status != ENOERR)
+	if (psp->version == 5) {
+		status = check_v1hs(psp, ncx_len_int64(varp->ndims));
+		if(status != ENOERR)
+			return status;
+		status = ncx_putn_longlong_int(&psp->pos,
+				varp->ndims, varp->dimids);
+		if(status != ENOERR)
+			return status;
+	}
+	else {
+  	    status = check_v1hs(psp, ncx_len_int(varp->ndims));
+	    if(status != ENOERR)
 		return status;
-	status = ncx_putn_int_int(&psp->pos,
+	    status = ncx_putn_int_int(&psp->pos,
 			varp->ndims, varp->dimids);
-	if(status != ENOERR)
+	    if(status != ENOERR)
 		return status;
+	}
 
 	status = v1h_put_NC_attrarray(psp, &varp->attrs);
 	if(status != ENOERR)
@@ -879,7 +917,7 @@ v1h_put_NC_var(v1hs *psp, const NC_var *varp)
 	if(status != ENOERR)
 		return status;
 
-	status = check_v1hs(psp, psp->version == 1 ? 4 : 8);
+	status = check_v1hs(psp, psp->version == 1 ? 4 : 8); /*begin*/
 	if(status != ENOERR)
 		 return status;
 	status = ncx_put_off_t(&psp->pos, &varp->begin, psp->version == 1 ? 4 : 8);
@@ -914,18 +952,27 @@ v1h_get_NC_var(v1hs *gsp, NC_var **varpp)
 		goto unwind_name;
 	}
 
-	status = check_v1hs(gsp, ncx_len_int(ndims));
-	if(status != ENOERR)
+	if (gsp->version == 5) {
+		status = check_v1hs(gsp, ncx_len_int64(ndims));
+		if(status != ENOERR)
+			goto unwind_alloc;
+		status = ncx_getn_longlong_int((const void **)(&gsp->pos),
+				ndims, varp->dimids);
+		if(status != ENOERR)
+			goto unwind_alloc;
+	}
+	else {
+	    status = check_v1hs(gsp, ncx_len_int(ndims));
+	    if(status != ENOERR)
 		goto unwind_alloc;
-	status = ncx_getn_int_int((const void **)(&gsp->pos),
+	    status = ncx_getn_int_int((const void **)(&gsp->pos),
 			ndims, varp->dimids);
-	if(status != ENOERR)
+	    if(status != ENOERR)
 		goto unwind_alloc;
-
+	}
 	status = v1h_get_NC_attrarray(gsp, &varp->attrs);
 	if(status != ENOERR)
 		goto unwind_alloc;
-
 	status = v1h_get_nc_type(gsp, &varp->type);
 	if(status != ENOERR)
 		 goto unwind_alloc;
@@ -957,10 +1004,10 @@ unwind_name:
 
 /* How much space in the header is required for this NC_vararray? */
 static size_t
-ncx_len_NC_vararray(const NC_vararray *ncap, size_t sizeof_off_t)
+ncx_len_NC_vararray(const NC_vararray *ncap, size_t sizeof_off_t, int version)
 {
 	size_t xlen = X_SIZEOF_NCTYPE;	/* type */
-	xlen += X_SIZEOF_SIZE_T;	/* count */
+	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* count */
 	if(ncap == NULL)
 		return xlen;
 	/* else */
@@ -969,7 +1016,7 @@ ncx_len_NC_vararray(const NC_vararray *ncap, size_t sizeof_off_t)
 		const NC_var *const *const end = &vpp[ncap->nelems];
 		for( /*NADA*/; vpp < end; vpp++)
 		{
-			xlen += ncx_len_NC_var(*vpp, sizeof_off_t);
+			xlen += ncx_len_NC_var(*vpp, sizeof_off_t, version);
 		}
 	}
 	return xlen;
@@ -1117,7 +1164,8 @@ NC_computeshapes(NC3_INFO* ncp)
 		{
 	  		if(first_rec == NULL)	
 				first_rec = *vpp;
-			if((*vpp)->len == UINT32_MAX) /* Flag for large last record */
+			if((*vpp)->len == UINT32_MAX &&
+                           fIsSet(ncp->flags, NC_64BIT_OFFSET)) /* Flag for large last record */
                             ncp->recsize += (*vpp)->dsizes[0] * (*vpp)->xsz;
 			else
 			    ncp->recsize += (*vpp)->len;
@@ -1168,15 +1216,20 @@ NC_computeshapes(NC3_INFO* ncp)
 size_t
 ncx_len_NC(const NC3_INFO* ncp, size_t sizeof_off_t)
 {
+	int version=1;
 	size_t xlen = sizeof(ncmagic);
 
 	assert(ncp != NULL);
+	if (fIsSet(ncp->flags, NC_64BIT_DATA)) /* CDF-5 */
+		version = 5;
+    	else if (fIsSet(ncp->flags, NC_64BIT_OFFSET)) /* CDF-2 */
+		version = 2;
+
+	xlen += (version == 5) ? X_SIZEOF_INT64 : X_SIZEOF_SIZE_T; /* numrecs */
+	xlen += ncx_len_NC_dimarray(&ncp->dims, version);
+	xlen += ncx_len_NC_attrarray(&ncp->attrs, version);
+	xlen += ncx_len_NC_vararray(&ncp->vars, sizeof_off_t, version);
 	
-	xlen += X_SIZEOF_SIZE_T; /* numrecs */
-	xlen += ncx_len_NC_dimarray(&ncp->dims);
-	xlen += ncx_len_NC_attrarray(&ncp->attrs);
-	xlen += ncx_len_NC_vararray(&ncp->vars, sizeof_off_t);
-
 	return xlen;
 }
 
@@ -1195,7 +1248,9 @@ ncx_put_NC(const NC3_INFO* ncp, void **xpp, off_t offset, size_t extent)
 	ps.nciop = ncp->nciop;
 	ps.flags = RGN_WRITE;
 
-	if (ncp->flags & NC_64BIT_OFFSET)
+	if (ncp->flags & NC_64BIT_DATA)
+	  ps.version = 5;
+	else if (ncp->flags & NC_64BIT_OFFSET)
 	  ps.version = 2;
 	else 
 	  ps.version = 1;
@@ -1206,7 +1261,7 @@ ncx_put_NC(const NC3_INFO* ncp, void **xpp, off_t offset, size_t extent)
 		 * Come up with a reasonable stream read size.
 		 */
 		extent = ncp->xsz;
-		if(extent <= MIN_NC_XSZ)
+		if(extent <= ((ps.version==5)?MIN_NC5_XSZ:MIN_NC3_XSZ))
 		{
 			/* first time read */
 			extent = ncp->chunk;
@@ -1236,7 +1291,9 @@ ncx_put_NC(const NC3_INFO* ncp, void **xpp, off_t offset, size_t extent)
 		ps.end = (char *)ps.base + ps.extent;
 	}
 
-	if (ps.version == 2)
+	if (ps.version == 5)
+	  status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic5), ncmagic5);
+	else if (ps.version == 2)
 	  status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic), ncmagic);
 	else
 	  status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic1), ncmagic1);
@@ -1245,7 +1302,10 @@ ncx_put_NC(const NC3_INFO* ncp, void **xpp, off_t offset, size_t extent)
 
 	{
 	const size_t nrecs = NC_get_numrecs(ncp);
-	status = ncx_put_size_t(&ps.pos, &nrecs);
+       	if (ps.version == 5)
+	    status = ncx_put_int64(&ps.pos, nrecs);
+       	else
+	    status = ncx_put_size_t(&ps.pos, &nrecs);
 	if(status != ENOERR)
 		goto release;
 	}
@@ -1295,10 +1355,9 @@ nc_get_NC(NC3_INFO* ncp)
 		 * Come up with a reasonable stream read size.
 		 */
 	        off_t filesize;
-		size_t extent = MIN_NC_XSZ;
+		size_t extent = ncp->xsz;
 		
-		extent = ncp->xsz;
-		if(extent <= MIN_NC_XSZ)
+		if(extent <= ((fIsSet(ncp->flags, NC_64BIT_DATA))?MIN_NC5_XSZ:MIN_NC3_XSZ))
 		{
 		        status = ncio_filesize(ncp->nciop, &filesize);
 			if(status)
@@ -1362,6 +1421,9 @@ nc_get_NC(NC3_INFO* ncp)
 		    fprintf(stderr, "NETCDF WARNING: Version 2 file on 32-bit system.\n");
 		  }
 #endif
+		} else if (magic[sizeof(ncmagic)-1] == 0x5) {
+		  gs.version = 5;
+		  fSet(ncp->flags, NC_64BIT_DATA);
 		} else {
 			status = NC_ENOTNC;
 			goto unwind_get;
@@ -1370,7 +1432,13 @@ nc_get_NC(NC3_INFO* ncp)
 	
 	{
 	size_t nrecs = 0;
-	status = ncx_get_size_t((const void **)(&gs.pos), &nrecs);
+       	if (gs.version == 5) {
+		long long tmp = 0;
+		status = ncx_get_int64((const void **)(&gs.pos), &tmp);
+		nrecs = (size_t)tmp;
+       	}
+       	else
+	    status = ncx_get_size_t((const void **)(&gs.pos), &nrecs);
 	if(status != ENOERR)
 		goto unwind_get;
 	NC_set_numrecs(ncp, nrecs);
diff --git a/libsrc/var.c b/libsrc/var.c
index f47c404..d6a49db 100644
--- a/libsrc/var.c
+++ b/libsrc/var.c
@@ -81,7 +81,6 @@ new_x_NC_var(
 #else /*!MALLOCHACK*/
 	  varp->dimids = (int*)malloc(o1);
 	  varp->shape = (size_t*)malloc(o2);
-      if(varp->shape) { memset(varp->shape,0,o2); }
 	  varp->dsizes = (off_t*)malloc(o3);
 #endif /*!MALLOCHACK*/
 	} else {
@@ -377,6 +376,7 @@ ncx_szof(nc_type type)
 	switch(type){
 	case NC_BYTE:
 	case NC_CHAR:
+	case NC_UBYTE:
 		return(1);
 	case NC_SHORT :
 		return(2);
@@ -386,6 +386,14 @@ ncx_szof(nc_type type)
 		return X_SIZEOF_FLOAT;
 	case NC_DOUBLE :
 		return X_SIZEOF_DOUBLE;
+	case NC_USHORT : 
+		return X_SIZEOF_USHORT;
+	case NC_UINT : 
+		return X_SIZEOF_UINT;
+	case NC_INT64 : 
+		return X_SIZEOF_INT64;
+	case NC_UINT64 : 
+		return X_SIZEOF_UINT64;
 	default:
 	        assert("ncx_szof invalid type" == 0);
 	        return 0;
@@ -461,6 +469,7 @@ out :
 		switch(varp->type) {
 		case NC_BYTE :
 		case NC_CHAR :
+		case NC_UBYTE :
 		case NC_SHORT :
 		        if( varp->len%4 != 0 )
 			{
@@ -568,7 +577,7 @@ NC3_def_var( int ncid, const char *name, nc_type type,
 	if(status != NC_NOERR)
 		return status;
 
-	status = nc_cktype(type);
+	status = nc3_cktype(nc->mode, type);
 	if(status != NC_NOERR)
 		return status;
 
diff --git a/libsrc4/Makefile.in b/libsrc4/Makefile.in
index 5b297b7..366d18d 100644
--- a/libsrc4/Makefile.in
+++ b/libsrc4/Makefile.in
@@ -247,6 +247,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -279,6 +280,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -290,6 +292,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/libsrc4/nc4dim.c b/libsrc4/nc4dim.c
index c5fc3d6..111392b 100644
--- a/libsrc4/nc4dim.c
+++ b/libsrc4/nc4dim.c
@@ -191,7 +191,7 @@ NC4_inq_dimid(int ncid, const char *name, int *idp)
 }
 
 /* Find out name and len of a dim. For an unlimited dimension, the
-   length is the largest lenght so far written. If the name of lenp
+   length is the largest length so far written. If the name of lenp
    pointers are NULL, they will be ignored. */
 int
 NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
diff --git a/libsrc4/nc4dispatch.c b/libsrc4/nc4dispatch.c
index 645a229..02d01fb 100644
--- a/libsrc4/nc4dispatch.c
+++ b/libsrc4/nc4dispatch.c
@@ -12,7 +12,7 @@
 
 static NC_Dispatch NC4_dispatcher = {
 
-NC_DISPATCH_NC4,
+NC_FORMATX_NC4,
 
 NC4_create,
 NC4_open,
@@ -108,3 +108,9 @@ NC4_initialize(void)
     NC4_dispatch_table = &NC4_dispatcher;
     return NC_NOERR;
 }
+
+int
+NC4_finalize(void)
+{
+    return NC_NOERR;
+}
diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c
index 5976237..dc294fb 100644
--- a/libsrc4/nc4file.c
+++ b/libsrc4/nc4file.c
@@ -46,9 +46,9 @@ extern int num_spaces;
 #define NAME "NAME"
 
 /* Define the illegal mode flags */
-#define ILLEGAL_OPEN_FLAGS (NC_MMAP|NC_64BIT_OFFSET)
+static const int ILLEGAL_OPEN_FLAGS = (NC_MMAP|NC_64BIT_OFFSET);
 
-#define ILLEGAL_CREATE_FLAGS (NC_NOWRITE|NC_MMAP|NC_INMEMORY|NC_64BIT_OFFSET|NC_PNETCDF)
+static const int ILLEGAL_CREATE_FLAGS = (NC_NOWRITE|NC_MMAP|NC_INMEMORY|NC_64BIT_OFFSET|NC_CDF5);
 
 /*! Struct to track information about objects in a group, for nc4_rec_read_metadata()
 
@@ -193,7 +193,7 @@ static int
 nc_check_for_hdf(const char *path, int flags, void* parameters, int *hdf_file)
 {
    char blob[MAGIC_NUMBER_LEN];
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    int use_parallel = ((flags & NC_MPIIO) == NC_MPIIO);
    NC_MPI_INFO* mpiinfo = (NC_MPI_INFO*)parameters;
    MPI_Comm comm = MPI_COMM_WORLD;
@@ -204,7 +204,7 @@ nc_check_for_hdf(const char *path, int flags, void* parameters, int *hdf_file)
    NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
 #endif
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    if(use_parallel) {
        comm = mpiinfo->comm;
        info = mpiinfo->info;
@@ -222,7 +222,7 @@ nc_check_for_hdf(const char *path, int flags, void* parameters, int *hdf_file)
 
 /* Get the 4-byte blob from the beginning of the file. Don't use posix
  * for parallel, use the MPI functions instead. */
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
        if (!inmemory && use_parallel)
        {
 	   MPI_File fh;
@@ -238,7 +238,7 @@ nc_check_for_hdf(const char *path, int flags, void* parameters, int *hdf_file)
 	       return NC_EPARINIT;
        }
        else
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
        if(!inmemory) {
 	   FILE *fp;
 	   if (!(fp = fopen(path, "r")) ||
@@ -276,10 +276,10 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
    FILE *fp;
    int retval = NC_NOERR;
    NC_HDF5_FILE_INFO_T* nc4_info = NULL;
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    int comm_duped = 0;          /* Whether the MPI Communicator was duplicated */
    int info_duped = 0;          /* Whether the MPI Info object was duplicated */
-#else /* !USE_PARALLEL */
+#else /* !USE_PARALLEL4 */
    int persist = 0; /* Should diskless try to persist its data into file?*/
 #endif
 
@@ -298,7 +298,7 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
    /* If this file already exists, and NC_NOCLOBBER is specified,
       return an error. */
    if (cmode & NC_DISKLESS) {
-#ifndef USE_PARALLEL
+#ifndef USE_PARALLEL4
 	if(cmode & NC_WRITE)
 	    persist = 1;
 #endif
@@ -334,7 +334,7 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
       BAIL(NC_EHDFERR);
 #endif /* EXTRA_TESTS */
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    /* If this is a parallel file create, set up the file creation
       property list. */
    if ((cmode & NC_MPIIO) || (cmode & NC_MPIPOSIX))
@@ -388,7 +388,7 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
       BAIL(NC_EHDFERR);
    LOG((4, "%s: set HDF raw chunk cache to size %d nelems %d preemption %f",
 	__func__, nc4_chunk_cache_size, nc4_chunk_cache_nelems, nc4_chunk_cache_preemption));
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
 
    if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
       BAIL(NC_EHDFERR);
@@ -440,7 +440,7 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
    return NC_NOERR;
 
 exit: /*failure exit*/
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    if (comm_duped) MPI_Comm_free(&nc4_info->comm);
    if (info_duped) MPI_Info_free(&nc4_info->info);
 #endif
@@ -482,13 +482,13 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
    LOG((1, "%s: path %s cmode 0x%x comm %d info %d",
 	__func__, path, cmode, comm, info));
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    if (parameters)
    {
       comm = ((NC_MPI_INFO *)parameters)->comm;
       info = ((NC_MPI_INFO *)parameters)->info;
    }
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
 
    /* If this is our first file, turn off HDF5 error messages. */
    if (virgin)
@@ -525,7 +525,9 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
    cmode |= NC_NETCDF4;
 
    /* Apply default create format. */
-   if (nc_get_default_format() == NC_FORMAT_64BIT)
+   if (nc_get_default_format() == NC_FORMAT_CDF5)
+      cmode |= NC_CDF5;
+   else if (nc_get_default_format() == NC_FORMAT_64BIT_OFFSET)
       cmode |= NC_64BIT_OFFSET;
    else if (nc_get_default_format() == NC_FORMAT_NETCDF4_CLASSIC)
       cmode |= NC_CLASSIC_MODEL;
@@ -2193,11 +2195,11 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
 #ifdef USE_DISKLESS
    NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
 #endif
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    NC_MPI_INFO* mpiinfo = (NC_MPI_INFO*)parameters;
    int comm_duped = 0;          /* Whether the MPI Communicator was duplicated */
    int info_duped = 0;          /* Whether the MPI Info object was duplicated */
-#endif /* !USE_PARALLEL */
+#endif /* !USE_PARALLEL4 */
 
    LOG((3, "%s: path %s mode %d", __func__, path, mode));
    assert(path && nc);
@@ -2224,7 +2226,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
       BAIL(NC_EHDFERR);
 #endif
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    /* If this is a parallel file create, set up the file creation
       property list. */
    if (mode & NC_MPIIO || mode & NC_MPIPOSIX)
@@ -2274,7 +2276,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
       BAIL(NC_EHDFERR);
    LOG((4, "%s: set HDF raw chunk cache to size %d nelems %d preemption %f",
 	__func__, nc4_chunk_cache_size, nc4_chunk_cache_nelems, nc4_chunk_cache_preemption));
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
 
    /* The NetCDF-3.x prototype contains an mode option NC_SHARE for
       multiple processes accessing the dataset concurrently.  As there
@@ -2320,7 +2322,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
    return NC_NOERR;
 
 exit:
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    if (comm_duped) MPI_Comm_free(&nc4_info->comm);
    if (info_duped) MPI_Info_free(&nc4_info->info);
 #endif
@@ -2770,10 +2772,10 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
 {
    int res;
    int hdf_file = 0;
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    NC_MPI_INFO mpidfalt = {MPI_COMM_WORLD, MPI_INFO_NULL};
 #endif
-#if defined USE_PARALLEL || defined USE_HDF4
+#if defined USE_PARALLEL4 || defined USE_HDF4
    int inmemory = ((mode & NC_INMEMORY) == NC_INMEMORY);
 #endif
 
@@ -2782,10 +2784,10 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
    LOG((1, "%s: path %s mode %d params %x",
 	__func__, path, mode, parameters));
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
    if (!inmemory && use_parallel && parameters == NULL)
 	parameters = &mpidfalt;
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
 
    /* If this is our first file, turn off HDF5 error messages. */
    if (virgin)
@@ -2978,7 +2980,7 @@ sync_netcdf4_file(NC_HDF5_FILE_INFO_T *h5)
       /* Turn define mode off. */
       h5->flags ^= NC_INDEF;
 
-      /* Redef mode needs to be tracked seperately for nc_abort. */
+      /* Redef mode needs to be tracked separately for nc_abort. */
       h5->redef = NC_FALSE;
    }
 
@@ -3076,7 +3078,7 @@ close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5, int abort)
    else
 #endif /* USE_HDF4 */
    {
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
       /* Free the MPI Comm & Info objects, if we opened the file in parallel */
       if(h5->parallel)
       {
@@ -3309,7 +3311,7 @@ nc4_enddef_netcdf4_file(NC_HDF5_FILE_INFO_T *h5)
    /* Turn define mode off. */
    h5->flags ^= NC_INDEF;
 
-   /* Redef mode needs to be tracked seperately for nc_abort. */
+   /* Redef mode needs to be tracked separately for nc_abort. */
    h5->redef = NC_FALSE;
 
    return sync_netcdf4_file(h5);
@@ -3326,10 +3328,10 @@ nc_exit()
 }
 #endif /* EXTRA_TESTS */
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
 int
 nc_use_parallel_enabled()
 {
    return 0;
 }
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c
index 4c037bd..f90401a 100644
--- a/libsrc4/nc4hdf.c
+++ b/libsrc4/nc4hdf.c
@@ -484,7 +484,7 @@ log_dim_info(NC_VAR_INFO_T *var, hsize_t *fdims, hsize_t *fmaxdims,
 }
 #endif /* LOGGING */
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
 static int
 set_par_access(NC_HDF5_FILE_INFO_T *h5, NC_VAR_INFO_T *var, hid_t xfer_plistid)
 {
@@ -691,7 +691,7 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
     BAIL(NC_EHDFERR);
 #endif
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
   /* Set up parallel I/O, if needed. */
   if ((retval = set_par_access(h5, var, xfer_plistid)))
     BAIL(retval);
@@ -729,7 +729,7 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
             }
         }
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
       /* Check if anyone wants to extend */
       if (h5->parallel && NC_COLLECTIVE == var->parallel_access)
         {
@@ -739,14 +739,14 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
           if(MPI_SUCCESS != MPI_Allreduce(MPI_IN_PLACE, &need_to_extend, 1, MPI_INT, MPI_BOR, h5->comm))
             BAIL(NC_EMPI);
         }
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
 
       /* If we need to extend it, we also need a new file_spaceid
          to reflect the new size of the space. */
       if (need_to_extend)
         {
           LOG((4, "extending dataset"));
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
           if (h5->parallel)
             {
               if(NC_COLLECTIVE != var->parallel_access)
@@ -755,12 +755,12 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
               /* Reach consensus about dimension sizes to extend to */
               /* (Note: Somewhat hackish, with the use of MPI_INTEGER, but MPI_MAX is
                *        correct with this usage, as long as it's not executed on
-               *        heterogenous systems)
+               *        heterogeneous systems)
                */
               if(MPI_SUCCESS != MPI_Allreduce(MPI_IN_PLACE, &xtend_size, (var->ndims * (sizeof(hsize_t) / sizeof(int))), MPI_UNSIGNED, MPI_MAX, h5->comm))
                 BAIL(NC_EMPI);
             }
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
           if (H5Dset_extent(var->hdf_datasetid, xtend_size) < 0)
             BAIL(NC_EHDFERR);
           if (file_spaceid > 0 && H5Sclose(file_spaceid) < 0)
@@ -1075,7 +1075,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
         BAIL(NC_EHDFERR);
 #endif
 
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
       /* Set up parallel I/O, if needed. */
       if ((retval = set_par_access(h5, var, xfer_plistid)))
         BAIL(retval);
@@ -1743,7 +1743,7 @@ nc4_adjust_var_cache(NC_GRP_INFO_T *grp, NC_VAR_INFO_T * var)
   /* Nothing to be done. */
   if (var->contiguous)
     return NC_NOERR;
-#ifdef USE_PARALLEL
+#ifdef USE_PARALLEL4
   return NC_NOERR;
 #endif
 
diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c
index 1d282ad..2d30f51 100644
--- a/libsrc4/nc4var.c
+++ b/libsrc4/nc4var.c
@@ -931,6 +931,10 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
 
 	 if ((retval = check_chunksizes(grp, var, chunksizes)))
 	    return retval;
+	 for (d = 0; d < var->ndims; d++) {
+	    if(var->dim[d]->len > 0 && chunksizes[d] > var->dim[d]->len)
+	       return NC_EBADCHUNK;
+	 }
 
 	 /* Set the chunksizes for this variable. */
 	 for (d = 0; d < var->ndims; d++)
@@ -1293,7 +1297,7 @@ NC4_rename_var(int ncid, int varid, const char *name)
 int
 NC4_var_par_access(int ncid, int varid, int par_access) 
 {
-#ifndef USE_PARALLEL
+#ifndef USE_PARALLEL4
    return NC_ENOPAR;
 #else
    NC *nc; 
@@ -1343,7 +1347,7 @@ NC4_var_par_access(int ncid, int varid, int par_access)
    else
       var->parallel_access = NC_INDEPENDENT;
    return NC_NOERR;
-#endif /* USE_PARALLEL */
+#endif /* USE_PARALLEL4 */
 }
 
 static int
diff --git a/libsrc4/ncfunc.c b/libsrc4/ncfunc.c
index a6a9fcd..8fb7fb1 100644
--- a/libsrc4/ncfunc.c
+++ b/libsrc4/ncfunc.c
@@ -84,9 +84,9 @@ NC4_inq_format_extended(int ncid, int *formatp, int *modep)
    if(formatp) {
 #ifdef USE_HDF4
 	/* Distinguish HDF5 from HDF4 */
-	*formatp = (h5->hdf4 ? NC_FORMAT_NC_HDF4 : NC_FORMAT_NC_HDF5);
+	*formatp = (h5->hdf4 ? NC_FORMATX_NC_HDF4 : NC_FORMATX_NC_HDF5);
 #else /* USE_HDF4 */
-	*formatp = NC_FORMAT_NC_HDF5;
+	*formatp = NC_FORMATX_NC_HDF5;
 #endif /* USE_HDF4 */
    }
    return NC_NOERR;
diff --git a/libsrcp/Makefile.in b/libsrcp/Makefile.in
index d804bbc..b20eb9b 100644
--- a/libsrcp/Makefile.in
+++ b/libsrcp/Makefile.in
@@ -245,6 +245,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -277,6 +278,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -288,6 +290,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/libsrcp/ncpdispatch.c b/libsrcp/ncpdispatch.c
index c3a9494..a4e8c3e 100644
--- a/libsrcp/ncpdispatch.c
+++ b/libsrcp/ncpdispatch.c
@@ -1,6 +1,6 @@
-/********************************************************************* *   Copyright 1993, UCAR/Unidata
+/*********************************************************************
+ *   Copyright 1993, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Header: /upc/share/CVS/netcdf-3/libsrc4/NCPdispatch.c,v 1.5 2010/05/27 02:19:37 dmh Exp $
  *********************************************************************/
 
 /* WARNING: Order of mpi.h, nc.h, and pnetcdf.h is important */
@@ -29,9 +29,10 @@ typedef struct NCP_INFO
 #define NCP_DATA(nc) ((NCP_INFO*)(nc)->dispatchdata)
 #define NCP_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
 
-#define LEGAL_CREATE_FLAGS (NC_NOCLOBBER | NC_64BIT_OFFSET | NC_CLASSIC_MODEL | NC_SHARE | NC_MPIIO | NC_MPIPOSIX | NC_LOCK | NC_PNETCDF)
+/* Cannot have NC_MPIPOSIX flag, ignore NC_MPIIO as PnetCDF use MPIIO */
+static const int LEGAL_CREATE_FLAGS = (NC_NOCLOBBER | NC_64BIT_OFFSET | NC_CLASSIC_MODEL | NC_SHARE | NC_LOCK | NC_64BIT_DATA | NC_MPIIO);
 
-#define LEGAL_OPEN_FLAGS (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_MPIIO | NC_MPIPOSIX | NC_LOCK | NC_PNETCDF | NC_CLASSIC_MODEL | NC_64BIT_OFFSET)
+static const int LEGAL_OPEN_FLAGS = (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_LOCK | NC_CLASSIC_MODEL | NC_64BIT_OFFSET | NC_64BIT_DATA | NC_MPIIO);
 
 
 /**************************************************/
@@ -42,8 +43,8 @@ NCP_create(const char *path, int cmode,
 	  int use_parallel, void* mpidata,
 	  struct NC_Dispatch* table, NC* nc)
 {
-    int res;
-    NCP_INFO* ncp;
+    int res, default_format;
+    NCP_INFO* nc5;
     MPI_Comm comm = MPI_COMM_WORLD;
     MPI_Info info = MPI_INFO_NULL;
 
@@ -55,42 +56,50 @@ NCP_create(const char *path, int cmode,
     if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
 	return NC_EINVAL;
 
-    /* Appears that this comment is wrong; allow 64 bit offset*/
-    /* Cannot have 64 bit offset flag */
-    /*if(cmode & (NC_64BIT_OFFSET)) return NC_EINVAL;*/
+    /* Cannot have both NC_64BIT_OFFSET & NC_64BIT_DATA */
+    if((cmode & (NC_64BIT_OFFSET|NC_64BIT_DATA)) == (NC_64BIT_OFFSET|NC_64BIT_DATA))
+ 	return NC_EINVAL;
+
+    default_format = nc_get_default_format();
+    /* if (default_format == NC_FORMAT_CLASSIC) then we respect the format set in cmode */
+    if (default_format == NC_FORMAT_64BIT_OFFSET) {
+        if (! (cmode & NC_64BIT_OFFSET)) /* check if cmode has NC_64BIT_OFFSET already */
+            cmode |= NC_64BIT_OFFSET;
+    }
+    else if (default_format == NC_FORMAT_CDF5) {
+        if (! (cmode & NC_64BIT_DATA)) /* check if cmode has NC_64BIT_DATA already */
+            cmode |= NC_64BIT_DATA;
+    }
+
+    /* No MPI environment initialized */
+    if (mpidata == NULL) return NC_ENOPAR;
 
     comm = ((NC_MPI_INFO *)mpidata)->comm;
     info = ((NC_MPI_INFO *)mpidata)->info;
 
     /* Create our specific NCP_INFO instance */
-    ncp = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
-    if(ncp == NULL) return NC_ENOMEM;
+    nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
+    if(nc5 == NULL) return NC_ENOMEM;
 
-    /* Link ncp and nc */
-    NCP_DATA_SET(nc,ncp);
+    /* Link nc5 and nc */
+    NCP_DATA_SET(nc,nc5);
 
     /* Fix up the cmode by keeping only essential flags;
        these are the flags that are the same in netcf.h and pnetcdf.h
     */
-#if 0
-    cmode &= (NC_WRITE | NC_NOCLOBBER | NC_LOCK | NC_SHARE | NC_64BIT_OFFSET);
-#else
-    cmode &= (NC_WRITE | NC_NOCLOBBER | NC_LOCK | NC_SHARE );
-#endif
-
     /* It turns out that pnetcdf.h defines a flag called
        NC_64BIT_DATA (not to be confused with NC_64BIT_OFFSET).
        This flag is essential to getting ncmpi_create to create
        a proper pnetcdf format file.
-       It just happens that the value of NC_64BIT_DATA is the same
-       as the netcdf NC_NETCDF4 flag value. This is probably no accident.
-
+       We have set the value of NC_64BIT_DATA to be the same as in pnetcdf.h
+       (as of pnetcdf version 1.6.0) to avoid conflicts.
        In any case, this flag must be set.
     */
-    cmode |= (NC_NETCDF4);
+    /* PnetCDF recognizes the flags below for create and ignores NC_LOCK and  NC_SHARE */
+    cmode &= (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_64BIT_OFFSET | NC_64BIT_DATA);
     res = ncmpi_create(comm, path, cmode, info, &(nc->int_ncid));
 
-    if(res && ncp != NULL) free(ncp); /* reclaim allocated space */
+    if(res && nc5 != NULL) free(nc5); /* reclaim allocated space */
     return res;
 }
 
@@ -101,7 +110,7 @@ NCP_open(const char *path, int cmode,
 	    struct NC_Dispatch* table, NC* nc)
 {
     int res;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     MPI_Comm comm = MPI_COMM_WORLD;
     MPI_Info info = MPI_INFO_NULL;
 
@@ -125,26 +134,28 @@ NCP_open(const char *path, int cmode,
 	info = MPI_INFO_NULL;
     }
 
-    /* Fix up the cmode by keeping only essential flags;
-       these are the flags that are the same in netcf.h and pnetcdf.h
-    */
-    cmode &= (NC_WRITE | NC_NOCLOBBER | NC_LOCK | NC_SHARE | NC_64BIT_OFFSET);
+   /* PnetCDF recognizes the flags NC_WRITE and NC_NOCLOBBER for file open
+     * and ignores NC_LOCK, NC_SHARE, NC_64BIT_OFFSET, and NC_64BIT_DATA.
+     * Ignoring the NC_64BIT_OFFSET and NC_64BIT_DATA flags is because the
+     * file is already in one of the CDF-formats, and setting these 2 flags
+     * will not change the format of that file.
+     */
 
-    cmode |= (NC_NETCDF4); /* see comment in NCP_create */
+    cmode &= (NC_WRITE | NC_NOCLOBBER);
 
     /* Create our specific NCP_INFO instance */
-    ncp = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
-    if(ncp == NULL) return NC_ENOMEM;
+    nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
+    if(nc5 == NULL) return NC_ENOMEM;
 
-    /* Link ncp and nc */
-    NCP_DATA_SET(nc,ncp);
+    /* Link nc5 and nc */
+    NCP_DATA_SET(nc,nc5);
 
     res = ncmpi_open(comm, path, cmode, info, &(nc->int_ncid));
 
     /* Default to independent access, like netCDF-4/HDF5 files. */
     if(!res) {
 	res = ncmpi_begin_indep_data(nc->int_ncid);
-	ncp->pnetcdf_access_mode = NC_INDEPENDENT;
+	nc5->pnetcdf_access_mode = NC_INDEPENDENT;
     }
 
     return res;
@@ -160,34 +171,40 @@ NCP_redef(int ncid)
 }
 
 static int
-NCP_enddef(int ncid)
+NCP__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
 {
     int status;
     NC* nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
+    MPI_Offset mpi_h_minfree = h_minfree;
+    MPI_Offset mpi_v_align   = v_align;
+    MPI_Offset mpi_v_minfree = v_minfree;
+    MPI_Offset mpi_r_align   = r_align;
 
     status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR)
 	return status;
 
-    ncp = NCP_DATA(nc);
-    assert(ncp);
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
 
+    /* causes implicitly defined warning; may be because of old installed pnetcdf? */
+#if 0
+    /* In PnetCDF ncmpi__enddef() is only implemented in v1.5.0 and later */
+    status = ncmpi__enddef(nc->int_ncid, mpi_h_minfree, mpi_v_align,
+                           mpi_v_minfree, mpi_r_align);
+#else
     status = ncmpi_enddef(nc->int_ncid);
+#endif
+
     if(!status) {
-	if (ncp->pnetcdf_access_mode == NC_INDEPENDENT)
+	if (nc5->pnetcdf_access_mode == NC_INDEPENDENT)
 	    status = ncmpi_begin_indep_data(nc->int_ncid);
     }
     return status;
 }
 
 static int
-NCP__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
-{
-    return NCP_enddef(ncid);
-}
-
-static int
 NCP_sync(int ncid)
 {
     NC* nc;
@@ -200,15 +217,15 @@ static int
 NCP_abort(int ncid)
 {
     NC* nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     int status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) goto done;
 
     status = ncmpi_abort(nc->int_ncid);
 
 done:
-    ncp = NCP_DATA(nc);
-    if(ncp != NULL) free(ncp); /* reclaim allocated space */
+    nc5 = NCP_DATA(nc);
+    if(nc5 != NULL) free(nc5); /* reclaim allocated space */
     return status;
 }
 
@@ -217,15 +234,15 @@ static int
 NCP_close(int ncid)
 {
     NC* nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     int status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) goto done;
 
     status = ncmpi_close(nc->int_ncid);
 
 done:
-    ncp = NCP_DATA(nc);
-    if(ncp != NULL) free(ncp); /* reclaim allocated space */
+    nc5 = NCP_DATA(nc);
+    if(nc5 != NULL) free(nc5); /* reclaim allocated space */
     return status;
 }
 
@@ -257,7 +274,8 @@ NCP_inq_format(int ncid, int* formatp)
     NC* nc;
     int status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) return status;
-    return ncmpi_inq_format(nc->int_ncid,formatp);
+    status = ncmpi_inq_format(nc->int_ncid,formatp);
+    return status;
 }
 
 static int
@@ -267,7 +285,8 @@ NCP_inq_format_extended(int ncid, int* formatp, int *modep)
     int status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) return status;
     if(modep) *modep = nc->mode;
-    if(formatp) *formatp = NC_FORMAT_PNETCDF;
+    /* Note that we do not use NC_FORMAT_CDF5 because PNETCDF has a dispatch table */
+    if(formatp) *formatp = NC_FORMATX_PNETCDF;
     return NC_NOERR;
 }
 
@@ -284,28 +303,17 @@ NCP_inq(int ncid,
     return ncmpi_inq(nc->int_ncid,ndimsp,nvarsp,nattsp,unlimp);
 }
 
-static int
-atomic_size[6] = {
-1, 1, 2, 4, 4, 8
-};
-static char
-atomic_name[6][NC_MAX_NAME + 1] = {
-"byte", "char", "short","int", "float", "double"
-};
 
 static int
 NCP_inq_type(int ncid, nc_type typeid, char* name, size_t* size)
 {
-   if(typeid < NC_BYTE || typeid > NC_DOUBLE)
-      return NC_EBADTYPE;
-
-   /* Give the user the values they want. Subtract one because types
-    * are numbered starting at 1, not 0. */
-   if(name)
-      strcpy(name, atomic_name[typeid - 1]);
-   if(size)
-      *size = atomic_size[typeid - 1];
-
+    /* Assert mode & NC_FORMAT_CDF5 */
+    if (typeid < NC_BYTE || typeid >= NC_STRING)
+           return NC_EBADTYPE;
+    if(name)
+	strcpy(name, NC_atomictypename(typeid));
+    if(size)
+        *size = NC_atomictypelen(typeid);
    return NC_NOERR;
 }
 
@@ -313,15 +321,15 @@ static int
 NCP_def_dim(int ncid, const char* name, size_t len, int* idp)
 {
     int status;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     NC* nc;
 
     status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR)
 	return status;
 
-    ncp = NCP_DATA(nc);
-    assert(ncp);
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
 
     return ncmpi_def_dim(nc->int_ncid, name, len, idp);
 }
@@ -372,6 +380,7 @@ NCP_inq_att(int ncid, int varid, const char* name, nc_type* xtypep, size_t* lenp
     NC* nc;
     MPI_Offset mpilen;
     int status = NC_check_id(ncid, &nc);
+    if(status != NC_NOERR) return status;
     status = ncmpi_inq_att(nc->int_ncid,varid,name,xtypep,&mpilen);
     if(status != NC_NOERR) return status;
     if(lenp) *lenp = mpilen;
@@ -448,10 +457,16 @@ NCP_get_att(
         return ncmpi_get_att_float(nc->int_ncid, varid, name, (float*)ip);
     case NC_DOUBLE:
         return ncmpi_get_att_double(nc->int_ncid, varid, name, (double*)ip);
-    case NC_INT64: /* synthetic */
-        return ncmpi_get_att_long(nc->int_ncid, varid, name, (long*)ip);
-    case NC_UBYTE: /* Synthetic */
-        return ncmpi_get_att_uchar(nc->int_ncid, varid, name, (unsigned char*)ip);
+    case NC_UBYTE:
+         return ncmpi_get_att_uchar(nc->int_ncid, varid, name, (unsigned char*)ip);
+    case NC_USHORT:
+        return ncmpi_get_att_ushort(nc->int_ncid, varid, name, (unsigned short*)ip);
+    case NC_UINT:
+        return ncmpi_get_att_uint(nc->int_ncid, varid, name, (unsigned int*)ip);
+    case NC_INT64:
+        return ncmpi_get_att_longlong(nc->int_ncid, varid, name, (long long*)ip);
+    case NC_UINT64:
+        return ncmpi_get_att_ulonglong(nc->int_ncid, varid, name, (unsigned long long*)ip);
     default:
 	break;
     }
@@ -498,10 +513,16 @@ NCP_put_att(
         return ncmpi_put_att_float(nc->int_ncid, varid, name, xtype, mpilen, (float*)ip);
     case NC_DOUBLE:
         return ncmpi_put_att_double(nc->int_ncid, varid, name, xtype, mpilen, (double*)ip);
-    case NC_INT64: /* synthetic */
-        return ncmpi_put_att_long(nc->int_ncid, varid, name, xtype, mpilen, (long*)ip);
-    case NC_UBYTE: /* Synthetic */
-        return ncmpi_put_att_uchar(nc->int_ncid, varid, name, xtype, mpilen, (unsigned char*)ip);
+    case NC_UBYTE:
+         return ncmpi_put_att_uchar(nc->int_ncid, varid, name, xtype, mpilen, (unsigned char*)ip);
+    case NC_USHORT:
+        return ncmpi_put_att_ushort(nc->int_ncid, varid, name, xtype, mpilen, (unsigned short*)ip);
+    case NC_UINT:
+        return ncmpi_put_att_uint(nc->int_ncid, varid, name, xtype, mpilen, (unsigned int*)ip);
+    case NC_INT64:
+        return ncmpi_put_att_longlong(nc->int_ncid, varid, name, xtype, mpilen, (long long*)ip);
+    case NC_UINT64:
+        return ncmpi_put_att_ulonglong(nc->int_ncid, varid, name, xtype, mpilen, (unsigned long long*)ip);
     default:
 	break;
     }
@@ -513,13 +534,13 @@ NCP_def_var(int ncid, const char *name, nc_type xtype,
 	    int ndims, const int *dimidsp, int *varidp)
 {
     NC* nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     int status;
 
     status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) return status;
-    ncp = NCP_DATA(nc);
-    assert(ncp);
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
 
     status = ncmpi_def_var(nc->int_ncid,name,xtype,ndims,dimidsp,varidp);
     return status;
@@ -552,7 +573,7 @@ NCP_get_vara(int ncid,
 		nc_type memtype)
 {
     NC* nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     int status;
     MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS];
     int d;
@@ -561,20 +582,25 @@ NCP_get_vara(int ncid,
     status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) return status;
 
-    ncp = NCP_DATA(nc);
-    assert(ncp);
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
 
     /* get variable's rank */
     status= ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
     if(status) return status;
 
-    /* We must convert the start, count, and stride arrays to MPI_Offset type. */
+    /* We must convert the start and count arrays to MPI_Offset type. */
     for (d = 0; d < rank; d++) {
 	 mpi_start[d] = startp[d];
 	 mpi_count[d] = countp[d];
     }
 
-    if(ncp->pnetcdf_access_mode == NC_INDEPENDENT) {
+    if (memtype == NC_NAT) {
+        status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
+        if (status) return status;
+    }
+
+    if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
 	switch(memtype) {
 	case NC_BYTE:
 	    status=ncmpi_get_vara_schar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
@@ -588,10 +614,16 @@ NCP_get_vara(int ncid,
 	    status=ncmpi_get_vara_float(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	case NC_DOUBLE:
 	    status=ncmpi_get_vara_double(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
-	case NC_UBYTE: /* synthetic */
-	    status=ncmpi_get_vara_uchar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
-	case NC_INT64: /* synthetic */
-	    status=ncmpi_get_vara_long(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UBYTE:
+ 	    status=ncmpi_get_vara_uchar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_USHORT:
+	    status=ncmpi_get_vara_ushort(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT:
+	    status=ncmpi_get_vara_uint(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_INT64:
+	    status=ncmpi_get_vara_longlong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT64:
+	    status=ncmpi_get_vara_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	default:
 	    status = NC_EBADTYPE;
 	}
@@ -611,8 +643,14 @@ NCP_get_vara(int ncid,
 	    status=ncmpi_get_vara_double_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	case NC_UBYTE:
 	    status=ncmpi_get_vara_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
-	case NC_INT64:
-	    status=ncmpi_get_vara_long_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_USHORT:
+	    status=ncmpi_get_vara_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT:
+	    status=ncmpi_get_vara_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+ 	case NC_INT64:
+	    status=ncmpi_get_vara_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT64:
+	    status=ncmpi_get_vara_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	default:
 	    status = NC_EBADTYPE;
 	}
@@ -629,7 +667,7 @@ NCP_put_vara(int ncid,
 	nc_type memtype)
 {
     NC* nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     int status;
     MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS];
     int d;
@@ -638,20 +676,25 @@ NCP_put_vara(int ncid,
     status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) return status;
 
-    ncp = NCP_DATA(nc);
-    assert(ncp);
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
 
     /* get variable's rank */
     status = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
     if(status) return status;
 
-    /* We must convert the start, count, and stride arrays to MPI_Offset type. */
+    /* We must convert the start and count arrays to MPI_Offset type. */
     for (d = 0; d < rank; d++) {
 	 mpi_start[d] = startp[d];
 	 mpi_count[d] = countp[d];
     }
 
-    if(ncp->pnetcdf_access_mode == NC_INDEPENDENT) {
+    if (memtype == NC_NAT) {
+        status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
+        if (status) return status;
+    }
+
+    if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
 	switch(memtype) {
 	case NC_BYTE:
 	    status = ncmpi_put_vara_schar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
@@ -667,8 +710,14 @@ NCP_put_vara(int ncid,
 	    status = ncmpi_put_vara_double(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	case NC_UBYTE:
 	    status = ncmpi_put_vara_uchar(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_USHORT:
+	    status = ncmpi_put_vara_ushort(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT:
+	    status = ncmpi_put_vara_uint(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	case NC_INT64:
-	    status = ncmpi_put_vara_long(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+      status = ncmpi_put_vara_longlong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT64:
+	    status = ncmpi_put_vara_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	default:
 	    status = NC_EBADTYPE;
 	}
@@ -688,8 +737,402 @@ NCP_put_vara(int ncid,
 	    status = ncmpi_put_vara_double_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
 	case NC_UBYTE:
 	    status = ncmpi_put_vara_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_USHORT:
+	    status = ncmpi_put_vara_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT:
+	    status = ncmpi_put_vara_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+ 	case NC_INT64:
+	    status = ncmpi_put_vara_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	case NC_UINT64:
+	    status = ncmpi_put_vara_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+    }
+    return status;
+}
+
+static int
+NCP_get_vars(int ncid,
+		int varid,
+		const size_t* startp,
+		const size_t* countp,
+		const ptrdiff_t* stridep,
+		void* ip,
+		nc_type memtype)
+{
+    NC* nc;
+    NCP_INFO* nc5;
+    int status;
+    MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS];
+    int d;
+    int rank = 0;
+
+    status = NC_check_id(ncid, &nc);
+    if(status != NC_NOERR) return status;
+
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
+
+    /* get variable's rank */
+    status= ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
+    if(status) return status;
+
+    /* We must convert the start, count, and stride arrays to MPI_Offset type. */
+    for (d = 0; d < rank; d++) {
+	 mpi_start[d] = startp[d];
+	 mpi_count[d] = countp[d];
+	 mpi_stride[d] = stridep[d];
+    }
+
+    if (memtype == NC_NAT) {
+        status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
+        if (status) return status;
+    }
+
+    if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
+	switch(memtype) {
+	case NC_BYTE:
+	    status=ncmpi_get_vars_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_CHAR:
+	    status=ncmpi_get_vars_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_SHORT:
+	    status=ncmpi_get_vars_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT:
+	    status=ncmpi_get_vars_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_FLOAT:
+	    status=ncmpi_get_vars_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_DOUBLE:
+	    status=ncmpi_get_vars_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UBYTE:
+	    status=ncmpi_get_vars_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_USHORT:
+	    status=ncmpi_get_vars_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT:
+	    status=ncmpi_get_vars_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT64:
+	    status=ncmpi_get_vars_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT64:
+	    status=ncmpi_get_vars_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+      } else {
+	switch(memtype) {
+	case NC_BYTE:
+	    status=ncmpi_get_vars_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_CHAR:
+	    status=ncmpi_get_vars_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_SHORT:
+	    status=ncmpi_get_vars_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT:
+	    status=ncmpi_get_vars_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_FLOAT:
+	    status=ncmpi_get_vars_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_DOUBLE:
+	    status=ncmpi_get_vars_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UBYTE:
+	    status=ncmpi_get_vars_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_USHORT:
+	    status=ncmpi_get_vars_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT:
+	    status=ncmpi_get_vars_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT64:
+	    status=ncmpi_get_vars_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT64:
+	    status=ncmpi_get_vars_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+    }
+    return status;
+}
+
+static int
+NCP_put_vars(int ncid,
+	int varid,
+	const size_t* startp,
+	const size_t* countp,
+	const ptrdiff_t* stridep,
+	const void*ip,
+	nc_type memtype)
+{
+    NC* nc;
+    NCP_INFO* nc5;
+    int status;
+    MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS];
+    int d;
+    int rank;
+
+    status = NC_check_id(ncid, &nc);
+    if(status != NC_NOERR) return status;
+
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
+
+    /* get variable's rank */
+    status = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
+    if(status) return status;
+
+    /* We must convert the start, count, and stride arrays to MPI_Offset type. */
+    for (d = 0; d < rank; d++) {
+	 mpi_start[d] = startp[d];
+	 mpi_count[d] = countp[d];
+	 mpi_stride[d] = stridep[d];
+    }
+
+    if (memtype == NC_NAT) {
+        status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
+        if (status) return status;
+    }
+
+    if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
+	switch(memtype) {
+	case NC_BYTE:
+	    status = ncmpi_put_vars_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_CHAR:
+	    status = ncmpi_put_vars_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_SHORT:
+	    status = ncmpi_put_vars_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT:
+	    status = ncmpi_put_vars_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_FLOAT:
+	    status = ncmpi_put_vars_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_DOUBLE:
+	    status = ncmpi_put_vars_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UBYTE:
+	    status = ncmpi_put_vars_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_USHORT:
+	    status = ncmpi_put_vars_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT:
+	    status = ncmpi_put_vars_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT64:
+	    status = ncmpi_put_vars_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT64:
+	    status = ncmpi_put_vars_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+      } else {
+	switch(memtype) {
+	case NC_BYTE:
+	    status = ncmpi_put_vars_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_CHAR:
+	    status = ncmpi_put_vars_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_SHORT:
+	    status = ncmpi_put_vars_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT:
+	    status = ncmpi_put_vars_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_FLOAT:
+	    status = ncmpi_put_vars_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_DOUBLE:
+	    status = ncmpi_put_vars_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UBYTE:
+	    status = ncmpi_put_vars_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_USHORT:
+	    status = ncmpi_put_vars_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT:
+	    status = ncmpi_put_vars_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_INT64:
+	    status = ncmpi_put_vars_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	case NC_UINT64:
+	    status = ncmpi_put_vars_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+    }
+    return status;
+}
+
+static int
+NCP_get_varm(int ncid,
+		int varid,
+		const size_t* startp,
+		const size_t* countp,
+		const ptrdiff_t* stridep,
+		const ptrdiff_t* imapp,
+		void* ip,
+		nc_type memtype)
+{
+    NC* nc;
+    NCP_INFO* nc5;
+    int status;
+    MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS], mpi_imap[NC_MAX_VAR_DIMS];
+    int d;
+    int rank = 0;
+
+    status = NC_check_id(ncid, &nc);
+    if(status != NC_NOERR) return status;
+
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
+
+    /* get variable's rank */
+    status= ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
+    if(status) return status;
+
+    /* We must convert the start, count, stride, and imap arrays to MPI_Offset type. */
+    for (d = 0; d < rank; d++) {
+	 mpi_start[d] = startp[d];
+	 mpi_count[d] = countp[d];
+	 mpi_stride[d] = stridep[d];
+	 mpi_imap[d] = imapp[d];
+    }
+
+    if (memtype == NC_NAT) {
+        status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
+        if (status) return status;
+    }
+
+    if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
+	switch(memtype) {
+	case NC_BYTE:
+	    status=ncmpi_get_varm_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_CHAR:
+	    status=ncmpi_get_varm_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_SHORT:
+	    status=ncmpi_get_varm_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT:
+	    status=ncmpi_get_varm_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_FLOAT:
+	    status=ncmpi_get_varm_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_DOUBLE:
+	    status=ncmpi_get_varm_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UBYTE:
+	    status=ncmpi_get_varm_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_USHORT:
+	    status=ncmpi_get_varm_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT:
+	    status=ncmpi_get_varm_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT64:
+	    status=ncmpi_get_varm_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT64:
+	    status=ncmpi_get_varm_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+      } else {
+	switch(memtype) {
+	case NC_BYTE:
+	    status=ncmpi_get_varm_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_CHAR:
+	    status=ncmpi_get_varm_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_SHORT:
+	    status=ncmpi_get_varm_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT:
+	    status=ncmpi_get_varm_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_FLOAT:
+	    status=ncmpi_get_varm_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_DOUBLE:
+	    status=ncmpi_get_varm_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UBYTE:
+	    status=ncmpi_get_varm_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_USHORT:
+	    status=ncmpi_get_varm_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT:
+	    status=ncmpi_get_varm_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT64:
+	    status=ncmpi_get_varm_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT64:
+	    status=ncmpi_get_varm_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+    }
+    return status;
+}
+
+static int
+NCP_put_varm(int ncid,
+	int varid,
+	const size_t* startp,
+	const size_t* countp,
+	const ptrdiff_t* stridep,
+	const ptrdiff_t* imapp,
+	const void*ip,
+	nc_type memtype)
+{
+    NC* nc;
+    NCP_INFO* nc5;
+    int status;
+    MPI_Offset mpi_start[NC_MAX_VAR_DIMS], mpi_count[NC_MAX_VAR_DIMS], mpi_stride[NC_MAX_VAR_DIMS], mpi_imap[NC_MAX_VAR_DIMS];
+    int d;
+    int rank;
+
+    status = NC_check_id(ncid, &nc);
+    if(status != NC_NOERR) return status;
+
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
+
+    /* get variable's rank */
+    status = ncmpi_inq_varndims(nc->int_ncid, varid, &rank);
+    if(status) return status;
+
+    /* We must convert the start, count, stride, and imap arrays to MPI_Offset type. */
+    for (d = 0; d < rank; d++) {
+	 mpi_start[d] = startp[d];
+	 mpi_count[d] = countp[d];
+	 mpi_stride[d] = stridep[d];
+	 mpi_imap[d] = imapp[d];
+    }
+
+    if (memtype == NC_NAT) {
+        status = ncmpi_inq_vartype(nc->int_ncid, varid, &memtype);
+        if (status) return status;
+    }
+
+    if(nc5->pnetcdf_access_mode == NC_INDEPENDENT) {
+	switch(memtype) {
+	case NC_BYTE:
+	    status = ncmpi_put_varm_schar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_CHAR:
+	    status = ncmpi_put_varm_text(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_SHORT:
+	    status = ncmpi_put_varm_short(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT:
+	    status = ncmpi_put_varm_int(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_FLOAT:
+	    status = ncmpi_put_varm_float(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_DOUBLE:
+	    status = ncmpi_put_varm_double(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UBYTE:
+	    status = ncmpi_put_varm_uchar(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_USHORT:
+	    status = ncmpi_put_varm_ushort(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT:
+	    status = ncmpi_put_varm_uint(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT64:
+	    status = ncmpi_put_varm_longlong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT64:
+	    status = ncmpi_put_varm_ulonglong(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	default:
+	    status = NC_EBADTYPE;
+	}
+      } else {
+	switch(memtype) {
+	case NC_BYTE:
+	    status = ncmpi_put_varm_schar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_CHAR:
+	    status = ncmpi_put_varm_text_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_SHORT:
+	    status = ncmpi_put_varm_short_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_INT:
+	    status = ncmpi_put_varm_int_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_FLOAT:
+	    status = ncmpi_put_varm_float_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_DOUBLE:
+	    status = ncmpi_put_varm_double_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UBYTE:
+	    status = ncmpi_put_varm_uchar_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_USHORT:
+	    status = ncmpi_put_varm_ushort_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT:
+	    status = ncmpi_put_varm_uint_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
 	case NC_INT64:
-	    status = ncmpi_put_vara_long_all(nc->int_ncid, varid, mpi_start, mpi_count, ip); break;
+	    status = ncmpi_put_varm_longlong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
+	case NC_UINT64:
+	    status = ncmpi_put_varm_ulonglong_all(nc->int_ncid, varid, mpi_start, mpi_count, mpi_stride, mpi_imap, ip); break;
 	default:
 	    status = NC_EBADTYPE;
 	}
@@ -727,7 +1170,7 @@ static int
 NCP_var_par_access(int ncid, int varid, int par_access)
 {
     NC *nc;
-    NCP_INFO* ncp;
+    NCP_INFO* nc5;
     int status;
 
     if (par_access != NC_INDEPENDENT && par_access != NC_COLLECTIVE)
@@ -736,12 +1179,12 @@ NCP_var_par_access(int ncid, int varid, int par_access)
     status = NC_check_id(ncid, &nc);
     if(status != NC_NOERR) return status;
 
-    ncp = NCP_DATA(nc);
-    assert(ncp);
+    nc5 = NCP_DATA(nc);
+    assert(nc5);
 
-    if(par_access == ncp->pnetcdf_access_mode)
+    if(par_access == nc5->pnetcdf_access_mode)
 	return NC_NOERR;
-    ncp->pnetcdf_access_mode = par_access;
+    nc5->pnetcdf_access_mode = par_access;
     if (par_access == NC_INDEPENDENT)
 	return ncmpi_begin_indep_data(nc->int_ncid);
     else
@@ -792,7 +1235,7 @@ NCP_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, nc_type typeid2, int*
     }
 
     /* If both are atomic types, the answer is easy. */
-    if (typeid1 <= ATOMICTYPEMAX) {
+    if (typeid1 <= ATOMICTYPEMAX5) {
         if (equalp) {
             if (typeid1 == typeid2)
                 *equalp = 1;
@@ -894,7 +1337,7 @@ static int
 NCP_inq_typeid(int ncid, const char *name, nc_type *typeidp)
 {
     int i;
-    for (i = 0; i <= ATOMICTYPEMAX; i++)
+    for (i = 0; i <= ATOMICTYPEMAX5; i++)
         if(!strcmp(name, NC_atomictypename(i))) {
             if(typeidp) *typeidp = i;
                 return NC_NOERR;
@@ -1055,7 +1498,7 @@ NCP_def_var_endian(int ncid, int varid, int endianness)
 
 NC_Dispatch NCP_dispatcher = {
 
-NC_DISPATCH_NCP,
+NC_FORMATX_PNETCDF,
 
 NCP_create,
 NCP_open,
@@ -1093,10 +1536,10 @@ NCP_inq_varid,
 NCP_rename_var,
 NCP_get_vara,
 NCP_put_vara,
-NCDEFAULT_get_vars,
-NCDEFAULT_put_vars,
-NCDEFAULT_get_varm,
-NCDEFAULT_put_varm,
+NCP_get_vars,
+NCP_put_vars,
+NCP_get_varm,
+NCP_put_varm,
 
 NCP_inq_var_all,
 
@@ -1153,3 +1596,9 @@ NCP_initialize(void)
     NCP_dispatch_table = &NCP_dispatcher;
     return NC_NOERR;
 }
+
+int
+NCP_finalize(void)
+{
+    return NC_NOERR;
+}
diff --git a/ljna b/ljna
deleted file mode 100644
index 4b6b039..0000000
--- a/ljna
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-# Define where the installation will be
-PREFIX=/home/dmh/opt/jna
-#PREFIX=/opt/netcdf
-
-# Define where to look for e.g. libz or libhdf5
-LIBDIR=/usr/local/lib
-
-CFLAGS=""
-CPPFLAGS="-I${PREFIX}/include"
-
-LDFLAGS="-L${LIBDIR} -lhdf5_hl -lhdf5 -lz $LDFLAGS"
-LD_LIBRARY_PATH="${LIBDIR}:$LD_LIBRARY_PATH"
-
-MAKE=make
-
-FLAGS="--prefix ${PREFIX}"
-FLAGS="$FLAGS --disable-examples"
-FLAGS="$FLAGS --disable-utilities"
-FLAGS="$FLAGS --enable-shared"
-#FLAGS="$FLAGS --enable-jna"
-
-export PATH
-export CC
-export CPPFLAGS
-export CFLAGS
-export LDFLAGS
-export LD_LIBRARY_PATH
-
-if test -f Makefile ; then ${MAKE} distclean >/dev/null 2>&1 ; fi
-sh ./configure ${FLAGS}
-
diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt
index 3831cbe..0f84673 100644
--- a/nc_test/CMakeLists.txt
+++ b/nc_test/CMakeLists.txt
@@ -35,7 +35,9 @@ ENDIF()
 IF(USE_PNETCDF)
   build_bin_test_no_prefix(tst_pnetcdf)
   build_bin_test_no_prefix(tst_parallel2)
+  build_bin_test_no_prefix(tst_addvar)
   add_sh_test(nc_test run_pnetcdf_test)
+  add_bin_test(nc_test tst_formatx_pnetcdf)
 ENDIF()
 
 IF(LARGE_FILE_TESTS)
diff --git a/nc_test/Make0 b/nc_test/Make0
index 51a9802..c60b85e 100644
--- a/nc_test/Make0
+++ b/nc_test/Make0
@@ -1,14 +1,34 @@
 # Test c output
-T=test_read
-#VG=valgrind --leak-check=full
+T=t
+#CMD=valgrind --leak-check=full
+
+#CMD=gdb --args
+
+CC=mpicc
 
 CFLAGS=-g -O0 -I.. -I../include
-LDFLAGS=../liblib/.libs/libnetcdf.a  -L/usr/local/lib -lhdf5_hl -lhdf5 -lz -lm -lcurl
+#LDFLAGS=../liblib/.libs/libnetcdf.a  -L/usr/local/lib -lhdf5_hl -lhdf5 -lz -lm -lcurl
+
+LDFLAGS=-L/usr/local/lib -lhdf5_hl -lhdf5 -lz  ../liblib/.libs/libnetcdf.a -ldl -lm -lcurl
+
+CC=/usr/local/bin/mpicc
+LDFLAGS=-L/usr/local/lib -lhdf5_hl -lhdf5 -lz  ../liblib/.libs/libnetcdf.a -ldl -lcurl -lpnetcdf -lmpich -lm
 
 #	cd .. ; ${MAKE} all
 
+LLP=/usr/local/lib:${LD_LIBRARY_PATH}
+
 all::
-	export LD_RUN_PATH; export CFLAGS; export LDFLAGS; \
-	gcc -o t ${CFLAGS} ${T}.c ${LDFLAGS}
-	${VG} ./t
+	echo ${LD_RUN_PATH}
+	export LD_LIBRARY_PATH=${LLP}; export CFLAGS; export LDFLAGS; \
+	${CC} -o t ${CFLAGS} ${T}.c ${LDFLAGS}; \
+	${CMD} ./t
+
+cpp::
+	${CC} -E ${CFLAGS} ${T}.c > ${T}.txt
 
+all::
+	echo ${LD_RUN_PATH}
+	export LD_LIBRARY_PATH=${LLP}; export CFLAGS; export LDFLAGS; \
+	gcc -o t ${CFLAGS} ${T}.c ${LDFLAGS}; \
+	${CMD} ./t
diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am
index 6060034..5532ac7 100644
--- a/nc_test/Makefile.am
+++ b/nc_test/Makefile.am
@@ -6,13 +6,15 @@
 
 # Put together AM_CPPFLAGS and AM_LDFLAGS.
 include $(top_srcdir)/lib_flags.am
+AM_CPPFLAGS += -I$(top_srcdir)/libsrc
 
 # These files are created by the tests.
 CLEANFILES = nc_test_classic.nc nc_test_64bit.nc nc_test_netcdf4.nc	\
 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 unlim.nc ncx.c
+tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc nc_test_cdf5.nc \
+unlim.nc
 
 # These are the tests which are always run.
 TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm \
@@ -24,7 +26,7 @@ TESTPROGRAMS += tst_atts tst_put_vars
 endif
 
 if USE_PNETCDF
-TESTPROGRAMS += tst_parallel2 tst_pnetcdf tst_formatx_pnetcdf
+TESTPROGRAMS += tst_parallel2 tst_pnetcdf tst_addvar tst_formatx_pnetcdf
 endif
 
 # These are the source files for the main workhorse test program,
@@ -100,6 +102,8 @@ EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt
 all:
 	cp $(top_srcdir)/libsrc/ncx.c .
 
+CLEANFILES += ncx.c
+
 # This rule tells make how to turn our .m4 files into .c files.
 .m4.c:
-	m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >$@
+	m4 $(AM_M4FLAGS) $(M4FLAGS) $< >$@
diff --git a/nc_test/Makefile.in b/nc_test/Makefile.in
index 058b676..fbdc0ec 100644
--- a/nc_test/Makefile.in
+++ b/nc_test/Makefile.in
@@ -106,7 +106,7 @@ target_triplet = @target@
 # This turns on declspec magic in netcdf.h for windows DLLs.
 @BUILD_DLL_TRUE at am__append_2 = -DDLL_NETCDF
 @USE_NETCDF4_TRUE at am__append_3 = tst_atts tst_put_vars
- at USE_PNETCDF_TRUE@am__append_4 = tst_parallel2 tst_pnetcdf tst_formatx_pnetcdf
+ at USE_PNETCDF_TRUE@am__append_4 = tst_parallel2 tst_pnetcdf tst_addvar tst_formatx_pnetcdf
 
 # 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	\
@@ -142,7 +142,7 @@ CONFIG_CLEAN_VPATH_FILES =
 @USE_NETCDF4_TRUE at am__EXEEXT_1 = tst_atts$(EXEEXT) \
 @USE_NETCDF4_TRUE@	tst_put_vars$(EXEEXT)
 @USE_PNETCDF_TRUE at am__EXEEXT_2 = tst_parallel2$(EXEEXT) \
- at USE_PNETCDF_TRUE@	tst_pnetcdf$(EXEEXT) \
+ at USE_PNETCDF_TRUE@	tst_pnetcdf$(EXEEXT) tst_addvar$(EXEEXT) \
 @USE_PNETCDF_TRUE@	tst_formatx_pnetcdf$(EXEEXT)
 @LARGE_FILE_TESTS_TRUE at am__EXEEXT_3 = quick_large_files$(EXEEXT) \
 @LARGE_FILE_TESTS_TRUE@	tst_big_var6$(EXEEXT) \
@@ -188,6 +188,10 @@ am__testnc3perf_SOURCES_DIST = testnc3perf.c
 testnc3perf_OBJECTS = $(am_testnc3perf_OBJECTS)
 testnc3perf_LDADD = $(LDADD)
 testnc3perf_DEPENDENCIES = ${top_builddir}/liblib/libnetcdf.la
+tst_addvar_SOURCES = tst_addvar.c
+tst_addvar_OBJECTS = tst_addvar.$(OBJEXT)
+tst_addvar_LDADD = $(LDADD)
+tst_addvar_DEPENDENCIES = ${top_builddir}/liblib/libnetcdf.la
 tst_atts_SOURCES = tst_atts.c
 tst_atts_OBJECTS = tst_atts.$(OBJEXT)
 tst_atts_LDADD = $(LDADD)
@@ -316,21 +320,21 @@ am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = large_files.c $(nc_test_SOURCES) quick_large_files.c t_nc.c \
-	$(testnc3perf_SOURCES) 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_formatx_pnetcdf.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
-DIST_SOURCES = large_files.c $(nc_test_SOURCES) quick_large_files.c \
-	t_nc.c $(am__testnc3perf_SOURCES_DIST) tst_atts.c tst_atts3.c \
+	$(testnc3perf_SOURCES) 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_formatx_pnetcdf.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
+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_formatx_pnetcdf.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
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -566,9 +570,11 @@ ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
 AMTAR = @AMTAR@
 AM_CFLAGS = @AM_CFLAGS@
+
+# Put together AM_CPPFLAGS and AM_LDFLAGS.
 AM_CPPFLAGS = -I$(top_srcdir)/include $(am__append_1) $(am__append_2) \
-	-I$(top_builddir)/liblib -I$(top_builddir)/include \
-	-I$(top_srcdir)/libsrc
+	-I$(top_srcdir)/libsrc -I$(top_builddir)/liblib \
+	-I$(top_builddir)/include -I$(top_srcdir)/libsrc
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AM_LDFLAGS = 
 AR = @AR@
@@ -613,6 +619,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -645,6 +652,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -656,6 +664,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -734,15 +743,13 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
-# Put together AM_CPPFLAGS and AM_LDFLAGS.
-
 # These files are created by the tests.
 CLEANFILES = nc_test_classic.nc nc_test_64bit.nc nc_test_netcdf4.nc \
 	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 unlim.nc \
-	ncx.c $(am__append_7)
+	tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc \
+	nc_test_cdf5.nc unlim.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 \
@@ -834,6 +841,10 @@ testnc3perf$(EXEEXT): $(testnc3perf_OBJECTS) $(testnc3perf_DEPENDENCIES) $(EXTRA
 	@rm -f testnc3perf$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(testnc3perf_OBJECTS) $(testnc3perf_LDADD) $(LIBS)
 
+tst_addvar$(EXEEXT): $(tst_addvar_OBJECTS) $(tst_addvar_DEPENDENCIES) $(EXTRA_tst_addvar_DEPENDENCIES) 
+	@rm -f tst_addvar$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(tst_addvar_OBJECTS) $(tst_addvar_LDADD) $(LIBS)
+
 tst_atts$(EXEEXT): $(tst_atts_OBJECTS) $(tst_atts_DEPENDENCIES) $(EXTRA_tst_atts_DEPENDENCIES) 
 	@rm -f tst_atts$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(tst_atts_OBJECTS) $(tst_atts_LDADD) $(LIBS)
@@ -942,6 +953,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_read.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_write.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/testnc3perf.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_addvar.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_atts.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_atts3.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_big_rvar.Po at am__quote@
@@ -1295,6 +1307,13 @@ tst_pnetcdf.log: tst_pnetcdf$(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_addvar.log: tst_addvar$(EXEEXT)
+	@p='tst_addvar$(EXEEXT)'; \
+	b='tst_addvar'; \
+	$(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_formatx_pnetcdf.log: tst_formatx_pnetcdf$(EXEEXT)
 	@p='tst_formatx_pnetcdf$(EXEEXT)'; \
 	b='tst_formatx_pnetcdf'; \
@@ -1577,7 +1596,7 @@ all:
 
 # This rule tells make how to turn our .m4 files into .c files.
 .m4.c:
-	m4 $(AM_M4FLAGS) $(M4FLAGS) -s $< >$@
+	m4 $(AM_M4FLAGS) $(M4FLAGS) $< >$@
 
 # 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.
diff --git a/nc_test/large_files.c b/nc_test/large_files.c
index fe47421..cd23526 100644
--- a/nc_test/large_files.c
+++ b/nc_test/large_files.c
@@ -48,7 +48,9 @@ main(int argc, char **argv) {
 
 #define NUMRECS 2
 #define I_LEN 5
-//#define J_LEN 214700000
+#if 0
+#define J_LEN 214700000
+#endif
 #define J_LEN   500000000
 #define K_LEN 1023
 #define N_LEN 2
@@ -103,7 +105,7 @@ main(int argc, char **argv) {
    var1_dims[0] = rec_dim;
    var1_dims[1] = i_dim;
    var1_dims[2] = j_dim;
-   //var1_dims[3] = k_dim;
+   /*var1_dims[3] = k_dim;*/
    stat = nc_def_var(ncid, "var1", NC_FLOAT, RANK_var1, var1_dims, &var1_id);
    check_err(stat,__LINE__,__FILE__);
 
@@ -116,7 +118,7 @@ main(int argc, char **argv) {
    check_err(stat,__LINE__,__FILE__);
 
    {			/* store var1 */
-     //static float var1[J_LEN];
+     /*static float var1[J_LEN];*/
      static float *var1 = NULL;
      var1 = malloc(sizeof(float)*J_LEN);
      if(!var1) {
@@ -156,7 +158,7 @@ main(int argc, char **argv) {
 
    {			/* read var1 */
      
-     //static float avar1[J_LEN];
+     /*static float avar1[J_LEN];*/
      static float *avar1 = NULL;
      avar1 = (float*)malloc(sizeof(float)*J_LEN);
      static size_t avar1_start[RANK_var1] = {0, 0, 0};
diff --git a/nc_test/nc_sync.c b/nc_test/nc_sync.c
index 8395927..e24bd05 100644
--- a/nc_test/nc_sync.c
+++ b/nc_test/nc_sync.c
@@ -120,7 +120,7 @@ nc_sync_sub(int ncid)
 
 	    pid = wait(&status);
 	}
-    }				/* successfull popen() */
+    }				/* successful popen() */
 
     return everythingOK ? 0 : 1;
 }
diff --git a/nc_test/nc_test.c b/nc_test/nc_test.c
index 65e2aae..bb1d1dd 100644
--- a/nc_test/nc_test.c
+++ b/nc_test/nc_test.c
@@ -1,9 +1,13 @@
 /*********************************************************************
  *   Copyright 1996-2005, UCAR/Unidata
  *   See COPYRIGHT file for copying and redistribution conditions.
- *   $Id: nc_test.c,v 1.44 2008/10/20 01:48:08 ed Exp $
+ *   $Id: nc_test.c 2796 2014-10-28 03:40:29Z wkliao $
  *********************************************************************/
 
+int numGatts;  /* number of global attributes */
+int numVars;   /* number of variables */
+int numTypes;  /* number of netCDF data types to test */
+
 #include "tests.h"
 
 /*
@@ -75,11 +79,7 @@ char scratch[] = "scratch.nc";  /* writable scratch file */
 
 /* Test everything for classic and 64-bit offsetfiles. If netcdf-4 is
  * included, that means another whole round of testing. */
-#ifdef USE_NETCDF4
-#define NUM_FORMATS (3)
-#else
-#define NUM_FORMATS (2)
-#endif
+#define NUM_FORMATS (5)
 
 int
 main(int argc, char *argv[])
@@ -87,6 +87,9 @@ main(int argc, char *argv[])
     int i;
     int  nfailsTotal = 0;        /* total number of failures */
 
+#ifdef USE_PNETCDF
+    MPI_Init(&argc, &argv);
+#endif
     /* Both CRAY MPP and OSF/1 Alpha systems need this.  Some of the
      * extreme test assignments in this program trigger floating point
      * exceptions on CRAY T90
@@ -96,9 +99,6 @@ main(int argc, char *argv[])
     verbose = 0;
     max_nmpt = 8;
 
-    /* Initialize global variables defining test file */
-    init_gvars();
-
     /* If you uncomment the nc_set_log_level line, you will get a lot
      * of debugging info. If you set the number higher, you'll get
      * more. 6 is max, 0 shows only errors. 3 is a good place to
@@ -114,6 +114,10 @@ main(int argc, char *argv[])
      * output of this program. */
     for (i = 1; i <= NUM_FORMATS; i++)
     {
+       numGatts = 6;
+       numVars  = 136;
+       numTypes = 6;
+
        switch (i) 
        {
 	  case NC_FORMAT_CLASSIC:
@@ -121,23 +125,37 @@ main(int argc, char *argv[])
 	     fprintf(stderr, "\n\nSwitching to netCDF classic format.\n");
 	     strcpy(testfile, "nc_test_classic.nc");
 	     break;
-	  case NC_FORMAT_64BIT:
-	     nc_set_default_format(NC_FORMAT_64BIT, NULL);
+	  case NC_FORMAT_64BIT_OFFSET:
+	     nc_set_default_format(NC_FORMAT_64BIT_OFFSET, NULL);
 	     fprintf(stderr, "\n\nSwitching to 64-bit offset format.\n");
 	     strcpy(testfile, "nc_test_64bit.nc");
 	     break;
-#ifdef USE_NETCDF4
+	  case NC_FORMAT_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;
+	  case NC_FORMAT_NETCDF4_CLASSIC:
 	  case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */
+#ifdef USE_NETCDF4
 	     nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL);
 	     strcpy(testfile, "nc_test_netcdf4.nc");
 	     fprintf(stderr, "\n\nSwitching to netCDF-4 format (with NC_CLASSIC_MODEL).\n");
 	     break;
+#else
+	     continue; /* loop i */
 #endif
 	  default:
 	     fprintf(stderr, "Unexpected format!\n");
 	     return 2;
        }
 
+       /* Initialize global variables defining test file */
+       init_gvars();
+
 	/* Write the test file, needed for the read-only tests below. */
        write_file(testfile);
 
@@ -172,6 +190,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_get_var_long);
 	NC_TEST(nc_get_var_float);
 	NC_TEST(nc_get_var_double);
+	NC_TEST(nc_get_var_ushort);
+	NC_TEST(nc_get_var_uint);
+	NC_TEST(nc_get_var_longlong);
+	NC_TEST(nc_get_var_ulonglong);
 	NC_TEST(nc_get_var1_text);
 	NC_TEST(nc_get_var1_uchar);
 	NC_TEST(nc_get_var1_schar);
@@ -180,6 +202,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_get_var1_long);
 	NC_TEST(nc_get_var1_float);
 	NC_TEST(nc_get_var1_double);
+	NC_TEST(nc_get_var1_ushort);
+	NC_TEST(nc_get_var1_uint);
+	NC_TEST(nc_get_var1_longlong);
+	NC_TEST(nc_get_var1_ulonglong);
 	NC_TEST(nc_get_var1);
 	NC_TEST(nc_get_vara_text);
 	NC_TEST(nc_get_vara_uchar);
@@ -189,6 +215,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_get_vara_long);
 	NC_TEST(nc_get_vara_float);
 	NC_TEST(nc_get_vara_double);
+	NC_TEST(nc_get_vara_ushort);
+	NC_TEST(nc_get_vara_uint);
+	NC_TEST(nc_get_vara_longlong);
+	NC_TEST(nc_get_vara_ulonglong);
 	NC_TEST(nc_get_vara);
 	NC_TEST(nc_get_vars_text);
 	NC_TEST(nc_get_vars_uchar);
@@ -198,6 +228,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_get_vars_long);
 	NC_TEST(nc_get_vars_float);
 	NC_TEST(nc_get_vars_double);
+	NC_TEST(nc_get_vars_ushort);
+	NC_TEST(nc_get_vars_uint);
+	NC_TEST(nc_get_vars_longlong);
+	NC_TEST(nc_get_vars_ulonglong);
 	NC_TEST(nc_get_vars);
 	NC_TEST(nc_get_varm_text);
 	NC_TEST(nc_get_varm_uchar);
@@ -207,6 +241,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_get_varm_long);
 	NC_TEST(nc_get_varm_float);
 	NC_TEST(nc_get_varm_double);
+	NC_TEST(nc_get_varm_ushort);
+	NC_TEST(nc_get_varm_uint);
+	NC_TEST(nc_get_varm_longlong);
+	NC_TEST(nc_get_varm_ulonglong);
 	NC_TEST(nc_get_varm);
 	NC_TEST(nc_get_att_text);
 	NC_TEST(nc_get_att_uchar);
@@ -216,6 +254,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_get_att_long);
 	NC_TEST(nc_get_att_float);
 	NC_TEST(nc_get_att_double);
+	NC_TEST(nc_get_att_ushort);
+	NC_TEST(nc_get_att_uint);
+	NC_TEST(nc_get_att_longlong);
+	NC_TEST(nc_get_att_ulonglong);
 	NC_TEST(nc_get_att);
 	NC_TEST(nc_inq_att);
 	NC_TEST(nc_inq_attname);
@@ -240,6 +282,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_put_var_long);
 	NC_TEST(nc_put_var_float);
 	NC_TEST(nc_put_var_double);
+	NC_TEST(nc_put_var_ushort);
+	NC_TEST(nc_put_var_uint);
+	NC_TEST(nc_put_var_longlong);
+	NC_TEST(nc_put_var_ulonglong);
 	NC_TEST(nc_put_var1_text);
 	NC_TEST(nc_put_var1_uchar);
 	NC_TEST(nc_put_var1_schar);
@@ -248,6 +294,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_put_var1_long);
 	NC_TEST(nc_put_var1_float);
 	NC_TEST(nc_put_var1_double);
+	NC_TEST(nc_put_var1_ushort);
+	NC_TEST(nc_put_var1_uint);
+	NC_TEST(nc_put_var1_longlong);
+	NC_TEST(nc_put_var1_ulonglong);
 	NC_TEST(nc_put_var1);
 	NC_TEST(nc_put_vara_text);
 	NC_TEST(nc_put_vara_uchar);
@@ -257,6 +307,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_put_vara_long);
 	NC_TEST(nc_put_vara_float);
 	NC_TEST(nc_put_vara_double);
+	NC_TEST(nc_put_vara_ushort);
+	NC_TEST(nc_put_vara_uint);
+	NC_TEST(nc_put_vara_longlong);
+	NC_TEST(nc_put_vara_ulonglong);
 	NC_TEST(nc_put_vara);
 	NC_TEST(nc_put_vars_text);
 	NC_TEST(nc_put_vars_uchar);
@@ -266,6 +320,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_put_vars_long);
 	NC_TEST(nc_put_vars_float);
 	NC_TEST(nc_put_vars_double);
+	NC_TEST(nc_put_vars_ushort);
+	NC_TEST(nc_put_vars_uint);
+	NC_TEST(nc_put_vars_longlong);
+	NC_TEST(nc_put_vars_ulonglong);
 	NC_TEST(nc_put_vars);
 	NC_TEST(nc_put_varm_text);
 	NC_TEST(nc_put_varm_uchar);
@@ -275,6 +333,10 @@ main(int argc, char *argv[])
 	NC_TEST(nc_put_varm_long);
 	NC_TEST(nc_put_varm_float);
 	NC_TEST(nc_put_varm_double);
+	NC_TEST(nc_put_varm_ushort);
+	NC_TEST(nc_put_varm_uint);
+	NC_TEST(nc_put_varm_longlong);
+	NC_TEST(nc_put_varm_ulonglong);
 	NC_TEST(nc_put_varm);
 	NC_TEST(nc_rename_var);
 	NC_TEST(nc_put_att_text);
@@ -284,7 +346,11 @@ main(int argc, char *argv[])
 	NC_TEST(nc_put_att_int);
 	NC_TEST(nc_put_att_long);
 	NC_TEST(nc_put_att_float);
-	NC_TEST(nc_put_att_double);
+	NC_TEST(nc_put_att_ulonglong);
+	NC_TEST(nc_put_att_ushort);
+	NC_TEST(nc_put_att_uint);
+	NC_TEST(nc_put_att_longlong);
+	NC_TEST(nc_put_att_ulonglong);
 	NC_TEST(nc_put_att);
 	NC_TEST(nc_copy_att);
 	NC_TEST(nc_rename_att);
@@ -302,6 +368,9 @@ main(int argc, char *argv[])
     else
        fprintf(stderr, "*** nc_test SUCCESS!!!\n");
 
+#ifdef USE_PNETCDF
+    MPI_Finalize();
+#endif
     exit(0);
     return 0;
 }
diff --git a/nc_test/quick_large_files.c b/nc_test/quick_large_files.c
index 14e58bf..7c8567d 100644
--- a/nc_test/quick_large_files.c
+++ b/nc_test/quick_large_files.c
@@ -2,7 +2,7 @@
  Copyright 2004-2006, UCAR/Unidata
  See COPYRIGHT file for copying and redistribution conditions.
 
- This program (quickly, but not throughly) tests the large file
+ This program (quickly, but not thoroughly) tests the large file
  features. It turns off fill mode to quickly create an 8 gb file, and
  write one value is written, nothing is read.
 
diff --git a/nc_test/run_pnetcdf_test.sh b/nc_test/run_pnetcdf_test.sh
index dacd3b0..096a30d 100755
--- a/nc_test/run_pnetcdf_test.sh
+++ b/nc_test/run_pnetcdf_test.sh
@@ -7,6 +7,9 @@ echo
 echo "Testing file created with pnetcdf is modifiable with netCDF..."
 ./tst_pnetcdf
 
+echo "Testing file created with pnetcdf works when adding variables..."
+./tst_addvar tst_pnetcdf.nc
+
 set -x
 # We assume a min of at least 2 processors is available
 mpiexec -n 2 ./tst_parallel2
diff --git a/nc_test/t_nc.c b/nc_test/t_nc.c
index a11b830..09cd49c 100644
--- a/nc_test/t_nc.c
+++ b/nc_test/t_nc.c
@@ -8,9 +8,8 @@
  
    Based on a program to test the nasa look-alike program, so not the
    most appropropriate test. See ../nctest for a complete spec test.
+*/
  
-   $Id: t_nc.c,v 1.94 2010/05/27 21:34:13 dmh Exp $ */
-
 #define REDEF
 /* #define SYNCDEBUG */
 
@@ -23,6 +22,9 @@
 #include <string.h>
 #include <assert.h>
 #include <netcdf.h>
+#ifdef USE_PNETCDF
+#include <netcdf_par.h>
+#endif
 
 #define MAXSHORT	32767
 #define MAXINT		2147483647
@@ -314,7 +316,7 @@ bad_ret :
 	return;
 }
 
-static const size_t	indices[][3] = {
+static size_t	indices[][3] = {
 	{0, 1, 3},
 	{0, 3, 0},
 	{1, 2, 3},
@@ -329,19 +331,19 @@ static const size_t s_start[] = {0,1};
 static const size_t s_edges[] = {NUM_RECS, SIZE_1 - 1};
 static char sentence[NUM_RECS* SIZE_1 -1] =
 	"The red death had long devastated the country.";
-static const short shs[] = {97, 99};
-static const int birthday = 82555;
+static short shs[] = {97, 99};
+static int birthday = 82555;
 #define M_E	2.7182818284590452354
-static const float e = (float) M_E;
-static const double pinot = 3.25;
-static const double zed = 0.0;
+static float e = (float) M_E;
+static double pinot = 3.25;
+static double zed = 0.0;
 
 
 /*ARGSUSED*/
 int
-main(int ac, char *av[])
+main(int argc, char *argv[])
 {
-	int ret;
+	int cmode=NC_CLOBBER, omode, ret;
 	int	 id;
 	char buf[256];
 #ifdef SYNCDEBUG
@@ -355,13 +357,23 @@ main(int ac, char *av[])
 	size_t chunksz = 8192;
 	size_t align = 8192/32;
 
-	ret = nc__create(fname,NC_NOCLOBBER, initialsz, &chunksz, &id);
+#ifdef USE_PNETCDF
+	MPI_Init(&argc, &argv);
+
+        cmode |= (NC_PNETCDF);
+	cmode |= (NC_64BIT_DATA);
+	ret = nc_create_par(fname,cmode, MPI_COMM_WORLD, MPI_INFO_NULL, &id);
+#else
+	ret = nc__create(fname,cmode, initialsz, &chunksz, &id);
 	if(ret != NC_NOERR) {
  		/* (void) fprintf(stderr, "trying again\n"); */
-		ret = nc__create(fname,NC_CLOBBER, initialsz, &chunksz, &id);
+		ret = nc__create(fname,cmode, initialsz, &chunksz, &id);
 	}
-	if(ret != NC_NOERR) 
+#endif
+	if(ret != NC_NOERR)  {
+		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);
@@ -459,7 +471,13 @@ main(int ac, char *av[])
 /*
  *	read it
  */
-	ret = nc__open(fname,NC_NOWRITE, &chunksz, &id);
+        omode = NC_NOWRITE;
+#ifdef USE_PNETCDF
+        omode |= NC_PNETCDF;
+	ret = nc_open_par(fname,omode, MPI_COMM_WORLD, MPI_INFO_NULL, &id);
+#else
+	ret = nc__open(fname,omode, &chunksz, &id);
+#endif
 	if(ret != NC_NOERR)
 	{
    	    (void) printf("Could not open %s: %s\n", fname,
@@ -652,5 +670,8 @@ main(int ac, char *av[])
 	ret = nc_close(id);
 	/* (void) printf("re nc_close ret = %d\n", ret); */
 
+#ifdef USE_PNETCDF
+	MPI_Finalize();
+#endif
 	return 0;
 }
diff --git a/nc_test/t_nc.c b/nc_test/t_nc_p5.c
similarity index 95%
copy from nc_test/t_nc.c
copy to nc_test/t_nc_p5.c
index a11b830..c1d3462 100644
--- a/nc_test/t_nc.c
+++ b/nc_test/t_nc_p5.c
@@ -9,7 +9,7 @@
    Based on a program to test the nasa look-alike program, so not the
    most appropropriate test. See ../nctest for a complete spec test.
  
-   $Id: t_nc.c,v 1.94 2010/05/27 21:34:13 dmh Exp $ */
+   $Id: t_nc.c 2792 2014-10-27 06:02:59Z wkliao $ */
 
 #define REDEF
 /* #define SYNCDEBUG */
@@ -22,7 +22,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include <mpi.h>
 #include <netcdf.h>
+#include <netcdf_par.h>
 
 #define MAXSHORT	32767
 #define MAXINT		2147483647
@@ -314,7 +316,7 @@ bad_ret :
 	return;
 }
 
-static const size_t	indices[][3] = {
+static size_t	indices[][3] = {
 	{0, 1, 3},
 	{0, 3, 0},
 	{1, 2, 3},
@@ -329,19 +331,19 @@ static const size_t s_start[] = {0,1};
 static const size_t s_edges[] = {NUM_RECS, SIZE_1 - 1};
 static char sentence[NUM_RECS* SIZE_1 -1] =
 	"The red death had long devastated the country.";
-static const short shs[] = {97, 99};
-static const int birthday = 82555;
+static short shs[] = {97, 99};
+static int birthday = 82555;
 #define M_E	2.7182818284590452354
-static const float e = (float) M_E;
-static const double pinot = 3.25;
-static const double zed = 0.0;
+static float e = (float) M_E;
+static double pinot = 3.25;
+static double zed = 0.0;
 
 
 /*ARGSUSED*/
 int
-main(int ac, char *av[])
+main(int argc, char *argv[])
 {
-	int ret;
+	int cmode=NC_CLOBBER, omode, ret;
 	int	 id;
 	char buf[256];
 #ifdef SYNCDEBUG
@@ -355,13 +357,15 @@ main(int ac, char *av[])
 	size_t chunksz = 8192;
 	size_t align = 8192/32;
 
-	ret = nc__create(fname,NC_NOCLOBBER, initialsz, &chunksz, &id);
-	if(ret != NC_NOERR) {
- 		/* (void) fprintf(stderr, "trying again\n"); */
-		ret = nc__create(fname,NC_CLOBBER, initialsz, &chunksz, &id);
-	}
-	if(ret != NC_NOERR) 
+	MPI_Init(&argc, &argv);
+
+        /* cmode |= NC_PNETCDF |NC_64BIT_OFFSET; */
+        cmode != NC_PNETCDF |NC_64BIT_DATA;
+	ret = nc_create_par(fname,cmode, MPI_COMM_WORLD, MPI_INFO_NULL, &id);
+	if(ret != NC_NOERR)  {
+		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);
@@ -459,7 +463,8 @@ main(int ac, char *av[])
 /*
  *	read it
  */
-	ret = nc__open(fname,NC_NOWRITE, &chunksz, &id);
+        omode = NC_NOWRITE;
+        omode = NC_NOWRITE | NC_PNETCDF;
 	if(ret != NC_NOERR)
 	{
    	    (void) printf("Could not open %s: %s\n", fname,
@@ -652,5 +657,6 @@ main(int ac, char *av[])
 	ret = nc_close(id);
 	/* (void) printf("re nc_close ret = %d\n", ret); */
 
+	MPI_Finalize();
 	return 0;
 }
diff --git a/nc_test/test_get.c b/nc_test/test_get.c
index 0395438..241bf85 100644
--- a/nc_test/test_get.c
+++ b/nc_test/test_get.c
@@ -1,12388 +1,9331 @@
-#line 5 "test_get.m4"
 /* Do not edit this file. It is produced from the corresponding .m4 source */
-#line 7
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_get.m4,v 1.16 2005/03/08 03:04:19 ed Exp $
+ *   $Id: test_get.m4 2785 2014-10-26 05:21:20Z wkliao $
  *********************************************************************/
 
-#line 31
+#ifdef USE_PARALLEL
+#include <mpi.h>
+#endif
+
 
 #include "tests.h"
 
-#line 116
 
 void
-#line 117
 test_nc_get_var1_text(void)
-#line 117
 {
-#line 117
     int ncid;
-#line 117
     int i;
-#line 117
     int j;
-#line 117
     int err;
-#line 117
     int nok = 0;      /* count of valid comparisons */
-#line 117
     size_t index[MAX_RANK];
-#line 117
     double expect;
-#line 117
     int canConvert;     /* Both text or both numeric */
-#line 117
     text value;
-#line 117
 
-#line 117
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 117
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 117
 	error("nc_open: %s", nc_strerror(err));
-#line 117
-    for (i = 0; i < NVARS; i++) {
-#line 117
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 117
 	for (j = 0; j < var_rank[i]; j++)
-#line 117
 	    index[j] = 0;
-#line 117
         err = nc_get_var1_text(BAD_ID, i, index, &value);
-#line 117
         IF (err != NC_EBADID)
-#line 117
 	    error("bad ncid: status = %d", err);
-#line 117
         err = nc_get_var1_text(ncid, BAD_VARID, index, &value);
-#line 117
         IF (err != NC_ENOTVAR)
-#line 117
 	    error("bad var id: status = %d", err);
-#line 117
 	for (j = 0; j < var_rank[i]; j++) {
-#line 117
 	    index[j] = var_shape[i][j];
-#line 117
 	    err = nc_get_var1_text(ncid, i, index, &value);
-#line 117
 	    if(!canConvert) {
-#line 117
 		IF(err != NC_ECHAR)
-#line 117
 			error("conversion: status = %d", err);
-#line 117
 	    } else IF (err != NC_EINVALCOORDS)
-#line 117
 		error("bad index: status = %d", err);
-#line 117
 	    index[j] = 0;
-#line 117
 	}
-#line 117
 	for (j = 0; j < var_nels[i]; j++) {
-#line 117
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 117
 	    IF (err)
-#line 117
 		error("error in toMixedBase 1");
-#line 117
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_TEXT );
-#line 117
 	    if (var_rank[i] == 0 && i%2 )
-#line 117
 		err = nc_get_var1_text(ncid, i, NULL, &value);
-#line 117
 	    else
-#line 117
 		err = nc_get_var1_text(ncid, i, index, &value);
-#line 117
             if (canConvert) {
-#line 117
 		if (inRange3(expect,var_type[i], NCT_TEXT)) {
-#line 117
 		    if (expect >= text_min && expect <= text_max) {
-#line 117
 			IF (err) {
-#line 117
 			    error("%s", nc_strerror(err));
-#line 117
 			} else {
-#line 117
 			    IF (!equal(value,expect,var_type[i],NCT_TEXT)) {
-#line 117
 				error("expected: %G, got: %G", expect,
-#line 117
 				    (double) value);
-#line 117
 			    } else {
-#line 117
 				nok++;
-#line 117
 			    }
-#line 117
 			}
-#line 117
 		    } else {
-#line 117
 			IF (err != NC_ERANGE)
-#line 117
 			    error("Range error: status = %d", err);
-#line 117
 		    }
-#line 117
                 } else {
-#line 117
                     IF (err != 0 && err != NC_ERANGE)
-#line 117
                         error("OK or Range error: status = %d", err);
-#line 117
 		}
-#line 117
 	    } else {
-#line 117
 		IF (err != NC_ECHAR)
-#line 117
 		    error("wrong type: status = %d", err);
-#line 117
 	    }
-#line 117
 	}
-#line 117
     }
-#line 117
     err = nc_close(ncid);
-#line 117
     IF (err)
-#line 117
 	error("nc_close: %s", nc_strerror(err));
-#line 117
     print_nok(nok);
-#line 117
 }
-#line 117
 
 void
-#line 118
 test_nc_get_var1_uchar(void)
-#line 118
 {
-#line 118
     int ncid;
-#line 118
     int i;
-#line 118
     int j;
-#line 118
     int err;
-#line 118
     int nok = 0;      /* count of valid comparisons */
-#line 118
     size_t index[MAX_RANK];
-#line 118
     double expect;
-#line 118
     int canConvert;     /* Both text or both numeric */
-#line 118
     uchar value;
-#line 118
 
-#line 118
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 118
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 118
 	error("nc_open: %s", nc_strerror(err));
-#line 118
-    for (i = 0; i < NVARS; i++) {
-#line 118
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 118
 	for (j = 0; j < var_rank[i]; j++)
-#line 118
 	    index[j] = 0;
-#line 118
         err = nc_get_var1_uchar(BAD_ID, i, index, &value);
-#line 118
         IF (err != NC_EBADID)
-#line 118
 	    error("bad ncid: status = %d", err);
-#line 118
         err = nc_get_var1_uchar(ncid, BAD_VARID, index, &value);
-#line 118
         IF (err != NC_ENOTVAR)
-#line 118
 	    error("bad var id: status = %d", err);
-#line 118
 	for (j = 0; j < var_rank[i]; j++) {
-#line 118
 	    index[j] = var_shape[i][j];
-#line 118
 	    err = nc_get_var1_uchar(ncid, i, index, &value);
-#line 118
 	    if(!canConvert) {
-#line 118
 		IF(err != NC_ECHAR)
-#line 118
 			error("conversion: status = %d", err);
-#line 118
 	    } else IF (err != NC_EINVALCOORDS)
-#line 118
 		error("bad index: status = %d", err);
-#line 118
 	    index[j] = 0;
-#line 118
 	}
-#line 118
 	for (j = 0; j < var_nels[i]; j++) {
-#line 118
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 118
 	    IF (err)
-#line 118
 		error("error in toMixedBase 1");
-#line 118
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_UCHAR );
-#line 118
 	    if (var_rank[i] == 0 && i%2 )
-#line 118
 		err = nc_get_var1_uchar(ncid, i, NULL, &value);
-#line 118
 	    else
-#line 118
 		err = nc_get_var1_uchar(ncid, i, index, &value);
-#line 118
             if (canConvert) {
-#line 118
 		if (inRange3(expect,var_type[i], NCT_UCHAR)) {
-#line 118
 		    if (expect >= uchar_min && expect <= uchar_max) {
-#line 118
 			IF (err) {
-#line 118
 			    error("%s", nc_strerror(err));
-#line 118
 			} else {
-#line 118
 			    IF (!equal(value,expect,var_type[i],NCT_UCHAR)) {
-#line 118
 				error("expected: %G, got: %G", expect,
-#line 118
 				    (double) value);
-#line 118
 			    } else {
-#line 118
 				nok++;
-#line 118
 			    }
-#line 118
 			}
-#line 118
 		    } else {
-#line 118
 			IF (err != NC_ERANGE)
-#line 118
 			    error("Range error: status = %d", err);
-#line 118
 		    }
-#line 118
                 } else {
-#line 118
                     IF (err != 0 && err != NC_ERANGE)
-#line 118
                         error("OK or Range error: status = %d", err);
-#line 118
 		}
-#line 118
 	    } else {
-#line 118
 		IF (err != NC_ECHAR)
-#line 118
 		    error("wrong type: status = %d", err);
-#line 118
 	    }
-#line 118
 	}
-#line 118
     }
-#line 118
     err = nc_close(ncid);
-#line 118
     IF (err)
-#line 118
 	error("nc_close: %s", nc_strerror(err));
-#line 118
     print_nok(nok);
-#line 118
 }
-#line 118
 
 void
-#line 119
 test_nc_get_var1_schar(void)
-#line 119
 {
-#line 119
     int ncid;
-#line 119
     int i;
-#line 119
     int j;
-#line 119
     int err;
-#line 119
     int nok = 0;      /* count of valid comparisons */
-#line 119
     size_t index[MAX_RANK];
-#line 119
     double expect;
-#line 119
     int canConvert;     /* Both text or both numeric */
-#line 119
     schar value;
-#line 119
 
-#line 119
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 119
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 119
 	error("nc_open: %s", nc_strerror(err));
-#line 119
-    for (i = 0; i < NVARS; i++) {
-#line 119
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 119
 	for (j = 0; j < var_rank[i]; j++)
-#line 119
 	    index[j] = 0;
-#line 119
         err = nc_get_var1_schar(BAD_ID, i, index, &value);
-#line 119
         IF (err != NC_EBADID)
-#line 119
 	    error("bad ncid: status = %d", err);
-#line 119
         err = nc_get_var1_schar(ncid, BAD_VARID, index, &value);
-#line 119
         IF (err != NC_ENOTVAR)
-#line 119
 	    error("bad var id: status = %d", err);
-#line 119
 	for (j = 0; j < var_rank[i]; j++) {
-#line 119
 	    index[j] = var_shape[i][j];
-#line 119
 	    err = nc_get_var1_schar(ncid, i, index, &value);
-#line 119
 	    if(!canConvert) {
-#line 119
 		IF(err != NC_ECHAR)
-#line 119
 			error("conversion: status = %d", err);
-#line 119
 	    } else IF (err != NC_EINVALCOORDS)
-#line 119
 		error("bad index: status = %d", err);
-#line 119
 	    index[j] = 0;
-#line 119
 	}
-#line 119
 	for (j = 0; j < var_nels[i]; j++) {
-#line 119
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 119
 	    IF (err)
-#line 119
 		error("error in toMixedBase 1");
-#line 119
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_SCHAR );
-#line 119
 	    if (var_rank[i] == 0 && i%2 )
-#line 119
 		err = nc_get_var1_schar(ncid, i, NULL, &value);
-#line 119
 	    else
-#line 119
 		err = nc_get_var1_schar(ncid, i, index, &value);
-#line 119
             if (canConvert) {
-#line 119
 		if (inRange3(expect,var_type[i], NCT_SCHAR)) {
-#line 119
 		    if (expect >= schar_min && expect <= schar_max) {
-#line 119
 			IF (err) {
-#line 119
 			    error("%s", nc_strerror(err));
-#line 119
 			} else {
-#line 119
 			    IF (!equal(value,expect,var_type[i],NCT_SCHAR)) {
-#line 119
 				error("expected: %G, got: %G", expect,
-#line 119
 				    (double) value);
-#line 119
 			    } else {
-#line 119
 				nok++;
-#line 119
 			    }
-#line 119
 			}
-#line 119
 		    } else {
-#line 119
 			IF (err != NC_ERANGE)
-#line 119
 			    error("Range error: status = %d", err);
-#line 119
 		    }
-#line 119
                 } else {
-#line 119
                     IF (err != 0 && err != NC_ERANGE)
-#line 119
                         error("OK or Range error: status = %d", err);
-#line 119
 		}
-#line 119
 	    } else {
-#line 119
 		IF (err != NC_ECHAR)
-#line 119
 		    error("wrong type: status = %d", err);
-#line 119
 	    }
-#line 119
 	}
-#line 119
     }
-#line 119
     err = nc_close(ncid);
-#line 119
     IF (err)
-#line 119
 	error("nc_close: %s", nc_strerror(err));
-#line 119
     print_nok(nok);
-#line 119
 }
-#line 119
 
 void
-#line 120
 test_nc_get_var1_short(void)
-#line 120
 {
-#line 120
     int ncid;
-#line 120
     int i;
-#line 120
     int j;
-#line 120
     int err;
-#line 120
     int nok = 0;      /* count of valid comparisons */
-#line 120
     size_t index[MAX_RANK];
-#line 120
     double expect;
-#line 120
     int canConvert;     /* Both text or both numeric */
-#line 120
     short value;
-#line 120
 
-#line 120
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 120
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 120
 	error("nc_open: %s", nc_strerror(err));
-#line 120
-    for (i = 0; i < NVARS; i++) {
-#line 120
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 120
 	for (j = 0; j < var_rank[i]; j++)
-#line 120
 	    index[j] = 0;
-#line 120
         err = nc_get_var1_short(BAD_ID, i, index, &value);
-#line 120
         IF (err != NC_EBADID)
-#line 120
 	    error("bad ncid: status = %d", err);
-#line 120
         err = nc_get_var1_short(ncid, BAD_VARID, index, &value);
-#line 120
         IF (err != NC_ENOTVAR)
-#line 120
 	    error("bad var id: status = %d", err);
-#line 120
 	for (j = 0; j < var_rank[i]; j++) {
-#line 120
 	    index[j] = var_shape[i][j];
-#line 120
 	    err = nc_get_var1_short(ncid, i, index, &value);
-#line 120
 	    if(!canConvert) {
-#line 120
 		IF(err != NC_ECHAR)
-#line 120
 			error("conversion: status = %d", err);
-#line 120
 	    } else IF (err != NC_EINVALCOORDS)
-#line 120
 		error("bad index: status = %d", err);
-#line 120
 	    index[j] = 0;
-#line 120
 	}
-#line 120
 	for (j = 0; j < var_nels[i]; j++) {
-#line 120
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 120
 	    IF (err)
-#line 120
 		error("error in toMixedBase 1");
-#line 120
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_SHORT );
-#line 120
 	    if (var_rank[i] == 0 && i%2 )
-#line 120
 		err = nc_get_var1_short(ncid, i, NULL, &value);
-#line 120
 	    else
-#line 120
 		err = nc_get_var1_short(ncid, i, index, &value);
-#line 120
             if (canConvert) {
-#line 120
 		if (inRange3(expect,var_type[i], NCT_SHORT)) {
-#line 120
 		    if (expect >= short_min && expect <= short_max) {
-#line 120
 			IF (err) {
-#line 120
 			    error("%s", nc_strerror(err));
-#line 120
 			} else {
-#line 120
 			    IF (!equal(value,expect,var_type[i],NCT_SHORT)) {
-#line 120
 				error("expected: %G, got: %G", expect,
-#line 120
 				    (double) value);
-#line 120
 			    } else {
-#line 120
 				nok++;
-#line 120
 			    }
-#line 120
 			}
-#line 120
 		    } else {
-#line 120
 			IF (err != NC_ERANGE)
-#line 120
 			    error("Range error: status = %d", err);
-#line 120
 		    }
-#line 120
                 } else {
-#line 120
                     IF (err != 0 && err != NC_ERANGE)
-#line 120
                         error("OK or Range error: status = %d", err);
-#line 120
 		}
-#line 120
 	    } else {
-#line 120
 		IF (err != NC_ECHAR)
-#line 120
 		    error("wrong type: status = %d", err);
-#line 120
 	    }
-#line 120
 	}
-#line 120
     }
-#line 120
     err = nc_close(ncid);
-#line 120
     IF (err)
-#line 120
 	error("nc_close: %s", nc_strerror(err));
-#line 120
     print_nok(nok);
-#line 120
 }
-#line 120
 
 void
-#line 121
 test_nc_get_var1_int(void)
-#line 121
 {
-#line 121
     int ncid;
-#line 121
     int i;
-#line 121
     int j;
-#line 121
     int err;
-#line 121
     int nok = 0;      /* count of valid comparisons */
-#line 121
     size_t index[MAX_RANK];
-#line 121
     double expect;
-#line 121
     int canConvert;     /* Both text or both numeric */
-#line 121
     int value;
-#line 121
 
-#line 121
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 121
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 121
 	error("nc_open: %s", nc_strerror(err));
-#line 121
-    for (i = 0; i < NVARS; i++) {
-#line 121
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 121
 	for (j = 0; j < var_rank[i]; j++)
-#line 121
 	    index[j] = 0;
-#line 121
         err = nc_get_var1_int(BAD_ID, i, index, &value);
-#line 121
         IF (err != NC_EBADID)
-#line 121
 	    error("bad ncid: status = %d", err);
-#line 121
         err = nc_get_var1_int(ncid, BAD_VARID, index, &value);
-#line 121
         IF (err != NC_ENOTVAR)
-#line 121
 	    error("bad var id: status = %d", err);
-#line 121
 	for (j = 0; j < var_rank[i]; j++) {
-#line 121
 	    index[j] = var_shape[i][j];
-#line 121
 	    err = nc_get_var1_int(ncid, i, index, &value);
-#line 121
 	    if(!canConvert) {
-#line 121
 		IF(err != NC_ECHAR)
-#line 121
 			error("conversion: status = %d", err);
-#line 121
 	    } else IF (err != NC_EINVALCOORDS)
-#line 121
 		error("bad index: status = %d", err);
-#line 121
 	    index[j] = 0;
-#line 121
 	}
-#line 121
 	for (j = 0; j < var_nels[i]; j++) {
-#line 121
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 121
 	    IF (err)
-#line 121
 		error("error in toMixedBase 1");
-#line 121
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_INT );
-#line 121
 	    if (var_rank[i] == 0 && i%2 )
-#line 121
 		err = nc_get_var1_int(ncid, i, NULL, &value);
-#line 121
 	    else
-#line 121
 		err = nc_get_var1_int(ncid, i, index, &value);
-#line 121
             if (canConvert) {
-#line 121
 		if (inRange3(expect,var_type[i], NCT_INT)) {
-#line 121
 		    if (expect >= int_min && expect <= int_max) {
-#line 121
 			IF (err) {
-#line 121
 			    error("%s", nc_strerror(err));
-#line 121
 			} else {
-#line 121
 			    IF (!equal(value,expect,var_type[i],NCT_INT)) {
-#line 121
 				error("expected: %G, got: %G", expect,
-#line 121
 				    (double) value);
-#line 121
 			    } else {
-#line 121
 				nok++;
-#line 121
 			    }
-#line 121
 			}
-#line 121
 		    } else {
-#line 121
 			IF (err != NC_ERANGE)
-#line 121
 			    error("Range error: status = %d", err);
-#line 121
 		    }
-#line 121
                 } else {
-#line 121
                     IF (err != 0 && err != NC_ERANGE)
-#line 121
                         error("OK or Range error: status = %d", err);
-#line 121
 		}
-#line 121
 	    } else {
-#line 121
 		IF (err != NC_ECHAR)
-#line 121
 		    error("wrong type: status = %d", err);
-#line 121
 	    }
-#line 121
 	}
-#line 121
     }
-#line 121
     err = nc_close(ncid);
-#line 121
     IF (err)
-#line 121
 	error("nc_close: %s", nc_strerror(err));
-#line 121
     print_nok(nok);
-#line 121
 }
-#line 121
 
 void
-#line 122
 test_nc_get_var1_long(void)
-#line 122
 {
-#line 122
     int ncid;
-#line 122
     int i;
-#line 122
     int j;
-#line 122
     int err;
-#line 122
     int nok = 0;      /* count of valid comparisons */
-#line 122
     size_t index[MAX_RANK];
-#line 122
     double expect;
-#line 122
     int canConvert;     /* Both text or both numeric */
-#line 122
     long value;
-#line 122
 
-#line 122
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 122
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 122
 	error("nc_open: %s", nc_strerror(err));
-#line 122
-    for (i = 0; i < NVARS; i++) {
-#line 122
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 122
 	for (j = 0; j < var_rank[i]; j++)
-#line 122
 	    index[j] = 0;
-#line 122
         err = nc_get_var1_long(BAD_ID, i, index, &value);
-#line 122
         IF (err != NC_EBADID)
-#line 122
 	    error("bad ncid: status = %d", err);
-#line 122
         err = nc_get_var1_long(ncid, BAD_VARID, index, &value);
-#line 122
         IF (err != NC_ENOTVAR)
-#line 122
 	    error("bad var id: status = %d", err);
-#line 122
 	for (j = 0; j < var_rank[i]; j++) {
-#line 122
 	    index[j] = var_shape[i][j];
-#line 122
 	    err = nc_get_var1_long(ncid, i, index, &value);
-#line 122
 	    if(!canConvert) {
-#line 122
 		IF(err != NC_ECHAR)
-#line 122
 			error("conversion: status = %d", err);
-#line 122
 	    } else IF (err != NC_EINVALCOORDS)
-#line 122
 		error("bad index: status = %d", err);
-#line 122
 	    index[j] = 0;
-#line 122
 	}
-#line 122
 	for (j = 0; j < var_nels[i]; j++) {
-#line 122
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 122
 	    IF (err)
-#line 122
 		error("error in toMixedBase 1");
-#line 122
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_LONG );
-#line 122
 	    if (var_rank[i] == 0 && i%2 )
-#line 122
 		err = nc_get_var1_long(ncid, i, NULL, &value);
-#line 122
 	    else
-#line 122
 		err = nc_get_var1_long(ncid, i, index, &value);
-#line 122
             if (canConvert) {
-#line 122
 		if (inRange3(expect,var_type[i], NCT_LONG)) {
-#line 122
 		    if (expect >= long_min && expect <= long_max) {
-#line 122
 			IF (err) {
-#line 122
 			    error("%s", nc_strerror(err));
-#line 122
 			} else {
-#line 122
 			    IF (!equal(value,expect,var_type[i],NCT_LONG)) {
-#line 122
 				error("expected: %G, got: %G", expect,
-#line 122
 				    (double) value);
-#line 122
 			    } else {
-#line 122
 				nok++;
-#line 122
 			    }
-#line 122
 			}
-#line 122
 		    } else {
-#line 122
 			IF (err != NC_ERANGE)
-#line 122
 			    error("Range error: status = %d", err);
-#line 122
 		    }
-#line 122
                 } else {
-#line 122
                     IF (err != 0 && err != NC_ERANGE)
-#line 122
                         error("OK or Range error: status = %d", err);
-#line 122
 		}
-#line 122
 	    } else {
-#line 122
 		IF (err != NC_ECHAR)
-#line 122
 		    error("wrong type: status = %d", err);
-#line 122
 	    }
-#line 122
 	}
-#line 122
     }
-#line 122
     err = nc_close(ncid);
-#line 122
     IF (err)
-#line 122
 	error("nc_close: %s", nc_strerror(err));
-#line 122
     print_nok(nok);
-#line 122
 }
-#line 122
 
 void
-#line 123
 test_nc_get_var1_float(void)
-#line 123
 {
-#line 123
     int ncid;
-#line 123
     int i;
-#line 123
     int j;
-#line 123
     int err;
-#line 123
     int nok = 0;      /* count of valid comparisons */
-#line 123
     size_t index[MAX_RANK];
-#line 123
     double expect;
-#line 123
     int canConvert;     /* Both text or both numeric */
-#line 123
     float value;
-#line 123
 
-#line 123
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 123
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 123
 	error("nc_open: %s", nc_strerror(err));
-#line 123
-    for (i = 0; i < NVARS; i++) {
-#line 123
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 123
 	for (j = 0; j < var_rank[i]; j++)
-#line 123
 	    index[j] = 0;
-#line 123
         err = nc_get_var1_float(BAD_ID, i, index, &value);
-#line 123
         IF (err != NC_EBADID)
-#line 123
 	    error("bad ncid: status = %d", err);
-#line 123
         err = nc_get_var1_float(ncid, BAD_VARID, index, &value);
-#line 123
         IF (err != NC_ENOTVAR)
-#line 123
 	    error("bad var id: status = %d", err);
-#line 123
 	for (j = 0; j < var_rank[i]; j++) {
-#line 123
 	    index[j] = var_shape[i][j];
-#line 123
 	    err = nc_get_var1_float(ncid, i, index, &value);
-#line 123
 	    if(!canConvert) {
-#line 123
 		IF(err != NC_ECHAR)
-#line 123
 			error("conversion: status = %d", err);
-#line 123
 	    } else IF (err != NC_EINVALCOORDS)
-#line 123
 		error("bad index: status = %d", err);
-#line 123
 	    index[j] = 0;
-#line 123
 	}
-#line 123
 	for (j = 0; j < var_nels[i]; j++) {
-#line 123
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 123
 	    IF (err)
-#line 123
 		error("error in toMixedBase 1");
-#line 123
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_FLOAT );
-#line 123
 	    if (var_rank[i] == 0 && i%2 )
-#line 123
 		err = nc_get_var1_float(ncid, i, NULL, &value);
-#line 123
 	    else
-#line 123
 		err = nc_get_var1_float(ncid, i, index, &value);
-#line 123
             if (canConvert) {
-#line 123
 		if (inRange3(expect,var_type[i], NCT_FLOAT)) {
-#line 123
 		    if (expect >= float_min && expect <= float_max) {
-#line 123
 			IF (err) {
-#line 123
 			    error("%s", nc_strerror(err));
-#line 123
 			} else {
-#line 123
 			    IF (!equal(value,expect,var_type[i],NCT_FLOAT)) {
-#line 123
 				error("expected: %G, got: %G", expect,
-#line 123
 				    (double) value);
-#line 123
 			    } else {
-#line 123
 				nok++;
-#line 123
 			    }
-#line 123
 			}
-#line 123
 		    } else {
-#line 123
 			IF (err != NC_ERANGE)
-#line 123
 			    error("Range error: status = %d", err);
-#line 123
 		    }
-#line 123
                 } else {
-#line 123
                     IF (err != 0 && err != NC_ERANGE)
-#line 123
                         error("OK or Range error: status = %d", err);
-#line 123
 		}
-#line 123
 	    } else {
-#line 123
 		IF (err != NC_ECHAR)
-#line 123
 		    error("wrong type: status = %d", err);
-#line 123
 	    }
-#line 123
 	}
-#line 123
     }
-#line 123
     err = nc_close(ncid);
-#line 123
     IF (err)
-#line 123
 	error("nc_close: %s", nc_strerror(err));
-#line 123
     print_nok(nok);
-#line 123
 }
-#line 123
 
 void
-#line 124
 test_nc_get_var1_double(void)
-#line 124
 {
-#line 124
     int ncid;
-#line 124
     int i;
-#line 124
     int j;
-#line 124
     int err;
-#line 124
     int nok = 0;      /* count of valid comparisons */
-#line 124
     size_t index[MAX_RANK];
-#line 124
     double expect;
-#line 124
     int canConvert;     /* Both text or both numeric */
-#line 124
     double value;
-#line 124
 
-#line 124
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 124
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 124
 	error("nc_open: %s", nc_strerror(err));
-#line 124
-    for (i = 0; i < NVARS; i++) {
-#line 124
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 124
 	for (j = 0; j < var_rank[i]; j++)
-#line 124
 	    index[j] = 0;
-#line 124
         err = nc_get_var1_double(BAD_ID, i, index, &value);
-#line 124
         IF (err != NC_EBADID)
-#line 124
 	    error("bad ncid: status = %d", err);
-#line 124
         err = nc_get_var1_double(ncid, BAD_VARID, index, &value);
-#line 124
         IF (err != NC_ENOTVAR)
-#line 124
 	    error("bad var id: status = %d", err);
-#line 124
 	for (j = 0; j < var_rank[i]; j++) {
-#line 124
 	    index[j] = var_shape[i][j];
-#line 124
 	    err = nc_get_var1_double(ncid, i, index, &value);
-#line 124
 	    if(!canConvert) {
-#line 124
 		IF(err != NC_ECHAR)
-#line 124
 			error("conversion: status = %d", err);
-#line 124
 	    } else IF (err != NC_EINVALCOORDS)
-#line 124
 		error("bad index: status = %d", err);
-#line 124
 	    index[j] = 0;
-#line 124
 	}
-#line 124
 	for (j = 0; j < var_nels[i]; j++) {
-#line 124
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 124
 	    IF (err)
-#line 124
 		error("error in toMixedBase 1");
-#line 124
 	    expect = hash4( var_type[i], var_rank[i], index, NCT_DOUBLE );
-#line 124
 	    if (var_rank[i] == 0 && i%2 )
-#line 124
 		err = nc_get_var1_double(ncid, i, NULL, &value);
-#line 124
 	    else
-#line 124
 		err = nc_get_var1_double(ncid, i, index, &value);
-#line 124
             if (canConvert) {
-#line 124
 		if (inRange3(expect,var_type[i], NCT_DOUBLE)) {
-#line 124
 		    if (expect >= double_min && expect <= double_max) {
-#line 124
 			IF (err) {
-#line 124
 			    error("%s", nc_strerror(err));
-#line 124
 			} else {
-#line 124
 			    IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) {
-#line 124
 				error("expected: %G, got: %G", expect,
-#line 124
 				    (double) value);
-#line 124
 			    } else {
-#line 124
 				nok++;
-#line 124
 			    }
-#line 124
 			}
-#line 124
 		    } else {
-#line 124
 			IF (err != NC_ERANGE)
-#line 124
 			    error("Range error: status = %d", err);
-#line 124
 		    }
-#line 124
                 } else {
-#line 124
                     IF (err != 0 && err != NC_ERANGE)
-#line 124
                         error("OK or Range error: status = %d", err);
-#line 124
 		}
-#line 124
 	    } else {
-#line 124
 		IF (err != NC_ECHAR)
-#line 124
 		    error("wrong type: status = %d", err);
-#line 124
 	    }
-#line 124
 	}
-#line 124
     }
-#line 124
     err = nc_close(ncid);
-#line 124
     IF (err)
-#line 124
 	error("nc_close: %s", nc_strerror(err));
-#line 124
     print_nok(nok);
-#line 124
 }
-#line 124
-
-
-
-#line 221
 
 void
-#line 222
-test_nc_get_var_text(void)
-#line 222
+test_nc_get_var1_ushort(void)
 {
-#line 222
     int ncid;
-#line 222
     int i;
-#line 222
     int j;
-#line 222
     int err;
-#line 222
-    int allInExtRange;	/* all values within external range? */
-#line 222
-    int allInIntRange;	/* all values within internal range? */
-#line 222
-    int nels;
-#line 222
     int nok = 0;      /* count of valid comparisons */
-#line 222
     size_t index[MAX_RANK];
-#line 222
+    double expect;
     int canConvert;     /* Both text or both numeric */
-#line 222
-    text value[MAX_NELS];
-#line 222
-    double expect[MAX_NELS];
-#line 222
+    ushort value;
 
-#line 222
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 222
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 222
 	error("nc_open: %s", nc_strerror(err));
-#line 222
-    for (i = 0; i < NVARS; i++) {
-#line 222
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 222
-        assert(var_rank[i] <= MAX_RANK);
-#line 222
-        assert(var_nels[i] <= MAX_NELS);
-#line 222
-        err = nc_get_var_text(BAD_ID, i, value);
-#line 222
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+	for (j = 0; j < var_rank[i]; j++)
+	    index[j] = 0;
+        err = nc_get_var1_ushort(BAD_ID, i, index, &value);
         IF (err != NC_EBADID)
-#line 222
 	    error("bad ncid: status = %d", err);
-#line 222
-        err = nc_get_var_text(ncid, BAD_VARID, value);
-#line 222
+        err = nc_get_var1_ushort(ncid, BAD_VARID, index, &value);
         IF (err != NC_ENOTVAR)
-#line 222
 	    error("bad var id: status = %d", err);
-#line 222
-
-#line 222
-	nels = 1;
-#line 222
 	for (j = 0; j < var_rank[i]; j++) {
-#line 222
-	    nels *= var_shape[i][j];
-#line 222
+	    index[j] = var_shape[i][j];
+	    err = nc_get_var1_ushort(ncid, i, index, &value);
+	    if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	    } else IF (err != NC_EINVALCOORDS)
+		error("bad index: status = %d", err);
+	    index[j] = 0;
 	}
-#line 222
-	allInExtRange = allInIntRange = 1;
-#line 222
-	for (j = 0; j < nels; j++) {
-#line 222
+	for (j = 0; j < var_nels[i]; j++) {
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 222
 	    IF (err)
-#line 222
 		error("error in toMixedBase 1");
-#line 222
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT);
-#line 222
-	    if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
-#line 222
-		allInIntRange = allInIntRange && expect[j] >= text_min
-#line 222
-			    && expect[j] <= text_max;
-#line 222
-	    } else {
-#line 222
-		allInExtRange = 0;
-#line 222
-	    }
-#line 222
-	}
-#line 222
-	err = nc_get_var_text(ncid, i, value);
-#line 222
-	if (canConvert) {
-#line 222
-	    if (allInExtRange) {
-#line 222
-		if (allInIntRange) {
-#line 222
-		    IF (err)
-#line 222
-			error("%s", nc_strerror(err));
-#line 222
-		} else {
-#line 222
-		    IF (err != NC_ERANGE)
-#line 222
-			error("Range error: status = %d", err);
-#line 222
-		}
-#line 222
-	    } else {
-#line 222
-		IF (err != 0 && err != NC_ERANGE)
-#line 222
-		    error("OK or Range error: status = %d", err);
-#line 222
-	    }
-#line 222
-	    for (j = 0; j < nels; j++) {
-#line 222
-		if (inRange3(expect[j],var_type[i],NCT_TEXT)
-#line 222
-			&& expect[j] >= text_min && expect[j] <= text_max) {
-#line 222
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){
-#line 222
-			error("value read not that expected");
-#line 222
-			if (verbose) {
-#line 222
-			    error("\n");
-#line 222
-			    error("varid: %d, ", i);
-#line 222
-			    error("var_name: %s, ", var_name[i]);
-#line 222
-			    error("element number: %d ", j);
-#line 222
-			    error("expect: %g", expect[j]);
-#line 222
-			    error("got: %g", (double) value[j]);
-#line 222
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_USHORT );
+	    if (var_rank[i] == 0 && i%2 )
+		err = nc_get_var1_ushort(ncid, i, NULL, &value);
+	    else
+		err = nc_get_var1_ushort(ncid, i, index, &value);
+            if (canConvert) {
+		if (inRange3(expect,var_type[i], NCT_USHORT)) {
+		    if (expect >= ushort_min && expect <= ushort_max) {
+			IF (err) {
+			    error("%s", nc_strerror(err));
+			} else {
+			    IF (!equal(value,expect,var_type[i],NCT_USHORT)) {
+				error("expected: %G, got: %G", expect,
+				    (double) value);
+			    } else {
+				nok++;
+			    }
 			}
-#line 222
 		    } else {
-#line 222
-			nok++;
-#line 222
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 222
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
 		}
-#line 222
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
 	    }
-#line 222
-	} else {
-#line 222
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 222
-		error("wrong type: status = %d", err);
-#line 222
 	}
-#line 222
     }
-#line 222
     err = nc_close(ncid);
-#line 222
     IF (err)
-#line 222
 	error("nc_close: %s", nc_strerror(err));
-#line 222
     print_nok(nok);
-#line 222
 }
-#line 222
 
 void
-#line 223
-test_nc_get_var_uchar(void)
-#line 223
+test_nc_get_var1_uint(void)
 {
-#line 223
     int ncid;
-#line 223
     int i;
-#line 223
     int j;
-#line 223
     int err;
-#line 223
-    int allInExtRange;	/* all values within external range? */
-#line 223
-    int allInIntRange;	/* all values within internal range? */
-#line 223
-    int nels;
-#line 223
     int nok = 0;      /* count of valid comparisons */
-#line 223
     size_t index[MAX_RANK];
-#line 223
+    double expect;
     int canConvert;     /* Both text or both numeric */
-#line 223
-    uchar value[MAX_NELS];
-#line 223
-    double expect[MAX_NELS];
-#line 223
+    uint value;
 
-#line 223
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 223
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 223
 	error("nc_open: %s", nc_strerror(err));
-#line 223
-    for (i = 0; i < NVARS; i++) {
-#line 223
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 223
-        assert(var_rank[i] <= MAX_RANK);
-#line 223
-        assert(var_nels[i] <= MAX_NELS);
-#line 223
-        err = nc_get_var_uchar(BAD_ID, i, value);
-#line 223
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+	for (j = 0; j < var_rank[i]; j++)
+	    index[j] = 0;
+        err = nc_get_var1_uint(BAD_ID, i, index, &value);
         IF (err != NC_EBADID)
-#line 223
 	    error("bad ncid: status = %d", err);
-#line 223
-        err = nc_get_var_uchar(ncid, BAD_VARID, value);
-#line 223
+        err = nc_get_var1_uint(ncid, BAD_VARID, index, &value);
         IF (err != NC_ENOTVAR)
-#line 223
 	    error("bad var id: status = %d", err);
-#line 223
-
-#line 223
-	nels = 1;
-#line 223
 	for (j = 0; j < var_rank[i]; j++) {
-#line 223
-	    nels *= var_shape[i][j];
-#line 223
+	    index[j] = var_shape[i][j];
+	    err = nc_get_var1_uint(ncid, i, index, &value);
+	    if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	    } else IF (err != NC_EINVALCOORDS)
+		error("bad index: status = %d", err);
+	    index[j] = 0;
 	}
-#line 223
-	allInExtRange = allInIntRange = 1;
-#line 223
-	for (j = 0; j < nels; j++) {
-#line 223
+	for (j = 0; j < var_nels[i]; j++) {
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 223
 	    IF (err)
-#line 223
 		error("error in toMixedBase 1");
-#line 223
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 223
-	    if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
-#line 223
-		allInIntRange = allInIntRange && expect[j] >= uchar_min
-#line 223
-			    && expect[j] <= uchar_max;
-#line 223
-	    } else {
-#line 223
-		allInExtRange = 0;
-#line 223
-	    }
-#line 223
-	}
-#line 223
-	err = nc_get_var_uchar(ncid, i, value);
-#line 223
-	if (canConvert) {
-#line 223
-	    if (allInExtRange) {
-#line 223
-		if (allInIntRange) {
-#line 223
-		    IF (err)
-#line 223
-			error("%s", nc_strerror(err));
-#line 223
-		} else {
-#line 223
-		    IF (err != NC_ERANGE)
-#line 223
-			error("Range error: status = %d", err);
-#line 223
-		}
-#line 223
-	    } else {
-#line 223
-		IF (err != 0 && err != NC_ERANGE)
-#line 223
-		    error("OK or Range error: status = %d", err);
-#line 223
-	    }
-#line 223
-	    for (j = 0; j < nels; j++) {
-#line 223
-		if (inRange3(expect[j],var_type[i],NCT_UCHAR)
-#line 223
-			&& expect[j] >= uchar_min && expect[j] <= uchar_max) {
-#line 223
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){
-#line 223
-			error("value read not that expected");
-#line 223
-			if (verbose) {
-#line 223
-			    error("\n");
-#line 223
-			    error("varid: %d, ", i);
-#line 223
-			    error("var_name: %s, ", var_name[i]);
-#line 223
-			    error("element number: %d ", j);
-#line 223
-			    error("expect: %g", expect[j]);
-#line 223
-			    error("got: %g", (double) value[j]);
-#line 223
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_UINT );
+	    if (var_rank[i] == 0 && i%2 )
+		err = nc_get_var1_uint(ncid, i, NULL, &value);
+	    else
+		err = nc_get_var1_uint(ncid, i, index, &value);
+            if (canConvert) {
+		if (inRange3(expect,var_type[i], NCT_UINT)) {
+		    if (expect >= uint_min && expect <= uint_max) {
+			IF (err) {
+			    error("%s", nc_strerror(err));
+			} else {
+			    IF (!equal(value,expect,var_type[i],NCT_UINT)) {
+				error("expected: %G, got: %G", expect,
+				    (double) value);
+			    } else {
+				nok++;
+			    }
 			}
-#line 223
 		    } else {
-#line 223
-			nok++;
-#line 223
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 223
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
 		}
-#line 223
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
 	    }
-#line 223
-	} else {
-#line 223
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 223
-		error("wrong type: status = %d", err);
-#line 223
 	}
-#line 223
     }
-#line 223
     err = nc_close(ncid);
-#line 223
     IF (err)
-#line 223
 	error("nc_close: %s", nc_strerror(err));
-#line 223
     print_nok(nok);
-#line 223
 }
-#line 223
 
 void
-#line 224
-test_nc_get_var_schar(void)
-#line 224
+test_nc_get_var1_longlong(void)
 {
-#line 224
     int ncid;
-#line 224
     int i;
-#line 224
     int j;
-#line 224
     int err;
-#line 224
-    int allInExtRange;	/* all values within external range? */
-#line 224
-    int allInIntRange;	/* all values within internal range? */
-#line 224
-    int nels;
-#line 224
     int nok = 0;      /* count of valid comparisons */
-#line 224
     size_t index[MAX_RANK];
-#line 224
+    double expect;
     int canConvert;     /* Both text or both numeric */
-#line 224
-    schar value[MAX_NELS];
-#line 224
-    double expect[MAX_NELS];
-#line 224
+    longlong value;
 
-#line 224
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 224
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 224
 	error("nc_open: %s", nc_strerror(err));
-#line 224
-    for (i = 0; i < NVARS; i++) {
-#line 224
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 224
-        assert(var_rank[i] <= MAX_RANK);
-#line 224
-        assert(var_nels[i] <= MAX_NELS);
-#line 224
-        err = nc_get_var_schar(BAD_ID, i, value);
-#line 224
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+	for (j = 0; j < var_rank[i]; j++)
+	    index[j] = 0;
+        err = nc_get_var1_longlong(BAD_ID, i, index, &value);
         IF (err != NC_EBADID)
-#line 224
 	    error("bad ncid: status = %d", err);
-#line 224
-        err = nc_get_var_schar(ncid, BAD_VARID, value);
-#line 224
+        err = nc_get_var1_longlong(ncid, BAD_VARID, index, &value);
         IF (err != NC_ENOTVAR)
-#line 224
 	    error("bad var id: status = %d", err);
-#line 224
-
-#line 224
-	nels = 1;
-#line 224
 	for (j = 0; j < var_rank[i]; j++) {
-#line 224
-	    nels *= var_shape[i][j];
-#line 224
+	    index[j] = var_shape[i][j];
+	    err = nc_get_var1_longlong(ncid, i, index, &value);
+	    if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	    } else IF (err != NC_EINVALCOORDS)
+		error("bad index: status = %d", err);
+	    index[j] = 0;
 	}
-#line 224
-	allInExtRange = allInIntRange = 1;
-#line 224
-	for (j = 0; j < nels; j++) {
-#line 224
+	for (j = 0; j < var_nels[i]; j++) {
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 224
 	    IF (err)
-#line 224
 		error("error in toMixedBase 1");
-#line 224
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 224
-	    if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
-#line 224
-		allInIntRange = allInIntRange && expect[j] >= schar_min
-#line 224
-			    && expect[j] <= schar_max;
-#line 224
-	    } else {
-#line 224
-		allInExtRange = 0;
-#line 224
-	    }
-#line 224
-	}
-#line 224
-	err = nc_get_var_schar(ncid, i, value);
-#line 224
-	if (canConvert) {
-#line 224
-	    if (allInExtRange) {
-#line 224
-		if (allInIntRange) {
-#line 224
-		    IF (err)
-#line 224
-			error("%s", nc_strerror(err));
-#line 224
-		} else {
-#line 224
-		    IF (err != NC_ERANGE)
-#line 224
-			error("Range error: status = %d", err);
-#line 224
-		}
-#line 224
-	    } else {
-#line 224
-		IF (err != 0 && err != NC_ERANGE)
-#line 224
-		    error("OK or Range error: status = %d", err);
-#line 224
-	    }
-#line 224
-	    for (j = 0; j < nels; j++) {
-#line 224
-		if (inRange3(expect[j],var_type[i],NCT_SCHAR)
-#line 224
-			&& expect[j] >= schar_min && expect[j] <= schar_max) {
-#line 224
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){
-#line 224
-			error("value read not that expected");
-#line 224
-			if (verbose) {
-#line 224
-			    error("\n");
-#line 224
-			    error("varid: %d, ", i);
-#line 224
-			    error("var_name: %s, ", var_name[i]);
-#line 224
-			    error("element number: %d ", j);
-#line 224
-			    error("expect: %g", expect[j]);
-#line 224
-			    error("got: %g", (double) value[j]);
-#line 224
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_LONGLONG );
+	    if (var_rank[i] == 0 && i%2 )
+		err = nc_get_var1_longlong(ncid, i, NULL, &value);
+	    else
+		err = nc_get_var1_longlong(ncid, i, index, &value);
+            if (canConvert) {
+		if (inRange3(expect,var_type[i], NCT_LONGLONG)) {
+		    if (expect >= longlong_min && expect <= longlong_max) {
+			IF (err) {
+			    error("%s", nc_strerror(err));
+			} else {
+			    IF (!equal(value,expect,var_type[i],NCT_LONGLONG)) {
+				error("expected: %G, got: %G", expect,
+				    (double) value);
+			    } else {
+				nok++;
+			    }
 			}
-#line 224
 		    } else {
-#line 224
-			nok++;
-#line 224
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 224
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
 		}
-#line 224
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
 	    }
-#line 224
-	} else {
-#line 224
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 224
-		error("wrong type: status = %d", err);
-#line 224
 	}
-#line 224
     }
-#line 224
     err = nc_close(ncid);
-#line 224
     IF (err)
-#line 224
 	error("nc_close: %s", nc_strerror(err));
-#line 224
     print_nok(nok);
-#line 224
 }
-#line 224
 
 void
-#line 225
-test_nc_get_var_short(void)
-#line 225
+test_nc_get_var1_ulonglong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    int nok = 0;      /* count of valid comparisons */
+    size_t index[MAX_RANK];
+    double expect;
+    int canConvert;     /* Both text or both numeric */
+    ulonglong value;
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+	for (j = 0; j < var_rank[i]; j++)
+	    index[j] = 0;
+        err = nc_get_var1_ulonglong(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID)
+	    error("bad ncid: status = %d", err);
+        err = nc_get_var1_ulonglong(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR)
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    index[j] = var_shape[i][j];
+	    err = nc_get_var1_ulonglong(ncid, i, index, &value);
+	    if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	    } else IF (err != NC_EINVALCOORDS)
+		error("bad index: status = %d", err);
+	    index[j] = 0;
+	}
+	for (j = 0; j < var_nels[i]; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_ULONGLONG );
+	    if (var_rank[i] == 0 && i%2 )
+		err = nc_get_var1_ulonglong(ncid, i, NULL, &value);
+	    else
+		err = nc_get_var1_ulonglong(ncid, i, index, &value);
+            if (canConvert) {
+		if (inRange3(expect,var_type[i], NCT_ULONGLONG)) {
+		    if (expect >= ulonglong_min && expect <= ulonglong_max) {
+			IF (err) {
+			    error("%s", nc_strerror(err));
+			} else {
+			    IF (!equal(value,expect,var_type[i],NCT_ULONGLONG)) {
+				error("expected: %G, got: %G", expect,
+				    (double) value);
+			    } else {
+				nok++;
+			    }
+			}
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
+		    }
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+	}
+    }
+    err = nc_close(ncid);
+    IF (err)
+	error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+
+
+
+void
+test_nc_get_var_text(void)
 {
-#line 225
     int ncid;
-#line 225
     int i;
-#line 225
     int j;
-#line 225
     int err;
-#line 225
     int allInExtRange;	/* all values within external range? */
-#line 225
     int allInIntRange;	/* all values within internal range? */
-#line 225
     int nels;
-#line 225
     int nok = 0;      /* count of valid comparisons */
-#line 225
     size_t index[MAX_RANK];
-#line 225
     int canConvert;     /* Both text or both numeric */
-#line 225
-    short value[MAX_NELS];
-#line 225
+    text value[MAX_NELS];
     double expect[MAX_NELS];
-#line 225
 
-#line 225
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 225
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 225
 	error("nc_open: %s", nc_strerror(err));
-#line 225
-    for (i = 0; i < NVARS; i++) {
-#line 225
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 225
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 225
         assert(var_nels[i] <= MAX_NELS);
-#line 225
-        err = nc_get_var_short(BAD_ID, i, value);
-#line 225
+        err = nc_get_var_text(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 225
 	    error("bad ncid: status = %d", err);
-#line 225
-        err = nc_get_var_short(ncid, BAD_VARID, value);
-#line 225
+        err = nc_get_var_text(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 225
 	    error("bad var id: status = %d", err);
-#line 225
 
-#line 225
 	nels = 1;
-#line 225
 	for (j = 0; j < var_rank[i]; j++) {
-#line 225
 	    nels *= var_shape[i][j];
-#line 225
 	}
-#line 225
 	allInExtRange = allInIntRange = 1;
-#line 225
 	for (j = 0; j < nels; j++) {
-#line 225
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 225
 	    IF (err)
-#line 225
 		error("error in toMixedBase 1");
-#line 225
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT);
-#line 225
-	    if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
-#line 225
-		allInIntRange = allInIntRange && expect[j] >= short_min
-#line 225
-			    && expect[j] <= short_max;
-#line 225
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT);
+	    if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
+		allInIntRange = allInIntRange && expect[j] >= text_min
+			    && expect[j] <= text_max;
 	    } else {
-#line 225
 		allInExtRange = 0;
-#line 225
 	    }
-#line 225
 	}
-#line 225
-	err = nc_get_var_short(ncid, i, value);
-#line 225
+	err = nc_get_var_text(ncid, i, value);
 	if (canConvert) {
-#line 225
 	    if (allInExtRange) {
-#line 225
 		if (allInIntRange) {
-#line 225
 		    IF (err)
-#line 225
 			error("%s", nc_strerror(err));
-#line 225
 		} else {
-#line 225
 		    IF (err != NC_ERANGE)
-#line 225
 			error("Range error: status = %d", err);
-#line 225
 		}
-#line 225
 	    } else {
-#line 225
 		IF (err != 0 && err != NC_ERANGE)
-#line 225
 		    error("OK or Range error: status = %d", err);
-#line 225
 	    }
-#line 225
 	    for (j = 0; j < nels; j++) {
-#line 225
-		if (inRange3(expect[j],var_type[i],NCT_SHORT)
-#line 225
-			&& expect[j] >= short_min && expect[j] <= short_max) {
-#line 225
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){
-#line 225
+		if (inRange3(expect[j],var_type[i],NCT_TEXT)
+			&& expect[j] >= text_min && expect[j] <= text_max) {
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){
 			error("value read not that expected");
-#line 225
 			if (verbose) {
-#line 225
 			    error("\n");
-#line 225
 			    error("varid: %d, ", i);
-#line 225
 			    error("var_name: %s, ", var_name[i]);
-#line 225
 			    error("element number: %d ", j);
-#line 225
 			    error("expect: %g", expect[j]);
-#line 225
 			    error("got: %g", (double) value[j]);
-#line 225
 			}
-#line 225
 		    } else {
-#line 225
 			nok++;
-#line 225
 		    }
-#line 225
 		}
-#line 225
 	    }
-#line 225
 	} else {
-#line 225
 	    IF (nels > 0 && err != NC_ECHAR)
-#line 225
 		error("wrong type: status = %d", err);
-#line 225
 	}
-#line 225
     }
-#line 225
     err = nc_close(ncid);
-#line 225
     IF (err)
-#line 225
 	error("nc_close: %s", nc_strerror(err));
-#line 225
     print_nok(nok);
-#line 225
 }
-#line 225
 
 void
-#line 226
-test_nc_get_var_int(void)
-#line 226
+test_nc_get_var_uchar(void)
 {
-#line 226
     int ncid;
-#line 226
     int i;
-#line 226
     int j;
-#line 226
     int err;
-#line 226
     int allInExtRange;	/* all values within external range? */
-#line 226
     int allInIntRange;	/* all values within internal range? */
-#line 226
     int nels;
-#line 226
     int nok = 0;      /* count of valid comparisons */
-#line 226
     size_t index[MAX_RANK];
-#line 226
     int canConvert;     /* Both text or both numeric */
-#line 226
-    int value[MAX_NELS];
-#line 226
+    uchar value[MAX_NELS];
     double expect[MAX_NELS];
-#line 226
 
-#line 226
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 226
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 226
 	error("nc_open: %s", nc_strerror(err));
-#line 226
-    for (i = 0; i < NVARS; i++) {
-#line 226
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 226
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 226
         assert(var_nels[i] <= MAX_NELS);
-#line 226
-        err = nc_get_var_int(BAD_ID, i, value);
-#line 226
+        err = nc_get_var_uchar(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 226
 	    error("bad ncid: status = %d", err);
-#line 226
-        err = nc_get_var_int(ncid, BAD_VARID, value);
-#line 226
+        err = nc_get_var_uchar(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 226
 	    error("bad var id: status = %d", err);
-#line 226
 
-#line 226
 	nels = 1;
-#line 226
 	for (j = 0; j < var_rank[i]; j++) {
-#line 226
 	    nels *= var_shape[i][j];
-#line 226
 	}
-#line 226
 	allInExtRange = allInIntRange = 1;
-#line 226
 	for (j = 0; j < nels; j++) {
-#line 226
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 226
 	    IF (err)
-#line 226
 		error("error in toMixedBase 1");
-#line 226
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT);
-#line 226
-	    if (inRange3(expect[j],var_type[i], NCT_INT)) {
-#line 226
-		allInIntRange = allInIntRange && expect[j] >= int_min
-#line 226
-			    && expect[j] <= int_max;
-#line 226
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR);
+	    if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
+		allInIntRange = allInIntRange && expect[j] >= uchar_min
+			    && expect[j] <= uchar_max;
 	    } else {
-#line 226
 		allInExtRange = 0;
-#line 226
 	    }
-#line 226
 	}
-#line 226
-	err = nc_get_var_int(ncid, i, value);
-#line 226
+	err = nc_get_var_uchar(ncid, i, value);
 	if (canConvert) {
-#line 226
 	    if (allInExtRange) {
-#line 226
 		if (allInIntRange) {
-#line 226
 		    IF (err)
-#line 226
 			error("%s", nc_strerror(err));
-#line 226
 		} else {
-#line 226
 		    IF (err != NC_ERANGE)
-#line 226
 			error("Range error: status = %d", err);
-#line 226
 		}
-#line 226
 	    } else {
-#line 226
 		IF (err != 0 && err != NC_ERANGE)
-#line 226
 		    error("OK or Range error: status = %d", err);
-#line 226
 	    }
-#line 226
 	    for (j = 0; j < nels; j++) {
-#line 226
-		if (inRange3(expect[j],var_type[i],NCT_INT)
-#line 226
-			&& expect[j] >= int_min && expect[j] <= int_max) {
-#line 226
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){
-#line 226
+		if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+			&& expect[j] >= uchar_min && expect[j] <= uchar_max) {
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){
 			error("value read not that expected");
-#line 226
 			if (verbose) {
-#line 226
 			    error("\n");
-#line 226
 			    error("varid: %d, ", i);
-#line 226
 			    error("var_name: %s, ", var_name[i]);
-#line 226
 			    error("element number: %d ", j);
-#line 226
 			    error("expect: %g", expect[j]);
-#line 226
 			    error("got: %g", (double) value[j]);
-#line 226
 			}
-#line 226
 		    } else {
-#line 226
 			nok++;
-#line 226
 		    }
-#line 226
 		}
-#line 226
 	    }
-#line 226
 	} else {
-#line 226
 	    IF (nels > 0 && err != NC_ECHAR)
-#line 226
 		error("wrong type: status = %d", err);
-#line 226
 	}
-#line 226
     }
-#line 226
     err = nc_close(ncid);
-#line 226
     IF (err)
-#line 226
 	error("nc_close: %s", nc_strerror(err));
-#line 226
     print_nok(nok);
-#line 226
 }
-#line 226
 
 void
-#line 227
-test_nc_get_var_long(void)
-#line 227
+test_nc_get_var_schar(void)
 {
-#line 227
     int ncid;
-#line 227
     int i;
-#line 227
     int j;
-#line 227
     int err;
-#line 227
     int allInExtRange;	/* all values within external range? */
-#line 227
     int allInIntRange;	/* all values within internal range? */
-#line 227
     int nels;
-#line 227
     int nok = 0;      /* count of valid comparisons */
-#line 227
     size_t index[MAX_RANK];
-#line 227
     int canConvert;     /* Both text or both numeric */
-#line 227
-    long value[MAX_NELS];
-#line 227
+    schar value[MAX_NELS];
     double expect[MAX_NELS];
-#line 227
 
-#line 227
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 227
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 227
 	error("nc_open: %s", nc_strerror(err));
-#line 227
-    for (i = 0; i < NVARS; i++) {
-#line 227
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 227
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 227
         assert(var_nels[i] <= MAX_NELS);
-#line 227
-        err = nc_get_var_long(BAD_ID, i, value);
-#line 227
+        err = nc_get_var_schar(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 227
 	    error("bad ncid: status = %d", err);
-#line 227
-        err = nc_get_var_long(ncid, BAD_VARID, value);
-#line 227
+        err = nc_get_var_schar(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 227
 	    error("bad var id: status = %d", err);
-#line 227
 
-#line 227
 	nels = 1;
-#line 227
 	for (j = 0; j < var_rank[i]; j++) {
-#line 227
 	    nels *= var_shape[i][j];
-#line 227
 	}
-#line 227
 	allInExtRange = allInIntRange = 1;
-#line 227
 	for (j = 0; j < nels; j++) {
-#line 227
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 227
 	    IF (err)
-#line 227
 		error("error in toMixedBase 1");
-#line 227
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG);
-#line 227
-	    if (inRange3(expect[j],var_type[i], NCT_LONG)) {
-#line 227
-		allInIntRange = allInIntRange && expect[j] >= long_min
-#line 227
-			    && expect[j] <= long_max;
-#line 227
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR);
+	    if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
+		allInIntRange = allInIntRange && expect[j] >= schar_min
+			    && expect[j] <= schar_max;
 	    } else {
-#line 227
 		allInExtRange = 0;
-#line 227
 	    }
-#line 227
 	}
-#line 227
-	err = nc_get_var_long(ncid, i, value);
-#line 227
+	err = nc_get_var_schar(ncid, i, value);
 	if (canConvert) {
-#line 227
 	    if (allInExtRange) {
-#line 227
 		if (allInIntRange) {
-#line 227
 		    IF (err)
-#line 227
 			error("%s", nc_strerror(err));
-#line 227
 		} else {
-#line 227
 		    IF (err != NC_ERANGE)
-#line 227
 			error("Range error: status = %d", err);
-#line 227
 		}
-#line 227
 	    } else {
-#line 227
 		IF (err != 0 && err != NC_ERANGE)
-#line 227
 		    error("OK or Range error: status = %d", err);
-#line 227
 	    }
-#line 227
 	    for (j = 0; j < nels; j++) {
-#line 227
-		if (inRange3(expect[j],var_type[i],NCT_LONG)
-#line 227
-			&& expect[j] >= long_min && expect[j] <= long_max) {
-#line 227
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_LONG)){
-#line 227
+		if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+			&& expect[j] >= schar_min && expect[j] <= schar_max) {
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){
 			error("value read not that expected");
-#line 227
 			if (verbose) {
-#line 227
 			    error("\n");
-#line 227
 			    error("varid: %d, ", i);
-#line 227
 			    error("var_name: %s, ", var_name[i]);
-#line 227
 			    error("element number: %d ", j);
-#line 227
 			    error("expect: %g", expect[j]);
-#line 227
 			    error("got: %g", (double) value[j]);
-#line 227
 			}
-#line 227
 		    } else {
-#line 227
 			nok++;
-#line 227
 		    }
-#line 227
 		}
-#line 227
 	    }
-#line 227
 	} else {
-#line 227
 	    IF (nels > 0 && err != NC_ECHAR)
-#line 227
 		error("wrong type: status = %d", err);
-#line 227
 	}
-#line 227
     }
-#line 227
     err = nc_close(ncid);
-#line 227
     IF (err)
-#line 227
 	error("nc_close: %s", nc_strerror(err));
-#line 227
     print_nok(nok);
-#line 227
 }
-#line 227
 
 void
-#line 228
-test_nc_get_var_float(void)
-#line 228
+test_nc_get_var_short(void)
 {
-#line 228
     int ncid;
-#line 228
     int i;
-#line 228
     int j;
-#line 228
     int err;
-#line 228
     int allInExtRange;	/* all values within external range? */
-#line 228
     int allInIntRange;	/* all values within internal range? */
-#line 228
     int nels;
-#line 228
     int nok = 0;      /* count of valid comparisons */
-#line 228
     size_t index[MAX_RANK];
-#line 228
     int canConvert;     /* Both text or both numeric */
-#line 228
-    float value[MAX_NELS];
-#line 228
+    short value[MAX_NELS];
     double expect[MAX_NELS];
-#line 228
 
-#line 228
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 228
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 228
 	error("nc_open: %s", nc_strerror(err));
-#line 228
-    for (i = 0; i < NVARS; i++) {
-#line 228
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 228
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 228
         assert(var_nels[i] <= MAX_NELS);
-#line 228
-        err = nc_get_var_float(BAD_ID, i, value);
-#line 228
+        err = nc_get_var_short(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 228
 	    error("bad ncid: status = %d", err);
-#line 228
-        err = nc_get_var_float(ncid, BAD_VARID, value);
-#line 228
+        err = nc_get_var_short(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 228
 	    error("bad var id: status = %d", err);
-#line 228
 
-#line 228
 	nels = 1;
-#line 228
 	for (j = 0; j < var_rank[i]; j++) {
-#line 228
 	    nels *= var_shape[i][j];
-#line 228
 	}
-#line 228
 	allInExtRange = allInIntRange = 1;
-#line 228
 	for (j = 0; j < nels; j++) {
-#line 228
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 228
 	    IF (err)
-#line 228
 		error("error in toMixedBase 1");
-#line 228
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 228
-	    if (inRange3(expect[j],var_type[i], NCT_FLOAT)) {
-#line 228
-		allInIntRange = allInIntRange && expect[j] >= float_min
-#line 228
-			    && expect[j] <= float_max;
-#line 228
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT);
+	    if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
+		allInIntRange = allInIntRange && expect[j] >= short_min
+			    && expect[j] <= short_max;
 	    } else {
-#line 228
 		allInExtRange = 0;
-#line 228
 	    }
-#line 228
 	}
-#line 228
-	err = nc_get_var_float(ncid, i, value);
-#line 228
+	err = nc_get_var_short(ncid, i, value);
 	if (canConvert) {
-#line 228
 	    if (allInExtRange) {
-#line 228
 		if (allInIntRange) {
-#line 228
 		    IF (err)
-#line 228
 			error("%s", nc_strerror(err));
-#line 228
 		} else {
-#line 228
 		    IF (err != NC_ERANGE)
-#line 228
 			error("Range error: status = %d", err);
-#line 228
 		}
-#line 228
 	    } else {
-#line 228
 		IF (err != 0 && err != NC_ERANGE)
-#line 228
 		    error("OK or Range error: status = %d", err);
-#line 228
 	    }
-#line 228
 	    for (j = 0; j < nels; j++) {
-#line 228
-		if (inRange3(expect[j],var_type[i],NCT_FLOAT)
-#line 228
-			&& expect[j] >= float_min && expect[j] <= float_max) {
-#line 228
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_FLOAT)){
-#line 228
+		if (inRange3(expect[j],var_type[i],NCT_SHORT)
+			&& expect[j] >= short_min && expect[j] <= short_max) {
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){
 			error("value read not that expected");
-#line 228
 			if (verbose) {
-#line 228
 			    error("\n");
-#line 228
 			    error("varid: %d, ", i);
-#line 228
 			    error("var_name: %s, ", var_name[i]);
-#line 228
 			    error("element number: %d ", j);
-#line 228
 			    error("expect: %g", expect[j]);
-#line 228
 			    error("got: %g", (double) value[j]);
-#line 228
 			}
-#line 228
 		    } else {
-#line 228
 			nok++;
-#line 228
 		    }
-#line 228
 		}
-#line 228
 	    }
-#line 228
 	} else {
-#line 228
 	    IF (nels > 0 && err != NC_ECHAR)
-#line 228
 		error("wrong type: status = %d", err);
-#line 228
 	}
-#line 228
     }
-#line 228
     err = nc_close(ncid);
-#line 228
     IF (err)
-#line 228
 	error("nc_close: %s", nc_strerror(err));
-#line 228
     print_nok(nok);
-#line 228
 }
-#line 228
 
 void
-#line 229
-test_nc_get_var_double(void)
-#line 229
+test_nc_get_var_int(void)
 {
-#line 229
     int ncid;
-#line 229
     int i;
-#line 229
     int j;
-#line 229
     int err;
-#line 229
     int allInExtRange;	/* all values within external range? */
-#line 229
     int allInIntRange;	/* all values within internal range? */
-#line 229
     int nels;
-#line 229
     int nok = 0;      /* count of valid comparisons */
-#line 229
     size_t index[MAX_RANK];
-#line 229
     int canConvert;     /* Both text or both numeric */
-#line 229
-    double value[MAX_NELS];
-#line 229
+    int value[MAX_NELS];
     double expect[MAX_NELS];
-#line 229
 
-#line 229
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 229
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 229
 	error("nc_open: %s", nc_strerror(err));
-#line 229
-    for (i = 0; i < NVARS; i++) {
-#line 229
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 229
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 229
         assert(var_nels[i] <= MAX_NELS);
-#line 229
-        err = nc_get_var_double(BAD_ID, i, value);
-#line 229
+        err = nc_get_var_int(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 229
 	    error("bad ncid: status = %d", err);
-#line 229
-        err = nc_get_var_double(ncid, BAD_VARID, value);
-#line 229
+        err = nc_get_var_int(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 229
 	    error("bad var id: status = %d", err);
-#line 229
 
-#line 229
 	nels = 1;
-#line 229
 	for (j = 0; j < var_rank[i]; j++) {
-#line 229
 	    nels *= var_shape[i][j];
-#line 229
 	}
-#line 229
 	allInExtRange = allInIntRange = 1;
-#line 229
 	for (j = 0; j < nels; j++) {
-#line 229
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 229
 	    IF (err)
-#line 229
 		error("error in toMixedBase 1");
-#line 229
-	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 229
-	    if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) {
-#line 229
-		allInIntRange = allInIntRange && expect[j] >= double_min
-#line 229
-			    && expect[j] <= double_max;
-#line 229
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT);
+	    if (inRange3(expect[j],var_type[i], NCT_INT)) {
+		allInIntRange = allInIntRange && expect[j] >= int_min
+			    && expect[j] <= int_max;
 	    } else {
-#line 229
 		allInExtRange = 0;
-#line 229
 	    }
-#line 229
 	}
-#line 229
-	err = nc_get_var_double(ncid, i, value);
-#line 229
+	err = nc_get_var_int(ncid, i, value);
 	if (canConvert) {
-#line 229
 	    if (allInExtRange) {
-#line 229
 		if (allInIntRange) {
-#line 229
 		    IF (err)
-#line 229
 			error("%s", nc_strerror(err));
-#line 229
 		} else {
-#line 229
 		    IF (err != NC_ERANGE)
-#line 229
 			error("Range error: status = %d", err);
-#line 229
 		}
-#line 229
 	    } else {
-#line 229
 		IF (err != 0 && err != NC_ERANGE)
-#line 229
 		    error("OK or Range error: status = %d", err);
-#line 229
 	    }
-#line 229
 	    for (j = 0; j < nels; j++) {
-#line 229
-		if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
-#line 229
-			&& expect[j] >= double_min && expect[j] <= double_max) {
-#line 229
-		    IF (!equal(value[j],expect[j],var_type[i],NCT_DOUBLE)){
-#line 229
+		if (inRange3(expect[j],var_type[i],NCT_INT)
+			&& expect[j] >= int_min && expect[j] <= int_max) {
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){
 			error("value read not that expected");
-#line 229
 			if (verbose) {
-#line 229
 			    error("\n");
-#line 229
 			    error("varid: %d, ", i);
-#line 229
 			    error("var_name: %s, ", var_name[i]);
-#line 229
 			    error("element number: %d ", j);
-#line 229
 			    error("expect: %g", expect[j]);
-#line 229
 			    error("got: %g", (double) value[j]);
-#line 229
 			}
-#line 229
 		    } else {
-#line 229
 			nok++;
-#line 229
 		    }
-#line 229
 		}
-#line 229
 	    }
-#line 229
 	} else {
-#line 229
 	    IF (nels > 0 && err != NC_ECHAR)
-#line 229
 		error("wrong type: status = %d", err);
-#line 229
 	}
-#line 229
     }
-#line 229
     err = nc_close(ncid);
-#line 229
     IF (err)
-#line 229
 	error("nc_close: %s", nc_strerror(err));
-#line 229
     print_nok(nok);
-#line 229
 }
-#line 229
-
-
-
-#line 401
 
 void
-#line 402
-test_nc_get_vara_text(void)
-#line 402
+test_nc_get_var_long(void)
 {
-#line 402
     int ncid;
-#line 402
-    int d;
-#line 402
     int i;
-#line 402
     int j;
-#line 402
-    int k;
-#line 402
     int err;
-#line 402
     int allInExtRange;	/* all values within external range? */
-#line 402
     int allInIntRange;	/* all values within internal range? */
-#line 402
     int nels;
-#line 402
-    int nslabs;
-#line 402
     int nok = 0;      /* count of valid comparisons */
-#line 402
-    size_t start[MAX_RANK];
-#line 402
-    size_t edge[MAX_RANK];
-#line 402
     size_t index[MAX_RANK];
-#line 402
-    size_t mid[MAX_RANK];
-#line 402
     int canConvert;     /* Both text or both numeric */
-#line 402
-    text value[MAX_NELS];
-#line 402
+    long value[MAX_NELS];
     double expect[MAX_NELS];
-#line 402
 
-#line 402
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 402
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 402
 	error("nc_open: %s", nc_strerror(err));
-#line 402
-    for (i = 0; i < NVARS; i++) {
-#line 402
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 402
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 402
         assert(var_nels[i] <= MAX_NELS);
-#line 402
-	for (j = 0; j < var_rank[i]; j++) {
-#line 402
-	    start[j] = 0;
-#line 402
-	    edge[j] = 1;
-#line 402
-	}
-#line 402
-        err = nc_get_vara_text(BAD_ID, i, start, edge, value);
-#line 402
+        err = nc_get_var_long(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 402
 	    error("bad ncid: status = %d", err);
-#line 402
-        err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value);
-#line 402
+        err = nc_get_var_long(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 402
 	    error("bad var id: status = %d", err);
-#line 402
+
+	nels = 1;
 	for (j = 0; j < var_rank[i]; j++) {
-#line 402
-	    start[j] = var_shape[i][j];
-#line 402
-	    err = nc_get_vara_text(ncid, i, start, edge, value);
-#line 402
-            IF (canConvert && err != NC_EINVALCOORDS)
-#line 402
-                error("bad index: status = %d", err);
-#line 402
-	    start[j] = 0;
-#line 402
-	    edge[j] = var_shape[i][j] + 1;
-#line 402
-	    err = nc_get_vara_text(ncid, i, start, edge, value);
-#line 402
-            IF (canConvert && err != NC_EEDGE)
-#line 402
-		error("bad edge: status = %d", err);
-#line 402
-	    edge[j] = 1;
-#line 402
+	    nels *= var_shape[i][j];
 	}
-#line 402
-            /* Check non-scalars for correct error returned even when */
-#line 402
-            /* there is nothing to get (edge[j]==0) */
-#line 402
-	if(var_rank[i] > 0) {
-#line 402
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 402
-		edge[j] = 0;
-#line 402
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG);
+	    if (inRange3(expect[j],var_type[i], NCT_LONG)) {
+		allInIntRange = allInIntRange && expect[j] >= long_min
+			    && expect[j] <= long_max;
+	    } else {
+		allInExtRange = 0;
 	    }
-#line 402
-	    err = nc_get_vara_text(BAD_ID, i, start, edge, value);
-#line 402
-	    IF (err != NC_EBADID) 
-#line 402
-		error("bad ncid: status = %d", err);
-#line 402
-	    err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value);
-#line 402
-	    IF (err != NC_ENOTVAR) 
-#line 402
-		error("bad var id: status = %d", err);
-#line 402
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 402
-		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 402
-		    start[j] = var_shape[i][j];
-#line 402
-		    err = nc_get_vara_text(ncid, i, start, edge, value);
-#line 402
-		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 402
-			error("bad start: status = %d", err);
-#line 402
-		    start[j] = 0;
-#line 402
-		}
-#line 402
-	    }
-#line 402
-	    err = nc_get_vara_text(ncid, i, start, edge, value);
-#line 402
-	    if (canConvert) {
-#line 402
-		IF (err) 
-#line 402
-		    error("%s", nc_strerror(err));
-#line 402
-	    } else {
-#line 402
-		IF (err != NC_ECHAR)
-#line 402
-		    error("wrong type: status = %d", err);
-#line 402
-	    }
-#line 402
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 402
-		edge[j] = 1;
-#line 402
-	    }
-#line 402
-	}            /* Choose a random point dividing each dim into 2 parts */
-#line 402
-            /* get 2^rank (nslabs) slabs so defined */
-#line 402
-        nslabs = 1;
-#line 402
-        for (j = 0; j < var_rank[i]; j++) {
-#line 402
-            mid[j] = roll( var_shape[i][j] );
-#line 402
-            nslabs *= 2;
-#line 402
-        }
-#line 402
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 402
-        for (k = 0; k < nslabs; k++) {
-#line 402
-            nels = 1;
-#line 402
-            for (j = 0; j < var_rank[i]; j++) {
-#line 402
-                if ((k >> j) & 1) {
-#line 402
-                    start[j] = 0;
-#line 402
-                    edge[j] = mid[j];
-#line 402
-                }else{
-#line 402
-                    start[j] = mid[j];
-#line 402
-                    edge[j] = var_shape[i][j] - mid[j];
-#line 402
-                }
-#line 402
-                nels *= edge[j];
-#line 402
-            }
-#line 402
-	    allInExtRange = allInIntRange = 1;
-#line 402
-            for (j = 0; j < nels; j++) {
-#line 402
-                err = toMixedBase(j, var_rank[i], edge, index);
-#line 402
-                IF (err)
-#line 402
-                    error("error in toMixedBase 1");
-#line 402
-                for (d = 0; d < var_rank[i]; d++)
-#line 402
-                    index[d] += start[d];
-#line 402
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT);
-#line 402
-		if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
-#line 402
-		    allInIntRange = allInIntRange && expect[j] >= text_min
-#line 402
-				&& expect[j] <= text_max;
-#line 402
+	}
+	err = nc_get_var_long(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		if (allInIntRange) {
+		    IF (err)
+			error("%s", nc_strerror(err));
 		} else {
-#line 402
-		    allInExtRange = 0;
-#line 402
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
 		}
-#line 402
+	    } else {
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
 	    }
-#line 402
-            if (var_rank[i] == 0 && i%2)
-#line 402
-		err = nc_get_vara_text(ncid, i, NULL, NULL, value);
-#line 402
-	    else
-#line 402
-		err = nc_get_vara_text(ncid, i, start, edge, value);
-#line 402
-            if (canConvert) {
-#line 402
-		if (allInExtRange) {
-#line 402
-		    if (allInIntRange) {
-#line 402
-			IF (err)
-#line 402
-			    error("%s", nc_strerror(err));
-#line 402
-		    } else {
-#line 402
-			IF (err != NC_ERANGE)
-#line 402
-			    error("Range error: status = %d", err);
-#line 402
-		    }
-#line 402
-		} else {
-#line 402
-		    IF (err != 0 && err != NC_ERANGE)
-#line 402
-			error("OK or Range error: status = %d", err);
-#line 402
-		}
-#line 402
-		for (j = 0; j < nels; j++) {
-#line 402
-		    if (inRange3(expect[j],var_type[i],NCT_TEXT)
-#line 402
-			    && expect[j] >= text_min && expect[j] <= text_max) {
-#line 402
-			IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){
-#line 402
-			    error("value read not that expected");
-#line 402
-			    if (verbose) {
-#line 402
-				error("\n");
-#line 402
-				error("varid: %d, ", i);
-#line 402
-				error("var_name: %s, ", var_name[i]);
-#line 402
-				error("element number: %d ", j);
-#line 402
-				error("expect: %g", expect[j]);
-#line 402
-				error("got: %g", (double) value[j]);
-#line 402
-			    }
-#line 402
-			} else {
-#line 402
-			    nok++;
-#line 402
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_LONG)
+			&& expect[j] >= long_min && expect[j] <= long_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
 			}
-#line 402
+		    } else {
+			nok++;
 		    }
-#line 402
 		}
-#line 402
-            } else {
-#line 402
-                IF (nels > 0 && err != NC_ECHAR)
-#line 402
-                    error("wrong type: status = %d", err);
-#line 402
-            }
-#line 402
-        }
-#line 402
+	    }
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
     }
-#line 402
     err = nc_close(ncid);
-#line 402
     IF (err)
-#line 402
 	error("nc_close: %s", nc_strerror(err));
-#line 402
     print_nok(nok);
-#line 402
 }
-#line 402
 
 void
-#line 403
-test_nc_get_vara_uchar(void)
-#line 403
+test_nc_get_var_float(void)
 {
-#line 403
     int ncid;
-#line 403
-    int d;
-#line 403
     int i;
-#line 403
     int j;
-#line 403
-    int k;
-#line 403
     int err;
-#line 403
     int allInExtRange;	/* all values within external range? */
-#line 403
     int allInIntRange;	/* all values within internal range? */
-#line 403
     int nels;
-#line 403
-    int nslabs;
-#line 403
     int nok = 0;      /* count of valid comparisons */
-#line 403
-    size_t start[MAX_RANK];
-#line 403
-    size_t edge[MAX_RANK];
-#line 403
     size_t index[MAX_RANK];
-#line 403
-    size_t mid[MAX_RANK];
-#line 403
     int canConvert;     /* Both text or both numeric */
-#line 403
-    uchar value[MAX_NELS];
-#line 403
+    float value[MAX_NELS];
     double expect[MAX_NELS];
-#line 403
 
-#line 403
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 403
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 403
 	error("nc_open: %s", nc_strerror(err));
-#line 403
-    for (i = 0; i < NVARS; i++) {
-#line 403
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 403
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 403
         assert(var_nels[i] <= MAX_NELS);
-#line 403
-	for (j = 0; j < var_rank[i]; j++) {
-#line 403
-	    start[j] = 0;
-#line 403
-	    edge[j] = 1;
-#line 403
-	}
-#line 403
-        err = nc_get_vara_uchar(BAD_ID, i, start, edge, value);
-#line 403
+        err = nc_get_var_float(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 403
 	    error("bad ncid: status = %d", err);
-#line 403
-        err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value);
-#line 403
+        err = nc_get_var_float(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 403
 	    error("bad var id: status = %d", err);
-#line 403
+
+	nels = 1;
 	for (j = 0; j < var_rank[i]; j++) {
-#line 403
-	    start[j] = var_shape[i][j];
-#line 403
-	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
-#line 403
-            IF (canConvert && err != NC_EINVALCOORDS)
-#line 403
-                error("bad index: status = %d", err);
-#line 403
-	    start[j] = 0;
-#line 403
-	    edge[j] = var_shape[i][j] + 1;
-#line 403
-	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
-#line 403
-            IF (canConvert && err != NC_EEDGE)
-#line 403
-		error("bad edge: status = %d", err);
-#line 403
-	    edge[j] = 1;
-#line 403
+	    nels *= var_shape[i][j];
 	}
-#line 403
-            /* Check non-scalars for correct error returned even when */
-#line 403
-            /* there is nothing to get (edge[j]==0) */
-#line 403
-	if(var_rank[i] > 0) {
-#line 403
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 403
-		edge[j] = 0;
-#line 403
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT);
+	    if (inRange3(expect[j],var_type[i], NCT_FLOAT)) {
+		allInIntRange = allInIntRange && expect[j] >= float_min
+			    && expect[j] <= float_max;
+	    } else {
+		allInExtRange = 0;
 	    }
-#line 403
-	    err = nc_get_vara_uchar(BAD_ID, i, start, edge, value);
-#line 403
-	    IF (err != NC_EBADID) 
-#line 403
-		error("bad ncid: status = %d", err);
-#line 403
-	    err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value);
-#line 403
-	    IF (err != NC_ENOTVAR) 
-#line 403
-		error("bad var id: status = %d", err);
-#line 403
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 403
-		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 403
-		    start[j] = var_shape[i][j];
-#line 403
-		    err = nc_get_vara_uchar(ncid, i, start, edge, value);
-#line 403
-		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 403
-			error("bad start: status = %d", err);
-#line 403
-		    start[j] = 0;
-#line 403
+	}
+	err = nc_get_var_float(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		if (allInIntRange) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
 		}
-#line 403
-	    }
-#line 403
-	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
-#line 403
-	    if (canConvert) {
-#line 403
-		IF (err) 
-#line 403
-		    error("%s", nc_strerror(err));
-#line 403
 	    } else {
-#line 403
-		IF (err != NC_ECHAR)
-#line 403
-		    error("wrong type: status = %d", err);
-#line 403
-	    }
-#line 403
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 403
-		edge[j] = 1;
-#line 403
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
 	    }
-#line 403
-	}            /* Choose a random point dividing each dim into 2 parts */
-#line 403
-            /* get 2^rank (nslabs) slabs so defined */
-#line 403
-        nslabs = 1;
-#line 403
-        for (j = 0; j < var_rank[i]; j++) {
-#line 403
-            mid[j] = roll( var_shape[i][j] );
-#line 403
-            nslabs *= 2;
-#line 403
-        }
-#line 403
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 403
-        for (k = 0; k < nslabs; k++) {
-#line 403
-            nels = 1;
-#line 403
-            for (j = 0; j < var_rank[i]; j++) {
-#line 403
-                if ((k >> j) & 1) {
-#line 403
-                    start[j] = 0;
-#line 403
-                    edge[j] = mid[j];
-#line 403
-                }else{
-#line 403
-                    start[j] = mid[j];
-#line 403
-                    edge[j] = var_shape[i][j] - mid[j];
-#line 403
-                }
-#line 403
-                nels *= edge[j];
-#line 403
-            }
-#line 403
-	    allInExtRange = allInIntRange = 1;
-#line 403
-            for (j = 0; j < nels; j++) {
-#line 403
-                err = toMixedBase(j, var_rank[i], edge, index);
-#line 403
-                IF (err)
-#line 403
-                    error("error in toMixedBase 1");
-#line 403
-                for (d = 0; d < var_rank[i]; d++)
-#line 403
-                    index[d] += start[d];
-#line 403
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 403
-		if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
-#line 403
-		    allInIntRange = allInIntRange && expect[j] >= uchar_min
-#line 403
-				&& expect[j] <= uchar_max;
-#line 403
-		} else {
-#line 403
-		    allInExtRange = 0;
-#line 403
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+			&& expect[j] >= float_min && expect[j] <= float_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
+			}
+		    } else {
+			nok++;
+		    }
 		}
-#line 403
 	    }
-#line 403
-            if (var_rank[i] == 0 && i%2)
-#line 403
-		err = nc_get_vara_uchar(ncid, i, NULL, NULL, value);
-#line 403
-	    else
-#line 403
-		err = nc_get_vara_uchar(ncid, i, start, edge, value);
-#line 403
-            if (canConvert) {
-#line 403
-		if (allInExtRange) {
-#line 403
-		    if (allInIntRange) {
-#line 403
-			IF (err)
-#line 403
-			    error("%s", nc_strerror(err));
-#line 403
-		    } else {
-#line 403
-			IF (err != NC_ERANGE)
-#line 403
-			    error("Range error: status = %d", err);
-#line 403
-		    }
-#line 403
-		} else {
-#line 403
-		    IF (err != 0 && err != NC_ERANGE)
-#line 403
-			error("OK or Range error: status = %d", err);
-#line 403
-		}
-#line 403
-		for (j = 0; j < nels; j++) {
-#line 403
-		    if (inRange3(expect[j],var_type[i],NCT_UCHAR)
-#line 403
-			    && expect[j] >= uchar_min && expect[j] <= uchar_max) {
-#line 403
-			IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){
-#line 403
-			    error("value read not that expected");
-#line 403
-			    if (verbose) {
-#line 403
-				error("\n");
-#line 403
-				error("varid: %d, ", i);
-#line 403
-				error("var_name: %s, ", var_name[i]);
-#line 403
-				error("element number: %d ", j);
-#line 403
-				error("expect: %g", expect[j]);
-#line 403
-				error("got: %g", (double) value[j]);
-#line 403
-			    }
-#line 403
-			} else {
-#line 403
-			    nok++;
-#line 403
-			}
-#line 403
-		    }
-#line 403
-		}
-#line 403
-            } else {
-#line 403
-                IF (nels > 0 && err != NC_ECHAR)
-#line 403
-                    error("wrong type: status = %d", err);
-#line 403
-            }
-#line 403
-        }
-#line 403
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
     }
-#line 403
     err = nc_close(ncid);
-#line 403
     IF (err)
-#line 403
 	error("nc_close: %s", nc_strerror(err));
-#line 403
     print_nok(nok);
-#line 403
 }
-#line 403
 
 void
-#line 404
-test_nc_get_vara_schar(void)
-#line 404
+test_nc_get_var_double(void)
 {
-#line 404
     int ncid;
-#line 404
-    int d;
-#line 404
     int i;
-#line 404
     int j;
-#line 404
-    int k;
-#line 404
     int err;
-#line 404
     int allInExtRange;	/* all values within external range? */
-#line 404
     int allInIntRange;	/* all values within internal range? */
-#line 404
     int nels;
-#line 404
-    int nslabs;
-#line 404
     int nok = 0;      /* count of valid comparisons */
-#line 404
-    size_t start[MAX_RANK];
-#line 404
-    size_t edge[MAX_RANK];
-#line 404
     size_t index[MAX_RANK];
-#line 404
-    size_t mid[MAX_RANK];
-#line 404
     int canConvert;     /* Both text or both numeric */
-#line 404
-    schar value[MAX_NELS];
-#line 404
+    double value[MAX_NELS];
     double expect[MAX_NELS];
-#line 404
 
-#line 404
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 404
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 404
 	error("nc_open: %s", nc_strerror(err));
-#line 404
-    for (i = 0; i < NVARS; i++) {
-#line 404
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 404
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 404
         assert(var_nels[i] <= MAX_NELS);
-#line 404
-	for (j = 0; j < var_rank[i]; j++) {
-#line 404
-	    start[j] = 0;
-#line 404
-	    edge[j] = 1;
-#line 404
-	}
-#line 404
-        err = nc_get_vara_schar(BAD_ID, i, start, edge, value);
-#line 404
+        err = nc_get_var_double(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 404
 	    error("bad ncid: status = %d", err);
-#line 404
-        err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value);
-#line 404
+        err = nc_get_var_double(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 404
 	    error("bad var id: status = %d", err);
-#line 404
+
+	nels = 1;
 	for (j = 0; j < var_rank[i]; j++) {
-#line 404
-	    start[j] = var_shape[i][j];
-#line 404
-	    err = nc_get_vara_schar(ncid, i, start, edge, value);
-#line 404
-            IF (canConvert && err != NC_EINVALCOORDS)
-#line 404
-                error("bad index: status = %d", err);
-#line 404
-	    start[j] = 0;
-#line 404
-	    edge[j] = var_shape[i][j] + 1;
-#line 404
-	    err = nc_get_vara_schar(ncid, i, start, edge, value);
-#line 404
-            IF (canConvert && err != NC_EEDGE)
-#line 404
-		error("bad edge: status = %d", err);
-#line 404
-	    edge[j] = 1;
-#line 404
+	    nels *= var_shape[i][j];
 	}
-#line 404
-            /* Check non-scalars for correct error returned even when */
-#line 404
-            /* there is nothing to get (edge[j]==0) */
-#line 404
-	if(var_rank[i] > 0) {
-#line 404
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 404
-		edge[j] = 0;
-#line 404
-	    }
-#line 404
-	    err = nc_get_vara_schar(BAD_ID, i, start, edge, value);
-#line 404
-	    IF (err != NC_EBADID) 
-#line 404
-		error("bad ncid: status = %d", err);
-#line 404
-	    err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value);
-#line 404
-	    IF (err != NC_ENOTVAR) 
-#line 404
-		error("bad var id: status = %d", err);
-#line 404
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 404
-		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 404
-		    start[j] = var_shape[i][j];
-#line 404
-		    err = nc_get_vara_schar(ncid, i, start, edge, value);
-#line 404
-		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 404
-			error("bad start: status = %d", err);
-#line 404
-		    start[j] = 0;
-#line 404
-		}
-#line 404
-	    }
-#line 404
-	    err = nc_get_vara_schar(ncid, i, start, edge, value);
-#line 404
-	    if (canConvert) {
-#line 404
-		IF (err) 
-#line 404
-		    error("%s", nc_strerror(err));
-#line 404
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE);
+	    if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) {
+		allInIntRange = allInIntRange && expect[j] >= double_min
+			    && expect[j] <= double_max;
 	    } else {
-#line 404
-		IF (err != NC_ECHAR)
-#line 404
-		    error("wrong type: status = %d", err);
-#line 404
-	    }
-#line 404
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 404
-		edge[j] = 1;
-#line 404
+		allInExtRange = 0;
 	    }
-#line 404
-	}            /* Choose a random point dividing each dim into 2 parts */
-#line 404
-            /* get 2^rank (nslabs) slabs so defined */
-#line 404
-        nslabs = 1;
-#line 404
-        for (j = 0; j < var_rank[i]; j++) {
-#line 404
-            mid[j] = roll( var_shape[i][j] );
-#line 404
-            nslabs *= 2;
-#line 404
-        }
-#line 404
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 404
-        for (k = 0; k < nslabs; k++) {
-#line 404
-            nels = 1;
-#line 404
-            for (j = 0; j < var_rank[i]; j++) {
-#line 404
-                if ((k >> j) & 1) {
-#line 404
-                    start[j] = 0;
-#line 404
-                    edge[j] = mid[j];
-#line 404
-                }else{
-#line 404
-                    start[j] = mid[j];
-#line 404
-                    edge[j] = var_shape[i][j] - mid[j];
-#line 404
-                }
-#line 404
-                nels *= edge[j];
-#line 404
-            }
-#line 404
-	    allInExtRange = allInIntRange = 1;
-#line 404
-            for (j = 0; j < nels; j++) {
-#line 404
-                err = toMixedBase(j, var_rank[i], edge, index);
-#line 404
-                IF (err)
-#line 404
-                    error("error in toMixedBase 1");
-#line 404
-                for (d = 0; d < var_rank[i]; d++)
-#line 404
-                    index[d] += start[d];
-#line 404
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 404
-		if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
-#line 404
-		    allInIntRange = allInIntRange && expect[j] >= schar_min
-#line 404
-				&& expect[j] <= schar_max;
-#line 404
+	}
+	err = nc_get_var_double(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		if (allInIntRange) {
+		    IF (err)
+			error("%s", nc_strerror(err));
 		} else {
-#line 404
-		    allInExtRange = 0;
-#line 404
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
 		}
-#line 404
+	    } else {
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
 	    }
-#line 404
-            if (var_rank[i] == 0 && i%2)
-#line 404
-		err = nc_get_vara_schar(ncid, i, NULL, NULL, value);
-#line 404
-	    else
-#line 404
-		err = nc_get_vara_schar(ncid, i, start, edge, value);
-#line 404
-            if (canConvert) {
-#line 404
-		if (allInExtRange) {
-#line 404
-		    if (allInIntRange) {
-#line 404
-			IF (err)
-#line 404
-			    error("%s", nc_strerror(err));
-#line 404
-		    } else {
-#line 404
-			IF (err != NC_ERANGE)
-#line 404
-			    error("Range error: status = %d", err);
-#line 404
-		    }
-#line 404
-		} else {
-#line 404
-		    IF (err != 0 && err != NC_ERANGE)
-#line 404
-			error("OK or Range error: status = %d", err);
-#line 404
-		}
-#line 404
-		for (j = 0; j < nels; j++) {
-#line 404
-		    if (inRange3(expect[j],var_type[i],NCT_SCHAR)
-#line 404
-			    && expect[j] >= schar_min && expect[j] <= schar_max) {
-#line 404
-			IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){
-#line 404
-			    error("value read not that expected");
-#line 404
-			    if (verbose) {
-#line 404
-				error("\n");
-#line 404
-				error("varid: %d, ", i);
-#line 404
-				error("var_name: %s, ", var_name[i]);
-#line 404
-				error("element number: %d ", j);
-#line 404
-				error("expect: %g", expect[j]);
-#line 404
-				error("got: %g", (double) value[j]);
-#line 404
-			    }
-#line 404
-			} else {
-#line 404
-			    nok++;
-#line 404
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+			&& expect[j] >= double_min && expect[j] <= double_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
 			}
-#line 404
+		    } else {
+			nok++;
 		    }
-#line 404
 		}
-#line 404
-            } else {
-#line 404
-                IF (nels > 0 && err != NC_ECHAR)
-#line 404
-                    error("wrong type: status = %d", err);
-#line 404
-            }
-#line 404
-        }
-#line 404
+	    }
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
     }
-#line 404
     err = nc_close(ncid);
-#line 404
     IF (err)
-#line 404
 	error("nc_close: %s", nc_strerror(err));
-#line 404
     print_nok(nok);
-#line 404
 }
-#line 404
 
 void
-#line 405
-test_nc_get_vara_short(void)
-#line 405
+test_nc_get_var_ushort(void)
 {
-#line 405
     int ncid;
-#line 405
-    int d;
-#line 405
     int i;
-#line 405
     int j;
-#line 405
-    int k;
-#line 405
     int err;
-#line 405
     int allInExtRange;	/* all values within external range? */
-#line 405
     int allInIntRange;	/* all values within internal range? */
-#line 405
     int nels;
-#line 405
-    int nslabs;
-#line 405
     int nok = 0;      /* count of valid comparisons */
-#line 405
-    size_t start[MAX_RANK];
-#line 405
-    size_t edge[MAX_RANK];
-#line 405
     size_t index[MAX_RANK];
-#line 405
-    size_t mid[MAX_RANK];
-#line 405
     int canConvert;     /* Both text or both numeric */
-#line 405
-    short value[MAX_NELS];
-#line 405
+    ushort value[MAX_NELS];
     double expect[MAX_NELS];
-#line 405
 
-#line 405
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 405
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 405
 	error("nc_open: %s", nc_strerror(err));
-#line 405
-    for (i = 0; i < NVARS; i++) {
-#line 405
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 405
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 405
         assert(var_nels[i] <= MAX_NELS);
-#line 405
-	for (j = 0; j < var_rank[i]; j++) {
-#line 405
-	    start[j] = 0;
-#line 405
-	    edge[j] = 1;
-#line 405
-	}
-#line 405
-        err = nc_get_vara_short(BAD_ID, i, start, edge, value);
-#line 405
+        err = nc_get_var_ushort(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 405
 	    error("bad ncid: status = %d", err);
-#line 405
-        err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value);
-#line 405
+        err = nc_get_var_ushort(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 405
 	    error("bad var id: status = %d", err);
-#line 405
+
+	nels = 1;
 	for (j = 0; j < var_rank[i]; j++) {
-#line 405
-	    start[j] = var_shape[i][j];
-#line 405
-	    err = nc_get_vara_short(ncid, i, start, edge, value);
-#line 405
-            IF (canConvert && err != NC_EINVALCOORDS)
-#line 405
-                error("bad index: status = %d", err);
-#line 405
-	    start[j] = 0;
-#line 405
-	    edge[j] = var_shape[i][j] + 1;
-#line 405
-	    err = nc_get_vara_short(ncid, i, start, edge, value);
-#line 405
-            IF (canConvert && err != NC_EEDGE)
-#line 405
-		error("bad edge: status = %d", err);
-#line 405
-	    edge[j] = 1;
-#line 405
+	    nels *= var_shape[i][j];
 	}
-#line 405
-            /* Check non-scalars for correct error returned even when */
-#line 405
-            /* there is nothing to get (edge[j]==0) */
-#line 405
-	if(var_rank[i] > 0) {
-#line 405
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 405
-		edge[j] = 0;
-#line 405
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_USHORT);
+	    if (inRange3(expect[j],var_type[i], NCT_USHORT)) {
+		allInIntRange = allInIntRange && expect[j] >= ushort_min
+			    && expect[j] <= ushort_max;
+	    } else {
+		allInExtRange = 0;
 	    }
-#line 405
-	    err = nc_get_vara_short(BAD_ID, i, start, edge, value);
-#line 405
-	    IF (err != NC_EBADID) 
-#line 405
-		error("bad ncid: status = %d", err);
-#line 405
-	    err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value);
-#line 405
-	    IF (err != NC_ENOTVAR) 
-#line 405
-		error("bad var id: status = %d", err);
-#line 405
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 405
-		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 405
-		    start[j] = var_shape[i][j];
-#line 405
-		    err = nc_get_vara_short(ncid, i, start, edge, value);
-#line 405
-		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 405
-			error("bad start: status = %d", err);
-#line 405
-		    start[j] = 0;
-#line 405
-		}
-#line 405
-	    }
-#line 405
-	    err = nc_get_vara_short(ncid, i, start, edge, value);
-#line 405
-	    if (canConvert) {
-#line 405
-		IF (err) 
-#line 405
-		    error("%s", nc_strerror(err));
-#line 405
-	    } else {
-#line 405
-		IF (err != NC_ECHAR)
-#line 405
-		    error("wrong type: status = %d", err);
-#line 405
-	    }
-#line 405
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 405
-		edge[j] = 1;
-#line 405
-	    }
-#line 405
-	}            /* Choose a random point dividing each dim into 2 parts */
-#line 405
-            /* get 2^rank (nslabs) slabs so defined */
-#line 405
-        nslabs = 1;
-#line 405
-        for (j = 0; j < var_rank[i]; j++) {
-#line 405
-            mid[j] = roll( var_shape[i][j] );
-#line 405
-            nslabs *= 2;
-#line 405
-        }
-#line 405
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 405
-        for (k = 0; k < nslabs; k++) {
-#line 405
-            nels = 1;
-#line 405
-            for (j = 0; j < var_rank[i]; j++) {
-#line 405
-                if ((k >> j) & 1) {
-#line 405
-                    start[j] = 0;
-#line 405
-                    edge[j] = mid[j];
-#line 405
-                }else{
-#line 405
-                    start[j] = mid[j];
-#line 405
-                    edge[j] = var_shape[i][j] - mid[j];
-#line 405
-                }
-#line 405
-                nels *= edge[j];
-#line 405
-            }
-#line 405
-	    allInExtRange = allInIntRange = 1;
-#line 405
-            for (j = 0; j < nels; j++) {
-#line 405
-                err = toMixedBase(j, var_rank[i], edge, index);
-#line 405
-                IF (err)
-#line 405
-                    error("error in toMixedBase 1");
-#line 405
-                for (d = 0; d < var_rank[i]; d++)
-#line 405
-                    index[d] += start[d];
-#line 405
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT);
-#line 405
-		if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
-#line 405
-		    allInIntRange = allInIntRange && expect[j] >= short_min
-#line 405
-				&& expect[j] <= short_max;
-#line 405
+	}
+	err = nc_get_var_ushort(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		if (allInIntRange) {
+		    IF (err)
+			error("%s", nc_strerror(err));
 		} else {
-#line 405
-		    allInExtRange = 0;
-#line 405
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
 		}
-#line 405
+	    } else {
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
 	    }
-#line 405
-            if (var_rank[i] == 0 && i%2)
-#line 405
-		err = nc_get_vara_short(ncid, i, NULL, NULL, value);
-#line 405
-	    else
-#line 405
-		err = nc_get_vara_short(ncid, i, start, edge, value);
-#line 405
-            if (canConvert) {
-#line 405
-		if (allInExtRange) {
-#line 405
-		    if (allInIntRange) {
-#line 405
-			IF (err)
-#line 405
-			    error("%s", nc_strerror(err));
-#line 405
-		    } else {
-#line 405
-			IF (err != NC_ERANGE)
-#line 405
-			    error("Range error: status = %d", err);
-#line 405
-		    }
-#line 405
-		} else {
-#line 405
-		    IF (err != 0 && err != NC_ERANGE)
-#line 405
-			error("OK or Range error: status = %d", err);
-#line 405
-		}
-#line 405
-		for (j = 0; j < nels; j++) {
-#line 405
-		    if (inRange3(expect[j],var_type[i],NCT_SHORT)
-#line 405
-			    && expect[j] >= short_min && expect[j] <= short_max) {
-#line 405
-			IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){
-#line 405
-			    error("value read not that expected");
-#line 405
-			    if (verbose) {
-#line 405
-				error("\n");
-#line 405
-				error("varid: %d, ", i);
-#line 405
-				error("var_name: %s, ", var_name[i]);
-#line 405
-				error("element number: %d ", j);
-#line 405
-				error("expect: %g", expect[j]);
-#line 405
-				error("got: %g", (double) value[j]);
-#line 405
-			    }
-#line 405
-			} else {
-#line 405
-			    nok++;
-#line 405
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_USHORT)
+			&& expect[j] >= ushort_min && expect[j] <= ushort_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
 			}
-#line 405
+		    } else {
+			nok++;
 		    }
-#line 405
 		}
-#line 405
-            } else {
-#line 405
-                IF (nels > 0 && err != NC_ECHAR)
-#line 405
-                    error("wrong type: status = %d", err);
-#line 405
-            }
-#line 405
-        }
-#line 405
+	    }
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
     }
-#line 405
     err = nc_close(ncid);
-#line 405
     IF (err)
-#line 405
 	error("nc_close: %s", nc_strerror(err));
-#line 405
     print_nok(nok);
-#line 405
 }
-#line 405
 
 void
-#line 406
-test_nc_get_vara_int(void)
-#line 406
+test_nc_get_var_uint(void)
 {
-#line 406
     int ncid;
-#line 406
-    int d;
-#line 406
     int i;
-#line 406
     int j;
-#line 406
-    int k;
-#line 406
     int err;
-#line 406
     int allInExtRange;	/* all values within external range? */
-#line 406
     int allInIntRange;	/* all values within internal range? */
-#line 406
     int nels;
-#line 406
-    int nslabs;
-#line 406
     int nok = 0;      /* count of valid comparisons */
-#line 406
-    size_t start[MAX_RANK];
-#line 406
-    size_t edge[MAX_RANK];
-#line 406
     size_t index[MAX_RANK];
-#line 406
-    size_t mid[MAX_RANK];
-#line 406
     int canConvert;     /* Both text or both numeric */
-#line 406
-    int value[MAX_NELS];
-#line 406
+    uint value[MAX_NELS];
     double expect[MAX_NELS];
-#line 406
 
-#line 406
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 406
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 406
 	error("nc_open: %s", nc_strerror(err));
-#line 406
-    for (i = 0; i < NVARS; i++) {
-#line 406
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 406
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 406
         assert(var_nels[i] <= MAX_NELS);
-#line 406
-	for (j = 0; j < var_rank[i]; j++) {
-#line 406
-	    start[j] = 0;
-#line 406
-	    edge[j] = 1;
-#line 406
-	}
-#line 406
-        err = nc_get_vara_int(BAD_ID, i, start, edge, value);
-#line 406
+        err = nc_get_var_uint(BAD_ID, i, value);
         IF (err != NC_EBADID)
-#line 406
 	    error("bad ncid: status = %d", err);
-#line 406
-        err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value);
-#line 406
+        err = nc_get_var_uint(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR)
-#line 406
 	    error("bad var id: status = %d", err);
-#line 406
+
+	nels = 1;
 	for (j = 0; j < var_rank[i]; j++) {
-#line 406
-	    start[j] = var_shape[i][j];
-#line 406
-	    err = nc_get_vara_int(ncid, i, start, edge, value);
-#line 406
-            IF (canConvert && err != NC_EINVALCOORDS)
-#line 406
-                error("bad index: status = %d", err);
-#line 406
-	    start[j] = 0;
-#line 406
-	    edge[j] = var_shape[i][j] + 1;
-#line 406
-	    err = nc_get_vara_int(ncid, i, start, edge, value);
-#line 406
-            IF (canConvert && err != NC_EEDGE)
-#line 406
-		error("bad edge: status = %d", err);
-#line 406
-	    edge[j] = 1;
-#line 406
+	    nels *= var_shape[i][j];
 	}
-#line 406
-            /* Check non-scalars for correct error returned even when */
-#line 406
-            /* there is nothing to get (edge[j]==0) */
-#line 406
-	if(var_rank[i] > 0) {
-#line 406
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 406
-		edge[j] = 0;
-#line 406
-	    }
-#line 406
-	    err = nc_get_vara_int(BAD_ID, i, start, edge, value);
-#line 406
-	    IF (err != NC_EBADID) 
-#line 406
-		error("bad ncid: status = %d", err);
-#line 406
-	    err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value);
-#line 406
-	    IF (err != NC_ENOTVAR) 
-#line 406
-		error("bad var id: status = %d", err);
-#line 406
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 406
-		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 406
-		    start[j] = var_shape[i][j];
-#line 406
-		    err = nc_get_vara_int(ncid, i, start, edge, value);
-#line 406
-		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 406
-			error("bad start: status = %d", err);
-#line 406
-		    start[j] = 0;
-#line 406
-		}
-#line 406
-	    }
-#line 406
-	    err = nc_get_vara_int(ncid, i, start, edge, value);
-#line 406
-	    if (canConvert) {
-#line 406
-		IF (err) 
-#line 406
-		    error("%s", nc_strerror(err));
-#line 406
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UINT);
+	    if (inRange3(expect[j],var_type[i], NCT_UINT)) {
+		allInIntRange = allInIntRange && expect[j] >= uint_min
+			    && expect[j] <= uint_max;
 	    } else {
-#line 406
-		IF (err != NC_ECHAR)
-#line 406
-		    error("wrong type: status = %d", err);
-#line 406
-	    }
-#line 406
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 406
-		edge[j] = 1;
-#line 406
+		allInExtRange = 0;
 	    }
-#line 406
-	}            /* Choose a random point dividing each dim into 2 parts */
-#line 406
-            /* get 2^rank (nslabs) slabs so defined */
-#line 406
-        nslabs = 1;
-#line 406
-        for (j = 0; j < var_rank[i]; j++) {
-#line 406
-            mid[j] = roll( var_shape[i][j] );
-#line 406
-            nslabs *= 2;
-#line 406
-        }
-#line 406
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 406
-        for (k = 0; k < nslabs; k++) {
-#line 406
-            nels = 1;
-#line 406
-            for (j = 0; j < var_rank[i]; j++) {
-#line 406
-                if ((k >> j) & 1) {
-#line 406
-                    start[j] = 0;
-#line 406
-                    edge[j] = mid[j];
-#line 406
-                }else{
-#line 406
-                    start[j] = mid[j];
-#line 406
-                    edge[j] = var_shape[i][j] - mid[j];
-#line 406
-                }
-#line 406
-                nels *= edge[j];
-#line 406
-            }
-#line 406
-	    allInExtRange = allInIntRange = 1;
-#line 406
-            for (j = 0; j < nels; j++) {
-#line 406
-                err = toMixedBase(j, var_rank[i], edge, index);
-#line 406
-                IF (err)
-#line 406
-                    error("error in toMixedBase 1");
-#line 406
-                for (d = 0; d < var_rank[i]; d++)
-#line 406
-                    index[d] += start[d];
-#line 406
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT);
-#line 406
-		if (inRange3(expect[j],var_type[i], NCT_INT)) {
-#line 406
-		    allInIntRange = allInIntRange && expect[j] >= int_min
-#line 406
-				&& expect[j] <= int_max;
-#line 406
+	}
+	err = nc_get_var_uint(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		if (allInIntRange) {
+		    IF (err)
+			error("%s", nc_strerror(err));
 		} else {
-#line 406
-		    allInExtRange = 0;
-#line 406
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
 		}
-#line 406
+	    } else {
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
 	    }
-#line 406
-            if (var_rank[i] == 0 && i%2)
-#line 406
-		err = nc_get_vara_int(ncid, i, NULL, NULL, value);
-#line 406
-	    else
-#line 406
-		err = nc_get_vara_int(ncid, i, start, edge, value);
-#line 406
-            if (canConvert) {
-#line 406
-		if (allInExtRange) {
-#line 406
-		    if (allInIntRange) {
-#line 406
-			IF (err)
-#line 406
-			    error("%s", nc_strerror(err));
-#line 406
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_UINT)
+			&& expect[j] >= uint_min && expect[j] <= uint_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
+			}
 		    } else {
-#line 406
-			IF (err != NC_ERANGE)
-#line 406
-			    error("Range error: status = %d", err);
-#line 406
+			nok++;
 		    }
-#line 406
-		} else {
-#line 406
-		    IF (err != 0 && err != NC_ERANGE)
-#line 406
-			error("OK or Range error: status = %d", err);
-#line 406
 		}
-#line 406
-		for (j = 0; j < nels; j++) {
-#line 406
-		    if (inRange3(expect[j],var_type[i],NCT_INT)
-#line 406
-			    && expect[j] >= int_min && expect[j] <= int_max) {
-#line 406
-			IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){
-#line 406
-			    error("value read not that expected");
-#line 406
-			    if (verbose) {
-#line 406
-				error("\n");
-#line 406
-				error("varid: %d, ", i);
-#line 406
-				error("var_name: %s, ", var_name[i]);
-#line 406
-				error("element number: %d ", j);
-#line 406
-				error("expect: %g", expect[j]);
-#line 406
-				error("got: %g", (double) value[j]);
-#line 406
-			    }
-#line 406
-			} else {
-#line 406
-			    nok++;
-#line 406
+	    }
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+    err = nc_close(ncid);
+    IF (err)
+	error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_var_longlong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nok = 0;      /* count of valid comparisons */
+    size_t index[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    longlong value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_get_var_longlong(BAD_ID, i, value);
+        IF (err != NC_EBADID)
+	    error("bad ncid: status = %d", err);
+        err = nc_get_var_longlong(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR)
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONGLONG);
+	    if (inRange3(expect[j],var_type[i], NCT_LONGLONG)) {
+		allInIntRange = 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)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
+		}
+	    } else {
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
+	    }
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+			&& expect[j] >= longlong_min && expect[j] <= longlong_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
 			}
-#line 406
+		    } else {
+			nok++;
 		    }
-#line 406
 		}
-#line 406
-            } else {
-#line 406
-                IF (nels > 0 && err != NC_ECHAR)
-#line 406
-                    error("wrong type: status = %d", err);
-#line 406
-            }
-#line 406
-        }
-#line 406
+	    }
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
     }
-#line 406
     err = nc_close(ncid);
-#line 406
     IF (err)
-#line 406
 	error("nc_close: %s", nc_strerror(err));
-#line 406
     print_nok(nok);
-#line 406
 }
-#line 406
 
 void
-#line 407
-test_nc_get_vara_long(void)
-#line 407
+test_nc_get_var_ulonglong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nok = 0;      /* count of valid comparisons */
+    size_t index[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    ulonglong value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_get_var_ulonglong(BAD_ID, i, value);
+        IF (err != NC_EBADID)
+	    error("bad ncid: status = %d", err);
+        err = nc_get_var_ulonglong(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR)
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	allInExtRange = allInIntRange = 1;
+	for (j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err)
+		error("error in toMixedBase 1");
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_ULONGLONG);
+	    if (inRange3(expect[j],var_type[i], NCT_ULONGLONG)) {
+		allInIntRange = 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)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("Range error: status = %d", err);
+		}
+	    } else {
+		IF (err != 0 && err != NC_ERANGE)
+		    error("OK or Range error: status = %d", err);
+	    }
+	    for (j = 0; j < nels; j++) {
+		if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+			&& expect[j] >= ulonglong_min && expect[j] <= ulonglong_max) {
+		    IF (!equal(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("element number: %d ", j);
+			    error("expect: %g", expect[j]);
+			    error("got: %g", (double) value[j]);
+			}
+		    } else {
+			nok++;
+		    }
+		}
+	    }
+	} else {
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+    err = nc_close(ncid);
+    IF (err)
+	error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+
+
+
+void
+test_nc_get_vara_text(void)
 {
-#line 407
     int ncid;
-#line 407
     int d;
-#line 407
     int i;
-#line 407
     int j;
-#line 407
     int k;
-#line 407
     int err;
-#line 407
     int allInExtRange;	/* all values within external range? */
-#line 407
     int allInIntRange;	/* all values within internal range? */
-#line 407
     int nels;
-#line 407
     int nslabs;
-#line 407
     int nok = 0;      /* count of valid comparisons */
-#line 407
     size_t start[MAX_RANK];
-#line 407
     size_t edge[MAX_RANK];
-#line 407
     size_t index[MAX_RANK];
-#line 407
     size_t mid[MAX_RANK];
-#line 407
     int canConvert;     /* Both text or both numeric */
-#line 407
-    long value[MAX_NELS];
-#line 407
+    text value[MAX_NELS];
     double expect[MAX_NELS];
-#line 407
 
-#line 407
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 407
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 407
 	error("nc_open: %s", nc_strerror(err));
-#line 407
-    for (i = 0; i < NVARS; i++) {
-#line 407
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 407
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 407
         assert(var_nels[i] <= MAX_NELS);
-#line 407
 	for (j = 0; j < var_rank[i]; j++) {
-#line 407
 	    start[j] = 0;
-#line 407
 	    edge[j] = 1;
-#line 407
 	}
-#line 407
-        err = nc_get_vara_long(BAD_ID, i, start, edge, value);
-#line 407
+        err = nc_get_vara_text(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 407
 	    error("bad ncid: status = %d", err);
-#line 407
-        err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value);
-#line 407
+        err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 407
 	    error("bad var id: status = %d", err);
-#line 407
 	for (j = 0; j < var_rank[i]; j++) {
-#line 407
 	    start[j] = var_shape[i][j];
-#line 407
-	    err = nc_get_vara_long(ncid, i, start, edge, value);
-#line 407
+	    err = nc_get_vara_text(ncid, i, start, edge, value);
             IF (canConvert && err != NC_EINVALCOORDS)
-#line 407
                 error("bad index: status = %d", err);
-#line 407
 	    start[j] = 0;
-#line 407
 	    edge[j] = var_shape[i][j] + 1;
-#line 407
-	    err = nc_get_vara_long(ncid, i, start, edge, value);
-#line 407
+	    err = nc_get_vara_text(ncid, i, start, edge, value);
             IF (canConvert && err != NC_EEDGE)
-#line 407
 		error("bad edge: status = %d", err);
-#line 407
 	    edge[j] = 1;
-#line 407
 	}
-#line 407
             /* Check non-scalars for correct error returned even when */
-#line 407
             /* there is nothing to get (edge[j]==0) */
-#line 407
 	if(var_rank[i] > 0) {
-#line 407
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 407
 		edge[j] = 0;
-#line 407
 	    }
-#line 407
-	    err = nc_get_vara_long(BAD_ID, i, start, edge, value);
-#line 407
+	    err = nc_get_vara_text(BAD_ID, i, start, edge, value);
 	    IF (err != NC_EBADID) 
-#line 407
 		error("bad ncid: status = %d", err);
-#line 407
-	    err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value);
-#line 407
+	    err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value);
 	    IF (err != NC_ENOTVAR) 
-#line 407
 		error("bad var id: status = %d", err);
-#line 407
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 407
 		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 407
 		    start[j] = var_shape[i][j];
-#line 407
-		    err = nc_get_vara_long(ncid, i, start, edge, value);
-#line 407
+		    err = nc_get_vara_text(ncid, i, start, edge, value);
 		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 407
 			error("bad start: status = %d", err);
-#line 407
 		    start[j] = 0;
-#line 407
 		}
-#line 407
 	    }
-#line 407
-	    err = nc_get_vara_long(ncid, i, start, edge, value);
-#line 407
+	    err = nc_get_vara_text(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 407
 		IF (err) 
-#line 407
 		    error("%s", nc_strerror(err));
-#line 407
 	    } else {
-#line 407
 		IF (err != NC_ECHAR)
-#line 407
 		    error("wrong type: status = %d", err);
-#line 407
 	    }
-#line 407
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 407
 		edge[j] = 1;
-#line 407
 	    }
-#line 407
 	}            /* Choose a random point dividing each dim into 2 parts */
-#line 407
             /* get 2^rank (nslabs) slabs so defined */
-#line 407
         nslabs = 1;
-#line 407
         for (j = 0; j < var_rank[i]; j++) {
-#line 407
             mid[j] = roll( var_shape[i][j] );
-#line 407
             nslabs *= 2;
-#line 407
         }
-#line 407
             /* bits of k determine whether to get lower or upper part of dim */
-#line 407
         for (k = 0; k < nslabs; k++) {
-#line 407
             nels = 1;
-#line 407
             for (j = 0; j < var_rank[i]; j++) {
-#line 407
                 if ((k >> j) & 1) {
-#line 407
                     start[j] = 0;
-#line 407
                     edge[j] = mid[j];
-#line 407
                 }else{
-#line 407
                     start[j] = mid[j];
-#line 407
                     edge[j] = var_shape[i][j] - mid[j];
-#line 407
                 }
-#line 407
                 nels *= edge[j];
-#line 407
             }
-#line 407
 	    allInExtRange = allInIntRange = 1;
-#line 407
             for (j = 0; j < nels; j++) {
-#line 407
                 err = toMixedBase(j, var_rank[i], edge, index);
-#line 407
                 IF (err)
-#line 407
                     error("error in toMixedBase 1");
-#line 407
                 for (d = 0; d < var_rank[i]; d++)
-#line 407
                     index[d] += start[d];
-#line 407
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG);
-#line 407
-		if (inRange3(expect[j],var_type[i], NCT_LONG)) {
-#line 407
-		    allInIntRange = allInIntRange && expect[j] >= long_min
-#line 407
-				&& expect[j] <= long_max;
-#line 407
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT);
+		if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
+		    allInIntRange = allInIntRange && expect[j] >= text_min
+				&& expect[j] <= text_max;
 		} else {
-#line 407
 		    allInExtRange = 0;
-#line 407
 		}
-#line 407
 	    }
-#line 407
             if (var_rank[i] == 0 && i%2)
-#line 407
-		err = nc_get_vara_long(ncid, i, NULL, NULL, value);
-#line 407
+		err = nc_get_vara_text(ncid, i, NULL, NULL, value);
 	    else
-#line 407
-		err = nc_get_vara_long(ncid, i, start, edge, value);
-#line 407
+		err = nc_get_vara_text(ncid, i, start, edge, value);
             if (canConvert) {
-#line 407
 		if (allInExtRange) {
-#line 407
 		    if (allInIntRange) {
-#line 407
 			IF (err)
-#line 407
 			    error("%s", nc_strerror(err));
-#line 407
 		    } else {
-#line 407
 			IF (err != NC_ERANGE)
-#line 407
 			    error("Range error: status = %d", err);
-#line 407
 		    }
-#line 407
 		} else {
-#line 407
 		    IF (err != 0 && err != NC_ERANGE)
-#line 407
 			error("OK or Range error: status = %d", err);
-#line 407
 		}
-#line 407
 		for (j = 0; j < nels; j++) {
-#line 407
-		    if (inRange3(expect[j],var_type[i],NCT_LONG)
-#line 407
-			    && expect[j] >= long_min && expect[j] <= long_max) {
-#line 407
-			IF (!equal(value[j],expect[j],var_type[i],NCT_LONG)){
-#line 407
+		    if (inRange3(expect[j],var_type[i],NCT_TEXT)
+			    && expect[j] >= text_min && expect[j] <= text_max) {
+			IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){
 			    error("value read not that expected");
-#line 407
 			    if (verbose) {
-#line 407
 				error("\n");
-#line 407
 				error("varid: %d, ", i);
-#line 407
 				error("var_name: %s, ", var_name[i]);
-#line 407
 				error("element number: %d ", j);
-#line 407
 				error("expect: %g", expect[j]);
-#line 407
 				error("got: %g", (double) value[j]);
-#line 407
 			    }
-#line 407
 			} else {
-#line 407
 			    nok++;
-#line 407
 			}
-#line 407
 		    }
-#line 407
 		}
-#line 407
             } else {
-#line 407
                 IF (nels > 0 && err != NC_ECHAR)
-#line 407
                     error("wrong type: status = %d", err);
-#line 407
             }
-#line 407
         }
-#line 407
     }
-#line 407
     err = nc_close(ncid);
-#line 407
     IF (err)
-#line 407
 	error("nc_close: %s", nc_strerror(err));
-#line 407
     print_nok(nok);
-#line 407
 }
-#line 407
 
 void
-#line 408
-test_nc_get_vara_float(void)
-#line 408
+test_nc_get_vara_uchar(void)
 {
-#line 408
     int ncid;
-#line 408
     int d;
-#line 408
     int i;
-#line 408
     int j;
-#line 408
     int k;
-#line 408
     int err;
-#line 408
     int allInExtRange;	/* all values within external range? */
-#line 408
     int allInIntRange;	/* all values within internal range? */
-#line 408
     int nels;
-#line 408
     int nslabs;
-#line 408
     int nok = 0;      /* count of valid comparisons */
-#line 408
     size_t start[MAX_RANK];
-#line 408
     size_t edge[MAX_RANK];
-#line 408
     size_t index[MAX_RANK];
-#line 408
     size_t mid[MAX_RANK];
-#line 408
     int canConvert;     /* Both text or both numeric */
-#line 408
-    float value[MAX_NELS];
-#line 408
+    uchar value[MAX_NELS];
     double expect[MAX_NELS];
-#line 408
 
-#line 408
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 408
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 408
 	error("nc_open: %s", nc_strerror(err));
-#line 408
-    for (i = 0; i < NVARS; i++) {
-#line 408
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 408
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 408
         assert(var_nels[i] <= MAX_NELS);
-#line 408
 	for (j = 0; j < var_rank[i]; j++) {
-#line 408
 	    start[j] = 0;
-#line 408
 	    edge[j] = 1;
-#line 408
 	}
-#line 408
-        err = nc_get_vara_float(BAD_ID, i, start, edge, value);
-#line 408
+        err = nc_get_vara_uchar(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 408
 	    error("bad ncid: status = %d", err);
-#line 408
-        err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value);
-#line 408
+        err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 408
 	    error("bad var id: status = %d", err);
-#line 408
 	for (j = 0; j < var_rank[i]; j++) {
-#line 408
 	    start[j] = var_shape[i][j];
-#line 408
-	    err = nc_get_vara_float(ncid, i, start, edge, value);
-#line 408
+	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
             IF (canConvert && err != NC_EINVALCOORDS)
-#line 408
                 error("bad index: status = %d", err);
-#line 408
 	    start[j] = 0;
-#line 408
 	    edge[j] = var_shape[i][j] + 1;
-#line 408
-	    err = nc_get_vara_float(ncid, i, start, edge, value);
-#line 408
+	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
             IF (canConvert && err != NC_EEDGE)
-#line 408
 		error("bad edge: status = %d", err);
-#line 408
 	    edge[j] = 1;
-#line 408
 	}
-#line 408
             /* Check non-scalars for correct error returned even when */
-#line 408
             /* there is nothing to get (edge[j]==0) */
-#line 408
 	if(var_rank[i] > 0) {
-#line 408
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 408
 		edge[j] = 0;
-#line 408
 	    }
-#line 408
-	    err = nc_get_vara_float(BAD_ID, i, start, edge, value);
-#line 408
+	    err = nc_get_vara_uchar(BAD_ID, i, start, edge, value);
 	    IF (err != NC_EBADID) 
-#line 408
 		error("bad ncid: status = %d", err);
-#line 408
-	    err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value);
-#line 408
+	    err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value);
 	    IF (err != NC_ENOTVAR) 
-#line 408
 		error("bad var id: status = %d", err);
-#line 408
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 408
 		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 408
 		    start[j] = var_shape[i][j];
-#line 408
-		    err = nc_get_vara_float(ncid, i, start, edge, value);
-#line 408
+		    err = nc_get_vara_uchar(ncid, i, start, edge, value);
 		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 408
 			error("bad start: status = %d", err);
-#line 408
 		    start[j] = 0;
-#line 408
 		}
-#line 408
 	    }
-#line 408
-	    err = nc_get_vara_float(ncid, i, start, edge, value);
-#line 408
+	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 408
 		IF (err) 
-#line 408
 		    error("%s", nc_strerror(err));
-#line 408
 	    } else {
-#line 408
 		IF (err != NC_ECHAR)
-#line 408
 		    error("wrong type: status = %d", err);
-#line 408
 	    }
-#line 408
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 408
 		edge[j] = 1;
-#line 408
 	    }
-#line 408
 	}            /* Choose a random point dividing each dim into 2 parts */
-#line 408
             /* get 2^rank (nslabs) slabs so defined */
-#line 408
         nslabs = 1;
-#line 408
         for (j = 0; j < var_rank[i]; j++) {
-#line 408
             mid[j] = roll( var_shape[i][j] );
-#line 408
             nslabs *= 2;
-#line 408
         }
-#line 408
             /* bits of k determine whether to get lower or upper part of dim */
-#line 408
         for (k = 0; k < nslabs; k++) {
-#line 408
             nels = 1;
-#line 408
             for (j = 0; j < var_rank[i]; j++) {
-#line 408
                 if ((k >> j) & 1) {
-#line 408
                     start[j] = 0;
-#line 408
                     edge[j] = mid[j];
-#line 408
                 }else{
-#line 408
                     start[j] = mid[j];
-#line 408
                     edge[j] = var_shape[i][j] - mid[j];
-#line 408
                 }
-#line 408
                 nels *= edge[j];
-#line 408
             }
-#line 408
 	    allInExtRange = allInIntRange = 1;
-#line 408
             for (j = 0; j < nels; j++) {
-#line 408
                 err = toMixedBase(j, var_rank[i], edge, index);
-#line 408
                 IF (err)
-#line 408
                     error("error in toMixedBase 1");
-#line 408
                 for (d = 0; d < var_rank[i]; d++)
-#line 408
                     index[d] += start[d];
-#line 408
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 408
-		if (inRange3(expect[j],var_type[i], NCT_FLOAT)) {
-#line 408
-		    allInIntRange = allInIntRange && expect[j] >= float_min
-#line 408
-				&& expect[j] <= float_max;
-#line 408
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR);
+		if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
+		    allInIntRange = allInIntRange && expect[j] >= uchar_min
+				&& expect[j] <= uchar_max;
 		} else {
-#line 408
 		    allInExtRange = 0;
-#line 408
 		}
-#line 408
 	    }
-#line 408
             if (var_rank[i] == 0 && i%2)
-#line 408
-		err = nc_get_vara_float(ncid, i, NULL, NULL, value);
-#line 408
+		err = nc_get_vara_uchar(ncid, i, NULL, NULL, value);
 	    else
-#line 408
-		err = nc_get_vara_float(ncid, i, start, edge, value);
-#line 408
+		err = nc_get_vara_uchar(ncid, i, start, edge, value);
             if (canConvert) {
-#line 408
 		if (allInExtRange) {
-#line 408
 		    if (allInIntRange) {
-#line 408
 			IF (err)
-#line 408
 			    error("%s", nc_strerror(err));
-#line 408
 		    } else {
-#line 408
 			IF (err != NC_ERANGE)
-#line 408
 			    error("Range error: status = %d", err);
-#line 408
 		    }
-#line 408
 		} else {
-#line 408
 		    IF (err != 0 && err != NC_ERANGE)
-#line 408
 			error("OK or Range error: status = %d", err);
-#line 408
 		}
-#line 408
 		for (j = 0; j < nels; j++) {
-#line 408
-		    if (inRange3(expect[j],var_type[i],NCT_FLOAT)
-#line 408
-			    && expect[j] >= float_min && expect[j] <= float_max) {
-#line 408
-			IF (!equal(value[j],expect[j],var_type[i],NCT_FLOAT)){
-#line 408
+		    if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+			    && expect[j] >= uchar_min && expect[j] <= uchar_max) {
+			IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){
 			    error("value read not that expected");
-#line 408
 			    if (verbose) {
-#line 408
 				error("\n");
-#line 408
 				error("varid: %d, ", i);
-#line 408
 				error("var_name: %s, ", var_name[i]);
-#line 408
 				error("element number: %d ", j);
-#line 408
 				error("expect: %g", expect[j]);
-#line 408
 				error("got: %g", (double) value[j]);
-#line 408
 			    }
-#line 408
 			} else {
-#line 408
 			    nok++;
-#line 408
 			}
-#line 408
 		    }
-#line 408
 		}
-#line 408
             } else {
-#line 408
                 IF (nels > 0 && err != NC_ECHAR)
-#line 408
                     error("wrong type: status = %d", err);
-#line 408
             }
-#line 408
         }
-#line 408
     }
-#line 408
     err = nc_close(ncid);
-#line 408
     IF (err)
-#line 408
 	error("nc_close: %s", nc_strerror(err));
-#line 408
     print_nok(nok);
-#line 408
 }
-#line 408
 
 void
-#line 409
-test_nc_get_vara_double(void)
-#line 409
+test_nc_get_vara_schar(void)
 {
-#line 409
     int ncid;
-#line 409
     int d;
-#line 409
     int i;
-#line 409
     int j;
-#line 409
     int k;
-#line 409
     int err;
-#line 409
     int allInExtRange;	/* all values within external range? */
-#line 409
     int allInIntRange;	/* all values within internal range? */
-#line 409
     int nels;
-#line 409
     int nslabs;
-#line 409
     int nok = 0;      /* count of valid comparisons */
-#line 409
     size_t start[MAX_RANK];
-#line 409
     size_t edge[MAX_RANK];
-#line 409
     size_t index[MAX_RANK];
-#line 409
     size_t mid[MAX_RANK];
-#line 409
     int canConvert;     /* Both text or both numeric */
-#line 409
-    double value[MAX_NELS];
-#line 409
+    schar value[MAX_NELS];
     double expect[MAX_NELS];
-#line 409
 
-#line 409
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 409
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 409
 	error("nc_open: %s", nc_strerror(err));
-#line 409
-    for (i = 0; i < NVARS; i++) {
-#line 409
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 409
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 409
         assert(var_nels[i] <= MAX_NELS);
-#line 409
 	for (j = 0; j < var_rank[i]; j++) {
-#line 409
 	    start[j] = 0;
-#line 409
 	    edge[j] = 1;
-#line 409
 	}
-#line 409
-        err = nc_get_vara_double(BAD_ID, i, start, edge, value);
-#line 409
+        err = nc_get_vara_schar(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 409
 	    error("bad ncid: status = %d", err);
-#line 409
-        err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value);
-#line 409
+        err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 409
 	    error("bad var id: status = %d", err);
-#line 409
 	for (j = 0; j < var_rank[i]; j++) {
-#line 409
 	    start[j] = var_shape[i][j];
-#line 409
-	    err = nc_get_vara_double(ncid, i, start, edge, value);
-#line 409
+	    err = nc_get_vara_schar(ncid, i, start, edge, value);
             IF (canConvert && err != NC_EINVALCOORDS)
-#line 409
                 error("bad index: status = %d", err);
-#line 409
 	    start[j] = 0;
-#line 409
 	    edge[j] = var_shape[i][j] + 1;
-#line 409
-	    err = nc_get_vara_double(ncid, i, start, edge, value);
-#line 409
+	    err = nc_get_vara_schar(ncid, i, start, edge, value);
             IF (canConvert && err != NC_EEDGE)
-#line 409
 		error("bad edge: status = %d", err);
-#line 409
 	    edge[j] = 1;
-#line 409
 	}
-#line 409
             /* Check non-scalars for correct error returned even when */
-#line 409
             /* there is nothing to get (edge[j]==0) */
-#line 409
 	if(var_rank[i] > 0) {
-#line 409
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 409
 		edge[j] = 0;
-#line 409
 	    }
-#line 409
-	    err = nc_get_vara_double(BAD_ID, i, start, edge, value);
-#line 409
+	    err = nc_get_vara_schar(BAD_ID, i, start, edge, value);
 	    IF (err != NC_EBADID) 
-#line 409
 		error("bad ncid: status = %d", err);
-#line 409
-	    err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value);
-#line 409
+	    err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value);
 	    IF (err != NC_ENOTVAR) 
-#line 409
 		error("bad var id: status = %d", err);
-#line 409
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 409
 		if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 409
 		    start[j] = var_shape[i][j];
-#line 409
-		    err = nc_get_vara_double(ncid, i, start, edge, value);
-#line 409
+		    err = nc_get_vara_schar(ncid, i, start, edge, value);
 		    IF (canConvert && err != NC_EINVALCOORDS)
-#line 409
 			error("bad start: status = %d", err);
-#line 409
 		    start[j] = 0;
-#line 409
 		}
-#line 409
 	    }
-#line 409
-	    err = nc_get_vara_double(ncid, i, start, edge, value);
-#line 409
+	    err = nc_get_vara_schar(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 409
 		IF (err) 
-#line 409
 		    error("%s", nc_strerror(err));
-#line 409
 	    } else {
-#line 409
 		IF (err != NC_ECHAR)
-#line 409
 		    error("wrong type: status = %d", err);
-#line 409
 	    }
-#line 409
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 409
 		edge[j] = 1;
-#line 409
 	    }
-#line 409
 	}            /* Choose a random point dividing each dim into 2 parts */
-#line 409
             /* get 2^rank (nslabs) slabs so defined */
-#line 409
         nslabs = 1;
-#line 409
         for (j = 0; j < var_rank[i]; j++) {
-#line 409
             mid[j] = roll( var_shape[i][j] );
-#line 409
             nslabs *= 2;
-#line 409
         }
-#line 409
             /* bits of k determine whether to get lower or upper part of dim */
-#line 409
         for (k = 0; k < nslabs; k++) {
-#line 409
             nels = 1;
-#line 409
             for (j = 0; j < var_rank[i]; j++) {
-#line 409
                 if ((k >> j) & 1) {
-#line 409
                     start[j] = 0;
-#line 409
                     edge[j] = mid[j];
-#line 409
                 }else{
-#line 409
                     start[j] = mid[j];
-#line 409
                     edge[j] = var_shape[i][j] - mid[j];
-#line 409
                 }
-#line 409
                 nels *= edge[j];
-#line 409
             }
-#line 409
 	    allInExtRange = allInIntRange = 1;
-#line 409
             for (j = 0; j < nels; j++) {
-#line 409
                 err = toMixedBase(j, var_rank[i], edge, index);
-#line 409
                 IF (err)
-#line 409
                     error("error in toMixedBase 1");
-#line 409
                 for (d = 0; d < var_rank[i]; d++)
-#line 409
                     index[d] += start[d];
-#line 409
-                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 409
-		if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) {
-#line 409
-		    allInIntRange = allInIntRange && expect[j] >= double_min
-#line 409
-				&& expect[j] <= double_max;
-#line 409
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR);
+		if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
+		    allInIntRange = allInIntRange && expect[j] >= schar_min
+				&& expect[j] <= schar_max;
 		} else {
-#line 409
 		    allInExtRange = 0;
-#line 409
 		}
-#line 409
 	    }
-#line 409
             if (var_rank[i] == 0 && i%2)
-#line 409
-		err = nc_get_vara_double(ncid, i, NULL, NULL, value);
-#line 409
+		err = nc_get_vara_schar(ncid, i, NULL, NULL, value);
 	    else
-#line 409
-		err = nc_get_vara_double(ncid, i, start, edge, value);
-#line 409
+		err = nc_get_vara_schar(ncid, i, start, edge, value);
             if (canConvert) {
-#line 409
 		if (allInExtRange) {
-#line 409
 		    if (allInIntRange) {
-#line 409
 			IF (err)
-#line 409
 			    error("%s", nc_strerror(err));
-#line 409
 		    } else {
-#line 409
 			IF (err != NC_ERANGE)
-#line 409
 			    error("Range error: status = %d", err);
-#line 409
 		    }
-#line 409
 		} else {
-#line 409
 		    IF (err != 0 && err != NC_ERANGE)
-#line 409
 			error("OK or Range error: status = %d", err);
-#line 409
 		}
-#line 409
 		for (j = 0; j < nels; j++) {
-#line 409
-		    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
-#line 409
-			    && expect[j] >= double_min && expect[j] <= double_max) {
-#line 409
-			IF (!equal(value[j],expect[j],var_type[i],NCT_DOUBLE)){
-#line 409
+		    if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+			    && expect[j] >= schar_min && expect[j] <= schar_max) {
+			IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){
 			    error("value read not that expected");
-#line 409
 			    if (verbose) {
-#line 409
 				error("\n");
-#line 409
 				error("varid: %d, ", i);
-#line 409
 				error("var_name: %s, ", var_name[i]);
-#line 409
 				error("element number: %d ", j);
-#line 409
 				error("expect: %g", expect[j]);
-#line 409
 				error("got: %g", (double) value[j]);
-#line 409
 			    }
-#line 409
 			} else {
-#line 409
 			    nok++;
-#line 409
 			}
-#line 409
 		    }
-#line 409
 		}
-#line 409
             } else {
-#line 409
                 IF (nels > 0 && err != NC_ECHAR)
-#line 409
                     error("wrong type: status = %d", err);
-#line 409
             }
-#line 409
         }
-#line 409
     }
-#line 409
     err = nc_close(ncid);
-#line 409
     IF (err)
-#line 409
 	error("nc_close: %s", nc_strerror(err));
-#line 409
     print_nok(nok);
-#line 409
 }
-#line 409
-
-
-
-#line 590
 
 void
-#line 591
-test_nc_get_vars_text(void)
-#line 591
+test_nc_get_vara_short(void)
 {
-#line 591
     int ncid;
-#line 591
     int d;
-#line 591
     int i;
-#line 591
     int j;
-#line 591
     int k;
-#line 591
-    int m;
-#line 591
     int err;
-#line 591
     int allInExtRange;	/* all values within external range? */
-#line 591
     int allInIntRange;	/* all values within internal range? */
-#line 591
     int nels;
-#line 591
     int nslabs;
-#line 591
-    int nstarts;        /* number of different starts */
-#line 591
     int nok = 0;      /* count of valid comparisons */
-#line 591
     size_t start[MAX_RANK];
-#line 591
     size_t edge[MAX_RANK];
-#line 591
     size_t index[MAX_RANK];
-#line 591
-    size_t index2[MAX_RANK];
-#line 591
     size_t mid[MAX_RANK];
-#line 591
-    size_t count[MAX_RANK];
-#line 591
-    size_t sstride[MAX_RANK];
-#line 591
-    ptrdiff_t stride[MAX_RANK];
-#line 591
     int canConvert;     /* Both text or both numeric */
-#line 591
-    text value[MAX_NELS];
-#line 591
+    short value[MAX_NELS];
     double expect[MAX_NELS];
-#line 591
 
-#line 591
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 591
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 591
-        error("nc_open: %s", nc_strerror(err));
-#line 591
-    for (i = 0; i < NVARS; i++) {
-#line 591
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 591
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 591
         assert(var_nels[i] <= MAX_NELS);
-#line 591
-        for (j = 0; j < var_rank[i]; j++) {
-#line 591
-            start[j] = 0;
-#line 591
-            edge[j] = 1;
-#line 591
-            stride[j] = 1;
-#line 591
-        }
-#line 591
-        err = nc_get_vars_text(BAD_ID, i, start, edge, stride, value);
-#line 591
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_short(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 591
-            error("bad ncid: status = %d", err);
-#line 591
-        err = nc_get_vars_text(ncid, BAD_VARID, start, edge, stride, value);
-#line 591
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 591
-            error("bad var id: status = %d", err);
-#line 591
-        for (j = 0; j < var_rank[i]; j++) {
-#line 591
-            start[j] = var_shape[i][j];
-#line 591
-            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
-#line 591
-	  if(!canConvert) {
-#line 591
-		IF (err != NC_ECHAR)
-#line 591
-               	    error("conversion: status = %d", err);
-#line 591
-	  } else {
-#line 591
-            IF (err != NC_EINVALCOORDS)
-#line 591
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_short(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 591
-            start[j] = 0;
-#line 591
-            edge[j] = var_shape[i][j] + 1;
-#line 591
-            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
-#line 591
-            IF (err != NC_EEDGE)
-#line 591
-                error("bad edge: status = %d", err);
-#line 591
-            edge[j] = 1;
-#line 591
-            stride[j] = 0;
-#line 591
-            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
-#line 591
-            IF (err != NC_ESTRIDE)
-#line 591
-                error("bad stride: status = %d", err);
-#line 591
-            stride[j] = 1;
-#line 591
-	  }
-#line 591
-        }
-#line 591
-            /* Choose a random point dividing each dim into 2 parts */
-#line 591
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_short(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_short(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_short(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_short(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 591
         nslabs = 1;
-#line 591
         for (j = 0; j < var_rank[i]; j++) {
-#line 591
             mid[j] = roll( var_shape[i][j] );
-#line 591
             nslabs *= 2;
-#line 591
         }
-#line 591
             /* bits of k determine whether to get lower or upper part of dim */
-#line 591
-            /* choose random stride from 1 to edge */
-#line 591
         for (k = 0; k < nslabs; k++) {
-#line 591
-            nstarts = 1;
-#line 591
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 591
                 if ((k >> j) & 1) {
-#line 591
                     start[j] = 0;
-#line 591
                     edge[j] = mid[j];
-#line 591
                 }else{
-#line 591
                     start[j] = mid[j];
-#line 591
                     edge[j] = var_shape[i][j] - mid[j];
-#line 591
                 }
-#line 591
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 591
-                nstarts *= stride[j];
-#line 591
+                nels *= edge[j];
             }
-#line 591
-            for (m = 0; m < nstarts; m++) {
-#line 591
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 591
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 591
-                    error("error in toMixedBase");
-#line 591
-                nels = 1;
-#line 591
-                for (j = 0; j < var_rank[i]; j++) {
-#line 591
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 591
-                    nels *= count[j];
-#line 591
-                    index[j] += start[j];
-#line 591
-                }
-#line 591
-                        /* Random choice of forward or backward */
-#line 591
-/* TODO
-#line 591
-                if ( roll(2) ) {
-#line 591
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 591
-                        index[j] += (count[j] - 1) * stride[j];
-#line 591
-                        stride[j] = -stride[j];
-#line 591
-                    }
-#line 591
-                }
-#line 591
-*/
-#line 591
-		allInExtRange = allInIntRange = 1;
-#line 591
-		for (j = 0; j < nels; j++) {
-#line 591
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 591
-		    IF (err)
-#line 591
-			error("error in toMixedBase 1");
-#line 591
-		    for (d = 0; d < var_rank[i]; d++)
-#line 591
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 591
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 591
-			NCT_TEXT);
-#line 591
-		    if (inRange3(expect[j],var_type[i],NCT_TEXT)) {
-#line 591
-			allInIntRange = allInIntRange && expect[j] >= text_min
-#line 591
-			    && expect[j] <= text_max;
-#line 591
-		    } else {
-#line 591
-			allInExtRange = 0;
-#line 591
-		    }
-#line 591
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT);
+		if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
+		    allInIntRange = allInIntRange && expect[j] >= short_min
+				&& expect[j] <= short_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 591
-                if (var_rank[i] == 0 && i%2 )
-#line 591
-                    err = nc_get_vars_text(ncid, i, NULL, NULL, NULL, value);
-#line 591
-                else
-#line 591
-                    err = nc_get_vars_text(ncid, i, index, count, stride, value);
-#line 591
-		if (canConvert) {
-#line 591
-		    if (allInExtRange) {
-#line 591
-			if (allInIntRange) {
-#line 591
-			    IF (err)
-#line 591
-				error("%s", nc_strerror(err));
-#line 591
-			} else {
-#line 591
-			    IF (err != NC_ERANGE)
-#line 591
-				error("Range error: status = %d", err);
-#line 591
-			}
-#line 591
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_short(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_short(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 591
-			IF (err != 0 && err != NC_ERANGE)
-#line 591
-			    error("OK or Range error: status = %d", err);
-#line 591
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 591
-		    for (j = 0; j < nels; j++) {
-#line 591
-			if (inRange3(expect[j],var_type[i],NCT_TEXT)
-#line 591
-				&& expect[j] >= text_min && expect[j] <= text_max) {
-#line 591
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_TEXT)){
-#line 591
-				error("value read not that expected");
-#line 591
-				if (verbose) {
-#line 591
-				    error("\n");
-#line 591
-				    error("varid: %d, ", i);
-#line 591
-				    error("var_name: %s, ", var_name[i]);
-#line 591
-				    error("element number: %d ", j);
-#line 591
-                                    error("expect: %g, ", expect[j]);
-#line 591
-				    error("got: %g", (double) value[j]);
-#line 591
-				}
-#line 591
-			    } else {
-#line 591
-				nok++;
-#line 591
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_SHORT)
+			    && expect[j] >= short_min && expect[j] <= short_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 591
+			} else {
+			    nok++;
 			}
-#line 591
 		    }
-#line 591
-		} else {
-#line 591
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 591
-			error("wrong type: status = %d", err);
-#line 591
 		}
-#line 591
-	    }
-#line 591
-	}
-#line 591
-
-#line 591
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 591
     err = nc_close(ncid);
-#line 591
     IF (err)
-#line 591
-        error("nc_close: %s", nc_strerror(err));
-#line 591
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 591
 }
-#line 591
 
 void
-#line 592
-test_nc_get_vars_uchar(void)
-#line 592
+test_nc_get_vara_int(void)
 {
-#line 592
     int ncid;
-#line 592
     int d;
-#line 592
     int i;
-#line 592
     int j;
-#line 592
     int k;
-#line 592
-    int m;
-#line 592
     int err;
-#line 592
     int allInExtRange;	/* all values within external range? */
-#line 592
     int allInIntRange;	/* all values within internal range? */
-#line 592
     int nels;
-#line 592
     int nslabs;
-#line 592
-    int nstarts;        /* number of different starts */
-#line 592
     int nok = 0;      /* count of valid comparisons */
-#line 592
     size_t start[MAX_RANK];
-#line 592
     size_t edge[MAX_RANK];
-#line 592
     size_t index[MAX_RANK];
-#line 592
-    size_t index2[MAX_RANK];
-#line 592
     size_t mid[MAX_RANK];
-#line 592
-    size_t count[MAX_RANK];
-#line 592
-    size_t sstride[MAX_RANK];
-#line 592
-    ptrdiff_t stride[MAX_RANK];
-#line 592
     int canConvert;     /* Both text or both numeric */
-#line 592
-    uchar value[MAX_NELS];
-#line 592
+    int value[MAX_NELS];
     double expect[MAX_NELS];
-#line 592
 
-#line 592
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 592
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 592
-        error("nc_open: %s", nc_strerror(err));
-#line 592
-    for (i = 0; i < NVARS; i++) {
-#line 592
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 592
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 592
         assert(var_nels[i] <= MAX_NELS);
-#line 592
-        for (j = 0; j < var_rank[i]; j++) {
-#line 592
-            start[j] = 0;
-#line 592
-            edge[j] = 1;
-#line 592
-            stride[j] = 1;
-#line 592
-        }
-#line 592
-        err = nc_get_vars_uchar(BAD_ID, i, start, edge, stride, value);
-#line 592
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_int(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 592
-            error("bad ncid: status = %d", err);
-#line 592
-        err = nc_get_vars_uchar(ncid, BAD_VARID, start, edge, stride, value);
-#line 592
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 592
-            error("bad var id: status = %d", err);
-#line 592
-        for (j = 0; j < var_rank[i]; j++) {
-#line 592
-            start[j] = var_shape[i][j];
-#line 592
-            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
-#line 592
-	  if(!canConvert) {
-#line 592
-		IF (err != NC_ECHAR)
-#line 592
-               	    error("conversion: status = %d", err);
-#line 592
-	  } else {
-#line 592
-            IF (err != NC_EINVALCOORDS)
-#line 592
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_int(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 592
-            start[j] = 0;
-#line 592
-            edge[j] = var_shape[i][j] + 1;
-#line 592
-            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
-#line 592
-            IF (err != NC_EEDGE)
-#line 592
-                error("bad edge: status = %d", err);
-#line 592
-            edge[j] = 1;
-#line 592
-            stride[j] = 0;
-#line 592
-            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
-#line 592
-            IF (err != NC_ESTRIDE)
-#line 592
-                error("bad stride: status = %d", err);
-#line 592
-            stride[j] = 1;
-#line 592
-	  }
-#line 592
-        }
-#line 592
-            /* Choose a random point dividing each dim into 2 parts */
-#line 592
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_int(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_int(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_int(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_int(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 592
         nslabs = 1;
-#line 592
         for (j = 0; j < var_rank[i]; j++) {
-#line 592
             mid[j] = roll( var_shape[i][j] );
-#line 592
             nslabs *= 2;
-#line 592
         }
-#line 592
             /* bits of k determine whether to get lower or upper part of dim */
-#line 592
-            /* choose random stride from 1 to edge */
-#line 592
         for (k = 0; k < nslabs; k++) {
-#line 592
-            nstarts = 1;
-#line 592
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 592
                 if ((k >> j) & 1) {
-#line 592
                     start[j] = 0;
-#line 592
                     edge[j] = mid[j];
-#line 592
                 }else{
-#line 592
                     start[j] = mid[j];
-#line 592
                     edge[j] = var_shape[i][j] - mid[j];
-#line 592
                 }
-#line 592
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 592
-                nstarts *= stride[j];
-#line 592
+                nels *= edge[j];
             }
-#line 592
-            for (m = 0; m < nstarts; m++) {
-#line 592
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 592
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 592
-                    error("error in toMixedBase");
-#line 592
-                nels = 1;
-#line 592
-                for (j = 0; j < var_rank[i]; j++) {
-#line 592
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 592
-                    nels *= count[j];
-#line 592
-                    index[j] += start[j];
-#line 592
-                }
-#line 592
-                        /* Random choice of forward or backward */
-#line 592
-/* TODO
-#line 592
-                if ( roll(2) ) {
-#line 592
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 592
-                        index[j] += (count[j] - 1) * stride[j];
-#line 592
-                        stride[j] = -stride[j];
-#line 592
-                    }
-#line 592
-                }
-#line 592
-*/
-#line 592
-		allInExtRange = allInIntRange = 1;
-#line 592
-		for (j = 0; j < nels; j++) {
-#line 592
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 592
-		    IF (err)
-#line 592
-			error("error in toMixedBase 1");
-#line 592
-		    for (d = 0; d < var_rank[i]; d++)
-#line 592
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 592
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 592
-			NCT_UCHAR);
-#line 592
-		    if (inRange3(expect[j],var_type[i],NCT_UCHAR)) {
-#line 592
-			allInIntRange = allInIntRange && expect[j] >= uchar_min
-#line 592
-			    && expect[j] <= uchar_max;
-#line 592
-		    } else {
-#line 592
-			allInExtRange = 0;
-#line 592
-		    }
-#line 592
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT);
+		if (inRange3(expect[j],var_type[i], NCT_INT)) {
+		    allInIntRange = allInIntRange && expect[j] >= int_min
+				&& expect[j] <= int_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 592
-                if (var_rank[i] == 0 && i%2 )
-#line 592
-                    err = nc_get_vars_uchar(ncid, i, NULL, NULL, NULL, value);
-#line 592
-                else
-#line 592
-                    err = nc_get_vars_uchar(ncid, i, index, count, stride, value);
-#line 592
-		if (canConvert) {
-#line 592
-		    if (allInExtRange) {
-#line 592
-			if (allInIntRange) {
-#line 592
-			    IF (err)
-#line 592
-				error("%s", nc_strerror(err));
-#line 592
-			} else {
-#line 592
-			    IF (err != NC_ERANGE)
-#line 592
-				error("Range error: status = %d", err);
-#line 592
-			}
-#line 592
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_int(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_int(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 592
-			IF (err != 0 && err != NC_ERANGE)
-#line 592
-			    error("OK or Range error: status = %d", err);
-#line 592
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 592
-		    for (j = 0; j < nels; j++) {
-#line 592
-			if (inRange3(expect[j],var_type[i],NCT_UCHAR)
-#line 592
-				&& expect[j] >= uchar_min && expect[j] <= uchar_max) {
-#line 592
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_UCHAR)){
-#line 592
-				error("value read not that expected");
-#line 592
-				if (verbose) {
-#line 592
-				    error("\n");
-#line 592
-				    error("varid: %d, ", i);
-#line 592
-				    error("var_name: %s, ", var_name[i]);
-#line 592
-				    error("element number: %d ", j);
-#line 592
-                                    error("expect: %g, ", expect[j]);
-#line 592
-				    error("got: %g", (double) value[j]);
-#line 592
-				}
-#line 592
-			    } else {
-#line 592
-				nok++;
-#line 592
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_INT)
+			    && expect[j] >= int_min && expect[j] <= int_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 592
+			} else {
+			    nok++;
 			}
-#line 592
 		    }
-#line 592
-		} else {
-#line 592
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 592
-			error("wrong type: status = %d", err);
-#line 592
 		}
-#line 592
-	    }
-#line 592
-	}
-#line 592
-
-#line 592
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 592
     err = nc_close(ncid);
-#line 592
     IF (err)
-#line 592
-        error("nc_close: %s", nc_strerror(err));
-#line 592
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 592
 }
-#line 592
 
 void
-#line 593
-test_nc_get_vars_schar(void)
-#line 593
+test_nc_get_vara_long(void)
 {
-#line 593
     int ncid;
-#line 593
     int d;
-#line 593
     int i;
-#line 593
     int j;
-#line 593
     int k;
-#line 593
-    int m;
-#line 593
     int err;
-#line 593
     int allInExtRange;	/* all values within external range? */
-#line 593
     int allInIntRange;	/* all values within internal range? */
-#line 593
     int nels;
-#line 593
     int nslabs;
-#line 593
-    int nstarts;        /* number of different starts */
-#line 593
     int nok = 0;      /* count of valid comparisons */
-#line 593
     size_t start[MAX_RANK];
-#line 593
     size_t edge[MAX_RANK];
-#line 593
     size_t index[MAX_RANK];
-#line 593
-    size_t index2[MAX_RANK];
-#line 593
     size_t mid[MAX_RANK];
-#line 593
-    size_t count[MAX_RANK];
-#line 593
-    size_t sstride[MAX_RANK];
-#line 593
-    ptrdiff_t stride[MAX_RANK];
-#line 593
     int canConvert;     /* Both text or both numeric */
-#line 593
-    schar value[MAX_NELS];
-#line 593
+    long value[MAX_NELS];
     double expect[MAX_NELS];
-#line 593
 
-#line 593
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 593
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 593
-        error("nc_open: %s", nc_strerror(err));
-#line 593
-    for (i = 0; i < NVARS; i++) {
-#line 593
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 593
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 593
         assert(var_nels[i] <= MAX_NELS);
-#line 593
-        for (j = 0; j < var_rank[i]; j++) {
-#line 593
-            start[j] = 0;
-#line 593
-            edge[j] = 1;
-#line 593
-            stride[j] = 1;
-#line 593
-        }
-#line 593
-        err = nc_get_vars_schar(BAD_ID, i, start, edge, stride, value);
-#line 593
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_long(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 593
-            error("bad ncid: status = %d", err);
-#line 593
-        err = nc_get_vars_schar(ncid, BAD_VARID, start, edge, stride, value);
-#line 593
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 593
-            error("bad var id: status = %d", err);
-#line 593
-        for (j = 0; j < var_rank[i]; j++) {
-#line 593
-            start[j] = var_shape[i][j];
-#line 593
-            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
-#line 593
-	  if(!canConvert) {
-#line 593
-		IF (err != NC_ECHAR)
-#line 593
-               	    error("conversion: status = %d", err);
-#line 593
-	  } else {
-#line 593
-            IF (err != NC_EINVALCOORDS)
-#line 593
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_long(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 593
-            start[j] = 0;
-#line 593
-            edge[j] = var_shape[i][j] + 1;
-#line 593
-            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
-#line 593
-            IF (err != NC_EEDGE)
-#line 593
-                error("bad edge: status = %d", err);
-#line 593
-            edge[j] = 1;
-#line 593
-            stride[j] = 0;
-#line 593
-            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
-#line 593
-            IF (err != NC_ESTRIDE)
-#line 593
-                error("bad stride: status = %d", err);
-#line 593
-            stride[j] = 1;
-#line 593
-	  }
-#line 593
-        }
-#line 593
-            /* Choose a random point dividing each dim into 2 parts */
-#line 593
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_long(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_long(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_long(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_long(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 593
         nslabs = 1;
-#line 593
         for (j = 0; j < var_rank[i]; j++) {
-#line 593
             mid[j] = roll( var_shape[i][j] );
-#line 593
             nslabs *= 2;
-#line 593
         }
-#line 593
             /* bits of k determine whether to get lower or upper part of dim */
-#line 593
-            /* choose random stride from 1 to edge */
-#line 593
         for (k = 0; k < nslabs; k++) {
-#line 593
-            nstarts = 1;
-#line 593
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 593
                 if ((k >> j) & 1) {
-#line 593
                     start[j] = 0;
-#line 593
                     edge[j] = mid[j];
-#line 593
                 }else{
-#line 593
                     start[j] = mid[j];
-#line 593
                     edge[j] = var_shape[i][j] - mid[j];
-#line 593
                 }
-#line 593
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 593
-                nstarts *= stride[j];
-#line 593
+                nels *= edge[j];
             }
-#line 593
-            for (m = 0; m < nstarts; m++) {
-#line 593
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 593
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 593
-                    error("error in toMixedBase");
-#line 593
-                nels = 1;
-#line 593
-                for (j = 0; j < var_rank[i]; j++) {
-#line 593
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 593
-                    nels *= count[j];
-#line 593
-                    index[j] += start[j];
-#line 593
-                }
-#line 593
-                        /* Random choice of forward or backward */
-#line 593
-/* TODO
-#line 593
-                if ( roll(2) ) {
-#line 593
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 593
-                        index[j] += (count[j] - 1) * stride[j];
-#line 593
-                        stride[j] = -stride[j];
-#line 593
-                    }
-#line 593
-                }
-#line 593
-*/
-#line 593
-		allInExtRange = allInIntRange = 1;
-#line 593
-		for (j = 0; j < nels; j++) {
-#line 593
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 593
-		    IF (err)
-#line 593
-			error("error in toMixedBase 1");
-#line 593
-		    for (d = 0; d < var_rank[i]; d++)
-#line 593
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 593
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 593
-			NCT_SCHAR);
-#line 593
-		    if (inRange3(expect[j],var_type[i],NCT_SCHAR)) {
-#line 593
-			allInIntRange = allInIntRange && expect[j] >= schar_min
-#line 593
-			    && expect[j] <= schar_max;
-#line 593
-		    } else {
-#line 593
-			allInExtRange = 0;
-#line 593
-		    }
-#line 593
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG);
+		if (inRange3(expect[j],var_type[i], NCT_LONG)) {
+		    allInIntRange = allInIntRange && expect[j] >= long_min
+				&& expect[j] <= long_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 593
-                if (var_rank[i] == 0 && i%2 )
-#line 593
-                    err = nc_get_vars_schar(ncid, i, NULL, NULL, NULL, value);
-#line 593
-                else
-#line 593
-                    err = nc_get_vars_schar(ncid, i, index, count, stride, value);
-#line 593
-		if (canConvert) {
-#line 593
-		    if (allInExtRange) {
-#line 593
-			if (allInIntRange) {
-#line 593
-			    IF (err)
-#line 593
-				error("%s", nc_strerror(err));
-#line 593
-			} else {
-#line 593
-			    IF (err != NC_ERANGE)
-#line 593
-				error("Range error: status = %d", err);
-#line 593
-			}
-#line 593
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_long(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_long(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 593
-			IF (err != 0 && err != NC_ERANGE)
-#line 593
-			    error("OK or Range error: status = %d", err);
-#line 593
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 593
-		    for (j = 0; j < nels; j++) {
-#line 593
-			if (inRange3(expect[j],var_type[i],NCT_SCHAR)
-#line 593
-				&& expect[j] >= schar_min && expect[j] <= schar_max) {
-#line 593
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_SCHAR)){
-#line 593
-				error("value read not that expected");
-#line 593
-				if (verbose) {
-#line 593
-				    error("\n");
-#line 593
-				    error("varid: %d, ", i);
-#line 593
-				    error("var_name: %s, ", var_name[i]);
-#line 593
-				    error("element number: %d ", j);
-#line 593
-                                    error("expect: %g, ", expect[j]);
-#line 593
-				    error("got: %g", (double) value[j]);
-#line 593
-				}
-#line 593
-			    } else {
-#line 593
-				nok++;
-#line 593
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_LONG)
+			    && expect[j] >= long_min && expect[j] <= long_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 593
+			} else {
+			    nok++;
 			}
-#line 593
 		    }
-#line 593
-		} else {
-#line 593
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 593
-			error("wrong type: status = %d", err);
-#line 593
 		}
-#line 593
-	    }
-#line 593
-	}
-#line 593
-
-#line 593
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 593
     err = nc_close(ncid);
-#line 593
     IF (err)
-#line 593
-        error("nc_close: %s", nc_strerror(err));
-#line 593
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 593
 }
-#line 593
 
 void
-#line 594
-test_nc_get_vars_short(void)
-#line 594
+test_nc_get_vara_float(void)
 {
-#line 594
     int ncid;
-#line 594
     int d;
-#line 594
     int i;
-#line 594
     int j;
-#line 594
     int k;
-#line 594
-    int m;
-#line 594
     int err;
-#line 594
     int allInExtRange;	/* all values within external range? */
-#line 594
     int allInIntRange;	/* all values within internal range? */
-#line 594
     int nels;
-#line 594
     int nslabs;
-#line 594
-    int nstarts;        /* number of different starts */
-#line 594
     int nok = 0;      /* count of valid comparisons */
-#line 594
     size_t start[MAX_RANK];
-#line 594
     size_t edge[MAX_RANK];
-#line 594
     size_t index[MAX_RANK];
-#line 594
-    size_t index2[MAX_RANK];
-#line 594
     size_t mid[MAX_RANK];
-#line 594
-    size_t count[MAX_RANK];
-#line 594
-    size_t sstride[MAX_RANK];
-#line 594
-    ptrdiff_t stride[MAX_RANK];
-#line 594
     int canConvert;     /* Both text or both numeric */
-#line 594
-    short value[MAX_NELS];
-#line 594
+    float value[MAX_NELS];
     double expect[MAX_NELS];
-#line 594
 
-#line 594
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 594
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 594
-        error("nc_open: %s", nc_strerror(err));
-#line 594
-    for (i = 0; i < NVARS; i++) {
-#line 594
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 594
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 594
         assert(var_nels[i] <= MAX_NELS);
-#line 594
-        for (j = 0; j < var_rank[i]; j++) {
-#line 594
-            start[j] = 0;
-#line 594
-            edge[j] = 1;
-#line 594
-            stride[j] = 1;
-#line 594
-        }
-#line 594
-        err = nc_get_vars_short(BAD_ID, i, start, edge, stride, value);
-#line 594
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_float(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 594
-            error("bad ncid: status = %d", err);
-#line 594
-        err = nc_get_vars_short(ncid, BAD_VARID, start, edge, stride, value);
-#line 594
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 594
-            error("bad var id: status = %d", err);
-#line 594
-        for (j = 0; j < var_rank[i]; j++) {
-#line 594
-            start[j] = var_shape[i][j];
-#line 594
-            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
-#line 594
-	  if(!canConvert) {
-#line 594
-		IF (err != NC_ECHAR)
-#line 594
-               	    error("conversion: status = %d", err);
-#line 594
-	  } else {
-#line 594
-            IF (err != NC_EINVALCOORDS)
-#line 594
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_float(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 594
-            start[j] = 0;
-#line 594
-            edge[j] = var_shape[i][j] + 1;
-#line 594
-            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
-#line 594
-            IF (err != NC_EEDGE)
-#line 594
-                error("bad edge: status = %d", err);
-#line 594
-            edge[j] = 1;
-#line 594
-            stride[j] = 0;
-#line 594
-            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
-#line 594
-            IF (err != NC_ESTRIDE)
-#line 594
-                error("bad stride: status = %d", err);
-#line 594
-            stride[j] = 1;
-#line 594
-	  }
-#line 594
-        }
-#line 594
-            /* Choose a random point dividing each dim into 2 parts */
-#line 594
-            /* get 2^rank (nslabs) slabs so defined */
-#line 594
-        nslabs = 1;
-#line 594
-        for (j = 0; j < var_rank[i]; j++) {
-#line 594
-            mid[j] = roll( var_shape[i][j] );
-#line 594
-            nslabs *= 2;
-#line 594
-        }
-#line 594
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 594
-            /* choose random stride from 1 to edge */
-#line 594
-        for (k = 0; k < nslabs; k++) {
-#line 594
-            nstarts = 1;
-#line 594
-            for (j = 0; j < var_rank[i]; j++) {
-#line 594
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_float(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_float(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_float(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_float(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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++) {
+            nels = 1;
+            for (j = 0; j < var_rank[i]; j++) {
                 if ((k >> j) & 1) {
-#line 594
                     start[j] = 0;
-#line 594
                     edge[j] = mid[j];
-#line 594
                 }else{
-#line 594
                     start[j] = mid[j];
-#line 594
                     edge[j] = var_shape[i][j] - mid[j];
-#line 594
                 }
-#line 594
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 594
-                nstarts *= stride[j];
-#line 594
+                nels *= edge[j];
             }
-#line 594
-            for (m = 0; m < nstarts; m++) {
-#line 594
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 594
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 594
-                    error("error in toMixedBase");
-#line 594
-                nels = 1;
-#line 594
-                for (j = 0; j < var_rank[i]; j++) {
-#line 594
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 594
-                    nels *= count[j];
-#line 594
-                    index[j] += start[j];
-#line 594
-                }
-#line 594
-                        /* Random choice of forward or backward */
-#line 594
-/* TODO
-#line 594
-                if ( roll(2) ) {
-#line 594
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 594
-                        index[j] += (count[j] - 1) * stride[j];
-#line 594
-                        stride[j] = -stride[j];
-#line 594
-                    }
-#line 594
-                }
-#line 594
-*/
-#line 594
-		allInExtRange = allInIntRange = 1;
-#line 594
-		for (j = 0; j < nels; j++) {
-#line 594
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 594
-		    IF (err)
-#line 594
-			error("error in toMixedBase 1");
-#line 594
-		    for (d = 0; d < var_rank[i]; d++)
-#line 594
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 594
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 594
-			NCT_SHORT);
-#line 594
-		    if (inRange3(expect[j],var_type[i],NCT_SHORT)) {
-#line 594
-			allInIntRange = allInIntRange && expect[j] >= short_min
-#line 594
-			    && expect[j] <= short_max;
-#line 594
-		    } else {
-#line 594
-			allInExtRange = 0;
-#line 594
-		    }
-#line 594
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT);
+		if (inRange3(expect[j],var_type[i], NCT_FLOAT)) {
+		    allInIntRange = allInIntRange && expect[j] >= float_min
+				&& expect[j] <= float_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 594
-                if (var_rank[i] == 0 && i%2 )
-#line 594
-                    err = nc_get_vars_short(ncid, i, NULL, NULL, NULL, value);
-#line 594
-                else
-#line 594
-                    err = nc_get_vars_short(ncid, i, index, count, stride, value);
-#line 594
-		if (canConvert) {
-#line 594
-		    if (allInExtRange) {
-#line 594
-			if (allInIntRange) {
-#line 594
-			    IF (err)
-#line 594
-				error("%s", nc_strerror(err));
-#line 594
-			} else {
-#line 594
-			    IF (err != NC_ERANGE)
-#line 594
-				error("Range error: status = %d", err);
-#line 594
-			}
-#line 594
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_float(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_float(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 594
-			IF (err != 0 && err != NC_ERANGE)
-#line 594
-			    error("OK or Range error: status = %d", err);
-#line 594
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 594
-		    for (j = 0; j < nels; j++) {
-#line 594
-			if (inRange3(expect[j],var_type[i],NCT_SHORT)
-#line 594
-				&& expect[j] >= short_min && expect[j] <= short_max) {
-#line 594
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_SHORT)){
-#line 594
-				error("value read not that expected");
-#line 594
-				if (verbose) {
-#line 594
-				    error("\n");
-#line 594
-				    error("varid: %d, ", i);
-#line 594
-				    error("var_name: %s, ", var_name[i]);
-#line 594
-				    error("element number: %d ", j);
-#line 594
-                                    error("expect: %g, ", expect[j]);
-#line 594
-				    error("got: %g", (double) value[j]);
-#line 594
-				}
-#line 594
-			    } else {
-#line 594
-				nok++;
-#line 594
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+			    && expect[j] >= float_min && expect[j] <= float_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 594
+			} else {
+			    nok++;
 			}
-#line 594
 		    }
-#line 594
-		} else {
-#line 594
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 594
-			error("wrong type: status = %d", err);
-#line 594
 		}
-#line 594
-	    }
-#line 594
-	}
-#line 594
-
-#line 594
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 594
     err = nc_close(ncid);
-#line 594
     IF (err)
-#line 594
-        error("nc_close: %s", nc_strerror(err));
-#line 594
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 594
 }
-#line 594
 
 void
-#line 595
-test_nc_get_vars_int(void)
-#line 595
+test_nc_get_vara_double(void)
 {
-#line 595
     int ncid;
-#line 595
     int d;
-#line 595
     int i;
-#line 595
     int j;
-#line 595
     int k;
-#line 595
-    int m;
-#line 595
     int err;
-#line 595
     int allInExtRange;	/* all values within external range? */
-#line 595
     int allInIntRange;	/* all values within internal range? */
-#line 595
     int nels;
-#line 595
     int nslabs;
-#line 595
-    int nstarts;        /* number of different starts */
-#line 595
     int nok = 0;      /* count of valid comparisons */
-#line 595
     size_t start[MAX_RANK];
-#line 595
     size_t edge[MAX_RANK];
-#line 595
     size_t index[MAX_RANK];
-#line 595
-    size_t index2[MAX_RANK];
-#line 595
     size_t mid[MAX_RANK];
-#line 595
-    size_t count[MAX_RANK];
-#line 595
-    size_t sstride[MAX_RANK];
-#line 595
-    ptrdiff_t stride[MAX_RANK];
-#line 595
     int canConvert;     /* Both text or both numeric */
-#line 595
-    int value[MAX_NELS];
-#line 595
+    double value[MAX_NELS];
     double expect[MAX_NELS];
-#line 595
 
-#line 595
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 595
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 595
-        error("nc_open: %s", nc_strerror(err));
-#line 595
-    for (i = 0; i < NVARS; i++) {
-#line 595
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 595
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 595
         assert(var_nels[i] <= MAX_NELS);
-#line 595
-        for (j = 0; j < var_rank[i]; j++) {
-#line 595
-            start[j] = 0;
-#line 595
-            edge[j] = 1;
-#line 595
-            stride[j] = 1;
-#line 595
-        }
-#line 595
-        err = nc_get_vars_int(BAD_ID, i, start, edge, stride, value);
-#line 595
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_double(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 595
-            error("bad ncid: status = %d", err);
-#line 595
-        err = nc_get_vars_int(ncid, BAD_VARID, start, edge, stride, value);
-#line 595
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 595
-            error("bad var id: status = %d", err);
-#line 595
-        for (j = 0; j < var_rank[i]; j++) {
-#line 595
-            start[j] = var_shape[i][j];
-#line 595
-            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
-#line 595
-	  if(!canConvert) {
-#line 595
-		IF (err != NC_ECHAR)
-#line 595
-               	    error("conversion: status = %d", err);
-#line 595
-	  } else {
-#line 595
-            IF (err != NC_EINVALCOORDS)
-#line 595
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_double(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 595
-            start[j] = 0;
-#line 595
-            edge[j] = var_shape[i][j] + 1;
-#line 595
-            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
-#line 595
-            IF (err != NC_EEDGE)
-#line 595
-                error("bad edge: status = %d", err);
-#line 595
-            edge[j] = 1;
-#line 595
-            stride[j] = 0;
-#line 595
-            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
-#line 595
-            IF (err != NC_ESTRIDE)
-#line 595
-                error("bad stride: status = %d", err);
-#line 595
-            stride[j] = 1;
-#line 595
-	  }
-#line 595
-        }
-#line 595
-            /* Choose a random point dividing each dim into 2 parts */
-#line 595
-            /* get 2^rank (nslabs) slabs so defined */
-#line 595
-        nslabs = 1;
-#line 595
-        for (j = 0; j < var_rank[i]; j++) {
-#line 595
-            mid[j] = roll( var_shape[i][j] );
-#line 595
-            nslabs *= 2;
-#line 595
-        }
-#line 595
-            /* bits of k determine whether to get lower or upper part of dim */
-#line 595
-            /* choose random stride from 1 to edge */
-#line 595
-        for (k = 0; k < nslabs; k++) {
-#line 595
-            nstarts = 1;
-#line 595
-            for (j = 0; j < var_rank[i]; j++) {
-#line 595
-                if ((k >> j) & 1) {
-#line 595
-                    start[j] = 0;
-#line 595
-                    edge[j] = mid[j];
-#line 595
-                }else{
-#line 595
-                    start[j] = mid[j];
-#line 595
-                    edge[j] = var_shape[i][j] - mid[j];
-#line 595
-                }
-#line 595
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 595
-                nstarts *= stride[j];
-#line 595
-            }
-#line 595
-            for (m = 0; m < nstarts; m++) {
-#line 595
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 595
-                IF (err)
-#line 595
-                    error("error in toMixedBase");
-#line 595
-                nels = 1;
-#line 595
-                for (j = 0; j < var_rank[i]; j++) {
-#line 595
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 595
-                    nels *= count[j];
-#line 595
-                    index[j] += start[j];
-#line 595
-                }
-#line 595
-                        /* Random choice of forward or backward */
-#line 595
-/* TODO
-#line 595
-                if ( roll(2) ) {
-#line 595
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 595
-                        index[j] += (count[j] - 1) * stride[j];
-#line 595
-                        stride[j] = -stride[j];
-#line 595
-                    }
-#line 595
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_double(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_double(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_double(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_double(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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++) {
+            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];
                 }
-#line 595
-*/
-#line 595
-		allInExtRange = allInIntRange = 1;
-#line 595
-		for (j = 0; j < nels; j++) {
-#line 595
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 595
-		    IF (err)
-#line 595
-			error("error in toMixedBase 1");
-#line 595
-		    for (d = 0; d < var_rank[i]; d++)
-#line 595
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 595
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 595
-			NCT_INT);
-#line 595
-		    if (inRange3(expect[j],var_type[i],NCT_INT)) {
-#line 595
-			allInIntRange = allInIntRange && expect[j] >= int_min
-#line 595
-			    && expect[j] <= int_max;
-#line 595
-		    } else {
-#line 595
-			allInExtRange = 0;
-#line 595
-		    }
-#line 595
+                nels *= edge[j];
+            }
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
+                IF (err)
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE);
+		if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) {
+		    allInIntRange = allInIntRange && expect[j] >= double_min
+				&& expect[j] <= double_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 595
-                if (var_rank[i] == 0 && i%2 )
-#line 595
-                    err = nc_get_vars_int(ncid, i, NULL, NULL, NULL, value);
-#line 595
-                else
-#line 595
-                    err = nc_get_vars_int(ncid, i, index, count, stride, value);
-#line 595
-		if (canConvert) {
-#line 595
-		    if (allInExtRange) {
-#line 595
-			if (allInIntRange) {
-#line 595
-			    IF (err)
-#line 595
-				error("%s", nc_strerror(err));
-#line 595
-			} else {
-#line 595
-			    IF (err != NC_ERANGE)
-#line 595
-				error("Range error: status = %d", err);
-#line 595
-			}
-#line 595
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_double(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_double(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 595
-			IF (err != 0 && err != NC_ERANGE)
-#line 595
-			    error("OK or Range error: status = %d", err);
-#line 595
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 595
-		    for (j = 0; j < nels; j++) {
-#line 595
-			if (inRange3(expect[j],var_type[i],NCT_INT)
-#line 595
-				&& expect[j] >= int_min && expect[j] <= int_max) {
-#line 595
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_INT)){
-#line 595
-				error("value read not that expected");
-#line 595
-				if (verbose) {
-#line 595
-				    error("\n");
-#line 595
-				    error("varid: %d, ", i);
-#line 595
-				    error("var_name: %s, ", var_name[i]);
-#line 595
-				    error("element number: %d ", j);
-#line 595
-                                    error("expect: %g, ", expect[j]);
-#line 595
-				    error("got: %g", (double) value[j]);
-#line 595
-				}
-#line 595
-			    } else {
-#line 595
-				nok++;
-#line 595
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+			    && expect[j] >= double_min && expect[j] <= double_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 595
+			} else {
+			    nok++;
 			}
-#line 595
 		    }
-#line 595
-		} else {
-#line 595
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 595
-			error("wrong type: status = %d", err);
-#line 595
 		}
-#line 595
-	    }
-#line 595
-	}
-#line 595
-
-#line 595
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 595
     err = nc_close(ncid);
-#line 595
     IF (err)
-#line 595
-        error("nc_close: %s", nc_strerror(err));
-#line 595
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 595
 }
-#line 595
 
 void
-#line 596
-test_nc_get_vars_long(void)
-#line 596
+test_nc_get_vara_ushort(void)
 {
-#line 596
     int ncid;
-#line 596
     int d;
-#line 596
     int i;
-#line 596
     int j;
-#line 596
     int k;
-#line 596
-    int m;
-#line 596
     int err;
-#line 596
     int allInExtRange;	/* all values within external range? */
-#line 596
     int allInIntRange;	/* all values within internal range? */
-#line 596
     int nels;
-#line 596
     int nslabs;
-#line 596
-    int nstarts;        /* number of different starts */
-#line 596
     int nok = 0;      /* count of valid comparisons */
-#line 596
     size_t start[MAX_RANK];
-#line 596
     size_t edge[MAX_RANK];
-#line 596
     size_t index[MAX_RANK];
-#line 596
-    size_t index2[MAX_RANK];
-#line 596
     size_t mid[MAX_RANK];
-#line 596
-    size_t count[MAX_RANK];
-#line 596
-    size_t sstride[MAX_RANK];
-#line 596
-    ptrdiff_t stride[MAX_RANK];
-#line 596
     int canConvert;     /* Both text or both numeric */
-#line 596
-    long value[MAX_NELS];
-#line 596
+    ushort value[MAX_NELS];
     double expect[MAX_NELS];
-#line 596
 
-#line 596
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 596
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 596
-        error("nc_open: %s", nc_strerror(err));
-#line 596
-    for (i = 0; i < NVARS; i++) {
-#line 596
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 596
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 596
         assert(var_nels[i] <= MAX_NELS);
-#line 596
-        for (j = 0; j < var_rank[i]; j++) {
-#line 596
-            start[j] = 0;
-#line 596
-            edge[j] = 1;
-#line 596
-            stride[j] = 1;
-#line 596
-        }
-#line 596
-        err = nc_get_vars_long(BAD_ID, i, start, edge, stride, value);
-#line 596
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_ushort(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 596
-            error("bad ncid: status = %d", err);
-#line 596
-        err = nc_get_vars_long(ncid, BAD_VARID, start, edge, stride, value);
-#line 596
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_ushort(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 596
-            error("bad var id: status = %d", err);
-#line 596
-        for (j = 0; j < var_rank[i]; j++) {
-#line 596
-            start[j] = var_shape[i][j];
-#line 596
-            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
-#line 596
-	  if(!canConvert) {
-#line 596
-		IF (err != NC_ECHAR)
-#line 596
-               	    error("conversion: status = %d", err);
-#line 596
-	  } else {
-#line 596
-            IF (err != NC_EINVALCOORDS)
-#line 596
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 596
-            start[j] = 0;
-#line 596
-            edge[j] = var_shape[i][j] + 1;
-#line 596
-            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
-#line 596
-            IF (err != NC_EEDGE)
-#line 596
-                error("bad edge: status = %d", err);
-#line 596
-            edge[j] = 1;
-#line 596
-            stride[j] = 0;
-#line 596
-            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
-#line 596
-            IF (err != NC_ESTRIDE)
-#line 596
-                error("bad stride: status = %d", err);
-#line 596
-            stride[j] = 1;
-#line 596
-	  }
-#line 596
-        }
-#line 596
-            /* Choose a random point dividing each dim into 2 parts */
-#line 596
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_ushort(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_ushort(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 596
         nslabs = 1;
-#line 596
         for (j = 0; j < var_rank[i]; j++) {
-#line 596
             mid[j] = roll( var_shape[i][j] );
-#line 596
             nslabs *= 2;
-#line 596
         }
-#line 596
             /* bits of k determine whether to get lower or upper part of dim */
-#line 596
-            /* choose random stride from 1 to edge */
-#line 596
         for (k = 0; k < nslabs; k++) {
-#line 596
-            nstarts = 1;
-#line 596
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 596
                 if ((k >> j) & 1) {
-#line 596
                     start[j] = 0;
-#line 596
                     edge[j] = mid[j];
-#line 596
                 }else{
-#line 596
                     start[j] = mid[j];
-#line 596
                     edge[j] = var_shape[i][j] - mid[j];
-#line 596
                 }
-#line 596
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 596
-                nstarts *= stride[j];
-#line 596
+                nels *= edge[j];
             }
-#line 596
-            for (m = 0; m < nstarts; m++) {
-#line 596
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 596
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 596
-                    error("error in toMixedBase");
-#line 596
-                nels = 1;
-#line 596
-                for (j = 0; j < var_rank[i]; j++) {
-#line 596
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 596
-                    nels *= count[j];
-#line 596
-                    index[j] += start[j];
-#line 596
-                }
-#line 596
-                        /* Random choice of forward or backward */
-#line 596
-/* TODO
-#line 596
-                if ( roll(2) ) {
-#line 596
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 596
-                        index[j] += (count[j] - 1) * stride[j];
-#line 596
-                        stride[j] = -stride[j];
-#line 596
-                    }
-#line 596
-                }
-#line 596
-*/
-#line 596
-		allInExtRange = allInIntRange = 1;
-#line 596
-		for (j = 0; j < nels; j++) {
-#line 596
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 596
-		    IF (err)
-#line 596
-			error("error in toMixedBase 1");
-#line 596
-		    for (d = 0; d < var_rank[i]; d++)
-#line 596
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 596
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 596
-			NCT_LONG);
-#line 596
-		    if (inRange3(expect[j],var_type[i],NCT_LONG)) {
-#line 596
-			allInIntRange = allInIntRange && expect[j] >= long_min
-#line 596
-			    && expect[j] <= long_max;
-#line 596
-		    } else {
-#line 596
-			allInExtRange = 0;
-#line 596
-		    }
-#line 596
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_USHORT);
+		if (inRange3(expect[j],var_type[i], NCT_USHORT)) {
+		    allInIntRange = allInIntRange && expect[j] >= ushort_min
+				&& expect[j] <= ushort_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 596
-                if (var_rank[i] == 0 && i%2 )
-#line 596
-                    err = nc_get_vars_long(ncid, i, NULL, NULL, NULL, value);
-#line 596
-                else
-#line 596
-                    err = nc_get_vars_long(ncid, i, index, count, stride, value);
-#line 596
-		if (canConvert) {
-#line 596
-		    if (allInExtRange) {
-#line 596
-			if (allInIntRange) {
-#line 596
-			    IF (err)
-#line 596
-				error("%s", nc_strerror(err));
-#line 596
-			} else {
-#line 596
-			    IF (err != NC_ERANGE)
-#line 596
-				error("Range error: status = %d", err);
-#line 596
-			}
-#line 596
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_ushort(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_ushort(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 596
-			IF (err != 0 && err != NC_ERANGE)
-#line 596
-			    error("OK or Range error: status = %d", err);
-#line 596
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 596
-		    for (j = 0; j < nels; j++) {
-#line 596
-			if (inRange3(expect[j],var_type[i],NCT_LONG)
-#line 596
-				&& expect[j] >= long_min && expect[j] <= long_max) {
-#line 596
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_LONG)){
-#line 596
-				error("value read not that expected");
-#line 596
-				if (verbose) {
-#line 596
-				    error("\n");
-#line 596
-				    error("varid: %d, ", i);
-#line 596
-				    error("var_name: %s, ", var_name[i]);
-#line 596
-				    error("element number: %d ", j);
-#line 596
-                                    error("expect: %g, ", expect[j]);
-#line 596
-				    error("got: %g", (double) value[j]);
-#line 596
-				}
-#line 596
-			    } else {
-#line 596
-				nok++;
-#line 596
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_USHORT)
+			    && expect[j] >= ushort_min && expect[j] <= ushort_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 596
+			} else {
+			    nok++;
 			}
-#line 596
 		    }
-#line 596
-		} else {
-#line 596
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 596
-			error("wrong type: status = %d", err);
-#line 596
 		}
-#line 596
-	    }
-#line 596
-	}
-#line 596
-
-#line 596
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 596
     err = nc_close(ncid);
-#line 596
     IF (err)
-#line 596
-        error("nc_close: %s", nc_strerror(err));
-#line 596
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 596
 }
-#line 596
 
 void
-#line 597
-test_nc_get_vars_float(void)
-#line 597
+test_nc_get_vara_uint(void)
 {
-#line 597
     int ncid;
-#line 597
     int d;
-#line 597
     int i;
-#line 597
     int j;
-#line 597
     int k;
-#line 597
-    int m;
-#line 597
     int err;
-#line 597
     int allInExtRange;	/* all values within external range? */
-#line 597
     int allInIntRange;	/* all values within internal range? */
-#line 597
     int nels;
-#line 597
     int nslabs;
-#line 597
-    int nstarts;        /* number of different starts */
-#line 597
     int nok = 0;      /* count of valid comparisons */
-#line 597
     size_t start[MAX_RANK];
-#line 597
     size_t edge[MAX_RANK];
-#line 597
     size_t index[MAX_RANK];
-#line 597
-    size_t index2[MAX_RANK];
-#line 597
     size_t mid[MAX_RANK];
-#line 597
-    size_t count[MAX_RANK];
-#line 597
-    size_t sstride[MAX_RANK];
-#line 597
-    ptrdiff_t stride[MAX_RANK];
-#line 597
     int canConvert;     /* Both text or both numeric */
-#line 597
-    float value[MAX_NELS];
-#line 597
+    uint value[MAX_NELS];
     double expect[MAX_NELS];
-#line 597
 
-#line 597
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 597
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 597
-        error("nc_open: %s", nc_strerror(err));
-#line 597
-    for (i = 0; i < NVARS; i++) {
-#line 597
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 597
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 597
         assert(var_nels[i] <= MAX_NELS);
-#line 597
-        for (j = 0; j < var_rank[i]; j++) {
-#line 597
-            start[j] = 0;
-#line 597
-            edge[j] = 1;
-#line 597
-            stride[j] = 1;
-#line 597
-        }
-#line 597
-        err = nc_get_vars_float(BAD_ID, i, start, edge, stride, value);
-#line 597
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_uint(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 597
-            error("bad ncid: status = %d", err);
-#line 597
-        err = nc_get_vars_float(ncid, BAD_VARID, start, edge, stride, value);
-#line 597
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_uint(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 597
-            error("bad var id: status = %d", err);
-#line 597
-        for (j = 0; j < var_rank[i]; j++) {
-#line 597
-            start[j] = var_shape[i][j];
-#line 597
-            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
-#line 597
-	  if(!canConvert) {
-#line 597
-		IF (err != NC_ECHAR)
-#line 597
-               	    error("conversion: status = %d", err);
-#line 597
-	  } else {
-#line 597
-            IF (err != NC_EINVALCOORDS)
-#line 597
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_uint(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 597
-            start[j] = 0;
-#line 597
-            edge[j] = var_shape[i][j] + 1;
-#line 597
-            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
-#line 597
-            IF (err != NC_EEDGE)
-#line 597
-                error("bad edge: status = %d", err);
-#line 597
-            edge[j] = 1;
-#line 597
-            stride[j] = 0;
-#line 597
-            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
-#line 597
-            IF (err != NC_ESTRIDE)
-#line 597
-                error("bad stride: status = %d", err);
-#line 597
-            stride[j] = 1;
-#line 597
-	  }
-#line 597
-        }
-#line 597
-            /* Choose a random point dividing each dim into 2 parts */
-#line 597
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_uint(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_uint(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_uint(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_uint(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_uint(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 597
         nslabs = 1;
-#line 597
         for (j = 0; j < var_rank[i]; j++) {
-#line 597
             mid[j] = roll( var_shape[i][j] );
-#line 597
             nslabs *= 2;
-#line 597
         }
-#line 597
             /* bits of k determine whether to get lower or upper part of dim */
-#line 597
-            /* choose random stride from 1 to edge */
-#line 597
         for (k = 0; k < nslabs; k++) {
-#line 597
-            nstarts = 1;
-#line 597
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 597
                 if ((k >> j) & 1) {
-#line 597
                     start[j] = 0;
-#line 597
                     edge[j] = mid[j];
-#line 597
                 }else{
-#line 597
                     start[j] = mid[j];
-#line 597
                     edge[j] = var_shape[i][j] - mid[j];
-#line 597
                 }
-#line 597
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 597
-                nstarts *= stride[j];
-#line 597
+                nels *= edge[j];
             }
-#line 597
-            for (m = 0; m < nstarts; m++) {
-#line 597
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 597
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 597
-                    error("error in toMixedBase");
-#line 597
-                nels = 1;
-#line 597
-                for (j = 0; j < var_rank[i]; j++) {
-#line 597
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 597
-                    nels *= count[j];
-#line 597
-                    index[j] += start[j];
-#line 597
-                }
-#line 597
-                        /* Random choice of forward or backward */
-#line 597
-/* TODO
-#line 597
-                if ( roll(2) ) {
-#line 597
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 597
-                        index[j] += (count[j] - 1) * stride[j];
-#line 597
-                        stride[j] = -stride[j];
-#line 597
-                    }
-#line 597
-                }
-#line 597
-*/
-#line 597
-		allInExtRange = allInIntRange = 1;
-#line 597
-		for (j = 0; j < nels; j++) {
-#line 597
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 597
-		    IF (err)
-#line 597
-			error("error in toMixedBase 1");
-#line 597
-		    for (d = 0; d < var_rank[i]; d++)
-#line 597
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 597
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 597
-			NCT_FLOAT);
-#line 597
-		    if (inRange3(expect[j],var_type[i],NCT_FLOAT)) {
-#line 597
-			allInIntRange = allInIntRange && expect[j] >= float_min
-#line 597
-			    && expect[j] <= float_max;
-#line 597
-		    } else {
-#line 597
-			allInExtRange = 0;
-#line 597
-		    }
-#line 597
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UINT);
+		if (inRange3(expect[j],var_type[i], NCT_UINT)) {
+		    allInIntRange = allInIntRange && expect[j] >= uint_min
+				&& expect[j] <= uint_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 597
-                if (var_rank[i] == 0 && i%2 )
-#line 597
-                    err = nc_get_vars_float(ncid, i, NULL, NULL, NULL, value);
-#line 597
-                else
-#line 597
-                    err = nc_get_vars_float(ncid, i, index, count, stride, value);
-#line 597
-		if (canConvert) {
-#line 597
-		    if (allInExtRange) {
-#line 597
-			if (allInIntRange) {
-#line 597
-			    IF (err)
-#line 597
-				error("%s", nc_strerror(err));
-#line 597
-			} else {
-#line 597
-			    IF (err != NC_ERANGE)
-#line 597
-				error("Range error: status = %d", err);
-#line 597
-			}
-#line 597
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_uint(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_uint(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 597
-			IF (err != 0 && err != NC_ERANGE)
-#line 597
-			    error("OK or Range error: status = %d", err);
-#line 597
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 597
-		    for (j = 0; j < nels; j++) {
-#line 597
-			if (inRange3(expect[j],var_type[i],NCT_FLOAT)
-#line 597
-				&& expect[j] >= float_min && expect[j] <= float_max) {
-#line 597
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_FLOAT)){
-#line 597
-				error("value read not that expected");
-#line 597
-				if (verbose) {
-#line 597
-				    error("\n");
-#line 597
-				    error("varid: %d, ", i);
-#line 597
-				    error("var_name: %s, ", var_name[i]);
-#line 597
-				    error("element number: %d ", j);
-#line 597
-                                    error("expect: %g, ", expect[j]);
-#line 597
-				    error("got: %g", (double) value[j]);
-#line 597
-				}
-#line 597
-			    } else {
-#line 597
-				nok++;
-#line 597
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_UINT)
+			    && expect[j] >= uint_min && expect[j] <= uint_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 597
+			} else {
+			    nok++;
 			}
-#line 597
 		    }
-#line 597
-		} else {
-#line 597
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 597
-			error("wrong type: status = %d", err);
-#line 597
 		}
-#line 597
-	    }
-#line 597
-	}
-#line 597
-
-#line 597
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
     }
-#line 597
     err = nc_close(ncid);
-#line 597
     IF (err)
-#line 597
-        error("nc_close: %s", nc_strerror(err));
-#line 597
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 597
 }
-#line 597
 
 void
-#line 598
-test_nc_get_vars_double(void)
-#line 598
+test_nc_get_vara_longlong(void)
 {
-#line 598
     int ncid;
-#line 598
     int d;
-#line 598
     int i;
-#line 598
     int j;
-#line 598
     int k;
-#line 598
-    int m;
-#line 598
     int err;
-#line 598
     int allInExtRange;	/* all values within external range? */
-#line 598
     int allInIntRange;	/* all values within internal range? */
-#line 598
     int nels;
-#line 598
     int nslabs;
-#line 598
-    int nstarts;        /* number of different starts */
-#line 598
     int nok = 0;      /* count of valid comparisons */
-#line 598
     size_t start[MAX_RANK];
-#line 598
     size_t edge[MAX_RANK];
-#line 598
     size_t index[MAX_RANK];
-#line 598
-    size_t index2[MAX_RANK];
-#line 598
     size_t mid[MAX_RANK];
-#line 598
-    size_t count[MAX_RANK];
-#line 598
-    size_t sstride[MAX_RANK];
-#line 598
-    ptrdiff_t stride[MAX_RANK];
-#line 598
     int canConvert;     /* Both text or both numeric */
-#line 598
-    double value[MAX_NELS];
-#line 598
+    longlong value[MAX_NELS];
     double expect[MAX_NELS];
-#line 598
 
-#line 598
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 598
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 598
-        error("nc_open: %s", nc_strerror(err));
-#line 598
-    for (i = 0; i < NVARS; i++) {
-#line 598
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 598
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 598
         assert(var_nels[i] <= MAX_NELS);
-#line 598
-        for (j = 0; j < var_rank[i]; j++) {
-#line 598
-            start[j] = 0;
-#line 598
-            edge[j] = 1;
-#line 598
-            stride[j] = 1;
-#line 598
-        }
-#line 598
-        err = nc_get_vars_double(BAD_ID, i, start, edge, stride, value);
-#line 598
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_longlong(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 598
-            error("bad ncid: status = %d", err);
-#line 598
-        err = nc_get_vars_double(ncid, BAD_VARID, start, edge, stride, value);
-#line 598
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_longlong(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 598
-            error("bad var id: status = %d", err);
-#line 598
-        for (j = 0; j < var_rank[i]; j++) {
-#line 598
-            start[j] = var_shape[i][j];
-#line 598
-            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
-#line 598
-	  if(!canConvert) {
-#line 598
-		IF (err != NC_ECHAR)
-#line 598
-               	    error("conversion: status = %d", err);
-#line 598
-	  } else {
-#line 598
-            IF (err != NC_EINVALCOORDS)
-#line 598
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 598
-            start[j] = 0;
-#line 598
-            edge[j] = var_shape[i][j] + 1;
-#line 598
-            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
-#line 598
-            IF (err != NC_EEDGE)
-#line 598
-                error("bad edge: status = %d", err);
-#line 598
-            edge[j] = 1;
-#line 598
-            stride[j] = 0;
-#line 598
-            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
-#line 598
-            IF (err != NC_ESTRIDE)
-#line 598
-                error("bad stride: status = %d", err);
-#line 598
-            stride[j] = 1;
-#line 598
-	  }
-#line 598
-        }
-#line 598
-            /* Choose a random point dividing each dim into 2 parts */
-#line 598
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_longlong(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_longlong(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 598
         nslabs = 1;
-#line 598
         for (j = 0; j < var_rank[i]; j++) {
-#line 598
             mid[j] = roll( var_shape[i][j] );
-#line 598
             nslabs *= 2;
-#line 598
         }
-#line 598
             /* bits of k determine whether to get lower or upper part of dim */
-#line 598
-            /* choose random stride from 1 to edge */
-#line 598
         for (k = 0; k < nslabs; k++) {
-#line 598
-            nstarts = 1;
-#line 598
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 598
                 if ((k >> j) & 1) {
-#line 598
                     start[j] = 0;
-#line 598
                     edge[j] = mid[j];
-#line 598
                 }else{
-#line 598
                     start[j] = mid[j];
-#line 598
                     edge[j] = var_shape[i][j] - mid[j];
-#line 598
                 }
-#line 598
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 598
-                nstarts *= stride[j];
-#line 598
+                nels *= edge[j];
             }
-#line 598
-            for (m = 0; m < nstarts; m++) {
-#line 598
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 598
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 598
-                    error("error in toMixedBase");
-#line 598
-                nels = 1;
-#line 598
-                for (j = 0; j < var_rank[i]; j++) {
-#line 598
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 598
-                    nels *= count[j];
-#line 598
-                    index[j] += start[j];
-#line 598
-                }
-#line 598
-                        /* Random choice of forward or backward */
-#line 598
-/* TODO
-#line 598
-                if ( roll(2) ) {
-#line 598
-                    for (j = 0; j < var_rank[i]; j++) {
-#line 598
-                        index[j] += (count[j] - 1) * stride[j];
-#line 598
-                        stride[j] = -stride[j];
-#line 598
-                    }
-#line 598
-                }
-#line 598
-*/
-#line 598
-		allInExtRange = allInIntRange = 1;
-#line 598
-		for (j = 0; j < nels; j++) {
-#line 598
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 598
-		    IF (err)
-#line 598
-			error("error in toMixedBase 1");
-#line 598
-		    for (d = 0; d < var_rank[i]; d++)
-#line 598
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 598
-		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
-#line 598
-			NCT_DOUBLE);
-#line 598
-		    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) {
-#line 598
-			allInIntRange = allInIntRange && expect[j] >= double_min
-#line 598
-			    && expect[j] <= double_max;
-#line 598
-		    } else {
-#line 598
-			allInExtRange = 0;
-#line 598
-		    }
-#line 598
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONGLONG);
+		if (inRange3(expect[j],var_type[i], NCT_LONGLONG)) {
+		    allInIntRange = allInIntRange && expect[j] >= longlong_min
+				&& expect[j] <= longlong_max;
+		} else {
+		    allInExtRange = 0;
 		}
-#line 598
-                if (var_rank[i] == 0 && i%2 )
-#line 598
-                    err = nc_get_vars_double(ncid, i, NULL, NULL, NULL, value);
-#line 598
-                else
-#line 598
-                    err = nc_get_vars_double(ncid, i, index, count, stride, value);
-#line 598
-		if (canConvert) {
-#line 598
-		    if (allInExtRange) {
-#line 598
-			if (allInIntRange) {
-#line 598
-			    IF (err)
-#line 598
-				error("%s", nc_strerror(err));
-#line 598
-			} else {
-#line 598
-			    IF (err != NC_ERANGE)
-#line 598
-				error("Range error: status = %d", err);
-#line 598
-			}
-#line 598
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_longlong(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_longlong(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
 		    } else {
-#line 598
-			IF (err != 0 && err != NC_ERANGE)
-#line 598
-			    error("OK or Range error: status = %d", err);
-#line 598
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 598
-		    for (j = 0; j < nels; j++) {
-#line 598
-			if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
-#line 598
-				&& expect[j] >= double_min && expect[j] <= double_max) {
-#line 598
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_DOUBLE)){
-#line 598
-				error("value read not that expected");
-#line 598
-				if (verbose) {
-#line 598
-				    error("\n");
-#line 598
-				    error("varid: %d, ", i);
-#line 598
-				    error("var_name: %s, ", var_name[i]);
-#line 598
-				    error("element number: %d ", j);
-#line 598
-                                    error("expect: %g, ", expect[j]);
-#line 598
-				    error("got: %g", (double) value[j]);
-#line 598
-				}
-#line 598
-			    } else {
-#line 598
-				nok++;
-#line 598
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
+		}
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+			    && expect[j] >= longlong_min && expect[j] <= longlong_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
 			    }
-#line 598
+			} else {
+			    nok++;
 			}
-#line 598
 		    }
-#line 598
-		} else {
-#line 598
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 598
-			error("wrong type: status = %d", err);
-#line 598
 		}
-#line 598
-	    }
-#line 598
-	}
-#line 598
-
-#line 598
-    }
-#line 598
-    err = nc_close(ncid);
-#line 598
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
+            }
+        }
+    }
+    err = nc_close(ncid);
     IF (err)
-#line 598
-        error("nc_close: %s", nc_strerror(err));
-#line 598
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 598
 }
-#line 598
-
-
-
-#line 787
 
 void
-#line 788
-test_nc_get_varm_text(void)
-#line 788
+test_nc_get_vara_ulonglong(void)
 {
-#line 788
     int ncid;
-#line 788
     int d;
-#line 788
     int i;
-#line 788
     int j;
-#line 788
     int k;
-#line 788
-    int m;
-#line 788
     int err;
-#line 788
     int allInExtRange;	/* all values within external range? */
-#line 788
     int allInIntRange;	/* all values within internal range? */
-#line 788
     int nels;
-#line 788
     int nslabs;
-#line 788
-    int nstarts;        /* number of different starts */
-#line 788
     int nok = 0;      /* count of valid comparisons */
-#line 788
     size_t start[MAX_RANK];
-#line 788
     size_t edge[MAX_RANK];
-#line 788
     size_t index[MAX_RANK];
-#line 788
-    size_t index2[MAX_RANK];
-#line 788
     size_t mid[MAX_RANK];
-#line 788
-    size_t count[MAX_RANK];
-#line 788
-    size_t sstride[MAX_RANK];
-#line 788
-    ptrdiff_t stride[MAX_RANK];
-#line 788
-    ptrdiff_t imap[MAX_RANK];
-#line 788
     int canConvert;     /* Both text or both numeric */
-#line 788
-    text value[MAX_NELS];
-#line 788
+    ulonglong value[MAX_NELS];
     double expect[MAX_NELS];
-#line 788
 
-#line 788
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 788
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 788
-        error("nc_open: %s", nc_strerror(err));
-#line 788
-    for (i = 0; i < NVARS; i++) {
-#line 788
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 788
+	error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 788
         assert(var_nels[i] <= MAX_NELS);
-#line 788
-        for (j = 0; j < var_rank[i]; j++) {
-#line 788
-            start[j] = 0;
-#line 788
-            edge[j] = 1;
-#line 788
-            stride[j] = 1;
-#line 788
-            imap[j] = 1;
-#line 788
-        }
-#line 788
-        err = nc_get_varm_text(BAD_ID, i, start, edge, stride, imap, value);
-#line 788
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	}
+        err = nc_get_vara_ulonglong(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID)
-#line 788
-            error("bad ncid: status = %d", err);
-#line 788
-        err = nc_get_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 788
+	    error("bad ncid: status = %d", err);
+        err = nc_get_vara_ulonglong(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR)
-#line 788
-            error("bad var id: status = %d", err);
-#line 788
-        for (j = 0; j < var_rank[i]; j++) {
-#line 788
-            start[j] = var_shape[i][j];
-#line 788
-            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
-#line 788
-	  if(!canConvert) {
-#line 788
-		IF (err != NC_ECHAR)
-#line 788
-               	    error("conversion: status = %d", err);
-#line 788
-	  } else {
-#line 788
-	    IF (err != NC_EINVALCOORDS)
-#line 788
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = var_shape[i][j];
+	    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 788
-            start[j] = 0;
-#line 788
-            edge[j] = var_shape[i][j] + 1;
-#line 788
-            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
-#line 788
-            IF (err != NC_EEDGE)
-#line 788
-                error("bad edge: status = %d", err);
-#line 788
-            edge[j] = 1;
-#line 788
-            stride[j] = 0;
-#line 788
-            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
-#line 788
-            IF (err != NC_ESTRIDE)
-#line 788
-                error("bad stride: status = %d", err);
-#line 788
-            stride[j] = 1;
-#line 788
-           }
-#line 788
-        }
-#line 788
-            /* Choose a random point dividing each dim into 2 parts */
-#line 788
+	    start[j] = 0;
+	    edge[j] = var_shape[i][j] + 1;
+	    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+            IF (canConvert && err != NC_EEDGE)
+		error("bad edge: status = %d", err);
+	    edge[j] = 1;
+	}
+            /* Check non-scalars for correct error returned even when */
+            /* there is nothing to get (edge[j]==0) */
+	if(var_rank[i] > 0) {
+	    for (j = 0; j < var_rank[i]; j++) {
+		edge[j] = 0;
+	    }
+	    err = nc_get_vara_ulonglong(BAD_ID, i, start, edge, value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_vara_ulonglong(ncid, BAD_VARID, start, edge, value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    for (j = 0; j < var_rank[i]; j++) {
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+		    start[j] = var_shape[i][j];
+		    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+		    IF (canConvert && err != NC_EINVALCOORDS)
+			error("bad start: status = %d", err);
+		    start[j] = 0;
+		}
+	    }
+	    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+	    if (canConvert) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", 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 */
-#line 788
         nslabs = 1;
-#line 788
         for (j = 0; j < var_rank[i]; j++) {
-#line 788
             mid[j] = roll( var_shape[i][j] );
-#line 788
             nslabs *= 2;
-#line 788
         }
-#line 788
             /* bits of k determine whether to get lower or upper part of dim */
-#line 788
-            /* choose random stride from 1 to edge */
-#line 788
         for (k = 0; k < nslabs; k++) {
-#line 788
-            nstarts = 1;
-#line 788
+            nels = 1;
             for (j = 0; j < var_rank[i]; j++) {
-#line 788
                 if ((k >> j) & 1) {
-#line 788
                     start[j] = 0;
-#line 788
                     edge[j] = mid[j];
-#line 788
                 }else{
-#line 788
                     start[j] = mid[j];
-#line 788
                     edge[j] = var_shape[i][j] - mid[j];
-#line 788
                 }
-#line 788
-                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 788
-                nstarts *= stride[j];
-#line 788
+                nels *= edge[j];
             }
-#line 788
-            for (m = 0; m < nstarts; m++) {
-#line 788
-                err = toMixedBase(m, var_rank[i], sstride, index);
-#line 788
+	    allInExtRange = allInIntRange = 1;
+            for (j = 0; j < nels; j++) {
+                err = toMixedBase(j, var_rank[i], edge, index);
                 IF (err)
-#line 788
-                    error("error in toMixedBase");
-#line 788
-                nels = 1;
-#line 788
-                for (j = 0; j < var_rank[i]; j++) {
-#line 788
-                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 788
-                    nels *= count[j];
-#line 788
-                    index[j] += start[j];
-#line 788
-                }
-#line 788
-		    /* Random choice of forward or backward */
-#line 788
-/* TODO
-#line 788
-		if ( roll(2) ) {
-#line 788
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 788
-			index[j] += (count[j] - 1) * stride[j];
-#line 788
-			stride[j] = -stride[j];
-#line 788
+                    error("error in toMixedBase 1");
+                for (d = 0; d < var_rank[i]; d++)
+                    index[d] += start[d];
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_ULONGLONG);
+		if (inRange3(expect[j],var_type[i], NCT_ULONGLONG)) {
+		    allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+				&& expect[j] <= ulonglong_max;
+		} else {
+		    allInExtRange = 0;
+		}
+	    }
+            if (var_rank[i] == 0 && i%2)
+		err = nc_get_vara_ulonglong(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+            if (canConvert) {
+		if (allInExtRange) {
+		    if (allInIntRange) {
+			IF (err)
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("Range error: status = %d", err);
 		    }
-#line 788
+		} else {
+		    IF (err != 0 && err != NC_ERANGE)
+			error("OK or Range error: status = %d", err);
 		}
-#line 788
- */
-#line 788
-		if (var_rank[i] > 0) {
-#line 788
-		    j = var_rank[i] - 1;
-#line 788
-		    imap[j] = 1;
-#line 788
-		    for (; j > 0; j--)
-#line 788
-			imap[j-1] = imap[j] * count[j];
-#line 788
+		for (j = 0; j < nels; j++) {
+		    if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+			    && expect[j] >= ulonglong_min && expect[j] <= ulonglong_max) {
+			IF (!equal(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("element number: %d ", j);
+				error("expect: %g", expect[j]);
+				error("got: %g", (double) value[j]);
+			    }
+			} else {
+			    nok++;
+			}
+		    }
 		}
-#line 788
-                allInExtRange = allInIntRange = 1;
-#line 788
-                for (j = 0; j < nels; j++) {
-#line 788
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 788
-                    IF (err)
-#line 788
-                        error("error in toMixedBase 1");
-#line 788
-                    for (d = 0; d < var_rank[i]; d++)
-#line 788
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 788
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 788
-                        NCT_TEXT);
-#line 788
-                    if (inRange3(expect[j],var_type[i],NCT_TEXT)) {
-#line 788
-                        allInIntRange = allInIntRange && expect[j] >= text_min
-#line 788
-                            && expect[j] <= text_max;
-#line 788
-                    } else {
-#line 788
-                        allInExtRange = 0;
-#line 788
-                    }
-#line 788
-                }
-#line 788
-                if (var_rank[i] == 0 && i%2 )
-#line 788
-                    err = nc_get_varm_text(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 788
-                else
-#line 788
-                    err = nc_get_varm_text(ncid,i,index,count,stride,imap,value);
-#line 788
-                if (canConvert) {
-#line 788
-                    if (allInExtRange) {
-#line 788
-                        if (allInIntRange) {
-#line 788
-                            IF (err)
-#line 788
-                                error("%s", nc_strerror(err));
-#line 788
-                        } else {
-#line 788
-                            IF (err != NC_ERANGE)
-#line 788
-                                error("Range error: status = %d", err);
-#line 788
-                        }
-#line 788
-                    } else {
-#line 788
-                        IF (err != 0 && err != NC_ERANGE)
-#line 788
-                            error("OK or Range error: status = %d", err);
-#line 788
-                    }
-#line 788
-                    for (j = 0; j < nels; j++) {
-#line 788
-                        if (inRange3(expect[j],var_type[i],NCT_TEXT)
-#line 788
-                                && expect[j] >= text_min 
-#line 788
-				&& expect[j] <= text_max) {
-#line 788
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_TEXT)){
-#line 788
-                                error("value read not that expected");
-#line 788
-                                if (verbose) {
-#line 788
-                                    error("\n");
-#line 788
-                                    error("varid: %d, ", i);
-#line 788
-                                    error("var_name: %s, ", var_name[i]);
-#line 788
-                                    error("element number: %d ", j);
-#line 788
-                                    error("expect: %g, ", expect[j]);
-#line 788
-                                    error("got: %g", (double) value[j]);
-#line 788
-                                }
-#line 788
-                            } else {
-#line 788
-                                nok++;
-#line 788
-                            }
-#line 788
-                        }
-#line 788
-                    }
-#line 788
-                } else {
-#line 788
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 788
-                        error("wrong type: status = %d", err);
-#line 788
-                }
-#line 788
+            } else {
+                IF (nels > 0 && err != NC_ECHAR)
+                    error("wrong type: status = %d", err);
             }
-#line 788
         }
-#line 788
     }
-#line 788
     err = nc_close(ncid);
-#line 788
     IF (err)
-#line 788
-        error("nc_close: %s", nc_strerror(err));
-#line 788
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 788
 }
-#line 788
+
+
+
 
 void
-#line 789
-test_nc_get_varm_uchar(void)
-#line 789
+test_nc_get_vars_text(void)
 {
-#line 789
     int ncid;
-#line 789
     int d;
-#line 789
     int i;
-#line 789
     int j;
-#line 789
     int k;
-#line 789
     int m;
-#line 789
     int err;
-#line 789
     int allInExtRange;	/* all values within external range? */
-#line 789
     int allInIntRange;	/* all values within internal range? */
-#line 789
     int nels;
-#line 789
     int nslabs;
-#line 789
     int nstarts;        /* number of different starts */
-#line 789
     int nok = 0;      /* count of valid comparisons */
-#line 789
     size_t start[MAX_RANK];
-#line 789
     size_t edge[MAX_RANK];
-#line 789
     size_t index[MAX_RANK];
-#line 789
     size_t index2[MAX_RANK];
-#line 789
     size_t mid[MAX_RANK];
-#line 789
     size_t count[MAX_RANK];
-#line 789
     size_t sstride[MAX_RANK];
-#line 789
     ptrdiff_t stride[MAX_RANK];
-#line 789
-    ptrdiff_t imap[MAX_RANK];
-#line 789
     int canConvert;     /* Both text or both numeric */
-#line 789
-    uchar value[MAX_NELS];
-#line 789
+    text value[MAX_NELS];
     double expect[MAX_NELS];
-#line 789
 
-#line 789
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 789
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 789
         error("nc_open: %s", nc_strerror(err));
-#line 789
-    for (i = 0; i < NVARS; i++) {
-#line 789
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 789
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 789
         assert(var_nels[i] <= MAX_NELS);
-#line 789
         for (j = 0; j < var_rank[i]; j++) {
-#line 789
             start[j] = 0;
-#line 789
             edge[j] = 1;
-#line 789
             stride[j] = 1;
-#line 789
-            imap[j] = 1;
-#line 789
         }
-#line 789
-        err = nc_get_varm_uchar(BAD_ID, i, start, edge, stride, imap, value);
-#line 789
+        err = nc_get_vars_text(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 789
             error("bad ncid: status = %d", err);
-#line 789
-        err = nc_get_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 789
+        err = nc_get_vars_text(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 789
             error("bad var id: status = %d", err);
-#line 789
         for (j = 0; j < var_rank[i]; j++) {
-#line 789
             start[j] = var_shape[i][j];
-#line 789
-            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
-#line 789
+            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 789
 		IF (err != NC_ECHAR)
-#line 789
                	    error("conversion: status = %d", err);
-#line 789
 	  } else {
-#line 789
-	    IF (err != NC_EINVALCOORDS)
-#line 789
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 789
             start[j] = 0;
-#line 789
             edge[j] = var_shape[i][j] + 1;
-#line 789
-            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
-#line 789
+            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 789
                 error("bad edge: status = %d", err);
-#line 789
             edge[j] = 1;
-#line 789
             stride[j] = 0;
-#line 789
-            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
-#line 789
+            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 789
                 error("bad stride: status = %d", err);
-#line 789
             stride[j] = 1;
-#line 789
-           }
-#line 789
+	  }
         }
-#line 789
             /* Choose a random point dividing each dim into 2 parts */
-#line 789
             /* get 2^rank (nslabs) slabs so defined */
-#line 789
         nslabs = 1;
-#line 789
         for (j = 0; j < var_rank[i]; j++) {
-#line 789
             mid[j] = roll( var_shape[i][j] );
-#line 789
             nslabs *= 2;
-#line 789
         }
-#line 789
             /* bits of k determine whether to get lower or upper part of dim */
-#line 789
             /* choose random stride from 1 to edge */
-#line 789
         for (k = 0; k < nslabs; k++) {
-#line 789
             nstarts = 1;
-#line 789
             for (j = 0; j < var_rank[i]; j++) {
-#line 789
                 if ((k >> j) & 1) {
-#line 789
                     start[j] = 0;
-#line 789
                     edge[j] = mid[j];
-#line 789
                 }else{
-#line 789
                     start[j] = mid[j];
-#line 789
                     edge[j] = var_shape[i][j] - mid[j];
-#line 789
                 }
-#line 789
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 789
                 nstarts *= stride[j];
-#line 789
             }
-#line 789
             for (m = 0; m < nstarts; m++) {
-#line 789
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 789
                 IF (err)
-#line 789
                     error("error in toMixedBase");
-#line 789
                 nels = 1;
-#line 789
                 for (j = 0; j < var_rank[i]; j++) {
-#line 789
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 789
                     nels *= count[j];
-#line 789
                     index[j] += start[j];
-#line 789
                 }
-#line 789
-		    /* Random choice of forward or backward */
-#line 789
+                        /* Random choice of forward or backward */
 /* TODO
-#line 789
-		if ( roll(2) ) {
-#line 789
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 789
-			index[j] += (count[j] - 1) * stride[j];
-#line 789
-			stride[j] = -stride[j];
-#line 789
-		    }
-#line 789
-		}
-#line 789
- */
-#line 789
-		if (var_rank[i] > 0) {
-#line 789
-		    j = var_rank[i] - 1;
-#line 789
-		    imap[j] = 1;
-#line 789
-		    for (; j > 0; j--)
-#line 789
-			imap[j-1] = imap[j] * count[j];
-#line 789
-		}
-#line 789
-                allInExtRange = allInIntRange = 1;
-#line 789
-                for (j = 0; j < nels; j++) {
-#line 789
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 789
-                    IF (err)
-#line 789
-                        error("error in toMixedBase 1");
-#line 789
-                    for (d = 0; d < var_rank[i]; d++)
-#line 789
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 789
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 789
-                        NCT_UCHAR);
-#line 789
-                    if (inRange3(expect[j],var_type[i],NCT_UCHAR)) {
-#line 789
-                        allInIntRange = allInIntRange && expect[j] >= uchar_min
-#line 789
-                            && expect[j] <= uchar_max;
-#line 789
-                    } else {
-#line 789
-                        allInExtRange = 0;
-#line 789
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
                     }
-#line 789
                 }
-#line 789
+*/
+		allInExtRange = allInIntRange = 1;
+		for (j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_TEXT);
+		    if (inRange3(expect[j],var_type[i],NCT_TEXT)) {
+			allInIntRange = allInIntRange && expect[j] >= text_min
+			    && expect[j] <= text_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
                 if (var_rank[i] == 0 && i%2 )
-#line 789
-                    err = nc_get_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 789
+                    err = nc_get_vars_text(ncid, i, NULL, NULL, NULL, value);
                 else
-#line 789
-                    err = nc_get_varm_uchar(ncid,i,index,count,stride,imap,value);
-#line 789
-                if (canConvert) {
-#line 789
-                    if (allInExtRange) {
-#line 789
-                        if (allInIntRange) {
-#line 789
-                            IF (err)
-#line 789
-                                error("%s", nc_strerror(err));
-#line 789
-                        } else {
-#line 789
-                            IF (err != NC_ERANGE)
-#line 789
-                                error("Range error: status = %d", err);
-#line 789
-                        }
-#line 789
-                    } else {
-#line 789
-                        IF (err != 0 && err != NC_ERANGE)
-#line 789
-                            error("OK or Range error: status = %d", err);
-#line 789
-                    }
-#line 789
-                    for (j = 0; j < nels; j++) {
-#line 789
-                        if (inRange3(expect[j],var_type[i],NCT_UCHAR)
-#line 789
-                                && expect[j] >= uchar_min 
-#line 789
-				&& expect[j] <= uchar_max) {
-#line 789
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_UCHAR)){
-#line 789
-                                error("value read not that expected");
-#line 789
-                                if (verbose) {
-#line 789
-                                    error("\n");
-#line 789
-                                    error("varid: %d, ", i);
-#line 789
-                                    error("var_name: %s, ", var_name[i]);
-#line 789
-                                    error("element number: %d ", j);
-#line 789
+                    err = nc_get_vars_text(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_TEXT)
+				&& expect[j] >= text_min && expect[j] <= text_max) {
+			    IF (!equal(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("element number: %d ", j);
                                     error("expect: %g, ", expect[j]);
-#line 789
-                                    error("got: %g", (double) value[j]);
-#line 789
-                                }
-#line 789
-                            } else {
-#line 789
-                                nok++;
-#line 789
-                            }
-#line 789
-                        }
-#line 789
-                    }
-#line 789
-                } else {
-#line 789
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 789
-                        error("wrong type: status = %d", err);
-#line 789
-                }
-#line 789
-            }
-#line 789
-        }
-#line 789
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
     }
-#line 789
     err = nc_close(ncid);
-#line 789
     IF (err)
-#line 789
         error("nc_close: %s", nc_strerror(err));
-#line 789
     print_nok(nok);
-#line 789
 }
-#line 789
 
 void
-#line 790
-test_nc_get_varm_schar(void)
-#line 790
+test_nc_get_vars_uchar(void)
 {
-#line 790
     int ncid;
-#line 790
     int d;
-#line 790
     int i;
-#line 790
     int j;
-#line 790
     int k;
-#line 790
     int m;
-#line 790
     int err;
-#line 790
     int allInExtRange;	/* all values within external range? */
-#line 790
     int allInIntRange;	/* all values within internal range? */
-#line 790
     int nels;
-#line 790
     int nslabs;
-#line 790
     int nstarts;        /* number of different starts */
-#line 790
     int nok = 0;      /* count of valid comparisons */
-#line 790
     size_t start[MAX_RANK];
-#line 790
     size_t edge[MAX_RANK];
-#line 790
     size_t index[MAX_RANK];
-#line 790
     size_t index2[MAX_RANK];
-#line 790
     size_t mid[MAX_RANK];
-#line 790
     size_t count[MAX_RANK];
-#line 790
     size_t sstride[MAX_RANK];
-#line 790
     ptrdiff_t stride[MAX_RANK];
-#line 790
-    ptrdiff_t imap[MAX_RANK];
-#line 790
     int canConvert;     /* Both text or both numeric */
-#line 790
-    schar value[MAX_NELS];
-#line 790
+    uchar value[MAX_NELS];
     double expect[MAX_NELS];
-#line 790
 
-#line 790
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 790
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 790
         error("nc_open: %s", nc_strerror(err));
-#line 790
-    for (i = 0; i < NVARS; i++) {
-#line 790
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 790
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 790
         assert(var_nels[i] <= MAX_NELS);
-#line 790
         for (j = 0; j < var_rank[i]; j++) {
-#line 790
             start[j] = 0;
-#line 790
             edge[j] = 1;
-#line 790
             stride[j] = 1;
-#line 790
-            imap[j] = 1;
-#line 790
         }
-#line 790
-        err = nc_get_varm_schar(BAD_ID, i, start, edge, stride, imap, value);
-#line 790
+        err = nc_get_vars_uchar(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 790
             error("bad ncid: status = %d", err);
-#line 790
-        err = nc_get_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 790
+        err = nc_get_vars_uchar(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 790
             error("bad var id: status = %d", err);
-#line 790
         for (j = 0; j < var_rank[i]; j++) {
-#line 790
             start[j] = var_shape[i][j];
-#line 790
-            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
-#line 790
+            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 790
 		IF (err != NC_ECHAR)
-#line 790
                	    error("conversion: status = %d", err);
-#line 790
 	  } else {
-#line 790
-	    IF (err != NC_EINVALCOORDS)
-#line 790
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 790
             start[j] = 0;
-#line 790
             edge[j] = var_shape[i][j] + 1;
-#line 790
-            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
-#line 790
+            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 790
                 error("bad edge: status = %d", err);
-#line 790
             edge[j] = 1;
-#line 790
             stride[j] = 0;
-#line 790
-            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
-#line 790
+            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 790
                 error("bad stride: status = %d", err);
-#line 790
             stride[j] = 1;
-#line 790
-           }
-#line 790
+	  }
         }
-#line 790
             /* Choose a random point dividing each dim into 2 parts */
-#line 790
             /* get 2^rank (nslabs) slabs so defined */
-#line 790
         nslabs = 1;
-#line 790
         for (j = 0; j < var_rank[i]; j++) {
-#line 790
             mid[j] = roll( var_shape[i][j] );
-#line 790
             nslabs *= 2;
-#line 790
         }
-#line 790
             /* bits of k determine whether to get lower or upper part of dim */
-#line 790
             /* choose random stride from 1 to edge */
-#line 790
         for (k = 0; k < nslabs; k++) {
-#line 790
             nstarts = 1;
-#line 790
             for (j = 0; j < var_rank[i]; j++) {
-#line 790
                 if ((k >> j) & 1) {
-#line 790
                     start[j] = 0;
-#line 790
                     edge[j] = mid[j];
-#line 790
                 }else{
-#line 790
                     start[j] = mid[j];
-#line 790
                     edge[j] = var_shape[i][j] - mid[j];
-#line 790
                 }
-#line 790
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 790
                 nstarts *= stride[j];
-#line 790
             }
-#line 790
             for (m = 0; m < nstarts; m++) {
-#line 790
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 790
                 IF (err)
-#line 790
                     error("error in toMixedBase");
-#line 790
                 nels = 1;
-#line 790
                 for (j = 0; j < var_rank[i]; j++) {
-#line 790
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 790
                     nels *= count[j];
-#line 790
                     index[j] += start[j];
-#line 790
                 }
-#line 790
-		    /* Random choice of forward or backward */
-#line 790
+                        /* Random choice of forward or backward */
 /* TODO
-#line 790
-		if ( roll(2) ) {
-#line 790
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 790
-			index[j] += (count[j] - 1) * stride[j];
-#line 790
-			stride[j] = -stride[j];
-#line 790
-		    }
-#line 790
-		}
-#line 790
- */
-#line 790
-		if (var_rank[i] > 0) {
-#line 790
-		    j = var_rank[i] - 1;
-#line 790
-		    imap[j] = 1;
-#line 790
-		    for (; j > 0; j--)
-#line 790
-			imap[j-1] = imap[j] * count[j];
-#line 790
-		}
-#line 790
-                allInExtRange = allInIntRange = 1;
-#line 790
-                for (j = 0; j < nels; j++) {
-#line 790
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 790
-                    IF (err)
-#line 790
-                        error("error in toMixedBase 1");
-#line 790
-                    for (d = 0; d < var_rank[i]; d++)
-#line 790
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 790
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 790
-                        NCT_SCHAR);
-#line 790
-                    if (inRange3(expect[j],var_type[i],NCT_SCHAR)) {
-#line 790
-                        allInIntRange = allInIntRange && expect[j] >= schar_min
-#line 790
-                            && expect[j] <= schar_max;
-#line 790
-                    } else {
-#line 790
-                        allInExtRange = 0;
-#line 790
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
                     }
-#line 790
                 }
-#line 790
+*/
+		allInExtRange = allInIntRange = 1;
+		for (j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_UCHAR);
+		    if (inRange3(expect[j],var_type[i],NCT_UCHAR)) {
+			allInIntRange = allInIntRange && expect[j] >= uchar_min
+			    && expect[j] <= uchar_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
                 if (var_rank[i] == 0 && i%2 )
-#line 790
-                    err = nc_get_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 790
+                    err = nc_get_vars_uchar(ncid, i, NULL, NULL, NULL, value);
                 else
-#line 790
-                    err = nc_get_varm_schar(ncid,i,index,count,stride,imap,value);
-#line 790
-                if (canConvert) {
-#line 790
-                    if (allInExtRange) {
-#line 790
-                        if (allInIntRange) {
-#line 790
-                            IF (err)
-#line 790
-                                error("%s", nc_strerror(err));
-#line 790
-                        } else {
-#line 790
-                            IF (err != NC_ERANGE)
-#line 790
-                                error("Range error: status = %d", err);
-#line 790
-                        }
-#line 790
-                    } else {
-#line 790
-                        IF (err != 0 && err != NC_ERANGE)
-#line 790
-                            error("OK or Range error: status = %d", err);
-#line 790
-                    }
-#line 790
-                    for (j = 0; j < nels; j++) {
-#line 790
-                        if (inRange3(expect[j],var_type[i],NCT_SCHAR)
-#line 790
-                                && expect[j] >= schar_min 
-#line 790
-				&& expect[j] <= schar_max) {
-#line 790
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_SCHAR)){
-#line 790
-                                error("value read not that expected");
-#line 790
-                                if (verbose) {
-#line 790
-                                    error("\n");
-#line 790
-                                    error("varid: %d, ", i);
-#line 790
-                                    error("var_name: %s, ", var_name[i]);
-#line 790
-                                    error("element number: %d ", j);
-#line 790
+                    err = nc_get_vars_uchar(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+				&& expect[j] >= uchar_min && expect[j] <= uchar_max) {
+			    IF (!equal(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("element number: %d ", j);
                                     error("expect: %g, ", expect[j]);
-#line 790
-                                    error("got: %g", (double) value[j]);
-#line 790
-                                }
-#line 790
-                            } else {
-#line 790
-                                nok++;
-#line 790
-                            }
-#line 790
-                        }
-#line 790
-                    }
-#line 790
-                } else {
-#line 790
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 790
-                        error("wrong type: status = %d", err);
-#line 790
-                }
-#line 790
-            }
-#line 790
-        }
-#line 790
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
     }
-#line 790
     err = nc_close(ncid);
-#line 790
     IF (err)
-#line 790
         error("nc_close: %s", nc_strerror(err));
-#line 790
     print_nok(nok);
-#line 790
 }
-#line 790
 
 void
-#line 791
-test_nc_get_varm_short(void)
-#line 791
+test_nc_get_vars_schar(void)
 {
-#line 791
     int ncid;
-#line 791
     int d;
-#line 791
     int i;
-#line 791
     int j;
-#line 791
     int k;
-#line 791
     int m;
-#line 791
     int err;
-#line 791
     int allInExtRange;	/* all values within external range? */
-#line 791
     int allInIntRange;	/* all values within internal range? */
-#line 791
     int nels;
-#line 791
     int nslabs;
-#line 791
     int nstarts;        /* number of different starts */
-#line 791
     int nok = 0;      /* count of valid comparisons */
-#line 791
     size_t start[MAX_RANK];
-#line 791
     size_t edge[MAX_RANK];
-#line 791
     size_t index[MAX_RANK];
-#line 791
     size_t index2[MAX_RANK];
-#line 791
     size_t mid[MAX_RANK];
-#line 791
     size_t count[MAX_RANK];
-#line 791
     size_t sstride[MAX_RANK];
-#line 791
     ptrdiff_t stride[MAX_RANK];
-#line 791
-    ptrdiff_t imap[MAX_RANK];
-#line 791
     int canConvert;     /* Both text or both numeric */
-#line 791
-    short value[MAX_NELS];
-#line 791
+    schar value[MAX_NELS];
     double expect[MAX_NELS];
-#line 791
 
-#line 791
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 791
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 791
         error("nc_open: %s", nc_strerror(err));
-#line 791
-    for (i = 0; i < NVARS; i++) {
-#line 791
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 791
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 791
         assert(var_nels[i] <= MAX_NELS);
-#line 791
         for (j = 0; j < var_rank[i]; j++) {
-#line 791
             start[j] = 0;
-#line 791
             edge[j] = 1;
-#line 791
             stride[j] = 1;
-#line 791
-            imap[j] = 1;
-#line 791
         }
-#line 791
-        err = nc_get_varm_short(BAD_ID, i, start, edge, stride, imap, value);
-#line 791
+        err = nc_get_vars_schar(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 791
             error("bad ncid: status = %d", err);
-#line 791
-        err = nc_get_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 791
+        err = nc_get_vars_schar(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 791
             error("bad var id: status = %d", err);
-#line 791
         for (j = 0; j < var_rank[i]; j++) {
-#line 791
             start[j] = var_shape[i][j];
-#line 791
-            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
-#line 791
+            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 791
 		IF (err != NC_ECHAR)
-#line 791
                	    error("conversion: status = %d", err);
-#line 791
 	  } else {
-#line 791
-	    IF (err != NC_EINVALCOORDS)
-#line 791
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 791
             start[j] = 0;
-#line 791
             edge[j] = var_shape[i][j] + 1;
-#line 791
-            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
-#line 791
+            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 791
                 error("bad edge: status = %d", err);
-#line 791
             edge[j] = 1;
-#line 791
             stride[j] = 0;
-#line 791
-            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
-#line 791
+            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 791
                 error("bad stride: status = %d", err);
-#line 791
             stride[j] = 1;
-#line 791
-           }
-#line 791
+	  }
         }
-#line 791
             /* Choose a random point dividing each dim into 2 parts */
-#line 791
             /* get 2^rank (nslabs) slabs so defined */
-#line 791
         nslabs = 1;
-#line 791
         for (j = 0; j < var_rank[i]; j++) {
-#line 791
             mid[j] = roll( var_shape[i][j] );
-#line 791
             nslabs *= 2;
-#line 791
         }
-#line 791
             /* bits of k determine whether to get lower or upper part of dim */
-#line 791
             /* choose random stride from 1 to edge */
-#line 791
         for (k = 0; k < nslabs; k++) {
-#line 791
             nstarts = 1;
-#line 791
             for (j = 0; j < var_rank[i]; j++) {
-#line 791
                 if ((k >> j) & 1) {
-#line 791
                     start[j] = 0;
-#line 791
                     edge[j] = mid[j];
-#line 791
                 }else{
-#line 791
                     start[j] = mid[j];
-#line 791
                     edge[j] = var_shape[i][j] - mid[j];
-#line 791
                 }
-#line 791
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 791
                 nstarts *= stride[j];
-#line 791
             }
-#line 791
             for (m = 0; m < nstarts; m++) {
-#line 791
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 791
                 IF (err)
-#line 791
                     error("error in toMixedBase");
-#line 791
                 nels = 1;
-#line 791
                 for (j = 0; j < var_rank[i]; j++) {
-#line 791
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 791
                     nels *= count[j];
-#line 791
                     index[j] += start[j];
-#line 791
                 }
-#line 791
-		    /* Random choice of forward or backward */
-#line 791
+                        /* Random choice of forward or backward */
 /* TODO
-#line 791
-		if ( roll(2) ) {
-#line 791
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 791
-			index[j] += (count[j] - 1) * stride[j];
-#line 791
-			stride[j] = -stride[j];
-#line 791
-		    }
-#line 791
-		}
-#line 791
- */
-#line 791
-		if (var_rank[i] > 0) {
-#line 791
-		    j = var_rank[i] - 1;
-#line 791
-		    imap[j] = 1;
-#line 791
-		    for (; j > 0; j--)
-#line 791
-			imap[j-1] = imap[j] * count[j];
-#line 791
-		}
-#line 791
-                allInExtRange = allInIntRange = 1;
-#line 791
-                for (j = 0; j < nels; j++) {
-#line 791
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 791
-                    IF (err)
-#line 791
-                        error("error in toMixedBase 1");
-#line 791
-                    for (d = 0; d < var_rank[i]; d++)
-#line 791
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 791
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 791
-                        NCT_SHORT);
-#line 791
-                    if (inRange3(expect[j],var_type[i],NCT_SHORT)) {
-#line 791
-                        allInIntRange = allInIntRange && expect[j] >= short_min
-#line 791
-                            && expect[j] <= short_max;
-#line 791
-                    } else {
-#line 791
-                        allInExtRange = 0;
-#line 791
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
                     }
-#line 791
                 }
-#line 791
+*/
+		allInExtRange = allInIntRange = 1;
+		for (j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_SCHAR);
+		    if (inRange3(expect[j],var_type[i],NCT_SCHAR)) {
+			allInIntRange = allInIntRange && expect[j] >= schar_min
+			    && expect[j] <= schar_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
                 if (var_rank[i] == 0 && i%2 )
-#line 791
-                    err = nc_get_varm_short(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 791
+                    err = nc_get_vars_schar(ncid, i, NULL, NULL, NULL, value);
                 else
-#line 791
-                    err = nc_get_varm_short(ncid,i,index,count,stride,imap,value);
-#line 791
-                if (canConvert) {
-#line 791
-                    if (allInExtRange) {
-#line 791
-                        if (allInIntRange) {
-#line 791
-                            IF (err)
-#line 791
-                                error("%s", nc_strerror(err));
-#line 791
-                        } else {
-#line 791
-                            IF (err != NC_ERANGE)
-#line 791
-                                error("Range error: status = %d", err);
-#line 791
-                        }
-#line 791
-                    } else {
-#line 791
-                        IF (err != 0 && err != NC_ERANGE)
-#line 791
-                            error("OK or Range error: status = %d", err);
-#line 791
-                    }
-#line 791
-                    for (j = 0; j < nels; j++) {
-#line 791
-                        if (inRange3(expect[j],var_type[i],NCT_SHORT)
-#line 791
-                                && expect[j] >= short_min 
-#line 791
-				&& expect[j] <= short_max) {
-#line 791
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_SHORT)){
-#line 791
-                                error("value read not that expected");
-#line 791
-                                if (verbose) {
-#line 791
-                                    error("\n");
-#line 791
-                                    error("varid: %d, ", i);
-#line 791
-                                    error("var_name: %s, ", var_name[i]);
-#line 791
-                                    error("element number: %d ", j);
-#line 791
+                    err = nc_get_vars_schar(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+				&& expect[j] >= schar_min && expect[j] <= schar_max) {
+			    IF (!equal(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("element number: %d ", j);
                                     error("expect: %g, ", expect[j]);
-#line 791
-                                    error("got: %g", (double) value[j]);
-#line 791
-                                }
-#line 791
-                            } else {
-#line 791
-                                nok++;
-#line 791
-                            }
-#line 791
-                        }
-#line 791
-                    }
-#line 791
-                } else {
-#line 791
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 791
-                        error("wrong type: status = %d", err);
-#line 791
-                }
-#line 791
-            }
-#line 791
-        }
-#line 791
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
     }
-#line 791
     err = nc_close(ncid);
-#line 791
     IF (err)
-#line 791
         error("nc_close: %s", nc_strerror(err));
-#line 791
     print_nok(nok);
-#line 791
 }
-#line 791
 
 void
-#line 792
-test_nc_get_varm_int(void)
-#line 792
+test_nc_get_vars_short(void)
 {
-#line 792
     int ncid;
-#line 792
     int d;
-#line 792
     int i;
-#line 792
     int j;
-#line 792
     int k;
-#line 792
     int m;
-#line 792
     int err;
-#line 792
     int allInExtRange;	/* all values within external range? */
-#line 792
     int allInIntRange;	/* all values within internal range? */
-#line 792
     int nels;
-#line 792
     int nslabs;
-#line 792
     int nstarts;        /* number of different starts */
-#line 792
     int nok = 0;      /* count of valid comparisons */
-#line 792
     size_t start[MAX_RANK];
-#line 792
     size_t edge[MAX_RANK];
-#line 792
     size_t index[MAX_RANK];
-#line 792
     size_t index2[MAX_RANK];
-#line 792
     size_t mid[MAX_RANK];
-#line 792
     size_t count[MAX_RANK];
-#line 792
     size_t sstride[MAX_RANK];
-#line 792
     ptrdiff_t stride[MAX_RANK];
-#line 792
-    ptrdiff_t imap[MAX_RANK];
-#line 792
     int canConvert;     /* Both text or both numeric */
-#line 792
-    int value[MAX_NELS];
-#line 792
+    short value[MAX_NELS];
     double expect[MAX_NELS];
-#line 792
 
-#line 792
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 792
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 792
         error("nc_open: %s", nc_strerror(err));
-#line 792
-    for (i = 0; i < NVARS; i++) {
-#line 792
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 792
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 792
         assert(var_nels[i] <= MAX_NELS);
-#line 792
         for (j = 0; j < var_rank[i]; j++) {
-#line 792
             start[j] = 0;
-#line 792
             edge[j] = 1;
-#line 792
             stride[j] = 1;
-#line 792
-            imap[j] = 1;
-#line 792
         }
-#line 792
-        err = nc_get_varm_int(BAD_ID, i, start, edge, stride, imap, value);
-#line 792
+        err = nc_get_vars_short(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 792
             error("bad ncid: status = %d", err);
-#line 792
-        err = nc_get_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 792
+        err = nc_get_vars_short(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 792
             error("bad var id: status = %d", err);
-#line 792
         for (j = 0; j < var_rank[i]; j++) {
-#line 792
             start[j] = var_shape[i][j];
-#line 792
-            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
-#line 792
+            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 792
 		IF (err != NC_ECHAR)
-#line 792
                	    error("conversion: status = %d", err);
-#line 792
 	  } else {
-#line 792
-	    IF (err != NC_EINVALCOORDS)
-#line 792
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 792
             start[j] = 0;
-#line 792
             edge[j] = var_shape[i][j] + 1;
-#line 792
-            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
-#line 792
+            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 792
                 error("bad edge: status = %d", err);
-#line 792
             edge[j] = 1;
-#line 792
             stride[j] = 0;
-#line 792
-            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
-#line 792
+            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 792
                 error("bad stride: status = %d", err);
-#line 792
             stride[j] = 1;
-#line 792
-           }
-#line 792
+	  }
         }
-#line 792
             /* Choose a random point dividing each dim into 2 parts */
-#line 792
             /* get 2^rank (nslabs) slabs so defined */
-#line 792
         nslabs = 1;
-#line 792
         for (j = 0; j < var_rank[i]; j++) {
-#line 792
             mid[j] = roll( var_shape[i][j] );
-#line 792
             nslabs *= 2;
-#line 792
         }
-#line 792
             /* bits of k determine whether to get lower or upper part of dim */
-#line 792
             /* choose random stride from 1 to edge */
-#line 792
         for (k = 0; k < nslabs; k++) {
-#line 792
             nstarts = 1;
-#line 792
             for (j = 0; j < var_rank[i]; j++) {
-#line 792
                 if ((k >> j) & 1) {
-#line 792
                     start[j] = 0;
-#line 792
                     edge[j] = mid[j];
-#line 792
                 }else{
-#line 792
                     start[j] = mid[j];
-#line 792
                     edge[j] = var_shape[i][j] - mid[j];
-#line 792
                 }
-#line 792
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 792
                 nstarts *= stride[j];
-#line 792
             }
-#line 792
             for (m = 0; m < nstarts; m++) {
-#line 792
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 792
                 IF (err)
-#line 792
                     error("error in toMixedBase");
-#line 792
                 nels = 1;
-#line 792
                 for (j = 0; j < var_rank[i]; j++) {
-#line 792
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 792
                     nels *= count[j];
-#line 792
                     index[j] += start[j];
-#line 792
                 }
-#line 792
-		    /* Random choice of forward or backward */
-#line 792
+                        /* Random choice of forward or backward */
 /* TODO
-#line 792
-		if ( roll(2) ) {
-#line 792
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 792
-			index[j] += (count[j] - 1) * stride[j];
-#line 792
-			stride[j] = -stride[j];
-#line 792
-		    }
-#line 792
-		}
-#line 792
- */
-#line 792
-		if (var_rank[i] > 0) {
-#line 792
-		    j = var_rank[i] - 1;
-#line 792
-		    imap[j] = 1;
-#line 792
-		    for (; j > 0; j--)
-#line 792
-			imap[j-1] = imap[j] * count[j];
-#line 792
-		}
-#line 792
-                allInExtRange = allInIntRange = 1;
-#line 792
-                for (j = 0; j < nels; j++) {
-#line 792
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 792
-                    IF (err)
-#line 792
-                        error("error in toMixedBase 1");
-#line 792
-                    for (d = 0; d < var_rank[i]; d++)
-#line 792
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 792
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 792
-                        NCT_INT);
-#line 792
-                    if (inRange3(expect[j],var_type[i],NCT_INT)) {
-#line 792
-                        allInIntRange = allInIntRange && expect[j] >= int_min
-#line 792
-                            && expect[j] <= int_max;
-#line 792
-                    } else {
-#line 792
-                        allInExtRange = 0;
-#line 792
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
                     }
-#line 792
                 }
-#line 792
+*/
+		allInExtRange = allInIntRange = 1;
+		for (j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_SHORT);
+		    if (inRange3(expect[j],var_type[i],NCT_SHORT)) {
+			allInIntRange = allInIntRange && expect[j] >= short_min
+			    && expect[j] <= short_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
                 if (var_rank[i] == 0 && i%2 )
-#line 792
-                    err = nc_get_varm_int(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 792
+                    err = nc_get_vars_short(ncid, i, NULL, NULL, NULL, value);
                 else
-#line 792
-                    err = nc_get_varm_int(ncid,i,index,count,stride,imap,value);
-#line 792
-                if (canConvert) {
-#line 792
-                    if (allInExtRange) {
-#line 792
-                        if (allInIntRange) {
-#line 792
-                            IF (err)
-#line 792
-                                error("%s", nc_strerror(err));
-#line 792
-                        } else {
-#line 792
-                            IF (err != NC_ERANGE)
-#line 792
-                                error("Range error: status = %d", err);
-#line 792
-                        }
-#line 792
-                    } else {
-#line 792
-                        IF (err != 0 && err != NC_ERANGE)
-#line 792
-                            error("OK or Range error: status = %d", err);
-#line 792
-                    }
-#line 792
-                    for (j = 0; j < nels; j++) {
-#line 792
-                        if (inRange3(expect[j],var_type[i],NCT_INT)
-#line 792
-                                && expect[j] >= int_min 
-#line 792
-				&& expect[j] <= int_max) {
-#line 792
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_INT)){
-#line 792
-                                error("value read not that expected");
-#line 792
-                                if (verbose) {
-#line 792
-                                    error("\n");
-#line 792
-                                    error("varid: %d, ", i);
-#line 792
-                                    error("var_name: %s, ", var_name[i]);
-#line 792
-                                    error("element number: %d ", j);
-#line 792
+                    err = nc_get_vars_short(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_SHORT)
+				&& expect[j] >= short_min && expect[j] <= short_max) {
+			    IF (!equal(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("element number: %d ", j);
                                     error("expect: %g, ", expect[j]);
-#line 792
-                                    error("got: %g", (double) value[j]);
-#line 792
-                                }
-#line 792
-                            } else {
-#line 792
-                                nok++;
-#line 792
-                            }
-#line 792
-                        }
-#line 792
-                    }
-#line 792
-                } else {
-#line 792
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 792
-                        error("wrong type: status = %d", err);
-#line 792
-                }
-#line 792
-            }
-#line 792
-        }
-#line 792
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
     }
-#line 792
     err = nc_close(ncid);
-#line 792
     IF (err)
-#line 792
         error("nc_close: %s", nc_strerror(err));
-#line 792
     print_nok(nok);
-#line 792
 }
-#line 792
 
 void
-#line 793
-test_nc_get_varm_long(void)
-#line 793
+test_nc_get_vars_int(void)
 {
-#line 793
     int ncid;
-#line 793
     int d;
-#line 793
     int i;
-#line 793
     int j;
-#line 793
     int k;
-#line 793
     int m;
-#line 793
     int err;
-#line 793
     int allInExtRange;	/* all values within external range? */
-#line 793
     int allInIntRange;	/* all values within internal range? */
-#line 793
     int nels;
-#line 793
     int nslabs;
-#line 793
     int nstarts;        /* number of different starts */
-#line 793
     int nok = 0;      /* count of valid comparisons */
-#line 793
     size_t start[MAX_RANK];
-#line 793
     size_t edge[MAX_RANK];
-#line 793
     size_t index[MAX_RANK];
-#line 793
     size_t index2[MAX_RANK];
-#line 793
     size_t mid[MAX_RANK];
-#line 793
     size_t count[MAX_RANK];
-#line 793
     size_t sstride[MAX_RANK];
-#line 793
     ptrdiff_t stride[MAX_RANK];
-#line 793
-    ptrdiff_t imap[MAX_RANK];
-#line 793
     int canConvert;     /* Both text or both numeric */
-#line 793
-    long value[MAX_NELS];
-#line 793
+    int value[MAX_NELS];
     double expect[MAX_NELS];
-#line 793
 
-#line 793
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 793
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 793
         error("nc_open: %s", nc_strerror(err));
-#line 793
-    for (i = 0; i < NVARS; i++) {
-#line 793
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 793
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 793
         assert(var_nels[i] <= MAX_NELS);
-#line 793
         for (j = 0; j < var_rank[i]; j++) {
-#line 793
             start[j] = 0;
-#line 793
             edge[j] = 1;
-#line 793
             stride[j] = 1;
-#line 793
-            imap[j] = 1;
-#line 793
         }
-#line 793
-        err = nc_get_varm_long(BAD_ID, i, start, edge, stride, imap, value);
-#line 793
+        err = nc_get_vars_int(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 793
             error("bad ncid: status = %d", err);
-#line 793
-        err = nc_get_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 793
+        err = nc_get_vars_int(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 793
             error("bad var id: status = %d", err);
-#line 793
         for (j = 0; j < var_rank[i]; j++) {
-#line 793
             start[j] = var_shape[i][j];
-#line 793
-            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
-#line 793
+            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 793
 		IF (err != NC_ECHAR)
-#line 793
                	    error("conversion: status = %d", err);
-#line 793
 	  } else {
-#line 793
-	    IF (err != NC_EINVALCOORDS)
-#line 793
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 793
             start[j] = 0;
-#line 793
             edge[j] = var_shape[i][j] + 1;
-#line 793
-            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
-#line 793
+            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 793
                 error("bad edge: status = %d", err);
-#line 793
             edge[j] = 1;
-#line 793
             stride[j] = 0;
-#line 793
-            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
-#line 793
+            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 793
                 error("bad stride: status = %d", err);
-#line 793
             stride[j] = 1;
-#line 793
-           }
-#line 793
+	  }
         }
-#line 793
             /* Choose a random point dividing each dim into 2 parts */
-#line 793
             /* get 2^rank (nslabs) slabs so defined */
-#line 793
         nslabs = 1;
-#line 793
         for (j = 0; j < var_rank[i]; j++) {
-#line 793
             mid[j] = roll( var_shape[i][j] );
-#line 793
             nslabs *= 2;
-#line 793
         }
-#line 793
             /* bits of k determine whether to get lower or upper part of dim */
-#line 793
             /* choose random stride from 1 to edge */
-#line 793
         for (k = 0; k < nslabs; k++) {
-#line 793
             nstarts = 1;
-#line 793
             for (j = 0; j < var_rank[i]; j++) {
-#line 793
                 if ((k >> j) & 1) {
-#line 793
                     start[j] = 0;
-#line 793
                     edge[j] = mid[j];
-#line 793
                 }else{
-#line 793
                     start[j] = mid[j];
-#line 793
                     edge[j] = var_shape[i][j] - mid[j];
-#line 793
                 }
-#line 793
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 793
                 nstarts *= stride[j];
-#line 793
             }
-#line 793
             for (m = 0; m < nstarts; m++) {
-#line 793
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 793
                 IF (err)
-#line 793
                     error("error in toMixedBase");
-#line 793
                 nels = 1;
-#line 793
                 for (j = 0; j < var_rank[i]; j++) {
-#line 793
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 793
                     nels *= count[j];
-#line 793
                     index[j] += start[j];
-#line 793
                 }
-#line 793
-		    /* Random choice of forward or backward */
-#line 793
+                        /* Random choice of forward or backward */
 /* TODO
-#line 793
-		if ( roll(2) ) {
-#line 793
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 793
-			index[j] += (count[j] - 1) * stride[j];
-#line 793
-			stride[j] = -stride[j];
-#line 793
-		    }
-#line 793
-		}
-#line 793
- */
-#line 793
-		if (var_rank[i] > 0) {
-#line 793
-		    j = var_rank[i] - 1;
-#line 793
-		    imap[j] = 1;
-#line 793
-		    for (; j > 0; j--)
-#line 793
-			imap[j-1] = imap[j] * count[j];
-#line 793
-		}
-#line 793
-                allInExtRange = allInIntRange = 1;
-#line 793
-                for (j = 0; j < nels; j++) {
-#line 793
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 793
-                    IF (err)
-#line 793
-                        error("error in toMixedBase 1");
-#line 793
-                    for (d = 0; d < var_rank[i]; d++)
-#line 793
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 793
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 793
-                        NCT_LONG);
-#line 793
-                    if (inRange3(expect[j],var_type[i],NCT_LONG)) {
-#line 793
-                        allInIntRange = allInIntRange && expect[j] >= long_min
-#line 793
-                            && expect[j] <= long_max;
-#line 793
-                    } else {
-#line 793
-                        allInExtRange = 0;
-#line 793
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
                     }
-#line 793
                 }
-#line 793
+*/
+		allInExtRange = allInIntRange = 1;
+		for (j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_INT);
+		    if (inRange3(expect[j],var_type[i],NCT_INT)) {
+			allInIntRange = allInIntRange && expect[j] >= int_min
+			    && expect[j] <= int_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
                 if (var_rank[i] == 0 && i%2 )
-#line 793
-                    err = nc_get_varm_long(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 793
+                    err = nc_get_vars_int(ncid, i, NULL, NULL, NULL, value);
                 else
-#line 793
-                    err = nc_get_varm_long(ncid,i,index,count,stride,imap,value);
-#line 793
-                if (canConvert) {
-#line 793
-                    if (allInExtRange) {
-#line 793
-                        if (allInIntRange) {
-#line 793
-                            IF (err)
-#line 793
-                                error("%s", nc_strerror(err));
-#line 793
-                        } else {
-#line 793
-                            IF (err != NC_ERANGE)
-#line 793
-                                error("Range error: status = %d", err);
-#line 793
-                        }
-#line 793
-                    } else {
-#line 793
-                        IF (err != 0 && err != NC_ERANGE)
-#line 793
-                            error("OK or Range error: status = %d", err);
-#line 793
-                    }
-#line 793
-                    for (j = 0; j < nels; j++) {
-#line 793
-                        if (inRange3(expect[j],var_type[i],NCT_LONG)
-#line 793
-                                && expect[j] >= long_min 
-#line 793
-				&& expect[j] <= long_max) {
-#line 793
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_LONG)){
-#line 793
-                                error("value read not that expected");
-#line 793
-                                if (verbose) {
-#line 793
-                                    error("\n");
-#line 793
-                                    error("varid: %d, ", i);
-#line 793
-                                    error("var_name: %s, ", var_name[i]);
-#line 793
-                                    error("element number: %d ", j);
-#line 793
+                    err = nc_get_vars_int(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_INT)
+				&& expect[j] >= int_min && expect[j] <= int_max) {
+			    IF (!equal(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("element number: %d ", j);
                                     error("expect: %g, ", expect[j]);
-#line 793
-                                    error("got: %g", (double) value[j]);
-#line 793
-                                }
-#line 793
-                            } else {
-#line 793
-                                nok++;
-#line 793
-                            }
-#line 793
-                        }
-#line 793
-                    }
-#line 793
-                } else {
-#line 793
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 793
-                        error("wrong type: status = %d", err);
-#line 793
-                }
-#line 793
-            }
-#line 793
-        }
-#line 793
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
     }
-#line 793
     err = nc_close(ncid);
-#line 793
     IF (err)
-#line 793
         error("nc_close: %s", nc_strerror(err));
-#line 793
     print_nok(nok);
-#line 793
 }
-#line 793
 
 void
-#line 794
-test_nc_get_varm_float(void)
-#line 794
+test_nc_get_vars_long(void)
 {
-#line 794
     int ncid;
-#line 794
     int d;
-#line 794
     int i;
-#line 794
     int j;
-#line 794
     int k;
-#line 794
     int m;
-#line 794
     int err;
-#line 794
     int allInExtRange;	/* all values within external range? */
-#line 794
     int allInIntRange;	/* all values within internal range? */
-#line 794
     int nels;
-#line 794
     int nslabs;
-#line 794
     int nstarts;        /* number of different starts */
-#line 794
     int nok = 0;      /* count of valid comparisons */
-#line 794
     size_t start[MAX_RANK];
-#line 794
     size_t edge[MAX_RANK];
-#line 794
     size_t index[MAX_RANK];
-#line 794
     size_t index2[MAX_RANK];
-#line 794
     size_t mid[MAX_RANK];
-#line 794
     size_t count[MAX_RANK];
-#line 794
     size_t sstride[MAX_RANK];
-#line 794
     ptrdiff_t stride[MAX_RANK];
-#line 794
-    ptrdiff_t imap[MAX_RANK];
-#line 794
     int canConvert;     /* Both text or both numeric */
-#line 794
-    float value[MAX_NELS];
-#line 794
+    long value[MAX_NELS];
     double expect[MAX_NELS];
-#line 794
 
-#line 794
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 794
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 794
         error("nc_open: %s", nc_strerror(err));
-#line 794
-    for (i = 0; i < NVARS; i++) {
-#line 794
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 794
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 794
         assert(var_nels[i] <= MAX_NELS);
-#line 794
         for (j = 0; j < var_rank[i]; j++) {
-#line 794
             start[j] = 0;
-#line 794
             edge[j] = 1;
-#line 794
             stride[j] = 1;
-#line 794
-            imap[j] = 1;
-#line 794
         }
-#line 794
-        err = nc_get_varm_float(BAD_ID, i, start, edge, stride, imap, value);
-#line 794
+        err = nc_get_vars_long(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 794
             error("bad ncid: status = %d", err);
-#line 794
-        err = nc_get_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 794
+        err = nc_get_vars_long(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 794
             error("bad var id: status = %d", err);
-#line 794
         for (j = 0; j < var_rank[i]; j++) {
-#line 794
             start[j] = var_shape[i][j];
-#line 794
-            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
-#line 794
+            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 794
 		IF (err != NC_ECHAR)
-#line 794
                	    error("conversion: status = %d", err);
-#line 794
 	  } else {
-#line 794
-	    IF (err != NC_EINVALCOORDS)
-#line 794
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 794
             start[j] = 0;
-#line 794
             edge[j] = var_shape[i][j] + 1;
-#line 794
-            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
-#line 794
+            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 794
                 error("bad edge: status = %d", err);
-#line 794
             edge[j] = 1;
-#line 794
             stride[j] = 0;
-#line 794
-            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
-#line 794
+            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 794
                 error("bad stride: status = %d", err);
-#line 794
             stride[j] = 1;
-#line 794
-           }
-#line 794
+	  }
         }
-#line 794
             /* Choose a random point dividing each dim into 2 parts */
-#line 794
             /* get 2^rank (nslabs) slabs so defined */
-#line 794
         nslabs = 1;
-#line 794
         for (j = 0; j < var_rank[i]; j++) {
-#line 794
             mid[j] = roll( var_shape[i][j] );
-#line 794
             nslabs *= 2;
-#line 794
         }
-#line 794
             /* bits of k determine whether to get lower or upper part of dim */
-#line 794
             /* choose random stride from 1 to edge */
-#line 794
         for (k = 0; k < nslabs; k++) {
-#line 794
             nstarts = 1;
-#line 794
             for (j = 0; j < var_rank[i]; j++) {
-#line 794
                 if ((k >> j) & 1) {
-#line 794
                     start[j] = 0;
-#line 794
                     edge[j] = mid[j];
-#line 794
                 }else{
-#line 794
                     start[j] = mid[j];
-#line 794
                     edge[j] = var_shape[i][j] - mid[j];
-#line 794
                 }
-#line 794
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 794
                 nstarts *= stride[j];
-#line 794
             }
-#line 794
             for (m = 0; m < nstarts; m++) {
-#line 794
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 794
                 IF (err)
-#line 794
                     error("error in toMixedBase");
-#line 794
                 nels = 1;
-#line 794
                 for (j = 0; j < var_rank[i]; j++) {
-#line 794
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 794
                     nels *= count[j];
-#line 794
                     index[j] += start[j];
-#line 794
                 }
-#line 794
-		    /* Random choice of forward or backward */
-#line 794
+                        /* Random choice of forward or backward */
 /* TODO
-#line 794
-		if ( roll(2) ) {
-#line 794
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 794
-			index[j] += (count[j] - 1) * stride[j];
-#line 794
-			stride[j] = -stride[j];
-#line 794
-		    }
-#line 794
-		}
-#line 794
- */
-#line 794
-		if (var_rank[i] > 0) {
-#line 794
-		    j = var_rank[i] - 1;
-#line 794
-		    imap[j] = 1;
-#line 794
-		    for (; j > 0; j--)
-#line 794
-			imap[j-1] = imap[j] * count[j];
-#line 794
-		}
-#line 794
-                allInExtRange = allInIntRange = 1;
-#line 794
-                for (j = 0; j < nels; j++) {
-#line 794
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 794
-                    IF (err)
-#line 794
-                        error("error in toMixedBase 1");
-#line 794
-                    for (d = 0; d < var_rank[i]; d++)
-#line 794
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 794
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 794
-                        NCT_FLOAT);
-#line 794
-                    if (inRange3(expect[j],var_type[i],NCT_FLOAT)) {
-#line 794
-                        allInIntRange = allInIntRange && expect[j] >= float_min
-#line 794
-                            && expect[j] <= float_max;
-#line 794
-                    } else {
-#line 794
-                        allInExtRange = 0;
-#line 794
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
                     }
-#line 794
                 }
-#line 794
+*/
+		allInExtRange = allInIntRange = 1;
+		for (j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_LONG);
+		    if (inRange3(expect[j],var_type[i],NCT_LONG)) {
+			allInIntRange = allInIntRange && expect[j] >= long_min
+			    && expect[j] <= long_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
                 if (var_rank[i] == 0 && i%2 )
-#line 794
-                    err = nc_get_varm_float(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 794
+                    err = nc_get_vars_long(ncid, i, NULL, NULL, NULL, value);
                 else
-#line 794
-                    err = nc_get_varm_float(ncid,i,index,count,stride,imap,value);
-#line 794
-                if (canConvert) {
-#line 794
-                    if (allInExtRange) {
-#line 794
-                        if (allInIntRange) {
-#line 794
-                            IF (err)
-#line 794
-                                error("%s", nc_strerror(err));
-#line 794
-                        } else {
-#line 794
-                            IF (err != NC_ERANGE)
-#line 794
-                                error("Range error: status = %d", err);
-#line 794
-                        }
-#line 794
-                    } else {
-#line 794
-                        IF (err != 0 && err != NC_ERANGE)
-#line 794
-                            error("OK or Range error: status = %d", err);
-#line 794
-                    }
-#line 794
-                    for (j = 0; j < nels; j++) {
-#line 794
-                        if (inRange3(expect[j],var_type[i],NCT_FLOAT)
-#line 794
-                                && expect[j] >= float_min 
-#line 794
-				&& expect[j] <= float_max) {
-#line 794
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_FLOAT)){
-#line 794
-                                error("value read not that expected");
-#line 794
-                                if (verbose) {
-#line 794
-                                    error("\n");
-#line 794
-                                    error("varid: %d, ", i);
-#line 794
-                                    error("var_name: %s, ", var_name[i]);
-#line 794
-                                    error("element number: %d ", j);
-#line 794
+                    err = nc_get_vars_long(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_LONG)
+				&& expect[j] >= long_min && expect[j] <= long_max) {
+			    IF (!equal(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("element number: %d ", j);
                                     error("expect: %g, ", expect[j]);
-#line 794
-                                    error("got: %g", (double) value[j]);
-#line 794
-                                }
-#line 794
-                            } else {
-#line 794
-                                nok++;
-#line 794
-                            }
-#line 794
-                        }
-#line 794
-                    }
-#line 794
-                } else {
-#line 794
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 794
-                        error("wrong type: status = %d", err);
-#line 794
-                }
-#line 794
-            }
-#line 794
-        }
-#line 794
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
     }
-#line 794
     err = nc_close(ncid);
-#line 794
     IF (err)
-#line 794
         error("nc_close: %s", nc_strerror(err));
-#line 794
     print_nok(nok);
-#line 794
 }
-#line 794
 
 void
-#line 795
-test_nc_get_varm_double(void)
-#line 795
+test_nc_get_vars_float(void)
 {
-#line 795
     int ncid;
-#line 795
     int d;
-#line 795
     int i;
-#line 795
     int j;
-#line 795
     int k;
-#line 795
     int m;
-#line 795
     int err;
-#line 795
     int allInExtRange;	/* all values within external range? */
-#line 795
     int allInIntRange;	/* all values within internal range? */
-#line 795
     int nels;
-#line 795
     int nslabs;
-#line 795
     int nstarts;        /* number of different starts */
-#line 795
     int nok = 0;      /* count of valid comparisons */
-#line 795
     size_t start[MAX_RANK];
-#line 795
     size_t edge[MAX_RANK];
-#line 795
     size_t index[MAX_RANK];
-#line 795
     size_t index2[MAX_RANK];
-#line 795
     size_t mid[MAX_RANK];
-#line 795
     size_t count[MAX_RANK];
-#line 795
     size_t sstride[MAX_RANK];
-#line 795
     ptrdiff_t stride[MAX_RANK];
-#line 795
-    ptrdiff_t imap[MAX_RANK];
-#line 795
     int canConvert;     /* Both text or both numeric */
-#line 795
-    double value[MAX_NELS];
-#line 795
+    float value[MAX_NELS];
     double expect[MAX_NELS];
-#line 795
 
-#line 795
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 795
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
-#line 795
         error("nc_open: %s", nc_strerror(err));
-#line 795
-    for (i = 0; i < NVARS; i++) {
-#line 795
-        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 795
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 795
         assert(var_nels[i] <= MAX_NELS);
-#line 795
         for (j = 0; j < var_rank[i]; j++) {
-#line 795
             start[j] = 0;
-#line 795
             edge[j] = 1;
-#line 795
             stride[j] = 1;
-#line 795
-            imap[j] = 1;
-#line 795
         }
-#line 795
-        err = nc_get_varm_double(BAD_ID, i, start, edge, stride, imap, value);
-#line 795
+        err = nc_get_vars_float(BAD_ID, i, start, edge, stride, value);
         IF (err != NC_EBADID)
-#line 795
             error("bad ncid: status = %d", err);
-#line 795
-        err = nc_get_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 795
+        err = nc_get_vars_float(ncid, BAD_VARID, start, edge, stride, value);
         IF (err != NC_ENOTVAR)
-#line 795
             error("bad var id: status = %d", err);
-#line 795
         for (j = 0; j < var_rank[i]; j++) {
-#line 795
             start[j] = var_shape[i][j];
-#line 795
-            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
-#line 795
+            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
 	  if(!canConvert) {
-#line 795
 		IF (err != NC_ECHAR)
-#line 795
                	    error("conversion: status = %d", err);
-#line 795
 	  } else {
-#line 795
-	    IF (err != NC_EINVALCOORDS)
-#line 795
+            IF (err != NC_EINVALCOORDS)
                 error("bad index: status = %d", err);
-#line 795
             start[j] = 0;
-#line 795
             edge[j] = var_shape[i][j] + 1;
-#line 795
-            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
-#line 795
+            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
             IF (err != NC_EEDGE)
-#line 795
                 error("bad edge: status = %d", err);
-#line 795
             edge[j] = 1;
-#line 795
             stride[j] = 0;
-#line 795
-            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
-#line 795
+            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
             IF (err != NC_ESTRIDE)
-#line 795
                 error("bad stride: status = %d", err);
-#line 795
             stride[j] = 1;
-#line 795
-           }
-#line 795
+	  }
         }
-#line 795
             /* Choose a random point dividing each dim into 2 parts */
-#line 795
             /* get 2^rank (nslabs) slabs so defined */
-#line 795
         nslabs = 1;
-#line 795
         for (j = 0; j < var_rank[i]; j++) {
-#line 795
             mid[j] = roll( var_shape[i][j] );
-#line 795
             nslabs *= 2;
-#line 795
         }
-#line 795
             /* bits of k determine whether to get lower or upper part of dim */
-#line 795
             /* choose random stride from 1 to edge */
-#line 795
         for (k = 0; k < nslabs; k++) {
-#line 795
             nstarts = 1;
-#line 795
             for (j = 0; j < var_rank[i]; j++) {
-#line 795
                 if ((k >> j) & 1) {
-#line 795
                     start[j] = 0;
-#line 795
                     edge[j] = mid[j];
-#line 795
                 }else{
-#line 795
                     start[j] = mid[j];
-#line 795
                     edge[j] = var_shape[i][j] - mid[j];
-#line 795
                 }
-#line 795
                 sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 795
                 nstarts *= stride[j];
-#line 795
             }
-#line 795
             for (m = 0; m < nstarts; m++) {
-#line 795
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 795
                 IF (err)
-#line 795
                     error("error in toMixedBase");
-#line 795
                 nels = 1;
-#line 795
                 for (j = 0; j < var_rank[i]; j++) {
-#line 795
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 795
                     nels *= count[j];
-#line 795
                     index[j] += start[j];
-#line 795
                 }
-#line 795
-		    /* Random choice of forward or backward */
-#line 795
+                        /* Random choice of forward or backward */
 /* TODO
-#line 795
-		if ( roll(2) ) {
-#line 795
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 795
-			index[j] += (count[j] - 1) * stride[j];
-#line 795
-			stride[j] = -stride[j];
-#line 795
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * 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)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_FLOAT);
+		    if (inRange3(expect[j],var_type[i],NCT_FLOAT)) {
+			allInIntRange = allInIntRange && expect[j] >= float_min
+			    && expect[j] <= float_max;
+		    } else {
+			allInExtRange = 0;
 		    }
-#line 795
 		}
-#line 795
- */
-#line 795
-		if (var_rank[i] > 0) {
-#line 795
-		    j = var_rank[i] - 1;
-#line 795
-		    imap[j] = 1;
-#line 795
-		    for (; j > 0; j--)
-#line 795
-			imap[j-1] = imap[j] * count[j];
-#line 795
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_vars_float(ncid, i, NULL, NULL, NULL, value);
+                else
+                    err = nc_get_vars_float(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+				&& expect[j] >= float_min && expect[j] <= float_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 795
-                allInExtRange = allInIntRange = 1;
-#line 795
-                for (j = 0; j < nels; j++) {
-#line 795
-                    err = toMixedBase(j, var_rank[i], count, index2);
-#line 795
-                    IF (err)
-#line 795
-                        error("error in toMixedBase 1");
-#line 795
-                    for (d = 0; d < var_rank[i]; d++)
-#line 795
-                        index2[d] = index[d] + index2[d] * stride[d];
-#line 795
-                    expect[j] = hash4(var_type[i], var_rank[i], index2,
-#line 795
-                        NCT_DOUBLE);
-#line 795
-                    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) {
-#line 795
-                        allInIntRange = allInIntRange && expect[j] >= double_min
-#line 795
-                            && expect[j] <= double_max;
-#line 795
-                    } else {
-#line 795
-                        allInExtRange = 0;
-#line 795
-                    }
-#line 795
+	    }
+	}
+
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_vars_double(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    int canConvert;     /* Both text or both numeric */
+    double value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+        }
+        err = nc_get_vars_double(BAD_ID, i, start, edge, stride, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_vars_double(ncid, BAD_VARID, start, edge, stride, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+            IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * 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)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_DOUBLE);
+		    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) {
+			allInIntRange = allInIntRange && expect[j] >= double_min
+			    && expect[j] <= double_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_vars_double(ncid, i, NULL, NULL, NULL, value);
+                else
+                    err = nc_get_vars_double(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+				&& expect[j] >= double_min && expect[j] <= double_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_vars_ushort(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    int canConvert;     /* Both text or both numeric */
+    ushort value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+        }
+        err = nc_get_vars_ushort(BAD_ID, i, start, edge, stride, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_vars_ushort(ncid, BAD_VARID, start, edge, stride, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+            IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * 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)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_USHORT);
+		    if (inRange3(expect[j],var_type[i],NCT_USHORT)) {
+			allInIntRange = allInIntRange && expect[j] >= ushort_min
+			    && expect[j] <= ushort_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_vars_ushort(ncid, i, NULL, NULL, NULL, value);
+                else
+                    err = nc_get_vars_ushort(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_USHORT)
+				&& expect[j] >= ushort_min && expect[j] <= ushort_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_vars_uint(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    int canConvert;     /* Both text or both numeric */
+    uint value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+        }
+        err = nc_get_vars_uint(BAD_ID, i, start, edge, stride, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_vars_uint(ncid, BAD_VARID, start, edge, stride, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+            IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * 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)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_UINT);
+		    if (inRange3(expect[j],var_type[i],NCT_UINT)) {
+			allInIntRange = allInIntRange && expect[j] >= uint_min
+			    && expect[j] <= uint_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_vars_uint(ncid, i, NULL, NULL, NULL, value);
+                else
+                    err = nc_get_vars_uint(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_UINT)
+				&& expect[j] >= uint_min && expect[j] <= uint_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_vars_longlong(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    int canConvert;     /* Both text or both numeric */
+    longlong value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+        }
+        err = nc_get_vars_longlong(BAD_ID, i, start, edge, stride, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_vars_longlong(ncid, BAD_VARID, start, edge, stride, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+            IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * 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)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_LONGLONG);
+		    if (inRange3(expect[j],var_type[i],NCT_LONGLONG)) {
+			allInIntRange = allInIntRange && expect[j] >= longlong_min
+			    && expect[j] <= longlong_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_vars_longlong(ncid, i, NULL, NULL, NULL, value);
+                else
+                    err = nc_get_vars_longlong(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+				&& expect[j] >= longlong_min && expect[j] <= longlong_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_vars_ulonglong(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    int canConvert;     /* Both text or both numeric */
+    ulonglong value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+        }
+        err = nc_get_vars_ulonglong(BAD_ID, i, start, edge, stride, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_vars_ulonglong(ncid, BAD_VARID, start, edge, stride, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+            IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * 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)
+			error("error in toMixedBase 1");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+			NCT_ULONGLONG);
+		    if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)) {
+			allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+			    && expect[j] <= ulonglong_max;
+		    } else {
+			allInExtRange = 0;
+		    }
+		}
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_vars_ulonglong(ncid, i, NULL, NULL, NULL, value);
+                else
+                    err = nc_get_vars_ulonglong(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			if (allInIntRange) {
+			    IF (err)
+				error("%s", nc_strerror(err));
+			} else {
+			    IF (err != NC_ERANGE)
+				error("Range error: status = %d", err);
+			}
+		    } else {
+			IF (err != 0 && err != NC_ERANGE)
+			    error("OK or Range error: status = %d", err);
+		    }
+		    for (j = 0; j < nels; j++) {
+			if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+				&& expect[j] >= ulonglong_min && expect[j] <= ulonglong_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+				    error("got: %g", (double) value[j]);
+				}
+			    } else {
+				nok++;
+			    }
+			}
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+
+
+
+void
+test_nc_get_varm_text(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    text value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_text(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_TEXT);
+                    if (inRange3(expect[j],var_type[i],NCT_TEXT)) {
+                        allInIntRange = allInIntRange && expect[j] >= text_min
+                            && expect[j] <= text_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_text(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_text(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_TEXT)
+                                && expect[j] >= text_min 
+				&& expect[j] <= text_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_uchar(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    uchar value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_uchar(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_UCHAR);
+                    if (inRange3(expect[j],var_type[i],NCT_UCHAR)) {
+                        allInIntRange = allInIntRange && expect[j] >= uchar_min
+                            && expect[j] <= uchar_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_uchar(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+                                && expect[j] >= uchar_min 
+				&& expect[j] <= uchar_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_schar(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    schar value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_schar(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_SCHAR);
+                    if (inRange3(expect[j],var_type[i],NCT_SCHAR)) {
+                        allInIntRange = allInIntRange && expect[j] >= schar_min
+                            && expect[j] <= schar_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_schar(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+                                && expect[j] >= schar_min 
+				&& expect[j] <= schar_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_short(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    short value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_short(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_SHORT);
+                    if (inRange3(expect[j],var_type[i],NCT_SHORT)) {
+                        allInIntRange = allInIntRange && expect[j] >= short_min
+                            && expect[j] <= short_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_short(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_short(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_SHORT)
+                                && expect[j] >= short_min 
+				&& expect[j] <= short_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_int(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    int value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_int(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_INT);
+                    if (inRange3(expect[j],var_type[i],NCT_INT)) {
+                        allInIntRange = allInIntRange && expect[j] >= int_min
+                            && expect[j] <= int_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_int(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_int(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_INT)
+                                && expect[j] >= int_min 
+				&& expect[j] <= int_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_long(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    long value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_long(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_LONG);
+                    if (inRange3(expect[j],var_type[i],NCT_LONG)) {
+                        allInIntRange = allInIntRange && expect[j] >= long_min
+                            && expect[j] <= long_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_long(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_long(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_LONG)
+                                && expect[j] >= long_min 
+				&& expect[j] <= long_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_float(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    float value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_float(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_FLOAT);
+                    if (inRange3(expect[j],var_type[i],NCT_FLOAT)) {
+                        allInIntRange = allInIntRange && expect[j] >= float_min
+                            && expect[j] <= float_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_float(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_float(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+                                && expect[j] >= float_min 
+				&& expect[j] <= float_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_double(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    double value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_double(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_DOUBLE);
+                    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) {
+                        allInIntRange = allInIntRange && expect[j] >= double_min
+                            && expect[j] <= double_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_double(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_double(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+                                && expect[j] >= double_min 
+				&& expect[j] <= double_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_ushort(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    ushort value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_ushort(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_ushort(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_USHORT);
+                    if (inRange3(expect[j],var_type[i],NCT_USHORT)) {
+                        allInIntRange = allInIntRange && expect[j] >= ushort_min
+                            && expect[j] <= ushort_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_ushort(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_ushort(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_USHORT)
+                                && expect[j] >= ushort_min 
+				&& expect[j] <= ushort_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_uint(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    uint value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_uint(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_uint(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_UINT);
+                    if (inRange3(expect[j],var_type[i],NCT_UINT)) {
+                        allInIntRange = allInIntRange && expect[j] >= uint_min
+                            && expect[j] <= uint_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_uint(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_uint(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_UINT)
+                                && expect[j] >= uint_min 
+				&& expect[j] <= uint_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_longlong(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    longlong value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_longlong(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_longlong(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_LONGLONG);
+                    if (inRange3(expect[j],var_type[i],NCT_LONGLONG)) {
+                        allInIntRange = allInIntRange && expect[j] >= longlong_min
+                            && expect[j] <= longlong_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_longlong(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_longlong(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+                                && expect[j] >= longlong_min 
+				&& expect[j] <= longlong_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_varm_ulonglong(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int allInExtRange;	/* all values within external range? */
+    int allInIntRange;	/* all values within internal range? */
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    int nok = 0;      /* count of valid comparisons */
+    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];
+    ptrdiff_t imap[MAX_RANK];
+    int canConvert;     /* Both text or both numeric */
+    ulonglong value[MAX_NELS];
+    double expect[MAX_NELS];
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+    for (i = 0; i < numVars; i++) {
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+            stride[j] = 1;
+            imap[j] = 1;
+        }
+        err = nc_get_varm_ulonglong(BAD_ID, i, start, edge, stride, imap, value);
+        IF (err != NC_EBADID)
+            error("bad ncid: status = %d", err);
+        err = nc_get_varm_ulonglong(ncid, BAD_VARID, start, edge, stride, imap, value);
+        IF (err != NC_ENOTVAR)
+            error("bad var id: status = %d", err);
+        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("conversion: status = %d", err);
+	  } else {
+	    IF (err != NC_EINVALCOORDS)
+                error("bad index: status = %d", 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("bad edge: status = %d", err);
+            edge[j] = 1;
+            stride[j] = 0;
+            err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+            IF (err != NC_ESTRIDE)
+                error("bad stride: status = %d", err);
+            stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+                nstarts *= stride[j];
+            }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+ */
+		if (var_rank[i] > 0) {
+		    j = var_rank[i] - 1;
+		    imap[j] = 1;
+		    for (; j > 0; j--)
+			imap[j-1] = imap[j] * count[j];
+		}
+                allInExtRange = allInIntRange = 1;
+                for (j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase 1");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+                        NCT_ULONGLONG);
+                    if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)) {
+                        allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+                            && expect[j] <= ulonglong_max;
+                    } else {
+                        allInExtRange = 0;
+                    }
+                }
+                if (var_rank[i] == 0 && i%2 )
+                    err = nc_get_varm_ulonglong(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_get_varm_ulonglong(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        if (allInIntRange) {
+                            IF (err)
+                                error("%s", nc_strerror(err));
+                        } else {
+                            IF (err != NC_ERANGE)
+                                error("Range error: status = %d", err);
+                        }
+                    } else {
+                        IF (err != 0 && err != NC_ERANGE)
+                            error("OK or Range error: status = %d", err);
+                    }
+                    for (j = 0; j < nels; j++) {
+                        if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+                                && expect[j] >= ulonglong_min 
+				&& expect[j] <= ulonglong_max) {
+			    IF (!equal(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("element number: %d ", j);
+                                    error("expect: %g, ", expect[j]);
+                                    error("got: %g", (double) value[j]);
+                                }
+                            } else {
+                                nok++;
+                            }
+                        }
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
+                }
+            }
+        }
+    }
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+
+
+
+void
+test_nc_get_att_text(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    int allInExtRange;
+    int allInIntRange;
+    int canConvert;     /* Both text or both numeric */
+    text value[MAX_NELS];
+    double expect[MAX_NELS];
+    int nok = 0;      /* count of valid comparisons */
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err) 
+	error("nc_open: %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_TEXT == NCT_TEXT);
+	    err = nc_get_att_text(BAD_ID, i, ATT_NAME(i,j), value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_att_text(ncid, BAD_VARID, ATT_NAME(i,j), value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    err = nc_get_att_text(ncid, i, "noSuch", value);
+	    IF (err != NC_ENOTATT) 
+		error("Bad attribute name: status = %d", err);
+	    allInExtRange = allInIntRange = 1;
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_TEXT);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)) {
+                    allInIntRange = allInIntRange && expect[k] >= text_min
+                                && expect[k] <= text_max;
+                } 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)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("Range error: status = %d", err);
+                    }
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)
+                            && expect[k] >= text_min && expect[k] <= text_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_TEXT)){
+			    error("value read not that expected");
+                            if (verbose) {
+                                error("\n");
+                                error("varid: %d, ", i);
+                                error("att_name: %s, ", ATT_NAME(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("wrong type: status = %d", err);
+	    }
+	}
+    }
+
+    err = nc_close(ncid);
+    IF (err)
+	error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_att_uchar(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    int allInExtRange;
+    int allInIntRange;
+    int canConvert;     /* Both text or both numeric */
+    uchar value[MAX_NELS];
+    double expect[MAX_NELS];
+    int nok = 0;      /* count of valid comparisons */
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err) 
+	error("nc_open: %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);
+	    err = nc_get_att_uchar(BAD_ID, i, ATT_NAME(i,j), value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    err = nc_get_att_uchar(ncid, i, "noSuch", value);
+	    IF (err != NC_ENOTATT) 
+		error("Bad attribute name: status = %d", err);
+	    allInExtRange = allInIntRange = 1;
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_UCHAR);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)) {
+                    allInIntRange = 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)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("Range error: status = %d", err);
+                    }
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)
+                            && expect[k] >= uchar_min && expect[k] <= uchar_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_UCHAR)){
+			    error("value read not that expected");
+                            if (verbose) {
+                                error("\n");
+                                error("varid: %d, ", i);
+                                error("att_name: %s, ", ATT_NAME(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("wrong type: status = %d", err);
+	    }
+	}
+    }
+
+    err = nc_close(ncid);
+    IF (err)
+	error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_att_schar(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    int allInExtRange;
+    int allInIntRange;
+    int canConvert;     /* Both text or both numeric */
+    schar value[MAX_NELS];
+    double expect[MAX_NELS];
+    int nok = 0;      /* count of valid comparisons */
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err) 
+	error("nc_open: %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);
+	    err = nc_get_att_schar(BAD_ID, i, ATT_NAME(i,j), value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    err = nc_get_att_schar(ncid, i, "noSuch", value);
+	    IF (err != NC_ENOTATT) 
+		error("Bad attribute name: status = %d", err);
+	    allInExtRange = allInIntRange = 1;
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SCHAR);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)) {
+                    allInIntRange = 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)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("Range error: status = %d", err);
+                    }
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)
+                            && expect[k] >= schar_min && expect[k] <= schar_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_SCHAR)){
+			    error("value read not that expected");
+                            if (verbose) {
+                                error("\n");
+                                error("varid: %d, ", i);
+                                error("att_name: %s, ", ATT_NAME(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("wrong type: status = %d", err);
+	    }
+	}
+    }
+
+    err = nc_close(ncid);
+    IF (err)
+	error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+void
+test_nc_get_att_short(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    int allInExtRange;
+    int allInIntRange;
+    int canConvert;     /* Both text or both numeric */
+    short value[MAX_NELS];
+    double expect[MAX_NELS];
+    int nok = 0;      /* count of valid comparisons */
+
+    err = file_open(testfile, NC_NOWRITE, &ncid);
+    IF (err) 
+	error("nc_open: %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);
+	    err = nc_get_att_short(BAD_ID, i, ATT_NAME(i,j), value);
+	    IF (err != NC_EBADID) 
+		error("bad ncid: status = %d", err);
+	    err = nc_get_att_short(ncid, BAD_VARID, ATT_NAME(i,j), value);
+	    IF (err != NC_ENOTVAR) 
+		error("bad var id: status = %d", err);
+	    err = nc_get_att_short(ncid, i, "noSuch", value);
+	    IF (err != NC_ENOTATT) 
+		error("Bad attribute name: status = %d", err);
+	    allInExtRange = allInIntRange = 1;
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SHORT);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)) {
+                    allInIntRange = allInIntRange && expect[k] >= short_min
+                                && expect[k] <= short_max;
+                } else {
+                    allInExtRange = 0;
                 }
-#line 795
-                if (var_rank[i] == 0 && i%2 )
-#line 795
-                    err = nc_get_varm_double(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 795
-                else
-#line 795
-                    err = nc_get_varm_double(ncid,i,index,count,stride,imap,value);
-#line 795
-                if (canConvert) {
-#line 795
-                    if (allInExtRange) {
-#line 795
-                        if (allInIntRange) {
-#line 795
-                            IF (err)
-#line 795
-                                error("%s", nc_strerror(err));
-#line 795
-                        } else {
-#line 795
-                            IF (err != NC_ERANGE)
-#line 795
-                                error("Range error: status = %d", err);
-#line 795
-                        }
-#line 795
+	    }
+	    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)
+                            error("%s", nc_strerror(err));
                     } else {
-#line 795
-                        IF (err != 0 && err != NC_ERANGE)
-#line 795
-                            error("OK or Range error: status = %d", err);
-#line 795
-                    }
-#line 795
-                    for (j = 0; j < nels; j++) {
-#line 795
-                        if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
-#line 795
-                                && expect[j] >= double_min 
-#line 795
-				&& expect[j] <= double_max) {
-#line 795
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_DOUBLE)){
-#line 795
-                                error("value read not that expected");
-#line 795
-                                if (verbose) {
-#line 795
-                                    error("\n");
-#line 795
-                                    error("varid: %d, ", i);
-#line 795
-                                    error("var_name: %s, ", var_name[i]);
-#line 795
-                                    error("element number: %d ", j);
-#line 795
-                                    error("expect: %g, ", expect[j]);
-#line 795
-                                    error("got: %g", (double) value[j]);
-#line 795
-                                }
-#line 795
-                            } else {
-#line 795
-                                nok++;
-#line 795
-                            }
-#line 795
-                        }
-#line 795
+                        IF (err != NC_ERANGE)
+                            error("Range error: status = %d", err);
                     }
-#line 795
                 } else {
-#line 795
-                    IF (nels > 0 && err != NC_ECHAR)
-#line 795
-                        error("wrong type: status = %d", err);
-#line 795
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
                 }
-#line 795
-            }
-#line 795
-        }
-#line 795
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)
+                            && expect[k] >= short_min && expect[k] <= short_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_SHORT)){
+			    error("value read not that expected");
+                            if (verbose) {
+                                error("\n");
+                                error("varid: %d, ", i);
+                                error("att_name: %s, ", ATT_NAME(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("wrong type: status = %d", err);
+	    }
+	}
     }
-#line 795
+
     err = nc_close(ncid);
-#line 795
     IF (err)
-#line 795
-        error("nc_close: %s", nc_strerror(err));
-#line 795
+	error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 795
 }
-#line 795
-
-
-
-#line 888
 
 void
-#line 889
-test_nc_get_att_text(void)
-#line 889
+test_nc_get_att_int(void)
 {
-#line 889
     int ncid;
-#line 889
     int i;
-#line 889
     int j;
-#line 889
     size_t k;
-#line 889
     int err;
-#line 889
     int allInExtRange;
-#line 889
     int allInIntRange;
-#line 889
     int canConvert;     /* Both text or both numeric */
-#line 889
-    text value[MAX_NELS];
-#line 889
+    int value[MAX_NELS];
     double expect[MAX_NELS];
-#line 889
     int nok = 0;      /* count of valid comparisons */
-#line 889
 
-#line 889
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 889
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 889
 	error("nc_open: %s", nc_strerror(err));
-#line 889
 
-#line 889
-    for (i = -1; i < NVARS; i++) {
-#line 889
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 889
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 889
-	    err = nc_get_att_text(BAD_ID, i, ATT_NAME(i,j), value);
-#line 889
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
+	    err = nc_get_att_int(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 889
 		error("bad ncid: status = %d", err);
-#line 889
-	    err = nc_get_att_text(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 889
+	    err = nc_get_att_int(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 889
 		error("bad var id: status = %d", err);
-#line 889
-	    err = nc_get_att_text(ncid, i, "noSuch", value);
-#line 889
+	    err = nc_get_att_int(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 889
 		error("Bad attribute name: status = %d", err);
-#line 889
 	    allInExtRange = allInIntRange = 1;
-#line 889
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 889
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_TEXT);
-#line 889
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)) {
-#line 889
-                    allInIntRange = allInIntRange && expect[k] >= text_min
-#line 889
-                                && expect[k] <= text_max;
-#line 889
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_INT);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)) {
+                    allInIntRange = allInIntRange && expect[k] >= int_min
+                                && expect[k] <= int_max;
                 } else {
-#line 889
                     allInExtRange = 0;
-#line 889
                 }
-#line 889
 	    }
-#line 889
-	    err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value);
-#line 889
+	    err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 889
                 if (allInExtRange) {
-#line 889
                     if (allInIntRange) {
-#line 889
                         IF (err)
-#line 889
                             error("%s", nc_strerror(err));
-#line 889
                     } else {
-#line 889
                         IF (err != NC_ERANGE)
-#line 889
                             error("Range error: status = %d", err);
-#line 889
                     }
-#line 889
                 } else {
-#line 889
                     IF (err != 0 && err != NC_ERANGE)
-#line 889
                         error("OK or Range error: status = %d", err);
-#line 889
                 }
-#line 889
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 889
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)
-#line 889
-                            && expect[k] >= text_min && expect[k] <= text_max) {
-#line 889
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_TEXT)){
-#line 889
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)
+                            && expect[k] >= int_min && expect[k] <= int_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_INT)){
 			    error("value read not that expected");
-#line 889
                             if (verbose) {
-#line 889
                                 error("\n");
-#line 889
                                 error("varid: %d, ", i);
-#line 889
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 889
                                 error("element number: %d ", k);
-#line 889
                                 error("expect: %g", expect[k]);
-#line 889
                                 error("got: %g", (double) value[k]);
-#line 889
                             }
-#line 889
 			} else {
-#line 889
 			    nok++;
-#line 889
                         }
-#line 889
 		    }
-#line 889
 		}
-#line 889
 	    } else {
-#line 889
 		IF (err != NC_ECHAR)
-#line 889
 		    error("wrong type: status = %d", err);
-#line 889
 	    }
-#line 889
 	}
-#line 889
     }
-#line 889
 
-#line 889
     err = nc_close(ncid);
-#line 889
     IF (err)
-#line 889
 	error("nc_close: %s", nc_strerror(err));
-#line 889
     print_nok(nok);
-#line 889
 }
-#line 889
 
 void
-#line 890
-test_nc_get_att_uchar(void)
-#line 890
+test_nc_get_att_long(void)
 {
-#line 890
     int ncid;
-#line 890
     int i;
-#line 890
     int j;
-#line 890
     size_t k;
-#line 890
     int err;
-#line 890
     int allInExtRange;
-#line 890
     int allInIntRange;
-#line 890
     int canConvert;     /* Both text or both numeric */
-#line 890
-    uchar value[MAX_NELS];
-#line 890
+    long value[MAX_NELS];
     double expect[MAX_NELS];
-#line 890
     int nok = 0;      /* count of valid comparisons */
-#line 890
 
-#line 890
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 890
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 890
 	error("nc_open: %s", nc_strerror(err));
-#line 890
 
-#line 890
-    for (i = -1; i < NVARS; i++) {
-#line 890
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 890
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 890
-	    err = nc_get_att_uchar(BAD_ID, i, ATT_NAME(i,j), value);
-#line 890
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+	    err = nc_get_att_long(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 890
 		error("bad ncid: status = %d", err);
-#line 890
-	    err = nc_get_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 890
+	    err = nc_get_att_long(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 890
 		error("bad var id: status = %d", err);
-#line 890
-	    err = nc_get_att_uchar(ncid, i, "noSuch", value);
-#line 890
+	    err = nc_get_att_long(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 890
 		error("Bad attribute name: status = %d", err);
-#line 890
 	    allInExtRange = allInIntRange = 1;
-#line 890
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 890
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_UCHAR);
-#line 890
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)) {
-#line 890
-                    allInIntRange = allInIntRange && expect[k] >= uchar_min
-#line 890
-                                && expect[k] <= uchar_max;
-#line 890
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_LONG);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)) {
+                    allInIntRange = allInIntRange && expect[k] >= long_min
+                                && expect[k] <= long_max;
                 } else {
-#line 890
                     allInExtRange = 0;
-#line 890
                 }
-#line 890
 	    }
-#line 890
-	    err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
-#line 890
+	    err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 890
                 if (allInExtRange) {
-#line 890
                     if (allInIntRange) {
-#line 890
                         IF (err)
-#line 890
                             error("%s", nc_strerror(err));
-#line 890
                     } else {
-#line 890
                         IF (err != NC_ERANGE)
-#line 890
                             error("Range error: status = %d", err);
-#line 890
                     }
-#line 890
                 } else {
-#line 890
                     IF (err != 0 && err != NC_ERANGE)
-#line 890
                         error("OK or Range error: status = %d", err);
-#line 890
                 }
-#line 890
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 890
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)
-#line 890
-                            && expect[k] >= uchar_min && expect[k] <= uchar_max) {
-#line 890
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_UCHAR)){
-#line 890
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)
+                            && expect[k] >= long_min && expect[k] <= long_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_LONG)){
 			    error("value read not that expected");
-#line 890
                             if (verbose) {
-#line 890
                                 error("\n");
-#line 890
                                 error("varid: %d, ", i);
-#line 890
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 890
                                 error("element number: %d ", k);
-#line 890
                                 error("expect: %g", expect[k]);
-#line 890
                                 error("got: %g", (double) value[k]);
-#line 890
                             }
-#line 890
 			} else {
-#line 890
 			    nok++;
-#line 890
                         }
-#line 890
 		    }
-#line 890
 		}
-#line 890
 	    } else {
-#line 890
 		IF (err != NC_ECHAR)
-#line 890
 		    error("wrong type: status = %d", err);
-#line 890
 	    }
-#line 890
 	}
-#line 890
     }
-#line 890
 
-#line 890
     err = nc_close(ncid);
-#line 890
     IF (err)
-#line 890
 	error("nc_close: %s", nc_strerror(err));
-#line 890
     print_nok(nok);
-#line 890
 }
-#line 890
 
 void
-#line 891
-test_nc_get_att_schar(void)
-#line 891
+test_nc_get_att_float(void)
 {
-#line 891
     int ncid;
-#line 891
     int i;
-#line 891
     int j;
-#line 891
     size_t k;
-#line 891
     int err;
-#line 891
     int allInExtRange;
-#line 891
     int allInIntRange;
-#line 891
     int canConvert;     /* Both text or both numeric */
-#line 891
-    schar value[MAX_NELS];
-#line 891
+    float value[MAX_NELS];
     double expect[MAX_NELS];
-#line 891
     int nok = 0;      /* count of valid comparisons */
-#line 891
 
-#line 891
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 891
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 891
 	error("nc_open: %s", nc_strerror(err));
-#line 891
 
-#line 891
-    for (i = -1; i < NVARS; i++) {
-#line 891
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 891
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 891
-	    err = nc_get_att_schar(BAD_ID, i, ATT_NAME(i,j), value);
-#line 891
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+	    err = nc_get_att_float(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 891
 		error("bad ncid: status = %d", err);
-#line 891
-	    err = nc_get_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 891
+	    err = nc_get_att_float(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 891
 		error("bad var id: status = %d", err);
-#line 891
-	    err = nc_get_att_schar(ncid, i, "noSuch", value);
-#line 891
+	    err = nc_get_att_float(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 891
 		error("Bad attribute name: status = %d", err);
-#line 891
 	    allInExtRange = allInIntRange = 1;
-#line 891
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 891
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SCHAR);
-#line 891
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)) {
-#line 891
-                    allInIntRange = allInIntRange && expect[k] >= schar_min
-#line 891
-                                && expect[k] <= schar_max;
-#line 891
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_FLOAT);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)) {
+                    allInIntRange = allInIntRange && expect[k] >= float_min
+                                && expect[k] <= float_max;
                 } else {
-#line 891
                     allInExtRange = 0;
-#line 891
                 }
-#line 891
 	    }
-#line 891
-	    err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
-#line 891
+	    err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 891
                 if (allInExtRange) {
-#line 891
                     if (allInIntRange) {
-#line 891
                         IF (err)
-#line 891
                             error("%s", nc_strerror(err));
-#line 891
                     } else {
-#line 891
                         IF (err != NC_ERANGE)
-#line 891
                             error("Range error: status = %d", err);
-#line 891
                     }
-#line 891
                 } else {
-#line 891
                     IF (err != 0 && err != NC_ERANGE)
-#line 891
                         error("OK or Range error: status = %d", err);
-#line 891
                 }
-#line 891
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 891
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)
-#line 891
-                            && expect[k] >= schar_min && expect[k] <= schar_max) {
-#line 891
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_SCHAR)){
-#line 891
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)
+                            && expect[k] >= float_min && expect[k] <= float_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_FLOAT)){
 			    error("value read not that expected");
-#line 891
                             if (verbose) {
-#line 891
                                 error("\n");
-#line 891
                                 error("varid: %d, ", i);
-#line 891
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 891
                                 error("element number: %d ", k);
-#line 891
                                 error("expect: %g", expect[k]);
-#line 891
                                 error("got: %g", (double) value[k]);
-#line 891
                             }
-#line 891
 			} else {
-#line 891
 			    nok++;
-#line 891
                         }
-#line 891
 		    }
-#line 891
 		}
-#line 891
 	    } else {
-#line 891
 		IF (err != NC_ECHAR)
-#line 891
 		    error("wrong type: status = %d", err);
-#line 891
 	    }
-#line 891
 	}
-#line 891
     }
-#line 891
 
-#line 891
     err = nc_close(ncid);
-#line 891
     IF (err)
-#line 891
 	error("nc_close: %s", nc_strerror(err));
-#line 891
     print_nok(nok);
-#line 891
 }
-#line 891
 
 void
-#line 892
-test_nc_get_att_short(void)
-#line 892
+test_nc_get_att_double(void)
 {
-#line 892
     int ncid;
-#line 892
     int i;
-#line 892
     int j;
-#line 892
     size_t k;
-#line 892
     int err;
-#line 892
     int allInExtRange;
-#line 892
     int allInIntRange;
-#line 892
     int canConvert;     /* Both text or both numeric */
-#line 892
-    short value[MAX_NELS];
-#line 892
+    double value[MAX_NELS];
     double expect[MAX_NELS];
-#line 892
     int nok = 0;      /* count of valid comparisons */
-#line 892
 
-#line 892
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 892
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 892
 	error("nc_open: %s", nc_strerror(err));
-#line 892
 
-#line 892
-    for (i = -1; i < NVARS; i++) {
-#line 892
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 892
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 892
-	    err = nc_get_att_short(BAD_ID, i, ATT_NAME(i,j), value);
-#line 892
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+	    err = nc_get_att_double(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 892
 		error("bad ncid: status = %d", err);
-#line 892
-	    err = nc_get_att_short(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 892
+	    err = nc_get_att_double(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 892
 		error("bad var id: status = %d", err);
-#line 892
-	    err = nc_get_att_short(ncid, i, "noSuch", value);
-#line 892
+	    err = nc_get_att_double(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 892
 		error("Bad attribute name: status = %d", err);
-#line 892
 	    allInExtRange = allInIntRange = 1;
-#line 892
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 892
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SHORT);
-#line 892
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)) {
-#line 892
-                    allInIntRange = allInIntRange && expect[k] >= short_min
-#line 892
-                                && expect[k] <= short_max;
-#line 892
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)) {
+                    allInIntRange = allInIntRange && expect[k] >= double_min
+                                && expect[k] <= double_max;
                 } else {
-#line 892
                     allInExtRange = 0;
-#line 892
                 }
-#line 892
 	    }
-#line 892
-	    err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
-#line 892
+	    err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 892
                 if (allInExtRange) {
-#line 892
                     if (allInIntRange) {
-#line 892
                         IF (err)
-#line 892
                             error("%s", nc_strerror(err));
-#line 892
                     } else {
-#line 892
                         IF (err != NC_ERANGE)
-#line 892
                             error("Range error: status = %d", err);
-#line 892
                     }
-#line 892
                 } else {
-#line 892
                     IF (err != 0 && err != NC_ERANGE)
-#line 892
                         error("OK or Range error: status = %d", err);
-#line 892
                 }
-#line 892
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 892
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)
-#line 892
-                            && expect[k] >= short_min && expect[k] <= short_max) {
-#line 892
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_SHORT)){
-#line 892
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)
+                            && expect[k] >= double_min && expect[k] <= double_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_DOUBLE)){
 			    error("value read not that expected");
-#line 892
                             if (verbose) {
-#line 892
                                 error("\n");
-#line 892
                                 error("varid: %d, ", i);
-#line 892
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 892
                                 error("element number: %d ", k);
-#line 892
                                 error("expect: %g", expect[k]);
-#line 892
                                 error("got: %g", (double) value[k]);
-#line 892
                             }
-#line 892
 			} else {
-#line 892
 			    nok++;
-#line 892
                         }
-#line 892
 		    }
-#line 892
 		}
-#line 892
 	    } else {
-#line 892
 		IF (err != NC_ECHAR)
-#line 892
 		    error("wrong type: status = %d", err);
-#line 892
 	    }
-#line 892
 	}
-#line 892
     }
-#line 892
 
-#line 892
     err = nc_close(ncid);
-#line 892
     IF (err)
-#line 892
 	error("nc_close: %s", nc_strerror(err));
-#line 892
     print_nok(nok);
-#line 892
 }
-#line 892
 
 void
-#line 893
-test_nc_get_att_int(void)
-#line 893
+test_nc_get_att_ushort(void)
 {
-#line 893
     int ncid;
-#line 893
     int i;
-#line 893
     int j;
-#line 893
     size_t k;
-#line 893
     int err;
-#line 893
     int allInExtRange;
-#line 893
     int allInIntRange;
-#line 893
     int canConvert;     /* Both text or both numeric */
-#line 893
-    int value[MAX_NELS];
-#line 893
+    ushort value[MAX_NELS];
     double expect[MAX_NELS];
-#line 893
     int nok = 0;      /* count of valid comparisons */
-#line 893
 
-#line 893
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 893
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 893
 	error("nc_open: %s", nc_strerror(err));
-#line 893
 
-#line 893
-    for (i = -1; i < NVARS; i++) {
-#line 893
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 893
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 893
-	    err = nc_get_att_int(BAD_ID, i, ATT_NAME(i,j), value);
-#line 893
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+	    err = nc_get_att_ushort(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 893
 		error("bad ncid: status = %d", err);
-#line 893
-	    err = nc_get_att_int(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 893
+	    err = nc_get_att_ushort(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 893
 		error("bad var id: status = %d", err);
-#line 893
-	    err = nc_get_att_int(ncid, i, "noSuch", value);
-#line 893
+	    err = nc_get_att_ushort(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 893
 		error("Bad attribute name: status = %d", err);
-#line 893
 	    allInExtRange = allInIntRange = 1;
-#line 893
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 893
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_INT);
-#line 893
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)) {
-#line 893
-                    allInIntRange = allInIntRange && expect[k] >= int_min
-#line 893
-                                && expect[k] <= int_max;
-#line 893
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_USHORT);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_USHORT)) {
+                    allInIntRange = allInIntRange && expect[k] >= ushort_min
+                                && expect[k] <= ushort_max;
                 } else {
-#line 893
                     allInExtRange = 0;
-#line 893
                 }
-#line 893
 	    }
-#line 893
-	    err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
-#line 893
+	    err = nc_get_att_ushort(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 893
                 if (allInExtRange) {
-#line 893
                     if (allInIntRange) {
-#line 893
                         IF (err)
-#line 893
                             error("%s", nc_strerror(err));
-#line 893
                     } else {
-#line 893
                         IF (err != NC_ERANGE)
-#line 893
                             error("Range error: status = %d", err);
-#line 893
                     }
-#line 893
                 } else {
-#line 893
                     IF (err != 0 && err != NC_ERANGE)
-#line 893
                         error("OK or Range error: status = %d", err);
-#line 893
                 }
-#line 893
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 893
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)
-#line 893
-                            && expect[k] >= int_min && expect[k] <= int_max) {
-#line 893
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_INT)){
-#line 893
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_USHORT)
+                            && expect[k] >= ushort_min && expect[k] <= ushort_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_USHORT)){
 			    error("value read not that expected");
-#line 893
                             if (verbose) {
-#line 893
                                 error("\n");
-#line 893
                                 error("varid: %d, ", i);
-#line 893
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 893
                                 error("element number: %d ", k);
-#line 893
                                 error("expect: %g", expect[k]);
-#line 893
                                 error("got: %g", (double) value[k]);
-#line 893
                             }
-#line 893
 			} else {
-#line 893
 			    nok++;
-#line 893
                         }
-#line 893
 		    }
-#line 893
 		}
-#line 893
 	    } else {
-#line 893
 		IF (err != NC_ECHAR)
-#line 893
 		    error("wrong type: status = %d", err);
-#line 893
 	    }
-#line 893
 	}
-#line 893
     }
-#line 893
 
-#line 893
     err = nc_close(ncid);
-#line 893
     IF (err)
-#line 893
 	error("nc_close: %s", nc_strerror(err));
-#line 893
     print_nok(nok);
-#line 893
 }
-#line 893
 
 void
-#line 894
-test_nc_get_att_long(void)
-#line 894
+test_nc_get_att_uint(void)
 {
-#line 894
     int ncid;
-#line 894
     int i;
-#line 894
     int j;
-#line 894
     size_t k;
-#line 894
     int err;
-#line 894
     int allInExtRange;
-#line 894
     int allInIntRange;
-#line 894
     int canConvert;     /* Both text or both numeric */
-#line 894
-    long value[MAX_NELS];
-#line 894
+    uint value[MAX_NELS];
     double expect[MAX_NELS];
-#line 894
     int nok = 0;      /* count of valid comparisons */
-#line 894
 
-#line 894
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 894
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 894
 	error("nc_open: %s", nc_strerror(err));
-#line 894
 
-#line 894
-    for (i = -1; i < NVARS; i++) {
-#line 894
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 894
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 894
-	    err = nc_get_att_long(BAD_ID, i, ATT_NAME(i,j), value);
-#line 894
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+	    err = nc_get_att_uint(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 894
 		error("bad ncid: status = %d", err);
-#line 894
-	    err = nc_get_att_long(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 894
+	    err = nc_get_att_uint(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 894
 		error("bad var id: status = %d", err);
-#line 894
-	    err = nc_get_att_long(ncid, i, "noSuch", value);
-#line 894
+	    err = nc_get_att_uint(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 894
 		error("Bad attribute name: status = %d", err);
-#line 894
 	    allInExtRange = allInIntRange = 1;
-#line 894
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 894
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_LONG);
-#line 894
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)) {
-#line 894
-                    allInIntRange = allInIntRange && expect[k] >= long_min
-#line 894
-                                && expect[k] <= long_max;
-#line 894
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_UINT);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UINT)) {
+                    allInIntRange = allInIntRange && expect[k] >= uint_min
+                                && expect[k] <= uint_max;
                 } else {
-#line 894
                     allInExtRange = 0;
-#line 894
                 }
-#line 894
 	    }
-#line 894
-	    err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
-#line 894
+	    err = nc_get_att_uint(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 894
                 if (allInExtRange) {
-#line 894
                     if (allInIntRange) {
-#line 894
                         IF (err)
-#line 894
                             error("%s", nc_strerror(err));
-#line 894
                     } else {
-#line 894
                         IF (err != NC_ERANGE)
-#line 894
                             error("Range error: status = %d", err);
-#line 894
                     }
-#line 894
                 } else {
-#line 894
                     IF (err != 0 && err != NC_ERANGE)
-#line 894
                         error("OK or Range error: status = %d", err);
-#line 894
                 }
-#line 894
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 894
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)
-#line 894
-                            && expect[k] >= long_min && expect[k] <= long_max) {
-#line 894
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_LONG)){
-#line 894
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UINT)
+                            && expect[k] >= uint_min && expect[k] <= uint_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_UINT)){
 			    error("value read not that expected");
-#line 894
                             if (verbose) {
-#line 894
                                 error("\n");
-#line 894
                                 error("varid: %d, ", i);
-#line 894
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 894
                                 error("element number: %d ", k);
-#line 894
                                 error("expect: %g", expect[k]);
-#line 894
                                 error("got: %g", (double) value[k]);
-#line 894
                             }
-#line 894
 			} else {
-#line 894
 			    nok++;
-#line 894
                         }
-#line 894
 		    }
-#line 894
 		}
-#line 894
 	    } else {
-#line 894
 		IF (err != NC_ECHAR)
-#line 894
 		    error("wrong type: status = %d", err);
-#line 894
 	    }
-#line 894
 	}
-#line 894
     }
-#line 894
 
-#line 894
     err = nc_close(ncid);
-#line 894
     IF (err)
-#line 894
 	error("nc_close: %s", nc_strerror(err));
-#line 894
     print_nok(nok);
-#line 894
 }
-#line 894
 
 void
-#line 895
-test_nc_get_att_float(void)
-#line 895
+test_nc_get_att_longlong(void)
 {
-#line 895
     int ncid;
-#line 895
     int i;
-#line 895
     int j;
-#line 895
     size_t k;
-#line 895
     int err;
-#line 895
     int allInExtRange;
-#line 895
     int allInIntRange;
-#line 895
     int canConvert;     /* Both text or both numeric */
-#line 895
-    float value[MAX_NELS];
-#line 895
+    longlong value[MAX_NELS];
     double expect[MAX_NELS];
-#line 895
     int nok = 0;      /* count of valid comparisons */
-#line 895
 
-#line 895
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 895
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 895
 	error("nc_open: %s", nc_strerror(err));
-#line 895
 
-#line 895
-    for (i = -1; i < NVARS; i++) {
-#line 895
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 895
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 895
-	    err = nc_get_att_float(BAD_ID, i, ATT_NAME(i,j), value);
-#line 895
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+	    err = nc_get_att_longlong(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 895
 		error("bad ncid: status = %d", err);
-#line 895
-	    err = nc_get_att_float(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 895
+	    err = nc_get_att_longlong(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 895
 		error("bad var id: status = %d", err);
-#line 895
-	    err = nc_get_att_float(ncid, i, "noSuch", value);
-#line 895
+	    err = nc_get_att_longlong(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 895
 		error("Bad attribute name: status = %d", err);
-#line 895
 	    allInExtRange = allInIntRange = 1;
-#line 895
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 895
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_FLOAT);
-#line 895
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)) {
-#line 895
-                    allInIntRange = allInIntRange && expect[k] >= float_min
-#line 895
-                                && expect[k] <= float_max;
-#line 895
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_LONGLONG);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONGLONG)) {
+                    allInIntRange = allInIntRange && expect[k] >= longlong_min
+                                && expect[k] <= longlong_max;
                 } else {
-#line 895
                     allInExtRange = 0;
-#line 895
                 }
-#line 895
 	    }
-#line 895
-	    err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
-#line 895
+	    err = nc_get_att_longlong(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 895
                 if (allInExtRange) {
-#line 895
                     if (allInIntRange) {
-#line 895
                         IF (err)
-#line 895
                             error("%s", nc_strerror(err));
-#line 895
                     } else {
-#line 895
                         IF (err != NC_ERANGE)
-#line 895
                             error("Range error: status = %d", err);
-#line 895
                     }
-#line 895
                 } else {
-#line 895
                     IF (err != 0 && err != NC_ERANGE)
-#line 895
                         error("OK or Range error: status = %d", err);
-#line 895
                 }
-#line 895
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 895
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)
-#line 895
-                            && expect[k] >= float_min && expect[k] <= float_max) {
-#line 895
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_FLOAT)){
-#line 895
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONGLONG)
+                            && expect[k] >= longlong_min && expect[k] <= longlong_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_LONGLONG)){
 			    error("value read not that expected");
-#line 895
                             if (verbose) {
-#line 895
                                 error("\n");
-#line 895
                                 error("varid: %d, ", i);
-#line 895
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 895
                                 error("element number: %d ", k);
-#line 895
                                 error("expect: %g", expect[k]);
-#line 895
                                 error("got: %g", (double) value[k]);
-#line 895
                             }
-#line 895
 			} else {
-#line 895
 			    nok++;
-#line 895
                         }
-#line 895
 		    }
-#line 895
 		}
-#line 895
 	    } else {
-#line 895
 		IF (err != NC_ECHAR)
-#line 895
 		    error("wrong type: status = %d", err);
-#line 895
 	    }
-#line 895
 	}
-#line 895
     }
-#line 895
 
-#line 895
     err = nc_close(ncid);
-#line 895
     IF (err)
-#line 895
 	error("nc_close: %s", nc_strerror(err));
-#line 895
     print_nok(nok);
-#line 895
 }
-#line 895
 
 void
-#line 896
-test_nc_get_att_double(void)
-#line 896
+test_nc_get_att_ulonglong(void)
 {
-#line 896
     int ncid;
-#line 896
     int i;
-#line 896
     int j;
-#line 896
     size_t k;
-#line 896
     int err;
-#line 896
     int allInExtRange;
-#line 896
     int allInIntRange;
-#line 896
     int canConvert;     /* Both text or both numeric */
-#line 896
-    double value[MAX_NELS];
-#line 896
+    ulonglong value[MAX_NELS];
     double expect[MAX_NELS];
-#line 896
     int nok = 0;      /* count of valid comparisons */
-#line 896
 
-#line 896
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
-#line 896
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
-#line 896
 	error("nc_open: %s", nc_strerror(err));
-#line 896
 
-#line 896
-    for (i = -1; i < NVARS; i++) {
-#line 896
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 896
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 896
-	    err = nc_get_att_double(BAD_ID, i, ATT_NAME(i,j), value);
-#line 896
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+	    err = nc_get_att_ulonglong(BAD_ID, i, ATT_NAME(i,j), value);
 	    IF (err != NC_EBADID) 
-#line 896
 		error("bad ncid: status = %d", err);
-#line 896
-	    err = nc_get_att_double(ncid, BAD_VARID, ATT_NAME(i,j), value);
-#line 896
+	    err = nc_get_att_ulonglong(ncid, BAD_VARID, ATT_NAME(i,j), value);
 	    IF (err != NC_ENOTVAR) 
-#line 896
 		error("bad var id: status = %d", err);
-#line 896
-	    err = nc_get_att_double(ncid, i, "noSuch", value);
-#line 896
+	    err = nc_get_att_ulonglong(ncid, i, "noSuch", value);
 	    IF (err != NC_ENOTATT) 
-#line 896
 		error("Bad attribute name: status = %d", err);
-#line 896
 	    allInExtRange = allInIntRange = 1;
-#line 896
             for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 896
-		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE);
-#line 896
-                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)) {
-#line 896
-                    allInIntRange = allInIntRange && expect[k] >= double_min
-#line 896
-                                && expect[k] <= double_max;
-#line 896
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_ULONGLONG);
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ULONGLONG)) {
+                    allInIntRange = allInIntRange && expect[k] >= ulonglong_min
+                                && expect[k] <= ulonglong_max;
                 } else {
-#line 896
                     allInExtRange = 0;
-#line 896
                 }
-#line 896
 	    }
-#line 896
-	    err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
-#line 896
+	    err = nc_get_att_ulonglong(ncid, i, ATT_NAME(i,j), value);
             if (canConvert || ATT_LEN(i,j) == 0) {
-#line 896
                 if (allInExtRange) {
-#line 896
                     if (allInIntRange) {
-#line 896
                         IF (err)
-#line 896
                             error("%s", nc_strerror(err));
-#line 896
                     } else {
-#line 896
                         IF (err != NC_ERANGE)
-#line 896
                             error("Range error: status = %d", err);
-#line 896
                     }
-#line 896
                 } else {
-#line 896
                     IF (err != 0 && err != NC_ERANGE)
-#line 896
                         error("OK or Range error: status = %d", err);
-#line 896
                 }
-#line 896
 		for (k = 0; k < ATT_LEN(i,j); k++) {
-#line 896
-		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)
-#line 896
-                            && expect[k] >= double_min && expect[k] <= double_max) {
-#line 896
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_DOUBLE)){
-#line 896
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ULONGLONG)
+                            && expect[k] >= ulonglong_min && expect[k] <= ulonglong_max) {
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_ULONGLONG)){
 			    error("value read not that expected");
-#line 896
                             if (verbose) {
-#line 896
                                 error("\n");
-#line 896
                                 error("varid: %d, ", i);
-#line 896
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 896
                                 error("element number: %d ", k);
-#line 896
                                 error("expect: %g", expect[k]);
-#line 896
                                 error("got: %g", (double) value[k]);
-#line 896
                             }
-#line 896
 			} else {
-#line 896
 			    nok++;
-#line 896
                         }
-#line 896
 		    }
-#line 896
 		}
-#line 896
 	    } else {
-#line 896
 		IF (err != NC_ECHAR)
-#line 896
 		    error("wrong type: status = %d", err);
-#line 896
 	    }
-#line 896
 	}
-#line 896
     }
-#line 896
 
-#line 896
     err = nc_close(ncid);
-#line 896
     IF (err)
-#line 896
 	error("nc_close: %s", nc_strerror(err));
-#line 896
     print_nok(nok);
-#line 896
 }
-#line 896
 
 
diff --git a/nc_test/test_get.m4 b/nc_test/test_get.m4
index d8b6696..3b77f9c 100644
--- a/nc_test/test_get.m4
+++ b/nc_test/test_get.m4
@@ -7,9 +7,13 @@ dnl
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_get.m4,v 1.16 2005/03/08 03:04:19 ed Exp $
+ *   $Id: test_get.m4 2785 2014-10-26 05:21:20Z wkliao $
  *********************************************************************/
 
+#ifdef USE_PARALLEL
+#include <mpi.h>
+#endif
+
 undefine(`index')dnl
 dnl dnl dnl
 dnl
@@ -48,10 +52,10 @@ test_nc_get_var1_$1(void)
     int canConvert;     /* Both text or both numeric */
     $1 value;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	for (j = 0; j < var_rank[i]; j++)
 	    index[j] = 0;
@@ -122,6 +126,10 @@ TEST_NC_GET_VAR1(int)
 TEST_NC_GET_VAR1(long)
 TEST_NC_GET_VAR1(float)
 TEST_NC_GET_VAR1(double)
+TEST_NC_GET_VAR1(ushort)
+TEST_NC_GET_VAR1(uint)
+TEST_NC_GET_VAR1(longlong)
+TEST_NC_GET_VAR1(ulonglong)
 
 
 dnl TEST_NC_GET_VAR(TYPE)
@@ -144,10 +152,10 @@ test_nc_get_var_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -227,6 +235,10 @@ TEST_NC_GET_VAR(int)
 TEST_NC_GET_VAR(long)
 TEST_NC_GET_VAR(float)
 TEST_NC_GET_VAR(double)
+TEST_NC_GET_VAR(ushort)
+TEST_NC_GET_VAR(uint)
+TEST_NC_GET_VAR(longlong)
+TEST_NC_GET_VAR(ulonglong)
 
 
 dnl TEST_NC_GET_VARA(TYPE)
@@ -255,10 +267,10 @@ test_nc_get_vara_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -407,6 +419,10 @@ TEST_NC_GET_VARA(int)
 TEST_NC_GET_VARA(long)
 TEST_NC_GET_VARA(float)
 TEST_NC_GET_VARA(double)
+TEST_NC_GET_VARA(ushort)
+TEST_NC_GET_VARA(uint)
+TEST_NC_GET_VARA(longlong)
+TEST_NC_GET_VARA(ulonglong)
 
 
 dnl TEST_NC_GET_VARS(TYPE)
@@ -441,10 +457,10 @@ test_nc_get_vars_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -596,6 +612,10 @@ TEST_NC_GET_VARS(int)
 TEST_NC_GET_VARS(long)
 TEST_NC_GET_VARS(float)
 TEST_NC_GET_VARS(double)
+TEST_NC_GET_VARS(ushort)
+TEST_NC_GET_VARS(uint)
+TEST_NC_GET_VARS(longlong)
+TEST_NC_GET_VARS(ulonglong)
 
 
 dnl TEST_NC_GET_VARM(TYPE)
@@ -631,10 +651,10 @@ test_nc_get_varm_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -793,6 +813,10 @@ TEST_NC_GET_VARM(int)
 TEST_NC_GET_VARM(long)
 TEST_NC_GET_VARM(float)
 TEST_NC_GET_VARM(double)
+TEST_NC_GET_VARM(ushort)
+TEST_NC_GET_VARM(uint)
+TEST_NC_GET_VARM(longlong)
+TEST_NC_GET_VARM(ulonglong)
 
 
 dnl TEST_NC_GET_ATT(TYPE)
@@ -814,11 +838,11 @@ test_nc_get_att_$1(void)
     double expect[MAX_NELS];
     int nok = 0;      /* count of valid comparisons */
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
 	error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
 	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	    err = nc_get_att_$1(BAD_ID, i, ATT_NAME(i,j), value);
@@ -894,4 +918,8 @@ TEST_NC_GET_ATT(int)
 TEST_NC_GET_ATT(long)
 TEST_NC_GET_ATT(float)
 TEST_NC_GET_ATT(double)
+TEST_NC_GET_ATT(ushort)
+TEST_NC_GET_ATT(uint)
+TEST_NC_GET_ATT(longlong)
+TEST_NC_GET_ATT(ulonglong)
 
diff --git a/nc_test/test_get_p5.c b/nc_test/test_get_p5.c
new file mode 100644
index 0000000..1e0607d
--- /dev/null
+++ b/nc_test/test_get_p5.c
@@ -0,0 +1,19215 @@
+#line 5 "test_get_p5.m4"
+/* Do not edit this file. It is produced from the corresponding .m4 source */
+#line 7
+/*********************************************************************
+ *   Copyright 1996, UCAR/Unidata
+ *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
+ *   $Id: test_get.m4 2785 2014-10-26 05:21:20Z wkliao $
+ *********************************************************************/
+
+// #define TEST_PNETCDF
+#include <mpi.h>
+
+#line 34
+
+#include "tests.h"
+
+#line 123
+
+void
+#line 124
+test_nc_get_var1_text(void)
+#line 124
+{
+#line 124
+    int ncid;
+#line 124
+    int i;
+#line 124
+    int j;
+#line 124
+    int err;
+#line 124
+    int nok = 0;      /* count of valid comparisons */
+#line 124
+    size_t index[MAX_RANK];
+#line 124
+    double expect;
+#line 124
+    int canConvert;     /* Both text or both numeric */
+#line 124
+    text value;
+#line 124
+
+#line 124
+#ifdef TEST_PNETCDF
+#line 124
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 124
+#else
+#line 124
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 124
+#endif
+#line 124
+    IF (err)
+#line 124
+	error("nc_open: %s", nc_strerror(err));
+#line 124
+    for (i = 0; i < numVars; i++) {
+#line 124
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+#line 124
+	for (j = 0; j < var_rank[i]; j++)
+#line 124
+	    index[j] = 0;
+#line 124
+        err = nc_get_var1_text(BAD_ID, i, index, &value);
+#line 124
+        IF (err != NC_EBADID)
+#line 124
+	    error("bad ncid: status = %d", err);
+#line 124
+        err = nc_get_var1_text(ncid, BAD_VARID, index, &value);
+#line 124
+        IF (err != NC_ENOTVAR)
+#line 124
+	    error("bad var id: status = %d", err);
+#line 124
+	for (j = 0; j < var_rank[i]; j++) {
+#line 124
+	    index[j] = var_shape[i][j];
+#line 124
+	    err = nc_get_var1_text(ncid, i, index, &value);
+#line 124
+	    if(!canConvert) {
+#line 124
+		IF(err != NC_ECHAR)
+#line 124
+			error("conversion: status = %d", err);
+#line 124
+	    } else IF (err != NC_EINVALCOORDS)
+#line 124
+		error("bad index: status = %d", err);
+#line 124
+	    index[j] = 0;
+#line 124
+	}
+#line 124
+	for (j = 0; j < var_nels[i]; j++) {
+#line 124
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 124
+	    IF (err)
+#line 124
+		error("error in toMixedBase 1");
+#line 124
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_TEXT );
+#line 124
+	    if (var_rank[i] == 0 && i%2 )
+#line 124
+		err = nc_get_var1_text(ncid, i, NULL, &value);
+#line 124
+	    else
+#line 124
+		err = nc_get_var1_text(ncid, i, index, &value);
+#line 124
+            if (canConvert) {
+#line 124
+		if (inRange3(expect,var_type[i], NCT_TEXT)) {
+#line 124
+		    if (expect >= text_min && expect <= text_max) {
+#line 124
+			IF (err) {
+#line 124
+			    error("%s", nc_strerror(err));
+#line 124
+			} else {
+#line 124
+			    IF (!equal(value,expect,var_type[i],NCT_TEXT)) {
+#line 124
+				error("expected: %G, got: %G", expect,
+#line 124
+				    (double) value);
+#line 124
+			    } else {
+#line 124
+				nok++;
+#line 124
+			    }
+#line 124
+			}
+#line 124
+		    } else {
+#line 124
+			IF (err != NC_ERANGE)
+#line 124
+			    error("Range error: status = %d", err);
+#line 124
+		    }
+#line 124
+                } else {
+#line 124
+                    IF (err != 0 && err != NC_ERANGE)
+#line 124
+                        error("OK or Range error: status = %d", err);
+#line 124
+		}
+#line 124
+	    } else {
+#line 124
+		IF (err != NC_ECHAR)
+#line 124
+		    error("wrong type: status = %d", err);
+#line 124
+	    }
+#line 124
+	}
+#line 124
+    }
+#line 124
+    err = nc_close(ncid);
+#line 124
+    IF (err)
+#line 124
+	error("nc_close: %s", nc_strerror(err));
+#line 124
+    print_nok(nok);
+#line 124
+}
+#line 124
+
+void
+#line 125
+test_nc_get_var1_uchar(void)
+#line 125
+{
+#line 125
+    int ncid;
+#line 125
+    int i;
+#line 125
+    int j;
+#line 125
+    int err;
+#line 125
+    int nok = 0;      /* count of valid comparisons */
+#line 125
+    size_t index[MAX_RANK];
+#line 125
+    double expect;
+#line 125
+    int canConvert;     /* Both text or both numeric */
+#line 125
+    uchar value;
+#line 125
+
+#line 125
+#ifdef TEST_PNETCDF
+#line 125
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 125
+#else
+#line 125
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 125
+#endif
+#line 125
+    IF (err)
+#line 125
+	error("nc_open: %s", nc_strerror(err));
+#line 125
+    for (i = 0; i < numVars; i++) {
+#line 125
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+#line 125
+	for (j = 0; j < var_rank[i]; j++)
+#line 125
+	    index[j] = 0;
+#line 125
+        err = nc_get_var1_uchar(BAD_ID, i, index, &value);
+#line 125
+        IF (err != NC_EBADID)
+#line 125
+	    error("bad ncid: status = %d", err);
+#line 125
+        err = nc_get_var1_uchar(ncid, BAD_VARID, index, &value);
+#line 125
+        IF (err != NC_ENOTVAR)
+#line 125
+	    error("bad var id: status = %d", err);
+#line 125
+	for (j = 0; j < var_rank[i]; j++) {
+#line 125
+	    index[j] = var_shape[i][j];
+#line 125
+	    err = nc_get_var1_uchar(ncid, i, index, &value);
+#line 125
+	    if(!canConvert) {
+#line 125
+		IF(err != NC_ECHAR)
+#line 125
+			error("conversion: status = %d", err);
+#line 125
+	    } else IF (err != NC_EINVALCOORDS)
+#line 125
+		error("bad index: status = %d", err);
+#line 125
+	    index[j] = 0;
+#line 125
+	}
+#line 125
+	for (j = 0; j < var_nels[i]; j++) {
+#line 125
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 125
+	    IF (err)
+#line 125
+		error("error in toMixedBase 1");
+#line 125
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_UCHAR );
+#line 125
+	    if (var_rank[i] == 0 && i%2 )
+#line 125
+		err = nc_get_var1_uchar(ncid, i, NULL, &value);
+#line 125
+	    else
+#line 125
+		err = nc_get_var1_uchar(ncid, i, index, &value);
+#line 125
+            if (canConvert) {
+#line 125
+		if (inRange3(expect,var_type[i], NCT_UCHAR)) {
+#line 125
+		    if (expect >= uchar_min && expect <= uchar_max) {
+#line 125
+			IF (err) {
+#line 125
+			    error("%s", nc_strerror(err));
+#line 125
+			} else {
+#line 125
+			    IF (!equal(value,expect,var_type[i],NCT_UCHAR)) {
+#line 125
+				error("expected: %G, got: %G", expect,
+#line 125
+				    (double) value);
+#line 125
+			    } else {
+#line 125
+				nok++;
+#line 125
+			    }
+#line 125
+			}
+#line 125
+		    } else {
+#line 125
+			IF (err != NC_ERANGE)
+#line 125
+			    error("Range error: status = %d", err);
+#line 125
+		    }
+#line 125
+                } else {
+#line 125
+                    IF (err != 0 && err != NC_ERANGE)
+#line 125
+                        error("OK or Range error: status = %d", err);
+#line 125
+		}
+#line 125
+	    } else {
+#line 125
+		IF (err != NC_ECHAR)
+#line 125
+		    error("wrong type: status = %d", err);
+#line 125
+	    }
+#line 125
+	}
+#line 125
+    }
+#line 125
+    err = nc_close(ncid);
+#line 125
+    IF (err)
+#line 125
+	error("nc_close: %s", nc_strerror(err));
+#line 125
+    print_nok(nok);
+#line 125
+}
+#line 125
+
+void
+#line 126
+test_nc_get_var1_schar(void)
+#line 126
+{
+#line 126
+    int ncid;
+#line 126
+    int i;
+#line 126
+    int j;
+#line 126
+    int err;
+#line 126
+    int nok = 0;      /* count of valid comparisons */
+#line 126
+    size_t index[MAX_RANK];
+#line 126
+    double expect;
+#line 126
+    int canConvert;     /* Both text or both numeric */
+#line 126
+    schar value;
+#line 126
+
+#line 126
+#ifdef TEST_PNETCDF
+#line 126
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 126
+#else
+#line 126
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 126
+#endif
+#line 126
+    IF (err)
+#line 126
+	error("nc_open: %s", nc_strerror(err));
+#line 126
+    for (i = 0; i < numVars; i++) {
+#line 126
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+#line 126
+	for (j = 0; j < var_rank[i]; j++)
+#line 126
+	    index[j] = 0;
+#line 126
+        err = nc_get_var1_schar(BAD_ID, i, index, &value);
+#line 126
+        IF (err != NC_EBADID)
+#line 126
+	    error("bad ncid: status = %d", err);
+#line 126
+        err = nc_get_var1_schar(ncid, BAD_VARID, index, &value);
+#line 126
+        IF (err != NC_ENOTVAR)
+#line 126
+	    error("bad var id: status = %d", err);
+#line 126
+	for (j = 0; j < var_rank[i]; j++) {
+#line 126
+	    index[j] = var_shape[i][j];
+#line 126
+	    err = nc_get_var1_schar(ncid, i, index, &value);
+#line 126
+	    if(!canConvert) {
+#line 126
+		IF(err != NC_ECHAR)
+#line 126
+			error("conversion: status = %d", err);
+#line 126
+	    } else IF (err != NC_EINVALCOORDS)
+#line 126
+		error("bad index: status = %d", err);
+#line 126
+	    index[j] = 0;
+#line 126
+	}
+#line 126
+	for (j = 0; j < var_nels[i]; j++) {
+#line 126
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 126
+	    IF (err)
+#line 126
+		error("error in toMixedBase 1");
+#line 126
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_SCHAR );
+#line 126
+	    if (var_rank[i] == 0 && i%2 )
+#line 126
+		err = nc_get_var1_schar(ncid, i, NULL, &value);
+#line 126
+	    else
+#line 126
+		err = nc_get_var1_schar(ncid, i, index, &value);
+#line 126
+            if (canConvert) {
+#line 126
+		if (inRange3(expect,var_type[i], NCT_SCHAR)) {
+#line 126
+		    if (expect >= schar_min && expect <= schar_max) {
+#line 126
+			IF (err) {
+#line 126
+			    error("%s", nc_strerror(err));
+#line 126
+			} else {
+#line 126
+			    IF (!equal(value,expect,var_type[i],NCT_SCHAR)) {
+#line 126
+				error("expected: %G, got: %G", expect,
+#line 126
+				    (double) value);
+#line 126
+			    } else {
+#line 126
+				nok++;
+#line 126
+			    }
+#line 126
+			}
+#line 126
+		    } else {
+#line 126
+			IF (err != NC_ERANGE)
+#line 126
+			    error("Range error: status = %d", err);
+#line 126
+		    }
+#line 126
+                } else {
+#line 126
+                    IF (err != 0 && err != NC_ERANGE)
+#line 126
+                        error("OK or Range error: status = %d", err);
+#line 126
+		}
+#line 126
+	    } else {
+#line 126
+		IF (err != NC_ECHAR)
+#line 126
+		    error("wrong type: status = %d", err);
+#line 126
+	    }
+#line 126
+	}
+#line 126
+    }
+#line 126
+    err = nc_close(ncid);
+#line 126
+    IF (err)
+#line 126
+	error("nc_close: %s", nc_strerror(err));
+#line 126
+    print_nok(nok);
+#line 126
+}
+#line 126
+
+void
+#line 127
+test_nc_get_var1_short(void)
+#line 127
+{
+#line 127
+    int ncid;
+#line 127
+    int i;
+#line 127
+    int j;
+#line 127
+    int err;
+#line 127
+    int nok = 0;      /* count of valid comparisons */
+#line 127
+    size_t index[MAX_RANK];
+#line 127
+    double expect;
+#line 127
+    int canConvert;     /* Both text or both numeric */
+#line 127
+    short value;
+#line 127
+
+#line 127
+#ifdef TEST_PNETCDF
+#line 127
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 127
+#else
+#line 127
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 127
+#endif
+#line 127
+    IF (err)
+#line 127
+	error("nc_open: %s", nc_strerror(err));
+#line 127
+    for (i = 0; i < numVars; i++) {
+#line 127
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+#line 127
+	for (j = 0; j < var_rank[i]; j++)
+#line 127
+	    index[j] = 0;
+#line 127
+        err = nc_get_var1_short(BAD_ID, i, index, &value);
+#line 127
+        IF (err != NC_EBADID)
+#line 127
+	    error("bad ncid: status = %d", err);
+#line 127
+        err = nc_get_var1_short(ncid, BAD_VARID, index, &value);
+#line 127
+        IF (err != NC_ENOTVAR)
+#line 127
+	    error("bad var id: status = %d", err);
+#line 127
+	for (j = 0; j < var_rank[i]; j++) {
+#line 127
+	    index[j] = var_shape[i][j];
+#line 127
+	    err = nc_get_var1_short(ncid, i, index, &value);
+#line 127
+	    if(!canConvert) {
+#line 127
+		IF(err != NC_ECHAR)
+#line 127
+			error("conversion: status = %d", err);
+#line 127
+	    } else IF (err != NC_EINVALCOORDS)
+#line 127
+		error("bad index: status = %d", err);
+#line 127
+	    index[j] = 0;
+#line 127
+	}
+#line 127
+	for (j = 0; j < var_nels[i]; j++) {
+#line 127
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 127
+	    IF (err)
+#line 127
+		error("error in toMixedBase 1");
+#line 127
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_SHORT );
+#line 127
+	    if (var_rank[i] == 0 && i%2 )
+#line 127
+		err = nc_get_var1_short(ncid, i, NULL, &value);
+#line 127
+	    else
+#line 127
+		err = nc_get_var1_short(ncid, i, index, &value);
+#line 127
+            if (canConvert) {
+#line 127
+		if (inRange3(expect,var_type[i], NCT_SHORT)) {
+#line 127
+		    if (expect >= short_min && expect <= short_max) {
+#line 127
+			IF (err) {
+#line 127
+			    error("%s", nc_strerror(err));
+#line 127
+			} else {
+#line 127
+			    IF (!equal(value,expect,var_type[i],NCT_SHORT)) {
+#line 127
+				error("expected: %G, got: %G", expect,
+#line 127
+				    (double) value);
+#line 127
+			    } else {
+#line 127
+				nok++;
+#line 127
+			    }
+#line 127
+			}
+#line 127
+		    } else {
+#line 127
+			IF (err != NC_ERANGE)
+#line 127
+			    error("Range error: status = %d", err);
+#line 127
+		    }
+#line 127
+                } else {
+#line 127
+                    IF (err != 0 && err != NC_ERANGE)
+#line 127
+                        error("OK or Range error: status = %d", err);
+#line 127
+		}
+#line 127
+	    } else {
+#line 127
+		IF (err != NC_ECHAR)
+#line 127
+		    error("wrong type: status = %d", err);
+#line 127
+	    }
+#line 127
+	}
+#line 127
+    }
+#line 127
+    err = nc_close(ncid);
+#line 127
+    IF (err)
+#line 127
+	error("nc_close: %s", nc_strerror(err));
+#line 127
+    print_nok(nok);
+#line 127
+}
+#line 127
+
+void
+#line 128
+test_nc_get_var1_int(void)
+#line 128
+{
+#line 128
+    int ncid;
+#line 128
+    int i;
+#line 128
+    int j;
+#line 128
+    int err;
+#line 128
+    int nok = 0;      /* count of valid comparisons */
+#line 128
+    size_t index[MAX_RANK];
+#line 128
+    double expect;
+#line 128
+    int canConvert;     /* Both text or both numeric */
+#line 128
+    int value;
+#line 128
+
+#line 128
+#ifdef TEST_PNETCDF
+#line 128
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 128
+#else
+#line 128
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 128
+#endif
+#line 128
+    IF (err)
+#line 128
+	error("nc_open: %s", nc_strerror(err));
+#line 128
+    for (i = 0; i < numVars; i++) {
+#line 128
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+#line 128
+	for (j = 0; j < var_rank[i]; j++)
+#line 128
+	    index[j] = 0;
+#line 128
+        err = nc_get_var1_int(BAD_ID, i, index, &value);
+#line 128
+        IF (err != NC_EBADID)
+#line 128
+	    error("bad ncid: status = %d", err);
+#line 128
+        err = nc_get_var1_int(ncid, BAD_VARID, index, &value);
+#line 128
+        IF (err != NC_ENOTVAR)
+#line 128
+	    error("bad var id: status = %d", err);
+#line 128
+	for (j = 0; j < var_rank[i]; j++) {
+#line 128
+	    index[j] = var_shape[i][j];
+#line 128
+	    err = nc_get_var1_int(ncid, i, index, &value);
+#line 128
+	    if(!canConvert) {
+#line 128
+		IF(err != NC_ECHAR)
+#line 128
+			error("conversion: status = %d", err);
+#line 128
+	    } else IF (err != NC_EINVALCOORDS)
+#line 128
+		error("bad index: status = %d", err);
+#line 128
+	    index[j] = 0;
+#line 128
+	}
+#line 128
+	for (j = 0; j < var_nels[i]; j++) {
+#line 128
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 128
+	    IF (err)
+#line 128
+		error("error in toMixedBase 1");
+#line 128
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_INT );
+#line 128
+	    if (var_rank[i] == 0 && i%2 )
+#line 128
+		err = nc_get_var1_int(ncid, i, NULL, &value);
+#line 128
+	    else
+#line 128
+		err = nc_get_var1_int(ncid, i, index, &value);
+#line 128
+            if (canConvert) {
+#line 128
+		if (inRange3(expect,var_type[i], NCT_INT)) {
+#line 128
+		    if (expect >= int_min && expect <= int_max) {
+#line 128
+			IF (err) {
+#line 128
+			    error("%s", nc_strerror(err));
+#line 128
+			} else {
+#line 128
+			    IF (!equal(value,expect,var_type[i],NCT_INT)) {
+#line 128
+				error("expected: %G, got: %G", expect,
+#line 128
+				    (double) value);
+#line 128
+			    } else {
+#line 128
+				nok++;
+#line 128
+			    }
+#line 128
+			}
+#line 128
+		    } else {
+#line 128
+			IF (err != NC_ERANGE)
+#line 128
+			    error("Range error: status = %d", err);
+#line 128
+		    }
+#line 128
+                } else {
+#line 128
+                    IF (err != 0 && err != NC_ERANGE)
+#line 128
+                        error("OK or Range error: status = %d", err);
+#line 128
+		}
+#line 128
+	    } else {
+#line 128
+		IF (err != NC_ECHAR)
+#line 128
+		    error("wrong type: status = %d", err);
+#line 128
+	    }
+#line 128
+	}
+#line 128
+    }
+#line 128
+    err = nc_close(ncid);
+#line 128
+    IF (err)
+#line 128
+	error("nc_close: %s", nc_strerror(err));
+#line 128
+    print_nok(nok);
+#line 128
+}
+#line 128
+
+void
+#line 129
+test_nc_get_var1_long(void)
+#line 129
+{
+#line 129
+    int ncid;
+#line 129
+    int i;
+#line 129
+    int j;
+#line 129
+    int err;
+#line 129
+    int nok = 0;      /* count of valid comparisons */
+#line 129
+    size_t index[MAX_RANK];
+#line 129
+    double expect;
+#line 129
+    int canConvert;     /* Both text or both numeric */
+#line 129
+    long value;
+#line 129
+
+#line 129
+#ifdef TEST_PNETCDF
+#line 129
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 129
+#else
+#line 129
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 129
+#endif
+#line 129
+    IF (err)
+#line 129
+	error("nc_open: %s", nc_strerror(err));
+#line 129
+    for (i = 0; i < numVars; i++) {
+#line 129
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+#line 129
+	for (j = 0; j < var_rank[i]; j++)
+#line 129
+	    index[j] = 0;
+#line 129
+        err = nc_get_var1_long(BAD_ID, i, index, &value);
+#line 129
+        IF (err != NC_EBADID)
+#line 129
+	    error("bad ncid: status = %d", err);
+#line 129
+        err = nc_get_var1_long(ncid, BAD_VARID, index, &value);
+#line 129
+        IF (err != NC_ENOTVAR)
+#line 129
+	    error("bad var id: status = %d", err);
+#line 129
+	for (j = 0; j < var_rank[i]; j++) {
+#line 129
+	    index[j] = var_shape[i][j];
+#line 129
+	    err = nc_get_var1_long(ncid, i, index, &value);
+#line 129
+	    if(!canConvert) {
+#line 129
+		IF(err != NC_ECHAR)
+#line 129
+			error("conversion: status = %d", err);
+#line 129
+	    } else IF (err != NC_EINVALCOORDS)
+#line 129
+		error("bad index: status = %d", err);
+#line 129
+	    index[j] = 0;
+#line 129
+	}
+#line 129
+	for (j = 0; j < var_nels[i]; j++) {
+#line 129
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 129
+	    IF (err)
+#line 129
+		error("error in toMixedBase 1");
+#line 129
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_LONG );
+#line 129
+	    if (var_rank[i] == 0 && i%2 )
+#line 129
+		err = nc_get_var1_long(ncid, i, NULL, &value);
+#line 129
+	    else
+#line 129
+		err = nc_get_var1_long(ncid, i, index, &value);
+#line 129
+            if (canConvert) {
+#line 129
+		if (inRange3(expect,var_type[i], NCT_LONG)) {
+#line 129
+		    if (expect >= long_min && expect <= long_max) {
+#line 129
+			IF (err) {
+#line 129
+			    error("%s", nc_strerror(err));
+#line 129
+			} else {
+#line 129
+			    IF (!equal(value,expect,var_type[i],NCT_LONG)) {
+#line 129
+				error("expected: %G, got: %G", expect,
+#line 129
+				    (double) value);
+#line 129
+			    } else {
+#line 129
+				nok++;
+#line 129
+			    }
+#line 129
+			}
+#line 129
+		    } else {
+#line 129
+			IF (err != NC_ERANGE)
+#line 129
+			    error("Range error: status = %d", err);
+#line 129
+		    }
+#line 129
+                } else {
+#line 129
+                    IF (err != 0 && err != NC_ERANGE)
+#line 129
+                        error("OK or Range error: status = %d", err);
+#line 129
+		}
+#line 129
+	    } else {
+#line 129
+		IF (err != NC_ECHAR)
+#line 129
+		    error("wrong type: status = %d", err);
+#line 129
+	    }
+#line 129
+	}
+#line 129
+    }
+#line 129
+    err = nc_close(ncid);
+#line 129
+    IF (err)
+#line 129
+	error("nc_close: %s", nc_strerror(err));
+#line 129
+    print_nok(nok);
+#line 129
+}
+#line 129
+
+void
+#line 130
+test_nc_get_var1_float(void)
+#line 130
+{
+#line 130
+    int ncid;
+#line 130
+    int i;
+#line 130
+    int j;
+#line 130
+    int err;
+#line 130
+    int nok = 0;      /* count of valid comparisons */
+#line 130
+    size_t index[MAX_RANK];
+#line 130
+    double expect;
+#line 130
+    int canConvert;     /* Both text or both numeric */
+#line 130
+    float value;
+#line 130
+
+#line 130
+#ifdef TEST_PNETCDF
+#line 130
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 130
+#else
+#line 130
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 130
+#endif
+#line 130
+    IF (err)
+#line 130
+	error("nc_open: %s", nc_strerror(err));
+#line 130
+    for (i = 0; i < numVars; i++) {
+#line 130
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+#line 130
+	for (j = 0; j < var_rank[i]; j++)
+#line 130
+	    index[j] = 0;
+#line 130
+        err = nc_get_var1_float(BAD_ID, i, index, &value);
+#line 130
+        IF (err != NC_EBADID)
+#line 130
+	    error("bad ncid: status = %d", err);
+#line 130
+        err = nc_get_var1_float(ncid, BAD_VARID, index, &value);
+#line 130
+        IF (err != NC_ENOTVAR)
+#line 130
+	    error("bad var id: status = %d", err);
+#line 130
+	for (j = 0; j < var_rank[i]; j++) {
+#line 130
+	    index[j] = var_shape[i][j];
+#line 130
+	    err = nc_get_var1_float(ncid, i, index, &value);
+#line 130
+	    if(!canConvert) {
+#line 130
+		IF(err != NC_ECHAR)
+#line 130
+			error("conversion: status = %d", err);
+#line 130
+	    } else IF (err != NC_EINVALCOORDS)
+#line 130
+		error("bad index: status = %d", err);
+#line 130
+	    index[j] = 0;
+#line 130
+	}
+#line 130
+	for (j = 0; j < var_nels[i]; j++) {
+#line 130
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 130
+	    IF (err)
+#line 130
+		error("error in toMixedBase 1");
+#line 130
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_FLOAT );
+#line 130
+	    if (var_rank[i] == 0 && i%2 )
+#line 130
+		err = nc_get_var1_float(ncid, i, NULL, &value);
+#line 130
+	    else
+#line 130
+		err = nc_get_var1_float(ncid, i, index, &value);
+#line 130
+            if (canConvert) {
+#line 130
+		if (inRange3(expect,var_type[i], NCT_FLOAT)) {
+#line 130
+		    if (expect >= float_min && expect <= float_max) {
+#line 130
+			IF (err) {
+#line 130
+			    error("%s", nc_strerror(err));
+#line 130
+			} else {
+#line 130
+			    IF (!equal(value,expect,var_type[i],NCT_FLOAT)) {
+#line 130
+				error("expected: %G, got: %G", expect,
+#line 130
+				    (double) value);
+#line 130
+			    } else {
+#line 130
+				nok++;
+#line 130
+			    }
+#line 130
+			}
+#line 130
+		    } else {
+#line 130
+			IF (err != NC_ERANGE)
+#line 130
+			    error("Range error: status = %d", err);
+#line 130
+		    }
+#line 130
+                } else {
+#line 130
+                    IF (err != 0 && err != NC_ERANGE)
+#line 130
+                        error("OK or Range error: status = %d", err);
+#line 130
+		}
+#line 130
+	    } else {
+#line 130
+		IF (err != NC_ECHAR)
+#line 130
+		    error("wrong type: status = %d", err);
+#line 130
+	    }
+#line 130
+	}
+#line 130
+    }
+#line 130
+    err = nc_close(ncid);
+#line 130
+    IF (err)
+#line 130
+	error("nc_close: %s", nc_strerror(err));
+#line 130
+    print_nok(nok);
+#line 130
+}
+#line 130
+
+void
+#line 131
+test_nc_get_var1_double(void)
+#line 131
+{
+#line 131
+    int ncid;
+#line 131
+    int i;
+#line 131
+    int j;
+#line 131
+    int err;
+#line 131
+    int nok = 0;      /* count of valid comparisons */
+#line 131
+    size_t index[MAX_RANK];
+#line 131
+    double expect;
+#line 131
+    int canConvert;     /* Both text or both numeric */
+#line 131
+    double value;
+#line 131
+
+#line 131
+#ifdef TEST_PNETCDF
+#line 131
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 131
+#else
+#line 131
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 131
+#endif
+#line 131
+    IF (err)
+#line 131
+	error("nc_open: %s", nc_strerror(err));
+#line 131
+    for (i = 0; i < numVars; i++) {
+#line 131
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+#line 131
+	for (j = 0; j < var_rank[i]; j++)
+#line 131
+	    index[j] = 0;
+#line 131
+        err = nc_get_var1_double(BAD_ID, i, index, &value);
+#line 131
+        IF (err != NC_EBADID)
+#line 131
+	    error("bad ncid: status = %d", err);
+#line 131
+        err = nc_get_var1_double(ncid, BAD_VARID, index, &value);
+#line 131
+        IF (err != NC_ENOTVAR)
+#line 131
+	    error("bad var id: status = %d", err);
+#line 131
+	for (j = 0; j < var_rank[i]; j++) {
+#line 131
+	    index[j] = var_shape[i][j];
+#line 131
+	    err = nc_get_var1_double(ncid, i, index, &value);
+#line 131
+	    if(!canConvert) {
+#line 131
+		IF(err != NC_ECHAR)
+#line 131
+			error("conversion: status = %d", err);
+#line 131
+	    } else IF (err != NC_EINVALCOORDS)
+#line 131
+		error("bad index: status = %d", err);
+#line 131
+	    index[j] = 0;
+#line 131
+	}
+#line 131
+	for (j = 0; j < var_nels[i]; j++) {
+#line 131
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 131
+	    IF (err)
+#line 131
+		error("error in toMixedBase 1");
+#line 131
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_DOUBLE );
+#line 131
+	    if (var_rank[i] == 0 && i%2 )
+#line 131
+		err = nc_get_var1_double(ncid, i, NULL, &value);
+#line 131
+	    else
+#line 131
+		err = nc_get_var1_double(ncid, i, index, &value);
+#line 131
+            if (canConvert) {
+#line 131
+		if (inRange3(expect,var_type[i], NCT_DOUBLE)) {
+#line 131
+		    if (expect >= double_min && expect <= double_max) {
+#line 131
+			IF (err) {
+#line 131
+			    error("%s", nc_strerror(err));
+#line 131
+			} else {
+#line 131
+			    IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) {
+#line 131
+				error("expected: %G, got: %G", expect,
+#line 131
+				    (double) value);
+#line 131
+			    } else {
+#line 131
+				nok++;
+#line 131
+			    }
+#line 131
+			}
+#line 131
+		    } else {
+#line 131
+			IF (err != NC_ERANGE)
+#line 131
+			    error("Range error: status = %d", err);
+#line 131
+		    }
+#line 131
+                } else {
+#line 131
+                    IF (err != 0 && err != NC_ERANGE)
+#line 131
+                        error("OK or Range error: status = %d", err);
+#line 131
+		}
+#line 131
+	    } else {
+#line 131
+		IF (err != NC_ECHAR)
+#line 131
+		    error("wrong type: status = %d", err);
+#line 131
+	    }
+#line 131
+	}
+#line 131
+    }
+#line 131
+    err = nc_close(ncid);
+#line 131
+    IF (err)
+#line 131
+	error("nc_close: %s", nc_strerror(err));
+#line 131
+    print_nok(nok);
+#line 131
+}
+#line 131
+
+void
+#line 132
+test_nc_get_var1_ushort(void)
+#line 132
+{
+#line 132
+    int ncid;
+#line 132
+    int i;
+#line 132
+    int j;
+#line 132
+    int err;
+#line 132
+    int nok = 0;      /* count of valid comparisons */
+#line 132
+    size_t index[MAX_RANK];
+#line 132
+    double expect;
+#line 132
+    int canConvert;     /* Both text or both numeric */
+#line 132
+    ushort value;
+#line 132
+
+#line 132
+#ifdef TEST_PNETCDF
+#line 132
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 132
+#else
+#line 132
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 132
+#endif
+#line 132
+    IF (err)
+#line 132
+	error("nc_open: %s", nc_strerror(err));
+#line 132
+    for (i = 0; i < numVars; i++) {
+#line 132
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+#line 132
+	for (j = 0; j < var_rank[i]; j++)
+#line 132
+	    index[j] = 0;
+#line 132
+        err = nc_get_var1_ushort(BAD_ID, i, index, &value);
+#line 132
+        IF (err != NC_EBADID)
+#line 132
+	    error("bad ncid: status = %d", err);
+#line 132
+        err = nc_get_var1_ushort(ncid, BAD_VARID, index, &value);
+#line 132
+        IF (err != NC_ENOTVAR)
+#line 132
+	    error("bad var id: status = %d", err);
+#line 132
+	for (j = 0; j < var_rank[i]; j++) {
+#line 132
+	    index[j] = var_shape[i][j];
+#line 132
+	    err = nc_get_var1_ushort(ncid, i, index, &value);
+#line 132
+	    if(!canConvert) {
+#line 132
+		IF(err != NC_ECHAR)
+#line 132
+			error("conversion: status = %d", err);
+#line 132
+	    } else IF (err != NC_EINVALCOORDS)
+#line 132
+		error("bad index: status = %d", err);
+#line 132
+	    index[j] = 0;
+#line 132
+	}
+#line 132
+	for (j = 0; j < var_nels[i]; j++) {
+#line 132
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 132
+	    IF (err)
+#line 132
+		error("error in toMixedBase 1");
+#line 132
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_USHORT );
+#line 132
+	    if (var_rank[i] == 0 && i%2 )
+#line 132
+		err = nc_get_var1_ushort(ncid, i, NULL, &value);
+#line 132
+	    else
+#line 132
+		err = nc_get_var1_ushort(ncid, i, index, &value);
+#line 132
+            if (canConvert) {
+#line 132
+		if (inRange3(expect,var_type[i], NCT_USHORT)) {
+#line 132
+		    if (expect >= ushort_min && expect <= ushort_max) {
+#line 132
+			IF (err) {
+#line 132
+			    error("%s", nc_strerror(err));
+#line 132
+			} else {
+#line 132
+			    IF (!equal(value,expect,var_type[i],NCT_USHORT)) {
+#line 132
+				error("expected: %G, got: %G", expect,
+#line 132
+				    (double) value);
+#line 132
+			    } else {
+#line 132
+				nok++;
+#line 132
+			    }
+#line 132
+			}
+#line 132
+		    } else {
+#line 132
+			IF (err != NC_ERANGE)
+#line 132
+			    error("Range error: status = %d", err);
+#line 132
+		    }
+#line 132
+                } else {
+#line 132
+                    IF (err != 0 && err != NC_ERANGE)
+#line 132
+                        error("OK or Range error: status = %d", err);
+#line 132
+		}
+#line 132
+	    } else {
+#line 132
+		IF (err != NC_ECHAR)
+#line 132
+		    error("wrong type: status = %d", err);
+#line 132
+	    }
+#line 132
+	}
+#line 132
+    }
+#line 132
+    err = nc_close(ncid);
+#line 132
+    IF (err)
+#line 132
+	error("nc_close: %s", nc_strerror(err));
+#line 132
+    print_nok(nok);
+#line 132
+}
+#line 132
+
+void
+#line 133
+test_nc_get_var1_uint(void)
+#line 133
+{
+#line 133
+    int ncid;
+#line 133
+    int i;
+#line 133
+    int j;
+#line 133
+    int err;
+#line 133
+    int nok = 0;      /* count of valid comparisons */
+#line 133
+    size_t index[MAX_RANK];
+#line 133
+    double expect;
+#line 133
+    int canConvert;     /* Both text or both numeric */
+#line 133
+    uint value;
+#line 133
+
+#line 133
+#ifdef TEST_PNETCDF
+#line 133
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 133
+#else
+#line 133
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 133
+#endif
+#line 133
+    IF (err)
+#line 133
+	error("nc_open: %s", nc_strerror(err));
+#line 133
+    for (i = 0; i < numVars; i++) {
+#line 133
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+#line 133
+	for (j = 0; j < var_rank[i]; j++)
+#line 133
+	    index[j] = 0;
+#line 133
+        err = nc_get_var1_uint(BAD_ID, i, index, &value);
+#line 133
+        IF (err != NC_EBADID)
+#line 133
+	    error("bad ncid: status = %d", err);
+#line 133
+        err = nc_get_var1_uint(ncid, BAD_VARID, index, &value);
+#line 133
+        IF (err != NC_ENOTVAR)
+#line 133
+	    error("bad var id: status = %d", err);
+#line 133
+	for (j = 0; j < var_rank[i]; j++) {
+#line 133
+	    index[j] = var_shape[i][j];
+#line 133
+	    err = nc_get_var1_uint(ncid, i, index, &value);
+#line 133
+	    if(!canConvert) {
+#line 133
+		IF(err != NC_ECHAR)
+#line 133
+			error("conversion: status = %d", err);
+#line 133
+	    } else IF (err != NC_EINVALCOORDS)
+#line 133
+		error("bad index: status = %d", err);
+#line 133
+	    index[j] = 0;
+#line 133
+	}
+#line 133
+	for (j = 0; j < var_nels[i]; j++) {
+#line 133
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 133
+	    IF (err)
+#line 133
+		error("error in toMixedBase 1");
+#line 133
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_UINT );
+#line 133
+	    if (var_rank[i] == 0 && i%2 )
+#line 133
+		err = nc_get_var1_uint(ncid, i, NULL, &value);
+#line 133
+	    else
+#line 133
+		err = nc_get_var1_uint(ncid, i, index, &value);
+#line 133
+            if (canConvert) {
+#line 133
+		if (inRange3(expect,var_type[i], NCT_UINT)) {
+#line 133
+		    if (expect >= uint_min && expect <= uint_max) {
+#line 133
+			IF (err) {
+#line 133
+			    error("%s", nc_strerror(err));
+#line 133
+			} else {
+#line 133
+			    IF (!equal(value,expect,var_type[i],NCT_UINT)) {
+#line 133
+				error("expected: %G, got: %G", expect,
+#line 133
+				    (double) value);
+#line 133
+			    } else {
+#line 133
+				nok++;
+#line 133
+			    }
+#line 133
+			}
+#line 133
+		    } else {
+#line 133
+			IF (err != NC_ERANGE)
+#line 133
+			    error("Range error: status = %d", err);
+#line 133
+		    }
+#line 133
+                } else {
+#line 133
+                    IF (err != 0 && err != NC_ERANGE)
+#line 133
+                        error("OK or Range error: status = %d", err);
+#line 133
+		}
+#line 133
+	    } else {
+#line 133
+		IF (err != NC_ECHAR)
+#line 133
+		    error("wrong type: status = %d", err);
+#line 133
+	    }
+#line 133
+	}
+#line 133
+    }
+#line 133
+    err = nc_close(ncid);
+#line 133
+    IF (err)
+#line 133
+	error("nc_close: %s", nc_strerror(err));
+#line 133
+    print_nok(nok);
+#line 133
+}
+#line 133
+
+void
+#line 134
+test_nc_get_var1_longlong(void)
+#line 134
+{
+#line 134
+    int ncid;
+#line 134
+    int i;
+#line 134
+    int j;
+#line 134
+    int err;
+#line 134
+    int nok = 0;      /* count of valid comparisons */
+#line 134
+    size_t index[MAX_RANK];
+#line 134
+    double expect;
+#line 134
+    int canConvert;     /* Both text or both numeric */
+#line 134
+    longlong value;
+#line 134
+
+#line 134
+#ifdef TEST_PNETCDF
+#line 134
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 134
+#else
+#line 134
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 134
+#endif
+#line 134
+    IF (err)
+#line 134
+	error("nc_open: %s", nc_strerror(err));
+#line 134
+    for (i = 0; i < numVars; i++) {
+#line 134
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+#line 134
+	for (j = 0; j < var_rank[i]; j++)
+#line 134
+	    index[j] = 0;
+#line 134
+        err = nc_get_var1_longlong(BAD_ID, i, index, &value);
+#line 134
+        IF (err != NC_EBADID)
+#line 134
+	    error("bad ncid: status = %d", err);
+#line 134
+        err = nc_get_var1_longlong(ncid, BAD_VARID, index, &value);
+#line 134
+        IF (err != NC_ENOTVAR)
+#line 134
+	    error("bad var id: status = %d", err);
+#line 134
+	for (j = 0; j < var_rank[i]; j++) {
+#line 134
+	    index[j] = var_shape[i][j];
+#line 134
+	    err = nc_get_var1_longlong(ncid, i, index, &value);
+#line 134
+	    if(!canConvert) {
+#line 134
+		IF(err != NC_ECHAR)
+#line 134
+			error("conversion: status = %d", err);
+#line 134
+	    } else IF (err != NC_EINVALCOORDS)
+#line 134
+		error("bad index: status = %d", err);
+#line 134
+	    index[j] = 0;
+#line 134
+	}
+#line 134
+	for (j = 0; j < var_nels[i]; j++) {
+#line 134
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 134
+	    IF (err)
+#line 134
+		error("error in toMixedBase 1");
+#line 134
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_LONGLONG );
+#line 134
+	    if (var_rank[i] == 0 && i%2 )
+#line 134
+		err = nc_get_var1_longlong(ncid, i, NULL, &value);
+#line 134
+	    else
+#line 134
+		err = nc_get_var1_longlong(ncid, i, index, &value);
+#line 134
+            if (canConvert) {
+#line 134
+		if (inRange3(expect,var_type[i], NCT_LONGLONG)) {
+#line 134
+		    if (expect >= longlong_min && expect <= longlong_max) {
+#line 134
+			IF (err) {
+#line 134
+			    error("%s", nc_strerror(err));
+#line 134
+			} else {
+#line 134
+			    IF (!equal(value,expect,var_type[i],NCT_LONGLONG)) {
+#line 134
+				error("expected: %G, got: %G", expect,
+#line 134
+				    (double) value);
+#line 134
+			    } else {
+#line 134
+				nok++;
+#line 134
+			    }
+#line 134
+			}
+#line 134
+		    } else {
+#line 134
+			IF (err != NC_ERANGE)
+#line 134
+			    error("Range error: status = %d", err);
+#line 134
+		    }
+#line 134
+                } else {
+#line 134
+                    IF (err != 0 && err != NC_ERANGE)
+#line 134
+                        error("OK or Range error: status = %d", err);
+#line 134
+		}
+#line 134
+	    } else {
+#line 134
+		IF (err != NC_ECHAR)
+#line 134
+		    error("wrong type: status = %d", err);
+#line 134
+	    }
+#line 134
+	}
+#line 134
+    }
+#line 134
+    err = nc_close(ncid);
+#line 134
+    IF (err)
+#line 134
+	error("nc_close: %s", nc_strerror(err));
+#line 134
+    print_nok(nok);
+#line 134
+}
+#line 134
+
+void
+#line 135
+test_nc_get_var1_ulonglong(void)
+#line 135
+{
+#line 135
+    int ncid;
+#line 135
+    int i;
+#line 135
+    int j;
+#line 135
+    int err;
+#line 135
+    int nok = 0;      /* count of valid comparisons */
+#line 135
+    size_t index[MAX_RANK];
+#line 135
+    double expect;
+#line 135
+    int canConvert;     /* Both text or both numeric */
+#line 135
+    ulonglong value;
+#line 135
+
+#line 135
+#ifdef TEST_PNETCDF
+#line 135
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 135
+#else
+#line 135
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 135
+#endif
+#line 135
+    IF (err)
+#line 135
+	error("nc_open: %s", nc_strerror(err));
+#line 135
+    for (i = 0; i < numVars; i++) {
+#line 135
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+#line 135
+	for (j = 0; j < var_rank[i]; j++)
+#line 135
+	    index[j] = 0;
+#line 135
+        err = nc_get_var1_ulonglong(BAD_ID, i, index, &value);
+#line 135
+        IF (err != NC_EBADID)
+#line 135
+	    error("bad ncid: status = %d", err);
+#line 135
+        err = nc_get_var1_ulonglong(ncid, BAD_VARID, index, &value);
+#line 135
+        IF (err != NC_ENOTVAR)
+#line 135
+	    error("bad var id: status = %d", err);
+#line 135
+	for (j = 0; j < var_rank[i]; j++) {
+#line 135
+	    index[j] = var_shape[i][j];
+#line 135
+	    err = nc_get_var1_ulonglong(ncid, i, index, &value);
+#line 135
+	    if(!canConvert) {
+#line 135
+		IF(err != NC_ECHAR)
+#line 135
+			error("conversion: status = %d", err);
+#line 135
+	    } else IF (err != NC_EINVALCOORDS)
+#line 135
+		error("bad index: status = %d", err);
+#line 135
+	    index[j] = 0;
+#line 135
+	}
+#line 135
+	for (j = 0; j < var_nels[i]; j++) {
+#line 135
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 135
+	    IF (err)
+#line 135
+		error("error in toMixedBase 1");
+#line 135
+	    expect = hash4( var_type[i], var_rank[i], index, NCT_ULONGLONG );
+#line 135
+	    if (var_rank[i] == 0 && i%2 )
+#line 135
+		err = nc_get_var1_ulonglong(ncid, i, NULL, &value);
+#line 135
+	    else
+#line 135
+		err = nc_get_var1_ulonglong(ncid, i, index, &value);
+#line 135
+            if (canConvert) {
+#line 135
+		if (inRange3(expect,var_type[i], NCT_ULONGLONG)) {
+#line 135
+		    if (expect >= ulonglong_min && expect <= ulonglong_max) {
+#line 135
+			IF (err) {
+#line 135
+			    error("%s", nc_strerror(err));
+#line 135
+			} else {
+#line 135
+			    IF (!equal(value,expect,var_type[i],NCT_ULONGLONG)) {
+#line 135
+				error("expected: %G, got: %G", expect,
+#line 135
+				    (double) value);
+#line 135
+			    } else {
+#line 135
+				nok++;
+#line 135
+			    }
+#line 135
+			}
+#line 135
+		    } else {
+#line 135
+			IF (err != NC_ERANGE)
+#line 135
+			    error("Range error: status = %d", err);
+#line 135
+		    }
+#line 135
+                } else {
+#line 135
+                    IF (err != 0 && err != NC_ERANGE)
+#line 135
+                        error("OK or Range error: status = %d", err);
+#line 135
+		}
+#line 135
+	    } else {
+#line 135
+		IF (err != NC_ECHAR)
+#line 135
+		    error("wrong type: status = %d", err);
+#line 135
+	    }
+#line 135
+	}
+#line 135
+    }
+#line 135
+    err = nc_close(ncid);
+#line 135
+    IF (err)
+#line 135
+	error("nc_close: %s", nc_strerror(err));
+#line 135
+    print_nok(nok);
+#line 135
+}
+#line 135
+
+
+
+#line 236
+
+void
+#line 237
+test_nc_get_var_text(void)
+#line 237
+{
+#line 237
+    int ncid;
+#line 237
+    int i;
+#line 237
+    int j;
+#line 237
+    int err;
+#line 237
+    int allInExtRange;	/* all values within external range? */
+#line 237
+    int allInIntRange;	/* all values within internal range? */
+#line 237
+    int nels;
+#line 237
+    int nok = 0;      /* count of valid comparisons */
+#line 237
+    size_t index[MAX_RANK];
+#line 237
+    int canConvert;     /* Both text or both numeric */
+#line 237
+    text value[MAX_NELS];
+#line 237
+    double expect[MAX_NELS];
+#line 237
+
+#line 237
+#ifdef TEST_PNETCDF
+#line 237
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 237
+#else
+#line 237
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 237
+#endif
+#line 237
+    IF (err)
+#line 237
+	error("nc_open: %s", nc_strerror(err));
+#line 237
+    for (i = 0; i < numVars; i++) {
+#line 237
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+#line 237
+        assert(var_rank[i] <= MAX_RANK);
+#line 237
+        assert(var_nels[i] <= MAX_NELS);
+#line 237
+        err = nc_get_var_text(BAD_ID, i, value);
+#line 237
+        IF (err != NC_EBADID)
+#line 237
+	    error("bad ncid: status = %d", err);
+#line 237
+        err = nc_get_var_text(ncid, BAD_VARID, value);
+#line 237
+        IF (err != NC_ENOTVAR)
+#line 237
+	    error("bad var id: status = %d", err);
+#line 237
+
+#line 237
+	nels = 1;
+#line 237
+	for (j = 0; j < var_rank[i]; j++) {
+#line 237
+	    nels *= var_shape[i][j];
+#line 237
+	}
+#line 237
+	allInExtRange = allInIntRange = 1;
+#line 237
+	for (j = 0; j < nels; j++) {
+#line 237
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 237
+	    IF (err)
+#line 237
+		error("error in toMixedBase 1");
+#line 237
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT);
+#line 237
+	    if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
+#line 237
+		allInIntRange = allInIntRange && expect[j] >= text_min
+#line 237
+			    && expect[j] <= text_max;
+#line 237
+	    } else {
+#line 237
+		allInExtRange = 0;
+#line 237
+	    }
+#line 237
+	}
+#line 237
+	err = nc_get_var_text(ncid, i, value);
+#line 237
+	if (canConvert) {
+#line 237
+	    if (allInExtRange) {
+#line 237
+		if (allInIntRange) {
+#line 237
+		    IF (err)
+#line 237
+			error("%s", nc_strerror(err));
+#line 237
+		} else {
+#line 237
+		    IF (err != NC_ERANGE)
+#line 237
+			error("Range error: status = %d", err);
+#line 237
+		}
+#line 237
+	    } else {
+#line 237
+		IF (err != 0 && err != NC_ERANGE)
+#line 237
+		    error("OK or Range error: status = %d", err);
+#line 237
+	    }
+#line 237
+	    for (j = 0; j < nels; j++) {
+#line 237
+		if (inRange3(expect[j],var_type[i],NCT_TEXT)
+#line 237
+			&& expect[j] >= text_min && expect[j] <= text_max) {
+#line 237
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){
+#line 237
+			error("value read not that expected");
+#line 237
+			if (verbose) {
+#line 237
+			    error("\n");
+#line 237
+			    error("varid: %d, ", i);
+#line 237
+			    error("var_name: %s, ", var_name[i]);
+#line 237
+			    error("element number: %d ", j);
+#line 237
+			    error("expect: %g", expect[j]);
+#line 237
+			    error("got: %g", (double) value[j]);
+#line 237
+			}
+#line 237
+		    } else {
+#line 237
+			nok++;
+#line 237
+		    }
+#line 237
+		}
+#line 237
+	    }
+#line 237
+	} else {
+#line 237
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 237
+		error("wrong type: status = %d", err);
+#line 237
+	}
+#line 237
+    }
+#line 237
+    err = nc_close(ncid);
+#line 237
+    IF (err)
+#line 237
+	error("nc_close: %s", nc_strerror(err));
+#line 237
+    print_nok(nok);
+#line 237
+}
+#line 237
+
+void
+#line 238
+test_nc_get_var_uchar(void)
+#line 238
+{
+#line 238
+    int ncid;
+#line 238
+    int i;
+#line 238
+    int j;
+#line 238
+    int err;
+#line 238
+    int allInExtRange;	/* all values within external range? */
+#line 238
+    int allInIntRange;	/* all values within internal range? */
+#line 238
+    int nels;
+#line 238
+    int nok = 0;      /* count of valid comparisons */
+#line 238
+    size_t index[MAX_RANK];
+#line 238
+    int canConvert;     /* Both text or both numeric */
+#line 238
+    uchar value[MAX_NELS];
+#line 238
+    double expect[MAX_NELS];
+#line 238
+
+#line 238
+#ifdef TEST_PNETCDF
+#line 238
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 238
+#else
+#line 238
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 238
+#endif
+#line 238
+    IF (err)
+#line 238
+	error("nc_open: %s", nc_strerror(err));
+#line 238
+    for (i = 0; i < numVars; i++) {
+#line 238
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+#line 238
+        assert(var_rank[i] <= MAX_RANK);
+#line 238
+        assert(var_nels[i] <= MAX_NELS);
+#line 238
+        err = nc_get_var_uchar(BAD_ID, i, value);
+#line 238
+        IF (err != NC_EBADID)
+#line 238
+	    error("bad ncid: status = %d", err);
+#line 238
+        err = nc_get_var_uchar(ncid, BAD_VARID, value);
+#line 238
+        IF (err != NC_ENOTVAR)
+#line 238
+	    error("bad var id: status = %d", err);
+#line 238
+
+#line 238
+	nels = 1;
+#line 238
+	for (j = 0; j < var_rank[i]; j++) {
+#line 238
+	    nels *= var_shape[i][j];
+#line 238
+	}
+#line 238
+	allInExtRange = allInIntRange = 1;
+#line 238
+	for (j = 0; j < nels; j++) {
+#line 238
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 238
+	    IF (err)
+#line 238
+		error("error in toMixedBase 1");
+#line 238
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR);
+#line 238
+	    if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
+#line 238
+		allInIntRange = allInIntRange && expect[j] >= uchar_min
+#line 238
+			    && expect[j] <= uchar_max;
+#line 238
+	    } else {
+#line 238
+		allInExtRange = 0;
+#line 238
+	    }
+#line 238
+	}
+#line 238
+	err = nc_get_var_uchar(ncid, i, value);
+#line 238
+	if (canConvert) {
+#line 238
+	    if (allInExtRange) {
+#line 238
+		if (allInIntRange) {
+#line 238
+		    IF (err)
+#line 238
+			error("%s", nc_strerror(err));
+#line 238
+		} else {
+#line 238
+		    IF (err != NC_ERANGE)
+#line 238
+			error("Range error: status = %d", err);
+#line 238
+		}
+#line 238
+	    } else {
+#line 238
+		IF (err != 0 && err != NC_ERANGE)
+#line 238
+		    error("OK or Range error: status = %d", err);
+#line 238
+	    }
+#line 238
+	    for (j = 0; j < nels; j++) {
+#line 238
+		if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+#line 238
+			&& expect[j] >= uchar_min && expect[j] <= uchar_max) {
+#line 238
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){
+#line 238
+			error("value read not that expected");
+#line 238
+			if (verbose) {
+#line 238
+			    error("\n");
+#line 238
+			    error("varid: %d, ", i);
+#line 238
+			    error("var_name: %s, ", var_name[i]);
+#line 238
+			    error("element number: %d ", j);
+#line 238
+			    error("expect: %g", expect[j]);
+#line 238
+			    error("got: %g", (double) value[j]);
+#line 238
+			}
+#line 238
+		    } else {
+#line 238
+			nok++;
+#line 238
+		    }
+#line 238
+		}
+#line 238
+	    }
+#line 238
+	} else {
+#line 238
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 238
+		error("wrong type: status = %d", err);
+#line 238
+	}
+#line 238
+    }
+#line 238
+    err = nc_close(ncid);
+#line 238
+    IF (err)
+#line 238
+	error("nc_close: %s", nc_strerror(err));
+#line 238
+    print_nok(nok);
+#line 238
+}
+#line 238
+
+void
+#line 239
+test_nc_get_var_schar(void)
+#line 239
+{
+#line 239
+    int ncid;
+#line 239
+    int i;
+#line 239
+    int j;
+#line 239
+    int err;
+#line 239
+    int allInExtRange;	/* all values within external range? */
+#line 239
+    int allInIntRange;	/* all values within internal range? */
+#line 239
+    int nels;
+#line 239
+    int nok = 0;      /* count of valid comparisons */
+#line 239
+    size_t index[MAX_RANK];
+#line 239
+    int canConvert;     /* Both text or both numeric */
+#line 239
+    schar value[MAX_NELS];
+#line 239
+    double expect[MAX_NELS];
+#line 239
+
+#line 239
+#ifdef TEST_PNETCDF
+#line 239
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 239
+#else
+#line 239
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 239
+#endif
+#line 239
+    IF (err)
+#line 239
+	error("nc_open: %s", nc_strerror(err));
+#line 239
+    for (i = 0; i < numVars; i++) {
+#line 239
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+#line 239
+        assert(var_rank[i] <= MAX_RANK);
+#line 239
+        assert(var_nels[i] <= MAX_NELS);
+#line 239
+        err = nc_get_var_schar(BAD_ID, i, value);
+#line 239
+        IF (err != NC_EBADID)
+#line 239
+	    error("bad ncid: status = %d", err);
+#line 239
+        err = nc_get_var_schar(ncid, BAD_VARID, value);
+#line 239
+        IF (err != NC_ENOTVAR)
+#line 239
+	    error("bad var id: status = %d", err);
+#line 239
+
+#line 239
+	nels = 1;
+#line 239
+	for (j = 0; j < var_rank[i]; j++) {
+#line 239
+	    nels *= var_shape[i][j];
+#line 239
+	}
+#line 239
+	allInExtRange = allInIntRange = 1;
+#line 239
+	for (j = 0; j < nels; j++) {
+#line 239
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 239
+	    IF (err)
+#line 239
+		error("error in toMixedBase 1");
+#line 239
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR);
+#line 239
+	    if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
+#line 239
+		allInIntRange = allInIntRange && expect[j] >= schar_min
+#line 239
+			    && expect[j] <= schar_max;
+#line 239
+	    } else {
+#line 239
+		allInExtRange = 0;
+#line 239
+	    }
+#line 239
+	}
+#line 239
+	err = nc_get_var_schar(ncid, i, value);
+#line 239
+	if (canConvert) {
+#line 239
+	    if (allInExtRange) {
+#line 239
+		if (allInIntRange) {
+#line 239
+		    IF (err)
+#line 239
+			error("%s", nc_strerror(err));
+#line 239
+		} else {
+#line 239
+		    IF (err != NC_ERANGE)
+#line 239
+			error("Range error: status = %d", err);
+#line 239
+		}
+#line 239
+	    } else {
+#line 239
+		IF (err != 0 && err != NC_ERANGE)
+#line 239
+		    error("OK or Range error: status = %d", err);
+#line 239
+	    }
+#line 239
+	    for (j = 0; j < nels; j++) {
+#line 239
+		if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+#line 239
+			&& expect[j] >= schar_min && expect[j] <= schar_max) {
+#line 239
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){
+#line 239
+			error("value read not that expected");
+#line 239
+			if (verbose) {
+#line 239
+			    error("\n");
+#line 239
+			    error("varid: %d, ", i);
+#line 239
+			    error("var_name: %s, ", var_name[i]);
+#line 239
+			    error("element number: %d ", j);
+#line 239
+			    error("expect: %g", expect[j]);
+#line 239
+			    error("got: %g", (double) value[j]);
+#line 239
+			}
+#line 239
+		    } else {
+#line 239
+			nok++;
+#line 239
+		    }
+#line 239
+		}
+#line 239
+	    }
+#line 239
+	} else {
+#line 239
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 239
+		error("wrong type: status = %d", err);
+#line 239
+	}
+#line 239
+    }
+#line 239
+    err = nc_close(ncid);
+#line 239
+    IF (err)
+#line 239
+	error("nc_close: %s", nc_strerror(err));
+#line 239
+    print_nok(nok);
+#line 239
+}
+#line 239
+
+void
+#line 240
+test_nc_get_var_short(void)
+#line 240
+{
+#line 240
+    int ncid;
+#line 240
+    int i;
+#line 240
+    int j;
+#line 240
+    int err;
+#line 240
+    int allInExtRange;	/* all values within external range? */
+#line 240
+    int allInIntRange;	/* all values within internal range? */
+#line 240
+    int nels;
+#line 240
+    int nok = 0;      /* count of valid comparisons */
+#line 240
+    size_t index[MAX_RANK];
+#line 240
+    int canConvert;     /* Both text or both numeric */
+#line 240
+    short value[MAX_NELS];
+#line 240
+    double expect[MAX_NELS];
+#line 240
+
+#line 240
+#ifdef TEST_PNETCDF
+#line 240
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 240
+#else
+#line 240
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 240
+#endif
+#line 240
+    IF (err)
+#line 240
+	error("nc_open: %s", nc_strerror(err));
+#line 240
+    for (i = 0; i < numVars; i++) {
+#line 240
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+#line 240
+        assert(var_rank[i] <= MAX_RANK);
+#line 240
+        assert(var_nels[i] <= MAX_NELS);
+#line 240
+        err = nc_get_var_short(BAD_ID, i, value);
+#line 240
+        IF (err != NC_EBADID)
+#line 240
+	    error("bad ncid: status = %d", err);
+#line 240
+        err = nc_get_var_short(ncid, BAD_VARID, value);
+#line 240
+        IF (err != NC_ENOTVAR)
+#line 240
+	    error("bad var id: status = %d", err);
+#line 240
+
+#line 240
+	nels = 1;
+#line 240
+	for (j = 0; j < var_rank[i]; j++) {
+#line 240
+	    nels *= var_shape[i][j];
+#line 240
+	}
+#line 240
+	allInExtRange = allInIntRange = 1;
+#line 240
+	for (j = 0; j < nels; j++) {
+#line 240
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 240
+	    IF (err)
+#line 240
+		error("error in toMixedBase 1");
+#line 240
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT);
+#line 240
+	    if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
+#line 240
+		allInIntRange = allInIntRange && expect[j] >= short_min
+#line 240
+			    && expect[j] <= short_max;
+#line 240
+	    } else {
+#line 240
+		allInExtRange = 0;
+#line 240
+	    }
+#line 240
+	}
+#line 240
+	err = nc_get_var_short(ncid, i, value);
+#line 240
+	if (canConvert) {
+#line 240
+	    if (allInExtRange) {
+#line 240
+		if (allInIntRange) {
+#line 240
+		    IF (err)
+#line 240
+			error("%s", nc_strerror(err));
+#line 240
+		} else {
+#line 240
+		    IF (err != NC_ERANGE)
+#line 240
+			error("Range error: status = %d", err);
+#line 240
+		}
+#line 240
+	    } else {
+#line 240
+		IF (err != 0 && err != NC_ERANGE)
+#line 240
+		    error("OK or Range error: status = %d", err);
+#line 240
+	    }
+#line 240
+	    for (j = 0; j < nels; j++) {
+#line 240
+		if (inRange3(expect[j],var_type[i],NCT_SHORT)
+#line 240
+			&& expect[j] >= short_min && expect[j] <= short_max) {
+#line 240
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){
+#line 240
+			error("value read not that expected");
+#line 240
+			if (verbose) {
+#line 240
+			    error("\n");
+#line 240
+			    error("varid: %d, ", i);
+#line 240
+			    error("var_name: %s, ", var_name[i]);
+#line 240
+			    error("element number: %d ", j);
+#line 240
+			    error("expect: %g", expect[j]);
+#line 240
+			    error("got: %g", (double) value[j]);
+#line 240
+			}
+#line 240
+		    } else {
+#line 240
+			nok++;
+#line 240
+		    }
+#line 240
+		}
+#line 240
+	    }
+#line 240
+	} else {
+#line 240
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 240
+		error("wrong type: status = %d", err);
+#line 240
+	}
+#line 240
+    }
+#line 240
+    err = nc_close(ncid);
+#line 240
+    IF (err)
+#line 240
+	error("nc_close: %s", nc_strerror(err));
+#line 240
+    print_nok(nok);
+#line 240
+}
+#line 240
+
+void
+#line 241
+test_nc_get_var_int(void)
+#line 241
+{
+#line 241
+    int ncid;
+#line 241
+    int i;
+#line 241
+    int j;
+#line 241
+    int err;
+#line 241
+    int allInExtRange;	/* all values within external range? */
+#line 241
+    int allInIntRange;	/* all values within internal range? */
+#line 241
+    int nels;
+#line 241
+    int nok = 0;      /* count of valid comparisons */
+#line 241
+    size_t index[MAX_RANK];
+#line 241
+    int canConvert;     /* Both text or both numeric */
+#line 241
+    int value[MAX_NELS];
+#line 241
+    double expect[MAX_NELS];
+#line 241
+
+#line 241
+#ifdef TEST_PNETCDF
+#line 241
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 241
+#else
+#line 241
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 241
+#endif
+#line 241
+    IF (err)
+#line 241
+	error("nc_open: %s", nc_strerror(err));
+#line 241
+    for (i = 0; i < numVars; i++) {
+#line 241
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+#line 241
+        assert(var_rank[i] <= MAX_RANK);
+#line 241
+        assert(var_nels[i] <= MAX_NELS);
+#line 241
+        err = nc_get_var_int(BAD_ID, i, value);
+#line 241
+        IF (err != NC_EBADID)
+#line 241
+	    error("bad ncid: status = %d", err);
+#line 241
+        err = nc_get_var_int(ncid, BAD_VARID, value);
+#line 241
+        IF (err != NC_ENOTVAR)
+#line 241
+	    error("bad var id: status = %d", err);
+#line 241
+
+#line 241
+	nels = 1;
+#line 241
+	for (j = 0; j < var_rank[i]; j++) {
+#line 241
+	    nels *= var_shape[i][j];
+#line 241
+	}
+#line 241
+	allInExtRange = allInIntRange = 1;
+#line 241
+	for (j = 0; j < nels; j++) {
+#line 241
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 241
+	    IF (err)
+#line 241
+		error("error in toMixedBase 1");
+#line 241
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT);
+#line 241
+	    if (inRange3(expect[j],var_type[i], NCT_INT)) {
+#line 241
+		allInIntRange = allInIntRange && expect[j] >= int_min
+#line 241
+			    && expect[j] <= int_max;
+#line 241
+	    } else {
+#line 241
+		allInExtRange = 0;
+#line 241
+	    }
+#line 241
+	}
+#line 241
+	err = nc_get_var_int(ncid, i, value);
+#line 241
+	if (canConvert) {
+#line 241
+	    if (allInExtRange) {
+#line 241
+		if (allInIntRange) {
+#line 241
+		    IF (err)
+#line 241
+			error("%s", nc_strerror(err));
+#line 241
+		} else {
+#line 241
+		    IF (err != NC_ERANGE)
+#line 241
+			error("Range error: status = %d", err);
+#line 241
+		}
+#line 241
+	    } else {
+#line 241
+		IF (err != 0 && err != NC_ERANGE)
+#line 241
+		    error("OK or Range error: status = %d", err);
+#line 241
+	    }
+#line 241
+	    for (j = 0; j < nels; j++) {
+#line 241
+		if (inRange3(expect[j],var_type[i],NCT_INT)
+#line 241
+			&& expect[j] >= int_min && expect[j] <= int_max) {
+#line 241
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){
+#line 241
+			error("value read not that expected");
+#line 241
+			if (verbose) {
+#line 241
+			    error("\n");
+#line 241
+			    error("varid: %d, ", i);
+#line 241
+			    error("var_name: %s, ", var_name[i]);
+#line 241
+			    error("element number: %d ", j);
+#line 241
+			    error("expect: %g", expect[j]);
+#line 241
+			    error("got: %g", (double) value[j]);
+#line 241
+			}
+#line 241
+		    } else {
+#line 241
+			nok++;
+#line 241
+		    }
+#line 241
+		}
+#line 241
+	    }
+#line 241
+	} else {
+#line 241
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 241
+		error("wrong type: status = %d", err);
+#line 241
+	}
+#line 241
+    }
+#line 241
+    err = nc_close(ncid);
+#line 241
+    IF (err)
+#line 241
+	error("nc_close: %s", nc_strerror(err));
+#line 241
+    print_nok(nok);
+#line 241
+}
+#line 241
+
+void
+#line 242
+test_nc_get_var_long(void)
+#line 242
+{
+#line 242
+    int ncid;
+#line 242
+    int i;
+#line 242
+    int j;
+#line 242
+    int err;
+#line 242
+    int allInExtRange;	/* all values within external range? */
+#line 242
+    int allInIntRange;	/* all values within internal range? */
+#line 242
+    int nels;
+#line 242
+    int nok = 0;      /* count of valid comparisons */
+#line 242
+    size_t index[MAX_RANK];
+#line 242
+    int canConvert;     /* Both text or both numeric */
+#line 242
+    long value[MAX_NELS];
+#line 242
+    double expect[MAX_NELS];
+#line 242
+
+#line 242
+#ifdef TEST_PNETCDF
+#line 242
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 242
+#else
+#line 242
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 242
+#endif
+#line 242
+    IF (err)
+#line 242
+	error("nc_open: %s", nc_strerror(err));
+#line 242
+    for (i = 0; i < numVars; i++) {
+#line 242
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+#line 242
+        assert(var_rank[i] <= MAX_RANK);
+#line 242
+        assert(var_nels[i] <= MAX_NELS);
+#line 242
+        err = nc_get_var_long(BAD_ID, i, value);
+#line 242
+        IF (err != NC_EBADID)
+#line 242
+	    error("bad ncid: status = %d", err);
+#line 242
+        err = nc_get_var_long(ncid, BAD_VARID, value);
+#line 242
+        IF (err != NC_ENOTVAR)
+#line 242
+	    error("bad var id: status = %d", err);
+#line 242
+
+#line 242
+	nels = 1;
+#line 242
+	for (j = 0; j < var_rank[i]; j++) {
+#line 242
+	    nels *= var_shape[i][j];
+#line 242
+	}
+#line 242
+	allInExtRange = allInIntRange = 1;
+#line 242
+	for (j = 0; j < nels; j++) {
+#line 242
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 242
+	    IF (err)
+#line 242
+		error("error in toMixedBase 1");
+#line 242
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG);
+#line 242
+	    if (inRange3(expect[j],var_type[i], NCT_LONG)) {
+#line 242
+		allInIntRange = allInIntRange && expect[j] >= long_min
+#line 242
+			    && expect[j] <= long_max;
+#line 242
+	    } else {
+#line 242
+		allInExtRange = 0;
+#line 242
+	    }
+#line 242
+	}
+#line 242
+	err = nc_get_var_long(ncid, i, value);
+#line 242
+	if (canConvert) {
+#line 242
+	    if (allInExtRange) {
+#line 242
+		if (allInIntRange) {
+#line 242
+		    IF (err)
+#line 242
+			error("%s", nc_strerror(err));
+#line 242
+		} else {
+#line 242
+		    IF (err != NC_ERANGE)
+#line 242
+			error("Range error: status = %d", err);
+#line 242
+		}
+#line 242
+	    } else {
+#line 242
+		IF (err != 0 && err != NC_ERANGE)
+#line 242
+		    error("OK or Range error: status = %d", err);
+#line 242
+	    }
+#line 242
+	    for (j = 0; j < nels; j++) {
+#line 242
+		if (inRange3(expect[j],var_type[i],NCT_LONG)
+#line 242
+			&& expect[j] >= long_min && expect[j] <= long_max) {
+#line 242
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_LONG)){
+#line 242
+			error("value read not that expected");
+#line 242
+			if (verbose) {
+#line 242
+			    error("\n");
+#line 242
+			    error("varid: %d, ", i);
+#line 242
+			    error("var_name: %s, ", var_name[i]);
+#line 242
+			    error("element number: %d ", j);
+#line 242
+			    error("expect: %g", expect[j]);
+#line 242
+			    error("got: %g", (double) value[j]);
+#line 242
+			}
+#line 242
+		    } else {
+#line 242
+			nok++;
+#line 242
+		    }
+#line 242
+		}
+#line 242
+	    }
+#line 242
+	} else {
+#line 242
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 242
+		error("wrong type: status = %d", err);
+#line 242
+	}
+#line 242
+    }
+#line 242
+    err = nc_close(ncid);
+#line 242
+    IF (err)
+#line 242
+	error("nc_close: %s", nc_strerror(err));
+#line 242
+    print_nok(nok);
+#line 242
+}
+#line 242
+
+void
+#line 243
+test_nc_get_var_float(void)
+#line 243
+{
+#line 243
+    int ncid;
+#line 243
+    int i;
+#line 243
+    int j;
+#line 243
+    int err;
+#line 243
+    int allInExtRange;	/* all values within external range? */
+#line 243
+    int allInIntRange;	/* all values within internal range? */
+#line 243
+    int nels;
+#line 243
+    int nok = 0;      /* count of valid comparisons */
+#line 243
+    size_t index[MAX_RANK];
+#line 243
+    int canConvert;     /* Both text or both numeric */
+#line 243
+    float value[MAX_NELS];
+#line 243
+    double expect[MAX_NELS];
+#line 243
+
+#line 243
+#ifdef TEST_PNETCDF
+#line 243
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 243
+#else
+#line 243
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 243
+#endif
+#line 243
+    IF (err)
+#line 243
+	error("nc_open: %s", nc_strerror(err));
+#line 243
+    for (i = 0; i < numVars; i++) {
+#line 243
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+#line 243
+        assert(var_rank[i] <= MAX_RANK);
+#line 243
+        assert(var_nels[i] <= MAX_NELS);
+#line 243
+        err = nc_get_var_float(BAD_ID, i, value);
+#line 243
+        IF (err != NC_EBADID)
+#line 243
+	    error("bad ncid: status = %d", err);
+#line 243
+        err = nc_get_var_float(ncid, BAD_VARID, value);
+#line 243
+        IF (err != NC_ENOTVAR)
+#line 243
+	    error("bad var id: status = %d", err);
+#line 243
+
+#line 243
+	nels = 1;
+#line 243
+	for (j = 0; j < var_rank[i]; j++) {
+#line 243
+	    nels *= var_shape[i][j];
+#line 243
+	}
+#line 243
+	allInExtRange = allInIntRange = 1;
+#line 243
+	for (j = 0; j < nels; j++) {
+#line 243
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 243
+	    IF (err)
+#line 243
+		error("error in toMixedBase 1");
+#line 243
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT);
+#line 243
+	    if (inRange3(expect[j],var_type[i], NCT_FLOAT)) {
+#line 243
+		allInIntRange = allInIntRange && expect[j] >= float_min
+#line 243
+			    && expect[j] <= float_max;
+#line 243
+	    } else {
+#line 243
+		allInExtRange = 0;
+#line 243
+	    }
+#line 243
+	}
+#line 243
+	err = nc_get_var_float(ncid, i, value);
+#line 243
+	if (canConvert) {
+#line 243
+	    if (allInExtRange) {
+#line 243
+		if (allInIntRange) {
+#line 243
+		    IF (err)
+#line 243
+			error("%s", nc_strerror(err));
+#line 243
+		} else {
+#line 243
+		    IF (err != NC_ERANGE)
+#line 243
+			error("Range error: status = %d", err);
+#line 243
+		}
+#line 243
+	    } else {
+#line 243
+		IF (err != 0 && err != NC_ERANGE)
+#line 243
+		    error("OK or Range error: status = %d", err);
+#line 243
+	    }
+#line 243
+	    for (j = 0; j < nels; j++) {
+#line 243
+		if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+#line 243
+			&& expect[j] >= float_min && expect[j] <= float_max) {
+#line 243
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_FLOAT)){
+#line 243
+			error("value read not that expected");
+#line 243
+			if (verbose) {
+#line 243
+			    error("\n");
+#line 243
+			    error("varid: %d, ", i);
+#line 243
+			    error("var_name: %s, ", var_name[i]);
+#line 243
+			    error("element number: %d ", j);
+#line 243
+			    error("expect: %g", expect[j]);
+#line 243
+			    error("got: %g", (double) value[j]);
+#line 243
+			}
+#line 243
+		    } else {
+#line 243
+			nok++;
+#line 243
+		    }
+#line 243
+		}
+#line 243
+	    }
+#line 243
+	} else {
+#line 243
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 243
+		error("wrong type: status = %d", err);
+#line 243
+	}
+#line 243
+    }
+#line 243
+    err = nc_close(ncid);
+#line 243
+    IF (err)
+#line 243
+	error("nc_close: %s", nc_strerror(err));
+#line 243
+    print_nok(nok);
+#line 243
+}
+#line 243
+
+void
+#line 244
+test_nc_get_var_double(void)
+#line 244
+{
+#line 244
+    int ncid;
+#line 244
+    int i;
+#line 244
+    int j;
+#line 244
+    int err;
+#line 244
+    int allInExtRange;	/* all values within external range? */
+#line 244
+    int allInIntRange;	/* all values within internal range? */
+#line 244
+    int nels;
+#line 244
+    int nok = 0;      /* count of valid comparisons */
+#line 244
+    size_t index[MAX_RANK];
+#line 244
+    int canConvert;     /* Both text or both numeric */
+#line 244
+    double value[MAX_NELS];
+#line 244
+    double expect[MAX_NELS];
+#line 244
+
+#line 244
+#ifdef TEST_PNETCDF
+#line 244
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 244
+#else
+#line 244
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 244
+#endif
+#line 244
+    IF (err)
+#line 244
+	error("nc_open: %s", nc_strerror(err));
+#line 244
+    for (i = 0; i < numVars; i++) {
+#line 244
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+#line 244
+        assert(var_rank[i] <= MAX_RANK);
+#line 244
+        assert(var_nels[i] <= MAX_NELS);
+#line 244
+        err = nc_get_var_double(BAD_ID, i, value);
+#line 244
+        IF (err != NC_EBADID)
+#line 244
+	    error("bad ncid: status = %d", err);
+#line 244
+        err = nc_get_var_double(ncid, BAD_VARID, value);
+#line 244
+        IF (err != NC_ENOTVAR)
+#line 244
+	    error("bad var id: status = %d", err);
+#line 244
+
+#line 244
+	nels = 1;
+#line 244
+	for (j = 0; j < var_rank[i]; j++) {
+#line 244
+	    nels *= var_shape[i][j];
+#line 244
+	}
+#line 244
+	allInExtRange = allInIntRange = 1;
+#line 244
+	for (j = 0; j < nels; j++) {
+#line 244
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 244
+	    IF (err)
+#line 244
+		error("error in toMixedBase 1");
+#line 244
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE);
+#line 244
+	    if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) {
+#line 244
+		allInIntRange = allInIntRange && expect[j] >= double_min
+#line 244
+			    && expect[j] <= double_max;
+#line 244
+	    } else {
+#line 244
+		allInExtRange = 0;
+#line 244
+	    }
+#line 244
+	}
+#line 244
+	err = nc_get_var_double(ncid, i, value);
+#line 244
+	if (canConvert) {
+#line 244
+	    if (allInExtRange) {
+#line 244
+		if (allInIntRange) {
+#line 244
+		    IF (err)
+#line 244
+			error("%s", nc_strerror(err));
+#line 244
+		} else {
+#line 244
+		    IF (err != NC_ERANGE)
+#line 244
+			error("Range error: status = %d", err);
+#line 244
+		}
+#line 244
+	    } else {
+#line 244
+		IF (err != 0 && err != NC_ERANGE)
+#line 244
+		    error("OK or Range error: status = %d", err);
+#line 244
+	    }
+#line 244
+	    for (j = 0; j < nels; j++) {
+#line 244
+		if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+#line 244
+			&& expect[j] >= double_min && expect[j] <= double_max) {
+#line 244
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_DOUBLE)){
+#line 244
+			error("value read not that expected");
+#line 244
+			if (verbose) {
+#line 244
+			    error("\n");
+#line 244
+			    error("varid: %d, ", i);
+#line 244
+			    error("var_name: %s, ", var_name[i]);
+#line 244
+			    error("element number: %d ", j);
+#line 244
+			    error("expect: %g", expect[j]);
+#line 244
+			    error("got: %g", (double) value[j]);
+#line 244
+			}
+#line 244
+		    } else {
+#line 244
+			nok++;
+#line 244
+		    }
+#line 244
+		}
+#line 244
+	    }
+#line 244
+	} else {
+#line 244
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 244
+		error("wrong type: status = %d", err);
+#line 244
+	}
+#line 244
+    }
+#line 244
+    err = nc_close(ncid);
+#line 244
+    IF (err)
+#line 244
+	error("nc_close: %s", nc_strerror(err));
+#line 244
+    print_nok(nok);
+#line 244
+}
+#line 244
+
+void
+#line 245
+test_nc_get_var_ushort(void)
+#line 245
+{
+#line 245
+    int ncid;
+#line 245
+    int i;
+#line 245
+    int j;
+#line 245
+    int err;
+#line 245
+    int allInExtRange;	/* all values within external range? */
+#line 245
+    int allInIntRange;	/* all values within internal range? */
+#line 245
+    int nels;
+#line 245
+    int nok = 0;      /* count of valid comparisons */
+#line 245
+    size_t index[MAX_RANK];
+#line 245
+    int canConvert;     /* Both text or both numeric */
+#line 245
+    ushort value[MAX_NELS];
+#line 245
+    double expect[MAX_NELS];
+#line 245
+
+#line 245
+#ifdef TEST_PNETCDF
+#line 245
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 245
+#else
+#line 245
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 245
+#endif
+#line 245
+    IF (err)
+#line 245
+	error("nc_open: %s", nc_strerror(err));
+#line 245
+    for (i = 0; i < numVars; i++) {
+#line 245
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+#line 245
+        assert(var_rank[i] <= MAX_RANK);
+#line 245
+        assert(var_nels[i] <= MAX_NELS);
+#line 245
+        err = nc_get_var_ushort(BAD_ID, i, value);
+#line 245
+        IF (err != NC_EBADID)
+#line 245
+	    error("bad ncid: status = %d", err);
+#line 245
+        err = nc_get_var_ushort(ncid, BAD_VARID, value);
+#line 245
+        IF (err != NC_ENOTVAR)
+#line 245
+	    error("bad var id: status = %d", err);
+#line 245
+
+#line 245
+	nels = 1;
+#line 245
+	for (j = 0; j < var_rank[i]; j++) {
+#line 245
+	    nels *= var_shape[i][j];
+#line 245
+	}
+#line 245
+	allInExtRange = allInIntRange = 1;
+#line 245
+	for (j = 0; j < nels; j++) {
+#line 245
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 245
+	    IF (err)
+#line 245
+		error("error in toMixedBase 1");
+#line 245
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_USHORT);
+#line 245
+	    if (inRange3(expect[j],var_type[i], NCT_USHORT)) {
+#line 245
+		allInIntRange = allInIntRange && expect[j] >= ushort_min
+#line 245
+			    && expect[j] <= ushort_max;
+#line 245
+	    } else {
+#line 245
+		allInExtRange = 0;
+#line 245
+	    }
+#line 245
+	}
+#line 245
+	err = nc_get_var_ushort(ncid, i, value);
+#line 245
+	if (canConvert) {
+#line 245
+	    if (allInExtRange) {
+#line 245
+		if (allInIntRange) {
+#line 245
+		    IF (err)
+#line 245
+			error("%s", nc_strerror(err));
+#line 245
+		} else {
+#line 245
+		    IF (err != NC_ERANGE)
+#line 245
+			error("Range error: status = %d", err);
+#line 245
+		}
+#line 245
+	    } else {
+#line 245
+		IF (err != 0 && err != NC_ERANGE)
+#line 245
+		    error("OK or Range error: status = %d", err);
+#line 245
+	    }
+#line 245
+	    for (j = 0; j < nels; j++) {
+#line 245
+		if (inRange3(expect[j],var_type[i],NCT_USHORT)
+#line 245
+			&& expect[j] >= ushort_min && expect[j] <= ushort_max) {
+#line 245
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_USHORT)){
+#line 245
+			error("value read not that expected");
+#line 245
+			if (verbose) {
+#line 245
+			    error("\n");
+#line 245
+			    error("varid: %d, ", i);
+#line 245
+			    error("var_name: %s, ", var_name[i]);
+#line 245
+			    error("element number: %d ", j);
+#line 245
+			    error("expect: %g", expect[j]);
+#line 245
+			    error("got: %g", (double) value[j]);
+#line 245
+			}
+#line 245
+		    } else {
+#line 245
+			nok++;
+#line 245
+		    }
+#line 245
+		}
+#line 245
+	    }
+#line 245
+	} else {
+#line 245
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 245
+		error("wrong type: status = %d", err);
+#line 245
+	}
+#line 245
+    }
+#line 245
+    err = nc_close(ncid);
+#line 245
+    IF (err)
+#line 245
+	error("nc_close: %s", nc_strerror(err));
+#line 245
+    print_nok(nok);
+#line 245
+}
+#line 245
+
+void
+#line 246
+test_nc_get_var_uint(void)
+#line 246
+{
+#line 246
+    int ncid;
+#line 246
+    int i;
+#line 246
+    int j;
+#line 246
+    int err;
+#line 246
+    int allInExtRange;	/* all values within external range? */
+#line 246
+    int allInIntRange;	/* all values within internal range? */
+#line 246
+    int nels;
+#line 246
+    int nok = 0;      /* count of valid comparisons */
+#line 246
+    size_t index[MAX_RANK];
+#line 246
+    int canConvert;     /* Both text or both numeric */
+#line 246
+    uint value[MAX_NELS];
+#line 246
+    double expect[MAX_NELS];
+#line 246
+
+#line 246
+#ifdef TEST_PNETCDF
+#line 246
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 246
+#else
+#line 246
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 246
+#endif
+#line 246
+    IF (err)
+#line 246
+	error("nc_open: %s", nc_strerror(err));
+#line 246
+    for (i = 0; i < numVars; i++) {
+#line 246
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+#line 246
+        assert(var_rank[i] <= MAX_RANK);
+#line 246
+        assert(var_nels[i] <= MAX_NELS);
+#line 246
+        err = nc_get_var_uint(BAD_ID, i, value);
+#line 246
+        IF (err != NC_EBADID)
+#line 246
+	    error("bad ncid: status = %d", err);
+#line 246
+        err = nc_get_var_uint(ncid, BAD_VARID, value);
+#line 246
+        IF (err != NC_ENOTVAR)
+#line 246
+	    error("bad var id: status = %d", err);
+#line 246
+
+#line 246
+	nels = 1;
+#line 246
+	for (j = 0; j < var_rank[i]; j++) {
+#line 246
+	    nels *= var_shape[i][j];
+#line 246
+	}
+#line 246
+	allInExtRange = allInIntRange = 1;
+#line 246
+	for (j = 0; j < nels; j++) {
+#line 246
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 246
+	    IF (err)
+#line 246
+		error("error in toMixedBase 1");
+#line 246
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UINT);
+#line 246
+	    if (inRange3(expect[j],var_type[i], NCT_UINT)) {
+#line 246
+		allInIntRange = allInIntRange && expect[j] >= uint_min
+#line 246
+			    && expect[j] <= uint_max;
+#line 246
+	    } else {
+#line 246
+		allInExtRange = 0;
+#line 246
+	    }
+#line 246
+	}
+#line 246
+	err = nc_get_var_uint(ncid, i, value);
+#line 246
+	if (canConvert) {
+#line 246
+	    if (allInExtRange) {
+#line 246
+		if (allInIntRange) {
+#line 246
+		    IF (err)
+#line 246
+			error("%s", nc_strerror(err));
+#line 246
+		} else {
+#line 246
+		    IF (err != NC_ERANGE)
+#line 246
+			error("Range error: status = %d", err);
+#line 246
+		}
+#line 246
+	    } else {
+#line 246
+		IF (err != 0 && err != NC_ERANGE)
+#line 246
+		    error("OK or Range error: status = %d", err);
+#line 246
+	    }
+#line 246
+	    for (j = 0; j < nels; j++) {
+#line 246
+		if (inRange3(expect[j],var_type[i],NCT_UINT)
+#line 246
+			&& expect[j] >= uint_min && expect[j] <= uint_max) {
+#line 246
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_UINT)){
+#line 246
+			error("value read not that expected");
+#line 246
+			if (verbose) {
+#line 246
+			    error("\n");
+#line 246
+			    error("varid: %d, ", i);
+#line 246
+			    error("var_name: %s, ", var_name[i]);
+#line 246
+			    error("element number: %d ", j);
+#line 246
+			    error("expect: %g", expect[j]);
+#line 246
+			    error("got: %g", (double) value[j]);
+#line 246
+			}
+#line 246
+		    } else {
+#line 246
+			nok++;
+#line 246
+		    }
+#line 246
+		}
+#line 246
+	    }
+#line 246
+	} else {
+#line 246
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 246
+		error("wrong type: status = %d", err);
+#line 246
+	}
+#line 246
+    }
+#line 246
+    err = nc_close(ncid);
+#line 246
+    IF (err)
+#line 246
+	error("nc_close: %s", nc_strerror(err));
+#line 246
+    print_nok(nok);
+#line 246
+}
+#line 246
+
+void
+#line 247
+test_nc_get_var_longlong(void)
+#line 247
+{
+#line 247
+    int ncid;
+#line 247
+    int i;
+#line 247
+    int j;
+#line 247
+    int err;
+#line 247
+    int allInExtRange;	/* all values within external range? */
+#line 247
+    int allInIntRange;	/* all values within internal range? */
+#line 247
+    int nels;
+#line 247
+    int nok = 0;      /* count of valid comparisons */
+#line 247
+    size_t index[MAX_RANK];
+#line 247
+    int canConvert;     /* Both text or both numeric */
+#line 247
+    longlong value[MAX_NELS];
+#line 247
+    double expect[MAX_NELS];
+#line 247
+
+#line 247
+#ifdef TEST_PNETCDF
+#line 247
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 247
+#else
+#line 247
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 247
+#endif
+#line 247
+    IF (err)
+#line 247
+	error("nc_open: %s", nc_strerror(err));
+#line 247
+    for (i = 0; i < numVars; i++) {
+#line 247
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+#line 247
+        assert(var_rank[i] <= MAX_RANK);
+#line 247
+        assert(var_nels[i] <= MAX_NELS);
+#line 247
+        err = nc_get_var_longlong(BAD_ID, i, value);
+#line 247
+        IF (err != NC_EBADID)
+#line 247
+	    error("bad ncid: status = %d", err);
+#line 247
+        err = nc_get_var_longlong(ncid, BAD_VARID, value);
+#line 247
+        IF (err != NC_ENOTVAR)
+#line 247
+	    error("bad var id: status = %d", err);
+#line 247
+
+#line 247
+	nels = 1;
+#line 247
+	for (j = 0; j < var_rank[i]; j++) {
+#line 247
+	    nels *= var_shape[i][j];
+#line 247
+	}
+#line 247
+	allInExtRange = allInIntRange = 1;
+#line 247
+	for (j = 0; j < nels; j++) {
+#line 247
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 247
+	    IF (err)
+#line 247
+		error("error in toMixedBase 1");
+#line 247
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONGLONG);
+#line 247
+	    if (inRange3(expect[j],var_type[i], NCT_LONGLONG)) {
+#line 247
+		allInIntRange = allInIntRange && expect[j] >= longlong_min
+#line 247
+			    && expect[j] <= longlong_max;
+#line 247
+	    } else {
+#line 247
+		allInExtRange = 0;
+#line 247
+	    }
+#line 247
+	}
+#line 247
+	err = nc_get_var_longlong(ncid, i, value);
+#line 247
+	if (canConvert) {
+#line 247
+	    if (allInExtRange) {
+#line 247
+		if (allInIntRange) {
+#line 247
+		    IF (err)
+#line 247
+			error("%s", nc_strerror(err));
+#line 247
+		} else {
+#line 247
+		    IF (err != NC_ERANGE)
+#line 247
+			error("Range error: status = %d", err);
+#line 247
+		}
+#line 247
+	    } else {
+#line 247
+		IF (err != 0 && err != NC_ERANGE)
+#line 247
+		    error("OK or Range error: status = %d", err);
+#line 247
+	    }
+#line 247
+	    for (j = 0; j < nels; j++) {
+#line 247
+		if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+#line 247
+			&& expect[j] >= longlong_min && expect[j] <= longlong_max) {
+#line 247
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_LONGLONG)){
+#line 247
+			error("value read not that expected");
+#line 247
+			if (verbose) {
+#line 247
+			    error("\n");
+#line 247
+			    error("varid: %d, ", i);
+#line 247
+			    error("var_name: %s, ", var_name[i]);
+#line 247
+			    error("element number: %d ", j);
+#line 247
+			    error("expect: %g", expect[j]);
+#line 247
+			    error("got: %g", (double) value[j]);
+#line 247
+			}
+#line 247
+		    } else {
+#line 247
+			nok++;
+#line 247
+		    }
+#line 247
+		}
+#line 247
+	    }
+#line 247
+	} else {
+#line 247
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 247
+		error("wrong type: status = %d", err);
+#line 247
+	}
+#line 247
+    }
+#line 247
+    err = nc_close(ncid);
+#line 247
+    IF (err)
+#line 247
+	error("nc_close: %s", nc_strerror(err));
+#line 247
+    print_nok(nok);
+#line 247
+}
+#line 247
+
+void
+#line 248
+test_nc_get_var_ulonglong(void)
+#line 248
+{
+#line 248
+    int ncid;
+#line 248
+    int i;
+#line 248
+    int j;
+#line 248
+    int err;
+#line 248
+    int allInExtRange;	/* all values within external range? */
+#line 248
+    int allInIntRange;	/* all values within internal range? */
+#line 248
+    int nels;
+#line 248
+    int nok = 0;      /* count of valid comparisons */
+#line 248
+    size_t index[MAX_RANK];
+#line 248
+    int canConvert;     /* Both text or both numeric */
+#line 248
+    ulonglong value[MAX_NELS];
+#line 248
+    double expect[MAX_NELS];
+#line 248
+
+#line 248
+#ifdef TEST_PNETCDF
+#line 248
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 248
+#else
+#line 248
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 248
+#endif
+#line 248
+    IF (err)
+#line 248
+	error("nc_open: %s", nc_strerror(err));
+#line 248
+    for (i = 0; i < numVars; i++) {
+#line 248
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+#line 248
+        assert(var_rank[i] <= MAX_RANK);
+#line 248
+        assert(var_nels[i] <= MAX_NELS);
+#line 248
+        err = nc_get_var_ulonglong(BAD_ID, i, value);
+#line 248
+        IF (err != NC_EBADID)
+#line 248
+	    error("bad ncid: status = %d", err);
+#line 248
+        err = nc_get_var_ulonglong(ncid, BAD_VARID, value);
+#line 248
+        IF (err != NC_ENOTVAR)
+#line 248
+	    error("bad var id: status = %d", err);
+#line 248
+
+#line 248
+	nels = 1;
+#line 248
+	for (j = 0; j < var_rank[i]; j++) {
+#line 248
+	    nels *= var_shape[i][j];
+#line 248
+	}
+#line 248
+	allInExtRange = allInIntRange = 1;
+#line 248
+	for (j = 0; j < nels; j++) {
+#line 248
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+#line 248
+	    IF (err)
+#line 248
+		error("error in toMixedBase 1");
+#line 248
+	    expect[j] = hash4(var_type[i], var_rank[i], index, NCT_ULONGLONG);
+#line 248
+	    if (inRange3(expect[j],var_type[i], NCT_ULONGLONG)) {
+#line 248
+		allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+#line 248
+			    && expect[j] <= ulonglong_max;
+#line 248
+	    } else {
+#line 248
+		allInExtRange = 0;
+#line 248
+	    }
+#line 248
+	}
+#line 248
+	err = nc_get_var_ulonglong(ncid, i, value);
+#line 248
+	if (canConvert) {
+#line 248
+	    if (allInExtRange) {
+#line 248
+		if (allInIntRange) {
+#line 248
+		    IF (err)
+#line 248
+			error("%s", nc_strerror(err));
+#line 248
+		} else {
+#line 248
+		    IF (err != NC_ERANGE)
+#line 248
+			error("Range error: status = %d", err);
+#line 248
+		}
+#line 248
+	    } else {
+#line 248
+		IF (err != 0 && err != NC_ERANGE)
+#line 248
+		    error("OK or Range error: status = %d", err);
+#line 248
+	    }
+#line 248
+	    for (j = 0; j < nels; j++) {
+#line 248
+		if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+#line 248
+			&& expect[j] >= ulonglong_min && expect[j] <= ulonglong_max) {
+#line 248
+		    IF (!equal(value[j],expect[j],var_type[i],NCT_ULONGLONG)){
+#line 248
+			error("value read not that expected");
+#line 248
+			if (verbose) {
+#line 248
+			    error("\n");
+#line 248
+			    error("varid: %d, ", i);
+#line 248
+			    error("var_name: %s, ", var_name[i]);
+#line 248
+			    error("element number: %d ", j);
+#line 248
+			    error("expect: %g", expect[j]);
+#line 248
+			    error("got: %g", (double) value[j]);
+#line 248
+			}
+#line 248
+		    } else {
+#line 248
+			nok++;
+#line 248
+		    }
+#line 248
+		}
+#line 248
+	    }
+#line 248
+	} else {
+#line 248
+	    IF (nels > 0 && err != NC_ECHAR)
+#line 248
+		error("wrong type: status = %d", err);
+#line 248
+	}
+#line 248
+    }
+#line 248
+    err = nc_close(ncid);
+#line 248
+    IF (err)
+#line 248
+	error("nc_close: %s", nc_strerror(err));
+#line 248
+    print_nok(nok);
+#line 248
+}
+#line 248
+
+
+
+#line 424
+
+void
+#line 425
+test_nc_get_vara_text(void)
+#line 425
+{
+#line 425
+    int ncid;
+#line 425
+    int d;
+#line 425
+    int i;
+#line 425
+    int j;
+#line 425
+    int k;
+#line 425
+    int err;
+#line 425
+    int allInExtRange;	/* all values within external range? */
+#line 425
+    int allInIntRange;	/* all values within internal range? */
+#line 425
+    int nels;
+#line 425
+    int nslabs;
+#line 425
+    int nok = 0;      /* count of valid comparisons */
+#line 425
+    size_t start[MAX_RANK];
+#line 425
+    size_t edge[MAX_RANK];
+#line 425
+    size_t index[MAX_RANK];
+#line 425
+    size_t mid[MAX_RANK];
+#line 425
+    int canConvert;     /* Both text or both numeric */
+#line 425
+    text value[MAX_NELS];
+#line 425
+    double expect[MAX_NELS];
+#line 425
+
+#line 425
+#ifdef TEST_PNETCDF
+#line 425
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 425
+#else
+#line 425
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 425
+#endif
+#line 425
+    IF (err)
+#line 425
+	error("nc_open: %s", nc_strerror(err));
+#line 425
+    for (i = 0; i < numVars; i++) {
+#line 425
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+#line 425
+        assert(var_rank[i] <= MAX_RANK);
+#line 425
+        assert(var_nels[i] <= MAX_NELS);
+#line 425
+	for (j = 0; j < var_rank[i]; j++) {
+#line 425
+	    start[j] = 0;
+#line 425
+	    edge[j] = 1;
+#line 425
+	}
+#line 425
+        err = nc_get_vara_text(BAD_ID, i, start, edge, value);
+#line 425
+        IF (err != NC_EBADID)
+#line 425
+	    error("bad ncid: status = %d", err);
+#line 425
+        err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value);
+#line 425
+        IF (err != NC_ENOTVAR)
+#line 425
+	    error("bad var id: status = %d", err);
+#line 425
+	for (j = 0; j < var_rank[i]; j++) {
+#line 425
+	    start[j] = var_shape[i][j];
+#line 425
+	    err = nc_get_vara_text(ncid, i, start, edge, value);
+#line 425
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 425
+                error("bad index: status = %d", err);
+#line 425
+	    start[j] = 0;
+#line 425
+	    edge[j] = var_shape[i][j] + 1;
+#line 425
+	    err = nc_get_vara_text(ncid, i, start, edge, value);
+#line 425
+            IF (canConvert && err != NC_EEDGE)
+#line 425
+		error("bad edge: status = %d", err);
+#line 425
+	    edge[j] = 1;
+#line 425
+	}
+#line 425
+            /* Check non-scalars for correct error returned even when */
+#line 425
+            /* there is nothing to get (edge[j]==0) */
+#line 425
+	if(var_rank[i] > 0) {
+#line 425
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 425
+		edge[j] = 0;
+#line 425
+	    }
+#line 425
+	    err = nc_get_vara_text(BAD_ID, i, start, edge, value);
+#line 425
+	    IF (err != NC_EBADID) 
+#line 425
+		error("bad ncid: status = %d", err);
+#line 425
+	    err = nc_get_vara_text(ncid, BAD_VARID, start, edge, value);
+#line 425
+	    IF (err != NC_ENOTVAR) 
+#line 425
+		error("bad var id: status = %d", err);
+#line 425
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 425
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 425
+		    start[j] = var_shape[i][j];
+#line 425
+		    err = nc_get_vara_text(ncid, i, start, edge, value);
+#line 425
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 425
+			error("bad start: status = %d", err);
+#line 425
+		    start[j] = 0;
+#line 425
+		}
+#line 425
+	    }
+#line 425
+	    err = nc_get_vara_text(ncid, i, start, edge, value);
+#line 425
+	    if (canConvert) {
+#line 425
+		IF (err) 
+#line 425
+		    error("%s", nc_strerror(err));
+#line 425
+	    } else {
+#line 425
+		IF (err != NC_ECHAR)
+#line 425
+		    error("wrong type: status = %d", err);
+#line 425
+	    }
+#line 425
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 425
+		edge[j] = 1;
+#line 425
+	    }
+#line 425
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 425
+            /* get 2^rank (nslabs) slabs so defined */
+#line 425
+        nslabs = 1;
+#line 425
+        for (j = 0; j < var_rank[i]; j++) {
+#line 425
+            mid[j] = roll( var_shape[i][j] );
+#line 425
+            nslabs *= 2;
+#line 425
+        }
+#line 425
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 425
+        for (k = 0; k < nslabs; k++) {
+#line 425
+            nels = 1;
+#line 425
+            for (j = 0; j < var_rank[i]; j++) {
+#line 425
+                if ((k >> j) & 1) {
+#line 425
+                    start[j] = 0;
+#line 425
+                    edge[j] = mid[j];
+#line 425
+                }else{
+#line 425
+                    start[j] = mid[j];
+#line 425
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 425
+                }
+#line 425
+                nels *= edge[j];
+#line 425
+            }
+#line 425
+	    allInExtRange = allInIntRange = 1;
+#line 425
+            for (j = 0; j < nels; j++) {
+#line 425
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 425
+                IF (err)
+#line 425
+                    error("error in toMixedBase 1");
+#line 425
+                for (d = 0; d < var_rank[i]; d++)
+#line 425
+                    index[d] += start[d];
+#line 425
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_TEXT);
+#line 425
+		if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
+#line 425
+		    allInIntRange = allInIntRange && expect[j] >= text_min
+#line 425
+				&& expect[j] <= text_max;
+#line 425
+		} else {
+#line 425
+		    allInExtRange = 0;
+#line 425
+		}
+#line 425
+	    }
+#line 425
+            if (var_rank[i] == 0 && i%2)
+#line 425
+		err = nc_get_vara_text(ncid, i, NULL, NULL, value);
+#line 425
+	    else
+#line 425
+		err = nc_get_vara_text(ncid, i, start, edge, value);
+#line 425
+            if (canConvert) {
+#line 425
+		if (allInExtRange) {
+#line 425
+		    if (allInIntRange) {
+#line 425
+			IF (err)
+#line 425
+			    error("%s", nc_strerror(err));
+#line 425
+		    } else {
+#line 425
+			IF (err != NC_ERANGE)
+#line 425
+			    error("Range error: status = %d", err);
+#line 425
+		    }
+#line 425
+		} else {
+#line 425
+		    IF (err != 0 && err != NC_ERANGE)
+#line 425
+			error("OK or Range error: status = %d", err);
+#line 425
+		}
+#line 425
+		for (j = 0; j < nels; j++) {
+#line 425
+		    if (inRange3(expect[j],var_type[i],NCT_TEXT)
+#line 425
+			    && expect[j] >= text_min && expect[j] <= text_max) {
+#line 425
+			IF (!equal(value[j],expect[j],var_type[i],NCT_TEXT)){
+#line 425
+			    error("value read not that expected");
+#line 425
+			    if (verbose) {
+#line 425
+				error("\n");
+#line 425
+				error("varid: %d, ", i);
+#line 425
+				error("var_name: %s, ", var_name[i]);
+#line 425
+				error("element number: %d ", j);
+#line 425
+				error("expect: %g", expect[j]);
+#line 425
+				error("got: %g", (double) value[j]);
+#line 425
+			    }
+#line 425
+			} else {
+#line 425
+			    nok++;
+#line 425
+			}
+#line 425
+		    }
+#line 425
+		}
+#line 425
+            } else {
+#line 425
+                IF (nels > 0 && err != NC_ECHAR)
+#line 425
+                    error("wrong type: status = %d", err);
+#line 425
+            }
+#line 425
+        }
+#line 425
+    }
+#line 425
+    err = nc_close(ncid);
+#line 425
+    IF (err)
+#line 425
+	error("nc_close: %s", nc_strerror(err));
+#line 425
+    print_nok(nok);
+#line 425
+}
+#line 425
+
+void
+#line 426
+test_nc_get_vara_uchar(void)
+#line 426
+{
+#line 426
+    int ncid;
+#line 426
+    int d;
+#line 426
+    int i;
+#line 426
+    int j;
+#line 426
+    int k;
+#line 426
+    int err;
+#line 426
+    int allInExtRange;	/* all values within external range? */
+#line 426
+    int allInIntRange;	/* all values within internal range? */
+#line 426
+    int nels;
+#line 426
+    int nslabs;
+#line 426
+    int nok = 0;      /* count of valid comparisons */
+#line 426
+    size_t start[MAX_RANK];
+#line 426
+    size_t edge[MAX_RANK];
+#line 426
+    size_t index[MAX_RANK];
+#line 426
+    size_t mid[MAX_RANK];
+#line 426
+    int canConvert;     /* Both text or both numeric */
+#line 426
+    uchar value[MAX_NELS];
+#line 426
+    double expect[MAX_NELS];
+#line 426
+
+#line 426
+#ifdef TEST_PNETCDF
+#line 426
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 426
+#else
+#line 426
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 426
+#endif
+#line 426
+    IF (err)
+#line 426
+	error("nc_open: %s", nc_strerror(err));
+#line 426
+    for (i = 0; i < numVars; i++) {
+#line 426
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+#line 426
+        assert(var_rank[i] <= MAX_RANK);
+#line 426
+        assert(var_nels[i] <= MAX_NELS);
+#line 426
+	for (j = 0; j < var_rank[i]; j++) {
+#line 426
+	    start[j] = 0;
+#line 426
+	    edge[j] = 1;
+#line 426
+	}
+#line 426
+        err = nc_get_vara_uchar(BAD_ID, i, start, edge, value);
+#line 426
+        IF (err != NC_EBADID)
+#line 426
+	    error("bad ncid: status = %d", err);
+#line 426
+        err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value);
+#line 426
+        IF (err != NC_ENOTVAR)
+#line 426
+	    error("bad var id: status = %d", err);
+#line 426
+	for (j = 0; j < var_rank[i]; j++) {
+#line 426
+	    start[j] = var_shape[i][j];
+#line 426
+	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
+#line 426
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 426
+                error("bad index: status = %d", err);
+#line 426
+	    start[j] = 0;
+#line 426
+	    edge[j] = var_shape[i][j] + 1;
+#line 426
+	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
+#line 426
+            IF (canConvert && err != NC_EEDGE)
+#line 426
+		error("bad edge: status = %d", err);
+#line 426
+	    edge[j] = 1;
+#line 426
+	}
+#line 426
+            /* Check non-scalars for correct error returned even when */
+#line 426
+            /* there is nothing to get (edge[j]==0) */
+#line 426
+	if(var_rank[i] > 0) {
+#line 426
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 426
+		edge[j] = 0;
+#line 426
+	    }
+#line 426
+	    err = nc_get_vara_uchar(BAD_ID, i, start, edge, value);
+#line 426
+	    IF (err != NC_EBADID) 
+#line 426
+		error("bad ncid: status = %d", err);
+#line 426
+	    err = nc_get_vara_uchar(ncid, BAD_VARID, start, edge, value);
+#line 426
+	    IF (err != NC_ENOTVAR) 
+#line 426
+		error("bad var id: status = %d", err);
+#line 426
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 426
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 426
+		    start[j] = var_shape[i][j];
+#line 426
+		    err = nc_get_vara_uchar(ncid, i, start, edge, value);
+#line 426
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 426
+			error("bad start: status = %d", err);
+#line 426
+		    start[j] = 0;
+#line 426
+		}
+#line 426
+	    }
+#line 426
+	    err = nc_get_vara_uchar(ncid, i, start, edge, value);
+#line 426
+	    if (canConvert) {
+#line 426
+		IF (err) 
+#line 426
+		    error("%s", nc_strerror(err));
+#line 426
+	    } else {
+#line 426
+		IF (err != NC_ECHAR)
+#line 426
+		    error("wrong type: status = %d", err);
+#line 426
+	    }
+#line 426
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 426
+		edge[j] = 1;
+#line 426
+	    }
+#line 426
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 426
+            /* get 2^rank (nslabs) slabs so defined */
+#line 426
+        nslabs = 1;
+#line 426
+        for (j = 0; j < var_rank[i]; j++) {
+#line 426
+            mid[j] = roll( var_shape[i][j] );
+#line 426
+            nslabs *= 2;
+#line 426
+        }
+#line 426
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 426
+        for (k = 0; k < nslabs; k++) {
+#line 426
+            nels = 1;
+#line 426
+            for (j = 0; j < var_rank[i]; j++) {
+#line 426
+                if ((k >> j) & 1) {
+#line 426
+                    start[j] = 0;
+#line 426
+                    edge[j] = mid[j];
+#line 426
+                }else{
+#line 426
+                    start[j] = mid[j];
+#line 426
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 426
+                }
+#line 426
+                nels *= edge[j];
+#line 426
+            }
+#line 426
+	    allInExtRange = allInIntRange = 1;
+#line 426
+            for (j = 0; j < nels; j++) {
+#line 426
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 426
+                IF (err)
+#line 426
+                    error("error in toMixedBase 1");
+#line 426
+                for (d = 0; d < var_rank[i]; d++)
+#line 426
+                    index[d] += start[d];
+#line 426
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UCHAR);
+#line 426
+		if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
+#line 426
+		    allInIntRange = allInIntRange && expect[j] >= uchar_min
+#line 426
+				&& expect[j] <= uchar_max;
+#line 426
+		} else {
+#line 426
+		    allInExtRange = 0;
+#line 426
+		}
+#line 426
+	    }
+#line 426
+            if (var_rank[i] == 0 && i%2)
+#line 426
+		err = nc_get_vara_uchar(ncid, i, NULL, NULL, value);
+#line 426
+	    else
+#line 426
+		err = nc_get_vara_uchar(ncid, i, start, edge, value);
+#line 426
+            if (canConvert) {
+#line 426
+		if (allInExtRange) {
+#line 426
+		    if (allInIntRange) {
+#line 426
+			IF (err)
+#line 426
+			    error("%s", nc_strerror(err));
+#line 426
+		    } else {
+#line 426
+			IF (err != NC_ERANGE)
+#line 426
+			    error("Range error: status = %d", err);
+#line 426
+		    }
+#line 426
+		} else {
+#line 426
+		    IF (err != 0 && err != NC_ERANGE)
+#line 426
+			error("OK or Range error: status = %d", err);
+#line 426
+		}
+#line 426
+		for (j = 0; j < nels; j++) {
+#line 426
+		    if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+#line 426
+			    && expect[j] >= uchar_min && expect[j] <= uchar_max) {
+#line 426
+			IF (!equal(value[j],expect[j],var_type[i],NCT_UCHAR)){
+#line 426
+			    error("value read not that expected");
+#line 426
+			    if (verbose) {
+#line 426
+				error("\n");
+#line 426
+				error("varid: %d, ", i);
+#line 426
+				error("var_name: %s, ", var_name[i]);
+#line 426
+				error("element number: %d ", j);
+#line 426
+				error("expect: %g", expect[j]);
+#line 426
+				error("got: %g", (double) value[j]);
+#line 426
+			    }
+#line 426
+			} else {
+#line 426
+			    nok++;
+#line 426
+			}
+#line 426
+		    }
+#line 426
+		}
+#line 426
+            } else {
+#line 426
+                IF (nels > 0 && err != NC_ECHAR)
+#line 426
+                    error("wrong type: status = %d", err);
+#line 426
+            }
+#line 426
+        }
+#line 426
+    }
+#line 426
+    err = nc_close(ncid);
+#line 426
+    IF (err)
+#line 426
+	error("nc_close: %s", nc_strerror(err));
+#line 426
+    print_nok(nok);
+#line 426
+}
+#line 426
+
+void
+#line 427
+test_nc_get_vara_schar(void)
+#line 427
+{
+#line 427
+    int ncid;
+#line 427
+    int d;
+#line 427
+    int i;
+#line 427
+    int j;
+#line 427
+    int k;
+#line 427
+    int err;
+#line 427
+    int allInExtRange;	/* all values within external range? */
+#line 427
+    int allInIntRange;	/* all values within internal range? */
+#line 427
+    int nels;
+#line 427
+    int nslabs;
+#line 427
+    int nok = 0;      /* count of valid comparisons */
+#line 427
+    size_t start[MAX_RANK];
+#line 427
+    size_t edge[MAX_RANK];
+#line 427
+    size_t index[MAX_RANK];
+#line 427
+    size_t mid[MAX_RANK];
+#line 427
+    int canConvert;     /* Both text or both numeric */
+#line 427
+    schar value[MAX_NELS];
+#line 427
+    double expect[MAX_NELS];
+#line 427
+
+#line 427
+#ifdef TEST_PNETCDF
+#line 427
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 427
+#else
+#line 427
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 427
+#endif
+#line 427
+    IF (err)
+#line 427
+	error("nc_open: %s", nc_strerror(err));
+#line 427
+    for (i = 0; i < numVars; i++) {
+#line 427
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+#line 427
+        assert(var_rank[i] <= MAX_RANK);
+#line 427
+        assert(var_nels[i] <= MAX_NELS);
+#line 427
+	for (j = 0; j < var_rank[i]; j++) {
+#line 427
+	    start[j] = 0;
+#line 427
+	    edge[j] = 1;
+#line 427
+	}
+#line 427
+        err = nc_get_vara_schar(BAD_ID, i, start, edge, value);
+#line 427
+        IF (err != NC_EBADID)
+#line 427
+	    error("bad ncid: status = %d", err);
+#line 427
+        err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value);
+#line 427
+        IF (err != NC_ENOTVAR)
+#line 427
+	    error("bad var id: status = %d", err);
+#line 427
+	for (j = 0; j < var_rank[i]; j++) {
+#line 427
+	    start[j] = var_shape[i][j];
+#line 427
+	    err = nc_get_vara_schar(ncid, i, start, edge, value);
+#line 427
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 427
+                error("bad index: status = %d", err);
+#line 427
+	    start[j] = 0;
+#line 427
+	    edge[j] = var_shape[i][j] + 1;
+#line 427
+	    err = nc_get_vara_schar(ncid, i, start, edge, value);
+#line 427
+            IF (canConvert && err != NC_EEDGE)
+#line 427
+		error("bad edge: status = %d", err);
+#line 427
+	    edge[j] = 1;
+#line 427
+	}
+#line 427
+            /* Check non-scalars for correct error returned even when */
+#line 427
+            /* there is nothing to get (edge[j]==0) */
+#line 427
+	if(var_rank[i] > 0) {
+#line 427
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 427
+		edge[j] = 0;
+#line 427
+	    }
+#line 427
+	    err = nc_get_vara_schar(BAD_ID, i, start, edge, value);
+#line 427
+	    IF (err != NC_EBADID) 
+#line 427
+		error("bad ncid: status = %d", err);
+#line 427
+	    err = nc_get_vara_schar(ncid, BAD_VARID, start, edge, value);
+#line 427
+	    IF (err != NC_ENOTVAR) 
+#line 427
+		error("bad var id: status = %d", err);
+#line 427
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 427
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 427
+		    start[j] = var_shape[i][j];
+#line 427
+		    err = nc_get_vara_schar(ncid, i, start, edge, value);
+#line 427
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 427
+			error("bad start: status = %d", err);
+#line 427
+		    start[j] = 0;
+#line 427
+		}
+#line 427
+	    }
+#line 427
+	    err = nc_get_vara_schar(ncid, i, start, edge, value);
+#line 427
+	    if (canConvert) {
+#line 427
+		IF (err) 
+#line 427
+		    error("%s", nc_strerror(err));
+#line 427
+	    } else {
+#line 427
+		IF (err != NC_ECHAR)
+#line 427
+		    error("wrong type: status = %d", err);
+#line 427
+	    }
+#line 427
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 427
+		edge[j] = 1;
+#line 427
+	    }
+#line 427
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 427
+            /* get 2^rank (nslabs) slabs so defined */
+#line 427
+        nslabs = 1;
+#line 427
+        for (j = 0; j < var_rank[i]; j++) {
+#line 427
+            mid[j] = roll( var_shape[i][j] );
+#line 427
+            nslabs *= 2;
+#line 427
+        }
+#line 427
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 427
+        for (k = 0; k < nslabs; k++) {
+#line 427
+            nels = 1;
+#line 427
+            for (j = 0; j < var_rank[i]; j++) {
+#line 427
+                if ((k >> j) & 1) {
+#line 427
+                    start[j] = 0;
+#line 427
+                    edge[j] = mid[j];
+#line 427
+                }else{
+#line 427
+                    start[j] = mid[j];
+#line 427
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 427
+                }
+#line 427
+                nels *= edge[j];
+#line 427
+            }
+#line 427
+	    allInExtRange = allInIntRange = 1;
+#line 427
+            for (j = 0; j < nels; j++) {
+#line 427
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 427
+                IF (err)
+#line 427
+                    error("error in toMixedBase 1");
+#line 427
+                for (d = 0; d < var_rank[i]; d++)
+#line 427
+                    index[d] += start[d];
+#line 427
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SCHAR);
+#line 427
+		if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
+#line 427
+		    allInIntRange = allInIntRange && expect[j] >= schar_min
+#line 427
+				&& expect[j] <= schar_max;
+#line 427
+		} else {
+#line 427
+		    allInExtRange = 0;
+#line 427
+		}
+#line 427
+	    }
+#line 427
+            if (var_rank[i] == 0 && i%2)
+#line 427
+		err = nc_get_vara_schar(ncid, i, NULL, NULL, value);
+#line 427
+	    else
+#line 427
+		err = nc_get_vara_schar(ncid, i, start, edge, value);
+#line 427
+            if (canConvert) {
+#line 427
+		if (allInExtRange) {
+#line 427
+		    if (allInIntRange) {
+#line 427
+			IF (err)
+#line 427
+			    error("%s", nc_strerror(err));
+#line 427
+		    } else {
+#line 427
+			IF (err != NC_ERANGE)
+#line 427
+			    error("Range error: status = %d", err);
+#line 427
+		    }
+#line 427
+		} else {
+#line 427
+		    IF (err != 0 && err != NC_ERANGE)
+#line 427
+			error("OK or Range error: status = %d", err);
+#line 427
+		}
+#line 427
+		for (j = 0; j < nels; j++) {
+#line 427
+		    if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+#line 427
+			    && expect[j] >= schar_min && expect[j] <= schar_max) {
+#line 427
+			IF (!equal(value[j],expect[j],var_type[i],NCT_SCHAR)){
+#line 427
+			    error("value read not that expected");
+#line 427
+			    if (verbose) {
+#line 427
+				error("\n");
+#line 427
+				error("varid: %d, ", i);
+#line 427
+				error("var_name: %s, ", var_name[i]);
+#line 427
+				error("element number: %d ", j);
+#line 427
+				error("expect: %g", expect[j]);
+#line 427
+				error("got: %g", (double) value[j]);
+#line 427
+			    }
+#line 427
+			} else {
+#line 427
+			    nok++;
+#line 427
+			}
+#line 427
+		    }
+#line 427
+		}
+#line 427
+            } else {
+#line 427
+                IF (nels > 0 && err != NC_ECHAR)
+#line 427
+                    error("wrong type: status = %d", err);
+#line 427
+            }
+#line 427
+        }
+#line 427
+    }
+#line 427
+    err = nc_close(ncid);
+#line 427
+    IF (err)
+#line 427
+	error("nc_close: %s", nc_strerror(err));
+#line 427
+    print_nok(nok);
+#line 427
+}
+#line 427
+
+void
+#line 428
+test_nc_get_vara_short(void)
+#line 428
+{
+#line 428
+    int ncid;
+#line 428
+    int d;
+#line 428
+    int i;
+#line 428
+    int j;
+#line 428
+    int k;
+#line 428
+    int err;
+#line 428
+    int allInExtRange;	/* all values within external range? */
+#line 428
+    int allInIntRange;	/* all values within internal range? */
+#line 428
+    int nels;
+#line 428
+    int nslabs;
+#line 428
+    int nok = 0;      /* count of valid comparisons */
+#line 428
+    size_t start[MAX_RANK];
+#line 428
+    size_t edge[MAX_RANK];
+#line 428
+    size_t index[MAX_RANK];
+#line 428
+    size_t mid[MAX_RANK];
+#line 428
+    int canConvert;     /* Both text or both numeric */
+#line 428
+    short value[MAX_NELS];
+#line 428
+    double expect[MAX_NELS];
+#line 428
+
+#line 428
+#ifdef TEST_PNETCDF
+#line 428
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 428
+#else
+#line 428
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 428
+#endif
+#line 428
+    IF (err)
+#line 428
+	error("nc_open: %s", nc_strerror(err));
+#line 428
+    for (i = 0; i < numVars; i++) {
+#line 428
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+#line 428
+        assert(var_rank[i] <= MAX_RANK);
+#line 428
+        assert(var_nels[i] <= MAX_NELS);
+#line 428
+	for (j = 0; j < var_rank[i]; j++) {
+#line 428
+	    start[j] = 0;
+#line 428
+	    edge[j] = 1;
+#line 428
+	}
+#line 428
+        err = nc_get_vara_short(BAD_ID, i, start, edge, value);
+#line 428
+        IF (err != NC_EBADID)
+#line 428
+	    error("bad ncid: status = %d", err);
+#line 428
+        err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value);
+#line 428
+        IF (err != NC_ENOTVAR)
+#line 428
+	    error("bad var id: status = %d", err);
+#line 428
+	for (j = 0; j < var_rank[i]; j++) {
+#line 428
+	    start[j] = var_shape[i][j];
+#line 428
+	    err = nc_get_vara_short(ncid, i, start, edge, value);
+#line 428
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 428
+                error("bad index: status = %d", err);
+#line 428
+	    start[j] = 0;
+#line 428
+	    edge[j] = var_shape[i][j] + 1;
+#line 428
+	    err = nc_get_vara_short(ncid, i, start, edge, value);
+#line 428
+            IF (canConvert && err != NC_EEDGE)
+#line 428
+		error("bad edge: status = %d", err);
+#line 428
+	    edge[j] = 1;
+#line 428
+	}
+#line 428
+            /* Check non-scalars for correct error returned even when */
+#line 428
+            /* there is nothing to get (edge[j]==0) */
+#line 428
+	if(var_rank[i] > 0) {
+#line 428
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 428
+		edge[j] = 0;
+#line 428
+	    }
+#line 428
+	    err = nc_get_vara_short(BAD_ID, i, start, edge, value);
+#line 428
+	    IF (err != NC_EBADID) 
+#line 428
+		error("bad ncid: status = %d", err);
+#line 428
+	    err = nc_get_vara_short(ncid, BAD_VARID, start, edge, value);
+#line 428
+	    IF (err != NC_ENOTVAR) 
+#line 428
+		error("bad var id: status = %d", err);
+#line 428
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 428
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 428
+		    start[j] = var_shape[i][j];
+#line 428
+		    err = nc_get_vara_short(ncid, i, start, edge, value);
+#line 428
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 428
+			error("bad start: status = %d", err);
+#line 428
+		    start[j] = 0;
+#line 428
+		}
+#line 428
+	    }
+#line 428
+	    err = nc_get_vara_short(ncid, i, start, edge, value);
+#line 428
+	    if (canConvert) {
+#line 428
+		IF (err) 
+#line 428
+		    error("%s", nc_strerror(err));
+#line 428
+	    } else {
+#line 428
+		IF (err != NC_ECHAR)
+#line 428
+		    error("wrong type: status = %d", err);
+#line 428
+	    }
+#line 428
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 428
+		edge[j] = 1;
+#line 428
+	    }
+#line 428
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 428
+            /* get 2^rank (nslabs) slabs so defined */
+#line 428
+        nslabs = 1;
+#line 428
+        for (j = 0; j < var_rank[i]; j++) {
+#line 428
+            mid[j] = roll( var_shape[i][j] );
+#line 428
+            nslabs *= 2;
+#line 428
+        }
+#line 428
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 428
+        for (k = 0; k < nslabs; k++) {
+#line 428
+            nels = 1;
+#line 428
+            for (j = 0; j < var_rank[i]; j++) {
+#line 428
+                if ((k >> j) & 1) {
+#line 428
+                    start[j] = 0;
+#line 428
+                    edge[j] = mid[j];
+#line 428
+                }else{
+#line 428
+                    start[j] = mid[j];
+#line 428
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 428
+                }
+#line 428
+                nels *= edge[j];
+#line 428
+            }
+#line 428
+	    allInExtRange = allInIntRange = 1;
+#line 428
+            for (j = 0; j < nels; j++) {
+#line 428
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 428
+                IF (err)
+#line 428
+                    error("error in toMixedBase 1");
+#line 428
+                for (d = 0; d < var_rank[i]; d++)
+#line 428
+                    index[d] += start[d];
+#line 428
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_SHORT);
+#line 428
+		if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
+#line 428
+		    allInIntRange = allInIntRange && expect[j] >= short_min
+#line 428
+				&& expect[j] <= short_max;
+#line 428
+		} else {
+#line 428
+		    allInExtRange = 0;
+#line 428
+		}
+#line 428
+	    }
+#line 428
+            if (var_rank[i] == 0 && i%2)
+#line 428
+		err = nc_get_vara_short(ncid, i, NULL, NULL, value);
+#line 428
+	    else
+#line 428
+		err = nc_get_vara_short(ncid, i, start, edge, value);
+#line 428
+            if (canConvert) {
+#line 428
+		if (allInExtRange) {
+#line 428
+		    if (allInIntRange) {
+#line 428
+			IF (err)
+#line 428
+			    error("%s", nc_strerror(err));
+#line 428
+		    } else {
+#line 428
+			IF (err != NC_ERANGE)
+#line 428
+			    error("Range error: status = %d", err);
+#line 428
+		    }
+#line 428
+		} else {
+#line 428
+		    IF (err != 0 && err != NC_ERANGE)
+#line 428
+			error("OK or Range error: status = %d", err);
+#line 428
+		}
+#line 428
+		for (j = 0; j < nels; j++) {
+#line 428
+		    if (inRange3(expect[j],var_type[i],NCT_SHORT)
+#line 428
+			    && expect[j] >= short_min && expect[j] <= short_max) {
+#line 428
+			IF (!equal(value[j],expect[j],var_type[i],NCT_SHORT)){
+#line 428
+			    error("value read not that expected");
+#line 428
+			    if (verbose) {
+#line 428
+				error("\n");
+#line 428
+				error("varid: %d, ", i);
+#line 428
+				error("var_name: %s, ", var_name[i]);
+#line 428
+				error("element number: %d ", j);
+#line 428
+				error("expect: %g", expect[j]);
+#line 428
+				error("got: %g", (double) value[j]);
+#line 428
+			    }
+#line 428
+			} else {
+#line 428
+			    nok++;
+#line 428
+			}
+#line 428
+		    }
+#line 428
+		}
+#line 428
+            } else {
+#line 428
+                IF (nels > 0 && err != NC_ECHAR)
+#line 428
+                    error("wrong type: status = %d", err);
+#line 428
+            }
+#line 428
+        }
+#line 428
+    }
+#line 428
+    err = nc_close(ncid);
+#line 428
+    IF (err)
+#line 428
+	error("nc_close: %s", nc_strerror(err));
+#line 428
+    print_nok(nok);
+#line 428
+}
+#line 428
+
+void
+#line 429
+test_nc_get_vara_int(void)
+#line 429
+{
+#line 429
+    int ncid;
+#line 429
+    int d;
+#line 429
+    int i;
+#line 429
+    int j;
+#line 429
+    int k;
+#line 429
+    int err;
+#line 429
+    int allInExtRange;	/* all values within external range? */
+#line 429
+    int allInIntRange;	/* all values within internal range? */
+#line 429
+    int nels;
+#line 429
+    int nslabs;
+#line 429
+    int nok = 0;      /* count of valid comparisons */
+#line 429
+    size_t start[MAX_RANK];
+#line 429
+    size_t edge[MAX_RANK];
+#line 429
+    size_t index[MAX_RANK];
+#line 429
+    size_t mid[MAX_RANK];
+#line 429
+    int canConvert;     /* Both text or both numeric */
+#line 429
+    int value[MAX_NELS];
+#line 429
+    double expect[MAX_NELS];
+#line 429
+
+#line 429
+#ifdef TEST_PNETCDF
+#line 429
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 429
+#else
+#line 429
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 429
+#endif
+#line 429
+    IF (err)
+#line 429
+	error("nc_open: %s", nc_strerror(err));
+#line 429
+    for (i = 0; i < numVars; i++) {
+#line 429
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+#line 429
+        assert(var_rank[i] <= MAX_RANK);
+#line 429
+        assert(var_nels[i] <= MAX_NELS);
+#line 429
+	for (j = 0; j < var_rank[i]; j++) {
+#line 429
+	    start[j] = 0;
+#line 429
+	    edge[j] = 1;
+#line 429
+	}
+#line 429
+        err = nc_get_vara_int(BAD_ID, i, start, edge, value);
+#line 429
+        IF (err != NC_EBADID)
+#line 429
+	    error("bad ncid: status = %d", err);
+#line 429
+        err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value);
+#line 429
+        IF (err != NC_ENOTVAR)
+#line 429
+	    error("bad var id: status = %d", err);
+#line 429
+	for (j = 0; j < var_rank[i]; j++) {
+#line 429
+	    start[j] = var_shape[i][j];
+#line 429
+	    err = nc_get_vara_int(ncid, i, start, edge, value);
+#line 429
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 429
+                error("bad index: status = %d", err);
+#line 429
+	    start[j] = 0;
+#line 429
+	    edge[j] = var_shape[i][j] + 1;
+#line 429
+	    err = nc_get_vara_int(ncid, i, start, edge, value);
+#line 429
+            IF (canConvert && err != NC_EEDGE)
+#line 429
+		error("bad edge: status = %d", err);
+#line 429
+	    edge[j] = 1;
+#line 429
+	}
+#line 429
+            /* Check non-scalars for correct error returned even when */
+#line 429
+            /* there is nothing to get (edge[j]==0) */
+#line 429
+	if(var_rank[i] > 0) {
+#line 429
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 429
+		edge[j] = 0;
+#line 429
+	    }
+#line 429
+	    err = nc_get_vara_int(BAD_ID, i, start, edge, value);
+#line 429
+	    IF (err != NC_EBADID) 
+#line 429
+		error("bad ncid: status = %d", err);
+#line 429
+	    err = nc_get_vara_int(ncid, BAD_VARID, start, edge, value);
+#line 429
+	    IF (err != NC_ENOTVAR) 
+#line 429
+		error("bad var id: status = %d", err);
+#line 429
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 429
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 429
+		    start[j] = var_shape[i][j];
+#line 429
+		    err = nc_get_vara_int(ncid, i, start, edge, value);
+#line 429
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 429
+			error("bad start: status = %d", err);
+#line 429
+		    start[j] = 0;
+#line 429
+		}
+#line 429
+	    }
+#line 429
+	    err = nc_get_vara_int(ncid, i, start, edge, value);
+#line 429
+	    if (canConvert) {
+#line 429
+		IF (err) 
+#line 429
+		    error("%s", nc_strerror(err));
+#line 429
+	    } else {
+#line 429
+		IF (err != NC_ECHAR)
+#line 429
+		    error("wrong type: status = %d", err);
+#line 429
+	    }
+#line 429
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 429
+		edge[j] = 1;
+#line 429
+	    }
+#line 429
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 429
+            /* get 2^rank (nslabs) slabs so defined */
+#line 429
+        nslabs = 1;
+#line 429
+        for (j = 0; j < var_rank[i]; j++) {
+#line 429
+            mid[j] = roll( var_shape[i][j] );
+#line 429
+            nslabs *= 2;
+#line 429
+        }
+#line 429
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 429
+        for (k = 0; k < nslabs; k++) {
+#line 429
+            nels = 1;
+#line 429
+            for (j = 0; j < var_rank[i]; j++) {
+#line 429
+                if ((k >> j) & 1) {
+#line 429
+                    start[j] = 0;
+#line 429
+                    edge[j] = mid[j];
+#line 429
+                }else{
+#line 429
+                    start[j] = mid[j];
+#line 429
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 429
+                }
+#line 429
+                nels *= edge[j];
+#line 429
+            }
+#line 429
+	    allInExtRange = allInIntRange = 1;
+#line 429
+            for (j = 0; j < nels; j++) {
+#line 429
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 429
+                IF (err)
+#line 429
+                    error("error in toMixedBase 1");
+#line 429
+                for (d = 0; d < var_rank[i]; d++)
+#line 429
+                    index[d] += start[d];
+#line 429
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_INT);
+#line 429
+		if (inRange3(expect[j],var_type[i], NCT_INT)) {
+#line 429
+		    allInIntRange = allInIntRange && expect[j] >= int_min
+#line 429
+				&& expect[j] <= int_max;
+#line 429
+		} else {
+#line 429
+		    allInExtRange = 0;
+#line 429
+		}
+#line 429
+	    }
+#line 429
+            if (var_rank[i] == 0 && i%2)
+#line 429
+		err = nc_get_vara_int(ncid, i, NULL, NULL, value);
+#line 429
+	    else
+#line 429
+		err = nc_get_vara_int(ncid, i, start, edge, value);
+#line 429
+            if (canConvert) {
+#line 429
+		if (allInExtRange) {
+#line 429
+		    if (allInIntRange) {
+#line 429
+			IF (err)
+#line 429
+			    error("%s", nc_strerror(err));
+#line 429
+		    } else {
+#line 429
+			IF (err != NC_ERANGE)
+#line 429
+			    error("Range error: status = %d", err);
+#line 429
+		    }
+#line 429
+		} else {
+#line 429
+		    IF (err != 0 && err != NC_ERANGE)
+#line 429
+			error("OK or Range error: status = %d", err);
+#line 429
+		}
+#line 429
+		for (j = 0; j < nels; j++) {
+#line 429
+		    if (inRange3(expect[j],var_type[i],NCT_INT)
+#line 429
+			    && expect[j] >= int_min && expect[j] <= int_max) {
+#line 429
+			IF (!equal(value[j],expect[j],var_type[i],NCT_INT)){
+#line 429
+			    error("value read not that expected");
+#line 429
+			    if (verbose) {
+#line 429
+				error("\n");
+#line 429
+				error("varid: %d, ", i);
+#line 429
+				error("var_name: %s, ", var_name[i]);
+#line 429
+				error("element number: %d ", j);
+#line 429
+				error("expect: %g", expect[j]);
+#line 429
+				error("got: %g", (double) value[j]);
+#line 429
+			    }
+#line 429
+			} else {
+#line 429
+			    nok++;
+#line 429
+			}
+#line 429
+		    }
+#line 429
+		}
+#line 429
+            } else {
+#line 429
+                IF (nels > 0 && err != NC_ECHAR)
+#line 429
+                    error("wrong type: status = %d", err);
+#line 429
+            }
+#line 429
+        }
+#line 429
+    }
+#line 429
+    err = nc_close(ncid);
+#line 429
+    IF (err)
+#line 429
+	error("nc_close: %s", nc_strerror(err));
+#line 429
+    print_nok(nok);
+#line 429
+}
+#line 429
+
+void
+#line 430
+test_nc_get_vara_long(void)
+#line 430
+{
+#line 430
+    int ncid;
+#line 430
+    int d;
+#line 430
+    int i;
+#line 430
+    int j;
+#line 430
+    int k;
+#line 430
+    int err;
+#line 430
+    int allInExtRange;	/* all values within external range? */
+#line 430
+    int allInIntRange;	/* all values within internal range? */
+#line 430
+    int nels;
+#line 430
+    int nslabs;
+#line 430
+    int nok = 0;      /* count of valid comparisons */
+#line 430
+    size_t start[MAX_RANK];
+#line 430
+    size_t edge[MAX_RANK];
+#line 430
+    size_t index[MAX_RANK];
+#line 430
+    size_t mid[MAX_RANK];
+#line 430
+    int canConvert;     /* Both text or both numeric */
+#line 430
+    long value[MAX_NELS];
+#line 430
+    double expect[MAX_NELS];
+#line 430
+
+#line 430
+#ifdef TEST_PNETCDF
+#line 430
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 430
+#else
+#line 430
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 430
+#endif
+#line 430
+    IF (err)
+#line 430
+	error("nc_open: %s", nc_strerror(err));
+#line 430
+    for (i = 0; i < numVars; i++) {
+#line 430
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+#line 430
+        assert(var_rank[i] <= MAX_RANK);
+#line 430
+        assert(var_nels[i] <= MAX_NELS);
+#line 430
+	for (j = 0; j < var_rank[i]; j++) {
+#line 430
+	    start[j] = 0;
+#line 430
+	    edge[j] = 1;
+#line 430
+	}
+#line 430
+        err = nc_get_vara_long(BAD_ID, i, start, edge, value);
+#line 430
+        IF (err != NC_EBADID)
+#line 430
+	    error("bad ncid: status = %d", err);
+#line 430
+        err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value);
+#line 430
+        IF (err != NC_ENOTVAR)
+#line 430
+	    error("bad var id: status = %d", err);
+#line 430
+	for (j = 0; j < var_rank[i]; j++) {
+#line 430
+	    start[j] = var_shape[i][j];
+#line 430
+	    err = nc_get_vara_long(ncid, i, start, edge, value);
+#line 430
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 430
+                error("bad index: status = %d", err);
+#line 430
+	    start[j] = 0;
+#line 430
+	    edge[j] = var_shape[i][j] + 1;
+#line 430
+	    err = nc_get_vara_long(ncid, i, start, edge, value);
+#line 430
+            IF (canConvert && err != NC_EEDGE)
+#line 430
+		error("bad edge: status = %d", err);
+#line 430
+	    edge[j] = 1;
+#line 430
+	}
+#line 430
+            /* Check non-scalars for correct error returned even when */
+#line 430
+            /* there is nothing to get (edge[j]==0) */
+#line 430
+	if(var_rank[i] > 0) {
+#line 430
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 430
+		edge[j] = 0;
+#line 430
+	    }
+#line 430
+	    err = nc_get_vara_long(BAD_ID, i, start, edge, value);
+#line 430
+	    IF (err != NC_EBADID) 
+#line 430
+		error("bad ncid: status = %d", err);
+#line 430
+	    err = nc_get_vara_long(ncid, BAD_VARID, start, edge, value);
+#line 430
+	    IF (err != NC_ENOTVAR) 
+#line 430
+		error("bad var id: status = %d", err);
+#line 430
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 430
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 430
+		    start[j] = var_shape[i][j];
+#line 430
+		    err = nc_get_vara_long(ncid, i, start, edge, value);
+#line 430
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 430
+			error("bad start: status = %d", err);
+#line 430
+		    start[j] = 0;
+#line 430
+		}
+#line 430
+	    }
+#line 430
+	    err = nc_get_vara_long(ncid, i, start, edge, value);
+#line 430
+	    if (canConvert) {
+#line 430
+		IF (err) 
+#line 430
+		    error("%s", nc_strerror(err));
+#line 430
+	    } else {
+#line 430
+		IF (err != NC_ECHAR)
+#line 430
+		    error("wrong type: status = %d", err);
+#line 430
+	    }
+#line 430
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 430
+		edge[j] = 1;
+#line 430
+	    }
+#line 430
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 430
+            /* get 2^rank (nslabs) slabs so defined */
+#line 430
+        nslabs = 1;
+#line 430
+        for (j = 0; j < var_rank[i]; j++) {
+#line 430
+            mid[j] = roll( var_shape[i][j] );
+#line 430
+            nslabs *= 2;
+#line 430
+        }
+#line 430
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 430
+        for (k = 0; k < nslabs; k++) {
+#line 430
+            nels = 1;
+#line 430
+            for (j = 0; j < var_rank[i]; j++) {
+#line 430
+                if ((k >> j) & 1) {
+#line 430
+                    start[j] = 0;
+#line 430
+                    edge[j] = mid[j];
+#line 430
+                }else{
+#line 430
+                    start[j] = mid[j];
+#line 430
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 430
+                }
+#line 430
+                nels *= edge[j];
+#line 430
+            }
+#line 430
+	    allInExtRange = allInIntRange = 1;
+#line 430
+            for (j = 0; j < nels; j++) {
+#line 430
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 430
+                IF (err)
+#line 430
+                    error("error in toMixedBase 1");
+#line 430
+                for (d = 0; d < var_rank[i]; d++)
+#line 430
+                    index[d] += start[d];
+#line 430
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONG);
+#line 430
+		if (inRange3(expect[j],var_type[i], NCT_LONG)) {
+#line 430
+		    allInIntRange = allInIntRange && expect[j] >= long_min
+#line 430
+				&& expect[j] <= long_max;
+#line 430
+		} else {
+#line 430
+		    allInExtRange = 0;
+#line 430
+		}
+#line 430
+	    }
+#line 430
+            if (var_rank[i] == 0 && i%2)
+#line 430
+		err = nc_get_vara_long(ncid, i, NULL, NULL, value);
+#line 430
+	    else
+#line 430
+		err = nc_get_vara_long(ncid, i, start, edge, value);
+#line 430
+            if (canConvert) {
+#line 430
+		if (allInExtRange) {
+#line 430
+		    if (allInIntRange) {
+#line 430
+			IF (err)
+#line 430
+			    error("%s", nc_strerror(err));
+#line 430
+		    } else {
+#line 430
+			IF (err != NC_ERANGE)
+#line 430
+			    error("Range error: status = %d", err);
+#line 430
+		    }
+#line 430
+		} else {
+#line 430
+		    IF (err != 0 && err != NC_ERANGE)
+#line 430
+			error("OK or Range error: status = %d", err);
+#line 430
+		}
+#line 430
+		for (j = 0; j < nels; j++) {
+#line 430
+		    if (inRange3(expect[j],var_type[i],NCT_LONG)
+#line 430
+			    && expect[j] >= long_min && expect[j] <= long_max) {
+#line 430
+			IF (!equal(value[j],expect[j],var_type[i],NCT_LONG)){
+#line 430
+			    error("value read not that expected");
+#line 430
+			    if (verbose) {
+#line 430
+				error("\n");
+#line 430
+				error("varid: %d, ", i);
+#line 430
+				error("var_name: %s, ", var_name[i]);
+#line 430
+				error("element number: %d ", j);
+#line 430
+				error("expect: %g", expect[j]);
+#line 430
+				error("got: %g", (double) value[j]);
+#line 430
+			    }
+#line 430
+			} else {
+#line 430
+			    nok++;
+#line 430
+			}
+#line 430
+		    }
+#line 430
+		}
+#line 430
+            } else {
+#line 430
+                IF (nels > 0 && err != NC_ECHAR)
+#line 430
+                    error("wrong type: status = %d", err);
+#line 430
+            }
+#line 430
+        }
+#line 430
+    }
+#line 430
+    err = nc_close(ncid);
+#line 430
+    IF (err)
+#line 430
+	error("nc_close: %s", nc_strerror(err));
+#line 430
+    print_nok(nok);
+#line 430
+}
+#line 430
+
+void
+#line 431
+test_nc_get_vara_float(void)
+#line 431
+{
+#line 431
+    int ncid;
+#line 431
+    int d;
+#line 431
+    int i;
+#line 431
+    int j;
+#line 431
+    int k;
+#line 431
+    int err;
+#line 431
+    int allInExtRange;	/* all values within external range? */
+#line 431
+    int allInIntRange;	/* all values within internal range? */
+#line 431
+    int nels;
+#line 431
+    int nslabs;
+#line 431
+    int nok = 0;      /* count of valid comparisons */
+#line 431
+    size_t start[MAX_RANK];
+#line 431
+    size_t edge[MAX_RANK];
+#line 431
+    size_t index[MAX_RANK];
+#line 431
+    size_t mid[MAX_RANK];
+#line 431
+    int canConvert;     /* Both text or both numeric */
+#line 431
+    float value[MAX_NELS];
+#line 431
+    double expect[MAX_NELS];
+#line 431
+
+#line 431
+#ifdef TEST_PNETCDF
+#line 431
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 431
+#else
+#line 431
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 431
+#endif
+#line 431
+    IF (err)
+#line 431
+	error("nc_open: %s", nc_strerror(err));
+#line 431
+    for (i = 0; i < numVars; i++) {
+#line 431
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+#line 431
+        assert(var_rank[i] <= MAX_RANK);
+#line 431
+        assert(var_nels[i] <= MAX_NELS);
+#line 431
+	for (j = 0; j < var_rank[i]; j++) {
+#line 431
+	    start[j] = 0;
+#line 431
+	    edge[j] = 1;
+#line 431
+	}
+#line 431
+        err = nc_get_vara_float(BAD_ID, i, start, edge, value);
+#line 431
+        IF (err != NC_EBADID)
+#line 431
+	    error("bad ncid: status = %d", err);
+#line 431
+        err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value);
+#line 431
+        IF (err != NC_ENOTVAR)
+#line 431
+	    error("bad var id: status = %d", err);
+#line 431
+	for (j = 0; j < var_rank[i]; j++) {
+#line 431
+	    start[j] = var_shape[i][j];
+#line 431
+	    err = nc_get_vara_float(ncid, i, start, edge, value);
+#line 431
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 431
+                error("bad index: status = %d", err);
+#line 431
+	    start[j] = 0;
+#line 431
+	    edge[j] = var_shape[i][j] + 1;
+#line 431
+	    err = nc_get_vara_float(ncid, i, start, edge, value);
+#line 431
+            IF (canConvert && err != NC_EEDGE)
+#line 431
+		error("bad edge: status = %d", err);
+#line 431
+	    edge[j] = 1;
+#line 431
+	}
+#line 431
+            /* Check non-scalars for correct error returned even when */
+#line 431
+            /* there is nothing to get (edge[j]==0) */
+#line 431
+	if(var_rank[i] > 0) {
+#line 431
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 431
+		edge[j] = 0;
+#line 431
+	    }
+#line 431
+	    err = nc_get_vara_float(BAD_ID, i, start, edge, value);
+#line 431
+	    IF (err != NC_EBADID) 
+#line 431
+		error("bad ncid: status = %d", err);
+#line 431
+	    err = nc_get_vara_float(ncid, BAD_VARID, start, edge, value);
+#line 431
+	    IF (err != NC_ENOTVAR) 
+#line 431
+		error("bad var id: status = %d", err);
+#line 431
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 431
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 431
+		    start[j] = var_shape[i][j];
+#line 431
+		    err = nc_get_vara_float(ncid, i, start, edge, value);
+#line 431
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 431
+			error("bad start: status = %d", err);
+#line 431
+		    start[j] = 0;
+#line 431
+		}
+#line 431
+	    }
+#line 431
+	    err = nc_get_vara_float(ncid, i, start, edge, value);
+#line 431
+	    if (canConvert) {
+#line 431
+		IF (err) 
+#line 431
+		    error("%s", nc_strerror(err));
+#line 431
+	    } else {
+#line 431
+		IF (err != NC_ECHAR)
+#line 431
+		    error("wrong type: status = %d", err);
+#line 431
+	    }
+#line 431
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 431
+		edge[j] = 1;
+#line 431
+	    }
+#line 431
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 431
+            /* get 2^rank (nslabs) slabs so defined */
+#line 431
+        nslabs = 1;
+#line 431
+        for (j = 0; j < var_rank[i]; j++) {
+#line 431
+            mid[j] = roll( var_shape[i][j] );
+#line 431
+            nslabs *= 2;
+#line 431
+        }
+#line 431
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 431
+        for (k = 0; k < nslabs; k++) {
+#line 431
+            nels = 1;
+#line 431
+            for (j = 0; j < var_rank[i]; j++) {
+#line 431
+                if ((k >> j) & 1) {
+#line 431
+                    start[j] = 0;
+#line 431
+                    edge[j] = mid[j];
+#line 431
+                }else{
+#line 431
+                    start[j] = mid[j];
+#line 431
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 431
+                }
+#line 431
+                nels *= edge[j];
+#line 431
+            }
+#line 431
+	    allInExtRange = allInIntRange = 1;
+#line 431
+            for (j = 0; j < nels; j++) {
+#line 431
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 431
+                IF (err)
+#line 431
+                    error("error in toMixedBase 1");
+#line 431
+                for (d = 0; d < var_rank[i]; d++)
+#line 431
+                    index[d] += start[d];
+#line 431
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_FLOAT);
+#line 431
+		if (inRange3(expect[j],var_type[i], NCT_FLOAT)) {
+#line 431
+		    allInIntRange = allInIntRange && expect[j] >= float_min
+#line 431
+				&& expect[j] <= float_max;
+#line 431
+		} else {
+#line 431
+		    allInExtRange = 0;
+#line 431
+		}
+#line 431
+	    }
+#line 431
+            if (var_rank[i] == 0 && i%2)
+#line 431
+		err = nc_get_vara_float(ncid, i, NULL, NULL, value);
+#line 431
+	    else
+#line 431
+		err = nc_get_vara_float(ncid, i, start, edge, value);
+#line 431
+            if (canConvert) {
+#line 431
+		if (allInExtRange) {
+#line 431
+		    if (allInIntRange) {
+#line 431
+			IF (err)
+#line 431
+			    error("%s", nc_strerror(err));
+#line 431
+		    } else {
+#line 431
+			IF (err != NC_ERANGE)
+#line 431
+			    error("Range error: status = %d", err);
+#line 431
+		    }
+#line 431
+		} else {
+#line 431
+		    IF (err != 0 && err != NC_ERANGE)
+#line 431
+			error("OK or Range error: status = %d", err);
+#line 431
+		}
+#line 431
+		for (j = 0; j < nels; j++) {
+#line 431
+		    if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+#line 431
+			    && expect[j] >= float_min && expect[j] <= float_max) {
+#line 431
+			IF (!equal(value[j],expect[j],var_type[i],NCT_FLOAT)){
+#line 431
+			    error("value read not that expected");
+#line 431
+			    if (verbose) {
+#line 431
+				error("\n");
+#line 431
+				error("varid: %d, ", i);
+#line 431
+				error("var_name: %s, ", var_name[i]);
+#line 431
+				error("element number: %d ", j);
+#line 431
+				error("expect: %g", expect[j]);
+#line 431
+				error("got: %g", (double) value[j]);
+#line 431
+			    }
+#line 431
+			} else {
+#line 431
+			    nok++;
+#line 431
+			}
+#line 431
+		    }
+#line 431
+		}
+#line 431
+            } else {
+#line 431
+                IF (nels > 0 && err != NC_ECHAR)
+#line 431
+                    error("wrong type: status = %d", err);
+#line 431
+            }
+#line 431
+        }
+#line 431
+    }
+#line 431
+    err = nc_close(ncid);
+#line 431
+    IF (err)
+#line 431
+	error("nc_close: %s", nc_strerror(err));
+#line 431
+    print_nok(nok);
+#line 431
+}
+#line 431
+
+void
+#line 432
+test_nc_get_vara_double(void)
+#line 432
+{
+#line 432
+    int ncid;
+#line 432
+    int d;
+#line 432
+    int i;
+#line 432
+    int j;
+#line 432
+    int k;
+#line 432
+    int err;
+#line 432
+    int allInExtRange;	/* all values within external range? */
+#line 432
+    int allInIntRange;	/* all values within internal range? */
+#line 432
+    int nels;
+#line 432
+    int nslabs;
+#line 432
+    int nok = 0;      /* count of valid comparisons */
+#line 432
+    size_t start[MAX_RANK];
+#line 432
+    size_t edge[MAX_RANK];
+#line 432
+    size_t index[MAX_RANK];
+#line 432
+    size_t mid[MAX_RANK];
+#line 432
+    int canConvert;     /* Both text or both numeric */
+#line 432
+    double value[MAX_NELS];
+#line 432
+    double expect[MAX_NELS];
+#line 432
+
+#line 432
+#ifdef TEST_PNETCDF
+#line 432
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 432
+#else
+#line 432
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 432
+#endif
+#line 432
+    IF (err)
+#line 432
+	error("nc_open: %s", nc_strerror(err));
+#line 432
+    for (i = 0; i < numVars; i++) {
+#line 432
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+#line 432
+        assert(var_rank[i] <= MAX_RANK);
+#line 432
+        assert(var_nels[i] <= MAX_NELS);
+#line 432
+	for (j = 0; j < var_rank[i]; j++) {
+#line 432
+	    start[j] = 0;
+#line 432
+	    edge[j] = 1;
+#line 432
+	}
+#line 432
+        err = nc_get_vara_double(BAD_ID, i, start, edge, value);
+#line 432
+        IF (err != NC_EBADID)
+#line 432
+	    error("bad ncid: status = %d", err);
+#line 432
+        err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value);
+#line 432
+        IF (err != NC_ENOTVAR)
+#line 432
+	    error("bad var id: status = %d", err);
+#line 432
+	for (j = 0; j < var_rank[i]; j++) {
+#line 432
+	    start[j] = var_shape[i][j];
+#line 432
+	    err = nc_get_vara_double(ncid, i, start, edge, value);
+#line 432
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 432
+                error("bad index: status = %d", err);
+#line 432
+	    start[j] = 0;
+#line 432
+	    edge[j] = var_shape[i][j] + 1;
+#line 432
+	    err = nc_get_vara_double(ncid, i, start, edge, value);
+#line 432
+            IF (canConvert && err != NC_EEDGE)
+#line 432
+		error("bad edge: status = %d", err);
+#line 432
+	    edge[j] = 1;
+#line 432
+	}
+#line 432
+            /* Check non-scalars for correct error returned even when */
+#line 432
+            /* there is nothing to get (edge[j]==0) */
+#line 432
+	if(var_rank[i] > 0) {
+#line 432
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 432
+		edge[j] = 0;
+#line 432
+	    }
+#line 432
+	    err = nc_get_vara_double(BAD_ID, i, start, edge, value);
+#line 432
+	    IF (err != NC_EBADID) 
+#line 432
+		error("bad ncid: status = %d", err);
+#line 432
+	    err = nc_get_vara_double(ncid, BAD_VARID, start, edge, value);
+#line 432
+	    IF (err != NC_ENOTVAR) 
+#line 432
+		error("bad var id: status = %d", err);
+#line 432
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 432
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 432
+		    start[j] = var_shape[i][j];
+#line 432
+		    err = nc_get_vara_double(ncid, i, start, edge, value);
+#line 432
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 432
+			error("bad start: status = %d", err);
+#line 432
+		    start[j] = 0;
+#line 432
+		}
+#line 432
+	    }
+#line 432
+	    err = nc_get_vara_double(ncid, i, start, edge, value);
+#line 432
+	    if (canConvert) {
+#line 432
+		IF (err) 
+#line 432
+		    error("%s", nc_strerror(err));
+#line 432
+	    } else {
+#line 432
+		IF (err != NC_ECHAR)
+#line 432
+		    error("wrong type: status = %d", err);
+#line 432
+	    }
+#line 432
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 432
+		edge[j] = 1;
+#line 432
+	    }
+#line 432
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 432
+            /* get 2^rank (nslabs) slabs so defined */
+#line 432
+        nslabs = 1;
+#line 432
+        for (j = 0; j < var_rank[i]; j++) {
+#line 432
+            mid[j] = roll( var_shape[i][j] );
+#line 432
+            nslabs *= 2;
+#line 432
+        }
+#line 432
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 432
+        for (k = 0; k < nslabs; k++) {
+#line 432
+            nels = 1;
+#line 432
+            for (j = 0; j < var_rank[i]; j++) {
+#line 432
+                if ((k >> j) & 1) {
+#line 432
+                    start[j] = 0;
+#line 432
+                    edge[j] = mid[j];
+#line 432
+                }else{
+#line 432
+                    start[j] = mid[j];
+#line 432
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 432
+                }
+#line 432
+                nels *= edge[j];
+#line 432
+            }
+#line 432
+	    allInExtRange = allInIntRange = 1;
+#line 432
+            for (j = 0; j < nels; j++) {
+#line 432
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 432
+                IF (err)
+#line 432
+                    error("error in toMixedBase 1");
+#line 432
+                for (d = 0; d < var_rank[i]; d++)
+#line 432
+                    index[d] += start[d];
+#line 432
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_DOUBLE);
+#line 432
+		if (inRange3(expect[j],var_type[i], NCT_DOUBLE)) {
+#line 432
+		    allInIntRange = allInIntRange && expect[j] >= double_min
+#line 432
+				&& expect[j] <= double_max;
+#line 432
+		} else {
+#line 432
+		    allInExtRange = 0;
+#line 432
+		}
+#line 432
+	    }
+#line 432
+            if (var_rank[i] == 0 && i%2)
+#line 432
+		err = nc_get_vara_double(ncid, i, NULL, NULL, value);
+#line 432
+	    else
+#line 432
+		err = nc_get_vara_double(ncid, i, start, edge, value);
+#line 432
+            if (canConvert) {
+#line 432
+		if (allInExtRange) {
+#line 432
+		    if (allInIntRange) {
+#line 432
+			IF (err)
+#line 432
+			    error("%s", nc_strerror(err));
+#line 432
+		    } else {
+#line 432
+			IF (err != NC_ERANGE)
+#line 432
+			    error("Range error: status = %d", err);
+#line 432
+		    }
+#line 432
+		} else {
+#line 432
+		    IF (err != 0 && err != NC_ERANGE)
+#line 432
+			error("OK or Range error: status = %d", err);
+#line 432
+		}
+#line 432
+		for (j = 0; j < nels; j++) {
+#line 432
+		    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+#line 432
+			    && expect[j] >= double_min && expect[j] <= double_max) {
+#line 432
+			IF (!equal(value[j],expect[j],var_type[i],NCT_DOUBLE)){
+#line 432
+			    error("value read not that expected");
+#line 432
+			    if (verbose) {
+#line 432
+				error("\n");
+#line 432
+				error("varid: %d, ", i);
+#line 432
+				error("var_name: %s, ", var_name[i]);
+#line 432
+				error("element number: %d ", j);
+#line 432
+				error("expect: %g", expect[j]);
+#line 432
+				error("got: %g", (double) value[j]);
+#line 432
+			    }
+#line 432
+			} else {
+#line 432
+			    nok++;
+#line 432
+			}
+#line 432
+		    }
+#line 432
+		}
+#line 432
+            } else {
+#line 432
+                IF (nels > 0 && err != NC_ECHAR)
+#line 432
+                    error("wrong type: status = %d", err);
+#line 432
+            }
+#line 432
+        }
+#line 432
+    }
+#line 432
+    err = nc_close(ncid);
+#line 432
+    IF (err)
+#line 432
+	error("nc_close: %s", nc_strerror(err));
+#line 432
+    print_nok(nok);
+#line 432
+}
+#line 432
+
+void
+#line 433
+test_nc_get_vara_ushort(void)
+#line 433
+{
+#line 433
+    int ncid;
+#line 433
+    int d;
+#line 433
+    int i;
+#line 433
+    int j;
+#line 433
+    int k;
+#line 433
+    int err;
+#line 433
+    int allInExtRange;	/* all values within external range? */
+#line 433
+    int allInIntRange;	/* all values within internal range? */
+#line 433
+    int nels;
+#line 433
+    int nslabs;
+#line 433
+    int nok = 0;      /* count of valid comparisons */
+#line 433
+    size_t start[MAX_RANK];
+#line 433
+    size_t edge[MAX_RANK];
+#line 433
+    size_t index[MAX_RANK];
+#line 433
+    size_t mid[MAX_RANK];
+#line 433
+    int canConvert;     /* Both text or both numeric */
+#line 433
+    ushort value[MAX_NELS];
+#line 433
+    double expect[MAX_NELS];
+#line 433
+
+#line 433
+#ifdef TEST_PNETCDF
+#line 433
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 433
+#else
+#line 433
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 433
+#endif
+#line 433
+    IF (err)
+#line 433
+	error("nc_open: %s", nc_strerror(err));
+#line 433
+    for (i = 0; i < numVars; i++) {
+#line 433
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+#line 433
+        assert(var_rank[i] <= MAX_RANK);
+#line 433
+        assert(var_nels[i] <= MAX_NELS);
+#line 433
+	for (j = 0; j < var_rank[i]; j++) {
+#line 433
+	    start[j] = 0;
+#line 433
+	    edge[j] = 1;
+#line 433
+	}
+#line 433
+        err = nc_get_vara_ushort(BAD_ID, i, start, edge, value);
+#line 433
+        IF (err != NC_EBADID)
+#line 433
+	    error("bad ncid: status = %d", err);
+#line 433
+        err = nc_get_vara_ushort(ncid, BAD_VARID, start, edge, value);
+#line 433
+        IF (err != NC_ENOTVAR)
+#line 433
+	    error("bad var id: status = %d", err);
+#line 433
+	for (j = 0; j < var_rank[i]; j++) {
+#line 433
+	    start[j] = var_shape[i][j];
+#line 433
+	    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+#line 433
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 433
+                error("bad index: status = %d", err);
+#line 433
+	    start[j] = 0;
+#line 433
+	    edge[j] = var_shape[i][j] + 1;
+#line 433
+	    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+#line 433
+            IF (canConvert && err != NC_EEDGE)
+#line 433
+		error("bad edge: status = %d", err);
+#line 433
+	    edge[j] = 1;
+#line 433
+	}
+#line 433
+            /* Check non-scalars for correct error returned even when */
+#line 433
+            /* there is nothing to get (edge[j]==0) */
+#line 433
+	if(var_rank[i] > 0) {
+#line 433
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 433
+		edge[j] = 0;
+#line 433
+	    }
+#line 433
+	    err = nc_get_vara_ushort(BAD_ID, i, start, edge, value);
+#line 433
+	    IF (err != NC_EBADID) 
+#line 433
+		error("bad ncid: status = %d", err);
+#line 433
+	    err = nc_get_vara_ushort(ncid, BAD_VARID, start, edge, value);
+#line 433
+	    IF (err != NC_ENOTVAR) 
+#line 433
+		error("bad var id: status = %d", err);
+#line 433
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 433
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 433
+		    start[j] = var_shape[i][j];
+#line 433
+		    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+#line 433
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 433
+			error("bad start: status = %d", err);
+#line 433
+		    start[j] = 0;
+#line 433
+		}
+#line 433
+	    }
+#line 433
+	    err = nc_get_vara_ushort(ncid, i, start, edge, value);
+#line 433
+	    if (canConvert) {
+#line 433
+		IF (err) 
+#line 433
+		    error("%s", nc_strerror(err));
+#line 433
+	    } else {
+#line 433
+		IF (err != NC_ECHAR)
+#line 433
+		    error("wrong type: status = %d", err);
+#line 433
+	    }
+#line 433
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 433
+		edge[j] = 1;
+#line 433
+	    }
+#line 433
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 433
+            /* get 2^rank (nslabs) slabs so defined */
+#line 433
+        nslabs = 1;
+#line 433
+        for (j = 0; j < var_rank[i]; j++) {
+#line 433
+            mid[j] = roll( var_shape[i][j] );
+#line 433
+            nslabs *= 2;
+#line 433
+        }
+#line 433
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 433
+        for (k = 0; k < nslabs; k++) {
+#line 433
+            nels = 1;
+#line 433
+            for (j = 0; j < var_rank[i]; j++) {
+#line 433
+                if ((k >> j) & 1) {
+#line 433
+                    start[j] = 0;
+#line 433
+                    edge[j] = mid[j];
+#line 433
+                }else{
+#line 433
+                    start[j] = mid[j];
+#line 433
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 433
+                }
+#line 433
+                nels *= edge[j];
+#line 433
+            }
+#line 433
+	    allInExtRange = allInIntRange = 1;
+#line 433
+            for (j = 0; j < nels; j++) {
+#line 433
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 433
+                IF (err)
+#line 433
+                    error("error in toMixedBase 1");
+#line 433
+                for (d = 0; d < var_rank[i]; d++)
+#line 433
+                    index[d] += start[d];
+#line 433
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_USHORT);
+#line 433
+		if (inRange3(expect[j],var_type[i], NCT_USHORT)) {
+#line 433
+		    allInIntRange = allInIntRange && expect[j] >= ushort_min
+#line 433
+				&& expect[j] <= ushort_max;
+#line 433
+		} else {
+#line 433
+		    allInExtRange = 0;
+#line 433
+		}
+#line 433
+	    }
+#line 433
+            if (var_rank[i] == 0 && i%2)
+#line 433
+		err = nc_get_vara_ushort(ncid, i, NULL, NULL, value);
+#line 433
+	    else
+#line 433
+		err = nc_get_vara_ushort(ncid, i, start, edge, value);
+#line 433
+            if (canConvert) {
+#line 433
+		if (allInExtRange) {
+#line 433
+		    if (allInIntRange) {
+#line 433
+			IF (err)
+#line 433
+			    error("%s", nc_strerror(err));
+#line 433
+		    } else {
+#line 433
+			IF (err != NC_ERANGE)
+#line 433
+			    error("Range error: status = %d", err);
+#line 433
+		    }
+#line 433
+		} else {
+#line 433
+		    IF (err != 0 && err != NC_ERANGE)
+#line 433
+			error("OK or Range error: status = %d", err);
+#line 433
+		}
+#line 433
+		for (j = 0; j < nels; j++) {
+#line 433
+		    if (inRange3(expect[j],var_type[i],NCT_USHORT)
+#line 433
+			    && expect[j] >= ushort_min && expect[j] <= ushort_max) {
+#line 433
+			IF (!equal(value[j],expect[j],var_type[i],NCT_USHORT)){
+#line 433
+			    error("value read not that expected");
+#line 433
+			    if (verbose) {
+#line 433
+				error("\n");
+#line 433
+				error("varid: %d, ", i);
+#line 433
+				error("var_name: %s, ", var_name[i]);
+#line 433
+				error("element number: %d ", j);
+#line 433
+				error("expect: %g", expect[j]);
+#line 433
+				error("got: %g", (double) value[j]);
+#line 433
+			    }
+#line 433
+			} else {
+#line 433
+			    nok++;
+#line 433
+			}
+#line 433
+		    }
+#line 433
+		}
+#line 433
+            } else {
+#line 433
+                IF (nels > 0 && err != NC_ECHAR)
+#line 433
+                    error("wrong type: status = %d", err);
+#line 433
+            }
+#line 433
+        }
+#line 433
+    }
+#line 433
+    err = nc_close(ncid);
+#line 433
+    IF (err)
+#line 433
+	error("nc_close: %s", nc_strerror(err));
+#line 433
+    print_nok(nok);
+#line 433
+}
+#line 433
+
+void
+#line 434
+test_nc_get_vara_uint(void)
+#line 434
+{
+#line 434
+    int ncid;
+#line 434
+    int d;
+#line 434
+    int i;
+#line 434
+    int j;
+#line 434
+    int k;
+#line 434
+    int err;
+#line 434
+    int allInExtRange;	/* all values within external range? */
+#line 434
+    int allInIntRange;	/* all values within internal range? */
+#line 434
+    int nels;
+#line 434
+    int nslabs;
+#line 434
+    int nok = 0;      /* count of valid comparisons */
+#line 434
+    size_t start[MAX_RANK];
+#line 434
+    size_t edge[MAX_RANK];
+#line 434
+    size_t index[MAX_RANK];
+#line 434
+    size_t mid[MAX_RANK];
+#line 434
+    int canConvert;     /* Both text or both numeric */
+#line 434
+    uint value[MAX_NELS];
+#line 434
+    double expect[MAX_NELS];
+#line 434
+
+#line 434
+#ifdef TEST_PNETCDF
+#line 434
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 434
+#else
+#line 434
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 434
+#endif
+#line 434
+    IF (err)
+#line 434
+	error("nc_open: %s", nc_strerror(err));
+#line 434
+    for (i = 0; i < numVars; i++) {
+#line 434
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+#line 434
+        assert(var_rank[i] <= MAX_RANK);
+#line 434
+        assert(var_nels[i] <= MAX_NELS);
+#line 434
+	for (j = 0; j < var_rank[i]; j++) {
+#line 434
+	    start[j] = 0;
+#line 434
+	    edge[j] = 1;
+#line 434
+	}
+#line 434
+        err = nc_get_vara_uint(BAD_ID, i, start, edge, value);
+#line 434
+        IF (err != NC_EBADID)
+#line 434
+	    error("bad ncid: status = %d", err);
+#line 434
+        err = nc_get_vara_uint(ncid, BAD_VARID, start, edge, value);
+#line 434
+        IF (err != NC_ENOTVAR)
+#line 434
+	    error("bad var id: status = %d", err);
+#line 434
+	for (j = 0; j < var_rank[i]; j++) {
+#line 434
+	    start[j] = var_shape[i][j];
+#line 434
+	    err = nc_get_vara_uint(ncid, i, start, edge, value);
+#line 434
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 434
+                error("bad index: status = %d", err);
+#line 434
+	    start[j] = 0;
+#line 434
+	    edge[j] = var_shape[i][j] + 1;
+#line 434
+	    err = nc_get_vara_uint(ncid, i, start, edge, value);
+#line 434
+            IF (canConvert && err != NC_EEDGE)
+#line 434
+		error("bad edge: status = %d", err);
+#line 434
+	    edge[j] = 1;
+#line 434
+	}
+#line 434
+            /* Check non-scalars for correct error returned even when */
+#line 434
+            /* there is nothing to get (edge[j]==0) */
+#line 434
+	if(var_rank[i] > 0) {
+#line 434
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 434
+		edge[j] = 0;
+#line 434
+	    }
+#line 434
+	    err = nc_get_vara_uint(BAD_ID, i, start, edge, value);
+#line 434
+	    IF (err != NC_EBADID) 
+#line 434
+		error("bad ncid: status = %d", err);
+#line 434
+	    err = nc_get_vara_uint(ncid, BAD_VARID, start, edge, value);
+#line 434
+	    IF (err != NC_ENOTVAR) 
+#line 434
+		error("bad var id: status = %d", err);
+#line 434
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 434
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 434
+		    start[j] = var_shape[i][j];
+#line 434
+		    err = nc_get_vara_uint(ncid, i, start, edge, value);
+#line 434
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 434
+			error("bad start: status = %d", err);
+#line 434
+		    start[j] = 0;
+#line 434
+		}
+#line 434
+	    }
+#line 434
+	    err = nc_get_vara_uint(ncid, i, start, edge, value);
+#line 434
+	    if (canConvert) {
+#line 434
+		IF (err) 
+#line 434
+		    error("%s", nc_strerror(err));
+#line 434
+	    } else {
+#line 434
+		IF (err != NC_ECHAR)
+#line 434
+		    error("wrong type: status = %d", err);
+#line 434
+	    }
+#line 434
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 434
+		edge[j] = 1;
+#line 434
+	    }
+#line 434
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 434
+            /* get 2^rank (nslabs) slabs so defined */
+#line 434
+        nslabs = 1;
+#line 434
+        for (j = 0; j < var_rank[i]; j++) {
+#line 434
+            mid[j] = roll( var_shape[i][j] );
+#line 434
+            nslabs *= 2;
+#line 434
+        }
+#line 434
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 434
+        for (k = 0; k < nslabs; k++) {
+#line 434
+            nels = 1;
+#line 434
+            for (j = 0; j < var_rank[i]; j++) {
+#line 434
+                if ((k >> j) & 1) {
+#line 434
+                    start[j] = 0;
+#line 434
+                    edge[j] = mid[j];
+#line 434
+                }else{
+#line 434
+                    start[j] = mid[j];
+#line 434
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 434
+                }
+#line 434
+                nels *= edge[j];
+#line 434
+            }
+#line 434
+	    allInExtRange = allInIntRange = 1;
+#line 434
+            for (j = 0; j < nels; j++) {
+#line 434
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 434
+                IF (err)
+#line 434
+                    error("error in toMixedBase 1");
+#line 434
+                for (d = 0; d < var_rank[i]; d++)
+#line 434
+                    index[d] += start[d];
+#line 434
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_UINT);
+#line 434
+		if (inRange3(expect[j],var_type[i], NCT_UINT)) {
+#line 434
+		    allInIntRange = allInIntRange && expect[j] >= uint_min
+#line 434
+				&& expect[j] <= uint_max;
+#line 434
+		} else {
+#line 434
+		    allInExtRange = 0;
+#line 434
+		}
+#line 434
+	    }
+#line 434
+            if (var_rank[i] == 0 && i%2)
+#line 434
+		err = nc_get_vara_uint(ncid, i, NULL, NULL, value);
+#line 434
+	    else
+#line 434
+		err = nc_get_vara_uint(ncid, i, start, edge, value);
+#line 434
+            if (canConvert) {
+#line 434
+		if (allInExtRange) {
+#line 434
+		    if (allInIntRange) {
+#line 434
+			IF (err)
+#line 434
+			    error("%s", nc_strerror(err));
+#line 434
+		    } else {
+#line 434
+			IF (err != NC_ERANGE)
+#line 434
+			    error("Range error: status = %d", err);
+#line 434
+		    }
+#line 434
+		} else {
+#line 434
+		    IF (err != 0 && err != NC_ERANGE)
+#line 434
+			error("OK or Range error: status = %d", err);
+#line 434
+		}
+#line 434
+		for (j = 0; j < nels; j++) {
+#line 434
+		    if (inRange3(expect[j],var_type[i],NCT_UINT)
+#line 434
+			    && expect[j] >= uint_min && expect[j] <= uint_max) {
+#line 434
+			IF (!equal(value[j],expect[j],var_type[i],NCT_UINT)){
+#line 434
+			    error("value read not that expected");
+#line 434
+			    if (verbose) {
+#line 434
+				error("\n");
+#line 434
+				error("varid: %d, ", i);
+#line 434
+				error("var_name: %s, ", var_name[i]);
+#line 434
+				error("element number: %d ", j);
+#line 434
+				error("expect: %g", expect[j]);
+#line 434
+				error("got: %g", (double) value[j]);
+#line 434
+			    }
+#line 434
+			} else {
+#line 434
+			    nok++;
+#line 434
+			}
+#line 434
+		    }
+#line 434
+		}
+#line 434
+            } else {
+#line 434
+                IF (nels > 0 && err != NC_ECHAR)
+#line 434
+                    error("wrong type: status = %d", err);
+#line 434
+            }
+#line 434
+        }
+#line 434
+    }
+#line 434
+    err = nc_close(ncid);
+#line 434
+    IF (err)
+#line 434
+	error("nc_close: %s", nc_strerror(err));
+#line 434
+    print_nok(nok);
+#line 434
+}
+#line 434
+
+void
+#line 435
+test_nc_get_vara_longlong(void)
+#line 435
+{
+#line 435
+    int ncid;
+#line 435
+    int d;
+#line 435
+    int i;
+#line 435
+    int j;
+#line 435
+    int k;
+#line 435
+    int err;
+#line 435
+    int allInExtRange;	/* all values within external range? */
+#line 435
+    int allInIntRange;	/* all values within internal range? */
+#line 435
+    int nels;
+#line 435
+    int nslabs;
+#line 435
+    int nok = 0;      /* count of valid comparisons */
+#line 435
+    size_t start[MAX_RANK];
+#line 435
+    size_t edge[MAX_RANK];
+#line 435
+    size_t index[MAX_RANK];
+#line 435
+    size_t mid[MAX_RANK];
+#line 435
+    int canConvert;     /* Both text or both numeric */
+#line 435
+    longlong value[MAX_NELS];
+#line 435
+    double expect[MAX_NELS];
+#line 435
+
+#line 435
+#ifdef TEST_PNETCDF
+#line 435
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 435
+#else
+#line 435
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 435
+#endif
+#line 435
+    IF (err)
+#line 435
+	error("nc_open: %s", nc_strerror(err));
+#line 435
+    for (i = 0; i < numVars; i++) {
+#line 435
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+#line 435
+        assert(var_rank[i] <= MAX_RANK);
+#line 435
+        assert(var_nels[i] <= MAX_NELS);
+#line 435
+	for (j = 0; j < var_rank[i]; j++) {
+#line 435
+	    start[j] = 0;
+#line 435
+	    edge[j] = 1;
+#line 435
+	}
+#line 435
+        err = nc_get_vara_longlong(BAD_ID, i, start, edge, value);
+#line 435
+        IF (err != NC_EBADID)
+#line 435
+	    error("bad ncid: status = %d", err);
+#line 435
+        err = nc_get_vara_longlong(ncid, BAD_VARID, start, edge, value);
+#line 435
+        IF (err != NC_ENOTVAR)
+#line 435
+	    error("bad var id: status = %d", err);
+#line 435
+	for (j = 0; j < var_rank[i]; j++) {
+#line 435
+	    start[j] = var_shape[i][j];
+#line 435
+	    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+#line 435
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 435
+                error("bad index: status = %d", err);
+#line 435
+	    start[j] = 0;
+#line 435
+	    edge[j] = var_shape[i][j] + 1;
+#line 435
+	    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+#line 435
+            IF (canConvert && err != NC_EEDGE)
+#line 435
+		error("bad edge: status = %d", err);
+#line 435
+	    edge[j] = 1;
+#line 435
+	}
+#line 435
+            /* Check non-scalars for correct error returned even when */
+#line 435
+            /* there is nothing to get (edge[j]==0) */
+#line 435
+	if(var_rank[i] > 0) {
+#line 435
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 435
+		edge[j] = 0;
+#line 435
+	    }
+#line 435
+	    err = nc_get_vara_longlong(BAD_ID, i, start, edge, value);
+#line 435
+	    IF (err != NC_EBADID) 
+#line 435
+		error("bad ncid: status = %d", err);
+#line 435
+	    err = nc_get_vara_longlong(ncid, BAD_VARID, start, edge, value);
+#line 435
+	    IF (err != NC_ENOTVAR) 
+#line 435
+		error("bad var id: status = %d", err);
+#line 435
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 435
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 435
+		    start[j] = var_shape[i][j];
+#line 435
+		    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+#line 435
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 435
+			error("bad start: status = %d", err);
+#line 435
+		    start[j] = 0;
+#line 435
+		}
+#line 435
+	    }
+#line 435
+	    err = nc_get_vara_longlong(ncid, i, start, edge, value);
+#line 435
+	    if (canConvert) {
+#line 435
+		IF (err) 
+#line 435
+		    error("%s", nc_strerror(err));
+#line 435
+	    } else {
+#line 435
+		IF (err != NC_ECHAR)
+#line 435
+		    error("wrong type: status = %d", err);
+#line 435
+	    }
+#line 435
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 435
+		edge[j] = 1;
+#line 435
+	    }
+#line 435
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 435
+            /* get 2^rank (nslabs) slabs so defined */
+#line 435
+        nslabs = 1;
+#line 435
+        for (j = 0; j < var_rank[i]; j++) {
+#line 435
+            mid[j] = roll( var_shape[i][j] );
+#line 435
+            nslabs *= 2;
+#line 435
+        }
+#line 435
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 435
+        for (k = 0; k < nslabs; k++) {
+#line 435
+            nels = 1;
+#line 435
+            for (j = 0; j < var_rank[i]; j++) {
+#line 435
+                if ((k >> j) & 1) {
+#line 435
+                    start[j] = 0;
+#line 435
+                    edge[j] = mid[j];
+#line 435
+                }else{
+#line 435
+                    start[j] = mid[j];
+#line 435
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 435
+                }
+#line 435
+                nels *= edge[j];
+#line 435
+            }
+#line 435
+	    allInExtRange = allInIntRange = 1;
+#line 435
+            for (j = 0; j < nels; j++) {
+#line 435
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 435
+                IF (err)
+#line 435
+                    error("error in toMixedBase 1");
+#line 435
+                for (d = 0; d < var_rank[i]; d++)
+#line 435
+                    index[d] += start[d];
+#line 435
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_LONGLONG);
+#line 435
+		if (inRange3(expect[j],var_type[i], NCT_LONGLONG)) {
+#line 435
+		    allInIntRange = allInIntRange && expect[j] >= longlong_min
+#line 435
+				&& expect[j] <= longlong_max;
+#line 435
+		} else {
+#line 435
+		    allInExtRange = 0;
+#line 435
+		}
+#line 435
+	    }
+#line 435
+            if (var_rank[i] == 0 && i%2)
+#line 435
+		err = nc_get_vara_longlong(ncid, i, NULL, NULL, value);
+#line 435
+	    else
+#line 435
+		err = nc_get_vara_longlong(ncid, i, start, edge, value);
+#line 435
+            if (canConvert) {
+#line 435
+		if (allInExtRange) {
+#line 435
+		    if (allInIntRange) {
+#line 435
+			IF (err)
+#line 435
+			    error("%s", nc_strerror(err));
+#line 435
+		    } else {
+#line 435
+			IF (err != NC_ERANGE)
+#line 435
+			    error("Range error: status = %d", err);
+#line 435
+		    }
+#line 435
+		} else {
+#line 435
+		    IF (err != 0 && err != NC_ERANGE)
+#line 435
+			error("OK or Range error: status = %d", err);
+#line 435
+		}
+#line 435
+		for (j = 0; j < nels; j++) {
+#line 435
+		    if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+#line 435
+			    && expect[j] >= longlong_min && expect[j] <= longlong_max) {
+#line 435
+			IF (!equal(value[j],expect[j],var_type[i],NCT_LONGLONG)){
+#line 435
+			    error("value read not that expected");
+#line 435
+			    if (verbose) {
+#line 435
+				error("\n");
+#line 435
+				error("varid: %d, ", i);
+#line 435
+				error("var_name: %s, ", var_name[i]);
+#line 435
+				error("element number: %d ", j);
+#line 435
+				error("expect: %g", expect[j]);
+#line 435
+				error("got: %g", (double) value[j]);
+#line 435
+			    }
+#line 435
+			} else {
+#line 435
+			    nok++;
+#line 435
+			}
+#line 435
+		    }
+#line 435
+		}
+#line 435
+            } else {
+#line 435
+                IF (nels > 0 && err != NC_ECHAR)
+#line 435
+                    error("wrong type: status = %d", err);
+#line 435
+            }
+#line 435
+        }
+#line 435
+    }
+#line 435
+    err = nc_close(ncid);
+#line 435
+    IF (err)
+#line 435
+	error("nc_close: %s", nc_strerror(err));
+#line 435
+    print_nok(nok);
+#line 435
+}
+#line 435
+
+void
+#line 436
+test_nc_get_vara_ulonglong(void)
+#line 436
+{
+#line 436
+    int ncid;
+#line 436
+    int d;
+#line 436
+    int i;
+#line 436
+    int j;
+#line 436
+    int k;
+#line 436
+    int err;
+#line 436
+    int allInExtRange;	/* all values within external range? */
+#line 436
+    int allInIntRange;	/* all values within internal range? */
+#line 436
+    int nels;
+#line 436
+    int nslabs;
+#line 436
+    int nok = 0;      /* count of valid comparisons */
+#line 436
+    size_t start[MAX_RANK];
+#line 436
+    size_t edge[MAX_RANK];
+#line 436
+    size_t index[MAX_RANK];
+#line 436
+    size_t mid[MAX_RANK];
+#line 436
+    int canConvert;     /* Both text or both numeric */
+#line 436
+    ulonglong value[MAX_NELS];
+#line 436
+    double expect[MAX_NELS];
+#line 436
+
+#line 436
+#ifdef TEST_PNETCDF
+#line 436
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 436
+#else
+#line 436
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 436
+#endif
+#line 436
+    IF (err)
+#line 436
+	error("nc_open: %s", nc_strerror(err));
+#line 436
+    for (i = 0; i < numVars; i++) {
+#line 436
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+#line 436
+        assert(var_rank[i] <= MAX_RANK);
+#line 436
+        assert(var_nels[i] <= MAX_NELS);
+#line 436
+	for (j = 0; j < var_rank[i]; j++) {
+#line 436
+	    start[j] = 0;
+#line 436
+	    edge[j] = 1;
+#line 436
+	}
+#line 436
+        err = nc_get_vara_ulonglong(BAD_ID, i, start, edge, value);
+#line 436
+        IF (err != NC_EBADID)
+#line 436
+	    error("bad ncid: status = %d", err);
+#line 436
+        err = nc_get_vara_ulonglong(ncid, BAD_VARID, start, edge, value);
+#line 436
+        IF (err != NC_ENOTVAR)
+#line 436
+	    error("bad var id: status = %d", err);
+#line 436
+	for (j = 0; j < var_rank[i]; j++) {
+#line 436
+	    start[j] = var_shape[i][j];
+#line 436
+	    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+#line 436
+            IF (canConvert && err != NC_EINVALCOORDS)
+#line 436
+                error("bad index: status = %d", err);
+#line 436
+	    start[j] = 0;
+#line 436
+	    edge[j] = var_shape[i][j] + 1;
+#line 436
+	    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+#line 436
+            IF (canConvert && err != NC_EEDGE)
+#line 436
+		error("bad edge: status = %d", err);
+#line 436
+	    edge[j] = 1;
+#line 436
+	}
+#line 436
+            /* Check non-scalars for correct error returned even when */
+#line 436
+            /* there is nothing to get (edge[j]==0) */
+#line 436
+	if(var_rank[i] > 0) {
+#line 436
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 436
+		edge[j] = 0;
+#line 436
+	    }
+#line 436
+	    err = nc_get_vara_ulonglong(BAD_ID, i, start, edge, value);
+#line 436
+	    IF (err != NC_EBADID) 
+#line 436
+		error("bad ncid: status = %d", err);
+#line 436
+	    err = nc_get_vara_ulonglong(ncid, BAD_VARID, start, edge, value);
+#line 436
+	    IF (err != NC_ENOTVAR) 
+#line 436
+		error("bad var id: status = %d", err);
+#line 436
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 436
+		if (var_dimid[i][j] > 0) {		/* skip record dim */
+#line 436
+		    start[j] = var_shape[i][j];
+#line 436
+		    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+#line 436
+		    IF (canConvert && err != NC_EINVALCOORDS)
+#line 436
+			error("bad start: status = %d", err);
+#line 436
+		    start[j] = 0;
+#line 436
+		}
+#line 436
+	    }
+#line 436
+	    err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+#line 436
+	    if (canConvert) {
+#line 436
+		IF (err) 
+#line 436
+		    error("%s", nc_strerror(err));
+#line 436
+	    } else {
+#line 436
+		IF (err != NC_ECHAR)
+#line 436
+		    error("wrong type: status = %d", err);
+#line 436
+	    }
+#line 436
+	    for (j = 0; j < var_rank[i]; j++) {
+#line 436
+		edge[j] = 1;
+#line 436
+	    }
+#line 436
+	}            /* Choose a random point dividing each dim into 2 parts */
+#line 436
+            /* get 2^rank (nslabs) slabs so defined */
+#line 436
+        nslabs = 1;
+#line 436
+        for (j = 0; j < var_rank[i]; j++) {
+#line 436
+            mid[j] = roll( var_shape[i][j] );
+#line 436
+            nslabs *= 2;
+#line 436
+        }
+#line 436
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 436
+        for (k = 0; k < nslabs; k++) {
+#line 436
+            nels = 1;
+#line 436
+            for (j = 0; j < var_rank[i]; j++) {
+#line 436
+                if ((k >> j) & 1) {
+#line 436
+                    start[j] = 0;
+#line 436
+                    edge[j] = mid[j];
+#line 436
+                }else{
+#line 436
+                    start[j] = mid[j];
+#line 436
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 436
+                }
+#line 436
+                nels *= edge[j];
+#line 436
+            }
+#line 436
+	    allInExtRange = allInIntRange = 1;
+#line 436
+            for (j = 0; j < nels; j++) {
+#line 436
+                err = toMixedBase(j, var_rank[i], edge, index);
+#line 436
+                IF (err)
+#line 436
+                    error("error in toMixedBase 1");
+#line 436
+                for (d = 0; d < var_rank[i]; d++)
+#line 436
+                    index[d] += start[d];
+#line 436
+                expect[j] = hash4(var_type[i], var_rank[i], index, NCT_ULONGLONG);
+#line 436
+		if (inRange3(expect[j],var_type[i], NCT_ULONGLONG)) {
+#line 436
+		    allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+#line 436
+				&& expect[j] <= ulonglong_max;
+#line 436
+		} else {
+#line 436
+		    allInExtRange = 0;
+#line 436
+		}
+#line 436
+	    }
+#line 436
+            if (var_rank[i] == 0 && i%2)
+#line 436
+		err = nc_get_vara_ulonglong(ncid, i, NULL, NULL, value);
+#line 436
+	    else
+#line 436
+		err = nc_get_vara_ulonglong(ncid, i, start, edge, value);
+#line 436
+            if (canConvert) {
+#line 436
+		if (allInExtRange) {
+#line 436
+		    if (allInIntRange) {
+#line 436
+			IF (err)
+#line 436
+			    error("%s", nc_strerror(err));
+#line 436
+		    } else {
+#line 436
+			IF (err != NC_ERANGE)
+#line 436
+			    error("Range error: status = %d", err);
+#line 436
+		    }
+#line 436
+		} else {
+#line 436
+		    IF (err != 0 && err != NC_ERANGE)
+#line 436
+			error("OK or Range error: status = %d", err);
+#line 436
+		}
+#line 436
+		for (j = 0; j < nels; j++) {
+#line 436
+		    if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+#line 436
+			    && expect[j] >= ulonglong_min && expect[j] <= ulonglong_max) {
+#line 436
+			IF (!equal(value[j],expect[j],var_type[i],NCT_ULONGLONG)){
+#line 436
+			    error("value read not that expected");
+#line 436
+			    if (verbose) {
+#line 436
+				error("\n");
+#line 436
+				error("varid: %d, ", i);
+#line 436
+				error("var_name: %s, ", var_name[i]);
+#line 436
+				error("element number: %d ", j);
+#line 436
+				error("expect: %g", expect[j]);
+#line 436
+				error("got: %g", (double) value[j]);
+#line 436
+			    }
+#line 436
+			} else {
+#line 436
+			    nok++;
+#line 436
+			}
+#line 436
+		    }
+#line 436
+		}
+#line 436
+            } else {
+#line 436
+                IF (nels > 0 && err != NC_ECHAR)
+#line 436
+                    error("wrong type: status = %d", err);
+#line 436
+            }
+#line 436
+        }
+#line 436
+    }
+#line 436
+    err = nc_close(ncid);
+#line 436
+    IF (err)
+#line 436
+	error("nc_close: %s", nc_strerror(err));
+#line 436
+    print_nok(nok);
+#line 436
+}
+#line 436
+
+
+
+#line 622
+
+void
+#line 623
+test_nc_get_vars_text(void)
+#line 623
+{
+#line 623
+    int ncid;
+#line 623
+    int d;
+#line 623
+    int i;
+#line 623
+    int j;
+#line 623
+    int k;
+#line 623
+    int m;
+#line 623
+    int err;
+#line 623
+    int allInExtRange;	/* all values within external range? */
+#line 623
+    int allInIntRange;	/* all values within internal range? */
+#line 623
+    int nels;
+#line 623
+    int nslabs;
+#line 623
+    int nstarts;        /* number of different starts */
+#line 623
+    int nok = 0;      /* count of valid comparisons */
+#line 623
+    size_t start[MAX_RANK];
+#line 623
+    size_t edge[MAX_RANK];
+#line 623
+    size_t index[MAX_RANK];
+#line 623
+    size_t index2[MAX_RANK];
+#line 623
+    size_t mid[MAX_RANK];
+#line 623
+    size_t count[MAX_RANK];
+#line 623
+    size_t sstride[MAX_RANK];
+#line 623
+    ptrdiff_t stride[MAX_RANK];
+#line 623
+    int canConvert;     /* Both text or both numeric */
+#line 623
+    text value[MAX_NELS];
+#line 623
+    double expect[MAX_NELS];
+#line 623
+
+#line 623
+#ifdef TEST_PNETCDF
+#line 623
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 623
+#else
+#line 623
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 623
+#endif
+#line 623
+    IF (err)
+#line 623
+        error("nc_open: %s", nc_strerror(err));
+#line 623
+    for (i = 0; i < numVars; i++) {
+#line 623
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+#line 623
+        assert(var_rank[i] <= MAX_RANK);
+#line 623
+        assert(var_nels[i] <= MAX_NELS);
+#line 623
+        for (j = 0; j < var_rank[i]; j++) {
+#line 623
+            start[j] = 0;
+#line 623
+            edge[j] = 1;
+#line 623
+            stride[j] = 1;
+#line 623
+        }
+#line 623
+        err = nc_get_vars_text(BAD_ID, i, start, edge, stride, value);
+#line 623
+        IF (err != NC_EBADID)
+#line 623
+            error("bad ncid: status = %d", err);
+#line 623
+        err = nc_get_vars_text(ncid, BAD_VARID, start, edge, stride, value);
+#line 623
+        IF (err != NC_ENOTVAR)
+#line 623
+            error("bad var id: status = %d", err);
+#line 623
+        for (j = 0; j < var_rank[i]; j++) {
+#line 623
+            start[j] = var_shape[i][j];
+#line 623
+            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+#line 623
+	  if(!canConvert) {
+#line 623
+		IF (err != NC_ECHAR)
+#line 623
+               	    error("conversion: status = %d", err);
+#line 623
+	  } else {
+#line 623
+            IF (err != NC_EINVALCOORDS)
+#line 623
+                error("bad index: status = %d", err);
+#line 623
+            start[j] = 0;
+#line 623
+            edge[j] = var_shape[i][j] + 1;
+#line 623
+            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+#line 623
+            IF (err != NC_EEDGE)
+#line 623
+                error("bad edge: status = %d", err);
+#line 623
+            edge[j] = 1;
+#line 623
+            stride[j] = 0;
+#line 623
+            err = nc_get_vars_text(ncid, i, start, edge, stride, value);
+#line 623
+            IF (err != NC_ESTRIDE)
+#line 623
+                error("bad stride: status = %d", err);
+#line 623
+            stride[j] = 1;
+#line 623
+	  }
+#line 623
+        }
+#line 623
+            /* Choose a random point dividing each dim into 2 parts */
+#line 623
+            /* get 2^rank (nslabs) slabs so defined */
+#line 623
+        nslabs = 1;
+#line 623
+        for (j = 0; j < var_rank[i]; j++) {
+#line 623
+            mid[j] = roll( var_shape[i][j] );
+#line 623
+            nslabs *= 2;
+#line 623
+        }
+#line 623
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 623
+            /* choose random stride from 1 to edge */
+#line 623
+        for (k = 0; k < nslabs; k++) {
+#line 623
+            nstarts = 1;
+#line 623
+            for (j = 0; j < var_rank[i]; j++) {
+#line 623
+                if ((k >> j) & 1) {
+#line 623
+                    start[j] = 0;
+#line 623
+                    edge[j] = mid[j];
+#line 623
+                }else{
+#line 623
+                    start[j] = mid[j];
+#line 623
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 623
+                }
+#line 623
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 623
+                nstarts *= stride[j];
+#line 623
+            }
+#line 623
+            for (m = 0; m < nstarts; m++) {
+#line 623
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 623
+                IF (err)
+#line 623
+                    error("error in toMixedBase");
+#line 623
+                nels = 1;
+#line 623
+                for (j = 0; j < var_rank[i]; j++) {
+#line 623
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 623
+                    nels *= count[j];
+#line 623
+                    index[j] += start[j];
+#line 623
+                }
+#line 623
+                        /* Random choice of forward or backward */
+#line 623
+/* TODO
+#line 623
+                if ( roll(2) ) {
+#line 623
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 623
+                        index[j] += (count[j] - 1) * stride[j];
+#line 623
+                        stride[j] = -stride[j];
+#line 623
+                    }
+#line 623
+                }
+#line 623
+*/
+#line 623
+		allInExtRange = allInIntRange = 1;
+#line 623
+		for (j = 0; j < nels; j++) {
+#line 623
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 623
+		    IF (err)
+#line 623
+			error("error in toMixedBase 1");
+#line 623
+		    for (d = 0; d < var_rank[i]; d++)
+#line 623
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 623
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 623
+			NCT_TEXT);
+#line 623
+		    if (inRange3(expect[j],var_type[i],NCT_TEXT)) {
+#line 623
+			allInIntRange = allInIntRange && expect[j] >= text_min
+#line 623
+			    && expect[j] <= text_max;
+#line 623
+		    } else {
+#line 623
+			allInExtRange = 0;
+#line 623
+		    }
+#line 623
+		}
+#line 623
+                if (var_rank[i] == 0 && i%2 )
+#line 623
+                    err = nc_get_vars_text(ncid, i, NULL, NULL, NULL, value);
+#line 623
+                else
+#line 623
+                    err = nc_get_vars_text(ncid, i, index, count, stride, value);
+#line 623
+		if (canConvert) {
+#line 623
+		    if (allInExtRange) {
+#line 623
+			if (allInIntRange) {
+#line 623
+			    IF (err)
+#line 623
+				error("%s", nc_strerror(err));
+#line 623
+			} else {
+#line 623
+			    IF (err != NC_ERANGE)
+#line 623
+				error("Range error: status = %d", err);
+#line 623
+			}
+#line 623
+		    } else {
+#line 623
+			IF (err != 0 && err != NC_ERANGE)
+#line 623
+			    error("OK or Range error: status = %d", err);
+#line 623
+		    }
+#line 623
+		    for (j = 0; j < nels; j++) {
+#line 623
+			if (inRange3(expect[j],var_type[i],NCT_TEXT)
+#line 623
+				&& expect[j] >= text_min && expect[j] <= text_max) {
+#line 623
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 623
+				    NCT_TEXT)){
+#line 623
+				error("value read not that expected");
+#line 623
+				if (verbose) {
+#line 623
+				    error("\n");
+#line 623
+				    error("varid: %d, ", i);
+#line 623
+				    error("var_name: %s, ", var_name[i]);
+#line 623
+				    error("element number: %d ", j);
+#line 623
+                                    error("expect: %g, ", expect[j]);
+#line 623
+				    error("got: %g", (double) value[j]);
+#line 623
+				}
+#line 623
+			    } else {
+#line 623
+				nok++;
+#line 623
+			    }
+#line 623
+			}
+#line 623
+		    }
+#line 623
+		} else {
+#line 623
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 623
+			error("wrong type: status = %d", err);
+#line 623
+		}
+#line 623
+	    }
+#line 623
+	}
+#line 623
+
+#line 623
+    }
+#line 623
+    err = nc_close(ncid);
+#line 623
+    IF (err)
+#line 623
+        error("nc_close: %s", nc_strerror(err));
+#line 623
+    print_nok(nok);
+#line 623
+}
+#line 623
+
+void
+#line 624
+test_nc_get_vars_uchar(void)
+#line 624
+{
+#line 624
+    int ncid;
+#line 624
+    int d;
+#line 624
+    int i;
+#line 624
+    int j;
+#line 624
+    int k;
+#line 624
+    int m;
+#line 624
+    int err;
+#line 624
+    int allInExtRange;	/* all values within external range? */
+#line 624
+    int allInIntRange;	/* all values within internal range? */
+#line 624
+    int nels;
+#line 624
+    int nslabs;
+#line 624
+    int nstarts;        /* number of different starts */
+#line 624
+    int nok = 0;      /* count of valid comparisons */
+#line 624
+    size_t start[MAX_RANK];
+#line 624
+    size_t edge[MAX_RANK];
+#line 624
+    size_t index[MAX_RANK];
+#line 624
+    size_t index2[MAX_RANK];
+#line 624
+    size_t mid[MAX_RANK];
+#line 624
+    size_t count[MAX_RANK];
+#line 624
+    size_t sstride[MAX_RANK];
+#line 624
+    ptrdiff_t stride[MAX_RANK];
+#line 624
+    int canConvert;     /* Both text or both numeric */
+#line 624
+    uchar value[MAX_NELS];
+#line 624
+    double expect[MAX_NELS];
+#line 624
+
+#line 624
+#ifdef TEST_PNETCDF
+#line 624
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 624
+#else
+#line 624
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 624
+#endif
+#line 624
+    IF (err)
+#line 624
+        error("nc_open: %s", nc_strerror(err));
+#line 624
+    for (i = 0; i < numVars; i++) {
+#line 624
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+#line 624
+        assert(var_rank[i] <= MAX_RANK);
+#line 624
+        assert(var_nels[i] <= MAX_NELS);
+#line 624
+        for (j = 0; j < var_rank[i]; j++) {
+#line 624
+            start[j] = 0;
+#line 624
+            edge[j] = 1;
+#line 624
+            stride[j] = 1;
+#line 624
+        }
+#line 624
+        err = nc_get_vars_uchar(BAD_ID, i, start, edge, stride, value);
+#line 624
+        IF (err != NC_EBADID)
+#line 624
+            error("bad ncid: status = %d", err);
+#line 624
+        err = nc_get_vars_uchar(ncid, BAD_VARID, start, edge, stride, value);
+#line 624
+        IF (err != NC_ENOTVAR)
+#line 624
+            error("bad var id: status = %d", err);
+#line 624
+        for (j = 0; j < var_rank[i]; j++) {
+#line 624
+            start[j] = var_shape[i][j];
+#line 624
+            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+#line 624
+	  if(!canConvert) {
+#line 624
+		IF (err != NC_ECHAR)
+#line 624
+               	    error("conversion: status = %d", err);
+#line 624
+	  } else {
+#line 624
+            IF (err != NC_EINVALCOORDS)
+#line 624
+                error("bad index: status = %d", err);
+#line 624
+            start[j] = 0;
+#line 624
+            edge[j] = var_shape[i][j] + 1;
+#line 624
+            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+#line 624
+            IF (err != NC_EEDGE)
+#line 624
+                error("bad edge: status = %d", err);
+#line 624
+            edge[j] = 1;
+#line 624
+            stride[j] = 0;
+#line 624
+            err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
+#line 624
+            IF (err != NC_ESTRIDE)
+#line 624
+                error("bad stride: status = %d", err);
+#line 624
+            stride[j] = 1;
+#line 624
+	  }
+#line 624
+        }
+#line 624
+            /* Choose a random point dividing each dim into 2 parts */
+#line 624
+            /* get 2^rank (nslabs) slabs so defined */
+#line 624
+        nslabs = 1;
+#line 624
+        for (j = 0; j < var_rank[i]; j++) {
+#line 624
+            mid[j] = roll( var_shape[i][j] );
+#line 624
+            nslabs *= 2;
+#line 624
+        }
+#line 624
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 624
+            /* choose random stride from 1 to edge */
+#line 624
+        for (k = 0; k < nslabs; k++) {
+#line 624
+            nstarts = 1;
+#line 624
+            for (j = 0; j < var_rank[i]; j++) {
+#line 624
+                if ((k >> j) & 1) {
+#line 624
+                    start[j] = 0;
+#line 624
+                    edge[j] = mid[j];
+#line 624
+                }else{
+#line 624
+                    start[j] = mid[j];
+#line 624
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 624
+                }
+#line 624
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 624
+                nstarts *= stride[j];
+#line 624
+            }
+#line 624
+            for (m = 0; m < nstarts; m++) {
+#line 624
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 624
+                IF (err)
+#line 624
+                    error("error in toMixedBase");
+#line 624
+                nels = 1;
+#line 624
+                for (j = 0; j < var_rank[i]; j++) {
+#line 624
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 624
+                    nels *= count[j];
+#line 624
+                    index[j] += start[j];
+#line 624
+                }
+#line 624
+                        /* Random choice of forward or backward */
+#line 624
+/* TODO
+#line 624
+                if ( roll(2) ) {
+#line 624
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 624
+                        index[j] += (count[j] - 1) * stride[j];
+#line 624
+                        stride[j] = -stride[j];
+#line 624
+                    }
+#line 624
+                }
+#line 624
+*/
+#line 624
+		allInExtRange = allInIntRange = 1;
+#line 624
+		for (j = 0; j < nels; j++) {
+#line 624
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 624
+		    IF (err)
+#line 624
+			error("error in toMixedBase 1");
+#line 624
+		    for (d = 0; d < var_rank[i]; d++)
+#line 624
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 624
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 624
+			NCT_UCHAR);
+#line 624
+		    if (inRange3(expect[j],var_type[i],NCT_UCHAR)) {
+#line 624
+			allInIntRange = allInIntRange && expect[j] >= uchar_min
+#line 624
+			    && expect[j] <= uchar_max;
+#line 624
+		    } else {
+#line 624
+			allInExtRange = 0;
+#line 624
+		    }
+#line 624
+		}
+#line 624
+                if (var_rank[i] == 0 && i%2 )
+#line 624
+                    err = nc_get_vars_uchar(ncid, i, NULL, NULL, NULL, value);
+#line 624
+                else
+#line 624
+                    err = nc_get_vars_uchar(ncid, i, index, count, stride, value);
+#line 624
+		if (canConvert) {
+#line 624
+		    if (allInExtRange) {
+#line 624
+			if (allInIntRange) {
+#line 624
+			    IF (err)
+#line 624
+				error("%s", nc_strerror(err));
+#line 624
+			} else {
+#line 624
+			    IF (err != NC_ERANGE)
+#line 624
+				error("Range error: status = %d", err);
+#line 624
+			}
+#line 624
+		    } else {
+#line 624
+			IF (err != 0 && err != NC_ERANGE)
+#line 624
+			    error("OK or Range error: status = %d", err);
+#line 624
+		    }
+#line 624
+		    for (j = 0; j < nels; j++) {
+#line 624
+			if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+#line 624
+				&& expect[j] >= uchar_min && expect[j] <= uchar_max) {
+#line 624
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 624
+				    NCT_UCHAR)){
+#line 624
+				error("value read not that expected");
+#line 624
+				if (verbose) {
+#line 624
+				    error("\n");
+#line 624
+				    error("varid: %d, ", i);
+#line 624
+				    error("var_name: %s, ", var_name[i]);
+#line 624
+				    error("element number: %d ", j);
+#line 624
+                                    error("expect: %g, ", expect[j]);
+#line 624
+				    error("got: %g", (double) value[j]);
+#line 624
+				}
+#line 624
+			    } else {
+#line 624
+				nok++;
+#line 624
+			    }
+#line 624
+			}
+#line 624
+		    }
+#line 624
+		} else {
+#line 624
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 624
+			error("wrong type: status = %d", err);
+#line 624
+		}
+#line 624
+	    }
+#line 624
+	}
+#line 624
+
+#line 624
+    }
+#line 624
+    err = nc_close(ncid);
+#line 624
+    IF (err)
+#line 624
+        error("nc_close: %s", nc_strerror(err));
+#line 624
+    print_nok(nok);
+#line 624
+}
+#line 624
+
+void
+#line 625
+test_nc_get_vars_schar(void)
+#line 625
+{
+#line 625
+    int ncid;
+#line 625
+    int d;
+#line 625
+    int i;
+#line 625
+    int j;
+#line 625
+    int k;
+#line 625
+    int m;
+#line 625
+    int err;
+#line 625
+    int allInExtRange;	/* all values within external range? */
+#line 625
+    int allInIntRange;	/* all values within internal range? */
+#line 625
+    int nels;
+#line 625
+    int nslabs;
+#line 625
+    int nstarts;        /* number of different starts */
+#line 625
+    int nok = 0;      /* count of valid comparisons */
+#line 625
+    size_t start[MAX_RANK];
+#line 625
+    size_t edge[MAX_RANK];
+#line 625
+    size_t index[MAX_RANK];
+#line 625
+    size_t index2[MAX_RANK];
+#line 625
+    size_t mid[MAX_RANK];
+#line 625
+    size_t count[MAX_RANK];
+#line 625
+    size_t sstride[MAX_RANK];
+#line 625
+    ptrdiff_t stride[MAX_RANK];
+#line 625
+    int canConvert;     /* Both text or both numeric */
+#line 625
+    schar value[MAX_NELS];
+#line 625
+    double expect[MAX_NELS];
+#line 625
+
+#line 625
+#ifdef TEST_PNETCDF
+#line 625
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 625
+#else
+#line 625
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 625
+#endif
+#line 625
+    IF (err)
+#line 625
+        error("nc_open: %s", nc_strerror(err));
+#line 625
+    for (i = 0; i < numVars; i++) {
+#line 625
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+#line 625
+        assert(var_rank[i] <= MAX_RANK);
+#line 625
+        assert(var_nels[i] <= MAX_NELS);
+#line 625
+        for (j = 0; j < var_rank[i]; j++) {
+#line 625
+            start[j] = 0;
+#line 625
+            edge[j] = 1;
+#line 625
+            stride[j] = 1;
+#line 625
+        }
+#line 625
+        err = nc_get_vars_schar(BAD_ID, i, start, edge, stride, value);
+#line 625
+        IF (err != NC_EBADID)
+#line 625
+            error("bad ncid: status = %d", err);
+#line 625
+        err = nc_get_vars_schar(ncid, BAD_VARID, start, edge, stride, value);
+#line 625
+        IF (err != NC_ENOTVAR)
+#line 625
+            error("bad var id: status = %d", err);
+#line 625
+        for (j = 0; j < var_rank[i]; j++) {
+#line 625
+            start[j] = var_shape[i][j];
+#line 625
+            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+#line 625
+	  if(!canConvert) {
+#line 625
+		IF (err != NC_ECHAR)
+#line 625
+               	    error("conversion: status = %d", err);
+#line 625
+	  } else {
+#line 625
+            IF (err != NC_EINVALCOORDS)
+#line 625
+                error("bad index: status = %d", err);
+#line 625
+            start[j] = 0;
+#line 625
+            edge[j] = var_shape[i][j] + 1;
+#line 625
+            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+#line 625
+            IF (err != NC_EEDGE)
+#line 625
+                error("bad edge: status = %d", err);
+#line 625
+            edge[j] = 1;
+#line 625
+            stride[j] = 0;
+#line 625
+            err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
+#line 625
+            IF (err != NC_ESTRIDE)
+#line 625
+                error("bad stride: status = %d", err);
+#line 625
+            stride[j] = 1;
+#line 625
+	  }
+#line 625
+        }
+#line 625
+            /* Choose a random point dividing each dim into 2 parts */
+#line 625
+            /* get 2^rank (nslabs) slabs so defined */
+#line 625
+        nslabs = 1;
+#line 625
+        for (j = 0; j < var_rank[i]; j++) {
+#line 625
+            mid[j] = roll( var_shape[i][j] );
+#line 625
+            nslabs *= 2;
+#line 625
+        }
+#line 625
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 625
+            /* choose random stride from 1 to edge */
+#line 625
+        for (k = 0; k < nslabs; k++) {
+#line 625
+            nstarts = 1;
+#line 625
+            for (j = 0; j < var_rank[i]; j++) {
+#line 625
+                if ((k >> j) & 1) {
+#line 625
+                    start[j] = 0;
+#line 625
+                    edge[j] = mid[j];
+#line 625
+                }else{
+#line 625
+                    start[j] = mid[j];
+#line 625
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 625
+                }
+#line 625
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 625
+                nstarts *= stride[j];
+#line 625
+            }
+#line 625
+            for (m = 0; m < nstarts; m++) {
+#line 625
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 625
+                IF (err)
+#line 625
+                    error("error in toMixedBase");
+#line 625
+                nels = 1;
+#line 625
+                for (j = 0; j < var_rank[i]; j++) {
+#line 625
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 625
+                    nels *= count[j];
+#line 625
+                    index[j] += start[j];
+#line 625
+                }
+#line 625
+                        /* Random choice of forward or backward */
+#line 625
+/* TODO
+#line 625
+                if ( roll(2) ) {
+#line 625
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 625
+                        index[j] += (count[j] - 1) * stride[j];
+#line 625
+                        stride[j] = -stride[j];
+#line 625
+                    }
+#line 625
+                }
+#line 625
+*/
+#line 625
+		allInExtRange = allInIntRange = 1;
+#line 625
+		for (j = 0; j < nels; j++) {
+#line 625
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 625
+		    IF (err)
+#line 625
+			error("error in toMixedBase 1");
+#line 625
+		    for (d = 0; d < var_rank[i]; d++)
+#line 625
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 625
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 625
+			NCT_SCHAR);
+#line 625
+		    if (inRange3(expect[j],var_type[i],NCT_SCHAR)) {
+#line 625
+			allInIntRange = allInIntRange && expect[j] >= schar_min
+#line 625
+			    && expect[j] <= schar_max;
+#line 625
+		    } else {
+#line 625
+			allInExtRange = 0;
+#line 625
+		    }
+#line 625
+		}
+#line 625
+                if (var_rank[i] == 0 && i%2 )
+#line 625
+                    err = nc_get_vars_schar(ncid, i, NULL, NULL, NULL, value);
+#line 625
+                else
+#line 625
+                    err = nc_get_vars_schar(ncid, i, index, count, stride, value);
+#line 625
+		if (canConvert) {
+#line 625
+		    if (allInExtRange) {
+#line 625
+			if (allInIntRange) {
+#line 625
+			    IF (err)
+#line 625
+				error("%s", nc_strerror(err));
+#line 625
+			} else {
+#line 625
+			    IF (err != NC_ERANGE)
+#line 625
+				error("Range error: status = %d", err);
+#line 625
+			}
+#line 625
+		    } else {
+#line 625
+			IF (err != 0 && err != NC_ERANGE)
+#line 625
+			    error("OK or Range error: status = %d", err);
+#line 625
+		    }
+#line 625
+		    for (j = 0; j < nels; j++) {
+#line 625
+			if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+#line 625
+				&& expect[j] >= schar_min && expect[j] <= schar_max) {
+#line 625
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 625
+				    NCT_SCHAR)){
+#line 625
+				error("value read not that expected");
+#line 625
+				if (verbose) {
+#line 625
+				    error("\n");
+#line 625
+				    error("varid: %d, ", i);
+#line 625
+				    error("var_name: %s, ", var_name[i]);
+#line 625
+				    error("element number: %d ", j);
+#line 625
+                                    error("expect: %g, ", expect[j]);
+#line 625
+				    error("got: %g", (double) value[j]);
+#line 625
+				}
+#line 625
+			    } else {
+#line 625
+				nok++;
+#line 625
+			    }
+#line 625
+			}
+#line 625
+		    }
+#line 625
+		} else {
+#line 625
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 625
+			error("wrong type: status = %d", err);
+#line 625
+		}
+#line 625
+	    }
+#line 625
+	}
+#line 625
+
+#line 625
+    }
+#line 625
+    err = nc_close(ncid);
+#line 625
+    IF (err)
+#line 625
+        error("nc_close: %s", nc_strerror(err));
+#line 625
+    print_nok(nok);
+#line 625
+}
+#line 625
+
+void
+#line 626
+test_nc_get_vars_short(void)
+#line 626
+{
+#line 626
+    int ncid;
+#line 626
+    int d;
+#line 626
+    int i;
+#line 626
+    int j;
+#line 626
+    int k;
+#line 626
+    int m;
+#line 626
+    int err;
+#line 626
+    int allInExtRange;	/* all values within external range? */
+#line 626
+    int allInIntRange;	/* all values within internal range? */
+#line 626
+    int nels;
+#line 626
+    int nslabs;
+#line 626
+    int nstarts;        /* number of different starts */
+#line 626
+    int nok = 0;      /* count of valid comparisons */
+#line 626
+    size_t start[MAX_RANK];
+#line 626
+    size_t edge[MAX_RANK];
+#line 626
+    size_t index[MAX_RANK];
+#line 626
+    size_t index2[MAX_RANK];
+#line 626
+    size_t mid[MAX_RANK];
+#line 626
+    size_t count[MAX_RANK];
+#line 626
+    size_t sstride[MAX_RANK];
+#line 626
+    ptrdiff_t stride[MAX_RANK];
+#line 626
+    int canConvert;     /* Both text or both numeric */
+#line 626
+    short value[MAX_NELS];
+#line 626
+    double expect[MAX_NELS];
+#line 626
+
+#line 626
+#ifdef TEST_PNETCDF
+#line 626
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 626
+#else
+#line 626
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 626
+#endif
+#line 626
+    IF (err)
+#line 626
+        error("nc_open: %s", nc_strerror(err));
+#line 626
+    for (i = 0; i < numVars; i++) {
+#line 626
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+#line 626
+        assert(var_rank[i] <= MAX_RANK);
+#line 626
+        assert(var_nels[i] <= MAX_NELS);
+#line 626
+        for (j = 0; j < var_rank[i]; j++) {
+#line 626
+            start[j] = 0;
+#line 626
+            edge[j] = 1;
+#line 626
+            stride[j] = 1;
+#line 626
+        }
+#line 626
+        err = nc_get_vars_short(BAD_ID, i, start, edge, stride, value);
+#line 626
+        IF (err != NC_EBADID)
+#line 626
+            error("bad ncid: status = %d", err);
+#line 626
+        err = nc_get_vars_short(ncid, BAD_VARID, start, edge, stride, value);
+#line 626
+        IF (err != NC_ENOTVAR)
+#line 626
+            error("bad var id: status = %d", err);
+#line 626
+        for (j = 0; j < var_rank[i]; j++) {
+#line 626
+            start[j] = var_shape[i][j];
+#line 626
+            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+#line 626
+	  if(!canConvert) {
+#line 626
+		IF (err != NC_ECHAR)
+#line 626
+               	    error("conversion: status = %d", err);
+#line 626
+	  } else {
+#line 626
+            IF (err != NC_EINVALCOORDS)
+#line 626
+                error("bad index: status = %d", err);
+#line 626
+            start[j] = 0;
+#line 626
+            edge[j] = var_shape[i][j] + 1;
+#line 626
+            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+#line 626
+            IF (err != NC_EEDGE)
+#line 626
+                error("bad edge: status = %d", err);
+#line 626
+            edge[j] = 1;
+#line 626
+            stride[j] = 0;
+#line 626
+            err = nc_get_vars_short(ncid, i, start, edge, stride, value);
+#line 626
+            IF (err != NC_ESTRIDE)
+#line 626
+                error("bad stride: status = %d", err);
+#line 626
+            stride[j] = 1;
+#line 626
+	  }
+#line 626
+        }
+#line 626
+            /* Choose a random point dividing each dim into 2 parts */
+#line 626
+            /* get 2^rank (nslabs) slabs so defined */
+#line 626
+        nslabs = 1;
+#line 626
+        for (j = 0; j < var_rank[i]; j++) {
+#line 626
+            mid[j] = roll( var_shape[i][j] );
+#line 626
+            nslabs *= 2;
+#line 626
+        }
+#line 626
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 626
+            /* choose random stride from 1 to edge */
+#line 626
+        for (k = 0; k < nslabs; k++) {
+#line 626
+            nstarts = 1;
+#line 626
+            for (j = 0; j < var_rank[i]; j++) {
+#line 626
+                if ((k >> j) & 1) {
+#line 626
+                    start[j] = 0;
+#line 626
+                    edge[j] = mid[j];
+#line 626
+                }else{
+#line 626
+                    start[j] = mid[j];
+#line 626
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 626
+                }
+#line 626
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 626
+                nstarts *= stride[j];
+#line 626
+            }
+#line 626
+            for (m = 0; m < nstarts; m++) {
+#line 626
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 626
+                IF (err)
+#line 626
+                    error("error in toMixedBase");
+#line 626
+                nels = 1;
+#line 626
+                for (j = 0; j < var_rank[i]; j++) {
+#line 626
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 626
+                    nels *= count[j];
+#line 626
+                    index[j] += start[j];
+#line 626
+                }
+#line 626
+                        /* Random choice of forward or backward */
+#line 626
+/* TODO
+#line 626
+                if ( roll(2) ) {
+#line 626
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 626
+                        index[j] += (count[j] - 1) * stride[j];
+#line 626
+                        stride[j] = -stride[j];
+#line 626
+                    }
+#line 626
+                }
+#line 626
+*/
+#line 626
+		allInExtRange = allInIntRange = 1;
+#line 626
+		for (j = 0; j < nels; j++) {
+#line 626
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 626
+		    IF (err)
+#line 626
+			error("error in toMixedBase 1");
+#line 626
+		    for (d = 0; d < var_rank[i]; d++)
+#line 626
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 626
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 626
+			NCT_SHORT);
+#line 626
+		    if (inRange3(expect[j],var_type[i],NCT_SHORT)) {
+#line 626
+			allInIntRange = allInIntRange && expect[j] >= short_min
+#line 626
+			    && expect[j] <= short_max;
+#line 626
+		    } else {
+#line 626
+			allInExtRange = 0;
+#line 626
+		    }
+#line 626
+		}
+#line 626
+                if (var_rank[i] == 0 && i%2 )
+#line 626
+                    err = nc_get_vars_short(ncid, i, NULL, NULL, NULL, value);
+#line 626
+                else
+#line 626
+                    err = nc_get_vars_short(ncid, i, index, count, stride, value);
+#line 626
+		if (canConvert) {
+#line 626
+		    if (allInExtRange) {
+#line 626
+			if (allInIntRange) {
+#line 626
+			    IF (err)
+#line 626
+				error("%s", nc_strerror(err));
+#line 626
+			} else {
+#line 626
+			    IF (err != NC_ERANGE)
+#line 626
+				error("Range error: status = %d", err);
+#line 626
+			}
+#line 626
+		    } else {
+#line 626
+			IF (err != 0 && err != NC_ERANGE)
+#line 626
+			    error("OK or Range error: status = %d", err);
+#line 626
+		    }
+#line 626
+		    for (j = 0; j < nels; j++) {
+#line 626
+			if (inRange3(expect[j],var_type[i],NCT_SHORT)
+#line 626
+				&& expect[j] >= short_min && expect[j] <= short_max) {
+#line 626
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 626
+				    NCT_SHORT)){
+#line 626
+				error("value read not that expected");
+#line 626
+				if (verbose) {
+#line 626
+				    error("\n");
+#line 626
+				    error("varid: %d, ", i);
+#line 626
+				    error("var_name: %s, ", var_name[i]);
+#line 626
+				    error("element number: %d ", j);
+#line 626
+                                    error("expect: %g, ", expect[j]);
+#line 626
+				    error("got: %g", (double) value[j]);
+#line 626
+				}
+#line 626
+			    } else {
+#line 626
+				nok++;
+#line 626
+			    }
+#line 626
+			}
+#line 626
+		    }
+#line 626
+		} else {
+#line 626
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 626
+			error("wrong type: status = %d", err);
+#line 626
+		}
+#line 626
+	    }
+#line 626
+	}
+#line 626
+
+#line 626
+    }
+#line 626
+    err = nc_close(ncid);
+#line 626
+    IF (err)
+#line 626
+        error("nc_close: %s", nc_strerror(err));
+#line 626
+    print_nok(nok);
+#line 626
+}
+#line 626
+
+void
+#line 627
+test_nc_get_vars_int(void)
+#line 627
+{
+#line 627
+    int ncid;
+#line 627
+    int d;
+#line 627
+    int i;
+#line 627
+    int j;
+#line 627
+    int k;
+#line 627
+    int m;
+#line 627
+    int err;
+#line 627
+    int allInExtRange;	/* all values within external range? */
+#line 627
+    int allInIntRange;	/* all values within internal range? */
+#line 627
+    int nels;
+#line 627
+    int nslabs;
+#line 627
+    int nstarts;        /* number of different starts */
+#line 627
+    int nok = 0;      /* count of valid comparisons */
+#line 627
+    size_t start[MAX_RANK];
+#line 627
+    size_t edge[MAX_RANK];
+#line 627
+    size_t index[MAX_RANK];
+#line 627
+    size_t index2[MAX_RANK];
+#line 627
+    size_t mid[MAX_RANK];
+#line 627
+    size_t count[MAX_RANK];
+#line 627
+    size_t sstride[MAX_RANK];
+#line 627
+    ptrdiff_t stride[MAX_RANK];
+#line 627
+    int canConvert;     /* Both text or both numeric */
+#line 627
+    int value[MAX_NELS];
+#line 627
+    double expect[MAX_NELS];
+#line 627
+
+#line 627
+#ifdef TEST_PNETCDF
+#line 627
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 627
+#else
+#line 627
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 627
+#endif
+#line 627
+    IF (err)
+#line 627
+        error("nc_open: %s", nc_strerror(err));
+#line 627
+    for (i = 0; i < numVars; i++) {
+#line 627
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+#line 627
+        assert(var_rank[i] <= MAX_RANK);
+#line 627
+        assert(var_nels[i] <= MAX_NELS);
+#line 627
+        for (j = 0; j < var_rank[i]; j++) {
+#line 627
+            start[j] = 0;
+#line 627
+            edge[j] = 1;
+#line 627
+            stride[j] = 1;
+#line 627
+        }
+#line 627
+        err = nc_get_vars_int(BAD_ID, i, start, edge, stride, value);
+#line 627
+        IF (err != NC_EBADID)
+#line 627
+            error("bad ncid: status = %d", err);
+#line 627
+        err = nc_get_vars_int(ncid, BAD_VARID, start, edge, stride, value);
+#line 627
+        IF (err != NC_ENOTVAR)
+#line 627
+            error("bad var id: status = %d", err);
+#line 627
+        for (j = 0; j < var_rank[i]; j++) {
+#line 627
+            start[j] = var_shape[i][j];
+#line 627
+            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+#line 627
+	  if(!canConvert) {
+#line 627
+		IF (err != NC_ECHAR)
+#line 627
+               	    error("conversion: status = %d", err);
+#line 627
+	  } else {
+#line 627
+            IF (err != NC_EINVALCOORDS)
+#line 627
+                error("bad index: status = %d", err);
+#line 627
+            start[j] = 0;
+#line 627
+            edge[j] = var_shape[i][j] + 1;
+#line 627
+            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+#line 627
+            IF (err != NC_EEDGE)
+#line 627
+                error("bad edge: status = %d", err);
+#line 627
+            edge[j] = 1;
+#line 627
+            stride[j] = 0;
+#line 627
+            err = nc_get_vars_int(ncid, i, start, edge, stride, value);
+#line 627
+            IF (err != NC_ESTRIDE)
+#line 627
+                error("bad stride: status = %d", err);
+#line 627
+            stride[j] = 1;
+#line 627
+	  }
+#line 627
+        }
+#line 627
+            /* Choose a random point dividing each dim into 2 parts */
+#line 627
+            /* get 2^rank (nslabs) slabs so defined */
+#line 627
+        nslabs = 1;
+#line 627
+        for (j = 0; j < var_rank[i]; j++) {
+#line 627
+            mid[j] = roll( var_shape[i][j] );
+#line 627
+            nslabs *= 2;
+#line 627
+        }
+#line 627
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 627
+            /* choose random stride from 1 to edge */
+#line 627
+        for (k = 0; k < nslabs; k++) {
+#line 627
+            nstarts = 1;
+#line 627
+            for (j = 0; j < var_rank[i]; j++) {
+#line 627
+                if ((k >> j) & 1) {
+#line 627
+                    start[j] = 0;
+#line 627
+                    edge[j] = mid[j];
+#line 627
+                }else{
+#line 627
+                    start[j] = mid[j];
+#line 627
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 627
+                }
+#line 627
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 627
+                nstarts *= stride[j];
+#line 627
+            }
+#line 627
+            for (m = 0; m < nstarts; m++) {
+#line 627
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 627
+                IF (err)
+#line 627
+                    error("error in toMixedBase");
+#line 627
+                nels = 1;
+#line 627
+                for (j = 0; j < var_rank[i]; j++) {
+#line 627
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 627
+                    nels *= count[j];
+#line 627
+                    index[j] += start[j];
+#line 627
+                }
+#line 627
+                        /* Random choice of forward or backward */
+#line 627
+/* TODO
+#line 627
+                if ( roll(2) ) {
+#line 627
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 627
+                        index[j] += (count[j] - 1) * stride[j];
+#line 627
+                        stride[j] = -stride[j];
+#line 627
+                    }
+#line 627
+                }
+#line 627
+*/
+#line 627
+		allInExtRange = allInIntRange = 1;
+#line 627
+		for (j = 0; j < nels; j++) {
+#line 627
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 627
+		    IF (err)
+#line 627
+			error("error in toMixedBase 1");
+#line 627
+		    for (d = 0; d < var_rank[i]; d++)
+#line 627
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 627
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 627
+			NCT_INT);
+#line 627
+		    if (inRange3(expect[j],var_type[i],NCT_INT)) {
+#line 627
+			allInIntRange = allInIntRange && expect[j] >= int_min
+#line 627
+			    && expect[j] <= int_max;
+#line 627
+		    } else {
+#line 627
+			allInExtRange = 0;
+#line 627
+		    }
+#line 627
+		}
+#line 627
+                if (var_rank[i] == 0 && i%2 )
+#line 627
+                    err = nc_get_vars_int(ncid, i, NULL, NULL, NULL, value);
+#line 627
+                else
+#line 627
+                    err = nc_get_vars_int(ncid, i, index, count, stride, value);
+#line 627
+		if (canConvert) {
+#line 627
+		    if (allInExtRange) {
+#line 627
+			if (allInIntRange) {
+#line 627
+			    IF (err)
+#line 627
+				error("%s", nc_strerror(err));
+#line 627
+			} else {
+#line 627
+			    IF (err != NC_ERANGE)
+#line 627
+				error("Range error: status = %d", err);
+#line 627
+			}
+#line 627
+		    } else {
+#line 627
+			IF (err != 0 && err != NC_ERANGE)
+#line 627
+			    error("OK or Range error: status = %d", err);
+#line 627
+		    }
+#line 627
+		    for (j = 0; j < nels; j++) {
+#line 627
+			if (inRange3(expect[j],var_type[i],NCT_INT)
+#line 627
+				&& expect[j] >= int_min && expect[j] <= int_max) {
+#line 627
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 627
+				    NCT_INT)){
+#line 627
+				error("value read not that expected");
+#line 627
+				if (verbose) {
+#line 627
+				    error("\n");
+#line 627
+				    error("varid: %d, ", i);
+#line 627
+				    error("var_name: %s, ", var_name[i]);
+#line 627
+				    error("element number: %d ", j);
+#line 627
+                                    error("expect: %g, ", expect[j]);
+#line 627
+				    error("got: %g", (double) value[j]);
+#line 627
+				}
+#line 627
+			    } else {
+#line 627
+				nok++;
+#line 627
+			    }
+#line 627
+			}
+#line 627
+		    }
+#line 627
+		} else {
+#line 627
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 627
+			error("wrong type: status = %d", err);
+#line 627
+		}
+#line 627
+	    }
+#line 627
+	}
+#line 627
+
+#line 627
+    }
+#line 627
+    err = nc_close(ncid);
+#line 627
+    IF (err)
+#line 627
+        error("nc_close: %s", nc_strerror(err));
+#line 627
+    print_nok(nok);
+#line 627
+}
+#line 627
+
+void
+#line 628
+test_nc_get_vars_long(void)
+#line 628
+{
+#line 628
+    int ncid;
+#line 628
+    int d;
+#line 628
+    int i;
+#line 628
+    int j;
+#line 628
+    int k;
+#line 628
+    int m;
+#line 628
+    int err;
+#line 628
+    int allInExtRange;	/* all values within external range? */
+#line 628
+    int allInIntRange;	/* all values within internal range? */
+#line 628
+    int nels;
+#line 628
+    int nslabs;
+#line 628
+    int nstarts;        /* number of different starts */
+#line 628
+    int nok = 0;      /* count of valid comparisons */
+#line 628
+    size_t start[MAX_RANK];
+#line 628
+    size_t edge[MAX_RANK];
+#line 628
+    size_t index[MAX_RANK];
+#line 628
+    size_t index2[MAX_RANK];
+#line 628
+    size_t mid[MAX_RANK];
+#line 628
+    size_t count[MAX_RANK];
+#line 628
+    size_t sstride[MAX_RANK];
+#line 628
+    ptrdiff_t stride[MAX_RANK];
+#line 628
+    int canConvert;     /* Both text or both numeric */
+#line 628
+    long value[MAX_NELS];
+#line 628
+    double expect[MAX_NELS];
+#line 628
+
+#line 628
+#ifdef TEST_PNETCDF
+#line 628
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 628
+#else
+#line 628
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 628
+#endif
+#line 628
+    IF (err)
+#line 628
+        error("nc_open: %s", nc_strerror(err));
+#line 628
+    for (i = 0; i < numVars; i++) {
+#line 628
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+#line 628
+        assert(var_rank[i] <= MAX_RANK);
+#line 628
+        assert(var_nels[i] <= MAX_NELS);
+#line 628
+        for (j = 0; j < var_rank[i]; j++) {
+#line 628
+            start[j] = 0;
+#line 628
+            edge[j] = 1;
+#line 628
+            stride[j] = 1;
+#line 628
+        }
+#line 628
+        err = nc_get_vars_long(BAD_ID, i, start, edge, stride, value);
+#line 628
+        IF (err != NC_EBADID)
+#line 628
+            error("bad ncid: status = %d", err);
+#line 628
+        err = nc_get_vars_long(ncid, BAD_VARID, start, edge, stride, value);
+#line 628
+        IF (err != NC_ENOTVAR)
+#line 628
+            error("bad var id: status = %d", err);
+#line 628
+        for (j = 0; j < var_rank[i]; j++) {
+#line 628
+            start[j] = var_shape[i][j];
+#line 628
+            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+#line 628
+	  if(!canConvert) {
+#line 628
+		IF (err != NC_ECHAR)
+#line 628
+               	    error("conversion: status = %d", err);
+#line 628
+	  } else {
+#line 628
+            IF (err != NC_EINVALCOORDS)
+#line 628
+                error("bad index: status = %d", err);
+#line 628
+            start[j] = 0;
+#line 628
+            edge[j] = var_shape[i][j] + 1;
+#line 628
+            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+#line 628
+            IF (err != NC_EEDGE)
+#line 628
+                error("bad edge: status = %d", err);
+#line 628
+            edge[j] = 1;
+#line 628
+            stride[j] = 0;
+#line 628
+            err = nc_get_vars_long(ncid, i, start, edge, stride, value);
+#line 628
+            IF (err != NC_ESTRIDE)
+#line 628
+                error("bad stride: status = %d", err);
+#line 628
+            stride[j] = 1;
+#line 628
+	  }
+#line 628
+        }
+#line 628
+            /* Choose a random point dividing each dim into 2 parts */
+#line 628
+            /* get 2^rank (nslabs) slabs so defined */
+#line 628
+        nslabs = 1;
+#line 628
+        for (j = 0; j < var_rank[i]; j++) {
+#line 628
+            mid[j] = roll( var_shape[i][j] );
+#line 628
+            nslabs *= 2;
+#line 628
+        }
+#line 628
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 628
+            /* choose random stride from 1 to edge */
+#line 628
+        for (k = 0; k < nslabs; k++) {
+#line 628
+            nstarts = 1;
+#line 628
+            for (j = 0; j < var_rank[i]; j++) {
+#line 628
+                if ((k >> j) & 1) {
+#line 628
+                    start[j] = 0;
+#line 628
+                    edge[j] = mid[j];
+#line 628
+                }else{
+#line 628
+                    start[j] = mid[j];
+#line 628
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 628
+                }
+#line 628
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 628
+                nstarts *= stride[j];
+#line 628
+            }
+#line 628
+            for (m = 0; m < nstarts; m++) {
+#line 628
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 628
+                IF (err)
+#line 628
+                    error("error in toMixedBase");
+#line 628
+                nels = 1;
+#line 628
+                for (j = 0; j < var_rank[i]; j++) {
+#line 628
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 628
+                    nels *= count[j];
+#line 628
+                    index[j] += start[j];
+#line 628
+                }
+#line 628
+                        /* Random choice of forward or backward */
+#line 628
+/* TODO
+#line 628
+                if ( roll(2) ) {
+#line 628
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 628
+                        index[j] += (count[j] - 1) * stride[j];
+#line 628
+                        stride[j] = -stride[j];
+#line 628
+                    }
+#line 628
+                }
+#line 628
+*/
+#line 628
+		allInExtRange = allInIntRange = 1;
+#line 628
+		for (j = 0; j < nels; j++) {
+#line 628
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 628
+		    IF (err)
+#line 628
+			error("error in toMixedBase 1");
+#line 628
+		    for (d = 0; d < var_rank[i]; d++)
+#line 628
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 628
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 628
+			NCT_LONG);
+#line 628
+		    if (inRange3(expect[j],var_type[i],NCT_LONG)) {
+#line 628
+			allInIntRange = allInIntRange && expect[j] >= long_min
+#line 628
+			    && expect[j] <= long_max;
+#line 628
+		    } else {
+#line 628
+			allInExtRange = 0;
+#line 628
+		    }
+#line 628
+		}
+#line 628
+                if (var_rank[i] == 0 && i%2 )
+#line 628
+                    err = nc_get_vars_long(ncid, i, NULL, NULL, NULL, value);
+#line 628
+                else
+#line 628
+                    err = nc_get_vars_long(ncid, i, index, count, stride, value);
+#line 628
+		if (canConvert) {
+#line 628
+		    if (allInExtRange) {
+#line 628
+			if (allInIntRange) {
+#line 628
+			    IF (err)
+#line 628
+				error("%s", nc_strerror(err));
+#line 628
+			} else {
+#line 628
+			    IF (err != NC_ERANGE)
+#line 628
+				error("Range error: status = %d", err);
+#line 628
+			}
+#line 628
+		    } else {
+#line 628
+			IF (err != 0 && err != NC_ERANGE)
+#line 628
+			    error("OK or Range error: status = %d", err);
+#line 628
+		    }
+#line 628
+		    for (j = 0; j < nels; j++) {
+#line 628
+			if (inRange3(expect[j],var_type[i],NCT_LONG)
+#line 628
+				&& expect[j] >= long_min && expect[j] <= long_max) {
+#line 628
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 628
+				    NCT_LONG)){
+#line 628
+				error("value read not that expected");
+#line 628
+				if (verbose) {
+#line 628
+				    error("\n");
+#line 628
+				    error("varid: %d, ", i);
+#line 628
+				    error("var_name: %s, ", var_name[i]);
+#line 628
+				    error("element number: %d ", j);
+#line 628
+                                    error("expect: %g, ", expect[j]);
+#line 628
+				    error("got: %g", (double) value[j]);
+#line 628
+				}
+#line 628
+			    } else {
+#line 628
+				nok++;
+#line 628
+			    }
+#line 628
+			}
+#line 628
+		    }
+#line 628
+		} else {
+#line 628
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 628
+			error("wrong type: status = %d", err);
+#line 628
+		}
+#line 628
+	    }
+#line 628
+	}
+#line 628
+
+#line 628
+    }
+#line 628
+    err = nc_close(ncid);
+#line 628
+    IF (err)
+#line 628
+        error("nc_close: %s", nc_strerror(err));
+#line 628
+    print_nok(nok);
+#line 628
+}
+#line 628
+
+void
+#line 629
+test_nc_get_vars_float(void)
+#line 629
+{
+#line 629
+    int ncid;
+#line 629
+    int d;
+#line 629
+    int i;
+#line 629
+    int j;
+#line 629
+    int k;
+#line 629
+    int m;
+#line 629
+    int err;
+#line 629
+    int allInExtRange;	/* all values within external range? */
+#line 629
+    int allInIntRange;	/* all values within internal range? */
+#line 629
+    int nels;
+#line 629
+    int nslabs;
+#line 629
+    int nstarts;        /* number of different starts */
+#line 629
+    int nok = 0;      /* count of valid comparisons */
+#line 629
+    size_t start[MAX_RANK];
+#line 629
+    size_t edge[MAX_RANK];
+#line 629
+    size_t index[MAX_RANK];
+#line 629
+    size_t index2[MAX_RANK];
+#line 629
+    size_t mid[MAX_RANK];
+#line 629
+    size_t count[MAX_RANK];
+#line 629
+    size_t sstride[MAX_RANK];
+#line 629
+    ptrdiff_t stride[MAX_RANK];
+#line 629
+    int canConvert;     /* Both text or both numeric */
+#line 629
+    float value[MAX_NELS];
+#line 629
+    double expect[MAX_NELS];
+#line 629
+
+#line 629
+#ifdef TEST_PNETCDF
+#line 629
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 629
+#else
+#line 629
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 629
+#endif
+#line 629
+    IF (err)
+#line 629
+        error("nc_open: %s", nc_strerror(err));
+#line 629
+    for (i = 0; i < numVars; i++) {
+#line 629
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+#line 629
+        assert(var_rank[i] <= MAX_RANK);
+#line 629
+        assert(var_nels[i] <= MAX_NELS);
+#line 629
+        for (j = 0; j < var_rank[i]; j++) {
+#line 629
+            start[j] = 0;
+#line 629
+            edge[j] = 1;
+#line 629
+            stride[j] = 1;
+#line 629
+        }
+#line 629
+        err = nc_get_vars_float(BAD_ID, i, start, edge, stride, value);
+#line 629
+        IF (err != NC_EBADID)
+#line 629
+            error("bad ncid: status = %d", err);
+#line 629
+        err = nc_get_vars_float(ncid, BAD_VARID, start, edge, stride, value);
+#line 629
+        IF (err != NC_ENOTVAR)
+#line 629
+            error("bad var id: status = %d", err);
+#line 629
+        for (j = 0; j < var_rank[i]; j++) {
+#line 629
+            start[j] = var_shape[i][j];
+#line 629
+            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+#line 629
+	  if(!canConvert) {
+#line 629
+		IF (err != NC_ECHAR)
+#line 629
+               	    error("conversion: status = %d", err);
+#line 629
+	  } else {
+#line 629
+            IF (err != NC_EINVALCOORDS)
+#line 629
+                error("bad index: status = %d", err);
+#line 629
+            start[j] = 0;
+#line 629
+            edge[j] = var_shape[i][j] + 1;
+#line 629
+            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+#line 629
+            IF (err != NC_EEDGE)
+#line 629
+                error("bad edge: status = %d", err);
+#line 629
+            edge[j] = 1;
+#line 629
+            stride[j] = 0;
+#line 629
+            err = nc_get_vars_float(ncid, i, start, edge, stride, value);
+#line 629
+            IF (err != NC_ESTRIDE)
+#line 629
+                error("bad stride: status = %d", err);
+#line 629
+            stride[j] = 1;
+#line 629
+	  }
+#line 629
+        }
+#line 629
+            /* Choose a random point dividing each dim into 2 parts */
+#line 629
+            /* get 2^rank (nslabs) slabs so defined */
+#line 629
+        nslabs = 1;
+#line 629
+        for (j = 0; j < var_rank[i]; j++) {
+#line 629
+            mid[j] = roll( var_shape[i][j] );
+#line 629
+            nslabs *= 2;
+#line 629
+        }
+#line 629
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 629
+            /* choose random stride from 1 to edge */
+#line 629
+        for (k = 0; k < nslabs; k++) {
+#line 629
+            nstarts = 1;
+#line 629
+            for (j = 0; j < var_rank[i]; j++) {
+#line 629
+                if ((k >> j) & 1) {
+#line 629
+                    start[j] = 0;
+#line 629
+                    edge[j] = mid[j];
+#line 629
+                }else{
+#line 629
+                    start[j] = mid[j];
+#line 629
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 629
+                }
+#line 629
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 629
+                nstarts *= stride[j];
+#line 629
+            }
+#line 629
+            for (m = 0; m < nstarts; m++) {
+#line 629
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 629
+                IF (err)
+#line 629
+                    error("error in toMixedBase");
+#line 629
+                nels = 1;
+#line 629
+                for (j = 0; j < var_rank[i]; j++) {
+#line 629
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 629
+                    nels *= count[j];
+#line 629
+                    index[j] += start[j];
+#line 629
+                }
+#line 629
+                        /* Random choice of forward or backward */
+#line 629
+/* TODO
+#line 629
+                if ( roll(2) ) {
+#line 629
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 629
+                        index[j] += (count[j] - 1) * stride[j];
+#line 629
+                        stride[j] = -stride[j];
+#line 629
+                    }
+#line 629
+                }
+#line 629
+*/
+#line 629
+		allInExtRange = allInIntRange = 1;
+#line 629
+		for (j = 0; j < nels; j++) {
+#line 629
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 629
+		    IF (err)
+#line 629
+			error("error in toMixedBase 1");
+#line 629
+		    for (d = 0; d < var_rank[i]; d++)
+#line 629
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 629
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 629
+			NCT_FLOAT);
+#line 629
+		    if (inRange3(expect[j],var_type[i],NCT_FLOAT)) {
+#line 629
+			allInIntRange = allInIntRange && expect[j] >= float_min
+#line 629
+			    && expect[j] <= float_max;
+#line 629
+		    } else {
+#line 629
+			allInExtRange = 0;
+#line 629
+		    }
+#line 629
+		}
+#line 629
+                if (var_rank[i] == 0 && i%2 )
+#line 629
+                    err = nc_get_vars_float(ncid, i, NULL, NULL, NULL, value);
+#line 629
+                else
+#line 629
+                    err = nc_get_vars_float(ncid, i, index, count, stride, value);
+#line 629
+		if (canConvert) {
+#line 629
+		    if (allInExtRange) {
+#line 629
+			if (allInIntRange) {
+#line 629
+			    IF (err)
+#line 629
+				error("%s", nc_strerror(err));
+#line 629
+			} else {
+#line 629
+			    IF (err != NC_ERANGE)
+#line 629
+				error("Range error: status = %d", err);
+#line 629
+			}
+#line 629
+		    } else {
+#line 629
+			IF (err != 0 && err != NC_ERANGE)
+#line 629
+			    error("OK or Range error: status = %d", err);
+#line 629
+		    }
+#line 629
+		    for (j = 0; j < nels; j++) {
+#line 629
+			if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+#line 629
+				&& expect[j] >= float_min && expect[j] <= float_max) {
+#line 629
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 629
+				    NCT_FLOAT)){
+#line 629
+				error("value read not that expected");
+#line 629
+				if (verbose) {
+#line 629
+				    error("\n");
+#line 629
+				    error("varid: %d, ", i);
+#line 629
+				    error("var_name: %s, ", var_name[i]);
+#line 629
+				    error("element number: %d ", j);
+#line 629
+                                    error("expect: %g, ", expect[j]);
+#line 629
+				    error("got: %g", (double) value[j]);
+#line 629
+				}
+#line 629
+			    } else {
+#line 629
+				nok++;
+#line 629
+			    }
+#line 629
+			}
+#line 629
+		    }
+#line 629
+		} else {
+#line 629
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 629
+			error("wrong type: status = %d", err);
+#line 629
+		}
+#line 629
+	    }
+#line 629
+	}
+#line 629
+
+#line 629
+    }
+#line 629
+    err = nc_close(ncid);
+#line 629
+    IF (err)
+#line 629
+        error("nc_close: %s", nc_strerror(err));
+#line 629
+    print_nok(nok);
+#line 629
+}
+#line 629
+
+void
+#line 630
+test_nc_get_vars_double(void)
+#line 630
+{
+#line 630
+    int ncid;
+#line 630
+    int d;
+#line 630
+    int i;
+#line 630
+    int j;
+#line 630
+    int k;
+#line 630
+    int m;
+#line 630
+    int err;
+#line 630
+    int allInExtRange;	/* all values within external range? */
+#line 630
+    int allInIntRange;	/* all values within internal range? */
+#line 630
+    int nels;
+#line 630
+    int nslabs;
+#line 630
+    int nstarts;        /* number of different starts */
+#line 630
+    int nok = 0;      /* count of valid comparisons */
+#line 630
+    size_t start[MAX_RANK];
+#line 630
+    size_t edge[MAX_RANK];
+#line 630
+    size_t index[MAX_RANK];
+#line 630
+    size_t index2[MAX_RANK];
+#line 630
+    size_t mid[MAX_RANK];
+#line 630
+    size_t count[MAX_RANK];
+#line 630
+    size_t sstride[MAX_RANK];
+#line 630
+    ptrdiff_t stride[MAX_RANK];
+#line 630
+    int canConvert;     /* Both text or both numeric */
+#line 630
+    double value[MAX_NELS];
+#line 630
+    double expect[MAX_NELS];
+#line 630
+
+#line 630
+#ifdef TEST_PNETCDF
+#line 630
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 630
+#else
+#line 630
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 630
+#endif
+#line 630
+    IF (err)
+#line 630
+        error("nc_open: %s", nc_strerror(err));
+#line 630
+    for (i = 0; i < numVars; i++) {
+#line 630
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+#line 630
+        assert(var_rank[i] <= MAX_RANK);
+#line 630
+        assert(var_nels[i] <= MAX_NELS);
+#line 630
+        for (j = 0; j < var_rank[i]; j++) {
+#line 630
+            start[j] = 0;
+#line 630
+            edge[j] = 1;
+#line 630
+            stride[j] = 1;
+#line 630
+        }
+#line 630
+        err = nc_get_vars_double(BAD_ID, i, start, edge, stride, value);
+#line 630
+        IF (err != NC_EBADID)
+#line 630
+            error("bad ncid: status = %d", err);
+#line 630
+        err = nc_get_vars_double(ncid, BAD_VARID, start, edge, stride, value);
+#line 630
+        IF (err != NC_ENOTVAR)
+#line 630
+            error("bad var id: status = %d", err);
+#line 630
+        for (j = 0; j < var_rank[i]; j++) {
+#line 630
+            start[j] = var_shape[i][j];
+#line 630
+            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+#line 630
+	  if(!canConvert) {
+#line 630
+		IF (err != NC_ECHAR)
+#line 630
+               	    error("conversion: status = %d", err);
+#line 630
+	  } else {
+#line 630
+            IF (err != NC_EINVALCOORDS)
+#line 630
+                error("bad index: status = %d", err);
+#line 630
+            start[j] = 0;
+#line 630
+            edge[j] = var_shape[i][j] + 1;
+#line 630
+            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+#line 630
+            IF (err != NC_EEDGE)
+#line 630
+                error("bad edge: status = %d", err);
+#line 630
+            edge[j] = 1;
+#line 630
+            stride[j] = 0;
+#line 630
+            err = nc_get_vars_double(ncid, i, start, edge, stride, value);
+#line 630
+            IF (err != NC_ESTRIDE)
+#line 630
+                error("bad stride: status = %d", err);
+#line 630
+            stride[j] = 1;
+#line 630
+	  }
+#line 630
+        }
+#line 630
+            /* Choose a random point dividing each dim into 2 parts */
+#line 630
+            /* get 2^rank (nslabs) slabs so defined */
+#line 630
+        nslabs = 1;
+#line 630
+        for (j = 0; j < var_rank[i]; j++) {
+#line 630
+            mid[j] = roll( var_shape[i][j] );
+#line 630
+            nslabs *= 2;
+#line 630
+        }
+#line 630
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 630
+            /* choose random stride from 1 to edge */
+#line 630
+        for (k = 0; k < nslabs; k++) {
+#line 630
+            nstarts = 1;
+#line 630
+            for (j = 0; j < var_rank[i]; j++) {
+#line 630
+                if ((k >> j) & 1) {
+#line 630
+                    start[j] = 0;
+#line 630
+                    edge[j] = mid[j];
+#line 630
+                }else{
+#line 630
+                    start[j] = mid[j];
+#line 630
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 630
+                }
+#line 630
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 630
+                nstarts *= stride[j];
+#line 630
+            }
+#line 630
+            for (m = 0; m < nstarts; m++) {
+#line 630
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 630
+                IF (err)
+#line 630
+                    error("error in toMixedBase");
+#line 630
+                nels = 1;
+#line 630
+                for (j = 0; j < var_rank[i]; j++) {
+#line 630
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 630
+                    nels *= count[j];
+#line 630
+                    index[j] += start[j];
+#line 630
+                }
+#line 630
+                        /* Random choice of forward or backward */
+#line 630
+/* TODO
+#line 630
+                if ( roll(2) ) {
+#line 630
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 630
+                        index[j] += (count[j] - 1) * stride[j];
+#line 630
+                        stride[j] = -stride[j];
+#line 630
+                    }
+#line 630
+                }
+#line 630
+*/
+#line 630
+		allInExtRange = allInIntRange = 1;
+#line 630
+		for (j = 0; j < nels; j++) {
+#line 630
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 630
+		    IF (err)
+#line 630
+			error("error in toMixedBase 1");
+#line 630
+		    for (d = 0; d < var_rank[i]; d++)
+#line 630
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 630
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 630
+			NCT_DOUBLE);
+#line 630
+		    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) {
+#line 630
+			allInIntRange = allInIntRange && expect[j] >= double_min
+#line 630
+			    && expect[j] <= double_max;
+#line 630
+		    } else {
+#line 630
+			allInExtRange = 0;
+#line 630
+		    }
+#line 630
+		}
+#line 630
+                if (var_rank[i] == 0 && i%2 )
+#line 630
+                    err = nc_get_vars_double(ncid, i, NULL, NULL, NULL, value);
+#line 630
+                else
+#line 630
+                    err = nc_get_vars_double(ncid, i, index, count, stride, value);
+#line 630
+		if (canConvert) {
+#line 630
+		    if (allInExtRange) {
+#line 630
+			if (allInIntRange) {
+#line 630
+			    IF (err)
+#line 630
+				error("%s", nc_strerror(err));
+#line 630
+			} else {
+#line 630
+			    IF (err != NC_ERANGE)
+#line 630
+				error("Range error: status = %d", err);
+#line 630
+			}
+#line 630
+		    } else {
+#line 630
+			IF (err != 0 && err != NC_ERANGE)
+#line 630
+			    error("OK or Range error: status = %d", err);
+#line 630
+		    }
+#line 630
+		    for (j = 0; j < nels; j++) {
+#line 630
+			if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+#line 630
+				&& expect[j] >= double_min && expect[j] <= double_max) {
+#line 630
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 630
+				    NCT_DOUBLE)){
+#line 630
+				error("value read not that expected");
+#line 630
+				if (verbose) {
+#line 630
+				    error("\n");
+#line 630
+				    error("varid: %d, ", i);
+#line 630
+				    error("var_name: %s, ", var_name[i]);
+#line 630
+				    error("element number: %d ", j);
+#line 630
+                                    error("expect: %g, ", expect[j]);
+#line 630
+				    error("got: %g", (double) value[j]);
+#line 630
+				}
+#line 630
+			    } else {
+#line 630
+				nok++;
+#line 630
+			    }
+#line 630
+			}
+#line 630
+		    }
+#line 630
+		} else {
+#line 630
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 630
+			error("wrong type: status = %d", err);
+#line 630
+		}
+#line 630
+	    }
+#line 630
+	}
+#line 630
+
+#line 630
+    }
+#line 630
+    err = nc_close(ncid);
+#line 630
+    IF (err)
+#line 630
+        error("nc_close: %s", nc_strerror(err));
+#line 630
+    print_nok(nok);
+#line 630
+}
+#line 630
+
+void
+#line 631
+test_nc_get_vars_ushort(void)
+#line 631
+{
+#line 631
+    int ncid;
+#line 631
+    int d;
+#line 631
+    int i;
+#line 631
+    int j;
+#line 631
+    int k;
+#line 631
+    int m;
+#line 631
+    int err;
+#line 631
+    int allInExtRange;	/* all values within external range? */
+#line 631
+    int allInIntRange;	/* all values within internal range? */
+#line 631
+    int nels;
+#line 631
+    int nslabs;
+#line 631
+    int nstarts;        /* number of different starts */
+#line 631
+    int nok = 0;      /* count of valid comparisons */
+#line 631
+    size_t start[MAX_RANK];
+#line 631
+    size_t edge[MAX_RANK];
+#line 631
+    size_t index[MAX_RANK];
+#line 631
+    size_t index2[MAX_RANK];
+#line 631
+    size_t mid[MAX_RANK];
+#line 631
+    size_t count[MAX_RANK];
+#line 631
+    size_t sstride[MAX_RANK];
+#line 631
+    ptrdiff_t stride[MAX_RANK];
+#line 631
+    int canConvert;     /* Both text or both numeric */
+#line 631
+    ushort value[MAX_NELS];
+#line 631
+    double expect[MAX_NELS];
+#line 631
+
+#line 631
+#ifdef TEST_PNETCDF
+#line 631
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 631
+#else
+#line 631
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 631
+#endif
+#line 631
+    IF (err)
+#line 631
+        error("nc_open: %s", nc_strerror(err));
+#line 631
+    for (i = 0; i < numVars; i++) {
+#line 631
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+#line 631
+        assert(var_rank[i] <= MAX_RANK);
+#line 631
+        assert(var_nels[i] <= MAX_NELS);
+#line 631
+        for (j = 0; j < var_rank[i]; j++) {
+#line 631
+            start[j] = 0;
+#line 631
+            edge[j] = 1;
+#line 631
+            stride[j] = 1;
+#line 631
+        }
+#line 631
+        err = nc_get_vars_ushort(BAD_ID, i, start, edge, stride, value);
+#line 631
+        IF (err != NC_EBADID)
+#line 631
+            error("bad ncid: status = %d", err);
+#line 631
+        err = nc_get_vars_ushort(ncid, BAD_VARID, start, edge, stride, value);
+#line 631
+        IF (err != NC_ENOTVAR)
+#line 631
+            error("bad var id: status = %d", err);
+#line 631
+        for (j = 0; j < var_rank[i]; j++) {
+#line 631
+            start[j] = var_shape[i][j];
+#line 631
+            err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+#line 631
+	  if(!canConvert) {
+#line 631
+		IF (err != NC_ECHAR)
+#line 631
+               	    error("conversion: status = %d", err);
+#line 631
+	  } else {
+#line 631
+            IF (err != NC_EINVALCOORDS)
+#line 631
+                error("bad index: status = %d", err);
+#line 631
+            start[j] = 0;
+#line 631
+            edge[j] = var_shape[i][j] + 1;
+#line 631
+            err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+#line 631
+            IF (err != NC_EEDGE)
+#line 631
+                error("bad edge: status = %d", err);
+#line 631
+            edge[j] = 1;
+#line 631
+            stride[j] = 0;
+#line 631
+            err = nc_get_vars_ushort(ncid, i, start, edge, stride, value);
+#line 631
+            IF (err != NC_ESTRIDE)
+#line 631
+                error("bad stride: status = %d", err);
+#line 631
+            stride[j] = 1;
+#line 631
+	  }
+#line 631
+        }
+#line 631
+            /* Choose a random point dividing each dim into 2 parts */
+#line 631
+            /* get 2^rank (nslabs) slabs so defined */
+#line 631
+        nslabs = 1;
+#line 631
+        for (j = 0; j < var_rank[i]; j++) {
+#line 631
+            mid[j] = roll( var_shape[i][j] );
+#line 631
+            nslabs *= 2;
+#line 631
+        }
+#line 631
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 631
+            /* choose random stride from 1 to edge */
+#line 631
+        for (k = 0; k < nslabs; k++) {
+#line 631
+            nstarts = 1;
+#line 631
+            for (j = 0; j < var_rank[i]; j++) {
+#line 631
+                if ((k >> j) & 1) {
+#line 631
+                    start[j] = 0;
+#line 631
+                    edge[j] = mid[j];
+#line 631
+                }else{
+#line 631
+                    start[j] = mid[j];
+#line 631
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 631
+                }
+#line 631
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 631
+                nstarts *= stride[j];
+#line 631
+            }
+#line 631
+            for (m = 0; m < nstarts; m++) {
+#line 631
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 631
+                IF (err)
+#line 631
+                    error("error in toMixedBase");
+#line 631
+                nels = 1;
+#line 631
+                for (j = 0; j < var_rank[i]; j++) {
+#line 631
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 631
+                    nels *= count[j];
+#line 631
+                    index[j] += start[j];
+#line 631
+                }
+#line 631
+                        /* Random choice of forward or backward */
+#line 631
+/* TODO
+#line 631
+                if ( roll(2) ) {
+#line 631
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 631
+                        index[j] += (count[j] - 1) * stride[j];
+#line 631
+                        stride[j] = -stride[j];
+#line 631
+                    }
+#line 631
+                }
+#line 631
+*/
+#line 631
+		allInExtRange = allInIntRange = 1;
+#line 631
+		for (j = 0; j < nels; j++) {
+#line 631
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 631
+		    IF (err)
+#line 631
+			error("error in toMixedBase 1");
+#line 631
+		    for (d = 0; d < var_rank[i]; d++)
+#line 631
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 631
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 631
+			NCT_USHORT);
+#line 631
+		    if (inRange3(expect[j],var_type[i],NCT_USHORT)) {
+#line 631
+			allInIntRange = allInIntRange && expect[j] >= ushort_min
+#line 631
+			    && expect[j] <= ushort_max;
+#line 631
+		    } else {
+#line 631
+			allInExtRange = 0;
+#line 631
+		    }
+#line 631
+		}
+#line 631
+                if (var_rank[i] == 0 && i%2 )
+#line 631
+                    err = nc_get_vars_ushort(ncid, i, NULL, NULL, NULL, value);
+#line 631
+                else
+#line 631
+                    err = nc_get_vars_ushort(ncid, i, index, count, stride, value);
+#line 631
+		if (canConvert) {
+#line 631
+		    if (allInExtRange) {
+#line 631
+			if (allInIntRange) {
+#line 631
+			    IF (err)
+#line 631
+				error("%s", nc_strerror(err));
+#line 631
+			} else {
+#line 631
+			    IF (err != NC_ERANGE)
+#line 631
+				error("Range error: status = %d", err);
+#line 631
+			}
+#line 631
+		    } else {
+#line 631
+			IF (err != 0 && err != NC_ERANGE)
+#line 631
+			    error("OK or Range error: status = %d", err);
+#line 631
+		    }
+#line 631
+		    for (j = 0; j < nels; j++) {
+#line 631
+			if (inRange3(expect[j],var_type[i],NCT_USHORT)
+#line 631
+				&& expect[j] >= ushort_min && expect[j] <= ushort_max) {
+#line 631
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 631
+				    NCT_USHORT)){
+#line 631
+				error("value read not that expected");
+#line 631
+				if (verbose) {
+#line 631
+				    error("\n");
+#line 631
+				    error("varid: %d, ", i);
+#line 631
+				    error("var_name: %s, ", var_name[i]);
+#line 631
+				    error("element number: %d ", j);
+#line 631
+                                    error("expect: %g, ", expect[j]);
+#line 631
+				    error("got: %g", (double) value[j]);
+#line 631
+				}
+#line 631
+			    } else {
+#line 631
+				nok++;
+#line 631
+			    }
+#line 631
+			}
+#line 631
+		    }
+#line 631
+		} else {
+#line 631
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 631
+			error("wrong type: status = %d", err);
+#line 631
+		}
+#line 631
+	    }
+#line 631
+	}
+#line 631
+
+#line 631
+    }
+#line 631
+    err = nc_close(ncid);
+#line 631
+    IF (err)
+#line 631
+        error("nc_close: %s", nc_strerror(err));
+#line 631
+    print_nok(nok);
+#line 631
+}
+#line 631
+
+void
+#line 632
+test_nc_get_vars_uint(void)
+#line 632
+{
+#line 632
+    int ncid;
+#line 632
+    int d;
+#line 632
+    int i;
+#line 632
+    int j;
+#line 632
+    int k;
+#line 632
+    int m;
+#line 632
+    int err;
+#line 632
+    int allInExtRange;	/* all values within external range? */
+#line 632
+    int allInIntRange;	/* all values within internal range? */
+#line 632
+    int nels;
+#line 632
+    int nslabs;
+#line 632
+    int nstarts;        /* number of different starts */
+#line 632
+    int nok = 0;      /* count of valid comparisons */
+#line 632
+    size_t start[MAX_RANK];
+#line 632
+    size_t edge[MAX_RANK];
+#line 632
+    size_t index[MAX_RANK];
+#line 632
+    size_t index2[MAX_RANK];
+#line 632
+    size_t mid[MAX_RANK];
+#line 632
+    size_t count[MAX_RANK];
+#line 632
+    size_t sstride[MAX_RANK];
+#line 632
+    ptrdiff_t stride[MAX_RANK];
+#line 632
+    int canConvert;     /* Both text or both numeric */
+#line 632
+    uint value[MAX_NELS];
+#line 632
+    double expect[MAX_NELS];
+#line 632
+
+#line 632
+#ifdef TEST_PNETCDF
+#line 632
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 632
+#else
+#line 632
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 632
+#endif
+#line 632
+    IF (err)
+#line 632
+        error("nc_open: %s", nc_strerror(err));
+#line 632
+    for (i = 0; i < numVars; i++) {
+#line 632
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+#line 632
+        assert(var_rank[i] <= MAX_RANK);
+#line 632
+        assert(var_nels[i] <= MAX_NELS);
+#line 632
+        for (j = 0; j < var_rank[i]; j++) {
+#line 632
+            start[j] = 0;
+#line 632
+            edge[j] = 1;
+#line 632
+            stride[j] = 1;
+#line 632
+        }
+#line 632
+        err = nc_get_vars_uint(BAD_ID, i, start, edge, stride, value);
+#line 632
+        IF (err != NC_EBADID)
+#line 632
+            error("bad ncid: status = %d", err);
+#line 632
+        err = nc_get_vars_uint(ncid, BAD_VARID, start, edge, stride, value);
+#line 632
+        IF (err != NC_ENOTVAR)
+#line 632
+            error("bad var id: status = %d", err);
+#line 632
+        for (j = 0; j < var_rank[i]; j++) {
+#line 632
+            start[j] = var_shape[i][j];
+#line 632
+            err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+#line 632
+	  if(!canConvert) {
+#line 632
+		IF (err != NC_ECHAR)
+#line 632
+               	    error("conversion: status = %d", err);
+#line 632
+	  } else {
+#line 632
+            IF (err != NC_EINVALCOORDS)
+#line 632
+                error("bad index: status = %d", err);
+#line 632
+            start[j] = 0;
+#line 632
+            edge[j] = var_shape[i][j] + 1;
+#line 632
+            err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+#line 632
+            IF (err != NC_EEDGE)
+#line 632
+                error("bad edge: status = %d", err);
+#line 632
+            edge[j] = 1;
+#line 632
+            stride[j] = 0;
+#line 632
+            err = nc_get_vars_uint(ncid, i, start, edge, stride, value);
+#line 632
+            IF (err != NC_ESTRIDE)
+#line 632
+                error("bad stride: status = %d", err);
+#line 632
+            stride[j] = 1;
+#line 632
+	  }
+#line 632
+        }
+#line 632
+            /* Choose a random point dividing each dim into 2 parts */
+#line 632
+            /* get 2^rank (nslabs) slabs so defined */
+#line 632
+        nslabs = 1;
+#line 632
+        for (j = 0; j < var_rank[i]; j++) {
+#line 632
+            mid[j] = roll( var_shape[i][j] );
+#line 632
+            nslabs *= 2;
+#line 632
+        }
+#line 632
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 632
+            /* choose random stride from 1 to edge */
+#line 632
+        for (k = 0; k < nslabs; k++) {
+#line 632
+            nstarts = 1;
+#line 632
+            for (j = 0; j < var_rank[i]; j++) {
+#line 632
+                if ((k >> j) & 1) {
+#line 632
+                    start[j] = 0;
+#line 632
+                    edge[j] = mid[j];
+#line 632
+                }else{
+#line 632
+                    start[j] = mid[j];
+#line 632
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 632
+                }
+#line 632
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 632
+                nstarts *= stride[j];
+#line 632
+            }
+#line 632
+            for (m = 0; m < nstarts; m++) {
+#line 632
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 632
+                IF (err)
+#line 632
+                    error("error in toMixedBase");
+#line 632
+                nels = 1;
+#line 632
+                for (j = 0; j < var_rank[i]; j++) {
+#line 632
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 632
+                    nels *= count[j];
+#line 632
+                    index[j] += start[j];
+#line 632
+                }
+#line 632
+                        /* Random choice of forward or backward */
+#line 632
+/* TODO
+#line 632
+                if ( roll(2) ) {
+#line 632
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 632
+                        index[j] += (count[j] - 1) * stride[j];
+#line 632
+                        stride[j] = -stride[j];
+#line 632
+                    }
+#line 632
+                }
+#line 632
+*/
+#line 632
+		allInExtRange = allInIntRange = 1;
+#line 632
+		for (j = 0; j < nels; j++) {
+#line 632
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 632
+		    IF (err)
+#line 632
+			error("error in toMixedBase 1");
+#line 632
+		    for (d = 0; d < var_rank[i]; d++)
+#line 632
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 632
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 632
+			NCT_UINT);
+#line 632
+		    if (inRange3(expect[j],var_type[i],NCT_UINT)) {
+#line 632
+			allInIntRange = allInIntRange && expect[j] >= uint_min
+#line 632
+			    && expect[j] <= uint_max;
+#line 632
+		    } else {
+#line 632
+			allInExtRange = 0;
+#line 632
+		    }
+#line 632
+		}
+#line 632
+                if (var_rank[i] == 0 && i%2 )
+#line 632
+                    err = nc_get_vars_uint(ncid, i, NULL, NULL, NULL, value);
+#line 632
+                else
+#line 632
+                    err = nc_get_vars_uint(ncid, i, index, count, stride, value);
+#line 632
+		if (canConvert) {
+#line 632
+		    if (allInExtRange) {
+#line 632
+			if (allInIntRange) {
+#line 632
+			    IF (err)
+#line 632
+				error("%s", nc_strerror(err));
+#line 632
+			} else {
+#line 632
+			    IF (err != NC_ERANGE)
+#line 632
+				error("Range error: status = %d", err);
+#line 632
+			}
+#line 632
+		    } else {
+#line 632
+			IF (err != 0 && err != NC_ERANGE)
+#line 632
+			    error("OK or Range error: status = %d", err);
+#line 632
+		    }
+#line 632
+		    for (j = 0; j < nels; j++) {
+#line 632
+			if (inRange3(expect[j],var_type[i],NCT_UINT)
+#line 632
+				&& expect[j] >= uint_min && expect[j] <= uint_max) {
+#line 632
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 632
+				    NCT_UINT)){
+#line 632
+				error("value read not that expected");
+#line 632
+				if (verbose) {
+#line 632
+				    error("\n");
+#line 632
+				    error("varid: %d, ", i);
+#line 632
+				    error("var_name: %s, ", var_name[i]);
+#line 632
+				    error("element number: %d ", j);
+#line 632
+                                    error("expect: %g, ", expect[j]);
+#line 632
+				    error("got: %g", (double) value[j]);
+#line 632
+				}
+#line 632
+			    } else {
+#line 632
+				nok++;
+#line 632
+			    }
+#line 632
+			}
+#line 632
+		    }
+#line 632
+		} else {
+#line 632
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 632
+			error("wrong type: status = %d", err);
+#line 632
+		}
+#line 632
+	    }
+#line 632
+	}
+#line 632
+
+#line 632
+    }
+#line 632
+    err = nc_close(ncid);
+#line 632
+    IF (err)
+#line 632
+        error("nc_close: %s", nc_strerror(err));
+#line 632
+    print_nok(nok);
+#line 632
+}
+#line 632
+
+void
+#line 633
+test_nc_get_vars_longlong(void)
+#line 633
+{
+#line 633
+    int ncid;
+#line 633
+    int d;
+#line 633
+    int i;
+#line 633
+    int j;
+#line 633
+    int k;
+#line 633
+    int m;
+#line 633
+    int err;
+#line 633
+    int allInExtRange;	/* all values within external range? */
+#line 633
+    int allInIntRange;	/* all values within internal range? */
+#line 633
+    int nels;
+#line 633
+    int nslabs;
+#line 633
+    int nstarts;        /* number of different starts */
+#line 633
+    int nok = 0;      /* count of valid comparisons */
+#line 633
+    size_t start[MAX_RANK];
+#line 633
+    size_t edge[MAX_RANK];
+#line 633
+    size_t index[MAX_RANK];
+#line 633
+    size_t index2[MAX_RANK];
+#line 633
+    size_t mid[MAX_RANK];
+#line 633
+    size_t count[MAX_RANK];
+#line 633
+    size_t sstride[MAX_RANK];
+#line 633
+    ptrdiff_t stride[MAX_RANK];
+#line 633
+    int canConvert;     /* Both text or both numeric */
+#line 633
+    longlong value[MAX_NELS];
+#line 633
+    double expect[MAX_NELS];
+#line 633
+
+#line 633
+#ifdef TEST_PNETCDF
+#line 633
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 633
+#else
+#line 633
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 633
+#endif
+#line 633
+    IF (err)
+#line 633
+        error("nc_open: %s", nc_strerror(err));
+#line 633
+    for (i = 0; i < numVars; i++) {
+#line 633
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+#line 633
+        assert(var_rank[i] <= MAX_RANK);
+#line 633
+        assert(var_nels[i] <= MAX_NELS);
+#line 633
+        for (j = 0; j < var_rank[i]; j++) {
+#line 633
+            start[j] = 0;
+#line 633
+            edge[j] = 1;
+#line 633
+            stride[j] = 1;
+#line 633
+        }
+#line 633
+        err = nc_get_vars_longlong(BAD_ID, i, start, edge, stride, value);
+#line 633
+        IF (err != NC_EBADID)
+#line 633
+            error("bad ncid: status = %d", err);
+#line 633
+        err = nc_get_vars_longlong(ncid, BAD_VARID, start, edge, stride, value);
+#line 633
+        IF (err != NC_ENOTVAR)
+#line 633
+            error("bad var id: status = %d", err);
+#line 633
+        for (j = 0; j < var_rank[i]; j++) {
+#line 633
+            start[j] = var_shape[i][j];
+#line 633
+            err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+#line 633
+	  if(!canConvert) {
+#line 633
+		IF (err != NC_ECHAR)
+#line 633
+               	    error("conversion: status = %d", err);
+#line 633
+	  } else {
+#line 633
+            IF (err != NC_EINVALCOORDS)
+#line 633
+                error("bad index: status = %d", err);
+#line 633
+            start[j] = 0;
+#line 633
+            edge[j] = var_shape[i][j] + 1;
+#line 633
+            err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+#line 633
+            IF (err != NC_EEDGE)
+#line 633
+                error("bad edge: status = %d", err);
+#line 633
+            edge[j] = 1;
+#line 633
+            stride[j] = 0;
+#line 633
+            err = nc_get_vars_longlong(ncid, i, start, edge, stride, value);
+#line 633
+            IF (err != NC_ESTRIDE)
+#line 633
+                error("bad stride: status = %d", err);
+#line 633
+            stride[j] = 1;
+#line 633
+	  }
+#line 633
+        }
+#line 633
+            /* Choose a random point dividing each dim into 2 parts */
+#line 633
+            /* get 2^rank (nslabs) slabs so defined */
+#line 633
+        nslabs = 1;
+#line 633
+        for (j = 0; j < var_rank[i]; j++) {
+#line 633
+            mid[j] = roll( var_shape[i][j] );
+#line 633
+            nslabs *= 2;
+#line 633
+        }
+#line 633
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 633
+            /* choose random stride from 1 to edge */
+#line 633
+        for (k = 0; k < nslabs; k++) {
+#line 633
+            nstarts = 1;
+#line 633
+            for (j = 0; j < var_rank[i]; j++) {
+#line 633
+                if ((k >> j) & 1) {
+#line 633
+                    start[j] = 0;
+#line 633
+                    edge[j] = mid[j];
+#line 633
+                }else{
+#line 633
+                    start[j] = mid[j];
+#line 633
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 633
+                }
+#line 633
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 633
+                nstarts *= stride[j];
+#line 633
+            }
+#line 633
+            for (m = 0; m < nstarts; m++) {
+#line 633
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 633
+                IF (err)
+#line 633
+                    error("error in toMixedBase");
+#line 633
+                nels = 1;
+#line 633
+                for (j = 0; j < var_rank[i]; j++) {
+#line 633
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 633
+                    nels *= count[j];
+#line 633
+                    index[j] += start[j];
+#line 633
+                }
+#line 633
+                        /* Random choice of forward or backward */
+#line 633
+/* TODO
+#line 633
+                if ( roll(2) ) {
+#line 633
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 633
+                        index[j] += (count[j] - 1) * stride[j];
+#line 633
+                        stride[j] = -stride[j];
+#line 633
+                    }
+#line 633
+                }
+#line 633
+*/
+#line 633
+		allInExtRange = allInIntRange = 1;
+#line 633
+		for (j = 0; j < nels; j++) {
+#line 633
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 633
+		    IF (err)
+#line 633
+			error("error in toMixedBase 1");
+#line 633
+		    for (d = 0; d < var_rank[i]; d++)
+#line 633
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 633
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 633
+			NCT_LONGLONG);
+#line 633
+		    if (inRange3(expect[j],var_type[i],NCT_LONGLONG)) {
+#line 633
+			allInIntRange = allInIntRange && expect[j] >= longlong_min
+#line 633
+			    && expect[j] <= longlong_max;
+#line 633
+		    } else {
+#line 633
+			allInExtRange = 0;
+#line 633
+		    }
+#line 633
+		}
+#line 633
+                if (var_rank[i] == 0 && i%2 )
+#line 633
+                    err = nc_get_vars_longlong(ncid, i, NULL, NULL, NULL, value);
+#line 633
+                else
+#line 633
+                    err = nc_get_vars_longlong(ncid, i, index, count, stride, value);
+#line 633
+		if (canConvert) {
+#line 633
+		    if (allInExtRange) {
+#line 633
+			if (allInIntRange) {
+#line 633
+			    IF (err)
+#line 633
+				error("%s", nc_strerror(err));
+#line 633
+			} else {
+#line 633
+			    IF (err != NC_ERANGE)
+#line 633
+				error("Range error: status = %d", err);
+#line 633
+			}
+#line 633
+		    } else {
+#line 633
+			IF (err != 0 && err != NC_ERANGE)
+#line 633
+			    error("OK or Range error: status = %d", err);
+#line 633
+		    }
+#line 633
+		    for (j = 0; j < nels; j++) {
+#line 633
+			if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+#line 633
+				&& expect[j] >= longlong_min && expect[j] <= longlong_max) {
+#line 633
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 633
+				    NCT_LONGLONG)){
+#line 633
+				error("value read not that expected");
+#line 633
+				if (verbose) {
+#line 633
+				    error("\n");
+#line 633
+				    error("varid: %d, ", i);
+#line 633
+				    error("var_name: %s, ", var_name[i]);
+#line 633
+				    error("element number: %d ", j);
+#line 633
+                                    error("expect: %g, ", expect[j]);
+#line 633
+				    error("got: %g", (double) value[j]);
+#line 633
+				}
+#line 633
+			    } else {
+#line 633
+				nok++;
+#line 633
+			    }
+#line 633
+			}
+#line 633
+		    }
+#line 633
+		} else {
+#line 633
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 633
+			error("wrong type: status = %d", err);
+#line 633
+		}
+#line 633
+	    }
+#line 633
+	}
+#line 633
+
+#line 633
+    }
+#line 633
+    err = nc_close(ncid);
+#line 633
+    IF (err)
+#line 633
+        error("nc_close: %s", nc_strerror(err));
+#line 633
+    print_nok(nok);
+#line 633
+}
+#line 633
+
+void
+#line 634
+test_nc_get_vars_ulonglong(void)
+#line 634
+{
+#line 634
+    int ncid;
+#line 634
+    int d;
+#line 634
+    int i;
+#line 634
+    int j;
+#line 634
+    int k;
+#line 634
+    int m;
+#line 634
+    int err;
+#line 634
+    int allInExtRange;	/* all values within external range? */
+#line 634
+    int allInIntRange;	/* all values within internal range? */
+#line 634
+    int nels;
+#line 634
+    int nslabs;
+#line 634
+    int nstarts;        /* number of different starts */
+#line 634
+    int nok = 0;      /* count of valid comparisons */
+#line 634
+    size_t start[MAX_RANK];
+#line 634
+    size_t edge[MAX_RANK];
+#line 634
+    size_t index[MAX_RANK];
+#line 634
+    size_t index2[MAX_RANK];
+#line 634
+    size_t mid[MAX_RANK];
+#line 634
+    size_t count[MAX_RANK];
+#line 634
+    size_t sstride[MAX_RANK];
+#line 634
+    ptrdiff_t stride[MAX_RANK];
+#line 634
+    int canConvert;     /* Both text or both numeric */
+#line 634
+    ulonglong value[MAX_NELS];
+#line 634
+    double expect[MAX_NELS];
+#line 634
+
+#line 634
+#ifdef TEST_PNETCDF
+#line 634
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 634
+#else
+#line 634
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 634
+#endif
+#line 634
+    IF (err)
+#line 634
+        error("nc_open: %s", nc_strerror(err));
+#line 634
+    for (i = 0; i < numVars; i++) {
+#line 634
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+#line 634
+        assert(var_rank[i] <= MAX_RANK);
+#line 634
+        assert(var_nels[i] <= MAX_NELS);
+#line 634
+        for (j = 0; j < var_rank[i]; j++) {
+#line 634
+            start[j] = 0;
+#line 634
+            edge[j] = 1;
+#line 634
+            stride[j] = 1;
+#line 634
+        }
+#line 634
+        err = nc_get_vars_ulonglong(BAD_ID, i, start, edge, stride, value);
+#line 634
+        IF (err != NC_EBADID)
+#line 634
+            error("bad ncid: status = %d", err);
+#line 634
+        err = nc_get_vars_ulonglong(ncid, BAD_VARID, start, edge, stride, value);
+#line 634
+        IF (err != NC_ENOTVAR)
+#line 634
+            error("bad var id: status = %d", err);
+#line 634
+        for (j = 0; j < var_rank[i]; j++) {
+#line 634
+            start[j] = var_shape[i][j];
+#line 634
+            err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+#line 634
+	  if(!canConvert) {
+#line 634
+		IF (err != NC_ECHAR)
+#line 634
+               	    error("conversion: status = %d", err);
+#line 634
+	  } else {
+#line 634
+            IF (err != NC_EINVALCOORDS)
+#line 634
+                error("bad index: status = %d", err);
+#line 634
+            start[j] = 0;
+#line 634
+            edge[j] = var_shape[i][j] + 1;
+#line 634
+            err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+#line 634
+            IF (err != NC_EEDGE)
+#line 634
+                error("bad edge: status = %d", err);
+#line 634
+            edge[j] = 1;
+#line 634
+            stride[j] = 0;
+#line 634
+            err = nc_get_vars_ulonglong(ncid, i, start, edge, stride, value);
+#line 634
+            IF (err != NC_ESTRIDE)
+#line 634
+                error("bad stride: status = %d", err);
+#line 634
+            stride[j] = 1;
+#line 634
+	  }
+#line 634
+        }
+#line 634
+            /* Choose a random point dividing each dim into 2 parts */
+#line 634
+            /* get 2^rank (nslabs) slabs so defined */
+#line 634
+        nslabs = 1;
+#line 634
+        for (j = 0; j < var_rank[i]; j++) {
+#line 634
+            mid[j] = roll( var_shape[i][j] );
+#line 634
+            nslabs *= 2;
+#line 634
+        }
+#line 634
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 634
+            /* choose random stride from 1 to edge */
+#line 634
+        for (k = 0; k < nslabs; k++) {
+#line 634
+            nstarts = 1;
+#line 634
+            for (j = 0; j < var_rank[i]; j++) {
+#line 634
+                if ((k >> j) & 1) {
+#line 634
+                    start[j] = 0;
+#line 634
+                    edge[j] = mid[j];
+#line 634
+                }else{
+#line 634
+                    start[j] = mid[j];
+#line 634
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 634
+                }
+#line 634
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 634
+                nstarts *= stride[j];
+#line 634
+            }
+#line 634
+            for (m = 0; m < nstarts; m++) {
+#line 634
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 634
+                IF (err)
+#line 634
+                    error("error in toMixedBase");
+#line 634
+                nels = 1;
+#line 634
+                for (j = 0; j < var_rank[i]; j++) {
+#line 634
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 634
+                    nels *= count[j];
+#line 634
+                    index[j] += start[j];
+#line 634
+                }
+#line 634
+                        /* Random choice of forward or backward */
+#line 634
+/* TODO
+#line 634
+                if ( roll(2) ) {
+#line 634
+                    for (j = 0; j < var_rank[i]; j++) {
+#line 634
+                        index[j] += (count[j] - 1) * stride[j];
+#line 634
+                        stride[j] = -stride[j];
+#line 634
+                    }
+#line 634
+                }
+#line 634
+*/
+#line 634
+		allInExtRange = allInIntRange = 1;
+#line 634
+		for (j = 0; j < nels; j++) {
+#line 634
+		    err = toMixedBase(j, var_rank[i], count, index2);
+#line 634
+		    IF (err)
+#line 634
+			error("error in toMixedBase 1");
+#line 634
+		    for (d = 0; d < var_rank[i]; d++)
+#line 634
+			index2[d] = index[d] + index2[d] * stride[d];
+#line 634
+		    expect[j] = hash4(var_type[i], var_rank[i], index2, 
+#line 634
+			NCT_ULONGLONG);
+#line 634
+		    if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)) {
+#line 634
+			allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+#line 634
+			    && expect[j] <= ulonglong_max;
+#line 634
+		    } else {
+#line 634
+			allInExtRange = 0;
+#line 634
+		    }
+#line 634
+		}
+#line 634
+                if (var_rank[i] == 0 && i%2 )
+#line 634
+                    err = nc_get_vars_ulonglong(ncid, i, NULL, NULL, NULL, value);
+#line 634
+                else
+#line 634
+                    err = nc_get_vars_ulonglong(ncid, i, index, count, stride, value);
+#line 634
+		if (canConvert) {
+#line 634
+		    if (allInExtRange) {
+#line 634
+			if (allInIntRange) {
+#line 634
+			    IF (err)
+#line 634
+				error("%s", nc_strerror(err));
+#line 634
+			} else {
+#line 634
+			    IF (err != NC_ERANGE)
+#line 634
+				error("Range error: status = %d", err);
+#line 634
+			}
+#line 634
+		    } else {
+#line 634
+			IF (err != 0 && err != NC_ERANGE)
+#line 634
+			    error("OK or Range error: status = %d", err);
+#line 634
+		    }
+#line 634
+		    for (j = 0; j < nels; j++) {
+#line 634
+			if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+#line 634
+				&& expect[j] >= ulonglong_min && expect[j] <= ulonglong_max) {
+#line 634
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 634
+				    NCT_ULONGLONG)){
+#line 634
+				error("value read not that expected");
+#line 634
+				if (verbose) {
+#line 634
+				    error("\n");
+#line 634
+				    error("varid: %d, ", i);
+#line 634
+				    error("var_name: %s, ", var_name[i]);
+#line 634
+				    error("element number: %d ", j);
+#line 634
+                                    error("expect: %g, ", expect[j]);
+#line 634
+				    error("got: %g", (double) value[j]);
+#line 634
+				}
+#line 634
+			    } else {
+#line 634
+				nok++;
+#line 634
+			    }
+#line 634
+			}
+#line 634
+		    }
+#line 634
+		} else {
+#line 634
+		    IF (nels > 0 && err != NC_ECHAR)
+#line 634
+			error("wrong type: status = %d", err);
+#line 634
+		}
+#line 634
+	    }
+#line 634
+	}
+#line 634
+
+#line 634
+    }
+#line 634
+    err = nc_close(ncid);
+#line 634
+    IF (err)
+#line 634
+        error("nc_close: %s", nc_strerror(err));
+#line 634
+    print_nok(nok);
+#line 634
+}
+#line 634
+
+
+
+#line 828
+
+void
+#line 829
+test_nc_get_varm_text(void)
+#line 829
+{
+#line 829
+    int ncid;
+#line 829
+    int d;
+#line 829
+    int i;
+#line 829
+    int j;
+#line 829
+    int k;
+#line 829
+    int m;
+#line 829
+    int err;
+#line 829
+    int allInExtRange;	/* all values within external range? */
+#line 829
+    int allInIntRange;	/* all values within internal range? */
+#line 829
+    int nels;
+#line 829
+    int nslabs;
+#line 829
+    int nstarts;        /* number of different starts */
+#line 829
+    int nok = 0;      /* count of valid comparisons */
+#line 829
+    size_t start[MAX_RANK];
+#line 829
+    size_t edge[MAX_RANK];
+#line 829
+    size_t index[MAX_RANK];
+#line 829
+    size_t index2[MAX_RANK];
+#line 829
+    size_t mid[MAX_RANK];
+#line 829
+    size_t count[MAX_RANK];
+#line 829
+    size_t sstride[MAX_RANK];
+#line 829
+    ptrdiff_t stride[MAX_RANK];
+#line 829
+    ptrdiff_t imap[MAX_RANK];
+#line 829
+    int canConvert;     /* Both text or both numeric */
+#line 829
+    text value[MAX_NELS];
+#line 829
+    double expect[MAX_NELS];
+#line 829
+
+#line 829
+#ifdef TEST_PNETCDF
+#line 829
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 829
+#else
+#line 829
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 829
+#endif
+#line 829
+    IF (err)
+#line 829
+        error("nc_open: %s", nc_strerror(err));
+#line 829
+    for (i = 0; i < numVars; i++) {
+#line 829
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+#line 829
+        assert(var_rank[i] <= MAX_RANK);
+#line 829
+        assert(var_nels[i] <= MAX_NELS);
+#line 829
+        for (j = 0; j < var_rank[i]; j++) {
+#line 829
+            start[j] = 0;
+#line 829
+            edge[j] = 1;
+#line 829
+            stride[j] = 1;
+#line 829
+            imap[j] = 1;
+#line 829
+        }
+#line 829
+        err = nc_get_varm_text(BAD_ID, i, start, edge, stride, imap, value);
+#line 829
+        IF (err != NC_EBADID)
+#line 829
+            error("bad ncid: status = %d", err);
+#line 829
+        err = nc_get_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 829
+        IF (err != NC_ENOTVAR)
+#line 829
+            error("bad var id: status = %d", err);
+#line 829
+        for (j = 0; j < var_rank[i]; j++) {
+#line 829
+            start[j] = var_shape[i][j];
+#line 829
+            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+#line 829
+	  if(!canConvert) {
+#line 829
+		IF (err != NC_ECHAR)
+#line 829
+               	    error("conversion: status = %d", err);
+#line 829
+	  } else {
+#line 829
+	    IF (err != NC_EINVALCOORDS)
+#line 829
+                error("bad index: status = %d", err);
+#line 829
+            start[j] = 0;
+#line 829
+            edge[j] = var_shape[i][j] + 1;
+#line 829
+            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+#line 829
+            IF (err != NC_EEDGE)
+#line 829
+                error("bad edge: status = %d", err);
+#line 829
+            edge[j] = 1;
+#line 829
+            stride[j] = 0;
+#line 829
+            err = nc_get_varm_text(ncid, i, start, edge, stride, imap, value);
+#line 829
+            IF (err != NC_ESTRIDE)
+#line 829
+                error("bad stride: status = %d", err);
+#line 829
+            stride[j] = 1;
+#line 829
+           }
+#line 829
+        }
+#line 829
+            /* Choose a random point dividing each dim into 2 parts */
+#line 829
+            /* get 2^rank (nslabs) slabs so defined */
+#line 829
+        nslabs = 1;
+#line 829
+        for (j = 0; j < var_rank[i]; j++) {
+#line 829
+            mid[j] = roll( var_shape[i][j] );
+#line 829
+            nslabs *= 2;
+#line 829
+        }
+#line 829
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 829
+            /* choose random stride from 1 to edge */
+#line 829
+        for (k = 0; k < nslabs; k++) {
+#line 829
+            nstarts = 1;
+#line 829
+            for (j = 0; j < var_rank[i]; j++) {
+#line 829
+                if ((k >> j) & 1) {
+#line 829
+                    start[j] = 0;
+#line 829
+                    edge[j] = mid[j];
+#line 829
+                }else{
+#line 829
+                    start[j] = mid[j];
+#line 829
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 829
+                }
+#line 829
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 829
+                nstarts *= stride[j];
+#line 829
+            }
+#line 829
+            for (m = 0; m < nstarts; m++) {
+#line 829
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 829
+                IF (err)
+#line 829
+                    error("error in toMixedBase");
+#line 829
+                nels = 1;
+#line 829
+                for (j = 0; j < var_rank[i]; j++) {
+#line 829
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 829
+                    nels *= count[j];
+#line 829
+                    index[j] += start[j];
+#line 829
+                }
+#line 829
+		    /* Random choice of forward or backward */
+#line 829
+/* TODO
+#line 829
+		if ( roll(2) ) {
+#line 829
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 829
+			index[j] += (count[j] - 1) * stride[j];
+#line 829
+			stride[j] = -stride[j];
+#line 829
+		    }
+#line 829
+		}
+#line 829
+ */
+#line 829
+		if (var_rank[i] > 0) {
+#line 829
+		    j = var_rank[i] - 1;
+#line 829
+		    imap[j] = 1;
+#line 829
+		    for (; j > 0; j--)
+#line 829
+			imap[j-1] = imap[j] * count[j];
+#line 829
+		}
+#line 829
+                allInExtRange = allInIntRange = 1;
+#line 829
+                for (j = 0; j < nels; j++) {
+#line 829
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 829
+                    IF (err)
+#line 829
+                        error("error in toMixedBase 1");
+#line 829
+                    for (d = 0; d < var_rank[i]; d++)
+#line 829
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 829
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 829
+                        NCT_TEXT);
+#line 829
+                    if (inRange3(expect[j],var_type[i],NCT_TEXT)) {
+#line 829
+                        allInIntRange = allInIntRange && expect[j] >= text_min
+#line 829
+                            && expect[j] <= text_max;
+#line 829
+                    } else {
+#line 829
+                        allInExtRange = 0;
+#line 829
+                    }
+#line 829
+                }
+#line 829
+                if (var_rank[i] == 0 && i%2 )
+#line 829
+                    err = nc_get_varm_text(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 829
+                else
+#line 829
+                    err = nc_get_varm_text(ncid,i,index,count,stride,imap,value);
+#line 829
+                if (canConvert) {
+#line 829
+                    if (allInExtRange) {
+#line 829
+                        if (allInIntRange) {
+#line 829
+                            IF (err)
+#line 829
+                                error("%s", nc_strerror(err));
+#line 829
+                        } else {
+#line 829
+                            IF (err != NC_ERANGE)
+#line 829
+                                error("Range error: status = %d", err);
+#line 829
+                        }
+#line 829
+                    } else {
+#line 829
+                        IF (err != 0 && err != NC_ERANGE)
+#line 829
+                            error("OK or Range error: status = %d", err);
+#line 829
+                    }
+#line 829
+                    for (j = 0; j < nels; j++) {
+#line 829
+                        if (inRange3(expect[j],var_type[i],NCT_TEXT)
+#line 829
+                                && expect[j] >= text_min 
+#line 829
+				&& expect[j] <= text_max) {
+#line 829
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 829
+				    NCT_TEXT)){
+#line 829
+                                error("value read not that expected");
+#line 829
+                                if (verbose) {
+#line 829
+                                    error("\n");
+#line 829
+                                    error("varid: %d, ", i);
+#line 829
+                                    error("var_name: %s, ", var_name[i]);
+#line 829
+                                    error("element number: %d ", j);
+#line 829
+                                    error("expect: %g, ", expect[j]);
+#line 829
+                                    error("got: %g", (double) value[j]);
+#line 829
+                                }
+#line 829
+                            } else {
+#line 829
+                                nok++;
+#line 829
+                            }
+#line 829
+                        }
+#line 829
+                    }
+#line 829
+                } else {
+#line 829
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 829
+                        error("wrong type: status = %d", err);
+#line 829
+                }
+#line 829
+            }
+#line 829
+        }
+#line 829
+    }
+#line 829
+    err = nc_close(ncid);
+#line 829
+    IF (err)
+#line 829
+        error("nc_close: %s", nc_strerror(err));
+#line 829
+    print_nok(nok);
+#line 829
+}
+#line 829
+
+void
+#line 830
+test_nc_get_varm_uchar(void)
+#line 830
+{
+#line 830
+    int ncid;
+#line 830
+    int d;
+#line 830
+    int i;
+#line 830
+    int j;
+#line 830
+    int k;
+#line 830
+    int m;
+#line 830
+    int err;
+#line 830
+    int allInExtRange;	/* all values within external range? */
+#line 830
+    int allInIntRange;	/* all values within internal range? */
+#line 830
+    int nels;
+#line 830
+    int nslabs;
+#line 830
+    int nstarts;        /* number of different starts */
+#line 830
+    int nok = 0;      /* count of valid comparisons */
+#line 830
+    size_t start[MAX_RANK];
+#line 830
+    size_t edge[MAX_RANK];
+#line 830
+    size_t index[MAX_RANK];
+#line 830
+    size_t index2[MAX_RANK];
+#line 830
+    size_t mid[MAX_RANK];
+#line 830
+    size_t count[MAX_RANK];
+#line 830
+    size_t sstride[MAX_RANK];
+#line 830
+    ptrdiff_t stride[MAX_RANK];
+#line 830
+    ptrdiff_t imap[MAX_RANK];
+#line 830
+    int canConvert;     /* Both text or both numeric */
+#line 830
+    uchar value[MAX_NELS];
+#line 830
+    double expect[MAX_NELS];
+#line 830
+
+#line 830
+#ifdef TEST_PNETCDF
+#line 830
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 830
+#else
+#line 830
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 830
+#endif
+#line 830
+    IF (err)
+#line 830
+        error("nc_open: %s", nc_strerror(err));
+#line 830
+    for (i = 0; i < numVars; i++) {
+#line 830
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+#line 830
+        assert(var_rank[i] <= MAX_RANK);
+#line 830
+        assert(var_nels[i] <= MAX_NELS);
+#line 830
+        for (j = 0; j < var_rank[i]; j++) {
+#line 830
+            start[j] = 0;
+#line 830
+            edge[j] = 1;
+#line 830
+            stride[j] = 1;
+#line 830
+            imap[j] = 1;
+#line 830
+        }
+#line 830
+        err = nc_get_varm_uchar(BAD_ID, i, start, edge, stride, imap, value);
+#line 830
+        IF (err != NC_EBADID)
+#line 830
+            error("bad ncid: status = %d", err);
+#line 830
+        err = nc_get_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 830
+        IF (err != NC_ENOTVAR)
+#line 830
+            error("bad var id: status = %d", err);
+#line 830
+        for (j = 0; j < var_rank[i]; j++) {
+#line 830
+            start[j] = var_shape[i][j];
+#line 830
+            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+#line 830
+	  if(!canConvert) {
+#line 830
+		IF (err != NC_ECHAR)
+#line 830
+               	    error("conversion: status = %d", err);
+#line 830
+	  } else {
+#line 830
+	    IF (err != NC_EINVALCOORDS)
+#line 830
+                error("bad index: status = %d", err);
+#line 830
+            start[j] = 0;
+#line 830
+            edge[j] = var_shape[i][j] + 1;
+#line 830
+            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+#line 830
+            IF (err != NC_EEDGE)
+#line 830
+                error("bad edge: status = %d", err);
+#line 830
+            edge[j] = 1;
+#line 830
+            stride[j] = 0;
+#line 830
+            err = nc_get_varm_uchar(ncid, i, start, edge, stride, imap, value);
+#line 830
+            IF (err != NC_ESTRIDE)
+#line 830
+                error("bad stride: status = %d", err);
+#line 830
+            stride[j] = 1;
+#line 830
+           }
+#line 830
+        }
+#line 830
+            /* Choose a random point dividing each dim into 2 parts */
+#line 830
+            /* get 2^rank (nslabs) slabs so defined */
+#line 830
+        nslabs = 1;
+#line 830
+        for (j = 0; j < var_rank[i]; j++) {
+#line 830
+            mid[j] = roll( var_shape[i][j] );
+#line 830
+            nslabs *= 2;
+#line 830
+        }
+#line 830
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 830
+            /* choose random stride from 1 to edge */
+#line 830
+        for (k = 0; k < nslabs; k++) {
+#line 830
+            nstarts = 1;
+#line 830
+            for (j = 0; j < var_rank[i]; j++) {
+#line 830
+                if ((k >> j) & 1) {
+#line 830
+                    start[j] = 0;
+#line 830
+                    edge[j] = mid[j];
+#line 830
+                }else{
+#line 830
+                    start[j] = mid[j];
+#line 830
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 830
+                }
+#line 830
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 830
+                nstarts *= stride[j];
+#line 830
+            }
+#line 830
+            for (m = 0; m < nstarts; m++) {
+#line 830
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 830
+                IF (err)
+#line 830
+                    error("error in toMixedBase");
+#line 830
+                nels = 1;
+#line 830
+                for (j = 0; j < var_rank[i]; j++) {
+#line 830
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 830
+                    nels *= count[j];
+#line 830
+                    index[j] += start[j];
+#line 830
+                }
+#line 830
+		    /* Random choice of forward or backward */
+#line 830
+/* TODO
+#line 830
+		if ( roll(2) ) {
+#line 830
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 830
+			index[j] += (count[j] - 1) * stride[j];
+#line 830
+			stride[j] = -stride[j];
+#line 830
+		    }
+#line 830
+		}
+#line 830
+ */
+#line 830
+		if (var_rank[i] > 0) {
+#line 830
+		    j = var_rank[i] - 1;
+#line 830
+		    imap[j] = 1;
+#line 830
+		    for (; j > 0; j--)
+#line 830
+			imap[j-1] = imap[j] * count[j];
+#line 830
+		}
+#line 830
+                allInExtRange = allInIntRange = 1;
+#line 830
+                for (j = 0; j < nels; j++) {
+#line 830
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 830
+                    IF (err)
+#line 830
+                        error("error in toMixedBase 1");
+#line 830
+                    for (d = 0; d < var_rank[i]; d++)
+#line 830
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 830
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 830
+                        NCT_UCHAR);
+#line 830
+                    if (inRange3(expect[j],var_type[i],NCT_UCHAR)) {
+#line 830
+                        allInIntRange = allInIntRange && expect[j] >= uchar_min
+#line 830
+                            && expect[j] <= uchar_max;
+#line 830
+                    } else {
+#line 830
+                        allInExtRange = 0;
+#line 830
+                    }
+#line 830
+                }
+#line 830
+                if (var_rank[i] == 0 && i%2 )
+#line 830
+                    err = nc_get_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 830
+                else
+#line 830
+                    err = nc_get_varm_uchar(ncid,i,index,count,stride,imap,value);
+#line 830
+                if (canConvert) {
+#line 830
+                    if (allInExtRange) {
+#line 830
+                        if (allInIntRange) {
+#line 830
+                            IF (err)
+#line 830
+                                error("%s", nc_strerror(err));
+#line 830
+                        } else {
+#line 830
+                            IF (err != NC_ERANGE)
+#line 830
+                                error("Range error: status = %d", err);
+#line 830
+                        }
+#line 830
+                    } else {
+#line 830
+                        IF (err != 0 && err != NC_ERANGE)
+#line 830
+                            error("OK or Range error: status = %d", err);
+#line 830
+                    }
+#line 830
+                    for (j = 0; j < nels; j++) {
+#line 830
+                        if (inRange3(expect[j],var_type[i],NCT_UCHAR)
+#line 830
+                                && expect[j] >= uchar_min 
+#line 830
+				&& expect[j] <= uchar_max) {
+#line 830
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 830
+				    NCT_UCHAR)){
+#line 830
+                                error("value read not that expected");
+#line 830
+                                if (verbose) {
+#line 830
+                                    error("\n");
+#line 830
+                                    error("varid: %d, ", i);
+#line 830
+                                    error("var_name: %s, ", var_name[i]);
+#line 830
+                                    error("element number: %d ", j);
+#line 830
+                                    error("expect: %g, ", expect[j]);
+#line 830
+                                    error("got: %g", (double) value[j]);
+#line 830
+                                }
+#line 830
+                            } else {
+#line 830
+                                nok++;
+#line 830
+                            }
+#line 830
+                        }
+#line 830
+                    }
+#line 830
+                } else {
+#line 830
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 830
+                        error("wrong type: status = %d", err);
+#line 830
+                }
+#line 830
+            }
+#line 830
+        }
+#line 830
+    }
+#line 830
+    err = nc_close(ncid);
+#line 830
+    IF (err)
+#line 830
+        error("nc_close: %s", nc_strerror(err));
+#line 830
+    print_nok(nok);
+#line 830
+}
+#line 830
+
+void
+#line 831
+test_nc_get_varm_schar(void)
+#line 831
+{
+#line 831
+    int ncid;
+#line 831
+    int d;
+#line 831
+    int i;
+#line 831
+    int j;
+#line 831
+    int k;
+#line 831
+    int m;
+#line 831
+    int err;
+#line 831
+    int allInExtRange;	/* all values within external range? */
+#line 831
+    int allInIntRange;	/* all values within internal range? */
+#line 831
+    int nels;
+#line 831
+    int nslabs;
+#line 831
+    int nstarts;        /* number of different starts */
+#line 831
+    int nok = 0;      /* count of valid comparisons */
+#line 831
+    size_t start[MAX_RANK];
+#line 831
+    size_t edge[MAX_RANK];
+#line 831
+    size_t index[MAX_RANK];
+#line 831
+    size_t index2[MAX_RANK];
+#line 831
+    size_t mid[MAX_RANK];
+#line 831
+    size_t count[MAX_RANK];
+#line 831
+    size_t sstride[MAX_RANK];
+#line 831
+    ptrdiff_t stride[MAX_RANK];
+#line 831
+    ptrdiff_t imap[MAX_RANK];
+#line 831
+    int canConvert;     /* Both text or both numeric */
+#line 831
+    schar value[MAX_NELS];
+#line 831
+    double expect[MAX_NELS];
+#line 831
+
+#line 831
+#ifdef TEST_PNETCDF
+#line 831
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 831
+#else
+#line 831
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 831
+#endif
+#line 831
+    IF (err)
+#line 831
+        error("nc_open: %s", nc_strerror(err));
+#line 831
+    for (i = 0; i < numVars; i++) {
+#line 831
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+#line 831
+        assert(var_rank[i] <= MAX_RANK);
+#line 831
+        assert(var_nels[i] <= MAX_NELS);
+#line 831
+        for (j = 0; j < var_rank[i]; j++) {
+#line 831
+            start[j] = 0;
+#line 831
+            edge[j] = 1;
+#line 831
+            stride[j] = 1;
+#line 831
+            imap[j] = 1;
+#line 831
+        }
+#line 831
+        err = nc_get_varm_schar(BAD_ID, i, start, edge, stride, imap, value);
+#line 831
+        IF (err != NC_EBADID)
+#line 831
+            error("bad ncid: status = %d", err);
+#line 831
+        err = nc_get_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 831
+        IF (err != NC_ENOTVAR)
+#line 831
+            error("bad var id: status = %d", err);
+#line 831
+        for (j = 0; j < var_rank[i]; j++) {
+#line 831
+            start[j] = var_shape[i][j];
+#line 831
+            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+#line 831
+	  if(!canConvert) {
+#line 831
+		IF (err != NC_ECHAR)
+#line 831
+               	    error("conversion: status = %d", err);
+#line 831
+	  } else {
+#line 831
+	    IF (err != NC_EINVALCOORDS)
+#line 831
+                error("bad index: status = %d", err);
+#line 831
+            start[j] = 0;
+#line 831
+            edge[j] = var_shape[i][j] + 1;
+#line 831
+            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+#line 831
+            IF (err != NC_EEDGE)
+#line 831
+                error("bad edge: status = %d", err);
+#line 831
+            edge[j] = 1;
+#line 831
+            stride[j] = 0;
+#line 831
+            err = nc_get_varm_schar(ncid, i, start, edge, stride, imap, value);
+#line 831
+            IF (err != NC_ESTRIDE)
+#line 831
+                error("bad stride: status = %d", err);
+#line 831
+            stride[j] = 1;
+#line 831
+           }
+#line 831
+        }
+#line 831
+            /* Choose a random point dividing each dim into 2 parts */
+#line 831
+            /* get 2^rank (nslabs) slabs so defined */
+#line 831
+        nslabs = 1;
+#line 831
+        for (j = 0; j < var_rank[i]; j++) {
+#line 831
+            mid[j] = roll( var_shape[i][j] );
+#line 831
+            nslabs *= 2;
+#line 831
+        }
+#line 831
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 831
+            /* choose random stride from 1 to edge */
+#line 831
+        for (k = 0; k < nslabs; k++) {
+#line 831
+            nstarts = 1;
+#line 831
+            for (j = 0; j < var_rank[i]; j++) {
+#line 831
+                if ((k >> j) & 1) {
+#line 831
+                    start[j] = 0;
+#line 831
+                    edge[j] = mid[j];
+#line 831
+                }else{
+#line 831
+                    start[j] = mid[j];
+#line 831
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 831
+                }
+#line 831
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 831
+                nstarts *= stride[j];
+#line 831
+            }
+#line 831
+            for (m = 0; m < nstarts; m++) {
+#line 831
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 831
+                IF (err)
+#line 831
+                    error("error in toMixedBase");
+#line 831
+                nels = 1;
+#line 831
+                for (j = 0; j < var_rank[i]; j++) {
+#line 831
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 831
+                    nels *= count[j];
+#line 831
+                    index[j] += start[j];
+#line 831
+                }
+#line 831
+		    /* Random choice of forward or backward */
+#line 831
+/* TODO
+#line 831
+		if ( roll(2) ) {
+#line 831
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 831
+			index[j] += (count[j] - 1) * stride[j];
+#line 831
+			stride[j] = -stride[j];
+#line 831
+		    }
+#line 831
+		}
+#line 831
+ */
+#line 831
+		if (var_rank[i] > 0) {
+#line 831
+		    j = var_rank[i] - 1;
+#line 831
+		    imap[j] = 1;
+#line 831
+		    for (; j > 0; j--)
+#line 831
+			imap[j-1] = imap[j] * count[j];
+#line 831
+		}
+#line 831
+                allInExtRange = allInIntRange = 1;
+#line 831
+                for (j = 0; j < nels; j++) {
+#line 831
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 831
+                    IF (err)
+#line 831
+                        error("error in toMixedBase 1");
+#line 831
+                    for (d = 0; d < var_rank[i]; d++)
+#line 831
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 831
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 831
+                        NCT_SCHAR);
+#line 831
+                    if (inRange3(expect[j],var_type[i],NCT_SCHAR)) {
+#line 831
+                        allInIntRange = allInIntRange && expect[j] >= schar_min
+#line 831
+                            && expect[j] <= schar_max;
+#line 831
+                    } else {
+#line 831
+                        allInExtRange = 0;
+#line 831
+                    }
+#line 831
+                }
+#line 831
+                if (var_rank[i] == 0 && i%2 )
+#line 831
+                    err = nc_get_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 831
+                else
+#line 831
+                    err = nc_get_varm_schar(ncid,i,index,count,stride,imap,value);
+#line 831
+                if (canConvert) {
+#line 831
+                    if (allInExtRange) {
+#line 831
+                        if (allInIntRange) {
+#line 831
+                            IF (err)
+#line 831
+                                error("%s", nc_strerror(err));
+#line 831
+                        } else {
+#line 831
+                            IF (err != NC_ERANGE)
+#line 831
+                                error("Range error: status = %d", err);
+#line 831
+                        }
+#line 831
+                    } else {
+#line 831
+                        IF (err != 0 && err != NC_ERANGE)
+#line 831
+                            error("OK or Range error: status = %d", err);
+#line 831
+                    }
+#line 831
+                    for (j = 0; j < nels; j++) {
+#line 831
+                        if (inRange3(expect[j],var_type[i],NCT_SCHAR)
+#line 831
+                                && expect[j] >= schar_min 
+#line 831
+				&& expect[j] <= schar_max) {
+#line 831
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 831
+				    NCT_SCHAR)){
+#line 831
+                                error("value read not that expected");
+#line 831
+                                if (verbose) {
+#line 831
+                                    error("\n");
+#line 831
+                                    error("varid: %d, ", i);
+#line 831
+                                    error("var_name: %s, ", var_name[i]);
+#line 831
+                                    error("element number: %d ", j);
+#line 831
+                                    error("expect: %g, ", expect[j]);
+#line 831
+                                    error("got: %g", (double) value[j]);
+#line 831
+                                }
+#line 831
+                            } else {
+#line 831
+                                nok++;
+#line 831
+                            }
+#line 831
+                        }
+#line 831
+                    }
+#line 831
+                } else {
+#line 831
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 831
+                        error("wrong type: status = %d", err);
+#line 831
+                }
+#line 831
+            }
+#line 831
+        }
+#line 831
+    }
+#line 831
+    err = nc_close(ncid);
+#line 831
+    IF (err)
+#line 831
+        error("nc_close: %s", nc_strerror(err));
+#line 831
+    print_nok(nok);
+#line 831
+}
+#line 831
+
+void
+#line 832
+test_nc_get_varm_short(void)
+#line 832
+{
+#line 832
+    int ncid;
+#line 832
+    int d;
+#line 832
+    int i;
+#line 832
+    int j;
+#line 832
+    int k;
+#line 832
+    int m;
+#line 832
+    int err;
+#line 832
+    int allInExtRange;	/* all values within external range? */
+#line 832
+    int allInIntRange;	/* all values within internal range? */
+#line 832
+    int nels;
+#line 832
+    int nslabs;
+#line 832
+    int nstarts;        /* number of different starts */
+#line 832
+    int nok = 0;      /* count of valid comparisons */
+#line 832
+    size_t start[MAX_RANK];
+#line 832
+    size_t edge[MAX_RANK];
+#line 832
+    size_t index[MAX_RANK];
+#line 832
+    size_t index2[MAX_RANK];
+#line 832
+    size_t mid[MAX_RANK];
+#line 832
+    size_t count[MAX_RANK];
+#line 832
+    size_t sstride[MAX_RANK];
+#line 832
+    ptrdiff_t stride[MAX_RANK];
+#line 832
+    ptrdiff_t imap[MAX_RANK];
+#line 832
+    int canConvert;     /* Both text or both numeric */
+#line 832
+    short value[MAX_NELS];
+#line 832
+    double expect[MAX_NELS];
+#line 832
+
+#line 832
+#ifdef TEST_PNETCDF
+#line 832
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 832
+#else
+#line 832
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 832
+#endif
+#line 832
+    IF (err)
+#line 832
+        error("nc_open: %s", nc_strerror(err));
+#line 832
+    for (i = 0; i < numVars; i++) {
+#line 832
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+#line 832
+        assert(var_rank[i] <= MAX_RANK);
+#line 832
+        assert(var_nels[i] <= MAX_NELS);
+#line 832
+        for (j = 0; j < var_rank[i]; j++) {
+#line 832
+            start[j] = 0;
+#line 832
+            edge[j] = 1;
+#line 832
+            stride[j] = 1;
+#line 832
+            imap[j] = 1;
+#line 832
+        }
+#line 832
+        err = nc_get_varm_short(BAD_ID, i, start, edge, stride, imap, value);
+#line 832
+        IF (err != NC_EBADID)
+#line 832
+            error("bad ncid: status = %d", err);
+#line 832
+        err = nc_get_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 832
+        IF (err != NC_ENOTVAR)
+#line 832
+            error("bad var id: status = %d", err);
+#line 832
+        for (j = 0; j < var_rank[i]; j++) {
+#line 832
+            start[j] = var_shape[i][j];
+#line 832
+            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+#line 832
+	  if(!canConvert) {
+#line 832
+		IF (err != NC_ECHAR)
+#line 832
+               	    error("conversion: status = %d", err);
+#line 832
+	  } else {
+#line 832
+	    IF (err != NC_EINVALCOORDS)
+#line 832
+                error("bad index: status = %d", err);
+#line 832
+            start[j] = 0;
+#line 832
+            edge[j] = var_shape[i][j] + 1;
+#line 832
+            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+#line 832
+            IF (err != NC_EEDGE)
+#line 832
+                error("bad edge: status = %d", err);
+#line 832
+            edge[j] = 1;
+#line 832
+            stride[j] = 0;
+#line 832
+            err = nc_get_varm_short(ncid, i, start, edge, stride, imap, value);
+#line 832
+            IF (err != NC_ESTRIDE)
+#line 832
+                error("bad stride: status = %d", err);
+#line 832
+            stride[j] = 1;
+#line 832
+           }
+#line 832
+        }
+#line 832
+            /* Choose a random point dividing each dim into 2 parts */
+#line 832
+            /* get 2^rank (nslabs) slabs so defined */
+#line 832
+        nslabs = 1;
+#line 832
+        for (j = 0; j < var_rank[i]; j++) {
+#line 832
+            mid[j] = roll( var_shape[i][j] );
+#line 832
+            nslabs *= 2;
+#line 832
+        }
+#line 832
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 832
+            /* choose random stride from 1 to edge */
+#line 832
+        for (k = 0; k < nslabs; k++) {
+#line 832
+            nstarts = 1;
+#line 832
+            for (j = 0; j < var_rank[i]; j++) {
+#line 832
+                if ((k >> j) & 1) {
+#line 832
+                    start[j] = 0;
+#line 832
+                    edge[j] = mid[j];
+#line 832
+                }else{
+#line 832
+                    start[j] = mid[j];
+#line 832
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 832
+                }
+#line 832
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 832
+                nstarts *= stride[j];
+#line 832
+            }
+#line 832
+            for (m = 0; m < nstarts; m++) {
+#line 832
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 832
+                IF (err)
+#line 832
+                    error("error in toMixedBase");
+#line 832
+                nels = 1;
+#line 832
+                for (j = 0; j < var_rank[i]; j++) {
+#line 832
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 832
+                    nels *= count[j];
+#line 832
+                    index[j] += start[j];
+#line 832
+                }
+#line 832
+		    /* Random choice of forward or backward */
+#line 832
+/* TODO
+#line 832
+		if ( roll(2) ) {
+#line 832
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 832
+			index[j] += (count[j] - 1) * stride[j];
+#line 832
+			stride[j] = -stride[j];
+#line 832
+		    }
+#line 832
+		}
+#line 832
+ */
+#line 832
+		if (var_rank[i] > 0) {
+#line 832
+		    j = var_rank[i] - 1;
+#line 832
+		    imap[j] = 1;
+#line 832
+		    for (; j > 0; j--)
+#line 832
+			imap[j-1] = imap[j] * count[j];
+#line 832
+		}
+#line 832
+                allInExtRange = allInIntRange = 1;
+#line 832
+                for (j = 0; j < nels; j++) {
+#line 832
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 832
+                    IF (err)
+#line 832
+                        error("error in toMixedBase 1");
+#line 832
+                    for (d = 0; d < var_rank[i]; d++)
+#line 832
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 832
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 832
+                        NCT_SHORT);
+#line 832
+                    if (inRange3(expect[j],var_type[i],NCT_SHORT)) {
+#line 832
+                        allInIntRange = allInIntRange && expect[j] >= short_min
+#line 832
+                            && expect[j] <= short_max;
+#line 832
+                    } else {
+#line 832
+                        allInExtRange = 0;
+#line 832
+                    }
+#line 832
+                }
+#line 832
+                if (var_rank[i] == 0 && i%2 )
+#line 832
+                    err = nc_get_varm_short(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 832
+                else
+#line 832
+                    err = nc_get_varm_short(ncid,i,index,count,stride,imap,value);
+#line 832
+                if (canConvert) {
+#line 832
+                    if (allInExtRange) {
+#line 832
+                        if (allInIntRange) {
+#line 832
+                            IF (err)
+#line 832
+                                error("%s", nc_strerror(err));
+#line 832
+                        } else {
+#line 832
+                            IF (err != NC_ERANGE)
+#line 832
+                                error("Range error: status = %d", err);
+#line 832
+                        }
+#line 832
+                    } else {
+#line 832
+                        IF (err != 0 && err != NC_ERANGE)
+#line 832
+                            error("OK or Range error: status = %d", err);
+#line 832
+                    }
+#line 832
+                    for (j = 0; j < nels; j++) {
+#line 832
+                        if (inRange3(expect[j],var_type[i],NCT_SHORT)
+#line 832
+                                && expect[j] >= short_min 
+#line 832
+				&& expect[j] <= short_max) {
+#line 832
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 832
+				    NCT_SHORT)){
+#line 832
+                                error("value read not that expected");
+#line 832
+                                if (verbose) {
+#line 832
+                                    error("\n");
+#line 832
+                                    error("varid: %d, ", i);
+#line 832
+                                    error("var_name: %s, ", var_name[i]);
+#line 832
+                                    error("element number: %d ", j);
+#line 832
+                                    error("expect: %g, ", expect[j]);
+#line 832
+                                    error("got: %g", (double) value[j]);
+#line 832
+                                }
+#line 832
+                            } else {
+#line 832
+                                nok++;
+#line 832
+                            }
+#line 832
+                        }
+#line 832
+                    }
+#line 832
+                } else {
+#line 832
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 832
+                        error("wrong type: status = %d", err);
+#line 832
+                }
+#line 832
+            }
+#line 832
+        }
+#line 832
+    }
+#line 832
+    err = nc_close(ncid);
+#line 832
+    IF (err)
+#line 832
+        error("nc_close: %s", nc_strerror(err));
+#line 832
+    print_nok(nok);
+#line 832
+}
+#line 832
+
+void
+#line 833
+test_nc_get_varm_int(void)
+#line 833
+{
+#line 833
+    int ncid;
+#line 833
+    int d;
+#line 833
+    int i;
+#line 833
+    int j;
+#line 833
+    int k;
+#line 833
+    int m;
+#line 833
+    int err;
+#line 833
+    int allInExtRange;	/* all values within external range? */
+#line 833
+    int allInIntRange;	/* all values within internal range? */
+#line 833
+    int nels;
+#line 833
+    int nslabs;
+#line 833
+    int nstarts;        /* number of different starts */
+#line 833
+    int nok = 0;      /* count of valid comparisons */
+#line 833
+    size_t start[MAX_RANK];
+#line 833
+    size_t edge[MAX_RANK];
+#line 833
+    size_t index[MAX_RANK];
+#line 833
+    size_t index2[MAX_RANK];
+#line 833
+    size_t mid[MAX_RANK];
+#line 833
+    size_t count[MAX_RANK];
+#line 833
+    size_t sstride[MAX_RANK];
+#line 833
+    ptrdiff_t stride[MAX_RANK];
+#line 833
+    ptrdiff_t imap[MAX_RANK];
+#line 833
+    int canConvert;     /* Both text or both numeric */
+#line 833
+    int value[MAX_NELS];
+#line 833
+    double expect[MAX_NELS];
+#line 833
+
+#line 833
+#ifdef TEST_PNETCDF
+#line 833
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 833
+#else
+#line 833
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 833
+#endif
+#line 833
+    IF (err)
+#line 833
+        error("nc_open: %s", nc_strerror(err));
+#line 833
+    for (i = 0; i < numVars; i++) {
+#line 833
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+#line 833
+        assert(var_rank[i] <= MAX_RANK);
+#line 833
+        assert(var_nels[i] <= MAX_NELS);
+#line 833
+        for (j = 0; j < var_rank[i]; j++) {
+#line 833
+            start[j] = 0;
+#line 833
+            edge[j] = 1;
+#line 833
+            stride[j] = 1;
+#line 833
+            imap[j] = 1;
+#line 833
+        }
+#line 833
+        err = nc_get_varm_int(BAD_ID, i, start, edge, stride, imap, value);
+#line 833
+        IF (err != NC_EBADID)
+#line 833
+            error("bad ncid: status = %d", err);
+#line 833
+        err = nc_get_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 833
+        IF (err != NC_ENOTVAR)
+#line 833
+            error("bad var id: status = %d", err);
+#line 833
+        for (j = 0; j < var_rank[i]; j++) {
+#line 833
+            start[j] = var_shape[i][j];
+#line 833
+            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+#line 833
+	  if(!canConvert) {
+#line 833
+		IF (err != NC_ECHAR)
+#line 833
+               	    error("conversion: status = %d", err);
+#line 833
+	  } else {
+#line 833
+	    IF (err != NC_EINVALCOORDS)
+#line 833
+                error("bad index: status = %d", err);
+#line 833
+            start[j] = 0;
+#line 833
+            edge[j] = var_shape[i][j] + 1;
+#line 833
+            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+#line 833
+            IF (err != NC_EEDGE)
+#line 833
+                error("bad edge: status = %d", err);
+#line 833
+            edge[j] = 1;
+#line 833
+            stride[j] = 0;
+#line 833
+            err = nc_get_varm_int(ncid, i, start, edge, stride, imap, value);
+#line 833
+            IF (err != NC_ESTRIDE)
+#line 833
+                error("bad stride: status = %d", err);
+#line 833
+            stride[j] = 1;
+#line 833
+           }
+#line 833
+        }
+#line 833
+            /* Choose a random point dividing each dim into 2 parts */
+#line 833
+            /* get 2^rank (nslabs) slabs so defined */
+#line 833
+        nslabs = 1;
+#line 833
+        for (j = 0; j < var_rank[i]; j++) {
+#line 833
+            mid[j] = roll( var_shape[i][j] );
+#line 833
+            nslabs *= 2;
+#line 833
+        }
+#line 833
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 833
+            /* choose random stride from 1 to edge */
+#line 833
+        for (k = 0; k < nslabs; k++) {
+#line 833
+            nstarts = 1;
+#line 833
+            for (j = 0; j < var_rank[i]; j++) {
+#line 833
+                if ((k >> j) & 1) {
+#line 833
+                    start[j] = 0;
+#line 833
+                    edge[j] = mid[j];
+#line 833
+                }else{
+#line 833
+                    start[j] = mid[j];
+#line 833
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 833
+                }
+#line 833
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 833
+                nstarts *= stride[j];
+#line 833
+            }
+#line 833
+            for (m = 0; m < nstarts; m++) {
+#line 833
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 833
+                IF (err)
+#line 833
+                    error("error in toMixedBase");
+#line 833
+                nels = 1;
+#line 833
+                for (j = 0; j < var_rank[i]; j++) {
+#line 833
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 833
+                    nels *= count[j];
+#line 833
+                    index[j] += start[j];
+#line 833
+                }
+#line 833
+		    /* Random choice of forward or backward */
+#line 833
+/* TODO
+#line 833
+		if ( roll(2) ) {
+#line 833
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 833
+			index[j] += (count[j] - 1) * stride[j];
+#line 833
+			stride[j] = -stride[j];
+#line 833
+		    }
+#line 833
+		}
+#line 833
+ */
+#line 833
+		if (var_rank[i] > 0) {
+#line 833
+		    j = var_rank[i] - 1;
+#line 833
+		    imap[j] = 1;
+#line 833
+		    for (; j > 0; j--)
+#line 833
+			imap[j-1] = imap[j] * count[j];
+#line 833
+		}
+#line 833
+                allInExtRange = allInIntRange = 1;
+#line 833
+                for (j = 0; j < nels; j++) {
+#line 833
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 833
+                    IF (err)
+#line 833
+                        error("error in toMixedBase 1");
+#line 833
+                    for (d = 0; d < var_rank[i]; d++)
+#line 833
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 833
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 833
+                        NCT_INT);
+#line 833
+                    if (inRange3(expect[j],var_type[i],NCT_INT)) {
+#line 833
+                        allInIntRange = allInIntRange && expect[j] >= int_min
+#line 833
+                            && expect[j] <= int_max;
+#line 833
+                    } else {
+#line 833
+                        allInExtRange = 0;
+#line 833
+                    }
+#line 833
+                }
+#line 833
+                if (var_rank[i] == 0 && i%2 )
+#line 833
+                    err = nc_get_varm_int(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 833
+                else
+#line 833
+                    err = nc_get_varm_int(ncid,i,index,count,stride,imap,value);
+#line 833
+                if (canConvert) {
+#line 833
+                    if (allInExtRange) {
+#line 833
+                        if (allInIntRange) {
+#line 833
+                            IF (err)
+#line 833
+                                error("%s", nc_strerror(err));
+#line 833
+                        } else {
+#line 833
+                            IF (err != NC_ERANGE)
+#line 833
+                                error("Range error: status = %d", err);
+#line 833
+                        }
+#line 833
+                    } else {
+#line 833
+                        IF (err != 0 && err != NC_ERANGE)
+#line 833
+                            error("OK or Range error: status = %d", err);
+#line 833
+                    }
+#line 833
+                    for (j = 0; j < nels; j++) {
+#line 833
+                        if (inRange3(expect[j],var_type[i],NCT_INT)
+#line 833
+                                && expect[j] >= int_min 
+#line 833
+				&& expect[j] <= int_max) {
+#line 833
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 833
+				    NCT_INT)){
+#line 833
+                                error("value read not that expected");
+#line 833
+                                if (verbose) {
+#line 833
+                                    error("\n");
+#line 833
+                                    error("varid: %d, ", i);
+#line 833
+                                    error("var_name: %s, ", var_name[i]);
+#line 833
+                                    error("element number: %d ", j);
+#line 833
+                                    error("expect: %g, ", expect[j]);
+#line 833
+                                    error("got: %g", (double) value[j]);
+#line 833
+                                }
+#line 833
+                            } else {
+#line 833
+                                nok++;
+#line 833
+                            }
+#line 833
+                        }
+#line 833
+                    }
+#line 833
+                } else {
+#line 833
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 833
+                        error("wrong type: status = %d", err);
+#line 833
+                }
+#line 833
+            }
+#line 833
+        }
+#line 833
+    }
+#line 833
+    err = nc_close(ncid);
+#line 833
+    IF (err)
+#line 833
+        error("nc_close: %s", nc_strerror(err));
+#line 833
+    print_nok(nok);
+#line 833
+}
+#line 833
+
+void
+#line 834
+test_nc_get_varm_long(void)
+#line 834
+{
+#line 834
+    int ncid;
+#line 834
+    int d;
+#line 834
+    int i;
+#line 834
+    int j;
+#line 834
+    int k;
+#line 834
+    int m;
+#line 834
+    int err;
+#line 834
+    int allInExtRange;	/* all values within external range? */
+#line 834
+    int allInIntRange;	/* all values within internal range? */
+#line 834
+    int nels;
+#line 834
+    int nslabs;
+#line 834
+    int nstarts;        /* number of different starts */
+#line 834
+    int nok = 0;      /* count of valid comparisons */
+#line 834
+    size_t start[MAX_RANK];
+#line 834
+    size_t edge[MAX_RANK];
+#line 834
+    size_t index[MAX_RANK];
+#line 834
+    size_t index2[MAX_RANK];
+#line 834
+    size_t mid[MAX_RANK];
+#line 834
+    size_t count[MAX_RANK];
+#line 834
+    size_t sstride[MAX_RANK];
+#line 834
+    ptrdiff_t stride[MAX_RANK];
+#line 834
+    ptrdiff_t imap[MAX_RANK];
+#line 834
+    int canConvert;     /* Both text or both numeric */
+#line 834
+    long value[MAX_NELS];
+#line 834
+    double expect[MAX_NELS];
+#line 834
+
+#line 834
+#ifdef TEST_PNETCDF
+#line 834
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 834
+#else
+#line 834
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 834
+#endif
+#line 834
+    IF (err)
+#line 834
+        error("nc_open: %s", nc_strerror(err));
+#line 834
+    for (i = 0; i < numVars; i++) {
+#line 834
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+#line 834
+        assert(var_rank[i] <= MAX_RANK);
+#line 834
+        assert(var_nels[i] <= MAX_NELS);
+#line 834
+        for (j = 0; j < var_rank[i]; j++) {
+#line 834
+            start[j] = 0;
+#line 834
+            edge[j] = 1;
+#line 834
+            stride[j] = 1;
+#line 834
+            imap[j] = 1;
+#line 834
+        }
+#line 834
+        err = nc_get_varm_long(BAD_ID, i, start, edge, stride, imap, value);
+#line 834
+        IF (err != NC_EBADID)
+#line 834
+            error("bad ncid: status = %d", err);
+#line 834
+        err = nc_get_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 834
+        IF (err != NC_ENOTVAR)
+#line 834
+            error("bad var id: status = %d", err);
+#line 834
+        for (j = 0; j < var_rank[i]; j++) {
+#line 834
+            start[j] = var_shape[i][j];
+#line 834
+            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+#line 834
+	  if(!canConvert) {
+#line 834
+		IF (err != NC_ECHAR)
+#line 834
+               	    error("conversion: status = %d", err);
+#line 834
+	  } else {
+#line 834
+	    IF (err != NC_EINVALCOORDS)
+#line 834
+                error("bad index: status = %d", err);
+#line 834
+            start[j] = 0;
+#line 834
+            edge[j] = var_shape[i][j] + 1;
+#line 834
+            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+#line 834
+            IF (err != NC_EEDGE)
+#line 834
+                error("bad edge: status = %d", err);
+#line 834
+            edge[j] = 1;
+#line 834
+            stride[j] = 0;
+#line 834
+            err = nc_get_varm_long(ncid, i, start, edge, stride, imap, value);
+#line 834
+            IF (err != NC_ESTRIDE)
+#line 834
+                error("bad stride: status = %d", err);
+#line 834
+            stride[j] = 1;
+#line 834
+           }
+#line 834
+        }
+#line 834
+            /* Choose a random point dividing each dim into 2 parts */
+#line 834
+            /* get 2^rank (nslabs) slabs so defined */
+#line 834
+        nslabs = 1;
+#line 834
+        for (j = 0; j < var_rank[i]; j++) {
+#line 834
+            mid[j] = roll( var_shape[i][j] );
+#line 834
+            nslabs *= 2;
+#line 834
+        }
+#line 834
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 834
+            /* choose random stride from 1 to edge */
+#line 834
+        for (k = 0; k < nslabs; k++) {
+#line 834
+            nstarts = 1;
+#line 834
+            for (j = 0; j < var_rank[i]; j++) {
+#line 834
+                if ((k >> j) & 1) {
+#line 834
+                    start[j] = 0;
+#line 834
+                    edge[j] = mid[j];
+#line 834
+                }else{
+#line 834
+                    start[j] = mid[j];
+#line 834
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 834
+                }
+#line 834
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 834
+                nstarts *= stride[j];
+#line 834
+            }
+#line 834
+            for (m = 0; m < nstarts; m++) {
+#line 834
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 834
+                IF (err)
+#line 834
+                    error("error in toMixedBase");
+#line 834
+                nels = 1;
+#line 834
+                for (j = 0; j < var_rank[i]; j++) {
+#line 834
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 834
+                    nels *= count[j];
+#line 834
+                    index[j] += start[j];
+#line 834
+                }
+#line 834
+		    /* Random choice of forward or backward */
+#line 834
+/* TODO
+#line 834
+		if ( roll(2) ) {
+#line 834
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 834
+			index[j] += (count[j] - 1) * stride[j];
+#line 834
+			stride[j] = -stride[j];
+#line 834
+		    }
+#line 834
+		}
+#line 834
+ */
+#line 834
+		if (var_rank[i] > 0) {
+#line 834
+		    j = var_rank[i] - 1;
+#line 834
+		    imap[j] = 1;
+#line 834
+		    for (; j > 0; j--)
+#line 834
+			imap[j-1] = imap[j] * count[j];
+#line 834
+		}
+#line 834
+                allInExtRange = allInIntRange = 1;
+#line 834
+                for (j = 0; j < nels; j++) {
+#line 834
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 834
+                    IF (err)
+#line 834
+                        error("error in toMixedBase 1");
+#line 834
+                    for (d = 0; d < var_rank[i]; d++)
+#line 834
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 834
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 834
+                        NCT_LONG);
+#line 834
+                    if (inRange3(expect[j],var_type[i],NCT_LONG)) {
+#line 834
+                        allInIntRange = allInIntRange && expect[j] >= long_min
+#line 834
+                            && expect[j] <= long_max;
+#line 834
+                    } else {
+#line 834
+                        allInExtRange = 0;
+#line 834
+                    }
+#line 834
+                }
+#line 834
+                if (var_rank[i] == 0 && i%2 )
+#line 834
+                    err = nc_get_varm_long(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 834
+                else
+#line 834
+                    err = nc_get_varm_long(ncid,i,index,count,stride,imap,value);
+#line 834
+                if (canConvert) {
+#line 834
+                    if (allInExtRange) {
+#line 834
+                        if (allInIntRange) {
+#line 834
+                            IF (err)
+#line 834
+                                error("%s", nc_strerror(err));
+#line 834
+                        } else {
+#line 834
+                            IF (err != NC_ERANGE)
+#line 834
+                                error("Range error: status = %d", err);
+#line 834
+                        }
+#line 834
+                    } else {
+#line 834
+                        IF (err != 0 && err != NC_ERANGE)
+#line 834
+                            error("OK or Range error: status = %d", err);
+#line 834
+                    }
+#line 834
+                    for (j = 0; j < nels; j++) {
+#line 834
+                        if (inRange3(expect[j],var_type[i],NCT_LONG)
+#line 834
+                                && expect[j] >= long_min 
+#line 834
+				&& expect[j] <= long_max) {
+#line 834
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 834
+				    NCT_LONG)){
+#line 834
+                                error("value read not that expected");
+#line 834
+                                if (verbose) {
+#line 834
+                                    error("\n");
+#line 834
+                                    error("varid: %d, ", i);
+#line 834
+                                    error("var_name: %s, ", var_name[i]);
+#line 834
+                                    error("element number: %d ", j);
+#line 834
+                                    error("expect: %g, ", expect[j]);
+#line 834
+                                    error("got: %g", (double) value[j]);
+#line 834
+                                }
+#line 834
+                            } else {
+#line 834
+                                nok++;
+#line 834
+                            }
+#line 834
+                        }
+#line 834
+                    }
+#line 834
+                } else {
+#line 834
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 834
+                        error("wrong type: status = %d", err);
+#line 834
+                }
+#line 834
+            }
+#line 834
+        }
+#line 834
+    }
+#line 834
+    err = nc_close(ncid);
+#line 834
+    IF (err)
+#line 834
+        error("nc_close: %s", nc_strerror(err));
+#line 834
+    print_nok(nok);
+#line 834
+}
+#line 834
+
+void
+#line 835
+test_nc_get_varm_float(void)
+#line 835
+{
+#line 835
+    int ncid;
+#line 835
+    int d;
+#line 835
+    int i;
+#line 835
+    int j;
+#line 835
+    int k;
+#line 835
+    int m;
+#line 835
+    int err;
+#line 835
+    int allInExtRange;	/* all values within external range? */
+#line 835
+    int allInIntRange;	/* all values within internal range? */
+#line 835
+    int nels;
+#line 835
+    int nslabs;
+#line 835
+    int nstarts;        /* number of different starts */
+#line 835
+    int nok = 0;      /* count of valid comparisons */
+#line 835
+    size_t start[MAX_RANK];
+#line 835
+    size_t edge[MAX_RANK];
+#line 835
+    size_t index[MAX_RANK];
+#line 835
+    size_t index2[MAX_RANK];
+#line 835
+    size_t mid[MAX_RANK];
+#line 835
+    size_t count[MAX_RANK];
+#line 835
+    size_t sstride[MAX_RANK];
+#line 835
+    ptrdiff_t stride[MAX_RANK];
+#line 835
+    ptrdiff_t imap[MAX_RANK];
+#line 835
+    int canConvert;     /* Both text or both numeric */
+#line 835
+    float value[MAX_NELS];
+#line 835
+    double expect[MAX_NELS];
+#line 835
+
+#line 835
+#ifdef TEST_PNETCDF
+#line 835
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 835
+#else
+#line 835
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 835
+#endif
+#line 835
+    IF (err)
+#line 835
+        error("nc_open: %s", nc_strerror(err));
+#line 835
+    for (i = 0; i < numVars; i++) {
+#line 835
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+#line 835
+        assert(var_rank[i] <= MAX_RANK);
+#line 835
+        assert(var_nels[i] <= MAX_NELS);
+#line 835
+        for (j = 0; j < var_rank[i]; j++) {
+#line 835
+            start[j] = 0;
+#line 835
+            edge[j] = 1;
+#line 835
+            stride[j] = 1;
+#line 835
+            imap[j] = 1;
+#line 835
+        }
+#line 835
+        err = nc_get_varm_float(BAD_ID, i, start, edge, stride, imap, value);
+#line 835
+        IF (err != NC_EBADID)
+#line 835
+            error("bad ncid: status = %d", err);
+#line 835
+        err = nc_get_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 835
+        IF (err != NC_ENOTVAR)
+#line 835
+            error("bad var id: status = %d", err);
+#line 835
+        for (j = 0; j < var_rank[i]; j++) {
+#line 835
+            start[j] = var_shape[i][j];
+#line 835
+            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+#line 835
+	  if(!canConvert) {
+#line 835
+		IF (err != NC_ECHAR)
+#line 835
+               	    error("conversion: status = %d", err);
+#line 835
+	  } else {
+#line 835
+	    IF (err != NC_EINVALCOORDS)
+#line 835
+                error("bad index: status = %d", err);
+#line 835
+            start[j] = 0;
+#line 835
+            edge[j] = var_shape[i][j] + 1;
+#line 835
+            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+#line 835
+            IF (err != NC_EEDGE)
+#line 835
+                error("bad edge: status = %d", err);
+#line 835
+            edge[j] = 1;
+#line 835
+            stride[j] = 0;
+#line 835
+            err = nc_get_varm_float(ncid, i, start, edge, stride, imap, value);
+#line 835
+            IF (err != NC_ESTRIDE)
+#line 835
+                error("bad stride: status = %d", err);
+#line 835
+            stride[j] = 1;
+#line 835
+           }
+#line 835
+        }
+#line 835
+            /* Choose a random point dividing each dim into 2 parts */
+#line 835
+            /* get 2^rank (nslabs) slabs so defined */
+#line 835
+        nslabs = 1;
+#line 835
+        for (j = 0; j < var_rank[i]; j++) {
+#line 835
+            mid[j] = roll( var_shape[i][j] );
+#line 835
+            nslabs *= 2;
+#line 835
+        }
+#line 835
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 835
+            /* choose random stride from 1 to edge */
+#line 835
+        for (k = 0; k < nslabs; k++) {
+#line 835
+            nstarts = 1;
+#line 835
+            for (j = 0; j < var_rank[i]; j++) {
+#line 835
+                if ((k >> j) & 1) {
+#line 835
+                    start[j] = 0;
+#line 835
+                    edge[j] = mid[j];
+#line 835
+                }else{
+#line 835
+                    start[j] = mid[j];
+#line 835
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 835
+                }
+#line 835
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 835
+                nstarts *= stride[j];
+#line 835
+            }
+#line 835
+            for (m = 0; m < nstarts; m++) {
+#line 835
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 835
+                IF (err)
+#line 835
+                    error("error in toMixedBase");
+#line 835
+                nels = 1;
+#line 835
+                for (j = 0; j < var_rank[i]; j++) {
+#line 835
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 835
+                    nels *= count[j];
+#line 835
+                    index[j] += start[j];
+#line 835
+                }
+#line 835
+		    /* Random choice of forward or backward */
+#line 835
+/* TODO
+#line 835
+		if ( roll(2) ) {
+#line 835
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 835
+			index[j] += (count[j] - 1) * stride[j];
+#line 835
+			stride[j] = -stride[j];
+#line 835
+		    }
+#line 835
+		}
+#line 835
+ */
+#line 835
+		if (var_rank[i] > 0) {
+#line 835
+		    j = var_rank[i] - 1;
+#line 835
+		    imap[j] = 1;
+#line 835
+		    for (; j > 0; j--)
+#line 835
+			imap[j-1] = imap[j] * count[j];
+#line 835
+		}
+#line 835
+                allInExtRange = allInIntRange = 1;
+#line 835
+                for (j = 0; j < nels; j++) {
+#line 835
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 835
+                    IF (err)
+#line 835
+                        error("error in toMixedBase 1");
+#line 835
+                    for (d = 0; d < var_rank[i]; d++)
+#line 835
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 835
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 835
+                        NCT_FLOAT);
+#line 835
+                    if (inRange3(expect[j],var_type[i],NCT_FLOAT)) {
+#line 835
+                        allInIntRange = allInIntRange && expect[j] >= float_min
+#line 835
+                            && expect[j] <= float_max;
+#line 835
+                    } else {
+#line 835
+                        allInExtRange = 0;
+#line 835
+                    }
+#line 835
+                }
+#line 835
+                if (var_rank[i] == 0 && i%2 )
+#line 835
+                    err = nc_get_varm_float(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 835
+                else
+#line 835
+                    err = nc_get_varm_float(ncid,i,index,count,stride,imap,value);
+#line 835
+                if (canConvert) {
+#line 835
+                    if (allInExtRange) {
+#line 835
+                        if (allInIntRange) {
+#line 835
+                            IF (err)
+#line 835
+                                error("%s", nc_strerror(err));
+#line 835
+                        } else {
+#line 835
+                            IF (err != NC_ERANGE)
+#line 835
+                                error("Range error: status = %d", err);
+#line 835
+                        }
+#line 835
+                    } else {
+#line 835
+                        IF (err != 0 && err != NC_ERANGE)
+#line 835
+                            error("OK or Range error: status = %d", err);
+#line 835
+                    }
+#line 835
+                    for (j = 0; j < nels; j++) {
+#line 835
+                        if (inRange3(expect[j],var_type[i],NCT_FLOAT)
+#line 835
+                                && expect[j] >= float_min 
+#line 835
+				&& expect[j] <= float_max) {
+#line 835
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 835
+				    NCT_FLOAT)){
+#line 835
+                                error("value read not that expected");
+#line 835
+                                if (verbose) {
+#line 835
+                                    error("\n");
+#line 835
+                                    error("varid: %d, ", i);
+#line 835
+                                    error("var_name: %s, ", var_name[i]);
+#line 835
+                                    error("element number: %d ", j);
+#line 835
+                                    error("expect: %g, ", expect[j]);
+#line 835
+                                    error("got: %g", (double) value[j]);
+#line 835
+                                }
+#line 835
+                            } else {
+#line 835
+                                nok++;
+#line 835
+                            }
+#line 835
+                        }
+#line 835
+                    }
+#line 835
+                } else {
+#line 835
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 835
+                        error("wrong type: status = %d", err);
+#line 835
+                }
+#line 835
+            }
+#line 835
+        }
+#line 835
+    }
+#line 835
+    err = nc_close(ncid);
+#line 835
+    IF (err)
+#line 835
+        error("nc_close: %s", nc_strerror(err));
+#line 835
+    print_nok(nok);
+#line 835
+}
+#line 835
+
+void
+#line 836
+test_nc_get_varm_double(void)
+#line 836
+{
+#line 836
+    int ncid;
+#line 836
+    int d;
+#line 836
+    int i;
+#line 836
+    int j;
+#line 836
+    int k;
+#line 836
+    int m;
+#line 836
+    int err;
+#line 836
+    int allInExtRange;	/* all values within external range? */
+#line 836
+    int allInIntRange;	/* all values within internal range? */
+#line 836
+    int nels;
+#line 836
+    int nslabs;
+#line 836
+    int nstarts;        /* number of different starts */
+#line 836
+    int nok = 0;      /* count of valid comparisons */
+#line 836
+    size_t start[MAX_RANK];
+#line 836
+    size_t edge[MAX_RANK];
+#line 836
+    size_t index[MAX_RANK];
+#line 836
+    size_t index2[MAX_RANK];
+#line 836
+    size_t mid[MAX_RANK];
+#line 836
+    size_t count[MAX_RANK];
+#line 836
+    size_t sstride[MAX_RANK];
+#line 836
+    ptrdiff_t stride[MAX_RANK];
+#line 836
+    ptrdiff_t imap[MAX_RANK];
+#line 836
+    int canConvert;     /* Both text or both numeric */
+#line 836
+    double value[MAX_NELS];
+#line 836
+    double expect[MAX_NELS];
+#line 836
+
+#line 836
+#ifdef TEST_PNETCDF
+#line 836
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 836
+#else
+#line 836
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 836
+#endif
+#line 836
+    IF (err)
+#line 836
+        error("nc_open: %s", nc_strerror(err));
+#line 836
+    for (i = 0; i < numVars; i++) {
+#line 836
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+#line 836
+        assert(var_rank[i] <= MAX_RANK);
+#line 836
+        assert(var_nels[i] <= MAX_NELS);
+#line 836
+        for (j = 0; j < var_rank[i]; j++) {
+#line 836
+            start[j] = 0;
+#line 836
+            edge[j] = 1;
+#line 836
+            stride[j] = 1;
+#line 836
+            imap[j] = 1;
+#line 836
+        }
+#line 836
+        err = nc_get_varm_double(BAD_ID, i, start, edge, stride, imap, value);
+#line 836
+        IF (err != NC_EBADID)
+#line 836
+            error("bad ncid: status = %d", err);
+#line 836
+        err = nc_get_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 836
+        IF (err != NC_ENOTVAR)
+#line 836
+            error("bad var id: status = %d", err);
+#line 836
+        for (j = 0; j < var_rank[i]; j++) {
+#line 836
+            start[j] = var_shape[i][j];
+#line 836
+            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+#line 836
+	  if(!canConvert) {
+#line 836
+		IF (err != NC_ECHAR)
+#line 836
+               	    error("conversion: status = %d", err);
+#line 836
+	  } else {
+#line 836
+	    IF (err != NC_EINVALCOORDS)
+#line 836
+                error("bad index: status = %d", err);
+#line 836
+            start[j] = 0;
+#line 836
+            edge[j] = var_shape[i][j] + 1;
+#line 836
+            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+#line 836
+            IF (err != NC_EEDGE)
+#line 836
+                error("bad edge: status = %d", err);
+#line 836
+            edge[j] = 1;
+#line 836
+            stride[j] = 0;
+#line 836
+            err = nc_get_varm_double(ncid, i, start, edge, stride, imap, value);
+#line 836
+            IF (err != NC_ESTRIDE)
+#line 836
+                error("bad stride: status = %d", err);
+#line 836
+            stride[j] = 1;
+#line 836
+           }
+#line 836
+        }
+#line 836
+            /* Choose a random point dividing each dim into 2 parts */
+#line 836
+            /* get 2^rank (nslabs) slabs so defined */
+#line 836
+        nslabs = 1;
+#line 836
+        for (j = 0; j < var_rank[i]; j++) {
+#line 836
+            mid[j] = roll( var_shape[i][j] );
+#line 836
+            nslabs *= 2;
+#line 836
+        }
+#line 836
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 836
+            /* choose random stride from 1 to edge */
+#line 836
+        for (k = 0; k < nslabs; k++) {
+#line 836
+            nstarts = 1;
+#line 836
+            for (j = 0; j < var_rank[i]; j++) {
+#line 836
+                if ((k >> j) & 1) {
+#line 836
+                    start[j] = 0;
+#line 836
+                    edge[j] = mid[j];
+#line 836
+                }else{
+#line 836
+                    start[j] = mid[j];
+#line 836
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 836
+                }
+#line 836
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 836
+                nstarts *= stride[j];
+#line 836
+            }
+#line 836
+            for (m = 0; m < nstarts; m++) {
+#line 836
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 836
+                IF (err)
+#line 836
+                    error("error in toMixedBase");
+#line 836
+                nels = 1;
+#line 836
+                for (j = 0; j < var_rank[i]; j++) {
+#line 836
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 836
+                    nels *= count[j];
+#line 836
+                    index[j] += start[j];
+#line 836
+                }
+#line 836
+		    /* Random choice of forward or backward */
+#line 836
+/* TODO
+#line 836
+		if ( roll(2) ) {
+#line 836
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 836
+			index[j] += (count[j] - 1) * stride[j];
+#line 836
+			stride[j] = -stride[j];
+#line 836
+		    }
+#line 836
+		}
+#line 836
+ */
+#line 836
+		if (var_rank[i] > 0) {
+#line 836
+		    j = var_rank[i] - 1;
+#line 836
+		    imap[j] = 1;
+#line 836
+		    for (; j > 0; j--)
+#line 836
+			imap[j-1] = imap[j] * count[j];
+#line 836
+		}
+#line 836
+                allInExtRange = allInIntRange = 1;
+#line 836
+                for (j = 0; j < nels; j++) {
+#line 836
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 836
+                    IF (err)
+#line 836
+                        error("error in toMixedBase 1");
+#line 836
+                    for (d = 0; d < var_rank[i]; d++)
+#line 836
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 836
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 836
+                        NCT_DOUBLE);
+#line 836
+                    if (inRange3(expect[j],var_type[i],NCT_DOUBLE)) {
+#line 836
+                        allInIntRange = allInIntRange && expect[j] >= double_min
+#line 836
+                            && expect[j] <= double_max;
+#line 836
+                    } else {
+#line 836
+                        allInExtRange = 0;
+#line 836
+                    }
+#line 836
+                }
+#line 836
+                if (var_rank[i] == 0 && i%2 )
+#line 836
+                    err = nc_get_varm_double(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 836
+                else
+#line 836
+                    err = nc_get_varm_double(ncid,i,index,count,stride,imap,value);
+#line 836
+                if (canConvert) {
+#line 836
+                    if (allInExtRange) {
+#line 836
+                        if (allInIntRange) {
+#line 836
+                            IF (err)
+#line 836
+                                error("%s", nc_strerror(err));
+#line 836
+                        } else {
+#line 836
+                            IF (err != NC_ERANGE)
+#line 836
+                                error("Range error: status = %d", err);
+#line 836
+                        }
+#line 836
+                    } else {
+#line 836
+                        IF (err != 0 && err != NC_ERANGE)
+#line 836
+                            error("OK or Range error: status = %d", err);
+#line 836
+                    }
+#line 836
+                    for (j = 0; j < nels; j++) {
+#line 836
+                        if (inRange3(expect[j],var_type[i],NCT_DOUBLE)
+#line 836
+                                && expect[j] >= double_min 
+#line 836
+				&& expect[j] <= double_max) {
+#line 836
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 836
+				    NCT_DOUBLE)){
+#line 836
+                                error("value read not that expected");
+#line 836
+                                if (verbose) {
+#line 836
+                                    error("\n");
+#line 836
+                                    error("varid: %d, ", i);
+#line 836
+                                    error("var_name: %s, ", var_name[i]);
+#line 836
+                                    error("element number: %d ", j);
+#line 836
+                                    error("expect: %g, ", expect[j]);
+#line 836
+                                    error("got: %g", (double) value[j]);
+#line 836
+                                }
+#line 836
+                            } else {
+#line 836
+                                nok++;
+#line 836
+                            }
+#line 836
+                        }
+#line 836
+                    }
+#line 836
+                } else {
+#line 836
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 836
+                        error("wrong type: status = %d", err);
+#line 836
+                }
+#line 836
+            }
+#line 836
+        }
+#line 836
+    }
+#line 836
+    err = nc_close(ncid);
+#line 836
+    IF (err)
+#line 836
+        error("nc_close: %s", nc_strerror(err));
+#line 836
+    print_nok(nok);
+#line 836
+}
+#line 836
+
+void
+#line 837
+test_nc_get_varm_ushort(void)
+#line 837
+{
+#line 837
+    int ncid;
+#line 837
+    int d;
+#line 837
+    int i;
+#line 837
+    int j;
+#line 837
+    int k;
+#line 837
+    int m;
+#line 837
+    int err;
+#line 837
+    int allInExtRange;	/* all values within external range? */
+#line 837
+    int allInIntRange;	/* all values within internal range? */
+#line 837
+    int nels;
+#line 837
+    int nslabs;
+#line 837
+    int nstarts;        /* number of different starts */
+#line 837
+    int nok = 0;      /* count of valid comparisons */
+#line 837
+    size_t start[MAX_RANK];
+#line 837
+    size_t edge[MAX_RANK];
+#line 837
+    size_t index[MAX_RANK];
+#line 837
+    size_t index2[MAX_RANK];
+#line 837
+    size_t mid[MAX_RANK];
+#line 837
+    size_t count[MAX_RANK];
+#line 837
+    size_t sstride[MAX_RANK];
+#line 837
+    ptrdiff_t stride[MAX_RANK];
+#line 837
+    ptrdiff_t imap[MAX_RANK];
+#line 837
+    int canConvert;     /* Both text or both numeric */
+#line 837
+    ushort value[MAX_NELS];
+#line 837
+    double expect[MAX_NELS];
+#line 837
+
+#line 837
+#ifdef TEST_PNETCDF
+#line 837
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 837
+#else
+#line 837
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 837
+#endif
+#line 837
+    IF (err)
+#line 837
+        error("nc_open: %s", nc_strerror(err));
+#line 837
+    for (i = 0; i < numVars; i++) {
+#line 837
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+#line 837
+        assert(var_rank[i] <= MAX_RANK);
+#line 837
+        assert(var_nels[i] <= MAX_NELS);
+#line 837
+        for (j = 0; j < var_rank[i]; j++) {
+#line 837
+            start[j] = 0;
+#line 837
+            edge[j] = 1;
+#line 837
+            stride[j] = 1;
+#line 837
+            imap[j] = 1;
+#line 837
+        }
+#line 837
+        err = nc_get_varm_ushort(BAD_ID, i, start, edge, stride, imap, value);
+#line 837
+        IF (err != NC_EBADID)
+#line 837
+            error("bad ncid: status = %d", err);
+#line 837
+        err = nc_get_varm_ushort(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 837
+        IF (err != NC_ENOTVAR)
+#line 837
+            error("bad var id: status = %d", err);
+#line 837
+        for (j = 0; j < var_rank[i]; j++) {
+#line 837
+            start[j] = var_shape[i][j];
+#line 837
+            err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+#line 837
+	  if(!canConvert) {
+#line 837
+		IF (err != NC_ECHAR)
+#line 837
+               	    error("conversion: status = %d", err);
+#line 837
+	  } else {
+#line 837
+	    IF (err != NC_EINVALCOORDS)
+#line 837
+                error("bad index: status = %d", err);
+#line 837
+            start[j] = 0;
+#line 837
+            edge[j] = var_shape[i][j] + 1;
+#line 837
+            err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+#line 837
+            IF (err != NC_EEDGE)
+#line 837
+                error("bad edge: status = %d", err);
+#line 837
+            edge[j] = 1;
+#line 837
+            stride[j] = 0;
+#line 837
+            err = nc_get_varm_ushort(ncid, i, start, edge, stride, imap, value);
+#line 837
+            IF (err != NC_ESTRIDE)
+#line 837
+                error("bad stride: status = %d", err);
+#line 837
+            stride[j] = 1;
+#line 837
+           }
+#line 837
+        }
+#line 837
+            /* Choose a random point dividing each dim into 2 parts */
+#line 837
+            /* get 2^rank (nslabs) slabs so defined */
+#line 837
+        nslabs = 1;
+#line 837
+        for (j = 0; j < var_rank[i]; j++) {
+#line 837
+            mid[j] = roll( var_shape[i][j] );
+#line 837
+            nslabs *= 2;
+#line 837
+        }
+#line 837
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 837
+            /* choose random stride from 1 to edge */
+#line 837
+        for (k = 0; k < nslabs; k++) {
+#line 837
+            nstarts = 1;
+#line 837
+            for (j = 0; j < var_rank[i]; j++) {
+#line 837
+                if ((k >> j) & 1) {
+#line 837
+                    start[j] = 0;
+#line 837
+                    edge[j] = mid[j];
+#line 837
+                }else{
+#line 837
+                    start[j] = mid[j];
+#line 837
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 837
+                }
+#line 837
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 837
+                nstarts *= stride[j];
+#line 837
+            }
+#line 837
+            for (m = 0; m < nstarts; m++) {
+#line 837
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 837
+                IF (err)
+#line 837
+                    error("error in toMixedBase");
+#line 837
+                nels = 1;
+#line 837
+                for (j = 0; j < var_rank[i]; j++) {
+#line 837
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 837
+                    nels *= count[j];
+#line 837
+                    index[j] += start[j];
+#line 837
+                }
+#line 837
+		    /* Random choice of forward or backward */
+#line 837
+/* TODO
+#line 837
+		if ( roll(2) ) {
+#line 837
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 837
+			index[j] += (count[j] - 1) * stride[j];
+#line 837
+			stride[j] = -stride[j];
+#line 837
+		    }
+#line 837
+		}
+#line 837
+ */
+#line 837
+		if (var_rank[i] > 0) {
+#line 837
+		    j = var_rank[i] - 1;
+#line 837
+		    imap[j] = 1;
+#line 837
+		    for (; j > 0; j--)
+#line 837
+			imap[j-1] = imap[j] * count[j];
+#line 837
+		}
+#line 837
+                allInExtRange = allInIntRange = 1;
+#line 837
+                for (j = 0; j < nels; j++) {
+#line 837
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 837
+                    IF (err)
+#line 837
+                        error("error in toMixedBase 1");
+#line 837
+                    for (d = 0; d < var_rank[i]; d++)
+#line 837
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 837
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 837
+                        NCT_USHORT);
+#line 837
+                    if (inRange3(expect[j],var_type[i],NCT_USHORT)) {
+#line 837
+                        allInIntRange = allInIntRange && expect[j] >= ushort_min
+#line 837
+                            && expect[j] <= ushort_max;
+#line 837
+                    } else {
+#line 837
+                        allInExtRange = 0;
+#line 837
+                    }
+#line 837
+                }
+#line 837
+                if (var_rank[i] == 0 && i%2 )
+#line 837
+                    err = nc_get_varm_ushort(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 837
+                else
+#line 837
+                    err = nc_get_varm_ushort(ncid,i,index,count,stride,imap,value);
+#line 837
+                if (canConvert) {
+#line 837
+                    if (allInExtRange) {
+#line 837
+                        if (allInIntRange) {
+#line 837
+                            IF (err)
+#line 837
+                                error("%s", nc_strerror(err));
+#line 837
+                        } else {
+#line 837
+                            IF (err != NC_ERANGE)
+#line 837
+                                error("Range error: status = %d", err);
+#line 837
+                        }
+#line 837
+                    } else {
+#line 837
+                        IF (err != 0 && err != NC_ERANGE)
+#line 837
+                            error("OK or Range error: status = %d", err);
+#line 837
+                    }
+#line 837
+                    for (j = 0; j < nels; j++) {
+#line 837
+                        if (inRange3(expect[j],var_type[i],NCT_USHORT)
+#line 837
+                                && expect[j] >= ushort_min 
+#line 837
+				&& expect[j] <= ushort_max) {
+#line 837
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 837
+				    NCT_USHORT)){
+#line 837
+                                error("value read not that expected");
+#line 837
+                                if (verbose) {
+#line 837
+                                    error("\n");
+#line 837
+                                    error("varid: %d, ", i);
+#line 837
+                                    error("var_name: %s, ", var_name[i]);
+#line 837
+                                    error("element number: %d ", j);
+#line 837
+                                    error("expect: %g, ", expect[j]);
+#line 837
+                                    error("got: %g", (double) value[j]);
+#line 837
+                                }
+#line 837
+                            } else {
+#line 837
+                                nok++;
+#line 837
+                            }
+#line 837
+                        }
+#line 837
+                    }
+#line 837
+                } else {
+#line 837
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 837
+                        error("wrong type: status = %d", err);
+#line 837
+                }
+#line 837
+            }
+#line 837
+        }
+#line 837
+    }
+#line 837
+    err = nc_close(ncid);
+#line 837
+    IF (err)
+#line 837
+        error("nc_close: %s", nc_strerror(err));
+#line 837
+    print_nok(nok);
+#line 837
+}
+#line 837
+
+void
+#line 838
+test_nc_get_varm_uint(void)
+#line 838
+{
+#line 838
+    int ncid;
+#line 838
+    int d;
+#line 838
+    int i;
+#line 838
+    int j;
+#line 838
+    int k;
+#line 838
+    int m;
+#line 838
+    int err;
+#line 838
+    int allInExtRange;	/* all values within external range? */
+#line 838
+    int allInIntRange;	/* all values within internal range? */
+#line 838
+    int nels;
+#line 838
+    int nslabs;
+#line 838
+    int nstarts;        /* number of different starts */
+#line 838
+    int nok = 0;      /* count of valid comparisons */
+#line 838
+    size_t start[MAX_RANK];
+#line 838
+    size_t edge[MAX_RANK];
+#line 838
+    size_t index[MAX_RANK];
+#line 838
+    size_t index2[MAX_RANK];
+#line 838
+    size_t mid[MAX_RANK];
+#line 838
+    size_t count[MAX_RANK];
+#line 838
+    size_t sstride[MAX_RANK];
+#line 838
+    ptrdiff_t stride[MAX_RANK];
+#line 838
+    ptrdiff_t imap[MAX_RANK];
+#line 838
+    int canConvert;     /* Both text or both numeric */
+#line 838
+    uint value[MAX_NELS];
+#line 838
+    double expect[MAX_NELS];
+#line 838
+
+#line 838
+#ifdef TEST_PNETCDF
+#line 838
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 838
+#else
+#line 838
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 838
+#endif
+#line 838
+    IF (err)
+#line 838
+        error("nc_open: %s", nc_strerror(err));
+#line 838
+    for (i = 0; i < numVars; i++) {
+#line 838
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+#line 838
+        assert(var_rank[i] <= MAX_RANK);
+#line 838
+        assert(var_nels[i] <= MAX_NELS);
+#line 838
+        for (j = 0; j < var_rank[i]; j++) {
+#line 838
+            start[j] = 0;
+#line 838
+            edge[j] = 1;
+#line 838
+            stride[j] = 1;
+#line 838
+            imap[j] = 1;
+#line 838
+        }
+#line 838
+        err = nc_get_varm_uint(BAD_ID, i, start, edge, stride, imap, value);
+#line 838
+        IF (err != NC_EBADID)
+#line 838
+            error("bad ncid: status = %d", err);
+#line 838
+        err = nc_get_varm_uint(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 838
+        IF (err != NC_ENOTVAR)
+#line 838
+            error("bad var id: status = %d", err);
+#line 838
+        for (j = 0; j < var_rank[i]; j++) {
+#line 838
+            start[j] = var_shape[i][j];
+#line 838
+            err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+#line 838
+	  if(!canConvert) {
+#line 838
+		IF (err != NC_ECHAR)
+#line 838
+               	    error("conversion: status = %d", err);
+#line 838
+	  } else {
+#line 838
+	    IF (err != NC_EINVALCOORDS)
+#line 838
+                error("bad index: status = %d", err);
+#line 838
+            start[j] = 0;
+#line 838
+            edge[j] = var_shape[i][j] + 1;
+#line 838
+            err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+#line 838
+            IF (err != NC_EEDGE)
+#line 838
+                error("bad edge: status = %d", err);
+#line 838
+            edge[j] = 1;
+#line 838
+            stride[j] = 0;
+#line 838
+            err = nc_get_varm_uint(ncid, i, start, edge, stride, imap, value);
+#line 838
+            IF (err != NC_ESTRIDE)
+#line 838
+                error("bad stride: status = %d", err);
+#line 838
+            stride[j] = 1;
+#line 838
+           }
+#line 838
+        }
+#line 838
+            /* Choose a random point dividing each dim into 2 parts */
+#line 838
+            /* get 2^rank (nslabs) slabs so defined */
+#line 838
+        nslabs = 1;
+#line 838
+        for (j = 0; j < var_rank[i]; j++) {
+#line 838
+            mid[j] = roll( var_shape[i][j] );
+#line 838
+            nslabs *= 2;
+#line 838
+        }
+#line 838
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 838
+            /* choose random stride from 1 to edge */
+#line 838
+        for (k = 0; k < nslabs; k++) {
+#line 838
+            nstarts = 1;
+#line 838
+            for (j = 0; j < var_rank[i]; j++) {
+#line 838
+                if ((k >> j) & 1) {
+#line 838
+                    start[j] = 0;
+#line 838
+                    edge[j] = mid[j];
+#line 838
+                }else{
+#line 838
+                    start[j] = mid[j];
+#line 838
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 838
+                }
+#line 838
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 838
+                nstarts *= stride[j];
+#line 838
+            }
+#line 838
+            for (m = 0; m < nstarts; m++) {
+#line 838
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 838
+                IF (err)
+#line 838
+                    error("error in toMixedBase");
+#line 838
+                nels = 1;
+#line 838
+                for (j = 0; j < var_rank[i]; j++) {
+#line 838
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 838
+                    nels *= count[j];
+#line 838
+                    index[j] += start[j];
+#line 838
+                }
+#line 838
+		    /* Random choice of forward or backward */
+#line 838
+/* TODO
+#line 838
+		if ( roll(2) ) {
+#line 838
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 838
+			index[j] += (count[j] - 1) * stride[j];
+#line 838
+			stride[j] = -stride[j];
+#line 838
+		    }
+#line 838
+		}
+#line 838
+ */
+#line 838
+		if (var_rank[i] > 0) {
+#line 838
+		    j = var_rank[i] - 1;
+#line 838
+		    imap[j] = 1;
+#line 838
+		    for (; j > 0; j--)
+#line 838
+			imap[j-1] = imap[j] * count[j];
+#line 838
+		}
+#line 838
+                allInExtRange = allInIntRange = 1;
+#line 838
+                for (j = 0; j < nels; j++) {
+#line 838
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 838
+                    IF (err)
+#line 838
+                        error("error in toMixedBase 1");
+#line 838
+                    for (d = 0; d < var_rank[i]; d++)
+#line 838
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 838
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 838
+                        NCT_UINT);
+#line 838
+                    if (inRange3(expect[j],var_type[i],NCT_UINT)) {
+#line 838
+                        allInIntRange = allInIntRange && expect[j] >= uint_min
+#line 838
+                            && expect[j] <= uint_max;
+#line 838
+                    } else {
+#line 838
+                        allInExtRange = 0;
+#line 838
+                    }
+#line 838
+                }
+#line 838
+                if (var_rank[i] == 0 && i%2 )
+#line 838
+                    err = nc_get_varm_uint(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 838
+                else
+#line 838
+                    err = nc_get_varm_uint(ncid,i,index,count,stride,imap,value);
+#line 838
+                if (canConvert) {
+#line 838
+                    if (allInExtRange) {
+#line 838
+                        if (allInIntRange) {
+#line 838
+                            IF (err)
+#line 838
+                                error("%s", nc_strerror(err));
+#line 838
+                        } else {
+#line 838
+                            IF (err != NC_ERANGE)
+#line 838
+                                error("Range error: status = %d", err);
+#line 838
+                        }
+#line 838
+                    } else {
+#line 838
+                        IF (err != 0 && err != NC_ERANGE)
+#line 838
+                            error("OK or Range error: status = %d", err);
+#line 838
+                    }
+#line 838
+                    for (j = 0; j < nels; j++) {
+#line 838
+                        if (inRange3(expect[j],var_type[i],NCT_UINT)
+#line 838
+                                && expect[j] >= uint_min 
+#line 838
+				&& expect[j] <= uint_max) {
+#line 838
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 838
+				    NCT_UINT)){
+#line 838
+                                error("value read not that expected");
+#line 838
+                                if (verbose) {
+#line 838
+                                    error("\n");
+#line 838
+                                    error("varid: %d, ", i);
+#line 838
+                                    error("var_name: %s, ", var_name[i]);
+#line 838
+                                    error("element number: %d ", j);
+#line 838
+                                    error("expect: %g, ", expect[j]);
+#line 838
+                                    error("got: %g", (double) value[j]);
+#line 838
+                                }
+#line 838
+                            } else {
+#line 838
+                                nok++;
+#line 838
+                            }
+#line 838
+                        }
+#line 838
+                    }
+#line 838
+                } else {
+#line 838
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 838
+                        error("wrong type: status = %d", err);
+#line 838
+                }
+#line 838
+            }
+#line 838
+        }
+#line 838
+    }
+#line 838
+    err = nc_close(ncid);
+#line 838
+    IF (err)
+#line 838
+        error("nc_close: %s", nc_strerror(err));
+#line 838
+    print_nok(nok);
+#line 838
+}
+#line 838
+
+void
+#line 839
+test_nc_get_varm_longlong(void)
+#line 839
+{
+#line 839
+    int ncid;
+#line 839
+    int d;
+#line 839
+    int i;
+#line 839
+    int j;
+#line 839
+    int k;
+#line 839
+    int m;
+#line 839
+    int err;
+#line 839
+    int allInExtRange;	/* all values within external range? */
+#line 839
+    int allInIntRange;	/* all values within internal range? */
+#line 839
+    int nels;
+#line 839
+    int nslabs;
+#line 839
+    int nstarts;        /* number of different starts */
+#line 839
+    int nok = 0;      /* count of valid comparisons */
+#line 839
+    size_t start[MAX_RANK];
+#line 839
+    size_t edge[MAX_RANK];
+#line 839
+    size_t index[MAX_RANK];
+#line 839
+    size_t index2[MAX_RANK];
+#line 839
+    size_t mid[MAX_RANK];
+#line 839
+    size_t count[MAX_RANK];
+#line 839
+    size_t sstride[MAX_RANK];
+#line 839
+    ptrdiff_t stride[MAX_RANK];
+#line 839
+    ptrdiff_t imap[MAX_RANK];
+#line 839
+    int canConvert;     /* Both text or both numeric */
+#line 839
+    longlong value[MAX_NELS];
+#line 839
+    double expect[MAX_NELS];
+#line 839
+
+#line 839
+#ifdef TEST_PNETCDF
+#line 839
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 839
+#else
+#line 839
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 839
+#endif
+#line 839
+    IF (err)
+#line 839
+        error("nc_open: %s", nc_strerror(err));
+#line 839
+    for (i = 0; i < numVars; i++) {
+#line 839
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+#line 839
+        assert(var_rank[i] <= MAX_RANK);
+#line 839
+        assert(var_nels[i] <= MAX_NELS);
+#line 839
+        for (j = 0; j < var_rank[i]; j++) {
+#line 839
+            start[j] = 0;
+#line 839
+            edge[j] = 1;
+#line 839
+            stride[j] = 1;
+#line 839
+            imap[j] = 1;
+#line 839
+        }
+#line 839
+        err = nc_get_varm_longlong(BAD_ID, i, start, edge, stride, imap, value);
+#line 839
+        IF (err != NC_EBADID)
+#line 839
+            error("bad ncid: status = %d", err);
+#line 839
+        err = nc_get_varm_longlong(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 839
+        IF (err != NC_ENOTVAR)
+#line 839
+            error("bad var id: status = %d", err);
+#line 839
+        for (j = 0; j < var_rank[i]; j++) {
+#line 839
+            start[j] = var_shape[i][j];
+#line 839
+            err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+#line 839
+	  if(!canConvert) {
+#line 839
+		IF (err != NC_ECHAR)
+#line 839
+               	    error("conversion: status = %d", err);
+#line 839
+	  } else {
+#line 839
+	    IF (err != NC_EINVALCOORDS)
+#line 839
+                error("bad index: status = %d", err);
+#line 839
+            start[j] = 0;
+#line 839
+            edge[j] = var_shape[i][j] + 1;
+#line 839
+            err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+#line 839
+            IF (err != NC_EEDGE)
+#line 839
+                error("bad edge: status = %d", err);
+#line 839
+            edge[j] = 1;
+#line 839
+            stride[j] = 0;
+#line 839
+            err = nc_get_varm_longlong(ncid, i, start, edge, stride, imap, value);
+#line 839
+            IF (err != NC_ESTRIDE)
+#line 839
+                error("bad stride: status = %d", err);
+#line 839
+            stride[j] = 1;
+#line 839
+           }
+#line 839
+        }
+#line 839
+            /* Choose a random point dividing each dim into 2 parts */
+#line 839
+            /* get 2^rank (nslabs) slabs so defined */
+#line 839
+        nslabs = 1;
+#line 839
+        for (j = 0; j < var_rank[i]; j++) {
+#line 839
+            mid[j] = roll( var_shape[i][j] );
+#line 839
+            nslabs *= 2;
+#line 839
+        }
+#line 839
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 839
+            /* choose random stride from 1 to edge */
+#line 839
+        for (k = 0; k < nslabs; k++) {
+#line 839
+            nstarts = 1;
+#line 839
+            for (j = 0; j < var_rank[i]; j++) {
+#line 839
+                if ((k >> j) & 1) {
+#line 839
+                    start[j] = 0;
+#line 839
+                    edge[j] = mid[j];
+#line 839
+                }else{
+#line 839
+                    start[j] = mid[j];
+#line 839
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 839
+                }
+#line 839
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 839
+                nstarts *= stride[j];
+#line 839
+            }
+#line 839
+            for (m = 0; m < nstarts; m++) {
+#line 839
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 839
+                IF (err)
+#line 839
+                    error("error in toMixedBase");
+#line 839
+                nels = 1;
+#line 839
+                for (j = 0; j < var_rank[i]; j++) {
+#line 839
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 839
+                    nels *= count[j];
+#line 839
+                    index[j] += start[j];
+#line 839
+                }
+#line 839
+		    /* Random choice of forward or backward */
+#line 839
+/* TODO
+#line 839
+		if ( roll(2) ) {
+#line 839
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 839
+			index[j] += (count[j] - 1) * stride[j];
+#line 839
+			stride[j] = -stride[j];
+#line 839
+		    }
+#line 839
+		}
+#line 839
+ */
+#line 839
+		if (var_rank[i] > 0) {
+#line 839
+		    j = var_rank[i] - 1;
+#line 839
+		    imap[j] = 1;
+#line 839
+		    for (; j > 0; j--)
+#line 839
+			imap[j-1] = imap[j] * count[j];
+#line 839
+		}
+#line 839
+                allInExtRange = allInIntRange = 1;
+#line 839
+                for (j = 0; j < nels; j++) {
+#line 839
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 839
+                    IF (err)
+#line 839
+                        error("error in toMixedBase 1");
+#line 839
+                    for (d = 0; d < var_rank[i]; d++)
+#line 839
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 839
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 839
+                        NCT_LONGLONG);
+#line 839
+                    if (inRange3(expect[j],var_type[i],NCT_LONGLONG)) {
+#line 839
+                        allInIntRange = allInIntRange && expect[j] >= longlong_min
+#line 839
+                            && expect[j] <= longlong_max;
+#line 839
+                    } else {
+#line 839
+                        allInExtRange = 0;
+#line 839
+                    }
+#line 839
+                }
+#line 839
+                if (var_rank[i] == 0 && i%2 )
+#line 839
+                    err = nc_get_varm_longlong(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 839
+                else
+#line 839
+                    err = nc_get_varm_longlong(ncid,i,index,count,stride,imap,value);
+#line 839
+                if (canConvert) {
+#line 839
+                    if (allInExtRange) {
+#line 839
+                        if (allInIntRange) {
+#line 839
+                            IF (err)
+#line 839
+                                error("%s", nc_strerror(err));
+#line 839
+                        } else {
+#line 839
+                            IF (err != NC_ERANGE)
+#line 839
+                                error("Range error: status = %d", err);
+#line 839
+                        }
+#line 839
+                    } else {
+#line 839
+                        IF (err != 0 && err != NC_ERANGE)
+#line 839
+                            error("OK or Range error: status = %d", err);
+#line 839
+                    }
+#line 839
+                    for (j = 0; j < nels; j++) {
+#line 839
+                        if (inRange3(expect[j],var_type[i],NCT_LONGLONG)
+#line 839
+                                && expect[j] >= longlong_min 
+#line 839
+				&& expect[j] <= longlong_max) {
+#line 839
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 839
+				    NCT_LONGLONG)){
+#line 839
+                                error("value read not that expected");
+#line 839
+                                if (verbose) {
+#line 839
+                                    error("\n");
+#line 839
+                                    error("varid: %d, ", i);
+#line 839
+                                    error("var_name: %s, ", var_name[i]);
+#line 839
+                                    error("element number: %d ", j);
+#line 839
+                                    error("expect: %g, ", expect[j]);
+#line 839
+                                    error("got: %g", (double) value[j]);
+#line 839
+                                }
+#line 839
+                            } else {
+#line 839
+                                nok++;
+#line 839
+                            }
+#line 839
+                        }
+#line 839
+                    }
+#line 839
+                } else {
+#line 839
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 839
+                        error("wrong type: status = %d", err);
+#line 839
+                }
+#line 839
+            }
+#line 839
+        }
+#line 839
+    }
+#line 839
+    err = nc_close(ncid);
+#line 839
+    IF (err)
+#line 839
+        error("nc_close: %s", nc_strerror(err));
+#line 839
+    print_nok(nok);
+#line 839
+}
+#line 839
+
+void
+#line 840
+test_nc_get_varm_ulonglong(void)
+#line 840
+{
+#line 840
+    int ncid;
+#line 840
+    int d;
+#line 840
+    int i;
+#line 840
+    int j;
+#line 840
+    int k;
+#line 840
+    int m;
+#line 840
+    int err;
+#line 840
+    int allInExtRange;	/* all values within external range? */
+#line 840
+    int allInIntRange;	/* all values within internal range? */
+#line 840
+    int nels;
+#line 840
+    int nslabs;
+#line 840
+    int nstarts;        /* number of different starts */
+#line 840
+    int nok = 0;      /* count of valid comparisons */
+#line 840
+    size_t start[MAX_RANK];
+#line 840
+    size_t edge[MAX_RANK];
+#line 840
+    size_t index[MAX_RANK];
+#line 840
+    size_t index2[MAX_RANK];
+#line 840
+    size_t mid[MAX_RANK];
+#line 840
+    size_t count[MAX_RANK];
+#line 840
+    size_t sstride[MAX_RANK];
+#line 840
+    ptrdiff_t stride[MAX_RANK];
+#line 840
+    ptrdiff_t imap[MAX_RANK];
+#line 840
+    int canConvert;     /* Both text or both numeric */
+#line 840
+    ulonglong value[MAX_NELS];
+#line 840
+    double expect[MAX_NELS];
+#line 840
+
+#line 840
+#ifdef TEST_PNETCDF
+#line 840
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 840
+#else
+#line 840
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 840
+#endif
+#line 840
+    IF (err)
+#line 840
+        error("nc_open: %s", nc_strerror(err));
+#line 840
+    for (i = 0; i < numVars; i++) {
+#line 840
+        canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+#line 840
+        assert(var_rank[i] <= MAX_RANK);
+#line 840
+        assert(var_nels[i] <= MAX_NELS);
+#line 840
+        for (j = 0; j < var_rank[i]; j++) {
+#line 840
+            start[j] = 0;
+#line 840
+            edge[j] = 1;
+#line 840
+            stride[j] = 1;
+#line 840
+            imap[j] = 1;
+#line 840
+        }
+#line 840
+        err = nc_get_varm_ulonglong(BAD_ID, i, start, edge, stride, imap, value);
+#line 840
+        IF (err != NC_EBADID)
+#line 840
+            error("bad ncid: status = %d", err);
+#line 840
+        err = nc_get_varm_ulonglong(ncid, BAD_VARID, start, edge, stride, imap, value);
+#line 840
+        IF (err != NC_ENOTVAR)
+#line 840
+            error("bad var id: status = %d", err);
+#line 840
+        for (j = 0; j < var_rank[i]; j++) {
+#line 840
+            start[j] = var_shape[i][j];
+#line 840
+            err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+#line 840
+	  if(!canConvert) {
+#line 840
+		IF (err != NC_ECHAR)
+#line 840
+               	    error("conversion: status = %d", err);
+#line 840
+	  } else {
+#line 840
+	    IF (err != NC_EINVALCOORDS)
+#line 840
+                error("bad index: status = %d", err);
+#line 840
+            start[j] = 0;
+#line 840
+            edge[j] = var_shape[i][j] + 1;
+#line 840
+            err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+#line 840
+            IF (err != NC_EEDGE)
+#line 840
+                error("bad edge: status = %d", err);
+#line 840
+            edge[j] = 1;
+#line 840
+            stride[j] = 0;
+#line 840
+            err = nc_get_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
+#line 840
+            IF (err != NC_ESTRIDE)
+#line 840
+                error("bad stride: status = %d", err);
+#line 840
+            stride[j] = 1;
+#line 840
+           }
+#line 840
+        }
+#line 840
+            /* Choose a random point dividing each dim into 2 parts */
+#line 840
+            /* get 2^rank (nslabs) slabs so defined */
+#line 840
+        nslabs = 1;
+#line 840
+        for (j = 0; j < var_rank[i]; j++) {
+#line 840
+            mid[j] = roll( var_shape[i][j] );
+#line 840
+            nslabs *= 2;
+#line 840
+        }
+#line 840
+            /* bits of k determine whether to get lower or upper part of dim */
+#line 840
+            /* choose random stride from 1 to edge */
+#line 840
+        for (k = 0; k < nslabs; k++) {
+#line 840
+            nstarts = 1;
+#line 840
+            for (j = 0; j < var_rank[i]; j++) {
+#line 840
+                if ((k >> j) & 1) {
+#line 840
+                    start[j] = 0;
+#line 840
+                    edge[j] = mid[j];
+#line 840
+                }else{
+#line 840
+                    start[j] = mid[j];
+#line 840
+                    edge[j] = var_shape[i][j] - mid[j];
+#line 840
+                }
+#line 840
+                sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+#line 840
+                nstarts *= stride[j];
+#line 840
+            }
+#line 840
+            for (m = 0; m < nstarts; m++) {
+#line 840
+                err = toMixedBase(m, var_rank[i], sstride, index);
+#line 840
+                IF (err)
+#line 840
+                    error("error in toMixedBase");
+#line 840
+                nels = 1;
+#line 840
+                for (j = 0; j < var_rank[i]; j++) {
+#line 840
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+#line 840
+                    nels *= count[j];
+#line 840
+                    index[j] += start[j];
+#line 840
+                }
+#line 840
+		    /* Random choice of forward or backward */
+#line 840
+/* TODO
+#line 840
+		if ( roll(2) ) {
+#line 840
+		    for (j = 0; j < var_rank[i]; j++) {
+#line 840
+			index[j] += (count[j] - 1) * stride[j];
+#line 840
+			stride[j] = -stride[j];
+#line 840
+		    }
+#line 840
+		}
+#line 840
+ */
+#line 840
+		if (var_rank[i] > 0) {
+#line 840
+		    j = var_rank[i] - 1;
+#line 840
+		    imap[j] = 1;
+#line 840
+		    for (; j > 0; j--)
+#line 840
+			imap[j-1] = imap[j] * count[j];
+#line 840
+		}
+#line 840
+                allInExtRange = allInIntRange = 1;
+#line 840
+                for (j = 0; j < nels; j++) {
+#line 840
+                    err = toMixedBase(j, var_rank[i], count, index2);
+#line 840
+                    IF (err)
+#line 840
+                        error("error in toMixedBase 1");
+#line 840
+                    for (d = 0; d < var_rank[i]; d++)
+#line 840
+                        index2[d] = index[d] + index2[d] * stride[d];
+#line 840
+                    expect[j] = hash4(var_type[i], var_rank[i], index2,
+#line 840
+                        NCT_ULONGLONG);
+#line 840
+                    if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)) {
+#line 840
+                        allInIntRange = allInIntRange && expect[j] >= ulonglong_min
+#line 840
+                            && expect[j] <= ulonglong_max;
+#line 840
+                    } else {
+#line 840
+                        allInExtRange = 0;
+#line 840
+                    }
+#line 840
+                }
+#line 840
+                if (var_rank[i] == 0 && i%2 )
+#line 840
+                    err = nc_get_varm_ulonglong(ncid,i,NULL,NULL,NULL,NULL,value);
+#line 840
+                else
+#line 840
+                    err = nc_get_varm_ulonglong(ncid,i,index,count,stride,imap,value);
+#line 840
+                if (canConvert) {
+#line 840
+                    if (allInExtRange) {
+#line 840
+                        if (allInIntRange) {
+#line 840
+                            IF (err)
+#line 840
+                                error("%s", nc_strerror(err));
+#line 840
+                        } else {
+#line 840
+                            IF (err != NC_ERANGE)
+#line 840
+                                error("Range error: status = %d", err);
+#line 840
+                        }
+#line 840
+                    } else {
+#line 840
+                        IF (err != 0 && err != NC_ERANGE)
+#line 840
+                            error("OK or Range error: status = %d", err);
+#line 840
+                    }
+#line 840
+                    for (j = 0; j < nels; j++) {
+#line 840
+                        if (inRange3(expect[j],var_type[i],NCT_ULONGLONG)
+#line 840
+                                && expect[j] >= ulonglong_min 
+#line 840
+				&& expect[j] <= ulonglong_max) {
+#line 840
+			    IF (!equal(value[j],expect[j],var_type[i],
+#line 840
+				    NCT_ULONGLONG)){
+#line 840
+                                error("value read not that expected");
+#line 840
+                                if (verbose) {
+#line 840
+                                    error("\n");
+#line 840
+                                    error("varid: %d, ", i);
+#line 840
+                                    error("var_name: %s, ", var_name[i]);
+#line 840
+                                    error("element number: %d ", j);
+#line 840
+                                    error("expect: %g, ", expect[j]);
+#line 840
+                                    error("got: %g", (double) value[j]);
+#line 840
+                                }
+#line 840
+                            } else {
+#line 840
+                                nok++;
+#line 840
+                            }
+#line 840
+                        }
+#line 840
+                    }
+#line 840
+                } else {
+#line 840
+                    IF (nels > 0 && err != NC_ECHAR)
+#line 840
+                        error("wrong type: status = %d", err);
+#line 840
+                }
+#line 840
+            }
+#line 840
+        }
+#line 840
+    }
+#line 840
+    err = nc_close(ncid);
+#line 840
+    IF (err)
+#line 840
+        error("nc_close: %s", nc_strerror(err));
+#line 840
+    print_nok(nok);
+#line 840
+}
+#line 840
+
+
+
+#line 938
+
+void
+#line 939
+test_nc_get_att_text(void)
+#line 939
+{
+#line 939
+    int ncid;
+#line 939
+    int i;
+#line 939
+    int j;
+#line 939
+    size_t k;
+#line 939
+    int err;
+#line 939
+    int allInExtRange;
+#line 939
+    int allInIntRange;
+#line 939
+    int canConvert;     /* Both text or both numeric */
+#line 939
+    text value[MAX_NELS];
+#line 939
+    double expect[MAX_NELS];
+#line 939
+    int nok = 0;      /* count of valid comparisons */
+#line 939
+
+#line 939
+#ifdef TEST_PNETCDF
+#line 939
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 939
+#else
+#line 939
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 939
+#endif
+#line 939
+    IF (err) 
+#line 939
+	error("nc_open: %s", nc_strerror(err));
+#line 939
+
+#line 939
+    for (i = -1; i < numVars; i++) {
+#line 939
+        for (j = 0; j < NATTS(i); j++) {
+#line 939
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+#line 939
+	    err = nc_get_att_text(BAD_ID, i, ATT_NAME(i,j), value);
+#line 939
+	    IF (err != NC_EBADID) 
+#line 939
+		error("bad ncid: status = %d", err);
+#line 939
+	    err = nc_get_att_text(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 939
+	    IF (err != NC_ENOTVAR) 
+#line 939
+		error("bad var id: status = %d", err);
+#line 939
+	    err = nc_get_att_text(ncid, i, "noSuch", value);
+#line 939
+	    IF (err != NC_ENOTATT) 
+#line 939
+		error("Bad attribute name: status = %d", err);
+#line 939
+	    allInExtRange = allInIntRange = 1;
+#line 939
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 939
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_TEXT);
+#line 939
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)) {
+#line 939
+                    allInIntRange = allInIntRange && expect[k] >= text_min
+#line 939
+                                && expect[k] <= text_max;
+#line 939
+                } else {
+#line 939
+                    allInExtRange = 0;
+#line 939
+                }
+#line 939
+	    }
+#line 939
+	    err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value);
+#line 939
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 939
+                if (allInExtRange) {
+#line 939
+                    if (allInIntRange) {
+#line 939
+                        IF (err)
+#line 939
+                            error("%s", nc_strerror(err));
+#line 939
+                    } else {
+#line 939
+                        IF (err != NC_ERANGE)
+#line 939
+                            error("Range error: status = %d", err);
+#line 939
+                    }
+#line 939
+                } else {
+#line 939
+                    IF (err != 0 && err != NC_ERANGE)
+#line 939
+                        error("OK or Range error: status = %d", err);
+#line 939
+                }
+#line 939
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 939
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_TEXT)
+#line 939
+                            && expect[k] >= text_min && expect[k] <= text_max) {
+#line 939
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 939
+				NCT_TEXT)){
+#line 939
+			    error("value read not that expected");
+#line 939
+                            if (verbose) {
+#line 939
+                                error("\n");
+#line 939
+                                error("varid: %d, ", i);
+#line 939
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 939
+                                error("element number: %d ", k);
+#line 939
+                                error("expect: %g", expect[k]);
+#line 939
+                                error("got: %g", (double) value[k]);
+#line 939
+                            }
+#line 939
+			} else {
+#line 939
+			    nok++;
+#line 939
+                        }
+#line 939
+		    }
+#line 939
+		}
+#line 939
+	    } else {
+#line 939
+		IF (err != NC_ECHAR)
+#line 939
+		    error("wrong type: status = %d", err);
+#line 939
+	    }
+#line 939
+	}
+#line 939
+    }
+#line 939
+
+#line 939
+    err = nc_close(ncid);
+#line 939
+    IF (err)
+#line 939
+	error("nc_close: %s", nc_strerror(err));
+#line 939
+    print_nok(nok);
+#line 939
+}
+#line 939
+
+void
+#line 940
+test_nc_get_att_uchar(void)
+#line 940
+{
+#line 940
+    int ncid;
+#line 940
+    int i;
+#line 940
+    int j;
+#line 940
+    size_t k;
+#line 940
+    int err;
+#line 940
+    int allInExtRange;
+#line 940
+    int allInIntRange;
+#line 940
+    int canConvert;     /* Both text or both numeric */
+#line 940
+    uchar value[MAX_NELS];
+#line 940
+    double expect[MAX_NELS];
+#line 940
+    int nok = 0;      /* count of valid comparisons */
+#line 940
+
+#line 940
+#ifdef TEST_PNETCDF
+#line 940
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 940
+#else
+#line 940
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 940
+#endif
+#line 940
+    IF (err) 
+#line 940
+	error("nc_open: %s", nc_strerror(err));
+#line 940
+
+#line 940
+    for (i = -1; i < numVars; i++) {
+#line 940
+        for (j = 0; j < NATTS(i); j++) {
+#line 940
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+#line 940
+	    err = nc_get_att_uchar(BAD_ID, i, ATT_NAME(i,j), value);
+#line 940
+	    IF (err != NC_EBADID) 
+#line 940
+		error("bad ncid: status = %d", err);
+#line 940
+	    err = nc_get_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 940
+	    IF (err != NC_ENOTVAR) 
+#line 940
+		error("bad var id: status = %d", err);
+#line 940
+	    err = nc_get_att_uchar(ncid, i, "noSuch", value);
+#line 940
+	    IF (err != NC_ENOTATT) 
+#line 940
+		error("Bad attribute name: status = %d", err);
+#line 940
+	    allInExtRange = allInIntRange = 1;
+#line 940
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 940
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_UCHAR);
+#line 940
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)) {
+#line 940
+                    allInIntRange = allInIntRange && expect[k] >= uchar_min
+#line 940
+                                && expect[k] <= uchar_max;
+#line 940
+                } else {
+#line 940
+                    allInExtRange = 0;
+#line 940
+                }
+#line 940
+	    }
+#line 940
+	    err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
+#line 940
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 940
+                if (allInExtRange) {
+#line 940
+                    if (allInIntRange) {
+#line 940
+                        IF (err)
+#line 940
+                            error("%s", nc_strerror(err));
+#line 940
+                    } else {
+#line 940
+                        IF (err != NC_ERANGE)
+#line 940
+                            error("Range error: status = %d", err);
+#line 940
+                    }
+#line 940
+                } else {
+#line 940
+                    IF (err != 0 && err != NC_ERANGE)
+#line 940
+                        error("OK or Range error: status = %d", err);
+#line 940
+                }
+#line 940
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 940
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UCHAR)
+#line 940
+                            && expect[k] >= uchar_min && expect[k] <= uchar_max) {
+#line 940
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 940
+				NCT_UCHAR)){
+#line 940
+			    error("value read not that expected");
+#line 940
+                            if (verbose) {
+#line 940
+                                error("\n");
+#line 940
+                                error("varid: %d, ", i);
+#line 940
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 940
+                                error("element number: %d ", k);
+#line 940
+                                error("expect: %g", expect[k]);
+#line 940
+                                error("got: %g", (double) value[k]);
+#line 940
+                            }
+#line 940
+			} else {
+#line 940
+			    nok++;
+#line 940
+                        }
+#line 940
+		    }
+#line 940
+		}
+#line 940
+	    } else {
+#line 940
+		IF (err != NC_ECHAR)
+#line 940
+		    error("wrong type: status = %d", err);
+#line 940
+	    }
+#line 940
+	}
+#line 940
+    }
+#line 940
+
+#line 940
+    err = nc_close(ncid);
+#line 940
+    IF (err)
+#line 940
+	error("nc_close: %s", nc_strerror(err));
+#line 940
+    print_nok(nok);
+#line 940
+}
+#line 940
+
+void
+#line 941
+test_nc_get_att_schar(void)
+#line 941
+{
+#line 941
+    int ncid;
+#line 941
+    int i;
+#line 941
+    int j;
+#line 941
+    size_t k;
+#line 941
+    int err;
+#line 941
+    int allInExtRange;
+#line 941
+    int allInIntRange;
+#line 941
+    int canConvert;     /* Both text or both numeric */
+#line 941
+    schar value[MAX_NELS];
+#line 941
+    double expect[MAX_NELS];
+#line 941
+    int nok = 0;      /* count of valid comparisons */
+#line 941
+
+#line 941
+#ifdef TEST_PNETCDF
+#line 941
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 941
+#else
+#line 941
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 941
+#endif
+#line 941
+    IF (err) 
+#line 941
+	error("nc_open: %s", nc_strerror(err));
+#line 941
+
+#line 941
+    for (i = -1; i < numVars; i++) {
+#line 941
+        for (j = 0; j < NATTS(i); j++) {
+#line 941
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+#line 941
+	    err = nc_get_att_schar(BAD_ID, i, ATT_NAME(i,j), value);
+#line 941
+	    IF (err != NC_EBADID) 
+#line 941
+		error("bad ncid: status = %d", err);
+#line 941
+	    err = nc_get_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 941
+	    IF (err != NC_ENOTVAR) 
+#line 941
+		error("bad var id: status = %d", err);
+#line 941
+	    err = nc_get_att_schar(ncid, i, "noSuch", value);
+#line 941
+	    IF (err != NC_ENOTATT) 
+#line 941
+		error("Bad attribute name: status = %d", err);
+#line 941
+	    allInExtRange = allInIntRange = 1;
+#line 941
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 941
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SCHAR);
+#line 941
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)) {
+#line 941
+                    allInIntRange = allInIntRange && expect[k] >= schar_min
+#line 941
+                                && expect[k] <= schar_max;
+#line 941
+                } else {
+#line 941
+                    allInExtRange = 0;
+#line 941
+                }
+#line 941
+	    }
+#line 941
+	    err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
+#line 941
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 941
+                if (allInExtRange) {
+#line 941
+                    if (allInIntRange) {
+#line 941
+                        IF (err)
+#line 941
+                            error("%s", nc_strerror(err));
+#line 941
+                    } else {
+#line 941
+                        IF (err != NC_ERANGE)
+#line 941
+                            error("Range error: status = %d", err);
+#line 941
+                    }
+#line 941
+                } else {
+#line 941
+                    IF (err != 0 && err != NC_ERANGE)
+#line 941
+                        error("OK or Range error: status = %d", err);
+#line 941
+                }
+#line 941
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 941
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SCHAR)
+#line 941
+                            && expect[k] >= schar_min && expect[k] <= schar_max) {
+#line 941
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 941
+				NCT_SCHAR)){
+#line 941
+			    error("value read not that expected");
+#line 941
+                            if (verbose) {
+#line 941
+                                error("\n");
+#line 941
+                                error("varid: %d, ", i);
+#line 941
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 941
+                                error("element number: %d ", k);
+#line 941
+                                error("expect: %g", expect[k]);
+#line 941
+                                error("got: %g", (double) value[k]);
+#line 941
+                            }
+#line 941
+			} else {
+#line 941
+			    nok++;
+#line 941
+                        }
+#line 941
+		    }
+#line 941
+		}
+#line 941
+	    } else {
+#line 941
+		IF (err != NC_ECHAR)
+#line 941
+		    error("wrong type: status = %d", err);
+#line 941
+	    }
+#line 941
+	}
+#line 941
+    }
+#line 941
+
+#line 941
+    err = nc_close(ncid);
+#line 941
+    IF (err)
+#line 941
+	error("nc_close: %s", nc_strerror(err));
+#line 941
+    print_nok(nok);
+#line 941
+}
+#line 941
+
+void
+#line 942
+test_nc_get_att_short(void)
+#line 942
+{
+#line 942
+    int ncid;
+#line 942
+    int i;
+#line 942
+    int j;
+#line 942
+    size_t k;
+#line 942
+    int err;
+#line 942
+    int allInExtRange;
+#line 942
+    int allInIntRange;
+#line 942
+    int canConvert;     /* Both text or both numeric */
+#line 942
+    short value[MAX_NELS];
+#line 942
+    double expect[MAX_NELS];
+#line 942
+    int nok = 0;      /* count of valid comparisons */
+#line 942
+
+#line 942
+#ifdef TEST_PNETCDF
+#line 942
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 942
+#else
+#line 942
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 942
+#endif
+#line 942
+    IF (err) 
+#line 942
+	error("nc_open: %s", nc_strerror(err));
+#line 942
+
+#line 942
+    for (i = -1; i < numVars; i++) {
+#line 942
+        for (j = 0; j < NATTS(i); j++) {
+#line 942
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+#line 942
+	    err = nc_get_att_short(BAD_ID, i, ATT_NAME(i,j), value);
+#line 942
+	    IF (err != NC_EBADID) 
+#line 942
+		error("bad ncid: status = %d", err);
+#line 942
+	    err = nc_get_att_short(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 942
+	    IF (err != NC_ENOTVAR) 
+#line 942
+		error("bad var id: status = %d", err);
+#line 942
+	    err = nc_get_att_short(ncid, i, "noSuch", value);
+#line 942
+	    IF (err != NC_ENOTATT) 
+#line 942
+		error("Bad attribute name: status = %d", err);
+#line 942
+	    allInExtRange = allInIntRange = 1;
+#line 942
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 942
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_SHORT);
+#line 942
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)) {
+#line 942
+                    allInIntRange = allInIntRange && expect[k] >= short_min
+#line 942
+                                && expect[k] <= short_max;
+#line 942
+                } else {
+#line 942
+                    allInExtRange = 0;
+#line 942
+                }
+#line 942
+	    }
+#line 942
+	    err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
+#line 942
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 942
+                if (allInExtRange) {
+#line 942
+                    if (allInIntRange) {
+#line 942
+                        IF (err)
+#line 942
+                            error("%s", nc_strerror(err));
+#line 942
+                    } else {
+#line 942
+                        IF (err != NC_ERANGE)
+#line 942
+                            error("Range error: status = %d", err);
+#line 942
+                    }
+#line 942
+                } else {
+#line 942
+                    IF (err != 0 && err != NC_ERANGE)
+#line 942
+                        error("OK or Range error: status = %d", err);
+#line 942
+                }
+#line 942
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 942
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_SHORT)
+#line 942
+                            && expect[k] >= short_min && expect[k] <= short_max) {
+#line 942
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 942
+				NCT_SHORT)){
+#line 942
+			    error("value read not that expected");
+#line 942
+                            if (verbose) {
+#line 942
+                                error("\n");
+#line 942
+                                error("varid: %d, ", i);
+#line 942
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 942
+                                error("element number: %d ", k);
+#line 942
+                                error("expect: %g", expect[k]);
+#line 942
+                                error("got: %g", (double) value[k]);
+#line 942
+                            }
+#line 942
+			} else {
+#line 942
+			    nok++;
+#line 942
+                        }
+#line 942
+		    }
+#line 942
+		}
+#line 942
+	    } else {
+#line 942
+		IF (err != NC_ECHAR)
+#line 942
+		    error("wrong type: status = %d", err);
+#line 942
+	    }
+#line 942
+	}
+#line 942
+    }
+#line 942
+
+#line 942
+    err = nc_close(ncid);
+#line 942
+    IF (err)
+#line 942
+	error("nc_close: %s", nc_strerror(err));
+#line 942
+    print_nok(nok);
+#line 942
+}
+#line 942
+
+void
+#line 943
+test_nc_get_att_int(void)
+#line 943
+{
+#line 943
+    int ncid;
+#line 943
+    int i;
+#line 943
+    int j;
+#line 943
+    size_t k;
+#line 943
+    int err;
+#line 943
+    int allInExtRange;
+#line 943
+    int allInIntRange;
+#line 943
+    int canConvert;     /* Both text or both numeric */
+#line 943
+    int value[MAX_NELS];
+#line 943
+    double expect[MAX_NELS];
+#line 943
+    int nok = 0;      /* count of valid comparisons */
+#line 943
+
+#line 943
+#ifdef TEST_PNETCDF
+#line 943
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 943
+#else
+#line 943
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 943
+#endif
+#line 943
+    IF (err) 
+#line 943
+	error("nc_open: %s", nc_strerror(err));
+#line 943
+
+#line 943
+    for (i = -1; i < numVars; i++) {
+#line 943
+        for (j = 0; j < NATTS(i); j++) {
+#line 943
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
+#line 943
+	    err = nc_get_att_int(BAD_ID, i, ATT_NAME(i,j), value);
+#line 943
+	    IF (err != NC_EBADID) 
+#line 943
+		error("bad ncid: status = %d", err);
+#line 943
+	    err = nc_get_att_int(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 943
+	    IF (err != NC_ENOTVAR) 
+#line 943
+		error("bad var id: status = %d", err);
+#line 943
+	    err = nc_get_att_int(ncid, i, "noSuch", value);
+#line 943
+	    IF (err != NC_ENOTATT) 
+#line 943
+		error("Bad attribute name: status = %d", err);
+#line 943
+	    allInExtRange = allInIntRange = 1;
+#line 943
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 943
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_INT);
+#line 943
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)) {
+#line 943
+                    allInIntRange = allInIntRange && expect[k] >= int_min
+#line 943
+                                && expect[k] <= int_max;
+#line 943
+                } else {
+#line 943
+                    allInExtRange = 0;
+#line 943
+                }
+#line 943
+	    }
+#line 943
+	    err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
+#line 943
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 943
+                if (allInExtRange) {
+#line 943
+                    if (allInIntRange) {
+#line 943
+                        IF (err)
+#line 943
+                            error("%s", nc_strerror(err));
+#line 943
+                    } else {
+#line 943
+                        IF (err != NC_ERANGE)
+#line 943
+                            error("Range error: status = %d", err);
+#line 943
+                    }
+#line 943
+                } else {
+#line 943
+                    IF (err != 0 && err != NC_ERANGE)
+#line 943
+                        error("OK or Range error: status = %d", err);
+#line 943
+                }
+#line 943
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 943
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)
+#line 943
+                            && expect[k] >= int_min && expect[k] <= int_max) {
+#line 943
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 943
+				NCT_INT)){
+#line 943
+			    error("value read not that expected");
+#line 943
+                            if (verbose) {
+#line 943
+                                error("\n");
+#line 943
+                                error("varid: %d, ", i);
+#line 943
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 943
+                                error("element number: %d ", k);
+#line 943
+                                error("expect: %g", expect[k]);
+#line 943
+                                error("got: %g", (double) value[k]);
+#line 943
+                            }
+#line 943
+			} else {
+#line 943
+			    nok++;
+#line 943
+                        }
+#line 943
+		    }
+#line 943
+		}
+#line 943
+	    } else {
+#line 943
+		IF (err != NC_ECHAR)
+#line 943
+		    error("wrong type: status = %d", err);
+#line 943
+	    }
+#line 943
+	}
+#line 943
+    }
+#line 943
+
+#line 943
+    err = nc_close(ncid);
+#line 943
+    IF (err)
+#line 943
+	error("nc_close: %s", nc_strerror(err));
+#line 943
+    print_nok(nok);
+#line 943
+}
+#line 943
+
+void
+#line 944
+test_nc_get_att_long(void)
+#line 944
+{
+#line 944
+    int ncid;
+#line 944
+    int i;
+#line 944
+    int j;
+#line 944
+    size_t k;
+#line 944
+    int err;
+#line 944
+    int allInExtRange;
+#line 944
+    int allInIntRange;
+#line 944
+    int canConvert;     /* Both text or both numeric */
+#line 944
+    long value[MAX_NELS];
+#line 944
+    double expect[MAX_NELS];
+#line 944
+    int nok = 0;      /* count of valid comparisons */
+#line 944
+
+#line 944
+#ifdef TEST_PNETCDF
+#line 944
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 944
+#else
+#line 944
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 944
+#endif
+#line 944
+    IF (err) 
+#line 944
+	error("nc_open: %s", nc_strerror(err));
+#line 944
+
+#line 944
+    for (i = -1; i < numVars; i++) {
+#line 944
+        for (j = 0; j < NATTS(i); j++) {
+#line 944
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+#line 944
+	    err = nc_get_att_long(BAD_ID, i, ATT_NAME(i,j), value);
+#line 944
+	    IF (err != NC_EBADID) 
+#line 944
+		error("bad ncid: status = %d", err);
+#line 944
+	    err = nc_get_att_long(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 944
+	    IF (err != NC_ENOTVAR) 
+#line 944
+		error("bad var id: status = %d", err);
+#line 944
+	    err = nc_get_att_long(ncid, i, "noSuch", value);
+#line 944
+	    IF (err != NC_ENOTATT) 
+#line 944
+		error("Bad attribute name: status = %d", err);
+#line 944
+	    allInExtRange = allInIntRange = 1;
+#line 944
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 944
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_LONG);
+#line 944
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)) {
+#line 944
+                    allInIntRange = allInIntRange && expect[k] >= long_min
+#line 944
+                                && expect[k] <= long_max;
+#line 944
+                } else {
+#line 944
+                    allInExtRange = 0;
+#line 944
+                }
+#line 944
+	    }
+#line 944
+	    err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
+#line 944
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 944
+                if (allInExtRange) {
+#line 944
+                    if (allInIntRange) {
+#line 944
+                        IF (err)
+#line 944
+                            error("%s", nc_strerror(err));
+#line 944
+                    } else {
+#line 944
+                        IF (err != NC_ERANGE)
+#line 944
+                            error("Range error: status = %d", err);
+#line 944
+                    }
+#line 944
+                } else {
+#line 944
+                    IF (err != 0 && err != NC_ERANGE)
+#line 944
+                        error("OK or Range error: status = %d", err);
+#line 944
+                }
+#line 944
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 944
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)
+#line 944
+                            && expect[k] >= long_min && expect[k] <= long_max) {
+#line 944
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 944
+				NCT_LONG)){
+#line 944
+			    error("value read not that expected");
+#line 944
+                            if (verbose) {
+#line 944
+                                error("\n");
+#line 944
+                                error("varid: %d, ", i);
+#line 944
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 944
+                                error("element number: %d ", k);
+#line 944
+                                error("expect: %g", expect[k]);
+#line 944
+                                error("got: %g", (double) value[k]);
+#line 944
+                            }
+#line 944
+			} else {
+#line 944
+			    nok++;
+#line 944
+                        }
+#line 944
+		    }
+#line 944
+		}
+#line 944
+	    } else {
+#line 944
+		IF (err != NC_ECHAR)
+#line 944
+		    error("wrong type: status = %d", err);
+#line 944
+	    }
+#line 944
+	}
+#line 944
+    }
+#line 944
+
+#line 944
+    err = nc_close(ncid);
+#line 944
+    IF (err)
+#line 944
+	error("nc_close: %s", nc_strerror(err));
+#line 944
+    print_nok(nok);
+#line 944
+}
+#line 944
+
+void
+#line 945
+test_nc_get_att_float(void)
+#line 945
+{
+#line 945
+    int ncid;
+#line 945
+    int i;
+#line 945
+    int j;
+#line 945
+    size_t k;
+#line 945
+    int err;
+#line 945
+    int allInExtRange;
+#line 945
+    int allInIntRange;
+#line 945
+    int canConvert;     /* Both text or both numeric */
+#line 945
+    float value[MAX_NELS];
+#line 945
+    double expect[MAX_NELS];
+#line 945
+    int nok = 0;      /* count of valid comparisons */
+#line 945
+
+#line 945
+#ifdef TEST_PNETCDF
+#line 945
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 945
+#else
+#line 945
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 945
+#endif
+#line 945
+    IF (err) 
+#line 945
+	error("nc_open: %s", nc_strerror(err));
+#line 945
+
+#line 945
+    for (i = -1; i < numVars; i++) {
+#line 945
+        for (j = 0; j < NATTS(i); j++) {
+#line 945
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+#line 945
+	    err = nc_get_att_float(BAD_ID, i, ATT_NAME(i,j), value);
+#line 945
+	    IF (err != NC_EBADID) 
+#line 945
+		error("bad ncid: status = %d", err);
+#line 945
+	    err = nc_get_att_float(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 945
+	    IF (err != NC_ENOTVAR) 
+#line 945
+		error("bad var id: status = %d", err);
+#line 945
+	    err = nc_get_att_float(ncid, i, "noSuch", value);
+#line 945
+	    IF (err != NC_ENOTATT) 
+#line 945
+		error("Bad attribute name: status = %d", err);
+#line 945
+	    allInExtRange = allInIntRange = 1;
+#line 945
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 945
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_FLOAT);
+#line 945
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)) {
+#line 945
+                    allInIntRange = allInIntRange && expect[k] >= float_min
+#line 945
+                                && expect[k] <= float_max;
+#line 945
+                } else {
+#line 945
+                    allInExtRange = 0;
+#line 945
+                }
+#line 945
+	    }
+#line 945
+	    err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
+#line 945
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 945
+                if (allInExtRange) {
+#line 945
+                    if (allInIntRange) {
+#line 945
+                        IF (err)
+#line 945
+                            error("%s", nc_strerror(err));
+#line 945
+                    } else {
+#line 945
+                        IF (err != NC_ERANGE)
+#line 945
+                            error("Range error: status = %d", err);
+#line 945
+                    }
+#line 945
+                } else {
+#line 945
+                    IF (err != 0 && err != NC_ERANGE)
+#line 945
+                        error("OK or Range error: status = %d", err);
+#line 945
+                }
+#line 945
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 945
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)
+#line 945
+                            && expect[k] >= float_min && expect[k] <= float_max) {
+#line 945
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 945
+				NCT_FLOAT)){
+#line 945
+			    error("value read not that expected");
+#line 945
+                            if (verbose) {
+#line 945
+                                error("\n");
+#line 945
+                                error("varid: %d, ", i);
+#line 945
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 945
+                                error("element number: %d ", k);
+#line 945
+                                error("expect: %g", expect[k]);
+#line 945
+                                error("got: %g", (double) value[k]);
+#line 945
+                            }
+#line 945
+			} else {
+#line 945
+			    nok++;
+#line 945
+                        }
+#line 945
+		    }
+#line 945
+		}
+#line 945
+	    } else {
+#line 945
+		IF (err != NC_ECHAR)
+#line 945
+		    error("wrong type: status = %d", err);
+#line 945
+	    }
+#line 945
+	}
+#line 945
+    }
+#line 945
+
+#line 945
+    err = nc_close(ncid);
+#line 945
+    IF (err)
+#line 945
+	error("nc_close: %s", nc_strerror(err));
+#line 945
+    print_nok(nok);
+#line 945
+}
+#line 945
+
+void
+#line 946
+test_nc_get_att_double(void)
+#line 946
+{
+#line 946
+    int ncid;
+#line 946
+    int i;
+#line 946
+    int j;
+#line 946
+    size_t k;
+#line 946
+    int err;
+#line 946
+    int allInExtRange;
+#line 946
+    int allInIntRange;
+#line 946
+    int canConvert;     /* Both text or both numeric */
+#line 946
+    double value[MAX_NELS];
+#line 946
+    double expect[MAX_NELS];
+#line 946
+    int nok = 0;      /* count of valid comparisons */
+#line 946
+
+#line 946
+#ifdef TEST_PNETCDF
+#line 946
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 946
+#else
+#line 946
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 946
+#endif
+#line 946
+    IF (err) 
+#line 946
+	error("nc_open: %s", nc_strerror(err));
+#line 946
+
+#line 946
+    for (i = -1; i < numVars; i++) {
+#line 946
+        for (j = 0; j < NATTS(i); j++) {
+#line 946
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+#line 946
+	    err = nc_get_att_double(BAD_ID, i, ATT_NAME(i,j), value);
+#line 946
+	    IF (err != NC_EBADID) 
+#line 946
+		error("bad ncid: status = %d", err);
+#line 946
+	    err = nc_get_att_double(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 946
+	    IF (err != NC_ENOTVAR) 
+#line 946
+		error("bad var id: status = %d", err);
+#line 946
+	    err = nc_get_att_double(ncid, i, "noSuch", value);
+#line 946
+	    IF (err != NC_ENOTATT) 
+#line 946
+		error("Bad attribute name: status = %d", err);
+#line 946
+	    allInExtRange = allInIntRange = 1;
+#line 946
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 946
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE);
+#line 946
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)) {
+#line 946
+                    allInIntRange = allInIntRange && expect[k] >= double_min
+#line 946
+                                && expect[k] <= double_max;
+#line 946
+                } else {
+#line 946
+                    allInExtRange = 0;
+#line 946
+                }
+#line 946
+	    }
+#line 946
+	    err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
+#line 946
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 946
+                if (allInExtRange) {
+#line 946
+                    if (allInIntRange) {
+#line 946
+                        IF (err)
+#line 946
+                            error("%s", nc_strerror(err));
+#line 946
+                    } else {
+#line 946
+                        IF (err != NC_ERANGE)
+#line 946
+                            error("Range error: status = %d", err);
+#line 946
+                    }
+#line 946
+                } else {
+#line 946
+                    IF (err != 0 && err != NC_ERANGE)
+#line 946
+                        error("OK or Range error: status = %d", err);
+#line 946
+                }
+#line 946
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 946
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)
+#line 946
+                            && expect[k] >= double_min && expect[k] <= double_max) {
+#line 946
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 946
+				NCT_DOUBLE)){
+#line 946
+			    error("value read not that expected");
+#line 946
+                            if (verbose) {
+#line 946
+                                error("\n");
+#line 946
+                                error("varid: %d, ", i);
+#line 946
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 946
+                                error("element number: %d ", k);
+#line 946
+                                error("expect: %g", expect[k]);
+#line 946
+                                error("got: %g", (double) value[k]);
+#line 946
+                            }
+#line 946
+			} else {
+#line 946
+			    nok++;
+#line 946
+                        }
+#line 946
+		    }
+#line 946
+		}
+#line 946
+	    } else {
+#line 946
+		IF (err != NC_ECHAR)
+#line 946
+		    error("wrong type: status = %d", err);
+#line 946
+	    }
+#line 946
+	}
+#line 946
+    }
+#line 946
+
+#line 946
+    err = nc_close(ncid);
+#line 946
+    IF (err)
+#line 946
+	error("nc_close: %s", nc_strerror(err));
+#line 946
+    print_nok(nok);
+#line 946
+}
+#line 946
+
+void
+#line 947
+test_nc_get_att_ushort(void)
+#line 947
+{
+#line 947
+    int ncid;
+#line 947
+    int i;
+#line 947
+    int j;
+#line 947
+    size_t k;
+#line 947
+    int err;
+#line 947
+    int allInExtRange;
+#line 947
+    int allInIntRange;
+#line 947
+    int canConvert;     /* Both text or both numeric */
+#line 947
+    ushort value[MAX_NELS];
+#line 947
+    double expect[MAX_NELS];
+#line 947
+    int nok = 0;      /* count of valid comparisons */
+#line 947
+
+#line 947
+#ifdef TEST_PNETCDF
+#line 947
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 947
+#else
+#line 947
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 947
+#endif
+#line 947
+    IF (err) 
+#line 947
+	error("nc_open: %s", nc_strerror(err));
+#line 947
+
+#line 947
+    for (i = -1; i < numVars; i++) {
+#line 947
+        for (j = 0; j < NATTS(i); j++) {
+#line 947
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+#line 947
+	    err = nc_get_att_ushort(BAD_ID, i, ATT_NAME(i,j), value);
+#line 947
+	    IF (err != NC_EBADID) 
+#line 947
+		error("bad ncid: status = %d", err);
+#line 947
+	    err = nc_get_att_ushort(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 947
+	    IF (err != NC_ENOTVAR) 
+#line 947
+		error("bad var id: status = %d", err);
+#line 947
+	    err = nc_get_att_ushort(ncid, i, "noSuch", value);
+#line 947
+	    IF (err != NC_ENOTATT) 
+#line 947
+		error("Bad attribute name: status = %d", err);
+#line 947
+	    allInExtRange = allInIntRange = 1;
+#line 947
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 947
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_USHORT);
+#line 947
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_USHORT)) {
+#line 947
+                    allInIntRange = allInIntRange && expect[k] >= ushort_min
+#line 947
+                                && expect[k] <= ushort_max;
+#line 947
+                } else {
+#line 947
+                    allInExtRange = 0;
+#line 947
+                }
+#line 947
+	    }
+#line 947
+	    err = nc_get_att_ushort(ncid, i, ATT_NAME(i,j), value);
+#line 947
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 947
+                if (allInExtRange) {
+#line 947
+                    if (allInIntRange) {
+#line 947
+                        IF (err)
+#line 947
+                            error("%s", nc_strerror(err));
+#line 947
+                    } else {
+#line 947
+                        IF (err != NC_ERANGE)
+#line 947
+                            error("Range error: status = %d", err);
+#line 947
+                    }
+#line 947
+                } else {
+#line 947
+                    IF (err != 0 && err != NC_ERANGE)
+#line 947
+                        error("OK or Range error: status = %d", err);
+#line 947
+                }
+#line 947
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 947
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_USHORT)
+#line 947
+                            && expect[k] >= ushort_min && expect[k] <= ushort_max) {
+#line 947
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 947
+				NCT_USHORT)){
+#line 947
+			    error("value read not that expected");
+#line 947
+                            if (verbose) {
+#line 947
+                                error("\n");
+#line 947
+                                error("varid: %d, ", i);
+#line 947
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 947
+                                error("element number: %d ", k);
+#line 947
+                                error("expect: %g", expect[k]);
+#line 947
+                                error("got: %g", (double) value[k]);
+#line 947
+                            }
+#line 947
+			} else {
+#line 947
+			    nok++;
+#line 947
+                        }
+#line 947
+		    }
+#line 947
+		}
+#line 947
+	    } else {
+#line 947
+		IF (err != NC_ECHAR)
+#line 947
+		    error("wrong type: status = %d", err);
+#line 947
+	    }
+#line 947
+	}
+#line 947
+    }
+#line 947
+
+#line 947
+    err = nc_close(ncid);
+#line 947
+    IF (err)
+#line 947
+	error("nc_close: %s", nc_strerror(err));
+#line 947
+    print_nok(nok);
+#line 947
+}
+#line 947
+
+void
+#line 948
+test_nc_get_att_uint(void)
+#line 948
+{
+#line 948
+    int ncid;
+#line 948
+    int i;
+#line 948
+    int j;
+#line 948
+    size_t k;
+#line 948
+    int err;
+#line 948
+    int allInExtRange;
+#line 948
+    int allInIntRange;
+#line 948
+    int canConvert;     /* Both text or both numeric */
+#line 948
+    uint value[MAX_NELS];
+#line 948
+    double expect[MAX_NELS];
+#line 948
+    int nok = 0;      /* count of valid comparisons */
+#line 948
+
+#line 948
+#ifdef TEST_PNETCDF
+#line 948
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 948
+#else
+#line 948
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 948
+#endif
+#line 948
+    IF (err) 
+#line 948
+	error("nc_open: %s", nc_strerror(err));
+#line 948
+
+#line 948
+    for (i = -1; i < numVars; i++) {
+#line 948
+        for (j = 0; j < NATTS(i); j++) {
+#line 948
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+#line 948
+	    err = nc_get_att_uint(BAD_ID, i, ATT_NAME(i,j), value);
+#line 948
+	    IF (err != NC_EBADID) 
+#line 948
+		error("bad ncid: status = %d", err);
+#line 948
+	    err = nc_get_att_uint(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 948
+	    IF (err != NC_ENOTVAR) 
+#line 948
+		error("bad var id: status = %d", err);
+#line 948
+	    err = nc_get_att_uint(ncid, i, "noSuch", value);
+#line 948
+	    IF (err != NC_ENOTATT) 
+#line 948
+		error("Bad attribute name: status = %d", err);
+#line 948
+	    allInExtRange = allInIntRange = 1;
+#line 948
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 948
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_UINT);
+#line 948
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UINT)) {
+#line 948
+                    allInIntRange = allInIntRange && expect[k] >= uint_min
+#line 948
+                                && expect[k] <= uint_max;
+#line 948
+                } else {
+#line 948
+                    allInExtRange = 0;
+#line 948
+                }
+#line 948
+	    }
+#line 948
+	    err = nc_get_att_uint(ncid, i, ATT_NAME(i,j), value);
+#line 948
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 948
+                if (allInExtRange) {
+#line 948
+                    if (allInIntRange) {
+#line 948
+                        IF (err)
+#line 948
+                            error("%s", nc_strerror(err));
+#line 948
+                    } else {
+#line 948
+                        IF (err != NC_ERANGE)
+#line 948
+                            error("Range error: status = %d", err);
+#line 948
+                    }
+#line 948
+                } else {
+#line 948
+                    IF (err != 0 && err != NC_ERANGE)
+#line 948
+                        error("OK or Range error: status = %d", err);
+#line 948
+                }
+#line 948
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 948
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_UINT)
+#line 948
+                            && expect[k] >= uint_min && expect[k] <= uint_max) {
+#line 948
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 948
+				NCT_UINT)){
+#line 948
+			    error("value read not that expected");
+#line 948
+                            if (verbose) {
+#line 948
+                                error("\n");
+#line 948
+                                error("varid: %d, ", i);
+#line 948
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 948
+                                error("element number: %d ", k);
+#line 948
+                                error("expect: %g", expect[k]);
+#line 948
+                                error("got: %g", (double) value[k]);
+#line 948
+                            }
+#line 948
+			} else {
+#line 948
+			    nok++;
+#line 948
+                        }
+#line 948
+		    }
+#line 948
+		}
+#line 948
+	    } else {
+#line 948
+		IF (err != NC_ECHAR)
+#line 948
+		    error("wrong type: status = %d", err);
+#line 948
+	    }
+#line 948
+	}
+#line 948
+    }
+#line 948
+
+#line 948
+    err = nc_close(ncid);
+#line 948
+    IF (err)
+#line 948
+	error("nc_close: %s", nc_strerror(err));
+#line 948
+    print_nok(nok);
+#line 948
+}
+#line 948
+
+void
+#line 949
+test_nc_get_att_longlong(void)
+#line 949
+{
+#line 949
+    int ncid;
+#line 949
+    int i;
+#line 949
+    int j;
+#line 949
+    size_t k;
+#line 949
+    int err;
+#line 949
+    int allInExtRange;
+#line 949
+    int allInIntRange;
+#line 949
+    int canConvert;     /* Both text or both numeric */
+#line 949
+    longlong value[MAX_NELS];
+#line 949
+    double expect[MAX_NELS];
+#line 949
+    int nok = 0;      /* count of valid comparisons */
+#line 949
+
+#line 949
+#ifdef TEST_PNETCDF
+#line 949
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 949
+#else
+#line 949
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 949
+#endif
+#line 949
+    IF (err) 
+#line 949
+	error("nc_open: %s", nc_strerror(err));
+#line 949
+
+#line 949
+    for (i = -1; i < numVars; i++) {
+#line 949
+        for (j = 0; j < NATTS(i); j++) {
+#line 949
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+#line 949
+	    err = nc_get_att_longlong(BAD_ID, i, ATT_NAME(i,j), value);
+#line 949
+	    IF (err != NC_EBADID) 
+#line 949
+		error("bad ncid: status = %d", err);
+#line 949
+	    err = nc_get_att_longlong(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 949
+	    IF (err != NC_ENOTVAR) 
+#line 949
+		error("bad var id: status = %d", err);
+#line 949
+	    err = nc_get_att_longlong(ncid, i, "noSuch", value);
+#line 949
+	    IF (err != NC_ENOTATT) 
+#line 949
+		error("Bad attribute name: status = %d", err);
+#line 949
+	    allInExtRange = allInIntRange = 1;
+#line 949
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 949
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_LONGLONG);
+#line 949
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONGLONG)) {
+#line 949
+                    allInIntRange = allInIntRange && expect[k] >= longlong_min
+#line 949
+                                && expect[k] <= longlong_max;
+#line 949
+                } else {
+#line 949
+                    allInExtRange = 0;
+#line 949
+                }
+#line 949
+	    }
+#line 949
+	    err = nc_get_att_longlong(ncid, i, ATT_NAME(i,j), value);
+#line 949
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 949
+                if (allInExtRange) {
+#line 949
+                    if (allInIntRange) {
+#line 949
+                        IF (err)
+#line 949
+                            error("%s", nc_strerror(err));
+#line 949
+                    } else {
+#line 949
+                        IF (err != NC_ERANGE)
+#line 949
+                            error("Range error: status = %d", err);
+#line 949
+                    }
+#line 949
+                } else {
+#line 949
+                    IF (err != 0 && err != NC_ERANGE)
+#line 949
+                        error("OK or Range error: status = %d", err);
+#line 949
+                }
+#line 949
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 949
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONGLONG)
+#line 949
+                            && expect[k] >= longlong_min && expect[k] <= longlong_max) {
+#line 949
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 949
+				NCT_LONGLONG)){
+#line 949
+			    error("value read not that expected");
+#line 949
+                            if (verbose) {
+#line 949
+                                error("\n");
+#line 949
+                                error("varid: %d, ", i);
+#line 949
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 949
+                                error("element number: %d ", k);
+#line 949
+                                error("expect: %g", expect[k]);
+#line 949
+                                error("got: %g", (double) value[k]);
+#line 949
+                            }
+#line 949
+			} else {
+#line 949
+			    nok++;
+#line 949
+                        }
+#line 949
+		    }
+#line 949
+		}
+#line 949
+	    } else {
+#line 949
+		IF (err != NC_ECHAR)
+#line 949
+		    error("wrong type: status = %d", err);
+#line 949
+	    }
+#line 949
+	}
+#line 949
+    }
+#line 949
+
+#line 949
+    err = nc_close(ncid);
+#line 949
+    IF (err)
+#line 949
+	error("nc_close: %s", nc_strerror(err));
+#line 949
+    print_nok(nok);
+#line 949
+}
+#line 949
+
+void
+#line 950
+test_nc_get_att_ulonglong(void)
+#line 950
+{
+#line 950
+    int ncid;
+#line 950
+    int i;
+#line 950
+    int j;
+#line 950
+    size_t k;
+#line 950
+    int err;
+#line 950
+    int allInExtRange;
+#line 950
+    int allInIntRange;
+#line 950
+    int canConvert;     /* Both text or both numeric */
+#line 950
+    ulonglong value[MAX_NELS];
+#line 950
+    double expect[MAX_NELS];
+#line 950
+    int nok = 0;      /* count of valid comparisons */
+#line 950
+
+#line 950
+#ifdef TEST_PNETCDF
+#line 950
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#line 950
+#else
+#line 950
+    err = nc_open(testfile, NC_NOWRITE, &ncid);
+#line 950
+#endif
+#line 950
+    IF (err) 
+#line 950
+	error("nc_open: %s", nc_strerror(err));
+#line 950
+
+#line 950
+    for (i = -1; i < numVars; i++) {
+#line 950
+        for (j = 0; j < NATTS(i); j++) {
+#line 950
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+#line 950
+	    err = nc_get_att_ulonglong(BAD_ID, i, ATT_NAME(i,j), value);
+#line 950
+	    IF (err != NC_EBADID) 
+#line 950
+		error("bad ncid: status = %d", err);
+#line 950
+	    err = nc_get_att_ulonglong(ncid, BAD_VARID, ATT_NAME(i,j), value);
+#line 950
+	    IF (err != NC_ENOTVAR) 
+#line 950
+		error("bad var id: status = %d", err);
+#line 950
+	    err = nc_get_att_ulonglong(ncid, i, "noSuch", value);
+#line 950
+	    IF (err != NC_ENOTATT) 
+#line 950
+		error("Bad attribute name: status = %d", err);
+#line 950
+	    allInExtRange = allInIntRange = 1;
+#line 950
+            for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 950
+		expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_ULONGLONG);
+#line 950
+                if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ULONGLONG)) {
+#line 950
+                    allInIntRange = allInIntRange && expect[k] >= ulonglong_min
+#line 950
+                                && expect[k] <= ulonglong_max;
+#line 950
+                } else {
+#line 950
+                    allInExtRange = 0;
+#line 950
+                }
+#line 950
+	    }
+#line 950
+	    err = nc_get_att_ulonglong(ncid, i, ATT_NAME(i,j), value);
+#line 950
+            if (canConvert || ATT_LEN(i,j) == 0) {
+#line 950
+                if (allInExtRange) {
+#line 950
+                    if (allInIntRange) {
+#line 950
+                        IF (err)
+#line 950
+                            error("%s", nc_strerror(err));
+#line 950
+                    } else {
+#line 950
+                        IF (err != NC_ERANGE)
+#line 950
+                            error("Range error: status = %d", err);
+#line 950
+                    }
+#line 950
+                } else {
+#line 950
+                    IF (err != 0 && err != NC_ERANGE)
+#line 950
+                        error("OK or Range error: status = %d", err);
+#line 950
+                }
+#line 950
+		for (k = 0; k < ATT_LEN(i,j); k++) {
+#line 950
+		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ULONGLONG)
+#line 950
+                            && expect[k] >= ulonglong_min && expect[k] <= ulonglong_max) {
+#line 950
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+#line 950
+				NCT_ULONGLONG)){
+#line 950
+			    error("value read not that expected");
+#line 950
+                            if (verbose) {
+#line 950
+                                error("\n");
+#line 950
+                                error("varid: %d, ", i);
+#line 950
+                                error("att_name: %s, ", ATT_NAME(i,j));
+#line 950
+                                error("element number: %d ", k);
+#line 950
+                                error("expect: %g", expect[k]);
+#line 950
+                                error("got: %g", (double) value[k]);
+#line 950
+                            }
+#line 950
+			} else {
+#line 950
+			    nok++;
+#line 950
+                        }
+#line 950
+		    }
+#line 950
+		}
+#line 950
+	    } else {
+#line 950
+		IF (err != NC_ECHAR)
+#line 950
+		    error("wrong type: status = %d", err);
+#line 950
+	    }
+#line 950
+	}
+#line 950
+    }
+#line 950
+
+#line 950
+    err = nc_close(ncid);
+#line 950
+    IF (err)
+#line 950
+	error("nc_close: %s", nc_strerror(err));
+#line 950
+    print_nok(nok);
+#line 950
+}
+#line 950
+
+
diff --git a/nc_test/test_get.m4 b/nc_test/test_get_p5.m4
similarity index 93%
copy from nc_test/test_get.m4
copy to nc_test/test_get_p5.m4
index d8b6696..91b09e9 100644
--- a/nc_test/test_get.m4
+++ b/nc_test/test_get_p5.m4
@@ -7,9 +7,12 @@ dnl
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_get.m4,v 1.16 2005/03/08 03:04:19 ed Exp $
+ *   $Id: test_get.m4 2785 2014-10-26 05:21:20Z wkliao $
  *********************************************************************/
 
+// #define TEST_PNETCDF
+#include <mpi.h>
+
 undefine(`index')dnl
 dnl dnl dnl
 dnl
@@ -48,10 +51,14 @@ test_nc_get_var1_$1(void)
     int canConvert;     /* Both text or both numeric */
     $1 value;
 
+#ifdef TEST_PNETCDF
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     err = nc_open(testfile, NC_NOWRITE, &ncid);
+#endif
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	for (j = 0; j < var_rank[i]; j++)
 	    index[j] = 0;
@@ -122,6 +129,10 @@ TEST_NC_GET_VAR1(int)
 TEST_NC_GET_VAR1(long)
 TEST_NC_GET_VAR1(float)
 TEST_NC_GET_VAR1(double)
+TEST_NC_GET_VAR1(ushort)
+TEST_NC_GET_VAR1(uint)
+TEST_NC_GET_VAR1(longlong)
+TEST_NC_GET_VAR1(ulonglong)
 
 
 dnl TEST_NC_GET_VAR(TYPE)
@@ -144,10 +155,14 @@ test_nc_get_var_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
+#ifdef TEST_PNETCDF
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     err = nc_open(testfile, NC_NOWRITE, &ncid);
+#endif
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -227,6 +242,10 @@ TEST_NC_GET_VAR(int)
 TEST_NC_GET_VAR(long)
 TEST_NC_GET_VAR(float)
 TEST_NC_GET_VAR(double)
+TEST_NC_GET_VAR(ushort)
+TEST_NC_GET_VAR(uint)
+TEST_NC_GET_VAR(longlong)
+TEST_NC_GET_VAR(ulonglong)
 
 
 dnl TEST_NC_GET_VARA(TYPE)
@@ -255,10 +274,14 @@ test_nc_get_vara_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
+#ifdef TEST_PNETCDF
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     err = nc_open(testfile, NC_NOWRITE, &ncid);
+#endif
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -407,6 +430,10 @@ TEST_NC_GET_VARA(int)
 TEST_NC_GET_VARA(long)
 TEST_NC_GET_VARA(float)
 TEST_NC_GET_VARA(double)
+TEST_NC_GET_VARA(ushort)
+TEST_NC_GET_VARA(uint)
+TEST_NC_GET_VARA(longlong)
+TEST_NC_GET_VARA(ulonglong)
 
 
 dnl TEST_NC_GET_VARS(TYPE)
@@ -441,10 +468,14 @@ test_nc_get_vars_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
+#ifdef TEST_PNETCDF
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     err = nc_open(testfile, NC_NOWRITE, &ncid);
+#endif
     IF (err)
         error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -558,7 +589,8 @@ test_nc_get_vars_$1(void)
 		    for (j = 0; j < nels; j++) {
 			if (inRange3(expect[j],var_type[i],NCT_ITYPE($1))
 				&& expect[j] >= $1_min && expect[j] <= $1_max) {
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_ITYPE($1))){
+			    IF (!equal(value[j],expect[j],var_type[i],
+				    NCT_ITYPE($1))){
 				error("value read not that expected");
 				if (verbose) {
 				    error("\n");
@@ -596,6 +628,10 @@ TEST_NC_GET_VARS(int)
 TEST_NC_GET_VARS(long)
 TEST_NC_GET_VARS(float)
 TEST_NC_GET_VARS(double)
+TEST_NC_GET_VARS(ushort)
+TEST_NC_GET_VARS(uint)
+TEST_NC_GET_VARS(longlong)
+TEST_NC_GET_VARS(ulonglong)
 
 
 dnl TEST_NC_GET_VARM(TYPE)
@@ -631,10 +667,14 @@ test_nc_get_varm_$1(void)
     $1 value[MAX_NELS];
     double expect[MAX_NELS];
 
+#ifdef TEST_PNETCDF
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     err = nc_open(testfile, NC_NOWRITE, &ncid);
+#endif
     IF (err)
         error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -756,7 +796,8 @@ test_nc_get_varm_$1(void)
                         if (inRange3(expect[j],var_type[i],NCT_ITYPE($1))
                                 && expect[j] >= $1_min 
 				&& expect[j] <= $1_max) {
-			    IF (!equal(value[j],expect[j],var_type[i], NCT_ITYPE($1))){
+			    IF (!equal(value[j],expect[j],var_type[i],
+				    NCT_ITYPE($1))){
                                 error("value read not that expected");
                                 if (verbose) {
                                     error("\n");
@@ -793,6 +834,10 @@ TEST_NC_GET_VARM(int)
 TEST_NC_GET_VARM(long)
 TEST_NC_GET_VARM(float)
 TEST_NC_GET_VARM(double)
+TEST_NC_GET_VARM(ushort)
+TEST_NC_GET_VARM(uint)
+TEST_NC_GET_VARM(longlong)
+TEST_NC_GET_VARM(ulonglong)
 
 
 dnl TEST_NC_GET_ATT(TYPE)
@@ -814,11 +859,15 @@ test_nc_get_att_$1(void)
     double expect[MAX_NELS];
     int nok = 0;      /* count of valid comparisons */
 
+#ifdef TEST_PNETCDF
+    err = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     err = nc_open(testfile, NC_NOWRITE, &ncid);
+#endif
     IF (err) 
 	error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
 	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	    err = nc_get_att_$1(BAD_ID, i, ATT_NAME(i,j), value);
@@ -857,7 +906,8 @@ test_nc_get_att_$1(void)
 		for (k = 0; k < ATT_LEN(i,j); k++) {
 		    if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ITYPE($1))
                             && expect[k] >= $1_min && expect[k] <= $1_max) {
-			IF (!equal(value[k],expect[k],ATT_TYPE(i,j), NCT_ITYPE($1))){
+			IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
+				NCT_ITYPE($1))){
 			    error("value read not that expected");
                             if (verbose) {
                                 error("\n");
@@ -894,4 +944,8 @@ TEST_NC_GET_ATT(int)
 TEST_NC_GET_ATT(long)
 TEST_NC_GET_ATT(float)
 TEST_NC_GET_ATT(double)
+TEST_NC_GET_ATT(ushort)
+TEST_NC_GET_ATT(uint)
+TEST_NC_GET_ATT(longlong)
+TEST_NC_GET_ATT(ulonglong)
 
diff --git a/nc_test/test_put.c b/nc_test/test_put.c
index 39e5e2d..470ba9f 100644
--- a/nc_test/test_put.c
+++ b/nc_test/test_put.c
@@ -1,13629 +1,11186 @@
-#line 5 "test_put.m4"
 /* Do not edit this file. It is produced from the corresponding .m4 source */
-#line 7
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_put.m4,v 1.25 2005/03/08 03:04:19 ed Exp $
+ *   $Id: test_put.m4 2785 2014-10-26 05:21:20Z wkliao $
  *********************************************************************/
 
-#line 31
+#ifdef USE_PARALLEL
+#include <mpi.h>
+#endif
+
 
 #include "tests.h"
 
-#line 55
 
 /*
-#line 56
  *  ensure hash value within range for internal TYPE
-#line 56
  */
-#line 56
 static
-#line 56
 double
-#line 56
 hash_text(
-#line 56
     const nc_type type,
-#line 56
     const int rank,
-#line 56
     const size_t *index,
-#line 56
     const nct_itype itype)
-#line 56
 {
-#line 56
     const double min = text_min;
-#line 56
     const double max = text_max;
-#line 56
 
-#line 56
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 56
 }
-#line 56
 
 /*
-#line 57
  *  ensure hash value within range for internal TYPE
-#line 57
  */
-#line 57
 static
-#line 57
 double
-#line 57
 hash_uchar(
-#line 57
     const nc_type type,
-#line 57
     const int rank,
-#line 57
     const size_t *index,
-#line 57
     const nct_itype itype)
-#line 57
 {
-#line 57
     const double min = uchar_min;
-#line 57
     const double max = uchar_max;
-#line 57
 
-#line 57
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 57
 }
-#line 57
 
 /*
-#line 58
  *  ensure hash value within range for internal TYPE
-#line 58
  */
-#line 58
 static
-#line 58
 double
-#line 58
 hash_schar(
-#line 58
     const nc_type type,
-#line 58
     const int rank,
-#line 58
     const size_t *index,
-#line 58
     const nct_itype itype)
-#line 58
 {
-#line 58
     const double min = schar_min;
-#line 58
     const double max = schar_max;
-#line 58
 
-#line 58
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 58
 }
-#line 58
 
 /*
-#line 59
  *  ensure hash value within range for internal TYPE
-#line 59
  */
-#line 59
 static
-#line 59
 double
-#line 59
 hash_short(
-#line 59
     const nc_type type,
-#line 59
     const int rank,
-#line 59
     const size_t *index,
-#line 59
     const nct_itype itype)
-#line 59
 {
-#line 59
     const double min = short_min;
-#line 59
     const double max = short_max;
-#line 59
 
-#line 59
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 59
 }
-#line 59
 
 /*
-#line 60
  *  ensure hash value within range for internal TYPE
-#line 60
  */
-#line 60
 static
-#line 60
 double
-#line 60
 hash_int(
-#line 60
     const nc_type type,
-#line 60
     const int rank,
-#line 60
     const size_t *index,
-#line 60
     const nct_itype itype)
-#line 60
 {
-#line 60
     const double min = int_min;
-#line 60
     const double max = int_max;
-#line 60
 
-#line 60
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 60
 }
-#line 60
 
 /*
-#line 61
  *  ensure hash value within range for internal TYPE
-#line 61
  */
-#line 61
 static
-#line 61
 double
-#line 61
 hash_long(
-#line 61
     const nc_type type,
-#line 61
     const int rank,
-#line 61
     const size_t *index,
-#line 61
     const nct_itype itype)
-#line 61
 {
-#line 61
     const double min = long_min;
-#line 61
     const double max = long_max;
-#line 61
 
-#line 61
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 61
 }
-#line 61
 
 /*
-#line 62
  *  ensure hash value within range for internal TYPE
-#line 62
  */
-#line 62
 static
-#line 62
 double
-#line 62
 hash_float(
-#line 62
     const nc_type type,
-#line 62
     const int rank,
-#line 62
     const size_t *index,
-#line 62
     const nct_itype itype)
-#line 62
 {
-#line 62
     const double min = float_min;
-#line 62
     const double max = float_max;
-#line 62
 
-#line 62
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 62
 }
-#line 62
 
 /*
-#line 63
  *  ensure hash value within range for internal TYPE
-#line 63
  */
-#line 63
 static
-#line 63
 double
-#line 63
 hash_double(
-#line 63
     const nc_type type,
-#line 63
     const int rank,
-#line 63
     const size_t *index,
-#line 63
     const nct_itype itype)
-#line 63
 {
-#line 63
     const double min = double_min;
-#line 63
     const double max = double_max;
-#line 63
 
-#line 63
     return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-#line 63
 }
-#line 63
+
+/*
+ *  ensure hash value within range for internal TYPE
+ */
+static
+double
+hash_ushort(
+    const nc_type type,
+    const int rank,
+    const size_t *index,
+    const nct_itype itype)
+{
+    const double min = ushort_min;
+    const double max = ushort_max;
+
+    return MAX(min, MIN(max, hash4( type, rank, index, itype)));
+}
+
+/*
+ *  ensure hash value within range for internal TYPE
+ */
+static
+double
+hash_uint(
+    const nc_type type,
+    const int rank,
+    const size_t *index,
+    const nct_itype itype)
+{
+    const double min = uint_min;
+    const double max = uint_max;
+
+    return MAX(min, MIN(max, hash4( type, rank, index, itype)));
+}
+
+/*
+ *  ensure hash value within range for internal TYPE
+ */
+static
+double
+hash_longlong(
+    const nc_type type,
+    const int rank,
+    const size_t *index,
+    const nct_itype itype)
+{
+    const double min = longlong_min;
+    const double max = longlong_max;
+
+    return MAX(min, MIN(max, hash4( type, rank, index, itype)));
+}
+
+/*
+ *  ensure hash value within range for internal TYPE
+ */
+static
+double
+hash_ulonglong(
+    const nc_type type,
+    const int rank,
+    const size_t *index,
+    const nct_itype itype)
+{
+    const double min = ulonglong_min;
+    const double max = ulonglong_max;
+
+    return MAX(min, MIN(max, hash4( type, rank, index, itype)));
+}
 
 
 
-#line 154
 
 /* 
-#line 155
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 155
  */
-#line 155
 static
-#line 155
 void
-#line 155
 check_vars_text(const char *filename)
-#line 155
 {
-#line 155
     int  ncid;                  /* netCDF id */
-#line 155
     size_t index[MAX_RANK];
-#line 155
     int  err;           /* status */
-#line 155
     int  d;
-#line 155
     int  i;
-#line 155
     size_t  j;
-#line 155
     text value;
-#line 155
     nc_type datatype;
-#line 155
     int ndims;
-#line 155
     int dimids[MAX_RANK];
-#line 155
     double expect;
-#line 155
     char name[NC_MAX_NAME];
-#line 155
     size_t length;
-#line 155
     int canConvert;     /* Both text or both numeric */
-#line 155
     int nok = 0;      /* count of valid comparisons */
-#line 155
 
-#line 155
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 155
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 155
         error("nc_open: %s", nc_strerror(err));
-#line 155
 
-#line 155
-    for (i = 0; i < NVARS; i++) {
-#line 155
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 155
 	if (canConvert) {
-#line 155
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 155
 	    IF (err)
-#line 155
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 155
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 155
 		error("Unexpected var_name");
-#line 155
 	    IF (datatype != var_type[i])
-#line 155
 		error("Unexpected type");
-#line 155
 	    IF (ndims != var_rank[i])
-#line 155
 		error("Unexpected rank");
-#line 155
 	    for (j = 0; j < ndims; j++) {
-#line 155
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 155
 		IF (err)
-#line 155
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 155
 		IF (length != var_shape[i][j])
-#line 155
 		    error("Unexpected shape");
-#line 155
 	    }
-#line 155
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 155
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 155
 		IF (err)
-#line 155
 		    error("error in toMixedBase 2");
-#line 155
 		expect = hash4( var_type[i], var_rank[i], index, NCT_TEXT);
-#line 155
 		err = nc_get_var1_text(ncid, i, index, &value);
-#line 155
 		if (inRange3(expect,datatype,NCT_TEXT)) {
-#line 155
                     if (expect >= text_min && expect <= text_max) {
-#line 155
 			IF (err) {
-#line 155
 			    error("nc_get_var1_text: %s", nc_strerror(err));
-#line 155
 			} else {
-#line 155
                             IF (!equal(value,expect,var_type[i],NCT_TEXT)) {
-#line 155
 				error("Var value read not that expected");
-#line 155
 				if (verbose) {
-#line 155
 				    error("\n");
-#line 155
 				    error("varid: %d, ", i);
-#line 155
 				    error("var_name: %s, ", var_name[i]);
-#line 155
 				    error("index:");
-#line 155
 				    for (d = 0; d < var_rank[i]; d++)
-#line 155
 					error(" %d", index[d]);
-#line 155
 				    error(", expect: %g, ", expect);
-#line 155
 				    error("got: %g", (double) value);
-#line 155
 				}
-#line 155
 			    } else {
-#line 155
 				++nok;
-#line 155
 			    }
-#line 155
 			}
-#line 155
 		    }
-#line 155
 		}
-#line 155
 	    }
-#line 155
 	}
-#line 155
     }
-#line 155
     err = nc_close (ncid);
-#line 155
     IF (err)
-#line 155
         error("nc_close: %s", nc_strerror(err));
-#line 155
     print_nok(nok);
-#line 155
 }
-#line 155
 
 /* 
-#line 156
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 156
  */
-#line 156
 static
-#line 156
 void
-#line 156
 check_vars_uchar(const char *filename)
-#line 156
 {
-#line 156
     int  ncid;                  /* netCDF id */
-#line 156
     size_t index[MAX_RANK];
-#line 156
     int  err;           /* status */
-#line 156
     int  d;
-#line 156
     int  i;
-#line 156
     size_t  j;
-#line 156
     uchar value;
-#line 156
     nc_type datatype;
-#line 156
     int ndims;
-#line 156
     int dimids[MAX_RANK];
-#line 156
     double expect;
-#line 156
     char name[NC_MAX_NAME];
-#line 156
     size_t length;
-#line 156
     int canConvert;     /* Both text or both numeric */
-#line 156
     int nok = 0;      /* count of valid comparisons */
-#line 156
 
-#line 156
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 156
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 156
         error("nc_open: %s", nc_strerror(err));
-#line 156
 
-#line 156
-    for (i = 0; i < NVARS; i++) {
-#line 156
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 156
 	if (canConvert) {
-#line 156
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 156
 	    IF (err)
-#line 156
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 156
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 156
 		error("Unexpected var_name");
-#line 156
 	    IF (datatype != var_type[i])
-#line 156
 		error("Unexpected type");
-#line 156
 	    IF (ndims != var_rank[i])
-#line 156
 		error("Unexpected rank");
-#line 156
 	    for (j = 0; j < ndims; j++) {
-#line 156
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 156
 		IF (err)
-#line 156
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 156
 		IF (length != var_shape[i][j])
-#line 156
 		    error("Unexpected shape");
-#line 156
 	    }
-#line 156
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 156
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 156
 		IF (err)
-#line 156
 		    error("error in toMixedBase 2");
-#line 156
 		expect = hash4( var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 156
 		err = nc_get_var1_uchar(ncid, i, index, &value);
-#line 156
 		if (inRange3(expect,datatype,NCT_UCHAR)) {
-#line 156
                     if (expect >= uchar_min && expect <= uchar_max) {
-#line 156
 			IF (err) {
-#line 156
 			    error("nc_get_var1_uchar: %s", nc_strerror(err));
-#line 156
 			} else {
-#line 156
                             IF (!equal(value,expect,var_type[i],NCT_UCHAR)) {
-#line 156
 				error("Var value read not that expected");
-#line 156
 				if (verbose) {
-#line 156
 				    error("\n");
-#line 156
 				    error("varid: %d, ", i);
-#line 156
 				    error("var_name: %s, ", var_name[i]);
-#line 156
 				    error("index:");
-#line 156
 				    for (d = 0; d < var_rank[i]; d++)
-#line 156
 					error(" %d", index[d]);
-#line 156
 				    error(", expect: %g, ", expect);
-#line 156
 				    error("got: %g", (double) value);
-#line 156
 				}
-#line 156
 			    } else {
-#line 156
 				++nok;
-#line 156
 			    }
-#line 156
 			}
-#line 156
 		    }
-#line 156
 		}
-#line 156
 	    }
-#line 156
 	}
-#line 156
     }
-#line 156
     err = nc_close (ncid);
-#line 156
     IF (err)
-#line 156
         error("nc_close: %s", nc_strerror(err));
-#line 156
     print_nok(nok);
-#line 156
 }
-#line 156
 
 /* 
-#line 157
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 157
  */
-#line 157
 static
-#line 157
 void
-#line 157
 check_vars_schar(const char *filename)
-#line 157
 {
-#line 157
     int  ncid;                  /* netCDF id */
-#line 157
     size_t index[MAX_RANK];
-#line 157
     int  err;           /* status */
-#line 157
     int  d;
-#line 157
     int  i;
-#line 157
     size_t  j;
-#line 157
     schar value;
-#line 157
     nc_type datatype;
-#line 157
     int ndims;
-#line 157
     int dimids[MAX_RANK];
-#line 157
     double expect;
-#line 157
     char name[NC_MAX_NAME];
-#line 157
     size_t length;
-#line 157
     int canConvert;     /* Both text or both numeric */
-#line 157
     int nok = 0;      /* count of valid comparisons */
-#line 157
 
-#line 157
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 157
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 157
         error("nc_open: %s", nc_strerror(err));
-#line 157
 
-#line 157
-    for (i = 0; i < NVARS; i++) {
-#line 157
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 157
 	if (canConvert) {
-#line 157
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 157
 	    IF (err)
-#line 157
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 157
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 157
 		error("Unexpected var_name");
-#line 157
 	    IF (datatype != var_type[i])
-#line 157
 		error("Unexpected type");
-#line 157
 	    IF (ndims != var_rank[i])
-#line 157
 		error("Unexpected rank");
-#line 157
 	    for (j = 0; j < ndims; j++) {
-#line 157
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 157
 		IF (err)
-#line 157
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 157
 		IF (length != var_shape[i][j])
-#line 157
 		    error("Unexpected shape");
-#line 157
 	    }
-#line 157
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 157
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 157
 		IF (err)
-#line 157
 		    error("error in toMixedBase 2");
-#line 157
 		expect = hash4( var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 157
 		err = nc_get_var1_schar(ncid, i, index, &value);
-#line 157
 		if (inRange3(expect,datatype,NCT_SCHAR)) {
-#line 157
                     if (expect >= schar_min && expect <= schar_max) {
-#line 157
 			IF (err) {
-#line 157
 			    error("nc_get_var1_schar: %s", nc_strerror(err));
-#line 157
 			} else {
-#line 157
                             IF (!equal(value,expect,var_type[i],NCT_SCHAR)) {
-#line 157
 				error("Var value read not that expected");
-#line 157
 				if (verbose) {
-#line 157
 				    error("\n");
-#line 157
 				    error("varid: %d, ", i);
-#line 157
 				    error("var_name: %s, ", var_name[i]);
-#line 157
 				    error("index:");
-#line 157
 				    for (d = 0; d < var_rank[i]; d++)
-#line 157
 					error(" %d", index[d]);
-#line 157
 				    error(", expect: %g, ", expect);
-#line 157
 				    error("got: %g", (double) value);
-#line 157
 				}
-#line 157
 			    } else {
-#line 157
 				++nok;
-#line 157
 			    }
-#line 157
 			}
-#line 157
 		    }
-#line 157
 		}
-#line 157
 	    }
-#line 157
 	}
-#line 157
     }
-#line 157
     err = nc_close (ncid);
-#line 157
     IF (err)
-#line 157
         error("nc_close: %s", nc_strerror(err));
-#line 157
     print_nok(nok);
-#line 157
 }
-#line 157
 
 /* 
-#line 158
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 158
  */
-#line 158
 static
-#line 158
 void
-#line 158
 check_vars_short(const char *filename)
-#line 158
 {
-#line 158
     int  ncid;                  /* netCDF id */
-#line 158
     size_t index[MAX_RANK];
-#line 158
     int  err;           /* status */
-#line 158
     int  d;
-#line 158
     int  i;
-#line 158
     size_t  j;
-#line 158
     short value;
-#line 158
     nc_type datatype;
-#line 158
     int ndims;
-#line 158
     int dimids[MAX_RANK];
-#line 158
     double expect;
-#line 158
     char name[NC_MAX_NAME];
-#line 158
     size_t length;
-#line 158
     int canConvert;     /* Both text or both numeric */
-#line 158
     int nok = 0;      /* count of valid comparisons */
-#line 158
 
-#line 158
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 158
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 158
         error("nc_open: %s", nc_strerror(err));
-#line 158
 
-#line 158
-    for (i = 0; i < NVARS; i++) {
-#line 158
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 158
 	if (canConvert) {
-#line 158
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 158
 	    IF (err)
-#line 158
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 158
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 158
 		error("Unexpected var_name");
-#line 158
 	    IF (datatype != var_type[i])
-#line 158
 		error("Unexpected type");
-#line 158
 	    IF (ndims != var_rank[i])
-#line 158
 		error("Unexpected rank");
-#line 158
 	    for (j = 0; j < ndims; j++) {
-#line 158
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 158
 		IF (err)
-#line 158
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 158
 		IF (length != var_shape[i][j])
-#line 158
 		    error("Unexpected shape");
-#line 158
 	    }
-#line 158
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 158
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 158
 		IF (err)
-#line 158
 		    error("error in toMixedBase 2");
-#line 158
 		expect = hash4( var_type[i], var_rank[i], index, NCT_SHORT);
-#line 158
 		err = nc_get_var1_short(ncid, i, index, &value);
-#line 158
 		if (inRange3(expect,datatype,NCT_SHORT)) {
-#line 158
                     if (expect >= short_min && expect <= short_max) {
-#line 158
 			IF (err) {
-#line 158
 			    error("nc_get_var1_short: %s", nc_strerror(err));
-#line 158
 			} else {
-#line 158
                             IF (!equal(value,expect,var_type[i],NCT_SHORT)) {
-#line 158
 				error("Var value read not that expected");
-#line 158
 				if (verbose) {
-#line 158
 				    error("\n");
-#line 158
 				    error("varid: %d, ", i);
-#line 158
 				    error("var_name: %s, ", var_name[i]);
-#line 158
 				    error("index:");
-#line 158
 				    for (d = 0; d < var_rank[i]; d++)
-#line 158
 					error(" %d", index[d]);
-#line 158
 				    error(", expect: %g, ", expect);
-#line 158
 				    error("got: %g", (double) value);
-#line 158
 				}
-#line 158
 			    } else {
-#line 158
 				++nok;
-#line 158
 			    }
-#line 158
 			}
-#line 158
 		    }
-#line 158
 		}
-#line 158
 	    }
-#line 158
 	}
-#line 158
     }
-#line 158
     err = nc_close (ncid);
-#line 158
     IF (err)
-#line 158
         error("nc_close: %s", nc_strerror(err));
-#line 158
     print_nok(nok);
-#line 158
 }
-#line 158
 
 /* 
-#line 159
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 159
  */
-#line 159
 static
-#line 159
 void
-#line 159
 check_vars_int(const char *filename)
-#line 159
 {
-#line 159
     int  ncid;                  /* netCDF id */
-#line 159
     size_t index[MAX_RANK];
-#line 159
     int  err;           /* status */
-#line 159
     int  d;
-#line 159
     int  i;
-#line 159
     size_t  j;
-#line 159
     int value;
-#line 159
     nc_type datatype;
-#line 159
     int ndims;
-#line 159
     int dimids[MAX_RANK];
-#line 159
     double expect;
-#line 159
     char name[NC_MAX_NAME];
-#line 159
     size_t length;
-#line 159
     int canConvert;     /* Both text or both numeric */
-#line 159
     int nok = 0;      /* count of valid comparisons */
-#line 159
 
-#line 159
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 159
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 159
         error("nc_open: %s", nc_strerror(err));
-#line 159
 
-#line 159
-    for (i = 0; i < NVARS; i++) {
-#line 159
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 159
 	if (canConvert) {
-#line 159
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 159
 	    IF (err)
-#line 159
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 159
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 159
 		error("Unexpected var_name");
-#line 159
 	    IF (datatype != var_type[i])
-#line 159
 		error("Unexpected type");
-#line 159
 	    IF (ndims != var_rank[i])
-#line 159
 		error("Unexpected rank");
-#line 159
 	    for (j = 0; j < ndims; j++) {
-#line 159
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 159
 		IF (err)
-#line 159
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 159
 		IF (length != var_shape[i][j])
-#line 159
 		    error("Unexpected shape");
-#line 159
 	    }
-#line 159
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 159
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 159
 		IF (err)
-#line 159
 		    error("error in toMixedBase 2");
-#line 159
 		expect = hash4( var_type[i], var_rank[i], index, NCT_INT);
-#line 159
 		err = nc_get_var1_int(ncid, i, index, &value);
-#line 159
 		if (inRange3(expect,datatype,NCT_INT)) {
-#line 159
                     if (expect >= int_min && expect <= int_max) {
-#line 159
 			IF (err) {
-#line 159
 			    error("nc_get_var1_int: %s", nc_strerror(err));
-#line 159
 			} else {
-#line 159
                             IF (!equal(value,expect,var_type[i],NCT_INT)) {
-#line 159
 				error("Var value read not that expected");
-#line 159
 				if (verbose) {
-#line 159
 				    error("\n");
-#line 159
 				    error("varid: %d, ", i);
-#line 159
 				    error("var_name: %s, ", var_name[i]);
-#line 159
 				    error("index:");
-#line 159
 				    for (d = 0; d < var_rank[i]; d++)
-#line 159
 					error(" %d", index[d]);
-#line 159
 				    error(", expect: %g, ", expect);
-#line 159
 				    error("got: %g", (double) value);
-#line 159
 				}
-#line 159
 			    } else {
-#line 159
 				++nok;
-#line 159
 			    }
-#line 159
 			}
-#line 159
 		    }
-#line 159
 		}
-#line 159
 	    }
-#line 159
 	}
-#line 159
     }
-#line 159
     err = nc_close (ncid);
-#line 159
     IF (err)
-#line 159
         error("nc_close: %s", nc_strerror(err));
-#line 159
     print_nok(nok);
-#line 159
 }
-#line 159
 
 /* 
-#line 160
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 160
  */
-#line 160
 static
-#line 160
 void
-#line 160
 check_vars_long(const char *filename)
-#line 160
 {
-#line 160
     int  ncid;                  /* netCDF id */
-#line 160
     size_t index[MAX_RANK];
-#line 160
     int  err;           /* status */
-#line 160
     int  d;
-#line 160
     int  i;
-#line 160
     size_t  j;
-#line 160
     long value;
-#line 160
     nc_type datatype;
-#line 160
     int ndims;
-#line 160
     int dimids[MAX_RANK];
-#line 160
     double expect;
-#line 160
     char name[NC_MAX_NAME];
-#line 160
     size_t length;
-#line 160
     int canConvert;     /* Both text or both numeric */
-#line 160
     int nok = 0;      /* count of valid comparisons */
-#line 160
 
-#line 160
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 160
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 160
         error("nc_open: %s", nc_strerror(err));
-#line 160
 
-#line 160
-    for (i = 0; i < NVARS; i++) {
-#line 160
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 160
 	if (canConvert) {
-#line 160
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 160
 	    IF (err)
-#line 160
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 160
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 160
 		error("Unexpected var_name");
-#line 160
 	    IF (datatype != var_type[i])
-#line 160
 		error("Unexpected type");
-#line 160
 	    IF (ndims != var_rank[i])
-#line 160
 		error("Unexpected rank");
-#line 160
 	    for (j = 0; j < ndims; j++) {
-#line 160
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 160
 		IF (err)
-#line 160
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 160
 		IF (length != var_shape[i][j])
-#line 160
 		    error("Unexpected shape");
-#line 160
 	    }
-#line 160
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 160
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 160
 		IF (err)
-#line 160
 		    error("error in toMixedBase 2");
-#line 160
 		expect = hash4( var_type[i], var_rank[i], index, NCT_LONG);
-#line 160
 		err = nc_get_var1_long(ncid, i, index, &value);
-#line 160
 		if (inRange3(expect,datatype,NCT_LONG)) {
-#line 160
                     if (expect >= long_min && expect <= long_max) {
-#line 160
 			IF (err) {
-#line 160
 			    error("nc_get_var1_long: %s", nc_strerror(err));
-#line 160
 			} else {
-#line 160
                             IF (!equal(value,expect,var_type[i],NCT_LONG)) {
-#line 160
 				error("Var value read not that expected");
-#line 160
 				if (verbose) {
-#line 160
 				    error("\n");
-#line 160
 				    error("varid: %d, ", i);
-#line 160
 				    error("var_name: %s, ", var_name[i]);
-#line 160
 				    error("index:");
-#line 160
 				    for (d = 0; d < var_rank[i]; d++)
-#line 160
 					error(" %d", index[d]);
-#line 160
 				    error(", expect: %g, ", expect);
-#line 160
 				    error("got: %g", (double) value);
-#line 160
 				}
-#line 160
 			    } else {
-#line 160
 				++nok;
-#line 160
 			    }
-#line 160
 			}
-#line 160
 		    }
-#line 160
 		}
-#line 160
 	    }
-#line 160
 	}
-#line 160
     }
-#line 160
     err = nc_close (ncid);
-#line 160
     IF (err)
-#line 160
         error("nc_close: %s", nc_strerror(err));
-#line 160
     print_nok(nok);
-#line 160
 }
-#line 160
 
 /* 
-#line 161
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 161
  */
-#line 161
 static
-#line 161
 void
-#line 161
 check_vars_float(const char *filename)
-#line 161
 {
-#line 161
     int  ncid;                  /* netCDF id */
-#line 161
     size_t index[MAX_RANK];
-#line 161
     int  err;           /* status */
-#line 161
     int  d;
-#line 161
     int  i;
-#line 161
     size_t  j;
-#line 161
     float value;
-#line 161
     nc_type datatype;
-#line 161
     int ndims;
-#line 161
     int dimids[MAX_RANK];
-#line 161
     double expect;
-#line 161
     char name[NC_MAX_NAME];
-#line 161
     size_t length;
-#line 161
     int canConvert;     /* Both text or both numeric */
-#line 161
     int nok = 0;      /* count of valid comparisons */
-#line 161
 
-#line 161
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 161
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 161
         error("nc_open: %s", nc_strerror(err));
-#line 161
 
-#line 161
-    for (i = 0; i < NVARS; i++) {
-#line 161
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 161
 	if (canConvert) {
-#line 161
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 161
 	    IF (err)
-#line 161
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 161
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 161
 		error("Unexpected var_name");
-#line 161
 	    IF (datatype != var_type[i])
-#line 161
 		error("Unexpected type");
-#line 161
 	    IF (ndims != var_rank[i])
-#line 161
 		error("Unexpected rank");
-#line 161
 	    for (j = 0; j < ndims; j++) {
-#line 161
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 161
 		IF (err)
-#line 161
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 161
 		IF (length != var_shape[i][j])
-#line 161
 		    error("Unexpected shape");
-#line 161
 	    }
-#line 161
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 161
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 161
 		IF (err)
-#line 161
 		    error("error in toMixedBase 2");
-#line 161
 		expect = hash4( var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 161
 		err = nc_get_var1_float(ncid, i, index, &value);
-#line 161
 		if (inRange3(expect,datatype,NCT_FLOAT)) {
-#line 161
                     if (expect >= float_min && expect <= float_max) {
-#line 161
 			IF (err) {
-#line 161
 			    error("nc_get_var1_float: %s", nc_strerror(err));
-#line 161
 			} else {
-#line 161
                             IF (!equal(value,expect,var_type[i],NCT_FLOAT)) {
-#line 161
 				error("Var value read not that expected");
-#line 161
 				if (verbose) {
-#line 161
 				    error("\n");
-#line 161
 				    error("varid: %d, ", i);
-#line 161
 				    error("var_name: %s, ", var_name[i]);
-#line 161
 				    error("index:");
-#line 161
 				    for (d = 0; d < var_rank[i]; d++)
-#line 161
 					error(" %d", index[d]);
-#line 161
 				    error(", expect: %g, ", expect);
-#line 161
 				    error("got: %g", (double) value);
-#line 161
 				}
-#line 161
 			    } else {
-#line 161
 				++nok;
-#line 161
 			    }
-#line 161
 			}
-#line 161
 		    }
-#line 161
 		}
-#line 161
 	    }
-#line 161
 	}
-#line 161
     }
-#line 161
     err = nc_close (ncid);
-#line 161
     IF (err)
-#line 161
         error("nc_close: %s", nc_strerror(err));
-#line 161
     print_nok(nok);
-#line 161
 }
-#line 161
 
 /* 
-#line 162
  *  check all vars in file which are (text/numeric) compatible with TYPE
-#line 162
  */
-#line 162
 static
-#line 162
 void
-#line 162
 check_vars_double(const char *filename)
-#line 162
 {
-#line 162
     int  ncid;                  /* netCDF id */
-#line 162
     size_t index[MAX_RANK];
-#line 162
     int  err;           /* status */
-#line 162
     int  d;
-#line 162
     int  i;
-#line 162
     size_t  j;
-#line 162
     double value;
-#line 162
     nc_type datatype;
-#line 162
     int ndims;
-#line 162
     int dimids[MAX_RANK];
-#line 162
     double expect;
-#line 162
     char name[NC_MAX_NAME];
-#line 162
     size_t length;
-#line 162
     int canConvert;     /* Both text or both numeric */
-#line 162
     int nok = 0;      /* count of valid comparisons */
-#line 162
 
-#line 162
-    err = nc_open(filename, NC_NOWRITE, &ncid);
-#line 162
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
-#line 162
         error("nc_open: %s", nc_strerror(err));
-#line 162
 
-#line 162
-    for (i = 0; i < NVARS; i++) {
-#line 162
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 162
 	if (canConvert) {
-#line 162
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
-#line 162
 	    IF (err)
-#line 162
 		error("nc_inq_var: %s", nc_strerror(err));
-#line 162
 	    IF (strcmp(name, var_name[i]) != 0)
-#line 162
 		error("Unexpected var_name");
-#line 162
 	    IF (datatype != var_type[i])
-#line 162
 		error("Unexpected type");
-#line 162
 	    IF (ndims != var_rank[i])
-#line 162
 		error("Unexpected rank");
-#line 162
 	    for (j = 0; j < ndims; j++) {
-#line 162
 		err = nc_inq_dim(ncid, dimids[j], 0, &length);
-#line 162
 		IF (err)
-#line 162
 		    error("nc_inq_dim: %s", nc_strerror(err));
-#line 162
 		IF (length != var_shape[i][j])
-#line 162
 		    error("Unexpected shape");
-#line 162
 	    }
-#line 162
 	    for (j = 0; j < var_nels[i]; j++) {
-#line 162
 		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 162
 		IF (err)
-#line 162
 		    error("error in toMixedBase 2");
-#line 162
 		expect = hash4( var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 162
 		err = nc_get_var1_double(ncid, i, index, &value);
-#line 162
 		if (inRange3(expect,datatype,NCT_DOUBLE)) {
-#line 162
                     if (expect >= double_min && expect <= double_max) {
-#line 162
 			IF (err) {
-#line 162
 			    error("nc_get_var1_double: %s", nc_strerror(err));
-#line 162
 			} else {
-#line 162
                             IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) {
-#line 162
 				error("Var value read not that expected");
-#line 162
 				if (verbose) {
-#line 162
 				    error("\n");
-#line 162
 				    error("varid: %d, ", i);
-#line 162
 				    error("var_name: %s, ", var_name[i]);
-#line 162
 				    error("index:");
-#line 162
 				    for (d = 0; d < var_rank[i]; d++)
-#line 162
 					error(" %d", index[d]);
-#line 162
 				    error(", expect: %g, ", expect);
-#line 162
 				    error("got: %g", (double) value);
-#line 162
 				}
-#line 162
 			    } else {
-#line 162
 				++nok;
-#line 162
 			    }
-#line 162
 			}
-#line 162
 		    }
-#line 162
 		}
-#line 162
 	    }
-#line 162
 	}
-#line 162
     }
-#line 162
     err = nc_close (ncid);
-#line 162
     IF (err)
-#line 162
         error("nc_close: %s", nc_strerror(err));
-#line 162
     print_nok(nok);
-#line 162
 }
-#line 162
-
-
-
-#line 244
 
 /* 
-#line 245
- *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 245
- *  ignore any attributes containing values outside range of TYPE
-#line 245
+ *  check all vars in file which are (text/numeric) compatible with TYPE
  */
-#line 245
 static
-#line 245
 void
-#line 245
-check_atts_text(int  ncid)
-#line 245
+check_vars_ushort(const char *filename)
 {
-#line 245
+    int  ncid;                  /* netCDF id */
+    size_t index[MAX_RANK];
     int  err;           /* status */
-#line 245
+    int  d;
     int  i;
-#line 245
-    int  j;
-#line 245
-    size_t  k;
-#line 245
-    text value[MAX_NELS];
-#line 245
+    size_t  j;
+    ushort value;
     nc_type datatype;
-#line 245
-    double expect[MAX_NELS];
-#line 245
+    int ndims;
+    int dimids[MAX_RANK];
+    double expect;
+    char name[NC_MAX_NAME];
     size_t length;
-#line 245
-    size_t nInExtRange;  /* number values within external range */
-#line 245
-    size_t nInIntRange;  /* number values within internal range */
-#line 245
     int canConvert;     /* Both text or both numeric */
-#line 245
     int nok = 0;      /* count of valid comparisons */
-#line 245
 
-#line 245
-    for (i = -1; i < NVARS; i++) {
-#line 245
-        for (j = 0; j < NATTS(i); j++) {
-#line 245
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 245
-	    if (canConvert) {
-#line 245
-		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 245
+    err = file_open(filename, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+	if (canConvert) {
+	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+	    IF (err)
+		error("nc_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)
-#line 245
-		    error("nc_inq_att: %s", nc_strerror(err));
-#line 245
-		IF (datatype != ATT_TYPE(i,j))
-#line 245
-		error("nc_inq_att: unexpected type");
-#line 245
-		IF (length != ATT_LEN(i,j))
-#line 245
-		    error("nc_inq_att: unexpected length");
-#line 245
-		assert(length <= MAX_NELS);
-#line 245
-		nInIntRange = nInExtRange = 0;
-#line 245
-		for (k = 0; k < length; k++) {
-#line 245
-		    expect[k] = hash4( datatype, -1, &k, NCT_TEXT);
-#line 245
-		    if (inRange3(expect[k], datatype, NCT_TEXT)) {
-#line 245
-			++nInExtRange;
-#line 245
-			if (expect[k] >= text_min && expect[k] <= text_max)
-#line 245
-			    ++nInIntRange;
-#line 245
+		    error("nc_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)
+		    error("error in toMixedBase 2");
+		expect = hash4( var_type[i], var_rank[i], index, NCT_USHORT);
+		err = nc_get_var1_ushort(ncid, i, index, &value);
+		if (inRange3(expect,datatype,NCT_USHORT)) {
+                    if (expect >= ushort_min && expect <= ushort_max) {
+			IF (err) {
+			    error("nc_get_var1_ushort: %s", nc_strerror(err));
+			} else {
+                            IF (!equal(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("index:");
+				    for (d = 0; d < var_rank[i]; d++)
+					error(" %d", index[d]);
+				    error(", expect: %g, ", expect);
+				    error("got: %g", (double) value);
+				}
+			    } else {
+				++nok;
+			    }
+			}
 		    }
-#line 245
 		}
-#line 245
-		err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value);
-#line 245
-                if (nInExtRange == length && nInIntRange == length) {
-#line 245
-		    IF (err)
-#line 245
-			error("%s", nc_strerror(err));
-#line 245
-                } else {
-#line 245
-                    IF (err != 0 && err != NC_ERANGE)
-#line 245
-                        error("OK or Range error: status = %d", err);
-#line 245
-                }
-#line 245
-		for (k = 0; k < length; k++) {
-#line 245
-                    if (inRange3(expect[k],datatype,NCT_TEXT)
-#line 245
-                            && expect[k] >= text_min && expect[k] <= text_max) {
-#line 245
-                        IF (!equal(value[k],expect[k],datatype,NCT_TEXT)) {
-#line 245
-                            error("att. value read not that expected");
-#line 245
-                            if (verbose) {
-#line 245
-                                error("\n");
-#line 245
-                                error("varid: %d, ", i);
-#line 245
-                                error("att_name: %s, ", ATT_NAME(i,j));
-#line 245
-                                error("element number: %d ", k);
-#line 245
-                                error("expect: %g, ", expect[k]);
-#line 245
-                                error("got: %g", (double) value[k]);
-#line 245
-                            }
-#line 245
-                        } else {
-#line 245
-                            nok++;
-#line 245
-                        }
-#line 245
-                    }
-#line 245
-                }
-#line 245
-            }                                               
-#line 245
-        }
-#line 245
+	    }
+	}
     }
-#line 245
-
-#line 245
+    err = nc_close (ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 245
 }
-#line 245
 
 /* 
-#line 246
- *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 246
- *  ignore any attributes containing values outside range of TYPE
-#line 246
+ *  check all vars in file which are (text/numeric) compatible with TYPE
  */
-#line 246
 static
-#line 246
 void
-#line 246
-check_atts_uchar(int  ncid)
-#line 246
+check_vars_uint(const char *filename)
 {
-#line 246
+    int  ncid;                  /* netCDF id */
+    size_t index[MAX_RANK];
     int  err;           /* status */
-#line 246
+    int  d;
     int  i;
-#line 246
-    int  j;
-#line 246
-    size_t  k;
-#line 246
-    uchar value[MAX_NELS];
-#line 246
+    size_t  j;
+    uint value;
     nc_type datatype;
-#line 246
-    double expect[MAX_NELS];
-#line 246
+    int ndims;
+    int dimids[MAX_RANK];
+    double expect;
+    char name[NC_MAX_NAME];
     size_t length;
-#line 246
-    size_t nInExtRange;  /* number values within external range */
-#line 246
-    size_t nInIntRange;  /* number values within internal range */
-#line 246
     int canConvert;     /* Both text or both numeric */
-#line 246
     int nok = 0;      /* count of valid comparisons */
-#line 246
 
-#line 246
-    for (i = -1; i < NVARS; i++) {
-#line 246
-        for (j = 0; j < NATTS(i); j++) {
-#line 246
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 246
-	    if (canConvert) {
-#line 246
-		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 246
+    err = file_open(filename, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+	if (canConvert) {
+	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+	    IF (err)
+		error("nc_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)
-#line 246
-		    error("nc_inq_att: %s", nc_strerror(err));
-#line 246
-		IF (datatype != ATT_TYPE(i,j))
-#line 246
-		error("nc_inq_att: unexpected type");
-#line 246
-		IF (length != ATT_LEN(i,j))
-#line 246
-		    error("nc_inq_att: unexpected length");
-#line 246
-		assert(length <= MAX_NELS);
-#line 246
-		nInIntRange = nInExtRange = 0;
-#line 246
-		for (k = 0; k < length; k++) {
-#line 246
-		    expect[k] = hash4( datatype, -1, &k, NCT_UCHAR);
-#line 246
-		    if (inRange3(expect[k], datatype, NCT_UCHAR)) {
-#line 246
-			++nInExtRange;
-#line 246
-			if (expect[k] >= uchar_min && expect[k] <= uchar_max)
-#line 246
-			    ++nInIntRange;
-#line 246
+		    error("nc_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)
+		    error("error in toMixedBase 2");
+		expect = hash4( var_type[i], var_rank[i], index, NCT_UINT);
+		err = nc_get_var1_uint(ncid, i, index, &value);
+		if (inRange3(expect,datatype,NCT_UINT)) {
+                    if (expect >= uint_min && expect <= uint_max) {
+			IF (err) {
+			    error("nc_get_var1_uint: %s", nc_strerror(err));
+			} else {
+                            IF (!equal(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("index:");
+				    for (d = 0; d < var_rank[i]; d++)
+					error(" %d", index[d]);
+				    error(", expect: %g, ", expect);
+				    error("got: %g", (double) value);
+				}
+			    } else {
+				++nok;
+			    }
+			}
 		    }
-#line 246
 		}
-#line 246
-		err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
-#line 246
-                if (nInExtRange == length && nInIntRange == length) {
-#line 246
-		    IF (err)
-#line 246
-			error("%s", nc_strerror(err));
-#line 246
-                } else {
-#line 246
-                    IF (err != 0 && err != NC_ERANGE)
-#line 246
-                        error("OK or Range error: status = %d", err);
-#line 246
-                }
-#line 246
-		for (k = 0; k < length; k++) {
-#line 246
-                    if (inRange3(expect[k],datatype,NCT_UCHAR)
-#line 246
-                            && expect[k] >= uchar_min && expect[k] <= uchar_max) {
-#line 246
-                        IF (!equal(value[k],expect[k],datatype,NCT_UCHAR)) {
-#line 246
-                            error("att. value read not that expected");
-#line 246
-                            if (verbose) {
-#line 246
-                                error("\n");
-#line 246
-                                error("varid: %d, ", i);
-#line 246
-                                error("att_name: %s, ", ATT_NAME(i,j));
-#line 246
-                                error("element number: %d ", k);
-#line 246
-                                error("expect: %g, ", expect[k]);
-#line 246
-                                error("got: %g", (double) value[k]);
-#line 246
-                            }
-#line 246
-                        } else {
-#line 246
-                            nok++;
-#line 246
-                        }
-#line 246
-                    }
-#line 246
-                }
-#line 246
-            }                                               
-#line 246
-        }
-#line 246
+	    }
+	}
+    }
+    err = nc_close (ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
+
+/* 
+ *  check all vars in file which are (text/numeric) compatible with TYPE
+ */
+static
+void
+check_vars_longlong(const char *filename)
+{
+    int  ncid;                  /* netCDF id */
+    size_t index[MAX_RANK];
+    int  err;           /* status */
+    int  d;
+    int  i;
+    size_t  j;
+    longlong value;
+    nc_type datatype;
+    int ndims;
+    int dimids[MAX_RANK];
+    double expect;
+    char name[NC_MAX_NAME];
+    size_t length;
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    err = file_open(filename, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+	if (canConvert) {
+	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+	    IF (err)
+		error("nc_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)
+		    error("nc_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)
+		    error("error in toMixedBase 2");
+		expect = hash4( var_type[i], var_rank[i], index, NCT_LONGLONG);
+		err = nc_get_var1_longlong(ncid, i, index, &value);
+		if (inRange3(expect,datatype,NCT_LONGLONG)) {
+                    if (expect >= longlong_min && expect <= longlong_max) {
+			IF (err) {
+			    error("nc_get_var1_longlong: %s", nc_strerror(err));
+			} else {
+                            IF (!equal(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("index:");
+				    for (d = 0; d < var_rank[i]; d++)
+					error(" %d", index[d]);
+				    error(", expect: %g, ", expect);
+				    error("got: %g", (double) value);
+				}
+			    } else {
+				++nok;
+			    }
+			}
+		    }
+		}
+	    }
+	}
     }
-#line 246
+    err = nc_close (ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+    print_nok(nok);
+}
 
-#line 246
+/* 
+ *  check all vars in file which are (text/numeric) compatible with TYPE
+ */
+static
+void
+check_vars_ulonglong(const char *filename)
+{
+    int  ncid;                  /* netCDF id */
+    size_t index[MAX_RANK];
+    int  err;           /* status */
+    int  d;
+    int  i;
+    size_t  j;
+    ulonglong value;
+    nc_type datatype;
+    int ndims;
+    int dimids[MAX_RANK];
+    double expect;
+    char name[NC_MAX_NAME];
+    size_t length;
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    err = file_open(filename, NC_NOWRITE, &ncid);
+    IF (err)
+        error("nc_open: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+	if (canConvert) {
+	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
+	    IF (err)
+		error("nc_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)
+		    error("nc_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)
+		    error("error in toMixedBase 2");
+		expect = hash4( var_type[i], var_rank[i], index, NCT_ULONGLONG);
+		err = nc_get_var1_ulonglong(ncid, i, index, &value);
+		if (inRange3(expect,datatype,NCT_ULONGLONG)) {
+                    if (expect >= ulonglong_min && expect <= ulonglong_max) {
+			IF (err) {
+			    error("nc_get_var1_ulonglong: %s", nc_strerror(err));
+			} else {
+                            IF (!equal(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("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)
+        error("nc_close: %s", nc_strerror(err));
     print_nok(nok);
-#line 246
 }
-#line 246
+
+
+
 
 /* 
-#line 247
  *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 247
  *  ignore any attributes containing values outside range of TYPE
-#line 247
  */
-#line 247
 static
-#line 247
 void
-#line 247
-check_atts_schar(int  ncid)
-#line 247
+check_atts_text(int  ncid)
 {
-#line 247
     int  err;           /* status */
-#line 247
     int  i;
-#line 247
     int  j;
-#line 247
     size_t  k;
-#line 247
-    schar value[MAX_NELS];
-#line 247
+    text value[MAX_NELS];
     nc_type datatype;
-#line 247
     double expect[MAX_NELS];
-#line 247
     size_t length;
-#line 247
     size_t nInExtRange;  /* number values within external range */
-#line 247
     size_t nInIntRange;  /* number values within internal range */
-#line 247
     int canConvert;     /* Both text or both numeric */
-#line 247
     int nok = 0;      /* count of valid comparisons */
-#line 247
 
-#line 247
-    for (i = -1; i < NVARS; i++) {
-#line 247
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 247
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 247
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
 	    if (canConvert) {
-#line 247
 		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 247
 		IF (err)
-#line 247
 		    error("nc_inq_att: %s", nc_strerror(err));
-#line 247
 		IF (datatype != ATT_TYPE(i,j))
-#line 247
 		error("nc_inq_att: unexpected type");
-#line 247
 		IF (length != ATT_LEN(i,j))
-#line 247
 		    error("nc_inq_att: unexpected length");
-#line 247
 		assert(length <= MAX_NELS);
-#line 247
 		nInIntRange = nInExtRange = 0;
-#line 247
 		for (k = 0; k < length; k++) {
-#line 247
-		    expect[k] = hash4( datatype, -1, &k, NCT_SCHAR);
-#line 247
-		    if (inRange3(expect[k], datatype, NCT_SCHAR)) {
-#line 247
+		    expect[k] = hash4( datatype, -1, &k, NCT_TEXT);
+		    if (inRange3(expect[k], datatype, NCT_TEXT)) {
 			++nInExtRange;
-#line 247
-			if (expect[k] >= schar_min && expect[k] <= schar_max)
-#line 247
+			if (expect[k] >= text_min && expect[k] <= text_max)
 			    ++nInIntRange;
-#line 247
 		    }
-#line 247
 		}
-#line 247
-		err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
-#line 247
+		err = nc_get_att_text(ncid, i, ATT_NAME(i,j), value);
                 if (nInExtRange == length && nInIntRange == length) {
-#line 247
 		    IF (err)
-#line 247
 			error("%s", nc_strerror(err));
-#line 247
                 } else {
-#line 247
                     IF (err != 0 && err != NC_ERANGE)
-#line 247
                         error("OK or Range error: status = %d", err);
-#line 247
                 }
-#line 247
 		for (k = 0; k < length; k++) {
-#line 247
-                    if (inRange3(expect[k],datatype,NCT_SCHAR)
-#line 247
-                            && expect[k] >= schar_min && expect[k] <= schar_max) {
-#line 247
-                        IF (!equal(value[k],expect[k],datatype,NCT_SCHAR)) {
-#line 247
+                    if (inRange3(expect[k],datatype,NCT_TEXT)
+                            && expect[k] >= text_min && expect[k] <= text_max) {
+                        IF (!equal(value[k],expect[k],datatype,NCT_TEXT)) {
                             error("att. value read not that expected");
-#line 247
                             if (verbose) {
-#line 247
                                 error("\n");
-#line 247
                                 error("varid: %d, ", i);
-#line 247
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 247
                                 error("element number: %d ", k);
-#line 247
                                 error("expect: %g, ", expect[k]);
-#line 247
                                 error("got: %g", (double) value[k]);
-#line 247
                             }
-#line 247
                         } else {
-#line 247
                             nok++;
-#line 247
                         }
-#line 247
                     }
-#line 247
                 }
-#line 247
             }                                               
-#line 247
         }
-#line 247
     }
-#line 247
 
-#line 247
     print_nok(nok);
-#line 247
 }
-#line 247
 
 /* 
-#line 248
  *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 248
  *  ignore any attributes containing values outside range of TYPE
-#line 248
  */
-#line 248
 static
-#line 248
 void
-#line 248
-check_atts_short(int  ncid)
-#line 248
+check_atts_uchar(int  ncid)
 {
-#line 248
     int  err;           /* status */
-#line 248
     int  i;
-#line 248
     int  j;
-#line 248
     size_t  k;
-#line 248
-    short value[MAX_NELS];
-#line 248
+    uchar value[MAX_NELS];
     nc_type datatype;
-#line 248
     double expect[MAX_NELS];
-#line 248
     size_t length;
-#line 248
     size_t nInExtRange;  /* number values within external range */
-#line 248
     size_t nInIntRange;  /* number values within internal range */
-#line 248
     int canConvert;     /* Both text or both numeric */
-#line 248
     int nok = 0;      /* count of valid comparisons */
-#line 248
 
-#line 248
-    for (i = -1; i < NVARS; i++) {
-#line 248
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 248
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 248
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
 	    if (canConvert) {
-#line 248
 		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 248
 		IF (err)
-#line 248
 		    error("nc_inq_att: %s", nc_strerror(err));
-#line 248
 		IF (datatype != ATT_TYPE(i,j))
-#line 248
 		error("nc_inq_att: unexpected type");
-#line 248
 		IF (length != ATT_LEN(i,j))
-#line 248
 		    error("nc_inq_att: unexpected length");
-#line 248
 		assert(length <= MAX_NELS);
-#line 248
 		nInIntRange = nInExtRange = 0;
-#line 248
 		for (k = 0; k < length; k++) {
-#line 248
-		    expect[k] = hash4( datatype, -1, &k, NCT_SHORT);
-#line 248
-		    if (inRange3(expect[k], datatype, NCT_SHORT)) {
-#line 248
+		    expect[k] = hash4( datatype, -1, &k, NCT_UCHAR);
+		    if (inRange3(expect[k], datatype, NCT_UCHAR)) {
 			++nInExtRange;
-#line 248
-			if (expect[k] >= short_min && expect[k] <= short_max)
-#line 248
+			if (expect[k] >= uchar_min && expect[k] <= uchar_max)
 			    ++nInIntRange;
-#line 248
 		    }
-#line 248
 		}
-#line 248
-		err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
-#line 248
+		err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
                 if (nInExtRange == length && nInIntRange == length) {
-#line 248
 		    IF (err)
-#line 248
 			error("%s", nc_strerror(err));
-#line 248
                 } else {
-#line 248
                     IF (err != 0 && err != NC_ERANGE)
-#line 248
                         error("OK or Range error: status = %d", err);
-#line 248
                 }
-#line 248
 		for (k = 0; k < length; k++) {
-#line 248
-                    if (inRange3(expect[k],datatype,NCT_SHORT)
-#line 248
-                            && expect[k] >= short_min && expect[k] <= short_max) {
-#line 248
-                        IF (!equal(value[k],expect[k],datatype,NCT_SHORT)) {
-#line 248
+                    if (inRange3(expect[k],datatype,NCT_UCHAR)
+                            && expect[k] >= uchar_min && expect[k] <= uchar_max) {
+                        IF (!equal(value[k],expect[k],datatype,NCT_UCHAR)) {
                             error("att. value read not that expected");
-#line 248
                             if (verbose) {
-#line 248
                                 error("\n");
-#line 248
                                 error("varid: %d, ", i);
-#line 248
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 248
                                 error("element number: %d ", k);
-#line 248
                                 error("expect: %g, ", expect[k]);
-#line 248
                                 error("got: %g", (double) value[k]);
-#line 248
                             }
-#line 248
                         } else {
-#line 248
                             nok++;
-#line 248
                         }
-#line 248
                     }
-#line 248
                 }
-#line 248
             }                                               
-#line 248
         }
-#line 248
     }
-#line 248
 
-#line 248
     print_nok(nok);
-#line 248
 }
-#line 248
 
 /* 
-#line 249
  *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 249
  *  ignore any attributes containing values outside range of TYPE
-#line 249
  */
-#line 249
 static
-#line 249
 void
-#line 249
-check_atts_int(int  ncid)
-#line 249
+check_atts_schar(int  ncid)
 {
-#line 249
     int  err;           /* status */
-#line 249
     int  i;
-#line 249
     int  j;
-#line 249
     size_t  k;
-#line 249
-    int value[MAX_NELS];
-#line 249
+    schar value[MAX_NELS];
     nc_type datatype;
-#line 249
     double expect[MAX_NELS];
-#line 249
     size_t length;
-#line 249
     size_t nInExtRange;  /* number values within external range */
-#line 249
     size_t nInIntRange;  /* number values within internal range */
-#line 249
     int canConvert;     /* Both text or both numeric */
-#line 249
     int nok = 0;      /* count of valid comparisons */
-#line 249
 
-#line 249
-    for (i = -1; i < NVARS; i++) {
-#line 249
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 249
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 249
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
 	    if (canConvert) {
-#line 249
 		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 249
 		IF (err)
-#line 249
 		    error("nc_inq_att: %s", nc_strerror(err));
-#line 249
 		IF (datatype != ATT_TYPE(i,j))
-#line 249
 		error("nc_inq_att: unexpected type");
-#line 249
 		IF (length != ATT_LEN(i,j))
-#line 249
 		    error("nc_inq_att: unexpected length");
-#line 249
 		assert(length <= MAX_NELS);
-#line 249
 		nInIntRange = nInExtRange = 0;
-#line 249
 		for (k = 0; k < length; k++) {
-#line 249
-		    expect[k] = hash4( datatype, -1, &k, NCT_INT);
-#line 249
-		    if (inRange3(expect[k], datatype, NCT_INT)) {
-#line 249
+		    expect[k] = hash4( datatype, -1, &k, NCT_SCHAR);
+		    if (inRange3(expect[k], datatype, NCT_SCHAR)) {
 			++nInExtRange;
-#line 249
-			if (expect[k] >= int_min && expect[k] <= int_max)
-#line 249
+			if (expect[k] >= schar_min && expect[k] <= schar_max)
 			    ++nInIntRange;
-#line 249
 		    }
-#line 249
 		}
-#line 249
-		err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
-#line 249
+		err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
                 if (nInExtRange == length && nInIntRange == length) {
-#line 249
 		    IF (err)
-#line 249
 			error("%s", nc_strerror(err));
-#line 249
                 } else {
-#line 249
                     IF (err != 0 && err != NC_ERANGE)
-#line 249
                         error("OK or Range error: status = %d", err);
-#line 249
                 }
-#line 249
 		for (k = 0; k < length; k++) {
-#line 249
-                    if (inRange3(expect[k],datatype,NCT_INT)
-#line 249
-                            && expect[k] >= int_min && expect[k] <= int_max) {
-#line 249
-                        IF (!equal(value[k],expect[k],datatype,NCT_INT)) {
-#line 249
+                    if (inRange3(expect[k],datatype,NCT_SCHAR)
+                            && expect[k] >= schar_min && expect[k] <= schar_max) {
+                        IF (!equal(value[k],expect[k],datatype,NCT_SCHAR)) {
                             error("att. value read not that expected");
-#line 249
                             if (verbose) {
-#line 249
                                 error("\n");
-#line 249
                                 error("varid: %d, ", i);
-#line 249
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 249
                                 error("element number: %d ", k);
-#line 249
                                 error("expect: %g, ", expect[k]);
-#line 249
                                 error("got: %g", (double) value[k]);
-#line 249
                             }
-#line 249
                         } else {
-#line 249
                             nok++;
-#line 249
                         }
-#line 249
                     }
-#line 249
                 }
-#line 249
             }                                               
-#line 249
         }
-#line 249
     }
-#line 249
 
-#line 249
     print_nok(nok);
-#line 249
 }
-#line 249
 
 /* 
-#line 250
  *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 250
  *  ignore any attributes containing values outside range of TYPE
-#line 250
  */
-#line 250
 static
-#line 250
 void
-#line 250
-check_atts_long(int  ncid)
-#line 250
+check_atts_short(int  ncid)
 {
-#line 250
     int  err;           /* status */
-#line 250
     int  i;
-#line 250
     int  j;
-#line 250
     size_t  k;
-#line 250
-    long value[MAX_NELS];
-#line 250
+    short value[MAX_NELS];
     nc_type datatype;
-#line 250
     double expect[MAX_NELS];
-#line 250
     size_t length;
-#line 250
     size_t nInExtRange;  /* number values within external range */
-#line 250
     size_t nInIntRange;  /* number values within internal range */
-#line 250
     int canConvert;     /* Both text or both numeric */
-#line 250
     int nok = 0;      /* count of valid comparisons */
-#line 250
 
-#line 250
-    for (i = -1; i < NVARS; i++) {
-#line 250
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 250
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 250
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
 	    if (canConvert) {
-#line 250
 		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 250
 		IF (err)
-#line 250
 		    error("nc_inq_att: %s", nc_strerror(err));
-#line 250
 		IF (datatype != ATT_TYPE(i,j))
-#line 250
 		error("nc_inq_att: unexpected type");
-#line 250
 		IF (length != ATT_LEN(i,j))
-#line 250
 		    error("nc_inq_att: unexpected length");
-#line 250
 		assert(length <= MAX_NELS);
-#line 250
 		nInIntRange = nInExtRange = 0;
-#line 250
 		for (k = 0; k < length; k++) {
-#line 250
-		    expect[k] = hash4( datatype, -1, &k, NCT_LONG);
-#line 250
-		    if (inRange3(expect[k], datatype, NCT_LONG)) {
-#line 250
+		    expect[k] = hash4( datatype, -1, &k, NCT_SHORT);
+		    if (inRange3(expect[k], datatype, NCT_SHORT)) {
 			++nInExtRange;
-#line 250
-			if (expect[k] >= long_min && expect[k] <= long_max)
-#line 250
+			if (expect[k] >= short_min && expect[k] <= short_max)
 			    ++nInIntRange;
-#line 250
 		    }
-#line 250
 		}
-#line 250
-		err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
-#line 250
+		err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
                 if (nInExtRange == length && nInIntRange == length) {
-#line 250
 		    IF (err)
-#line 250
 			error("%s", nc_strerror(err));
-#line 250
                 } else {
-#line 250
                     IF (err != 0 && err != NC_ERANGE)
-#line 250
                         error("OK or Range error: status = %d", err);
-#line 250
                 }
-#line 250
 		for (k = 0; k < length; k++) {
-#line 250
-                    if (inRange3(expect[k],datatype,NCT_LONG)
-#line 250
-                            && expect[k] >= long_min && expect[k] <= long_max) {
-#line 250
-                        IF (!equal(value[k],expect[k],datatype,NCT_LONG)) {
-#line 250
+                    if (inRange3(expect[k],datatype,NCT_SHORT)
+                            && expect[k] >= short_min && expect[k] <= short_max) {
+                        IF (!equal(value[k],expect[k],datatype,NCT_SHORT)) {
                             error("att. value read not that expected");
-#line 250
                             if (verbose) {
-#line 250
                                 error("\n");
-#line 250
                                 error("varid: %d, ", i);
-#line 250
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 250
                                 error("element number: %d ", k);
-#line 250
                                 error("expect: %g, ", expect[k]);
-#line 250
                                 error("got: %g", (double) value[k]);
-#line 250
                             }
-#line 250
                         } else {
-#line 250
                             nok++;
-#line 250
                         }
-#line 250
                     }
-#line 250
                 }
-#line 250
             }                                               
-#line 250
         }
-#line 250
     }
-#line 250
 
-#line 250
     print_nok(nok);
-#line 250
 }
-#line 250
 
 /* 
-#line 251
  *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 251
  *  ignore any attributes containing values outside range of TYPE
-#line 251
  */
-#line 251
 static
-#line 251
 void
-#line 251
-check_atts_float(int  ncid)
-#line 251
+check_atts_int(int  ncid)
 {
-#line 251
     int  err;           /* status */
-#line 251
     int  i;
-#line 251
     int  j;
-#line 251
     size_t  k;
-#line 251
-    float value[MAX_NELS];
-#line 251
+    int value[MAX_NELS];
     nc_type datatype;
-#line 251
     double expect[MAX_NELS];
-#line 251
     size_t length;
-#line 251
     size_t nInExtRange;  /* number values within external range */
-#line 251
     size_t nInIntRange;  /* number values within internal range */
-#line 251
     int canConvert;     /* Both text or both numeric */
-#line 251
     int nok = 0;      /* count of valid comparisons */
-#line 251
 
-#line 251
-    for (i = -1; i < NVARS; i++) {
-#line 251
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 251
-	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 251
+	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == NCT_TEXT);
 	    if (canConvert) {
-#line 251
 		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 251
 		IF (err)
-#line 251
 		    error("nc_inq_att: %s", nc_strerror(err));
-#line 251
 		IF (datatype != ATT_TYPE(i,j))
-#line 251
 		error("nc_inq_att: unexpected type");
-#line 251
 		IF (length != ATT_LEN(i,j))
-#line 251
 		    error("nc_inq_att: unexpected length");
-#line 251
 		assert(length <= MAX_NELS);
-#line 251
 		nInIntRange = nInExtRange = 0;
-#line 251
 		for (k = 0; k < length; k++) {
-#line 251
-		    expect[k] = hash4( datatype, -1, &k, NCT_FLOAT);
-#line 251
+		    expect[k] = hash4( datatype, -1, &k, NCT_INT);
+		    if (inRange3(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)
+			error("%s", nc_strerror(err));
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < length; k++) {
+                    if (inRange3(expect[k],datatype,NCT_INT)
+                            && expect[k] >= int_min && expect[k] <= int_max) {
+                        IF (!equal(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("element number: %d ", k);
+                                error("expect: %g, ", expect[k]);
+                                error("got: %g", (double) value[k]);
+                            }
+                        } else {
+                            nok++;
+                        }
+                    }
+                }
+            }                                               
+        }
+    }
+
+    print_nok(nok);
+}
+
+/* 
+ *  check all attributes in file which are (text/numeric) compatible with TYPE
+ *  ignore any attributes containing values outside range of TYPE
+ */
+static
+void
+check_atts_long(int  ncid)
+{
+    int  err;           /* status */
+    int  i;
+    int  j;
+    size_t  k;
+    long value[MAX_NELS];
+    nc_type datatype;
+    double expect[MAX_NELS];
+    size_t length;
+    size_t nInExtRange;  /* number values within external range */
+    size_t nInIntRange;  /* number values within internal range */
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    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) {
+		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+		IF (err)
+		    error("nc_inq_att: %s", nc_strerror(err));
+		IF (datatype != ATT_TYPE(i,j))
+		error("nc_inq_att: unexpected type");
+		IF (length != ATT_LEN(i,j))
+		    error("nc_inq_att: unexpected length");
+		assert(length <= MAX_NELS);
+		nInIntRange = nInExtRange = 0;
+		for (k = 0; k < length; k++) {
+		    expect[k] = hash4( datatype, -1, &k, NCT_LONG);
+		    if (inRange3(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)
+			error("%s", nc_strerror(err));
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < length; k++) {
+                    if (inRange3(expect[k],datatype,NCT_LONG)
+                            && expect[k] >= long_min && expect[k] <= long_max) {
+                        IF (!equal(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("element number: %d ", k);
+                                error("expect: %g, ", expect[k]);
+                                error("got: %g", (double) value[k]);
+                            }
+                        } else {
+                            nok++;
+                        }
+                    }
+                }
+            }                                               
+        }
+    }
+
+    print_nok(nok);
+}
+
+/* 
+ *  check all attributes in file which are (text/numeric) compatible with TYPE
+ *  ignore any attributes containing values outside range of TYPE
+ */
+static
+void
+check_atts_float(int  ncid)
+{
+    int  err;           /* status */
+    int  i;
+    int  j;
+    size_t  k;
+    float value[MAX_NELS];
+    nc_type datatype;
+    double expect[MAX_NELS];
+    size_t length;
+    size_t nInExtRange;  /* number values within external range */
+    size_t nInIntRange;  /* number values within internal range */
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    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) {
+		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+		IF (err)
+		    error("nc_inq_att: %s", nc_strerror(err));
+		IF (datatype != ATT_TYPE(i,j))
+		error("nc_inq_att: unexpected type");
+		IF (length != ATT_LEN(i,j))
+		    error("nc_inq_att: unexpected length");
+		assert(length <= MAX_NELS);
+		nInIntRange = nInExtRange = 0;
+		for (k = 0; k < length; k++) {
+		    expect[k] = hash4( datatype, -1, &k, NCT_FLOAT);
 		    if (inRange3(expect[k], datatype, NCT_FLOAT)) {
-#line 251
 			++nInExtRange;
-#line 251
 			if (expect[k] >= float_min && expect[k] <= float_max)
-#line 251
 			    ++nInIntRange;
-#line 251
 		    }
-#line 251
 		}
-#line 251
 		err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
-#line 251
                 if (nInExtRange == length && nInIntRange == length) {
-#line 251
 		    IF (err)
-#line 251
 			error("%s", nc_strerror(err));
-#line 251
                 } else {
-#line 251
                     IF (err != 0 && err != NC_ERANGE)
-#line 251
                         error("OK or Range error: status = %d", err);
-#line 251
                 }
-#line 251
 		for (k = 0; k < length; k++) {
-#line 251
                     if (inRange3(expect[k],datatype,NCT_FLOAT)
-#line 251
                             && expect[k] >= float_min && expect[k] <= float_max) {
-#line 251
                         IF (!equal(value[k],expect[k],datatype,NCT_FLOAT)) {
-#line 251
                             error("att. value read not that expected");
-#line 251
                             if (verbose) {
-#line 251
                                 error("\n");
-#line 251
                                 error("varid: %d, ", i);
-#line 251
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 251
                                 error("element number: %d ", k);
-#line 251
                                 error("expect: %g, ", expect[k]);
-#line 251
                                 error("got: %g", (double) value[k]);
-#line 251
                             }
-#line 251
                         } else {
-#line 251
                             nok++;
-#line 251
                         }
-#line 251
                     }
-#line 251
                 }
-#line 251
             }                                               
-#line 251
         }
-#line 251
     }
-#line 251
 
-#line 251
     print_nok(nok);
-#line 251
 }
-#line 251
 
 /* 
-#line 252
  *  check all attributes in file which are (text/numeric) compatible with TYPE
-#line 252
  *  ignore any attributes containing values outside range of TYPE
-#line 252
  */
-#line 252
 static
-#line 252
 void
-#line 252
 check_atts_double(int  ncid)
-#line 252
 {
-#line 252
     int  err;           /* status */
-#line 252
     int  i;
-#line 252
     int  j;
-#line 252
     size_t  k;
-#line 252
     double value[MAX_NELS];
-#line 252
     nc_type datatype;
-#line 252
     double expect[MAX_NELS];
-#line 252
     size_t length;
-#line 252
     size_t nInExtRange;  /* number values within external range */
-#line 252
     size_t nInIntRange;  /* number values within internal range */
-#line 252
     int canConvert;     /* Both text or both numeric */
-#line 252
     int nok = 0;      /* count of valid comparisons */
-#line 252
 
-#line 252
-    for (i = -1; i < NVARS; i++) {
-#line 252
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 252
 	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 252
 	    if (canConvert) {
-#line 252
 		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
-#line 252
 		IF (err)
-#line 252
 		    error("nc_inq_att: %s", nc_strerror(err));
-#line 252
 		IF (datatype != ATT_TYPE(i,j))
-#line 252
 		error("nc_inq_att: unexpected type");
-#line 252
 		IF (length != ATT_LEN(i,j))
-#line 252
 		    error("nc_inq_att: unexpected length");
-#line 252
 		assert(length <= MAX_NELS);
-#line 252
 		nInIntRange = nInExtRange = 0;
-#line 252
 		for (k = 0; k < length; k++) {
-#line 252
 		    expect[k] = hash4( datatype, -1, &k, NCT_DOUBLE);
-#line 252
 		    if (inRange3(expect[k], datatype, NCT_DOUBLE)) {
-#line 252
 			++nInExtRange;
-#line 252
 			if (expect[k] >= double_min && expect[k] <= double_max)
-#line 252
 			    ++nInIntRange;
-#line 252
 		    }
-#line 252
 		}
-#line 252
 		err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
-#line 252
                 if (nInExtRange == length && nInIntRange == length) {
-#line 252
 		    IF (err)
-#line 252
 			error("%s", nc_strerror(err));
-#line 252
                 } else {
-#line 252
                     IF (err != 0 && err != NC_ERANGE)
-#line 252
                         error("OK or Range error: status = %d", err);
-#line 252
                 }
-#line 252
 		for (k = 0; k < length; k++) {
-#line 252
                     if (inRange3(expect[k],datatype,NCT_DOUBLE)
-#line 252
                             && expect[k] >= double_min && expect[k] <= double_max) {
-#line 252
                         IF (!equal(value[k],expect[k],datatype,NCT_DOUBLE)) {
-#line 252
                             error("att. value read not that expected");
-#line 252
                             if (verbose) {
-#line 252
                                 error("\n");
-#line 252
                                 error("varid: %d, ", i);
-#line 252
                                 error("att_name: %s, ", ATT_NAME(i,j));
-#line 252
                                 error("element number: %d ", k);
-#line 252
                                 error("expect: %g, ", expect[k]);
-#line 252
                                 error("got: %g", (double) value[k]);
-#line 252
                             }
-#line 252
                         } else {
-#line 252
                             nok++;
-#line 252
                         }
-#line 252
                     }
-#line 252
                 }
-#line 252
             }                                               
-#line 252
         }
-#line 252
     }
-#line 252
 
-#line 252
     print_nok(nok);
-#line 252
 }
-#line 252
-
-
-
-#line 339
 
+/* 
+ *  check all attributes in file which are (text/numeric) compatible with TYPE
+ *  ignore any attributes containing values outside range of TYPE
+ */
+static
 void
-#line 340
-test_nc_put_var1_text(void)
-#line 340
+check_atts_ushort(int  ncid)
 {
-#line 340
-    int ncid;
-#line 340
-    int i;
-#line 340
-    int j;
-#line 340
-    int err;
-#line 340
-    size_t index[MAX_RANK];
-#line 340
-    int canConvert;	/* Both text or both numeric */
-#line 340
-    text value = 5;	/* any value would do - only for error cases */
-#line 340
-
-#line 340
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 340
-    IF (err) {
-#line 340
-        error("nc_create: %s", nc_strerror(err));
-#line 340
-        return;
-#line 340
-    }
-#line 340
-    def_dims(ncid);
-#line 340
-    def_vars(ncid);
-#line 340
-    err = nc_enddef(ncid);
-#line 340
-    IF (err)
-#line 340
-        error("nc_enddef: %s", nc_strerror(err));
-#line 340
+    int  err;           /* status */
+    int  i;
+    int  j;
+    size_t  k;
+    ushort value[MAX_NELS];
+    nc_type datatype;
+    double expect[MAX_NELS];
+    size_t length;
+    size_t nInExtRange;  /* number values within external range */
+    size_t nInIntRange;  /* number values within internal range */
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
 
-#line 340
-    for (i = 0; i < NVARS; i++) {
-#line 340
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 340
-        for (j = 0; j < var_rank[i]; j++)
-#line 340
-            index[j] = 0;
-#line 340
-        err = nc_put_var1_text(BAD_ID, i, index, &value);
-#line 340
-        IF (err != NC_EBADID) 
-#line 340
-	    error("bad ncid: status = %d", err);
-#line 340
-        err = nc_put_var1_text(ncid, BAD_VARID, index, &value);
-#line 340
-        IF (err != NC_ENOTVAR) 
-#line 340
-	    error("bad var id: status = %d", err);
-#line 340
-        for (j = 0; j < var_rank[i]; j++) {
-#line 340
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 340
-		index[j] = var_shape[i][j];
-#line 340
-		err = nc_put_var1_text(ncid, i, index, &value);
-#line 340
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 340
-		    error("bad index: status = %d", err);
-#line 340
-		index[j] = 0;
-#line 340
-	    }
-#line 340
-        }
-#line 340
-        for (j = 0; j < var_nels[i]; j++) {
-#line 340
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 340
-            IF (err) 
-#line 340
-		error("error in toMixedBase 1");
-#line 340
-            value = hash_text( var_type[i], var_rank[i], index, NCT_TEXT);
-#line 340
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 340
-		err = nc_put_var1_text(ncid, i, NULL, &value);
-#line 340
-	    else
-#line 340
-		err = nc_put_var1_text(ncid, i, index, &value);
-#line 340
+    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) {
-#line 340
-		if (inRange3(value, var_type[i],NCT_TEXT)) {
-#line 340
-		    IF (err)
-#line 340
-			error("%s", nc_strerror(err));
-#line 340
-		} else {
-#line 340
-		    IF (err != NC_ERANGE) {
-#line 340
-			error("Range error: status = %d", err);
-#line 340
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 340
-				s_nc_type(var_type[i]),
-#line 340
-				(double)value, (long)value);
-#line 340
+		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+		IF (err)
+		    error("nc_inq_att: %s", nc_strerror(err));
+		IF (datatype != ATT_TYPE(i,j))
+		error("nc_inq_att: unexpected type");
+		IF (length != ATT_LEN(i,j))
+		    error("nc_inq_att: unexpected length");
+		assert(length <= MAX_NELS);
+		nInIntRange = nInExtRange = 0;
+		for (k = 0; k < length; k++) {
+		    expect[k] = hash4( datatype, -1, &k, NCT_USHORT);
+		    if (inRange3(expect[k], datatype, NCT_USHORT)) {
+			++nInExtRange;
+			if (expect[k] >= ushort_min && expect[k] <= ushort_max)
+			    ++nInIntRange;
 		    }
-#line 340
 		}
-#line 340
-	    } else {
-#line 340
-		IF (err != NC_ECHAR)
-#line 340
-		    error("wrong type: status = %d", err);
-#line 340
-            }
-#line 340
-        }
-#line 340
-    }
-#line 340
-
-#line 340
-    err = nc_close(ncid);
-#line 340
-    IF (err) 
-#line 340
-	error("nc_close: %s", nc_strerror(err));
-#line 340
-
-#line 340
-    check_vars_text(scratch);
-#line 340
-
-#line 340
-    err = remove(scratch);
-#line 340
-    IF (err)
-#line 340
-        error("remove of %s failed", scratch);
-#line 340
-}
-#line 340
-
-void
-#line 341
-test_nc_put_var1_uchar(void)
-#line 341
-{
-#line 341
+		err = nc_get_att_ushort(ncid, i, ATT_NAME(i,j), value);
+                if (nInExtRange == length && nInIntRange == length) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < length; k++) {
+                    if (inRange3(expect[k],datatype,NCT_USHORT)
+                            && expect[k] >= ushort_min && expect[k] <= ushort_max) {
+                        IF (!equal(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("element number: %d ", k);
+                                error("expect: %g, ", expect[k]);
+                                error("got: %g", (double) value[k]);
+                            }
+                        } else {
+                            nok++;
+                        }
+                    }
+                }
+            }                                               
+        }
+    }
+
+    print_nok(nok);
+}
+
+/* 
+ *  check all attributes in file which are (text/numeric) compatible with TYPE
+ *  ignore any attributes containing values outside range of TYPE
+ */
+static
+void
+check_atts_uint(int  ncid)
+{
+    int  err;           /* status */
+    int  i;
+    int  j;
+    size_t  k;
+    uint value[MAX_NELS];
+    nc_type datatype;
+    double expect[MAX_NELS];
+    size_t length;
+    size_t nInExtRange;  /* number values within external range */
+    size_t nInIntRange;  /* number values within internal range */
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    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) {
+		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+		IF (err)
+		    error("nc_inq_att: %s", nc_strerror(err));
+		IF (datatype != ATT_TYPE(i,j))
+		error("nc_inq_att: unexpected type");
+		IF (length != ATT_LEN(i,j))
+		    error("nc_inq_att: unexpected length");
+		assert(length <= MAX_NELS);
+		nInIntRange = nInExtRange = 0;
+		for (k = 0; k < length; k++) {
+		    expect[k] = hash4( datatype, -1, &k, NCT_UINT);
+		    if (inRange3(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)
+			error("%s", nc_strerror(err));
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < length; k++) {
+                    if (inRange3(expect[k],datatype,NCT_UINT)
+                            && expect[k] >= uint_min && expect[k] <= uint_max) {
+                        IF (!equal(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("element number: %d ", k);
+                                error("expect: %g, ", expect[k]);
+                                error("got: %g", (double) value[k]);
+                            }
+                        } else {
+                            nok++;
+                        }
+                    }
+                }
+            }                                               
+        }
+    }
+
+    print_nok(nok);
+}
+
+/* 
+ *  check all attributes in file which are (text/numeric) compatible with TYPE
+ *  ignore any attributes containing values outside range of TYPE
+ */
+static
+void
+check_atts_longlong(int  ncid)
+{
+    int  err;           /* status */
+    int  i;
+    int  j;
+    size_t  k;
+    longlong value[MAX_NELS];
+    nc_type datatype;
+    double expect[MAX_NELS];
+    size_t length;
+    size_t nInExtRange;  /* number values within external range */
+    size_t nInIntRange;  /* number values within internal range */
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    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) {
+		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+		IF (err)
+		    error("nc_inq_att: %s", nc_strerror(err));
+		IF (datatype != ATT_TYPE(i,j))
+		error("nc_inq_att: unexpected type");
+		IF (length != ATT_LEN(i,j))
+		    error("nc_inq_att: unexpected length");
+		assert(length <= MAX_NELS);
+		nInIntRange = nInExtRange = 0;
+		for (k = 0; k < length; k++) {
+		    expect[k] = hash4( datatype, -1, &k, NCT_LONGLONG);
+		    if (inRange3(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)
+			error("%s", nc_strerror(err));
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < length; k++) {
+                    if (inRange3(expect[k],datatype,NCT_LONGLONG)
+                            && expect[k] >= longlong_min && expect[k] <= longlong_max) {
+                        IF (!equal(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("element number: %d ", k);
+                                error("expect: %g, ", expect[k]);
+                                error("got: %g", (double) value[k]);
+                            }
+                        } else {
+                            nok++;
+                        }
+                    }
+                }
+            }                                               
+        }
+    }
+
+    print_nok(nok);
+}
+
+/* 
+ *  check all attributes in file which are (text/numeric) compatible with TYPE
+ *  ignore any attributes containing values outside range of TYPE
+ */
+static
+void
+check_atts_ulonglong(int  ncid)
+{
+    int  err;           /* status */
+    int  i;
+    int  j;
+    size_t  k;
+    ulonglong value[MAX_NELS];
+    nc_type datatype;
+    double expect[MAX_NELS];
+    size_t length;
+    size_t nInExtRange;  /* number values within external range */
+    size_t nInIntRange;  /* number values within internal range */
+    int canConvert;     /* Both text or both numeric */
+    int nok = 0;      /* count of valid comparisons */
+
+    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) {
+		err = nc_inq_att(ncid, i, ATT_NAME(i,j), &datatype, &length);
+		IF (err)
+		    error("nc_inq_att: %s", nc_strerror(err));
+		IF (datatype != ATT_TYPE(i,j))
+		error("nc_inq_att: unexpected type");
+		IF (length != ATT_LEN(i,j))
+		    error("nc_inq_att: unexpected length");
+		assert(length <= MAX_NELS);
+		nInIntRange = nInExtRange = 0;
+		for (k = 0; k < length; k++) {
+		    expect[k] = hash4( datatype, -1, &k, NCT_ULONGLONG);
+		    if (inRange3(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)
+			error("%s", nc_strerror(err));
+                } else {
+                    IF (err != 0 && err != NC_ERANGE)
+                        error("OK or Range error: status = %d", err);
+                }
+		for (k = 0; k < length; k++) {
+                    if (inRange3(expect[k],datatype,NCT_ULONGLONG)
+                            && expect[k] >= ulonglong_min && expect[k] <= ulonglong_max) {
+                        IF (!equal(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("element number: %d ", k);
+                                error("expect: %g, ", expect[k]);
+                                error("got: %g", (double) value[k]);
+                            }
+                        } else {
+                            nok++;
+                        }
+                    }
+                }
+            }                                               
+        }
+    }
+
+    print_nok(nok);
+}
+
+
+
+
+void
+test_nc_put_var1_text(void)
+{
     int ncid;
-#line 341
     int i;
-#line 341
     int j;
-#line 341
     int err;
-#line 341
     size_t index[MAX_RANK];
-#line 341
     int canConvert;	/* Both text or both numeric */
-#line 341
-    uchar value = 5;	/* any value would do - only for error cases */
-#line 341
+    text value = 5;	/* any value would do - only for error cases */
 
-#line 341
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 341
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 341
         error("nc_create: %s", nc_strerror(err));
-#line 341
         return;
-#line 341
     }
-#line 341
     def_dims(ncid);
-#line 341
     def_vars(ncid);
-#line 341
     err = nc_enddef(ncid);
-#line 341
     IF (err)
-#line 341
         error("nc_enddef: %s", nc_strerror(err));
-#line 341
 
-#line 341
-    for (i = 0; i < NVARS; i++) {
-#line 341
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 341
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
         for (j = 0; j < var_rank[i]; j++)
-#line 341
             index[j] = 0;
-#line 341
-        err = nc_put_var1_uchar(BAD_ID, i, index, &value);
-#line 341
+        err = nc_put_var1_text(BAD_ID, i, index, &value);
         IF (err != NC_EBADID) 
-#line 341
 	    error("bad ncid: status = %d", err);
-#line 341
-        err = nc_put_var1_uchar(ncid, BAD_VARID, index, &value);
-#line 341
+        err = nc_put_var1_text(ncid, BAD_VARID, index, &value);
         IF (err != NC_ENOTVAR) 
-#line 341
 	    error("bad var id: status = %d", err);
-#line 341
         for (j = 0; j < var_rank[i]; j++) {
-#line 341
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 341
 		index[j] = var_shape[i][j];
-#line 341
-		err = nc_put_var1_uchar(ncid, i, index, &value);
-#line 341
+		err = nc_put_var1_text(ncid, i, index, &value);
 		IF (canConvert && err != NC_EINVALCOORDS)
-#line 341
 		    error("bad index: status = %d", err);
-#line 341
 		index[j] = 0;
-#line 341
 	    }
-#line 341
-        }
-#line 341
-        for (j = 0; j < var_nels[i]; j++) {
-#line 341
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 341
-            IF (err) 
-#line 341
-		error("error in toMixedBase 1");
-#line 341
-            value = hash_uchar( var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 341
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 341
-		err = nc_put_var1_uchar(ncid, i, NULL, &value);
-#line 341
-	    else
-#line 341
-		err = nc_put_var1_uchar(ncid, i, index, &value);
-#line 341
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_text( var_type[i], var_rank[i], index, NCT_TEXT);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_text(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_text(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_TEXT)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_text(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_uchar(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    uchar value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_uchar(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_uchar(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_uchar(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_uchar( var_type[i], var_rank[i], index, NCT_UCHAR);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_uchar(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_uchar(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_UCHAR)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_uchar(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_schar(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    schar value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_schar(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_schar(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_schar(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_schar( var_type[i], var_rank[i], index, NCT_SCHAR);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_schar(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_schar(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_SCHAR)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_schar(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_short(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    short value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_short(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_short(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_short(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_short( var_type[i], var_rank[i], index, NCT_SHORT);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_short(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_short(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_SHORT)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_short(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_int(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_int(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_int(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_int(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_int( var_type[i], var_rank[i], index, NCT_INT);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_int(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_int(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_INT)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_int(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_long(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    long value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_long(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_long(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_long(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_long( var_type[i], var_rank[i], index, NCT_LONG);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_long(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_long(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_LONG)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_long(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_float(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    float value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_float(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_float(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_float(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_float( var_type[i], var_rank[i], index, NCT_FLOAT);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_float(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_float(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_FLOAT)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_float(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_double(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    double value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_double(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_double(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_double(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_double( var_type[i], var_rank[i], index, NCT_DOUBLE);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_double(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_double(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_DOUBLE)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_double(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_ushort(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    ushort value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_ushort(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_ushort(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_ushort(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_ushort( var_type[i], var_rank[i], index, NCT_USHORT);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_ushort(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_ushort(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_USHORT)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_ushort(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_uint(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    uint value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_uint(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_uint(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_uint(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_uint( var_type[i], var_rank[i], index, NCT_UINT);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_uint(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_uint(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_UINT)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_uint(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_longlong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    longlong value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_longlong(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_longlong(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_longlong(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_longlong( var_type[i], var_rank[i], index, NCT_LONGLONG);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_longlong(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_longlong(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_LONGLONG)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_longlong(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var1_ulonglong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    int err;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    ulonglong value = 5;	/* any value would do - only for error cases */
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+        for (j = 0; j < var_rank[i]; j++)
+            index[j] = 0;
+        err = nc_put_var1_ulonglong(BAD_ID, i, index, &value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var1_ulonglong(ncid, BAD_VARID, index, &value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		index[j] = var_shape[i][j];
+		err = nc_put_var1_ulonglong(ncid, i, index, &value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad index: status = %d", err);
+		index[j] = 0;
+	    }
+        }
+        for (j = 0; j < var_nels[i]; j++) {
+            err = toMixedBase(j, var_rank[i], var_shape[i], index);
+            IF (err) 
+		error("error in toMixedBase 1");
+            value = hash_ulonglong( var_type[i], var_rank[i], index, NCT_ULONGLONG);
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_var1_ulonglong(ncid, i, NULL, &value);
+	    else
+		err = nc_put_var1_ulonglong(ncid, i, index, &value);
+	    if (canConvert) {
+		if (inRange3(value, var_type[i],NCT_ULONGLONG)) {
+		    IF (err)
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE) {
+			error("Range error: status = %d", err);
+			error("\n\t\tfor type %s value %.17e %ld",
+				s_nc_type(var_type[i]),
+				(double)value, (long)value);
+		    }
+		}
+	    } else {
+		IF (err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+            }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_ulonglong(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+
+
+
+void
+test_nc_put_var_text(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    text value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_text(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_text(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_TEXT);
+	}
+        err = nc_put_var_text(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_text(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_TEXT);
+	    }
+	    err = nc_put_var_text(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_text(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_uchar(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    uchar value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_uchar(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_uchar(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_UCHAR);
+	}
+        err = nc_put_var_uchar(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_uchar(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_UCHAR);
+	    }
+	    err = nc_put_var_uchar(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_uchar(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_schar(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    schar value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_schar(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_schar(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_SCHAR);
+	}
+        err = nc_put_var_schar(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_schar(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_SCHAR);
+	    }
+	    err = nc_put_var_schar(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_schar(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_short(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    short value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_short(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_short(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_SHORT);
+	}
+        err = nc_put_var_short(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_short(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_SHORT);
+	    }
+	    err = nc_put_var_short(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_short(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_int(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    int value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_int(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_int(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_INT);
+	}
+        err = nc_put_var_int(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_int(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_INT);
+	    }
+	    err = nc_put_var_int(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_int(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_long(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    long value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_long(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_long(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_LONG);
+	}
+        err = nc_put_var_long(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_long(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_LONG);
+	    }
+	    err = nc_put_var_long(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_long(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_float(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    float value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_float(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_float(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_FLOAT);
+	}
+        err = nc_put_var_float(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_float(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_FLOAT);
+	    }
+	    err = nc_put_var_float(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_float(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_double(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    double value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_double(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_double(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_DOUBLE);
+	}
+        err = nc_put_var_double(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_double(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_DOUBLE);
+	    }
+	    err = nc_put_var_double(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_double(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_ushort(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    ushort value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_ushort(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_ushort(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_ushort(var_type[i], var_rank[i], index, NCT_USHORT);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_USHORT);
+	}
+        err = nc_put_var_ushort(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_ushort(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_ushort(var_type[i], var_rank[i], index, NCT_USHORT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_USHORT);
+	    }
+	    err = nc_put_var_ushort(ncid, i, value);
+	    if (canConvert) {
+		if (allInExtRange) {
+		    IF (err) 
+			error("%s", nc_strerror(err));
+		} else {
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
+		}
+	    } else {
+		IF (nels > 0 && err != NC_ECHAR)
+		    error("wrong type: status = %d", err);
+	    }
+        }
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
+    check_vars_ushort(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_var_uint(void)
+{
+    int ncid;
+    int varid;
+    int i;
+    int j;
+    int err;
+    int nels;
+    size_t index[MAX_RANK];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    uint value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+        error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_uint(BAD_ID, i, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_var_uint(ncid, BAD_VARID, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_uint(var_type[i], var_rank[i], index, NCT_UINT);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_UINT);
+	}
+        err = nc_put_var_uint(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_uint(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
+	    }
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_uint(var_type[i], var_rank[i], index, NCT_UINT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_UINT);
+	    }
+	    err = nc_put_var_uint(ncid, i, value);
 	    if (canConvert) {
-#line 341
-		if (inRange3(value, var_type[i],NCT_UCHAR)) {
-#line 341
-		    IF (err)
-#line 341
+		if (allInExtRange) {
+		    IF (err) 
 			error("%s", nc_strerror(err));
-#line 341
 		} else {
-#line 341
-		    IF (err != NC_ERANGE) {
-#line 341
-			error("Range error: status = %d", err);
-#line 341
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 341
-				s_nc_type(var_type[i]),
-#line 341
-				(double)value, (long)value);
-#line 341
-		    }
-#line 341
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
 		}
-#line 341
 	    } else {
-#line 341
-		IF (err != NC_ECHAR)
-#line 341
+		IF (nels > 0 && err != NC_ECHAR)
 		    error("wrong type: status = %d", err);
-#line 341
-            }
-#line 341
+	    }
         }
-#line 341
     }
-#line 341
 
-#line 341
     err = nc_close(ncid);
-#line 341
     IF (err) 
-#line 341
 	error("nc_close: %s", nc_strerror(err));
-#line 341
 
-#line 341
-    check_vars_uchar(scratch);
-#line 341
+    check_vars_uint(scratch);
 
-#line 341
     err = remove(scratch);
-#line 341
     IF (err)
-#line 341
         error("remove of %s failed", scratch);
-#line 341
 }
-#line 341
 
 void
-#line 342
-test_nc_put_var1_schar(void)
-#line 342
+test_nc_put_var_longlong(void)
 {
-#line 342
     int ncid;
-#line 342
+    int varid;
     int i;
-#line 342
     int j;
-#line 342
     int err;
-#line 342
+    int nels;
     size_t index[MAX_RANK];
-#line 342
     int canConvert;	/* Both text or both numeric */
-#line 342
-    schar value = 5;	/* any value would do - only for error cases */
-#line 342
+    int allInExtRange;	/* all values within external range? */
+    longlong value[MAX_NELS];
 
-#line 342
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 342
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 342
         error("nc_create: %s", nc_strerror(err));
-#line 342
         return;
-#line 342
     }
-#line 342
     def_dims(ncid);
-#line 342
     def_vars(ncid);
-#line 342
     err = nc_enddef(ncid);
-#line 342
     IF (err)
-#line 342
         error("nc_enddef: %s", nc_strerror(err));
-#line 342
 
-#line 342
-    for (i = 0; i < NVARS; i++) {
-#line 342
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 342
-        for (j = 0; j < var_rank[i]; j++)
-#line 342
-            index[j] = 0;
-#line 342
-        err = nc_put_var1_schar(BAD_ID, i, index, &value);
-#line 342
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_longlong(BAD_ID, i, value);
         IF (err != NC_EBADID) 
-#line 342
 	    error("bad ncid: status = %d", err);
-#line 342
-        err = nc_put_var1_schar(ncid, BAD_VARID, index, &value);
-#line 342
+        err = nc_put_var_longlong(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR) 
-#line 342
 	    error("bad var id: status = %d", err);
-#line 342
-        for (j = 0; j < var_rank[i]; j++) {
-#line 342
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 342
-		index[j] = var_shape[i][j];
-#line 342
-		err = nc_put_var1_schar(ncid, i, index, &value);
-#line 342
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 342
-		    error("bad index: status = %d", err);
-#line 342
-		index[j] = 0;
-#line 342
-	    }
-#line 342
-        }
-#line 342
-        for (j = 0; j < var_nels[i]; j++) {
-#line 342
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 342
-            IF (err) 
-#line 342
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
 		error("error in toMixedBase 1");
-#line 342
-            value = hash_schar( var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 342
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 342
-		err = nc_put_var1_schar(ncid, i, NULL, &value);
-#line 342
-	    else
-#line 342
-		err = nc_put_var1_schar(ncid, i, index, &value);
-#line 342
-	    if (canConvert) {
-#line 342
-		if (inRange3(value, var_type[i],NCT_SCHAR)) {
-#line 342
-		    IF (err)
-#line 342
-			error("%s", nc_strerror(err));
-#line 342
-		} else {
-#line 342
-		    IF (err != NC_ERANGE) {
-#line 342
-			error("Range error: status = %d", err);
-#line 342
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 342
-				s_nc_type(var_type[i]),
-#line 342
-				(double)value, (long)value);
-#line 342
-		    }
-#line 342
-		}
-#line 342
+	    value[j]= hash_longlong(var_type[i], var_rank[i], index, NCT_LONGLONG);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_LONGLONG);
+	}
+        err = nc_put_var_longlong(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
 	    } else {
-#line 342
-		IF (err != NC_ECHAR)
-#line 342
-		    error("wrong type: status = %d", err);
-#line 342
-            }
-#line 342
-        }
-#line 342
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
     }
-#line 342
-
-#line 342
-    err = nc_close(ncid);
-#line 342
-    IF (err) 
-#line 342
-	error("nc_close: %s", nc_strerror(err));
-#line 342
 
-#line 342
-    check_vars_schar(scratch);
-#line 342
+        /* Preceding has written nothing for record variables, now try */
+        /* again with more than 0 records */
 
-#line 342
-    err = remove(scratch);
-#line 342
+	/* 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)
-#line 342
-        error("remove of %s failed", scratch);
-#line 342
-}
-#line 342
-
-void
-#line 343
-test_nc_put_var1_short(void)
-#line 343
-{
-#line 343
-    int ncid;
-#line 343
-    int i;
-#line 343
-    int j;
-#line 343
-    int err;
-#line 343
-    size_t index[MAX_RANK];
-#line 343
-    int canConvert;	/* Both text or both numeric */
-#line 343
-    short value = 5;	/* any value would do - only for error cases */
-#line 343
-
-#line 343
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 343
-    IF (err) {
-#line 343
-        error("nc_create: %s", nc_strerror(err));
-#line 343
-        return;
-#line 343
-    }
-#line 343
-    def_dims(ncid);
-#line 343
-    def_vars(ncid);
-#line 343
-    err = nc_enddef(ncid);
-#line 343
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
     IF (err)
-#line 343
-        error("nc_enddef: %s", nc_strerror(err));
-#line 343
+        error("nc_put_var1_text: %s", nc_strerror(err));
 
-#line 343
-    for (i = 0; i < NVARS; i++) {
-#line 343
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 343
-        for (j = 0; j < var_rank[i]; j++)
-#line 343
-            index[j] = 0;
-#line 343
-        err = nc_put_var1_short(BAD_ID, i, index, &value);
-#line 343
-        IF (err != NC_EBADID) 
-#line 343
-	    error("bad ncid: status = %d", err);
-#line 343
-        err = nc_put_var1_short(ncid, BAD_VARID, index, &value);
-#line 343
-        IF (err != NC_ENOTVAR) 
-#line 343
-	    error("bad var id: status = %d", err);
-#line 343
-        for (j = 0; j < var_rank[i]; j++) {
-#line 343
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 343
-		index[j] = var_shape[i][j];
-#line 343
-		err = nc_put_var1_short(ncid, i, index, &value);
-#line 343
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 343
-		    error("bad index: status = %d", err);
-#line 343
-		index[j] = 0;
-#line 343
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_longlong(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
 	    }
-#line 343
-        }
-#line 343
-        for (j = 0; j < var_nels[i]; j++) {
-#line 343
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 343
-            IF (err) 
-#line 343
-		error("error in toMixedBase 1");
-#line 343
-            value = hash_short( var_type[i], var_rank[i], index, NCT_SHORT);
-#line 343
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 343
-		err = nc_put_var1_short(ncid, i, NULL, &value);
-#line 343
-	    else
-#line 343
-		err = nc_put_var1_short(ncid, i, index, &value);
-#line 343
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_longlong(var_type[i], var_rank[i], index, NCT_LONGLONG);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_LONGLONG);
+	    }
+	    err = nc_put_var_longlong(ncid, i, value);
 	    if (canConvert) {
-#line 343
-		if (inRange3(value, var_type[i],NCT_SHORT)) {
-#line 343
-		    IF (err)
-#line 343
+		if (allInExtRange) {
+		    IF (err) 
 			error("%s", nc_strerror(err));
-#line 343
 		} else {
-#line 343
-		    IF (err != NC_ERANGE) {
-#line 343
-			error("Range error: status = %d", err);
-#line 343
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 343
-				s_nc_type(var_type[i]),
-#line 343
-				(double)value, (long)value);
-#line 343
-		    }
-#line 343
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
 		}
-#line 343
 	    } else {
-#line 343
-		IF (err != NC_ECHAR)
-#line 343
+		IF (nels > 0 && err != NC_ECHAR)
 		    error("wrong type: status = %d", err);
-#line 343
-            }
-#line 343
+	    }
         }
-#line 343
     }
-#line 343
 
-#line 343
     err = nc_close(ncid);
-#line 343
     IF (err) 
-#line 343
 	error("nc_close: %s", nc_strerror(err));
-#line 343
 
-#line 343
-    check_vars_short(scratch);
-#line 343
+    check_vars_longlong(scratch);
 
-#line 343
     err = remove(scratch);
-#line 343
     IF (err)
-#line 343
         error("remove of %s failed", scratch);
-#line 343
 }
-#line 343
 
 void
-#line 344
-test_nc_put_var1_int(void)
-#line 344
+test_nc_put_var_ulonglong(void)
 {
-#line 344
     int ncid;
-#line 344
+    int varid;
     int i;
-#line 344
     int j;
-#line 344
     int err;
-#line 344
+    int nels;
     size_t index[MAX_RANK];
-#line 344
     int canConvert;	/* Both text or both numeric */
-#line 344
-    int value = 5;	/* any value would do - only for error cases */
-#line 344
+    int allInExtRange;	/* all values within external range? */
+    ulonglong value[MAX_NELS];
 
-#line 344
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 344
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 344
         error("nc_create: %s", nc_strerror(err));
-#line 344
         return;
-#line 344
     }
-#line 344
     def_dims(ncid);
-#line 344
     def_vars(ncid);
-#line 344
     err = nc_enddef(ncid);
-#line 344
     IF (err)
-#line 344
         error("nc_enddef: %s", nc_strerror(err));
-#line 344
 
-#line 344
-    for (i = 0; i < NVARS; i++) {
-#line 344
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 344
-        for (j = 0; j < var_rank[i]; j++)
-#line 344
-            index[j] = 0;
-#line 344
-        err = nc_put_var1_int(BAD_ID, i, index, &value);
-#line 344
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        err = nc_put_var_ulonglong(BAD_ID, i, value);
         IF (err != NC_EBADID) 
-#line 344
 	    error("bad ncid: status = %d", err);
-#line 344
-        err = nc_put_var1_int(ncid, BAD_VARID, index, &value);
-#line 344
+        err = nc_put_var_ulonglong(ncid, BAD_VARID, value);
         IF (err != NC_ENOTVAR) 
-#line 344
 	    error("bad var id: status = %d", err);
-#line 344
-        for (j = 0; j < var_rank[i]; j++) {
-#line 344
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 344
-		index[j] = var_shape[i][j];
-#line 344
-		err = nc_put_var1_int(ncid, i, index, &value);
-#line 344
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 344
-		    error("bad index: status = %d", err);
-#line 344
-		index[j] = 0;
-#line 344
+
+	nels = 1;
+	for (j = 0; j < var_rank[i]; j++) {
+	    nels *= var_shape[i][j];
+	}
+	for (allInExtRange = 1, j = 0; j < nels; j++) {
+	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
+	    IF (err) 
+		error("error in toMixedBase 1");
+	    value[j]= hash_ulonglong(var_type[i], var_rank[i], index, NCT_ULONGLONG);
+	    allInExtRange = allInExtRange 
+		&& inRange3(value[j], var_type[i], NCT_ULONGLONG);
+	}
+        err = nc_put_var_ulonglong(ncid, i, value);
+	if (canConvert) {
+	    if (allInExtRange) {
+		IF (err) 
+		    error("%s", nc_strerror(err));
+	    } else {
+		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
+		    error("range error: status = %d", err);
+	    }
+	} else {       /* should flag wrong type even if nothing to write */
+	    IF (nels > 0 && err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+	}
+    }
+
+        /* 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)
+        error("nc_inq_varid: %s", nc_strerror(err));
+    index[0] = NRECS-1;
+    err = nc_put_var1_text(ncid, varid, index, "x");
+    IF (err)
+        error("nc_put_var1_text: %s", nc_strerror(err));
+
+    for (i = 0; i < numVars; i++) {
+        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
+	    canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
+	    assert(var_rank[i] <= MAX_RANK);
+	    assert(var_nels[i] <= MAX_NELS);
+	    err = nc_put_var_ulonglong(BAD_ID, i, value);
+	    IF (err != NC_EBADID) 
+	        error("bad ncid: status = %d", err);
+	    nels = 1;
+	    for (j = 0; j < var_rank[i]; j++) {
+		nels *= var_shape[i][j];
 	    }
-#line 344
-        }
-#line 344
-        for (j = 0; j < var_nels[i]; j++) {
-#line 344
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 344
-            IF (err) 
-#line 344
-		error("error in toMixedBase 1");
-#line 344
-            value = hash_int( var_type[i], var_rank[i], index, NCT_INT);
-#line 344
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 344
-		err = nc_put_var1_int(ncid, i, NULL, &value);
-#line 344
-	    else
-#line 344
-		err = nc_put_var1_int(ncid, i, index, &value);
-#line 344
+	    for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], var_shape[i], index);
+		IF (err) 
+		    error("error in toMixedBase 1");
+		value[j]= hash_ulonglong(var_type[i], var_rank[i], index, NCT_ULONGLONG);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_ULONGLONG);
+	    }
+	    err = nc_put_var_ulonglong(ncid, i, value);
 	    if (canConvert) {
-#line 344
-		if (inRange3(value, var_type[i],NCT_INT)) {
-#line 344
-		    IF (err)
-#line 344
+		if (allInExtRange) {
+		    IF (err) 
 			error("%s", nc_strerror(err));
-#line 344
 		} else {
-#line 344
-		    IF (err != NC_ERANGE) {
-#line 344
-			error("Range error: status = %d", err);
-#line 344
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 344
-				s_nc_type(var_type[i]),
-#line 344
-				(double)value, (long)value);
-#line 344
-		    }
-#line 344
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
 		}
-#line 344
 	    } else {
-#line 344
-		IF (err != NC_ECHAR)
-#line 344
+		IF (nels > 0 && err != NC_ECHAR)
 		    error("wrong type: status = %d", err);
-#line 344
-            }
-#line 344
+	    }
         }
-#line 344
     }
-#line 344
 
-#line 344
     err = nc_close(ncid);
-#line 344
     IF (err) 
-#line 344
 	error("nc_close: %s", nc_strerror(err));
-#line 344
 
-#line 344
-    check_vars_int(scratch);
-#line 344
+    check_vars_ulonglong(scratch);
 
-#line 344
     err = remove(scratch);
-#line 344
     IF (err)
-#line 344
         error("remove of %s failed", scratch);
-#line 344
 }
-#line 344
+
+
+
 
 void
-#line 345
-test_nc_put_var1_long(void)
-#line 345
+test_nc_put_vara_text(void)
 {
-#line 345
     int ncid;
-#line 345
+    int d;
     int i;
-#line 345
     int j;
-#line 345
+    int k;
     int err;
-#line 345
+    int nslabs;
+    int nels;
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 345
     int canConvert;	/* Both text or both numeric */
-#line 345
-    long value = 5;	/* any value would do - only for error cases */
-#line 345
+    int allInExtRange;	/* all values within external range? */
+    text value[MAX_NELS];
 
-#line 345
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 345
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 345
         error("nc_create: %s", nc_strerror(err));
-#line 345
         return;
-#line 345
     }
-#line 345
     def_dims(ncid);
-#line 345
     def_vars(ncid);
-#line 345
     err = nc_enddef(ncid);
-#line 345
     IF (err)
-#line 345
         error("nc_enddef: %s", nc_strerror(err));
-#line 345
 
-#line 345
-    for (i = 0; i < NVARS; i++) {
-#line 345
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 345
-        for (j = 0; j < var_rank[i]; j++)
-#line 345
-            index[j] = 0;
-#line 345
-        err = nc_put_var1_long(BAD_ID, i, index, &value);
-#line 345
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_text(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 345
 	    error("bad ncid: status = %d", err);
-#line 345
-        err = nc_put_var1_long(ncid, BAD_VARID, index, &value);
-#line 345
+        err = nc_put_vara_text(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 345
 	    error("bad var id: status = %d", err);
-#line 345
         for (j = 0; j < var_rank[i]; j++) {
-#line 345
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 345
-		index[j] = var_shape[i][j];
-#line 345
-		err = nc_put_var1_long(ncid, i, index, &value);
-#line 345
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_text(ncid, i, start, edge, value);
 		IF (canConvert && err != NC_EINVALCOORDS)
-#line 345
-		    error("bad index: status = %d", err);
-#line 345
-		index[j] = 0;
-#line 345
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_text(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 345
         }
-#line 345
-        for (j = 0; j < var_nels[i]; j++) {
-#line 345
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 345
-            IF (err) 
-#line 345
-		error("error in toMixedBase 1");
-#line 345
-            value = hash_long( var_type[i], var_rank[i], index, NCT_LONG);
-#line 345
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
+	}
+        err = nc_put_vara_text(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_text(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_text(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
+
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
+
+	err = nc_put_vara_text(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        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) 
+		    error("error in toMixedBase 1");
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_TEXT);
+	    }
 	    if (var_rank[i] == 0 && i%2 == 0)
-#line 345
-		err = nc_put_var1_long(ncid, i, NULL, &value);
-#line 345
+		err = nc_put_vara_text(ncid, i, NULL, NULL, value);
 	    else
-#line 345
-		err = nc_put_var1_long(ncid, i, index, &value);
-#line 345
+		err = nc_put_vara_text(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 345
-		if (inRange3(value, var_type[i],NCT_LONG)) {
-#line 345
-		    IF (err)
-#line 345
+		if (allInExtRange) {
+		    IF (err) 
 			error("%s", nc_strerror(err));
-#line 345
 		} else {
-#line 345
-		    IF (err != NC_ERANGE) {
-#line 345
-			error("Range error: status = %d", err);
-#line 345
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 345
-				s_nc_type(var_type[i]),
-#line 345
-				(double)value, (long)value);
-#line 345
-		    }
-#line 345
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
 		}
-#line 345
 	    } else {
-#line 345
-		IF (err != NC_ECHAR)
-#line 345
+		IF (nels > 0 && err != NC_ECHAR)
 		    error("wrong type: status = %d", err);
-#line 345
             }
-#line 345
         }
-#line 345
     }
-#line 345
 
-#line 345
     err = nc_close(ncid);
-#line 345
     IF (err) 
-#line 345
 	error("nc_close: %s", nc_strerror(err));
-#line 345
 
-#line 345
-    check_vars_long(scratch);
-#line 345
+    check_vars_text(scratch);
 
-#line 345
     err = remove(scratch);
-#line 345
     IF (err)
-#line 345
         error("remove of %s failed", scratch);
-#line 345
 }
-#line 345
 
 void
-#line 346
-test_nc_put_var1_float(void)
-#line 346
+test_nc_put_vara_uchar(void)
 {
-#line 346
     int ncid;
-#line 346
+    int d;
     int i;
-#line 346
     int j;
-#line 346
+    int k;
     int err;
-#line 346
+    int nslabs;
+    int nels;
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 346
     int canConvert;	/* Both text or both numeric */
-#line 346
-    float value = 5;	/* any value would do - only for error cases */
-#line 346
+    int allInExtRange;	/* all values within external range? */
+    uchar value[MAX_NELS];
 
-#line 346
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 346
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 346
         error("nc_create: %s", nc_strerror(err));
-#line 346
         return;
-#line 346
     }
-#line 346
     def_dims(ncid);
-#line 346
     def_vars(ncid);
-#line 346
     err = nc_enddef(ncid);
-#line 346
     IF (err)
-#line 346
         error("nc_enddef: %s", nc_strerror(err));
-#line 346
 
-#line 346
-    for (i = 0; i < NVARS; i++) {
-#line 346
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 346
-        for (j = 0; j < var_rank[i]; j++)
-#line 346
-            index[j] = 0;
-#line 346
-        err = nc_put_var1_float(BAD_ID, i, index, &value);
-#line 346
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_uchar(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 346
 	    error("bad ncid: status = %d", err);
-#line 346
-        err = nc_put_var1_float(ncid, BAD_VARID, index, &value);
-#line 346
+        err = nc_put_vara_uchar(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 346
 	    error("bad var id: status = %d", err);
-#line 346
         for (j = 0; j < var_rank[i]; j++) {
-#line 346
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 346
-		index[j] = var_shape[i][j];
-#line 346
-		err = nc_put_var1_float(ncid, i, index, &value);
-#line 346
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_uchar(ncid, i, start, edge, value);
 		IF (canConvert && err != NC_EINVALCOORDS)
-#line 346
-		    error("bad index: status = %d", err);
-#line 346
-		index[j] = 0;
-#line 346
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_uchar(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
+	    }
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
+	}
+        err = nc_put_vara_uchar(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_uchar(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_uchar(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
+
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
+
+	err = nc_put_vara_uchar(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        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) 
+		    error("error in toMixedBase 1");
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_UCHAR);
 	    }
-#line 346
-        }
-#line 346
-        for (j = 0; j < var_nels[i]; j++) {
-#line 346
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 346
-            IF (err) 
-#line 346
-		error("error in toMixedBase 1");
-#line 346
-            value = hash_float( var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 346
 	    if (var_rank[i] == 0 && i%2 == 0)
-#line 346
-		err = nc_put_var1_float(ncid, i, NULL, &value);
-#line 346
+		err = nc_put_vara_uchar(ncid, i, NULL, NULL, value);
 	    else
-#line 346
-		err = nc_put_var1_float(ncid, i, index, &value);
-#line 346
+		err = nc_put_vara_uchar(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 346
-		if (inRange3(value, var_type[i],NCT_FLOAT)) {
-#line 346
-		    IF (err)
-#line 346
+		if (allInExtRange) {
+		    IF (err) 
 			error("%s", nc_strerror(err));
-#line 346
 		} else {
-#line 346
-		    IF (err != NC_ERANGE) {
-#line 346
-			error("Range error: status = %d", err);
-#line 346
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 346
-				s_nc_type(var_type[i]),
-#line 346
-				(double)value, (long)value);
-#line 346
-		    }
-#line 346
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
 		}
-#line 346
 	    } else {
-#line 346
-		IF (err != NC_ECHAR)
-#line 346
+		IF (nels > 0 && err != NC_ECHAR)
 		    error("wrong type: status = %d", err);
-#line 346
             }
-#line 346
         }
-#line 346
     }
-#line 346
 
-#line 346
     err = nc_close(ncid);
-#line 346
     IF (err) 
-#line 346
 	error("nc_close: %s", nc_strerror(err));
-#line 346
 
-#line 346
-    check_vars_float(scratch);
-#line 346
+    check_vars_uchar(scratch);
 
-#line 346
     err = remove(scratch);
-#line 346
     IF (err)
-#line 346
         error("remove of %s failed", scratch);
-#line 346
 }
-#line 346
 
 void
-#line 347
-test_nc_put_var1_double(void)
-#line 347
+test_nc_put_vara_schar(void)
 {
-#line 347
     int ncid;
-#line 347
+    int d;
     int i;
-#line 347
     int j;
-#line 347
+    int k;
     int err;
-#line 347
+    int nslabs;
+    int nels;
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 347
     int canConvert;	/* Both text or both numeric */
-#line 347
-    double value = 5;	/* any value would do - only for error cases */
-#line 347
+    int allInExtRange;	/* all values within external range? */
+    schar value[MAX_NELS];
 
-#line 347
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 347
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 347
         error("nc_create: %s", nc_strerror(err));
-#line 347
         return;
-#line 347
     }
-#line 347
     def_dims(ncid);
-#line 347
     def_vars(ncid);
-#line 347
     err = nc_enddef(ncid);
-#line 347
     IF (err)
-#line 347
         error("nc_enddef: %s", nc_strerror(err));
-#line 347
 
-#line 347
-    for (i = 0; i < NVARS; i++) {
-#line 347
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 347
-        for (j = 0; j < var_rank[i]; j++)
-#line 347
-            index[j] = 0;
-#line 347
-        err = nc_put_var1_double(BAD_ID, i, index, &value);
-#line 347
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+        assert(var_rank[i] <= MAX_RANK);
+        assert(var_nels[i] <= MAX_NELS);
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_schar(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 347
 	    error("bad ncid: status = %d", err);
-#line 347
-        err = nc_put_var1_double(ncid, BAD_VARID, index, &value);
-#line 347
+        err = nc_put_vara_schar(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 347
 	    error("bad var id: status = %d", err);
-#line 347
         for (j = 0; j < var_rank[i]; j++) {
-#line 347
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 347
-		index[j] = var_shape[i][j];
-#line 347
-		err = nc_put_var1_double(ncid, i, index, &value);
-#line 347
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_schar(ncid, i, start, edge, value);
 		IF (canConvert && err != NC_EINVALCOORDS)
-#line 347
-		    error("bad index: status = %d", err);
-#line 347
-		index[j] = 0;
-#line 347
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_schar(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 347
         }
-#line 347
-        for (j = 0; j < var_nels[i]; j++) {
-#line 347
-            err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 347
-            IF (err) 
-#line 347
-		error("error in toMixedBase 1");
-#line 347
-            value = hash_double( var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 347
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
+	}
+        err = nc_put_vara_schar(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_schar(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_schar(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
+
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
+
+	err = nc_put_vara_schar(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        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) 
+		    error("error in toMixedBase 1");
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR);
+		allInExtRange = allInExtRange 
+		    && inRange3(value[j], var_type[i], NCT_SCHAR);
+	    }
 	    if (var_rank[i] == 0 && i%2 == 0)
-#line 347
-		err = nc_put_var1_double(ncid, i, NULL, &value);
-#line 347
+		err = nc_put_vara_schar(ncid, i, NULL, NULL, value);
 	    else
-#line 347
-		err = nc_put_var1_double(ncid, i, index, &value);
-#line 347
+		err = nc_put_vara_schar(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 347
-		if (inRange3(value, var_type[i],NCT_DOUBLE)) {
-#line 347
-		    IF (err)
-#line 347
+		if (allInExtRange) {
+		    IF (err) 
 			error("%s", nc_strerror(err));
-#line 347
 		} else {
-#line 347
-		    IF (err != NC_ERANGE) {
-#line 347
-			error("Range error: status = %d", err);
-#line 347
-			error("\n\t\tfor type %s value %.17e %ld",
-#line 347
-				s_nc_type(var_type[i]),
-#line 347
-				(double)value, (long)value);
-#line 347
-		    }
-#line 347
+		    IF (err != NC_ERANGE)
+			error("range error: status = %d", err);
 		}
-#line 347
 	    } else {
-#line 347
-		IF (err != NC_ECHAR)
-#line 347
+		IF (nels > 0 && err != NC_ECHAR)
 		    error("wrong type: status = %d", err);
-#line 347
             }
-#line 347
         }
-#line 347
     }
-#line 347
 
-#line 347
     err = nc_close(ncid);
-#line 347
     IF (err) 
-#line 347
 	error("nc_close: %s", nc_strerror(err));
-#line 347
 
-#line 347
-    check_vars_double(scratch);
-#line 347
+    check_vars_schar(scratch);
 
-#line 347
     err = remove(scratch);
-#line 347
     IF (err)
-#line 347
         error("remove of %s failed", scratch);
-#line 347
 }
-#line 347
-
-
-
-#line 477
 
 void
-#line 478
-test_nc_put_var_text(void)
-#line 478
+test_nc_put_vara_short(void)
 {
-#line 478
     int ncid;
-#line 478
-    int varid;
-#line 478
+    int d;
     int i;
-#line 478
     int j;
-#line 478
+    int k;
     int err;
-#line 478
+    int nslabs;
     int nels;
-#line 478
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 478
     int canConvert;	/* Both text or both numeric */
-#line 478
     int allInExtRange;	/* all values within external range? */
-#line 478
-    text value[MAX_NELS];
-#line 478
+    short value[MAX_NELS];
 
-#line 478
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 478
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 478
         error("nc_create: %s", nc_strerror(err));
-#line 478
         return;
-#line 478
     }
-#line 478
     def_dims(ncid);
-#line 478
     def_vars(ncid);
-#line 478
     err = nc_enddef(ncid);
-#line 478
     IF (err)
-#line 478
         error("nc_enddef: %s", nc_strerror(err));
-#line 478
 
-#line 478
-    for (i = 0; i < NVARS; i++) {
-#line 478
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 478
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 478
         assert(var_nels[i] <= MAX_NELS);
-#line 478
-        err = nc_put_var_text(BAD_ID, i, value);
-#line 478
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_short(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 478
 	    error("bad ncid: status = %d", err);
-#line 478
-        err = nc_put_var_text(ncid, BAD_VARID, value);
-#line 478
+        err = nc_put_vara_short(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 478
 	    error("bad var id: status = %d", err);
-#line 478
-
-#line 478
-	nels = 1;
-#line 478
-	for (j = 0; j < var_rank[i]; j++) {
-#line 478
-	    nels *= var_shape[i][j];
-#line 478
-	}
-#line 478
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 478
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 478
-	    IF (err) 
-#line 478
-		error("error in toMixedBase 1");
-#line 478
-	    value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT);
-#line 478
-	    allInExtRange = allInExtRange 
-#line 478
-		&& inRange3(value[j], var_type[i], NCT_TEXT);
-#line 478
-	}
-#line 478
-        err = nc_put_var_text(ncid, i, value);
-#line 478
-	if (canConvert) {
-#line 478
-	    if (allInExtRange) {
-#line 478
-		IF (err) 
-#line 478
-		    error("%s", nc_strerror(err));
-#line 478
-	    } else {
-#line 478
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 478
-		    error("range error: status = %d", err);
-#line 478
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_short(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_short(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 478
-	} else {       /* should flag wrong type even if nothing to write */
-#line 478
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 478
-		error("wrong type: status = %d", err);
-#line 478
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 478
-    }
-#line 478
+        err = nc_put_vara_short(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_short(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_short(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
 
-#line 478
-        /* Preceeding has written nothing for record variables, now try */
-#line 478
-        /* again with more than 0 records */
-#line 478
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 478
-	/* Write record number NRECS to force writing of preceding records */
-#line 478
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 478
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 478
-    IF (err)
-#line 478
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 478
-    index[0] = NRECS-1;
-#line 478
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 478
-    IF (err)
-#line 478
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 478
+	err = nc_put_vara_short(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 478
-    for (i = 0; i < NVARS; i++) {
-#line 478
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 478
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 478
-	    assert(var_rank[i] <= MAX_RANK);
-#line 478
-	    assert(var_nels[i] <= MAX_NELS);
-#line 478
-	    err = nc_put_var_text(BAD_ID, i, value);
-#line 478
-	    IF (err != NC_EBADID) 
-#line 478
-	        error("bad ncid: status = %d", err);
-#line 478
+	    /* 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;
-#line 478
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 478
-		nels *= var_shape[i][j];
-#line 478
+		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];
 	    }
-#line 478
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 478
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 478
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 478
 		    error("error in toMixedBase 1");
-#line 478
-		value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT);
-#line 478
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT);
 		allInExtRange = allInExtRange 
-#line 478
-		    && inRange3(value[j], var_type[i], NCT_TEXT);
-#line 478
+		    && inRange3(value[j], var_type[i], NCT_SHORT);
 	    }
-#line 478
-	    err = nc_put_var_text(ncid, i, value);
-#line 478
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_short(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_short(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 478
 		if (allInExtRange) {
-#line 478
 		    IF (err) 
-#line 478
 			error("%s", nc_strerror(err));
-#line 478
 		} else {
-#line 478
 		    IF (err != NC_ERANGE)
-#line 478
 			error("range error: status = %d", err);
-#line 478
 		}
-#line 478
 	    } else {
-#line 478
 		IF (nels > 0 && err != NC_ECHAR)
-#line 478
 		    error("wrong type: status = %d", err);
-#line 478
-	    }
-#line 478
+            }
         }
-#line 478
     }
-#line 478
 
-#line 478
     err = nc_close(ncid);
-#line 478
     IF (err) 
-#line 478
 	error("nc_close: %s", nc_strerror(err));
-#line 478
 
-#line 478
-    check_vars_text(scratch);
-#line 478
+    check_vars_short(scratch);
 
-#line 478
     err = remove(scratch);
-#line 478
     IF (err)
-#line 478
         error("remove of %s failed", scratch);
-#line 478
 }
-#line 478
 
 void
-#line 479
-test_nc_put_var_uchar(void)
-#line 479
+test_nc_put_vara_int(void)
 {
-#line 479
     int ncid;
-#line 479
-    int varid;
-#line 479
+    int d;
     int i;
-#line 479
     int j;
-#line 479
+    int k;
     int err;
-#line 479
+    int nslabs;
     int nels;
-#line 479
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 479
     int canConvert;	/* Both text or both numeric */
-#line 479
     int allInExtRange;	/* all values within external range? */
-#line 479
-    uchar value[MAX_NELS];
-#line 479
+    int value[MAX_NELS];
 
-#line 479
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 479
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 479
         error("nc_create: %s", nc_strerror(err));
-#line 479
         return;
-#line 479
     }
-#line 479
     def_dims(ncid);
-#line 479
     def_vars(ncid);
-#line 479
     err = nc_enddef(ncid);
-#line 479
     IF (err)
-#line 479
         error("nc_enddef: %s", nc_strerror(err));
-#line 479
 
-#line 479
-    for (i = 0; i < NVARS; i++) {
-#line 479
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 479
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 479
         assert(var_nels[i] <= MAX_NELS);
-#line 479
-        err = nc_put_var_uchar(BAD_ID, i, value);
-#line 479
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_int(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 479
 	    error("bad ncid: status = %d", err);
-#line 479
-        err = nc_put_var_uchar(ncid, BAD_VARID, value);
-#line 479
+        err = nc_put_vara_int(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 479
 	    error("bad var id: status = %d", err);
-#line 479
-
-#line 479
-	nels = 1;
-#line 479
-	for (j = 0; j < var_rank[i]; j++) {
-#line 479
-	    nels *= var_shape[i][j];
-#line 479
-	}
-#line 479
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 479
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 479
-	    IF (err) 
-#line 479
-		error("error in toMixedBase 1");
-#line 479
-	    value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 479
-	    allInExtRange = allInExtRange 
-#line 479
-		&& inRange3(value[j], var_type[i], NCT_UCHAR);
-#line 479
-	}
-#line 479
-        err = nc_put_var_uchar(ncid, i, value);
-#line 479
-	if (canConvert) {
-#line 479
-	    if (allInExtRange) {
-#line 479
-		IF (err) 
-#line 479
-		    error("%s", nc_strerror(err));
-#line 479
-	    } else {
-#line 479
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 479
-		    error("range error: status = %d", err);
-#line 479
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_int(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_int(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 479
-	} else {       /* should flag wrong type even if nothing to write */
-#line 479
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 479
-		error("wrong type: status = %d", err);
-#line 479
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 479
-    }
-#line 479
+        err = nc_put_vara_int(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_int(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_int(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
 
-#line 479
-        /* Preceeding has written nothing for record variables, now try */
-#line 479
-        /* again with more than 0 records */
-#line 479
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 479
-	/* Write record number NRECS to force writing of preceding records */
-#line 479
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 479
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 479
-    IF (err)
-#line 479
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 479
-    index[0] = NRECS-1;
-#line 479
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 479
-    IF (err)
-#line 479
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 479
+	err = nc_put_vara_int(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 479
-    for (i = 0; i < NVARS; i++) {
-#line 479
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 479
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 479
-	    assert(var_rank[i] <= MAX_RANK);
-#line 479
-	    assert(var_nels[i] <= MAX_NELS);
-#line 479
-	    err = nc_put_var_uchar(BAD_ID, i, value);
-#line 479
-	    IF (err != NC_EBADID) 
-#line 479
-	        error("bad ncid: status = %d", err);
-#line 479
+	    /* 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;
-#line 479
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 479
-		nels *= var_shape[i][j];
-#line 479
+		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];
 	    }
-#line 479
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 479
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 479
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 479
 		    error("error in toMixedBase 1");
-#line 479
-		value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 479
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT);
 		allInExtRange = allInExtRange 
-#line 479
-		    && inRange3(value[j], var_type[i], NCT_UCHAR);
-#line 479
+		    && inRange3(value[j], var_type[i], NCT_INT);
 	    }
-#line 479
-	    err = nc_put_var_uchar(ncid, i, value);
-#line 479
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_int(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_int(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 479
 		if (allInExtRange) {
-#line 479
 		    IF (err) 
-#line 479
 			error("%s", nc_strerror(err));
-#line 479
 		} else {
-#line 479
 		    IF (err != NC_ERANGE)
-#line 479
 			error("range error: status = %d", err);
-#line 479
 		}
-#line 479
 	    } else {
-#line 479
 		IF (nels > 0 && err != NC_ECHAR)
-#line 479
 		    error("wrong type: status = %d", err);
-#line 479
-	    }
-#line 479
+            }
         }
-#line 479
     }
-#line 479
 
-#line 479
     err = nc_close(ncid);
-#line 479
     IF (err) 
-#line 479
 	error("nc_close: %s", nc_strerror(err));
-#line 479
 
-#line 479
-    check_vars_uchar(scratch);
-#line 479
+    check_vars_int(scratch);
 
-#line 479
     err = remove(scratch);
-#line 479
     IF (err)
-#line 479
         error("remove of %s failed", scratch);
-#line 479
 }
-#line 479
 
 void
-#line 480
-test_nc_put_var_schar(void)
-#line 480
+test_nc_put_vara_long(void)
 {
-#line 480
     int ncid;
-#line 480
-    int varid;
-#line 480
+    int d;
     int i;
-#line 480
     int j;
-#line 480
+    int k;
     int err;
-#line 480
+    int nslabs;
     int nels;
-#line 480
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 480
     int canConvert;	/* Both text or both numeric */
-#line 480
     int allInExtRange;	/* all values within external range? */
-#line 480
-    schar value[MAX_NELS];
-#line 480
+    long value[MAX_NELS];
 
-#line 480
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 480
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 480
         error("nc_create: %s", nc_strerror(err));
-#line 480
         return;
-#line 480
     }
-#line 480
     def_dims(ncid);
-#line 480
     def_vars(ncid);
-#line 480
     err = nc_enddef(ncid);
-#line 480
     IF (err)
-#line 480
         error("nc_enddef: %s", nc_strerror(err));
-#line 480
 
-#line 480
-    for (i = 0; i < NVARS; i++) {
-#line 480
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 480
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 480
         assert(var_nels[i] <= MAX_NELS);
-#line 480
-        err = nc_put_var_schar(BAD_ID, i, value);
-#line 480
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_long(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 480
 	    error("bad ncid: status = %d", err);
-#line 480
-        err = nc_put_var_schar(ncid, BAD_VARID, value);
-#line 480
+        err = nc_put_vara_long(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 480
 	    error("bad var id: status = %d", err);
-#line 480
-
-#line 480
-	nels = 1;
-#line 480
-	for (j = 0; j < var_rank[i]; j++) {
-#line 480
-	    nels *= var_shape[i][j];
-#line 480
-	}
-#line 480
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 480
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 480
-	    IF (err) 
-#line 480
-		error("error in toMixedBase 1");
-#line 480
-	    value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 480
-	    allInExtRange = allInExtRange 
-#line 480
-		&& inRange3(value[j], var_type[i], NCT_SCHAR);
-#line 480
-	}
-#line 480
-        err = nc_put_var_schar(ncid, i, value);
-#line 480
-	if (canConvert) {
-#line 480
-	    if (allInExtRange) {
-#line 480
-		IF (err) 
-#line 480
-		    error("%s", nc_strerror(err));
-#line 480
-	    } else {
-#line 480
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 480
-		    error("range error: status = %d", err);
-#line 480
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_long(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_long(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 480
-	} else {       /* should flag wrong type even if nothing to write */
-#line 480
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 480
-		error("wrong type: status = %d", err);
-#line 480
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 480
-    }
-#line 480
+        err = nc_put_vara_long(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_long(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_long(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
 
-#line 480
-        /* Preceeding has written nothing for record variables, now try */
-#line 480
-        /* again with more than 0 records */
-#line 480
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 480
-	/* Write record number NRECS to force writing of preceding records */
-#line 480
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 480
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 480
-    IF (err)
-#line 480
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 480
-    index[0] = NRECS-1;
-#line 480
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 480
-    IF (err)
-#line 480
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 480
+	err = nc_put_vara_long(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 480
-    for (i = 0; i < NVARS; i++) {
-#line 480
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 480
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 480
-	    assert(var_rank[i] <= MAX_RANK);
-#line 480
-	    assert(var_nels[i] <= MAX_NELS);
-#line 480
-	    err = nc_put_var_schar(BAD_ID, i, value);
-#line 480
-	    IF (err != NC_EBADID) 
-#line 480
-	        error("bad ncid: status = %d", err);
-#line 480
+	    /* 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;
-#line 480
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 480
-		nels *= var_shape[i][j];
-#line 480
+		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];
 	    }
-#line 480
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 480
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 480
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 480
 		    error("error in toMixedBase 1");
-#line 480
-		value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 480
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG);
 		allInExtRange = allInExtRange 
-#line 480
-		    && inRange3(value[j], var_type[i], NCT_SCHAR);
-#line 480
+		    && inRange3(value[j], var_type[i], NCT_LONG);
 	    }
-#line 480
-	    err = nc_put_var_schar(ncid, i, value);
-#line 480
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_long(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_long(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 480
 		if (allInExtRange) {
-#line 480
 		    IF (err) 
-#line 480
 			error("%s", nc_strerror(err));
-#line 480
 		} else {
-#line 480
 		    IF (err != NC_ERANGE)
-#line 480
 			error("range error: status = %d", err);
-#line 480
 		}
-#line 480
 	    } else {
-#line 480
 		IF (nels > 0 && err != NC_ECHAR)
-#line 480
 		    error("wrong type: status = %d", err);
-#line 480
-	    }
-#line 480
+            }
         }
-#line 480
     }
-#line 480
 
-#line 480
     err = nc_close(ncid);
-#line 480
     IF (err) 
-#line 480
 	error("nc_close: %s", nc_strerror(err));
-#line 480
 
-#line 480
-    check_vars_schar(scratch);
-#line 480
+    check_vars_long(scratch);
 
-#line 480
     err = remove(scratch);
-#line 480
     IF (err)
-#line 480
         error("remove of %s failed", scratch);
-#line 480
 }
-#line 480
 
 void
-#line 481
-test_nc_put_var_short(void)
-#line 481
+test_nc_put_vara_float(void)
 {
-#line 481
     int ncid;
-#line 481
-    int varid;
-#line 481
+    int d;
     int i;
-#line 481
     int j;
-#line 481
+    int k;
     int err;
-#line 481
+    int nslabs;
     int nels;
-#line 481
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 481
     int canConvert;	/* Both text or both numeric */
-#line 481
     int allInExtRange;	/* all values within external range? */
-#line 481
-    short value[MAX_NELS];
-#line 481
+    float value[MAX_NELS];
 
-#line 481
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 481
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 481
         error("nc_create: %s", nc_strerror(err));
-#line 481
         return;
-#line 481
     }
-#line 481
     def_dims(ncid);
-#line 481
     def_vars(ncid);
-#line 481
     err = nc_enddef(ncid);
-#line 481
     IF (err)
-#line 481
         error("nc_enddef: %s", nc_strerror(err));
-#line 481
 
-#line 481
-    for (i = 0; i < NVARS; i++) {
-#line 481
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 481
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 481
         assert(var_nels[i] <= MAX_NELS);
-#line 481
-        err = nc_put_var_short(BAD_ID, i, value);
-#line 481
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_float(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 481
 	    error("bad ncid: status = %d", err);
-#line 481
-        err = nc_put_var_short(ncid, BAD_VARID, value);
-#line 481
+        err = nc_put_vara_float(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 481
 	    error("bad var id: status = %d", err);
-#line 481
-
-#line 481
-	nels = 1;
-#line 481
-	for (j = 0; j < var_rank[i]; j++) {
-#line 481
-	    nels *= var_shape[i][j];
-#line 481
-	}
-#line 481
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 481
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 481
-	    IF (err) 
-#line 481
-		error("error in toMixedBase 1");
-#line 481
-	    value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT);
-#line 481
-	    allInExtRange = allInExtRange 
-#line 481
-		&& inRange3(value[j], var_type[i], NCT_SHORT);
-#line 481
-	}
-#line 481
-        err = nc_put_var_short(ncid, i, value);
-#line 481
-	if (canConvert) {
-#line 481
-	    if (allInExtRange) {
-#line 481
-		IF (err) 
-#line 481
-		    error("%s", nc_strerror(err));
-#line 481
-	    } else {
-#line 481
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 481
-		    error("range error: status = %d", err);
-#line 481
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_float(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_float(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 481
-	} else {       /* should flag wrong type even if nothing to write */
-#line 481
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 481
-		error("wrong type: status = %d", err);
-#line 481
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 481
-    }
-#line 481
+        err = nc_put_vara_float(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_float(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_float(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
 
-#line 481
-        /* Preceeding has written nothing for record variables, now try */
-#line 481
-        /* again with more than 0 records */
-#line 481
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 481
-	/* Write record number NRECS to force writing of preceding records */
-#line 481
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 481
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 481
-    IF (err)
-#line 481
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 481
-    index[0] = NRECS-1;
-#line 481
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 481
-    IF (err)
-#line 481
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 481
+	err = nc_put_vara_float(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 481
-    for (i = 0; i < NVARS; i++) {
-#line 481
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 481
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 481
-	    assert(var_rank[i] <= MAX_RANK);
-#line 481
-	    assert(var_nels[i] <= MAX_NELS);
-#line 481
-	    err = nc_put_var_short(BAD_ID, i, value);
-#line 481
-	    IF (err != NC_EBADID) 
-#line 481
-	        error("bad ncid: status = %d", err);
-#line 481
+	    /* 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;
-#line 481
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 481
-		nels *= var_shape[i][j];
-#line 481
+		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];
 	    }
-#line 481
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 481
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 481
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 481
 		    error("error in toMixedBase 1");
-#line 481
-		value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT);
-#line 481
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT);
 		allInExtRange = allInExtRange 
-#line 481
-		    && inRange3(value[j], var_type[i], NCT_SHORT);
-#line 481
+		    && inRange3(value[j], var_type[i], NCT_FLOAT);
 	    }
-#line 481
-	    err = nc_put_var_short(ncid, i, value);
-#line 481
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_float(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_float(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 481
 		if (allInExtRange) {
-#line 481
 		    IF (err) 
-#line 481
 			error("%s", nc_strerror(err));
-#line 481
 		} else {
-#line 481
 		    IF (err != NC_ERANGE)
-#line 481
 			error("range error: status = %d", err);
-#line 481
 		}
-#line 481
 	    } else {
-#line 481
 		IF (nels > 0 && err != NC_ECHAR)
-#line 481
 		    error("wrong type: status = %d", err);
-#line 481
-	    }
-#line 481
+            }
         }
-#line 481
     }
-#line 481
 
-#line 481
     err = nc_close(ncid);
-#line 481
     IF (err) 
-#line 481
 	error("nc_close: %s", nc_strerror(err));
-#line 481
 
-#line 481
-    check_vars_short(scratch);
-#line 481
+    check_vars_float(scratch);
 
-#line 481
     err = remove(scratch);
-#line 481
     IF (err)
-#line 481
         error("remove of %s failed", scratch);
-#line 481
 }
-#line 481
 
 void
-#line 482
-test_nc_put_var_int(void)
-#line 482
+test_nc_put_vara_double(void)
 {
-#line 482
     int ncid;
-#line 482
-    int varid;
-#line 482
+    int d;
     int i;
-#line 482
     int j;
-#line 482
+    int k;
     int err;
-#line 482
+    int nslabs;
     int nels;
-#line 482
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 482
     int canConvert;	/* Both text or both numeric */
-#line 482
     int allInExtRange;	/* all values within external range? */
-#line 482
-    int value[MAX_NELS];
-#line 482
+    double value[MAX_NELS];
 
-#line 482
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 482
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 482
         error("nc_create: %s", nc_strerror(err));
-#line 482
         return;
-#line 482
     }
-#line 482
     def_dims(ncid);
-#line 482
     def_vars(ncid);
-#line 482
     err = nc_enddef(ncid);
-#line 482
     IF (err)
-#line 482
         error("nc_enddef: %s", nc_strerror(err));
-#line 482
 
-#line 482
-    for (i = 0; i < NVARS; i++) {
-#line 482
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 482
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 482
         assert(var_nels[i] <= MAX_NELS);
-#line 482
-        err = nc_put_var_int(BAD_ID, i, value);
-#line 482
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_double(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 482
 	    error("bad ncid: status = %d", err);
-#line 482
-        err = nc_put_var_int(ncid, BAD_VARID, value);
-#line 482
+        err = nc_put_vara_double(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 482
 	    error("bad var id: status = %d", err);
-#line 482
-
-#line 482
-	nels = 1;
-#line 482
-	for (j = 0; j < var_rank[i]; j++) {
-#line 482
-	    nels *= var_shape[i][j];
-#line 482
-	}
-#line 482
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 482
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 482
-	    IF (err) 
-#line 482
-		error("error in toMixedBase 1");
-#line 482
-	    value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT);
-#line 482
-	    allInExtRange = allInExtRange 
-#line 482
-		&& inRange3(value[j], var_type[i], NCT_INT);
-#line 482
-	}
-#line 482
-        err = nc_put_var_int(ncid, i, value);
-#line 482
-	if (canConvert) {
-#line 482
-	    if (allInExtRange) {
-#line 482
-		IF (err) 
-#line 482
-		    error("%s", nc_strerror(err));
-#line 482
-	    } else {
-#line 482
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 482
-		    error("range error: status = %d", err);
-#line 482
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_double(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_double(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 482
-	} else {       /* should flag wrong type even if nothing to write */
-#line 482
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 482
-		error("wrong type: status = %d", err);
-#line 482
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 482
-    }
-#line 482
+        err = nc_put_vara_double(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_double(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_double(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
 
-#line 482
-        /* Preceeding has written nothing for record variables, now try */
-#line 482
-        /* again with more than 0 records */
-#line 482
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 482
-	/* Write record number NRECS to force writing of preceding records */
-#line 482
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 482
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 482
-    IF (err)
-#line 482
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 482
-    index[0] = NRECS-1;
-#line 482
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 482
-    IF (err)
-#line 482
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 482
+	err = nc_put_vara_double(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 482
-    for (i = 0; i < NVARS; i++) {
-#line 482
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 482
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 482
-	    assert(var_rank[i] <= MAX_RANK);
-#line 482
-	    assert(var_nels[i] <= MAX_NELS);
-#line 482
-	    err = nc_put_var_int(BAD_ID, i, value);
-#line 482
-	    IF (err != NC_EBADID) 
-#line 482
-	        error("bad ncid: status = %d", err);
-#line 482
+	    /* 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;
-#line 482
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 482
-		nels *= var_shape[i][j];
-#line 482
+		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];
 	    }
-#line 482
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 482
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 482
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 482
 		    error("error in toMixedBase 1");
-#line 482
-		value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT);
-#line 482
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
 		allInExtRange = allInExtRange 
-#line 482
-		    && inRange3(value[j], var_type[i], NCT_INT);
-#line 482
+		    && inRange3(value[j], var_type[i], NCT_DOUBLE);
 	    }
-#line 482
-	    err = nc_put_var_int(ncid, i, value);
-#line 482
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_double(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_double(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 482
 		if (allInExtRange) {
-#line 482
 		    IF (err) 
-#line 482
 			error("%s", nc_strerror(err));
-#line 482
 		} else {
-#line 482
 		    IF (err != NC_ERANGE)
-#line 482
 			error("range error: status = %d", err);
-#line 482
 		}
-#line 482
 	    } else {
-#line 482
 		IF (nels > 0 && err != NC_ECHAR)
-#line 482
 		    error("wrong type: status = %d", err);
-#line 482
-	    }
-#line 482
+            }
         }
-#line 482
     }
-#line 482
 
-#line 482
     err = nc_close(ncid);
-#line 482
     IF (err) 
-#line 482
 	error("nc_close: %s", nc_strerror(err));
-#line 482
 
-#line 482
-    check_vars_int(scratch);
-#line 482
+    check_vars_double(scratch);
 
-#line 482
     err = remove(scratch);
-#line 482
     IF (err)
-#line 482
         error("remove of %s failed", scratch);
-#line 482
 }
-#line 482
 
 void
-#line 483
-test_nc_put_var_long(void)
-#line 483
+test_nc_put_vara_ushort(void)
 {
-#line 483
     int ncid;
-#line 483
-    int varid;
-#line 483
+    int d;
     int i;
-#line 483
     int j;
-#line 483
+    int k;
     int err;
-#line 483
+    int nslabs;
     int nels;
-#line 483
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 483
     int canConvert;	/* Both text or both numeric */
-#line 483
     int allInExtRange;	/* all values within external range? */
-#line 483
-    long value[MAX_NELS];
-#line 483
+    ushort value[MAX_NELS];
 
-#line 483
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 483
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 483
         error("nc_create: %s", nc_strerror(err));
-#line 483
         return;
-#line 483
     }
-#line 483
     def_dims(ncid);
-#line 483
     def_vars(ncid);
-#line 483
     err = nc_enddef(ncid);
-#line 483
     IF (err)
-#line 483
         error("nc_enddef: %s", nc_strerror(err));
-#line 483
 
-#line 483
-    for (i = 0; i < NVARS; i++) {
-#line 483
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 483
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 483
         assert(var_nels[i] <= MAX_NELS);
-#line 483
-        err = nc_put_var_long(BAD_ID, i, value);
-#line 483
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_ushort(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 483
 	    error("bad ncid: status = %d", err);
-#line 483
-        err = nc_put_var_long(ncid, BAD_VARID, value);
-#line 483
+        err = nc_put_vara_ushort(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 483
 	    error("bad var id: status = %d", err);
-#line 483
-
-#line 483
-	nels = 1;
-#line 483
-	for (j = 0; j < var_rank[i]; j++) {
-#line 483
-	    nels *= var_shape[i][j];
-#line 483
-	}
-#line 483
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 483
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 483
-	    IF (err) 
-#line 483
-		error("error in toMixedBase 1");
-#line 483
-	    value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG);
-#line 483
-	    allInExtRange = allInExtRange 
-#line 483
-		&& inRange3(value[j], var_type[i], NCT_LONG);
-#line 483
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_ushort(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_ushort(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
+	    }
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 483
-        err = nc_put_var_long(ncid, i, value);
-#line 483
-	if (canConvert) {
-#line 483
-	    if (allInExtRange) {
-#line 483
-		IF (err) 
-#line 483
-		    error("%s", nc_strerror(err));
-#line 483
-	    } else {
-#line 483
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 483
-		    error("range error: status = %d", err);
-#line 483
+        err = nc_put_vara_ushort(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_ushort(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_ushort(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
 	    }
-#line 483
-	} else {       /* should flag wrong type even if nothing to write */
-#line 483
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 483
+        }
+
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
+
+	err = nc_put_vara_ushort(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
 		error("wrong type: status = %d", err);
-#line 483
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
 	}
-#line 483
-    }
-#line 483
-
-#line 483
-        /* Preceeding has written nothing for record variables, now try */
-#line 483
-        /* again with more than 0 records */
-#line 483
-
-#line 483
-	/* Write record number NRECS to force writing of preceding records */
-#line 483
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 483
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 483
-    IF (err)
-#line 483
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 483
-    index[0] = NRECS-1;
-#line 483
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 483
-    IF (err)
-#line 483
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 483
 
-#line 483
-    for (i = 0; i < NVARS; i++) {
-#line 483
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 483
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 483
-	    assert(var_rank[i] <= MAX_RANK);
-#line 483
-	    assert(var_nels[i] <= MAX_NELS);
-#line 483
-	    err = nc_put_var_long(BAD_ID, i, value);
-#line 483
-	    IF (err != NC_EBADID) 
-#line 483
-	        error("bad ncid: status = %d", err);
-#line 483
+	    /* 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;
-#line 483
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 483
-		nels *= var_shape[i][j];
-#line 483
+		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];
 	    }
-#line 483
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 483
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 483
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 483
 		    error("error in toMixedBase 1");
-#line 483
-		value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG);
-#line 483
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_ushort(var_type[i], var_rank[i], index, NCT_USHORT);
 		allInExtRange = allInExtRange 
-#line 483
-		    && inRange3(value[j], var_type[i], NCT_LONG);
-#line 483
+		    && inRange3(value[j], var_type[i], NCT_USHORT);
 	    }
-#line 483
-	    err = nc_put_var_long(ncid, i, value);
-#line 483
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_ushort(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_ushort(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 483
 		if (allInExtRange) {
-#line 483
 		    IF (err) 
-#line 483
 			error("%s", nc_strerror(err));
-#line 483
 		} else {
-#line 483
 		    IF (err != NC_ERANGE)
-#line 483
 			error("range error: status = %d", err);
-#line 483
 		}
-#line 483
 	    } else {
-#line 483
 		IF (nels > 0 && err != NC_ECHAR)
-#line 483
 		    error("wrong type: status = %d", err);
-#line 483
-	    }
-#line 483
+            }
         }
-#line 483
     }
-#line 483
 
-#line 483
     err = nc_close(ncid);
-#line 483
     IF (err) 
-#line 483
 	error("nc_close: %s", nc_strerror(err));
-#line 483
 
-#line 483
-    check_vars_long(scratch);
-#line 483
+    check_vars_ushort(scratch);
 
-#line 483
     err = remove(scratch);
-#line 483
     IF (err)
-#line 483
         error("remove of %s failed", scratch);
-#line 483
 }
-#line 483
 
 void
-#line 484
-test_nc_put_var_float(void)
-#line 484
+test_nc_put_vara_uint(void)
 {
-#line 484
     int ncid;
-#line 484
-    int varid;
-#line 484
+    int d;
     int i;
-#line 484
     int j;
-#line 484
+    int k;
     int err;
-#line 484
+    int nslabs;
     int nels;
-#line 484
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 484
     int canConvert;	/* Both text or both numeric */
-#line 484
     int allInExtRange;	/* all values within external range? */
-#line 484
-    float value[MAX_NELS];
-#line 484
+    uint value[MAX_NELS];
 
-#line 484
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 484
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 484
         error("nc_create: %s", nc_strerror(err));
-#line 484
         return;
-#line 484
     }
-#line 484
     def_dims(ncid);
-#line 484
     def_vars(ncid);
-#line 484
     err = nc_enddef(ncid);
-#line 484
     IF (err)
-#line 484
         error("nc_enddef: %s", nc_strerror(err));
-#line 484
 
-#line 484
-    for (i = 0; i < NVARS; i++) {
-#line 484
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 484
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 484
         assert(var_nels[i] <= MAX_NELS);
-#line 484
-        err = nc_put_var_float(BAD_ID, i, value);
-#line 484
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_uint(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 484
 	    error("bad ncid: status = %d", err);
-#line 484
-        err = nc_put_var_float(ncid, BAD_VARID, value);
-#line 484
+        err = nc_put_vara_uint(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 484
 	    error("bad var id: status = %d", err);
-#line 484
-
-#line 484
-	nels = 1;
-#line 484
-	for (j = 0; j < var_rank[i]; j++) {
-#line 484
-	    nels *= var_shape[i][j];
-#line 484
-	}
-#line 484
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 484
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 484
-	    IF (err) 
-#line 484
-		error("error in toMixedBase 1");
-#line 484
-	    value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 484
-	    allInExtRange = allInExtRange 
-#line 484
-		&& inRange3(value[j], var_type[i], NCT_FLOAT);
-#line 484
-	}
-#line 484
-        err = nc_put_var_float(ncid, i, value);
-#line 484
-	if (canConvert) {
-#line 484
-	    if (allInExtRange) {
-#line 484
-		IF (err) 
-#line 484
-		    error("%s", nc_strerror(err));
-#line 484
-	    } else {
-#line 484
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 484
-		    error("range error: status = %d", err);
-#line 484
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_uint(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_uint(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
 	    }
-#line 484
-	} else {       /* should flag wrong type even if nothing to write */
-#line 484
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 484
-		error("wrong type: status = %d", err);
-#line 484
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 484
-    }
-#line 484
+        err = nc_put_vara_uint(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_uint(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_uint(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+	    }
+        }
 
-#line 484
-        /* Preceeding has written nothing for record variables, now try */
-#line 484
-        /* again with more than 0 records */
-#line 484
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 484
-	/* Write record number NRECS to force writing of preceding records */
-#line 484
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 484
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 484
-    IF (err)
-#line 484
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 484
-    index[0] = NRECS-1;
-#line 484
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 484
-    IF (err)
-#line 484
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 484
+	err = nc_put_vara_uint(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 484
-    for (i = 0; i < NVARS; i++) {
-#line 484
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 484
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 484
-	    assert(var_rank[i] <= MAX_RANK);
-#line 484
-	    assert(var_nels[i] <= MAX_NELS);
-#line 484
-	    err = nc_put_var_float(BAD_ID, i, value);
-#line 484
-	    IF (err != NC_EBADID) 
-#line 484
-	        error("bad ncid: status = %d", err);
-#line 484
+	    /* 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;
-#line 484
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 484
-		nels *= var_shape[i][j];
-#line 484
+		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];
 	    }
-#line 484
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 484
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 484
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 484
 		    error("error in toMixedBase 1");
-#line 484
-		value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 484
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_uint(var_type[i], var_rank[i], index, NCT_UINT);
 		allInExtRange = allInExtRange 
-#line 484
-		    && inRange3(value[j], var_type[i], NCT_FLOAT);
-#line 484
+		    && inRange3(value[j], var_type[i], NCT_UINT);
 	    }
-#line 484
-	    err = nc_put_var_float(ncid, i, value);
-#line 484
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_uint(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_uint(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 484
 		if (allInExtRange) {
-#line 484
 		    IF (err) 
-#line 484
 			error("%s", nc_strerror(err));
-#line 484
 		} else {
-#line 484
 		    IF (err != NC_ERANGE)
-#line 484
 			error("range error: status = %d", err);
-#line 484
 		}
-#line 484
 	    } else {
-#line 484
 		IF (nels > 0 && err != NC_ECHAR)
-#line 484
 		    error("wrong type: status = %d", err);
-#line 484
-	    }
-#line 484
+            }
         }
-#line 484
     }
-#line 484
 
-#line 484
     err = nc_close(ncid);
-#line 484
     IF (err) 
-#line 484
 	error("nc_close: %s", nc_strerror(err));
-#line 484
 
-#line 484
-    check_vars_float(scratch);
-#line 484
+    check_vars_uint(scratch);
 
-#line 484
     err = remove(scratch);
-#line 484
     IF (err)
-#line 484
         error("remove of %s failed", scratch);
-#line 484
 }
-#line 484
 
 void
-#line 485
-test_nc_put_var_double(void)
-#line 485
+test_nc_put_vara_longlong(void)
 {
-#line 485
     int ncid;
-#line 485
-    int varid;
-#line 485
+    int d;
     int i;
-#line 485
     int j;
-#line 485
+    int k;
     int err;
-#line 485
+    int nslabs;
     int nels;
-#line 485
+    size_t start[MAX_RANK];
+    size_t edge[MAX_RANK];
+    size_t mid[MAX_RANK];
     size_t index[MAX_RANK];
-#line 485
     int canConvert;	/* Both text or both numeric */
-#line 485
     int allInExtRange;	/* all values within external range? */
-#line 485
-    double value[MAX_NELS];
-#line 485
+    longlong value[MAX_NELS];
 
-#line 485
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 485
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 485
         error("nc_create: %s", nc_strerror(err));
-#line 485
         return;
-#line 485
     }
-#line 485
     def_dims(ncid);
-#line 485
     def_vars(ncid);
-#line 485
     err = nc_enddef(ncid);
-#line 485
     IF (err)
-#line 485
         error("nc_enddef: %s", nc_strerror(err));
-#line 485
 
-#line 485
-    for (i = 0; i < NVARS; i++) {
-#line 485
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 485
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    value[0] = 0;
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 485
         assert(var_nels[i] <= MAX_NELS);
-#line 485
-        err = nc_put_var_double(BAD_ID, i, value);
-#line 485
+        for (j = 0; j < var_rank[i]; j++) {
+            start[j] = 0;
+            edge[j] = 1;
+	}
+        err = nc_put_vara_longlong(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 485
 	    error("bad ncid: status = %d", err);
-#line 485
-        err = nc_put_var_double(ncid, BAD_VARID, value);
-#line 485
+        err = nc_put_vara_longlong(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 485
 	    error("bad var id: status = %d", err);
-#line 485
-
-#line 485
-	nels = 1;
-#line 485
-	for (j = 0; j < var_rank[i]; j++) {
-#line 485
-	    nels *= var_shape[i][j];
-#line 485
-	}
-#line 485
-	for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 485
-	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 485
-	    IF (err) 
-#line 485
-		error("error in toMixedBase 1");
-#line 485
-	    value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 485
-	    allInExtRange = allInExtRange 
-#line 485
-		&& inRange3(value[j], var_type[i], NCT_DOUBLE);
-#line 485
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_longlong(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vara_longlong(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
+	    }
+        }
+            /* Check correct error returned even when nothing to put */
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 0;
 	}
-#line 485
-        err = nc_put_var_double(ncid, i, value);
-#line 485
-	if (canConvert) {
-#line 485
-	    if (allInExtRange) {
-#line 485
-		IF (err) 
-#line 485
-		    error("%s", nc_strerror(err));
-#line 485
-	    } else {
-#line 485
-		IF (err != NC_ERANGE && var_dimid[i][0] != RECDIM)
-#line 485
-		    error("range error: status = %d", err);
-#line 485
+        err = nc_put_vara_longlong(BAD_ID, i, start, edge, value);
+        IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+        err = nc_put_vara_longlong(ncid, BAD_VARID, start, edge, value);
+        IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+        for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j];
+		err = nc_put_vara_longlong(ncid, i, start, edge, value);
+		IF (canConvert && err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		start[j] = 0;
 	    }
-#line 485
-	} else {       /* should flag wrong type even if nothing to write */
-#line 485
-	    IF (nels > 0 && err != NC_ECHAR)
-#line 485
-		error("wrong type: status = %d", err);
-#line 485
-	}
-#line 485
-    }
-#line 485
+        }
 
-#line 485
-        /* Preceeding has written nothing for record variables, now try */
-#line 485
-        /* again with more than 0 records */
-#line 485
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
 
-#line 485
-	/* Write record number NRECS to force writing of preceding records */
-#line 485
-	/* Assumes variable cr is char vector with UNLIMITED dimension */
-#line 485
-    err = nc_inq_varid(ncid, "cr", &varid);
-#line 485
-    IF (err)
-#line 485
-        error("nc_inq_varid: %s", nc_strerror(err));
-#line 485
-    index[0] = NRECS-1;
-#line 485
-    err = nc_put_var1_text(ncid, varid, index, "x");
-#line 485
-    IF (err)
-#line 485
-        error("nc_put_var1_text: %s", nc_strerror(err));
-#line 485
+	err = nc_put_vara_longlong(ncid, i, start, edge, value);
+	if (canConvert) {
+	    IF (err) 
+		error("%s", nc_strerror(err));
+	} else {
+	    IF (err != NC_ECHAR)
+		error("wrong type: status = %d", err);
+        }
+*/
+        for (j = 0; j < var_rank[i]; j++) {
+            edge[j] = 1;
+	}
 
-#line 485
-    for (i = 0; i < NVARS; i++) {
-#line 485
-        if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
-#line 485
-	    canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 485
-	    assert(var_rank[i] <= MAX_RANK);
-#line 485
-	    assert(var_nels[i] <= MAX_NELS);
-#line 485
-	    err = nc_put_var_double(BAD_ID, i, value);
-#line 485
-	    IF (err != NC_EBADID) 
-#line 485
-	        error("bad ncid: status = %d", err);
-#line 485
+	    /* 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;
-#line 485
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 485
-		nels *= var_shape[i][j];
-#line 485
+		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];
 	    }
-#line 485
-	    for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 485
-		err = toMixedBase(j, var_rank[i], var_shape[i], index);
-#line 485
+            for (allInExtRange = 1, j = 0; j < nels; j++) {
+		err = toMixedBase(j, var_rank[i], edge, index);
 		IF (err) 
-#line 485
 		    error("error in toMixedBase 1");
-#line 485
-		value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 485
+		for (d = 0; d < var_rank[i]; d++) 
+		    index[d] += start[d];
+		value[j]= hash_longlong(var_type[i], var_rank[i], index, NCT_LONGLONG);
 		allInExtRange = allInExtRange 
-#line 485
-		    && inRange3(value[j], var_type[i], NCT_DOUBLE);
-#line 485
+		    && inRange3(value[j], var_type[i], NCT_LONGLONG);
 	    }
-#line 485
-	    err = nc_put_var_double(ncid, i, value);
-#line 485
+	    if (var_rank[i] == 0 && i%2 == 0)
+		err = nc_put_vara_longlong(ncid, i, NULL, NULL, value);
+	    else
+		err = nc_put_vara_longlong(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 485
 		if (allInExtRange) {
-#line 485
 		    IF (err) 
-#line 485
 			error("%s", nc_strerror(err));
-#line 485
 		} else {
-#line 485
 		    IF (err != NC_ERANGE)
-#line 485
 			error("range error: status = %d", err);
-#line 485
 		}
-#line 485
 	    } else {
-#line 485
 		IF (nels > 0 && err != NC_ECHAR)
-#line 485
 		    error("wrong type: status = %d", err);
-#line 485
-	    }
-#line 485
+            }
         }
-#line 485
     }
-#line 485
 
-#line 485
     err = nc_close(ncid);
-#line 485
     IF (err) 
-#line 485
 	error("nc_close: %s", nc_strerror(err));
-#line 485
 
-#line 485
-    check_vars_double(scratch);
-#line 485
+    check_vars_longlong(scratch);
 
-#line 485
     err = remove(scratch);
-#line 485
     IF (err)
-#line 485
         error("remove of %s failed", scratch);
-#line 485
 }
-#line 485
-
-
-
-#line 642
 
 void
-#line 643
-test_nc_put_vara_text(void)
-#line 643
+test_nc_put_vara_ulonglong(void)
 {
-#line 643
     int ncid;
-#line 643
     int d;
-#line 643
     int i;
-#line 643
     int j;
-#line 643
     int k;
-#line 643
     int err;
-#line 643
     int nslabs;
-#line 643
     int nels;
-#line 643
     size_t start[MAX_RANK];
-#line 643
     size_t edge[MAX_RANK];
-#line 643
     size_t mid[MAX_RANK];
-#line 643
     size_t index[MAX_RANK];
-#line 643
     int canConvert;	/* Both text or both numeric */
-#line 643
     int allInExtRange;	/* all values within external range? */
-#line 643
-    text value[MAX_NELS];
-#line 643
+    ulonglong value[MAX_NELS];
 
-#line 643
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 643
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 643
         error("nc_create: %s", nc_strerror(err));
-#line 643
         return;
-#line 643
     }
-#line 643
     def_dims(ncid);
-#line 643
     def_vars(ncid);
-#line 643
     err = nc_enddef(ncid);
-#line 643
     IF (err)
-#line 643
         error("nc_enddef: %s", nc_strerror(err));
-#line 643
 
-#line 643
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
     value[0] = 0;
-#line 643
-    for (i = 0; i < NVARS; i++) {
-#line 643
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 643
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
-#line 643
         assert(var_nels[i] <= MAX_NELS);
-#line 643
         for (j = 0; j < var_rank[i]; j++) {
-#line 643
             start[j] = 0;
-#line 643
             edge[j] = 1;
-#line 643
 	}
-#line 643
-        err = nc_put_vara_text(BAD_ID, i, start, edge, value);
-#line 643
+        err = nc_put_vara_ulonglong(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 643
 	    error("bad ncid: status = %d", err);
-#line 643
-        err = nc_put_vara_text(ncid, BAD_VARID, start, edge, value);
-#line 643
+        err = nc_put_vara_ulonglong(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 643
 	    error("bad var id: status = %d", err);
-#line 643
         for (j = 0; j < var_rank[i]; j++) {
-#line 643
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 643
 		start[j] = var_shape[i][j];
-#line 643
-		err = nc_put_vara_text(ncid, i, start, edge, value);
-#line 643
+		err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
 		IF (canConvert && err != NC_EINVALCOORDS)
-#line 643
 		    error("bad start: status = %d", err);
-#line 643
 		start[j] = 0;
-#line 643
 		edge[j] = var_shape[i][j] + 1;
-#line 643
-		err = nc_put_vara_text(ncid, i, start, edge, value);
-#line 643
+		err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
 		IF (canConvert && err != NC_EEDGE)
-#line 643
 		    error("bad edge: status = %d", err);
-#line 643
 		edge[j] = 1;
-#line 643
 	    }
-#line 643
         }
-#line 643
             /* Check correct error returned even when nothing to put */
-#line 643
         for (j = 0; j < var_rank[i]; j++) {
-#line 643
             edge[j] = 0;
-#line 643
 	}
-#line 643
-        err = nc_put_vara_text(BAD_ID, i, start, edge, value);
-#line 643
+        err = nc_put_vara_ulonglong(BAD_ID, i, start, edge, value);
         IF (err != NC_EBADID) 
-#line 643
 	    error("bad ncid: status = %d", err);
-#line 643
-        err = nc_put_vara_text(ncid, BAD_VARID, start, edge, value);
-#line 643
+        err = nc_put_vara_ulonglong(ncid, BAD_VARID, start, edge, value);
         IF (err != NC_ENOTVAR) 
-#line 643
 	    error("bad var id: status = %d", err);
-#line 643
         for (j = 0; j < var_rank[i]; j++) {
-#line 643
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 643
 		start[j] = var_shape[i][j];
-#line 643
-		err = nc_put_vara_text(ncid, i, start, edge, value);
-#line 643
+		err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
 		IF (canConvert && err != NC_EINVALCOORDS)
-#line 643
 		    error("bad start: status = %d", err);
-#line 643
 		start[j] = 0;
-#line 643
 	    }
-#line 643
         }
-#line 643
-	err = nc_put_vara_text(ncid, i, start, edge, value);
-#line 643
+
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
+
+	err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
 	if (canConvert) {
-#line 643
 	    IF (err) 
-#line 643
 		error("%s", nc_strerror(err));
-#line 643
 	} else {
-#line 643
 	    IF (err != NC_ECHAR)
-#line 643
 		error("wrong type: status = %d", err);
-#line 643
         }
-#line 643
+*/
         for (j = 0; j < var_rank[i]; j++) {
-#line 643
             edge[j] = 1;
-#line 643
 	}
-#line 643
 
-#line 643
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 643
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 643
 	nslabs = 1;
-#line 643
 	for (j = 0; j < var_rank[i]; j++) {
-#line 643
             mid[j] = roll( var_shape[i][j] );
-#line 643
 	    nslabs *= 2;
-#line 643
 	}
-#line 643
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 643
 	for (k = 0; k < nslabs; k++) {
-#line 643
 	    nels = 1;
-#line 643
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 643
 		if ((k >> j) & 1) {
-#line 643
 		    start[j] = 0;
-#line 643
 		    edge[j] = mid[j];
-#line 643
 		}else{
-#line 643
 		    start[j] = mid[j];
-#line 643
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 643
 		}
-#line 643
 		nels *= edge[j];
-#line 643
 	    }
-#line 643
             for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 643
 		err = toMixedBase(j, var_rank[i], edge, index);
-#line 643
 		IF (err) 
-#line 643
 		    error("error in toMixedBase 1");
-#line 643
 		for (d = 0; d < var_rank[i]; d++) 
-#line 643
 		    index[d] += start[d];
-#line 643
-		value[j]= hash_text(var_type[i], var_rank[i], index, NCT_TEXT);
-#line 643
+		value[j]= hash_ulonglong(var_type[i], var_rank[i], index, NCT_ULONGLONG);
 		allInExtRange = allInExtRange 
-#line 643
-		    && inRange3(value[j], var_type[i], NCT_TEXT);
-#line 643
+		    && inRange3(value[j], var_type[i], NCT_ULONGLONG);
 	    }
-#line 643
 	    if (var_rank[i] == 0 && i%2 == 0)
-#line 643
-		err = nc_put_vara_text(ncid, i, NULL, NULL, value);
-#line 643
+		err = nc_put_vara_ulonglong(ncid, i, NULL, NULL, value);
 	    else
-#line 643
-		err = nc_put_vara_text(ncid, i, start, edge, value);
-#line 643
+		err = nc_put_vara_ulonglong(ncid, i, start, edge, value);
 	    if (canConvert) {
-#line 643
 		if (allInExtRange) {
-#line 643
 		    IF (err) 
-#line 643
 			error("%s", nc_strerror(err));
-#line 643
 		} else {
-#line 643
 		    IF (err != NC_ERANGE)
-#line 643
 			error("range error: status = %d", err);
-#line 643
 		}
-#line 643
 	    } else {
-#line 643
 		IF (nels > 0 && err != NC_ECHAR)
-#line 643
 		    error("wrong type: status = %d", err);
-#line 643
             }
-#line 643
         }
-#line 643
     }
-#line 643
 
-#line 643
     err = nc_close(ncid);
-#line 643
     IF (err) 
-#line 643
 	error("nc_close: %s", nc_strerror(err));
-#line 643
 
-#line 643
+    check_vars_ulonglong(scratch);
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+
+
+
+void
+test_nc_put_vars_text(void)
+{
+    int ncid;
+    int d;
+    int i;
+    int j;
+    int k;
+    int m;
+    int err;
+    int nels;
+    int nslabs;
+    int nstarts;        /* number of different starts */
+    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];
+    int canConvert;	/* Both text or both numeric */
+    int allInExtRange;	/* all values within external range? */
+    text value[MAX_NELS];
+
+    err = file_create(scratch, NC_CLOBBER, &ncid);
+    IF (err) {
+	error("nc_create: %s", nc_strerror(err));
+	return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+    err = nc_enddef(ncid);
+    IF (err)
+	error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
+	}
+	err = nc_put_vars_text(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
+	    error("bad ncid: status = %d", err);
+	err = nc_put_vars_text(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
+	    error("bad var id: status = %d", err);
+	for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
+		    error("bad start: status = %d", err);
+		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("bad edge: status = %d", err);
+		edge[j] = 1;
+		stride[j] = 0;
+		err = nc_put_vars_text(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
+	    }
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_text(var_type[i], var_rank[i], index2, 
+			NCT_TEXT);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_TEXT);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_text(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_text(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
+		} else {
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
+		}
+	    }
+	}
+    }
+
+    err = nc_close(ncid);
+    IF (err) 
+	error("nc_close: %s", nc_strerror(err));
+
     check_vars_text(scratch);
-#line 643
 
-#line 643
     err = remove(scratch);
-#line 643
     IF (err)
-#line 643
-        error("remove of %s failed", scratch);
-#line 643
+	error("remove of %s failed", scratch);
 }
-#line 643
 
 void
-#line 644
-test_nc_put_vara_uchar(void)
-#line 644
+test_nc_put_vars_uchar(void)
 {
-#line 644
     int ncid;
-#line 644
     int d;
-#line 644
     int i;
-#line 644
     int j;
-#line 644
     int k;
-#line 644
+    int m;
     int err;
-#line 644
-    int nslabs;
-#line 644
     int nels;
-#line 644
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 644
     size_t edge[MAX_RANK];
-#line 644
-    size_t mid[MAX_RANK];
-#line 644
     size_t index[MAX_RANK];
-#line 644
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 644
     int allInExtRange;	/* all values within external range? */
-#line 644
     uchar value[MAX_NELS];
-#line 644
 
-#line 644
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 644
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 644
-        error("nc_create: %s", nc_strerror(err));
-#line 644
-        return;
-#line 644
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 644
     def_dims(ncid);
-#line 644
     def_vars(ncid);
-#line 644
     err = nc_enddef(ncid);
-#line 644
     IF (err)
-#line 644
-        error("nc_enddef: %s", nc_strerror(err));
-#line 644
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 644
-    value[0] = 0;
-#line 644
-    for (i = 0; i < NVARS; i++) {
-#line 644
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 644
-        assert(var_rank[i] <= MAX_RANK);
-#line 644
-        assert(var_nels[i] <= MAX_NELS);
-#line 644
-        for (j = 0; j < var_rank[i]; j++) {
-#line 644
-            start[j] = 0;
-#line 644
-            edge[j] = 1;
-#line 644
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 644
-        err = nc_put_vara_uchar(BAD_ID, i, start, edge, value);
-#line 644
-        IF (err != NC_EBADID) 
-#line 644
+	err = nc_put_vars_uchar(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 644
-        err = nc_put_vara_uchar(ncid, BAD_VARID, start, edge, value);
-#line 644
-        IF (err != NC_ENOTVAR) 
-#line 644
+	err = nc_put_vars_uchar(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 644
-        for (j = 0; j < var_rank[i]; j++) {
-#line 644
+	for (j = 0; j < var_rank[i]; j++) {
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 644
-		start[j] = var_shape[i][j];
-#line 644
-		err = nc_put_vara_uchar(ncid, i, start, edge, value);
-#line 644
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 644
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 644
 		start[j] = 0;
-#line 644
 		edge[j] = var_shape[i][j] + 1;
-#line 644
-		err = nc_put_vara_uchar(ncid, i, start, edge, value);
-#line 644
-		IF (canConvert && err != NC_EEDGE)
-#line 644
+		err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
 		    error("bad edge: status = %d", err);
-#line 644
 		edge[j] = 1;
-#line 644
-	    }
-#line 644
-        }
-#line 644
-            /* Check correct error returned even when nothing to put */
-#line 644
-        for (j = 0; j < var_rank[i]; j++) {
-#line 644
-            edge[j] = 0;
-#line 644
-	}
-#line 644
-        err = nc_put_vara_uchar(BAD_ID, i, start, edge, value);
-#line 644
-        IF (err != NC_EBADID) 
-#line 644
-	    error("bad ncid: status = %d", err);
-#line 644
-        err = nc_put_vara_uchar(ncid, BAD_VARID, start, edge, value);
-#line 644
-        IF (err != NC_ENOTVAR) 
-#line 644
-	    error("bad var id: status = %d", err);
-#line 644
-        for (j = 0; j < var_rank[i]; j++) {
-#line 644
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 644
-		start[j] = var_shape[i][j];
-#line 644
-		err = nc_put_vara_uchar(ncid, i, start, edge, value);
-#line 644
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 644
-		    error("bad start: status = %d", err);
-#line 644
-		start[j] = 0;
-#line 644
+		stride[j] = 0;
+		err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 644
-        }
-#line 644
-	err = nc_put_vara_uchar(ncid, i, start, edge, value);
-#line 644
-	if (canConvert) {
-#line 644
-	    IF (err) 
-#line 644
-		error("%s", nc_strerror(err));
-#line 644
-	} else {
-#line 644
-	    IF (err != NC_ECHAR)
-#line 644
-		error("wrong type: status = %d", err);
-#line 644
-        }
-#line 644
-        for (j = 0; j < var_rank[i]; j++) {
-#line 644
-            edge[j] = 1;
-#line 644
 	}
-#line 644
-
-#line 644
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 644
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 644
 	nslabs = 1;
-#line 644
 	for (j = 0; j < var_rank[i]; j++) {
-#line 644
-            mid[j] = roll( var_shape[i][j] );
-#line 644
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 644
 	}
-#line 644
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 644
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 644
-	    nels = 1;
-#line 644
+	    nstarts = 1;
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 644
 		if ((k >> j) & 1) {
-#line 644
 		    start[j] = 0;
-#line 644
 		    edge[j] = mid[j];
-#line 644
 		}else{
-#line 644
 		    start[j] = mid[j];
-#line 644
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 644
 		}
-#line 644
-		nels *= edge[j];
-#line 644
-	    }
-#line 644
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 644
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 644
-		IF (err) 
-#line 644
-		    error("error in toMixedBase 1");
-#line 644
-		for (d = 0; d < var_rank[i]; d++) 
-#line 644
-		    index[d] += start[d];
-#line 644
-		value[j]= hash_uchar(var_type[i], var_rank[i], index, NCT_UCHAR);
-#line 644
-		allInExtRange = allInExtRange 
-#line 644
-		    && inRange3(value[j], var_type[i], NCT_UCHAR);
-#line 644
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 644
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 644
-		err = nc_put_vara_uchar(ncid, i, NULL, NULL, value);
-#line 644
-	    else
-#line 644
-		err = nc_put_vara_uchar(ncid, i, start, edge, value);
-#line 644
-	    if (canConvert) {
-#line 644
-		if (allInExtRange) {
-#line 644
-		    IF (err) 
-#line 644
-			error("%s", nc_strerror(err));
-#line 644
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_uchar(var_type[i], var_rank[i], index2, 
+			NCT_UCHAR);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_UCHAR);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_uchar(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_uchar(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 644
-		    IF (err != NC_ERANGE)
-#line 644
-			error("range error: status = %d", err);
-#line 644
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 644
-	    } else {
-#line 644
-		IF (nels > 0 && err != NC_ECHAR)
-#line 644
-		    error("wrong type: status = %d", err);
-#line 644
-            }
-#line 644
-        }
-#line 644
+	    }
+	}
     }
-#line 644
 
-#line 644
     err = nc_close(ncid);
-#line 644
     IF (err) 
-#line 644
 	error("nc_close: %s", nc_strerror(err));
-#line 644
 
-#line 644
     check_vars_uchar(scratch);
-#line 644
 
-#line 644
     err = remove(scratch);
-#line 644
     IF (err)
-#line 644
-        error("remove of %s failed", scratch);
-#line 644
+	error("remove of %s failed", scratch);
 }
-#line 644
 
 void
-#line 645
-test_nc_put_vara_schar(void)
-#line 645
+test_nc_put_vars_schar(void)
 {
-#line 645
     int ncid;
-#line 645
     int d;
-#line 645
     int i;
-#line 645
     int j;
-#line 645
     int k;
-#line 645
+    int m;
     int err;
-#line 645
-    int nslabs;
-#line 645
     int nels;
-#line 645
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 645
     size_t edge[MAX_RANK];
-#line 645
-    size_t mid[MAX_RANK];
-#line 645
     size_t index[MAX_RANK];
-#line 645
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 645
     int allInExtRange;	/* all values within external range? */
-#line 645
     schar value[MAX_NELS];
-#line 645
 
-#line 645
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 645
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 645
-        error("nc_create: %s", nc_strerror(err));
-#line 645
-        return;
-#line 645
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 645
     def_dims(ncid);
-#line 645
     def_vars(ncid);
-#line 645
     err = nc_enddef(ncid);
-#line 645
     IF (err)
-#line 645
-        error("nc_enddef: %s", nc_strerror(err));
-#line 645
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 645
-    value[0] = 0;
-#line 645
-    for (i = 0; i < NVARS; i++) {
-#line 645
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 645
-        assert(var_rank[i] <= MAX_RANK);
-#line 645
-        assert(var_nels[i] <= MAX_NELS);
-#line 645
-        for (j = 0; j < var_rank[i]; j++) {
-#line 645
-            start[j] = 0;
-#line 645
-            edge[j] = 1;
-#line 645
-	}
-#line 645
-        err = nc_put_vara_schar(BAD_ID, i, start, edge, value);
-#line 645
-        IF (err != NC_EBADID) 
-#line 645
-	    error("bad ncid: status = %d", err);
-#line 645
-        err = nc_put_vara_schar(ncid, BAD_VARID, start, edge, value);
-#line 645
-        IF (err != NC_ENOTVAR) 
-#line 645
-	    error("bad var id: status = %d", err);
-#line 645
-        for (j = 0; j < var_rank[i]; j++) {
-#line 645
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 645
-		start[j] = var_shape[i][j];
-#line 645
-		err = nc_put_vara_schar(ncid, i, start, edge, value);
-#line 645
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 645
-		    error("bad start: status = %d", err);
-#line 645
-		start[j] = 0;
-#line 645
-		edge[j] = var_shape[i][j] + 1;
-#line 645
-		err = nc_put_vara_schar(ncid, i, start, edge, value);
-#line 645
-		IF (canConvert && err != NC_EEDGE)
-#line 645
-		    error("bad edge: status = %d", err);
-#line 645
-		edge[j] = 1;
-#line 645
-	    }
-#line 645
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
         }
-#line 645
-            /* Check correct error returned even when nothing to put */
-#line 645
-        for (j = 0; j < var_rank[i]; j++) {
-#line 645
-            edge[j] = 0;
-#line 645
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 645
-        err = nc_put_vara_schar(BAD_ID, i, start, edge, value);
-#line 645
-        IF (err != NC_EBADID) 
-#line 645
+	err = nc_put_vars_schar(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 645
-        err = nc_put_vara_schar(ncid, BAD_VARID, start, edge, value);
-#line 645
-        IF (err != NC_ENOTVAR) 
-#line 645
+	err = nc_put_vars_schar(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 645
-        for (j = 0; j < var_rank[i]; j++) {
-#line 645
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 645
-		start[j] = var_shape[i][j];
-#line 645
-		err = nc_put_vara_schar(ncid, i, start, edge, value);
-#line 645
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 645
+	for (j = 0; j < var_rank[i]; j++) {
+	    if (var_dimid[i][j] > 0) {		/* skip record dim */
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 645
 		start[j] = 0;
-#line 645
+		edge[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
+		    error("bad edge: status = %d", err);
+		edge[j] = 1;
+		stride[j] = 0;
+		err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 645
-        }
-#line 645
-	err = nc_put_vara_schar(ncid, i, start, edge, value);
-#line 645
-	if (canConvert) {
-#line 645
-	    IF (err) 
-#line 645
-		error("%s", nc_strerror(err));
-#line 645
-	} else {
-#line 645
-	    IF (err != NC_ECHAR)
-#line 645
-		error("wrong type: status = %d", err);
-#line 645
-        }
-#line 645
-        for (j = 0; j < var_rank[i]; j++) {
-#line 645
-            edge[j] = 1;
-#line 645
 	}
-#line 645
-
-#line 645
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 645
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 645
 	nslabs = 1;
-#line 645
 	for (j = 0; j < var_rank[i]; j++) {
-#line 645
-            mid[j] = roll( var_shape[i][j] );
-#line 645
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 645
 	}
-#line 645
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 645
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 645
-	    nels = 1;
-#line 645
+	    nstarts = 1;
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 645
 		if ((k >> j) & 1) {
-#line 645
 		    start[j] = 0;
-#line 645
 		    edge[j] = mid[j];
-#line 645
 		}else{
-#line 645
 		    start[j] = mid[j];
-#line 645
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 645
 		}
-#line 645
-		nels *= edge[j];
-#line 645
-	    }
-#line 645
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 645
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 645
-		IF (err) 
-#line 645
-		    error("error in toMixedBase 1");
-#line 645
-		for (d = 0; d < var_rank[i]; d++) 
-#line 645
-		    index[d] += start[d];
-#line 645
-		value[j]= hash_schar(var_type[i], var_rank[i], index, NCT_SCHAR);
-#line 645
-		allInExtRange = allInExtRange 
-#line 645
-		    && inRange3(value[j], var_type[i], NCT_SCHAR);
-#line 645
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 645
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 645
-		err = nc_put_vara_schar(ncid, i, NULL, NULL, value);
-#line 645
-	    else
-#line 645
-		err = nc_put_vara_schar(ncid, i, start, edge, value);
-#line 645
-	    if (canConvert) {
-#line 645
-		if (allInExtRange) {
-#line 645
-		    IF (err) 
-#line 645
-			error("%s", nc_strerror(err));
-#line 645
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_schar(var_type[i], var_rank[i], index2, 
+			NCT_SCHAR);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_SCHAR);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_schar(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_schar(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 645
-		    IF (err != NC_ERANGE)
-#line 645
-			error("range error: status = %d", err);
-#line 645
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 645
-	    } else {
-#line 645
-		IF (nels > 0 && err != NC_ECHAR)
-#line 645
-		    error("wrong type: status = %d", err);
-#line 645
-            }
-#line 645
-        }
-#line 645
+	    }
+	}
     }
-#line 645
 
-#line 645
     err = nc_close(ncid);
-#line 645
     IF (err) 
-#line 645
 	error("nc_close: %s", nc_strerror(err));
-#line 645
 
-#line 645
     check_vars_schar(scratch);
-#line 645
 
-#line 645
     err = remove(scratch);
-#line 645
     IF (err)
-#line 645
-        error("remove of %s failed", scratch);
-#line 645
+	error("remove of %s failed", scratch);
 }
-#line 645
 
 void
-#line 646
-test_nc_put_vara_short(void)
-#line 646
+test_nc_put_vars_short(void)
 {
-#line 646
     int ncid;
-#line 646
     int d;
-#line 646
     int i;
-#line 646
     int j;
-#line 646
     int k;
-#line 646
+    int m;
     int err;
-#line 646
-    int nslabs;
-#line 646
     int nels;
-#line 646
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 646
     size_t edge[MAX_RANK];
-#line 646
-    size_t mid[MAX_RANK];
-#line 646
     size_t index[MAX_RANK];
-#line 646
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 646
     int allInExtRange;	/* all values within external range? */
-#line 646
     short value[MAX_NELS];
-#line 646
 
-#line 646
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 646
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 646
-        error("nc_create: %s", nc_strerror(err));
-#line 646
-        return;
-#line 646
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 646
     def_dims(ncid);
-#line 646
     def_vars(ncid);
-#line 646
     err = nc_enddef(ncid);
-#line 646
     IF (err)
-#line 646
-        error("nc_enddef: %s", nc_strerror(err));
-#line 646
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 646
-    value[0] = 0;
-#line 646
-    for (i = 0; i < NVARS; i++) {
-#line 646
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 646
-        assert(var_rank[i] <= MAX_RANK);
-#line 646
-        assert(var_nels[i] <= MAX_NELS);
-#line 646
-        for (j = 0; j < var_rank[i]; j++) {
-#line 646
-            start[j] = 0;
-#line 646
-            edge[j] = 1;
-#line 646
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 646
-        err = nc_put_vara_short(BAD_ID, i, start, edge, value);
-#line 646
-        IF (err != NC_EBADID) 
-#line 646
+	err = nc_put_vars_short(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 646
-        err = nc_put_vara_short(ncid, BAD_VARID, start, edge, value);
-#line 646
-        IF (err != NC_ENOTVAR) 
-#line 646
+	err = nc_put_vars_short(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 646
-        for (j = 0; j < var_rank[i]; j++) {
-#line 646
+	for (j = 0; j < var_rank[i]; j++) {
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 646
-		start[j] = var_shape[i][j];
-#line 646
-		err = nc_put_vara_short(ncid, i, start, edge, value);
-#line 646
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 646
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 646
 		start[j] = 0;
-#line 646
 		edge[j] = var_shape[i][j] + 1;
-#line 646
-		err = nc_put_vara_short(ncid, i, start, edge, value);
-#line 646
-		IF (canConvert && err != NC_EEDGE)
-#line 646
+		err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
 		    error("bad edge: status = %d", err);
-#line 646
 		edge[j] = 1;
-#line 646
-	    }
-#line 646
-        }
-#line 646
-            /* Check correct error returned even when nothing to put */
-#line 646
-        for (j = 0; j < var_rank[i]; j++) {
-#line 646
-            edge[j] = 0;
-#line 646
-	}
-#line 646
-        err = nc_put_vara_short(BAD_ID, i, start, edge, value);
-#line 646
-        IF (err != NC_EBADID) 
-#line 646
-	    error("bad ncid: status = %d", err);
-#line 646
-        err = nc_put_vara_short(ncid, BAD_VARID, start, edge, value);
-#line 646
-        IF (err != NC_ENOTVAR) 
-#line 646
-	    error("bad var id: status = %d", err);
-#line 646
-        for (j = 0; j < var_rank[i]; j++) {
-#line 646
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 646
-		start[j] = var_shape[i][j];
-#line 646
-		err = nc_put_vara_short(ncid, i, start, edge, value);
-#line 646
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 646
-		    error("bad start: status = %d", err);
-#line 646
-		start[j] = 0;
-#line 646
+		stride[j] = 0;
+		err = nc_put_vars_short(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 646
-        }
-#line 646
-	err = nc_put_vara_short(ncid, i, start, edge, value);
-#line 646
-	if (canConvert) {
-#line 646
-	    IF (err) 
-#line 646
-		error("%s", nc_strerror(err));
-#line 646
-	} else {
-#line 646
-	    IF (err != NC_ECHAR)
-#line 646
-		error("wrong type: status = %d", err);
-#line 646
-        }
-#line 646
-        for (j = 0; j < var_rank[i]; j++) {
-#line 646
-            edge[j] = 1;
-#line 646
 	}
-#line 646
-
-#line 646
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 646
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 646
 	nslabs = 1;
-#line 646
 	for (j = 0; j < var_rank[i]; j++) {
-#line 646
-            mid[j] = roll( var_shape[i][j] );
-#line 646
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 646
 	}
-#line 646
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 646
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 646
-	    nels = 1;
-#line 646
+	    nstarts = 1;
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 646
 		if ((k >> j) & 1) {
-#line 646
 		    start[j] = 0;
-#line 646
 		    edge[j] = mid[j];
-#line 646
 		}else{
-#line 646
 		    start[j] = mid[j];
-#line 646
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 646
 		}
-#line 646
-		nels *= edge[j];
-#line 646
-	    }
-#line 646
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 646
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 646
-		IF (err) 
-#line 646
-		    error("error in toMixedBase 1");
-#line 646
-		for (d = 0; d < var_rank[i]; d++) 
-#line 646
-		    index[d] += start[d];
-#line 646
-		value[j]= hash_short(var_type[i], var_rank[i], index, NCT_SHORT);
-#line 646
-		allInExtRange = allInExtRange 
-#line 646
-		    && inRange3(value[j], var_type[i], NCT_SHORT);
-#line 646
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 646
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 646
-		err = nc_put_vara_short(ncid, i, NULL, NULL, value);
-#line 646
-	    else
-#line 646
-		err = nc_put_vara_short(ncid, i, start, edge, value);
-#line 646
-	    if (canConvert) {
-#line 646
-		if (allInExtRange) {
-#line 646
-		    IF (err) 
-#line 646
-			error("%s", nc_strerror(err));
-#line 646
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_short(var_type[i], var_rank[i], index2, 
+			NCT_SHORT);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_SHORT);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_short(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_short(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 646
-		    IF (err != NC_ERANGE)
-#line 646
-			error("range error: status = %d", err);
-#line 646
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 646
-	    } else {
-#line 646
-		IF (nels > 0 && err != NC_ECHAR)
-#line 646
-		    error("wrong type: status = %d", err);
-#line 646
-            }
-#line 646
-        }
-#line 646
+	    }
+	}
     }
-#line 646
 
-#line 646
     err = nc_close(ncid);
-#line 646
     IF (err) 
-#line 646
 	error("nc_close: %s", nc_strerror(err));
-#line 646
 
-#line 646
     check_vars_short(scratch);
-#line 646
 
-#line 646
     err = remove(scratch);
-#line 646
     IF (err)
-#line 646
-        error("remove of %s failed", scratch);
-#line 646
+	error("remove of %s failed", scratch);
 }
-#line 646
 
 void
-#line 647
-test_nc_put_vara_int(void)
-#line 647
+test_nc_put_vars_int(void)
 {
-#line 647
     int ncid;
-#line 647
     int d;
-#line 647
     int i;
-#line 647
     int j;
-#line 647
     int k;
-#line 647
+    int m;
     int err;
-#line 647
-    int nslabs;
-#line 647
     int nels;
-#line 647
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 647
     size_t edge[MAX_RANK];
-#line 647
-    size_t mid[MAX_RANK];
-#line 647
     size_t index[MAX_RANK];
-#line 647
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 647
     int allInExtRange;	/* all values within external range? */
-#line 647
     int value[MAX_NELS];
-#line 647
 
-#line 647
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 647
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 647
-        error("nc_create: %s", nc_strerror(err));
-#line 647
-        return;
-#line 647
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 647
     def_dims(ncid);
-#line 647
     def_vars(ncid);
-#line 647
     err = nc_enddef(ncid);
-#line 647
     IF (err)
-#line 647
-        error("nc_enddef: %s", nc_strerror(err));
-#line 647
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 647
-    value[0] = 0;
-#line 647
-    for (i = 0; i < NVARS; i++) {
-#line 647
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 647
-        assert(var_rank[i] <= MAX_RANK);
-#line 647
-        assert(var_nels[i] <= MAX_NELS);
-#line 647
-        for (j = 0; j < var_rank[i]; j++) {
-#line 647
-            start[j] = 0;
-#line 647
-            edge[j] = 1;
-#line 647
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 647
-        err = nc_put_vara_int(BAD_ID, i, start, edge, value);
-#line 647
-        IF (err != NC_EBADID) 
-#line 647
+	err = nc_put_vars_int(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 647
-        err = nc_put_vara_int(ncid, BAD_VARID, start, edge, value);
-#line 647
-        IF (err != NC_ENOTVAR) 
-#line 647
+	err = nc_put_vars_int(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 647
-        for (j = 0; j < var_rank[i]; j++) {
-#line 647
+	for (j = 0; j < var_rank[i]; j++) {
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 647
-		start[j] = var_shape[i][j];
-#line 647
-		err = nc_put_vara_int(ncid, i, start, edge, value);
-#line 647
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 647
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 647
 		start[j] = 0;
-#line 647
 		edge[j] = var_shape[i][j] + 1;
-#line 647
-		err = nc_put_vara_int(ncid, i, start, edge, value);
-#line 647
-		IF (canConvert && err != NC_EEDGE)
-#line 647
+		err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
 		    error("bad edge: status = %d", err);
-#line 647
 		edge[j] = 1;
-#line 647
-	    }
-#line 647
-        }
-#line 647
-            /* Check correct error returned even when nothing to put */
-#line 647
-        for (j = 0; j < var_rank[i]; j++) {
-#line 647
-            edge[j] = 0;
-#line 647
-	}
-#line 647
-        err = nc_put_vara_int(BAD_ID, i, start, edge, value);
-#line 647
-        IF (err != NC_EBADID) 
-#line 647
-	    error("bad ncid: status = %d", err);
-#line 647
-        err = nc_put_vara_int(ncid, BAD_VARID, start, edge, value);
-#line 647
-        IF (err != NC_ENOTVAR) 
-#line 647
-	    error("bad var id: status = %d", err);
-#line 647
-        for (j = 0; j < var_rank[i]; j++) {
-#line 647
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 647
-		start[j] = var_shape[i][j];
-#line 647
-		err = nc_put_vara_int(ncid, i, start, edge, value);
-#line 647
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 647
-		    error("bad start: status = %d", err);
-#line 647
-		start[j] = 0;
-#line 647
+		stride[j] = 0;
+		err = nc_put_vars_int(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 647
-        }
-#line 647
-	err = nc_put_vara_int(ncid, i, start, edge, value);
-#line 647
-	if (canConvert) {
-#line 647
-	    IF (err) 
-#line 647
-		error("%s", nc_strerror(err));
-#line 647
-	} else {
-#line 647
-	    IF (err != NC_ECHAR)
-#line 647
-		error("wrong type: status = %d", err);
-#line 647
-        }
-#line 647
-        for (j = 0; j < var_rank[i]; j++) {
-#line 647
-            edge[j] = 1;
-#line 647
 	}
-#line 647
-
-#line 647
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 647
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 647
 	nslabs = 1;
-#line 647
 	for (j = 0; j < var_rank[i]; j++) {
-#line 647
-            mid[j] = roll( var_shape[i][j] );
-#line 647
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 647
 	}
-#line 647
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 647
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 647
-	    nels = 1;
-#line 647
+	    nstarts = 1;
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 647
 		if ((k >> j) & 1) {
-#line 647
 		    start[j] = 0;
-#line 647
 		    edge[j] = mid[j];
-#line 647
 		}else{
-#line 647
 		    start[j] = mid[j];
-#line 647
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 647
 		}
-#line 647
-		nels *= edge[j];
-#line 647
-	    }
-#line 647
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 647
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 647
-		IF (err) 
-#line 647
-		    error("error in toMixedBase 1");
-#line 647
-		for (d = 0; d < var_rank[i]; d++) 
-#line 647
-		    index[d] += start[d];
-#line 647
-		value[j]= hash_int(var_type[i], var_rank[i], index, NCT_INT);
-#line 647
-		allInExtRange = allInExtRange 
-#line 647
-		    && inRange3(value[j], var_type[i], NCT_INT);
-#line 647
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 647
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 647
-		err = nc_put_vara_int(ncid, i, NULL, NULL, value);
-#line 647
-	    else
-#line 647
-		err = nc_put_vara_int(ncid, i, start, edge, value);
-#line 647
-	    if (canConvert) {
-#line 647
-		if (allInExtRange) {
-#line 647
-		    IF (err) 
-#line 647
-			error("%s", nc_strerror(err));
-#line 647
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_int(var_type[i], var_rank[i], index2, 
+			NCT_INT);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_INT);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_int(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_int(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 647
-		    IF (err != NC_ERANGE)
-#line 647
-			error("range error: status = %d", err);
-#line 647
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 647
-	    } else {
-#line 647
-		IF (nels > 0 && err != NC_ECHAR)
-#line 647
-		    error("wrong type: status = %d", err);
-#line 647
-            }
-#line 647
-        }
-#line 647
+	    }
+	}
     }
-#line 647
 
-#line 647
     err = nc_close(ncid);
-#line 647
     IF (err) 
-#line 647
 	error("nc_close: %s", nc_strerror(err));
-#line 647
 
-#line 647
     check_vars_int(scratch);
-#line 647
 
-#line 647
     err = remove(scratch);
-#line 647
     IF (err)
-#line 647
-        error("remove of %s failed", scratch);
-#line 647
+	error("remove of %s failed", scratch);
 }
-#line 647
 
 void
-#line 648
-test_nc_put_vara_long(void)
-#line 648
+test_nc_put_vars_long(void)
 {
-#line 648
     int ncid;
-#line 648
     int d;
-#line 648
     int i;
-#line 648
     int j;
-#line 648
     int k;
-#line 648
+    int m;
     int err;
-#line 648
-    int nslabs;
-#line 648
     int nels;
-#line 648
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 648
     size_t edge[MAX_RANK];
-#line 648
-    size_t mid[MAX_RANK];
-#line 648
     size_t index[MAX_RANK];
-#line 648
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 648
     int allInExtRange;	/* all values within external range? */
-#line 648
     long value[MAX_NELS];
-#line 648
 
-#line 648
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 648
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 648
-        error("nc_create: %s", nc_strerror(err));
-#line 648
-        return;
-#line 648
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 648
     def_dims(ncid);
-#line 648
     def_vars(ncid);
-#line 648
     err = nc_enddef(ncid);
-#line 648
     IF (err)
-#line 648
-        error("nc_enddef: %s", nc_strerror(err));
-#line 648
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 648
-    value[0] = 0;
-#line 648
-    for (i = 0; i < NVARS; i++) {
-#line 648
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 648
-        assert(var_rank[i] <= MAX_RANK);
-#line 648
-        assert(var_nels[i] <= MAX_NELS);
-#line 648
-        for (j = 0; j < var_rank[i]; j++) {
-#line 648
-            start[j] = 0;
-#line 648
-            edge[j] = 1;
-#line 648
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 648
-        err = nc_put_vara_long(BAD_ID, i, start, edge, value);
-#line 648
-        IF (err != NC_EBADID) 
-#line 648
+	err = nc_put_vars_long(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 648
-        err = nc_put_vara_long(ncid, BAD_VARID, start, edge, value);
-#line 648
-        IF (err != NC_ENOTVAR) 
-#line 648
+	err = nc_put_vars_long(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 648
-        for (j = 0; j < var_rank[i]; j++) {
-#line 648
+	for (j = 0; j < var_rank[i]; j++) {
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 648
-		start[j] = var_shape[i][j];
-#line 648
-		err = nc_put_vara_long(ncid, i, start, edge, value);
-#line 648
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 648
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 648
 		start[j] = 0;
-#line 648
 		edge[j] = var_shape[i][j] + 1;
-#line 648
-		err = nc_put_vara_long(ncid, i, start, edge, value);
-#line 648
-		IF (canConvert && err != NC_EEDGE)
-#line 648
+		err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
 		    error("bad edge: status = %d", err);
-#line 648
 		edge[j] = 1;
-#line 648
-	    }
-#line 648
-        }
-#line 648
-            /* Check correct error returned even when nothing to put */
-#line 648
-        for (j = 0; j < var_rank[i]; j++) {
-#line 648
-            edge[j] = 0;
-#line 648
-	}
-#line 648
-        err = nc_put_vara_long(BAD_ID, i, start, edge, value);
-#line 648
-        IF (err != NC_EBADID) 
-#line 648
-	    error("bad ncid: status = %d", err);
-#line 648
-        err = nc_put_vara_long(ncid, BAD_VARID, start, edge, value);
-#line 648
-        IF (err != NC_ENOTVAR) 
-#line 648
-	    error("bad var id: status = %d", err);
-#line 648
-        for (j = 0; j < var_rank[i]; j++) {
-#line 648
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 648
-		start[j] = var_shape[i][j];
-#line 648
-		err = nc_put_vara_long(ncid, i, start, edge, value);
-#line 648
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 648
-		    error("bad start: status = %d", err);
-#line 648
-		start[j] = 0;
-#line 648
+		stride[j] = 0;
+		err = nc_put_vars_long(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 648
-        }
-#line 648
-	err = nc_put_vara_long(ncid, i, start, edge, value);
-#line 648
-	if (canConvert) {
-#line 648
-	    IF (err) 
-#line 648
-		error("%s", nc_strerror(err));
-#line 648
-	} else {
-#line 648
-	    IF (err != NC_ECHAR)
-#line 648
-		error("wrong type: status = %d", err);
-#line 648
-        }
-#line 648
-        for (j = 0; j < var_rank[i]; j++) {
-#line 648
-            edge[j] = 1;
-#line 648
 	}
-#line 648
-
-#line 648
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 648
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 648
 	nslabs = 1;
-#line 648
 	for (j = 0; j < var_rank[i]; j++) {
-#line 648
-            mid[j] = roll( var_shape[i][j] );
-#line 648
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 648
 	}
-#line 648
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 648
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 648
-	    nels = 1;
-#line 648
+	    nstarts = 1;
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 648
 		if ((k >> j) & 1) {
-#line 648
 		    start[j] = 0;
-#line 648
 		    edge[j] = mid[j];
-#line 648
 		}else{
-#line 648
 		    start[j] = mid[j];
-#line 648
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 648
 		}
-#line 648
-		nels *= edge[j];
-#line 648
-	    }
-#line 648
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 648
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 648
-		IF (err) 
-#line 648
-		    error("error in toMixedBase 1");
-#line 648
-		for (d = 0; d < var_rank[i]; d++) 
-#line 648
-		    index[d] += start[d];
-#line 648
-		value[j]= hash_long(var_type[i], var_rank[i], index, NCT_LONG);
-#line 648
-		allInExtRange = allInExtRange 
-#line 648
-		    && inRange3(value[j], var_type[i], NCT_LONG);
-#line 648
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 648
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 648
-		err = nc_put_vara_long(ncid, i, NULL, NULL, value);
-#line 648
-	    else
-#line 648
-		err = nc_put_vara_long(ncid, i, start, edge, value);
-#line 648
-	    if (canConvert) {
-#line 648
-		if (allInExtRange) {
-#line 648
-		    IF (err) 
-#line 648
-			error("%s", nc_strerror(err));
-#line 648
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_long(var_type[i], var_rank[i], index2, 
+			NCT_LONG);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_LONG);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_long(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_long(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 648
-		    IF (err != NC_ERANGE)
-#line 648
-			error("range error: status = %d", err);
-#line 648
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 648
-	    } else {
-#line 648
-		IF (nels > 0 && err != NC_ECHAR)
-#line 648
-		    error("wrong type: status = %d", err);
-#line 648
-            }
-#line 648
-        }
-#line 648
+	    }
+	}
     }
-#line 648
 
-#line 648
     err = nc_close(ncid);
-#line 648
     IF (err) 
-#line 648
 	error("nc_close: %s", nc_strerror(err));
-#line 648
 
-#line 648
     check_vars_long(scratch);
-#line 648
 
-#line 648
     err = remove(scratch);
-#line 648
     IF (err)
-#line 648
-        error("remove of %s failed", scratch);
-#line 648
+	error("remove of %s failed", scratch);
 }
-#line 648
 
 void
-#line 649
-test_nc_put_vara_float(void)
-#line 649
+test_nc_put_vars_float(void)
 {
-#line 649
     int ncid;
-#line 649
     int d;
-#line 649
     int i;
-#line 649
     int j;
-#line 649
     int k;
-#line 649
+    int m;
     int err;
-#line 649
-    int nslabs;
-#line 649
     int nels;
-#line 649
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 649
     size_t edge[MAX_RANK];
-#line 649
-    size_t mid[MAX_RANK];
-#line 649
     size_t index[MAX_RANK];
-#line 649
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 649
     int allInExtRange;	/* all values within external range? */
-#line 649
     float value[MAX_NELS];
-#line 649
 
-#line 649
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 649
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 649
-        error("nc_create: %s", nc_strerror(err));
-#line 649
-        return;
-#line 649
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 649
     def_dims(ncid);
-#line 649
     def_vars(ncid);
-#line 649
     err = nc_enddef(ncid);
-#line 649
     IF (err)
-#line 649
-        error("nc_enddef: %s", nc_strerror(err));
-#line 649
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 649
-    value[0] = 0;
-#line 649
-    for (i = 0; i < NVARS; i++) {
-#line 649
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 649
-        assert(var_rank[i] <= MAX_RANK);
-#line 649
-        assert(var_nels[i] <= MAX_NELS);
-#line 649
-        for (j = 0; j < var_rank[i]; j++) {
-#line 649
-            start[j] = 0;
-#line 649
-            edge[j] = 1;
-#line 649
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 649
-        err = nc_put_vara_float(BAD_ID, i, start, edge, value);
-#line 649
-        IF (err != NC_EBADID) 
-#line 649
+	err = nc_put_vars_float(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 649
-        err = nc_put_vara_float(ncid, BAD_VARID, start, edge, value);
-#line 649
-        IF (err != NC_ENOTVAR) 
-#line 649
+	err = nc_put_vars_float(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 649
-        for (j = 0; j < var_rank[i]; j++) {
-#line 649
+	for (j = 0; j < var_rank[i]; j++) {
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 649
-		start[j] = var_shape[i][j];
-#line 649
-		err = nc_put_vara_float(ncid, i, start, edge, value);
-#line 649
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 649
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 649
 		start[j] = 0;
-#line 649
 		edge[j] = var_shape[i][j] + 1;
-#line 649
-		err = nc_put_vara_float(ncid, i, start, edge, value);
-#line 649
-		IF (canConvert && err != NC_EEDGE)
-#line 649
+		err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
 		    error("bad edge: status = %d", err);
-#line 649
 		edge[j] = 1;
-#line 649
-	    }
-#line 649
-        }
-#line 649
-            /* Check correct error returned even when nothing to put */
-#line 649
-        for (j = 0; j < var_rank[i]; j++) {
-#line 649
-            edge[j] = 0;
-#line 649
-	}
-#line 649
-        err = nc_put_vara_float(BAD_ID, i, start, edge, value);
-#line 649
-        IF (err != NC_EBADID) 
-#line 649
-	    error("bad ncid: status = %d", err);
-#line 649
-        err = nc_put_vara_float(ncid, BAD_VARID, start, edge, value);
-#line 649
-        IF (err != NC_ENOTVAR) 
-#line 649
-	    error("bad var id: status = %d", err);
-#line 649
-        for (j = 0; j < var_rank[i]; j++) {
-#line 649
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 649
-		start[j] = var_shape[i][j];
-#line 649
-		err = nc_put_vara_float(ncid, i, start, edge, value);
-#line 649
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 649
-		    error("bad start: status = %d", err);
-#line 649
-		start[j] = 0;
-#line 649
+		stride[j] = 0;
+		err = nc_put_vars_float(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 649
-        }
-#line 649
-	err = nc_put_vara_float(ncid, i, start, edge, value);
-#line 649
-	if (canConvert) {
-#line 649
-	    IF (err) 
-#line 649
-		error("%s", nc_strerror(err));
-#line 649
-	} else {
-#line 649
-	    IF (err != NC_ECHAR)
-#line 649
-		error("wrong type: status = %d", err);
-#line 649
-        }
-#line 649
-        for (j = 0; j < var_rank[i]; j++) {
-#line 649
-            edge[j] = 1;
-#line 649
 	}
-#line 649
-
-#line 649
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 649
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 649
 	nslabs = 1;
-#line 649
 	for (j = 0; j < var_rank[i]; j++) {
-#line 649
-            mid[j] = roll( var_shape[i][j] );
-#line 649
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 649
 	}
-#line 649
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 649
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 649
-	    nels = 1;
-#line 649
-	    for (j = 0; j < var_rank[i]; j++) {
-#line 649
-		if ((k >> j) & 1) {
-#line 649
-		    start[j] = 0;
-#line 649
-		    edge[j] = mid[j];
-#line 649
-		}else{
-#line 649
-		    start[j] = mid[j];
-#line 649
-		    edge[j] = var_shape[i][j] - mid[j];
-#line 649
-		}
-#line 649
-		nels *= edge[j];
-#line 649
-	    }
-#line 649
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 649
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 649
-		IF (err) 
-#line 649
-		    error("error in toMixedBase 1");
-#line 649
-		for (d = 0; d < var_rank[i]; d++) 
-#line 649
-		    index[d] += start[d];
-#line 649
-		value[j]= hash_float(var_type[i], var_rank[i], index, NCT_FLOAT);
-#line 649
-		allInExtRange = allInExtRange 
-#line 649
-		    && inRange3(value[j], var_type[i], NCT_FLOAT);
-#line 649
+	    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] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 649
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 649
-		err = nc_put_vara_float(ncid, i, NULL, NULL, value);
-#line 649
-	    else
-#line 649
-		err = nc_put_vara_float(ncid, i, start, edge, value);
-#line 649
-	    if (canConvert) {
-#line 649
-		if (allInExtRange) {
-#line 649
-		    IF (err) 
-#line 649
-			error("%s", nc_strerror(err));
-#line 649
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_float(var_type[i], var_rank[i], index2, 
+			NCT_FLOAT);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_FLOAT);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_float(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_float(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 649
-		    IF (err != NC_ERANGE)
-#line 649
-			error("range error: status = %d", err);
-#line 649
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 649
-	    } else {
-#line 649
-		IF (nels > 0 && err != NC_ECHAR)
-#line 649
-		    error("wrong type: status = %d", err);
-#line 649
-            }
-#line 649
-        }
-#line 649
+	    }
+	}
     }
-#line 649
 
-#line 649
     err = nc_close(ncid);
-#line 649
     IF (err) 
-#line 649
 	error("nc_close: %s", nc_strerror(err));
-#line 649
 
-#line 649
     check_vars_float(scratch);
-#line 649
 
-#line 649
     err = remove(scratch);
-#line 649
     IF (err)
-#line 649
-        error("remove of %s failed", scratch);
-#line 649
+	error("remove of %s failed", scratch);
 }
-#line 649
 
 void
-#line 650
-test_nc_put_vara_double(void)
-#line 650
+test_nc_put_vars_double(void)
 {
-#line 650
     int ncid;
-#line 650
     int d;
-#line 650
     int i;
-#line 650
     int j;
-#line 650
     int k;
-#line 650
+    int m;
     int err;
-#line 650
-    int nslabs;
-#line 650
     int nels;
-#line 650
+    int nslabs;
+    int nstarts;        /* number of different starts */
     size_t start[MAX_RANK];
-#line 650
     size_t edge[MAX_RANK];
-#line 650
-    size_t mid[MAX_RANK];
-#line 650
     size_t index[MAX_RANK];
-#line 650
+    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];
     int canConvert;	/* Both text or both numeric */
-#line 650
     int allInExtRange;	/* all values within external range? */
-#line 650
     double value[MAX_NELS];
-#line 650
 
-#line 650
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 650
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 650
-        error("nc_create: %s", nc_strerror(err));
-#line 650
-        return;
-#line 650
+	error("nc_create: %s", nc_strerror(err));
+	return;
     }
-#line 650
     def_dims(ncid);
-#line 650
     def_vars(ncid);
-#line 650
     err = nc_enddef(ncid);
-#line 650
     IF (err)
-#line 650
-        error("nc_enddef: %s", nc_strerror(err));
-#line 650
+	error("nc_enddef: %s", nc_strerror(err));
 
-#line 650
-    value[0] = 0;
-#line 650
-    for (i = 0; i < NVARS; i++) {
-#line 650
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 650
-        assert(var_rank[i] <= MAX_RANK);
-#line 650
-        assert(var_nels[i] <= MAX_NELS);
-#line 650
-        for (j = 0; j < var_rank[i]; j++) {
-#line 650
-            start[j] = 0;
-#line 650
-            edge[j] = 1;
-#line 650
+	assert(var_rank[i] <= MAX_RANK);
+	assert(var_nels[i] <= MAX_NELS);
+	for (j = 0; j < var_rank[i]; j++) {
+	    start[j] = 0;
+	    edge[j] = 1;
+	    stride[j] = 1;
 	}
-#line 650
-        err = nc_put_vara_double(BAD_ID, i, start, edge, value);
-#line 650
-        IF (err != NC_EBADID) 
-#line 650
+	err = nc_put_vars_double(BAD_ID, i, start, edge, stride, value);
+	IF (err != NC_EBADID) 
 	    error("bad ncid: status = %d", err);
-#line 650
-        err = nc_put_vara_double(ncid, BAD_VARID, start, edge, value);
-#line 650
-        IF (err != NC_ENOTVAR) 
-#line 650
+	err = nc_put_vars_double(ncid, BAD_VARID, start, edge, stride, value);
+	IF (err != NC_ENOTVAR) 
 	    error("bad var id: status = %d", err);
-#line 650
-        for (j = 0; j < var_rank[i]; j++) {
-#line 650
+	for (j = 0; j < var_rank[i]; j++) {
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 650
-		start[j] = var_shape[i][j];
-#line 650
-		err = nc_put_vara_double(ncid, i, start, edge, value);
-#line 650
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 650
+		start[j] = var_shape[i][j] + 1;
+		err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+	      if(!canConvert) {
+		IF(err != NC_ECHAR)
+			error("conversion: status = %d", err);
+	      } else {
+		IF(err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 650
 		start[j] = 0;
-#line 650
 		edge[j] = var_shape[i][j] + 1;
-#line 650
-		err = nc_put_vara_double(ncid, i, start, edge, value);
-#line 650
-		IF (canConvert && err != NC_EEDGE)
-#line 650
+		err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+		IF (err != NC_EEDGE)
 		    error("bad edge: status = %d", err);
-#line 650
 		edge[j] = 1;
-#line 650
-	    }
-#line 650
-        }
-#line 650
-            /* Check correct error returned even when nothing to put */
-#line 650
-        for (j = 0; j < var_rank[i]; j++) {
-#line 650
-            edge[j] = 0;
-#line 650
-	}
-#line 650
-        err = nc_put_vara_double(BAD_ID, i, start, edge, value);
-#line 650
-        IF (err != NC_EBADID) 
-#line 650
-	    error("bad ncid: status = %d", err);
-#line 650
-        err = nc_put_vara_double(ncid, BAD_VARID, start, edge, value);
-#line 650
-        IF (err != NC_ENOTVAR) 
-#line 650
-	    error("bad var id: status = %d", err);
-#line 650
-        for (j = 0; j < var_rank[i]; j++) {
-#line 650
-	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 650
-		start[j] = var_shape[i][j];
-#line 650
-		err = nc_put_vara_double(ncid, i, start, edge, value);
-#line 650
-		IF (canConvert && err != NC_EINVALCOORDS)
-#line 650
-		    error("bad start: status = %d", err);
-#line 650
-		start[j] = 0;
-#line 650
+		stride[j] = 0;
+		err = nc_put_vars_double(ncid, i, start, edge, stride, value);
+		IF (err != NC_ESTRIDE)
+		    error("bad stride: status = %d", err);
+		stride[j] = 1;
+              }
 	    }
-#line 650
-        }
-#line 650
-	err = nc_put_vara_double(ncid, i, start, edge, value);
-#line 650
-	if (canConvert) {
-#line 650
-	    IF (err) 
-#line 650
-		error("%s", nc_strerror(err));
-#line 650
-	} else {
-#line 650
-	    IF (err != NC_ECHAR)
-#line 650
-		error("wrong type: status = %d", err);
-#line 650
-        }
-#line 650
-        for (j = 0; j < var_rank[i]; j++) {
-#line 650
-            edge[j] = 1;
-#line 650
 	}
-#line 650
-
-#line 650
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 650
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 650
 	nslabs = 1;
-#line 650
 	for (j = 0; j < var_rank[i]; j++) {
-#line 650
-            mid[j] = roll( var_shape[i][j] );
-#line 650
+	    mid[j] = roll( var_shape[i][j] );
 	    nslabs *= 2;
-#line 650
 	}
-#line 650
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 650
+	    /* choose random stride from 1 to edge */
 	for (k = 0; k < nslabs; k++) {
-#line 650
-	    nels = 1;
-#line 650
+	    nstarts = 1;
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 650
 		if ((k >> j) & 1) {
-#line 650
 		    start[j] = 0;
-#line 650
 		    edge[j] = mid[j];
-#line 650
 		}else{
-#line 650
 		    start[j] = mid[j];
-#line 650
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 650
 		}
-#line 650
-		nels *= edge[j];
-#line 650
-	    }
-#line 650
-            for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 650
-		err = toMixedBase(j, var_rank[i], edge, index);
-#line 650
-		IF (err) 
-#line 650
-		    error("error in toMixedBase 1");
-#line 650
-		for (d = 0; d < var_rank[i]; d++) 
-#line 650
-		    index[d] += start[d];
-#line 650
-		value[j]= hash_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
-#line 650
-		allInExtRange = allInExtRange 
-#line 650
-		    && inRange3(value[j], var_type[i], NCT_DOUBLE);
-#line 650
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
 	    }
-#line 650
-	    if (var_rank[i] == 0 && i%2 == 0)
-#line 650
-		err = nc_put_vara_double(ncid, i, NULL, NULL, value);
-#line 650
-	    else
-#line 650
-		err = nc_put_vara_double(ncid, i, start, edge, value);
-#line 650
-	    if (canConvert) {
-#line 650
-		if (allInExtRange) {
-#line 650
-		    IF (err) 
-#line 650
-			error("%s", nc_strerror(err));
-#line 650
+	    for (m = 0; m < nstarts; m++) {
+		err = toMixedBase(m, var_rank[i], sstride, index);
+		IF (err)
+		    error("error in toMixedBase");
+		nels = 1;
+		for (j = 0; j < var_rank[i]; j++) {
+		    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+			stride[j] = -stride[j];
+		    }
+		}
+*/
+		for (allInExtRange = 1, j = 0; j < nels; j++) {
+		    err = toMixedBase(j, var_rank[i], count, index2);
+		    IF (err)
+			error("error in toMixedBase");
+		    for (d = 0; d < var_rank[i]; d++)
+			index2[d] = index[d] + index2[d] * stride[d];
+		    value[j] = hash_double(var_type[i], var_rank[i], index2, 
+			NCT_DOUBLE);
+		    allInExtRange = allInExtRange 
+			&& inRange3(value[j], var_type[i], NCT_DOUBLE);
+		}
+		if (var_rank[i] == 0 && i%2 == 0)
+		    err = nc_put_vars_double(ncid, i, NULL, NULL, stride, value);
+		else
+		    err = nc_put_vars_double(ncid, i, index, count, stride, value);
+		if (canConvert) {
+		    if (allInExtRange) {
+			IF (err) 
+			    error("%s", nc_strerror(err));
+		    } else {
+			IF (err != NC_ERANGE)
+			    error("range error: status = %d", err);
+		    }
 		} else {
-#line 650
-		    IF (err != NC_ERANGE)
-#line 650
-			error("range error: status = %d", err);
-#line 650
+		    IF (nels > 0 && err != NC_ECHAR)
+			error("wrong type: status = %d", err);
 		}
-#line 650
-	    } else {
-#line 650
-		IF (nels > 0 && err != NC_ECHAR)
-#line 650
-		    error("wrong type: status = %d", err);
-#line 650
-            }
-#line 650
-        }
-#line 650
+	    }
+	}
     }
-#line 650
 
-#line 650
     err = nc_close(ncid);
-#line 650
     IF (err) 
-#line 650
 	error("nc_close: %s", nc_strerror(err));
-#line 650
 
-#line 650
     check_vars_double(scratch);
-#line 650
 
-#line 650
     err = remove(scratch);
-#line 650
     IF (err)
-#line 650
-        error("remove of %s failed", scratch);
-#line 650
+	error("remove of %s failed", scratch);
 }
-#line 650
-
-
-
-#line 815
 
 void
-#line 816
-test_nc_put_vars_text(void)
-#line 816
+test_nc_put_vars_ushort(void)
 {
-#line 816
     int ncid;
-#line 816
     int d;
-#line 816
     int i;
-#line 816
     int j;
-#line 816
     int k;
-#line 816
     int m;
-#line 816
     int err;
-#line 816
     int nels;
-#line 816
     int nslabs;
-#line 816
     int nstarts;        /* number of different starts */
-#line 816
     size_t start[MAX_RANK];
-#line 816
     size_t edge[MAX_RANK];
-#line 816
     size_t index[MAX_RANK];
-#line 816
     size_t index2[MAX_RANK];
-#line 816
     size_t mid[MAX_RANK];
-#line 816
     size_t count[MAX_RANK];
-#line 816
     size_t sstride[MAX_RANK];
-#line 816
     ptrdiff_t stride[MAX_RANK];
-#line 816
     int canConvert;	/* Both text or both numeric */
-#line 816
     int allInExtRange;	/* all values within external range? */
-#line 816
-    text value[MAX_NELS];
-#line 816
+    ushort value[MAX_NELS];
 
-#line 816
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 816
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 816
 	error("nc_create: %s", nc_strerror(err));
-#line 816
 	return;
-#line 816
     }
-#line 816
     def_dims(ncid);
-#line 816
     def_vars(ncid);
-#line 816
     err = nc_enddef(ncid);
-#line 816
     IF (err)
-#line 816
 	error("nc_enddef: %s", nc_strerror(err));
-#line 816
 
-#line 816
-    for (i = 0; i < NVARS; i++) {
-#line 816
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 816
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 816
 	assert(var_nels[i] <= MAX_NELS);
-#line 816
 	for (j = 0; j < var_rank[i]; j++) {
-#line 816
 	    start[j] = 0;
-#line 816
 	    edge[j] = 1;
-#line 816
 	    stride[j] = 1;
-#line 816
 	}
-#line 816
-	err = nc_put_vars_text(BAD_ID, i, start, edge, stride, value);
-#line 816
+	err = nc_put_vars_ushort(BAD_ID, i, start, edge, stride, value);
 	IF (err != NC_EBADID) 
-#line 816
 	    error("bad ncid: status = %d", err);
-#line 816
-	err = nc_put_vars_text(ncid, BAD_VARID, start, edge, stride, value);
-#line 816
+	err = nc_put_vars_ushort(ncid, BAD_VARID, start, edge, stride, value);
 	IF (err != NC_ENOTVAR) 
-#line 816
 	    error("bad var id: status = %d", err);
-#line 816
 	for (j = 0; j < var_rank[i]; j++) {
-#line 816
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 816
 		start[j] = var_shape[i][j] + 1;
-#line 816
-		err = nc_put_vars_text(ncid, i, start, edge, stride, value);
-#line 816
+		err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
 	      if(!canConvert) {
-#line 816
 		IF(err != NC_ECHAR)
-#line 816
 			error("conversion: status = %d", err);
-#line 816
 	      } else {
-#line 816
 		IF(err != NC_EINVALCOORDS)
-#line 816
 		    error("bad start: status = %d", err);
-#line 816
 		start[j] = 0;
-#line 816
 		edge[j] = var_shape[i][j] + 1;
-#line 816
-		err = nc_put_vars_text(ncid, i, start, edge, stride, value);
-#line 816
+		err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
 		IF (err != NC_EEDGE)
-#line 816
 		    error("bad edge: status = %d", err);
-#line 816
 		edge[j] = 1;
-#line 816
 		stride[j] = 0;
-#line 816
-		err = nc_put_vars_text(ncid, i, start, edge, stride, value);
-#line 816
+		err = nc_put_vars_ushort(ncid, i, start, edge, stride, value);
 		IF (err != NC_ESTRIDE)
-#line 816
 		    error("bad stride: status = %d", err);
-#line 816
 		stride[j] = 1;
-#line 816
               }
-#line 816
 	    }
-#line 816
 	}
-#line 816
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 816
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 816
 	nslabs = 1;
-#line 816
 	for (j = 0; j < var_rank[i]; j++) {
-#line 816
 	    mid[j] = roll( var_shape[i][j] );
-#line 816
 	    nslabs *= 2;
-#line 816
 	}
-#line 816
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 816
 	    /* choose random stride from 1 to edge */
-#line 816
 	for (k = 0; k < nslabs; k++) {
-#line 816
 	    nstarts = 1;
-#line 816
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 816
 		if ((k >> j) & 1) {
-#line 816
 		    start[j] = 0;
-#line 816
 		    edge[j] = mid[j];
-#line 816
 		}else{
-#line 816
 		    start[j] = mid[j];
-#line 816
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 816
 		}
-#line 816
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 816
 		nstarts *= stride[j];
-#line 816
 	    }
-#line 816
 	    for (m = 0; m < nstarts; m++) {
-#line 816
 		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 816
 		IF (err)
-#line 816
 		    error("error in toMixedBase");
-#line 816
 		nels = 1;
-#line 816
 		for (j = 0; j < var_rank[i]; j++) {
-#line 816
 		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 816
 		    nels *= count[j];
-#line 816
 		    index[j] += start[j];
-#line 816
 		}
-#line 816
 		    /* Random choice of forward or backward */
-#line 816
 /* TODO
-#line 816
 		if ( roll(2) ) {
-#line 816
 		    for (j = 0; j < var_rank[i]; j++) {
-#line 816
 			index[j] += (count[j] - 1) * stride[j];
-#line 816
 			stride[j] = -stride[j];
-#line 816
 		    }
-#line 816
 		}
-#line 816
 */
-#line 816
 		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 816
 		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 816
 		    IF (err)
-#line 816
 			error("error in toMixedBase");
-#line 816
 		    for (d = 0; d < var_rank[i]; d++)
-#line 816
 			index2[d] = index[d] + index2[d] * stride[d];
-#line 816
-		    value[j] = hash_text(var_type[i], var_rank[i], index2, 
-#line 816
-			NCT_TEXT);
-#line 816
+		    value[j] = hash_ushort(var_type[i], var_rank[i], index2, 
+			NCT_USHORT);
 		    allInExtRange = allInExtRange 
-#line 816
-			&& inRange3(value[j], var_type[i], NCT_TEXT);
-#line 816
+			&& inRange3(value[j], var_type[i], NCT_USHORT);
 		}
-#line 816
 		if (var_rank[i] == 0 && i%2 == 0)
-#line 816
-		    err = nc_put_vars_text(ncid, i, NULL, NULL, stride, value);
-#line 816
+		    err = nc_put_vars_ushort(ncid, i, NULL, NULL, stride, value);
 		else
-#line 816
-		    err = nc_put_vars_text(ncid, i, index, count, stride, value);
-#line 816
+		    err = nc_put_vars_ushort(ncid, i, index, count, stride, value);
 		if (canConvert) {
-#line 816
 		    if (allInExtRange) {
-#line 816
 			IF (err) 
-#line 816
 			    error("%s", nc_strerror(err));
-#line 816
 		    } else {
-#line 816
 			IF (err != NC_ERANGE)
-#line 816
 			    error("range error: status = %d", err);
-#line 816
 		    }
-#line 816
 		} else {
-#line 816
 		    IF (nels > 0 && err != NC_ECHAR)
-#line 816
 			error("wrong type: status = %d", err);
-#line 816
 		}
-#line 816
 	    }
-#line 816
 	}
-#line 816
     }
-#line 816
 
-#line 816
     err = nc_close(ncid);
-#line 816
     IF (err) 
-#line 816
 	error("nc_close: %s", nc_strerror(err));
-#line 816
 
-#line 816
-    check_vars_text(scratch);
-#line 816
+    check_vars_ushort(scratch);
 
-#line 816
     err = remove(scratch);
-#line 816
     IF (err)
-#line 816
 	error("remove of %s failed", scratch);
-#line 816
 }
-#line 816
 
 void
-#line 817
-test_nc_put_vars_uchar(void)
-#line 817
+test_nc_put_vars_uint(void)
 {
-#line 817
     int ncid;
-#line 817
     int d;
-#line 817
     int i;
-#line 817
     int j;
-#line 817
     int k;
-#line 817
     int m;
-#line 817
     int err;
-#line 817
     int nels;
-#line 817
     int nslabs;
-#line 817
     int nstarts;        /* number of different starts */
-#line 817
     size_t start[MAX_RANK];
-#line 817
     size_t edge[MAX_RANK];
-#line 817
     size_t index[MAX_RANK];
-#line 817
     size_t index2[MAX_RANK];
-#line 817
     size_t mid[MAX_RANK];
-#line 817
     size_t count[MAX_RANK];
-#line 817
     size_t sstride[MAX_RANK];
-#line 817
     ptrdiff_t stride[MAX_RANK];
-#line 817
     int canConvert;	/* Both text or both numeric */
-#line 817
     int allInExtRange;	/* all values within external range? */
-#line 817
-    uchar value[MAX_NELS];
-#line 817
+    uint value[MAX_NELS];
 
-#line 817
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 817
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 817
 	error("nc_create: %s", nc_strerror(err));
-#line 817
 	return;
-#line 817
     }
-#line 817
     def_dims(ncid);
-#line 817
     def_vars(ncid);
-#line 817
     err = nc_enddef(ncid);
-#line 817
     IF (err)
-#line 817
 	error("nc_enddef: %s", nc_strerror(err));
-#line 817
 
-#line 817
-    for (i = 0; i < NVARS; i++) {
-#line 817
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 817
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 817
 	assert(var_nels[i] <= MAX_NELS);
-#line 817
 	for (j = 0; j < var_rank[i]; j++) {
-#line 817
 	    start[j] = 0;
-#line 817
 	    edge[j] = 1;
-#line 817
 	    stride[j] = 1;
-#line 817
 	}
-#line 817
-	err = nc_put_vars_uchar(BAD_ID, i, start, edge, stride, value);
-#line 817
+	err = nc_put_vars_uint(BAD_ID, i, start, edge, stride, value);
 	IF (err != NC_EBADID) 
-#line 817
 	    error("bad ncid: status = %d", err);
-#line 817
-	err = nc_put_vars_uchar(ncid, BAD_VARID, start, edge, stride, value);
-#line 817
+	err = nc_put_vars_uint(ncid, BAD_VARID, start, edge, stride, value);
 	IF (err != NC_ENOTVAR) 
-#line 817
 	    error("bad var id: status = %d", err);
-#line 817
 	for (j = 0; j < var_rank[i]; j++) {
-#line 817
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 817
 		start[j] = var_shape[i][j] + 1;
-#line 817
-		err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
-#line 817
+		err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
 	      if(!canConvert) {
-#line 817
 		IF(err != NC_ECHAR)
-#line 817
 			error("conversion: status = %d", err);
-#line 817
 	      } else {
-#line 817
 		IF(err != NC_EINVALCOORDS)
-#line 817
 		    error("bad start: status = %d", err);
-#line 817
 		start[j] = 0;
-#line 817
 		edge[j] = var_shape[i][j] + 1;
-#line 817
-		err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
-#line 817
+		err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
 		IF (err != NC_EEDGE)
-#line 817
 		    error("bad edge: status = %d", err);
-#line 817
 		edge[j] = 1;
-#line 817
 		stride[j] = 0;
-#line 817
-		err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
-#line 817
+		err = nc_put_vars_uint(ncid, i, start, edge, stride, value);
 		IF (err != NC_ESTRIDE)
-#line 817
 		    error("bad stride: status = %d", err);
-#line 817
 		stride[j] = 1;
-#line 817
               }
-#line 817
 	    }
-#line 817
 	}
-#line 817
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 817
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 817
 	nslabs = 1;
-#line 817
 	for (j = 0; j < var_rank[i]; j++) {
-#line 817
 	    mid[j] = roll( var_shape[i][j] );
-#line 817
 	    nslabs *= 2;
-#line 817
 	}
-#line 817
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 817
 	    /* choose random stride from 1 to edge */
-#line 817
 	for (k = 0; k < nslabs; k++) {
-#line 817
 	    nstarts = 1;
-#line 817
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 817
 		if ((k >> j) & 1) {
-#line 817
 		    start[j] = 0;
-#line 817
 		    edge[j] = mid[j];
-#line 817
 		}else{
-#line 817
 		    start[j] = mid[j];
-#line 817
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 817
 		}
-#line 817
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 817
 		nstarts *= stride[j];
-#line 817
 	    }
-#line 817
 	    for (m = 0; m < nstarts; m++) {
-#line 817
 		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 817
 		IF (err)
-#line 817
 		    error("error in toMixedBase");
-#line 817
 		nels = 1;
-#line 817
 		for (j = 0; j < var_rank[i]; j++) {
-#line 817
 		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 817
 		    nels *= count[j];
-#line 817
 		    index[j] += start[j];
-#line 817
 		}
-#line 817
 		    /* Random choice of forward or backward */
-#line 817
 /* TODO
-#line 817
 		if ( roll(2) ) {
-#line 817
 		    for (j = 0; j < var_rank[i]; j++) {
-#line 817
 			index[j] += (count[j] - 1) * stride[j];
-#line 817
 			stride[j] = -stride[j];
-#line 817
 		    }
-#line 817
 		}
-#line 817
 */
-#line 817
 		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 817
 		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 817
 		    IF (err)
-#line 817
 			error("error in toMixedBase");
-#line 817
 		    for (d = 0; d < var_rank[i]; d++)
-#line 817
 			index2[d] = index[d] + index2[d] * stride[d];
-#line 817
-		    value[j] = hash_uchar(var_type[i], var_rank[i], index2, 
-#line 817
-			NCT_UCHAR);
-#line 817
+		    value[j] = hash_uint(var_type[i], var_rank[i], index2, 
+			NCT_UINT);
 		    allInExtRange = allInExtRange 
-#line 817
-			&& inRange3(value[j], var_type[i], NCT_UCHAR);
-#line 817
+			&& inRange3(value[j], var_type[i], NCT_UINT);
 		}
-#line 817
 		if (var_rank[i] == 0 && i%2 == 0)
-#line 817
-		    err = nc_put_vars_uchar(ncid, i, NULL, NULL, stride, value);
-#line 817
+		    err = nc_put_vars_uint(ncid, i, NULL, NULL, stride, value);
 		else
-#line 817
-		    err = nc_put_vars_uchar(ncid, i, index, count, stride, value);
-#line 817
+		    err = nc_put_vars_uint(ncid, i, index, count, stride, value);
 		if (canConvert) {
-#line 817
 		    if (allInExtRange) {
-#line 817
 			IF (err) 
-#line 817
 			    error("%s", nc_strerror(err));
-#line 817
 		    } else {
-#line 817
 			IF (err != NC_ERANGE)
-#line 817
 			    error("range error: status = %d", err);
-#line 817
 		    }
-#line 817
 		} else {
-#line 817
 		    IF (nels > 0 && err != NC_ECHAR)
-#line 817
 			error("wrong type: status = %d", err);
-#line 817
 		}
-#line 817
 	    }
-#line 817
 	}
-#line 817
     }
-#line 817
 
-#line 817
     err = nc_close(ncid);
-#line 817
     IF (err) 
-#line 817
 	error("nc_close: %s", nc_strerror(err));
-#line 817
 
-#line 817
-    check_vars_uchar(scratch);
-#line 817
+    check_vars_uint(scratch);
 
-#line 817
     err = remove(scratch);
-#line 817
     IF (err)
-#line 817
 	error("remove of %s failed", scratch);
-#line 817
 }
-#line 817
 
 void
-#line 818
-test_nc_put_vars_schar(void)
-#line 818
+test_nc_put_vars_longlong(void)
 {
-#line 818
     int ncid;
-#line 818
     int d;
-#line 818
     int i;
-#line 818
     int j;
-#line 818
     int k;
-#line 818
     int m;
-#line 818
     int err;
-#line 818
     int nels;
-#line 818
     int nslabs;
-#line 818
     int nstarts;        /* number of different starts */
-#line 818
     size_t start[MAX_RANK];
-#line 818
     size_t edge[MAX_RANK];
-#line 818
     size_t index[MAX_RANK];
-#line 818
     size_t index2[MAX_RANK];
-#line 818
     size_t mid[MAX_RANK];
-#line 818
     size_t count[MAX_RANK];
-#line 818
     size_t sstride[MAX_RANK];
-#line 818
     ptrdiff_t stride[MAX_RANK];
-#line 818
     int canConvert;	/* Both text or both numeric */
-#line 818
     int allInExtRange;	/* all values within external range? */
-#line 818
-    schar value[MAX_NELS];
-#line 818
+    longlong value[MAX_NELS];
 
-#line 818
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 818
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 818
 	error("nc_create: %s", nc_strerror(err));
-#line 818
 	return;
-#line 818
     }
-#line 818
     def_dims(ncid);
-#line 818
     def_vars(ncid);
-#line 818
     err = nc_enddef(ncid);
-#line 818
     IF (err)
-#line 818
 	error("nc_enddef: %s", nc_strerror(err));
-#line 818
 
-#line 818
-    for (i = 0; i < NVARS; i++) {
-#line 818
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 818
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 818
 	assert(var_nels[i] <= MAX_NELS);
-#line 818
 	for (j = 0; j < var_rank[i]; j++) {
-#line 818
 	    start[j] = 0;
-#line 818
 	    edge[j] = 1;
-#line 818
 	    stride[j] = 1;
-#line 818
 	}
-#line 818
-	err = nc_put_vars_schar(BAD_ID, i, start, edge, stride, value);
-#line 818
+	err = nc_put_vars_longlong(BAD_ID, i, start, edge, stride, value);
 	IF (err != NC_EBADID) 
-#line 818
 	    error("bad ncid: status = %d", err);
-#line 818
-	err = nc_put_vars_schar(ncid, BAD_VARID, start, edge, stride, value);
-#line 818
+	err = nc_put_vars_longlong(ncid, BAD_VARID, start, edge, stride, value);
 	IF (err != NC_ENOTVAR) 
-#line 818
 	    error("bad var id: status = %d", err);
-#line 818
 	for (j = 0; j < var_rank[i]; j++) {
-#line 818
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 818
 		start[j] = var_shape[i][j] + 1;
-#line 818
-		err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
-#line 818
+		err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
 	      if(!canConvert) {
-#line 818
 		IF(err != NC_ECHAR)
-#line 818
 			error("conversion: status = %d", err);
-#line 818
 	      } else {
-#line 818
 		IF(err != NC_EINVALCOORDS)
-#line 818
 		    error("bad start: status = %d", err);
-#line 818
 		start[j] = 0;
-#line 818
 		edge[j] = var_shape[i][j] + 1;
-#line 818
-		err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
-#line 818
+		err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
 		IF (err != NC_EEDGE)
-#line 818
 		    error("bad edge: status = %d", err);
-#line 818
 		edge[j] = 1;
-#line 818
 		stride[j] = 0;
-#line 818
-		err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
-#line 818
+		err = nc_put_vars_longlong(ncid, i, start, edge, stride, value);
 		IF (err != NC_ESTRIDE)
-#line 818
 		    error("bad stride: status = %d", err);
-#line 818
 		stride[j] = 1;
-#line 818
               }
-#line 818
 	    }
-#line 818
 	}
-#line 818
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 818
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 818
 	nslabs = 1;
-#line 818
 	for (j = 0; j < var_rank[i]; j++) {
-#line 818
 	    mid[j] = roll( var_shape[i][j] );
-#line 818
 	    nslabs *= 2;
-#line 818
 	}
-#line 818
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 818
 	    /* choose random stride from 1 to edge */
-#line 818
 	for (k = 0; k < nslabs; k++) {
-#line 818
 	    nstarts = 1;
-#line 818
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 818
 		if ((k >> j) & 1) {
-#line 818
 		    start[j] = 0;
-#line 818
 		    edge[j] = mid[j];
-#line 818
 		}else{
-#line 818
 		    start[j] = mid[j];
-#line 818
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 818
 		}
-#line 818
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 818
 		nstarts *= stride[j];
-#line 818
 	    }
-#line 818
 	    for (m = 0; m < nstarts; m++) {
-#line 818
 		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 818
 		IF (err)
-#line 818
 		    error("error in toMixedBase");
-#line 818
 		nels = 1;
-#line 818
 		for (j = 0; j < var_rank[i]; j++) {
-#line 818
 		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 818
 		    nels *= count[j];
-#line 818
 		    index[j] += start[j];
-#line 818
 		}
-#line 818
 		    /* Random choice of forward or backward */
-#line 818
 /* TODO
-#line 818
 		if ( roll(2) ) {
-#line 818
 		    for (j = 0; j < var_rank[i]; j++) {
-#line 818
 			index[j] += (count[j] - 1) * stride[j];
-#line 818
 			stride[j] = -stride[j];
-#line 818
 		    }
-#line 818
 		}
-#line 818
 */
-#line 818
 		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 818
 		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 818
 		    IF (err)
-#line 818
 			error("error in toMixedBase");
-#line 818
 		    for (d = 0; d < var_rank[i]; d++)
-#line 818
 			index2[d] = index[d] + index2[d] * stride[d];
-#line 818
-		    value[j] = hash_schar(var_type[i], var_rank[i], index2, 
-#line 818
-			NCT_SCHAR);
-#line 818
+		    value[j] = hash_longlong(var_type[i], var_rank[i], index2, 
+			NCT_LONGLONG);
 		    allInExtRange = allInExtRange 
-#line 818
-			&& inRange3(value[j], var_type[i], NCT_SCHAR);
-#line 818
+			&& inRange3(value[j], var_type[i], NCT_LONGLONG);
 		}
-#line 818
 		if (var_rank[i] == 0 && i%2 == 0)
-#line 818
-		    err = nc_put_vars_schar(ncid, i, NULL, NULL, stride, value);
-#line 818
+		    err = nc_put_vars_longlong(ncid, i, NULL, NULL, stride, value);
 		else
-#line 818
-		    err = nc_put_vars_schar(ncid, i, index, count, stride, value);
-#line 818
+		    err = nc_put_vars_longlong(ncid, i, index, count, stride, value);
 		if (canConvert) {
-#line 818
 		    if (allInExtRange) {
-#line 818
 			IF (err) 
-#line 818
 			    error("%s", nc_strerror(err));
-#line 818
 		    } else {
-#line 818
 			IF (err != NC_ERANGE)
-#line 818
 			    error("range error: status = %d", err);
-#line 818
 		    }
-#line 818
 		} else {
-#line 818
 		    IF (nels > 0 && err != NC_ECHAR)
-#line 818
 			error("wrong type: status = %d", err);
-#line 818
 		}
-#line 818
 	    }
-#line 818
 	}
-#line 818
     }
-#line 818
 
-#line 818
     err = nc_close(ncid);
-#line 818
     IF (err) 
-#line 818
 	error("nc_close: %s", nc_strerror(err));
-#line 818
 
-#line 818
-    check_vars_schar(scratch);
-#line 818
+    check_vars_longlong(scratch);
 
-#line 818
     err = remove(scratch);
-#line 818
     IF (err)
-#line 818
 	error("remove of %s failed", scratch);
-#line 818
 }
-#line 818
 
 void
-#line 819
-test_nc_put_vars_short(void)
-#line 819
+test_nc_put_vars_ulonglong(void)
 {
-#line 819
     int ncid;
-#line 819
     int d;
-#line 819
     int i;
-#line 819
     int j;
-#line 819
     int k;
-#line 819
     int m;
-#line 819
     int err;
-#line 819
     int nels;
-#line 819
     int nslabs;
-#line 819
     int nstarts;        /* number of different starts */
-#line 819
     size_t start[MAX_RANK];
-#line 819
     size_t edge[MAX_RANK];
-#line 819
     size_t index[MAX_RANK];
-#line 819
     size_t index2[MAX_RANK];
-#line 819
     size_t mid[MAX_RANK];
-#line 819
     size_t count[MAX_RANK];
-#line 819
     size_t sstride[MAX_RANK];
-#line 819
     ptrdiff_t stride[MAX_RANK];
-#line 819
     int canConvert;	/* Both text or both numeric */
-#line 819
     int allInExtRange;	/* all values within external range? */
-#line 819
-    short value[MAX_NELS];
-#line 819
+    ulonglong value[MAX_NELS];
 
-#line 819
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 819
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 819
 	error("nc_create: %s", nc_strerror(err));
-#line 819
 	return;
-#line 819
     }
-#line 819
     def_dims(ncid);
-#line 819
     def_vars(ncid);
-#line 819
     err = nc_enddef(ncid);
-#line 819
     IF (err)
-#line 819
 	error("nc_enddef: %s", nc_strerror(err));
-#line 819
 
-#line 819
-    for (i = 0; i < NVARS; i++) {
-#line 819
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 819
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 819
 	assert(var_nels[i] <= MAX_NELS);
-#line 819
 	for (j = 0; j < var_rank[i]; j++) {
-#line 819
 	    start[j] = 0;
-#line 819
 	    edge[j] = 1;
-#line 819
 	    stride[j] = 1;
-#line 819
 	}
-#line 819
-	err = nc_put_vars_short(BAD_ID, i, start, edge, stride, value);
-#line 819
+	err = nc_put_vars_ulonglong(BAD_ID, i, start, edge, stride, value);
 	IF (err != NC_EBADID) 
-#line 819
 	    error("bad ncid: status = %d", err);
-#line 819
-	err = nc_put_vars_short(ncid, BAD_VARID, start, edge, stride, value);
-#line 819
+	err = nc_put_vars_ulonglong(ncid, BAD_VARID, start, edge, stride, value);
 	IF (err != NC_ENOTVAR) 
-#line 819
 	    error("bad var id: status = %d", err);
-#line 819
 	for (j = 0; j < var_rank[i]; j++) {
-#line 819
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 819
 		start[j] = var_shape[i][j] + 1;
-#line 819
-		err = nc_put_vars_short(ncid, i, start, edge, stride, value);
-#line 819
+		err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
 	      if(!canConvert) {
-#line 819
 		IF(err != NC_ECHAR)
-#line 819
 			error("conversion: status = %d", err);
-#line 819
 	      } else {
-#line 819
 		IF(err != NC_EINVALCOORDS)
-#line 819
 		    error("bad start: status = %d", err);
-#line 819
 		start[j] = 0;
-#line 819
 		edge[j] = var_shape[i][j] + 1;
-#line 819
-		err = nc_put_vars_short(ncid, i, start, edge, stride, value);
-#line 819
+		err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
 		IF (err != NC_EEDGE)
-#line 819
 		    error("bad edge: status = %d", err);
-#line 819
 		edge[j] = 1;
-#line 819
 		stride[j] = 0;
-#line 819
-		err = nc_put_vars_short(ncid, i, start, edge, stride, value);
-#line 819
+		err = nc_put_vars_ulonglong(ncid, i, start, edge, stride, value);
 		IF (err != NC_ESTRIDE)
-#line 819
 		    error("bad stride: status = %d", err);
-#line 819
 		stride[j] = 1;
-#line 819
               }
-#line 819
 	    }
-#line 819
 	}
-#line 819
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 819
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 819
 	nslabs = 1;
-#line 819
 	for (j = 0; j < var_rank[i]; j++) {
-#line 819
 	    mid[j] = roll( var_shape[i][j] );
-#line 819
 	    nslabs *= 2;
-#line 819
 	}
-#line 819
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 819
 	    /* choose random stride from 1 to edge */
-#line 819
 	for (k = 0; k < nslabs; k++) {
-#line 819
 	    nstarts = 1;
-#line 819
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 819
 		if ((k >> j) & 1) {
-#line 819
 		    start[j] = 0;
-#line 819
 		    edge[j] = mid[j];
-#line 819
 		}else{
-#line 819
 		    start[j] = mid[j];
-#line 819
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 819
 		}
-#line 819
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 819
 		nstarts *= stride[j];
-#line 819
 	    }
-#line 819
 	    for (m = 0; m < nstarts; m++) {
-#line 819
 		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 819
 		IF (err)
-#line 819
 		    error("error in toMixedBase");
-#line 819
 		nels = 1;
-#line 819
 		for (j = 0; j < var_rank[i]; j++) {
-#line 819
 		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 819
 		    nels *= count[j];
-#line 819
 		    index[j] += start[j];
-#line 819
 		}
-#line 819
 		    /* Random choice of forward or backward */
-#line 819
 /* TODO
-#line 819
 		if ( roll(2) ) {
-#line 819
 		    for (j = 0; j < var_rank[i]; j++) {
-#line 819
 			index[j] += (count[j] - 1) * stride[j];
-#line 819
 			stride[j] = -stride[j];
-#line 819
 		    }
-#line 819
 		}
-#line 819
 */
-#line 819
 		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 819
 		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 819
 		    IF (err)
-#line 819
 			error("error in toMixedBase");
-#line 819
 		    for (d = 0; d < var_rank[i]; d++)
-#line 819
 			index2[d] = index[d] + index2[d] * stride[d];
-#line 819
-		    value[j] = hash_short(var_type[i], var_rank[i], index2, 
-#line 819
-			NCT_SHORT);
-#line 819
+		    value[j] = hash_ulonglong(var_type[i], var_rank[i], index2, 
+			NCT_ULONGLONG);
 		    allInExtRange = allInExtRange 
-#line 819
-			&& inRange3(value[j], var_type[i], NCT_SHORT);
-#line 819
+			&& inRange3(value[j], var_type[i], NCT_ULONGLONG);
 		}
-#line 819
 		if (var_rank[i] == 0 && i%2 == 0)
-#line 819
-		    err = nc_put_vars_short(ncid, i, NULL, NULL, stride, value);
-#line 819
+		    err = nc_put_vars_ulonglong(ncid, i, NULL, NULL, stride, value);
 		else
-#line 819
-		    err = nc_put_vars_short(ncid, i, index, count, stride, value);
-#line 819
+		    err = nc_put_vars_ulonglong(ncid, i, index, count, stride, value);
 		if (canConvert) {
-#line 819
 		    if (allInExtRange) {
-#line 819
 			IF (err) 
-#line 819
 			    error("%s", nc_strerror(err));
-#line 819
 		    } else {
-#line 819
 			IF (err != NC_ERANGE)
-#line 819
 			    error("range error: status = %d", err);
-#line 819
 		    }
-#line 819
 		} else {
-#line 819
 		    IF (nels > 0 && err != NC_ECHAR)
-#line 819
 			error("wrong type: status = %d", err);
-#line 819
 		}
-#line 819
 	    }
-#line 819
 	}
-#line 819
     }
-#line 819
 
-#line 819
     err = nc_close(ncid);
-#line 819
     IF (err) 
-#line 819
 	error("nc_close: %s", nc_strerror(err));
-#line 819
 
-#line 819
-    check_vars_short(scratch);
-#line 819
+    check_vars_ulonglong(scratch);
 
-#line 819
     err = remove(scratch);
-#line 819
     IF (err)
-#line 819
 	error("remove of %s failed", scratch);
-#line 819
 }
-#line 819
+
+
+
 
 void
-#line 820
-test_nc_put_vars_int(void)
-#line 820
+test_nc_put_varm_text(void)
 {
-#line 820
     int ncid;
-#line 820
     int d;
-#line 820
     int i;
-#line 820
     int j;
-#line 820
     int k;
-#line 820
     int m;
-#line 820
     int err;
-#line 820
     int nels;
-#line 820
     int nslabs;
-#line 820
     int nstarts;        /* number of different starts */
-#line 820
     size_t start[MAX_RANK];
-#line 820
     size_t edge[MAX_RANK];
-#line 820
     size_t index[MAX_RANK];
-#line 820
     size_t index2[MAX_RANK];
-#line 820
     size_t mid[MAX_RANK];
-#line 820
     size_t count[MAX_RANK];
-#line 820
     size_t sstride[MAX_RANK];
-#line 820
     ptrdiff_t stride[MAX_RANK];
-#line 820
+    ptrdiff_t imap[MAX_RANK];
     int canConvert;	/* Both text or both numeric */
-#line 820
     int allInExtRange;	/* all values within external range? */
-#line 820
-    int value[MAX_NELS];
-#line 820
+    text value[MAX_NELS];
 
-#line 820
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 820
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 820
 	error("nc_create: %s", nc_strerror(err));
-#line 820
 	return;
-#line 820
     }
-#line 820
     def_dims(ncid);
-#line 820
     def_vars(ncid);
-#line 820
     err = nc_enddef(ncid);
-#line 820
     IF (err)
-#line 820
 	error("nc_enddef: %s", nc_strerror(err));
-#line 820
 
-#line 820
-    for (i = 0; i < NVARS; i++) {
-#line 820
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 820
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 820
 	assert(var_nels[i] <= MAX_NELS);
-#line 820
 	for (j = 0; j < var_rank[i]; j++) {
-#line 820
 	    start[j] = 0;
-#line 820
 	    edge[j] = 1;
-#line 820
 	    stride[j] = 1;
-#line 820
+	    imap[j] = 1;
 	}
-#line 820
-	err = nc_put_vars_int(BAD_ID, i, start, edge, stride, value);
-#line 820
+	err = nc_put_varm_text(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 820
 	    error("bad ncid: status = %d", err);
-#line 820
-	err = nc_put_vars_int(ncid, BAD_VARID, start, edge, stride, value);
-#line 820
+	err = nc_put_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 820
 	    error("bad var id: status = %d", err);
-#line 820
 	for (j = 0; j < var_rank[i]; j++) {
-#line 820
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 820
 		start[j] = var_shape[i][j] + 1;
-#line 820
-		err = nc_put_vars_int(ncid, i, start, edge, stride, value);
-#line 820
-	      if(!canConvert) {
-#line 820
+		err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
+	      if (!canConvert) {
 		IF(err != NC_ECHAR)
-#line 820
 			error("conversion: status = %d", err);
-#line 820
 	      } else {
-#line 820
-		IF(err != NC_EINVALCOORDS)
-#line 820
+		IF (err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 820
 		start[j] = 0;
-#line 820
 		edge[j] = var_shape[i][j] + 1;
-#line 820
-		err = nc_put_vars_int(ncid, i, start, edge, stride, value);
-#line 820
+		err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 820
 		    error("bad edge: status = %d", err);
-#line 820
 		edge[j] = 1;
-#line 820
 		stride[j] = 0;
-#line 820
-		err = nc_put_vars_int(ncid, i, start, edge, stride, value);
-#line 820
+		err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 820
 		    error("bad stride: status = %d", err);
-#line 820
 		stride[j] = 1;
-#line 820
-              }
-#line 820
+	      }
 	    }
-#line 820
 	}
-#line 820
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 820
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 820
 	nslabs = 1;
-#line 820
 	for (j = 0; j < var_rank[i]; j++) {
-#line 820
 	    mid[j] = roll( var_shape[i][j] );
-#line 820
 	    nslabs *= 2;
-#line 820
 	}
-#line 820
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 820
 	    /* choose random stride from 1 to edge */
-#line 820
 	for (k = 0; k < nslabs; k++) {
-#line 820
 	    nstarts = 1;
-#line 820
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 820
 		if ((k >> j) & 1) {
-#line 820
 		    start[j] = 0;
-#line 820
 		    edge[j] = mid[j];
-#line 820
 		}else{
-#line 820
 		    start[j] = mid[j];
-#line 820
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 820
 		}
-#line 820
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 820
 		nstarts *= stride[j];
-#line 820
 	    }
-#line 820
-	    for (m = 0; m < nstarts; m++) {
-#line 820
-		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 820
-		IF (err)
-#line 820
-		    error("error in toMixedBase");
-#line 820
-		nels = 1;
-#line 820
-		for (j = 0; j < var_rank[i]; j++) {
-#line 820
-		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 820
-		    nels *= count[j];
-#line 820
-		    index[j] += start[j];
-#line 820
-		}
-#line 820
-		    /* Random choice of forward or backward */
-#line 820
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+                    nels *= count[j];
+                    index[j] += start[j];
+                }
+                    /* Random choice of forward or backward */
 /* TODO
-#line 820
-		if ( roll(2) ) {
-#line 820
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 820
-			index[j] += (count[j] - 1) * stride[j];
-#line 820
-			stride[j] = -stride[j];
-#line 820
-		    }
-#line 820
-		}
-#line 820
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
+                    }
+                }
 */
-#line 820
-		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 820
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 820
-		    IF (err)
-#line 820
-			error("error in toMixedBase");
-#line 820
-		    for (d = 0; d < var_rank[i]; d++)
-#line 820
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 820
-		    value[j] = hash_int(var_type[i], var_rank[i], index2, 
-#line 820
-			NCT_INT);
-#line 820
-		    allInExtRange = allInExtRange 
-#line 820
-			&& inRange3(value[j], var_type[i], NCT_INT);
-#line 820
-		}
-#line 820
-		if (var_rank[i] == 0 && i%2 == 0)
-#line 820
-		    err = nc_put_vars_int(ncid, i, NULL, NULL, stride, value);
-#line 820
-		else
-#line 820
-		    err = nc_put_vars_int(ncid, i, index, count, stride, value);
-#line 820
-		if (canConvert) {
-#line 820
-		    if (allInExtRange) {
-#line 820
-			IF (err) 
-#line 820
-			    error("%s", nc_strerror(err));
-#line 820
-		    } else {
-#line 820
-			IF (err != NC_ERANGE)
-#line 820
-			    error("range error: status = %d", err);
-#line 820
-		    }
-#line 820
-		} else {
-#line 820
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 820
-			error("wrong type: status = %d", err);
-#line 820
+                if (var_rank[i] > 0) {
+                    j = var_rank[i] - 1;
+                    imap[j] = 1;
+                    for (; j > 0; j--)
+                        imap[j-1] = imap[j] * count[j];
+                }
+                for (allInExtRange = 1, j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    value[j] = hash_text(var_type[i], var_rank[i], index2,
+                        NCT_TEXT);
+                    allInExtRange = allInExtRange
+                        && inRange3(value[j], var_type[i], NCT_TEXT);
+                }
+                if (var_rank[i] == 0 && i%2 == 0)
+                    err = nc_put_varm_text(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_put_varm_text(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        IF (err)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("range error: status = %d", err);
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
 		}
-#line 820
 	    }
-#line 820
 	}
-#line 820
     }
-#line 820
 
-#line 820
     err = nc_close(ncid);
-#line 820
     IF (err) 
-#line 820
 	error("nc_close: %s", nc_strerror(err));
-#line 820
 
-#line 820
-    check_vars_int(scratch);
-#line 820
+    check_vars_text(scratch);
 
-#line 820
     err = remove(scratch);
-#line 820
     IF (err)
-#line 820
-	error("remove of %s failed", scratch);
-#line 820
+        error("remove of %s failed", scratch);
 }
-#line 820
 
 void
-#line 821
-test_nc_put_vars_long(void)
-#line 821
+test_nc_put_varm_uchar(void)
 {
-#line 821
     int ncid;
-#line 821
     int d;
-#line 821
     int i;
-#line 821
     int j;
-#line 821
     int k;
-#line 821
     int m;
-#line 821
     int err;
-#line 821
     int nels;
-#line 821
     int nslabs;
-#line 821
     int nstarts;        /* number of different starts */
-#line 821
     size_t start[MAX_RANK];
-#line 821
     size_t edge[MAX_RANK];
-#line 821
     size_t index[MAX_RANK];
-#line 821
     size_t index2[MAX_RANK];
-#line 821
     size_t mid[MAX_RANK];
-#line 821
     size_t count[MAX_RANK];
-#line 821
     size_t sstride[MAX_RANK];
-#line 821
     ptrdiff_t stride[MAX_RANK];
-#line 821
+    ptrdiff_t imap[MAX_RANK];
     int canConvert;	/* Both text or both numeric */
-#line 821
     int allInExtRange;	/* all values within external range? */
-#line 821
-    long value[MAX_NELS];
-#line 821
+    uchar value[MAX_NELS];
 
-#line 821
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 821
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 821
 	error("nc_create: %s", nc_strerror(err));
-#line 821
 	return;
-#line 821
     }
-#line 821
     def_dims(ncid);
-#line 821
     def_vars(ncid);
-#line 821
     err = nc_enddef(ncid);
-#line 821
     IF (err)
-#line 821
 	error("nc_enddef: %s", nc_strerror(err));
-#line 821
 
-#line 821
-    for (i = 0; i < NVARS; i++) {
-#line 821
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 821
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 821
 	assert(var_nels[i] <= MAX_NELS);
-#line 821
 	for (j = 0; j < var_rank[i]; j++) {
-#line 821
 	    start[j] = 0;
-#line 821
 	    edge[j] = 1;
-#line 821
 	    stride[j] = 1;
-#line 821
+	    imap[j] = 1;
 	}
-#line 821
-	err = nc_put_vars_long(BAD_ID, i, start, edge, stride, value);
-#line 821
+	err = nc_put_varm_uchar(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 821
 	    error("bad ncid: status = %d", err);
-#line 821
-	err = nc_put_vars_long(ncid, BAD_VARID, start, edge, stride, value);
-#line 821
+	err = nc_put_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 821
 	    error("bad var id: status = %d", err);
-#line 821
 	for (j = 0; j < var_rank[i]; j++) {
-#line 821
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 821
 		start[j] = var_shape[i][j] + 1;
-#line 821
-		err = nc_put_vars_long(ncid, i, start, edge, stride, value);
-#line 821
-	      if(!canConvert) {
-#line 821
+		err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
+	      if (!canConvert) {
 		IF(err != NC_ECHAR)
-#line 821
 			error("conversion: status = %d", err);
-#line 821
 	      } else {
-#line 821
-		IF(err != NC_EINVALCOORDS)
-#line 821
+		IF (err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 821
 		start[j] = 0;
-#line 821
 		edge[j] = var_shape[i][j] + 1;
-#line 821
-		err = nc_put_vars_long(ncid, i, start, edge, stride, value);
-#line 821
+		err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 821
 		    error("bad edge: status = %d", err);
-#line 821
 		edge[j] = 1;
-#line 821
 		stride[j] = 0;
-#line 821
-		err = nc_put_vars_long(ncid, i, start, edge, stride, value);
-#line 821
+		err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 821
 		    error("bad stride: status = %d", err);
-#line 821
 		stride[j] = 1;
-#line 821
-              }
-#line 821
+	      }
 	    }
-#line 821
 	}
-#line 821
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 821
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 821
 	nslabs = 1;
-#line 821
 	for (j = 0; j < var_rank[i]; j++) {
-#line 821
 	    mid[j] = roll( var_shape[i][j] );
-#line 821
 	    nslabs *= 2;
-#line 821
 	}
-#line 821
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 821
 	    /* choose random stride from 1 to edge */
-#line 821
 	for (k = 0; k < nslabs; k++) {
-#line 821
 	    nstarts = 1;
-#line 821
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 821
 		if ((k >> j) & 1) {
-#line 821
 		    start[j] = 0;
-#line 821
 		    edge[j] = mid[j];
-#line 821
 		}else{
-#line 821
 		    start[j] = mid[j];
-#line 821
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 821
 		}
-#line 821
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 821
 		nstarts *= stride[j];
-#line 821
 	    }
-#line 821
-	    for (m = 0; m < nstarts; m++) {
-#line 821
-		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 821
-		IF (err)
-#line 821
-		    error("error in toMixedBase");
-#line 821
-		nels = 1;
-#line 821
-		for (j = 0; j < var_rank[i]; j++) {
-#line 821
-		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 821
-		    nels *= count[j];
-#line 821
-		    index[j] += start[j];
-#line 821
-		}
-#line 821
-		    /* Random choice of forward or backward */
-#line 821
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+                    nels *= count[j];
+                    index[j] += start[j];
+                }
+                    /* Random choice of forward or backward */
 /* TODO
-#line 821
-		if ( roll(2) ) {
-#line 821
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 821
-			index[j] += (count[j] - 1) * stride[j];
-#line 821
-			stride[j] = -stride[j];
-#line 821
-		    }
-#line 821
-		}
-#line 821
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
+                    }
+                }
 */
-#line 821
-		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 821
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 821
-		    IF (err)
-#line 821
-			error("error in toMixedBase");
-#line 821
-		    for (d = 0; d < var_rank[i]; d++)
-#line 821
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 821
-		    value[j] = hash_long(var_type[i], var_rank[i], index2, 
-#line 821
-			NCT_LONG);
-#line 821
-		    allInExtRange = allInExtRange 
-#line 821
-			&& inRange3(value[j], var_type[i], NCT_LONG);
-#line 821
-		}
-#line 821
-		if (var_rank[i] == 0 && i%2 == 0)
-#line 821
-		    err = nc_put_vars_long(ncid, i, NULL, NULL, stride, value);
-#line 821
-		else
-#line 821
-		    err = nc_put_vars_long(ncid, i, index, count, stride, value);
-#line 821
-		if (canConvert) {
-#line 821
-		    if (allInExtRange) {
-#line 821
-			IF (err) 
-#line 821
-			    error("%s", nc_strerror(err));
-#line 821
-		    } else {
-#line 821
-			IF (err != NC_ERANGE)
-#line 821
-			    error("range error: status = %d", err);
-#line 821
-		    }
-#line 821
-		} else {
-#line 821
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 821
-			error("wrong type: status = %d", err);
-#line 821
+                if (var_rank[i] > 0) {
+                    j = var_rank[i] - 1;
+                    imap[j] = 1;
+                    for (; j > 0; j--)
+                        imap[j-1] = imap[j] * count[j];
+                }
+                for (allInExtRange = 1, j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    value[j] = hash_uchar(var_type[i], var_rank[i], index2,
+                        NCT_UCHAR);
+                    allInExtRange = allInExtRange
+                        && inRange3(value[j], var_type[i], NCT_UCHAR);
+                }
+                if (var_rank[i] == 0 && i%2 == 0)
+                    err = nc_put_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_put_varm_uchar(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        IF (err)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("range error: status = %d", err);
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
 		}
-#line 821
 	    }
-#line 821
 	}
-#line 821
     }
-#line 821
 
-#line 821
     err = nc_close(ncid);
-#line 821
     IF (err) 
-#line 821
 	error("nc_close: %s", nc_strerror(err));
-#line 821
 
-#line 821
-    check_vars_long(scratch);
-#line 821
+    check_vars_uchar(scratch);
 
-#line 821
     err = remove(scratch);
-#line 821
     IF (err)
-#line 821
-	error("remove of %s failed", scratch);
-#line 821
+        error("remove of %s failed", scratch);
 }
-#line 821
 
 void
-#line 822
-test_nc_put_vars_float(void)
-#line 822
+test_nc_put_varm_schar(void)
 {
-#line 822
     int ncid;
-#line 822
     int d;
-#line 822
     int i;
-#line 822
     int j;
-#line 822
     int k;
-#line 822
     int m;
-#line 822
     int err;
-#line 822
     int nels;
-#line 822
     int nslabs;
-#line 822
     int nstarts;        /* number of different starts */
-#line 822
     size_t start[MAX_RANK];
-#line 822
     size_t edge[MAX_RANK];
-#line 822
     size_t index[MAX_RANK];
-#line 822
     size_t index2[MAX_RANK];
-#line 822
     size_t mid[MAX_RANK];
-#line 822
     size_t count[MAX_RANK];
-#line 822
     size_t sstride[MAX_RANK];
-#line 822
     ptrdiff_t stride[MAX_RANK];
-#line 822
+    ptrdiff_t imap[MAX_RANK];
     int canConvert;	/* Both text or both numeric */
-#line 822
     int allInExtRange;	/* all values within external range? */
-#line 822
-    float value[MAX_NELS];
-#line 822
+    schar value[MAX_NELS];
 
-#line 822
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 822
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 822
 	error("nc_create: %s", nc_strerror(err));
-#line 822
 	return;
-#line 822
     }
-#line 822
     def_dims(ncid);
-#line 822
     def_vars(ncid);
-#line 822
     err = nc_enddef(ncid);
-#line 822
     IF (err)
-#line 822
 	error("nc_enddef: %s", nc_strerror(err));
-#line 822
 
-#line 822
-    for (i = 0; i < NVARS; i++) {
-#line 822
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 822
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 822
 	assert(var_nels[i] <= MAX_NELS);
-#line 822
 	for (j = 0; j < var_rank[i]; j++) {
-#line 822
 	    start[j] = 0;
-#line 822
 	    edge[j] = 1;
-#line 822
 	    stride[j] = 1;
-#line 822
+	    imap[j] = 1;
 	}
-#line 822
-	err = nc_put_vars_float(BAD_ID, i, start, edge, stride, value);
-#line 822
+	err = nc_put_varm_schar(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 822
 	    error("bad ncid: status = %d", err);
-#line 822
-	err = nc_put_vars_float(ncid, BAD_VARID, start, edge, stride, value);
-#line 822
+	err = nc_put_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 822
 	    error("bad var id: status = %d", err);
-#line 822
 	for (j = 0; j < var_rank[i]; j++) {
-#line 822
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 822
 		start[j] = var_shape[i][j] + 1;
-#line 822
-		err = nc_put_vars_float(ncid, i, start, edge, stride, value);
-#line 822
-	      if(!canConvert) {
-#line 822
+		err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
+	      if (!canConvert) {
 		IF(err != NC_ECHAR)
-#line 822
 			error("conversion: status = %d", err);
-#line 822
 	      } else {
-#line 822
-		IF(err != NC_EINVALCOORDS)
-#line 822
+		IF (err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 822
 		start[j] = 0;
-#line 822
 		edge[j] = var_shape[i][j] + 1;
-#line 822
-		err = nc_put_vars_float(ncid, i, start, edge, stride, value);
-#line 822
+		err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 822
 		    error("bad edge: status = %d", err);
-#line 822
 		edge[j] = 1;
-#line 822
 		stride[j] = 0;
-#line 822
-		err = nc_put_vars_float(ncid, i, start, edge, stride, value);
-#line 822
+		err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 822
 		    error("bad stride: status = %d", err);
-#line 822
 		stride[j] = 1;
-#line 822
-              }
-#line 822
+	      }
 	    }
-#line 822
 	}
-#line 822
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 822
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 822
 	nslabs = 1;
-#line 822
 	for (j = 0; j < var_rank[i]; j++) {
-#line 822
 	    mid[j] = roll( var_shape[i][j] );
-#line 822
 	    nslabs *= 2;
-#line 822
 	}
-#line 822
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 822
 	    /* choose random stride from 1 to edge */
-#line 822
 	for (k = 0; k < nslabs; k++) {
-#line 822
 	    nstarts = 1;
-#line 822
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 822
 		if ((k >> j) & 1) {
-#line 822
 		    start[j] = 0;
-#line 822
 		    edge[j] = mid[j];
-#line 822
 		}else{
-#line 822
 		    start[j] = mid[j];
-#line 822
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 822
 		}
-#line 822
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 822
 		nstarts *= stride[j];
-#line 822
 	    }
-#line 822
-	    for (m = 0; m < nstarts; m++) {
-#line 822
-		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 822
-		IF (err)
-#line 822
-		    error("error in toMixedBase");
-#line 822
-		nels = 1;
-#line 822
-		for (j = 0; j < var_rank[i]; j++) {
-#line 822
-		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 822
-		    nels *= count[j];
-#line 822
-		    index[j] += start[j];
-#line 822
-		}
-#line 822
-		    /* Random choice of forward or backward */
-#line 822
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
+                    nels *= count[j];
+                    index[j] += start[j];
+                }
+                    /* Random choice of forward or backward */
 /* TODO
-#line 822
-		if ( roll(2) ) {
-#line 822
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 822
-			index[j] += (count[j] - 1) * stride[j];
-#line 822
-			stride[j] = -stride[j];
-#line 822
-		    }
-#line 822
-		}
-#line 822
+                if ( roll(2) ) {
+                    for (j = 0; j < var_rank[i]; j++) {
+                        index[j] += (count[j] - 1) * stride[j];
+                        stride[j] = -stride[j];
+                    }
+                }
 */
-#line 822
-		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 822
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 822
-		    IF (err)
-#line 822
-			error("error in toMixedBase");
-#line 822
-		    for (d = 0; d < var_rank[i]; d++)
-#line 822
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 822
-		    value[j] = hash_float(var_type[i], var_rank[i], index2, 
-#line 822
-			NCT_FLOAT);
-#line 822
-		    allInExtRange = allInExtRange 
-#line 822
-			&& inRange3(value[j], var_type[i], NCT_FLOAT);
-#line 822
-		}
-#line 822
-		if (var_rank[i] == 0 && i%2 == 0)
-#line 822
-		    err = nc_put_vars_float(ncid, i, NULL, NULL, stride, value);
-#line 822
-		else
-#line 822
-		    err = nc_put_vars_float(ncid, i, index, count, stride, value);
-#line 822
-		if (canConvert) {
-#line 822
-		    if (allInExtRange) {
-#line 822
-			IF (err) 
-#line 822
-			    error("%s", nc_strerror(err));
-#line 822
-		    } else {
-#line 822
-			IF (err != NC_ERANGE)
-#line 822
-			    error("range error: status = %d", err);
-#line 822
-		    }
-#line 822
-		} else {
-#line 822
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 822
-			error("wrong type: status = %d", err);
-#line 822
+                if (var_rank[i] > 0) {
+                    j = var_rank[i] - 1;
+                    imap[j] = 1;
+                    for (; j > 0; j--)
+                        imap[j-1] = imap[j] * count[j];
+                }
+                for (allInExtRange = 1, j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    value[j] = hash_schar(var_type[i], var_rank[i], index2,
+                        NCT_SCHAR);
+                    allInExtRange = allInExtRange
+                        && inRange3(value[j], var_type[i], NCT_SCHAR);
+                }
+                if (var_rank[i] == 0 && i%2 == 0)
+                    err = nc_put_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_put_varm_schar(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        IF (err)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("range error: status = %d", err);
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
 		}
-#line 822
 	    }
-#line 822
 	}
-#line 822
     }
-#line 822
 
-#line 822
     err = nc_close(ncid);
-#line 822
     IF (err) 
-#line 822
 	error("nc_close: %s", nc_strerror(err));
-#line 822
 
-#line 822
-    check_vars_float(scratch);
-#line 822
+    check_vars_schar(scratch);
 
-#line 822
     err = remove(scratch);
-#line 822
     IF (err)
-#line 822
-	error("remove of %s failed", scratch);
-#line 822
+        error("remove of %s failed", scratch);
 }
-#line 822
 
 void
-#line 823
-test_nc_put_vars_double(void)
-#line 823
+test_nc_put_varm_short(void)
 {
-#line 823
     int ncid;
-#line 823
     int d;
-#line 823
     int i;
-#line 823
     int j;
-#line 823
     int k;
-#line 823
     int m;
-#line 823
     int err;
-#line 823
     int nels;
-#line 823
     int nslabs;
-#line 823
     int nstarts;        /* number of different starts */
-#line 823
     size_t start[MAX_RANK];
-#line 823
     size_t edge[MAX_RANK];
-#line 823
     size_t index[MAX_RANK];
-#line 823
     size_t index2[MAX_RANK];
-#line 823
     size_t mid[MAX_RANK];
-#line 823
     size_t count[MAX_RANK];
-#line 823
     size_t sstride[MAX_RANK];
-#line 823
     ptrdiff_t stride[MAX_RANK];
-#line 823
+    ptrdiff_t imap[MAX_RANK];
     int canConvert;	/* Both text or both numeric */
-#line 823
     int allInExtRange;	/* all values within external range? */
-#line 823
-    double value[MAX_NELS];
-#line 823
+    short value[MAX_NELS];
 
-#line 823
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 823
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 823
 	error("nc_create: %s", nc_strerror(err));
-#line 823
 	return;
-#line 823
     }
-#line 823
     def_dims(ncid);
-#line 823
     def_vars(ncid);
-#line 823
     err = nc_enddef(ncid);
-#line 823
     IF (err)
-#line 823
 	error("nc_enddef: %s", nc_strerror(err));
-#line 823
 
-#line 823
-    for (i = 0; i < NVARS; i++) {
-#line 823
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 823
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 823
 	assert(var_nels[i] <= MAX_NELS);
-#line 823
 	for (j = 0; j < var_rank[i]; j++) {
-#line 823
 	    start[j] = 0;
-#line 823
 	    edge[j] = 1;
-#line 823
 	    stride[j] = 1;
-#line 823
+	    imap[j] = 1;
 	}
-#line 823
-	err = nc_put_vars_double(BAD_ID, i, start, edge, stride, value);
-#line 823
+	err = nc_put_varm_short(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 823
 	    error("bad ncid: status = %d", err);
-#line 823
-	err = nc_put_vars_double(ncid, BAD_VARID, start, edge, stride, value);
-#line 823
+	err = nc_put_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 823
 	    error("bad var id: status = %d", err);
-#line 823
 	for (j = 0; j < var_rank[i]; j++) {
-#line 823
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 823
 		start[j] = var_shape[i][j] + 1;
-#line 823
-		err = nc_put_vars_double(ncid, i, start, edge, stride, value);
-#line 823
-	      if(!canConvert) {
-#line 823
+		err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
+	      if (!canConvert) {
 		IF(err != NC_ECHAR)
-#line 823
 			error("conversion: status = %d", err);
-#line 823
 	      } else {
-#line 823
-		IF(err != NC_EINVALCOORDS)
-#line 823
+		IF (err != NC_EINVALCOORDS)
 		    error("bad start: status = %d", err);
-#line 823
 		start[j] = 0;
-#line 823
 		edge[j] = var_shape[i][j] + 1;
-#line 823
-		err = nc_put_vars_double(ncid, i, start, edge, stride, value);
-#line 823
+		err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 823
 		    error("bad edge: status = %d", err);
-#line 823
 		edge[j] = 1;
-#line 823
 		stride[j] = 0;
-#line 823
-		err = nc_put_vars_double(ncid, i, start, edge, stride, value);
-#line 823
+		err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 823
 		    error("bad stride: status = %d", err);
-#line 823
 		stride[j] = 1;
-#line 823
-              }
-#line 823
+	      }
 	    }
-#line 823
 	}
-#line 823
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 823
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 823
 	nslabs = 1;
-#line 823
 	for (j = 0; j < var_rank[i]; j++) {
-#line 823
 	    mid[j] = roll( var_shape[i][j] );
-#line 823
 	    nslabs *= 2;
-#line 823
 	}
-#line 823
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 823
 	    /* choose random stride from 1 to edge */
-#line 823
 	for (k = 0; k < nslabs; k++) {
-#line 823
 	    nstarts = 1;
-#line 823
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 823
 		if ((k >> j) & 1) {
-#line 823
 		    start[j] = 0;
-#line 823
 		    edge[j] = mid[j];
-#line 823
 		}else{
-#line 823
-		    start[j] = mid[j];
-#line 823
-		    edge[j] = var_shape[i][j] - mid[j];
-#line 823
-		}
-#line 823
-		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 823
-		nstarts *= stride[j];
-#line 823
-	    }
-#line 823
-	    for (m = 0; m < nstarts; m++) {
-#line 823
-		err = toMixedBase(m, var_rank[i], sstride, index);
-#line 823
-		IF (err)
-#line 823
-		    error("error in toMixedBase");
-#line 823
-		nels = 1;
-#line 823
-		for (j = 0; j < var_rank[i]; j++) {
-#line 823
-		    count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 823
-		    nels *= count[j];
-#line 823
-		    index[j] += start[j];
-#line 823
-		}
-#line 823
-		    /* Random choice of forward or backward */
-#line 823
-/* TODO
-#line 823
-		if ( roll(2) ) {
-#line 823
-		    for (j = 0; j < var_rank[i]; j++) {
-#line 823
-			index[j] += (count[j] - 1) * stride[j];
-#line 823
-			stride[j] = -stride[j];
-#line 823
-		    }
-#line 823
+		    start[j] = mid[j];
+		    edge[j] = var_shape[i][j] - mid[j];
 		}
-#line 823
+		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
+		nstarts *= stride[j];
+	    }
+            for (m = 0; m < nstarts; m++) {
+                err = toMixedBase(m, var_rank[i], sstride, index);
+                IF (err)
+                    error("error in toMixedBase");
+                nels = 1;
+                for (j = 0; j < var_rank[i]; j++) {
+                    count[j] = 1 + (edge[j] - index[j] - 1) / 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) * stride[j];
+                        stride[j] = -stride[j];
+                    }
+                }
 */
-#line 823
-		for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 823
-		    err = toMixedBase(j, var_rank[i], count, index2);
-#line 823
-		    IF (err)
-#line 823
-			error("error in toMixedBase");
-#line 823
-		    for (d = 0; d < var_rank[i]; d++)
-#line 823
-			index2[d] = index[d] + index2[d] * stride[d];
-#line 823
-		    value[j] = hash_double(var_type[i], var_rank[i], index2, 
-#line 823
-			NCT_DOUBLE);
-#line 823
-		    allInExtRange = allInExtRange 
-#line 823
-			&& inRange3(value[j], var_type[i], NCT_DOUBLE);
-#line 823
-		}
-#line 823
-		if (var_rank[i] == 0 && i%2 == 0)
-#line 823
-		    err = nc_put_vars_double(ncid, i, NULL, NULL, stride, value);
-#line 823
-		else
-#line 823
-		    err = nc_put_vars_double(ncid, i, index, count, stride, value);
-#line 823
-		if (canConvert) {
-#line 823
-		    if (allInExtRange) {
-#line 823
-			IF (err) 
-#line 823
-			    error("%s", nc_strerror(err));
-#line 823
-		    } else {
-#line 823
-			IF (err != NC_ERANGE)
-#line 823
-			    error("range error: status = %d", err);
-#line 823
-		    }
-#line 823
-		} else {
-#line 823
-		    IF (nels > 0 && err != NC_ECHAR)
-#line 823
-			error("wrong type: status = %d", err);
-#line 823
+                if (var_rank[i] > 0) {
+                    j = var_rank[i] - 1;
+                    imap[j] = 1;
+                    for (; j > 0; j--)
+                        imap[j-1] = imap[j] * count[j];
+                }
+                for (allInExtRange = 1, j = 0; j < nels; j++) {
+                    err = toMixedBase(j, var_rank[i], count, index2);
+                    IF (err)
+                        error("error in toMixedBase");
+                    for (d = 0; d < var_rank[i]; d++)
+                        index2[d] = index[d] + index2[d] * stride[d];
+                    value[j] = hash_short(var_type[i], var_rank[i], index2,
+                        NCT_SHORT);
+                    allInExtRange = allInExtRange
+                        && inRange3(value[j], var_type[i], NCT_SHORT);
+                }
+                if (var_rank[i] == 0 && i%2 == 0)
+                    err = nc_put_varm_short(ncid,i,NULL,NULL,NULL,NULL,value);
+                else
+                    err = nc_put_varm_short(ncid,i,index,count,stride,imap,value);
+                if (canConvert) {
+                    if (allInExtRange) {
+                        IF (err)
+                            error("%s", nc_strerror(err));
+                    } else {
+                        IF (err != NC_ERANGE)
+                            error("range error: status = %d", err);
+                    }
+                } else {
+                    IF (nels > 0 && err != NC_ECHAR)
+                        error("wrong type: status = %d", err);
 		}
-#line 823
 	    }
-#line 823
 	}
-#line 823
     }
-#line 823
 
-#line 823
     err = nc_close(ncid);
-#line 823
     IF (err) 
-#line 823
 	error("nc_close: %s", nc_strerror(err));
-#line 823
 
-#line 823
-    check_vars_double(scratch);
-#line 823
+    check_vars_short(scratch);
 
-#line 823
     err = remove(scratch);
-#line 823
     IF (err)
-#line 823
-	error("remove of %s failed", scratch);
-#line 823
+        error("remove of %s failed", scratch);
 }
-#line 823
-
-
-
-#line 996
 
 void
-#line 997
-test_nc_put_varm_text(void)
-#line 997
+test_nc_put_varm_int(void)
 {
-#line 997
     int ncid;
-#line 997
     int d;
-#line 997
     int i;
-#line 997
     int j;
-#line 997
     int k;
-#line 997
     int m;
-#line 997
     int err;
-#line 997
     int nels;
-#line 997
     int nslabs;
-#line 997
     int nstarts;        /* number of different starts */
-#line 997
     size_t start[MAX_RANK];
-#line 997
     size_t edge[MAX_RANK];
-#line 997
     size_t index[MAX_RANK];
-#line 997
     size_t index2[MAX_RANK];
-#line 997
     size_t mid[MAX_RANK];
-#line 997
     size_t count[MAX_RANK];
-#line 997
     size_t sstride[MAX_RANK];
-#line 997
     ptrdiff_t stride[MAX_RANK];
-#line 997
     ptrdiff_t imap[MAX_RANK];
-#line 997
     int canConvert;	/* Both text or both numeric */
-#line 997
     int allInExtRange;	/* all values within external range? */
-#line 997
-    text value[MAX_NELS];
-#line 997
+    int value[MAX_NELS];
 
-#line 997
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 997
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 997
 	error("nc_create: %s", nc_strerror(err));
-#line 997
 	return;
-#line 997
     }
-#line 997
     def_dims(ncid);
-#line 997
     def_vars(ncid);
-#line 997
     err = nc_enddef(ncid);
-#line 997
     IF (err)
-#line 997
 	error("nc_enddef: %s", nc_strerror(err));
-#line 997
 
-#line 997
-    for (i = 0; i < NVARS; i++) {
-#line 997
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
-#line 997
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 997
 	assert(var_nels[i] <= MAX_NELS);
-#line 997
 	for (j = 0; j < var_rank[i]; j++) {
-#line 997
 	    start[j] = 0;
-#line 997
 	    edge[j] = 1;
-#line 997
 	    stride[j] = 1;
-#line 997
 	    imap[j] = 1;
-#line 997
 	}
-#line 997
-	err = nc_put_varm_text(BAD_ID, i, start, edge, stride, imap, value);
-#line 997
+	err = nc_put_varm_int(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 997
 	    error("bad ncid: status = %d", err);
-#line 997
-	err = nc_put_varm_text(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 997
+	err = nc_put_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 997
 	    error("bad var id: status = %d", err);
-#line 997
 	for (j = 0; j < var_rank[i]; j++) {
-#line 997
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 997
 		start[j] = var_shape[i][j] + 1;
-#line 997
-		err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
-#line 997
+		err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 997
 		IF(err != NC_ECHAR)
-#line 997
 			error("conversion: status = %d", err);
-#line 997
 	      } else {
-#line 997
 		IF (err != NC_EINVALCOORDS)
-#line 997
 		    error("bad start: status = %d", err);
-#line 997
 		start[j] = 0;
-#line 997
 		edge[j] = var_shape[i][j] + 1;
-#line 997
-		err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
-#line 997
+		err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 997
 		    error("bad edge: status = %d", err);
-#line 997
 		edge[j] = 1;
-#line 997
 		stride[j] = 0;
-#line 997
-		err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
-#line 997
+		err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 997
 		    error("bad stride: status = %d", err);
-#line 997
 		stride[j] = 1;
-#line 997
 	      }
-#line 997
 	    }
-#line 997
 	}
-#line 997
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 997
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 997
 	nslabs = 1;
-#line 997
 	for (j = 0; j < var_rank[i]; j++) {
-#line 997
 	    mid[j] = roll( var_shape[i][j] );
-#line 997
 	    nslabs *= 2;
-#line 997
 	}
-#line 997
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 997
 	    /* choose random stride from 1 to edge */
-#line 997
 	for (k = 0; k < nslabs; k++) {
-#line 997
 	    nstarts = 1;
-#line 997
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 997
 		if ((k >> j) & 1) {
-#line 997
 		    start[j] = 0;
-#line 997
 		    edge[j] = mid[j];
-#line 997
 		}else{
-#line 997
 		    start[j] = mid[j];
-#line 997
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 997
 		}
-#line 997
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 997
 		nstarts *= stride[j];
-#line 997
 	    }
-#line 997
             for (m = 0; m < nstarts; m++) {
-#line 997
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 997
                 IF (err)
-#line 997
                     error("error in toMixedBase");
-#line 997
                 nels = 1;
-#line 997
                 for (j = 0; j < var_rank[i]; j++) {
-#line 997
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 997
                     nels *= count[j];
-#line 997
                     index[j] += start[j];
-#line 997
                 }
-#line 997
                     /* Random choice of forward or backward */
-#line 997
 /* TODO
-#line 997
                 if ( roll(2) ) {
-#line 997
                     for (j = 0; j < var_rank[i]; j++) {
-#line 997
                         index[j] += (count[j] - 1) * stride[j];
-#line 997
                         stride[j] = -stride[j];
-#line 997
                     }
-#line 997
                 }
-#line 997
 */
-#line 997
                 if (var_rank[i] > 0) {
-#line 997
                     j = var_rank[i] - 1;
-#line 997
                     imap[j] = 1;
-#line 997
                     for (; j > 0; j--)
-#line 997
                         imap[j-1] = imap[j] * count[j];
-#line 997
                 }
-#line 997
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 997
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 997
                     IF (err)
-#line 997
                         error("error in toMixedBase");
-#line 997
                     for (d = 0; d < var_rank[i]; d++)
-#line 997
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 997
-                    value[j] = hash_text(var_type[i], var_rank[i], index2,
-#line 997
-                        NCT_TEXT);
-#line 997
+                    value[j] = hash_int(var_type[i], var_rank[i], index2,
+                        NCT_INT);
                     allInExtRange = allInExtRange
-#line 997
-                        && inRange3(value[j], var_type[i], NCT_TEXT);
-#line 997
+                        && inRange3(value[j], var_type[i], NCT_INT);
                 }
-#line 997
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 997
-                    err = nc_put_varm_text(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 997
+                    err = nc_put_varm_int(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 997
-                    err = nc_put_varm_text(ncid,i,index,count,stride,imap,value);
-#line 997
+                    err = nc_put_varm_int(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 997
                     if (allInExtRange) {
-#line 997
                         IF (err)
-#line 997
                             error("%s", nc_strerror(err));
-#line 997
                     } else {
-#line 997
                         IF (err != NC_ERANGE)
-#line 997
                             error("range error: status = %d", err);
-#line 997
                     }
-#line 997
                 } else {
-#line 997
                     IF (nels > 0 && err != NC_ECHAR)
-#line 997
                         error("wrong type: status = %d", err);
-#line 997
 		}
-#line 997
 	    }
-#line 997
 	}
-#line 997
     }
-#line 997
 
-#line 997
     err = nc_close(ncid);
-#line 997
     IF (err) 
-#line 997
 	error("nc_close: %s", nc_strerror(err));
-#line 997
 
-#line 997
-    check_vars_text(scratch);
-#line 997
+    check_vars_int(scratch);
 
-#line 997
     err = remove(scratch);
-#line 997
     IF (err)
-#line 997
         error("remove of %s failed", scratch);
-#line 997
 }
-#line 997
 
 void
-#line 998
-test_nc_put_varm_uchar(void)
-#line 998
+test_nc_put_varm_long(void)
 {
-#line 998
     int ncid;
-#line 998
     int d;
-#line 998
     int i;
-#line 998
     int j;
-#line 998
     int k;
-#line 998
     int m;
-#line 998
     int err;
-#line 998
     int nels;
-#line 998
     int nslabs;
-#line 998
     int nstarts;        /* number of different starts */
-#line 998
     size_t start[MAX_RANK];
-#line 998
     size_t edge[MAX_RANK];
-#line 998
     size_t index[MAX_RANK];
-#line 998
     size_t index2[MAX_RANK];
-#line 998
     size_t mid[MAX_RANK];
-#line 998
     size_t count[MAX_RANK];
-#line 998
     size_t sstride[MAX_RANK];
-#line 998
     ptrdiff_t stride[MAX_RANK];
-#line 998
     ptrdiff_t imap[MAX_RANK];
-#line 998
     int canConvert;	/* Both text or both numeric */
-#line 998
     int allInExtRange;	/* all values within external range? */
-#line 998
-    uchar value[MAX_NELS];
-#line 998
+    long value[MAX_NELS];
 
-#line 998
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 998
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 998
 	error("nc_create: %s", nc_strerror(err));
-#line 998
 	return;
-#line 998
     }
-#line 998
     def_dims(ncid);
-#line 998
     def_vars(ncid);
-#line 998
     err = nc_enddef(ncid);
-#line 998
     IF (err)
-#line 998
 	error("nc_enddef: %s", nc_strerror(err));
-#line 998
 
-#line 998
-    for (i = 0; i < NVARS; i++) {
-#line 998
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
-#line 998
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 998
 	assert(var_nels[i] <= MAX_NELS);
-#line 998
 	for (j = 0; j < var_rank[i]; j++) {
-#line 998
 	    start[j] = 0;
-#line 998
 	    edge[j] = 1;
-#line 998
 	    stride[j] = 1;
-#line 998
 	    imap[j] = 1;
-#line 998
 	}
-#line 998
-	err = nc_put_varm_uchar(BAD_ID, i, start, edge, stride, imap, value);
-#line 998
+	err = nc_put_varm_long(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 998
 	    error("bad ncid: status = %d", err);
-#line 998
-	err = nc_put_varm_uchar(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 998
+	err = nc_put_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 998
 	    error("bad var id: status = %d", err);
-#line 998
 	for (j = 0; j < var_rank[i]; j++) {
-#line 998
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 998
 		start[j] = var_shape[i][j] + 1;
-#line 998
-		err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
-#line 998
+		err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 998
 		IF(err != NC_ECHAR)
-#line 998
 			error("conversion: status = %d", err);
-#line 998
 	      } else {
-#line 998
 		IF (err != NC_EINVALCOORDS)
-#line 998
 		    error("bad start: status = %d", err);
-#line 998
 		start[j] = 0;
-#line 998
 		edge[j] = var_shape[i][j] + 1;
-#line 998
-		err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
-#line 998
+		err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 998
 		    error("bad edge: status = %d", err);
-#line 998
 		edge[j] = 1;
-#line 998
 		stride[j] = 0;
-#line 998
-		err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
-#line 998
+		err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 998
 		    error("bad stride: status = %d", err);
-#line 998
 		stride[j] = 1;
-#line 998
 	      }
-#line 998
 	    }
-#line 998
 	}
-#line 998
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 998
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 998
 	nslabs = 1;
-#line 998
 	for (j = 0; j < var_rank[i]; j++) {
-#line 998
 	    mid[j] = roll( var_shape[i][j] );
-#line 998
 	    nslabs *= 2;
-#line 998
 	}
-#line 998
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 998
 	    /* choose random stride from 1 to edge */
-#line 998
 	for (k = 0; k < nslabs; k++) {
-#line 998
 	    nstarts = 1;
-#line 998
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 998
 		if ((k >> j) & 1) {
-#line 998
 		    start[j] = 0;
-#line 998
 		    edge[j] = mid[j];
-#line 998
 		}else{
-#line 998
 		    start[j] = mid[j];
-#line 998
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 998
 		}
-#line 998
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 998
 		nstarts *= stride[j];
-#line 998
 	    }
-#line 998
             for (m = 0; m < nstarts; m++) {
-#line 998
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 998
                 IF (err)
-#line 998
                     error("error in toMixedBase");
-#line 998
                 nels = 1;
-#line 998
                 for (j = 0; j < var_rank[i]; j++) {
-#line 998
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 998
                     nels *= count[j];
-#line 998
                     index[j] += start[j];
-#line 998
                 }
-#line 998
                     /* Random choice of forward or backward */
-#line 998
 /* TODO
-#line 998
                 if ( roll(2) ) {
-#line 998
                     for (j = 0; j < var_rank[i]; j++) {
-#line 998
                         index[j] += (count[j] - 1) * stride[j];
-#line 998
                         stride[j] = -stride[j];
-#line 998
                     }
-#line 998
                 }
-#line 998
 */
-#line 998
                 if (var_rank[i] > 0) {
-#line 998
                     j = var_rank[i] - 1;
-#line 998
                     imap[j] = 1;
-#line 998
                     for (; j > 0; j--)
-#line 998
                         imap[j-1] = imap[j] * count[j];
-#line 998
                 }
-#line 998
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 998
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 998
                     IF (err)
-#line 998
                         error("error in toMixedBase");
-#line 998
                     for (d = 0; d < var_rank[i]; d++)
-#line 998
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 998
-                    value[j] = hash_uchar(var_type[i], var_rank[i], index2,
-#line 998
-                        NCT_UCHAR);
-#line 998
+                    value[j] = hash_long(var_type[i], var_rank[i], index2,
+                        NCT_LONG);
                     allInExtRange = allInExtRange
-#line 998
-                        && inRange3(value[j], var_type[i], NCT_UCHAR);
-#line 998
+                        && inRange3(value[j], var_type[i], NCT_LONG);
                 }
-#line 998
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 998
-                    err = nc_put_varm_uchar(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 998
+                    err = nc_put_varm_long(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 998
-                    err = nc_put_varm_uchar(ncid,i,index,count,stride,imap,value);
-#line 998
+                    err = nc_put_varm_long(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 998
                     if (allInExtRange) {
-#line 998
                         IF (err)
-#line 998
                             error("%s", nc_strerror(err));
-#line 998
                     } else {
-#line 998
                         IF (err != NC_ERANGE)
-#line 998
                             error("range error: status = %d", err);
-#line 998
                     }
-#line 998
                 } else {
-#line 998
                     IF (nels > 0 && err != NC_ECHAR)
-#line 998
                         error("wrong type: status = %d", err);
-#line 998
 		}
-#line 998
 	    }
-#line 998
 	}
-#line 998
     }
-#line 998
 
-#line 998
     err = nc_close(ncid);
-#line 998
     IF (err) 
-#line 998
 	error("nc_close: %s", nc_strerror(err));
-#line 998
 
-#line 998
-    check_vars_uchar(scratch);
-#line 998
+    check_vars_long(scratch);
 
-#line 998
     err = remove(scratch);
-#line 998
     IF (err)
-#line 998
         error("remove of %s failed", scratch);
-#line 998
 }
-#line 998
 
 void
-#line 999
-test_nc_put_varm_schar(void)
-#line 999
+test_nc_put_varm_float(void)
 {
-#line 999
     int ncid;
-#line 999
     int d;
-#line 999
     int i;
-#line 999
     int j;
-#line 999
     int k;
-#line 999
     int m;
-#line 999
     int err;
-#line 999
     int nels;
-#line 999
     int nslabs;
-#line 999
     int nstarts;        /* number of different starts */
-#line 999
     size_t start[MAX_RANK];
-#line 999
     size_t edge[MAX_RANK];
-#line 999
     size_t index[MAX_RANK];
-#line 999
     size_t index2[MAX_RANK];
-#line 999
     size_t mid[MAX_RANK];
-#line 999
     size_t count[MAX_RANK];
-#line 999
     size_t sstride[MAX_RANK];
-#line 999
     ptrdiff_t stride[MAX_RANK];
-#line 999
     ptrdiff_t imap[MAX_RANK];
-#line 999
     int canConvert;	/* Both text or both numeric */
-#line 999
     int allInExtRange;	/* all values within external range? */
-#line 999
-    schar value[MAX_NELS];
-#line 999
+    float value[MAX_NELS];
 
-#line 999
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 999
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 999
 	error("nc_create: %s", nc_strerror(err));
-#line 999
 	return;
-#line 999
     }
-#line 999
     def_dims(ncid);
-#line 999
     def_vars(ncid);
-#line 999
     err = nc_enddef(ncid);
-#line 999
     IF (err)
-#line 999
 	error("nc_enddef: %s", nc_strerror(err));
-#line 999
 
-#line 999
-    for (i = 0; i < NVARS; i++) {
-#line 999
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
-#line 999
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 999
 	assert(var_nels[i] <= MAX_NELS);
-#line 999
 	for (j = 0; j < var_rank[i]; j++) {
-#line 999
 	    start[j] = 0;
-#line 999
 	    edge[j] = 1;
-#line 999
 	    stride[j] = 1;
-#line 999
 	    imap[j] = 1;
-#line 999
 	}
-#line 999
-	err = nc_put_varm_schar(BAD_ID, i, start, edge, stride, imap, value);
-#line 999
+	err = nc_put_varm_float(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 999
 	    error("bad ncid: status = %d", err);
-#line 999
-	err = nc_put_varm_schar(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 999
+	err = nc_put_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 999
 	    error("bad var id: status = %d", err);
-#line 999
 	for (j = 0; j < var_rank[i]; j++) {
-#line 999
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 999
 		start[j] = var_shape[i][j] + 1;
-#line 999
-		err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
-#line 999
+		err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 999
 		IF(err != NC_ECHAR)
-#line 999
 			error("conversion: status = %d", err);
-#line 999
 	      } else {
-#line 999
 		IF (err != NC_EINVALCOORDS)
-#line 999
 		    error("bad start: status = %d", err);
-#line 999
 		start[j] = 0;
-#line 999
 		edge[j] = var_shape[i][j] + 1;
-#line 999
-		err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
-#line 999
+		err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 999
 		    error("bad edge: status = %d", err);
-#line 999
 		edge[j] = 1;
-#line 999
 		stride[j] = 0;
-#line 999
-		err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
-#line 999
+		err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 999
 		    error("bad stride: status = %d", err);
-#line 999
 		stride[j] = 1;
-#line 999
 	      }
-#line 999
 	    }
-#line 999
 	}
-#line 999
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 999
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 999
 	nslabs = 1;
-#line 999
 	for (j = 0; j < var_rank[i]; j++) {
-#line 999
 	    mid[j] = roll( var_shape[i][j] );
-#line 999
 	    nslabs *= 2;
-#line 999
 	}
-#line 999
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 999
 	    /* choose random stride from 1 to edge */
-#line 999
 	for (k = 0; k < nslabs; k++) {
-#line 999
 	    nstarts = 1;
-#line 999
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 999
 		if ((k >> j) & 1) {
-#line 999
 		    start[j] = 0;
-#line 999
 		    edge[j] = mid[j];
-#line 999
 		}else{
-#line 999
 		    start[j] = mid[j];
-#line 999
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 999
 		}
-#line 999
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 999
 		nstarts *= stride[j];
-#line 999
 	    }
-#line 999
             for (m = 0; m < nstarts; m++) {
-#line 999
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 999
                 IF (err)
-#line 999
                     error("error in toMixedBase");
-#line 999
                 nels = 1;
-#line 999
                 for (j = 0; j < var_rank[i]; j++) {
-#line 999
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 999
                     nels *= count[j];
-#line 999
                     index[j] += start[j];
-#line 999
                 }
-#line 999
                     /* Random choice of forward or backward */
-#line 999
 /* TODO
-#line 999
                 if ( roll(2) ) {
-#line 999
                     for (j = 0; j < var_rank[i]; j++) {
-#line 999
                         index[j] += (count[j] - 1) * stride[j];
-#line 999
                         stride[j] = -stride[j];
-#line 999
                     }
-#line 999
                 }
-#line 999
 */
-#line 999
                 if (var_rank[i] > 0) {
-#line 999
                     j = var_rank[i] - 1;
-#line 999
                     imap[j] = 1;
-#line 999
                     for (; j > 0; j--)
-#line 999
                         imap[j-1] = imap[j] * count[j];
-#line 999
                 }
-#line 999
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 999
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 999
                     IF (err)
-#line 999
                         error("error in toMixedBase");
-#line 999
                     for (d = 0; d < var_rank[i]; d++)
-#line 999
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 999
-                    value[j] = hash_schar(var_type[i], var_rank[i], index2,
-#line 999
-                        NCT_SCHAR);
-#line 999
+                    value[j] = hash_float(var_type[i], var_rank[i], index2,
+                        NCT_FLOAT);
                     allInExtRange = allInExtRange
-#line 999
-                        && inRange3(value[j], var_type[i], NCT_SCHAR);
-#line 999
+                        && inRange3(value[j], var_type[i], NCT_FLOAT);
                 }
-#line 999
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 999
-                    err = nc_put_varm_schar(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 999
+                    err = nc_put_varm_float(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 999
-                    err = nc_put_varm_schar(ncid,i,index,count,stride,imap,value);
-#line 999
+                    err = nc_put_varm_float(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 999
                     if (allInExtRange) {
-#line 999
                         IF (err)
-#line 999
                             error("%s", nc_strerror(err));
-#line 999
                     } else {
-#line 999
                         IF (err != NC_ERANGE)
-#line 999
                             error("range error: status = %d", err);
-#line 999
                     }
-#line 999
                 } else {
-#line 999
                     IF (nels > 0 && err != NC_ECHAR)
-#line 999
                         error("wrong type: status = %d", err);
-#line 999
 		}
-#line 999
 	    }
-#line 999
 	}
-#line 999
     }
-#line 999
 
-#line 999
     err = nc_close(ncid);
-#line 999
     IF (err) 
-#line 999
 	error("nc_close: %s", nc_strerror(err));
-#line 999
 
-#line 999
-    check_vars_schar(scratch);
-#line 999
+    check_vars_float(scratch);
 
-#line 999
     err = remove(scratch);
-#line 999
     IF (err)
-#line 999
         error("remove of %s failed", scratch);
-#line 999
 }
-#line 999
 
 void
-#line 1000
-test_nc_put_varm_short(void)
-#line 1000
+test_nc_put_varm_double(void)
 {
-#line 1000
     int ncid;
-#line 1000
     int d;
-#line 1000
     int i;
-#line 1000
     int j;
-#line 1000
     int k;
-#line 1000
     int m;
-#line 1000
     int err;
-#line 1000
     int nels;
-#line 1000
     int nslabs;
-#line 1000
     int nstarts;        /* number of different starts */
-#line 1000
     size_t start[MAX_RANK];
-#line 1000
     size_t edge[MAX_RANK];
-#line 1000
     size_t index[MAX_RANK];
-#line 1000
     size_t index2[MAX_RANK];
-#line 1000
     size_t mid[MAX_RANK];
-#line 1000
     size_t count[MAX_RANK];
-#line 1000
     size_t sstride[MAX_RANK];
-#line 1000
     ptrdiff_t stride[MAX_RANK];
-#line 1000
     ptrdiff_t imap[MAX_RANK];
-#line 1000
     int canConvert;	/* Both text or both numeric */
-#line 1000
     int allInExtRange;	/* all values within external range? */
-#line 1000
-    short value[MAX_NELS];
-#line 1000
+    double value[MAX_NELS];
 
-#line 1000
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 1000
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 1000
 	error("nc_create: %s", nc_strerror(err));
-#line 1000
 	return;
-#line 1000
     }
-#line 1000
     def_dims(ncid);
-#line 1000
     def_vars(ncid);
-#line 1000
     err = nc_enddef(ncid);
-#line 1000
     IF (err)
-#line 1000
 	error("nc_enddef: %s", nc_strerror(err));
-#line 1000
 
-#line 1000
-    for (i = 0; i < NVARS; i++) {
-#line 1000
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
-#line 1000
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 1000
 	assert(var_nels[i] <= MAX_NELS);
-#line 1000
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1000
 	    start[j] = 0;
-#line 1000
 	    edge[j] = 1;
-#line 1000
 	    stride[j] = 1;
-#line 1000
 	    imap[j] = 1;
-#line 1000
 	}
-#line 1000
-	err = nc_put_varm_short(BAD_ID, i, start, edge, stride, imap, value);
-#line 1000
+	err = nc_put_varm_double(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 1000
 	    error("bad ncid: status = %d", err);
-#line 1000
-	err = nc_put_varm_short(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 1000
+	err = nc_put_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 1000
 	    error("bad var id: status = %d", err);
-#line 1000
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1000
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 1000
 		start[j] = var_shape[i][j] + 1;
-#line 1000
-		err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
-#line 1000
+		err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 1000
 		IF(err != NC_ECHAR)
-#line 1000
 			error("conversion: status = %d", err);
-#line 1000
 	      } else {
-#line 1000
 		IF (err != NC_EINVALCOORDS)
-#line 1000
 		    error("bad start: status = %d", err);
-#line 1000
 		start[j] = 0;
-#line 1000
 		edge[j] = var_shape[i][j] + 1;
-#line 1000
-		err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
-#line 1000
+		err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 1000
 		    error("bad edge: status = %d", err);
-#line 1000
 		edge[j] = 1;
-#line 1000
 		stride[j] = 0;
-#line 1000
-		err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
-#line 1000
+		err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 1000
 		    error("bad stride: status = %d", err);
-#line 1000
 		stride[j] = 1;
-#line 1000
 	      }
-#line 1000
 	    }
-#line 1000
 	}
-#line 1000
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 1000
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 1000
 	nslabs = 1;
-#line 1000
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1000
 	    mid[j] = roll( var_shape[i][j] );
-#line 1000
 	    nslabs *= 2;
-#line 1000
 	}
-#line 1000
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 1000
 	    /* choose random stride from 1 to edge */
-#line 1000
 	for (k = 0; k < nslabs; k++) {
-#line 1000
 	    nstarts = 1;
-#line 1000
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 1000
 		if ((k >> j) & 1) {
-#line 1000
 		    start[j] = 0;
-#line 1000
 		    edge[j] = mid[j];
-#line 1000
 		}else{
-#line 1000
 		    start[j] = mid[j];
-#line 1000
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 1000
 		}
-#line 1000
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 1000
 		nstarts *= stride[j];
-#line 1000
 	    }
-#line 1000
             for (m = 0; m < nstarts; m++) {
-#line 1000
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 1000
                 IF (err)
-#line 1000
                     error("error in toMixedBase");
-#line 1000
                 nels = 1;
-#line 1000
                 for (j = 0; j < var_rank[i]; j++) {
-#line 1000
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 1000
                     nels *= count[j];
-#line 1000
                     index[j] += start[j];
-#line 1000
                 }
-#line 1000
                     /* Random choice of forward or backward */
-#line 1000
 /* TODO
-#line 1000
                 if ( roll(2) ) {
-#line 1000
                     for (j = 0; j < var_rank[i]; j++) {
-#line 1000
                         index[j] += (count[j] - 1) * stride[j];
-#line 1000
                         stride[j] = -stride[j];
-#line 1000
                     }
-#line 1000
                 }
-#line 1000
 */
-#line 1000
                 if (var_rank[i] > 0) {
-#line 1000
                     j = var_rank[i] - 1;
-#line 1000
                     imap[j] = 1;
-#line 1000
                     for (; j > 0; j--)
-#line 1000
                         imap[j-1] = imap[j] * count[j];
-#line 1000
                 }
-#line 1000
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 1000
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 1000
                     IF (err)
-#line 1000
                         error("error in toMixedBase");
-#line 1000
                     for (d = 0; d < var_rank[i]; d++)
-#line 1000
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 1000
-                    value[j] = hash_short(var_type[i], var_rank[i], index2,
-#line 1000
-                        NCT_SHORT);
-#line 1000
+                    value[j] = hash_double(var_type[i], var_rank[i], index2,
+                        NCT_DOUBLE);
                     allInExtRange = allInExtRange
-#line 1000
-                        && inRange3(value[j], var_type[i], NCT_SHORT);
-#line 1000
+                        && inRange3(value[j], var_type[i], NCT_DOUBLE);
                 }
-#line 1000
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 1000
-                    err = nc_put_varm_short(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 1000
+                    err = nc_put_varm_double(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 1000
-                    err = nc_put_varm_short(ncid,i,index,count,stride,imap,value);
-#line 1000
+                    err = nc_put_varm_double(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 1000
                     if (allInExtRange) {
-#line 1000
                         IF (err)
-#line 1000
                             error("%s", nc_strerror(err));
-#line 1000
                     } else {
-#line 1000
                         IF (err != NC_ERANGE)
-#line 1000
                             error("range error: status = %d", err);
-#line 1000
                     }
-#line 1000
                 } else {
-#line 1000
                     IF (nels > 0 && err != NC_ECHAR)
-#line 1000
                         error("wrong type: status = %d", err);
-#line 1000
 		}
-#line 1000
 	    }
-#line 1000
 	}
-#line 1000
     }
-#line 1000
 
-#line 1000
     err = nc_close(ncid);
-#line 1000
     IF (err) 
-#line 1000
 	error("nc_close: %s", nc_strerror(err));
-#line 1000
 
-#line 1000
-    check_vars_short(scratch);
-#line 1000
+    check_vars_double(scratch);
 
-#line 1000
     err = remove(scratch);
-#line 1000
     IF (err)
-#line 1000
         error("remove of %s failed", scratch);
-#line 1000
 }
-#line 1000
 
 void
-#line 1001
-test_nc_put_varm_int(void)
-#line 1001
+test_nc_put_varm_ushort(void)
 {
-#line 1001
     int ncid;
-#line 1001
     int d;
-#line 1001
     int i;
-#line 1001
     int j;
-#line 1001
     int k;
-#line 1001
     int m;
-#line 1001
     int err;
-#line 1001
     int nels;
-#line 1001
     int nslabs;
-#line 1001
     int nstarts;        /* number of different starts */
-#line 1001
     size_t start[MAX_RANK];
-#line 1001
     size_t edge[MAX_RANK];
-#line 1001
     size_t index[MAX_RANK];
-#line 1001
     size_t index2[MAX_RANK];
-#line 1001
     size_t mid[MAX_RANK];
-#line 1001
     size_t count[MAX_RANK];
-#line 1001
     size_t sstride[MAX_RANK];
-#line 1001
     ptrdiff_t stride[MAX_RANK];
-#line 1001
     ptrdiff_t imap[MAX_RANK];
-#line 1001
     int canConvert;	/* Both text or both numeric */
-#line 1001
     int allInExtRange;	/* all values within external range? */
-#line 1001
-    int value[MAX_NELS];
-#line 1001
+    ushort value[MAX_NELS];
 
-#line 1001
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 1001
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 1001
 	error("nc_create: %s", nc_strerror(err));
-#line 1001
 	return;
-#line 1001
     }
-#line 1001
     def_dims(ncid);
-#line 1001
     def_vars(ncid);
-#line 1001
     err = nc_enddef(ncid);
-#line 1001
     IF (err)
-#line 1001
 	error("nc_enddef: %s", nc_strerror(err));
-#line 1001
 
-#line 1001
-    for (i = 0; i < NVARS; i++) {
-#line 1001
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
-#line 1001
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_USHORT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 1001
 	assert(var_nels[i] <= MAX_NELS);
-#line 1001
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1001
 	    start[j] = 0;
-#line 1001
 	    edge[j] = 1;
-#line 1001
 	    stride[j] = 1;
-#line 1001
 	    imap[j] = 1;
-#line 1001
 	}
-#line 1001
-	err = nc_put_varm_int(BAD_ID, i, start, edge, stride, imap, value);
-#line 1001
+	err = nc_put_varm_ushort(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 1001
 	    error("bad ncid: status = %d", err);
-#line 1001
-	err = nc_put_varm_int(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 1001
+	err = nc_put_varm_ushort(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 1001
 	    error("bad var id: status = %d", err);
-#line 1001
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1001
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 1001
 		start[j] = var_shape[i][j] + 1;
-#line 1001
-		err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
-#line 1001
+		err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 1001
 		IF(err != NC_ECHAR)
-#line 1001
 			error("conversion: status = %d", err);
-#line 1001
 	      } else {
-#line 1001
 		IF (err != NC_EINVALCOORDS)
-#line 1001
 		    error("bad start: status = %d", err);
-#line 1001
 		start[j] = 0;
-#line 1001
 		edge[j] = var_shape[i][j] + 1;
-#line 1001
-		err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
-#line 1001
+		err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 1001
 		    error("bad edge: status = %d", err);
-#line 1001
 		edge[j] = 1;
-#line 1001
 		stride[j] = 0;
-#line 1001
-		err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
-#line 1001
+		err = nc_put_varm_ushort(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 1001
 		    error("bad stride: status = %d", err);
-#line 1001
 		stride[j] = 1;
-#line 1001
 	      }
-#line 1001
 	    }
-#line 1001
 	}
-#line 1001
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 1001
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 1001
 	nslabs = 1;
-#line 1001
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1001
 	    mid[j] = roll( var_shape[i][j] );
-#line 1001
 	    nslabs *= 2;
-#line 1001
 	}
-#line 1001
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 1001
 	    /* choose random stride from 1 to edge */
-#line 1001
 	for (k = 0; k < nslabs; k++) {
-#line 1001
 	    nstarts = 1;
-#line 1001
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 1001
 		if ((k >> j) & 1) {
-#line 1001
 		    start[j] = 0;
-#line 1001
 		    edge[j] = mid[j];
-#line 1001
 		}else{
-#line 1001
 		    start[j] = mid[j];
-#line 1001
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 1001
 		}
-#line 1001
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 1001
 		nstarts *= stride[j];
-#line 1001
 	    }
-#line 1001
             for (m = 0; m < nstarts; m++) {
-#line 1001
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 1001
                 IF (err)
-#line 1001
                     error("error in toMixedBase");
-#line 1001
                 nels = 1;
-#line 1001
                 for (j = 0; j < var_rank[i]; j++) {
-#line 1001
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 1001
                     nels *= count[j];
-#line 1001
                     index[j] += start[j];
-#line 1001
                 }
-#line 1001
                     /* Random choice of forward or backward */
-#line 1001
 /* TODO
-#line 1001
                 if ( roll(2) ) {
-#line 1001
                     for (j = 0; j < var_rank[i]; j++) {
-#line 1001
                         index[j] += (count[j] - 1) * stride[j];
-#line 1001
                         stride[j] = -stride[j];
-#line 1001
                     }
-#line 1001
                 }
-#line 1001
 */
-#line 1001
                 if (var_rank[i] > 0) {
-#line 1001
                     j = var_rank[i] - 1;
-#line 1001
                     imap[j] = 1;
-#line 1001
                     for (; j > 0; j--)
-#line 1001
                         imap[j-1] = imap[j] * count[j];
-#line 1001
                 }
-#line 1001
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 1001
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 1001
                     IF (err)
-#line 1001
                         error("error in toMixedBase");
-#line 1001
                     for (d = 0; d < var_rank[i]; d++)
-#line 1001
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 1001
-                    value[j] = hash_int(var_type[i], var_rank[i], index2,
-#line 1001
-                        NCT_INT);
-#line 1001
+                    value[j] = hash_ushort(var_type[i], var_rank[i], index2,
+                        NCT_USHORT);
                     allInExtRange = allInExtRange
-#line 1001
-                        && inRange3(value[j], var_type[i], NCT_INT);
-#line 1001
+                        && inRange3(value[j], var_type[i], NCT_USHORT);
                 }
-#line 1001
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 1001
-                    err = nc_put_varm_int(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 1001
+                    err = nc_put_varm_ushort(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 1001
-                    err = nc_put_varm_int(ncid,i,index,count,stride,imap,value);
-#line 1001
+                    err = nc_put_varm_ushort(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 1001
                     if (allInExtRange) {
-#line 1001
                         IF (err)
-#line 1001
                             error("%s", nc_strerror(err));
-#line 1001
                     } else {
-#line 1001
                         IF (err != NC_ERANGE)
-#line 1001
                             error("range error: status = %d", err);
-#line 1001
                     }
-#line 1001
                 } else {
-#line 1001
                     IF (nels > 0 && err != NC_ECHAR)
-#line 1001
                         error("wrong type: status = %d", err);
-#line 1001
 		}
-#line 1001
 	    }
-#line 1001
 	}
-#line 1001
     }
-#line 1001
 
-#line 1001
     err = nc_close(ncid);
-#line 1001
     IF (err) 
-#line 1001
 	error("nc_close: %s", nc_strerror(err));
-#line 1001
 
-#line 1001
-    check_vars_int(scratch);
-#line 1001
+    check_vars_ushort(scratch);
 
-#line 1001
     err = remove(scratch);
-#line 1001
     IF (err)
-#line 1001
         error("remove of %s failed", scratch);
-#line 1001
 }
-#line 1001
 
 void
-#line 1002
-test_nc_put_varm_long(void)
-#line 1002
+test_nc_put_varm_uint(void)
 {
-#line 1002
     int ncid;
-#line 1002
     int d;
-#line 1002
     int i;
-#line 1002
     int j;
-#line 1002
     int k;
-#line 1002
     int m;
-#line 1002
     int err;
-#line 1002
     int nels;
-#line 1002
     int nslabs;
-#line 1002
     int nstarts;        /* number of different starts */
-#line 1002
     size_t start[MAX_RANK];
-#line 1002
     size_t edge[MAX_RANK];
-#line 1002
     size_t index[MAX_RANK];
-#line 1002
     size_t index2[MAX_RANK];
-#line 1002
     size_t mid[MAX_RANK];
-#line 1002
     size_t count[MAX_RANK];
-#line 1002
     size_t sstride[MAX_RANK];
-#line 1002
     ptrdiff_t stride[MAX_RANK];
-#line 1002
     ptrdiff_t imap[MAX_RANK];
-#line 1002
     int canConvert;	/* Both text or both numeric */
-#line 1002
     int allInExtRange;	/* all values within external range? */
-#line 1002
-    long value[MAX_NELS];
-#line 1002
+    uint value[MAX_NELS];
 
-#line 1002
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 1002
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 1002
 	error("nc_create: %s", nc_strerror(err));
-#line 1002
 	return;
-#line 1002
     }
-#line 1002
     def_dims(ncid);
-#line 1002
     def_vars(ncid);
-#line 1002
     err = nc_enddef(ncid);
-#line 1002
     IF (err)
-#line 1002
 	error("nc_enddef: %s", nc_strerror(err));
-#line 1002
 
-#line 1002
-    for (i = 0; i < NVARS; i++) {
-#line 1002
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
-#line 1002
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_UINT == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 1002
 	assert(var_nels[i] <= MAX_NELS);
-#line 1002
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1002
 	    start[j] = 0;
-#line 1002
 	    edge[j] = 1;
-#line 1002
 	    stride[j] = 1;
-#line 1002
 	    imap[j] = 1;
-#line 1002
 	}
-#line 1002
-	err = nc_put_varm_long(BAD_ID, i, start, edge, stride, imap, value);
-#line 1002
+	err = nc_put_varm_uint(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 1002
 	    error("bad ncid: status = %d", err);
-#line 1002
-	err = nc_put_varm_long(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 1002
+	err = nc_put_varm_uint(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 1002
 	    error("bad var id: status = %d", err);
-#line 1002
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1002
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 1002
 		start[j] = var_shape[i][j] + 1;
-#line 1002
-		err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
-#line 1002
+		err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 1002
 		IF(err != NC_ECHAR)
-#line 1002
 			error("conversion: status = %d", err);
-#line 1002
 	      } else {
-#line 1002
 		IF (err != NC_EINVALCOORDS)
-#line 1002
 		    error("bad start: status = %d", err);
-#line 1002
 		start[j] = 0;
-#line 1002
 		edge[j] = var_shape[i][j] + 1;
-#line 1002
-		err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
-#line 1002
+		err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 1002
 		    error("bad edge: status = %d", err);
-#line 1002
 		edge[j] = 1;
-#line 1002
 		stride[j] = 0;
-#line 1002
-		err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
-#line 1002
+		err = nc_put_varm_uint(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 1002
 		    error("bad stride: status = %d", err);
-#line 1002
 		stride[j] = 1;
-#line 1002
 	      }
-#line 1002
 	    }
-#line 1002
 	}
-#line 1002
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 1002
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 1002
 	nslabs = 1;
-#line 1002
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1002
 	    mid[j] = roll( var_shape[i][j] );
-#line 1002
 	    nslabs *= 2;
-#line 1002
 	}
-#line 1002
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 1002
 	    /* choose random stride from 1 to edge */
-#line 1002
 	for (k = 0; k < nslabs; k++) {
-#line 1002
 	    nstarts = 1;
-#line 1002
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 1002
 		if ((k >> j) & 1) {
-#line 1002
 		    start[j] = 0;
-#line 1002
 		    edge[j] = mid[j];
-#line 1002
 		}else{
-#line 1002
 		    start[j] = mid[j];
-#line 1002
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 1002
 		}
-#line 1002
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 1002
 		nstarts *= stride[j];
-#line 1002
 	    }
-#line 1002
             for (m = 0; m < nstarts; m++) {
-#line 1002
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 1002
                 IF (err)
-#line 1002
                     error("error in toMixedBase");
-#line 1002
                 nels = 1;
-#line 1002
                 for (j = 0; j < var_rank[i]; j++) {
-#line 1002
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 1002
                     nels *= count[j];
-#line 1002
                     index[j] += start[j];
-#line 1002
                 }
-#line 1002
                     /* Random choice of forward or backward */
-#line 1002
 /* TODO
-#line 1002
                 if ( roll(2) ) {
-#line 1002
                     for (j = 0; j < var_rank[i]; j++) {
-#line 1002
                         index[j] += (count[j] - 1) * stride[j];
-#line 1002
                         stride[j] = -stride[j];
-#line 1002
                     }
-#line 1002
                 }
-#line 1002
 */
-#line 1002
                 if (var_rank[i] > 0) {
-#line 1002
                     j = var_rank[i] - 1;
-#line 1002
                     imap[j] = 1;
-#line 1002
                     for (; j > 0; j--)
-#line 1002
                         imap[j-1] = imap[j] * count[j];
-#line 1002
                 }
-#line 1002
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 1002
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 1002
                     IF (err)
-#line 1002
                         error("error in toMixedBase");
-#line 1002
                     for (d = 0; d < var_rank[i]; d++)
-#line 1002
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 1002
-                    value[j] = hash_long(var_type[i], var_rank[i], index2,
-#line 1002
-                        NCT_LONG);
-#line 1002
+                    value[j] = hash_uint(var_type[i], var_rank[i], index2,
+                        NCT_UINT);
                     allInExtRange = allInExtRange
-#line 1002
-                        && inRange3(value[j], var_type[i], NCT_LONG);
-#line 1002
+                        && inRange3(value[j], var_type[i], NCT_UINT);
                 }
-#line 1002
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 1002
-                    err = nc_put_varm_long(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 1002
+                    err = nc_put_varm_uint(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 1002
-                    err = nc_put_varm_long(ncid,i,index,count,stride,imap,value);
-#line 1002
+                    err = nc_put_varm_uint(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 1002
                     if (allInExtRange) {
-#line 1002
                         IF (err)
-#line 1002
                             error("%s", nc_strerror(err));
-#line 1002
                     } else {
-#line 1002
                         IF (err != NC_ERANGE)
-#line 1002
                             error("range error: status = %d", err);
-#line 1002
                     }
-#line 1002
                 } else {
-#line 1002
                     IF (nels > 0 && err != NC_ECHAR)
-#line 1002
                         error("wrong type: status = %d", err);
-#line 1002
 		}
-#line 1002
 	    }
-#line 1002
 	}
-#line 1002
     }
-#line 1002
 
-#line 1002
     err = nc_close(ncid);
-#line 1002
     IF (err) 
-#line 1002
 	error("nc_close: %s", nc_strerror(err));
-#line 1002
 
-#line 1002
-    check_vars_long(scratch);
-#line 1002
+    check_vars_uint(scratch);
 
-#line 1002
     err = remove(scratch);
-#line 1002
     IF (err)
-#line 1002
         error("remove of %s failed", scratch);
-#line 1002
 }
-#line 1002
 
 void
-#line 1003
-test_nc_put_varm_float(void)
-#line 1003
+test_nc_put_varm_longlong(void)
 {
-#line 1003
     int ncid;
-#line 1003
     int d;
-#line 1003
     int i;
-#line 1003
     int j;
-#line 1003
     int k;
-#line 1003
     int m;
-#line 1003
     int err;
-#line 1003
     int nels;
-#line 1003
     int nslabs;
-#line 1003
     int nstarts;        /* number of different starts */
-#line 1003
     size_t start[MAX_RANK];
-#line 1003
     size_t edge[MAX_RANK];
-#line 1003
     size_t index[MAX_RANK];
-#line 1003
     size_t index2[MAX_RANK];
-#line 1003
     size_t mid[MAX_RANK];
-#line 1003
     size_t count[MAX_RANK];
-#line 1003
     size_t sstride[MAX_RANK];
-#line 1003
     ptrdiff_t stride[MAX_RANK];
-#line 1003
     ptrdiff_t imap[MAX_RANK];
-#line 1003
     int canConvert;	/* Both text or both numeric */
-#line 1003
     int allInExtRange;	/* all values within external range? */
-#line 1003
-    float value[MAX_NELS];
-#line 1003
+    longlong value[MAX_NELS];
 
-#line 1003
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 1003
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 1003
 	error("nc_create: %s", nc_strerror(err));
-#line 1003
 	return;
-#line 1003
     }
-#line 1003
     def_dims(ncid);
-#line 1003
     def_vars(ncid);
-#line 1003
     err = nc_enddef(ncid);
-#line 1003
     IF (err)
-#line 1003
 	error("nc_enddef: %s", nc_strerror(err));
-#line 1003
 
-#line 1003
-    for (i = 0; i < NVARS; i++) {
-#line 1003
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
-#line 1003
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_LONGLONG == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 1003
 	assert(var_nels[i] <= MAX_NELS);
-#line 1003
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1003
 	    start[j] = 0;
-#line 1003
 	    edge[j] = 1;
-#line 1003
 	    stride[j] = 1;
-#line 1003
 	    imap[j] = 1;
-#line 1003
 	}
-#line 1003
-	err = nc_put_varm_float(BAD_ID, i, start, edge, stride, imap, value);
-#line 1003
+	err = nc_put_varm_longlong(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 1003
 	    error("bad ncid: status = %d", err);
-#line 1003
-	err = nc_put_varm_float(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 1003
+	err = nc_put_varm_longlong(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 1003
 	    error("bad var id: status = %d", err);
-#line 1003
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1003
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 1003
 		start[j] = var_shape[i][j] + 1;
-#line 1003
-		err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
-#line 1003
+		err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 1003
 		IF(err != NC_ECHAR)
-#line 1003
 			error("conversion: status = %d", err);
-#line 1003
 	      } else {
-#line 1003
 		IF (err != NC_EINVALCOORDS)
-#line 1003
 		    error("bad start: status = %d", err);
-#line 1003
 		start[j] = 0;
-#line 1003
 		edge[j] = var_shape[i][j] + 1;
-#line 1003
-		err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
-#line 1003
+		err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 1003
 		    error("bad edge: status = %d", err);
-#line 1003
 		edge[j] = 1;
-#line 1003
 		stride[j] = 0;
-#line 1003
-		err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
-#line 1003
+		err = nc_put_varm_longlong(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 1003
 		    error("bad stride: status = %d", err);
-#line 1003
 		stride[j] = 1;
-#line 1003
 	      }
-#line 1003
 	    }
-#line 1003
 	}
-#line 1003
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 1003
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 1003
 	nslabs = 1;
-#line 1003
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1003
 	    mid[j] = roll( var_shape[i][j] );
-#line 1003
 	    nslabs *= 2;
-#line 1003
 	}
-#line 1003
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 1003
 	    /* choose random stride from 1 to edge */
-#line 1003
 	for (k = 0; k < nslabs; k++) {
-#line 1003
 	    nstarts = 1;
-#line 1003
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 1003
 		if ((k >> j) & 1) {
-#line 1003
 		    start[j] = 0;
-#line 1003
 		    edge[j] = mid[j];
-#line 1003
 		}else{
-#line 1003
 		    start[j] = mid[j];
-#line 1003
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 1003
 		}
-#line 1003
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 1003
 		nstarts *= stride[j];
-#line 1003
 	    }
-#line 1003
             for (m = 0; m < nstarts; m++) {
-#line 1003
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 1003
                 IF (err)
-#line 1003
                     error("error in toMixedBase");
-#line 1003
                 nels = 1;
-#line 1003
                 for (j = 0; j < var_rank[i]; j++) {
-#line 1003
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 1003
                     nels *= count[j];
-#line 1003
                     index[j] += start[j];
-#line 1003
                 }
-#line 1003
                     /* Random choice of forward or backward */
-#line 1003
 /* TODO
-#line 1003
                 if ( roll(2) ) {
-#line 1003
                     for (j = 0; j < var_rank[i]; j++) {
-#line 1003
                         index[j] += (count[j] - 1) * stride[j];
-#line 1003
                         stride[j] = -stride[j];
-#line 1003
                     }
-#line 1003
                 }
-#line 1003
 */
-#line 1003
                 if (var_rank[i] > 0) {
-#line 1003
                     j = var_rank[i] - 1;
-#line 1003
                     imap[j] = 1;
-#line 1003
                     for (; j > 0; j--)
-#line 1003
                         imap[j-1] = imap[j] * count[j];
-#line 1003
                 }
-#line 1003
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 1003
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 1003
                     IF (err)
-#line 1003
                         error("error in toMixedBase");
-#line 1003
                     for (d = 0; d < var_rank[i]; d++)
-#line 1003
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 1003
-                    value[j] = hash_float(var_type[i], var_rank[i], index2,
-#line 1003
-                        NCT_FLOAT);
-#line 1003
+                    value[j] = hash_longlong(var_type[i], var_rank[i], index2,
+                        NCT_LONGLONG);
                     allInExtRange = allInExtRange
-#line 1003
-                        && inRange3(value[j], var_type[i], NCT_FLOAT);
-#line 1003
+                        && inRange3(value[j], var_type[i], NCT_LONGLONG);
                 }
-#line 1003
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 1003
-                    err = nc_put_varm_float(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 1003
+                    err = nc_put_varm_longlong(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 1003
-                    err = nc_put_varm_float(ncid,i,index,count,stride,imap,value);
-#line 1003
+                    err = nc_put_varm_longlong(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 1003
                     if (allInExtRange) {
-#line 1003
                         IF (err)
-#line 1003
                             error("%s", nc_strerror(err));
-#line 1003
                     } else {
-#line 1003
                         IF (err != NC_ERANGE)
-#line 1003
                             error("range error: status = %d", err);
-#line 1003
                     }
-#line 1003
                 } else {
-#line 1003
                     IF (nels > 0 && err != NC_ECHAR)
-#line 1003
                         error("wrong type: status = %d", err);
-#line 1003
 		}
-#line 1003
 	    }
-#line 1003
 	}
-#line 1003
     }
-#line 1003
 
-#line 1003
     err = nc_close(ncid);
-#line 1003
     IF (err) 
-#line 1003
 	error("nc_close: %s", nc_strerror(err));
-#line 1003
 
-#line 1003
-    check_vars_float(scratch);
-#line 1003
+    check_vars_longlong(scratch);
 
-#line 1003
     err = remove(scratch);
-#line 1003
     IF (err)
-#line 1003
         error("remove of %s failed", scratch);
-#line 1003
 }
-#line 1003
 
 void
-#line 1004
-test_nc_put_varm_double(void)
-#line 1004
+test_nc_put_varm_ulonglong(void)
 {
-#line 1004
     int ncid;
-#line 1004
     int d;
-#line 1004
     int i;
-#line 1004
     int j;
-#line 1004
     int k;
-#line 1004
     int m;
-#line 1004
     int err;
-#line 1004
     int nels;
-#line 1004
     int nslabs;
-#line 1004
     int nstarts;        /* number of different starts */
-#line 1004
     size_t start[MAX_RANK];
-#line 1004
     size_t edge[MAX_RANK];
-#line 1004
     size_t index[MAX_RANK];
-#line 1004
     size_t index2[MAX_RANK];
-#line 1004
     size_t mid[MAX_RANK];
-#line 1004
     size_t count[MAX_RANK];
-#line 1004
     size_t sstride[MAX_RANK];
-#line 1004
     ptrdiff_t stride[MAX_RANK];
-#line 1004
     ptrdiff_t imap[MAX_RANK];
-#line 1004
     int canConvert;	/* Both text or both numeric */
-#line 1004
     int allInExtRange;	/* all values within external range? */
-#line 1004
-    double value[MAX_NELS];
-#line 1004
+    ulonglong value[MAX_NELS];
 
-#line 1004
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
-#line 1004
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
-#line 1004
 	error("nc_create: %s", nc_strerror(err));
-#line 1004
 	return;
-#line 1004
     }
-#line 1004
     def_dims(ncid);
-#line 1004
     def_vars(ncid);
-#line 1004
     err = nc_enddef(ncid);
-#line 1004
     IF (err)
-#line 1004
 	error("nc_enddef: %s", nc_strerror(err));
-#line 1004
 
-#line 1004
-    for (i = 0; i < NVARS; i++) {
-#line 1004
-	canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
-#line 1004
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
+	canConvert = (var_type[i] == NC_CHAR) == (NCT_ULONGLONG == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
-#line 1004
 	assert(var_nels[i] <= MAX_NELS);
-#line 1004
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1004
 	    start[j] = 0;
-#line 1004
 	    edge[j] = 1;
-#line 1004
 	    stride[j] = 1;
-#line 1004
 	    imap[j] = 1;
-#line 1004
 	}
-#line 1004
-	err = nc_put_varm_double(BAD_ID, i, start, edge, stride, imap, value);
-#line 1004
+	err = nc_put_varm_ulonglong(BAD_ID, i, start, edge, stride, imap, value);
 	IF (err != NC_EBADID) 
-#line 1004
 	    error("bad ncid: status = %d", err);
-#line 1004
-	err = nc_put_varm_double(ncid, BAD_VARID, start, edge, stride, imap, value);
-#line 1004
+	err = nc_put_varm_ulonglong(ncid, BAD_VARID, start, edge, stride, imap, value);
 	IF (err != NC_ENOTVAR) 
-#line 1004
 	    error("bad var id: status = %d", err);
-#line 1004
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1004
 	    if (var_dimid[i][j] > 0) {		/* skip record dim */
-#line 1004
 		start[j] = var_shape[i][j] + 1;
-#line 1004
-		err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
-#line 1004
+		err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
 	      if (!canConvert) {
-#line 1004
 		IF(err != NC_ECHAR)
-#line 1004
 			error("conversion: status = %d", err);
-#line 1004
 	      } else {
-#line 1004
 		IF (err != NC_EINVALCOORDS)
-#line 1004
 		    error("bad start: status = %d", err);
-#line 1004
 		start[j] = 0;
-#line 1004
 		edge[j] = var_shape[i][j] + 1;
-#line 1004
-		err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
-#line 1004
+		err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_EEDGE)
-#line 1004
 		    error("bad edge: status = %d", err);
-#line 1004
 		edge[j] = 1;
-#line 1004
 		stride[j] = 0;
-#line 1004
-		err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
-#line 1004
+		err = nc_put_varm_ulonglong(ncid, i, start, edge, stride, imap, value);
 		IF (err != NC_ESTRIDE)
-#line 1004
 		    error("bad stride: status = %d", err);
-#line 1004
 		stride[j] = 1;
-#line 1004
 	      }
-#line 1004
 	    }
-#line 1004
 	}
-#line 1004
 	    /* Choose a random point dividing each dim into 2 parts */
-#line 1004
 	    /* Put 2^rank (nslabs) slabs so defined */
-#line 1004
 	nslabs = 1;
-#line 1004
 	for (j = 0; j < var_rank[i]; j++) {
-#line 1004
 	    mid[j] = roll( var_shape[i][j] );
-#line 1004
 	    nslabs *= 2;
-#line 1004
 	}
-#line 1004
 	    /* bits of k determine whether to put lower or upper part of dim */
-#line 1004
 	    /* choose random stride from 1 to edge */
-#line 1004
 	for (k = 0; k < nslabs; k++) {
-#line 1004
 	    nstarts = 1;
-#line 1004
 	    for (j = 0; j < var_rank[i]; j++) {
-#line 1004
 		if ((k >> j) & 1) {
-#line 1004
 		    start[j] = 0;
-#line 1004
 		    edge[j] = mid[j];
-#line 1004
 		}else{
-#line 1004
 		    start[j] = mid[j];
-#line 1004
 		    edge[j] = var_shape[i][j] - mid[j];
-#line 1004
 		}
-#line 1004
 		sstride[j] = stride[j] = edge[j] > 0 ? 1+roll(edge[j]) : 1;
-#line 1004
 		nstarts *= stride[j];
-#line 1004
 	    }
-#line 1004
             for (m = 0; m < nstarts; m++) {
-#line 1004
                 err = toMixedBase(m, var_rank[i], sstride, index);
-#line 1004
                 IF (err)
-#line 1004
                     error("error in toMixedBase");
-#line 1004
                 nels = 1;
-#line 1004
                 for (j = 0; j < var_rank[i]; j++) {
-#line 1004
                     count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
-#line 1004
                     nels *= count[j];
-#line 1004
                     index[j] += start[j];
-#line 1004
                 }
-#line 1004
                     /* Random choice of forward or backward */
-#line 1004
 /* TODO
-#line 1004
                 if ( roll(2) ) {
-#line 1004
                     for (j = 0; j < var_rank[i]; j++) {
-#line 1004
                         index[j] += (count[j] - 1) * stride[j];
-#line 1004
                         stride[j] = -stride[j];
-#line 1004
                     }
-#line 1004
                 }
-#line 1004
 */
-#line 1004
                 if (var_rank[i] > 0) {
-#line 1004
                     j = var_rank[i] - 1;
-#line 1004
                     imap[j] = 1;
-#line 1004
                     for (; j > 0; j--)
-#line 1004
                         imap[j-1] = imap[j] * count[j];
-#line 1004
                 }
-#line 1004
                 for (allInExtRange = 1, j = 0; j < nels; j++) {
-#line 1004
                     err = toMixedBase(j, var_rank[i], count, index2);
-#line 1004
                     IF (err)
-#line 1004
                         error("error in toMixedBase");
-#line 1004
                     for (d = 0; d < var_rank[i]; d++)
-#line 1004
                         index2[d] = index[d] + index2[d] * stride[d];
-#line 1004
-                    value[j] = hash_double(var_type[i], var_rank[i], index2,
-#line 1004
-                        NCT_DOUBLE);
-#line 1004
+                    value[j] = hash_ulonglong(var_type[i], var_rank[i], index2,
+                        NCT_ULONGLONG);
                     allInExtRange = allInExtRange
-#line 1004
-                        && inRange3(value[j], var_type[i], NCT_DOUBLE);
-#line 1004
+                        && inRange3(value[j], var_type[i], NCT_ULONGLONG);
                 }
-#line 1004
                 if (var_rank[i] == 0 && i%2 == 0)
-#line 1004
-                    err = nc_put_varm_double(ncid,i,NULL,NULL,NULL,NULL,value);
-#line 1004
+                    err = nc_put_varm_ulonglong(ncid,i,NULL,NULL,NULL,NULL,value);
                 else
-#line 1004
-                    err = nc_put_varm_double(ncid,i,index,count,stride,imap,value);
-#line 1004
+                    err = nc_put_varm_ulonglong(ncid,i,index,count,stride,imap,value);
                 if (canConvert) {
-#line 1004
                     if (allInExtRange) {
-#line 1004
                         IF (err)
-#line 1004
                             error("%s", nc_strerror(err));
-#line 1004
                     } else {
-#line 1004
                         IF (err != NC_ERANGE)
-#line 1004
                             error("range error: status = %d", err);
-#line 1004
                     }
-#line 1004
                 } else {
-#line 1004
                     IF (nels > 0 && err != NC_ECHAR)
-#line 1004
                         error("wrong type: status = %d", err);
-#line 1004
 		}
-#line 1004
 	    }
-#line 1004
 	}
-#line 1004
     }
-#line 1004
 
-#line 1004
     err = nc_close(ncid);
-#line 1004
     IF (err) 
-#line 1004
 	error("nc_close: %s", nc_strerror(err));
-#line 1004
 
-#line 1004
-    check_vars_double(scratch);
-#line 1004
+    check_vars_ulonglong(scratch);
 
-#line 1004
     err = remove(scratch);
-#line 1004
     IF (err)
-#line 1004
         error("remove of %s failed", scratch);
-#line 1004
 }
-#line 1004
 
 
 
@@ -13637,7 +11194,7 @@ test_nc_put_att_text(void)
     int err;
     text value[MAX_NELS];
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -13653,7 +11210,7 @@ test_nc_put_att_text(void)
 	IF (err != NC_EBADNAME)
 	   error("should be NC_EBADNAME: status = %d", err);
     }
-    for (i = -1; i < NVARS; i++) {
+    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);
@@ -13688,881 +11245,698 @@ test_nc_put_att_text(void)
 }
 
 
-#line 1135
 
 void
-#line 1136
 test_nc_put_att_uchar(void)
-#line 1136
 {
-#line 1136
     int ncid;
-#line 1136
     int i;
-#line 1136
     int j;
-#line 1136
     size_t k;
-#line 1136
     int err;
-#line 1136
     uchar value[MAX_NELS];
-#line 1136
     int allInExtRange;  /* all values within external range? */
-#line 1136
 
-#line 1136
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1136
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1136
         error("nc_create: %s", nc_strerror(err));
-#line 1136
         return;
-#line 1136
     }
-#line 1136
     def_dims(ncid);
-#line 1136
     def_vars(ncid);
-#line 1136
 
-#line 1136
-    for (i = -1; i < NVARS; i++) {
-#line 1136
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1136
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1136
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1136
 		err = nc_put_att_uchar(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1136
 		    ATT_LEN(i,j), value);
-#line 1136
 		IF (err != NC_EBADID)
-#line 1136
 		    error("bad ncid: status = %d", err);
-#line 1136
 		err = nc_put_att_uchar(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1136
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1136
 		IF (err != NC_ENOTVAR)
-#line 1136
 		    error("bad var id: status = %d", err);
-#line 1136
 		err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1136
 		    ATT_LEN(i,j), value);
-#line 1136
 		IF (err != NC_EBADTYPE)
-#line 1136
 		    error("bad type: status = %d", err);
-#line 1136
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1136
 		    value[k] = hash_uchar(ATT_TYPE(i,j), -1, &k, NCT_UCHAR);
-#line 1136
 		    allInExtRange = allInExtRange
-#line 1136
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_UCHAR);
-#line 1136
 		}
-#line 1136
 		err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1136
 		    ATT_LEN(i,j), value);
-#line 1136
 		if (allInExtRange) {
-#line 1136
 		    IF (err)
-#line 1136
 			error("%s", nc_strerror(err));
-#line 1136
 		} else {
-#line 1136
                     IF (err != NC_ERANGE)
-#line 1136
                         error("range error: status = %d", err);
-#line 1136
 		}
-#line 1136
 	    }
-#line 1136
         }
-#line 1136
     }
-#line 1136
 
-#line 1136
     check_atts_uchar(ncid);
-#line 1136
     err = nc_close(ncid);
-#line 1136
     IF (err)
-#line 1136
         error("nc_close: %s", nc_strerror(err));
-#line 1136
 
-#line 1136
     err = remove(scratch);
-#line 1136
     IF (err)
-#line 1136
         error("remove of %s failed", scratch);
-#line 1136
 }
-#line 1136
 
 void
-#line 1137
 test_nc_put_att_schar(void)
-#line 1137
 {
-#line 1137
     int ncid;
-#line 1137
     int i;
-#line 1137
     int j;
-#line 1137
     size_t k;
-#line 1137
     int err;
-#line 1137
     schar value[MAX_NELS];
-#line 1137
     int allInExtRange;  /* all values within external range? */
-#line 1137
 
-#line 1137
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1137
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1137
         error("nc_create: %s", nc_strerror(err));
-#line 1137
         return;
-#line 1137
     }
-#line 1137
     def_dims(ncid);
-#line 1137
     def_vars(ncid);
-#line 1137
 
-#line 1137
-    for (i = -1; i < NVARS; i++) {
-#line 1137
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1137
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1137
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1137
 		err = nc_put_att_schar(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1137
 		    ATT_LEN(i,j), value);
-#line 1137
 		IF (err != NC_EBADID)
-#line 1137
 		    error("bad ncid: status = %d", err);
-#line 1137
 		err = nc_put_att_schar(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1137
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1137
 		IF (err != NC_ENOTVAR)
-#line 1137
 		    error("bad var id: status = %d", err);
-#line 1137
 		err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1137
 		    ATT_LEN(i,j), value);
-#line 1137
 		IF (err != NC_EBADTYPE)
-#line 1137
 		    error("bad type: status = %d", err);
-#line 1137
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1137
 		    value[k] = hash_schar(ATT_TYPE(i,j), -1, &k, NCT_SCHAR);
-#line 1137
 		    allInExtRange = allInExtRange
-#line 1137
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_SCHAR);
-#line 1137
 		}
-#line 1137
 		err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1137
 		    ATT_LEN(i,j), value);
-#line 1137
 		if (allInExtRange) {
-#line 1137
 		    IF (err)
-#line 1137
 			error("%s", nc_strerror(err));
-#line 1137
 		} else {
-#line 1137
                     IF (err != NC_ERANGE)
-#line 1137
                         error("range error: status = %d", err);
-#line 1137
 		}
-#line 1137
 	    }
-#line 1137
         }
-#line 1137
     }
-#line 1137
 
-#line 1137
     check_atts_schar(ncid);
-#line 1137
     err = nc_close(ncid);
-#line 1137
     IF (err)
-#line 1137
         error("nc_close: %s", nc_strerror(err));
-#line 1137
 
-#line 1137
     err = remove(scratch);
-#line 1137
     IF (err)
-#line 1137
         error("remove of %s failed", scratch);
-#line 1137
 }
-#line 1137
 
 void
-#line 1138
 test_nc_put_att_short(void)
-#line 1138
 {
-#line 1138
     int ncid;
-#line 1138
     int i;
-#line 1138
     int j;
-#line 1138
     size_t k;
-#line 1138
     int err;
-#line 1138
     short value[MAX_NELS];
-#line 1138
     int allInExtRange;  /* all values within external range? */
-#line 1138
 
-#line 1138
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1138
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1138
         error("nc_create: %s", nc_strerror(err));
-#line 1138
         return;
-#line 1138
     }
-#line 1138
     def_dims(ncid);
-#line 1138
     def_vars(ncid);
-#line 1138
 
-#line 1138
-    for (i = -1; i < NVARS; i++) {
-#line 1138
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1138
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1138
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1138
 		err = nc_put_att_short(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1138
 		    ATT_LEN(i,j), value);
-#line 1138
 		IF (err != NC_EBADID)
-#line 1138
 		    error("bad ncid: status = %d", err);
-#line 1138
 		err = nc_put_att_short(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1138
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1138
 		IF (err != NC_ENOTVAR)
-#line 1138
 		    error("bad var id: status = %d", err);
-#line 1138
 		err = nc_put_att_short(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1138
 		    ATT_LEN(i,j), value);
-#line 1138
 		IF (err != NC_EBADTYPE)
-#line 1138
 		    error("bad type: status = %d", err);
-#line 1138
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1138
 		    value[k] = hash_short(ATT_TYPE(i,j), -1, &k, NCT_SHORT);
-#line 1138
 		    allInExtRange = allInExtRange
-#line 1138
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_SHORT);
-#line 1138
 		}
-#line 1138
 		err = nc_put_att_short(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1138
 		    ATT_LEN(i,j), value);
-#line 1138
 		if (allInExtRange) {
-#line 1138
 		    IF (err)
-#line 1138
 			error("%s", nc_strerror(err));
-#line 1138
 		} else {
-#line 1138
                     IF (err != NC_ERANGE)
-#line 1138
                         error("range error: status = %d", err);
-#line 1138
 		}
-#line 1138
 	    }
-#line 1138
         }
-#line 1138
     }
-#line 1138
 
-#line 1138
     check_atts_short(ncid);
-#line 1138
     err = nc_close(ncid);
-#line 1138
     IF (err)
-#line 1138
         error("nc_close: %s", nc_strerror(err));
-#line 1138
 
-#line 1138
     err = remove(scratch);
-#line 1138
     IF (err)
-#line 1138
         error("remove of %s failed", scratch);
-#line 1138
 }
-#line 1138
 
 void
-#line 1139
 test_nc_put_att_int(void)
-#line 1139
 {
-#line 1139
     int ncid;
-#line 1139
     int i;
-#line 1139
     int j;
-#line 1139
     size_t k;
-#line 1139
     int err;
-#line 1139
     int value[MAX_NELS];
-#line 1139
     int allInExtRange;  /* all values within external range? */
-#line 1139
 
-#line 1139
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1139
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1139
         error("nc_create: %s", nc_strerror(err));
-#line 1139
         return;
-#line 1139
     }
-#line 1139
     def_dims(ncid);
-#line 1139
     def_vars(ncid);
-#line 1139
 
-#line 1139
-    for (i = -1; i < NVARS; i++) {
-#line 1139
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1139
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1139
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1139
 		err = nc_put_att_int(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1139
 		    ATT_LEN(i,j), value);
-#line 1139
 		IF (err != NC_EBADID)
-#line 1139
 		    error("bad ncid: status = %d", err);
-#line 1139
 		err = nc_put_att_int(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1139
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1139
 		IF (err != NC_ENOTVAR)
-#line 1139
 		    error("bad var id: status = %d", err);
-#line 1139
 		err = nc_put_att_int(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1139
 		    ATT_LEN(i,j), value);
-#line 1139
 		IF (err != NC_EBADTYPE)
-#line 1139
 		    error("bad type: status = %d", err);
-#line 1139
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1139
 		    value[k] = hash_int(ATT_TYPE(i,j), -1, &k, NCT_INT);
-#line 1139
 		    allInExtRange = allInExtRange
-#line 1139
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_INT);
-#line 1139
 		}
-#line 1139
 		err = nc_put_att_int(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1139
 		    ATT_LEN(i,j), value);
-#line 1139
 		if (allInExtRange) {
-#line 1139
 		    IF (err)
-#line 1139
 			error("%s", nc_strerror(err));
-#line 1139
 		} else {
-#line 1139
                     IF (err != NC_ERANGE)
-#line 1139
                         error("range error: status = %d", err);
-#line 1139
 		}
-#line 1139
 	    }
-#line 1139
         }
-#line 1139
     }
-#line 1139
 
-#line 1139
     check_atts_int(ncid);
-#line 1139
     err = nc_close(ncid);
-#line 1139
     IF (err)
-#line 1139
         error("nc_close: %s", nc_strerror(err));
-#line 1139
 
-#line 1139
     err = remove(scratch);
-#line 1139
     IF (err)
-#line 1139
         error("remove of %s failed", scratch);
-#line 1139
 }
-#line 1139
 
 void
-#line 1140
 test_nc_put_att_long(void)
-#line 1140
 {
-#line 1140
     int ncid;
-#line 1140
     int i;
-#line 1140
     int j;
-#line 1140
     size_t k;
-#line 1140
     int err;
-#line 1140
     long value[MAX_NELS];
-#line 1140
     int allInExtRange;  /* all values within external range? */
-#line 1140
 
-#line 1140
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1140
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1140
         error("nc_create: %s", nc_strerror(err));
-#line 1140
         return;
-#line 1140
     }
-#line 1140
     def_dims(ncid);
-#line 1140
     def_vars(ncid);
-#line 1140
 
-#line 1140
-    for (i = -1; i < NVARS; i++) {
-#line 1140
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1140
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1140
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1140
 		err = nc_put_att_long(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1140
 		    ATT_LEN(i,j), value);
-#line 1140
 		IF (err != NC_EBADID)
-#line 1140
 		    error("bad ncid: status = %d", err);
-#line 1140
 		err = nc_put_att_long(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1140
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1140
 		IF (err != NC_ENOTVAR)
-#line 1140
 		    error("bad var id: status = %d", err);
-#line 1140
 		err = nc_put_att_long(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1140
 		    ATT_LEN(i,j), value);
-#line 1140
 		IF (err != NC_EBADTYPE)
-#line 1140
 		    error("bad type: status = %d", err);
-#line 1140
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1140
 		    value[k] = hash_long(ATT_TYPE(i,j), -1, &k, NCT_LONG);
-#line 1140
 		    allInExtRange = allInExtRange
-#line 1140
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_LONG);
-#line 1140
 		}
-#line 1140
 		err = nc_put_att_long(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1140
 		    ATT_LEN(i,j), value);
-#line 1140
 		if (allInExtRange) {
-#line 1140
 		    IF (err)
-#line 1140
 			error("%s", nc_strerror(err));
-#line 1140
 		} else {
-#line 1140
                     IF (err != NC_ERANGE)
-#line 1140
                         error("range error: status = %d", err);
-#line 1140
 		}
-#line 1140
 	    }
-#line 1140
         }
-#line 1140
     }
-#line 1140
 
-#line 1140
     check_atts_long(ncid);
-#line 1140
     err = nc_close(ncid);
-#line 1140
     IF (err)
-#line 1140
         error("nc_close: %s", nc_strerror(err));
-#line 1140
 
-#line 1140
     err = remove(scratch);
-#line 1140
     IF (err)
-#line 1140
         error("remove of %s failed", scratch);
-#line 1140
 }
-#line 1140
 
 void
-#line 1141
 test_nc_put_att_float(void)
-#line 1141
 {
-#line 1141
     int ncid;
-#line 1141
     int i;
-#line 1141
     int j;
-#line 1141
     size_t k;
-#line 1141
     int err;
-#line 1141
     float value[MAX_NELS];
-#line 1141
     int allInExtRange;  /* all values within external range? */
-#line 1141
 
-#line 1141
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1141
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1141
         error("nc_create: %s", nc_strerror(err));
-#line 1141
         return;
-#line 1141
     }
-#line 1141
     def_dims(ncid);
-#line 1141
     def_vars(ncid);
-#line 1141
 
-#line 1141
-    for (i = -1; i < NVARS; i++) {
-#line 1141
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1141
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1141
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1141
 		err = nc_put_att_float(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1141
 		    ATT_LEN(i,j), value);
-#line 1141
 		IF (err != NC_EBADID)
-#line 1141
 		    error("bad ncid: status = %d", err);
-#line 1141
 		err = nc_put_att_float(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1141
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1141
 		IF (err != NC_ENOTVAR)
-#line 1141
 		    error("bad var id: status = %d", err);
-#line 1141
 		err = nc_put_att_float(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1141
 		    ATT_LEN(i,j), value);
-#line 1141
 		IF (err != NC_EBADTYPE)
-#line 1141
 		    error("bad type: status = %d", err);
-#line 1141
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1141
 		    value[k] = hash_float(ATT_TYPE(i,j), -1, &k, NCT_FLOAT);
-#line 1141
 		    allInExtRange = allInExtRange
-#line 1141
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_FLOAT);
-#line 1141
 		}
-#line 1141
 		err = nc_put_att_float(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1141
 		    ATT_LEN(i,j), value);
-#line 1141
 		if (allInExtRange) {
-#line 1141
 		    IF (err)
-#line 1141
 			error("%s", nc_strerror(err));
-#line 1141
 		} else {
-#line 1141
                     IF (err != NC_ERANGE)
-#line 1141
                         error("range error: status = %d", err);
-#line 1141
 		}
-#line 1141
 	    }
-#line 1141
         }
-#line 1141
     }
-#line 1141
 
-#line 1141
     check_atts_float(ncid);
-#line 1141
     err = nc_close(ncid);
-#line 1141
     IF (err)
-#line 1141
         error("nc_close: %s", nc_strerror(err));
-#line 1141
 
-#line 1141
     err = remove(scratch);
-#line 1141
     IF (err)
-#line 1141
         error("remove of %s failed", scratch);
-#line 1141
 }
-#line 1141
 
 void
-#line 1142
 test_nc_put_att_double(void)
-#line 1142
 {
-#line 1142
     int ncid;
-#line 1142
     int i;
-#line 1142
     int j;
-#line 1142
     size_t k;
-#line 1142
     int err;
-#line 1142
     double value[MAX_NELS];
-#line 1142
     int allInExtRange;  /* all values within external range? */
-#line 1142
 
-#line 1142
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
-#line 1142
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
-#line 1142
         error("nc_create: %s", nc_strerror(err));
-#line 1142
         return;
-#line 1142
     }
-#line 1142
     def_dims(ncid);
-#line 1142
     def_vars(ncid);
-#line 1142
 
-#line 1142
-    for (i = -1; i < NVARS; i++) {
-#line 1142
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
-#line 1142
             if (!(ATT_TYPE(i,j) == NC_CHAR)) {
-#line 1142
 		assert(ATT_LEN(i,j) <= MAX_NELS);
-#line 1142
 		err = nc_put_att_double(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
-#line 1142
 		    ATT_LEN(i,j), value);
-#line 1142
 		IF (err != NC_EBADID)
-#line 1142
 		    error("bad ncid: status = %d", err);
-#line 1142
 		err = nc_put_att_double(ncid, BAD_VARID, ATT_NAME(i,j), 
-#line 1142
 		    ATT_TYPE(i,j), ATT_LEN(i,j), value);
-#line 1142
 		IF (err != NC_ENOTVAR)
-#line 1142
 		    error("bad var id: status = %d", err);
-#line 1142
 		err = nc_put_att_double(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
-#line 1142
 		    ATT_LEN(i,j), value);
-#line 1142
 		IF (err != NC_EBADTYPE)
-#line 1142
 		    error("bad type: status = %d", err);
-#line 1142
 		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
-#line 1142
 		    value[k] = hash_double(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE);
-#line 1142
 		    allInExtRange = allInExtRange
-#line 1142
 			&& inRange3(value[k], ATT_TYPE(i,j), NCT_DOUBLE);
-#line 1142
 		}
-#line 1142
 		err = nc_put_att_double(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
-#line 1142
 		    ATT_LEN(i,j), value);
-#line 1142
 		if (allInExtRange) {
-#line 1142
 		    IF (err)
-#line 1142
 			error("%s", nc_strerror(err));
-#line 1142
 		} else {
-#line 1142
                     IF (err != NC_ERANGE)
-#line 1142
                         error("range error: status = %d", err);
-#line 1142
 		}
-#line 1142
 	    }
-#line 1142
         }
-#line 1142
     }
-#line 1142
 
-#line 1142
     check_atts_double(ncid);
-#line 1142
     err = nc_close(ncid);
-#line 1142
     IF (err)
-#line 1142
         error("nc_close: %s", nc_strerror(err));
-#line 1142
 
-#line 1142
     err = remove(scratch);
-#line 1142
     IF (err)
-#line 1142
         error("remove of %s failed", scratch);
-#line 1142
 }
-#line 1142
+
+void
+test_nc_put_att_ushort(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    ushort value[MAX_NELS];
+    int allInExtRange;  /* all values within external range? */
+
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+
+    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(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADID)
+		    error("bad ncid: status = %d", err);
+		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("bad var id: status = %d", err);
+		err = nc_put_att_ushort(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADTYPE)
+		    error("bad type: status = %d", err);
+		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+		    value[k] = hash_ushort(ATT_TYPE(i,j), -1, &k, NCT_USHORT);
+		    allInExtRange = allInExtRange
+			&& inRange3(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)
+			error("%s", nc_strerror(err));
+		} else {
+                    IF (err != NC_ERANGE)
+                        error("range error: status = %d", err);
+		}
+	    }
+        }
+    }
+
+    check_atts_ushort(ncid);
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_att_uint(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    uint value[MAX_NELS];
+    int allInExtRange;  /* all values within external range? */
+
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+
+    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(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADID)
+		    error("bad ncid: status = %d", err);
+		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("bad var id: status = %d", err);
+		err = nc_put_att_uint(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADTYPE)
+		    error("bad type: status = %d", err);
+		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+		    value[k] = hash_uint(ATT_TYPE(i,j), -1, &k, NCT_UINT);
+		    allInExtRange = allInExtRange
+			&& inRange3(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)
+			error("%s", nc_strerror(err));
+		} else {
+                    IF (err != NC_ERANGE)
+                        error("range error: status = %d", err);
+		}
+	    }
+        }
+    }
+
+    check_atts_uint(ncid);
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_att_longlong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    longlong value[MAX_NELS];
+    int allInExtRange;  /* all values within external range? */
+
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+
+    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(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADID)
+		    error("bad ncid: status = %d", err);
+		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("bad var id: status = %d", err);
+		err = nc_put_att_longlong(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADTYPE)
+		    error("bad type: status = %d", err);
+		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+		    value[k] = hash_longlong(ATT_TYPE(i,j), -1, &k, NCT_LONGLONG);
+		    allInExtRange = allInExtRange
+			&& inRange3(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)
+			error("%s", nc_strerror(err));
+		} else {
+                    IF (err != NC_ERANGE)
+                        error("range error: status = %d", err);
+		}
+	    }
+        }
+    }
+
+    check_atts_longlong(ncid);
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
+
+void
+test_nc_put_att_ulonglong(void)
+{
+    int ncid;
+    int i;
+    int j;
+    size_t k;
+    int err;
+    ulonglong value[MAX_NELS];
+    int allInExtRange;  /* all values within external range? */
+
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
+    IF (err) {
+        error("nc_create: %s", nc_strerror(err));
+        return;
+    }
+    def_dims(ncid);
+    def_vars(ncid);
+
+    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(BAD_ID, i, ATT_NAME(i,j), ATT_TYPE(i,j), 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADID)
+		    error("bad ncid: status = %d", err);
+		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("bad var id: status = %d", err);
+		err = nc_put_att_ulonglong(ncid, i, ATT_NAME(i,j), BAD_TYPE, 
+		    ATT_LEN(i,j), value);
+		IF (err != NC_EBADTYPE)
+		    error("bad type: status = %d", err);
+		for (allInExtRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
+		    value[k] = hash_ulonglong(ATT_TYPE(i,j), -1, &k, NCT_ULONGLONG);
+		    allInExtRange = allInExtRange
+			&& inRange3(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)
+			error("%s", nc_strerror(err));
+		} else {
+                    IF (err != NC_ERANGE)
+                        error("range error: status = %d", err);
+		}
+	    }
+        }
+    }
+
+    check_atts_ulonglong(ncid);
+    err = nc_close(ncid);
+    IF (err)
+        error("nc_close: %s", nc_strerror(err));
+
+    err = remove(scratch);
+    IF (err)
+        error("remove of %s failed", scratch);
+}
 
 
diff --git a/nc_test/test_put.m4 b/nc_test/test_put.m4
index 526dc38..3e6ca5d 100644
--- a/nc_test/test_put.m4
+++ b/nc_test/test_put.m4
@@ -7,9 +7,13 @@ dnl
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_put.m4,v 1.25 2005/03/08 03:04:19 ed Exp $
+ *   $Id: test_put.m4 2785 2014-10-26 05:21:20Z wkliao $
  *********************************************************************/
 
+#ifdef USE_PARALLEL
+#include <mpi.h>
+#endif
+
 undefine(`index')dnl
 dnl dnl dnl
 dnl
@@ -61,6 +65,10 @@ HASH(int)
 HASH(long)
 HASH(float)
 HASH(double)
+HASH(ushort)
+HASH(uint)
+HASH(longlong)
+HASH(ulonglong)
 
 
 dnl CHECK_VARS(TYPE)
@@ -90,11 +98,11 @@ check_vars_$1(const char *filename)
     int canConvert;     /* Both text or both numeric */
     int nok = 0;      /* count of valid comparisons */
 
-    err = nc_open(filename, NC_NOWRITE, &ncid);
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	if (canConvert) {
 	    err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
@@ -160,6 +168,10 @@ CHECK_VARS(int)
 CHECK_VARS(long)
 CHECK_VARS(float)
 CHECK_VARS(double)
+CHECK_VARS(ushort)
+CHECK_VARS(uint)
+CHECK_VARS(longlong)
+CHECK_VARS(ulonglong)
 
 
 dnl CHECK_ATTS(TYPE)         numeric only
@@ -187,7 +199,7 @@ check_atts_$1(int  ncid)
     int canConvert;     /* Both text or both numeric */
     int nok = 0;      /* count of valid comparisons */
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         for (j = 0; j < NATTS(i); j++) {
 	    canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	    if (canConvert) {
@@ -250,6 +262,10 @@ CHECK_ATTS(int)
 CHECK_ATTS(long)
 CHECK_ATTS(float)
 CHECK_ATTS(double)
+CHECK_ATTS(ushort)
+CHECK_ATTS(uint)
+CHECK_ATTS(longlong)
+CHECK_ATTS(ulonglong)
 
 
 dnl TEST_NC_PUT_VAR1(TYPE)
@@ -267,7 +283,7 @@ test_nc_put_var1_$1(void)
     int canConvert;	/* Both text or both numeric */
     $1 value = 5;	/* any value would do - only for error cases */
 
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -278,7 +294,21 @@ test_nc_put_var1_$1(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         for (j = 0; j < var_rank[i]; j++)
             index[j] = 0;
@@ -345,6 +375,10 @@ TEST_NC_PUT_VAR1(int)
 TEST_NC_PUT_VAR1(long)
 TEST_NC_PUT_VAR1(float)
 TEST_NC_PUT_VAR1(double)
+TEST_NC_PUT_VAR1(ushort)
+TEST_NC_PUT_VAR1(uint)
+TEST_NC_PUT_VAR1(longlong)
+TEST_NC_PUT_VAR1(ulonglong)
 
 
 dnl TEST_NC_PUT_VAR(TYPE)
@@ -365,7 +399,7 @@ test_nc_put_var_$1(void)
     int allInExtRange;	/* all values within external range? */
     $1 value[MAX_NELS];
 
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -376,7 +410,21 @@ test_nc_put_var_$1(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -414,7 +462,7 @@ test_nc_put_var_$1(void)
 	}
     }
 
-        /* Preceeding has written nothing for record variables, now try */
+        /* 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 */
@@ -427,7 +475,7 @@ test_nc_put_var_$1(void)
     IF (err)
         error("nc_put_var1_text: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         if (var_dimid[i][0] == RECDIM) {  /* only test record variables here */
 	    canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	    assert(var_rank[i] <= MAX_RANK);
@@ -483,6 +531,10 @@ TEST_NC_PUT_VAR(int)
 TEST_NC_PUT_VAR(long)
 TEST_NC_PUT_VAR(float)
 TEST_NC_PUT_VAR(double)
+TEST_NC_PUT_VAR(ushort)
+TEST_NC_PUT_VAR(uint)
+TEST_NC_PUT_VAR(longlong)
+TEST_NC_PUT_VAR(ulonglong)
 
 
 dnl TEST_NC_PUT_VARA(TYPE)
@@ -508,7 +560,7 @@ test_nc_put_vara_$1(void)
     int allInExtRange;	/* all values within external range? */
     $1 value[MAX_NELS];
 
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -519,8 +571,22 @@ test_nc_put_vara_$1(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
     value[0] = 0;
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
@@ -567,6 +633,11 @@ test_nc_put_vara_$1(void)
 		start[j] = 0;
 	    }
         }
+
+/* wkliao: this test below of put_vara is redundant and incorrectly uses the
+           value[] set from the previously iteration. There is no such test
+           in put_vars and put_varm.
+
 	err = nc_put_vara_$1(ncid, i, start, edge, value);
 	if (canConvert) {
 	    IF (err) 
@@ -575,6 +646,7 @@ test_nc_put_vara_$1(void)
 	    IF (err != NC_ECHAR)
 		error("wrong type: status = %d", err);
         }
+*/
         for (j = 0; j < var_rank[i]; j++) {
             edge[j] = 1;
 	}
@@ -648,6 +720,10 @@ TEST_NC_PUT_VARA(int)
 TEST_NC_PUT_VARA(long)
 TEST_NC_PUT_VARA(float)
 TEST_NC_PUT_VARA(double)
+TEST_NC_PUT_VARA(ushort)
+TEST_NC_PUT_VARA(uint)
+TEST_NC_PUT_VARA(longlong)
+TEST_NC_PUT_VARA(ulonglong)
 
 
 dnl TEST_NC_PUT_VARS(TYPE)
@@ -679,7 +755,7 @@ test_nc_put_vars_$1(void)
     int allInExtRange;	/* all values within external range? */
     $1 value[MAX_NELS];
 
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
 	error("nc_create: %s", nc_strerror(err));
 	return;
@@ -690,7 +766,21 @@ test_nc_put_vars_$1(void)
     IF (err)
 	error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
 	assert(var_nels[i] <= MAX_NELS);
@@ -821,6 +911,10 @@ TEST_NC_PUT_VARS(int)
 TEST_NC_PUT_VARS(long)
 TEST_NC_PUT_VARS(float)
 TEST_NC_PUT_VARS(double)
+TEST_NC_PUT_VARS(ushort)
+TEST_NC_PUT_VARS(uint)
+TEST_NC_PUT_VARS(longlong)
+TEST_NC_PUT_VARS(ulonglong)
 
 
 dnl TEST_NC_PUT_VARM(TYPE)
@@ -853,7 +947,7 @@ test_nc_put_varm_$1(void)
     int allInExtRange;	/* all values within external range? */
     $1 value[MAX_NELS];
 
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
 	error("nc_create: %s", nc_strerror(err));
 	return;
@@ -864,7 +958,21 @@ test_nc_put_varm_$1(void)
     IF (err)
 	error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+#ifdef USE_PNETCDF
+    {
+    int format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err)
+	        error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }
+    }
+#endif
+
+    for (i = 0; i < numVars; i++) {
 	canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
 	assert(var_rank[i] <= MAX_RANK);
 	assert(var_nels[i] <= MAX_NELS);
@@ -1002,6 +1110,10 @@ TEST_NC_PUT_VARM(int)
 TEST_NC_PUT_VARM(long)
 TEST_NC_PUT_VARM(float)
 TEST_NC_PUT_VARM(double)
+TEST_NC_PUT_VARM(ushort)
+TEST_NC_PUT_VARM(uint)
+TEST_NC_PUT_VARM(longlong)
+TEST_NC_PUT_VARM(ulonglong)
 
 
 void
@@ -1014,7 +1126,7 @@ test_nc_put_att_text(void)
     int err;
     text value[MAX_NELS];
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1030,7 +1142,7 @@ test_nc_put_att_text(void)
 	IF (err != NC_EBADNAME)
 	   error("should be NC_EBADNAME: status = %d", err);
     }
-    for (i = -1; i < NVARS; i++) {
+    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);
@@ -1080,7 +1192,7 @@ test_nc_put_att_$1(void)
     $1 value[MAX_NELS];
     int allInExtRange;  /* all values within external range? */
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1088,7 +1200,7 @@ test_nc_put_att_$1(void)
     def_dims(ncid);
     def_vars(ncid);
 
-    for (i = -1; i < NVARS; i++) {
+    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);
@@ -1140,4 +1252,8 @@ TEST_NC_PUT_ATT(int)
 TEST_NC_PUT_ATT(long)
 TEST_NC_PUT_ATT(float)
 TEST_NC_PUT_ATT(double)
+TEST_NC_PUT_ATT(ushort)
+TEST_NC_PUT_ATT(uint)
+TEST_NC_PUT_ATT(longlong)
+TEST_NC_PUT_ATT(ulonglong)
 
diff --git a/nc_test/test_read.c b/nc_test/test_read.c
index 894a50e..f0e4c08 100644
--- a/nc_test/test_read.c
+++ b/nc_test/test_read.c
@@ -1,7 +1,7 @@
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_read.c,v 1.32 2008/04/04 20:23:51 dmh Exp $
+ *   $Id: test_read.c 2792 2014-10-27 06:02:59Z wkliao $
  *********************************************************************/
 
 #include "tests.h"
@@ -58,14 +58,14 @@ test_nc_strerror(void)
     /* Try on a bad error status */
     /* Dmh: allow trailing extra info */
     message = nc_strerror(-666);/* should fail */
-    IF (strcmp(message, "Unknown Error") != 0)
+    IF (strncmp(message, "Unknown Error", strlen("Unknown Error")) != 0)
 	error("nc_strerror on bad error status returned: %s", message);
 
     /* Try on each legitimate error status */
     /* Dmh: allow trailing extra info */
     for (i=0; i<LEN_OF(ncerrs); i++) {
 	const char *message = nc_strerror(ncerrs[i].status);
-	IF (strcmp(message, ncerrs[i].msg) != 0)
+	IF (strncmp(message, ncerrs[i].msg, strlen(ncerrs[i].msg)) != 0)
 	    error("nc_strerror(%d) should return `%s', not `%s'",
 		  ncerrs[i].status, ncerrs[i].msg, message);
     }
@@ -92,7 +92,7 @@ test_nc_open(void)
     int ncid2;
     
     /* Try to open a nonexistent file */
-    err = nc_open("tooth-fairy.nc", NC_NOWRITE, &ncid);/* should fail */
+    err = file_open("tooth-fairy.nc", NC_NOWRITE, &ncid);/* should fail */
     IF (err == NC_NOERR)
 	error("nc_open of nonexistent file should have failed");
 #ifndef USE_PARALLEL
@@ -107,14 +107,14 @@ test_nc_open(void)
     /* 	error("nc_open of non-netCDF file: status = %d", err); */
 
     /* Open a netCDF file in read-only mode, check that write fails */
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_redef(ncid);	/* should fail */
     IF (err != NC_EPERM)
 	error("nc_redef of read-only file should fail");
     /* Opened OK, see if can open again and get a different netCDF ID */
-    err = nc_open(testfile, NC_NOWRITE, &ncid2);
+    err = file_open(testfile, NC_NOWRITE, &ncid2);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     else {
@@ -123,12 +123,12 @@ test_nc_open(void)
     IF (ncid2 == ncid)
 	error("netCDF IDs for first and second nc_open calls should differ");
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid2);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid2);
     IF (err) 
        error("nc_create: %s", nc_strerror(err));
     else 
        (void) nc_close(ncid2);
-    err = nc_open(scratch, NC_WRITE, &ncid2);
+    err = file_open(scratch, NC_WRITE, &ncid2);
     IF (err) 
        error("nc_open: %s", nc_strerror(err));
     else 
@@ -152,9 +152,9 @@ test_nc_open(void)
 void
 test_nc_close(void)
 {
-    int ncid;
-    int err = nc_open(testfile, NC_NOWRITE, &ncid);
+    int ncid, err;
 
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
 
@@ -172,14 +172,14 @@ test_nc_close(void)
 	error("nc_close with bad netCDF ID returned wrong error (%d)", err);
 
     /* Close in data mode */
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_close(ncid);
     IF (err)
 	error("nc_close in data mode failed: %s", nc_strerror(err));
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) 
        error("nc_create: %s", nc_strerror(err));
     err = nc_close(ncid);
@@ -208,8 +208,9 @@ test_nc_inq(void)
     int nvars;			/* number of variables */
     int ngatts;			/* number of global attributes */
     int recdim;			/* id of unlimited dimension */
-    int err = nc_open(testfile, NC_NOWRITE, &ncid);
+    int err;
 
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     
@@ -223,9 +224,9 @@ test_nc_inq(void)
 	error("nc_inq: %s", nc_strerror(err));
     else IF (ndims != NDIMS)
 	error("nc_inq: wrong number of dimensions returned, %d", ndims);
-    else IF (nvars != NVARS)
+    else IF (nvars != numVars)
 	error("nc_inq: wrong number of variables returned, %d", nvars);
-    else IF (ngatts != NGATTS)
+    else IF (ngatts != numGatts)
 	error("nc_inq: wrong number of global atts returned, %d", ngatts);
     else IF (recdim != RECDIM)
 	error("nc_inq: wrong record dimension ID returned, %d", recdim);
@@ -236,26 +237,30 @@ test_nc_inq(void)
 	error("nc_inq for no info failed: %s", nc_strerror(err));
 
     /* Inguire for subsets of info */
-    ngatts = NGATTS - 1;	/* wipe out previous correct value */
+    ngatts = numGatts - 1;	/* wipe out previous correct value */
     err = nc_inq(ncid, 0, 0, &ngatts, 0);
     IF (err)
 	error("nc_inq for one item failed: %s", nc_strerror(err));
-    else IF (ngatts != NGATTS)
+    else IF (ngatts != numGatts)
 	error("nc_inq subset: wrong number of global atts returned, %d", ngatts);
     ndims = NDIMS - 1;
-    nvars = NVARS - 1;
+    nvars = numVars - 1;
     err = nc_inq(ncid, &ndims, &nvars, 0, 0);
     IF (err)
 	error("nc_inq for two items failed: %s", nc_strerror(err));
     else IF (ndims != NDIMS)
 	error("nc_inq subset: wrong number of dimensions returned, %d", ndims);
-    else IF (nvars != NVARS)
+    else IF (nvars != numVars)
 	error("nc_inq subset: wrong number of variables returned, %d", nvars);
 
     {		/* tests using netCDF scratch file */
 	int ncid2;		/* for scratch netCDF dataset */
 
+#ifdef TEST_PNETCDF
+        err = nc_create_par(scratch, NC_NOCLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid2);
+#else
         err = nc_create(scratch, NC_NOCLOBBER, &ncid2);
+#endif
         IF (err) {
             error("nc_create: %s", nc_strerror(err));
 	} else {		/* add dim, var, gatt, check inq */
@@ -347,13 +352,13 @@ test_nc_inq_natts(void)
     err = nc_inq_natts(BAD_ID, &ngatts);
     IF (err != NC_EBADID)
 	error("bad ncid: status = %d", err);
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_inq_natts(ncid, &ngatts);
     IF (err)
 	error("nc_inq_natts: %s", nc_strerror(err));
-    else IF (ngatts != NGATTS)
+    else IF (ngatts != numGatts)
 	error("nc_inq_natts: wrong number of global atts returned, %d", ngatts);
     err = nc_close(ncid);
     IF (err)
@@ -371,7 +376,7 @@ test_nc_inq_ndims(void)
     err = nc_inq_ndims(BAD_ID, &ndims);
     IF (err != NC_EBADID)
 	error("bad ncid: status = %d", err);
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_inq_ndims(ncid, &ndims);
@@ -395,13 +400,13 @@ test_nc_inq_nvars(void)
     err = nc_inq_nvars(BAD_ID, &nvars);
     IF (err != NC_EBADID)
 	error("bad ncid: status = %d", err);
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_inq_nvars(ncid, &nvars);
     IF (err)
 	error("nc_inq_nvars: %s", nc_strerror(err));
-    else IF (nvars != NVARS)
+    else IF (nvars != numVars)
 	error("nc_inq_nvars: wrong number returned, %d", nvars);
     err = nc_close(ncid);
     IF (err)
@@ -419,7 +424,7 @@ test_nc_inq_unlimdim(void)
     err = nc_inq_unlimdim(BAD_ID, &unlimdim);
     IF (err != NC_EBADID)
 	error("bad ncid: status = %d", err);
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_inq_unlimdim(ncid, &unlimdim);
@@ -441,7 +446,7 @@ test_nc_inq_dimid(void)
     int i;
     int err;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     err = nc_inq_dimid(ncid, "noSuch", &dimid);
@@ -472,7 +477,7 @@ test_nc_inq_dim(void)
     char name[NC_MAX_NAME];
     size_t length;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     for (i = 0; i < NDIMS; i++) {
@@ -517,7 +522,7 @@ test_nc_inq_dimlen(void)
     int err;
     size_t length;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     for (i = 0; i < NDIMS; i++) {
@@ -547,7 +552,7 @@ test_nc_inq_dimname(void)
     int err;
     char name[NC_MAX_NAME];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
     for (i = 0; i < NDIMS; i++) {
@@ -577,7 +582,7 @@ test_nc_inq_varid(void)
     int i;
     int err;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
 
@@ -585,7 +590,7 @@ test_nc_inq_varid(void)
     IF (err != NC_ENOTVAR)
 	error("bad ncid: status = %d", err);
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_inq_varid(BAD_ID, var_name[i], &varid);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -614,10 +619,10 @@ test_nc_inq_var(void)
     int dimids[MAX_RANK];
     int natts;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_inq_var(BAD_ID, i, name, &datatype, &ndims, dimids, &natts);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -680,10 +685,10 @@ test_nc_inq_vardimid(void)
     int err;
     int dimids[MAX_RANK];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_inq_vardimid(BAD_ID, i, dimids);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -710,10 +715,10 @@ test_nc_inq_varname(void)
     int err;
     char name[NC_MAX_NAME];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_inq_varname(BAD_ID, i, name);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -740,10 +745,10 @@ test_nc_inq_varnatts(void)
     int err;
     int natts;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	err = nc_inq_varnatts(BAD_ID, i, &natts);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -770,10 +775,10 @@ test_nc_inq_varndims(void)
     int err;
     int ndims;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_inq_varndims(BAD_ID, i, &ndims);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -800,10 +805,10 @@ test_nc_inq_vartype(void)
     int err;
     nc_type datatype;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_inq_vartype(BAD_ID, i, &datatype);
         IF (err != NC_EBADID)
 	    error("bad ncid: status = %d", err);
@@ -838,10 +843,10 @@ test_nc_get_var1(void)
     double buf[1];		/* (void *) buffer */
     double value;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	for (j = 0; j < var_rank[i]; j++)
 	    index[j] = 0;
         err = nc_get_var1(BAD_ID, i, index, buf);
@@ -913,10 +918,10 @@ test_nc_get_vara(void)
     double expect;
     double got;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
         for (j = 0; j < var_rank[i]; j++) {
@@ -1040,10 +1045,10 @@ test_nc_get_vars(void)
     double expect;
     double got;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
         for (j = 0; j < var_rank[i]; j++) {
@@ -1207,10 +1212,10 @@ test_nc_get_varm(void)
     double expect;
     double got;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
 	error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
         for (j = 0; j < var_rank[i]; j++) {
@@ -1220,7 +1225,8 @@ test_nc_get_varm(void)
         }
         if (var_rank[i] > 0) {
             j = var_rank[i] - 1;
-            imap[j] = nctypelen(var_type[i]);
+            /* imap[j] = nctypelen(var_type[i]); in bytes */
+            imap[j] = 1; /* in numbers of elements */
             for (; j > 0; j--)
                 imap[j-1] = imap[j] * var_shape[i][j];
         }
@@ -1346,11 +1352,11 @@ test_nc_get_att(void)
     double got;
     int nok = 0;      /* count of valid comparisons */
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
 	error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    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) 
@@ -1411,11 +1417,11 @@ test_nc_inq_att(void)
     nc_type t;
     size_t n;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err) 
 	error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    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) 
@@ -1453,11 +1459,11 @@ test_nc_inq_attlen(void)
     int err;
     size_t len;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	err = nc_inq_attlen(ncid, i, "noSuch", &len);
 	IF (err != NC_ENOTATT)
 	    error("Bad attribute name: status = %d", err);
@@ -1493,11 +1499,11 @@ test_nc_inq_atttype(void)
     int err;
     nc_type datatype;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	err = nc_inq_atttype(ncid, i, "noSuch", &datatype);
 	IF (err != NC_ENOTATT)
 	    error("Bad attribute name: status = %d", err);
@@ -1533,11 +1539,11 @@ test_nc_inq_attname(void)
     int err;
     char name[NC_MAX_NAME];
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	err = nc_inq_attname(ncid, i, BAD_ATTNUM, name);
 	IF (err != NC_ENOTATT)
 	    error("Bad attribute number: status = %d", err);
@@ -1576,11 +1582,11 @@ test_nc_inq_attid(void)
     int err;
     int attnum;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	err = nc_inq_attid(ncid, i, "noSuch", &attnum);
 	IF (err != NC_ENOTATT)
 	    error("Bad attribute name: status = %d", err);
diff --git a/nc_test/test_write.c b/nc_test/test_write.c
index 4e0e818..4c17175 100644
--- a/nc_test/test_write.c
+++ b/nc_test/test_write.c
@@ -1,7 +1,7 @@
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: test_write.c,v 1.33 2006/10/31 16:23:13 ed Exp $
+ *   $Id: test_write.c 2796 2014-10-28 03:40:29Z wkliao $
  *********************************************************************/
 
 #include "tests.h"
@@ -28,13 +28,14 @@ test_nc_create(void)
     int recdim;                 /* id of unlimited dimension */
 
     for (clobber = 0; clobber < 2; clobber++) {
-	err = nc_create(scratch, clobber ? NC_CLOBBER : NC_NOCLOBBER, &ncid);
+        int cmode = clobber ? NC_CLOBBER : NC_NOCLOBBER;
+	err = file_create(scratch, cmode, &ncid);
 	IF (err)
 	    error("nc_create: %s", nc_strerror(err));
 	err = nc_close(ncid);
 	IF (err)
 	    error("nc_close: %s", nc_strerror(err));
-	err = nc_open(scratch, NC_NOWRITE, &ncid);
+	err = file_open(scratch, NC_NOWRITE, &ncid);
 	IF (err)
 	    error("nc_open: %s", nc_strerror(err));
 	err = nc_inq(ncid, &ndims, &nvars, &ngatts, &recdim);
@@ -53,7 +54,7 @@ test_nc_create(void)
 	    error("nc_close: %s", nc_strerror(err));
     }
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err != NC_EEXIST)
 	error("attempt to overwrite file: status = %d", err);
     err = remove(scratch);
@@ -106,7 +107,7 @@ test_nc_redef(void)
 	error("bad ncid: status = %d", err);
 
 	/* read-only tests */
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     err = nc_redef(ncid);
@@ -120,7 +121,7 @@ test_nc_redef(void)
 	error("nc_close: %s", nc_strerror(err));
 
 	/* tests using scratch file */
-    err = nc__create(scratch, NC_NOCLOBBER, 0, &sizehint, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -195,7 +196,7 @@ test_nc_redef(void)
     /* check scratch file written as expected */
     check_file(scratch);  /* checks all except "abc" stuff added above */
 
-    IF ((err = nc_open(scratch, NC_NOWRITE, &ncid)))
+    IF ((err = file_open(scratch, NC_NOWRITE, &ncid)))
         error("nc_open: %s", nc_strerror(err));
     IF ((err = nc_inq_dim(ncid, dimid, name, &length))) 
 	error("nc_inq_dim: %s", nc_strerror(err));
@@ -211,7 +212,7 @@ test_nc_redef(void)
         error("nc_close: %s", nc_strerror(err));
 
     /* open scratch file for writing, add another dim, var, att, then check */
-    IF ((err = nc_open(scratch, NC_WRITE, &ncid)))
+    IF ((err = file_open(scratch, NC_WRITE, &ncid)))
         error("nc_open: %s", nc_strerror(err));
     IF ((err = nc_redef(ncid)))
         error("nc_redef: %s", nc_strerror(err));
@@ -234,7 +235,7 @@ test_nc_redef(void)
     /* check scratch file written as expected */
     check_file(scratch);
 
-    err = nc_open(scratch, NC_NOWRITE, &ncid);
+        err = file_open(scratch, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     err = nc_inq_dim(ncid, dimid, name, &length);
@@ -294,7 +295,7 @@ test_nc_sync(void)
         error("bad ncid: status = %d", err);
 
         /* create scratch file & try nc_sync in define mode */
-    err = nc_create(scratch, NC_NOCLOBBER, &ncidw);
+    err = file_create(scratch, NC_NOCLOBBER, &ncidw);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
 	return;
@@ -316,7 +317,7 @@ test_nc_sync(void)
         error("nc_sync of ncidw failed: %s", nc_strerror(err));
 
         /* open another handle, nc_sync, read (check) */
-    err = nc_open(scratch, NC_NOWRITE, &ncidr);
+        err = file_open(scratch, NC_NOWRITE, &ncidr);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     err = nc_sync(ncidr);
@@ -362,7 +363,7 @@ test_nc_abort(void)
         error("bad ncid: status = %d", err);
 
         /* create scratch file & try nc_abort in define mode */
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -386,7 +387,7 @@ test_nc_abort(void)
 	 * define new dims, vars, atts
 	 * try nc_abort: should restore previous state (no dims, vars, atts)
 	 */ 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -406,7 +407,7 @@ test_nc_abort(void)
     err = nc_close(ncid);	/* should already be closed */
     IF (err != NC_EBADID)
         error("bad ncid: status = %d", err);
-    err = nc_open(scratch, NC_NOWRITE, &ncid);
+        err = file_open(scratch, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     err = nc_inq (ncid, &ndims, &nvars, &ngatts, NULL);
@@ -423,7 +424,7 @@ test_nc_abort(void)
         error("nc_close: %s", nc_strerror(err));
 
         /* try nc_abort in data mode - should just close */
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -473,7 +474,7 @@ test_nc_def_dim(void)
         error("bad ncid: status = %d", err);
 
         /* data mode test */
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -567,7 +568,7 @@ test_nc_rename_dim(void)
         error("bad ncid: status = %d", err);
 
         /* main tests */
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -629,7 +630,7 @@ test_nc_def_var(void)
         error("bad ncid: status = %d", err);
 
         /* scalar tests */
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -672,13 +673,13 @@ test_nc_def_var(void)
         error("remove of %s failed", scratch);
 
         /* general tests using global vars */
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
     }
     def_dims(ncid);
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         err = nc_def_var(ncid, var_name[i], var_type[i], var_rank[i],
             var_dimid[i], &varid);
         IF (err) 
@@ -716,7 +717,7 @@ test_nc_put_var1(void)
     double value;
     double buf[1];		/* (void *) buffer */
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -727,7 +728,7 @@ test_nc_put_var1(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         for (j = 0; j < var_rank[i]; j++)
             index[j] = 0;
         err = nc_put_var1(BAD_ID, i, index, buf);
@@ -801,7 +802,7 @@ test_nc_put_vara(void)
     char *p;			/* (void *) pointer */
     double value;
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -812,7 +813,7 @@ test_nc_put_vara(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
         for (j = 0; j < var_rank[i]; j++) {
@@ -928,7 +929,7 @@ test_nc_put_vars(void)
     char *p;			/* (void *) pointer */
     double value;
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -939,7 +940,7 @@ test_nc_put_vars(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
         for (j = 0; j < var_rank[i]; j++) {
@@ -1083,7 +1084,7 @@ test_nc_put_varm(void)
     char *p;			/* (void *) pointer */
     double value;
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1094,7 +1095,7 @@ test_nc_put_varm(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         assert(var_rank[i] <= MAX_RANK);
         assert(var_nels[i] <= MAX_NELS);
         for (j = 0; j < var_rank[i]; j++) {
@@ -1104,7 +1105,8 @@ test_nc_put_varm(void)
         }
 	if (var_rank[i] > 0) {
 	    j = var_rank[i] - 1; 
-	    imap[j] = nctypelen(var_type[i]);
+            // imap[j] = nctypelen(var_type[i]); /* in bytes */
+            imap[j] = 1; /* in numbers of elements */
 	    for (; j > 0; j--)
 		imap[j-1] = imap[j] * var_shape[i][j];
 	}
@@ -1228,7 +1230,7 @@ test_nc_rename_var(void)
     int i;
     char name[NC_MAX_NAME];
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1240,11 +1242,11 @@ test_nc_rename_var(void)
     def_vars(ncid);
 
 	/* Prefix "new_" to each name */
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         err = nc_rename_var(BAD_ID, i, "newName");
         IF (err != NC_EBADID)
             error("bad ncid: status = %d", err);
-        err = nc_rename_var(ncid, i, var_name[NVARS-1]);
+        err = nc_rename_var(ncid, i, var_name[numVars-1]);
         IF (err != NC_ENAMEINUSE)
             error("duplicate name: status = %d", err);
 	(void) strcpy(name, "new_");
@@ -1264,7 +1266,7 @@ test_nc_rename_var(void)
     err = nc_enddef(ncid);
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	(void) strcpy(name, "even_longer_");
 	(void) strcat(name, var_name[i]);
         err = nc_rename_var(ncid, i, name);
@@ -1309,7 +1311,7 @@ test_nc_put_att(void)
     size_t length;		/* of att */
     double value;
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1317,7 +1319,7 @@ test_nc_put_att(void)
     def_dims(ncid);
     def_vars(ncid);
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	varid = VARID(i);
         for (j = 0; j < NATTS(i); j++) {
 	    name = ATT_NAME(i,j);
@@ -1389,10 +1391,10 @@ test_nc_copy_att(void)
     size_t length;              /* of att */
     char  value;
 
-    err = nc_open(testfile, NC_NOWRITE, &ncid_in);
+    err = file_open(testfile, NC_NOWRITE, &ncid_in);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid_out);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid_out);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1400,7 +1402,7 @@ test_nc_copy_att(void)
     def_dims(ncid_out);
     def_vars(ncid_out);
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         varid = VARID(i);
         for (j = 0; j < NATTS(i); j++) {
             name = ATT_NAME(i,j);
@@ -1436,7 +1438,7 @@ test_nc_copy_att(void)
     err = nc_close(ncid_out);
     IF (err)
         error("nc_close: %s", nc_strerror(err));
-    err = nc_open(scratch, NC_WRITE, &ncid_out);
+    err = file_open(scratch, NC_WRITE, &ncid_out);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     check_atts(ncid_out);
@@ -1463,7 +1465,7 @@ test_nc_copy_att(void)
     err = nc_enddef(ncid_out);
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	if (NATTS(i) > 0 && ATT_LEN(i,j) > 0) {
 	    err = nc_rename_att(ncid_out, i, att_name[i][0], "a");
 	    IF (err)
@@ -1478,10 +1480,10 @@ test_nc_copy_att(void)
         error("nc_close: %s", nc_strerror(err));
 
 	/* Reopen & check */
-    err = nc_open(scratch, NC_WRITE, &ncid_out);
+    err = file_open(scratch, NC_WRITE, &ncid_out);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	if (NATTS(i) > 0 && ATT_LEN(i,j) > 0) {
 	    err = nc_inq_att(ncid_out, i, "a", &datatype, &length);
 	    IF (err)
@@ -1539,7 +1541,7 @@ test_nc_rename_att(void)
     double value[MAX_NELS];
     double expect;
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1551,7 +1553,7 @@ test_nc_rename_att(void)
     def_vars(ncid);
     put_atts(ncid);
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         varid = VARID(i);
         for (j = 0; j < NATTS(i); j++) {
 	    attname = ATT_NAME(i,j);
@@ -1578,11 +1580,11 @@ test_nc_rename_att(void)
     err = nc_close(ncid);
     IF (err)
         error("nc_close: %s", nc_strerror(err));
-    err = nc_open(scratch, NC_WRITE, &ncid);
+    err = file_open(scratch, NC_WRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         varid = VARID(i);
         for (j = 0; j < NATTS(i); j++) {
 	    attname = ATT_NAME(i,j);
@@ -1636,7 +1638,7 @@ test_nc_rename_att(void)
 	/* Now in data mode */
 	/* Try making names even longer. Then restore original names */
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
         varid = VARID(i);
         for (j = 0; j < NATTS(i); j++) {
 	    attname = ATT_NAME(i,j);
@@ -1689,7 +1691,7 @@ test_nc_del_att(void)
     int varid;
     char *name;                 /* of att */
 
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1701,7 +1703,7 @@ test_nc_del_att(void)
     def_vars(ncid);
     put_atts(ncid);
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	varid = VARID(i);
 	numatts = NATTS(i);
         for (j = 0; j < numatts; j++) {
@@ -1737,7 +1739,7 @@ test_nc_del_att(void)
     err = nc_close(ncid);
     IF (err)
         error("nc_close: %s", nc_strerror(err));
-    err = nc_open(scratch, NC_WRITE, &ncid);
+    err = file_open(scratch, NC_WRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     err = nc_inq_natts(ncid, &natts);
@@ -1745,7 +1747,7 @@ test_nc_del_att(void)
 	error("nc_inq_natts: %s", nc_strerror(err));
     IF (natts != 0)
 	error("natts: expected %d, got %d", 0, natts);
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	varid = VARID(i);
 	err = nc_inq_varnatts(ncid, varid, &natts);
 	IF (err)
@@ -1763,7 +1765,7 @@ test_nc_del_att(void)
     IF (err)
         error("nc_enddef: %s", nc_strerror(err));
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	varid = VARID(i);
 	numatts = NATTS(i);
         for (j = 0; j < numatts; j++) {
@@ -1814,7 +1816,7 @@ test_nc_set_fill(void)
 	error("bad ncid: status = %d", err);
 
 	/* try in read-only mode */
-    err = nc_open(testfile, NC_NOWRITE, &ncid);
+    err = file_open(testfile, NC_NOWRITE, &ncid);
     IF (err)
         error("nc_open: %s", nc_strerror(err));
     err = nc_set_fill(ncid, NC_NOFILL, &old_fillmode);
@@ -1825,7 +1827,7 @@ test_nc_set_fill(void)
         error("nc_close: %s", nc_strerror(err));
 
 	/* create scratch */
-    err = nc_create(scratch, NC_NOCLOBBER, &ncid);
+    err = file_create(scratch, NC_NOCLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1873,7 +1875,7 @@ test_nc_set_fill(void)
         error("nc_put_var1_text: %s", nc_strerror(err));
 
 	/* get all variables & check all values equal default fill */
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	switch (var_type[i]) {
 	    case NC_CHAR:   fill = NC_FILL_CHAR; break;
 	    case NC_BYTE:   fill = NC_FILL_BYTE; break;
@@ -1909,7 +1911,7 @@ test_nc_set_fill(void)
     err = nc_close(ncid);
     IF (err)
         error("nc_close: %s", nc_strerror(err));
-    err = nc_create(scratch, NC_CLOBBER, &ncid);
+    err = file_create(scratch, NC_CLOBBER, &ncid);
     IF (err) {
         error("nc_create: %s", nc_strerror(err));
         return;
@@ -1919,7 +1921,7 @@ test_nc_set_fill(void)
 
 	/* set _FillValue = 42 for all vars */
     text = fill = 42;
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	if (var_type[i] == NC_CHAR) {
 	    err = nc_put_att_text(ncid, i, "_FillValue", 1, &text);
 	    IF (err)
@@ -1941,7 +1943,7 @@ test_nc_set_fill(void)
         error("nc_put_var1_text: %s", nc_strerror(err));
 
 	/* get all variables & check all values equal 42 */
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	for (j = 0; j < var_nels[i]; j++) {
             err = toMixedBase(j, var_rank[i], var_shape[i], index);
             IF (err)
@@ -1973,7 +1975,8 @@ test_nc_set_fill(void)
 }
 
 /* This function gets the version of a netCDF file, 1 is for netCDF
-   classic, 2 for 64-bit offset format, (someday) 3 for HDF5 format.
+   classic, 2 for 64-bit offset format, (someday) 3 for HDF5 format,
+   5 for 64-bit data format (CDF-5).
 */
 #define MAGIC_NUM_LEN 4
 static
@@ -1997,7 +2000,8 @@ nc_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)
+	  magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET ||
+	  magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5)
 	 *version = magic[MAGIC_NUM_LEN-1];
       else
 	 return NC_ENOTNC;
@@ -2033,16 +2037,18 @@ test_nc_set_default_format(void)
 	error("bad default format: status = %d", err);
 
     /* NULL old_formatp */
-    err = nc_set_default_format(NC_FORMAT_64BIT, NULL);
+    err = nc_set_default_format(NC_FORMAT_64BIT_OFFSET, NULL);
     IF (err)
 	error("null old_fortmatp: status = %d", err);
 
     /* Cycle through available formats. */
-    for(i=1; i<3; 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 = nc_set_default_format(i, NULL)))
 	  error("setting classic format: status = %d", err);
-       if ((err=nc_create(scratch, NC_CLOBBER, &ncid)))
+       if ((file_create(scratch, NC_CLOBBER, &ncid)))
 	  error("bad nc_create: status = %d", err);
        if ((err=nc_put_att_text(ncid, NC_GLOBAL, "testatt", 
 				sizeof("blah"), "blah")))
@@ -2050,9 +2056,18 @@ test_nc_set_default_format(void)
        if ((err=nc_close(ncid)))
 	  error("bad close: status = %d", err);
        if ((err = nc_get_file_version(scratch, &version)))
-	  error("bad file version = %d", err);
-       if (version != i)
-	  error("bad file version = %d", err);
+	  error("bad file version = %d", version);
+       if (version != i) {
+#if 0
+          if (i == 4) {
+              if (version == 3) continue;
+	      printf("expect version 3 but got %d (file=%s)",version,scratch);
+              continue;
+          }
+#endif
+	  printf("expect version %d but got %d (file=%s)",i,version,scratch);
+	  error("bad file version = %d", version);
+	}
     }
 
     /* Remove the left-over file. */
diff --git a/nc_test/tests.h b/nc_test/tests.h
index 5943561..9a46755 100644
--- a/nc_test/tests.h
+++ b/nc_test/tests.h
@@ -1,7 +1,7 @@
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: tests.h,v 1.39 2008/09/21 13:11:23 ed Exp $
+ *   $Id: tests.h 2785 2014-10-26 05:21:20Z wkliao $
  *********************************************************************/
 
 #include <config.h>
@@ -13,6 +13,9 @@
 #include <float.h>
 #define NO_NETCDF_2 1
 #include "netcdf.h"
+#ifdef USE_PARALLEL
+#include "netcdf_par.h"
+#endif
 #include "error.h"
 
 #if defined(_CRAY) && !defined(_CRAYIEEE) && !defined(__crayx1)
@@ -51,6 +54,40 @@
 #endif
 #define X_DOUBLE_MIN	(-X_DOUBLE_MAX)
 
+#define X_SCHAR_MAX     X_CHAR_MAX
+#define X_SCHAR_MIN     X_CHAR_MIN
+#define X_UCHAR_MAX     UCHAR_MAX
+#define X_UCHAR_MIN     0
+#define X_UBYTE_MAX     X_UCHAR_MAX
+#define X_UBYTE_MIN     X_UCHAR_MIN
+#define X_USHORT_MAX    USHRT_MAX
+#define X_USHORT_MIN    0
+#define X_UINT_MAX      UINT_MAX
+#define X_UINT_MIN      0
+
+#ifndef LLONG_MAX
+#define LLONG_MAX  0x7fffffffffffffffLL
+#endif
+#ifndef LLONG_MIN
+#define LLONG_MIN (-0x7fffffffffffffffLL-1)
+#endif
+#ifndef ULLONG_MAX
+#define ULLONG_MAX  0xffffffffffffffffULL
+#endif
+
+#ifndef X_INT64_MAX
+#define X_INT64_MAX    LLONG_MAX
+#endif
+#ifndef X_INT64_MIN
+#define X_INT64_MIN    LLONG_MIN
+#endif
+#ifndef X_UINT64_MAX
+#define X_UINT64_MAX  ULLONG_MAX
+#endif
+#ifndef X_UINT64_MIN
+#define X_UINT64_MIN  ULLONG_MIN
+#endif
+
 
 #if _SX /* NEC SUPER UX */
 #if _INT64
@@ -86,9 +123,9 @@
 
     /* Parameters of test data */
 
-#define NTYPES 6
+#define NTYPES 11
 #define NDIMS 5
-#define NVARS 136
+#define NVARS 166
 #define NRECS 2
 #define NGATTS NTYPES
 #define RECDIM 0
@@ -97,6 +134,10 @@
 #define MAX_DIM_LEN 4
 #define MAX_NATTS 3
 
+extern int numGatts;  /* number of global attributes */
+extern int numVars;   /* number of variables */
+extern int numTypes;  /* number of netCDF data types to test */
+
 
     /* Limits of internal types */
 
@@ -108,6 +149,13 @@
 #define long_min LONG_MIN
 #define float_min (-FLT_MAX)
 #define double_min (-DBL_MAX)
+#define ushort_min 0
+#define uint_min 0
+#define ulong_min 0
+#define int64_min LLONG_MIN
+#define longlong_min int64_min
+#define uint64_min 0
+#define ulonglong_min uint64_min
 
 #define text_max CHAR_MAX
 #define uchar_max UCHAR_MAX
@@ -117,6 +165,13 @@
 #define long_max LONG_MAX
 #define float_max FLT_MAX
 #define double_max DBL_MAX
+#define ushort_max USHRT_MAX
+#define uint_max UINT_MAX
+#define ulong_max ULONG_MAX
+#define int64_max LLONG_MAX
+#define longlong_max int64_max
+#define uint64_max ULLONG_MAX
+#define ulonglong_max uint64_max
 
 
 
@@ -140,9 +195,29 @@ extern "C" {
 
     /* Non-standard internal types */
 
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
 typedef char text;
 typedef signed char schar;
 
+#ifndef HAVE_USHORT
+typedef unsigned short int  ushort;
+#endif
+
+#ifndef HAVE_UINT
+typedef unsigned       int  uint;
+#endif
+
+#ifndef HAVE_INT64
+typedef          long long  int64;
+#endif
+
+#ifndef HAVE_UINT64
+typedef unsigned long long  uint64;
+#endif
+
 
     /* Global variables - filenames */
 
@@ -179,7 +254,7 @@ extern size_t gatt_len[NGATTS];
     /* varid is -1 for NC_GLOBAL so can do global atts in same loop */
 
 #define VARID(varid)      (varid < 0 ? NC_GLOBAL : varid)
-#define NATTS(varid)      (varid < 0 ? NGATTS : var_natts[varid])
+#define NATTS(varid)      (varid < 0 ? numGatts : var_natts[varid])
 #define ATT_NAME(varid,j) (varid < 0 ? gatt_name[j] : att_name[varid][j])
 #define ATT_TYPE(varid,j) (varid < 0 ? gatt_type[j] : att_type[varid][j])
 #define ATT_LEN(varid,j)  (varid < 0 ? gatt_len[j] : att_len[varid][j])
@@ -218,6 +293,10 @@ extern void test_nc_get_var_short(void);
 extern void test_nc_get_var_text(void);
 extern void test_nc_get_var_uchar(void);
 extern void test_nc_get_var(void);
+extern void test_nc_get_var_ushort(void);
+extern void test_nc_get_var_uint(void);
+extern void test_nc_get_var_longlong(void);
+extern void test_nc_get_var_ulonglong(void);
 
 extern void test_nc_get_var1_double(void);
 extern void test_nc_get_var1_float(void);
@@ -228,6 +307,10 @@ extern void test_nc_get_var1_short(void);
 extern void test_nc_get_var1_text(void);
 extern void test_nc_get_var1_uchar(void);
 extern void test_nc_get_var1(void);
+extern void test_nc_get_var1_ushort(void);
+extern void test_nc_get_var1_uint(void);
+extern void test_nc_get_var1_longlong(void);
+extern void test_nc_get_var1_ulonglong(void);
 
 extern void test_nc_get_vara_double(void);
 extern void test_nc_get_vara_float(void);
@@ -238,6 +321,10 @@ extern void test_nc_get_vara_short(void);
 extern void test_nc_get_vara_text(void);
 extern void test_nc_get_vara_uchar(void);
 extern void test_nc_get_vara(void);
+extern void test_nc_get_vara_ushort(void);
+extern void test_nc_get_vara_uint(void);
+extern void test_nc_get_vara_longlong(void);
+extern void test_nc_get_vara_ulonglong(void);
 
 extern void test_nc_get_vars(void);
 extern void test_nc_get_vars_double(void);
@@ -249,6 +336,10 @@ extern void test_nc_get_vars_short(void);
 extern void test_nc_get_vars_text(void);
 extern void test_nc_get_vars_uchar(void);
 extern void test_nc_get_vars(void);
+extern void test_nc_get_vars_ushort(void);
+extern void test_nc_get_vars_uint(void);
+extern void test_nc_get_vars_longlong(void);
+extern void test_nc_get_vars_ulonglong(void);
 
 extern void test_nc_get_varm(void);
 extern void test_nc_get_varm_double(void);
@@ -260,6 +351,10 @@ extern void test_nc_get_varm_short(void);
 extern void test_nc_get_varm_text(void);
 extern void test_nc_get_varm_uchar(void);
 extern void test_nc_get_varm(void);
+extern void test_nc_get_varm_ushort(void);
+extern void test_nc_get_varm_uint(void);
+extern void test_nc_get_varm_longlong(void);
+extern void test_nc_get_varm_ulonglong(void);
 
 extern void test_nc_get_att(void);
 extern void test_nc_get_att_double(void);
@@ -270,6 +365,10 @@ extern void test_nc_get_att_schar(void);
 extern void test_nc_get_att_short(void);
 extern void test_nc_get_att_text(void);
 extern void test_nc_get_att_uchar(void);
+extern void test_nc_get_att_ushort(void);
+extern void test_nc_get_att_uint(void);
+extern void test_nc_get_att_longlong(void);
+extern void test_nc_get_att_ulonglong(void);
 
 extern void test_nc_put_att(void);
 extern void test_nc_put_var_double(void);
@@ -281,6 +380,10 @@ extern void test_nc_put_var_short(void);
 extern void test_nc_put_var_text(void);
 extern void test_nc_put_var_uchar(void);
 extern void test_nc_put_var(void);
+extern void test_nc_put_var_ushort(void);
+extern void test_nc_put_var_uint(void);
+extern void test_nc_put_var_longlong(void);
+extern void test_nc_put_var_ulonglong(void);
 
 extern void test_nc_put_var1_double(void);
 extern void test_nc_put_var1_float(void);
@@ -291,6 +394,10 @@ extern void test_nc_put_var1_short(void);
 extern void test_nc_put_var1_text(void);
 extern void test_nc_put_var1_uchar(void);
 extern void test_nc_put_var1(void);
+extern void test_nc_put_var1_ushort(void);
+extern void test_nc_put_var1_uint(void);
+extern void test_nc_put_var1_longlong(void);
+extern void test_nc_put_var1_ulonglong(void);
 
 extern void test_nc_put_vara_double(void);
 extern void test_nc_put_vara_float(void);
@@ -301,6 +408,10 @@ extern void test_nc_put_vara_short(void);
 extern void test_nc_put_vara_text(void);
 extern void test_nc_put_vara_uchar(void);
 extern void test_nc_put_vara(void);
+extern void test_nc_put_vara_ushort(void);
+extern void test_nc_put_vara_uint(void);
+extern void test_nc_put_vara_longlong(void);
+extern void test_nc_put_vara_ulonglong(void);
 
 extern void test_nc_put_vars_double(void);
 extern void test_nc_put_vars_float(void);
@@ -311,6 +422,10 @@ extern void test_nc_put_vars_short(void);
 extern void test_nc_put_vars_text(void);
 extern void test_nc_put_vars_uchar(void);
 extern void test_nc_put_vars(void);
+extern void test_nc_put_vars_ushort(void);
+extern void test_nc_put_vars_uint(void);
+extern void test_nc_put_vars_longlong(void);
+extern void test_nc_put_vars_ulonglong(void);
 
 extern void test_nc_put_varm_double(void);
 extern void test_nc_put_varm_float(void);
@@ -321,6 +436,10 @@ extern void test_nc_put_varm_short(void);
 extern void test_nc_put_varm_text(void);
 extern void test_nc_put_varm_uchar(void);
 extern void test_nc_put_varm(void);
+extern void test_nc_put_varm_ushort(void);
+extern void test_nc_put_varm_uint(void);
+extern void test_nc_put_varm_longlong(void);
+extern void test_nc_put_varm_ulonglong(void);
 
 extern void test_nc_put_att_double(void);
 extern void test_nc_put_att_float(void);
@@ -330,6 +449,10 @@ extern void test_nc_put_att_schar(void);
 extern void test_nc_put_att_short(void);
 extern void test_nc_put_att_text(void);
 extern void test_nc_put_att_uchar(void);
+extern void test_nc_put_att_ushort(void);
+extern void test_nc_put_att_uint(void);
+extern void test_nc_put_att_longlong(void);
+extern void test_nc_put_att_ulonglong(void);
 
 extern void test_nc_create(void);
 extern void test_nc_redef(void);
@@ -370,7 +493,13 @@ typedef enum {
 	NCT_INT =	20,	/* int */
 	NCT_LONG =	22,	/* long */
 	NCT_FLOAT =	36,	/* float */
-	NCT_DOUBLE =	40	/* double */
+	NCT_DOUBLE =	40,	/* double */
+        NCT_USHORT =    41,
+        NCT_UINT =      42,
+        NCT_INT64 =     43,
+#define NCT_LONGLONG NCT_INT64
+        NCT_UINT64 =    44
+#define NCT_ULONGLONG NCT_UINT64
 } nct_itype;
 
 int inRange3(const double value, const nc_type datatype, const nct_itype itype);
@@ -426,6 +555,10 @@ void check_atts(int  ncid);
 
 void check_file(char *filename);
 
+int file_create(const char *filename, int cmode, int *ncid);
+
+int file_open(const char *filename, int omode, int *ncid);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/nc_test/tst_addvar.c b/nc_test/tst_addvar.c
new file mode 100644
index 0000000..d6a93f9
--- /dev/null
+++ b/nc_test/tst_addvar.c
@@ -0,0 +1,84 @@
+/* This program adds two new variables to an existing netCDF file.
+ * It is used to test if netCDF can correctly calculate the file offsets
+ * for the two new variables, in particular for files that align the
+ * fix-size variables to a boundary larger than 4 bytes, for instance
+ * a file created by PnetCDF with defaut alignment of 512 bytes.
+ *
+ * This program should run after tst_pnetcdf.c and takes the output file
+ * from tst_pnetcdf.c as input on the command-line.
+ *
+ * To check the file offsets for all variables, adding a printf statement is
+ * necessary in netcdf-4.3.3.1/libsrc/nc3internal.c around line 222,
+ * for example,
+ * printf("var %s: begin=%ld len=%ld end=%ld\n",(*vpp)->name->cp, (*vpp)->begin, (*vpp)->len, (*vpp)->begin+(*vpp)->len);
+ *
+ * Check the first new variable's begin to see whether it is less than
+ * the last variable's offset in the existing file.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <netcdf.h>
+
+#define ERR {if(err!=NC_NOERR){printf("Error at line=%d: %s\n", __LINE__, nc_strerror(err));}}
+
+int main(int argc, char** argv) {
+    int i, j, err, nerrs, ncid, varid[5], dimid[2];
+    int old_buf[3][5], get_buf[3][5], new_buf[1024];
+
+    if (argc != 2) {
+        printf("Usage: %s [filename]\n",argv[0]);
+        exit(0);
+    }
+
+    err = nc_open(argv[1], NC_WRITE, &ncid); ERR
+
+    /* read all fixed-size variables */
+    err = nc_inq_varid(ncid, "fixed_var_1", &varid[0]);
+    err = nc_inq_varid(ncid, "fixed_var_3", &varid[1]);
+    err = nc_inq_varid(ncid, "fixed_var_5", &varid[2]);
+    err = nc_get_var_int(ncid, varid[0], old_buf[0]); ERR
+    err = nc_get_var_int(ncid, varid[1], old_buf[1]); ERR
+    err = nc_get_var_int(ncid, varid[2], old_buf[2]); ERR
+
+    err = nc_redef(ncid); ERR
+
+    /* add 2 new dimensions */
+    err = nc_def_dim(ncid, "new_dim_1", 32, &dimid[0]); ERR
+    err = nc_def_dim(ncid, "new_dim_2", 32, &dimid[1]); ERR
+
+    /* add 2 new dimensions */
+    err = nc_def_var(ncid, "new_var1", NC_INT,   2, dimid, &varid[3]); ERR
+    err = nc_def_var(ncid, "new_var2", NC_FLOAT, 2, dimid, &varid[4]); ERR
+    err = nc_enddef(ncid); ERR
+
+    /* write more than 512 bytes (the default alignment used in PnetCDF) */
+    for (i=0; i<1024; i++) new_buf[i] = -1;
+    err = nc_put_var_int(ncid, varid[3], new_buf); ERR
+
+    /* read and check all variables from the original file */
+    err = nc_get_var_int(ncid, varid[0], get_buf[0]); ERR
+    err = nc_get_var_int(ncid, varid[1], get_buf[1]); ERR
+    err = nc_get_var_int(ncid, varid[2], get_buf[2]); ERR
+
+    nerrs = 0;
+    for (i=0; i<3; i++) {
+        char varname[32];
+        sprintf(varname, "fixed_var_%d",2*i+1);
+        for (j=0; j<5; j++) {
+            if (get_buf[i][j] != old_buf[i][j]) {
+                printf("Error in %s line %d: expecting %s[%d]=%d but got %d\n",
+                       __FILE__,__LINE__,varname,j,old_buf[i][j],get_buf[i][j]);
+                nerrs++;
+            }
+        }
+    }
+
+    err = nc_close(ncid); ERR
+
+    if (nerrs > 0) exit(-1);
+/*
+    SUMMARIZE_ERR;
+    FINAL_RESULTS;
+*/
+    return 0;
+}
diff --git a/nc_test/tst_atts.c b/nc_test/tst_atts.c
index a0b48ae..506797d 100644
--- a/nc_test/tst_atts.c
+++ b/nc_test/tst_atts.c
@@ -6,7 +6,7 @@
    Unicode names encoded with UTF-8. It is the NETCDF3 equivalent
    of tst_unicode.c
 
-   $Id$
+   $Id: tst_atts.c 2792 2014-10-27 06:02:59Z wkliao $
 */
 
 #include <nc_tests.h>
@@ -454,7 +454,11 @@ create_file()
     int i444_dims[RANK_i444];
 
     /* enter define mode */
+#ifdef TEST_PNETCDF
+    stat = nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
     stat = nc_create(FILE_NAME, NC_CLOBBER, &ncid);
+#endif
     check_err(stat,__LINE__,__FILE__);
 
     /* define dimensions */
@@ -2342,6 +2346,9 @@ create_file()
 int
 main(int argc, char **argv)
 {
+#ifdef TEST_PNETCDF
+   MPI_Init(&argc, &argv);
+#endif
    printf("\n*** Testing netCDF attributes.\n");
    printf("*** testing attribute renaming for memory leak, like nc_test...");
    {
@@ -2354,7 +2361,11 @@ main(int argc, char **argv)
       char char_data = 'a';
 
       /* Create a file with a var with two atts. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL|NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_def_var(ncid, VAR_NAME, NC_INT, 0, NULL, &varid)) ERR;
       if (nc_put_att(ncid, varid, A1_NAME, NC_CHAR, 1, &char_data)) ERR;
       if (nc_put_att(ncid, varid, B1_NAME, NC_CHAR, 1, &char_data)) ERR;
@@ -2377,9 +2388,15 @@ main(int argc, char **argv)
       {
 	  static const int var_FillValue_atts[] = {42, -99} ;
 	  float var_FillValue_att = -99 ;
+	  int res = 0;
 	  /* This should return error, because attribute has too many values */
-	  if (nc_put_att_int(ncid, varid, "_FillValue", NC_INT, 2, var_FillValue_atts) 
+#if 1
+	  res=nc_put_att_int(ncid, varid, "_FillValue", NC_INT, 2, var_FillValue_atts);
+	  if(res != NC_EINVAL) ERR;
+#else
+	  if ((res=nc_put_att_int(ncid, varid, "_FillValue", NC_INT, 2, var_FillValue_atts))
 	      != NC_EINVAL) ERR;
+#endif
 	  /* This also should return error, because types don't match */
 	  if (nc_put_att_float(ncid, varid, "_FillValue", NC_FLOAT, 1, &var_FillValue_att) 
 	      != NC_EBADTYPE) ERR;
@@ -2390,7 +2407,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
 
       /* Reopen the file and check it. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_inq_nvars(ncid, &nvars)) ERR;
       if (nvars != 1) ERR_RET;
       for (v = 0; v < nvars; v++)
@@ -2418,7 +2439,11 @@ main(int argc, char **argv)
       if (create_file()) ERR;
 
       /* Open the file. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_redef(ncid)) ERR;
 
       /* Add a global attribute A_NAME. */
@@ -2443,7 +2468,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
 
       /* Reopen the file and check it. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_inq_nvars(ncid, &nvars)) ERR;
       if (nvars != NVARS) ERR_RET;
       for (v = 0; v < nvars; v++)
@@ -2459,5 +2488,8 @@ main(int argc, char **argv)
 
    }
    SUMMARIZE_ERR;
+#ifdef TEST_PNETCDF
+   MPI_Finalize();
+#endif
    FINAL_RESULTS;
 }
diff --git a/nc_test/tst_atts3.c b/nc_test/tst_atts3.c
index fdd2049..01d2eea 100644
--- a/nc_test/tst_atts3.c
+++ b/nc_test/tst_atts3.c
@@ -4,12 +4,16 @@
 
    Test attributes. 
 
-   $Id: tst_atts1.c 2190 2012-05-21 11:20:44Z russ $
+   $Id: tst_atts3.c 2796 2014-10-28 03:40:29Z wkliao $
 */
 
+#include "config.h"
 #include <nc_tests.h>
-#include "netcdf.h"
 #include <signal.h>
+#include "netcdf.h"
+#ifdef USE_PARALLEL
+#include "netcdf_par.h"
+#endif
 
 #define FILE_NAME "tst_atts_3.nc"
 #define FILE_NAME2 "tst_atts_2.nc"
@@ -93,7 +97,11 @@ tst_att_ordering(int cmode)
    int j;
 
    /* Create a file with some global atts. */
+#ifdef TEST_PNETCDF
+   if (nc_create_par(FILE_NAME, cmode|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
    if (nc_create(FILE_NAME, cmode, &ncid)) ERR;
+#endif
    if (nc_put_att_text(ncid, NC_GLOBAL, name[0], len[0], NULL)) ERR;      
    if (nc_put_att_schar(ncid, NC_GLOBAL, name[1], NC_BYTE, len[1], b)) ERR;      
    if (nc_put_att_short(ncid, NC_GLOBAL, name[2], NC_SHORT, len[2], s)) ERR;      
@@ -105,7 +113,11 @@ tst_att_ordering(int cmode)
    if (nc_close(ncid)) ERR;
       
    /* Reopen the file and check the order. */
+#ifdef TEST_PNETCDF
+   if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
    if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
    for (j = 0; j < NUM_ATTS; j++)
    {
       if (nc_inq_attname(ncid, NC_GLOBAL, j, name_in)) ERR;
@@ -136,6 +148,9 @@ main(int argc, char **argv)
     unsigned long long ulonglong_out[ATT_LEN] = {0LL, 128LL, 3123456789LL};
 #endif
 
+#ifdef TEST_PNETCDF
+   MPI_Init(&argc, &argv);
+#endif
     (void) signal(SIGFPE, SIG_IGN);
 
    printf("\n*** Testing netcdf-3 attribute functions.\n");
@@ -149,13 +164,21 @@ main(int argc, char **argv)
       int j;
 
       /* Create a file with some global atts. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       for (j = 0; j < NUM_SIMPLE_ATTS; j++)
 	 if (nc_put_att_int(ncid, NC_GLOBAL, name[j], NC_INT, 0, NULL)) ERR;      
       if (nc_close(ncid)) ERR;
       
       /* Reopen the file and check the order. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
       for (j = 0; j < NUM_SIMPLE_ATTS; j++)
       {
 	 if (nc_inq_attname(ncid, NC_GLOBAL, j, name_in)) ERR;
@@ -176,7 +199,11 @@ main(int argc, char **argv)
       char *speech_in;
 
       /* This won't work, because classic files can't create these types. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_int(ncid, NC_GLOBAL, ATT_INT_NAME, NC_INT, ATT_LEN, 
 			    int_out)) ERR;      
       /* It is also OK to read classic types converted into
@@ -193,7 +220,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
 
       /* Create a file with a global attribute of each type. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, strlen(speech)+1, speech)) ERR;      
       if (nc_put_att_schar(ncid, NC_GLOBAL, ATT_SCHAR_NAME, NC_BYTE, ATT_LEN, schar_out)) ERR;      
       if (nc_put_att_short(ncid, NC_GLOBAL, ATT_SHORT_NAME, NC_SHORT, ATT_LEN, short_out)) ERR;      
@@ -203,7 +234,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
 
       /* Open the file and check attributes. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
       /* Check text. */
       if (nc_inq_att(ncid, NC_GLOBAL, ATT_TEXT_NAME, &att_type, &att_len))
 	 ERR;
@@ -238,7 +273,11 @@ main(int argc, char **argv)
       int i;
 
       /* Reopen the file and try different type conversions. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
 
       /* No text conversions are allowed, and people who try them should
        * be locked up, away from decent folk! */
@@ -379,7 +418,11 @@ main(int argc, char **argv)
       /*int int_in[ATT_LEN], int_out[ATT_LEN] = {NC_MIN_INT, 128, NC_MAX_INT};*/
 
       /* Create a file with a global attribute of each type of zero length. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, 0, NULL)) ERR;
       if (nc_put_att_schar(ncid, NC_GLOBAL, ATT_SCHAR_NAME, NC_BYTE, 0, NULL)) ERR;
       if (nc_put_att_short(ncid, NC_GLOBAL, ATT_SHORT_NAME, NC_SHORT, 0, NULL)) ERR;
@@ -401,7 +444,11 @@ main(int argc, char **argv)
       size_t len;
       nc_type xtype;
 
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
       if (nc_get_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, NULL)) ERR;
       if (nc_inq_att(ncid, NC_GLOBAL, ATT_TEXT_NAME, &xtype, &len)) ERR;
       if (len || xtype != NC_CHAR) ERR;
@@ -440,7 +487,11 @@ main(int argc, char **argv)
 
 
       /* Create a file with a global attribute of each type of zero length. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_enddef(ncid)) ERR;
       if (nc_redef(ncid)) ERR;
       if (nc_put_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, 0, NULL)) ERR;
@@ -453,7 +504,11 @@ main(int argc, char **argv)
 
       /* Make sure we can read all these zero-length atts added during a
        * redef. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
       if (nc_get_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, NULL)) ERR;
       if (nc_get_att_schar(ncid, NC_GLOBAL, ATT_SCHAR_NAME, schar_in)) ERR;
       if (nc_get_att_short(ncid, NC_GLOBAL, ATT_SHORT_NAME, short_in)) ERR;
@@ -480,13 +535,21 @@ main(int argc, char **argv)
       int int_out[ATT_LEN] = {-100000, 128, 100000};
 
       /* Create a file with a global attribute. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, strlen(speech)+1, 
 			  speech)) ERR;      
       if (nc_close(ncid)) ERR;
       
       /* Rename it. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_inq_attid(ncid, NC_GLOBAL, ATT_TEXT_NAME, &attid_in)) ERR;
       if (attid_in != 0) ERR;
       if (nc_inq_attname(ncid, NC_GLOBAL, attid_in, name_in)) ERR;
@@ -497,7 +560,11 @@ main(int argc, char **argv)
       if (strcmp(name_in, ATT_TEXT_NAME2)) ERR;
       if (nc_close(ncid)) ERR;
 
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_inq_att(ncid, NC_GLOBAL, ATT_TEXT_NAME2, &att_type, &att_len)) ERR;
       if (att_type != NC_CHAR || att_len != strlen(speech) + 1) ERR;
       if (!(speech_in = malloc(att_len + 1))) ERR;
@@ -508,13 +575,21 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
 
       /* Now delete the att. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_redef(ncid)) ERR;
       if (nc_del_att(ncid, NC_GLOBAL, ATT_TEXT_NAME2)) ERR;
       if (nc_close(ncid)) ERR;
 
       /* Now create a file with a variable, which has an att. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, strlen(speech)+1, speech)) ERR;      
       if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
       if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimids[1])) ERR;
@@ -523,14 +598,22 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
       
       /* Reopen the file and delete it. Make sure it's gone. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_redef(ncid)) ERR;
       if (nc_del_att(ncid, 0, ATT_INT_NAME)) ERR;
       if (nc_close(ncid)) ERR;
 
       /* Reopen the file and readd the attribute. Enddef and redef,
        * and delete it, then check to make sure it's gone. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_redef(ncid)) ERR;
       if (nc_put_att_int(ncid, varid, ATT_INT_NAME, NC_INT, 3, int_out)) ERR;      
       if (nc_enddef(ncid)) ERR;
@@ -552,13 +635,21 @@ main(int argc, char **argv)
       const int number = 42;
 
       /* Create a file with several global attributes. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_int(ncid, NC_GLOBAL, ATT0, NC_INT, 1, &number)) ERR;
       if (nc_put_att_int(ncid, NC_GLOBAL, ATT1, NC_INT, 1, &number)) ERR;
       if (nc_close(ncid)) ERR;
       
       /* Open it and check the order. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_inq_attid(ncid, NC_GLOBAL, ATT0, &attid_in)) ERR;
       if (attid_in != 0) ERR;
       if (nc_inq_attid(ncid, NC_GLOBAL, ATT1, &attid_in)) ERR;
@@ -566,7 +657,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
 
       /* Now create a file with a variable, which has two atts. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
       if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimids[1])) ERR;
       if (nc_def_var(ncid, VAR1_NAME, NC_INT, 2, dimids, &varid)) ERR;
@@ -575,7 +670,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
       
       /* Reopen the file and check the order of the attributes on the var. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_WRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
+#endif
       if (nc_inq_attid(ncid, 0, ATT0, &attid_in)) ERR;
       if (attid_in != 0) ERR;
       if (nc_inq_attid(ncid, 0, ATT1, &attid_in)) ERR;
@@ -600,7 +699,11 @@ main(int argc, char **argv)
       char name_in[NC_MAX_NAME + 1];
 
       /* Create a file with one var, and attach three atts to it. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_def_var(ncid, VAR_NAME, NC_INT, 0, NULL, &varid)) ERR;
       if (nc_put_att_double(ncid, varid, A1_NAME, NC_INT, A1_LEN, dvalue)) ERR;      
       if (nc_put_att_double(ncid, varid, A2_NAME, NC_INT, A2_LEN, dvalue)) ERR;      
@@ -608,7 +711,11 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
       
       /* Reopen the file and check. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
       if (nc_inq_nvars(ncid, &nvars)) ERR;
       if (nvars != 1) ERR;
       if (nc_inq_varnatts(ncid, 0, &natts)) ERR;
@@ -640,7 +747,11 @@ main(int argc, char **argv)
    {
       int ncid, att = 1;
 
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_enddef(ncid)) ERR;
       if (nc_redef(ncid)) ERR;
       if (nc_put_att(ncid, NC_GLOBAL, ATT_1, NC_INT, 1, &att)) ERR;
@@ -649,7 +760,11 @@ main(int argc, char **argv)
 
       if (nc_close(ncid)) ERR;
 
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+#endif
       if (nc_close(ncid)) ERR;
    }
 
@@ -669,7 +784,11 @@ main(int argc, char **argv)
       double double_in[ATT_LEN], double_out[ATT_LEN] = {0.25, .5, 0.125};
 
       /* Create a file with a global attribute of each type. */
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)) ERR;
+#else
       if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
+#endif
       if (nc_put_att_text(ncid, NC_GLOBAL, ATT_TEXT_NAME, strlen(speech)+1, speech)) ERR;      
       if (nc_put_att_schar(ncid, NC_GLOBAL, ATT_SCHAR_NAME, NC_BYTE, ATT_LEN, schar_out)) ERR;      
       if (nc_put_att_short(ncid, NC_GLOBAL, ATT_SHORT_NAME, NC_SHORT, ATT_LEN, short_out)) ERR;      
@@ -678,7 +797,11 @@ main(int argc, char **argv)
       if (nc_put_att_double(ncid, NC_GLOBAL, ATT_DOUBLE_NAME, NC_DOUBLE, ATT_LEN, double_out)) ERR;      
 
       /* Create another file and copy all the attributes. */
-      if (nc_create(FILE_NAME2, NC_CLOBBER, &ncid2)) ERR;      
+#ifdef TEST_PNETCDF
+      if (nc_create_par(FILE_NAME2, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid2)) ERR;
+#else
+      if (nc_create(FILE_NAME2, NC_CLOBBER, &ncid2)) ERR;
+#endif
       if (nc_copy_att(ncid, NC_GLOBAL, ATT_TEXT_NAME, ncid2, NC_GLOBAL)) ERR;
       if (nc_copy_att(ncid, NC_GLOBAL, ATT_SCHAR_NAME, ncid2, NC_GLOBAL)) ERR;
       if (nc_copy_att(ncid, NC_GLOBAL, ATT_SHORT_NAME, ncid2, NC_GLOBAL)) ERR;
@@ -691,7 +814,11 @@ main(int argc, char **argv)
       if (nc_close(ncid2)) ERR;
 
       /* Open the file and check attributes. */
+#ifdef TEST_PNETCDF
+      if (nc_open_par(FILE_NAME2, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)) ERR;
+#else
       if (nc_open(FILE_NAME2, 0, &ncid)) ERR;
+#endif
       /* Check text. */
       if (nc_inq_att(ncid, NC_GLOBAL, ATT_TEXT_NAME, &att_type, &att_len)) ERR;
       if (att_type != NC_CHAR || att_len != strlen(speech) + 1) ERR;
@@ -718,6 +845,9 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
    }
    SUMMARIZE_ERR;
+#ifdef TEST_PNETCDF
+   MPI_Finalize();
+#endif
    FINAL_RESULTS;
 }
 
diff --git a/nc_test/tst_cdf5format.c b/nc_test/tst_cdf5format.c
new file mode 100644
index 0000000..91a65c5
--- /dev/null
+++ b/nc_test/tst_cdf5format.c
@@ -0,0 +1,228 @@
+/* This is part of the netCDF package.
+   Copyright 2005 University Corporation for Atmospheric Research/Unidata
+   See COPYRIGHT file for conditions of use.
+
+   Test fix of bug involving creation of a file with pnetcdf APIs,
+   then opening and modifying the file with netcdf.
+
+   Author: Wei-keng Liao.
+*/
+
+/*
+Goal is to verify that cdf-5 code is writing data that can
+be read by pnetcdf and vice-versa.
+*/
+
+/*
+    Compile:
+        mpicc -g -o tst_cdf5format tst_cdf5format.c -lnetcdf -lcurl -lhdf5_hl -lhdf5 -lpnetcdf -lz -lm
+    Run:
+        nc_pnc
+*/
+
+#include <nc_tests.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mpi.h>
+#include <netcdf.h>
+#include <netcdf_par.h>
+#include <assert.h>
+
+#define NVARS 6
+#define NX    5
+#define FILENAME "tst_pnetcdf.nc"
+
+static void 
+report(int stat, char* file, int line)
+{
+    fflush(stdout); /* Make sure our stdout is synced with stderr.*/
+    if(stat != 0) {
+        fprintf(stderr, "Sorry! Unexpected result, %s, line: %d: status=%d\n", \
+	        __FILE__, __LINE__,stat);
+    }
+}
+
+#define Error(stat) report(stat,__FILE__,__LINE__)
+
+/*
+Given ncid,
+write meta-data and data
+*/
+
+int
+write(int ncid, int parallel)
+{
+    int i, j, rank, nprocs, cmode, varid[NVARS], dimid[2], *buf;
+    int err = 0;
+    char str[32];
+    size_t start[2], count[2];
+    int stat = NC_NOERR;
+
+    /* define dimension */
+    if (stat=nc_def_dim(ncid, "Y", NC_UNLIMITED, &dimid[0])) Error(stat);;
+    if (stat=nc_def_dim(ncid, "X", NX,           &dimid[1])) Error(stat);;
+
+    /* Odd numbers are fixed variables, even numbers are record variables */
+    for (i=0; i<NVARS; i++) {
+        if (i%2) {
+            sprintf(str,"fixed_var_%d",i);
+            if (nc_def_var(ncid, str, NC_INT, 1, dimid+1, &varid[i])) Error(stat);;
+        }
+        else {
+            sprintf(str,"record_var_%d",i);
+            if (stat=nc_def_var(ncid, str, NC_INT, 2, dimid, &varid[i])) Error(stat);;
+        }
+    }
+    if (stat=nc_enddef(ncid)) Error(stat);;
+<<<<<<< HEAD
+=======
+
+>>>>>>> 896fe992ff193edcd1a7f2ad592d144a91de3de5
+    for (i=0; i<NVARS; i++) {
+	if(parallel) {
+            /* Note NC_INDEPENDENT is the default */
+            if (stat=nc_var_par_access(ncid, varid[i], NC_INDEPENDENT)) Error(stat);;
+	}
+    }
+
+    /* write all variables */
+    buf = (int*) malloc(NX * sizeof(int));
+    for (i=0; i<NVARS; i++) {
+        for (j=0; j<NX; j++) buf[j] = i*10 + j;
+        if (i%2) {
+            start[0] = 0; count[0] = NX;
+            if (stat=nc_put_vara_int(ncid, varid[i], start, count, buf)) Error(stat);;
+        }
+        else {
+            start[0] = 0; start[1] = 0;
+            count[0] = 1; count[1] = NX;
+            if (stat=nc_put_vara_int(ncid, varid[i], start, count, buf)) Error(stat);;
+        }
+    }
+    return NC_NOERR;
+}
+
+int
+extend(int ncid)
+{
+    int i, j, rank, nprocs, cmode, varid[NVARS], dimid[2], *buf;
+    int err = 0;
+    char str[32];
+    size_t start[2], count[2];
+    int stat = NC_NOERR;
+
+    if (stat=nc_redef(ncid)) Error(stat);;
+    /* add attributes to make header grow */
+    for (i=0; i<NVARS; i++) {
+        sprintf(str, "annotation_for_var_%d",i);
+        if (stat=nc_put_att_text(ncid, varid[i], "text_attr", strlen(str), str)) Error(stat);;
+    }
+    if (stat=nc_enddef(ncid)) Error(stat);;
+    return NC_NOERR;
+}
+
+int
+read(int ncid)
+{
+    int i, j, rank, nprocs, cmode, varid[NVARS], dimid[2], *buf;
+    int err = 0;
+    char str[32];
+    size_t start[2], count[2];
+    int stat = NC_NOERR;
+<<<<<<< HEAD
+=======
+
+>>>>>>> 896fe992ff193edcd1a7f2ad592d144a91de3de5
+    /* read variables and check their contents */
+    for (i=0; i<NVARS; i++) {
+        for (j=0; j<NX; j++) buf[j] = -1;
+        if (i%2) {
+            start[0] = 0; count[0] = NX;
+            if (stat=nc_get_var_int(ncid, varid[i], buf)) Error(stat);
+            for (j=0; j<NX; j++)
+                if (buf[j] != i*10 + j)
+                    printf("unexpected read value var i=%d buf[j=%d]=%d should be %d\n",i,j,buf[j],i*10+j);
+        }
+        else {
+            start[0] = 0; start[1] = 0;
+            count[0] = 1; count[1] = NX;
+            if (stat=nc_get_vara_int(ncid, varid[i], start, count, buf)) Error(stat);
+            for (j=0; j<NX; j++)
+                if (buf[j] != i*10+j)
+                    printf("unexpected read value var i=%d buf[j=%d]=%d should be %d\n",i,j,buf[j],i*10+j);
+        }
+    }
+    return NC_NOERR;
+}
+
+
+int main(int argc, char* argv[])
+{
+    int rank, nprocs, ncid, cmode, stat;
+/*
+    int i, j, rank, nprocs, ncid, cmode, varid[NVARS], dimid[2], *buf;
+    int err = 0;
+    char str[32];
+    size_t start[2], count[2];
+*/
+    MPI_Comm comm=MPI_COMM_SELF;
+    MPI_Info info=MPI_INFO_NULL;
+
+    MPI_Init(&argc,&argv);
+    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    if (nprocs > 1 && rank == 0)
+        printf("This test program is intended to run on ONE process\n");
+    if (rank > 0) goto fn_exit;
+
+
+#ifdef DISABLE_PNETCDF_ALIGNMENT
+    MPI_Info_create(&info);
+    MPI_Info_set(info, "nc_header_align_size", "1");
+    MPI_Info_set(info, "nc_var_align_size",    "1");
+#endif
+
+    /* pnetcdf->cdf5 */
+    printf("\nWrite using PNETCDF; Read using CDF5\n");
+    
+    cmode = NC_PNETCDF | NC_CLOBBER;
+    if (stat=nc_create_par(FILENAME, cmode, comm, info, &ncid)) Error(stat);
+    if (stat=write(ncid,1)) Error(stat);
+    if (stat=nc_close(ncid)) Error(stat);
+    /* re-open the file with netCDF (parallel) and enter define mode */
+    if (stat=nc_open_par(FILENAME, NC_WRITE|NC_PNETCDF, comm, info, &ncid)) Error(stat);
+    if(stat=extend(ncid)) Error(stat);
+    if (stat=nc_close(ncid)) Error(stat);
+
+    cmode = NC_CDF5 | NC_NOCLOBBER;
+    if (stat=nc_open(FILENAME, cmode, &ncid)) ERR_RET;
+    if (stat=read(ncid)) Error(stat);
+    if (stat=nc_close(ncid)) Error(stat);
+
+    unlink(FILENAME);
+
+    /* cdf5->pnetcdf */
+    printf("\nWrite using CDF-5; Read using PNETCDF\n");
+    cmode = NC_CDF5 | NC_CLOBBER;
+    if (stat=nc_create(FILENAME, cmode, &ncid)) ERR_RET;
+    if (stat=write(ncid,0)) Error(stat);
+    if (stat=nc_close(ncid)) Error(stat);
+    /* re-open the file with netCDF (parallel) and enter define mode */
+    if (stat=nc_open(FILENAME, NC_WRITE|NC_CDF5, &ncid)) ERR_RET;
+    if (stat=extend(ncid)) Error(stat);
+    if (stat=nc_close(ncid)) Error(stat);
+
+    cmode = NC_PNETCDF | NC_NOCLOBBER;
+    if (stat=nc_open_par(FILENAME, cmode, comm, info, &ncid)) ERR_RET;
+    if (stat=read(ncid)) Error(stat);
+    if (stat=nc_close(ncid)) Error(stat);
+
+    if (info != MPI_INFO_NULL) MPI_Info_free(&info);
+
+fn_exit:
+    MPI_Finalize();
+    SUMMARIZE_ERR;
+    FINAL_RESULTS;
+    return 0;
+}
diff --git a/nc_test/tst_diskless3.c b/nc_test/tst_diskless3.c
index 8ea38fa..9667582 100644
--- a/nc_test/tst_diskless3.c
+++ b/nc_test/tst_diskless3.c
@@ -34,9 +34,6 @@
 #define TITLE " OUTPUT FROM WRF V2.0.3.1 MODEL"
 #define ATT_NAME2 "TITLE"
 
-#undef ERR
-#define ERR report(status,__LINE__)
-
 static int status = NC_NOERR;
 
 /* Control flags  */
@@ -44,13 +41,6 @@ static int persist, usenetcdf4, mmap, diskless;
 
 static int diskmode;
 
-void report(int stat, int lno)
-{
-    fprintf(stderr,"line: %d ; %s\n",stat,nc_strerror(stat));
-    fflush(stderr);
-    exit(1);
-}
-
 /* Test a diskless file with two record vars, which grow, and has
  * attributes added. */
 static int
@@ -63,11 +53,11 @@ test_two_growing_with_att(const char *testfile)
    int v, r;
 
    /* Create a file with one ulimited dimensions, and one var. */
-   if((status=nc_create(testfile, NC_CLOBBER, &ncid))) ERR;
-   if((status=nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid))) ERR;
-   if((status=nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid[0]))) ERR;
-   if((status=nc_def_var(ncid, VAR_NAME2, NC_CHAR, 1, &dimid, &varid[1]))) ERR;
-   if((status=nc_close(ncid))) ERR;
+   if((status=nc_create(testfile, NC_CLOBBER, &ncid))) ERRSTAT(status);
+   if((status=nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid))) ERRSTAT(status);
+   if((status=nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid[0]))) ERRSTAT(status);
+   if((status=nc_def_var(ncid, VAR_NAME2, NC_CHAR, 1, &dimid, &varid[1]))) ERRSTAT(status);
+   if((status=nc_close(ncid))) ERRSTAT(status);
 
    /* Create some phoney data. */
    for (data[0] = 'a', r = 1; r < MAX_RECS; r++)
@@ -79,30 +69,30 @@ test_two_growing_with_att(const char *testfile)
    for (r = 0; r < MAX_RECS; r++)
    {
       /* Write one record of var data, a single character. */
-      if((status=nc_open(testfile, NC_WRITE, &ncid))) ERR;
+      if((status=nc_open(testfile, NC_WRITE, &ncid))) ERRSTAT(status);
       count[0] = 1;
       start[0] = r;
       sprintf(att_name, "a_%d", data[r]);
       for (v = 0; v < NUM_VARS; v++)
       {
-	 if((status=nc_put_vara_text(ncid, varid[v], start, count, &data[r]))) ERR;
-	 if((status=nc_redef(ncid))) ERR;
-	 if((status=nc_put_att_text(ncid, varid[v], att_name, 1, &data[r]))) ERR;
-	 if((status=nc_enddef(ncid))) ERR;
+	 if((status=nc_put_vara_text(ncid, varid[v], start, count, &data[r]))) ERRSTAT(status);
+	 if((status=nc_redef(ncid))) ERRSTAT(status);
+	 if((status=nc_put_att_text(ncid, varid[v], att_name, 1, &data[r]))) ERRSTAT(status);
+	 if((status=nc_enddef(ncid))) ERRSTAT(status);
       }
-      if((status=nc_close(ncid))) ERR;
+      if((status=nc_close(ncid))) ERRSTAT(status);
       
       /* Reopen the file and check it. */
-      if((status=nc_open(testfile, diskmode|NC_WRITE, &ncid))) ERR;
-      if((status=nc_inq_dimlen(ncid, 0, &len_in))) ERR;
+      if((status=nc_open(testfile, diskmode|NC_WRITE, &ncid))) ERRSTAT(status);
+      if((status=nc_inq_dimlen(ncid, 0, &len_in))) ERRSTAT(status);
       if (len_in != r + 1) ERR;
       index[0] = r;
       for (v = 0; v < NUM_VARS; v++)
       {
-	 if((status=nc_get_var1_text(ncid, varid[v], index, &data_in))) ERR;
+	 if((status=nc_get_var1_text(ncid, varid[v], index, &data_in))) ERRSTAT(status);
 	 if (data_in != data[r]) ERR;
       }
-      if((status=nc_close(ncid))) ERR; 
+      if((status=nc_close(ncid))) ERRSTAT(status); 
    } /* Next record. */
    return 0;
 }
@@ -118,29 +108,29 @@ test_one_with_att(const char *testfile)
    size_t start[NDIMS], count[NDIMS];
 
    /* Create a file with one ulimited dimensions, and one var. */
-   if((status=nc_create(testfile, NC_CLOBBER, &ncid))) ERR;
-   if((status=nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid))) ERR;
-   if((status=nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid))) ERR;
-   if((status=nc_put_att_text(ncid, NC_GLOBAL, ATT_NAME, 1, &data))) ERR;
-   if((status=nc_enddef(ncid))) ERR;
+   if((status=nc_create(testfile, NC_CLOBBER, &ncid))) ERRSTAT(status);
+   if((status=nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid))) ERRSTAT(status);
+   if((status=nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid))) ERRSTAT(status);
+   if((status=nc_put_att_text(ncid, NC_GLOBAL, ATT_NAME, 1, &data))) ERRSTAT(status);
+   if((status=nc_enddef(ncid))) ERRSTAT(status);
 
    /* Write one record of var data, a single character. */
    count[0] = 1;
    start[0] = 0;
-   if((status=nc_put_vara_text(ncid, varid, start, count, &data))) ERR;
+   if((status=nc_put_vara_text(ncid, varid, start, count, &data))) ERRSTAT(status);
 
    /* We're done! */
-   if((status=nc_close(ncid))) ERR;
+   if((status=nc_close(ncid))) ERRSTAT(status);
    
    /* Reopen the file and check it. */
-   if((status=nc_open(testfile, diskmode|NC_WRITE, &ncid))) ERR;
-   if((status=nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid))) ERR;
-   if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR;
-   if((status=nc_get_var_text(ncid, varid, &data_in))) ERR;
-   if (data_in != data) ERR;
-   if((status=nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in))) ERR;
-   if (data_in != data) ERR;
-   if((status=nc_close(ncid))) ERR; 
+   if((status=nc_open(testfile, diskmode|NC_WRITE, &ncid))) ERRSTAT(status);
+   if((status=nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid))) ERRSTAT(status);
+   if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERRSTAT(status);
+   if((status=nc_get_var_text(ncid, varid, &data_in))) ERRSTAT(status);
+   if (data_in != data) ERRSTAT(status);
+   if((status=nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in))) ERRSTAT(status);
+   if (data_in != data) ERRSTAT(status);
+   if((status=nc_close(ncid))) ERRSTAT(status); 
    return 0;
 }
 #endif
diff --git a/nc_test/tst_formatx_pnetcdf.c b/nc_test/tst_formatx_pnetcdf.c
index 07f2e0e..fa1ee1e 100644
--- a/nc_test/tst_formatx_pnetcdf.c
+++ b/nc_test/tst_formatx_pnetcdf.c
@@ -48,19 +48,56 @@ int main(int argc, char* argv[])
     MPI_Info_set(info, "nc_var_align_size",    "1");
 #endif
 
+    /* test CDF-1 file format */
     cmode = NC_PNETCDF | NC_CLOBBER;
     if (nc_create_par(FILENAME, cmode, comm, info, &ncid)) ERR_RET;
 
     if (nc_enddef(ncid)) ERR;
 
     if(nc_inq_format_extended(ncid,&format,&cmode)) ERR;
-    if(cmode != 0x8000) {
-	printf("***FAIL: mode was %08x ; expected %08x\n",cmode,0);
+    if((cmode & NC_PNETCDF) != NC_PNETCDF) {
+	printf("***FAIL at line %d: mode was %08x ; expected %08x\n",__LINE__,cmode,NC_PNETCDF);
 	ecode = 1;
 	ERR;
     }
-    if(format != NC_FORMAT_PNETCDF) {
-	printf("***FAIL: format was %d ; expected %d\n",format,NC_FORMAT_PNETCDF);
+    if(format != NC_FORMATX_PNETCDF) {
+	printf("***FAIL at line %d: format was %d ; expected %d\n",__LINE__,format,NC_FORMATX_PNETCDF);
+	ecode = 1;
+	ERR;
+    }
+
+    /* test CDF-2 file format */
+    cmode = NC_PNETCDF | NC_CLOBBER | NC_64BIT_OFFSET;
+    if (nc_create_par(FILENAME, cmode, comm, info, &ncid)) ERR_RET;
+
+    if (nc_enddef(ncid)) ERR;
+
+    if(nc_inq_format_extended(ncid,&format,&cmode)) ERR;
+    if((cmode & NC_64BIT_OFFSET) != NC_64BIT_OFFSET) {
+	printf("***FAIL at line %d: mode was %08x ; expected %08x\n",__LINE__,cmode,NC_64BIT_OFFSET);
+	ecode = 1;
+	ERR;
+    }
+    if(format != NC_FORMATX_PNETCDF) {
+	printf("***FAIL at line %d: format was %d ; expected %d\n",__LINE__,format,NC_FORMATX_PNETCDF);
+	ecode = 1;
+	ERR;
+    }
+
+    /* test CDF-5 file format */
+    cmode = NC_PNETCDF | NC_CLOBBER | NC_64BIT_DATA;
+    if (nc_create_par(FILENAME, cmode, comm, info, &ncid)) ERR_RET;
+
+    if (nc_enddef(ncid)) ERR;
+
+    if(nc_inq_format_extended(ncid,&format,&cmode)) ERR;
+    if((cmode & NC_64BIT_DATA) != NC_64BIT_DATA) {
+	printf("***FAIL at line %d: mode was %08x ; expected %08x\n",__LINE__,cmode,NC_64BIT_DATA);
+	ecode = 1;
+	ERR;
+    }
+    if(format != NC_FORMATX_PNETCDF) {
+	printf("***FAIL at line %d: format was %d ; expected %d\n",__LINE__,format,NC_FORMATX_PNETCDF);
 	ecode = 1;
 	ERR;
     }
diff --git a/nc_test/tst_meta.c b/nc_test/tst_meta.c
index 0194f67..cde11f5 100644
--- a/nc_test/tst_meta.c
+++ b/nc_test/tst_meta.c
@@ -9,6 +9,7 @@
 
 */
 
+#include <stdio.h> /* printf() */
 #include <config.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/nc_test/tst_misc.c b/nc_test/tst_misc.c
index abdabd2..4a999a9 100644
--- a/nc_test/tst_misc.c
+++ b/nc_test/tst_misc.c
@@ -9,17 +9,23 @@
   $Id: tst_misc.c,v 1.6 2010/05/05 22:15:36 dmh Exp $
 */
 
-#include <config.h>
-#include <nc_tests.h>
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
-#include <netcdf.h>
+#include "netcdf.h"
+#include "nc_tests.h"
+#ifdef USE_PARALLEL
+#include "netcdf_par.h"
+#endif
 
 #define FILE_NAME "tst_misc.nc"
 
 int
 main(int argc, char **argv) 
 {
+#ifdef TEST_PNETCDF
+   MPI_Init(&argc, &argv);
+#endif
    printf("\n*** Testing some extra stuff.\n");
    printf("*** Trying to open non-netCDF files of tiny length...");
    {
@@ -41,7 +47,11 @@ main(int argc, char **argv)
 	 if (fclose(file)) ERR;
 	 
 	 /* Make sure that netCDF rejects this file politely. */
-	 openstat = nc_open(FILE_NAME, 0, &ncid);
+#ifdef TEST_PNETCDF
+        openstat = nc_open_par(FILE_NAME, NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+#else
+         openstat = nc_open(FILE_NAME, 0, &ncid);
+#endif
 	 /* Some platforms (OSX, buddy) return stat = 2 (file not found)
 	    for index i == 2.  Not sure why, but this is a work around. */
 	 if(openstat != NC_ENOTNC && openstat != 2) ERR;
@@ -50,5 +60,8 @@ main(int argc, char **argv)
    }
 
    SUMMARIZE_ERR;
+#ifdef TEST_PNETCDF
+   MPI_Finalize();
+#endif
    FINAL_RESULTS;
 }
diff --git a/nc_test/tst_names.c b/nc_test/tst_names.c
index 7538e39..fe7bfe1 100644
--- a/nc_test/tst_names.c
+++ b/nc_test/tst_names.c
@@ -6,13 +6,16 @@
    netCDF data objects, including names with "/" character, trailing spaces, 
    leading special characters, and invalid UTF-8 strings.
 
-   $Id: tst_names.c,v 1.9 2008/08/07 14:23:36 russ Exp $
+   $Id: tst_names.c 2792 2014-10-27 06:02:59Z wkliao $
 */
 #include <config.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <netcdf.h>
+#ifdef USE_PARALLEL
+#include <netcdf_par.h>
+#endif
 #include <nc_tests.h>
 
 /* The data file we will create. */
@@ -20,6 +23,9 @@
 #define NDIMS 1
 #define DIMLEN 1
 
+#define ERROR {printf("Error at line %d: %s\n",__LINE__,nc_strerror(res)); continue;}
+#define ERRORI {printf("Error at line %d (loop=%d): %s\n",__LINE__,i,nc_strerror(res)); continue;}
+
 int
 main(int argc, char **argv)
 {
@@ -213,7 +219,9 @@ main(int argc, char **argv)
    int formats[] = {
        NC_FORMAT_CLASSIC
        ,
-       NC_FORMAT_64BIT
+       NC_FORMAT_64BIT_OFFSET
+       ,
+       NC_FORMAT_CDF5
 #ifdef USE_NETCDF4
        ,
        NC_FORMAT_NETCDF4
@@ -223,35 +231,44 @@ main(int argc, char **argv)
    };
    int num_formats = (sizeof formats) / (sizeof formats[0]);
    char *format_names[] = {
-       "classic", "64-bit offset", "netCDF-4/HDF5", "netCDF-4 classic model"
+       "classic", "64-bit offset", "64-bit data", "netCDF-4/HDF5", "netCDF-4 classic model"
    };
 
+#ifdef TEST_PNETCDF
+   MPI_Init(&argc, &argv);
+#endif
+
    printf("\n*** testing names with file %s...\n", testfile);
    for (j = 0; j < num_formats; j++)
    {
        printf("*** switching to netCDF %s format...", format_names[j]);
        nc_set_default_format(formats[j], NULL);
+#ifdef TEST_PNETCDF
+       if((res = nc_create_par(testfile, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)))
+#else
        if((res = nc_create(testfile, NC_CLOBBER, &ncid)))
-	   ERR;
+#endif
+	   ERROR
        
        /* Define dimensions, variables, and attributes with various
 	* acceptable names */
        for (i = 0; i < NUM_GOOD; i++) {
 	   if ((res = nc_def_dim(ncid, valid[i], DIMLEN, &dimid)))
-	       ERR;
+	       ERRORI
+
 	   dimids[i] = dimid;
 	   /* Define variable with same name */
 	   if ((res = nc_def_var(ncid, valid[i], NC_FLOAT, NDIMS, &dimids[i], 
 				 &varid)))
-	       ERR;
+	       ERRORI
 	   varids[i] = varid;
 	   /* Define variable and global attributes with same name and value */
 	   if ((res = nc_put_att_text(ncid, varid, valid[i], 
 				      strlen(valid[i]), valid[i])))
-	       ERR;
+	       ERRORI
 	   if ((res = nc_put_att_double(ncid, NC_GLOBAL, valid[i], NC_DOUBLE, 
 					NATTVALS, attvals)))
-	       ERR;
+	       ERRORI
 #if 0
 	   attnums[i] = i;
 #endif
@@ -261,50 +278,58 @@ main(int argc, char **argv)
 	* bad names and make sure these are rejected */
        for (i = 0; i < NUM_BAD; i++) {
 	   if ((res = nc_def_dim(ncid, notvalid[i], DIMLEN, &dimid)) 
-	       != NC_EBADNAME) ERR;
+	       != NC_EBADNAME) ERRORI
 	   if ((res = nc_def_var(ncid, notvalid[i], NC_FLOAT, NDIMS, dimids, 
 				 &varid))
-	       != NC_EBADNAME) ERR;
+	       != NC_EBADNAME) ERRORI
 	   if ((res = nc_put_att_text(ncid, varid, notvalid[i], 
 				      strlen(attstring), attstring))
-	       != NC_EBADNAME) ERR;
+	       != NC_EBADNAME) ERRORI
 	   if ((res = nc_put_att_double(ncid, NC_GLOBAL, notvalid[i], NC_DOUBLE, 
 					NATTVALS, attvals))
-	       != NC_EBADNAME) ERR;
+	       != NC_EBADNAME) ERRORI
        }
        if ((res = nc_enddef(ncid)))
-	   ERR;
+	   ERROR
        if ((res = nc_close(ncid)))
-	   ERR;
+	   ERROR
        
        /* Check it out, make sure all objects with good names were defined OK */
+#ifdef TEST_PNETCDF
+       if ((res = nc_open_par(testfile, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid)))
+#else
        if ((res = nc_open(testfile, NC_NOWRITE, &ncid)))
-	   ERR;
+#endif
+	   ERROR
        for (i = 0; i < NUM_GOOD; i++) {
 	   size_t attlen;
 	   if ((res = nc_inq_dimid(ncid, valid[i], &dimid)) || 
 	       dimid != dimids[i])
-	       ERR;
+	       ERRORI
 	   if ((res = nc_inq_varid(ncid, valid[i], &varid)) || 
 	       varid != varids[i])
-	       ERR;
+	       ERRORI
 	   res = nc_inq_attlen(ncid, varid, valid[i], &attlen);
 	   if ((res = nc_get_att_text(ncid, varid, valid[i], attstr_in))) 
-	       ERR;
+	       ERRORI
 	   attstr_in[attlen] = '\0';
 	   if (strcmp(valid[i], attstr_in) != 0) 
-	       ERR;
+	       ERRORI
 	   if ((res = nc_get_att_double(ncid, NC_GLOBAL, valid[i], 
 					attvals_in)) 
 	       || attvals[0] != attvals_in[0]) 
-	       ERR;
+	       ERRORI
        }
        if ((res = nc_close(ncid)))
-	   ERR;
+	   ERROR
 /*        (void) remove(testfile); */
+
        SUMMARIZE_ERR;
    }
    FINAL_RESULTS;
 
+#ifdef TEST_PNETCDF
+   MPI_Finalize();
+#endif
    return 0;
 }
diff --git a/nc_test/tst_nofill.c b/nc_test/tst_nofill.c
index a7c85fb..e763707 100644
--- a/nc_test/tst_nofill.c
+++ b/nc_test/tst_nofill.c
@@ -9,7 +9,7 @@
   when invoked with the blksize argument between 2091953 and 2150032,
   inclusive, and succeeds for other blksizes.
 
-  $Id$
+  $Id: tst_nofill.c 2792 2014-10-27 06:02:59Z wkliao $
 */
 
 #include <config.h>
@@ -107,9 +107,14 @@ create_file(char *file_name, int fill_mode, size_t* sizehintp)
     * the same effect by providing the desired value as sizehint to
     * nc__create() instead of calling nc_create() and getting the
     * block size reported by fstat */
+#ifdef USE_PNETCDF
+   stat = nc_create_par(file_name, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid);
+   /* PnetCDF does not support fill mode */
+#else
    stat = nc__create(file_name, NC_CLOBBER, default_initialsize, sizehintp, &ncid);
    check_err(stat,__LINE__,__FILE__);
    stat = nc_set_fill(ncid, fill_mode, &old_fill_mode);
+#endif
    check_err(stat,__LINE__,__FILE__);
 
    /* define dimensions */
@@ -357,6 +362,9 @@ main(int argc, char **argv)
 				 * value between 2091953 and 2150032
 				 * triggers bug, whereas all other
 				 * values work fine. */
+#ifdef USE_PNETCDF
+    MPI_Init(&argc, &argv);
+#endif
 
     if (argc > 1) {
 	char *endptr, *str = argv[1];
@@ -393,8 +401,13 @@ main(int argc, char **argv)
        printf("*** Compare values in nofill mode and fill mode files...");
        /* compare data in two files created with nofill mode and fill
 	* mode, which should be identical if all the data were written */
+#ifdef USE_PNETCDF
+       if (nc_open_par(FILE_NAME1, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid1)) ERR;
+       if (nc_open_par(FILE_NAME2, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, &ncid2)) ERR;
+#else
        if (nc_open(FILE_NAME1, NC_NOWRITE, &ncid1)) ERR;
        if (nc_open(FILE_NAME2, NC_NOWRITE, &ncid2)) ERR;
+#endif
        if (nc_inq_nvars(ncid1, &nvars1)) ERR;
        if (nc_inq_nvars(ncid2, &nvars2)) ERR;
        if (nvars1 != nvars2) ERR;
@@ -473,4 +486,7 @@ main(int argc, char **argv)
        SUMMARIZE_ERR;
    }
    FINAL_RESULTS;
+#ifdef USE_PNETCDF
+   MPI_Finalize();
+#endif
 }
diff --git a/nc_test/tst_norm.c b/nc_test/tst_norm.c
index 4ec018f..b861e0f 100644
--- a/nc_test/tst_norm.c
+++ b/nc_test/tst_norm.c
@@ -5,13 +5,16 @@
    This is a very simple example which tests NFC normalization of
    Unicode names encoded with UTF-8.
 
-   $Id: tst_norm.c,v 1.8 2008/10/20 01:48:08 ed Exp $
+   $Id: tst_norm.c 2792 2014-10-27 06:02:59Z wkliao $
 */
 #include <config.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <netcdf.h>
+#ifdef USE_PARALLEL
+#include <netcdf_par.h>
+#endif
 #include <nc_tests.h>
 
 /* The data file we will create. */
@@ -99,8 +102,15 @@ main(int argc, char **argv)
    int attvals[] = {42};
 #define ATTNUM ((sizeof attvals)/(sizeof attvals[0]))
 
+#ifdef TEST_PNETCDF
+MPI_Init(&argc, &argv);
+#endif
    printf("\n*** testing UTF-8 normalization...");
+#ifdef TEST_PNETCDF
+   if((res = nc_create_par(FILE7_NAME, NC_CLOBBER|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL,&ncid)))
+#else
    if((res = nc_create(FILE7_NAME, NC_CLOBBER, &ncid)))
+#endif
        ERR;
 
    /* Define dimension with unnormalized Unicode UTF-8 encoded name */
@@ -124,10 +134,11 @@ main(int argc, char **argv)
     * version of same name.  These should fail, as unnormalized name
     * should have been normalized in library, so these are attempts to
     * create duplicate netCDF objects. */
-   if ((res = nc_def_dim(ncid, NNAME, NX, &dimid))
-       != NC_ENAMEINUSE) ERR;
-   if ((res = nc_def_var(ncid, NNAME, NC_CHAR, NDIMS, dimids, &varid))
-       != NC_ENAMEINUSE) ERR;
+   if ((res = nc_def_dim(ncid, NNAME, NX, &dimid)) != NC_ENAMEINUSE)
+       ERR;
+
+   if ((res = nc_def_var(ncid, NNAME, NC_CHAR, NDIMS, dimids, &varid)) != NC_ENAMEINUSE)
+       ERR;
    if ((res = nc_enddef(ncid)))
        ERR;
 
@@ -138,7 +149,11 @@ main(int argc, char **argv)
        ERR;
 
    /* Check it out. */
+#ifdef TEST_PNETCDF
+   if ((res = nc_open_par(FILE7_NAME, NC_NOWRITE|NC_PNETCDF, MPI_COMM_WORLD,MPI_INFO_NULL, &ncid)))
+#else
    if ((res = nc_open(FILE7_NAME, NC_NOWRITE, &ncid)))
+#endif
        ERR;
    if ((res = nc_inq_varid(ncid, UNAME, &varid)))
        ERR;
@@ -169,6 +184,9 @@ main(int argc, char **argv)
        ERR;
 
    SUMMARIZE_ERR;
+#ifdef TEST_PNETCDF
+   MPI_Finalize();
+#endif
    FINAL_RESULTS;
    return 0;
 }
diff --git a/nc_test/tst_small.c b/nc_test/tst_small.c
index 856fbcb..c28b00e 100644
--- a/nc_test/tst_small.c
+++ b/nc_test/tst_small.c
@@ -4,23 +4,87 @@
 
    Test small files.
 
-   $Id: tst_small.c,v 1.15 2008/10/20 01:48:08 ed Exp $
+   $Id: tst_small.c 2796 2014-10-28 03:40:29Z wkliao $
 */
 
+#include "config.h"
 #include <nc_tests.h>
 #include <netcdf.h>
+#ifdef USE_PNETCDF
+#include <netcdf_par.h>
+#endif
 
-/* Test everything for classic and 64-bit offsetfiles. If netcdf-4 is
+/* Test everything for classic, 64-bit offset, 64-bit data files. If netcdf-4 is
  * included, that means another whole round of testing. */
-#ifdef USE_NETCDF4
-#define NUM_FORMATS (4)
-#else
-#define NUM_FORMATS (2)
-#endif
+#define NUM_FORMATS (5)
 
 #define ATT_NAME "Atom"
 #define MAX_LEN 7   
 
+#define ERR2 { \
+    err++; \
+    fprintf(stderr, "Sorry! Unexpected result, %s, line: %d (%s)\n", \
+    __FILE__, __LINE__, nc_strerror(stat));                          \
+    exit(1); \
+}
+
+#ifdef USE_PNETCDF
+#define FMTCHECK {\
+     int format; \
+     nc_inq_format_extended(ncid,&format,NULL); \
+     if (format == NC_FORMATX_PNETCDF) { \
+       if (nc_var_par_access(ncid, varid, NC_COLLECTIVE)) ERR;\
+     }\
+   }
+#else
+#define FMTCHECK 
+#endif
+
+
+static int file_create(const char *filename, int cmode, int *ncid)
+{        
+    int err;
+         
+    /* get the default file format */
+    int default_format;
+    nc_set_default_format(NC_FORMAT_CLASSIC, &default_format);
+    /* set it back to the default */
+    nc_set_default_format(default_format, NULL);
+    
+#ifdef USE_PNETCDF
+    if (default_format == NC_FORMAT_CLASSIC ||
+        default_format == NC_FORMAT_64BIT_OFFSET ||
+        default_format == NC_FORMAT_64BIT_DATA)
+        err = nc_create_par(filename, cmode|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, ncid);
+    else
+#endif 
+        err = nc_create(filename, cmode, ncid);
+
+    return err;
+}
+
+static int file_open(const char *filename, int omode, int *ncid)
+{
+    int err;
+
+    /* get the default file format */
+    int default_format;
+    err = nc_set_default_format(NC_FORMAT_CLASSIC, &default_format);
+    /* set it back to the default */
+    err = nc_set_default_format(default_format, NULL);
+
+#ifdef USE_PNETCDF
+    if (default_format == NC_FORMAT_CLASSIC ||
+        default_format == NC_FORMAT_64BIT_OFFSET ||
+        default_format == NC_FORMAT_64BIT_DATA)
+        err = nc_open_par(filename, omode|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, ncid);
+    else
+#endif
+        err = nc_open(filename, omode, ncid);
+
+    return err;
+}
+
 static int
 test_small_atts(const char *testfile)
 {
@@ -41,13 +105,13 @@ test_small_atts(const char *testfile)
 	 strncpy(att, source, t);
 	 
 	 /* Create a file with one attribute. */
-	 if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+	 if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
 	 if (nc_put_att_text(ncid, NC_GLOBAL, ATT_NAME, t + 1, att)) ERR;
 	 if (f && nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
 	 if (nc_close(ncid)) ERR;
 	 
 	 /* Reopen the file and check it. */
-	 if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+	 if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
 	 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
 	 if (ndims != 0 && nvars != 0 && natts != 1 && unlimdimid != -1) ERR;
 	 if (nc_inq_attlen(ncid, NC_GLOBAL, ATT_NAME, &len_in)) ERR;
@@ -76,7 +140,7 @@ test_small_atts(const char *testfile)
 static int
 test_small_unlim(const char *testfile)
 {
-   int ncid, dimids[NDIMS], varid;
+   int ncid, dimids[NDIMS], varid, stat;
    char data[NUM_VALS][STR_LEN + 1], data_in[NUM_VALS][STR_LEN];
    int ndims, nvars, natts, unlimdimid;
    size_t i, start[NDIMS], count[NDIMS];
@@ -89,7 +153,7 @@ test_small_unlim(const char *testfile)
    
    /* Create a file with two dimensions, one unlimited, and one
     * var, and a global att. */
-   if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+   if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
    if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, dimids)) ERR;
    if (nc_def_dim(ncid, DIM2_NAME, STR_LEN, &dimids[1])) ERR;
    if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 2, dimids, &varid)) ERR;
@@ -100,14 +164,17 @@ test_small_unlim(const char *testfile)
    count[0] = 1;
    count[1] = STR_LEN;
    start[1] = 0;
+
+   FMTCHECK;
+
    for (start[0] = 0; start[0] < NUM_VALS; start[0]++)
-      if (nc_put_vara_text(ncid, varid, start, count, data[start[0]])) ERR;
+      if ((stat=nc_put_vara_text(ncid, varid, start, count, data[start[0]]))!=NC_NOERR) ERR2;
 
    /* We're done! */
    if (nc_close(ncid)) ERR;
    
    /* Reopen the file and check it. */
-   if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+   if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
    if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
    if (ndims != 2 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR;
    if (nc_get_var_text(ncid, varid, (char *)data_in)) ERR;
@@ -134,7 +201,7 @@ test_small_fixed(const char *testfile)
    
    /* Create a file with two dimensions, one unlimited, and one
     * var, and a global att. */
-   if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+   if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
    if (nc_def_dim(ncid, DIM1_NAME, NUM_VALS, dimids)) ERR;
    if (nc_def_dim(ncid, DIM2_NAME, STR_LEN, &dimids[1])) ERR;
    if (nc_def_var(ncid, VAR_NAME, NC_CHAR, NDIMS, dimids, &varid)) ERR;
@@ -152,7 +219,7 @@ test_small_fixed(const char *testfile)
    if (nc_close(ncid)) ERR;
    
    /* Reopen the file and check it. */
-   if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+   if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
    if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
    if (ndims != 2 && nvars != 1 && natts != 0 && unlimdimid != -1) ERR;
    if (nc_get_var_text(ncid, varid, (char *)data_in)) ERR;
@@ -172,7 +239,7 @@ test_small_one(const char *testfile)
    size_t start[NDIMS], count[NDIMS];
 
    /* Create a file with one ulimited dimensions, and one var. */
-   if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+   if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
    if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
    if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid)) ERR;
    if (nc_enddef(ncid)) ERR;
@@ -180,13 +247,16 @@ test_small_one(const char *testfile)
    /* Write one record of var data, a single character. */
    count[0] = 1;
    start[0] = 0;
+
+   FMTCHECK;
+
    if (nc_put_vara_text(ncid, varid, start, count, &data)) ERR;
 
    /* We're done! */
    if (nc_close(ncid)) ERR;
    
    /* Reopen the file and check it. */
-   if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+   if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
    if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
    if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR;
    if (nc_get_var_text(ncid, varid, &data_in)) ERR;
@@ -215,7 +285,7 @@ test_one_growing(const char *testfile)
    for (f = 0; f < 2; f++)
    {
       /* Create a file with one ulimited dimensions, and one var. */
-      if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+      if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
       if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
       if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid)) ERR;
       if (nc_close(ncid)) ERR;
@@ -225,15 +295,28 @@ test_one_growing(const char *testfile)
       for (r = 0; r < MAX_RECS; r++)
       {
 	 /* Write one record of var data, a single character. */
-	 if (nc_open(testfile, NC_WRITE, &ncid)) ERR;
-	 if (f && nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
+	 if (file_open(testfile, NC_WRITE, &ncid)) ERR;
+         if (f) {
+             int format;
+             nc_inq_format_extended(ncid,&format,NULL);
+             if (format == NC_FORMATX_PNETCDF) {
+                 /* in PnetCDF, nc_set_fill() can only be called in define mode */
+                 if (nc_redef(ncid)) ERR;
+                 if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
+                 if (nc_enddef(ncid)) ERR;
+             }
+             else { /* test_netcdf4 */
+                 if (nc_set_fill(ncid, NC_NOFILL, NULL)) ERR;
+             }
+         }
 	 count[0] = 1;
 	 start[0] = r;
+	 FMTCHECK;
 	 if (nc_put_vara_text(ncid, varid, start, count, &data[r])) ERR;
 	 if (nc_close(ncid)) ERR;
       
 	 /* Reopen the file and check it. */
-	 if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+	 if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
 	 if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
 	 if (len_in != r + 1) ERR;
 	 index[0] = r;
@@ -260,7 +343,7 @@ test_one_growing_with_att(const char *testfile)
    int r;
 
    /* Create a file with one ulimited dimensions, and one var. */
-   if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+   if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
    if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
    if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid)) ERR;
    if (nc_close(ncid)) ERR;
@@ -275,9 +358,12 @@ test_one_growing_with_att(const char *testfile)
    for (r = 0; r < MAX_RECS; r++)
    {
       /* Write one record of var data, a single character. */
-      if (nc_open(testfile, NC_WRITE, &ncid)) ERR;
+      if (file_open(testfile, NC_WRITE, &ncid)) ERR;
       count[0] = 1;
       start[0] = r;
+
+      FMTCHECK;
+
       if (nc_put_vara_text(ncid, varid, start, count, &data[r])) ERR;
       sprintf(att_name, "a_%d", data[r]);
       if (nc_redef(ncid)) ERR;
@@ -285,7 +371,7 @@ test_one_growing_with_att(const char *testfile)
       if (nc_close(ncid)) ERR;
       
       /* Reopen the file and check it. */
-      if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+      if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
       if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
       if (len_in != r + 1) ERR;
       index[0] = r;
@@ -313,7 +399,7 @@ test_two_growing_with_att(const char *testfile)
    int v, r;
 
    /* Create a file with one ulimited dimensions, and one var. */
-   if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+   if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
    if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
    if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid[0])) ERR;
    if (nc_def_var(ncid, VAR_NAME2, NC_CHAR, 1, &dimid, &varid[1])) ERR;
@@ -329,7 +415,16 @@ test_two_growing_with_att(const char *testfile)
    for (r = 0; r < MAX_RECS; r++)
    {
       /* Write one record of var data, a single character. */
-      if (nc_open(testfile, NC_WRITE, &ncid)) ERR;
+      if (file_open(testfile, NC_WRITE, &ncid)) ERR;
+#ifdef USE_PNETCDF
+      {int format;
+      nc_inq_format_extended(ncid,&format,NULL);
+      if (format == NC_FORMATX_PNETCDF) {
+          for (v = 0; v < NUM_VARS; v++) {
+              if (nc_var_par_access(ncid, varid[v], NC_COLLECTIVE)) ERR;
+          }
+      }}
+#endif
       count[0] = 1;
       start[0] = r;
       sprintf(att_name, "a_%d", data[r]);
@@ -343,7 +438,7 @@ test_two_growing_with_att(const char *testfile)
       if (nc_close(ncid)) ERR;
       
       /* Reopen the file and check it. */
-      if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+      if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
       if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
       if (len_in != r + 1) ERR;
       index[0] = r;
@@ -367,7 +462,7 @@ test_one_with_att(const char *testfile)
    size_t start[NDIMS], count[NDIMS];
 
    /* Create a file with one ulimited dimensions, and one var. */
-   if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+   if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;
    if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
    if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid)) ERR;
    if (nc_put_att_text(ncid, NC_GLOBAL, ATT_NAME, 1, &data)) ERR;
@@ -376,13 +471,16 @@ test_one_with_att(const char *testfile)
    /* Write one record of var data, a single character. */
    count[0] = 1;
    start[0] = 0;
+
+   FMTCHECK;
+
    if (nc_put_vara_text(ncid, varid, start, count, &data)) ERR;
 
    /* We're done! */
    if (nc_close(ncid)) ERR;
    
    /* Reopen the file and check it. */
-   if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+   if (file_open(testfile, NC_NOWRITE, &ncid)) ERR;
    if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
    if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR;
    if (nc_get_var_text(ncid, varid, &data_in)) ERR;
@@ -399,6 +497,10 @@ main(int argc, char **argv)
    int i;
    char testfile[NC_MAX_NAME + 1];
 
+#ifdef USE_PNETCDF
+   MPI_Init(&argc, &argv);
+#endif
+
    printf("\n*** Testing small files.\n");
    /*nc_set_log_level(3);*/
 
@@ -413,11 +515,16 @@ main(int argc, char **argv)
 	    printf("Switching to netCDF classic format.\n");
 	    strcpy(testfile, "tst_small_classic.nc");
 	    break;
-	 case NC_FORMAT_64BIT:
-	    nc_set_default_format(NC_FORMAT_64BIT, NULL);
+	 case NC_FORMAT_64BIT_OFFSET:
+	    nc_set_default_format(NC_FORMAT_64BIT_OFFSET, NULL);
 	    printf("Switching to 64-bit offset format.\n");
 	    strcpy(testfile, "tst_small_64bit.nc");
 	    break;
+	 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;
 #ifdef USE_NETCDF4
 	 case NC_FORMAT_NETCDF4_CLASSIC:
 	    nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL);
@@ -429,6 +536,10 @@ main(int argc, char **argv)
 	    strcpy(testfile, "tst_small_netcdf4.nc");
 	    printf("Switching to netCDF-4 format.\n");
 	    break;
+#else
+	 case NC_FORMAT_NETCDF4_CLASSIC:
+	 case NC_FORMAT_NETCDF4:
+	    continue; /* loop i */
 #endif
 	 default:
 	    printf("Unexpected format!\n");
@@ -470,6 +581,9 @@ main(int argc, char **argv)
       SUMMARIZE_ERR;
    }
 
+#ifdef USE_PNETCDF
+   MPI_Finalize();
+#endif
    FINAL_RESULTS;
 }
 
diff --git a/nc_test/util.c b/nc_test/util.c
index 916dc61..fcdb111 100644
--- a/nc_test/util.c
+++ b/nc_test/util.c
@@ -1,7 +1,7 @@
 /*********************************************************************
  *   Copyright 1996, UCAR/Unidata
  *   See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *   $Id: util.c,v 1.27 2006/12/10 13:59:56 ed Exp $
+ *   $Id: util.c 2792 2014-10-27 06:02:59Z wkliao $
  *********************************************************************/
 
 #include "tests.h"
@@ -23,12 +23,17 @@ inRange(const double value, const nc_type datatype)
     double min, max;
 
     switch (datatype) {
-	case NC_CHAR:   min = X_CHAR_MIN;   max = X_CHAR_MAX; break;
-	case NC_BYTE:   min = X_BYTE_MIN;   max = X_BYTE_MAX; break;
-	case NC_SHORT:  min = X_SHORT_MIN;  max = X_SHORT_MAX; break;
-	case NC_INT:   min = X_INT_MIN;   max = X_INT_MAX; break;
-	case NC_FLOAT:  min = X_FLOAT_MIN;  max = X_FLOAT_MAX; break;
-	case NC_DOUBLE: min = X_DOUBLE_MIN; max = X_DOUBLE_MAX; break;
+        case NC_CHAR:   return value >= X_CHAR_MIN   && value <= X_CHAR_MAX;
+        case NC_BYTE:   return value >= X_BYTE_MIN   && value <= X_BYTE_MAX;
+        case NC_SHORT:  return value >= X_SHORT_MIN  && value <= X_SHORT_MAX;
+        case NC_INT:    return value >= X_INT_MIN    && value <= X_INT_MAX;
+        case NC_FLOAT:  return value >= X_FLOAT_MIN  && value <= X_FLOAT_MAX;
+        case NC_DOUBLE: return value >= X_DOUBLE_MIN && value <= X_DOUBLE_MAX;
+        case NC_UBYTE:  return value >= 0            && value <= X_UCHAR_MAX;
+        case NC_USHORT: return value >= 0            && value <= X_USHORT_MAX;
+        case NC_UINT:   return value >= 0            && value <= X_UINT_MAX;
+        case NC_INT64:  return value >= X_INT64_MIN  && value <= X_INT64_MAX;
+        case NC_UINT64: return value >= 0            && value <= X_UINT64_MAX;
 	default:  assert(0);
     }
     return value >= min && value <= max;
@@ -45,6 +50,22 @@ inRange_uchar(const double value, const nc_type datatype)
 }
 
 static int
+inRange_schar(const double value, const nc_type datatype)
+{
+    /* check value of type datatype if within schar range */
+
+    if (datatype == NC_UBYTE) {
+        /* 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_rc/data_type.html#type_conversion
+         */
+        return(value >= X_CHAR_MIN && value <= X_CHAR_MAX);
+    }
+    /* else */
+    return inRange(value, datatype);
+}
+
+static int
 inRange_float(const double value, const nc_type datatype)
 {
     double min, max;
@@ -72,6 +93,11 @@ inRange_float(const double value, const nc_type datatype)
 			max = X_DOUBLE_MAX;
 		}
 		break;
+        case NC_UBYTE:  min = 0;            max = X_UCHAR_MAX;  break;
+        case NC_USHORT: min = 0;            max = X_USHORT_MAX; break;
+        case NC_UINT:   min = 0;            max = X_UINT_MAX;   break;
+        case NC_INT64:  min = X_INT64_MIN;  max = X_INT64_MAX;  break;
+        case NC_UINT64: min = 0;            max = X_UINT64_MAX; break;
 	default:  assert(0);
     }
     if(!( value >= min && value <= max)) {
@@ -104,6 +130,9 @@ inRange3(
     const nct_itype itype)
 {
     switch (itype) {
+        case NCT_SCHAR:
+        case NCT_CHAR:
+            return inRange_schar(value, datatype);
     case NCT_UCHAR:
 	return inRange_uchar(value, datatype);
     case NCT_FLOAT:
@@ -239,13 +268,22 @@ int nc2dbl ( const nc_type datatype, const void *p, double *result)
         case NC_SHORT: *result = *((short *) p); break;
         case NC_INT:
 #if INT_MAX >= X_INT_MAX
-		*result = *((int *) p);
+		*result = *((int *) p); break;
 #else
-		*result = *((long *) p);
+		*result = *((long *) p); break;
 #endif
-		break;
         case NC_FLOAT: *result = *((float *) p); break;
         case NC_DOUBLE: *result = *((double *) p); break;
+        case NC_UBYTE:  *result = *((unsigned char *)  p); break;
+        case NC_USHORT: *result = *((unsigned short *) p); break;
+        case NC_UINT:
+#if UINT_MAX >= X_UINT_MAX
+            *result = *((unsigned int *) p); break;
+#else
+            *result = *((unsigned long *) p); break;
+#endif
+        case NC_INT64:  *result = *((long long *)          p); break;
+        case NC_UINT64: *result = *((unsigned long long *) p); break;
         default: return 1;
     }
     return 0;
@@ -290,6 +328,35 @@ int dbl2nc ( const double d, const nc_type datatype, void *p)
             case NC_DOUBLE:
                 *((double *) p) = d;
                 break;
+        case NC_UBYTE:
+            r = floor(0.5+d);
+            if ( r < 0.0  ||  r > uchar_max )  return 2;
+            *((unsigned char *) p) = r;
+            break;
+        case NC_USHORT:
+            r = floor(0.5+d);
+            if ( r < 0.0  ||  r > ushort_max )  return 2;
+            *((unsigned short *) p) = r;
+            break;
+        case NC_UINT:
+            r = floor(0.5+d);
+            if ( r < 0.0  ||  r > uint_max )  return 2;
+#if UINT_MAX >= X_UINT_MAX
+            *((unsigned int  *) p) = r;
+#else
+            *((unsigned long *) p) = r;
+#endif
+            break;
+        case NC_INT64:
+            r = floor(0.5+d);
+            if ( r < int64_min  ||  r > int64_max )  return 2;
+            *((long long *) p) = r;
+            break;
+        case NC_UINT64:
+            r = floor(0.5+d);
+            if ( r < 0.0  ||  r > uint64_max )  return 2;
+            *((unsigned long long *) p) = r;
+            break;
             default:
                 return 1;
         }
@@ -322,6 +389,12 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return X_INT_MIN;
 		    case NC_FLOAT:  return X_FLOAT_MIN;
 		    case NC_DOUBLE: return X_DOUBLE_MIN;
+                    case NC_UBYTE:  return 0;
+                    case NC_USHORT: return 0;
+                    case NC_UINT:   return 0;
+                    case NC_INT64:  return X_INT_MIN - 128.0; /* slight smaller
+                                                                 than INT_MIN */
+                    case NC_UINT64: return 0;
 		    default:  assert(0);
 		}
 	    case 1:
@@ -332,6 +405,13 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return X_INT_MAX;
 		    case NC_FLOAT:  return X_FLOAT_MAX;
 		    case NC_DOUBLE: return X_DOUBLE_MAX;
+                    case NC_UBYTE:  return X_UCHAR_MAX;
+                    case NC_USHORT: return X_USHORT_MAX;
+                    case NC_UINT:   return X_UINT_MAX;
+                    case NC_INT64:  return X_INT_MAX + 128.0;
+                                    /* slightly bigger than INT_MAX */
+                    case NC_UINT64: return X_UINT_MAX + 128.0;
+                                    /* slightly bigger than UINT_MAX */
 		    default:  assert(0);
 		}
 	    case 2:
@@ -342,6 +422,11 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return X_INT_MIN-1.0;
 		    case NC_FLOAT:  return X_FLOAT_MIN * (1.0 + FUZZ);
 		    case NC_DOUBLE: return -1.0;
+                    case NC_UBYTE:  return -1.0;
+                    case NC_USHORT: return -1.0;
+                    case NC_UINT:   return -1.0;
+                    case NC_INT64:  return -1.0;  /* skip test */
+                    case NC_UINT64: return -1.0;
 		    default:  assert(0);
 		}
 	    case 3:
@@ -352,6 +437,11 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return X_INT_MAX+1.0;
 		    case NC_FLOAT:  return X_FLOAT_MAX * (1.0 + FUZZ);
 		    case NC_DOUBLE: return 1.0;
+                    case NC_UBYTE:  return X_UCHAR_MAX +1.0;
+                    case NC_USHORT: return X_USHORT_MAX+1.0;
+                    case NC_UINT:   return X_UINT_MAX  +1.0;
+                    case NC_INT64:  return 1.0;    /* skip test */
+                    case NC_UINT64: return 1.0;    /* skip test */
 		    default:  assert(0);
 		}
 	}
@@ -363,6 +453,13 @@ hash( const nc_type type, const int rank, const size_t *index )
 	    case NC_INT: base = -20; break;
 	    case NC_FLOAT: base = -9; break;
 	    case NC_DOUBLE: base = -10; break;
+
+            /* not sure what right values are */
+            case NC_UBYTE:   base =   2;  break;
+            case NC_USHORT:  base =   5;  break;
+            case NC_UINT:    base =  20;  break;
+            case NC_INT64:   base = -20;  break;
+            case NC_UINT64:  base =  20;  break;
 	    default:  assert(0);
 	}
 	result = rank < 0 ? base * 7 : base * (rank + 1);
@@ -397,6 +494,12 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return SANE_INT;
 		    case NC_FLOAT:  return SANE_FLOAT;
 		    case NC_DOUBLE: return SANE_DOUBLE;
+                    case NC_UBYTE:  return 0;
+                    case NC_USHORT: return 0;
+                    case NC_UINT:   return 0;
+                    case NC_INT64:  return X_INT_MIN - 128.0; /* slight smaller
+                                                                 than INT_MIN */
+                    case NC_UINT64: return 0;
 		    default:  assert(0);
 		}
 	    case 1:
@@ -407,6 +510,13 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return SANE_INT;
 		    case NC_FLOAT:  return SANE_FLOAT;
 		    case NC_DOUBLE: return SANE_DOUBLE;
+                    case NC_UBYTE:  return X_UCHAR_MAX;
+                    case NC_USHORT: return X_USHORT_MAX;
+                    case NC_UINT:   return X_UINT_MAX;
+                    case NC_INT64:  return X_INT_MAX + 128.0;
+                                    /* slightly bigger than INT_MAX */
+                    case NC_UINT64: return X_UINT_MAX + 128.0;
+                                    /* slightly bigger than UINT_MAX */
 		    default:  assert(0);
 		}
 	    case 2:
@@ -417,6 +527,11 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return SANE_INT-1.0;
 		    case NC_FLOAT:  return SANE_FLOAT * (1.0 + FUZZ);
 		    case NC_DOUBLE: return -1.0;
+                    case NC_UBYTE:  return -1.0;
+                    case NC_USHORT: return -1.0;
+                    case NC_UINT:   return -1.0;
+                    case NC_INT64:  return -1.0;  /* skip test */
+                    case NC_UINT64: return -1.0;
 		    default:  assert(0);
 		}
 	    case 3:
@@ -427,6 +542,11 @@ hash( const nc_type type, const int rank, const size_t *index )
 		    case NC_INT:   return SANE_INT+1.0;
 		    case NC_FLOAT:  return SANE_FLOAT * (1.0 + FUZZ);
 		    case NC_DOUBLE: return 1.0;
+                    case NC_UBYTE:  return X_UCHAR_MAX +1.0;
+                    case NC_USHORT: return X_USHORT_MAX+1.0;
+                    case NC_UINT:   return X_UINT_MAX  +1.0;
+                    case NC_INT64:  return 1.0;    /* skip test */
+                    case NC_UINT64: return 1.0;    /* skip test */
 		    default:  assert(0);
 		}
 	}
@@ -438,6 +558,13 @@ hash( const nc_type type, const int rank, const size_t *index )
 	    case NC_INT: base = -20; break;
 	    case NC_FLOAT: base = -9; break;
 	    case NC_DOUBLE: base = -10; break;
+
+            /* not sure what right values are */
+            case NC_UBYTE:   base =   2;  break;
+            case NC_USHORT:  base =   5;  break;
+            case NC_UINT:    base =  20;  break;
+            case NC_INT64:   base = -20;  break;
+            case NC_UINT64:  base =  20;  break;
 	    default:  assert(0);
 	}
 	result = rank < 0 ? base * 7 : base * (rank + 1);
@@ -472,6 +599,11 @@ char2type(char letter) {
         case 'i': return NC_INT;
         case 'f': return NC_FLOAT;
         case 'd': return NC_DOUBLE;
+        case 'y': return NC_UBYTE;
+        case 't': return NC_USHORT;
+        case 'u': return NC_UINT;
+        case 'x': return NC_INT64;
+        case 'z': return NC_UINT64;
         default:  assert(0);
     }
     return NC_CHAR;  /* Just to keep compiler happy */
@@ -495,7 +627,7 @@ static void
 init_gatts(const char *type_letter)
 {
 	int attid;
-	for (attid = 0; attid < NGATTS; attid++)
+	for (attid = 0; attid < numGatts; attid++)
 	{
 		gatt_name[attid][0] = 'G';
 		gatt_name[attid][1] = type_letter[attid];
@@ -528,7 +660,10 @@ init_gvars (void)
 		MAX_DIM_LEN,
 		MAX_DIM_LEN
 	};
-	const char type_letter[] = "cbsifd";
+    const char type_letter[] = "cbsifdytuxz";
+    /* c:char, b:byte, s:short, i:int, f:float, d:double, y:ubyte, t:ushort,
+     * u:uint, x:int64, z:uint64
+     */
 	const char digit[] = "r123456789";
 
 	size_t rank;
@@ -540,6 +675,9 @@ init_gvars (void)
 
 	init_dims(digit);
 
+	for (vn=0; vn<numVars; vn++)
+	    memset(var_name[vn], 0, 2+MAX_RANK);
+
 	for (rank = 0, vn = 0, xtype = 0, an = 0;  rank <= MAX_RANK; rank++)
 	{
 			/* number variables of a type and rank */
@@ -549,11 +687,11 @@ init_gvars (void)
 		for (jj = 0; jj < nvars; jj++)
 		{
 				/* number types of this shape */
-			const int ntypes = rank < 2 ? NTYPES : 1;
+			const int ntypes = rank < 2 ? numTypes : 1;
 
 			int tc;
 			for (tc = 0; tc < ntypes;
-			     tc++, vn++, xtype = (xtype + 1) % NTYPES)
+			     tc++, vn++, xtype = (xtype + 1) % numTypes)
 			{
 				size_t tmp[MAX_RANK];
 
@@ -565,10 +703,10 @@ init_gvars (void)
 					int ac;
 					for (ac = 0; ac < var_natts[vn]; ac++, an++)
 					{
-						att_name[vn][ac][0] = type_letter[an % NTYPES];
+						att_name[vn][ac][0] = type_letter[an % numTypes];
 						att_name[vn][ac][1] = '\0';
 						att_len[vn][ac] = an;
-						att_type[vn][ac] = char2type (type_letter[an % NTYPES]);
+						att_type[vn][ac] = char2type (type_letter[an % numTypes]);
 					}
 				} /* ac block */
 #ifndef NDEBUG
@@ -622,7 +760,7 @@ def_vars(int ncid)
     int  i;
     int var_id;
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	err = nc_def_var(ncid, var_name[i], var_type[i], var_rank[i],
 	    var_dimid[i], &var_id);
 	IF (err) error("nc_def_var: %s", nc_strerror(err));
@@ -642,7 +780,7 @@ put_atts(int ncid)
     double att[MAX_NELS];
     char catt[MAX_NELS];
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	for (j = 0; j < NATTS(i); j++) {
 	    if (ATT_TYPE(i,j) == NC_CHAR) {
 		for (k = 0; k < ATT_LEN(i,j); k++) {
@@ -686,7 +824,7 @@ put_vars(int ncid)
 
     for (j = 0; j < MAX_RANK; j++)
 	start[j] = 0;
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
 	for (allInRange = 1, j = 0; j < var_nels[i]; j++) {
 	    err = toMixedBase(j, var_rank[i], var_shape[i], index);
 	    IF (err) error("toMixedBase");
@@ -719,10 +857,9 @@ put_vars(int ncid)
 void
 write_file(char *filename) 
 {
-    int  ncid;			/* netCDF id */
-    int  err;		/* status */
-
-    err = nc_create(filename, NC_CLOBBER, &ncid);
+    int  ncid; /* netCDF id */
+    int  err;  /* status */
+    err = file_create(filename, NC_CLOBBER, &ncid);
     IF (err) 
 	error("nc_create: %s", nc_strerror(err));
 
@@ -732,6 +869,18 @@ write_file(char *filename)
     err = nc_enddef(ncid);
     IF (err) 
 	error("nc_enddef: %s", nc_strerror(err));
+
+#ifdef USE_PNETCDF
+    { int i,format;
+    nc_inq_format_extended(ncid, &format, NULL);
+    if (format == NC_FORMATX_PNETCDF) {
+        for (i = 0; i < numVars; i++) {
+            err = nc_var_par_access(ncid, i, NC_COLLECTIVE);
+	    IF (err) error("nc_var_par_access: %s", nc_strerror(err));
+        }
+    }}
+#endif
+
     put_vars(ncid);
 
     err = nc_close (ncid);
@@ -784,7 +933,7 @@ check_vars(int  ncid)
     size_t length;
     int nok = 0;      /* count of valid comparisons */
 
-    for (i = 0; i < NVARS; i++) {
+    for (i = 0; i < numVars; i++) {
         isChar = var_type[i] == NC_CHAR;
 	err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, NULL);
 	IF (err) 
@@ -829,9 +978,11 @@ check_vars(int  ncid)
 			error("nc_get_var1_double: %s", nc_strerror(err));
 		    } else {
 			IF (!equal(value,expect,var_type[i], NCT_DOUBLE)) {
-	error("Var %s value read % 12.5e not that expected % 12.7e ",
-		var_name[i], value, expect);
-		print_n_size_t(var_rank[i], index);
+			    value = 0;
+	  		    err = nc_get_var1_double(ncid, i, index, &value);		
+			    error("Var %s value read % 12.5e not that expected % 12.7e ",
+					var_name[i], value, expect);
+			    print_n_size_t(var_rank[i], index);
 			} else {
 #if 0
 			print("\nOk %s ", var_name[i]);
@@ -866,7 +1017,7 @@ check_atts(int  ncid)
     double expect;
     int nok = 0;      /* count of valid comparisons */
 
-    for (i = -1; i < NVARS; i++) {
+    for (i = -1; i < numVars; i++) {
 	for (j = 0; j < NATTS(i); j++) {
             err = nc_inq_attname(ncid, i, j, name);
             IF (err) 
@@ -919,7 +1070,7 @@ check_file(char *filename)
     int  ncid;		/* netCDF id */
     int  err;		/* status */
 
-    err = nc_open(filename, NC_NOWRITE, &ncid);
+    err = file_open(filename, NC_NOWRITE, &ncid);
     IF (err) {
         error("nc_open: %s", nc_strerror(err));
     } else {
@@ -937,18 +1088,62 @@ const char *
 s_nc_type(nc_type type)
 {
 	switch((int)type){
-	case NC_BYTE:
-		return "NC_BYTE";
-	case NC_CHAR:
-		return "NC_CHAR";
-	case NC_SHORT:
-		return "NC_SHORT";
-	case NC_INT:
-		return "NC_INT";
-	case NC_FLOAT:
-		return "NC_FLOAT";
-	case NC_DOUBLE:
-		return "NC_DOUBLE";
+        case NC_CHAR:   return "NC_CHAR";
+        case NC_BYTE:   return "NC_BYTE";
+        case NC_UBYTE:  return "NC_UBYTE";
+        case NC_SHORT:  return "NC_SHORT";
+        case NC_USHORT: return "NC_USHORT";
+        case NC_INT:    return "NC_INT";
+        case NC_UINT:   return "NC_UINT";
+        case NC_FLOAT:  return "NC_FLOAT";
+        case NC_DOUBLE: return "NC_DOUBLE";
+        case NC_INT64:  return "NC_INT64";
+        case NC_UINT64: return "NC_UINT64";
 	}
 	return "";
 }
+
+
+int file_create(const char *filename, int cmode, int *ncid)
+{
+    int err;
+
+    /* get the default file format */
+    int default_format;
+    nc_set_default_format(NC_FORMAT_CLASSIC, &default_format);
+    /* set it back to the default */
+    nc_set_default_format(default_format, NULL);
+
+#ifdef USE_PNETCDF
+    if (default_format == NC_FORMAT_CLASSIC ||
+        default_format == NC_FORMAT_64BIT_OFFSET ||
+        default_format == NC_FORMAT_64BIT_DATA)
+        err = nc_create_par(filename, cmode|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, ncid);
+    else
+#endif
+        err = nc_create(filename, cmode, ncid);
+
+    return err;
+}
+
+int file_open(const char *filename, int omode, int *ncid)
+{
+    int err;
+
+    /* get the default file format */
+    int default_format;
+    err = nc_set_default_format(NC_FORMAT_CLASSIC, &default_format);
+    /* set it back to the default */
+    err = nc_set_default_format(default_format, NULL);
+
+#ifdef USE_PNETCDF
+    if (default_format == NC_FORMAT_CLASSIC ||
+        default_format == NC_FORMAT_64BIT_OFFSET ||
+        default_format == NC_FORMAT_64BIT_DATA)
+        err = nc_open_par(filename, omode|NC_PNETCDF, MPI_COMM_WORLD, MPI_INFO_NULL, ncid);
+    else
+#endif
+        err = nc_open(filename, omode, ncid);
+
+    return err;
+}
diff --git a/nc_test4/Makefile.am b/nc_test4/Makefile.am
index 7757330..3c68014 100644
--- a/nc_test4/Makefile.am
+++ b/nc_test4/Makefile.am
@@ -71,9 +71,9 @@ tst_ar5 tst_h_files3 tst_mem                                            \
 run_get_knmi_files.sh tst_knmi
 
 # This will run a parallel I/O benchmark for parallel builds.
-if TEST_PARALLEL
+if TEST_PARALLEL4
 TESTS += run_par_bm_test.sh
-endif # TEST_PARALLEL
+endif # TEST_PARALLEL4
 
 benchmarks: check
 	./run_bm_radar_2D.sh
@@ -106,7 +106,7 @@ endif # USE_VALGRIND_TESTS
 
 # This are extra tests that will only be run if netcdf-4 is configured
 # with --enable-parallel-tests.
-if TEST_PARALLEL
+if TEST_PARALLEL4
 check_PROGRAMS += tst_mpi_parallel tst_parallel tst_parallel3	\
 tst_parallel4 tst_nc4perf
 TESTS += run_par_test.sh
@@ -132,7 +132,7 @@ tst_*.nc tst_floats2_*.cdl tst_ints2_*.cdl tst_shorts2_*.cdl		\
 tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.*	\
 usi_01.* thetau_01.* tst_*.nc tst_*.h5                                  \
 tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \
-foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4
+foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4 test.nc
 
 if USE_HDF4_FILE_TESTS
 DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf	\
diff --git a/nc_test4/Makefile.in b/nc_test4/Makefile.in
index f83d38b..8e71d86 100644
--- a/nc_test4/Makefile.in
+++ b/nc_test4/Makefile.in
@@ -140,7 +140,7 @@ TESTS = $(am__EXEEXT_1) run_grp_rename.sh $(am__EXEEXT_3) \
 
 
 # This will run a parallel I/O benchmark for parallel builds.
- at BUILD_BENCHMARKS_TRUE@@TEST_PARALLEL_TRUE at am__append_10 = run_par_bm_test.sh
+ at BUILD_BENCHMARKS_TRUE@@TEST_PARALLEL4_TRUE at am__append_10 = run_par_bm_test.sh
 
 # These are the tests for HDF4.
 @USE_HDF4_TRUE at am__append_11 = tst_interops2 tst_chunk_hdf4 tst_h4_lendian
@@ -157,10 +157,10 @@ TESTS = $(am__EXEEXT_1) run_grp_rename.sh $(am__EXEEXT_3) \
 
 # This are extra tests that will only be run if netcdf-4 is configured
 # with --enable-parallel-tests.
- at TEST_PARALLEL_TRUE@am__append_17 = tst_mpi_parallel tst_parallel tst_parallel3	\
- at TEST_PARALLEL_TRUE@tst_parallel4 tst_nc4perf
+ at TEST_PARALLEL4_TRUE@am__append_17 = tst_mpi_parallel tst_parallel tst_parallel3	\
+ at TEST_PARALLEL4_TRUE@tst_parallel4 tst_nc4perf
 
- at TEST_PARALLEL_TRUE@am__append_18 = run_par_test.sh
+ at TEST_PARALLEL4_TRUE@am__append_18 = run_par_test.sh
 subdir = nc_test4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -214,11 +214,11 @@ am__EXEEXT_1 = tst_dims$(EXEEXT) tst_dims2$(EXEEXT) tst_dims3$(EXEEXT) \
 @USE_HDF4_TRUE at am__EXEEXT_6 = tst_interops2$(EXEEXT) \
 @USE_HDF4_TRUE@	tst_chunk_hdf4$(EXEEXT) tst_h4_lendian$(EXEEXT)
 @USE_HDF4_FILE_TESTS_TRUE@@USE_HDF4_TRUE at am__EXEEXT_7 = tst_interops3$(EXEEXT)
- at TEST_PARALLEL_TRUE@am__EXEEXT_8 = tst_mpi_parallel$(EXEEXT) \
- at TEST_PARALLEL_TRUE@	tst_parallel$(EXEEXT) \
- at TEST_PARALLEL_TRUE@	tst_parallel3$(EXEEXT) \
- at TEST_PARALLEL_TRUE@	tst_parallel4$(EXEEXT) \
- at TEST_PARALLEL_TRUE@	tst_nc4perf$(EXEEXT)
+ at TEST_PARALLEL4_TRUE@am__EXEEXT_8 = tst_mpi_parallel$(EXEEXT) \
+ at TEST_PARALLEL4_TRUE@	tst_parallel$(EXEEXT) \
+ at TEST_PARALLEL4_TRUE@	tst_parallel3$(EXEEXT) \
+ at TEST_PARALLEL4_TRUE@	tst_parallel4$(EXEEXT) \
+ at TEST_PARALLEL4_TRUE@	tst_nc4perf$(EXEEXT)
 am__bm_file_SOURCES_DIST = bm_file.c tst_utils.c
 @BUILD_BENCHMARKS_TRUE at am_bm_file_OBJECTS = bm_file.$(OBJEXT) \
 @BUILD_BENCHMARKS_TRUE@	tst_utils.$(OBJEXT)
@@ -876,6 +876,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -908,6 +909,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -919,6 +921,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -1039,7 +1042,7 @@ tst_*.nc tst_floats2_*.cdl tst_ints2_*.cdl tst_shorts2_*.cdl		\
 tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.*	\
 usi_01.* thetau_01.* tst_*.nc tst_*.h5                                  \
 tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \
-foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4
+foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4 test.nc
 
 @USE_HDF4_FILE_TESTS_TRUE at DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf	\
 @USE_HDF4_FILE_TESTS_TRUE at AMSR_E_L3_DailyLand_V06_20020619.hdf			\
diff --git a/nc_test4/bm_file.c b/nc_test4/bm_file.c
index 4f1f3ba..daa8f81 100644
--- a/nc_test4/bm_file.c
+++ b/nc_test4/bm_file.c
@@ -680,7 +680,7 @@ int copy_file(char *file_name_in, char *file_name_out, int cmode_out,
 
       /* Get the start and count arrays, and also the increment of the
        * start array zeroth element, the number of read steps, the
-       * lenght of a slice in number of elements, and the count needed
+       * length of a slice in number of elements, and the count needed
        * for the final read, in the cases where the length of the
        * zeroth dimension is not evenly divisible by slow_count. The
        * variable slow_count is the number of elements in the slowest
@@ -868,9 +868,12 @@ main(int argc, char **argv)
 	    {
 	       case NC_FORMAT_CLASSIC:
 		  break;
-	       case NC_FORMAT_64BIT:
+	       case NC_FORMAT_64BIT_OFFSET:
 		  cmode = NC_64BIT_OFFSET;
 		  break;
+	       case NC_FORMAT_CDF5:
+		  cmode = NC_CDF5;
+		  break;
 	       case NC_FORMAT_NETCDF4:
 		  cmode = NC_NETCDF4;
 		  break;
@@ -1005,7 +1008,7 @@ main(int argc, char **argv)
    {
       if (use_par)
       {
-	 printf("Can't use start/count/slice for paralell runs yet!\n");
+	 printf("Can't use start/count/slice for parallel runs yet!\n");
 	 return 2;
       }
    }
diff --git a/nc_test4/run_bm.sh b/nc_test4/run_bm.sh
index d1619cf..f76575b 100755
--- a/nc_test4/run_bm.sh
+++ b/nc_test4/run_bm.sh
@@ -49,7 +49,7 @@ if ! test -f $TMP/${d1}-3d.nc3; then
     cp /upc/share/testdata/nssl/mosaic3d_nc/tile1/20070803-2300.netcdf $TMP/${d1}-3d.nc3
 fi
 
-# Test diferent compressions, with and without shuffle.
+# Test different compressions, with and without shuffle.
 out1=radar_3d_compression.txt
 c0=3
 c1=100
diff --git a/nc_test4/tst_camrun.c b/nc_test4/tst_camrun.c
index 17c8f48..a76a59d 100644
--- a/nc_test4/tst_camrun.c
+++ b/nc_test4/tst_camrun.c
@@ -5693,10 +5693,10 @@ main()
    if (nc_put_att_text(ncid, FLUTC_id, "long_name", 48, "Clearsky upwelling longwave flux at top of model")) ERR;
    if (nc_put_att_text(ncid, FLUTC_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, FREQSH_id, "units", 8, "fraction")) ERR;
-   if (nc_put_att_text(ncid, FREQSH_id, "long_name", 42, "Fractional occurance of shallow convection")) ERR;
+   if (nc_put_att_text(ncid, FREQSH_id, "long_name", 42, "Fractional occurrence of shallow convection")) ERR;
    if (nc_put_att_text(ncid, FREQSH_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, FREQZM_id, "units", 8, "fraction")) ERR;
-   if (nc_put_att_text(ncid, FREQZM_id, "long_name", 37, "Fractional occurance of ZM convection")) ERR;
+   if (nc_put_att_text(ncid, FREQZM_id, "long_name", 37, "Fractional occurrence of ZM convection")) ERR;
    if (nc_put_att_text(ncid, FREQZM_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, FSDS_id, "Sampling_Sequence", 8, "rad_lwsw")) ERR;
    if (nc_put_att_text(ncid, FSDS_id, "units", 4, "W/m2")) ERR;
@@ -6065,7 +6065,7 @@ main()
    if (nc_put_att_text(ncid, SO2_id, "long_name", 3, "SO2")) ERR;
    if (nc_put_att_text(ncid, SO2_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, SO2_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, SO2_CLXF_id, "long_name", 47, "vertically intergrated external forcing for SO2")) ERR;
+   if (nc_put_att_text(ncid, SO2_CLXF_id, "long_name", 47, "vertically integrated external forcing for SO2")) ERR;
    if (nc_put_att_text(ncid, SO2_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, SO2_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, SO2_XFRC_id, "long_name", 24, "external forcing for SO2")) ERR;
@@ -6167,7 +6167,7 @@ main()
    if (nc_put_att_text(ncid, TROP_P_id, "long_name", 19, "Tropopause Pressure")) ERR;
    if (nc_put_att_text(ncid, TROP_P_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, TROP_PD_id, "units", 11, "probability")) ERR;
-   if (nc_put_att_text(ncid, TROP_PD_id, "long_name", 21, "Tropopause Probabilty")) ERR;
+   if (nc_put_att_text(ncid, TROP_PD_id, "long_name", 21, "Tropopause Probability")) ERR;
    if (nc_put_att_text(ncid, TROP_PD_id, "cell_methods", 10, "time: mean")) ERR;
    { /* _FillValue */
       static const double TROP_T_FillValue_att[1] = {1e+36} ;
@@ -6279,7 +6279,7 @@ main()
    if (nc_put_att_text(ncid, bc_a1TBF_id, "long_name", 35, "bc_a1 turbulent dry deposition flux")) ERR;
    if (nc_put_att_text(ncid, bc_a1TBF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, bc_a1_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, bc_a1_CLXF_id, "long_name", 49, "vertically intergrated external forcing for bc_a1")) ERR;
+   if (nc_put_att_text(ncid, bc_a1_CLXF_id, "long_name", 49, "vertically integrated external forcing for bc_a1")) ERR;
    if (nc_put_att_text(ncid, bc_a1_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, bc_a1_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, bc_a1_XFRC_id, "long_name", 26, "external forcing for bc_a1")) ERR;
@@ -6688,7 +6688,7 @@ main()
    if (nc_put_att_text(ncid, num_a1TBF_id, "long_name", 36, "num_a1 turbulent dry deposition flux")) ERR;
    if (nc_put_att_text(ncid, num_a1TBF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, num_a1_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, num_a1_CLXF_id, "long_name", 50, "vertically intergrated external forcing for num_a1")) ERR;
+   if (nc_put_att_text(ncid, num_a1_CLXF_id, "long_name", 50, "vertically integrated external forcing for num_a1")) ERR;
    if (nc_put_att_text(ncid, num_a1_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, num_a1_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, num_a1_XFRC_id, "long_name", 27, "external forcing for num_a1")) ERR;
@@ -6739,7 +6739,7 @@ main()
    if (nc_put_att_text(ncid, num_a2TBF_id, "long_name", 36, "num_a2 turbulent dry deposition flux")) ERR;
    if (nc_put_att_text(ncid, num_a2TBF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, num_a2_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, num_a2_CLXF_id, "long_name", 50, "vertically intergrated external forcing for num_a2")) ERR;
+   if (nc_put_att_text(ncid, num_a2_CLXF_id, "long_name", 50, "vertically integrated external forcing for num_a2")) ERR;
    if (nc_put_att_text(ncid, num_a2_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, num_a2_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, num_a2_XFRC_id, "long_name", 27, "external forcing for num_a2")) ERR;
@@ -6943,7 +6943,7 @@ main()
    if (nc_put_att_text(ncid, pom_a1TBF_id, "long_name", 36, "pom_a1 turbulent dry deposition flux")) ERR;
    if (nc_put_att_text(ncid, pom_a1TBF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, pom_a1_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, pom_a1_CLXF_id, "long_name", 50, "vertically intergrated external forcing for pom_a1")) ERR;
+   if (nc_put_att_text(ncid, pom_a1_CLXF_id, "long_name", 50, "vertically integrated external forcing for pom_a1")) ERR;
    if (nc_put_att_text(ncid, pom_a1_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, pom_a1_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, pom_a1_XFRC_id, "long_name", 27, "external forcing for pom_a1")) ERR;
@@ -7003,7 +7003,7 @@ main()
    if (nc_put_att_text(ncid, so4_a1TBF_id, "long_name", 36, "so4_a1 turbulent dry deposition flux")) ERR;
    if (nc_put_att_text(ncid, so4_a1TBF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, so4_a1_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, so4_a1_CLXF_id, "long_name", 50, "vertically intergrated external forcing for so4_a1")) ERR;
+   if (nc_put_att_text(ncid, so4_a1_CLXF_id, "long_name", 50, "vertically integrated external forcing for so4_a1")) ERR;
    if (nc_put_att_text(ncid, so4_a1_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, so4_a1_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, so4_a1_XFRC_id, "long_name", 27, "external forcing for so4_a1")) ERR;
@@ -7051,7 +7051,7 @@ main()
    if (nc_put_att_text(ncid, so4_a2TBF_id, "long_name", 36, "so4_a2 turbulent dry deposition flux")) ERR;
    if (nc_put_att_text(ncid, so4_a2TBF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, so4_a2_CLXF_id, "units", 11, "molec/cm2/s")) ERR;
-   if (nc_put_att_text(ncid, so4_a2_CLXF_id, "long_name", 50, "vertically intergrated external forcing for so4_a2")) ERR;
+   if (nc_put_att_text(ncid, so4_a2_CLXF_id, "long_name", 50, "vertically integrated external forcing for so4_a2")) ERR;
    if (nc_put_att_text(ncid, so4_a2_CLXF_id, "cell_methods", 10, "time: mean")) ERR;
    if (nc_put_att_text(ncid, so4_a2_XFRC_id, "units", 11, "molec/cm3/s")) ERR;
    if (nc_put_att_text(ncid, so4_a2_XFRC_id, "long_name", 27, "external forcing for so4_a2")) ERR;
diff --git a/nc_test4/tst_chunks.c b/nc_test4/tst_chunks.c
index e1dfd5e..e228d5b 100644
--- a/nc_test4/tst_chunks.c
+++ b/nc_test4/tst_chunks.c
@@ -253,6 +253,44 @@ main(int argc, char **argv)
       if (nc_close(ncid)) ERR;
    }
    SUMMARIZE_ERR;
+   printf("**** testing that too large chunksizes fail...");
+   {
+#define D_SMALL_LEN2 66
+      int stat = NC_NOERR;
+      int ncid;
+      int nvars, ndims, ngatts, unlimdimid;
+      int contig;
+      int ndims_in, natts_in, dimids_in;
+      int small_dimid, medium_dimid, large_dimid;
+      int small_varid;
+      char var_name_in[NC_MAX_NAME + 1];
+      size_t chunks[1], chunksize_in;
+      nc_type xtype_in;
+
+      /* Create a netcdf-4 file with three dimensions. */
+      if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
+      if (nc_def_dim(ncid, D_SMALL, D_SMALL_LEN2, &small_dimid)) ERR;
+
+      /* Add one var. */
+      if (nc_def_var(ncid, V_SMALL, NC_INT64, NDIMS1, &small_dimid, &small_varid)) ERR;
+
+      /* Attempt to set too large chunksizes */
+      chunks[0] = D_SMALL_LEN2 + 1;
+      stat = nc_def_var_chunking(ncid, small_varid, NC_CHUNKED, chunks);
+      if(stat != NC_EBADCHUNK) {
+	printf("Return code is '%s', expected NC_BADCHUNK",nc_strerror(stat));
+	ERR;
+      }
+      /* try agains with proper chunksize */
+      chunks[0] = D_SMALL_LEN2;
+      stat = nc_def_var_chunking(ncid, small_varid, NC_CHUNKED, chunks);
+      if(stat != NC_NOERR) {
+	printf("Return code is '%s', expected NC_NOERR",nc_strerror(stat));
+	ERR;
+      }
+      if (nc_abort(ncid)) ERR;
+   }
+   SUMMARIZE_ERR;
    FINAL_RESULTS;
 }
 
diff --git a/nc_test4/tst_converts.c b/nc_test4/tst_converts.c
index 080939b..474283d 100644
--- a/nc_test4/tst_converts.c
+++ b/nc_test4/tst_converts.c
@@ -53,8 +53,10 @@ create_file(int format, unsigned char *uchar_out)
    int ncid, varid, cflags=0, dimids[1];
    int retval;
 
-   if (format == NC_FORMAT_64BIT)
+   if (format == NC_FORMAT_64BIT_OFFSET)
       cflags |= NC_64BIT_OFFSET;
+   else if (format == NC_FORMAT_CDF5)
+      cflags |= NC_CDF5;
    else if (format == NC_FORMAT_NETCDF4_CLASSIC)
    {
       cflags |= (NC_NETCDF4|NC_CLASSIC_MODEL);
diff --git a/nc_test4/tst_create_files.c b/nc_test4/tst_create_files.c
index a25cbb5..09a2efb 100644
--- a/nc_test4/tst_create_files.c
+++ b/nc_test4/tst_create_files.c
@@ -11,7 +11,7 @@
 #include <netcdf.h>
 #include <stdio.h>
 #include <string.h>
-#include <math.h>
+#include "ncdispatch.h"
 
 /* We will create this file. */
 #define FILE_NAME "tst_floats_1D.nc"
@@ -19,10 +19,10 @@
 int
 main(int argc, char **argv)
 {
+    nc_argc = argc;
+    nc_argv = argv;    
+    nc_initialize();
 
-#ifdef USE_PARALLEL
-   MPI_Init(&argc, &argv);
-#endif
     printf("\n*** Create some files for testing benchmarks.\n");
 
 #ifdef LARGE_FILE_TESTS
@@ -299,9 +299,7 @@ main(int argc, char **argv)
     }
     SUMMARIZE_ERR;
 
-#ifdef USE_PARALLEL
-   MPI_Finalize();
-#endif   
+    nc_finalize();
     FINAL_RESULTS;
 }
 
diff --git a/nc_test4/tst_files.c b/nc_test4/tst_files.c
index 56f5999..5af8b15 100644
--- a/nc_test4/tst_files.c
+++ b/nc_test4/tst_files.c
@@ -259,7 +259,7 @@ main(int argc, char **argv)
    test_redef(NC_FORMAT_CLASSIC);
    SUMMARIZE_ERR;
    printf("*** testing redef for netCDF 64-bit offset...");
-   test_redef(NC_FORMAT_64BIT);
+   test_redef(NC_FORMAT_64BIT_OFFSET);
    SUMMARIZE_ERR;
    printf("*** testing redef for netCDF-4 ...");
    test_redef(NC_FORMAT_NETCDF4);
@@ -281,7 +281,7 @@ main(int argc, char **argv)
       /* Create a netcdf-3 64-bit offset file. */
       if (nc_create(FILE_NAME, NC_64BIT_OFFSET|NC_CLOBBER, &ncid)) ERR;
       if (nc_inq_format(ncid, &format)) ERR;
-      if (format != NC_FORMAT_64BIT) ERR;
+      if (format != NC_FORMAT_64BIT_OFFSET) ERR;
       if (nc_close(ncid)) ERR;
 
       /* Create a netcdf-4 file. */
@@ -305,7 +305,7 @@ main(int argc, char **argv)
       /* Create a netcdf-3 64-bit offset file. */
       if (nc_create(FILE_NAME, NC_64BIT_OFFSET|NC_CLOBBER|NC_CLASSIC_MODEL, &ncid)) ERR;
       if (nc_inq_format(ncid, &format)) ERR;
-      if (format != NC_FORMAT_64BIT) ERR;
+      if (format != NC_FORMAT_64BIT_OFFSET) ERR;
       if (nc_close(ncid)) ERR;
    }
    SUMMARIZE_ERR;
@@ -395,8 +395,10 @@ test_redef(int format)
    float cache_preemption_in;
    int ret;
 
-   if (format == NC_FORMAT_64BIT)
+   if (format == NC_FORMAT_64BIT_OFFSET)
       cflags |= NC_64BIT_OFFSET;
+   else if (format == NC_FORMAT_CDF5)
+      cflags |= NC_CDF5;
    else if (format == NC_FORMAT_NETCDF4_CLASSIC)
       cflags |= (NC_NETCDF4|NC_CLASSIC_MODEL);
    else if (format == NC_FORMAT_NETCDF4)
diff --git a/nc_test4/tst_h4_lendian.c b/nc_test4/tst_h4_lendian.c
index 30e34d1..f7128fe 100644
--- a/nc_test4/tst_h4_lendian.c
+++ b/nc_test4/tst_h4_lendian.c
@@ -66,7 +66,7 @@ int create_hdf_file(int dtype) {
     edges[0] = DIM1;
     edges[1] = DIM0;
 
-    // populate data array
+    /* populate data array */
     count = 0;
     for (j = 0; j < DIM0; j++)
       {
@@ -77,7 +77,7 @@ int create_hdf_file(int dtype) {
     printf("\to Creating hdf4 file with little-endian datatype %d....\t",dtype);
 
     sd_id = SDstart(FILENAME, DFACC_CREATE);
-    //sds_id = SDcreate(sd_id, SDSNAME, DFNT_LITEND|dtype, RANK, edges);
+    /* sds_id = SDcreate(sd_id, SDSNAME, DFNT_LITEND|dtype, RANK, edges); */
     sds_id = SDcreate(sd_id, SDSNAME, dtype, RANK, edges);
 
     istat = SDendaccess(sds_id);
diff --git a/nc_test4/tst_large.c b/nc_test4/tst_large.c
index 163a2df..3d37fda 100644
--- a/nc_test4/tst_large.c
+++ b/nc_test4/tst_large.c
@@ -8,20 +8,19 @@
 
 #include <nc_tests.h>
 #include "netcdf.h"
+#include "ncdispatch.h"
 
 #define FILE_NAME "tst_large.nc"
 #define NUMDIMS 2		/* rank of each variable in tests */
 #define DIM1 2048
 #define DIM2 2097153		/* DIM1*DIM2*sizeof(char)   > 2**32 */
 
+
+
 int
 main(int argc, char **argv)
 {
 
-#ifdef USE_PARALLEL
-   MPI_Init(&argc, &argv);
-#endif
-
    printf("\n*** Testing netcdf-4 large files.\n");
    printf("**** testing simple fill value attribute creation...");
    {
@@ -58,9 +57,8 @@ main(int argc, char **argv)
    }
    SUMMARIZE_ERR;
 
-#ifdef USE_PARALLEL
-   MPI_Finalize();
-#endif   
+   nc_finalize();
+
    FINAL_RESULTS;
 }
 
diff --git a/nc_test4/tst_large2.c b/nc_test4/tst_large2.c
index 311cd48..0a683fc 100644
--- a/nc_test4/tst_large2.c
+++ b/nc_test4/tst_large2.c
@@ -16,14 +16,8 @@
 #define DIM1 2048
 #define DIM2 2097153		/* DIM1*DIM2*sizeof(char)   > 2**32 */
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
-
-#ifdef USE_PARALLEL
-   MPI_Init(&argc, &argv);
-#endif
-
    printf("\n*** Testing netcdf-4 large files.\n");
    printf("**** testing with user-contributed test...\n");
    {
@@ -101,9 +95,8 @@ main(int argc, char **argv)
    }
    SUMMARIZE_ERR;
 
-#ifdef USE_PARALLEL
-   MPI_Finalize();
-#endif   
+   nc_finalize();
+
    FINAL_RESULTS;
 }
 
diff --git a/nc_test4/tst_large3.c b/nc_test4/tst_large3.c
index 9bc89cf..05fff4d 100644
--- a/nc_test4/tst_large3.c
+++ b/nc_test4/tst_large3.c
@@ -2,7 +2,7 @@
  Copyright 2007, UCAR/Unidata
  See COPYRIGHT file for copying and redistribution conditions.
 
- This program (quickly, but not throughly) tests the large file
+ This program (quickly, but not thoroughly) tests the large file
  features. It turns off fill mode to quickly create an 8 gb file, and
  write one value is written, nothing is read.
 
@@ -39,10 +39,6 @@ main(int argc, char **argv)
 {
    char file_name[NC_MAX_NAME + 1];
 
-#ifdef USE_PARALLEL
-   MPI_Init(&argc, &argv);
-#endif
-
     printf("\n*** Testing really large files in netCDF-4/HDF5 format, quickly.\n");
 
     printf("*** Testing create of simple, but large, file...");
@@ -100,9 +96,7 @@ main(int argc, char **argv)
 
     SUMMARIZE_ERR;
 
-#ifdef USE_PARALLEL
-   MPI_Finalize();
-#endif   
+    nc_finalize();
 
     FINAL_RESULTS;
 }
diff --git a/nc_test4/tst_large5.c b/nc_test4/tst_large5.c
index 30a15fe..32cd7cb 100644
--- a/nc_test4/tst_large5.c
+++ b/nc_test4/tst_large5.c
@@ -60,11 +60,6 @@ return 2;                                                   \
 int
 main(int argc, char **argv)
 {
-
-#ifdef USE_PARALLEL
-   MPI_Init(&argc, &argv);
-#endif
-
    printf("\n*** Testing netcdf-4 large files.\n");
    printf("**** testing with user-contributed test...\n");
    {
@@ -145,8 +140,7 @@ main(int argc, char **argv)
    }
    SUMMARIZE_ERR;
 
-#ifdef USE_PARALLEL
-   MPI_Finalize();
-#endif   
+   nc_finalize();
+
    FINAL_RESULTS;
 }
diff --git a/nc_test4/tst_rename.c b/nc_test4/tst_rename.c
index 547ba49..178ddbb 100644
--- a/nc_test4/tst_rename.c
+++ b/nc_test4/tst_rename.c
@@ -44,7 +44,7 @@ create_test_file(
     case (NC_FORMAT_CLASSIC):
 	if (nc_create(path, 0, &ncid)) ERR;
 	break;
-    case (NC_FORMAT_64BIT):
+    case (NC_FORMAT_64BIT_OFFSET):
 	if (nc_create(path, NC_64BIT_OFFSET, &ncid)) ERR;
 	break;
     case (NC_FORMAT_NETCDF4):
diff --git a/nc_test4/tst_types.c b/nc_test4/tst_types.c
index 5dc82d8..e57e25d 100644
--- a/nc_test4/tst_types.c
+++ b/nc_test4/tst_types.c
@@ -62,10 +62,6 @@ int main(int argc, char *argv[])
    int type, num_errors = 0, res = NC_NOERR;
    int errors = 0, total_errors = 0;
 
-#ifdef USE_PARALLEL
-   MPI_Init(&argc, &argv);
-#endif
-
    /* Uncomment the following line to get verbose feedback. */
    /*nc_set_log_level(2);*/
    printf("\n\n*** Testing netCDF-4 new atomic types...\n");
@@ -333,9 +329,7 @@ int main(int argc, char *argv[])
    else
       printf(" *** success!\n");
 
-#ifdef USE_PARALLEL
-   MPI_Finalize();
-#endif   
+   nc_finalize();
 
    return 2 ? errors : 0;
 }
diff --git a/nc_test4/tst_vars.c b/nc_test4/tst_vars.c
index 40c56fb..1d4d84b 100644
--- a/nc_test4/tst_vars.c
+++ b/nc_test4/tst_vars.c
@@ -1217,7 +1217,7 @@ main(int argc, char **argv)
 
    printf("*** testing 4D example file in 64-bit offset format...");
    if (create_4D_example(NC3_64BIT_OFFSET_FILE, NC_CLOBBER|NC_64BIT_OFFSET)) ERR;
-   if (check_4D_example(NC3_64BIT_OFFSET_FILE, NC_FORMAT_64BIT)) ERR;      
+   if (check_4D_example(NC3_64BIT_OFFSET_FILE, NC_FORMAT_64BIT_OFFSET)) ERR;      
    SUMMARIZE_ERR;
 
    printf("*** testing 4D example file in netCDF-4/HDF5 format...");
diff --git a/nc_test4/tst_vars2.c b/nc_test4/tst_vars2.c
index 6c6c30b..19527c0 100644
--- a/nc_test4/tst_vars2.c
+++ b/nc_test4/tst_vars2.c
@@ -300,7 +300,7 @@ main(int argc, char **argv)
       SUMMARIZE_ERR;
 
 #ifndef NO_NETCDF_2
-      /* The following test is an attempt to recreate a problem occuring
+      /* The following test is an attempt to recreate a problem occurring
          in the cxx tests. The file is created in c++ in nctsts.cpp. */
       printf("**** testing fill value with example from cxx tests in v2 api...");
       {
@@ -846,7 +846,7 @@ main(int argc, char **argv)
       if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
       if (nc_def_var(ncid, GENERIC_NAME, NC_BYTE, 0, NULL, &varid)) ERR;
 
-      /* These don'e work, becuase the name is already in use. Make
+      /* These don'e work, because the name is already in use. Make
        * sure the correct error is returned. */
       if (nc_def_grp(ncid, GENERIC_NAME, NULL) != NC_ENAMEINUSE) ERR;
       if (nc_def_opaque(ncid, 1, GENERIC_NAME, NULL) != NC_ENAMEINUSE) ERR;
@@ -878,7 +878,7 @@ main(int argc, char **argv)
       if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
       if (nc_def_opaque(ncid, 1, GENERIC_NAME, NULL)) ERR;
 
-      /* These don'e work, becuase the name is already in use. Make
+      /* These don'e work, because the name is already in use. Make
        * sure the correct error is returned. */
       if (nc_def_grp(ncid, GENERIC_NAME, NULL) != NC_ENAMEINUSE) ERR;
       if (nc_def_var(ncid, GENERIC_NAME, NC_BYTE, 0, NULL, &varid) != NC_ENAMEINUSE) ERR;
@@ -907,7 +907,7 @@ main(int argc, char **argv)
       if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
       if (nc_def_grp(ncid, GENERIC_NAME, NULL)) ERR;
 
-      /* These don'e work, becuase the name is already in use. Make
+      /* These don'e work, because the name is already in use. Make
        * sure the correct error is returned. */
       if (nc_def_opaque(ncid, 1, GENERIC_NAME, NULL) != NC_ENAMEINUSE) ERR;
       if (nc_def_var(ncid, GENERIC_NAME, NC_BYTE, 0, NULL, &varid) != NC_ENAMEINUSE) ERR;
diff --git a/nc_test4/tst_vars3.c b/nc_test4/tst_vars3.c
index 173a9ab..370784f 100644
--- a/nc_test4/tst_vars3.c
+++ b/nc_test4/tst_vars3.c
@@ -262,7 +262,7 @@ main(int argc, char **argv)
       if (nc_inq_var(ncid, 1, NULL, NULL, &ndims, dimids_in, NULL)) ERR;
       if (ndims != 3 || dimids_in[0] != 0 || dimids_in[1] != 2 || dimids_in[2] != 1) ERR;
 
-      /* Read the record of non-existant data. */
+      /* Read the record of non-existent data. */
       if (nc_get_vara(ncid, 1, cor, edg, P_data)) ERR;
       for (i = 0; i < LEN; i++)
 	 if (P_data[i] != NC_FILL_FLOAT) ERR;
diff --git a/ncdap.m4 b/ncdap.m4
deleted file mode 100644
index 4ba8b93..0000000
--- a/ncdap.m4
+++ /dev/null
@@ -1,197 +0,0 @@
-AC_DEFUN([NCDAP_XML2], [dnl
-  # Did user must specify a location for the XML2 library?
-  AC_MSG_CHECKING([whether a location for the XML2 library was specified])
-  AC_ARG_WITH([xml2], [AS_HELP_STRING([--with-xml2=<directory>],
-              [Specify location of XML2 library. XML2 is required for opendap. Configure will expect to find subdirs include and lib.])],
-              [xml2dir=$with_xml2])
-  if test -n "$with_xml2" ; then
-    AC_MSG_RESULT([$with_xml2])
-  else
-    AC_MSG_RESULT([no])
-  fi
-  if test -n "${with_xml2}" ; then
-    xml2src="with"
-  else
-    # See if we can locate xml2-config; if so, then use it for at least cflags
-    if xml2-config --version >/dev/null 2>&1 ; then
-      xml2dir="`xml2-config --prefix`"  
-      xml2src="config"
-      AC_MSG_NOTICE([Found -lxml2 using xml2-config])
-    else
-      # see if autoconf can find it
-      AC_MSG_NOTICE([Checking for -lxml2])
-      AC_CHECK_LIB([xml2],[xmlParseFile],[xml2src="checklib"],[xml2src=])
-      if test "$xml2src" = checklib; then
-        AC_MSG_NOTICE([Found -lxml2 using checklib])
-      fi
-    fi
-  fi
-  if test -z "$xml2src"; then
-    AC_MSG_NOTICE([xml2 library not found; continuing])
-  fi
-  if test "$xml2src" = "with" -o "$xml2src" = "config"; then
-    xml2_cflags="-I${xml2dir}/include/libxml2"
-    xml2_libs="-L${xml2dir}/lib -lxml2"
-  fi
-  if test "$xml2src" = "checklib"; then
-    xml2_libs="-lxml2"
-  fi
-  AC_SUBST([XML2_CFLAGS],[${xml2_cflags}])
-  AC_SUBST([XML2_LIBS],[${xml2_libs}])
-  AC_SUBST([XML2DIR],[${xml2dir}])
-  found_xml2=$xml2src
-])  
-AC_DEFUN([NCDAP_CURL], [dnl
-  # Did user must specify a location for the CURL library?
-  AC_MSG_CHECKING([whether a location for the CURL library was specified])
-  AC_ARG_WITH([curl], [AS_HELP_STRING([--with-curl=<directory>],
-              [Specify location of CURL library. CURL is required for opendap. Configure will expect to find subdirs include and lib.])],
-              [curldir=$with_curl])
-  if test -n "$with_curl" ; then
-    AC_MSG_RESULT([$with_curl])
-  else
-    AC_MSG_RESULT([no])
-  fi
-  if test -n "${with_curl}" ; then
-    curlsrc="with"
-  else
-    # See if we can locate curl-config; if so, then use it for at least cflags
-    if curl-config --version >/dev/null 2>&1 ; then
-      curldir="`curl-config --prefix`"  
-      curlsrc="config"
-      AC_MSG_NOTICE([Found -lcurl using curl-config])
-    else
-      # see if autoconf can find it
-      AC_MSG_NOTICE([Checking for -lcurl])
-      AC_CHECK_LIB([curl],[curl_easy_setopt],[curlsrc="checklib"],[curlsrc=])
-      if test "$curlsrc" = checklib; then
-        AC_MSG_NOTICE([Checklib found -lcurl])
-      fi
-    fi
-  fi
-  if test -z "$curlsrc"; then
-    AC_MSG_NOTICE([curl library not found; continuing])
-  fi
-  if test "$curlsrc" = "with" -o "$curlsrc" = "config"; then
-    curl_cflags="-I${curldir}/include"
-    curl_libs="-L${curldir}/lib -lcurl"
-  fi
-  if test "$curlsrc" = "checklib"; then
-    curl_libs="-lcurl"
-  fi
-  AC_SUBST([CURL_CFLAGS],[${curl_cflags}])
-  AC_SUBST([CURL_LIBS],[${curl_libs}])
-  AC_SUBST([CURLDIR],[${curldir}])
-  found_curl=$curlsrc
-])  
-AC_DEFUN([NCDAP_ZLIB], [dnl
-  # Did user must specify a location for the ZLIB library?
-  AC_MSG_CHECKING([whether a location for the ZLIB library was specified])
-  AC_ARG_WITH([zlib], [AS_HELP_STRING([--with-zlib=<directory>],
-              [Specify location of ZLIB library. ZLIB may be required for opendap. Configure will expect to find subdirs include and lib.])],
-              [zlibdir=$with_zlib])
-  if test -n "$with_zlib" ; then
-    AC_MSG_RESULT([$with_zlib])
-  else
-    AC_MSG_RESULT([no])
-  fi
-  if test -n "${with_zlib}" ; then
-    zlibsrc="with"
-  else
-    # see if autoconf can find it
-    AC_CHECK_LIB([z],[zlibVersion],[zlibsrc="checklib"],[zlibsrc=])
-  fi
-  if test -z "$zlibsrc"; then
-    AC_MSG_NOTICE([zlib library not found; assume optional])
-  fi
-  if test "$zlibsrc" = "with"; then
-    zlib_cflags="-I${zlibdir}/include"
-    zlib_libs="-L${zlibdir}/lib -lz"
-  fi
-  if test "$zlibsrc" = "checklib"; then
-    zlib_libs="-lz"
-  fi
-  AC_SUBST([ZLIB_CFLAGS],[${zlib_cflags}])
-  AC_SUBST([ZLIB_LIBS],[${zlib_libs}])
-  AC_SUBST([ZLIBDIR],[${zlibdir}])
-  found_zlib=$zlibsrc
-])  
-AC_DEFUN([NCDAP_SZLIB], [dnl
-  # Did user must specify a location for the SZLIB library?
-  AC_MSG_CHECKING([whether a location for the SZLIB library was specified])
-  AC_ARG_WITH([szlib], [AS_HELP_STRING([--with-szlib=<directory>],
-              [Specify location of SZLIB library. SZLIB may be required for opendap. Configure will expect to find subdirs include and lib.])],
-              [szlibdir=$with_szlib])
-  if test -n "$with_szlib" ; then
-    AC_MSG_RESULT([$with_szlib])
-  else
-    AC_MSG_RESULT([no])
-  fi
-  if test -n "${with_szlib}" ; then
-    szlibsrc="with"
-  else
-    # see if autoconf can find it
-    AC_CHECK_LIB([sz],[SZ_Decompress],[szlibsrc="checklib"],[szlibsrc=])
-  fi
-  if test -z "$szlibsrc"; then
-    AC_MSG_NOTICE([szlib library not found; assume optional])
-  fi
-  if test "$szlibsrc" = "with"; then
-    szlib_cflags="-I${szlibdir}/include"
-    szlib_libs="-L${szlibdir}/lib -lz"
-  fi
-  if test "$szlibsrc" = "checklib"; then
-    szlib_libs="-lsz"
-  fi
-  AC_SUBST([SZLIB_CFLAGS],[${szlib_cflags}])
-  AC_SUBST([SZLIB_LIBS],[${szlib_libs}])
-  AC_SUBST([SZLIBDIR],[${szlibdir}])
-  found_szlib=$szlibsrc
-])  
-AC_DEFUN([NCDAP_OCLIB], [dnl
-  # Did user must specify a location for liboc?
-  AC_MSG_CHECKING([whether a location for liboc was specified])
-  AC_ARG_WITH([oclib], [AS_HELP_STRING([--with-oclib=<directory>],
-              [Specify location of liboc. Configure will expect to find subdirs include and lib. This is required for opendap; if not specified, then the internal version will be used. ])],
-              [oclibdir=$with_oclib])
-  if test -n "$with_oclib" ; then
-    AC_MSG_RESULT([$with_oclib])
-  else
-    AC_MSG_RESULT([no])
-  fi
-  if test -n "${with_oclib}" ; then
-    oclibsrc="with"
-  else
-    oclibsrc=
-  fi
-  if test -z "$oclibsrc"; then
-    AC_MSG_NOTICE([external oclib library not specified; using internal version])
-  fi
-  if test "$oclibsrc" = "with"; then
-    oclib_cflags="-I${oclibdir}/include"
-    oclib_libs="-L${oclibdir}/lib -loc"
-  fi
-  AC_SUBST([OCLIB_CFLAGS],[${oclib_cflags}])
-  AC_SUBST([OCLIB_LIBS],[${oclib_libs}])
-  found_oclib=$oclibsrc
-])  
-AC_DEFUN([NCDAP_XDR], [dnl
-    # See if autoconf can find it; check libc, librpc, librpcsvc and libnsl
-    dap_xdrlib=
-    AC_SEARCH_LIBS([xdr_void],[c rpc nsl rpcsvc],
-      [dap_xdrlib=$ac_res],[dapxdrlib=])
-    if test -z "$dap_xdrlib" ; then
-      AC_MSG_ERROR(Cannot locate library containing xdr functions.)
-    else
-      dap_xdrlib=`echo $dap_xdrlib | sed -e s/-l//g`
-      if test "$dap_xdrlib" = "-lc" ; then
-        AC_MSG_NOTICE(XDR Functions appear to be in libc.)	
-      elif test "$dap_xdrlib" = "none required" ; then
-        AC_MSG_NOTICE(XDR Functions appear to be in libc.)	
-      else
-        AC_MSG_NOTICE(XDR Functions appear to be in lib${dap_xdrlib}.)	
-        # Add to library list
-        AC_CHECK_LIB($dap_xdrlib,xdr_void)
-      fi
-    fi
-])  
diff --git a/ncdap_test/Makefile.in b/ncdap_test/Makefile.in
index ff129b0..b5ec8d1 100644
--- a/ncdap_test/Makefile.in
+++ b/ncdap_test/Makefile.in
@@ -565,6 +565,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -597,6 +598,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -608,6 +610,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdap_test/expected3/Makefile.in b/ncdap_test/expected3/Makefile.in
index 844b2b0..929e5f6 100644
--- a/ncdap_test/expected3/Makefile.in
+++ b/ncdap_test/expected3/Makefile.in
@@ -178,6 +178,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -210,6 +211,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -221,6 +223,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdap_test/expected4/Makefile.in b/ncdap_test/expected4/Makefile.in
index 31d08d9..6c30ea4 100644
--- a/ncdap_test/expected4/Makefile.in
+++ b/ncdap_test/expected4/Makefile.in
@@ -176,6 +176,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -208,6 +209,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -219,6 +221,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdap_test/expectremote3/Makefile.in b/ncdap_test/expectremote3/Makefile.in
index f30997c..892ffbb 100644
--- a/ncdap_test/expectremote3/Makefile.in
+++ b/ncdap_test/expectremote3/Makefile.in
@@ -178,6 +178,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -210,6 +211,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -221,6 +223,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdap_test/expectremote4/Makefile.in b/ncdap_test/expectremote4/Makefile.in
index e03da2b..7bd807b 100644
--- a/ncdap_test/expectremote4/Makefile.in
+++ b/ncdap_test/expectremote4/Makefile.in
@@ -178,6 +178,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -210,6 +211,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -221,6 +223,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdap_test/t_ncf330.c b/ncdap_test/t_ncf330.c
index 64e3a7e..d68f820 100644
--- a/ncdap_test/t_ncf330.c
+++ b/ncdap_test/t_ncf330.c
@@ -6,8 +6,13 @@
  * See https://bugtracking.unidata.ucar.edu/browse/NCF-330
  */
 
-#include <stdio.h>
+#include "config.h"
+#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
+#endif
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
 #include <netcdf.h>
 
 #ifdef _MSC_VER
@@ -33,7 +38,7 @@ main()
 #ifdef _MSC_VER
 	 /* See https://msdn.microsoft.com/en-us/library/5at7yxcs(v=vs.120).aspx
 	    for more information re: these. */
-	 //int tmpFlag = _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
+	 /*int tmpFlag = _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);*/
 #endif
      printf(" \n");
      printf("********************\n");
@@ -46,11 +51,11 @@ main()
      }
      printf("status after open = %d\n", ncstatus);
 
-     // get the format
+     /* get the format */
      ncstatus = nc_inq_format(ncid, &format_p);
      printf("lat id = %d\n", format_p);
 
-     // get varid for latitude
+     /* get varid for latitude */
      ncstatus = nc_inq_varid(ncid,"lat",&lat_id);
      printf("status after inq lat id = %d\n", ncstatus);
      printf("lat id = %d\n", lat_id);
@@ -59,13 +64,14 @@ main()
      printf("status after inq lat var = %d\n", ncstatus);
      printf("lat type = %d\n", lat_type);
 
-     // extract the first latitude value
+     /* extract the first latitude value */
      ncstatus = nc_get_var_float(ncid, lat_id, &lat_data[0]);
      printf("status after get = %d\n", ncstatus);
      printf("my datum = %f\n", lat_data[0]);
 
-     // This code works okay in Linux and Mac
-     // Everything works okay up until here in Windows then an exception occurs
+     /* This code works okay in Linux and Mac
+        Everything works okay up until here in Windows then an exception occurs
+     */
      ncstatus = nc_close(ncid);
      printf("status after close = %d\n", ncstatus);
      printf("End of test.\n\n");
diff --git a/ncdap_test/testdata3/Makefile.in b/ncdap_test/testdata3/Makefile.in
index 8194679..f061edf 100644
--- a/ncdap_test/testdata3/Makefile.in
+++ b/ncdap_test/testdata3/Makefile.in
@@ -178,6 +178,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -210,6 +211,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -221,6 +223,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdump/CMakeLists.txt b/ncdump/CMakeLists.txt
index eb6c2f3..a7ebdd1 100644
--- a/ncdump/CMakeLists.txt
+++ b/ncdump/CMakeLists.txt
@@ -87,7 +87,12 @@ ENDIF()
   add_sh_test(ncdump tst_lengths)
   add_sh_test(ncdump tst_calendars)
   add_bin_test(ncdump tst_utf8)
+
   add_sh_test(ncdump run_utf8_tests)
+  IF(USE_NETCDF4)
+    add_sh_test(ncdump run_utf8_nc4_tests)
+  ENDIF(USE_NETCDF4)
+
   add_sh_test(ncdump tst_nccopy3)
   add_sh_test(ncdump tst_charfill)
 
@@ -105,8 +110,11 @@ ENDIF()
   ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
 
   IF(BUILD_DISKLESS)
-    add_sh_test(ncdump tst_inmemory)
-  ENDIF()
+    add_sh_test(ncdump tst_inmemory_nc3)
+    IF(USE_NETCDF4)
+      add_sh_test(ncdump tst_inmemory_nc4)
+    ENDIF(USE_NETCDF4)
+  ENDIF(BUILD_DISKLESS)
 
   ###
   # This test fails on Visual Studio builds with bash.
diff --git a/ncdump/Makefile.am b/ncdump/Makefile.am
index 69e05ec..5c6548a 100644
--- a/ncdump/Makefile.am
+++ b/ncdump/Makefile.am
@@ -38,7 +38,10 @@ TESTS += tst_iter.sh
 endif
 
 if BUILD_DISKLESS
-TESTS += tst_inmemory.sh
+TESTS += tst_inmemory_nc3.sh
+if USE_NETCDF4
+TESTS += tst_inmemory_nc4.sh
+endif
 endif
 
 if USE_NETCDF4
@@ -53,7 +56,7 @@ 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             \
 tst_grp_spec.sh tst_mud.sh tst_h_scalar tst_h_scalar.sh tst_formatx4.sh \
-tst_bug324
+tst_bug324 run_utf8_nc4_tests.sh
 
 if EXTRA_TESTS
 TESTS += run_back_comp_tests.sh
@@ -71,7 +74,7 @@ ctest.c:
 	$(top_builddir)/ncgen/ncgen -lc -o ctest0.nc $(top_srcdir)/ncgen/c0.cdl > $(top_builddir)/ncdump/ctest.c
 
 ctest64.c:
-	$(top_builddir)/ncgen/ncgen -v2 -lc -o ctest0_64.nc $(top_srcdir)/ncgen/c0.cdl > $(top_builddir)/ncdump/ctest64.c
+	$(top_builddir)/ncgen/ncgen -k2 -lc -o ctest0_64.nc $(top_srcdir)/ncgen/c0.cdl > $(srcdir)/ctest64.c
 else
 ctest.c:
 	cp $(top_srcdir)/ncdump/ref_ctest.c $(top_builddir)/ncdump/ctest.c
@@ -131,8 +134,9 @@ ref_tst_charfill.cdl tst_charfill.cdl tst_charfill.sh                   \
 tst_iter.sh tst_mud.sh ref_tst_mud4.cdl ref_tst_mud4-bc.cdl             \
 ref_tst_mud4_chars.cdl \
 ref_tst_ncf213.cdl tst_h_scalar.sh                                      \
-tst_formatx3.sh tst_formatx4.sh ref_tst_utf8_4.cdl                        \
-CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory.sh
+run_utf8_nc4_tests.sh							\
+tst_formatx3.sh tst_formatx4.sh ref_tst_utf8_4.cdl                      \
+CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory_nc3.sh tst_inmemory_nc4.sh
 
 # CDL files and Expected results
 SUBDIRS=cdl expected
diff --git a/ncdump/Makefile.in b/ncdump/Makefile.in
index 0b08cda..844aac9 100644
--- a/ncdump/Makefile.in
+++ b/ncdump/Makefile.in
@@ -118,26 +118,28 @@ bin_PROGRAMS = ncdump$(EXEEXT) nccopy$(EXEEXT)
 @BUILD_TESTSETS_TRUE@	tst_nccopy3.sh tst_charfill.sh \
 @BUILD_TESTSETS_TRUE@	tst_iter.sh tst_formatx3.sh tst_bom.sh \
 @BUILD_TESTSETS_TRUE@	$(am__append_3) $(am__append_4) \
- at BUILD_TESTSETS_TRUE@	$(am__EXEEXT_2) $(am__append_7) \
- at BUILD_TESTSETS_TRUE@	tst_ncgen4_classic.sh $(am__append_8)
+ at BUILD_TESTSETS_TRUE@	$(am__append_5) $(am__EXEEXT_2) \
+ at BUILD_TESTSETS_TRUE@	$(am__append_8) tst_ncgen4_classic.sh \
+ at BUILD_TESTSETS_TRUE@	$(am__append_9)
 @BUILD_TESTSETS_TRUE@@LARGE_FILE_TESTS_TRUE at am__append_3 = tst_iter.sh
- at BUILD_DISKLESS_TRUE@@BUILD_TESTSETS_TRUE at am__append_4 = tst_inmemory.sh
+ at BUILD_DISKLESS_TRUE@@BUILD_TESTSETS_TRUE at am__append_4 = tst_inmemory_nc3.sh
+ at BUILD_DISKLESS_TRUE@@BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_5 = tst_inmemory_nc4.sh
 
 # NetCDF-4 has some extra tests.
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_5 = tst_create_files tst_h_rdc0 tst_group_data		\
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_6 = tst_create_files tst_h_rdc0 tst_group_data		\
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_enum_data tst_opaque_data tst_string_data tst_vlen_data tst_comp	\
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_comp2 tst_nans tst_special_atts tst_unicode tst_fillbug tst_compress \
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_chunking tst_h_scalar tst_bug324
 
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_6 = tst_create_files tst_group_data tst_enum_data tst_opaque_data	\
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_7 = tst_create_files tst_group_data tst_enum_data tst_opaque_data	\
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_string_data tst_vlen_data tst_comp tst_comp2 tst_nans		\
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_special_atts tst_netcdf4.sh tst_h_rdc0 tst_unicode tst_fillbug	\
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_fillbug.sh tst_netcdf4_4.sh tst_compress tst_nccopy4.sh             \
 @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
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at tst_bug324 run_utf8_nc4_tests.sh
 
- at BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE@@USE_NETCDF4_TRUE at am__append_7 = run_back_comp_tests.sh
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_8 = tst_ncgen4.sh
+ at BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE@@USE_NETCDF4_TRUE at am__append_8 = run_back_comp_tests.sh
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE at am__append_9 = tst_ncgen4.sh
 subdir = ncdump
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -568,7 +570,8 @@ RECHECK_LOGS = $(TEST_LOGS)
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@	tst_h_scalar$(EXEEXT) \
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@	tst_h_scalar.sh \
 @BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@	tst_formatx4.sh \
- at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@	tst_bug324$(EXEEXT)
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@	tst_bug324$(EXEEXT) \
+ at BUILD_TESTSETS_TRUE@@USE_NETCDF4_TRUE@	run_utf8_nc4_tests.sh
 TEST_SUITE_LOG = test-suite.log
 TEST_EXTENSIONS = @EXEEXT@ .test
 LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
@@ -667,6 +670,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -699,6 +703,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -710,6 +715,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -855,9 +861,10 @@ EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
 	ref_tst_grp_spec.cdl tst_grp_spec.sh ref_tst_charfill.cdl \
 	tst_charfill.cdl tst_charfill.sh tst_iter.sh tst_mud.sh \
 	ref_tst_mud4.cdl ref_tst_mud4-bc.cdl ref_tst_mud4_chars.cdl \
-	ref_tst_ncf213.cdl tst_h_scalar.sh tst_formatx3.sh \
-	tst_formatx4.sh ref_tst_utf8_4.cdl CMakeLists.txt XGetopt.c \
-	tst_bom.sh tst_inmemory.sh tst_ncgen_shared.sh tst_ncgen4.sh \
+	ref_tst_ncf213.cdl tst_h_scalar.sh run_utf8_nc4_tests.sh \
+	tst_formatx3.sh tst_formatx4.sh ref_tst_utf8_4.cdl \
+	CMakeLists.txt XGetopt.c tst_bom.sh tst_inmemory_nc3.sh \
+	tst_inmemory_nc4.sh 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
 
@@ -1518,9 +1525,16 @@ tst_bom.sh.log: tst_bom.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_inmemory.sh.log: tst_inmemory.sh
-	@p='tst_inmemory.sh'; \
-	b='tst_inmemory.sh'; \
+tst_inmemory_nc3.sh.log: tst_inmemory_nc3.sh
+	@p='tst_inmemory_nc3.sh'; \
+	b='tst_inmemory_nc3.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_inmemory_nc4.sh.log: tst_inmemory_nc4.sh
+	@p='tst_inmemory_nc4.sh'; \
+	b='tst_inmemory_nc4.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) \
@@ -1693,6 +1707,13 @@ tst_bug324.log: tst_bug324$(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)
+run_utf8_nc4_tests.sh.log: run_utf8_nc4_tests.sh
+	@p='run_utf8_nc4_tests.sh'; \
+	b='run_utf8_nc4_tests.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)
 run_back_comp_tests.sh.log: run_back_comp_tests.sh
 	@p='run_back_comp_tests.sh'; \
 	b='run_back_comp_tests.sh'; \
@@ -1931,7 +1952,7 @@ uninstall-man: uninstall-man1
 @BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE@	$(top_builddir)/ncgen/ncgen -lc -o ctest0.nc $(top_srcdir)/ncgen/c0.cdl > $(top_builddir)/ncdump/ctest.c
 
 @BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE at ctest64.c:
- at BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE@	$(top_builddir)/ncgen/ncgen -v2 -lc -o ctest0_64.nc $(top_srcdir)/ncgen/c0.cdl > $(top_builddir)/ncdump/ctest64.c
+ at BUILD_TESTSETS_TRUE@@EXTRA_TESTS_TRUE@	$(top_builddir)/ncgen/ncgen -k2 -lc -o ctest0_64.nc $(top_srcdir)/ncgen/c0.cdl > $(srcdir)/ctest64.c
 @BUILD_TESTSETS_TRUE@@EXTRA_TESTS_FALSE at ctest.c:
 @BUILD_TESTSETS_TRUE@@EXTRA_TESTS_FALSE@	cp $(top_srcdir)/ncdump/ref_ctest.c $(top_builddir)/ncdump/ctest.c
 
diff --git a/ncdump/cdl/Makefile.in b/ncdump/cdl/Makefile.in
index c138312..1db16c2 100644
--- a/ncdump/cdl/Makefile.in
+++ b/ncdump/cdl/Makefile.in
@@ -178,6 +178,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -210,6 +211,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -221,6 +223,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdump/chunkspec.c b/ncdump/chunkspec.c
index 3083256..d5a3b26 100644
--- a/ncdump/chunkspec.c
+++ b/ncdump/chunkspec.c
@@ -31,7 +31,7 @@ static struct {
  *         omitted, in which case it is assumed to be the entire
  *         dimension size.  That is also the default for dimensions
  *         not mentioned in the string.
- *         If the chunkspec string is "/", specifiying no dimensions or 
+ *         If the chunkspec string is "/", specifying no dimensions or 
  *         chunk sizes, it indicates chunking to be turned off on output.
  *
  * Returns NC_NOERR if no error, NC_EINVAL if spec has consecutive
diff --git a/ncdump/ctests.sh b/ncdump/ctests.sh
index defc25b..af507cf 100755
--- a/ncdump/ctests.sh
+++ b/ncdump/ctests.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #set -e
-#set -x
+set -x
 echo "*** ctests.sh: testing ncgen4 -c"
 
 KFLAG=3
diff --git a/ncdump/dumplib.c b/ncdump/dumplib.c
index 140ccbf..c3bc7e8 100644
--- a/ncdump/dumplib.c
+++ b/ncdump/dumplib.c
@@ -370,7 +370,6 @@ get_default_fmt(nc_type typeid) {
 	return float_var_fmt;
     case NC_DOUBLE:
 	return double_var_fmt;
-#ifdef USE_NETCDF4
     case NC_UBYTE:
 	return "%u";
     case NC_USHORT:
@@ -383,7 +382,6 @@ get_default_fmt(nc_type typeid) {
 	return "%llu";
     case NC_STRING:
 	return "\"%s\"";
-#endif	/* USE_NETCDF4 */
     default:
 	break;
     }
@@ -434,7 +432,6 @@ prim_type_name(nc_type type)
 	return "float";
       case NC_DOUBLE:
 	return "double";
-#ifdef USE_NETCDF4
       case NC_UBYTE:
 	return "ubyte";
       case NC_USHORT:
@@ -447,7 +444,6 @@ prim_type_name(nc_type type)
 	return "uint64";
       case NC_STRING:
 	return "string";
-#endif /* USE_NETCDF4 */
       default:
 	error("prim_type_name: bad type %d", type);
 	return "bogus";
@@ -455,6 +451,7 @@ prim_type_name(nc_type type)
 }
 
 static int max_type = 0;
+static int max_atomic_type = 0;
 static nctype_t **nctypes = 0;	/* holds all types in a netCDF dataset */
 
 
@@ -486,19 +483,48 @@ count_udtypes(int ncid) {
 }
 #endif /*USE_NETCDF4*/
 
-/* This routine really is intended to return the max typeid */
+/* This routine really is intended to return the max atomic typeid */
 static int
 max_typeid(int ncid) {
-    int maxtypes = NC_DOUBLE; /*ignore NC_NAT?*/
+    int maxtypes = NC_NAT;
+    int maxatomictypes = NC_NAT;
+    int format = 0;
+    int err = NC_NOERR;
+
+    /* get the file type */
+    err = nc_inq_format(ncid,&format);
+    if(err) {
+	fprintf(stderr,"%s: Cannot get file format.\n",nc_strerror(err));
+	return 0;
+    }
+    switch (format) {
+    case NC_FORMAT_CLASSIC:
+    case NC_FORMAT_NETCDF4_CLASSIC:
+    case NC_FORMAT_64BIT_OFFSET:
+        maxatomictypes = (maxtypes = NC_DOUBLE); /*ignore NC_NAT?*/
+	break;
+    case NC_FORMAT_64BIT_DATA:
+	maxatomictypes = (maxtypes = NC_UINT64);
+	break;
+    case NC_FORMAT_NETCDF4:
 #ifdef USE_NETCDF4
-    int nuser = 0;
-    maxtypes = NC_STRING; /* extra netCDF-4 primitive types */
-    maxtypes += 4;		/* user-defined classes */
-    nuser = count_udtypes(ncid);
-    if(nuser > 0)
-	maxtypes = NC_FIRSTUSERTYPEID + (nuser - 1);
+	{
+        int nuser = 0;
+        maxatomictypes = (maxtypes = NC_STRING); /* extra netCDF-4 primitive types */
+        maxtypes += 4;		/* user-defined classes */
+        nuser = count_udtypes(ncid);
+        if(nuser > 0)
+	    maxtypes = NC_FIRSTUSERTYPEID + (nuser - 1);
+	} break;
+#else
+	/* fallthru */
 #endif
+    default:
+	fprintf(stderr,"Unexpected file format: %d\n",format);
+	return 0;
+    }
     max_type = maxtypes;
+    max_atomic_type = maxatomictypes;
     return maxtypes;
 }
 
@@ -598,7 +624,6 @@ ncdouble_val_equals(const nctype_t *this,
     return false;
 }
 
-#ifdef USE_NETCDF4
 bool_t
 ncubyte_val_equals(const nctype_t *this,
 		   const void *v1p, const void *v2p) {
@@ -641,6 +666,7 @@ ncstring_val_equals(const nctype_t *this,
     return (strcmp(*((char **)v1p), *((char **)v2p)) == 0);
 }
 
+#ifdef USE_NETCDF4
 bool_t
 ncopaque_val_equals(const nctype_t *this,
 		    const void *v1p, const void *v2p) {
@@ -821,7 +847,6 @@ ncdouble_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp) {
     return sbuf_len(sfbf);
 }
 
-#ifdef USE_NETCDF4
 int
 ncubyte_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp) {
     char sout[PRIM_LEN];
@@ -945,6 +970,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp
     return sbuf_len(sfbf);
 }
 
+#ifdef USE_NETCDF4
 int
 ncenum_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp) {
     char symbol[NC_MAX_NAME + 1];
@@ -1260,7 +1286,6 @@ double to_double(const ncvar_t *varp, const void *valp) {
     case NC_DOUBLE:
 	dd = *(double *)valp;
 	break;
-#ifdef USE_NETCDF4
     case NC_UBYTE:
 	dd = *(unsigned char *)valp;
 	break;
@@ -1276,7 +1301,6 @@ double to_double(const ncvar_t *varp, const void *valp) {
     case NC_UINT64:
 	dd = *(unsigned long long *)valp;
 	break;
-#endif /* USE_NETCDF4 */
     default:
 	error("to_double: type not numeric primitive");
     }
@@ -1303,7 +1327,6 @@ nctime_val_tostring(const ncvar_t *varp, safebuf_t *sfbf, const void *valp) {
     return sbuf_len(sfbf);
 }
 
-#ifdef USE_NETCDF4
 int
 ncubyte_val_tostring(const ncvar_t *varp, safebuf_t *sfbf, const void *valp) {
     char sout[PRIM_LEN];
@@ -1359,6 +1382,7 @@ ncstring_val_tostring(const ncvar_t *varp, safebuf_t *sfbf, const void *valp) {
     return ncstring_typ_tostring(varp->tinfo, sfbf, valp);
 }
 
+#ifdef USE_NETCDF4
 int
 ncenum_val_tostring(const ncvar_t *varp, safebuf_t *sfbf, const void *valp) {
     return ncenum_typ_tostring(varp->tinfo, sfbf, valp);
@@ -1381,7 +1405,7 @@ int
 nccomp_val_tostring(const ncvar_t *varp, safebuf_t *sfbf, const void *valp) {
     return nccomp_typ_tostring(varp->tinfo, sfbf, valp);
 }
-#endif /* USE_NETCDF4 */
+#endif /*USE_NETCDF4*/
 
 static val_equals_func eq_funcs[] = {
 	ncbyte_val_equals,
@@ -1389,16 +1413,13 @@ static val_equals_func eq_funcs[] = {
 	ncshort_val_equals,
 	ncint_val_equals,
 	ncfloat_val_equals,
-	ncdouble_val_equals
-#ifdef USE_NETCDF4
-,
+	ncdouble_val_equals,
 	ncubyte_val_equals,
 	ncushort_val_equals,
 	ncuint_val_equals,
 	ncint64_val_equals,
 	ncuint64_val_equals,
 	ncstring_val_equals
-#endif /* USE_NETCDF4 */
     };
 
 static typ_tostring_func ts_funcs[] = {
@@ -1407,16 +1428,13 @@ static typ_tostring_func ts_funcs[] = {
 	ncshort_typ_tostring,
 	ncint_typ_tostring,
 	ncfloat_typ_tostring,
-	ncdouble_typ_tostring
-#ifdef USE_NETCDF4
-,
+	ncdouble_typ_tostring,
 	ncubyte_typ_tostring,
 	ncushort_typ_tostring,
 	ncuint_typ_tostring,
 	ncint64_typ_tostring,
 	ncuint64_typ_tostring,
 	ncstring_typ_tostring
-#endif /* USE_NETCDF4 */
     };
 
 
@@ -1430,16 +1448,13 @@ set_tostring_func(ncvar_t *varp) {
 	ncshort_val_tostring,
 	ncint_val_tostring,
 	ncfloat_val_tostring,
-	ncdouble_val_tostring
-#ifdef USE_NETCDF4
-,
+	ncdouble_val_tostring,
 	ncubyte_val_tostring,
 	ncushort_val_tostring,
 	ncuint_val_tostring,
 	ncint64_val_tostring,
 	ncuint64_val_tostring,
 	ncstring_val_tostring
-#endif /* USE_NETCDF4 */
     };
     if(varp->has_timeval && formatting_specs.string_times) {
 	varp->val_tostring = (val_tostring_func) nctime_val_tostring;
@@ -1478,22 +1493,20 @@ static void
 init_prim_types(int ncid) {
     nctype_t *tp;
     int i;
-    int types[] = {
+    int types[] =
+{
 	NC_BYTE,
 	NC_CHAR,
 	NC_SHORT,
 	NC_INT,
 	NC_FLOAT,
-	NC_DOUBLE
-#ifdef USE_NETCDF4
-,
+	NC_DOUBLE,
 	NC_UBYTE,
 	NC_USHORT,
 	NC_UINT,
 	NC_INT64,
 	NC_UINT64,
 	NC_STRING
-#endif /* USE_NETCDF4 */
     };
     size_t sizes[] = {
 	sizeof(char),
@@ -1501,19 +1514,20 @@ init_prim_types(int ncid) {
 	sizeof(short),
 	sizeof(int),
 	sizeof(float),
-	sizeof(double)
-#ifdef USE_NETCDF4
-,
+	sizeof(double),
 	sizeof(unsigned char),
 	sizeof(unsigned short),
 	sizeof(unsigned int),
 	sizeof(long long),
 	sizeof(unsigned long long),
 	sizeof(char **)
-#endif /* USE_NETCDF4 */
     };
 
+#if 0
     for(i=0; i < sizeof(types)/sizeof(int); i++) {
+#else
+    for(i=0; i < max_atomic_type; i++) {
+#endif
 	tp = (nctype_t *)emalloc(sizeof(nctype_t));
 	tp->ncid = ncid;
 	tp->tid = types[i];
@@ -1830,6 +1844,7 @@ print_type_name(int locid, int typeid) {
  * use by is_unlim_dim() function.  If ncid is a subgroup of a netCDF
  * dataset, the table will still be initialized for the whole dataset
  * in which the subgroup resides. */
+#ifdef USE_NETCDF4
 static int
 init_is_unlim(int ncid, int **is_unlim_p)
 {
@@ -1840,7 +1855,6 @@ init_is_unlim(int ncid, int **is_unlim_p)
     int igrp;
     int grpid;
 
-#ifdef USE_NETCDF4
     /* if ncid is not root group, find its ancestor root group id */
     int status = nc_inq_grp_parent(ncid, &grpid);
     while(status == NC_NOERR && grpid != ncid) {
@@ -1883,9 +1897,9 @@ init_is_unlim(int ncid, int **is_unlim_p)
 	    free(dimids);
     }
     free(grpids);
-#endif	/*  USE_NETCDF4 */
     return NC_NOERR;
 }
+#endif	/*  USE_NETCDF4 */
 
 /* TODO: make list of these arrays for multiple open datasets, such as
  * the idnode_t lists above.  For now, we just have one of these, for
@@ -1901,7 +1915,7 @@ is_unlim_dim(int ncid, int dimid) {
 #ifdef USE_NETCDF4
     static int *is_unlim = NULL; /* gets allocated by init_is_unlim() */
     if(for_ncid == UNLIM_NOT_INITIALIZED) {
-      NC_CHECK( init_is_unlim(ncid, &is_unlim) );
+      NC_CHECK(init_is_unlim(ncid, &is_unlim));
       for_ncid = ncid;
     }
     assert(is_unlim);
diff --git a/ncdump/expected/Makefile.in b/ncdump/expected/Makefile.in
index bfca65d..1883008 100644
--- a/ncdump/expected/Makefile.in
+++ b/ncdump/expected/Makefile.in
@@ -176,6 +176,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -208,6 +209,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -219,6 +221,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncdump/nccopy.c b/ncdump/nccopy.c
index f3bf1b6..ed56eb0 100644
--- a/ncdump/nccopy.c
+++ b/ncdump/nccopy.c
@@ -1160,7 +1160,8 @@ count_dims(int ncid) {
  * to copy data a record at a time. */
 static int
 nc3_special_case(int ncid, int kind) {
-    if (kind == NC_FORMAT_CLASSIC ||  kind == NC_FORMAT_64BIT) {
+    if (kind == NC_FORMAT_CLASSIC ||  kind == NC_FORMAT_64BIT_OFFSET
+        || kind == NC_FORMAT_CDF5) {
 	int recdimid = 0;
 	NC_CHECK(nc_inq_unlimdim(ncid, &recdimid));
 	if (recdimid != -1) {	/* we have a record dimension */
@@ -1368,7 +1369,8 @@ copy(char* infile, char* outfile)
     if (option_kind == SAME_AS_INPUT) {	/* default, kind not specified */
 	outkind = inkind;
 	/* Deduce output kind if netCDF-4 features requested */
-	if (inkind == NC_FORMAT_CLASSIC || inkind == NC_FORMAT_64BIT) { 
+	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) 
@@ -1406,9 +1408,12 @@ copy(char* infile, char* outfile)
     case NC_FORMAT_CLASSIC:
 	/* nothing to do */
 	break;
-    case NC_FORMAT_64BIT:
+    case NC_FORMAT_64BIT_OFFSET:
 	create_mode |= NC_64BIT_OFFSET;
 	break;
+    case NC_FORMAT_CDF5:
+	create_mode |= NC_64BIT_DATA;
+	break;
 #ifdef USE_NETCDF4
     case NC_FORMAT_NETCDF4:
 	create_mode |= NC_NETCDF4;
@@ -1514,12 +1519,13 @@ usage(void)
 {
 #define USAGE   "\
   [-k kind] specify kind of netCDF format for output file, default same as input\n\
-	    kind strings: 'classic', '64-bit offset',\n\
+	    kind strings: 'classic', '64-bit offset', 'cdf5',\n\
                           'netCDF-4', 'netCDF-4 classic model'\n\
   [-3]      netCDF classic output (same as -k 'classic')\n\
   [-6]      64-bit-offset output (same as -k '64-bit offset')\n\
   [-4]      netCDF-4 output (same as -k 'netCDF-4')\n\
   [-7]      netCDF-4-classic output (same as -k 'netCDF-4 classic model')\n\
+  [-5]      CDF5 output (same as -k 'cdf5)\n\
   [-d n]    set output deflation compression level, default same as input (0=none 9=max)\n\
   [-s]      add shuffle option to deflation compression\n\
   [-c chunkspec] specify chunking for dimensions, e.g. \"dim1/N1,dim2/N2,...\"\n\
@@ -1532,7 +1538,7 @@ usage(void)
   [-m n]    set size in bytes of copy buffer, default is 5000000 bytes\n\
   [-h n]    set size in bytes of chunk_cache for chunked variables\n\
   [-e n]    set number of elements that chunk_cache can hold\n\
-  [-r]      read whole input file into diskless file on open (classic or 64-bit offset format only)\n\
+  [-r]      read whole input file into diskless file on open (classic or 64-bit offset or cdf5 formats only)\n\
   infile    name of netCDF input file\n\
   outfile   name for netCDF output file\n"
 
@@ -1561,10 +1567,10 @@ main(int argc, char**argv)
 	{"1", NC_FORMAT_CLASSIC}, /* deprecated, use "-3" or "-k nc3" instead */
 	
 	/* NetCDF-3 64-bit offset format */
-	{"64-bit offset", NC_FORMAT_64BIT}, /* canonical format name */
-	{"nc6", NC_FORMAT_64BIT},	    /* short format name */
-	{"2", NC_FORMAT_64BIT},	/* deprecated, use "-6" or "-k nc6" instead */
-	{"64-bit-offset", NC_FORMAT_64BIT}, /* deprecated alias */
+	{"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 */
@@ -1584,6 +1590,13 @@ main(int argc, char**argv)
 	{"hdf5-nc3", NC_FORMAT_NETCDF4_CLASSIC},
 	{"enhanced-nc3", NC_FORMAT_NETCDF4_CLASSIC},
 
+	/* The 64-bit data (CDF5) kind (5) */
+	{"5", NC_FORMAT_CDF5},
+	{"64-bit-data", NC_FORMAT_CDF5},
+	{"64-bit data", NC_FORMAT_CDF5},
+	{"nc5", NC_FORMAT_CDF5},
+	{"cdf5", NC_FORMAT_CDF5},
+
 	/* null terminate*/
 	{NULL,0}
     };
@@ -1604,11 +1617,13 @@ main(int argc, char**argv)
                        "64-bit offset" or "nc6"
 		       "netCDF-4" or "nc4"
 		       "netCDF-4 classic model" or "nc7"
+                       "64-bit-data" | "64-bit data" | "cdf5" | "nc5"
                      Format version numbers (deprecated):
                        1 (=> classic)
                        2 (=> 64-bit offset)
                        3 (=> netCDF-4)
                        4 (=> netCDF-4 classic model)
+                       5 (=> classic 64 bit data, CDF-5)
 		   */
 	    {
 		struct Kvalues* kvalue;
@@ -1628,8 +1643,11 @@ main(int argc, char**argv)
 	case '3':		/* output format is classic (netCDF-3) */
 	    option_kind = NC_FORMAT_CLASSIC;
 	    break;
+	case '5':		/* output format is cdf5 */
+	    option_kind = NC_FORMAT_CDF5;
+	    break;
 	case '6':		/* output format is 64-bit-offset (netCDF-3 version 2) */
-	    option_kind = NC_FORMAT_64BIT;
+	    option_kind = NC_FORMAT_64BIT_OFFSET;
 	    break;
 	case '4':		/* output format is netCDF-4 (variant of HDF5) */
 	    option_kind = NC_FORMAT_NETCDF4;
diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c
index 835d251..7e1c5ac 100644
--- a/ncdump/ncdump.c
+++ b/ncdump/ncdump.c
@@ -148,7 +148,7 @@ name_path(const char *path)
     cp = strrchr(path, FILE_DELIMITER);
     if (cp == 0)		/* no delimiter */
       cp = path;
-    else			/* skip delimeter */
+    else			/* skip delimiter */
       cp++;
     new = (char *) emalloc((unsigned) (strlen(cp)+1));
     (void) strncpy(new, cp, strlen(cp) + 1);	/* copy last component of path */
@@ -174,7 +174,6 @@ prim_type_name(nc_type type)
 	return "float";
       case NC_DOUBLE:
 	return "double";
-#ifdef USE_NETCDF4
       case NC_UBYTE:
 	return "ubyte";
       case NC_USHORT:
@@ -193,7 +192,6 @@ prim_type_name(nc_type type)
 	return "opaque";
       case NC_COMPOUND:
 	return "compound";
-#endif /* USE_NETCDF4 */
       default:
 	error("prim_type_name: bad type %d", type);
 	return "bogus";
@@ -238,8 +236,10 @@ kind_string(int kind)
     switch (kind) {
     case NC_FORMAT_CLASSIC:
 	return "classic";
-    case NC_FORMAT_64BIT:
+    case NC_FORMAT_64BIT_OFFSET:
 	return "64-bit offset";
+    case NC_FORMAT_CDF5:
+	return "cdf5";
     case NC_FORMAT_NETCDF4:
 	return "netCDF-4";
     case NC_FORMAT_NETCDF4_CLASSIC:
@@ -257,28 +257,30 @@ kind_string_extended(int kind, int mode)
 {
     static char text[1024];
     switch (kind) {
-    case NC_FORMAT_NC3:
-	if(mode & NC_64BIT_OFFSET)
+    case NC_FORMATX_NC3:
+	if(mode & NC_CDF5)
+	    snprintf(text,sizeof(text),"%s mode=%08x", "64-bit data",mode);
+	else if(mode & NC_64BIT_OFFSET)
 	    snprintf(text,sizeof(text),"%s mode=%08x", "64-bit offset",mode);
 	else
 	    snprintf(text,sizeof(text),"%s mode=%08x", "classic",mode);
 	break;
-    case NC_FORMAT_NC_HDF5:
+    case NC_FORMATX_NC_HDF5:
 	snprintf(text,sizeof(text),"%s mode=%08x", "HDF5",mode);
 	break;
-    case NC_FORMAT_NC_HDF4:
+    case NC_FORMATX_NC_HDF4:
 	snprintf(text,sizeof(text),"%s mode=%08x", "HDF4",mode);
 	break;
-    case NC_FORMAT_PNETCDF:
+    case NC_FORMATX_PNETCDF:
 	snprintf(text,sizeof(text),"%s mode=%08x", "PNETCDF",mode);
 	break;
-    case NC_FORMAT_DAP2:
+    case NC_FORMATX_DAP2:
 	snprintf(text,sizeof(text),"%s mode=%08x", "DAP2",mode);
 	break;
-    case NC_FORMAT_DAP4:
+    case NC_FORMATX_DAP4:
 	snprintf(text,sizeof(text),"%s mode=%08x", "DAP4",mode);
 	break;
-    case NC_FORMAT_UNDEFINED:
+    case NC_FORMATX_UNDEFINED:
 	snprintf(text,sizeof(text),"%s mode=%08x", "unknown",mode);
 	break;
     default:
@@ -405,7 +407,7 @@ pr_att_string(
 	    break;
 	case '\n':
 	    /* Only generate linebreaks after embedded newlines for
-	     * classic, 64-bit offset, or classic model files.  For
+	     * classic, 64-bit offset, cdf5, or classic model files.  For
 	     * netCDF-4 files, don't generate linebreaks, because that
 	     * would create an extra string in a list of strings.  */
 	    if (kind != NC_FORMAT_NETCDF4) {
@@ -520,12 +522,12 @@ pr_att_valgs(
     char gps[PRIM_LEN];
     float ff;
     double dd;
-#ifdef USE_NETCDF4
     unsigned char uc;
     unsigned short us;
     unsigned int ui;
     int64_t i64;
     uint64_t ui64;
+#ifdef USE_NETCDF4
     char *stringp;
 #endif /* USE_NETCDF4 */
     char *delim = ", ";	/* delimiter between output values */
@@ -590,7 +592,6 @@ pr_att_valgs(
 		}
 	    }
 	    break;
-#ifdef USE_NETCDF4
 	case NC_UBYTE:
 	    uc = ((unsigned char *) vals)[iel];
 	    printf ("%uUB%s", uc, delim);
@@ -611,6 +612,7 @@ pr_att_valgs(
 	    ui64 = ((uint64_t *) vals)[iel];
 	    printf ("%lluUL%s", ui64, delim);
 	    break;
+#ifdef USE_NETCDF4
 	case NC_STRING:
 	    stringp = ((char **) vals)[iel];
             if(stringp)
@@ -646,11 +648,9 @@ pr_att_valsx(
     float ff;
     double dd;
     int ii;
-#ifdef USE_NETCDF4
     unsigned int ui;
     int64_t i64;
     uint64_t ui64;
-#endif /* USE_NETCDF4 */
 
     attvals[0]='\0';
     if (len == 0)
@@ -668,7 +668,6 @@ pr_att_valsx(
 	    (void) strlcat(attvals, gps, attvalslen);
 	    (void) strlcat(attvals, iel < len-1 ? " " : "", attvalslen);
 	    break;
-#ifdef USE_NETCDF4
 	case NC_UBYTE:
 	case NC_USHORT:
 	case NC_UINT:
@@ -692,7 +691,6 @@ pr_att_valsx(
 	    (void) strlcat(attvals, gps, attvalslen);
 	    (void) strlcat(attvals, iel < len-1 ? " " : "", attvalslen);
 	    break;
-#endif /* USE_NETCDF4 */
 	case NC_FLOAT:
 	    ff = vals[iel];
 	    res = snprintf(gps, PRIM_LEN, float_attx_fmt, ff);
@@ -1192,7 +1190,6 @@ print_enum_type(int ncid, nc_type typeid) {
 	case NC_INT:
 	    memval = *(int *)&data;
 	    break;
-#ifdef USE_NETCDF4
 	case NC_UBYTE:
 	    memval = *(unsigned char *)&data;
 	    break;
@@ -1208,7 +1205,6 @@ print_enum_type(int ncid, nc_type typeid) {
 	case NC_UINT64:
 	    memval = *(uint64_t *)&data;
 	    break;
-#endif /* USE_NETCDF4 */
 	default:
 	    error("Bad base type for enum!");
 	    break;
@@ -1347,7 +1343,6 @@ get_fill_info(int ncid, int varid, ncvar_t *vp) {
 	case NC_DOUBLE:
 	    *(double *)fillvalp = NC_FILL_DOUBLE;
 	    break;
-#ifdef USE_NETCDF4
 	case NC_UBYTE:
 	    /* don't do default fill-values for bytes, too risky */
 	    vp->has_fillval = 0;
@@ -1366,6 +1361,7 @@ get_fill_info(int ncid, int varid, ncvar_t *vp) {
 	case NC_UINT64:
 	    *(uint64_t *)fillvalp = NC_FILL_UINT64;
 	    break;
+#ifdef USE_NETCDF4
 	case NC_STRING:
 	    *((char **)fillvalp) = strdup(NC_FILL_STRING);
 	    break;
@@ -1554,7 +1550,7 @@ do_ncdump_rec(int ncid, const char *path)
    /* Because netCDF-4 can have a string attribute with multiple
     * string values, we can't output strings with embedded newlines
     * as what look like multiple strings, as we do for classic and
-    * 64-bit offset files.  So we need to know the output file type
+    * 64-bit offset  and cdf5 files.  So we need to know the output file type
     * to know how to print strings with embedded newlines. */
    NC_CHECK( nc_inq_format(ncid, &kind) );
 
diff --git a/ncdump/nctime0.c b/ncdump/nctime0.c
index 7031260..35265b4 100644
--- a/ncdump/nctime0.c
+++ b/ncdump/nctime0.c
@@ -265,7 +265,7 @@ get_timeinfo(int ncid1, int varid1, ncvar_t *vp) {
  *     are always printed on successive lines, with line wrapping
  *     as needed.
  *
- * Assume: Preceeding call to pr_att_valgs has already screened
+ * Assume: Preceding call to pr_att_valgs has already screened
  * this attribute for valid primitive types for the current netcdf
  * model (netcdf 3 or 4).
  */
diff --git a/ncdump/run_utf8_nc4_tests.sh b/ncdump/run_utf8_nc4_tests.sh
new file mode 100755
index 0000000..05a1f86
--- /dev/null
+++ b/ncdump/run_utf8_nc4_tests.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# Moving some netcdf-4 only tests here, out of tst_nccopy and run_utf8_tests.
+# Without this, the tests fail when netcdf-4 is disabled.
+
+set -e
+if test "x$srcdir" = "x"; then
+    srcdir=`dirname $0`;
+fi
+export srcdir
+echo ""
+
+rm -f utf8.nc utf8.cdl
+echo "*** creating enhanced file with utf8 characters..."
+../ncgen/ncgen -4 -b -o utf8.nc ${srcdir}/ref_tst_utf8_4.cdl
+echo "*** dump and compare utf8 output..."
+./ncdump utf8.nc > utf8.cdl
+diff -b -w utf8.cdl ${srcdir}/ref_tst_utf8_4.cdl
diff --git a/ncdump/run_utf8_tests.sh b/ncdump/run_utf8_tests.sh
index c4eabec..7d9e8ef 100755
--- a/ncdump/run_utf8_tests.sh
+++ b/ncdump/run_utf8_tests.sh
@@ -21,13 +21,6 @@ echo "*** dump and compare utf8 output..."
 diff -b -w utf8.cdl ${srcdir}/ref_tst_utf8.cdl
 
 rm -f utf8.nc utf8.cdl
-echo "*** creating enhanced file with utf8 characters..."
-../ncgen/ncgen -4 -b -o utf8.nc ${srcdir}/ref_tst_utf8_4.cdl
-echo "*** dump and compare utf8 output..."
-./ncdump utf8.nc > utf8.cdl
-diff -b -w utf8.cdl ${srcdir}/ref_tst_utf8_4.cdl
-
-rm -f utf8.nc utf8.cdl
 echo "*** creating 64-bit offset file with utf8 characters..."
 ../ncgen/ncgen -k 64-bit-offset -b -o utf8.nc ${srcdir}/ref_tst_utf8.cdl
 echo "*** (64 bit) dump and compare utf8 output..."
diff --git a/ncdump/tst_64bit.sh b/ncdump/tst_64bit.sh
index 18819bc..b8a5468 100755
--- a/ncdump/tst_64bit.sh
+++ b/ncdump/tst_64bit.sh
@@ -6,13 +6,28 @@ echo ""
 echo "*** Testing ncgen and ncdump with 64-bit offset format."
 set -e
 echo "*** creating test0.nc from test0.cdl..."
-../ncgen/ncgen -b -v2 $srcdir/test0.cdl
+../ncgen/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/ncgen -b -v2 test1.cdl
+../ncgen/ncgen -b -k2 test1.cdl
 echo "*** creating test2.cdl from test1.nc..."
 ./ncdump test1.nc > test2.cdl
 cmp test1.cdl test2.cdl
 echo "*** All ncgen and ncdump with 64-bit offset format tests passed!"
+
+echo ""
+echo "*** Testing ncgen and ncdump with CDF5 format."
+set -e
+echo "*** creating test0.nc from test0.cdl..."
+../ncgen/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/ncgen -b -k5 test1.cdl
+echo "*** creating test2.cdl from test1.nc..."
+./ncdump test1.nc > test2.cdl
+cmp test1.cdl test2.cdl
+echo "*** All ncgen and ncdump with CDF5 format tests passed!"
+
 exit 0
diff --git a/ncdump/tst_formatx3.sh b/ncdump/tst_formatx3.sh
index 9c4c0f4..ef0bf38 100755
--- a/ncdump/tst_formatx3.sh
+++ b/ncdump/tst_formatx3.sh
@@ -21,7 +21,7 @@ echo "*** Fail: extended format for a classic file"
 ECODE=1
 fi
 
-echo "Test extended format output for a 64-bit netcdf-3 file"
+echo "Test extended format output for a 64-bit offset netcdf-3 file"
 rm -f tmp
 ../ncgen/ncgen -k nc6 -b -o ./test.nc $srcdir/ref_tst_small.cdl
 ./ncdump -K test.nc >tmp
@@ -30,6 +30,15 @@ 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/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
+
 rm -f tmp test.nc
 
 exit $ECODE
diff --git a/ncdump/tst_inmemory.sh b/ncdump/tst_inmemory_nc3.sh
similarity index 97%
copy from ncdump/tst_inmemory.sh
copy to ncdump/tst_inmemory_nc3.sh
index 66b17a7..315a946 100755
--- a/ncdump/tst_inmemory.sh
+++ b/ncdump/tst_inmemory_nc3.sh
@@ -41,7 +41,6 @@ done
 }
 
 dotest "3" "$CLASSIC"
-dotest "4" "$EXTENDED"
 
 # Cleanup
 rm -fr results
@@ -53,5 +52,3 @@ else
   CODE=1
 fi
 exit $CODE
-
-
diff --git a/ncdump/tst_inmemory.sh b/ncdump/tst_inmemory_nc4.sh
similarity index 84%
rename from ncdump/tst_inmemory.sh
rename to ncdump/tst_inmemory_nc4.sh
index 66b17a7..2283392 100755
--- a/ncdump/tst_inmemory.sh
+++ b/ncdump/tst_inmemory_nc4.sh
@@ -41,7 +41,13 @@ done
 }
 
 dotest "3" "$CLASSIC"
-dotest "4" "$EXTENDED"
+dotest "5" "$EXTENDED5"
+
+if test -f ${builddir}/../config.h ; then
+  if fgrep -e '#define USE_NETCDF4 1' ${builddir}/../config.h >/dev/null ; then
+    dotest "4" "$EXTENDED4"
+  fi
+fi
 
 # Cleanup
 rm -fr results
@@ -53,5 +59,3 @@ else
   CODE=1
 fi
 exit $CODE
-
-
diff --git a/ncdump/tst_lengths.sh b/ncdump/tst_lengths.sh
index bac330f..dead6b2 100755
--- a/ncdump/tst_lengths.sh
+++ b/ncdump/tst_lengths.sh
@@ -87,6 +87,36 @@ echo "*** testing length of rewritten 64-bit offset file written with NOFILL"
 #    exit 1
 #fi
 
+echo "*** testing length of 64-bit data file"
+../ncgen/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/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/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/ncgen -b -5 ${srcdir}/small.cdl && ./rewrite-scalar small.nc t
+if test `wc -c < small.nc` != 104; then
+    exit 1
+fi
+
+echo "*** testing length of rewritten 64-bit data file written with NOFILL"
+../ncgen/ncgen -b -5 -x ${srcdir}/small.cdl && ./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"
@@ -95,6 +125,36 @@ echo "*** testing length of one-record-variable classic file"
 #    exit 1
 #fi
 
+echo "*** testing length of one-record-variable 64-bit data file"
+../ncgen/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/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/ncgen -b -5 -x ${srcdir}/small2.cdl
+if test `wc -c < small2.nc` != 161; then
+    exit 1
+fi
+
+echo "*** testing length of one-record-variable classic file written with NOFILL"
+../ncgen/ncgen -b -x ${srcdir}/small2.cdl
+if test `wc -c < small2.nc` != 101; then
+    exit 1
+fi
+
+echo "*** testing length of one-record-variable classic file written with NOFILL"
+../ncgen/ncgen -b -x ${srcdir}/small2.cdl
+if test `wc -c < small2.nc` != 101; then
+    exit 1
+fi
+
 echo "*** testing length of one-record-variable classic file written with NOFILL"
 ../ncgen/ncgen -b -x ${srcdir}/small2.cdl
 #if test `wc -c < small2.nc` != 101; then
diff --git a/ncdump/vardata.c b/ncdump/vardata.c
index 6131e78..620554d 100644
--- a/ncdump/vardata.c
+++ b/ncdump/vardata.c
@@ -106,7 +106,7 @@ lput2(
 /* (1) Single space or newline/indent sequence, as needed. */
     
     linep = linep + 1 + len1;		/* new line position, without newline */
-    					/* add 1 extra for preceeding space   */
+    					/* add 1 extra for preceding space   */
     
     make_newline = (wrap && (first_item || linep > max_line_len + 2));
     					/* NEVER new line in no-wrap mode */
diff --git a/ncgen/ConvertUTF.h b/ncgen/ConvertUTF.h
index e264915..e26e7c9 100644
--- a/ncgen/ConvertUTF.h
+++ b/ncgen/ConvertUTF.h
@@ -24,7 +24,7 @@
 
     Conversions between UTF32, UTF-16, and UTF-8.  Header file.
 
-    Several funtions are included here, forming a complete set of
+    Several functions are included here, forming a complete set of
     conversions between the three formats.  UTF-7 is not included
     here, but is handled in a separate source file.
 
diff --git a/ncgen/Makefile.am b/ncgen/Makefile.am
index e88dc05..e27b258 100644
--- a/ncgen/Makefile.am
+++ b/ncgen/Makefile.am
@@ -22,7 +22,7 @@ man_MANS = ncgen.1
 # These files all need to be distributed.
 EXTRA_DIST = ncgen.y ncgenyy.c ncgen.l $(man_MANS) internals.html	\
 run_tests.sh run_nc4_tests.sh c0.cdl c0_4.cdl ref_camrun.cdl \
-ncf199.cdl CMakeLists.txt XGetopt.c
+ncf199.cdl CMakeLists.txt XGetopt.c c5.cdl
 
 # This shell script causes ncgen to build a classic and a 64-bit
 # offset file from a cdl file shipped with the distribution.
@@ -34,7 +34,7 @@ endif # USE_NETCDF4
 #endif # !BUILD_DLL
 
 CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c \
-		ncf199.nc
+		ncf199.nc c5.nc
 
 # These rules are used if someone wants to rebuild ncgenyy.c or ncgentab.c
 # Otherwise never invoked, but records how to do it.
diff --git a/ncgen/Makefile.in b/ncgen/Makefile.in
index 211696d..c281b93 100644
--- a/ncgen/Makefile.in
+++ b/ncgen/Makefile.in
@@ -457,6 +457,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -489,6 +490,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -500,6 +502,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -594,7 +597,7 @@ man_MANS = ncgen.1
 # These files all need to be distributed.
 EXTRA_DIST = ncgen.y ncgenyy.c ncgen.l $(man_MANS) internals.html	\
 run_tests.sh run_nc4_tests.sh c0.cdl c0_4.cdl ref_camrun.cdl \
-ncf199.cdl CMakeLists.txt XGetopt.c
+ncf199.cdl CMakeLists.txt XGetopt.c c5.cdl
 
 
 # This shell script causes ncgen to build a classic and a 64-bit
@@ -603,7 +606,7 @@ ncf199.cdl CMakeLists.txt XGetopt.c
 TESTS = run_tests.sh $(am__append_3)
 #endif # !BUILD_DLL
 CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c \
-		ncf199.nc
+		ncf199.nc c5.nc
 
 all: all-am
 
diff --git a/ncgen/c0.cdl b/ncgen/c0.cdl
index 1bfe245..a712263 100644
--- a/ncgen/c0.cdl
+++ b/ncgen/c0.cdl
@@ -159,7 +159,8 @@ data:
 
  d2 = -1e+308, 1e+308 ;
 
- c3 = "\001\177." ;
+// c3 = "\001\300." ; This is actually illegal utf8
+   c3 = "\001\177." ;
 
  b3 = -128, 127, -1 ;
 
diff --git a/ncgen3/c0.cdl b/ncgen/c5.cdl
similarity index 85%
copy from ncgen3/c0.cdl
copy to ncgen/c5.cdl
index 5a1455c..e1544e7 100644
--- a/ncgen3/c0.cdl
+++ b/ncgen/c5.cdl
@@ -14,12 +14,12 @@ variables:
 		c:att.name.dots = 5 ;
                 c:att+name+plusses = 6 ;
 		c:att at name@ats = 7 ;
-	byte b ;
+	ubyte b ;
 		b:c = "" ;
-	short s ;
+	ushort s ;
 		s:b = 0b, 127b, -128b, -1b ;
 		s:s = -32768s, 0s, 32767s ;
-	int i ;
+	uint i ;
 		i:i = -2147483647, 0, 2147483647 ;
 		i:f = -1.e+36f, 0.f, 1.e+36f ;
 		i:d = -1.e+308, 0., 1.e+308 ;
@@ -28,70 +28,70 @@ variables:
 	double d ;
 		d:c = "abcd\tZ$&" ;
 	char cr(Dr) ;
-	byte br(Dr) ;
-	short sr(Dr) ;
-	int ir(Dr) ;
+	ubyte br(Dr) ;
+	ushort sr(Dr) ;
+	uint ir(Dr) ;
 	float fr(Dr) ;
 	double dr(Dr) ;
 	char c1(D1) ;
-	byte b1(D1) ;
-	short s1(D1) ;
-	int i1(D1) ;
+	ubyte b1(D1) ;
+	ushort s1(D1) ;
+	uint i1(D1) ;
 	float f1(D1) ;
 	double d1(D1) ;
 	char c2(D2) ;
-	byte b2(D2) ;
-	short s2(D2) ;
-	int i2(D2) ;
+	ubyte b2(D2) ;
+	ushort s2(D2) ;
+	uint i2(D2) ;
 	float f2(D2) ;
 	double d2(D2) ;
 	char c3(D3) ;
-	byte b3(D3) ;
-	short s3(D3) ;
-	int i3(D3) ;
+	ubyte b3(D3) ;
+	ushort s3(D3) ;
+	uint i3(D3) ;
 	float f3(D3) ;
 	double d3(D3) ;
 	char cr1(Dr, D1) ;
-	byte br2(Dr, D2) ;
-	short sr3(Dr, D3) ;
+	ubyte br2(Dr, D2) ;
+	ushort sr3(Dr, D3) ;
 	float f11(D1, D1) ;
 	double d12(D1, D2) ;
 	char c13(D1, D3) ;
-	short s21(D2, D1) ;
-	int i22(D2, D2) ;
+	ushort s21(D2, D1) ;
+	uint i22(D2, D2) ;
 	float f23(D2, D3) ;
 	char c31(D3, D1) ;
-	byte b32(D3, D2) ;
-	short s33(D3, D3) ;
-	short sr11(Dr, D1, D1) ;
-	int ir12(Dr, D1, D2) ;
+	ubyte b32(D3, D2) ;
+	ushort s33(D3, D3) ;
+	ushort sr11(Dr, D1, D1) ;
+	uint ir12(Dr, D1, D2) ;
 	float fr13(Dr, D1, D3) ;
 	char cr21(Dr, D2, D1) ;
-	byte br22(Dr, D2, D2) ;
-	short sr23(Dr, D2, D3) ;
+	ubyte br22(Dr, D2, D2) ;
+	ushort sr23(Dr, D2, D3) ;
 	float fr31(Dr, D3, D1) ;
 	double dr32(Dr, D3, D2) ;
 	char cr33(Dr, D3, D3) ;
 	char c111(D1, D1, D1) ;
-	byte b112(D1, D1, D2) ;
-	short s113(D1, D1, D3) ;
+	ubyte b112(D1, D1, D2) ;
+	ushort s113(D1, D1, D3) ;
 	float f121(D1, D2, D1) ;
 	double d122(D1, D2, D2) ;
 	char c123(D1, D2, D3) ;
-	short s131(D1, D3, D1) ;
-	int i132(D1, D3, D2) ;
+	ushort s131(D1, D3, D1) ;
+	uint i132(D1, D3, D2) ;
 	float f133(D1, D3, D3) ;
 	float f211(D2, D1, D1) ;
 	double d212(D2, D1, D2) ;
 	char c213(D2, D1, D3) ;
-	short s221(D2, D2, D1) ;
-	int i222(D2, D2, D2) ;
+	ushort s221(D2, D2, D1) ;
+	uint i222(D2, D2, D2) ;
 	float f223(D2, D2, D3) ;
 	char c231(D2, D3, D1) ;
-	byte b232(D2, D3, D2) ;
-	short s233(D2, D3, D3) ;
-	short s311(D3, D1, D1) ;
-	int i312(D3, D1, D2) ;
+	ubyte b232(D2, D3, D2) ;
+	ushort s233(D2, D3, D3) ;
+	ushort s311(D3, D1, D1) ;
+	uint i312(D3, D1, D2) ;
 	float f313(D3, D1, D3) ;
 	double var-name-dashes ;
 	double var.name.dots ;
@@ -159,7 +159,7 @@ data:
 
  d2 = -1e+308, 1e+308 ;
 
- c3 = "\001\177." ;
+ c3 = "\001\300." ;
 
  b3 = -128, 127, -1 ;
 
diff --git a/ncgen/escapes.c b/ncgen/escapes.c
index ed411f8..5f24fa9 100644
--- a/ncgen/escapes.c
+++ b/ncgen/escapes.c
@@ -641,7 +641,7 @@ unescapeoct(const char* s)
 
 /*
  * "Un-escapes" valid escape sequences in yystring (read by lex) into the
- * apropriate unescaped characters.  For example, the two character
+ * appropriate unescaped characters.  For example, the two character
  * sequence "\t" in yystring would be converted into a single tab character.
  * On return, termstring is nul terminated.
  * Watch out for embedded nuls and utf-8 characters.
diff --git a/ncgen/genc.c b/ncgen/genc.c
index 2378843..b421244 100644
--- a/ncgen/genc.c
+++ b/ncgen/genc.c
@@ -1140,14 +1140,13 @@ genc_writeattr(Generator* generator, Symbol* asym, Bytebuffer* code,
 	codedump(stmt);
 	break;
 
-#ifdef USE_NETCDF4
     /* !usingclassic only (except NC_STRING) */
     case NC_UBYTE:
     case NC_USHORT:
     case NC_UINT:
     case NC_INT64:
     case NC_UINT64:
-	if(usingclassic) {
+	if(usingclassic && k_flag <= 2) {
 	    verror("Non-classic type: %s",nctypename(basetype->typ.typecode));
 	    return;
 	}
@@ -1164,6 +1163,7 @@ genc_writeattr(Generator* generator, Symbol* asym, Bytebuffer* code,
 	codedump(stmt);
 	break;
 
+#ifdef USE_NETCDF4
     case NC_STRING:
 	if(usingclassic) {
 	    verror("Non-classic type: %s",nctypename(basetype->typ.typecode));
@@ -1185,7 +1185,7 @@ genc_writeattr(Generator* generator, Symbol* asym, Bytebuffer* code,
     default: /* User defined type */
 #ifndef USE_NETCDF4
         verror("Non-classic type: %s",nctypename(basetype->typ.typecode));
-#else /* USE_NETCDF4 */
+#else /* !USE_NETCDF4 */
 	if(usingclassic && !isclassicprim(basetype->typ.typecode)) {
             verror("Non-classic type: %s",nctypename(basetype->typ.typecode));
 	}
diff --git a/ncgen/genchar.c b/ncgen/genchar.c
index 3570a40..1768224 100644
--- a/ncgen/genchar.c
+++ b/ncgen/genchar.c
@@ -236,7 +236,7 @@ gen_leafchararray(Dimset* dimset, int dimindex, Datalist* data,
     of each string constant. Expected size is then the size
     of concat of the string constants after padding.
 
-    There is another special case used for back compatability with ncgen3.
+    There is another special case used for back compatibility with ncgen3.
     In the datalist, all sequences of character constants (i.e. 'X')
     are concatenated into a single string; the result, however is not
     concatenated with any trailing or leading string (with double quotes).
@@ -286,7 +286,7 @@ gen_leafchararray(Dimset* dimset, int dimindex, Datalist* data,
 	}
     }
 
-    /* Compute crossproduct upto (but not includng) the last dimension */
+    /* Compute crossproduct up to (but not including) the last dimension */
     xproduct = crossproduct(dimset,dimindex,rank-1);
 
     /* Start casing it out */
diff --git a/ncgen/generate.c b/ncgen/generate.c
index 9f4b747..b77c1bf 100644
--- a/ncgen/generate.c
+++ b/ncgen/generate.c
@@ -81,9 +81,11 @@ generate_vardata(Symbol* vsym, Generator* generator, Writer writer, Bytebuffer*
     int rank = dimset->ndims;
     Symbol* basetype = vsym->typ.basetype;
     Datalist* filler = getfiller(vsym);
+#if 0
     const size_t* start;
     const size_t* count;
     Odometer* odom;
+#endif
 
     if(vsym->data == NULL) return;
 
@@ -96,10 +98,12 @@ generate_vardata(Symbol* vsym, Generator* generator, Writer writer, Bytebuffer*
         generate_basetype(basetype,c0,code,filler,generator);
         writer(generator,vsym,code,0,NULL,NULL);
     } else {/*rank > 0*/
+#if 0
         /* First, create an odometer using all of the dimensions */
         odom = newodometer(dimset,NULL,NULL);
 	start = odometerstartvector(odom);
 	count = odometercountvector(odom);
+#endif
 	generate_array(vsym,code,filler,generator,writer);
     }
 }
@@ -149,7 +153,9 @@ generate_array(Symbol* vsym,
 	    /* Create an odometer to get the dimension info */
             odom = newodometer(dimset,NULL,NULL);
             writer(generator,vsym,code,odom->rank,odom->start,odom->count);
-//            writer(generator,vsym,code,odom->rank,0,bbLength(charbuf));
+#if 0
+            writer(generator,vsym,code,odom->rank,0,bbLength(charbuf));
+#endif
 	    bbFree(charbuf);
 	} else { /* typecode != NC_CHAR */
             /* Case: dim 1..rank-1 are not unlimited, dim 0 might be */
diff --git a/ncgen/generr.c b/ncgen/generr.c
index d9d8acc..b1ec973 100644
--- a/ncgen/generr.c
+++ b/ncgen/generr.c
@@ -110,6 +110,22 @@ getmarkcdf4(void)
     return markcdf4_msg;
 }
 
+/* Capture potential version errors */
+static char* markcdf5_msg = NULL;
+void
+markcdf5(const char* msg)
+{
+    cdf5_flag = 1;
+    if(markcdf5_msg == NULL)
+        markcdf5_msg = (char*)msg;
+}
+
+char*
+getmarkcdf5(void)
+{
+    return markcdf5_msg;
+}
+
 /**************************************************/
 /* Provide a version of snprintf that panics if*/
 /* the buffer is overrun*/
diff --git a/ncgen/genlib.h b/ncgen/genlib.h
index 05f9a30..2c6c87e 100644
--- a/ncgen/genlib.h
+++ b/ncgen/genlib.h
@@ -39,10 +39,12 @@ extern void	verror ( const char *fmt, ... )
 #endif
 ;
 
-
 extern void markcdf4(const char *msg);
 extern char* getmarkcdf4(void);
 
+extern void markcdf5(const char *msg);
+extern char* getmarkcdf4(void);
+
 
 /*
 All external procedures in ncgen.h have been moved to this file.
@@ -156,11 +158,14 @@ extern void jflush(void);
 
 
 /* from: main.c */
+extern int k_flag;    /* -k value from command line*/
 extern int format_flag;   /* _Format attribute value (same range as -k flag) */
 extern int format_attribute; /* 1 if format came from _FORMAT attribute */
 extern int enhanced_flag; /* 1 => netcdf-4 constructs appear in the parse */
+extern int cdf5_flag; /* 1 => cdf-5 unsigned types in the parse */
 extern int specials_flag; /* 1 => special attributes are present */
-extern int usingclassic;   /* 1 => k_flag == 1|2 */
+extern int usingclassic;   /* 1 => k_flag == 1|2|5 */
+extern int k_flag;
 
 /* Global data */
 
diff --git a/ncgen/main.c b/ncgen/main.c
index d0b8d4d..8181b61 100644
--- a/ncgen/main.c
+++ b/ncgen/main.c
@@ -40,7 +40,8 @@ int header_only;
 int k_flag;    /* > 0  => -k was specified on command line*/
 int format_flag;   /* _Format attribute value (same range as -k flag) */
 int format_attribute; /* 1=>format came from format attribute */
-int enhanced_flag; /* 1 => netcdf-4 constructs appear in the parse */
+int enhanced_flag; /* 1 => netcdf-4 */
+int cdf5_flag; /* 1 => cdf5 | maybe netcdf-4 */
 int specials_flag; /* 1=> special attributes are present */
 int usingclassic;
 int cmode_modifier;
@@ -71,10 +72,10 @@ struct Kvalues legalkinds[NKVALUES] = {
     {"1", NC_FORMAT_CLASSIC},	/* deprecated, use "-3" or "-k nc3" instead */
 
     /* NetCDF-3 64-bit offset format */
-    {"64-bit offset", NC_FORMAT_64BIT}, /* canonical format name */
-    {"nc6", NC_FORMAT_64BIT},		/* short format name */
-    {"2", NC_FORMAT_64BIT},     /* deprecated, use "-6" or "-k nc6" instead */
-    {"64-bit-offset", NC_FORMAT_64BIT}, /* aliases */
+    {"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}, /* aliases */
 
     /* NetCDF-4 HDF5-based format */
     {"netCDF-4", NC_FORMAT_NETCDF4}, /* canonical format name */
@@ -96,6 +97,14 @@ struct Kvalues legalkinds[NKVALUES] = {
     {"hdf5-nc3", NC_FORMAT_NETCDF4_CLASSIC},
     {"enhanced-nc3", NC_FORMAT_NETCDF4_CLASSIC},
 
+    /* CDF-5 format */
+    {"5", NC_FORMAT_64BIT_DATA},
+    {"64-bit-data", NC_FORMAT_64BIT_DATA},
+    {"64-bit data", NC_FORMAT_64BIT_DATA},
+    {"nc5", NC_FORMAT_64BIT_DATA},
+    {"cdf5", NC_FORMAT_64BIT_DATA},
+    {"cdf-5", NC_FORMAT_64BIT_DATA},
+
     /* null terminate*/
     {NULL,0}
 };
@@ -170,7 +179,26 @@ ubasename(char *logident)
 void
 usage(void)
 {
-    derror("Usage: %s [ -b ] [ -c ] [ -f ] [ -k kind ] [ -x ] [-S struct-format] [-M <name> [ -o outfile]  [ file ... ]",
+    derror("Usage: %s"
+" [-1]"
+" [-3]"
+" [-4]"
+" [-5]"
+" [-6]"
+" [-7]"
+" [-b]"
+" [-B buffersize]"
+" [-d]"
+" [-D debuglevel]"
+" [-h]"
+" [-k kind ]"
+" [-l language=b|c|f77|java]"
+" [-M <name>]"
+" [-n]"
+" [-o outfile]"
+" [-P]"
+" [-x]"
+" [file ... ]",
 	   progname);
     derror("netcdf library version %s", nc_inq_libvers());
 }
@@ -206,6 +234,7 @@ main(
     format_flag = 0;
     format_attribute = 0;
     enhanced_flag = 0;
+    cdf5_flag = 0;
     specials_flag = 0;
 
     diskless = 0;
@@ -215,7 +244,7 @@ main(
     (void) par_io_init(32, 32);
 #endif
 
-    while ((c = getopt(argc, argv, "hbcfk:3467l:no:v:xdM:D:B:P")) != EOF)
+    while ((c = getopt(argc, argv, "134567bB:cdD:fhk:l:M:no:Pv:x")) != EOF)
       switch(c) {
 	case 'd':
 	  debug = 1;
@@ -249,33 +278,29 @@ main(
 	case 'h':
 	  header_only = 1;
 	  break;
-    case 'l': /* specify language, instead of using -c or -f or -b */
-
-      {
-		if(l_flag != 0) {
-          fprintf(stderr,"Please specify only one language\n");
-          return 1;
-		}
-        if(!optarg) {
-          derror("%s: output language is null",
-                 progname);
-          return(1);
-        }
-        lang_name = (char*) emalloc(strlen(optarg)+1);
-		(void)strcpy(lang_name, optarg);
-		for(langs=legallanguages;langs->name != NULL;langs++) {
-          if(strcmp(lang_name,langs->name)==0) {
-			l_flag = langs->flag;
-            break;
-          }
-		}
-		if(langs->name == NULL) {
-          derror("%s: output language %s not implemented",
-                 progname, lang_name);
-          return(1);
-		}
-      }
-	  break;
+        case 'l': /* specify language, instead of using -c or -f or -b */
+	{
+	    if(l_flag != 0) {
+              fprintf(stderr,"Please specify only one language\n");
+              return 1;
+	    }
+            if(!optarg) {
+              derror("%s: output language is null", progname);
+              return(1);
+            }
+            lang_name = (char*) emalloc(strlen(optarg)+1);
+	    (void)strcpy(lang_name, optarg);
+	    for(langs=legallanguages;langs->name != NULL;langs++) {
+              if(strcmp(lang_name,langs->name)==0) {
+	  	l_flag = langs->flag;
+                break;
+              }
+	    }
+	    if(langs->name == NULL) {
+              derror("%s: output language %s not implemented",progname, lang_name);
+              return(1);
+	    }
+	}; break;
 	case 'n':		/* old version of -b, uses ".cdf" extension */
 	  if(l_flag != 0) {
 	    fprintf(stderr,"Please specify only one language\n");
@@ -297,13 +322,16 @@ main(
 		     Format names:
 		       "classic" or "nc3"
 		       "64-bit offset" or "nc6"
+		       "64-bit data" or "nc5" or "cdf-5"
 		       "netCDF-4" or "nc4"
 		       "netCDF-4 classic model" or "nc7"
+		       "netCDF-5" or "nc5" or "cdf5"
 		     Format version numbers (deprecated):
 		       1 (=> classic)
 		       2 (=> 64-bit offset)
 		       3 (=> netCDF-4)
 		       4 (=> netCDF-4 classic model)
+                       5 (=> classic 64 bit data aka CDF-5)
 		   */
 	    {
 		struct Kvalues* kvalue;
@@ -331,11 +359,14 @@ main(
 	    k_flag = NC_FORMAT_CLASSIC;
 	    break;
 	case '6':		/* output format is 64-bit-offset (netCDF-3 version 2) */
-	    k_flag = NC_FORMAT_64BIT;
+	    k_flag = NC_FORMAT_64BIT_OFFSET;
 	    break;
 	case '4':		/* output format is netCDF-4 (variant of HDF5) */
 	    k_flag = NC_FORMAT_NETCDF4;
 	    break;
+	case '5':		/* output format is CDF5 */
+	    k_flag = NC_FORMAT_CDF5;
+	    break;
 	case '7':		/* output format is netCDF-4 (restricted to classic model)*/
 	    k_flag = NC_FORMAT_NETCDF4_CLASSIC;
 	    break;
@@ -474,14 +505,18 @@ main(
     }
 
     if(k_flag == 0)
-	k_flag = format_flag;
+      k_flag = format_flag;
 
+    if(cdf5_flag && !enhanced_flag && k_flag == 0)
+      k_flag = 5;
     if(enhanced_flag && k_flag == 0)
-	k_flag = 3;
+      k_flag = 3;
 
     if(enhanced_flag && k_flag != 3) {
-	derror("-k or _Format conflicts with enhanced CDL input");
-	return 0;
+      if(enhanced_flag && k_flag != 3 && k_flag != 5) {
+        derror("-k or _Format conflicts with enhanced CDL input");
+        return 0;
+      }
     }
 
     if(specials_flag > 0 && k_flag == 0)
@@ -494,7 +529,7 @@ main(
     if(k_flag == 0)
 	k_flag = 1;
 
-    usingclassic = (k_flag <= 2 || k_flag == 4)?1:0;
+    usingclassic = (k_flag <= 2 || k_flag == 4 || k_flag == 5)?1:0;
 
     /* compute cmode_modifier */
     switch (k_flag) {
@@ -502,6 +537,7 @@ main(
     case 2: cmode_modifier = NC_64BIT_OFFSET; break;
     case 3: cmode_modifier = NC_NETCDF4; break;
     case 4: cmode_modifier = NC_NETCDF4 | NC_CLASSIC_MODEL; break;
+    case 5: cmode_modifier = NC_CDF5; break;
     default: ASSERT(0); /* cannot happen */
     }
 
diff --git a/ncgen/ncgen.1 b/ncgen/ncgen.1
index 11faa3d..5015d07 100644
--- a/ncgen/ncgen.1
+++ b/ncgen/ncgen.1
@@ -72,12 +72,13 @@ seekable.
 .IP "\fB-\fIformat_code\fP"
 The \-k flag specifies the format of the file to be created and, by inference,
 the data model accepted by ncgen (i.e. netcdf-3 (classic) versus
-netcdf-4). As a shortcut, a numeric \fIformat_code\fP may be specified instead.
+netcdf-4 vs netcdf-5). As a shortcut, a numeric \fIformat_code\fP may be specified instead.
 The possible \fIformat_name\fP values for the \-k option are:
 .RS
 .RS
 .IP "'classic' or 'nc3' => netCDF classic format"
 .IP "'64-bit offset' or 'nc6' => netCDF 64-bit format"
+.IP "'64-bit data or 'nc5' => netCDF-5 (64-bit data) format"
 .IP "'netCDF-4' 0r 'nc4' => netCDF-4 format (enhanced data model)"
 .IP "'netCDF-4 classic model' or 'nc7' => netCDF-4 classic model format"
 .RE
@@ -86,6 +87,7 @@ Accepted \fIformat_number\fP arguments, just shortcuts for format_names, are:
 .RS
 .RS
 .IP "3 => netcdf classic format"
+.IP "5 => netcdf 5 format"
 .IP "6 => netCDF 64-bit format"
 .IP "4 => netCDF-4 format (enhanced data model)"
 .IP "7 => netCDF-4 classic model format"
@@ -127,11 +129,17 @@ only the classic model is supported.
 The choice of output format is determined by three flags.
 .IP "\fB-k flag.\fP"
 .IP "\fB_Format attribute (see below).\fP"
-.IP "\fBOccurrence of netcdf-4 constructs in the input CDL.\fP"
+.IP "\fBOccurrence of CDF-5 (64-bit data) or
+netcdf-4 constructs in the input CDL.\fP"
 The term "netCDF-4 constructs" means
 constructs from the enhanced data model,
 not just special performance-related attributes such as
  _ChunkSizes, _DeflateLevel, _Endianness, etc.
+The term "CDF-5 constructs" means
+extended unsigned integer types allowed in the 64-bit data model.
+.LP
+Note that there is an ambiguity between the netCDF-4 case
+and the CDF-5 case is only an unsigned type is seen in the input.
 .LP
 The rules are as follows, in order of application.
 .IP "\fB1.\fP"
@@ -152,7 +160,9 @@ ncgen will output a file in the requested form,
 else an error will be reported.
 .IP "\fB4.\fP"
 If the \-k flag is undefined,
-and if there are netCDF-4 constructs in the CDL,
+and if there are CDF-5 constructs, only, in the CDL,
+a \-k flag value of 5 (64-bit data model) will be used.
+If there are true netCDF-4 constructs in the CDL,
 a \-k flag value of 3 (enhanced model) will be used.
 .IP "\fB5.\fP"
 If special performance-related attributes are specified in the CDL,
@@ -731,7 +741,7 @@ The special attributes currently supported are as follows:
 .LP
 `_Format' is a global attribute specifying the netCDF format
 variant. Its value must be a single string
-matching one of `classic', `64-bit offset', `netCDF-4', or
+matching one of `classic', `64-bit offset', `64-bit data', `netCDF-4', or
 `netCDF-4 classic model'.
 .LP
 The rest of the special attributes are all variable attributes.
diff --git a/ncgen/ncgen.h b/ncgen/ncgen.h
index 0b36e7f..5566e98 100644
--- a/ncgen/ncgen.h
+++ b/ncgen/ncgen.h
@@ -103,7 +103,7 @@ char* name;
 int k_flag;
 };
 
-#define NKVALUES 24
+#define NKVALUES 100
 extern struct Kvalues legalkinds[NKVALUES];
 
 /* Note: some non-var specials (i.e. _Format) are not included in this struct*/
diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l
index 10c0847..31a4dc0 100644
--- a/ncgen/ncgen.l
+++ b/ncgen/ncgen.l
@@ -40,6 +40,43 @@
 #define XDR_INT64_MIN  (-9223372036854775807LL-1)
 #define XDR_INT64_MAX  (9223372036854775807LL)
 
+#undef DEBUG
+#ifdef DEBUG
+static int MIN_BYTE = NC_MIN_BYTE;
+static int MIN_SHORT = NC_MIN_SHORT;
+static int MIN_INT = NC_MIN_INT;
+static int MAX_BYTE = NC_MAX_BYTE;
+static int MAX_SHORT = NC_MAX_SHORT;
+static int MAX_INT = NC_MAX_INT;
+static int MAX_UBYTE = NC_MAX_UBYTE;
+static int MAX_USHORT = NC_MAX_USHORT;
+static unsigned int MAX_UINT = NC_MAX_UINT;
+
+#undef NC_MIN_BYTE
+#undef NC_MIN_SHORT
+#undef NC_MIN_INT
+#undef NC_MAX_BYTE
+#undef NC_MAX_SHORT
+#undef NC_MAX_INT
+#undef NC_MAX_UBYTE
+#undef NC_MAX_USHORT
+#undef NC_MAX_UINT
+
+#define NC_MIN_BYTE MIN_BYTE
+#define NC_MIN_SHORT MIN_SHORT
+#define NC_MIN_INT MIN_INT
+#define NC_MAX_BYTE MAX_BYTE
+#define NC_MAX_SHORT MAX_SHORT
+#define NC_MAX_INT MAX_INT
+#define NC_MAX_UBYTE MAX_UBYTE
+#define NC_MAX_USHORT MAX_USHORT
+#define NC_MAX_UINT MAX_UINT
+#endif
+
+#define TAG "BbSsLl"
+
+#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
+
 /*Mnemonics*/
 #define ISIDENT 1
 
@@ -49,7 +86,7 @@ int lineno;              /* line number for error messages */
 Bytebuffer* lextext;           /* name or string with escapes removed */
 
 #define YY_BREAK                /* defining as nothing eliminates unreachable
-				   statement warnings from flex output, 
+				   statement warnings from flex output,
                                    but make sure every action ends with
                                    "return" or "break"! */
 
@@ -68,7 +105,10 @@ unsigned char ubyte_val;       /* last byte value read */
 
 static Symbol* makepath(char* text);
 static int lexdebug(int);
-static int parseLL(char* text);
+static unsigned long long parseULL(char* text, int*);
+static nc_type downconvert(unsigned long long uint64, int, int, int);
+static int tagmatch(nc_type nct, int tag, int hasU);
+static int nct2lexeme(nc_type nct);
 
 static struct Specialtoken {
     char* name;
@@ -156,10 +196,8 @@ OPAQUESTRING	(0[xX][0-9A-Fa-f][0-9A-Fa-f]*)
 
 PATH    ([/]|([/]{ID})([/]{ID})*)
 
-SIMPLENUMBER [+-]?[0-9][0-9]*
 XUNUMBER     {OPAQUESTRING}[SsLl]
-UNUMBER      [0-9][0-9]*[Uu][BbSsLl]?
-NUMBER       [+-]?[0-9][0-9]*[BbSsLl]
+NUMBER       [+-]?[0-9][0-9]*[Uu]?[BbSsLl]?
 DBLNUMBER    [+-]?[0-9]*\.[0-9]*{exp}?[LlDd]?|[+-]?[0-9]*{exp}[LlDd]?
 FLTNUMBER    [+-]?[0-9]*\.[0-9]*{exp}?[Ff]|[+-]?[0-9]*{exp}[Ff]
 
@@ -168,11 +206,11 @@ SPECIAL "_FillValue"|"_Format"|"_Storage"|"_ChunkSizes"|"_Fletcher32"|"_DeflateL
 USASCII   [\x01-\x7F]
 
 %%
-[ \r\t\f]+	{ /* whitespace */ 
-		  break;        
+[ \r\t\f]+	{ /* whitespace */
+		  break;
 		}
 
-\/\/.*		        { /* comment */ 
+\/\/.*		        { /* comment */
                           break;
                         }
 
@@ -325,158 +363,69 @@ NIL|nil|Nil {
 		    return lexdebug(IDENT);
 		}
 
-{SIMPLENUMBER}	{
-		    /* We need to try to see what size of integer ((u)int). */
-		    /* Technically, the user should specify, but... */
-		    /* If out of any integer range, then complain */
-		    switch (parseLL(yytext)) {
-		    case 0:
-			return lexdebug(INT64_CONST); /* meaningless */
-		    case -1:
-#ifdef USE_NETCDF4
-		        if(int64_val >= NC_MIN_INT) {
-			    int32_val = (int)int64_val;
-		            return lexdebug(INT_CONST);
-			} else
-		            return lexdebug(INT64_CONST);
-#else
-			/* Convert to int32, unless overflow then complain  */
-			if(int64_val >=NC_MIN_INT) {
-			    int32_val = (int)int64_val;
-			} else {
-			   sprintf(errstr,"32 bit integer constant out of range: %s",(char*)yytext);
-			   yyerror(errstr);
-			}
-		        return lexdebug(INT_CONST);		    
-#endif
-		    case 1:
-#ifdef USE_NETCDF4
- 		        if(uint64_val <= NC_MAX_INT) {
-			    int32_val = (int)uint64_val;
-		            return lexdebug(INT_CONST);
- 		        } else if(uint64_val <= NC_MAX_UINT) {
-			    uint32_val = (unsigned int)uint64_val;
-		            return lexdebug(UINT_CONST);
- 		        } else if(uint64_val <= NC_MAX_INT64) {
-			    int64_val = (long long)uint64_val;
-		            return lexdebug(INT64_CONST);
-			} else
-		            return lexdebug(UINT64_CONST);
-#else
-			/* Convert to int32 but complain if overflow */
-			if(uint64_val > NC_MAX_INT) {
-			    sprintf(errstr,"32 bit integer constant out of range: %s",(char*)yytext);
-			    yyerror(errstr);
+{NUMBER}    {
+/*
+We need to try to see what size of integer ((u)int).
+Technically, the user should specify, but...
+If out of any integer range, then complain
+*/
+		    int slen = strlen(ncgtext);
+		    int tag = ncgtext[slen-1];
+		    int hasU = 0;
+		    int signchar = 0;
+		    int isneg = 0;
+		    int c = ncgtext[0];
+		    int fail = 0;
+		    nc_type nct = 0;
+		    char* pos = NULL;
+
+		    if(!tstdecimal(c)) {
+			pos = ncgtext+1;
+			isneg = (c == '-');
+		    } else
+		        pos = ncgtext;
+		    if(tag != '\0' && strchr(TAG,tag) != NULL) {
+			if(slen > 2) {
+			    c = ncgtext[slen-2];
+			    hasU = (c == 'U' || c == 'u') ? 1 : 0;
 			}
-			int32_val = (int)uint64_val;
-			return lexdebug(INT_CONST);
-#endif
-                     default:
-                         yyerror("Unknown integer size");
+		    } else
+			tag = 0;
+		    if(isneg && hasU) {
+			sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
+			yyerror(errstr);
+			goto done;
 		    }
-		}
-
-{NUMBER}    { /* The number may be signed or unsigned (signed has priority) */
-		int slen = strlen(yytext);
-		int tag = yytext[slen-1];
-		int token = 0;
-		switch (tag) {
-		case 'B': case 'b':
-		    if (sscanf((char*)yytext, "%d", &int32_val) != 1) {
-		        sprintf(errstr,"bad byte constant: %s",(char*)yytext);
-		        yyerror(errstr);
-		    } else if(int32_val >= NC_MIN_BYTE && int32_val <= NC_MAX_BYTE) {
-		        byte_val = (signed char)int32_val;
-		        token = BYTE_CONST;
-		    } else if(int32_val >= 0 && int32_val <= NC_MAX_UBYTE) {
-		        ubyte_val = (unsigned char)int32_val;
-		        token = UBYTE_CONST;
-		    } else {
-		        sprintf(errstr,"bad byte constant: %s",(char*)yytext);
-		        yyerror(errstr);
+		    uint64_val = parseULL(pos,&fail);
+		    if(fail) {
+			sprintf(errstr,"integer constant out of range: %s",ncgtext);
+			yyerror(errstr);
+			goto done;
 		    }
-		    break;
-		case 'S': case 's':
-		    if (sscanf((char*)yytext, "%d", &int32_val) != 1) {
-		        sprintf(errstr,"bad short constant: %s",(char*)yytext);
-		        yyerror(errstr);
-		    } else if(int32_val >= NC_MIN_SHORT && int32_val <= NC_MAX_SHORT) {
-		        int16_val = (signed short)int32_val;
-		        token = SHORT_CONST;
-		    } else if(int32_val >= 0 && int32_val <= NC_MAX_USHORT) {
-		        uint16_val = (unsigned short)int32_val;
-		        token = USHORT_CONST;
-		    } else {
-		        sprintf(errstr,"bad short constant: %s",(char*)yytext);
-		        yyerror(errstr);
+		    /* Down convert to smallest possible range */
+		    nct = downconvert(uint64_val,isneg,tag,hasU);
+		    switch (k_flag) {
+		    case NC_FORMAT_64BIT_DATA:
+		    case NC_FORMAT_NETCDF4:
+			    return lexdebug(nct2lexeme(nct));
+		    case NC_FORMAT_CLASSIC:
+		    case NC_FORMAT_64BIT_OFFSET:
+		    case NC_FORMAT_NETCDF4_CLASSIC:
+			    if(nct > NC_INT) {
+				sprintf(errstr,"Illegal integer constant for classic format: %s",ncgtext);
+				yyerror(errstr);
+				goto done;
+			    }
 		    }
-		    break;
-		case 'L': case 'l':
-		    switch(parseLL(yytext)) {
-		    case 0:
-		        sprintf(errstr,"bad int64 constant: %s",(char*)yytext);
-		        yyerror(errstr);
-			break;
-		    case -1: token = INT64_CONST; break;
-		    case 1:
-			/* if value is too big, complain */
-			/* cannot actually test this.
-		        if(uint64_val > NC_MAX_INT64) {
-			   sprintf(errstr,"64 bit integer constant out of range: %s",(char*)yytext);
-			   yyerror(errstr);
-			}
-                        */
-		        int64_val = (long long)(uint64_val & 0x7fffffffffffffffLL);
-			token = INT64_CONST;
-			break;
+		    if(!tagmatch(nct,tag,hasU))  {
+			sprintf(errstr,"Integer out of range for tag: %s",ncgtext);
+			yyerror(errstr);
+			goto done;
 		    }
-		    break;
-		default:/*(optionally)signed string of digits; treat like int*/
-		    sprintf(errstr,"bad numeric constant: %s",(char*)yytext);
-		    yyerror(errstr);
-		}
-		return lexdebug(token);
+		    return lexdebug(nct2lexeme(nct));
+done: return 0;
 	    }
 
-{UNUMBER}    {
-		int slen = strlen(yytext);
-		int tag = yytext[slen-1];
-		int token = 0;
-		switch (tag) {
-		case 'B': case 'b':
-		    if (sscanf((char*)yytext, "%u", &uint32_val) != 1
-		        || uint32_val > NC_MAX_UBYTE) {
-		        sprintf(errstr,"bad unsigned byte constant: %s",(char*)yytext);
-		        yyerror(errstr);
-		    }
-		    ubyte_val = (unsigned char)uint32_val;
-		    token = UBYTE_CONST;
-		    break;
-		case 'S': case 's':
-		    if (sscanf((char*)yytext, "%u", &uint32_val) != 1
-		        || uint32_val > NC_MAX_USHORT) {
-		        sprintf(errstr,"bad unsigned short constant: %s",(char*)yytext);
-		        yyerror(errstr);
-		    }
-		    uint16_val = (unsigned short)uint32_val;
-		    token = USHORT_CONST;
-		    break;
-		case 'L': case 'l':
-		    if (sscanf((char*)yytext, "%llu", &uint64_val) != 1) {
-		        sprintf(errstr,"bad unsigned int64 constant: %s",(char*)yytext);
-		        yyerror(errstr);
-		    }
-		    token = UINT64_CONST;
-		    break;
-		default: /* string of digits; treat like int */
-		    if (sscanf((char*)yytext, "%u", &uint32_val) != 1) {
-		        sprintf(errstr,"bad unsigned int constant: %s",(char*)yytext);
-		        yyerror(errstr);
-		    }
-		    token = UINT_CONST;
-		}
-		return lexdebug(token);
-	    }
 {XUNUMBER}    {
 		int c;
 		int token = 0;
@@ -534,7 +483,7 @@ NIL|nil|Nil {
 		if(oct < 0) {
 		    sprintf(errstr,"bad octal character constant: %s",(char*)yytext);
 		    yyerror(errstr);
-		}		    		    
+		}
 	        byte_val = (unsigned int)oct;
 		return lexdebug(BYTE_CONST);
                 }
@@ -543,7 +492,7 @@ NIL|nil|Nil {
 		if(byte_val < 0) {
 		    sprintf(errstr,"bad hex character constant: %s",(char*)yytext);
 		    yyerror(errstr);
-		}		    		    
+		}
 		byte_val = (unsigned int)hex;
 		return lexdebug(BYTE_CONST);
                 }
@@ -664,7 +613,7 @@ makepath(char* text0)
 		    refsym->subnodes = listnew();
 		}
 		container = refsym;
-	        ident=p+1; p=ident;		
+	        ident=p+1; p=ident;
 	        break;
 	    }
 	} while(c != '\0');
@@ -674,41 +623,189 @@ makepath(char* text0)
     return refsym;
 }
 
-
-static int
-parseLL(char* text)
+/*
+Parse a simple string of digitis into an unsigned long long
+Return the value.
+*/
+static unsigned long long
+parseULL(char* text, int* failp)
 {
     int result = 0;
-#if defined(HAVE_STRTOLL) && defined(HAVE_STRTOULL)
     extern int errno;
     char* endptr;
+    unsigned long long uint64 = 0;
+
     errno = 0; endptr = NULL;
-    if(text[0] == '-') {
-        int64_val = strtoll(text,&endptr,10);
-	result = -1; /* negative int64_val */	
-    } else {
-        uint64_val = strtoull(text,&endptr,10);
-	result = 1; /* positive uint64_val */	
+    assert(tstdecimal(text[0]));
+#ifdef HAVE_STRTOULL
+    uint64 = strtoull(text,&endptr,10);
+    if(errno == ERANGE) {
+	if(failp) *failp = ERANGE;
+	return 0;
     }
-    if(result == 0) {
-	sprintf(errstr,"Unparseable 64 bit integer constant: %s",(char*)text);
-	yyerror(errstr);
-    } else if(errno == ERANGE) {
-	sprintf(errstr,"64 bit integer constant out of range: %s",(char*)text);
-	yyerror(errstr);
-	result = 0; /* out of range */
-    }			
 #else /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/
-    if(text[0] == '-') {
-        sscanf((char*)text, "%lld", &int64_val);
-	result = -1; /* negative int64_val */	
-    } else {
-	sscanf((char*)text, "%llu", &uint64_val);
-	result = 1; /* positive uint64_val */	
-    }
+    sscanf((char*)text, "%llu", &uint64);
     /* Have no useful way to detect out of range */
 #endif /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/
-    return result;
+    return uint64;
+}
+
+
+/**
+Given the raw bits, the sign char, the tag, and hasU
+fill in the appropriate *_val field
+and return the type
+*/
+static nc_type
+downconvert(unsigned long long uint64, int isneg, int tag, int hasU)
+{
+    nc_type nct = NC_NAT;
+    int bit64 = (uint64 >> 63);
+    int allones = (uint64 == 0xffffffffffffffffUL);
+    long long int64 = *((long long*)&uint64);
+
+    if(isneg && hasU)
+	return NC_NAT;
+    /* Special cases: all (u)int64 values */
+    if(allones && (hasU || !isneg)) /* bare max uint64 value */
+	return NC_UINT64;
+    if((int64 < NC_MIN_INT) || (int64 > NC_MAX_INT)) {
+	if(isneg && !hasU) {
+	    int64_val = - int64;
+	    return NC_INT64;
+	}
+	if(!isneg && hasU) {
+	    uint64_val = uint64;
+	    return NC_UINT64;
+	}
+	/* Bare big integer, assume int64 unless sign bit set */
+	if(!isneg && !hasU && bit64) {
+	    uint64_val = uint64;
+	    return NC_UINT64;
+	} else if(!bit64) {
+	    int64_val = int64;
+	    return NC_INT64;
+	}
+        /*assert(!isneg)*/
+        uint64_val = uint64;
+	return NC_UINT64;
+    }
+
+    if(isneg) int64 = -int64;
+
+    /* special case:
+       If there is no tag and the size is ok,
+       then always return NC_INT or NC_UINT.
+    */
+    if(!tag) {
+	if(!hasU) {
+	    if((int64 >= NC_MIN_INT) && (int64 <= NC_MAX_INT)) {
+		int32_val = (int)int64;
+	        return NC_INT;
+	    }
+	}
+	if(uint64 <= NC_MAX_UINT) {
+	    uint32_val = (unsigned int)uint64;
+	    return NC_INT;
+	}
+    }
+    /* assert (tag != 0) */
+
+    /* Pick smallest enclosing type;
+       for historical reasons (ncgen3), technically out of range
+       values are allowed and conversion is attempted;
+	e.g. 65535s; is legal and is return as an unsigned short.
+    */
+    if(hasU) {
+        switch (tag) {
+        case 'B': case 'b':
+	    if((int64 >= 0) && (int64 <= NC_MAX_UBYTE)) {
+	        nct = NC_UBYTE;
+	        ubyte_val = (unsigned char)int64;
+	    }; break;
+        case 'S': case 's':
+	    if((int64 >= 0) && (int64 <= NC_MAX_USHORT)) {
+	        nct = NC_USHORT;
+	        uint16_val = (unsigned short)int64;
+	    } break;
+        case 'L': case 'l':
+            if((int64 >= 0) && (int64 <= NC_MAX_UINT64)) {
+	        nct = NC_UINT64;
+	        uint64_val = uint64;
+	    } break;
+	default:
+	    return NC_NAT;
+	}
+    } else { /* !hasU */
+        switch (tag) {
+        case 'B': case 'b':
+            if((int64 >= NC_MIN_BYTE) && (int64 <= NC_MAX_BYTE)) {
+	        nct = NC_BYTE;
+	        byte_val = (signed char)int64;
+	    } else {/* force to unsigned value */
+		uint64_val = uint64 & 0xff;
+		nct = NC_UBYTE;
+	    }
+	    break;
+        case 'S': case 's':
+	    if((int64 >= NC_MIN_SHORT) && (int64 <= NC_MAX_SHORT)) {
+	        nct = NC_SHORT;
+	        int16_val = (signed short)int64;
+	    } else {/* force to unsigned value */
+		uint64_val = uint64 & 0xffff;
+		nct = NC_USHORT;
+	    }
+	    break;
+        case 'L': case 'l':
+            if((uint64 <= NC_MAX_INT64)) {
+	        nct = NC_INT64;
+	        int64_val = int64;
+	    } else {/* force to unsigned value */
+		uint64_val = uint64;
+		nct = NC_UINT64;
+	    }
+	    break;
+	default:
+	    return NC_NAT;
+	}
+    }
+    return nct;
+}
+
+static int
+nct2lexeme(nc_type nct)
+{
+    switch(nct) {
+    case NC_BYTE: return BYTE_CONST;
+    case NC_CHAR: return CHAR_CONST;
+    case NC_SHORT: return SHORT_CONST;
+    case NC_INT: return INT_CONST;
+    case NC_UBYTE: return UBYTE_CONST;
+    case NC_USHORT: return USHORT_CONST;
+    case NC_UINT: return UINT_CONST;
+    case NC_INT64: return INT64_CONST;
+    case NC_UINT64: return UINT64_CONST;
+    }
+    return 0;
 }
 
 
+static int
+tagmatch(nc_type nct, int tag, int hasU)
+{
+    if(hasU) switch(nct) {
+        case NC_UBYTE: return (tag == 0 || tag == 'B' || tag == 'b');
+        case NC_USHORT: return (tag == 0 || tag == 'S' || tag == 's');
+        case NC_UINT: return (tag == 0);
+        case NC_UINT64: return (tag == 0 || tag == 'L' || tag == 'l');
+	default: return 0;
+    } else switch(nct) {
+	case NC_BYTE: return (tag == 0 || tag == 'B' || tag == 'b');
+	case NC_SHORT: return (tag == 0 || tag == 'S' || tag == 's');
+	case NC_INT: return (tag == 0);
+	case NC_INT64: return (tag == 0 || tag == 'L' || tag == 'l');
+	default: return 0;
+    }
+    return 0;
+}
+
diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y
index 1a0293d..2dd12f7 100644
--- a/ncgen/ncgen.y
+++ b/ncgen/ncgen.y
@@ -1278,7 +1278,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
             }
             attr = makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
         } else switch (tag) {
-	    // These will be output as attributes later
+	    /* These will be output as attributes later */
             case _STORAGE_FLAG:
               if(!sdata)
                 derror("_Storage: illegal NULL value");
@@ -1394,23 +1394,21 @@ datalistextend(Datalist* dl, NCConstant* con)
 }
 
 static void
-vercheck(int ncid)
+vercheck(int tid)
 {
-    char* tmsg = NULL;
-    switch (ncid) {
-    case NC_UBYTE: tmsg = "netCDF4 type: UBYTE"; break;
-    case NC_USHORT: tmsg = "netCDF4 type: USHORT"; break;
-    case NC_UINT: tmsg = "netCDF4 type: UINT"; break;
-    case NC_INT64: tmsg = "netCDF4 type: INT64"; break;
-    case NC_UINT64: tmsg = "netCDF4 type: UINT64"; break;
-    case NC_STRING: tmsg = "netCDF4 type: STRING"; break;
-    case NC_VLEN: tmsg = "netCDF4 type: VLEN"; break;
-    case NC_OPAQUE: tmsg = "netCDF4 type: OPAQUE"; break;
-    case NC_ENUM: tmsg = "netCDF4 type: ENUM"; break;
-    case NC_COMPOUND: tmsg = "netCDF4 type: COMPOUND"; break;
+    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_STRING: markcdf4("netCDF4 type: STRING"); break;
+    case NC_VLEN: markcdf4("netCDF4 type: VLEN"); break;
+    case NC_OPAQUE: markcdf4("netCDF4 type: OPAQUE"); break;
+    case NC_ENUM: markcdf4("netCDF4 type: ENUM"); break;
+    case NC_COMPOUND: markcdf4("netCDF4 type: COMPOUND"); break;
     default: break;
     }
-    if(tmsg != NULL) markcdf4(tmsg);
 }
 
 /*
diff --git a/ncgen/ncgentab.c b/ncgen/ncgentab.c
index 6622e18..96915dd 100644
--- a/ncgen/ncgentab.c
+++ b/ncgen/ncgentab.c
@@ -3606,7 +3606,7 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
             }
             attr = makeattribute(install("_FillValue"),vsym,tsym,list,ATTRVAR);
         } else switch (tag) {
-	    // These will be output as attributes later
+	    /* These will be output as attributes later */
             case _STORAGE_FLAG:
               if(!sdata)
                 derror("_Storage: illegal NULL value");
@@ -3722,23 +3722,21 @@ datalistextend(Datalist* dl, NCConstant* con)
 }
 
 static void
-vercheck(int ncid)
+vercheck(int tid)
 {
-    char* tmsg = NULL;
-    switch (ncid) {
-    case NC_UBYTE: tmsg = "netCDF4 type: UBYTE"; break;
-    case NC_USHORT: tmsg = "netCDF4 type: USHORT"; break;
-    case NC_UINT: tmsg = "netCDF4 type: UINT"; break;
-    case NC_INT64: tmsg = "netCDF4 type: INT64"; break;
-    case NC_UINT64: tmsg = "netCDF4 type: UINT64"; break;
-    case NC_STRING: tmsg = "netCDF4 type: STRING"; break;
-    case NC_VLEN: tmsg = "netCDF4 type: VLEN"; break;
-    case NC_OPAQUE: tmsg = "netCDF4 type: OPAQUE"; break;
-    case NC_ENUM: tmsg = "netCDF4 type: ENUM"; break;
-    case NC_COMPOUND: tmsg = "netCDF4 type: COMPOUND"; break;
+    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_STRING: markcdf4("netCDF4 type: STRING"); break;
+    case NC_VLEN: markcdf4("netCDF4 type: VLEN"); break;
+    case NC_OPAQUE: markcdf4("netCDF4 type: OPAQUE"); break;
+    case NC_ENUM: markcdf4("netCDF4 type: ENUM"); break;
+    case NC_COMPOUND: markcdf4("netCDF4 type: COMPOUND"); break;
     default: break;
     }
-    if(tmsg != NULL) markcdf4(tmsg);
 }
 
 /*
diff --git a/ncgen/ncgenyy.c b/ncgen/ncgenyy.c
index 0fd102a..ee8c86f 100644
--- a/ncgen/ncgenyy.c
+++ b/ncgen/ncgenyy.c
@@ -378,8 +378,8 @@ static void yy_fatal_error (yyconst char msg[]  );
 	*yy_cp = '\0'; \
 	(yy_c_buf_p) = yy_cp;
 
-#define YY_NUM_RULES 50
-#define YY_END_OF_BUFFER 51
+#define YY_NUM_RULES 48
+#define YY_END_OF_BUFFER 49
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -387,50 +387,50 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static yyconst flex_int16_t yy_accept[384] =
+static yyconst flex_int16_t yy_accept[382] =
     {   0,
-        0,    0,   47,   47,    0,    0,   51,   49,    1,   45,
-       49,   49,   49,   49,   39,   31,   35,   35,   34,   34,
-       34,   34,   34,   34,   34,   49,   34,   34,   34,   34,
+        0,    0,   45,   45,    0,    0,   49,   47,    1,   43,
+       47,   47,   47,   47,   37,   31,   35,   35,   34,   34,
+       34,   34,   34,   34,   34,   47,   34,   34,   34,   34,
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   49,   49,   49,   47,   50,   33,   50,    1,
-        0,    3,    0,    0,    0,   39,   35,    0,    0,   39,
-       39,    0,   40,   46,    2,   31,    0,    0,    0,    0,
-       35,   36,   37,    0,   34,    0,    0,    0,    0,   34,
+       34,   34,   47,   47,   47,   45,   48,   33,   48,    1,
+        0,    3,    0,    0,    0,   37,   35,    0,    0,   37,
+       37,    0,   38,   44,    2,   31,    0,    0,    0,    0,
+       35,   35,   35,    0,   34,    0,    0,    0,    0,   34,
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
 
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,    0,    0,   47,    0,   48,   33,   41,    0,    0,
-        0,   35,    0,   39,    0,    0,   39,    2,   31,    0,
-        0,    0,    0,    0,    0,    0,   37,    4,    0,    0,
-       34,   34,   34,   34,   34,   34,   30,   27,   34,   34,
+       34,    0,    0,   45,    0,   46,   33,   39,    0,    0,
+        0,    0,   37,    0,    0,   37,    2,   31,    0,    0,
+        0,    0,    0,    0,    0,    4,    0,    0,   34,   34,
+       34,   34,   34,   34,   30,   27,   34,   34,   34,   34,
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   14,   34,   27,
+       34,   34,   34,   34,   34,   14,   34,   27,   34,   34,
        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,    0,   44,    0,    0,   39,    0,   31,    0,
-
-        0,    0,    0,    0,    0,    0,    4,   38,    0,   34,
-       34,   28,   34,   34,   29,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   10,    9,   34,   34,   34,
-       34,    6,   34,   34,   34,   34,   14,   34,   34,   34,
-        8,   34,   34,   34,   34,   15,   34,   34,   34,   34,
-        0,    0,   28,    0,   31,    0,    0,    0,    0,    0,
-        0,    0,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   23,   34,   34,
-       34,   16,   34,   34,   34,   34,   12,   34,   34,   11,
-       34,   34,   15,   34,   34,   34,   42,   43,    0,    0,
-
-        0,    0,   34,   34,   34,   25,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,   18,   24,
-       34,    7,    5,   20,   17,   34,   34,   13,   34,    0,
-        0,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       32,   34,   34,   34,   34,   34,   34,   34,   34,    0,
-       34,   26,   34,   34,   34,   34,   34,   34,    5,   34,
-       34,   34,   34,   26,   26,   19,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,   22,   34,
-       21,   34,    0
+        0,   42,    0,    0,   37,    0,   31,    0,    0,    0,
+
+        0,    0,    0,    0,    4,   36,    0,   34,   34,   28,
+       34,   34,   29,   34,   34,   34,   34,   34,   34,   34,
+       34,   34,   34,   10,    9,   34,   34,   34,   34,    6,
+       34,   34,   34,   34,   14,   34,   34,   34,    8,   34,
+       34,   34,   34,   15,   34,   34,   34,   34,    0,    0,
+       28,    0,   31,    0,    0,    0,    0,    0,    0,    0,
+       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
+       34,   34,   34,   34,   34,   23,   34,   34,   34,   16,
+       34,   34,   34,   34,   12,   34,   34,   11,   34,   34,
+       15,   34,   34,   34,   40,   41,    0,    0,    0,    0,
+
+       34,   34,   34,   25,   34,   34,   34,   34,   34,   34,
+       34,   34,   34,   34,   34,   34,   18,   24,   34,    7,
+        5,   20,   17,   34,   34,   13,   34,    0,    0,   34,
+       34,   34,   34,   34,   34,   34,   34,   34,   32,   34,
+       34,   34,   34,   34,   34,   34,   34,    0,   34,   26,
+       34,   34,   34,   34,   34,   34,    5,   34,   34,   34,
+       34,   26,   26,   19,   34,   34,   34,   34,   34,   34,
+       34,   34,   34,   34,   34,   34,   22,   34,   21,   34,
+        0
     } ;
 
 static yyconst flex_int32_t yy_ec[256] =
@@ -476,105 +476,103 @@ static yyconst flex_int32_t yy_meta[68] =
        11,   11,   14,    1,   11,   11,   11
     } ;
 
-static yyconst flex_int16_t yy_base[402] =
+static yyconst flex_int16_t yy_base[400] =
     {   0,
-        0,    0,  328,  323,  264,  263,  323, 2232,   66, 2232,
-       63,  284,   60,   61,   93,   83,  140,  284,   50,   60,
+        0,    0,  336,  331,  274,  273,  331, 2153,   66, 2153,
+       63,  289,   60,   61,   93,   83,  140,  285,   50,   60,
       191,   64,   95,  154,  102,  198,  198,  180,  195,  228,
-      268,  188,  213,  221,  232,  252,  237,  245,  267,  263,
-      297,  275,  252,  245,  244,  299,  294,    0, 2232,   78,
-       86, 2232,  281,  275,  342,    0,  369,  356,  225,    0,
-     2232,  414, 2232, 2232,    0,  338,  421,  210,  208,  207,
-      230, 2232,  141,    0,  351,  437,  188,  186,  185,  355,
-       74,  437,  412,  418,  432,  423,  436,  443,  456,  453,
-      466,  473,  476,  496,  492,  489,  510,  486,  499,  522,
-
-      531,  534,  543,  552,  568,  546,  576,  584,  565,  587,
-      600,  606,  609,  621,  591,  617,  641,  632,  651,  656,
-      625,  180,  179,  232,  227, 2232,    0, 2232,  230,  697,
-      228,    0,  711,  718,  189,  736,  756,    0,  726,  722,
-      790,  168,  164,  163,  131,  129, 2232,  146,  125,  124,
-      738,  742,  746,  776,  779,  791,  782,  785,  796,  800,
-      826,  817,  830,  834,  838,  843,  847,  864,  877,  860,
-      869,  880,  884,  899,  903,  915,  918,  934,  921,  951,
-      937,  954,  957,  970,  973,  987,  976,  990,  995, 1011,
-     1020, 1026,  123, 2232, 1052,    0, 2232,   48, 1033, 1088,
-
-      122,  121,  114,  108,  101,   88,  419, 2232,   82, 1044,
-     1050, 1057, 1074, 1089, 1080, 1094, 1083, 1113, 1104, 1124,
-     1099, 1130, 1134, 1138, 1146, 1120, 1150, 1154, 1186, 1170,
-     1160, 1176, 1180, 1190, 1212, 1193, 1196, 1229, 1226, 1238,
-     1233, 1243, 1246, 1249, 1279, 1284, 1287, 1269, 1291, 1299,
-      138,  137, 2232,   90, 1329, 1355,   77,   75,   71,   68,
-       64,   58, 1304, 1339, 1334, 1346, 1349, 1342, 1379, 1382,
-     1385, 1360, 1390, 1393, 1396, 1399, 1415, 2232, 1429, 1432,
-     1449, 1435, 1439, 1452, 1446, 1465, 1455, 1469, 1472, 1485,
-     1491, 1495, 1488, 1511, 1505, 1526, 2232, 2232,   55,   36,
-
-       35,   33, 1536, 1530, 1541, 1545, 1550, 1556, 1560, 1567,
-     1590, 1582, 1586, 1593, 1600, 1608, 1624, 1630, 1575, 2232,
-     1642, 1634, 1645, 2232, 1648, 1678, 1665, 1654, 1668,   36,
-       25, 1686, 1691, 1699, 1702, 1711, 1717, 1733, 1724, 1737,
-     1741, 1748, 1757, 1767, 1773, 1779, 1787, 1783, 1792,   24,
-     1817, 1822, 1803, 1799, 1833, 1836, 1847, 1852, 1855, 1858,
-     1867, 1888, 1871,   36, 1877, 1891, 1897, 1901, 1908, 1932,
-     1914, 1921, 1951, 1939, 1947, 1944, 1954, 1964, 2232, 1984,
-     2232, 1977, 2232, 2051, 2065, 2079, 2093, 2102, 2111, 2120,
-     2133, 2147, 2160, 2174, 2184, 2190, 2198, 2200, 2206, 2212,
-
-     2218
+      269,  188,  213,  221,  232,  252,  237,  245,  267,  263,
+      297,  275,  256,  252,  245,  300,  295,    0, 2153,   78,
+       86, 2153,  303,  277,  342,    0,  245,  356,  225,    0,
+     2153,  367, 2153, 2153,    0,  340,  374,  210,  208,  207,
+      230, 2153,  141,    0,  329,  393,  188,  186,  185,  370,
+       74,  400,  373,  396,  381,  386,  417,  404,  427,  420,
+      430,  434,  437,  460,  452,  473,  476,  483,  486,  497,
+
+      494,  506,  509,  516,  532,  528,  539,  549,  542,  546,
+      552,  582,  572,  565,  586,  589,  605,  608,  626,  620,
+      639,  180,  179,  232,  227, 2153,    0, 2153,  230,  683,
+      228,  665,  694,  189,  712,  732,    0,  650,  491,  748,
+      168,  164,  163,  131,  129,  146,  125,  124,  700,  704,
+      722,  734,  747,  740,  743,  752,  755,  764,  787,  790,
+      777,  796,  803,  799,  808,  833,  838,  822,  841,  845,
+      852,  856,  863,  875,  878,  908,  889,  893,  915,  896,
+      882,  912,  926,  932,  929,  945,  948,  968,  952,  982,
+      123, 2153, 1008,    0, 2153,   48,  989, 1023,  122,  121,
+
+      114,  108,  101,   88,  293, 2153,   82,  993, 1006, 1012,
+     1015, 1027, 1019, 1030, 1024, 1037, 1050, 1061, 1067, 1070,
+     1074, 1085, 1082, 1091, 1104, 1107, 1123, 1115, 1126, 1130,
+     1140, 1145, 1137, 1148, 1162, 1183, 1179, 1171, 1186, 1196,
+     1193, 1209, 1226, 1239, 1233, 1229, 1246, 1249,  138,  137,
+     2153,   90, 1243, 1313,   77,   75,   71,   68,   64,   58,
+     1259, 1293, 1289, 1263, 1303, 1296, 1300, 1306, 1312, 1315,
+     1345, 1336, 1349, 1352, 1361, 2153, 1366, 1369, 1386, 1383,
+     1399, 1402, 1409, 1417, 1392, 1422, 1425, 1406, 1439, 1432,
+     1443, 1447, 1458, 1462, 2153, 2153,   55,   36,   35,   33,
+
+     1473, 1455, 1477, 1480, 1492, 1498, 1495, 1503, 1510, 1533,
+     1516, 1528, 1541, 1546, 1549, 1571, 1558, 2153, 1564, 1567,
+     1580, 2153, 1583, 1597, 1602, 1588, 1606,   36,   25, 1613,
+     1621, 1632, 1651, 1636, 1647, 1643, 1654, 1662, 1658, 1667,
+     1692, 1688, 1684, 1700, 1704, 1697, 1708,   24, 1723, 1734,
+     1753, 1742, 1746, 1749, 1758, 1765, 1768, 1784, 1799, 1802,
+     1789,   36, 1806, 1809, 1814, 1819, 1832, 1839, 1844, 1850,
+     1858, 1855, 1870, 1862, 1875, 1894, 2153, 1900, 2153, 1905,
+     2153, 1972, 1986, 2000, 2014, 2023, 2032, 2041, 2054, 2068,
+     2081, 2095, 2105, 2111, 2119, 2121, 2127, 2133, 2139
+
     } ;
 
-static yyconst flex_int16_t yy_def[402] =
+static yyconst flex_int16_t yy_def[400] =
     {   0,
-      383,    1,  384,  384,  385,  385,  383,  383,  383,  383,
-      386,  387,  383,  388,  383,  389,  383,   17,  390,  390,
-      390,  390,  390,  390,  390,  383,  390,  390,  390,  390,
-       21,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  383,  383,  383,  391,  391,  392,  383,  383,
-      386,  383,  386,  383,  393,   15,  383,  383,  383,   15,
-      383,  383,  383,  383,  394,  395,  383,  383,  383,  383,
-       17,  383,  383,  396,  390,  383,  383,  383,  383,  390,
-       21,   21,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  383,  383,  391,  391,  383,  392,  383,  383,  383,
-      397,   57,  383,  383,  383,  383,  383,  394,  395,  398,
-      383,  383,  383,  383,  383,  383,  383,  399,  383,  383,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  383,  383,  383,  400,  383,  383,  401,  383,
-
-      383,  383,  383,  383,  383,  383,  399,  383,  383,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      383,  383,  383,  383,  401,  383,  383,  383,  383,  383,
-      383,  383,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  383,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  383,  383,  383,  383,
-
-      383,  383,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  383,
-      390,  390,  390,  383,  390,  390,  390,  390,  390,  383,
-      383,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  383,
-      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  383,  390,  390,  390,  390,  390,  390,
-      390,  390,  390,  390,  390,  390,  390,  390,  383,  390,
-      383,  390,    0,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
+      381,    1,  382,  382,  383,  383,  381,  381,  381,  381,
+      384,  385,  381,  386,  381,  387,  381,   17,  388,  388,
+      388,  388,  388,  388,  388,  381,  388,  388,  388,  388,
+       21,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  381,  381,  381,  389,  389,  390,  381,  381,
+      384,  381,  384,  381,  391,   15,   17,  381,  381,   15,
+      381,  381,  381,  381,  392,  393,  381,  381,  381,  381,
+       17,  381,  381,  394,  388,  381,  381,  381,  381,  388,
+       21,   21,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  381,  381,  389,  389,  381,  390,  381,  381,  381,
+      395,  381,  381,  381,  381,  381,  392,  393,  396,  381,
+      381,  381,  381,  381,  381,  397,  381,  381,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      381,  381,  381,  398,  381,  381,  399,  381,  381,  381,
+
+      381,  381,  381,  381,  397,  381,  381,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  381,  381,
+      381,  381,  399,  381,  381,  381,  381,  381,  381,  381,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  381,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  381,  381,  381,  381,  381,  381,
+
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  381,  388,  388,
+      388,  381,  388,  388,  388,  388,  388,  381,  381,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  381,  388,  388,
+      388,  388,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  381,  388,  388,  388,  388,  388,  388,  388,  388,
+      388,  388,  388,  388,  388,  388,  381,  388,  381,  388,
+        0,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381
 
-      383
     } ;
 
-static yyconst flex_int16_t yy_nxt[2300] =
+static yyconst flex_int16_t yy_nxt[2221] =
     {   0,
         8,    9,   10,    9,    8,   11,   12,    8,   13,   14,
        15,   16,   17,   18,   18,   18,   18,   18,   18,    8,
@@ -584,254 +582,245 @@ static yyconst flex_int16_t yy_nxt[2300] =
        19,   36,   37,   19,   19,   38,   39,   40,   41,   42,
        19,   19,    8,    8,   43,   44,   45,   50,   52,   50,
        56,   56,   57,   57,   57,   57,   57,   57,   57,   50,
-      253,   50,   75,   75,  364,   58,   58,   76,  255,   59,
-       64,   52,  253,  350,   65,  254,  199,   76,  331,  255,
+      251,   50,   75,   75,  362,   58,   58,   76,  253,   59,
+       64,   52,  251,  348,   65,  252,  197,   76,  329,  253,
 
-       53,   76,  330,   58,   58,   60,   60,   60,   60,   60,
+       53,   76,  328,   58,   58,   60,   60,   60,   60,   60,
        60,   60,   80,   83,   77,   78,   79,   61,   62,   63,
-       67,  139,   61,   53,   77,   78,   79,  302,   77,   78,
-       79,  199,   76,   89,  301,   61,   62,   63,  300,   76,
-      255,  299,   61,  298,  297,   75,   84,   68,   69,   70,
+       67,  138,   61,   53,   77,   78,   79,  300,   77,   78,
+       79,  197,   76,   89,  299,   61,   62,   63,  298,   76,
+      253,  297,   61,  296,  295,   75,   84,   68,   69,   70,
        56,   66,   71,   71,   71,   71,   71,   71,   71,   77,
-       78,   79,   72,  147,  262,   58,   77,   78,   79,   72,
-      147,  139,   72,  147,   73,  208,   74,  261,  208,   85,
-       72,  147,   86,   58,  260,  199,   90,  209,   75,   72,
-      147,   76,  206,   87,   66,  208,   72,  147,   73,   81,
+       78,   79,   72,   72,  260,   58,   77,   78,   79,   72,
+       72,  138,   72,   72,   73,  206,   74,  259,  206,   85,
+       72,   72,   86,   58,  258,  197,   90,  207,   75,   72,
+       72,   76,  204,   87,   66,  206,   72,   72,   73,   81,
 
-       81,   88,  208,   82,   82,   82,   82,   82,   82,   82,
+       81,   88,  206,   82,   82,   82,   82,   82,   82,   82,
        90,   90,   90,   90,   90,   90,   90,   76,   77,   78,
-       79,   91,   92,   93,   94,   76,  205,  204,   76,   95,
-       96,  139,   76,  198,  194,   76,  194,  104,  383,  125,
-       97,   98,  193,   90,   77,   78,   79,   99,  150,  149,
+       79,   91,   92,   93,   94,   76,  203,  202,   76,   95,
+       96,  138,   76,  196,  192,   76,  192,  104,  381,  125,
+       97,   98,  191,   90,   77,   78,   79,   99,  148,  147,
        76,   75,   77,   78,   79,   77,   78,   79,   76,   77,
-       78,   79,   77,   78,   79,   76,  383,  100,  105,   76,
-      146,  145,  106,   66,   76,  101,  135,   77,   78,   79,
-      102,  128,   76,  383,  107,   77,   78,   79,  112,   76,
+       78,   79,   77,   78,   79,   76,  381,  100,  105,   76,
+      145,  144,  106,   66,   76,  101,  134,   77,   78,   79,
+      102,  381,   76,  128,  107,   77,   78,   79,  112,   76,
       111,  108,   77,   78,   79,  109,   77,   78,   79,  110,
 
-       76,   77,   78,   79,   76,  126,  125,  123,  122,   77,
-       78,   79,   76,  113,  121,   90,   77,   78,   79,  103,
-      383,   55,  383,  115,  114,   49,   49,   77,   78,   79,
-       47,   77,   78,   79,   76,   47,  383,  116,  383,   77,
-       78,   79,  383,  383,  117,  383,  118,  383,  119,  140,
-      383,  383,  383,  120,  130,  130,  130,  130,  130,  130,
-      383,   77,   78,   79,  133,  133,  383,  383,  134,  134,
-      134,  134,  134,  134,  134,  141,  383,  383,  131,   56,
-      383,  132,  132,  132,  132,  132,  132,  132,   76,  383,
-      383,   72,   76,  383,   58,  383,  383,  383,   72,  383,
-
-      383,   72,  142,  143,  144,  383,  383,  383,  383,   72,
-      383,  383,   58,  151,  383,   77,   78,   79,   72,   77,
-       78,   79,  136,  136,  383,   72,  137,  137,  137,  137,
-      137,  137,  137,   66,   66,   66,   66,   66,   66,   66,
-       75,   75,   75,   75,   75,   75,   75,  383,  208,   76,
-      383,  208,  157,  383,  383,   76,   75,  383,  383,  383,
-       76,  152,  155,  153,  154,  156,  152,  158,  208,   76,
-      383,  383,  383,   76,   75,  208,   77,   78,   79,  152,
-       76,  153,   77,   78,   79,  159,  152,   77,   78,   79,
-       76,  383,  157,   76,  383,  383,   77,   78,   79,   75,
-
-       77,   78,   79,   76,  383,  383,  383,   77,   78,   79,
-       76,  383,  160,   76,  383,  383,  161,   77,   78,   79,
-       77,   78,   79,   76,  383,  170,   76,  162,  383,   76,
-       77,   78,   79,   76,  383,  167,   76,   77,   78,   79,
-       77,   78,   79,  163,  166,  164,  168,   76,  165,  171,
+       76,   77,   78,   79,   76,  381,  126,  125,  123,   77,
+       78,   79,   76,  113,  121,  122,   77,   78,   79,   90,
+      103,  381,  206,  115,  114,  206,   55,   77,   78,   79,
+      381,   77,   78,   79,   76,   49,   49,  116,   47,   77,
+       78,   79,  206,   47,  117,  381,  118,  381,  119,  206,
+      381,  139,  381,  120,  130,  130,  130,  130,  130,  130,
+      381,   77,   78,   79,  132,  132,   76,  381,  133,  133,
+      133,  133,  133,  133,  133,  135,  135,  140,  131,  136,
+      136,  136,  136,  136,  136,  136,   66,   66,   66,   66,
+       66,   66,   66,   77,   78,   79,   75,   75,   75,   75,
+
+       75,  381,  381,  381,  141,  142,  143,   76,   75,   75,
+       76,  381,   75,  381,  154,  155,  381,  381,   76,  381,
+      381,  381,  381,   76,  150,  152,  151,  381,  149,  150,
+       75,  381,  381,   76,   77,   78,   79,   77,   78,   79,
+      153,   76,  150,  381,  151,   77,   78,   79,  156,  150,
+       77,   78,   79,  155,   76,   75,  157,   76,  381,  381,
+       77,   78,   79,  381,   76,  381,  381,   76,   77,   78,
+       79,   76,  381,  381,   76,  381,  158,  159,  381,  381,
+      381,   77,   78,   79,   77,   78,   79,  381,  160,   76,
+      381,   77,   78,   79,   77,   78,   79,   76,   77,   78,
+
+       79,   77,   78,   79,  164,  381,  381,  161,  381,  162,
+       76,  381,  163,   76,  381,  381,   77,   78,   79,  165,
+       76,  381,  168,   76,   77,   78,   79,  381,  198,  381,
+      166,   76,  381,  167,   76,  381,  169,   77,   78,   79,
+       77,   78,   79,   76,  171,  381,   76,   77,   78,   79,
+       77,   78,   79,   76,  170,  199,  200,  201,   77,   78,
+       79,   77,   78,   79,  172,   76,  381,  173,  174,   76,
+       77,   78,   79,   77,   78,   79,   76,  381,  381,   76,
+       77,   78,   79,   76,  175,  176,   76,  381,  381,   76,
+      177,  180,   77,   78,   79,  155,   77,   78,   79,  179,
+
+      178,  381,   76,   77,   78,   79,   77,   78,   79,   76,
        77,   78,   79,   77,   78,   79,   77,   78,   79,   76,
-       77,   78,   79,   77,   78,   79,  383,  169,   76,  383,
-      383,   76,  383,  383,   77,   78,   79,  383,  383,  172,
-       76,  173,  383,   76,  383,  383,   77,   78,   79,   76,
-      383,  383,  174,  383,  383,   77,   78,   79,   77,   78,
-
-       79,  175,   76,  178,  176,   76,  383,   77,   78,   79,
-       77,   78,   79,   76,  383,  383,   77,   78,   79,  383,
-      177,   76,  181,  383,   76,  383,  383,  179,   76,   77,
-       78,   79,   77,   78,   79,  180,  157,   76,  383,  182,
-       77,   78,   79,   76,  186,  183,   76,  383,   77,   78,
-       79,   77,   78,   79,   76,   77,   78,   79,   76,  383,
-      383,  184,   76,  383,   77,   78,   79,  383,  383,   76,
-       77,   78,   79,   77,   78,   79,  185,  187,   76,  383,
-      192,   77,   78,   79,  189,   77,   78,   79,   76,   77,
-       78,   79,  188,   76,  383,  383,   77,   78,   79,  383,
-
-      190,  383,  191,  194,  383,   77,   78,   79,  383,  195,
-      195,  195,  195,  195,  195,   77,   78,   79,  383,  383,
-       77,   78,   79,  134,  134,  134,  134,  134,  134,  134,
-      134,  134,  134,  134,  134,  134,  134,  140,  383,  383,
-      383,  383,  197,  383,   63,  383,  383,  197,  137,  137,
-      137,  137,  137,  137,  137,  383,  383,  383,  383,  200,
-      197,  383,   63,  141,  383,  383,  383,  197,  137,  137,
-      137,  137,  137,  137,  137,   76,  383,  383,  210,   76,
-       61,  383,   63,   76,  383,   61,  201,  202,  203,  383,
-      142,  143,  144,  139,  139,  139,  139,  139,   61,  383,
-
-       63,  383,   77,   78,   79,   61,   77,   78,   79,  139,
-       77,   78,   79,   76,  214,  211,   76,  383,  383,   76,
-      383,  383,   76,  212,  216,  383,  213,  139,   76,  215,
-      383,  383,  383,   76,  383,  383,  383,   76,  383,  383,
-       77,   78,   79,   77,   78,   79,   77,   78,   79,   77,
-       78,   79,  139,  383,   76,   77,   78,   79,  217,  219,
-       77,   78,   79,   76,   77,   78,   79,   76,  383,  223,
-      218,   76,  383,  383,  383,   76,  383,  221,  383,  220,
-       76,   77,   78,   79,   76,  383,  383,  383,  383,  383,
-       77,   78,   79,  222,   77,   78,   79,   76,   77,   78,
-
-       79,   76,   77,   78,   79,  224,   76,   77,   78,   79,
-      383,   77,   78,   79,   76,  227,  225,   76,  383,  229,
-      226,   76,  228,  383,   77,   78,   79,  230,   77,   78,
-       79,  383,  383,   77,   78,   79,   76,  383,  383,  231,
-       76,   77,   78,   79,   77,   78,   79,  383,   77,   78,
-       79,  235,   76,  232,  233,   76,  383,  383,   76,  383,
-      238,  383,  383,   77,   78,   79,  237,   77,   78,   79,
-      383,   76,  383,  383,   76,  383,  234,  236,  239,   77,
-       78,   79,   77,   78,   79,   77,   78,   79,   76,  383,
-      383,   76,  383,  383,   76,  215,  383,  383,   77,   78,
-
-       79,   77,   78,   79,  383,  383,  241,   76,  240,  383,
-       76,  383,  383,   76,  383,   77,   78,   79,   77,   78,
-       79,   77,   78,   79,   76,  242,  383,   76,  383,  383,
-      244,  243,   76,  245,   77,   78,   79,   77,   78,   79,
-       77,   78,   79,  383,  140,  383,  247,  246,   76,  383,
-      383,   77,   78,   79,   77,   78,   79,   76,  248,   77,
-       78,   79,  383,   76,  251,  251,  251,  251,  251,  251,
-      256,  383,  249,  250,  383,   77,   78,   79,  383,  383,
-      383,   76,  383,  383,   77,   78,   79,   76,  383,  383,
-       77,   78,   79,  263,   76,  383,  383,  257,  258,  259,
-
-      199,  199,  199,  199,  199,  199,  199,  264,   77,   78,
-       79,   76,  383,  266,   77,   78,   79,   76,  383,  383,
-       76,   77,   78,   79,  267,  265,   76,  383,  383,  383,
-      383,   76,  383,  383,  268,  383,   76,  383,   77,   78,
-       79,   76,  383,  383,   77,   78,   79,   77,   78,   79,
-       76,  270,  383,   77,   78,   79,  272,   76,   77,   78,
-       79,   76,  269,   77,   78,   79,  383,   76,   77,   78,
-       79,   76,  383,  271,  383,   76,  383,   77,   78,   79,
-      273,  274,  275,   76,   77,   78,   79,   76,   77,   78,
-       79,   76,  383,  383,   77,   78,   79,   76,   77,   78,
-
-       79,  276,   77,   78,   79,  278,  277,   76,  383,  280,
-       77,   78,   79,   76,   77,   78,   79,   76,   77,   78,
-       79,  279,  383,   76,   77,   78,   79,   76,  282,  383,
-       76,  383,  383,   76,   77,   78,   79,  241,  283,  383,
-       77,   78,   79,  281,   77,   78,   79,  383,  383,   76,
-       77,   78,   79,  284,   77,   78,   79,   77,   78,   79,
-       77,   78,   79,   76,  383,  383,   76,  383,  285,  383,
-       76,  383,  383,  383,  383,   76,   77,   78,   79,  383,
-       76,  383,  383,   76,  383,  383,   76,  288,  383,  383,
-       77,   78,   79,   77,   78,   79,  286,   77,   78,   79,
-
-      287,  291,   77,   78,   79,  289,   76,   77,   78,   79,
-       77,   78,   79,   77,   78,   79,   76,  383,  383,  294,
-      383,   76,  290,  383,   76,  383,  383,  292,   76,  383,
-      383,  383,  293,   77,   78,   79,   76,  383,  296,  383,
-      140,   76,  383,   77,   78,   79,  295,  303,   77,   78,
-       79,   77,   78,   79,  383,   77,   78,   79,  255,  255,
-      255,  255,  255,   77,   78,   79,  256,  304,   77,   78,
-       79,   76,  306,  383,  255,  383,   76,  307,  383,   76,
-      383,  305,  383,   76,  383,  383,   76,  383,  383,  383,
-      308,  383,  255,  257,  258,  259,  383,   76,   77,   78,
-
-       79,  312,  383,   77,   78,   79,   77,   78,   79,  383,
-       77,   78,   79,   77,   78,   79,   76,  255,  309,   76,
-      311,  310,   76,  383,   77,   78,   79,   76,  383,  313,
-       76,  383,  383,   76,  383,  383,   76,  383,  316,  383,
-      315,  383,  314,   77,   78,   79,   77,   78,   79,   77,
-       78,   79,   76,  383,   77,   78,   79,   77,   78,   79,
-       77,   78,   79,   77,   78,   79,   76,  383,  320,   76,
-      383,  383,   76,  317,  383,  319,   76,  383,  306,   77,
-       78,   79,  321,   76,  383,  318,   76,  383,  383,   76,
-      306,  324,   76,   77,   78,   79,   77,   78,   79,   77,
-
-       78,   79,   76,   77,   78,   79,   76,  325,  322,   76,
-       77,   78,   79,   77,   78,   79,   77,   78,   79,   77,
-       78,   79,   76,  383,  383,   76,  323,  383,   76,   77,
-       78,   79,   76,   77,   78,   79,   77,   78,   79,  383,
-      326,  383,   76,  383,  383,  383,  383,  383,   76,   77,
-       78,   79,   77,   78,   79,   77,   78,   79,  327,   77,
-       78,   79,  328,   76,  332,  383,  329,   76,  383,   77,
-       78,   79,  383,   76,  383,   77,   78,   79,   76,  383,
-      383,  333,   76,  335,  383,  383,  383,   76,  336,  383,
-       77,   78,   79,   76,   77,   78,   79,   76,  334,  383,
-
-       77,   78,   79,  383,   76,   77,   78,   79,  383,   77,
-       78,   79,   76,  383,   77,   78,   79,  337,  338,   76,
-       77,   78,   79,   76,   77,   78,   79,   76,  340,  339,
-       76,   77,   78,   79,  383,  383,  383,   76,  383,   77,
-       78,   79,  341,  341,  383,   76,   77,   78,   79,  342,
-       77,   78,   79,  343,   77,   78,   79,   77,   78,   79,
-      383,   76,  383,  383,   77,   78,   79,   76,  383,  383,
-      383,   76,   77,   78,   79,  344,  383,  345,  383,   76,
-      383,  383,   76,  383,  383,   76,  383,  383,   77,   78,
-       79,   76,  383,  383,   77,   78,   79,  237,   77,   78,
-
-       79,  383,   76,  346,  383,   76,   77,   78,   79,   77,
-       78,   79,   77,   78,   79,   76,  383,  349,   77,   78,
-       79,  347,  348,   76,  383,  383,  383,  353,   76,   77,
-       78,   79,   77,   78,   79,  212,   76,  351,  383,   76,
-      383,  383,   77,   78,   79,  383,  383,  383,   76,  383,
-       77,   78,   79,  383,   76,   77,   78,   79,  354,  352,
-      355,   76,  383,   77,   78,   79,   77,   78,   79,  383,
-       76,  383,  383,  357,   76,   77,   78,   79,   76,  383,
-      358,   77,   78,   79,  356,   76,  383,  383,   77,   78,
-       79,  341,  383,  383,   76,  383,  383,   77,   78,   79,
-
-      341,   77,   78,   79,   76,   77,   78,   79,  383,  359,
-       76,  383,   77,   78,   79,  383,   76,  383,  383,  383,
-       76,   77,   78,   79,   76,  360,  362,  366,  383,   76,
-      383,   77,   78,   79,  361,  363,   76,   77,   78,   79,
-       76,  383,  293,   77,   78,   79,  383,   77,   78,   79,
-      383,   77,   78,   79,   76,  383,   77,   78,   79,   76,
-      367,  365,  368,   77,   78,   79,  212,   77,   78,   79,
-       76,  383,  383,   76,  383,  383,  383,  383,  383,  369,
-      383,   77,   78,   79,   76,  383,   77,   78,   79,   76,
-      383,  383,   76,  383,  383,   76,  383,   77,   78,   79,
-
-       77,   78,   79,  383,   76,  370,  383,  371,   76,  372,
-      359,   77,   78,   79,   76,  383,   77,   78,   79,   77,
-       78,   79,   77,   78,   79,   76,  383,  373,   76,  377,
-      366,   77,   78,   79,   76,   77,   78,   79,   76,  383,
-      374,   77,   78,   79,  375,   76,  383,  383,  383,  383,
-      383,   76,   77,   78,   79,   77,   78,   79,   76,  383,
-      383,   77,   78,   79,  376,   77,   78,   79,  341,   76,
-      379,  383,   77,   78,   79,  341,   76,  378,   77,   78,
-       79,   76,  383,  381,   76,   77,   78,   79,   76,  383,
-      383,   76,  383,  383,  383,  341,   77,   78,   79,  383,
-
-      341,   76,  383,   77,   78,   79,  380,  383,   77,   78,
-       79,   77,   78,   79,   76,   77,   78,   79,   77,   78,
-       79,   76,  383,  383,  383,  383,  341,  382,   77,   78,
-       79,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,   77,   78,   79,  383,  383,  383,  383,   77,   78,
-       79,   46,   46,   46,   46,   46,   46,   46,   46,   46,
-       46,   46,   46,   46,   46,   48,   48,   48,   48,   48,
-       48,   48,   48,   48,   48,   48,   48,   48,   48,   51,
-       51,   51,   51,   51,   51,   51,   51,   51,   51,   51,
-       51,   51,   51,   54,   54,   54,   54,   54,   54,   54,
+      183,  181,  381,   76,  182,  381,   76,  381,  381,   77,
+       78,   79,  381,  381,  381,  381,   77,   78,   79,  184,
+      381,  381,   76,  381,  381,   76,   77,   78,   79,  185,
+       77,   78,   79,   77,   78,   79,  186,   76,  381,  381,
+      187,  139,  381,   76,  381,  381,  189,  381,  381,   77,
+       78,   79,   77,   78,   79,  188,   76,  133,  133,  133,
+      133,  133,  133,  133,   77,   78,   79,  140,  381,  192,
+       77,   78,   79,  381,  190,  193,  193,  193,  193,  193,
+
+      193,  381,  381,   77,   78,   79,  133,  133,  133,  133,
+      133,  133,  133,  381,  141,  142,  143,  381,  195,  381,
+       63,  381,  381,  195,  136,  136,  136,  136,  136,  136,
+      136,  381,  381,  381,  381,  381,  195,   76,   63,  381,
+      208,   76,  381,  195,  136,  136,  136,  136,  136,  136,
+      136,  138,  138,  138,  138,  138,   61,  381,   63,   76,
+      381,   61,  381,  212,   77,   78,   79,  138,   77,   78,
+       79,   76,  381,  209,   61,  381,   63,   76,  381,  381,
+       76,   61,  381,  214,   76,  138,   77,   78,   79,   76,
+      381,  210,   76,  381,  211,  381,  213,  381,   77,   78,
+
+       79,   76,  381,  381,   77,   78,   79,   77,   78,   79,
+      138,   77,   78,   79,   76,  381,   77,   78,   79,   77,
+       78,   79,  215,  381,   76,  221,  218,   76,   77,   78,
+       79,  216,  217,   76,  381,  381,   76,  381,  381,  219,
+       76,   77,   78,   79,  381,   76,  381,  381,  381,  381,
+      381,   77,   78,   79,   77,   78,   79,  381,  220,   76,
+       77,   78,   79,   77,   78,   79,  222,   77,   78,   79,
+       76,  381,   77,   78,   79,   76,  381,  225,   76,  381,
+      381,  224,   76,  381,  227,  223,   77,   78,   79,   76,
+      381,  381,  381,   76,  226,  228,  229,   77,   78,   79,
+
+       76,  381,   77,   78,   79,   77,   78,   79,  381,   77,
+       78,   79,   76,  230,  231,   76,   77,   78,   79,   76,
+       77,   78,   79,  381,  381,  233,   76,   77,   78,   79,
+       76,  239,  381,   76,  235,  381,  232,  213,  236,   77,
+       78,   79,   77,   78,   79,   76,   77,   78,   79,   76,
+      238,  234,   76,   77,   78,   79,  237,   77,   78,   79,
+       77,   78,   79,   76,  381,  381,   76,  240,  381,   76,
+      381,  381,   77,   78,   79,  242,   77,   78,   79,   77,
+       78,   79,   76,  381,  241,   76,  243,  381,  381,   76,
+       77,   78,   79,   77,   78,   79,   77,   78,   79,  245,
+
+      139,  381,  244,  381,  247,   76,  381,  381,  381,   77,
+       78,   79,   77,   78,   79,  246,   77,   78,   79,   76,
+      249,  249,  249,  249,  249,  249,  254,  381,  381,  248,
+       76,  381,   77,   78,   79,  197,  197,  197,  197,  197,
+      197,  197,  261,   76,  381,  381,   77,   78,   79,   76,
+      381,  264,   76,  255,  256,  257,   76,   77,   78,   79,
+      265,   76,  381,  262,   76,  381,  263,   76,  381,  381,
+       77,   78,   79,  381,   76,  266,   77,   78,   79,   77,
+       78,   79,  381,   77,   78,   79,  267,   76,   77,   78,
+       79,   77,   78,   79,   77,   78,   79,  268,   76,  381,
+
+      381,   77,   78,   79,   76,  381,  381,   76,  381,  381,
+      269,   76,  381,  381,   77,   78,   79,  381,  381,   76,
+      271,  272,   76,  381,  270,   77,   78,   79,   76,  273,
+      381,   77,   78,   79,   77,   78,   79,  274,   77,   78,
+       79,   76,  276,  381,   76,  381,   77,   78,   79,   77,
+       78,   79,   76,  280,  381,   77,   78,   79,  381,  275,
+       76,  381,  381,   76,  381,  381,  277,   76,   77,   78,
+       79,   77,   78,   79,   76,  278,  381,   76,  381,   77,
+       78,   79,   76,  381,  381,   76,  381,   77,   78,   79,
+       77,   78,   79,  281,   77,   78,   79,  239,  279,   76,
+
+      381,   77,   78,   79,   77,   78,   79,  282,   76,   77,
+       78,   79,   77,   78,   79,  381,   76,  381,  381,  381,
+       76,  283,  381,   76,  381,  381,   77,   78,   79,  284,
+       76,  381,  381,   76,  286,   77,   78,   79,  381,  381,
+      381,  381,  381,   77,   78,   79,   76,   77,   78,   79,
+       77,   78,   79,  285,  139,  381,  289,   77,   78,   79,
+       77,   78,   79,   76,  381,  287,   76,  381,  381,  288,
+       76,  381,  381,   77,   78,   79,   76,  381,  291,  292,
+      254,  381,  290,   76,  381,  381,   76,  381,  294,  304,
+       77,   78,   79,   77,   78,   79,   76,   77,   78,   79,
+
+       76,  293,  301,   77,   78,   79,  381,  255,  256,  257,
+       77,   78,   79,   77,   78,   79,  253,  253,  253,  253,
+      253,  302,  381,   77,   78,   79,   76,   77,   78,   79,
+       76,  305,  253,   76,  381,  381,  303,   76,  381,  307,
+       76,  381,  381,   76,  306,  308,  381,  309,  381,   76,
+      253,  381,   76,   77,   78,   79,  310,   77,   78,   79,
+       77,   78,   79,  381,   77,   78,   79,   77,   78,   79,
+       77,   78,   79,   76,  381,  253,   77,   78,   79,   77,
+       78,   79,   76,  381,  311,  312,   76,  381,  381,   76,
+      381,  314,  381,  313,  381,  381,  381,  381,   76,  381,
+
+       77,   78,   79,   76,  381,  318,   76,  381,  381,   77,
+       78,   79,  317,   77,   78,   79,   77,   78,   79,  315,
+       76,  381,  316,   76,  381,   77,   78,   79,  304,   76,
+       77,   78,   79,   77,   78,   79,   76,  381,  381,   76,
+      381,  381,  319,   76,  322,  381,   76,   77,   78,   79,
+       77,   78,   79,  304,   76,  323,   77,   78,   79,   76,
+      320,  381,   76,   77,   78,   79,   77,   78,   79,   76,
+       77,   78,   79,   77,   78,   79,   76,  324,  381,  321,
+       76,   77,   78,   79,   76,  381,   77,   78,   79,   77,
+       78,   79,   76,  381,  325,   76,   77,   78,   79,   76,
+
+      381,  330,  327,   77,   78,   79,  331,   77,   78,   79,
+       76,   77,   78,   79,   76,  326,  381,   76,  381,   77,
+       78,   79,   77,   78,   79,  333,   77,   78,   79,   76,
+      334,  381,   76,  381,  332,   76,  381,   77,   78,   79,
+       76,   77,   78,   79,   77,   78,   79,   76,  381,  337,
+      381,  381,  335,   76,  336,  381,   77,   78,   79,   77,
+       78,   79,   77,   78,   79,   76,  381,   77,   78,   79,
+       76,  381,  381,  339,   77,   78,   79,  339,   76,  338,
+       77,   78,   79,   76,  381,  381,   76,  381,  381,  381,
+      340,  341,   77,   78,   79,   76,  381,   77,   78,   79,
+
+      342,   76,  381,  381,   76,   77,   78,   79,   76,  381,
+       77,   78,   79,   77,   78,   79,  381,   76,  343,  235,
+       76,  381,   77,   78,   79,   76,  381,  381,   77,   78,
+       79,   77,   78,   79,   76,   77,   78,   79,  344,   76,
+      345,  381,  381,   76,   77,   78,   79,   77,   78,   79,
+       76,  381,   77,   78,   79,  347,  381,  381,   76,  346,
+      381,   77,   78,   79,  349,  210,   77,   78,   79,   76,
+       77,   78,   79,   76,  381,  381,  351,   77,   78,   79,
+       76,  381,  381,  352,   76,   77,   78,   79,   76,  381,
+      353,   76,  350,  381,  354,   76,   77,   78,   79,   76,
+
+       77,   78,   79,  355,   76,  356,  381,   77,   78,   79,
+      339,   77,   78,   79,  381,   77,   78,   79,   77,   78,
+       79,   76,   77,   78,   79,   76,   77,   78,   79,   76,
+      357,   77,   78,   79,   76,  339,  358,   76,  381,  381,
+      360,   76,  381,  381,  381,   76,  381,  381,   77,   78,
+       79,  361,   77,   78,   79,  359,   77,   78,   79,  291,
+       76,   77,   78,   79,   77,   78,   79,  363,   77,   78,
+       79,   76,   77,   78,   79,  366,  381,  364,  210,   76,
+      381,  381,  381,   76,  381,  381,   76,   77,   78,   79,
+       76,  381,  367,  381,  381,   76,  381,  381,   77,   78,
+
+       79,  381,   76,  365,  381,   76,   77,   78,   79,  381,
+       77,   78,   79,   77,   78,   79,  368,   77,   78,   79,
+      369,   76,   77,   78,   79,  381,   76,  381,  381,   77,
+       78,   79,   77,   78,   79,  370,   76,  381,  381,   76,
+      381,  381,  357,   76,  364,  371,   76,  381,   77,   78,
+       79,   76,  381,   77,   78,   79,   76,  372,  381,  375,
+      381,  381,  373,   77,   78,   79,   77,   78,   79,   76,
+       77,   78,   79,   77,   78,   79,   76,  377,   77,   78,
+       79,   76,  339,   77,   78,   79,  381,   76,  374,  339,
+      381,  381,   76,  381,  381,   76,   77,   78,   79,   76,
+
+      381,  381,  381,   77,   78,   79,  376,   76,   77,   78,
+       79,  339,   76,  379,   77,   78,   79,  381,  339,   77,
+       78,   79,   77,   78,   79,  381,   77,   78,   79,  378,
+      381,   76,  381,  381,   77,   78,   79,   76,  381,   77,
+       78,   79,   76,  380,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  339,  381,  381,  381,   77,   78,
+       79,  381,  381,  381,   77,   78,   79,  381,  381,   77,
+       78,   79,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   48,   48,   48,   48,
+       48,   48,   48,   48,   48,   48,   48,   48,   48,   48,
 
-       54,   54,   54,   54,   54,   54,   54,   57,  383,   57,
-      383,   57,  383,   57,   66,  383,  383,   66,  383,   66,
-       66,   66,   66,   66,   75,   75,  383,   75,   75,   75,
-       75,   75,   75,  124,  124,  124,  124,  124,  124,  124,
-      124,  124,  124,  124,  124,  124,  124,  127,  127,  127,
+       51,   51,   51,   51,   51,   51,   51,   51,   51,   51,
+       51,   51,   51,   51,   54,   54,   54,   54,   54,   54,
+       54,   54,   54,   54,   54,   54,   54,   54,   57,  381,
+       57,  381,   57,  381,   57,   66,  381,  381,   66,  381,
+       66,   66,   66,   66,   66,   75,   75,  381,   75,   75,
+       75,   75,   75,   75,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  127,  127,
       127,  127,  127,  127,  127,  127,  127,  127,  127,  127,
-      129,  383,  129,  129,  129,  129,  129,  129,  129,  129,
-      129,  129,  129,  129,  138,  383,  138,  138,  138,  138,
-      138,  138,  138,  138,  138,  138,  138,  138,  139,  139,
-      139,  139,  139,  139,  139,  139,  139,  148,  148,  148,
-
-      196,  383,  383,  383,  383,  196,  196,  196,  199,  199,
-      199,  199,  199,  207,  207,  207,  383,  383,  207,  252,
-      252,  252,  255,  255,  255,  255,  255,  255,  255,  255,
-      255,    7,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383
-
+      127,  129,  381,  129,  129,  129,  129,  129,  129,  129,
+      129,  129,  129,  129,  129,  137,  381,  137,  137,  137,
+
+      137,  137,  137,  137,  137,  137,  137,  137,  137,  138,
+      138,  138,  138,  138,  138,  138,  138,  138,  146,  146,
+      146,  194,  381,  381,  381,  381,  194,  194,  194,  197,
+      197,  197,  197,  197,  205,  205,  205,  381,  381,  205,
+      250,  250,  250,  253,  253,  253,  253,  253,  253,  253,
+      253,  253,    7,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381
     } ;
 
-static yyconst flex_int16_t yy_chk[2300] =
+static yyconst flex_int16_t yy_chk[2221] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -841,251 +830,242 @@ static yyconst flex_int16_t yy_chk[2300] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    9,   11,    9,
        13,   14,   13,   13,   13,   13,   13,   13,   13,   50,
-      364,   50,   81,   81,  350,   13,   14,   19,  331,   14,
-       16,   51,  198,  330,   16,  198,  302,   20,  301,  300,
+      362,   50,   81,   81,  348,   13,   14,   19,  329,   14,
+       16,   51,  196,  328,   16,  196,  300,   20,  299,  298,
 
-       11,   22,  299,   13,   14,   15,   15,   15,   15,   15,
+       11,   22,  297,   13,   14,   15,   15,   15,   15,   15,
        15,   15,   20,   22,   19,   19,   19,   15,   15,   15,
-       16,  262,   15,   51,   20,   20,   20,  261,   22,   22,
-       22,  260,   23,   25,  259,   15,   15,   15,  258,   25,
-      257,  254,   15,  252,  251,  209,   23,   16,   16,   16,
-       17,  206,   17,   17,   17,   17,   17,   17,   17,   23,
-       23,   23,   17,   73,  205,   17,   25,   25,   25,   17,
-       73,  204,   17,   73,   17,  148,   17,  203,  148,   24,
-       17,   73,   24,   17,  202,  201,  193,  150,  149,   17,
-       73,   24,  146,   24,  145,  148,   17,   73,   17,   21,
-
-       21,   24,  148,   21,   21,   21,   21,   21,   21,   21,
+       16,  260,   15,   51,   20,   20,   20,  259,   22,   22,
+       22,  258,   23,   25,  257,   15,   15,   15,  256,   25,
+      255,  252,   15,  250,  249,  207,   23,   16,   16,   16,
+       17,  204,   17,   17,   17,   17,   17,   17,   17,   23,
+       23,   23,   17,   73,  203,   17,   25,   25,   25,   17,
+       73,  202,   17,   73,   17,  146,   17,  201,  146,   24,
+       17,   73,   24,   17,  200,  199,  191,  148,  147,   17,
+       73,   24,  145,   24,  144,  146,   17,   73,   17,   21,
+
+       21,   24,  146,   21,   21,   21,   21,   21,   21,   21,
        26,   26,   26,   26,   26,   26,   26,   28,   24,   24,
-       24,   27,   27,   27,   27,   32,  144,  143,   21,   27,
-       27,  142,   29,  135,  131,   27,  129,   32,  125,  124,
+       24,   27,   27,   27,   27,   32,  143,  142,   21,   27,
+       27,  141,   29,  134,  131,   27,  129,   32,  125,  124,
        28,   29,  123,  122,   28,   28,   28,   29,   79,   78,
        33,   77,   32,   32,   32,   21,   21,   21,   34,   29,
        29,   29,   27,   27,   27,   30,   71,   30,   33,   35,
        70,   69,   34,   68,   37,   30,   59,   33,   33,   33,
-       30,   54,   38,   53,   35,   34,   34,   34,   38,   36,
+       30,   57,   38,   54,   35,   34,   34,   34,   38,   36,
        37,   36,   30,   30,   30,   36,   35,   35,   35,   36,
 
-       40,   37,   37,   37,   39,   47,   46,   45,   44,   38,
-       38,   38,   42,   39,   42,   43,   36,   36,   36,   31,
-       18,   12,    7,   40,   39,    6,    5,   40,   40,   40,
-        4,   39,   39,   39,   41,    3,    0,   41,    0,   42,
-       42,   42,    0,    0,   41,    0,   41,    0,   41,   66,
-        0,    0,    0,   41,   55,   55,   55,   55,   55,   55,
-        0,   41,   41,   41,   58,   58,    0,    0,   58,   58,
-       58,   58,   58,   58,   58,   66,    0,    0,   55,   57,
-        0,   57,   57,   57,   57,   57,   57,   57,   75,    0,
-        0,   57,   80,    0,   57,    0,    0,    0,   57,    0,
-
-        0,   57,   66,   66,   66,    0,    0,    0,    0,   57,
-        0,    0,   57,   80,    0,   75,   75,   75,   57,   80,
-       80,   80,   62,   62,    0,   57,   62,   62,   62,   62,
-       62,   62,   62,   67,   67,   67,   67,   67,   67,   67,
-       76,   76,   76,   76,   76,   82,   82,    0,  207,   83,
-        0,  207,   86,    0,    0,   84,   76,    0,    0,    0,
-       86,   82,   84,   82,   83,   85,   82,   87,  207,   85,
-        0,    0,    0,   87,   76,  207,   83,   83,   83,   82,
-       88,   82,   84,   84,   84,   89,   82,   86,   86,   86,
-       90,    0,   88,   89,    0,    0,   85,   85,   85,   76,
-
-       87,   87,   87,   91,    0,    0,    0,   88,   88,   88,
-       92,    0,   91,   93,    0,    0,   92,   90,   90,   90,
-       89,   89,   89,   98,    0,   98,   96,   93,    0,   95,
-       91,   91,   91,   94,    0,   96,   99,   92,   92,   92,
-       93,   93,   93,   94,   95,   94,   96,   97,   94,   99,
-       98,   98,   98,   96,   96,   96,   95,   95,   95,  100,
-       94,   94,   94,   99,   99,   99,    0,   97,  101,    0,
-        0,  102,    0,    0,   97,   97,   97,    0,    0,  100,
-      103,  101,    0,  106,    0,    0,  100,  100,  100,  104,
-        0,    0,  102,    0,    0,  101,  101,  101,  102,  102,
-
-      102,  103,  109,  106,  104,  105,    0,  103,  103,  103,
-      106,  106,  106,  107,    0,    0,  104,  104,  104,    0,
-      105,  108,  109,    0,  110,    0,    0,  107,  115,  109,
-      109,  109,  105,  105,  105,  108,  110,  111,    0,  111,
-      107,  107,  107,  112,  115,  112,  113,    0,  108,  108,
-      108,  110,  110,  110,  116,  115,  115,  115,  114,    0,
-        0,  113,  121,    0,  111,  111,  111,    0,    0,  118,
-      112,  112,  112,  113,  113,  113,  114,  116,  117,    0,
-      121,  116,  116,  116,  118,  114,  114,  114,  119,  121,
-      121,  121,  117,  120,    0,    0,  118,  118,  118,    0,
-
-      119,    0,  120,  130,    0,  117,  117,  117,    0,  130,
-      130,  130,  130,  130,  130,  119,  119,  119,    0,    0,
-      120,  120,  120,  133,  133,  133,  133,  133,  133,  133,
-      134,  134,  134,  134,  134,  134,  134,  139,    0,    0,
-        0,    0,  134,    0,  134,    0,    0,  134,  136,  136,
-      136,  136,  136,  136,  136,    0,    0,    0,    0,  140,
-      134,    0,  134,  139,    0,    0,    0,  134,  137,  137,
-      137,  137,  137,  137,  137,  151,    0,    0,  151,  152,
-      137,    0,  137,  153,    0,  137,  140,  140,  140,    0,
-      139,  139,  139,  141,  141,  141,  141,  141,  137,    0,
-
-      137,    0,  151,  151,  151,  137,  152,  152,  152,  141,
-      153,  153,  153,  154,  156,  154,  155,    0,    0,  157,
-        0,    0,  158,  155,  159,    0,  155,  141,  156,  158,
-        0,    0,    0,  159,    0,    0,    0,  160,    0,    0,
-      154,  154,  154,  155,  155,  155,  157,  157,  157,  158,
-      158,  158,  141,    0,  162,  156,  156,  156,  160,  162,
-      159,  159,  159,  161,  160,  160,  160,  163,    0,  166,
-      161,  164,    0,    0,    0,  165,    0,  164,    0,  163,
-      166,  162,  162,  162,  167,    0,    0,    0,    0,    0,
-      161,  161,  161,  165,  163,  163,  163,  170,  164,  164,
-
-      164,  168,  165,  165,  165,  167,  171,  166,  166,  166,
-        0,  167,  167,  167,  169,  170,  168,  172,    0,  172,
-      169,  173,  171,    0,  170,  170,  170,  173,  168,  168,
-      168,    0,    0,  171,  171,  171,  174,    0,    0,  174,
-      175,  169,  169,  169,  172,  172,  172,    0,  173,  173,
-      173,  178,  176,  175,  176,  177,    0,    0,  179,    0,
-      181,    0,    0,  174,  174,  174,  179,  175,  175,  175,
-        0,  178,    0,    0,  181,    0,  177,  178,  181,  176,
-      176,  176,  177,  177,  177,  179,  179,  179,  180,    0,
-        0,  182,    0,    0,  183,  180,    0,    0,  178,  178,
-
-      178,  181,  181,  181,    0,    0,  183,  184,  182,    0,
-      185,    0,    0,  187,    0,  180,  180,  180,  182,  182,
-      182,  183,  183,  183,  186,  184,    0,  188,    0,    0,
-      186,  185,  189,  187,  184,  184,  184,  185,  185,  185,
-      187,  187,  187,    0,  199,    0,  189,  188,  190,    0,
-        0,  186,  186,  186,  188,  188,  188,  191,  190,  189,
-      189,  189,    0,  192,  195,  195,  195,  195,  195,  195,
-      199,    0,  191,  192,    0,  190,  190,  190,    0,    0,
-        0,  210,    0,    0,  191,  191,  191,  211,    0,    0,
-      192,  192,  192,  210,  212,    0,    0,  199,  199,  199,
-
-      200,  200,  200,  200,  200,  200,  200,  211,  210,  210,
-      210,  213,    0,  214,  211,  211,  211,  215,    0,    0,
-      217,  212,  212,  212,  216,  213,  214,    0,    0,    0,
-        0,  216,    0,    0,  217,    0,  221,    0,  213,  213,
-      213,  219,    0,    0,  215,  215,  215,  217,  217,  217,
-      218,  219,    0,  214,  214,  214,  221,  226,  216,  216,
-      216,  220,  218,  221,  221,  221,    0,  222,  219,  219,
-      219,  223,    0,  220,    0,  224,    0,  218,  218,  218,
-      222,  223,  224,  225,  226,  226,  226,  227,  220,  220,
-      220,  228,    0,    0,  222,  222,  222,  231,  223,  223,
-
-      223,  225,  224,  224,  224,  229,  228,  230,    0,  231,
-      225,  225,  225,  232,  227,  227,  227,  233,  228,  228,
-      228,  230,    0,  229,  231,  231,  231,  234,  235,    0,
-      236,    0,    0,  237,  230,  230,  230,  233,  236,    0,
-      232,  232,  232,  234,  233,  233,  233,    0,    0,  235,
-      229,  229,  229,  238,  234,  234,  234,  236,  236,  236,
-      237,  237,  237,  239,    0,    0,  238,    0,  239,    0,
-      241,    0,    0,    0,    0,  240,  235,  235,  235,    0,
-      242,    0,    0,  243,    0,    0,  244,  243,    0,    0,
-      239,  239,  239,  238,  238,  238,  240,  241,  241,  241,
-
-      242,  246,  240,  240,  240,  244,  248,  242,  242,  242,
-      243,  243,  243,  244,  244,  244,  245,    0,    0,  248,
-        0,  246,  245,    0,  247,    0,    0,  246,  249,    0,
-        0,    0,  247,  248,  248,  248,  250,    0,  250,    0,
-      255,  263,    0,  245,  245,  245,  249,  263,  246,  246,
-      246,  247,  247,  247,    0,  249,  249,  249,  256,  256,
-      256,  256,  256,  250,  250,  250,  255,  264,  263,  263,
-      263,  265,  266,    0,  256,    0,  264,  267,    0,  268,
-        0,  265,    0,  266,    0,    0,  267,    0,    0,    0,
-      268,    0,  256,  255,  255,  255,    0,  272,  265,  265,
-
-      265,  272,    0,  264,  264,  264,  268,  268,  268,    0,
-      266,  266,  266,  267,  267,  267,  269,  256,  269,  270,
-      271,  270,  271,    0,  272,  272,  272,  273,    0,  273,
-      274,    0,    0,  275,    0,    0,  276,    0,  276,    0,
-      275,    0,  274,  269,  269,  269,  270,  270,  270,  271,
-      271,  271,  277,    0,  273,  273,  273,  274,  274,  274,
-      275,  275,  275,  276,  276,  276,  279,    0,  281,  280,
-        0,    0,  282,  277,    0,  280,  283,    0,  284,  277,
-      277,  277,  283,  285,    0,  279,  281,    0,    0,  284,
-      285,  289,  287,  279,  279,  279,  280,  280,  280,  282,
-
-      282,  282,  286,  283,  283,  283,  288,  291,  286,  289,
-      285,  285,  285,  281,  281,  281,  284,  284,  284,  287,
-      287,  287,  290,    0,    0,  293,  288,    0,  291,  286,
-      286,  286,  292,  288,  288,  288,  289,  289,  289,    0,
-      292,    0,  295,    0,    0,    0,    0,    0,  294,  290,
-      290,  290,  293,  293,  293,  291,  291,  291,  294,  292,
-      292,  292,  295,  296,  303,    0,  296,  304,    0,  295,
-      295,  295,    0,  303,    0,  294,  294,  294,  305,    0,
-        0,  304,  306,  307,    0,    0,    0,  307,  308,    0,
-      296,  296,  296,  308,  304,  304,  304,  309,  305,    0,
-
-      303,  303,  303,    0,  310,  305,  305,  305,    0,  306,
-      306,  306,  319,    0,  307,  307,  307,  309,  310,  312,
-      308,  308,  308,  313,  309,  309,  309,  311,  312,  311,
-      314,  310,  310,  310,    0,    0,    0,  315,    0,  319,
-      319,  319,  314,  313,    0,  316,  312,  312,  312,  315,
-      313,  313,  313,  316,  311,  311,  311,  314,  314,  314,
-        0,  317,    0,    0,  315,  315,  315,  318,    0,    0,
-        0,  322,  316,  316,  316,  317,    0,  318,    0,  321,
-        0,    0,  323,    0,    0,  325,    0,    0,  317,  317,
-      317,  328,    0,    0,  318,  318,  318,  321,  322,  322,
-
-      322,    0,  327,  323,    0,  329,  321,  321,  321,  323,
-      323,  323,  325,  325,  325,  326,    0,  329,  328,  328,
-      328,  326,  327,  332,    0,    0,    0,  335,  333,  327,
-      327,  327,  329,  329,  329,  333,  334,  332,    0,  335,
-        0,    0,  326,  326,  326,    0,    0,    0,  336,    0,
-      332,  332,  332,    0,  337,  333,  333,  333,  336,  334,
-      337,  339,    0,  334,  334,  334,  335,  335,  335,    0,
-      338,    0,    0,  339,  340,  336,  336,  336,  341,    0,
-      340,  337,  337,  337,  338,  342,    0,    0,  339,  339,
-      339,  342,    0,    0,  343,    0,    0,  338,  338,  338,
-
-      343,  340,  340,  340,  344,  341,  341,  341,    0,  344,
-      345,    0,  342,  342,  342,    0,  346,    0,    0,    0,
-      348,  343,  343,  343,  347,  345,  348,  353,    0,  349,
-        0,  344,  344,  344,  346,  349,  354,  345,  345,  345,
-      353,    0,  347,  346,  346,  346,    0,  348,  348,  348,
-        0,  347,  347,  347,  351,    0,  349,  349,  349,  352,
-      354,  351,  355,  354,  354,  354,  352,  353,  353,  353,
-      355,    0,    0,  356,    0,    0,    0,    0,    0,  356,
-        0,  351,  351,  351,  357,    0,  352,  352,  352,  358,
-        0,    0,  359,    0,    0,  360,    0,  355,  355,  355,
-
-      356,  356,  356,    0,  361,  357,    0,  358,  363,  360,
-      361,  357,  357,  357,  365,    0,  358,  358,  358,  359,
-      359,  359,  360,  360,  360,  362,    0,  363,  366,  371,
-      362,  361,  361,  361,  367,  363,  363,  363,  368,    0,
-      367,  365,  365,  365,  368,  369,    0,    0,    0,    0,
-        0,  371,  362,  362,  362,  366,  366,  366,  372,    0,
-        0,  367,  367,  367,  369,  368,  368,  368,  377,  370,
-      373,    0,  369,  369,  369,  370,  374,  372,  371,  371,
-      371,  376,    0,  378,  375,  372,  372,  372,  373,    0,
-        0,  377,    0,    0,    0,  374,  370,  370,  370,    0,
-
-      376,  378,    0,  374,  374,  374,  375,    0,  376,  376,
-      376,  375,  375,  375,  382,  373,  373,  373,  377,  377,
-      377,  380,    0,    0,    0,    0,  382,  380,  378,  378,
-      378,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-        0,  382,  382,  382,    0,    0,    0,    0,  380,  380,
-      380,  384,  384,  384,  384,  384,  384,  384,  384,  384,
-      384,  384,  384,  384,  384,  385,  385,  385,  385,  385,
-      385,  385,  385,  385,  385,  385,  385,  385,  385,  386,
-      386,  386,  386,  386,  386,  386,  386,  386,  386,  386,
-      386,  386,  386,  387,  387,  387,  387,  387,  387,  387,
-
-      387,  387,  387,  387,  387,  387,  387,  388,    0,  388,
-        0,  388,    0,  388,  389,    0,    0,  389,    0,  389,
-      389,  389,  389,  389,  390,  390,    0,  390,  390,  390,
-      390,  390,  390,  391,  391,  391,  391,  391,  391,  391,
-      391,  391,  391,  391,  391,  391,  391,  392,  392,  392,
-      392,  392,  392,  392,  392,  392,  392,  392,  392,  392,
-      393,    0,  393,  393,  393,  393,  393,  393,  393,  393,
-      393,  393,  393,  393,  394,    0,  394,  394,  394,  394,
-      394,  394,  394,  394,  394,  394,  394,  394,  395,  395,
-      395,  395,  395,  395,  395,  395,  395,  396,  396,  396,
-
-      397,    0,    0,    0,    0,  397,  397,  397,  398,  398,
-      398,  398,  398,  399,  399,  399,    0,    0,  399,  400,
-      400,  400,  401,  401,  401,  401,  401,  401,  401,  401,
-      401,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
+       40,   37,   37,   37,   39,   53,   47,   46,   45,   38,
+       38,   38,   42,   39,   42,   44,   36,   36,   36,   43,
+       31,   18,  205,   40,   39,  205,   12,   40,   40,   40,
+        7,   39,   39,   39,   41,    6,    5,   41,    4,   42,
+       42,   42,  205,    3,   41,    0,   41,    0,   41,  205,
+        0,   66,    0,   41,   55,   55,   55,   55,   55,   55,
+        0,   41,   41,   41,   58,   58,   75,    0,   58,   58,
+       58,   58,   58,   58,   58,   62,   62,   66,   55,   62,
+       62,   62,   62,   62,   62,   62,   67,   67,   67,   67,
+       67,   67,   67,   75,   75,   75,   76,   76,   76,   76,
+
+       76,    0,    0,    0,   66,   66,   66,   80,   82,   82,
+       83,    0,   76,    0,   85,   86,    0,    0,   85,    0,
+        0,    0,    0,   86,   82,   83,   82,    0,   80,   82,
+       76,    0,    0,   84,   80,   80,   80,   83,   83,   83,
+       84,   88,   82,    0,   82,   85,   85,   85,   87,   82,
+       86,   86,   86,   88,   87,   76,   89,   90,    0,    0,
+       84,   84,   84,    0,   89,    0,    0,   91,   88,   88,
+       88,   92,    0,    0,   93,    0,   91,   92,    0,    0,
+        0,   87,   87,   87,   90,   90,   90,    0,   93,   95,
+        0,   89,   89,   89,   91,   91,   91,   94,   92,   92,
+
+       92,   93,   93,   93,   95,    0,    0,   94,    0,   94,
+       96,    0,   94,   97,    0,    0,   95,   95,   95,   96,
+       98,    0,   98,   99,   94,   94,   94,    0,  139,    0,
+       96,  101,    0,   97,  100,    0,   99,   96,   96,   96,
+       97,   97,   97,  102,  101,    0,  103,   98,   98,   98,
+       99,   99,   99,  104,  100,  139,  139,  139,  101,  101,
+      101,  100,  100,  100,  102,  106,    0,  103,  104,  105,
+      102,  102,  102,  103,  103,  103,  107,    0,    0,  109,
+      104,  104,  104,  110,  105,  106,  108,    0,    0,  111,
+      107,  111,  106,  106,  106,  110,  105,  105,  105,  109,
+
+      108,    0,  114,  107,  107,  107,  109,  109,  109,  113,
+      110,  110,  110,  108,  108,  108,  111,  111,  111,  112,
+      114,  112,    0,  115,  113,    0,  116,    0,    0,  114,
+      114,  114,    0,    0,    0,    0,  113,  113,  113,  115,
+        0,    0,  117,    0,    0,  118,  112,  112,  112,  116,
+      115,  115,  115,  116,  116,  116,  117,  120,    0,    0,
+      118,  138,    0,  119,    0,    0,  120,    0,    0,  117,
+      117,  117,  118,  118,  118,  119,  121,  132,  132,  132,
+      132,  132,  132,  132,  120,  120,  120,  138,    0,  130,
+      119,  119,  119,    0,  121,  130,  130,  130,  130,  130,
+
+      130,    0,    0,  121,  121,  121,  133,  133,  133,  133,
+      133,  133,  133,    0,  138,  138,  138,    0,  133,    0,
+      133,    0,    0,  133,  135,  135,  135,  135,  135,  135,
+      135,    0,    0,    0,    0,    0,  133,  149,  133,    0,
+      149,  150,    0,  133,  136,  136,  136,  136,  136,  136,
+      136,  140,  140,  140,  140,  140,  136,    0,  136,  151,
+        0,  136,    0,  154,  149,  149,  149,  140,  150,  150,
+      150,  152,    0,  152,  136,    0,  136,  154,    0,    0,
+      155,  136,    0,  157,  153,  140,  151,  151,  151,  156,
+        0,  153,  157,    0,  153,    0,  156,    0,  152,  152,
+
+      152,  158,    0,    0,  154,  154,  154,  155,  155,  155,
+      140,  153,  153,  153,  161,    0,  156,  156,  156,  157,
+      157,  157,  158,    0,  159,  164,  161,  160,  158,  158,
+      158,  159,  160,  162,    0,    0,  164,    0,    0,  162,
+      163,  161,  161,  161,    0,  165,    0,    0,    0,    0,
+        0,  159,  159,  159,  160,  160,  160,    0,  163,  168,
+      162,  162,  162,  164,  164,  164,  165,  163,  163,  163,
+      166,    0,  165,  165,  165,  167,    0,  168,  169,    0,
+        0,  167,  170,    0,  170,  166,  168,  168,  168,  171,
+        0,    0,    0,  172,  169,  171,  172,  166,  166,  166,
+
+      173,    0,  167,  167,  167,  169,  169,  169,    0,  170,
+      170,  170,  174,  173,  174,  175,  171,  171,  171,  181,
+      172,  172,  172,    0,    0,  176,  177,  173,  173,  173,
+      178,  181,    0,  180,  177,    0,  175,  178,  179,  174,
+      174,  174,  175,  175,  175,  176,  181,  181,  181,  182,
+      180,  176,  179,  177,  177,  177,  179,  178,  178,  178,
+      180,  180,  180,  183,    0,    0,  185,  182,    0,  184,
+        0,    0,  176,  176,  176,  184,  182,  182,  182,  179,
+      179,  179,  186,    0,  183,  187,  185,    0,    0,  189,
+      183,  183,  183,  185,  185,  185,  184,  184,  184,  187,
+
+      197,    0,  186,    0,  189,  188,    0,    0,    0,  186,
+      186,  186,  187,  187,  187,  188,  189,  189,  189,  190,
+      193,  193,  193,  193,  193,  193,  197,    0,    0,  190,
+      208,    0,  188,  188,  188,  198,  198,  198,  198,  198,
+      198,  198,  208,  209,    0,    0,  190,  190,  190,  210,
+        0,  212,  211,  197,  197,  197,  213,  208,  208,  208,
+      214,  215,    0,  209,  212,    0,  211,  214,    0,    0,
+      209,  209,  209,    0,  216,  215,  210,  210,  210,  211,
+      211,  211,    0,  213,  213,  213,  216,  217,  215,  215,
+      215,  212,  212,  212,  214,  214,  214,  217,  218,    0,
+
+        0,  216,  216,  216,  219,    0,    0,  220,    0,    0,
+      218,  221,    0,    0,  217,  217,  217,    0,    0,  223,
+      220,  221,  222,    0,  219,  218,  218,  218,  224,  222,
+        0,  219,  219,  219,  220,  220,  220,  223,  221,  221,
+      221,  225,  227,    0,  226,    0,  223,  223,  223,  222,
+      222,  222,  228,  233,    0,  224,  224,  224,    0,  226,
+      227,    0,    0,  229,    0,    0,  228,  230,  225,  225,
+      225,  226,  226,  226,  233,  229,    0,  231,    0,  228,
+      228,  228,  232,    0,    0,  234,    0,  227,  227,  227,
+      229,  229,  229,  234,  230,  230,  230,  231,  232,  235,
+
+        0,  233,  233,  233,  231,  231,  231,  236,  238,  232,
+      232,  232,  234,  234,  234,    0,  237,    0,    0,    0,
+      236,  237,    0,  239,    0,    0,  235,  235,  235,  238,
+      241,    0,    0,  240,  241,  238,  238,  238,    0,    0,
+        0,    0,    0,  237,  237,  237,  242,  236,  236,  236,
+      239,  239,  239,  240,  253,    0,  244,  241,  241,  241,
+      240,  240,  240,  243,    0,  242,  246,    0,    0,  243,
+      245,    0,    0,  242,  242,  242,  244,    0,  245,  246,
+      253,    0,  244,  247,    0,    0,  248,    0,  248,  264,
+      243,  243,  243,  246,  246,  246,  261,  245,  245,  245,
+
+      264,  247,  261,  244,  244,  244,    0,  253,  253,  253,
+      247,  247,  247,  248,  248,  248,  254,  254,  254,  254,
+      254,  262,    0,  261,  261,  261,  263,  264,  264,  264,
+      262,  265,  254,  266,    0,    0,  263,  267,    0,  267,
+      265,    0,    0,  268,  266,  268,    0,  269,    0,  269,
+      254,    0,  270,  263,  263,  263,  270,  262,  262,  262,
+      266,  266,  266,    0,  267,  267,  267,  265,  265,  265,
+      268,  268,  268,  272,    0,  254,  269,  269,  269,  270,
+      270,  270,  271,    0,  271,  272,  273,    0,    0,  274,
+        0,  274,    0,  273,    0,    0,    0,    0,  275,    0,
+
+      272,  272,  272,  277,    0,  279,  278,    0,    0,  271,
+      271,  271,  278,  273,  273,  273,  274,  274,  274,  275,
+      280,    0,  277,  279,    0,  275,  275,  275,  282,  285,
+      277,  277,  277,  278,  278,  278,  281,    0,    0,  282,
+        0,    0,  281,  288,  287,    0,  283,  280,  280,  280,
+      279,  279,  279,  283,  284,  289,  285,  285,  285,  286,
+      284,    0,  287,  281,  281,  281,  282,  282,  282,  290,
+      288,  288,  288,  283,  283,  283,  289,  290,    0,  286,
+      291,  284,  284,  284,  292,    0,  286,  286,  286,  287,
+      287,  287,  302,    0,  292,  293,  290,  290,  290,  294,
+
+        0,  301,  294,  289,  289,  289,  302,  291,  291,  291,
+      301,  292,  292,  292,  303,  293,    0,  304,    0,  302,
+      302,  302,  293,  293,  293,  305,  294,  294,  294,  305,
+      306,    0,  307,    0,  303,  306,    0,  301,  301,  301,
+      308,  303,  303,  303,  304,  304,  304,  309,    0,  309,
+        0,    0,  307,  311,  308,    0,  305,  305,  305,  307,
+      307,  307,  306,  306,  306,  312,    0,  308,  308,  308,
+      310,    0,    0,  311,  309,  309,  309,  312,  313,  310,
+      311,  311,  311,  314,    0,    0,  315,    0,    0,    0,
+      313,  314,  312,  312,  312,  317,    0,  310,  310,  310,
+
+      315,  319,    0,    0,  320,  313,  313,  313,  316,    0,
+      314,  314,  314,  315,  315,  315,    0,  321,  316,  319,
+      323,    0,  317,  317,  317,  326,    0,    0,  319,  319,
+      319,  320,  320,  320,  324,  316,  316,  316,  321,  325,
+      324,    0,    0,  327,  321,  321,  321,  323,  323,  323,
+      330,    0,  326,  326,  326,  327,    0,    0,  331,  325,
+        0,  324,  324,  324,  330,  331,  325,  325,  325,  332,
+      327,  327,  327,  334,    0,    0,  333,  330,  330,  330,
+      336,    0,    0,  334,  335,  331,  331,  331,  333,    0,
+      335,  337,  332,    0,  336,  339,  332,  332,  332,  338,
+
+      334,  334,  334,  337,  340,  338,    0,  336,  336,  336,
+      340,  335,  335,  335,    0,  333,  333,  333,  337,  337,
+      337,  343,  339,  339,  339,  342,  338,  338,  338,  341,
+      342,  340,  340,  340,  346,  341,  343,  344,    0,    0,
+      346,  345,    0,    0,    0,  347,    0,    0,  343,  343,
+      343,  347,  342,  342,  342,  344,  341,  341,  341,  345,
+      349,  346,  346,  346,  344,  344,  344,  349,  345,  345,
+      345,  350,  347,  347,  347,  353,    0,  351,  350,  352,
+        0,    0,    0,  353,    0,    0,  354,  349,  349,  349,
+      351,    0,  354,    0,    0,  355,    0,    0,  350,  350,
+
+      350,    0,  356,  352,    0,  357,  352,  352,  352,    0,
+      353,  353,  353,  354,  354,  354,  355,  351,  351,  351,
+      356,  358,  355,  355,  355,    0,  361,    0,    0,  356,
+      356,  356,  357,  357,  357,  358,  359,    0,    0,  360,
+        0,    0,  359,  363,  360,  361,  364,    0,  358,  358,
+      358,  365,    0,  361,  361,  361,  366,  365,    0,  369,
+        0,    0,  366,  359,  359,  359,  360,  360,  360,  367,
+      363,  363,  363,  364,  364,  364,  368,  371,  365,  365,
+      365,  369,  368,  366,  366,  366,    0,  370,  367,  375,
+        0,    0,  372,    0,    0,  371,  367,  367,  367,  374,
+
+        0,    0,    0,  368,  368,  368,  370,  373,  369,  369,
+      369,  372,  375,  376,  370,  370,  370,    0,  374,  372,
+      372,  372,  371,  371,  371,    0,  374,  374,  374,  373,
+        0,  376,    0,    0,  373,  373,  373,  378,    0,  375,
+      375,  375,  380,  378,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,  380,    0,    0,    0,  376,  376,
+      376,    0,    0,    0,  378,  378,  378,    0,    0,  380,
+      380,  380,  382,  382,  382,  382,  382,  382,  382,  382,
+      382,  382,  382,  382,  382,  382,  383,  383,  383,  383,
       383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383,  383,
-      383,  383,  383,  383,  383,  383,  383,  383,  383
 
+      384,  384,  384,  384,  384,  384,  384,  384,  384,  384,
+      384,  384,  384,  384,  385,  385,  385,  385,  385,  385,
+      385,  385,  385,  385,  385,  385,  385,  385,  386,    0,
+      386,    0,  386,    0,  386,  387,    0,    0,  387,    0,
+      387,  387,  387,  387,  387,  388,  388,    0,  388,  388,
+      388,  388,  388,  388,  389,  389,  389,  389,  389,  389,
+      389,  389,  389,  389,  389,  389,  389,  389,  390,  390,
+      390,  390,  390,  390,  390,  390,  390,  390,  390,  390,
+      390,  391,    0,  391,  391,  391,  391,  391,  391,  391,
+      391,  391,  391,  391,  391,  392,    0,  392,  392,  392,
+
+      392,  392,  392,  392,  392,  392,  392,  392,  392,  393,
+      393,  393,  393,  393,  393,  393,  393,  393,  394,  394,
+      394,  395,    0,    0,    0,    0,  395,  395,  395,  396,
+      396,  396,  396,  396,  397,  397,  397,    0,    0,  397,
+      398,  398,  398,  399,  399,  399,  399,  399,  399,  399,
+      399,  399,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381,
+      381,  381,  381,  381,  381,  381,  381,  381,  381,  381
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -1145,6 +1125,43 @@ char *ncgtext;
 #define XDR_INT64_MIN  (-9223372036854775807LL-1)
 #define XDR_INT64_MAX  (9223372036854775807LL)
 
+#undef DEBUG
+#ifdef DEBUG
+static int MIN_BYTE = NC_MIN_BYTE;
+static int MIN_SHORT = NC_MIN_SHORT;
+static int MIN_INT = NC_MIN_INT;
+static int MAX_BYTE = NC_MAX_BYTE;
+static int MAX_SHORT = NC_MAX_SHORT;
+static int MAX_INT = NC_MAX_INT;
+static int MAX_UBYTE = NC_MAX_UBYTE;
+static int MAX_USHORT = NC_MAX_USHORT;
+static unsigned int MAX_UINT = NC_MAX_UINT;
+
+#undef NC_MIN_BYTE
+#undef NC_MIN_SHORT
+#undef NC_MIN_INT
+#undef NC_MAX_BYTE
+#undef NC_MAX_SHORT
+#undef NC_MAX_INT
+#undef NC_MAX_UBYTE
+#undef NC_MAX_USHORT
+#undef NC_MAX_UINT
+
+#define NC_MIN_BYTE MIN_BYTE
+#define NC_MIN_SHORT MIN_SHORT
+#define NC_MIN_INT MIN_INT
+#define NC_MAX_BYTE MAX_BYTE
+#define NC_MAX_SHORT MAX_SHORT
+#define NC_MAX_INT MAX_INT
+#define NC_MAX_UBYTE MAX_UBYTE
+#define NC_MAX_USHORT MAX_USHORT
+#define NC_MAX_UINT MAX_UINT
+#endif
+
+#define TAG "BbSsLl"
+
+#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
+
 /*Mnemonics*/
 #define ISIDENT 1
 
@@ -1154,7 +1171,7 @@ int lineno;              /* line number for error messages */
 Bytebuffer* lextext;           /* name or string with escapes removed */
 
 #define YY_BREAK                /* defining as nothing eliminates unreachable
-				   statement warnings from flex output, 
+				   statement warnings from flex output,
                                    but make sure every action ends with
                                    "return" or "break"! */
 
@@ -1173,7 +1190,10 @@ unsigned char ubyte_val;       /* last byte value read */
 
 static Symbol* makepath(char* text);
 static int lexdebug(int);
-static int parseLL(char* text);
+static unsigned long long parseULL(char* text, int*);
+static nc_type downconvert(unsigned long long uint64, int, int, int);
+static int tagmatch(nc_type nct, int tag, int hasU);
+static int nct2lexeme(nc_type nct);
 
 static struct Specialtoken {
     char* name;
@@ -1234,7 +1254,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 1238 "ncgenyy.c"
+#line 1258 "ncgenyy.c"
 
 #define INITIAL 0
 #define ST_C_COMMENT 1
@@ -1418,9 +1438,9 @@ YY_DECL
 	register char *yy_cp, *yy_bp;
 	register int yy_act;
     
-#line 170 "ncgen.l"
+#line 208 "ncgen.l"
 
-#line 1424 "ncgenyy.c"
+#line 1444 "ncgenyy.c"
 
 	if ( !(yy_init) )
 		{
@@ -1473,13 +1493,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 384 )
+				if ( yy_current_state >= 382 )
 					yy_c = yy_meta[(unsigned int) yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			++yy_cp;
 			}
-		while ( yy_base[yy_current_state] != 2232 );
+		while ( yy_base[yy_current_state] != 2153 );
 
 yy_find_action:
 		yy_act = yy_accept[yy_current_state];
@@ -1505,22 +1525,22 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 171 "ncgen.l"
-{ /* whitespace */ 
-		  break;        
+#line 209 "ncgen.l"
+{ /* whitespace */
+		  break;
 		}
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 175 "ncgen.l"
-{ /* comment */ 
+#line 213 "ncgen.l"
+{ /* comment */
                           break;
                         }
 	YY_BREAK
 case 3:
 /* rule 3 can match eol */
 YY_RULE_SETUP
-#line 179 "ncgen.l"
+#line 217 "ncgen.l"
 {int len;
 			 /* In netcdf4, this will be used in a variety
                             of places, so only remove escapes */
@@ -1547,7 +1567,7 @@ ncgtext[MAXTRST-1] = '\0';
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 203 "ncgen.l"
+#line 241 "ncgen.l"
 { /* drop leading 0x; pad to even number of chars */
 		char* p = ncgtext+2;
 		int len = ncgleng - 2;
@@ -1562,113 +1582,113 @@ YY_RULE_SETUP
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 215 "ncgen.l"
+#line 253 "ncgen.l"
 {return lexdebug(COMPOUND);}
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 216 "ncgen.l"
+#line 254 "ncgen.l"
 {return lexdebug(ENUM);}
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 217 "ncgen.l"
+#line 255 "ncgen.l"
 {return lexdebug(OPAQUE);}
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 219 "ncgen.l"
+#line 257 "ncgen.l"
 {return lexdebug(FLOAT_K);}
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 220 "ncgen.l"
+#line 258 "ncgen.l"
 {return lexdebug(CHAR_K);}
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 221 "ncgen.l"
+#line 259 "ncgen.l"
 {return lexdebug(BYTE_K);}
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 222 "ncgen.l"
+#line 260 "ncgen.l"
 {return lexdebug(UBYTE_K);}
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 223 "ncgen.l"
+#line 261 "ncgen.l"
 {return lexdebug(SHORT_K);}
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 224 "ncgen.l"
+#line 262 "ncgen.l"
 {return lexdebug(USHORT_K);}
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 225 "ncgen.l"
+#line 263 "ncgen.l"
 {return lexdebug(INT_K);}
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 226 "ncgen.l"
+#line 264 "ncgen.l"
 {return lexdebug(UINT_K);}
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 227 "ncgen.l"
+#line 265 "ncgen.l"
 {return lexdebug(INT64_K);}
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 228 "ncgen.l"
+#line 266 "ncgen.l"
 {return lexdebug(UINT64_K);}
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 229 "ncgen.l"
+#line 267 "ncgen.l"
 {return lexdebug(DOUBLE_K);}
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 230 "ncgen.l"
+#line 268 "ncgen.l"
 {int32_val = -1;
 			 return lexdebug(NC_UNLIMITED_K);}
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 233 "ncgen.l"
+#line 271 "ncgen.l"
 {return lexdebug(TYPES);}
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 234 "ncgen.l"
+#line 272 "ncgen.l"
 {return lexdebug(DIMENSIONS);}
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 235 "ncgen.l"
+#line 273 "ncgen.l"
 {return lexdebug(VARIABLES);}
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 236 "ncgen.l"
+#line 274 "ncgen.l"
 {return lexdebug(DATA);}
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 237 "ncgen.l"
+#line 275 "ncgen.l"
 {return lexdebug(GROUP);}
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 239 "ncgen.l"
+#line 277 "ncgen.l"
 {BEGIN(TEXT);return lexdebug(NETCDF);}
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 241 "ncgen.l"
+#line 279 "ncgen.l"
 { /* missing value (pre-2.4 backward compatibility) */
                 if (ncgtext[0] == '-') {
 		    double_val = NEGNC_INFINITE;
@@ -1681,7 +1701,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 250 "ncgen.l"
+#line 288 "ncgen.l"
 { /* missing value (pre-2.4 backward compatibility) */
 		double_val = NAN;
 		specialconstants = 1;
@@ -1690,7 +1710,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 256 "ncgen.l"
+#line 294 "ncgen.l"
 {/* missing value (pre-2.4 backward compatibility)*/
                 if (ncgtext[0] == '-') {
 		    float_val = NEGNC_INFINITEF;
@@ -1703,7 +1723,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 265 "ncgen.l"
+#line 303 "ncgen.l"
 { /* missing value (pre-2.4 backward compatibility) */
 		float_val = NANF;
 		specialconstants = 1;
@@ -1712,7 +1732,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 271 "ncgen.l"
+#line 309 "ncgen.l"
 {
 #ifdef USE_NETCDF4
 		if(l_flag == L_C || l_flag == L_BINARY)
@@ -1725,7 +1745,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 281 "ncgen.l"
+#line 319 "ncgen.l"
 {
 		bbClear(lextext);
 		bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */
@@ -1736,7 +1756,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 290 "ncgen.l"
+#line 328 "ncgen.l"
 {struct Specialtoken* st;
 		bbClear(lextext);
 		bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */
@@ -1750,7 +1770,7 @@ YY_RULE_SETUP
 case 33:
 /* rule 33 can match eol */
 YY_RULE_SETUP
-#line 300 "ncgen.l"
+#line 338 "ncgen.l"
 {
 		    int c;
 		    char* p; char* q;
@@ -1769,7 +1789,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 316 "ncgen.l"
+#line 354 "ncgen.l"
 { char* id; int len;
 		    bbClear(lextext);
 		    bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */
@@ -1784,169 +1804,73 @@ YY_RULE_SETUP
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 328 "ncgen.l"
+#line 366 "ncgen.l"
 {
-		    /* We need to try to see what size of integer ((u)int). */
-		    /* Technically, the user should specify, but... */
-		    /* If out of any integer range, then complain */
-		    switch (parseLL(ncgtext)) {
-		    case 0:
-			return lexdebug(INT64_CONST); /* meaningless */
-		    case -1:
-#ifdef USE_NETCDF4
-		        if(int64_val >= NC_MIN_INT) {
-			    int32_val = (int)int64_val;
-		            return lexdebug(INT_CONST);
-			} else
-		            return lexdebug(INT64_CONST);
-#else
-			/* Convert to int32, unless overflow then complain  */
-			if(int64_val >=NC_MIN_INT) {
-			    int32_val = (int)int64_val;
-			} else {
-			   sprintf(errstr,"32 bit integer constant out of range: %s",(char*)ncgtext);
-			   yyerror(errstr);
-			}
-		        return lexdebug(INT_CONST);		    
-#endif
-		    case 1:
-#ifdef USE_NETCDF4
- 		        if(uint64_val <= NC_MAX_INT) {
-			    int32_val = (int)uint64_val;
-		            return lexdebug(INT_CONST);
- 		        } else if(uint64_val <= NC_MAX_UINT) {
-			    uint32_val = (unsigned int)uint64_val;
-		            return lexdebug(UINT_CONST);
- 		        } else if(uint64_val <= NC_MAX_INT64) {
-			    int64_val = (long long)uint64_val;
-		            return lexdebug(INT64_CONST);
-			} else
-		            return lexdebug(UINT64_CONST);
-#else
-			/* Convert to int32 but complain if overflow */
-			if(uint64_val > NC_MAX_INT) {
-			    sprintf(errstr,"32 bit integer constant out of range: %s",(char*)ncgtext);
-			    yyerror(errstr);
+/*
+We need to try to see what size of integer ((u)int).
+Technically, the user should specify, but...
+If out of any integer range, then complain
+*/
+		    int slen = strlen(ncgtext);
+		    int tag = ncgtext[slen-1];
+		    int hasU = 0;
+		    int signchar = 0;
+		    int isneg = 0;
+		    int c = ncgtext[0];
+		    int fail = 0;
+		    nc_type nct = 0;
+		    char* pos = NULL;
+
+		    if(!tstdecimal(c)) {
+			pos = ncgtext+1;
+			isneg = (c == '-');
+		    } else
+		        pos = ncgtext;
+		    if(tag != '\0' && strchr(TAG,tag) != NULL) {
+			if(slen > 2) {
+			    c = ncgtext[slen-2];
+			    hasU = (c == 'U' || c == 'u') ? 1 : 0;
 			}
-			int32_val = (int)uint64_val;
-			return lexdebug(INT_CONST);
-#endif
-                     default:
-                         yyerror("Unknown integer size");
+		    } else
+			tag = 0;
+		    if(isneg && hasU) {
+			sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
+			yyerror(errstr);
+			goto done;
 		    }
-		}
-	YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 379 "ncgen.l"
-{ /* The number may be signed or unsigned (signed has priority) */
-		int slen = strlen(ncgtext);
-		int tag = ncgtext[slen-1];
-		int token = 0;
-		switch (tag) {
-		case 'B': case 'b':
-		    if (sscanf((char*)ncgtext, "%d", &int32_val) != 1) {
-		        sprintf(errstr,"bad byte constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-		    } else if(int32_val >= NC_MIN_BYTE && int32_val <= NC_MAX_BYTE) {
-		        byte_val = (signed char)int32_val;
-		        token = BYTE_CONST;
-		    } else if(int32_val >= 0 && int32_val <= NC_MAX_UBYTE) {
-		        ubyte_val = (unsigned char)int32_val;
-		        token = UBYTE_CONST;
-		    } else {
-		        sprintf(errstr,"bad byte constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
+		    uint64_val = parseULL(pos,&fail);
+		    if(fail) {
+			sprintf(errstr,"integer constant out of range: %s",ncgtext);
+			yyerror(errstr);
+			goto done;
 		    }
-		    break;
-		case 'S': case 's':
-		    if (sscanf((char*)ncgtext, "%d", &int32_val) != 1) {
-		        sprintf(errstr,"bad short constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-		    } else if(int32_val >= NC_MIN_SHORT && int32_val <= NC_MAX_SHORT) {
-		        int16_val = (signed short)int32_val;
-		        token = SHORT_CONST;
-		    } else if(int32_val >= 0 && int32_val <= NC_MAX_USHORT) {
-		        uint16_val = (unsigned short)int32_val;
-		        token = USHORT_CONST;
-		    } else {
-		        sprintf(errstr,"bad short constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
+		    /* Down convert to smallest possible range */
+		    nct = downconvert(uint64_val,isneg,tag,hasU);
+		    switch (k_flag) {
+		    case NC_FORMAT_64BIT_DATA:
+		    case NC_FORMAT_NETCDF4:
+			    return lexdebug(nct2lexeme(nct));
+		    case NC_FORMAT_CLASSIC:
+		    case NC_FORMAT_64BIT_OFFSET:
+		    case NC_FORMAT_NETCDF4_CLASSIC:
+			    if(nct > NC_INT) {
+				sprintf(errstr,"Illegal integer constant for classic format: %s",ncgtext);
+				yyerror(errstr);
+				goto done;
+			    }
 		    }
-		    break;
-		case 'L': case 'l':
-		    switch(parseLL(ncgtext)) {
-		    case 0:
-		        sprintf(errstr,"bad int64 constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-			break;
-		    case -1: token = INT64_CONST; break;
-		    case 1:
-			/* if value is too big, complain */
-			/* cannot actually test this.
-		        if(uint64_val > NC_MAX_INT64) {
-			   sprintf(errstr,"64 bit integer constant out of range: %s",(char*)ncgtext);
-			   yyerror(errstr);
-			}
-                        */
-		        int64_val = (long long)(uint64_val & 0x7fffffffffffffffLL);
-			token = INT64_CONST;
-			break;
+		    if(!tagmatch(nct,tag,hasU))  {
+			sprintf(errstr,"Integer out of range for tag: %s",ncgtext);
+			yyerror(errstr);
+			goto done;
 		    }
-		    break;
-		default:/*(optionally)signed string of digits; treat like int*/
-		    sprintf(errstr,"bad numeric constant: %s",(char*)ncgtext);
-		    yyerror(errstr);
-		}
-		return lexdebug(token);
+		    return lexdebug(nct2lexeme(nct));
+done: return 0;
 	    }
 	YY_BREAK
-case 37:
-YY_RULE_SETUP
-#line 441 "ncgen.l"
-{
-		int slen = strlen(ncgtext);
-		int tag = ncgtext[slen-1];
-		int token = 0;
-		switch (tag) {
-		case 'B': case 'b':
-		    if (sscanf((char*)ncgtext, "%u", &uint32_val) != 1
-		        || uint32_val > NC_MAX_UBYTE) {
-		        sprintf(errstr,"bad unsigned byte constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-		    }
-		    ubyte_val = (unsigned char)uint32_val;
-		    token = UBYTE_CONST;
-		    break;
-		case 'S': case 's':
-		    if (sscanf((char*)ncgtext, "%u", &uint32_val) != 1
-		        || uint32_val > NC_MAX_USHORT) {
-		        sprintf(errstr,"bad unsigned short constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-		    }
-		    uint16_val = (unsigned short)uint32_val;
-		    token = USHORT_CONST;
-		    break;
-		case 'L': case 'l':
-		    if (sscanf((char*)ncgtext, "%llu", &uint64_val) != 1) {
-		        sprintf(errstr,"bad unsigned int64 constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-		    }
-		    token = UINT64_CONST;
-		    break;
-		default: /* string of digits; treat like int */
-		    if (sscanf((char*)ncgtext, "%u", &uint32_val) != 1) {
-		        sprintf(errstr,"bad unsigned int constant: %s",(char*)ncgtext);
-		        yyerror(errstr);
-		    }
-		    token = UINT_CONST;
-		}
-		return lexdebug(token);
-	    }
-	YY_BREAK
-case 38:
+case 36:
 YY_RULE_SETUP
-#line 480 "ncgen.l"
+#line 429 "ncgen.l"
 {
 		int c;
 		int token = 0;
@@ -1982,9 +1906,9 @@ YY_RULE_SETUP
 		return lexdebug(token);
 	    }
 	YY_BREAK
-case 39:
+case 37:
 YY_RULE_SETUP
-#line 514 "ncgen.l"
+#line 463 "ncgen.l"
 {
 		if (sscanf((char*)ncgtext, "%le", &double_val) != 1) {
 		    sprintf(errstr,"bad long or double constant: %s",(char*)ncgtext);
@@ -1993,9 +1917,9 @@ YY_RULE_SETUP
                 return lexdebug(DOUBLE_CONST);
                 }
 	YY_BREAK
-case 40:
+case 38:
 YY_RULE_SETUP
-#line 521 "ncgen.l"
+#line 470 "ncgen.l"
 {
 		if (sscanf((char*)ncgtext, "%e", &float_val) != 1) {
 		    sprintf(errstr,"bad float constant: %s",(char*)ncgtext);
@@ -2004,44 +1928,44 @@ YY_RULE_SETUP
                 return lexdebug(FLOAT_CONST);
                 }
 	YY_BREAK
-case 41:
-/* rule 41 can match eol */
+case 39:
+/* rule 39 can match eol */
 YY_RULE_SETUP
-#line 528 "ncgen.l"
+#line 477 "ncgen.l"
 {
 	        (void) sscanf((char*)&ncgtext[1],"%c",&byte_val);
 		return lexdebug(BYTE_CONST);
                 }
 	YY_BREAK
-case 42:
+case 40:
 YY_RULE_SETUP
-#line 532 "ncgen.l"
+#line 481 "ncgen.l"
 {
 		int oct = unescapeoct(&ncgtext[2]);
 		if(oct < 0) {
 		    sprintf(errstr,"bad octal character constant: %s",(char*)ncgtext);
 		    yyerror(errstr);
-		}		    		    
+		}
 	        byte_val = (unsigned int)oct;
 		return lexdebug(BYTE_CONST);
                 }
 	YY_BREAK
-case 43:
+case 41:
 YY_RULE_SETUP
-#line 541 "ncgen.l"
+#line 490 "ncgen.l"
 {
 		int hex = unescapehex(&ncgtext[3]);
 		if(byte_val < 0) {
 		    sprintf(errstr,"bad hex character constant: %s",(char*)ncgtext);
 		    yyerror(errstr);
-		}		    		    
+		}
 		byte_val = (unsigned int)hex;
 		return lexdebug(BYTE_CONST);
                 }
 	YY_BREAK
-case 44:
+case 42:
 YY_RULE_SETUP
-#line 550 "ncgen.l"
+#line 499 "ncgen.l"
 {
 	       switch ((char)ncgtext[2]) {
 	          case 'a': byte_val = '\007'; break; /* not everyone under-
@@ -2060,60 +1984,60 @@ YY_RULE_SETUP
 		return lexdebug(BYTE_CONST);
                 }
 	YY_BREAK
-case 45:
-/* rule 45 can match eol */
+case 43:
+/* rule 43 can match eol */
 YY_RULE_SETUP
-#line 568 "ncgen.l"
+#line 517 "ncgen.l"
 {
 		lineno++ ;
                 break;
 		}
 	YY_BREAK
-case 46:
+case 44:
 YY_RULE_SETUP
-#line 573 "ncgen.l"
+#line 522 "ncgen.l"
 {/*initial*/
 	    BEGIN(ST_C_COMMENT);
 	    break;
 	}
 	YY_BREAK
-case 47:
-/* rule 47 can match eol */
+case 45:
+/* rule 45 can match eol */
 YY_RULE_SETUP
-#line 578 "ncgen.l"
+#line 527 "ncgen.l"
 {/* continuation */
 				     break;
 				}
 	YY_BREAK
-case 48:
+case 46:
 YY_RULE_SETUP
-#line 582 "ncgen.l"
+#line 531 "ncgen.l"
 {/* final */
 			    BEGIN(INITIAL);
 			    break;
 			}
 	YY_BREAK
 case YY_STATE_EOF(ST_C_COMMENT):
-#line 587 "ncgen.l"
+#line 536 "ncgen.l"
 {/* final, error */
 			    fprintf(stderr,"unterminated /**/ comment");
 			    BEGIN(INITIAL);
 			    break;
 			}
 	YY_BREAK
-case 49:
+case 47:
 YY_RULE_SETUP
-#line 593 "ncgen.l"
+#line 542 "ncgen.l"
 {/* Note: this next rule will not work for UTF8 characters */
 		return lexdebug(ncgtext[0]) ;
 		}
 	YY_BREAK
-case 50:
+case 48:
 YY_RULE_SETUP
-#line 596 "ncgen.l"
+#line 545 "ncgen.l"
 ECHO;
 	YY_BREAK
-#line 2117 "ncgenyy.c"
+#line 2041 "ncgenyy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(TEXT):
 	yyterminate();
@@ -2406,7 +2330,7 @@ static int yy_get_next_buffer (void)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 384 )
+			if ( yy_current_state >= 382 )
 				yy_c = yy_meta[(unsigned int) yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -2434,11 +2358,11 @@ static int yy_get_next_buffer (void)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 384 )
+		if ( yy_current_state >= 382 )
 			yy_c = yy_meta[(unsigned int) yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-	yy_is_jam = (yy_current_state == 383);
+	yy_is_jam = (yy_current_state == 381);
 
 	return yy_is_jam ? 0 : yy_current_state;
 }
@@ -3112,7 +3036,7 @@ void ncgfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 596 "ncgen.l"
+#line 545 "ncgen.l"
 
 
 static int
@@ -3185,7 +3109,7 @@ makepath(char* text0)
 		    refsym->subnodes = listnew();
 		}
 		container = refsym;
-	        ident=p+1; p=ident;		
+	        ident=p+1; p=ident;
 	        break;
 	    }
 	} while(c != '\0');
@@ -3195,42 +3119,190 @@ makepath(char* text0)
     return refsym;
 }
 
-
-static int
-parseLL(char* text)
+/*
+Parse a simple string of digitis into an unsigned long long
+Return the value.
+*/
+static unsigned long long
+parseULL(char* text, int* failp)
 {
     int result = 0;
-#if defined(HAVE_STRTOLL) && defined(HAVE_STRTOULL)
     extern int errno;
     char* endptr;
+    unsigned long long uint64 = 0;
+
     errno = 0; endptr = NULL;
-    if(text[0] == '-') {
-        int64_val = strtoll(text,&endptr,10);
-	result = -1; /* negative int64_val */	
-    } else {
-        uint64_val = strtoull(text,&endptr,10);
-	result = 1; /* positive uint64_val */	
+    assert(tstdecimal(text[0]));
+#ifdef HAVE_STRTOULL
+    uint64 = strtoull(text,&endptr,10);
+    if(errno == ERANGE) {
+	if(failp) *failp = ERANGE;
+	return 0;
     }
-    if(result == 0) {
-	sprintf(errstr,"Unparseable 64 bit integer constant: %s",(char*)text);
-	yyerror(errstr);
-    } else if(errno == ERANGE) {
-	sprintf(errstr,"64 bit integer constant out of range: %s",(char*)text);
-	yyerror(errstr);
-	result = 0; /* out of range */
-    }			
 #else /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/
-    if(text[0] == '-') {
-        sscanf((char*)text, "%lld", &int64_val);
-	result = -1; /* negative int64_val */	
-    } else {
-	sscanf((char*)text, "%llu", &uint64_val);
-	result = 1; /* positive uint64_val */	
-    }
+    sscanf((char*)text, "%llu", &uint64);
     /* Have no useful way to detect out of range */
 #endif /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/
-    return result;
+    return uint64;
+}
+
+
+/**
+Given the raw bits, the sign char, the tag, and hasU
+fill in the appropriate *_val field
+and return the type
+*/
+static nc_type
+downconvert(unsigned long long uint64, int isneg, int tag, int hasU)
+{
+    nc_type nct = NC_NAT;
+    int bit64 = (uint64 >> 63);
+    int allones = (uint64 == 0xffffffffffffffffUL);
+    long long int64 = *((long long*)&uint64);
+
+    if(isneg && hasU)
+	return NC_NAT;
+    /* Special cases: all (u)int64 values */
+    if(allones && (hasU || !isneg)) /* bare max uint64 value */
+	return NC_UINT64;
+    if((int64 < NC_MIN_INT) || (int64 > NC_MAX_INT)) {
+	if(isneg && !hasU) {
+	    int64_val = - int64;
+	    return NC_INT64;
+	}
+	if(!isneg && hasU) {
+	    uint64_val = uint64;
+	    return NC_UINT64;
+	}
+	/* Bare big integer, assume int64 unless sign bit set */
+	if(!isneg && !hasU && bit64) {
+	    uint64_val = uint64;
+	    return NC_UINT64;
+	} else if(!bit64) {
+	    int64_val = int64;
+	    return NC_INT64;
+	}
+        /*assert(!isneg)*/
+        uint64_val = uint64;
+	return NC_UINT64;
+    }
+
+    if(isneg) int64 = -int64;
+
+    /* special case:
+       If there is no tag and the size is ok,
+       then always return NC_INT or NC_UINT.
+    */
+    if(!tag) {
+	if(!hasU) {
+	    if((int64 >= NC_MIN_INT) && (int64 <= NC_MAX_INT)) {
+		int32_val = (int)int64;
+	        return NC_INT;
+	    }
+	}
+	if(uint64 <= NC_MAX_UINT) {
+	    uint32_val = (unsigned int)uint64;
+	    return NC_INT;
+	}
+    }
+    /* assert (tag != 0) */
+
+    /* Pick smallest enclosing type;
+       for historical reasons (ncgen3), technically out of range
+       values are allowed and conversion is attempted;
+	e.g. 65535s; is legal and is return as an unsigned short.
+    */
+    if(hasU) {
+        switch (tag) {
+        case 'B': case 'b':
+	    if((int64 >= 0) && (int64 <= NC_MAX_UBYTE)) {
+	        nct = NC_UBYTE;
+	        ubyte_val = (unsigned char)int64;
+	    }; break;
+        case 'S': case 's':
+	    if((int64 >= 0) && (int64 <= NC_MAX_USHORT)) {
+	        nct = NC_USHORT;
+	        uint16_val = (unsigned short)int64;
+	    } break;
+        case 'L': case 'l':
+            if((int64 >= 0) && (int64 <= NC_MAX_UINT64)) {
+	        nct = NC_UINT64;
+	        uint64_val = uint64;
+	    } break;
+	default:
+	    return NC_NAT;
+	}
+    } else { /* !hasU */
+        switch (tag) {
+        case 'B': case 'b':
+            if((int64 >= NC_MIN_BYTE) && (int64 <= NC_MAX_BYTE)) {
+	        nct = NC_BYTE;
+	        byte_val = (signed char)int64;
+	    } else {/* force to unsigned value */
+		uint64_val = uint64 & 0xff;
+		nct = NC_UBYTE;
+	    }
+	    break;
+        case 'S': case 's':
+	    if((int64 >= NC_MIN_SHORT) && (int64 <= NC_MAX_SHORT)) {
+	        nct = NC_SHORT;
+	        int16_val = (signed short)int64;
+	    } else {/* force to unsigned value */
+		uint64_val = uint64 & 0xffff;
+		nct = NC_USHORT;
+	    }
+	    break;
+        case 'L': case 'l':
+            if((uint64 <= NC_MAX_INT64)) {
+	        nct = NC_INT64;
+	        int64_val = int64;
+	    } else {/* force to unsigned value */
+		uint64_val = uint64;
+		nct = NC_UINT64;
+	    }
+	    break;
+	default:
+	    return NC_NAT;
+	}
+    }
+    return nct;
 }
 
+static int
+nct2lexeme(nc_type nct)
+{
+    switch(nct) {
+    case NC_BYTE: return BYTE_CONST;
+    case NC_CHAR: return CHAR_CONST;
+    case NC_SHORT: return SHORT_CONST;
+    case NC_INT: return INT_CONST;
+    case NC_UBYTE: return UBYTE_CONST;
+    case NC_USHORT: return USHORT_CONST;
+    case NC_UINT: return UINT_CONST;
+    case NC_INT64: return INT64_CONST;
+    case NC_UINT64: return UINT64_CONST;
+    }
+    return 0;
+}
+
+
+static int
+tagmatch(nc_type nct, int tag, int hasU)
+{
+    if(hasU) switch(nct) {
+        case NC_UBYTE: return (tag == 0 || tag == 'B' || tag == 'b');
+        case NC_USHORT: return (tag == 0 || tag == 'S' || tag == 's');
+        case NC_UINT: return (tag == 0);
+        case NC_UINT64: return (tag == 0 || tag == 'L' || tag == 'l');
+	default: return 0;
+    } else switch(nct) {
+	case NC_BYTE: return (tag == 0 || tag == 'B' || tag == 'b');
+	case NC_SHORT: return (tag == 0 || tag == 'S' || tag == 's');
+	case NC_INT: return (tag == 0);
+	case NC_INT64: return (tag == 0 || tag == 'L' || tag == 'l');
+	default: return 0;
+    }
+    return 0;
+}
 
 
diff --git a/ncgen/run_tests.sh b/ncgen/run_tests.sh
index 5bd3d7b..fc1bdc8 100755
--- a/ncgen/run_tests.sh
+++ b/ncgen/run_tests.sh
@@ -2,12 +2,33 @@
 # This shell script runs the ncgen tests.
 # $Id: run_tests.sh,v 1.10 2010/04/04 22:06:03 dmh Exp $
 
+if test "x$srcdir" = x ; then
+srcdir="."
+fi
+
 echo "*** Testing ncgen."
 set -e
 echo "*** creating classic file c0.nc from c0.cdl..."
 ./ncgen -b -o c0.nc $srcdir/c0.cdl
+if [ ! -f c0.nc ]; then
+    echo "Failure."
+    exit 1
+fi
+
 echo "*** creating 64-bit offset file c0_64.nc from c0.cdl..."
 ./ncgen -k 64-bit-offset -b -o c0_64.nc $srcdir/c0.cdl
+if [ ! -f c0_64.nc ]; then
+    echo "Failure."
+    exit 1
+fi
+
+echo "*** creating 64-bit offset file c5.nc from c5.cdl..."
+./ncgen -k 64-bit-data -b -o c5.nc $srcdir/c5.cdl
+if [ ! -f c5.nc ]; then
+    echo "Failure."
+    exit 1
+fi
+
 
 echo "*** Test successful!"
 exit 0
diff --git a/ncgen/semantics.c b/ncgen/semantics.c
index bca47f7..5a941f9 100644
--- a/ncgen/semantics.c
+++ b/ncgen/semantics.c
@@ -823,15 +823,8 @@ inferattributetype(Symbol* asym)
         asym->typ.basetype = basetypefor(NC_CHAR);
     else if(usingclassic) {
         /* If we are in classic mode, then restrict the inferred type
-           to the classic types */
+           to the classic or cdf5 atypes */
 	switch (nctype) {
-	case NC_UBYTE:
-	    nctype = NC_SHORT;
-	    break;	
-	case NC_USHORT:
-	case NC_UINT:
-	case NC_INT64:
-	case NC_UINT64:
 	case NC_OPAQUE:
 	case NC_ENUM:
 	    nctype = NC_INT;
@@ -1007,7 +1000,7 @@ computeunlimitedsizes(Dimset* dimset, int dimindex, Datalist* data, int ischar)
     xproduct = crossproduct(dimset,dimindex+1,nextunlim);
 
     if(!lastunlim) {
-	/* Compute candiate size of this unlimited */
+	/* Compute candidate size of this unlimited */
         length = data->length;
 	unlimsize = length / xproduct;
 	if(length % xproduct != 0)
diff --git a/ncgen3/Makefile.in b/ncgen3/Makefile.in
index 5c71726..7751bd4 100644
--- a/ncgen3/Makefile.in
+++ b/ncgen3/Makefile.in
@@ -450,6 +450,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -482,6 +483,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -493,6 +495,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/ncgen3/c0.cdl b/ncgen3/c0.cdl
index 5a1455c..edc932d 100644
--- a/ncgen3/c0.cdl
+++ b/ncgen3/c0.cdl
@@ -159,7 +159,8 @@ data:
 
  d2 = -1e+308, 1e+308 ;
 
- c3 = "\001\177." ;
+// c3 = "\001\300." ; This is actually illegal utf8
+   c3 = "\001\177." ;
 
  b3 = -128, 127, -1 ;
 
diff --git a/ncgen3/escapes.c b/ncgen3/escapes.c
index 737fac0..0e746ba 100644
--- a/ncgen3/escapes.c
+++ b/ncgen3/escapes.c
@@ -12,7 +12,7 @@
 
 /*
  * "Expands" valid escape sequences in yystring (read by lex) into the
- * apropriate characters in termstring.  For example, the two character
+ * appropriate characters in termstring.  For example, the two character
  * sequence "\t" in yystring would be converted into a single tab character
  * in termstring.  On return, termstring is properly terminated.
  */
diff --git a/ncgen3/genlib.c b/ncgen3/genlib.c
index c38efac..177e45c 100644
--- a/ncgen3/genlib.c
+++ b/ncgen3/genlib.c
@@ -860,7 +860,7 @@ cline(
 }
 
 /*
- * From a long line FORTRAN statment, generates the necessary FORTRAN
+ * From a long line FORTRAN statement, generates the necessary FORTRAN
  * lines with continuation characters in column 6.  If stmnt starts with "*",
  * it is treated as a one-line comment.  Statement labels are *not* handled,
  * but since we don't generate any labels, we don't care.
diff --git a/ncgen3/main.c b/ncgen3/main.c
index f86e720..da8bb91 100644
--- a/ncgen3/main.c
+++ b/ncgen3/main.c
@@ -176,10 +176,10 @@ main(
 		    return(1);
 		}
 		(void)strcpy(kind_name, optarg);
-		/* The default kind is kind 1, with 32-bit offsets */
+		/* The default kind is kind 1 (classic), with 32-bit offsets */
 		if (strcmp(kind_name, "1") == 0 || 
 		    strcmp(kind_name, "classic") == 0) {
-		    cmode_modifier = 0;
+		    cmode_modifier |= NC_CLASSIC_MODEL;
 		}
 		/* The 64-bit offset kind (2)  should only be used if actually needed */
 		else if (strcmp(kind_name, "2") == 0 || 
diff --git a/ncgen3/run_nc4_tests.sh b/ncgen3/run_nc4_tests.sh
index b4fe95f..4dc8a77 100755
--- a/ncgen3/run_nc4_tests.sh
+++ b/ncgen3/run_nc4_tests.sh
@@ -2,6 +2,10 @@
 # This shell script runs the ncdump tests.
 # $Id: run_nc4_tests.sh,v 1.3 2009/09/24 18:19:10 dmh Exp $
 
+if test "x$srcdir" = x ; then
+srcdir=`pwd`
+fi
+
 echo "*** Testing ncgen3 for netCDF-4."
 set -e
 echo "*** creating netCDF-4 file c0_4.nc from c0.cdl..."
diff --git a/ncgen3/run_tests.sh b/ncgen3/run_tests.sh
index 776ba09..c31e08a 100755
--- a/ncgen3/run_tests.sh
+++ b/ncgen3/run_tests.sh
@@ -4,6 +4,11 @@
 
 echo "*** Testing ncgen3."
 set -e
+
+if test "x$srcdir" = x ;then
+srcdir=`pwd`
+fi
+
 echo "*** creating classic file c0.nc from c0.cdl..."
 ./ncgen3 -b -o c0.nc $srcdir/c0.cdl
 echo "*** creating 64-bit offset file c0_64.nc from c0.cdl..."
diff --git a/nctest/CMakeLists.txt b/nctest/CMakeLists.txt
index d1ac3d5..c1f0dda 100644
--- a/nctest/CMakeLists.txt
+++ b/nctest/CMakeLists.txt
@@ -1,19 +1,15 @@
 SET(nctest_SRC add.c atttests.c cdftests.c dimtests.c driver.c emalloc.c error.c misctest.c rec.c slabs.c val.c vardef.c varget.c vargetg.c varput.c varputg.c vartests.c vputget.c vputgetg.c)
 
-FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc)
+FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
 FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
 
+###
+# Can't use macro since
+# there are multiple sources.
+###
 ADD_EXECUTABLE(nctest ${nctest_SRC})
-ADD_EXECUTABLE(tst_rename tst_rename.c)
-
 TARGET_LINK_LIBRARIES(nctest netcdf)
-TARGET_LINK_LIBRARIES(tst_rename netcdf)
-
 ADD_TEST(nctest ${EXECUTABLE_OUTPUT_PATH}/nctest)
-ADD_TEST(tst_rename ${EXECUTABLE_OUTPUT_PATH}/tst_rename)
 
-## Specify files to be distributed by 'make dist'
-FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
-SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
-SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ref_nctest_classic.nc ref_nctest_64bit_offset.nc)
-ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
+add_bin_test_no_prefix(tst_rename)
+add_sh_test(nctest compare_test_files)
\ No newline at end of file
diff --git a/nctest/Makefile.in b/nctest/Makefile.in
index 58b087c..484d8de 100644
--- a/nctest/Makefile.in
+++ b/nctest/Makefile.in
@@ -459,6 +459,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -491,6 +492,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -502,6 +504,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
diff --git a/nctest/atttests.c b/nctest/atttests.c
index 38153aa..5e3a437 100644
--- a/nctest/atttests.c
+++ b/nctest/atttests.c
@@ -593,7 +593,7 @@ test_ncattget(path)
     }
     /* try getting non-existent attribute, should fail */
     if (ncattget(cdfid, uu_id, "nonesuch", vmax.val) != -1) {
-	error("%s: ncattget should fail with nonexistant attribute", pname);
+	error("%s: ncattget should fail with nonexistent attribute", pname);
 	ncclose(cdfid); return ++nerrs;
     }
     if (ncclose (cdfid) == -1) {
diff --git a/nctest/compare_test_files.sh b/nctest/compare_test_files.sh
index 6a43427..57c6d41 100755
--- a/nctest/compare_test_files.sh
+++ b/nctest/compare_test_files.sh
@@ -1,3 +1,8 @@
 #!/bin/sh
-cmp nctest_classic.nc $srcdir/ref_nctest_classic.nc && cmp nctest_64bit_offset.nc $srcdir/ref_nctest_64bit_offset.nc
+set -e
+if test "x$srcdir" = x ; then
+srcdir=`pwd`
+fi
+cmp nctest_classic.nc $srcdir/ref_nctest_classic.nc
+cmp nctest_64bit_offset.nc $srcdir/ref_nctest_64bit_offset.nc
 
diff --git a/nctest/driver.c b/nctest/driver.c
index 171c019..0830929 100644
--- a/nctest/driver.c
+++ b/nctest/driver.c
@@ -32,7 +32,7 @@ main(int argc, char **argv)
   /*EXTERNL int ncopts;	*/	/* netCDF error options */
     char *testfiles[] = {"nonesuch", "nctest_classic.nc", 
 			 "nctest_64bit_offset.nc", "nctest_netcdf4.nc"};
-    char *testfile;
+    char *testfile = NULL;
     int i, nerrs = 0;
 
     ncopts &= ~NC_FATAL;	/* make errors nonfatal */
@@ -49,8 +49,8 @@ main(int argc, char **argv)
 	     nc_set_default_format(NC_FORMAT_CLASSIC, NULL);
 	     fprintf(stderr, "\n\nSwitching to netCDF classic format.\n");
 	     break;
-	  case NC_FORMAT_64BIT:
-	     nc_set_default_format(NC_FORMAT_64BIT, NULL);
+	  case NC_FORMAT_64BIT_OFFSET:
+	     nc_set_default_format(NC_FORMAT_64BIT_OFFSET, NULL);
 	     fprintf(stderr, "\n\nSwitching to 64-bit offset format.\n");
 	     break;
 #ifdef USE_NETCDF4 
@@ -66,6 +66,7 @@ main(int argc, char **argv)
        testfile = testfiles[i];
 
        /* Run all the tests for this format. */
+	   
        nerrs += test_nccreate(testfile);
        nerrs += test_ncopen(testfile);
        nerrs += test_ncredef(testfile);
@@ -81,6 +82,7 @@ main(int argc, char **argv)
        nerrs += test_ncvardef(testfile);
        nerrs += test_ncvarid(testfile);
        nerrs += test_ncvarinq(testfile);
+	   nerrs += test_ncvarputg(testfile);
        nerrs += test_ncvarput1(testfile);
        nerrs += test_ncvarget1(testfile);
        nerrs += test_ncvarput(testfile);
diff --git a/nctest/ref_nctest_64bit_offset.nc b/nctest/ref_nctest_64bit_offset.nc
index 5cecce4..a289f9b 100644
Binary files a/nctest/ref_nctest_64bit_offset.nc and b/nctest/ref_nctest_64bit_offset.nc differ
diff --git a/nctest/ref_nctest_classic.nc b/nctest/ref_nctest_classic.nc
index ad1e347..d010f95 100644
Binary files a/nctest/ref_nctest_classic.nc and b/nctest/ref_nctest_classic.nc differ
diff --git a/nctest/varputg.c b/nctest/varputg.c
index d5f32a2..c95d4a3 100644
--- a/nctest/varputg.c
+++ b/nctest/varputg.c
@@ -138,7 +138,7 @@ test_ncvarputg(path)
 	error("%s: ncvarputg failed to report bad netcdf handle", pname);
 	nerrs++;
     }
-    free (hc.vals);
+    if(hc.vals != NULL) free (hc.vals);
     if (nerrs > 0)
       (void) fprintf(stderr,"FAILED! ***\n");
     else
diff --git a/nctest/vartests.c b/nctest/vartests.c
index 3aa664f..fca2594 100644
--- a/nctest/vartests.c
+++ b/nctest/vartests.c
@@ -218,8 +218,8 @@ test_ncvarinq(path)
 	    nerrs++;
 	}
     }
-    free(var.dims);
-    free(var.name);
+    if(var.dims != NULL) free(var.dims);
+    if(var.name != NULL) free(var.name);
     if (nerrs > 0)
       (void) fprintf(stderr,"FAILED! ***\n");
     else
diff --git a/nctest/vputget.c b/nctest/vputget.c
index a84537f..34244fa 100644
--- a/nctest/vputget.c
+++ b/nctest/vputget.c
@@ -43,8 +43,8 @@ test_varputget(cdfid)
     int ne = 3;			/* number of test hypercubes for each var */
     struct cdfhc {		/* a hypercube with generic values */
 	long cor[MAX_NC_DIMS];	/* netcdf coordinates for lower corner */
-	long edg[MAX_NC_DIMS];	/* netcdf edge lengths to upper corner */
-	void *vals;		/* pointer to block of values */
+    long edg[MAX_NC_DIMS];	/* netcdf edge lengths to upper corner */
+		void *vals;		/* pointer to block of values */
     } hc[3], tmp;		/* test hypercubes */
     int nel[3];			/* number of elements in hypercube */
 
diff --git a/nctest/vputgetg.c b/nctest/vputgetg.c
index 8062de7..5bf931d 100644
--- a/nctest/vputgetg.c
+++ b/nctest/vputgetg.c
@@ -39,7 +39,7 @@ test_varputgetg(cdfid)
 {
     int nerrs = 0;
     static char pname[] = "test_varputgetg";
-    int id, ie, iv;		/* loop indices */
+    int id = 0, ie = 0, iv = 0;		/* loop indices */
     int ne = 3;			/* number of test hypercubes for each var */
     struct cdfhc {		/* a hypercube with generic values */
 	long cor[MAX_NC_DIMS];	/* netcdf coordinates for lower corner */
@@ -53,8 +53,8 @@ test_varputgetg(cdfid)
 
     for (iv = 0; iv < test.nvars; iv++)	{ /* for each var in netcdf */
 
-	for (ie = 0; ie < ne; ie++)
-	  nel[ie] = 1;		/* to compute space for hypercube values */
+		for (ie = 0; ie < ne; ie++)
+			nel[ie] = 1;		/* to compute space for hypercube values */
 
 	/*
 	 * The following macro returns the size of a dimension for a
@@ -80,7 +80,7 @@ test_varputgetg(cdfid)
 					? nctypelen(test.vars[iv].type)
 					: hc[0].imap[id+1] * hc[0].npts[id+1];
 	    nel[0]		*= hc[0].npts[id];
-	    if (id == 0)
+	    if (id <= 0)
 		hc[0].offset	= 0;
 
 	    /* start at "upper-right" corner, do one point */
diff --git a/oc2/Make0 b/oc2/Make0
index e2991fe..de8a136 100755
--- a/oc2/Make0
+++ b/oc2/Make0
@@ -25,7 +25,7 @@ ochttp.h ocread.h ocutil.h \
 ocbytes.h oclist.h ocuri.h oclog.h \
 xxdr.h
 
-DOCS=docs/ocauth.html
+DOCS=docs/auth.html.in docs/oc.css
 
 MISC=dap.y
 
diff --git a/oc2/Makefile.am b/oc2/Makefile.am
index 26e515e..4ac66b4 100755
--- a/oc2/Makefile.am
+++ b/oc2/Makefile.am
@@ -31,7 +31,7 @@ ochttp.h ocread.h ocutil.h \
 ocbytes.h oclist.h ocuri.h oclog.h \
 xxdr.h
 
-EXTRA_DIST = dap.y CMakeLists.txt ocauth.html
+EXTRA_DIST = dap.y CMakeLists.txt auth.html.in oc.css
 
 if BUILD_DAP
 noinst_LTLIBRARIES = liboc.la
diff --git a/oc2/Makefile.in b/oc2/Makefile.in
index eeca5f9..fd8ec59 100644
--- a/oc2/Makefile.in
+++ b/oc2/Makefile.in
@@ -251,6 +251,7 @@ HAS_MMAP = @HAS_MMAP@
 HAS_NC2 = @HAS_NC2@
 HAS_NC4 = @HAS_NC4@
 HAS_PARALLEL = @HAS_PARALLEL@
+HAS_PARALLEL4 = @HAS_PARALLEL4@
 HAS_PNETCDF = @HAS_PNETCDF@
 HAS_SZIP = @HAS_SZIP@
 HAS_SZLIB = @HAS_SZLIB@
@@ -283,6 +284,7 @@ NC_HAS_MMAP = @NC_HAS_MMAP@
 NC_HAS_NC2 = @NC_HAS_NC2@
 NC_HAS_NC4 = @NC_HAS_NC4@
 NC_HAS_PARALLEL = @NC_HAS_PARALLEL@
+NC_HAS_PARALLEL4 = @NC_HAS_PARALLEL4@
 NC_HAS_PNETCDF = @NC_HAS_PNETCDF@
 NC_HAS_SZIP = @NC_HAS_SZIP@
 NC_LIBS = @NC_LIBS@
@@ -294,6 +296,7 @@ NC_VERSION_NOTE = @NC_VERSION_NOTE@
 NC_VERSION_PATCH = @NC_VERSION_PATCH@
 NM = @NM@
 NMEDIT = @NMEDIT@
+NOUNDEFINED = @NOUNDEFINED@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -393,7 +396,7 @@ ochttp.h ocread.h ocutil.h \
 ocbytes.h oclist.h ocuri.h oclog.h \
 xxdr.h
 
-EXTRA_DIST = dap.y CMakeLists.txt ocauth.html
+EXTRA_DIST = dap.y CMakeLists.txt auth.html.in oc.css
 @BUILD_DAP_TRUE at noinst_LTLIBRARIES = liboc.la
 @BUILD_DAP_TRUE at liboc_la_SOURCES = $(SRC) $(HDRS) 
 @BUILD_DAP_TRUE at liboc_la_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/oc2/ocauth.html b/oc2/auth.html.in
similarity index 68%
rename from oc2/ocauth.html
rename to oc2/auth.html.in
index d8e2537..72a7aa7 100644
--- a/oc2/ocauth.html
+++ b/oc2/auth.html.in
@@ -1,38 +1,21 @@
-<!- Copyright 2014, UCAR/Unidata and OPeNDAP, Inc. --> 
+<!- Copyright 2015, UCAR/Unidata and OPeNDAP, Inc. --> 
 <!- See the COPYRIGHT file for more information. --> 
 <html> 
-<style> 
-.break { page-break-before: always; } 
-body { counter-reset: H2; font-size: 12pt; } 
-h2:before { 
-  content: counter(H2) " "; 
-  counter-increment: H2; 
-} 
-h2 { counter-reset: H3; } 
-h3:before { 
-  content: counter(H2) "." counter(H3) " "; 
-  counter-increment:H3; 
-} 
-h3 { counter-reset: H4; } 
-h4:before { 
-  content: counter(H2) "." counter(H3) "." counter(H4) " "; 
-  counter-increment:H4; 
-} 
-h5 {font-size: 14pt; } /* For Appendices */ 
-h6 {font-size: 16pt; } /* For Subtitles */ 
-</style> 
+<head>
+<link rel="stylesheet" type="text/css" href="oc.css">
+</head>
 <body> 
  
-<center> 
-<h1>OC Authorization Support</h1> 
-<h6>Author: Dennis Heimbigner<br>
-dmh at ucar dot edu</h6>
-<h6>Draft: 11/21/2014<br> 
-Last Revised: 12/23/2014<br> 
-OC Version 2.1</h6> 
-</center> 
+<h1 class="title">ZZ Authorization Support</h1> 
+<div class="subtitle">
+<h1>Author: Dennis Heimbigner</h1>
+<h1>Address: http://www.unidata.ucar.edu/staff/dmh/</h1>
+<h1>Draft: 11/21/2014</h1>
+<h1>Last Revised: 10/24/2015</h1>
+<OC><h1>ZZ Version 4.0</h1> 
+</div>
  
-<h6 class="break"><u>Table of Contents</u></h6> 
+<h1 class="toc">Table of Contents</h1> 
 <ol> 
 <li> <a href="#Introduction">Introduction</a> 
 <li> <a href="#URL-AUTH">URL-Based Authentication</a> 
@@ -44,8 +27,8 @@ OC Version 2.1</h6>
 <li> <a href="#ESGDETAIL">Appendix B. ESG Access in Detail</a>
 </ol> 
  
-<h2 class="break"><a name="Introduction"><u>Introduction</u></a></h2> 
-OC can support user authorization using those provided by the curl
+<h2><a name="Introduction">Introduction</a></h2> 
+ZZ can support user authorization using the facilities provided by the curl
 library. This includes basic password authentication as well as
 certificate-based authorization.
 <p>
@@ -57,7 +40,7 @@ The libcurl authorization mechanisms can be accessed in two ways
 <i>.daprc</i> or <i>.dodsrc</i>
 </ol>
 
-<h2 class="break"><a name="URL-AUTH"><u>URL-Based Authentication</u></a></h2> 
+<h2><a name="URL-AUTH">URL-Based Authentication</a></h2> 
 For simple password based authentication, it is possible to
 directly insert the username and the password into a url in this form.
 <pre>
@@ -67,23 +50,25 @@ 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 <a href="#REDIR">redirection</a> based
-authorization will not work with this.
+authorization will not work with this because the username and password
+will only be used on the initial request, not the redirection
 
-<h2 class="break"><a name="DODSRC"><u>RC File Authentication</u></a></h2> 
-The oc library supports an <i>rc</i> file mechanism to allow the passing
-of a number of parameters to liboc and libcurl.
+<h2><a name="DODSRC">RC File Authentication</a></h2> 
+The zz library supports an <i>rc</i> file mechanism to allow the passing
+of a number of parameters to libzz and libcurl.
 <p>
 The file must be called one of the following names:
-".daprc", ".dodsrc"
+".daprc" or ".dodsrc"
 If both .daprc and .dodsrc exist, then
 the .daprc file will take precedence.
 <p>
-Searching for the rc file first looks in the current directory
+The rc file is searched for first in the current directory
 and then in the home directory (as defined by the HOME environment
-variable). It is also possible to specify a direct path using
-the <i>-R</i> option to ocprint or using the <i>oc_set_rcfile</i>
-procedure (see oc.h). Note that for these latter cases, the path
-must be to the file itself, not to the containing directory.
+variable).
+<OC>It is also possible to specify a direct path using
+<OC>the <i>-R</i> option to ocprint or using the <i>oc_set_rcfile</i>
+<OC>procedure (see oc.h). Note that for these latter cases, the path
+<OC>must be to the file itself, not to the containing directory.
 <p>
 The rc file format is a series of lines of the general form:
 <pre>
@@ -93,10 +78,11 @@ where the bracket-enclosed host:port is optional and will be discussed
 subsequently.
 <p>
 The currently defined set of authorization-related keys are as follows.
-The second column is the affected curl_easy_setopt option(s).
+The second column is the affected curl_easy_setopt option(s), if any.
 <table>
-<tr><th>Key<th>curl_easy_setopt Option
-<tr><td>HTTP.COOKIEJAR<td>CURLOPT_COOKIEJAR, CURLOPT_COOKIEFILE
+<tr><th>Key<th>Affected curl_easy_setopt Options<th>Notes
+<tr><td>HTTP.COOKIEJAR<td>CURLOPT_COOKIEJAR
+<tr><td>HTTP.COOKIEFILE<td>CURLOPT_COOKIEJAR<td>Alias for CURLOPT_COOKIEJAR
 <tr><td>HTTP.PROXY_SERVER<td>CURLOPT_PROXY, CURLOPT_PROXYPORT, CURLOPT_PROXYUSERPWD
 <tr><td>HTTP.SSL.CERTIFICATE<td>CURLOPT_SSLCERT
 <tr><td>HTTP.SSL.KEY<td>CURLOPT_SSLKEY
@@ -104,36 +90,41 @@ The second column is the affected curl_easy_setopt option(s).
 <tr><td>HTTP.SSL.CAINFO<td>CURLOPT_SSLCAINFO
 <tr><td>HTTP.SSL.CAPATH<td>CURLOPT_SSLCAPATH
 <tr><td>HTTP.SSL.VERIFYPEER<td>CURLOPT_SSL_VERIFYPEER
+<tr><td>HTTP.SSL.VALIDATE<td>CURLOPT_SSL_VERIFYPEER, CURLOPT_SSL_VERIFYHOST
 <tr><td>HTTP.CREDENTIALS.USERPASSWORD<td>CURLOPT_USERPASSWORD
+<tr><td>HTTP.NETRC<td>N.A.<td>Specify path of the .netrc file
 </table>
 </ul>
 
-<h3><u>Password Authentication</u></h3> 
+<h3>Password Authentication</h3> 
 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 <a href="#REDIR">redirection authorization</a>
+for important additional information.
 
-<h3><u>Cookie Jar</u></h3> 
+<h3>Cookie Jar</h3> 
 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 <a href="#REDIR">redirection authorization</a>
+for important additional information.
 
-<h3><u>Certificate Authentication</u></h3> 
+<h3>Certificate Authentication</h3> 
 HTTP.SSL.CERTIFICATE
 specifies a file path for a file containing a PEM cerficate.
 This is typically used for client-side authentication.
 <p>
 HTTP.SSL.KEY is essentially the same as HTTP.SSL.CERTIFICATE
-and should usually have the same value.
+and should always have the same value.
 <p>
 HTTP.SSL.KEYPASSWORD
-specifies the password for accessing the HTTP.SSL.KEY/HTTP.SSL.CERTIFICATE
-file.
+specifies the password for accessing the HTTP.SSL.CERTIFICAT/HTTP.SSL.key file.
 <p>
 HTTP.SSL.CAPATH
 specifies the path to a directory containing
@@ -144,57 +135,77 @@ is a boolean (1/0) value that if true (1)
 specifies that the client should verify the server's presented certificate.
 <p>
 HTTP.PROXY_SERVER
-specified the url for accessing the proxy:
-(e.g.http://[username:password@]host[:port])
+specifies the url for accessing the proxy:
+e.g. <i>http://[username:password@]host[:port]</i>
+<p>
+HTTP.NETRC
+specifies the absolute path of the .netrc file.
+See <a href="#REDIR">redirection authorization</a>
+for information about using .netrc.
 
-<h2 class="break"><a name="REDIR"><u>Redirection-Based Authentication</u></a> </h2>
+<h2><a name="REDIR">Redirection-Based Authentication</a> </h2>
 Some sites provide authentication by using a third party site
-to to the authentication. One example is
-<a href="https://uat.urs.earthdata.nasa.gov">URS</a>,
-the EOSDIS User Registration System.
+to do the authentication. Examples include ESG and URS.
 <p>
 The process is usually as follows.
 <ol>
-<li>The client contacts the server of interest (SOI), the actual data provider.
-<li>The SOI sends a redirect to the client to connect to the URS system.
+<li>The client contacts the server of interest (SOI), the actual data provider
+using, typically http protocol.
+<li>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).
 <li>The client authenticates with URS.
 <li>URS sends a redirect (with authorization information) to send
 the client back to the SOI to actually obtain the data.
 </ol>
 <p>
-In order for this to work with libcurl, the client will usually need
-to provide a .netrc file so that the redirection will work correctly.
+It turns out that libcurl uses the password in the .daprc file — or from the url —
+only for the initial connection. This causes problems because
+the redirected connection is the one that actually requires the password.
+This is where .netrc 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 the redirection site.
+In summary, if you are using redirection, then you must create a .netrc
+file to hold the password for the site to which the redirection is sent.
+<p>
 The format of this .netrc file will contain content that
 typically look like this.
 <pre>
-machine uat.urs.earthdata.nasa.gov login xxxxxx password yyyyyy
-</pre>
-where the machine is the one to which the client is redirected
-for authorization, and the login and password are those
-needed to authenticate.
-<p>
-The .netrc file can be specified in two ways.
-<ol>
-<li> Specify the netrc file to liboc using the procedure in oc.h:
-<pre>
-oc_set_netrc(OClink* link, const char* file)
+machine mmmmmm login xxxxxx password yyyyyy
 </pre>
-(This is equivalent to the -N flag to ocprint). 
+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.
 <p>
-<li> Put the following line in your .daprc/.dodsrc file.
-<pre>
-HTTP.NETRC=<path to netrc file>
-</pre>
-</ol>
+<NC>The .netrc file can be specified by
+<NC>putting the following line in your .daprc/.dodsrc file.
+<NC><pre>
+<NC>HTTP.NETRC=<path to netrc file>
+<NC></pre>
+<OC>The .netrc file can be specified in two ways.
+<OC><ol>
+<OC><li> Specify the netrc file to libzz using the procedure in oc.h:
+<OC><pre>
+<OC>oc_set_netrc(OClink* link, const char* file)
+<OC></pre>
+<OC>(This is equivalent to the -N flag to ocprint). 
+<OC><p>
+<OC><li> Put the following line in your .daprc/.dodsrc file.
+<OC><pre>
+<OC>HTTP.NETRC=<path to netrc file>
+<OC></pre>
+<OC></ol>
+
 <p>
-One final note. In using this, it is probable that you will
-need to specify a cookie jar (HTTP.COOKIEJAR) so that the
+One final note. In using this, it is almost certain that you will
+need to specify a real cookie jar file (HTTP.COOKIEJAR) so that the
 redirect site can pass back authorization information.
 
-<h2 class="break"><a name="URLCONS"><u>URL Constrained RC File Entries</u></a></h2> 
+<h2><a name="URLCONS">URL Constrained RC File Entries</a></h2> 
 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
+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.
@@ -205,8 +216,8 @@ Examples.
 or
 [fake.ucar.edu:9090]HTTP.VERBOSE=0
 </pre>
-If the url request from, say, the <i>oc_open</i> method
-has a host+port matchine one of the prefixes in the rc file, then
+If the url request from, say, the <i>zz_open</i> method
+has a host+port matching one of the prefixes in the rc file, then
 the corresponding entry will be used, otherwise ignored.
 <p>
 For example, the URL
@@ -221,7 +232,7 @@ http://fake.ucar.edu:9090/dts/test.01
 </pre>
 will have HTTP.VERBOSE set to 0.
 
-<h2 class="break"><a name="CLIENTCERTS"><u>Client-Side Certificates</u></a></h2> 
+<h2><a name="CLIENTCERTS">Client-Side Certificates</a></h2> 
 Some systems, notably ESG (Earth System Grid), requires
 the use of client-side certificates, as well as being
 <a href="#REDIR">re-direction based</a>.
@@ -236,8 +247,10 @@ This requires setting the following entries:
 </ul>
 Note that the first two are to support re-direction based authentication.
 
-<h5 class="break"><a name="allkeys"><u>Appendix A. All RC-File Keys</u></a></h5> 
+<h1 class="appendix><a name="allkeys">Appendix A. All RC-File Keys</a></h1> 
 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>curl_easy_setopt Option
 <tr valign="top"><td>HTTP.DEFLATE<td>CUROPT_DEFLATE<br>with value "deflate,gzip"
@@ -258,14 +271,23 @@ For completeness, this is the list of all rc-file keys.
 </table>
 </ul>
 
-<h5 class="break"><a name="ESGDETAIL"><u>Appendix B. ESG Access in Detail</u></a></h5> 
+<h1 class="appendix"><a name="URSDETAIL">Appendix B. URS Access in Detail</a></h1>
+It is possible to use the NASA Earthdata Login System (URS)
+with zz by using using the process specified in the 
+<a href="#REDIR">redirection</a> based authorization section.
+In order to access URS controlled datasets, however, it is necessary to
+register as a user with NASA at the
+<i>https://uat.urs.earthdata.nasa.gov/</i>
+website.
+
+<h1 class="appendix"><a name="ESGDETAIL">Appendix C. ESG Access in Detail</a></h1>
 It is possible to access Earth Systems Grid (ESG) datasets
-from ESG servers through the OC API using the techniques
+from ESG servers through the ZZ API using the techniques
 described in the section on <a href="#CLIENTCERTS">Client-Side Certificates</a>.
 <p>
 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 oc
+so that proper authentication is established between an zz
 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
@@ -275,10 +297,10 @@ 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.
 <p>
-The oc library uses the <i>curl</i> library and it is that
+The zz library uses the <i>curl</i> library and it is that
 underlying library that must be properly configured.
 
-<h3><u>Terminology</u></h3>
+<h3>Terminology</h3>
 The key elements for client-side keys requires the constructions of
 two "stores" on the client side.
 <ul>
@@ -290,7 +312,7 @@ two "stores" on the client side.
 The server actually has a similar set of stores, but the client
 need not be concerned with those.
 
-<h3><u>Initial Steps</u></h3>
+<h3>Initial Steps</h3>
 
 The first step is to obtain authorization from ESG.
 Note that this information may evolve over time, and
@@ -318,7 +340,7 @@ to substitute as necessary.
    (read the whole page, it will help you understand the remaining steps).
 </ol>
 
-<h3><u>Building the KeyStore</u></h3>
+<h3>Building the KeyStore</h3>
 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:
@@ -332,7 +354,7 @@ The commands are these:
 Note, the file names "key.der" and "cert.der" can be whatever you choose.
 It is probably best to leave the .der extension, though.
 
-<h3><u>Building the TrustStore</u></h3>
+<h3>Building the TrustStore</h3>
 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
@@ -342,7 +364,7 @@ named "truststore"
   keytool -trustcacerts -storepass "password" -v -keystore "truststore"  -importcert -file "${c}"
 </pre>
 
-<h3><u>Running the C Client</u></h3>
+<h3>Running the C Client</h3>
 
 Refer to the section on <a href="#CLIENTCERTS">Client-Side Certificates</a>.
 The keys specified there  must be set in the rc file to support
@@ -369,7 +391,7 @@ redirects to a separate authentication server. When that
 server has authenticated the client, it redirects back to
 the original url to complete the request.
 
-<h3><u>Script for creating Stores</u></h3>
+<h3>Script for creating Stores</h3>
 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
diff --git a/oc2/daplex.c b/oc2/daplex.c
index 3d3a392..274995f 100644
--- a/oc2/daplex.c
+++ b/oc2/daplex.c
@@ -9,7 +9,11 @@
 #include "daptab.h"
 
 #undef URLCVT /* NEVER turn this on */
+
 #define DAP2ENCODE
+#ifdef DAP2ENCODE
+#define KEEPSLASH
+#endif
 
 /* Forward */
 static void dumptoken(DAPlexstate* lexstate);
@@ -132,18 +136,30 @@ daplex(YYSTYPE* lvalp, DAPparsestate* state)
 	    int more = 1;
 	    /* We have a string token; will be reported as WORD_STRING */
 	    while(more && (c=*(++p))) {
-#ifdef DAP2ENCODE
-	        if(c == '"')
+	        if(c == '"') {
 		    more = 0;
-		else if(c == '\\') {
-		    /* Remove spec ambiguity by convering \c to c
-                       for any character c */
+		    continue;
+		}
+#ifdef DAP2ENCODE
+		if(c == '\\') {
+		    /* Resolve spec ambiguity about handling of \c:
+			1. !KEEPSLASH: convert \c to c for any character c
+			2. KEEPSLASH: convert \c to \c for any character c;
+			   that is, keep the backslash.
+			It is clear that the problem being addressed was \".
+			But it is unclear what to to do about \n: convert to
+                        Ascii LF or leave as \n.
+                        This code will leave as \n and assume higher levels
+                        of code will address the issue.
+		    */
+#ifdef KEEPSLASH
+		    dapaddyytext(lexstate,c);		    
+#endif
 		    c=*(++p);
 		    if(c == '\0') more = 0;
 		}
 #else /*Non-standard*/
 		switch (c) {
-		case '"': more=0; break;
 		case '\\':
 		    c=*(++p);
 		    switch (c) {
diff --git a/oc2/daptab.c b/oc2/daptab.c
index da689cd..1014c72 100644
--- a/oc2/daptab.c
+++ b/oc2/daptab.c
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.2"
+#define YYBISON_VERSION "3.0"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -77,11 +77,11 @@ int dapdebug = 0;
 
 #line 79 "dap.tab.c" /* yacc.c:339  */
 
-# ifndef YY_NULLPTR
+# ifndef YY_NULL
 #  if defined __cplusplus && 201103L <= __cplusplus
-#   define YY_NULLPTR nullptr
+#   define YY_NULL nullptr
 #  else
-#   define YY_NULLPTR 0
+#   define YY_NULL 0
 #  endif
 # endif
 
@@ -210,30 +210,11 @@ typedef short int yytype_int16;
 # endif
 #endif
 
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__                                               \
-      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
-     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
-# else
-#  define YY_ATTRIBUTE(Spec) /* empty */
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
-     && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-#  define _Noreturn __declspec (noreturn)
-# else
-#  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if (! defined __GNUC__ || __GNUC__ < 2 \
+      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
+#  define __attribute__(Spec) /* empty */
 # endif
 #endif
 
@@ -483,7 +464,7 @@ static const char *const yytname[] =
   "array_decl", "datasetname", "var_name", "attributebody", "attr_list",
   "attribute", "bytes", "int16", "uint16", "int32", "uint32", "float32",
   "float64", "strs", "urls", "url", "str_or_id", "alias", "errorbody",
-  "errorcode", "errormsg", "errorptype", "errorprog", "name", YY_NULLPTR
+  "errorcode", "errormsg", "errorptype", "errorprog", "name", YY_NULL
 };
 #endif
 
@@ -1008,11 +989,11 @@ static int
 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                 yytype_int16 *yyssp, int yytoken)
 {
-  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
+  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
   YYSIZE_T yysize = yysize0;
   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   /* Internationalized format string. */
-  const char *yyformat = YY_NULLPTR;
+  const char *yyformat = YY_NULL;
   /* Arguments of yyformat. */
   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
   /* Number of reported tokens (one for the "unexpected", one per
@@ -1069,7 +1050,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                   }
                 yyarg[yycount++] = yytname[yyx];
                 {
-                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
+                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
                   if (! (yysize <= yysize1
                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
                     return 2;
@@ -1408,611 +1389,611 @@ yyreduce:
         case 6:
 #line 58 "dap.y" /* yacc.c:1646  */
     {dap_unrecognizedresponse(parsestate); YYABORT;}
-#line 1412 "dap.tab.c" /* yacc.c:1646  */
+#line 1393 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 7:
 #line 63 "dap.y" /* yacc.c:1646  */
     {dap_tagparse(parsestate,SCAN_DATASET);}
-#line 1418 "dap.tab.c" /* yacc.c:1646  */
+#line 1399 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 8:
 #line 67 "dap.y" /* yacc.c:1646  */
     {dap_tagparse(parsestate,SCAN_ATTR);}
-#line 1424 "dap.tab.c" /* yacc.c:1646  */
+#line 1405 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 9:
 #line 71 "dap.y" /* yacc.c:1646  */
     {dap_tagparse(parsestate,SCAN_ERROR);}
-#line 1430 "dap.tab.c" /* yacc.c:1646  */
+#line 1411 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 10:
 #line 76 "dap.y" /* yacc.c:1646  */
     {dap_datasetbody(parsestate,(yyvsp[-1]),(yyvsp[-3]));}
-#line 1436 "dap.tab.c" /* yacc.c:1646  */
+#line 1417 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 11:
 #line 81 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_declarations(parsestate,null,null);}
-#line 1442 "dap.tab.c" /* yacc.c:1646  */
+#line 1423 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 12:
 #line 82 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_declarations(parsestate,(yyvsp[-1]),(yyvsp[0]));}
-#line 1448 "dap.tab.c" /* yacc.c:1646  */
+#line 1429 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 13:
 #line 89 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_makebase(parsestate,(yyvsp[-2]),(yyvsp[-3]),(yyvsp[-1]));}
-#line 1454 "dap.tab.c" /* yacc.c:1646  */
+#line 1435 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 14:
 #line 91 "dap.y" /* yacc.c:1646  */
     {if(((yyval)=dap_makestructure(parsestate,(yyvsp[-2]),(yyvsp[-1]),(yyvsp[-4])))==null) {YYABORT;}}
-#line 1460 "dap.tab.c" /* yacc.c:1646  */
+#line 1441 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 15:
 #line 93 "dap.y" /* yacc.c:1646  */
     {if(((yyval)=dap_makesequence(parsestate,(yyvsp[-1]),(yyvsp[-3])))==null) {YYABORT;}}
-#line 1466 "dap.tab.c" /* yacc.c:1646  */
+#line 1447 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 16:
 #line 96 "dap.y" /* yacc.c:1646  */
     {if(((yyval)=dap_makegrid(parsestate,(yyvsp[-1]),(yyvsp[-6]),(yyvsp[-3])))==null) {YYABORT;}}
-#line 1472 "dap.tab.c" /* yacc.c:1646  */
+#line 1453 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 17:
 #line 98 "dap.y" /* yacc.c:1646  */
     {dapsemanticerror(parsestate,OC_EBADTYPE,"Unrecognized type"); YYABORT;}
-#line 1478 "dap.tab.c" /* yacc.c:1646  */
+#line 1459 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 18:
 #line 103 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_BYTE;}
-#line 1484 "dap.tab.c" /* yacc.c:1646  */
+#line 1465 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 19:
 #line 104 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_INT16;}
-#line 1490 "dap.tab.c" /* yacc.c:1646  */
+#line 1471 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 20:
 #line 105 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_UINT16;}
-#line 1496 "dap.tab.c" /* yacc.c:1646  */
+#line 1477 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 21:
 #line 106 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_INT32;}
-#line 1502 "dap.tab.c" /* yacc.c:1646  */
+#line 1483 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 22:
 #line 107 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_UINT32;}
-#line 1508 "dap.tab.c" /* yacc.c:1646  */
+#line 1489 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 23:
 #line 108 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_FLOAT32;}
-#line 1514 "dap.tab.c" /* yacc.c:1646  */
+#line 1495 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 24:
 #line 109 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_FLOAT64;}
-#line 1520 "dap.tab.c" /* yacc.c:1646  */
+#line 1501 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 25:
 #line 110 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_URL;}
-#line 1526 "dap.tab.c" /* yacc.c:1646  */
+#line 1507 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 26:
 #line 111 "dap.y" /* yacc.c:1646  */
     {(yyval)=(Object)SCAN_STRING;}
-#line 1532 "dap.tab.c" /* yacc.c:1646  */
+#line 1513 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 27:
 #line 115 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_arraydecls(parsestate,null,null);}
-#line 1538 "dap.tab.c" /* yacc.c:1646  */
+#line 1519 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 28:
 #line 116 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_arraydecls(parsestate,(yyvsp[-1]),(yyvsp[0]));}
-#line 1544 "dap.tab.c" /* yacc.c:1646  */
+#line 1525 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 29:
 #line 120 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_arraydecl(parsestate,null,(yyvsp[-1]));}
-#line 1550 "dap.tab.c" /* yacc.c:1646  */
+#line 1531 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 30:
 #line 121 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_arraydecl(parsestate,null,(yyvsp[-1]));}
-#line 1556 "dap.tab.c" /* yacc.c:1646  */
+#line 1537 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 31:
 #line 122 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_arraydecl(parsestate,(yyvsp[-3]),(yyvsp[-1]));}
-#line 1562 "dap.tab.c" /* yacc.c:1646  */
+#line 1543 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 32:
 #line 124 "dap.y" /* yacc.c:1646  */
     {dapsemanticerror(parsestate,OC_EDIMSIZE,"Illegal dimension declaration"); YYABORT;}
-#line 1568 "dap.tab.c" /* yacc.c:1646  */
+#line 1549 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 33:
 #line 128 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[0]);}
-#line 1574 "dap.tab.c" /* yacc.c:1646  */
+#line 1555 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 34:
 #line 130 "dap.y" /* yacc.c:1646  */
     {dapsemanticerror(parsestate,OC_EDDS,"Illegal dataset declaration"); YYABORT;}
-#line 1580 "dap.tab.c" /* yacc.c:1646  */
+#line 1561 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 35:
 #line 133 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[0]);}
-#line 1586 "dap.tab.c" /* yacc.c:1646  */
+#line 1567 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 36:
 #line 136 "dap.y" /* yacc.c:1646  */
     {dap_attributebody(parsestate,(yyvsp[-1]));}
-#line 1592 "dap.tab.c" /* yacc.c:1646  */
+#line 1573 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 37:
 #line 138 "dap.y" /* yacc.c:1646  */
     {dapsemanticerror(parsestate,OC_EDAS,"Illegal DAS body"); YYABORT;}
-#line 1598 "dap.tab.c" /* yacc.c:1646  */
+#line 1579 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 38:
 #line 142 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrlist(parsestate,null,null);}
-#line 1604 "dap.tab.c" /* yacc.c:1646  */
+#line 1585 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 39:
 #line 143 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrlist(parsestate,(yyvsp[-1]),(yyvsp[0]));}
-#line 1610 "dap.tab.c" /* yacc.c:1646  */
+#line 1591 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 40:
 #line 147 "dap.y" /* yacc.c:1646  */
     {(yyval)=null;}
-#line 1616 "dap.tab.c" /* yacc.c:1646  */
+#line 1597 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 41:
 #line 149 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_BYTE);}
-#line 1622 "dap.tab.c" /* yacc.c:1646  */
+#line 1603 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 42:
 #line 151 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_INT16);}
-#line 1628 "dap.tab.c" /* yacc.c:1646  */
+#line 1609 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 43:
 #line 153 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_UINT16);}
-#line 1634 "dap.tab.c" /* yacc.c:1646  */
+#line 1615 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 44:
 #line 155 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_INT32);}
-#line 1640 "dap.tab.c" /* yacc.c:1646  */
+#line 1621 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 45:
 #line 157 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_UINT32);}
-#line 1646 "dap.tab.c" /* yacc.c:1646  */
+#line 1627 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 46:
 #line 159 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_FLOAT32);}
-#line 1652 "dap.tab.c" /* yacc.c:1646  */
+#line 1633 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 47:
 #line 161 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_FLOAT64);}
-#line 1658 "dap.tab.c" /* yacc.c:1646  */
+#line 1639 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 48:
 #line 163 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_STRING);}
-#line 1664 "dap.tab.c" /* yacc.c:1646  */
+#line 1645 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 49:
 #line 165 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attribute(parsestate,(yyvsp[-2]),(yyvsp[-1]),(Object)SCAN_URL);}
-#line 1670 "dap.tab.c" /* yacc.c:1646  */
+#line 1651 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 50:
 #line 166 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrset(parsestate,(yyvsp[-3]),(yyvsp[-1]));}
-#line 1676 "dap.tab.c" /* yacc.c:1646  */
+#line 1657 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 51:
 #line 168 "dap.y" /* yacc.c:1646  */
     {dapsemanticerror(parsestate,OC_EDAS,"Illegal attribute"); YYABORT;}
-#line 1682 "dap.tab.c" /* yacc.c:1646  */
+#line 1663 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 52:
 #line 172 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_BYTE);}
-#line 1688 "dap.tab.c" /* yacc.c:1646  */
+#line 1669 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 53:
 #line 174 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_BYTE);}
-#line 1694 "dap.tab.c" /* yacc.c:1646  */
+#line 1675 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 54:
 #line 177 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_INT16);}
-#line 1700 "dap.tab.c" /* yacc.c:1646  */
+#line 1681 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 55:
 #line 179 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_INT16);}
-#line 1706 "dap.tab.c" /* yacc.c:1646  */
+#line 1687 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 56:
 #line 182 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_UINT16);}
-#line 1712 "dap.tab.c" /* yacc.c:1646  */
+#line 1693 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 57:
 #line 184 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_UINT16);}
-#line 1718 "dap.tab.c" /* yacc.c:1646  */
+#line 1699 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 58:
 #line 187 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_INT32);}
-#line 1724 "dap.tab.c" /* yacc.c:1646  */
+#line 1705 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 59:
 #line 189 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_INT32);}
-#line 1730 "dap.tab.c" /* yacc.c:1646  */
+#line 1711 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 60:
 #line 192 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_UINT32);}
-#line 1736 "dap.tab.c" /* yacc.c:1646  */
+#line 1717 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 61:
 #line 193 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_UINT32);}
-#line 1742 "dap.tab.c" /* yacc.c:1646  */
+#line 1723 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 62:
 #line 196 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_FLOAT32);}
-#line 1748 "dap.tab.c" /* yacc.c:1646  */
+#line 1729 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 63:
 #line 197 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_FLOAT32);}
-#line 1754 "dap.tab.c" /* yacc.c:1646  */
+#line 1735 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 64:
 #line 200 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_FLOAT64);}
-#line 1760 "dap.tab.c" /* yacc.c:1646  */
+#line 1741 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 65:
 #line 201 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_FLOAT64);}
-#line 1766 "dap.tab.c" /* yacc.c:1646  */
+#line 1747 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 66:
 #line 204 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_STRING);}
-#line 1772 "dap.tab.c" /* yacc.c:1646  */
+#line 1753 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 67:
 #line 205 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_STRING);}
-#line 1778 "dap.tab.c" /* yacc.c:1646  */
+#line 1759 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 68:
 #line 209 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,null,(yyvsp[0]),(Object)SCAN_URL);}
-#line 1784 "dap.tab.c" /* yacc.c:1646  */
+#line 1765 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 69:
 #line 210 "dap.y" /* yacc.c:1646  */
     {(yyval)=dap_attrvalue(parsestate,(yyvsp[-2]),(yyvsp[0]),(Object)SCAN_URL);}
-#line 1790 "dap.tab.c" /* yacc.c:1646  */
+#line 1771 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 70:
 #line 214 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[0]);}
-#line 1796 "dap.tab.c" /* yacc.c:1646  */
+#line 1777 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 71:
 #line 218 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[0]);}
-#line 1802 "dap.tab.c" /* yacc.c:1646  */
+#line 1783 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 72:
 #line 219 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[0]);}
-#line 1808 "dap.tab.c" /* yacc.c:1646  */
+#line 1789 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 73:
 #line 230 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[-1]); (yyval)=(yyvsp[0]); (yyval)=null;}
-#line 1814 "dap.tab.c" /* yacc.c:1646  */
+#line 1795 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 74:
 #line 235 "dap.y" /* yacc.c:1646  */
     {dap_errorbody(parsestate,(yyvsp[-5]),(yyvsp[-4]),(yyvsp[-3]),(yyvsp[-2]));}
-#line 1820 "dap.tab.c" /* yacc.c:1646  */
+#line 1801 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 75:
 #line 238 "dap.y" /* yacc.c:1646  */
     {(yyval)=null;}
-#line 1826 "dap.tab.c" /* yacc.c:1646  */
+#line 1807 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 76:
 #line 238 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[-1]);}
-#line 1832 "dap.tab.c" /* yacc.c:1646  */
+#line 1813 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 77:
 #line 239 "dap.y" /* yacc.c:1646  */
     {(yyval)=null;}
-#line 1838 "dap.tab.c" /* yacc.c:1646  */
+#line 1819 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 78:
 #line 239 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[-1]);}
-#line 1844 "dap.tab.c" /* yacc.c:1646  */
+#line 1825 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 79:
 #line 240 "dap.y" /* yacc.c:1646  */
     {(yyval)=null;}
-#line 1850 "dap.tab.c" /* yacc.c:1646  */
+#line 1831 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 80:
 #line 240 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[-1]);}
-#line 1856 "dap.tab.c" /* yacc.c:1646  */
+#line 1837 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 81:
 #line 241 "dap.y" /* yacc.c:1646  */
     {(yyval)=null;}
-#line 1862 "dap.tab.c" /* yacc.c:1646  */
+#line 1843 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 82:
 #line 241 "dap.y" /* yacc.c:1646  */
     {(yyval)=(yyvsp[-1]);}
-#line 1868 "dap.tab.c" /* yacc.c:1646  */
+#line 1849 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 83:
 #line 247 "dap.y" /* yacc.c:1646  */
     {(yyval)=dapdecode(parsestate->lexstate,(yyvsp[0]));}
-#line 1874 "dap.tab.c" /* yacc.c:1646  */
+#line 1855 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 84:
 #line 248 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("alias");}
-#line 1880 "dap.tab.c" /* yacc.c:1646  */
+#line 1861 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 85:
 #line 249 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("array");}
-#line 1886 "dap.tab.c" /* yacc.c:1646  */
+#line 1867 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 86:
 #line 250 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("attributes");}
-#line 1892 "dap.tab.c" /* yacc.c:1646  */
+#line 1873 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 87:
 #line 251 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("byte");}
-#line 1898 "dap.tab.c" /* yacc.c:1646  */
+#line 1879 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 88:
 #line 252 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("dataset");}
-#line 1904 "dap.tab.c" /* yacc.c:1646  */
+#line 1885 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 89:
 #line 253 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("data");}
-#line 1910 "dap.tab.c" /* yacc.c:1646  */
+#line 1891 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 90:
 #line 254 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("error");}
-#line 1916 "dap.tab.c" /* yacc.c:1646  */
+#line 1897 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 91:
 #line 255 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("float32");}
-#line 1922 "dap.tab.c" /* yacc.c:1646  */
+#line 1903 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 92:
 #line 256 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("float64");}
-#line 1928 "dap.tab.c" /* yacc.c:1646  */
+#line 1909 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 93:
 #line 257 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("grid");}
-#line 1934 "dap.tab.c" /* yacc.c:1646  */
+#line 1915 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 94:
 #line 258 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("int16");}
-#line 1940 "dap.tab.c" /* yacc.c:1646  */
+#line 1921 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 95:
 #line 259 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("int32");}
-#line 1946 "dap.tab.c" /* yacc.c:1646  */
+#line 1927 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 96:
 #line 260 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("maps");}
-#line 1952 "dap.tab.c" /* yacc.c:1646  */
+#line 1933 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 97:
 #line 261 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("sequence");}
-#line 1958 "dap.tab.c" /* yacc.c:1646  */
+#line 1939 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 98:
 #line 262 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("string");}
-#line 1964 "dap.tab.c" /* yacc.c:1646  */
+#line 1945 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 99:
 #line 263 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("structure");}
-#line 1970 "dap.tab.c" /* yacc.c:1646  */
+#line 1951 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 100:
 #line 264 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("uint16");}
-#line 1976 "dap.tab.c" /* yacc.c:1646  */
+#line 1957 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 101:
 #line 265 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("uint32");}
-#line 1982 "dap.tab.c" /* yacc.c:1646  */
+#line 1963 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 102:
 #line 266 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("url");}
-#line 1988 "dap.tab.c" /* yacc.c:1646  */
+#line 1969 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 103:
 #line 267 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("code");}
-#line 1994 "dap.tab.c" /* yacc.c:1646  */
+#line 1975 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 104:
 #line 268 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("message");}
-#line 2000 "dap.tab.c" /* yacc.c:1646  */
+#line 1981 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 105:
 #line 269 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("program");}
-#line 2006 "dap.tab.c" /* yacc.c:1646  */
+#line 1987 "dap.tab.c" /* yacc.c:1646  */
     break;
 
   case 106:
 #line 270 "dap.y" /* yacc.c:1646  */
     {(yyval)=strdup("program_type");}
-#line 2012 "dap.tab.c" /* yacc.c:1646  */
+#line 1993 "dap.tab.c" /* yacc.c:1646  */
     break;
 
 
-#line 2016 "dap.tab.c" /* yacc.c:1646  */
+#line 1997 "dap.tab.c" /* yacc.c:1646  */
       default: break;
     }
   /* User semantic actions sometimes alter yychar, and that requires
diff --git a/oc2/daptab.h b/oc2/daptab.h
index 97d6518..d015b33 100644
--- a/oc2/daptab.h
+++ b/oc2/daptab.h
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.  */
 
 /* Bison interface for Yacc-like parsers in C
 
diff --git a/oc2/oc.css b/oc2/oc.css
new file mode 100644
index 0000000..3e0844d
--- /dev/null
+++ b/oc2/oc.css
@@ -0,0 +1,39 @@
+<style> 
+.break { page-break-before: always; } 
+body { counter-reset: H2; font-size: 12pt; } 
+h1.title {
+  font-size: 18pt;
+  text-decoration: underline;
+}
+div.subtitle {
+}
+.subtitle h1 {
+  font-size: 14pt;
+  margin-top: 0;
+  margin-bottom: 0;
+}
+
+h1.toc {
+  font-size: 16pt;
+  text-decoration: underline;
+}
+h1.appendix {
+  font-size: 14pt;
+}
+
+h2:before { 
+  content: counter(H2) " "; 
+  counter-increment: H2; 
+} 
+h2 { counter-reset: H3; text-decoration: underline; } 
+h3:before { 
+  content: counter(H2) "." counter(H3) " "; 
+  counter-increment:H3; 
+} 
+h3 { counter-reset: H4; } 
+h4:before { 
+  content: counter(H2) "." counter(H3) "." counter(H4) " "; 
+  counter-increment:H4; 
+} 
+
+</style> 
diff --git a/oc2/oc.h b/oc2/oc.h
index e0fa0ad..f3d0de2 100644
--- a/oc2/oc.h
+++ b/oc2/oc.h
@@ -537,7 +537,7 @@ extern OCerror oc_svcerrordata(OClink link, char** codep,
    note that this may or may not be the same as returned
    by oc_svcerrordata.
  */
-extern int oc_httpcode(OClink);
+extern OCerror oc_httpcode(OClink);
 
 /*
 (Re-)initialize the oc library as if nothing had been called.
diff --git a/oc2/occurlflags.c b/oc2/occurlflags.c
index be02356..d8eeb82 100644
--- a/oc2/occurlflags.c
+++ b/oc2/occurlflags.c
@@ -253,6 +253,8 @@ static void
 initialize(void)
 {
   struct OCCURLFLAG* p;
+  size_t len = 0;
+
   if(nflags == 0) {  /* initialize */
 	maxflag = -1;
     for(p=oc_curlflags;p->name;p++) {
@@ -267,7 +269,9 @@ initialize(void)
 	}
 
 
-    flagindices = (struct OCCURLFLAG**)calloc(1,(maxflag+(maxflag == -1 ? 2 : 1))*sizeof(struct OCCURLFLAG*));
+    len = maxflag;
+    if(maxflag == -1) len += 2; else len += 1;
+    flagindices = (struct OCCURLFLAG**)calloc(1,len*sizeof(struct OCCURLFLAG*));
     for(p=oc_curlflags;p->name;p++)
       flagindices[p->flag] = p;
   }
diff --git a/oc2/occurlfunctions.c b/oc2/occurlfunctions.c
index c946f18..38c78a0 100644
--- a/oc2/occurlfunctions.c
+++ b/oc2/occurlfunctions.c
@@ -214,21 +214,21 @@ ocset_flags_perlink(OCstate* state)
     OCerror stat = OC_NOERR;
 
     /* Following are always set */
-    stat = ocset_curlflag(state,CURLOPT_ENCODING);
-    stat = ocset_curlflag(state,CURLOPT_NETRC);
-    stat = ocset_curlflag(state,CURLOPT_TIMEOUT);
-    stat = ocset_curlflag(state,CURLOPT_USERAGENT);
-    stat = ocset_curlflag(state,CURLOPT_COOKIEJAR);
-    stat = ocset_curlflag(state,CURLOPT_USERPWD);
-    stat = ocset_curlflag(state,CURLOPT_PROXY);
-    stat = ocset_curlflag(state,CURLOPT_USE_SSL);
-    
-    stat = ocset_curlflag(state, CURLOPT_FOLLOWLOCATION);
-    stat = ocset_curlflag(state, CURLOPT_MAXREDIRS);
-    stat = ocset_curlflag(state, CURLOPT_ERRORBUFFER);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_ENCODING);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_NETRC);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_VERBOSE);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_TIMEOUT);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USERAGENT);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_COOKIEJAR);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USERPWD);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_PROXY);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state,CURLOPT_USE_SSL);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state, CURLOPT_FOLLOWLOCATION);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state, CURLOPT_MAXREDIRS);
+    if(stat == OC_NOERR) stat = ocset_curlflag(state, CURLOPT_ERRORBUFFER);
 
     /* Set the CURL. options */
-    stat = oc_set_curl_options(state);
+    if(stat == OC_NOERR) stat = oc_set_curl_options(state);
 
     return stat;
 }
diff --git a/oc2/ochttp.c b/oc2/ochttp.c
index 4254574..df38f3d 100644
--- a/oc2/ochttp.c
+++ b/oc2/ochttp.c
@@ -88,11 +88,11 @@ fail:
 	return OCTHROW(OC_ECURL);
 }
 
-int
+OCerror
 ocfetchurl(CURL* curl, const char* url, OCbytes* buf, long* filetime,
            struct OCcredentials* creds)
 {
-	int stat = OC_NOERR;
+	OCerror stat = OC_NOERR;
 	CURLcode cstat = CURLE_OK;
 	size_t len;
         long httpcode = 0;
diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c
index 500dd5a..464929a 100644
--- a/oc2/ocinternal.c
+++ b/oc2/ocinternal.c
@@ -12,7 +12,7 @@
 #endif
 #include <errno.h>
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 typedef int pid_t;
 #endif
 
@@ -76,9 +76,10 @@ ocinternalinitialize(void)
 #if 0
     if(sizeof(off_t) != sizeof(void*)) {
       fprintf(stderr,"OC xxdr depends on the assumption that sizeof(off_t) == sizeof(void*)\n");
-      //Commenting out for now, as this does not hold true on 32-bit
-      //linux systems.
-      //OCASSERT(sizeof(off_t) == sizeof(void*));
+      /*
+	Commenting out for now, as this does not hold true on 32-bit linux systems.
+      OCASSERT(sizeof(off_t) == sizeof(void*));
+	*/
     }
 #endif
 
diff --git a/oc2/ocrc.c b/oc2/ocrc.c
index 8e6a074..450a1a7 100644
--- a/oc2/ocrc.c
+++ b/oc2/ocrc.c
@@ -301,7 +301,7 @@ ocrc_compile(const char* path)
 	if(strlen(line) == 0) continue;
         if(strlen(line) >= MAXRCLINESIZE) {
             oclog(OCLOGERR, "%s line too long: %s",path,line0);
-            return 0;
+            continue; /* ignore it */
         }
         /* setup */
         ocrc->triples[ocrc->ntriples].host[0] = '\0';
@@ -408,10 +408,10 @@ done:
     return stat;
 }
 
-int
+OCerror
 ocrc_process(OCstate* state)
 {
-    int stat = 0;
+    OCerror stat = OC_NOERR;
     char* value = NULL;
     OCURI* uri = state->uri;
     char* url_userpwd = NULL;
diff --git a/oc2/ocuri.c b/oc2/ocuri.c
index 3f18a55..a8fe65d 100644
--- a/oc2/ocuri.c
+++ b/oc2/ocuri.c
@@ -583,7 +583,7 @@ than once, then the last occurrence is used; this is so
 that is possible to forcibly override user specified
 parameters by suffixing.  IMPORTANT: client parameter string
 is assumed to have blanks compressed out.  Returns 1 if parse
-suceeded, 0 otherwise; */
+succeeded, 0 otherwise; */
 
 int
 ocuridecodeparams(OCURI* ocuri)

-- 
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