[SCM] general-purpose neural simulator branch, master, updated. upstream/2.3-16-ga91a97a
Gabriele Giacone
1o5g4r8o at gmail.com
Sat Dec 10 23:07:58 UTC 2011
The following commit has been merged in the master branch:
commit 8a5402ed026c36c24d1d4247cac54ebd481ba753
Author: Gabriele Giacone <1o5g4r8o at gmail.com>
Date: Sat Dec 10 17:23:41 2011 +0100
Imported Upstream version 2.3+dfsg
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/copyright.html b/src/diskio/interface/netcdf/netcdf-3.4/copyright.html
deleted file mode 100644
index df61021..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/copyright.html
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<HTML>
-<HEAD>
-
-<TITLE>Unidata netCDF Copyright Notice</TITLE>
-
-</HEAD>
-<BODY bgcolor="#ffffff">
-<IMG SRC="/icons/uni_emboss.GIF" ALT="UNIDATA">
-<HR>
-
-<H1>Copyright 1993-1999 University Corporation for Atmospheric Research/Unidata</H1>
-
-
-Portions of this software were developed by the Unidata Program at the
-University Corporation for Atmospheric Research.
-
-<p>
-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."
-
-<p>
-<strong>
-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.
-</strong>
-
-<HR>
-<A HREF="/"><IMG ALT="" SRC="/icons/BTN_HomePage.gif"></A>Go to the <A HREF="/">Unidata Homepage.</A>
-<HR>
-
-<ADDRESS>
-Questions or comments can be sent to <A HREF="mailto:support at unidata.ucar.edu">
-<support at unidata.ucar.edu></A>.
-</ADDRESS>
-
-This page was updated on <EM>Feb 01, 1999</EM>.
-</BODY> </HTML>
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/COMPATIBILITY b/src/diskio/interface/netcdf/netcdf-3.4/src/COMPATIBILITY
deleted file mode 100644
index 6d8815a..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/COMPATIBILITY
+++ /dev/null
@@ -1,319 +0,0 @@
-Overview of Library Changes Between netCDF Version 2 and 3:
-
-NetCDF version 3 includes a complete rewrite of the netCDF library. It
-is about twice as fast as the previous version. The netCDF file format
-is unchanged, so files written with version 3 can be read with version 2
-code and vice versa.
-
-The library is now written in Standard C. For example, prototypes are
-used throughout as well as "const" qualifiers where appropriate. You
-*must* have a Standard C compiler to compile this version.
-
-Rewriting the library to use Standard C offered an opportunity to
-implement an improved C interface that provides some significant
-benefits:
-
- * Type safety, by eliminating the use of generic void* pointers;
-
- * Automatic type conversions, by eliminating the undesirable coupling
- between the language-independent external netCDF types (NC_BYTE, ...,
- NC_DOUBLE) and language-dependent internal data types (char, ...,
- double);
-
- * Support for future enhancements, by eliminating obstacles to the clean
- addition of support for packed data and multithreading;
-
- * More standard error behavior, by uniformly communicating an error
- status back to the calling program in the return value of each
- function.
-
-It is not necessary to rewrite programs that use the version 2
-interface, because the netCDF-3 library includes a backward
-compatibility interface that supports all the old functions, globals,
-and behavior. However, you will have to recompile programs that use
-the version 2 interface if you are going to link them against the
-netCDF-3 library.
-
-We are hoping that the benefits of the new interface will be an
-incentive to use it in new netCDF applications. It is possible to
-convert old applications to the new interface incrementally, replacing
-netCDF-2 calls with the corresponding netCDF-3 calls one at a time. If
-you want to check that only netCDF-3 calls are used in an application,
-a preprocessor macro (NO_NETCDF_2) is available for that purpose.
-
-Other changes in the implementation of netCDF result in improved
-portability, maintainability, and performance on most platforms. A
-clean separation between I/O and type layers facilitates
-platform-specific optimizations. The new library no longer uses a
-vendor-provided XDR library, which simplifies linking programs that
-use netCDF and speeds up data access significantly in most cases. A
-rewrite of the install script provides a simpler installation
-procedure that no longer generates new Makefiles for each platform.
-
-----------------------------------------------------------------------------
-The New C Interface:
-
-First, here's an example of C code that uses the netCDF-2 interface:
-
- void *bufferp;
- nc_type xtype;
- ncvarinq(ncid, varid, ..., &xtype, ...
- ...
- /* allocate bufferp based on dimensions and type */
- ...
- if (ncvarget(ncid, varid, start, count, bufferp) == -1) {
- (void) fprintf(stderr, "Some error message, error code is %d\n"
- ncerr);
- /* deal with it */
- ...
- }
- switch(xtype) {
- /* deal with the data, according to type */
- ....
- case NC_FLOAT:
- fanalyze((float *)bufferp);
- break;
- case NC_DOUBLE:
- danalyze((double *)bufferp);
- break;
- }
-
-Here's how you might handle this with the new netCDF-3 interface:
-
- /*
- * I want to use doubles for my analysis.
- */
- double dbuf[NDOUBLES];
- int status;
-
- /* So, I use the function that gets the data as doubles. */
- status = nc_get_vara_double(ncid, varid, start, count, dbuf)
- if (status != NC_NOERR) {
- (void) fprintf(stderr, "Some error message, %s\n",
- nc_strerror(status));
- /* deal with it */
- ...
- }
- danalyze(dbuf);
-
-The example above illustrates changes in function names, data type
-conversion, and error handling, discussed in detail in the sections below.
-
-----------------------------------------------------------------------------
-The New FORTRAN interface:
-
-The new FORTRAN interface is almost one-for-one identical with the new C
-interface. For example, the following symbols are defined by their
-respective interfaces:
-
- C Interface FORTRAN Interface
- ----------- -----------------
-
- nc_get_vara_double nf_get_vara_double
- nc_get_vara_float nf_get_vara_real
- nc_put_var_int nf_put_var_int
- nc_inq_libvers nf_inq_libvers
- nc_strerror nf_strerror
- nc_open nf_open
- nc_create nf_create
- nc_sync nf_sync
-
-----------------------------------------------------------------------------
-Naming Conventions:
-
-The netCDF-3 library employs a new naming convention, intended to make
-netCDF programs more readable. For example, the name of the function
-to rename a variable is now "nc_rename_var" (FORTRAN: "nf_rename_var")
-instead of the previous "ncvarrename" (FORTRAN: "ncvren").
-
-All function names begin with "nc_" (FORTRAN: "nf_"). The second part
-of the name is a verb, like "get", "put", "inq" (for inquire), or
-"open". The third part of the name is typically the object of the
-verb: for example "dim", "var", or "att" for functions dealing with
-dimensions, variables, or attributes. To distinguish the various I/O
-operations for variables, "var" gets a single character modifier:
-
- "var" access to the entire array
-
- "var1" access to a single value
-
- "vara" access to an array or array section
-
- "vars" strided access to a subsample of values
-
- "varm" mapped access to values not contiguous in memory
-
-At the end of the name for variable and attribute functions, there is
-component indicating the type of the final argument: "text", "uchar",
-"schar", "short", "int", "long", "float", or "double" (FORTRAN:
-"text", "int1", "int2", "int", "real", or "double"). This part of the
-function name indicates the type of the data container you are using
-in your program: character string, "unsigned char", "signed char", and
-so on.
-
-----------------------------------------------------------------------------
-Type Conversion:
-
-With the new interface, users need not be aware of the external type
-of numeric variables, since automatic conversion to or from any
-desired numeric type is now available. You can use this feature to
-simplify code, by making it independent of external types. The
-elimination of void* pointers provides detection of type errors at
-compile time that could not be detected with the previous
-interface. Programs may be made more robust with the new interface,
-because they need not be changed to accommodate a change to the
-external type of a variable.
-
-If conversion to or from an external numeric type is necessary, it is
-handled by the library. This automatic conversion and separation of
-external data representation from internal data types will become even
-more important in netCDF version 4, when new external types will be
-added for packed data for which there is no natural corresponding
-internal type (for example, arrays of 11-bit values).
-
-Converting from one numeric type to another may result in an error if
-the target type is not capable of representing the converted
-value. (In netCDF-2, such overflows can only happen in the XDR layer.)
-For example, a short may not be able to hold data stored externally as
-an NC_FLOAT (an IEEE floating-point number). When accessing an array
-of values, an ERANGE error is returned if one or more values are out
-of the range of representable values, but other values are converted
-properly.
-
-Note that mere loss of precision in type conversion does not return an
-error. Thus, if you read double precision values into a "long", for
-example, no error results unless the magnitude of the double precision
-value exceeds the representable range of "long"s on your
-platform. Similarly, if you read a large integer into a "float"
-incapable of representing all the bits of the integer in its mantissa,
-this loss of precision will not result in an error. If you want to
-avoid such precision loss, check the external types of the variables
-you access to make sure you use an internal type that has a compatible
-precision.
-
-The new interface distinguishes arrays of characters intended to
-represent text strings from arrays of 8-bit bytes intended to
-represent small integers. The interface supports the internal types
-"text", "uchar", and "schar", intended for text strings, unsigned byte
-values, and signed byte values.
-
-The "_uchar" and "_schar" functions were introduced in netCDF-3 to
-eliminate an ambiguity, and support both signed and unsigned byte
-data. In netCDF-2, whether the external NC_BYTE type represented
-signed or unsigned values was left up to the user. In netcdf-3, we
-treat NC_BYTE as signed for the purposes of conversion to "short",
-"int", "long", "float", or "double". (Of course, no conversion takes
-place when the internal type is "signed char".) In the _uchar
-functions, we treat NC_BYTE as if it were unsigned. Thus, no ERANGE
-error can occur converting between NC_BYTE and "unsigned char".
-
-----------------------------------------------------------------------------
-Error handling:
-
-The new interface handles errors differently than netCDF-2. In the old
-interface, the default behavior when an error was detected was to
-print an error message and exit. To get control of error handling, you
-had to set flag bits in a global variable, "ncopts", and to determine
-the cause of an error, you had to test the value of another global
-variable "ncerr".
-
-In the new interface, functions return an integer status that
-indicates not only success or failure, but also the cause of the
-error. The global variables "ncerr" and "ncopt" have been
-eliminated. The library will never try to print anything, nor will it
-call exit() (unless you are using the netCDF version 2 compatibility
-functions). You will have to check the function return status and do
-this yourself. We eliminated these globals in the interest of
-supporting parallel (multiprocessor) execution cleanly, as well as
-reducing the number of assumptions about the environment where netCDF
-is being used. The new behavior should provide better support for
-using netCDF as a hidden layer in applications that have their own GUI
-interface.
-
-----------------------------------------------------------------------------
-NC_LONG and NC_INT:
-
-Where the netCDF-2 interface used NC_LONG to identify an external data
-type corresponding to 32-bit integers, the new interface uses NC_INT
-instead. NC_LONG is defined to have the same value as NC_INT for
-backward compatibility, but it should not be used in new code. With
-new 64-bit platforms using long for 64-bit integers, we would like to
-reduce the confusion caused by this name clash. Note that there is
-still no netCDF external data type corresponding to 64-bit integers.
-
-----------------------------------------------------------------------------
-What's Missing?
-
-The new C interface omits three "record I/O" functions, "ncrecput",
-"ncrecget", and "ncrecinq", from the netCDF-2 interface, although
-these functions are still supported via the netCDF-2 compatibility
-interface. This means you may have to replace one record-oriented call
-with multiple type-specific calls, one for each record variable. For
-example, a single call to "ncrecput" can always be replaced by
-multiple calls to the appropriate "nc_put_var" functions, one call for
-each variable accessed. The record-oriented functions were omitted,
-because there is no simple way to provide type-safety and automatic
-type conversion for such an interface.
-
-There also is no function corresponding to the "nctypelen" function
-from the version 2 interface. The separation of internal and external
-types and the new type-conversion interfaces make "nctypelen"
-unnecessary. Since users read into and write out of native types, the
-"sizeof" operator is perfectly adequate to determine how much space to
-allocate for a value.
-
-In the previous library, there was no checking that the characters
-used in the name of a netCDF object were compatible with the CDL
-restrictions that only alphanumeric characters, "_" and "-" are
-permitted in names. Now this restriction is enforced by the library on
-creation of new dimensions, variables, and attributes, but previously
-existing components with names like "a.b.c" will still work OK.
-
-----------------------------------------------------------------------------
-Other Changes:
-
-There are two new functions in netCDF-3 that don't correspond to any
-netCDF-2 functions: "nc_inq_libvers" and "nc_strerror". The version of
-the netCDF library in use is returned as a string by
-"nc_inq_libvers". An error message corresponding to the status
-returned by a netCDF function call is returned as a string by the
-"nc_strerror" function.
-
-A new NC_SHARE flag is available for use in an "nc_open" or
-"nc_create" call, to suppress the default buffering of accesses. The
-use of NC_SHARE for concurrent access to a netCDF file means you don't
-have to call "nc_sync" after every access to make sure that disk
-updates are synchronous.
-
-The version 2 interface had a single inquiry function, "ncvarinq", for
-getting the name, type, and shape of a variable. Similarly, only a
-single inquiry function was available for getting information about a
-dimension, an attribute, or a netCDF dataset. When you only wanted a
-subset of this information, you had to provide NULL arguments as
-placeholders for the unneeded information. The new interface includes
-additional inquire functions that return each item separately, so
-errors are less likely from miscounting arguments.
-
-The new test program, "nc_test", is run on installation and tests all
-the functions in the new interface. A capability has been added to
-specify an argument to "nc_test" that will test a read-only
-implementations of the netCDF interface.
-
-The previous implementation returned an error when 0-valued count
-components were specified in "ncvarput" and "ncvarget" calls. This
-restriction has been removed, so that now functions in the
-"nc_put_var" and "nc_get_var" families may be called with 0-valued
-count components, resulting in no data being accessed. Although this
-may seem useless, it simplifies some programs to not treat 0-valued
-counts as a special case.
-
-The previous implementation returned an error when the same dimension
-was used more than once in specifying the shape of a variable in
-"ncvardef". This restriction is relaxed in the netCDF-3
-implementation, because an autocorrelation matrix is a good example
-where using the same dimension twice makes sense.
-
-In the new interface, units for the imap argument to the mapped access
-functions "nc_put_varm_*" and "nc_put_varm_*" are now in terms of the
-number of data elements of the desired internal type, not in terms of
-bytes as in the netCDF version-2 mapped access interfaces.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/INSTALL b/src/diskio/interface/netcdf/netcdf-3.4/src/INSTALL
deleted file mode 100644
index aaf43c9..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/INSTALL
+++ /dev/null
@@ -1,996 +0,0 @@
-$Id: INSTALL,v 1.1.1.1 2005/06/14 04:38:29 svitak Exp $
-
-This file contains instructions on how to build and install
-netcdf-3.3.1. If you don't understand them, then PLEASE, PLEASE, PLEASE
-find someone who does. :-)
-
-If you encounter a problem during the installation of this package and
-wish to report it, then see the section "REPORTING PROBLEMS" below.
-
-Read the README file to understand what this release is all about.
-
-You will need about 10 Mbytes of free space to unpack, build, and run the
-tests.
-
-If you wish to build from source on a Win32 platform, there are some
-different instructions. Obtain the following file
-
- ftp://ftp.unidata.ucar.edu/dist/ftp/pub/netcdf/contrib/win32/maks.zip,
-
-unpack it in the parent directory of this one, and read WIN32_INSTALL.
-
-Select and specify an appropriate build environment. You will need a
-Standard C compiler (if you don't have one, then you probably won't be
-able to build this package). Set the environment variables CPPFLAGS,
-CC, CFLAGS, FC, FFLAGS, CXX, and CXXFLAGS (and perhaps LIBS) to
-represent that environment. The section marked "TESTED SYSTEMS" below
-contains a list of systems on which we have tried to build this package,
-the setting we used, and additional, important commentary (USE IT!).
-Feel free to expand this list.
-
-Go to the top-level source directory (i.e. the directory containing this
-INSTALL file).
-
-Decide on where you want to install this package. This will be used
-as the --prefix= argument to the configure script below. The default
-installation prefix is "..", which will install the package's files
-in ../bin, ../lib, ../man, etc. -- relative to the top-level source
-directory.
-
-Execute the configure script:
-
- ./configure [--prefix=_whatever_you_decided]
-
-The square brackets above merely indicate that the "prefix"
-specification is optional: do not type them.
-
-The configure script will examine your computer system -- checking for
-attributes that are relevant to building the netCDF package. It will
-print to standard output the checks that it makes and the results that
-it finds. (It is a good idea to redirect this output and standard
-error to a file -- in case something goes wrong.)
-
-The configure script will also create the file "config.log", which will
-contain error messages from the utilities that the configure script uses
-in examining the attributes of your system. Because such an examination
-can result in errors, it is *expected* that "config.log" will contain
-error messages. Therefore, such messages do not necessarily indicate a
-problem (a better indicator would be failure of the subsequent "make").
-One exception, however, is an error message in "config.log" that
-indicates that a compiler could not be executed (not that it failed,
-mind you, but rather that it couldn't be started). This indicates a
-severe problem in your compilation environment -- one that you must
-fix. If you don't understand what the problem is, then seek out a local
-expert who might.
-
-Run "make". This will build one or more netCDF libraries. It will
-build the basic netCDF library libsrc/libnetcdf.a. If you have a
-Fortran compiler, then the Fortran interface will be included in this
-library. If you have a C++ compiler, then the C++ interface will be
-built into the library cxx/libnetcdf_c++.a. This will also build the
-netCDF utilities ncgen(1) and ncdump(1).
-
-Run "make test" to verify the build. This will build and run
-"libsrc/t_nc", a simple "blunder test". It will also build and run the
-programs "nctest" and "nc_test", which test the version 2 and version 3
-C interfaces, respectively. If you have a Fortran compiler, then this
-will also run the programs "ftest" and "nf_test", which test the version
-2 and version 3 Fortran interfaces, respectively.
-
-Run "make install". Try linking your applications. Let us know if
-you have problems (see REPORTING PROBLEMS below). Let us know how much
-faster it is. Update your applications to the new interface. Write
-new applications using the new interface. Port the library to other
-platforms. Share data.
-
-***********************************************************************
-PORTING NOTES:
-
-The configure and build system should work on any system which has a
-modern "sh" shell, "make", and so on. The configure and build system
-is less portable than the "C" code itself, however. You may run into
-problems with the "include" syntax in the Makefiles. You can use GNU
-make to overcome this, or simply manually include the specified files
-after running configure.
-
-If you can't run "configure", you will need to create libsrc/ncconfig.h
-and fortran/nfconfig.inc. Start with libsrc/ncconfig.in and
-fortran/nfconfig.in and set the defines as appropriate for your
-system.
-
-Operating system dependency is isolated in the "ncio" module. We
-provide two versions. posixio.c uses POSIX system calls like "open()",
-"read()" and "write(). ffio.c uses a special library available on CRAY
-systems. You could create others which used Macintosh or VMS system
-calls. The program "t_ncio.c" can be used as a simple test of this
-layer.
-
-Numerical representation dependency is isolated in the "ncx" module. As
-supplied, ncx.m4 (ncx.c) supports IEEE floating point representation,
-VAX floating point, and CRAY floating point. BIG_ENDIAN vs LITTLE_ENDIAN
-is handled, as well as various sizes of "int", "short", and "long". We
-assume, however, that a "char" is eight bits.
-
-There is a separate implementation of the ncx interface available as
-ncx_cray.c which contains optimizations for CRAY vector architectures.
-Move the generic ncx.c out of the way and rename ncx_cray.c to ncx.c
-to use this module. By default, this module does not use the IEG2CRAY
-and CRAY2IEG library calls. When compiled with aggressive inlining and
-optimization, it provides equivalent functionality with comparable
-speed and clearer error semantics. If you wish to use the IEG library
-functions, compile this module with -DUSE_IEG.
-
-***********************************************************************
-TESTED SYSTEMS:
-
-The following are sets of settings that we've used to build netCDF-3 on
-various systems -- plus commentary. Take your pick if there is more
-than one set of settings for a particular system (for execution speed,
-choose the "-DNDEBUG" and "-O" set; for debugging, choose the "-g" set).
-
-If you don't find your environment listed here, then try URL
-<http://www.unidata.ucar.edu/packages/netcdf/other-builds.html> for
-reports of successfull builds of this package in environments that we
-did not or could not try.
-
-AIX 4.2 (imogene or gale) 2 4 000109423500
- CC=xlc
- CPPFLAGS=
- CFLAGS=-g
- FC=xlf
- FFLAGS=-g
- CXX=xlC
-
- --------
-
- CC=xlc
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=xlf
- FFLAGS=-O
- CXX=xlC
-
-BSD/OS emo 2.1 i386 # Note: release 2.1
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- NOTE: Use the GNU make(1) utility (gmake(1)) rather than
- /usr/bin/make to build the package. The latter utility doesn't
- support the "include" syntax used in the makefiles.
-
- CC=/usr/bin/cc
- CPPFLAGS=-Df2cFortran # "-Df2cFortran" is necessary if fort77(1)
- # is used as the Fortran "compiler".
- CFLAGS=-g
- FC=/usr/local/bin/fort77 # actually an f2c(1)-using script
- FFLAGS="-g -w"
-
-BSD/OS emo 3.0 i386 # Note: release 3.0
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- NOTE: Use the GNU make(1) utility (gmake(1)) rather than
- /usr/bin/make to build the package. The latter utility doesn't
- support the "include" syntax used in the makefiles.
-
- --------
-
- CC=/usr/bin/cc
- CPPFLAGS="-DNDEBUG -Df2cFortran" # "-Df2cFortran" is necessary if
- # fort77(1) is used as the Fortran
- # "compiler".
- CFLAGS=-O
- FC=fort77 # actually an f2c(1)-using script
- FFLAGS="-O -w -Nx400" # "-Nx400" allows fortran/netcdf.inc
- # to have many EXTERNAL statements
- CXX=/usr/bin/g++ # version 2.7.2.1
-
- --------
-
- CC=/usr/bin/cc
- CPPFLAGS="-DNDEBUG -Df2cFortran" # "-Df2cFortran" is necessary if the
- # Fortran "compiler" is fort77(1).
- CFLAGS=-O
- FC=/usr/local/bin/fort77 # actually an f2c(1)-using script
- FFLAGS="-O -w -Nx400" # "-Nx400" allows fortran/netcdf.inc
- # to have many EXTERNAL statements
- CXX=/usr/bin/g++ # version 2.7.2.1
-
-HP-UX robin A.09.05 A 9000/715 2010262449 two-user license
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- Note: Subtle problems that may be difficult to diagnose
- reportedly result if a C application compiled without the "+a" C
- flag is linked against the library compiled with the "+a" C flag.
-
- --------
-
- CC=/bin/c89
- CFLAGS=
- FC=/usr/bin/fort77
- FFLAGS=-w
- CXX=/usr/bin/CC
-
- --------
-
- CC=/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/usr/bin/fort77
- FFLAGS="-O -w"
- CXX=/usr/bin/CC
-
-HP-UX robin B.10.20 E 9000/715 2010262449 8-user license
-
- Note: Subtle problems that may be difficult to diagnose
- reportedly result if a C application compiled without the "+a" C
- flag is linked against the library compiled with the "+a" C flag.
-
- --------
-
- CC=/bin/c89
- CPPFLAGS=-D_HPUX_SOURCE
- CFLAGS=
- FC=/opt/fortran/bin/fort77 # might be /usr/bin/fort77 instead
- FFLAGS=-w
- CXX=/usr/bin/CC
-
- The above results in harmless warnings like the following:
-
- CC: "ncvalues.hh", line 40: warning: "signed" not implemented \
- (ignored) (163)
- CC: "ncvalues.hh", line 43: warning: int initialized with long \
- (103)
- CC: "ncvalues.hh", line 44: warning: const int initialized with \
- long (103)
-
- --------
-
- CC=/bin/c89
- CPPFLAGS="-D_HPUX_SOURCE -DNDEBUG"
- CFLAGS=-O
- FC=/opt/fortran/bin/fort77 # might be /usr/bin/fort77 instead
- FFLAGS="-O3 -w"
- CXX=/usr/bin/CC
-
-IRIX dana 5.3 11091811 IP20 mips
-
- CC=/bin/cc
- CPPFLAGS=
- CFLAGS=-g
- FC=/bin/f77
- FFLAGS=-g
- CXX=/bin/CC
-
- The above results in harmless warnings like the following:
-
- "ncvalues.hh", line 40: warning(3161): integer conversion \
- resulted in a change
-
- --------
-
- CC=/bin/cc
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/bin/f77
- FFLAGS=-O
- CXX=/bin/CC
-
- The above results in harmless warnings like the following:
-
- "ncvalues.hh", line 40: warning(3161): integer conversion \
- resulted in a change
-
-IRIX chevy 6.2 03131015 IP22
-
- IRIX f90 Note: On IRIX 6.x platforms with version 7 compilers,
- the f90 compiler accepts 'integer*1', while f77
- accepts both 'integer*1' and 'byte'. Using
- FC=f90 forces the configure script to select 'integer*1'.
- The resulting *.inc files and test configurations will then
- work with either compiler.
-
- --------
-
- CC=/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FC=/bin/f77
- FFLAGS=-g
- CXX=/bin/CC
-
- The above results in harmless warnings like the following:
-
- "ncvalues.hh", line 40: warning(3161): integer conversion resulted
- in a change
-
- --------
-
- CC="/bin/cc -n32"
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC="/bin/f77 -n32"
- FFLAGS=-O
- CXX="/bin/CC -n32"
-
- The above results in harmless warnings like the following:
-
- "ncgen.y", line 1127: warning(1172): subscript out of range
-
- --------
-
- CC=/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/bin/f77
- FFLAGS=-O
- CXX=/bin/CC
-
- The above results in harmless warnings like the following:
-
- "ncvalues.hh", line 40: warning(3161): integer conversion \
- resulted in a change
-
-IRIX64 flip 6.4 02121744 IP30
-
- See IRIX f90 Note above.
-
- --------
-
- CC=/bin/cc
- CPPFLAGS=
- CFLAGS=-g
- FC=/bin/f77
- FFLAGS=-g
- CXX=/bin/CC
-
- The above results in harmless warnings like the following:
-
- "ncgen.y", line 1127: warning(1172): subscript out of range
-
- --------
-
- CC="/bin/cc -64"
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC="/bin/f77 -64"
- FFLAGS=-O
- CXX="/bin/CC -64"
-
- The above results in harmless warnings like the following:
-
- "load.c", line 187: warning(1178): argument is incompatible with ...
- "ncgen.y", line 1127: warning(1172): subscript out of range
-
- --------
-
- CC=/bin/cc
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/bin/f77
- FFLAGS=-O
- CXX=/bin/CC
-
- The above results in harmless warnings like the following:
-
- "ncgen.y", line 1127: warning(1172): subscript out of range
-
-Linux sunshine 2.0.31 #1 Sun Nov 9 21:45:23 EST 1997 i586
- CC=/usr/bin/cc # actually gcc version 2.7.2.3
- CPPFLAGS=-Df2cFortran # "-Df2cFortran" is necessary if the Fortran
- # "compiler" is fort77(1).
- CFLAGS=-g
- FC=/usr/bin/fort77 # actually an f2c(1)-using script
- FFLAGS="-g -Nx400 -w" # "-Nx400" allows fortran/netcdf.inc to
- # have many EXTERNAL statements
- CXX=/usr/bin/c++ # actually gcc version 2.7.2.3
-
- --------
-
- CC=/usr/bin/cc # actually gcc version 2.7.2.3
- CPPFLAGS="-DNDEBUG -Df2cFortran" # "-Df2cFortran" is necessary if
- # the Fortran "compiler" is fort77(1).
- CFLAGS=-O
- FC=/usr/bin/fort77 # actually an f2c(1)-using script
- FFLAGS="-O -Nx400 -w" # "-Nx400" allows fortran/netcdf.inc to
- # have many EXTERNAL statements
- CXX=/usr/bin/c++ # actually gcc version 2.7.2.3
-
- If you get errors similar to the following:
-
- ... undefined reference to `GLOBAL_OFFSET_TABLE_'
-
- then your gcc(1) compiler probably doesn't support ELF binaries --
- though your kernel does. Try gcc(1) version 2.7.2 or later.
-
-OSF1 ernie V4.0B 564 alpha
- CC=/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FC=/bin/f77
- FFLAGS=-g
- CXX=g++
-
- --------
-
- CC=/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/bin/f77
- FFLAGS=-O
- CXX=g++
-
- The above results in a harmless warning like the following:
-
- cc: Warning: ncgen.l, line 26: The redefinition of the macro
- "YY_BREAK" conflicts with a current definition because the
- replacement lists differ. The redefinition is now in effect.
-
-SunOS gummo 4.1.4 11 sun4m
- # SunOS 4 will complain bitterly due to its hosed (non ANSI)
- # <string.h>. This is harmless. May be suppressed by CFLAGS=-w .
- CC=acc # SC3.0.1
- CPPFLAGS=-DNDEBUG # Because the SunOS 4 assert() macro is non ANSI,
- # always compile the library -DNDEBUG on these systems.
- CFLAGS=-g
- FC=f77 # SC3.0.1
- FFLAGS="-g -w"
- CXX=CC # SC3.0.1
-
- --------
-
- CC=acc # SC3.0.1
- CPPFLAGS=-DNDEBUG # Because the SunOS 4 assert() macro is non ANSI,
- # always compile the library -DNDEBUG on these systems.
- CFLAGS="-O -temp=." # Insufficient room in "/tmp/" for temporary files
- # => we use current directory. You might be OK.
- FC=f77 # SC3.0.1
- FFLAGS="-O -w -temp=."
- # Insufficient room in "/tmp/" for temporary files
- # => we use current directory. You might be OK.
- CXX=CC # SC3.0.1
- LIBS=-ldl # For some reason our linker needed to be told
- # to use the dynamic-link library. This shouldn't
- # have occurred and might not be necessary outside
- # the Unidata Program Center.
-
- --------
-
- CC=gcc # version 2.7.2.2
- CPPFLAGS="-DNDEBUG -D__USE_FIXED_PROTOTYPES__"
- # -D__USE_FIXED_PROTOTYPES__ shouldn't hurt and is
- # necessary for some gcc(1) installations.
- CFLAGS=-g
- FC=f77 # SC3.0.1
- FFLAGS="-g -w"
- CXX=g++ # version 2.7.2.2
- LIBS="-L/usr/lang/SC3.0.1/lib -lansi" # To obtain memmove(). Given
- # this dependency, one might be better off using
- # acc(1) instead of gcc(1).
-
-SunOS meeker 4.1.3 3 sun4m
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- # SunOS 4 will complain bitterly due to its hosed (non ANSI)
- # <string.h>. This is harmless. May be suppressed by CFLAGS=-w .
- CC=acc # acc: SC3.0.1 7/13/94
- CPPFLAGS=-DNDEBUG # Because the SunOS 4 assert() macro is non ANSI,
- # always compile the library -DNDEBUG on these systems.
- CFLAGS=-O
- FFLAGS="-O -w"
- 796.8u 240.6s 19:45 87% 0+2780k 839+7664io 2445pf+0w
- CFLAGS=-O4
- FFLAGS="-O4 -w"
- 1728.8u 290.5s 36:46 91% 0+3896k 988+8896io 5034pf+0w
-
-SunOS laraine 5.5 Generic sun4u sparc SUNW,Ultra-2
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-g -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O # -xO5 works too
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-O -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FPP=fpp # necessary for correct preprocessing
- FPPFLAGS=-D__SUNPRO_F90 # necessary for correct preprocessing
- COMPILE_F= # necessary for correct preprocessing
- FC=/opt/SUNWspro/bin/f90 # SC4.2 Fortran 90 compiler 1.2
- FFLAGS="-g -w" # "-w" disables an ignorable warning.
- CXX=/opt/SUNWspro/bin/CC
-
-SunOS wcfields 5.5 Generic_103093-07 sun4m sparc SUNW,SPARCstation-10
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- CC=cc # cc: WorkShop Compilers 4.2 15 Oct 1996 C 4.2
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
-
- --------
-
- CFLAGS=-g
- CC="cc -v -errtags -xtransition -Xa"
- # Passes dbx(1)'s "check -all"
-
-SunOS laraine 5.6 Generic sun4u sparc SUNW,Ultra-2
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-g -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-O -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FPP=fpp # necessary for correct preprocessing
- FPPFLAGS=-D__SUNPRO_F90 # necessary for correct preprocessing
- COMPILE_F= # necessary for correct preprocessing
- FC=/opt/SUNWspro/bin/f90 # SC4.2 Fortran 90 compiler 1.2
- FFLAGS="-g -w" # "-w" disables an ignorable warning.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS="-O `getconf LFS_CFLAGS`" # for large file compilation environment
- FPP=fpp # necessary for correct preprocessing
- FPPFLAGS=-D__SUNPRO_F90 # necessary for correct preprocessing
- COMPILE_F= # necessary for correct preprocessing
- FC=/opt/SUNWspro/bin/f90 # SC4.2 Fortran 90 compiler 1.2
- FFLAGS="-O -w" # "-w" disables an ignorable warning.
- CXX=/opt/SUNWspro/bin/CC
- LDFLAGS=`getconf LFS_LDFLAGS` # for large file compilation environment
- LIBS=`getconf LFS_LIBS` # for large file compilation environment
-
-SunOS lenny 5.6 Generic_105182-01 i86pc i386 i86pc
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=
- CFLAGS=-g
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-g -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-O -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
-
- --------
-
- CC=/opt/SUNWspro/bin/c89
- CPPFLAGS=-DNDEBUG
- CFLAGS="-O `getconf LFS_CFLAGS`" # for large file compilation environment
- FC=/opt/SUNWspro/bin/f77
- FFLAGS="-O -erroff=WDECL_LOCAL_NOTUSED" # "-erroff=..." turns
- # off an ignorable warning.
- # Your compiler may differ.
- CXX=/opt/SUNWspro/bin/CC
- LDFLAGS=`getconf LFS_LDFLAGS` # for large file compilation environment
- LIBS=`getconf LFS_LIBS` # for large file compilation environment
-
-
-sn9607 (UNICOS) ouray 10.0.0 and.2 CRAY J90
- Cray Standard C Version 6.0.1.3 03/04/98 14:55:01
- Cray CF90 Version 3.0.1.3 03/04/98 14:55:17
- Cray C++ Version 3.0.1.3 03/04/98 15:13:33
-Fri Mar 6 14:37:42 MST 1998
-
- The "-F" option in the following causes the Fortran compiler to
- 1) do its own preprocessing of *.F files rather than use a separate
- utility; and 2) substitute macros in code as well as in conditional
- compilation directives (which is necessary).
-
- Before executing make(1), manually copy the file "libsrc/ncx_cray.c"
- to file "libsrc/ncx.c". See the commentary at the top of this file
- for more information.
-
- --------
-
- # The following requires about 46.3 MB for the source build-and-test
- # directory hierarchy, and about 6.8 MB for the installation
- # directory hierarchy.
- CC=/opt/ctl/bin/cc
- CPPFLAGS=
- CFLAGS= -O3 # -g works as well
- FC=/opt/ctl/bin/f90
- FFLAGS="-g -F -dp" # "-F" enables macro substitution in code.
- # "-dp" enables DOUBLEPRECISION/double
- # equivalence.
- CXX=/opt/ctl/bin/CC
- CXXFLAGS= # "-h char" may be necessary with
- # older rev C++ compilers
-
- The 'C' compiler may run out of memory compiling libsrc/putget.c
- using "-O3" option.
- cc-7951 cc: LIMIT File = putget.c, Line = 6617
- Insufficient memory is available for compiler to continue.
- (We don't see this problem anymore.) You can work around this
- by compiling -O2
- cd libsrc; c89 -c -O2 -I. -DNDEBUG putget.c
- and continuing with the build.
-
- The C compiler issues some warnings:
- cc-7212 c89: ... Variable "xx" is used before it is defined.
- We believe these are unfounded. Since the only appear with
- optimisation, they may be due to the compiler's inlining strategy.
-
- In nf_test, you can ignore the following warning:
- ldr-290 f90: CAUTION
- Duplicate entry point 'HASH' was encountered.
- Entry in module 'HASH' from file 'util.o' has been used.
- Entry in module '$ZZFFLOW' from file '/opt/ctl/mpt/mpt/lib/libc.a' has
- been ignored.
-
-
-sn4031 antero 9.0.2.5 and.15 CRAY C90
- Cray Standard C Version 6.0.1.3 03/04/98 15:01:58
- Cray CF90 Version 3.0.1.3 03/04/98 15:02:10
- Cray C++ Version 3.0.1.3 03/06/98 15:23:50
-Fri Mar 6 15:43:25 MST 1998
-
- This example is for a CRAY C90 and *not* for a CRAY T3D that is
- being front-ended by a C90.
-
- Before proceeding with make(1), manually copy the file
- "libsrc/ncx_cray.c" to file "libsrc/ncx.c". See the commentary at
- the top of this file for more information.
-
- CC=cc
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O3
- FC=f90
- FFLAGS="-g -F -dp" # -F is equiv to old -Wp-F
-
- The 'C' compiler may run out of memory compiling libsrc/putget.c
- using "-O3" option.
- cc-7951 cc: LIMIT File = putget.c, Line = 6617
- Insufficient memory is available for compiler to continue.
- (We don't see this problem anymore.) You can work around this
- by compiling -O2
- cd libsrc; c89 -c -O2 -I. -DNDEBUG putget.c
- and continuing with the build.
-
- The C compiler issues some warnings:
- cc-7212 c89: ... Variable "xx" is used before it is defined.
- We believe these are unfounded. Since the only appear with
- optimisation, they may be due to the compiler's inlining strategy.
-
-
-sn4031 antero 9.0.2.5 and.15 CRAY C90 TARGET cray-t3d
- Cray Standard C Version 5.0.5.0 (d34p55m295a41) Mar 6 1998 15:51:17
- Cray CF90 Version 2.0.4.0 03/06/98 15:51:53
- Cray C++ Version 2.0.4.0 03/06/98 15:52:20
-Fri Mar 6 15:52:34 MST 1998
-
- This example is for a CRAY T3D that is being front-ended by a CRAY
- C90 and *not* for the C90 itself.
-
- Have /mpp/bin at the head of your PATH.
-
- Set this environment variable so that the configure script
- (and tests) will be run on the t3d.
- TARGET=cray-t3d
-
- Set this environment variable so that the configure script
- (and tests) will be run on a single processor of the t3d.
- MPP_NPES=1
-
- CC=cc
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=f90
- FFLAGS="-g -F -dp"
- CXX="" # problems compiling cplusplus, use CXXFLAGS="-h char"?
-
-
-sn7203 t90 9.1.0.1 gfd.11 CRAY TS
- Cray Standard C Version 5.0.1.0 (d27p23g111a29) Mar 6 1998 22:56:40
- Cray CF90 Version 2.0.4.0 03/06/98 22:56:40
- Cray C++ Version 2.0.1 03/06/98 22:56:41
-Fri Mar 6 22:29:16 MST 1998
-
- Before proceeding with make(1), manually copy the file
- "libsrc/ncx_cray.c" to file "libsrc/ncx.c". See the commentary at
- the top of this file for more information.
-
- CC=cc
- CFLAGS=-O3
- FC=f90
- FFLAGS="-g -F -dp" # -O3 works as well as -g
- CXX=CC
- CXXFLAGS="-h char" # needed with this version
-
- This compiler version (or environment) still chokes on libsrc/putget.c
- cc -c -O3 -I. -DNDEBUG putget.c
- cc-7951 cc: LIMIT File = putget.c, Line = 6617
- Insufficient memory is available for compiler to continue.
- Recompile manually at lower optimisation level.
- cd libsrc ; cc -c -O2 -I. -DNDEBUG putget.c
-
-
-
-sn6602 t3e 2.0.2.15 unicosmk CRAY T3E
- Cray Standard C Version 5.0.3.0 (d29p35m275a35) Mar 7 1998 00:42:04
- Cray CF90 Version 2.0.3.4 03/07/98 00:42:05
- Cray C++ Version 2.0.3 03/07/98 00:42:06
-
- CC=cc
- CFLAGS=-O3
- FC=f90
- FFLAGS='-g -F -M1110'
- CXX=CC
- CXXFLAGS="-h char" # needed with this version
-
-
- 'C' compiler still chokes on libsrc/putget.c
- c89 -c -O3 -I. -DNDEBUG putget.c
- cc-7951 c89: LIMIT File = putget.c, Line = 6617
- Insufficient memory is available for compiler to continue.
- (56% of the way through the file. This is with a pragma to
- prevent inlining of odo1.)
-
-
-SUPER-UX unix 7.2 SX-4 (sx4.hstc.necsyl.com)
- Wed Sep 17 13:30:59 MDT 1997
- /home/cust/ncar1/netcdf-3.3.2b/{lib,lib_float2}
-
- CC="cc -Xa"
- CFLAGS=-h2
- FC=f90
- FFLAGS=""
- CXX=""
-
- Passes libsrc/t_nc.
- Passes nctest.
- nc_test:
- 30 failures in nc_test for _long functions.
- Okay to ignore: cpp problem sets up improper ranges for test.
- (cpp problem reported to NEC)
- fortran/ftest works.
- Compiling nftest: Many (ignoreable) warn(82)
- nf_test:
- 6435 failures
- get_int1: Range error: No error
- get_int2: Range error: No error
- Okay to ignore.
- put_real: Var value read not that expected
- ???
- Passes ncdump test.
- Minor roundoff errors in test of ncgen.
- < i:d = -1.e+308, ...
- ---
- > i:d = -9.99999999999999e+307, ...
-
- There are SX specific hacks in nc_test and ncx.m4 to deal with
- the broken C preprocessor.
-
-
- Cray compatibility options:
- CC="cc -Xa -hfloat2 -hint64"
- CFLAGS=-h2
- FC="f90 -float2"
- FFLAGS=""
- CXX=""
- FLDFLAGS="-Wl -int64" # needed for the interlanguage linkage
- LIBS=-lm # needed for ie3_fl2(), fl2_ie3()
-
- Passes libsrc/t_nc.
- Passes nctest.
- Passes nc_test.
- Passes fortran/ftest.
- nf_test:
- get_int1: Range error: No error
- get_int2: Range error: No error
- Total number of failures: 6412
- Okay to ignore - int1 and int2 types are integer
- Minor roundoff errors in test of ncdump.
- < 7, 8, 9.99999999999989e+29 ;
- ---
- > 7, 8, 9.99999999999977e+29 ;
- Minor roundoff errors in test of ncgen.
- < i:d = -9.99999999999881e+307, 0., 9.99999999999881e+307 ;
- ---
- > i:d = -9.9999999999975e+307, 0., 9.9999999999975e+307 ;
- ...
-
-
-ULTRIX curly 4.5 0 RISC
-
- (netCDF 3.3 example follows; netCDF 3.4 not tested)
-
- CC=gcc # gcc version 2.7.2
- CPPFLAGS=
- CFLAGS=-g
- FC=/usr/bin/f77
- FFLAGS="-g -fpe1" # "-fpe1" is necessary to allow the netCDF
- # package to return NC_ERANGE rather than generate
- # SIGFPE (which would terminate the program)
- CXX=g++ # version 2.7.2
- LIBS=/usr/local/gnu/lib/gcc-lib/mips-dec-ultrix4.5/2.7.2/libgcc.a
- # LIBS is needed because even Fortran programs
- # will references the GNU C library due to CC=gcc
-
- --------
-
- CC=gcc # gcc version 2.7.2
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- FC=/usr/bin/f77
- FFLAGS="-O -fpe1" # "-fpe1" is necessary to allow the netCDF
- # package to return NC_ERANGE rather than generate
- # SIGFPE (which would terminate the program)
- CXX=g++ # version 2.7.2
- LIBS=/usr/local/gnu/lib/gcc-lib/mips-dec-ultrix4.5/2.7.2/libgcc.a
- # LIBS is needed because even Fortran programs
- # will references the GNU C library due to CC=gcc
-
-ULTRIX milton 4.4 0 VAX
- CC=gcc # gcc version 2.7.2
- CPPFLAGS=
- CFLAGS=-g
- FC= # The Fortran interface can't be built because the
- # f77(1) compiler can't handle underscores in names
- # and doesn't support exclamation points as comment
- # delimiters. Try g77(1)?
- CXX=g++ # g++ version 2.7.2
-
- --------
-
- CC=gcc # gcc version 2.7.2
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O # If you use this option, then you will have to
- # *manually* compile libsrc/ncx.c
- FC= # The Fortran interface can't be built because the
- # f77(1) compiler can't handle underscores in names
- # and doesn't support exclamation points as comment
- # delimiters. Try g77(1)?
- CXX=g++ # g++ version 2.7.2
-
- NOTE: If you use gcc(1) with the "-O" option in CFLAGS, then
- gcc(1)'s optimizer will probably corrupt the structure layouts
- in "libsrc/ncx.c". The symptom of this is that "libsrc/t_nc"
- fails during the "make test". Thus, you will probably have to
- manually compile the file "libsrc/ncx.c" -- without the "-O"
- option -- before executing the "make". For example:
-
- $ ./configure
- ...
- $ cd libsrc
- $ make ncx.o CFLAGS=
- ...
- $ cd ..
- $ make
- ...
-
- It appears that, if you need to build the netCDF-3 Fortran interface
- on a VAX ULTRIX system, we're afraid you're on your own (we couldn't
- do it). You might try using the GNU Fortran compiler g77(1) instead
- of the native Fortran compiler. We are happy to advise in this
- effort but would be unwilling, at this time, to modify the code
- solely to support this (now ancient) system.
-
-UNIX_SV sx4iox 4.2MP 1.release.1023.06:17 R4000 r4000 (sx4iox.hstc.necsyl.com)
- /home/d51djp/netcdf-3.3a
- CPPFLAGS=-DNDEBUG
- CFLAGS=-O
- (cd fortran; ln -s irix5.m4 unix_sv.m4)
- nc_test has 74 failures, problems with extremal values.
-
-***********************************************************************
-Other platforms verified at 3.1a (an earlier version):
-
-NeXT Computer, Inc. version cc-216.obj~13, gcc version 2.2.2
-(M68K, NeXTStep 3.1)
- CFLAGS = -g
- CC = cc -Wall -D_POSIX_SOURCE
- Problems with put,get_uchar in nc_test due to bugs in this
-old version of gcc. Can be safely ignored?
-
-***********************************************************************
-REPORTING PROBLEMS:
-
-If you have a problem with the installation and wish to report it, then
-please do the following:
-
- 1. Re-read and understand all of this INSTALL document --
- especially all examples and commentary relevant to your system.
-
- 2. Go to the top-level source directory (the directory containing
- this file).
-
- 3. Execute the command "make distclean". Don't worry if it fails.
-
- 4. Remove the file "config.cache" if it exists.
-
- 5. Set your environment variables as described above.
-
- 6. Re-execute the configure script. Redirect its standard output
- and standard error to the file "configure.log". If this step
- fails -- which is indicated by error messages (not warnings) in
- "configure.log" -- then stop and send items A through E below to
- <support at unidata.ucar.edu>.
-
- 7. Execute the command "make". Redirect its standard output
- and standard error to the file "make.log". If this step
- fails, then stop and send items A through F below to
- <support at unidata.ucar.edu>.
-
- 8. Execute the command "make test". Redirect its standard
- output and standard error to the file "test.log". If this
- step fails, then stop and send items A through G below to
- <support at unidata.ucar.edu>.
-
- 9. Execute the command "make install". Redirect its standard
- output and standard error to the file "install.log". If this
- step fails, then stop and send items A through H below to
- <support at unidata.ucar.edu>.
-
-The following items help us diagnose installation problems:
-
- A. The standard output of the command "uname -a".
-
- B. The contents of the file VERSION, which is in the top-level
- source directory.
-
- C. The absolute pathnames of all compilers (C, Fortran, C++) used
- in the build process (use the type(1) or which(1) utility to
- determine this).
-
- D. The file "configure.log" from step 6 above.
-
- E. The file "config.log", which is created in the top-level source
- directory by the configure script during step 6 above.
-
- F. The file "make.log" from step 7 above.
-
- G. The file "test.log" from step 8 above.
-
- H. The file "install.log" from step 9 above.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/MANIFEST b/src/diskio/interface/netcdf/netcdf-3.4/src/MANIFEST
deleted file mode 100644
index 6d01766..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/MANIFEST
+++ /dev/null
@@ -1,173 +0,0 @@
-INSTALL
-COMPATIBILITY
-MANIFEST
-Makefile
-README
-VERSION
-aclocal.m4
-configure
-configure.in
-macros.make.in
-macros.make.def
-rules.make
-libsrc/attr.c
-libsrc/dim.c
-libsrc/error.c
-libsrc/libvers.c
-libsrc/nc.c
-libsrc/ncio.c
-libsrc/ncx.c
-libsrc/putget.c
-libsrc/string.c
-libsrc/v1hpg.c
-libsrc/v2i.c
-libsrc/var.c
-libsrc/attr.m4
-libsrc/depend
-libsrc/fbits.h
-libsrc/Makefile
-libsrc/nc.h
-libsrc/ncconfig.in
-libsrc/ncio.h
-libsrc/ncx.m4
-libsrc/onstack.h
-libsrc/putget.m4
-libsrc/ffio.c
-libsrc/posixio.c
-libsrc/ncx.h
-libsrc/ncx_cray.c
-libsrc/netcdf.3
-libsrc/netcdf.h
-libsrc/rnd.h
-libsrc/test_nc.sav
-libsrc/t_nc.c
-libsrc/t_ncio.c
-libsrc/t_ncxx.m4
-libsrc/t_ncxx.c
-libsrc/t_ncx.c
-nctest/add.c
-nctest/add.h
-nctest/atttests.c
-nctest/cdftests.c
-nctest/depend
-nctest/dimtests.c
-nctest/driver.c
-nctest/emalloc.c
-nctest/emalloc.h
-nctest/error.c
-nctest/error.h
-nctest/Makefile
-nctest/misctest.c
-nctest/nctime.c
-nctest/README
-nctest/rec.c
-nctest/slabs.c
-nctest/testcdf.h
-nctest/testfile_nc.sav
-nctest/tests.h
-nctest/timesum.awk
-nctest/val.c
-nctest/val.h
-nctest/vardef.c
-nctest/varget.c
-nctest/vargetg.c
-nctest/varput.c
-nctest/varputg.c
-nctest/vartests.c
-nctest/vputget.c
-nctest/vputgetg.c
-nc_test/nc_test.c
-nc_test/error.c
-nc_test/test_get.c
-nc_test/test_put.c
-nc_test/test_read.c
-nc_test/test_write.c
-nc_test/util.c
-nc_test/test_get.m4
-nc_test/test_put.m4
-nc_test/error.h
-nc_test/tests.h
-nc_test/depend
-nc_test/Makefile
-fortran/cfortran.doc
-fortran/cfortran.h
-fortran/depend
-fortran/fills.nc
-fortran/fort-attio.c
-fortran/fort-control.c
-fortran/fort-dim.c
-fortran/fort-genatt.c
-fortran/fort-geninq.c
-fortran/fort-genvar.c
-fortran/fort-lib.c
-fortran/fort-lib.h
-fortran/fort-misc.c
-fortran/fort-v2compat.c
-fortran/fort-vario.c
-fortran/fort-var1io.c
-fortran/fort-varaio.c
-fortran/fort-varmio.c
-fortran/fort-varsio.c
-fortran/ftest.F
-fortran/Makefile
-fortran/ncfortran.h
-fortran/netcdf.3f
-fortran/netcdf.inc
-fortran/nfconfig.in
-nf_test/fortlib.c
-nf_test/test_get.F
-nf_test/test_put.F
-nf_test/nf_error.F
-nf_test/nf_test.F
-nf_test/test_read.F
-nf_test/test_write.F
-nf_test/util.F
-nf_test/test_get.m4
-nf_test/test_put.m4
-nf_test/depend
-nf_test/Makefile
-nf_test/tests.inc
-ncdump/ncdump.c
-ncdump/vardata.c
-ncdump/dumplib.c
-ncdump/ncdump.h
-ncdump/vardata.h
-ncdump/dumplib.h
-ncdump/depend
-ncdump/test0.cdl
-ncdump/ncdump.1
-ncdump/Makefile
-ncgen/Makefile
-ncgen/depend
-ncgen/escapes.c
-ncgen/generic.h
-ncgen/ncgenyy.c
-ncgen/ncgentab.c
-ncgen/ncgentab.h
-ncgen/genlib.c
-ncgen/genlib.h
-ncgen/getfill.c
-ncgen/init.c
-ncgen/load.c
-ncgen/main.c
-ncgen/ncgen.1
-ncgen/ncgen.h
-ncgen/ncgen.l
-ncgen/ncgen.y
-ncgen/c0.cdl
-man/Makefile
-man/netcdf.m4
-cxx/Makefile
-cxx/README
-cxx/depend
-cxx/example.c
-cxx/example.cc
-cxx/nctst.cc
-cxx/ncvalues.cc
-cxx/ncvalues.hh
-cxx/netcdf.cc
-cxx/netcdf.hh
-cxx/expected
-cxx/cxxdoc.tex
-cxx/cxxdoc.ps
-cxx/texinfo.tex
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/Makefile
deleted file mode 100644
index 90bc4cb..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/Makefile
+++ /dev/null
@@ -1,193 +0,0 @@
-# $Id: Makefile,v 1.2 2005/08/04 19:58:47 svitak Exp $
-# $Log: Makefile,v $
-# Revision 1.2 2005/08/04 19:58:47 svitak
-# Removed references and files related to fortran and c++ modules not used by
-# Genesis.
-#
-# Revision 1.1.1.1 2005/06/14 04:38:29 svitak
-# Import from snapshot of CalTech CVS tree of June 8, 2005
-#
-# Revision 1.3 2000/06/22 22:54:15 mhucka
-# Removed directives that built the FORTRAN and C++ portions.
-# GENESIS doesn't use them.
-#
-
-include macros.make
-
-
-PACKAGE = netcdf
-SUBDIRS = libsrc nctest nc_test ncdump ncgen man
-DIST_GARBAGE = \
- config.cache \
- config.status \
- MANIFEST
-PACKING_LIST = \
- INSTALL \
- COMPATIBILITY \
- MANIFEST \
- Makefile \
- README \
- VERSION \
- aclocal.m4 \
- configure \
- configure.in \
- macros.make.in \
- macros.make.def \
- rules.make
-
-
-all: libsrc/all \
- ncdump/all \
- ncgen/all
-
-test: libsrc/test \
- nctest/test nc_test/test \
- ncdump/test ncgen/test
-
-check: test
-
-install: libsrc/install \
- ncdump/install \
- ncgen/install \
- $(MANDIR)/$(WHATIS)
-
-clean: libsrc/clean \
- nctest/clean nc_test/clean \
- ncdump/clean ncgen/clean \
- clean_config
-
-distclean: libsrc/distclean \
- nctest/distclean nc_test/distclean \
- ncdump/distclean ncgen/distclean \
- clean_macros
-
-clean_config:
- -rm -f config.cache
-
-clean_macros:
- -cp macros.make.def macros.make
-
-libsrc/all \
-libsrc/test \
-libsrc/install \
-libsrc/clean \
-libsrc/distclean \
-nctest/all \
-nctest/test \
-nctest/clean \
-nctest/distclean \
-nc_test/all \
-nc_test/test \
-nc_test/clean \
-nc_test/distclean \
-ncdump/all \
-ncdump/test \
-ncdump/install \
-ncdump/clean \
-ncdump/distclean \
-ncgen/all \
-ncgen/test \
-ncgen/install \
-ncgen/clean \
-ncgen/distclean \
-:
- @subdir=`echo $@ | sed 's,/.*,,'`; \
- target=`echo $@ | sed 's,.*/,,'`; \
- $(MAKE) SUBDIR=$$subdir TGET=$$target subdir_target
-
-subdir_target:
- @echo ""
- @cd $(SUBDIR) && \
- echo "Making \`$(TGET)' in directory `pwd`" && \
- echo "" && \
- $(MAKE) $(TGET) || exit 1
- @echo ""
- @echo "Returning to directory `pwd`"
- @echo ""
-
-
-################################################################################
-# Distribution:
-
-# The following rule checks to see that were on the right system. If we're
-# not, then the distribution mightn't contain the intended ncgen(1) (not
-# to mention that dvips(1) is necessary for building the C++ User's Guide).
-#
-check_system: FORCE
- @case "$(OVERRIDE)" in \
- '') case `uname -sr` in \
- 'SunOS 5'*) \
- exit 0;; \
- *) echo 1>&2 "Error: Not on a SunOS 5 system."; \
- echo 1>&2 "Set macro OVERRIDE to override."; \
- exit 1;; \
- esac;; \
- *) exit 0;; \
- esac
-
-# Make a compressed, tar(1) file of the source distribution in the current
-# directory.
-#
-tar.Z: check_system FORCE
- @version=`cat VERSION`; \
- $(MAKE) $(MFLAGS) $(PACKAGE)-$$version.tar.Z VERSION=$$version
-
-$(PACKAGE)-$(VERSION).tar.Z: ensure_manifest MANIFEST
- id=$(PACKAGE)-$(VERSION) \
- && rm -rf $$id \
- && mkdir $$id \
- && ln -s .. $$id/src \
- && tar $(TARFLAGS) - `sed "s|^|$$id/src/|" MANIFEST` | compress > $@ \
- && rm -r $$id
-
-MANIFEST: FORCE
- $(MAKE) MANIFEST.echo >$@
-
-# Make a compressed, tar(1) file of the source distribution in the
-# appropriate FTP directory.
-#
-# NOTE: Making "ftp" will cause the "tar.Z" file to be made even if it
-# already exists. This is because the MANIFEST file upon which it
-# depends must be remade every time. This is not a waste of time,
-# however, if the "tar.Z" target is made in private directories and the
-# "ftp" target is made in the "/upc/$(PACKAGE)/build/" directory.
-#
-ftp: check_system FORCE
- version=`cat VERSION`; \
- $(MAKE) $(MFLAGS) $(FTPDIR)/$(PACKAGE)-$$version.tar.Z \
- VERSION=$$version; \
- test -r $(FTPDIR)/$(PACKAGE).tar.Z || exit 0; \
- cd $(FTPDIR) || exit 1; \
- rm $(PACKAGE).tar.Z || exit 1; \
- ln -s $(PACKAGE)-$$version.tar.Z $(PACKAGE).tar.Z;
-
-$(FTPDIR)/$(PACKAGE)-$(VERSION).tar.Z: $(PACKAGE)-$(VERSION).tar.Z
- rm -f $@
- cp $(PACKAGE)-$(VERSION).tar.Z $@
- chmod u+rw,g+rw,o=r $@
-
-# Make a compressed, tar(1) file of the binary distribution in the
-# appropriate FTP directory.
-#
-binftp: FORCE
- version=`cat VERSION`; \
- $(MAKE) $(MFLAGS) $(FTPBINDIR)/$(PACKAGE)-$$version.tar.Z \
- VERSION=$$version
-ftpbin: binftp
-
-$(FTPBINDIR)/$(PACKAGE)-$(VERSION).tar.Z:
- rm -f $@
- id=$(PACKAGE)-$(VERSION) \
- && rm -f $$id \
- && ln -s $(prefix) $$id \
- && tar $(TARFLAGS) - README $$id/bin $$id/include \
- $$id/lib $$id/man | compress > $@ \
- && rm $$id
- chmod u+rw,g+rw,o=r $@
- test -r $(FTPBINDIR)/$(PACKAGE).tar.Z || exit 0; \
- cd $(FTPBINDIR) || exit 1; \
- rm $(PACKAGE).tar.Z || exit 1; \
- ln -s $(PACKAGE)-$(VERSION).tar.Z $(PACKAGE).tar.Z;
-
-
-include rules.make
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/README b/src/diskio/interface/netcdf/netcdf-3.4/src/README
deleted file mode 100644
index 709f6ba..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/README
+++ /dev/null
@@ -1,34 +0,0 @@
-NetCDF-3 Release
-
-This document describes version 3 of the netCDF package (otherwise known
-as "netCDF-3"). For an overview of netCDF, see the netCDF Web page at
-
- http://www.unidata.ucar.edu/packages/netcdf/
-
-Legal stuff (copyright, licensing restrictions, etc.) can be found in
-the file COPYRIGHT.
-
-To install this package, please see the file INSTALL.
-
-The netCDF-3 C and FORTRAN interfaces are documented in man(1) pages in
-the distribution in files netcdf.3 and netcdf.3f, respectively.
-
-Two new User's Guides for C and FORTRAN are also available in several
-forms:
-
- NetCDF User's Guide for C:
- ftp://ftp.unidata.ucar.edu/pub/netcdf/guidec.ps.Z (PostScript)
- ftp://ftp.unidata.ucar.edu/pub/netcdf/guidec.html.tar.Z (HTML)
- http://www.unidata.ucar.edu/packages/netcdf/guidec/ (online)
-
- NetCDF User's Guide for FORTRAN:
- ftp://ftp.unidata.ucar.edu/pub/netcdf/guidef.ps.Z (PostScript)
- ftp://ftp.unidata.ucar.edu/pub/netcdf/guidef.html.tar.Z (HTML)
- http://www.unidata.ucar.edu/packages/netcdf/guidef/ (online)
-
-An overview of the differences between netCDF-2 and netCDF-3 can be
-found in the file COMPATIBILITY.
-
-We appreciate feedback from users of this package. Please send
-comments, suggestions, and bug reports to <support at unidata.ucar.edu>.
-Please identify the version of the package (file VERSION).
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/VERSION b/src/diskio/interface/netcdf/netcdf-3.4/src/VERSION
deleted file mode 100644
index 2f4b607..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-3.4
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/aclocal.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/aclocal.m4
deleted file mode 100644
index 5bba46f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/aclocal.m4
+++ /dev/null
@@ -1,578 +0,0 @@
-dnl $Id: aclocal.m4,v 1.2 2005/08/04 19:58:47 svitak Exp $
-dnl UD macros for netcdf configure
-
-
-dnl Convert a string to all uppercase.
-dnl
-define([uppercase],
-[translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)])
-
-dnl
-dnl Check for an m4(1) preprocessor utility.
-dnl
-AC_DEFUN(UD_PROG_M4,
-[
- AC_CHECK_PROGS(M4, m4 gm4, m4)
-])
-
-dnl
-dnl Check for a Standard C compiler. Prefer a native one over the
-dnl GNU one to reduce the chance that the environment variable LIBS
-dnl will have to be set to reference the GNU C runtime library.
-dnl
-AC_DEFUN(UD_PROG_CC,
-[
- # Because we must have a C compiler, we treat an unset CC
- # the same as an empty CC.
- case "${CC}" in
- '')
- case `uname` in
- ULTRIX)
- # The native ULTRIX C compiler isn't standard.
- ccs='gcc cc'
- ;;
- *)
- # xlc is before c89 because AIX's sizeof(long long)
- # differs between the two.
- #
- ccs='xlc c89 acc cc gcc'
- ;;
- esac
- for cc in $ccs; do
- AC_CHECK_PROG(CC, $cc, $cc)
- case "$CC" in
- '') ;;
- *) break
- ;;
- esac
- done
- case "${CC}" in
- '')
- AC_MSG_ERROR("Could not find C compiler")
- ;;
- esac
- ;;
- *)
- AC_CHECKING(user-defined C compiler \"$CC\")
- ;;
- esac
- #
- # On some systems, a discovered compiler nevertheless won't
- # work (due to licensing, for example); thus, we check the
- # compiler with a test program.
- #
- AC_MSG_CHECKING(C compiler)
- AC_TRY_COMPILE(, ,
- AC_MSG_RESULT(works),
- AC_MSG_ERROR($CC failed to compile test program))
- AC_SUBST(CC)
- case "$CC" in
- *gcc*)
- GCC=yes # Expected by autoconf(1) macros
- ;;
- esac
- case `uname -sr` in
- 'HP-UX A.09'*)
- AC_DEFINE(_HPUX_SOURCE)
- ;;
- esac
-])
-
-
-dnl
-dnl like AC_LONG_DOUBLE, except checks for 'long long'
-dnl
-AC_DEFUN(UD_C_LONG_LONG,
-[AC_MSG_CHECKING(for long long)
-AC_CACHE_VAL(ac_cv_c_long_long,
-[if test "$GCC" = yes; then
- ac_cv_c_long_long=yes
-else
-AC_TRY_RUN([int main() {
-long long foo = 0;
-exit(sizeof(long long) < sizeof(long)); }],
-ac_cv_c_long_long=yes, ac_cv_c_long_long=no, :)
-fi])dnl
-AC_MSG_RESULT($ac_cv_c_long_long)
-if test $ac_cv_c_long_long = yes; then
- AC_DEFINE(HAVE_LONG_LONG)
-fi
-])
-
-dnl UD_CHECK_SIZEOF(TYPE)
-AC_DEFUN(UD_CHECK_SIZEOF,
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
-dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
-changequote([, ])dnl
-AC_MSG_CHECKING(size of $1)
-AC_CACHE_VAL(AC_CV_NAME,
-[AC_TRY_RUN([#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof($1));
- exit(0);
-}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl
-AC_MSG_RESULT($AC_CV_NAME)
-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-])
-
-
-dnl
-dnl UD_CHECK_IEEE
-dnl If the 'double' is not an IEEE double
-dnl or the 'float' is not and IEEE single,
-dnl define NO_IEEE_FLOAT
-dnl
-AC_DEFUN(UD_CHECK_IEEE,
-[
-AC_MSG_CHECKING(for IEEE floating point format)
-AC_TRY_RUN([#ifndef NO_FLOAT_H
-#include <float.h>
-#endif
-
-#define EXIT_NOTIEEE 1
-#define EXIT_MAYBEIEEE 0
-
-int
-main()
-{
-#if defined(FLT_RADIX) && FLT_RADIX != 2
- return EXIT_NOTIEEE;
-#elif defined(DBL_MAX_EXP) && DBL_MAX_EXP != 1024
- return EXIT_NOTIEEE;
-#elif defined(DBL_MANT_DIG) && DBL_MANT_DIG != 53
- return EXIT_NOTIEEE;
-#elif defined(FLT_MAX_EXP) && !(FLT_MAX_EXP == 1024 || FLT_MAX_EXP == 128)
- return EXIT_NOTIEEE;
-#elif defined(FLT_MANT_DIG) && !(FLT_MANT_DIG == 53 || FLT_MANT_DIG == 24)
- return EXIT_NOTIEEE;
-#else
- /* (assuming eight bit char) */
- if(sizeof(double) != 8)
- return EXIT_NOTIEEE;
- if(!(sizeof(float) == 4 || sizeof(float) == 8))
- return EXIT_NOTIEEE;
-
- return EXIT_MAYBEIEEE;
-#endif
-}],ac_cv_c_ieeefloat=yes, ac_cv_c_ieeefloat=no, :)
-AC_MSG_RESULT($ac_cv_c_ieeefloat)
-if test $ac_cv_c_ieeefloat = no; then
- AC_DEFINE(NO_IEEE_FLOAT)
-fi
-])
-
-dnl Check for utility for generating makefile dependencies.
-dnl Should only be used at the UPC.
-dnl
-AC_DEFUN(UD_PROG_CC_MAKEDEPEND,
-[
- AC_MSG_CHECKING(how to make dependencies)
- case `uname -s` in
- IRIX*|OSF1)
- CC_MAKEDEPEND='cc -M'
- ;;
- SunOS)
- case `uname -r` in
- 4*)
- CC_MAKEDEPEND='cc -M'
- ;;
- 5*|*)
- CC_MAKEDEPEND='cc -xM'
- ;;
- esac
- ;;
- ULTRIX)
- case `uname -m` in
- RISC)
- CC_MAKEDEPEND='cc -M'
- ;;
- VAX) # Can't handle prototypes in netcdf.h
- ;;
- esac
- ;;
- AIX) # Writes to .u files rather than standard out
- ;;
- HP-UX) # Writes escaped newlines to standard error
- ;;
- esac
- case "${CC_MAKEDEPEND}" in
- '')
- CC_MAKEDEPEND=false
- ;;
- esac
- AC_MSG_RESULT($CC_MAKEDEPEND)
- AC_SUBST(CC_MAKEDEPEND)
-])
-
-
-dnl Setup for making a manual-page database.
-dnl
-AC_DEFUN(UD_MAKEWHATIS,
-[
- #
- # NB: We always want to define WHATIS to prevent the
- # $(MANDIR)/$(WHATIS) make(1) target from being just $(MANDIR)/ and
- # conflicting with the (directory creation) target with the same name.
- #
- WHATIS=whatis
- case `uname -sr` in
- BSD/OS*)
- # Can't generate a user-database -- only /usr/share/man/whatis.db.
- MAKEWHATIS_CMD=
- ;;
- 'IRIX 6'*)
- # Can't generate a user-database.
- MAKEWHATIS_CMD=
- ;;
- HP-UX*)
- # Can't generate a user-database -- only /usr/lib/whatis.
- MAKEWHATIS_CMD=
- ;;
- 'Linux '*)
- # /usr/sbin/makewhatis doesn't work
- MAKEWHATIS_CMD=
- ;;
- ULTRIX*)
- # Can't generate a user-database -- only /usr/lib/whatis.
- MAKEWHATIS_CMD=
- ;;
- *)
- if test -r /usr/man/windex; then
- WHATIS=windex
- fi
- AC_CHECK_PROGS(prog, catman makewhatis)
- case "$prog" in
- *catman*)
- MAKEWHATIS_CMD=$prog' -w -M $(MANDIR)'
- ;;
- *makewhatis*)
- MAKEWHATIS_CMD=$prog' $(MANDIR)'
- ;;
- esac
- ;;
- esac
- AC_SUBST(WHATIS)
- AC_SUBST(MAKEWHATIS_CMD)
- AC_MSG_CHECKING(for manual-page index command)
- AC_MSG_RESULT($MAKEWHATIS_CMD)
-])
-
-
-dnl Check for the math library.
-dnl
-AC_DEFUN(UD_CHECK_LIB_MATH,
-[
- AC_CHECKING(for math library)
- case "${MATHLIB}" in
- '')
- AC_CHECK_LIB(c, tanh, MATHLIB=,
- AC_CHECK_LIB(m, tanh, MATHLIB=-lm, MATHLIB=))
- ;;
- *)
- AC_MSG_RESULT($MATHLIB (user defined))
- ;;
- esac
- AC_SUBST(MATHLIB)
-])
-
-
-dnl Check for the ftruncate() function and its correct behavior.
-dnl
-AC_DEFUN(UD_CHECK_FTRUNCATE,
-[
- AC_MSG_CHECKING(for working ftruncate())
- AC_TRY_RUN(dnl
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-main()
-{
- char* path = tmpnam(NULL);
- int exitStatus = 1;
-
- if (path != NULL)
- {
- int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
-
- if (fd != -1)
- {
- if (write(fd, "0", 1) == 1)
- {
- off_t pos = lseek(fd, 0, SEEK_CUR);
-
- if (pos != (off_t)-1)
- {
- if (ftruncate(fd, 512) != -1)
- {
- if (pos == lseek(fd, 0, SEEK_CUR))
- {
- if (lseek(fd, 0, SEEK_SET) == 0)
- {
- char buf[[512]];
-
- if (read(fd, buf, 512) == 512)
- exitStatus = 0;
- }
- }
- }
- }
- }
- close(fd);
- unlink(path);
- }
- }
-
- return exitStatus;
-}
- ,
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_FTRUNCATE)
- ,
- AC_MSG_RESULT(no)
- )
-])
-
-
-dnl Set the binary distribution directory.
-dnl
-AC_DEFUN([UD_FTPBINDIR], [dnl
- AC_MSG_CHECKING([binary distribution directory])
- case ${FTPBINDIR-unset} in
- unset)
- system=`(system) 2>/dev/null || echo dummy_system`
- FTPBINDIR=${FTPDIR-/home/ftp}/pub/binary/$system
- ;;
- esac
- AC_SUBST(FTPBINDIR)dnl
- AC_MSG_RESULT($FTPBINDIR)
-])
-
-
-dnl
-dnl
-dnl
-
-dnl
-dnl These headers won't get C style comments
-dnl
-dnl UD_CONFIG_HEADER(HEADER-TO-CREATE ...)
-AC_DEFUN(UD_CONFIG_HEADER,
-[define(UD_LIST_HEADER, $1)])
-
-dnl The big finish.
-dnl Just like AC_OUTPUT except it calls UD_OUTPUT_HEADER for UD_LIST_HEADER.
-dnl Produce config.status, config.h, and links, and configure subdirs.
-dnl UD_OUTPUT([FILE...] [, EXTRA-CMDS] [, INIT-CMDS])
-define(UD_OUTPUT,
-[trap '' 1 2 15
-AC_CACHE_SAVE
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
-changequote(, )dnl
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-changequote([, ])dnl
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-ifdef([AC_LIST_HEADER], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-dnl hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-dnl so uname gets run too.
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-[#] [$]0 [$]ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-changequote(, )dnl
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-changequote([, ])dnl
-for ac_option
-do
- case "[\$]ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion"
- exec [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version AC_ACVERSION"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "[\$]ac_cs_usage"; exit 0 ;;
- *) echo "[\$]ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ifdef([AC_PROVIDE_AC_PROG_INSTALL], [ac_given_INSTALL="$INSTALL"
-])dnl
-
-changequote(<<, >>)dnl
-ifdef(<<AC_LIST_HEADER>>,
-<<trap 'rm -fr `echo "$1 AC_LIST_HEADER" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15>>,
-<<trap 'rm -fr `echo "$1" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15>>)
-changequote([, ])dnl
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-AC_OUTPUT_FILES($1)
-ifdef([UD_LIST_HEADER], [UD_OUTPUT_HEADER(UD_LIST_HEADER)])dnl
-ifdef([AC_LIST_HEADER], [AC_OUTPUT_HEADER(AC_LIST_HEADER)])dnl
-ifdef([AC_LIST_LINKS], [AC_OUTPUT_LINKS(AC_LIST_FILES, AC_LIST_LINKS)])dnl
-ifelse([$3], , ,
-[EOF
-cat >> $CONFIG_STATUS <<EOF
-$3
-EOF
-cat >> $CONFIG_STATUS <<\EOF])
-$2
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-dnl config.status should not do recursion.
-ifdef([AC_LIST_SUBDIRS], [AC_OUTPUT_SUBDIRS(AC_LIST_SUBDIRS)])dnl
-])dnl
-
-
-dnl This is a subroutine of UD_OUTPUT.
-dnl Acts just like AC_OUTPUT_HEADER except that no C style comments are
-dnl produced.
-dnl UD_OUTPUT_HEADER(HEADER-FILE...)
-define(UD_OUTPUT_HEADER,
-[changequote(<<, >>)dnl
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='<<$>>%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-changequote([, ])dnl
-
-UDCONFIG_HEADERS=${UDCONFIG_HEADERS-"$1"}
-for ac_file in .. $UDCONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo udcreating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- cp $ac_given_srcdir/$ac_file_in conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-dnl Using a here document instead of a string reduces the quoting nightmare.
-dnl Putting comments in sed scripts is not portable.
-cat > conftest.hdr <<\EOF
-changequote(<<, >>)dnl
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%<<#define>> \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-changequote([, ])dnl
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-# Maximum number of lines to put in a single here document.
-ac_max_here_lines=12
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-dnl Now back to your regularly scheduled config.status.
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- case "$ac_file" in
- *.h|*.hh|*.H)
- echo "/* $ac_file. Generated automatically by configure. */" \
- > conftest.h
- ;;
- esac
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-])
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/configure b/src/diskio/interface/netcdf/netcdf-3.4/src/configure
deleted file mode 100755
index 6f4e051..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/configure
+++ /dev/null
@@ -1,3844 +0,0 @@
-#! /bin/sh
-
-# From configure.in Id: configure.in
-CPPFLAGS=${CPPFLAGS--DNDEBUG}
-CFLAGS=${CFLAGS--O}
-FFLAGS=${FFLAGS--O}
-FPPFLAGS=${FPPFLAGS-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.9
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_default_prefix=`(cd ..; pwd)`
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # 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 << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.9"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=libsrc/ncconfig.in
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi at caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-
-
- for ac_prog in m4 gm4
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_M4'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$M4"; then
- ac_cv_prog_M4="$M4" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_M4="$ac_prog"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-M4="$ac_cv_prog_M4"
-if test -n "$M4"; then
- echo "$ac_t""$M4" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-test -n "$M4" && break
-done
-test -n "$M4" || M4="m4"
-
-
-
- # Because we must have a C compiler, we treat an unset CC
- # the same as an empty CC.
- case "${CC}" in
- '')
- case `uname` in
- ULTRIX)
- # The native ULTRIX C compiler isn't standard.
- ccs='gcc cc'
- ;;
- *)
- # xlc is before c89 because AIX's sizeof(long long)
- # differs between the two.
- #
- ccs='xlc c89 acc cc gcc'
- ;;
- esac
- for cc in $ccs; do
- # Extract the first word of "$cc", so it can be a program name with args.
-set dummy $cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="$cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- case "$CC" in
- '') ;;
- *) break
- ;;
- esac
- done
- case "${CC}" in
- '')
- { echo "configure: error: "Could not find C compiler"" 1>&2; exit 1; }
- ;;
- esac
- ;;
- *)
- echo "checking user-defined C compiler \"$CC\"" 1>&6
- ;;
- esac
- #
- # On some systems, a discovered compiler nevertheless won't
- # work (due to licensing, for example); thus, we check the
- # compiler with a test program.
- #
- echo $ac_n "checking C compiler""... $ac_c" 1>&6
- cat > conftest.$ac_ext <<EOF
-#line 1012 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-
-; return 0; }
-EOF
-if { (eval echo configure:1020: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- echo "$ac_t""works" 1>&6
-else
- rm -rf conftest*
- { echo "configure: error: $CC failed to compile test program" 1>&2; exit 1; }
-fi
-rm -f conftest*
-
-
- case "$CC" in
- *gcc*)
- GCC=yes # Expected by autoconf(1) macros
- ;;
- esac
- case `uname -sr` in
- 'HP-UX A.09'*)
- cat >> confdefs.h <<\EOF
-#define _HPUX_SOURCE 1
-EOF
-
- ;;
- esac
-
-
- echo $ac_n "checking how to make dependencies""... $ac_c" 1>&6
- case `uname -s` in
- IRIX*|OSF1)
- CC_MAKEDEPEND='cc -M'
- ;;
- SunOS)
- case `uname -r` in
- 4*)
- CC_MAKEDEPEND='cc -M'
- ;;
- 5*|*)
- CC_MAKEDEPEND='cc -xM'
- ;;
- esac
- ;;
- ULTRIX)
- case `uname -m` in
- RISC)
- CC_MAKEDEPEND='cc -M'
- ;;
- VAX) # Can't handle prototypes in netcdf.h
- ;;
- esac
- ;;
- AIX) # Writes to .u files rather than standard out
- ;;
- HP-UX) # Writes escaped newlines to standard error
- ;;
- esac
- case "${CC_MAKEDEPEND}" in
- '')
- CC_MAKEDEPEND=false
- ;;
- esac
- echo "$ac_t""$CC_MAKEDEPEND" 1>&6
-
-
-
- case "${CXX-unset}" in
- unset)
- case `uname` in
- AIX)
- preferred_cxx='xlC'
- ;;
- esac
- possible_cxxs="${preferred_cxx} CC cxx c++ g++ gcc"
- ;;
- '') echo "configure: "Empty CXX variable"" 1>&2
- possible_cxxs=
- ;;
- *) possible_cxxs=$CXX
- ;;
- esac
- case "${possible_cxxs}" in
- '') CXX=
- ;;
- *)
- ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-
- for cxx in $possible_cxxs; do
- # Extract the first word of "$cxx", so it can be a program name with args.
-set dummy $cxx; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CXX="$cxx"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CXX="$ac_cv_prog_CXX"
-if test -n "$CXX"; then
- echo "$ac_t""$CXX" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- case "$CXX" in
- '') ;;
- *) # On some systems, a discovered compiler nevertheless
- # won't work (because it's a script to a non-existant
- # executable, for example); thus, we check the
- # compiler with a test program.
- #
- echo $ac_n "checking C++ compiler \"$CXX\"""... $ac_c" 1>&6
- cat > conftest.$ac_ext <<EOF
-#line 1145 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-
-; return 0; }
-EOF
-if { (eval echo configure:1153: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
-
- echo "$ac_t""works" 1>&6
- break
-
-else
- rm -rf conftest*
-
- echo "configure: warning: $CXX failed to compile test program" 1>&2
- CXX=
- unset ac_cv_prog_CXX
-
-fi
-rm -f conftest*
-
- ;;
- esac
- done
- ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-
- case "${CXX}" in
- '') echo "configure: warning: "Could not find working C++ compiler"" 1>&2
- echo "configure: warning: Setting CXX to the empty string" 1>&2
- ;;
- esac
- ;;
- esac
- case "${CXX}" in
- '') echo "configure: The C++ interface will not be built" 1>&2
- ;;
- esac
-
- case `uname` in
- 'HP-UX A.09'*)
- cat >> confdefs.h <<\EOF
-#define _HPUX_SOURCE 1
-EOF
-
- ;;
- esac
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 1214 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1220: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 1229 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1235: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-
-
- case `uname -sr` in
- AIX*)
- # xlf90(1) thinks fortran/ftest.F has bad syntax.
- forts="xlf f77"
- ;;
- BSD/OS*)
- forts="f77 fort77 g77"
- ;;
- HP-UX*)
- # f77(1) doesn't have the -L option.
- forts=fort77
- flibs=-lU77
- ;;
- IRIX*)
- # f90(1) can't link with c89(1)-compiled objects
- forts=f77
- ;;
- IRIX64*)
- forts='f77 g77 fort77'
- ;;
- Linux*)
- forts="f77 fort77 g77"
- ;;
- OSF1*)
- # The use of f90(1) results in the following for
- # an unknown reason (`make' works in the fortran/
- # directory):
- # f90 -c -I../libsrc ftest.F
- # Last chance handler: pc = 0xa971b8, sp = 0x3fece0, ra = 0xa971b8
- # Last chance handler: internal exception: unwinding
- forts="f77"
- ;;
- 'SunOS 4'*)
- forts='f77 g77 fort77'
- ;;
- 'SunOS 5'*)
- # SunOS's f90(1) has problems passing a C `char'
- # as a Fortran `integer*1' => use f77(1)
- forts="f77"
- ;;
- sn*|UNICOS*)
- forts="fort77 cf77 f77 g77 f90"
- ;;
- *)
- forts="xlf fort77 ghf77 f77 cf77 g77 xlf90 f90"
- ;;
- esac
- FFLAGS="${FFLAGS}"
- FLIBS="${FLIBS} ${flibs}"
- case "${FC+set}" in
- set)
- case "$FC" in
- '')
- echo "configure: no Fortran compiler" 1>&2
- ;;
- *)
- echo $ac_n "checking user-defined Fortran compiler \"$FC\"""... $ac_c" 1>&6
- cat <<EOF >conftest.f
- CALL FOO
- END
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:1319: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""works" 1>&6
- else
- echo "configure: warning: $FC failed to compile test program" 1>&2
- FC=
- fi
- rm -f conftest.*
- ;;
- esac
- ;;
- *)
- for fc in $forts; do
- # Extract the first word of "$fc", so it can be a program name with args.
-set dummy $fc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_FC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$FC"; then
- ac_cv_prog_FC="$FC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_FC="$fc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-FC="$ac_cv_prog_FC"
-if test -n "$FC"; then
- echo "$ac_t""$FC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- case "${FC}" in
- '')
- ;;
- *)
- #
- # On some systems, a discovered compiler
- # nevertheless won't work (due to licensing,
- # for example); thus, we check the compiler
- # with a test program.
- #
- cat <<EOF >conftest.f
- CALL FOO
- END
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:1373: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- break
- else
- echo "configure: warning: $FC failed to compile test program" 1>&2
- unset FC
- unset ac_cv_prog_FC
- fi
- ;;
- esac
- done
- rm -f conftest.*
- case "${FC}" in
- '') echo "configure: warning: "Could not find working Fortran compiler"" 1>&2
- echo "configure: warning: Setting FC to the empty string" 1>&2
- ;;
- esac
- ;;
- esac
- case "${FC}" in
- '')
- echo "configure: "The Fortran interface will not be built"" 1>&2
- ;;
- esac
-
-
-
- #
- # Set the make(1) macro for compiling a .F file.
- #
- echo $ac_n "checking for Fortran .F compiler""... $ac_c" 1>&6
- echo "$ac_t""$COMPILE_F" 1>&6
- case "${COMPILE_F-unset}" in
- unset)
- case "${FC}" in
- '')
- COMPILE_F=
- ;;
- *)
- echo $ac_n "checking if Fortran compiler handles *.F files""... $ac_c" 1>&6
- cat >conftest.h <<\EOF
-#define J 1
-EOF
- cat >conftest.F <<\EOF
-#include "conftest.h"
-#define N 5
- real r(J,N)
- end
-EOF
- doit='$FC -o conftest ${FFLAGS} conftest.F ${FLIBS}'
- if { (eval echo configure:1422: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- COMPILE_F='$(COMPILE.f) $(FPPFLAGS)'
- echo "$ac_t""yes" 1>&6
- else
- COMPILE_F=
- echo "$ac_t""no" 1>&6
- fi
- rm -f conftest*
- ;;
- esac
- ;;
- esac
- case "${COMPILE_F-}" in
- '')
- echo $ac_n "checking for Fortran preprocessor""... $ac_c" 1>&6
- case "$FPP" in
- '')
-
- FPP="$CPP"
- ;;
- esac
- echo "$ac_t""$FPP" 1>&6
-
-;;
- esac
-
- FPPFLAGS=${FPPFLAGS-}
-
-
-
-
- case "$FC" in
- '') ;;
- *)
-
- echo $ac_n "checking for C-equivalent to Fortran routine \"SUB\"""... $ac_c" 1>&6
- cat >conftest.f <<\EOF
- call sub()
- end
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:1463: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- FCALLSCSUB=`nm conftest.o | awk '
- /SUB_/{print "SUB_";exit}
- /SUB/ {print "SUB"; exit}
- /sub_/{print "sub_";exit}
- /sub/ {print "sub"; exit}'`
- case "$FCALLSCSUB" in
- '') { echo "configure: error: not found" 1>&2; exit 1; }
- ;;
- *) echo "$ac_t""$FCALLSCSUB" 1>&6
- ;;
- esac
- else
- { echo "configure: error: Could not compile conftest.f" 1>&2; exit 1; }
- fi
- rm -f conftest*
- ;;
- esac
-
-
-
- case "$FC" in
- '')
- ;;
- *)
-
-
- for ftype in byte integer*1 "integer(kind(1))"; do
- echo $ac_n "checking for Fortran \"$ftype\"""... $ac_c" 1>&6
- cat >conftest.f <<EOF
- subroutine sub(value)
- $ftype value
- end
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:1498: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- NF_INT1_T=$ftype
- cat >> confdefs.h <<EOF
-#define NF_INT1_T $ftype
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- done
- rm -f conftest*
-
-
- for ftype in integer*2 "integer(kind(2))"; do
- echo $ac_n "checking for Fortran \"$ftype\"""... $ac_c" 1>&6
- cat >conftest.f <<EOF
- subroutine sub(value)
- $ftype value
- end
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:1521: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- NF_INT2_T=$ftype
- cat >> confdefs.h <<EOF
-#define NF_INT2_T $ftype
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- done
- rm -f conftest*
-
-
- case "${NF_INT1_T}" in
- '') ;;
- *)
- cat >conftestf.f <<EOF
- $NF_INT1_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in "signed char"; do
- echo $ac_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1555: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1557: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1559: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1561: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT1_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- $NF_INT1_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in "short"; do
- echo $ac_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1602: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1604: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1606: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1608: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT1_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- $NF_INT1_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in "int"; do
- echo $ac_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1649: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1651: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1653: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1655: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT1_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- $NF_INT1_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in "long"; do
- echo $ac_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1696: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1698: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1700: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1702: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT1_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
- ;;
- esac
- case "${NF_INT2_T}" in
- '') ;;
- *)
- cat >conftestf.f <<EOF
- $NF_INT2_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in short; do
- echo $ac_n "checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1747: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1749: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1751: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1753: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT2_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- $NF_INT2_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in int; do
- echo $ac_n "checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1794: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1796: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1798: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1800: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT2_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- $NF_INT2_T values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in long; do
- echo $ac_n "checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1841: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1843: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1845: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1847: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT2_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
- ;;
- esac
-
- cat >conftestf.f <<EOF
- integer values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in int long; do
- echo $ac_n "checking if Fortran \"integer\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1890: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1892: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1894: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1896: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_INT_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- real values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in float double; do
- echo $ac_n "checking if Fortran \"real\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1937: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1939: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1941: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1943: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_REAL_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
- cat >conftestf.f <<EOF
- doubleprecision values(4)
- data values /-1, -2, -3, -4/
- call sub(values)
- end
-EOF
- for ctype in double float; do
- echo $ac_n "checking if Fortran \"doubleprecision\" is C \"$ctype\"""... $ac_c" 1>&6
- cat >conftest.c <<EOF
- void $FCALLSCSUB(values)
- $ctype values[4];
- {
- exit(values[1] != -2 || values[2] != -3);
- }
-EOF
- doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
- if { (eval echo configure:1984: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC ${FFLAGS} -c conftestf.f'
- if { (eval echo configure:1986: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${LIBS}'
- if { (eval echo configure:1988: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- doit=./conftest
- if { (eval echo configure:1990: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- echo "$ac_t""yes" 1>&6
- cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
- _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- cat >> confdefs.h <<EOF
-#define NF_DOUBLEPRECISION_IS_C_$cname 1
-EOF
-
- break
- else
- echo "$ac_t""no" 1>&6
- fi
- else
- { echo "configure: error: Could not link conftestf.o and conftest.o" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftestf.f" 1>&2; exit 1; }
- fi
- else
- { echo "configure: error: Could not compile conftest.c" 1>&2; exit 1; }
- fi
- done
- rm -f conftest*
-
-
-
- echo $ac_n "checking for Fortran-equivalent to netCDF \"byte\"""... $ac_c" 1>&6
- for type in byte integer*1 integer; do
- cat >conftest.f <<EOF
- $type foo
- end
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:2023: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- break;
- fi
- done
- rm -f conftest.f conftest.o
- cat >> confdefs.h <<EOF
-#define NCBYTE_T $type
-EOF
-
- echo "$ac_t""$type" 1>&6
- NCBYTE_T=$type
-
-
-
- echo $ac_n "checking for Fortran-equivalent to netCDF \"short\"""... $ac_c" 1>&6
- for type in integer*2 integer; do
- cat >conftest.f <<EOF
- $type foo
- end
-EOF
- doit='$FC -c ${FFLAGS} conftest.f'
- if { (eval echo configure:2044: \"$doit\") 1>&5; (eval $doit) 2>&5; }; then
- break;
- fi
- done
- rm -f conftest.f conftest.o
- cat >> confdefs.h <<EOF
-#define NCSHORT_T $type
-EOF
-
- echo "$ac_t""$type" 1>&6
- NCSHORT_T=$type
-
-
-
-
- ;;
- esac
-
-
- echo "checking for math library" 1>&6
- case "${MATHLIB}" in
- '')
- echo $ac_n "checking for -lc""... $ac_c" 1>&6
-ac_lib_var=`echo c_tanh | tr '.-/+' '___p'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lc $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2074 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-char tanh();
-
-int main() { return 0; }
-int t() {
-tanh()
-; return 0; }
-EOF
-if { (eval echo configure:2084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- MATHLIB=
-else
- echo "$ac_t""no" 1>&6
-echo $ac_n "checking for -lm""... $ac_c" 1>&6
-ac_lib_var=`echo m_tanh | tr '.-/+' '___p'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lm $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2108 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-char tanh();
-
-int main() { return 0; }
-int t() {
-tanh()
-; return 0; }
-EOF
-if { (eval echo configure:2118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- MATHLIB=-lm
-else
- echo "$ac_t""no" 1>&6
-MATHLIB=
-fi
-
-fi
-
- ;;
- *)
- echo "$ac_t""$MATHLIB (user defined)" 1>&6
- ;;
- esac
-
-
-# Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_AR="ar"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_AR" && ac_cv_prog_AR=":"
-fi
-fi
-AR="$ac_cv_prog_AR"
-if test -n "$AR"; then
- echo "$ac_t""$AR" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "stdlib.h" | tr './\055' '___'`
-echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2208 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2213: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-cat >> confdefs.h <<\EOF
-#define NO_STDLIB_H 1
-EOF
-
-fi
-
-ac_safe=`echo "sys/types.h" | tr './\055' '___'`
-echo $ac_n "checking for sys/types.h""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2242 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2247: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-cat >> confdefs.h <<\EOF
-#define NO_SYS_TYPES_H 1
-EOF
-
-fi
-
-echo $ac_n "checking for strerror""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2275 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char strerror(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char strerror();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_strerror) || defined (__stub___strerror)
-choke me
-#else
-strerror();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_strerror=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_strerror=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'strerror`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-cat >> confdefs.h <<\EOF
-#define NO_STRERROR 1
-EOF
-
-fi
-
-# If we cannot run a trivial program, we must be cross compiling.
-echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_c_cross=yes
-else
-cat > conftest.$ac_ext <<EOF
-#line 2327 "configure"
-#include "confdefs.h"
-main(){return(0);}
-EOF
-{ (eval echo configure:2331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_cross=no
-else
- ac_cv_c_cross=yes
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_c_cross" 1>&6
-cross_compiling=$ac_cv_c_cross
-
-
- echo $ac_n "checking for working ftruncate()""... $ac_c" 1>&6
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 2350 "configure"
-#include "confdefs.h"
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-main()
-{
- char* path = tmpnam(NULL);
- int exitStatus = 1;
-
- if (path != NULL)
- {
- int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
-
- if (fd != -1)
- {
- if (write(fd, "0", 1) == 1)
- {
- off_t pos = lseek(fd, 0, SEEK_CUR);
-
- if (pos != (off_t)-1)
- {
- if (ftruncate(fd, 512) != -1)
- {
- if (pos == lseek(fd, 0, SEEK_CUR))
- {
- if (lseek(fd, 0, SEEK_SET) == 0)
- {
- char buf[512];
-
- if (read(fd, buf, 512) == 512)
- exitStatus = 0;
- }
- }
- }
- }
- }
- close(fd);
- unlink(path);
- }
- }
-
- return exitStatus;
-}
-
-EOF
-{ (eval echo configure:2398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_FTRUNCATE 1
-EOF
-
-
-else
- echo "$ac_t""no" 1>&6
-
-fi
-fi
-rm -fr conftest*
-
-# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
-# for constant arguments. Useless!
-echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2420 "configure"
-#include "confdefs.h"
-#include <alloca.h>
-int main() { return 0; }
-int t() {
-char *p = alloca(2 * sizeof(int));
-; return 0; }
-EOF
-if { (eval echo configure:2428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- ac_cv_header_alloca_h=yes
-else
- rm -rf conftest*
- ac_cv_header_alloca_h=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
-if test $ac_cv_header_alloca_h = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_ALLOCA_H 1
-EOF
-
-fi
-
-echo $ac_n "checking for alloca""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_alloca'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2452 "configure"
-#include "confdefs.h"
-
-#ifdef __GNUC__
-# define alloca __builtin_alloca
-#else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-# endif
-# endif
-# endif
-#endif
-
-int main() { return 0; }
-int t() {
-char *p = (char *) alloca(1);
-; return 0; }
-EOF
-if { (eval echo configure:2476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- ac_cv_func_alloca=yes
-else
- rm -rf conftest*
- ac_cv_func_alloca=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_func_alloca" 1>&6
-if test $ac_cv_func_alloca = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_ALLOCA 1
-EOF
-
-fi
-
-if test $ac_cv_func_alloca = no; then
- # The SVR3 libPW and SVR4 libucb both contain incompatible functions
- # that cause trouble. Some versions do not even contain alloca or
- # contain a buggy version. If you still want to use their alloca,
- # use ar to extract alloca.o from them instead of compiling alloca.c.
- ALLOCA=alloca.o
- cat >> confdefs.h <<\EOF
-#define C_ALLOCA 1
-EOF
-
-
-echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2511 "configure"
-#include "confdefs.h"
-#if defined(CRAY) && ! defined(CRAY2)
-webecray
-#else
-wenotbecray
-#endif
-
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e 'webecray' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_os_cray=yes
-else
- rm -rf conftest*
- ac_cv_os_cray=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_os_cray" 1>&6
-if test $ac_cv_os_cray = yes; then
-for ac_func in _getb67 GETB67 getb67; do
- echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2540 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<EOF
-#define CRAY_STACKSEG_END $ac_func
-EOF
-
- break
-else
- echo "$ac_t""no" 1>&6
-fi
-
-done
-fi
-
-echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_c_stack_direction=0
-else
-cat > conftest.$ac_ext <<EOF
-#line 2594 "configure"
-#include "confdefs.h"
-find_stack_direction ()
-{
- static char *addr = 0;
- auto char dummy;
- if (addr == 0)
- {
- addr = &dummy;
- return find_stack_direction ();
- }
- else
- return (&dummy > addr) ? 1 : -1;
-}
-main ()
-{
- exit (find_stack_direction() < 0);
-}
-EOF
-{ (eval echo configure:2613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_stack_direction=1
-else
- ac_cv_c_stack_direction=-1
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_c_stack_direction" 1>&6
-cat >> confdefs.h <<EOF
-#define STACK_DIRECTION $ac_cv_c_stack_direction
-EOF
-
-fi
-
-echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2635 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-int main() { return 0; }
-int t() {
-struct stat s; s.st_blksize;
-; return 0; }
-EOF
-if { (eval echo configure:2644: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_struct_st_blksize=yes
-else
- rm -rf conftest*
- ac_cv_struct_st_blksize=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_struct_st_blksize" 1>&6
-if test $ac_cv_struct_st_blksize = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_ST_BLKSIZE 1
-EOF
-
-fi
-
-
-echo $ac_n "checking for IEEE floating point format""... $ac_c" 1>&6
-if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 2669 "configure"
-#include "confdefs.h"
-#ifndef NO_FLOAT_H
-#include <float.h>
-#endif
-
-#define EXIT_NOTIEEE 1
-#define EXIT_MAYBEIEEE 0
-
-int
-main()
-{
-#if defined(FLT_RADIX) && FLT_RADIX != 2
- return EXIT_NOTIEEE;
-#elif defined(DBL_MAX_EXP) && DBL_MAX_EXP != 1024
- return EXIT_NOTIEEE;
-#elif defined(DBL_MANT_DIG) && DBL_MANT_DIG != 53
- return EXIT_NOTIEEE;
-#elif defined(FLT_MAX_EXP) && !(FLT_MAX_EXP == 1024 || FLT_MAX_EXP == 128)
- return EXIT_NOTIEEE;
-#elif defined(FLT_MANT_DIG) && !(FLT_MANT_DIG == 53 || FLT_MANT_DIG == 24)
- return EXIT_NOTIEEE;
-#else
- /* (assuming eight bit char) */
- if(sizeof(double) != 8)
- return EXIT_NOTIEEE;
- if(!(sizeof(float) == 4 || sizeof(float) == 8))
- return EXIT_NOTIEEE;
-
- return EXIT_MAYBEIEEE;
-#endif
-}
-EOF
-{ (eval echo configure:2702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_ieeefloat=yes
-else
- ac_cv_c_ieeefloat=no
-fi
-fi
-rm -fr conftest*
-echo "$ac_t""$ac_cv_c_ieeefloat" 1>&6
-if test $ac_cv_c_ieeefloat = no; then
- cat >> confdefs.h <<\EOF
-#define NO_IEEE_FLOAT 1
-EOF
-
-fi
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2723 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2731: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 2746 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e 'memchr' >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 2764 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e 'free' >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 2785 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
-
-EOF
-{ (eval echo configure:2796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- :
-else
- ac_cv_header_stdc=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-echo $ac_n "checking for size_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2820 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stddef.h>
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e '( | )size_t( | |;)' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_size_t=yes
-else
- rm -rf conftest*
- ac_cv_type_size_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_size_t" 1>&6
-if test $ac_cv_type_size_t = no; then
- cat >> confdefs.h <<\EOF
-#define size_t unsigned
-EOF
-
-fi
-
-echo $ac_n "checking for off_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2852 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stddef.h>
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e '( | )off_t( | |;)' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_off_t=yes
-else
- rm -rf conftest*
- ac_cv_type_off_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_off_t" 1>&6
-if test $ac_cv_type_off_t = no; then
- cat >> confdefs.h <<\EOF
-#define off_t long
-EOF
-
-fi
-
-echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2884 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stddef.h>
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e '( | )ssize_t( | |;)' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_ssize_t=yes
-else
- rm -rf conftest*
- ac_cv_type_ssize_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_ssize_t" 1>&6
-if test $ac_cv_type_ssize_t = no; then
- cat >> confdefs.h <<\EOF
-#define ssize_t int
-EOF
-
-fi
-
-echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2916 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stddef.h>
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e '( | )ptrdiff_t( | |;)' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_ptrdiff_t=yes
-else
- rm -rf conftest*
- ac_cv_type_ptrdiff_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
-if test $ac_cv_type_ptrdiff_t = no; then
- cat >> confdefs.h <<\EOF
-#define ptrdiff_t int
-EOF
-
-fi
-
-echo $ac_n "checking for uchar""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_uchar'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2948 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stddef.h>
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e '( | )uchar( | |;)' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_uchar=yes
-else
- rm -rf conftest*
- ac_cv_type_uchar=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_uchar" 1>&6
-if test $ac_cv_type_uchar = no; then
- cat >> confdefs.h <<\EOF
-#define uchar unsigned char
-EOF
-
-fi
-
-echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$GCC" = yes; then
- # GCC predefines this symbol on systems where it applies.
-cat > conftest.$ac_ext <<EOF
-#line 2982 "configure"
-#include "confdefs.h"
-#ifdef __CHAR_UNSIGNED__
- yes
-#endif
-
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep -e 'yes' >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_c_char_unsigned=yes
-else
- rm -rf conftest*
- ac_cv_c_char_unsigned=no
-fi
-rm -f conftest*
-
-else
-if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3004 "configure"
-#include "confdefs.h"
-/* volatile prevents gcc2 from optimizing the test away on sparcs. */
-#if !defined(__STDC__) || __STDC__ != 1
-#define volatile
-#endif
-main() {
- volatile char c = 255; exit(c < 0);
-}
-EOF
-{ (eval echo configure:3014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_char_unsigned=yes
-else
- ac_cv_c_char_unsigned=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-
-echo "$ac_t""$ac_cv_c_char_unsigned" 1>&6
-if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
- cat >> confdefs.h <<\EOF
-#define __CHAR_UNSIGNED__ 1
-EOF
-
-fi
-
-echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_cv_c_bigendian=unknown
-# See if sys/param.h defines the BYTE_ORDER macro.
-cat > conftest.$ac_ext <<EOF
-#line 3040 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-int main() { return 0; }
-int t() {
-
-#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
- bogus endian macros
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:3052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- # It does; now see whether it defined to BIG_ENDIAN or not.
-cat > conftest.$ac_ext <<EOF
-#line 3056 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-int main() { return 0; }
-int t() {
-
-#if BYTE_ORDER != BIG_ENDIAN
- not big endian
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:3068: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_c_bigendian=yes
-else
- rm -rf conftest*
- ac_cv_c_bigendian=no
-fi
-rm -f conftest*
-
-fi
-rm -f conftest*
-
-if test $ac_cv_c_bigendian = unknown; then
-if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3085 "configure"
-#include "confdefs.h"
-main () {
- /* Are we little or big endian? From Harbison&Steele. */
- union
- {
- long l;
- char c[sizeof (long)];
- } u;
- u.l = 1;
- exit (u.c[sizeof (long) - 1] == 1);
-}
-EOF
-{ (eval echo configure:3098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_bigendian=no
-else
- ac_cv_c_bigendian=yes
-fi
-fi
-rm -fr conftest*
-fi
-fi
-
-echo "$ac_t""$ac_cv_c_bigendian" 1>&6
-if test $ac_cv_c_bigendian = yes; then
- cat >> confdefs.h <<\EOF
-#define WORDS_BIGENDIAN 1
-EOF
-
-fi
-
-echo $ac_n "checking size of short""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 3125 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(short));
- exit(0);
-}
-EOF
-{ (eval echo configure:3136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_short=`cat conftestval`
-else
- ac_cv_sizeof_short=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_short" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_SHORT $ac_cv_sizeof_short
-EOF
-
-
-echo $ac_n "checking size of int""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 3159 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(int));
- exit(0);
-}
-EOF
-{ (eval echo configure:3170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_int=`cat conftestval`
-else
- ac_cv_sizeof_int=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_int" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_INT $ac_cv_sizeof_int
-EOF
-
-
-echo $ac_n "checking size of long""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 3193 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(long));
- exit(0);
-}
-EOF
-{ (eval echo configure:3204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_long=`cat conftestval`
-else
- ac_cv_sizeof_long=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_long" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_LONG $ac_cv_sizeof_long
-EOF
-
-
-echo $ac_n "checking size of float""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 3227 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(float));
- exit(0);
-}
-EOF
-{ (eval echo configure:3238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_float=`cat conftestval`
-else
- ac_cv_sizeof_float=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_float" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_FLOAT $ac_cv_sizeof_float
-EOF
-
-
-echo $ac_n "checking size of double""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 3261 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(double));
- exit(0);
-}
-EOF
-{ (eval echo configure:3272: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_double=`cat conftestval`
-else
- ac_cv_sizeof_double=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_double" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_DOUBLE $ac_cv_sizeof_double
-EOF
-
-
-echo $ac_n "checking size of off_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_sizeof_off_t=0
-else
-cat > conftest.$ac_ext <<EOF
-#line 3295 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(off_t));
- exit(0);
-}
-EOF
-{ (eval echo configure:3310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_off_t=`cat conftestval`
-else
- ac_cv_sizeof_off_t=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_off_t" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_OFF_T $ac_cv_sizeof_off_t
-EOF
-
-
-echo $ac_n "checking size of size_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_sizeof_size_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_sizeof_size_t=0
-else
-cat > conftest.$ac_ext <<EOF
-#line 3333 "configure"
-#include "confdefs.h"
-#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(size_t));
- exit(0);
-}
-EOF
-{ (eval echo configure:3348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_sizeof_size_t=`cat conftestval`
-else
- ac_cv_sizeof_size_t=0
-fi
-fi
-rm -fr conftest*
-fi
-echo "$ac_t""$ac_cv_sizeof_size_t" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t
-EOF
-
-
-
- #
- # NB: We always want to define WHATIS to prevent the
- # $(MANDIR)/$(WHATIS) make(1) target from being just $(MANDIR)/ and
- # conflicting with the (directory creation) target with the same name.
- #
- WHATIS=whatis
- case `uname -sr` in
- BSD/OS*)
- # Can't generate a user-database -- only /usr/share/man/whatis.db.
- MAKEWHATIS_CMD=
- ;;
- 'IRIX 6'*)
- # Can't generate a user-database.
- MAKEWHATIS_CMD=
- ;;
- HP-UX*)
- # Can't generate a user-database -- only /usr/lib/whatis.
- MAKEWHATIS_CMD=
- ;;
- 'Linux '*)
- # /usr/sbin/makewhatis doesn't work
- MAKEWHATIS_CMD=
- ;;
- ULTRIX*)
- # Can't generate a user-database -- only /usr/lib/whatis.
- MAKEWHATIS_CMD=
- ;;
- *)
- if test -r /usr/man/windex; then
- WHATIS=windex
- fi
- for ac_prog in catman makewhatis
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_prog'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$prog"; then
- ac_cv_prog_prog="$prog" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_prog="$ac_prog"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-prog="$ac_cv_prog_prog"
-if test -n "$prog"; then
- echo "$ac_t""$prog" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-test -n "$prog" && break
-done
-
- case "$prog" in
- *catman*)
- MAKEWHATIS_CMD=$prog' -w -M $(MANDIR)'
- ;;
- *makewhatis*)
- MAKEWHATIS_CMD=$prog' $(MANDIR)'
- ;;
- esac
- ;;
- esac
-
-
- echo $ac_n "checking for manual-page index command""... $ac_c" 1>&6
- echo "$ac_t""$MAKEWHATIS_CMD" 1>&6
-
- echo $ac_n "checking binary distribution directory""... $ac_c" 1>&6
- case ${FTPBINDIR-unset} in
- unset)
- system=`(system) 2>/dev/null || echo dummy_system`
- FTPBINDIR=${FTPDIR-/home/ftp}/pub/binary/$system
- ;;
- esac
- echo "$ac_t""$FTPBINDIR" 1>&6
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
- >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.9"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-
-trap 'rm -fr `echo "macros.make libsrc/ncconfig.h:libsrc/ncconfig.in
-" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@M4@%$M4%g
-s%@CC@%$CC%g
-s%@CC_MAKEDEPEND@%$CC_MAKEDEPEND%g
-s%@CXX@%$CXX%g
-s%@FC@%$FC%g
-s%@FFLAGS@%$FFLAGS%g
-s%@FLIBS@%$FLIBS%g
-s%@CPP@%$CPP%g
-s%@FPP@%$FPP%g
-s%@COMPILE_F@%$COMPILE_F%g
-s%@FPPFLAGS@%$FPPFLAGS%g
-s%@MATHLIB@%$MATHLIB%g
-s%@AR@%$AR%g
-s%@RANLIB@%$RANLIB%g
-s%@ALLOCA@%$ALLOCA%g
-s%@prog@%$prog%g
-s%@WHATIS@%$WHATIS%g
-s%@MAKEWHATIS_CMD@%$MAKEWHATIS_CMD%g
-s%@FTPBINDIR@%$FTPBINDIR%g
-
-CEOF
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"macros.make"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust relative srcdir, etc. for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
-fi; done
-rm -f conftest.subs
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-for ac_file in .. $UDCONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo udcreating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- cp $ac_given_srcdir/$ac_file_in conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-# Maximum number of lines to put in a single here document.
-ac_max_here_lines=12
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- case "$ac_file" in
- *.h|*.hh|*.H)
- echo "/* $ac_file. Generated automatically by configure. */" \
- > conftest.h
- ;;
- esac
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-CONFIG_HEADERS=${CONFIG_HEADERS-"libsrc/ncconfig.h:libsrc/ncconfig.in
-"}
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo creating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- cp $ac_given_srcdir/$ac_file_in conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-# Maximum number of lines to put in a single here document.
-ac_max_here_lines=12
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- case "$ac_file" in
- *.h|*.hh|*.H)
- echo "/* $ac_file. Generated automatically by configure. */" \
- > conftest.h
- ;;
- esac
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/configure.in b/src/diskio/interface/netcdf/netcdf-3.4/src/configure.in
deleted file mode 100644
index 28ccdbf..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/configure.in
+++ /dev/null
@@ -1,52 +0,0 @@
-AC_REVISION($Id: configure.in,v 1.4 2005/10/06 22:14:43 svitak Exp $)dnl
-dnl
-dnl Process this file with GNU autoconf(1) to produce a configure script.
-dnl
-
-dnl Defaults:
-CPPFLAGS=${CPPFLAGS--DNDEBUG}
-CFLAGS=${CFLAGS--O}
-FFLAGS=${FFLAGS--O}
-FPPFLAGS=${FPPFLAGS-}
-
-AC_INIT(libsrc/ncconfig.in)
-AC_PREFIX_DEFAULT(`(cd ..; pwd)`)
-AC_CONFIG_HEADER(
- libsrc/ncconfig.h:libsrc/ncconfig.in
-)
-UD_CONFIG_HEADER(
- fortran/nfconfig.inc:fortran/nfconfig.in
-)
-dnl AC_DEFINE(_ANSI_C_SOURCE)
-dnl AC_DEFINE(_POSIX_SOURCE)
-dnl AC_DEFINE(_XOPEN_SOURCE)
-UD_PROG_M4
-UD_PROG_CC
-UD_PROG_CC_MAKEDEPEND
-UD_CHECK_LIB_MATH
-AC_CHECK_PROG(AR, ar, ar, :)
-AC_PROG_RANLIB
-AC_CHECK_HEADER(stdlib.h, ,AC_DEFINE(NO_STDLIB_H))
-AC_CHECK_HEADER(sys/types.h, ,AC_DEFINE(NO_SYS_TYPES_H))
-AC_CHECK_FUNC(strerror, ,AC_DEFINE(NO_STRERROR))
-UD_CHECK_FTRUNCATE
-AC_FUNC_ALLOCA
-AC_STRUCT_ST_BLKSIZE
-UD_CHECK_IEEE
-AC_TYPE_SIZE_T
-AC_TYPE_OFF_T
-AC_CHECK_TYPE(ssize_t, int)
-AC_CHECK_TYPE(ptrdiff_t, int)
-AC_CHECK_TYPE(uchar, unsigned char)
-AC_C_CHAR_UNSIGNED
-AC_C_BIGENDIAN
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(float)
-AC_CHECK_SIZEOF(double)
-UD_CHECK_SIZEOF(off_t)
-UD_CHECK_SIZEOF(size_t)
-UD_MAKEWHATIS
-UD_FTPBINDIR
-UD_OUTPUT(macros.make)
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/Makefile
deleted file mode 100644
index 6f604bb..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/Makefile
+++ /dev/null
@@ -1,148 +0,0 @@
-# $Id: Makefile,v 1.3 2005/06/18 18:52:56 svitak Exp $
-#
-# Makefile for netcdf libsrc
-#
-
-include ../macros.make
-
-INCLUDES = -I.
-
-LIBRARY = libnetcdf.a
-ld_netcdf = -L. -lnetcdf
-
-HEADER = netcdf.h
-
-MANUAL = netcdf.3
-
-LIB_CSRCS = \
- attr.c \
- dim.c \
- error.c \
- libvers.c \
- nc.c \
- ncio.c \
- ncx.c \
- putget.c \
- string.c \
- v1hpg.c \
- v2i.c \
- var.c
-
-PACKING_LIST = \
- $(LIB_CSRCS) \
- attr.m4 \
- depend \
- fbits.h \
- Makefile \
- nc.h \
- ncconfig.in \
- ncio.h \
- ncx.m4 \
- onstack.h \
- putget.m4 \
- ffio.c \
- posixio.c \
- ncx.h \
- ncx_cray.c \
- netcdf.3 \
- netcdf.h \
- rnd.h \
- test_nc.sav \
- t_nc.c \
- t_ncio.c \
- t_ncxx.m4 \
- t_ncxx.c \
- t_ncx.c
-
-LIB_OBJS = $(LIB_CSRCS:.c=.o)
-
-GARBAGE = ncconfig.h attr.c ncx.c putget.c t_ncxx.c \
- t_ncio.o t_ncio t_ncx.o t_ncx t_ncxx.o t_ncxx \
- t_nc.o t_nc test.nc *.so
-
-DIST_GARBAGE =
-
-
-all: $(LIBRARY) $(MANUAL)
-
-check: full_test
-
-full_test: test_ncx test nctest
-
-install: $(LIBDIR)/$(LIBRARY) \
- $(INCDIR)/$(HEADER) \
- $(MANDIR)/man3/$(MANUAL)
-
-
-libvers.o: ../VERSION libvers.c
- $(COMPILE.c) -DVERSION=`cat ../VERSION` libvers.c
-
-test_ncio: t_ncio
- time ./t_ncio -s 16384 -c /tmp/test.io < t_ncio.in
- time ./t_ncio -s 16384 -w -S /tmp/test.io < t_ncio.in
- -rm /tmp/test.io
-
-test_ncx: t_ncx t_ncxx
- ./t_ncx
- ./t_ncxx
-
-test: t_nc
- ./t_nc
- cmp test.nc test_nc.sav
- @echo '*** Success ***'
-
-nctest: $(LIBRARY)
- (cd ../nctest ; make test)
-
-nc_test: $(LIBRARY)
- (cd ../nc_test ; make test)
-
-
-t_ncio: ncio.o t_ncio.o
- $(LINK.c) t_ncio.o ncio.o $(LIBS)
-
-t_ncx: t_ncx.o ncx.o
- $(LINK.c) t_ncx.o ncx.o $(LIBS)
-
-t_ncxx: t_ncxx.o ncx.o
- $(LINK.c) t_ncxx.o ncx.o $(LIBS)
-
-
-t_nc: t_nc.o $(LIBRARY)
- $(LINK.c) t_nc.o $(ld_netcdf) $(LIBS)
-
-saber_src:
- #load -C $(CPPFLAGS) $(LIB_CSRCS)
-
-tags: FORCE
- ctags -t *.c *.h
-
-# The rule for generating the manual page is here for completeness only.
-# The manual page is actually part of the distribution so that we don't
-# have to depend on the non-POSIX utility m4(1).
-#
-$(MANUAL): ../man/netcdf.m4
- $(M4) $(M4FLAGS) -DAPI=C $? >$@ || rm $@
-
-include ../rules.make
-
-.SUFFIXES: .ln
-LINT = lint
-LINT.c = $(LINT) $(LINTFLAGS) $(CPPFLAGS)
-.c.ln:
- $(LINT.c) -c $<
-
-llib-lnetcdf.ln: $(LIB_CSRCS)
- $(LINT.c) $(LIB_CSRCS) -y -o netcdf
-
-lint: llib-lnetcdf.ln
- $(LINT.c) t_nc.c llib-lnetcdf.ln
-
-attr.c: attr.m4
-ncx.c: ncx.m4
-putget.c: putget.m4
-t_ncxx.c: t_ncxx.m4
-# Ensure that the I/O module depends on ALL implementation files.
-ncio.o: ffio.c posixio.c
-
-include depend
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/attr.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/attr.m4
deleted file mode 100644
index 061a57c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/attr.m4
+++ /dev/null
@@ -1,1176 +0,0 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-dnl If you see this line, you can ignore the next one.
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: attr.m4,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "ncx.h"
-#include "fbits.h"
-#include "rnd.h"
-
-
-/*
- * Free attr
- * Formerly
-NC_free_attr()
- */
-void
-free_NC_attr(NC_attr *attrp)
-{
-
- if(attrp == NULL)
- return;
- free_NC_string(attrp->name);
- free(attrp);
-}
-
-
-/*
- * How much space will 'nelems' of 'type' take in
- * external representation (as the values of an attribute)?
- */
-static size_t
-ncx_len_NC_attrV(nc_type type, size_t nelems)
-{
- switch(type) {
- case NC_BYTE:
- case NC_CHAR:
- return ncx_len_char(nelems);
- case NC_SHORT:
- return ncx_len_short(nelems);
- case NC_INT:
- return ncx_len_int(nelems);
- case NC_FLOAT:
- return ncx_len_float(nelems);
- case NC_DOUBLE:
- return ncx_len_double(nelems);
- }
- /* default */
- assert("ncx_len_NC_attr bad type" == 0);
- return 0;
-}
-
-
-NC_attr *
-new_x_NC_attr(
- NC_string *strp,
- nc_type type,
- size_t nelems)
-{
- NC_attr *attrp;
- const size_t xsz = ncx_len_NC_attrV(type, nelems);
- size_t sz = M_RNDUP(sizeof(NC_attr));
-
- assert(!(xsz == 0 && nelems != 0));
-
- sz += xsz;
-
- attrp = (NC_attr *) malloc(sz);
- if(attrp == NULL )
- return NULL;
-
- attrp->xsz = xsz;
-
- attrp->name = strp;
- attrp->type = type;
- attrp->nelems = nelems;
- if(xsz != 0)
- attrp->xvalue = (char *)attrp + M_RNDUP(sizeof(NC_attr));
- else
- attrp->xvalue = NULL;
-
- return(attrp);
-}
-
-
-/*
- * Formerly
-NC_new_attr(name,type,count,value)
- */
-static NC_attr *
-new_NC_attr(
- const char *name,
- nc_type type,
- size_t nelems)
-{
- NC_string *strp;
- NC_attr *attrp;
-
- assert(name != NULL && *name != 0);
-
- strp = new_NC_string(strlen(name), name);
- if(strp == NULL)
- return NULL;
-
- attrp = new_x_NC_attr(strp, type, nelems);
- if(attrp == NULL)
- {
- free_NC_string(strp);
- return NULL;
- }
-
- return(attrp);
-}
-
-
-static NC_attr *
-dup_NC_attr(const NC_attr *rattrp)
-{
- NC_attr *attrp = new_NC_attr(rattrp->name->cp,
- rattrp->type, rattrp->nelems);
- if(attrp == NULL)
- return NULL;
- (void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz);
- return attrp;
-}
-
-/* attrarray */
-
-/*
- * Free the stuff "in" (referred to by) an NC_attrarray.
- * Leaves the array itself allocated.
- */
-void
-free_NC_attrarrayV0(NC_attrarray *ncap)
-{
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return;
-
- assert(ncap->value != NULL);
-
- {
- NC_attr **app = ncap->value;
- NC_attr *const *const end = &app[ncap->nelems];
- for( /*NADA*/; app < end; app++)
- {
- free_NC_attr(*app);
- *app = NULL;
- }
- }
- ncap->nelems = 0;
-}
-
-
-/*
- * Free NC_attrarray values.
- * formerly
-NC_free_array()
- */
-void
-free_NC_attrarrayV(NC_attrarray *ncap)
-{
- assert(ncap != NULL);
-
- if(ncap->nalloc == 0)
- return;
-
- assert(ncap->value != NULL);
-
- free_NC_attrarrayV0(ncap);
-
- free(ncap->value);
- ncap->value = NULL;
- ncap->nalloc = 0;
-}
-
-
-int
-dup_NC_attrarrayV(NC_attrarray *ncap, const NC_attrarray *ref)
-{
- int status = NC_NOERR;
-
- assert(ref != NULL);
- assert(ncap != NULL);
-
- if(ref->nelems != 0)
- {
- const size_t sz = ref->nelems * sizeof(NC_attr *);
- ncap->value = (NC_attr **) malloc(sz);
- if(ncap->value == NULL)
- return NC_ENOMEM;
-
- (void) memset(ncap->value, 0, sz);
- ncap->nalloc = ref->nelems;
- }
-
- ncap->nelems = 0;
- {
- NC_attr **app = ncap->value;
- const NC_attr **drpp = (const NC_attr **)ref->value;
- NC_attr *const *const end = &app[ref->nelems];
- for( /*NADA*/; app < end; drpp++, app++, ncap->nelems++)
- {
- *app = dup_NC_attr(*drpp);
- if(*app == NULL)
- {
- status = NC_ENOMEM;
- break;
- }
- }
- }
-
- if(status != NC_NOERR)
- {
- free_NC_attrarrayV(ncap);
- return status;
- }
-
- assert(ncap->nelems == ref->nelems);
-
- return NC_NOERR;
-}
-
-
-/*
- * Add a new handle on the end of an array of handles
- * Formerly
-NC_incr_array(array, tail)
- */
-static int
-incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp)
-{
- NC_attr **vp;
-
- assert(ncap != NULL);
-
- if(ncap->nalloc == 0)
- {
- assert(ncap->nelems == 0);
- vp = (NC_attr **) malloc(NC_ARRAY_GROWBY * sizeof(NC_attr *));
- if(vp == NULL)
- return NC_ENOMEM;
-
- ncap->value = vp;
- ncap->nalloc = NC_ARRAY_GROWBY;
- }
- else if(ncap->nelems +1 > ncap->nalloc)
- {
- vp = (NC_attr **) realloc(ncap->value,
- (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *));
- if(vp == NULL)
- return NC_ENOMEM;
-
- ncap->value = vp;
- ncap->nalloc += NC_ARRAY_GROWBY;
- }
-
- if(newelemp != NULL)
- {
- ncap->value[ncap->nelems] = newelemp;
- ncap->nelems++;
- }
- return NC_NOERR;
-}
-
-
-NC_attr *
-elem_NC_attrarray(const NC_attrarray *ncap, size_t elem)
-{
- assert(ncap != NULL);
- /* cast needed for braindead systems with signed size_t */
- if(ncap->nelems == 0 || (unsigned long) elem >= ncap->nelems)
- return NULL;
-
- assert(ncap->value != NULL);
-
- return ncap->value[elem];
-}
-
-/* End attarray per se */
-
-/*
- * Given ncp and varid, return ptr to array of attributes
- * else NULL on error
- */
-static NC_attrarray *
-NC_attrarray0( NC *ncp, int varid)
-{
- NC_attrarray *ap;
-
- if(varid == NC_GLOBAL) /* Global attribute, attach to cdf */
- {
- ap = &ncp->attrs;
- }
- else if(varid >= 0 && (size_t) varid < ncp->vars.nelems)
- {
- NC_var **vpp;
- vpp = (NC_var **)ncp->vars.value;
- vpp += varid;
- ap = &(*vpp)->attrs;
- } else {
- ap = NULL;
- }
- return(ap);
-}
-
-
-/*
- * Step thru NC_ATTRIBUTE array, seeking match on name.
- * return match or NULL if Not Found.
- */
-NC_attr **
-NC_findattr(const NC_attrarray *ncap, const char *name)
-{
- NC_attr **attrpp;
- size_t attrid;
- size_t slen;
-
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return NULL;
-
- attrpp = (NC_attr **) ncap->value;
-
- slen = strlen(name);
-
- for(attrid = 0; attrid < ncap->nelems; attrid++, attrpp++)
- {
- if(strlen((*attrpp)->name->cp) == slen &&
- strncmp((*attrpp)->name->cp, name, slen) == 0)
- {
- return(attrpp); /* Normal return */
- }
- }
- return(NULL);
-}
-
-
-/*
- * Look up by ncid, varid and name, return NULL if not found
- */
-static int
-NC_lookupattr(int ncid,
- int varid,
- const char *name, /* attribute name */
- NC_attr **attrpp) /* modified on return */
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **tmp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- tmp = NC_findattr(ncap, name);
- if(tmp == NULL)
- return NC_ENOTATT;
-
- if(attrpp != NULL)
- *attrpp = *tmp;
-
- return ENOERR;
-}
-
-/* Public */
-
-int
-nc_inq_attname(int ncid, int varid, int attnum, char *name)
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr *attrp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- attrp = elem_NC_attrarray(ncap, (size_t)attnum);
- if(attrp == NULL)
- return NC_ENOTATT;
-
- (void) strncpy(name, attrp->name->cp, attrp->name->nchars);
- name[attrp->name->nchars] = 0;
-
- return NC_NOERR;
-}
-
-
-int
-nc_inq_attid(int ncid, int varid, const char *name, int *attnump)
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **attrpp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
-
- attrpp = NC_findattr(ncap, name);
- if(attrpp == NULL)
- return NC_ENOTATT;
-
- if(attnump != NULL)
- *attnump = (int)(attrpp - ncap->value);
-
- return NC_NOERR;
-}
-
-int
-nc_inq_atttype(int ncid, int varid, const char *name, nc_type *datatypep)
-{
- int status;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid, varid, name, &attrp);
- if(status != NC_NOERR)
- return status;
-
- if(datatypep != NULL)
- *datatypep = attrp->type;
-
- return NC_NOERR;
-}
-
-int
-nc_inq_attlen(int ncid, int varid, const char *name, size_t *lenp)
-{
- int status;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid, varid, name, &attrp);
- if(status != NC_NOERR)
- return status;
-
- if(lenp != NULL)
- *lenp = attrp->nelems;
-
- return NC_NOERR;
-}
-
-int
-nc_inq_att(int ncid,
- int varid,
- const char *name, /* input, attribute name */
- nc_type *datatypep,
- size_t *lenp)
-{
- int status;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid, varid, name, &attrp);
- if(status != NC_NOERR)
- return status;
-
- if(datatypep != NULL)
- *datatypep = attrp->type;
- if(lenp != NULL)
- *lenp = attrp->nelems;
-
- return NC_NOERR;
-}
-
-
-int
-nc_rename_att( int ncid, int varid, const char *name, const char *newname)
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **tmp;
- NC_attr *attrp;
- NC_string *newStr, *old;
-
- /* sortof inline clone of NC_lookupattr() */
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- status = NC_check_name(name);
- if(status != NC_NOERR)
- return status;
-
- tmp = NC_findattr(ncap, name);
- if(tmp == NULL)
- return NC_ENOTATT;
- attrp = *tmp;
- /* end inline clone NC_lookupattr() */
-
- if(NC_findattr(ncap, newname) != NULL)
- {
- /* name in use */
- return NC_ENAMEINUSE;
- }
-
- old = attrp->name;
- if(NC_indef(ncp))
- {
- newStr = new_NC_string(strlen(newname), newname);
- if( newStr == NULL)
- return NC_ENOMEM;
- attrp->name = newStr;
- free_NC_string(old);
- return NC_NOERR;
- }
- /* else */
- status = set_NC_string(old, newname);
- if( status != NC_NOERR)
- return status;
-
- set_NC_hdirty(ncp);
-
- if(NC_doHsync(ncp))
- {
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out, int ovarid)
-{
- int status;
- NC_attr *iattrp;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **attrpp;
- NC_attr *old = NULL;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid_in, varid_in, name, &iattrp);
- if(status != NC_NOERR)
- return status;
-
- status = NC_check_id(ncid_out, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- ncap = NC_attrarray0(ncp, ovarid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- attrpp = NC_findattr(ncap, name);
- if(attrpp != NULL) /* name in use */
- {
- if(!NC_indef(ncp) )
- {
- attrp = *attrpp; /* convenience */
-
- if(iattrp->xsz > attrp->xsz)
- return NC_ENOTINDEFINE;
- /* else, we can reuse existing without redef */
-
- attrp->xsz = iattrp->xsz;
- attrp->type = iattrp->type;
- attrp->nelems = iattrp->nelems;
-
- (void) memcpy(attrp->xvalue, iattrp->xvalue,
- iattrp->xsz);
-
- set_NC_hdirty(ncp);
-
- if(NC_doHsync(ncp))
- {
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- return NC_NOERR;
- }
- /* else, redefine using existing array slot */
- old = *attrpp;
- }
- else
- {
- if(!NC_indef(ncp))
- return NC_ENOTINDEFINE;
-
- if(ncap->nelems >= NC_MAX_ATTRS)
- return NC_EMAXATTS;
- }
-
- attrp = new_NC_attr(name, iattrp->type, iattrp->nelems);
- if(attrp == NULL)
- return NC_ENOMEM;
-
- (void) memcpy(attrp->xvalue, iattrp->xvalue,
- iattrp->xsz);
-
- if(attrpp != NULL)
- {
- assert(old != NULL);
- *attrpp = attrp;
- free_NC_attr(old);
- }
- else
- {
- status = incr_NC_attrarray(ncap, attrp);
- if(status != NC_NOERR)
- {
- free_NC_attr(attrp);
- return status;
- }
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_del_att(int ncid, int varid, const char *name)
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **attrpp;
- NC_attr *old = NULL;
- int attrid;
- size_t slen;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(!NC_indef(ncp))
- return NC_ENOTINDEFINE;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- /* sortof inline NC_findattr() */
- slen = strlen(name);
-
- attrpp = (NC_attr **) ncap->value;
- for(attrid = 0; (size_t) attrid < ncap->nelems; attrid++, attrpp++)
- {
- if( slen == (*attrpp)->name->nchars &&
- strncmp(name, (*attrpp)->name->cp, slen) == 0)
- {
- old = *attrpp;
- break;
- }
- }
- if( (size_t) attrid == ncap->nelems )
- return NC_ENOTATT;
- /* end inline NC_findattr() */
-
- /* shuffle down */
- for(attrid++; (size_t) attrid < ncap->nelems; attrid++)
- {
- *attrpp = *(attrpp + 1);
- attrpp++;
- }
- *attrpp = NULL;
- /* decrement count */
- ncap->nelems--;
-
- free_NC_attr(old);
-
- return NC_NOERR;
-}
-
-dnl
-dnl XNCX_PAD_PUTN(Type)
-dnl
-define(`XNCX_PAD_PUTN',dnl
-`dnl
-static int
-ncx_pad_putn_I$1(void **xpp, size_t nelems, const $1 *tp, nc_type type)
-{
- switch(type) {
- case NC_CHAR:
- return NC_ECHAR;
- case NC_BYTE:
- return ncx_pad_putn_schar_$1(xpp, nelems, tp);
- case NC_SHORT:
- return ncx_pad_putn_short_$1(xpp, nelems, tp);
- case NC_INT:
- return ncx_putn_int_$1(xpp, nelems, tp);
- case NC_FLOAT:
- return ncx_putn_float_$1(xpp, nelems, tp);
- case NC_DOUBLE:
- return ncx_putn_double_$1(xpp, nelems, tp);
- }
- assert("ncx_pad_putn_I$1 invalid type" == 0);
- return NC_EBADTYPE;
-}
-')dnl
-dnl
-dnl XNCX_PAD_GETN(Type)
-dnl
-define(`XNCX_PAD_GETN',dnl
-`dnl
-static int
-ncx_pad_getn_I$1(const void **xpp, size_t nelems, $1 *tp, nc_type type)
-{
- switch(type) {
- case NC_CHAR:
- return NC_ECHAR;
- case NC_BYTE:
- return ncx_pad_getn_schar_$1(xpp, nelems, tp);
- case NC_SHORT:
- return ncx_pad_getn_short_$1(xpp, nelems, tp);
- case NC_INT:
- return ncx_getn_int_$1(xpp, nelems, tp);
- case NC_FLOAT:
- return ncx_getn_float_$1(xpp, nelems, tp);
- case NC_DOUBLE:
- return ncx_getn_double_$1(xpp, nelems, tp);
- }
- assert("ncx_pad_getn_I$1 invalid type" == 0);
- return NC_EBADTYPE;
-}
-')dnl
-dnl Implement
-
-XNCX_PAD_PUTN(uchar)
-XNCX_PAD_GETN(uchar)
-
-XNCX_PAD_PUTN(schar)
-XNCX_PAD_GETN(schar)
-
-XNCX_PAD_PUTN(short)
-XNCX_PAD_GETN(short)
-
-XNCX_PAD_PUTN(int)
-XNCX_PAD_GETN(int)
-
-XNCX_PAD_PUTN(long)
-XNCX_PAD_GETN(long)
-
-XNCX_PAD_PUTN(float)
-XNCX_PAD_GETN(float)
-
-XNCX_PAD_PUTN(double)
-XNCX_PAD_GETN(double)
-
-
-int
-nc_put_att_text(int ncid, int varid, const char *name,
- size_t nelems, const char *value)
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **attrpp;
- NC_attr *old = NULL;
- NC_attr *attrp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- status = NC_check_name(name);
- if(status != NC_NOERR)
- return status;
-
- /* cast needed for braindead systems with signed size_t */
- if((unsigned long) nelems > X_INT_MAX) /* backward compat */
- return NC_EINVAL; /* Invalid nelems */
-
- if(nelems != 0 && value == NULL)
- return NC_EINVAL; /* Null arg */
-
- attrpp = NC_findattr(ncap, name);
- if(attrpp != NULL) /* name in use */
- {
- if(!NC_indef(ncp) )
- {
- const size_t xsz = ncx_len_NC_attrV(NC_CHAR, nelems);
- attrp = *attrpp; /* convenience */
-
- if(xsz > attrp->xsz)
- return NC_ENOTINDEFINE;
- /* else, we can reuse existing without redef */
-
- attrp->xsz = xsz;
- attrp->type = NC_CHAR;
- attrp->nelems = nelems;
-
- if(nelems != 0)
- {
- void *xp = attrp->xvalue;
- status = ncx_pad_putn_text(&xp, nelems, value);
- if(status != NC_NOERR)
- return status;
- }
-
- set_NC_hdirty(ncp);
-
- if(NC_doHsync(ncp))
- {
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- return NC_NOERR;
- }
- /* else, redefine using existing array slot */
- old = *attrpp;
- }
- else
- {
- if(!NC_indef(ncp))
- return NC_ENOTINDEFINE;
-
- if(ncap->nelems >= NC_MAX_ATTRS)
- return NC_EMAXATTS;
- }
-
- attrp = new_NC_attr(name, NC_CHAR, nelems);
- if(attrp == NULL)
- return NC_ENOMEM;
-
- if(nelems != 0)
- {
- void *xp = attrp->xvalue;
- status = ncx_pad_putn_text(&xp, nelems, value);
- if(status != NC_NOERR)
- return status;
- }
-
- if(attrpp != NULL)
- {
- assert(old != NULL);
- *attrpp = attrp;
- free_NC_attr(old);
- }
- else
- {
- status = incr_NC_attrarray(ncap, attrp);
- if(status != NC_NOERR)
- {
- free_NC_attr(attrp);
- return status;
- }
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_get_att_text(int ncid, int varid, const char *name, char *str)
-{
- int status;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid, varid, name, &attrp);
- if(status != NC_NOERR)
- return status;
-
- if(attrp->nelems == 0)
- return NC_NOERR;
-
- if(attrp->type != NC_CHAR)
- return NC_ECHAR;
-
- /* else */
- {
- const void *xp = attrp->xvalue;
- return ncx_pad_getn_text(&xp, attrp->nelems, str);
- }
-}
-
-
-dnl
-dnl NC_PUT_ATT(Abbrv, Type)
-dnl
-define(`NC_PUT_ATT',dnl
-`dnl
-int
-nc_put_att_$1(int ncid, int varid, const char *name,
- nc_type type, size_t nelems, const $2 *value)
-{
- int status;
- NC *ncp;
- NC_attrarray *ncap;
- NC_attr **attrpp;
- NC_attr *old = NULL;
- NC_attr *attrp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- ncap = NC_attrarray0(ncp, varid);
- if(ncap == NULL)
- return NC_ENOTVAR;
-
- status = nc_cktype(type);
- if(status != NC_NOERR)
- return status;
-
- if(type == NC_CHAR)
- return NC_ECHAR;
-
- /* cast needed for braindead systems with signed size_t */
- if((unsigned long) nelems > X_INT_MAX) /* backward compat */
- return NC_EINVAL; /* Invalid nelems */
-
- if(nelems != 0 && value == NULL)
- return NC_EINVAL; /* Null arg */
-
- attrpp = NC_findattr(ncap, name);
- if(attrpp != NULL) /* name in use */
- {
- if(!NC_indef(ncp) )
- {
- const size_t xsz = ncx_len_NC_attrV(type, nelems);
- attrp = *attrpp; /* convenience */
-
- if(xsz > attrp->xsz)
- return NC_ENOTINDEFINE;
- /* else, we can reuse existing without redef */
-
- attrp->xsz = xsz;
- attrp->type = type;
- attrp->nelems = nelems;
-
- if(nelems != 0)
- {
- void *xp = attrp->xvalue;
- status = ncx_pad_putn_I$1(&xp, nelems,
- value, type);
- }
-
- set_NC_hdirty(ncp);
-
- if(NC_doHsync(ncp))
- {
- const int lstatus = NC_sync(ncp);
- /*
- * N.B.: potentially overrides NC_ERANGE
- * set by ncx_pad_putn_I$1
- */
- if(lstatus != ENOERR)
- return lstatus;
- }
-
- return status;
- }
- /* else, redefine using existing array slot */
- old = *attrpp;
- }
- else
- {
- if(!NC_indef(ncp))
- return NC_ENOTINDEFINE;
-
- if(ncap->nelems >= NC_MAX_ATTRS)
- return NC_EMAXATTS;
- }
-
- status = NC_check_name(name);
- if(status != NC_NOERR)
- return status;
-
- attrp = new_NC_attr(name, type, nelems);
- if(attrp == NULL)
- return NC_ENOMEM;
-
- if(nelems != 0)
- {
- void *xp = attrp->xvalue;
- status = ncx_pad_putn_I$1(&xp, nelems,
- value, type);
- }
-
- if(attrpp != NULL)
- {
- assert(old != NULL);
- *attrpp = attrp;
- free_NC_attr(old);
- }
- else
- {
- const int lstatus = incr_NC_attrarray(ncap, attrp);
- /*
- * N.B.: potentially overrides NC_ERANGE
- * set by ncx_pad_putn_I$1
- */
- if(lstatus != NC_NOERR)
- {
- free_NC_attr(attrp);
- return lstatus;
- }
- }
-
- return status;
-}
-')dnl
-dnl
-dnl NC_GET_ATT(Abbrv, Type)
-dnl
-define(`NC_GET_ATT',dnl
-`dnl
-int
-nc_get_att_$1(int ncid, int varid, const char *name, $2 *tp)
-{
- int status;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid, varid, name, &attrp);
- if(status != NC_NOERR)
- return status;
-
- if(attrp->nelems == 0)
- return NC_NOERR;
-
- if(attrp->type == NC_CHAR)
- return NC_ECHAR;
-
- {
- const void *xp = attrp->xvalue;
- return ncx_pad_getn_I$1(&xp, attrp->nelems, tp, attrp->type);
- }
-}
-')dnl
-
-
-NC_PUT_ATT(schar, signed char)
-NC_GET_ATT(schar, signed char)
-
-NC_PUT_ATT(uchar, unsigned char)
-NC_GET_ATT(uchar, unsigned char)
-
-NC_PUT_ATT(short, short)
-NC_GET_ATT(short, short)
-
-NC_PUT_ATT(int, int)
-NC_GET_ATT(int, int)
-
-NC_PUT_ATT(long, long)
-NC_GET_ATT(long, long)
-
-NC_PUT_ATT(float, float)
-NC_GET_ATT(float, float)
-
-NC_PUT_ATT(double, double)
-NC_GET_ATT(double, double)
-
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_put_att(
- int ncid,
- int varid,
- const char *name,
- nc_type type,
- size_t nelems,
- const void *value)
-{
- switch (type) {
- case NC_BYTE:
- return nc_put_att_schar(ncid, varid, name, type, nelems,
- (schar *)value);
- case NC_CHAR:
- return nc_put_att_text(ncid, varid, name, nelems,
- (char *)value);
- case NC_SHORT:
- return nc_put_att_short(ncid, varid, name, type, nelems,
- (short *)value);
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- return nc_put_att_int(ncid, varid, name, type, nelems,
- (int *)value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- return nc_put_att_long(ncid, varid, name, type, nelems,
- (long *)value);
-#endif
- case NC_FLOAT:
- return nc_put_att_float(ncid, varid, name, type, nelems,
- (float *)value);
- case NC_DOUBLE:
- return nc_put_att_double(ncid, varid, name, type, nelems,
- (double *)value);
- }
- return NC_EBADTYPE;
-}
-
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_get_att(int ncid, int varid, const char *name, void *value)
-{
- int status;
- NC_attr *attrp;
-
- status = NC_lookupattr(ncid, varid, name, &attrp);
- if(status != NC_NOERR)
- return status;
-
- switch (attrp->type) {
- case NC_BYTE:
- return nc_get_att_schar(ncid, varid, name,
- (schar *)value);
- case NC_CHAR:
- return nc_get_att_text(ncid, varid, name,
- (char *)value);
- case NC_SHORT:
- return nc_get_att_short(ncid, varid, name,
- (short *)value);
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- return nc_get_att_int(ncid, varid, name,
- (int *)value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- return nc_get_att_long(ncid, varid, name,
- (long *)value);
-#endif
- case NC_FLOAT:
- return nc_get_att_float(ncid, varid, name,
- (float *)value);
- case NC_DOUBLE:
- return nc_get_att_double(ncid, varid, name,
- (double *)value);
- }
- return NC_EBADTYPE;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/depend b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/depend
deleted file mode 100644
index 643ec90..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/depend
+++ /dev/null
@@ -1,121 +0,0 @@
-attr.o: attr.c
-attr.o: fbits.h
-attr.o: nc.h
-attr.o: ncconfig.h
-attr.o: ncio.h
-attr.o: ncx.h
-attr.o: netcdf.h
-attr.o: rnd.h
-dim.o: dim.c
-dim.o: fbits.h
-dim.o: nc.h
-dim.o: ncconfig.h
-dim.o: ncio.h
-dim.o: ncx.h
-dim.o: netcdf.h
-dim.o: rnd.h
-error.o: error.c
-error.o: netcdf.h
-extinit.o: error.h
-extinit.o: extinit.c
-extinit.o: netcdf.h
-ffio.o: fbits.h
-ffio.o: ffio.c
-ffio.o: ncconfig.h
-ffio.o: ncio.h
-ffio.o: netcdf.h
-ffio.o: rnd.h
-libvers.o: libvers.c
-libvers.o: netcdf.h
-n.o: n.c
-nc.o: fbits.h
-nc.o: nc.c
-nc.o: nc.h
-nc.o: ncconfig.h
-nc.o: ncio.h
-nc.o: ncx.h
-nc.o: netcdf.h
-nc.o: rnd.h
-ncio.o: fbits.h
-ncio.o: ncconfig.h
-ncio.o: ncio.c
-ncio.o: ncio.h
-ncio.o: netcdf.h
-ncio.o: posixio.c
-ncio.o: rnd.h
-ncx.o: ncconfig.h
-ncx.o: ncx.c
-ncx.o: ncx.h
-ncx.o: rnd.h
-ncx_cray.o: ncx_cray.c
-ncxx.o: ncxx.c
-posixio.o: fbits.h
-posixio.o: ncconfig.h
-posixio.o: ncio.h
-posixio.o: netcdf.h
-posixio.o: posixio.c
-posixio.o: rnd.h
-putget.o: fbits.h
-putget.o: nc.h
-putget.o: ncconfig.h
-putget.o: ncio.h
-putget.o: ncx.h
-putget.o: netcdf.h
-putget.o: onstack.h
-putget.o: putget.c
-putget.o: rnd.h
-string.o: fbits.h
-string.o: nc.h
-string.o: ncconfig.h
-string.o: ncio.h
-string.o: ncx.h
-string.o: netcdf.h
-string.o: rnd.h
-string.o: string.c
-t_nc.o: netcdf.h
-t_nc.o: t_nc.c
-t_ncio.o: ncconfig.h
-t_ncio.o: ncio.h
-t_ncio.o: ncx.h
-t_ncio.o: netcdf.h
-t_ncio.o: rnd.h
-t_ncio.o: t_ncio.c
-t_ncx.o: ncconfig.h
-t_ncx.o: ncx.h
-t_ncx.o: rnd.h
-t_ncx.o: t_ncx.c
-t_ncxx.o: ncconfig.h
-t_ncxx.o: ncx.h
-t_ncxx.o: rnd.h
-t_ncxx.o: t_ncxx.c
-tf.o: netcdf.h
-tf.o: tf.c
-ti.o: netcdf.h
-ti.o: ti.c
-tvf.o: ncconfig.h
-tvf.o: ncx.h
-tvf.o: rnd.h
-tvf.o: tvf.c
-v1hpg.o: fbits.h
-v1hpg.o: nc.h
-v1hpg.o: ncconfig.h
-v1hpg.o: ncio.h
-v1hpg.o: ncx.h
-v1hpg.o: netcdf.h
-v1hpg.o: rnd.h
-v1hpg.o: v1hpg.c
-v2i.o: fbits.h
-v2i.o: nc.h
-v2i.o: ncconfig.h
-v2i.o: ncio.h
-v2i.o: netcdf.h
-v2i.o: onstack.h
-v2i.o: v2i.c
-var.o: fbits.h
-var.o: nc.h
-var.o: ncconfig.h
-var.o: ncio.h
-var.o: ncx.h
-var.o: netcdf.h
-var.o: rnd.h
-var.o: var.c
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/dim.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/dim.c
deleted file mode 100644
index 107f5cd..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/dim.c
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: dim.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "ncx.h"
-#include "fbits.h"
-
-/*
- * Free dim
- * Formerly
-NC_free_dim(dim)
- */
-void
-free_NC_dim(NC_dim *dimp)
-{
- if(dimp == NULL)
- return;
- free_NC_string(dimp->name);
- free(dimp);
-}
-
-
-NC_dim *
-new_x_NC_dim(NC_string *name)
-{
- NC_dim *dimp;
-
- dimp = (NC_dim *) malloc(sizeof(NC_dim));
- if(dimp == NULL)
- return NULL;
-
- dimp->name = name;
- dimp->size = 0;
-
- return(dimp);
-}
-
-
-/*
- * Formerly
-NC_new_dim(const char *name, long size)
- */
-static NC_dim *
-new_NC_dim(const char *name, size_t size)
-{
- NC_string *strp;
- NC_dim *dimp;
-
- strp = new_NC_string(strlen(name), name);
- if(strp == NULL)
- return NULL;
-
- dimp = new_x_NC_dim(strp);
- if(dimp == NULL)
- {
- free_NC_string(strp);
- return NULL;
- }
-
- dimp->size = size;
-
- return(dimp);
-}
-
-
-static NC_dim *
-dup_NC_dim(const NC_dim *dimp)
-{
- return new_NC_dim(dimp->name->cp, dimp->size);
-}
-
-/*
- * Step thru NC_DIMENSION array, seeking the UNLIMITED dimension.
- * Return dimid or -1 on not found.
- * *dimpp is set to the appropriate NC_dim.
- * The loop structure is odd. In order to parallelize,
- * we moved a clearer 'break' inside the loop body to the loop test.
- */
-int
-find_NC_Udim(const NC_dimarray *ncap, NC_dim **dimpp)
-{
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return -1;
-
- {
- int dimid = 0;
- NC_dim **loc = ncap->value;
-
- for(; (size_t) dimid < ncap->nelems
- && (*loc)->size != NC_UNLIMITED; dimid++, loc++)
- {
- /*EMPTY*/
- }
- if(dimid >= ncap->nelems)
- return(-1); /* not found */
- /* else, normal return */
- if(dimpp != NULL)
- *dimpp = *loc;
- return dimid;
- }
-}
-
-
-/*
- * Step thru NC_DIMENSION array, seeking match on name.
- * Return dimid or -1 on not found.
- * *dimpp is set to the appropriate NC_dim.
- * The loop structure is odd. In order to parallelize,
- * we moved a clearer 'break' inside the loop body to the loop test.
- */
-static int
-NC_finddim(const NC_dimarray *ncap, const char *name, NC_dim **dimpp)
-{
-
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return -1;
-
- {
- size_t slen = strlen(name);
- int dimid = 0;
- NC_dim **loc = (NC_dim **) ncap->value;
-
- for(; (size_t) dimid < ncap->nelems
- && (strlen((*loc)->name->cp) != slen
- || strncmp((*loc)->name->cp, name, slen) != 0);
- dimid++, loc++)
- {
- /*EMPTY*/
- }
- if(dimid >= ncap->nelems)
- return(-1); /* not found */
- /* else, normal return */
- if(dimpp != NULL)
- *dimpp = *loc;
- return(dimid);
- }
-}
-
-
-/* dimarray */
-
-
-/*
- * Free the stuff "in" (referred to by) an NC_dimarray.
- * Leaves the array itself allocated.
- */
-void
-free_NC_dimarrayV0(NC_dimarray *ncap)
-{
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return;
-
- assert(ncap->value != NULL);
-
- {
- NC_dim **dpp = ncap->value;
- NC_dim *const *const end = &dpp[ncap->nelems];
- for( /*NADA*/; dpp < end; dpp++)
- {
- free_NC_dim(*dpp);
- *dpp = NULL;
- }
- }
- ncap->nelems = 0;
-}
-
-
-/*
- * Free NC_dimarray values.
- * formerly
-NC_free_array()
- */
-void
-free_NC_dimarrayV(NC_dimarray *ncap)
-{
- assert(ncap != NULL);
-
- if(ncap->nalloc == 0)
- return;
-
- assert(ncap->value != NULL);
-
- free_NC_dimarrayV0(ncap);
-
- free(ncap->value);
- ncap->value = NULL;
- ncap->nalloc = 0;
-}
-
-
-int
-dup_NC_dimarrayV(NC_dimarray *ncap, const NC_dimarray *ref)
-{
- int status = NC_NOERR;
-
- assert(ref != NULL);
- assert(ncap != NULL);
-
- if(ref->nelems != 0)
- {
- const size_t sz = ref->nelems * sizeof(NC_dim *);
- ncap->value = (NC_dim **) malloc(sz);
- if(ncap->value == NULL)
- return NC_ENOMEM;
- (void) memset(ncap->value, 0, sz);
- ncap->nalloc = ref->nelems;
- }
-
- ncap->nelems = 0;
- {
- NC_dim **dpp = ncap->value;
- const NC_dim **drpp = (const NC_dim **)ref->value;
- NC_dim *const *const end = &dpp[ref->nelems];
- for( /*NADA*/; dpp < end; drpp++, dpp++, ncap->nelems++)
- {
- *dpp = dup_NC_dim(*drpp);
- if(*dpp == NULL)
- {
- status = NC_ENOMEM;
- break;
- }
- }
- }
-
- if(status != NC_NOERR)
- {
- free_NC_dimarrayV(ncap);
- return status;
- }
-
- assert(ncap->nelems == ref->nelems);
-
- return NC_NOERR;
-}
-
-
-/*
- * Add a new handle on the end of an array of handles
- * Formerly
-NC_incr_array(array, tail)
- */
-static int
-incr_NC_dimarray(NC_dimarray *ncap, NC_dim *newelemp)
-{
- NC_dim **vp;
-
- assert(ncap != NULL);
-
- if(ncap->nalloc == 0)
- {
- assert(ncap->nelems == 0);
- vp = (NC_dim **) malloc(NC_ARRAY_GROWBY * sizeof(NC_dim *));
- if(vp == NULL)
- return NC_ENOMEM;
- ncap->value = vp;
- ncap->nalloc = NC_ARRAY_GROWBY;
- }
- else if(ncap->nelems +1 > ncap->nalloc)
- {
- vp = (NC_dim **) realloc(ncap->value,
- (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_dim *));
- if(vp == NULL)
- return NC_ENOMEM;
- ncap->value = vp;
- ncap->nalloc += NC_ARRAY_GROWBY;
- }
-
- if(newelemp != NULL)
- {
- ncap->value[ncap->nelems] = newelemp;
- ncap->nelems++;
- }
- return NC_NOERR;
-}
-
-
-NC_dim *
-elem_NC_dimarray(const NC_dimarray *ncap, size_t elem)
-{
- assert(ncap != NULL);
- /* cast needed for braindead systems with signed size_t */
- if(ncap->nelems == 0 || (unsigned long) elem >= ncap->nelems)
- return NULL;
-
- assert(ncap->value != NULL);
-
- return ncap->value[elem];
-}
-
-
-/* Public */
-
-int
-nc_def_dim(int ncid, const char *name, size_t size, int *dimidp)
-{
- int status;
- NC *ncp;
- int dimid;
- NC_dim *dimp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(!NC_indef(ncp))
- return NC_ENOTINDEFINE;
-
- status = NC_check_name(name);
- if(status != NC_NOERR)
- return status;
-
- /* cast needed for braindead systems with signed size_t */
- if((unsigned long) size > X_INT_MAX) /* Backward compat */
- return NC_EINVAL;
-
- if(size == NC_UNLIMITED)
- {
- dimid = find_NC_Udim(&ncp->dims, &dimp);
- if(dimid != -1)
- {
- assert(dimid != -1);
- return NC_EUNLIMIT;
- }
- }
-
- if(ncp->dims.nelems >= NC_MAX_DIMS)
- return NC_EMAXDIMS;
-
- dimid = NC_finddim(&ncp->dims, name, &dimp);
- if(dimid != -1)
- return NC_ENAMEINUSE;
-
- dimp = new_NC_dim(name, size);
- if(dimp == NULL)
- return NC_ENOMEM;
- status = incr_NC_dimarray(&ncp->dims, dimp);
- if(status != NC_NOERR)
- {
- free_NC_dim(dimp);
- return status;
- }
-
- if(dimidp != NULL)
- *dimidp = (int)ncp->dims.nelems -1;
- return NC_NOERR;
-}
-
-
-int
-nc_inq_dimid(int ncid, const char *name, int *dimid_ptr)
-{
- int status;
- NC *ncp;
- int dimid;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- dimid = NC_finddim(&ncp->dims, name, NULL);
-
- if(dimid == -1)
- return NC_EBADDIM;
-
- *dimid_ptr = dimid;
- return NC_NOERR;
-}
-
-
-int
-nc_inq_dim(int ncid, int dimid, char *name, size_t *sizep)
-{
- int status;
- NC *ncp;
- NC_dim *dimp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
- if(dimp == NULL)
- return NC_EBADDIM;
-
- if(name != NULL)
- {
- (void)strncpy(name, dimp->name->cp,
- dimp->name->nchars);
- name[dimp->name->nchars] = 0;
- }
- if(sizep != 0)
- {
- if(dimp->size == NC_UNLIMITED)
- *sizep = ncp->numrecs;
- else
- *sizep = dimp->size;
- }
- return NC_NOERR;
-}
-
-
-int
-nc_inq_dimname(int ncid, int dimid, char *name)
-{
- int status;
- NC *ncp;
- NC_dim *dimp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
- if(dimp == NULL)
- return NC_EBADDIM;
-
- if(name != NULL)
- {
- (void)strncpy(name, dimp->name->cp,
- dimp->name->nchars);
- name[dimp->name->nchars] = 0;
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
-{
- int status;
- NC *ncp;
- NC_dim *dimp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
- if(dimp == NULL)
- return NC_EBADDIM;
-
- if(lenp != 0)
- {
- if(dimp->size == NC_UNLIMITED)
- *lenp = ncp->numrecs;
- else
- *lenp = dimp->size;
- }
- return NC_NOERR;
-}
-
-
-int
-nc_rename_dim( int ncid, int dimid, const char *newname)
-{
- int status;
- NC *ncp;
- int existid;
- NC_dim *dimp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- status = NC_check_name(newname);
- if(status != NC_NOERR)
- return status;
-
- existid = NC_finddim(&ncp->dims, newname, &dimp);
- if(existid != -1)
- return NC_ENAMEINUSE;
-
- dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
- if(dimp == NULL)
- return NC_EBADDIM;
-
- if(NC_indef(ncp))
- {
- NC_string *old = dimp->name;
- NC_string *newStr = new_NC_string(strlen(newname), newname);
- if(newStr == NULL)
- return NC_ENOMEM;
- dimp->name = newStr;
- free_NC_string(old);
- return NC_NOERR;
- }
-
- /* else, not in define mode */
-
- status = set_NC_string(dimp->name, newname);
- if(status != NC_NOERR)
- return status;
-
- set_NC_hdirty(ncp);
-
- if(NC_doHsync(ncp))
- {
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- return NC_NOERR;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/error.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/error.c
deleted file mode 100644
index 7d129c8..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/error.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: error.c,v 1.14 90/02/23 16:08:55 davis Exp */
-
-/*LINTLIBRARY*/
-
-#include "ncconfig.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "netcdf.h"
-
-
-#ifndef NO_STRERROR
-#include <string.h> /* contains prototype for ansi libc function strerror() */
-#else
-/* provide a strerror function for older unix systems */
-static char *
-strerror(int errnum)
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
-
- if(errnum < 0 || errnum >= sys_nerr) return NULL;
- /* else */
- return sys_errlist[errnum];
-}
-#endif /* NO_STRERROR */
-
-
-#ifdef vms
-/* UNTESTED */
-/*
- * On the vms system, when a system error occurs which is not
- * mapped into the unix styled errno values, errno is set EVMSERR
- * and a VMS error code is set in vaxc$errno.
- * This routine prints the systems message associated with status return
- * from a system services call.
- */
-
-#include <errno.h>
-#include <descrip.h>
-#include <ssdef.h>
-
-static const char *
-vms_strerror( int status )
-{
- short msglen;
- static char msgbuf[256];
- $DESCRIPTOR(message, msgbuf);
- register ret;
-
- msgbuf[0] = 0;
- ret = SYS$GETMSG(status, &msglen, &message, 15, 0);
-
- if(ret != SS$_BUFFEROVF && ret != SS$_NORMAL) {
- (void) strcpy(msgbuf, "EVMSERR");
- }
- return(msgbuf);
-}
-#endif /* vms */
-
-
-static char unknown[] = "Unknown Error";
-
-
-const char *
-nc_strerror(int err)
-{
-
-#ifdef vms
- if(err == EVMSERR)
- {
- return vms_strerror(err);
- }
- /* else */
-#endif /* vms */
-
- if(NC_ISSYSERR(err))
- {
- const char *cp = (const char *) strerror(err);
- if(cp == NULL)
- return unknown;
- /* else */
- return cp;
- }
- /* else */
-
- switch (err) {
- case NC_NOERR:
- return "No error";
- case NC_EBADID:
- return "Not a netCDF id";
- case NC_ENFILE:
- return "Too many netCDF files open";
- case NC_EEXIST:
- return "netCDF file exists && NC_NOCLOBBER";
- case NC_EINVAL:
- return "Invalid argument";
- case NC_EPERM:
- return "Write to read only";
- case NC_ENOTINDEFINE:
- return "Operation not allowed in data mode";
- case NC_EINDEFINE:
- return "Operation not allowed in define mode";
- case NC_EINVALCOORDS:
- return "Index exceeds dimension bound";
- case NC_EMAXDIMS:
- return "NC_MAX_DIMS exceeded";
- case NC_ENAMEINUSE:
- return "String match to name in use";
- case NC_ENOTATT:
- return "Attribute not found";
- case NC_EMAXATTS:
- return "NC_MAX_ATTRS exceeded";
- case NC_EBADTYPE:
- return "Not a netCDF data type or _FillValue type mismatch";
- case NC_EBADDIM:
- return "Invalid dimension id or name";
- case NC_EUNLIMPOS:
- return "NC_UNLIMITED in the wrong index";
- case NC_EMAXVARS:
- return "NC_MAX_VARS exceeded";
- case NC_ENOTVAR:
- return "Variable not found";
- case NC_EGLOBAL:
- return "Action prohibited on NC_GLOBAL varid";
- case NC_ENOTNC:
- return "Not a netCDF file";
- case NC_ESTS:
- return "In Fortran, string too short";
- case NC_EMAXNAME:
- return "NC_MAX_NAME exceeded";
- case NC_EUNLIMIT:
- return "NC_UNLIMITED size already in use";
- case NC_ENORECVARS:
- return "nc_rec op when there are no record vars";
- case NC_ECHAR:
- return "Attempt to convert between text & numbers";
- case NC_EEDGE:
- return "Edge+start exceeds dimension bound";
- case NC_ESTRIDE:
- return "Illegal stride";
- case NC_EBADNAME:
- return "Attribute or variable name contains illegal characters";
- case NC_ERANGE:
- return "Numeric conversion not representable";
- case NC_ENOMEM:
- return "Memory allocation (malloc) failure";
- }
- /* default */
- return unknown;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/fbits.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/fbits.h
deleted file mode 100644
index 09e5310..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/fbits.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 1995, University Corporation for Atmospheric Research
- * See top level COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: fbits.h,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#ifndef _FBITS_H_
-#define _FBITS_H_
-
-/*
- * Macros for dealing with flag bits.
- */
-#define fSet(t, f) ((t) |= (f))
-#define fClr(t, f) ((t) &= ~(f))
-#define fIsSet(t, f) ((t) & (f))
-#define fMask(t, f) ((t) & ~(f))
-
-/*
- * Propositions
- */
-/* a implies b */
-#define pIf(a,b) (!(a) || (b))
-/* a if and only if b, use == when it makes sense */
-#define pIff(a,b) (((a) && (b)) || (!(a) && !(b)))
-
-#endif /*!FBITS_H_*/
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ffio.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ffio.c
deleted file mode 100644
index f618075..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ffio.c
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: ffio.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "ncconfig.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h> /* DEBUG */
-#include <errno.h>
-#ifndef ENOERR
-#define ENOERR 0
-#endif
-#include <fcntl.h>
-#include <ffio.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "ncio.h"
-#include "fbits.h"
-#include "rnd.h"
-
-#if !defined(NDEBUG) && !defined(X_INT_MAX)
-#define X_INT_MAX 2147483647
-#endif
-#if 0 /* !defined(NDEBUG) && !defined(X_ALIGN) */
-#define X_ALIGN 4
-#endif
-
-#define ALWAYS_NC_SHARE 0 /* DEBUG */
-
-/* Begin OS */
-
-/*
- * What is the preferred I/O block size?
- * (This becomes the default *sizehint == ncp->chunk in the higher layers.)
- * TODO: What is the the best answer here?
- */
-static size_t
-blksize(int fd)
-{
- struct ffc_stat_s sb;
- struct ffsw sw;
- if (fffcntl(fd, FC_STAT, &sb, &sw) > -1)
- {
- if(sb.st_oblksize > 0)
- return (size_t) sb.st_oblksize;
- }
- /* else, silent in the face of error */
- return (size_t) 32768;
-}
-
-/*
- * Sortof like ftruncate, except won't make the
- * file shorter.
- */
-static int
-fgrow(const int fd, const off_t len)
-{
- struct ffc_stat_s sb;
- struct ffsw sw;
- if (fffcntl(fd, FC_STAT, &sb, &sw) < 0)
- return errno;
- if (len < sb.st_size)
- return ENOERR;
- {
- const long dumb = 0;
- /* cache current position */
- const off_t pos = ffseek(fd, 0, SEEK_CUR);
- if(pos < 0)
- return errno;
- if (ffseek(fd, len-sizeof(dumb), SEEK_SET) < 0)
- return errno;
- if(ffwrite(fd, (void *)&dumb, sizeof(dumb)) < 0)
- return errno;
- if (ffseek(fd, pos, SEEK_SET) < 0)
- return errno;
- }
- /* else */
- return ENOERR;
-}
-
-/* End OS */
-/* Begin ffio */
-
-static int
-ffio_pgout(ncio *const nciop,
- off_t const offset, const size_t extent,
- const void *const vp, off_t *posp)
-{
-#ifdef X_ALIGN
- assert(offset % X_ALIGN == 0);
- assert(extent % X_ALIGN == 0);
-#endif
-
- if(*posp != offset)
- {
- if(ffseek(nciop->fd, offset, SEEK_SET) != offset)
- {
- return errno;
- }
- *posp = offset;
- }
- if(ffwrite(nciop->fd, vp, extent) != extent)
- {
- return errno;
- }
- *posp += extent;
-
- return ENOERR;
-}
-
-
-static int
-ffio_pgin(ncio *const nciop,
- off_t const offset, const size_t extent,
- void *const vp, size_t *nreadp, off_t *posp)
-{
- int status;
- ssize_t nread;
-
-#ifdef X_ALIGN
- assert(offset % X_ALIGN == 0);
- assert(extent % X_ALIGN == 0);
-#endif
-
- if(*posp != offset)
- {
- if(ffseek(nciop->fd, offset, SEEK_SET) != offset)
- {
- status = errno;
- return status;
- }
- *posp = offset;
- }
-
- errno = 0;
- nread = ffread(nciop->fd, vp, extent);
- if(nread != extent)
- {
- status = errno;
- if(nread == -1 || status != ENOERR)
- return status;
- /* else it's okay we read 0. */
- }
- *nreadp = nread;
- *posp += nread;
-
- return ENOERR;
-}
-
-/* */
-
-typedef struct ncio_ffio {
- off_t pos;
- /* buffer */
- off_t bf_offset;
- size_t bf_extent;
- size_t bf_cnt;
- void *bf_base;
-} ncio_ffio;
-
-
-static int
-ncio_ffio_rel(ncio *const nciop, off_t offset, int rflags)
-{
- ncio_ffio *ffp = (ncio_ffio *)nciop->pvt;
- int status = ENOERR;
-
- assert(ffp->bf_offset <= offset);
- assert(ffp->bf_cnt != 0);
- assert(ffp->bf_cnt <= ffp->bf_extent);
-#ifdef X_ALIGN
- assert(offset < ffp->bf_offset + X_ALIGN);
- assert(ffp->bf_cnt % X_ALIGN == 0 );
-#endif
-
- if(fIsSet(rflags, RGN_MODIFIED))
- {
- if(!fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- status = ffio_pgout(nciop, ffp->bf_offset,
- ffp->bf_cnt,
- ffp->bf_base, &ffp->pos);
- /* if error, invalidate buffer anyway */
- }
- ffp->bf_offset = OFF_NONE;
- ffp->bf_cnt = 0;
- return status;
-}
-
-
-static int
-ncio_ffio_get(ncio *const nciop,
- off_t offset, size_t extent,
- int rflags,
- void **const vpp)
-{
- ncio_ffio *ffp = (ncio_ffio *)nciop->pvt;
- int status = ENOERR;
-#ifdef X_ALIGN
- size_t rem;
-#endif
-
- if(fIsSet(rflags, RGN_WRITE) && !fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- assert(extent != 0);
- assert(extent < X_INT_MAX); /* sanity check */
- assert(offset < X_INT_MAX); /* sanity check */
-
- assert(ffp->bf_cnt == 0);
-
-#ifdef X_ALIGN
- /* round to seekable boundaries */
- rem = offset % X_ALIGN;
- if(rem != 0)
- {
- offset -= rem;
- extent += rem;
- }
-
- {
- const size_t rndup = extent % X_ALIGN;
- if(rndup != 0)
- extent += X_ALIGN - rndup;
- }
-
- assert(offset % X_ALIGN == 0);
- assert(extent % X_ALIGN == 0);
-#endif
-
- if(ffp->bf_extent < extent)
- {
- if(ffp->bf_base != NULL)
- {
- free(ffp->bf_base);
- ffp->bf_base = NULL;
- ffp->bf_extent = 0;
- }
- assert(ffp->bf_extent == 0);
- ffp->bf_base = malloc(extent);
- if(ffp->bf_base == NULL)
- return ENOMEM;
- ffp->bf_extent = extent;
- }
-
- status = ffio_pgin(nciop, offset,
- extent,
- ffp->bf_base,
- &ffp->bf_cnt, &ffp->pos);
- if(status != ENOERR)
- return status;
-
- ffp->bf_offset = offset;
-
- if(ffp->bf_cnt < extent)
- {
- (void) memset((char *)ffp->bf_base + ffp->bf_cnt, 0,
- extent - ffp->bf_cnt);
- ffp->bf_cnt = extent;
- }
-
-
-#ifdef X_ALIGN
- *vpp = (char *)ffp->bf_base + rem;
-#else
- *vpp = (char *)ffp->bf_base;
-#endif
- return ENOERR;
-}
-
-
-static int
-ncio_ffio_move(ncio *const nciop, off_t to, off_t from,
- size_t nbytes, int rflags)
-{
- int status = ENOERR;
- off_t lower = from;
- off_t upper = to;
- char *base;
- size_t diff = upper - lower;
- size_t extent = diff + nbytes;
-
- rflags &= RGN_NOLOCK; /* filter unwanted flags */
-
- if(to == from)
- return ENOERR; /* NOOP */
-
- if(to > from)
- {
- /* growing */
- lower = from;
- upper = to;
- }
- else
- {
- /* shrinking */
- lower = to;
- upper = from;
- }
-
- diff = upper - lower;
- extent = diff + nbytes;
-
- status = ncio_ffio_get(nciop, lower, extent, RGN_WRITE|rflags,
- (void **)&base);
-
- if(status != ENOERR)
- return status;
-
- if(to > from)
- (void) memmove(base + diff, base, nbytes);
- else
- (void) memmove(base, base + diff, nbytes);
-
- (void) ncio_ffio_rel(nciop, lower, RGN_MODIFIED);
-
- return status;
-}
-
-
-static int
-ncio_ffio_sync(ncio *const nciop)
-{
- if(ffflush(nciop->fd) < 0)
- return errno;
- return ENOERR;
-}
-
-static void
-ncio_ffio_free(void *const pvt)
-{
- ncio_ffio *ffp = (ncio_ffio *)pvt;
- if(ffp == NULL)
- return;
-
- if(ffp->bf_base != NULL)
- {
- free(ffp->bf_base);
- ffp->bf_base = NULL;
- ffp->bf_offset = OFF_NONE;
- ffp->bf_extent = 0;
- ffp->bf_cnt = 0;
- }
-}
-
-
-static int
-ncio_ffio_init2(ncio *const nciop, size_t *sizehintp)
-{
- ncio_ffio *ffp = (ncio_ffio *)nciop->pvt;
-
- assert(nciop->fd >= 0);
-
- ffp->bf_extent = *sizehintp;
-
- assert(ffp->bf_base == NULL);
-
- /* this is separate allocation because it may grow */
- ffp->bf_base = malloc(ffp->bf_extent);
- if(ffp->bf_base == NULL)
- {
- ffp->bf_extent = 0;
- return ENOMEM;
- }
- /* else */
- return ENOERR;
-}
-
-
-static void
-ncio_ffio_init(ncio *const nciop)
-{
- ncio_ffio *ffp = (ncio_ffio *)nciop->pvt;
-
- *((ncio_relfunc **)&nciop->rel) = ncio_ffio_rel; /* cast away const */
- *((ncio_getfunc **)&nciop->get) = ncio_ffio_get; /* cast away const */
- *((ncio_movefunc **)&nciop->move) = ncio_ffio_move; /* cast away const */
- *((ncio_syncfunc **)&nciop->sync) = ncio_ffio_sync; /* cast away const */
- *((ncio_freefunc **)&nciop->free) = ncio_ffio_free; /* cast away const */
-
- ffp->pos = -1;
- ffp->bf_offset = OFF_NONE;
- ffp->bf_extent = 0;
- ffp->bf_cnt = 0;
- ffp->bf_base = NULL;
-}
-
-/* */
-
-static void
-ncio_free(ncio *nciop)
-{
- if(nciop == NULL)
- return;
-
- if(nciop->free != NULL)
- nciop->free(nciop->pvt);
-
- free(nciop);
-}
-
-
-static ncio *
-ncio_new(const char *path, int ioflags)
-{
- size_t sz_ncio = M_RNDUP(sizeof(ncio));
- size_t sz_path = M_RNDUP(strlen(path) +1);
- size_t sz_ncio_pvt;
- ncio *nciop;
-
-#if ALWAYS_NC_SHARE /* DEBUG */
- fSet(ioflags, NC_SHARE);
-#endif
-
- if(fIsSet(ioflags, NC_SHARE))
- fprintf(stderr, "NC_SHARE not implemented for ffio\n");
-
- sz_ncio_pvt = sizeof(ncio_ffio);
-
- nciop = (ncio *) malloc(sz_ncio + sz_path + sz_ncio_pvt);
- if(nciop == NULL)
- return NULL;
-
- nciop->ioflags = ioflags;
- *((int *)&nciop->fd) = -1; /* cast away const */
-
- nciop->path = (char *) ((char *)nciop + sz_ncio);
- (void) strcpy((char *)nciop->path, path); /* cast away const */
-
- /* cast away const */
- *((void **)&nciop->pvt) = (void *)(nciop->path + sz_path);
-
- ncio_ffio_init(nciop);
-
- return nciop;
-}
-
-
-/* Public below this point */
-
-/* TODO: Is this reasonable for this platform? */
-static const size_t NCIO_MINBLOCKSIZE = 256;
-static const size_t NCIO_MAXBLOCKSIZE = 268435456; /* sanity check, about X_SIZE_T_MAX/8 */
-
-int
-ncio_create(const char *path, int ioflags,
- size_t initialsz,
- off_t igeto, size_t igetsz, size_t *sizehintp,
- ncio **nciopp, void **const igetvpp)
-{
- ncio *nciop;
- char *ControlString;
- int oflags = (O_RDWR|O_CREAT|O_TRUNC);
- int fd;
- int status;
- struct ffsw stat;
-
- if(initialsz < (size_t)igeto + igetsz)
- initialsz = (size_t)igeto + igetsz;
-
- fSet(ioflags, NC_WRITE);
-
- if(path == NULL || *path == 0)
- return EINVAL;
-
- nciop = ncio_new(path, ioflags);
- if(nciop == NULL)
- return ENOMEM;
-
- /* TODO: use *sizehintp for input? */
- ControlString = getenv("NETCDF_FFIOSPEC");
- if(ControlString == NULL)
- {
- ControlString="bufa:336:2";
- }
-
- if(fIsSet(ioflags, NC_NOCLOBBER))
- fSet(oflags, O_EXCL);
-
- fd = ffopens(path, oflags, 0666, 0, &stat, ControlString);
- if(fd < 0)
- {
- status = errno;
- goto unwind_new;
- }
- *((int *)&nciop->fd) = fd; /* cast away const */
-
- if(*sizehintp < NCIO_MINBLOCKSIZE || *sizehintp > NCIO_MAXBLOCKSIZE)
- {
- /* Use default */
- *sizehintp = blksize(fd);
- }
- else
- {
- *sizehintp = M_RNDUP(*sizehintp);
- }
-
- status = ncio_ffio_init2(nciop, sizehintp);
- if(status != ENOERR)
- goto unwind_open;
-
- if(initialsz != 0)
- {
- status = fgrow(fd, (off_t)initialsz);
- if(status != ENOERR)
- goto unwind_open;
- }
-
- if(igetsz != 0)
- {
- status = nciop->get(nciop,
- igeto, igetsz,
- RGN_WRITE,
- igetvpp);
- if(status != ENOERR)
- goto unwind_open;
- }
-
- *nciopp = nciop;
- return ENOERR;
-
-unwind_open:
- (void) ffclose(fd);
- /* ?? unlink */
- /*FALLTHRU*/
-unwind_new:
- ncio_free(nciop);
- return status;
-}
-
-
-int
-ncio_open(const char *path,
- int ioflags,
- off_t igeto, size_t igetsz, size_t *sizehintp,
- ncio **nciopp, void **const igetvpp)
-{
- ncio *nciop;
- char *ControlString;
- int oflags = fIsSet(ioflags, NC_WRITE) ? O_RDWR : O_RDONLY;
- int fd;
- int status;
- struct ffsw stat;
-
- if(path == NULL || *path == 0)
- return EINVAL;
-
- nciop = ncio_new(path, ioflags);
- if(nciop == NULL)
- return ENOMEM;
-
- /* TODO: use *sizehintp for input? */
- ControlString = getenv("NETCDF_FFIOSPEC");
- if(ControlString == NULL)
- {
- ControlString="bufa:336:2";
- }
-
- fd = ffopens(path, oflags, 0, 0, &stat, ControlString);
- if(fd < 0)
- {
- status = errno;
- goto unwind_new;
- }
- *((int *)&nciop->fd) = fd; /* cast away const */
-
- if(*sizehintp < NCIO_MINBLOCKSIZE || *sizehintp > NCIO_MAXBLOCKSIZE)
- {
- /* Use default */
- *sizehintp = blksize(fd);
- }
- else
- {
- *sizehintp = M_RNDUP(*sizehintp);
- }
-
- status = ncio_ffio_init2(nciop, sizehintp);
- if(status != ENOERR)
- goto unwind_open;
-
- if(igetsz != 0)
- {
- status = nciop->get(nciop,
- igeto, igetsz,
- 0,
- igetvpp);
- if(status != ENOERR)
- goto unwind_open;
- }
-
- *nciopp = nciop;
- return ENOERR;
-
-unwind_open:
- (void) ffclose(fd);
- /*FALLTHRU*/
-unwind_new:
- ncio_free(nciop);
- return status;
-}
-
-
-int
-ncio_close(ncio *nciop, int doUnlink)
-{
- int status = ENOERR;
-
- if(nciop == NULL)
- return EINVAL;
-
- status = nciop->sync(nciop);
-
- (void) ffclose(nciop->fd);
-
- if(doUnlink)
- (void) unlink(nciop->path);
-
- ncio_free(nciop);
-
- return status;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/libvers.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/libvers.c
deleted file mode 100644
index 8948ecf..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/libvers.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: libvers.c,v 1.2 2005/06/18 18:55:17 svitak Exp $ */
-
-#include "netcdf.h"
-
-/*
- * A version string.
- */
-#define SKIP_LEADING_GARBAGE 33 /* # of chars prior to the actual version */
-#define XSTRING(x) #x
-#define STRING(x) XSTRING(x)
-
-static const char nc_libvers[] = "\044Id: \100(#) netcdf library version "STRING(VERSION)" of "__DATE__" "__TIME__" $";
-
-
-const char *
-nc_inq_libvers(void)
-{
- return &nc_libvers[SKIP_LEADING_GARBAGE];
-}
-
-#if 0 /* TEST JIG */
-#include <stdio.h>
-
-main()
-{
- (void) printf("Version: %s\n", nc_inq_libvers());
- return 0;
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/nc.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/nc.c
deleted file mode 100644
index dc2cd12..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/nc.c
+++ /dev/null
@@ -1,1318 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: nc.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-#include "rnd.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "ncx.h"
-
-
-/* list of open netcdf's */
-static NC *NClist = NULL;
-
-static void
-add_to_NCList(NC *ncp)
-{
- assert(ncp != NULL);
-
- ncp->prev = NULL;
- if(NClist != NULL)
- NClist->prev = ncp;
- ncp->next = NClist;
- NClist = ncp;
-}
-
-static void
-del_from_NCList(NC *ncp)
-{
- assert(ncp != NULL);
-
- if(NClist == ncp)
- {
- assert(ncp->prev == NULL);
- NClist = ncp->next;
- }
- else
- {
- assert(ncp->prev != NULL);
- ncp->prev->next = ncp->next;
- }
-
- if(ncp->next != NULL)
- ncp->next->prev = ncp->prev;
-
- ncp->next = NULL;
- ncp->prev = NULL;
-}
-
-
-int
-NC_check_id(int ncid, NC **ncpp)
-{
- NC *ncp;
-
- if(ncid >= 0)
- {
- for(ncp = NClist; ncp != NULL; ncp = ncp->next)
- {
- if(ncp->nciop->fd == ncid)
- {
- *ncpp = ncp;
- return NC_NOERR; /* normal return */
- }
- }
- }
-
- /* else, not found */
- return NC_EBADID;
-}
-
-
-static void
-free_NC(NC *ncp)
-{
- if(ncp == NULL)
- return;
- free_NC_dimarrayV(&ncp->dims);
- free_NC_attrarrayV(&ncp->attrs);
- free_NC_vararrayV(&ncp->vars);
- free(ncp);
-}
-
-
-static NC *
-new_NC(const size_t *chunkp)
-{
- NC *ncp;
-
- ncp = (NC *) malloc(sizeof(NC));
- if(ncp == NULL)
- return NULL;
- (void) memset(ncp, 0, sizeof(NC));
-
- ncp->xsz = MIN_NC_XSZ;
- assert(ncp->xsz == ncx_len_NC(ncp));
-
- ncp->chunk = chunkp != NULL ? *chunkp : NC_SIZEHINT_DEFAULT;
-
- return ncp;
-}
-
-
-static NC *
-dup_NC(const NC *ref)
-{
- NC *ncp;
-
- ncp = (NC *) malloc(sizeof(NC));
- if(ncp == NULL)
- return NULL;
- (void) memset(ncp, 0, sizeof(NC));
-
- if(dup_NC_dimarrayV(&ncp->dims, &ref->dims) != NC_NOERR)
- goto err;
- if(dup_NC_attrarrayV(&ncp->attrs, &ref->attrs) != NC_NOERR)
- goto err;
- if(dup_NC_vararrayV(&ncp->vars, &ref->vars) != NC_NOERR)
- goto err;
-
- ncp->xsz = ref->xsz;
- ncp->begin_var = ref->begin_var;
- ncp->begin_rec = ref->begin_rec;
- ncp->recsize = ref->recsize;
- ncp->numrecs = ref->numrecs;
- return ncp;
-err:
- free_NC(ncp);
- return NULL;
-}
-
-
-/*
- * Verify that this is a user nc_type
- * Formerly
-NCcktype()
- * Sense of the return is changed.
- */
-int
-nc_cktype(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);
-}
-
-
-/*
- * How many objects of 'type'
- * will fit into xbufsize?
- */
-size_t
-ncx_howmany(nc_type type, size_t xbufsize)
-{
- switch(type){
- case NC_BYTE:
- case NC_CHAR:
- return xbufsize;
- case NC_SHORT:
- return xbufsize/X_SIZEOF_SHORT;
- case NC_INT:
- return xbufsize/X_SIZEOF_INT;
- case NC_FLOAT:
- return xbufsize/X_SIZEOF_FLOAT;
- case NC_DOUBLE:
- return xbufsize/X_SIZEOF_DOUBLE;
- }
- assert("ncx_howmany: Bad type" == 0);
- return(0);
-}
-
-#define D_RNDUP(x, align) _RNDUP(x, (off_t)(align))
-
-/*
- * Compute each variable's 'begin' offset,
- * update 'begin_rec' as well.
- */
-static void
-NC_begins(NC *ncp,
- size_t h_minfree, size_t v_align,
- size_t v_minfree, size_t r_align)
-{
- size_t ii;
- off_t index = 0;
- NC_var **vpp;
- NC_var *last = NULL;
-
- if(v_align == NC_ALIGN_CHUNK)
- v_align = ncp->chunk;
- if(r_align == NC_ALIGN_CHUNK)
- r_align = ncp->chunk;
-
- ncp->xsz = ncx_len_NC(ncp);
-
- if(ncp->vars.nelems == 0)
- return;
-
- index = (off_t) ncp->xsz;
- ncp->begin_var = D_RNDUP(index, v_align);
- if(ncp->begin_var - index < h_minfree)
- {
- ncp->begin_var = D_RNDUP(index + (off_t)h_minfree, v_align);
- }
- index = ncp->begin_var;
-
- /* loop thru vars, first pass is for the 'non-record' vars */
- vpp = ncp->vars.value;
- for(ii = 0; ii < ncp->vars.nelems ; ii++, vpp++)
- {
- if( IS_RECVAR(*vpp) )
- {
- /* skip record variables on this pass */
- continue;
- }
-#if 0
-fprintf(stderr, " VAR %d %s: %ld\n", ii, (*vpp)->name->cp, (long)index);
-#endif
- (*vpp)->begin = index;
- index += (*vpp)->len;
- }
-
- ncp->begin_rec = D_RNDUP(index, r_align);
- if(ncp->begin_rec - index < v_minfree)
- {
- ncp->begin_rec = D_RNDUP(index + (off_t)v_minfree, r_align);
- }
- index = ncp->begin_rec;
-
- ncp->recsize = 0;
-
- /* loop thru vars, second pass is for the 'record' vars */
- vpp = (NC_var **)ncp->vars.value;
- for(ii = 0; ii < ncp->vars.nelems; ii++, vpp++)
- {
- if( !IS_RECVAR(*vpp) )
- {
- /* skip non-record variables on this pass */
- continue;
- }
-
-#if 0
-fprintf(stderr, " REC %d %s: %ld\n", ii, (*vpp)->name->cp, (long)index);
-#endif
- (*vpp)->begin = index;
- index += (*vpp)->len;
- ncp->recsize += (*vpp)->len;
- last = (*vpp);
- }
-
- /*
- * for special case of exactly one record variable, pack value
- */
- if(last != NULL && ncp->recsize == last->len)
- ncp->recsize = *last->dsizes * last->xsz;
-
- if(NC_IsNew(ncp))
- ncp->numrecs = 0;
-
-}
-
-
-/*
- * Read just the numrecs member.
- * (A relatively expensive way to do things.)
- */
-int
-read_numrecs(NC *ncp)
-{
- int status = NC_NOERR;
- const void *xp;
-
- assert(!NC_indef(ncp));
-
-#define NC_NUMRECS_OFFSET 4
-#define NC_NUMRECS_EXTENT 4
- status = ncp->nciop->get(ncp->nciop,
- NC_NUMRECS_OFFSET, NC_NUMRECS_EXTENT, 0, (void **)&xp);
- /* cast away const */
- if(status != NC_NOERR)
- return status;
-
- status = ncx_get_size_t(&xp, &ncp->numrecs);
-
- (void) ncp->nciop->rel(ncp->nciop, NC_NUMRECS_OFFSET, 0);
-
- if(status == NC_NOERR)
- fClr(ncp->flags, NC_NDIRTY);
-
- return status;
-}
-
-
-/*
- * Write out just the numrecs member.
- * (A relatively expensive way to do things.)
- */
-int
-write_numrecs(NC *ncp)
-{
- int status = NC_NOERR;
- void *xp;
-
- assert(!NC_readonly(ncp));
- assert(!NC_indef(ncp));
-
- status = ncp->nciop->get(ncp->nciop,
- NC_NUMRECS_OFFSET, NC_NUMRECS_EXTENT, RGN_WRITE, &xp);
- if(status != NC_NOERR)
- return status;
-
- status = ncx_put_size_t(&xp, &ncp->numrecs);
-
- (void) ncp->nciop->rel(ncp->nciop, NC_NUMRECS_OFFSET, RGN_MODIFIED);
-
- if(status == NC_NOERR)
- fClr(ncp->flags, NC_NDIRTY);
-
- return status;
-}
-
-
-/*
- * Read in the header
- * It is expensive.
- */
-static int
-read_NC(NC *ncp)
-{
- int status = NC_NOERR;
-
- free_NC_dimarrayV(&ncp->dims);
- free_NC_attrarrayV(&ncp->attrs);
- free_NC_vararrayV(&ncp->vars);
-
- status = nc_get_NC(ncp);
-
- if(status == NC_NOERR)
- fClr(ncp->flags, NC_NDIRTY | NC_HDIRTY);
-
- return status;
-}
-
-
-/*
- * Write out the header
- */
-static int
-write_NC(NC *ncp)
-{
- int status = NC_NOERR;
-
- assert(!NC_readonly(ncp));
-
- status = ncx_put_NC(ncp, NULL, 0, 0);
-
- if(status == NC_NOERR)
- fClr(ncp->flags, NC_NDIRTY | NC_HDIRTY);
-
- return status;
-}
-
-
-/*
- * Write the header or the numrecs if necessary.
- */
-int
-NC_sync(NC *ncp)
-{
- assert(!NC_readonly(ncp));
-
- if(NC_hdirty(ncp))
- {
- return write_NC(ncp);
- }
- /* else */
-
- if(NC_ndirty(ncp))
- {
- return write_numrecs(ncp);
- }
- /* else */
-
- return NC_NOERR;
-}
-
-
-/*
- * Initialize the 'non-record' variables.
- */
-static int
-fillerup(NC *ncp)
-{
- int status = NC_NOERR;
- size_t ii;
- NC_var **varpp;
-
- assert(!NC_readonly(ncp));
- assert(NC_dofill(ncp));
-
- /* loop thru vars */
- varpp = ncp->vars.value;
- for(ii = 0; ii < ncp->vars.nelems; ii++, varpp++)
- {
- if(IS_RECVAR(*varpp))
- {
- /* skip record variables */
- continue;
- }
-
- status = fill_NC_var(ncp, *varpp, 0);
- if(status != NC_NOERR)
- break;
- }
- return status;
-}
-
-/* Begin endef */
-
-/*
- */
-static int
-fill_added_recs(NC *gnu, NC *old)
-{
- NC_var ** const gnu_varpp = (NC_var **)gnu->vars.value;
-
- int recno = 0;
- for(; recno < old->numrecs; recno++)
- {
- int varid = (int)old->vars.nelems;
- for(; varid < (int)gnu->vars.nelems; varid++)
- {
- const NC_var *const gnu_varp = *(gnu_varpp + varid);
- if(!IS_RECVAR(gnu_varp))
- {
- /* skip non-record variables */
- continue;
- }
- /* else */
- {
- const int status = fill_NC_var(gnu, gnu_varp, recno);
- if(status != NC_NOERR)
- return status;
- }
- }
- }
-
- return NC_NOERR;
-}
-
-/*
- */
-static int
-fill_added(NC *gnu, NC *old)
-{
- NC_var ** const gnu_varpp = (NC_var **)gnu->vars.value;
- int varid = (int)old->vars.nelems;
-
- for(; varid < (int)gnu->vars.nelems; varid++)
- {
- const NC_var *const gnu_varp = *(gnu_varpp + varid);
- if(IS_RECVAR(gnu_varp))
- {
- /* skip record variables */
- continue;
- }
- /* else */
- {
- const int status = fill_NC_var(gnu, gnu_varp, 0);
- if(status != NC_NOERR)
- return status;
- }
- }
-
- return NC_NOERR;
-}
-
-
-/*
- * Move the records "out".
- * Fill as needed.
- */
-static int
-move_recs_r(NC *gnu, NC *old)
-{
- int status;
- int recno;
- int varid;
- NC_var **gnu_varpp = (NC_var **)gnu->vars.value;
- NC_var **old_varpp = (NC_var **)old->vars.value;
- NC_var *gnu_varp;
- NC_var *old_varp;
- off_t gnu_off;
- off_t old_off;
-
- /* Don't parallelize this loop */
- for(recno = (int)old->numrecs -1; recno >= 0; recno--)
- {
- /* Don't parallelize this loop */
- for(varid = (int)old->vars.nelems -1; varid >= 0; varid--)
- {
- gnu_varp = *(gnu_varpp + varid);
- if(!IS_RECVAR(gnu_varp))
- {
- /* skip non-record variables on this pass */
- continue;
- }
- /* else */
-
- /* else, a pre-existing variable */
- old_varp = *(old_varpp + varid);
- gnu_off = gnu_varp->begin + (off_t)(gnu->recsize * recno);
- old_off = old_varp->begin + (off_t)(old->recsize * recno);
-
- if(gnu_off == old_off)
- continue; /* nothing to do */
-
- assert(gnu_off > old_off);
-
- status = gnu->nciop->move(gnu->nciop, gnu_off, old_off,
- old_varp->len, 0);
-
- if(status != NC_NOERR)
- return status;
-
- }
- }
-
- gnu->numrecs = old->numrecs;
-
- return NC_NOERR;
-}
-
-
-/*
- * Move the "non record" variables "out".
- * Fill as needed.
- */
-static int
-move_vars_r(NC *gnu, NC *old)
-{
- int status;
- int varid;
- NC_var **gnu_varpp = (NC_var **)gnu->vars.value;
- NC_var **old_varpp = (NC_var **)old->vars.value;
- NC_var *gnu_varp;
- NC_var *old_varp;
- off_t gnu_off;
- off_t old_off;
-
- /* Don't parallelize this loop */
- for(varid = (int)old->vars.nelems -1;
- varid >= 0; varid--)
- {
- gnu_varp = *(gnu_varpp + varid);
- if(IS_RECVAR(gnu_varp))
- {
- /* skip record variables on this pass */
- continue;
- }
- /* else */
-
- old_varp = *(old_varpp + varid);
- gnu_off = gnu_varp->begin;
- old_off = old_varp->begin;
-
- if(gnu_off == old_off)
- continue; /* nothing to do */
-
- assert(gnu_off > old_off);
-
- status = gnu->nciop->move(gnu->nciop, gnu_off, old_off,
- old_varp->len, 0);
-
- if(status != NC_NOERR)
- return status;
-
- }
-
- return NC_NOERR;
-}
-
-
-/*
- * Move the "non record" variables "in".
- * Fill as needed.
- */
-static int
-move_vars_f(NC *gnu, NC *old)
-{
- int status;
- int varid;
- NC_var **gnu_varpp = (NC_var **)gnu->vars.value;
- NC_var **old_varpp = (NC_var **)old->vars.value;
- NC_var *gnu_varp;
- NC_var *old_varp;
- off_t gnu_off;
- off_t old_off;
-
-
- for(varid = 0; (size_t) varid < old->vars.nelems; varid++)
- {
- gnu_varp = *(gnu_varpp + varid);
- if(IS_RECVAR(gnu_varp))
- {
- /* skip record variables on this pass */
- continue;
- }
- /* else */
-
- old_varp = *(old_varpp + varid);
- gnu_off = gnu_varp->begin;
- old_off = old_varp->begin;
-
- if(gnu_off == old_off)
- continue; /* nothing to do */
-
- assert(gnu_off < old_off);
-
- status = gnu->nciop->move(gnu->nciop, gnu_off, old_off,
- old_varp->len, 0);
-
- if(status != NC_NOERR)
- return status;
- }
-
- return NC_NOERR;
-}
-
-
-/*
- * Move the records "in".
- * Fill as needed.
- */
-static int
-move_recs_f(NC *gnu, NC *old)
-{
- int status;
- size_t recno;
- int varid;
- NC_var **gnu_varpp = (NC_var **)gnu->vars.value;
- NC_var **old_varpp = (NC_var **)old->vars.value;
- NC_var *gnu_varp;
- NC_var *old_varp;
- off_t gnu_off;
- off_t old_off;
-
-
- for(recno = 0; recno < old->numrecs; recno++)
- {
- for(varid = 0; (size_t) varid < gnu->vars.nelems; varid++)
- {
- gnu_varp = *(gnu_varpp + varid);
- if(!IS_RECVAR(gnu_varp))
- {
- /* skip non-record variables on this pass */
- continue;
- }
- /* else */
-
- if((size_t) varid < old->vars.nelems)
- {
- /* a pre-existing variable */
- old_varp = *(old_varpp + varid);
- gnu_off = gnu_varp->begin +
- (off_t)(gnu->recsize * recno);
- old_off = old_varp->begin +
- (off_t)(old->recsize * recno);
-
- if(gnu_off == old_off)
- continue; /* nothing to do */
-
- assert(gnu_off < old_off);
-
- status = gnu->nciop->move(gnu->nciop, gnu_off, old_off,
- old_varp->len, 0);
-
- if(status != NC_NOERR)
- return status;
- continue;
- }
-
-
- /* else, a new variable */
- if(NC_dofill(gnu))
- {
- status = fill_NC_var(gnu, gnu_varp, recno);
- if(status != NC_NOERR)
- return status;
- }
- }
- }
-
- gnu->numrecs = old->numrecs;
-
- return NC_NOERR;
-}
-
-
-/*
- * End define mode.
- * Common code for ncendef, ncclose(endef)
- */
-static int
-NC_endef(NC *ncp,
- size_t h_minfree, size_t v_align,
- size_t v_minfree, size_t r_align)
-{
- int status = NC_NOERR;
-
- assert(!NC_readonly(ncp));
- assert(NC_indef(ncp));
-
- NC_begins(ncp, h_minfree, v_align, v_minfree, r_align);
-
- if(ncp->old != NULL)
- {
- /* a plain redef, not a create */
- assert(!NC_IsNew(ncp));
- assert(fIsSet(ncp->flags, NC_INDEF));
-
- if(ncp->vars.nelems != 0)
- {
- if(ncp->begin_rec > ncp->old->begin_rec)
- {
- status = move_recs_r(ncp, ncp->old);
- if(status != NC_NOERR)
- return status;
- if(ncp->begin_var > ncp->old->begin_var)
- {
- status = move_vars_r(ncp, ncp->old);
- if(status != NC_NOERR)
- return status;
- }
- else
- {
- /* ncp->begin_var <= ncp->old->begin_var */
- /* rare */
- status = move_vars_f(ncp, ncp->old);
- if(status != NC_NOERR)
- return status;
- }
- }
- else if(ncp->begin_rec < ncp->old->begin_rec)
- {
- if(ncp->begin_var < ncp->old->begin_var)
- {
- status = move_vars_f(ncp, ncp->old);
- if(status != NC_NOERR)
- return status;
- }
-#ifndef NDEBUG
- else
- {
- assert("Number of non rec vars shrank (<) ???"
- == 0);
- }
-#endif
- status = move_recs_f(ncp, ncp->old);
- if(status != NC_NOERR)
- return status;
- }
- else
- {
- /* ncp->begin_rec == ncp->old->begin_rec */
- /* rare and untested */
- if(ncp->begin_var < ncp->old->begin_var)
- {
- status = move_vars_f(ncp, ncp->old);
- if(status != NC_NOERR)
- return status;
- }
-#ifndef NDEBUG
- else if(ncp->begin_var > ncp->old->begin_var)
- {
- assert("Number of non rec vars shrank (==) ???"
- == 0);
- }
-#endif
- /* ncp->begin_var == ncp->old->begin_var */
- /* NOOP */
- }
- }
- }
-
- status = write_NC(ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_dofill(ncp))
- {
- if(NC_IsNew(ncp))
- {
- status = fillerup(ncp);
- if(status != NC_NOERR)
- return status;
-
- }
- else if(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)
- {
- free_NC(ncp->old);
- ncp->old = NULL;
- }
-
- fClr(ncp->flags, NC_CREAT | NC_INDEF);
- return(status);
-}
-
-
-/* Public */
-
-int
-nc__create(const char * path, int ioflags, size_t initialsz,
- size_t *chunksizehintp, int *ncid_ptr)
-{
- NC *ncp;
- int status;
- void *xp = NULL;
-
-#if ALWAYS_NC_SHARE /* DEBUG */
- fSet(ioflags, NC_SHARE);
-#endif
-
- ncp = new_NC(chunksizehintp);
- if(ncp == NULL)
- return NC_ENOMEM;
-
- assert(ncp->xsz == ncx_len_NC(ncp));
-
- status = ncio_create(path, ioflags,
- initialsz,
- 0, ncp->xsz, &ncp->chunk,
- &ncp->nciop, &xp);
- if(status != NC_NOERR)
- {
- /* translate error status */
- if(status == EEXIST)
- status = NC_EEXIST;
- goto unwind_alloc;
- }
-
- assert(ncp->flags == 0);
- fSet(ncp->flags, NC_CREAT);
-
- if(fIsSet(ncp->nciop->ioflags, NC_SHARE))
- {
- /*
- * NC_SHARE implies sync up the number of records as well.
- * (File format version one.)
- * Note that other header changes are not shared
- * automatically. Some sort of IPC (external to this package)
- * would be used to trigger a call to nc_sync().
- */
- fSet(ncp->flags, NC_NSYNC);
- }
-
- status = ncx_put_NC(ncp, &xp, 0, ncp->xsz);
- if(status != NC_NOERR)
- goto unwind_ioc;
-
- add_to_NCList(ncp);
-
- if(chunksizehintp != NULL)
- *chunksizehintp = ncp->chunk;
- *ncid_ptr = ncp->nciop->fd;
- return NC_NOERR;
-
-unwind_ioc:
- (void) ncio_close(ncp->nciop, 1); /* N.B.: unlink */
- ncp->nciop = NULL;
- /*FALLTHRU*/
-unwind_alloc:
- free_NC(ncp);
- return status;
-}
-
-int
-nc_create(const char * path, int ioflags, int *ncid_ptr)
-{
- return nc__create(path, ioflags, 0, NULL, ncid_ptr);
-}
-
-
-int
-nc__open(const char * path, int ioflags, size_t *chunksizehintp, int *ncid_ptr)
-{
- NC *ncp;
- int status;
-
-#if ALWAYS_NC_SHARE /* DEBUG */
- fSet(ioflags, NC_SHARE);
-#endif
-
- ncp = new_NC(chunksizehintp);
- if(ncp == NULL)
- return NC_ENOMEM;
-
- status = ncio_open(path, ioflags,
- 0, 0, &ncp->chunk,
- &ncp->nciop, 0);
- if(status)
- goto unwind_alloc;
-
- assert(ncp->flags == 0);
-
- if(fIsSet(ncp->nciop->ioflags, NC_SHARE))
- {
- /*
- * NC_SHARE implies sync up the number of records as well.
- * (File format version one.)
- * Note that other header changes are not shared
- * automatically. Some sort of IPC (external to this package)
- * would be used to trigger a call to nc_sync().
- */
- fSet(ncp->flags, NC_NSYNC);
- }
-
- status = nc_get_NC(ncp);
- if(status != NC_NOERR)
- goto unwind_ioc;
-
- add_to_NCList(ncp);
-
- if(chunksizehintp != NULL)
- *chunksizehintp = ncp->chunk;
- *ncid_ptr = ncp->nciop->fd;
- return NC_NOERR;
-
-unwind_ioc:
- (void) ncio_close(ncp->nciop, 0);
- ncp->nciop = NULL;
- /*FALLTHRU*/
-unwind_alloc:
- free_NC(ncp);
- return status;
-}
-
-int
-nc_open(const char * path, int ioflags, int *ncid_ptr)
-{
- return nc__open(path, ioflags, NULL, ncid_ptr);
-}
-
-
-int
-nc__enddef(int ncid,
- size_t h_minfree, size_t v_align,
- size_t v_minfree, size_t r_align)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(!NC_indef(ncp))
- return(NC_ENOTINDEFINE);
-
- return(NC_endef(ncp, h_minfree, v_align, v_minfree, r_align));
-}
-
-int
-nc_enddef(int ncid)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(!NC_indef(ncp))
- return(NC_ENOTINDEFINE);
-
- /* return(NC_endef(ncp, 0, 4096, 0, 4096)); */
- return(NC_endef(ncp, 0, 1, 0, 1));
-}
-
-
-int
-nc_close(int ncid)
-{
- int status = NC_NOERR;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- {
- status = NC_endef(ncp, 0, 1, 0, 1); /* TODO: defaults */
- if(status != NC_NOERR )
- {
- (void) nc_abort(ncid);
- return status;
- }
- }
- else if(!NC_readonly(ncp))
- {
- status = NC_sync(ncp);
- }
-
- (void) ncio_close(ncp->nciop, 0);
- ncp->nciop = NULL;
-
- del_from_NCList(ncp);
-
- free_NC(ncp);
-
- return status;
-}
-
-
-EXTERNL int
-nc_delete(const char * path)
-{
- NC *ncp;
- int status;
- size_t chunk = 512;
-
- ncp = new_NC(&chunk);
- if(ncp == NULL)
- return NC_ENOMEM;
-
- status = ncio_open(path, NC_NOWRITE,
- 0, 0, &ncp->chunk,
- &ncp->nciop, 0);
- if(status)
- goto unwind_alloc;
-
- assert(ncp->flags == 0);
-
- status = nc_get_NC(ncp);
- if(status != NC_NOERR)
- {
- /* Not a netcdf file, don't delete */
- /* ??? is this the right semantic? what if it was just too big? */
- (void) ncio_close(ncp->nciop, 0);
- }
- else
- {
- /* ncio_close does the unlink */
- status = ncio_close(ncp->nciop, 1); /* ncio_close does the unlink */
- }
-
- ncp->nciop = NULL;
-unwind_alloc:
- free_NC(ncp);
- return status;
-}
-
-
-/*
- * In data mode, same as ncclose.
- * In define mode, restore previous definition.
- * In create, remove the file.
- */
-int
-nc_abort(int ncid)
-{
- int status;
- NC *ncp;
- int doUnlink = 0;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- doUnlink = NC_IsNew(ncp);
-
- if(ncp->old != NULL)
- {
- /* a plain redef, not a create */
- assert(!NC_IsNew(ncp));
- assert(fIsSet(ncp->flags, NC_INDEF));
- free_NC(ncp->old);
- ncp->old = NULL;
- fClr(ncp->flags, NC_INDEF);
- }
- else if(!NC_readonly(ncp))
- {
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
-
- (void) ncio_close(ncp->nciop, doUnlink);
- ncp->nciop = NULL;
-
- del_from_NCList(ncp);
-
- free_NC(ncp);
-
- return NC_NOERR;
-}
-
-
-int
-nc_redef(int ncid)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
-
- if(fIsSet(ncp->nciop->ioflags, NC_SHARE))
- {
- /* read in from disk */
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- ncp->old = dup_NC(ncp);
- if(ncp->old == NULL)
- return NC_ENOMEM;
-
- fSet(ncp->flags, NC_INDEF);
-
- return NC_NOERR;
-}
-
-
-int
-nc_inq(int ncid,
- int *ndimsp,
- int *nvarsp,
- int *nattsp,
- int *xtendimp)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(ndimsp != NULL)
- *ndimsp = (int) ncp->dims.nelems;
- if(nvarsp != NULL)
- *nvarsp = (int) ncp->vars.nelems;
- if(nattsp != NULL)
- *nattsp = (int) ncp->attrs.nelems;
- if(xtendimp != NULL)
- *xtendimp = find_NC_Udim(&ncp->dims, NULL);
-
- return NC_NOERR;
-}
-
-int
-nc_inq_ndims(int ncid, int *ndimsp)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(ndimsp != NULL)
- *ndimsp = (int) ncp->dims.nelems;
-
- return NC_NOERR;
-}
-
-int
-nc_inq_nvars(int ncid, int *nvarsp)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(nvarsp != NULL)
- *nvarsp = (int) ncp->vars.nelems;
-
- return NC_NOERR;
-}
-
-int
-nc_inq_natts(int ncid, int *nattsp)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(nattsp != NULL)
- *nattsp = (int) ncp->attrs.nelems;
-
- return NC_NOERR;
-}
-
-int
-nc_inq_unlimdim(int ncid, int *xtendimp)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(xtendimp != NULL)
- *xtendimp = find_NC_Udim(&ncp->dims, NULL);
-
- return NC_NOERR;
-}
-
-
-int
-nc_sync(int ncid)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- if(NC_readonly(ncp))
- {
- return read_NC(ncp);
- }
- /* else, read/write */
-
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
-
- return ncp->nciop->sync(ncp->nciop);
-}
-
-
-int
-nc_set_fill(int ncid,
- int fillmode, int *old_mode_ptr)
-{
- int status;
- NC *ncp;
- int oldmode;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- oldmode = fIsSet(ncp->flags, NC_NOFILL) ? NC_NOFILL : NC_FILL;
-
- if(fillmode == NC_NOFILL)
- {
- fSet(ncp->flags, NC_NOFILL);
- }
- else if(fillmode == NC_FILL)
- {
- if(fIsSet(ncp->flags, NC_NOFILL))
- {
- /*
- * We are changing back to fill mode
- * so do a sync
- */
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
- fClr(ncp->flags, NC_NOFILL);
- }
- else
- {
- return NC_EINVAL; /* Invalid fillmode */
- }
-
- if(old_mode_ptr != NULL)
- *old_mode_ptr = oldmode;
-
- return NC_NOERR;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/nc.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/nc.h
deleted file mode 100644
index de256c6..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/nc.h
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: nc.h,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-#ifndef _NC_H_
-#define _NC_H_
-
-/*
- * netcdf library 'private' data structures, objects and interfaces
- */
-
-#include "ncconfig.h"
-#include <stddef.h> /* size_t */
-#include <sys/types.h> /* off_t */
-#include "netcdf.h"
-#include "ncio.h" /* ncio */
-#include "fbits.h"
-
-
-#ifndef NC_ARRAY_GROWBY
-#define NC_ARRAY_GROWBY 4
-#endif
-
-/*
- * The extern size of an empty
- * netcdf version 1 file.
- * The initial value of ncp->xsz.
- */
-#define MIN_NC_XSZ 32
-
-typedef struct NC NC; /* forward reference */
-
-/*
- * The internal data types
- */
-typedef enum {
- NC_UNSPECIFIED = 0,
-/* future NC_BITFIELD = 7, */
-/* NC_STRING = 8, */
- NC_DIMENSION = 10,
- NC_VARIABLE = 11,
- NC_ATTRIBUTE = 12
-} NCtype;
-
-
-/*
- * Counted string for names and such
- */
-typedef struct {
- /* all xdr'd */
- size_t nchars;
- char *cp;
-} NC_string;
-
-/* Begin defined in string.c */
-extern void
-free_NC_string(NC_string *ncstrp);
-
-extern int
-NC_check_name(const char *name);
-
-extern NC_string *
-new_NC_string(size_t slen, const char *str);
-
-extern int
-set_NC_string(NC_string *ncstrp, const char *str);
-
-/* End defined in string.c */
-
-/*
- * NC dimension stucture
- */
-typedef struct {
- /* all xdr'd */
- NC_string *name;
- size_t size;
-} NC_dim;
-
-typedef struct NC_dimarray {
- size_t nalloc; /* number allocated >= nelems */
- /* below gets xdr'd */
- /* NCtype type = NC_DIMENSION */
- size_t nelems; /* length of the array */
- NC_dim **value;
-} NC_dimarray;
-
-/* Begin defined in dim.c */
-
-extern void
-free_NC_dim(NC_dim *dimp);
-
-extern NC_dim *
-new_x_NC_dim(NC_string *name);
-
-extern int
-find_NC_Udim(const NC_dimarray *ncap, NC_dim **dimpp);
-
-/* dimarray */
-
-extern void
-free_NC_dimarrayV0(NC_dimarray *ncap);
-
-extern void
-free_NC_dimarrayV(NC_dimarray *ncap);
-
-extern int
-dup_NC_dimarrayV(NC_dimarray *ncap, const NC_dimarray *ref);
-
-extern NC_dim *
-elem_NC_dimarray(const NC_dimarray *ncap, size_t elem);
-
-/* End defined in dim.c */
-
-/*
- * NC attribute
- */
-typedef struct {
- size_t xsz; /* amount of space at xvalue */
- /* below gets xdr'd */
- NC_string *name;
- nc_type type; /* the discriminant */
- size_t nelems; /* length of the array */
- void *xvalue; /* the actual data, in external representation */
-} NC_attr;
-
-typedef struct NC_attrarray {
- size_t nalloc; /* number allocated >= nelems */
- /* below gets xdr'd */
- /* NCtype type = NC_ATTRIBUTE */
- size_t nelems; /* length of the array */
- NC_attr **value;
-} NC_attrarray;
-
-/* Begin defined in attr.c */
-
-extern void
-free_NC_attr(NC_attr *attrp);
-
-extern NC_attr *
-new_x_NC_attr(
- NC_string *strp,
- nc_type type,
- size_t nelems);
-
-extern NC_attr **
-NC_findattr(const NC_attrarray *ncap, const char *name);
-
-/* attrarray */
-
-extern void
-free_NC_attrarrayV0(NC_attrarray *ncap);
-
-extern void
-free_NC_attrarrayV(NC_attrarray *ncap);
-
-extern int
-dup_NC_attrarrayV(NC_attrarray *ncap, const NC_attrarray *ref);
-
-extern NC_attr *
-elem_NC_attrarray(const NC_attrarray *ncap, size_t elem);
-
-/* End defined in attr.c */
-
-
-/*
- * NC variable: description and data
- */
-typedef struct {
- size_t xsz; /* xszof 1 element */
- size_t *shape; /* compiled info: dim->size of each dim */
- size_t *dsizes; /* compiled info: the right to left product of shape */
- /* below gets xdr'd */
- NC_string *name;
- /* next two: formerly NC_iarray *assoc */ /* user definition */
- size_t ndims; /* assoc->count */
- int *dimids; /* assoc->value */
- NC_attrarray attrs;
- nc_type type; /* the discriminant */
- size_t len; /* the total length originally allocated */
- off_t begin;
-} NC_var;
-
-typedef struct NC_vararray {
- size_t nalloc; /* number allocated >= nelems */
- /* below gets xdr'd */
- /* NCtype type = NC_VARIABLE */
- size_t nelems; /* length of the array */
- NC_var **value;
-} NC_vararray;
-
-/* Begin defined in var.c */
-
-extern void
-free_NC_var(NC_var *varp);
-
-extern NC_var *
-new_x_NC_var(
- NC_string *strp,
- size_t ndims);
-
-/* vararray */
-
-extern void
-free_NC_vararrayV0(NC_vararray *ncap);
-
-extern void
-free_NC_vararrayV(NC_vararray *ncap);
-
-extern int
-dup_NC_vararrayV(NC_vararray *ncap, const NC_vararray *ref);
-
-extern int
-NC_var_shape(NC_var *varp, const NC_dimarray *dims);
-
-extern int
-NC_findvar(const NC_vararray *ncap, const char *name, NC_var **varpp);
-
-extern NC_var *
-NC_lookupvar(NC *ncp, int varid);
-
-/* End defined in var.c */
-
-#define IS_RECVAR(vp) \
- ((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )
-
-struct NC {
- /* links to make list of open netcdf's */
- struct NC *next;
- struct NC *prev;
- /* contains the previous NC during redef. */
- struct NC *old;
- /* flags */
-#define NC_CREAT 2 /* in create phase, cleared by ncendef */
-#define NC_INDEF 8 /* in define mode, cleared by ncendef */
-#define NC_NSYNC 0x10 /* synchronise numrecs on change */
-#define NC_HSYNC 0x20 /* synchronise whole header on change */
-#define NC_NDIRTY 0x40 /* numrecs has changed */
-#define NC_HDIRTY 0x80 /* header info has changed */
-/* NC_NOFILL in netcdf.h, historical interface */
- int flags;
- ncio *nciop;
- size_t chunk; /* largest extent this layer will request from ncio->get() */
- size_t xsz; /* external size of this header, == var[0].begin */
- off_t begin_var; /* postion of the first (non-record) var */
- off_t begin_rec; /* postion of the first 'record' */
- size_t recsize; /* length of 'record' */
- /* below gets xdr'd */
- size_t numrecs; /* number of 'records' allocated */
- NC_dimarray dims;
- NC_attrarray attrs;
- NC_vararray vars;
-};
-
-#define NC_readonly(ncp) \
- (!fIsSet(ncp->nciop->ioflags, NC_WRITE))
-
-#define NC_IsNew(ncp) \
- fIsSet((ncp)->flags, NC_CREAT)
-
-#define NC_indef(ncp) \
- (NC_IsNew(ncp) || fIsSet((ncp)->flags, NC_INDEF))
-
-#define set_NC_ndirty(ncp) \
- fSet((ncp)->flags, NC_NDIRTY)
-
-#define NC_ndirty(ncp) \
- fIsSet((ncp)->flags, NC_NDIRTY)
-
-#define set_NC_hdirty(ncp) \
- fSet((ncp)->flags, NC_HDIRTY)
-
-#define NC_hdirty(ncp) \
- fIsSet((ncp)->flags, NC_HDIRTY)
-
-#define NC_dofill(ncp) \
- (!fIsSet((ncp)->flags, NC_NOFILL))
-
-#define NC_doHsync(ncp) \
- fIsSet((ncp)->flags, NC_HSYNC)
-
-#define NC_doNsync(ncp) \
- fIsSet((ncp)->flags, NC_NSYNC)
-
-/* Begin defined in nc.c */
-
-extern int
-NC_check_id(int ncid, NC **ncpp);
-
-extern int
-nc_cktype(nc_type datatype);
-
-extern size_t
-ncx_howmany(nc_type type, size_t xbufsize);
-
-extern int
-read_numrecs(NC *ncp);
-
-extern int
-write_numrecs(NC *ncp);
-
-extern int
-NC_sync(NC *ncp);
-
-/* End defined in nc.c */
-/* Begin defined in v1hpg.c */
-
-extern size_t
-ncx_len_NC(const NC *ncp);
-
-extern int
-ncx_put_NC(const NC *ncp, void **xpp, off_t offset, size_t extent);
-
-extern int
-nc_get_NC( NC *ncp);
-
-/* End defined in v1hpg.c */
-/* Begin defined in putget.c */
-
-extern int
-fill_NC_var(NC *ncp, const NC_var *varp, size_t recno);
-
-extern int
-nc_inq_rec(int ncid, size_t *nrecvars, int *recvarids, size_t *recsizes);
-
-extern int
-nc_get_rec(int ncid, size_t recnum, void **datap);
-
-extern int
-nc_put_rec(int ncid, size_t recnum, void *const *datap);
-
-/* End defined in putget.c */
-
-/*
- * These functions are used to support
- * interface version 2 backward compatiblity.
- * N.B. these are tested in ../nc_test even though they are
- * not public. So, be careful to change the declarations in
- * ../nc_test/tests.h if you change these.
- */
-
-extern int
-nc_put_att(int ncid, int varid, const char *name, nc_type datatype,
- size_t len, const void *value);
-
-extern int
-nc_get_att(int ncid, int varid, const char *name, void *value);
-
-extern int
-nc_put_var1(int ncid, int varid, const size_t *index, const void *value);
-
-extern int
-nc_get_var1(int ncid, int varid, const size_t *index, void *value);
-
-extern int
-nc_put_vara(int ncid, int varid,
- const size_t *start, const size_t *count, const void *value);
-
-extern int
-nc_get_vara(int ncid, int varid,
- const size_t *start, const size_t *count, void *value);
-
-extern int
-nc_put_vars(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- const void * value);
-
-extern int
-nc_get_vars(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- void * value);
-
-extern int
-nc_put_varm(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- const ptrdiff_t * map, const void *value);
-
-extern int
-nc_get_varm(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- const ptrdiff_t * map, void *value);
-
-#endif /* _NC_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncconfig.in b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncconfig.in
deleted file mode 100644
index 487a487..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncconfig.in
+++ /dev/null
@@ -1,81 +0,0 @@
-/* libsrc/ncconfig.in. Generated automatically from configure.in by autoheader. */
-/* $Id: ncconfig.in,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-#ifndef _NCCONFIG_H_
-#define _NCCONFIG_H_
-
-/* Define if you're on an HP-UX system. */
-#undef _HPUX_SOURCE
-
-/* Define if type char is unsigned and you are not using gcc. */
-#ifndef __CHAR_UNSIGNED__
-#undef __CHAR_UNSIGNED__
-#endif
-
-/* Define if your struct stat has st_blksize. */
-#undef HAVE_ST_BLKSIZE
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-#undef off_t
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-#undef size_t
-
-/* Define if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
-/* Define if you don't have the <stdlib.h>. */
-#undef NO_STDLIB_H
-
-/* Define if you don't have the <sys/types.h>. */
-#undef NO_SYS_TYPES_H
-
-/* Define if you have the ftruncate function */
-#undef HAVE_FTRUNCATE
-
-/* Define if you have alloca, as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-#undef HAVE_ALLOCA_H
-
-/* Define if you don't have the strerror function */
-#undef NO_STRERROR
-
-/* The number of bytes in a size_t */
-#undef SIZEOF_SIZE_T
-
-/* The number of bytes in a off_t */
-#undef SIZEOF_OFF_T
-
-/* Define to `int' if system doesn't define. */
-#undef ssize_t
-
-/* Define to `int' if system doesn't define. */
-#undef ptrdiff_t
-
-/* Define to `unsigned char' if system doesn't define. */
-#undef uchar
-
-/* Define if the system does not use IEEE floating point representation */
-#undef NO_IEEE_FLOAT
-
-/* The number of bytes in a double. */
-#undef SIZEOF_DOUBLE
-
-/* The number of bytes in a float. */
-#undef SIZEOF_FLOAT
-
-/* The number of bytes in a int. */
-#undef SIZEOF_INT
-
-/* The number of bytes in a long. */
-#undef SIZEOF_LONG
-
-/* The number of bytes in a short. */
-#undef SIZEOF_SHORT
-
-#endif /* !_NCCONFIG_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncconfig.xt3.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncconfig.xt3.h
deleted file mode 100644
index efcdbe9..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncconfig.xt3.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ncconfig.h for Cray XT3 (needed since netcdf configure scripts do not work
- with cross-compilation environment on the XT3) */
-
-/* $Id: ncconfig.xt3.h,v 1.1 2005/09/29 21:35:43 ghood Exp $ */
-#ifndef _NCCONFIG_H_
-#define _NCCONFIG_H_
-
-/* Define if you're on an HP-UX system. */
-#undef _HPUX_SOURCE
-
-/* Define if type char is unsigned and you are not using gcc. */
-#ifndef __CHAR_UNSIGNED__
-#undef __CHAR_UNSIGNED__
-#endif
-
-/* Define if your struct stat has st_blksize. */
-#define HAVE_ST_BLKSIZE
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-#undef off_t
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-#undef size_t
-
-/* Define if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
-/* Define if you don't have the <stdlib.h>. */
-#undef NO_STDLIB_H
-
-/* Define if you don't have the <sys/types.h>. */
-#undef NO_SYS_TYPES_H
-
-/* Define if you have the ftruncate function */
-#undef HAVE_FTRUNCATE
-
-/* Define if you have alloca, as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-#undef HAVE_ALLOCA_H
-
-/* Define if you don't have the strerror function */
-#undef NO_STRERROR
-
-/* The number of bytes in a size_t */
-#define SIZEOF_SIZE_T 8
-
-/* The number of bytes in a off_t */
-#define SIZEOF_OFF_T 8
-
-/* Define to `int' if system doesn't define. */
-#undef ssize_t
-
-/* Define to `int' if system doesn't define. */
-#undef ptrdiff_t
-
-/* Define to `unsigned char' if system doesn't define. */
-#define uchar unsigned char
-
-/* Define if the system does not use IEEE floating point representation */
-#undef NO_IEEE_FLOAT
-
-/* The number of bytes in a double. */
-#define SIZEOF_DOUBLE 8
-
-/* The number of bytes in a float. */
-#define SIZEOF_FLOAT 4
-
-/* The number of bytes in a int. */
-#define SIZEOF_INT 4
-
-/* The number of bytes in a long. */
-#define SIZEOF_LONG 8
-
-/* The number of bytes in a short. */
-#define SIZEOF_SHORT 2
-
-#endif /* !_NCCONFIG_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncio.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncio.c
deleted file mode 100644
index 7146a7f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncio.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * $Id: ncio.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- */
-
-#if defined(_CRAY)
-# include "ffio.c"
-#else
-# include "posixio.c"
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncio.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncio.h
deleted file mode 100644
index 517222f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncio.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: ncio.h,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#ifndef _NCIO_H_
-#define _NCIO_H_
-
-#include <stddef.h> /* size_t */
-#include <sys/types.h> /* off_t */
-#include "netcdf.h"
-
-typedef struct ncio ncio; /* forward reference */
-
-/*
- * A value which is an invalid off_t
- */
-#define OFF_NONE ((off_t)(-1))
-
-/*
- * Flags used by the region layer,
- * 'rflags' argument to ncio.rel() and ncio.get().
- */
-#define RGN_NOLOCK 0x1 /* Don't lock region.
- * Used when contention control handled
- * elsewhere.
- */
-#define RGN_NOWAIT 0x2 /* return immediate if can't lock, else wait */
-
-#define RGN_WRITE 0x4 /* we intend to modify, else read only */
-
-#define RGN_MODIFIED 0x8 /* we did modify, else, discard */
-
-
-/*
- * The next four typedefs define the signatures
- * of function pointers in struct ncio below.
- * They are not used outside of this file and ncio.h,
- * They just some casts in the ncio.c more readable.
- */
- /*
- * Indicate that you are done with the region which begins
- * at offset. Only reasonable flag value is RGN_MODIFIED.
- */
-typedef int ncio_relfunc(ncio *const nciop,
- off_t offset, int rflags);
-
- /*
- * Request that the region (offset, extent)
- * be made available through *vpp.
- */
-typedef int ncio_getfunc(ncio *const nciop,
- off_t offset, size_t extent,
- int rflags,
- void **const vpp);
-
- /*
- * Like memmove(), safely move possibly overlapping data.
- * Only reasonable flag value is RGN_NOLOCK.
- */
-typedef int ncio_movefunc(ncio *const nciop, off_t to, off_t from,
- size_t nbytes, int rflags);
-
- /*
- * Write out any dirty buffers to disk and
- * ensure that next read will get data from disk.
- */
-typedef int ncio_syncfunc(ncio *const nciop);
-
- /*
- * Don't call this.
- * Internal function called at close to
- * free up anything hanging off pvt;
- */
-typedef void ncio_freefunc(void *const pvt);
-
-/* Get around cplusplus "const xxx in class ncio without constructor" error */
-#if defined(__cplusplus)
-#define NCIO_CONST
-#else
-#define NCIO_CONST const
-#endif
-
-/*
- * netcdf i/o abstraction
- */
-struct ncio {
- /*
- * A copy of the ioflags argument passed in to ncio_open()
- * or ncio_create().
- */
- int ioflags;
-
- /*
- * The file descriptor of the netcdf file.
- * This gets handed to the user as the netcdf id.
- */
- NCIO_CONST int fd;
-
- /* member functions do the work */
-
- ncio_relfunc *NCIO_CONST rel;
-
- ncio_getfunc *NCIO_CONST get;
-
- ncio_movefunc *NCIO_CONST move;
-
- ncio_syncfunc *NCIO_CONST sync;
-
- ncio_freefunc *NCIO_CONST free; /* Implementation private */
-
- /*
- * A copy of the 'path' argument passed in to ncio_open()
- * or ncio_create(). Used by ncabort() to remove (unlink)
- * the file and by error messages.
- */
- const char *path;
-
- /* implementation private stuff */
- void *NCIO_CONST pvt;
-};
-
-#undef NCIO_CONST
-
-extern int
-ncio_create(const char *path, int ioflags,
- size_t initialsz,
- off_t igeto, size_t igetsz, size_t *sizehintp,
- ncio **nciopp, void **const igetvpp);
-
-extern int
-ncio_open(const char *path,
- int ioflags,
- off_t igeto, size_t igetsz, size_t *sizehintp,
- ncio **nciopp, void **const igetvpp);
-
-extern int
-ncio_close(ncio *nciop, int doUnlink);
-
-#endif /* _NCIO_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx.h
deleted file mode 100644
index 97fbf75..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx.h
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* "$Id: ncx.h,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $" */
-
-#ifndef _NCX_H_
-#define _NCX_H_
-
-/*
- * An external data representation interface.
- *
- * This started out as a general replacement for ONC XDR,
- * specifically, the xdrmem family of functions.
- *
- * We eventually realized that we could write more portable
- * code if we decoupled any association between the 'C' types
- * and the external types. (XDR has this association between the 'C'
- * types and the external representations, like xdr_int() takes
- * an int argument and goes to an external int representation.)
- * So, now there is a matrix of functions.
- *
- */
-
-#include "ncconfig.h" /* output of 'configure' */
-#include "rnd.h"
-#include <stddef.h> /* size_t */
-#include <errno.h>
-#include <sys/types.h> /* off_t */
-
-#if defined(_CRAY) && !defined(_CRAYIEEE)
-#define CRAYFLOAT 1 /* CRAY Floating point */
-#elif defined(_SX) && defined(_FLOAT2) /* NEC SUPER-UX in CRAY mode */
-#define CRAYFLOAT 1 /* CRAY Floating point */
-#endif
-
-/*
- * The integer return code for the conversion routines
- * is 0 (ENOERR) when no error occured, or NC_ERANGE as appropriate
- * for an overflow conversion.
- */
-#ifndef ENOERR
-#define ENOERR 0
-#endif
-#ifndef NC_ERANGE
-#define NC_ERANGE (-60) /* N.B. must match value in netcdf.h */
-#endif
-
-
-/*
- * External sizes of the primitive elements.
- */
-#define X_SIZEOF_CHAR 1
-#define X_SIZEOF_SHORT 2
-#define X_SIZEOF_INT 4 /* xdr_int */
-#if 0
-#define X_SIZEOF_LONG 8 */ /* xdr_long_long */
-#endif
-#define X_SIZEOF_FLOAT 4
-#define X_SIZEOF_DOUBLE 8
-
-/*
- * For now, netcdf is limited to 32 bit offsets and sizes,
- * see also X_SIZE_MAX, X_OFF_MAX below
- */
-#define X_SIZEOF_OFF_T X_SIZEOF_INT
-#define X_SIZEOF_SIZE_T X_SIZEOF_INT
-
-/*
- * limits of the external representation
- */
-#define X_SCHAR_MIN (-128)
-#define X_SCHAR_MAX 127
-#define X_UCHAR_MAX 255U
-#define X_SHORT_MIN (-32768)
-#define X_SHRT_MIN X_SHORT_MIN /* alias compatible with limits.h */
-#define X_SHORT_MAX 32767
-#define X_SHRT_MAX X_SHORT_MAX /* alias compatible with limits.h */
-#define X_USHORT_MAX 65535U
-#define X_USHRT_MAX X_USHORT_MAX /* alias compatible with limits.h */
-#define X_INT_MIN (-2147483647-1)
-#define X_INT_MAX 2147483647
-#define X_UINT_MAX 4294967295U
-#if 0
-#define X_LONG_MIN (-2147483647-1)
-#define X_LONG_MAX 2147483647
-#define X_ULONG_MAX 4294967295U
-#endif
-#define X_FLOAT_MAX 3.40282347e+38f
-#define X_FLOAT_MIN (-X_FLOAT_MAX)
-#define X_FLT_MAX X_FLOAT_MAX /* alias compatible with limits.h */
-#if CRAYFLOAT
-/* ldexp(1. - ldexp(.5 , -46), 1024) */
-#define X_DOUBLE_MAX 1.79769313486230e+308
-#else
-/* scalb(1. - scalb(.5 , -52), 1024) */
-#define X_DOUBLE_MAX 1.7976931348623157e+308
-#endif
-#define X_DOUBLE_MIN (-X_DOUBLE_MAX)
-#define X_DBL_MAX X_DOUBLE_MAX /* alias compatible with limits.h */
-
-#define X_SIZE_MAX X_INT_MAX /* N.B., just uses the signed range */
-#define X_OFF_MAX X_INT_MAX
-
-
-/* Begin ncx_len */
-
-/*
- * ncx_len_xxx() interfaces are defined as macros below,
- * These give the length of an array of nelems of the type.
- * N.B. The 'char' and 'short' interfaces give the X_ALIGNED length.
- */
-#define X_ALIGN 4 /* a.k.a. BYTES_PER_XDR_UNIT */
-
-#define ncx_len_char(nelems) \
- _RNDUP((nelems), X_ALIGN)
-
-#define ncx_len_short(nelems) \
- (((nelems) + (nelems)%2) * X_SIZEOF_SHORT)
-
-#define ncx_len_int(nelems) \
- ((nelems) * X_SIZEOF_INT)
-
-#define ncx_len_long(nelems) \
- ((nelems) * X_SIZEOF_LONG)
-
-#define ncx_len_float(nelems) \
- ((nelems) * X_SIZEOF_FLOAT)
-
-#define ncx_len_double(nelems) \
- ((nelems) * X_SIZEOF_DOUBLE)
-
-/* End ncx_len */
-
-#if __CHAR_UNSIGNED__
- /* 'char' is unsigned, declare ncbyte as 'signed char' */
-typedef signed char schar;
-
-#else
- /* 'char' is signed */
-typedef signed char schar;
-
-#endif /* __CHAR_UNSIGNED__ */
-
-/*
- * Primitive numeric conversion functions.
- * The `put' functions convert from native internal
- * type to the external type, while the `get' functions
- * convert from the external to the internal.
- *
- * These take the form
- * int ncx_get_{external_type}_{internal_type}(
- * const void *xp,
- * internal_type *ip
- * );
- * int ncx_put_{external_type}_{internal_type}(
- * void *xp,
- * const internal_type *ip
- * );
- * where
- * `external_type' and `internal_type' chosen from
- schar
- uchar
- short
- ushort
- int
- uint
- long
- ulong
- float
- double
- *
- * Not all combinations make sense.
- * We may not implement all combinations that make sense.
- * The netcdf functions that use this ncx interface don't
- * use these primitive conversion functions. They use the
- * aggregate conversion functions declared below.
- *
- * Storage for a single element of external type is at the `void * xp'
- * argument.
- *
- * Storage for a single element of internal type is at `ip' argument.
- *
- * These functions return 0 (ENOERR) when no error occured,
- * or NC_ERANGE when the value being converted is too large.
- * When NC_ERANGE occurs, an undefined (implementation dependent)
- * conversion may have occured.
- *
- * Note that loss of precision may occur silently.
- *
- */
-
-#if 0
-extern int
-ncx_get_schar_schar(const void *xp, schar *ip);
-extern int
-ncx_get_schar_uchar(const void *xp, uchar *ip);
-extern int
-ncx_get_schar_short(const void *xp, short *ip);
-extern int
-ncx_get_schar_int(const void *xp, int *ip);
-extern int
-ncx_get_schar_long(const void *xp, long *ip);
-extern int
-ncx_get_schar_float(const void *xp, float *ip);
-extern int
-ncx_get_schar_double(const void *xp, double *ip);
-
-extern int
-ncx_put_schar_schar(void *xp, const schar *ip);
-extern int
-ncx_put_schar_uchar(void *xp, const uchar *ip);
-extern int
-ncx_put_schar_short(void *xp, const short *ip);
-extern int
-ncx_put_schar_int(void *xp, const int *ip);
-extern int
-ncx_put_schar_long(void *xp, const long *ip);
-extern int
-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
- * N.B. slightly different interface
- * Used by netcdf.
- */
-
-/* ncx_get_int_size_t */
-extern int
-ncx_get_size_t(const void **xpp, size_t *ulp);
-/* ncx_get_int_off_t */
-extern int
-ncx_get_off_t(const void **xpp, off_t *lp);
-
-/* ncx_put_int_size_t */
-extern int
-ncx_put_size_t(void **xpp, const size_t *ulp);
-/* ncx_put_int_off_t */
-extern int
-ncx_put_off_t(void **xpp, const off_t *lp);
-
-
-/*
- * Aggregate numeric conversion functions.
- * Convert an array. Replaces xdr_array(...).
- * These functions are used by netcdf. Unlike the xdr
- * interface, we optimize for aggregate conversions.
- * This functions should be implemented to take advantage
- * of multiple processor / parallel hardware where available.
- *
- * These take the form
- * int ncx_getn_{external_type}_{internal_type}(
- * const void *xpp,
- * size_t nelems,
- * internal_type *ip
- * );
- * int ncx_putn_{external_type}_{internal_type}(
- * void **xpp,
- * size_t nelems,
- * const internal_type *ip
- * );
- * Where the types are as in the primitive numeric conversion functions.
- *
- * The value of the pointer to pointer argument, *xpp, is
- * expected to reference storage for `nelems' of the external
- * type. On return, it modified to reference just past the last
- * converted external element.
- *
- * The types whose external size is less than X_ALIGN also have `pad'
- * interfaces. These round (and zero fill on put) *xpp up to X_ALIGN
- * boundaries. (This is the usual xdr behavior.)
- *
- * The `ip' argument should point to an array of `nelems' of
- * internal_type.
- *
- * Range errors (NC_ERANGE) for a individual values in the array
- * DO NOT terminate the array conversion. All elements are converted,
- * with some having undefined values.
- * If any range error occurs, the function returns NC_ERANGE.
- *
- */
-
-extern int
-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);
-extern int
-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);
-extern int
-ncx_getn_schar_long(const void **xpp, size_t nelems, long *ip);
-extern int
-ncx_getn_schar_float(const void **xpp, size_t nelems, float *ip);
-extern int
-ncx_getn_schar_double(const void **xpp, size_t nelems, double *ip);
-
-extern int
-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);
-extern int
-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);
-extern int
-ncx_pad_getn_schar_long(const void **xpp, size_t nelems, long *ip);
-extern int
-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_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);
-extern int
-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);
-extern int
-ncx_putn_schar_long(void **xpp, size_t nelems, const long *ip);
-extern int
-ncx_putn_schar_float(void **xpp, size_t nelems, const float *ip);
-extern int
-ncx_putn_schar_double(void **xpp, size_t nelems, const double *ip);
-
-extern int
-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);
-extern int
-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);
-extern int
-ncx_pad_putn_schar_long(void **xpp, size_t nelems, const long *ip);
-extern int
-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_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_int(const void **xpp, size_t nelems, int *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_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);
-extern int
-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);
-extern int
-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_double(const void **xpp, size_t nelems, double *ip);
-
-extern int
-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);
-extern int
-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);
-extern int
-ncx_putn_short_long(void **xpp, size_t nelems, const long *ip);
-extern int
-ncx_putn_short_float(void **xpp, size_t nelems, const float *ip);
-extern int
-ncx_putn_short_double(void **xpp, size_t nelems, const double *ip);
-
-extern int
-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);
-extern int
-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);
-extern int
-ncx_pad_putn_short_long(void **xpp, size_t nelems, const long *ip);
-extern int
-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_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_int(const void **xpp, size_t nelems, int *ip);
-extern int
-ncx_getn_int_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_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);
-extern int
-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);
-extern int
-ncx_putn_int_long(void **xpp, size_t nelems, const long *ip);
-extern int
-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_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_int(const void **xpp, size_t nelems, int *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_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);
-extern int
-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);
-extern int
-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_double(void **xpp, size_t nelems, const double *ip);
-
-
-extern int
-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);
-extern int
-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);
-extern int
-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_double(const void **xpp, size_t nelems, double *ip);
-
-extern int
-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);
-extern int
-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);
-extern int
-ncx_putn_double_long(void **xpp, size_t nelems, const long *ip);
-extern int
-ncx_putn_double_float(void **xpp, size_t nelems, const float *ip);
-extern int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *ip);
-
-
-/*
- * Other aggregate conversion functions.
- */
-
-/* read ASCII characters */
-extern int
-ncx_getn_text(const void **xpp, size_t nchars, char *cp);
-extern int
-ncx_pad_getn_text(const void **xpp, size_t nchars, char *cp);
-
-/* write ASCII characters */
-extern int
-ncx_putn_text(void **xpp, size_t nchars, const char *cp);
-extern int
-ncx_pad_putn_text(void **xpp, size_t nchars, const char *cp);
-
-/* for symmetry */
-#define ncx_getn_char_char(xpp, nelems, fillp) ncx_getn_text(xpp, nelems, fillp)
-#define ncx_putn_char_char(xpp, nelems, fillp) ncx_putn_text(xpp, nelems, fillp)
-
-/* read opaque data */
-extern int
-ncx_getn_void(const void **xpp, size_t nchars, void *vp);
-extern int
-ncx_pad_getn_void(const void **xpp, size_t nchars, void *vp);
-
-/* write opaque data */
-extern int
-ncx_putn_void(void **xpp, size_t nchars, const void *vp);
-extern int
-ncx_pad_putn_void(void **xpp, size_t nchars, const void *vp);
-
-#endif /* _NCX_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx.m4
deleted file mode 100644
index bbd54a4..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx.m4
+++ /dev/null
@@ -1,2654 +0,0 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-dnl If you see this line, you can ignore the next one.
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *
- * This file contains some routines derived from code
- * which is copyrighted by Sun Microsystems, Inc.
- * The "#ifdef vax" versions of
- * ncx_put_float_float()
- * ncx_get_float_float()
- * ncx_put_double_double()
- * ncx_get_double_double()
- * ncx_putn_float_float()
- * ncx_getn_float_float()
- * ncx_putn_double_double()
- * ncx_getn_double_double()
- * are derived from xdr_float() and xdr_double() routines
- * in the freely available, copyrighted Sun RPCSRC 3.9
- * distribution, xdr_float.c.
- * Our "value added" is that these are always memory to memory,
- * they handle IEEE subnormals properly, and their "n" versions
- * operate speedily on arrays.
- */
-/* $Id: ncx.m4,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $ */
-
-/*
- * An external data representation interface.
- */
-
-#include "ncx.h"
-#include <string.h>
-#include <limits.h>
-/* alias poorly named limits.h macros */
-#define SHORT_MAX SHRT_MAX
-#define SHORT_MIN SHRT_MIN
-#define USHORT_MAX USHRT_MAX
-#include <float.h>
-#ifndef FLT_MAX /* This POSIX macro missing on some systems */
-# ifndef NO_IEEE_FLOAT
-# define FLT_MAX 3.40282347e+38f
-# else
-# error "You will need to define FLT_MAX"
-# endif
-#endif
-#include <assert.h>
-
-/*
- * If the machine's float domain is "smaller" than the external one
- * use the machine domain
- */
-#if defined(FLT_MAX_EXP) && FLT_MAX_EXP < 128 /* 128 is X_FLT_MAX_EXP */
-#undef X_FLOAT_MAX
-# define X_FLOAT_MAX FLT_MAX
-#undef X_FLOAT_MIN
-# define X_FLOAT_MIN (-X_FLOAT_MAX)
-#endif
-
-#if _SX /* NEC SUPER UX */
-#if _INT64
-#undef INT_MAX /* workaround cpp bug */
-#define INT_MAX X_INT_MAX
-#undef INT_MIN /* workaround cpp bug */
-#define INT_MIN X_INT_MIN
-#undef LONG_MAX /* workaround cpp bug */
-#define LONG_MAX X_INT_MAX
-#undef LONG_MIN /* workaround cpp bug */
-#define LONG_MIN X_INT_MIN
-#elif _LONG64
-#undef LONG_MAX /* workaround cpp bug */
-#define LONG_MAX 4294967295L
-#undef LONG_MIN /* workaround cpp bug */
-#define LONG_MIN -4294967295L
-#endif
-#endif /* _SX */
-
-static const char nada[X_ALIGN] = {0, 0, 0, 0};
-
-#ifndef WORDS_BIGENDIAN
-/* LITTLE_ENDIAN: DEC and intel */
-/*
- * Routines to convert to BIGENDIAN.
- * Optimize the swapn?b() and swap?b() routines aggressivly.
- */
-
-#define SWAP2(a) ( (((a) & 0xff) << 8) | \
- (((a) >> 8) & 0xff) )
-
-#define SWAP4(a) ( ((a) << 24) | \
- (((a) << 8) & 0x00ff0000) | \
- (((a) >> 8) & 0x0000ff00) | \
- (((a) >> 24) & 0x000000ff) )
-
-static void
-swapn2b(void *dst, const void *src, size_t nn)
-{
- char *op = dst;
- const char *ip = src;
- while(nn-- != 0)
- {
- *op++ = *(++ip);
- *op++ = *(ip++ -1);
- }
-}
-
-# ifndef vax
-static void
-swap4b(void *dst, const void *src)
-{
- char *op = dst;
- const char *ip = src;
- op[0] = ip[3];
- op[1] = ip[2];
- op[2] = ip[1];
- op[3] = ip[0];
-}
-# endif /* !vax */
-
-static void
-swapn4b(void *dst, const void *src, size_t nn)
-{
- char *op = dst;
- const char *ip = src;
- while(nn-- != 0)
- {
- op[0] = ip[3];
- op[1] = ip[2];
- op[2] = ip[1];
- op[3] = ip[0];
- op += 4;
- ip += 4;
- }
-}
-
-# ifndef vax
-static void
-swap8b(void *dst, const void *src)
-{
- char *op = dst;
- const char *ip = src;
- op[0] = ip[7];
- op[1] = ip[6];
- op[2] = ip[5];
- op[3] = ip[4];
- op[4] = ip[3];
- op[5] = ip[2];
- op[6] = ip[1];
- op[7] = ip[0];
-}
-# endif /* !vax */
-
-# ifndef vax
-static void
-swapn8b(void *dst, const void *src, size_t nn)
-{
- char *op = dst;
- const char *ip = src;
- while(nn-- != 0)
- {
- op[0] = ip[7];
- op[1] = ip[6];
- op[2] = ip[5];
- op[3] = ip[4];
- op[4] = ip[3];
- op[5] = ip[2];
- op[6] = ip[1];
- op[7] = ip[0];
- op += 8;
- ip += 8;
- }
-}
-# endif /* !vax */
-
-#endif /* LITTLE_ENDIAN */
-
-
-/*
- * Primitive numeric conversion functions.
- */
-
-/* x_schar */
-
- /* We don't implement and x_schar primitives. */
-
-
-/* x_short */
-
-#if SHORT_MAX == X_SHORT_MAX
-typedef short ix_short;
-#define SIZEOF_IX_SHORT SIZEOF_SHORT
-#define IX_SHORT_MAX SHORT_MAX
-#elif INT_MAX >= X_SHORT_MAX
-typedef int ix_short;
-#define SIZEOF_IX_SHORT SIZEOF_INT
-#define IX_SHORT_MAX INT_MAX
-#elif LONG_MAX >= X_SHORT_MAX
-typedef long ix_short;
-#define SIZEOF_IX_SHORT SIZEOF_LONG
-#define IX_SHORT_MAX LONG_MAX
-#else
-#error "ix_short implementation"
-#endif
-
-static void
-get_ix_short(const void *xp, ix_short *ip)
-{
- 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;
-}
-
-static void
-put_ix_short(void *xp, const ix_short *ip)
-{
- uchar *cp = (uchar *) xp;
- *cp++ = (*ip) >> 8;
- *cp = (*ip) & 0xff;
-}
-
-
-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_long(const void *xp, 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_MAX >= X_SHORT_MAX); */
- ix_short xx;
- get_ix_short(xp, &xx);
- *ip = xx;
- 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
-ncx_put_short_schar(void *xp, const schar *ip)
-{
- uchar *cp = (uchar *) xp;
- if(*ip & 0x80)
- *cp++ = 0xff;
- else
- *cp++ = 0;
- *cp = (uchar)*ip;
- return ENOERR;
-}
-
-int
-ncx_put_short_uchar(void *xp, const uchar *ip)
-{
- uchar *cp = (uchar *) xp;
- *cp++ = 0;
- *cp = *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;
-#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;
-#endif
-}
-
-int
-ncx_put_short_int(void *xp, const int *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;
-#endif
-}
-
-int
-ncx_put_short_long(void *xp, const long *ip)
-{
-#if SIZEOF_IX_SHORT == SIZEOF_LONG && X_SHORT_MAX == 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_MAX
- if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
- return NC_ERANGE;
-# endif
- return ENOERR;
-#endif
-}
-
-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)
-{
- ix_short xx = *ip;
- put_ix_short(xp, &xx);
- 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
-#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);
-}
-
-
-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_long(const void *xp, long *ip)
-{
-#if SIZEOF_IX_INT == SIZEOF_LONG && IX_INT_MAX == LONG_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 > LONG_MAX /* unlikely */
- if(xx > LONG_MAX || xx < LONG_MIN)
- return NC_ERANGE;
-# endif
- return ENOERR;
-#endif
-}
-
-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
-ncx_put_int_schar(void *xp, const schar *ip)
-{
- uchar *cp = (uchar *) xp;
- if(*ip & 0x80)
- {
- *cp++ = 0xff;
- *cp++ = 0xff;
- *cp++ = 0xff;
- }
- else
- {
- *cp++ = 0x00;
- *cp++ = 0x00;
- *cp++ = 0x00;
- }
- *cp = (uchar)*ip;
- return ENOERR;
-}
-
-int
-ncx_put_int_uchar(void *xp, const uchar *ip)
-{
- uchar *cp = (uchar *) xp;
- *cp++ = 0x00;
- *cp++ = 0x00;
- *cp++ = 0x00;
- *cp = *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
-}
-
-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;
-#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;
-#endif
-}
-
-int
-ncx_put_int_long(void *xp, const 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 || *ip < X_INT_MIN)
- return NC_ERANGE;
-# endif
- return ENOERR;
-#endif
-}
-
-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;
-}
-
-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_float */
-
-#if X_SIZEOF_FLOAT == SIZEOF_FLOAT && !defined(NO_IEEE_FLOAT)
-
-static void
-get_ix_float(const void *xp, float *ip)
-{
-#ifdef WORDS_BIGENDIAN
- (void) memcpy(ip, xp, sizeof(float));
-#else
- swap4b(ip, xp);
-#endif
-}
-
-static void
-put_ix_float(void *xp, const float *ip)
-{
-#ifdef WORDS_BIGENDIAN
- (void) memcpy(xp, ip, X_SIZEOF_FLOAT);
-#else
- swap4b(xp, ip);
-#endif
-}
-
-#elif vax
-
-/* What IEEE single precision floating point looks like on a Vax */
-struct ieee_single {
- unsigned int exp_hi : 7;
- unsigned int sign : 1;
- unsigned int mant_hi : 7;
- unsigned int exp_lo : 1;
- unsigned int mant_lo_hi : 8;
- unsigned int mant_lo_lo : 8;
-};
-
-/* Vax single precision floating point */
-struct vax_single {
- unsigned int mantissa1 : 7;
- unsigned int exp : 8;
- unsigned int sign : 1;
- unsigned int mantissa2 : 16;
-};
-
-#define VAX_SNG_BIAS 0x81
-#define IEEE_SNG_BIAS 0x7f
-
-static struct sgl_limits {
- struct vax_single s;
- struct ieee_single ieee;
-} max = {
- { 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */
- { 0x7f, 0x0, 0x0, 0x1, 0x0, 0x0 } /* Max IEEE */
-};
-static struct sgl_limits min = {
- { 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */
- { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } /* Min IEEE */
-};
-
-dnl dnl dnl
-dnl
-dnl GET_VAX_DFLOAT_Body(xp) (body for get_ix_float)
-dnl
-define(`GET_VAX_DFLOAT_Body',dnl
-`dnl
- struct vax_single *const vsp = (struct vax_single *) ip;
- const struct ieee_single *const isp =
- (const struct ieee_single *) $1;
- 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;
- }
-
- vsp->sign = isp->sign;
-')dnl
-static void
-get_ix_float(const void *xp, float *ip)
-{
-GET_VAX_DFLOAT_Body(xp)
-}
-
-dnl dnl dnl
-dnl
-dnl PUT_VAX_DFLOAT_Body(xp) (body for get_ix_float)
-dnl
-define(`PUT_VAX_DFLOAT_Body',dnl
-`dnl
- const struct vax_single *const vsp =
- (const struct vax_single *)ip;
- struct ieee_single *const isp = (struct ieee_single *) $1;
-
- 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;
-')dnl
-
-static void
-put_ix_float(void *xp, const float *ip)
-{
-PUT_VAX_DFLOAT_Body(xp)
-}
-
- /* vax */
-#elif defined(_CRAY)
-
-/*
- * Return the number of bytes until the next "word" boundary
- * N.B. This is based on the very wierd YMP address structure,
- * which puts the address within a word in the leftmost 3 bits
- * of the address.
- */
-static size_t
-word_align(const void *vp)
-{
- const size_t rem = ((size_t)vp >> (64 - 3)) & 0x7;
- return (rem != 0);
-}
-
-struct ieee_single_hi {
- unsigned int sign : 1;
- unsigned int exp : 8;
- unsigned int mant :23;
- unsigned int pad :32;
-};
-typedef struct ieee_single_hi ieee_single_hi;
-
-struct ieee_single_lo {
- unsigned int pad :32;
- unsigned int sign : 1;
- unsigned int exp : 8;
- unsigned int mant :23;
-};
-typedef struct ieee_single_lo ieee_single_lo;
-
-static const int ieee_single_bias = 0x7f;
-
-struct ieee_double {
- unsigned int sign : 1;
- unsigned int exp :11;
- unsigned int mant :52;
-};
-typedef struct ieee_double ieee_double;
-
-static const int ieee_double_bias = 0x3ff;
-
-#if defined(NO_IEEE_FLOAT)
-
-struct cray_single {
- unsigned int sign : 1;
- unsigned int exp :15;
- unsigned int mant :48;
-};
-typedef struct cray_single cray_single;
-
-static const int cs_ieis_bias = 0x4000 - 0x7f;
-
-static const int cs_id_bias = 0x4000 - 0x3ff;
-
-dnl dnl dnl
-dnl
-dnl GET_IX_FLOAT_Body (body for get_ix_float)
-dnl
-define(`GET_IX_FLOAT_Body',dnl
-`dnl
- cray_single *csp = (cray_single *) ip;
-
- if(isp->exp == 0)
- {
- /* ieee subnormal */
- *ip = (double)isp->mant;
- if(isp->mant != 0)
- {
- csp->exp -= (ieee_single_bias + 22);
- }
- }
- else
- {
- csp->exp = isp->exp + cs_ieis_bias + 1;
- csp->mant = isp->mant << (48 - 1 - 23);
- csp->mant |= (1 << (48 - 1));
- }
- csp->sign = isp->sign;
-
-')dnl
-dnl dnl dnl
-dnl
-dnl PUT_IX_FLOAT_Body (body for put_ix_float)
-dnl
-define(`PUT_IX_FLOAT_Body',dnl
-`dnl
- const cray_single *csp = (const cray_single *) ip;
- int ieee_exp = csp->exp - cs_ieis_bias -1;
-
- isp->sign = csp->sign;
-
- if(ieee_exp >= 0xff)
- {
- /* NC_ERANGE => ieee Inf */
- isp->exp = 0xff;
- isp->mant = 0x0;
- }
- else if(ieee_exp > 0)
- {
- /* normal ieee representation */
- isp->exp = ieee_exp;
- /* assumes cray rep is in normal form */
- assert(csp->mant & 0x800000000000);
- isp->mant = (((csp->mant << 1) &
- 0xffffffffffff) >> (48 - 23));
- }
- else if(ieee_exp > -23)
- {
- /* ieee subnormal, right shift */
- const int rshift = (48 - 23 - ieee_exp);
-
- isp->mant = csp->mant >> rshift;
-
-#if 0
- if(csp->mant & (1 << (rshift -1)))
- {
- /* round up */
- isp->mant++;
- }
-#endif
-
- isp->exp = 0;
- }
- else
- {
- /* smaller than ieee can represent */
- isp->exp = 0;
- isp->mant = 0;
- }
-')dnl
-
-static void
-get_ix_float(const void *xp, float *ip)
-{
-
- if(word_align(xp) == 0)
- {
- const ieee_single_hi *isp = (const ieee_single_hi *) xp;
-GET_IX_FLOAT_Body
- }
- else
- {
- const ieee_single_lo *isp = (const ieee_single_lo *) xp;
-GET_IX_FLOAT_Body
- }
-}
-
-static void
-put_ix_float(void *xp, const float *ip)
-{
- if(word_align(xp) == 0)
- {
- ieee_single_hi *isp = (ieee_single_hi*)xp;
-PUT_IX_FLOAT_Body
- }
- else
- {
- ieee_single_lo *isp = (ieee_single_lo*)xp;
-PUT_IX_FLOAT_Body
- }
-}
-
-#else
- /* IEEE Cray with only doubles */
-static void
-get_ix_float(const void *xp, float *ip)
-{
-
- ieee_double *idp = (ieee_double *) ip;
-
- if(word_align(xp) == 0)
- {
- const ieee_single_hi *isp = (const ieee_single_hi *) 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;
- }
- 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
-
-#elif _SX && _FLOAT2
-static void
-get_ix_float(const void *xp, float *ip)
-{
- const int ncnv = ie3_fl2(xp, ip, 4, 8, 1);
-}
-
-static void
-put_ix_float(void *xp, const float *ip)
-{
- const int ncnv = fl2_ie3(ip, xp, 8, 4, 1);
-}
-#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_long(const void *xp, long *ip)
-{
- float xx;
- get_ix_float(xp, &xx);
- *ip = (long) xx;
- if(xx > LONG_MAX || xx < LONG_MIN)
- 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;
-}
-
-int
-ncx_put_float_uchar(void *xp, const uchar *ip)
-{
- float xx = (float) *ip;
- put_ix_float(xp, &xx);
- return ENOERR;
-}
-
-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;
-#endif
- return ENOERR;
-}
-
-int
-ncx_put_float_long(void *xp, const long *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_float(void *xp, const float *ip)
-{
- put_ix_float(xp, ip);
-#ifdef NO_IEEE_FLOAT
- if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
- return NC_ERANGE;
-#endif
- return ENOERR;
-}
-
-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;
-}
-
-/* x_double */
-
-#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
-
-static void
-get_ix_double(const void *xp, double *ip)
-{
-#ifdef WORDS_BIGENDIAN
- (void) memcpy(ip, xp, sizeof(double));
-#else
- swap8b(ip, xp);
-#endif
-}
-
-static void
-put_ix_double(void *xp, const double *ip)
-{
-#ifdef WORDS_BIGENDIAN
- (void) memcpy(xp, ip, X_SIZEOF_DOUBLE);
-#else
- swap8b(xp, ip);
-#endif
-}
-
-#elif vax
-
-/* What IEEE double precision floating point looks like on a Vax */
-struct ieee_double {
- unsigned int exp_hi : 7;
- unsigned int sign : 1;
- unsigned int mant_6 : 4;
- unsigned int exp_lo : 4;
- unsigned int mant_5 : 8;
- unsigned int mant_4 : 8;
-
- unsigned int mant_lo : 32;
-};
-
-/* Vax double precision floating point */
-struct vax_double {
- unsigned int mantissa1 : 7;
- unsigned int exp : 8;
- unsigned int sign : 1;
- unsigned int mantissa2 : 16;
- unsigned int mantissa3 : 16;
- unsigned int mantissa4 : 16;
-};
-
-#define VAX_DBL_BIAS 0x81
-#define IEEE_DBL_BIAS 0x3ff
-#define MASK(nbits) ((1 << nbits) - 1)
-
-static const struct dbl_limits {
- struct vax_double d;
- struct ieee_double ieee;
-} dbl_limits[2] = {
- {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */
- { 0x7f, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0}}, /* Max IEEE */
- {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
- { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, /* Min IEEE */
-};
-
-
-dnl dnl dnl
-dnl
-dnl GET_VAX_DDOUBLE_Body(xp) (body for get_ix_double)
-dnl
-define(`GET_VAX_DDOUBLE_Body',dnl
-`dnl
- struct vax_double *const vdp =
- (struct vax_double *)ip;
- const struct ieee_double *const idp =
- (const struct ieee_double *) $1;
- {
- 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;
-')dnl
-static void
-get_ix_double(const void *xp, double *ip)
-{
-GET_VAX_DDOUBLE_Body(xp)
-}
-
-
-dnl dnl dnl
-dnl
-dnl PUT_VAX_DDOUBLE_Body(xp) (body for put_ix_double)
-dnl
-define(`PUT_VAX_DDOUBLE_Body',dnl
-`dnl
- const struct vax_double *const vdp =
- (const struct vax_double *)ip;
- struct ieee_double *const idp =
- (struct ieee_double *) $1;
-
- 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;
-')dnl
-static void
-put_ix_double(void *xp, const double *ip)
-{
-PUT_VAX_DDOUBLE_Body(xp)
-}
-
- /* vax */
-#elif defined(_CRAY)
-
-static void
-get_ix_double(const void *xp, double *ip)
-{
- const ieee_double *idp = (const ieee_double *) xp;
- cray_single *csp = (cray_single *) ip;
-
- if(idp->exp == 0)
- {
- /* ieee subnormal */
- *ip = (double)idp->mant;
- if(idp->mant != 0)
- {
- csp->exp -= (ieee_double_bias + 51);
- }
- }
- else
- {
- csp->exp = idp->exp + cs_id_bias + 1;
- csp->mant = idp->mant >> (52 - 48 + 1);
- csp->mant |= (1 << (48 - 1));
- }
- csp->sign = idp->sign;
-}
-
-static void
-put_ix_double(void *xp, const double *ip)
-{
- ieee_double *idp = (ieee_double *) xp;
- const cray_single *csp = (const cray_single *) ip;
-
- int ieee_exp = csp->exp - cs_id_bias -1;
-
- idp->sign = csp->sign;
-
- if(ieee_exp >= 0x7ff)
- {
- /* NC_ERANGE => ieee Inf */
- idp->exp = 0x7ff;
- idp->mant = 0x0;
- }
- else if(ieee_exp > 0)
- {
- /* normal ieee representation */
- idp->exp = ieee_exp;
- /* assumes cray rep is in normal form */
- assert(csp->mant & 0x800000000000);
- idp->mant = (((csp->mant << 1) &
- 0xffffffffffff) << (52 - 48));
- }
- else if(ieee_exp >= (-(52 -48)))
- {
- /* ieee subnormal, left shift */
- const int lshift = (52 - 48) + ieee_exp;
- idp->mant = csp->mant << lshift;
- idp->exp = 0;
- }
- else if(ieee_exp >= -52)
- {
- /* ieee subnormal, right shift */
- const int rshift = (- (52 - 48) - ieee_exp);
-
- idp->mant = csp->mant >> rshift;
-
-#if 0
- if(csp->mant & (1 << (rshift -1)))
- {
- /* round up */
- idp->mant++;
- }
-#endif
-
- idp->exp = 0;
- }
- else
- {
- /* smaller than ieee can represent */
- idp->exp = 0;
- idp->mant = 0;
- }
-}
-#elif _SX && _FLOAT2
-static void
-get_ix_double(const void *xp, double *ip)
-{
- const int ncnv = ie3_fl2(xp, ip, 8, 8, 1);
-}
-
-static void
-put_ix_double(void *xp, const double *ip)
-{
- const int ncnv = fl2_ie3(ip, xp, 8, 8, 1);
-}
-#else
-#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_long(const void *xp, long *ip)
-{
- double xx;
- get_ix_double(xp, &xx);
- *ip = (long) xx;
- if(xx > LONG_MAX || xx < LONG_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_get_double_float(const void *xp, float *ip)
-{
- double xx;
- get_ix_double(xp, &xx);
- if(xx > FLT_MAX || xx < (-FLT_MAX))
- {
- *ip = FLT_MAX;
- return NC_ERANGE;
- }
- if(xx < (-FLT_MAX))
- {
- *ip = (-FLT_MAX);
- return NC_ERANGE;
- }
- *ip = (float) xx;
- return ENOERR;
-}
-
-int
-ncx_get_double_double(const void *xp, double *ip)
-{
- /* TODO */
- get_ix_double(xp, ip);
- return ENOERR;
-}
-
-
-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)
-{
- 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)
- return NC_ERANGE;
-#endif
- return ENOERR;
-}
-
-int
-ncx_put_double_int(void *xp, const int *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)
- return NC_ERANGE;
-#endif
- return ENOERR;
-}
-
-int
-ncx_put_double_long(void *xp, const long *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;
-#endif
- return ENOERR;
-}
-
-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;
-#endif
- return ENOERR;
-}
-
-int
-ncx_put_double_double(void *xp, const double *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;
-}
-
-
-/* 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^31 -1 */
-#endif
-
-int
-ncx_put_size_t(void **xpp, const size_t *ulp)
-{
- /* similar to put_ix_int() */
- uchar *cp = (uchar *) *xpp;
- /* sizes limited to 2^31 -1 in netcdf */
- assert(*ulp <= X_SIZE_MAX && (long) (*ulp) >= 0);
-
- *cp++ = (uchar)((*ulp) >> 24);
- *cp++ = (uchar)(((*ulp) & 0x00ff0000) >> 16);
- *cp++ = (uchar)(((*ulp) & 0x0000ff00) >> 8);
- *cp = (uchar)((*ulp) & 0x000000ff);
-
- *xpp = (void *)((char *)(*xpp) + X_SIZEOF_SIZE_T);
- return ENOERR;
-}
-
-int
-ncx_get_size_t(const void **xpp, size_t *ulp)
-{
- /* similar to get_ix_int */
- const uchar *cp = (const uchar *) *xpp;
- assert((*cp & 0x80) == 0); /* sizes limited to 2^31 -1 in netcdf */
-
- *ulp = *cp++ << 24;
- *ulp |= (*cp++ << 16);
- *ulp |= (*cp++ << 8);
- *ulp |= *cp;
-
- *xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_SIZE_T);
- return ENOERR;
-}
-
-/* x_off_t */
-
-#if SIZEOF_OFF_T < X_SIZEOF_OFF_T
-#error "x_off_t implementation"
-/* netcdf requires size_t which can hold a values from 0 to 2^31 -1 */
-#endif
-
-int
-ncx_put_off_t(void **xpp, const off_t *lp)
-{
- /* similar to put_ix_int() */
- uchar *cp = (uchar *) *xpp;
- /* No negative offsets stored in netcdf */
- assert(*lp >= 0 && *lp <= X_OFF_MAX);
-
- *cp++ = (uchar)((*lp) >> 24);
- *cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
- *cp++ = (uchar)(((*lp) & 0x0000ff00) >> 8);
- *cp = (uchar)((*lp) & 0x000000ff);
-
- *xpp = (void *)((char *)(*xpp) + X_SIZEOF_OFF_T);
- return ENOERR;
-}
-
-int
-ncx_get_off_t(const void **xpp, off_t *lp)
-{
- /* similar to get_ix_int() */
- const uchar *cp = (const uchar *) *xpp;
- assert((*cp & 0x80) == 0); /* No negative offsets stored in netcdf */
-
- *lp = *cp++ << 24;
- *lp |= (*cp++ << 16);
- *lp |= (*cp++ << 8);
- *lp |= *cp;
-
- *xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_OFF_T);
- return ENOERR;
-}
-
-
-/*
- * 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 Xsizeof(Xtype)
-dnl
-define(`Xsizeof', ``X_SIZEOF_'Upcase($1)')dnl
-dnl
-dnl dnl dnl
-dnl
-dnl NCX_GETN_Byte_Body (body for one byte types on diagonal)
-dnl
-define(`NCX_GETN_Byte_Body',dnl
-`dnl
- (void) memcpy(tp, *xpp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
- return ENOERR;
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PAD_GETN_Byte_body (body for one byte types on diagonal)
-dnl
-define(`NCX_PAD_GETN_Byte_Body',dnl
-`dnl
- 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;
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_GETN_SCHAR(Type)
-dnl
-define(`NCX_GETN_SCHAR',dnl
-`dnl
-int
-ncx_getn_schar_$1(const void **xpp, size_t nelems, $1 *tp)
-{
- schar *xp = (schar *)(*xpp);
-
- while(nelems-- != 0)
- {
- *tp++ = *xp++;
- }
-
- *xpp = (const void *)xp;
- return ENOERR;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PAD_GETN_SCHAR(Type)
-dnl
-define(`NCX_PAD_GETN_SCHAR',dnl
-`dnl
-int
-ncx_pad_getn_schar_$1(const void **xpp, size_t nelems, $1 *tp)
-{
- 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 ENOERR;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_GETNo(XType, Type) deprecated
-dnl
-define(`NCX_GETNo',dnl
-`dnl
-int
-ncx_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
-{
- const char *xp = (const char *) *xpp;
- int status = ENOERR;
- $1 xx;
-
- for( ; nelems != 0; nelems--, xp += Xsizeof($1), tp++)
- {
- const int lstatus = ncx_get_$1_$1(xp, &xx);
- *tp = ($2)xx;
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_GETN(XType, Type)
-dnl
-define(`NCX_GETN',dnl
-`dnl
-int
-ncx_getn_$1_$2(const void **xpp, size_t nelems, $2 *tp)
-{
- const char *xp = (const char *) *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += Xsizeof($1), tp++)
- {
- const int lstatus = ncx_get_$1_$2(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PAD_GETN_SHORT( Type)
-dnl
-define(`NCX_PAD_GETN_SHORT',dnl
-`dnl
-int
-ncx_pad_getn_short_$1(const void **xpp, size_t nelems, $1 *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_$1(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- if(rndup != 0)
- xp += X_SIZEOF_SHORT;
-
- *xpp = (void *)xp;
- return status;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PUTN_Byte_Body(Type) (body for one byte types)
-dnl
-define(`NCX_PUTN_Byte_Body',dnl
-`dnl
- (void) memcpy(*xpp, tp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
-
- return ENOERR;
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PAD_PUTN_Byte_Body(Type) (body for one byte types)
-dnl
-define(`NCX_PAD_PUTN_Byte_Body',dnl
- 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;
-`dnl
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PUTN_SCHAR(Type)
-dnl
-define(`NCX_PUTN_SCHAR',dnl
-`dnl
-int
-ncx_putn_schar_$1(void **xpp, size_t nelems, const $1 *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;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PAD_PUTN_SCHAR(Type)
-dnl
-define(`NCX_PAD_PUTN_SCHAR',dnl
-`dnl
-int
-ncx_pad_putn_schar_$1(void **xpp, size_t nelems, const $1 *tp)
-{
- int status = ENOERR;
- size_t rndup = nelems % X_ALIGN;
- schar *xp = (schar *) *xpp;
-
- if(rndup)
- rndup = X_ALIGN - rndup;
-
- while(nelems-- != 0)
- {
- /* N.B. schar as signed */
- 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;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PUTNo(XType, Type) deprecated
-dnl
-define(`NCX_PUTNo',dnl
-`dnl
-int
-ncx_putn_$1_$2(void **xpp, size_t nelems, const $2 *tp)
-{
- char *xp = (char *) *xpp;
- int status = ENOERR;
- $1 xx;
-
- for( ; nelems != 0; nelems--, xp += Xsizeof($1), tp++)
- {
- xx = ($1) *tp;
- {
- int lstatus = ncx_put_$1_$1(xp, &xx);
- if(lstatus != ENOERR)
- status = lstatus;
- }
- }
-
- *xpp = (void *)xp;
- return status;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PUTN(XType, Type)
-dnl
-define(`NCX_PUTN',dnl
-`dnl
-int
-ncx_putn_$1_$2(void **xpp, size_t nelems, const $2 *tp)
-{
- char *xp = (char *) *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += Xsizeof($1), tp++)
- {
- int lstatus = ncx_put_$1_$2(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl NCX_PAD_PUTN_SHORT(Type)
-dnl
-define(`NCX_PAD_PUTN_SHORT',dnl
-`dnl
-int
-ncx_pad_putn_short_$1(void **xpp, size_t nelems, const $1 *tp)
-{
- const size_t rndup = nelems % 2;
-
- char *xp = (char *) *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += Xsizeof(short), tp++)
- {
- int lstatus = ncx_put_short_$1(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;
-}
-')dnl
-
-
-dnl dnl dnl
-dnl
-dnl Declare & define routines
-dnl
-dnl dnl dnl
-
-/* schar */
-
-dnl NCX_GETN_SCHAR(schar)
-int
-ncx_getn_schar_schar(const void **xpp, size_t nelems, schar *tp)
-{
- NCX_GETN_Byte_Body
-}
-dnl NCX_GETN_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(long)
-NCX_GETN_SCHAR(float)
-NCX_GETN_SCHAR(double)
-
-dnl NCX_PAD_GETN_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)
-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(long)
-NCX_PAD_GETN_SCHAR(float)
-NCX_PAD_GETN_SCHAR(double)
-
-dnl NCX_PUTN_SCHAR(schar)
-int
-ncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp)
-{
- NCX_PUTN_Byte_Body
-}
-dnl NCX_PUTN_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(long)
-NCX_PUTN_SCHAR(float)
-NCX_PUTN_SCHAR(double)
-
-dnl NCX_PAD_PUTN_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)
-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(long)
-NCX_PAD_PUTN_SCHAR(float)
-NCX_PAD_PUTN_SCHAR(double)
-
-
-/* short */
-
-NCX_GETN(short, schar)
-NCX_GETN(short, uchar)
-#if X_SIZEOF_SHORT == SIZEOF_SHORT
-/* optimized version */
-int
-ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
-{
-# if 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
-NCX_GETN(short, short)
-#endif
-NCX_GETN(short, int)
-NCX_GETN(short, long)
-NCX_GETN(short, float)
-NCX_GETN(short, double)
-
-NCX_PAD_GETN_SHORT(schar)
-NCX_PAD_GETN_SHORT(uchar)
-NCX_PAD_GETN_SHORT(short)
-NCX_PAD_GETN_SHORT(int)
-NCX_PAD_GETN_SHORT(long)
-NCX_PAD_GETN_SHORT(float)
-NCX_PAD_GETN_SHORT(double)
-
-NCX_PUTN(short, schar)
-NCX_PUTN(short, uchar)
-#if X_SIZEOF_SHORT == SIZEOF_SHORT
-/* optimized version */
-int
-ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
-{
-# if 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
-NCX_PUTN(short, short)
-#endif
-NCX_PUTN(short, int)
-NCX_PUTN(short, long)
-NCX_PUTN(short, float)
-NCX_PUTN(short, double)
-
-NCX_PAD_PUTN_SHORT(schar)
-NCX_PAD_PUTN_SHORT(uchar)
-NCX_PAD_PUTN_SHORT(short)
-NCX_PAD_PUTN_SHORT(int)
-NCX_PAD_PUTN_SHORT(long)
-NCX_PAD_PUTN_SHORT(float)
-NCX_PAD_PUTN_SHORT(double)
-
-
-/* int */
-
-NCX_GETN(int, schar)
-NCX_GETN(int, uchar)
-NCX_GETN(int, short)
-#if X_SIZEOF_INT == SIZEOF_INT
-/* optimized version */
-int
-ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
-{
-# if 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
-NCX_GETN(int, int)
-#endif
-#if X_SIZEOF_INT == SIZEOF_LONG
-/* optimized version */
-int
-ncx_getn_int_long(const void **xpp, size_t nelems, long *tp)
-{
-# if WORDS_BIGENDIAN
- (void) memcpy(tp, *xpp, nelems * sizeof(long));
-# else
- swapn4b(tp, *xpp, nelems);
-# endif
- *xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_INT);
- return ENOERR;
-}
-#else
-NCX_GETN(int, long)
-#endif
-NCX_GETN(int, float)
-NCX_GETN(int, double)
-
-NCX_PUTN(int, schar)
-NCX_PUTN(int, uchar)
-NCX_PUTN(int, short)
-#if X_SIZEOF_INT == SIZEOF_INT
-/* optimized version */
-int
-ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
-{
-# if 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
-NCX_PUTN(int, int)
-#endif
-#if X_SIZEOF_INT == SIZEOF_LONG
-/* optimized version */
-int
-ncx_putn_int_long(void **xpp, size_t nelems, const long *tp)
-{
-# if 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
-NCX_PUTN(int, long)
-#endif
-NCX_PUTN(int, float)
-NCX_PUTN(int, double)
-
-
-/* float */
-
-NCX_GETN(float, schar)
-NCX_GETN(float, uchar)
-NCX_GETN(float, short)
-NCX_GETN(float, int)
-NCX_GETN(float, long)
-#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)
-{
-# if 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)
- {
-GET_VAX_DFLOAT_Body(`(*xpp)')
-
- ip++;
- *xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
- }
- return ENOERR;
-}
-#elif _SX && _FLOAT2
-int
-ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
-{
- const char *const xp = *xpp;
-
- const int ncnv = ie3_fl2(xp, tp, 4, 8, nelems);
-
- *xpp = xp + nelems * X_SIZEOF_FLOAT;
- return (nelems == ncnv ? ENOERR : NC_ERANGE);
-}
-#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++)
- {
- const int lstatus = ncx_get_float_float(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-#endif
-NCX_GETN(float, double)
-
-NCX_PUTN(float, schar)
-NCX_PUTN(float, uchar)
-NCX_PUTN(float, short)
-NCX_PUTN(float, int)
-NCX_PUTN(float, long)
-#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)
-{
-# if 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)
- {
-PUT_VAX_DFLOAT_Body(`(*xpp)')
-
- ip++;
- *xpp = (char *)(*xpp) + X_SIZEOF_FLOAT;
- }
- return ENOERR;
-}
-#elif _SX && _FLOAT2
-int
-ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
-{
- char *const xp = *xpp;
-
- const int ncnv = fl2_ie3(tp, xp, 8, 4, nelems);
-
- *xpp = xp + nelems * X_SIZEOF_FLOAT;
- return (nelems == ncnv ? ENOERR : NC_ERANGE);
-}
-#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
-NCX_PUTN(float, double)
-
-
-/* double */
-
-NCX_GETN(double, schar)
-NCX_GETN(double, uchar)
-NCX_GETN(double, short)
-NCX_GETN(double, int)
-NCX_GETN(double, long)
-NCX_GETN(double, float)
-dnl NCX_GETN(double, 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)
-{
-# if 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)
- {
-GET_VAX_DDOUBLE_Body(`(*xpp)')
- ip++;
- *xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
- }
- return ENOERR;
-}
- /* vax */
-#elif _SX && _FLOAT2
-int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
-{
- const char *const xp = *xpp;
-
- const int ncnv = ie3_fl2(xp, tp, 8, 8, nelems);
-
- *xpp = xp + nelems * X_SIZEOF_DOUBLE;
- return (nelems == ncnv ? ENOERR : NC_ERANGE);
-}
-#else
-int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_double(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-#endif
-
-NCX_PUTN(double, schar)
-NCX_PUTN(double, uchar)
-NCX_PUTN(double, short)
-NCX_PUTN(double, int)
-NCX_PUTN(double, long)
-NCX_PUTN(double, float)
-dnl NCX_PUTN(double, double)
-#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)
-{
-# if 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)
-{
- const double *const end = ip + ndoubles;
-
- while(ip < end)
- {
-PUT_VAX_DDOUBLE_Body(`(*xpp)')
- ip++;
- *xpp = (char *)(*xpp) + X_SIZEOF_DOUBLE;
- }
- return ENOERR;
-}
- /* vax */
-#elif _SX && _FLOAT2
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
- char *const xp = *xpp;
-
- const int ncnv = fl2_ie3(tp, xp, 8, 8, nelems);
-
- *xpp = xp + nelems * X_SIZEOF_DOUBLE;
- return (nelems == ncnv ? ENOERR : NC_ERANGE);
-}
-#else
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
- 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
-
-
-/*
- * Other aggregate conversion functions.
- */
-
-/* text */
-
-int
-ncx_getn_text(const void **xpp, size_t nelems, char *tp)
-{
-NCX_GETN_Byte_Body
-}
-
-int
-ncx_pad_getn_text(const void **xpp, size_t nelems, char *tp)
-{
-NCX_PAD_GETN_Byte_Body
-}
-
-int
-ncx_putn_text(void **xpp, size_t nelems, const char *tp)
-{
-NCX_PUTN_Byte_Body
-}
-
-int
-ncx_pad_putn_text(void **xpp, size_t nelems, const char *tp)
-{
-NCX_PAD_PUTN_Byte_Body
-}
-
-
-/* opaque */
-
-int
-ncx_getn_void(const void **xpp, size_t nelems, void *tp)
-{
-NCX_GETN_Byte_Body
-}
-
-int
-ncx_pad_getn_void(const void **xpp, size_t nelems, void *tp)
-{
-NCX_PAD_GETN_Byte_Body
-}
-
-int
-ncx_putn_void(void **xpp, size_t nelems, const void *tp)
-{
-NCX_PUTN_Byte_Body
-}
-
-int
-ncx_pad_putn_void(void **xpp, size_t nelems, const void *tp)
-{
-NCX_PAD_PUTN_Byte_Body
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx_cray.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx_cray.c
deleted file mode 100644
index d8ef348..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/ncx_cray.c
+++ /dev/null
@@ -1,3820 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- *
- */
-/* $Id: ncx_cray.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $ */
-#ifndef _CRAY
-#error "ncx_cray.c is a cray specific implementation"
-#endif
-
-/*
- * An external data representation interface.
- */
-/*
- * TODO: Fix "off diagonal" functions (ncx_{put,get}[n]_t1_t2() s.t. t1 != t2)
- * to be use IEG functions when diagonals are.
- *
- * Whine to cray about IEG function limiting behavior.
- */
-
-#include <string.h>
-#include <limits.h>
-/* alias poorly named limits.h macros */
-#define SHORT_MAX SHRT_MAX
-#define SHORT_MIN SHRT_MIN
-#define USHORT_MAX USHRT_MAX
-#include <float.h>
-#include <assert.h>
-#include "ncx.h"
-
-/**/
-#if USE_IEG
-#define C_SIZE_T size_t
-
-extern int
-CRAY2IEG(
- const int *typep,
- const C_SIZE_T *nump,
- word *foreignp,
- const int *bitoffp,
- const void *local,
- const int *stride
-);
-
-extern int
-IEG2CRAY(
- const int *typep,
- const C_SIZE_T *nump,
- const word *foreignp,
- const int *bitoffp,
- void *local,
- const int *stride
-);
-
-
-static const int Zero = 0;
-static const C_SIZE_T One = 1;
-static const int ThirtyTwo = 32;
-static const int UnitStride = 1;
-static const int Cray2_I32 = 1; /* 32 bit two complement */
-static const int Cray2_F32 = 2; /* IEEE single precision */
-static const int Cray2_I16 = 7; /* 16 bit twos complement */
-static const int Cray2_F64 = 8; /* CRAY float to IEEE double */
-
-#define SHORT_USE_IEG 1
-#define INT_USE_IEG 1
-#define FLOAT_USE_IEG 1
-#define DOUBLE_USE_IEG 1
-
-#if _CRAY1
-/*
- * Return the number of bits "into" a word that (void *) is.
- * N.B. This is based on the CRAY1 (PVP) address structure,
- * which puts the address within a word in the leftmost 3 bits
- * of the address.
- */
-static size_t
-bitoff(const void *vp)
-{
- const size_t bitoffset = ((size_t)vp >> (64 - 6)) & 0x3f;
- return bitoffset;
-}
-# else
-#error "Don't use IEG2CRAY, CRAY2IEG except on CRAY1 (MPP) platforms"
-#define bitoff(vp) ((size_t)(vp) % 64) /* N.B. Assumes 64 bit word */
-# endif /* _CRAY1 */
-
-#endif /* USE_IEG */
-
-#if _CRAY1
-/*
- * Return the number of bytes "into" a word that (void *) is.
- * N.B. This is based on the CRAY1 (PVP) address structure,
- * which puts the address within a word in the leftmost 3 bits
- * of the address.
- */
-static size_t
-byteoff(const void *vp)
-{
- const size_t byteoffset = ((size_t)vp >> (64 - 3)) & 0x7;
- return byteoffset;
-}
-#else
-#define byteoff(vp) ((size_t)(vp) % 8) /* N.B. Assumes 64 bit word */
-#endif /* _CRAY1 */
-
-/*
- * Return the number of bytes until the next "word" boundary
- */
-static size_t
-word_align(const void *vp)
-{
- const size_t rem = byteoff(vp);
- if(rem == 0)
- return 0;
- return sizeof(word) - rem;
-}
-
-
-static const char nada[X_ALIGN] = {0, 0, 0, 0};
-
-
-/*
- * Primitive numeric conversion functions.
- */
-
-/* x_schar */
-
- /* We don't implement and x_schar primitives. */
-
-
-/* x_short */
-
-typedef short ix_short;
-#define SIZEOF_IX_SHORT SIZEOF_SHORT
-#define IX_SHORT_MAX SHORT_MAX
-
-static void
-cget_short_short(const void *xp, short *ip, int which)
-{
- const long *wp = xp;
-
- switch(which) {
- case 0:
- *ip = (short)(*wp >> 48);
- break;
- case 1:
- *ip = (short)((*wp >> 32) & 0xffff);
- break;
- case 2:
- *ip = (short)((*wp >> 16) & 0xffff);
- break;
- case 3:
- *ip = (short)(*wp & 0xffff);
- break;
- }
-
- if(*ip & 0x8000)
- {
- /* extern is negative */
- *ip |= (~(0xffff));
- }
-}
-#define get_ix_short(xp, ip) cget_short_short((xp), (ip), byteoff(xp)/X_SIZEOF_SHORT)
-
-static int
-cput_short_short(void *xp, const short *ip, int which)
-{
- word *wp = xp;
-
- switch(which) {
- case 0:
- *wp = (*ip << 48)
- | (*wp & 0x0000ffffffffffff);
- break;
- case 1:
- *wp = ((*ip << 32) & 0x0000ffff00000000)
- | (*wp & 0xffff0000ffffffff);
- break;
- case 2:
- *wp = ((*ip << 16) & 0x00000000ffff0000)
- | (*wp & 0xffffffff0000ffff);
- break;
- case 3:
- *wp = (*ip & 0x000000000000ffff)
- | (*wp & 0xffffffffffff0000);
- break;
- }
-
- if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-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)
-{
- get_ix_short(xp, ip);
- return ENOERR;
-}
-
-int
-ncx_get_short_int(const void *xp, int *ip)
-{
- ix_short xx;
- get_ix_short(xp, &xx);
- *ip = xx;
- return ENOERR;
-}
-
-int
-ncx_get_short_long(const void *xp, long *ip)
-{
- ix_short xx;
- get_ix_short(xp, &xx);
- *ip = xx;
- return ENOERR;
-}
-
-int
-ncx_get_short_float(const void *xp, float *ip)
-{
- ix_short xx;
- get_ix_short(xp, &xx);
- *ip = xx;
- return ENOERR;
-}
-
-int
-ncx_get_short_double(const void *xp, double *ip)
-{
- ix_short xx;
- get_ix_short(xp, &xx);
- *ip = xx;
- return ENOERR;
-}
-
-int
-ncx_put_short_schar(void *xp, const schar *ip)
-{
- uchar *cp = xp;
- if(*ip & 0x80)
- *cp++ = 0xff;
- else
- *cp++ = 0;
- *cp = (uchar)*ip;
- return ENOERR;
-}
-
-int
-ncx_put_short_uchar(void *xp, const uchar *ip)
-{
- uchar *cp = xp;
- *cp++ = 0;
- *cp = *ip;
- return ENOERR;
-}
-
-int
-ncx_put_short_short(void *xp, const short *ip)
-{
- return cput_short_short(xp, ip, byteoff(xp)/X_SIZEOF_SHORT);
-}
-
-int
-ncx_put_short_int(void *xp, const int *ip)
-{
- ix_short xx = (ix_short)*ip;
- return cput_short_short(xp, &xx, byteoff(xp)/X_SIZEOF_SHORT);
-}
-
-int
-ncx_put_short_long(void *xp, const long *ip)
-{
- ix_short xx = (ix_short)*ip;
- return cput_short_short(xp, &xx, byteoff(xp)/X_SIZEOF_SHORT);
-}
-
-int
-ncx_put_short_float(void *xp, const float *ip)
-{
- ix_short xx = (ix_short)*ip;
- const int status = cput_short_short(xp, &xx, byteoff(xp)/X_SIZEOF_SHORT);
- if(status != ENOERR)
- return status;
- if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_put_short_double(void *xp, const double *ip)
-{
- ix_short xx = (ix_short)*ip;
- const int status = cput_short_short(xp, &xx, byteoff(xp)/X_SIZEOF_SHORT);
- if(status != ENOERR)
- return status;
- if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-/* x_int */
-
-typedef int ix_int;
-#define SIZEOF_IX_INT SIZEOF_INT
-#define IX_INT_MAX INT_MAX
-
-static void
-cget_int_int(const void *xp, int *ip, int which)
-{
- const long *wp = xp;
-
- if(which == 0)
- {
- *ip = (int)(*wp >> 32);
- }
- else
- {
- *ip = (int)(*wp & 0xffffffff);
- }
-
- if(*ip & 0x80000000)
- {
- /* extern is negative */
- *ip |= (~(0xffffffff));
- }
-}
-#define get_ix_int(xp, ip) cget_int_int((xp), (ip), byteoff(xp))
-
-static int
-cput_int_int(void *xp, const int *ip, int which)
-{
- word *wp = xp;
-
- if(which == 0)
- {
- *wp = (*ip << 32) | (*wp & 0xffffffff);
- }
- else
- {
- *wp = (*wp & ~0xffffffff) | (*ip & 0xffffffff);
- }
- if(*ip > X_INT_MAX || *ip < X_INT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-#define put_ix_int(xp, ip) cput_int_int((xp), (ip), byteoff(xp))
-
-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)
-{
- ix_int xx;
- get_ix_int(xp, &xx);
- *ip = xx;
- if(xx > SHORT_MAX || xx < SHORT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_get_int_int(const void *xp, int *ip)
-{
- ix_int xx;
- get_ix_int(xp, &xx);
- *ip = xx;
- return ENOERR;
-}
-
-static void
-cget_int_long(const void *xp, long *ip, int which)
-{
- const long *wp = xp;
-
- if(which == 0)
- {
- *ip = (int)(*wp >> 32);
- }
- else
- {
- *ip = (int)(*wp & 0xffffffff);
- }
-
- if(*ip & 0x80000000)
- {
- /* extern is negative */
- *ip |= (~(0xffffffff));
- }
-}
-
-int
-ncx_get_int_long(const void *xp, long *ip)
-{
- cget_int_long(xp, ip, byteoff(xp));
- return ENOERR;
-}
-
-int
-ncx_get_int_float(const void *xp, float *ip)
-{
- ix_int xx;
- get_ix_int(xp, &xx);
- *ip = xx;
- if(xx > FLT_MAX || xx < (-FLT_MAX))
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_get_int_double(const void *xp, double *ip)
-{
- ix_int xx;
- get_ix_int(xp, &xx);
- *ip = xx;
- return ENOERR;
-}
-
-int
-ncx_put_int_schar(void *xp, const schar *ip)
-{
- uchar *cp = xp;
- if(*ip & 0x80)
- {
- *cp++ = 0xff;
- *cp++ = 0xff;
- *cp++ = 0xff;
- }
- else
- {
- *cp++ = 0x00;
- *cp++ = 0x00;
- *cp++ = 0x00;
- }
- *cp = (uchar)*ip;
- return ENOERR;
-}
-
-int
-ncx_put_int_uchar(void *xp, const uchar *ip)
-{
- uchar *cp = xp;
- *cp++ = 0x00;
- *cp++ = 0x00;
- *cp++ = 0x00;
- *cp = *ip;
- return ENOERR;
-}
-
-int
-ncx_put_int_short(void *xp, const short *ip)
-{
- ix_int xx = (ix_int)(*ip);
- return put_ix_int(xp, &xx);
-}
-
-int
-ncx_put_int_int(void *xp, const int *ip)
-{
- return put_ix_int(xp, ip);
-}
-
-static int
-cput_int_long(void *xp, const long *ip, int which)
-{
- long *wp = xp;
-
- if(which == 0)
- {
- *wp = (*ip << 32) | (*wp & 0xffffffff);
- }
- else
- {
- *wp = (*wp & ~0xffffffff) | (*ip & 0xffffffff);
- }
- if(*ip > X_INT_MAX || *ip < X_INT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_put_int_long(void *xp, const long *ip)
-{
- return cput_int_long(xp, ip, byteoff(xp));
-}
-
-int
-ncx_put_int_float(void *xp, const float *ip)
-{
- ix_int xx = (ix_int)(*ip);
- const int status = put_ix_int(xp, &xx);
- if(status != ENOERR)
- return status;
- if(*ip > (double)X_INT_MAX || *ip < (double)X_INT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_put_int_double(void *xp, const double *ip)
-{
- ix_int xx = (ix_int)(*ip);
- const int status = put_ix_int(xp, &xx);
- if(status != ENOERR)
- return status;
- if(*ip > X_INT_MAX || *ip < X_INT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-
-/* x_float */
-
-#if defined(NO_IEEE_FLOAT)
-
-struct cray_single {
- unsigned int sign : 1;
- unsigned int exp :15;
- unsigned int mant :48;
-};
-typedef struct cray_single cray_single;
-
-static const int cs_ieis_bias = 0x4000 - 0x7f;
-
-static const int cs_id_bias = 0x4000 - 0x3ff;
-
-#endif
-
-struct ieee_single_hi {
- unsigned int sign : 1;
- unsigned int exp : 8;
- unsigned int mant :23;
- unsigned int pad :32;
-};
-typedef struct ieee_single_hi ieee_single_hi;
-
-struct ieee_single_lo {
- unsigned int pad :32;
- unsigned int sign : 1;
- unsigned int exp : 8;
- unsigned int mant :23;
-};
-typedef struct ieee_single_lo ieee_single_lo;
-
-static const int ieee_single_bias = 0x7f;
-
-
-struct ieee_double {
- unsigned int sign : 1;
- unsigned int exp :11;
- unsigned int mant :52;
-};
-typedef struct ieee_double ieee_double;
-
-static const int ieee_double_bias = 0x3ff;
-
-#if FLOAT_USE_IEG
-
-static void
-get_ix_float(const void *xp, float *ip)
-{
- const int bo = bitoff(xp);
- (void) IEG2CRAY(&Cray2_F32, &One, (word *)xp, &bo, ip, &UnitStride);
-}
-
-static int
-put_ix_float(void *xp, const float *ip)
-{
- const int bo = bitoff(xp);
- int status = CRAY2IEG(&Cray2_F32, &One, (word *)xp, &bo, ip, &UnitStride);
- if(status != 0)
- status = NC_ERANGE;
- /* else, status == 0 == ENOERR */
- return status;
-}
-
-#else
- /* !FLOAT_USE_IEG */
-
-#if defined(NO_IEEE_FLOAT)
-
-static void
-cget_float_float(const void *xp, float *ip, int which)
-{
-
- if(which == 0)
- {
- const ieee_single_hi *isp = (const ieee_single_hi *) xp;
- cray_single *csp = (cray_single *) ip;
-
- if(isp->exp == 0)
- {
- /* ieee subnormal */
- *ip = (double)isp->mant;
- if(isp->mant != 0)
- {
- csp->exp -= (ieee_single_bias + 22);
- }
- }
- else
- {
- csp->exp = isp->exp + cs_ieis_bias + 1;
- csp->mant = isp->mant << (48 - 1 - 23);
- csp->mant |= (1 << (48 - 1));
- }
- csp->sign = isp->sign;
-
-
- }
- else
- {
- const ieee_single_lo *isp = (const ieee_single_lo *) xp;
- cray_single *csp = (cray_single *) ip;
-
- if(isp->exp == 0)
- {
- /* ieee subnormal */
- *ip = (double)isp->mant;
- if(isp->mant != 0)
- {
- csp->exp -= (ieee_single_bias + 22);
- }
- }
- else
- {
- csp->exp = isp->exp + cs_ieis_bias + 1;
- csp->mant = isp->mant << (48 - 1 - 23);
- csp->mant |= (1 << (48 - 1));
- }
- csp->sign = isp->sign;
-
-
- }
-}
-
-static int
-cput_float_float(void *xp, const float *ip, int which)
-{
- int status = ENOERR;
- if(which == 0)
- {
- ieee_single_hi *isp = (ieee_single_hi*)xp;
- const cray_single *csp = (const cray_single *) ip;
- int ieee_exp = csp->exp - cs_ieis_bias -1;
-
- isp->sign = csp->sign;
-
- if(ieee_exp >= 0xff
- || *ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
- {
- /* NC_ERANGE => ieee Inf */
- isp->exp = 0xff;
- isp->mant = 0x0;
- return NC_ERANGE;
- }
- /* else */
-
- if(ieee_exp > 0)
- {
- /* normal ieee representation */
- isp->exp = ieee_exp;
- /* assumes cray rep is in normal form */
- /* assert(csp->mant & 0x800000000000); */
- isp->mant = (((csp->mant << 1) &
- 0xffffffffffff) >> (48 - 23));
- }
- else if(ieee_exp > -23)
- {
- /* ieee subnormal, right */
- const int rshift = (48 - 23 - ieee_exp);
-
- isp->mant = csp->mant >> rshift;
- isp->exp = 0;
- }
- else
- {
- /* smaller than ieee can represent */
- isp->exp = 0;
- isp->mant = 0;
- }
-
- }
- else
- {
- ieee_single_lo *isp = (ieee_single_lo*)xp;
- const cray_single *csp = (const cray_single *) ip;
- int ieee_exp = csp->exp - cs_ieis_bias -1;
-
- isp->sign = csp->sign;
-
- if(ieee_exp >= 0xff
- || *ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
- {
- /* NC_ERANGE => ieee Inf */
- isp->exp = 0xff;
- isp->mant = 0x0;
- return NC_ERANGE;
- }
- /* else */
-
- if(ieee_exp > 0)
- {
- /* normal ieee representation */
- isp->exp = ieee_exp;
- /* assumes cray rep is in normal form */
- /* assert(csp->mant & 0x800000000000); */
- isp->mant = (((csp->mant << 1) &
- 0xffffffffffff) >> (48 - 23));
- }
- else if(ieee_exp > -23)
- {
- /* ieee subnormal, right */
- const int rshift = (48 - 23 - ieee_exp);
-
- isp->mant = csp->mant >> rshift;
- isp->exp = 0;
- }
- else
- {
- /* smaller than ieee can represent */
- isp->exp = 0;
- isp->mant = 0;
- }
-
- }
- return ENOERR;
-}
-
-#define get_ix_float(xp, ip) cget_float_float((xp), (ip), byteoff(xp))
-#define put_ix_float(xp, ip) cput_float_float((xp), (ip), byteoff(xp))
-
-#else
- /* IEEE Cray with only doubles */
-static void
-cget_float_float(const void *xp, float *ip, int which)
-{
-
- ieee_double *idp = (ieee_double *) ip;
-
- if(which == 0)
- {
- const ieee_single_hi *isp = (const ieee_single_hi *) 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;
- }
- 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 int
-cput_float_float(void *xp, const float *ip, int which)
-{
- const ieee_double *idp = (const ieee_double *) ip;
- if(which == 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;
- }
- if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-#define get_ix_float(xp, ip) cget_float_float((xp), (ip), byteoff(xp))
-#define put_ix_float(xp, ip) cput_float_float((xp), (ip), byteoff(xp))
-
-#endif /* NO_IEEE_FLOAT */
-
-#endif /* FLOAT_USE_IEG */
-
-
-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_long(const void *xp, long *ip)
-{
- float xx;
- get_ix_float(xp, &xx);
- *ip = (long) xx;
- if(xx > LONG_MAX || xx < LONG_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_get_float_float(const void *xp, float *ip)
-{
- get_ix_float(xp, ip);
- return ENOERR;
-}
-
-int
-ncx_get_float_double(const void *xp, double *ip)
-{
-#if SIZEOF_FLOAT == SIZEOF_DOUBLE && FLT_MANT_DIG == DBL_MANT_DIG
- return ncx_get_float_float(xp, (float *)ip);
-#else
- float xx;
- get_ix_float(xp, &xx);
- *ip = xx;
- return ENOERR;
-#endif
-}
-
-
-int
-ncx_put_float_schar(void *xp, const schar *ip)
-{
- float xx = (float) *ip;
- return put_ix_float(xp, &xx);
-}
-
-int
-ncx_put_float_uchar(void *xp, const uchar *ip)
-{
- float xx = (float) *ip;
- return put_ix_float(xp, &xx);
-}
-
-int
-ncx_put_float_short(void *xp, const short *ip)
-{
- float xx = (float) *ip;
- return put_ix_float(xp, &xx);
-}
-
-int
-ncx_put_float_int(void *xp, const int *ip)
-{
- float xx = (float) *ip;
- return put_ix_float(xp, &xx);
-}
-
-int
-ncx_put_float_long(void *xp, const long *ip)
-{
- float xx = (float) *ip;
- return put_ix_float(xp, &xx);
-}
-
-int
-ncx_put_float_float(void *xp, const float *ip)
-{
- return put_ix_float(xp, ip);
-}
-
-int
-ncx_put_float_double(void *xp, const double *ip)
-{
-#if SIZEOF_FLOAT == SIZEOF_DOUBLE && FLT_MANT_DIG == DBL_MANT_DIG
- return put_ix_float(xp, (float *)ip);
-#else
- float xx = (float) *ip;
- int status = put_ix_float(xp, &xx);
- if(*ip > X_FLOAT_MAX || *ip < X_FLOAT_MIN)
- return NC_ERANGE;
- return status;
-#endif
-}
-
-/* x_double */
-
-
-#if X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
-
-static void
-get_ix_double(const void *xp, double *ip)
-{
- (void) memcpy(ip, xp, sizeof(double));
-}
-
-static int
-put_ix_double(void *xp, const double *ip)
-{
- (void) memcpy(xp, ip, X_SIZEOF_DOUBLE);
- return ENOERR;
-}
-
-#else
-
-static void
-cget_double_double(const void *xp, double *ip)
-{
- const ieee_double *idp = (const ieee_double *) xp;
- cray_single *csp = (cray_single *) ip;
-
- if(idp->exp == 0)
- {
- /* ieee subnormal */
- *ip = (double)idp->mant;
- if(idp->mant != 0)
- {
- csp->exp -= (ieee_double_bias + 51);
- }
- }
- else
- {
- csp->exp = idp->exp + cs_id_bias + 1;
- csp->mant = idp->mant >> (52 - 48 + 1);
- csp->mant |= (1 << (48 - 1));
- }
- csp->sign = idp->sign;
-}
-
-static int
-cput_double_double(void *xp, const double *ip)
-{
- ieee_double *idp = (ieee_double *) xp;
- const cray_single *csp = (const cray_single *) ip;
-
- int ieee_exp = csp->exp - cs_id_bias -1;
-
- idp->sign = csp->sign;
-
- if(ieee_exp >= 0x7ff)
- {
- /* NC_ERANGE => ieee Inf */
- idp->exp = 0x7ff;
- idp->mant = 0x0;
- return NC_ERANGE;
- }
- /* else */
-
- if(ieee_exp > 0)
- {
- /* normal ieee representation */
- idp->exp = ieee_exp;
- /* assumes cray rep is in normal form */
- assert(csp->mant & 0x800000000000);
- idp->mant = (((csp->mant << 1) &
- 0xffffffffffff) << (52 - 48));
- }
- else if(ieee_exp >= (-(52 -48)))
- {
- /* ieee subnormal, left */
- const int lshift = (52 - 48) + ieee_exp;
- idp->mant = csp->mant << lshift;
- idp->exp = 0;
- }
- else if(ieee_exp >= -52)
- {
- /* ieee subnormal, right */
- const int rshift = (- (52 - 48) - ieee_exp);
-
- idp->mant = csp->mant >> rshift;
- idp->exp = 0;
- }
- else
- {
- /* smaller than ieee can represent */
- idp->exp = 0;
- idp->mant = 0;
- }
- return ENOERR;
-}
-
-#define get_ix_double(xp, ip) cget_double_double((xp), (ip))
-#define put_ix_double(xp, ip) cput_double_double((xp), (ip))
-
-#endif /* NO_IEEE_FLOAT */
-
-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_long(const void *xp, long *ip)
-{
- double xx;
- get_ix_double(xp, &xx);
- *ip = (long) xx;
- if(xx > LONG_MAX || xx < LONG_MIN)
- return NC_ERANGE;
- return ENOERR;
-}
-
-int
-ncx_get_double_float(const void *xp, float *ip)
-{
-#if SIZEOF_FLOAT == SIZEOF_DOUBLE && FLT_MANT_DIG == DBL_MANT_DIG
- get_ix_double(xp, (double *)ip);
- return ENOERR;
-#else
- double xx;
- get_ix_double(xp, &xx);
- if(xx > FLT_MAX || xx < (-FLT_MAX))
- {
- *ip = FLT_MAX;
- return NC_ERANGE;
- }
- if(xx < (-FLT_MAX))
- {
- *ip = (-FLT_MAX);
- return NC_ERANGE;
- }
- *ip = (float) xx;
- return ENOERR;
-#endif
-}
-
-int
-ncx_get_double_double(const void *xp, double *ip)
-{
- get_ix_double(xp, ip);
- return ENOERR;
-}
-
-
-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)
-{
- double xx = (double) *ip;
- put_ix_double(xp, &xx);
- return ENOERR;
-}
-
-int
-ncx_put_double_int(void *xp, const int *ip)
-{
- double xx = (double) *ip;
- put_ix_double(xp, &xx);
- return ENOERR;
-}
-
-int
-ncx_put_double_long(void *xp, const long *ip)
-{
- double xx = (double) *ip;
- put_ix_double(xp, &xx);
- /* TODO: Deal with big guys */
- return ENOERR;
-}
-
-int
-ncx_put_double_float(void *xp, const float *ip)
-{
-#if SIZEOF_FLOAT == SIZEOF_DOUBLE && FLT_MANT_DIG == DBL_MANT_DIG
- put_ix_double(xp, (double *)ip);
- return ENOERR;
-#else
- double xx = (double) *ip;
- return put_ix_double(xp, &xx);
-#endif
-}
-
-int
-ncx_put_double_double(void *xp, const double *ip)
-{
-#if !defined(NO_IEEE_FLOAT)
- put_ix_double(xp, ip);
- return ENOERR;
-#else
- return put_ix_double(xp, ip);
-#endif
-}
-
-
-/* x_size_t */
-
-int
-ncx_put_size_t(void **xpp, const size_t *ulp)
-{
- /* similar to put_ix_int() */
- uchar *cp = *xpp;
- /* sizes limited to 2^31 -1 in netcdf */
- assert(*ulp <= X_SIZE_MAX && (long) (*ulp) >= 0);
-
- *cp++ = (uchar)((*ulp) >> 24);
- *cp++ = (uchar)(((*ulp) & 0x00ff0000) >> 16);
- *cp++ = (uchar)(((*ulp) & 0x0000ff00) >> 8);
- *cp = (uchar)((*ulp) & 0x000000ff);
-
- *xpp = (void *)((char *)(*xpp) + X_SIZEOF_SIZE_T);
- return ENOERR;
-}
-
-int
-ncx_get_size_t(const void **xpp, size_t *ulp)
-{
- /* similar to get_ix_int */
- const uchar *cp = *xpp;
- assert((*cp & 0x80) == 0); /* sizes limited to 2^31 -1 in netcdf */
-
- *ulp = *cp++ << 24;
- *ulp |= (*cp++ << 16);
- *ulp |= (*cp++ << 8);
- *ulp |= *cp;
-
- *xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_SIZE_T);
- return ENOERR;
-}
-
-/* x_off_t */
-
-int
-ncx_put_off_t(void **xpp, const off_t *lp)
-{
- /* similar to put_ix_int() */
- uchar *cp = *xpp;
- /* No negative offsets stored in netcdf */
- assert(*lp >= 0 && *lp <= X_OFF_MAX);
-
- *cp++ = (uchar)((*lp) >> 24);
- *cp++ = (uchar)(((*lp) & 0x00ff0000) >> 16);
- *cp++ = (uchar)(((*lp) & 0x0000ff00) >> 8);
- *cp = (uchar)((*lp) & 0x000000ff);
-
- *xpp = (void *)((char *)(*xpp) + X_SIZEOF_OFF_T);
- return ENOERR;
-}
-
-int
-ncx_get_off_t(const void **xpp, off_t *lp)
-{
- /* similar to get_ix_int() */
- const uchar *cp = *xpp;
- assert((*cp & 0x80) == 0); /* No negative offsets stored in netcdf */
-
- *lp = *cp++ << 24;
- *lp |= (*cp++ << 16);
- *lp |= (*cp++ << 8);
- *lp |= *cp;
-
- *xpp = (const void *)((const char *)(*xpp) + X_SIZEOF_OFF_T);
- return ENOERR;
-}
-
-
-/*
- * 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;
-
-}
-int
-ncx_getn_schar_uchar(const void **xpp, size_t nelems, uchar *tp)
-{
- (void) memcpy(tp, *xpp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
- return ENOERR;
-
-}
-int
-ncx_getn_schar_short(const void **xpp, size_t nelems, short *tp)
-{
- schar *xp = (schar *)(*xpp);
-
- while(nelems-- != 0)
- {
- *tp++ = *xp++;
- }
-
- *xpp = (const void *)xp;
- return ENOERR;
-}
-
-int
-ncx_getn_schar_int(const void **xpp, size_t nelems, int *tp)
-{
- schar *xp = (schar *)(*xpp);
-
- while(nelems-- != 0)
- {
- *tp++ = *xp++;
- }
-
- *xpp = (const void *)xp;
- return ENOERR;
-}
-
-int
-ncx_getn_schar_long(const void **xpp, size_t nelems, long *tp)
-{
- schar *xp = (schar *)(*xpp);
-
- while(nelems-- != 0)
- {
- *tp++ = *xp++;
- }
-
- *xpp = (const void *)xp;
- return ENOERR;
-}
-
-int
-ncx_getn_schar_float(const void **xpp, size_t nelems, float *tp)
-{
- schar *xp = (schar *)(*xpp);
-
- while(nelems-- != 0)
- {
- *tp++ = *xp++;
- }
-
- *xpp = (const void *)xp;
- return ENOERR;
-}
-
-int
-ncx_getn_schar_double(const void **xpp, size_t nelems, double *tp)
-{
- schar *xp = (schar *)(*xpp);
-
- while(nelems-- != 0)
- {
- *tp++ = *xp++;
- }
-
- *xpp = (const void *)xp;
- return ENOERR;
-}
-
-
-int
-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)
-{
- 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 ENOERR;
-}
-
-int
-ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp)
-{
- 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 ENOERR;
-}
-
-int
-ncx_pad_getn_schar_long(const void **xpp, size_t nelems, long *tp)
-{
- 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 ENOERR;
-}
-
-int
-ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp)
-{
- 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 ENOERR;
-}
-
-int
-ncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp)
-{
- 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 ENOERR;
-}
-
-
-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_long(void **xpp, size_t nelems, const long *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_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)
- {
- /* N.B. schar as signed */
- 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)
- {
- /* N.B. schar as signed */
- 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_long(void **xpp, size_t nelems, const long *tp)
-{
- int status = ENOERR;
- size_t rndup = nelems % X_ALIGN;
- schar *xp = (schar *)(*xpp);
-
- if(rndup)
- rndup = X_ALIGN - rndup;
-
- while(nelems-- != 0)
- {
- /* N.B. schar as signed */
- 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)
- {
- /* N.B. schar as signed */
- 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)
- {
- /* N.B. schar as signed */
- 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;
-}
-
-
-
-/* short */
-
-int
-ncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
-{
- const char *xp = *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;
-}
-
-int
-ncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp)
-{
- const char *xp = *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;
-}
-
-#if SHORT_USE_IEG
-int
-ncx_getn_short_short(const void **xpp, size_t nelems, short *tp)
-{
- if(nelems > 0)
- {
- const int bo = bitoff(*xpp);
- const word *wp = *xpp;
- int ierr;
- *xpp = ((const char *) (*xpp) + nelems * X_SIZEOF_SHORT);
- ierr = IEG2CRAY(&Cray2_I16, &nelems, wp,
- &bo, tp, &UnitStride);
- assert(ierr >= 0);
- if(ierr > 0)
- return NC_ERANGE;
- }
- return ENOERR;
-}
-#else
-int
-ncx_getn_short_short(const void **xpp, const size_t nelems, short *tp)
-{
- if(nelems > 0)
- {
- const word *wp = *xpp;
- const short *const last = &tp[nelems -1];
- const int rem = word_align(*xpp)/X_SIZEOF_SHORT;
- *xpp = ((const char *) (*xpp) + nelems * X_SIZEOF_SHORT);
-
- switch(rem) {
- case 3:
- *tp = (short)((*wp >> 32) & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- if(tp == last)
- return ENOERR;
- tp++;
- /*FALLTHRU*/
- case 2:
- *tp = (short)((*wp >> 16) & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- if(tp == last)
- return ENOERR;
- tp++;
- /*FALLTHRU*/
- case 1:
- *tp = (short)(*wp & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- if(tp == last)
- return ENOERR;
- tp++;
- wp++; /* Note Bene */
- /*FALLTHRU*/
- }
-
- assert((nelems - rem) != 0);
- {
- const int nwords = ((nelems - rem) * X_SIZEOF_SHORT)
- / sizeof(word);
- const word *const endw = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < endw; wp++)
- {
-
- *tp = (short)(*wp >> 48);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
-
- *tp = (short)((*wp >> 32) & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
-
- *tp = (short)((*wp >> 16) & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
-
- *tp = (short)(*wp & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
- }
- }
-
- if(tp <= last)
- {
- *tp = (short)(*wp >> 48);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
- }
- if(tp <= last)
- {
- *tp = (short)((*wp >> 32) & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
- }
- if(tp <= last)
- {
- *tp = (short)((*wp >> 16) & 0xffff);
- if(*tp & 0x8000)
- *tp |= (~(0xffff));
- tp++;
- }
-
- }
- return ENOERR;
-}
-#endif
-
-int
-ncx_getn_short_int(const void **xpp, size_t nelems, int *tp)
-{
- const char *xp = *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;
-}
-
-int
-ncx_getn_short_long(const void **xpp, size_t nelems, long *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_get_short_long(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_short_float(const void **xpp, size_t nelems, float *tp)
-{
- const char *xp = *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;
-}
-
-int
-ncx_getn_short_double(const void **xpp, size_t nelems, double *tp)
-{
- const char *xp = *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;
-}
-
-
-int
-ncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp)
-{
- const size_t rndup = nelems % 2;
-
- const char *xp = *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 = *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 int status = ncx_getn_short_short(xpp, nelems, tp);
-
- if(rndup != 0)
- {
- *xpp = ((char *) (*xpp) + X_SIZEOF_SHORT);
- }
-
- 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 = *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_long(const void **xpp, size_t nelems, long *tp)
-{
- const size_t rndup = nelems % 2;
-
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_get_short_long(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 = *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 = *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_putn_short_schar(void **xpp, size_t nelems, const schar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_schar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_uchar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-#if SHORT_USE_IEG
-int
-ncx_putn_short_short(void **xpp, size_t nelems, const short *tp)
-{
- if(nelems > 0)
- {
- word *wp = *xpp;
- const int bo = bitoff(*xpp);
- int ierr;
-
- *xpp = ((char *) (*xpp) + nelems * X_SIZEOF_SHORT);
-
- ierr = CRAY2IEG(&Cray2_I16, &nelems, wp,
- &bo, tp, &UnitStride);
- assert(ierr >= 0);
- if(ierr > 0)
- return NC_ERANGE;
- }
- return ENOERR;
-}
-#else
-int
-ncx_putn_short_short(void **xpp, const size_t nelems, const short *tp)
-{
- int status = ENOERR;
- if(nelems == 0)
- return status;
-{
- word *wp = *xpp;
- const short *const last = &tp[nelems -1];
- const int rem = word_align(*xpp)/X_SIZEOF_SHORT;
- *xpp = ((char *) (*xpp) + nelems * X_SIZEOF_SHORT);
-
- switch(rem) {
- case 3:
- *wp = ((*tp << 32) & 0x0000ffff00000000)
- | (*wp & 0xffff0000ffffffff);
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- if(tp == last)
- return status;
- tp++;
- /*FALLTHRU*/
- case 2:
- *wp = ((*tp << 16) & 0x00000000ffff0000)
- | (*wp & 0xffffffff0000ffff);
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- if(tp == last)
- return status;
- tp++;
- /*FALLTHRU*/
- case 1:
- *wp = (*tp & 0x000000000000ffff)
- | (*wp & 0xffffffffffff0000);
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- if(tp == last)
- return status;
- tp++;
- wp++; /* Note Bene */
- /*FALLTHRU*/
- }
-
- assert((nelems - rem) != 0);
- {
- const int nwords = ((nelems - rem) * X_SIZEOF_SHORT)
- / sizeof(word);
- const word *const endw = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < endw; wp++)
- {
- *wp = (*tp << 48)
- | ((*(tp +1) << 32) & 0x0000ffff00000000)
- | ((*(tp +2) << 16) & 0x00000000ffff0000)
- | ((*(tp +3) ) & 0x000000000000ffff);
-
- { int ii = 0;
- for(; ii < 4; ii++, tp++)
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- }
- }
- }
-
- if(tp <= last)
- {
- *wp = (*tp << 48)
- | (*wp & 0x0000ffffffffffff);
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- tp++;
- }
- if(tp <= last)
- {
- *wp = ((*tp << 32) & 0x0000ffff00000000)
- | (*wp & 0xffff0000ffffffff);
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- tp++;
- }
- if(tp <= last)
- {
- *wp = ((*tp << 16) & 0x00000000ffff0000)
- | (*wp & 0xffffffff0000ffff);
- if(*tp > X_SHORT_MAX || *tp < X_SHORT_MIN)
- status = NC_ERANGE;
- }
-
- return status;
-}
-}
-#endif
-
-int
-ncx_putn_short_int(void **xpp, size_t nelems, const int *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_int(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_short_long(void **xpp, size_t nelems, const long *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_long(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_short_float(void **xpp, size_t nelems, const float *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_float(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_short_double(void **xpp, size_t nelems, const double *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_double(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-
-int
-ncx_pad_putn_short_schar(void **xpp, size_t nelems, const schar *tp)
-{
- const size_t rndup = nelems % 2;
-
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const 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 = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const 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;
-
- const int status = ncx_putn_short_short(xpp, nelems, tp);
-
- if(rndup != 0)
- {
- *xpp = ((char *) (*xpp) + X_SIZEOF_SHORT);
- }
-
- return status;
-}
-
-int
-ncx_pad_putn_short_int(void **xpp, size_t nelems, const int *tp)
-{
- const size_t rndup = nelems % 2;
-
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const 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_long(void **xpp, size_t nelems, const long *tp)
-{
- const size_t rndup = nelems % 2;
-
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const int lstatus = ncx_put_short_long(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 = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const 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 = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++)
- {
- const 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 */
-
-int
-ncx_getn_int_schar(const void **xpp, size_t nelems, schar *tp)
-{
- const char *xp = *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;
-}
-
-int
-ncx_getn_int_uchar(const void **xpp, size_t nelems, uchar *tp)
-{
- const char *xp = *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;
-}
-
-int
-ncx_getn_int_short(const void **xpp, size_t nelems, short *tp)
-{
- const char *xp = *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;
-}
-
-#if INT_USE_IEG
-int
-ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
-{
- if(nelems > 0)
- {
- const int bo = bitoff(*xpp);
- const word *wp = *xpp;
- int ierr;
- *xpp = ((const char *) (*xpp) + nelems * X_SIZEOF_INT);
- ierr = IEG2CRAY(&Cray2_I32, &nelems, wp,
- &bo, tp, &UnitStride);
- assert(ierr >= 0);
- if(ierr > 0)
- return NC_ERANGE;
- }
- return ENOERR;
-}
-#else
-int
-ncx_getn_int_int(const void **xpp, size_t nelems, int *tp)
-{
- const int bo = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(bo != 0)
- {
- cget_int_int(*xpp, tp, bo);
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- nelems--;
- if(nelems == 0)
- return ENOERR;
- tp++;
- }
-
- assert(byteoff(*xpp) == 0);
-
- {
- const int nwords = (nelems * X_SIZEOF_INT)/sizeof(word);
- const word *wp = *xpp;
- const word *const end = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp += 2)
- {
- cget_int_int(wp, tp, 0);
- cget_int_int(wp, tp + 1, 1);
- }
-
- *xpp = ((char *) (*xpp) + nwords * sizeof(word));
- nelems -= (nwords * sizeof(word)/X_SIZEOF_INT);
- if(nelems != 0)
- {
- cget_int_int(wp, tp, 0);
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- }
- }
-
- return ENOERR;
-}
-#endif
-
-int
-ncx_getn_int_long(const void **xpp, size_t nelems, long *tp)
-{
- const int bo = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(bo != 0)
- {
- cget_int_long(*xpp, tp, bo);
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- nelems--;
- if(nelems == 0)
- return ENOERR;
- tp++;
- }
-
- assert(byteoff(*xpp) == 0);
-
- {
- const int nwords = (nelems * X_SIZEOF_INT)/sizeof(word);
- const word *wp = *xpp;
- const word *const end = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp += 2)
- {
- cget_int_long(wp, tp, 0);
- cget_int_long(wp, tp + 1, 1);
- }
-
- *xpp = ((char *) (*xpp) + nwords * sizeof(word));
- nelems -= (nwords * sizeof(word)/X_SIZEOF_INT);
- if(nelems != 0)
- {
- cget_int_long(wp, tp, 0);
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- }
- }
-
- return ENOERR;
-}
-
-int
-ncx_getn_int_float(const void **xpp, size_t nelems, float *tp)
-{
- const char *xp = *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;
-}
-
-int
-ncx_getn_int_double(const void **xpp, size_t nelems, double *tp)
-{
- const char *xp = *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;
-}
-
-
-int
-ncx_putn_int_schar(void **xpp, size_t nelems, const schar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
- {
- const int lstatus = ncx_put_int_schar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_int_uchar(void **xpp, size_t nelems, const uchar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
- {
- const int lstatus = ncx_put_int_uchar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_int_short(void **xpp, size_t nelems, const short *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
- {
- const int lstatus = ncx_put_int_short(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-#if INT_USE_IEG
-int
-ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
-{
- if(nelems > 0)
- {
- word *wp = *xpp;
- const int bo = bitoff(*xpp);
- int ierr;
-
- *xpp = ((char *) (*xpp) + nelems * X_SIZEOF_INT);
-
- ierr = CRAY2IEG(&Cray2_I32, &nelems, wp,
- &bo, tp, &UnitStride);
- assert(ierr >= 0);
- if(ierr > 0)
- return NC_ERANGE;
- }
- return ENOERR;
-}
-#else
-int
-ncx_putn_int_int(void **xpp, size_t nelems, const int *tp)
-{
- int status = ENOERR;
- const int bo = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(bo != 0)
- {
- status = cput_int_int(*xpp, tp, bo);
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- nelems--;
- if(nelems == 0)
- return status;
- tp++;
- }
-
- assert(byteoff(*xpp) == 0);
-
- {
- const int nwords = (nelems * X_SIZEOF_INT)/sizeof(word);
- word *wp = *xpp;
- const word *const end = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp += 2)
- {
- int lstatus = cput_int_int(wp, tp, 0);
- if(lstatus != ENOERR)
- status = lstatus;
- lstatus = cput_int_int(wp, tp + 1, 1);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = ((char *) (*xpp) + nwords * sizeof(word));
- nelems -= (nwords * sizeof(word)/X_SIZEOF_INT);
- if(nelems != 0)
- {
- const int lstatus = cput_int_int(wp, tp, 0);
- if(lstatus != ENOERR)
- status = lstatus;
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- }
- }
-
- return status;
-}
-#endif
-
-int
-ncx_putn_int_long(void **xpp, size_t nelems, const long *tp)
-{
- int status = ENOERR;
- const int bo = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(bo != 0)
- {
- status = cput_int_long(*xpp, tp, bo);
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- nelems--;
- if(nelems == 0)
- return status;
- tp++;
- }
-
- assert(byteoff(*xpp) == 0);
-
- {
- const int nwords = (nelems * X_SIZEOF_INT)/sizeof(word);
- word *wp = *xpp;
- const word *const end = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp += 2)
- {
- int lstatus = cput_int_long(wp, tp, 0);
- if(lstatus != ENOERR)
- status = lstatus;
- lstatus = cput_int_long(wp, tp + 1, 1);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = ((char *) (*xpp) + nwords * sizeof(word));
- nelems -= (nwords * sizeof(word)/X_SIZEOF_INT);
- if(nelems != 0)
- {
- const int lstatus = cput_int_long(wp, tp, 0);
- if(lstatus != ENOERR)
- status = lstatus;
- *xpp = ((char *) (*xpp) + X_SIZEOF_INT);
- }
- }
-
- return status;
-}
-
-int
-ncx_putn_int_float(void **xpp, size_t nelems, const float *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
- {
- const int lstatus = ncx_put_int_float(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_int_double(void **xpp, size_t nelems, const double *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_INT, tp++)
- {
- const int lstatus = ncx_put_int_double(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-
-
-/* float */
-
-int
-ncx_getn_float_schar(const void **xpp, size_t nelems, schar *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_get_float_schar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_float_uchar(const void **xpp, size_t nelems, uchar *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_get_float_uchar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_float_short(const void **xpp, size_t nelems, short *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_get_float_short(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_float_int(const void **xpp, size_t nelems, int *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_get_float_int(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_float_long(const void **xpp, size_t nelems, long *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_get_float_long(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-#if FLOAT_USE_IEG
-int
-ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
-{
- if(nelems > 0)
- {
- const int bo = bitoff(*xpp);
- const word *wp = *xpp;
- int ierr;
- *xpp = ((const char *) (*xpp) + nelems * X_SIZEOF_FLOAT);
- ierr = IEG2CRAY(&Cray2_F32, &nelems, wp,
- &bo, tp, &UnitStride);
- assert(ierr >= 0);
- if(ierr > 0)
- return NC_ERANGE;
- }
- return ENOERR;
-
-}
-#else
-int
-ncx_getn_float_float(const void **xpp, size_t nelems, float *tp)
-{
- const int bo = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(bo != 0)
- {
- cget_float_float(*xpp, tp, bo);
- *xpp = ((char *) (*xpp) + X_SIZEOF_FLOAT);
- nelems--;
- if(nelems == 0)
- return ENOERR;
- tp++;
- }
-
- assert(byteoff(*xpp) == 0);
-
- {
- const int nwords = (nelems * X_SIZEOF_FLOAT)/sizeof(word);
- const word *wp = *xpp;
- const word *const end = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp += 2)
- {
- cget_float_float(wp, tp, 0);
- cget_float_float(wp, tp + 1, 1);
- }
-
- *xpp = ((char *) (*xpp) + nwords * sizeof(word));
- nelems -= (nwords * sizeof(word)/X_SIZEOF_FLOAT);
- if(nelems != 0)
- {
- cget_float_float(wp, tp, 0);
- *xpp = ((char *) (*xpp) + X_SIZEOF_FLOAT);
- }
- }
-
- return ENOERR;
-}
-#endif
-
-int
-ncx_getn_float_double(const void **xpp, size_t nelems, double *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_get_float_double(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-
-int
-ncx_putn_float_schar(void **xpp, size_t nelems, const schar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_put_float_schar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_float_uchar(void **xpp, size_t nelems, const uchar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_put_float_uchar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_float_short(void **xpp, size_t nelems, const short *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_put_float_short(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_float_int(void **xpp, size_t nelems, const int *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_put_float_int(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_float_long(void **xpp, size_t nelems, const long *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_put_float_long(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-#if FLOAT_USE_IEG
-int
-ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
-{
- if(nelems > 0)
- {
- word *wp = *xpp;
- const int bo = bitoff(*xpp);
- int ierr;
-
- *xpp = ((char *) (*xpp) + nelems * X_SIZEOF_FLOAT);
-
- ierr = CRAY2IEG(&Cray2_F32, &nelems, wp,
- &bo, tp, &UnitStride);
- assert(ierr >= 0);
- if(ierr > 0)
- return NC_ERANGE;
- }
- return ENOERR;
-}
-#else
-int
-ncx_putn_float_float(void **xpp, size_t nelems, const float *tp)
-{
- int status = ENOERR;
- const int bo = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(bo != 0)
- {
- status = cput_float_float(*xpp, tp, bo);
- *xpp = ((char *) (*xpp) + X_SIZEOF_FLOAT);
- nelems--;
- if(nelems == 0)
- return status;
- tp++;
- }
-
- assert(byteoff(*xpp) == 0);
-
- {
- const int nwords = (nelems * X_SIZEOF_FLOAT)/sizeof(word);
- word *wp = *xpp;
- const word *const end = &wp[nwords];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp += 2)
- {
- int lstatus = cput_float_float(wp, tp, 0);
- if(lstatus != ENOERR)
- status = lstatus;
- lstatus = cput_float_float(wp, tp + 1, 1);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = ((char *) (*xpp) + nwords * sizeof(word));
- nelems -= (nwords * sizeof(word)/X_SIZEOF_FLOAT);
- if(nelems != 0)
- {
- const int lstatus = cput_float_float(wp, tp, 0);
- if(lstatus != ENOERR)
- status = lstatus;
- *xpp = ((char *) (*xpp) + X_SIZEOF_FLOAT);
- }
- }
-
- return status;
-}
-#endif
-
-int
-ncx_putn_float_double(void **xpp, size_t nelems, const double *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_FLOAT, tp++)
- {
- const int lstatus = ncx_put_float_double(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-
-
-/* double */
-
-int
-ncx_getn_double_schar(const void **xpp, size_t nelems, schar *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_schar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_double_uchar(const void **xpp, size_t nelems, uchar *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_uchar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_double_short(const void **xpp, size_t nelems, short *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_short(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_double_int(const void **xpp, size_t nelems, int *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_int(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-int
-ncx_getn_double_long(const void **xpp, size_t nelems, long *tp)
-{
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_long(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-}
-
-#if DOUBLE_USE_IEG
-int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
-{
- const size_t noff = byteoff(*xpp);
- int ierr;
-
- if(nelems == 0)
- return ENOERR;
-
- if(noff != 0)
- {
- /* (*xpp) not word aligned, forced to make a copy */
- word xbuf[nelems];
- (void) memcpy(xbuf, *xpp, nelems * X_SIZEOF_DOUBLE);
- ierr = IEG2CRAY(&Cray2_F64, &nelems, xbuf,
- &Zero, tp, &UnitStride);
- }
- else
- {
- ierr = IEG2CRAY(&Cray2_F64, &nelems, *xpp,
- &Zero, tp, &UnitStride);
- }
-
- *xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
-
- assert(ierr >= 0);
-
- return ierr > 0 ? NC_ERANGE : ENOERR;
-}
-#elif X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
-int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
-{
- (void) memcpy(tp, *xpp, nelems * X_SIZEOF_DOUBLE);
- *xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
- return ENOERR;
-}
-#else
-int
-ncx_getn_double_double(const void **xpp, size_t nelems, double *tp)
-{
- const size_t noff = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(noff != 0)
- {
- /* (*xpp) not word aligned, forced to make a copy */
- word xbuf[nelems];
- const word *wp = xbuf;
- const word *const end = &wp[nelems];
-
- (void) memcpy(xbuf, *xpp, nelems * X_SIZEOF_DOUBLE);
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp++)
- {
- cget_double_double(wp, tp);
- }
-
- }
- else
- {
- const word *wp = *xpp;
- const word *const end = &wp[nelems];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp++)
- {
- cget_double_double(wp, tp);
- }
-
- }
- *xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
- return ENOERR;
-}
-#endif
-
-int
-ncx_getn_double_float(const void **xpp, size_t nelems, float *tp)
-{
-#if SIZEOF_FLOAT == SIZEOF_DOUBLE && FLT_MANT_DIG == DBL_MANT_DIG
- return ncx_getn_double_double(xpp, nelems, (double *)tp);
-#else
- const char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_get_double_float(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (const void *)xp;
- return status;
-#endif
-}
-
-
-int
-ncx_putn_double_schar(void **xpp, size_t nelems, const schar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_put_double_schar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_double_uchar(void **xpp, size_t nelems, const uchar *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_put_double_uchar(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_double_short(void **xpp, size_t nelems, const short *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_put_double_short(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_double_int(void **xpp, size_t nelems, const int *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_put_double_int(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-int
-ncx_putn_double_long(void **xpp, size_t nelems, const long *tp)
-{
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_put_double_long(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-}
-
-#if DOUBLE_USE_IEG
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
- const size_t noff = byteoff(*xpp);
- int ierr;
-
- if(nelems == 0)
- return ENOERR;
-
- if(noff != 0)
- {
- /* (*xpp) not word aligned, forced to make a copy */
- word xbuf[nelems];
- ierr = CRAY2IEG(&Cray2_F64, &nelems, xbuf,
- &Zero, tp, &UnitStride);
- assert(ierr >= 0);
- (void) memcpy(*xpp, xbuf, nelems * X_SIZEOF_DOUBLE);
- }
- else
- {
- ierr = CRAY2IEG(&Cray2_F64, &nelems, *xpp,
- &Zero, tp, &UnitStride);
- assert(ierr >= 0);
- }
-
- *xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
-
- return ierr > 0 ? NC_ERANGE : ENOERR;
-}
-#elif X_SIZEOF_DOUBLE == SIZEOF_DOUBLE && !defined(NO_IEEE_FLOAT)
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
- const size_t noff = byteoff(*xpp);
- (void) memcpy(*xpp, tp, nelems * X_SIZEOF_DOUBLE);
- *xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
- return ENOERR;
-}
-#else
-int
-ncx_putn_double_double(void **xpp, size_t nelems, const double *tp)
-{
- int status = ENOERR;
- const size_t noff = byteoff(*xpp);
-
- if(nelems == 0)
- return ENOERR;
-
- if(noff != 0)
- {
- /* (*xpp) not word aligned, forced to make a copy */
- word xbuf[nelems];
- word *wp = xbuf;
- const word *const end = &wp[nelems];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp++)
- {
- const int lstatus = cput_double_double(wp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- (void) memcpy(*xpp, xbuf, nelems * X_SIZEOF_DOUBLE);
- }
- else
- {
- word *wp = *xpp;
- const word *const end = &wp[nelems];
-
-#pragma _CRI ivdep
- for( ; wp < end; wp++, tp++)
- {
- const int lstatus = cput_double_double(wp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- }
-
- *xpp = (void *)((char *)(*xpp) + nelems * X_SIZEOF_DOUBLE);
- return status;
-}
-#endif
-
-int
-ncx_putn_double_float(void **xpp, size_t nelems, const float *tp)
-{
-#if SIZEOF_FLOAT == SIZEOF_DOUBLE && FLT_MANT_DIG == DBL_MANT_DIG
- return ncx_putn_double_double(xpp, nelems, (double *)tp);
-#else
- char *xp = *xpp;
- int status = ENOERR;
-
- for( ; nelems != 0; nelems--, xp += X_SIZEOF_DOUBLE, tp++)
- {
- const int lstatus = ncx_put_double_float(xp, tp);
- if(lstatus != ENOERR)
- status = lstatus;
- }
-
- *xpp = (void *)xp;
- return status;
-#endif
-}
-
-
-
-/*
- * Other aggregate conversion functions.
- */
-
-/* text */
-
-int
-ncx_getn_text(const void **xpp, size_t nelems, char *tp)
-{
- (void) memcpy(tp, *xpp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
- return ENOERR;
-
-}
-
-int
-ncx_pad_getn_text(const void **xpp, size_t nelems, char *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_putn_text(void **xpp, size_t nelems, const char *tp)
-{
- (void) memcpy(*xpp, tp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
-
- return ENOERR;
-
-}
-
-int
-ncx_pad_putn_text(void **xpp, size_t nelems, const char *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;
-
-}
-
-
-/* opaque */
-
-int
-ncx_getn_void(const void **xpp, size_t nelems, void *tp)
-{
- (void) memcpy(tp, *xpp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
- return ENOERR;
-
-}
-
-int
-ncx_pad_getn_void(const void **xpp, size_t nelems, void *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_putn_void(void **xpp, size_t nelems, const void *tp)
-{
- (void) memcpy(*xpp, tp, nelems);
- *xpp = (void *)((char *)(*xpp) + nelems);
-
- return ENOERR;
-
-}
-
-int
-ncx_pad_putn_void(void **xpp, size_t nelems, const void *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;
-
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/netcdf.3 b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/netcdf.3
deleted file mode 100644
index 3c7e11a..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/netcdf.3
+++ /dev/null
@@ -1,909 +0,0 @@
-.TH NETCDF 3 "18 April 1997" "Printed: \n(yr.\n(mo.\n(dy" "UNIDATA LIBRARY FUNCTIONS"
-.SH NAME
-netcdf \- Unidata Network Common Data Form (netCDF) library, version 3 interface
-.SH SYNOPSIS
-.ft B
-.na
-.nh
-#include "netcdf.h"
-.sp
-
-cc ... -lnetcdf
-
-.ad
-.hy
-.SH "LIBRARY VERSION"
-.LP
-This document describes version 3 of Unidata netCDF data-access interface
-for the C programming language.
-.HP
-\fBconst char* nc_inq_libvers()\fR
-.sp
-Returns a string identifying the version of the netCDF library, and
-when it was built, like: "3.1a of Aug 22 1996 12:57:47 $".
-.LP
-The RCS \fBident(1)\fP command will find a string like
-"$\|Id: @\|(#) netcdf library version 3.1a of Sep 6 1996 15:56:26 $"
-in the library. The SCCS \fBwhat(1)\fP command will find a string like
-"netcdf library version 3.1a of Aug 23 1996 16:07:40 $".
-.SH "RETURN VALUES"
-.LP
-All netCDF functions (except
-\fBnc_inq_libvers(\|)\fR and \fBnc_strerror(\|)\fR) return an integer status.
-This behavior replaces the
-\fBncerr()\fR function
-used in previous versions of the library.
-If this returned status value is not equal to
-\fBNC_NOERR\fR (zero), it
-indicates that an error occurred. The possible status values are defined in
-system include file <errno.h> and in "netcdf.h".
-.HP
-\fBconst char* nc_strerror(int \fIstatus\fP)\fR
-.sp
-Returns a string textual translation of the \fIstatus\fP
-value, like "Attribute or variable name contains illegal characters"
-or "No such file or directory".
-.SH "FUNCTION DESCRIPTIONS"
-.HP
-\fBint nc_create(const char \fIpath\fP[], int \fIcmode\fP,
-int* \fIncid\fP)\fR
-.sp
-(Corresponds to \fBnccreate(\|)\fR in version 2)
-.sp
-Creates a new netCDF dataset at \fIpath\fP,
-returning a netCDF ID in \fIncid\fP.
-The argument \fIcmode\fP may include the bitwise-or
-of the following flags:
-\fBNC_NOCLOBBER\fR
-to protect existing datasets (default
-silently blows them away),
-\fBNC_SHARE\fR
-for synchronous dataset updates
-(default is to buffer accesses), and
-\fBNC_LOCK\fR
-(not yet implemented).
-When a netCDF dataset is created, is is opened
-\fBNC_WRITE\fR.
-The new netCDF dataset is in define mode.
-.HP
-\fBint nc_open(const char \fIpath\fP[], int \fImode\fP, int* \fIncid\fP)\fR
-.sp
-(Corresponds to \fBncopen(\|)\fR in version 2)
-.sp
-Opens a existing netCDF dataset at \fIpath\fP
-returning a netCDF ID
-in \fIncid\fP.
-The type of access is described by the \fImode\fP parameter,
-which may include the bitwise-or
-of the following flags:
-\fBNC_WRITE\fR
-for read-write access (default
-read-only),
-\fBNC_SHARE\fR
-for synchronous dataset updates (default is
-to buffer accesses), and
-\fBNC_LOCK\fR
-(not yet implemented).
-.HP
-\fBint nc_redef(int \fIncid\fP)\fR
-.sp
-(Corresponds to \fBncredef(\|)\fR in version 2)
-.sp
-Puts an open netCDF dataset into define mode,
-so dimensions, variables, and attributes can be added or renamed and
-attributes can be deleted.
-.HP
-\fBint nc_endef(int \fIncid\fP)\fR
-.sp
-(Corresponds to \fBncendef(\|)\fR in version 2)
-.sp
-Takes an open netCDF dataset out of define mode.
-The changes made to the netCDF dataset
-while it was in define mode are checked and committed to disk if no
-problems occurred. Some data values may be written as well,
-see "VARIABLE PREFILLING" below.
-After a successful call, variable data can be read or written to the dataset.
-.HP
-\fBint nc_sync(int \fIncid\fP)\fR
-.sp
-(Corresponds to \fBncsync(\|)\fR in version 2)
-.sp
-Unless the
-\fBNC_SHARE\fR
-bit is set in
-\fBnc_open(\|)\fR or \fBnc_create(\|)\fR,
-accesses to the underlying netCDF dataset are
-buffered by the library. This function synchronizes the state of
-the underlying dataset and the library.
-This is done automatically by
-\fBnc_close(\|)\fR and \fBnc_endef(\|)\fR.
-.HP
-\fBint nc_abort(int \fIncid\fP)\fR
-.sp
-(Corresponds to \fBncabort(\|)\fR in version 2)
-.sp
-You don't need to call this function.
-This function is called automatically by
-\fBnc_close(\|)\fR
-if the netCDF was in define mode and something goes wrong with the commit.
-If the netCDF dataset isn't in define mode, then this function is equivalent to
-\fBnc_close(\|)\fR.
-If it is called after
-\fBnc_redef(\|)\fR,
-but before
-\fBnc_enddef(\|)\fR,
-the new definitions are not committed and the dataset is closed.
-If it is called after
-\fBnc_create(\|)\fR
-but before
-\fBnc_enddef(\|)\fR,
-the dataset disappears.
-.HP
-\fBint nc_close(int \fIncid\fP)\fR
-.sp
-(Corresponds to
-\fBncclose(\|)\fR in version 2)
-.sp
-Closes an open netCDF dataset.
-If the dataset is in define mode,
-\fBnc_endef(\|)\fR
-will be called before closing.
-After a dataset is closed, its ID may be reassigned to another dataset.
-.HP
-\fBint nc_inq(int \fIncid\fP, int* \fIndims\fP, int* \fInvars\fP,
-int* \fInatts\fP, int* \fIunlimdimid\fP)\fR
-.HP
-\fBint nc_inq_ndims(int \fIncid\fP, int* \fIndims\fP)\fR
-.HP
-\fBint nc_inq_nvars(int \fIncid\fP, int* \fInvars\fP)\fR
-.HP
-\fBint nc_inq_natts(int \fIncid\fP, int* \fInatts\fP)\fR
-.HP
-\fBint nc_inq_unlimdim(int \fIncid\fP, int* \fIunlimdimid\fP)\fR
-.sp
-(Replace \fBncinquire(\|)\fR in version 2)
-.sp
-Use these functions to find out what is in a netCDF dataset.
-Upon successful return,
-\fIndims\fP will contain the
-number of dimensions defined for this netCDF dataset,
-\fInvars\fP will contain the number of variables,
-\fInatts\fP will contain the number of attributes, and
-\fIunlimdimid\fP will contain the
-dimension ID of the unlimited dimension if one exists, or
--1 otherwise.
-If any of the
-return parameters is a \fBNULL\fR pointer, then the corresponding information
-will not be returned; hence, no space need be allocated for it.
-.HP
-\fBint nc_def_dim(int \fIncid\fP, const char \fIname\fP[], size_t \fIlen\fP, int* \fIdimid\fP)\fR
-.sp
-(Corresponds to \fBncdimdef(\|)\fR in version 2)
-.sp
-Adds a new dimension to an open netCDF dataset, which must be
-in define mode.
-\fIname\fP is the dimension name.
-If \fIdimid\fP is not a \fBNULL\fR pointer then upon successful completion \fIdimid\fP will contain the dimension ID of the newly created dimension.
-.HP
-\fBint nc_inq_dimid(int \fIncid\fP, const char \fIname\fP[], int* \fIdimid\fP)\fR
-.sp
-(Corresponds to \fBncdimid(\|)\fR in version 2)
-.sp
-Given a dimension name, returns the ID of a netCDF dimension in \fIdimid\fP.
-.HP
-\fBint nc_inq_dim(int \fIncid\fP, int \fIdimid\fP, char \fIname\fP[], size_t* \fIlen\fP)\fR
-.HP
-\fBint nc_inq_dimname(int \fIncid\fP, int \fIdimid\fP, char \fIname\fP[])\fR
-.HP
-\fBint nc_inq_dimlen(int \fIncid\fP, int \fIdimid\fP, size_t* \fIlen\fP)\fR
-.sp
-(Replace \fBncdiminq(\|)\fR in version 2)
-.sp
-Use these functions to find out about a dimension.
-If either the \fIname\fP
-argument or \fIlen\fP argument is a \fBNULL\fR pointer, then
-the associated information will not be returned. Otherwise,
-\fIname\fP should be big enough (\fBNC_MAX_NAME\fR)
-to hold the dimension name as the name will be copied into your storage.
-The length return parameter, \fIlen\fP
-will contain the size of the dimension.
-For the unlimited dimension, the returned length is the current
-maximum value used for writing into any of the variables which use
-the dimension.
-.HP
-\fBint nc_rename_dim(int \fIncid\fP, int \fIdimid\fP, const char \fIname\fP[])\fR
-.sp
-(Corresponds to \fBncdimrename(\|)\fR 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
-define mode.
-You cannot rename a dimension to have the same name as another dimension.
-.HP
-\fBint nc_def_var(int \fIncid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, int \fIndims\fP, const int \fIdimids\fP[], int* \fIvarid\fP)\fR
-.sp
-(Corresponds to \fBncvardef(\|)\fR in version 2)
-.sp
-Adds a new variable to a netCDF dataset. The netCDF must be in define mode.
-If not \fBNULL\fR, then \fIvarid\fP will be set to the netCDF variable ID.
-.HP
-\fBint nc_inq_varid(int \fIncid\fP, const char \fIname\fP[], int* \fIvarid\fP)\fR
-.sp
-(Corresponds to \fBncvarid(\|)\fR in version 2)
-.sp
-Returns the ID of a netCDF variable in \fIvarid\fP given its name.
-.HP
-\fBint nc_inq_var(int \fIncid\fP, int \fIvarid\fP, char \fIname\fP[], nc_type* \fIxtype\fP, int* \fIndims\fP, int \fIdimids\fP[],
-int* \fInatts\fP)\fR
-.HP
-\fBint nc_inq_varname(int \fIncid\fP, int \fIvarid\fP, char \fIname\fP[])\fR
-.HP
-\fBint nc_inq_vartype(int \fIncid\fP, int \fIvarid\fP, nc_type* \fIxtype\fP)\fR
-.HP
-\fBint nc_inq_varndims(int \fIncid\fP, int \fIvarid\fP, int* \fIndims\fP)\fR
-.HP
-\fBint nc_inq_vardimid(int \fIncid\fP, int \fIvarid\fP, int \fIdimids\fP[])\fR
-.HP
-\fBint nc_inq_varnatts(int \fIncid\fP, int \fIvarid\fP, int* \fInatts\fP)\fR
-.sp
-(Replace \fBncvarinq(\|)\fR in version 2)
-.sp
-Returns information about a netCDF variable, given its ID.
-If any of the
-return parameters (\fIname\fP, \fIxtype\fP, \fIndims\fP, \fIdimids\fP, or
-\fInatts\fP) is a \fBNULL\fR pointer, then the corresponding information
-will not be returned; hence, no space need be allocated for it.
-.HP
-\fBint nc_rename_var(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[])\fR
-.sp
-(Corresponds to \fBncvarrename(\|)\fR in version 2)
-.sp
-Changes the name of a netCDF variable.
-If the new name is longer than the old name, the netCDF must be in define mode.
-You cannot rename a variable to have the name of any existing variable.
-.HP
-\fBint nc_put_var_text(int \fIncid\fP, int \fIvarid\fP, const char \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_uchar(int \fIncid\fP, int \fIvarid\fP, const unsigned char \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_schar(int \fIncid\fP, int \fIvarid\fP, const signed char \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_short(int \fIncid\fP, int \fIvarid\fP, const short \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_int(int \fIncid\fP, int \fIvarid\fP, const int \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_long(int \fIncid\fP, int \fIvarid\fP, const long \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_float(int \fIncid\fP, int \fIvarid\fP, const float \fIout\fP[])\fR
-.HP
-\fBint nc_put_var_double(int \fIncid\fP, int \fIvarid\fP, const double \fIout\fP[])\fR
-.sp
-(Replace \fBncvarput(\|)\fR in version 2)
-.sp
-Writes an entire netCDF variable (i.e. all the values).
-The netCDF dataset must be open and in data mode. The type of the data is
-specified in the function name, and it is converted to the external type
-of the specified variable, if possible, otherwise an
-\fBNC_ERANGE\fR error is returned.
-.HP
-\fBint nc_get_var_text(int \fIncid\fP, int \fIvarid\fP, char \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_uchar(int \fIncid\fP, int \fIvarid\fP, unsigned char \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_schar(int \fIncid\fP, int \fIvarid\fP, signed char \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_short(int \fIncid\fP, int \fIvarid\fP, short \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_int(int \fIncid\fP, int \fIvarid\fP, int \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_long(int \fIncid\fP, int \fIvarid\fP, long \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_float(int \fIncid\fP, int \fIvarid\fP, float \fIin\fP[])\fR
-.HP
-\fBint nc_get_var_double(int \fIncid\fP, int \fIvarid\fP, double \fIin\fP[])\fR
-.sp
-(Replace \fBncvarget(\|)\fR in version 2)
-.sp
-Reads an entire netCDF variable (i.e. all the values).
-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 \fBNC_ERANGE\fR error is returned.
-.HP
-\fBint nc_put_var1_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], char \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], unsigned char \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], signed char \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], short \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], int \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], long \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], float \fI*out\fP)\fR
-.HP
-\fBint nc_put_var1_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], double \fI*out\fP)\fR
-.sp
-(Replace \fBncvarput1(\|)\fR in version 2)
-.sp
-Puts a single data value into a variable at the position \fIindex\fP of an
-open netCDF dataset that is in data mode. The type of the data is
-specified in the function name, and it is converted to the external type
-of the specified variable, if possible, otherwise an \fBNC_ERANGE\fR
-error is returned.
-.HP
-\fBint nc_get_var1_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], char* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], unsigned char* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], signed char* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], short* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], int* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], long* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], float* \fIin\fP)\fR
-.HP
-\fBint nc_get_var1_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIindex\fP[], double* \fIin\fP)\fR
-.sp
-(Replace \fBncvarget1(\|)\fR in version 2)
-.sp
-Gets a single data value from a variable at the position \fIindex\fP
-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 \fBNC_ERANGE\fR error is returned.
-.HP
-\fBint nc_put_vara_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const char \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const unsigned char \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const signed char \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const short \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const int \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const long \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const float \fIout\fP[])\fR
-.HP
-\fBint nc_put_vara_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const double \fIout\fP[])\fR
-.sp
-(Replace \fBncvarput(\|)\fR in version 2)
-.sp
-Writes an array section of values into a netCDF variable of an open
-netCDF dataset, which must be in data mode. The array section is specified
-by the \fIstart\fP and \fIcount\fP vectors, which give the starting index
-and count of values along each dimension of the specified variable.
-The type of the data is
-specified in the function name and is converted to the external type
-of the specified variable, if possible, otherwise an \fBNC_ERANGE\fR
-error is returned.
-.HP
-\fBint nc_get_vara_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], char \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], unsigned char \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], signed char \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], short \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], int \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], long \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], float \fIin\fP[])\fR
-.HP
-\fBint nc_get_vara_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], double \fIin\fP[])\fR
-.sp
-(Corresponds to \fBncvarget(\|)\fR in version 2)
-.sp
-Reads an array section of values from a netCDF variable of an open
-netCDF dataset, which must be in data mode. The array section is specified
-by the \fIstart\fP and \fIcount\fP vectors, which give the starting index
-and count of values along each dimension of the specified variable.
-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 \fBNC_ERANGE\fR error is returned.
-.HP
-\fBint nc_put_vars_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const char \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const unsigned char \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const signed char \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const short \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const int \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const long \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const float \fIout\fP[])\fR
-.HP
-\fBint nc_put_vars_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], const double \fIout\fP[])\fR
-.sp
-(Corresponds to \fBncvarputg(\|)\fR in version 2)
-.sp
-These functions are used for \fIstrided output\fP, which is like the
-array section output described above, except that
-the sampling stride (the interval between accessed values) is
-specified for each dimension.
-For an explanation of the sampling stride
-vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-.HP
-\fBint nc_get_vars_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], char \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], unsigned char \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], signed char \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], short \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], int \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], long \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], float \fIin\fP[])\fR
-.HP
-\fBint nc_get_vars_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], double \fIin\fP[])\fR
-.sp
-(Corresponds to \fBncvargetg(\|)\fR in version 2)
-.sp
-These functions are used for \fIstrided input\fP, which is like the
-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
-vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-.HP
-\fBint nc_put_varm_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const char \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const unsigned char \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const signed char \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const short \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const int \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const long \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const float \fIout\fP[])\fR
-.HP
-\fBint nc_put_varm_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, const double \fIout\fP[])\fR
-.sp
-(Corresponds to \fBncvarputg(\|)\fR in version 2)
-.sp
-These functions are used for \fImapped output\fP, which is like
-strided output described above, except that an additional index mapping
-vector is provided to specify the in-memory arrangement of the data
-values.
-For an explanation of the index
-mapping vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-.HP
-\fBint nc_get_varm_text(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, char \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_uchar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, unsigned char \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_schar(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, signed char \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_short(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, short \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_int(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, int \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_long(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, long \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_float(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, float \fIin\fP[])\fR
-.HP
-\fBint nc_get_varm_double(int \fIncid\fP, int \fIvarid\fP, const size_t \fIstart\fP[], const size_t \fIcount\fP[], const size_t \fIstride\fP[], \fIimap\fP, double \fIin\fP[])\fR
-.sp
-(Corresponds to \fBncvargetg(\|)\fR in version 2)
-.sp
-These functions are used for \fImapped input\fP, which is like
-strided input described above, except that an additional index mapping
-vector is provided to specify the in-memory arrangement of the data
-values.
-For an explanation of the index
-mapping vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-.HP
-\fBint nc_put_att_text(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const char \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_uchar(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const unsigned char \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_schar(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const signed char \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_short(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const short \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_int(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const int \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_long(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const long \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_float(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const float \fIout\fP[])\fR
-.HP
-\fBint nc_put_att_double(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type \fIxtype\fP, size_t \fIlen\fP, const double \fIout\fP[])\fR
-.sp
-(Replace \fBncattput(\|)\fR in version 2)
-.sp
-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.
-If the attribute is new, or if the space required to
-store the attribute value is greater than before,
-the netCDF dataset must be in define mode.
-The parameter \fIlen\fP is the number of values from \fIout\fP to transfer.
-It is often one, except that for
-\fBnc_put_att_text(\|)\fR it will usually be
-\fBstrlen(\fIout\fP)\fR.
-.sp
-For these functions, the type component of the function name refers to
-the in-memory type of the value, whereas the \fIxtype\fP argument refers to the
-external type for storing the value. An \fBNC_ERANGE\fR
-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
-external type.
-.HP
-\fBint nc_inq_attname(int \fIncid\fP, int \fIvarid\fP, int \fIattnum\fP, char \fIname\fP[])\fR
-.sp
-(Corresponds to \fBncattname(\|)\fR in version 2)
-.sp
-Gets the
-name of an attribute, given its variable ID and attribute number.
-This function is useful in generic applications that
-need to get the names of all the attributes associated with a variable,
-since attributes are accessed by name rather than number in all other
-attribute functions. The number of an attribute is more volatile than
-the name, since it can change when other attributes of the same variable
-are deleted. The attributes for each variable are numbered
-from 0 (the first attribute) to
-\fInvatts\fP-1,
-where \fInvatts\fP is
-the number of attributes for the variable, as returned from a call to
-\fBnc_inq_varnatts(\|)\fR.
-If the \fIname\fP parameter is a \fBNULL\fR pointer, no name will be
-returned and no space need be allocated.
-.HP
-\fBint nc_inq_att(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type* \fIxtype\fP, size_t* \fIlen\fP)\fR
-.HP
-\fBint nc_inq_attid(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], int* \fIattnum\fP)\fR
-.HP
-\fBint nc_inq_atttype(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], nc_type* \fIxtype\fP)\fR
-.HP
-\fBint nc_inq_attlen(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], size_t* \fIlen\fP)\fR
-.sp
-(Corresponds to \fBncattinq(\|)\fR in version 2)
-.sp
-These functions return information about a netCDF attribute,
-given its variable ID and name. The information returned is the
-external type in \fIxtype\fP
-and the number of elements in the attribute as \fIlen\fP.
-If any of the return arguments is a \fBNULL\fR pointer,
-the specified information will not be returned.
-.HP
-\fBint nc_copy_att(int \fIncid\fP, int \fIvarid_in\fP, const char \fIname\fP[], int \fIncid_out\fP, int \fIvarid_out\fP)\fR
-.sp
-(Corresponds to \fBncattcopy(\|)\fR in version 2)
-.sp
-Copies an
-attribute from one netCDF dataset to another. It can also be used to
-copy an attribute from one variable to another within the same netCDF.
-\fIncid_in\fP is the netCDF ID of an input netCDF dataset from which the
-attribute will be copied.
-\fIvarid_in\fP
-is the ID of the variable in the input netCDF dataset from which the
-attribute will be copied, or \fBNC_GLOBAL\fR
-for a global attribute.
-\fIname\fP
-is the name of the attribute in the input netCDF dataset to be copied.
-\fIncid_out\fP
-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
-copied does not already exist for the target variable, or if it would
-cause an existing target attribute to grow.
-\fIvarid_out\fP
-is the ID of the variable in the output netCDF dataset to which the attribute will
-be copied, or \fBNC_GLOBAL\fR to copy to a global attribute.
-.HP
-\fBint nc_rename_att(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], const char \fInewname\fP[])\fR
-.sp
-(Corresponds to \fBncattrename(\|)\fR
-.sp
-Changes the
-name of an attribute. If the new name is longer than the original name,
-the netCDF must be in define mode. You cannot rename an attribute to
-have the same name as another attribute of the same variable.
-\fIname\fP is the original attribute name.
-\fInewname\fP
-is the new name to be assigned to the specified attribute. If the new name
-is longer than the old name, the netCDF dataset must be in define mode.
-.HP
-\fBint nc_del_att(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[])\fR
-.sp
-(Corresponds to \fBncattdel(\|)\fR in version 2)
-.sp
-Deletes an attribute from a netCDF dataset. The dataset must be in
-define mode.
-.HP
-\fBint nc_get_att_text(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], char \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_uchar(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], unsigned char \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_schar(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], signed char \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_short(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], short \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_int(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], int \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_long(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], long \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_float(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], float \fIin\fP[])\fR
-.HP
-\fBint nc_get_att_double(int \fIncid\fP, int \fIvarid\fP, const char \fIname\fP[], double \fIin\fP[])\fR
-.sp
-(Replace \fBncattget(\|)\fR in version 2)
-.sp
-Gets the value(s) of a netCDF attribute, given its
-variable ID and name. Converts from the external type to the type
-specified in
-the function name, if possible, otherwise returns an \fBNC_ERANGE\fR
-error.
-All elements of the vector of attribute
-values are returned, so you must allocate enough space to hold
-them. If you don't know how much space to reserve, call
-\fBnc_inq_attlen(\|)\fR
-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
-"FUNCTION DESCRIPTIONS" section.
-.TP
-int \fIncid\fP
-is the netCDF ID returned from a previous, successful call to
-\fBnc_open(\|)\fR or \fBnc_create(\|)\fR
-.TP
-char \fIname\fP[]
-is the name of a dimension, variable, or attribute.
-It shall begin with an alphabetic character, followed by
-zero or more alphanumeric characters including the underscore
-(`_') or hyphen (`-'). Case is significant.
-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
-(excluding the terminating 0) is \fBNC_MAX_NAME\fR.
-Names that begin with an underscore (`_') are reserved for use
-by the netCDF interface.
-.TP
-nc_type \fIxtype\fP
-specifies the external data type of a netCDF variable or attribute and
-is one of the following:
-\fBNC_BYTE\fR, \fBNC_CHAR\fR, \fBNC_SHORT\fR, \fBNC_INT\fR,
-\fBNC_FLOAT\fR, or \fBNC_DOUBLE\fR.
-These are used to specify 8-bit integers,
-characters, 16-bit integers, 32-bit integers, 32-bit IEEE floating point
-numbers, and 64-bit IEEE floating-point numbers, respectively.
-(\fBNC_INT\fR corresponds to \fBNC_LONG\fR in version 2, to specify a
-32-bit integer).
-.TP
-int \fIdimids\fP[]
-is a vector of dimension ID's and defines the shape of a netCDF variable.
-The size of the vector shall be greater than or equal to the
-rank (i.e. the number of dimensions) of the variable (\fIndims\fP).
-The vector shall be ordered by the speed with which a dimension varies:
-\fIdimids\fP[\fIndims\fP-1]
-shall be the dimension ID of the most rapidly
-varying dimension and
-\fIdimids\fP[0]
-shall be the dimension ID of the most slowly
-varying dimension.
-The maximum possible number of
-dimensions for a variable is given by the symbolic constant
-\fBNC_MAX_VAR_DIMS\fR.
-.TP
-int \fIdimid\fP
-is the ID of a netCDF dimension.
-netCDF dimension ID's are allocated sequentially from the
-non-negative
-integers beginning with 0.
-.TP
-int \fIndims\fP
-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
-\fBNC_MAX_VAR_DIMS\fR.
-.TP
-int \fIvarid\fP
-is the ID of a netCDF variable or (for the attribute-access functions)
-the symbolic constant
-\fBNC_GLOBAL\fR,
-which is used to reference global attributes.
-netCDF variable ID's are allocated sequentially from the
-non-negative
-integers beginning with 0.
-.TP
-int* \fInatts\fP
-is the number of global attributes in a netCDF dataset for the
-\fBnc_inquire(\|)\fR
-function or the number
-of attributes associated with a netCDF variable for the
-\fBnc_varinq(\|)\fR
-function.
-.TP
-const size_t \fIindex\fP[]
-specifies the indicial coordinates of the netCDF data value to be accessed.
-The indices start at 0;
-thus, for example, the first data value of a
-two-dimensional variable is (0,0).
-The size of the vector shall be at least the rank of the associated
-netCDF variable and its elements shall correspond, in order, to the
-variable's dimensions.
-.TP
-const size_t \fIstart\fP[]
-specifies the starting point
-for accessing a netCDF variable's data values
-in terms of the indicial coordinates of
-the corner of the array section.
-The indices start at 0;
-thus, the first data
-value of a variable is (0, 0, ..., 0).
-The size of the vector shall be at least the rank of the associated
-netCDF variable and its elements shall correspond, in order, to the
-variable's dimensions.
-.TP
-const size_t \fIcount\fP[]
-specifies the number of indices selected along each dimension of the
-array section.
-Thus, to access a single value, for example, specify \fIcount\fP as
-(1, 1, ..., 1).
-Note that, for strided I/O, this argument must be adjusted
-to be compatible with the \fIstride\fP and \fIstart\fP arguments so that
-the interaction of the
-three does not attempt to access an invalid data co-ordinate.
-The elements of the
-\fIcount\fP vector correspond, in order, to the variable's dimensions.
-.TP
-const size_t \fIstride\fP[]
-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 (\fIstride\fP[0])
-gives the sampling interval along the most slowly
-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
-dimension, a value of 2 selects every other element, etc.).
-A \fBNULL\fR stride argument is treated as (1, 1, ... , 1).
-.TP
-\fIimap\fP
-specifies the mapping between the dimensions of a netCDF variable and
-the in-memory structure of the internal data array. The elements of
-the index mapping vector correspond, in order, to the netCDF variable's
-dimensions (\fIimap\fP[0] gives the distance
-between elements of the internal array corresponding to the most
-slowly varying dimension of the netCDF variable).
-Distances between elements are specified in type-independent units of
-elements (the distance between internal elements that occupy adjacent
-memory locations is 1 and not the element's byte-length as in netCDF 2).
-A \fBNULL\fR pointer means the memory-resident values have
-the same structure as the associated netCDF variable.
-.SH "VARIABLE PREFILLING"
-.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
-variable. This is done when \fBnc_endef(\|)\fR
-is called. The
-fill-value for a variable may be changed from the default value by
-defining the attribute `\fB_FillValue\fR' for the variable. This
-attribute must have the same type as the variable and be of length one.
-.LP
-Variables with an unlimited dimension are also prefilled, but on
-an `as needed' basis. For example, if the first write of such a
-variable is to position 5, then
-positions
-0 through 4
-(and no others)
-would be set to the fill-value at the same time.
-.LP
-This default prefilling of data values may be disabled by
-or'ing the
-\fBNC_NOFILL\fR
-flag into the mode parameter of \fBnc_open(\|)\fR or \fBnc_create(\|)\fR,
-or, by calling the function \fBnc_set_fill(\|)\fR
-with the argument \fBNC_NOFILL\fR.
-For variables that do not use the unlimited dimension,
-this call must
-be made before
-\fBnc_endef(\|)\fR.
-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
-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 \fBnc_set_fill(\|)\fR
-is per netCDF ID,
-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
-of this feature may not be available (or even needed) in future
-releases. Programmers are cautioned against heavy reliance upon this
-feature.
-.HP
-\fBint nc_setfill(int \fIncid\fP, int \fIfillmode\fP, int* \fIold_fillemode\fP)\fR
-.sp
-(Corresponds to \fBncsetfill(\|)\fR in version 2)
-.sp
-Determines whether or not variable prefilling will be done (see
-above).
-The netCDF dataset shall be writable.
-\fIfillmode\fP is either \fBNC_FILL\fR
-to enable prefilling (the
-default) or \fBNC_NOFILL\fR
-to disable prefilling.
-This function returns the previous setting in \fIold_fillmode\fP.
-.SH "ENVIRONMENT VARIABLES"
-.TP 4
-.B NETCDF_FFIOSPEC
-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
-I/O.
-The default specification is \fBbufa:336:2\fP.
-See UNICOS Flexible File I/O for more information.
-.SH "MAILING-LISTS"
-.LP
-Both a mailing list and a digest are available for
-discussion of the netCDF interface and announcements about netCDF bugs,
-fixes, and enhancements.
-To begin or change your subscription to either the mailing-list or the
-digest, send one of the following in the body (not
-the subject line) of an email message to "majordomo at unidata.ucar.edu".
-Use your email address in place of \fIjdoe at host.inst.domain\fP.
-.sp
-To subscribe to the netCDF mailing list:
-.RS
-\fBsubscribe netcdfgroup \fIjdoe at host.inst.domain\fR
-.RE
-To unsubscribe from the netCDF mailing list:
-.RS
-\fBunsubscribe netcdfgroup \fIjdoe at host.inst.domain\fR
-.RE
-To subscribe to the netCDF digest:
-.RS
-\fBsubscribe netcdfdigest \fIjdoe at host.inst.domain\fR
-.RE
-To unsubscribe from the netCDF digest:
-.RS
-\fBunsubscribe netcdfdigest \fIjdoe at host.inst.domain\fR
-.RE
-To retrieve the general introductory information for the mailing list:
-.RS
-\fBinfo netcdfgroup\fR
-.RE
-To get a synopsis of other majordomo commands:
-.RS
-\fBhelp\fR
-.RE
-.SH "SEE ALSO"
-.LP
-.BR ncdump (1),
-.BR ncgen (1),
-.BR netcdf (3).
-.LP
-\fInetCDF User's Guide\fP, published
-by the Unidata Program Center, University Corporation for Atmospheric
-Research, located in Boulder, Colorado.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/netcdf.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/netcdf.h
deleted file mode 100644
index 70ac33b..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/netcdf.h
+++ /dev/null
@@ -1,942 +0,0 @@
-/*
- * 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: netcdf.h,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $" */
-
-#ifndef _NETCDF_
-#define _NETCDF_
-
-#include <stddef.h> /* size_t, ptrdiff_t */
-#include <errno.h> /* netcdf functions sometimes return system errors */
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/*
- * The netcdf external data types
- */
-typedef enum {
- NC_BYTE = 1, /* signed 1 byte integer */
- NC_CHAR = 2, /* ISO/ASCII character */
- NC_SHORT = 3, /* signed 2 byte integer */
- NC_INT = 4, /* signed 4 byte integer */
- NC_FLOAT = 5, /* single precision floating point number */
- NC_DOUBLE = 6 /* double precision floating point number */
-} nc_type;
-
-
-/*
- * Default fill values, used unless _FillValue attribute is set.
- * These values are stuffed into newly allocated space as appropriate.
- * The hope is that one might use these to notice that a particular datum
- * has not been set.
- */
-#define NC_FILL_BYTE ((signed char)-127)
-#define NC_FILL_CHAR ((char)0)
-#define NC_FILL_SHORT ((short)-32767)
-#define NC_FILL_INT (-2147483647L)
-#define NC_FILL_FLOAT (9.9692099683868690e+36f) /* near 15 * 2^119 */
-#define NC_FILL_DOUBLE (9.9692099683868690e+36)
-
-
-/*
- * The above values are defaults.
- * If you wish a variable to use a different value than the above
- * defaults, create an attribute with the same type as the variable
- * and the following reserved name. The value you give the attribute
- * will be used as the fill value for that variable.
- */
-#define _FillValue "_FillValue"
-
-
-/*
- * 'mode' flags for nccreate and ncopen
- */
-#define NC_NOWRITE 0 /* default is read only */
-#define NC_WRITE 0x1 /* read & write */
-#define NC_CLOBBER 0
-#define NC_NOCLOBBER 0x4 /* Don't destroy existing file on create */
-#define NC_FILL 0 /* argument to ncsetfill to clear NC_NOFILL */
-#define NC_NOFILL 0x100 /* Don't fill data section an records */
-#define NC_LOCK 0x0400 /* Use locking if available */
-#define NC_SHARE 0x0800 /* Share updates, limit cacheing */
-
-/*
- * Let nc__create() or nc__open() figure out
- * as suitable chunk size.
- */
-#define NC_SIZEHINT_DEFAULT 0
-
-/*
- * In nc__enddef(), align to the chunk size.
- */
-#define NC_ALIGN_CHUNK ((size_t)(-1))
-
-/*
- * 'size' argument to ncdimdef for an unlimited dimension
- */
-#define NC_UNLIMITED 0L
-
-/*
- * attribute id to put/get a global attribute
- */
-#define NC_GLOBAL -1
-
-
-/*
- * These maximums are enforced by the interface, to facilitate writing
- * applications and utilities. However, nothing is statically allocated to
- * these sizes internally.
- */
-#define NC_MAX_DIMS 100 /* max dimensions per file */
-#define NC_MAX_ATTRS 2000 /* max global or per variable attributes */
-#define NC_MAX_VARS 2000 /* max variables per file */
-#define NC_MAX_NAME 128 /* max length of a name */
-#define NC_MAX_VAR_DIMS NC_MAX_DIMS /* max per variable dimensions */
-
-
-/*
- * The netcdf version 3 functions all return integer error status.
- * These are the possible values, in addition to certain
- * values from the system errno.h.
- */
-
-#define NC_ISSYSERR(err) ((err) > 0)
-
-#define NC_NOERR 0 /* No Error */
-
-#define NC_EBADID (-33) /* Not a netcdf id */
-#define NC_ENFILE (-34) /* Too many netcdfs open */
-#define NC_EEXIST (-35) /* netcdf file exists && NC_NOCLOBBER */
-#define NC_EINVAL (-36) /* Invalid Argument */
-#define NC_EPERM (-37) /* Write to read only */
-#define NC_ENOTINDEFINE (-38) /* Operation not allowed in data mode */
-#define NC_EINDEFINE (-39) /* Operation not allowed in define mode */
-#define NC_EINVALCOORDS (-40) /* Index exceeds dimension bound */
-#define NC_EMAXDIMS (-41) /* NC_MAX_DIMS exceeded */
-#define NC_ENAMEINUSE (-42) /* String match to name in use */
-#define NC_ENOTATT (-43) /* Attribute not found */
-#define NC_EMAXATTS (-44) /* NC_MAX_ATTRS exceeded */
-#define NC_EBADTYPE (-45) /* Not a netcdf data type */
-#define NC_EBADDIM (-46) /* Invalid dimension id or name */
-#define NC_EUNLIMPOS (-47) /* NC_UNLIMITED in the wrong index */
-#define NC_EMAXVARS (-48) /* NC_MAX_VARS exceeded */
-#define NC_ENOTVAR (-49) /* Variable not found */
-#define NC_EGLOBAL (-50) /* Action prohibited on NC_GLOBAL varid */
-#define NC_ENOTNC (-51) /* Not a netcdf file */
-#define NC_ESTS (-52) /* In Fortran, string too short */
-#define NC_EMAXNAME (-53) /* NC_MAX_NAME exceeded */
-#define NC_EUNLIMIT (-54) /* NC_UNLIMITED size already in use */
-#define NC_ENORECVARS (-55) /* nc_rec op when there are no record vars */
-#define NC_ECHAR (-56) /* Attempt to convert between text & numbers */
-#define NC_EEDGE (-57) /* Edge+start exceeds dimension bound */
-#define NC_ESTRIDE (-58) /* Illegal stride */
-#define NC_EBADNAME (-59) /* Attribute or variable name
- contains illegal characters */
-/* N.B. must match value in ncx.h */
-#define NC_ERANGE (-60) /* Math result not representable */
-#define NC_ENOMEM (-61) /* Memory allocation (malloc) failure */
-
-/*
- * The Interface
- */
-
-/* Declaration modifiers for DLL support (MSC et al) */
-
-#if defined(DLL_NETCDF) /* define when library is a DLL */
-# if defined(DLL_EXPORT) /* define when building the library */
-# define MSC_EXTRA __declspec(dllexport)
-# else
-# define MSC_EXTRA __declspec(dllimport)
-# endif
-#else
-#define MSC_EXTRA
-#endif /* defined(DLL_NETCDF) */
-
-# define EXTERNL extern MSC_EXTRA
-
-EXTERNL const char *
-nc_inq_libvers(void);
-
-EXTERNL const char *
-nc_strerror(int ncerr);
-
-EXTERNL int
-nc__create(const char *path, int cmode, size_t initialsz,
- size_t *chunksizehintp, int *ncidp);
-
-EXTERNL int
-nc_create(const char *path, int cmode, int *ncidp);
-
-EXTERNL int
-nc__open(const char *path, int mode,
- size_t *chunksizehintp, int *ncidp);
-
-EXTERNL int
-nc_open(const char *path, int mode, int *ncidp);
-
-EXTERNL int
-nc_set_fill(int ncid, int fillmode, int *old_modep);
-
-EXTERNL int
-nc_redef(int ncid);
-
-EXTERNL int
-nc__enddef(int ncid, size_t h_minfree, size_t v_align,
- size_t v_minfree, size_t r_align);
-
-EXTERNL int
-nc_enddef(int ncid);
-
-EXTERNL int
-nc_sync(int ncid);
-
-EXTERNL int
-nc_abort(int ncid);
-
-EXTERNL int
-nc_close(int ncid);
-
-EXTERNL int
-nc_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp);
-
-EXTERNL int
-nc_inq_ndims(int ncid, int *ndimsp);
-
-EXTERNL int
-nc_inq_nvars(int ncid, int *nvarsp);
-
-EXTERNL int
-nc_inq_natts(int ncid, int *nattsp);
-
-EXTERNL int
-nc_inq_unlimdim(int ncid, int *unlimdimidp);
-
-/* Begin _dim */
-
-EXTERNL int
-nc_def_dim(int ncid, const char *name, size_t len, int *idp);
-
-EXTERNL int
-nc_inq_dimid(int ncid, const char *name, int *idp);
-
-EXTERNL int
-nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp);
-
-EXTERNL int
-nc_inq_dimname(int ncid, int dimid, char *name);
-
-EXTERNL int
-nc_inq_dimlen(int ncid, int dimid, size_t *lenp);
-
-EXTERNL int
-nc_rename_dim(int ncid, int dimid, const char *name);
-
-/* End _dim */
-/* Begin _att */
-
-EXTERNL int
-nc_inq_att(int ncid, int varid, const char *name,
- nc_type *xtypep, size_t *lenp);
-
-EXTERNL int
-nc_inq_attid(int ncid, int varid, const char *name, int *idp);
-
-EXTERNL int
-nc_inq_atttype(int ncid, int varid, const char *name, nc_type *xtypep);
-
-EXTERNL int
-nc_inq_attlen(int ncid, int varid, const char *name, size_t *lenp);
-
-EXTERNL int
-nc_inq_attname(int ncid, int varid, int attnum, char *name);
-
-EXTERNL int
-nc_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out, int varid_out);
-
-EXTERNL int
-nc_rename_att(int ncid, int varid, const char *name, const char *newname);
-
-EXTERNL int
-nc_del_att(int ncid, int varid, const char *name);
-
-/* End _att */
-/* Begin {put,get}_att */
-
-EXTERNL int
-nc_put_att_text(int ncid, int varid, const char *name,
- size_t len, const char *op);
-
-EXTERNL int
-nc_get_att_text(int ncid, int varid, const char *name, char *ip);
-
-EXTERNL int
-nc_put_att_uchar(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const unsigned char *op);
-
-EXTERNL int
-nc_get_att_uchar(int ncid, int varid, const char *name, unsigned char *ip);
-
-EXTERNL int
-nc_put_att_schar(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const signed char *op);
-
-EXTERNL int
-nc_get_att_schar(int ncid, int varid, const char *name, signed char *ip);
-
-EXTERNL int
-nc_put_att_short(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const short *op);
-
-EXTERNL int
-nc_get_att_short(int ncid, int varid, const char *name, short *ip);
-
-EXTERNL int
-nc_put_att_int(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const int *op);
-
-EXTERNL int
-nc_get_att_int(int ncid, int varid, const char *name, int *ip);
-
-EXTERNL int
-nc_put_att_long(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const long *op);
-
-EXTERNL int
-nc_get_att_long(int ncid, int varid, const char *name, long *ip);
-
-EXTERNL int
-nc_put_att_float(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const float *op);
-
-EXTERNL int
-nc_get_att_float(int ncid, int varid, const char *name, float *ip);
-
-EXTERNL int
-nc_put_att_double(int ncid, int varid, const char *name, nc_type xtype,
- size_t len, const double *op);
-
-EXTERNL int
-nc_get_att_double(int ncid, int varid, const char *name, double *ip);
-
-/* End {put,get}_att */
-/* Begin _var */
-
-EXTERNL int
-nc_def_var(int ncid, const char *name,
- nc_type xtype, int ndims, const int *dimidsp, int *varidp);
-
-EXTERNL int
-nc_inq_var(int ncid, int varid, char *name,
- nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp);
-
-EXTERNL int
-nc_inq_varid(int ncid, const char *name, int *varidp);
-
-EXTERNL int
-nc_inq_varname(int ncid, int varid, char *name);
-
-EXTERNL int
-nc_inq_vartype(int ncid, int varid, nc_type *xtypep);
-
-EXTERNL int
-nc_inq_varndims(int ncid, int varid, int *ndimsp);
-
-EXTERNL int
-nc_inq_vardimid(int ncid, int varid, int *dimidsp);
-
-EXTERNL int
-nc_inq_varnatts(int ncid, int varid, int *nattsp);
-
-EXTERNL int
-nc_rename_var(int ncid, int varid, const char *name);
-
-EXTERNL int
-nc_copy_var(int ncid_in, int varid, int ncid_out);
-#ifndef ncvarcpy
-/* support the old name for now */
-#define ncvarcpy(ncid_in, varid, ncid_out) ncvarcopy((ncid_in), (varid), (ncid_out))
-#endif
-
-/* End _var */
-/* Begin {put,get}_var1 */
-
-EXTERNL int
-nc_put_var1_text(int ncid, int varid, const size_t *indexp, const char *op);
-
-EXTERNL int
-nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip);
-
-EXTERNL int
-nc_put_var1_uchar(int ncid, int varid, const size_t *indexp,
- const unsigned char *op);
-
-EXTERNL int
-nc_get_var1_uchar(int ncid, int varid, const size_t *indexp,
- unsigned char *ip);
-
-EXTERNL int
-nc_put_var1_schar(int ncid, int varid, const size_t *indexp,
- const signed char *op);
-
-EXTERNL int
-nc_get_var1_schar(int ncid, int varid, const size_t *indexp,
- signed char *ip);
-
-EXTERNL int
-nc_put_var1_short(int ncid, int varid, const size_t *indexp,
- const short *op);
-
-EXTERNL int
-nc_get_var1_short(int ncid, int varid, const size_t *indexp,
- short *ip);
-
-EXTERNL int
-nc_put_var1_int(int ncid, int varid, const size_t *indexp, const int *op);
-
-EXTERNL int
-nc_get_var1_int(int ncid, int varid, const size_t *indexp, int *ip);
-
-EXTERNL int
-nc_put_var1_long(int ncid, int varid, const size_t *indexp, const long *op);
-
-EXTERNL int
-nc_get_var1_long(int ncid, int varid, const size_t *indexp, long *ip);
-
-EXTERNL int
-nc_put_var1_float(int ncid, int varid, const size_t *indexp, const float *op);
-
-EXTERNL int
-nc_get_var1_float(int ncid, int varid, const size_t *indexp, float *ip);
-
-EXTERNL int
-nc_put_var1_double(int ncid, int varid, const size_t *indexp, const double *op);
-
-EXTERNL int
-nc_get_var1_double(int ncid, int varid, const size_t *indexp, double *ip);
-
-/* End {put,get}_var1 */
-/* Begin {put,get}_vara */
-
-EXTERNL int
-nc_put_vara_text(int ncid, int varid,
- const size_t *startp, const size_t *countp, const char *op);
-
-EXTERNL int
-nc_get_vara_text(int ncid, int varid,
- const size_t *startp, const size_t *countp, char *ip);
-
-EXTERNL int
-nc_put_vara_uchar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const unsigned char *op);
-
-EXTERNL int
-nc_get_vara_uchar(int ncid, int varid,
- const size_t *startp, const size_t *countp, unsigned char *ip);
-
-EXTERNL int
-nc_put_vara_schar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const signed char *op);
-
-EXTERNL int
-nc_get_vara_schar(int ncid, int varid,
- const size_t *startp, const size_t *countp, signed char *ip);
-
-EXTERNL int
-nc_put_vara_short(int ncid, int varid,
- const size_t *startp, const size_t *countp, const short *op);
-
-EXTERNL int
-nc_get_vara_short(int ncid, int varid,
- const size_t *startp, const size_t *countp, short *ip);
-
-EXTERNL int
-nc_put_vara_int(int ncid, int varid,
- const size_t *startp, const size_t *countp, const int *op);
-
-EXTERNL int
-nc_get_vara_int(int ncid, int varid,
- const size_t *startp, const size_t *countp, int *ip);
-
-EXTERNL int
-nc_put_vara_long(int ncid, int varid,
- const size_t *startp, const size_t *countp, const long *op);
-
-EXTERNL int
-nc_get_vara_long(int ncid, int varid,
- const size_t *startp, const size_t *countp, long *ip);
-
-EXTERNL int
-nc_put_vara_float(int ncid, int varid,
- const size_t *startp, const size_t *countp, const float *op);
-
-EXTERNL int
-nc_get_vara_float(int ncid, int varid,
- const size_t *startp, const size_t *countp, float *ip);
-
-EXTERNL int
-nc_put_vara_double(int ncid, int varid,
- const size_t *startp, const size_t *countp, const double *op);
-
-EXTERNL int
-nc_get_vara_double(int ncid, int varid,
- const size_t *startp, const size_t *countp, double *ip);
-
-/* End {put,get}_vara */
-/* Begin {put,get}_vars */
-
-EXTERNL int
-nc_put_vars_text(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const char *op);
-
-EXTERNL int
-nc_get_vars_text(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- char *ip);
-
-EXTERNL int
-nc_put_vars_uchar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const unsigned char *op);
-
-EXTERNL int
-nc_get_vars_uchar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- unsigned char *ip);
-
-EXTERNL int
-nc_put_vars_schar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const signed char *op);
-
-EXTERNL int
-nc_get_vars_schar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- signed char *ip);
-
-EXTERNL int
-nc_put_vars_short(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const short *op);
-
-EXTERNL int
-nc_get_vars_short(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- short *ip);
-
-EXTERNL int
-nc_put_vars_int(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const int *op);
-
-EXTERNL int
-nc_get_vars_int(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- int *ip);
-
-EXTERNL int
-nc_put_vars_long(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const long *op);
-
-EXTERNL int
-nc_get_vars_long(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- long *ip);
-
-EXTERNL int
-nc_put_vars_float(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const float *op);
-
-EXTERNL int
-nc_get_vars_float(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- float *ip);
-
-EXTERNL int
-nc_put_vars_double(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const double *op);
-
-EXTERNL int
-nc_get_vars_double(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- double *ip);
-
-/* End {put,get}_vars */
-/* Begin {put,get}_varm */
-
-EXTERNL int
-nc_put_varm_text(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const char *op);
-
-EXTERNL int
-nc_get_varm_text(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- char *ip);
-
-EXTERNL int
-nc_put_varm_uchar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const unsigned char *op);
-
-EXTERNL int
-nc_get_varm_uchar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- unsigned char *ip);
-
-EXTERNL int
-nc_put_varm_schar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const signed char *op);
-
-EXTERNL int
-nc_get_varm_schar(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- signed char *ip);
-
-EXTERNL int
-nc_put_varm_short(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const short *op);
-
-EXTERNL int
-nc_get_varm_short(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- short *ip);
-
-EXTERNL int
-nc_put_varm_int(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const int *op);
-
-EXTERNL int
-nc_get_varm_int(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- int *ip);
-
-EXTERNL int
-nc_put_varm_long(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const long *op);
-
-EXTERNL int
-nc_get_varm_long(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- long *ip);
-
-EXTERNL int
-nc_put_varm_float(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const float *op);
-
-EXTERNL int
-nc_get_varm_float(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- float *ip);
-
-EXTERNL int
-nc_put_varm_double(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t *imapp,
- const double *op);
-
-EXTERNL int
-nc_get_varm_double(int ncid, int varid,
- const size_t *startp, const size_t *countp, const ptrdiff_t *stridep,
- const ptrdiff_t * imap,
- double *ip);
-
-/* End {put,get}_varm */
-/* Begin {put,get}_var */
-
-EXTERNL int
-nc_put_var_text(int ncid, int varid, const char *op);
-
-EXTERNL int
-nc_get_var_text(int ncid, int varid, char *ip);
-
-EXTERNL int
-nc_put_var_uchar(int ncid, int varid, const unsigned char *op);
-
-EXTERNL int
-nc_get_var_uchar(int ncid, int varid, unsigned char *ip);
-
-EXTERNL int
-nc_put_var_schar(int ncid, int varid, const signed char *op);
-
-EXTERNL int
-nc_get_var_schar(int ncid, int varid, signed char *ip);
-
-EXTERNL int
-nc_put_var_short(int ncid, int varid, const short *op);
-
-EXTERNL int
-nc_get_var_short(int ncid, int varid, short *ip);
-
-EXTERNL int
-nc_put_var_int(int ncid, int varid, const int *op);
-
-EXTERNL int
-nc_get_var_int(int ncid, int varid, int *ip);
-
-EXTERNL int
-nc_put_var_long(int ncid, int varid, const long *op);
-
-EXTERNL int
-nc_get_var_long(int ncid, int varid, long *ip);
-
-EXTERNL int
-nc_put_var_float(int ncid, int varid, const float *op);
-
-EXTERNL int
-nc_get_var_float(int ncid, int varid, float *ip);
-
-EXTERNL int
-nc_put_var_double(int ncid, int varid, const double *op);
-
-EXTERNL int
-nc_get_var_double(int ncid, int varid, double *ip);
-
-/* End {put,get}_var */
-
-/* Begin v2.4 backward compatiblity */
-/*
- * defining NO_NETCDF_2 to the preprocessor
- * turns off backward compatiblity declarations.
- */
-#ifndef NO_NETCDF_2
-
-/*
- * Backward compatible aliases
- */
-#define FILL_BYTE NC_FILL_BYTE
-#define FILL_CHAR NC_FILL_CHAR
-#define FILL_SHORT NC_FILL_SHORT
-#define FILL_LONG NC_FILL_INT
-#define FILL_FLOAT NC_FILL_FLOAT
-#define FILL_DOUBLE NC_FILL_DOUBLE
-
-#define MAX_NC_DIMS NC_MAX_DIMS
-#define MAX_NC_ATTRS NC_MAX_ATTRS
-#define MAX_NC_VARS NC_MAX_VARS
-#define MAX_NC_NAME NC_MAX_NAME
-#define MAX_VAR_DIMS NC_MAX_VAR_DIMS
-
-/*
- * If and when 64 integer types become ubiquitous,
- * we would like to use NC_LONG for that.
- * For now, define for backward compatibility.
- */
-#define NC_LONG NC_INT
-
-/*
- * Global error status
- */
-EXTERNL int ncerr;
-
-#define NC_ENTOOL NC_EMAXNAME /* Backward compatibility */
-#define NC_EXDR (-32) /* */
-#define NC_SYSERR (-31)
-
-/*
- * Avoid use of this meaningless macro
- * Use sysconf(_SC_OPEN_MAX).
- */
-#ifndef MAX_NC_OPEN
-#define MAX_NC_OPEN 32
-#endif
-
-/*
- * Global options variable.
- * Used to determine behavior of error handler.
- */
-#define NC_FATAL 1
-#define NC_VERBOSE 2
-
-EXTERNL int ncopts; /* default is (NC_FATAL | NC_VERBOSE) */
-
-EXTERNL void
-nc_advise(const char *cdf_routine_name, int err, const char *fmt,...);
-
-/*
- * C data type corresponding to a netCDF NC_LONG argument,
- * a signed 32 bit object.
- *
- * This is the only thing in this file which architecture dependent.
- */
-typedef int nclong;
-
-EXTERNL int
-nctypelen(nc_type datatype);
-
-EXTERNL int
-nccreate(const char* path, int cmode);
-
-EXTERNL int
-ncopen(const char* path, int mode);
-
-EXTERNL int
-ncsetfill(int ncid, int fillmode);
-
-EXTERNL int
-ncredef(int ncid);
-
-EXTERNL int
-ncendef(int ncid);
-
-EXTERNL int
-ncsync(int ncid);
-
-EXTERNL int
-ncabort(int ncid);
-
-EXTERNL int
-ncclose(int ncid);
-
-EXTERNL int
-ncinquire(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimp);
-
-EXTERNL int
-ncdimdef(int ncid, const char *name, long len);
-
-EXTERNL int
-ncdimid(int ncid, const char *name);
-
-EXTERNL int
-ncdiminq(int ncid, int dimid, char *name, long *lenp);
-
-EXTERNL int
-ncdimrename(int ncid, int dimid, const char *name);
-
-EXTERNL int
-ncattput(int ncid, int varid, const char *name, nc_type xtype,
- int len, const void *op);
-
-EXTERNL int
-ncattinq(int ncid, int varid, const char *name, nc_type *xtypep, int *lenp);
-
-EXTERNL int
-ncattget(int ncid, int varid, const char *name, void *ip);
-
-EXTERNL int
-ncattcopy(int ncid_in, int varid_in, const char *name, int ncid_out,
- int varid_out);
-
-EXTERNL int
-ncattname(int ncid, int varid, int attnum, char *name);
-
-EXTERNL int
-ncattrename(int ncid, int varid, const char *name, const char *newname);
-
-EXTERNL int
-ncattdel(int ncid, int varid, const char *name);
-
-EXTERNL int
-ncvardef(int ncid, const char *name, nc_type xtype,
- int ndims, const int *dimidsp);
-
-EXTERNL int
-ncvarid(int ncid, const char *name);
-
-EXTERNL int
-ncvarinq(int ncid, int varid, char *name, nc_type *xtypep,
- int *ndimsp, int *dimidsp, int *nattsp);
-
-EXTERNL int
-ncvarput1(int ncid, int varid, const long *indexp, const void *op);
-
-EXTERNL int
-ncvarget1(int ncid, int varid, const long *indexp, void *ip);
-
-EXTERNL int
-ncvarput(int ncid, int varid, const long *startp, const long *countp,
- const void *op);
-
-EXTERNL int
-ncvarget(int ncid, int varid, const long *startp, const long *countp,
- void *ip);
-
-EXTERNL int
-ncvarputs(int ncid, int varid, const long *startp, const long *countp,
- const long *stridep, const void *op);
-
-EXTERNL int
-ncvargets(int ncid, int varid, const long *startp, const long *countp,
- const long *stridep, void *ip);
-
-EXTERNL int
-ncvarputg(int ncid, int varid, const long *startp, const long *countp,
- const long *stridep, const long *imapp, const void *op);
-
-EXTERNL int
-ncvargetg(int ncid, int varid, const long *startp, const long *countp,
- const long *stridep, const long *imapp, void *ip);
-
-EXTERNL int
-ncvarrename(int ncid, int varid, const char *name);
-
-EXTERNL int
-ncrecinq(int ncid, int *nrecvarsp, int *recvaridsp, long *recsizesp);
-
-EXTERNL int
-ncrecget(int ncid, long recnum, void **datap);
-
-EXTERNL int
-ncrecput(int ncid, long recnum, void *const *datap);
-
-/* End v2.4 backward compatiblity */
-#endif /*!NO_NETCDF_2*/
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* _NETCDF_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/onstack.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/onstack.h
deleted file mode 100644
index b382ef8..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/onstack.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 1997, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: onstack.h,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $ */
-
-#ifndef _ONSTACK_H_
-#define _ONSTACK_H_
-/* include after ncconfig.h */
-/**
- * This file provides definitions which allow us to
- * "allocate" arrays on the stack where possible.
- * (Where not possible, malloc and free are used.)
- *
- * The macro ALLOC_ONSTACK(name, type, nelems) is used to declare
- * an array of 'type' named 'name' which is 'nelems' long.
- * FREE_ONSTACK(name) is placed at the end of the scope of 'name'
- * to call 'free' if necessary.
- *
- * The macro ALLOC_ONSTACK wraps a call to alloca() on most systems.
- */
-
-#if HAVE_ALLOCA
-/*
- * Implementation based on alloca()
- */
-
-#if defined(__GNUC__)
-# if !defined(alloca)
-# define alloca __builtin_alloca
-# endif
-#else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# elif defined(_AIX)
-# pragma alloca
-# endif /* HAVE_ALLOCA_H */
-#endif /* __GNUC__ */
-
-# if !defined(ALLOCA_ARG_T)
-# define ALLOCA_ARG_T int /* the usual type of the alloca argument */
-# endif
-
-# define ALLOC_ONSTACK(name, type, nelems) \
- type *const name = (type *) alloca((ALLOCA_ARG_T)((nelems) * sizeof(type)))
-
-# define FREE_ONSTACK(name)
-
-#elif defined(_CRAYC) && !__cplusplus && __STDC__ > 1
-/*
- * Cray C allows sizing of arrays with non-constant values.
- */
-
-# define ALLOC_ONSTACK(name, type, nelems) \
- type name[nelems]
-
-# define FREE_ONSTACK(name)
-
-#else
-/*
- * Default implementation. When all else fails, use malloc/free.
- */
-
-# define ALLOC_ONSTACK(name, type, nelems) \
- type *const name = (type *) malloc((nelems) * sizeof(type))
-
-# define FREE_ONSTACK(name) \
- free(name)
-
-#endif
-
-#endif /* _ONSTACK_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/posixio.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/posixio.c
deleted file mode 100644
index c60e916..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/posixio.c
+++ /dev/null
@@ -1,1294 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: posixio.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "ncconfig.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifndef ENOERR
-#define ENOERR 0
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#ifdef _MSC_VER /* Microsoft Compilers */
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif
-
-#include "ncio.h"
-#include "fbits.h"
-#include "rnd.h"
-
-/* #define INSTRUMENT 1 */
-#if INSTRUMENT /* debugging */
-#undef NDEBUG
-#include <stdio.h>
-#include "instr.h"
-#endif
-
-#undef MIN /* system may define MIN somewhere and complain */
-#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))
-
-#if !defined(NDEBUG) && !defined(X_INT_MAX)
-#define X_INT_MAX 2147483647
-#endif
-
-#if 0 /* !defined(NDEBUG) && !defined(X_ALIGN) */
-#define X_ALIGN 4
-#else
-#undef X_ALIGN
-#endif
-
-/*
- * Define the following for debugging.
- */
-/* #define ALWAYS_NC_SHARE 1 */
-
-/* Begin OS */
-
-#ifndef POSIXIO_DEFAULT_PAGESIZE
-#define POSIXIO_DEFAULT_PAGESIZE 4096
-#endif
-/*
- * What is the system pagesize?
- */
-static size_t
-pagesize(void)
-{
-/* Hmm, aren't standards great? */
-#if defined(_SC_PAGE_SIZE) && !defined(_SC_PAGESIZE)
-#define _SC_PAGESIZE _SC_PAGE_SIZE
-#endif
-
-#ifdef _SC_PAGESIZE
- {
- const long pgsz = sysconf(_SC_PAGESIZE);
- if(pgsz > 0)
- return (size_t) pgsz;
- /* else, silent in the face of error */
- }
-#elif defined(HAVE_GETPAGESIZE)
- return (size_t) getpagesize();
-#endif
- return (size_t) POSIXIO_DEFAULT_PAGESIZE;
-}
-
-/*
- * What is the preferred I/O block size?
- */
-static size_t
-blksize(int fd)
-{
-#if defined(HAVE_ST_BLKSIZE)
- struct stat sb;
- if (fstat(fd, &sb) > -1)
- {
- return (size_t) sb.st_blksize;
- }
- /* else, silent in the face of error */
-#endif
- return (size_t) 2 * pagesize();
-}
-
-
-/*
- * Sortof like ftruncate, except won't make the
- * file shorter.
- */
-static int
-fgrow(const int fd, const off_t len)
-{
- struct stat sb;
- if (fstat(fd, &sb) < 0)
- return errno;
- if (len < sb.st_size)
- return ENOERR;
-#if defined(HAVE_FTRUNCATE)
- if (ftruncate(fd, len) < 0)
- return errno;
-#else
- {
- const long dumb = 0;
- /* cache current position */
- const off_t pos = lseek(fd, 0, SEEK_CUR);
- if(pos < 0)
- return errno;
- if (lseek(fd, len-sizeof(dumb), SEEK_SET) < 0)
- return errno;
- if(write(fd, &dumb, sizeof(dumb)) < 0)
- return errno;
- if (lseek(fd, pos, SEEK_SET) < 0)
- return errno;
- }
-#endif /* HAVE_FTRUNCATE */
- /* else */
- return ENOERR;
-}
-
-/* End OS */
-/* Begin px */
-
-static int
-px_pgout(ncio *const nciop,
- off_t const offset, const size_t extent,
- void *const vp, off_t *posp)
-{
-#ifdef X_ALIGN
- assert(offset % X_ALIGN == 0);
-#endif
-
- assert(*posp == OFF_NONE || *posp == lseek(nciop->fd, 0, SEEK_CUR));
-
- if(*posp != offset)
- {
- if(lseek(nciop->fd, offset, SEEK_SET) != offset)
- {
- return errno;
- }
- *posp = offset;
- }
- if(write(nciop->fd, vp, extent) != (ssize_t) extent)
- {
- return errno;
- }
- *posp += extent;
-
- return ENOERR;
-}
-
-
-static int
-px_pgin(ncio *const nciop,
- off_t const offset, const size_t extent,
- void *const vp, size_t *nreadp, off_t *posp)
-{
- int status;
- ssize_t nread;
-
-#ifdef X_ALIGN
- assert(offset % X_ALIGN == 0);
- assert(extent % X_ALIGN == 0);
-#endif
-
- assert(*posp == OFF_NONE || *posp == lseek(nciop->fd, 0, SEEK_CUR));
-
- if(*posp != offset)
- {
- if(lseek(nciop->fd, offset, SEEK_SET) != offset)
- {
- status = errno;
- return status;
- }
- *posp = offset;
- }
-
- errno = 0;
- nread = read(nciop->fd, vp, extent);
- if(nread != (ssize_t) extent)
- {
- status = errno;
- if(nread == -1 || status != ENOERR)
- return status;
- /* else it's okay we read less than asked for */
- (void) memset((char *)vp + nread, 0, (ssize_t)extent - nread);
- }
- *nreadp = nread;
- *posp += nread;
-
- return ENOERR;
-}
-
-
-typedef struct ncio_px {
- size_t blksz;
- off_t pos;
- /* buffer */
- off_t bf_offset;
- size_t bf_extent;
- size_t bf_cnt;
- void *bf_base;
- int bf_rflags;
- int bf_refcount;
- /* chain for double buffering in px_move */
- struct ncio_px *slave;
-} ncio_px;
-
-
-/*ARGSUSED*/
-static int
-px_rel(ncio_px *const pxp, off_t offset, int rflags)
-{
- assert(pxp->bf_offset <= offset
- && offset < pxp->bf_offset + (off_t) pxp->bf_extent);
- assert(pIf(fIsSet(rflags, RGN_MODIFIED),
- fIsSet(pxp->bf_rflags, RGN_WRITE)));
-
- if(fIsSet(rflags, RGN_MODIFIED))
- {
- fSet(pxp->bf_rflags, RGN_MODIFIED);
- }
- pxp->bf_refcount--;
-
- return ENOERR;
-}
-
-static int
-ncio_px_rel(ncio *const nciop, off_t offset, int rflags)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
-
- if(fIsSet(rflags, RGN_MODIFIED) && !fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- return px_rel(pxp, offset, rflags);
-}
-
-static int
-px_get(ncio *const nciop, ncio_px *const pxp,
- off_t offset, size_t extent,
- int rflags,
- void **const vpp)
-{
- int status = ENOERR;
-
- const off_t blkoffset = _RNDDOWN(offset, (off_t)pxp->blksz);
- size_t diff = (size_t)(offset - blkoffset);
- size_t blkextent = _RNDUP(diff + extent, pxp->blksz);
-
- assert(extent != 0);
- assert(extent < X_INT_MAX); /* sanity check */
- assert(offset >= 0); /* sanity check */
- assert(offset < X_INT_MAX); /* sanity check */
-
- if(2 * pxp->blksz < blkextent)
- return E2BIG; /* TODO: temporary kludge */
- if(pxp->bf_offset == OFF_NONE)
- {
- /* Uninitialized */
- if(pxp->bf_base == NULL)
- {
- assert(pxp->bf_extent == 0);
- assert(blkextent <= 2 * pxp->blksz);
- pxp->bf_base = malloc(2 * pxp->blksz);
- if(pxp->bf_base == NULL)
- return ENOMEM;
- }
- goto pgin;
- }
- /* else */
- assert(blkextent <= 2 * pxp->blksz);
-
- if(blkoffset == pxp->bf_offset)
- {
- /* hit */
- if(blkextent > pxp->bf_extent)
- {
- /* page in upper */
- void *const middle =
- (void *)((char *)pxp->bf_base + pxp->blksz);
- assert(pxp->bf_extent == pxp->blksz);
- status = px_pgin(nciop,
- pxp->bf_offset + (off_t)pxp->blksz,
- pxp->blksz,
- middle,
- &pxp->bf_cnt,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- pxp->bf_extent = 2 * pxp->blksz;
- pxp->bf_cnt += pxp->blksz;
- }
- goto done;
- }
- /* else */
-
- if(pxp->bf_extent > pxp->blksz
- && blkoffset == pxp->bf_offset + pxp->blksz)
- {
- /* hit in upper half */
- if(blkextent == pxp->blksz)
- {
- /* all in upper half, no fault needed */
- diff += pxp->blksz;
- goto done;
- }
- /* else */
- if(pxp->bf_cnt > pxp->blksz)
- {
- /* data in upper half */
- void *const middle =
- (void *)((char *)pxp->bf_base + pxp->blksz);
- assert(pxp->bf_extent == 2 * pxp->blksz);
- if(fIsSet(pxp->bf_rflags, RGN_MODIFIED))
- {
- /* page out lower half */
- assert(pxp->bf_refcount <= 0);
- status = px_pgout(nciop,
- pxp->bf_offset,
- pxp->blksz,
- pxp->bf_base,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- }
- pxp->bf_cnt -= pxp->blksz;
- /* copy upper half into lower half */
- (void) memcpy(pxp->bf_base, middle, pxp->bf_cnt);
- }
- pxp->bf_offset = blkoffset;
- /* pxp->bf_extent = pxp->blksz; */
-
- assert(blkextent == 2 * pxp->blksz);
- {
- /* page in upper */
- void *const middle =
- (void *)((char *)pxp->bf_base + pxp->blksz);
- status = px_pgin(nciop,
- pxp->bf_offset + (off_t)pxp->blksz,
- pxp->blksz,
- middle,
- &pxp->bf_cnt,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- pxp->bf_extent = 2 * pxp->blksz;
- pxp->bf_cnt += pxp->blksz;
- }
- goto done;
- }
- /* else */
-
- if(blkoffset == pxp->bf_offset - pxp->blksz)
- {
- /* wants the page below */
- void *const middle =
- (void *)((char *)pxp->bf_base + pxp->blksz);
- size_t upper_cnt = 0;
- if(pxp->bf_cnt > pxp->blksz)
- {
- /* data in upper half */
- assert(pxp->bf_extent == 2 * pxp->blksz);
- if(fIsSet(pxp->bf_rflags, RGN_MODIFIED))
- {
- /* page out upper half */
- assert(pxp->bf_refcount <= 0);
- status = px_pgout(nciop,
- pxp->bf_offset + (off_t)pxp->blksz,
- pxp->bf_cnt - pxp->blksz,
- middle,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- }
- pxp->bf_cnt = pxp->blksz;
- pxp->bf_extent = pxp->blksz;
- }
- if(pxp->bf_cnt > 0)
- {
- /* copy lower half into upper half */
- (void) memcpy(middle, pxp->bf_base, pxp->blksz);
- upper_cnt = pxp->bf_cnt;
- }
- /* read page below into lower half */
- status = px_pgin(nciop,
- blkoffset,
- pxp->blksz,
- pxp->bf_base,
- &pxp->bf_cnt,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- pxp->bf_offset = blkoffset;
- if(upper_cnt != 0)
- {
- pxp->bf_extent = 2 * pxp->blksz;
- pxp->bf_cnt = pxp->blksz + upper_cnt;
- }
- else
- {
- pxp->bf_extent = pxp->blksz;
- }
- goto done;
- }
- /* else */
-
- /* no overlap */
- if(fIsSet(pxp->bf_rflags, RGN_MODIFIED))
- {
- assert(pxp->bf_refcount <= 0);
- status = px_pgout(nciop,
- pxp->bf_offset,
- pxp->bf_cnt,
- pxp->bf_base,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- pxp->bf_rflags = 0;
- }
-
-pgin:
- status = px_pgin(nciop,
- blkoffset,
- blkextent,
- pxp->bf_base,
- &pxp->bf_cnt,
- &pxp->pos);
- if(status != ENOERR)
- return status;
- pxp->bf_offset = blkoffset;
- pxp->bf_extent = blkextent;
-
-done:
- extent += diff;
- if(pxp->bf_cnt < extent)
- pxp->bf_cnt = extent;
- assert(pxp->bf_cnt <= pxp->bf_extent);
-
- pxp->bf_rflags |= rflags;
- pxp->bf_refcount++;
-
- *vpp = (char *)pxp->bf_base + diff;
- return ENOERR;
-}
-
-static int
-ncio_px_get(ncio *const nciop,
- off_t offset, size_t extent,
- int rflags,
- void **const vpp)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
-
- if(fIsSet(rflags, RGN_WRITE) && !fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- /* reclaim space used in move */
- if(pxp->slave != NULL)
- {
- if(pxp->slave->bf_base != NULL)
- {
- free(pxp->slave->bf_base);
- pxp->slave->bf_base = NULL;
- pxp->slave->bf_extent = 0;
- pxp->slave->bf_offset = OFF_NONE;
- }
- free(pxp->slave);
- pxp->slave = NULL;
- }
- return px_get(nciop, pxp, offset, extent, rflags, vpp);
-}
-
-
-/* ARGSUSED */
-static int
-px_double_buffer(ncio *const nciop, off_t to, off_t from,
- size_t nbytes, int rflags)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
- int status = ENOERR;
- void *src;
- void *dest;
-
-#if 0
-fprintf(stderr, "double_buffr %ld %ld %ld\n",
- (long)to, (long)from, (long)nbytes);
-#endif
- status = px_get(nciop, pxp, to, nbytes, RGN_WRITE,
- &dest);
- if(status != ENOERR)
- return status;
-
- if(pxp->slave == NULL)
- {
- pxp->slave = (ncio_px *) malloc(sizeof(ncio_px));
- if(pxp->slave == NULL)
- return ENOMEM;
-
- pxp->slave->blksz = pxp->blksz;
- /* pos done below */
- pxp->slave->bf_offset = pxp->bf_offset;
- pxp->slave->bf_extent = pxp->bf_extent;
- pxp->slave->bf_cnt = pxp->bf_cnt;
- pxp->slave->bf_base = malloc(2 * pxp->blksz);
- if(pxp->slave->bf_base == NULL)
- return ENOMEM;
- (void) memcpy(pxp->slave->bf_base, pxp->bf_base,
- pxp->bf_extent);
- pxp->slave->bf_rflags = 0;
- pxp->slave->bf_refcount = 0;
- pxp->slave->slave = NULL;
- }
-
- pxp->slave->pos = pxp->pos;
- status = px_get(nciop, pxp->slave, from, nbytes, 0,
- &src);
- if(status != ENOERR)
- return status;
- if(pxp->pos != pxp->slave->pos)
- {
- /* position changed, sync */
- pxp->pos = pxp->slave->pos;
- }
-
- (void) memcpy(dest, src, nbytes);
-
- (void)px_rel(pxp->slave, from, 0);
- (void)px_rel(pxp, to, RGN_MODIFIED);
-
- return status;
-}
-
-static int
-ncio_px_move(ncio *const nciop, off_t to, off_t from,
- size_t nbytes, int rflags)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
- int status = ENOERR;
- off_t lower;
- off_t upper;
- char *base;
- size_t diff;
- size_t extent;
-
- if(to == from)
- return ENOERR; /* NOOP */
-
- if(fIsSet(rflags, RGN_WRITE) && !fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- rflags &= RGN_NOLOCK; /* filter unwanted flags */
-
- if(to > from)
- {
- /* growing */
- lower = from;
- upper = to;
- }
- else
- {
- /* shrinking */
- lower = to;
- upper = from;
- }
- diff = (size_t)(upper - lower);
- extent = diff + nbytes;
-
- if(extent > pxp->blksz)
- {
- size_t remaining = nbytes;
- for(;;)
- {
- size_t loopextent = MIN(remaining, pxp->blksz);
-
- status = px_double_buffer(nciop, to, from,
- loopextent, rflags) ;
- if(status != ENOERR)
- return status;
- remaining -= loopextent;
-
- if(remaining == 0)
- break; /* normal loop exit */
- to += loopextent;
- from += loopextent;
- }
- return ENOERR;
- }
-
-#if 0
-fprintf(stderr, "ncio_px_move %ld %ld %ld %ld %ld\n",
- (long)to, (long)from, (long)nbytes, (long)lower, (long)extent);
-#endif
- status = px_get(nciop, pxp, lower, extent, RGN_WRITE|rflags,
- (void **)&base);
-
- if(status != ENOERR)
- return status;
-
- if(to > from)
- (void) memmove(base + diff, base, nbytes);
- else
- (void) memmove(base, base + diff, nbytes);
-
- (void) px_rel(pxp, lower, RGN_MODIFIED);
-
- return status;
-}
-
-
-static int
-ncio_px_sync(ncio *const nciop)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
- int status = ENOERR;
- if(fIsSet(pxp->bf_rflags, RGN_MODIFIED))
- {
- assert(pxp->bf_refcount <= 0);
- status = px_pgout(nciop, pxp->bf_offset,
- pxp->bf_cnt,
- pxp->bf_base, &pxp->pos);
- if(status != ENOERR)
- return status;
- pxp->bf_rflags = 0;
- }
- return status;
-}
-
-static void
-ncio_px_free(void *const pvt)
-{
- ncio_px *const pxp = (ncio_px *)pvt;
- if(pxp == NULL)
- return;
-
- if(pxp->slave != NULL)
- {
- if(pxp->slave->bf_base != NULL)
- {
- free(pxp->slave->bf_base);
- pxp->slave->bf_base = NULL;
- pxp->slave->bf_extent = 0;
- pxp->slave->bf_offset = OFF_NONE;
- }
- free(pxp->slave);
- pxp->slave = NULL;
- }
-
- if(pxp->bf_base != NULL)
- {
- free(pxp->bf_base);
- pxp->bf_base = NULL;
- pxp->bf_extent = 0;
- pxp->bf_offset = OFF_NONE;
- }
-}
-
-
-static int
-ncio_px_init2(ncio *const nciop, size_t *sizehintp, int isNew)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
- const size_t bufsz = 2 * *sizehintp;
-
- assert(nciop->fd >= 0);
-
- pxp->blksz = *sizehintp;
-
- assert(pxp->bf_base == NULL);
-
- /* this is separate allocation because it may grow */
- pxp->bf_base = malloc(bufsz);
- if(pxp->bf_base == NULL)
- return ENOMEM;
- /* else */
- pxp->bf_cnt = 0;
- if(isNew)
- {
- /* save a read */
- pxp->pos = 0;
- pxp->bf_offset = 0;
- pxp->bf_extent = bufsz;
- (void) memset(pxp->bf_base, 0, pxp->bf_extent);
- }
- return ENOERR;
-}
-
-
-static void
-ncio_px_init(ncio *const nciop)
-{
- ncio_px *const pxp = (ncio_px *)nciop->pvt;
-
- *((ncio_relfunc **)&nciop->rel) = ncio_px_rel; /* cast away const */
- *((ncio_getfunc **)&nciop->get) = ncio_px_get; /* cast away const */
- *((ncio_movefunc **)&nciop->move) = ncio_px_move; /* cast away const */
- *((ncio_syncfunc **)&nciop->sync) = ncio_px_sync; /* cast away const */
- *((ncio_freefunc **)&nciop->free) = ncio_px_free; /* cast away const */
-
- pxp->blksz = 0;
- pxp->pos = -1;
- pxp->bf_offset = OFF_NONE;
- pxp->bf_extent = 0;
- pxp->bf_rflags = 0;
- pxp->bf_refcount = 0;
- pxp->bf_base = NULL;
- pxp->slave = NULL;
-
-}
-
-/* Begin spx */
-
-typedef struct ncio_spx {
- off_t pos;
- /* buffer */
- off_t bf_offset;
- size_t bf_extent;
- size_t bf_cnt;
- void *bf_base;
-} ncio_spx;
-
-
-/*ARGSUSED*/
-static int
-ncio_spx_rel(ncio *const nciop, off_t offset, int rflags)
-{
- ncio_spx *const pxp = (ncio_spx *)nciop->pvt;
- int status = ENOERR;
-
- assert(pxp->bf_offset <= offset);
- assert(pxp->bf_cnt != 0);
- assert(pxp->bf_cnt <= pxp->bf_extent);
-#ifdef X_ALIGN
- assert(offset < pxp->bf_offset + X_ALIGN);
- assert(pxp->bf_cnt % X_ALIGN == 0 );
-#endif
-
- if(fIsSet(rflags, RGN_MODIFIED))
- {
- if(!fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- status = px_pgout(nciop, pxp->bf_offset,
- pxp->bf_cnt,
- pxp->bf_base, &pxp->pos);
- /* if error, invalidate buffer anyway */
- }
- pxp->bf_offset = OFF_NONE;
- pxp->bf_cnt = 0;
- return status;
-}
-
-
-static int
-ncio_spx_get(ncio *const nciop,
- off_t offset, size_t extent,
- int rflags,
- void **const vpp)
-{
- ncio_spx *const pxp = (ncio_spx *)nciop->pvt;
- int status = ENOERR;
-#ifdef X_ALIGN
- size_t rem;
-#endif
-
- if(fIsSet(rflags, RGN_WRITE) && !fIsSet(nciop->ioflags, NC_WRITE))
- return EPERM; /* attempt to write readonly file */
-
- assert(extent != 0);
- assert(extent < X_INT_MAX); /* sanity check */
- assert(offset < X_INT_MAX); /* sanity check */
-
- assert(pxp->bf_cnt == 0);
-
-#ifdef X_ALIGN
- rem = (size_t)(offset % X_ALIGN);
- if(rem != 0)
- {
- offset -= rem;
- extent += rem;
- }
-
- {
- const size_t rndup = extent % X_ALIGN;
- if(rndup != 0)
- extent += X_ALIGN - rndup;
- }
-
- assert(offset % X_ALIGN == 0);
- assert(extent % X_ALIGN == 0);
-#endif
-
- if(pxp->bf_extent < extent)
- {
- if(pxp->bf_base != NULL)
- {
- free(pxp->bf_base);
- pxp->bf_base = NULL;
- pxp->bf_extent = 0;
- }
- assert(pxp->bf_extent == 0);
- pxp->bf_base = malloc(extent);
- if(pxp->bf_base == NULL)
- return ENOMEM;
- pxp->bf_extent = extent;
- }
-
- status = px_pgin(nciop, offset,
- extent,
- pxp->bf_base,
- &pxp->bf_cnt, &pxp->pos);
- if(status != ENOERR)
- return status;
-
- pxp->bf_offset = offset;
-
- if(pxp->bf_cnt < extent)
- pxp->bf_cnt = extent;
-
-#ifdef X_ALIGN
- *vpp = (char *)pxp->bf_base + rem;
-#else
- *vpp = pxp->bf_base;
-#endif
- return ENOERR;
-}
-
-
-#if 0
-/*ARGSUSED*/
-static int
-strategy(ncio *const nciop, off_t to, off_t offset,
- size_t extent, int rflags)
-{
- static ncio_spx pxp[1];
- int status = ENOERR;
-#ifdef X_ALIGN
- size_t rem;
-#endif
-
- assert(extent != 0);
- assert(extent < X_INT_MAX); /* sanity check */
- assert(offset < X_INT_MAX); /* sanity check */
-#if INSTRUMENT
-fprintf(stderr, "strategy %ld at %ld to %ld\n",
- (long)extent, (long)offset, (long)to);
-#endif
-
-
-#ifdef X_ALIGN
- rem = (size_t)(offset % X_ALIGN);
- if(rem != 0)
- {
- offset -= rem;
- extent += rem;
- }
-
- {
- const size_t rndup = extent % X_ALIGN;
- if(rndup != 0)
- extent += X_ALIGN - rndup;
- }
-
- assert(offset % X_ALIGN == 0);
- assert(extent % X_ALIGN == 0);
-#endif
-
- if(pxp->bf_extent < extent)
- {
- if(pxp->bf_base != NULL)
- {
- free(pxp->bf_base);
- pxp->bf_base = NULL;
- pxp->bf_extent = 0;
- }
- assert(pxp->bf_extent == 0);
- pxp->bf_base = malloc(extent);
- if(pxp->bf_base == NULL)
- return ENOMEM;
- pxp->bf_extent = extent;
- }
-
- status = px_pgin(nciop, offset,
- extent,
- pxp->bf_base,
- &pxp->bf_cnt, &pxp->pos);
- if(status != ENOERR)
- return status;
-
- pxp->bf_offset = to; /* TODO: XALIGN */
-
- if(pxp->bf_cnt < extent)
- pxp->bf_cnt = extent;
-
- status = px_pgout(nciop, pxp->bf_offset,
- pxp->bf_cnt,
- pxp->bf_base, &pxp->pos);
- /* if error, invalidate buffer anyway */
- pxp->bf_offset = OFF_NONE;
- pxp->bf_cnt = 0;
- return status;
-}
-#endif
-
-static int
-ncio_spx_move(ncio *const nciop, off_t to, off_t from,
- size_t nbytes, int rflags)
-{
- int status = ENOERR;
- off_t lower = from;
- off_t upper = to;
- char *base;
- size_t diff = (size_t)(upper - lower);
- size_t extent = diff + nbytes;
-
- rflags &= RGN_NOLOCK; /* filter unwanted flags */
-
- if(to == from)
- return ENOERR; /* NOOP */
-
- if(to > from)
- {
- /* growing */
- lower = from;
- upper = to;
- }
- else
- {
- /* shrinking */
- lower = to;
- upper = from;
- }
-
- diff = (size_t)(upper - lower);
- extent = diff + nbytes;
-
- status = ncio_spx_get(nciop, lower, extent, RGN_WRITE|rflags,
- (void **)&base);
-
- if(status != ENOERR)
- return status;
-
- if(to > from)
- (void) memmove(base + diff, base, nbytes);
- else
- (void) memmove(base, base + diff, nbytes);
-
- (void) ncio_spx_rel(nciop, lower, RGN_MODIFIED);
-
- return status;
-}
-
-
-/*ARGSUSED*/
-static int
-ncio_spx_sync(ncio *const nciop)
-{
- /* NOOP */
- return ENOERR;
-}
-
-static void
-ncio_spx_free(void *const pvt)
-{
- ncio_spx *const pxp = (ncio_spx *)pvt;
- if(pxp == NULL)
- return;
-
- if(pxp->bf_base != NULL)
- {
- free(pxp->bf_base);
- pxp->bf_base = NULL;
- pxp->bf_offset = OFF_NONE;
- pxp->bf_extent = 0;
- pxp->bf_cnt = 0;
- }
-}
-
-
-static int
-ncio_spx_init2(ncio *const nciop, const size_t *const sizehintp)
-{
- ncio_spx *const pxp = (ncio_spx *)nciop->pvt;
-
- assert(nciop->fd >= 0);
-
- pxp->bf_extent = *sizehintp;
-
- assert(pxp->bf_base == NULL);
-
- /* this is separate allocation because it may grow */
- pxp->bf_base = malloc(pxp->bf_extent);
- if(pxp->bf_base == NULL)
- {
- pxp->bf_extent = 0;
- return ENOMEM;
- }
- /* else */
- return ENOERR;
-}
-
-
-static void
-ncio_spx_init(ncio *const nciop)
-{
- ncio_spx *const pxp = (ncio_spx *)nciop->pvt;
-
- *((ncio_relfunc **)&nciop->rel) = ncio_spx_rel; /* cast away const */
- *((ncio_getfunc **)&nciop->get) = ncio_spx_get; /* cast away const */
- *((ncio_movefunc **)&nciop->move) = ncio_spx_move; /* cast away const */
- *((ncio_syncfunc **)&nciop->sync) = ncio_spx_sync; /* cast away const */
- *((ncio_freefunc **)&nciop->free) = ncio_spx_free; /* cast away const */
-
- pxp->pos = -1;
- pxp->bf_offset = OFF_NONE;
- pxp->bf_extent = 0;
- pxp->bf_cnt = 0;
- pxp->bf_base = NULL;
-}
-
-
-/* */
-
-static void
-ncio_free(ncio *nciop)
-{
- if(nciop == NULL)
- return;
-
- if(nciop->free != NULL)
- nciop->free(nciop->pvt);
-
- free(nciop);
-}
-
-
-static ncio *
-ncio_new(const char *path, int ioflags)
-{
- size_t sz_ncio = M_RNDUP(sizeof(ncio));
- size_t sz_path = M_RNDUP(strlen(path) +1);
- size_t sz_ncio_pvt;
- ncio *nciop;
-
-#if ALWAYS_NC_SHARE /* DEBUG */
- fSet(ioflags, NC_SHARE);
-#endif
-
- if(fIsSet(ioflags, NC_SHARE))
- sz_ncio_pvt = sizeof(ncio_spx);
- else
- sz_ncio_pvt = sizeof(ncio_px);
-
- nciop = (ncio *) malloc(sz_ncio + sz_path + sz_ncio_pvt);
- if(nciop == NULL)
- return NULL;
-
- nciop->ioflags = ioflags;
- *((int *)&nciop->fd) = -1; /* cast away const */
-
- nciop->path = (char *) ((char *)nciop + sz_ncio);
- (void) strcpy((char *)nciop->path, path); /* cast away const */
-
- /* cast away const */
- *((void **)&nciop->pvt) = (void *)(nciop->path + sz_path);
-
- if(fIsSet(ioflags, NC_SHARE))
- ncio_spx_init(nciop);
- else
- ncio_px_init(nciop);
-
- return nciop;
-}
-
-
-/* Public below this point */
-
-#define NCIO_MINBLOCKSIZE 256
-#define NCIO_MAXBLOCKSIZE 268435456 /* sanity check, about X_SIZE_T_MAX/8 */
-
-#ifdef S_IRUSR
-#define NC_DEFAULT_CREAT_MODE \
- (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) /* 0666 */
-
-#else
-#define NC_DEFAULT_CREAT_MODE 0666
-#endif
-
-int
-ncio_create(const char *path, int ioflags,
- size_t initialsz,
- off_t igeto, size_t igetsz, size_t *sizehintp,
- ncio **nciopp, void **const igetvpp)
-{
- ncio *nciop;
- int oflags = (O_RDWR|O_CREAT);
- int fd;
- int status;
-
- if(initialsz < (size_t)igeto + igetsz)
- initialsz = (size_t)igeto + igetsz;
-
- fSet(ioflags, NC_WRITE);
-
- if(path == NULL || *path == 0)
- return EINVAL;
-
- nciop = ncio_new(path, ioflags);
- if(nciop == NULL)
- return ENOMEM;
-
- if(fIsSet(ioflags, NC_NOCLOBBER))
- fSet(oflags, O_EXCL);
- else
- fSet(oflags, O_TRUNC);
-#ifdef O_BINARY
- fSet(oflags, O_BINARY);
-#endif
-#ifdef vms
- fd = open(path, oflags, NC_DEFAULT_CREAT_MODE, "ctx=stm");
-#else
- /* Should we mess with the mode based on NC_SHARE ?? */
- fd = open(path, oflags, NC_DEFAULT_CREAT_MODE);
-#endif
-#if 0
- (void) fprintf(stderr, "ncio_create(): path=\"%s\"\n", path);
- (void) fprintf(stderr, "ncio_create(): oflags=0x%x\n", oflags);
-#endif
- if(fd < 0)
- {
- status = errno;
- goto unwind_new;
- }
- *((int *)&nciop->fd) = fd; /* cast away const */
-
- if(*sizehintp < NCIO_MINBLOCKSIZE || *sizehintp > NCIO_MAXBLOCKSIZE)
- {
- /* Use default */
- *sizehintp = blksize(fd);
- }
- else
- {
- *sizehintp = M_RNDUP(*sizehintp);
- }
-
- if(fIsSet(nciop->ioflags, NC_SHARE))
- status = ncio_spx_init2(nciop, sizehintp);
- else
- status = ncio_px_init2(nciop, sizehintp, 1);
-
- if(status != ENOERR)
- goto unwind_open;
-
- if(initialsz != 0)
- {
- status = fgrow(fd, (off_t)initialsz);
- if(status != ENOERR)
- goto unwind_open;
- }
-
- if(igetsz != 0)
- {
- status = nciop->get(nciop,
- igeto, igetsz,
- RGN_WRITE,
- igetvpp);
- if(status != ENOERR)
- goto unwind_open;
- }
-
- *nciopp = nciop;
- return ENOERR;
-
-unwind_open:
- (void) close(fd);
- /* ?? unlink */
- /*FALLTHRU*/
-unwind_new:
- ncio_free(nciop);
- return status;
-}
-
-
-int
-ncio_open(const char *path,
- int ioflags,
- off_t igeto, size_t igetsz, size_t *sizehintp,
- ncio **nciopp, void **const igetvpp)
-{
- ncio *nciop;
- int oflags = fIsSet(ioflags, NC_WRITE) ? O_RDWR : O_RDONLY;
- int fd;
- int status;
-
- if(path == NULL || *path == 0)
- return EINVAL;
-
- nciop = ncio_new(path, ioflags);
- if(nciop == NULL)
- return ENOMEM;
-
-#ifdef O_BINARY
- fSet(oflags, O_BINARY);
-#endif
-#ifdef vms
- fd = open(path, oflags, 0, "ctx=stm");
-#else
- fd = open(path, oflags, 0);
-#endif
- if(fd < 0)
- {
- status = errno;
- goto unwind_new;
- }
- *((int *)&nciop->fd) = fd; /* cast away const */
-
- if(*sizehintp < NCIO_MINBLOCKSIZE || *sizehintp > NCIO_MAXBLOCKSIZE)
- {
- /* Use default */
- *sizehintp = blksize(fd);
- }
- else
- {
- *sizehintp = M_RNDUP(*sizehintp);
- }
-
- if(fIsSet(nciop->ioflags, NC_SHARE))
- status = ncio_spx_init2(nciop, sizehintp);
- else
- status = ncio_px_init2(nciop, sizehintp, 0);
-
- if(status != ENOERR)
- goto unwind_open;
-
- if(igetsz != 0)
- {
- status = nciop->get(nciop,
- igeto, igetsz,
- 0,
- igetvpp);
- if(status != ENOERR)
- goto unwind_open;
- }
-
- *nciopp = nciop;
- return ENOERR;
-
-unwind_open:
- (void) close(fd);
- /*FALLTHRU*/
-unwind_new:
- ncio_free(nciop);
- return status;
-}
-
-
-int
-ncio_close(ncio *nciop, int doUnlink)
-{
- int status = ENOERR;
-
- if(nciop == NULL)
- return EINVAL;
-
- status = nciop->sync(nciop);
-
- (void) close(nciop->fd);
-
- if(doUnlink)
- (void) unlink(nciop->path);
-
- ncio_free(nciop);
-
- return status;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/putget.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/putget.m4
deleted file mode 100644
index 3a48570..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/putget.m4
+++ /dev/null
@@ -1,2689 +0,0 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-undefine(`begin')dnl
-undefine(`index')dnl
-undefine(`len')dnl
-dnl
-dnl If you see this line, you can ignore the next one.
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: putget.m4,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $ */
-
-#include "nc.h"
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include "ncx.h"
-#include "fbits.h"
-#include "onstack.h"
-
-#undef MIN /* system may define MIN somewhere and complain */
-#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))
-
-/* #define ODEBUG 1 */
-
-#if ODEBUG
-#include <stdio.h>
-/*
- * Print the values of an array of size_t
- */
-void
-arrayp(const char *label, size_t count, const size_t *array)
-{
- (void) fprintf(stderr, "%s", label);
- (void) fputc('\t',stderr);
- for(; count > 0; count--, array++)
- (void) fprintf(stderr," %lu", (unsigned long)*array);
- (void) fputc('\n',stderr);
-}
-#endif /* ODEBUG */
-
-
-/* Begin fill */
-/*
- * This is tunable parameter.
- * It essentially controls the tradeoff between the number of times
- * memcpy() gets called to copy the external data to fill
- * a large buffer vs the number of times its called to
- * prepare the external data.
- */
-#define NFILL 16
-
-
-dnl
-dnl NCFILL(Type, Xtype, XSize, Fill)
-dnl
-define(`NCFILL',dnl
-`dnl
-static int
-NC_fill_$2(
- void **xpp,
- size_t nelems) /* how many */
-{
- $1 fillp[NFILL * sizeof(double)/$3];
-
- assert(nelems <= sizeof(fillp)/sizeof(fillp[0]));
-
- {
- $1 *vp = fillp; /* lower bound of area to be filled */
- const $1 *const end = vp + nelems;
- while(vp < end)
- {
- *vp++ = $4;
- }
- }
- return ncx_putn_$2_$1(xpp, nelems, fillp);
-}
-')dnl
-
-/*
- * Next 6 type specific functions
- * Fill a some memory with the default special value.
- * Formerly
-NC_arrayfill()
- */
-NCFILL(schar, schar, X_SIZEOF_CHAR, NC_FILL_BYTE)
-NCFILL(char, char, X_SIZEOF_CHAR, NC_FILL_CHAR)
-NCFILL(short, short, X_SIZEOF_SHORT, NC_FILL_SHORT)
-
-#if (SIZEOF_INT >= X_SIZEOF_INT)
-NCFILL(int, int, X_SIZEOF_INT, NC_FILL_INT)
-#elif SIZEOF_LONG == X_SIZEOF_INT
-NCFILL(long, int, X_SIZEOF_INT, NC_FILL_INT)
-#else
-#error "NC_fill_int implementation"
-#endif
-
-NCFILL(float, float, X_SIZEOF_FLOAT, NC_FILL_FLOAT)
-NCFILL(double, double, X_SIZEOF_DOUBLE, NC_FILL_DOUBLE)
-
-
-/*
- * Fill the external space for variable 'varp' values at 'recno'
- * with the appropriate value. If 'varp' is not a record
- * variable, fill the whole thing.
- * Formerly
-xdr_NC_fill()
- */
-int
-fill_NC_var(NC *ncp, const NC_var *varp, size_t recno)
-{
- char xfillp[NFILL * X_SIZEOF_DOUBLE];
- const size_t step = varp->xsz;
- const size_t nelems = sizeof(xfillp)/step;
- const size_t xsz = varp->xsz * nelems;
- NC_attr **attrpp = NULL;
- off_t offset;
- size_t remaining = varp->len;
-
- void *xp;
- int status = NC_NOERR;
-
- /*
- * Set up fill value
- */
- attrpp = NC_findattr(&varp->attrs, _FillValue);
- if( attrpp != NULL )
- {
- /* User defined fill value */
- if( (*attrpp)->type != varp->type || (*attrpp)->nelems != 1 )
- {
- return NC_EBADTYPE;
- }
- else
- {
- /* Use the user defined value */
- char *cp = xfillp;
- const char *const end = &xfillp[sizeof(xfillp)];
-
- assert(step <= (*attrpp)->xsz);
-
- for( /*NADA*/; cp < end; cp += step)
- {
- (void) memcpy(cp, (*attrpp)->xvalue, step);
- }
- }
- }
- else
- {
- /* use the default */
-
- assert(xsz % X_ALIGN == 0);
- assert(xsz <= sizeof(xfillp));
-
- xp = xfillp;
-
- switch(varp->type){
- case NC_BYTE :
- status = NC_fill_schar(&xp, nelems);
- break;
- case NC_CHAR :
- status = NC_fill_char(&xp, nelems);
- break;
- case NC_SHORT :
- status = NC_fill_short(&xp, nelems);
- break;
- case NC_INT :
- status = NC_fill_int(&xp, nelems);
- break;
- case NC_FLOAT :
- status = NC_fill_float(&xp, nelems);
- break;
- case NC_DOUBLE :
- status = NC_fill_double(&xp, nelems);
- break;
- default :
- assert("fill_NC_var invalid type" == 0);
- status = NC_EBADTYPE;
- break;
- }
- if(status != NC_NOERR)
- return status;
-
- assert(xp == xfillp + xsz);
- }
-
- /*
- * copyout:
- * xfillp now contains 'nelems' elements of the fill value
- * in external representation.
- */
-
- /*
- * Copy it out.
- */
-
- offset = varp->begin;
- if(IS_RECVAR(varp))
- {
- offset += (off_t)ncp->recsize * recno;
- }
-
- assert(remaining > 0);
- for(;;)
- {
- const size_t chunksz = MIN(remaining, ncp->chunk);
- size_t ii;
- assert(chunksz % X_ALIGN == 0);
-
- status = ncp->nciop->get(ncp->nciop, offset, chunksz,
- RGN_WRITE, &xp);
- if(status != NC_NOERR)
- {
- return status;
- }
-
- /*
- * fill the chunksz buffer in units of xsz
- */
- for(ii = 0; ii < chunksz/xsz; ii++)
- {
- (void) memcpy(xp, xfillp, xsz);
- xp = (char *)xp + xsz;
- }
- /*
- * Deal with any remainder
- */
- {
- const size_t rem = chunksz % xsz;
- if(rem != 0)
- {
- (void) memcpy(xp, xfillp, rem);
- /* xp = (char *)xp + xsz; */
- }
-
- }
-
- status = ncp->nciop->rel(ncp->nciop, offset, RGN_MODIFIED);
-
- if(status != NC_NOERR)
- {
- break;
- }
-
- remaining -= chunksz;
- if(remaining == 0)
- break; /* normal loop exit */
- offset += chunksz;
-
- }
-
- return status;
-}
-/* End fill */
-
-
-/*
- * Add a record containing the fill values.
- */
-static int
-NCfillrecord(NC *ncp, const NC_var *const *varpp, size_t recno)
-{
- size_t ii = 0;
- for(; ii < ncp->vars.nelems; ii++, varpp++)
- {
- if( !IS_RECVAR(*varpp) )
- {
- continue; /* skip non-record variables */
- }
- {
- const int status = fill_NC_var(ncp, *varpp, recno);
- if(status != NC_NOERR)
- return status;
- }
- }
- return NC_NOERR;
-}
-
-/*
- * It is advantageous to
- * #define TOUCH_LAST
- * when using memory mapped io.
- */
-#if TOUCH_LAST
-/*
- * Grow the file to a size which can contain recno
- */
-static int
-NCtouchlast(NC *ncp, const NC_var *const *varpp, size_t recno)
-{
- int status = NC_NOERR;
- const NC_var *varp = NULL;
-
- {
- size_t ii = 0;
- for(; ii < ncp->vars.nelems; ii++, varpp++)
- {
- if( !IS_RECVAR(*varpp) )
- {
- continue; /* skip non-record variables */
- }
- varp = *varpp;
- }
- }
- assert(varp != NULL);
- assert( IS_RECVAR(varp) );
- {
- const off_t offset = varp->begin
- + (off_t)(recno-1) * (off_t)ncp->recsize
- + (off_t)(varp->len - varp->xsz);
- void *xp;
-
-
- status = ncp->nciop->get(ncp->nciop, offset, varp->xsz,
- RGN_WRITE, &xp);
- if(status != NC_NOERR)
- return status;
- (void)memset(xp, 0, varp->xsz);
- status = ncp->nciop->rel(ncp->nciop, offset, RGN_MODIFIED);
- }
- return status;
-}
-#endif /* TOUCH_LAST */
-
-
-/*
- * Ensure that the netcdf file has 'numrecs' records,
- * add records and fill as neccessary.
- */
-static int
-NCvnrecs(NC *ncp, size_t numrecs)
-{
- int status = NC_NOERR;
-
- if(numrecs > ncp->numrecs)
- {
-
-
-#if TOUCH_LAST
- status = NCtouchlast(ncp,
- (const NC_var *const*)ncp->vars.value,
- numrecs);
- if(status != NC_NOERR)
- return status;
-#endif /* TOUCH_LAST */
-
- set_NC_ndirty(ncp);
-
- if(!NC_dofill(ncp))
- {
- /* Go directly to jail, do not pass go */
- ncp->numrecs = numrecs;
- }
- else
- {
- size_t unfilled = numrecs - ncp->numrecs;
- size_t ii;
-
- for(ii = 0; ii < unfilled; ii++, ncp->numrecs++)
- {
- status = NCfillrecord(ncp,
- (const NC_var *const*)ncp->vars.value,
- ncp->numrecs);
- if(status != NC_NOERR)
- {
- break;
- }
- }
- if(status != NC_NOERR)
- return status;
- }
-
- if(NC_doNsync(ncp))
- {
- status = write_numrecs(ncp);
- }
-
- }
- return status;
-}
-
-
-/*
- * Check whether 'coord' values are valid for the variable.
- */
-static int
-NCcoordck(NC *ncp, const NC_var *varp, const size_t *coord)
-{
- const size_t *ip;
- size_t *up;
-
- if(varp->ndims == 0)
- return NC_NOERR; /* 'scalar' variable */
-
- if(IS_RECVAR(varp))
- {
- if(*coord > X_INT_MAX)
- return NC_EINVALCOORDS; /* sanity check */
- if(NC_readonly(ncp) && *coord >= ncp->numrecs)
- {
- if(!NC_doNsync(ncp))
- return NC_EINVALCOORDS;
- /* else */
- {
- /* Update from disk and check again */
- const int status = read_numrecs(ncp);
- if(status != NC_NOERR)
- return status;
- if(*coord >= ncp->numrecs)
- return NC_EINVALCOORDS;
- }
- }
- ip = coord + 1;
- up = varp->shape + 1;
- }
- else
- {
- ip = coord;
- up = varp->shape;
- }
-
-#ifdef CDEBUG
-fprintf(stderr," NCcoordck: coord %ld, count %d, ip %ld\n",
- coord, varp->ndims, ip );
-#endif /* CDEBUG */
-
- for(; ip < coord + varp->ndims; ip++, up++)
- {
-
-#ifdef CDEBUG
-fprintf(stderr," NCcoordck: ip %p, *ip %ld, up %p, *up %lu\n",
- ip, *ip, up, *up );
-#endif /* CDEBUG */
-
- /* cast needed for braindead systems with signed size_t */
- if((unsigned long) *ip >= (unsigned long) *up )
- return NC_EINVALCOORDS;
- }
-
- return NC_NOERR;
-}
-
-
-/*
- * Check whether 'edges' are valid for the variable and 'start'
- */
-/*ARGSUSED*/
-static int
-NCedgeck(const NC *ncp, const NC_var *varp,
- const size_t *start, const size_t *edges)
-{
- const size_t *const end = start + varp->ndims;
- const size_t *shp = varp->shape;
-
- if(varp->ndims == 0)
- return NC_NOERR; /* 'scalar' variable */
-
- if(IS_RECVAR(varp))
- {
- start++;
- edges++;
- shp++;
- }
-
- for(; start < end; start++, edges++, shp++)
- {
- /* cast needed for braindead systems with signed size_t */
- if((unsigned long) *edges > *shp ||
- (unsigned long) *start + (unsigned long) *edges > *shp)
- {
- return(NC_EEDGE);
- }
- }
- return NC_NOERR;
-}
-
-
-/*
- * Translate the (variable, coord) pair into a seek index
- */
-static off_t
-NC_varoffset(const NC *ncp, const NC_var *varp, const size_t *coord)
-{
- if(varp->ndims == 0) /* 'scalar' variable */
- return varp->begin;
-
- if(varp->ndims == 1)
- {
- if(IS_RECVAR(varp))
- return varp->begin +
- (off_t)(*coord) * (off_t)ncp->recsize;
- /* else */
- return varp->begin + (off_t)(*coord) * (off_t)varp->xsz;
- }
- /* else */
- {
- off_t lcoord = (off_t)coord[varp->ndims -1];
-
- size_t *up = varp->dsizes +1;
- const size_t *ip = coord;
- const size_t *const end = varp->dsizes + varp->ndims;
-
- if(IS_RECVAR(varp))
- up++, ip++;
-
- for(; up < end; up++, ip++)
- lcoord += *up * *ip;
-
- lcoord *= varp->xsz;
-
- if(IS_RECVAR(varp))
- lcoord += (off_t)(*coord) * ncp->recsize;
-
- lcoord += varp->begin;
- return lcoord;
- }
-}
-
-
-dnl
-dnl Output 'nelems' items of contiguous data of type "Type"
-dnl for variable 'varp' at 'start'.
-dnl "Xtype" had better match 'varp->type'.
-dnl---
-dnl
-dnl PUTNCVX(Xtype, Type)
-dnl
-define(`PUTNCVX',dnl
-`dnl
-static int
-putNCvx_$1_$2(NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, const $2 *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 = ncp->nciop->get(ncp->nciop, offset, extent,
- RGN_WRITE, &xp);
- if(lstatus != NC_NOERR)
- return lstatus;
-
- lstatus = ncx_putn_$1_$2(&xp, nput, value);
- if(lstatus != NC_NOERR && status == NC_NOERR)
- {
- /* not fatal to the loop */
- status = lstatus;
- }
-
- (void) ncp->nciop->rel(ncp->nciop, offset,
- RGN_MODIFIED);
-
- remaining -= extent;
- if(remaining == 0)
- break; /* normal loop exit */
- offset += extent;
- value += nput;
-
- }
-
- return status;
-}
-')dnl
-
-PUTNCVX(char, char)
-
-PUTNCVX(schar, schar)
-PUTNCVX(schar, uchar)
-PUTNCVX(schar, short)
-PUTNCVX(schar, int)
-PUTNCVX(schar, long)
-PUTNCVX(schar, float)
-PUTNCVX(schar, double)
-
-PUTNCVX(short, schar)
-PUTNCVX(short, uchar)
-PUTNCVX(short, short)
-PUTNCVX(short, int)
-PUTNCVX(short, long)
-PUTNCVX(short, float)
-PUTNCVX(short, double)
-
-PUTNCVX(int, schar)
-PUTNCVX(int, uchar)
-PUTNCVX(int, short)
-PUTNCVX(int, int)
-PUTNCVX(int, long)
-PUTNCVX(int, float)
-PUTNCVX(int, double)
-
-PUTNCVX(float, schar)
-PUTNCVX(float, uchar)
-PUTNCVX(float, short)
-PUTNCVX(float, int)
-PUTNCVX(float, long)
-PUTNCVX(float, float)
-PUTNCVX(float, double)
-
-PUTNCVX(double, schar)
-PUTNCVX(double, uchar)
-PUTNCVX(double, short)
-PUTNCVX(double, int)
-PUTNCVX(double, long)
-PUTNCVX(double, float)
-PUTNCVX(double, double)
-
-
-dnl
-dnl PUTNCV(Type)
-dnl
-define(`PUTNCV',dnl
-`dnl
-static int
-putNCv_$1(NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, const $1 *value)
-{
- switch(varp->type){
- case NC_CHAR:
- return NC_ECHAR;
- case NC_BYTE:
- return putNCvx_schar_$1(ncp, varp, start, nelems,
- value);
- case NC_SHORT:
- return putNCvx_short_$1(ncp, varp, start, nelems,
- value);
- case NC_INT:
- return putNCvx_int_$1(ncp, varp, start, nelems,
- value);
- case NC_FLOAT:
- return putNCvx_float_$1(ncp, varp, start, nelems,
- value);
- case NC_DOUBLE:
- return putNCvx_double_$1(ncp, varp, start, nelems,
- value);
- }
- return NC_EBADTYPE;
-}
-')dnl
-
-static int
-putNCv_text(NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, const char *value)
-{
- if(varp->type != NC_CHAR)
- return NC_ECHAR;
- return putNCvx_char_char(ncp, varp, start, nelems, value);
-}
-
-PUTNCV(schar)
-PUTNCV(uchar)
-PUTNCV(short)
-PUTNCV(int)
-PUTNCV(long)
-PUTNCV(float)
-PUTNCV(double)
-
-
-dnl
-dnl GETNCVX(XType, Type)
-dnl
-define(`GETNCVX',dnl
-`dnl
-static int
-getNCvx_$1_$2(const NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, $2 *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 = ncp->nciop->get(ncp->nciop, offset, extent,
- 0, (void **)&xp); /* cast away const */
- if(lstatus != NC_NOERR)
- return lstatus;
-
- lstatus = ncx_getn_$1_$2(&xp, nget, value);
- if(lstatus != NC_NOERR && status == NC_NOERR)
- status = lstatus;
-
- (void) ncp->nciop->rel(ncp->nciop, offset, 0);
-
- remaining -= extent;
- if(remaining == 0)
- break; /* normal loop exit */
- offset += extent;
- value += nget;
- }
-
- return status;
-}
-')dnl
-
-GETNCVX(char, char)
-
-GETNCVX(schar, schar)
-GETNCVX(schar, uchar)
-GETNCVX(schar, short)
-GETNCVX(schar, int)
-GETNCVX(schar, long)
-GETNCVX(schar, float)
-GETNCVX(schar, double)
-
-GETNCVX(short, schar)
-GETNCVX(short, uchar)
-GETNCVX(short, short)
-GETNCVX(short, int)
-GETNCVX(short, long)
-GETNCVX(short, float)
-GETNCVX(short, double)
-
-GETNCVX(int, schar)
-GETNCVX(int, uchar)
-GETNCVX(int, short)
-GETNCVX(int, int)
-GETNCVX(int, long)
-GETNCVX(int, float)
-GETNCVX(int, double)
-
-GETNCVX(float, schar)
-GETNCVX(float, uchar)
-GETNCVX(float, short)
-GETNCVX(float, int)
-GETNCVX(float, long)
-GETNCVX(float, float)
-GETNCVX(float, double)
-
-GETNCVX(double, schar)
-GETNCVX(double, uchar)
-GETNCVX(double, short)
-GETNCVX(double, int)
-GETNCVX(double, long)
-GETNCVX(double, float)
-GETNCVX(double, double)
-
-
-dnl
-dnl GETNCV(Type)
-dnl
-define(`GETNCV',dnl
-`dnl
-static int
-getNCv_$1(const NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, $1 *value)
-{
- switch(varp->type){
- case NC_CHAR:
- return NC_ECHAR;
- case NC_BYTE:
- return getNCvx_schar_$1(ncp, varp, start, nelems,
- value);
- case NC_SHORT:
- return getNCvx_short_$1(ncp, varp, start, nelems,
- value);
- case NC_INT:
- return getNCvx_int_$1(ncp, varp, start, nelems,
- value);
- case NC_FLOAT:
- return getNCvx_float_$1(ncp, varp, start, nelems,
- value);
- case NC_DOUBLE:
- return getNCvx_double_$1(ncp, varp, start, nelems,
- value);
- }
- return NC_EBADTYPE;
-}
-')dnl
-
-GETNCV(schar)
-GETNCV(uchar)
-GETNCV(short)
-GETNCV(int)
-GETNCV(long)
-GETNCV(float)
-GETNCV(double)
-
-
-static int
-getNCv_text(const NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, char *value)
-{
- if(varp->type != NC_CHAR)
- return NC_ECHAR;
- return getNCvx_char_char(ncp, varp, start, nelems, value);
-}
-
-
-/*
- * Copy 'nbytes' contiguous external values
- * from ('inncp', invp', inncoord')
- * to ('outncp', 'outvp', 'outcoord')
- * 'inncp' shouldn't be the same as 'outncp'.
- * Used only by ncvarcopy()
- */
-static int
-NCxvarcpy(NC *inncp, NC_var *invp, size_t *incoord,
- NC *outncp, NC_var *outvp, size_t *outcoord, size_t nbytes)
-{
- int status;
- off_t inoffset = NC_varoffset(inncp, invp, incoord);
- off_t outoffset = NC_varoffset(outncp, outvp, outcoord);
- void *inxp;
- void *outxp;
- const size_t chunk = MIN(inncp->chunk, outncp->chunk);
-
- do {
- const size_t extent = MIN(nbytes, chunk);
-
- status = inncp->nciop->get(inncp->nciop, inoffset, extent,
- 0, &inxp);
- if(status != NC_NOERR)
- return status;
-
- status = outncp->nciop->get(outncp->nciop, outoffset, extent,
- RGN_WRITE, &outxp);
- if(status != NC_NOERR)
- {
- (void) inncp->nciop->rel(inncp->nciop, inoffset, 0);
- break;
- }
-
- (void) memcpy(outxp, inxp, extent);
-
- status = outncp->nciop->rel(outncp->nciop, outoffset,
- RGN_MODIFIED);
- (void) inncp->nciop->rel(inncp->nciop, inoffset, 0);
-
- nbytes -= extent;
- if(nbytes == 0)
- break; /* normal loop exit */
- inoffset += extent;
- outoffset += extent;
-
- } while (status == NC_NOERR);
-
- return status;
-}
-
-
-/*
- * For ncvar{put,get},
- * find the largest contiguous block from within 'edges'.
- * returns the index to the left of this (which may be -1).
- * Compute the number of contiguous elements and return
- * that in *iocountp.
- * The presence of "record" variables makes this routine
- * overly subtle.
- */
-static int
-NCiocount(const NC *const ncp, const NC_var *const varp,
- const size_t *const edges,
- size_t *const iocountp)
-{
- const size_t *edp0 = edges;
- const size_t *edp = edges + varp->ndims;
- const size_t *shp = varp->shape + varp->ndims;
-
- if(IS_RECVAR(varp))
- {
- if(varp->ndims == 1 && ncp->recsize <= varp->len)
- {
- /* one dimensional && the only 'record' variable */
- *iocountp = *edges;
- return(0);
- }
- /* else */
- edp0++;
- }
-
- assert(edges != NULL);
-
- /* find max contiguous */
- while(edp > edp0)
- {
- shp--; edp--;
- if(*edp < *shp )
- {
- const size_t *zedp = edp;
- while(zedp >= edp0)
- {
- if(*zedp == 0)
- {
- *iocountp = 0;
- goto done;
- }
- /* Tip of the hat to segmented architectures */
- if(zedp == edp0)
- break;
- zedp--;
- }
- break;
- }
- assert(*edp == *shp);
- }
-
- /*
- * edp, shp reference rightmost index s.t. *(edp +1) == *(shp +1)
- *
- * Or there is only one dimension.
- * If there is only one dimension and it is 'non record' dimension,
- * edp is &edges[0] and we will return -1.
- * If there is only one dimension and and it is a "record dimension",
- * edp is &edges[1] (out of bounds) and we will return 0;
- */
- assert(shp >= varp->shape + varp->ndims -1
- || *(edp +1) == *(shp +1));
-
- /* now accumulate max count for a single io operation */
- for(*iocountp = 1, edp0 = edp;
- edp0 < edges + varp->ndims;
- edp0++)
- {
- *iocountp *= *edp0;
- }
-
-done:
- return((int)(edp - edges) - 1);
-}
-
-
-/*
- * Set the elements of the array 'upp' to
- * the sum of the corresponding elements of
- * 'stp' and 'edp'. 'end' should be &stp[nelems].
- */
-static void
-set_upper(size_t *upp, /* modified on return */
- const size_t *stp,
- const size_t *edp,
- const size_t *const end)
-{
- while(upp < end) {
- *upp++ = *stp++ + *edp++;
- }
-}
-
-
-/*
- * The infamous and oft-discussed odometer code.
- *
- * 'start[]' is the starting coordinate.
- * 'upper[]' is the upper bound s.t. start[ii] < upper[ii].
- * 'coord[]' is the register, the current coordinate value.
- * For some ii,
- * upp == &upper[ii]
- * cdp == &coord[ii]
- *
- * Running this routine increments *cdp.
- *
- * If after the increment, *cdp is equal to *upp
- * (and cdp is not the leftmost dimension),
- * *cdp is "zeroed" to the starting value and
- * we need to "carry", eg, increment one place to
- * the left.
- *
- * TODO: Some architectures hate recursion?
- * Reimplement non-recursively.
- */
-static void
-odo1(const size_t *const start, const size_t *const upper,
- size_t *const coord, /* modified on return */
- const size_t *upp,
- size_t *cdp)
-{
- assert(coord <= cdp && cdp <= coord + NC_MAX_DIMS);
- assert(upper <= upp && upp <= upper + NC_MAX_DIMS);
- assert(upp - upper == cdp - coord);
-
- assert(*cdp <= *upp);
-
- (*cdp)++;
- if(cdp != coord && *cdp >= *upp)
- {
- *cdp = start[cdp - coord];
- odo1(start, upper, coord, upp -1, cdp -1);
- }
-}
-#ifdef _CRAYC
-#pragma _CRI noinline odo1
-#endif
-
-
-dnl
-dnl NCTEXTCOND(Abbrv)
-dnl This is used inside the NC{PUT,GET} macros below
-dnl
-define(`NCTEXTCOND',dnl
-`dnl
-ifelse($1, text,dnl
-`dnl
- if(varp->type != NC_CHAR)
- return NC_ECHAR;
-',dnl
-`dnl
- if(varp->type == NC_CHAR)
- return NC_ECHAR;
-')dnl
-')dnl
-
-
-/* Public */
-
-dnl
-dnl NCPUTVAR1(Abbrev, Type)
-dnl
-define(`NCPUTVAR1',dnl
-`dnl
-int
-nc_put_var1_$1(int ncid, int varid, const size_t *coord,
- const $2 *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
-NCTEXTCOND($1)
- status = NCcoordck(ncp, varp, coord);
- if(status != NC_NOERR)
- return status;
-
- if(IS_RECVAR(varp))
- {
- status = NCvnrecs(ncp, *coord +1);
- if(status != NC_NOERR)
- return status;
- }
-
- return putNCv_$1(ncp, varp, coord, 1, value);
-}
-')dnl
-
-NCPUTVAR1(text, char)
-
-NCPUTVAR1(uchar, uchar)
-NCPUTVAR1(schar, schar)
-NCPUTVAR1(short, short)
-NCPUTVAR1(int, int)
-NCPUTVAR1(long, long)
-NCPUTVAR1(float, float)
-NCPUTVAR1(double, double)
-
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_put_var1(int ncid, int varid, const size_t *coord, const void *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- switch(varp->type){
- case NC_CHAR:
- return nc_put_var1_text(ncid, varid, coord,
- (const char *) value);
- case NC_BYTE:
- return nc_put_var1_schar(ncid, varid, coord,
- (const schar *) value);
- case NC_SHORT:
- return nc_put_var1_short(ncid, varid, coord,
- (const short *) value);
- case NC_INT:
- return nc_put_var1_int(ncid, varid, coord,
- (const int *) value);
- case NC_FLOAT:
- return nc_put_var1_float(ncid, varid, coord,
- (const float *) value);
- case NC_DOUBLE:
- return nc_put_var1_double(ncid, varid, coord,
- (const double *) value);
- }
- return NC_EBADTYPE;
-}
-
-
-dnl
-dnl NCGETVAR1(Abbrv, Type)
-dnl
-define(`NCGETVAR1',dnl
-`dnl
-int
-nc_get_var1_$1(int ncid, int varid, const size_t *coord, $2 *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
-NCTEXTCOND($1)
- status = NCcoordck(ncp, varp, coord);
- if(status != NC_NOERR)
- return status;
-
- return getNCv_$1(ncp, varp, coord, 1, value);
-}
-')dnl
-
-NCGETVAR1(text, char)
-
-NCGETVAR1(uchar, uchar)
-NCGETVAR1(schar, schar)
-NCGETVAR1(short, short)
-NCGETVAR1(int, int)
-NCGETVAR1(long, long)
-NCGETVAR1(float, float)
-NCGETVAR1(double, double)
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_get_var1(int ncid, int varid, const size_t *coord, void *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- switch(varp->type){
- case NC_CHAR:
- return nc_get_var1_text(ncid, varid, coord,
- (char *) value);
- case NC_BYTE:
- return nc_get_var1_schar(ncid, varid, coord,
- (schar *) value);
- case NC_SHORT:
- return nc_get_var1_short(ncid, varid, coord,
- (short *) value);
- case NC_INT:
- return nc_get_var1_int(ncid, varid, coord,
- (int *) value);
- case NC_FLOAT:
- return nc_get_var1_float(ncid, varid, coord,
- (float *) value);
- case NC_DOUBLE:
- return nc_get_var1_double(ncid, varid, coord,
- (double *) value);
- }
- return NC_EBADTYPE;
-}
-
-
-dnl
-dnl NCPUTVARA(Abbrv, Type)
-dnl
-define(`NCPUTVARA',dnl
-`dnl
-int
-nc_put_vara_$1(int ncid, int varid,
- const size_t *start, const size_t *edges, const $2 *value)
-{
- int status = NC_NOERR;
- NC *ncp;
- const NC_var *varp;
- int ii;
- size_t iocount;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
-NCTEXTCOND($1)
- status = NCcoordck(ncp, varp, start);
- if(status != NC_NOERR)
- return status;
- status = NCedgeck(ncp, varp, start, edges);
- if(status != NC_NOERR)
- return status;
-
- if(varp->ndims == 0) /* scalar variable */
- {
- return( putNCv_$1(ncp, varp, start, 1, value) );
- }
-
- if(IS_RECVAR(varp))
- {
- status = NCvnrecs(ncp, *start + *edges);
- if(status != NC_NOERR)
- return status;
-
- if(varp->ndims == 1
- && ncp->recsize <= varp->len)
- {
- /* one dimensional && the only record variable */
- return( putNCv_$1(ncp, varp, start, *edges, value) );
- }
- }
-
- /*
- * find max contiguous
- * and accumulate max count for a single io operation
- */
- ii = NCiocount(ncp, varp, edges, &iocount);
-
- if(ii == -1)
- {
- return( putNCv_$1(ncp, varp, start, iocount, value) );
- }
-
- assert(ii >= 0);
-
-
- { /* inline */
- ALLOC_ONSTACK(coord, size_t, varp->ndims);
- ALLOC_ONSTACK(upper, size_t, varp->ndims);
- const size_t index = ii;
-
- /* copy in starting indices */
- (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
-
- /* set up in maximum indices */
- set_upper(upper, start, edges, &upper[varp->ndims]);
-
- /* ripple counter */
- while(*coord < *upper)
- {
- const int lstatus = putNCv_$1(ncp, varp, coord, iocount,
- value);
- if(lstatus != NC_NOERR)
- {
- if(lstatus != NC_ERANGE)
- {
- status = lstatus;
- /* fatal for the loop */
- break;
- }
- /* else NC_ERANGE, not fatal for the loop */
- if(status == NC_NOERR)
- status = lstatus;
- }
- value += iocount;
- odo1(start, upper, coord, &upper[index], &coord[index]);
- }
-
- FREE_ONSTACK(upper);
- FREE_ONSTACK(coord);
- } /* end inline */
-
- return status;
-}
-')dnl
-
-NCPUTVARA(text, char)
-
-NCPUTVARA(uchar, uchar)
-NCPUTVARA(schar, schar)
-NCPUTVARA(short, short)
-NCPUTVARA(int, int)
-NCPUTVARA(long, long)
-NCPUTVARA(float, float)
-NCPUTVARA(double, double)
-
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_put_vara(int ncid, int varid,
- const size_t *start, const size_t *edges, const void *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
- switch(varp->type){
- case NC_CHAR:
- return nc_put_vara_text(ncid, varid, start, edges,
- (const char *) value);
- case NC_BYTE:
- return nc_put_vara_schar(ncid, varid, start, edges,
- (const schar *) value);
- case NC_SHORT:
- return nc_put_vara_short(ncid, varid, start, edges,
- (const short *) value);
- case NC_INT:
- return nc_put_vara_int(ncid, varid, start, edges,
- (const int *) value);
- case NC_FLOAT:
- return nc_put_vara_float(ncid, varid, start, edges,
- (const float *) value);
- case NC_DOUBLE:
- return nc_put_vara_double(ncid, varid, start, edges,
- (const double *) value);
- }
- return NC_EBADTYPE;
-}
-
-
-dnl
-dnl NCGETVARA(Abbrv, Type)
-dnl
-define(`NCGETVARA',dnl
-`dnl
-int
-nc_get_vara_$1(int ncid, int varid,
- const size_t *start, const size_t *edges, $2 *value)
-{
- int status = NC_NOERR;
- NC *ncp;
- const NC_var *varp;
- int ii;
- size_t iocount;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
-NCTEXTCOND($1)
- status = NCcoordck(ncp, varp, start);
- if(status != NC_NOERR)
- return status;
- status = NCedgeck(ncp, varp, start, edges);
- if(status != NC_NOERR)
- return status;
-
- if(varp->ndims == 0) /* scalar variable */
- {
- return( getNCv_$1(ncp, varp, start, 1, value) );
- }
-
- if(IS_RECVAR(varp))
- {
- if(*start + *edges > ncp->numrecs)
- return NC_EEDGE;
- if(varp->ndims == 1 && ncp->recsize <= varp->len)
- {
- /* one dimensional && the only record variable */
- return( getNCv_$1(ncp, varp, start, *edges, value) );
- }
- }
-
- /*
- * find max contiguous
- * and accumulate max count for a single io operation
- */
- ii = NCiocount(ncp, varp, edges, &iocount);
-
- if(ii == -1)
- {
- return( getNCv_$1(ncp, varp, start, iocount, value) );
- }
-
- assert(ii >= 0);
-
-
- { /* inline */
- ALLOC_ONSTACK(coord, size_t, varp->ndims);
- ALLOC_ONSTACK(upper, size_t, varp->ndims);
- const size_t index = ii;
-
- /* copy in starting indices */
- (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
-
- /* set up in maximum indices */
- set_upper(upper, start, edges, &upper[varp->ndims]);
-
- /* ripple counter */
- while(*coord < *upper)
- {
- const int lstatus = getNCv_$1(ncp, varp, coord, iocount,
- value);
- if(lstatus != NC_NOERR)
- {
- if(lstatus != NC_ERANGE)
- {
- status = lstatus;
- /* fatal for the loop */
- break;
- }
- /* else NC_ERANGE, not fatal for the loop */
- if(status == NC_NOERR)
- status = lstatus;
- }
- value += iocount;
- odo1(start, upper, coord, &upper[index], &coord[index]);
- }
-
- FREE_ONSTACK(upper);
- FREE_ONSTACK(coord);
- } /* end inline */
-
- return status;
-}
-')dnl
-
-NCGETVARA(text, char)
-
-NCGETVARA(uchar, uchar)
-NCGETVARA(schar, schar)
-NCGETVARA(short, short)
-NCGETVARA(int, int)
-NCGETVARA(long, long)
-NCGETVARA(float, float)
-NCGETVARA(double, double)
-
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_get_vara(int ncid, int varid,
- const size_t *start, const size_t *edges, void *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
- switch(varp->type){
- case NC_CHAR:
- return nc_get_vara_text(ncid, varid, start, edges,
- (char *) value);
- case NC_BYTE:
- return nc_get_vara_schar(ncid, varid, start, edges,
- (schar *) value);
- case NC_SHORT:
- return nc_get_vara_short(ncid, varid, start, edges,
- (short *) value);
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- return nc_get_vara_int(ncid, varid, start, edges,
- (int *) value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- return nc_get_vara_long(ncid, varid, start, edges,
- (long *) value);
-#else
-#error "nc_get_vara implementation"
-#endif
- case NC_FLOAT:
- return nc_get_vara_float(ncid, varid, start, edges,
- (float *) value);
- case NC_DOUBLE:
- return nc_get_vara_double(ncid, varid, start, edges,
- (double *) value);
- }
- return NC_EBADTYPE;
-}
-
-#if defined(__cplusplus)
-/* C++ consts default to internal linkage and must be initialized */
-const size_t coord_zero[NC_MAX_VAR_DIMS] = {0};
-#else
-static const size_t coord_zero[NC_MAX_VAR_DIMS];
-#endif
-
-dnl
-dnl NCPUTVAR(Abbrev, Type)
-dnl
-define(`NCPUTVAR',dnl
-`dnl
-int
-nc_put_var_$1(int ncid, int varid, const $2 *value)
-{
- int status = NC_NOERR;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- return NC_EPERM;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
-NCTEXTCOND($1)
- if(varp->ndims == 0) /* scalar variable */
- {
- const size_t zed = 0;
- return( putNCv_$1(ncp, varp, &zed, 1, value) );
- }
-
- if(!IS_RECVAR(varp))
- {
- return(putNCv_$1(ncp, varp, coord_zero, *varp->dsizes, value));
- }
- /* else */
-
- if(varp->ndims == 1
- && ncp->recsize <= varp->len)
- {
- /* one dimensional && the only record variable */
- return(putNCv_$1(ncp, varp, coord_zero, ncp->numrecs, value));
- }
- /* else */
-
- {
- ALLOC_ONSTACK(coord, size_t, varp->ndims);
- size_t elemsPerRec = 1;
- (void) memset(coord, 0, varp->ndims * sizeof(size_t));
- /* TODO: fix dsizes to avoid this nonsense */
- if(varp->ndims > 1)
- elemsPerRec = varp->dsizes[1];
- while(*coord < ncp->numrecs)
- {
- const int lstatus = putNCv_$1(ncp, varp, coord, elemsPerRec,
- value);
- if(lstatus != NC_NOERR)
- {
- if(lstatus != NC_ERANGE)
- {
- status = lstatus;
- /* fatal for the loop */
- break;
- }
- /* else NC_ERANGE, not fatal for the loop */
- if(status == NC_NOERR)
- status = lstatus;
- }
- value += elemsPerRec;
- (*coord)++;
- }
- FREE_ONSTACK(coord);
- } /* elemsPerRec */
-
- return status;
-}
-')dnl
-
-NCPUTVAR(text, char)
-
-NCPUTVAR(uchar, uchar)
-NCPUTVAR(schar, schar)
-NCPUTVAR(short, short)
-NCPUTVAR(int, int)
-NCPUTVAR(long, long)
-NCPUTVAR(float, float)
-NCPUTVAR(double, double)
-
-
-dnl
-dnl NCGETVAR(Abbrv, Type)
-dnl
-define(`NCGETVAR',dnl
-`dnl
-int
-nc_get_var_$1(int ncid, int varid, $2 *value)
-{
- int status = NC_NOERR;
- NC *ncp;
- const NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- return NC_EINDEFINE;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
-
- if(varp->ndims == 0) /* scalar variable */
- {
- const size_t zed = 0;
- return( getNCv_$1(ncp, varp, &zed, 1, value) );
- }
-
-NCTEXTCOND($1)
-
- if(!IS_RECVAR(varp))
- {
- return(getNCv_$1(ncp, varp, coord_zero, *varp->dsizes, value));
- }
- /* else */
-
- if(varp->ndims == 1
- && ncp->recsize <= varp->len)
- {
- /* one dimensional && the only record variable */
- return(getNCv_$1(ncp, varp, coord_zero, ncp->numrecs, value));
- }
- /* else */
-
- {
- ALLOC_ONSTACK(coord, size_t, varp->ndims);
- size_t elemsPerRec = 1;
- (void) memset(coord, 0, varp->ndims * sizeof(size_t));
- /* TODO: fix dsizes to avoid this nonsense */
- if(varp->ndims > 1)
- elemsPerRec = varp->dsizes[1];
- while(*coord < ncp->numrecs)
- {
- const int lstatus = getNCv_$1(ncp, varp, coord, elemsPerRec,
- value);
- if(lstatus != NC_NOERR)
- {
- if(lstatus != NC_ERANGE)
- {
- status = lstatus;
- /* fatal for the loop */
- break;
- }
- /* else NC_ERANGE, not fatal for the loop */
- if(status == NC_NOERR)
- status = lstatus;
- }
- value += elemsPerRec;
- (*coord)++;
- }
- FREE_ONSTACK(coord);
- } /* elemsPerRec */
-
- return status;
-}
-')dnl
-
-NCGETVAR(text, char)
-
-NCGETVAR(uchar, uchar)
-NCGETVAR(schar, schar)
-NCGETVAR(short, short)
-NCGETVAR(int, int)
-NCGETVAR(long, long)
-NCGETVAR(float, float)
-NCGETVAR(double, double)
-
-
-/* Begin putgetg.c */
-
-dnl
-dnl NC_VARM_Upper_Body(void)
-dnl
-define(`NC_VARM_Upper_Body',dnl
-`dnl
- int status = ENOERR;
- NC *ncp;
- NC_var *varp;
- int maxidim; /* maximum dimensional index */
-
- status = NC_check_id (ncid, &ncp);
- if (status != NC_NOERR)
- return status;
-
- if (NC_indef (ncp))
- {
- return NC_EINDEFINE;
- }
-')dnl
-dnl
-dnl NC_VARM_Mid_Body(put_or_get, Abbrv)
-dnl
-define(`NC_VARM_Mid_Body',dnl
-`dnl
- varp = NC_lookupvar (ncp, varid);
- if (varp == NULL)
- return NC_ENOTVAR;
-
-NCTEXTCOND($2)
- maxidim = (int) varp->ndims - 1;
-
- if (maxidim < 0)
- {
- /*
- * The variable is a scalar; consequently,
- * there s only one thing to get and only one place to put it.
- * (Why was I called?)
- */
- return $1 (ncp, varp, start, 1, value);
- }
-
- /*
- * else
- * The variable is an array.
- */
- {
- 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;
-
- /*
- * Verify stride argument.
- */
- for (idim = 0; idim <= maxidim; ++idim)
- {
- if (stride != NULL
- && (stride[idim] == 0
- /* cast needed for braindead systems with signed size_t */
- || (unsigned long) stride[idim] >= X_INT_MAX))
- {
- return NC_ESTRIDE;
- }
- }
-
- /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
- mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
- if(mystart == NULL)
- return NC_ENOMEM;
- myedges = mystart + varp->ndims;
- iocount = myedges + varp->ndims;
- stop = iocount + varp->ndims;
- length = stop + varp->ndims;
- mystride = (ptrdiff_t *)(length + varp->ndims);
- mymap = mystride + varp->ndims;
-
- /*
- * Initialize I/O parameters.
- */
- for (idim = maxidim; idim >= 0; --idim)
- {
- mystart[idim] = start != NULL
- ? start[idim]
- : 0;
-
- if (edges[idim] == 0)
- {
- status = NC_NOERR; /* read/write no data */
- goto done;
- }
-
- myedges[idim] = edges != NULL
- ? edges[idim]
- : idim == 0 && IS_RECVAR (varp)
- ? ncp->numrecs - mystart[idim]
- : varp->shape[idim] - mystart[idim];
- mystride[idim] = stride != NULL
- ? stride[idim]
- : 1;
- mymap[idim] = map != NULL
- ? map[idim]
- : idim == maxidim
- ? 1
- : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
-
- iocount[idim] = 1;
- length[idim] = mymap[idim] * myedges[idim];
- stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
- }
-')dnl
-dnl
-dnl NC_VARM_Lower_Body(put_or_get)
-dnl
-define(`NC_VARM_Lower_Body',dnl
-`dnl
- /*
- * As an optimization, adjust I/O parameters when the fastest
- * dimension has unity stride both externally and internally.
- * In this case, the user could have called a simpler routine
- * (i.e. ncvar$1()
- */
- if (mystride[maxidim] == 1
- && mymap[maxidim] == 1)
- {
- iocount[maxidim] = myedges[maxidim];
- mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
- mymap[maxidim] = (ptrdiff_t) length[maxidim];
- }
-
- /*
- * Perform I/O. Exit when done.
- */
- for (;;)
- {
- /* TODO: */
- int lstatus = $1 (ncid, varid, mystart, iocount,
- value);
- if (lstatus != NC_NOERR
- && (status == NC_NOERR || lstatus != NC_ERANGE))
- status = lstatus;
-
- /*
- * The following code permutes through the variable s
- * external start-index space and it s internal address
- * space. At the UPC, this algorithm is commonly
- * called "odometer code".
- */
- idim = maxidim;
- carry:
- value += mymap[idim];
- mystart[idim] += mystride[idim];
- if (mystart[idim] == stop[idim])
- {
- mystart[idim] = start[idim];
- value -= length[idim];
- if (--idim < 0)
- break; /* normal return */
- goto carry;
- }
- } /* I/O loop */
- done:
- free(mystart);
- } /* variable is array */
- return status;
-')dnl
-
-dnl
-dnl NCGETVARS(Abbrv, Type)
-dnl
-define(`NCGETVARS',dnl
-`dnl
-int
-nc_get_vars_$1 (
- int ncid,
- int varid,
- const size_t * start,
- const size_t * edges,
- const ptrdiff_t * stride,
- $2 *value)
-{
- return nc_get_varm_$1 (ncid, varid, start, edges,
- stride, 0, value);
-}
-')dnl
-
-NCGETVARS(text, char)
-
-NCGETVARS(uchar, uchar)
-NCGETVARS(schar, schar)
-NCGETVARS(short, short)
-NCGETVARS(int, int)
-NCGETVARS(long, long)
-NCGETVARS(float, float)
-NCGETVARS(double, double)
-
-int
-nc_get_vars (
- int ncid,
- int varid,
- const size_t * start,
- const size_t * edges,
- const ptrdiff_t * stride,
- void *value)
-{
- return nc_get_varm (ncid, varid, start, edges,
- stride, 0, value);
-}
-
-
-dnl
-dnl NCPUTVARS(Abbrv, Type)
-dnl
-define(`NCPUTVARS',dnl
-`dnl
-int
-nc_put_vars_$1 (
- int ncid,
- int varid,
- const size_t * start,
- const size_t * edges,
- const ptrdiff_t * stride,
- const $2 *value)
-{
- return nc_put_varm_$1 (ncid, varid, start, edges,
- stride, 0, value);
-}
-')dnl
-
-NCPUTVARS(text, char)
-
-NCPUTVARS(uchar, uchar)
-NCPUTVARS(schar, schar)
-NCPUTVARS(short, short)
-NCPUTVARS(int, int)
-NCPUTVARS(long, long)
-NCPUTVARS(float, float)
-NCPUTVARS(double, double)
-
-int
-nc_put_vars (
- int ncid,
- int varid,
- const size_t * start,
- const size_t * edges,
- const ptrdiff_t * stride,
- const void *value)
-{
- return nc_put_varm (ncid, varid, start, edges,
- stride, 0, value);
-}
-
-
-/*
- * Generalized hyperslab input.
- */
-dnl
-dnl NCGETVARM(Abbrv, Type)
-dnl
-define(`NCGETVARM',dnl
-`dnl
-int
-nc_get_varm_$1(int ncid, int varid,
- const size_t *start, const size_t *edges,
- const ptrdiff_t *stride,
- const ptrdiff_t *map,
- $2 *value)
-{
-NC_VARM_Upper_Body()
-NC_VARM_Mid_Body(getNCv_$1, $1)
- /*
- * Check start, edges
- */
- for (idim = maxidim; idim >= 0; --idim)
- {
- size_t dimlen =
- idim == 0 && IS_RECVAR (varp)
- ? ncp->numrecs : varp->shape[idim];
- if (mystart[idim] >= dimlen)
- {
- status = NC_EINVALCOORDS;
- goto done;
- }
-
- if (mystart[idim] + myedges[idim] > dimlen)
- {
- status = NC_EEDGE;
- goto done;
- }
-
- }
-NC_VARM_Lower_Body(nc_get_vara_$1)
-}
-')dnl
-
-NCGETVARM(text, char)
-
-NCGETVARM(uchar, uchar)
-NCGETVARM(schar, schar)
-NCGETVARM(short, short)
-NCGETVARM(int, int)
-NCGETVARM(long, long)
-NCGETVARM(float, float)
-NCGETVARM(double, double)
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_get_varm (
- int ncid,
- int varid,
- const size_t * start,
- const size_t * edges,
- const ptrdiff_t * stride,
- const ptrdiff_t * map,
- void *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
- ptrdiff_t *cvtmap = NULL;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- if(map != NULL && varp->ndims != 0)
- {
- /*
- * convert map units from bytes to units of sizeof(type)
- */
- size_t ii;
- const ptrdiff_t szof = (ptrdiff_t) nctypelen(varp->type);
- cvtmap = (ptrdiff_t *)calloc(varp->ndims, sizeof(ptrdiff_t));
- if(cvtmap == NULL)
- return NC_ENOMEM;
- for(ii = 0; ii < varp->ndims; ii++)
- {
- if(map[ii] % szof != 0)
- {
- free(cvtmap);
- return NC_EINVAL;
- }
- cvtmap[ii] = map[ii] / szof;
- }
- map = cvtmap;
- }
-
- switch(varp->type){
- case NC_CHAR:
- status = nc_get_varm_text(ncid, varid, start, edges,
- stride, map,
- (char *) value);
- break;
- case NC_BYTE:
- status = nc_get_varm_schar(ncid, varid, start, edges,
- stride, map,
- (schar *) value);
- break;
- case NC_SHORT:
- status = nc_get_varm_short(ncid, varid, start, edges,
- stride, map,
- (short *) value);
- break;
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- status = nc_get_varm_int(ncid, varid, start, edges,
- stride, map,
- (int *) value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- status = nc_get_varm_long(ncid, varid, start, edges,
- stride, map,
- (long *) value);
-#else
-#error "nc_get_varm implementation"
-#endif
- break;
- case NC_FLOAT:
- status = nc_get_varm_float(ncid, varid, start, edges,
- stride, map,
- (float *) value);
- break;
- case NC_DOUBLE:
- status = nc_get_varm_double(ncid, varid, start, edges,
- stride, map,
- (double *) value);
- break;
- default:
- status = NC_EBADTYPE;
- break;
- }
-
- if(cvtmap != NULL)
- {
- free(cvtmap);
- }
- return status;
-}
-
-
-/*
- * Generalized hyperslab output.
- */
-dnl
-dnl NCPUTVARM(Abbrv, Type)
-dnl
-define(`NCPUTVARM',dnl
-`dnl
-int
-nc_put_varm_$1(int ncid, int varid,
- const size_t *start, const size_t *edges,
- const ptrdiff_t *stride, const ptrdiff_t *map,
- const $2 *value)
-{
-NC_VARM_Upper_Body()
- if (NC_readonly (ncp))
- return NC_EPERM;
-NC_VARM_Mid_Body(putNCv_$1, $1)
- /*
- * Check start, edges
- */
- for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
- {
- if (mystart[idim] >= varp->shape[idim])
- {
- status = NC_EINVALCOORDS;
- goto done;
- }
- if (mystart[idim] + myedges[idim] > varp->shape[idim])
- {
- status = NC_EEDGE;
- goto done;
- }
- }
-NC_VARM_Lower_Body(nc_put_vara_$1)
-}
-')dnl
-
-NCPUTVARM(text, char)
-
-NCPUTVARM(uchar, uchar)
-NCPUTVARM(schar, schar)
-NCPUTVARM(short, short)
-NCPUTVARM(int, int)
-NCPUTVARM(long, long)
-NCPUTVARM(float, float)
-NCPUTVARM(double, double)
-
-
-/* deprecated, used to support the 2.x interface */
-int
-nc_put_varm (
- int ncid,
- int varid,
- const size_t * start,
- const size_t * edges,
- const ptrdiff_t * stride,
- const ptrdiff_t * map,
- const void *value)
-{
- int status;
- NC *ncp;
- const NC_var *varp;
- ptrdiff_t *cvtmap = NULL;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- if(map != NULL && varp->ndims != 0)
- {
- /*
- * convert map units from bytes to units of sizeof(type)
- */
- size_t ii;
- const ptrdiff_t szof = (ptrdiff_t) nctypelen(varp->type);
- cvtmap = (ptrdiff_t *)calloc(varp->ndims, sizeof(ptrdiff_t));
- if(cvtmap == NULL)
- return NC_ENOMEM;
- for(ii = 0; ii < varp->ndims; ii++)
- {
- if(map[ii] % szof != 0)
- {
- free(cvtmap);
- return NC_EINVAL;
- }
- cvtmap[ii] = map[ii] / szof;
- }
- map = cvtmap;
- }
-
- switch(varp->type){
- case NC_CHAR:
- status = nc_put_varm_text(ncid, varid, start, edges,
- stride, map,
- (const char *) value);
- break;
- case NC_BYTE:
- status = nc_put_varm_schar(ncid, varid, start, edges,
- stride, map,
- (const schar *) value);
- break;
- case NC_SHORT:
- status = nc_put_varm_short(ncid, varid, start, edges,
- stride, map,
- (const short *) value);
- break;
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- status = nc_put_varm_int(ncid, varid, start, edges,
- stride, map,
- (const int *) value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- status = nc_put_varm_long(ncid, varid, start, edges,
- stride, map,
- (const long *) value);
-#else
-#error "nc_put_varm implementation"
-#endif
- break;
- case NC_FLOAT:
- status = nc_put_varm_float(ncid, varid, start, edges,
- stride, map,
- (const float *) value);
- break;
- case NC_DOUBLE:
- status = nc_put_varm_double(ncid, varid, start, edges,
- stride, map,
- (const double *) value);
- break;
- default:
- status = NC_EBADTYPE;
- break;
- }
-
- if(cvtmap != NULL)
- {
- free(cvtmap);
- }
- return status;
-}
-
-
-/* Begin recio, deprecated */
-
-/*
- * input 'nelems' items of contiguous data of 'varp' at 'start'
- * N.B. this function deprecated.
- */
-static int
-getNCvdata(const NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, void *value)
-{
- switch(varp->type){
- case NC_CHAR:
- return getNCvx_char_char(ncp, varp, start, nelems,
- (char *) value);
- case NC_BYTE:
- return getNCvx_schar_schar(ncp, varp, start, nelems,
- (schar *) value);
- case NC_SHORT:
- return getNCvx_short_short(ncp, varp, start, nelems,
- (short *) value);
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- return getNCvx_int_int(ncp, varp, start, nelems,
- (int *) value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- return getNCvx_int_long(ncp, varp, start, nelems,
- (long *) value);
-#else
-#error "getNCvdata implementation"
-#endif
- case NC_FLOAT:
- return getNCvx_float_float(ncp, varp, start, nelems,
- (float *) value);
- case NC_DOUBLE:
- return getNCvx_double_double(ncp, varp, start, nelems,
- (double *) value);
- }
- return NC_EBADTYPE;
-}
-
-
-/*
- * output 'nelems' items of contiguous data of 'varp' at 'start'
- * N.B. this function deprecated.
- */
-static int
-putNCvdata(NC *ncp, const NC_var *varp,
- const size_t *start, size_t nelems, const void *value)
-{
- switch(varp->type){
- case NC_CHAR:
- return putNCvx_char_char(ncp, varp, start, nelems,
- (const char *) value);
- case NC_BYTE:
- return putNCvx_schar_schar(ncp, varp, start, nelems,
- (const schar *) value);
- case NC_SHORT:
- return putNCvx_short_short(ncp, varp, start, nelems,
- (const short *) value);
- case NC_INT:
-#if (SIZEOF_INT >= X_SIZEOF_INT)
- return putNCvx_int_int(ncp, varp, start, nelems,
- (const int *) value);
-#elif SIZEOF_LONG == X_SIZEOF_INT
- return putNCvx_long_int(ncp, varp, start, nelems,
- (const long *) value);
-#else
-#error "putNCvdata implementation"
-#endif
- case NC_FLOAT:
- return putNCvx_float_float(ncp, varp, start, nelems,
- (const float *) value);
- case NC_DOUBLE:
- return putNCvx_double_double(ncp, varp, start, nelems,
- (const double *) value);
- }
- return NC_EBADTYPE;
-}
-
-
-static size_t
-NCelemsPerRec(
- const NC_var *varp)
-{
- size_t nelems = 1;
- size_t jj;
- for(jj = 1; jj < varp->ndims; jj++)
- nelems *= varp->shape[jj];
- return nelems;
-}
-
-
-/*
- * Retrieves the number of record variables, the record variable ids, and the
- * record size of each record variable. If any pointer to info to be returned
- * is null, the associated information is not returned. Returns -1 on error.
- */
-int
-nc_inq_rec(
- int ncid,
- size_t *nrecvars,
- int *recvarids,
- size_t *recsizes)
-{
- NC *ncp;
-
- {
- const int status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- {
- size_t nrvars = 0;
- size_t ii = 0;
- for(; ii < ncp->vars.nelems; ii++)
- {
- const NC_var *const varp = ncp->vars.value[ii];
- if(!IS_RECVAR(varp))
- continue;
-
- if(recvarids != NULL)
- recvarids[nrvars] = (int) ii;
- if(recsizes != NULL)
- {
- *recsizes++ = nctypelen(varp->type)
- * NCelemsPerRec(varp);
- }
- nrvars++;
- }
-
- if(nrecvars != NULL)
- *nrecvars = nrvars;
- }
-
- return NC_NOERR;
-}
-
-
-static int
-NCrecput(
- NC *ncp,
- size_t recnum,
- void *const *datap)
-{
- int status = NC_NOERR;
- size_t nrvars = 0;
- NC_var *varp;
- size_t ii;
- size_t iocount;
- ALLOC_ONSTACK(coord, size_t, ncp->dims.nelems);
-
- assert(ncp->dims.nelems != 0);
-
- (void) memset(coord, 0, ncp->dims.nelems * sizeof(size_t));
- coord[0] = recnum;
- for(ii = 0; ii < ncp->vars.nelems; ii++)
- {
- varp = ncp->vars.value[ii];
- if(!IS_RECVAR(varp))
- continue;
- /* else */
- nrvars++;
- if(*datap == NULL)
- {
- datap++;
- continue;
- }
- /* else */
- iocount = NCelemsPerRec(varp);
- status = putNCvdata(ncp, varp, coord, iocount, *datap++);
- if(status != NC_NOERR)
- break;
- }
- if(nrvars == 0 && status == NC_NOERR)
- {
- status = NC_ENORECVARS;
- }
-
- FREE_ONSTACK(coord);
- return status;
-}
-
-
-static int
-NCrecget(
- NC *ncp,
- size_t recnum,
- void **datap)
-{
- int status = NC_NOERR;
- size_t nrvars = 0;
- NC_var *varp;
- size_t ii;
- size_t iocount;
- ALLOC_ONSTACK(coord, size_t, ncp->dims.nelems);
-
- assert(ncp->dims.nelems != 0);
-
- (void) memset(coord, 0, ncp->dims.nelems * sizeof(size_t));
- coord[0] = recnum;
- for(ii = 0; ii < ncp->vars.nelems; ii++)
- {
- varp = ncp->vars.value[ii];
- if(!IS_RECVAR(varp))
- continue;
- /* else */
- nrvars++;
- if(*datap == NULL)
- {
- datap++;
- continue;
- }
- /* else */
- iocount = NCelemsPerRec(varp);
- status = getNCvdata(ncp, varp, coord, iocount, *datap++);
- if(status != NC_NOERR)
- break;
- }
- if(nrvars == 0 && status == NC_NOERR)
- {
- status = NC_ENORECVARS;
- }
-
- FREE_ONSTACK(coord);
- return status;
-}
-
-
-/*
- * Write one record's worth of data, except don't write to variables for which
- * the address of the data to be written is null. Return -1 on error.
- */
-int
-nc_put_rec(
- int ncid,
- size_t recnum,
- void * const *datap)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- {
- return NC_EPERM;
- }
-
- if(NC_indef(ncp))
- {
- return NC_EINDEFINE;
- }
-
- status = NCvnrecs(ncp, recnum +1);
- if(status != NC_NOERR)
- return status;
-
- return( NCrecput(ncp, recnum, datap) );
-}
-
-
-/*
- * Read one record's worth of data, except don't read from variables for which
- * the address of the data to be read is null. Return -1 on error;
- */
-int
-nc_get_rec(
- int ncid,
- size_t recnum,
- void **datap)
-{
- int status;
- NC *ncp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_indef(ncp))
- {
- return NC_EINDEFINE;
- }
-
- if(recnum >= ncp->numrecs)
- {
- return NC_EINVALCOORDS;
- }
-
- return( NCrecget(ncp, recnum, datap) );
-}
-
-
-/*
- * Copy the values of a variable from an input netCDF to an output netCDF.
- * Input and output var assummed to have the same shape.
- * return -1 on error.
- */
-int
-nc_copy_var(int ncid_in, int varid, int ncid_out)
-{
- int status = NC_NOERR;
- NC *inncp, *outncp;
- NC_var *invp, *outvp;
-
- status = NC_check_id(ncid_in, &inncp);
- if(status != NC_NOERR)
- return status;
-
-
- if(NC_indef(inncp))
- {
- return NC_EINDEFINE;
- }
-
- status = NC_check_id(ncid_out, &outncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(outncp))
- {
- /* output file isn't writable */
- return NC_EPERM;
- }
-
- if(NC_indef(outncp))
- {
- return NC_EINDEFINE;
- }
-
- /* find the variable in the input cdf */
- invp = NC_lookupvar(inncp, varid);
- if(invp == NULL)
- {
- return NC_ENOTVAR;
- }
-
- /* find the variable in the output cdf */
- if(NC_findvar(&outncp->vars, invp->name->cp, &outvp) == -1)
- {
- return NC_ENOTVAR;
- }
-
- /* can we even attempt to copy without conversion? */
- if(outvp->type != invp->type)
- {
- return NC_EINVAL;
- }
-
- if( (invp->ndims == 0 && outvp->ndims != 0)
- || (invp->ndims != 0 && outvp->ndims == 0)
- || (IS_RECVAR(invp) && !IS_RECVAR(outvp))
- || (!IS_RECVAR(invp) && IS_RECVAR(outvp))
- || (invp->len != outvp->len)
- )
- {
- return NC_EINVAL;
- }
-
- /*
- * Check coordinates
- */
- {
- ALLOC_ONSTACK(coord, size_t, invp->ndims);
- (void) memcpy(coord, invp->shape, invp->ndims * sizeof(size_t));
- if(IS_RECVAR(invp))
- *coord = inncp->numrecs;
-
- {
- size_t ii = 0;
- for(; ii < invp->ndims; ii++)
- coord[ii] --;
- }
- /* at this point, coord is the largest valid coord of invp */
-
- if(NCcoordck(outncp, outvp, coord) != NC_NOERR)
- {
- return NC_EINVAL;
- }
- /* else */
-
- (void) memset(coord, 0, invp->ndims * sizeof(size_t));
-
- if(!IS_RECVAR(invp))
- {
- status = NCxvarcpy(inncp, invp, coord,
- outncp, outvp, coord,
- invp->len);
- goto done;
- }
- /* else */
-
- status = NCvnrecs(outncp, inncp->numrecs);
- if(status != NC_NOERR)
- goto done;
-
- for( /*NADA*/; *coord < inncp->numrecs; (*coord)++)
- {
- status = NCxvarcpy(inncp, invp, coord,
- outncp, outvp, coord,
- invp->len);
- if(status != NC_NOERR)
- break;
- }
-done:
- FREE_ONSTACK(coord);
- }
- return status;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/rnd.h b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/rnd.h
deleted file mode 100644
index 571bebb..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/rnd.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: rnd.h,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-#ifndef _RNDUP
-
-/* useful for aligning memory */
-#define _RNDUP(x, unit) ((((x) + (unit) - 1) / (unit)) \
- * (unit))
-#define _RNDDOWN(x, unit) ((x) - ((x)%(unit)))
-
-#define M_RND_UNIT (sizeof(double))
-#define M_RNDUP(x) _RNDUP(x, M_RND_UNIT)
-#define M_RNDDOWN(x) __RNDDOWN(x, M_RND_UNIT)
-
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/string.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/string.c
deleted file mode 100644
index 95e8ac0..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/string.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: string.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-#include "ncx.h"
-#include "rnd.h"
-
-
-/*
- * Free string, and, if needed, its values.
- * Formerly
-NC_free_string()
- */
-void
-free_NC_string(NC_string *ncstrp)
-{
- if(ncstrp==NULL)
- return;
- free(ncstrp);
-}
-
-
-/*
- * Verify that a name string is valid
- * CDL syntax, eg, all the characters are
- * alphanumeric, '-', '_', or '.'.
- */
-int
-NC_check_name(const char *name)
-{
- const char *cp = name;
- assert(name != NULL);
-
- if(*name == 0)
- return NC_EBADNAME; /* empty names disallowed */
-
- for(; *cp != 0; cp++)
- {
- int ch = *cp;
- if(!isalnum(ch))
- {
- if(ch != '_' && ch != '-' && ch != '.')
- return NC_EBADNAME;
- }
- }
- if(cp - name > NC_MAX_NAME)
- return NC_EMAXNAME;
-
- return NC_NOERR;
-}
-
-
-/*
- * Allocate a NC_string structure large enough
- * to hold slen characters.
- * Formerly
-NC_new_string(count, str)
- */
-NC_string *
-new_NC_string(size_t slen, const char *str)
-{
- NC_string *ncstrp;
- size_t sz = M_RNDUP(sizeof(NC_string)) + slen + 1;
-
-#if 0
- sz = _RNDUP(sz, X_ALIGN);
-#endif
-
- ncstrp = (NC_string *)malloc(sz);
- if( ncstrp == NULL )
- return NULL;
- (void) memset(ncstrp, 0, sz);
-
- ncstrp->nchars = sz - M_RNDUP(sizeof(NC_string)) - 1;
- assert(ncstrp->nchars + 1 > slen);
- ncstrp->cp = (char *)ncstrp + M_RNDUP(sizeof(NC_string));
-
- if(str != NULL && *str != 0)
- {
- (void) strncpy(ncstrp->cp, str, ncstrp->nchars +1);
- ncstrp->cp[ncstrp->nchars] = 0;
- }
-
- return(ncstrp);
-}
-
-
-/*
- * If possible, change the value of an NC_string to 'str'.
- *
- * Formerly
-NC_re_string()
- */
-int
-set_NC_string(NC_string *ncstrp, const char *str)
-{
- size_t slen;
- size_t diff;
-
- assert(str != NULL && *str != 0);
-
- slen = strlen(str);
-
- if(ncstrp->nchars < slen)
- return NC_ENOTINDEFINE;
-
- (void) memcpy(ncstrp->cp, str, slen);
- diff = ncstrp->nchars - slen;
- if(diff != 0)
- (void) memset(ncstrp->cp + slen, 0, diff);
-
- return NC_NOERR;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_nc.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_nc.c
deleted file mode 100644
index 729637d..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_nc.c
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- * Copyright 1988 University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: t_nc.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-/*
- * Program to create a cdf, exercise all cdf functions.
- * Creates cdf, stuff it full of numbers, closes it. Then
- * reopens it, and checks for consistancy.
- * Leaves the file around afterwards.
- *
- * Based on a program to test the nasa look-alike program,
- * so not the most appropropriate test. See ../nctest for a
- * complete spec test.
- */
-
-
-#define REDEF
-/* #define SYNCDEBUG */
-
-#undef NDEBUG /* always active assert() in this file */
-
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "netcdf.h"
-
-
-#define MAXSHORT 32767
-#define MAXINT 2147483647
-#define MAXBYTE 127
-
-
-#define FNAME "test.nc"
-#define NUM_DIMS 3
-#define DONT_CARE -1
-/* make these numbers big when you want to give this a real workout */
-#define NUM_RECS 8
-#define SIZE_1 7
-#define SIZE_2 8
-
-static struct {
- int num_dims;
- int num_vars;
- int num_attrs;
- int xtendim;
-} cdesc[1];
-
-static struct {
- char mnem[NC_MAX_NAME];
- nc_type type;
- int ndims;
- int dims[NC_MAX_DIMS];
- int num_attrs;
-} vdesc[1];
-
-static struct {
- char mnem[NC_MAX_NAME];
- nc_type type;
- size_t len;
-} adesc[1];
-
-union getret
-{
- char by[8];
- short sh[4];
- int in[2];
- float fl[2];
- double dbl;
-};
-
-
-static void
-chkgot(nc_type type, union getret got, double check)
-{
- switch(type){
- case NC_BYTE :
- assert( (char)check == got.by[0] );
- break;
- case NC_CHAR : /* TODO */
- assert( (char)check == got.by[0] );
- break;
- case NC_SHORT :
- assert( (short)check == got.sh[0] );
- break;
- case NC_INT :
- assert( (int)check == got.in[0] );
- break;
- case NC_FLOAT :
- assert( (float)check == got.fl[0] );
- break;
- case NC_DOUBLE :
- assert( check == got.dbl );
- break;
- default:
- break;
- }
-}
-
-static char *fname = FNAME;
-
-
-static size_t num_dims = NUM_DIMS;
-static size_t sizes[] = { NC_UNLIMITED, SIZE_1 , SIZE_2 };
-static char *dim_names[] = { "record", "ixx", "iyy"};
-
-static void
-createtestdims(int cdfid, size_t num_dims, size_t *sizes, char *dim_names[])
-{
- int dimid;
- while(num_dims-- != 0)
- {
- assert( nc_def_dim(cdfid, *dim_names++, *sizes, &dimid)
- == NC_NOERR);
- sizes++;
- }
-
-}
-
-
-static void
-testdims(int cdfid, size_t num_dims, size_t *sizes, char *dim_names[])
-{
- int ii;
- size_t size;
- char cp[NC_MAX_NAME];
- for(ii=0; (size_t) ii < num_dims; ii++, sizes++)
- {
- assert( nc_inq_dim(cdfid, ii, cp, &size) == NC_NOERR);
- if( size != *sizes)
- (void) fprintf(stderr, "%d: %lu != %lu\n",
- ii, (unsigned long)size, (unsigned long)*sizes);
- assert( size == *sizes);
- assert( strcmp(cp, *dim_names++) == 0);
- }
-
-}
-
-
-
-static char *reqattr[] = {
- "UNITS",
- "VALIDMIN",
- "VALIDMAX",
- "SCALEMIN",
- "SCALEMAX",
- "FIELDNAM",
- _FillValue
-};
-#define NUM_RATTRS 6
-
-static struct tcdfvar {
- char *mnem;
- nc_type type;
- char *fieldnam;
- double validmin;
- double validmax;
- double scalemin;
- double scalemax;
- char *units;
- int ndims;
- int dims[NUM_DIMS];
-} testvars[] = {
-#define Byte_id 0
- { "Byte", NC_BYTE, "Byte sized integer variable",
- -MAXBYTE, MAXBYTE, -MAXBYTE, MAXBYTE , "ones",
- 2, {0,1,DONT_CARE} },
-#define Char_id 1
- { "Char", NC_CHAR, "char (string) variable",
- DONT_CARE, DONT_CARE, DONT_CARE, DONT_CARE, "(unitless)",
- 2, {0,2,DONT_CARE} },
-#define Short_id 2
- { "Short", NC_SHORT, "Short variable",
- -MAXSHORT, MAXSHORT, -MAXSHORT, MAXSHORT , "ones",
- 2, {0, 2, DONT_CARE }},
-#define Long_id 3
- { "Long", NC_INT, "Long Integer variable", /* 2.x backward strings */
- -MAXINT, MAXINT, -MAXINT, MAXINT, "ones",
- 2, {1, 2, DONT_CARE}},
-#define Float_id 4
- { "Float", NC_FLOAT, "Single Precision Floating Point variable",
- -MAXINT, MAXINT, -MAXINT, MAXINT, "flots",
- 3, {0, 1, 2 }},
-#define Double_id 5
- { "Double", NC_DOUBLE, "Double Precision Floating Point variable",
- -MAXINT, MAXINT, -MAXINT, MAXINT, "dflots",
- 3, {0, 1, 2 }},
-};
-#define NUM_TESTVARS 6
-
-static void
-createtestvars(int id, struct tcdfvar *testvars, size_t count)
-{
- int ii;
- int varid;
- struct tcdfvar *vp = testvars;
-
- for(ii = 0; (size_t) ii < count; ii++, vp++ )
- {
- assert(nc_def_var(id, vp->mnem, vp->type, vp->ndims, vp->dims,
- &varid)
- == NC_NOERR );
-
- assert(
- nc_put_att_text(id,ii,reqattr[0],strlen(vp->units),
- vp->units)
- == NC_NOERR);
- assert(
- nc_put_att_double(id,ii,reqattr[1],NC_DOUBLE,1,
- &vp->validmin)
- == NC_NOERR);
- assert(
- nc_put_att_double(id,ii,reqattr[2],NC_DOUBLE,1,
- &vp->validmax)
- == NC_NOERR);
- assert(
- nc_put_att_double(id,ii,reqattr[3],NC_DOUBLE,1,
- &vp->scalemin)
- == NC_NOERR);
- assert(
- nc_put_att_double(id,ii,reqattr[4],NC_DOUBLE,1,
- &vp->scalemax)
- == NC_NOERR);
- assert(
- nc_put_att_text(id,ii,reqattr[5],strlen(vp->fieldnam),
- vp->fieldnam)
- == NC_NOERR);
- }
-}
-
-static void
-parray(char *label, size_t count, size_t array[])
-{
- (void) fprintf(stdout, "%s", label);
- (void) fputc('\t',stdout);
- for(; count != 0; count--, array++)
- (void) fprintf(stdout," %lu", (unsigned long) *array);
-}
-
-
-static void
-fill_seq(int id)
-{
- float values[NUM_RECS * SIZE_1 * SIZE_2];
- size_t vindices[NUM_DIMS];
-
- {
- size_t ii = 0;
- for(; ii < sizeof(values)/sizeof(values[0]); ii++)
- {
- values[ii] = (float) ii;
- }
- }
-
- /* zero the vindices */
- {
- size_t *cc = vindices;
- while (cc < &vindices[num_dims])
- *cc++ = 0;
- }
-
- sizes[0] = NUM_RECS;
-
- assert( nc_put_vara_float(id, Float_id, vindices, sizes, values)== NC_NOERR);
-
-}
-
-static void
-check_fill_seq(int id)
-{
- size_t vindices[NUM_DIMS];
- size_t *cc, *mm;
- union getret got;
- int ii = 0;
- float val;
-
- sizes[0] = NUM_RECS;
- cc = vindices;
- while (cc < &vindices[num_dims])
- *cc++ = 0;
-
- /* ripple counter */
- cc = vindices;
- mm = sizes;
- while (*vindices < *sizes)
- {
- while (*cc < *mm)
- {
- if (mm == &sizes[num_dims - 1])
- {
- if(nc_get_var1_float(id, Float_id, vindices, &got.fl[0]) == -1)
- goto bad_ret;
- val = (float) ii;
- if(val != got.fl[0])
- {
- parray("indices", NUM_DIMS, vindices);
- (void) printf("\t%f != %f\n", val, got.fl[0]);
- }
- (*cc)++; ii++;
- continue;
- }
- cc++;
- mm++;
- }
- if(cc == vindices)
- break;
- *cc = 0;
- cc--;
- mm--;
- (*cc)++;
- }
- return;
-bad_ret :
- (void) printf("couldn't get a var in check_fill_seq() %d\n",
- ii);
- return;
-}
-
-static size_t indices[][3] = {
- {0, 1, 3},
- {0, 3, 0},
- {1, 2, 3},
- {3, 2, 1},
- {2, 1, 3},
- {1, 0, 0},
- {0, 0, 0},
-};
-
-static char chs[] = {'A','B', ((char)0xff) };
-static size_t s_start[] = {0,1};
-static 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 short shs[] = {97, 99};
-static int birthday = 82555;
-#define M_E 2.7182818284590452354
-static float e = (float) M_E;
-static double pinot = 3.25;
-static double zed = 0.0;
-
-
-/*ARGSUSED*/
-int
-main(int ac, char *av[])
-{
- int ret;
- int id;
- char buf[256];
-#ifdef SYNCDEBUG
- char *str = "one";
-#endif
- int ii;
- size_t ui;
- struct tcdfvar *tvp = testvars;
- union getret got;
- const size_t initialsz = 8192;
- 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)
- exit(ret);
-
- assert( nc_put_att_text(id, NC_GLOBAL,
- "TITLE", 12, "another name") == NC_NOERR);
- assert( nc_get_att_text(id, NC_GLOBAL,
- "TITLE", buf) == NC_NOERR);
-/* (void) printf("title 1 \"%s\"\n", buf); */
- assert( nc_put_att_text(id, NC_GLOBAL,
- "TITLE", strlen(fname), fname) == NC_NOERR);
- assert( nc_get_att_text(id, NC_GLOBAL,
- "TITLE", buf) == NC_NOERR);
- buf[strlen(fname)] = 0;
-/* (void) printf("title 2 \"%s\"\n", buf); */
- assert( strcmp(fname, buf) == 0);
-
- createtestdims(id, NUM_DIMS, sizes, dim_names);
- testdims(id, NUM_DIMS, sizes, dim_names);
-
- createtestvars(id, testvars, NUM_TESTVARS);
-
- {
- int ifill = -1; double dfill = -9999;
- assert( nc_put_att_int(id, Long_id,
- _FillValue, NC_INT, 1, &ifill) == NC_NOERR);
- assert( nc_put_att_double(id, Double_id,
- _FillValue, NC_DOUBLE, 1, &dfill) == NC_NOERR);
- }
-
-#ifdef REDEF
- assert( nc__enddef(id, 0, align, 0, 2*align) == NC_NOERR );
- assert( nc_put_var1_int(id, Long_id, indices[3], &birthday)
- == NC_NOERR );
- fill_seq(id);
- assert( nc_redef(id) == NC_NOERR );
-/* assert( nc_rename_dim(id,2, "a long dim name") == NC_NOERR); */
-#endif
-
- assert( nc_rename_dim(id,1, "IXX") == NC_NOERR);
- assert( nc_inq_dim(id, 1, buf, &ui) == NC_NOERR);
- (void) printf("dimrename: %s\n", buf);
- assert( nc_rename_dim(id,1, dim_names[1]) == NC_NOERR);
-
-#ifdef ATTRX
- assert( nc_rename_att(id, 1, "UNITS", "units") == NC_NOERR);
- assert( nc_del_att(id, 4, "FIELDNAM")== NC_NOERR);
- assert( nc_del_att(id, 2, "SCALEMIN")== NC_NOERR);
- assert( nc_del_att(id, 2, "SCALEMAX")== NC_NOERR);
-#endif /* ATTRX */
-
- assert( nc__enddef(id, 0, align, 0, 2*align) == NC_NOERR );
-
-#ifndef REDEF
- fill_seq(id);
- assert( nc_put_var1_int(id, Long_id, indices[3], &birthday)== NC_NOERR );
-#endif
-
- assert( nc_put_vara_schar(id, Byte_id, s_start, s_edges,
- (signed char *)sentence)
- == NC_NOERR);
- assert( nc_put_var1_schar(id, Byte_id, indices[6], (signed char *)(chs+1))
- == NC_NOERR);
- assert( nc_put_var1_schar(id, Byte_id, indices[5], (signed char *)chs)
- == NC_NOERR);
-
- assert( nc_put_vara_text(id, Char_id, s_start, s_edges, sentence)
- == NC_NOERR);
- assert( nc_put_var1_text(id, Char_id, indices[6], (chs+1))
- == NC_NOERR) ;
- assert( nc_put_var1_text(id, Char_id, indices[5], chs)
- == NC_NOERR);
-
- assert( nc_put_var1_short(id, Short_id, indices[4], shs)
- == NC_NOERR);
-
- assert( nc_put_var1_float(id, Float_id, indices[2], &e)
- == NC_NOERR);
-
- assert( nc_put_var1_double(id, Double_id, indices[1], &zed)
- == NC_NOERR);
- assert( nc_put_var1_double(id, Double_id, indices[0], &pinot)
- == NC_NOERR);
-
-
-#ifdef SYNCDEBUG
- (void) printf("Hit Return to sync\n");
- gets(str);
- nc_sync(id,0);
- (void) printf("Sync done. Hit Return to continue\n");
- gets(str);
-#endif /* SYNCDEBUG */
-
- ret = nc_close(id);
- (void) printf("nc_close ret = %d\n\n", ret);
-
-
-/*
- * read it
- */
- ret = nc__open(fname,NC_NOWRITE, &chunksz, &id);
- if(ret != NC_NOERR)
- {
- (void) printf("Could not open %s: %s\n", fname,
- nc_strerror(ret));
- exit(1);
- }
- (void) printf("reopen id = %d for filename %s\n",
- id, fname);
-
- /* NC */
- (void) printf("NC ");
- assert( nc_inq(id, &(cdesc->num_dims), &(cdesc->num_vars),
- &(cdesc->num_attrs), &(cdesc->xtendim) ) == NC_NOERR);
- assert((size_t) cdesc->num_dims == num_dims);
- assert(cdesc->num_attrs == 1);
- assert(cdesc->num_vars == NUM_TESTVARS);
- (void) printf("done\n");
-
- /* GATTR */
- (void) printf("GATTR ");
-
- assert( nc_inq_attname(id, NC_GLOBAL, 0, adesc->mnem) == 0);
- assert(strcmp("TITLE",adesc->mnem) == 0);
- assert( nc_inq_att(id, NC_GLOBAL, adesc->mnem, &(adesc->type), &(adesc->len))== NC_NOERR);
- assert( adesc->type == NC_CHAR );
- assert( adesc->len == strlen(fname) );
- assert( nc_get_att_text(id, NC_GLOBAL, "TITLE", buf)== NC_NOERR);
- buf[adesc->len] = 0;
- assert( strcmp(fname, buf) == 0);
-
- /* VAR */
- (void) printf("VAR ");
- assert( cdesc->num_vars == NUM_TESTVARS );
-
- for(ii = 0; ii < cdesc->num_vars; ii++, tvp++ )
- {
- int jj;
- assert( nc_inq_var(id, ii,
- vdesc->mnem,
- &(vdesc->type),
- &(vdesc->ndims),
- vdesc->dims,
- &(vdesc->num_attrs)) == NC_NOERR);
- if(strcmp(tvp->mnem , vdesc->mnem) != 0)
- {
- (void) printf("attr %d mnem mismatch %s, %s\n",
- ii, tvp->mnem, vdesc->mnem);
- continue;
- }
- if(tvp->type != vdesc->type)
- {
- (void) printf("attr %d type mismatch %d, %d\n",
- ii, tvp->type, vdesc->type);
- continue;
- }
- for(jj = 0; jj < vdesc->ndims; jj++ )
- {
- if(tvp->dims[jj] != vdesc->dims[jj] )
- {
- (void) printf(
- "inconsistant dim[%d] for variable %d: %d != %d\n",
- jj, ii, tvp->dims[jj], vdesc->dims[jj] );
- continue;
- }
- }
-
- /* VATTR */
- (void) printf("VATTR\n");
- for(jj=0; jj<vdesc->num_attrs; jj++ )
- {
- assert( nc_inq_attname(id, ii, jj, adesc->mnem) == NC_NOERR);
- if( strcmp(adesc->mnem, reqattr[jj]) != 0 )
- {
- (void) printf("var %d attr %d mismatch %s != %s\n",
- ii, jj, adesc->mnem, reqattr[jj] );
- break;
- }
- }
-
- if( nc_inq_att(id, ii, reqattr[0], &(adesc->type), &(adesc->len))
- != -1) {
- assert( adesc->type == NC_CHAR );
- assert( adesc->len == strlen(tvp->units) );
- assert( nc_get_att_text(id,ii,reqattr[0],buf)== NC_NOERR);
- buf[adesc->len] = 0;
- assert( strcmp(tvp->units, buf) == 0);
- }
-
- if(
- nc_inq_att(id, ii, reqattr[1], &(adesc->type), &(adesc->len))
- != -1)
- {
- assert( adesc->type == NC_DOUBLE );
- assert( adesc->len == 1 );
- assert( nc_get_att_double(id, ii, reqattr[1], &got.dbl)== NC_NOERR);
- chkgot(adesc->type, got, tvp->validmin);
- }
-
- if(
- nc_inq_att(id, ii, reqattr[2], &(adesc->type), &(adesc->len))
- != -1)
- {
- assert( adesc->type == NC_DOUBLE );
- assert( adesc->len == 1 );
- assert( nc_get_att_double(id, ii, reqattr[2], &got.dbl)== NC_NOERR);
- chkgot(adesc->type, got, tvp->validmax);
- }
-
- if(
- nc_inq_att(id, ii, reqattr[3], &(adesc->type), &(adesc->len))
- != -1)
- {
- assert( adesc->type == NC_DOUBLE );
- assert( adesc->len ==1 );
- assert( nc_get_att_double(id, ii, reqattr[3], &got.dbl)== NC_NOERR);
- chkgot(adesc->type, got, tvp->scalemin);
- }
-
- if(
- nc_inq_att(id, ii, reqattr[4], &(adesc->type), &(adesc->len))
- != -1)
- {
- assert( adesc->type == NC_DOUBLE );
- assert( adesc->len == 1 );
- assert( nc_get_att_double(id, ii, reqattr[4], &got.dbl)== NC_NOERR);
- chkgot(adesc->type, got, tvp->scalemax);
- }
-
- if( nc_inq_att(id, ii, reqattr[5], &(adesc->type), &(adesc->len))== NC_NOERR)
- {
- assert( adesc->type == NC_CHAR );
- assert( adesc->len == strlen(tvp->fieldnam) );
- assert( nc_get_att_text(id,ii,reqattr[5],buf)== NC_NOERR);
- buf[adesc->len] = 0;
- assert( strcmp(tvp->fieldnam, buf) == 0);
- }
- }
-
- (void) printf("fill_seq ");
- check_fill_seq(id);
- (void) printf("Done\n");
-
- assert( nc_get_var1_double(id, Double_id, indices[0], &got.dbl)== NC_NOERR);
- (void) printf("got val = %f\n", got.dbl );
-
- assert( nc_get_var1_double(id, Double_id, indices[1], &got.dbl)== NC_NOERR);
- (void) printf("got val = %f\n", got.dbl );
-
- assert( nc_get_var1_float(id, Float_id, indices[2], &got.fl[0])== NC_NOERR);
- (void) printf("got val = %f\n", got.fl[0] );
-
- assert( nc_get_var1_int(id, Long_id, indices[3], &got.in[0])== NC_NOERR);
- (void) printf("got val = %d\n", got.in[0] );
-
- assert( nc_get_var1_short(id, Short_id, indices[4], &got.sh[0])== NC_NOERR);
- (void) printf("got val = %d\n", got.sh[0] );
-
- assert( nc_get_var1_text(id, Char_id, indices[5], &got.by[0]) == NC_NOERR);
- (void) printf("got NC_CHAR val = %c (0x%02x) \n",
- got.by[0] , got.by[0]);
-
- assert( nc_get_var1_text(id, Char_id, indices[6], &got.by[0]) == NC_NOERR);
- (void) printf("got NC_CHAR val = %c (0x%02x) \n",
- got.by[0], got.by[0] );
-
- (void) memset(buf,0,sizeof(buf));
- assert( nc_get_vara_text(id, Char_id, s_start, s_edges, buf) == NC_NOERR);
- (void) printf("got NC_CHAR val = \"%s\"\n", buf);
-
- assert( nc_get_var1_schar(id, Byte_id, indices[5],
- (signed char *)&got.by[0])== NC_NOERR);
- (void) printf("got val = %c (0x%02x) \n", got.by[0] , got.by[0]);
-
- assert( nc_get_var1_schar(id, Byte_id, indices[6],
- (signed char *)&got.by[0])== NC_NOERR);
- (void) printf("got val = %c (0x%02x) \n", got.by[0], got.by[0] );
-
- (void) memset(buf,0,sizeof(buf));
- assert( nc_get_vara_schar(id, Byte_id, s_start, s_edges,
- (signed char *)buf)== NC_NOERR );
- (void) printf("got val = \"%s\"\n", buf);
-
- {
- double dbuf[NUM_RECS * SIZE_1 * SIZE_2];
- assert(nc_get_var_double(id, Float_id, dbuf) == NC_NOERR);
- (void) printf("got vals = %f ... %f\n", dbuf[0],
- dbuf[NUM_RECS * SIZE_1 * SIZE_2 -1] );
- }
-
- ret = nc_close(id);
- (void) printf("re nc_close ret = %d\n", ret);
-
- return 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncio.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncio.c
deleted file mode 100644
index eb355d9..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncio.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright 1995, University Corporation for Atmospheric Research
- * See top level COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: t_ncio.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-#include "ncio.h"
-#ifndef ENOERR
-#define ENOERR 0
-#endif
-
-
-static void
-usage(const char *av0)
-{
- (void)fprintf(stderr,
- "Usage: %s [options] fname\t\nOptions:\n", av0);
- (void)fprintf(stderr,
- "\t-v Verbose\n") ;
- (void)fprintf(stderr,
- "\t-w Open Read/Write, default is read only\n") ;
- (void)fprintf(stderr,
- "\t-c Create, clobber existing\n") ;
- (void)fprintf(stderr,
- "\t-n Create, error if it already exists\n") ;
- (void)fprintf(stderr,
- "\t-L Use locking if available\n") ;
- (void)fprintf(stderr,
- "\t-S Share updates (turn off caching)\n") ;
- (void)fprintf(stderr,
- "\t-U Delete (unlink) on close\n") ;
- (void)fprintf(stderr,
- "\t-o igeto Initial get offset\n") ;
- (void)fprintf(stderr,
- "\t-i igetsz Initial get size\n") ;
- (void)fprintf(stderr,
- "\t-I initialsz Initial file size for create\n") ;
- (void)fprintf(stderr,
- "\t-s sizehint Buffer size\n") ;
- exit(EXIT_FAILURE);
-}
-
-
-static long
-argscale(const char *arg, const char *tag)
-{
- long value = 0;
- /* last character */
- const char *cp = arg + strlen(arg) -1;
- value = atol(arg);
- if(isalpha(*cp))
- {
- switch(*cp) {
- case 'k':
- case 'K':
- value *= 1024;
- break;
- case 'm':
- case 'M':
- value *= (1024*1024);
- break;
- default:
- value = 0; /* trigger error below */
- break;
- }
- }
- if(value == 0)
- {
- fprintf(stderr,
- "Illegal %s \"%s\", ignored\n", tag, arg);
- }
- return value;
-}
-
-
-static void
-modify_ex(off_t offset, size_t extent, void *vp)
-{
- unsigned char *obuf = vp;
- const unsigned char *const end = &obuf[extent];
- unsigned char *cp = obuf;
-
- if(cp >= end) return;
- *cp++ = (unsigned char)( offset >> 24);
- if(cp >= end) return;
- *cp++ = (unsigned char)((offset & 0x00ff0000) >> 16);
- if(cp >= end) return;
- *cp++ = (unsigned char)((offset & 0x0000ff00) >> 8);
- if(cp >= end) return;
- *cp++ = (unsigned char)( offset & 0x000000ff);
- if(cp >= end) return;
- *cp++ = (unsigned char)( extent >> 24);
- if(cp >= end) return;
- *cp++ = (unsigned char)((extent & 0x00ff0000) >> 16);
- if(cp >= end) return;
- *cp++ = (unsigned char)((extent & 0x0000ff00) >> 8);
- if(cp >= end) return;
- *cp++ = (unsigned char)( extent & 0x000000ff);
-
- while(cp < end)
- {
- *cp++ = (unsigned char) (cp - obuf);
- }
-}
-
-
-typedef struct riu {
- struct riu *next;
- struct riu *prev;
- off_t offset;
- size_t extent;
- void *vp;
-} riu;
-
-static void
-free_riu(riu *riup)
-{
- if(riup == NULL)
- return;
- free(riup);
-}
-
-static riu *
-new_riu(off_t offset, size_t extent, void *vp)
-{
- riu *riup = (riu *)malloc(sizeof(riu));
- if(riup == NULL)
- {
- fprintf(stderr,
- "new_riu: malloc failed\n");
- exit(EXIT_FAILURE);
- }
- riup->next = NULL;
- riup->prev = NULL;
- riup->offset = offset;
- riup->extent = extent;
- riup->vp = vp;
- return riup;
-}
-
-static riu *stack = NULL;
-
-static void
-riu_push(off_t offset, size_t extent, void *vp)
-{
- riu *riup = new_riu(offset, extent, vp);
- /* assert(riup != NULL); */
- riup->next = stack;
- if(stack != NULL)
- stack->prev = riup;
- stack = riup;
-}
-
-static int
-riu_pop(off_t offset, int modify)
-{
- riu *riup = stack;
- while(riup != NULL)
- {
- if(riup->offset == offset)
- {
- if(modify)
- {
- modify_ex(riup->offset, riup->extent, riup->vp);
- }
- if(riup->next != NULL)
- {
- riup->next->prev = riup->prev;
- }
- if(riup == stack)
- {
- stack = riup->next;
- }
- else
- {
- assert(riup->prev != NULL);
- riup->prev->next = riup->next;
- }
- free_riu(riup);
- return 1;
- }
- riup = riup->next;
- }
- /* else, not found */
- return 0;
-}
-
-main(int ac, char *av[])
-{
- char *path = "";
- ncio *nciop;
- char linebuf[128];
- off_t offset;
- size_t extent;
- void *vp;
- int status = ENOERR;
- int verbose = 0;
- int flags = 0;
- int create = 0;
- off_t igeto = 0;
- size_t igetsz = 0;
- size_t initialsz = 0;
- int doUnlink = 0;
- size_t sizehint = NC_SIZEHINT_DEFAULT;
-
- {
- extern int optind;
- extern int opterr;
- extern char *optarg;
- int ch;
-
- opterr = 1;
-
- while ((ch = getopt(ac, av, "vwcnLSUo:i:I:s:")) != EOF)
- switch (ch) {
- case 'v':
- verbose = 1;
- break;
- case 'w':
- flags |= NC_WRITE;
- break;
- case 'c':
- create = 1;
- break;
- case 'n':
- create = 1;
- flags |= NC_NOCLOBBER;
- break;
- case 'L':
- flags |= NC_LOCK;
- break;
- case 'S':
- flags |= NC_SHARE;
- break;
- case 'U':
- doUnlink = 1;
- break;
- case 'o':
- igeto = argscale(optarg, "igeto");
- break;
- case 'i':
- igetsz = argscale(optarg, "igetsz");
- break;
- case 'I':
- initialsz = argscale(optarg, "initialsz");
- break;
- case 's':
- sizehint = argscale(optarg, "sizehint");
- break;
- case '?':
- usage(av[0]);
- break;
- }
-
- /* last arg, the file name, is required */
- if(ac - optind <= 0)
- usage(av[0]) ;
- path = av[optind];
-
-
- }
-
- if(!create)
- {
- status = ncio_open(path, flags,
- igeto, igetsz, &sizehint,
- &nciop, &vp);
- if(status != ENOERR)
- {
- fprintf(stderr, "ncio_open: %s: %s\n",
- path, strerror(status));
- return(EXIT_FAILURE);
- }
- } else {
- status = ncio_create(path, flags, initialsz,
- igeto, igetsz, &sizehint,
- &nciop, &vp);
- if(status != ENOERR)
- {
- fprintf(stderr, "ncio_create: %s: %s\n",
- path, strerror(status));
- return(EXIT_FAILURE);
- }
- }
-
- while(fgets(linebuf, sizeof(linebuf), stdin) != NULL)
- {
- offset = 0;
- extent = 0;
-
- if(*linebuf == '#')
- continue; /* comment */
- if(sscanf(linebuf, "rel 0x%lx", &offset) == 1
- || sscanf(linebuf, "rel %ld", &offset) == 1)
- {
- if(verbose)
- printf("- rel %8ld\n", offset);
- if(!riu_pop(offset, 0))
- continue;
- status = nciop->rel(nciop, offset, 0);
- if(status)
- {
- fprintf(stderr, "- rel error: %s\n",
- strerror(status));
- continue;
- }
- }
- else if(sscanf(linebuf, "relm 0x%lx", &offset) == 1
- || sscanf(linebuf, "relm %ld", &offset) == 1)
- {
- if(verbose)
- printf("- relm %8ld\n", offset);
- if(!riu_pop(offset, 1))
- continue;
- status = nciop->rel(nciop, offset, RGN_MODIFIED);
- if(status)
- {
- fprintf(stderr, "- relm %8ld error: %s\n",
- offset, strerror(status));
- continue;
- }
- }
- else if(sscanf(linebuf, "get 0x%lx %ld", &offset, &extent) == 2
- || sscanf(linebuf, "get %ld %ld", &offset, &extent) == 2)
- {
- if(verbose)
- printf("- get %10ld %8ld\n", offset, extent);
- status = nciop->get(nciop, offset, extent, 0, &vp);
- if(status)
- {
- fprintf(stderr, "- get error: %s\n",
- strerror(status));
- continue;
- }
- riu_push(offset, extent, vp);
- }
- else if(sscanf(linebuf, "getw 0x%lx %ld", &offset, &extent) == 2
- || sscanf(linebuf, "getw %ld %ld", &offset, &extent) == 2)
- {
- if(verbose)
- printf("- getw %10ld %8ld\n", offset, extent);
- status = nciop->get(nciop, offset, extent, RGN_WRITE, &vp);
- if(status)
- {
- fprintf(stderr, "- getw error: %s\n",
- strerror(status));
- continue;
- }
- riu_push(offset, extent, vp);
- }
- else if(strchr(linebuf, 'q') != NULL)
- break;
- else
- printf("???\n");
- }
-
- status = ncio_close(nciop, doUnlink);
- if(status != ENOERR)
- {
- fprintf(stderr, "ncio_close(%s): %s: %s\n",
- doUnlink ? "doUnlink" : "",
- path, strerror(status));
- return(EXIT_FAILURE);
- }
-
- return(EXIT_SUCCESS);
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncx.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncx.c
deleted file mode 100644
index 717b435..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncx.c
+++ /dev/null
@@ -1,1250 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: t_ncx.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $ */
-
-#include <stdio.h>
-#include <limits.h>
-/* alias poorly named limits.h macros */
-#define SHORT_MAX SHRT_MAX
-#define SHORT_MIN SHRT_MIN
-#define USHORT_MAX USHRT_MAX
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <string.h>
-#include "ncx.h"
-
-#define NO_UNSIGNED
-#define NO_UNSIGNED_LONG
-
-/*
- * This program tests the xdr_mem implementation and
- * the ncx_ implementation, and compares the two.
- * Link like this:
- * cc t_ncx.c ncx.o [-lsome_xdr_lib] -o t_nxc
- * Successful output is:
- xdr_encode ends at byte 640
- xdr_check ends at byte 640
- ncx_encode ends at byte 640
- ncx_check ends at byte 640
- xdr_check ends at byte 640
- ncx_check ends at byte 640
- * with exit status 0;
- */
-
-#define XBSZ 1024
-
-char xdrb[XBSZ];
-char ncxb[XBSZ];
-
-#define ArraySize(thang) (sizeof(thang)/sizeof(thang[0]))
-#define uiArraySize(thang) ((u_int)ArraySize(thang))
-#define eSizeOf(thang) ((u_int)(sizeof(thang[0])))
-
-/*
- * Some test data
- */
-
-static char text[] = { "Hiya sailor. New in town?" };
-
-/*
- * Some test data
- * The ideas is that ncx_putn_type_type(...., types)
- * should not return NC_ERANGE.
- */
-
-#if SCHAR_MAX == X_SCHAR_MAX && SCHAR_MIN == X_SCHAR_MIN
-static schar schars[] = {
- SCHAR_MIN, SCHAR_MIN +1,
- -1, 0, 1,
- SCHAR_MAX - 1, SCHAR_MAX
-};
-#else
-/* The implementation and this test assume 8 bit bytes. */
-#error "Not 8 bit bytes ??"
-#endif
-
-static short shorts[] = {
-#if SHORT_MAX <= X_SHORT_MAX
- SHORT_MIN, SHORT_MIN + 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
- SHORT_MAX - 1, SHORT_MAX
-#else
- X_SHORT_MIN, X_SHORT_MIN + 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
- X_SHORT_MAX - 1, X_SHORT_MAX
-#endif
-};
-
-static int ints[] = {
-#if INT_MAX <= X_INT_MAX
- INT_MIN, INT_MIN +1,
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
- INT_MAX - 1, INT_MAX
-#else
- X_INT_MIN, X_INT_MIN +1,
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
- X_INT_MAX - 1, X_INT_MAX
-#endif /* INT */
-};
-
-
-/* N.B. only testing longs over X_INT range for now */
-static long longs[] = {
-#if LONG_MAX <= X_INT_MAX
- LONG_MIN, LONG_MIN +1,
-# if INT_MAX < X_INT_MAX
- INT_MIN -1, INT_MIN, INT_MIN + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
-# if INT_MAX < X_INT_MAX
- INT_MAX -1, INT_MAX, INT_MAX + 1,
-# endif
- LONG_MAX - 1, LONG_MAX
-#else
- X_INT_MIN, X_INT_MIN +1,
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
- X_INT_MAX - 1, X_INT_MAX
-#endif
-};
-
-static float floats[] = {
- -100.625, -100.5, -100.375, -100.25, -100.125,
- -1.0, -.125, 0., .125, 1.,
- 100.125, 100.25, 100.375, 100.5, 100.625
-};
-
-/* The big numbers require 25 bits: 2^(25-i)+1/2^i, i = 2, 3, ..., 6 */
-static double doubles[] = {
- -8388608.25, -4194304.125, -2097152.0625, -1048576.03125, -524288.015625
- -100.625, -100.5, -100.375, -100.25, -100.125,
- -1.0, -.125, 0., .125, 1.,
- 100.125, 100.25, 100.375, 100.5, 100.625,
- 524288.015625, 1048576.03125, 2097152.0625, 4194304.125, 8388608.25
-};
-
-/* End of test data */
-
-/*
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: t_ncx.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $ */
-
-/* putget.c */
-/*
- * xdr 1 - 3 bytes, leaving adjoining bytes within the word ok.
- * (minimum unit of io is 4 bytes)
- */
-static bool_t
-xdr_NCvbyte(XDR *xdrs, unsigned rem, unsigned count, char *value)
-{
- char buf[4] ;
- u_int origin ;
- enum xdr_op x_op = xdrs->x_op ; /* save state */
-
- if(x_op == XDR_ENCODE)
- {
- /*
- * Since we only read/write multiples of four bytes,
- * We will read in the word to change one byte in it.
- */
- origin = xdr_getpos( xdrs ) ;
- /* next op is a get */
- xdrs->x_op = XDR_DECODE ;
- }
-
- if(!xdr_opaque(xdrs, buf, 4))
- {
- /* get failed, assume we are trying to read off the end */
- (void)memset(buf, 0, sizeof(buf)) ;
- }
-
- if(x_op == XDR_ENCODE) /* back to encode */
- xdrs->x_op = x_op ;
-
- while(count-- != 0)
- {
- if(x_op == XDR_ENCODE)
- buf[rem] = *value ;
- else
- *value = buf[rem] ;
-
- rem++ ;
- value++ ;
- }
-
- if(x_op == XDR_ENCODE)
- {
- if( !xdr_setpos(xdrs, origin) )
- return(FALSE) ;
- if( !xdr_opaque(xdrs, buf, 4))
- return(FALSE) ;
- }
-
- return(TRUE) ;
-}
-
-
-/* xdrshorts.c */
-/* you may wish to tune this: big on a cray, small on a PC? */
-#define NC_SHRT_BUFSIZ 8192
-#define NC_NSHRTS_PER (NC_SHRT_BUFSIZ/2) /* number of netshorts the buffer holds */
-
-/*
- * xdr a short leaving adjoining short within the word ok.
- * (minimum unit of io is 4 bytes)
- */
-static bool_t
-xdr_NCvshort(XDR *xdrs, unsigned which, short *value)
-{
- unsigned char buf[4] ; /* unsigned is important here */
- u_int origin ;
- enum xdr_op x_op = xdrs->x_op ; /* save state */
-
- if(x_op == XDR_ENCODE)
- {
- origin = xdr_getpos( xdrs ) ;
- /* next op is a get */
- xdrs->x_op = XDR_DECODE ;
- }
-
- if(!xdr_opaque(xdrs, (caddr_t)buf, 4))
- {
- /* get failed, assume we are trying to read off the end */
- (void)memset(buf, 0, sizeof(buf)) ;
- }
-
- if(x_op == XDR_ENCODE) /* back to encode */
- xdrs->x_op = x_op ;
-
- if(which != 0) which = 2 ;
-
- if(xdrs->x_op == XDR_ENCODE)
- {
- buf[which +1] = *value % 256 ;
- buf[which] = (*value >> 8) ;
-
- if( !xdr_setpos(xdrs, origin) )
- return(FALSE) ;
- if( !xdr_opaque(xdrs, (caddr_t)buf, 4))
- return(FALSE) ;
- }
- else
- {
- *value = (((unsigned)buf[which] & 0x7f) << 8) +
- (unsigned)buf[which + 1] ;
- if((unsigned)buf[which] & 0x80)
- {
- /* extern is neg */
- *value -= 0x8000 ;
- }
- }
- return(TRUE) ;
-}
-
-/*
- * internal function, bulk xdr of an even number of shorts, less than NC_NSHRTS_PER
- */
-static
-bool_t
-NCxdr_shortsb(XDR *xdrs, short *sp, u_int nshorts)
-{
- unsigned char buf[NC_SHRT_BUFSIZ] ;
- unsigned char *cp ;
- unsigned int nbytes = nshorts * 2;
-
- /* assert(nshorts <= NC_NSHRTS_PER) ; */
- /* assert(nshorts > 0) ; */
-
- if(xdrs->x_op == XDR_ENCODE)
- {
- for(cp = buf ; cp < &buf[nbytes] ; sp++, cp += 2 )
- {
- *(cp +1) = *sp % 256 ;
- *cp = (*sp >> 8) ;
- }
- }
-
- if(!xdr_opaque(xdrs, (caddr_t)buf, nbytes))
- return FALSE ;
-
- if(xdrs->x_op == XDR_DECODE)
- {
- for(cp = buf ; cp < &buf[nbytes] ; sp++, cp += 2 )
- {
- *sp = (((unsigned)*cp & 0x7f) << 8) +
- (unsigned)*(cp +1) ;
- if((unsigned)*cp & 0x80)
- {
- /* extern is neg */
- *sp -= 0x8000 ;
- }
- }
- }
-
- return TRUE ;
-}
-
-
-/*
- * Translate an array of cnt short integers at sp.
- */
-bool_t
-xdr_shorts(XDR *xdrs, short *sp, u_int cnt)
-{
- int odd ; /* 1 if cnt is odd, 0 otherwise */
-
- if(cnt == 0)
- return TRUE ; /* ? */
-
- odd = cnt % 2 ;
- if(odd)
- cnt-- ;
- /* cnt is even, odd is set if apropos */
-
- while(cnt > NC_NSHRTS_PER)
- {
- if(!NCxdr_shortsb(xdrs, sp, NC_NSHRTS_PER))
- return FALSE ;
- /* else */
- sp += NC_NSHRTS_PER ;
- cnt -= NC_NSHRTS_PER ;
- }
-
- /* we know cnt <= NC_NSHRTS_PER at this point */
-
- if(cnt != 0)
- {
- if(!NCxdr_shortsb(xdrs, sp, cnt))
- return FALSE ;
- /* else */
- sp += cnt ;
- cnt = 0 ;
- }
-
- if(odd)
- if(!xdr_NCvshort(xdrs, 0, sp))
- return FALSE ;
-
- return TRUE ;
-}
-
-/*
- * Use standard xdr interface (plus the netcdf xdr_shorts())
- * to encode data to 'buf'
- * Returns 0 on success.
- */
-static int
-xdr_encode(char *buf, u_int sz)
-{
- XDR xdrs[1];
- u_int pos;
- int ii;
-
- xdrmem_create(xdrs, buf, sz, XDR_ENCODE);
-
- if(!xdr_opaque(xdrs, (caddr_t)text, (u_int)sizeof(text)))
- return 1;
-
- if(!xdr_opaque(xdrs, (caddr_t)schars, (u_int)sizeof(schars)))
- return 2;
-
- if(!xdr_shorts(xdrs, shorts, uiArraySize(shorts)))
- return 3;
-
- if(!xdr_vector(xdrs, (char *)ints,
- uiArraySize(ints), eSizeOf(ints),
- (xdrproc_t)xdr_int))
- return 4;
-
- /* double the ints to check both ncx_ interfaces */
- if(!xdr_vector(xdrs, (char *)ints,
- uiArraySize(ints), eSizeOf(ints),
- (xdrproc_t)xdr_int))
- return 5;
-
-#ifndef NO_UNSIGNED
- if(!xdr_vector(xdrs, (char *)u_ints,
- uiArraySize(u_ints), eSizeOf(u_ints),
- (xdrproc_t)xdr_u_int))
- return 6;
-#endif
-
- if(!xdr_vector(xdrs, (char *)longs,
- uiArraySize(longs), eSizeOf(longs),
- (xdrproc_t)xdr_long))
- return 7;
-
-#ifndef NO_UNSIGNED_LONG
- if(!xdr_vector(xdrs, (char *)u_longs,
- uiArraySize(u_longs), eSizeOf(u_longs),
- (xdrproc_t)xdr_u_long))
- return 9;
-#endif
-
- if(!xdr_vector(xdrs, (char *)floats,
- uiArraySize(floats), eSizeOf(floats),
- (xdrproc_t)xdr_float))
- return 10;
-
- if(!xdr_vector(xdrs, (char *)doubles,
- uiArraySize(doubles), eSizeOf(doubles),
- (xdrproc_t)xdr_double))
- return 11;
-
- /* mix it up */
- for(ii = 1; ii < 5; ii++)
- {
- if(
- !xdr_opaque(xdrs, (caddr_t)text, ii)
- || !xdr_shorts(xdrs, shorts, ii)
- || !xdr_opaque(xdrs, (caddr_t)schars, ii)
- )
- return (11 + ii);
- }
-
- /*
- * Test non-aligned unit ops used by netcdf.
- */
-
- for(ii = 1; ii < 5; ii++)
- {
- pos = xdr_getpos(xdrs);
- if(!xdr_NCvbyte(xdrs, ii, BYTES_PER_XDR_UNIT -ii, &text[ii]))
- return (15 + ii);
- if(!xdr_setpos(xdrs, pos + BYTES_PER_XDR_UNIT))
- return (15 + ii);
- }
-
- for(ii = 1; ii < 5; ii++)
- {
- pos = xdr_getpos(xdrs);
- if(!xdr_NCvbyte(xdrs, ii, BYTES_PER_XDR_UNIT -ii,
- (char *)&schars[ii]))
- return (19 + ii);
- if(!xdr_setpos(xdrs, pos + BYTES_PER_XDR_UNIT))
- return (18 + ii);
- }
-
- for(ii = 1; ii < 3; ii++)
- {
- pos = xdr_getpos(xdrs);
- if(!xdr_NCvshort(xdrs, ii%2, &shorts[ii]))
- return (23 + ii);
- if(!xdr_setpos(xdrs, pos + BYTES_PER_XDR_UNIT))
- return (23 + ii);
- }
-
- pos = xdr_getpos(xdrs);
- (void) printf("xdr_encode ends at byte %u\n", pos);
-
- return 0;
-}
-
-
-static int
-cmp_chars(const char *c1, const char *c2, size_t nchars)
-{
- int status = 0;
- const char *const end = c1 + nchars;
-
- while(c1 < end)
- {
- if(*c1 != *c2)
- {
- (void) fprintf(stderr,
- "%c != %c char\n",
- *c1,
- *c2);
- if(status == 0)
- status = *c2 < *c1 ? -1 : 1;
- }
- c1++, c2++;
- }
-
- return status;
-}
-
-static int
-cmp_schars(const schar *b1, const schar *b2, size_t nbytes)
-{
- int status = 0;
- const schar *const end = b1 + nbytes;
-
- while(b1 < end)
- {
- if(*b1 != *b2)
- {
- (void) fprintf(stderr,
- "0x%02x != 0x%02x byte\n",
- (unsigned)(*b1),
- (unsigned)(*b2));
-
- if(status == 0)
- status = *b2 < *b1 ? -1 : 1;
- }
- b1++, b2++;
- }
-
- return status;
-}
-
-static int
-cmp_shorts(const short *s1, const short *s2, size_t nshorts)
-{
- int status = 0;
- const short *const end = s1 + nshorts;
-
- while(s1 < end)
- {
- if(*s1 != *s2)
- {
- (void) fprintf(stderr,
- "0x%04x != 0x%04x (%hd) short\n",
- (unsigned)(*s1),
- (unsigned)(*s2), *s2);
- if(status == 0)
- status = *s2 < *s1 ? -1 : 1;
- }
- s1++, s2++;
- }
-
- return status;
-}
-
-static int
-cmp_ints(const int *i1, const int *i2, size_t nints)
-{
- int status = 0;
- const int *const end = i1 + nints;
-
- while(i1 < end)
- {
- if(*i1 != *i2)
- {
- (void) fprintf(stderr,
- "0x%08x != 0x%08x int\n",
- (unsigned)(*i1),
- (unsigned)(*i2));
- if(status == 0)
- status = *i2 < *i1 ? -1 : 1;
- }
- i1++, i2++;
- }
-
- return status;
-}
-
-#ifndef NO_UNSIGNED
-static int
-cmp_u_ints(const unsigned int *i1, const unsigned int *i2, size_t nints)
-{
- int status = 0;
- const unsigned int *const end = i1 + nints;
-
- while(i1 < end)
- {
- if(*i1 != *i2)
- {
- (void) fprintf(stderr,
- "(%u) 0x%08x != 0x%08x (%u) uint\n",
- *i1, *i1,
- *i2, *i2);
- if(status == 0)
- status = *i2 < *i1 ? -1 : 1;
- }
- i1++, i2++;
- }
-
- return status;
-}
-#endif
-
-static int
-cmp_longs(const long *l1, const long *l2, size_t nlongs)
-{
- int status = 0;
- const long *const end = l1 + nlongs;
-
- while(l1 < end)
- {
- if(*l1 != *l2)
- {
- (void) fprintf(stderr,
- "0x%016lx != 0x%016lx long\n",
- (unsigned long)(*l1),
- (unsigned long)(*l2));
- if(status == 0)
- status = *l2 < *l1 ? -1 : 1;
- }
- l1++, l2++;
- }
-
- return status;
-}
-
-#ifndef NO_UNSIGNED_LONG
-static int
-cmp_u_longs(const unsigned long *l1, const unsigned long *l2, size_t nlongs)
-{
- int status = 0;
- const unsigned long *const end = l1 + nlongs;
-
- while(l1 < end)
- {
- if(*l1 != *l2)
- {
- (void) fprintf(stderr,
- "0x%016lx != 0x%016lx ulong\n",
- *l1,
- *l2);
- if(status == 0)
- status = *l2 < *l1 ? -1 : 1;
- }
- l1++, l2++;
- }
-
- return status;
-}
-#endif
-
-static int
-cmp_floats(const float *f1, const float *f2, size_t nfloats)
-{
-#define F_EPS 1.0e-6
-
- int status = 0;
- const float *const end = f1 + nfloats;
-
- while(f1 < end)
- {
- if(*f1 < *f2 && *f2 - *f1 > F_EPS)
- {
- (void) fprintf(stderr,
- "%.9e != %.9e float (diff %.9e)\n",
- *f1, *f2, *f1 - *f2);
- if(status == 0)
- status = 1;
- }
- else if( *f2 < *f1 && *f1 - *f2 > F_EPS)
- {
- (void) fprintf(stderr,
- "%.9e != %.9e float (diff %.9e)\n",
- *f1, *f2, *f1 - *f2);
- if(status == 0)
- status = -1;
- }
- f1++, f2++;
- }
-
- return status;
-}
-
-static int
-cmp_doubles(const double *d1, const double *d2, size_t ndoubles)
-{
-#define D_EPS 1.0e-15
-
- int status = 0;
- const double *const end = d1 + ndoubles;
-
- while(d1 < end)
- {
- if(*d1 < *d2 && *d2 - *d1 > D_EPS)
- {
- (void) fprintf(stderr,
- "%.17e != %.17e double (diff %.17e)\n",
- *d1, *d2, *d1 - *d2);
- if(status == 0)
- status = 1;
- }
- else if( *d2 < *d1 && *d1 - *d2 > D_EPS)
- {
- (void) fprintf(stderr,
- "%.17e != %.17e double (diff %.17e)\n",
- *d1, *d2, *d1 - *d2);
- if(status == 0)
- status = -1;
- }
- d1++, d2++;
- }
-
- return status;
-}
-
-/*
- * Verify that data in buf is as encoded
- * by xdr_encode() above.
- * Returns zero on sucess.
- */
-static int
-xdr_check(char *buf, u_int sz)
-{
- XDR xdrs[1];
- char tbuf[XBSZ];
- u_int pos;
- int ii;
- int jj;
-
- xdrmem_create(xdrs, buf, sz, XDR_DECODE);
-
- (void) memset(tbuf, 0, sizeof(text)+4);
- if(!xdr_opaque(xdrs, (caddr_t)tbuf, (u_int)sizeof(text))
- || cmp_chars(tbuf, text,
- sizeof(text)) != 0)
- return 1;
-
- (void) memset(tbuf, 0, sizeof(schars)+4);
- if(!xdr_opaque(xdrs, (caddr_t)tbuf, (u_int)sizeof(schars))
- || cmp_schars((schar *)tbuf, schars,
- sizeof(schars)) != 0)
- return 2;
-
- (void) memset(tbuf, 0, sizeof(shorts)+4);
- if(!xdr_shorts(xdrs, (short *)tbuf, uiArraySize(shorts))
- || cmp_shorts((short *)tbuf, shorts,
- ArraySize(shorts)) != 0)
- return 3;
-
- (void) memset(tbuf, 0, sizeof(ints)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(ints), eSizeOf(ints),
- (xdrproc_t)xdr_int)
- || cmp_ints((int *)tbuf, ints,
- ArraySize(ints)) != 0)
- return 4;
-
- /* double the ints to check both ncx_ interfaces */
- (void) memset(tbuf, 0, sizeof(ints)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(ints), eSizeOf(ints),
- (xdrproc_t)xdr_int)
- || cmp_ints((int *)tbuf, ints,
- ArraySize(ints)) != 0)
- return 5;
-
-#ifndef NO_UNSIGNED
- (void) memset(tbuf, 0, sizeof(u_ints)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(u_ints), eSizeOf(u_ints),
- (xdrproc_t)xdr_u_int)
- || cmp_u_ints((unsigned int *)tbuf, u_ints,
- ArraySize(u_ints)) != 0)
- return 6;
-#endif
-
- (void) memset(tbuf, 0, sizeof(longs)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(longs), eSizeOf(longs), (xdrproc_t)xdr_long)
- || cmp_longs((long *)tbuf, longs,
- ArraySize(longs)) != 0)
- return 7;
-
-#ifndef NO_UNSIGNED_LONG
- (void) memset(tbuf, 0, sizeof(u_longs)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(u_longs), eSizeOf(u_longs), (xdrproc_t)xdr_u_long)
- || cmp_u_longs((unsigned long *)tbuf, u_longs,
- ArraySize(u_longs)) != 0)
- return 9;
-#endif
-
- (void) memset(tbuf, 0, sizeof(floats)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(floats), eSizeOf(floats), (xdrproc_t)xdr_float)
- || cmp_floats((float *)tbuf, floats,
- ArraySize(floats)) != 0)
- return 10;
-
- (void) memset(tbuf, 0, sizeof(doubles)+4);
- if(!xdr_vector(xdrs, tbuf,
- uiArraySize(doubles), eSizeOf(doubles), (xdrproc_t)xdr_double)
- || cmp_doubles((double *)tbuf, doubles,
- ArraySize(doubles)) != 0)
- return 11;
-
- for(ii = 1; ii < 5; ii++)
- {
- char tx[4];
- short sh[4];
- schar by[4];
- if(
- !xdr_opaque(xdrs, (caddr_t)tx, ii)
- || !xdr_shorts(xdrs, sh, ii)
- || !xdr_opaque(xdrs, (caddr_t)by, ii)
- )
- return (11 + ii);
- for(jj = 0; jj < ii; jj++)
- {
- if(tx[jj] != text[jj])
- {
- (void) fprintf(stderr, "\txdr %c != %c text[%d]\n",
- tx[jj], text[jj], jj);
- return (11 + ii);
- }
- /* else */
- if(sh[jj] != shorts[jj])
- {
- (void) fprintf(stderr, "\txdr %hd != %hd shorts[%d]\n",
- sh[jj], shorts[jj], jj);
- return (11 + ii);
- }
- /* else */
- if(by[jj] != schars[jj])
- {
- (void) fprintf(stderr,
- "\txdr 0x%02x != 0x%02x schars[%d]\n",
- (unsigned) by[jj],
- (unsigned) schars[jj], jj);
- return (11 + ii);
- }
- /* else */
- }
- }
-
- /*
- * Test non-aligned unit ops used by netcdf.
- */
-
- for(ii = 1; ii < 5; ii++)
- {
- pos = xdr_getpos(xdrs);
- (void) memset(tbuf, 0, BYTES_PER_XDR_UNIT);
- if(!xdr_NCvbyte(xdrs, ii, BYTES_PER_XDR_UNIT -ii, tbuf)
- || cmp_chars(&text[ii], tbuf,
- BYTES_PER_XDR_UNIT -ii) != 0)
- return (15 + ii);
- if(!xdr_setpos(xdrs, pos + BYTES_PER_XDR_UNIT))
- return (15 + ii);
- }
-
- for(ii = 1; ii < 5; ii++)
- {
- pos = xdr_getpos(xdrs);
- (void) memset(tbuf, 0, BYTES_PER_XDR_UNIT);
- if(!xdr_NCvbyte(xdrs, ii, BYTES_PER_XDR_UNIT -ii, tbuf)
- || cmp_schars((schar *)tbuf, &schars[ii],
- BYTES_PER_XDR_UNIT -ii) != 0)
- return (19 + ii);
- if(!xdr_setpos(xdrs, pos + BYTES_PER_XDR_UNIT))
- return (19 + ii);
- }
-
- for(ii = 1; ii < 3; ii++)
- {
- pos = xdr_getpos(xdrs);
- (void) memset(tbuf, 0, BYTES_PER_XDR_UNIT);
- if(!xdr_NCvshort(xdrs, ii%2, (short *)tbuf)
- || cmp_shorts((short *)tbuf, &shorts[ii], 1))
- return (23 + ii);
- if(!xdr_setpos(xdrs, pos + BYTES_PER_XDR_UNIT))
- return (23 + ii);
- }
-
- pos = xdr_getpos(xdrs);
- (void) printf("xdr_check ends at byte %u\n", pos);
-
- return 0;
-}
-
-
-/* Poor man's template */
-#define NCX_VEC(xpp, nn, vecp, TYPE, proc, step) \
-{ \
-\
- size_t nelems = (nn); \
- TYPE *elemp = (vecp); \
-\
- while(nelems != 0) \
- { \
- status = (proc)((*(xpp)), elemp); \
- if(status != ENOERR) \
- break; \
- (*(xpp)) = (void *)((char *)(*(xpp)) + (step)); \
- elemp ++; \
- nelems--; \
- } \
-}
-
-
-/*
- * Use ncx interface
- * to encode data to 'buf'
- * Returns zero on success.
- */
-static int
-ncx_encode(char *buf)
-{
- int status = ENOERR;
-
- void *vp = buf;
- int ii;
-
- if(ncx_pad_putn_text(&vp, sizeof(text), text))
- return 1;
-
- if(ncx_pad_putn_schar_schar(&vp, sizeof(schars), schars))
- return 2;
-
- if(ncx_pad_putn_short_short(&vp, ArraySize(shorts), shorts))
- return 3;
-
- if(ncx_putn_int_int(&vp, ArraySize(ints), ints))
- return 4;
-
- NCX_VEC(&vp, ArraySize(ints), ints,
- int, ncx_put_int_int, X_SIZEOF_INT);
- if(status != ENOERR)
- return 5;
-
-#ifndef NO_UNSIGNED
- NCX_VEC(&vp, ArraySize(u_ints), u_ints,
- unsigned int, ncx_put_uint_uint, X_SIZEOF_INT);
- if(status != ENOERR)
- return 6;
-#endif
-
- if(ncx_putn_int_long(&vp, ArraySize(longs), longs))
- return 7;
-
-#ifndef NO_UNSIGNED_LONG
- NCX_VEC(&vp, ArraySize(u_longs), u_longs,
- unsigned long, ncx_put_ulong_ulong, X_SIZEOF_LONG);
- if(status != ENOERR)
- return 9;
-#endif
-
- if(ncx_putn_float_float(&vp, ArraySize(floats), floats))
- return 10;
-
- if(ncx_putn_double_double(&vp, ArraySize(doubles), doubles))
- return 11;
-
- /* mix it up */
- for(ii = 1; ii < 5; ii++)
- {
- if(
- ncx_pad_putn_text(&vp, ii, text)
- || ncx_pad_putn_short_short(&vp, ii, shorts)
- || ncx_pad_putn_schar_schar(&vp, ii, schars)
- )
- return (11 + ii);
- }
-
- /*
- * Test non-aligned unit ops used by netcdf.
- */
-
- for(ii = 1; ii < 5; ii++)
- {
- vp = (char *)vp + ii;
- if(ncx_putn_text(&vp, X_ALIGN - ii, &text[ii]))
- return (15 + ii);
- }
-
- for(ii = 1; ii < 5; ii++)
- {
- vp = (char *)vp + ii;
- if(ncx_putn_schar_schar(&vp, X_ALIGN - ii, &schars[ii]))
- return (19 + ii);
- }
-
- for(ii = 1; ii < 3; ii++)
- {
- char *pos = vp;
- vp = (char *)vp + (ii%2) * 2;
- if(ncx_putn_short_short(&vp, 1, &shorts[ii]))
- return (23 + ii);
- vp = pos + X_ALIGN;
- }
-
- (void) printf("ncx_encode ends at byte %u\n",
- (unsigned)(((char *)vp) - buf));
-
- return 0;
-}
-
-/*
- * Verify the ncx_getn_xxx() routines.
- * Returns zero on success.
- */
-static int
-ncx_check(char *buf)
-{
- int status = ENOERR;
- const void *vp = buf;
- char tbuf[XBSZ];
- int ii;
- int jj;
-
- (void) memset(tbuf, 0, sizeof(text)+4);
- if(ncx_pad_getn_text(&vp, sizeof(text), tbuf)
- || cmp_chars(tbuf, text,
- sizeof(text)) != 0)
- return 1;
-
- (void) memset(tbuf, 0, sizeof(schars)+4);
- if(ncx_pad_getn_schar_schar(&vp, sizeof(schars), (schar *)tbuf)
- || cmp_schars((schar *)tbuf, schars,
- sizeof(schars)) != 0)
- return 2;
-
- (void) memset(tbuf, 0, sizeof(shorts)+4);
- if(ncx_pad_getn_short_short(&vp, ArraySize(shorts), (short *)tbuf)
- || cmp_shorts((short *)tbuf, shorts,
- ArraySize(shorts)) != 0)
- return 3;
-
- (void) memset(tbuf, 0, sizeof(ints)+4);
- if(ncx_getn_int_int(&vp, ArraySize(ints), (int *)tbuf)
- || cmp_ints((int *)tbuf, ints,
- ArraySize(ints)) != 0)
- return 4;
-
- (void) memset(tbuf, 0, sizeof(ints)+4);
- NCX_VEC(&vp, ArraySize(ints), (int *)tbuf,
- int, ncx_get_int_int, X_SIZEOF_INT);
- if(status != ENOERR
- || cmp_ints((int *)tbuf, ints,
- ArraySize(ints)) != 0)
- return 5;
-
-#ifndef NO_UNSIGNED
- (void) memset(tbuf, 0, sizeof(u_ints)+4);
- NCX_VEC(&vp, ArraySize(u_ints), (unsigned int *)tbuf,
- unsigned, ncx_get_uint_uint, X_SIZEOF_INT);
- if(status != ENOERR
- || cmp_u_ints((unsigned int *)tbuf, u_ints,
- ArraySize(u_ints)) != 0)
- return 6;
-#endif
-
- (void) memset(tbuf, 0, sizeof(longs)+4);
- if(ncx_getn_int_long(&vp, ArraySize(longs), (long *)tbuf)
- || cmp_longs((long *)tbuf, longs,
- ArraySize(longs)) != 0)
- return 7;
-
-#ifndef NO_UNSIGNED_LONG
- (void) memset(tbuf, 0, sizeof(u_longs)+4);
- NCX_VEC(&vp, ArraySize(u_longs), (unsigned long *)tbuf,
- unsigned long, ncx_get_ulong_ulong, X_SIZEOF_LONG);
- if(status != ENOERR
- || cmp_u_longs((unsigned long *)tbuf, u_longs,
- ArraySize(u_longs)) != 0)
- return 9;
-#endif
-
- (void) memset(tbuf, 0, sizeof(floats)+4);
- if(ncx_getn_float_float(&vp, ArraySize(floats), (float *)tbuf)
- || cmp_floats((float *)tbuf, floats,
- ArraySize(floats)) != 0)
- return 10;
-
- (void) memset(tbuf, 0, sizeof(doubles)+4);
- if(ncx_getn_double_double(&vp, ArraySize(doubles), (double *)tbuf)
- || cmp_doubles((double *)tbuf, doubles,
- ArraySize(doubles)) != 0)
- return 11;
-
- for(ii = 1; ii < 5; ii++)
- {
- char tx[4];
- short sh[4];
- schar by[4];
- if(
- ncx_pad_getn_text(&vp, ii, tx)
- || ncx_pad_getn_short_short(&vp, ii, sh)
- || ncx_pad_getn_schar_schar(&vp, ii, by)
- )
- return (11 + ii);
- for(jj = 0; jj < ii; jj++)
- {
- if(tx[jj] != text[jj])
- {
- (void) fprintf(stderr,
- "\tncx %c != %c text[%d]\n",
- tx[jj], text[jj], jj);
- return (11 + ii);
- }
- /* else */
- if(sh[jj] != shorts[jj])
- {
- (void) fprintf(stderr,
- "\tncx %hd != %hd shorts[%d]\n",
- sh[jj], shorts[jj], jj);
- return (11 + ii);
- }
- /* else */
- if((unsigned)by[jj] != (unsigned)schars[jj])
- {
- (void) fprintf(stderr,
- "\tncx 0x%02x != 0x%02x schars[%d] %d\n",
- by[jj], schars[jj], jj, ii);
- return (11 + ii);
- }
- }
- }
-
- /*
- * Test non-aligned unit ops used by netcdf.
- */
-
- for(ii = 1; ii < 5; ii++)
- {
- (void) memset(tbuf, 0, X_ALIGN);
- vp = (char *)vp + ii;
- if(ncx_getn_text(&vp, X_ALIGN -ii, tbuf)
- || cmp_chars(tbuf, &text[ii],
- X_ALIGN -ii) != 0)
- return (15 + ii);
- }
-
- for(ii = 1; ii < 5; ii++)
- {
- (void) memset(tbuf, 0, X_ALIGN);
- vp = (char *)vp + ii;
- if(ncx_getn_schar_schar(&vp, X_ALIGN -ii, (schar *)tbuf)
- || cmp_schars((schar *)tbuf, &schars[ii],
- X_ALIGN -ii) != 0)
- return (19 + ii);
- }
-
- for(ii = 1; ii < 3; ii++)
- {
- const char *pos = vp;
- (void) memset(tbuf, 0, X_ALIGN);
- vp = (char *)vp + (ii%2) *2;
- if(ncx_getn_short_short(&vp, 1, (short *)tbuf)
- || cmp_shorts((short *)tbuf, &shorts[ii],
- 1) != 0)
- return (23 + ii);
- vp = pos + X_ALIGN;
- }
-
- (void) printf("ncx_check ends at byte %u\n",
- (unsigned)(((char *)vp) - buf));
-
-
- return 0;
-}
-
-
-int
-main(int ac, char *av[])
-{
- int status;
-
- status = xdr_encode(xdrb, sizeof(xdrb));
- if(status)
- {
- (void) fprintf(stderr,
- "xdr_encode failed %d\n", status);
- return 1;
- }
-
- status = xdr_check(xdrb, sizeof(xdrb));
- if(status)
- {
- (void) fprintf(stderr,
- "xdr_check of xdrb failed %d\n", status);
- return 1;
- }
-
- status = ncx_encode(ncxb);
- if(status)
- {
- (void) fprintf(stderr,
- "ncx_encode failed %d\n", status);
- return 1;
- }
-
- /* cross check */
- status = xdr_check(ncxb, sizeof(ncxb));
- if(status)
- {
- (void) fprintf(stderr,
- "xdr_check of ncxb failed %d\n", status);
- return 1;
- }
-
- status = ncx_check(xdrb);
- if(status)
- {
- (void) fprintf(stderr,
- "ncx_check of xdrb failed %d\n", status);
- return 1;
- }
-
- status = ncx_check(ncxb);
- if(status)
- {
- (void) fprintf(stderr,
- "ncx_check of ncxb failed %d\n", status);
- return 1;
- }
-
- return 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncxx.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncxx.m4
deleted file mode 100644
index fbff29c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/t_ncxx.m4
+++ /dev/null
@@ -1,956 +0,0 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-dnl If you see this line, you can ignore the next one.
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* "$Id: t_ncxx.m4,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $" */
-
-/*
- * This program tests the aggregate external representation conversion
- * functions "ncx_[pad_]{put,get}n_*()" declared in ncx.h.
- * Unlike t_ncx.c, it only checks self consistancy,
- * not consistancy with the xdr library.
- *
- * Link like this:
- * cc t_ncxx.c ncx.o -o t_nxc
- * (The xdr library is not needed.)
- *
- * If an assertion fails, there is a problem.
- * Otherwise, the program is silent and has exit code 0.
- */
-
-#undef NDEBUG /* always active assert() in this file */
-
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-/* alias poorly named limits.h macros */
-#define SHORT_MAX SHRT_MAX
-#define SHORT_MIN SHRT_MIN
-#define USHORT_MAX USHRT_MAX
-#include <assert.h>
-#include "ncx.h"
-#define X_SIZEOF_SCHAR X_SIZEOF_CHAR
-#define X_LONG_MAX X_INT_MAX
-#define X_LONG_MIN X_INT_MIN
-
-#define XBSZ 1024
-
-char ncxb[XBSZ];
-char lbuf[XBSZ];
-
-#define ArraySize(thang) (sizeof(thang)/sizeof(thang[0]))
-#define eSizeOf(thang) ((size_t)(sizeof(thang[0])))
-
-/*
- * Some test data
- * The ideas is that ncx_putn_type_type(...., types)
- * should not return NC_ERANGE.
- */
-
-#if SCHAR_MAX == X_SCHAR_MAX && SCHAR_MIN == X_SCHAR_MIN
-static schar schars[] = {
- SCHAR_MIN, SCHAR_MIN +1,
- -1, 0, 1,
- SCHAR_MAX - 1, SCHAR_MAX
-};
-#else
-/* The implementation and this test assume 8 bit bytes. */
-#error "Not 8 bit bytes ??"
-#endif
-
-static short shorts[] = {
-#if SHORT_MAX <= X_SHORT_MAX
- SHORT_MIN, SHORT_MIN + 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
- SHORT_MAX - 1, SHORT_MAX
-#else
- X_SHORT_MIN, X_SHORT_MIN + 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_SHORT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
- X_SHORT_MAX - 1, X_SHORT_MAX
-#endif
-};
-
-static int ints[] = {
-#if INT_MAX <= X_INT_MAX
- INT_MIN, INT_MIN +1,
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
- INT_MAX - 1, INT_MAX
-#else
- X_INT_MIN, X_INT_MIN +1,
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
- X_INT_MAX - 1, X_INT_MAX
-#endif /* INT */
-};
-
-
-/* N.B. only testing longs over X_INT range for now */
-static long longs[] = {
-#if LONG_MAX <= X_INT_MAX
- LONG_MIN, LONG_MIN +1,
-# if INT_MAX < X_INT_MAX
- INT_MIN -1, INT_MIN, INT_MIN + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
-# if INT_MAX < X_INT_MAX
- INT_MAX -1, INT_MAX, INT_MAX + 1,
-# endif
- LONG_MAX - 1, LONG_MAX
-#else
- X_INT_MIN, X_INT_MIN +1,
-# if SHORT_MAX < X_INT_MAX
- SHORT_MIN -1, SHORT_MIN, SHORT_MIN + 1,
-# endif
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MIN - 1, SCHAR_MIN, SCHAR_MIN + 1,
-# endif
- -1, 0, 1,
-# if SCHAR_MAX < X_INT_MAX
- SCHAR_MAX - 1, SCHAR_MAX, SCHAR_MAX + 1,
-# endif
-# if SHORT_MAX < X_INT_MAX
- SHORT_MAX - 1, SHORT_MAX, SHORT_MAX +1,
-# endif
- X_INT_MAX - 1, X_INT_MAX
-#endif
-};
-
-static float floats[] = {
- -1.E9F,
- -16777215, -16777214,
- -999999,
- -32769, -32768, -32767,
- -129, -128, 127,
- -1, 0, 1,
- 126, 127, 128,
- 32766, 32767, 32768,
- 999999,
- 16777214, 16777215, /* 2^24 -1 */
- 1.E9F
-};
-
-static double doubles[] = {
- -1.E20,
- -4503599627370495., -4503599627370494.,
- -999999999999999.,
- -1.E9,
- -16777215, -16777214,
- -999999,
- -32769, -32768, -32767,
- -129, -128, 127,
- -1, 0, 1,
- 126, 127, 128,
- 32766, 32767, 32768,
- 999999,
- 16777214, 16777215, /* 2^24 -1 */
- 1.E9,
- 999999999999999.,
- 4503599627370494., 4503599627370495., /* 2^53 -1 */
- 1.E20
-};
-
-static uchar uchars[] = {
- 0, 1,
- UCHAR_MAX/2 -1, UCHAR_MAX/2, UCHAR_MAX/2 +1,
- UCHAR_MAX - 1, UCHAR_MAX
-};
-
-/* End of test data */
-
-dnl dnl dnl
-dnl
-dnl Macros
-dnl
-dnl dnl dnl
-dnl
-dnl Upcase(str)
-dnl
-define(`Upcase',dnl
-`dnl
-translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)')dnl
-dnl dnl dnl
-dnl
-dnl Xsizeof(Xtype)
-dnl
-define(`Xsizeof', ``X_SIZEOF_'Upcase($1)')dnl
-dnl dnl dnl
-define(`XMin', ``X_'Upcase($1)`_MIN'')dnl
-define(`XMax', ``X_'Upcase($1)`_MAX'')dnl
-dnl dnl dnl
-dnl
-dnl T_PUTN(XType, Type)
-dnl
-define(`T_PUTN',dnl
-`dnl
-static void
-t_putn_$1_$2(char *const buf)
-{
- char *xp = buf;
- const $2 *tp = `$2's;
- size_t nelems = ArraySize(`$2's);
- int status = ncx_putn_$1_$2((void **)&xp, nelems, tp);
- assert(xp == buf + nelems * Xsizeof($1));
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if((double) tp[ii] > XMax($1))
- {
- assert(status == NC_ERANGE);
- return;
- }
- if((double) tp[ii] < XMin($1))
- {
- assert(status == NC_ERANGE);
- return;
- }
- }
- assert(status == 0);
- }
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl T_PUTN_U(XType, Type)
-dnl Doesn't make signed comparisons to unsigned type
-dnl
-define(`T_PUTN_U',dnl
-`dnl
-static void
-t_putn_$1_$2(char *const buf)
-{
- char *xp = buf;
- const $2 *tp = `$2's;
- size_t nelems = ArraySize(`$2's);
- int status = ncx_putn_$1_$2((void **)&xp, nelems, tp);
- assert(xp == buf + nelems * Xsizeof($1));
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if((double) tp[ii] > XMax($1))
- {
- assert(status == NC_ERANGE);
- return;
- }
- }
- assert(status == 0);
- }
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl T_PAD_PUTN(XType, Type)
-dnl
-define(`T_PAD_PUTN',dnl
-`dnl
-static void
-t_pad_putn_$1_$2(char *const buf)
-{
- char *xp = buf;
- const $2 *tp = `$2's;
- size_t nelems = ArraySize(`$2's);
- const char *end = buf + nelems * Xsizeof($1);
- int status = ncx_pad_putn_$1_$2((void **)&xp, nelems, tp);
- assert(xp >= end);
- assert((xp - end) < 4);
- assert((xp - buf)%4 == 0);
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if((double) tp[ii] > XMax($1))
- {
- assert(status == NC_ERANGE);
- return;
- }
- if((double) tp[ii] < XMin($1))
- {
- assert(status == NC_ERANGE);
- return;
- }
- }
- assert(status == 0);
- }
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl T_GETN(XType, Type)
-dnl
-define(`T_GETN',dnl
-`dnl
-static void
-t_getn_$1_$2(const char *const buf)
-{
- const char *xp = buf;
- const $2 *tp = `$2's;
- $2 *lp = ($2 *)lbuf;
- size_t nelems = ArraySize(`$2's);
- int status = ncx_getn_$1_$2((const void **)&xp, nelems, lp);
- assert(xp == buf + nelems * Xsizeof($1));
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if(((double)tp[ii] <= XMax($1))
- && ((double)tp[ii] >= XMin($1)))
- {
- assert(tp[ii] == lp[ii]);
- }
- }
- }
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl T_GETN_U(XType, Type)
-dnl Doesn't make signed comparisons to unsigned type
-dnl
-define(`T_GETN_U',dnl
-`dnl
-static void
-t_getn_$1_$2(const char *const buf)
-{
- const char *xp = buf;
- const $2 *tp = `$2's;
- $2 *lp = ($2 *)lbuf;
- size_t nelems = ArraySize(`$2's);
- int status = ncx_getn_$1_$2((const void **)&xp, nelems, lp);
- assert(xp == buf + nelems * Xsizeof($1));
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if((double) tp[ii] <= XMax($1))
- {
- assert(tp[ii] == lp[ii]);
- }
- }
- }
-}
-')dnl
-dnl dnl dnl
-dnl
-dnl T_PAD_GETN(XType, Type)
-dnl
-define(`T_PAD_GETN',dnl
-`dnl
-static void
-t_pad_getn_$1_$2(const char *const buf)
-{
- const char *xp = buf;
- const $2 *tp = `$2's;
- $2 *lp = ($2 *)lbuf;
- size_t nelems = ArraySize(`$2's);
- const char *end = buf + nelems * Xsizeof($1);
- int status = ncx_pad_getn_$1_$2((const void **)&xp, nelems, lp);
- assert(xp >= end);
- assert((xp - end) < 4);
- assert((xp - buf)%4 == 0);
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if(((double) tp[ii] <= XMax($1))
- && ((double) tp[ii] >= XMin($1)))
- {
- assert(tp[ii] == lp[ii]);
- }
- }
- }
-}
-')dnl
-
-dnl dnl dnl
-dnl
-dnl Declare & define test routines
-dnl
-dnl dnl dnl
-
-T_PUTN(schar, schar)
-dnl T_PUTN(schar, uchar) replaced by special case code.
-dnl - we don't return conversion errors putting uchar to schar.
-static void
-t_putn_schar_uchar(char *const buf)
-{
- char *xp = buf;
- const uchar *tp = uchars;
- size_t nelems = ArraySize(schars);
- int status = ncx_putn_schar_uchar((void **)&xp, nelems, tp);
- assert(xp == buf + nelems * X_SIZEOF_SCHAR);
- assert(status == 0);
-}
-
-T_PUTN(schar, short)
-T_PUTN(schar, int)
-T_PUTN(schar, long)
-T_PUTN(schar, float)
-T_PUTN(schar, double)
-
-T_PAD_PUTN(schar, schar)
-dnl T_PAD_PUTN(schar, uchar) replaced by special case code.
-dnl - we don't return conversion errors putting uchar to schar.
-static void
-t_pad_putn_schar_uchar(char *const buf)
-{
- char *xp = buf;
- const uchar *tp = uchars;
- size_t nelems = ArraySize(uchars);
- const char *end = buf + nelems * X_SIZEOF_SCHAR;
- int status = ncx_pad_putn_schar_uchar((void **)&xp, nelems, tp);
- assert(xp >= end);
- assert((xp - end) < 4);
- assert((xp - buf)%4 == 0);
- assert(status == 0);
-}
-
-T_PAD_PUTN(schar, short)
-T_PAD_PUTN(schar, int)
-T_PAD_PUTN(schar, long)
-T_PAD_PUTN(schar, float)
-T_PAD_PUTN(schar, double)
-
-T_PUTN(short, schar)
-T_PUTN_U(short, uchar)
-T_PUTN(short, short)
-T_PUTN(short, int)
-T_PUTN(short, long)
-T_PUTN(short, float)
-T_PUTN(short, double)
-
-T_PAD_PUTN(short, schar)
-dnl T_PAD_PUTN(short, uchar)
-dnl Don't make signed comparisons to usigned type
-static void
-t_pad_putn_short_uchar(char *const buf)
-{
- char *xp = buf;
- const uchar *tp = uchars;
- size_t nelems = ArraySize(uchars);
- const char *end = buf + nelems * X_SIZEOF_SHORT;
- int status = ncx_pad_putn_short_uchar((void **)&xp, nelems, tp);
- assert(xp >= end);
- assert((xp - end) < 4);
- assert((xp - buf)%4 == 0);
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if(tp[ii] > X_SHORT_MAX)
- {
- assert(status == NC_ERANGE);
- return;
- }
- }
- assert(status == 0);
- }
-}
-
-T_PAD_PUTN(short, short)
-T_PAD_PUTN(short, int)
-T_PAD_PUTN(short, long)
-T_PAD_PUTN(short, float)
-T_PAD_PUTN(short, double)
-
-T_PUTN(int, schar)
-T_PUTN_U(int, uchar)
-T_PUTN(int, short)
-T_PUTN(int, int)
-T_PUTN(int, long)
-T_PUTN(int, float)
-T_PUTN(int, double)
-
-T_PUTN(float, schar)
-T_PUTN_U(float, uchar)
-T_PUTN(float, short)
-T_PUTN(float, int)
-T_PUTN(float, long)
-T_PUTN(float, float)
-T_PUTN(float, double)
-
-T_PUTN(double, schar)
-T_PUTN_U(double, uchar)
-T_PUTN(double, short)
-T_PUTN(double, int)
-T_PUTN(double, long)
-T_PUTN(double, float)
-T_PUTN(double, double)
-
-
-
-T_GETN(schar, schar)
-dnl T_GETN(schar, uchar)
-dnl - we don't return conversion errors gettin schar to uchar.
-static void
-t_getn_schar_uchar(const char *const buf)
-{
- const char *xp = buf;
- const uchar *tp = uchars;
- uchar *lp = (uchar *)lbuf;
- size_t nelems = ArraySize(schars);
- int status = ncx_getn_schar_uchar((const void **)&xp, nelems, lp);
- assert(xp == buf + nelems * X_SIZEOF_SCHAR);
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- assert(tp[ii] == lp[ii]);
- }
- }
-}
-
-T_GETN(schar, short)
-T_GETN(schar, int)
-T_GETN(schar, long)
-T_GETN(schar, float)
-T_GETN(schar, double)
-
-T_PAD_GETN(schar, schar)
-dnl T_PAD_GETN(schar, uchar)
-dnl - we don't return conversion errors gettin schar to uchar.
-static void
-t_pad_getn_schar_uchar(const char *const buf)
-{
- const char *xp = buf;
- const uchar *tp = uchars;
- uchar *lp = (uchar *)lbuf;
- size_t nelems = ArraySize(schars);
- const char *end = buf + nelems * X_SIZEOF_SCHAR;
- int status = ncx_pad_getn_schar_uchar((const void **)&xp, nelems, lp);
- assert(xp >= end);
- assert((xp - end) < 4);
- assert((xp - buf)%4 == 0);
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- assert(tp[ii] == lp[ii]);
- }
- }
-}
-
-T_PAD_GETN(schar, short)
-T_PAD_GETN(schar, int)
-T_PAD_GETN(schar, long)
-T_PAD_GETN(schar, float)
-T_PAD_GETN(schar, double)
-
-T_GETN(short, schar)
-T_GETN_U(short, uchar)
-T_GETN(short, short)
-T_GETN(short, int)
-T_GETN(short, long)
-T_GETN(short, float)
-T_GETN(short, double)
-
-T_PAD_GETN(short, schar)
-dnl T_PAD_GETN(short, uchar)
-dnl Don't make signed comparisons to usigned type
-static void
-t_pad_getn_short_uchar(const char *const buf)
-{
- const char *xp = buf;
- const uchar *tp = uchars;
- uchar *lp = (uchar *)lbuf;
- size_t nelems = ArraySize(uchars);
- const char *end = buf + nelems * X_SIZEOF_SHORT;
- int status = ncx_pad_getn_short_uchar((const void **)&xp, nelems, lp);
- assert(xp >= end);
- assert((xp - end) < 4);
- assert((xp - buf)%4 == 0);
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if((tp[ii] <= X_SHORT_MAX))
- {
- assert(tp[ii] == lp[ii]);
- }
- }
- }
-}
-
-T_PAD_GETN(short, short)
-T_PAD_GETN(short, int)
-T_PAD_GETN(short, long)
-T_PAD_GETN(short, float)
-T_PAD_GETN(short, double)
-
-T_GETN(int, schar)
-T_GETN_U(int, uchar)
-T_GETN(int, short)
-T_GETN(int, int)
-T_GETN(int, long)
-T_GETN(int, float)
-T_GETN(int, double)
-
-T_GETN(float, schar)
-T_GETN_U(float, uchar)
-T_GETN(float, short)
-dnl T_GETN(float, int)
-dnl Exact conversion of int to x_float is limited by external float mantissa
-static void
-t_getn_float_int(const char *const buf)
-{
- const char *xp = buf;
- const int *tp = ints;
- int *lp = (int *)lbuf;
- size_t nelems = ArraySize(ints);
- int status = ncx_getn_float_int((const void **)&xp, nelems, lp);
- assert(xp == buf + nelems * X_SIZEOF_FLOAT);
- /* If the system rounds up can get NC_ERANGE */
- assert(status == 0 || status == NC_ERANGE);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- /* limited by x_float mantissa nbits */
- if((tp[ii] <= 16777215)
- && (tp[ii] >= -16777215))
- {
- assert(tp[ii] == lp[ii]);
- }
- }
- }
-}
-
-dnl T_GETN(float, long)
-dnl Exact conversion of long to x_float is limited by external float mantissa
-static void
-t_getn_float_long(const char *const buf)
-{
- const char *xp = buf;
- const long *tp = longs;
- long *lp = (long *)lbuf;
- size_t nelems = ArraySize(longs);
- int status = ncx_getn_float_long((const void **)&xp, nelems, lp);
- assert(xp == buf + nelems * X_SIZEOF_FLOAT);
- /* If the system rounds up can get NC_ERANGE */
- assert(status == 0 || status == NC_ERANGE);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- /* limited by x_float mantissa nbits */
- if((tp[ii] <= 16777215)
- && (tp[ii] >= 16777215))
- {
- if(tp[ii] != lp[ii])
- (void) fprintf(stderr,
- "%.9e != %.9e float_float (diff %.9e)\n",
- (double)tp[ii], (double)lp[ii],
- (double)(tp[ii] - lp[ii]));
- }
- }
- }
-}
-T_GETN(float, float)
-dnl T_GETN(float, double)
-dnl Exact conversion of double to x_float is limited by external float mantissa
-static void
-t_getn_float_double(const char *const buf)
-{
- const char *xp = buf;
- const double *tp = doubles;
- double *lp = (double *)lbuf;
- size_t nelems = ArraySize(doubles);
- int status = ncx_getn_float_double((const void **)&xp, nelems, lp);
- assert(xp == buf + nelems * X_SIZEOF_FLOAT);
- assert(status == 0);
-
- {
- size_t ii;
- for(ii = 0; ii < nelems; ii++)
- {
- if((tp[ii] <= X_FLOAT_MAX)
- && (tp[ii] >= X_FLOAT_MIN))
- {
- if(((float)tp[ii]) != lp[ii])
- {
- if(tp[ii] != 0)
- {
- double eps = (tp[ii] - lp[ii])/tp[ii];
- if(eps > 1.19209290E-07F) /* X_FLT_EPSILON */
- {
- (void) fprintf(stderr,
- "%.9e != %.9e float_double (eps %.9e)\n",
- tp[ii], lp[ii], eps);
- }
- }
- else
- {
- (void) fprintf(stderr,
- "%.9e != %.9e float_double (diff %.9e)\n",
- tp[ii], lp[ii], tp[ii] - lp[ii]);
-
- }
- }
- }
- }
- }
-}
-
-
-T_GETN(double, schar)
-T_GETN_U(double, uchar)
-T_GETN(double, short)
-T_GETN(double, int)
-T_GETN(double, long)
-T_GETN(double, float)
-T_GETN(double, double)
-
-
-#if defined(_CRAYIEEE) && !defined(_CRAYMPP) /* T90 */
-#include <signal.h>
-#endif /* T90 */
-
-int
-main(int ac, char *av[])
-{
-
-#if defined(_CRAYIEEE) && !defined(_CRAYMPP) /* T90 */
- /*
- * Some of the extreme test assignments in this program trigger
- * floating point exceptions on CRAY T90
- */
- (void) signal(SIGFPE, SIG_IGN);
-#endif /* T90 */
-
- /* x_schar */
- t_putn_schar_schar(ncxb);
- t_getn_schar_schar(ncxb);
-
- t_putn_schar_uchar(ncxb);
- t_getn_schar_uchar(ncxb);
-
- t_putn_schar_short(ncxb);
- t_getn_schar_short(ncxb);
-
- t_putn_schar_int(ncxb);
- t_getn_schar_int(ncxb);
-
- t_putn_schar_long(ncxb);
- t_getn_schar_long(ncxb);
-
- t_putn_schar_float(ncxb);
- t_getn_schar_float(ncxb);
-
- t_putn_schar_double(ncxb);
- t_getn_schar_double(ncxb);
-
- /* pad x_schar */
- t_pad_putn_schar_schar(ncxb);
- t_getn_schar_schar(ncxb);
- t_pad_getn_schar_schar(ncxb);
-
- t_pad_putn_schar_uchar(ncxb);
- t_getn_schar_uchar(ncxb);
- t_pad_getn_schar_uchar(ncxb);
-
- t_pad_putn_schar_short(ncxb);
- t_getn_schar_short(ncxb);
- t_pad_getn_schar_short(ncxb);
-
- t_pad_putn_schar_int(ncxb);
- t_getn_schar_int(ncxb);
- t_pad_getn_schar_int(ncxb);
-
- t_pad_putn_schar_long(ncxb);
- t_getn_schar_long(ncxb);
- t_pad_getn_schar_long(ncxb);
-
- t_pad_putn_schar_float(ncxb);
- t_getn_schar_float(ncxb);
- t_pad_getn_schar_float(ncxb);
-
- t_pad_putn_schar_double(ncxb);
- t_getn_schar_double(ncxb);
- t_pad_getn_schar_double(ncxb);
-
- /* x_short */
- t_putn_short_schar(ncxb);
- t_getn_short_schar(ncxb);
-
- t_putn_short_uchar(ncxb);
- t_getn_short_uchar(ncxb);
-
- t_putn_short_short(ncxb);
- t_getn_short_short(ncxb);
-
- t_putn_short_int(ncxb);
- t_getn_short_int(ncxb);
-
- t_putn_short_long(ncxb);
- t_getn_short_long(ncxb);
-
- t_putn_short_float(ncxb);
- t_getn_short_float(ncxb);
-
- t_putn_short_double(ncxb);
- t_getn_short_double(ncxb);
-
- /* pad x_short */
- t_pad_putn_short_schar(ncxb);
- t_getn_short_schar(ncxb);
- t_pad_getn_short_schar(ncxb);
-
- t_pad_putn_short_uchar(ncxb);
- t_getn_short_uchar(ncxb);
- t_pad_getn_short_uchar(ncxb);
-
- t_pad_putn_short_short(ncxb);
- t_getn_short_short(ncxb);
- t_pad_getn_short_short(ncxb);
-
- t_pad_putn_short_int(ncxb);
- t_getn_short_int(ncxb);
- t_pad_getn_short_int(ncxb);
-
- t_pad_putn_short_long(ncxb);
- t_getn_short_long(ncxb);
- t_pad_getn_short_long(ncxb);
-
- t_pad_putn_short_float(ncxb);
- t_getn_short_float(ncxb);
- t_pad_getn_short_float(ncxb);
-
- t_pad_putn_short_double(ncxb);
- t_getn_short_double(ncxb);
- t_pad_getn_short_double(ncxb);
-
- /* x_int */
- t_putn_int_schar(ncxb);
- t_getn_int_schar(ncxb);
-
- t_putn_int_uchar(ncxb);
- t_getn_int_uchar(ncxb);
-
- t_putn_int_short(ncxb);
- t_getn_int_short(ncxb);
-
- t_putn_int_int(ncxb);
- t_getn_int_int(ncxb);
-
- t_putn_int_long(ncxb);
- t_getn_int_long(ncxb);
-
- t_putn_int_float(ncxb);
- t_getn_int_float(ncxb);
-
- t_putn_int_double(ncxb);
- t_getn_int_double(ncxb);
-
- /* x_float */
- t_putn_float_schar(ncxb);
- t_getn_float_schar(ncxb);
-
- t_putn_float_uchar(ncxb);
- t_getn_float_uchar(ncxb);
-
- t_putn_float_short(ncxb);
- t_getn_float_short(ncxb);
-
- t_putn_float_int(ncxb);
- t_getn_float_int(ncxb);
-
- t_putn_float_long(ncxb);
- t_getn_float_long(ncxb);
-
- t_putn_float_float(ncxb);
- t_getn_float_float(ncxb);
-
- t_putn_float_double(ncxb);
- t_getn_float_double(ncxb);
-
- /* x_double */
- t_putn_double_schar(ncxb);
- t_getn_double_schar(ncxb);
-
- t_putn_double_uchar(ncxb);
- t_getn_double_uchar(ncxb);
-
- t_putn_double_short(ncxb);
- t_getn_double_short(ncxb);
-
- t_putn_double_int(ncxb);
- t_getn_double_int(ncxb);
-
- t_putn_double_long(ncxb);
- t_getn_double_long(ncxb);
-
- t_putn_double_float(ncxb);
- t_getn_double_float(ncxb);
-
- t_putn_double_double(ncxb);
- t_getn_double_double(ncxb);
-
- return 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/test_nc.sav b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/test_nc.sav
deleted file mode 100644
index 3a83947..0000000
Binary files a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/test_nc.sav and /dev/null differ
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/v1hpg.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/v1hpg.c
deleted file mode 100644
index bf70e51..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/v1hpg.c
+++ /dev/null
@@ -1,1315 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: v1hpg.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "rnd.h"
-#include "ncx.h"
-
-/*
- * This module defines the external representation
- * of the "header" of a netcdf version one file.
- * For each of the components of the NC structure,
- * There are (static) ncx_len_XXX(), ncx_put_XXX()
- * and v1h_get_XXX() functions. These define the
- * external representation of the components.
- * The exported entry points for the whole NC structure
- * are built up from these.
- */
-
-
-/*
- * "magic number" at beginning of file: 0x43444601 (big endian)
- * assert(sizeof(ncmagic) % X_ALIGN == 0);
- */
-static const schar ncmagic[] = {'C', 'D', 'F', 0x01};
-
-
-/*
- * v1hs == "Version 1 Header Stream"
- *
- * The netcdf file version 1 header is
- * of unknown and potentially unlimited size.
- * So, we don't know how much to get() on
- * the initial read. We build a stream, 'v1hs'
- * on top of ncio to do the header get.
- */
-typedef struct v1hs {
- ncio *nciop;
- off_t offset; /* argument to nciop->get() */
- size_t extent; /* argument to nciop->get() */
- int flags; /* set to RGN_WRITE for write */
- void *base; /* beginning of current buffer */
- void *pos; /* current position in buffer */
- void *end; /* end of current buffer = base + extent */
-} v1hs;
-
-
-/*
- * Release the stream, invalidate buffer
- */
-static int
-rel_v1hs(v1hs *gsp)
-{
- int status;
- if(gsp->offset == OFF_NONE || gsp->base == NULL)
- return ENOERR;
- status = gsp->nciop->rel(gsp->nciop, gsp->offset,
- gsp->flags == RGN_WRITE ? RGN_MODIFIED : 0);
- gsp->end = NULL;
- gsp->pos = NULL;
- gsp->base = NULL;
- return status;
-}
-
-
-/*
- * Release the current chunk and get the next one.
- * Also used for initialization when gsp->base == NULL.
- */
-static int
-fault_v1hs(v1hs *gsp, size_t extent)
-{
- int status;
-
- if(gsp->base != NULL)
- {
- const size_t incr = (char *)gsp->pos - (char *)gsp->base;
- status = rel_v1hs(gsp);
- if(status)
- return status;
- gsp->offset += incr;
- }
-
- if(extent > gsp->extent)
- gsp->extent = extent;
-
- status = gsp->nciop->get(gsp->nciop,
- gsp->offset, gsp->extent,
- gsp->flags, &gsp->base);
- if(status)
- return status;
-
- gsp->pos = gsp->base;
- gsp->end = (char *)gsp->base + gsp->extent;
-
- return ENOERR;
-}
-
-
-/*
- * Ensure that 'nextread' bytes are available.
- */
-static int
-check_v1hs(v1hs *gsp, size_t nextread)
-{
-
-#if 0 /* DEBUG */
-fprintf(stderr, "nextread %lu, remaining %lu\n",
- (unsigned long)nextread,
- (unsigned long)((char *)gsp->end - (char *)gsp->pos));
-#endif
-
- if((char *)gsp->pos + nextread < (char *)gsp->end)
- return ENOERR;
- return fault_v1hs(gsp, nextread);
-}
-
-/* End v1hs */
-
-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);
-}
-
-
-static int
-v1h_get_size_t(v1hs *gsp, size_t *sp)
-{
- int status = check_v1hs(gsp, X_SIZEOF_SIZE_T);
- if(status != ENOERR)
- return status;
- return ncx_get_size_t((const void **)(&gsp->pos), sp);
-}
-
-
-/* Begin nc_type */
-
-#define X_SIZEOF_NC_TYPE X_SIZEOF_INT
-
-static int
-v1h_put_nc_type(v1hs *psp, const nc_type *typep)
-{
- const int itype = (int) *typep;
- int status = check_v1hs(psp, X_SIZEOF_INT);
- if(status != ENOERR)
- return status;
- status = ncx_put_int_int(psp->pos, &itype);
- psp->pos = (void *)((char *)psp->pos + X_SIZEOF_INT);
- return status;
-}
-
-
-static int
-v1h_get_nc_type(v1hs *gsp, nc_type *typep)
-{
- int type = 0;
- int status = check_v1hs(gsp, X_SIZEOF_INT);
- if(status != ENOERR)
- return status;
- status = ncx_get_int_int(gsp->pos, &type);
- gsp->pos = (void *)((char *)gsp->pos + X_SIZEOF_INT);
- if(status != ENOERR)
- return status;
-
- assert(type == NC_BYTE
- || type == NC_CHAR
- || type == NC_SHORT
- || type == NC_INT
- || type == NC_FLOAT
- || type == NC_DOUBLE);
-
- /* else */
- *typep = (nc_type) type;
-
- return ENOERR;
-}
-
-/* End nc_type */
-/* Begin NCtype (internal tags) */
-
-#define X_SIZEOF_NCTYPE X_SIZEOF_INT
-
-static int
-v1h_put_NCtype(v1hs *psp, NCtype type)
-{
- const int itype = (int) type;
- int status = check_v1hs(psp, X_SIZEOF_INT);
- if(status != ENOERR)
- return status;
- status = ncx_put_int_int(psp->pos, &itype);
- psp->pos = (void *)((char *)psp->pos + X_SIZEOF_INT);
- return status;
-}
-
-static int
-v1h_get_NCtype(v1hs *gsp, NCtype *typep)
-{
- int type = 0;
- int status = check_v1hs(gsp, X_SIZEOF_INT);
- if(status != ENOERR)
- return status;
- status = ncx_get_int_int(gsp->pos, &type);
- gsp->pos = (void *)((char *)gsp->pos + X_SIZEOF_INT);
- if(status != ENOERR)
- return status;
- /* else */
- *typep = (NCtype) type;
- return ENOERR;
-}
-
-/* End NCtype */
-/* Begin NC_string */
-
-/*
- * How much space will the xdr'd string take.
- * Formerly
-NC_xlen_string(cdfstr)
- */
-static size_t
-ncx_len_NC_string(const NC_string *ncstrp)
-{
- size_t sz = X_SIZEOF_SIZE_T; /* nchars */
-
- assert(ncstrp != NULL);
-
- if(ncstrp->nchars != 0)
- {
-#if 0
- assert(ncstrp->nchars % X_ALIGN == 0);
- sz += ncstrp->nchars;
-#else
- sz += _RNDUP(ncstrp->nchars, X_ALIGN);
-#endif
- }
- return sz;
-}
-
-
-static int
-v1h_put_NC_string(v1hs *psp, const NC_string *ncstrp)
-{
- int status;
-
-#if 0
- assert(ncstrp->nchars % X_ALIGN == 0);
-#endif
-
- status = v1h_put_size_t(psp, &ncstrp->nchars);
- if(status != ENOERR)
- return status;
- status = check_v1hs(psp, _RNDUP(ncstrp->nchars, X_ALIGN));
- if(status != ENOERR)
- return status;
- status = ncx_pad_putn_text(&psp->pos, ncstrp->nchars, ncstrp->cp);
- if(status != ENOERR)
- return status;
-
- return ENOERR;
-}
-
-
-static int
-v1h_get_NC_string(v1hs *gsp, NC_string **ncstrpp)
-{
- int status;
- size_t nchars = 0;
- NC_string *ncstrp;
-
- status = v1h_get_size_t(gsp, &nchars);
- if(status != ENOERR)
- return status;
-
- ncstrp = new_NC_string(nchars, NULL);
- if(ncstrp == NULL)
- {
- return NC_ENOMEM;
- }
-
-
-#if 0
-/* assert(ncstrp->nchars == nchars || ncstrp->nchars - nchars < X_ALIGN); */
- assert(ncstrp->nchars % X_ALIGN == 0);
- status = check_v1hs(gsp, ncstrp->nchars);
-#else
-
- status = check_v1hs(gsp, _RNDUP(ncstrp->nchars, X_ALIGN));
-#endif
- if(status != ENOERR)
- goto unwind_alloc;
-
- status = ncx_pad_getn_text((const void **)(&gsp->pos),
- nchars, ncstrp->cp);
- if(status != ENOERR)
- goto unwind_alloc;
-
- *ncstrpp = ncstrp;
-
- return ENOERR;
-
-unwind_alloc:
- free_NC_string(ncstrp);
- return status;
-
-}
-
-/* End NC_string */
-/* Begin NC_dim */
-
-/*
- * How much space will the xdr'd dim take.
- * Formerly
-NC_xlen_dim(dpp)
- */
-static size_t
-ncx_len_NC_dim(const NC_dim *dimp)
-{
- size_t sz;
-
- assert(dimp != NULL);
-
- sz = ncx_len_NC_string(dimp->name);
- sz += X_SIZEOF_SIZE_T;
-
- return(sz);
-}
-
-
-static int
-v1h_put_NC_dim(v1hs *psp, const NC_dim *dimp)
-{
- int status;
-
- status = v1h_put_NC_string(psp, dimp->name);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_size_t(psp, &dimp->size);
- if(status != ENOERR)
- return status;
-
- return ENOERR;
-}
-
-static int
-v1h_get_NC_dim(v1hs *gsp, NC_dim **dimpp)
-{
- int status;
- NC_string *ncstrp;
- NC_dim *dimp;
-
- status = v1h_get_NC_string(gsp, &ncstrp);
- if(status != ENOERR)
- return status;
-
- dimp = new_x_NC_dim(ncstrp);
- if(dimp == NULL)
- {
- status = NC_ENOMEM;
- goto unwind_name;
- }
-
- status = v1h_get_size_t(gsp, &dimp->size);
- if(status != ENOERR)
- {
- free_NC_dim(dimp); /* frees name */
- return status;
- }
-
- *dimpp = dimp;
-
- return ENOERR;
-
-unwind_name:
- free_NC_string(ncstrp);
- return status;
-}
-
-
-static size_t
-ncx_len_NC_dimarray(const NC_dimarray *ncap)
-{
- size_t xlen = X_SIZEOF_NCTYPE; /* type */
- xlen += X_SIZEOF_SIZE_T; /* count */
- if(ncap == NULL)
- return xlen;
- /* else */
- {
- const NC_dim **dpp = (const NC_dim **)ncap->value;
- const NC_dim *const *const end = &dpp[ncap->nelems];
- for( /*NADA*/; dpp < end; dpp++)
- {
- xlen += ncx_len_NC_dim(*dpp);
- }
- }
- return xlen;
-}
-
-
-static int
-v1h_put_NC_dimarray(v1hs *psp, const NC_dimarray *ncap)
-{
- int status;
-
- assert(psp != NULL);
-
- if(ncap == NULL
-#if 1
- /* Backward:
- * This clause is for 'byte for byte'
- * backward compatibility.
- * Strickly speaking, it is 'bug for bug'.
- */
- || ncap->nelems == 0
-#endif
- )
- {
- /*
- * Handle empty netcdf
- */
- const size_t nosz = 0;
-
- status = v1h_put_NCtype(psp, NC_UNSPECIFIED);
- if(status != ENOERR)
- return status;
- status = v1h_put_size_t(psp, &nosz);
- if(status != ENOERR)
- return status;
- return ENOERR;
- }
- /* else */
-
- status = v1h_put_NCtype(psp, NC_DIMENSION);
- if(status != ENOERR)
- return status;
- status = v1h_put_size_t(psp, &ncap->nelems);
- if(status != ENOERR)
- return status;
-
- {
- const NC_dim **dpp = (const NC_dim **)ncap->value;
- const NC_dim *const *const end = &dpp[ncap->nelems];
- for( /*NADA*/; dpp < end; dpp++)
- {
- status = v1h_put_NC_dim(psp, *dpp);
- if(status)
- return status;
- }
- }
- return ENOERR;
-}
-
-
-static int
-v1h_get_NC_dimarray(v1hs *gsp, NC_dimarray *ncap)
-{
- int status;
- NCtype type = NC_UNSPECIFIED;
-
- assert(gsp != NULL && gsp->pos != NULL);
- assert(ncap != NULL);
- assert(ncap->value == NULL);
-
- status = v1h_get_NCtype(gsp, &type);
- if(status != ENOERR)
- return status;
-
- status = v1h_get_size_t(gsp, &ncap->nelems);
- if(status != ENOERR)
- return status;
-
- if(ncap->nelems == 0)
- return ENOERR;
- /* else */
- if(type != NC_DIMENSION)
- return EINVAL;
-
- ncap->value = (NC_dim **) malloc(ncap->nelems * sizeof(NC_dim *));
- if(ncap->value == NULL)
- return NC_ENOMEM;
- ncap->nalloc = ncap->nelems;
-
- {
- NC_dim **dpp = ncap->value;
- NC_dim *const *const end = &dpp[ncap->nelems];
- for( /*NADA*/; dpp < end; dpp++)
- {
- status = v1h_get_NC_dim(gsp, dpp);
- if(status)
- {
- ncap->nelems = dpp - ncap->value;
- free_NC_dimarrayV(ncap);
- return status;
- }
- }
- }
-
- return ENOERR;
-}
-
-
-/* End NC_dim */
-/* Begin NC_attr */
-
-
-/*
- * How much space will 'attrp' take in external representation?
- * Formerly
-NC_xlen_attr(app)
- */
-static size_t
-ncx_len_NC_attr(const NC_attr *attrp)
-{
- size_t sz;
-
- assert(attrp != NULL);
-
- sz = ncx_len_NC_string(attrp->name);
- sz += X_SIZEOF_NC_TYPE; /* type */
- sz += X_SIZEOF_SIZE_T; /* nelems */
- sz += attrp->xsz;
-
- return(sz);
-}
-
-
-#undef MIN
-#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))
-
-/*
- * Put the values of an attribute
- * The loop is necessary since attrp->nelems
- * could potentially be quite large.
- */
-static int
-v1h_put_NC_attrV(v1hs *psp, const NC_attr *attrp)
-{
- int status;
- const size_t perchunk = psp->extent;
- size_t remaining = attrp->xsz;
- void *value = attrp->xvalue;
- size_t nbytes;
-
- assert(psp->extent % X_ALIGN == 0);
-
- do {
- nbytes = MIN(perchunk, remaining);
-
- status = check_v1hs(psp, nbytes);
- if(status != ENOERR)
- return status;
-
- (void) memcpy(psp->pos, value, nbytes);
-
- psp->pos = (void *)((char *)psp->pos + nbytes);
- value = (void *)((char *)value + nbytes);
- remaining -= nbytes;
-
- } while(remaining != 0);
-
- return ENOERR;
-}
-
-static int
-v1h_put_NC_attr(v1hs *psp, const NC_attr *attrp)
-{
- int status;
-
- status = v1h_put_NC_string(psp, attrp->name);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_nc_type(psp, &attrp->type);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_size_t(psp, &attrp->nelems);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_NC_attrV(psp, attrp);
- if(status != ENOERR)
- return status;
-
- return ENOERR;
-}
-
-
-/*
- * Get the values of an attribute
- * The loop is necessary since attrp->nelems
- * could potentially be quite large.
- */
-static int
-v1h_get_NC_attrV(v1hs *gsp, NC_attr *attrp)
-{
- int status;
- const size_t perchunk = gsp->extent;
- size_t remaining = attrp->xsz;
- void *value = attrp->xvalue;
- size_t nget;
-
- assert(gsp->extent % X_ALIGN == 0);
-
- do {
- nget = MIN(perchunk, remaining);
-
- status = check_v1hs(gsp, nget);
- if(status != ENOERR)
- return status;
-
- (void) memcpy(value, gsp->pos, nget);
-
- gsp->pos = (void *)((char *)gsp->pos + nget);
- value = (void *)((char *)value + nget);
- remaining -= nget;
-
- } while(remaining != 0);
-
- return ENOERR;
-}
-
-
-static int
-v1h_get_NC_attr(v1hs *gsp, NC_attr **attrpp)
-{
- NC_string *strp;
- int status;
- nc_type type;
- size_t nelems;
- NC_attr *attrp;
-
- status = v1h_get_NC_string(gsp, &strp);
- if(status != ENOERR)
- return status;
-
- status = v1h_get_nc_type(gsp, &type);
- if(status != ENOERR)
- goto unwind_name;
-
- status = v1h_get_size_t(gsp, &nelems);
- if(status != ENOERR)
- goto unwind_name;
-
- attrp = new_x_NC_attr(strp, type, nelems);
- if(attrp == NULL)
- {
- status = NC_ENOMEM;
- goto unwind_name;
- }
-
- status = v1h_get_NC_attrV(gsp, attrp);
- if(status != ENOERR)
- {
- free_NC_attr(attrp); /* frees strp */
- return status;
- }
-
- *attrpp = attrp;
-
- return ENOERR;
-
-unwind_name:
- free_NC_string(strp);
- return status;
-}
-
-
-static size_t
-ncx_len_NC_attrarray(const NC_attrarray *ncap)
-{
- size_t xlen = X_SIZEOF_NCTYPE; /* type */
- xlen += X_SIZEOF_SIZE_T; /* count */
- if(ncap == NULL)
- return xlen;
- /* else */
- {
- const NC_attr **app = (const NC_attr **)ncap->value;
- const NC_attr *const *const end = &app[ncap->nelems];
- for( /*NADA*/; app < end; app++)
- {
- xlen += ncx_len_NC_attr(*app);
- }
- }
- return xlen;
-}
-
-
-static int
-v1h_put_NC_attrarray(v1hs *psp, const NC_attrarray *ncap)
-{
- int status;
-
- assert(psp != NULL);
-
- if(ncap == NULL
-#if 1
- /* Backward:
- * This clause is for 'byte for byte'
- * backward compatibility.
- * Strickly speaking, it is 'bug for bug'.
- */
- || ncap->nelems == 0
-#endif
- )
- {
- /*
- * Handle empty netcdf
- */
- const size_t nosz = 0;
-
- status = v1h_put_NCtype(psp, NC_UNSPECIFIED);
- if(status != ENOERR)
- return status;
- status = v1h_put_size_t(psp, &nosz);
- if(status != ENOERR)
- return status;
- return ENOERR;
- }
- /* else */
-
- status = v1h_put_NCtype(psp, NC_ATTRIBUTE);
- if(status != ENOERR)
- return status;
- status = v1h_put_size_t(psp, &ncap->nelems);
- if(status != ENOERR)
- return status;
-
- {
- const NC_attr **app = (const NC_attr **)ncap->value;
- const NC_attr *const *const end = &app[ncap->nelems];
- for( /*NADA*/; app < end; app++)
- {
- status = v1h_put_NC_attr(psp, *app);
- if(status)
- return status;
- }
- }
- return ENOERR;
-}
-
-
-static int
-v1h_get_NC_attrarray(v1hs *gsp, NC_attrarray *ncap)
-{
- int status;
- NCtype type = NC_UNSPECIFIED;
-
- assert(gsp != NULL && gsp->pos != NULL);
- assert(ncap != NULL);
- assert(ncap->value == NULL);
-
- status = v1h_get_NCtype(gsp, &type);
- if(status != ENOERR)
- return status;
- status = v1h_get_size_t(gsp, &ncap->nelems);
- if(status != ENOERR)
- return status;
-
- if(ncap->nelems == 0)
- return ENOERR;
- /* else */
- if(type != NC_ATTRIBUTE)
- return EINVAL;
-
- ncap->value = (NC_attr **) malloc(ncap->nelems * sizeof(NC_attr *));
- if(ncap->value == NULL)
- return NC_ENOMEM;
- ncap->nalloc = ncap->nelems;
-
- {
- NC_attr **app = ncap->value;
- NC_attr *const *const end = &app[ncap->nelems];
- for( /*NADA*/; app < end; app++)
- {
- status = v1h_get_NC_attr(gsp, app);
- if(status)
- {
- ncap->nelems = app - ncap->value;
- free_NC_attrarrayV(ncap);
- return status;
- }
- }
- }
-
- return ENOERR;
-}
-
-/* End NC_attr */
-/* Begin NC_var */
-
-/*
- * How much space will the xdr'd var take.
- * Formerly
-NC_xlen_var(vpp)
- */
-static size_t
-ncx_len_NC_var(const NC_var *varp)
-{
- size_t sz;
-
- assert(varp != NULL);
-
- 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 += X_SIZEOF_OFF_T; /* begin */
-
- return(sz);
-}
-
-
-static int
-v1h_put_NC_var(v1hs *psp, const NC_var *varp)
-{
- int status;
-
- status = v1h_put_NC_string(psp, varp->name);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_size_t(psp, &varp->ndims);
- if(status != ENOERR)
- return status;
-
- status = check_v1hs(psp, ncx_len_int(varp->ndims));
- if(status != ENOERR)
- return status;
- status = ncx_putn_int_int(&psp->pos,
- varp->ndims, varp->dimids);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_NC_attrarray(psp, &varp->attrs);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_nc_type(psp, &varp->type);
- if(status != ENOERR)
- return status;
-
- status = v1h_put_size_t(psp, &varp->len);
- if(status != ENOERR)
- return status;
-
- status = check_v1hs(psp, X_SIZEOF_OFF_T);
- if(status != ENOERR)
- return status;
- status = ncx_put_off_t(&psp->pos, &varp->begin);
- if(status != ENOERR)
- return status;
-
- return ENOERR;
-}
-
-
-static int
-v1h_get_NC_var(v1hs *gsp, NC_var **varpp)
-{
- NC_string *strp;
- int status;
- size_t ndims;
- NC_var *varp;
-
- status = v1h_get_NC_string(gsp, &strp);
- if(status != ENOERR)
- return status;
-
- status = v1h_get_size_t(gsp, &ndims);
- if(status != ENOERR)
- goto unwind_name;
-
- varp = new_x_NC_var(strp, ndims);
- if(varp == NULL)
- {
- status = NC_ENOMEM;
- goto unwind_name;
- }
-
- status = check_v1hs(gsp, ncx_len_int(ndims));
- if(status != ENOERR)
- goto unwind_alloc;
- status = ncx_getn_int_int((const void **)(&gsp->pos),
- ndims, varp->dimids);
- 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;
-
- status = v1h_get_size_t(gsp, &varp->len);
- if(status != ENOERR)
- goto unwind_alloc;
-
- status = check_v1hs(gsp, X_SIZEOF_OFF_T);
- if(status != ENOERR)
- goto unwind_alloc;
- status = ncx_get_off_t((const void **)&gsp->pos,
- &varp->begin);
- if(status != ENOERR)
- goto unwind_alloc;
-
- *varpp = varp;
- return ENOERR;
-
-unwind_alloc:
- free_NC_var(varp); /* frees name */
- return status;
-
-unwind_name:
- free_NC_string(strp);
- return status;
-}
-
-
-static size_t
-ncx_len_NC_vararray(const NC_vararray *ncap)
-{
- size_t xlen = X_SIZEOF_NCTYPE; /* type */
- xlen += X_SIZEOF_SIZE_T; /* count */
- if(ncap == NULL)
- return xlen;
- /* else */
- {
- const NC_var **vpp = (const NC_var **)ncap->value;
- const NC_var *const *const end = &vpp[ncap->nelems];
- for( /*NADA*/; vpp < end; vpp++)
- {
- xlen += ncx_len_NC_var(*vpp);
- }
- }
- return xlen;
-}
-
-
-static int
-v1h_put_NC_vararray(v1hs *psp, const NC_vararray *ncap)
-{
- int status;
-
- assert(psp != NULL);
-
- if(ncap == NULL
-#if 1
- /* Backward:
- * This clause is for 'byte for byte'
- * backward compatibility.
- * Strickly speaking, it is 'bug for bug'.
- */
- || ncap->nelems == 0
-#endif
- )
- {
- /*
- * Handle empty netcdf
- */
- const size_t nosz = 0;
-
- status = v1h_put_NCtype(psp, NC_UNSPECIFIED);
- if(status != ENOERR)
- return status;
- status = v1h_put_size_t(psp, &nosz);
- if(status != ENOERR)
- return status;
- return ENOERR;
- }
- /* else */
-
- status = v1h_put_NCtype(psp, NC_VARIABLE);
- if(status != ENOERR)
- return status;
- status = v1h_put_size_t(psp, &ncap->nelems);
- if(status != ENOERR)
- return status;
-
- {
- const NC_var **vpp = (const NC_var **)ncap->value;
- const NC_var *const *const end = &vpp[ncap->nelems];
- for( /*NADA*/; vpp < end; vpp++)
- {
- status = v1h_put_NC_var(psp, *vpp);
- if(status)
- return status;
- }
- }
- return ENOERR;
-}
-
-
-static int
-v1h_get_NC_vararray(v1hs *gsp, NC_vararray *ncap)
-{
- int status;
- NCtype type = NC_UNSPECIFIED;
-
- assert(gsp != NULL && gsp->pos != NULL);
- assert(ncap != NULL);
- assert(ncap->value == NULL);
-
- status = v1h_get_NCtype(gsp, &type);
- if(status != ENOERR)
- return status;
-
- status = v1h_get_size_t(gsp, &ncap->nelems);
- if(status != ENOERR)
- return status;
-
- if(ncap->nelems == 0)
- return ENOERR;
- /* else */
- if(type != NC_VARIABLE)
- return EINVAL;
-
- ncap->value = (NC_var **) malloc(ncap->nelems * sizeof(NC_var *));
- if(ncap->value == NULL)
- return NC_ENOMEM;
- ncap->nalloc = ncap->nelems;
-
- {
- NC_var **vpp = ncap->value;
- NC_var *const *const end = &vpp[ncap->nelems];
- for( /*NADA*/; vpp < end; vpp++)
- {
- status = v1h_get_NC_var(gsp, vpp);
- if(status)
- {
- ncap->nelems = vpp - ncap->value;
- free_NC_vararrayV(ncap);
- return status;
- }
- }
- }
-
- return ENOERR;
-}
-
-
-/* End NC_var */
-/* Begin NC */
-
-
-/*
- * Recompute the shapes of all variables
- * Sets ncp->begin_var to start of first variable.
- * Sets ncp->begin_rec to start of first record variable.
- * Returns -1 on error. The only possible error is an reference
- * to a non existent dimension, which would occur for a corrupt
- * netcdf file.
- */
-static int
-NC_computeshapes(NC *ncp)
-{
- NC_var **vpp = (NC_var **)ncp->vars.value;
- NC_var *const *const end = &vpp[ncp->vars.nelems];
- NC_var *first_var = NULL; /* first "non-record" var */
- NC_var *first_rec = NULL; /* first "record" var */
- int status;
-
- ncp->begin_var = (off_t) ncp->xsz;
- ncp->begin_rec = (off_t) ncp->xsz;
- ncp->recsize = 0;
-
- if(ncp->vars.nelems == 0)
- return(0);
-
- for( /*NADA*/; vpp < end; vpp++)
- {
- status = NC_var_shape(*vpp, &ncp->dims);
- if(status != ENOERR)
- return(status);
-
- if(IS_RECVAR(*vpp))
- {
- if(first_rec == NULL)
- first_rec = *vpp;
- ncp->recsize += (*vpp)->len;
- }
- else if(first_var == NULL)
- {
- first_var = *vpp;
- /*
- * Overwritten each time thru.
- * Usually overwritten in first_rec != NULL clause.
- */
- ncp->begin_rec = (*vpp)->begin + (off_t)(*vpp)->len;
- }
- }
-
- if(first_rec != NULL)
- {
- assert(ncp->begin_rec <= first_rec->begin);
- ncp->begin_rec = first_rec->begin;
- /*
- * for special case of exactly one record variable, pack value
- */
- if(ncp->recsize == first_rec->len)
- ncp->recsize = *first_rec->dsizes * first_rec->xsz;
- }
-
- if(first_var != NULL)
- {
- ncp->begin_var = first_var->begin;
- }
- else
- {
- ncp->begin_var = ncp->begin_rec;
- }
-
- assert(ncp->begin_var > 0);
- assert(ncp->xsz <= (size_t)ncp->begin_var);
- assert(ncp->begin_rec > 0);
- assert(ncp->begin_var <= ncp->begin_rec);
-
- return(ENOERR);
-}
-
-
-size_t
-ncx_len_NC(const NC *ncp)
-{
- size_t xlen = sizeof(ncmagic);
-
- assert(ncp != NULL);
-
- 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);
-
- return xlen;
-}
-
-
-int
-ncx_put_NC(const NC *ncp, void **xpp, off_t offset, size_t extent)
-{
- int status = ENOERR;
- v1hs ps; /* the get stream */
-
- assert(ncp != NULL);
-
- /* Initialize stream ps */
-
- ps.nciop = ncp->nciop;
- ps.flags = RGN_WRITE;
-
- if(xpp == NULL)
- {
- /*
- * Come up with a reasonable stream read size.
- */
- extent = ncp->xsz;
- if(extent <= MIN_NC_XSZ)
- {
- /* first time read */
- extent = ncp->chunk;
- /* Protection for when ncp->chunk is huge;
- * no need to read hugely. */
- if(extent > 4096)
- extent = 4096;
- }
- else if(extent > ncp->chunk)
- {
- extent = ncp->chunk;
- }
-
- ps.offset = 0;
- ps.extent = extent;
- ps.base = NULL;
- ps.pos = ps.base;
-
- status = fault_v1hs(&ps, extent);
- if(status)
- return status;
- }
- else
- {
- ps.offset = offset;
- ps.extent = extent;
- ps.base = *xpp;
- ps.pos = ps.base;
- ps.end = (char *)ps.base + ps.extent;
- }
-
- status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic), ncmagic);
- if(status != ENOERR)
- goto release;
-
- status = ncx_put_size_t(&ps.pos, &ncp->numrecs);
- if(status != ENOERR)
- goto release;
-
- assert((char *)ps.pos < (char *)ps.end);
-
- status = v1h_put_NC_dimarray(&ps, &ncp->dims);
- if(status != ENOERR)
- goto release;
-
- status = v1h_put_NC_attrarray(&ps, &ncp->attrs);
- if(status != ENOERR)
- goto release;
-
- status = v1h_put_NC_vararray(&ps, &ncp->vars);
- if(status != ENOERR)
- goto release;
-
-release:
- (void) rel_v1hs(&ps);
-
- return status;
-}
-
-
-int
-nc_get_NC(NC *ncp)
-{
- int status;
- v1hs gs; /* the get stream */
-
- assert(ncp != NULL);
-
- /* Initialize stream gs */
-
- gs.nciop = ncp->nciop;
- gs.offset = 0; /* beginning of file */
- gs.extent = 0;
- gs.flags = 0;
- gs.base = NULL;
- gs.pos = gs.base;
-
- {
- /*
- * Come up with a reasonable stream read size.
- */
- size_t extent = ncp->xsz;
- if(extent <= MIN_NC_XSZ)
- {
- /* first time read */
- extent = ncp->chunk;
- /* Protection for when ncp->chunk is huge;
- * no need to read hugely. */
- if(extent > 4096)
- extent = 4096;
- }
- else if(extent > ncp->chunk)
- {
- extent = ncp->chunk;
- }
-
- status = fault_v1hs(&gs, extent);
- if(status)
- return status;
- }
-
- /* get the header from the stream gs */
-
- {
- /* Get & check magic number */
- schar magic[sizeof(ncmagic)];
- (void) memset(magic, 0, sizeof(magic));
-
- status = ncx_getn_schar_schar(
- (const void **)(&gs.pos), sizeof(magic), magic);
- if(status != ENOERR)
- goto unwind_get;
-
- if(memcmp(magic, ncmagic, sizeof(ncmagic)) != 0)
- {
- status = NC_ENOTNC;
- goto unwind_get;
- }
- }
-
- status = ncx_get_size_t((const void **)(&gs.pos), &ncp->numrecs);
- if(status != ENOERR)
- goto unwind_get;
-
- assert((char *)gs.pos < (char *)gs.end);
-
- status = v1h_get_NC_dimarray(&gs, &ncp->dims);
- if(status != ENOERR)
- goto unwind_get;
-
- status = v1h_get_NC_attrarray(&gs, &ncp->attrs);
- if(status != ENOERR)
- goto unwind_get;
-
- status = v1h_get_NC_vararray(&gs, &ncp->vars);
- if(status != ENOERR)
- goto unwind_get;
-
- ncp->xsz = ncx_len_NC(ncp);
-
- status = NC_computeshapes(ncp);
-
-unwind_get:
- (void) rel_v1hs(&gs);
- return status;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/v2i.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/v2i.c
deleted file mode 100644
index b0b7356..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/v2i.c
+++ /dev/null
@@ -1,943 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: v2i.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-
-#if SIZEOF_LONG == SIZEOF_SIZE_T
-/*
- * We don't have to copy the arguments to switch from 'long'
- * to 'size_t' or 'ptrdiff_t'. Use dummy macros.
- */
-
-# define NDIMS_DECL
-# define A_DECL(name, type, ndims, rhs) \
- const type *const name = ((const type *)(rhs))
-
-# define A_FREE(name)
-
-# define A_INIT(lhs, type, ndims, rhs)
-
-#else
-/*
- * We do have to copy the arguments to switch from 'long'
- * to 'size_t' or 'ptrdiff_t'. In my tests on an SGI,
- * any additional cost was lost in measurement variation.
- */
-
-# include "onstack.h"
-
-static size_t
-nvdims(int ncid, int varid)
-{
- NC *ncp;
- if(NC_check_id(ncid, &ncp) != NC_NOERR)
- return 0;
- {
- const NC_var *const varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- return 0;
- return varp->ndims;
- }
-}
-
-#define NDIMS_DECL const size_t ndims = nvdims(ncid, varid);
-
-# define A_DECL(name, type, ndims, rhs) \
- ALLOC_ONSTACK(name, type, ndims)
-
-# define A_FREE(name) \
- FREE_ONSTACK(name)
-
-# define A_INIT(lhs, type, ndims, rhs) \
- { \
- const long *lp = rhs; \
- type *tp = lhs; \
- type *const end = lhs + ndims; \
- while(tp < end) \
- { \
- *tp++ = (type) *lp++; \
- } \
- }
-
-
-#endif
-
-
-/* Begin globals */
-
-/*
- * Error code
- */
-int ncerr = NC_NOERR ;
-
-
-/*
- * The subroutines in error.c emit no messages unless NC_VERBOSE bit is on.
- * They call exit() when NC_FATAL bit is on.
- */
-int ncopts = (NC_FATAL | NC_VERBOSE) ;
-
-
-/*
- * Backward compatibility for the version 2 fortran jackets
- */
-const char *cdf_routine_name;
-
-
-/* End globals */
-
-/* Begin error handling */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-
-/*
- */
-void
-nc_advise(const char *routine_name, int err, const char *fmt,...)
-{
- va_list args;
-
- if(NC_ISSYSERR(err))
- ncerr = NC_SYSERR;
- else
- ncerr = err;
-
- if( ncopts & NC_VERBOSE )
- {
- (void) fprintf(stderr,"%s: ", routine_name);
- va_start(args ,fmt);
- (void) vfprintf(stderr,fmt,args);
- va_end(args);
- if(err != NC_NOERR)
- {
- (void) fprintf(stderr,": %s",
- nc_strerror(err));
- }
- (void) fputc('\n',stderr);
- (void) fflush(stderr); /* to ensure log files are current */
- }
-
- if( (ncopts & NC_FATAL) && err != NC_NOERR )
- {
- exit(ncopts);
- }
-}
-
-
-/*
- * Backward compatibility for the version 2 fortran jackets
- */
-void
-NCadvise(int err, char *fmt,...)
-{
- va_list args;
-
- va_start(args ,fmt);
- nc_advise(cdf_routine_name, err, fmt, args);
- va_end(args);
-}
-
-/* End error handling */
-
-
-int
-nccreate(const char* path, int cmode)
-{
- int ncid;
- const int status = nc_create(path, cmode, &ncid);
- if(status != NC_NOERR)
- {
- nc_advise("nccreate", status, "filename \"%s\"", path);
- return -1;
- }
- return ncid;
-}
-
-
-int
-ncopen(const char *path, int mode)
-{
- int ncid;
- const int status = nc_open(path, mode, &ncid);
- if(status != NC_NOERR)
- {
- nc_advise("ncopen", status, "filename \"%s\"", path);
- return -1;
- }
- return ncid;
-}
-
-
-int
-ncredef(int ncid)
-{
- const int status = nc_redef(ncid);
- if(status != NC_NOERR)
- {
- nc_advise("ncredef", status, "ncid %d", ncid);
- return -1;
- }
- return 0;
-}
-
-
-int
-ncendef(int ncid)
-{
- const int status = nc_enddef(ncid);
- if(status != NC_NOERR)
- {
- nc_advise("ncendef", status, "ncid %d", ncid);
- return -1;
- }
- return 0;
-}
-
-
-int
-ncclose(int ncid)
-{
- const int status = nc_close(ncid);
- if(status != NC_NOERR)
- {
- nc_advise("ncclose", status, "ncid %d", ncid);
- return -1;
-
- }
- return 0;
-}
-
-
-int
-ncinquire(
- int ncid,
- int* ndims,
- int* nvars,
- int* natts,
- int* recdim
-)
-{
- int nd, nv, na;
- const int status = nc_inq(ncid, &nd, &nv, &na, recdim);
-
- if(status != NC_NOERR)
- {
- nc_advise("ncinquire", status, "ncid %d", ncid);
- return -1;
- }
- /* else */
-
- if(ndims != NULL)
- *ndims = (int) nd;
-
- if(nvars != NULL)
- *nvars = (int) nv;
-
- if(natts != NULL)
- *natts = (int) na;
-
- return ncid;
-}
-
-
-int
-ncsync(int ncid)
-{
- const int status = nc_sync(ncid);
- if(status != NC_NOERR)
- {
- nc_advise("ncsync", status, "ncid %d", ncid);
- return -1;
-
- }
- return 0;
-}
-
-
-int
-ncabort(int ncid)
-{
- const int status = nc_abort(ncid);
- if(status != NC_NOERR)
- {
- nc_advise("ncabort", status, "ncid %d", ncid);
- return -1;
- }
- return 0;
-}
-
-
-int
-ncdimdef(
- int ncid,
- const char* name,
- long length
-)
-{
- int dimid;
- const int status = nc_def_dim(ncid, name, (size_t)length, &dimid);
- if(status != NC_NOERR)
- {
- nc_advise("ncdimdef", status, "ncid %d", ncid);
- return -1;
- }
- return dimid;
-}
-
-
-int
-ncdimid(int ncid, const char* name)
-{
- int dimid;
- const int status = nc_inq_dimid(ncid, name, &dimid);
- if(status != NC_NOERR)
- {
- nc_advise("ncdimid", status, "ncid %d", ncid);
- return -1;
- }
- return dimid;
-}
-
-
-int
-ncdiminq(
- int ncid,
- int dimid,
- char* name,
- long* length
-)
-{
- size_t ll;
- const int status = nc_inq_dim(ncid, dimid, name, &ll);
-
- if(status != NC_NOERR)
- {
- nc_advise("ncdiminq", status, "ncid %d", ncid);
- return -1;
- }
- /* else */
-
- if(length != NULL)
- *length = (int) ll;
-
- return dimid;
-}
-
-
-int
-ncdimrename(
- int ncid,
- int dimid,
- const char* name
-)
-{
- const int status = nc_rename_dim(ncid, dimid, name);
- if(status != NC_NOERR)
- {
- nc_advise("ncdimrename", status, "ncid %d", ncid);
- return -1;
- }
- return dimid;
-}
-
-
-int
-ncvardef(
- int ncid,
- const char* name,
- nc_type datatype,
- int ndims,
- const int* dim
-)
-{
- int varid = -1;
- const int status = nc_def_var(ncid, name, datatype, ndims, dim, &varid);
- if(status != NC_NOERR)
- {
- nc_advise("ncvardef", status, "ncid %d", ncid);
- return -1;
- }
- return varid;
-}
-
-
-int
-ncvarid(
- int ncid,
- const char* name
-)
-{
- int varid = -1;
- const int status = nc_inq_varid(ncid, name, &varid);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarid", status, "ncid %d", ncid);
- return -1;
- }
- return varid;
-}
-
-
-int
-ncvarinq(
- int ncid,
- int varid,
- char* name,
- nc_type* datatype,
- int* ndims,
- int* dim,
- int* natts
-)
-{
- int nd, na;
- const int status = nc_inq_var(ncid, varid, name, datatype,
- &nd, dim, &na);
-
- if(status != NC_NOERR)
- {
- nc_advise("ncvarinq", status, "ncid %d", ncid);
- return -1;
- }
- /* else */
-
- if(ndims != NULL)
- *ndims = (int) nd;
-
- if(natts != NULL)
- *natts = (int) na;
-
- return varid;
-}
-
-
-int
-ncvarput1(
- int ncid,
- int varid,
- const long* index,
- const void* value
-)
-{
- NDIMS_DECL
- A_DECL(coordp, size_t, ndims, index);
- A_INIT(coordp, size_t, ndims, index);
- {
- const int status = nc_put_var1(ncid, varid, coordp, value);
- A_FREE(coordp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarput1", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
-}
-
-
-int
-ncvarget1(
- int ncid,
- int varid,
- const long* index,
- void* value
-)
-{
- NDIMS_DECL
- A_DECL(coordp, size_t, ndims, index);
- A_INIT(coordp, size_t, ndims, index);
- {
- const int status = nc_get_var1(ncid, varid, coordp, value);
- A_FREE(coordp);
- if(status != NC_NOERR)
- {
- nc_advise("ncdimid", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
-}
-
-
-int
-ncvarput(
- int ncid,
- int varid,
- const long* start,
- const long* count,
- const void* value
-)
-{
- NDIMS_DECL
- A_DECL(stp, size_t, ndims, start);
- A_DECL(cntp, size_t, ndims, count);
- A_INIT(stp, size_t, ndims, start);
- A_INIT(cntp, size_t, ndims, count);
- {
- const int status = nc_put_vara(ncid, varid, stp, cntp, value);
- A_FREE(cntp);
- A_FREE(stp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarput", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
-}
-
-
-int
-ncvarget(
- int ncid,
- int varid,
- const long* start,
- const long* count,
- void* value
-)
-{
- NDIMS_DECL
- A_DECL(stp, size_t, ndims, start);
- A_DECL(cntp, size_t, ndims, count);
- A_INIT(stp, size_t, ndims, start);
- A_INIT(cntp, size_t, ndims, count);
- {
- const int status = nc_get_vara(ncid, varid, stp, cntp, value);
- A_FREE(cntp);
- A_FREE(stp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarget", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
-}
-
-
-int
-ncvarputs(
- int ncid,
- int varid,
- const long* start,
- const long* count,
- const long* stride,
- const void* value
-)
-{
- if(stride == NULL)
- return ncvarput(ncid, varid, start, count, value);
- /* else */
- {
- NDIMS_DECL
- A_DECL(stp, size_t, ndims, start);
- A_DECL(cntp, size_t, ndims, count);
- A_DECL(strdp, ptrdiff_t, ndims, stride);
- A_INIT(stp, size_t, ndims, start);
- A_INIT(cntp, size_t, ndims, count);
- A_INIT(strdp, ptrdiff_t, ndims, stride);
- {
- const int status = nc_put_vars(ncid, varid, stp, cntp, strdp, value);
- A_FREE(strdp);
- A_FREE(cntp);
- A_FREE(stp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarputs", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
- }
-}
-
-
-int
-ncvargets(
- int ncid,
- int varid,
- const long* start,
- const long* count,
- const long* stride,
- void* value
-)
-{
- if(stride == NULL)
- return ncvarget(ncid, varid, start, count, value);
- /* else */
- {
- NDIMS_DECL
- A_DECL(stp, size_t, ndims, start);
- A_DECL(cntp, size_t, ndims, count);
- A_DECL(strdp, ptrdiff_t, ndims, stride);
- A_INIT(stp, size_t, ndims, start);
- A_INIT(cntp, size_t, ndims, count);
- A_INIT(strdp, ptrdiff_t, ndims, stride);
- {
- const int status = nc_get_vars(ncid, varid, stp, cntp, strdp, value);
- A_FREE(strdp);
- A_FREE(cntp);
- A_FREE(stp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvargets", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
- }
-}
-
-
-int
-ncvarputg(
- int ncid,
- int varid,
- const long* start,
- const long* count,
- const long* stride,
- const long* map,
- const void* value
-)
-{
- if(map == NULL)
- return ncvarputs(ncid, varid, start, count, stride, value);
- /* else */
- {
- NDIMS_DECL
- 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);
- A_FREE(strdp);
- A_FREE(cntp);
- A_FREE(stp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarputg", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
- }
-}
-
-
-int
-ncvargetg(
- int ncid,
- int varid,
- const long* start,
- const long* count,
- const long* stride,
- const long* map,
- void* value
-)
-{
- if(map == NULL)
- return ncvargets(ncid, varid, start, count, stride, value);
- /* else */
- {
- NDIMS_DECL
- 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);
- A_FREE(strdp);
- A_FREE(cntp);
- A_FREE(stp);
- if(status != NC_NOERR)
- {
- nc_advise("ncvargetg", status, "ncid %d", ncid);
- return -1;
- }
- }
- return 0;
- }
-}
-
-
-int
-ncvarrename(
- int ncid,
- int varid,
- const char* name
-)
-{
- const int status = nc_rename_var(ncid, varid, name);
- if(status != NC_NOERR)
- {
- nc_advise("ncvarrename", status, "ncid %d", ncid);
- return -1;
- }
- return varid;
-}
-
-
-int
-ncattput(
- int ncid,
- int varid,
- const char* name,
- nc_type datatype,
- int len,
- const void* value
-)
-{
- const int status = nc_put_att(ncid, varid, name, datatype, len, value);
- if(status != NC_NOERR)
- {
- nc_advise("ncattput", status, "ncid %d", ncid);
- return -1;
- }
- return 0;
-}
-
-
-int
-ncattinq(
- int ncid,
- int varid,
- const char* name,
- nc_type* datatype,
- int* len
-)
-{
- size_t ll;
- const int status = nc_inq_att(ncid, varid, name, datatype, &ll);
- if(status != NC_NOERR)
- {
- nc_advise("ncattinq", status, "ncid %d", ncid);
- return -1;
- }
-
- if(len != NULL)
- *len = (int) ll;
-
- return 1;
-
-}
-
-
-int
-ncattget(
- int ncid,
- int varid,
- const char* name,
- void* value
-)
-{
- const int status = nc_get_att(ncid, varid, name, value);
- if(status != NC_NOERR)
- {
- nc_advise("ncattget", status, "ncid %d", ncid);
- return -1;
- }
- return 1;
-}
-
-
-int
-ncattcopy(
- int ncid_in,
- int varid_in,
- const char* name,
- int ncid_out,
- int varid_out
-)
-{
- const int status = nc_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
- if(status != NC_NOERR)
- {
- nc_advise("ncattcopy", status, "%s", name);
- return -1;
- }
- return 0;
-}
-
-
-int
-ncattname(
- int ncid,
- int varid,
- int attnum,
- char* name
-)
-{
- const int status = nc_inq_attname(ncid, varid, attnum, name);
- if(status != NC_NOERR)
- {
- nc_advise("ncattname", status, "ncid %d", ncid);
- return -1;
- }
- return attnum;
-}
-
-
-int
-ncattrename(
- int ncid,
- int varid,
- const char* name,
- const char* newname
-)
-{
- const int status = nc_rename_att(ncid, varid, name, newname);
- if(status != NC_NOERR)
- {
- nc_advise("ncattrename", status, "ncid %d", ncid);
- return -1;
- }
- return 1;
-}
-
-
-int
-ncattdel(
- int ncid,
- int varid,
- const char* name
-)
-{
- const int status = nc_del_att(ncid, varid, name);
- if(status != NC_NOERR)
- {
- nc_advise("ncattdel", status, "ncid %d", ncid);
- return -1;
- }
- return 1;
-}
-
-
-/*
- * This is how much space is required by the user, as in
- *
- * vals = malloc(nel * nctypelen(var.type));
- * ncvarget(cdfid, varid, cor, edg, vals);
- */
-int
-nctypelen(nc_type type)
-{
- switch(type){
- case NC_BYTE :
- case NC_CHAR :
- return((int)sizeof(char));
- case NC_SHORT :
- return(int)(sizeof(short));
- case NC_INT :
- return((int)sizeof(nclong));
- case NC_FLOAT :
- return((int)sizeof(float));
- case NC_DOUBLE :
- return((int)sizeof(double));
- }
- /* else */
- nc_advise("nctypelen", NC_EBADTYPE, "Unknown type %d",
- (int)type);
- return -1;
-}
-
-
-int
-ncsetfill(
- int ncid,
- int fillmode
-)
-{
- int oldmode = -1;
- const int status = nc_set_fill(ncid, fillmode, &oldmode);
- if(status != NC_NOERR)
- {
- nc_advise("ncsetfill", status, "ncid %d", ncid);
- return -1;
- }
- return oldmode;
-}
-
-
-int
-ncrecinq(
- int ncid,
- int* nrecvars,
- int* recvarids,
- long* recsizes
-)
-{
- size_t nrv = 0;
- size_t rs[NC_MAX_VARS]; /* TODO */
- const int status = nc_inq_rec(ncid, &nrv, recvarids, rs);
- if(status != NC_NOERR)
- {
- nc_advise("ncrecinq", status, "ncid %d", ncid);
- return -1;
- }
-
- if(nrecvars != NULL)
- *nrecvars = (int) nrv;
-
- if(recsizes != NULL)
- {
- size_t ii;
- for(ii = 0; ii < nrv; ii++)
- {
- recsizes[ii] = (long) rs[ii];
- }
- }
-
- return (int) nrv;
-}
-
-
-int
-ncrecget(
- int ncid,
- long recnum,
- void** datap
-)
-{
- const int status = nc_get_rec(ncid, (size_t)recnum, datap);
- if(status != NC_NOERR)
- {
- nc_advise("ncrecget", status, "ncid %d", ncid);
- return -1;
- }
- return 0;
-}
-
-
-int
-ncrecput(
- int ncid,
- long recnum,
- void* const* datap
-)
-{
- const int status = nc_put_rec(ncid, (size_t)recnum, datap);
- if(status != NC_NOERR)
- {
- nc_advise("ncrecput", status, "ncid %d", ncid);
- return -1;
- }
- return 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/var.c b/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/var.c
deleted file mode 100644
index d781be5..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/libsrc/var.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * Copyright 1996, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- */
-/* $Id: var.c,v 1.1.1.1 2005/06/14 04:38:32 svitak Exp $ */
-
-#include "nc.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "ncx.h"
-#include "rnd.h"
-
-
-/*
- * Free var
- * Formerly
-NC_free_var(var)
- */
-void
-free_NC_var(NC_var *varp)
-{
- if(varp == NULL)
- return;
- free_NC_attrarrayV(&varp->attrs);
- free_NC_string(varp->name);
- free(varp);
-}
-
-
-/*
- * Common code for new_NC_var()
- * and ncx_get_NC_var()
- */
-NC_var *
-new_x_NC_var(
- NC_string *strp,
- size_t ndims)
-{
- NC_var *varp;
- const size_t o1 = M_RNDUP(ndims * sizeof(int));
- const size_t o2 = M_RNDUP(ndims * sizeof(size_t));
- const size_t sz = M_RNDUP(sizeof(NC_var)) +
- o1 + o2 + ndims * sizeof(size_t);
-
- varp = (NC_var *) malloc(sz);
- if(varp == NULL )
- return NULL;
- (void) memset(varp, 0, sz);
-
- varp->name = strp;
- varp->ndims = ndims;
-
- if(ndims != 0)
- {
- /*
- * NOTE: lint may complain about the next 3 lines:
- * "pointer cast may result in improper alignment".
- * We use the M_RNDUP() macro to get the proper alignment.
- */
- varp->dimids = (int *)((char *)varp + M_RNDUP(sizeof(NC_var)));
- varp->shape = (size_t *)((char *)varp->dimids + o1);
- varp->dsizes = (size_t *)((char *)varp->shape + o2);
- }
-
- varp->xsz = 0;
- varp->len = 0;
- varp->begin = 0;
-
- return varp;
-}
-
-
-/*
- * Formerly
-NC_new_var()
- */
-static NC_var *
-new_NC_var(const char *name, nc_type type,
- size_t ndims, const int *dimids)
-{
- NC_string *strp;
- NC_var *varp;
-
- strp = new_NC_string(strlen(name), name);
- if(strp == NULL)
- return NULL;
-
- varp = new_x_NC_var(strp, ndims);
- if(varp == NULL )
- {
- free_NC_string(strp);
- return NULL;
- }
-
- varp->type = type;
-
- if( ndims != 0 && dimids != NULL)
- (void) memcpy(varp->dimids, dimids, ndims * sizeof(int));
-
- return(varp);
-}
-
-
-static NC_var *
-dup_NC_var(const NC_var *rvarp)
-{
- NC_var *varp = new_NC_var(rvarp->name->cp, rvarp->type,
- rvarp->ndims, rvarp->dimids);
- if(varp == NULL)
- return NULL;
-
-
- if(dup_NC_attrarrayV(&varp->attrs, &rvarp->attrs) != NC_NOERR)
- {
- free_NC_var(varp);
- return NULL;
- }
-
- (void) memcpy(varp->shape, rvarp->shape,
- rvarp->ndims * sizeof(size_t));
- (void) memcpy(varp->dsizes, rvarp->dsizes,
- rvarp->ndims * sizeof(size_t));
- varp->xsz = rvarp->xsz;
- varp->len = rvarp->len;
- varp->begin = rvarp->begin;
-
- return varp;
-}
-
-
-/* vararray */
-
-
-/*
- * Free the stuff "in" (referred to by) an NC_vararray.
- * Leaves the array itself allocated.
- */
-void
-free_NC_vararrayV0(NC_vararray *ncap)
-{
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return;
-
- assert(ncap->value != NULL);
-
- {
- NC_var **vpp = ncap->value;
- NC_var *const *const end = &vpp[ncap->nelems];
- for( /*NADA*/; vpp < end; vpp++)
- {
- free_NC_var(*vpp);
- *vpp = NULL;
- }
- }
- ncap->nelems = 0;
-}
-
-
-/*
- * Free NC_vararray values.
- * formerly
-NC_free_array()
- */
-void
-free_NC_vararrayV(NC_vararray *ncap)
-{
- assert(ncap != NULL);
-
- if(ncap->nalloc == 0)
- return;
-
- assert(ncap->value != NULL);
-
- free_NC_vararrayV0(ncap);
-
- free(ncap->value);
- ncap->value = NULL;
- ncap->nalloc = 0;
-}
-
-
-int
-dup_NC_vararrayV(NC_vararray *ncap, const NC_vararray *ref)
-{
- int status = NC_NOERR;
-
- assert(ref != NULL);
- assert(ncap != NULL);
-
- if(ref->nelems != 0)
- {
- const size_t sz = ref->nelems * sizeof(NC_var *);
- ncap->value = (NC_var **) malloc(sz);
- if(ncap->value == NULL)
- return NC_ENOMEM;
- (void) memset(ncap->value, 0, sz);
- ncap->nalloc = ref->nelems;
- }
-
- ncap->nelems = 0;
- {
- NC_var **vpp = ncap->value;
- const NC_var **drpp = (const NC_var **)ref->value;
- NC_var *const *const end = &vpp[ref->nelems];
- for( /*NADA*/; vpp < end; drpp++, vpp++, ncap->nelems++)
- {
- *vpp = dup_NC_var(*drpp);
- if(*vpp == NULL)
- {
- status = NC_ENOMEM;
- break;
- }
- }
- }
-
- if(status != NC_NOERR)
- {
- free_NC_vararrayV(ncap);
- return status;
- }
-
- assert(ncap->nelems == ref->nelems);
-
- return NC_NOERR;
-}
-
-
-/*
- * Add a new handle on the end of an array of handles
- * Formerly
-NC_incr_array(array, tail)
- */
-static int
-incr_NC_vararray(NC_vararray *ncap, NC_var *newelemp)
-{
- NC_var **vp;
-
- assert(ncap != NULL);
-
- if(ncap->nalloc == 0)
- {
- assert(ncap->nelems == 0);
- vp = (NC_var **) malloc(NC_ARRAY_GROWBY * sizeof(NC_var *));
- if(vp == NULL)
- return NC_ENOMEM;
- ncap->value = vp;
- ncap->nalloc = NC_ARRAY_GROWBY;
- }
- else if(ncap->nelems +1 > ncap->nalloc)
- {
- vp = (NC_var **) realloc(ncap->value,
- (ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_var *));
- if(vp == NULL)
- return NC_ENOMEM;
- ncap->value = vp;
- ncap->nalloc += NC_ARRAY_GROWBY;
- }
-
- if(newelemp != NULL)
- {
- ncap->value[ncap->nelems] = newelemp;
- ncap->nelems++;
- }
- return NC_NOERR;
-}
-
-
-static NC_var *
-elem_NC_vararray(const NC_vararray *ncap, size_t elem)
-{
- assert(ncap != NULL);
- /* cast needed for braindead systems with signed size_t */
- if(ncap->nelems == 0 || (unsigned long)elem >= ncap->nelems)
- return NULL;
-
- assert(ncap->value != NULL);
-
- return ncap->value[elem];
-}
-
-
-/* End vararray per se */
-
-
-/*
- * Step thru NC_VARIABLE array, seeking match on name.
- * Return varid or -1 on not found.
- * *varpp is set to the appropriate NC_var.
- * Formerly (sort of)
-NC_hvarid
- */
-int
-NC_findvar(const NC_vararray *ncap, const char *name, NC_var **varpp)
-{
- NC_var **loc;
- size_t slen;
- int varid;
-
- assert(ncap != NULL);
-
- if(ncap->nelems == 0)
- return -1;
-
- loc = (NC_var **) ncap->value;
-
- slen = strlen(name);
-
- for(varid = 0; (size_t) varid < ncap->nelems; varid++, loc++)
- {
- if(strlen((*loc)->name->cp) == slen &&
- strncmp((*loc)->name->cp, name, slen) == 0)
- {
- if(varpp != NULL)
- *varpp = *loc;
- return(varid); /* Normal return */
- }
- }
- return(-1); /* not found */
-}
-
-/*
- * For a netcdf type
- * return the size of one element in the external representation.
- * Note that arrays get rounded up to X_ALIGN boundaries.
- * Formerly
-NC_xtypelen
- * See also ncx_len()
- */
-size_t
-ncx_szof(nc_type type)
-{
- switch(type){
- case NC_BYTE:
- case NC_CHAR:
- return(1);
- case NC_SHORT :
- return(2);
- case NC_INT:
- return X_SIZEOF_INT;
- case NC_FLOAT:
- return X_SIZEOF_FLOAT;
- case NC_DOUBLE :
- return X_SIZEOF_DOUBLE;
- }
- /* default */
- assert("ncx_szof invalid type" == 0);
- return 0;
-}
-
-
-/*
- * 'compile' the shape and len of a variable
- * Formerly
-NC_var_shape(var, dims)
- */
-int
-NC_var_shape(NC_var *varp, const NC_dimarray *dims)
-{
- size_t *shp, *dsp, *op;
- int *ip;
- const NC_dim *dimp;
- size_t product = 1;
-
- varp->xsz = ncx_szof(varp->type);
-
- if(varp->ndims == 0)
- {
- goto out;
- }
-
- /*
- * use the user supplied dimension indices
- * to determine the shape
- */
- for(ip = varp->dimids, op = varp->shape
- ; ip < &varp->dimids[varp->ndims]; ip++, op++)
- {
- if(*ip < 0 || (size_t) (*ip) >= ((dims != NULL) ? dims->nelems : 1) )
- return NC_EBADDIM;
-
- dimp = elem_NC_dimarray(dims, (size_t)*ip);
- *op = dimp->size;
- if(*op == NC_UNLIMITED && ip != varp->dimids)
- return NC_EUNLIMPOS;
- }
-
- /*
- * Compute the dsizes
- */
- /* ndims is > 0 here */
- for(shp = varp->shape + varp->ndims -1,
- dsp = varp->dsizes + varp->ndims -1;
- shp >= varp->shape;
- shp--, dsp--)
- {
- if(!(shp == varp->shape && IS_RECVAR(varp)))
- product *= *shp;
- *dsp = product;
- }
-
-
-out :
- varp->len = product * varp->xsz;
- switch(varp->type) {
- case NC_BYTE :
- case NC_CHAR :
- case NC_SHORT :
- if( varp->len%4 != 0 )
- {
- varp->len += 4 - varp->len%4; /* round up */
- /* *dsp += 4 - *dsp%4; */
- }
- break;
- default:
- /* already aligned */
- break;
- }
-#if 0
- arrayp("\tshape", varp->ndims, varp->shape);
- arrayp("\tdsizes", varp->ndims, varp->dsizes);
-#endif
- return NC_NOERR;
-}
-
-
-/*
- * Given valid ncp and varid, return var
- * else NULL on error
- * Formerly
-NC_hlookupvar()
- */
-NC_var *
-NC_lookupvar(NC *ncp, int varid)
-{
- NC_var *varp;
-
- if(varid == NC_GLOBAL)
- {
- /* Global is error in this context */
- return(NULL);
- }
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- {
- return NULL;
- }
-
- assert(varp != NULL);
-
- return(varp);
-}
-
-
-/* Public */
-
-int
-nc_def_var( int ncid, const char *name, nc_type type,
- int ndims, const int *dimids, int *varidp)
-{
- int status;
- NC *ncp;
- int varid;
- NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(!NC_indef(ncp))
- {
- return NC_ENOTINDEFINE;
- }
-
- status = NC_check_name(name);
- if(status != NC_NOERR)
- return status;
-
- status = nc_cktype(type);
- if(status != NC_NOERR)
- return status;
-
- /* cast needed for braindead systems with signed size_t */
- if((unsigned long) ndims > X_INT_MAX) /* Backward compat */
- {
- return NC_EINVAL;
- }
-
- if(ncp->vars.nelems >= NC_MAX_VARS)
- {
- return NC_EMAXVARS;
- }
-
- varid = NC_findvar(&ncp->vars, name, &varp);
- if(varid != -1)
- {
- return NC_ENAMEINUSE;
- }
-
- varp = new_NC_var(name, type, ndims, dimids);
- if(varp == NULL)
- return NC_ENOMEM;
-
- status = NC_var_shape(varp, &ncp->dims);
- if(status != NC_NOERR)
- {
- free_NC_var(varp);
- return status;
- }
-
- status = incr_NC_vararray(&ncp->vars, varp);
- if(status != NC_NOERR)
- {
- free_NC_var(varp);
- return status;
- }
-
- if(varidp != NULL)
- *varidp = (int)ncp->vars.nelems -1; /* varid */
- return NC_NOERR;
-}
-
-
-int
-nc_inq_varid(int ncid, const char *name, int *varid_ptr)
-{
- int status;
- NC *ncp;
- NC_var *varp;
- int varid;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varid = NC_findvar(&ncp->vars, name, &varp);
- if(varid == -1)
- {
- return NC_ENOTVAR;
- }
-
- *varid_ptr = varid;
- return NC_NOERR;
-}
-
-
-int
-nc_inq_var(int ncid,
- int varid,
- char *name,
- nc_type *typep,
- int *ndimsp,
- int *dimids,
- int *nattsp)
-{
- int status;
- NC *ncp;
- NC_var *varp;
- size_t ii;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- if(name != NULL)
- {
- (void) strncpy(name, varp->name->cp, varp->name->nchars);
- name[varp->name->nchars] = 0;
- }
-
- if(typep != 0)
- *typep = varp->type;
- if(ndimsp != 0)
- {
- *ndimsp = (int) varp->ndims;
- }
- if(dimids != 0)
- {
- for(ii = 0; ii < varp->ndims; ii++)
- {
- dimids[ii] = varp->dimids[ii];
- }
- }
- if(nattsp != 0)
- {
- *nattsp = (int) varp->attrs.nelems;
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_inq_varname(int ncid, int varid, char *name)
-{
- int status;
- NC *ncp;
- NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- if(name != NULL)
- {
- (void) strncpy(name, varp->name->cp, varp->name->nchars);
- name[varp->name->nchars] = 0;
- }
-
- return NC_NOERR;
-}
-
-int
-nc_inq_vartype(int ncid, int varid, nc_type *typep)
-{
- int status;
- NC *ncp;
- NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- return NC_ENOTVAR;
-
- if(typep != 0)
- *typep = varp->type;
-
- return NC_NOERR;
-}
-
-int
-nc_inq_varndims(int ncid, int varid, int *ndimsp)
-{
- int status;
- NC *ncp;
- NC_var *varp;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: is this the right error code? */
-
- if(ndimsp != 0)
- {
- *ndimsp = (int) varp->ndims;
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_inq_vardimid(int ncid, int varid, int *dimids)
-{
- int status;
- NC *ncp;
- NC_var *varp;
- size_t ii;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: is this the right error code? */
-
- if(dimids != 0)
- {
- for(ii = 0; ii < varp->ndims; ii++)
- {
- dimids[ii] = varp->dimids[ii];
- }
- }
-
- return NC_NOERR;
-}
-
-
-int
-nc_inq_varnatts(int ncid, int varid, int *nattsp)
-{
- int status;
- NC *ncp;
- NC_var *varp;
-
- if(varid == NC_GLOBAL)
- return nc_inq_natts(ncid, nattsp);
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
- if(varp == NULL)
- return NC_ENOTVAR; /* TODO: is this the right error code? */
-
- if(nattsp != 0)
- {
- *nattsp = (int) varp->attrs.nelems;
- }
-
- return NC_NOERR;
-}
-
-int
-nc_rename_var(int ncid, int varid, const char *newname)
-{
- int status;
- NC *ncp;
- NC_var *varp;
- NC_string *old, *newStr;
- int other;
-
- status = NC_check_id(ncid, &ncp);
- if(status != NC_NOERR)
- return status;
-
- if(NC_readonly(ncp))
- {
- return NC_EPERM;
- }
-
- status = NC_check_name(newname);
- if(status != NC_NOERR)
- return status;
-
- /* check for name in use */
- other = NC_findvar(&ncp->vars, newname, &varp);
- if(other != -1)
- {
- return NC_ENAMEINUSE;
- }
-
- varp = NC_lookupvar(ncp, varid);
- if(varp == NULL)
- {
- /* invalid varid */
- return NC_ENOTVAR; /* TODO: is this the right error code? */
- }
-
- old = varp->name;
- if(NC_indef(ncp))
- {
- newStr = new_NC_string(strlen(newname),newname);
- if(newStr == NULL)
- return(-1);
- varp->name = newStr;
- free_NC_string(old);
- return NC_NOERR;
- }
-
- /* else, not in define mode */
- status = set_NC_string(varp->name, newname);
- if(status != NC_NOERR)
- return status;
-
- set_NC_hdirty(ncp);
-
- if(NC_doHsync(ncp))
- {
- status = NC_sync(ncp);
- if(status != NC_NOERR)
- return status;
- }
-
- return NC_NOERR;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/macros.make.def b/src/diskio/interface/netcdf/netcdf-3.4/src/macros.make.def
deleted file mode 100644
index 9bac86a..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/macros.make.def
+++ /dev/null
@@ -1,88 +0,0 @@
-# $Id: macros.make.def,v 1.3 2005/08/04 20:10:53 svitak Exp $
-
-# The purpose of this file is to contain common make(1) macros.
-# It should be processed by every execution of that utility.
-
-
-# POSIX shell. Shouldn't be necessary -- but is under IRIX 5.3.
-SHELL = /bin/sh
-
-
-# Installation Directories:
-prefix = /opt/netcdf
-exec_prefix = $(prefix)
-INCDIR = $(exec_prefix)/include
-LIBDIR = $(exec_prefix)/lib
-BINDIR = $(exec_prefix)/bin
-MANDIR = $(prefix)/man
-
-
-# Preprocessing:
-M4 = m4
-M4FLAGS = -B10000
-CPP = c89 -E
-CPPFLAGS = $(INCLUDES) $(DEFINES) @CPPFLAGS@
-FPP =
-FPPFLAGS = $(CPPFLAGS)
-CXXCPPFLAGS = $(CPPFLAGS)
-
-
-# Compilation:
-CC = c89
-CXX = CC
-FC = f77
-CFLAGS = -g
-CXXFLAGS = $(CFLAGS) @CXXFLAGS@
-FFLAGS = -g
-CC_MAKEDEPEND = :
-COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
-COMPILE.cxx = $(CXX) -c $(CXXFLAGS) $(CXXCPPFLAGS)
-COMPILE.f = $(FC) -c $(FFLAGS)
-# The following command isn't available on some systems; therefore, the
-# `.F.o' rule is relatively complicated.
-COMPILE.F = $(COMPILE.f)
-
-
-# Linking:
-MATHLIB =
-FLIBS =
-LIBS =
-LINK.c = $(CC) -o $@ $(CFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS)
-LINK.F = $(FC) -o $@ $(FFLAGS) $(FLDFLAGS)
-LINK.f = $(FC) -o $@ $(FFLAGS) $(FLDFLAGS)
-
-
-# NetCDF files:
-NCDUMP = ncdump
-NCGEN = ncgen
-
-
-# Manual pages:
-WHATIS =
-# The following macro should be empty on systems that don't
-# allow users to create their own manual-page indexes.
-MAKEWHATIS_CMD =
-
-
-# Misc. Utilities:
-AR = ar
-ARFLAGS = cru # NB: SunOS 4 doesn't like `-' option prefix
-RANLIB =
-TARFLAGS = -chf
-
-
-# Dummy macros: used only as placeholders to silence GNU make. They are
-# redefined, as necessary, in subdirectory makefiles.
-HEADER = dummy_header
-HEADER1 = dummy_header1
-HEADER2 = dummy_header2
-LIBRARY = dummy_library.a
-MANUAL = dummy_manual
-PROGRAM = dummy_program
-
-
-# Distribution macros:
-FTPDIR = /home/ftp/pub/$(PACKAGE)
-FTPBINDIR =
-VERSION = dummy_version
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/macros.make.in b/src/diskio/interface/netcdf/netcdf-3.4/src/macros.make.in
deleted file mode 100644
index 741cd86..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/macros.make.in
+++ /dev/null
@@ -1,88 +0,0 @@
-# $Id: macros.make.in,v 1.3 2005/08/04 20:10:53 svitak Exp $
-
-# The purpose of this file is to contain common make(1) macros.
-# It should be processed by every execution of that utility.
-
-
-# POSIX shell. Shouldn't be necessary -- but is under IRIX 5.3.
-SHELL = /bin/sh
-
-
-# Installation Directories:
-prefix = @prefix@
-exec_prefix = $(prefix)
-INCDIR = $(exec_prefix)/include
-LIBDIR = $(exec_prefix)/lib
-BINDIR = $(exec_prefix)/bin
-MANDIR = $(prefix)/man
-
-
-# Preprocessing:
-M4 = @M4@
-M4FLAGS = -B10000
-CPP = @CPP@
-CPPFLAGS = $(INCLUDES) $(DEFINES) @CPPFLAGS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
-CXXCPPFLAGS = $(CPPFLAGS)
-
-
-# Compilation:
-CC = @CC@
-CXX = @CXX@
-FC = @FC@
-CFLAGS = @CFLAGS@
-CXXFLAGS = $(CFLAGS) @CXXFLAGS@
-FFLAGS = @FFLAGS@
-CC_MAKEDEPEND = @CC_MAKEDEPEND@
-COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
-COMPILE.cxx = $(CXX) -c $(CXXFLAGS) $(CXXCPPFLAGS)
-COMPILE.f = $(FC) -c $(FFLAGS)
-# The following command isn't available on some systems; therefore, the
-# `.F.o' rule is relatively complicated.
-COMPILE.F = @COMPILE_F@
-
-
-# Linking:
-MATHLIB = @MATHLIB@
-FLIBS = @FLIBS@
-LIBS = @LIBS@
-LINK.c = $(CC) -o $@ $(CFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS)
-LINK.F = $(FC) -o $@ $(FFLAGS) $(FLDFLAGS)
-LINK.f = $(FC) -o $@ $(FFLAGS) $(FLDFLAGS)
-
-
-# NetCDF files:
-NCDUMP = ncdump
-NCGEN = ncgen
-
-
-# Manual pages:
-WHATIS = @WHATIS@
-# The following macro should be empty on systems that don't
-# allow users to create their own manual-page indexes.
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-
-
-# Misc. Utilities:
-AR = @AR@
-ARFLAGS = cru # NB: SunOS 4 doesn't like `-' option prefix
-RANLIB = @RANLIB@
-TARFLAGS = -chf
-
-
-# Dummy macros: used only as placeholders to silence GNU make. They are
-# redefined, as necessary, in subdirectory makefiles.
-HEADER = dummy_header
-HEADER1 = dummy_header1
-HEADER2 = dummy_header2
-LIBRARY = dummy_library.a
-MANUAL = dummy_manual
-PROGRAM = dummy_program
-
-
-# Distribution macros:
-FTPDIR = /home/ftp/pub/$(PACKAGE)
-FTPBINDIR = @FTPBINDIR@
-VERSION = dummy_version
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/macros.xt3.make b/src/diskio/interface/netcdf/netcdf-3.4/src/macros.xt3.make
deleted file mode 100644
index 63da8c7..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/macros.xt3.make
+++ /dev/null
@@ -1,90 +0,0 @@
-# macros.make for the Cray XT3 environment
-
-# $Id: macros.xt3.make,v 1.1 2005/09/29 21:37:21 ghood Exp $
-
-# The purpose of this file is to contain common make(1) macros.
-# It should be processed by every execution of that utility.
-
-
-# POSIX shell. Shouldn't be necessary -- but is under IRIX 5.3.
-SHELL = /bin/sh
-
-
-# Installation Directories:
-prefix = /home/ghood/genesis/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4
-exec_prefix = $(prefix)
-INCDIR = $(exec_prefix)/include
-LIBDIR = $(exec_prefix)/lib
-BINDIR = $(exec_prefix)/bin
-MANDIR = $(prefix)/man
-
-
-# Preprocessing:
-M4 = m4
-M4FLAGS = -B10000
-CPP = cc -E
-CPPFLAGS = $(INCLUDES) $(DEFINES) -DNDEBUG
-FPP = cc -E
-FPPFLAGS =
-CXXCPPFLAGS = $(CPPFLAGS)
-
-
-# Compilation:
-CC = cc
-CXX =
-FC =
-CFLAGS =
-CXXFLAGS = $(CFLAGS)
-FFLAGS = -O
-CC_MAKEDEPEND = false
-COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
-COMPILE.cxx = $(CXX) -c $(CXXFLAGS) $(CXXCPPFLAGS)
-COMPILE.f = $(FC) -c $(FFLAGS)
-# The following command isn't available on some systems; therefore, the
-# `.F.o' rule is relatively complicated.
-COMPILE.F =
-
-
-# Linking:
-MATHLIB = -lm
-FLIBS =
-LIBS =
-LINK.c = $(CC) -o $@ $(CFLAGS) $(LDFLAGS)
-LINK.cxx = $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS)
-LINK.F = $(FC) -o $@ $(FFLAGS) $(FLDFLAGS)
-LINK.f = $(FC) -o $@ $(FFLAGS) $(FLDFLAGS)
-
-
-# NetCDF files:
-NCDUMP = ncdump
-NCGEN = ncgen
-
-
-# Manual pages:
-WHATIS = whatis
-# The following macro should be empty on systems that don't
-# allow users to create their own manual-page indexes.
-MAKEWHATIS_CMD =
-
-
-# Misc. Utilities:
-AR = ar
-ARFLAGS = cru # NB: SunOS 4 doesn't like `-' option prefix
-RANLIB = ranlib
-TARFLAGS = -chf
-
-
-# Dummy macros: used only as placeholders to silence GNU make. They are
-# redefined, as necessary, in subdirectory makefiles.
-HEADER = dummy_header
-HEADER1 = dummy_header1
-HEADER2 = dummy_header2
-LIBRARY = dummy_library.a
-MANUAL = dummy_manual
-PROGRAM = dummy_program
-
-
-# Distribution macros:
-FTPDIR = /home/ftp/pub/$(PACKAGE)
-FTPBINDIR = /home/ftp/pub/binary/dummy_system
-VERSION = dummy_version
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/man/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/man/Makefile
deleted file mode 100644
index 1a9e88b..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/man/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
-#
-# Makefile for netcdf man
-#
-
-include ../macros.make
-
-PACKING_LIST = Makefile \
- netcdf.m4
-
-all:
-
-test:
-
-install:
-
-include ../rules.make
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/man/netcdf.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/man/netcdf.m4
deleted file mode 100644
index 64a4a1f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/man/netcdf.m4
+++ /dev/null
@@ -1,1058 +0,0 @@
-divert(-1)
-
-changequote(<<,>>)
-
-define(<<CODE>>, <<\fB$1\fR>>)
-
-define(<<ARG>>, <<\fI$1\fP>>)
-
-define(<<HEADER_FILE>>,
- <<ifelse(API,C,
- $1.h,
- $1.inc)>>)
-
-define(<<INCLUDE>>,
- <<ifelse(API,C,
- <<#include>> "HEADER_FILE($1)",
- <<<<include>>>> HEADER_FILE($1))>>)
-
-define(<<COMPILER>>,
- <<ifelse(API,C,
- cc,
- f77)>>)
-
-define(<<LANGUAGE>>,
- <<ifelse(API,C,
- C,
- FORTRAN)>>)
-
-define(<<RETSTR>>,
- <<ifelse(API,C,
- const char*,
- character*80)>>)
-
-define(<<FNAME>>,
- <<ifelse(API,C,
- nc_$1,
- nf_$1)>>)
-
-define(<<VOID_ARG>>,
- <<ifelse(API,C,,void)>>)
-
-define(<<MACRO>>,
- <<CODE(ifelse(API,C,
- NC_$1,
- NF_$1))>>)
-
-dnl AQUAL(io, rank)
-define(<<AQUAL>>, <<ifelse(API,C,
- <<ifelse($1, output, , <<ifelse($2, 0, , const )>>)>>)>>)
-
-dnl CTYPE(type)
-define(<<CTYPE>>,
- <<ifelse($1,text,char,
- <<ifelse($1,uchar,unsigned char,
- <<ifelse($1,schar,signed char,
- <<ifelse($1,short,short,
- <<ifelse($1,int,int,
- <<ifelse($1,nc_type,nc_type,
- <<ifelse($1,size_t,size_t,
- <<ifelse($1,ptrdiff_t,ptrdiff_t,
- <<ifelse($1,long,long,
- <<ifelse($1,float,float,
- <<ifelse($1,double,double)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)
-
-dnl CSTAR(io, rank)
-define(<<CSTAR>>, <<ifelse($1,input,,<<ifelse($2,0,*)>>)>>)
-
-dnl FTYPE(type, rank)
-define(<<FTYPE>>,
- <<ifelse($1,text,<<character*ifelse($2,0,1,(*))>>,
- <<ifelse($1,schar,integer*1,
- <<ifelse($1,short,integer*2,
- <<ifelse($1,int,integer,
- <<ifelse($1,nc_type,integer,
- <<ifelse($1,size_t,integer,
- <<ifelse($1,ptrdiff_t,integer,
- <<ifelse($1,long,integer,
- <<ifelse($1,float,real,
- <<ifelse($1,double,doubleprecision)>>)>>)>>)>>)>>)>>)>>)>>)>>)>>)
-
-dnl ATYPE(io,rank,type)
-define(<<ATYPE>>, <<ifelse(API,C,
- <<CTYPE($3)<<>>CSTAR($1,$2)>>,
- <<FTYPE($3,$2)>>)>>)
-
-dnl AID(name, rank, type)
-define(<<AID>>, <<ARG($1)<<>>ifelse(API,C,
- <<ifelse($2,0,,[])>>,
- <<ifelse($3,text,,<<ifelse($2,0,,(1))>>)>>)>>)
-
-dnl ADECL(io, rank, type, name)
-define(<<ADECL>>, <<AQUAL($1,$2)ATYPE($1,$2,$3) AID($4,$2,$3)>>)
-
-define(<<ITEXT>>, <<ADECL(input,0,text,$1)>>)
-define(<<ITEXTV>>, <<ADECL(input,1,text,$1)>>)
-define(<<OTEXT>>, <<ADECL(output,0,text,$1)>>)
-define(<<OTEXTV>>, <<ADECL(output,1,text,$1)>>)
-
-define(<<IUCHAR>>, <<ADECL(input,0,uchar,$1)>>)
-define(<<IUCHARV>>, <<ADECL(input,1,uchar,$1)>>)
-define(<<OUCHAR>>, <<ADECL(output,0,uchar,$1)>>)
-define(<<OUCHARV>>, <<ADECL(output,1,uchar,$1)>>)
-
-define(<<ISCHAR>>, <<ADECL(input,0,schar,$1)>>)
-define(<<ISCHARV>>, <<ADECL(input,1,schar,$1)>>)
-define(<<OSCHAR>>, <<ADECL(output,0,schar,$1)>>)
-define(<<OSCHARV>>, <<ADECL(output,1,schar,$1)>>)
-
-define(<<ISHORT>>, <<ADECL(input,0,short,$1)>>)
-define(<<ISHORTV>>, <<ADECL(input,1,short,$1)>>)
-define(<<OSHORT>>, <<ADECL(output,0,short,$1)>>)
-define(<<OSHORTV>>, <<ADECL(output,1,short,$1)>>)
-
-define(<<IINT>>, <<ADECL(input,0,int,$1)>>)
-define(<<IINTV>>, <<ADECL(input,1,int,$1)>>)
-define(<<OINT>>, <<ADECL(output,0,int,$1)>>)
-define(<<OINTV>>, <<ADECL(output,1,int,$1)>>)
-
-define(<<INCTYPE>>, <<ADECL(input,0,nc_type,$1)>>)
-define(<<INCTYPEV>>, <<ADECL(input,1,nc_type,$1)>>)
-define(<<ONCTYPE>>, <<ADECL(output,0,nc_type,$1)>>)
-define(<<ONCTYPEV>>, <<ADECL(output,1,nc_type,$1)>>)
-
-define(<<ISIZET>>, <<ADECL(input,0,size_t,$1)>>)
-define(<<ISIZETV>>, <<ADECL(input,1,size_t,$1)>>)
-define(<<OSIZET>>, <<ADECL(output,0,size_t,$1)>>)
-define(<<OSIZETV>>, <<ADECL(output,1,size_t,$1)>>)
-
-define(<<IPTRDIFFT>>, <<ADECL(input,0,ptrdiff_t,$1)>>)
-define(<<IPTRDIFFTV>>, <<ADECL(input,1,ptrdiff_t,$1)>>)
-define(<<OPTRDIFFT>>, <<ADECL(output,0,ptrdiff_t,$1)>>)
-define(<<OPTRDIFFTV>>, <<ADECL(output,1,ptrdiff_t,$1)>>)
-
-define(<<ILONG>>, <<ADECL(input,0,long,$1)>>)
-define(<<ILONGV>>, <<ADECL(input,1,long,$1)>>)
-define(<<OLONG>>, <<ADECL(output,0,long,$1)>>)
-define(<<OLONGV>>, <<ADECL(output,1,long,$1)>>)
-
-define(<<IFLOAT>>, <<ADECL(input,0,float,$1)>>)
-define(<<IFLOATV>>, <<ADECL(input,1,float,$1)>>)
-define(<<OFLOAT>>, <<ADECL(output,0,float,$1)>>)
-define(<<OFLOATV>>, <<ADECL(output,1,float,$1)>>)
-
-define(<<IDOUBLE>>, <<ADECL(input,0,double,$1)>>)
-define(<<IDOUBLEV>>, <<ADECL(input,1,double,$1)>>)
-define(<<ODOUBLE>>, <<ADECL(output,0,double,$1)>>)
-define(<<ODOUBLEV>>, <<ADECL(output,1,double,$1)>>)
-
-dnl CCOMP(type)
-define(<<CCOMP>>,
- <<ifelse($1,text,text,
- <<ifelse($1,uchar,uchar,
- <<ifelse($1,schar,schar,
- <<ifelse($1,short,short,
- <<ifelse($1,int,int,
- <<ifelse($1,long,long,
- <<ifelse($1,float,float,
- <<ifelse($1,double,double)>>)>>)>>)>>)>>)>>)>>)>>)
-
-dnl FCOMP(type)
-define(<<FCOMP>>,
- <<ifelse($1,text,text,
- <<ifelse($1,schar,int1,
- <<ifelse($1,short,int2,
- <<ifelse($1,int,int,
- <<ifelse($1,float,real,
- <<ifelse($1,double,double)>>)>>)>>)>>)>>)>>)
-
-dnl COMP(type)
-define(<<COMP>>, <<ifelse(API,C,<<CCOMP($1)>>,<<FCOMP($1)>>)>>)
-
-define(<<FDECL_TYPE>>,
- <<ifelse(API,C,
- int,
- integer function)>>)
-
-dnl DECL(return-type, name, argument-list)
-define(<<DECL>>, <<CODE($1 FNAME($2)$3)>>)
-
-dnl FDECL(name, argument-list)
-define(<<FDECL>>, <<DECL(FDECL_TYPE, $1, $2)>>)
-
-dnl IODECL(name, type, argument-list)
-define(<<IODECL>>, <<FDECL($1_<<>>COMP($2), $3)>>)
-
-dnl FREF(name)
-define(<<FREF>>, <<CODE(FNAME($1)(\|))>>)
-
-dnl FOLD(cname, fname)
-define(<<FOLD>>, <<CODE(ifelse(API,C, nc$1, nc$2)(\|))>>)
-
-dnl Function Input Arguments:
-define(<<IATTNUM>>, <<IINT(attnum)>>)
-define(<<ICMODE>>, <<IINT(cmode)>>)
-define(<<ICOUNT>>, <<ISIZETV(count)>>)
-define(<<IDIMID>>, <<IINT(dimid)>>)
-define(<<IDIMIDS>>, <<IINTV(dimids)>>)
-define(<<IFILLMODE>>, <<IINT(fillmode)>>)
-define(<<IINDEX>>, <<ISIZETV(index)>>)
-define(<<ILEN>>, <<ISIZET(<<len>>)>>)
-define(<<IMAP>>, <<IPTRDIFFTV(imap)>>)
-define(<<IMODE>>, <<IINT(mode)>>)
-define(<<INAME>>, <<ITEXTV(name)>>)
-define(<<INCID>>, <<IINT(ncid)>>)
-define(<<INCIDIN>>, <<IINT(ncid_in)>>)
-define(<<INCIDOUT>>, <<IINT(ncid_out)>>)
-define(<<INDIMS>>, <<IINT(ndims)>>)
-define(<<INEWNAME>>, <<ITEXTV(newname)>>)
-define(<<IPATH>>, ITEXTV(path))
-define(<<ISTART>>, <<ISIZETV(start)>>)
-define(<<ISTATUS>>, <<IINT(status)>>)
-define(<<ISTRIDE>>, <<ISIZETV(stride)>>)
-define(<<IVARID>>, <<IINT(varid)>>)
-define(<<IVARIDIN>>, <<IINT(varid_in)>>)
-define(<<IVARIDOUT>>, <<IINT(varid_out)>>)
-define(<<IXTYPE>>, <<INCTYPE(xtype)>>)
-
-dnl Function Output Arguments:
-define(<<OATTNUM>>, <<OINT(attnum)>>)
-define(<<ODIMID>>, <<OINT(dimid)>>)
-define(<<ODIMIDS>>, <<OINTV(dimids)>>)
-define(<<OLEN>>, <<OSIZET(<<len>>)>>)
-define(<<ONAME>>, <<OTEXTV(name)>>)
-define(<<ONATTS>>, <<OINT(natts)>>)
-define(<<ONCID>>, <<OINT(ncid)>>)
-define(<<ONDIMS>>, <<OINT(ndims)>>)
-define(<<ONVARS>>, <<OINT(nvars)>>)
-define(<<OOLDFILLMODE>>, <<OINT(old_fillemode)>>)
-define(<<OVARID>>, <<OINT(varid)>>)
-define(<<OUNLIMDIMID>>, <<OINT(unlimdimid)>>)
-define(<<OXTYPE>>, <<ONCTYPE(xtype)>>)
-
-dnl Argument References:
-define(<<ATTNUM>>, <<ARG(attnum)>>)
-define(<<COUNT>>, <<ARG(count)>>)
-define(<<DIMID>>, <<ARG(dimid)>>)
-define(<<DIMIDS>>, <<ARG(dimids)>>)
-define(<<FILLMODE>>, <<ARG(fillmode)>>)
-define(<<IN>>, <<ARG(in)>>)
-define(<<INDEX>>, <<ARG(index)>>)
-define(<<LEN>>, <<ARG(<<len>>)>>)
-define(<<IMAP>>, <<ARG(imap)>>)
-define(<<NAME>>, <<ARG(name)>>)
-define(<<NATTS>>, <<ARG(natts)>>)
-define(<<NCID>>, <<ARG(ncid)>>)
-define(<<NCIDIN>>, <<ARG(ncid_in)>>)
-define(<<NCIDOUT>>, <<ARG(ncid_out)>>)
-define(<<NDIMS>>, <<ARG(ndims)>>)
-define(<<NEWNAME>>, <<ARG(newname)>>)
-define(<<NULL>>, <<CODE(<<<<NULL>>>>)>>)
-define(<<NVARS>>, <<ARG(nvars)>>)
-define(<<NVATTS>>, <<ARG(nvatts)>>)
-define(<<OLDFILLMODE>>, <<ARG(old_fillmode)>>)
-define(<<OUT>>, <<ARG(out)>>)
-define(<<START>>, <<ARG(start)>>)
-define(<<STRIDE>>, <<ARG(stride)>>)
-define(<<UNLIMDIMID>>, <<ARG(unlimdimid)>>)
-define(<<VARID>>, <<ARG(varid)>>)
-define(<<VARIDIN>>, <<ARG(varid_in)>>)
-define(<<VARIDOUT>>, <<ARG(varid_out)>>)
-define(<<XTYPE>>, <<ARG(xtype)>>)
-
-define(<<UPCASE>>,
-<<translit($1,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ)>>)
-
-dnl Variable "Put" Functions:
-define(<<VOUT>>, <<I<<>>UPCASE($1)<<>>ifelse($2,1,,V)(ifelse($2,1,*)out)>>)
-define(<<VPUT>>, <<IODECL(put_var$1, $2, (INCID(), IVARID()$3, VOUT($2,$1)))>>)
-define(<<PUT_VAR>>, <<VPUT(,$1)>>)
-define(<<PUT_VAR1>>,<<VPUT(1,$1,<<, IINDEX()>>)>>)
-define(<<PUT_VARA>>,<<VPUT(a,$1,<<, ISTART(), ICOUNT()>>)>>)
-define(<<PUT_VARS>>,<<VPUT(s,$1,<<, ISTART(), ICOUNT(), ISTRIDE()>>)>>)
-define(<<PUT_VARM>>,<<VPUT(m,$1,<<, ISTART(), ICOUNT(), ISTRIDE(), IMAP()>>)>>)
-
-dnl Variable "Get" Functions:
-define(<<VIN>>, <<O<<>>UPCASE($1)<<>>ifelse($2,1,,V)(in)>>)
-define(<<VGET>>, <<IODECL(get_var$1, $2, (INCID(), IVARID()$3, VIN($2,$1)))>>)
-define(<<GET_VAR>>, <<VGET(,$1)>>)
-define(<<GET_VAR1>>,<<VGET(1,$1,<<, IINDEX()>>)>>)
-define(<<GET_VARA>>,<<VGET(a,$1,<<, ISTART(), ICOUNT()>>)>>)
-define(<<GET_VARS>>,<<VGET(s,$1,<<, ISTART(), ICOUNT(), ISTRIDE()>>)>>)
-define(<<GET_VARM>>,<<VGET(m,$1,<<, ISTART(), ICOUNT(), ISTRIDE(), IMAP()>>)>>)
-
-dnl Attribute "Put" Functions:
-define(<<AOUT>>, <<I<<>>UPCASE($1)<<>>V(out)>>)
-define(<<APUT>>,<<IODECL(put_att,$1,(INCID(), IVARID(), INAME(), IXTYPE(), ILEN(), AOUT($1)))>>)
-
-dnl Attribute "Get" Functions:
-define(<<AIN>>, <<O<<>>UPCASE($1)<<>>V(in)>>)
-define(<<AGET>>,<<IODECL(get_att,$1,(INCID(), IVARID(), INAME(), AIN($1)))>>)
-
-dnl Function Family Listing:
-define(<<FUNC_FAMILY>>,
-<<.HP
-$1(text)
-ifelse(API,C,
-<<.HP
-$1(uchar)>>)
-.HP
-$1(schar)
-.HP
-$1(short)
-.HP
-$1(int)
-ifelse(API,C,
-<<.HP
-$1(long)>>)
-.HP
-$1(float)
-.HP
-$1(double)>>)
-
-divert(0)dnl
-.TH NETCDF 3 "18 April 1997" "Printed: \n(yr.\n(mo.\n(dy" "UNIDATA LIBRARY FUNCTIONS"
-.SH N<<>>AME
-netcdf \- Unidata Network Common Data Form (netCDF) library, version 3 interface
-.SH SYNOPSIS
-.ft B
-.na
-.nh
-INCLUDE(netcdf)
-.sp
-ifelse(API,C,,
-.SS Most Systems:)
-COMPILER() ... -lnetcdf
-ifelse(API,C,,
-.sp
-.SS CRAY PVP Systems:
-f90 -dp -i64 ... -lnetcdf
-)
-.ad
-.hy
-.SH "LIBRARY VERSION"
-.LP
-This document describes version 3 of Unidata netCDF data-access interface
-for the LANGUAGE() programming language.
-.HP
-DECL(RETSTR(), inq_libvers, (VOID_ARG))
-.sp
-Returns a string identifying the version of the netCDF library, and
-when it was built, like: "3.1a of Aug 22 1996 12:57:47 $".
-.LP
-The RCS \fBident(1)\fP command will find a string like
-"$\|Id: @\|(#) netcdf library version 3.1a of Sep 6 1996 15:56:26 $"
-in the library. The SCCS \fBwhat(1)\fP command will find a string like
-"netcdf library version 3.1a of Aug 23 1996 16:07:40 $".
-.SH "RETURN VALUES"
-.LP
-All netCDF functions (except
-FREF(inq_libvers) and FREF(strerror)) return an integer status.
-This behavior replaces the
-ifelse(API,C, <<CODE(ncerr()) function>>, <<CODE(rcode)>> argument)
-used in previous versions of the library.
-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
-ifelse(API,C, system <<<<include>>>> file <errno.h> and in )<<>>dnl
-ifelse(API,C,")HEADER_FILE(netcdf)<<>>ifelse(API,C,").
-.HP
-DECL(RETSTR(), strerror, (ISTATUS()))
-.sp
-Returns a string textual translation of the \fIstatus\fP
-value, like "Attribute or variable name contains illegal characters"
-or "No such file or directory".
-.SH "FUNCTION DESCRIPTIONS"
-.HP
-FDECL(create, (IPATH(), ICMODE(),
-ONCID()))
-.sp
-(Corresponds to FOLD(create, cre) in version 2)
-.sp
-Creates a new netCDF dataset at ARG(path),
-returning a netCDF ID in ARG(ncid).
-The argument ARG(cmode) may <<include>> the bitwise-or
-of the following flags:
-MACRO(NOCLOBBER)
-to protect existing datasets (default
-silently blows them away),
-MACRO(SHARE)
-for synchronous dataset updates
-(default is to buffer accesses), and
-MACRO(LOCK)
-(not yet implemented).
-When a netCDF dataset is created, is is opened
-MACRO(WRITE).
-The new netCDF dataset is in <<define>> mode.
-.HP
-FDECL(open, (IPATH(), IMODE(), ONCID()))
-.sp
-(Corresponds to FOLD(open, opn) in version 2)
-.sp
-Opens a existing netCDF dataset at ARG(path)
-returning a netCDF ID
-in ARG(ncid).
-The type of access is described by the ARG(mode) parameter,
-which may <<include>> the bitwise-or
-of the following flags:
-MACRO(WRITE)
-for read-write access (default
-read-only),
-MACRO(SHARE)
-for synchronous dataset updates (default is
-to buffer accesses), and
-MACRO(LOCK)
-(not yet implemented).
-.HP
-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
-attributes can be deleted.
-.HP
-FDECL(endef, (INCID()))
-.sp
-(Corresponds to FOLD(endef, endf) in version 2)
-.sp
-Takes an open netCDF dataset out of <<define>> mode.
-The changes made to the netCDF dataset
-while it was in <<define>> mode are checked and committed to disk if no
-problems occurred. Some data values may be written as well,
-see "VARIABLE PREFILLING" below.
-After a successful call, variable data can be read or written to the dataset.
-.HP
-FDECL(sync, (INCID()))
-.sp
-(Corresponds to FOLD(sync, snc) in version 2)
-.sp
-Unless the
-MACRO(SHARE)
-bit is set in
-FREF(open) or FREF(create),
-accesses to the underlying netCDF dataset are
-buffered by the library. This function synchronizes the state of
-the underlying dataset and the library.
-This is done automatically by
-FREF(close) and FREF(endef).
-.HP
-FDECL(abort, (INCID()))
-.sp
-(Corresponds to FOLD(abort, abor) in version 2)
-.sp
-You don't need to call this function.
-This function is called automatically by
-FREF(close)
-if the netCDF was in <<define>> mode and something goes wrong with the commit.
-If the netCDF dataset isn't in <<define>> mode, then this function is equivalent to
-FREF(close).
-If it is called after
-FREF(redef),
-but before
-FREF(enddef),
-the new definitions are not committed and the dataset is closed.
-If it is called after
-FREF(create)
-but before
-FREF(enddef),
-the dataset disappears.
-.HP
-FDECL(close, (INCID()))
-.sp
-(Corresponds to
-FOLD(close, clos) in version 2)
-.sp
-Closes an open netCDF dataset.
-If the dataset is in <<define>> mode,
-FREF(endef)
-will be called before closing.
-After a dataset is closed, its ID may be reassigned to another dataset.
-.HP
-FDECL(inq, (INCID(), ONDIMS(), ONVARS(),
-ONATTS(), OUNLIMDIMID()))
-.HP
-FDECL(inq_ndims, (INCID(), ONDIMS()))
-.HP
-FDECL(inq_nvars, (INCID(), ONVARS()))
-.HP
-FDECL(inq_natts, (INCID(), ONATTS()))
-.HP
-FDECL(inq_unlimdim, (INCID(), OUNLIMDIMID()))
-.sp
-(Replace FOLD(inquire, inq) in version 2)
-.sp
-Use these functions to find out what is in a netCDF dataset.
-Upon successful return,
-NDIMS() will contain the
-number of dimensions defined for this netCDF dataset,
-NVARS() will contain the number of variables,
-NATTS() will contain the number of attributes, and
-UNLIMDIMID() will contain the
-dimension ID of the unlimited dimension if one exists, or
-ifelse(API,C, <<-1>>, <<0>>) otherwise.
-ifelse(API,C,
-<<If any of the
-return parameters is a NULL() pointer, then the corresponding information
-will not be returned; hence, no space need be allocated for it.>>)
-.HP
-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
-in <<define>> mode.
-NAME() is the dimension name.
-ifelse(API,C,dnl
-<<If DIMID() is not a NULL() pointer then upon successful completion >>)<<>>dnl
-DIMID() will contain the dimension ID of the newly created dimension.
-.HP
-FDECL(inq_dimid, (INCID(), INAME(), ODIMID()))
-.sp
-(Corresponds to FOLD(dimid, did) in version 2)
-.sp
-Given a dimension name, returns the ID of a netCDF dimension in DIMID().
-.HP
-FDECL(inq_dim, (INCID(), IDIMID(), ONAME(), OLEN()))
-.HP
-FDECL(inq_dimname, (INCID(), IDIMID(), ONAME()))
-.HP
-FDECL(inq_dimlen, (INCID(), IDIMID(), OLEN()))
-.sp
-(Replace FOLD(diminq, dinq) in version 2)
-.sp
-Use these functions to find out about a dimension.
-ifelse(API,C,
-<<If either the NAME()
-argument or LEN() argument is a NULL() pointer, then
-the associated information will not be returned. Otherwise,>>)
-NAME() should be big enough (MACRO(MAX_NAME))
-to hold the dimension name as the name will be copied into your storage.
-The length return parameter, LEN()
-will contain the size of the dimension.
-For the unlimited dimension, the returned length is the current
-maximum value used for writing into any of the variables which use
-the dimension.
-.HP
-FDECL(rename_dim, (INCID(), IDIMID(), INAME()))
-.sp
-(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
-<<define>> mode.
-You cannot rename a dimension to have the same name as another dimension.
-.HP
-FDECL(def_var, (INCID(), INAME(), IXTYPE(), INDIMS(), IDIMIDS(), OVARID()))
-.sp
-(Corresponds to FOLD(vardef, vdef) in version 2)
-.sp
-Adds a new variable to a netCDF dataset. The netCDF must be in <<define>> mode.
-ifelse(API,C, <<If not NULL(), then >>)dnl
-VARID() will be set to the netCDF variable ID.
-.HP
-FDECL(inq_varid, (INCID(), INAME(), OVARID()))
-.sp
-(Corresponds to FOLD(varid, vid) in version 2)
-.sp
-Returns the ID of a netCDF variable in VARID() given its name.
-.HP
-FDECL(inq_var, (INCID(), IVARID(), ONAME(), OXTYPE(), ONDIMS(), ODIMIDS(),
-ONATTS()))
-.HP
-FDECL(inq_varname, (INCID(), IVARID(), ONAME()))
-.HP
-FDECL(inq_vartype, (INCID(), IVARID(), OXTYPE()))
-.HP
-FDECL(inq_varndims, (INCID(), IVARID(), ONDIMS()))
-.HP
-FDECL(inq_vardimid, (INCID(), IVARID(), ODIMIDS()))
-.HP
-FDECL(inq_varnatts, (INCID(), IVARID(), ONATTS()))
-.sp
-(Replace FOLD(varinq, vinq) in version 2)
-.sp
-Returns information about a netCDF variable, given its ID.
-ifelse(API,C,
-<<If any of the
-return parameters (NAME(), XTYPE(), NDIMS(), DIMIDS(), or
-NATTS()) is a NULL() pointer, then the corresponding information
-will not be returned; hence, no space need be allocated for it.>>)
-.HP
-FDECL(rename_var, (INCID(), IVARID(), INAME()))
-.sp
-(Corresponds to FOLD(varrename, vren) in version 2)
-.sp
-Changes the name of a netCDF variable.
-If the new name is longer than the old name, the netCDF must be in <<define>> mode.
-You cannot rename a variable to have the name of any existing variable.
-FUNC_FAMILY(<<PUT_VAR>>)
-.sp
-(Replace FOLD(varput, vpt) in version 2)
-.sp
-Writes an entire netCDF variable (i.e. all the values).
-The netCDF dataset must be open and in data mode. The type of the data is
-specified in the function name, and it is converted to the external type
-of the specified variable, if possible, otherwise an
-MACRO(ERANGE) error is returned.
-FUNC_FAMILY(<<GET_VAR>>)
-.sp
-(Replace FOLD(varget, vgt) in version 2)
-.sp
-Reads an entire netCDF variable (i.e. all the values).
-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.
-FUNC_FAMILY(<<PUT_VAR1>>)
-.sp
-(Replace FOLD(varput1, vpt1) in version 2)
-.sp
-Puts a single data value into a variable at the position INDEX() of an
-open netCDF dataset that is in data mode. The type of the data is
-specified in the function name, and it is converted to the external type
-of the specified variable, if possible, otherwise an MACRO(ERANGE)
-error is returned.
-FUNC_FAMILY(<<GET_VAR1>>)
-.sp
-(Replace FOLD(varget1, vgt1) in version 2)
-.sp
-Gets a single data value from a variable at the position INDEX()
-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.
-FUNC_FAMILY(<<PUT_VARA>>)
-.sp
-(Replace FOLD(varput, vpt) in version 2)
-.sp
-Writes an array section of values into a netCDF variable of an open
-netCDF dataset, which must be in data mode. The array section is specified
-by the START() and COUNT() vectors, which give the starting <<index>>
-and count of values along each dimension of the specified variable.
-The type of the data is
-specified in the function name and is converted to the external type
-of the specified variable, if possible, otherwise an MACRO(ERANGE)
-error is returned.
-FUNC_FAMILY(<<GET_VARA>>)
-.sp
-(Corresponds to FOLD(varget, vgt) in version 2)
-.sp
-Reads an array section of values from a netCDF variable of an open
-netCDF dataset, which must be in data mode. The array section is specified
-by the START() and COUNT() vectors, which give the starting <<index>>
-and count of values along each dimension of the specified variable.
-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.
-FUNC_FAMILY(<<PUT_VARS>>)
-.sp
-(Corresponds to FOLD(varputg, vptg) in version 2)
-.sp
-These functions are used for \fIstrided output\fP, which is like the
-array section output described above, except that
-the sampling stride (the interval between accessed values) is
-specified for each dimension.
-For an explanation of the sampling stride
-vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-FUNC_FAMILY(<<GET_VARS>>)
-.sp
-(Corresponds to FOLD(vargetg, vgtg) in version 2)
-.sp
-These functions are used for \fIstrided input\fP, which is like the
-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
-vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-FUNC_FAMILY(<<PUT_VARM>>)
-.sp
-(Corresponds to FOLD(varputg, vptg) in version 2)
-.sp
-These functions are used for \fImapped output\fP, which is like
-strided output described above, except that an additional <<index>> mapping
-vector is provided to specify the in-memory arrangement of the data
-values.
-For an explanation of the <<index>>
-mapping vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-FUNC_FAMILY(<<GET_VARM>>)
-.sp
-(Corresponds to FOLD(vargetg, vgtg) in version 2)
-.sp
-These functions are used for \fImapped input\fP, which is like
-strided input described above, except that an additional <<index>> mapping
-vector is provided to specify the in-memory arrangement of the data
-values.
-For an explanation of the <<index>>
-mapping vector, see COMMON ARGUMENTS DESCRIPTIONS below.
-FUNC_FAMILY(<<APUT>>)
-.sp
-(Replace FOLD(attput, apt) in version 2)
-.sp
-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.
-If the attribute is new, or if the space required to
-store the attribute value is greater than before,
-the netCDF dataset must be in <<define>> mode.
-The parameter LEN() is the number of values from OUT() to transfer.
-It is often one, except that for
-FREF(put_att_text) it will usually be
-ifelse(API,C, <<CODE(strlen(OUT())).>>, <<CODE(len_trim(OUT())).>>)
-.sp
-For these functions, the type component of the function name refers to
-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
-external type.
-.HP
-FDECL(inq_attname, (INCID(), IVARID(), IATTNUM(), ONAME()))
-.sp
-(Corresponds to FOLD(attname, anam) in version 2)
-.sp
-Gets the
-name of an attribute, given its variable ID and attribute number.
-This function is useful in generic applications that
-need to get the names of all the attributes associated with a variable,
-since attributes are accessed by name rather than number in all other
-attribute functions. The number of an attribute is more volatile than
-the name, since it can change when other attributes of the same variable
-are deleted. The attributes for each variable are numbered
-from ifelse(API,C,0,1) (the first attribute) to
-NVATTS()<<>>ifelse(API,C,-1),
-where NVATTS() is
-the number of attributes for the variable, as returned from a call to
-FREF(inq_varnatts).
-ifelse(API,C,
-<<If the NAME() parameter is a NULL() pointer, no name will be
-returned and no space need be allocated.>>)
-.HP
-FDECL(inq_att, (INCID(), IVARID(), INAME(), OXTYPE(), OLEN()))
-.HP
-FDECL(inq_attid, (INCID(), IVARID(), INAME(), OATTNUM()))
-.HP
-FDECL(inq_atttype, (INCID(), IVARID(), INAME(), OXTYPE()))
-.HP
-FDECL(inq_attlen, (INCID(), IVARID(), INAME(), OLEN()))
-.sp
-(Corresponds to FOLD(attinq, ainq) in version 2)
-.sp
-These functions return information about a netCDF attribute,
-given its variable ID and name. The information returned is the
-external type in XTYPE()
-and the number of elements in the attribute as LEN().
-ifelse(API,C,
-<<If any of the return arguments is a NULL() pointer,
-the specified information will not be returned.>>)
-.HP
-FDECL(copy_att, (INCID(), IVARIDIN(), INAME(), INCIDOUT(), IVARIDOUT()))
-.sp
-(Corresponds to FOLD(attcopy, acpy) in version 2)
-.sp
-Copies an
-attribute from one netCDF dataset to another. It can also be used to
-copy an attribute from one variable to another within the same netCDF.
-NCIDIN() is the netCDF ID of an input netCDF dataset from which the
-attribute will be copied.
-VARIDIN()
-is the ID of the variable in the input netCDF dataset from which the
-attribute will be copied, or MACRO(GLOBAL)
-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
-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
-copied does not already exist for the target variable, or if it would
-cause an existing target attribute to grow.
-VARIDOUT()
-is the ID of the variable in the output netCDF dataset to which the attribute will
-be copied, or MACRO(GLOBAL) to copy to a global attribute.
-.HP
-FDECL(rename_att, (INCID(), IVARID(), INAME(), INEWNAME()))
-.sp
-(Corresponds to FOLD(attrename, aren)
-.sp
-Changes the
-name of an attribute. If the new name is longer than the original name,
-the netCDF must be in <<define>> mode. You cannot rename an attribute to
-have the same name as another attribute of the same variable.
-NAME() is the original attribute name.
-NEWNAME()
-is the new name to be assigned to the specified attribute. If the new name
-is longer than the old name, the netCDF dataset must be in <<define>> mode.
-.HP
-FDECL(del_att, (INCID(), IVARID(), INAME()))
-.sp
-(Corresponds to FOLD(attdel, adel) in version 2)
-.sp
-Deletes an attribute from a netCDF dataset. The dataset must be in
-<<define>> mode.
-FUNC_FAMILY(<<AGET>>)
-.sp
-(Replace FOLD(attget, agt) in version 2)
-.sp
-Gets the value(s) of a netCDF attribute, given its
-variable ID and name. Converts from the external type to the type
-specified in
-the function name, if possible, otherwise returns an MACRO(ERANGE)
-error.
-All elements of the vector of attribute
-values are returned, so you must allocate enough space to hold
-them. If you don't know how much space to reserve, call
-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
-"FUNCTION DESCRIPTIONS" section.
-.TP
-INCID()
-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.
-It shall begin with an alphabetic character, followed by
-zero or more alphanumeric characters including the underscore
-(`_') or hyphen (`-'). Case is significant.
-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
-ifelse(API,C,(excluding the terminating 0)) is MACRO(MAX_NAME).
-Names that begin with an underscore (`_') are reserved for use
-by the netCDF interface.
-.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(FLOAT), or MACRO(DOUBLE).
-These are used to specify 8-bit integers,
-characters, 16-bit integers, 32-bit integers, 32-bit IEEE floating point
-numbers, and 64-bit IEEE floating-point numbers, respectively.
-ifelse(API,C,
-<<(MACRO(INT) corresponds to MACRO(LONG) in version 2, to specify a
-32-bit integer).>>)
-.TP
-ODIMIDS()
-is a vector of dimension ID's and defines the shape of a netCDF variable.
-The size of the vector shall be greater than or equal to the
-rank (i.e. the number of dimensions) of the variable (NDIMS()).
-The vector shall be ordered by the speed with which a dimension varies:
-DIMIDS()<<>>ifelse(API,C,<<[NDIMS()-1]>>,<<(1)>>)
-shall be the dimension ID of the most rapidly
-varying dimension and
-DIMIDS()<<>>ifelse(API,C,<<[0]>>,<<(NDIMS())>>)
-shall be the dimension ID of the most slowly
-varying dimension.
-The maximum possible number of
-dimensions for a variable is given by the symbolic constant
-MACRO(MAX_VAR_DIMS).
-.TP
-IDIMID()
-is the ID of a netCDF dimension.
-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
-MACRO(MAX_VAR_DIMS).
-.TP
-IVARID()
-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
-ifelse(API,C,non-negative,positive)
-integers beginning with ifelse(API,C,0,1).
-.TP
-ONATTS()
-is the number of global attributes in a netCDF dataset for the
-FREF(inquire)
-function or the number
-of attributes associated with a netCDF variable for the
-FREF(varinq)
-function.
-.TP
-IINDEX()
-specifies the indicial coordinates of the netCDF data value to be accessed.
-The indices start at ifelse(API,C,0,1);
-thus, for example, the first data value of a
-two-dimensional variable is ifelse(API,C,(0,0),(1,1)).
-The size of the vector shall be at least the rank of the associated
-netCDF variable and its elements shall correspond, in order, to the
-variable's dimensions.
-.TP
-ISTART()
-specifies the starting point
-for accessing a netCDF variable's data values
-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
-value of a variable is ifelse(API,C,(0, 0, ..., 0),(1, 1, ..., 1)).
-The size of the vector shall be at least the rank of the associated
-netCDF variable and its elements shall correspond, in order, to the
-variable's dimensions.
-.TP
-ICOUNT()
-specifies the number of indices selected along each dimension of the
-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
-the interaction of the
-three does not attempt to access an invalid data co-ordinate.
-The elements of the
-COUNT() vector correspond, in order, to the variable's dimensions.
-.TP
-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)
-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
-dimension, a value of 2 selects every other element, etc.).
-ifelse(API,C,<<A NULL() stride argument is treated as (1, 1, ... , 1).>>)
-.TP
-IMAP()
-specifies the mapping between the dimensions of a netCDF variable and
-the in-memory structure of the internal data array. The elements of
-the <<index>> mapping vector correspond, in order, to the netCDF variable's
-dimensions (ARG(imap)<<>>ifelse(API,C,[0],<<(1)>>) gives the distance
-between elements of the internal array corresponding to the most
-ifelse(API,C,slowly,rapidly) varying dimension of the netCDF variable).
-Distances between elements are specified in type-independent units of
-elements (the distance between internal elements that occupy adjacent
-memory locations is 1 and not the element's byte-length as in netCDF 2).
-ifelse(API,C,<<A NULL() pointer means the memory-resident values have
-the same structure as the associated netCDF variable.>>)
-.SH "VARIABLE PREFILLING"
-.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
-variable. This is done when FREF(endef)
-is called. The
-fill-value for a variable may be changed from the default value by
-defining the attribute `CODE(_FillValue)' for the variable. This
-attribute must have the same type as the variable and be of length one.
-.LP
-Variables with an unlimited dimension are also prefilled, but on
-an `as needed' basis. For example, if the first write of such a
-variable is to position 5, then
-positions
-ifelse(API,C,0 through 4, 1 through 4)
-(and no others)
-would be set to the fill-value at the same time.
-.LP
-This default prefilling of data values may be disabled by
-or'ing the
-MACRO(NOFILL)
-flag into the mode parameter of FREF(open) or FREF(create),
-or, by calling the function FREF(set_fill)
-with the argument MACRO(NOFILL).
-For variables that do not use the unlimited dimension,
-this call must
-be made before
-FREF(endef).
-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
-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.
-Allowing this to change affects the degree to which
-a program can be effectively parallelized.
-Given all of this, we state that the use
-of this feature may not be available (or even needed) in future
-releases. Programmers are cautioned against heavy reliance upon this
-feature.
-.HP
-FDECL(setfill, (INCID(), IFILLMODE(), OOLDFILLMODE()))
-ifelse(API,C,
-<<.sp
-(Corresponds to FOLD(setfill) in version 2)>>)
-.sp
-Determines whether or not variable prefilling will be done (see
-above).
-The netCDF dataset shall be writable.
-FILLMODE() is either MACRO(FILL)
-to enable prefilling (the
-default) or MACRO(NOFILL)
-to disable prefilling.
-This function returns the previous setting in OLDFILLMODE().
-.SH "ENVIRONMENT VARIABLES"
-.TP 4
-.B NETCDF_FFIOSPEC
-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
-I/O.
-The default specification is \fBbufa:336:2\fP.
-See UNICOS Flexible File I/O for more information.
-.SH "MAILING-LISTS"
-.LP
-Both a mailing list and a digest are available for
-discussion of the netCDF interface and announcements about netCDF bugs,
-fixes, and enhancements.
-To begin or change your subscription to either the mailing-list or the
-digest, send one of the following in the body (not
-the subject line) of an email message to "majordomo at unidata.ucar.edu".
-Use your email address in place of \fIjdoe at host.inst.domain\fP.
-.sp
-To subscribe to the netCDF mailing list:
-.RS
-\fBsubscribe netcdfgroup \fIjdoe at host.inst.domain\fR
-.RE
-To unsubscribe from the netCDF mailing list:
-.RS
-\fBunsubscribe netcdfgroup \fIjdoe at host.inst.domain\fR
-.RE
-To subscribe to the netCDF digest:
-.RS
-\fBsubscribe netcdfdigest \fIjdoe at host.inst.domain\fR
-.RE
-To unsubscribe from the netCDF digest:
-.RS
-\fBunsubscribe netcdfdigest \fIjdoe at host.inst.domain\fR
-.RE
-To retrieve the general introductory information for the mailing list:
-.RS
-\fBinfo netcdfgroup\fR
-.RE
-To get a synopsis of other majordomo commands:
-.RS
-\fBhelp\fR
-.RE
-.SH "SEE ALSO"
-.LP
-.BR ncdump (1),
-.BR ncgen (1),
-.BR netcdf (3<<>>ifelse(API,C,,f)).
-.LP
-\fInetCDF User's Guide\fP, published
-by the Unidata Program Center, University Corporation for Atmospheric
-Research, located in Boulder, Colorado.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/Makefile
deleted file mode 100644
index dd60686..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-# Makefile for netCDF (semi)exhaustive test.
-#
-# $Id: Makefile,v 1.1.1.1 2005/06/14 04:38:29 svitak Exp $
-
-include ../macros.make
-# M4FLAGS = -s -B7168
-# CC = cc -fullwarn -woff 1209,1506
-
-
-INCLUDES = -I../libsrc
-
-ld_math = -lm
-
-SRCS = nc_test.c \
- error.c \
- test_get.c \
- test_put.c \
- test_read.c \
- test_write.c \
- util.c
-
-OBJS = $(SRCS:.c=.o)
-
-lib_netcdf = ../libsrc/libnetcdf.a
-ld_netcdf = -L../libsrc -lnetcdf
-
-time_log = times
-
-GARBAGE = nc_test test.nc scratch.nc lint.out $(time_log)
-
-PACKING_LIST = $(SRCS) \
- test_get.m4 \
- test_put.m4 \
- error.h \
- tests.h \
- depend \
- Makefile
-
-all: nc_test
-
-test: nc_test test.nc
- ./nc_test
- @echo '*** Success ***'
-
-readonly: nc_test test.nc
- ./nc_test -r
-
-test.nc: nc_test
- ./nc_test -c
-
-install:
-
-
-nc_test: $(OBJS) $(lib_netcdf)
- $(LINK.c) $(OBJS) $(ld_netcdf) $(ld_math) $(LIBS)
-
-test_get.c: test_get.m4
-
-test_put.c: test_put.m4
-
-nctime: nctime.o $(lib_netcdf)
- $(LINK.c) nctime.o $(ld_netcdf) $(ld_math) $(LIBS)
-
-time: nctime
- time ./nctime 24 13 19 17 > $(time_log)
- awk -f timesum.awk < $(time_log)
-
-saber_src:
- #load -C $(CPPFLAGS) $(SRCS) $(ld_netcdf) $(ld_math) $(LIBS)
-
-
-include ../rules.make
-include depend
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/depend b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/depend
deleted file mode 100644
index 3716fa0..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/depend
+++ /dev/null
@@ -1,25 +0,0 @@
-error.o: error.c
-nc_test.o: ../libsrc/netcdf.h
-nc_test.o: error.h
-nc_test.o: nc_test.c
-nc_test.o: tests.h
-test_get.o: ../libsrc/netcdf.h
-test_get.o: error.h
-test_get.o: test_get.c
-test_get.o: tests.h
-test_put.o: ../libsrc/netcdf.h
-test_put.o: error.h
-test_put.o: test_put.c
-test_put.o: tests.h
-test_read.o: ../libsrc/netcdf.h
-test_read.o: error.h
-test_read.o: test_read.c
-test_read.o: tests.h
-test_write.o: ../libsrc/netcdf.h
-test_write.o: error.h
-test_write.o: test_write.c
-test_write.o: tests.h
-util.o: ../libsrc/netcdf.h
-util.o: error.h
-util.o: tests.h
-util.o: util.c
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/error.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/error.c
deleted file mode 100644
index 0f35934..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/error.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: error.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stddef.h> /* because gcc 2.7.2.2 doesn't define size_t */
- /* in <stdio.h> and it cannot hurt */
-#include <stdio.h>
-#include <stdarg.h>
-
-extern int nfails; /* number of failures in specific test */
-extern int max_nmpt; /* max. number of messages per test */
-
-/*
- * Use for logging error conditions
- */
-void
-error(const char *fmt, ...)
-{
- va_list args ;
-
- va_start(args, fmt) ;
- if (nfails <= max_nmpt)
- (void) vfprintf(stderr,fmt,args) ;
- va_end(args) ;
-}
-
-/*
- * Use for general printing (other than error conditions)
- * This also currently goes to stderr, but this could change
- */
-void
-print(const char *fmt, ...)
-{
- va_list args ;
-
- va_start(args, fmt) ;
- (void) vfprintf(stderr,fmt,args) ;
- va_end(args) ;
-}
-
-/*
- * Called by macro IF
- */
-int
-ifFail(const int expr, const int line, const char *file)
-{
- if (expr) {
- ++nfails;
- error("\n\tFAILURE at line %d of %s: ", line, file);
- }
- return expr;
-}
-
-/* TODO:
- * This diagnostic doesn't fit very well with the diagnostic message
- * "architecture" of this program.
- */
-void
-print_n_size_t(size_t nelems, const size_t *array)
-{
- fprintf(stderr, "[");
- while(nelems-- > 0)
- {
- fprintf(stderr, "%ld", (long)*array++);
- if(nelems > 0)
- fprintf(stderr, " ");
- }
- fprintf(stderr, "]");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/error.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/error.h
deleted file mode 100644
index 1c522e5..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/error.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header $
- *********************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Print error message to stderr, don't exit */
-extern void error (const char *fmt, ...);
-
-void print(const char *fmt, ...);
-
-extern int ifFail(const int expr, const int line, const char *file);
-
-extern void
-print_n_size_t(size_t nelems, const size_t *array);
-
-#ifdef __cplusplus
-}
-#endif
-
-#define IF(EXPR) if (ifFail(EXPR, __LINE__, __FILE__))
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/nc_test.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/nc_test.c
deleted file mode 100644
index ff9a11e..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/nc_test.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: nc_test.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include "tests.h"
-
-/*
- * Test driver for netCDF-3 interface. This program performs tests against
- * the netCDF-3 specification for all user-level functions in an
- * implementation of the netCDF library.
- *
- * Unless invoked with "-r" (read_only) option, must be invoked from a
- * directory in which the invoker has write permission.
- *
- * Files:
- * The read-only tests read files:
- * test.nc (see below)
- * tests.h (used merely as an example of a non-netCDF file)
- *
- * The write tests
- * read test.nc (see below)
- * write scratch.nc (deleted after each test)
- *
- * The file test.nc is created by running nc_test with the -c (create) option.
- * It is described by the following global variables.
- */
-
-/*
- * global variables (defined by function init_gvars) describing file test.nc
- */
-char dim_name[NDIMS][3];
-size_t dim_len[NDIMS];
-char var_name[NVARS][2+MAX_RANK];
-nc_type var_type[NVARS];
-size_t var_rank[NVARS];
-int var_dimid[NVARS][MAX_RANK];
-size_t var_shape[NVARS][MAX_RANK];
-size_t var_nels[NVARS];
-size_t var_natts[NVARS];
-char att_name[NVARS][MAX_NATTS][2];
-char gatt_name[NGATTS][3];
-nc_type att_type[NVARS][NGATTS];
-nc_type gatt_type[NGATTS];
-size_t att_len[NVARS][MAX_NATTS];
-size_t gatt_len[NGATTS];
-
-/*
- * command-line options
- */
-int create_file; /* if 1, create file test.nc */
-int read_only; /* if 1, don't try to change files */
-int verbose; /* if 1, print details of tests */
-int max_nmpt; /* max. number of messages per test */
-
-/*
- * Misc. global variables
- */
-int nfails; /* number of failures in specific test */
-char *progname;
-char testfile[] = "test.nc"; /* read-only testfile */
-char scratch[] = "scratch.nc"; /* writable scratch file */
-
-static void
-usage(void)
-{
- error("%s [-hrv] [-n <MAX_NMPT>]\n", progname);
- error(" [-h] Print help\n" );
- error(" [-c] Create file test.nc (Do not do tests)\n" );
- error(" [-r] Just do read-only tests\n" );
- error(" [-v] Verbose mode\n" );
- error(" [-n <MAX_NMPT>] max. number of messages per test (Default: 8)\n");
-}
-
-#define NC_TEST(func) \
- print( "*** Testing " #func " ... ");\
- nfails = 0;\
- test_ ## func();\
- nfailsTotal += nfails;\
- if (verbose) \
- print("\n"); \
- if ( nfails == 0) \
- print( "ok\n");\
- else\
- print( "\n\t### %d FAILURES TESTING %s! ###\n", nfails, #func)
-
-
-#if 1 /* both CRAY MPP and OSF/1 Alpha systems need this */
-#include <signal.h>
-#endif /* T90 */
-
-int
-main(int argc, char *argv[])
-{
- extern int optind;
- extern int optopt;
- extern char *optarg;
- int c;
- int nfailsTotal = 0; /* total number of failures */
-
-#if 1 /* 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
- */
- (void) signal(SIGFPE, SIG_IGN);
-#endif
-
- progname = argv[0];
- create_file = 0; /* file test.nc will normally already exist */
- read_only = 0; /* assume may write in test dir as default */
- verbose = 0;
- max_nmpt = 8;
- while ((c = getopt(argc, argv, "chrvn:")) != EOF)
- switch(c) {
- case 'c': /* Create file test.nc */
- create_file = 1;
- break;
- case 'r': /* just perform read-only tests */
- read_only = 1;
- break;
- case 'v': /* verbose mode */
- verbose = 1;
- break;
- case 'n': /* verbose mode */
- max_nmpt = atoi(optarg);
- break;
- case 'h':
- case '?':
- usage();
- return 1;
- }
-
- /* Initialize global variables defining test file */
- init_gvars();
-
- if ( create_file ) {
- write_file(testfile);
- return nfailsTotal > 0;
- }
-
- /* delete any existing scratch netCDF file */
- if ( ! read_only )
- (void) remove(scratch);
-
- /* Test read-only functions, using pregenerated test-file */
- NC_TEST(nc_strerror);
- NC_TEST(nc_open);
- NC_TEST(nc_close);
- NC_TEST(nc_inq);
- NC_TEST(nc_inq_dimid);
- NC_TEST(nc_inq_dim);
- NC_TEST(nc_inq_dimlen);
- NC_TEST(nc_inq_dimname);
- NC_TEST(nc_inq_varid);
- NC_TEST(nc_inq_var);
- NC_TEST(nc_inq_natts);
- NC_TEST(nc_inq_ndims);
- NC_TEST(nc_inq_nvars);
- NC_TEST(nc_inq_unlimdim);
- NC_TEST(nc_inq_vardimid);
- NC_TEST(nc_inq_varname);
- NC_TEST(nc_inq_varnatts);
- NC_TEST(nc_inq_varndims);
- NC_TEST(nc_inq_vartype);
- NC_TEST(nc_get_var_text);
- NC_TEST(nc_get_var_uchar);
- NC_TEST(nc_get_var_schar);
- NC_TEST(nc_get_var_short);
- NC_TEST(nc_get_var_int);
- NC_TEST(nc_get_var_long);
- NC_TEST(nc_get_var_float);
- NC_TEST(nc_get_var_double);
- NC_TEST(nc_get_var1_text);
- NC_TEST(nc_get_var1_uchar);
- NC_TEST(nc_get_var1_schar);
- NC_TEST(nc_get_var1_short);
- NC_TEST(nc_get_var1_int);
- NC_TEST(nc_get_var1_long);
- NC_TEST(nc_get_var1_float);
- NC_TEST(nc_get_var1_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_get_var1);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_get_vara_text);
- NC_TEST(nc_get_vara_uchar);
- NC_TEST(nc_get_vara_schar);
- NC_TEST(nc_get_vara_short);
- NC_TEST(nc_get_vara_int);
- NC_TEST(nc_get_vara_long);
- NC_TEST(nc_get_vara_float);
- NC_TEST(nc_get_vara_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_get_vara);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_get_vars_text);
- NC_TEST(nc_get_vars_uchar);
- NC_TEST(nc_get_vars_schar);
- NC_TEST(nc_get_vars_short);
- NC_TEST(nc_get_vars_int);
- NC_TEST(nc_get_vars_long);
- NC_TEST(nc_get_vars_float);
- NC_TEST(nc_get_vars_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_get_vars);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_get_varm_text);
- NC_TEST(nc_get_varm_uchar);
- NC_TEST(nc_get_varm_schar);
- NC_TEST(nc_get_varm_short);
- NC_TEST(nc_get_varm_int);
- NC_TEST(nc_get_varm_long);
- NC_TEST(nc_get_varm_float);
- NC_TEST(nc_get_varm_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_get_varm);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_get_att_text);
- NC_TEST(nc_get_att_uchar);
- NC_TEST(nc_get_att_schar);
- NC_TEST(nc_get_att_short);
- NC_TEST(nc_get_att_int);
- NC_TEST(nc_get_att_long);
- NC_TEST(nc_get_att_float);
- NC_TEST(nc_get_att_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_get_att);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_inq_att);
- NC_TEST(nc_inq_attname);
- NC_TEST(nc_inq_attid);
- NC_TEST(nc_inq_attlen);
- NC_TEST(nc_inq_atttype);
-
- /* Test write functions */
- if (! read_only) {
- NC_TEST(nc_create);
- NC_TEST(nc_redef);
- /* NC_TEST(nc_enddef); *//* redundant */
- NC_TEST(nc_sync);
- NC_TEST(nc_abort);
- NC_TEST(nc_def_dim);
- NC_TEST(nc_rename_dim);
- NC_TEST(nc_def_var);
- NC_TEST(nc_put_var_text);
- NC_TEST(nc_put_var_uchar);
- NC_TEST(nc_put_var_schar);
- NC_TEST(nc_put_var_short);
- NC_TEST(nc_put_var_int);
- NC_TEST(nc_put_var_long);
- NC_TEST(nc_put_var_float);
- NC_TEST(nc_put_var_double);
- NC_TEST(nc_put_var1_text);
- NC_TEST(nc_put_var1_uchar);
- NC_TEST(nc_put_var1_schar);
- NC_TEST(nc_put_var1_short);
- NC_TEST(nc_put_var1_int);
- NC_TEST(nc_put_var1_long);
- NC_TEST(nc_put_var1_float);
- NC_TEST(nc_put_var1_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_put_var1);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_put_vara_text);
- NC_TEST(nc_put_vara_uchar);
- NC_TEST(nc_put_vara_schar);
- NC_TEST(nc_put_vara_short);
- NC_TEST(nc_put_vara_int);
- NC_TEST(nc_put_vara_long);
- NC_TEST(nc_put_vara_float);
- NC_TEST(nc_put_vara_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_put_vara);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_put_vars_text);
- NC_TEST(nc_put_vars_uchar);
- NC_TEST(nc_put_vars_schar);
- NC_TEST(nc_put_vars_short);
- NC_TEST(nc_put_vars_int);
- NC_TEST(nc_put_vars_long);
- NC_TEST(nc_put_vars_float);
- NC_TEST(nc_put_vars_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_put_vars);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_put_varm_text);
- NC_TEST(nc_put_varm_uchar);
- NC_TEST(nc_put_varm_schar);
- NC_TEST(nc_put_varm_short);
- NC_TEST(nc_put_varm_int);
- NC_TEST(nc_put_varm_long);
- NC_TEST(nc_put_varm_float);
- NC_TEST(nc_put_varm_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_put_varm);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_rename_var);
- NC_TEST(nc_put_att_text);
- NC_TEST(nc_put_att_uchar);
- NC_TEST(nc_put_att_schar);
- NC_TEST(nc_put_att_short);
- NC_TEST(nc_put_att_int);
- NC_TEST(nc_put_att_long);
- NC_TEST(nc_put_att_float);
- NC_TEST(nc_put_att_double);
-#ifdef TEST_VOIDSTAR
- NC_TEST(nc_put_att);
-#endif /* TEST_VOIDSTAR */
- NC_TEST(nc_copy_att);
- NC_TEST(nc_rename_att);
- NC_TEST(nc_del_att);
- NC_TEST(nc_set_fill);
- }
-
- print( "\nTotal number of failures: %d\n", nfailsTotal);
- return nfailsTotal > 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_get.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_get.c
deleted file mode 100644
index fa30f08..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_get.c
+++ /dev/null
@@ -1,6251 +0,0 @@
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: test_get.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-
-#include "tests.h"
-
-
-void
-test_nc_get_var1_text(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 */
- text value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_text(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_var1_text(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_text(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_TEXT );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_text(ncid, i, NULL, &value);
- else
- err = nc_get_var1_text(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_TEXT)) {
- if (expect >= text_min && expect <= text_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_TEXT)) {
- 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_var1_uchar(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 */
- uchar value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_uchar(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_uchar(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_UCHAR );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_uchar(ncid, i, NULL, &value);
- else
- err = nc_get_var1_uchar(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_UCHAR)) {
- if (expect >= uchar_min && expect <= uchar_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_UCHAR)) {
- 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_var1_schar(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 */
- schar value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_schar(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_schar(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_SCHAR );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_schar(ncid, i, NULL, &value);
- else
- err = nc_get_var1_schar(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_SCHAR)) {
- if (expect >= schar_min && expect <= schar_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_SCHAR)) {
- 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_var1_short(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 */
- short value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_short(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_short(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_SHORT );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_short(ncid, i, NULL, &value);
- else
- err = nc_get_var1_short(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_SHORT)) {
- if (expect >= short_min && expect <= short_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_SHORT)) {
- 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_var1_int(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 */
- int value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_int(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_int(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_INT );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_int(ncid, i, NULL, &value);
- else
- err = nc_get_var1_int(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_INT)) {
- if (expect >= int_min && expect <= int_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_INT)) {
- 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_var1_long(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 */
- long value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_long(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_long(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_LONG );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_long(ncid, i, NULL, &value);
- else
- err = nc_get_var1_long(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_LONG)) {
- if (expect >= long_min && expect <= long_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_LONG)) {
- 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_var1_float(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 */
- float value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_float(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_float(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_FLOAT );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_float(ncid, i, NULL, &value);
- else
- err = nc_get_var1_float(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_FLOAT)) {
- if (expect >= float_min && expect <= float_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_FLOAT)) {
- 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_var1_double(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 */
- double value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_double(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- index[j] = var_shape[i][j];
- err = nc_get_var1_double(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_DOUBLE );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_double(ncid, i, NULL, &value);
- else
- err = nc_get_var1_double(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_DOUBLE)) {
- if (expect >= double_min && expect <= double_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) {
- 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)
-{
- 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 */
- text value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_text(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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_TEXT);
- if (inRange3(expect[j],var_type[i], NCT_TEXT)) {
- allInIntRange = allInIntRange && expect[j] >= text_min
- && expect[j] <= text_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_text(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_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_var_uchar(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 */
- uchar value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_uchar(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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_UCHAR);
- if (inRange3(expect[j],var_type[i], NCT_UCHAR)) {
- allInIntRange = allInIntRange && expect[j] >= uchar_min
- && expect[j] <= uchar_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_uchar(ncid, i, value);
- if (canConvert) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_var_schar(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 */
- schar value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_schar(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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_SCHAR);
- if (inRange3(expect[j],var_type[i], NCT_SCHAR)) {
- allInIntRange = allInIntRange && expect[j] >= schar_min
- && expect[j] <= schar_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_schar(ncid, i, value);
- if (canConvert) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_var_short(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 */
- short value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_short(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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_SHORT);
- if (inRange3(expect[j],var_type[i], NCT_SHORT)) {
- allInIntRange = allInIntRange && expect[j] >= short_min
- && expect[j] <= short_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_short(ncid, i, value);
- if (canConvert) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_var_int(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 */
- int value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_int(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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_INT);
- if (inRange3(expect[j],var_type[i], NCT_INT)) {
- allInIntRange = allInIntRange && expect[j] >= int_min
- && expect[j] <= int_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_int(ncid, i, value);
- if (canConvert) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_var_long(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 */
- long value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_long(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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;
- }
- }
- err = nc_get_var_long(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_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_var_float(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 */
- float value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_float(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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;
- }
- }
- 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);
- }
- } 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_var_double(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 */
- double value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_var_double(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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];
- }
- 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 {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_double(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_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_vara_text(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- text value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_vara_text(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- start[j] = var_shape[i][j];
- err = nc_get_vara_text(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vara_text(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_text(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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_get_vara_text(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad start: status = %d", err);
- start[j] = 0;
- }
- }
- err = nc_get_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 */
- /* get 2^rank (nslabs) slabs so defined */
- nslabs = 1;
- for (j = 0; j < var_rank[i]; j++) {
- mid[j] = roll( var_shape[i][j] );
- nslabs *= 2;
- }
- /* bits of k determine whether to get lower or upper part of dim */
- for (k = 0; k < nslabs; k++) {
- nels = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- 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_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_vara_text(ncid, i, NULL, NULL, value);
- else
- err = nc_get_vara_text(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);
- }
- } 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_vara_uchar(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- uchar value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_vara_uchar(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- start[j] = var_shape[i][j];
- err = nc_get_vara_uchar(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vara_uchar(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_uchar(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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_get_vara_uchar(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad start: status = %d", err);
- start[j] = 0;
- }
- }
- err = nc_get_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 */
- /* get 2^rank (nslabs) slabs so defined */
- nslabs = 1;
- for (j = 0; j < var_rank[i]; j++) {
- mid[j] = roll( var_shape[i][j] );
- nslabs *= 2;
- }
- /* bits of k determine whether to get lower or upper part of dim */
- for (k = 0; k < nslabs; k++) {
- nels = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- 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_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_vara_uchar(ncid, i, NULL, NULL, value);
- else
- err = nc_get_vara_uchar(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);
- }
- } 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_vara_schar(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- schar value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_vara_schar(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- start[j] = var_shape[i][j];
- err = nc_get_vara_schar(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vara_schar(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_schar(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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_get_vara_schar(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad start: status = %d", err);
- start[j] = 0;
- }
- }
- err = nc_get_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 */
- /* get 2^rank (nslabs) slabs so defined */
- nslabs = 1;
- for (j = 0; j < var_rank[i]; j++) {
- mid[j] = roll( var_shape[i][j] );
- nslabs *= 2;
- }
- /* bits of k determine whether to get lower or upper part of dim */
- for (k = 0; k < nslabs; k++) {
- nels = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- 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_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_vara_schar(ncid, i, NULL, NULL, value);
- else
- err = nc_get_vara_schar(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);
- }
- } 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_vara_short(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- short value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- 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++) {
- 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);
- 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 */
- nslabs = 1;
- for (j = 0; j < var_rank[i]; j++) {
- mid[j] = roll( var_shape[i][j] );
- nslabs *= 2;
- }
- /* bits of k determine whether to get lower or upper part of dim */
- for (k = 0; k < nslabs; k++) {
- nels = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- 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_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_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 {
- 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_vara_int(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- 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++) {
- 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);
- 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 */
- nslabs = 1;
- for (j = 0; j < var_rank[i]; j++) {
- mid[j] = roll( var_shape[i][j] );
- nslabs *= 2;
- }
- /* bits of k determine whether to get lower or upper part of dim */
- for (k = 0; k < nslabs; k++) {
- nels = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- 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_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_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 {
- 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_vara_long(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- long value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- 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++) {
- 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);
- 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 */
- nslabs = 1;
- for (j = 0; j < var_rank[i]; j++) {
- mid[j] = roll( var_shape[i][j] );
- nslabs *= 2;
- }
- /* bits of k determine whether to get lower or upper part of dim */
- for (k = 0; k < nslabs; k++) {
- nels = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- 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_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_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 {
- 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_vara_float(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- float value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- 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++) {
- 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);
- 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) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- nels *= edge[j];
- }
- allInExtRange = allInIntRange = 1;
- for (j = 0; j < nels; j++) {
- 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_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_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 {
- 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_vara_double(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- double value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- 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++) {
- 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);
- 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];
- }
- 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;
- }
- }
- 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 {
- 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_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];
- int canConvert; /* Both text or both numeric */
- text value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_get_vars_text(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_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++) {
- start[j] = var_shape[i][j];
- err = nc_get_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_text(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_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 */
- /* 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_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_vars_text(ncid, i, NULL, NULL, NULL, value);
- else
- 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]);
- 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_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];
- int canConvert; /* Both text or both numeric */
- uchar value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- err = nc_get_vars_uchar(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_uchar(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_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_uchar(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars_uchar(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_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_vars_uchar(ncid, i, NULL, NULL, NULL, value);
- else
- 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]);
- 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_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];
- int canConvert; /* Both text or both numeric */
- schar value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- err = nc_get_vars_schar(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_schar(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_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_schar(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars_schar(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_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_vars_schar(ncid, i, NULL, NULL, NULL, value);
- else
- 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]);
- 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_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];
- int canConvert; /* Both text or both numeric */
- short value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- err = nc_get_vars_short(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_short(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_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_short(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars_short(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_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_vars_short(ncid, i, NULL, NULL, NULL, value);
- else
- 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]);
- 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_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];
- int canConvert; /* Both text or both numeric */
- int value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- err = nc_get_vars_int(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_int(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_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_int(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars_int(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_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_vars_int(ncid, i, NULL, NULL, NULL, value);
- else
- 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]);
- 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_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];
- int canConvert; /* Both text or both numeric */
- long value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- err = nc_get_vars_long(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_long(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_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_long(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars_long(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_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_vars_long(ncid, i, NULL, NULL, NULL, value);
- else
- 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]);
- 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_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];
- int canConvert; /* Both text or both numeric */
- float value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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;
- }
- err = nc_get_vars_float(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_float(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_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 index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars_float(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars_float(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_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_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);
- }
- }
- }
-
- }
- 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; 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_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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; 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 = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; 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;
- }
- }
- 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 {
- 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_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);
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- print_nok(nok);
-}
-
-void
-test_nc_get_att_int(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- int allInExtRange;
- int allInIntRange;
- int canConvert; /* Both text or both numeric */
- int value[MAX_NELS];
- double expect[MAX_NELS];
- int nok = 0; /* count of valid comparisons */
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- 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)
- error("bad ncid: status = %d", err);
- err = nc_get_att_int(ncid, BAD_VARID, ATT_NAME(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_get_att_int(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_INT);
- if (inRange3(expect[k],ATT_TYPE(i,j),NCT_INT)) {
- allInIntRange = allInIntRange && expect[k] >= int_min
- && expect[k] <= int_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_att_int(ncid, i, ATT_NAME(i,j), value);
- if (canConvert || ATT_LEN(i,j) == 0) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_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");
- 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_long(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- int allInExtRange;
- int allInIntRange;
- int canConvert; /* Both text or both numeric */
- long value[MAX_NELS];
- double expect[MAX_NELS];
- int nok = 0; /* count of valid comparisons */
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- 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)
- error("bad ncid: status = %d", err);
- err = nc_get_att_long(ncid, BAD_VARID, ATT_NAME(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_get_att_long(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_LONG);
- if (inRange3(expect[k],ATT_TYPE(i,j),NCT_LONG)) {
- allInIntRange = allInIntRange && expect[k] >= long_min
- && expect[k] <= long_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_att_long(ncid, i, ATT_NAME(i,j), value);
- if (canConvert || ATT_LEN(i,j) == 0) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_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");
- 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_float(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- int allInExtRange;
- int allInIntRange;
- int canConvert; /* Both text or both numeric */
- float value[MAX_NELS];
- double expect[MAX_NELS];
- int nok = 0; /* count of valid comparisons */
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- 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)
- error("bad ncid: status = %d", err);
- err = nc_get_att_float(ncid, BAD_VARID, ATT_NAME(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_get_att_float(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_FLOAT);
- if (inRange3(expect[k],ATT_TYPE(i,j),NCT_FLOAT)) {
- allInIntRange = allInIntRange && expect[k] >= float_min
- && expect[k] <= float_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
- if (canConvert || ATT_LEN(i,j) == 0) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_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");
- 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_double(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- int allInExtRange;
- int allInIntRange;
- int canConvert; /* Both text or both numeric */
- double value[MAX_NELS];
- double expect[MAX_NELS];
- int nok = 0; /* count of valid comparisons */
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- 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)
- error("bad ncid: status = %d", err);
- err = nc_get_att_double(ncid, BAD_VARID, ATT_NAME(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_get_att_double(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_DOUBLE);
- if (inRange3(expect[k],ATT_TYPE(i,j),NCT_DOUBLE)) {
- allInIntRange = allInIntRange && expect[k] >= double_min
- && expect[k] <= double_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
- if (canConvert || ATT_LEN(i,j) == 0) {
- if (allInExtRange) {
- if (allInIntRange) {
- IF (err)
- 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_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");
- 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);
-}
-
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_get.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_get.m4
deleted file mode 100644
index a5ca393..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_get.m4
+++ /dev/null
@@ -1,900 +0,0 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-dnl If you see this line, you can ignore the next one.
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: test_get.m4,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-undefine(`index')dnl
-dnl dnl dnl
-dnl
-dnl Macros
-dnl
-dnl dnl dnl
-dnl
-dnl Upcase(str)
-dnl
-define(`Upcase',dnl
-`dnl
-translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)')dnl
-dnl dnl dnl
-dnl
-dnl NCT_ITYPE(type)
-dnl
-define(`NCT_ITYPE', ``NCT_'Upcase($1)')dnl
-dnl
-
-#include "tests.h"
-
-dnl TEST_NC_GET_VAR1(TYPE)
-dnl
-define(`TEST_NC_GET_VAR1',dnl
-`dnl
-void
-test_nc_get_var1_$1(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 */
- $1 value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1_$1(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_var1_$1(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_$1(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_ITYPE($1) );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1_$1(ncid, i, NULL, &value);
- else
- err = nc_get_var1_$1(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(expect,var_type[i], NCT_ITYPE($1))) {
- if (expect >= $1_min && expect <= $1_max) {
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_ITYPE($1))) {
- 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);
-}
-')dnl
-
-TEST_NC_GET_VAR1(text)
-TEST_NC_GET_VAR1(uchar)
-TEST_NC_GET_VAR1(schar)
-TEST_NC_GET_VAR1(short)
-TEST_NC_GET_VAR1(int)
-TEST_NC_GET_VAR1(long)
-TEST_NC_GET_VAR1(float)
-TEST_NC_GET_VAR1(double)
-
-
-dnl TEST_NC_GET_VAR(TYPE)
-dnl
-define(`TEST_NC_GET_VAR',dnl
-`dnl
-void
-test_nc_get_var_$1(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 */
- $1 value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
- assert(var_rank[i] <= MAX_RANK);
- assert(var_nels[i] <= MAX_NELS);
- err = nc_get_var_$1(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_var_$1(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_ITYPE($1));
- if (inRange3(expect[j],var_type[i], NCT_ITYPE($1))) {
- allInIntRange = allInIntRange && expect[j] >= $1_min
- && expect[j] <= $1_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_var_$1(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_ITYPE($1))
- && expect[j] >= $1_min && expect[j] <= $1_max) {
- IF (!equal(value[j],expect[j],var_type[i],NCT_ITYPE($1))){
- 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);
-}
-')dnl
-
-TEST_NC_GET_VAR(text)
-TEST_NC_GET_VAR(uchar)
-TEST_NC_GET_VAR(schar)
-TEST_NC_GET_VAR(short)
-TEST_NC_GET_VAR(int)
-TEST_NC_GET_VAR(long)
-TEST_NC_GET_VAR(float)
-TEST_NC_GET_VAR(double)
-
-
-dnl TEST_NC_GET_VARA(TYPE)
-dnl
-define(`TEST_NC_GET_VARA',dnl
-`dnl
-void
-test_nc_get_vara_$1(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int allInExtRange; /* all values within external range? */
- int allInIntRange; /* all values within internal range? */
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- $1 value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == 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_get_vara_$1(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vara_$1(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++) {
- start[j] = var_shape[i][j];
- err = nc_get_vara_$1(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vara_$1(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_$1(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vara_$1(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_$1(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad start: status = %d", err);
- start[j] = 0;
- }
- }
- err = nc_get_vara_$1(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];
- }
- 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_ITYPE($1));
- if (inRange3(expect[j],var_type[i], NCT_ITYPE($1))) {
- allInIntRange = allInIntRange && expect[j] >= $1_min
- && expect[j] <= $1_max;
- } else {
- allInExtRange = 0;
- }
- }
- if (var_rank[i] == 0 && i%2)
- err = nc_get_vara_$1(ncid, i, NULL, NULL, value);
- else
- err = nc_get_vara_$1(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);
- }
- } 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_ITYPE($1))
- && expect[j] >= $1_min && expect[j] <= $1_max) {
- IF (!equal(value[j],expect[j],var_type[i],NCT_ITYPE($1))){
- 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);
-}
-')dnl
-
-TEST_NC_GET_VARA(text)
-TEST_NC_GET_VARA(uchar)
-TEST_NC_GET_VARA(schar)
-TEST_NC_GET_VARA(short)
-TEST_NC_GET_VARA(int)
-TEST_NC_GET_VARA(long)
-TEST_NC_GET_VARA(float)
-TEST_NC_GET_VARA(double)
-
-
-dnl TEST_NC_GET_VARS(TYPE)
-dnl
-define(`TEST_NC_GET_VARS',dnl
-`dnl
-void
-test_nc_get_vars_$1(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 */
- $1 value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == 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_$1(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars_$1(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_$1(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_$1(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_$1(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_ITYPE($1));
- if (inRange3(expect[j],var_type[i],NCT_ITYPE($1))) {
- allInIntRange = allInIntRange && expect[j] >= $1_min
- && expect[j] <= $1_max;
- } else {
- allInExtRange = 0;
- }
- }
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_vars_$1(ncid, i, NULL, NULL, NULL, value);
- else
- err = nc_get_vars_$1(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_ITYPE($1))
- && expect[j] >= $1_min && expect[j] <= $1_max) {
- IF (!equal(value[j],expect[j],var_type[i],
- NCT_ITYPE($1))){
- 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);
-}
-')dnl
-
-TEST_NC_GET_VARS(text)
-TEST_NC_GET_VARS(uchar)
-TEST_NC_GET_VARS(schar)
-TEST_NC_GET_VARS(short)
-TEST_NC_GET_VARS(int)
-TEST_NC_GET_VARS(long)
-TEST_NC_GET_VARS(float)
-TEST_NC_GET_VARS(double)
-
-
-dnl TEST_NC_GET_VARM(TYPE)
-dnl
-define(`TEST_NC_GET_VARM',dnl
-`dnl
-void
-test_nc_get_varm_$1(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 */
- $1 value[MAX_NELS];
- double expect[MAX_NELS];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == 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_$1(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_varm_$1(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_$1(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_$1(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_$1(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_ITYPE($1));
- if (inRange3(expect[j],var_type[i],NCT_ITYPE($1))) {
- allInIntRange = allInIntRange && expect[j] >= $1_min
- && expect[j] <= $1_max;
- } else {
- allInExtRange = 0;
- }
- }
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_varm_$1(ncid,i,NULL,NULL,NULL,NULL,value);
- else
- err = nc_get_varm_$1(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_ITYPE($1))
- && expect[j] >= $1_min
- && expect[j] <= $1_max) {
- IF (!equal(value[j],expect[j],var_type[i],
- NCT_ITYPE($1))){
- 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);
-}
-')dnl
-
-TEST_NC_GET_VARM(text)
-TEST_NC_GET_VARM(uchar)
-TEST_NC_GET_VARM(schar)
-TEST_NC_GET_VARM(short)
-TEST_NC_GET_VARM(int)
-TEST_NC_GET_VARM(long)
-TEST_NC_GET_VARM(float)
-TEST_NC_GET_VARM(double)
-
-
-dnl TEST_NC_GET_ATT(TYPE)
-dnl
-define(`TEST_NC_GET_ATT',dnl
-`dnl
-void
-test_nc_get_att_$1(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- int allInExtRange;
- int allInIntRange;
- int canConvert; /* Both text or both numeric */
- $1 value[MAX_NELS];
- double expect[MAX_NELS];
- int nok = 0; /* count of valid comparisons */
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; 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);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_att_$1(ncid, BAD_VARID, ATT_NAME(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_get_att_$1(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_ITYPE($1));
- if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ITYPE($1))) {
- allInIntRange = allInIntRange && expect[k] >= $1_min
- && expect[k] <= $1_max;
- } else {
- allInExtRange = 0;
- }
- }
- err = nc_get_att_$1(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_ITYPE($1))
- && expect[k] >= $1_min && expect[k] <= $1_max) {
- IF (!equal(value[k],expect[k],ATT_TYPE(i,j),
- NCT_ITYPE($1))){
- 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);
-}
-')dnl
-
-TEST_NC_GET_ATT(text)
-TEST_NC_GET_ATT(uchar)
-TEST_NC_GET_ATT(schar)
-TEST_NC_GET_ATT(short)
-TEST_NC_GET_ATT(int)
-TEST_NC_GET_ATT(long)
-TEST_NC_GET_ATT(float)
-TEST_NC_GET_ATT(double)
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_put.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_put.c
deleted file mode 100644
index ecb3adb..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_put.c
+++ /dev/null
@@ -1,7330 +0,0 @@
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: test_put.c,v 1.1.1.1 2005/06/14 04:38:29 svitak Exp $
- *********************************************************************/
-
-
-#include "tests.h"
-
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_text(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = text_min;
- const double max = text_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_uchar(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = uchar_min;
- const double max = uchar_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_schar(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = schar_min;
- const double max = schar_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_short(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = short_min;
- const double max = short_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_int(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = int_min;
- const double max = int_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_long(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = long_min;
- const double max = long_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_float(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = float_min;
- const double max = float_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_double(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = double_min;
- const double max = double_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-
-
-
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_text(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- text 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == 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_TEXT);
- err = nc_get_var1_text(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_TEXT)) {
- if (expect >= text_min && expect <= text_max) {
- IF (err) {
- error("nc_get_var1_text: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_TEXT)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_uchar(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- uchar 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_UCHAR == 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_UCHAR);
- err = nc_get_var1_uchar(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_UCHAR)) {
- if (expect >= uchar_min && expect <= uchar_max) {
- IF (err) {
- error("nc_get_var1_uchar: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_UCHAR)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_schar(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- schar 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_SCHAR == 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_SCHAR);
- err = nc_get_var1_schar(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_SCHAR)) {
- if (expect >= schar_min && expect <= schar_max) {
- IF (err) {
- error("nc_get_var1_schar: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_SCHAR)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_short(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- short 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_SHORT == 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_SHORT);
- err = nc_get_var1_short(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_SHORT)) {
- if (expect >= short_min && expect <= short_max) {
- IF (err) {
- error("nc_get_var1_short: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_SHORT)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_int(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- int 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_INT == 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_INT);
- err = nc_get_var1_int(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_INT)) {
- if (expect >= int_min && expect <= int_max) {
- IF (err) {
- error("nc_get_var1_int: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_INT)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_long(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- long 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_LONG == 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_LONG);
- err = nc_get_var1_long(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_LONG)) {
- if (expect >= long_min && expect <= long_max) {
- IF (err) {
- error("nc_get_var1_long: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_LONG)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_float(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- float 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_FLOAT == 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_FLOAT);
- err = nc_get_var1_float(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_FLOAT)) {
- if (expect >= float_min && expect <= float_max) {
- IF (err) {
- error("nc_get_var1_float: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_FLOAT)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_double(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- double 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_DOUBLE == 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_DOUBLE);
- err = nc_get_var1_double(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_DOUBLE)) {
- if (expect >= double_min && expect <= double_max) {
- IF (err) {
- error("nc_get_var1_double: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) {
- error("Var value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("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);
-}
-
-
-
-
-/*
- * check all attributes in file which are (text/numeric) compatible with TYPE
- * ignore any attributes containing values outside range of TYPE
- */
-void
-check_atts_text(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- text 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_TEXT == 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_TEXT);
- if (inRange3(expect[k], datatype, NCT_TEXT)) {
- ++nInExtRange;
- if (expect[k] >= text_min && expect[k] <= text_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_text(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_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");
- 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
- */
-void
-check_atts_uchar(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- uchar 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_UCHAR == 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_UCHAR);
- if (inRange3(expect[k], datatype, NCT_UCHAR)) {
- ++nInExtRange;
- if (expect[k] >= uchar_min && expect[k] <= uchar_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_uchar(ncid, i, ATT_NAME(i,j), value);
- if (nInExtRange == length && nInIntRange == length) {
- IF (err)
- 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_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");
- 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
- */
-void
-check_atts_schar(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- schar 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SCHAR == 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_SCHAR);
- if (inRange3(expect[k], datatype, NCT_SCHAR)) {
- ++nInExtRange;
- if (expect[k] >= schar_min && expect[k] <= schar_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_schar(ncid, i, ATT_NAME(i,j), value);
- if (nInExtRange == length && nInIntRange == length) {
- IF (err)
- 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_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");
- 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
- */
-void
-check_atts_short(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- short 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_SHORT == 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_SHORT);
- if (inRange3(expect[k], datatype, NCT_SHORT)) {
- ++nInExtRange;
- if (expect[k] >= short_min && expect[k] <= short_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_short(ncid, i, ATT_NAME(i,j), value);
- if (nInExtRange == length && nInIntRange == length) {
- IF (err)
- 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_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");
- 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
- */
-void
-check_atts_int(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- int 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_INT == 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_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
- */
-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 < NVARS; 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
- */
-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 < NVARS; 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)) {
- ++nInExtRange;
- if (expect[k] >= float_min && expect[k] <= float_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_float(ncid, i, ATT_NAME(i,j), value);
- if (nInExtRange == length && nInIntRange == length) {
- IF (err)
- 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_FLOAT)
- && expect[k] >= float_min && expect[k] <= float_max) {
- IF (!equal(value[k],expect[k],datatype,NCT_FLOAT)) {
- error("att. value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("att_name: %s, ", ATT_NAME(i,j));
- error("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
- */
-void
-check_atts_double(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- double 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_DOUBLE == 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_DOUBLE);
- if (inRange3(expect[k], datatype, NCT_DOUBLE)) {
- ++nInExtRange;
- if (expect[k] >= double_min && expect[k] <= double_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_double(ncid, i, ATT_NAME(i,j), value);
- if (nInExtRange == length && nInIntRange == length) {
- IF (err)
- 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_DOUBLE)
- && expect[k] >= double_min && expect[k] <= double_max) {
- IF (!equal(value[k],expect[k],datatype,NCT_DOUBLE)) {
- error("att. value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("att_name: %s, ", ATT_NAME(i,j));
- error("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;
- int i;
- int j;
- int err;
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- text value = 5; /* any value would do - only for error cases */
-
- err = nc_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));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_TEXT == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_put_var1_text(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_var1_text(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_text(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_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 = nc_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));
-
- for (i = 0; i < NVARS; 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 = nc_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));
-
- for (i = 0; i < NVARS; 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 = nc_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));
-
- for (i = 0; i < NVARS; 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 = nc_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));
-
- for (i = 0; i < NVARS; 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 = nc_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));
-
- for (i = 0; i < NVARS; 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 = nc_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));
-
- for (i = 0; i < NVARS; 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 = nc_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));
-
- for (i = 0; i < NVARS; 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_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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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 = nc_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));
-
- for (i = 0; i < NVARS; 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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
-
- 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_vara_text(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- text value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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)
- 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;
- 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;
- }
- }
- /* 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;
- }
- }
- 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)
- err = nc_put_vara_text(ncid, i, NULL, NULL, value);
- else
- err = nc_put_vara_text(ncid, i, start, edge, 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_vara_uchar(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- uchar value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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)
- 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;
- 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;
- }
- }
- 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);
- }
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_vara_uchar(ncid, i, NULL, NULL, value);
- else
- err = nc_put_vara_uchar(ncid, i, start, edge, 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_vara_schar(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- schar value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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)
- 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;
- 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;
- }
- }
- /* 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;
- }
- }
- 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)
- err = nc_put_vara_schar(ncid, i, NULL, NULL, value);
- else
- err = nc_put_vara_schar(ncid, i, start, edge, 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_vara_short(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- short value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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;
- }
- 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;
- 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;
- }
- }
- /* Check correct error returned even when nothing to put */
- for (j = 0; j < var_rank[i]; j++) {
- edge[j] = 0;
- }
- 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;
- }
- }
- 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;
- }
-
- /* 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_short(var_type[i], var_rank[i], index, NCT_SHORT);
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_SHORT);
- }
- 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) {
- 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_vara_int(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- int value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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;
- }
- 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;
- 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;
- }
- }
- /* Check correct error returned even when nothing to put */
- for (j = 0; j < var_rank[i]; j++) {
- edge[j] = 0;
- }
- 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;
- }
- }
- 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;
- }
-
- /* 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_int(var_type[i], var_rank[i], index, NCT_INT);
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_INT);
- }
- 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) {
- 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_vara_long(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- long value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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;
- }
- 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;
- 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;
- }
- }
- /* Check correct error returned even when nothing to put */
- for (j = 0; j < var_rank[i]; j++) {
- edge[j] = 0;
- }
- 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;
- }
- }
- 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;
- }
-
- /* 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_long(var_type[i], var_rank[i], index, NCT_LONG);
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_LONG);
- }
- 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) {
- 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_vara_float(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- float value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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;
- }
- 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;
- 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;
- }
- }
- /* Check correct error returned even when nothing to put */
- for (j = 0; j < var_rank[i]; j++) {
- edge[j] = 0;
- }
- 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;
- }
- }
- 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;
- }
-
- /* 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_float(var_type[i], var_rank[i], index, NCT_FLOAT);
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_FLOAT);
- }
- 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) {
- 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_vara_double(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- double value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; 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;
- }
- 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;
- 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;
- }
- }
- /* Check correct error returned even when nothing to put */
- for (j = 0; j < var_rank[i]; j++) {
- edge[j] = 0;
- }
- 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;
- }
- }
- 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;
- }
-
- /* 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_double(var_type[i], var_rank[i], index, NCT_DOUBLE);
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_DOUBLE);
- }
- 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) {
- 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_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 = nc_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));
-
- for (i = 0; i < NVARS; 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];
- 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);
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-void
-test_nc_put_vars_uchar(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? */
- uchar value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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;
- }
- err = nc_put_vars_uchar(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_uchar(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];
- 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);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars_uchar(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- 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;
- }
- }
- }
- /* 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_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 {
- 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_vars_schar(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? */
- schar value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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;
- }
- err = nc_put_vars_schar(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_schar(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];
- 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);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars_schar(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("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;
- }
- }
- }
- /* 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_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 {
- 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_vars_short(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? */
- short value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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;
- }
- err = nc_put_vars_short(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_short(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];
- 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);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars_short(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- 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;
- }
- }
- }
- /* 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_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 {
- 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_vars_int(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? */
- int value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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;
- }
- err = nc_put_vars_int(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_int(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];
- 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);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars_int(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- 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;
- }
- }
- }
- /* 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_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 {
- 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_vars_long(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? */
- long value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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;
- }
- err = nc_put_vars_long(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_long(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];
- 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);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars_long(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- 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;
- }
- }
- }
- /* 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_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 {
- 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_vars_float(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? */
- float value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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;
- }
- err = nc_put_vars_float(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_float(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];
- 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);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars_float(ncid, i, start, edge, stride, value);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- 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;
- }
- }
- }
- /* 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_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 {
- 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_vars_double(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? */
- double value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_vars_double(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_vars_double(ncid, i, start, edge, stride, value);
- if(!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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_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 {
- 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_varm_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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- text value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_text(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_text(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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);
- }
- }
- }
- }
-
- 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_varm_uchar(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- uchar value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_uchar(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_uchar(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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);
- }
- }
- }
- }
-
- 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_varm_schar(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- schar value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_schar(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_schar(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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);
- }
- }
- }
- }
-
- 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_varm_short(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- short value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_short(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_short(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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);
- }
- }
- }
- }
-
- 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_varm_int(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- int value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_int(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_int(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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_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_varm_int(ncid,i,NULL,NULL,NULL,NULL,value);
- else
- err = nc_put_varm_int(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);
- }
- }
- }
- }
-
- 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_varm_long(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- long value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_long(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_long(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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_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_varm_long(ncid,i,NULL,NULL,NULL,NULL,value);
- else
- err = nc_put_varm_long(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);
- }
- }
- }
- }
-
- 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_varm_float(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- float value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_float(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_float(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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_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_varm_float(ncid,i,NULL,NULL,NULL,NULL,value);
- else
- err = nc_put_varm_float(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);
- }
- }
- }
- }
-
- 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_varm_double(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- double value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; 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_put_varm_double(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_double(ncid, i, start, edge, stride, imap, value);
- if (!canConvert) {
- IF(err != NC_ECHAR)
- error("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_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_put_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 */
- /* 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];
- }
- }
-*/
- 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_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_varm_double(ncid,i,NULL,NULL,NULL,NULL,value);
- else
- err = nc_put_varm_double(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);
- }
- }
- }
- }
-
- 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_att_text(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- text value[MAX_NELS];
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- def_vars(ncid);
-
- {
- const char *const tval = "value for bad name";
- const size_t tval_len = strlen(tval);
-
- err = nc_put_att_text(ncid, 0, "", tval_len, tval);
- IF (err != NC_EBADNAME)
- error("should be NC_EBADNAME: status = %d", err);
- }
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (ATT_TYPE(i,j) == NC_CHAR) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_text(BAD_ID, i, ATT_NAME(i,j), ATT_LEN(i,j),
- value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_att_text(ncid, BAD_VARID, ATT_NAME(i,j),
- ATT_LEN(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- for (k = 0; k < ATT_LEN(i,j); k++) {
- value[k] = hash(ATT_TYPE(i,j), -1, &k);
- }
- err = nc_put_att_text(ncid, i, ATT_NAME(i,j),
- ATT_LEN(i,j), value);
- IF (err) {
- error("%s", nc_strerror(err));
- }
- }
- }
- }
-
- check_atts_text(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_uchar(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- uchar value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_uchar(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_uchar(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_uchar(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_uchar(ATT_TYPE(i,j), -1, &k, NCT_UCHAR);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_UCHAR);
- }
- err = nc_put_att_uchar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_uchar(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_schar(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- schar value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_schar(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_schar(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_schar(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_schar(ATT_TYPE(i,j), -1, &k, NCT_SCHAR);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_SCHAR);
- }
- err = nc_put_att_schar(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_schar(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_short(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- short value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_short(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_short(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_short(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_short(ATT_TYPE(i,j), -1, &k, NCT_SHORT);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_SHORT);
- }
- err = nc_put_att_short(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_short(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_int(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- int value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_int(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_int(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_int(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_int(ATT_TYPE(i,j), -1, &k, NCT_INT);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_INT);
- }
- err = nc_put_att_int(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_int(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_long(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- long value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_long(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_long(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_long(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_long(ATT_TYPE(i,j), -1, &k, NCT_LONG);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_LONG);
- }
- err = nc_put_att_long(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_long(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_float(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- float value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_float(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_float(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_float(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_float(ATT_TYPE(i,j), -1, &k, NCT_FLOAT);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_FLOAT);
- }
- err = nc_put_att_float(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_float(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_double(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- double value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (!(ATT_TYPE(i,j) == NC_CHAR)) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_double(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_double(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_double(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_double(ATT_TYPE(i,j), -1, &k, NCT_DOUBLE);
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_DOUBLE);
- }
- err = nc_put_att_double(ncid, i, ATT_NAME(i,j), ATT_TYPE(i,j),
- ATT_LEN(i,j), value);
- if (allInExtRange) {
- IF (err)
- error("%s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("range error: status = %d", err);
- }
- }
- }
- }
-
- check_atts_double(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/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_put.m4 b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_put.m4
deleted file mode 100644
index 0c5272b..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_put.m4
+++ /dev/null
@@ -1,1139 +0,0 @@
-dnl This is m4 source.
-dnl Process using m4 to produce 'C' language file.
-dnl
-dnl If you see this line, you can ignore the next one.
-/* Do not edit this file. It is produced from the corresponding .m4 source */
-dnl
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: test_put.m4,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-undefine(`index')dnl
-dnl dnl dnl
-dnl
-dnl Macros
-dnl
-dnl dnl dnl
-dnl
-dnl Upcase(str)
-dnl
-define(`Upcase',dnl
-`dnl
-translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)')dnl
-dnl dnl dnl
-dnl
-dnl NCT_ITYPE(type)
-dnl
-define(`NCT_ITYPE', ``NCT_'Upcase($1)')dnl
-dnl
-
-#include "tests.h"
-
-dnl HASH(TYPE)
-dnl
-define(`HASH',dnl
-`dnl
-/*
- * ensure hash value within range for internal TYPE
- */
-double
-hash_$1(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- const double min = $1_min;
- const double max = $1_max;
-
- return MAX(min, MIN(max, hash4( type, rank, index, itype)));
-}
-')dnl
-
-HASH(text)
-HASH(uchar)
-HASH(schar)
-HASH(short)
-HASH(int)
-HASH(long)
-HASH(float)
-HASH(double)
-
-
-dnl CHECK_VARS(TYPE)
-dnl
-define(`CHECK_VARS',dnl
-`dnl
-/*
- * check all vars in file which are (text/numeric) compatible with TYPE
- */
-void
-check_vars_$1(const char *filename)
-{
- int ncid; /* netCDF id */
- size_t index[MAX_RANK];
- int err; /* status */
- int d;
- int i;
- size_t j;
- $1 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 = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = 0; i < NVARS; 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);
- 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_ITYPE($1));
- err = nc_get_var1_$1(ncid, i, index, &value);
- if (inRange3(expect,datatype,NCT_ITYPE($1))) {
- if (expect >= $1_min && expect <= $1_max) {
- IF (err) {
- error("nc_get_var1_$1: %s", nc_strerror(err));
- } else {
- IF (!equal(value,expect,var_type[i],NCT_ITYPE($1))) {
- 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);
-}
-')dnl
-
-CHECK_VARS(text)
-CHECK_VARS(uchar)
-CHECK_VARS(schar)
-CHECK_VARS(short)
-CHECK_VARS(int)
-CHECK_VARS(long)
-CHECK_VARS(float)
-CHECK_VARS(double)
-
-
-dnl CHECK_ATTS(TYPE) numeric only
-dnl
-define(`CHECK_ATTS',dnl
-`dnl
-/*
- * check all attributes in file which are (text/numeric) compatible with TYPE
- * ignore any attributes containing values outside range of TYPE
- */
-void
-check_atts_$1(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- $1 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 < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- canConvert = (ATT_TYPE(i,j) == NC_CHAR) == (NCT_ITYPE($1) == 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_ITYPE($1));
- if (inRange3(expect[k], datatype, NCT_ITYPE($1))) {
- ++nInExtRange;
- if (expect[k] >= $1_min && expect[k] <= $1_max)
- ++nInIntRange;
- }
- }
- err = nc_get_att_$1(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_ITYPE($1))
- && expect[k] >= $1_min && expect[k] <= $1_max) {
- IF (!equal(value[k],expect[k],datatype,NCT_ITYPE($1))) {
- 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);
-}
-')dnl
-
-CHECK_ATTS(text)
-CHECK_ATTS(uchar)
-CHECK_ATTS(schar)
-CHECK_ATTS(short)
-CHECK_ATTS(int)
-CHECK_ATTS(long)
-CHECK_ATTS(float)
-CHECK_ATTS(double)
-
-
-dnl TEST_NC_PUT_VAR1(TYPE)
-dnl
-define(`TEST_NC_PUT_VAR1',dnl
-`dnl
-void
-test_nc_put_var1_$1(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- size_t index[MAX_RANK];
- 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);
- 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));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_put_var1_$1(BAD_ID, i, index, &value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_var1_$1(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_$1(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_$1( var_type[i], var_rank[i], index, NCT_ITYPE($1));
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_var1_$1(ncid, i, NULL, &value);
- else
- err = nc_put_var1_$1(ncid, i, index, &value);
- if (canConvert) {
- if (inRange3(value, var_type[i],NCT_ITYPE($1))) {
- 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_$1(scratch);
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-')dnl
-
-TEST_NC_PUT_VAR1(text)
-TEST_NC_PUT_VAR1(uchar)
-TEST_NC_PUT_VAR1(schar)
-TEST_NC_PUT_VAR1(short)
-TEST_NC_PUT_VAR1(int)
-TEST_NC_PUT_VAR1(long)
-TEST_NC_PUT_VAR1(float)
-TEST_NC_PUT_VAR1(double)
-
-
-dnl TEST_NC_PUT_VAR(TYPE)
-dnl
-define(`TEST_NC_PUT_VAR',dnl
-`dnl
-void
-test_nc_put_var_$1(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? */
- $1 value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == NCT_TEXT);
- assert(var_rank[i] <= MAX_RANK);
- assert(var_nels[i] <= MAX_NELS);
- err = nc_put_var_$1(BAD_ID, i, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_var_$1(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_$1(var_type[i], var_rank[i], index, NCT_ITYPE($1));
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_ITYPE($1));
- }
- err = nc_put_var_$1(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);
- }
- }
-
- /* Preceeding 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 < NVARS; 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);
- assert(var_nels[i] <= MAX_NELS);
- err = nc_put_var_$1(BAD_ID, i, value);
-
- 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_$1(var_type[i], var_rank[i], index, NCT_ITYPE($1));
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_ITYPE($1));
- }
- err = nc_put_var_$1(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_$1(scratch);
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-')dnl
-
-TEST_NC_PUT_VAR(text)
-TEST_NC_PUT_VAR(uchar)
-TEST_NC_PUT_VAR(schar)
-TEST_NC_PUT_VAR(short)
-TEST_NC_PUT_VAR(int)
-TEST_NC_PUT_VAR(long)
-TEST_NC_PUT_VAR(float)
-TEST_NC_PUT_VAR(double)
-
-
-dnl TEST_NC_PUT_VARA(TYPE)
-dnl
-define(`TEST_NC_PUT_VARA',dnl
-`dnl
-void
-test_nc_put_vara_$1(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nslabs;
- int nels;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t index[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- $1 value[MAX_NELS];
-
- err = nc_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));
-
- value[0] = 0;
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == 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_$1(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vara_$1(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_$1(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_$1(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_$1(BAD_ID, i, start, edge, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vara_$1(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_$1(ncid, i, start, edge, value);
- IF (canConvert && err != NC_EINVALCOORDS)
- error("bad start: status = %d", err);
- start[j] = 0;
- }
- }
- err = nc_put_vara_$1(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_$1(var_type[i], var_rank[i], index, NCT_ITYPE($1));
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_ITYPE($1));
- }
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_vara_$1(ncid, i, NULL, NULL, value);
- else
- err = nc_put_vara_$1(ncid, i, start, edge, 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_$1(scratch);
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-')dnl
-
-TEST_NC_PUT_VARA(text)
-TEST_NC_PUT_VARA(uchar)
-TEST_NC_PUT_VARA(schar)
-TEST_NC_PUT_VARA(short)
-TEST_NC_PUT_VARA(int)
-TEST_NC_PUT_VARA(long)
-TEST_NC_PUT_VARA(float)
-TEST_NC_PUT_VARA(double)
-
-
-dnl TEST_NC_PUT_VARS(TYPE)
-dnl
-define(`TEST_NC_PUT_VARS',dnl
-`dnl
-void
-test_nc_put_vars_$1(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? */
- $1 value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == 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_$1(BAD_ID, i, start, edge, stride, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars_$1(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];
- err = nc_put_vars_$1(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_$1(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_$1(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_$1(var_type[i], var_rank[i], index2,
- NCT_ITYPE($1));
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_ITYPE($1));
- }
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_vars_$1(ncid, i, NULL, NULL, stride, value);
- else
- err = nc_put_vars_$1(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_$1(scratch);
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-')dnl
-
-TEST_NC_PUT_VARS(text)
-TEST_NC_PUT_VARS(uchar)
-TEST_NC_PUT_VARS(schar)
-TEST_NC_PUT_VARS(short)
-TEST_NC_PUT_VARS(int)
-TEST_NC_PUT_VARS(long)
-TEST_NC_PUT_VARS(float)
-TEST_NC_PUT_VARS(double)
-
-
-dnl TEST_NC_PUT_VARM(TYPE)
-dnl
-define(`TEST_NC_PUT_VARM',dnl
-`dnl
-void
-test_nc_put_varm_$1(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];
- ptrdiff_t imap[MAX_RANK];
- int canConvert; /* Both text or both numeric */
- int allInExtRange; /* all values within external range? */
- $1 value[MAX_NELS];
-
- err = nc_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));
-
- for (i = 0; i < NVARS; i++) {
- canConvert = (var_type[i] == NC_CHAR) == (NCT_ITYPE($1) == 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_put_varm_$1(BAD_ID, i, start, edge, stride, imap, value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_varm_$1(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++) {
- if (var_dimid[i][j] > 0) { /* skip record dim */
- start[j] = var_shape[i][j];
- err = nc_put_varm_$1(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 start: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_varm_$1(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_put_varm_$1(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 */
- /* 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];
- }
- }
-*/
- 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_$1(var_type[i], var_rank[i], index2,
- NCT_ITYPE($1));
- allInExtRange = allInExtRange
- && inRange3(value[j], var_type[i], NCT_ITYPE($1));
- }
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_varm_$1(ncid,i,NULL,NULL,NULL,NULL,value);
- else
- err = nc_put_varm_$1(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);
- }
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- check_vars_$1(scratch);
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-')dnl
-
-TEST_NC_PUT_VARM(text)
-TEST_NC_PUT_VARM(uchar)
-TEST_NC_PUT_VARM(schar)
-TEST_NC_PUT_VARM(short)
-TEST_NC_PUT_VARM(int)
-TEST_NC_PUT_VARM(long)
-TEST_NC_PUT_VARM(float)
-TEST_NC_PUT_VARM(double)
-
-
-void
-test_nc_put_att_text(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- text value[MAX_NELS];
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- def_vars(ncid);
-
- {
- const char *const tval = "value for bad name";
- const size_t tval_len = strlen(tval);
-
- err = nc_put_att_text(ncid, 0, "", tval_len, tval);
- IF (err != NC_EBADNAME)
- error("should be NC_EBADNAME: status = %d", err);
- }
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (ATT_TYPE(i,j) == NC_CHAR) {
- assert(ATT_LEN(i,j) <= MAX_NELS);
- err = nc_put_att_text(BAD_ID, i, ATT_NAME(i,j), ATT_LEN(i,j),
- value);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_att_text(ncid, BAD_VARID, ATT_NAME(i,j),
- ATT_LEN(i,j), value);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- for (k = 0; k < ATT_LEN(i,j); k++) {
- value[k] = hash(ATT_TYPE(i,j), -1, &k);
- }
- err = nc_put_att_text(ncid, i, ATT_NAME(i,j),
- ATT_LEN(i,j), value);
- IF (err) {
- error("%s", nc_strerror(err));
- }
- }
- }
- }
-
- check_atts_text(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);
-}
-
-
-dnl TEST_NC_PUT_ATT(TYPE) numeric only
-dnl
-define(`TEST_NC_PUT_ATT',dnl
-`dnl
-void
-test_nc_put_att_$1(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- $1 value[MAX_NELS];
- int allInExtRange; /* all values within external range? */
-
- err = nc_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 < NVARS; 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_$1(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_$1(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_$1(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_$1(ATT_TYPE(i,j), -1, &k, NCT_ITYPE($1));
- allInExtRange = allInExtRange
- && inRange3(value[k], ATT_TYPE(i,j), NCT_ITYPE($1));
- }
- err = nc_put_att_$1(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_$1(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);
-}
-')dnl
-
-TEST_NC_PUT_ATT(uchar)
-TEST_NC_PUT_ATT(schar)
-TEST_NC_PUT_ATT(short)
-TEST_NC_PUT_ATT(int)
-TEST_NC_PUT_ATT(long)
-TEST_NC_PUT_ATT(float)
-TEST_NC_PUT_ATT(double)
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_read.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_read.c
deleted file mode 100644
index b68dfeb..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_read.c
+++ /dev/null
@@ -1,1604 +0,0 @@
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: test_read.c,v 1.1.1.1 2005/06/14 04:38:29 svitak Exp $
- *********************************************************************/
-
-#include "tests.h"
-
-/*
- * Test nc_strerror.
- * Try on a bad error status.
- * Test for each defined error status.
- */
-void
-test_nc_strerror(void)
-{
- int i;
- const char *message;
-
- static struct {
- int status;
- char *msg;
- } ncerrs[] = {
- {NC_NOERR, "No error"},
- {NC_EBADID, "Not a netCDF id"},
- {NC_ENFILE, "Too many netCDF files open"},
- {NC_EEXIST, "netCDF file exists && NC_NOCLOBBER"},
- {NC_EINVAL, "Invalid argument"},
- {NC_EPERM, "Write to read only"},
- {NC_ENOTINDEFINE, "Operation not allowed in data mode"},
- {NC_EINDEFINE, "Operation not allowed in define mode"},
- {NC_EINVALCOORDS, "Index exceeds dimension bound"},
- {NC_EMAXDIMS, "NC_MAX_DIMS exceeded"},
- {NC_ENAMEINUSE, "String match to name in use"},
- {NC_ENOTATT, "Attribute not found"},
- {NC_EMAXATTS, "NC_MAX_ATTRS exceeded"},
- {NC_EBADTYPE, "Not a netCDF data type or _FillValue type mismatch"},
- {NC_EBADDIM, "Invalid dimension id or name"},
- {NC_EUNLIMPOS, "NC_UNLIMITED in the wrong index"},
- {NC_EMAXVARS, "NC_MAX_VARS exceeded"},
- {NC_ENOTVAR, "Variable not found"},
- {NC_EGLOBAL, "Action prohibited on NC_GLOBAL varid"},
- {NC_ENOTNC, "Not a netCDF file"},
- {NC_ESTS, "In Fortran, string too short"},
- {NC_EMAXNAME, "NC_MAX_NAME exceeded"},
- {NC_EUNLIMIT, "NC_UNLIMITED size already in use"},
- {NC_ENORECVARS, "nc_rec op when there are no record vars"},
- {NC_ECHAR, "Attempt to convert between text & numbers"},
- {NC_EEDGE, "Edge+start exceeds dimension bound"},
- {NC_ESTRIDE, "Illegal stride"},
- {NC_EBADNAME, "Attribute or variable name contains illegal characters"},
- {NC_ERANGE, "Numeric conversion not representable"},
- {NC_ENOMEM, "Memory allocation (malloc) failure"},
- };
-
- /* Try on a bad error status */
- message = nc_strerror(-666);/* should fail */
- IF (strcmp(message, "Unknown Error") != 0)
- error("nc_strerror on bad error status returned: %s", message);
-
- /* Try on each legitimate error status */
- for (i=0; i<LEN_OF(ncerrs); i++) {
- const char *message = nc_strerror(ncerrs[i].status);
- IF (strcmp(message, ncerrs[i].msg) != 0)
- error("nc_strerror(%d) should return `%s', not `%s'",
- ncerrs[i].status, ncerrs[i].msg, message);
- }
-}
-
-
-/*
- * Test nc_open.
- * If in read-only section of tests,
- * Try to open a non-existent netCDF file, check error return.
- * Open a file that is not a netCDF file, check error return.
- * Open a netCDF file with a bad mode argument, check error return.
- * Open a netCDF file with NC_NOWRITE mode, try to write, check error.
- * Try to open a netcdf twice, check whether returned netcdf ids different.
- * If in writable section of tests,
- * Open a netCDF file with NC_WRITE mode, write something, close it.
- * On exit, any open netCDF files are closed.
- */
-void
-test_nc_open(void)
-{
- int err;
- int ncid;
- int ncid2;
-
- /* Try to open a nonexistent file */
- err = nc_open("tooth-fairy.nc", NC_NOWRITE, &ncid);/* should fail */
- IF (err == NC_NOERR)
- error("nc_open of nonexistent file should have failed");
- IF (! NC_ISSYSERR(err))
- error("nc_open of nonexistent file should have returned system error");
-
- /* Open a file that is not a netCDF file. */
- err = nc_open("tests.h", NC_NOWRITE, &ncid);/* should fail */
- IF (err != NC_ENOTNC)
- 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);
- 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);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- else {
- (void) nc_close(ncid2);
- }
- IF (ncid2 == ncid)
- error("netCDF IDs for first and second nc_open calls should differ");
-
- if (! read_only) { /* tests using netCDF scratch file */
- err = nc_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);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- else
- (void) nc_close(ncid2);
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-/*
- * Test nc_close.
- * Try to close a netCDF file twice, check whether second close fails.
- * Try on bad handle, check error return.
- * Try in define mode and data mode.
- */
-void
-test_nc_close(void)
-{
- int ncid;
- int err = nc_open(testfile, NC_NOWRITE, &ncid);
-
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- /* Close a netCDF file twice, second time should fail */
- err = nc_close(ncid);
- IF (err)
- error("nc_close failed: %s", nc_strerror(err));
- err = nc_close(ncid);
- IF (err != NC_EBADID)
- error("nc_close of closed file should have failed");
-
- /* Try with a bad netCDF ID */
- err = nc_close(BAD_ID);/* should fail */
- IF (err != NC_EBADID)
- error("nc_close with bad netCDF ID returned wrong error (%d)", err);
-
- /* Close in data mode */
- err = nc_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));
-
- if (! read_only) { /* tests using netCDF scratch file */
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err)
- error("nc_create: %s", nc_strerror(err));
- err = nc_close(ncid);
- IF (err)
- error("nc_close in define mode: %s", nc_strerror(err));
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
- }
-}
-
-
-/*
- * Test nc_inq.
- * Try on bad handle, check error return.
- * Try in data mode, check returned values.
- * Try asking for subsets of info.
- * If in writable section of tests,
- * Try in define mode, after adding an unlimited dimension, variable.
- * On exit, any open netCDF files are closed.
- */
-void
-test_nc_inq(void)
-{
- int ncid;
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int ngatts; /* number of global attributes */
- int recdim; /* id of unlimited dimension */
- int err = nc_open(testfile, NC_NOWRITE, &ncid);
-
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- /* Try on bad handle */
- err = nc_inq(BAD_ID, 0, 0, 0, 0);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- err = nc_inq(ncid, &ndims, &nvars, &ngatts, &recdim);
- IF (err)
- 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)
- error("nc_inq: wrong number of variables returned, %d", nvars);
- else IF (ngatts != NGATTS)
- 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);
-
- /* Inguire for no info (useless, but should still work) */
- err = nc_inq(ncid, 0, 0, 0, 0);
- IF (err)
- error("nc_inq for no info failed: %s", nc_strerror(err));
-
- /* Inguire for subsets of info */
- ngatts = NGATTS - 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)
- error("nc_inq subset: wrong number of global atts returned, %d", ngatts);
- ndims = NDIMS - 1;
- nvars = NVARS - 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)
- error("nc_inq subset: wrong number of variables returned, %d", nvars);
-
- if (! read_only) { /* tests using netCDF scratch file */
- int ncid2; /* for scratch netCDF dataset */
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid2);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- } else { /* add dim, var, gatt, check inq */
- int ndims0;
- int nvars0;
- int ngatts0;
- int recdim0;
- err = nc_enddef(ncid2); /* enter data mode */
- err = nc_inq(ncid2, &ndims0, &nvars0, &ngatts0, &recdim0);
- IF (err)
- error("nc_inq: %s", nc_strerror(err));
- err = nc_redef(ncid2); /* enter define mode */
- /* Check that inquire still works in define mode */
- err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim);
- IF (err)
- error("nc_inq in define mode: %s", nc_strerror(err));
- else IF (ndims != ndims0)
- error("nc_inq in define mode: ndims wrong, %d", ndims);
- else IF (nvars != nvars0)
- error("nc_inq in define mode: nvars wrong, %d", nvars);
- else IF (ngatts != ngatts0)
- error("nc_inq in define mode: ngatts wrong, %d", ngatts);
- else IF (recdim != recdim0)
- error("nc_inq in define mode: recdim wrong, %d", recdim);
-
- {
- int did, vid;
- /* Add dim, var, global att */
- err = nc_def_dim(ncid2, "inqd", 1L, &did);
- IF (err)
- error("nc_def_dim: %s", nc_strerror(err));
- err = nc_def_var(ncid2, "inqv", NC_FLOAT, 0, 0, &vid);
- IF (err)
- error("nc_def_var: %s", nc_strerror(err));
- }
- err = nc_put_att_text(ncid2, NC_GLOBAL, "inqa", 1+strlen("stuff"),
- "stuff");
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
-
- /* Make sure nc_inq sees the additions while in define mode */
- err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim);
- IF (err)
- error("nc_inq in define mode: %s", nc_strerror(err));
- else IF (ndims != ndims0 + 1)
- error("nc_inq in define mode: ndims wrong, %d", ndims);
- else IF (nvars != nvars0 + 1)
- error("nc_inq in define mode: nvars wrong, %d", nvars);
- else IF (ngatts != ngatts0 + 1)
- error("nc_inq in define mode: ngatts wrong, %d", ngatts);
- err = nc_enddef(ncid2);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
-
- /* Make sure nc_inq stills sees additions in data mode */
- err = nc_inq(ncid2, &ndims, &nvars, &ngatts, &recdim);
- IF (err)
- error("nc_inq failed in data mode: %s", nc_strerror(err));
- else IF (ndims != ndims0 + 1)
- error("nc_inq in define mode: ndims wrong, %d", ndims);
- else IF (nvars != nvars0 + 1)
- error("nc_inq in define mode: nvars wrong, %d", nvars);
- else IF (ngatts != ngatts0 + 1)
- error("nc_inq in define mode: ngatts wrong, %d", ngatts);
- (void) nc_close(ncid2);
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_natts(void)
-{
- int ncid;
- int ngatts; /* number of global attributes */
- int err;
-
- err = nc_inq_natts(BAD_ID, &ngatts);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_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)
- error("nc_inq_natts: wrong number of global atts returned, %d", ngatts);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_ndims(void)
-{
- int ncid;
- int ndims;
- int err;
-
- err = nc_inq_ndims(BAD_ID, &ndims);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq_ndims(ncid, &ndims);
- IF (err)
- error("nc_inq_ndims: %s", nc_strerror(err));
- else IF (ndims != NDIMS)
- error("nc_inq_ndims: wrong number returned, %d", ndims);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_nvars(void)
-{
- int ncid;
- int nvars;
- int err;
-
- err = nc_inq_nvars(BAD_ID, &nvars);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_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)
- error("nc_inq_nvars: wrong number returned, %d", nvars);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_unlimdim(void)
-{
- int ncid;
- int unlimdim;
- int err;
-
- err = nc_inq_unlimdim(BAD_ID, &unlimdim);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq_unlimdim(ncid, &unlimdim);
- IF (err)
- error("nc_inq_unlimdim: %s", nc_strerror(err));
- else IF (unlimdim != RECDIM)
- error("nc_inq_unlimdim: wrong number returned, %d", unlimdim);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_dimid(void)
-{
- int ncid;
- int dimid;
- int i;
- int err;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq_dimid(ncid, "noSuch", &dimid);
- IF (err != NC_EBADDIM)
- error("bad dim name: status = %d", err);
- for (i = 0; i < NDIMS; i++) {
- err = nc_inq_dimid(BAD_ID, dim_name[i], &dimid);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_dimid(ncid, dim_name[i], &dimid);
- IF (err)
- error("nc_inq_dimid: %s", nc_strerror(err));
- else IF (dimid != i)
- error("expected %d, got %d", i, dimid);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_dim(void)
-{
- int ncid;
- int i;
- int err;
- char name[NC_MAX_NAME];
- size_t length;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NDIMS; i++) {
- err = nc_inq_dim(BAD_ID, i, name, &length);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_dim(ncid, BAD_DIMID, name, &length);
- IF (err != NC_EBADDIM)
- error("bad dimid: status = %d", err);
- err = nc_inq_dim(ncid, i, 0, 0);
- IF (err)
- error("nc_inq_dim: %s", nc_strerror(err));
- err = nc_inq_dim(ncid, i, name, &length);
- IF (err)
- error("nc_inq_dim: %s", nc_strerror(err));
- else IF (strcmp(dim_name[i],name))
- error("name expected: %s, got: %s",dim_name[i],name);
- else IF (dim_len[i] != length)
- error("size expected: %d, got: %d",dim_len[i],length);
- err = nc_inq_dim(ncid, i, name, 0);
- IF (err)
- error("nc_inq_dim: %s", nc_strerror(err));
- else IF (strcmp(dim_name[i],name))
- error("name expected: %s, got: %s",dim_name[i],name);
- err = nc_inq_dim(ncid, i, 0, &length);
- IF (err)
- error("nc_inq_dim: %s", nc_strerror(err));
- else IF (dim_len[i] != length)
- error("size expected: %d, got: %d",dim_len[i],length);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_dimlen(void)
-{
- int ncid;
- int i;
- int err;
- size_t length;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NDIMS; i++) {
- err = nc_inq_dimlen(BAD_ID, i, &length);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_dimlen(ncid, BAD_DIMID, &length);
- IF (err != NC_EBADDIM)
- error("bad dimid: status = %d", err);
- err = nc_inq_dimlen(ncid, i, &length);
- IF (err)
- error("nc_inq_dimlen: %s", nc_strerror(err));
- else IF (dim_len[i] != length)
- error("size expected: %d, got: %d",dim_len[i],length);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_dimname(void)
-{
- int ncid;
- int i;
- int err;
- char name[NC_MAX_NAME];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NDIMS; i++) {
- err = nc_inq_dimname(BAD_ID, i, name);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_dimname(ncid, BAD_DIMID, name);
- IF (err != NC_EBADDIM)
- error("bad dimid: status = %d", err);
- err = nc_inq_dimname(ncid, i, name);
- IF (err)
- error("nc_inq_dimname: %s", nc_strerror(err));
- else IF (strcmp(dim_name[i],name))
- error("name expected: %s, got: %s",dim_name[i],name);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_varid(void)
-{
- int ncid;
- int varid;
- int i;
- int err;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- err = nc_inq_varid(ncid, "noSuch", &varid);
- IF (err != NC_ENOTVAR)
- error("bad ncid: status = %d", err);
-
- for (i = 0; i < NVARS; i++) {
- err = nc_inq_varid(BAD_ID, var_name[i], &varid);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_varid(ncid, var_name[i], &varid);
- IF (err)
- error("nc_inq_varid: %s", nc_strerror(err));
- else IF (varid != i)
- error("expected %d, got %d", i, varid);
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_var(void)
-{
- int ncid;
- int i;
- int err;
- char name[NC_MAX_NAME];
- nc_type datatype;
- int ndims;
- int dimids[MAX_RANK];
- int natts;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- err = nc_inq_var(BAD_ID, i, name, &datatype, &ndims, dimids, &natts);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_var(ncid,BAD_VARID,name,&datatype,&ndims,dimids,&natts);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_var(ncid, i, 0, 0, 0, 0, 0);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, &natts);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- else IF (strcmp(var_name[i],name))
- error("name expected: %s, got: %s",var_name[i],name);
- else IF (var_type[i] != datatype)
- error("type expected: %d, got: %d",var_type[i],datatype);
- else IF (var_rank[i] != ndims)
- error("ndims expected: %d, got: %d",var_rank[i],ndims);
- else IF (!int_vec_eq(var_dimid[i],dimids,ndims))
- error("unexpected dimid");
- else IF (var_natts[i] != natts)
- error("natts expected: %d, got: %d",var_natts[i],natts);
- err = nc_inq_var(ncid, i, name, 0, 0, 0, 0);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- else IF (strcmp(var_name[i],name))
- error("name expected: %s, got: %s",var_name[i],name);
- err = nc_inq_var(ncid, i, 0, &datatype, 0, 0, 0);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- else IF (var_type[i] != datatype)
- error("type expected: %d, got: %d",var_type[i],datatype);
- err = nc_inq_var(ncid, i, 0, 0, &ndims, 0, 0);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- else IF (var_rank[i] != ndims)
- error("ndims expected: %d, got: %d",var_rank[i],ndims);
- err = nc_inq_var(ncid, i, 0, 0, 0, dimids, 0);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- else IF (!int_vec_eq(var_dimid[i],dimids,ndims))
- error("unexpected dimid");
- err = nc_inq_var(ncid, i, 0, 0, 0, 0, &natts);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- else IF (var_natts[i] != natts)
- error("natts expected: %d, got: %d",var_natts[i],natts);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_vardimid(void)
-{
- int ncid;
- int i;
- int err;
- int dimids[MAX_RANK];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- err = nc_inq_vardimid(BAD_ID, i, dimids);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_vardimid(ncid, BAD_VARID, dimids);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_vardimid(ncid, i, dimids);
- IF (err)
- error("nc_inq_vardimid: %s", nc_strerror(err));
- else IF (!int_vec_eq(var_dimid[i], dimids, var_rank[i]))
- error("unexpected dimid");
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_varname(void)
-{
- int ncid;
- int i;
- int err;
- char name[NC_MAX_NAME];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- err = nc_inq_varname(BAD_ID, i, name);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_varname(ncid, BAD_VARID, name);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_varname(ncid, i, name);
- IF (err)
- error("nc_inq_varname: %s", nc_strerror(err));
- else IF (strcmp(var_name[i],name))
- error("name expected: %s, got: %s",var_name[i],name);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_varnatts(void)
-{
- int ncid;
- int i;
- int err;
- int natts;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = -1; i < NVARS; i++) {
- err = nc_inq_varnatts(BAD_ID, i, &natts);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_varnatts(ncid, BAD_VARID, &natts);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_varnatts(ncid, VARID(i), &natts);
- IF (err)
- error("nc_inq_varnatts: %s", nc_strerror(err));
- else IF (NATTS(i) != natts)
- error("natts expected: %d, got: %d",NATTS(i),natts);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_varndims(void)
-{
- int ncid;
- int i;
- int err;
- int ndims;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- err = nc_inq_varndims(BAD_ID, i, &ndims);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_varndims(ncid, BAD_VARID, &ndims);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_varndims(ncid, i, &ndims);
- IF (err)
- error("nc_inq_varndims: %s", nc_strerror(err));
- else IF (var_rank[i] != ndims)
- error("ndims expected: %d, got: %d",var_rank[i],ndims);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_vartype(void)
-{
- int ncid;
- int i;
- int err;
- nc_type datatype;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- err = nc_inq_vartype(BAD_ID, i, &datatype);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_vartype(ncid, BAD_VARID, &datatype);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_vartype(ncid, i, &datatype);
- IF (err)
- error("nc_inq_vartype: %s", nc_strerror(err));
- else IF (var_type[i] != datatype)
- error("type expected: %d, got: %d", var_type[i], datatype);
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-#ifdef TEST_VOIDSTAR
-/*
- * Test nc_put_var1
- */
-void
-test_nc_get_var1(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- size_t index[MAX_RANK];
- double expect;
- int nok = 0; /* count of valid comparisons */
- double buf[1]; /* (void *) buffer */
- double value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_get_var1(BAD_ID, i, index, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_var1(ncid, BAD_VARID, index, buf);
- 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(ncid, i, index, buf);
- 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 2");
- expect = hash( var_type[i], var_rank[i], index );
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_var1(ncid, i, NULL, buf);
- else
- err = nc_get_var1(ncid, i, index, buf);
- IF (err)
- error("%s", nc_strerror(err));
- err = nc2dbl( var_type[i], buf, &value );
- IF (err)
- error("error in nc2dbl");
- if (inRange(expect,var_type[i])) {
- IF (!equal(value,expect,var_type[i],NCT_DOUBLE)) {
- error("expected: %G, got: %G", expect, value);
- } else {
- nok++;
- }
- }
- }
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- print_nok(nok);
-}
-
-
-/*
- * Test nc_get_vara
- * Choose a random point dividing each dim into 2 parts
- * Get 2^rank (nslabs) slabs so defined
- * Each get overwrites buffer, so check after each get.
- */
-void
-test_nc_get_vara(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nels;
- int nslabs;
- int nok = 0; /* count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double expect;
- double got;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- 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_get_vara(BAD_ID, i, start, edge, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vara(ncid, BAD_VARID, start, edge, buf);
- 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_vara(ncid, i, start, edge, buf);
- IF (err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vara(ncid, i, start, edge, buf);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- 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];
- }
- nels *= edge[j];
- }
- if (var_rank[i] == 0 && i%2 )
- err = nc_get_vara(ncid, i, NULL, NULL, buf);
- else
- err = nc_get_vara(ncid, i, start, edge, buf);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- for (j = 0; j < nels; j++) {
- p = (char *) buf;
- p += j * nctypelen(var_type[i]);
- err = nc2dbl( var_type[i], p, & got );
- IF (err)
- error("error in nc2dbl");
- err = toMixedBase(j, var_rank[i], edge, index);
- IF (err)
- error("error in toMixedBase 1");
- for (d = 0; d < var_rank[i]; d++)
- index[d] += start[d];
- expect = hash(var_type[i], var_rank[i], index);
- if (inRange(expect,var_type[i])) {
- IF (!equal(got,expect,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);
- error("got: %g", got);
- }
- } else {
- nok++;
- }
- }
- }
- }
- }
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- print_nok(nok);
-}
-
-
-/*
- * Test nc_get_vars
- * Choose a random point dividing each dim into 2 parts
- * Get 2^rank (nslabs) slabs so defined
- * Each get overwrites buffer, so check after each get.
- */
-void
-test_nc_get_vars(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 */
- int nok = 0; /* total count of valid comparisons */
- int n; /* count of valid comparisons within var */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t index2[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t count[MAX_RANK];
- size_t sstride[MAX_RANK];
- ptrdiff_t stride[MAX_RANK];
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double expect;
- double got;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- 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(BAD_ID, i, start, edge, stride, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_vars(ncid, BAD_VARID, start, edge, stride, buf);
- 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(ncid, i, start, edge, stride, buf);
- IF (err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_vars(ncid, i, start, edge, stride, buf);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_vars(ncid, i, start, edge, stride, buf);
- 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 */
- n = 0;
- for (k = 0; k < nslabs; k++) {
- nstarts = 1;
- for (j = 0; j < var_rank[i]; j++) {
- if ((k >> j) & 1) {
- start[j] = 0;
- edge[j] = mid[j];
- }else{
- start[j] = mid[j];
- edge[j] = var_shape[i][j] - mid[j];
- }
- sstride[j] = 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 && i%2 )
- err = nc_get_vars(ncid, i, NULL, NULL, NULL, buf);
- else
- err = nc_get_vars(ncid, i, index, count, stride, buf);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- for (j = 0; j < nels; j++) {
- p = (char *) buf;
- p += j * nctypelen(var_type[i]);
- err = nc2dbl( var_type[i], p, & got );
- IF (err)
- error("error in nc2dbl");
- 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 = hash(var_type[i], var_rank[i], index2);
- if (inRange(expect,var_type[i])) {
- IF (!equal(got,expect,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);
- error("got: %g ", got);
- }
- } else {
- nok++;
- }
- }
- n++;
- }
- }
- }
- }
- IF (n != var_nels[i]) {
- error("count != nels");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ", var_name[i]);
- error("count: %d, ", n);
- error("nels: %d ", var_nels[i]);
- }
- }
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- print_nok(nok);
-}
-
-
-/*
- * Test nc_get_varm
- * Choose a random point dividing each dim into 2 parts
- * Get 2^rank (nslabs) slabs so defined
- * Choose random stride from 1 to edge
- * Buffer should end up being bit image of external variable.
- * So all gets for a variable store in different elements of buffer
- */
-void
-test_nc_get_varm(void)
-{
- int ncid;
- int i;
- int j;
- int k;
- int m;
- int err;
- int nslabs;
- int nstarts; /* number of different starts */
- int nok = 0; /* total count of valid comparisons */
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- size_t count[MAX_RANK];
- size_t sstride[MAX_RANK];
- ptrdiff_t stride[MAX_RANK];
- ptrdiff_t imap[MAX_RANK];
- ptrdiff_t imap2[MAX_RANK];
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double expect;
- double got;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- 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;
- }
- if (var_rank[i] > 0) {
- j = var_rank[i] - 1;
- imap[j] = nctypelen(var_type[i]);
- for (; j > 0; j--)
- imap[j-1] = imap[j] * var_shape[i][j];
- }
- err = nc_get_varm(BAD_ID, i, start, edge, stride, imap, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_varm(ncid, BAD_VARID, start, edge, stride, imap, buf);
- 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(ncid, i, start, edge, stride, imap, buf);
- IF (err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_get_varm(ncid, i, start, edge, stride, imap, buf);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_get_varm(ncid, i, start, edge, stride, imap, buf);
- 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;
- imap2[j] = imap[j] * sstride[j];
- nstarts *= stride[j];
- }
- for (m = 0; m < nstarts; m++) {
- if (var_rank[i] == 0 && i%2 ) {
- err = nc_get_varm(ncid, i, NULL, NULL, NULL, NULL, buf);
- } else {
- err = toMixedBase(m, var_rank[i], sstride, index);
- IF (err)
- error("error in toMixedBase");
- for (j = 0; j < var_rank[i]; j++) {
- count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
- index[j] += start[j];
- }
- /* Random choice of forward or backward */
-/* TODO
- if ( roll(2) ) {
- for (j = 0; j < var_rank[i]; j++) {
- index[j] += (count[j] - 1) * stride[j];
- stride[j] = -stride[j];
- }
- }
- */
- j = fromMixedBase(var_rank[i], index, var_shape[i]);
- p = (char *) buf + j * nctypelen(var_type[i]);
- err = nc_get_varm(ncid, i, index, count, stride, imap2, p);
- }
- IF (err)
- error("%s", nc_strerror(err));
- }
- }
- p = (char *) buf;
- for (j = 0; j < var_nels[i]; j++) {
- err = toMixedBase(j, var_rank[i], var_shape[i], index);
- IF (err)
- error("error in toMixedBase");
- expect = hash( var_type[i], var_rank[i], index);
- err = nc2dbl( var_type[i], p, & got );
- IF (err)
- error("error in nc2dbl");
- if (inRange(expect,var_type[i])) {
- IF (!equal(got,expect,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);
- error("got: %g ", got);
- }
- } else {
- nok++;
- }
- }
- p += nctypelen(var_type[i]);
- }
- }
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- print_nok(nok);
-}
-
-
-void
-test_nc_get_att(void)
-{
- int ncid;
- int i;
- int j;
- size_t k;
- int err;
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double expect;
- double got;
- int nok = 0; /* count of valid comparisons */
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- err = nc_get_att(BAD_ID, i, ATT_NAME(i,j), buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_get_att(ncid, BAD_VARID, ATT_NAME(i,j), buf);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_get_att(ncid, i, "noSuch", buf);
- IF (err != NC_ENOTATT)
- error("Bad attribute name: status = %d", err);
- err = nc_get_att(ncid, i, ATT_NAME(i,j), buf);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- for (k = 0; k < ATT_LEN(i,j); k++) {
- expect = hash(ATT_TYPE(i,j), -1, &k );
- p = (char *) buf;
- p += k * nctypelen(ATT_TYPE(i,j));
- err = nc2dbl( ATT_TYPE(i,j), p, &got );
- IF (err)
- error("error in nc2dbl");
- if (inRange(expect,ATT_TYPE(i,j))) {
- IF (!equal(got,expect,ATT_TYPE(i,j),NCT_DOUBLE)) {
- error("value read not that expected");
- if (verbose) {
- error("\n");
- error("varid: %d, ", i);
- error("var_name: %s, ",
- i >= 0 ? var_name[i] : "Global");
- error("att_name: %s, ", ATT_NAME(i,j));
- error("element number: %d\n", k);
- error("expect: %-23.16e\n", expect);
- error(" got: %-23.16e", got);
- }
- } else {
- nok++;
- }
- }
- }
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- print_nok(nok);
-}
-#endif /* TEST_VOIDSTAR */
-
-
-void
-test_nc_inq_att(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- nc_type t;
- size_t n;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- err = nc_inq_att(BAD_ID, i, ATT_NAME(i,j), &t, &n);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_att(ncid, BAD_VARID, ATT_NAME(i,j), &t, &n);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_att(ncid, i, "noSuch", &t, &n);
- IF (err != NC_ENOTATT)
- error("Bad attribute name: status = %d", err);
- err = nc_inq_att(ncid, i, ATT_NAME(i,j), &t, &n);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (t != ATT_TYPE(i,j))
- error("type not that expected");
- IF (n != ATT_LEN(i,j))
- error("length not that expected");
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_attlen(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- size_t len;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- err = nc_inq_attlen(ncid, i, "noSuch", &len);
- IF (err != NC_ENOTATT)
- error("Bad attribute name: status = %d", err);
- for (j = 0; j < NATTS(i); j++) {
- err = nc_inq_attlen(BAD_ID, i, ATT_NAME(i,j), &len);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_attlen(ncid, BAD_VARID, ATT_NAME(i,j), &len);
- IF (err != NC_ENOTVAR)
- error("bad varid: status = %d", err);
- err = nc_inq_attlen(ncid, i, ATT_NAME(i,j), &len);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (len != ATT_LEN(i,j))
- error("len not that expected");
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_atttype(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- nc_type datatype;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- err = nc_inq_atttype(ncid, i, "noSuch", &datatype);
- IF (err != NC_ENOTATT)
- error("Bad attribute name: status = %d", err);
- for (j = 0; j < NATTS(i); j++) {
- err = nc_inq_atttype(BAD_ID, i, ATT_NAME(i,j), &datatype);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_atttype(ncid, BAD_VARID, ATT_NAME(i,j), &datatype);
- IF (err != NC_ENOTVAR)
- error("bad varid: status = %d", err);
- err = nc_inq_atttype(ncid, i, ATT_NAME(i,j), &datatype);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (datatype != ATT_TYPE(i,j))
- error("type not that expected");
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_attname(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- char name[NC_MAX_NAME];
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- err = nc_inq_attname(ncid, i, BAD_ATTNUM, name);
- IF (err != NC_ENOTATT)
- error("Bad attribute number: status = %d", err);
- err = nc_inq_attname(ncid, i, NATTS(i), name);
- IF (err != NC_ENOTATT)
- error("Bad attribute number: status = %d", err);
- for (j = 0; j < NATTS(i); j++) {
- err = nc_inq_attname(BAD_ID, i, j, name);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_attname(ncid, BAD_VARID, j, name);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_inq_attname(ncid, i, j, name);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (strcmp(ATT_NAME(i,j), name) != 0)
- error("name not that expected");
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-void
-test_nc_inq_attid(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- int attnum;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- err = nc_inq_attid(ncid, i, "noSuch", &attnum);
- IF (err != NC_ENOTATT)
- error("Bad attribute name: status = %d", err);
- for (j = 0; j < NATTS(i); j++) {
- err = nc_inq_attid(BAD_ID, i, ATT_NAME(i,j), &attnum);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_inq_attid(ncid, BAD_VARID, ATT_NAME(i,j), &attnum);
- IF (err != NC_ENOTVAR)
- error("bad varid: status = %d", err);
- err = nc_inq_attid(ncid, i, ATT_NAME(i,j), &attnum);
- IF (err) {
- error("%s", nc_strerror(err));
- } else {
- IF (attnum != j)
- error("attnum not that expected");
- }
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_write.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_write.c
deleted file mode 100644
index 8d0f1e1..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/test_write.c
+++ /dev/null
@@ -1,1921 +0,0 @@
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: test_write.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include "tests.h"
-#include "math.h"
-
-
-/*
- * Test nc_create
- * For mode in NC_NOCLOBBER, NC_CLOBBER do:
- * create netcdf file 'scratch.nc' with no data, close it
- * test that it can be opened, do nc_inq to check nvars = 0, etc.
- * Try again in NC_NOCLOBBER mode, check error return
- * On exit, delete this file
- */
-void
-test_nc_create(void)
-{
- int clobber; /* 0 for NC_NOCLOBBER, 1 for NC_CLOBBER */
- int err;
- int ncid;
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int ngatts; /* number of global attributes */
- int recdim; /* id of unlimited dimension */
-
- for (clobber = 0; clobber < 2; clobber++) {
- err = nc_create(scratch, clobber ? NC_CLOBBER : NC_NOCLOBBER, &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);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq(ncid, &ndims, &nvars, &ngatts, &recdim);
- IF (err)
- error("nc_inq: %s", nc_strerror(err));
- else IF (ndims != 0)
- error("nc_inq: wrong number of dimensions returned, %d", ndims);
- else IF (nvars != 0)
- error("nc_inq: wrong number of variables returned, %d", nvars);
- else IF (ngatts != 0)
- error("nc_inq: wrong number of global atts returned, %d", ngatts);
- else IF (recdim != -1)
- error("nc_inq: wrong record dimension ID returned, %d", recdim);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- }
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err != NC_EEXIST)
- error("attempt to overwrite file: status = %d", err);
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_redef
- * (In fact also tests nc_enddef - called from test_nc_enddef)
- * BAD_ID
- * attempt redef (error) & enddef on read-only file
- * create file, define dims & vars.
- * attempt put var (error)
- * attempt redef (error) & enddef.
- * put vars
- * attempt def new dims (error)
- * redef
- * def new dims, vars.
- * put atts
- * enddef
- * put vars
- * close
- * check file: vars & atts
- */
-void
-test_nc_redef(void)
-{
- int ncid; /* netcdf id */
- /* used to force effective test of ncio->move() in redef */
- size_t sizehint = 8192;
- int dimid; /* dimension id */
- int varid; /* variable id */
- int varid1; /* variable id */
- int err;
- char * title = "Not funny";
- double var;
- char name[NC_MAX_NAME];
- size_t length;
-
- /* BAD_ID tests */
- err = nc_redef(BAD_ID);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_enddef(BAD_ID);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* read-only tests */
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_redef(ncid);
- IF (err != NC_EPERM)
- error("nc_redef in NC_NOWRITE mode: status = %d", err);
- err = nc_enddef(ncid);
- IF (err != NC_ENOTINDEFINE)
- error("nc_redef in NC_NOWRITE mode: status = %d", err);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- /* tests using scratch file */
- err = nc__create(scratch, NC_NOCLOBBER, 0, &sizehint, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- /* limit for ncio implementations which which have infinite chunksize */
- if(sizehint > 32768)
- sizehint = 16384;
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
- err = nc_inq_varid(ncid, "d", &varid);
- IF (err)
- error("nc_inq_varid: %s", nc_strerror(err));
- var = 1.0;
- err = nc_put_var1_double(ncid, varid, NULL, &var);
- IF (err != NC_EINDEFINE)
- error("nc_put_var... in define mode: status = %d", err);
- err = nc_redef(ncid);
- IF (err != NC_EINDEFINE)
- error("nc_redef in define mode: status = %d", err);
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- put_vars(ncid);
- err = nc_def_dim(ncid, "abc", sizehint, &dimid);
- IF (err != NC_ENOTINDEFINE)
- error("nc_def_dim in define mode: status = %d", err);
- err = nc_redef(ncid);
- IF (err)
- error("nc_redef: %s", nc_strerror(err));
-#if 0
- err = nc_set_fill(ncid, NC_NOFILL, NULL);
- IF (err)
- error("nc_set_fill: %s", nc_strerror(err));
-#endif
- err = nc_def_dim(ncid, "abc", sizehint, &dimid);
- IF (err)
- error("nc_def_dim: %s", nc_strerror(err));
- err = nc_def_var(ncid, "abcScalar", NC_INT, 0, NULL, &varid);
- IF (err)
- error("nc_def_var: %s", nc_strerror(err));
- err = nc_def_var(ncid, "abc", NC_INT, 1, &dimid, &varid1);
- IF (err)
- error("nc_def_var: %s", nc_strerror(err));
- {
- int dimids[NDIMS +1];
- int ii = 0;
- for(ii = 0; ii < NDIMS; ii++)
- dimids[ii] = ii;
- dimids[NDIMS] = dimid;
- err = nc_def_var(ncid, "abcRec", NC_INT, NDIMS, dimids, &varid1);
- IF (err)
- error("nc_def_var: %s", nc_strerror(err));
- }
- err = nc_put_att_text(ncid, NC_GLOBAL, "title", 1+strlen(title), title);
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- var = 1.0;
- err = nc_put_var1_double(ncid, varid, NULL, &var);
- IF (err)
- error("nc_put_var1_double: %s", nc_strerror(err));
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- /* check scratch file written as expected */
- check_file(scratch);
- err = nc_open(scratch, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq_dim(ncid, dimid, name, &length);
- IF (err)
- error("nc_inq_dim: %s", nc_strerror(err));
- IF (strcmp(name, "abc") != 0)
- error("Unexpected dim name");
- IF (length != sizehint)
- error("Unexpected dim length");
- err = nc_get_var1_double(ncid, varid, NULL, &var);
- IF (err)
- error("nc_get_var1_double: %s", nc_strerror(err));
- IF (var != 1.0)
- error("nc_get_var1_double: unexpected value");
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_enddef
- * Simply calls test_nc_redef which tests both nc_redef & nc_enddef
- */
-void
-test_nc_enddef(void)
-{
- test_nc_redef();
-}
-
-
-/*
- * Test nc_sync
- * try with bad handle, check error
- * try in define mode, check error
- * try writing with one handle, reading with another on same netCDF
- */
-void
-test_nc_sync(void)
-{
- int ncidw; /* netcdf id for writing */
- int ncidr; /* netcdf id for reading */
- int err;
-
- /* BAD_ID test */
- err = nc_sync(BAD_ID);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* create scratch file & try nc_sync in define mode */
- err = nc_create(scratch, NC_NOCLOBBER, &ncidw);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_sync(ncidw);
- IF (err != NC_EINDEFINE)
- error("nc_sync called in define mode: status = %d", err);
-
- /* write using same handle */
- def_dims(ncidw);
- def_vars(ncidw);
- put_atts(ncidw);
- err = nc_enddef(ncidw);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- put_vars(ncidw);
- err = nc_sync(ncidw);
- IF (err)
- error("nc_sync of ncidw failed: %s", nc_strerror(err));
-
- /* open another handle, nc_sync, read (check) */
- err = nc_open(scratch, NC_NOWRITE, &ncidr);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_sync(ncidr);
- IF (err)
- error("nc_sync of ncidr failed: %s", nc_strerror(err));
- check_dims(ncidr);
- check_atts(ncidr);
- check_vars(ncidr);
-
- /* close both handles */
- err = nc_close(ncidr);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = nc_close(ncidw);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_abort
- * try with bad handle, check error
- * try in define mode before anything written, check that file was deleted
- * try after nc_enddef, nc_redef, define new dims, vars, atts
- * try after writing variable
- */
-void
-test_nc_abort(void)
-{
- int ncid; /* netcdf id */
- int err;
- int ndims;
- int nvars;
- int ngatts;
-
- /* BAD_ID test */
- err = nc_abort(BAD_ID);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* create scratch file & try nc_abort in define mode */
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
- err = nc_abort(ncid);
- IF (err)
- error("nc_abort of ncid failed: %s", nc_strerror(err));
- err = nc_close(ncid); /* should already be closed */
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = remove(scratch); /* should already be deleted */
- IF (!err)
- error("file %s should not exist", scratch);
-
- /*
- * create scratch file
- * do nc_enddef & nc_redef
- * define new dims, vars, atts
- * try nc_abort: should restore previous state (no dims, vars, atts)
- */
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- err = nc_redef(ncid);
- IF (err)
- error("nc_redef: %s", nc_strerror(err));
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
- err = nc_abort(ncid);
- IF (err)
- error("nc_abort of ncid failed: %s", nc_strerror(err));
- 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);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq (ncid, &ndims, &nvars, &ngatts, NULL);
- IF (err)
- error("nc_inq: %s", nc_strerror(err));
- IF (ndims != 0)
- error("ndims should be 0");
- IF (nvars != 0)
- error("nvars should be 0");
- IF (ngatts != 0)
- error("ngatts should be 0");
- err = nc_close (ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- /* try nc_abort in data mode - should just close */
- err = nc_create(scratch, NC_CLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- put_vars(ncid);
- err = nc_abort(ncid);
- IF (err)
- error("nc_abort of ncid failed: %s", nc_strerror(err));
- err = nc_close(ncid); /* should already be closed */
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- check_file(scratch);
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_def_dim
- * try with bad netCDF handle, check error
- * try in data mode, check error
- * check that returned id is one more than previous id
- * try adding same dimension twice, check error
- * try with illegal sizes, check error
- * make sure unlimited size works, shows up in nc_inq_unlimdim
- * try to define a second unlimited dimension, check error
- */
-void
-test_nc_def_dim(void)
-{
- int ncid;
- int err; /* status */
- int i;
- int dimid; /* dimension id */
- size_t length;
-
- /* BAD_ID test */
- err = nc_def_dim(BAD_ID, "abc", 8, &dimid);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* data mode test */
- err = nc_create(scratch, NC_CLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- err = nc_def_dim(ncid, "abc", 8, &dimid);
- IF (err != NC_ENOTINDEFINE)
- error("bad ncid: status = %d", err);
-
- /* define-mode tests: unlimited dim */
- err = nc_redef(ncid);
- IF (err)
- error("nc_redef: %s", nc_strerror(err));
- err = nc_def_dim(ncid, dim_name[0], NC_UNLIMITED, &dimid);
- IF (err)
- error("nc_def_dim: %s", nc_strerror(err));
- IF (dimid != 0)
- error("Unexpected dimid");
- err = nc_inq_unlimdim(ncid, &dimid);
- IF (err)
- error("nc_inq_unlimdim: %s", nc_strerror(err));
- IF (dimid != 0)
- error("Unexpected recdim");
- err = nc_inq_dimlen(ncid, dimid, &length);
- IF (length != 0)
- error("Unexpected length");
- err = nc_def_dim(ncid, "abc", NC_UNLIMITED, &dimid);
- IF (err != NC_EUNLIMIT)
- error("2nd unlimited dimension: status = %d", err);
-
- /* define-mode tests: remaining dims */
- for (i = 1; i < NDIMS; i++) {
- err = nc_def_dim(ncid, dim_name[i-1], dim_len[i], &dimid);
- IF (err != NC_ENAMEINUSE)
- error("duplicate name: status = %d", err);
- err = nc_def_dim(ncid, BAD_NAME, dim_len[i], &dimid);
- IF (err != NC_EBADNAME)
- error("bad name: status = %d", err);
- err = nc_def_dim(ncid, dim_name[i], NC_UNLIMITED-1, &dimid);
- IF (err != NC_EINVAL)
- error("bad size: status = %d", err);
- err = nc_def_dim(ncid, dim_name[i], dim_len[i], &dimid);
- IF (err)
- error("nc_def_dim: %s", nc_strerror(err));
- IF (dimid != i)
- error("Unexpected dimid");
- }
-
- /* Following just to expand unlimited dim */
- def_vars(ncid);
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- put_vars(ncid);
-
- /* Check all dims */
- check_dims(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);
-}
-
-
-/*
- * Test nc_rename_dim
- * try with bad netCDF handle, check error
- * check that proper rename worked with nc_inq_dim
- * try renaming to existing dimension name, check error
- * try with bad dimension handle, check error
- */
-void
-test_nc_rename_dim(void)
-{
- int ncid;
- int err; /* status */
- char name[NC_MAX_NAME];
-
- /* BAD_ID test */
- err = nc_rename_dim(BAD_ID, 0, "abc");
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* main tests */
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- err = nc_rename_dim(ncid, BAD_DIMID, "abc");
- IF (err != NC_EBADDIM)
- error("bad dimid: status = %d", err);
- err = nc_rename_dim(ncid, 2, "abc");
- IF (err)
- error("nc_rename_dim: %s", nc_strerror(err));
- err = nc_inq_dimname(ncid, 2, name);
- IF (strcmp(name, "abc") != 0)
- error("Unexpected name: %s", name);
- err = nc_rename_dim(ncid, 0, "abc");
- IF (err != NC_ENAMEINUSE)
- error("duplicate name: status = %d", err);
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_def_var
- * try with bad netCDF handle, check error
- * try with bad name, check error
- * scalar tests:
- * check that proper define worked with nc_inq_var
- * try redefining an existing variable, check error
- * try with bad datatype, check error
- * try with bad number of dimensions, check error
- * try in data mode, check error
- * check that returned id is one more than previous id
- * try with bad dimension ids, check error
- */
-void
-test_nc_def_var(void)
-{
- int ncid;
- int varid;
- int err; /* status */
- int i;
- int ndims;
- int natts;
- char name[NC_MAX_NAME];
- int dimids[MAX_RANK];
- nc_type datatype;
-
- /* BAD_ID test */
- err = nc_def_var(BAD_ID, "abc", NC_SHORT, 0, NULL, &varid);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* scalar tests */
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_def_var(ncid, "abc", NC_SHORT, 0, NULL, &varid);
- IF (err)
- error("nc_def_var: %s", nc_strerror(err));
- err = nc_inq_var(ncid, varid, name, &datatype, &ndims, dimids, &natts);
- IF (err)
- error("nc_inq_var: %s", nc_strerror(err));
- IF (strcmp(name, "abc") != 0)
- error("Unexpected name: %s", name);
- IF (datatype != NC_SHORT)
- error("Unexpected datatype");
- IF (ndims != 0)
- error("Unexpected rank");
- err = nc_def_var(ncid, BAD_NAME, NC_SHORT, 0, NULL, &varid);
- IF (err != NC_EBADNAME)
- error("bad name: status = %d", err);
- err = nc_def_var(ncid, "abc", NC_SHORT, 0, NULL, &varid);
- IF (err != NC_ENAMEINUSE)
- error("duplicate name: status = %d", err);
- err = nc_def_var(ncid, "ABC", BAD_TYPE, -1, dimids, &varid);
- IF (err != NC_EBADTYPE)
- error("bad type: status = %d", err);
- err = nc_def_var(ncid, "ABC", NC_SHORT, -1, dimids, &varid);
- IF (err != NC_EINVAL)
- error("bad rank: status = %d", err);
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- err = nc_def_var(ncid, "ABC", NC_SHORT, 0, dimids, &varid);
- IF (err != NC_ENOTINDEFINE)
- error("nc_def_var called in data mode: status = %d", err);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-
- /* general tests using global vars */
- err = nc_create(scratch, NC_CLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- for (i = 0; i < NVARS; i++) {
- err = nc_def_var(ncid, var_name[i], var_type[i], var_rank[i],
- var_dimid[i], &varid);
- IF (err)
- error("nc_def_var: %s", nc_strerror(err));
- IF (varid != i)
- error("Unexpected varid");
- }
-
- /* try bad dim ids */
- dimids[0] = BAD_DIMID;
- err = nc_def_var(ncid, "abc", NC_SHORT, 1, dimids, &varid);
- IF (err != NC_EBADDIM)
- error("bad dim ids: status = %d", err);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-#ifdef TEST_VOIDSTAR
-/*
- * Test nc_put_var1
- */
-void
-test_nc_put_var1(void)
-{
- int ncid;
- int i;
- int j;
- int err;
- size_t index[MAX_RANK];
- double value;
- double buf[1]; /* (void *) buffer */
-
- err = nc_create(scratch, NC_NOCLOBBER, &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));
-
- for (i = 0; i < NVARS; i++) {
- for (j = 0; j < var_rank[i]; j++)
- index[j] = 0;
- err = nc_put_var1(BAD_ID, i, index, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_var1(ncid, BAD_VARID, index, buf);
- 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(ncid, i, index, buf);
- 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");
- value = hash( var_type[i], var_rank[i], index);
- if (inRange(value, var_type[i])) {
- err = dbl2nc(value, var_type[i], buf);
- IF (err)
- error("error in dbl2nc");
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_var1(ncid, i, NULL, buf);
- else
- err = nc_put_var1(ncid, i, index, buf);
- IF (err)
- error("%s", nc_strerror(err));
- }
- }
- }
-
- check_vars(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);
-}
-
-
-/*
- * Test nc_put_vara
- * Choose a random point dividing each dim into 2 parts
- * Put 2^rank (nslabs) slabs so defined
- * Redefine buffer for each put.
- * At end check all variables using check_vars
- */
-void
-test_nc_put_vara(void)
-{
- int ncid;
- int d;
- int i;
- int j;
- int k;
- int err;
- int nels;
- int nslabs;
- size_t start[MAX_RANK];
- size_t edge[MAX_RANK];
- size_t index[MAX_RANK];
- size_t mid[MAX_RANK];
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double value;
-
- err = nc_create(scratch, NC_NOCLOBBER, &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));
-
- for (i = 0; i < NVARS; i++) {
- 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(BAD_ID, i, start, edge, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vara(ncid, BAD_VARID, start, edge, buf);
- 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(ncid, i, start, edge, buf);
- IF (err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vara(ncid, i, start, edge, buf);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- 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];
- }
- p = (char *) buf;
- for (j = 0; j < nels; j++) {
- err = toMixedBase(j, var_rank[i], edge, index);
- IF (err)
- error("error in toMixedBase");
- for (d = 0; d < var_rank[i]; d++)
- index[d] += start[d];
- value = hash( var_type[i], var_rank[i], index);
- if (!inRange(value, var_type[i]))
- value = 0;
- err = dbl2nc(value, var_type[i], p);
- IF (err)
- error("error in dbl2nc");
- p += nctypelen(var_type[i]);
- }
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_vara(ncid, i, NULL, NULL, buf);
- else
- err = nc_put_vara(ncid, i, start, edge, buf);
- IF (err) {
- error("%s", nc_strerror(err));
- }
- }
- }
-
- check_vars(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);
-}
-
-
-/*
- * Test nc_put_vars
- * Choose a random point dividing each dim into 2 parts
- * Put 2^rank (nslabs) slabs so defined
- * Choose random stride from 1 to edge
- * Redefine buffer for each put.
- * At end check all variables using check_vars
- */
-void
-test_nc_put_vars(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];
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double value;
-
- err = nc_create(scratch, NC_NOCLOBBER, &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));
-
- for (i = 0; i < NVARS; i++) {
- 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(BAD_ID, i, start, edge, stride, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_vars(ncid, BAD_VARID, start, edge, stride, buf);
- 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_vars(ncid, i, start, edge, stride, buf);
- IF (err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_vars(ncid, i, start, edge, stride, buf);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_put_vars(ncid, i, start, edge, stride, buf);
- 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];
- }
- }
- */
- p = (char *) buf;
- for (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 = hash( var_type[i], var_rank[i], index2);
- if (!inRange(value, var_type[i]))
- value = 0;
- err = dbl2nc(value, var_type[i], p);
- IF (err)
- error("error in dbl2nc");
- p += nctypelen(var_type[i]);
- }
- if (var_rank[i] == 0 && i%2 == 0)
- err = nc_put_vars(ncid, i, NULL, NULL, NULL, buf);
- else
- err = nc_put_vars(ncid, i, index, count, stride, buf);
- IF (err) {
- error("%s", nc_strerror(err));
- }
- }
- }
- }
-
- check_vars(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);
-}
-
-
-/*
- * Test nc_put_varm
- * Choose a random point dividing each dim into 2 parts
- * Put 2^rank (nslabs) slabs so defined
- * Choose random stride from 1 to edge
- * Buffer is bit image of whole external variable.
- * So all puts for a variable put different elements of buffer
- * At end check all variables using check_vars
- */
-void
-test_nc_put_varm(void)
-{
- int ncid;
- int i;
- int j;
- int k;
- int m;
- int err;
- 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 mid[MAX_RANK];
- size_t count[MAX_RANK];
- size_t sstride[MAX_RANK];
- ptrdiff_t stride[MAX_RANK];
- ptrdiff_t imap[MAX_RANK];
- ptrdiff_t imap2[MAX_RANK];
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- double value;
-
- err = nc_create(scratch, NC_NOCLOBBER, &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));
-
- for (i = 0; i < NVARS; i++) {
- 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;
- }
- if (var_rank[i] > 0) {
- j = var_rank[i] - 1;
- imap[j] = nctypelen(var_type[i]);
- for (; j > 0; j--)
- imap[j-1] = imap[j] * var_shape[i][j];
- }
- p = (char *) buf;
- for (j = 0; j < var_nels[i]; j++) {
- err = toMixedBase(j, var_rank[i], var_shape[i], index);
- IF (err)
- error("error in toMixedBase");
- value = hash( var_type[i], var_rank[i], index);
- if (!inRange(value, var_type[i]))
- value = 0;
- err = dbl2nc(value, var_type[i], p);
- IF (err)
- error("error in dbl2nc");
- p += nctypelen(var_type[i]);
- }
- err = nc_put_varm(BAD_ID, i, start, edge, stride, imap, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_varm(ncid, BAD_VARID, start, edge, stride, imap, buf);
- 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_varm(ncid, i, start, edge, stride, imap, buf);
- IF (err != NC_EINVALCOORDS)
- error("bad index: status = %d", err);
- start[j] = 0;
- edge[j] = var_shape[i][j] + 1;
- err = nc_put_varm(ncid, i, start, edge, stride, imap, buf);
- IF (err != NC_EEDGE)
- error("bad edge: status = %d", err);
- edge[j] = 1;
- stride[j] = 0;
- err = nc_put_varm(ncid, i, start, edge, stride, imap, buf);
- 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;
- imap2[j] = imap[j] * sstride[j];
- nstarts *= stride[j];
- }
- for (m = 0; m < nstarts; m++) {
- if (var_rank[i] == 0 && i%2 == 0) {
- err = nc_put_varm(ncid, i, NULL, NULL, NULL, NULL, buf);
- } else {
- err = toMixedBase(m, var_rank[i], sstride, index);
- IF (err)
- error("error in toMixedBase");
- for (j = 0; j < var_rank[i]; j++) {
- count[j] = 1 + (edge[j] - index[j] - 1) / stride[j];
- index[j] += start[j];
- }
- /* Random choice of forward or backward */
-/* TODO
- if ( roll(2) ) {
- for (j = 0; j < var_rank[i]; j++) {
- index[j] += (count[j] - 1) * stride[j];
- stride[j] = -stride[j];
- }
- }
- */
- j = fromMixedBase(var_rank[i], index, var_shape[i]);
- p = (char *) buf + j * nctypelen(var_type[i]);
- err = nc_put_varm(ncid, i, index, count, stride, imap2, p);
- }
- IF (err) {
- error("%s", nc_strerror(err));
- }
- }
- }
- }
-
- check_vars(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);
-}
-#endif /* TEST_VOIDSTAR */
-
-
-/*
- * Test nc_rename_var
- * try with bad netCDF handle, check error
- * try with bad variable handle, check error
- * try renaming to existing variable name, check error
- * check that proper rename worked with nc_inq_varid
- * try in data mode, check error
- */
-void
-test_nc_rename_var(void)
-{
- int ncid;
- int varid;
- int err;
- int i;
- char name[NC_MAX_NAME];
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_rename_var(ncid, BAD_VARID, "newName");
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- def_dims(ncid);
- def_vars(ncid);
-
- /* Prefix "new_" to each name */
- for (i = 0; i < NVARS; 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]);
- IF (err != NC_ENAMEINUSE)
- error("duplicate name: status = %d", err);
- (void) strcpy(name, "new_");
- (void) strcat(name, var_name[i]);
- err = nc_rename_var(ncid, i, name);
- IF (err)
- error("nc_rename_var: %s", nc_strerror(err));
- err = nc_inq_varid(ncid, name, &varid);
- IF (err)
- error("nc_inq_varid: %s", nc_strerror(err));
- IF (varid != i)
- error("Unexpected varid");
- }
-
- /* Change to data mode */
- /* Try making names even longer. Then restore original names */
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- (void) strcpy(name, "even_longer_");
- (void) strcat(name, var_name[i]);
- err = nc_rename_var(ncid, i, name);
- IF (err != NC_ENOTINDEFINE)
- error("longer name in data mode: status = %d", err);
- err = nc_rename_var(ncid, i, var_name[i]);
- IF (err)
- error("nc_rename_var: %s", nc_strerror(err));
- err = nc_inq_varid(ncid, var_name[i], &varid);
- IF (err)
- error("nc_inq_varid: %s", nc_strerror(err));
- IF (varid != i)
- error("Unexpected varid");
- }
-
- put_vars(ncid);
- check_vars(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);
-}
-
-
-#ifdef TEST_VOIDSTAR
-void
-test_nc_put_att(void)
-{
- int ncid;
- int varid;
- int i;
- int j;
- size_t k;
- int err;
- double buf[MAX_NELS]; /* (void *) buffer */
- char *p; /* (void *) pointer */
- char *name; /* of att */
- nc_type datatype; /* of att */
- size_t length; /* of att */
- double value;
-
- err = nc_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 < NVARS; i++) {
- varid = VARID(i);
- for (j = 0; j < NATTS(i); j++) {
- name = ATT_NAME(i,j);
- datatype = ATT_TYPE(i,j);
- length = ATT_LEN(i,j);
- err = nc_put_att(BAD_ID, varid, name, datatype, length, buf);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_put_att(ncid, varid, BAD_NAME, datatype, length, buf);
- IF (err != NC_EBADNAME)
- error("bad name: status = %d", err);
- err = nc_put_att(ncid, BAD_VARID, name, datatype, length, buf);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_put_att(ncid, varid, name, BAD_TYPE, length, buf);
- IF (err != NC_EBADTYPE)
- error("bad type: status = %d", err);
- p = (char *) buf;
- for (k = 0; k < length; k++) {
- value = hash(datatype, -1, &k );
- if (!inRange(value, datatype))
- value = 0;
- err = dbl2nc(value, datatype, p);
- IF (err)
- error("error in dbl2nc");
- p += nctypelen(datatype);
- }
- err = nc_put_att(ncid, varid, name, datatype, length, buf);
- IF (err) {
- error("%s", nc_strerror(err));
- }
- }
- }
-
- check_atts(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);
-}
-#endif /* TEST_VOIDSTAR */
-
-
-/*
- * Test nc_copy_att
- * try with bad source or target netCDF handles, check error
- * try with bad source or target variable handle, check error
- * try with nonexisting attribute, check error
- * check that NC_GLOBAL variable for source or target works
- * check that new attribute put works with target in define mode
- * check that old attribute put works with target in data mode
- * check that changing type and length of an attribute work OK
- * try with same ncid for source and target, different variables
- * try with same ncid for source and target, same variable
- */
-void
-test_nc_copy_att(void)
-{
- int ncid_in;
- int ncid_out;
- int varid;
- int err;
- int i;
- int j;
- char *name; /* of att */
- nc_type datatype; /* of att */
- size_t length; /* of att */
- char value;
-
- err = nc_open(testfile, NC_NOWRITE, &ncid_in);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_create(scratch, NC_NOCLOBBER, &ncid_out);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid_out);
- def_vars(ncid_out);
-
- for (i = -1; i < NVARS; i++) {
- varid = VARID(i);
- for (j = 0; j < NATTS(i); j++) {
- name = ATT_NAME(i,j);
- err = nc_copy_att(ncid_in, BAD_VARID, name, ncid_out, varid);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_copy_att(ncid_in, varid, name, ncid_out, BAD_VARID);
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- err = nc_copy_att(BAD_ID, varid, name, ncid_out, varid);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_copy_att(ncid_in, varid, name, BAD_ID, varid);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_copy_att(ncid_in, varid, "noSuch", ncid_out, varid);
- IF (err != NC_ENOTATT)
- error("bad attname: status = %d", err);
- err = nc_copy_att(ncid_in, varid, name, ncid_out, varid);
- IF (err)
- error("nc_copy_att: %s", nc_strerror(err));
- err = nc_copy_att(ncid_out, varid, name, ncid_out, varid);
- IF (err)
- error("source = target: %s", nc_strerror(err));
- }
- }
-
- err = nc_close(ncid_in);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- /* Close scratch. Reopen & check attributes */
- err = nc_close(ncid_out);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = nc_open(scratch, NC_WRITE, &ncid_out);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- check_atts(ncid_out);
-
- /*
- * change to define mode
- * define single char. global att. ':a' with value 'A'
- * This will be used as source for following copies
- */
- err = nc_redef(ncid_out);
- IF (err)
- error("nc_redef: %s", nc_strerror(err));
- err = nc_put_att_text(ncid_out, NC_GLOBAL, "a", 1, "A");
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
-
- /*
- * change to data mode
- * Use scratch as both source & dest.
- * try copy to existing att. change type & decrease length
- * rename 1st existing att of each var (if any) 'a'
- * if this att. exists them copy ':a' to it
- */
- err = nc_enddef(ncid_out);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- if (NATTS(i) > 0 && ATT_LEN(i,j) > 0) {
- err = nc_rename_att(ncid_out, i, att_name[i][0], "a");
- IF (err)
- error("nc_rename_att: %s", nc_strerror(err));
- err = nc_copy_att(ncid_out, NC_GLOBAL, "a", ncid_out, i);
- IF (err)
- error("nc_copy_att: %s", nc_strerror(err));
- }
- }
- err = nc_close(ncid_out);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- /* Reopen & check */
- err = nc_open(scratch, NC_WRITE, &ncid_out);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- for (i = 0; i < NVARS; i++) {
- if (NATTS(i) > 0 && ATT_LEN(i,j) > 0) {
- err = nc_inq_att(ncid_out, i, "a", &datatype, &length);
- IF (err)
- error("nc_inq_att: %s", nc_strerror(err));
- IF (datatype != NC_CHAR)
- error("Unexpected type");
- IF (length != 1)
- error("Unexpected length");
- err = nc_get_att_text(ncid_out, i, "a", &value);
- IF (err)
- error("nc_get_att_text: %s", nc_strerror(err));
- IF (value != 'A')
- error("Unexpected value");
- }
- }
-
- err = nc_close(ncid_out);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_rename_att
- * try with bad netCDF handle, check error
- * try with bad variable handle, check error
- * try with nonexisting att name, check error
- * try renaming to existing att name, check error
- * check that proper rename worked with nc_inq_attid
- * try in data mode, check error
- */
-void
-test_nc_rename_att(void)
-{
- int ncid;
- int varid;
- int err;
- int i;
- int j;
- size_t k;
- int attnum;
- char *attname;
- char name[NC_MAX_NAME];
- char oldname[NC_MAX_NAME];
- char newname[NC_MAX_NAME];
- int nok = 0; /* count of valid comparisons */
- nc_type datatype;
- nc_type atttype;
- size_t length;
- size_t attlength;
- char text[MAX_NELS];
- double value[MAX_NELS];
- double expect;
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_rename_att(ncid, BAD_VARID, "abc", "newName");
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
-
- for (i = -1; i < NVARS; i++) {
- varid = VARID(i);
- for (j = 0; j < NATTS(i); j++) {
- attname = ATT_NAME(i,j);
- err = nc_rename_att(BAD_ID, varid, attname, "newName");
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_rename_att(ncid, varid, "noSuch", "newName");
- IF (err != NC_ENOTATT)
- error("bad attname: status = %d", err);
- (void) strcpy(newname, "new_");
- (void) strcat(newname, attname);
- err = nc_rename_att(ncid, varid, attname, newname);
- IF (err)
- error("nc_rename_att: %s", nc_strerror(err));
- err = nc_inq_attid(ncid, varid, newname, &attnum);
- IF (err)
- error("nc_inq_attid: %s", nc_strerror(err));
- IF (attnum != j)
- error("Unexpected attnum");
- }
- }
-
- /* Close. Reopen & check */
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = nc_open(scratch, NC_WRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- varid = VARID(i);
- for (j = 0; j < NATTS(i); j++) {
- attname = ATT_NAME(i,j);
- atttype = ATT_TYPE(i,j);
- attlength = ATT_LEN(i,j);
- (void) strcpy(newname, "new_");
- (void) strcat(newname, attname);
- err = nc_inq_attname(ncid, varid, j, name);
- IF (err)
- error("nc_inq_attname: %s", nc_strerror(err));
- IF (strcmp(name, newname) != 0)
- error("nc_inq_attname: unexpected name");
- err = nc_inq_att(ncid, varid, name, &datatype, &length);
- IF (err)
- error("nc_inq_att: %s", nc_strerror(err));
- IF (datatype != atttype)
- error("nc_inq_att: unexpected type");
- IF (length != attlength)
- error("nc_inq_att: unexpected length");
- if (datatype == NC_CHAR) {
- err = nc_get_att_text(ncid, varid, name, text);
- IF (err)
- error("nc_get_att_text: %s", nc_strerror(err));
- for (k = 0; k < attlength; k++) {
- expect = hash(datatype, -1, &k);
- IF (text[k] != expect) {
- error("nc_get_att_text: unexpected value");
- } else {
- nok++;
- }
- }
- } else {
- err = nc_get_att_double(ncid, varid, name, value);
- IF (err)
- error("nc_get_att_double: %s", nc_strerror(err));
- for (k = 0; k < attlength; k++) {
- expect = hash(datatype, -1, &k);
- if (inRange(expect, datatype)) {
- IF (!equal(value[k],expect,datatype,NCT_DOUBLE)) {
- error("nc_get_att_double: unexpected value");
- } else {
- nok++;
- }
- }
- }
- }
- }
- }
- print_nok(nok);
-
- /* Now in data mode */
- /* Try making names even longer. Then restore original names */
-
- for (i = -1; i < NVARS; i++) {
- varid = VARID(i);
- for (j = 0; j < NATTS(i); j++) {
- attname = ATT_NAME(i,j);
- (void) strcpy(oldname, "new_");
- (void) strcat(oldname, attname);
- (void) strcpy(newname, "even_longer_");
- (void) strcat(newname, attname);
- err = nc_rename_att(ncid, varid, oldname, newname);
- IF (err != NC_ENOTINDEFINE)
- error("longer name in data mode: status = %d", err);
- err = nc_rename_att(ncid, varid, oldname, attname);
- IF (err)
- error("nc_rename_att: %s", nc_strerror(err));
- err = nc_inq_attid(ncid, varid, attname, &attnum);
- IF (err)
- error("nc_inq_attid: %s", nc_strerror(err));
- IF (attnum != j)
- error("Unexpected attnum");
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_del_att
- * try with bad netCDF handle, check error
- * try with bad variable handle, check error
- * try with nonexisting att name, check error
- * check that proper delete worked using:
- * nc_inq_attid, nc_inq_natts, nc_inq_varnatts
- */
-void
-test_nc_del_att(void)
-{
- int ncid;
- int err;
- int i;
- int j;
- int attnum;
- int natts;
- int numatts;
- int varid;
- char *name; /* of att */
-
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- err = nc_del_att(ncid, BAD_VARID, "abc");
- IF (err != NC_ENOTVAR)
- error("bad var id: status = %d", err);
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
-
- for (i = -1; i < NVARS; i++) {
- varid = VARID(i);
- numatts = NATTS(i);
- for (j = 0; j < numatts; j++) {
- name = ATT_NAME(i,j);
- err = nc_del_att(BAD_ID, varid, name);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
- err = nc_del_att(ncid, varid, "noSuch");
- IF (err != NC_ENOTATT)
- error("bad attname: status = %d", err);
- err = nc_del_att(ncid, varid, name);
- IF (err)
- error("nc_del_att: %s", nc_strerror(err));
- err = nc_inq_attid(ncid, varid, name, &attnum);
- IF (err != NC_ENOTATT)
- error("bad attname: status = %d", err);
- if (i < 0) {
- err = nc_inq_natts(ncid, &natts);
- IF (err)
- error("nc_inq_natts: %s", nc_strerror(err));
- IF (natts != numatts-j-1)
- error("natts: expected %d, got %d", numatts-j-1, natts);
- }
- err = nc_inq_varnatts(ncid, varid, &natts);
- IF (err)
- error("nc_inq_natts: %s", nc_strerror(err));
- IF (natts != numatts-j-1)
- error("natts: expected %d, got %d", numatts-j-1, natts);
- }
- }
-
- /* Close. Reopen & check no attributes left */
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = nc_open(scratch, NC_WRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_inq_natts(ncid, &natts);
- IF (err)
- 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++) {
- varid = VARID(i);
- err = nc_inq_varnatts(ncid, varid, &natts);
- IF (err)
- error("nc_inq_natts: %s", nc_strerror(err));
- IF (natts != 0)
- error("natts: expected %d, got %d", 0, natts);
- }
-
- /* restore attributes. change to data mode. try to delete */
- err = nc_redef(ncid);
- IF (err)
- error("nc_redef: %s", nc_strerror(err));
- put_atts(ncid);
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
-
- for (i = -1; i < NVARS; i++) {
- varid = VARID(i);
- numatts = NATTS(i);
- for (j = 0; j < numatts; j++) {
- name = ATT_NAME(i,j);
- err = nc_del_att(ncid, varid, name);
- IF (err != NC_ENOTINDEFINE)
- error("in data mode: status = %d", err);
- }
- }
-
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = remove(scratch);
- IF (err)
- error("remove of %s failed", scratch);
-}
-
-
-/*
- * Test nc_set_fill
- * try with bad netCDF handle, check error
- * try in read-only mode, check error
- * try with bad new_fillmode, check error
- * try in data mode, check error
- * check that proper set to NC_FILL works for record & non-record variables
- * (note that it is not possible to test NC_NOFILL mode!)
- * close file & create again for test using attribute _FillValue
- */
-void
-test_nc_set_fill(void)
-{
- int ncid;
- int varid;
- int err;
- int i;
- int j;
- int old_fillmode;
- int nok = 0; /* count of valid comparisons */
- char text = 0;
- double value = 0;
- double fill;
- size_t index[MAX_RANK];
-
- /* bad ncid */
- err = nc_set_fill(BAD_ID, NC_NOFILL, &old_fillmode);
- IF (err != NC_EBADID)
- error("bad ncid: status = %d", err);
-
- /* try in read-only mode */
- err = nc_open(testfile, NC_NOWRITE, &ncid);
- IF (err)
- error("nc_open: %s", nc_strerror(err));
- err = nc_set_fill(ncid, NC_NOFILL, &old_fillmode);
- IF (err != NC_EPERM)
- error("read-only: status = %d", err);
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-
- /* create scratch */
- err = nc_create(scratch, NC_NOCLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
-
- /* BAD_FILLMODE */
- err = nc_set_fill(ncid, BAD_FILLMODE, &old_fillmode);
- IF (err != NC_EINVAL)
- error("bad fillmode: status = %d", err);
-
- /* proper calls */
- err = nc_set_fill(ncid, NC_NOFILL, &old_fillmode);
- IF (err)
- error("nc_set_fill: %s", nc_strerror(err));
- IF (old_fillmode != NC_FILL)
- error("Unexpected old fill mode: %d", old_fillmode);
- err = nc_set_fill(ncid, NC_FILL, &old_fillmode);
- IF (err)
- error("nc_set_fill: %s", nc_strerror(err));
- IF (old_fillmode != NC_NOFILL)
- error("Unexpected old fill mode: %d", old_fillmode);
-
- /* define dims & vars */
- def_dims(ncid);
- def_vars(ncid);
-
- /* Change to data mode. Set fillmode again */
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- err = nc_set_fill(ncid, NC_FILL, &old_fillmode);
- IF (err)
- error("nc_set_fill: %s", nc_strerror(err));
- IF (old_fillmode != NC_FILL)
- error("Unexpected old fill mode: %d", old_fillmode);
-
- /* 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;
- err = nc_put_var1_text(ncid, varid, index, &text);
- IF (err)
- error("nc_put_var1_text: %s", nc_strerror(err));
-
- /* get all variables & check all values equal default fill */
- for (i = 0; i < NVARS; i++) {
- switch (var_type[i]) {
- case NC_CHAR: fill = NC_FILL_CHAR; break;
- case NC_BYTE: fill = NC_FILL_BYTE; break;
- case NC_SHORT: fill = NC_FILL_SHORT; break;
- case NC_INT: fill = NC_FILL_INT; break;
- case NC_FLOAT: fill = NC_FILL_FLOAT; break;
- case NC_DOUBLE: fill = NC_FILL_DOUBLE; break;
- default: assert(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");
- if (var_type[i] == NC_CHAR) {
- err = nc_get_var1_text(ncid, i, index, &text);
- IF (err)
- error("nc_get_var1_text failed: %s", nc_strerror(err));
- value = text;
- } else {
- err = nc_get_var1_double(ncid, i, index, &value);
- IF (err)
- error("nc_get_var1_double failed: %s", nc_strerror(err));
- }
- IF (value != fill && fabs((fill - value)/fill) > DBL_EPSILON)
- error("\n\t\tValue expected: %-23.17e,\n\t\t read: %-23.17e\n",
- fill, value);
- else
- nok++;
- }
- }
-
- /* close scratch & create again for test using attribute _FillValue */
- err = nc_close(ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- err = nc_create(scratch, NC_CLOBBER, &ncid);
- IF (err) {
- error("nc_create: %s", nc_strerror(err));
- return;
- }
- def_dims(ncid);
- def_vars(ncid);
-
- /* set _FillValue = 42 for all vars */
- text = fill = 42;
- for (i = 0; i < NVARS; i++) {
- if (var_type[i] == NC_CHAR) {
- err = nc_put_att_text(ncid, i, "_FillValue", 1, &text);
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
- } else {
- err = nc_put_att_double(ncid, i, "_FillValue",var_type[i],1,&fill);
- IF (err)
- error("nc_put_att_double: %s", nc_strerror(err));
- }
- }
-
- /* data mode. write records */
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- index[0] = NRECS;
- err = nc_put_var1_text(ncid, varid, index, &text);
- IF (err)
- error("nc_put_var1_text: %s", nc_strerror(err));
-
- /* get all variables & check all values equal 42 */
- for (i = 0; i < NVARS; i++) {
- for (j = 0; j < var_nels[i]; j++) {
- err = toMixedBase(j, var_rank[i], var_shape[i], index);
- IF (err)
- error("error in toMixedBase");
- if (var_type[i] == NC_CHAR) {
- err = nc_get_var1_text(ncid, i, index, &text);
- IF (err)
- error("nc_get_var1_text failed: %s", nc_strerror(err));
- value = text;
- } else {
- err = nc_get_var1_double(ncid, i, index, &value);
- IF (err)
- error("nc_get_var1_double failed: %s", nc_strerror(err));
- }
- IF (value != fill)
- error(" Value expected: %g, read: %g\n", fill, value);
- else
- nok++;
- }
- }
- print_nok(nok);
-
- 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/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/tests.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/tests.h
deleted file mode 100644
index 2d469ed..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/tests.h
+++ /dev/null
@@ -1,479 +0,0 @@
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: tests.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <limits.h>
-#include <float.h>
-#define NO_NETCDF_2 1
-#include "netcdf.h"
-#include "error.h"
-
-#if defined(_CRAY) && !defined(_CRAYIEEE)
-#define CRAYFLOAT 1 /* CRAY Floating point */
-#elif defined(_SX) && defined(_FLOAT2) /* NEC SUPER-UX in CRAY mode */
-#define CRAYFLOAT 1 /* CRAY Floating point */
-#endif
-
- /* Limits of external types (based on those in ncx.h) */
-
-#define X_CHAR_MIN CHAR_MIN
-#define X_CHAR_MAX CHAR_MAX
-#define X_BYTE_MIN (-128)
-#define X_BYTE_MAX 127
-#define X_SHORT_MIN (-32768)
-#define X_SHORT_MAX 32767
-#define X_INT_MIN (-2147483648.)
-#define X_INT_MAX 2147483647
-#if defined(FLT_MAX_EXP) && FLT_MAX_EXP < 128
-/* FLT_MAX < X_FLOAT_MAX */
-#define X_FLOAT_MAX FLT_MAX
-#else
-#define X_FLOAT_MAX 3.40282347e+38f
-#endif
-#define X_FLOAT_MIN (-X_FLOAT_MAX)
-#if CRAYFLOAT
-/* ldexp(1. - ldexp(.5 , -46), 1024) */
-#define X_DOUBLE_MAX 1.79769313486230e+308
-#else
-/* scalb(1. - scalb(.5 , -52), 1024) */
-#define X_DOUBLE_MAX 1.7976931348623157e+308
-#endif
-#define X_DOUBLE_MIN (-X_DOUBLE_MAX)
-
-
-#if _SX /* NEC SUPER UX */
-#if _INT64
-#undef INT_MAX /* workaround cpp bug */
-#define INT_MAX X_INT_MAX
-#undef INT_MIN /* workaround cpp bug */
-#define INT_MIN X_INT_MIN
-#undef LONG_MAX /* workaround cpp bug */
-#define LONG_MAX X_INT_MAX
-#undef LONG_MIN /* workaround cpp bug */
-#define LONG_MIN X_INT_MIN
-#elif _LONG64
-#undef LONG_MAX /* workaround cpp bug */
-#define LONG_MAX 4294967295L
-#undef LONG_MIN /* workaround cpp bug */
-#define LONG_MIN -4294967295L
-#endif
-#endif /* _SX */
-
-
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif /* MAX */
-
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif /* MIN */
-
-#ifndef ABS
-#define ABS(x) ((x) < 0 ? -(x) : (x))
-#endif /* ABS */
-
-
- /* Parameters of test data */
-
-#define NTYPES 6
-#define NDIMS 5
-#define NVARS 136
-#define NRECS 2
-#define NGATTS NTYPES
-#define RECDIM 0
-#define MAX_RANK 3
-#define MAX_NELS 64
-#define MAX_DIM_LEN 4
-#define MAX_NATTS 3
-
-
- /* Limits of internal types */
-
-#define text_min CHAR_MIN
-#define uchar_min 0
-#define schar_min SCHAR_MIN
-#define short_min SHRT_MIN
-#define int_min INT_MIN
-#define long_min LONG_MIN
-#define float_min (-FLT_MAX)
-#define double_min (-DBL_MAX)
-
-#define text_max CHAR_MAX
-#define uchar_max UCHAR_MAX
-#define schar_max SCHAR_MAX
-#define short_max SHRT_MAX
-#define int_max INT_MAX
-#define long_max LONG_MAX
-#define float_max FLT_MAX
-#define double_max DBL_MAX
-
-
-
- /* Examples of invalid argument values */
-
-#define BAD_ID -1 /* invalid netCDF ID */
-#define BAD_DIMID -1 /* invalid dim ID */
-#define BAD_VARID -2 /* invalid var ID */
-#define BAD_ATTNUM -1 /* invalid att number */
-#define BAD_TYPE (nc_type) 0 /* invalid data type */
-#define BAD_FILLMODE -1 /* invalid fill mode */
-#define BAD_NAME "a+b" /* invalid name */
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
- /* Non-standard internal types */
-
-typedef char text;
-typedef signed char schar;
-#if !defined(uchar) && !defined(__osf__) && !defined(_AIX)
-typedef unsigned char uchar;
-#endif
-
-
-
- /* Global variables - filenames */
-
-extern char testfile[]; /* netCDF read-only test data */
-extern char scratch[]; /* netCDF test file for writing */
-
- /* Global variables - command-line arguments */
-
-extern int read_only; /* if 1, don't try to change files */
-extern int verbose; /* if 1, print details of tests */
-extern int nfails; /* number of failures in specific test */
-
- /* Global variables - test data */
-
-extern char dim_name[NDIMS][3];
-extern size_t dim_len[NDIMS];
-extern char var_name[NVARS][2+MAX_RANK];
-extern nc_type var_type[NVARS];
-extern size_t var_rank[NVARS];
-extern int var_dimid[NVARS][MAX_RANK];
-extern size_t var_shape[NVARS][MAX_RANK];
-extern size_t var_nels[NVARS];
-extern size_t var_natts[NVARS];
-extern char att_name[NVARS][MAX_NATTS][2];
-extern char gatt_name[NGATTS][3];
-extern nc_type att_type[NVARS][NGATTS];
-extern nc_type gatt_type[NGATTS];
-extern size_t att_len[NVARS][MAX_NATTS];
-extern size_t gatt_len[NGATTS];
-
-
- /* Macros for accessing attribute test data */
- /* 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 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])
-
-extern const char *s_nc_type(nc_type);
-
-extern void test_nc_strerror(void);
-extern void test_nc_open(void);
-extern void test_nc_close(void);
-
-extern void test_nc_inq(void);
-extern void test_nc_inq_natts(void);
-extern void test_nc_inq_ndims(void);
-extern void test_nc_inq_nvars(void);
-extern void test_nc_inq_unlimdim(void);
-
-extern void test_nc_inq_dimid(void);
-extern void test_nc_inq_dim(void);
-extern void test_nc_inq_dimlen(void);
-extern void test_nc_inq_dimname(void);
-
-extern void test_nc_inq_varid(void);
-extern void test_nc_inq_vardimid(void);
-extern void test_nc_inq_varname(void);
-extern void test_nc_inq_varnatts(void);
-extern void test_nc_inq_varndims(void);
-extern void test_nc_inq_vartype(void);
-extern void test_nc_inq_var(void);
-
-extern void test_nc_get_var_double(void);
-extern void test_nc_get_var_float(void);
-extern void test_nc_get_var_int(void);
-extern void test_nc_get_var_long(void);
-extern void test_nc_get_var_schar(void);
-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_var1_double(void);
-extern void test_nc_get_var1_float(void);
-extern void test_nc_get_var1_int(void);
-extern void test_nc_get_var1_long(void);
-extern void test_nc_get_var1_schar(void);
-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_vara_double(void);
-extern void test_nc_get_vara_float(void);
-extern void test_nc_get_vara_int(void);
-extern void test_nc_get_vara_long(void);
-extern void test_nc_get_vara_schar(void);
-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_vars(void);
-extern void test_nc_get_vars_double(void);
-extern void test_nc_get_vars_float(void);
-extern void test_nc_get_vars_int(void);
-extern void test_nc_get_vars_long(void);
-extern void test_nc_get_vars_schar(void);
-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_varm(void);
-extern void test_nc_get_varm_double(void);
-extern void test_nc_get_varm_float(void);
-extern void test_nc_get_varm_int(void);
-extern void test_nc_get_varm_long(void);
-extern void test_nc_get_varm_schar(void);
-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_att(void);
-extern void test_nc_get_att_double(void);
-extern void test_nc_get_att_float(void);
-extern void test_nc_get_att_int(void);
-extern void test_nc_get_att_long(void);
-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_put_var_double(void);
-extern void test_nc_put_var_float(void);
-extern void test_nc_put_var_int(void);
-extern void test_nc_put_var_long(void);
-extern void test_nc_put_var_schar(void);
-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_var1_double(void);
-extern void test_nc_put_var1_float(void);
-extern void test_nc_put_var1_int(void);
-extern void test_nc_put_var1_long(void);
-extern void test_nc_put_var1_schar(void);
-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_vara_double(void);
-extern void test_nc_put_vara_float(void);
-extern void test_nc_put_vara_int(void);
-extern void test_nc_put_vara_long(void);
-extern void test_nc_put_vara_schar(void);
-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_vars_double(void);
-extern void test_nc_put_vars_float(void);
-extern void test_nc_put_vars_int(void);
-extern void test_nc_put_vars_long(void);
-extern void test_nc_put_vars_schar(void);
-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_varm_double(void);
-extern void test_nc_put_varm_float(void);
-extern void test_nc_put_varm_int(void);
-extern void test_nc_put_varm_long(void);
-extern void test_nc_put_varm_schar(void);
-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_att(void);
-extern void test_nc_put_att_double(void);
-extern void test_nc_put_att_float(void);
-extern void test_nc_put_att_int(void);
-extern void test_nc_put_att_long(void);
-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_create(void);
-extern void test_nc_redef(void);
-extern void test_nc_enddef(void);
-extern void test_nc_sync(void);
-extern void test_nc_abort(void);
-extern void test_nc_def_dim(void);
-extern void test_nc_rename_dim(void);
-extern void test_nc_def_var(void);
-extern void test_nc_rename_var(void);
-extern void test_nc_copy_att(void);
-
-extern void test_nc_inq_att(void);
-extern void test_nc_inq_attname(void);
-extern void test_nc_inq_attid(void);
-extern void test_nc_inq_attlen(void);
-extern void test_nc_inq_atttype(void);
-
-extern void test_nc_rename_att(void);
-extern void test_nc_del_att(void);
-extern void test_nc_set_fill(void);
-
-void print_nok(int nok);
-
-int inRange(const double value, const nc_type datatype);
-
-/*
- * internal types
- */
-typedef enum {
- NCT_UNSPECIFIED = 0,
- NCT_UCHAR = 1, /* unsigned char */
- NCT_TEXT = 16, /* char */
-#define NCT_CHAR NCT_TEXT
- NCT_SCHAR = 17, /* signed char */
- NCT_SHORT = 18, /* short */
- NCT_INT = 20, /* int */
- NCT_LONG = 22, /* long */
- NCT_FLOAT = 36, /* float */
- NCT_DOUBLE = 40 /* double */
-} nct_itype;
-
-int inRange3(const double value, const nc_type datatype, const nct_itype itype);
-
-int equal(const double x, const double y, nc_type extType, nct_itype itype);
-
-int int_vec_eq(const int *v1, const int *v2, const int n);
-
-int roll( int n );
-
-int
-toMixedBase(
- size_t number, /* number to be converted to mixed base */
- size_t length,
- const size_t base[], /* dimensioned [length], base[0] ignored */
- size_t result[]); /* dimensioned [length] */
-
-size_t
-fromMixedBase(
- size_t length,
- size_t number[], /* dimensioned [length] */
- size_t base[]); /* dimensioned [length], base[0] ignored */
-
-int nc2dbl ( const nc_type datatype, const void *p, double *result);
-
-int dbl2nc ( const double d, const nc_type datatype, void *p);
-
-double hash( const nc_type type, const int rank, const size_t *index );
-
-double hash4(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype);
-
-void init_gvars(void);
-
-void def_dims(int ncid);
-
-void def_vars(int ncid);
-
-void put_atts(int ncid);
-
-void put_vars(int ncid);
-
-void write_file(char *filename);
-
-void check_dims(int ncid);
-
-void check_vars(int ncid);
-
-void check_atts(int ncid);
-
-void check_file(char *filename);
-
-/*
- * These functions are defined in ../libsrc and are
- * used to support interface version 2 backward compatiblity.
- * They are not really public, but we wrote these tests before
- * we decided to hide them.
- * N.B. there is potential for these declarations to get
- * out of sync with those in ../libsrc/nc.h and the definitions.
- */
-extern int
-nctypelen(nc_type datatype);
-
-extern int
-nc_put_att(int ncid, int varid, const char *name, nc_type datatype,
- size_t len, const void *value);
-
-extern int
-nc_get_att(int ncid, int varid, const char *name, void *value);
-
-extern int
-nc_put_var1(int ncid, int varid, const size_t *index, const void *value);
-
-extern int
-nc_get_var1(int ncid, int varid, const size_t *index, void *value);
-
-extern int
-nc_put_vara(int ncid, int varid,
- const size_t *start, const size_t *count, const void *value);
-
-extern int
-nc_get_vara(int ncid, int varid,
- const size_t *start, const size_t *count, void *value);
-
-extern int
-nc_put_vars(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- const void * value);
-
-extern int
-nc_get_vars(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- void * value);
-
-extern int
-nc_put_varm(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- const ptrdiff_t * map, const void *value);
-
-extern int
-nc_get_varm(int ncid, int varid,
- const size_t *start, const size_t *count, const ptrdiff_t *stride,
- const ptrdiff_t * map, void *value);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/util.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/util.c
deleted file mode 100644
index 61f66f2..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nc_test/util.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/*********************************************************************
- * Copyright 1996, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: util.c,v 1.1.1.1 2005/06/14 04:38:29 svitak Exp $
- *********************************************************************/
-
-#include <math.h>
-#include "tests.h"
-
-void
-print_nok(int nok)
-{
- if (verbose || nfails > 0)
- print("\n");
- print(" %d good comparisons. ", nok);
-}
-
-
-/* Is value within external type range? */
-int
-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;
- default: assert(0);
- }
- return value >= min && value <= max;
-}
-
-static int
-inRange_uchar(const double value, const nc_type datatype)
-{
- if (datatype == NC_BYTE) {
- return(value >= 0 && value <= 255);
- }
- /* else */
- return inRange(value, datatype);
-}
-
-int
-inRange_float(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:
- if(FLT_MAX < X_FLOAT_MAX) {
- min = (-FLT_MAX);
- max = FLT_MAX;
- } else {
- min = X_FLOAT_MIN;
- max = X_FLOAT_MAX;
- }
- break;
- case NC_DOUBLE:
- if(FLT_MAX < X_DOUBLE_MAX) {
- min = (-FLT_MAX);
- max = FLT_MAX;
- } else {
- min = X_DOUBLE_MIN;
- max = X_DOUBLE_MAX;
- }
- break;
- default: assert(0);
- }
- if(!( value >= min && value <= max)) {
-#if 0 /* DEBUG */
- if(datatype == NC_FLOAT) {
- fprintf(stderr, "\n");
- fprintf(stderr, "min % .17e\n", min);
- fprintf(stderr, "value % .17e\n", value);
- fprintf(stderr, "max % .17e\n", max);
- }
-#endif
- return 0;
- }
-#if FLT_MANT_DIG != DBL_MANT_DIG
- /* else */
- {
- const float fvalue = value;
- return fvalue >= min && fvalue <= max;
- }
-#else
- return 1;
-#endif
-}
-
-/* wrapper for inRange to handle special NC_BYTE/uchar adjustment */
-int
-inRange3(
- const double value,
- const nc_type datatype,
- const nct_itype itype)
-{
- switch (itype) {
- case NCT_UCHAR:
- return inRange_uchar(value, datatype);
- case NCT_FLOAT:
- return inRange_float(value, datatype);
- default:
- break;
- }
- return inRange(value, datatype);
-}
-
-
-/*
- * Does x == y, where one is internal and other external (netCDF)?
- * Use tolerant comparison based on IEEE FLT_EPSILON or DBL_EPSILON.
- */
-int
-equal(
- const double x,
- const double y,
- nc_type extType, /* external data type */
- nct_itype itype)
-{
- const double flt_epsilon = 1.19209290E-07;
- const double dbl_epsilon = 2.2204460492503131E-16;
- double epsilon;
-
- epsilon = extType == NC_FLOAT || itype == NCT_FLOAT ? flt_epsilon : dbl_epsilon;
- return ABS(x-y) <= epsilon * MAX( ABS(x), ABS(y));
-}
-
-/* Test whether two int vectors are equal. If so return 1, else 0 */
-int
-int_vec_eq(const int *v1, const int *v2, const int n)
-{
- int i;
- for (i= 0; i < n && v1[i] == v2[i]; i++)
- ;
- return i == n;
-}
-
-
-/*
- * Generate random integer from 0 to n-1
- * Like throwing an n-sided dice marked 0, 1, 2, ..., n-1
- */
-int roll( int n )
-{
- int r;
-
- do
- /*
- * Compute a pseudo-random value between 0.0 and 1.0, multiply
- * it by n-1, and then find the nearest integer.
- *
- * We don't use RAND_MAX here because not all compilation
- * environments define it (e.g. gcc(1) under SunOS 4.1.4).
- */
- r = ((rand() % 32768) / 32767.0) * (n - 1) + 0.5;
- while (r >= n);
-
- return r;
-}
-
-
-/*
- * Convert number to mixed base
- *
- * E.g. to convert 41 inches to yards, feet and inches:
- * size_t base[] = {1, 3, 12};
- * size_t result[3];
- * status = toMixedBase(41, 3, base, result);
- *
- * Author: Harvey Davies, Unidata/UCAR, Boulder, Colorado
- */
-int
-toMixedBase(
- size_t number, /* number to be converted to mixed base */
- size_t length,
- const size_t base[], /* dimensioned [length], base[0] ignored */
- size_t result[]) /* dimensioned [length] */
-{
- size_t i;
-
- if (length > 0) {
- for (i = length - 1; i > 0; i--) {
- if (base[i] == 0)
- return 1;
- result[i] = number % base[i];
- number = number / base[i];
- }
- result[0] = number;
- }
- return 0;
-}
-
-/*
- * Convert number from mixed base
- *
- * E.g. to convert 1 yard, 0 feet, 5 inches to inches:
- * size_t number[] = {1, 0, 5};
- * size_t base[] = {1, 3, 12};
- * inches = fromMixedBase(3, number, base);
- *
- * Author: Harvey Davies, Unidata/UCAR, Boulder, Colorado
- */
-size_t
-fromMixedBase(
- size_t length,
- size_t number[], /* dimensioned [length] */
- size_t base[]) /* dimensioned [length], base[0] ignored */
-{
- size_t i;
- size_t result = 0;
-
- for (i = 1; i < length; i++) {
- result += number[i-1];
- result *= base[i];
- }
- if (length > 0)
- result += number[i-1];
- return result;
-}
-
-
-/* Convert any nc_type to double */
-int nc2dbl ( const nc_type datatype, const void *p, double *result)
-{
- if ( ! p ) return 2;
- if ( ! result ) return 3;
- switch (datatype) {
- case NC_BYTE: *result = *((signed char *) p); break;
- case NC_CHAR: *result = *((char *) p); break;
- case NC_SHORT: *result = *((short *) p); break;
- case NC_INT:
-#if INT_MAX >= X_INT_MAX
- *result = *((int *) p);
-#else
- *result = *((long *) p);
-#endif
- break;
- case NC_FLOAT: *result = *((float *) p); break;
- case NC_DOUBLE: *result = *((double *) p); break;
- default: return 1;
- }
- return 0;
-}
-
-
-/* Convert double to any nc_type */
-int dbl2nc ( const double d, const nc_type datatype, void *p)
-{
- double r; /* rounded value */
-
- if (p) {
- switch (datatype) {
- case NC_BYTE:
- r = floor(0.5+d);
- if ( r < schar_min || r > schar_max ) return 2;
- *((signed char *) p) = r;
- break;
- case NC_CHAR:
- r = floor(0.5+d);
- if ( r < text_min || r > text_max ) return 2;
- *((char *) p) = r;
- break;
- case NC_SHORT:
- r = floor(0.5+d);
- if ( r < short_min || r > short_max ) return 2;
- *((short *) p) = r;
- break;
- case NC_INT:
- r = floor(0.5+d);
- if ( r < long_min || r > long_max ) return 2;
-#if INT_MAX >= X_INT_MAX
- *((int *) p) = r;
-#else
- *((long *) p) = r;
-#endif
- break;
- case NC_FLOAT:
- if ( fabs(d) > float_max ) return 2;
- *((float *) p) = d;
- break;
- case NC_DOUBLE:
- *((double *) p) = d;
- break;
- default:
- return 1;
- }
- return 0;
- } else {
- return 1;
- }
-}
-
-#define FUZZ (1.19209290E-07)
-
-/* Generate data values as function of type, rank (-1 for attribute), index */
-double
-hash( const nc_type type, const int rank, const size_t *index )
-{
- double base;
- double result;
- int d; /* index of dimension */
-
- /* If vector then elements 0 & 1 are min & max. Elements 2 & 3 are */
- /* just < min & > max (except for NC_CHAR & NC_DOUBLE) */
- if (abs(rank) == 1 && index[0] <= 3) {
- switch (index[0]) {
- case 0:
- switch (type) {
- case NC_CHAR: return X_CHAR_MIN;
- case NC_BYTE: return X_BYTE_MIN;
- case NC_SHORT: return X_SHORT_MIN;
- case NC_INT: return X_INT_MIN;
- case NC_FLOAT: return X_FLOAT_MIN;
- case NC_DOUBLE: return X_DOUBLE_MIN;
- default: assert(0);
- }
- case 1:
- switch (type) {
- case NC_CHAR: return X_CHAR_MAX;
- case NC_BYTE: return X_BYTE_MAX;
- case NC_SHORT: return X_SHORT_MAX;
- case NC_INT: return X_INT_MAX;
- case NC_FLOAT: return X_FLOAT_MAX;
- case NC_DOUBLE: return X_DOUBLE_MAX;
- default: assert(0);
- }
- case 2:
- switch (type) {
- case NC_CHAR: return 'A';
- case NC_BYTE: return X_BYTE_MIN-1.0;
- case NC_SHORT: return X_SHORT_MIN-1.0;
- 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;
- default: assert(0);
- }
- case 3:
- switch (type) {
- case NC_CHAR: return 'Z';
- case NC_BYTE: return X_BYTE_MAX+1.0;
- case NC_SHORT: return X_SHORT_MAX+1.0;
- 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;
- default: assert(0);
- }
- }
- } else {
- switch (type) {
- case NC_CHAR: base = 2; break;
- case NC_BYTE: base = -2; break;
- case NC_SHORT: base = -5; break;
- case NC_INT: base = -20; break;
- case NC_FLOAT: base = -9; break;
- case NC_DOUBLE: base = -10; break;
- default: assert(0);
- }
- result = rank < 0 ? base * 7 : base * (rank + 1);
- for (d = 0; d < abs(rank); d++)
- result = base * (result + index[d]);
- }
- return result;
-}
-
-/* wrapper for hash to handle special NC_BYTE/uchar adjustment */
-double
-hash4(
- const nc_type type,
- const int rank,
- const size_t *index,
- const nct_itype itype)
-{
- double result;
-
- result = hash( type, rank, index );
- if (itype == NCT_UCHAR && type == NC_BYTE && result >= -128 && result < 0)
- result += 256;
- return result;
-}
-
-static nc_type
-char2type(char letter) {
- switch (letter) {
- case 'c': return NC_CHAR;
- case 'b': return NC_BYTE;
- case 's': return NC_SHORT;
- case 'i': return NC_INT;
- case 'f': return NC_FLOAT;
- case 'd': return NC_DOUBLE;
- default: assert(0);
- }
- return NC_CHAR; /* Just to keep compiler happy */
-}
-
-
-static void
-init_dims(const char *digit)
-{
- int dimid; /* index of dimension */
- for (dimid = 0; dimid < NDIMS; dimid++)
- {
- dim_len[dimid] = dimid == 0 ? NRECS : dimid;
- dim_name[dimid][0] = 'D';
- dim_name[dimid][1] = digit[dimid];
- dim_name[dimid][2] = '\0';
- }
-}
-
-static void
-init_gatts(const char *type_letter)
-{
- int attid;
- for (attid = 0; attid < NGATTS; attid++)
- {
- gatt_name[attid][0] = 'G';
- gatt_name[attid][1] = type_letter[attid];
- gatt_name[attid][2] = '\0';
- gatt_len[attid] = 1 + attid;
- gatt_type[attid] = char2type (type_letter[attid]);
- }
-}
-
-static size_t
-product(size_t nn, const size_t *sp)
-{
- size_t result = 1;
- while(nn-- > 0)
- result *= *sp++;
- return result;
-}
-
-/*
- define global variables:
- dim_name, dim_len,
- var_name, var_type, var_rank, var_shape, var_natts, var_dimid, var_nels
- att_name, gatt_name, att_type, gatt_type, att_len, gatt_len
- */
-void
-init_gvars (void)
-{
- const size_t max_dim_len[MAX_RANK] = {
- MAX_DIM_LEN +1,
- MAX_DIM_LEN,
- MAX_DIM_LEN
- };
- const char type_letter[] = "cbsifd";
- const char digit[] = "r123456789";
-
- size_t rank;
- int vn; /* var number */
- int xtype; /* index of type */
- int an; /* attribute number */
-
- assert(sizeof(max_dim_len)/sizeof(max_dim_len[0]) >= MAX_RANK);
-
- init_dims(digit);
-
- for (rank = 0, vn = 0, xtype = 0, an = 0; rank <= MAX_RANK; rank++)
- {
- /* number variables of a type and rank */
- const size_t nvars = product(rank, max_dim_len);
- int jj;
-
- for (jj = 0; jj < nvars; jj++)
- {
- /* number types of this shape */
- const int ntypes = rank < 2 ? NTYPES : 1;
-
- int tc;
- for (tc = 0; tc < ntypes;
- tc++, vn++, xtype = (xtype + 1) % NTYPES)
- {
- size_t tmp[MAX_RANK];
-
- var_name[vn][0] = type_letter[xtype];
- var_type[vn] = char2type (type_letter[xtype]);
- var_rank[vn] = rank;
- var_natts[vn] = rank == 0 ? vn % (MAX_NATTS + 1) : 0;
- {
- int ac;
- for (ac = 0; ac < var_natts[vn]; ac++, an++)
- {
- att_name[vn][ac][0] = type_letter[an % NTYPES];
- att_name[vn][ac][1] = '\0';
- att_len[vn][ac] = an;
- att_type[vn][ac] = char2type (type_letter[an % NTYPES]);
- }
- } /* ac block */
-#ifndef NDEBUG
- assert(toMixedBase (jj, rank, max_dim_len, tmp) == 0);
-#else
- (void) toMixedBase (jj, rank, max_dim_len, tmp);
-#endif
- {
- int dn; /* dimension number */
- for (dn = 0; dn < rank; dn++)
- var_dimid[vn][dn] = (int)tmp[dn];
- for (dn = 0, var_nels[vn] = 1; dn < rank; dn++)
- {
- var_dimid[vn][dn] += dn > 0;
- assert (var_dimid[vn][dn] <= 9);
- var_name[vn][dn + 1] = digit[var_dimid[vn][dn]];
- var_shape[vn][dn] = var_dimid[vn][dn] ?
- var_dimid[vn][dn] : NRECS;
- var_nels[vn] *= var_shape[vn][dn];
- }
- } /* dn block */
- }
- }
- }
-
- init_gatts(type_letter);
-}
-
-
-/* define dims defined by global variables */
-void
-def_dims(int ncid)
-{
- int err; /* status */
- int i;
- int dimid; /* dimension id */
-
- for (i = 0; i < NDIMS; i++) {
- err = nc_def_dim(ncid, dim_name[i], i==0 ? NC_UNLIMITED : dim_len[i],
- &dimid);
- IF (err) error("nc_def_dim: %s", nc_strerror(err));
- }
-}
-
-
-/* define vars defined by global variables */
-void
-def_vars(int ncid)
-{
- int err; /* status */
- int i;
- int var_id;
-
- for (i = 0; i < NVARS; 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));
- }
-}
-
-
-/* put attributes defined by global variables */
-void
-put_atts(int ncid)
-{
- int err; /* status */
- int i;
- size_t k;
- int j; /* index of attribute */
- int allInRange;
- double att[MAX_NELS];
- char catt[MAX_NELS];
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- if (ATT_TYPE(i,j) == NC_CHAR) {
- for (k = 0; k < ATT_LEN(i,j); k++) {
- catt[k] = hash(ATT_TYPE(i,j), -1, &k);
- }
- err = nc_put_att_text(ncid, i, ATT_NAME(i,j),
- ATT_LEN(i,j), catt);
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
- } else {
- for (allInRange = 1, k = 0; k < ATT_LEN(i,j); k++) {
- att[k] = hash(ATT_TYPE(i,j), -1, &k);
- allInRange = allInRange && inRange(att[k], ATT_TYPE(i,j));
- }
- err = nc_put_att_double(ncid, i, ATT_NAME(i,j),
- ATT_TYPE(i,j), ATT_LEN(i,j), att);
- if (allInRange) {
- IF (err)
- error("nc_put_att_double: %s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("type-conversion range error: status = %d", err);
- }
- }
- }
- }
-}
-
-/* put variables defined by global variables */
-void
-put_vars(int ncid)
-{
- size_t start[MAX_RANK];
- size_t index[MAX_RANK];
- int err; /* status */
- int i;
- size_t j;
- double value[MAX_NELS];
- char text[MAX_NELS];
- int allInRange;
-
- for (j = 0; j < MAX_RANK; j++)
- start[j] = 0;
- for (i = 0; i < NVARS; 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");
- if (var_name[i][0] == 'c') {
- text[j] = hash(var_type[i], var_rank[i], index);
- } else {
- value[j] = hash(var_type[i], var_rank[i], index);
- allInRange = allInRange && inRange(value[j], var_type[i]);
- }
- }
- if (var_name[i][0] == 'c') {
- err = nc_put_vara_text(ncid, i, start, var_shape[i], text);
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
- } else {
- err = nc_put_vara_double(ncid, i, start, var_shape[i], value);
- if (allInRange) {
- IF (err)
- error("nc_put_att_text: %s", nc_strerror(err));
- } else {
- IF (err != NC_ERANGE)
- error("type-conversion range error: status = %d", err);
- }
- }
- }
-}
-
-
-/* Create & write all of specified file using global variables */
-void
-write_file(char *filename)
-{
- int ncid; /* netCDF id */
- int err; /* status */
-
- err = nc_create(filename, NC_CLOBBER, &ncid);
- IF (err)
- error("nc_create: %s", nc_strerror(err));
-
- def_dims(ncid);
- def_vars(ncid);
- put_atts(ncid);
- err = nc_enddef(ncid);
- IF (err)
- error("nc_enddef: %s", nc_strerror(err));
- put_vars(ncid);
-
- err = nc_close (ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
-}
-
-
-/*
- * check dimensions of specified file have expected name & length
- */
-void
-check_dims(int ncid)
-{
- char name[NC_MAX_NAME];
- size_t length;
- int i;
- int err; /* status */
-
- for (i = 0; i < NDIMS; i++) {
- err = nc_inq_dim(ncid, i, name, &length);
- IF (err)
- error("nc_inq_dim: %s", nc_strerror(err));
- IF (strcmp(name, dim_name[i]) != 0)
- error("Unexpected name of dimension %d", i);
- IF (length != dim_len[i])
- error("Unexpected length %d of dimension %d", length, i);
- }
-}
-
-
-/*
- * check variables of specified file have expected name, type, shape & values
- */
-void
-check_vars(int ncid)
-{
- size_t index[MAX_RANK];
- int err; /* status */
- int i;
- size_t j;
- char text;
- double value;
- nc_type datatype;
- int ndims;
- int dimids[MAX_RANK];
- int isChar;
- double expect;
- char name[NC_MAX_NAME];
- size_t length;
- int nok = 0; /* count of valid comparisons */
-
- for (i = 0; i < NVARS; i++) {
- isChar = var_type[i] == NC_CHAR;
- 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 = hash( var_type[i], var_rank[i], index );
- if (isChar) {
- err = nc_get_var1_text(ncid, i, index, &text);
- IF (err)
- error("nc_get_var1_text: %s", nc_strerror(err));
- IF (text != expect) {
- error("Var %s value read 0x%02x not that expected 0x%02x ",
- var_name[i], text, (char)expect);
- print_n_size_t(var_rank[i], index);
- } else {
-#if 0
- print("\nOk %s ", var_name[i]);
- print_n_size_t(var_rank[i], index);
-#endif
- nok++;
- }
- } else {
- err = nc_get_var1_double(ncid, i, index, &value);
- if (inRange(expect,var_type[i])) {
- IF (err) {
- 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);
- } else {
-#if 0
- print("\nOk %s ", var_name[i]);
- print_n_size_t(var_rank[i], index);
-#endif
- nok++;
- }
- }
- }
- }
- }
- }
- print_nok(nok);
-}
-
-
-/*
- * check attributes of specified file have expected name, type, length & values
- */
-void
-check_atts(int ncid)
-{
- int err; /* status */
- int i;
- int j;
- size_t k;
- nc_type datatype;
- char name[NC_MAX_NAME];
- size_t length;
- char text[MAX_NELS];
- double value[MAX_NELS];
- double expect;
- int nok = 0; /* count of valid comparisons */
-
- for (i = -1; i < NVARS; i++) {
- for (j = 0; j < NATTS(i); j++) {
- err = nc_inq_attname(ncid, i, j, name);
- IF (err)
- error("nc_inq_attname: %s", nc_strerror(err));
- IF (strcmp(name, ATT_NAME(i,j)) != 0)
- error("nc_inq_attname: unexpected name");
- err = nc_inq_att(ncid, i, name, &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");
- if (datatype == NC_CHAR) {
- err = nc_get_att_text(ncid, i, name, text);
- IF (err)
- error("nc_get_att_text: %s", nc_strerror(err));
- for (k = 0; k < ATT_LEN(i,j); k++) {
- IF (text[k] != hash(datatype, -1, &k)) {
- error("nc_get_att_text: unexpected value");
- } else {
- nok++;
- }
- }
- } else {
- err = nc_get_att_double(ncid, i, name, value);
- for (k = 0; k < ATT_LEN(i,j); k++) {
- expect = hash(datatype, -1, &k);
- if (inRange(expect,ATT_TYPE(i,j))) {
- IF (err)
- error("nc_get_att_double: %s", nc_strerror(err));
- IF (!equal(value[k], expect, ATT_TYPE(i,j), NCT_DOUBLE)) {
- error("Att value read not that expected");
- } else {
- nok++;
- }
- }
- }
- }
- }
- }
- print_nok(nok);
-}
-
-
-/* Check file (dims, vars, atts) corresponds to global variables */
-void
-check_file(char *filename)
-{
- int ncid; /* netCDF id */
- int err; /* status */
-
- err = nc_open(filename, NC_NOWRITE, &ncid);
- IF (err) {
- error("nc_open: %s", nc_strerror(err));
- } else {
- check_dims(ncid);
- check_vars(ncid);
- check_atts(ncid);
- err = nc_close (ncid);
- IF (err)
- error("nc_close: %s", nc_strerror(err));
- }
-}
-
-/* TODO: Maybe this function belongs in the netcdf library. */
-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";
- }
- return "";
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/Makefile
deleted file mode 100644
index cfcd707..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-# Makefile for ncdump(1).
-#
-# $Id: Makefile,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
-
-include ../macros.make
-
-# Override the default definition for ncgen(1) in the master makefile.
-#
-NCGEN = ../ncgen/ncgen
-
-INCLUDES = -I../libsrc
-
-c_sources = ncdump.c vardata.c dumplib.c
-headers = ncdump.h vardata.h dumplib.h
-
-PROGRAM = ncdump
-
-PACKING_LIST = $(c_sources) $(headers) depend \
- test0.cdl ncdump.1 Makefile
-MANUAL = ncdump.1
-
-lib_netcdf = ../libsrc/libnetcdf.a
-ld_netcdf = -L../libsrc -lnetcdf
-OBJS = ncdump.o vardata.o dumplib.o
-GARBAGE = $(PROGRAM) test0.nc test1.nc test1.cdl test2.cdl
-
-all: $(PROGRAM)
-
-$(PROGRAM): $(lib_netcdf) $(OBJS)
- $(LINK.c) $(OBJS) $(ld_netcdf) $(LIBS)
-
-test: $(PROGRAM) FORCE
- $(NCGEN) -b test0.cdl
- ./$(PROGRAM) -n test1 test0.nc > test1.cdl
- $(NCGEN) -b test1.cdl
- ./$(PROGRAM) test1.nc > test2.cdl
- @cmp test1.cdl test2.cdl && \
- echo "*** $(PROGRAM) test successful ***"
-
-install: $(BINDIR)/$(PROGRAM) $(MANDIR)/man1/$(MANUAL)
-
-$(PROGRAM)_oc : $(c_sources)
- #setopt primary_language C
- #load -C $(CPPFLAGS) $(c_sources)
- #load -C $(LIBS)
- #setopt program_name $(PROGRAM)
-
-TAGS: FORCE
- etags `echo $(PACKING_LIST) | fmt -1 | egrep '\.c|\.h'
-
-include ../rules.make
-include depend
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/depend b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/depend
deleted file mode 100644
index c48d4ea..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/depend
+++ /dev/null
@@ -1,13 +0,0 @@
-dumplib.o: ../libsrc/netcdf.h
-dumplib.o: dumplib.c
-dumplib.o: dumplib.h
-ncdump.o: ../libsrc/netcdf.h
-ncdump.o: dumplib.h
-ncdump.o: ncdump.c
-ncdump.o: ncdump.h
-ncdump.o: vardata.h
-vardata.o: ../libsrc/netcdf.h
-vardata.o: dumplib.h
-vardata.o: ncdump.h
-vardata.o: vardata.c
-vardata.o: vardata.h
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.c
deleted file mode 100644
index 06449dd..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/README file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-/*
- * We potentially include <stdarg.h> before <stdio.h> in order to obtain a
- * definition for va_list from the GNU C compiler.
- */
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "netcdf.h"
-#include "dumplib.h"
-
-static char* has_c_format_att(int ncid, int varid);
-static vnode* newvnode(void);
-
-int float_precision_specified = 0; /* -p option specified float precision */
-int double_precision_specified = 0; /* -p option specified double precision */
-char float_var_fmt[] = "%.NNg";
-char double_var_fmt[] = "%.NNg";
-char float_att_fmt[] = "%#.NNgf";
-char double_att_fmt[] = "%#.NNg";
-
-/*
- * Print error message to stderr and exit
- */
-void
-error(const char *fmt, ...)
-{
- va_list args ;
-
- (void) fprintf(stderr,"%s: ", progname);
- va_start(args, fmt) ;
- (void) vfprintf(stderr,fmt,args) ;
- va_end(args) ;
-
- (void) fprintf(stderr, "\n") ;
- (void) fflush(stderr); /* to ensure log files are current */
- exit(EXIT_FAILURE);
-}
-
-#define LINEPIND " " /* indent of continued lines */
-
-static int linep;
-static int max_line_len;
-
-void
-set_indent(int in)
-{
- linep = in;
-}
-
-
-void
-set_max_len(int len)
-{
- max_line_len = len-2;
-}
-
-
-void
-lput(const char *cp)
-{
- size_t nn = strlen(cp);
-
- if (nn+linep > max_line_len && nn > 2) {
- (void) fputs("\n", stdout);
- (void) fputs(LINEPIND, stdout);
- linep = (int)strlen(LINEPIND);
- }
- (void) fputs(cp,stdout);
- linep += nn;
-}
-
-/* In case different formats specified with -d option, set them here. */
-void
-set_formats(int float_digits, int double_digits)
-{
- (void) sprintf(float_var_fmt, "%%.%dg", float_digits);
- (void) sprintf(double_var_fmt, "%%.%dg", double_digits);
- (void) sprintf(float_att_fmt, "%%#.%dgf", float_digits);
- (void) sprintf(double_att_fmt, "%%#.%dg", double_digits);
-}
-
-
-static char *
-has_c_format_att(
- int ncid, /* netcdf id */
- int varid /* variable id */
- )
-{
- nc_type cfmt_type;
- size_t cfmt_len;
-#define C_FMT_NAME "C_format" /* name of C format attribute */
-#define MAX_CFMT_LEN 100 /* max length of C format attribute */
- static char cfmt[MAX_CFMT_LEN];
-
- /* we expect nc_inq_att to fail if there is no "C_format" attribute */
- int nc_stat = nc_inq_att(ncid, varid, "C_format", &cfmt_type, &cfmt_len);
-
- switch(nc_stat) {
- case NC_NOERR:
- if (cfmt_type == NC_CHAR && cfmt_len != 0 && cfmt_len < MAX_CFMT_LEN) {
- int nc_stat = nc_get_att_text(ncid, varid, "C_format", cfmt);
- if(nc_stat != NC_NOERR)
- nc_advise("Getting 'C_format' attribute", nc_stat, "");
- return &cfmt[0];
- }
- break;
- case NC_ENOTATT:
- break;
- default:
- nc_advise("Inquiring about 'C_format' attribute", nc_stat, "");
- break;
- }
- return 0;
-}
-
-
-/*
- * Determine print format to use for each value for this variable. Use value
- * of attribute C_format if it exists, otherwise a sensible default.
- */
-char *
-get_fmt(
- int ncid, /* netcdf id */
- int varid, /* variable id */
- nc_type type /* netCDF data type */
- )
-{
- char *c_format_att;
-
- /* float or double precision specified with -p option overrides any
- C_format attribute value, so check for that first. */
-
- if (float_precision_specified && type == NC_FLOAT)
- return float_var_fmt;
-
- if (double_precision_specified && type == NC_DOUBLE)
- return double_var_fmt;
-
- /* If C_format attribute exists, return it */
- c_format_att = has_c_format_att(ncid, varid);
- if (c_format_att)
- return c_format_att;
-
- /* Otherwise return sensible default. */
- switch (type) {
- case NC_BYTE:
- return "%d";
- case NC_CHAR:
- return "%s";
- case NC_SHORT:
- return "%d";
- case NC_INT:
- return "%d";
- case NC_FLOAT:
- return float_var_fmt;
- case NC_DOUBLE:
- return double_var_fmt;
- default:
- error("pr_vals: bad type");
- }
-
- return 0;
-}
-
-
-static vnode*
-newvnode(void)
-{
- vnode *newvp = (vnode*) malloc(sizeof(vnode));
-
- if (!newvp) {
- error("out of memory!");
- }
- return newvp;
-}
-
-
-/*
- * Get a new, empty variable list.
- */
-vnode*
-newvlist(void)
-{
- vnode *vp = newvnode();
-
- vp -> next = 0;
- vp -> id = -1; /* bad id */
-
- return vp;
-}
-
-
-void
-varadd(vnode* vlist, int varid)
-{
- vnode *newvp = newvnode();
-
- newvp -> next = vlist -> next;
- newvp -> id = varid;
- vlist -> next = newvp;
-}
-
-
-int
-varmember(const vnode* vlist, int varid)
-{
- vnode *vp = vlist -> next;
-
- for (; vp ; vp = vp->next)
- if (vp->id == varid)
- return 1;
- return 0;
-}
-
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.h
deleted file mode 100644
index bf13686..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/dumplib.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-extern char *progname; /* for error messages */
-
-#define NO_NETCDF_2 /* assert we aren't using any netcdf-2 stuff */
-
-#ifndef EXIT_FAILURE
-#ifndef vms
-#define EXIT_SUCCESS 0
-#define EXIT_FAILURE 1
-#else
-#define EXIT_SUCCESS 1
-#define EXIT_FAILURE 0
-#endif
-#endif
-
-#define FLT_DIGITS 7 /* default sig. digits for float data */
-#define DBL_DIGITS 15 /* default sig. digits for double data */
-
-extern int float_precision_specified; /* -p option specified float precision */
-extern int double_precision_specified; /* -p option specified double precision */
-extern char float_var_fmt[];
-extern char double_var_fmt[];
-extern char float_att_fmt[];
-extern char double_att_fmt[];
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Print error message to stderr and exit */
-extern void error ( const char *fmt, ... );
-
-/* set position in line before lput() calls */
-extern void set_indent ( int indent );
-
-/* set maximum line length */
-extern void set_max_len ( int len );
-
-/* splits lines to keep them short */
-extern void lput ( const char *string );
-
-/* In case different formats specified with -d option, set them here. */
-extern void set_formats ( int flt_digs, int dbl_digs );
-
-/* Determine print format to use for each value for this variable. */
-char * get_fmt ( int ncid, int varid, nc_type type );
-
-/* structure for list of variables specified with -v option */
-struct vnode
-{
- struct vnode* next;
- int id;
-};
-typedef struct vnode vnode;
-
-/* Get new variable list */
-extern vnode* newvlist ( void );
-
-/* Add a variable id to variable list */
-extern void varadd ( vnode* vlist, int varid );
-
-/* Test if a variable id is in variable list */
-extern int varmember ( const vnode* vlist, int varid );
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.1 b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.1
deleted file mode 100644
index 498bfa7..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.1
+++ /dev/null
@@ -1,178 +0,0 @@
-.\" $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.1,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
-.TH NCDUMP 1 "$Date: 2005/06/14 04:38:30 $" "Printed: \n(yr-\n(mo-\n(dy" "UNIDATA UTILITIES"
-.SH NAME
-ncdump \- Convert netCDF files to ASCII form (CDL)
-.SH SYNOPSIS
-.ft B
-.HP
-ncdump
-.nh
-\%[-c]
-\%[-h]
-\%[-v \fIvar1,...\fP]
-\%[-b \fIlang\fP]
-\%[-f \fIlang\fP]
-\%[-l \fIlen\fP]
-\%[-n \fIname\fP]
-\%[-p \fIf_digits[,d_digits]\fP]
-\%\fIfile\fP
-.hy
-.ft
-.SH DESCRIPTION
-\fBncdump\fP generates an ASCII representation of a specified netCDF file on
-standard output. The ASCII representation is in a form called CDL
-(``network Common Data form Language'') that can be viewed, edited, or serve
-as input to \fBncgen\fP. \fBncgen\fP is a companion program that can
-generate a binary netCDF file from a CDL file. Hence \fBncgen\fP and
-\fBncdump\fP can be used as inverses to transform the data representation
-between binary and ASCII representations. See \fBncgen\fP for a description
-of CDL and netCDF representations.
-.LP
-\fBncdump\fP defines a default format used for each type of netCDF data, but
-this can be changed if a `C_format' attribute is defined for a netCDF
-variable. In this case, \fBncdump\fP will use the `C_format' attribute to
-format each value. For example, if floating-point data for the netCDF
-variable `Z' is known to be accurate to only three significant digits, it
-would be appropriate to use the variable attribute
-.RS
-.HP
-Z:C_format = "%.3g"
-.RE
-.LP
-\fBncdump\fP may also be used as a simple browser for netCDF data
-files, to display the dimension names and sizes; variable names, types,
-and shapes; attribute names and values; and optionally, the values of
-data for all variables or selected variables in a netCDF file.
-.LP
-\fBncdump\fP uses `_' to represent data values that are equal to the
-`_FillValue' attribute for a variable, intended to represent data that
-has not yet been written. If a variable has no `_FillValue' attribute, the
-default fill value for the variable type is used if the variable is not of
-byte type.
-.SH OPTIONS
-.IP "\fB-c\fP"
-Show the values of \fIcoordinate\fP variables (variables that are also
-dimensions) as well as the declarations of all dimensions, variables, and
-attribute values. Data values of non-coordinate variables are not included
-in the output. This is the most suitable option to use for a brief look at
-the structure and contents of a netCDF file.
-.IP "\fB-h\fP"
-Show only the \fIheader\fP information in the output, that is the
-declarations of dimensions, variables, and attributes but no data values for
-any variables. The output is identical to using the \fB-c\fP option except
-that the values of coordinate variables are not included. (At most one of
-\fB-c\fP or \fB-h\fP options may be present.)
-.IP "\fB-v\fP \fIvar1,...,varn\fP"
-The output will include data values for the specified variables, in addition
-to the declarations of all dimensions, variables, and attributes. One or
-more variables must be specified by name in the comma-delimited list
-following this option. The list must be a single argument to the command,
-hence cannot contain blanks or other white space characters. The named
-variables must be valid netCDF variables in the input-file. The default,
-without this option and in the absence of the \fB-c\fP or \fB-h\fP
-options, is to include data values for \fIall\fP variables in the output.
-.IP "\fB-b\fP \fIlang\fP"
-A brief annotation in the form of a CDL comment (text beginning with the
-characters ``//'') will be included in the data section of the output for
-each `row' of data, to help identify data values for multidimensional
-variables. If \fIlang\fP begins with `C' or `c', then C language
-conventions will be used (zero-based indices, last dimension varying
-fastest). If \fIlang\fP begins with `F' or `f', then Fortran language
-conventions will be used (one-based indices, first dimension varying
-fastest). In either case, the data will be presented in the same order;
-only the annotations will differ. This option is useful for browsing
-through large volumes of multidimensional data.
-.IP "\fB-f\fP \fIlang\fP"
-Full annotations in the form of trailing CDL comments (text beginning with
-the characters ``//'') for every data value (except individual characters in
-character arrays) will be included in the data section. If \fIlang\fP
-begins with `C' or `c', then C language conventions will be used (zero-based
-indices, last dimension varying fastest). If \fIlang\fP begins with `F' or
-`f', then Fortran language conventions will be used (one-based indices,
-first dimension varying fastest). In either case, the data will be
-presented in the same order; only the annotations will differ. This option
-may be useful for piping data into other filters, since each data value
-appears on a separate line, fully identified.
-.IP "\fB-l\fP \fIlen\fP"
-Changes the default maximum line length (80) used in formatting lists of
-non-character data values.
-.IP "\fB-n\fP \fIname\fP"
-CDL requires a name for a netCDF data set, for use by \fBncgen -b\fP in
-generating a default netCDF file name. By default, \fIncdump\fP constructs
-this name from the last component of the pathname of the input netCDF file
-by stripping off any extension it has. Use the \fB-n\fP option to specify a
-different name. Although the output file name used by \fBncgen -b\fP can be
-specified, it may be wise to have \fIncdump\fP change the default name to
-avoid inadvertantly overwriting a valuable netCDF file when using
-\fBncdump\fP, editing the resulting CDL file, and using \fBncgen -b\fP to
-generate a new netCDF file from the edited CDL file.
-.IP "\fB-p\fP \fIfloat_digits[,double_digits]\fP"
-Specifies default precision (number of significant digits) to use in displaying
-floating-point or double precision data values for attributes and variables.
-If specified, this value overrides the value of the `C_format' attribute for
-any variable that has such an attribute.
-Floating-point data will be displayed with
-\fIfloat_digits\fP significant digits. If \fIdouble_digits\fP is also
-specified, double-precision values will be displayed with that many
-significant digits. In the absence of any
-\fB-p\fP specifications, floating-point and double-precision data are
-displayed with 7 and 15 significant digits respectively. CDL files can be
-made smaller if less precision is required. If both floating-point and
-double-presision precisions are specified, the two values must appear
-separated by a comma (no blanks) as a single argument to the command.
-If you really want every last bit of precision from the netCDF file
-represented in the CDL file for all possible floating-point values, you will
-have to specify this with \fB-p 9,17\fP (according to Theorem 15 of the
-paper listed under REFERENCES).
-
-.SH EXAMPLES
-.LP
-Look at the structure of the data in the netCDF file `\fBfoo.nc\fP':
-.RS
-.HP
-ncdump -c foo.nc
-.RE
-.LP
-Produce an annotated CDL version of the structure and data in the
-netCDF file `\fBfoo.nc\fP', using C-style indexing for the annotations:
-.RS
-.HP
-ncdump -b c foo.nc > foo.cdl
-.RE
-.LP
-Output data for only the variables `uwind' and `vwind' from the netCDF file
-`\fBfoo.nc\fP', and show the floating-point data with only three significant
-digits of precision:
-.RS
-.HP
-ncdump -v uwind,vwind -p 3 foo.nc
-.RE
-.LP
-Produce a fully-annotated (one data value per line) listing of the data for
-the variable `omega', using Fortran conventions for indices, and changing the
-netCDF dataset name in the resulting CDL file to `omega':
-.RS
-.HP
-ncdump -v omega -f fortran -n omega foo.nc > Z.cdl
-.RE
-.SH REFERENCES
- \fIWhat
-Every Computer Scientist should Know About Floating-Point Arithmetic\fP, D.
-Goldberg, \fBACM Computing Surveys, Vol. 23, No. 1\fP, March 1991, pp. 5-48.
-
-.SH "SEE ALSO"
-.LP
-.BR ncgen (1),
-.BR netcdf (3)
-.SH BUGS
-.LP
-Character arrays that contain a null-byte are treated like C strings, so no
-characters after the null byte appear in the output.
-
-Multidimensional character string arrays are not handled well, since the CDL
-syntax for breaking a long character string into several shorter lines is
-weak.
-
-There should be a way to specify that the data should be displayed in
-`record' order, that is with the all the values for `record' variables
-together that have the same value of the record dimension.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.c
deleted file mode 100644
index db9dc3e..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/README file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-#include <netcdf.h>
-#include "ncdump.h"
-#include "dumplib.h"
-#include "vardata.h"
-
-static void usage(void);
-static char* name_path(const char* path);
-static char* type_name(nc_type type);
-static void tztrim(char* ss);
-static void pr_att_string(size_t len, const char* string);
-static void pr_att_vals(nc_type type, size_t len, const double* vals);
-static void pr_att(int ncid, int varid, const char *varname, int ia);
-static void do_ncdump(const char* path, struct fspec* specp);
-static void make_lvars(char* optarg, struct fspec* fspecp);
-static void set_sigdigs( const char* optarg);
-static void set_precision( const char *optarg);
-int main(int argc, char** argv);
-
-#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-
-char *progname;
-
-static void
-usage(void)
-{
-#define USAGE "\
- [-c] Coordinate variable data and header information\n\
- [-h] Header information only, no data\n\
- [-v var1[,...]] Data for variable(s) <var1>,... only\n\
- [-b [c|f]] Brief annotations for C or Fortran indices in data\n\
- [-f [c|f]] Full annotations for C or Fortran indices in data\n\
- [-l len] Line length maximum in data section (default 80)\n\
- [-n name] Name for netCDF (default derived from file name)\n\
- [-p n[,n]] Display floating-point values with less precision\n\
- file File name of input netCDF file\n"
-
- (void) fprintf(stderr,
- "%s [-c|-h] [-v ...] [[-b|-f] [c|f]] [-l len] [-n name] [-p n[,n]] file\n%s",
- progname,
- USAGE);
-
- (void) fprintf(stderr,
- "netcdf library version %s\n",
- nc_inq_libvers());
- exit(EXIT_FAILURE);
-}
-
-
-/*
- * convert pathname of netcdf file into name for cdl unit, by taking
- * last component of path and stripping off any extension.
- */
-static char *
-name_path(const char *path)
-{
- const char *cp;
- char *new;
- char *sp;
-
-#ifdef vms
-#define FILE_DELIMITER ']'
-#endif
-#ifdef MSDOS
-#define FILE_DELIMITER '\\'
-#endif
-#ifndef FILE_DELIMITER /* default to unix */
-#define FILE_DELIMITER '/'
-#endif
- cp = strrchr(path, FILE_DELIMITER);
- if (cp == 0) /* no delimiter */
- cp = path;
- else /* skip delimeter */
- cp++;
- new = (char *) malloc((unsigned) (strlen(cp)+1));
- if (new == 0) {
- error("out of memory!");
- }
- (void) strcpy(new, cp); /* copy last component of path */
- if ((sp = strrchr(new, '.')) != NULL)
- *sp = '\0'; /* strip off any extension */
- return new;
-}
-
-
-static char *
-type_name(nc_type type)
-{
- switch (type) {
- case NC_BYTE:
- return "byte";
- case NC_CHAR:
- return "char";
- case NC_SHORT:
- return "short";
- case NC_INT:
- return "int";
- case NC_FLOAT:
- return "float";
- case NC_DOUBLE:
- return "double";
- default:
- error("type_name: bad type %d", type);
- return "bogus";
- }
-}
-
-
-/*
- * Remove trailing zeros (after decimal point) but not trailing decimal
- * point from ss, a string representation of a floating-point number that
- * might include an exponent part.
- */
-static void
-tztrim(char *ss)
-{
- char *cp, *ep;
-
- cp = ss;
- if (*cp == '-')
- cp++;
- while(isdigit((int)*cp) || *cp == '.')
- cp++;
- if (*--cp == '.')
- return;
- ep = cp+1;
- while (*cp == '0')
- cp--;
- cp++;
- if (cp == ep)
- return;
- while (*ep)
- *cp++ = *ep++;
- *cp = '\0';
- return;
-}
-
-
-/*
- * Print attribute string, for text attributes.
- */
-static void
-pr_att_string(
- size_t len,
- const char *string
- )
-{
- int iel;
- const char *cp;
- const char *sp;
- unsigned char uc;
-
- cp = string;
- Printf ("\"");
- /* adjust len so trailing nulls don't get printed */
- sp = cp + len - 1;
- while (len != 0 && *sp-- == '\0')
- len--;
- for (iel = 0; iel < len; iel++)
- switch (uc = *cp++ & 0377) {
- case '\b':
- Printf ("\\b");
- break;
- case '\f':
- Printf ("\\f");
- break;
- case '\n': /* generate linebreaks after new-lines */
- Printf ("\\n\",\n \"");
- break;
- case '\r':
- Printf ("\\r");
- break;
- case '\t':
- Printf ("\\t");
- break;
- case '\v':
- Printf ("\\v");
- break;
- case '\\':
- Printf ("\\\\");
- break;
- case '\'':
- Printf ("\\'");
- break;
- case '\"':
- Printf ("\\\"");
- break;
- default:
- Printf ("%c",uc);
- break;
- }
- Printf ("\"");
-
-}
-
-
-/*
- * Print list of attribute values, for numeric attributes. Attribute values
- * must be printed with explicit type tags, because CDL doesn't have explicit
- * syntax to declare an attribute type.
- */
-static void
-pr_att_vals(
- nc_type type,
- size_t len,
- const double *vals
- )
-{
- int iel;
- signed char sc;
- short ss;
- int ii;
- char gps[30];
- float ff;
- double dd;
-
- if (len == 0)
- return;
- for (iel = 0; iel < len-1; iel++) {
- switch (type) {
- case NC_BYTE:
- sc = (signed char) vals[iel] & 0377;
- Printf ("%db, ", sc);
- break;
- case NC_SHORT:
- ss = vals[iel];
- Printf ("%ds, ", ss);
- break;
- case NC_INT:
- ii = (int) vals[iel];
- Printf ("%d, ", ii);
- break;
- case NC_FLOAT:
- ff = vals[iel];
- (void) sprintf(gps, float_att_fmt, ff);
- tztrim(gps); /* trim trailing 0's after '.' */
- Printf ("%s, ", gps);
- break;
- case NC_DOUBLE:
- dd = vals[iel];
- (void) sprintf(gps, double_att_fmt, dd);
- tztrim(gps);
- Printf ("%s, ", gps);
- break;
- default:
- error("pr_att_vals: bad type");
- }
- }
- switch (type) {
- case NC_BYTE:
- sc = (signed char) vals[iel] & 0377;
- Printf ("%db", sc);
- break;
- case NC_SHORT:
- ss = vals[iel];
- Printf ("%ds", ss);
- break;
- case NC_INT:
- ii = (int) vals[iel];
- Printf ("%d", ii);
- break;
- case NC_FLOAT:
- ff = vals[iel];
- (void) sprintf(gps, float_att_fmt, ff);
- tztrim(gps);
- Printf ("%s", gps);
- break;
- case NC_DOUBLE:
- dd = vals[iel];
- (void) sprintf(gps, double_att_fmt, dd);
- tztrim(gps);
- Printf ("%s", gps);
- break;
- default:
- error("pr_att_vals: bad type");
- }
-}
-
-
-static void
-pr_att(
- int ncid,
- int varid,
- const char *varname,
- int ia
- )
-{
- struct ncatt att; /* attribute */
-
- NC_CHECK( nc_inq_attname(ncid, varid, ia, att.name) );
-
- Printf ("\t\t%s:%s = ", varname, att.name);
-
- NC_CHECK( nc_inq_att(ncid, varid, att.name, &att.type, &att.len) );
-
- if (att.len == 0) { /* show 0-length attributes as empty strings */
- att.type = NC_CHAR;
- att.len = 1;
- }
- switch (att.type) {
- case NC_CHAR:
- att.string = (char *) malloc(att.len);
- if (!att.string) {
- error("Out of memory!");
- NC_CHECK( nc_close(ncid) );
- return;
- }
- NC_CHECK( nc_get_att_text(ncid, varid, att.name, att.string ) );
- pr_att_string(att.len, att.string);
- free(att.string);
- break;
- default:
- att.vals = (double *) malloc(att.len * sizeof(double));
- if (!att.vals) {
- error("Out of memory!");
- NC_CHECK( nc_close(ncid) );
- return;
- }
- NC_CHECK( nc_get_att_double(ncid, varid, att.name, att.vals ) );
- pr_att_vals(att.type, att.len, att.vals);
- free(att.vals);
- break;
- }
- Printf (" ;\n");
-}
-
-
-static void
-do_ncdump(const char *path, struct fspec* specp)
-{
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int ngatts; /* number of global attributes */
- int xdimid; /* id of unlimited dimension */
- int dimid; /* dimension id */
- int varid; /* variable id */
- struct ncdim dims[NC_MAX_DIMS]; /* dimensions */
- size_t vdims[NC_MAX_DIMS]; /* dimension sizes for a single variable */
- struct ncvar var; /* variable */
- struct ncatt att; /* attribute */
- int id; /* dimension number per variable */
- int ia; /* attribute number */
- int iv; /* variable number */
- int is_coord; /* true if variable is a coordinate variable */
- int ncid; /* netCDF id */
- vnode* vlist = 0; /* list for vars specified with -v option */
- int nc_status; /* return from netcdf calls */
-
- nc_status = nc_open(path, NC_NOWRITE, &ncid);
- if (nc_status != NC_NOERR) {
- error("%s: %s", path, nc_strerror(nc_status));
- }
- /*
- * If any vars were specified with -v option, get list of associated
- * variable ids
- */
- if (specp->nlvars > 0) {
- vlist = newvlist(); /* list for vars specified with -v option */
- for (iv=0; iv < specp->nlvars; iv++) {
- NC_CHECK( nc_inq_varid(ncid, specp->lvars[iv], &varid) );
- varadd(vlist, varid);
- }
- }
-
- /* if name not specified, derive it from path */
- if (specp->name == (char *)0) {
- specp->name = name_path (path);
- }
-
- Printf ("netcdf %s {\n", specp->name);
- /*
- * get number of dimensions, number of variables, number of global
- * atts, and dimension id of unlimited dimension, if any
- */
- NC_CHECK( nc_inq(ncid, &ndims, &nvars, &ngatts, &xdimid) );
- /* get dimension info */
- if (ndims > 0)
- Printf ("dimensions:\n");
- for (dimid = 0; dimid < ndims; dimid++) {
- NC_CHECK( nc_inq_dim(ncid, dimid, dims[dimid].name, &dims[dimid].size) );
- if (dimid == xdimid)
- Printf ("\t%s = %s ; // (%ld currently)\n",dims[dimid].name,
- "UNLIMITED", (long)dims[dimid].size);
- else
- Printf ("\t%s = %ld ;\n", dims[dimid].name, (long)dims[dimid].size);
- }
-
- if (nvars > 0)
- Printf ("variables:\n");
- /* get variable info, with variable attributes */
- for (varid = 0; varid < nvars; varid++) {
- NC_CHECK( nc_inq_var(ncid, varid, var.name, &var.type, &var.ndims,
- var.dims, &var.natts) );
- Printf ("\t%s %s", type_name(var.type), var.name);
- if (var.ndims > 0)
- Printf ("(");
- for (id = 0; id < var.ndims; id++) {
- Printf ("%s%s",
- dims[var.dims[id]].name,
- id < var.ndims-1 ? ", " : ")");
- }
- Printf (" ;\n");
-
- /* get variable attributes */
- for (ia = 0; ia < var.natts; ia++)
- pr_att(ncid, varid, var.name, ia); /* print ia-th attribute */
- }
-
-
- /* get global attributes */
- if (ngatts > 0)
- Printf ("\n// global attributes:\n");
- for (ia = 0; ia < ngatts; ia++)
- pr_att(ncid, NC_GLOBAL, "", ia); /* print ia-th global attribute */
-
- if (! specp->header_only) {
- if (nvars > 0) {
- Printf ("data:\n");
- }
- /* output variable data */
- for (varid = 0; varid < nvars; varid++) {
- /* if var list specified, test for membership */
- if (specp->nlvars > 0 && ! varmember(vlist, varid))
- continue;
- NC_CHECK( nc_inq_var(ncid, varid, var.name, &var.type, &var.ndims,
- var.dims, &var.natts) );
- if (specp->coord_vals) {
- /* Find out if this is a coordinate variable */
- is_coord = 0;
- for (dimid = 0; dimid < ndims; dimid++) {
- if (strcmp(dims[dimid].name, var.name) == 0 &&
- var.ndims == 1) {
- is_coord = 1;
- break;
- }
- }
- if (! is_coord) /* don't get data for non-coordinate vars */
- continue;
- }
- /*
- * Only get data for variable if it is not a record variable,
- * or if it is a record variable and at least one record has
- * been written.
- */
- if (var.ndims == 0
- || var.dims[0] != xdimid
- || dims[xdimid].size != 0) {
-
- /* Collect variable's dim sizes */
- for (id = 0; id < var.ndims; id++)
- vdims[id] = dims[var.dims[id]].size;
- var.has_fillval = 1; /* by default, but turn off for bytes */
-
- /* get _FillValue attribute */
- nc_status = nc_inq_att(ncid,varid,_FillValue,&att.type,&att.len);
- if(nc_status == NC_NOERR &&
- att.type == var.type && att.len == 1) {
- if(var.type == NC_CHAR) {
- char fillc;
- NC_CHECK( nc_get_att_text(ncid, varid, _FillValue,
- &fillc ) );
- var.fillval = fillc;
- } else {
- NC_CHECK( nc_get_att_double(ncid, varid, _FillValue,
- &var.fillval) );
- }
- } else {
- switch (var.type) {
- case NC_BYTE:
- /* don't do default fill-values for bytes, too risky */
- var.has_fillval = 0;
- break;
- case NC_CHAR:
- var.fillval = NC_FILL_CHAR;
- break;
- case NC_SHORT:
- var.fillval = NC_FILL_SHORT;
- break;
- case NC_INT:
- var.fillval = NC_FILL_INT;
- break;
- case NC_FLOAT:
- var.fillval = NC_FILL_FLOAT;
- break;
- case NC_DOUBLE:
- var.fillval = NC_FILL_DOUBLE;
- break;
- default:
- break;
- }
- }
- if (vardata(&var, vdims, ncid, varid, specp) == -1) {
- error("can't output data for variable %s", var.name);
- NC_CHECK(
- nc_close(ncid) );
- if (vlist)
- free(vlist);
- return;
- }
- }
- }
- }
-
- Printf ("}\n");
- NC_CHECK(
- nc_close(ncid) );
- if (vlist)
- free(vlist);
-}
-
-
-static void
-make_lvars(char *optarg, struct fspec* fspecp)
-{
- char *cp = optarg;
- int nvars = 1;
- char ** cpp;
-
- /* compute number of variable names in comma-delimited list */
- fspecp->nlvars = 1;
- while (*cp++)
- if (*cp == ',')
- nvars++;
-
- fspecp->lvars = (char **) malloc(nvars * sizeof(char*));
- if (!fspecp->lvars) {
- error("out of memory");
- }
-
- cpp = fspecp->lvars;
- /* copy variable names into list */
- for (cp = strtok(optarg, ",");
- cp != NULL;
- cp = strtok((char *) NULL, ",")) {
-
- *cpp = (char *) malloc(strlen(cp) + 1);
- if (!*cpp) {
- error("out of memory");
- }
- strcpy(*cpp, cp);
- cpp++;
- }
- fspecp->nlvars = nvars;
-}
-
-
-/*
- * Extract the significant-digits specifiers from the -d argument on the
- * command-line and update the default data formats appropriately.
- */
-static void
-set_sigdigs(const char *optarg)
-{
- char *ptr1 = 0;
- char *ptr2 = 0;
- int flt_digits = FLT_DIGITS; /* default floating-point digits */
- int dbl_digits = DBL_DIGITS; /* default double-precision digits */
-
- if (optarg != 0 && (int) strlen(optarg) > 0 && optarg[0] != ',')
- flt_digits = (int)strtol(optarg, &ptr1, 10);
-
- if (flt_digits < 1 || flt_digits > 20) {
- error("unreasonable value for float significant digits: %d",
- flt_digits);
- }
- if (*ptr1 == ',')
- dbl_digits = (int)strtol(ptr1+1, &ptr2, 10);
- if (ptr2 == ptr1+1 || dbl_digits < 1 || dbl_digits > 20) {
- error("unreasonable value for double significant digits: %d",
- dbl_digits);
- }
- set_formats(flt_digits, dbl_digits);
-}
-
-
-/*
- * Extract the significant-digits specifiers from the -p argument on the
- * command-line, set flags so we can override C_format attributes (if any),
- * and update the default data formats appropriately.
- */
-static void
-set_precision(const char *optarg)
-{
- char *ptr1 = 0;
- char *ptr2 = 0;
- int flt_digits = FLT_DIGITS; /* default floating-point digits */
- int dbl_digits = DBL_DIGITS; /* default double-precision digits */
-
- if (optarg != 0 && (int) strlen(optarg) > 0 && optarg[0] != ',') {
- flt_digits = (int)strtol(optarg, &ptr1, 10);
- float_precision_specified = 1;
- }
-
- if (flt_digits < 1 || flt_digits > 20) {
- error("unreasonable value for float significant digits: %d",
- flt_digits);
- }
- if (*ptr1 == ',') {
- dbl_digits = (int) strtol(ptr1+1, &ptr2, 10);
- double_precision_specified = 1;
- }
- if (ptr2 == ptr1+1 || dbl_digits < 1 || dbl_digits > 20) {
- error("unreasonable value for double significant digits: %d",
- dbl_digits);
- }
- set_formats(flt_digits, dbl_digits);
-}
-
-
-int
-main(int argc, char *argv[])
-{
- extern int optind;
- extern int opterr;
- extern char *optarg;
- static struct fspec fspec = /* defaults, overridden on command line */
- {
- 0, /* construct netcdf name from file name */
- false, /* print header info only, no data? */
- false, /* just print coord vars? */
- false, /* brief comments in data section? */
- false, /* full annotations in data section? */
- LANG_C, /* language conventions for indices */
- 0, /* if -v specified, number of variables */
- 0 /* if -v specified, list of variable names */
- };
- int c;
- int i;
- int max_len = 80; /* default maximum line length */
-
- opterr = 1;
- progname = argv[0];
- set_formats(FLT_DIGITS, DBL_DIGITS); /* default for float, double data */
-
- while ((c = getopt(argc, argv, "b:cf:hl:n:v:d:p:")) != EOF)
- switch(c) {
- case 'h': /* dump header only, no data */
- fspec.header_only = true;
- break;
- case 'c': /* header, data only for coordinate dims */
- fspec.coord_vals = true;
- break;
- case 'n': /*
- * provide different name than derived from
- * file name
- */
- fspec.name = optarg;
- break;
- case 'b': /* brief comments in data section */
- fspec.brief_data_cmnts = true;
- switch (tolower(optarg[0])) {
- case 'c':
- fspec.data_lang = LANG_C;
- break;
- case 'f':
- fspec.data_lang = LANG_F;
- break;
- default:
- error("invalid value for -b option: %s", optarg);
- }
- break;
- case 'f': /* full comments in data section */
- fspec.full_data_cmnts = true;
- switch (tolower(optarg[0])) {
- case 'c':
- fspec.data_lang = LANG_C;
- break;
- case 'f':
- fspec.data_lang = LANG_F;
- break;
- default:
- error("invalid value for -f option: %s", optarg);
- }
- break;
- case 'l': /* maximum line length */
- max_len = (int) strtol(optarg, 0, 0);
- if (max_len < 10) {
- error("unreasonably small line length specified: %d", max_len);
- }
- break;
- case 'v': /* variable names */
- /* make list of names of variables specified */
- make_lvars (optarg, &fspec);
- break;
- case 'd': /* specify precision for floats (old option) */
- set_sigdigs(optarg);
- break;
- case 'p': /* specify precision for floats */
- set_precision(optarg);
- break;
- case '?':
- usage();
- break;
- }
-
- set_max_len(max_len);
-
- argc -= optind;
- argv += optind;
-
- i = 0;
-
- do {
- if (argc > 0)
- do_ncdump(argv[i], &fspec);
- } while (++i < argc);
-#ifdef vms
- exit(EXIT_SUCCESS);
-#else
- return EXIT_SUCCESS;
-#endif
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.h
deleted file mode 100644
index a8d8d7c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/ncdump.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-
-/* error checking macro */
-#define NC_CHECK(status) {\
- int nc_status = status;\
- if(nc_status != NC_NOERR)\
- error(nc_strerror(nc_status));\
- }
-
-#define Printf (void) printf
-
-typedef int boolean;
-enum {false=0, true=1};
-
-struct ncdim { /* dimension */
- char name[NC_MAX_NAME];
- size_t size;
-};
-
-struct ncvar { /* variable */
- char name[NC_MAX_NAME];
- nc_type type;
- int ndims;
- int dims[MAX_VAR_DIMS];
- int natts;
- boolean has_fillval;
- double fillval;
-};
-
-struct ncatt { /* attribute */
- int var;
- char name[NC_MAX_NAME];
- nc_type type;
- size_t len;
- char *string; /* for text attributes (type = NC_CHAR) */
- double *vals; /* for numeric attributes of all types */
-};
-
-typedef
-enum {LANG_C, LANG_F} Nclang;
-
-struct fspec { /* specification for how to format dump */
-
- char *name; /* name specified with -n or derived from
- * file name */
-
- boolean header_only; /* if true, don't print any variable data */
-
- boolean coord_vals; /* if true, print header and coordinate
- * dimension values (values of variables
- * that are also dimensions), but no other
- * variable data */
-
- boolean brief_data_cmnts; /* if true, put // comments in data section
- * identifying variable and indices, useful
- * for navigating through large
- * multi-dimensional data lists. */
-
- boolean full_data_cmnts; /* if true, put // comments in data section
- * identifying every value, useful for
- * navigating through large
- * multi-dimensional data lists. */
-
- Nclang data_lang; /* Specifies index conventions used in data
- * comments, either LANG_C (C, 0-based,
- * column major) or LANG_F (Fortran,
- * 1-based, row major) */
-
- int nlvars; /* Number of variables specified with -v
- * option on command line */
-
- char** lvars; /* list of variable names specified with -v
- * option on command line */
-};
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/test0.cdl b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/test0.cdl
deleted file mode 100644
index 7df86f9..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/test0.cdl
+++ /dev/null
@@ -1,46 +0,0 @@
-netcdf test0 {
-
-dimensions:
- i = 2;
- j = 3;
- k = unlimited;
- l = 3 ;
-
-variables:
- char broiled(i,j,l);
- broiled:act = "text string\n\t123";
- broiled:acb = 10b;
- broiled:acs = -200s ;
- broiled:acl = 17000 ;
- broiled:acf = -2.0f, 1.f, 0.0f ;
- broiled:acd = -1.0, 2.7182818284590455;
- byte the_bullet(i,j);
- short order(i,j);
- int rigue(i,j);
- float a_loan(i,j);
- double entendre(i,j);
- char cscalar;
- double dscalar;
- char cnodata(i);
- byte bnodata(i);
- short snodata(i);
- int inodata(i);
- float fnodata(i);
- double dnodata(i);
- int i(i);
- float j(j);
- byte l(l);
-
- :glob = "Global attribute" ;
-
-data:
- broiled = "indistinguishable" ;
- the_bullet = -127,0,127,128,255;
- order = 1s, 2s, 3s, 4s, 5s, 6s;
- rigue = 2, 3, 4, 5, 6, 7 ;
- a_loan = 3.f, 4.f, 5.f, 6.f, 7.f, 1.0e12f ;
- entendre = '\4', 5s, 6, 7.0f, 8.0, 1.0e30 ;
- i = 10, 20;
- j = 2, 4, 6;
- l = 10, 9, 8;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.c
deleted file mode 100644
index 71dc879..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.c
+++ /dev/null
@@ -1,862 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#ifndef NO_FLOAT_H
-#include <float.h> /* for FLT_EPSILON, DBL_EPSILON */
-#endif /* NO_FLOAT_H */
-
-#include <netcdf.h>
-#include "ncdump.h"
-#include "dumplib.h"
-#include "vardata.h"
-
-static float float_epsilon(void);
-static double double_epsilon(void);
-static void init_epsilons(void);
-static void printbval(char* sout, const char* fmt, const struct ncvar* varp,
- signed char val);
-static void printsval(char* sout, const char* fmt, const struct ncvar* varp,
- short val);
-static void printival(char* sout, const char* fmt, const struct ncvar* varp,
- int val);
-static void printfval(char* sout, const char* fmt, const struct ncvar* varp,
- float val);
-static void printdval(char* sout, const char* fmt, const struct ncvar* varp,
- double val);
-static void lastdelim(boolean more, boolean lastrow);
-static void annotate(const struct ncvar* vp, const struct fspec* fsp,
- const size_t* cor, long iel);
-static void pr_tvals(const struct ncvar *vp, size_t len, const char *fmt,
- boolean more, boolean lastrow, const char *vals,
- const struct fspec* fsp, const size_t *cor);
-static void pr_bvals(const struct ncvar *vp, size_t len, const char *fmt,
- boolean more, boolean lastrow, const signed char *vals,
- const struct fspec* fsp, const size_t *cor);
-static void pr_svals(const struct ncvar *vp, size_t len, const char *fmt,
- boolean more, boolean lastrow, const short *vals,
- const struct fspec* fsp, const size_t *cor);
-static void pr_ivals(const struct ncvar *vp, size_t len, const char *fmt,
- boolean more, boolean lastrow, const int *vals,
- const struct fspec* fsp, const size_t *cor);
-static void pr_fvals(const struct ncvar *vp, size_t len, const char *fmt,
- boolean more, boolean lastrow, const float *vals,
- const struct fspec* fsp, const size_t *cor);
-static void pr_dvals(const struct ncvar *vp, size_t len, const char *fmt,
- boolean more, boolean lastrow, const double *vals,
- const struct fspec* fsp, const size_t *cor);
-static int upcorner(const size_t* dims, int ndims, size_t* odom,
- const size_t* add);
-static void lastdelim2 (boolean more, boolean lastrow);
-
-#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-
-static float float_eps;
-static double double_eps;
-
-static float
-float_epsilon(void)
-{
- float float_eps;
-#ifndef NO_FLOAT_H
- float_eps = FLT_EPSILON;
-#else /* NO_FLOAT_H */
- {
- float etop, ebot, eps;
- float one = 1.0;
- float two = 2.0;
- etop = 1.0;
- ebot = 0.0;
- eps = ebot + (etop - ebot)/two;
- while (eps != ebot && eps != etop) {
- float epsp1;
-
- epsp1 = one + eps;
- if (epsp1 > one)
- etop = eps;
- else
- ebot = eps;
- eps = ebot + (etop - ebot)/two;
- }
- float_eps = two * etop;
- }
-#endif /* NO_FLOAT_H */
- return float_eps;
-}
-
-
-static double
-double_epsilon(void)
-{
- double double_eps;
-#ifndef NO_FLOAT_H
- double_eps = DBL_EPSILON;
-#else /* NO_FLOAT_H */
- {
- double etop, ebot, eps;
- double one = 1.0;
- double two = 2.0;
- etop = 1.0;
- ebot = 0.0;
- eps = ebot + (etop - ebot)/two;
- while (eps != ebot && eps != etop) {
- double epsp1;
-
- epsp1 = one + eps;
- if (epsp1 > one)
- etop = eps;
- else
- ebot = eps;
- eps = ebot + (etop - ebot)/two;
- }
- double_eps = two * etop;
- }
-#endif /* NO_FLOAT_H */
- return double_eps;
-}
-
-
-static void
-init_epsilons(void)
-{
- float_eps = float_epsilon();
- double_eps = double_epsilon();
-}
-
-/*
- * Output a value of a byte variable, except if there is a fill value for
- * the variable and the value is the fill value, print the fill-value string
- * instead.
- */
-static void
-printbval(
- char *sout, /* string where output goes */
- const char *fmt, /* printf format used for value */
- const struct ncvar *varp, /* variable */
- signed char val /* value */
- )
-{
- if (varp->has_fillval) {
- double fillval = varp->fillval;
- if(fillval == val) {
- (void) sprintf(sout, FILL_STRING);
- return;
- }
- }
- (void) sprintf(sout, fmt, val);
-}
-
-/*
- * Output a value of a short variable, except if there is a fill value for
- * the variable and the value is the fill value, print the fill-value string
- * instead.
- */
-static void
-printsval(
- char *sout, /* string where output goes */
- const char *fmt, /* printf format used for value */
- const struct ncvar *varp, /* variable */
- short val /* value */
- )
-{
- if (varp->has_fillval) {
- double fillval = varp->fillval;
- if(fillval == val) {
- (void) sprintf(sout, FILL_STRING);
- return;
- }
- }
- (void) sprintf(sout, fmt, val);
-}
-
-
-/*
- * Output a value of an int variable, except if there is a fill value for
- * the variable and the value is the fill value, print the fill-value string
- * instead.
- */
-static void
-printival(
- char *sout, /* string where output goes */
- const char *fmt, /* printf format used for value */
- const struct ncvar *varp, /* variable */
- int val /* value */
- )
-{
- if (varp->has_fillval) {
- int fillval = (int)varp->fillval;
- if(fillval == val) {
- (void) sprintf(sout, FILL_STRING);
- return;
- }
- }
- (void) sprintf(sout, fmt, val);
-}
-
-
-#define absval(x) ( (x) < 0 ? -(x) : (x) )
-
-/*
- * Output a value of a float variable, except if there is a fill value for
- * the variable and the value is the fill value, print the fill-value string
- * instead. Floating-point fill values need only be within machine epsilon of
- * defined fill value.
- */
-static void
-printfval(
- char *sout, /* string where output goes */
- const char *fmt, /* printf format used for value */
- const struct ncvar *varp, /* variable */
- float val /* value */
- )
-{
- if(varp->has_fillval) {
- double fillval = varp->fillval;
- if((val > 0) == (fillval > 0) && /* prevents potential overflow */
- (absval(val - fillval) <= absval(float_eps * fillval))) {
- (void) sprintf(sout, FILL_STRING);
- return;
- }
- }
- (void) sprintf(sout, fmt, val);
-}
-
-
-/*
- * Output a value of a double variable, except if there is a fill value for
- * the variable and the value is the fill value, print the fill-value string
- * instead. Floating-point fill values need only be within machine epsilon of
- * defined fill value.
- */
-static void
-printdval(
- char *sout, /* string where output goes */
- const char *fmt, /* printf format used for value */
- const struct ncvar *varp, /* variable */
- double val /* value */
- )
-{
- if(varp->has_fillval) {
- double fillval = varp->fillval;
- if((val > 0) == (fillval > 0) && /* prevents potential overflow */
- (absval(val - fillval) <= absval(double_eps * fillval))) {
- (void) sprintf(sout, FILL_STRING);
- return;
- }
- }
- (void) sprintf(sout, fmt, val);
-}
-
-
-/*
- * print last delimiter in each line before annotation (, or ;)
- */
-static void
-lastdelim (boolean more, boolean lastrow)
-{
- if (more) {
- Printf(", ");
- } else {
- if(lastrow) {
- Printf(";");
- } else {
- Printf(",");
- }
- }
-}
-
-/*
- * print last delimiter in each line before annotation (, or ;)
- */
-static void
-lastdelim2 (boolean more, boolean lastrow)
-{
- if (more) {
- lput(", ");
- } else {
- if(lastrow) {
- lput(" ;");
- lput("\n");
- } else {
- lput(",\n");
- lput(" ");
- }
- }
-}
-
-
-/*
- * Annotates a value in data section with var name and indices in comment
- */
-static void
-annotate(
- const struct ncvar *vp, /* variable */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor, /* corner coordinates */
- long iel /* which element in current row */
- )
-{
- int vrank = vp->ndims;
- int id;
-
- /* print indices according to data_lang */
- (void) printf(" // %s(", vp->name);
- switch (fsp->data_lang) {
- case LANG_C:
- /* C variable indices */
- for (id = 0; id < vrank-1; id++)
- Printf("%lu,", (unsigned long) cor[id]);
- Printf("%lu", (unsigned long) cor[id] + iel);
- break;
- case LANG_F:
- /* Fortran variable indices */
- Printf("%lu", (unsigned long) cor[vrank-1] + iel + 1);
- for (id = vrank-2; id >=0 ; id--) {
- Printf(",%lu", 1 + (unsigned long) cor[id]);
- }
- break;
- }
- Printf(")\n ");
-}
-
-
-/*
- * Print a number of char variable values, where the optional comments
- * for each value identify the variable, and each dimension index.
- */
-static void
-pr_tvals(
- const struct ncvar *vp, /* variable */
- size_t len, /* number of values to print */
- const char *fmt, /* printf format used for each value. If
- * nc_type is NC_CHAR and this is NULL,
- * character arrays will be printed as
- * strings enclosed in quotes. */
- boolean more, /* true if more data for this row will
- * follow, so add trailing comma */
- boolean lastrow, /* true if this is the last row for this
- * variable, so terminate with ";" instead
- * of "," */
- const char *vals, /* pointer to block of values */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor /* corner coordinates */
- )
-{
- long iel;
- const char *sp;
- unsigned char uc;
- char sout[100]; /* temporary string for each encoded output */
-
- if (fmt == 0 || STREQ(fmt,"%s") || STREQ(fmt,"")) { /* as string */
- Printf("\"");
- /* adjust len so trailing nulls don't get printed */
- sp = vals + len;
- while (len != 0 && *--sp == '\0')
- len--;
- for (iel = 0; iel < len; iel++)
- switch (uc = *vals++ & 0377) {
- case '\b':
- Printf("\\b");
- break;
- case '\f':
- Printf("\\f");
- break;
- case '\n': /* generate linebreaks after new-lines */
- Printf("\\n\",\n \"");
- break;
- case '\r':
- Printf("\\r");
- break;
- case '\t':
- Printf("\\t");
- break;
- case '\v':
- Printf("\\v");
- break;
- case '\\':
- Printf("\\\\");
- break;
- case '\'':
- Printf("\\\'");
- break;
- case '\"':
- Printf("\\\"");
- break;
- default:
- if (isprint(uc))
- Printf("%c",uc);
- else
- Printf("\\%.3o",uc);
- break;
- }
- Printf("\"");
- if (fsp->full_data_cmnts) {
- Printf("\"");
- lastdelim (more, lastrow);
- annotate (vp, fsp, (size_t *)cor, 0L);
- }
- } else { /* use format from C_format attribute */
- for (iel = 0; iel < len-1; iel++) {
- if (fsp->full_data_cmnts) {
- Printf(fmt, *vals++);
- Printf(", ");
- annotate (vp, fsp, (size_t *)cor, iel);
- } else {
- (void) sprintf(sout, fmt, *vals++);
- (void) strcat(sout, ", ");
- lput(sout);
- }
- }
- if (fsp->full_data_cmnts) {
- Printf(fmt, *vals++);
- lastdelim (more, lastrow);
- annotate (vp, fsp, (size_t *)cor, iel);
- } else {
- (void) sprintf(sout, fmt, *vals++);
- lput(sout);
- }
- }
- if (!fsp->full_data_cmnts) {
- lastdelim2 (more, lastrow);
- }
-}
-
-
-/*
- * Print a number of byte variable values, where the optional comments
- * for each value identify the variable, and each dimension index.
- */
-static void
-pr_bvals(
- const struct ncvar *vp, /* variable */
- size_t len, /* number of values to print */
- const char *fmt, /* printf format used for each value. If
- * nc_type is NC_CHAR and this is NULL,
- * character arrays will be printed as
- * strings enclosed in quotes. */
- boolean more, /* true if more data for this row will
- * follow, so add trailing comma */
- boolean lastrow, /* true if this is the last row for this
- * variable, so terminate with ";" instead
- * of "," */
- const signed char *vals, /* pointer to block of values */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor /* corner coordinates */
- )
-{
- long iel;
- char sout[100]; /* temporary string for each encoded output */
-
- for (iel = 0; iel < len-1; iel++) {
- printbval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- Printf(",");
- annotate (vp, fsp, cor, iel);
- } else {
- (void) strcat(sout, ", ");
- lput(sout);
- }
- }
- printbval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- lastdelim (more, lastrow);
- annotate (vp, fsp, cor, iel);
- } else {
- lput(sout);
- lastdelim2 (more, lastrow);
- }
-}
-
-
-/*
- * Print a number of short variable values, where the optional comments
- * for each value identify the variable, and each dimension index.
- */
-static void
-pr_svals(
- const struct ncvar *vp, /* variable */
- size_t len, /* number of values to print */
- const char *fmt, /* printf format used for each value. If
- * nc_type is NC_CHAR and this is NULL,
- * character arrays will be printed as
- * strings enclosed in quotes. */
- boolean more, /* true if more data for this row will
- * follow, so add trailing comma */
- boolean lastrow, /* true if this is the last row for this
- * variable, so terminate with ";" instead
- * of "," */
- const short *vals, /* pointer to block of values */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor /* corner coordinates */
- )
-{
- long iel;
- char sout[100]; /* temporary string for each encoded output */
-
- for (iel = 0; iel < len-1; iel++) {
- printsval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- Printf(",");
- annotate (vp, fsp, cor, iel);
- } else {
- (void) strcat(sout, ", ");
- lput(sout);
- }
- }
- printsval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- lastdelim (more, lastrow);
- annotate (vp, fsp, cor, iel);
- } else {
- lput(sout);
- lastdelim2 (more, lastrow);
- }
-}
-
-
-
-
-/*
- * Print a number of int variable values, where the optional comments
- * for each value identify the variable, and each dimension index.
- */
-static void
-pr_ivals(
- const struct ncvar *vp, /* variable */
- size_t len, /* number of values to print */
- const char *fmt, /* printf format used for each value. If
- * nc_type is NC_CHAR and this is NULL,
- * character arrays will be printed as
- * strings enclosed in quotes. */
- boolean more, /* true if more data for this row will
- * follow, so add trailing comma */
- boolean lastrow, /* true if this is the last row for this
- * variable, so terminate with ";" instead
- * of "," */
- const int *vals, /* pointer to block of values */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor /* corner coordinates */
- )
-{
- long iel;
- char sout[100]; /* temporary string for each encoded output */
-
- for (iel = 0; iel < len-1; iel++) {
- printival(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- Printf(",");
- annotate (vp, fsp, cor, iel);
- } else {
- (void) strcat(sout, ", ");
- lput(sout);
- }
- }
- printival(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- lastdelim (more, lastrow);
- annotate (vp, fsp, cor, iel);
- } else {
- lput(sout);
- lastdelim2 (more, lastrow);
- }
-}
-
-
-/*
- * Print a number of float variable values, where the optional comments
- * for each value identify the variable, and each dimension index.
- */
-static void
-pr_fvals(
- const struct ncvar *vp, /* variable */
- size_t len, /* number of values to print */
- const char *fmt, /* printf format used for each value. If
- * nc_type is NC_CHAR and this is NULL,
- * character arrays will be printed as
- * strings enclosed in quotes. */
- boolean more, /* true if more data for this row will
- * follow, so add trailing comma */
- boolean lastrow, /* true if this is the last row for this
- * variable, so terminate with ";" instead
- * of "," */
- const float *vals, /* pointer to block of values */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor /* corner coordinates */
- )
-{
- long iel;
- char sout[100]; /* temporary string for each encoded output */
-
- for (iel = 0; iel < len-1; iel++) {
- printfval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- Printf(",");
- annotate (vp, fsp, cor, iel);
- } else {
- (void) strcat(sout, ", ");
- lput(sout);
- }
- }
- printfval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- lastdelim (more, lastrow);
- annotate (vp, fsp, cor, iel);
- } else {
- lput(sout);
- lastdelim2 (more, lastrow);
- }
-}
-
-
-/*
- * Print a number of double variable values, where the optional comments
- * for each value identify the variable, and each dimension index.
- */
-static void
-pr_dvals(
- const struct ncvar *vp, /* variable */
- size_t len, /* number of values to print */
- const char *fmt, /* printf format used for each value. If
- * nc_type is NC_CHAR and this is NULL,
- * character arrays will be printed as
- * strings enclosed in quotes. */
- boolean more, /* true if more data for this row will
- * follow, so add trailing comma */
- boolean lastrow, /* true if this is the last row for this
- * variable, so terminate with ";" instead
- * of "," */
- const double *vals, /* pointer to block of values */
- const struct fspec* fsp, /* formatting specs */
- const size_t *cor /* corner coordinates */
- )
-{
- long iel;
- char sout[100]; /* temporary string for each encoded output */
-
- for (iel = 0; iel < len-1; iel++) {
- printdval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- Printf(",");
- annotate (vp, fsp, cor, iel);
- } else {
- (void) strcat(sout, ", ");
- lput(sout);
- }
- }
- printdval(sout, fmt, vp, *vals++);
- if (fsp->full_data_cmnts) {
- Printf(sout);
- lastdelim (more, lastrow);
- annotate (vp, fsp, cor, iel);
- } else {
- lput(sout);
- lastdelim2 (more, lastrow);
- }
-}
-
-
-/*
- * Updates a vector of ints, odometer style. Returns 0 if odometer
- * overflowed, else 1.
- */
-static int
-upcorner(
- const size_t *dims, /* The "odometer" limits for each dimension */
- int ndims, /* Number of dimensions */
- size_t* odom, /* The "odometer" vector to be updated */
- const size_t* add /* A vector to "add" to odom on each update */
- )
-{
- int id;
- int ret = 1;
-
- for (id = ndims-1; id > 0; id--) {
- odom[id] += add[id];
- if(odom[id] >= dims[id]) {
- odom[id-1]++;
- odom[id] -= dims[id];
- }
- }
- odom[0] += add[0];
- if (odom[0] >= dims[0])
- ret = 0;
- return ret;
-}
-
-
-/* Output the data for a single variable, in CDL syntax. */
-int
-vardata(
- const struct ncvar *vp, /* variable */
- size_t vdims[], /* variable dimension sizes */
- int ncid, /* netcdf id */
- int varid, /* variable id */
- const struct fspec* fsp /* formatting specs */
- )
-{
- size_t cor[NC_MAX_DIMS]; /* corner coordinates */
- size_t edg[NC_MAX_DIMS]; /* edges of hypercube */
- size_t add[NC_MAX_DIMS]; /* "odometer" increment to next "row" */
-#define VALBUFSIZ 1000
- double vals[VALBUFSIZ] ; /* aligned buffer */
-
- int gulp = VALBUFSIZ;
-
- int id;
- int ir;
- size_t nels;
- size_t ncols;
- size_t nrows;
- int vrank = vp->ndims;
- static int initeps = 0;
-
- /* printf format used to print each value */
- char *fmt = get_fmt(ncid, varid, vp->type);
-
- if (!initeps) { /* make sure epsilons get initialized */
- init_epsilons();
- initeps = 1;
- }
-
- nels = 1;
- for (id = 0; id < vrank; id++) {
- cor[id] = 0;
- edg[id] = 1;
- nels *= vdims[id]; /* total number of values for variable */
- }
-
- if (vrank <= 1) {
- Printf("\n %s = ", vp->name);
- set_indent ((int)strlen(vp->name) + 4);
- } else {
- Printf("\n %s =\n ", vp->name);
- set_indent (2);
- }
-
- if (vrank < 1) {
- ncols = 1;
- } else {
- ncols = vdims[vrank-1]; /* size of "row" along last dimension */
- edg[vrank-1] = vdims[vrank-1];
- for (id = 0; id < vrank; id++)
- add[id] = 0;
- if (vrank > 1)
- add[vrank-2] = 1;
- }
- nrows = nels/ncols; /* number of "rows" */
-
- for (ir = 0; ir < nrows; ir++) {
- /*
- * rather than just printing a whole row at once (which might exceed
- * the capacity of MSDOS platforms, for example), we break each row
- * into smaller chunks, if necessary.
- */
- size_t corsav;
- int left = (int)ncols;
- boolean lastrow;
-
- if (vrank > 0) {
- corsav = cor[vrank-1];
- if (fsp->brief_data_cmnts != false
- && vrank > 1
- && left > 0) { /* print brief comment with indices range */
- Printf("// %s(",vp->name);
- switch (fsp->data_lang) {
- case LANG_C:
- /* print brief comment with C variable indices */
- for (id = 0; id < vrank-1; id++)
- Printf("%lu,", (unsigned long)cor[id]);
- if (vdims[vrank-1] == 1)
- Printf("0");
- else
- Printf(" 0-%lu", (unsigned long)vdims[vrank-1]-1);
- break;
- case LANG_F:
- /* print brief comment with Fortran variable indices */
- if (vdims[vrank-1] == 1)
- Printf("1");
- else
- Printf("1-%lu ", (unsigned long)vdims[vrank-1]);
- for (id = vrank-2; id >=0 ; id--) {
- Printf(",%lu", (unsigned long)(1 + cor[id]));
- }
- break;
- }
- Printf(")\n ");
- set_indent(4);
- }
- }
- lastrow = (boolean)(ir == nrows-1);
- while (left > 0) {
- size_t toget = left < gulp ? left : gulp;
- if (vrank > 0)
- edg[vrank-1] = toget;
- switch(vp->type) {
- case NC_CHAR:
- NC_CHECK(
- nc_get_vara_text(ncid, varid, cor, edg, (char *)vals) );
- pr_tvals(vp, toget, fmt, left > toget, lastrow,
- (char *) vals, fsp, cor);
- break;
- case NC_BYTE:
- NC_CHECK(
- nc_get_vara_schar(ncid, varid, cor, edg, (signed char *)vals) );
- pr_bvals(vp, toget, fmt, left > toget, lastrow,
- (signed char *) vals, fsp, cor);
- break;
- case NC_SHORT:
- NC_CHECK(
- nc_get_vara_short(ncid, varid, cor, edg, (short *)vals) );
- pr_svals(vp, toget, fmt, left > toget, lastrow,
- (short *) vals, fsp, cor);
- break;
- case NC_INT:
- NC_CHECK(
- nc_get_vara_int(ncid, varid, cor, edg, (int *)vals) );
- pr_ivals(vp, toget, fmt, left > toget, lastrow,
- (int *) vals, fsp, cor);
- break;
- case NC_FLOAT:
- NC_CHECK(
- nc_get_vara_float(ncid, varid, cor, edg, (float *)vals) );
- pr_fvals(vp, toget, fmt, left > toget, lastrow,
- (float *) vals, fsp, cor);
- break;
- case NC_DOUBLE:
- NC_CHECK(
- nc_get_vara_double(ncid, varid, cor, edg, (double *)vals) );
- pr_dvals(vp, toget, fmt, left > toget, lastrow,
- (double *) vals, fsp, cor);
- break;
- default:
- error("vardata: bad type");
- }
- left -= toget;
- if (vrank > 0)
- cor[vrank-1] += toget;
- }
- if (vrank > 0)
- cor[vrank-1] = corsav;
- if (ir < nrows-1)
- if (!upcorner(vdims,vp->ndims,cor,add))
- error("vardata: odometer overflowed!");
- set_indent(2);
- }
-
- return 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.h
deleted file mode 100644
index 11e5c6e..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncdump/vardata.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-extern char *progname; /* for error messages */
-
-/* Display for user-defined fill values and default floating-point fill
- values; should match what ncgen looks for in ../ncgen/ncgen.l */
-#define FILL_STRING "_"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Output the data for a single variable, in CDL syntax. */
-extern int vardata ( const struct ncvar*, /* variable */
- size_t [], /* variable dimension lengths */
- int, /* netcdf id */
- int, /* variable id */
- const struct fspec* /* formatting specs */
- );
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/Makefile
deleted file mode 100644
index 8dc5680..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/Makefile
+++ /dev/null
@@ -1,185 +0,0 @@
-# Makefile for ncgen(1).
-#
-# $Id: Makefile,v 1.2 2005/06/19 05:04:26 svitak Exp $
-
-include ../macros.make
-
-PROGRAM = ncgen
-INCLUDES = -I../libsrc -I.
-MANUAL = ncgen.1
-GARBAGE = $(PROGRAM) \
- y.tab.c y.tab.h \
- netcdf.inc \
- c0.nc c1.cdl c1.nc c2.cdl \
- f0.nc \
- ctest.c ctest ctest0.nc ctest1.cdl \
- ftest.f ftest ftest0.nc ftest1.cdl
-
-lib_netcdf = ../libsrc/libnetcdf.a
-# Don't use "-L../libsrc -lnetcdf" in the following because that doesn't
-# work on a CRAY T90 (sigh).
-ld_netcdf = $(lib_netcdf)
-
-PACKING_LIST = Makefile depend escapes.c generic.h \
- ncgenyy.c ncgentab.c ncgentab.h \
- genlib.c genlib.h getfill.c init.c load.c \
- main.c ncgen.1 ncgen.h ncgen.l ncgen.y c0.cdl
-
-OBJS = main.o load.o ncgentab.o escapes.o \
- getfill.o init.o genlib.o
-
-lex = flex
-yacc = yacc
-
-program_srcs = main.c load.c ncgentab.c escapes.c \
- getfill.c init.c genlib.c
-
-all: $(PROGRAM)
-
-test: $(PROGRAM) b-test c-test f-test FORCE
-
-install: $(BINDIR)/$(PROGRAM) $(MANDIR)/man1/$(MANUAL)
-
-$(PROGRAM): $(OBJS) $(lib_netcdf)
- $(LINK.c) $(OBJS) $(ld_netcdf) $(LIBS)
-
-# "cat >" is used in the following rule to support linktree(1)-style
-# development and testing. "mv" is used to support brain-damaged make(1)
-# utilities that can't handle symbolic links and insist on regenerating
-# the target files (e.g. OSF/1).
-#
-ncgentab.c \
-ncgentab.h: ncgen.y ncgenyy.c ncgen.h
- @case `uname` in \
- OSF1) \
- echo 1>&2 "(expect 1 shift/reduce conflict)"; \
- set -x; \
- $(yacc) -d ncgen.y; \
- cat y.tab.c >ncgentab.c && rm y.tab.c; \
- cat y.tab.h >ncgentab.h && rm y.tab.h; \
- set +x; \
- ;; \
- *) echo 1>&2 "Warning: $@ is out-of-date with respect to $?"; \
- echo 1>&2 "Warning: It should be recreated via $(yacc)" \
- "on an OSF/1 system"; \
- : set -x; \
- : $(yacc) -d ncgen.y; \
- : mv y.tab.c ncgentab.c; \
- : mv y.tab.h ncgentab.h; \
- : set +x; \
- ;; \
- esac
-
-# "cat >" is used in the following rule to support linktree(1)-style
-# development and testing on a Solaris system. "mv" is used to support
-# brain-damaged make(1) utilities that can't handle symbolic links and
-# insist on regenerating the target file (e.g. OSF/1).
-#
-ncgenyy.c: ncgen.l
- @case `uname -sr` in \
- 'SunOS 5'*) \
- $(lex) ncgen.l; \
- cat lex.yy.c >ncgenyy.c && rm lex.yy.c; \
- ;; \
- *) echo 1>&2 "Warning: $@ is out-of-date with respect to $?"; \
- echo 1>&2 "Warning: It should be recreated via $(lex)" \
- "on a SunOS 5 system"; \
- set -x; \
- $(lex) ncgen.l; \
- mv lex.yy.c ncgenyy.c; \
- set +x; \
- ;; \
- esac
-
-vmstab.h \
-vmstab.c: ncgen.y
- @echo 1>&2 "$@ is out-of-date with respect to $?"
- @echo 1>&2 "It must be recreated via POSIX yacc(1) on a VMS system"
- false
-vms_yy.c: ncgenyy.c
- @echo 1>&2 "$@ is out-of-date with respect to $?"
- @echo 1>&2 "It must be recreated via POSIX lex(1) on a VMS system"
- false
-
-#
-# test "-b" option of ncgen
-#
-b-test: $(PROGRAM) c1.cdl
- @./$(PROGRAM) -b c1.cdl && \
- $(NCDUMP) c1.nc > c2.cdl
- @if diff c1.cdl c2.cdl; then \
- echo "*** $(PROGRAM) -b test successful ***"; \
- else \
- echo "*** $(PROGRAM) -b test failed ***"; \
- exit 1; \
- fi
-
-#
-# test "-c" option of ncgen
-#
-c-test: $(PROGRAM) c1.cdl
- ./$(PROGRAM) -c -o ctest0.nc c0.cdl > ctest.c && \
- $(CC) -o ctest $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) ctest.c $(ld_netcdf) $(LIBS) && \
- ./ctest && \
- $(NCDUMP) -n c1 ctest0.nc > ctest1.cdl
- @if diff c1.cdl ctest1.cdl; then \
- echo "*** $(PROGRAM) -c test successful ***"; \
- else \
- echo "*** $(PROGRAM) -c test failed ***"; \
- exit 1; \
- fi
-
-c1.cdl: $(PROGRAM) c0.cdl
- ./$(PROGRAM) -b -o c0.nc c0.cdl
- $(NCDUMP) -n c1 c0.nc > $@
-
-#
-# test "-f" option of ncgen
-#
-f-test: $(PROGRAM) c0.cdl c1.cdl
- @if [ -n "$(FC)" ]; then \
- $(MAKE) $(MFLAGS) ftest1.cdl && \
- if diff c1.cdl ftest1.cdl; then \
- echo "*** $(PROGRAM) -f test successful ***"; \
- else \
- echo "*** $(PROGRAM) -f test failed ***"; \
- exit 1; \
- fi; \
- else \
- echo 1>&2 "\`$@' not made because no FORTRAN compiler"; \
- fi
-
-ftest1.cdl: $(PROGRAM) c0.cdl netcdf.inc
- ./$(PROGRAM) -f -o ftest0.nc c0.cdl > ftest.f
- $(COMPILE.f) ftest.f
- $(FC) $(FFLAGS) $(LDFLAGS) -o ftest ftest.o $(ld_netcdf) $(LIBS)
- ./ftest
- $(NCDUMP) -n c1 ftest0.nc > ftest1.cdl
-
-netcdf.inc:
- @if [ -n "$(FC)" ]; then \
- cp ../fortran/$@ .; \
- else \
- echo 1>&2 "\`$@' not made because no FORTRAN compiler"; \
- fi
-
-$(PROGRAM)_src : $(program_srcs)
- #setopt primary_language C
- #load -C $(CPPFLAGS) $(program_srcs)
- #load -C $(LIBS)
- #load -C /usr/lang/SC2.0.1/libansi.a
- #setopt program_name gribtonc
-
-$(PROGRAM)_obj : $(program_srcs)
- #setopt primary_language C
- #load -C $(CPPFLAGS) $(OBJS)
- #load -C $(LIBS)
- #setopt program_name gribtonc
-
-# Override the default definition for ncdump(1) in the master makefile.
-#
-NCDUMP = ../ncdump/ncdump
-
-include ../rules.make
-
-include depend
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/c0.cdl b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/c0.cdl
deleted file mode 100644
index 28e1693..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/c0.cdl
+++ /dev/null
@@ -1,377 +0,0 @@
-netcdf c0 {
-dimensions:
- Dr = UNLIMITED ; // (2 currently)
- D1 = 1 ;
- D2 = 2 ;
- D3 = 3 ;
- dim-name-dashes = 4 ;
- dim.name.dots = 5 ;
-variables:
- char c ;
- c:att-name-dashes = 4 ;
- c:att.name.dots = 5 ;
- byte b ;
- b:c = "" ;
- short s ;
- s:b = 0b, 127b, -128b, -1b ;
- s:s = -32768s, 0s, 32767s ;
- int 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 ;
- float f ;
- f:c = "x" ;
- double d ;
- d:c = "abcd\tZ$&" ;
- char cr(Dr) ;
- byte br(Dr) ;
- short sr(Dr) ;
- int ir(Dr) ;
- float fr(Dr) ;
- double dr(Dr) ;
- char c1(D1) ;
- byte b1(D1) ;
- short s1(D1) ;
- int i1(D1) ;
- float f1(D1) ;
- double d1(D1) ;
- char c2(D2) ;
- byte b2(D2) ;
- short s2(D2) ;
- int i2(D2) ;
- float f2(D2) ;
- double d2(D2) ;
- char c3(D3) ;
- byte b3(D3) ;
- short s3(D3) ;
- int i3(D3) ;
- float f3(D3) ;
- double d3(D3) ;
- char cr1(Dr, D1) ;
- byte br2(Dr, D2) ;
- short sr3(Dr, D3) ;
- float f11(D1, D1) ;
- double d12(D1, D2) ;
- char c13(D1, D3) ;
- short s21(D2, D1) ;
- int 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) ;
- float fr13(Dr, D1, D3) ;
- char cr21(Dr, D2, D1) ;
- byte br22(Dr, D2, D2) ;
- short 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) ;
- 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) ;
- 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) ;
- 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) ;
- float f313(D3, D1, D3) ;
- double var-name-dashes ;
- double var.name.dots ;
-
-// global attributes:
- :Gc = "" ;
- :Gb = -128b, 127b ;
- :Gs = -32768s, 0s, 32767s ;
- :Gi = -2147483647, 0, 2147483647 ;
- :Gf = -1.e+36f, 0.f, 1.e+36f ;
- :Gd = -1.e+308, 0., 1.e+308 ;
- :Gatt-name-dashes = -1 ;
- :Gatt.name.dots = -2 ;
-data:
-
- c = "2" ;
-
- b = -2 ;
-
- s = -5 ;
-
- i = -20 ;
-
- f = -9 ;
-
- d = -10 ;
-
- cr = "ab" ;
-
- br = -128, 127 ;
-
- sr = -32768, 32767 ;
-
- ir = -2147483646, 2147483647 ;
-
- fr = -1e+36, 1e+36 ;
-
- dr = -1e+308, 1e+308 ;
-
- c1 = "" ;
-
- b1 = -128 ;
-
- s1 = -32768 ;
-
- i1 = -2147483646 ;
-
- f1 = -1e+36 ;
-
- d1 = -1e+308 ;
-
- c2 = "ab" ;
-
- b2 = -128, 127 ;
-
- s2 = -32768, 32767 ;
-
- i2 = -2147483646, 2147483647 ;
-
- f2 = -1e+36, 1e+36 ;
-
- d2 = -1e+308, 1e+308 ;
-
- c3 = "\001\300." ;
-
- b3 = -128, 127, -1 ;
-
- s3 = -32768, 0, 32767 ;
-
- i3 = -2147483646, 0, 2147483647 ;
-
- f3 = -1e+36, 0, 1e+36 ;
-
- d3 = -1e+308, 0, 1e+308 ;
-
- cr1 =
- "x",
- "y" ;
-
- br2 =
- -24, -26,
- -20, -22 ;
-
- sr3 =
- -375, -380, -385,
- -350, -355, -360 ;
-
- f11 =
- -2187 ;
-
- d12 =
- -3000, -3010 ;
-
- c13 =
- "\tb\177" ;
-
- s21 =
- -375,
- -350 ;
-
- i22 =
- -24000, -24020,
- -23600, -23620 ;
-
- f23 =
- -2187, -2196, -2205,
- -2106, -2115, -2124 ;
-
- c31 =
- "+",
- "-",
- " " ;
-
- b32 =
- -24, -26,
- -20, -22,
- -16, -18 ;
-
- s33 =
- -375, -380, -385,
- -350, -355, -360,
- -325, -330, -335 ;
-
- sr11 =
- 2500,
- 2375 ;
-
- ir12 =
- 640000, 639980,
- 632000, 631980 ;
-
- fr13 =
- 26244, 26235, 26226,
- 25515, 25506, 25497 ;
-
- cr21 =
- "@",
- "D",
- "H",
- "L" ;
-
- br22 =
- 64, 62,
- 68, 66,
- 56, 54,
- 60, 58 ;
-
- sr23 =
- 2500, 2495, 2490,
- 2525, 2520, 2515,
- 2375, 2370, 2365,
- 2400, 2395, 2390 ;
-
- fr31 =
- 26244,
- 26325,
- 26406,
- 25515,
- 25596,
- 25677 ;
-
- dr32 =
- 40000, 39990,
- 40100, 40090,
- 40200, 40190,
- 39000, 38990,
- 39100, 39090,
- 39200, 39190 ;
-
- cr33 =
- "1",
- "two",
- "3",
- "4",
- "5",
- "six" ;
-
- c111 =
- "@" ;
-
- b112 =
- 64, 62 ;
-
- s113 =
- 2500, 2495, 2490 ;
-
- f121 =
- 26244,
- 26325 ;
-
- d122 =
- 40000, 39990,
- 40100, 40090 ;
-
- c123 =
- "one",
- "2" ;
-
- s131 =
- 2500,
- 2525,
- 2550 ;
-
- i132 =
- 640000, 639980,
- 640400, 640380,
- 640800, 640780 ;
-
- f133 =
- 26244, 26235, 26226,
- 26325, 26316, 26307,
- 26406, 26397, 26388 ;
-
- f211 =
- 26244,
- 25515 ;
-
- d212 =
- 40000, 39990,
- 39000, 38990 ;
-
-// The following trips a bug on Cray T3E, but should work on other platforms
-// c213 =
-// "1",
-// "two" ;
-
- s221 =
- 2500,
- 2525,
- 2375,
- 2400 ;
-
- i222 =
- 640000, 639980,
- 640400, 640380,
- 632000, 631980,
- 632400, 632380 ;
-
- f223 =
- 26244, 26235, 26226,
- 26325, 26316, 26307,
- 25515, 25506, 25497,
- 25596, 25587, 25578 ;
-
- c231 =
- "@",
- "D",
- "H",
- "H",
- "L",
- "P" ;
-
- b232 =
- 64, 62,
- 68, 66,
- 72, 70,
- 56, 54,
- 60, 58,
- 64, 62 ;
-
- s233 =
- 2500, 2495, 2490,
- 2525, 2520, 2515,
- 2550, 2545, 2540,
- 2375, 2370, 2365,
- 2400, 2395, 2390,
- 2425, 2420, 2415 ;
-
- s311 =
- 2500,
- 2375,
- 2250 ;
-
- i312 =
- 640000, 639980,
- 632000, 631980,
- 624000, 623980 ;
-
- f313 =
- 26244, 26235, 26226,
- 25515, 25506, 25497,
- 24786, 24777, 24768 ;
-
- var-name-dashes = -1 ;
-
- var.name.dots = -2 ;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/depend b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/depend
deleted file mode 100644
index 2c2dc9f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/depend
+++ /dev/null
@@ -1,48 +0,0 @@
-close.o: ../libsrc/netcdf.h
-close.o: close.c
-close.o: generic.h
-close.o: genlib.h
-close.o: ncgen.h
-escapes.o: ../libsrc/netcdf.h
-escapes.o: escapes.c
-escapes.o: generic.h
-escapes.o: genlib.h
-escapes.o: ncgen.h
-genlib.o: ../libsrc/netcdf.h
-genlib.o: generic.h
-genlib.o: genlib.c
-genlib.o: genlib.h
-genlib.o: ncgen.h
-getfill.o: ../libsrc/netcdf.h
-getfill.o: generic.h
-getfill.o: genlib.h
-getfill.o: getfill.c
-getfill.o: ncgen.h
-init.o: ../libsrc/netcdf.h
-init.o: generic.h
-init.o: init.c
-init.o: ncgen.h
-load.o: ../libsrc/netcdf.h
-load.o: generic.h
-load.o: genlib.h
-load.o: load.c
-load.o: ncgen.h
-main.o: ../libsrc/netcdf.h
-main.o: generic.h
-main.o: genlib.h
-main.o: main.c
-main.o: ncgen.h
-msofttab.o: ../libsrc/netcdf.h
-msofttab.o: generic.h
-msofttab.o: msofttab.c
-msofttab.o: ncgen.h
-msofttab.o: ncgenyy.c
-msoftyy.o: msoftyy.c
-ncgenyy.o: ncgenyy.c
-vms_yy.o: vms_yy.c
-vmstab.o: ../libsrc/netcdf.h
-vmstab.o: generic.h
-vmstab.o: genlib.h
-vmstab.o: ncgen.h
-vmstab.o: ncgenyy.c
-vmstab.o: vmstab.c
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/escapes.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/escapes.c
deleted file mode 100644
index dfbc14c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/escapes.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/escapes.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdlib.h>
-#include <netcdf.h>
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h"
-
-/*
- * "Expands" valid escape sequences in yystring (read by lex) into the
- * apropriate 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.
- */
-
-void
-expand_escapes(
- char *termstring, /* returned, with escapes expanded */
- char *yytext,
- int yyleng)
-{
- char *s, *t, *endp;
-
- yytext[yyleng-1]='\0'; /* don't copy quotes */
- /* expand "\" escapes, e.g. "\t" to tab character */
- s = termstring;
- t = yytext+1;
- while(*t) {
- if (*t == '\\') {
- t++;
- switch (*t) {
- case 'a':
- *s++ = '\007'; t++; /* will use '\a' when STDC */
- break;
- case 'b':
- *s++ = '\b'; t++;
- break;
- case 'f':
- *s++ = '\f'; t++;
- break;
- case 'n':
- *s++ = '\n'; t++;
- break;
- case 'r':
- *s++ = '\r'; t++;
- break;
- case 't':
- *s++ = '\t'; t++;
- break;
- case 'v':
- *s++ = '\v'; t++;
- break;
- case '\\':
- *s++ = '\\'; t++;
- break;
- case '?':
- *s++ = '\177'; t++;
- break;
- case '\'':
- *s++ = '\''; t++;
- break;
- case '\"':
- *s++ = '\"'; t++;
- break;
- case 'x':
- t++; /* now t points to one or more hex digits */
- *s++ = (char) strtol(t, &endp, 16);
- t = endp;
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- /* t now points to octal digits */
- *s++ = (char) strtol(t, &endp, 8);
- t = endp;
- break;
- default:
- *s++ = *t++;
- break;
- }
- } else {
- *s++ = *t++;
- }
- }
- *s = '\0';
- return;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/generic.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/generic.h
deleted file mode 100644
index 11aa3c4..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/generic.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/generic.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#ifndef UD_GENERIC_H
-#define UD_GENERIC_H
-
-union generic { /* used to hold any kind of fill_value */
- float floatv;
- double doublev;
- int intv;
- short shortv;
- char charv;
-};
-
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.c
deleted file mode 100644
index 577e0c6..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.c
+++ /dev/null
@@ -1,1812 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h> /* for isprint() */
-#ifndef NO_STDARG
-#include <stdarg.h>
-#else
-/* try varargs instead */
-#include <varargs.h>
-#endif /* !NO_STDARG */
-#include <netcdf.h>
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h"
-
-extern char *netcdf_name; /* output netCDF filename, if on command line. */
-extern int netcdf_flag;
-extern int c_flag;
-extern int fortran_flag;
-
-int lineno = 1;
-int derror_count = 0;
-
-
-/* create netCDF from in-memory structure */
-static void
-gen_netcdf(
- char *filename) /* name for output netcdf file */
-{
- int idim, ivar, iatt;
- int dimid;
- int varid;
-
- int stat = nc_create(filename, NC_CLOBBER, &ncid);
- check_err(stat);
-
- /* define dimensions from info in dims array */
- for (idim = 0; idim < ndims; idim++) {
- stat = nc_def_dim(ncid, dims[idim].name, dims[idim].size, &dimid);
- check_err(stat);
- }
-
- /* define variables from info in vars array */
- for (ivar = 0; ivar < nvars; ivar++) {
- stat = nc_def_var(ncid,
- vars[ivar].name,
- vars[ivar].type,
- vars[ivar].ndims,
- vars[ivar].dims,
- &varid);
- check_err(stat);
- }
-
- /* define attributes from info in atts array */
- for (iatt = 0; iatt < natts; iatt++) {
- varid = (atts[iatt].var == -1) ? NC_GLOBAL : atts[iatt].var;
- switch(atts[iatt].type) {
- case NC_BYTE:
- stat = nc_put_att_schar(ncid, varid, atts[iatt].name,
- atts[iatt].type, atts[iatt].len,
- (signed char *) atts[iatt].val);
- break;
- case NC_CHAR:
- stat = nc_put_att_text(ncid, varid, atts[iatt].name,
- atts[iatt].len,
- (char *) atts[iatt].val);
- break;
- case NC_SHORT:
- stat = nc_put_att_short(ncid, varid, atts[iatt].name,
- atts[iatt].type, atts[iatt].len,
- (short *) atts[iatt].val);
- break;
- case NC_INT:
- stat = nc_put_att_int(ncid, varid, atts[iatt].name,
- atts[iatt].type, atts[iatt].len,
- (int *) atts[iatt].val);
- break;
- case NC_FLOAT:
- stat = nc_put_att_float(ncid, varid, atts[iatt].name,
- atts[iatt].type, atts[iatt].len,
- (float *) atts[iatt].val);
- break;
- case NC_DOUBLE:
- stat = nc_put_att_double(ncid, varid, atts[iatt].name,
- atts[iatt].type, atts[iatt].len,
- (double *) atts[iatt].val);
- break;
- default:
- stat = NC_EBADTYPE;
- }
- check_err(stat);
- }
-
- stat = nc_enddef(ncid);
- check_err(stat);
-}
-
-
-/*
- * Given a netcdf type, a pointer to a vector of values of that type,
- * and the index of the vector element desired, returns a pointer to a
- * malloced string representing the value in C.
- */
-static char *
-cstring(
- nc_type type, /* netCDF type code */
- void *valp, /* pointer to vector of values */
- int num) /* element of vector desired */
-{
- static char *cp, *sp, ch;
- signed char *bytep;
- short *shortp;
- int *intp;
- float *floatp;
- double *doublep;
-
- switch (type) {
- case NC_CHAR:
- sp = cp = (char *) emalloc (7);
- *cp++ = '\'';
- ch = *((char *)valp + num);
- switch (ch) {
- case '\b': *cp++ = '\\'; *cp++ = 'b'; break;
- case '\f': *cp++ = '\\'; *cp++ = 'f'; break;
- case '\n': *cp++ = '\\'; *cp++ = 'n'; break;
- case '\r': *cp++ = '\\'; *cp++ = 'r'; break;
- case '\t': *cp++ = '\\'; *cp++ = 't'; break;
- case '\v': *cp++ = '\\'; *cp++ = 'v'; break;
- case '\\': *cp++ = '\\'; *cp++ = '\\'; break;
- case '\'': *cp++ = '\\'; *cp++ = '\''; break;
- default:
- if (!isprint(ch)) {
- static char octs[] = "01234567";
- int rem = ((unsigned char)ch)%64;
- *cp++ = '\\';
- *cp++ = octs[((unsigned char)ch)/64]; /* to get, e.g. '\177' */
- *cp++ = octs[rem/8];
- *cp++ = octs[rem%8];
- } else {
- *cp++ = ch;
- }
- break;
- }
- *cp++ = '\'';
- *cp = '\0';
- return sp;
-
- case NC_BYTE:
- cp = (char *) emalloc (7);
- bytep = (signed char *)valp;
- /* Need to convert '\377' to -1, for example, on all platforms */
- (void) sprintf(cp,"%d", (signed char) *(bytep+num));
- return cp;
-
- case NC_SHORT:
- cp = (char *) emalloc (10);
- shortp = (short *)valp;
- (void) sprintf(cp,"%d",* (shortp + num));
- return cp;
-
- case NC_INT:
- cp = (char *) emalloc (20);
- intp = (int *)valp;
- (void) sprintf(cp,"%d",* (intp + num));
- return cp;
-
- case NC_FLOAT:
- cp = (char *) emalloc (20);
- floatp = (float *)valp;
- (void) sprintf(cp,"%.8g",* (floatp + num));
- return cp;
-
- case NC_DOUBLE:
- cp = (char *) emalloc (20);
- doublep = (double *)valp;
- (void) sprintf(cp,"%.16g",* (doublep + num));
- return cp;
-
- default:
- derror("cstring: bad type code");
- return 0;
- }
-}
-
-
-/*
- * Generate C code for creating netCDF from in-memory structure.
- */
-static void
-gen_c(
- char *filename)
-{
- int idim, ivar, iatt, jatt, maxdims;
- int vector_atts;
- char *val_string;
- char stmnt[C_MAX_STMNT];
-
- /* wrap in main program */
- cline("#include <stdio.h>");
- cline("#include <stdlib.h>");
- cline("#include <netcdf.h>");
- cline("");
- cline("void");
- cline("check_err(const int stat, const int line, const char *file) {");
- cline(" if (stat != NC_NOERR) {");
- cline(" (void) fprintf(stderr, \"line %d of %s: %s\\n\", line, file, nc_strerror(stat));");
- cline(" exit(1);");
- cline(" }");
- cline("}");
- cline("");
- cline("int");
- sprintf(stmnt, "main() {\t\t\t/* create %s */", filename);
- cline(stmnt);
-
- /* create necessary declarations */
- cline("");
- cline(" int ncid;\t\t\t/* netCDF id */");
-
- if (ndims > 0) {
- cline("");
- cline(" /* dimension ids */");
- for (idim = 0; idim < ndims; idim++) {
- sprintf(stmnt, " int %s_dim;", dims[idim].lname);
- cline(stmnt);
- }
-
- cline("");
- cline(" /* dimension lengths */");
- for (idim = 0; idim < ndims; idim++) {
- if (dims[idim].size == NC_UNLIMITED) {
- sprintf(stmnt, " size_t %s_len = NC_UNLIMITED;",
- dims[idim].lname);
- } else {
- sprintf(stmnt, " size_t %s_len = %lu;",
- dims[idim].lname,
- (unsigned long) dims[idim].size);
- }
- cline(stmnt);
- }
- }
-
- maxdims = 0; /* most dimensions of any variable */
- for (ivar = 0; ivar < nvars; ivar++)
- if (vars[ivar].ndims > maxdims)
- maxdims = vars[ivar].ndims;
-
- if (nvars > 0) {
- cline("");
- cline(" /* variable ids */");
- for (ivar = 0; ivar < nvars; ivar++) {
- sprintf(stmnt, " int %s_id;", vars[ivar].lname);
- cline(stmnt);
- }
-
- cline("");
- cline(" /* rank (number of dimensions) for each variable */");
- for (ivar = 0; ivar < nvars; ivar++) {
- sprintf(stmnt, "# define RANK_%s %d", vars[ivar].lname,
- vars[ivar].ndims);
- cline(stmnt);
- }
- if (maxdims > 0) { /* we have dimensioned variables */
- cline("");
- cline(" /* variable shapes */");
- for (ivar = 0; ivar < nvars; ivar++) {
- if (vars[ivar].ndims > 0) {
- sprintf(stmnt, " int %s_dims[RANK_%s];",
- vars[ivar].lname, vars[ivar].lname);
- cline(stmnt);
- }
- }
- }
- }
-
- /* determine if we need any attribute vectors */
- vector_atts = 0;
- for (iatt = 0; iatt < natts; iatt++) {
- if (atts[iatt].type != NC_CHAR) {
- vector_atts = 1;
- break;
- }
- }
- if (vector_atts) {
- cline("");
- cline(" /* attribute vectors */");
- for (iatt = 0; iatt < natts; iatt++) {
- if (atts[iatt].type != NC_CHAR) {
- sprintf(stmnt,
- " %s %s_%s[%lu];",
- ncatype(atts[iatt].type),
- atts[iatt].var == -1 ? "cdf" : vars[atts[iatt].var].lname,
- atts[iatt].lname,
- (unsigned long) atts[iatt].len);
- cline(stmnt);
- }
- }
- }
-
- /* create netCDF file, uses NC_CLOBBER mode */
- cline("");
- cline(" /* enter define mode */");
- sprintf(stmnt,
- " int stat = nc_create(\"%s\", NC_CLOBBER, &ncid);",
- filename);
- cline(stmnt);
- cline(" check_err(stat,__LINE__,__FILE__);");
-
- /* define dimensions from info in dims array */
- if (ndims > 0) {
- cline("");
- cline(" /* define dimensions */");
- }
- for (idim = 0; idim < ndims; idim++) {
- sprintf(stmnt,
- " stat = nc_def_dim(ncid, \"%s\", %s_len, &%s_dim);",
- dims[idim].name, dims[idim].lname, dims[idim].lname);
- cline(stmnt);
- cline(" check_err(stat,__LINE__,__FILE__);");
- }
-
- /* define variables from info in vars array */
- if (nvars > 0) {
- cline("");
- cline(" /* define variables */");
- for (ivar = 0; ivar < nvars; ivar++) {
- cline("");
- for (idim = 0; idim < vars[ivar].ndims; idim++) {
- sprintf(stmnt,
- " %s_dims[%d] = %s_dim;",
- vars[ivar].lname,
- idim,
- dims[vars[ivar].dims[idim]].lname);
- cline(stmnt);
- }
- if (vars[ivar].ndims > 0) { /* a dimensioned variable */
- sprintf(stmnt,
- " stat = nc_def_var(ncid, \"%s\", %s, RANK_%s, %s_dims, &%s_id);",
- vars[ivar].name,
- nctype(vars[ivar].type),
- vars[ivar].lname,
- vars[ivar].lname,
- vars[ivar].lname);
- } else { /* a scalar */
- sprintf(stmnt,
- " stat = nc_def_var(ncid, \"%s\", %s, RANK_%s, 0, &%s_id);",
- vars[ivar].name,
- nctype(vars[ivar].type),
- vars[ivar].lname,
- vars[ivar].lname);
- }
- cline(stmnt);
- cline(" check_err(stat,__LINE__,__FILE__);");
- }
- }
-
- /* define attributes from info in atts array */
- if (natts > 0) {
- cline("");
- cline(" /* assign attributes */");
- for (iatt = 0; iatt < natts; iatt++) {
- if (atts[iatt].type == NC_CHAR) { /* string */
- val_string = cstrstr((char *) atts[iatt].val, atts[iatt].len);
- sprintf(stmnt,
- " stat = nc_put_att_text(ncid, %s%s, \"%s\", %lu, %s);",
- atts[iatt].var == -1 ? "NC_GLOBAL" : vars[atts[iatt].var].lname,
- atts[iatt].var == -1 ? "" : "_id",
- atts[iatt].name,
- (unsigned long) atts[iatt].len,
- val_string);
- cline(stmnt);
- free (val_string);
- }
- else { /* vector attribute */
- for (jatt = 0; jatt < atts[iatt].len ; jatt++) {
- val_string = cstring(atts[iatt].type,atts[iatt].val,jatt);
- sprintf(stmnt, " %s_%s[%d] = %s;",
- atts[iatt].var == -1 ? "cdf" : vars[atts[iatt].var].lname,
- atts[iatt].lname,
- jatt,
- val_string);
- cline(stmnt);
- free (val_string);
- }
-
- sprintf(stmnt,
- " stat = nc_put_att_%s(ncid, %s%s, \"%s\", %s, %lu, %s_%s);",
- ncatype(atts[iatt].type),
- atts[iatt].var == -1 ? "NC_GLOBAL" : vars[atts[iatt].var].lname,
- atts[iatt].var == -1 ? "" : "_id",
- atts[iatt].name,
- nctype(atts[iatt].type),
- (unsigned long) atts[iatt].len,
- atts[iatt].var == -1 ? "cdf" : vars[atts[iatt].var].lname,
- atts[iatt].lname);
- cline(stmnt);
- }
- cline(" check_err(stat,__LINE__,__FILE__);");
- }
- }
- cline("");
- cline(" /* leave define mode */");
- cline(" stat = nc_enddef (ncid);");
- cline(" check_err(stat,__LINE__,__FILE__);");
-}
-
-
-/* return Fortran type name for netCDF type, given type code */
-static char *
-ncftype(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
-
- case NC_BYTE:
- return "integer";
- case NC_CHAR:
- return "character";
- case NC_SHORT:
- return "integer";
- case NC_INT:
-#ifdef MSDOS
- return "integer*4";
-#else
- return "integer";
-#endif
- case NC_FLOAT:
- return "real";
-#ifdef _CRAY
- case NC_DOUBLE:
- return "real"; /* we don't support CRAY 128-bit doubles */
-#else
- case NC_DOUBLE:
- return "double precision";
-#endif
- default:
- derror("ncftype: bad type code");
- return 0;
-
- }
-}
-
-
-/* return Fortran type suffix for netCDF type, given type code */
-char *
-nfstype(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return "int1";
- case NC_CHAR:
- return "text";
- case NC_SHORT:
- return "int2";
- case NC_INT:
- return "int";
- case NC_FLOAT:
- return "real";
- case NC_DOUBLE:
- return "double";
- default:
- derror("nfstype: bad type code");
- return 0;
-
- }
-}
-
-
-/* Return Fortran function suffix for netCDF type, given type code.
- * This should correspond to the Fortran type name in ncftype().
- */
-char *
-nfftype(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return "int";
- case NC_CHAR:
- return "text";
- case NC_SHORT:
- return "int";
- case NC_INT:
- return "int";
- case NC_FLOAT:
- return "real";
-#ifdef _CRAY
- case NC_DOUBLE:
- return "real"; /* we don't support CRAY 128-bit doubles */
-#else
- case NC_DOUBLE:
- return "double";
-#endif
- default:
- derror("nfstype: bad type code");
- return 0;
-
- }
-}
-
-
-/* return FORTRAN name for netCDF type, given type code */
-static char *
-ftypename(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return "NF_INT1";
- case NC_CHAR:
- return "NF_CHAR";
- case NC_SHORT:
- return "NF_INT2";
- case NC_INT:
- return "NF_INT";
- case NC_FLOAT:
- return "NF_REAL";
- case NC_DOUBLE:
- return "NF_DOUBLE";
- default:
- derror("ftypename: bad type code");
- return 0;
- }
-}
-
-
-/*
- * Generate FORTRAN code for creating netCDF from in-memory structure.
- */
-static void
-gen_fortran(
- char *filename)
-{
- int idim, ivar, iatt, jatt, itype, maxdims;
- int vector_atts;
- char *val_string;
- char stmnt[FORT_MAX_STMNT];
- char s2[NC_MAX_NAME + 10];
- char *sp;
- /* Need how many netCDF types there are, because we create an array
- * for each type of attribute. */
- int ntypes = 6; /* number of netCDF types, NC_BYTE, ... */
- nc_type types[6]; /* at least ntypes */
- size_t max_atts[NC_DOUBLE + 1];
-
- types[0] = NC_BYTE;
- types[1] = NC_CHAR;
- types[2] = NC_SHORT;
- types[3] = NC_INT;
- types[4] = NC_FLOAT;
- types[5] = NC_DOUBLE;
-
- fline("program fgennc");
-
- fline("include 'netcdf.inc'");
-
- /* create necessary declarations */
- fline("* error status return");
- fline("integer iret");
- fline("* netCDF id");
- fline("integer ncid");
-
- if (ndims > 0) {
- fline("* dimension ids");
- for (idim = 0; idim < ndims; idim++) {
- sprintf(stmnt, "integer %s_dim", dims[idim].lname);
- fline(stmnt);
- }
-
- fline("* dimension lengths");
- for (idim = 0; idim < ndims; idim++) {
- sprintf(stmnt, "integer %s_len", dims[idim].lname);
- fline(stmnt);
- }
- for (idim = 0; idim < ndims; idim++) {
- if (dims[idim].size == NC_UNLIMITED) {
- sprintf(stmnt, "parameter (%s_len = NF_UNLIMITED)",
- dims[idim].lname);
- } else {
- sprintf(stmnt, "parameter (%s_len = %lu)",
- dims[idim].lname,
- (unsigned long) dims[idim].size);
- }
- fline(stmnt);
- }
-
- }
-
- maxdims = 0; /* most dimensions of any variable */
- for (ivar = 0; ivar < nvars; ivar++)
- if (vars[ivar].ndims > maxdims)
- maxdims = vars[ivar].ndims;
-
- if (nvars > 0) {
- fline("* variable ids");
- for (ivar = 0; ivar < nvars; ivar++) {
- sprintf(stmnt, "integer %s_id", vars[ivar].lname);
- fline(stmnt);
- }
-
- fline("* rank (number of dimensions) for each variable");
- for (ivar = 0; ivar < nvars; ivar++) {
- sprintf(stmnt, "integer %s_rank", vars[ivar].lname);
- fline(stmnt);
- }
- for (ivar = 0; ivar < nvars; ivar++) {
- sprintf(stmnt, "parameter (%s_rank = %d)", vars[ivar].lname,
- vars[ivar].ndims);
- fline(stmnt);
- }
-
- fline("* variable shapes");
- for (ivar = 0; ivar < nvars; ivar++) {
- if (vars[ivar].ndims > 0) {
- sprintf(stmnt, "integer %s_dims(%s_rank)",
- vars[ivar].lname, vars[ivar].lname);
- fline(stmnt);
- }
- }
- }
-
- /* declarations for variables to be initialized */
- if (nvars > 0) { /* we have variables */
- fline("* data variables");
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- /* Generate declarations here for non-record data variables only.
- Record variables are declared in separate subroutine later,
- when we know how big they are. */
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- continue;
- }
- /* Make declarations for non-text variables only;
- for text variables, just include string in nf_put_var call */
- if (v->type == NC_CHAR) {
- continue;
- }
- if (v->ndims == 0) { /* scalar */
- sprintf(stmnt, "%s %s", ncftype(v->type),
- v->lname);
- } else {
- sprintf(stmnt, "%s %s(", ncftype(v->type),
- v->lname);
- /* reverse dimensions for FORTRAN */
- for (idim = v->ndims-1; idim >= 0; idim--) {
- sprintf(s2, "%s_len, ",
- dims[v->dims[idim]].lname);
- strcat(stmnt, s2);
- }
- sp = strrchr(stmnt, ',');
- if(sp != NULL) {
- *sp = '\0';
- }
- strcat(stmnt, ")");
- }
- fline(stmnt);
- }
- }
-
- /* determine what attribute vectors needed */
- for (itype = 0; itype < ntypes; itype++)
- max_atts[(int)types[itype]] = 0;
-
- vector_atts = 0;
- for (iatt = 0; iatt < natts; iatt++) {
- if (atts[iatt].len > max_atts[(int) atts[iatt].type]) {
- max_atts[(int)atts[iatt].type] = atts[iatt].len;
- vector_atts = 1;
- }
- }
- if (vector_atts) {
- fline("* attribute vectors");
- for (itype = 0; itype < ntypes; itype++) {
- if (types[itype] != NC_CHAR && max_atts[(int)types[itype]] > 0) {
- sprintf(stmnt, "%s %sval(%lu)", ncftype(types[itype]),
- nfstype(types[itype]),
- (unsigned long) max_atts[(int)types[itype]]);
- fline(stmnt);
- }
- }
- }
-
- /* create netCDF file, uses NC_CLOBBER mode */
- fline("* enter define mode");
- sprintf(stmnt, "iret = nf_create(\'%s\', NF_CLOBBER, ncid)", filename);
- fline(stmnt);
- fline("call check_err(iret)");
-
- /* define dimensions from info in dims array */
- if (ndims > 0)
- fline("* define dimensions");
- for (idim = 0; idim < ndims; idim++) {
- if (dims[idim].size == NC_UNLIMITED)
- sprintf(stmnt, "iret = nf_def_dim(ncid, \'%s\', NF_UNLIMITED, %s_dim)",
- dims[idim].name, dims[idim].lname);
- else
- sprintf(stmnt, "iret = nf_def_dim(ncid, \'%s\', %lu, %s_dim)",
- dims[idim].name, (unsigned long) dims[idim].size,
- dims[idim].lname);
- fline(stmnt);
- fline("call check_err(iret)");
- }
-
- /* define variables from info in vars array */
- if (nvars > 0) {
- fline("* define variables");
- for (ivar = 0; ivar < nvars; ivar++) {
- for (idim = 0; idim < vars[ivar].ndims; idim++) {
- sprintf(stmnt, "%s_dims(%d) = %s_dim",
- vars[ivar].lname,
- vars[ivar].ndims - idim, /* reverse dimensions */
- dims[vars[ivar].dims[idim]].lname);
- fline(stmnt);
- }
- if (vars[ivar].ndims > 0) { /* a dimensioned variable */
- sprintf(stmnt,
- "iret = nf_def_var(ncid, \'%s\', %s, %s_rank, %s_dims, %s_id)",
- vars[ivar].name,
- ftypename(vars[ivar].type),
- vars[ivar].lname,
- vars[ivar].lname,
- vars[ivar].lname);
- } else { /* a scalar */
- sprintf(stmnt,
- "iret = nf_def_var(ncid, \'%s\', %s, %s_rank, 0, %s_id)",
- vars[ivar].name,
- ftypename(vars[ivar].type),
- vars[ivar].lname,
- vars[ivar].lname);
- }
- fline(stmnt);
- fline("call check_err(iret)");
- }
- }
-
- /* define attributes from info in atts array */
- if (natts > 0) {
- fline("* assign attributes");
- for (iatt = 0; iatt < natts; iatt++) {
- if (atts[iatt].type == NC_CHAR) { /* string */
- val_string = fstrstr((char *) atts[iatt].val, atts[iatt].len);
- sprintf(stmnt,
- "iret = nf_put_att_text(ncid, %s%s, \'%s\', %lu, %s)",
- atts[iatt].var == -1 ? "NF_GLOBAL" : vars[atts[iatt].var].lname,
- atts[iatt].var == -1 ? "" : "_id",
- atts[iatt].name,
- (unsigned long) atts[iatt].len,
- val_string);
- fline(stmnt);
- fline("call check_err(iret)");
- free(val_string);
- } else {
- for (jatt = 0; jatt < atts[iatt].len ; jatt++) {
- val_string = fstring(atts[iatt].type,atts[iatt].val,jatt);
- sprintf(stmnt, "%sval(%d) = %s",
- nfstype(atts[iatt].type),
- jatt+1,
- val_string);
- fline(stmnt);
- free (val_string);
- }
-
- sprintf(stmnt,
- "iret = nf_put_att_%s(ncid, %s%s, \'%s\', %s, %lu, %sval)",
- nfftype(atts[iatt].type),
- atts[iatt].var == -1 ? "NCGLOBAL" : vars[atts[iatt].var].lname,
- atts[iatt].var == -1 ? "" : "_id",
- atts[iatt].name,
- ftypename(atts[iatt].type),
- (unsigned long) atts[iatt].len,
- nfstype(atts[iatt].type));
- fline(stmnt);
- fline("call check_err(iret)");
- }
- }
- }
- fline("* leave define mode");
- fline("iret = nf_enddef(ncid)");
- fline("call check_err(iret)");
-}
-
-
-/*
- * Output a C statement.
- */
-void
-cline(
- const char *stmnt)
-{
- FILE *cout = stdout;
-
- fputs(stmnt, cout);
- fputs("\n", cout);
-}
-
-/*
- * From a long line FORTRAN statment, 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.
- */
-void
-fline(
- const char *stmnt)
-{
- FILE *fout = stdout;
- int len = (int) strlen(stmnt);
- int line = 0;
- static char cont[] = { /* continuation characters */
- ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- '+', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- '+', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
-
- if(stmnt[0] == '*') {
- fputs(stmnt, fout);
- fputs("\n", fout);
- return;
- }
-
- while (len > 0) {
- if (line >= FORT_MAX_LINES)
- derror("FORTRAN statement too long: %s",stmnt);
- (void) fprintf(fout, " %c", cont[line++]);
- (void) fprintf(fout, "%.66s\n", stmnt);
- len -= 66;
- if (len > 0)
- stmnt += 66;
- }
-}
-
-
-/* return C name for netCDF type, given type code */
-char *
-nctype(
- nc_type type) /* netCDF type code */
-{
- switch (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";
- default:
- derror("nctype: bad type code");
- return 0;
- }
-}
-
-
-/*
- * Return C type name for netCDF type, given type code.
- */
-char *
-ncctype(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return "signed char";
- case NC_CHAR:
- return "char";
- case NC_SHORT:
- return "short";
- case NC_INT:
- return "int";
- case NC_FLOAT:
- return "float";
- case NC_DOUBLE:
- return "double";
- default:
- derror("ncctype: bad type code");
- return 0;
- }
-}
-
-
-
-/*
- * Return C type name for netCDF type suffix, given type code.
- */
-char *
-ncstype(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return "schar";
- case NC_CHAR:
- return "text";
- case NC_SHORT:
- return "short";
- case NC_INT:
- return "int";
- case NC_FLOAT:
- return "float";
- case NC_DOUBLE:
- return "double";
- default:
- derror("ncstype: bad type code");
- return 0;
- }
-}
-
-
-/*
- * Return C type name for netCDF attribute container type, given type code.
- */
-char *
-ncatype(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return "int"; /* avoids choosing between uchar and schar */
- case NC_CHAR:
- return "text";
- case NC_SHORT:
- return "short";
- case NC_INT:
- return "int";
- case NC_FLOAT:
- return "float";
- case NC_DOUBLE:
- return "double";
- default:
- derror("ncatype: bad type code");
- return 0;
- }
-}
-
-
-/* return internal size for values of specified netCDF type */
-size_t
-nctypesize(
- nc_type type) /* netCDF type code */
-{
- switch (type) {
- case NC_BYTE:
- return sizeof(char);
- case NC_CHAR:
- return sizeof(char);
- case NC_SHORT:
- return sizeof(short);
- case NC_INT:
- return sizeof(int);
- case NC_FLOAT:
- return sizeof(float);
- case NC_DOUBLE:
- return sizeof(double);
- default:
- derror("nctypesize: bad type code");
- return 0;
- }
-}
-
-
-/*
- * Given a netcdf numeric type, a pointer to a vector of values of that
- * type, and the index of the vector element desired, returns a pointer
- * to a malloced string representing the value in FORTRAN. Since this
- * may be used in a DATA statement, it must not include non-constant
- * expressions, such as "char(26)".
- */
-char *
-fstring(
- nc_type type, /* netCDF type code */
- void *valp, /* pointer to vector of values */
- int num) /* element of vector desired */
-{
- static char *cp;
- signed char *schp;
- short *shortp;
- int *intp;
- float *floatp;
- double *doublep;
-
- switch (type) {
- case NC_BYTE:
- cp = (char *) emalloc (10);
- schp = (signed char *)valp;
- sprintf(cp,"%d", schp[num]);
- return cp;
-
- case NC_SHORT:
- cp = (char *) emalloc (10);
- shortp = (short *)valp;
- (void) sprintf(cp,"%d",* (shortp + num));
- return cp;
-
- case NC_INT:
- cp = (char *) emalloc (20);
- intp = (int *)valp;
- (void) sprintf(cp,"%d",* (intp + num));
- return cp;
-
- case NC_FLOAT:
- cp = (char *) emalloc (20);
- floatp = (float *)valp;
- (void) sprintf(cp,"%.8g",* (floatp + num));
- return cp;
-
- case NC_DOUBLE:
- cp = (char *) emalloc (25);
- doublep = (double *)valp;
- (void) sprintf(cp,"%.16g",* (doublep + num));
- expe2d(cp); /* change 'e' to 'd' in exponent */
- return cp;
-
- default:
- derror("fstring: bad type code");
- return 0;
- }
-}
-
-
-/*
- * Given a pointer to a counted string, returns a pointer to a malloced string
- * representing the string as a C constant.
- */
-char *
-cstrstr(
- const char *valp, /* pointer to vector of characters*/
- size_t len) /* number of characters in valp */
-{
- static char *sp;
- char *cp;
- char *istr, *istr0; /* for null-terminated copy */
- int ii;
-
- if(4*len+3 != (unsigned)(4*len+3)) {
- derror("too much character data!");
- exit(9);
- }
- sp = cp = (char *) emalloc(4*len+3);
-
- if(len == 1 && *valp == 0) { /* empty string */
- strcpy(sp,"\"\"");
- return sp;
- }
-
- istr0 = istr = (char *) emalloc(len + 1);
- for(ii = 0; ii < len; ii++) {
- istr[ii] = valp[ii];
- }
- istr[len] = '\0';
-
- *cp++ = '"';
- for(ii = 0; ii < len; ii++) {
- switch (*istr) {
- case '\0': *cp++ = '\\'; *cp++ = '0'; *cp++ = '0'; *cp++ = '0'; break;
- case '\b': *cp++ = '\\'; *cp++ = 'b'; break;
- case '\f': *cp++ = '\\'; *cp++ = 'f'; break;
- case '\n': *cp++ = '\\'; *cp++ = 'n'; break;
- case '\r': *cp++ = '\\'; *cp++ = 'r'; break;
- case '\t': *cp++ = '\\'; *cp++ = 't'; break;
- case '\v': *cp++ = '\\'; *cp++ = 'v'; break;
- case '\\': *cp++ = '\\'; *cp++ = '\\'; break;
- case '\"': *cp++ = '\\'; *cp++ = '\"'; break;
- default:
- if (!isprint(*istr)) {
- static char octs[] = "01234567";
- int rem = ((unsigned char)*istr)%64;
- *cp++ = '\\';
- *cp++ = octs[((unsigned char)*istr)/64]; /* to get, e.g. '\177' */
- *cp++ = octs[rem/8];
- *cp++ = octs[rem%8];
- } else {
- *cp++ = *istr;
- }
- break;
- }
- istr++;
- }
- *cp++ = '"';
- *cp = '\0';
- free(istr0);
- return sp;
-}
-
-
-/* Given a pointer to a counted string (not necessarily
- * null-terminated), returns a pointer to a malloced string representing
- * the string as a FORTRAN string expression. For example, the string
- * "don't" would yield the FORTRAN string "'don''t'", and the string
- * "ab\ncd" would yield "'ab'//char(10)//'cd'". The common
- * interpretation of "\"-escaped characters is non-standard, so the
- * generated Fortran may require adjustment in compilers that don't
- * recognize "\" as anything special in a character context. */
-char *
-fstrstr(
- const char *str, /* pointer to vector of characters */
- size_t ilen) /* number of characters in istr */
-{
- static char *ostr;
- char *cp, tstr[12];
- int was_print = 0; /* true if last character was printable */
- char *istr, *istr0; /* for null-terminated copy */
- int ii;
-
- if(12*ilen != (size_t)(12*ilen)) {
- derror("too much character data!");
- exit(9);
- }
- istr0 = istr = (char *) emalloc(ilen + 1);
- for(ii = 0; ii < ilen; ii++) {
- istr[ii] = str[ii];
- }
- istr[ilen] = '\0';
-
- if (*istr == '\0') { /* empty string input, not legal in FORTRAN */
- ostr = (char*) emalloc(strlen("char(0)") + 1);
- strcpy(ostr, "char(0)");
- free(istr0);
- return ostr;
- }
- ostr = cp = (char *) emalloc(12*ilen);
- *ostr = '\0';
- if (isprint(*istr)) { /* handle first character in input */
- *cp++ = '\'';
- switch (*istr) {
- case '\'':
- *cp++ = '\'';
- *cp++ = '\'';
- break;
- case '\\':
- *cp++ = '\\';
- *cp++ = '\\';
- break;
- default:
- *cp++ = *istr;
- break;
- }
- *cp = '\0';
- was_print = 1;
- } else {
- sprintf(tstr, "char(%d)", (unsigned char)*istr);
- strcat(cp, tstr);
- cp += strlen(tstr);
- was_print = 0;
- }
- istr++;
-
- for(ii = 1; ii < ilen; ii++) { /* handle subsequent characters in input */
- if (isprint(*istr)) {
- if (! was_print) {
- strcat(cp, "//'");
- cp += 3;
- }
- switch (*istr) {
- case '\'':
- *cp++ = '\'';
- *cp++ = '\'';
- break;
- case '\\':
- *cp++ = '\\';
- *cp++ = '\\';
- break;
- default:
- *cp++ = *istr;
- break;
- }
- *cp = '\0';
- was_print = 1;
- } else {
- if (was_print) {
- *cp++ = '\'';
- *cp = '\0';
- }
- sprintf(tstr, "//char(%d)", (unsigned char)*istr);
- strcat(cp, tstr);
- cp += strlen(tstr);
- was_print = 0;
- }
- istr++;
- }
- if (was_print)
- *cp++ = '\'';
- *cp = '\0';
- free(istr0);
- return ostr;
-}
-
-
-static void
-cl_netcdf(void)
-{
- int stat = nc_close(ncid);
- check_err(stat);
-}
-
-#define fpr (void) fprintf
-
-static void
-cl_c(void)
-{
- cline(" stat = nc_close(ncid);");
- cline(" check_err(stat,__LINE__,__FILE__);");
-#ifndef vms
- cline(" return 0;");
-#else
- cline(" return 1;");
-#endif
- cline("}");
-}
-
-/* Returns true if dimension used in at least one record variable,
- otherwise false. This is an inefficient algorithm, but we don't call
- it very often ... */
-static int
-used_in_rec_var(
- int idim /* id of dimension */
- ) {
- int ivar;
-
- for (ivar = 0; ivar < nvars; ivar++) {
- if (vars[ivar].ndims > 0 && vars[ivar].dims[0] == rec_dim) {
- int jdim;
- for (jdim = 0; jdim < vars[ivar].ndims; jdim++) {
- if (vars[ivar].dims[jdim] == idim)
- return 1;
- }
- }
- }
- return 0;
-}
-
-
-/* Return name for Fortran fill constant of specified type */
-static char *
-f_fill_name(
- nc_type type
- )
-{
- switch(type) {
- case NC_BYTE:
- return "NF_FILL_BYTE";
- case NC_CHAR:
- return "NF_FILL_CHAR";
- case NC_SHORT:
- return "NF_FILL_SHORT";
- case NC_INT:
- return "NF_FILL_INT";
- case NC_FLOAT:
- return "NF_FILL_FLOAT";
- case NC_DOUBLE:
- return "NF_FILL_DOUBLE";
- }
- derror("f_fill_name: bad type code");
- return 0;
-}
-
-
-/* Generate Fortran for cleaning up and closing file */
-static void
-cl_fortran(void)
-{
- int ivar;
- int idim;
- char stmnt[FORT_MAX_STMNT];
- char s2[FORT_MAX_STMNT];
- char*sp;
- int have_rec_var = 0;
-
- /* do we have any record variables? */
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- have_rec_var = 1;
- break;
- }
- }
-
- if (have_rec_var) {
- fline(" ");
- fline("* Write record variables");
- sprintf(stmnt, "call writerecs(ncid,");
- /* generate parameter list for subroutine to write record vars */
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- /* if a record variable, include id in parameter list */
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- sprintf(s2, "%s_id,", v->lname);
- strcat(stmnt, s2);
- }
- }
- sp = strrchr(stmnt, ',');
- if(sp != NULL) {
- *sp = '\0';
- }
- strcat(stmnt, ")");
- fline(stmnt);
- }
-
- fline(" ");
- fline("iret = nf_close(ncid)");
- fline("call check_err(iret)");
- fline("end");
-
- fline(" ");
-
- if (have_rec_var) {
- sprintf(stmnt, "subroutine writerecs(ncid,");
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- sprintf(s2, "%s_id,", v->lname);
- strcat(stmnt, s2);
- }
- }
- sp = strrchr(stmnt, ',');
- if(sp != NULL) {
- *sp = '\0';
- }
- strcat(stmnt, ")");
- fline(stmnt);
- fline(" ");
- fline("* netCDF id");
- fline("integer ncid");
-
- fline("* variable ids");
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- sprintf(stmnt, "integer %s_id", v->lname);
- fline(stmnt);
- }
- }
-
- fline(" ");
- fline("include 'netcdf.inc'");
-
- /* create necessary declarations */
- fline("* error status return");
- fline("integer iret");
-
- /* generate integer/parameter declarations for all dimensions
- used in record variables, except record dimension. */
- fline(" ");
- fline("* netCDF dimension sizes for dimensions used with record variables");
- for (idim = 0; idim < ndims; idim++) {
- /* if used in a record variable and not record dimension */
- if (used_in_rec_var(idim) && dims[idim].size != NC_UNLIMITED) {
- sprintf(stmnt, "integer %s_len", dims[idim].lname);
- fline(stmnt);
- sprintf(stmnt, "parameter (%s_len = %lu)",
- dims[idim].lname, (unsigned long) dims[idim].size);
- fline(stmnt);
- }
- }
-
- fline(" ");
- fline("* rank (number of dimensions) for each variable");
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- sprintf(stmnt, "integer %s_rank", v->lname);
- fline(stmnt);
- }
- }
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- sprintf(stmnt, "parameter (%s_rank = %d)", v->lname,
- v->ndims);
- fline(stmnt);
- }
- }
-
- fline("* starts and counts for array sections of record variables");
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- sprintf(stmnt,
- "integer %s_start(%s_rank), %s_count(%s_rank)",
- v->lname, v->lname, v->lname, v->lname);
- fline(stmnt);
- }
- }
-
- fline(" ");
- fline("* data variables");
-
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- char *sp;
-
- fline(" ");
- sprintf(stmnt, "integer %s_nr", v->lname);
- fline(stmnt);
- if (v->nrecs > 0) {
- sprintf(stmnt, "parameter (%s_nr = %lu)",
- v->lname, (unsigned long) v->nrecs);
- } else {
- sprintf(stmnt, "parameter (%s_nr = 1)",
- v->lname);
- }
- fline(stmnt);
- if (v->type != NC_CHAR) {
- sprintf(stmnt, "%s %s(", ncftype(v->type),
- v->lname);
- /* reverse dimensions for FORTRAN */
- for (idim = v->ndims-1; idim >= 0; idim--) {
- if(v->dims[idim] == rec_dim) {
- sprintf(s2, "%s_nr, ", v->lname);
- } else {
- sprintf(s2, "%s_len, ",
- dims[v->dims[idim]].lname);
- }
- strcat(stmnt, s2);
- }
- sp = strrchr(stmnt, ',');
- if(sp != NULL) {
- *sp = '\0';
- }
- strcat(stmnt, ")");
- fline(stmnt);
- }
- }
- }
-
- fline(" ");
-
- /* Emit DATA statements after declarations, because f2c on Linux can't
- handle interspersing them */
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
-
- if (v->ndims > 0 && v->dims[0] == rec_dim && v->type != NC_CHAR) {
- if (v->has_data) {
- fline(v->data_stmnt);
- } else { /* generate data statement for FILL record */
- size_t rec_len = 1;
- for (idim = 1; idim < v->ndims; idim++) {
- rec_len *= dims[v->dims[idim]].size;
- }
- sprintf(stmnt,"data %s /%lu * %s/", v->lname,
- (unsigned long) rec_len,
- f_fill_name(v->type));
- fline(stmnt);
- }
- }
- }
- fline(" ");
- for (ivar = 0; ivar < nvars; ivar++) {
- struct vars *v = &vars[ivar];
- /* if a record variable, declare starts and counts */
- if (v->ndims > 0 && v->dims[0] == rec_dim) {
- if (!v->has_data)
- continue;
- sprintf(stmnt, "* store %s", v->name);
- fline(stmnt);
-
- for (idim = 0; idim < v->ndims; idim++) {
- sprintf(stmnt, "%s_start(%d) = 1", v->lname, idim+1);
- fline(stmnt);
- }
- for (idim = v->ndims-1; idim > 0; idim--) {
- sprintf(stmnt, "%s_count(%d) = %s_len", v->lname,
- v->ndims - idim, dims[v->dims[idim]].lname);
- fline(stmnt);
- }
- sprintf(stmnt, "%s_count(%d) = %s_nr", v->lname,
- v->ndims, v->lname);
- fline(stmnt);
-
- if (v->type != NC_CHAR) {
- sprintf(stmnt,
- "iret = nf_put_vara_%s(ncid, %s_id, %s_start, %s_count, %s)",
- nfftype(v->type), v->lname, v->lname, v->lname, v->lname);
- } else {
- sprintf(stmnt,
- "iret = nf_put_vara_%s(ncid, %s_id, %s_start, %s_count, %s)",
- nfftype(v->type), v->lname, v->lname, v->lname,
- v->data_stmnt);
- }
-
- fline(stmnt);
- fline("call check_err(iret)");
- }
- }
-
- fline(" ");
-
- fline("end");
-
- fline(" ");
- }
-
- fline("subroutine check_err(iret)");
- fline("integer iret");
- fline("include 'netcdf.inc'");
- fline("if (iret .ne. NF_NOERR) then");
- fline("print *, nf_strerror(iret)");
- fline("stop");
- fline("endif");
- fline("end");
-}
-
-
-/* invoke netcdf calls (or generate C or Fortran code) to create netcdf
- * from in-memory structure. */
-void
-define_netcdf(
- char *netcdfname)
-{
- char *filename; /* output file name */
-
- if (netcdf_name) { /* name given on command line */
- filename = netcdf_name;
- } else { /* construct name from CDL name */
- filename = (char *) emalloc(strlen(netcdfname) + 5);
- (void) strcpy(filename,netcdfname);
- if (netcdf_flag == -1)
- (void) strcat(filename,".cdf"); /* old, deprecated extension */
- else
- (void) strcat(filename,".nc"); /* new, favored extension */
- }
- if (netcdf_flag)
- gen_netcdf(filename); /* create netcdf */
- if (c_flag) /* create C code to create netcdf */
- gen_c(filename);
- if (fortran_flag) /* create Fortran code to create netcdf */
- gen_fortran(filename);
- free(filename);
-}
-
-
-void
-close_netcdf(void)
-{
- if (netcdf_flag)
- cl_netcdf(); /* close netcdf */
- if (c_flag) /* create C code to close netcdf */
- cl_c();
- if (fortran_flag) /* create Fortran code to close netcdf */
- cl_fortran();
-}
-
-
-void
-check_err(int stat) {
- if (stat != NC_NOERR) {
- fprintf(stderr, "ncgen: %s", nc_strerror(stat));
- }
-}
-
-/*
- * For logging error conditions.
- */
-#ifndef NO_STDARG
-void
-derror(const char *fmt, ...)
-#else
-/*VARARGS1*/
-void
-derror(fmt, va_alist)
- const char *fmt ; /* error-message printf-style format */
- va_dcl /* variable number of error args, if any */
-#endif /* !NO_STDARG */
-{
- va_list args ;
-
-
- if (lineno == 1)
- (void) fprintf(stderr,"%s: %s: ", progname, cdlname);
- else
- (void) fprintf(stderr,"%s: %s line %d: ", progname, cdlname, lineno);
-
-#ifndef NO_STDARG
- va_start(args ,fmt) ;
-#else
- va_start(args) ;
-#endif /* !NO_STDARG */
-
- (void) vfprintf(stderr,fmt,args) ;
- va_end(args) ;
-
- (void) fputc('\n',stderr) ;
- (void) fflush(stderr); /* to ensure log files are current */
- derror_count++;
-}
-
-
-void *
-emalloc ( /* check return from malloc */
- size_t size)
-{
- void *p;
-
- p = (void *) malloc (size);
- if (p == 0) {
- derror ("out of memory\n");
- exit(3);
- }
- return p;
-}
-
-void *
-erealloc ( /* check return from realloc */
- void *ptr,
- size_t size) /* if 0, this is really a free */
-{
- void *p;
-
- p = (void *) realloc (ptr, size);
-
- if (p == 0 && size != 0) {
- derror ("out of memory");
- exit(3);
- }
- return p;
-}
-
-
-/*
- * For generated Fortran, change 'e' to 'd' in exponent of double precision
- * constants.
- */
-void
-expe2d(
- char *cp) /* string containing double constant */
-{
- char *expchar = strrchr(cp,'e');
- if (expchar) {
- *expchar = 'd';
- }
-}
-
-
-
-/* Returns non-zero if n is a power of 2, 0 otherwise */
-int
-pow2(
- int n)
-{
- int m = n;
- int p = 1;
-
- while (m > 0) {
- m /= 2;
- p *= 2;
- }
- return p == 2*n;
-}
-
-
-/*
- * Grow an integer array as necessary.
- *
- * Assumption: nar never incremented by more than 1 from last call.
- *
- * Makes sure an array is within a factor of 2 of the size needed.
- *
- * Make sure *arpp points to enough space to hold nar integers. If not big
- * enough, malloc more space, copy over existing stuff, free old. When
- * called for first time, *arpp assumed to be uninitialized.
- */
-void
-grow_iarray(
- int nar, /* array must be at least this big */
- int **arpp) /* address of start of int array */
-{
- if (nar == 0) {
- *arpp = (int *) emalloc(1 * sizeof(int));
- return;
- }
- if (! pow2(nar)) /* return unless nar is a power of two */
- return;
- *arpp = (int *) erealloc(*arpp, 2 * nar * sizeof(int));
-}
-
-
-/*
- * Grow an array of variables as necessary.
- *
- * Assumption: nar never incremented by more than 1 from last call.
- *
- * Makes sure array is within a factor of 2 of the size needed.
- *
- * Make sure *arpp points to enough space to hold nar variables. If not big
- * enough, malloc more space, copy over existing stuff, free old. When
- * called for first time, *arpp assumed to be uninitialized.
- */
-void
-grow_varray(
- int nar, /* array must be at least this big */
- struct vars **arpp) /* address of start of var array */
-{
- if (nar == 0) {
- *arpp = (struct vars *) emalloc(1 * sizeof(struct vars));
- return;
- }
- if (! pow2(nar)) /* return unless nar is a power of two */
- return;
- *arpp = (struct vars *) erealloc(*arpp, 2 * nar * sizeof(struct vars));
-}
-
-
-/*
- * Grow an array of dimensions as necessary.
- *
- * Assumption: nar never incremented by more than 1 from last call.
- *
- * Makes sure array is within a factor of 2 of the size needed.
- *
- * Make sure *arpp points to enough space to hold nar dimensions. If not big
- * enough, malloc more space, copy over existing stuff, free old. When
- * called for first time, *arpp assumed to be uninitialized.
- */
-void
-grow_darray(
- int nar, /* array must be at least this big */
- struct dims **arpp) /* address of start of var array */
-{
- if (nar == 0) {
- *arpp = (struct dims *) emalloc(1 * sizeof(struct dims));
- return;
- }
- if (! pow2(nar)) /* return unless nar is a power of two */
- return;
- *arpp = (struct dims *) erealloc(*arpp, 2 * nar * sizeof(struct dims));
-}
-
-
-/*
- * Grow an array of attributes as necessary.
- *
- * Assumption: nar never incremented by more than 1 from last call.
- *
- * Makes sure array is within a factor of 2 of the size needed.
- *
- * Make sure *arpp points to enough space to hold nar attributes. If not big
- * enough, malloc more space, copy over existing stuff, free old. When
- * called for first time, *arpp assumed to be uninitialized.
- */
-void
-grow_aarray(
- int nar, /* array must be at least this big */
- struct atts **arpp) /* address of start of var array */
-{
- if (nar == 0) {
- *arpp = (struct atts *) emalloc(1 * sizeof(struct atts));
- return;
- }
- if (! pow2(nar)) /* return unless nar is a power of two */
- return;
- *arpp = (struct atts *) erealloc(*arpp, 2 * nar * sizeof(struct atts));
-}
-
-
-/*
- * Replace dashes and dots in name so it can be used in C and
- * Fortran without causing syntax errors. Here we just replace each "-"
- * in a name with "_dash_" and each "." with "_dot_", though any
- * similar replacement that doesn't clash with existing names would
- * work.
- */
-extern char*
-decodify (
- const char *name)
-{
- int count=0; /* number of minus signs in name */
- char *newname;
- const char *cp = name;
- char *sp;
-
- while(*cp != '\0') {
- if (*cp == '-')
- count += 5;
- else if(*cp == '.')
- count += 4;
- cp++;
- }
- newname = (char *) emalloc(strlen(name) + count + 1);
- cp = name;
- sp = newname;
- while(*cp != '\0') {
- if (*cp == '-') {
- *sp++ = '_';
- *sp++ = 'd';
- *sp++ = 'a';
- *sp++ = 's';
- *sp++ = 'h';
- *sp++ = '_';
- } else if (*cp == '.') {
- *sp++ = '_';
- *sp++ = 'd';
- *sp++ = 'o';
- *sp++ = 't';
- *sp++ = '_';
- } else {
- *sp++ = *cp;
- }
- cp++;
- }
- *sp = '\0';
- return newname;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.h
deleted file mode 100644
index 5abe1f2..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef NC_GENLIB_H
-#define NC_GENLIB_H
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/genlib.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-#include <stdlib.h>
-#include <limits.h>
-
-extern const char *progname; /* for error messages */
-extern const char *cdlname; /* for error messages */
-
-#define FORT_MAX_LINES 20 /* max lines in FORTRAN statement */
-#define FORT_MAX_STMNT 66*FORT_MAX_LINES /* max chars in FORTRAN statement */
-#define C_MAX_STMNT FORT_MAX_STMNT /* until we fix to break up C lines */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void cline ( const char* stmnt );
-extern void fline ( const char* stmnt );
-extern char* nctype ( nc_type type );
-extern char* ncctype ( nc_type type );
-extern char* ncstype ( nc_type type );
-extern char* ncatype ( nc_type type );
-extern char* nfstype ( nc_type type );
-extern char* nfftype ( nc_type type );
-extern char* fstring ( nc_type type, void* valp, int num );
-extern char* cstrstr ( const char* valp, size_t len );
-extern char* fstrstr ( const char* str, size_t ilen );
-extern size_t nctypesize( nc_type type );
-
-extern void derror ( const char *fmt, ... );
-extern void check_err ( int status );
-extern void *emalloc ( size_t size );
-extern void *erealloc ( void *ptr, size_t size );
-extern void expe2d ( char *ptr );
-extern void grow_iarray ( int narray, int **array );
-extern void grow_varray ( int narray, struct vars **array );
-extern void grow_darray ( int narray, struct dims **array );
-extern void grow_aarray ( int narray, struct atts **array );
-extern char* decodify (const char *name);
-
-extern int put_variable ( void* rec_start );
-
-/* initializes netcdf counts (e.g. nvars), defined in init.c */
-extern void init_netcdf ( void );
-
-/* generates all define mode stuff, defined in genlib.c */
-extern void define_netcdf(char *netcdfname);
-
-/* generates variable puts, defined in load.c */
-extern void load_netcdf ( void* rec_start );
-
-/* generates close, defined in close.c */
-extern void close_netcdf ( void );
-
-/* defined in escapes.c */
-extern void expand_escapes ( char* termstring, char* yytext, int yyleng );
-
-/* to get fill value for various types, defined in getfill.c */
-extern void nc_getfill ( nc_type type, union generic* gval );
-
-/* to put fill value for various types, defined in getfill.c */
-extern void nc_putfill ( nc_type type, void* val, union generic* gval );
-
-/* fills a generic array with a value, defined in getfill.c */
-extern void nc_fill ( nc_type type, size_t num, void* datp,
- union generic fill_val );
-
-/* reset symbol table to empty, defined in ncgen.y */
-extern void clearout(void);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /*!NC_GENLIB_H*/
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/getfill.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/getfill.c
deleted file mode 100644
index 4571a21..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/getfill.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/getfill.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include "netcdf.h"
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h"
-
-
-/*
- * Given netCDF type, return a default fill_value appropriate for
- * that type.
- */
-void
-nc_getfill(
- nc_type type,
- union generic *gval)
-{
- switch(type) {
- case NC_CHAR:
- gval->charv = NC_FILL_CHAR;
- return;
- case NC_BYTE:
- gval->charv = NC_FILL_BYTE;
- return;
- case NC_SHORT:
- gval->shortv = NC_FILL_SHORT;
- return;
- case NC_INT:
- gval->intv = NC_FILL_INT;
- return;
- case NC_FLOAT:
- gval->floatv = NC_FILL_FLOAT;
- return;
- case NC_DOUBLE:
- gval->doublev = NC_FILL_DOUBLE;
- return;
- default:
- derror("nc_getfill: unrecognized type");
- }
-}
-
-
-void
-nc_fill(
- nc_type type, /* netcdf type code */
- size_t num, /* number of values to fill */
- void *datp, /* where to start filling */
- union generic fill_val) /* value to use */
-{
- char *char_valp; /* pointers used to accumulate data values */
- short *short_valp;
- int *long_valp;
- float *float_valp;
- double *double_valp;
-
- switch (type) {
- case NC_CHAR:
- case NC_BYTE:
- char_valp = (char *) datp;
- break;
- case NC_SHORT:
- short_valp = (short *) datp;
- break;
- case NC_INT:
- long_valp = (int *) datp;
- break;
- case NC_FLOAT:
- float_valp = (float *) datp;
- break;
- case NC_DOUBLE:
- double_valp = (double *) datp;
- break;
- }
- while (num--) {
- switch (type) {
- case NC_CHAR:
- case NC_BYTE:
- *char_valp++ = fill_val.charv;
- break;
- case NC_SHORT:
- *short_valp++ = fill_val.shortv;
- break;
- case NC_INT:
- *long_valp++ = fill_val.intv;
- break;
- case NC_FLOAT:
- *float_valp++ = fill_val.floatv;
- break;
- case NC_DOUBLE:
- *double_valp++ = fill_val.doublev;
- break;
- }
- }
-}
-
-
-/*
- * Given netCDF type, put a value of that type into a fill_value
- */
-void
-nc_putfill(
- nc_type type,
- void *val, /* value of type to be put */
- union generic *gval) /* where the value is to be put */
-{
- switch(type) {
- case NC_CHAR:
- case NC_BYTE:
- gval->charv = *(char *)val;
- return;
- case NC_SHORT:
- gval->shortv = *(short *)val;
- return;
- case NC_INT:
- gval->intv = *(int *)val;
- return;
- case NC_FLOAT:
- gval->floatv = *(float *)val;
- return;
- case NC_DOUBLE:
- gval->doublev = *(double *)val;
- return;
- default:
- derror("nc_putfill: unrecognized type");
- }
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/init.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/init.c
deleted file mode 100644
index d5eb507..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/init.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/init.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <netcdf.h>
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h"
-
-extern int netcdf_flag;
-extern int c_flag;
-extern int fortran_flag;
-
-struct dims *dims; /* table of netcdf dimensions */
-
-int ncid; /* handle for netCDF */
-int ndims; /* number of dimensions declared for netcdf */
-int nvars; /* number of variables declared for netcdf */
-int natts; /* number of attributes */
-int nvdims; /* number of dimensions for variables */
-int dimnum; /* dimension number index for variables */
-int varnum; /* variable number index for attributes */
-int valnum; /* value number index for attributes */
-int rec_dim; /* number of the unlimited dimension, if any */
-size_t var_len; /* variable length (product of dimensions) */
-size_t rec_len; /* number of elements for a record of data */
-size_t var_size; /* size of each element of variable */
-
-struct vars *vars; /* a malloc'ed list */
-
-struct atts *atts; /* table of variable and global attributes */
-
-void
-init_netcdf(void) { /* initialize global counts, flags */
-
- clearout(); /* reset symbol table to empty */
- ndims = 0;
- nvars = 0;
- rec_dim = -1; /* means no unlimited dimension (yet) */
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/load.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/load.c
deleted file mode 100644
index 1b9a154..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/load.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: load.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <netcdf.h>
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h"
-
-extern int netcdf_flag;
-extern int c_flag;
-extern int fortran_flag;
-
-#define fpr (void) fprintf
-
-
-/*
- * Remove trailing zeros (after decimal point) but not trailing decimal
- * point from ss, a string representation of a floating-point number that
- * might include an exponent part.
- */
-static void
-tztrim(
- char *ss /* returned string representing dd */
- )
-{
- char *cp, *ep;
-
- cp = ss;
- if (*cp == '-')
- cp++;
- while(isdigit((int)*cp) || *cp == '.')
- cp++;
- if (*--cp == '.')
- return;
- ep = cp+1;
- while (*cp == '0')
- cp--;
- cp++;
- if (cp == ep)
- return;
- while (*ep)
- *cp++ = *ep++;
- *cp = '\0';
- return;
-}
-
-
-/* generate C to put netCDF record from in-memory data */
-static void
-gen_load_c(
- void *rec_start
- )
-{
- int idim, ival;
- char *val_string;
- char *charvalp;
- short *shortvalp;
- int *intvalp;
- float *floatvalp;
- double *doublevalp;
- char stmnt[C_MAX_STMNT];
- size_t stmnt_len;
- char s2[C_MAX_STMNT];
-
- if (!vars[varnum].has_data)
- return;
-
- cline("");
- sprintf(stmnt, " {\t\t\t/* store %s */", vars[varnum].name);
- cline(stmnt);
-
- if (vars[varnum].ndims > 0) {
- if (vars[varnum].dims[0] == rec_dim) {
- sprintf(stmnt, " static size_t %s_start[RANK_%s];",
- vars[varnum].lname, vars[varnum].lname);
- cline(stmnt);
-
- sprintf(stmnt, " static size_t %s_count[RANK_%s];",
- vars[varnum].lname, vars[varnum].lname);
- cline(stmnt);
- }
-
- /* load variable with data values using static initialization */
- sprintf(stmnt, " static %s %s[] = {",
- ncctype(vars[varnum].type),
- vars[varnum].lname);
-
- stmnt_len = strlen(stmnt);
- switch (vars[varnum].type) {
- case NC_CHAR:
- val_string = cstrstr((char *) rec_start, var_len);
- sprintf(s2, "%s", val_string);
- strncat(stmnt, s2, C_MAX_STMNT - strlen(stmnt) );
- free(val_string);
- break;
- default:
- switch (vars[varnum].type) {
- case NC_BYTE:
- charvalp = (char *) rec_start;
- break;
- case NC_SHORT:
- shortvalp = (short *) rec_start;
- break;
- case NC_INT:
- intvalp = (int *) rec_start;
- break;
- case NC_FLOAT:
- floatvalp = (float *) rec_start;
- break;
- case NC_DOUBLE:
- doublevalp = (double *) rec_start;
- break;
- }
- for (ival = 0; ival < var_len-1; ival++) {
- switch (vars[varnum].type) {
- case NC_BYTE:
- sprintf(s2, "%d, ", *charvalp++);
- break;
- case NC_SHORT:
- sprintf(s2, "%d, ", *shortvalp++);
- break;
- case NC_INT:
- sprintf(s2, "%ld, ", (long)*intvalp++);
- break;
- case NC_FLOAT:
- sprintf(s2, "%.8g, ", *floatvalp++);
- break;
- case NC_DOUBLE:
- sprintf(s2, "%#.16g", *doublevalp++);
- tztrim(s2);
- strcat(s2, ", ");
- break;
- }
- stmnt_len += strlen(s2);
- if (stmnt_len < C_MAX_STMNT)
- strcat(stmnt, s2);
- else {
- cline(stmnt);
- strcpy(stmnt,s2);
- stmnt_len = strlen(stmnt);
- }
- }
- for (;ival < var_len; ival++) {
- switch (vars[varnum].type) {
- case NC_BYTE:
- sprintf(s2, "%d", *charvalp);
- break;
- case NC_SHORT:
- sprintf(s2, "%d", *shortvalp);
- break;
- case NC_INT:
- sprintf(s2, "%ld", (long)*intvalp);
- break;
- case NC_FLOAT:
- sprintf(s2, "%.8g", *floatvalp);
- break;
- case NC_DOUBLE:
- sprintf(s2, "%#.16g", *doublevalp++);
- tztrim(s2);
- break;
- }
- stmnt_len += strlen(s2);
- if (stmnt_len < C_MAX_STMNT)
- strcat(stmnt, s2);
- else {
- cline(stmnt);
- strcpy(stmnt,s2);
- stmnt_len = strlen(stmnt);
- }
- }
- break;
- }
- strcat(stmnt,"};");
- cline(stmnt);
-
- if (vars[varnum].dims[0] == rec_dim) {
- sprintf(stmnt,
- " %s_len = %d; /* number of records of %s data */",
- dims[rec_dim].lname,
- vars[varnum].nrecs, /* number of recs for this variable */
- vars[varnum].name);
- cline(stmnt);
-
- for (idim = 0; idim < vars[varnum].ndims; idim++) {
- sprintf(stmnt, " %s_start[%d] = 0;",
- vars[varnum].lname,
- idim);
- cline(stmnt);
- }
-
- for (idim = 0; idim < vars[varnum].ndims; idim++) {
- sprintf(stmnt, " %s_count[%d] = %s_len;",
- vars[varnum].lname,
- idim,
- dims[vars[varnum].dims[idim]].lname);
- cline(stmnt);
- }
- }
-
- if (vars[varnum].dims[0] == rec_dim) {
- sprintf(stmnt,
- " stat = nc_put_vara_%s(ncid, %s_id, %s_start, %s_count, %s);",
- ncstype(vars[varnum].type),
- vars[varnum].lname,
- vars[varnum].lname,
- vars[varnum].lname,
- vars[varnum].lname);
- } else { /* non-record variables */
- sprintf(stmnt,
- " stat = nc_put_var_%s(ncid, %s_id, %s);",
- ncstype(vars[varnum].type),
- vars[varnum].lname,
- vars[varnum].lname);
- }
- cline(stmnt);
- } else { /* scalar variables */
- /* load variable with data values using static initialization */
- sprintf(stmnt, " static %s %s = ",
- ncctype(vars[varnum].type),
- vars[varnum].lname);
-
- switch (vars[varnum].type) {
- case NC_CHAR:
- val_string = cstrstr((char *) rec_start, var_len);
- val_string[strlen(val_string)-1] = '\0';
- sprintf(s2, "'%s'", &val_string[1]);
- free(val_string);
- break;
- case NC_BYTE:
- charvalp = (char *) rec_start;
- sprintf(s2, "%d", *charvalp);
- break;
- case NC_SHORT:
- shortvalp = (short *) rec_start;
- sprintf(s2, "%d", *shortvalp);
- break;
- case NC_INT:
- intvalp = (int *) rec_start;
- sprintf(s2, "%ld", (long)*intvalp);
- break;
- case NC_FLOAT:
- floatvalp = (float *) rec_start;
- sprintf(s2, "%.8g", *floatvalp);
- break;
- case NC_DOUBLE:
- doublevalp = (double *) rec_start;
- sprintf(s2, "%#.16g", *doublevalp++);
- tztrim(s2);
- break;
- }
- strncat(stmnt, s2, C_MAX_STMNT - strlen(stmnt) );
- strcat(stmnt,";");
- cline(stmnt);
- sprintf(stmnt,
- " stat = nc_put_var_%s(ncid, %s_id, &%s);",
- ncstype(vars[varnum].type),
- vars[varnum].lname,
- vars[varnum].lname);
- cline(stmnt);
- }
- cline(" check_err(stat,__LINE__,__FILE__);");
- cline(" }");
-}
-
-
-/*
- * Add to a partial Fortran statement, checking if it's too long. If it is too
- * long, output the first part of it as a single statement with continuation
- * characters and start a new (probably invalid) statement with the remainder.
- * This will cause a Fortran compiler error, but at least all the information
- * will be available.
- */
-static void
-fstrcat(
- char *s, /* source string of stement being built */
- char *t, /* string to be appended to source */
- size_t *slenp /* pointer to length of source string */
- )
-{
- *slenp += strlen(t);
- if (*slenp >= FORT_MAX_STMNT) {
- derror("FORTRAN statement too long: %s",s);
- fline(s);
- strcpy(s, t);
- *slenp = strlen(s);
- } else {
- strcat(s, t);
- }
-}
-
-/*
- * Create Fortran data statement to initialize numeric variable with
- * values.
- */
-static void
-f_var_init(
- int varnum, /* which variable */
- void *rec_start /* start of data */
- )
-{
- char *val_string;
- char *charvalp;
- short *shortvalp;
- int *intvalp;
- float *floatvalp;
- double *doublevalp;
- char stmnt[FORT_MAX_STMNT];
- size_t stmnt_len;
- char s2[FORT_MAX_STMNT];
- int ival;
-
- /* load variable with data values */
- sprintf(stmnt, "data %s /",vars[varnum].lname);
- stmnt_len = strlen(stmnt);
- switch (vars[varnum].type) {
- case NC_BYTE:
- charvalp = (char *) rec_start;
- for (ival = 0; ival < var_len-1; ival++) {
- val_string = fstring(NC_BYTE,(void *)charvalp++,0);
- sprintf(s2, "%s, ", val_string);
- fstrcat(stmnt, s2, &stmnt_len);
- free(val_string);
- }
- val_string = fstring(NC_BYTE,(void *)charvalp++,0);
- fstrcat(stmnt, val_string, &stmnt_len);
- free(val_string);
- break;
- case NC_SHORT:
- shortvalp = (short *) rec_start;
- for (ival = 0; ival < var_len-1; ival++) {
- sprintf(s2, "%d, ", *shortvalp++);
- fstrcat(stmnt, s2, &stmnt_len);
- }
- sprintf(s2, "%d", *shortvalp);
- fstrcat(stmnt, s2, &stmnt_len);
- break;
- case NC_INT:
- intvalp = (int *) rec_start;
- for (ival = 0; ival < var_len-1; ival++) {
- sprintf(s2, "%ld, ", (long)*intvalp++);
- fstrcat(stmnt, s2, &stmnt_len);
- }
- sprintf(s2, "%ld", (long)*intvalp);
- fstrcat(stmnt, s2, &stmnt_len);
- break;
- case NC_FLOAT:
- floatvalp = (float *) rec_start;
- for (ival = 0; ival < var_len-1; ival++) {
- sprintf(s2, "%.8g, ", *floatvalp++);
- fstrcat(stmnt, s2, &stmnt_len);
- }
- sprintf(s2, "%.8g", *floatvalp);
- fstrcat(stmnt, s2, &stmnt_len);
- break;
- case NC_DOUBLE:
- doublevalp = (double *) rec_start;
- for (ival = 0; ival < var_len-1; ival++) {
- sprintf(s2, "%#.16g", *doublevalp++);
- tztrim(s2);
- expe2d(s2); /* change 'e' to 'd' in exponent */
- fstrcat(s2, ", ", &stmnt_len);
- fstrcat(stmnt, s2, &stmnt_len);
- }
- sprintf(s2, "%#.16g", *doublevalp++);
- tztrim(s2);
- expe2d(s2);
- fstrcat(stmnt, s2, &stmnt_len);
- break;
- default:
- derror("fstrstr: bad type");
- break;
- }
- fstrcat(stmnt, "/", &stmnt_len);
-
- /* For record variables, store data statement for later use;
- otherwise, just print it. */
- if (vars[varnum].ndims > 0 && vars[varnum].dims[0] == rec_dim) {
- char *dup_stmnt = emalloc(strlen(stmnt)+1);
- strcpy(dup_stmnt, stmnt); /* ULTRIX missing strdup */
- vars[varnum].data_stmnt = dup_stmnt;
- } else {
- fline(stmnt);
- }
-}
-
-
-/* make Fortran to put record */
-static void
-gen_load_fortran(
- void *rec_start
- )
-{
- char stmnt[FORT_MAX_STMNT];
- struct vars *v = &vars[varnum];
-
- if (!v->has_data)
- return;
-
- if (v->ndims == 0 || v->dims[0] != rec_dim) {
- sprintf(stmnt, "* store %s", v->name);
- fline(stmnt);
- }
-
- /* generate code to initialize variable with values found in CDL input */
- if (v->type != NC_CHAR) {
- f_var_init(varnum, rec_start);
- } else {
- v->data_stmnt = fstrstr(rec_start, valnum);
- }
-
- if (v->ndims >0 && v->dims[0] == rec_dim) {
- return;
- }
- if (v->type != NC_CHAR) {
- sprintf(stmnt, "iret = nf_put_var_%s(ncid, %s_id, %s)",
- nfftype(v->type), v->lname, v->lname);
- } else {
- char *char_expr = fstrstr(rec_start, valnum);
- sprintf(stmnt, "iret = nf_put_var_%s(ncid, %s_id, %s)",
- nfftype(v->type), v->lname, char_expr);
- free(char_expr);
- }
-
- fline(stmnt);
- fline("call check_err(iret)");
-}
-
-
-/* invoke netcdf calls (or generate C or Fortran code) to load netcdf variable
- * from in-memory data. Assumes following global variables set from yacc
- * parser:
- * int varnum - number of variable to be loaded.
- * struct vars[varnum] - structure containing info on variable, specifically
- * name, type, ndims, dims, fill_value, has_data
- * int rec_dim - id of record dimension, or -1 if none
- * struct dims[] - structure containing name and size of dimensions.
- */
-int
-put_variable(
- void *rec_start /* points to data to be loaded */
- )
-{
- if (netcdf_flag)
- load_netcdf(rec_start); /* put variable values */
- if (c_flag) /* create C code to put values */
- gen_load_c(rec_start);
- if (fortran_flag) /* create Fortran code to put values */
- gen_load_fortran(rec_start);
-
- return 0;
-}
-
-
-/* write out variable's data from in-memory structure */
-void
-load_netcdf(
- void *rec_start
- )
-{
- int idim;
- int stat;
- size_t start[NC_MAX_VAR_DIMS];
- size_t count[NC_MAX_VAR_DIMS];
- char *charvalp;
- short *shortvalp;
- int *intvalp;
- float *floatvalp;
- double *doublevalp;
-
- /* load values into variable */
-
- switch (vars[varnum].type) {
- case NC_CHAR:
- case NC_BYTE:
- charvalp = (char *) rec_start;
- break;
- case NC_SHORT:
- shortvalp = (short *) rec_start;
- break;
- case NC_INT:
- intvalp = (int *) rec_start;
- break;
- case NC_FLOAT:
- floatvalp = (float *) rec_start;
- break;
- case NC_DOUBLE:
- doublevalp = (double *) rec_start;
- break;
- }
- if (vars[varnum].ndims > 0) {
- /* initialize start to upper left corner (0,0,0,...) */
- start[0] = 0;
- if (vars[varnum].dims[0] == rec_dim) {
- count[0] = vars[varnum].nrecs;
- }
- else {
- count[0] = dims[vars[varnum].dims[0]].size;
- }
- }
-
- for (idim = 1; idim < vars[varnum].ndims; idim++) {
- start[idim] = 0;
- count[idim] = dims[vars[varnum].dims[idim]].size;
- }
-
- switch (vars[varnum].type) {
- case NC_BYTE:
- stat = nc_put_vara_schar(ncid, varnum, start, count,
- (signed char *)charvalp);
- break;
- case NC_CHAR:
- stat = nc_put_vara_text(ncid, varnum, start, count, charvalp);
- break;
- case NC_SHORT:
- stat = nc_put_vara_short(ncid, varnum, start, count, shortvalp);
- break;
- case NC_INT:
- stat = nc_put_vara_int(ncid, varnum, start, count, intvalp);
- break;
- case NC_FLOAT:
- stat = nc_put_vara_float(ncid, varnum, start, count, floatvalp);
- break;
- case NC_DOUBLE:
- stat = nc_put_vara_double(ncid, varnum, start, count, doublevalp);
- break;
- }
- check_err(stat);
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/main.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/main.c
deleted file mode 100644
index fc7683c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/main.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/main.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h> /* has getopt() under VMS */
-#include <string.h>
-
-#ifdef __hpux
-#include <locale.h>
-#endif
-
-#include <netcdf.h>
-
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h"
-
-extern int yyparse(void);
-
-const char *progname; /* for error messages */
-const char *cdlname;
-
-int c_flag;
-int fortran_flag;
-int netcdf_flag;
-char *netcdf_name = NULL; /* name of output netCDF file to write */
-
-extern FILE *yyin;
-
-static const char* ubasename ( const char* av0 );
-static void usage ( void );
-int main ( int argc, char** argv );
-
-
-/* strip off leading path */
-static const char *
-ubasename(
- const char *av0)
-{
- const char *logident ;
-#ifdef VMS
-#define SEP ']'
-#endif
-#ifdef MSDOS
-#define SEP '\\'
-#endif
-#ifndef SEP
-#define SEP '/'
-#endif
- if ((logident = strrchr(av0, SEP)) == NULL)
- logident = av0 ;
- else
- logident++ ;
- return logident ;
-}
-
-
-static void usage(void)
-{
- derror("Usage: %s [ -b ] [ -c ] [ -f ] [ -o outfile] [ file ... ]",
- progname);
- derror("netcdf library version %s", nc_inq_libvers());
-}
-
-
-int
-main(
- int argc,
- char *argv[])
-{
- extern int optind;
- extern int opterr;
- extern char *optarg;
- int c;
- FILE *fp;
-
-#ifdef __hpux
- setlocale(LC_CTYPE,"");
-#endif
-
-#ifdef MDEBUG
- malloc_debug(2) ; /* helps find malloc/free errors on Sun */
-#endif /* MDEBUG */
-
- opterr = 1; /* print error message if bad option */
- progname = ubasename(argv[0]);
- cdlname = "-";
-
- c_flag = 0;
- fortran_flag = 0;
- netcdf_flag = 0;
-
-#if _CRAYMPP && 0
- /* initialize CRAY MPP parallel-I/O library */
- (void) par_io_init(32, 32);
-#endif
-
- while ((c = getopt(argc, argv, "bcfno:")) != EOF)
- switch(c) {
- case 'c': /* for c output */
- c_flag = 1;
- break;
- case 'f': /* for fortran output */
- fortran_flag = 1;
- break;
- case 'b': /* for binary netcdf output, ".nc" extension */
- netcdf_flag = 1;
- break;
- case 'n': /* old version of -b, uses ".cdf" extension */
- netcdf_flag = -1;
- break;
- case 'o': /* to explicitly specify output name */
- netcdf_flag = 1;
- netcdf_name = (char *) emalloc(strlen(optarg)+1);
- if (! netcdf_name) {
- derror ("%s: out of memory", progname);
- return(1);
- }
- (void)strcpy(netcdf_name,optarg);
- break;
- case '?':
- usage();
- return(8);
- }
-
- if (fortran_flag && c_flag) {
- derror("Only one of -c or -f may be specified");
- return(8);
- }
-
- argc -= optind;
- argv += optind;
-
- if (argc > 1) {
- derror ("%s: only one input file argument permitted",progname);
- return(6);
- }
-
- fp = stdin;
- if (argc > 0 && strcmp(argv[0], "-") != 0) {
- if ((fp = fopen(argv[0], "r")) == NULL) {
- derror ("can't open file %s for reading: ", argv[0]);
- perror("");
- return(7);
- }
- cdlname = argv[0];
- }
- yyin = fp;
- return (yyparse());
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.1 b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.1
deleted file mode 100644
index 6bc306c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.1
+++ /dev/null
@@ -1,361 +0,0 @@
-.\" $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.1,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
-.TH NCGEN 1 "$Date: 2005/06/14 04:38:30 $" "Printed: \n(yr-\n(mo-\n(dy" "UNIDATA UTILITIES"
-.SH NAME
-ncgen \- From a CDL file generate a netCDF file, a C program, or a Fortran
-program
-.SH SYNOPSIS
-.HP
-ncgen
-.nh
-\%[-b]
-\%[-c]
-\%[-f]
-\%[-n]
-\%[-o \fInetcdf_filename\fP]
-\%\fIinput_file\fP
-.hy
-.ft
-.SH DESCRIPTION
-\fBncgen\fP generates either a netCDF file, or C or Fortran source code to
-create a netCDF file. The input to \fBncgen\fP is a description of a netCDF
-file in a small language known as CDL (network Common Data form Language),
-described below.
-If no options are specified in invoking \fBncgen\fP, it merely checks the
-syntax of the input CDL file, producing error messages for
-any violations of CDL syntax. Other options can be used to create the
-corresponding netCDF file, to generate a C program that uses the netCDF C
-interface to create the netCDF file, or to generate a Fortran program that
-uses the netCDF Fortran interface to create the same netCDF file.
-.LP
-\fBncgen\fP may be used with the companion program \fBncdump\fP to perform
-some simple operations on netCDF files. For example, to rename a dimension
-in a netCDF file, use \fBncdump\fP to get a CDL version of the netCDF file,
-edit the CDL file to change the name of the dimensions, and use \fBncgen\fP
-to generate the corresponding netCDF file from the edited CDL file.
-.SH OPTIONS
-.IP "\fB-b\fP"
-Create a (binary) netCDF file. If the \fB-o\fP option is absent, a default
-file name will be constructed from the netCDF name (specified after the
-\fBnetcdf\fP keyword in the input) by appending the `.nc' extension. If a
-file already exists with the specified name, it will be overwritten.
-.IP "\fB-c\fP"
-Generate
-.B C
-source code that will create a netCDF file
-matching the netCDF specification. The C source code is written to
-standard output.
-.IP "\fB-f\fP"
-Generate
-.B Fortran
-source code that will create a netCDF file
-matching the netCDF specification. The Fortran source code is written
-to standard output.
-.IP "\fB-o\fP \fRnetcdf_file\fP"
-Name for the binary netCDF file created. If this option is specified, it implies
-the "\fB-b\fP" option. (This option is necessary because netCDF files
-cannot be written directly to standard output, since standard output is not
-seekable.)
-.IP "\fB-n\fP"
-Like \fB-b\fP option, except creates netCDF file with the obsolete `.cdf'
-extension instead of the `.nc' extension, in the absence of an output
-filename specified by the \fB-o\fP option. This option is only supported
-for backward compatibility.
-.SH EXAMPLES
-.LP
-Check the syntax of the CDL file `\fBfoo.cdl\fP':
-.RS
-.HP
-ncgen foo.cdl
-.RE
-.LP
-From the CDL file `\fBfoo.cdl\fP', generate an equivalent binary netCDF file
-named `\fBx.nc\fP':
-.RS
-.HP
-ncgen -o x.nc foo.cdl
-.RE
-.LP
-From the CDL file `\fBfoo.cdl\fP', generate a C program containing the
-netCDF function invocations necessary to create an equivalent binary netCDF
-file named `\fBx.nc\fP':
-.RS
-.HP
-ncgen -c -o x.nc foo.cdl
-.RE
-.LP
-.SH USAGE
-.SS "CDL Syntax Summary"
-.LP
-Below is an example of CDL syntax, describing a netCDF file with several
-named dimensions (lat, lon, and time), variables (Z, t, p, rh, lat, lon,
-time), variable attributes (units, long_name, valid_range, _FillValue), and
-some data. CDL keywords are in boldface. (This example is intended to
-illustrate the syntax; a real CDL file would have a more complete set of
-attributes so that the data would be more completely self-describing.)
-
-.RS
-.nf
-\fBnetcdf\fP foo { // an example netCDF specification in CDL
-
-\fBdimensions\fP:
- lat = 10, lon = 5, time = \fBunlimited\fP ;
-
-\fBvariables\fP:
- \fBlong\fP lat(lat), lon(lon), time(time);
- \fBfloat\fP Z(time,lat,lon), t(time,lat,lon);
- \fBdouble\fP p(time,lat,lon);
- \fBlong\fP rh(time,lat,lon);
-
- // variable attributes
- lat:long_name = "latitude";
- lat:units = "degrees_north";
- lon:long_name = "longitude";
- lon:units = "degrees_east";
- time:units = "seconds since 1992-1-1 00:00:00";
- Z:units = "geopotential meters";
- Z:valid_range = 0., 5000.;
- p:_FillValue = -9999.;
- rh:_FillValue = -1;
-
-\fBdata\fP:
- lat = 0, 10, 20, 30, 40, 50, 60, 70, 80, 90;
- lon = -140, -118, -96, -84, -52;
-}
-.fi
-.RE
-.LP
-All CDL statements are terminated by a semicolon. Spaces, tabs,
-and newlines can be used freely for readability.
-Comments may follow the characters `//' on any line.
-.LP
-A CDL description consists of three optional parts: \fIdimensions\fP,
-\fIvariables\fP, and \fIdata\fP, beginning with the keyword
-.BR dimensions: ,
-.BR variables: ,
-and
-.BR data ,
-respectively.
-The variable part may contain \fIvariable
-declarations\fP and \fIattribute assignments\fP.
-.LP
-A netCDF \fIdimension\fP is used to define the shape of one or more of the
-multidimensional variables contained in the netCDF file. A netCDF
-dimension has a name and a size. At most one dimension in a netCDF file
-can have the \fBunlimited\fP size, which means a variable using this
-dimension can grow to any length (like a record number in a file).
-.LP
-A \fIvariable\fP represents a multidimensional array of values of the
-same type. A variable has a name, a data type, and a shape described
-by its list of dimensions. Each variable may also have associated
-\fIattributes\fP (see below) as well as data values. The name, data
-type, and shape of a variable are specified by its declaration in the
-\fIvariable\fP section of a CDL description. A variable may have the same
-name as a dimension; by convention such a variable is one-dimensional
-and contains coordinates of the dimension it names. Dimensions need
-not have corresponding variables.
-.LP
-A netCDF \fIattribute\fP contains information about a netCDF variable or
-about the whole netCDF dataset. Attributes are used
-to specify such properties as units, special values, maximum and
-minimum valid values, scaling factors, offsets, and parameters. Attribute
-information is represented by single values or arrays of values. For
-example, "units" is an attribute represented by a character array such
-as "celsius". An attribute has an associated variable, a name,
-a data type, a length, and a value. In contrast to variables that are
-intended for data, attributes are intended for metadata (data about
-data).
-.LP
-In CDL, an attribute is designated by a variable and attribute name,
-separated by `:'. It is possible to assign \fIglobal\fP attributes
-not associated with any variable to the netCDF as a whole by using
-`:' before the attribute name. The data type of an attribute in CDL
-is derived from the type of the value assigned to it. The length of
-an attribute is the number of data values assigned to it, or the
-number of characters in the character string assigned to it. Multiple
-values are assigned to non-character attributes by separating the
-values with commas. All values assigned to an attribute must be of
-the same type.
-.LP
-The names for CDL dimensions, variables, and attributes must begin with an
-alphabetic character or `_', and subsequent characters may be alphanumeric
-or `_' or `-'.
-.LP
-The optional \fIdata\fP section of a CDL specification is where
-netCDF variables may be initialized. The syntax of an initialization
-is simple: a variable name, an equals sign, and a
-comma-delimited list of constants (possibly separated by spaces, tabs
-and newlines) terminated with a semicolon. For multi-dimensional
-arrays, the last dimension varies fastest. Thus row-order rather than
-column order is used for matrices. If fewer values are supplied than
-are needed to fill a variable, it is extended with a type-dependent
-`fill value', which can be overridden by supplying a value for a
-distinguished variable attribute named `_FillValue'. The
-types of constants need not match the type declared for a variable;
-coercions are done to convert integers to floating point, for example.
-The constant `_' can be used to designate the fill value for a variable.
-.SS "Primitive Data Types"
-.LP
-.RS
-.nf
-\fBchar\fP characters
-\fBbyte\fP 8-bit data
-\fBshort\fP 16-bit signed integers
-\fBlong\fP 32-bit signed integers
-\fBint\fP (synonymous with \fBlong\fP)
-\fBfloat\fP IEEE single precision floating point (32 bits)
-\fBreal\fP (synonymous with \fBfloat\fP)
-\fBdouble\fP IEEE double precision floating point (64 bits)
-.fi
-.RE
-.LP
-Except for the added data-type \fBbyte\fP and the lack of
-\fBunsigned\fP,
-CDL supports the same primitive data types as C.
-The names for the primitive data types are reserved words in CDL,
-so the names of variables, dimensions, and attributes must not be
-type names. In declarations, type names may be specified
-in either upper or lower case.
-.LP
-Bytes differ from characters in that they are intended to hold a full eight
-bits of data, and the zero byte has no special significance, as it
-does for character data.
-\fBncgen\fP converts \fBbyte\fP declarations to \fBchar\fP
-declarations in the output C code and to the nonstandard \fBBYTE\fP
-declaration in output Fortran code.
-.LP
-Shorts can hold values between -32768 and 32767.
-\fBncgen\fP converts \fBshort\fP declarations to \fBshort\fP
-declarations in the output C code and to the nonstandard \fBINTEGER*2\fP
-declaration in output Fortran code.
-.LP
-Longs can hold values between -2147483648 and 2147483647.
-\fBncgen\fP converts \fBlong\fP declarations to \fBlong\fP
-declarations in the output C code and to \fBINTEGER\fP
-declarations in output Fortran code. \fBint\fP and \fBinteger\fP are
-accepted as synonyms for \fBlong\fP in CDL declarations.
-Now that there are platforms with 64-bit representations for C longs, it may
-be better to use the \fBint\fP synonym to avoid confusion.
-.LP
-Floats can hold values between about -3.4+38 and 3.4+38. Their
-external representation is as 32-bit IEEE normalized single-precision
-floating point numbers. \fBncgen\fP converts \fBfloat\fP
-declarations to \fBfloat\fP declarations in the output C code and to
-\fBREAL\fP declarations in output Fortran code. \fBreal\fP is accepted
-as a synonym for \fBfloat\fP in CDL declarations.
-.LP
-Doubles can hold values between about -1.7+308 and 1.7+308. Their
-external representation is as 64-bit IEEE standard normalized
-double-precision floating point numbers. \fBncgen\fP converts
-\fBdouble\fP declarations to \fBdouble\fP declarations in the output C
-code and to \fBDOUBLE PRECISION\fP declarations in output Fortran
-code.
-.LP
-.SS "CDL Constants"
-.LP
-Constants assigned to attributes or variables may be of any of the
-basic netCDF types. The syntax for constants is similar to C syntax,
-except that type suffixes must be appended to shorts and floats to
-distinguish them from longs and doubles.
-.LP
-A \fIbyte\fP constant is represented by a single character or multiple
-character escape sequence enclosed in single quotes. For example,
-.RS
-.nf
- 'a' // ASCII `a'
- '\\0' // a zero byte
- '\\n' // ASCII newline character
- '\\33' // ASCII escape character (33 octal)
- '\\x2b' // ASCII plus (2b hex)
- '\\377' // 377 octal = 255 decimal, non-ASCII
-.fi
-.RE
-.LP
-Character constants are enclosed in double quotes. A character array
-may be represented as a string enclosed in double quotes. The usual C
-string escape conventions are honored. For example
-.RS
-.nf
-"a" // ASCII `a'
-"Two\\nlines\\n" // a 10-character string with two embedded newlines
-"a bell:\\007" // a string containing an ASCII bell
-.fi
-.RE
-Note that the netCDF character array "a" would fit in a one-element
-variable, since no terminating NULL character is assumed. However, a zero
-byte in a character array is interpreted as the end of the significant
-characters by the \fBncdump\fP program, following the C convention.
-Therefore, a NULL byte should not be embedded in a character string unless
-at the end: use the \fIbyte\fP data type instead for byte arrays that
-contain the zero byte. NetCDF and CDL have no string type, but only
-fixed-length character arrays, which may be multi-dimensional.
-.LP
-\fIshort\fP integer constants are intended for representing 16-bit
-signed quantities. The form of a \fIshort\fP constant is an integer
-constant with an `s' or `S' appended. If a \fIshort\fP constant
-begins with `0', it is interpreted as octal, except that if it begins with
-`0x', it is interpreted as a hexadecimal constant. For example:
-.RS
-.nf
--2s // a short -2
-0123s // octal
-0x7ffs //hexadecimal
-.fi
-.RE
-.LP
-\fILong\fP integer constants are intended for representing 32-bit signed
-quantities. The form of a \fIlong\fP constant is an ordinary integer
-constant, although it is acceptable to append an optional `l' or
-`L'. If a \fIlong\fP constant begins with `0', it is interpreted as
-octal, except that if it begins with `0x', it is interpreted as a hexadecimal
-constant. Examples of valid \fIlong\fP constants include:
-.RS
-.nf
--2
-1234567890L
-0123 // octal
-0x7ff // hexadecimal
-.fi
-.RE
-.LP
-Floating point constants of type \fIfloat\fP are appropriate for representing
-floating point data with about seven significant digits of precision.
-The form of a \fIfloat\fP constant is the same as a C floating point
-constant with an `f' or `F' appended. For example the following
-are all acceptable \fIfloat\fP constants:
-.RS
-.nf
--2.0f
-3.14159265358979f // will be truncated to less precision
-1.f
-.1f
-.fi
-.RE
-.LP
-Floating point constants of type \fIdouble\fP are appropriate for
-representing floating point data with about sixteen significant digits
-of precision. The form of a \fIdouble\fP constant is the same as a C
-floating point constant. An optional `d' or `D' may be appended.
-For example the following are all acceptable \fIdouble\fP constants:
-.RS
-.nf
--2.0
-3.141592653589793
-1.0e-20
-1.d
-.fi
-.RE
-
-.SH BUGS
-.LP
-The programs generated by \fBncgen\fP when using the \fB-c\fP or \fB-f\fP
-use initialization statements to store data in variables, and will fail to
-produce compilable programs if you try to use them for large datasets, since
-the resulting statements may exceed the line length or number of
-continuation statements permitted by the compiler.
-.LP
-The CDL syntax makes it easy to assign what looks like an array of
-variable-length strings to a netCDF variable, but the strings will simply be
-concatenated into a single array of characters, since netCDF cannot
-represent an array of variable-length strings in one netCDF variable.
-.LP
-NetCDF and CDL do not yet support a type corresponding to a 64-bit integer.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.h
deleted file mode 100644
index 3982da1..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef NC_NCGEN_H
-#define NC_NCGEN_H
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.h,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-#define MAX_NC_ATTSIZE 20000 /* max size of attribute (for ncgen) */
-#define MAXTRST 5000 /* max size of string value (for ncgen) */
-
-#include "generic.h"
-
-extern int ncid; /* handle for netCDF */
-extern int ndims; /* number of dimensions declared for netcdf */
-extern int nvars; /* number of variables declared for netcdf */
-extern int natts; /* number of attributes */
-extern int nvdims; /* number of dimensions for variables */
-extern int dimnum; /* dimension number index for variables */
-extern int varnum; /* variable number index for attributes */
-extern int valnum; /* number of values specified for variable */
-extern int rec_dim; /* number of the unlimited dimension, if any */
-extern size_t rec_len; /* number of elements for a record of data */
-extern size_t var_len; /* variable length (product of dimensions) */
-extern size_t var_size; /* size of each element of variable */
-
-extern struct dims {
- size_t size;
- char *name;
- char *lname; /* with no "-" characters, for C and Fortran */
-} *dims; /* table of dimensions */
-
-extern struct vars {
- char *name;
- nc_type type;
- int ndims;
- int *dims; /* array of dimension ids */
- union generic fill_value; /* set to value of _FillValue attribute */
- int has_data; /* 1 if data specified, 0 otherwise */
- size_t nrecs; /* for record variables, number of records
- * of data in CDL */
- char *data_stmnt; /* for record variables, to avoid
- * two passes with -f option */
- char *lname; /* with no "-" characters, for C and Fortran */
-} *vars; /* table of variables */
-
-
-extern struct atts {
- int var; /* number of variable for this attribute */
- char *name;
- nc_type type;
- size_t len;
- void *val;
- char *lname; /* with no "-" characters, for C and Fortran */
-} *atts; /* table of variable and global attributes */
-#endif /*!NC_NCGEN_H*/
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.l b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.l
deleted file mode 100644
index 77a0404..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.l
+++ /dev/null
@@ -1,208 +0,0 @@
-%{
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: ncgen.l,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-/* lex specification for tokens for ncgen */
-
-/* Fill value used by ncdump from version 2.4 and later. Should match
- definition of FILL_STRING in ../ncdump/vardata.h */
-#define FILL_STRING "_"
-#define XDR_INT_MIN (-2147483647-1)
-#define XDR_INT_MAX 2147483647
-
-char errstr[100]; /* for short error messages */
-
-#include <string.h>
-#include <ctype.h>
-#include "genlib.h"
-#include "ncgentab.h"
-
-#define YY_BREAK /* defining as nothing eliminates unreachable
- statement warnings from flex output,
- but make sure every action ends with
- "return" or "break"! */
-
-%}
-
-%p 6000
-
-escaped \\.
-nonquotes ([^"\\]|{escaped})*
-exp ([eE][+-]?[0-9]+)
-%%
-\/\/.* { /* comment */
- break;
- }
-
-\"{nonquotes}\" {
- if(yyleng > MAXTRST) {
- yyerror("string too long, truncated\n");
- yytext[MAXTRST-1] = '\0';
- }
- expand_escapes(termstring,(char *)yytext,yyleng);
- return (TERMSTRING);
- }
-
-float|FLOAT|real|REAL {return (FLOAT_K);}
-char|CHAR {return (CHAR_K);}
-byte|BYTE {return (BYTE_K);}
-short|SHORT {return (SHORT_K);}
-long|LONG|int|INT|integer|INTEGER {return (INT_K);}
-double|DOUBLE {return (DOUBLE_K);}
-unlimited|UNLIMITED {int_val = -1;
- return (NC_UNLIMITED_K);}
-
-dimensions:|DIMENSIONS: {return (DIMENSIONS);}
-variables:|VARIABLES: {return (VARIABLES);}
-data:|DATA: {return (DATA);}
-(netcdf|NETCDF|netCDF)[ \t]+[^\{]+ {
- char *s = (char*)yytext+strlen("netcdf");
- char *t = (char*)yytext+yyleng-1;
- while (isspace(*s))
- s++;
- while (isspace(*t))
- t--;
- t++;
- if (t-s+1 < 1) {
- yyerror("netCDF name required");
- return (DATA); /* generate syntax error */
- }
- netcdfname = (char *) emalloc(t-s+1);
- (void) strncpy(netcdfname, s, t-s);
- netcdfname[t-s] = '\0';
- return (NETCDF);
- }
-DoubleInf|NaN|-?Infinity { /* missing value (pre-2.4 backward compatibility) */
- if (yytext[0] == '-') {
- double_val = -FILL_DOUBLE;
- } else {
- double_val = FILL_DOUBLE;
- }
- return (DOUBLE_CONST);
- }
-FloatInf|-?Inff { /* missing value (pre-2.4 backward compatibility) */
- if (yytext[0] == '-') {
- float_val = -FILL_FLOAT;
- } else {
- float_val = FILL_FLOAT;
- }
- return (FLOAT_CONST);
- }
-[A-Za-z_][A-Z.a-z_0-9-]* {
- if (STREQ((char *)yytext, FILL_STRING))
- return (FILLVALUE);
- if ((yylval = lookup((char *)yytext)) == NULL) {
- yylval = install((char *)yytext);
- }
- return (IDENT);
- }
-
-\n {
- lineno++ ;
- break;
- }
-
-[+-]?[0-9]*[0-9][Bb] {
- int ii;
- if (sscanf((char*)yytext, "%d", &ii) != 1) {
- sprintf(errstr,"bad byte constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- byte_val = ii;
- if (ii != (int)byte_val) {
- sprintf(errstr,"byte constant out of range (-128,127): %s",(char*)yytext);
- yyerror(errstr);
- }
- return (BYTE_CONST);
- }
-
-[+-]?[0-9]*\.[0-9]*{exp}?[LlDd]?|[+-]?[0-9]*{exp}[LlDd]? {
- if (sscanf((char*)yytext, "%le", &double_val) != 1) {
- sprintf(errstr,"bad long or double constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- return (DOUBLE_CONST);
- }
-[+-]?[0-9]*\.[0-9]*{exp}?[Ff]|[+-]?[0-9]*{exp}[Ff] {
- if (sscanf((char*)yytext, "%e", &float_val) != 1) {
- sprintf(errstr,"bad float constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- return (FLOAT_CONST);
- }
-[+-]?[0-9]+[sS]|0[xX][0-9a-fA-F]+[sS] {
- if (sscanf((char*)yytext, "%hd", &short_val) != 1) {
- sprintf(errstr,"bad short constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- return (SHORT_CONST);
- }
-[+-]?([1-9][0-9]*|0)[lL]? {
- char *ptr;
- errno = 0;
- double_val = strtod((char*)yytext, &ptr);
- if (errno != 0 && double_val == 0.0) {
- sprintf(errstr,"bad numerical constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- if (double_val < XDR_INT_MIN ||double_val > XDR_INT_MAX) {
- return DOUBLE_CONST;
- } else {
- int_val = (int) double_val;
- return INT_CONST;
- }
- }
-0[xX]?[0-9a-fA-F]+[lL]? {
- char *ptr;
- long long_val;
- errno = 0;
- long_val = strtol((char*)yytext, &ptr, 0);
- if (errno != 0) {
- sprintf(errstr,"bad long constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- if (long_val < XDR_INT_MIN || long_val > XDR_INT_MAX) {
- double_val = (double) long_val;
- return DOUBLE_CONST;
- } else {
- int_val = (int) long_val;
- return INT_CONST;
- }
- }
-\'[^\\]\' {
- (void) sscanf((char*)&yytext[1],"%c",&byte_val);
- return (BYTE_CONST);
- }
-\'\\[0-7][0-7]?[0-7]?\' {
- byte_val = (char) strtol((char*)&yytext[2], (char **) 0, 8);
- return (BYTE_CONST);
- }
-\'\\[xX][0-9a-fA-F][0-9a-fA-F]?\' {
- byte_val = (char) strtol((char*)&yytext[3], (char **) 0, 16);
- return (BYTE_CONST);
- }
-\'\\.\' {
- switch ((char)yytext[2]) {
- case 'a': byte_val = '\007'; break; /* not everyone under-
- * stands '\a' yet */
- case 'b': byte_val = '\b'; break;
- case 'f': byte_val = '\f'; break;
- case 'n': byte_val = '\n'; break;
- case 'r': byte_val = '\r'; break;
- case 't': byte_val = '\t'; break;
- case 'v': byte_val = '\v'; break;
- case '\\': byte_val = '\\'; break;
- case '?': byte_val = '\177'; break;
- case '\'': byte_val = '\''; break;
- default: byte_val = (char)yytext[2];
- }
- return (BYTE_CONST);
- }
-
-[ \t\f]+ { /* whitespace */
- break;
- }
-. return (yytext[0]) ;
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.y b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.y
deleted file mode 100644
index 8bd29e8..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgen.y
+++ /dev/null
@@ -1,825 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: ncgen.y,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-/* yacc source for "ncgen", a netCDL parser and netCDF generator */
-
-%{
-#ifndef lint
-static char SccsId[] = "$Id: ncgen.y,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $";
-#endif
-#include <string.h>
-#include <stdlib.h>
-#include <netcdf.h>
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h" /* for grow_darray() et al */
-
-typedef struct Symbol { /* symbol table entry */
- char *name;
- struct Symbol *next;
- unsigned is_dim : 1; /* appears as netCDF dimension */
- unsigned is_var : 1; /* appears as netCDF variable */
- unsigned is_att : 1; /* appears as netCDF attribute */
- int dnum; /* handle as a dimension */
- int vnum; /* handle as a variable */
- } *YYSTYPE1;
-
-/* True if string a equals string b*/
-#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-#define NC_UNSPECIFIED ((nc_type)0) /* unspecified (as yet) type */
-
-#define YYSTYPE YYSTYPE1
-YYSTYPE symlist; /* symbol table: linked list */
-
-extern int derror_count; /* counts errors in netcdf definition */
-extern int lineno; /* line number for error messages */
-
-static int not_a_string; /* whether last constant read was a string */
-static char termstring[MAXTRST]; /* last terminal string read */
-static double double_val; /* last double value read */
-static float float_val; /* last float value read */
-static int int_val; /* last int value read */
-static short short_val; /* last short value read */
-static char char_val; /* last char value read */
-static signed char byte_val; /* last byte value read */
-
-static nc_type type_code; /* holds declared type for variables */
-static nc_type atype_code; /* holds derived type for attributes */
-static char *netcdfname; /* to construct netcdf file name */
-static void *att_space; /* pointer to block for attribute values */
-static nc_type valtype; /* type code for list of attribute values */
-
-static char *char_valp; /* pointers used to accumulate data values */
-static signed char *byte_valp;
-static short *short_valp;
-static int *int_valp;
-static float *float_valp;
-static double *double_valp;
-static void *rec_cur; /* pointer to where next data value goes */
-static void *rec_start; /* start of space for data */
-%}
-
-/* DECLARATIONS */
-
-%token
- NC_UNLIMITED_K /* keyword for unbounded record dimension */
- BYTE_K /* keyword for byte datatype */
- CHAR_K /* keyword for char datatype */
- SHORT_K /* keyword for short datatype */
- INT_K /* keyword for int datatype */
- FLOAT_K /* keyword for float datatype */
- DOUBLE_K /* keyword for double datatype */
- IDENT /* name for a dimension, variable, or attribute */
- TERMSTRING /* terminal string */
- BYTE_CONST /* byte constant */
- CHAR_CONST /* char constant */
- SHORT_CONST /* short constant */
- INT_CONST /* int constant */
- FLOAT_CONST /* float constant */
- DOUBLE_CONST /* double constant */
- DIMENSIONS /* keyword starting dimensions section, if any */
- VARIABLES /* keyword starting variables section, if any */
- NETCDF /* keyword declaring netcdf name */
- DATA /* keyword starting data section, if any */
- FILLVALUE /* fill value, from _FillValue attribute or default */
-
-%start ncdesc /* start symbol for grammar */
-
-%%
-
-/* RULES */
-
-ncdesc: NETCDF
- '{'
- { init_netcdf(); }
- dimsection /* dimension declarations */
- vasection /* variable and attribute declarations */
- {
- if (derror_count == 0)
- define_netcdf(netcdfname);
- }
- datasection /* data, variables loaded as encountered */
- '}'
- {
- if (derror_count == 0)
- close_netcdf();
- }
- ;
-dimsection: /* empty */
- | DIMENSIONS dimdecls
- ;
-dimdecls: dimdecline ';'
- | dimdecls dimdecline ';'
- ;
-dimdecline: dimdecl
- | dimdecline ',' dimdecl
- ;
-dimdecl: dimd '=' INT_CONST
- { if (int_val <= 0)
- derror("dimension length must be positive");
- dims[ndims].size = int_val;
- ndims++;
- }
- | dimd '=' NC_UNLIMITED_K
- { if (rec_dim != -1)
- derror("only one NC_UNLIMITED dimension allowed");
- rec_dim = ndims; /* the unlimited (record) dimension */
- dims[ndims].size = NC_UNLIMITED;
- ndims++;
- }
- ;
-dimd: dim
- { if ($1->is_dim == 1) {
- derror( "duplicate dimension declaration for %s",
- $1->name);
- }
- $1->is_dim = 1;
- $1->dnum = ndims;
- /* make sure dims array will hold dimensions */
- grow_darray(ndims, /* must hold ndims+1 dims */
- &dims); /* grow as needed */
- dims[ndims].name = (char *) emalloc(strlen($1->name)+1);
- (void) strcpy(dims[ndims].name, $1->name);
- /* name for use in generated Fortran and C variables */
- dims[ndims].lname = decodify($1->name);
- }
- ;
-dim: IDENT
- ;
-vasection: /* empty */
- | VARIABLES vadecls
- | gattdecls
- ;
-vadecls: vadecl ';'
- | vadecls vadecl ';'
- ;
-vadecl: vardecl | attdecl
- ;
-gattdecls: gattdecl ';'
- | gattdecls gattdecl ';'
- ;
-gattdecl: attdecl /* causes a shift/reduce conflict */
- ;
-vardecl: type varlist
- ;
-type: BYTE_K { type_code = NC_BYTE; }
- | CHAR_K { type_code = NC_CHAR; }
- | SHORT_K { type_code = NC_SHORT; }
- | INT_K { type_code = NC_INT; }
- | FLOAT_K { type_code = NC_FLOAT; }
- | DOUBLE_K{ type_code = NC_DOUBLE; }
- ;
-varlist: varspec
- | varlist ',' varspec
- ;
-varspec: var
- {
- static struct vars dummyvar;
-
- dummyvar.name = "dummy";
- dummyvar.type = NC_DOUBLE;
- dummyvar.ndims = 0;
- dummyvar.dims = 0;
- dummyvar.fill_value.doublev = NC_FILL_DOUBLE;
- dummyvar.has_data = 0;
-
- nvdims = 0;
- /* make sure variable not re-declared */
- if ($1->is_var == 1) {
- derror( "duplicate variable declaration for %s",
- $1->name);
- }
- $1->is_var = 1;
- $1->vnum = nvars;
- /* make sure vars array will hold variables */
- grow_varray(nvars, /* must hold nvars+1 vars */
- &vars); /* grow as needed */
- vars[nvars] = dummyvar; /* to make Purify happy */
- vars[nvars].name = (char *) emalloc(strlen($1->name)+1);
- (void) strcpy(vars[nvars].name, $1->name);
- /* name for use in generated Fortran and C variables */
- vars[nvars].lname = decodify($1->name);
- vars[nvars].type = type_code;
- /* set default fill value. You can override this with
- * the variable attribute "_FillValue". */
- nc_getfill(type_code, &vars[nvars].fill_value);
- vars[nvars].has_data = 0; /* has no data (yet) */
- }
- dimspec
- {
- vars[nvars].ndims = nvdims;
- nvars++;
- }
- ;
-var: IDENT
- ;
-dimspec: /* empty */
- | '(' dimlist ')'
- ;
-dimlist: vdim
- | dimlist ',' vdim
- ;
-vdim: dim
- {
- if (nvdims >= NC_MAX_VAR_DIMS) {
- derror("%s has too many dimensions",vars[nvars].name);
- }
- if ($1->is_dim == 1)
- dimnum = $1->dnum;
- else {
- derror( "%s is not declared as a dimension",
- $1->name);
- dimnum = ndims;
- }
- if (rec_dim != -1 && dimnum == rec_dim && nvdims != 0) {
- derror("unlimited dimension must be first");
- }
- grow_iarray(nvdims, /* must hold nvdims+1 ints */
- &vars[nvars].dims); /* grow as needed */
- vars[nvars].dims[nvdims] = dimnum;
- nvdims++;
- }
- ;
-attdecl: att
- {
- valnum = 0;
- valtype = NC_UNSPECIFIED;
- /* get a large block for attributes, realloc later */
- att_space = emalloc(MAX_NC_ATTSIZE);
- /* make all kinds of pointers point to it */
- char_valp = (char *) att_space;
- byte_valp = (signed char *) att_space;
- short_valp = (short *) att_space;
- int_valp = (int *) att_space;
- float_valp = (float *) att_space;
- double_valp = (double *) att_space;
- }
- '=' attvallist
- {
- { /* check if duplicate attribute for this var */
- int i;
- for(i=0; i<natts; i++) { /* expensive */
- if(atts[i].var == varnum &&
- STREQ(atts[i].name,atts[natts].name)) {
- derror("duplicate attribute %s:%s",
- vars[varnum].name,atts[natts].name);
- }
- }
- }
- atts[natts].var = varnum ;
- atts[natts].type = valtype;
- atts[natts].len = valnum;
- /* shrink space down to what was really needed */
- att_space = erealloc(att_space, valnum*nctypesize(valtype));
- atts[natts].val = att_space;
- if (STREQ(atts[natts].name, _FillValue) &&
- atts[natts].var != NC_GLOBAL) {
- nc_putfill(atts[natts].type,
- atts[natts].val,
- &vars[atts[natts].var].fill_value);
- if(atts[natts].type != vars[atts[natts].var].type) {
- derror("variable %s: %s type mismatch",
- vars[atts[natts].var].name, _FillValue);
- }
- }
- natts++;
- }
- ;
-att: avar ':' attr
- | ':' attr
- {
- varnum = NC_GLOBAL; /* handle of "global" attribute */
- }
- ;
-
-avar: var
- { if ($1->is_var == 1)
- varnum = $1->vnum;
- else {
- derror("%s not declared as a variable, fatal error",
- $1->name);
- YYABORT;
- }
- }
- ;
-attr: IDENT
- {
- /* make sure atts array will hold attributes */
- grow_aarray(natts, /* must hold natts+1 atts */
- &atts); /* grow as needed */
- atts[natts].name = (char *) emalloc(strlen($1->name)+1);
- (void) strcpy(atts[natts].name,$1->name);
- /* name for use in generated Fortran and C variables */
- atts[natts].lname = decodify($1->name);
- }
- ;
-attvallist: aconst
- | attvallist ',' aconst
- ;
-aconst: attconst
- {
- if (valtype == NC_UNSPECIFIED)
- valtype = atype_code;
- if (valtype != atype_code)
- derror("values for attribute must be all of same type");
- }
- ;
-
-attconst: CHAR_CONST
- {
- atype_code = NC_CHAR;
- *char_valp++ = char_val;
- valnum++;
- }
- | TERMSTRING
- {
- atype_code = NC_CHAR;
- {
- /* don't null-terminate attribute strings */
- size_t len = strlen(termstring);
- if (len == 0) /* need null if that's only value */
- len = 1;
- (void)strncpy(char_valp,termstring,len);
- valnum += len;
- char_valp += len;
- }
- }
- | BYTE_CONST
- {
- atype_code = NC_BYTE;
- *byte_valp++ = byte_val;
- valnum++;
- }
- | SHORT_CONST
- {
- atype_code = NC_SHORT;
- *short_valp++ = short_val;
- valnum++;
- }
- | INT_CONST
- {
- atype_code = NC_INT;
- *int_valp++ = int_val;
- valnum++;
- }
- | FLOAT_CONST
- {
- atype_code = NC_FLOAT;
- *float_valp++ = float_val;
- valnum++;
- }
- | DOUBLE_CONST
- {
- atype_code = NC_DOUBLE;
- *double_valp++ = double_val;
- valnum++;
- }
- ;
-
-datasection: /* empty */
- | DATA datadecls
- ;
-
-datadecls: datadecl ';'
- | datadecls datadecl ';'
- ;
-datadecl: avar
- {
- valtype = vars[varnum].type; /* variable type */
- valnum = 0; /* values accumulated for variable */
- vars[varnum].has_data = 1;
- /* compute dimensions product */
- var_size = nctypesize(valtype);
- if (vars[varnum].ndims == 0) { /* scalar */
- var_len = 1;
- } else if (vars[varnum].dims[0] == rec_dim) {
- var_len = 1; /* one record for unlimited vars */
- } else {
- var_len = dims[vars[varnum].dims[0]].size;
- }
- for(dimnum = 1; dimnum < vars[varnum].ndims; dimnum++)
- var_len = var_len*dims[vars[varnum].dims[dimnum]].size;
- /* allocate memory for variable data */
- if (var_len*var_size != (size_t)(var_len*var_size)) {
- derror("variable %s too large for memory",
- vars[varnum].name);
- exit(9);
- }
- rec_len = var_len;
- rec_start = malloc ((size_t)(rec_len*var_size));
- if (rec_start == 0) {
- derror ("out of memory\n");
- exit(3);
- }
- rec_cur = rec_start;
- switch (valtype) {
- case NC_CHAR:
- char_valp = (char *) rec_start;
- break;
- case NC_BYTE:
- byte_valp = (signed char *) rec_start;
- break;
- case NC_SHORT:
- short_valp = (short *) rec_start;
- break;
- case NC_INT:
- int_valp = (int *) rec_start;
- break;
- case NC_FLOAT:
- float_valp = (float *) rec_start;
- break;
- case NC_DOUBLE:
- double_valp = (double *) rec_start;
- break;
- }
- }
- '=' constlist
- {
- if (valnum < var_len) { /* leftovers */
- nc_fill(valtype,
- var_len - valnum,
- rec_cur,
- vars[varnum].fill_value);
- }
- /* put out var_len values */
- vars[varnum].nrecs = valnum / rec_len;
- if (derror_count == 0)
- put_variable(rec_start);
- free ((char *) rec_start);
- }
- ;
-constlist: dconst
- | constlist ',' dconst
- ;
-dconst:
- {
- if(valnum >= var_len) {
- if (vars[varnum].dims[0] != rec_dim) { /* not recvar */
- derror("too many values for this variable, %d >= %d",
- valnum, var_len);
- exit (4);
- } else { /* a record variable, so grow data
- container and increment var_len by
- multiple of record size */
- ptrdiff_t rec_inc = (char *)rec_cur
- - (char *)rec_start;
- var_len += rec_len * (1 + valnum - var_len)/rec_len;
- rec_start = erealloc(rec_start, var_len*var_size);
- rec_cur = (char *)rec_start + rec_inc;
- char_valp = (char *) rec_cur;
- byte_valp = (signed char *) rec_cur;
- short_valp = (short *) rec_cur;
- int_valp = (int *) rec_cur;
- float_valp = (float *) rec_cur;
- double_valp = (double *) rec_cur;
- }
- }
- not_a_string = 1;
- }
- const
- {
- if (not_a_string) {
- switch (valtype) {
- case NC_CHAR:
- rec_cur = (void *) char_valp;
- break;
- case NC_BYTE:
- rec_cur = (void *) byte_valp;
- break;
- case NC_SHORT:
- rec_cur = (void *) short_valp;
- break;
- case NC_INT:
- rec_cur = (void *) int_valp;
- break;
- case NC_FLOAT:
- rec_cur = (void *) float_valp;
- break;
- case NC_DOUBLE:
- rec_cur = (void *) double_valp;
- break;
- }
- }
- }
-;
-
-const: CHAR_CONST
- {
- atype_code = NC_CHAR;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = char_val;
- break;
- case NC_BYTE:
- *byte_valp++ = char_val;
- break;
- case NC_SHORT:
- *short_valp++ = char_val;
- break;
- case NC_INT:
- *int_valp++ = char_val;
- break;
- case NC_FLOAT:
- *float_valp++ = char_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = char_val;
- break;
- }
- valnum++;
- }
- | TERMSTRING
- {
- not_a_string = 0;
- atype_code = NC_CHAR;
- {
- size_t len = strlen(termstring);
-
- if(valnum + len > var_len) {
- if (vars[varnum].dims[0] != rec_dim) {
- derror("too many values for this variable, %d>%d",
- valnum+len, var_len);
- exit (5);
- } else {/* a record variable so grow it */
- ptrdiff_t rec_inc = (char *)rec_cur
- - (char *)rec_start;
- var_len += rec_len * (len + valnum - var_len)/rec_len;
- rec_start = erealloc(rec_start, var_len*var_size);
- rec_cur = (char *)rec_start + rec_inc;
- char_valp = (char *) rec_cur;
- }
- }
- switch (valtype) {
- case NC_CHAR:
- {
- int ld;
- size_t i, sl;
- (void)strncpy(char_valp,termstring,len);
-
- ld = vars[varnum].ndims-1;
- if (ld > 0) {/* null-fill to size of last dim */
- sl = dims[vars[varnum].dims[ld]].size;
- for (i =len;i<sl;i++)
- char_valp[i] = '\0';
- if (sl < len)
- sl = len;
- valnum += sl;
- char_valp += sl;
- } else { /* scalar or 1D strings */
- valnum += len;
- char_valp += len;
- }
- rec_cur = (void *) char_valp;
- }
- break;
- case NC_BYTE:
- case NC_SHORT:
- case NC_INT:
- case NC_FLOAT:
- case NC_DOUBLE:
- derror("string value invalid for %s variable",
- nctype(valtype));
- break;
- }
- }
- }
- | BYTE_CONST
- {
- atype_code = NC_BYTE;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = byte_val;
- break;
- case NC_BYTE:
- *byte_valp++ = byte_val;
- break;
- case NC_SHORT:
- *short_valp++ = byte_val;
- break;
- case NC_INT:
- *int_valp++ = byte_val;
- break;
- case NC_FLOAT:
- *float_valp++ = byte_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = byte_val;
- break;
- }
- valnum++;
- }
- | SHORT_CONST
- {
- atype_code = NC_SHORT;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = short_val;
- break;
- case NC_BYTE:
- *byte_valp++ = short_val;
- break;
- case NC_SHORT:
- *short_valp++ = short_val;
- break;
- case NC_INT:
- *int_valp++ = short_val;
- break;
- case NC_FLOAT:
- *float_valp++ = short_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = short_val;
- break;
- }
- valnum++;
- }
- | INT_CONST
- {
- atype_code = NC_INT;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = int_val;
- break;
- case NC_BYTE:
- *byte_valp++ = int_val;
- break;
- case NC_SHORT:
- *short_valp++ = int_val;
- break;
- case NC_INT:
- *int_valp++ = int_val;
- break;
- case NC_FLOAT:
- *float_valp++ = int_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = int_val;
- break;
- }
- valnum++;
- }
- | FLOAT_CONST
- {
- atype_code = NC_FLOAT;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = float_val;
- break;
- case NC_BYTE:
- *byte_valp++ = float_val;
- break;
- case NC_SHORT:
- *short_valp++ = float_val;
- break;
- case NC_INT:
- *int_valp++ = float_val;
- break;
- case NC_FLOAT:
- *float_valp++ = float_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = float_val;
- break;
- }
- valnum++;
- }
- | DOUBLE_CONST
- {
- atype_code = NC_DOUBLE;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = double_val;
- break;
- case NC_BYTE:
- *byte_valp++ = double_val;
- break;
- case NC_SHORT:
- *short_valp++ = double_val;
- break;
- case NC_INT:
- *int_valp++ = double_val;
- break;
- case NC_FLOAT:
- if (double_val == NC_FILL_DOUBLE)
- *float_valp++ = NC_FILL_FLOAT;
- else
- *float_valp++ = double_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = double_val;
- break;
- }
- valnum++;
- }
- | FILLVALUE
- {
- /* store fill_value */
- switch (valtype) {
- case NC_CHAR:
- nc_fill(valtype, 1, (void *)char_valp++,
- vars[varnum].fill_value);
- break;
- case NC_BYTE:
- nc_fill(valtype, 1, (void *)byte_valp++,
- vars[varnum].fill_value);
- break;
- case NC_SHORT:
- nc_fill(valtype, 1, (void *)short_valp++,
- vars[varnum].fill_value);
- break;
- case NC_INT:
- nc_fill(valtype, 1, (void *)int_valp++,
- vars[varnum].fill_value);
- break;
- case NC_FLOAT:
- nc_fill(valtype, 1, (void *)float_valp++,
- vars[varnum].fill_value);
- break;
- case NC_DOUBLE:
- nc_fill(valtype, 1, (void *)double_valp++,
- vars[varnum].fill_value);
- break;
- }
- valnum++;
- }
- ;
-
-/* END OF RULES */
-
-%%
-
-/* PROGRAMS */
-
-#ifdef vms
-void
-#else
-int
-#endif
-yyerror( /* called for yacc syntax error */
- char *s)
-{
- derror(s);
-#ifndef vms
- return -1;
-#endif
-}
-
-/* undefine yywrap macro, in case we are using bison instead of yacc */
-#ifdef yywrap
-#undef yywrap
-#endif
-
-int
-yywrap(void) /* returns 1 on EOF if no more input */
-{
- return 1;
-}
-
-
-/* Symbol table operations for ncgen tool */
-
-YYSTYPE lookup( /* find sname in symbol table (linear search) */
- char *sname)
-{
- YYSTYPE sp;
- for (sp = symlist; sp != (YYSTYPE) 0; sp = sp -> next)
- if (STREQ(sp -> name, sname)) {
- return sp;
- }
- return 0; /* 0 ==> not found */
-}
-
-YYSTYPE install( /* install sname in symbol table */
- char *sname)
-{
- YYSTYPE sp;
-
- sp = (YYSTYPE) emalloc (sizeof (struct Symbol));
- sp -> name = (char *) emalloc (strlen (sname) + 1);/* +1 for '\0' */
- (void) strcpy (sp -> name, sname);
- sp -> next = symlist; /* put at front of list */
- sp -> is_dim = 0;
- sp -> is_var = 0;
- sp -> is_att = 0;
- symlist = sp;
- return sp;
-}
-
-void
-clearout(void) /* reset symbol table to empty */
-{
- YYSTYPE sp, tp;
- for (sp = symlist; sp != (YYSTYPE) 0;) {
- tp = sp -> next;
- free (sp -> name);
- free ((char *) sp);
- sp = tp;
- }
- symlist = 0;
-}
-
-/* get lexical input routine generated by lex */
-#include "ncgenyy.c"
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgentab.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgentab.c
deleted file mode 100644
index 89f276f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgentab.c
+++ /dev/null
@@ -1,1573 +0,0 @@
-
-# line 10 "ncgen.y"
-#ifndef lint
-static char SccsId[] = "$Id: ncgentab.c,v 1.2 2005/06/17 19:37:54 svitak Exp $";
-#endif
-#include <string.h>
-#include <stdlib.h>
-#include <netcdf.h>
-#include "generic.h"
-#include "ncgen.h"
-#include "genlib.h" /* for grow_darray() et al */
-
-typedef struct Symbol { /* symbol table entry */
- char *name;
- struct Symbol *next;
- unsigned is_dim : 1; /* appears as netCDF dimension */
- unsigned is_var : 1; /* appears as netCDF variable */
- unsigned is_att : 1; /* appears as netCDF attribute */
- int dnum; /* handle as a dimension */
- int vnum; /* handle as a variable */
- } *YYSTYPE1;
-
-/* True if string a equals string b*/
-#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-#define NC_UNSPECIFIED ((nc_type)0) /* unspecified (as yet) type */
-
-#define YYSTYPE YYSTYPE1
-YYSTYPE symlist; /* symbol table: linked list */
-
-extern int derror_count; /* counts errors in netcdf definition */
-extern int lineno; /* line number for error messages */
-
-static int not_a_string; /* whether last constant read was a string */
-static char termstring[MAXTRST]; /* last terminal string read */
-static double double_val; /* last double value read */
-static float float_val; /* last float value read */
-static int int_val; /* last int value read */
-static short short_val; /* last short value read */
-static char char_val; /* last char value read */
-static signed char byte_val; /* last byte value read */
-
-static nc_type type_code; /* holds declared type for variables */
-static nc_type atype_code; /* holds derived type for attributes */
-static char *netcdfname; /* to construct netcdf file name */
-static void *att_space; /* pointer to block for attribute values */
-static nc_type valtype; /* type code for list of attribute values */
-
-static char *char_valp; /* pointers used to accumulate data values */
-static signed char *byte_valp;
-static short *short_valp;
-static int *int_valp;
-static float *float_valp;
-static double *double_valp;
-static void *rec_cur; /* pointer to where next data value goes */
-static void *rec_start; /* start of space for data */
-# define NC_UNLIMITED_K 257
-# define BYTE_K 258
-# define CHAR_K 259
-# define SHORT_K 260
-# define INT_K 261
-# define FLOAT_K 262
-# define DOUBLE_K 263
-# define IDENT 264
-# define TERMSTRING 265
-# define BYTE_CONST 266
-# define CHAR_CONST 267
-# define SHORT_CONST 268
-# define INT_CONST 269
-# define FLOAT_CONST 270
-# define DOUBLE_CONST 271
-# define DIMENSIONS 272
-# define VARIABLES 273
-# define NETCDF 274
-# define DATA 275
-# define FILLVALUE 276
-
-#ifdef __STDC__
-#include <stdlib.h>
-#include <string.h>
-#else
-#include <malloc.h>
-#include <memory.h>
-#endif
-
-#ifdef __cplusplus
-
-#ifndef yyerror
- void yyerror(const char *);
-#endif
-
-#ifndef yylex
-#ifdef __EXTERN_C__
- extern "C" { int yylex(void); }
-#else
- int yylex(void);
-#endif
-#endif
- int yyparse(void);
-
-#endif
-#define yyclearin yychar = -1
-#define yyerrok yyerrflag = 0
-extern int yychar;
-extern int yyerrflag;
-#ifndef YYSTYPE
-#define YYSTYPE int
-#endif
-YYSTYPE yylval;
-YYSTYPE yyval;
-typedef int yytabelem;
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 150
-#endif
-#if YYMAXDEPTH > 0
-int yy_yys[YYMAXDEPTH], *yys = yy_yys;
-YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv;
-#else /* user does initial allocation */
-int *yys;
-YYSTYPE *yyv;
-#endif
-static int yymaxdepth = YYMAXDEPTH;
-# define YYERRCODE 256
-
-# line 752 "ncgen.y"
-
-
-/* PROGRAMS */
-
-#ifdef vms
-void
-#else
-int
-#endif
-yyerror( /* called for yacc syntax error */
- char *s)
-{
- derror(s);
-#ifndef vms
- return -1;
-#endif
-}
-
-/* undefine yywrap macro, in case we are using bison instead of yacc */
-#ifdef yywrap
-#undef yywrap
-#endif
-
-int
-yywrap(void) /* returns 1 on EOF if no more input */
-{
- return 1;
-}
-
-
-/* Symbol table operations for ncgen tool */
-
-YYSTYPE lookup( /* find sname in symbol table (linear search) */
- char *sname)
-{
- YYSTYPE sp;
- for (sp = symlist; sp != (YYSTYPE) 0; sp = sp -> next)
- if (STREQ(sp -> name, sname)) {
- return sp;
- }
- return 0; /* 0 ==> not found */
-}
-
-YYSTYPE install( /* install sname in symbol table */
- char *sname)
-{
- YYSTYPE sp;
-
- sp = (YYSTYPE) emalloc (sizeof (struct Symbol));
- sp -> name = (char *) emalloc (strlen (sname) + 1);/* +1 for '\0' */
- (void) strcpy (sp -> name, sname);
- sp -> next = symlist; /* put at front of list */
- sp -> is_dim = 0;
- sp -> is_var = 0;
- sp -> is_att = 0;
- symlist = sp;
- return sp;
-}
-
-void
-clearout(void) /* reset symbol table to empty */
-{
- YYSTYPE sp, tp;
- for (sp = symlist; sp != (YYSTYPE) 0;) {
- tp = sp -> next;
- free (sp -> name);
- free ((char *) sp);
- sp = tp;
- }
- symlist = 0;
-}
-
-/* get lexical input routine generated by lex */
-#include "ncgenyy.c"
-static const yytabelem yyexca[] ={
--1, 1,
- 0, -1,
- -2, 0,
- };
-# define YYNPROD 75
-# define YYLAST 232
-static const yytabelem yyact[]={
-
- 97, 98, 96, 99, 100, 101, 102, 46, 14, 6,
- 2, 103, 70, 71, 69, 72, 73, 74, 75, 58,
- 22, 16, 40, 59, 14, 14, 3, 90, 15, 21,
- 86, 57, 67, 50, 13, 84, 53, 44, 61, 43,
- 43, 83, 77, 63, 52, 48, 36, 38, 92, 94,
- 82, 93, 64, 19, 55, 42, 81, 51, 11, 25,
- 18, 39, 10, 95, 91, 89, 78, 27, 60, 68,
- 66, 37, 35, 12, 85, 80, 65, 49, 41, 28,
- 26, 62, 9, 27, 47, 24, 20, 17, 45, 23,
- 7, 5, 4, 51, 1, 62, 0, 56, 79, 76,
- 54, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 87, 0, 0, 0, 88, 0, 0, 0, 0,
- 0, 0, 105, 87, 104, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 16, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, 29, 30, 31, 32, 33, 34,
- 16, 16 };
-static const yytabelem yypact[]={
-
- -264,-10000000, -97,-10000000, -263, -50, -244,-10000000, -34, -33,
- -13,-10000000,-10000000, -11, -242,-10000000,-10000000, -244, -4,-10000000,
- -24,-10000000,-10000000, -268, -34, -14,-10000000,-10000000, -243,-10000000,
--10000000,-10000000,-10000000,-10000000,-10000000, -15,-10000000, -25, -242,-10000000,
--10000000, -5,-10000000, -244, -238, -102, -243, -16,-10000000, 8,
--10000000,-10000000,-10000000, -253,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,
- -243, -17,-10000000,-10000000, -243, 16, 6,-10000000,-10000000,-10000000,
--10000000,-10000000,-10000000,-10000000,-10000000,-10000000, -18,-10000000, -26,-10000000,
--10000000, -244, -253,-10000000,-10000000, 7,-10000000,-10000000,-10000000, 5,
--10000000, -265,-10000000, -244,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,
--10000000,-10000000,-10000000,-10000000,-10000000,-10000000 };
-static const yytabelem yypgo[]={
-
- 0, 94, 92, 91, 90, 89, 88, 87, 60, 53,
- 86, 29, 85, 82, 59, 80, 58, 62, 79, 77,
- 33, 28, 76, 75, 74, 30, 73, 71, 70, 34,
- 61, 32, 69, 68, 38, 66, 65, 27, 64, 63 };
-static const yytabelem yyr1[]={
-
- 0, 2, 5, 1, 3, 3, 7, 7, 8, 8,
- 9, 9, 10, 11, 4, 4, 4, 12, 12, 14,
- 14, 13, 13, 17, 15, 18, 18, 18, 18, 18,
- 18, 19, 19, 22, 20, 21, 23, 23, 24, 24,
- 25, 27, 16, 26, 26, 29, 30, 28, 28, 31,
- 32, 32, 32, 32, 32, 32, 32, 6, 6, 33,
- 33, 35, 34, 36, 36, 38, 37, 39, 39, 39,
- 39, 39, 39, 39, 39 };
-static const yytabelem yyr2[]={
-
- 0, 1, 1, 17, 0, 4, 4, 6, 2, 6,
- 7, 7, 3, 2, 0, 4, 2, 4, 6, 2,
- 2, 4, 6, 2, 4, 3, 3, 3, 3, 3,
- 3, 2, 6, 1, 7, 2, 0, 6, 2, 6,
- 3, 1, 9, 6, 5, 3, 3, 2, 6, 3,
- 3, 3, 3, 3, 3, 3, 3, 0, 4, 4,
- 6, 1, 9, 2, 6, 1, 5, 3, 3, 3,
- 3, 3, 3, 3, 3 };
-static const yytabelem yychk[]={
-
--10000000, -1, 274, 123, -2, -3, 272, -4, 273, -13,
- -17, -16, -26, -29, 58, -21, 264, -7, -8, -9,
- -10, -11, 264, -5, -12, -14, -15, -16, -18, 258,
- 259, 260, 261, 262, 263, -17, 59, -27, 58, -30,
- 264, -8, 59, 44, 61, -6, 275, -14, 59, -19,
- -20, -21, 59, 61, -30, 59, -9, 269, 257, 125,
- -33, -34, -29, 59, 44, -22, -28, -31, -32, 267,
- 265, 266, 268, 269, 270, 271, -34, 59, -35, -20,
- -23, 40, 44, 59, 61, -24, -25, -11, -31, -36,
- -37, -38, 41, 44, 44, -39, 267, 265, 266, 268,
- 269, 270, 271, 276, -25, -37 };
-static const yytabelem yydef[]={
-
- 0, -2, 0, 1, 4, 14, 0, 2, 0, 16,
- 0, 23, 41, 0, 0, 45, 35, 5, 0, 8,
- 0, 12, 13, 57, 15, 0, 19, 20, 0, 25,
- 26, 27, 28, 29, 30, 0, 21, 0, 0, 44,
- 46, 0, 6, 0, 0, 0, 0, 0, 17, 24,
- 31, 33, 22, 0, 43, 7, 9, 10, 11, 3,
- 58, 0, 61, 18, 0, 36, 42, 47, 49, 50,
- 51, 52, 53, 54, 55, 56, 0, 59, 0, 32,
- 34, 0, 0, 60, 65, 0, 38, 40, 48, 62,
- 63, 0, 37, 0, 65, 66, 67, 68, 69, 70,
- 71, 72, 73, 74, 39, 64 };
-typedef struct
-#ifdef __cplusplus
- yytoktype
-#endif
-{ char *t_name; int t_val; } yytoktype;
-#ifndef YYDEBUG
-# define YYDEBUG 0 /* don't allow debugging */
-#endif
-
-#if YYDEBUG
-
-yytoktype yytoks[] =
-{
- "NC_UNLIMITED_K", 257,
- "BYTE_K", 258,
- "CHAR_K", 259,
- "SHORT_K", 260,
- "INT_K", 261,
- "FLOAT_K", 262,
- "DOUBLE_K", 263,
- "IDENT", 264,
- "TERMSTRING", 265,
- "BYTE_CONST", 266,
- "CHAR_CONST", 267,
- "SHORT_CONST", 268,
- "INT_CONST", 269,
- "FLOAT_CONST", 270,
- "DOUBLE_CONST", 271,
- "DIMENSIONS", 272,
- "VARIABLES", 273,
- "NETCDF", 274,
- "DATA", 275,
- "FILLVALUE", 276,
- "-unknown-", -1 /* ends search */
-};
-
-char * yyreds[] =
-{
- "-no such reduction-",
- "ncdesc : NETCDF '{'",
- "ncdesc : NETCDF '{' dimsection vasection",
- "ncdesc : NETCDF '{' dimsection vasection datasection '}'",
- "dimsection : /* empty */",
- "dimsection : DIMENSIONS dimdecls",
- "dimdecls : dimdecline ';'",
- "dimdecls : dimdecls dimdecline ';'",
- "dimdecline : dimdecl",
- "dimdecline : dimdecline ',' dimdecl",
- "dimdecl : dimd '=' INT_CONST",
- "dimdecl : dimd '=' NC_UNLIMITED_K",
- "dimd : dim",
- "dim : IDENT",
- "vasection : /* empty */",
- "vasection : VARIABLES vadecls",
- "vasection : gattdecls",
- "vadecls : vadecl ';'",
- "vadecls : vadecls vadecl ';'",
- "vadecl : vardecl",
- "vadecl : attdecl",
- "gattdecls : gattdecl ';'",
- "gattdecls : gattdecls gattdecl ';'",
- "gattdecl : attdecl",
- "vardecl : type varlist",
- "type : BYTE_K",
- "type : CHAR_K",
- "type : SHORT_K",
- "type : INT_K",
- "type : FLOAT_K",
- "type : DOUBLE_K",
- "varlist : varspec",
- "varlist : varlist ',' varspec",
- "varspec : var",
- "varspec : var dimspec",
- "var : IDENT",
- "dimspec : /* empty */",
- "dimspec : '(' dimlist ')'",
- "dimlist : vdim",
- "dimlist : dimlist ',' vdim",
- "vdim : dim",
- "attdecl : att",
- "attdecl : att '=' attvallist",
- "att : avar ':' attr",
- "att : ':' attr",
- "avar : var",
- "attr : IDENT",
- "attvallist : aconst",
- "attvallist : attvallist ',' aconst",
- "aconst : attconst",
- "attconst : CHAR_CONST",
- "attconst : TERMSTRING",
- "attconst : BYTE_CONST",
- "attconst : SHORT_CONST",
- "attconst : INT_CONST",
- "attconst : FLOAT_CONST",
- "attconst : DOUBLE_CONST",
- "datasection : /* empty */",
- "datasection : DATA datadecls",
- "datadecls : datadecl ';'",
- "datadecls : datadecls datadecl ';'",
- "datadecl : avar",
- "datadecl : avar '=' constlist",
- "constlist : dconst",
- "constlist : constlist ',' dconst",
- "dconst : /* empty */",
- "dconst : const",
- "const : CHAR_CONST",
- "const : TERMSTRING",
- "const : BYTE_CONST",
- "const : SHORT_CONST",
- "const : INT_CONST",
- "const : FLOAT_CONST",
- "const : DOUBLE_CONST",
- "const : FILLVALUE",
-};
-#endif /* YYDEBUG */
-# line 1 "/usr/ccs/bin/yaccpar"
-/*
- * Copyright (c) 1993 by Sun Microsystems, Inc.
- */
-
-#pragma ident "@(#)yaccpar 6.14 97/01/16 SMI"
-
-/*
-** Skeleton parser driver for yacc output
-*/
-
-/*
-** yacc user known macros and defines
-*/
-#define YYERROR goto yyerrlab
-#define YYACCEPT return(0)
-#define YYABORT return(1)
-#define YYBACKUP( newtoken, newvalue )\
-{\
- if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
- {\
- yyerror( "syntax error - cannot backup" );\
- goto yyerrlab;\
- }\
- yychar = newtoken;\
- yystate = *yyps;\
- yylval = newvalue;\
- goto yynewstate;\
-}
-#define YYRECOVERING() (!!yyerrflag)
-#define YYNEW(type) malloc(sizeof(type) * yynewmax)
-#define YYCOPY(to, from, type) \
- (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type))
-#define YYENLARGE( from, type) \
- (type *) realloc((char *) from, yynewmax * sizeof(type))
-#ifndef YYDEBUG
-# define YYDEBUG 1 /* make debugging available */
-#endif
-
-/*
-** user known globals
-*/
-int yydebug; /* set to 1 to get debugging */
-
-/*
-** driver internal defines
-*/
-#define YYFLAG (-10000000)
-
-/*
-** global variables used by the parser
-*/
-YYSTYPE *yypv; /* top of value stack */
-int *yyps; /* top of state stack */
-
-int yystate; /* current state */
-int yytmp; /* extra var (lasts between blocks) */
-
-int yynerrs; /* number of errors */
-int yyerrflag; /* error recovery flag */
-int yychar; /* current input token number */
-
-
-
-#ifdef YYNMBCHARS
-#define YYLEX() yycvtok(yylex())
-/*
-** yycvtok - return a token if i is a wchar_t value that exceeds 255.
-** If i<255, i itself is the token. If i>255 but the neither
-** of the 30th or 31st bit is on, i is already a token.
-*/
-#if defined(__STDC__) || defined(__cplusplus)
-int yycvtok(int i)
-#else
-int yycvtok(i) int i;
-#endif
-{
- int first = 0;
- int last = YYNMBCHARS - 1;
- int mid;
- wchar_t j;
-
- if(i&0x60000000){/*Must convert to a token. */
- if( yymbchars[last].character < i ){
- return i;/*Giving up*/
- }
- while ((last>=first)&&(first>=0)) {/*Binary search loop*/
- mid = (first+last)/2;
- j = yymbchars[mid].character;
- if( j==i ){/*Found*/
- return yymbchars[mid].tvalue;
- }else if( j<i ){
- first = mid + 1;
- }else{
- last = mid -1;
- }
- }
- /*No entry in the table.*/
- return i;/* Giving up.*/
- }else{/* i is already a token. */
- return i;
- }
-}
-#else/*!YYNMBCHARS*/
-#define YYLEX() yylex()
-#endif/*!YYNMBCHARS*/
-
-/*
-** yyparse - return 0 if worked, 1 if syntax error not recovered from
-*/
-#if defined(__STDC__) || defined(__cplusplus)
-int yyparse(void)
-#else
-int yyparse()
-#endif
-{
- register YYSTYPE *yypvt = 0; /* top of value stack for $vars */
-
-#if defined(__cplusplus) || defined(lint)
-/*
- hacks to please C++ and lint - goto's inside
- switch should never be executed
-*/
- static int __yaccpar_lint_hack__ = 0;
- switch (__yaccpar_lint_hack__)
- {
- case 1: goto yyerrlab;
- case 2: goto yynewstate;
- }
-#endif
-
- /*
- ** Initialize externals - yyparse may be called more than once
- */
- yypv = &yyv[-1];
- yyps = &yys[-1];
- yystate = 0;
- yytmp = 0;
- yynerrs = 0;
- yyerrflag = 0;
- yychar = -1;
-
-#if YYMAXDEPTH <= 0
- if (yymaxdepth <= 0)
- {
- if ((yymaxdepth = YYEXPAND(0)) <= 0)
- {
- yyerror("yacc initialization error");
- YYABORT;
- }
- }
-#endif
-
- {
- register YYSTYPE *yy_pv; /* top of value stack */
- register int *yy_ps; /* top of state stack */
- register int yy_state; /* current state */
- register int yy_n; /* internal state number info */
- goto yystack; /* moved from 6 lines above to here to please C++ */
-
- /*
- ** get globals into registers.
- ** branch to here only if YYBACKUP was called.
- */
- yynewstate:
- yy_pv = yypv;
- yy_ps = yyps;
- yy_state = yystate;
- goto yy_newstate;
-
- /*
- ** get globals into registers.
- ** either we just started, or we just finished a reduction
- */
- yystack:
- yy_pv = yypv;
- yy_ps = yyps;
- yy_state = yystate;
-
- /*
- ** top of for (;;) loop while no reductions done
- */
- yy_stack:
- /*
- ** put a state and value onto the stacks
- */
-#if YYDEBUG
- /*
- ** if debugging, look up token value in list of value vs.
- ** name pairs. 0 and negative (-1) are special values.
- ** Note: linear search is used since time is not a real
- ** consideration while debugging.
- */
- if ( yydebug )
- {
- register int yy_i;
-
- printf( "State %d, token ", yy_state );
- if ( yychar == 0 )
- printf( "end-of-file\n" );
- else if ( yychar < 0 )
- printf( "-none-\n" );
- else
- {
- for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
- yy_i++ )
- {
- if ( yytoks[yy_i].t_val == yychar )
- break;
- }
- printf( "%s\n", yytoks[yy_i].t_name );
- }
- }
-#endif /* YYDEBUG */
- if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */
- {
- /*
- ** reallocate and recover. Note that pointers
- ** have to be reset, or bad things will happen
- */
- int yyps_index = (yy_ps - yys);
- int yypv_index = (yy_pv - yyv);
- int yypvt_index = (yypvt - yyv);
- int yynewmax;
-#ifdef YYEXPAND
- yynewmax = YYEXPAND(yymaxdepth);
-#else
- yynewmax = 2 * yymaxdepth; /* double table size */
- if (yymaxdepth == YYMAXDEPTH) /* first time growth */
- {
- char *newyys = (char *)YYNEW(int);
- char *newyyv = (char *)YYNEW(YYSTYPE);
- if (newyys != 0 && newyyv != 0)
- {
- yys = YYCOPY(newyys, yys, int);
- yyv = YYCOPY(newyyv, yyv, YYSTYPE);
- }
- else
- yynewmax = 0; /* failed */
- }
- else /* not first time */
- {
- yys = YYENLARGE(yys, int);
- yyv = YYENLARGE(yyv, YYSTYPE);
- if (yys == 0 || yyv == 0)
- yynewmax = 0; /* failed */
- }
-#endif
- if (yynewmax <= yymaxdepth) /* tables not expanded */
- {
- yyerror( "yacc stack overflow" );
- YYABORT;
- }
- yymaxdepth = yynewmax;
-
- yy_ps = yys + yyps_index;
- yy_pv = yyv + yypv_index;
- yypvt = yyv + yypvt_index;
- }
- *yy_ps = yy_state;
- *++yy_pv = yyval;
-
- /*
- ** we have a new state - find out what to do
- */
- yy_newstate:
- if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
- goto yydefault; /* simple state */
-#if YYDEBUG
- /*
- ** if debugging, need to mark whether new token grabbed
- */
- yytmp = yychar < 0;
-#endif
- if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
- yychar = 0; /* reached EOF */
-#if YYDEBUG
- if ( yydebug && yytmp )
- {
- register int yy_i;
-
- printf( "Received token " );
- if ( yychar == 0 )
- printf( "end-of-file\n" );
- else if ( yychar < 0 )
- printf( "-none-\n" );
- else
- {
- for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
- yy_i++ )
- {
- if ( yytoks[yy_i].t_val == yychar )
- break;
- }
- printf( "%s\n", yytoks[yy_i].t_name );
- }
- }
-#endif /* YYDEBUG */
- if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
- goto yydefault;
- if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/
- {
- yychar = -1;
- yyval = yylval;
- yy_state = yy_n;
- if ( yyerrflag > 0 )
- yyerrflag--;
- goto yy_stack;
- }
-
- yydefault:
- if ( ( yy_n = yydef[ yy_state ] ) == -2 )
- {
-#if YYDEBUG
- yytmp = yychar < 0;
-#endif
- if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
- yychar = 0; /* reached EOF */
-#if YYDEBUG
- if ( yydebug && yytmp )
- {
- register int yy_i;
-
- printf( "Received token " );
- if ( yychar == 0 )
- printf( "end-of-file\n" );
- else if ( yychar < 0 )
- printf( "-none-\n" );
- else
- {
- for ( yy_i = 0;
- yytoks[yy_i].t_val >= 0;
- yy_i++ )
- {
- if ( yytoks[yy_i].t_val
- == yychar )
- {
- break;
- }
- }
- printf( "%s\n", yytoks[yy_i].t_name );
- }
- }
-#endif /* YYDEBUG */
- /*
- ** look through exception table
- */
- {
- register const int *yyxi = yyexca;
-
- while ( ( *yyxi != -1 ) ||
- ( yyxi[1] != yy_state ) )
- {
- yyxi += 2;
- }
- while ( ( *(yyxi += 2) >= 0 ) &&
- ( *yyxi != yychar ) )
- ;
- if ( ( yy_n = yyxi[1] ) < 0 )
- YYACCEPT;
- }
- }
-
- /*
- ** check for syntax error
- */
- if ( yy_n == 0 ) /* have an error */
- {
- /* no worry about speed here! */
- switch ( yyerrflag )
- {
- case 0: /* new error */
- yyerror( "syntax error" );
- goto skip_init;
- yyerrlab:
- /*
- ** get globals into registers.
- ** we have a user generated syntax type error
- */
- yy_pv = yypv;
- yy_ps = yyps;
- yy_state = yystate;
- skip_init:
- yynerrs++;
- /* FALLTHRU */
- case 1:
- case 2: /* incompletely recovered error */
- /* try again... */
- yyerrflag = 3;
- /*
- ** find state where "error" is a legal
- ** shift action
- */
- while ( yy_ps >= yys )
- {
- yy_n = yypact[ *yy_ps ] + YYERRCODE;
- if ( yy_n >= 0 && yy_n < YYLAST &&
- yychk[yyact[yy_n]] == YYERRCODE) {
- /*
- ** simulate shift of "error"
- */
- yy_state = yyact[ yy_n ];
- goto yy_stack;
- }
- /*
- ** current state has no shift on
- ** "error", pop stack
- */
-#if YYDEBUG
-# define _POP_ "Error recovery pops state %d, uncovers state %d\n"
- if ( yydebug )
- printf( _POP_, *yy_ps,
- yy_ps[-1] );
-# undef _POP_
-#endif
- yy_ps--;
- yy_pv--;
- }
- /*
- ** there is no state on stack with "error" as
- ** a valid shift. give up.
- */
- YYABORT;
- case 3: /* no shift yet; eat a token */
-#if YYDEBUG
- /*
- ** if debugging, look up token in list of
- ** pairs. 0 and negative shouldn't occur,
- ** but since timing doesn't matter when
- ** debugging, it doesn't hurt to leave the
- ** tests here.
- */
- if ( yydebug )
- {
- register int yy_i;
-
- printf( "Error recovery discards " );
- if ( yychar == 0 )
- printf( "token end-of-file\n" );
- else if ( yychar < 0 )
- printf( "token -none-\n" );
- else
- {
- for ( yy_i = 0;
- yytoks[yy_i].t_val >= 0;
- yy_i++ )
- {
- if ( yytoks[yy_i].t_val
- == yychar )
- {
- break;
- }
- }
- printf( "token %s\n",
- yytoks[yy_i].t_name );
- }
- }
-#endif /* YYDEBUG */
- if ( yychar == 0 ) /* reached EOF. quit */
- YYABORT;
- yychar = -1;
- goto yy_newstate;
- }
- }/* end if ( yy_n == 0 ) */
- /*
- ** reduction by production yy_n
- ** put stack tops, etc. so things right after switch
- */
-#if YYDEBUG
- /*
- ** if debugging, print the string that is the user's
- ** specification of the reduction which is just about
- ** to be done.
- */
- if ( yydebug )
- printf( "Reduce by (%d) \"%s\"\n",
- yy_n, yyreds[ yy_n ] );
-#endif
- yytmp = yy_n; /* value to switch over */
- yypvt = yy_pv; /* $vars top of value stack */
- /*
- ** Look in goto table for next state
- ** Sorry about using yy_state here as temporary
- ** register variable, but why not, if it works...
- ** If yyr2[ yy_n ] doesn't have the low order bit
- ** set, then there is no action to be done for
- ** this reduction. So, no saving & unsaving of
- ** registers done. The only difference between the
- ** code just after the if and the body of the if is
- ** the goto yy_stack in the body. This way the test
- ** can be made before the choice of what to do is needed.
- */
- {
- /* length of production doubled with extra bit */
- register int yy_len = yyr2[ yy_n ];
-
- if ( !( yy_len & 01 ) )
- {
- yy_len >>= 1;
- yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
- yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
- *( yy_ps -= yy_len ) + 1;
- if ( yy_state >= YYLAST ||
- yychk[ yy_state =
- yyact[ yy_state ] ] != -yy_n )
- {
- yy_state = yyact[ yypgo[ yy_n ] ];
- }
- goto yy_stack;
- }
- yy_len >>= 1;
- yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
- yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
- *( yy_ps -= yy_len ) + 1;
- if ( yy_state >= YYLAST ||
- yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
- {
- yy_state = yyact[ yypgo[ yy_n ] ];
- }
- }
- /* save until reenter driver code */
- yystate = yy_state;
- yyps = yy_ps;
- yypv = yy_pv;
- }
- /*
- ** code supplied by user is placed in this switch
- */
- switch( yytmp )
- {
-
-case 1:
-# line 97 "ncgen.y"
-{ init_netcdf(); } break;
-case 2:
-# line 100 "ncgen.y"
-{
- if (derror_count == 0)
- define_netcdf(netcdfname);
- } break;
-case 3:
-# line 106 "ncgen.y"
-{
- if (derror_count == 0)
- close_netcdf();
- } break;
-case 10:
-# line 121 "ncgen.y"
-{ if (int_val <= 0)
- derror("dimension length must be positive");
- dims[ndims].size = int_val;
- ndims++;
- } break;
-case 11:
-# line 127 "ncgen.y"
-{ if (rec_dim != -1)
- derror("only one NC_UNLIMITED dimension allowed");
- rec_dim = ndims; /* the unlimited (record) dimension */
- dims[ndims].size = NC_UNLIMITED;
- ndims++;
- } break;
-case 12:
-# line 135 "ncgen.y"
-{ if (yypvt[-0]->is_dim == 1) {
- derror( "duplicate dimension declaration for %s",
- yypvt[-0]->name);
- }
- yypvt[-0]->is_dim = 1;
- yypvt[-0]->dnum = ndims;
- /* make sure dims array will hold dimensions */
- grow_darray(ndims, /* must hold ndims+1 dims */
- &dims); /* grow as needed */
- dims[ndims].name = (char *) emalloc(strlen(yypvt[-0]->name)+1);
- (void) strcpy(dims[ndims].name, yypvt[-0]->name);
- /* name for use in generated Fortran and C variables */
- dims[ndims].lname = decodify(yypvt[-0]->name);
- } break;
-case 25:
-# line 168 "ncgen.y"
-{ type_code = NC_BYTE; } break;
-case 26:
-# line 169 "ncgen.y"
-{ type_code = NC_CHAR; } break;
-case 27:
-# line 170 "ncgen.y"
-{ type_code = NC_SHORT; } break;
-case 28:
-# line 171 "ncgen.y"
-{ type_code = NC_INT; } break;
-case 29:
-# line 172 "ncgen.y"
-{ type_code = NC_FLOAT; } break;
-case 30:
-# line 173 "ncgen.y"
-{ type_code = NC_DOUBLE; } break;
-case 33:
-# line 179 "ncgen.y"
-{
- static struct vars dummyvar;
-
- dummyvar.name = "dummy";
- dummyvar.type = NC_DOUBLE;
- dummyvar.ndims = 0;
- dummyvar.dims = 0;
- dummyvar.fill_value.doublev = NC_FILL_DOUBLE;
- dummyvar.has_data = 0;
-
- nvdims = 0;
- /* make sure variable not re-declared */
- if (yypvt[-0]->is_var == 1) {
- derror( "duplicate variable declaration for %s",
- yypvt[-0]->name);
- }
- yypvt[-0]->is_var = 1;
- yypvt[-0]->vnum = nvars;
- /* make sure vars array will hold variables */
- grow_varray(nvars, /* must hold nvars+1 vars */
- &vars); /* grow as needed */
- vars[nvars] = dummyvar; /* to make Purify happy */
- vars[nvars].name = (char *) emalloc(strlen(yypvt[-0]->name)+1);
- (void) strcpy(vars[nvars].name, yypvt[-0]->name);
- /* name for use in generated Fortran and C variables */
- vars[nvars].lname = decodify(yypvt[-0]->name);
- vars[nvars].type = type_code;
- /* set default fill value. You can override this with
- * the variable attribute "_FillValue". */
- nc_getfill(type_code, &vars[nvars].fill_value);
- vars[nvars].has_data = 0; /* has no data (yet) */
- } break;
-case 34:
-# line 212 "ncgen.y"
-{
- vars[nvars].ndims = nvdims;
- nvars++;
- } break;
-case 40:
-# line 226 "ncgen.y"
-{
- if (nvdims >= NC_MAX_VAR_DIMS) {
- derror("%s has too many dimensions",vars[nvars].name);
- }
- if (yypvt[-0]->is_dim == 1)
- dimnum = yypvt[-0]->dnum;
- else {
- derror( "%s is not declared as a dimension",
- yypvt[-0]->name);
- dimnum = ndims;
- }
- if (rec_dim != -1 && dimnum == rec_dim && nvdims != 0) {
- derror("unlimited dimension must be first");
- }
- grow_iarray(nvdims, /* must hold nvdims+1 ints */
- &vars[nvars].dims); /* grow as needed */
- vars[nvars].dims[nvdims] = dimnum;
- nvdims++;
- } break;
-case 41:
-# line 247 "ncgen.y"
-{
- valnum = 0;
- valtype = NC_UNSPECIFIED;
- /* get a large block for attributes, realloc later */
- att_space = emalloc(MAX_NC_ATTSIZE);
- /* make all kinds of pointers point to it */
- char_valp = (char *) att_space;
- byte_valp = (signed char *) att_space;
- short_valp = (short *) att_space;
- int_valp = (int *) att_space;
- float_valp = (float *) att_space;
- double_valp = (double *) att_space;
- } break;
-case 42:
-# line 261 "ncgen.y"
-{
- { /* check if duplicate attribute for this var */
- int i;
- for(i=0; i<natts; i++) { /* expensive */
- if(atts[i].var == varnum &&
- STREQ(atts[i].name,atts[natts].name)) {
- derror("duplicate attribute %s:%s",
- vars[varnum].name,atts[natts].name);
- }
- }
- }
- atts[natts].var = varnum ;
- atts[natts].type = valtype;
- atts[natts].len = valnum;
- /* shrink space down to what was really needed */
- att_space = erealloc(att_space, valnum*nctypesize(valtype));
- atts[natts].val = att_space;
- if (STREQ(atts[natts].name, _FillValue) &&
- atts[natts].var != NC_GLOBAL) {
- nc_putfill(atts[natts].type,
- atts[natts].val,
- &vars[atts[natts].var].fill_value);
- if(atts[natts].type != vars[atts[natts].var].type) {
- derror("variable %s: %s type mismatch",
- vars[atts[natts].var].name, _FillValue);
- }
- }
- natts++;
- } break;
-case 44:
-# line 293 "ncgen.y"
-{
- varnum = NC_GLOBAL; /* handle of "global" attribute */
- } break;
-case 45:
-# line 299 "ncgen.y"
-{ if (yypvt[-0]->is_var == 1)
- varnum = yypvt[-0]->vnum;
- else {
- derror("%s not declared as a variable, fatal error",
- yypvt[-0]->name);
- YYABORT;
- }
- } break;
-case 46:
-# line 309 "ncgen.y"
-{
- /* make sure atts array will hold attributes */
- grow_aarray(natts, /* must hold natts+1 atts */
- &atts); /* grow as needed */
- atts[natts].name = (char *) emalloc(strlen(yypvt[-0]->name)+1);
- (void) strcpy(atts[natts].name,yypvt[-0]->name);
- /* name for use in generated Fortran and C variables */
- atts[natts].lname = decodify(yypvt[-0]->name);
- } break;
-case 49:
-# line 323 "ncgen.y"
-{
- if (valtype == NC_UNSPECIFIED)
- valtype = atype_code;
- if (valtype != atype_code)
- derror("values for attribute must be all of same type");
- } break;
-case 50:
-# line 332 "ncgen.y"
-{
- atype_code = NC_CHAR;
- *char_valp++ = char_val;
- valnum++;
- } break;
-case 51:
-# line 338 "ncgen.y"
-{
- atype_code = NC_CHAR;
- {
- /* don't null-terminate attribute strings */
- size_t len = strlen(termstring);
- if (len == 0) /* need null if that's only value */
- len = 1;
- (void)strncpy(char_valp,termstring,len);
- valnum += len;
- char_valp += len;
- }
- } break;
-case 52:
-# line 351 "ncgen.y"
-{
- atype_code = NC_BYTE;
- *byte_valp++ = byte_val;
- valnum++;
- } break;
-case 53:
-# line 357 "ncgen.y"
-{
- atype_code = NC_SHORT;
- *short_valp++ = short_val;
- valnum++;
- } break;
-case 54:
-# line 363 "ncgen.y"
-{
- atype_code = NC_INT;
- *int_valp++ = int_val;
- valnum++;
- } break;
-case 55:
-# line 369 "ncgen.y"
-{
- atype_code = NC_FLOAT;
- *float_valp++ = float_val;
- valnum++;
- } break;
-case 56:
-# line 375 "ncgen.y"
-{
- atype_code = NC_DOUBLE;
- *double_valp++ = double_val;
- valnum++;
- } break;
-case 61:
-# line 390 "ncgen.y"
-{
- valtype = vars[varnum].type; /* variable type */
- valnum = 0; /* values accumulated for variable */
- vars[varnum].has_data = 1;
- /* compute dimensions product */
- var_size = nctypesize(valtype);
- if (vars[varnum].ndims == 0) { /* scalar */
- var_len = 1;
- } else if (vars[varnum].dims[0] == rec_dim) {
- var_len = 1; /* one record for unlimited vars */
- } else {
- var_len = dims[vars[varnum].dims[0]].size;
- }
- for(dimnum = 1; dimnum < vars[varnum].ndims; dimnum++)
- var_len = var_len*dims[vars[varnum].dims[dimnum]].size;
- /* allocate memory for variable data */
- if (var_len*var_size != (size_t)(var_len*var_size)) {
- derror("variable %s too large for memory",
- vars[varnum].name);
- exit(9);
- }
- rec_len = var_len;
- rec_start = malloc ((size_t)(rec_len*var_size));
- if (rec_start == 0) {
- derror ("out of memory\n");
- exit(3);
- }
- rec_cur = rec_start;
- switch (valtype) {
- case NC_CHAR:
- char_valp = (char *) rec_start;
- break;
- case NC_BYTE:
- byte_valp = (signed char *) rec_start;
- break;
- case NC_SHORT:
- short_valp = (short *) rec_start;
- break;
- case NC_INT:
- int_valp = (int *) rec_start;
- break;
- case NC_FLOAT:
- float_valp = (float *) rec_start;
- break;
- case NC_DOUBLE:
- double_valp = (double *) rec_start;
- break;
- }
- } break;
-case 62:
-# line 440 "ncgen.y"
-{
- if (valnum < var_len) { /* leftovers */
- nc_fill(valtype,
- var_len - valnum,
- rec_cur,
- vars[varnum].fill_value);
- }
- /* put out var_len values */
- vars[varnum].nrecs = valnum / rec_len;
- if (derror_count == 0)
- put_variable(rec_start);
- free ((char *) rec_start);
- } break;
-case 65:
-# line 458 "ncgen.y"
-{
- if(valnum >= var_len) {
- if (vars[varnum].dims[0] != rec_dim) { /* not recvar */
- derror("too many values for this variable, %d >= %d",
- valnum, var_len);
- exit (4);
- } else { /* a record variable, so grow data
- container and increment var_len by
- multiple of record size */
- ptrdiff_t rec_inc = (char *)rec_cur
- - (char *)rec_start;
- var_len += rec_len * (1 + valnum - var_len)/rec_len;
- rec_start = erealloc(rec_start, var_len*var_size);
- rec_cur = (char *)rec_start + rec_inc;
- char_valp = (char *) rec_cur;
- byte_valp = (signed char *) rec_cur;
- short_valp = (short *) rec_cur;
- int_valp = (int *) rec_cur;
- float_valp = (float *) rec_cur;
- double_valp = (double *) rec_cur;
- }
- }
- not_a_string = 1;
- } break;
-case 66:
-# line 483 "ncgen.y"
-{
- if (not_a_string) {
- switch (valtype) {
- case NC_CHAR:
- rec_cur = (void *) char_valp;
- break;
- case NC_BYTE:
- rec_cur = (void *) byte_valp;
- break;
- case NC_SHORT:
- rec_cur = (void *) short_valp;
- break;
- case NC_INT:
- rec_cur = (void *) int_valp;
- break;
- case NC_FLOAT:
- rec_cur = (void *) float_valp;
- break;
- case NC_DOUBLE:
- rec_cur = (void *) double_valp;
- break;
- }
- }
- } break;
-case 67:
-# line 510 "ncgen.y"
-{
- atype_code = NC_CHAR;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = char_val;
- break;
- case NC_BYTE:
- *byte_valp++ = char_val;
- break;
- case NC_SHORT:
- *short_valp++ = char_val;
- break;
- case NC_INT:
- *int_valp++ = char_val;
- break;
- case NC_FLOAT:
- *float_valp++ = char_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = char_val;
- break;
- }
- valnum++;
- } break;
-case 68:
-# line 535 "ncgen.y"
-{
- not_a_string = 0;
- atype_code = NC_CHAR;
- {
- size_t len = strlen(termstring);
-
- if(valnum + len > var_len) {
- if (vars[varnum].dims[0] != rec_dim) {
- derror("too many values for this variable, %d>%d",
- valnum+len, var_len);
- exit (5);
- } else {/* a record variable so grow it */
- ptrdiff_t rec_inc = (char *)rec_cur
- - (char *)rec_start;
- var_len += rec_len * (len + valnum - var_len)/rec_len;
- rec_start = erealloc(rec_start, var_len*var_size);
- rec_cur = (char *)rec_start + rec_inc;
- char_valp = (char *) rec_cur;
- }
- }
- switch (valtype) {
- case NC_CHAR:
- {
- int ld;
- size_t i, sl;
- (void)strncpy(char_valp,termstring,len);
-
- ld = vars[varnum].ndims-1;
- if (ld > 0) {/* null-fill to size of last dim */
- sl = dims[vars[varnum].dims[ld]].size;
- for (i =len;i<sl;i++)
- char_valp[i] = '\0';
- if (sl < len)
- sl = len;
- valnum += sl;
- char_valp += sl;
- } else { /* scalar or 1D strings */
- valnum += len;
- char_valp += len;
- }
- rec_cur = (void *) char_valp;
- }
- break;
- case NC_BYTE:
- case NC_SHORT:
- case NC_INT:
- case NC_FLOAT:
- case NC_DOUBLE:
- derror("string value invalid for %s variable",
- nctype(valtype));
- break;
- }
- }
- } break;
-case 69:
-# line 590 "ncgen.y"
-{
- atype_code = NC_BYTE;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = byte_val;
- break;
- case NC_BYTE:
- *byte_valp++ = byte_val;
- break;
- case NC_SHORT:
- *short_valp++ = byte_val;
- break;
- case NC_INT:
- *int_valp++ = byte_val;
- break;
- case NC_FLOAT:
- *float_valp++ = byte_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = byte_val;
- break;
- }
- valnum++;
- } break;
-case 70:
-# line 615 "ncgen.y"
-{
- atype_code = NC_SHORT;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = short_val;
- break;
- case NC_BYTE:
- *byte_valp++ = short_val;
- break;
- case NC_SHORT:
- *short_valp++ = short_val;
- break;
- case NC_INT:
- *int_valp++ = short_val;
- break;
- case NC_FLOAT:
- *float_valp++ = short_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = short_val;
- break;
- }
- valnum++;
- } break;
-case 71:
-# line 640 "ncgen.y"
-{
- atype_code = NC_INT;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = int_val;
- break;
- case NC_BYTE:
- *byte_valp++ = int_val;
- break;
- case NC_SHORT:
- *short_valp++ = int_val;
- break;
- case NC_INT:
- *int_valp++ = int_val;
- break;
- case NC_FLOAT:
- *float_valp++ = int_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = int_val;
- break;
- }
- valnum++;
- } break;
-case 72:
-# line 665 "ncgen.y"
-{
- atype_code = NC_FLOAT;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = float_val;
- break;
- case NC_BYTE:
- *byte_valp++ = float_val;
- break;
- case NC_SHORT:
- *short_valp++ = float_val;
- break;
- case NC_INT:
- *int_valp++ = float_val;
- break;
- case NC_FLOAT:
- *float_valp++ = float_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = float_val;
- break;
- }
- valnum++;
- } break;
-case 73:
-# line 690 "ncgen.y"
-{
- atype_code = NC_DOUBLE;
- switch (valtype) {
- case NC_CHAR:
- *char_valp++ = double_val;
- break;
- case NC_BYTE:
- *byte_valp++ = double_val;
- break;
- case NC_SHORT:
- *short_valp++ = double_val;
- break;
- case NC_INT:
- *int_valp++ = double_val;
- break;
- case NC_FLOAT:
- if (double_val == NC_FILL_DOUBLE)
- *float_valp++ = NC_FILL_FLOAT;
- else
- *float_valp++ = double_val;
- break;
- case NC_DOUBLE:
- *double_valp++ = double_val;
- break;
- }
- valnum++;
- } break;
-case 74:
-# line 718 "ncgen.y"
-{
- /* store fill_value */
- switch (valtype) {
- case NC_CHAR:
- nc_fill(valtype, 1, (void *)char_valp++,
- vars[varnum].fill_value);
- break;
- case NC_BYTE:
- nc_fill(valtype, 1, (void *)byte_valp++,
- vars[varnum].fill_value);
- break;
- case NC_SHORT:
- nc_fill(valtype, 1, (void *)short_valp++,
- vars[varnum].fill_value);
- break;
- case NC_INT:
- nc_fill(valtype, 1, (void *)int_valp++,
- vars[varnum].fill_value);
- break;
- case NC_FLOAT:
- nc_fill(valtype, 1, (void *)float_valp++,
- vars[varnum].fill_value);
- break;
- case NC_DOUBLE:
- nc_fill(valtype, 1, (void *)double_valp++,
- vars[varnum].fill_value);
- break;
- }
- valnum++;
- } break;
-# line 531 "/usr/ccs/bin/yaccpar"
- }
- goto yystack; /* reset registers in driver code */
-}
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgentab.h b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgentab.h
deleted file mode 100644
index 6b13513..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgentab.h
+++ /dev/null
@@ -1,20 +0,0 @@
-# define NC_UNLIMITED_K 257
-# define BYTE_K 258
-# define CHAR_K 259
-# define SHORT_K 260
-# define INT_K 261
-# define FLOAT_K 262
-# define DOUBLE_K 263
-# define IDENT 264
-# define TERMSTRING 265
-# define BYTE_CONST 266
-# define CHAR_CONST 267
-# define SHORT_CONST 268
-# define INT_CONST 269
-# define FLOAT_CONST 270
-# define DOUBLE_CONST 271
-# define DIMENSIONS 272
-# define VARIABLES 273
-# define NETCDF 274
-# define DATA 275
-# define FILLVALUE 276
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgenyy.c b/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgenyy.c
deleted file mode 100644
index 6f15391..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgenyy.c
+++ /dev/null
@@ -1,1991 +0,0 @@
-/* A lexical scanner generated by flex */
-
-/* Scanner skeleton version:
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/ncgen/ncgenyy.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-
-#include <stdio.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-#include <unistd.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
- YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yytext_ptr )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart YY_PROTO(( FILE *input_file ));
-
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
-
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
-
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
-
-typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-typedef int yy_state_type;
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 30
-#define YY_END_OF_BUFFER 31
-static yyconst short int yy_accept[249] =
- { 0,
- 0, 0, 31, 29, 28, 17, 29, 29, 29, 29,
- 19, 29, 22, 22, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 28, 0,
- 2, 0, 0, 0, 19, 22, 22, 0, 0, 19,
- 19, 0, 20, 1, 23, 23, 18, 23, 22, 21,
- 0, 22, 18, 16, 16, 16, 16, 16, 16, 16,
- 0, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 24, 0, 0,
-
- 0, 0, 19, 0, 0, 19, 1, 23, 19, 23,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 7, 16, 16, 16, 14, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 7, 16, 16, 16, 16,
- 16, 16, 27, 25, 0, 0, 19, 0, 19, 20,
- 19, 5, 4, 16, 16, 16, 16, 16, 16, 16,
- 15, 16, 7, 16, 3, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 25, 0,
- 26, 0, 15, 0, 12, 16, 16, 16, 16, 16,
- 16, 16, 6, 16, 16, 16, 16, 16, 16, 16,
-
- 16, 16, 0, 16, 8, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 0, 16, 16, 16,
- 16, 0, 16, 16, 16, 16, 16, 0, 16, 16,
- 13, 13, 16, 16, 16, 16, 16, 14, 16, 9,
- 16, 16, 16, 16, 11, 16, 10, 0
- } ;
-
-static yyconst int yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 4, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 5, 1, 1, 1, 1, 6, 1,
- 1, 1, 7, 1, 8, 9, 10, 11, 12, 12,
- 12, 12, 12, 12, 12, 13, 13, 14, 1, 1,
- 1, 1, 1, 1, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 24, 25, 26, 27, 28, 24,
- 24, 29, 30, 31, 32, 33, 24, 34, 35, 24,
- 1, 36, 1, 1, 24, 1, 37, 38, 39, 40,
-
- 41, 42, 43, 44, 45, 24, 24, 46, 47, 48,
- 49, 24, 24, 50, 51, 52, 53, 54, 24, 34,
- 55, 24, 56, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst int yy_meta[57] =
- { 0,
- 1, 1, 2, 1, 1, 3, 1, 4, 4, 1,
- 5, 5, 5, 1, 5, 5, 5, 5, 5, 5,
- 4, 4, 4, 4, 6, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 1, 5, 5, 5, 5,
- 5, 5, 4, 4, 4, 6, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 7
- } ;
-
-static yyconst short int yy_base[259] =
- { 0,
- 0, 0, 441, 442, 55, 442, 53, 404, 51, 56,
- 87, 429, 125, 168, 0, 403, 415, 59, 65, 55,
- 54, 408, 47, 416, 412, 406, 417, 376, 386, 46,
- 383, 380, 378, 385, 384, 380, 375, 385, 84, 80,
- 442, 418, 414, 92, 0, 98, 0, 106, 371, 0,
- 442, 140, 442, 0, 124, 69, 100, 161, 442, 442,
- 0, 0, 442, 0, 387, 402, 385, 389, 382, 360,
- 109, 119, 209, 384, 362, 379, 367, 381, 376, 379,
- 390, 376, 378, 373, 349, 363, 347, 351, 344, 347,
- 343, 346, 341, 355, 342, 344, 339, 442, 382, 177,
-
- 381, 110, 245, 344, 179, 281, 0, 442, 193, 180,
- 366, 355, 368, 363, 365, 342, 0, 0, 364, 341,
- 358, 48, 355, 358, 0, 349, 344, 342, 339, 312,
- 296, 289, 284, 286, 285, 279, 276, 122, 272, 267,
- 271, 270, 442, 442, 191, 308, 442, 112, 150, 153,
- 442, 0, 0, 299, 285, 286, 264, 278, 256, 286,
- 0, 257, 0, 286, 0, 272, 276, 285, 284, 249,
- 250, 243, 247, 271, 248, 234, 237, 246, 442, 276,
- 442, 275, 442, 232, 442, 249, 259, 236, 253, 256,
- 229, 253, 0, 249, 255, 218, 227, 226, 246, 222,
-
- 217, 223, 215, 236, 0, 231, 205, 223, 198, 246,
- 216, 221, 200, 194, 191, 196, 189, 212, 190, 195,
- 181, 230, 211, 209, 176, 183, 182, 162, 189, 173,
- 0, 210, 190, 174, 147, 154, 134, 442, 152, 0,
- 146, 73, 109, 82, 442, 57, 442, 442, 327, 334,
- 338, 344, 351, 354, 56, 358, 361, 366
- } ;
-
-static yyconst short int yy_def[259] =
- { 0,
- 248, 1, 248, 248, 248, 248, 249, 250, 248, 248,
- 248, 248, 248, 248, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 248, 249,
- 248, 249, 248, 252, 11, 14, 14, 248, 248, 11,
- 248, 248, 248, 253, 13, 254, 254, 254, 248, 248,
- 255, 14, 248, 251, 251, 251, 251, 251, 251, 251,
- 248, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 248, 248, 248,
-
- 256, 46, 248, 248, 248, 248, 253, 248, 58, 255,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 248, 248, 248, 257, 248, 248, 254, 254,
- 248, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 248, 248,
- 248, 248, 248, 248, 248, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 251, 251, 251, 251,
-
- 251, 251, 248, 251, 251, 251, 251, 251, 251, 251,
- 251, 251, 251, 251, 251, 251, 248, 251, 251, 251,
- 251, 258, 251, 251, 251, 251, 251, 248, 251, 251,
- 258, 258, 251, 251, 251, 251, 251, 248, 251, 251,
- 251, 251, 251, 251, 248, 251, 248, 0, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248
- } ;
-
-static yyconst short int yy_nxt[499] =
- { 0,
- 4, 5, 6, 5, 7, 8, 9, 10, 11, 12,
- 13, 14, 14, 4, 15, 16, 17, 18, 19, 20,
- 15, 15, 21, 15, 22, 15, 23, 15, 24, 25,
- 15, 26, 27, 15, 15, 4, 15, 28, 29, 30,
- 19, 31, 15, 15, 32, 33, 15, 34, 15, 35,
- 36, 15, 37, 38, 15, 4, 39, 41, 39, 45,
- 110, 46, 47, 47, 45, 79, 46, 47, 47, 48,
- 247, 71, 72, 67, 48, 73, 73, 73, 49, 74,
- 76, 68, 87, 80, 41, 39, 69, 39, 42, 161,
- 88, 48, 162, 108, 89, 247, 48, 50, 50, 50,
-
- 75, 77, 100, 100, 51, 52, 53, 70, 102, 102,
- 102, 51, 71, 71, 108, 42, 103, 103, 103, 103,
- 103, 103, 245, 246, 108, 101, 51, 52, 53, 73,
- 73, 73, 51, 45, 248, 55, 55, 55, 174, 56,
- 57, 56, 56, 58, 56, 108, 105, 105, 108, 59,
- 106, 106, 106, 183, 60, 248, 184, 248, 61, 245,
- 175, 56, 57, 56, 56, 58, 56, 71, 71, 108,
- 59, 109, 109, 109, 108, 60, 45, 108, 62, 62,
- 62, 244, 144, 63, 243, 108, 48, 145, 145, 106,
- 106, 106, 59, 240, 242, 108, 179, 60, 108, 248,
-
- 248, 180, 180, 241, 108, 63, 108, 240, 48, 60,
- 149, 232, 150, 59, 125, 239, 238, 151, 60, 73,
- 73, 73, 237, 236, 235, 108, 117, 234, 118, 233,
- 60, 232, 149, 117, 150, 125, 161, 230, 151, 229,
- 228, 227, 226, 163, 225, 224, 223, 222, 117, 221,
- 118, 163, 220, 219, 117, 103, 103, 103, 218, 217,
- 216, 215, 147, 210, 53, 210, 214, 205, 213, 147,
- 212, 211, 210, 209, 208, 207, 206, 205, 204, 203,
- 181, 179, 202, 201, 147, 193, 53, 200, 199, 198,
- 147, 106, 106, 106, 165, 197, 196, 185, 51, 195,
-
- 53, 194, 193, 192, 191, 51, 190, 189, 165, 188,
- 187, 186, 185, 181, 178, 177, 176, 165, 163, 173,
- 51, 172, 53, 171, 170, 169, 51, 40, 40, 40,
- 40, 40, 40, 40, 43, 43, 43, 43, 43, 43,
- 43, 64, 64, 64, 99, 153, 99, 99, 99, 99,
- 99, 107, 152, 107, 107, 107, 107, 107, 56, 56,
- 146, 168, 146, 182, 167, 182, 231, 231, 231, 231,
- 231, 231, 166, 165, 164, 163, 160, 159, 158, 157,
- 156, 155, 154, 153, 152, 148, 143, 143, 142, 141,
- 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,
-
- 130, 129, 128, 127, 126, 125, 124, 123, 122, 121,
- 120, 119, 116, 115, 114, 113, 112, 111, 104, 98,
- 248, 97, 96, 95, 94, 93, 92, 91, 90, 86,
- 85, 84, 83, 82, 81, 78, 66, 65, 54, 44,
- 248, 3, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248
-
- } ;
-
-static yyconst short int yy_chk[499] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 5, 7, 5, 9,
- 255, 9, 9, 9, 10, 23, 10, 10, 10, 9,
- 246, 19, 19, 18, 10, 19, 19, 19, 10, 20,
- 21, 18, 30, 23, 40, 39, 18, 39, 7, 122,
- 30, 9, 122, 56, 30, 244, 10, 11, 11, 11,
-
- 20, 21, 44, 44, 11, 11, 11, 18, 46, 46,
- 46, 11, 48, 48, 56, 40, 48, 48, 48, 71,
- 71, 71, 243, 242, 57, 44, 11, 11, 11, 72,
- 72, 72, 11, 13, 102, 13, 13, 13, 138, 13,
- 13, 13, 13, 13, 13, 57, 52, 52, 55, 13,
- 52, 52, 52, 148, 13, 102, 148, 55, 13, 241,
- 138, 13, 13, 13, 13, 13, 13, 58, 58, 55,
- 13, 58, 58, 58, 149, 13, 14, 150, 14, 14,
- 14, 239, 100, 14, 237, 58, 14, 100, 100, 105,
- 105, 105, 14, 236, 235, 149, 145, 14, 150, 109,
-
- 109, 145, 145, 234, 110, 14, 58, 233, 14, 110,
- 109, 232, 109, 14, 230, 229, 228, 109, 14, 73,
- 73, 73, 227, 226, 225, 110, 73, 224, 73, 223,
- 110, 222, 109, 73, 109, 221, 220, 219, 109, 218,
- 217, 216, 215, 214, 213, 212, 211, 210, 73, 209,
- 73, 208, 207, 206, 73, 103, 103, 103, 204, 203,
- 202, 201, 103, 200, 103, 199, 198, 197, 196, 103,
- 195, 194, 192, 191, 190, 189, 188, 187, 186, 184,
- 182, 180, 178, 177, 103, 176, 103, 175, 174, 173,
- 103, 106, 106, 106, 172, 171, 170, 169, 106, 168,
-
- 106, 167, 166, 164, 162, 106, 160, 159, 158, 157,
- 156, 155, 154, 146, 142, 141, 140, 139, 137, 136,
- 106, 135, 106, 134, 133, 132, 106, 249, 249, 249,
- 249, 249, 249, 249, 250, 250, 250, 250, 250, 250,
- 250, 251, 251, 251, 252, 131, 252, 252, 252, 252,
- 252, 253, 130, 253, 253, 253, 253, 253, 254, 254,
- 256, 129, 256, 257, 128, 257, 258, 258, 258, 258,
- 258, 258, 127, 126, 124, 123, 121, 120, 119, 116,
- 115, 114, 113, 112, 111, 104, 101, 99, 97, 96,
- 95, 94, 93, 92, 91, 90, 89, 88, 87, 86,
-
- 85, 84, 83, 82, 81, 80, 79, 78, 77, 76,
- 75, 74, 70, 69, 68, 67, 66, 65, 49, 43,
- 42, 38, 37, 36, 35, 34, 33, 32, 31, 29,
- 28, 27, 26, 25, 24, 22, 17, 16, 12, 8,
- 3, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248, 248, 248,
- 248, 248, 248, 248, 248, 248, 248, 248
-
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "ncgen.l"
-#define INITIAL 0
-#line 2 "ncgen.l"
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: ncgenyy.c,v 1.1.1.1 2005/06/14 04:38:30 svitak Exp $
- *********************************************************************/
-
-/* lex specification for tokens for ncgen */
-
-/* Fill value used by ncdump from version 2.4 and later. Should match
- definition of FILL_STRING in ../ncdump/vardata.h */
-#define FILL_STRING "_"
-#define XDR_INT_MIN (-2147483647-1)
-#define XDR_INT_MAX 2147483647
-
-char errstr[100]; /* for short error messages */
-
-#include <string.h>
-#include <ctype.h>
-#include "genlib.h"
-#include "ncgentab.h"
-
-#define YY_BREAK /* defining as nothing eliminates unreachable
- statement warnings from flex output,
- but make sure every action ends with
- "return" or "break"! */
-
-#line 583 "lex.yy.c"
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
-#else
-extern int yywrap YY_PROTO(( void ));
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-#endif
-
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
- { \
- int c = '*', n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 35 "ncgen.l"
-
-#line 736 "lex.yy.c"
-
- if ( yy_init )
- {
- yy_init = 0;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- 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 >= 249 )
- 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] != 442 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-
-do_action: /* This label is used only to access EOF actions. */
-
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 36 "ncgen.l"
-{ /* comment */
- break;
- }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 40 "ncgen.l"
-{
- if(yyleng > MAXTRST) {
- yyerror("string too long, truncated\n");
- yytext[MAXTRST-1] = '\0';
- }
- expand_escapes(termstring,(char *)yytext,yyleng);
- return (TERMSTRING);
- }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 49 "ncgen.l"
-{return (FLOAT_K);}
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 50 "ncgen.l"
-{return (CHAR_K);}
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 51 "ncgen.l"
-{return (BYTE_K);}
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 52 "ncgen.l"
-{return (SHORT_K);}
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 53 "ncgen.l"
-{return (INT_K);}
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 54 "ncgen.l"
-{return (DOUBLE_K);}
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 55 "ncgen.l"
-{int_val = -1;
- return (NC_UNLIMITED_K);}
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 58 "ncgen.l"
-{return (DIMENSIONS);}
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 59 "ncgen.l"
-{return (VARIABLES);}
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 60 "ncgen.l"
-{return (DATA);}
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 61 "ncgen.l"
-{
- char *s = (char*)yytext+strlen("netcdf");
- char *t = (char*)yytext+yyleng-1;
- while (isspace(*s))
- s++;
- while (isspace(*t))
- t--;
- t++;
- if (t-s+1 < 1) {
- yyerror("netCDF name required");
- return (DATA); /* generate syntax error */
- }
- netcdfname = (char *) emalloc(t-s+1);
- (void) strncpy(netcdfname, s, t-s);
- netcdfname[t-s] = '\0';
- return (NETCDF);
- }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 78 "ncgen.l"
-{ /* missing value (pre-2.4 backward compatibility) */
- if (yytext[0] == '-') {
- double_val = -FILL_DOUBLE;
- } else {
- double_val = FILL_DOUBLE;
- }
- return (DOUBLE_CONST);
- }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 86 "ncgen.l"
-{ /* missing value (pre-2.4 backward compatibility) */
- if (yytext[0] == '-') {
- float_val = -FILL_FLOAT;
- } else {
- float_val = FILL_FLOAT;
- }
- return (FLOAT_CONST);
- }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 94 "ncgen.l"
-{
- if (STREQ((char *)yytext, FILL_STRING))
- return (FILLVALUE);
- if ((yylval = lookup((char *)yytext)) == NULL) {
- yylval = install((char *)yytext);
- }
- return (IDENT);
- }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 103 "ncgen.l"
-{
- lineno++ ;
- break;
- }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 108 "ncgen.l"
-{
- int ii;
- if (sscanf((char*)yytext, "%d", &ii) != 1) {
- sprintf(errstr,"bad byte constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- byte_val = ii;
- if (ii != (int)byte_val) {
- sprintf(errstr,"byte constant out of range (-128,127): %s",(char*)yytext);
- yyerror(errstr);
- }
- return (BYTE_CONST);
- }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 122 "ncgen.l"
-{
- if (sscanf((char*)yytext, "%le", &double_val) != 1) {
- sprintf(errstr,"bad long or double constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- return (DOUBLE_CONST);
- }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 129 "ncgen.l"
-{
- if (sscanf((char*)yytext, "%e", &float_val) != 1) {
- sprintf(errstr,"bad float constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- return (FLOAT_CONST);
- }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 136 "ncgen.l"
-{
- if (sscanf((char*)yytext, "%hd", &short_val) != 1) {
- sprintf(errstr,"bad short constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- return (SHORT_CONST);
- }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 143 "ncgen.l"
-{
- char *ptr;
- errno = 0;
- double_val = strtod((char*)yytext, &ptr);
- if (errno != 0 && double_val == 0.0) {
- sprintf(errstr,"bad numerical constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- if (double_val < XDR_INT_MIN ||double_val > XDR_INT_MAX) {
- return DOUBLE_CONST;
- } else {
- int_val = (int) double_val;
- return INT_CONST;
- }
- }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 158 "ncgen.l"
-{
- char *ptr;
- long long_val;
- errno = 0;
- long_val = strtol((char*)yytext, &ptr, 0);
- if (errno != 0) {
- sprintf(errstr,"bad long constant: %s",(char*)yytext);
- yyerror(errstr);
- }
- if (long_val < XDR_INT_MIN || long_val > XDR_INT_MAX) {
- double_val = (double) long_val;
- return DOUBLE_CONST;
- } else {
- int_val = (int) long_val;
- return INT_CONST;
- }
- }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 175 "ncgen.l"
-{
- (void) sscanf((char*)&yytext[1],"%c",&byte_val);
- return (BYTE_CONST);
- }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 179 "ncgen.l"
-{
- byte_val = (char) strtol((char*)&yytext[2], (char **) 0, 8);
- return (BYTE_CONST);
- }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 183 "ncgen.l"
-{
- byte_val = (char) strtol((char*)&yytext[3], (char **) 0, 16);
- return (BYTE_CONST);
- }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 187 "ncgen.l"
-{
- switch ((char)yytext[2]) {
- case 'a': byte_val = '\007'; break; /* not everyone under-
- * stands '\a' yet */
- case 'b': byte_val = '\b'; break;
- case 'f': byte_val = '\f'; break;
- case 'n': byte_val = '\n'; break;
- case 'r': byte_val = '\r'; break;
- case 't': byte_val = '\t'; break;
- case 'v': byte_val = '\v'; break;
- case '\\': byte_val = '\\'; break;
- case '?': byte_val = '\177'; break;
- case '\'': byte_val = '\''; break;
- default: byte_val = (char)yytext[2];
- }
- return (BYTE_CONST);
- }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 205 "ncgen.l"
-{ /* whitespace */
- break;
- }
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 208 "ncgen.l"
-return (yytext[0]) ;
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 209 "ncgen.l"
-ECHO;
- YY_BREAK
-#line 1106 "lex.yy.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( yy_current_buffer->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
-
- else
- {
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
-
- int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yy_current_buffer->yy_buf_size -
- number_to_move - 1;
-#endif
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
-
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
-
- return ret_val;
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = yy_start;
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- 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 >= 249 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
- register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- 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 >= 249 )
- 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 == 248);
-
- return yy_is_jam ? 0 : yy_current_state;
- }
-
-
-#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
- {
- register char *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
- register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
-
- while ( source > yy_current_buffer->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
-
- yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
- }
-#endif /* ifndef YY_NO_UNPUT */
-
-
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
- {
- int c;
-
- *yy_c_buf_p = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* This was really a NUL. */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart( yyin );
-
- /* fall through */
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- return EOF;
-
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
-
- return c;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer( b, file );
-
- return b;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
- if ( ! b )
- return;
-
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
-
- yy_flex_free( (void *) b );
- }
-
-
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
-
- {
- yy_flush_buffer( b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
-#if YY_ALWAYS_INTERACTIVE
- b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
- {
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
- }
-
-
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer( b );
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
-
- return yy_scan_bytes( yy_str, len );
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
- {
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
- buf = (char *) yy_flex_alloc( n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
-
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer( buf, n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- yy_size_t new_size;
-
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
-
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
-
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
-
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
-
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
- BEGIN(new_state);
- }
-#endif
-
-
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
-
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-#endif
-
-
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-#endif
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
- }
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
- {
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
- }
-#endif
-
-#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
- {
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
- }
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
- {
- return (void *) malloc( size );
- }
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
- {
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
- }
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
-
-#if YY_MAIN
-int main()
- {
- yylex();
- return 0;
- }
-#endif
-#line 209 "ncgen.l"
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/Makefile b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/Makefile
deleted file mode 100644
index e054a22..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/Makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-# Makefile for netCDF (semi)exhaustive test.
-#
-# $Id: Makefile,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
-
-include ../macros.make
-# CC = cc -fullwarn -woff 1498,1692
-
-
-INCLUDES = -I../libsrc
-SRCS = varget.c vargetg.c varput.c varputg.c vardef.c vartests.c \
- vputget.c vputgetg.c driver.c cdftests.c dimtests.c rec.c \
- atttests.c misctest.c add.c error.c emalloc.c val.c slabs.c
-OBJS = $(SRCS:.c=.o)
-lib_netcdf = ../libsrc/libnetcdf.a
-ld_netcdf = -L../libsrc -lnetcdf
-time_log = times
-GARBAGE = nctest lint.out test.nc test2.nc $(time_log)
-PACKING_LIST = \
- add.c \
- add.h \
- atttests.c \
- cdftests.c \
- depend \
- dimtests.c \
- driver.c \
- emalloc.c \
- emalloc.h \
- error.c \
- error.h \
- Makefile \
- misctest.c \
- nctime.c \
- README \
- rec.c \
- slabs.c \
- testcdf.h \
- testfile_nc.sav \
- tests.h \
- timesum.awk \
- val.c \
- val.h \
- vardef.c \
- varget.c \
- vargetg.c \
- varput.c \
- varputg.c \
- vartests.c \
- vputget.c \
- vputgetg.c
-
-
-all: nctest
-
-test: nctest
- ./nctest
- cmp testfile.nc testfile_nc.sav
-
-install:
-
-
-nctest: $(OBJS) $(lib_netcdf)
- $(LINK.c) $(OBJS) $(ld_netcdf) $(LIBS) $(ld_math)
-
-nctime: nctime.o $(lib_netcdf)
- $(LINK.c) $(CFLAGS) nctime.o $(ld_netcdf) $(LIBS)
-
-time: nctime
- time ./nctime 24 13 19 17 > $(time_log)
- awk -f timesum.awk < $(time_log)
-
-saber_src:
- #load -C $(CPPFLAGS) $(SRCS) $(ld_netcdf) $(LIBS)
-
-include ../rules.make
-include depend
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/README b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/README
deleted file mode 100644
index 340fcb1..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/README
+++ /dev/null
@@ -1,44 +0,0 @@
-This directory contains source code for nctest, an extensive test
-program for the entire netCDF library. Before compiling the sources in
-this directory, you must have already made the netCDF library from the
-../src directory.
-
-For UNIX, just type "make". Then, when "nctest" is successfully made,
-invoke it with "nctest".
-
-For VMS, type "@make". The make.com, make.opt, and *-vms files are for
-VMS only. When nctest.exe is successfully made, invoke it with "run
-nctest".
-
-Output from the test program should look like the following:
---- Testing nccreate ...
---- Testing ncopen ...
---- Testing ncredef ...
---- Testing ncendef ...
---- Testing ncclose ...
---- Testing ncinquire ...
---- Testing ncsync ...
---- Testing ncabort ...
---- Testing ncdimdef ...
---- Testing ncdimid ...
---- Testing ncdiminq ...
---- Testing ncdimrename ...
---- Testing ncvardef ...
---- Testing ncvarid ...
---- Testing ncvarinq ...
---- Testing ncvarput1 ...
---- Testing ncvarget1 ...
---- Testing ncvarput ...
---- Testing ncvarget ...
---- Testing ncvarrename ...
---- Testing ncattput ...
---- Testing ncattinq ...
---- Testing ncattget ...
---- Testing ncattcopy ...
---- Testing ncattname ...
---- Testing ncattrename ...
---- Testing ncattdel ...
---- Testing nctypelen ...
-except that on VMS systems, the line "Doesn't support shared access on
-vms" will appear a couple of times after the "ncopen" and "ncsync"
-tests.
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.c
deleted file mode 100644
index 9cdafa4..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-/*
- * utility functions to update in-memory netcdf by adding new
- * dimensions, variables, and attributes.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h"
-#include "add.h"
-#include "emalloc.h"
-
-struct netcdf test; /*
- * in-memory netcdf structure, kept in sync
- * with disk netcdf
- */
-
-void
-add_dim (test, idim) /* add the dimension idim to the netcdf test */
- struct netcdf *test;
- struct cdfdim *idim;
-{
- static char pname[] = "add_dim";
-
- if (test->ndims >= MAX_NC_DIMS) {
- (void)fprintf(stderr,
- "%s: too many dimensions (%d)", pname, test->ndims);
- return;
- }
- test->dims[test->ndims].size = idim->size;
- test->dims[test->ndims].name = (char *) emalloc(strlen(idim->name) + 1);
- (void) strcpy(test->dims[test->ndims].name, idim->name);
- if (idim->size == NC_UNLIMITED)
- test->xdimid = test->ndims;
- test->ndims++;
-}
-
-void
-add_var (test, ivar) /* add the variable ivar to the netcdf test */
- struct netcdf *test;
- struct cdfvar *ivar;
-{
- static char pname[] = "add_var";
- int i;
-
- if (test->nvars >= MAX_NC_VARS) {
- (void)fprintf(stderr,
- "%s: too many variables (%d)", pname, test->nvars);
- return;
- }
-
- test->vars[test->nvars].name = (char *) emalloc(strlen(ivar->name) + 1);
- (void) strcpy(test->vars[test->nvars].name, ivar->name);
- test->vars[test->nvars].type = ivar->type;
- test->vars[test->nvars].ndims = ivar->ndims;
- test->vars[test->nvars].dims = (int *) emalloc(sizeof(int)*ivar->ndims);
- for (i = 0; i < ivar->ndims; i++)
- test->vars[test->nvars].dims[i] = ivar->dims[i];
- test->vars[test->nvars].natts = 0;
- test->nvars++;
-}
-
-void
-add_att (test, varid, iatt) /* add attribute iatt to the netcdf test */
- struct netcdf *test;
- int varid; /* variable id */
- struct cdfatt *iatt;
-{
- static char pname[] = "add_att";
- int ia; /* attribute number */
-
- if (test->natts >= MAX_TEST_ATTS) {
- (void)fprintf(stderr,
- "%s: too many attributes (%d)", pname, test->natts);
- return;
- }
-
- /* if already defined, change existing attribute and return */
- for (ia = 0; ia < test->natts ; ia++) {
- if (test->atts[ia].var == varid &&
- strcmp(test->atts[ia].name, iatt->name) == 0) {
- test->atts[ia].type = iatt->type;
- test->atts[ia].len = iatt->len;
- test->atts[ia].val = iatt->val;
- return;
- }
- }
- /* otherwise, add new attribute to list */
- test->atts[test->natts].var = varid;
- test->atts[test->natts].name = (char *) emalloc(strlen(iatt->name) + 1);
- (void) strcpy(test->atts[test->natts].name, iatt->name);
- test->atts[test->natts].type = iatt->type;
- test->atts[test->natts].len = iatt->len;
- test->atts[test->natts].val = iatt->val;
- test->natts++;
- if (varid == NC_GLOBAL)
- test->ngatts++;
- else
- test->vars[varid].natts++;
-}
-
-
-void
-add_reset(test) /* reset in-memory netcdf test to empty */
- struct netcdf *test;
-{
- test->ndims = 0;
- test->nvars = 0;
- test->natts = 0;
- test->ngatts = 0;
- test->xdimid = -1; /* no unlimited dimension */
-}
-
-
-void
-del_att (test, varid, iatt) /* delete attribute iatt in the netcdf test */
- struct netcdf *test;
- int varid; /* variable id */
- struct cdfatt *iatt;
-{
- static char pname[] = "del_att";
- int ia, ib; /* attribute number */
-
- for (ia = 0; ia < test->natts ; ia++) { /* find attribute to delete */
- if (test->atts[ia].var == varid &&
- strcmp(test->atts[ia].name, iatt->name) == 0) {
- free(test->atts[ia].name);
- for (ib = ia+1; ib < test->natts; ib++) { /* move down */
- test->atts[ib-1].var = test->atts[ib].var;
- test->atts[ib-1].name = test->atts[ib].name;
- test->atts[ib-1].type = test->atts[ib].type;
- test->atts[ib-1].len = test->atts[ib].len;
- test->atts[ib-1].val = test->atts[ib].val;
- }
- test->natts--;
- if (varid == NC_GLOBAL)
- test->ngatts--;
- else
- test->vars[varid].natts--;
- return;
- }
- }
- /* not found */
- (void) fprintf(stderr, "%s: no such attribute as (%s, %s)", pname,
- test->vars[varid].name, iatt->name);
-}
-
-void
-add_data(test, varid, start, edges) /* keep max record written updated */
- struct netcdf *test;
- int varid;
- long start[];
- long edges[];
-{
- if (varid != test->xdimid) /* not a record variable */
- return;
- if (start[0] + edges[0] > test->dims[test->xdimid].size)
- test->dims[test->xdimid].size = start[0] + edges[0];
-}
-
-
-void
-errvar(cdfp, varp)
- struct netcdf *cdfp;
- struct cdfvar *varp;
-{
- char *types;
- int id;
-
- switch (varp->type) {
- case NC_BYTE:
- types = "NC_BYTE";
- break;
- case NC_CHAR:
- types = "NC_CHAR";
- break;
- case NC_SHORT:
- types = "NC_SHORT";
- break;
- case NC_LONG:
- types = "NC_LONG";
- break;
- case NC_FLOAT:
- types = "NC_FLOAT";
- break;
- case NC_DOUBLE:
- types = "NC_DOUBLE ";
- break;
- default:
- types = "UNKNOWN";
- break;
- }
-
- (void) fprintf(stderr," name=%s type=%s dims=(",
- varp->name, types);
- for (id = 0; id < varp->ndims; id++)
- (void) fprintf(stderr, "%ld%s",
- (long)cdfp->dims[varp->dims[id]].size,
- id < varp->ndims - 1 ? ", " : "");
- (void) fprintf(stderr, ")\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.h
deleted file mode 100644
index 9efc21c..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/add.h,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#undef PROTO
-#ifndef NO_HAVE_PROTOTYPES
-# define PROTO(x) x
-#else
-# define PROTO(x) ()
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* add a dimension to an in-memory netcdf structure */
-extern void add_dim PROTO((
- struct netcdf *,
- struct cdfdim *
- ));
-
-/* add a variable var to an in-memory netcdf structure */
-extern void add_var PROTO((
- struct netcdf *,
- struct cdfvar *
- ));
-
-/* add an attribute att to an in-memory netcdf structure */
-extern void add_att PROTO((
- struct netcdf *,
- int,
- struct cdfatt *
- ));
-
-/* reset in-memory netcdf structure to empty */
-extern void add_reset PROTO((
- struct netcdf *
- ));
-
-/* delete an attribute att from an in-memory netcdf structure */
-extern void del_att PROTO((
- struct netcdf *,
- int,
- struct cdfatt *
- ));
-
-/* keep max record written updated */
-extern void add_data PROTO((
- struct netcdf *,
- int,
- long [],
- long []
- ));
-
-/* display info about variable, for error messages */
-extern void errvar PROTO((
- struct netcdf *,
- struct cdfvar *
- ));
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/atttests.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/atttests.c
deleted file mode 100644
index 54fa0d5..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/atttests.c
+++ /dev/null
@@ -1,1371 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/atttests.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#ifdef _MPW
-#define __SEG__ toobig /* under MPW on MacOS, makes it fit */
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-#include "emalloc.h"
-#include "tests.h"
-#include "val.h"
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-
-
-/*
- * Test ncattput
- * check that new attribute put works in define mode
- * check that NC_GLOBAL variable id works
- * check that changing type of existing attribute works in define mode
- * check that increasing length of attribute works in define mode
- * check that changing value of existing attribute works in define mode
- * try with bad datatype, should fail
- * try with negative length, should fail
- * try increasing length of attribute in data mode, should fail
- * try putting new attribute in data mode, should fail
- * check that changing type of existing attribute works in data mode
- * check that decreasing length of attribute works in data mode
- * check that changing value of existing attribute works in data mode
- * try with bad variable handle, should fail
- * try with bad netCDF handle, check error
- */
-void
-test_ncattput(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncattput";
- int cdfid; /* netcdf id */
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int ngatts_prev, ngatts; /* number of global attributes */
- int xdimid; /* id of unlimited dimension */
- int ia, id;
- static char byte_vals[] = {'a', 'b'};
- static char char_vals[] = "chars";
- static short short_vals[] = {-999, 0, 999};
- static nclong long_vals[] = {10, 20};
- static float float_vals[] = {1.5, 2.5, 3.5 };
- static double double_vals[] = {4.5, 5.5, 6.5, 7.5};
- /*
- * test attributes; it is important for this test that the size
- * required for the attribute values increases monotonically.
- */
- static struct cdfatt atts[] = {
- {___, "att0", NC_BYTE, LEN_OF(byte_vals), (void *) byte_vals},
- {___, "att1", NC_CHAR, LEN_OF(char_vals), (void *) char_vals},
- {___, "att2", NC_SHORT, LEN_OF(short_vals), (void *) short_vals},
- {___, "att3", NC_LONG, LEN_OF(long_vals), (void *) long_vals},
- {___, "att4", NC_FLOAT, LEN_OF(float_vals), (void *) float_vals},
- {___, "att5", NC_DOUBLE, LEN_OF(double_vals), (void *) double_vals}
- };
- int na = LEN_OF(atts); /* number of test attributes */
- int ww_id; /* variable id */
- static struct cdfvar ww = /* new variable */
- {"ww", NC_LONG, 1, ___, 0};
- static struct cdfatt tmp; /* attribute */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* get count of global attributes */
- if (ncinquire(cdfid, &ndims, &nvars, &ngatts, &xdimid) == -1) {
- error("%s: ncinquire failed", pname);
- ncclose(cdfid); return;
- }
- ngatts_prev = ngatts;
- /* in define mode, add global attributes of every type */
- for (ia = 0; ia < na; ia++) {
- if (ncattput(cdfid, NC_GLOBAL, atts[ia].name, atts[ia].type,
- atts[ia].len, atts[ia].val) == -1) {
- error("%s: ncattput of NC_GLOBAL attribute failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &atts[ia]); /* keep in-memory netcdf updated */
- }
- /* make sure count of global attributes has been updated */
- if (ncinquire(cdfid, &ndims, &nvars, &ngatts, &xdimid) == -1) {
- error("%s: ncinquire failed", pname);
- ncclose(cdfid); return;
- }
- if (ngatts != ngatts_prev + na) {
- error("%s: number of global = %d, expected %d",
- pname, ngatts, ngatts_prev + na);
- nerrs++;
- }
- /* check with ncattinq and ncattget that NC_GLOBAL attributes put OK */
- for (ia = 0; ia < na; ia++) {
- if (ncattinq(cdfid, NC_GLOBAL, atts[ia].name,
- &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of global attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (atts[ia].type != tmp.type || atts[ia].len != tmp.len) {
- error("%s: NC_GLOBAL ncattinq got unexpected type or len",
- pname);
- ncclose(cdfid); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(atts[ia].len * nctypelen(atts[ia].type));
- if (ncattget(cdfid, NC_GLOBAL, atts[ia].name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, atts[ia].val) != 0) {
- error("%s: ncattget got bad values after put of NC_GLOBAL attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
- }
- /* add a variable, then variable attributes of every type */
- ww.dims = (int *) emalloc(sizeof(int) * ww.ndims);
- for (id = 0; id < ww.ndims; id++)
- ww.dims[id] = id;
- if ((ww_id = ncvardef(cdfid,
- ww.name, ww.type, ww.ndims, ww.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &ww); /* keep in-memory netcdf in sync */
- for (ia = 0; ia < na; ia++) {
- if (ncattput(cdfid, ww_id,
- atts[ia].name, atts[ia].type, atts[ia].len, atts[ia].val)
- == -1) {
- error("%s: ncattput of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, ww_id, &atts[ia]); /* keep in-memory netcdf updated */
- }
- /* check with ncattinq and ncattget that variable attributes put OK */
- for (ia = 0; ia < na; ia++) {
- if (ncattinq(cdfid, ww_id, atts[ia].name,
- &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (atts[ia].type != tmp.type || atts[ia].len != tmp.len) {
- error("%s: ncattinq for new attribute got bad type or len",
- pname);
- ncclose(cdfid); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(atts[ia].len * nctypelen(atts[ia].type));
- if (ncattget(cdfid, ww_id, atts[ia].name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, atts[ia].val) != 0) {
- error("%s: ncattget got bad values after put of variable attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
- }
- /*
- * check that changing type of existing attribute, increasing
- * length of attribute, and changing value of existing attribute
- * work OK in define mode.
- */
- tmp.name = (char *) emalloc(MAX_NC_NAME);
- for (ia = 1; ia < na; ia++) {
- if (ncattput(cdfid, ww_id, atts[ia-1].name, atts[ia].type,
- atts[ia].len, atts[ia].val) == -1) {
- error("%s: ncattput of larger attribute failed", pname);
- ncclose(cdfid); return;
- }
- tmp.var = atts[ia].var;
- (void) strcpy (tmp.name, atts[ia-1].name);
- tmp.type = atts[ia].type;
- tmp.len = atts[ia].len;
- tmp.val = atts[ia].val;
- add_att(&test, ww_id, &tmp); /* keep in-memory netcdf updated */
- }
- /* check with ncattinq and ncattget that variable attributes put OK */
- for (ia = 1; ia < na; ia++) {
- if (ncattinq(cdfid, ww_id, atts[ia-1].name,
- &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of larger attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (atts[ia].type != tmp.type || atts[ia].len != tmp.len) {
- error("%s: ncattinq for larger attribute got bad type or len",
- pname);
- ncclose(cdfid); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(atts[ia].len * nctypelen(atts[ia].type));
- if (ncattget(cdfid, ww_id, atts[ia-1].name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, atts[ia].val) != 0) {
- error("%s: ncattget got bad values after put of larger attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
- }
- /* try with bad datatype, should fail */
- if (ncattput(cdfid, ww_id, "bogus_att1", BAD_TYPE,
- atts[0].len, atts[0].val) != -1) {
- error("%s: ncattput should fail with bad type", pname);
- nerrs++;
- }
- /* try with negative length, should fail */
- if (ncattput(cdfid, ww_id, "bogus_att2", atts[0].type,
- -1, atts[0].val) != -1) {
- error("%s: ncattput should fail with bad length", pname);
- nerrs++;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode try increasing length of attribute, should fail */
- if (ncattput(cdfid, ww_id, atts[0].name, atts[0].type,
- atts[0].len + 10, atts[0].val) != -1) {
- error("%s: ncattput should fail with increased length in data mode",
- pname);
- nerrs++;
- /* reset to correct length for later tests */
- if (ncattput(cdfid, ww_id, atts[0].name, atts[0].type,
- atts[0].len, atts[0].val) != -1) {
- error("%s: ncattput failed to reset length in data mode", pname);
- nerrs++;
- }
- }
- /* try creating new attribute in data mode, should fail */
- if (ncattput(cdfid, ww_id, "new_name", atts[0].type,
- atts[0].len, atts[0].val) != -1) {
- error("%s: ncattput of new attribute in data mode should fail",
- pname);
- ncclose(cdfid); return;
- }
- /*
- * check that changing type of existing attribute, decreasing
- * length of attribute, and changing value of existing attribute
- * work OK in data mode
- */
- for (ia = 0; ia < na - 1; ia++) {
- if (ncattput(cdfid, ww_id, atts[ia+1].name, atts[ia].type,
- atts[ia].len, atts[ia].val) == -1) {
- error("%s: ncattput of smaller attribute failed in data mode",
- pname);
- ncclose(cdfid); return;
- }
- tmp.var = atts[ia].var;
- (void) strcpy (tmp.name, atts[ia+1].name);
- tmp.type = atts[ia].type;
- tmp.len = atts[ia].len;
- tmp.val = atts[ia].val;
- add_att(&test, ww_id, &tmp); /* keep in-memory netcdf updated */
- }
- /* check with ncattinq and ncattget that variable attributes put OK */
- for (ia = 0; ia < na - 1; ia++) {
- if (ncattinq(cdfid, ww_id, atts[ia+1].name, &tmp.type, &tmp.len)
- == -1) {
- error("%s: ncattinq of variable attribute failed in data mode",
- pname);
- ncclose(cdfid); return;
- }
- if (atts[ia].type != tmp.type || atts[ia].len != tmp.len) {
- error("%s: VARIABLE ncattinq got bad type or len in data mode",
- pname);
- ncclose(cdfid); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(atts[ia].len * nctypelen(atts[ia].type));
- if (ncattget(cdfid, ww_id, atts[ia+1].name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed in data mode",
- pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, atts[ia].val) != 0) {
- error("%s: ncattget got bad values in data mode", pname);
- nerrs++;
- }
- free (tmp.val);
- }
- /* try with bad variable handle, should fail */
- if (ncattput(cdfid, test.nvars, atts[0].name, atts[0].type, atts[0].len,
- atts[0].val) != -1) {
- error("%s: ncattput should fail with bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netcdf handle, should fail */
- if (ncattput(cdfid, ww_id, atts[0].name, atts[0].type, atts[0].len,
- atts[0].val) != -1) {
- error("%s: ncattput should fail with bad netcdf handle", pname);
- ncclose(cdfid); return;
- }
- free(tmp.name);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncattinq
- * check returned values of properly created attributes
- * try with nonexisting attribute, check error
- * try with bad variable handle, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncattinq(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncattinq";
- int cdfid; /* netcdf id */
- int ia, id; /* attribute number */
- nc_type type;
- int len;
- int vv_id; /* variable id */
- static struct cdfvar vv = /* new variable */
- {"vv", NC_SHORT, 2, ___, 0};
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* in data mode, check all attributes against test netcdf */
- for (ia = 0; ia < test.natts; ia++) {
- if (ncattinq(cdfid, test.atts[ia].var, test.atts[ia].name,
- &type, &len) == -1) {
- error("%s: ncattinq failed", pname);
- ncclose(cdfid);
- return;
- }
- if (type != test.atts[ia].type) {
- error("%s: ncattinq returned wrong type", pname);
- ncclose(cdfid);
- return;
- }
- if (len != test.atts[ia].len) {
- error("%s: ncattinq returned wrong len", pname);
- ncclose(cdfid);
- return;
- }
- }
-
- /* enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add a variable */
- vv.dims = (int *) emalloc(sizeof(int) * vv.ndims);
- for (id = 0; id < vv.ndims; id++)
- vv.dims[id] = id; /* assumes vv.ndims <= test.ndims */
- if ((vv_id = ncvardef(cdfid, vv.name, vv.type, vv.ndims, vv.dims))
- == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &vv); /* keep in-memory netcdf in sync */
-
- /* try with nonexisting attribute, should fail */
- if (ncattinq(cdfid, vv_id, "nonesuch", &type, &len) != -1) {
- error("%s: ncattinq should fail with nonexisting attribute", pname);
- ncclose(cdfid); return;
- }
- /* try with bad variable handle, should fail */
- if (ncattinq(cdfid, test.nvars, test.atts[0].name, &type, &len) != -1) {
- error("%s: ncattinq should fail with bad variable id", pname);
- ncclose(cdfid); return;
- }
- /* in define mode check all attributes against test netcdf */
- for (ia = 0; ia < test.natts; ia++) {
- if (ncattinq(cdfid, test.atts[ia].var, test.atts[ia].name,
- &type, &len) == -1) {
- error("%s: ncattinq in define mode failed", pname);
- ncclose(cdfid);
- return;
- }
- if (type != test.atts[ia].type) {
- error("%s: ncattinq in define mode returned wrong type", pname);
- ncclose(cdfid);
- return;
- }
- if (len != test.atts[ia].len) {
- error("%s: ncattinq in define mode returned wrong len", pname);
- ncclose(cdfid);
- return;
- }
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- if (ncattinq(cdfid, NC_GLOBAL, test.atts[0].name, &type, &len) != -1) {
- error("%s: ncattinq should fail with bad cdfid", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncattget
- * check that NC_GLOBAL variable id works
- * check in both modes
- * check that proper call worked after ncattput
- * try with bad variable handle, check error
- * try with nonexisting attribute, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncattget(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- int cdfid; /* netcdf id */
- int ia, id;
- static struct cdfatt tmp; /* attribute */
- int uu_id; /* variable id */
- static struct cdfvar uu = /* variable */
- {"uu", NC_LONG, 2, ___, 0};
- static nclong uumax = 1000; /* attribute value */
- static struct cdfatt vmax = /* attribute */
- {___, "valid_max", NC_LONG, 1, (void *) &uumax};
-
- static char pname[] = "test_ncattget";
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* add a variable */
- uu.dims = (int *) emalloc(sizeof(int) * uu.ndims);
- for (id = 0; id < uu.ndims; id++)
- uu.dims[id] = id;
- if ((uu_id = ncvardef(cdfid,
- uu.name, uu.type, uu.ndims, uu.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &uu); /* keep in-memory netcdf in sync */
-
- /* add an attribute */
- if (ncattput(cdfid, uu_id,
- vmax.name, vmax.type, vmax.len, vmax.val)
- == -1) {
- error("%s: ncattput of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, uu_id, &vmax); /* keep in-memory netcdf updated */
-
- /* in define mode, check all attributes values against test netcdf */
- for (ia = 0; ia < test.natts; ia++) {
- if (ncattinq(cdfid, test.atts[ia].var, test.atts[ia].name,
- &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq in define mode failed", pname);
- ncclose(cdfid); return;
- }
- if (tmp.type != test.atts[ia].type) {
- error("%s: ncattinq in define mode returned wrong type", pname);
- ncclose(cdfid);
- return;
- }
- if (tmp.len != test.atts[ia].len) {
- error("%s: ncattinq in define mode returned wrong len", pname);
- ncclose(cdfid); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(tmp.len * nctypelen(tmp.type));
- if (ncattget(cdfid, test.atts[ia].var, test.atts[ia].name, tmp.val)
- == -1) {
- error("%s: ncattget of variable attribute failed in define mode",
- pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, test.atts[ia].val) != 0) {
- error("%s: ncattget got bad values in define mode", pname);
- error(" cdfid=%d, varname=%s, attname=%s, type=%d, len=%d",
- cdfid, test.vars[test.atts[ia].var].name,
- test.atts[ia].name, test.atts[ia].type, test.atts[ia].len);
- (void)fprintf(stderr,"should have got:");
- val_out(test.atts[ia].type, test.atts[ia].len,
- test.atts[ia].val);
- (void)fprintf(stderr," instead got:");
- val_out(tmp.type, tmp.len, tmp.val);
- nerrs++;
- }
- free (tmp.val);
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
-
- /* in data mode, check all attributes values against test netcdf */
- for (ia = 0; ia < test.natts; ia++) {
- if (ncattinq(cdfid, test.atts[ia].var, test.atts[ia].name,
- &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq failed", pname);
- ncclose(cdfid);
- return;
- }
- if (tmp.type != test.atts[ia].type) {
- error("%s: ncattinq returned wrong type", pname);
- ncclose(cdfid);
- return;
- }
- if (tmp.len != test.atts[ia].len) {
- error("%s: ncattinq returned wrong len", pname);
- ncclose(cdfid);
- return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(tmp.len * nctypelen(tmp.type));
- if (ncattget(cdfid, test.atts[ia].var, test.atts[ia].name, tmp.val)
- == -1) {
- error("%s: ncattget of variable attribute failed in data mode",
- pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, test.atts[ia].val) != 0) {
- error("%s: ncattget got bad values in data mode", pname);
- error(" cdfid=%d, varname=%s, attname=%s, type=%d, len=%d",
- cdfid, test.vars[test.atts[ia].var].name,
- test.atts[ia].name, test.atts[ia].type, test.atts[ia].len);
- (void)fprintf(stderr,"should have got:");
- val_out(test.atts[ia].type, test.atts[ia].len,
- test.atts[ia].val);
- (void)fprintf(stderr," instead got:");
- val_out(tmp.type, tmp.len, tmp.val);
- nerrs++;
- }
- free (tmp.val);
- }
- /* try with bad variable handle, should fail */
- if (ncattget(cdfid, test.nvars, vmax.name, vmax.val) != -1) {
- error("%s: ncattget should fail with bad variable handle", pname);
- ncclose(cdfid); return;
- }
- /* 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);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netcdf handle, should fail */
- if (ncattget(cdfid, uu_id, vmax.name, vmax.val) != -1) {
- error("%s: ncattput should fail with bad netcdf handle", pname);
- ncclose(cdfid); return;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncattcopy
- * check that NC_GLOBAL variable for source or target works
- * check that new attribute put works with target in define mode
- * check that old attribute put works with target in data mode
- * check that changing type and length of an attribute work OK
- * try with same cdfid for source and target, different variables
- * try with same cdfid for source and target, same variable
- * try with nonexisting attribute, check error
- * try with bad source or target netCDF handles, check error
- * try with bad source or target variable handle, check error
- */
-void
-test_ncattcopy(path1, path2)
- char *path1; /* name of input netcdf file to open */
- char *path2; /* name of output netcdf file to create */
-{
- int nerrs = 0;
- static char pname[] = "test_ncattcopy";
- int cdfid, cdfid2; /* netcdf id */
- int id; /* dimension id */
- int tt_id; /* variable id */
- static struct cdfvar tt = /* new variable for source netcdf */
- {"tt", NC_LONG, 1, ___, 0};
- int tu_id, tu2_id; /* variable ids */
- static struct cdfvar tu = /* new variable for target netcdf */
- {"tu", NC_DOUBLE, 2, ___, 0};
- static double double_vals[] = {-1., -2.};
- static float float_vals[] = {-1., -2.};
- static struct cdfatt att = /* attribute */
- {___, "att", NC_DOUBLE, LEN_OF(double_vals), (void *) double_vals};
- static struct cdfatt att2 = /* attribute */
- {___, "att", NC_FLOAT, LEN_OF(float_vals), (void *) float_vals};
- static struct cdfatt tmp; /* attribute */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path1, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened OK, enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed on source", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add a global attribute, a variable and an attribute */
- if (ncattput(cdfid, NC_GLOBAL, att.name, att.type, att.len, att.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &att); /* keep in-memory netcdf consistent */
- tt.dims = (int *) emalloc(sizeof(int) * tt.ndims);
- for (id=0; id < tt.ndims; id++)
- tt.dims[0] = id;
- if ((tt_id=ncvardef(cdfid, tt.name, tt.type, tt.ndims, tt.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &tt); /* keep in-memory netcdf consistent */
- if (ncattput(cdfid, tt_id, att.name, att.type, att.len, att.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, tt_id, &att); /* keep in-memory netcdf consistent */
-
- tu.dims = (int *) emalloc(sizeof(int) * tu.ndims);
- for (id = 0; id < tu.ndims; id++)
- tu.dims[id] = id;
- if ((tu_id=ncvardef(cdfid, tu.name, tu.type, tu.ndims, tu.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &tu); /* keep in-memory netcdf consistent */
- if (ncattput(cdfid, tu_id, att.name, att.type, att.len, att.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, tu_id, &att); /* keep in-memory netcdf consistent */
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* first (source) netcdf is in data mode */
- /* create second netCDF to copy attributes to */
- if ((cdfid2 = nccreate(path2, NC_CLOBBER)) == -1) {
- error("%s: nccreate failed", pname);
- return;
- }
- /* create dimensions and variable in second netcdf */
- for (id = 0; id < tu.ndims; id++) { /* copy dimensions from source */
- if ((tu.dims[id] =ncdimdef(cdfid2, test.dims[id].name,
- test.dims[id].size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- }
- if ((tu2_id=ncvardef(cdfid2, tu.name, tu.type, tu.ndims, tu.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* try copying NC_GLOBAL attribute from source to target */
- if (ncattcopy(cdfid, NC_GLOBAL, att.name, cdfid2, NC_GLOBAL) == -1) {
- error("%s: ncattcopy on NC_GLOBAL attribute '%s' failed",
- pname, att.name);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* check that copy worked with ncattinq and ncattget */
- if (ncattinq(cdfid2, NC_GLOBAL, att.name, &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of NC_GLOBAL attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (att.type != tmp.type || att.len != tmp.len) {
- error("%s: NC_GLOBAL ncattinq got unexpected type or len", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(att.len * nctypelen(att.type));
- if (ncattget(cdfid2, NC_GLOBAL, att.name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, att.val) != 0) {
- error("%s: ncattget got bad values after put of NC_GLOBAL attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
- /* try copying variable attribute from source to target */
- if (ncattcopy(cdfid, tt_id, att.name, cdfid2, tu2_id) == -1) {
- error("%s: ncattcopy failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* check that copy worked with ncattinq and ncattget */
- if (ncattinq(cdfid2, tu2_id, att.name, &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (att.type != tmp.type || att.len != tmp.len) {
- error("%s: variable ncattinq got unexpected type or len", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(att.len * nctypelen(att.type));
- if (ncattget(cdfid2, tu2_id, att.name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, att.val) != 0) {
- error("%s: ncattget got bad values after copy of variable attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
-
- /*
- * check that old attribute put works with target in data mode,
- * also checks that changing type and length of an attribute works OK
- */
- if (ncendef (cdfid2) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* change attribute to shorter attribute */
- if (ncattput(cdfid, NC_GLOBAL, att2.name, att2.type, att2.len, att2.val)
- == -1) {
- error("%s: ncattput of shorter NC_GLOBAL attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- add_att(&test, NC_GLOBAL, &att2); /* keep in-memory netcdf consistent */
- /* copy shorter attribute on existing attribute */
- if (ncattcopy(cdfid, NC_GLOBAL, att2.name, cdfid2, tu2_id) == -1) {
- error("%s: ncattcopy of shorter attribute on old attribute failed",
- pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* check that copy worked with ncattinq and ncattget */
- if (ncattinq(cdfid2, tu2_id, att2.name, &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (att2.type != tmp.type || att2.len != tmp.len) {
- error("%s: variable ncattinq got unexpected type or len", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(att2.len * nctypelen(att2.type));
- if (ncattget(cdfid2, tu2_id, att2.name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, att2.val) != 0) {
- error("%s: ncattget got bad values after copy of variable attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
-
- /* try copying with same source and target netcdf, different variables */
- /* copy shorter attribute on existing attribute */
- if (ncattcopy(cdfid, NC_GLOBAL, att2.name, cdfid, tu_id) == -1) {
- error("%s: ncattcopy of shorter NC_GLOBAL attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- add_att(&test, tu_id, &att2); /* keep in-memory netcdf consistent */
- /* check that copy worked with ncattinq and ncattget */
- if (ncattinq(cdfid, tu_id, att2.name, &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (att2.type != tmp.type || att2.len != tmp.len) {
- error("%s: variable ncattinq got unexpected type or len", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(att2.len * nctypelen(att2.type));
- if (ncattget(cdfid, tu_id, att2.name, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, att2.val) != 0) {
- error("%s: ncattget got bad values after copy of variable attrs",
- pname);
- nerrs++;
- }
- free (tmp.val);
-
- /* try with same cdfid for source and target, same variable */
- if (ncattcopy(cdfid, tu_id, att.name, cdfid, tu_id) == -1) {
- error("%s: ncattcopy failed with identical source and target",
- pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* try with nonexisting attribute, check error */
- if (ncattcopy(cdfid, tt_id, "nonesuch", cdfid, tu_id) != -1) {
- error("%s: ncattcopy should fail with bad attribute name",
- pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- /* try with bad source or target variable handle, check error */
- if (ncattcopy(cdfid, test.nvars, att.name, cdfid, tu_id) != -1) {
- error("%s: ncattcopy should fail with bad source variable id",
- pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (ncattcopy(cdfid, tt_id, att.name, cdfid, 2) != -1) {
- error("%s: ncattcopy should fail with bad target variable id",
- pname);
- ncclose(cdfid); ncclose(cdfid2); return;
- }
- if (ncclose (cdfid2) == -1) {
- error("%s: ncclose failed", pname);
- ncclose(cdfid); return;
- }
- /* try with bad source or target netCDF handles, check error */
- if (ncattcopy(cdfid, tt_id, att.name, cdfid2, tu_id) != -1) {
- error("%s: ncattcopy should fail with bad target netcdf id",
- pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- if (ncattcopy(cdfid, tt_id, att.name, cdfid2, tu_id) != -1) {
- error("%s: ncattcopy should fail with bad netcdf id", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncattname
- * check that NC_GLOBAL variable id works
- * check in both modes
- * check that proper call worked after ncattput
- * try with bad netCDF handle, check error
- * try with bad variable handle, check error
- * try with bad attribute number, check error
- */
-void
-test_ncattname(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncattname";
- int cdfid; /* netcdf id */
- struct cdfatt tmp; /* attributes */
- int ia, ib; /* attribute numbers */
- int iv; /* variable id */
- static short short_vals[] = {3, 4, 5};
- static struct cdfatt att = /* attribute */
- {___, ___, NC_SHORT, LEN_OF(short_vals), (void *) short_vals};
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened OK, enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* for each NC_GLOBAL attribute, get name and compare with expected name */
- att.name = (char *) emalloc(MAX_NC_NAME);
- ib = 0;
- for (ia = 0; ia < test.ngatts; ia++) {
- if (ncattname(cdfid, NC_GLOBAL, ia, att.name) == -1) {
- error("%s: ncattname failed on global attribute", pname);
- ncclose(cdfid); return;
- }
- /* find number of next global attribute */
- while (ib < test.natts && test.atts[ib].var != NC_GLOBAL)
- ib++;
- if (ib >= test.natts) {
- error("%s: test problem, expected global attribute not found",
- pname);
- ncclose(cdfid); return;
- }
- if (strcmp(att.name, test.atts[ib].name) != 0) {
- error("%s: NC_GLOBAL attribute name `%s' instead of expected `%s'",
- pname, att.name, test.atts[ib].name);
- nerrs++;
- }
- ib++;
- }
- /* for each variable attribute, get name and compare with expected name */
- for (iv = 0; iv < test.nvars; iv++) {
- ib = 0;
- for (ia = 0; ia < test.vars[iv].natts; ia++) {
- if (ncattname(cdfid, iv, ia, att.name) == -1) {
- error("%s: ncattname failed on variable attribute", pname);
- ncclose(cdfid); return;
- }
- /* find number of next attribute */
- while (ib < test.natts && test.atts[ib].var != iv)
- ib++;
- if (ib >= test.natts) {
- error("%s: problem in test, expected attribute not found",
- pname);
- ncclose(cdfid); return;
- }
- if (strcmp(att.name, test.atts[ib].name) != 0) {
- error("%s: variable '%s' name `%s' instead of expected `%s'",
- pname, test.vars[iv].name, att.name, test.atts[ib].name);
- nerrs++;
- }
- ib++;
- }
- }
- /* in define mode, add a global attribute */
- (void) strcpy(att.name,"attx");
- if (ncattput(cdfid, NC_GLOBAL, att.name, att.type, att.len, att.val)
- == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &att); /* keep in-memory netcdf consistent */
- /* test that ncattname works immediately after ncattput */
- tmp.name = (char *) emalloc(MAX_NC_NAME);
- if (ncattname(cdfid, NC_GLOBAL, test.ngatts-1, tmp.name) == -1) {
- error("%s: ncattname failed on variable attribute", pname);
- ncclose(cdfid); return;
- }
- if (strcmp(att.name, tmp.name) != 0) {
- error("%s: immediate NC_GLOBAL name `%s' instead of expected `%s'",
- pname, tmp.name, att.name);
- nerrs++;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode */
- /* for each NC_GLOBAL attribute, get name and compare with expected name */
- ib = 0;
- for (ia = 0; ia < test.ngatts; ia++) {
- if (ncattname(cdfid, NC_GLOBAL, ia, att.name) == -1) {
- error("%s: ncattname failed on global attribute", pname);
- ncclose(cdfid); return;
- }
- /* find number of next global attribute */
- while (ib < test.natts && test.atts[ib].var != NC_GLOBAL)
- ib++;
- if (ib >= test.natts) {
- error("%s: test problem, expected global attribute not found",
- pname);
- ncclose(cdfid); return;
- }
- if (strcmp(att.name, test.atts[ib].name) != 0) {
- error("%s: NC_GLOBAL attribute name `%s' instead of expected `%s'",
- pname, att.name, test.atts[ib].name);
- nerrs++;
- }
- ib++;
- }
- /* for each variable attribute, get name and compare with expected name */
- for (iv = 0; iv < test.nvars; iv++) {
- ib = 0;
- for (ia = 0; ia < test.vars[iv].natts; ia++) {
- if (ncattname(cdfid, iv, ia, att.name) == -1) {
- error("%s: ncattname failed on variable attribute", pname);
- ncclose(cdfid); return;
- }
- /* find number of next attribute */
- while (ib < test.natts && test.atts[ib].var != iv)
- ib++;
- if (ib >= test.natts) {
- error("%s: problem in test, expected attribute not found",
- pname);
- ncclose(cdfid); return;
- }
- if (strcmp(att.name, test.atts[ib].name) != 0) {
- error("%s: variable '%s' name `%s' instead of expected `%s'",
- pname, test.vars[iv].name, att.name, test.atts[ib].name);
- nerrs++;
- }
- ib++;
- }
- }
- /* try with bad variable handle, check error */
- if (ncattname(cdfid, test.nvars, 0, att.name) != -1) {
- error("%s: ncattname should fail with bad variable handle", pname);
- ncclose(cdfid); return;
- }
- /* try with bad attribute number, check error */
- if (ncattname(cdfid, NC_GLOBAL, -1, att.name) != -1) {
- error("%s: ncattname should fail with negative number", pname);
- ncclose(cdfid); return;
- }
- if (ncattname(cdfid, NC_GLOBAL, test.ngatts, att.name) != -1) {
- error("%s: ncattname should fail with too-high number", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- nerrs++;
- return;
- }
- /* try with bad netCDF handle, check error */
- if (ncattname(cdfid, NC_GLOBAL, 0, att.name) != -1) {
- error("%s: ncattname shoul fail with bad cdfid", pname);
- nerrs++;
- }
- free (tmp.name);
- free (att.name);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncattrename
- * check that proper rename worked with ncattinq, ncattget
- * try renaming to existing attribute name, check error
- * try with nonexisting attribute, check error
- * try with bad variable handle, check error
- * try in data mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncattrename(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncattrename";
- int cdfid; /* netcdf id */
- static char newname[] = "shorter";
- static char longername[] = "longer_name";
- struct cdfatt tmp; /* attributes */
- static short short_vals[] = {3, 4, 5};
- static struct cdfatt atty = /* attribute */
- {___, "long_name", NC_SHORT, LEN_OF(short_vals), (void *) short_vals};
- static struct cdfatt attz = /* attribute */
- {___, "arggh", NC_SHORT, LEN_OF(short_vals), (void *) short_vals};
- int ynum; /* attribute number */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened OK, enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add two attributes */
- if (ncattput(cdfid, NC_GLOBAL, atty.name, atty.type, atty.len,
- atty.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &atty); /* keep in-memory netcdf in sync */
- ynum = test.natts-1; /* number of attribute just put */
- if (ncattput(cdfid, NC_GLOBAL, attz.name, attz.type, attz.len,
- attz.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &attz); /* keep in-memory netcdf in sync */
-
- /* rename first attribute to shorter name */
- if (ncattrename(cdfid, NC_GLOBAL, atty.name, newname) == -1) {
- error("%s: ncattrename failed", pname);
- ncclose(cdfid); return;
- }
- (void) strcpy(test.atts[ynum].name, newname); /* keep test consistent */
- /* check new name with ncattinq */
- if (ncattinq(cdfid, NC_GLOBAL, newname, &tmp.type, &tmp.len) == -1) {
- error("%s: ncattinq of renamed attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (atty.type != tmp.type || atty.len != tmp.len) {
- error("%s: NC_GLOBAL ncattinq got unexpected type or len", pname);
- ncclose(cdfid); return;
- }
- /* allocate space to hold the attribute value to be retrieved */
- tmp.val = emalloc(atty.len * nctypelen(atty.type));
- if (ncattget(cdfid, NC_GLOBAL, newname, tmp.val) == -1) {
- error("%s: ncattget of variable attribute failed", pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, atty.val) != 0) {
- error("%s: ncattget got bad values after rename attrs", pname);
- nerrs++;
- }
- if (ncattinq(cdfid, NC_GLOBAL, atty.name, &tmp.type, &tmp.len) != -1) {
- error("%s: ncattrename left attribute with old name", pname);
- ncclose(cdfid); return;
- }
- /* try to rename second attribute same as first, should fail */
- if (ncattrename(cdfid, NC_GLOBAL, attz.name, newname) != -1) {
- error("%s: ncattrename should have failed with used name", pname);
- ncclose(cdfid); return;
- }
- /* try to rename second attribute with a longer name */
- if (ncattrename(cdfid, NC_GLOBAL, attz.name, longername) == -1) {
- error("%s: ncattrename failed with longer name", pname);
- ncclose(cdfid); return;
- }
- /* try with bad variable handle, check for failure */
- if (ncattrename(cdfid, test.nvars, newname, atty.name) != -1) {
- error("%s: ncattrename should have failed on bad variable id", pname);
- ncclose(cdfid); return;
- }
- /* try with bad attribute name, check for failure */
- if (ncattrename(cdfid, NC_GLOBAL, "nonesuch", newname) != -1) {
- error("%s: ncattrename should have failed on bad attribute name",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode change name to even shorter and check value */
- if (ncattrename(cdfid, NC_GLOBAL, newname, "short") == -1) {
- error("%s: ncattrename to shorter name failed in data mode", pname);
- ncclose(cdfid); return;
- }
- if (ncattrename(cdfid, NC_GLOBAL, "short", "plugh") == -1) {
- error("%s: ncattrename to same length failed in data mode", pname);
- ncclose(cdfid); return;
- }
- if (ncattget(cdfid, NC_GLOBAL, "plugh", tmp.val) == -1) {
- error("%s: ncgetatt of renamed attribute failed in data mode", pname);
- ncclose(cdfid); return;
- }
- if (val_cmp(tmp.type, tmp.len, tmp.val, atty.val) != 0) {
- error("%s: ncattget got bad values after data mode rename", pname);
- nerrs++;
- }
- free (tmp.val);
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail, since bad handle */
- if (ncattrename(cdfid, NC_GLOBAL, newname, atty.name) != -1) {
- error("%s: ncattrename should fail with bad cdfid", pname);
- ncclose(cdfid); return;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncattdel
- * check that proper delete worked
- * try with bad netCDF handle, check error
- * try with bad variable handle, check error
- * try with nonexisting attribute, check error
- * try in data mode, check error
- */
-void
-test_ncattdel(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncattdel";
- int cdfid; /* netcdf id */
- static short short_vals[] = {-1, -2, -3 };
- static struct cdfatt yaa = /* attribute */
- {___, "yet_another_attribute", NC_SHORT, LEN_OF(short_vals),
- (void *) short_vals};
- int id; /* dimension id */
- int yav_id; /* variable id */
- static struct cdfvar yav = /* new variable for target netcdf */
- {"yet_another_variable", NC_DOUBLE, 2, ___, 0};
- struct cdfvar vtmp; /* variable */
- struct cdfatt atmp; /* attribute */
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int ngatts1, ngatts2; /* number of global attributes */
- int natts; /* number of variable attributes */
- int xdimid; /* id of unlimited dimension */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened OK, enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add global attribute, variable, variable attribute */
- if (ncattput(cdfid, NC_GLOBAL, yaa.name, yaa.type, yaa.len, yaa.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &yaa); /* keep in-memory netcdf in sync */
- yav.dims = (int *) emalloc(sizeof(int) * yav.ndims);
- for (id = 0; id < yav.ndims; id++)
- yav.dims[id] = id;
- if ((yav_id=ncvardef(cdfid, yav.name, yav.type, yav.ndims, yav.dims))
- == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &yav); /* keep in-memory netcdf consistent */
- if (ncattput(cdfid, yav_id, yaa.name, yaa.type, yaa.len, yaa.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, yav_id, &yaa); /* keep in-memory netcdf consistent */
-
- /* get number of global attributes, number of attributes for variable */
- if (ncinquire(cdfid, &ndims, &nvars, &ngatts1, &xdimid) == -1) {
- error("%s: ncinquire in data mode failed", pname);
- ncclose(cdfid); return;
- }
- vtmp.dims = (int *) emalloc(sizeof(int) * MAX_VAR_DIMS);
- vtmp.name = (char *) emalloc(MAX_NC_NAME);
- if (ncvarinq(cdfid, yav_id, vtmp.name, &vtmp.type, &vtmp.ndims, vtmp.dims,
- &natts) == -1) {
- error("%s: ncvarinq failed", pname);
- ncclose(cdfid); return;
- }
-
- /* delete global attribute and check that it's gone */
- if (ncattdel(cdfid, NC_GLOBAL, yaa.name) == -1) {
- error("%s: ncattdel failed", pname);
- ncclose(cdfid); return;
- }
- del_att(&test, NC_GLOBAL, &yaa); /* keep in-memory netcdf consistent */
- if (ncinquire(cdfid, &ndims, &nvars, &ngatts2, &xdimid) == -1) {
- error("%s: ncinquire failed", pname);
- ncclose(cdfid); return;
- }
- if (ngatts2 != ngatts1 - 1) {
- error("%s: NC_GLOBAL attribute deleted, but ngatts did not decrement",
- pname);
- ncclose(cdfid); return;
- }
- if (ncattinq(cdfid, NC_GLOBAL, yaa.name, &atmp.type, &atmp.len) != -1) {
- error("%s: ncattinq on deleted NC_GLOBAL attribute should fail", pname);
- ncclose(cdfid); return;
- }
-
- /* delete variable attribute and check that it's gone */
- if (ncattdel(cdfid, yav_id, yaa.name) == -1) {
- error("%s: ncattdel failed", pname);
- ncclose(cdfid); return;
- }
- del_att(&test, yav_id, &yaa); /* keep in-memory netcdf consistent */
- if (ncvarinq(cdfid, yav_id, vtmp.name, &vtmp.type, &vtmp.ndims,
- vtmp.dims, &vtmp.natts) == -1) {
- error("%s: ncvarinq failed", pname);
- ncclose(cdfid); return;
- }
- if (vtmp.natts != natts - 1) {
- error("%s: NC_GLOBAL attribute deleted, but ngatts did not decrement",
- pname);
- ncclose(cdfid); return;
- }
- if (ncattinq(cdfid, yav_id, yaa.name, &atmp.type, &atmp.len) != -1) {
- error("%s: ncattinq on deleted variable attribute should fail",
- pname);
- ncclose(cdfid); return;
- }
- /* re-add global attribute, variable, variable attribute */
- if (ncattput(cdfid, NC_GLOBAL, yaa.name, yaa.type, yaa.len, yaa.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, NC_GLOBAL, &yaa); /* keep in-memory netcdf in sync */
- if (ncattput(cdfid, yav_id, yaa.name, yaa.type, yaa.len, yaa.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(cdfid); return;
- }
- add_att(&test, yav_id, &yaa); /* keep in-memory netcdf consistent */
- /* try on nonexistent attribute, should fail */
- if (ncattdel(cdfid, yav_id, "nonesuch") != -1) {
- error("%s: ncattdel should fail on bogus attribute", pname);
- ncclose(cdfid); return;
- }
- /* try on bad variable id, should fail */
- if (ncattdel(cdfid, test.nvars, yaa.name) != -1) {
- error("%s: ncattdel should fail on bad variable id", pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode, should fail */
- if (ncattdel(cdfid, NC_GLOBAL, yaa.name) != -1) {
- error("%s: ncattdel in data mode should fail", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try on bad netcdf handle, should fail */
- if (ncattdel(cdfid, yav_id, yaa.name) != -1) {
- error("%s: ncattdel should fail on bad netcdf id", pname);
- nerrs++;
- }
- free(vtmp.dims);
- free(vtmp.name);
- free(yav.dims);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/cdftests.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/cdftests.c
deleted file mode 100644
index ca3b28d..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/cdftests.c
+++ /dev/null
@@ -1,803 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/cdftests.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "emalloc.h"
-#include "testcdf.h" /* defines in-memory test netcdf structure */
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-#include "tests.h"
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-
-
-/*
- * Test nccreate
- * create a netcdf with no data, close it, test that it can be opened
- * try again with NC_CLOBBER mode, check that no errors occurred
- * try again with NC_NOCLOBBER mode, check error return
- * On exit, netcdf files are closed.
- * Uses: nccreate, ncendef, ncclose, ncopen.
- */
-void
-test_nccreate(path)
- char *path; /* name of netCDF file to create */
-{
- int nerrs = 0;
- static char pname[] = "test_nccreate";
- int ncid;
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((ncid = nccreate(path, NC_CLOBBER)) == -1) {
- error("%s: nccreate failed to NC_CLOBBER", pname);
- return;
- }
- /* in define mode already, so ncredef should fail */
- if (ncredef(ncid) != -1) {
- error("%s: ncredef should fail after nccreate", pname);
- nerrs++;
- }
- /* created OK */
- if (ncendef (ncid) == -1) {
- error("%s: ncendef failed", pname);
- nerrs++;
- }
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- nerrs++;
- }
- if ((ncid = ncopen(path, NC_NOWRITE)) == -1) {
- error("%s: ncopen of newly created netcdf failed", pname);
- return;
- }
- /* opened OK */
- if (ncclose (ncid) == -1) {
- error("%s: second ncclose failed", pname);
- nerrs++;
- }
- /* this call should fail, since we're using NC_NOCLOBBER mode */
- if ((ncid = nccreate(path, NC_NOCLOBBER)) != -1) {
- error("%s: nccreate failed to honor NC_NOCLOBBER mode", pname);
- nerrs++;
- }
-
- /* Initialize in-memory netcdf to empty */
- add_reset(&test);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncopen
- * try to open a non-existent netCDF, check error return
- * open a file that is not a netCDF file, check error return
- * open a netCDF with NC_WRITE mode, write something, close it
- * open a netCDF with NC_NOWRITE mode, write something and check error
- * try to open a netcdf twice, check whether returned netcdf ids different
- * On exit, netcdf files are closed.
- * Uses: ncopen, ncredef, ncattput, ncendef, ncclose.
- */
-void
-test_ncopen(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncopen";
- int ncid0, ncid1;
- static char title_val[] = "test netcdf";
- static char xpath[] = "tooth-fairy.nc"; /* must not exist */
- static struct cdfatt title = /* attribute */
- {NC_GLOBAL, "title", NC_CHAR, LEN_OF (title_val), (void *) title_val};
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- /* Open a nonexistent file */
- if((ncid0 = ncopen(xpath, NC_NOWRITE)) != -1) {
- error("%s: ncopen should fail opening nonexistent file",
- pname);
- return;
- }
- if (ncerr != NC_SYSERR) {
- error("%s: ncopen of nonexistent file should set ncerr to %d",
- pname, NC_SYSERR);
- }
- /*
- * Open a non-netCDF file. Don't use "Makefile.in" because that
- * name is munged to something else by PC/NFS and, consequently, won't
- * exist in a cross-mounted directory.
- */
- if((ncid0 = ncopen("driver.c", NC_NOWRITE)) != -1) {
- error("%s: ncopen should fail opening non-netCDF file",
- pname);
- return;
- }
- if(ncerr != NC_ENOTNC) {
- error("%s: ncopen of non-netCDF file should set ncerr to %d",
- pname, NC_ENOTNC);
- return;
- }
-
-
- if ((ncid0 = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed with NC_WRITE mode", pname);
- return;
- }
-
- /* opened */
- if (ncredef(ncid0) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(ncid0); return;
- }
- /* in define mode */
- if (ncattput(ncid0, NC_GLOBAL, "title", NC_CHAR, title.len, title.val)
- == -1) {
- error("%s: ncattput failed", pname);
- ncclose(ncid0); return;
- }
- add_att(&test, NC_GLOBAL, &title); /* keep in-memory netcdf updated */
- if (ncendef (ncid0) == -1) {
- error("%s: ncendef failed after ncattput", pname);
- ncclose(ncid0); return;
- }
- if (ncclose (ncid0) == -1) {
- error("%s: ncclose failed in NC_WRITE mode", pname);
- return;
- }
-
- if ((ncid0 = ncopen(path, NC_NOWRITE)) == -1) {
- error("%s: ncopen failed with NC_NOWRITE mode", pname);
- return;
- }
- /* opened */
- /* this should fail, since in NC_NOWRITE mode */
- if (ncredef(ncid0) != -1) {
- error("%s: cdredef should fail after NC_NOWRITE open", pname);
- ncclose(ncid0); return;
- }
- if ((ncid1 = ncopen(path, NC_WRITE)) == -1) {
-#ifndef vms
- error("%s: second ncopen failed", pname);
- nerrs++;
-#else
- fprintf(stderr,"Doesn't support shared access on vms\n") ;
-#endif
- }
- else
- {
- /* second open OK */
- if (ncid0 == ncid1) {
- error("%s: ncopen should return new ncid on second open",
- pname);
- nerrs++;
- }
- if (ncclose (ncid1) == -1) {
- error("%s: ncclose failed to close after second open", pname);
- nerrs++;
- }
- }
- if (ncclose (ncid0) == -1) {
- error("%s: ncclose failed in NC_NOWRITE mode", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncredef
- * open a netCDF, enter define mode, add dimension, variable, attribute
- * try ncredef from within define mode, check error
- * leave define mode and close, releasing netcdf handle
- * try ncredef with old handle, check error
- * On exit netcdf files are closed.
- * Uses: ncopen, ncredef, ncdimdef, ncvardef, ncattput, ncclose
- */
-void
-test_ncredef(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncredef";
- int ncid; /* netcdf id */
- int ii_dim; /* dimension id */
- static struct cdfdim ii = /* dimension */
- {"ii", 4};
- int aa_id; /* variable id */
- static struct cdfvar aa = /* variable */
- {"aa", NC_LONG, 1, ___, 0};
- static char units_val[] = "furlongs";
- static struct cdfatt aa_units = /* attribute */
- {___, "units", NC_CHAR, LEN_OF(units_val), (void *)units_val};
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened OK, enter define mode */
- if (ncredef(ncid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(ncid); return;
- }
- /* in define mode OK, add a dimension */
- if ((ii_dim = ncdimdef(ncid, ii.name, ii.size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(ncid); return;
- }
- add_dim(&test, &ii); /* keep in-memory netcdf in sync */
-
- /* dimension added OK, add a variable */
- aa.dims = (int *)emalloc(sizeof(int) * aa.ndims);
- aa.dims[0] = ii_dim;
- if ((aa_id = ncvardef(ncid, aa.name, aa.type,
- aa.ndims, aa.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(ncid); return;
- }
- add_var(&test, &aa); /* keep in-memory netcdf in sync */
-
- /* variable added OK, add a variable attribute */
- aa_units.var = aa_id;
- if (ncattput(ncid, aa_units.var, aa_units.name,
- aa_units.type, aa_units.len, (void *) aa_units.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(ncid); return;
- }
- add_att(&test, aa_id, &aa_units); /* keep in-memory netcdf in sync */
-
- if (ncredef(ncid) != -1) {
- error("%s: cdredef in define mode should have failed", pname);
- ncclose(ncid); return;
- }
- if (ncendef (ncid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(ncid); return;
- }
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- if (ncredef(ncid) != -1) {
- error("%s: ncredef failed to report bad netcdf handle", pname);
- nerrs++;
- }
- free (aa.dims);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncendef
- * check return from proper cdfendif after define mode
- * try ncendef when in data mode, check error
- * try ncendef with bad handle, check error
- * On exit netcdf files are closed.
- * Uses: ncopen, ncredef, ncdimdef, ncvardef, ncattput, ncendef, ncclose
- */
-void
-test_ncendef(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncendef";
- int ncid; /* netcdf id */
- int jj_dim, kk_dim; /* dimension ids */
- int bb_id; /* variable id */
- static struct cdfdim kk = /* dimension */
- {"kk", 3};
- static struct cdfdim jj = /* dimension */
- {"jj", 3};
- static struct cdfvar bb = /* variable */
- {"bb", NC_LONG, 2, ___, 0};
- static float bb_rangev[2] = {0., 100.}; /* attribute vector */
- static struct cdfatt bb_range = /* attribute */
- {___, "valid_range", NC_FLOAT, LEN_OF(bb_rangev), (void *)bb_rangev};
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened */
- if (ncredef(ncid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid); return;
- }
- /* in define mode, add dimensions */
- if ((jj_dim = ncdimdef(ncid, jj.name, jj.size)) == -1 ||
- (kk_dim = ncdimdef(ncid, kk.name, kk.size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(ncid); return;
- }
- add_dim(&test, &jj); /* keep in-memory netcdf in sync */
- add_dim(&test, &kk); /* keep in-memory netcdf in sync */
-
- /* dimensions added OK, add a variable */
- bb.dims = (int *) emalloc(sizeof(int) * bb.ndims);
- bb.dims[0] = kk_dim;
- bb.dims[1] = jj_dim;
- if ((bb_id = ncvardef(ncid, bb.name, bb.type,
- bb.ndims, bb.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(ncid); return;
- }
- add_var(&test, &bb); /* keep in-memory netcdf in sync */
-
- /* variable added OK, add a variable attribute */
- if (ncattput(ncid, bb_id, bb_range.name, bb_range.type, bb_range.len,
- (void *) bb_range.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(ncid); return;
- }
- add_att(&test, bb_id, &bb_range); /* keep in-memory netcdf in sync */
-
- if (ncendef (ncid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(ncid); return;
- }
- /* in data mode */
- if (ncendef (ncid) != -1) { /* should fail in data mode */
- error("%s: ncendef in data mode should have failed", pname);
- ncclose(ncid); return;
- }
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail on a bad handle */
- if (ncendef (ncid) != -1) {
- error("ncendef failed to report bad netcdf handle");
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncclose
- * try on open netCDF
- * try in define mode and data mode
- * try with bad handle, check error
- * On exit netcdf files are closed.
- */
-void
-test_ncclose(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncclose";
- int ncid; /* netcdf id */
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened */
- if (ncredef(ncid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid); return;
- }
- /* in define mode */
- if (ncclose (ncid) == -1) {
- error("%s: ncclose in define mode failed", pname);
- nerrs++;
- }
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* in data mode */
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- nerrs++;
- }
- if (ncclose (ncid) != -1) { /* should fail, since ncid is a bad handle */
- error("%s: ncclose failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncinquire
- * try in data mode, check returned values
- * try in define mode, after adding an unlimited dimension, variable
- * try with bad handle, check error
- * On exit netcdf files are closed.
- */
-void
-test_ncinquire(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncinquire";
- int ncid; /* netcdf id */
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int ngatts; /* number of global attributes */
- int xdimid; /* id of unlimited dimension */
- int rec_dim; /* dimension id */
- static struct cdfdim rec = /* dimension */
- {"rec", NC_UNLIMITED};
- static struct cdfdim dims[] = { /* dimensions */
- {"i1", 5},{"i2", 3},{"i3", 7}
- };
- int id, nd = LEN_OF(dims); /* number of dimensions */
- int dimids[LEN_OF(dims)];
- int cc_id; /* variable id */
- static struct cdfvar cc[] = { /* record variables of various sizes */
- {"cc", NC_LONG, 1, ___, 0},
- {"cd", NC_SHORT, 2, ___, 0},
- {"ce", NC_FLOAT, 3, ___, 0}
- };
- int iv;
- int nv = LEN_OF(cc); /* number of record variables */
- static char units_val[] = "moles";
- static struct cdfatt cc_units = /* attribute */
- {___, "units", NC_CHAR, LEN_OF(units_val), (void *)units_val};
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, in data mode */
- if (ncinquire(ncid, &ndims, &nvars, &ngatts, &xdimid) == -1) {
- error("%s: ncinquire in data mode failed", pname);
- ncclose(ncid); return;
- }
- /* compare returned with expected values */
- if (ndims != test.ndims) {
- error("%s: ndims returned as %d, expected %d",
- pname, ndims, test.ndims);
- nerrs++;
- }
- if (nvars != test.nvars) {
- error("%s: nvars returned as %d, expected %d",
- pname, nvars, test.nvars);
- nerrs++;
- }
- if (ngatts != test.ngatts) {
- error("%s: ngatts returned as %d, expected %d",
- pname, ngatts, test.ngatts);
- nerrs++;
- }
- if (xdimid != test.xdimid) {
- error("%s: xdimid returned as %d, expected %d",
- pname, xdimid, test.xdimid);
- nerrs++;
- }
-
- if (ncredef(ncid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid); return;
- }
- /* add dimensions */
- for (id = 0; id < nd; id++) {
- if ((dimids[id] = ncdimdef(ncid, dims[id].name, dims[id].size))
- == -1) {
- error("%s: ncdimdef failed on normal dimension", pname);
- ncclose(ncid); return;
- }
- add_dim(&test, &dims[id]);
- }
-
- /* add an unlimited dimension */
- if ((rec_dim = ncdimdef(ncid, rec.name, rec.size)) == -1) {
- error("%s: ncdimdef failed on NC_UNLIMITED dimension", pname);
- ncclose(ncid); return;
- }
- add_dim(&test, &rec);
-
- /* add some record variables */
- for (iv = 0; iv < nv; iv++) {
- cc[iv].dims = (int *) emalloc(sizeof(int) * cc[iv].ndims);
- cc[iv].dims[0] = rec_dim; /* first dimension unlimited */
- for (id = 1; id < cc[iv].ndims; id++)
- cc[iv].dims[id] = dimids[id];
- if ((cc_id = ncvardef(ncid, cc[iv].name, cc[iv].type,
- cc[iv].ndims, cc[iv].dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(ncid); return;
- }
- add_var(&test, &cc[iv]);
-
- /* add a variable attribute */
- if (ncattput(ncid, cc_id, cc_units.name, cc_units.type,
- cc_units.len, (void *) cc_units.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(ncid); return;
- }
- add_att(&test, cc_id, &cc_units);
- }
- /* try calling from define mode, compare returned values to expected */
- if (ncinquire(ncid, &ndims, &nvars, &ngatts, &xdimid) == -1) {
- error("%s: ncinquire in define mode failed", pname);
- ncclose(ncid); return;
- }
- /* compare returned with expected values */
- if (ndims != test.ndims) {
- error("%s: ndims returned as %d, expected %d",
- pname, ndims, test.ndims);
- nerrs++;
- }
- if (nvars != test.nvars) {
- error("%s: nvars returned as %d, expected %d",
- pname, nvars, test.nvars);
- nerrs++;
- }
- if (ngatts != test.ngatts) {
- error("%s: ngatts returned as %d, expected %d",
- pname, ngatts, test.ngatts);
- nerrs++;
- }
- if (xdimid != test.xdimid) {
- error("%s: xdimid returned as %d, expected %d",
- pname, xdimid, test.xdimid);
- nerrs++;
- }
-
- if (ncendef (ncid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(ncid); return;
- }
-
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail, since bad handle */
- if (ncinquire (ncid, &ndims, &nvars, &ngatts, &xdimid) != -1) {
- error("%s: ncinquire failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncsync
- * try in define mode, check error
- * try writing with one handle, reading with another on same netCDF
- * try with bad handle, check error
- * On exit netcdf files are closed.
- */
-void
-test_ncsync(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncsync";
- int ncid0, ncid1; /* netcdf ids */
- int ll_dim; /* dimension id */
- static struct cdfdim ll = /* dimension */
- {"ll", 3};
- int dd_id; /* variable id */
- static struct cdfvar dd = /* variable */
- {"dd", NC_SHORT, 1, ___, 0};
- static short dd_fill_valv[] = {-999};
- static struct cdfatt dd_fill_val = /* attribute */
- {___, "fill_value", NC_SHORT, LEN_OF(dd_fill_valv), (void *) dd_fill_valv};
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((ncid0 = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen in NC_WRITE mode failed", pname);
- return;
- }
-
- /* opened */
- if (ncredef(ncid0) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid0); return;
- }
- /* in define mode, add a dimension, variable, and attribute */
- if ((ll_dim = ncdimdef(ncid0, ll.name, ll.size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(ncid0);
- return;
- }
- add_dim(&test, &ll);
-
- dd.dims = (int *) emalloc(sizeof(int) * dd.ndims);
- dd.dims[0] = ll_dim;
- if ((dd_id=ncvardef(ncid0, dd.name, dd.type, dd.ndims, dd.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(ncid0);
- return;
- }
- add_var(&test, &dd);
-
- if (ncattput(ncid0, dd_id, dd_fill_val.name, dd_fill_val.type,
- dd_fill_val.len, (void *) dd_fill_val.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(ncid0);
- return;
- }
- add_att(&test, dd_id, &dd_fill_val);
-
- if (ncsync (ncid0) != -1) {
- error("%s: ncsync in define mode should fail", pname);
- nerrs++;
- }
-
- if (ncendef (ncid0) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(ncid0); return;
- }
- /* in data mode */
- if (ncsync (ncid0) == -1) {
- error("%s: ncsync in data mode failed", pname);
- nerrs++;
- }
-
- /* put some data into a variable */
- {
- static long dd_start[] = {0};
- static long dd_edges[] = {2};
- static short dd_vals[] = {1, 2};
- short got_vals[2];
-
- if (ncvarput(ncid0,dd_id,dd_start,dd_edges,(void *)dd_vals) == -1) {
- error("%s: ncvarput failed", pname);
- ncclose(ncid0);
- return;
- }
- add_data(&test,dd_id,dd_start,dd_edges); /* keep test in sync */
- if (ncsync (ncid0) == -1) {
- error("%s: ncsync after putting data failed", pname);
- nerrs++;
- }
- if ((ncid1 = ncopen(path, NC_NOWRITE)) == -1) {
-#ifndef vms
- error("%s: second ncopen failed", pname);
- nerrs++;
-#else
- fprintf(stderr,"Doesn't support shared access on vms\n") ;
-#endif
- } else {
- if (ncid0 == ncid1) {
- error("%s: second ncopen should return distinct handle",
- pname);
- nerrs++;
- } /* read data just put after a sync, should succeed */
- if (ncvarget(ncid1,dd_id,dd_start,dd_edges,(void *)got_vals)
- == -1) {
- error("%s: ncvarget failed", pname);
- nerrs++;
- }
- if (dd_vals[0] != got_vals[0] || dd_vals[1] != got_vals[1]) {
- error("%s: ncvarget succeeded but data values wrong",
- pname);
- }
- if (ncclose (ncid1) == -1) {
- error("%s: ncclose failed", pname);
- nerrs++;
- }
- }
- }
- if (ncclose (ncid0) == -1) {
- error("%s: ncclose failed", pname);
- nerrs++;
- }
- if (ncsync (ncid0) != -1) { /* should fail, since ncid0 is bad handle */
- error("%s: ncsync failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncabort
- * try in define mode, check that file was deleted
- * try after writing variable
- * try with bad handle, check error
- * On exit netcdf files are closed.
- */
-void
-test_ncabort(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncabort";
- static char fpath[] = "ufo.nc";
- static short attv[] = {3};
- static struct cdfatt att = /* attribute */
- {___, "temp", NC_SHORT, LEN_OF(attv), (void *) attv};
- int ncid; /* netcdf id */
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened */
- if (ncredef(ncid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid); return;
- }
- /* in define mode, add a new global attribute */
- if (ncattput(ncid, NC_GLOBAL, att.name, att.type, att.len, att.val) == -1) {
- error("%s: ncattput failed", pname);
- ncclose(ncid); return;
- }
-
- /* abort in define mode, should restore to state before define mode */
- if (ncabort(ncid) == -1) {
- error("%s: ncabort in define mode failed", pname);
- ncclose(ncid); return;
- }
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen after ncabort failed", pname);
- return;
- }
- /* check that new global attribute was not added */
- if (ncattinq(ncid, NC_GLOBAL, att.name, &att.type, &att.len) != -1) {
- error("%s: ncabort should have restored state before ncredef", pname);
- ncclose(ncid); return;
- }
- /* in data mode not being created, should just close */
- if (ncabort(ncid) == -1) {
- error("%s: ncabort in define mode failed", pname);
- return;
- }
- if ((ncid = nccreate(fpath, NC_CLOBBER)) == -1) {
- error("%s: nccreate failed to NC_CLOBBER", pname);
- return;
- }
- /* in define mode being created, should delete */
- if (ncabort(ncid) == -1) {
- error("%s: ncabort after nccreate failed", pname);
- return;
- }
- /* check with ncopen that file doesn't exist */
- if (ncopen(fpath, NC_NOWRITE) != -1) {
- error("%s: ncabort deleted file, but ncopen found it", pname);
- return;
- }
- if (ncabort(ncid) != -1) { /* should fail, ncid is bad handle */
- error("%s: ncclose failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/depend b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/depend
deleted file mode 100644
index db4f5f4..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/depend
+++ /dev/null
@@ -1,120 +0,0 @@
-add.o: ../libsrc/netcdf.h
-add.o: add.c
-add.o: add.h
-add.o: emalloc.h
-add.o: testcdf.h
-atttests.o: ../libsrc/netcdf.h
-atttests.o: add.h
-atttests.o: atttests.c
-atttests.o: emalloc.h
-atttests.o: error.h
-atttests.o: testcdf.h
-atttests.o: tests.h
-atttests.o: val.h
-cdftests.o: ../libsrc/netcdf.h
-cdftests.o: add.h
-cdftests.o: cdftests.c
-cdftests.o: emalloc.h
-cdftests.o: error.h
-cdftests.o: testcdf.h
-cdftests.o: tests.h
-dimtests.o: ../libsrc/netcdf.h
-dimtests.o: add.h
-dimtests.o: dimtests.c
-dimtests.o: emalloc.h
-dimtests.o: error.h
-dimtests.o: testcdf.h
-dimtests.o: tests.h
-driver.o: ../libsrc/netcdf.h
-driver.o: driver.c
-driver.o: tests.h
-emalloc.o: emalloc.c
-emalloc.o: emalloc.h
-emalloc.o: error.h
-error.o: ../libsrc/netcdf.h
-error.o: error.c
-error.o: error.h
-misctest.o: ../libsrc/netcdf.h
-misctest.o: add.h
-misctest.o: emalloc.h
-misctest.o: error.h
-misctest.o: misctest.c
-misctest.o: testcdf.h
-nctime.o: ../libsrc/netcdf.h
-nctime.o: nctime.c
-rec.o: ../libsrc/netcdf.h
-rec.o: emalloc.h
-rec.o: error.h
-rec.o: rec.c
-rec.o: testcdf.h
-rec.o: tests.h
-rec.o: val.h
-slabs.o: ../libsrc/netcdf.h
-slabs.o: add.h
-slabs.o: emalloc.h
-slabs.o: error.h
-slabs.o: slabs.c
-slabs.o: testcdf.h
-slabs.o: tests.h
-val.o: ../libsrc/netcdf.h
-val.o: emalloc.h
-val.o: error.h
-val.o: testcdf.h
-val.o: val.c
-val.o: val.h
-vardef.o: ../libsrc/netcdf.h
-vardef.o: add.h
-vardef.o: emalloc.h
-vardef.o: error.h
-vardef.o: testcdf.h
-vardef.o: tests.h
-vardef.o: vardef.c
-varget.o: ../libsrc/netcdf.h
-varget.o: emalloc.h
-varget.o: error.h
-varget.o: testcdf.h
-varget.o: tests.h
-varget.o: varget.c
-vargetg.o: ../libsrc/netcdf.h
-vargetg.o: emalloc.h
-vargetg.o: error.h
-vargetg.o: testcdf.h
-vargetg.o: tests.h
-vargetg.o: vargetg.c
-varput.o: ../libsrc/netcdf.h
-varput.o: emalloc.h
-varput.o: error.h
-varput.o: testcdf.h
-varput.o: tests.h
-varput.o: val.h
-varput.o: varput.c
-varputg.o: ../libsrc/netcdf.h
-varputg.o: emalloc.h
-varputg.o: error.h
-varputg.o: testcdf.h
-varputg.o: tests.h
-varputg.o: val.h
-varputg.o: varputg.c
-vartests.o: ../libsrc/netcdf.h
-vartests.o: add.h
-vartests.o: emalloc.h
-vartests.o: error.h
-vartests.o: testcdf.h
-vartests.o: tests.h
-vartests.o: vartests.c
-vputget.o: ../libsrc/netcdf.h
-vputget.o: add.h
-vputget.o: emalloc.h
-vputget.o: error.h
-vputget.o: testcdf.h
-vputget.o: tests.h
-vputget.o: val.h
-vputget.o: vputget.c
-vputgetg.o: ../libsrc/netcdf.h
-vputgetg.o: add.h
-vputgetg.o: emalloc.h
-vputgetg.o: error.h
-vputgetg.o: testcdf.h
-vputgetg.o: tests.h
-vputgetg.o: val.h
-vputgetg.o: vputgetg.c
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/dimtests.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/dimtests.c
deleted file mode 100644
index 7529602..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/dimtests.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/dimtests.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "emalloc.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-#include "tests.h"
-
-/*
- * Test ncdimdef
- * try in data mode, check error
- * check that returned id is one more than previous id
- * try adding same dimension twice, check error
- * try with illegal sizes, check error
- * make sure unlimited size works, shows up in ncinquire(...,*xtendim)
- * try to define a second unlimited dimension, check error
- */
-void
-test_ncdimdef(path)
- char *path; /* name of writable netcdf to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncdimdef";
- int cdfid; /* netcdf id */
- static struct cdfdim mm = /* dimension */
- {"mm", 1}; /* 1 should be a valid dimension size */
- static struct cdfdim nn = /* dimension */
- {"bogus", ___}; /* used for testing invalid dimension sizes */
- static struct cdfdim rec = /* dimension */
- {"rec", NC_UNLIMITED};
- int ndims; /* number of dimensions */
- int nvars; /* number of variables */
- int natts; /* number of attributes */
- int xdimid; /* id of unlimited dimension, or -1 if none */
- int dimid; /* dimension id */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, defining a dimension should fail in data mode */
- if (ncdimdef(cdfid, mm.name, mm.size) != -1) {
- error("%s: ncdimdef should have failed in data mode", pname);
- ncclose(cdfid); return;
- }
- /* enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode OK, add a dimension */
- if ((dimid = ncdimdef(cdfid, mm.name, mm.size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(cdfid); return;
- }
- add_dim(&test, &mm); /* keep in-memory netcdf in sync */
- /* check that dim id returned is one more than previous dim id */
- if (dimid != test.ndims - 1) {
- error("%s: ncdimdef returned %d for dim id, expected %d",
- pname, dimid, test.ndims-1);
- ncclose(cdfid); return;
- }
-
- /* try adding same dimension again, this should fail */
- if (ncdimdef(cdfid, mm.name, mm.size) != -1) {
- error("%s: ncdimdef should not have allowed redefinition", pname);
- ncclose(cdfid); return;
- }
- /* try adding dimension with negative size, this should fail */
- if (ncdimdef(cdfid, nn.name, (long) -10) != -1) {
- error("%s: ncdimdef should not allow negative size dimension", pname);
- ncclose(cdfid); return;
- }
- /* if there is not already an unlimited size dimension, try adding one */
- if (ncinquire(cdfid, &ndims, &nvars, &natts, &xdimid) == -1) {
- error("%s: ncinquire failed", pname);
- ncclose(cdfid); return;
- }
- if (xdimid == -1) {
- if (ncdimdef(cdfid, rec.name, rec.size) == -1) {
- error("%s: ncdimdef failed on NC_UNLIMITED dimension", pname);
- ncclose(cdfid); return;
- }
- add_dim(&test, &rec);
- }
- /* try adding another unlimited dimension, which should fail */
- if (ncdimdef(cdfid, "rec2", rec.size) != -1) {
- error("%s: ncdimdef should not allow second NC_UNLIMITED dimension",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- if (ncdimdef(cdfid, "rec2", rec.size) != -1) {
- error("%s: ncdimdef should fail on bad netCDF id", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncdimid
- * check return with defined dimension in both modes
- * try with undefined dimension, check error
- * check return with unlimited size dimension
- * try with bad handle, check error
- */
-void
-test_ncdimid(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncdimid";
- int cdfid; /* netcdf id */
- int nn_dim; /* dimension id */
- static struct cdfdim nn = /* dimension */
- {"nn", 1}; /* 1 should be a valid dimension size */
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode OK, add a dimension */
- if ((nn_dim = ncdimdef(cdfid, nn.name, nn.size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(cdfid); return;
- }
- add_dim(&test, &nn); /* keep in-memory netcdf in sync */
- /* check id returned for name matches id returned from definition */
- if (ncdimid(cdfid, nn.name) != nn_dim) {
- error("%s: ncdimid returned wrong value in define mode", pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode, check returned id for dimension just added */
- if (ncdimid(cdfid, nn.name) != nn_dim) {
- error("%s: ncdimid returned wrong value in data mode", pname);
- ncclose(cdfid); return;
- }
- /* try with undefined dimension, should fail */
- if (ncdimid(cdfid, "easter-bunny") != -1) {
- error("%s: ncdimid with bogus name should have failed ", pname);
- ncclose(cdfid); return;
- }
- /* try with unlimited dimension, assumed to be "rec" from earlier calls */
- if (ncdimid(cdfid, "rec") != test.xdimid) {
- error("%s: ncdimid returned bad value for record dimension", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try on bad handle, should fail */
- if (ncdimid(cdfid, nn.name) != -1) {
- error("%s: ncdimid failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncdiminq
- * try in both modes
- * check returned name and size against defined name and size
- * try with bad dimension handle, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncdiminq(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncdiminq";
- int cdfid; /* netcdf id */
- int dimid; /* dimension id */
- struct cdfdim dim; /* dimension */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, in data mode */
- dim.name = (char *) emalloc(MAX_NC_NAME);
- for (dimid = 0 ; dimid < test.ndims; dimid++) { /* loop on all dim ids */
- if (ncdiminq(cdfid, dimid, dim.name, &dim.size) == -1) {
- error("%s: ncdiminq in data mode failed on dim id %d",
- pname, dimid);
- ncclose(cdfid); return;
- }
- /* compare returned with expected values */
- if (strcmp(dim.name, test.dims[dimid].name) != 0) {
- error("%s: ncdiminq (data mode), name %s, expected %s for id = %d",
- pname, dim.name, test.dims[dimid].name, dimid);
- nerrs++;
- }
- if (dim.size != test.dims[dimid].size) {
- error("%s: ncdiminq (data mode), size %d, expected %d for id = %d",
- pname, dim.size, test.dims[dimid].size, dimid);
- nerrs++;
- }
- }
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, compare returned with expected values again */
- for (dimid = 0 ; dimid < test.ndims; dimid++) { /* loop on all dim ids */
- if (ncdiminq(cdfid, dimid, dim.name, &dim.size) == -1) {
- error("%s: ncdiminq in define mode failed on dim id %d",
- pname, dimid);
- ncclose(cdfid); return;
- }
- /* compare returned with expected values */
- if (strcmp(dim.name, test.dims[dimid].name) != 0) {
- error("%s: ncdiminq (define), name %s, expected %s for id = %d",
- pname, dim.name, test.dims[dimid].name, dimid);
- nerrs++;
- }
- if (dim.size != test.dims[dimid].size) {
- error("%s: ncdiminq (define), size %d, expected %d for id = %d",
- pname, dim.size, test.dims[dimid].size, dimid);
- nerrs++;
- }
- }
- /* try with bad dimension handles, check for failure */
- if (ncdiminq(cdfid, -1, dim.name, &dim.size) != -1 ||
- ncdiminq(cdfid, test.ndims, dim.name, &dim.size) != -1) {
- error("%s: ncdiminq should have failed on bad dimension ids",
- pname, dimid);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail, since bad handle */
- if (test.ndims >= 1) { /* if any dimensions have been defined */
- if (ncdiminq (cdfid, 0, dim.name, &dim.size) != -1) {
- error("%s: ncdiminq failed to report bad netcdf handle ", pname);
- nerrs++;
- }
- }
- free(dim.name);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-/*
- * Test ncdimrename
- * check that proper rename worked with ncdiminq
- * try renaming to existing dimension name, check error
- * try with bad dimension handle, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncdimrename(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncdimrename";
- int cdfid; /* netcdf id */
- int pp_dim; /* dimension id */
- static struct cdfdim pp = /* dimension */
- {"pp", 7};
- static char newname[MAX_NC_NAME] = /* dimension name */
- "new_name";
- struct cdfdim dim; /* dimension */
- static struct cdfdim qq = /* dimension */
- {"qq", 10};
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened */
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add two dimensions */
- if ((pp_dim = ncdimdef(cdfid, pp.name, pp.size)) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(cdfid); return;
- }
- add_dim(&test, &pp); /* keep in-memory netcdf in sync */
- if (ncdimdef(cdfid, qq.name, qq.size) == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(cdfid); return;
- }
- add_dim(&test, &qq); /* keep in-memory netcdf in sync */
- /* rename first dimension */
- if (ncdimrename(cdfid, pp_dim, newname) == -1) {
- error("%s: ncdimrename failed", pname);
- ncclose(cdfid); return;
- }
- /* check new name with ncdiminq */
- dim.name = (char *) emalloc(MAX_NC_NAME);
- if (ncdiminq(cdfid, pp_dim, dim.name, &dim.size) == -1) {
- error("%s: ncdiminq failed", pname);
- ncclose(cdfid); return;
- }
- if (strcmp(dim.name,pp.name) == 0) {
- error("%s: ncdimrename failed to change name", pname);
- ncclose(cdfid); return;
- }
- if (strcmp(dim.name,newname) != 0) {
- error("%s: ncdimrename changed name to %s instead of %s",
- pname, dim.name, newname);
- ncclose(cdfid); return;
- }
- test.dims[pp_dim].name = (char *) erealloc((void *)test.dims[pp_dim].name,
- strlen(newname)+1);
- (void) strcpy(test.dims[pp_dim].name, newname); /* keep test consistent */
- /* try to rename second dimension same as first, should fail */
- if (ncdimrename(cdfid, pp_dim, qq.name) != -1) {
- error("%s: ncdimrename should have failed with used name", pname);
- ncclose(cdfid); return;
- }
- /* try with bad dimension handles, check for failure */
- if (ncdimrename(cdfid, -1, dim.name) != -1 ||
- ncdimrename(cdfid, test.ndims, dim.name) != -1) {
- error("%s: ncdimrename should have failed on bad dimension ids",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
-
- /* in data mode, rename to shorter name */
- if (ncdimrename(cdfid, pp_dim, "p") == -1) {
- error("%s: ncdimrename to shorter name failed in data mode", pname);
- ncclose(cdfid); return;
- }
- test.dims[pp_dim].name = (char *) erealloc((void *)test.dims[pp_dim].name,
- strlen("p")+1);
- (void) strcpy(test.dims[pp_dim].name, "p"); /* keep test consistent */
- /* Check with ncdimid */
- if (pp_dim != ncdimid(cdfid, "p")) {
- error("%s: lookup by name in data mode failed after ncdimrename",
- pname);
- }
- /* in data mode, restore old name */
- if (ncdimrename(cdfid, pp_dim, pp.name) == -1) {
- error("%s: ncdimrename failed in data mode", pname);
- ncclose(cdfid); return;
- }
- test.dims[pp_dim].name = (char *) erealloc((void *)test.dims[pp_dim].name,
- strlen(pp.name)+1);
- (void) strcpy(test.dims[pp_dim].name, pp.name); /* keep test consistent */
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail, since bad handle */
- if (ncdimrename (cdfid, 0, dim.name) != -1) {
- error("%s: ncdimrename failed to report bad netcdf handle ", pname);
- nerrs++;
- }
- free (dim.name);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/driver.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/driver.c
deleted file mode 100644
index 796ddd4..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/driver.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/driver.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <netcdf.h>
-#include "tests.h"
-
- /*
- * Test driver for netCDF implementation. This program performs
- * tests against the netCDF specification for all user-level
- * functions in an implementation of the netCDF library. Must be
- * invoked from a directory in which the invoker has write
- * permission.
- */
-
-int
-main()
-{
- extern int ncopts; /* netCDF error options */
-
- static char testfile[] = "testfile.nc";
-
- ncopts &= ~NC_FATAL; /* make errors nonfatal */
- ncopts &= ~NC_VERBOSE; /* turn off error messages */
-
- test_nccreate(testfile);
-
- test_ncopen(testfile);
-
- test_ncredef(testfile);
-
- test_ncendef(testfile);
-
- test_ncclose(testfile);
-
- test_ncinquire(testfile);
-
- test_ncsync(testfile);
-
- test_ncabort(testfile);
-
- test_ncdimdef(testfile);
-
- test_ncdimid(testfile);
-
- test_ncdiminq(testfile);
-
- test_ncdimrename(testfile);
-
- test_ncvardef(testfile);
-
- test_ncvarid(testfile);
-
- test_ncvarinq(testfile);
-
- test_ncvarput1(testfile);
-
- test_ncvarget1(testfile);
-
- test_ncvarput(testfile);
-
- test_ncvarget(testfile);
-
- test_ncvarputg(testfile);
-
- test_ncvargetg(testfile);
-
- test_ncrecinq(testfile);
-
- test_ncrecput(testfile);
-
- test_ncrecget(testfile);
-
- test_ncvarrename(testfile);
-
- test_ncattput(testfile);
-
- test_ncattinq(testfile);
-
- test_ncattget(testfile);
-
- test_ncattcopy(testfile, "test2.nc");
-
- test_ncattname(testfile);
-
- test_ncattrename(testfile);
-
- test_ncattdel(testfile);
-
- test_nctypelen();
-
-#ifdef vms
-#define EXIT_SUCCESS 1
-#else
-#define EXIT_SUCCESS 0
-#endif
- return EXIT_SUCCESS;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.c
deleted file mode 100644
index 835cfa8..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-/*LINTLIBRARY*/
-#include <stdio.h>
-#include <stdlib.h>
-#include "error.h"
-#include "emalloc.h"
-
-void *
-emalloc (size) /* check return from malloc */
- size_t size;
-{
- void *p;
-
- if (size > (unsigned long)32767) {
- error ("absurd arg to emalloc: %lu", (unsigned long) size);
- return 0;
- }
- if (size == 0)
- return 0;
- p = (void *) malloc (size);
- if (p == 0) {
- error ("out of memory\n");
- exit (1);
- }
- return p;
-}
-
-void *
-erealloc (ptr, size) /* check return from realloc */
- void *ptr;
- size_t size;
-{
- void *p;
-
- if (size > (unsigned long)32767) {
- error ("absurd arg to erealloc %lu", (unsigned long) size);
- return 0;
- }
- p = (void *) realloc (ptr, size);
-
- if (p == 0) {
- error ("out of memory");
- exit(1);
- }
- return p;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.h
deleted file mode 100644
index eb9079d..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/emalloc.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header $
- *********************************************************************/
-#ifndef _EMALLOC_H_
-#define _EMALLOC_H_
-
-#include <stdlib.h> /* free() */
-
-#undef PROTO
-#ifndef NO_HAVE_PROTOTYPES
-# define PROTO(x) x
-#else
-# define PROTO(x) ()
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void *emalloc PROTO((
- size_t size
- ));
-
-extern void *erealloc PROTO((
- void *ptr,
- size_t size
- ));
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !_EMALLOC_H_ */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.c
deleted file mode 100644
index f99e45d..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-
-#ifndef NO_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <netcdf.h>
-#include "error.h"
-
-int error_count = 0;
-
-/*
- * Use for logging error conditions.
- */
-#ifndef NO_STDARG
-void
-error(char *fmt, ...)
-#else
-/*VARARGS1*/
-void
-error(fmt, va_alist)
- char *fmt ;
- va_dcl
-#endif
-{
- va_list args ;
-
- (void) fprintf(stderr,"*** ");
-
-#ifndef NO_STDARG
- va_start(args, fmt) ;
-#else
- va_start(args) ;
-#endif
- (void) vfprintf(stderr,fmt,args) ;
- va_end(args) ;
-
- (void) fprintf(stderr, "\n") ;
- error_count++;
-}
-
-
-/*
- * Turn off netCDF library handling of errors. Caller must check all error
- * returns after calling this, until on_errs() is called.
- */
-void
-off_errs()
-{
- extern int ncopts; /* error options */
- ncopts &= ~NC_FATAL; /* make errors nonfatal */
- ncopts &= ~NC_VERBOSE; /* turn off error messages */
-}
-
-
-/*
- * Let netCDF library handle subsequent errors. Callers don't need to check
- * error returns after this. (This is the initial default.)
- */
-void
-on_errs()
-{
- extern int ncopts; /* error options */
- ncopts |= NC_FATAL; /* make errors fatal */
- ncopts |= NC_VERBOSE; /* library prints error messages */
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.h
deleted file mode 100644
index 6721945..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/error.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header $
- *********************************************************************/
-
-#undef PROTO
-#ifndef NO_HAVE_PROTOTYPES
-# define PROTO(x) x
-#else
-# define PROTO(x) ()
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Print error message to stderr, don't exit */
-extern void error PROTO((
- char *fmt,
- ...
- ));
-
-/*
- * Turn off netCDF library handling of errors. Caller must check all error
- * returns after calling this, until on_errs() is called.
- */
-extern void off_errs PROTO((
- void
- ));
-
-/*
- * Let netCDF library handle subsequent errors. Callers don't need to check
- * error returns after this. (This is the initial default.)
- */
-extern void on_errs PROTO((
- void
- ));
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/misctest.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/misctest.c
deleted file mode 100644
index 6e1fe12..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/misctest.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/misctest.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-
-
-/*
- * Test nctypelen
- * try with bad datatype, check error
- * check returned values for each proper datatype
- */
-void
-test_nctypelen()
-{
- int nerrs = 0;
- static char pname[] = "test_nctypelen";
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if (nctypelen(NC_BYTE) != sizeof(char)) {
- error("%s: nctypelen failed for NC_BYTE", pname);
- nerrs++;
- }
- if (nctypelen(NC_CHAR) != sizeof(char)) {
- error("%s: nctypelen failed for NC_CHAR", pname);
- nerrs++;
- }
- if (nctypelen(NC_SHORT) != sizeof(short)) {
- error("%s: nctypelen failed for NC_SHORT", pname);
- nerrs++;
- }
- if (nctypelen(NC_LONG) != sizeof(nclong)) {
- error("%s: nctypelen failed for NC_LONG", pname);
- nerrs++;
- }
- if (nctypelen(NC_FLOAT) != sizeof(float)) {
- error("%s: nctypelen failed for NC_FLOAT", pname);
- nerrs++;
- }
- if (nctypelen(NC_DOUBLE) != sizeof(double)) {
- error("%s: nctypelen failed for NC_DOUBLE", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/nctime.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/nctime.c
deleted file mode 100644
index e1d5aab..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/nctime.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/*********************************************************************
- * Copyright 1989, University Corporation for Atmospheric Research
- * See netcdf/README file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/nctime.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-/*
- * This is a standalone benchmark program for timing netCDF hyperslab accesses.
- * Once it is built, the benchmarks are run by invoking it with the shape of a
- * four-dimensional netCDF variable, e.g.
- *
- * nctime 10 20 30 40
- *
- * which will run timing benchmarks accessing 1-, 2-, 3-, and 4-dimensional
- * slabs from 10 by 20 by 30 by 40 variables of each type. The first dimension
- * varies most slowly and is an unlimited (record) dimension.
- *
- * This program is especially useful for testing the effect of various compiler
- * optimization levels or platform-specific optimizations on the performance of
- * netCDF I/O.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/param.h> /* for HZ */
-#include <sys/times.h>
-#include <assert.h>
-#include <time.h>
-
-#ifndef HZ
-#ifdef CLK_TCK
-#define HZ CLK_TCK
-#else
-#define HZ 60
-#endif
-#endif
-
-#include "netcdf.h"
-
-struct ncdim { /* dimension */
- char *name;
- long size;
-};
-
-struct ncvar { /* variable */
- char *name;
- nc_type type;
- int ndims;
- int *dims;
- int natts;
-};
-
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-
-/* Number of dimensions. Changing this requires other changes as well. */
-#define NDIMS 4
-
-#define NVARS 6 /* number of variables, one for each type */
-
-/* Any function that maps dimension values 1-1 to values is OK here */
-#define VF(w) 1000*w[0]+100*w[1]+10*w[2]+w[3]
-
-/*
- * Fill typed array element with specified value, that is
- *
- * v[ii] = val;
- */
-static void
-val_stuff(type, v, ii, val) /* v[ii] = val */
- nc_type type; /* netcdf type of v, NC_BYTE, ..., NC_DOUBLE */
- void *v; /* array of specified type */
- int ii; /* it's v[ii] we want to store into */
- long val; /* value to store */
-{
- union gp {
- char cp[1];
- short sp[1];
- nclong lp[1];
- float fp[1];
- double dp[1];
- } *gp;
-
- gp = (union gp *) v;
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- gp->cp[ii] = (char) val;
- break;
- case NC_SHORT:
- gp->sp[ii] = (short) val;
- break;
- case NC_LONG:
- gp->lp[ii] = (nclong) val;
- break;
- case NC_FLOAT:
- gp->fp[ii] = (float) val;
- break;
- case NC_DOUBLE:
- gp->dp[ii] = (double) val;
- break;
- }
-}
-
-
-/*
- * Compare typed array element with specified value, that is return
- *
- * (v[ii] != val)
- *
- * returns 0 if equal, 1 if not equal
- */
-
-static int
-val_diff(type, v, ii, val) /* v[ii] != val */
- nc_type type; /* netcdf type of v, NC_BYTE, ..., NC_DOUBLE */
- void *v; /* array of specified type */
- int ii; /* it's v[ii] we want to compare */
- long val; /* value to compare with */
-{
- union gp {
- char cp[1];
- short sp[1];
- nclong lp[1];
- float fp[1];
- double dp[1];
- } *gp;
-
- gp = (union gp *) v;
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- return (gp->cp[ii] != (char) val);
- case NC_SHORT:
- return (gp->sp[ii] != (short) val);
- case NC_LONG:
- return (gp->lp[ii] != (nclong) val);
- case NC_FLOAT:
- return (gp->fp[ii] != (float) val);
- case NC_DOUBLE:
- return (gp->dp[ii] != (double) val);
- }
- /* NOTREACHED */
-}
-
-/*
- * The following timing macros can be used by including the necessary
- * declarations with
- *
- * TIMING_DECLS ;
- *
- * and surrounding sections of code to be timed with the "statements"
- *
- * TIMING_START ;
- * [code to be timed goes here]
- * TIMING_END ;
- *
- * (The terminating semicolon is required for TIMING_DECLS and TIMING_END.)
- * The macros assume the user has stored a description of what is being timed
- * in the user-declared string time_mess, and has included <sys/times.h>
- */
-
-#define TIMING_DECLS \
- long TMreps; /* counts repetitions of timed code */ \
- long TMrepeats; /* repetitions needed to exceed a second */ \
- clock_t TMus, TMsy; /* user and system time in clock ticks */ \
- float TMelapsed; /* elapsed time in seconds */ \
- struct tms TMru;
-
-#define TIMING_START \
- TMrepeats = 1; \
- do { /* loop enough times for at least 0.1 second elapsed time */ \
- TMrepeats *= 2; \
- times(&TMru); \
- TMus = TMru.tms_utime; \
- TMsy = TMru.tms_stime; \
- for(TMreps=0;TMreps < TMrepeats;TMreps++) {
-
-#define TIMING_END \
- } \
- times(&TMru); \
- TMus = TMru.tms_utime - TMus; \
- TMsy = TMru.tms_stime - TMsy; \
- TMelapsed= (float) (TMus+TMsy) / (float) HZ; \
- if (TMreps < TMrepeats) break; \
- } while (TMelapsed < 0.1 ); \
- printf("time for %-20.20s %10.3f msec\n", \
- time_mess, TMelapsed*1000./(TMreps+1))
-
-
-
-/*
- * For each type of variable, put a four-dimensional hypercube of values
- * with a single call to ncvarput. Then use ncvarget to retrieve a single
- * value, a vector of values along each of the four dimensions, a plane of
- * values along each of the six pairs of dimensions, a cube of values along
- * each of the four triples of dimensions, and all the values.
- */
-void
-test_slabs(ncid, sizes)
- int ncid; /* handle of netcdf open and in data mode */
- int *sizes; /* dimension sizes */
-{
- char time_mess[100];
-
- struct ncdim dims[NDIMS];
- int dimids[NDIMS]; /* dimension ids */
- long corner[NDIMS], edge[NDIMS], point[NDIMS];
-
- static struct ncvar va[NVARS] = { /* variables of all types */
- {"byte_var", NC_BYTE, NDIMS, 0, 0},
- {"char_var", NC_CHAR, NDIMS, 0, 0},
- {"short_var", NC_SHORT, NDIMS, 0, 0},
- {"long_var", NC_LONG, NDIMS, 0, 0},
- {"float_var", NC_FLOAT, NDIMS, 0, 0},
- {"double_var", NC_DOUBLE, NDIMS, 0, 0},
- };
- void *v;
-
- int varid[NVARS], iv; /* variable id */
- int idim, jdim, kdim, ldim;
- int iw, ix, iy, iz, ii, jj, kk;
- static char* dnames[] = {"w", "x", "y", "z", "u", "v", "a", "b", "c", "d"};
-
- assert(NDIMS <= LEN_OF(dnames));
- for (idim = 0; idim < NDIMS; idim++) {
- dims[idim].size = sizes[idim];
- dims[idim].name = dnames[idim];
- }
-
- /* back in define mode OK, now add dimensions */
-
- dimids[0] = ncdimdef(ncid, dims[0].name, NC_UNLIMITED);
- if (dimids[0] == -1) {
- ncclose(ncid);
- return;
- }
- for (idim = 1; idim < NDIMS; idim++) {
- dimids[idim] = ncdimdef(ncid, dims[idim].name, dims[idim].size);
- if (dimids[idim] == -1) {
- ncclose(ncid);
- return;
- }
- }
-
- /* define a multi-dimensional variable of each type */
-
- for (iv = 0; iv < NVARS; iv++) {
- va[iv].dims = (int *) malloc(sizeof(int) * (unsigned)va[iv].ndims);
- for (idim = 0; idim < va[iv].ndims; idim++)
- va[iv].dims[idim] = dimids[idim];
- varid[iv] = ncvardef(ncid, va[iv].name, va[iv].type, va[iv].ndims,
- va[iv].dims);
- if (varid[iv] == -1) {
- ncclose(ncid); return;
- }
- }
-
- if (ncendef (ncid) == -1) {
- ncclose(ncid); return;
- }
-
- printf("Note: first ncvarput writes fill values for all variables.\n");
-
- for (iv = 0; iv < NVARS; iv++) { /* test each type of variable */
- TIMING_DECLS ;
- printf("\n----- %s(%d,%d,%d,%d)\n",
- va[iv].name, sizes[0], sizes[1], sizes[2], sizes[3]);
-
- v = (void *) malloc((unsigned)sizes[0]*sizes[1]*sizes[2]*sizes[3]
- * nctypelen(va[iv].type));
-
- /* fill it with values using a function of dimension indices */
- ii = 0;
- for (iw=0; iw < sizes[0]; iw++) {
- corner[0] = iw;
- for (ix=0; ix < sizes[1]; ix++) {
- corner[1] = ix;
- for (iy=0; iy < sizes[2]; iy++) {
- corner[2] = iy;
- for (iz=0; iz < sizes[3]; iz++) {
- corner[3] = iz;
- /* v[ii++] = VF(corner); */
- val_stuff(va[iv].type, v, ii, VF(corner));
- ii++;
- }
- }
- }
- }
-
- for (idim = 0; idim < NDIMS; idim++) {
- corner[idim] = 0;
- edge[idim] = dims[idim].size;
- }
-
- sprintf(time_mess,"ncvarput %ldx%ldx%ldx%ld",
- edge[0], edge[1], edge[2], edge[3]);
-
- TIMING_START ;
- /* ncvarput the whole variable */
- if (ncvarput(ncid, varid[iv], corner, edge, (void *) v) == -1) {
- ncclose(ncid);
- return;
- }
- TIMING_END ;
-
- /*
- * For several combinations of fixed dimensions, get a slab and compare
- * values to function values.
- */
-
- /* get an interior point */
- for (idim=0; idim < NDIMS; idim++) {
- corner[idim] = dims[idim].size/2;
- edge[idim] = 1;
- point[idim] = corner[idim];
- }
-
- sprintf(time_mess,"ncvarget %ldx%ldx%ldx%ld"
- ,edge[0],edge[1],edge[2],edge[3]);
-
- TIMING_START ;
- if (ncvarget(ncid, varid[iv], corner, edge, (void *) v) == -1)
- return;
- TIMING_END ;
-
- /* if (v[0] != VF(point)) */
- if (val_diff(va[iv].type, v, 0, VF(point)))
- fprintf(stderr,"ncvarget got wrong value for point");
-
- /* get a vector in each direction */
- for (idim=0; idim < NDIMS; idim++) {
- for (jdim=0; jdim < NDIMS; jdim++) {
- corner[jdim] = 0;
- edge[jdim] = 1;
- point[jdim] = corner[jdim];
- }
- corner[idim] = 0; /* get vector along dimension idim */
- edge[idim] = dims[idim].size;
-
- sprintf(time_mess,"ncvarget %ldx%ldx%ldx%ld"
- ,edge[0],edge[1],edge[2],edge[3]);
-
- TIMING_START ;
- if (ncvarget(ncid, varid[iv], corner, edge, (void *) v) == -1)
- return;
- TIMING_END ;
-
- for (ii=corner[idim]; ii < edge[idim]; ii++) {
- point[idim] = ii;
- /* if (v[ii] != VF(point)) */
- if (val_diff(va[iv].type, v, ii, VF(point)))
- fprintf(stderr,"ncvarget got wrong value for vector");
- }
- }
-
- /* get a plane in each direction */
- for (idim=0; idim < NDIMS; idim++) {
- for (jdim=idim+1; jdim < NDIMS; jdim++) {
- for (kdim=0; kdim < NDIMS; kdim++) { /* reset corners and edges */
- corner[kdim] = 0;
- edge[kdim] = 1;
- point[kdim] = corner[kdim];
- }
- corner[idim] = 0; /* plane along dimensions idim jdim */
- corner[jdim] = 0;
- edge[idim] = dims[idim].size;
- edge[jdim] = dims[jdim].size;
-
- sprintf(time_mess,"ncvarget %ldx%ldx%ldx%ld"
- ,edge[0],edge[1],edge[2],edge[3]);
-
- TIMING_START ;
- if (ncvarget(ncid, varid[iv], corner, edge, (void *) v) == -1)
- return;
- TIMING_END ;
-
- for (ii=corner[idim]; ii < edge[idim]; ii++) {
- for (jj=corner[jdim]; jj < edge[jdim]; jj++) {
- point[idim] = ii;
- point[jdim] = jj;
- /* if (v[(ii)*edge[jdim]+jj] != VF(point)) { */
- if (val_diff(va[iv].type, v,
- (ii)*(int)edge[jdim]+jj, VF(point))) {
- fprintf(stderr,
- "ncvarget got wrong value in plane");
- }
- }
- }
- }
- }
-
- /* get a cube in each direction */
- for (idim=0; idim < NDIMS; idim++) {
- for (jdim=idim+1; jdim < NDIMS; jdim++) {
- for (kdim=jdim+1; kdim < NDIMS; kdim++) {
- for (ldim=0; ldim < NDIMS; ldim++) { /* reset corners, edges */
- corner[ldim] = 0;
- edge[ldim] = 1;
- point[ldim] = corner[ldim];
- }
- corner[idim] = 0; /* intr. cube along idim jdim kdim */
- corner[jdim] = 0;
- corner[kdim] = 0;
- edge[idim] = dims[idim].size;
- edge[jdim] = dims[jdim].size;
- edge[kdim] = dims[kdim].size;
-
- sprintf(time_mess,"ncvarget %ldx%ldx%ldx%ld"
- ,edge[0],edge[1],edge[2],edge[3]);
-
- TIMING_START ;
- if (ncvarget(ncid, varid[iv], corner, edge,
- (void *) v) == -1)
- return;
- TIMING_END ;
-
- for (ii=corner[idim]; ii < edge[idim]; ii++) {
- for (jj=corner[jdim]; jj < edge[jdim]; jj++) {
- for (kk=corner[kdim]; kk < edge[kdim]; kk++) {
- point[idim] = ii;
- point[jdim] = jj;
- point[kdim] = kk;
- /* if (v[((ii)*edge[jdim]+jj)*
- edge[kdim]+kk] != VF(point)) { */
- if (val_diff(va[iv].type,v,
- ((ii)*(int)edge[jdim]+jj)*
- (int)edge[kdim]+kk,VF(point))) {
- fprintf(stderr,
- "ncvarget - bad value in cube");
- }
- }
- }
- }
- }
- }
- }
-
- /* get one 4-D slab of data */
- for(idim = 0; idim < NDIMS; idim++) {
- corner[idim] = 0;
- edge[idim] = dims[idim].size;
- }
-
- sprintf(time_mess,"ncvarget %ldx%ldx%ldx%ld"
- ,edge[0],edge[1],edge[2],edge[3]);
-
- TIMING_START ;
- if (ncvarget(ncid, varid[iv], corner, edge, (void *) v) == -1)
- return;
- TIMING_END ;
-
- free(v);
- }
-}
-
-void
-usage(argv)
- char **argv;
-{
- int i;
- fprintf(stderr, "usage: %s ", argv[0]);
- for (i=0; i < NDIMS; i++)
- fprintf(stderr, "dim%d ", i);
- fprintf(stderr, "\n");
-}
-
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- int ncid;
- int i;
- int w[NDIMS];
-
- if (argc != NDIMS+1) {
- usage(argv);
- return -1;
- }
- for (i = 0; i < NDIMS; i++)
- w[i] = atoi(argv[i+1]);
-
- ncid = nccreate("benchmark.nc",NC_CLOBBER);
-
- test_slabs(ncid, w);
-
- ncclose(ncid);
- return 0;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/rec.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/rec.c
deleted file mode 100644
index 6bd79d3..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/rec.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*********************************************************************
- * Copyright 1993, University Corporation for Atmospheric Research
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/rec.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "emalloc.h"
-#include "val.h"
-#include "error.h"
-#include "tests.h"
-
-/*
- * Returns number of record variables in an open netCDF file, and an array of
- * the record variable ids, if the array parameter is non-null. Returns -1 on
- * error.
- */
-static int
-numrecvars(ncid, recvarids)
- int ncid;
- int *recvarids;
-{
- int ndims, iv, nvars;
- int nrecvars;
- int recdimid;
- int dimids[MAX_NC_DIMS];
-
- if (ncinquire(ncid, 0, &nvars, 0, &recdimid) == -1)
- return -1;
- if (recdimid == -1)
- return 0;
- nrecvars = 0;
- for (iv = 0; iv < nvars; iv++) {
- if (ncvarinq(ncid, iv, 0, 0, &ndims, dimids, 0) == -1)
- return -1;
- if (ndims > 0 && dimids[0] == recdimid) {
- if (recvarids)
- recvarids[nrecvars] = iv;
- nrecvars++;
- }
- }
- return nrecvars;
-}
-
-
-/*
- * Returns record size (in bytes) of the record variable with a specified
- * variable id. Returns 0 if not a record variable. Returns -1 on error.
- */
-static long
-ncrecsize(ncid,vid)
- int ncid;
- int vid;
-{
- int recdimid;
- nc_type type;
- int ndims;
- int dimids[MAX_NC_DIMS];
- int id;
- long size;
-
- if (ncinquire(ncid, 0, 0, 0, &recdimid) == -1)
- return -1;
- if (ncvarinq(ncid, vid, 0, &type, &ndims, dimids, 0) == -1)
- return -1;
- if (ndims == 0 || dimids[0] != recdimid)
- return 0;
- size = nctypelen(type);
- for (id = 1; id < ndims; id++) {
- long len;
- (void) ncdiminq(ncid, dimids[id], 0, &len);
- size *= len;
- }
- return size;
-}
-
-
-/*
- * Retrieves the number of record variables, the record variable ids, and the
- * record size of each record variable. If any pointer to info to be returned
- * is null, the associated information is not returned. Returns -1 on error.
- * This is the same as the ncrecinq() in the library, except that can handle
- * errors better.
- */
-static int
-recinq(ncid, nrecvars, recvarids, recsizes)
- int ncid;
- int *nrecvars;
- int *recvarids;
- long *recsizes;
-{
- int iv;
- int rvarids[MAX_NC_VARS];
- int nrvars = numrecvars(ncid, rvarids);
-
- if (nrvars == -1)
- return -1;
-
- if (nrecvars)
- *nrecvars = nrvars;
- if (recvarids)
- for (iv = 0; iv < nrvars; iv++)
- recvarids[iv] = rvarids[iv];
- if (recsizes)
- for (iv = 0; iv < nrvars; iv++)
- recsizes[iv] = ncrecsize(ncid, rvarids[iv]);
- return 0;
-}
-
-
-/*
- * Test ncrecinq
- * try in both data and define modes
- * check returned values against independently computed values
- * try with bad netCDF handle, check error
- */
-void
-test_ncrecinq(path)
- char *path; /* name of netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncrecinq";
- int ncid;
- int nrvars; /* number of record variables */
- int rvarids[MAX_NC_VARS]; /* id of each record variable */
- long rvarsizes[MAX_NC_VARS]; /* record size of each record variable */
- int tnrvars; /* true number of record variables */
- int trvarids[MAX_NC_VARS]; /* true id of each record variable */
- long trvarsizes[MAX_NC_VARS]; /* true rec size of each record variable */
- int iv;
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
-
- /* First compute independently what ncrecinq should return */
- if (recinq(ncid, &tnrvars, trvarids, trvarsizes) == -1) {
- error("%s: recinq failed", pname);
- ncclose(ncid);
- return;
- }
-
- /* check that ncrecinq() returns correct information in data mode */
- if (ncrecinq(ncid, &nrvars, rvarids, rvarsizes) == -1) {
- error("%s: ncrecinq failed", pname);
- ncclose(ncid);
- return;
- }
-
- if (nrvars != tnrvars) {
- error("ncrecinq returned wrong number of rec vars, %d != %d",
- nrvars, tnrvars);
- nerrs++;
- }
-
- for (iv = 0; iv < nrvars; iv++) {
- if (rvarids[iv] != trvarids[iv]) {
- error("ncrecinq returned wrong record id for var %d",
- trvarids[iv]);
- nerrs++;
- }
- if (rvarsizes[iv] != trvarsizes[iv]) {
- error("ncrecinq returned wrong record size for var %d",
- trvarids[iv]);
- nerrs++;
- }
- }
-
- if (ncredef(ncid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid);
- return;
- }
- /* check that ncrecinq() returns correct information in define mode too */
- if (ncrecinq(ncid, &nrvars, rvarids, rvarsizes) == -1) {
- error("%s: ncrecinq failed in define mode", pname);
- ncclose(ncid);
- return;
- }
- if (nrvars != tnrvars) {
- error("define mode, ncrecinq returned wrong num of rec vars, %d != %d",
- nrvars, tnrvars);
- nerrs++;
- }
- for (iv = 0; iv < nrvars; iv++) {
- if (rvarids[iv] != trvarids[iv]) {
- error("define mode, ncrecinq returned wrong record id for var %d",
- trvarids[iv]);
- nerrs++;
- }
- if (rvarsizes[iv] != trvarsizes[iv]) {
- error("define mode, ncrecinq returned wrong rec size for var %d",
- trvarids[iv]);
- nerrs++;
- }
- }
-
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
-
- if (ncrecinq(ncid, &nrvars, rvarids, rvarsizes) != -1) {
- error("%s: ncrecinq failed to report bad handle", pname);
- nerrs++;
- }
-
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Retrieves the dimension sizes of a variable with a specified variable id in
- * an open netCDF file. Returns -1 on error.
- */
-static int
-dimsizes(ncid, varid, sizes)
- int ncid;
- int varid;
- long *sizes;
-{
- int ndims;
- int id;
- int dimids[MAX_NC_DIMS];
-
- if (ncvarinq(ncid, varid, 0, 0, &ndims, dimids, 0) == -1)
- return -1;
- if (ndims == 0 || sizes == 0)
- return 0;
- for (id = 0; id < ndims; id++)
- (void) ncdiminq(ncid, dimids[id], 0, &sizes[id]);
- return 0;
-}
-
-
-/*
- * Write one record's worth of data, except don't write to variables for which
- * the address of the data to be written is NULL. Return -1 on error. This is
- * the same as the ncrecput() in the library, except that can handle errors
- * better.
- */
-static int
-recput(ncid, recnum, datap)
- int ncid;
- long recnum;
- void **datap;
-{
- int iv;
- int rvids[MAX_NC_VARS];
- int nrvars = numrecvars(ncid, rvids);
- long start[MAX_NC_DIMS];
- long edges[MAX_NC_DIMS];
-
- if (nrvars == -1)
- return -1;
-
- start[0] = recnum;
- for (iv = 1; iv < nrvars; iv++)
- start[iv] = 0;
-
- for (iv = 0; iv < nrvars; iv++) {
- if (datap[iv] != 0) {
- (void) dimsizes(ncid, rvids[iv], edges);
- edges[0] = 1; /* only 1 record's worth */
- if (ncvarput(ncid, rvids[iv], start, edges, datap[iv]) == -1)
- return -1;
- }
- }
- return 0;
-}
-
-
-/*
- * Read one record's worth of data, except don't read from variables for which
- * the address of the data to be read is null. Return -1 on error. This is
- * the same as the ncrecget() in the library, except that can handle errors
- * better.
- */
-static int
-recget(ncid, recnum, datap)
- int ncid;
- long recnum;
- void **datap;
-{
- int iv;
- int rvids[MAX_NC_VARS];
- int nrvars = numrecvars(ncid, rvids);
- long start[MAX_NC_DIMS];
- long edges[MAX_NC_DIMS];
-
- if (nrvars == -1)
- return -1;
-
- start[0] = recnum;
- for (iv = 1; iv < nrvars; iv++)
- start[iv] = 0;
-
- for (iv = 0; iv < nrvars; iv++) {
- if (datap[iv] != 0) {
- (void) dimsizes(ncid, rvids[iv], edges);
- edges[0] = 1; /* only 1 record's worth */
- if (ncvarget(ncid, rvids[iv], start, edges, datap[iv]) == -1)
- return -1;
- }
- }
- return 0;
-}
-
-
-/*
- * Test ncrecput
- * check that proper call works putting all recoerd variables
- * try putting only a proper subset of variables
- * try putting the empty subset of variables
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncrecput(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncrecput";
- int nrvars; /* number of record variables */
- int rvarids[MAX_NC_VARS]; /* id of each record variable */
- long rvarsizes[MAX_NC_VARS]; /* record size of each record variable */
- int ncid; /* netcdf id */
- void *datap[MAX_NC_VARS]; /* array of address pointers for rec vars */
- void *datar[MAX_NC_VARS]; /* pointers for comparison data */
- long recnum = 1; /* we'll write the second record */
- int iv;
- long recsize[MAX_NC_VARS]; /* record size in data elements */
- nc_type vartype[MAX_NC_VARS];
- void *zeros[MAX_NC_VARS];
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
-
- if (ncrecinq(ncid, &nrvars, rvarids, rvarsizes) == -1) {
- error("%s: ncrecinq failed", pname);
- ncclose(ncid);
- return;
- }
-
- /* get a block of data of the right type for each record variable */
- for (iv = 0; iv < nrvars; iv++) {
- datap[iv] = emalloc(rvarsizes[iv]);
- datar[iv] = emalloc(rvarsizes[iv]); /* for comparison values */
- if (ncvarinq(ncid, rvarids[iv], 0, &vartype[iv], 0, 0, 0) == -1) {
- error("%s: ncvarinq failed", pname);
- ncclose(ncid);
- return;
- }
- recsize[iv] = rvarsizes[iv]/nctypelen(vartype[iv]);
- /* Fill data blocks with 0,1,2,3,... */
- val_fill(vartype[iv], recsize[iv], datap[iv]);
- /* Zero out comparison data */
- val_fill_zero(vartype[iv], recsize[iv], datar[iv]);
- }
-
- /* Zero data in recnum record, before trying to put non-zero data */
- if (recput(ncid, recnum, datar) == -1) {
- error("%s: recput failed", pname);
- ncclose(ncid);
- return;
- }
-
- /* opened in data mode, try putting a complete record */
- if (ncrecput(ncid, recnum, datap) == -1) {
- error("%s: ncrecput failed on complete record", pname);
- nerrs++;
- }
-
- /* Check that right values were put */
- if (recget(ncid, recnum, datar) == -1) {
- error("%s: recget failed", pname);
- nerrs++;
- }
- for (iv = 0; iv < nrvars; iv++) {
- if (val_cmp(vartype[iv], recsize[iv], datap[iv], datar[iv]) != 0) {
- error("%s: bad values written by recput", pname);
- nerrs++;
- }
- val_fill_zero(vartype[iv], recsize[iv], datap[iv]);
- val_fill_zero(vartype[iv], recsize[iv], datar[iv]);
- zeros[iv] = 0;
- }
-
- if (nrvars > 0) {
- void *datap0 = datap[0];
-
- /* put a partial record, everything but first record variable */
- datap[0] = 0;
- val_fill(vartype[0], recsize[0], datar[0]);
- if (ncrecput(ncid, recnum, datap) == -1) {
- error("%s: ncrecput failed on partial record", pname);
- nerrs++;
- }
-
- /* Check right values were put, first record variable undisturbed */
- datap[0] = datap0;
- if (recget(ncid, recnum, datap) == -1) {
- error("%s: recget failed after partial record put", pname);
- nerrs++;
- }
- for (iv = 0; iv < nrvars; iv++) {
- if (val_cmp(vartype[iv], recsize[iv], datap[iv], datar[iv]) != 0) {
- error("%s: bad values written by partial recput", pname);
- nerrs++;
- }
- }
- }
-
- /* Put an empty record, check that values remain undisturbed */
- if (ncrecput(ncid, recnum, zeros) == -1) {
- error("%s: ncrecput failed on empty record", pname);
- nerrs++;
- }
- if (recget(ncid, recnum, datap) == -1) {
- error("%s: recget failed after empty record put", pname);
- nerrs++;
- }
- for (iv = 0; iv < nrvars; iv++) {
- if (val_cmp(vartype[iv], recsize[iv], datap[iv], datar[iv]) != 0) {
- error("%s: bad values written by empty recput", pname);
- nerrs++;
- }
- }
-
- /* try in define mode, check error */
- if (ncredef(ncid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(ncid);
- return;
- }
-
- if (ncrecput(ncid, recnum, datap) != -1) {
- error("%s: ncrecput should fail in define mode", pname);
- nerrs++;
- }
-
- /* try with bad netCDF handle, check error */
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- if (ncrecput(ncid, recnum, datap) != -1) {
- error("%s: ncrecput failed to report bad handle", pname);
- nerrs++;
- }
- for (iv = 0; iv < nrvars; iv++) {
- free(datap[iv]);
- free(datar[iv]);
- }
-
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncrecget
- * check that proper call works getting all record variables
- * try getting only a proper subset of variables
- * try getting the empty subset of variables
- * try with bad netCDF handle, check error
- */
-void
-test_ncrecget(path)
- char *path; /* name of netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncrecget";
- int nrvars; /* number of record variables */
- int rvarids[MAX_NC_VARS]; /* id of each record variable */
- long rvarsizes[MAX_NC_VARS]; /* record size of each record variable */
- int ncid; /* netcdf id */
- void *datap[MAX_NC_VARS]; /* array of address pointers for rec vars */
- void *datar[MAX_NC_VARS]; /* pointers for comparison data */
- long recnum = 1; /* we'll write the second record */
- int iv;
- long recsize[MAX_NC_VARS]; /* record size in data elements */
- nc_type vartype[MAX_NC_VARS];
- void *zeros[MAX_NC_VARS];
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((ncid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
-
- if (ncrecinq(ncid, &nrvars, rvarids, rvarsizes) == -1) {
- error("%s: ncrecinq failed", pname);
- ncclose(ncid);
- return;
- }
-
- /* get a block of data of the right type for each record variable */
- for (iv = 0; iv < nrvars; iv++) {
- datap[iv] = emalloc(rvarsizes[iv]);
- datar[iv] = emalloc(rvarsizes[iv]); /* for comparison values */
- if (ncvarinq(ncid, rvarids[iv], 0, &vartype[iv], 0, 0, 0) == -1) {
- error("%s: ncvarinq failed", pname);
- ncclose(ncid);
- return;
- }
- recsize[iv] = rvarsizes[iv]/nctypelen(vartype[iv]);
- /* Fill data blocks with 0,1,2,3,... */
- val_fill(vartype[iv], recsize[iv], datap[iv]);
- /* Zero out comparison data */
- val_fill_zero(vartype[iv], recsize[iv], datar[iv]);
- }
-
- if (recput(ncid, recnum, datap) == -1) {
- error("%s: recput failed", pname);
- ncclose(ncid);
- return;
- }
-
- /* opened in data mode, try getting a complete record */
- if (recget(ncid, recnum, datap) == -1) {
- error("%s: recget failed on complete record", pname);
- nerrs++;
- }
- if (ncrecget(ncid, recnum, datar) == -1) {
- error("%s: ncrecget failed on complete record", pname);
- nerrs++;
- }
-
- for (iv = 0; iv < nrvars; iv++) {
- if (val_cmp(vartype[iv], recsize[iv], datap[iv], datar[iv]) != 0) {
- error("%s: bad values written by recget", pname);
- nerrs++;
- }
- val_fill_zero(vartype[iv], recsize[iv], datap[iv]);
- val_fill_zero(vartype[iv], recsize[iv], datar[iv]);
- zeros[iv] = 0;
- }
-
- if (nrvars > 0) {
- void *datap0 = datap[0];
- void *datar0 = datar[0];
-
- /* get a partial record, everything but first record variable */
- datap[0] = 0;
- if (ncrecget(ncid, recnum, datap) == -1) {
- error("%s: ncrecget failed on partial record", pname);
- nerrs++;
- }
- datar[0] = 0;
- if (recget(ncid, recnum, datar) == -1) {
- error("%s: recget failed on partial record", pname);
- nerrs++;
- }
- /* Check right values were got, first record variable undisturbed */
- datap[0] = datap0;
- datar[0] = datar0;
- for (iv = 0; iv < nrvars; iv++) {
- if (val_cmp(vartype[iv], recsize[iv], datap[iv], datar[iv]) != 0) {
- error("%s: bad values read by partial recget", pname);
- nerrs++;
- }
- }
- }
-
- /* Get an empty record */
- if (ncrecget(ncid, recnum, zeros) == -1) {
- error("%s: ncrecget failed on empty record", pname);
- nerrs++;
- }
-
- /* try with bad netCDF handle, check error */
- if (ncclose (ncid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- if (ncrecget(ncid, recnum, datap) != -1) {
- error("%s: ncrecget failed to report bad handle", pname);
- nerrs++;
- }
- for (iv = 0; iv < nrvars; iv++) {
- free(datap[iv]);
- free(datar[iv]);
- }
-
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/slabs.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/slabs.c
deleted file mode 100644
index 032ca97..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/slabs.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/slabs.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "emalloc.h"
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-#include "tests.h"
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-/* dimension sizes */
-#define NDIMS 4 /* number of dimensions */
-#define WSIZE 7 /* sizes of dimensions */
-#define XSIZE 5
-#define YSIZE 6
-#define ZSIZE 4
-/* Any function that maps dimension values 1-1 to values is OK here */
-#define VF(w) 1000*w[0]+100*w[1]+10*w[2]+w[3]
-#define NVARS 6 /* number of variables */
-
-
-/*
- * Fill typed array element with specified value, that is
- *
- * v[ii] = val;
- */
-static void
-val_stuff(type, v, ii, val) /* v[ii] = val */
- nc_type type; /* netcdf type of v, NC_BYTE, ..., NC_DOUBLE */
- void *v; /* array of specified type */
- int ii; /* it's v[ii] we want to store into */
- long val; /* value to store */
-{
- static char pname[] = "val_stuff";
- union gp {
- char cp[1];
- short sp[1];
- nclong lp[1];
- float fp[1];
- double dp[1];
- } *gp;
-
- gp = (union gp *) v;
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- gp->cp[ii] = (char) val;
- break;
- case NC_SHORT:
- gp->sp[ii] = (short) val;
- break;
- case NC_LONG:
- gp->lp[ii] = (nclong) val;
- break;
- case NC_FLOAT:
- gp->fp[ii] = (float) val;
- break;
- case NC_DOUBLE:
- gp->dp[ii] = (double) val;
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
-}
-
-
-/*
- * Compare typed array element with specified value, that is return
- *
- * (v[ii] != val)
- *
- * returns 0 if equal, 1 if not equal
- */
-
-static int
-val_diff(type, v, ii, val) /* v[ii] != val */
- nc_type type; /* netcdf type of v, NC_BYTE, ..., NC_DOUBLE */
- void *v; /* array of specified type */
- int ii; /* it's v[ii] we want to compare */
- long val; /* value to compare with */
-{
- static char pname[] = "val_diff";
- union gp {
- char cp[1];
- short sp[1];
- nclong lp[1];
- float fp[1];
- double dp[1];
- } *gp;
-
- gp = (union gp *) v;
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- return (gp->cp[ii] != (char) val);
- case NC_SHORT:
- return (gp->sp[ii] != (short) val);
- case NC_LONG:
- return (gp->lp[ii] != (nclong) val);
- case NC_FLOAT:
- return (gp->fp[ii] != (float) val);
- case NC_DOUBLE:
- return (gp->dp[ii] != (double) val);
- default:
- error("%s: bad type, test program error", pname);
- return (-1);
- }
-}
-
-
-/*
- * For each type of variable, put a four-dimensional hypercube of values
- * with a single call to ncvarput. Then use ncvarget to retrieve a single
- * interior value, an interior vector of values along each of the four
- * dimensions, an interior plane of values along each of the six pairs of
- * dimensions, and an interior cube of values along each of the four
- * triples of dimensions. In each case, compare the retrieved values with
- * the written values.
- */
-
-int
-test_slabs(cdfid)
- int cdfid; /* handle of netcdf open and in data mode */
-{
- int nerrs = 0;
- static char pname[] = "test_slabs";
- static struct cdfdim dims[NDIMS] = {
- {"w", WSIZE},
- {"x", XSIZE},
- {"y", YSIZE},
- {"z", ZSIZE}
- };
- int dimids[NDIMS]; /* dimension ids */
- long corner[NDIMS], edge[NDIMS], point[NDIMS];
-
- static struct cdfvar va[NVARS] = { /* variables of all types */
- {"bytevar", NC_BYTE, NDIMS, ___, 0},
- {"charvar", NC_CHAR, NDIMS, ___, 0},
- {"shortvar", NC_SHORT, NDIMS, ___, 0},
- {"longvar", NC_LONG, NDIMS, ___, 0},
- {"floatvar", NC_FLOAT, NDIMS, ___, 0},
- {"doublevar", NC_DOUBLE, NDIMS, ___, 0},
- };
- void *v;
-
- int varid[NVARS], iv; /* variable id */
- int idim, jdim, kdim, ldim;
- int iw, ix, iy, iz, ii, jj, kk;
-
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return 1;
- }
-
- /* back in define mode OK, now add dimensions */
-
- for (idim = 0; idim < NDIMS; idim++) {
- dimids[idim] = ncdimdef(cdfid, dims[idim].name, dims[idim].size);
- if (dimids[idim] == -1) {
- error("%s: ncdimdef failed", pname);
- ncclose(cdfid);
- return 1;
- }
- add_dim(&test, &dims[idim]);
- }
-
- /* define a multi-dimensional variable of each type */
-
- for (iv = 0; iv < NVARS; iv++) {
- va[iv].dims = (int *) emalloc(sizeof(int) * va[iv].ndims);
- for (idim = 0; idim < va[iv].ndims; idim++)
- va[iv].dims[idim] = dimids[idim];
- varid[iv] = ncvardef(cdfid, va[iv].name, va[iv].type, va[iv].ndims,
- va[iv].dims);
- if (varid[iv] == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return 1;
- }
- add_var(&test, &va[iv]); /* keep in-memory netcdf in sync */
- }
-
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return 1;
- }
-
- for (iv = 0; iv < NVARS; iv++) { /* test each type of variable */
-
- v = emalloc(WSIZE*XSIZE*YSIZE*ZSIZE * nctypelen(va[iv].type));
-
- /* fill it with values using a function of dimension indices */
- ii = 0;
- for (iw=0; iw < WSIZE; iw++) {
- corner[0] = iw;
- for (ix=0; ix < XSIZE; ix++) {
- corner[1] = ix;
- for (iy=0; iy < YSIZE; iy++) {
- corner[2] = iy;
- for (iz=0; iz < ZSIZE; iz++) {
- corner[3] = iz;
- /* v[ii++] = VF(corner); */
- val_stuff(va[iv].type, v, ii, VF(corner));
- ii++;
- }
- }
- }
- }
-
- for (idim = 0; idim < NDIMS; idim++) {
- corner[idim] = 0;
- edge[idim] = dims[idim].size;
- }
-
- /* ncvarput the whole variable */
- if (ncvarput(cdfid, varid[iv], corner, edge, (void *) v) == -1) {
- error("%s: ncvarput failed", pname);
- nerrs++;
- }
-
- add_data(&test, varid[iv], corner, edge); /* keep test in sync */
- /*
- * For several combinations of fixed dimensions, get a slab and compare
- * values to function values.
- */
-
- /* get an interior point */
- for (idim=0; idim < NDIMS; idim++) {
- corner[idim] = dims[idim].size/2;
- edge[idim] = 1;
- point[idim] = corner[idim];
- }
- if (ncvarget(cdfid, varid[iv], corner, edge, (void *) v) == -1) {
- error("%s: ncvarget of one point failed", pname);
- nerrs++;
- }
- /* if (v[0] != VF(point)) */
- if (val_diff(va[iv].type, v, 0, VF(point))) {
- error("%s: ncvarget got wrong value for point", pname);
- nerrs++;
- }
-
- /* get an interior vector in each direction */
- for (idim=0; idim < NDIMS; idim++) {
- for (jdim=0; jdim < NDIMS; jdim++) {
- corner[jdim] = dims[jdim].size/2;
- edge[jdim] = 1;
- point[jdim] = corner[jdim];
- }
- corner[idim] = 1; /* get vector along dimension idim */
- edge[idim] = dims[idim].size - 2;
- if (ncvarget(cdfid, varid[iv], corner, edge, (void *) v) == -1) {
- error("%s: ncvarget of vector failed", pname);
- nerrs++;
- }
- for (ii=(int)corner[idim]; ii <= edge[idim]; ii++) {
- point[idim] = ii;
- /* if (v[ii-1] != VF(point)) */
- if (val_diff(va[iv].type, v, ii-1, VF(point))) {
- error("%s: ncvarget got wrong value for vector", pname);
- nerrs++;
- }
- }
- }
-
- /* get an interior plane in each direction */
- for (idim=0; idim < NDIMS; idim++) {
- for (jdim=idim+1; jdim < NDIMS; jdim++) {
- for (kdim=0; kdim < NDIMS; kdim++) { /* reset corners and edges */
- corner[kdim] = dims[kdim].size/2;
- edge[kdim] = 1;
- point[kdim] = corner[kdim];
- }
- corner[idim] = 1; /* interior plane along dimensions idim jdim */
- corner[jdim] = 1;
- edge[idim] = dims[idim].size - 2;
- edge[jdim] = dims[jdim].size - 2;
- if (ncvarget(cdfid, varid[iv], corner, edge, (void *) v) == -1) {
- error("%s: ncvarget of plane failed", pname);
- nerrs++;
- }
- for (ii=(int)corner[idim]; ii <= edge[idim]; ii++) {
- for (jj=(int)corner[jdim]; jj <= edge[jdim]; jj++) {
- point[idim] = ii;
- point[jdim] = jj;
- /* if (v[(ii-1)*edge[jdim]+jj-1] != VF(point)) { */
- if (val_diff(va[iv].type, v,
- (ii-1)*(int)edge[jdim]+jj-1, VF(point))) {
- error("%s: ncvarget got wrong value in plane", pname);
- error("idim=%d,jdim=%d,ii=%d,jj=%d",
- idim,
- jdim,
- ii,
- jj);
- nerrs++;
- }
- }
- }
- }
- }
-
- /* get an interior cube in each direction */
- for (idim=0; idim < NDIMS; idim++) {
- for (jdim=idim+1; jdim < NDIMS; jdim++) {
- for (kdim=jdim+1; kdim < NDIMS; kdim++) {
- for (ldim=0; ldim < NDIMS; ldim++) { /* reset corners, edges */
- corner[ldim] = dims[ldim].size/2;
- edge[ldim] = 1;
- point[ldim] = corner[ldim];
- }
- corner[idim] = 1; /* intr. cube along idim jdim kdim */
- corner[jdim] = 1;
- corner[kdim] = 1;
- edge[idim] = dims[idim].size - 2;
- edge[jdim] = dims[jdim].size - 2;
- edge[kdim] = dims[kdim].size - 2;
- if (ncvarget(cdfid, varid[iv], corner, edge, (void *) v) == -1) {
- error("%s: ncvarget of cube failed", pname);
- nerrs++;
- }
- for (ii=(int)corner[idim]; ii <= edge[idim]; ii++) {
- for (jj=(int)corner[jdim]; jj <= edge[jdim]; jj++) {
- for (kk=(int)corner[kdim]; kk <= edge[kdim]; kk++) {
- point[idim] = ii;
- point[jdim] = jj;
- point[kdim] = kk;
- /* if (v[((ii-1)*edge[jdim]+jj-1)*
- edge[kdim]+kk-1] != VF(point)) { */
- if (val_diff(va[iv].type,v,
- ((ii-1)*(int)edge[jdim]+jj-1)*
- (int)edge[kdim]+kk-1,VF(point))) {
- error("%s: ncvarget got wrong value in cube", pname);
- error("idim=%d,jdim=%d,kdim=%d,ii=%d,jj=%d,kk=%d",
- idim,
- jdim,
- kdim,
- ii,
- jj,
- kk);
- nerrs++;
- }
- }
- }
- }
- }
- }
- }
- free(v);
- }
- return nerrs;
-}
-
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testcdf.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testcdf.h
deleted file mode 100644
index fbb03a1..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testcdf.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testcdf.h,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-/*
- * In-memory structure holding netcdf structure for comparing with
- * on-disk netcdf. Whenever a disk netcdf is updated in the test
- * package, this structure should be updated at the same time, to keep
- * them in sync.
- */
-
-
-#define ___ 0 /* marker for structure place-holder */
-#define BAD_TYPE ((nc_type)0) /* must be distinct from valid types */
-
-struct cdfdim { /* dimension */
- char *name;
- long size;
-};
-
-struct cdfvar { /* variable */
- char *name;
- nc_type type;
- int ndims;
- int *dims;
- int natts;
-};
-
-struct cdfatt { /* attribute */
- int var;
- char *name;
- nc_type type;
- int len;
- void *val;
-};
-
-#define MAX_TEST_DIMS 32
-#define MAX_TEST_VARS 32
-#define MAX_TEST_ATTS 32
-
-struct netcdf {
- int ndims; /* number of dimensions declared for netcdf */
- int nvars; /* number of variables declared for netcdf */
- int natts; /* number of attributes */
- int ngatts; /* number of global attributes */
- int xdimid; /* number of the unlimited dimension, if any */
- struct cdfdim dims[MAX_TEST_DIMS]; /* dimensions */
- struct cdfvar vars[MAX_TEST_VARS]; /* variables */
- struct cdfatt atts[MAX_TEST_ATTS]; /* attributes */
-};
-
-
-extern struct netcdf test; /*
- * in-memory netcdf structure, kept in sync
- * with disk netcdf
- */
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testfile_nc.sav b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testfile_nc.sav
deleted file mode 100644
index ad1e347..0000000
Binary files a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/testfile_nc.sav and /dev/null differ
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/tests.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/tests.h
deleted file mode 100644
index 8ed8589..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/tests.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/tests.h,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#undef PROTO
-#ifndef NO_HAVE_PROTOTYPES
-# define PROTO(x) x
-#else
-# define PROTO(x) ()
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void test_nccreate PROTO((
- char*
- ));
-extern void test_ncopen PROTO((
- char*
- ));
-extern void test_ncredef PROTO((
- char*
- ));
-extern void test_ncendef PROTO((
- char*
- ));
-extern void test_ncclose PROTO((
- char*
- ));
-extern void test_ncinquire PROTO((
- char*
- ));
-extern void test_ncsync PROTO((
- char*
- ));
-extern void test_ncabort PROTO((
- char*
- ));
-extern void test_ncdimdef PROTO((
- char*
- ));
-extern void test_ncdimid PROTO((
- char*
- ));
-extern void test_ncdiminq PROTO((
- char*
- ));
-extern void test_ncdimrename PROTO((
- char*
- ));
-extern void test_ncvardef PROTO((
- char*
- ));
-extern void test_ncvarid PROTO((
- char*
- ));
-extern void test_ncvarinq PROTO((
- char*
- ));
-extern void test_ncvarput1 PROTO((
- char*
- ));
-extern void test_ncvarget1 PROTO((
- char*
- ));
-extern void test_ncvarput PROTO((
- char*
- ));
-extern void test_ncvarget PROTO((
- char*
- ));
-extern void test_ncvarputg PROTO((
- char*
- ));
-extern void test_ncvargetg PROTO((
- char*
- ));
-extern void test_ncrecinq PROTO((
- char*
- ));
-extern void test_ncrecput PROTO((
- char*
- ));
-extern void test_ncrecget PROTO((
- char*
- ));
-extern void test_ncvarrename PROTO((
- char*
- ));
-extern void test_ncattput PROTO((
- char*
- ));
-extern void test_ncattinq PROTO((
- char*
- ));
-extern void test_ncattget PROTO((
- char*
- ));
-extern void test_ncattcopy PROTO((
- char*,
- char*
- ));
-extern void test_ncattname PROTO((
- char*
- ));
-extern void test_ncattrename PROTO((
- char*
- ));
-extern void test_ncattdel PROTO((
- char*
- ));
-extern void test_nctypelen PROTO((
- void
- ));
-extern int test_varputget PROTO((
- int
- ));
-extern int test_varputgetg PROTO((
- int
- ));
-extern int test_slabs PROTO((
- int
- ));
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/timesum.awk b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/timesum.awk
deleted file mode 100644
index fb60f05..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/timesum.awk
+++ /dev/null
@@ -1,2 +0,0 @@
-{sum += $5;}
-END { print sum;}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.c
deleted file mode 100644
index 4d70d75..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include "netcdf.h"
-#include "testcdf.h"
-#include "val.h"
-#include "error.h"
-
-
-/* fill typed value block with values of specified type */
-void
-val_fill(type, len, vals)
- nc_type type; /* netcdf type, NC_BYTE, ..., NC_DOUBLE */
- long len; /* number of elements to fill with */
- void *vals; /* start of first block of values */
-{
- static char pname[] = "val_fill";
- long half = len/2;
- int iel;
- union {
- char *cp;
- short *sp;
- nclong *lp;
- float *fp;
- double *dp;
- } gp;
-
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- gp.cp = (char *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.cp++ = (char) iel;
- break;
- case NC_SHORT:
- gp.sp = (short *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.sp++ = (short) (iel - half); /* negative and positive values */
- break;
- case NC_LONG:
- gp.lp = (nclong *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.lp++ = (nclong) (iel - half);
- break;
- case NC_FLOAT:
- gp.fp = (float *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.fp++ = (float) (iel+1);
- break;
- case NC_DOUBLE:
- gp.dp = (double *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.dp++ = (double) (iel - half);
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
-}
-
-
-/* fill typed value block with zeros of specified type */
-void
-val_fill_zero(type, len, vals)
- nc_type type; /* netcdf type, NC_BYTE, ..., NC_DOUBLE */
- long len; /* number of elements to fill with */
- void *vals; /* start of first block of values */
-{
- static char pname[] = "val_fill_zero";
- int iel;
- union {
- char *cp;
- short *sp;
- nclong *lp;
- float *fp;
- double *dp;
- } gp;
-
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- gp.cp = (char *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.cp++ = (char) 0;
- break;
- case NC_SHORT:
- gp.sp = (short *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.sp++ = (short) 0;
- break;
- case NC_LONG:
- gp.lp = (nclong *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.lp++ = (nclong) 0;
- break;
- case NC_FLOAT:
- gp.fp = (float *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.fp++ = (float) 0;
- break;
- case NC_DOUBLE:
- gp.dp = (double *) vals;
- for (iel = 0; iel < len; iel++)
- *gp.dp++ = (double) 0;
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
-}
-
-
-
-/*
- * compare two typed value blocks, return 0 if equal, 1+n otherwise,
- * where n is the index of the first differing element.
- */
-int
-val_cmp (type, len, v1, v2)
- nc_type type; /* netcdf type, NC_BYTE, ..., NC_DOUBLE */
- long len; /* number of elements of type to compare */
- void *v1; /* start of first block of values */
- void *v2; /* start of second block of values */
-{
- static char pname[] = "val_cmp";
- int iel;
- union {
- char *cp;
- short *sp;
- nclong *lp;
- float *fp;
- double *dp;
- } gp, hp;
-
- switch (type) {
- case NC_CHAR:
- case NC_BYTE:
- gp.cp = (char *) v1;
- hp.cp = (char *) v2;
- for (iel = 0; iel < len; iel++) {
- if (*gp.cp != *hp.cp)
- return (iel + 1);
- gp.cp++;
- hp.cp++;
- }
- break;
- case NC_SHORT:
- gp.sp = (short *) v1;
- hp.sp = (short *) v2;
- for (iel = 0; iel < len; iel++) {
- if (*gp.sp != *hp.sp)
- return (iel + 1);
- gp.sp++;
- hp.sp++;
- }
- break;
- case NC_LONG:
- gp.lp = (nclong *) v1;
- hp.lp = (nclong *) v2;
- for (iel = 0; iel < len; iel++) {
- if (*gp.lp != *hp.lp)
- return (iel + 1);
- gp.lp++;
- hp.lp++;
- }
- break;
- case NC_FLOAT:
- gp.fp = (float *) v1;
- hp.fp = (float *) v2;
- for (iel = 0; iel < len; iel++) {
- if (*gp.fp != *hp.fp)
- return (iel + 1);
- gp.fp++;
- hp.fp++;
- }
- break;
- case NC_DOUBLE:
- gp.dp = (double *) v1;
- hp.dp = (double *) v2;
- for (iel = 0; iel < len; iel++) {
- if (*gp.dp != *hp.dp)
- return (iel + 1);
- gp.dp++;
- hp.dp++;
- }
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
- return 0; /* all values agree */
-}
-
-
-/* print typed value block with values of specified type */
-void
-val_out(type, len, vals)
- nc_type type; /* netcdf type, NC_BYTE, ..., NC_DOUBLE */
- long len; /* number of elements to fill with */
- void *vals; /* start of first block of values */
-{
- static char pname[] = "val_oout";
- int iel;
- union {
- char *cp;
- short *sp;
- nclong *lp;
- float *fp;
- double *dp;
- } gp;
-
- (void) fprintf(stderr," ");
- switch (type) {
- case NC_BYTE:
- case NC_CHAR:
- gp.cp = (char *) vals;
- for (iel = 0; iel < len; iel++)
- (void)fprintf(stderr,"%d%s",*gp.cp++,iel<len-1 ? ", " : "");
- break;
- case NC_SHORT:
- gp.sp = (short *) vals;
- for (iel = 0; iel < len; iel++)
- (void)fprintf(stderr,"%d%s",*gp.sp++,iel<len-1 ? ", " : "");
- break;
- case NC_LONG:
- gp.lp = (nclong *) vals;
- for (iel = 0; iel < len; iel++)
- (void)fprintf(stderr,"%d%s",*gp.lp++,iel<len-1 ? ", " : "");
- break;
- case NC_FLOAT:
- gp.fp = (float *) vals;
- for (iel = 0; iel < len; iel++)
- (void)fprintf(stderr,"%g%s",*gp.fp++,iel<len-1 ? ", " : "");
- break;
- case NC_DOUBLE:
- gp.dp = (double *) vals;
- for (iel = 0; iel < len; iel++)
- (void)fprintf(stderr,"%g%s",*gp.dp++,iel<len-1 ? ", " : "");
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
- (void) putc('\n',stderr);
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.h b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.h
deleted file mode 100644
index 1f09321..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/val.h,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#undef PROTO
-#ifndef NO_HAVE_PROTOTYPES
-# define PROTO(x) x
-#else
-# define PROTO(x) ()
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* fill typed value block with values of specified type */
-extern void val_fill PROTO((
- nc_type ,
- long,
- void *
- ));
-
-/* fill typed value block with zeros of specified type */
-extern void val_fill_zero PROTO((
- nc_type ,
- long,
- void *
- ));
-
-/*
- * compare two typed value blocks, return 0 if equal, 1+n otherwise,
- * where n is the index of the first differing element.
- */
-extern int val_cmp PROTO((
- nc_type ,
- long,
- void *,
- void *
- ));
-
-/* print typed value block with values of specified type */
-extern void val_out PROTO((
- nc_type ,
- long,
- void *
- ));
-#ifdef __cplusplus
-}
-#endif
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vardef.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vardef.c
deleted file mode 100644
index 3fb06b3..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vardef.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vardef.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* for free() */
-#ifndef NO_FLOAT_H
-#include <float.h> /* for FLT_EPSILON, DBL_EPSILON */
-#endif /* NO_FLOAT_H */
-#include <netcdf.h>
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "emalloc.h"
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-#include "tests.h"
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-
-static float float_eps;
-static double double_eps;
-
-static float
-float_epsilon()
-{
- float float_eps;
-#ifndef NO_FLOAT_H
- float_eps = FLT_EPSILON;
-#else /* NO_FLOAT_H */
- {
- float etop, ebot, eps;
- float one = 1.0;
- float two = 2.0;
- etop = 1.0;
- ebot = 0.0;
- eps = ebot + (etop - ebot)/two;
- while (eps != ebot && eps != etop) {
- float epsp1;
-
- epsp1 = one + eps;
- if (epsp1 > one)
- etop = eps;
- else
- ebot = eps;
- eps = ebot + (etop - ebot)/two;
- }
- float_eps = two * etop;
- }
-#endif /* NO_FLOAT_H */
- return float_eps;
-}
-
-
-static double
-double_epsilon()
-{
- double double_eps;
-#ifndef NO_FLOAT_H
- double_eps = DBL_EPSILON;
-#else /* NO_FLOAT_H */
- {
- double etop, ebot, eps;
- double one = 1.0;
- double two = 2.0;
- etop = 1.0;
- ebot = 0.0;
- eps = ebot + (etop - ebot)/two;
- while (eps != ebot && eps != etop) {
- double epsp1;
-
- epsp1 = one + eps;
- if (epsp1 > one)
- etop = eps;
- else
- ebot = eps;
- eps = ebot + (etop - ebot)/two;
- }
- double_eps = two * etop;
- }
-#endif /* NO_FLOAT_H */
- return double_eps;
-}
-
-
-static void
-init_epsilons()
-{
- float_eps = float_epsilon();
- double_eps = double_epsilon();
-}
-
-
-/*
- * Test ncvardef
- * check that proper define worked with ncvarinq
- * check that returned id is one more than previous id
- * try redefining an existing variable, check error
- * try adding scalar variable (no dimensions)
- * try with bad datatype, check error
- * try with bad number of dimensions, check error
- * try with bad dimension ids, check error
- * try in data mode, check error
- */
-void
-test_ncvardef(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- int cdfid; /* netcdf id */
- static char pname[] = "test_ncvardef";
- int id, iv;
- static struct cdfvar va[] = { /* variables of all shapes and sizes */
- {"bytev", NC_BYTE, 6, ___, 0},
- {"charv", NC_CHAR, 5, ___, 0},
- {"shortv", NC_SHORT, 4, ___, 0},
- {"longv", NC_LONG, 3, ___, 0},
- {"floatv", NC_FLOAT, 2, ___, 0},
- {"doublev", NC_DOUBLE, 1, ___, 0},
- {"scalarv", NC_DOUBLE, 0, ___, 0}
- };
- int nv = LEN_OF(va); /* number of variables to define */
- int va_id[LEN_OF(va)]; /* variable ids */
- static struct cdfvar tmp = /* variable for testing bad types, etc. */
- {"tmpv", NC_DOUBLE, 1, ___, 0};
- /* if d5 >= 91 in following, problem on machines with 16-bit ints ??? */
- static struct cdfdim di[] = { /* a bunch of dimensions */
- {"d0", 2}, {"d1",3}, {"d2",5}, {"d3", 6}, {"d4", 4}, {"d5", 31}};
- int nd = LEN_OF(di); /* number of dimensions */
- int di_id[LEN_OF(di)]; /* dimension ids */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- init_epsilons();
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, defining a variable should fail in data mode */
- if (ncvardef(cdfid, va[0].name, va[0].type, va[0].ndims, va[0].dims)
- != -1) {
- error("%s: ncvardef should have failed in data mode", pname);
- ncclose(cdfid); return;
- }
- /* enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
-
- /* Add nd more dimensions */
- for (id = 0; id < nd; id++) {
- if ((di_id[id] = ncdimdef(cdfid, di[id].name, di[id].size)) == -1) {
- error("%s: ncdimdef failed for %s, size %d",
- pname, di[id].name, di[id].size);
- ncclose(cdfid); return;
- }
- add_dim(&test, &di[id]); /* keep in-memory netcdf in sync */
- }
-
- tmp.dims = (int *) emalloc(sizeof(int) * MAX_VAR_DIMS);
- tmp.name = (char *) emalloc(MAX_NC_NAME);
-
- /* in define mode, add variables of each type with various shapes */
- for (iv = 0; iv < nv; iv++) {
- /* set shape to use subset of dimensions previously defined */
- va[iv].dims = (int *) emalloc(sizeof(int) * va[iv].ndims);
- for (id = 0; id < va[iv].ndims; id++)
- va[iv].dims[id] = di_id[id];
- if ((va_id[iv] = ncvardef(cdfid, va[iv].name, va[iv].type,
- va[iv].ndims, va[iv].dims)) == -1) {
- error("%s: ncvardef failed", pname);
- errvar(&test,&va[iv]); /* prints details about variable */
- ncclose(cdfid); return;
- }
- add_var(&test, &va[iv]); /* keep in-memory netcdf in sync */
- /* check that var id returned is one more than previous var id */
- if (va_id[iv] != test.nvars - 1) {
- error("%s: ncvardef returned %d for var id, expected %d",
- pname, va_id[iv], test.nvars-1);
- ncclose(cdfid); return;
- }
- /* use ncvarinq to get values just set and compare values */
- if (ncvarinq(cdfid, va_id[iv], tmp.name, &tmp.type,
- &tmp.ndims, tmp.dims, &tmp.natts) == -1) {
- error("%s: ncvarinq failed", pname);
- errvar(&test,&va[iv]); /* prints details about variable */
- ncclose(cdfid); return;
- }
- if (strcmp(tmp.name, va[iv].name) != 0 ||
- tmp.type != va[iv].type ||
- tmp.ndims != va[iv].ndims ||
- tmp.natts != va[iv].natts) {
- error("%s: ncvardef and ncvarinq don't agree for %s",
- pname, va[iv].name);
- nerrs++;
- errvar(&test,&va[iv]);
- errvar(&test,&tmp);
- }
- for (id = 0; id < va[iv].ndims; id++) {
- if (tmp.dims[id] != va[iv].dims[id]) {
- error("%s: ncvardef and ncvarinq don't agree on shape of %s",
- pname, va[iv].name);
- nerrs++;
- errvar(&test,&va[iv]);
- errvar(&test,&tmp);
- }
- }
- }
- /* try adding same variable again, this should fail */
- if (ncvardef(cdfid, va[0].name, va[0].type,
- va[0].ndims, va[0].dims) != -1) {
- error("%s: ncvardef should not allow redefinition", pname);
- ncclose(cdfid); return;
- }
- /* try bad type, should fail */
- if (ncvardef(cdfid, "badtype", BAD_TYPE, va[0].ndims, va[0].dims) != -1) {
- error("%s: ncvardef should have failed on bad type", pname);
- ncclose(cdfid); return;
- }
- /* try bad ndims, should fail */
- if (ncvardef(cdfid, "badndims", va[0].type, -1, va[0].dims) != -1) {
- error("%s: ncvardef should have failed on bad ndims", pname);
- ncclose(cdfid); return;
- }
- /* try bad ids in dims vector, should fail */
- id = va[0].dims[0];
- va[0].dims[va[0].ndims-1] = -1;
- if (ncvardef(cdfid, "baddims", va[0].type, va[0].ndims, va[0].dims)
- != -1) {
- error("%s: ncvardef should have failed on negative dim id in dims",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
-
- /* try reading a value of each type, should get appropriate fill value */
- for (iv = 0; iv < nv; iv++) {
- static long where[] = {0,0,0,0,0,0};
-
- switch(va[iv].type) {
- case NC_BYTE:
- {
- char val, fillval = FILL_BYTE;
- if (ncvarget1(cdfid, va_id[iv], where, (void *) &val) != -1) {
- if (val != fillval) {
- error("%s: unwritten byte not FILL_BYTE", pname);
- nerrs++;
- }
- } else {
- error("%s: ncvarget1 failure for byte", pname);
- nerrs++;
- }
- }
- break;
- case NC_CHAR:
- {
- char val, fillval = FILL_CHAR;
- if (ncvarget1(cdfid, va_id[iv], where, (void *) &val) != -1) {
- if (val != fillval) {
- error("%s: unwritten char not FILL_CHAR", pname);
- nerrs++;
- }
- } else {
- error("%s: ncvarget1 failure for char", pname);
- nerrs++;
- }
- }
- break;
- case NC_SHORT:
- {
- short val, fillval = FILL_SHORT;
- if (ncvarget1(cdfid, va_id[iv], where, (void *) &val) != -1) {
- if (val != fillval) {
- error("%s: unwritten short not FILL_SHORT", pname);
- nerrs++;
- }
- } else {
- error("%s: ncvarget1 failure for short", pname);
- nerrs++;
- }
- }
- break;
- case NC_LONG:
- {
- nclong val, fillval = FILL_LONG;
- if (ncvarget1(cdfid, va_id[iv], where, (void *) &val) != -1) {
- if (val != fillval) {
- error("%s: unwritten long not FILL_LONG", pname);
- nerrs++;
- }
- } else {
- error("%s: ncvarget1 failure for long", pname);
- nerrs++;
- }
- }
- break;
-#define absval(x) ( (x) < 0 ? -(x) : (x) )
- case NC_FLOAT:
- {
- float val, fillval = FILL_FLOAT;
- if (ncvarget1(cdfid, va_id[iv], where, (void *) &val) != -1) {
- if (absval(val-fillval) > absval(float_eps * fillval)) {
- error("%s: unwritten float not FILL_FLOAT", pname);
- nerrs++;
- }
- } else {
- error("%s: ncvarget1 failure for float", pname);
- nerrs++;
- }
- }
- break;
- case NC_DOUBLE:
- {
- double val, fillval = FILL_DOUBLE;
- if (ncvarget1(cdfid, va_id[iv], where, (void *) &val) != -1) {
-#define DBL_FUDGE 8.0 /* can be 1.0 on every platform we've seen
- except for VAX/Ultrix 4.3 with cc */
- if (absval(val-fillval) > DBL_FUDGE * absval(double_eps * fillval)) {
- error("%s: unwritten double not FILL_DOUBLE", pname);
- nerrs++;
- }
- } else {
- error("%s: ncvarget1 failure for double", pname);
- nerrs++;
- }
- }
- break;
- }
- }
-
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- free (tmp.dims);
- free (tmp.name);
- for (iv = 0; iv < nv; iv++)
- if (va[iv].dims)
- free(va[iv].dims);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varget.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varget.c
deleted file mode 100644
index d7162db..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varget.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varget.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "error.h"
-#include "tests.h"
-#include "emalloc.h"
-
-
-/*
- * Test ncvarget
- * check that proper call worked after ncvarput
- * try with negative coords, edges, check error
- * try with too-large coords, edges, check error
- * try with bad variable handle, check error
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvarget(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarget";
- int cdfid; /* netcdf id */
- int iv; /* variable id */
- 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 */
- } hc; /* test hypercube */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened in data mode, try putting and getting hypercubes of each type */
- nerrs += test_varputget (cdfid);
-
- /* try putting hypercube and getting various interior slabs */
- nerrs += test_slabs (cdfid);
-
- /* find a variable with at least one dimension */
- iv = 0;
- while (test.vars[iv].ndims <= 0 && iv < test.nvars)
- iv++;
- if (iv < test.nvars) { /* iv is varid of variable with dimensions */
- long tmp;
- /* set coords */
- int id; /* dimension id */
- for (id = 0; id < test.vars[iv].ndims; id++) {
- hc.cor[id] = 0;
- hc.edg[id] = 1;
- }
- /* get space for vals */
- hc.vals = emalloc(nctypelen(test.vars[iv].type) + 8);
-
- id = test.vars[iv].ndims - 1;
- tmp = hc.cor[id];
- hc.cor[id] = -1; /* try negative coordinate, should fail */
- if(ncvarget (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget should fail for negative corner", pname);
- ncclose(cdfid); return;
- }
- hc.cor[id] = tmp;
- tmp = hc.edg[id];
- hc.edg[id] = -1; /* try negative edge, should fail */
- if(ncvarget (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget should fail for negative edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[id] = tmp;
-
- {
- long mqv = test.vars[iv].ndims -1 ;
- int dim = test.vars[iv].dims[mqv] ;
-
- tmp = hc.cor[mqv];
- hc.cor[mqv] = test.dims[dim].size; /* try big coordinate, should fail */
- if(ncvarget (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget should fail for too-high coordinate", pname);
- ncclose(cdfid); return;
- }
- hc.cor[mqv] = tmp;
- tmp = hc.edg[mqv];
- hc.edg[mqv] = test.dims[dim].size + 1; /* try big edge, should fail */
- if(ncvarget (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget should fail for too-high edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[mqv] = tmp;
- } /* mqv block */
-
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* try in define mode, should fail */
- if(ncvarget (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget should fail in define mode",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- }
- /* try with bad variable handle, should fail */
- if(ncvarget (cdfid, -1, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget should fail for bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netCDF handle, should fail */
- if(ncvarget (cdfid, 0, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarget failed to report bad netcdf handle", pname);
- nerrs++;
- }
- free (hc.vals);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vargetg.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vargetg.c
deleted file mode 100644
index 3577645..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vargetg.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: vargetg.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "error.h"
-#include "tests.h"
-#include "emalloc.h"
-
-
-/*
- * Test ncvargetg
- * check that proper call worked after ncvarputg
- * try with negative coords, edges, check error
- * try with non-positive strides, check error
- * try with too-large coords, edges, check error
- * try with bad variable handle, check error
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvargetg(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvargetg";
- int cdfid; /* netcdf id */
- int iv; /* variable id */
- 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 */
- } hc; /* test hypercube */
- long strides[MAX_NC_DIMS]; /* external, I/O strides */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened in data mode, try putting and getting hypercubes of each type */
- nerrs += test_varputgetg (cdfid);
-
- /* find a variable with at least one dimension */
- iv = 0;
- while (test.vars[iv].ndims <= 0 && iv < test.nvars)
- iv++;
- if (iv < test.nvars) { /* iv is varid of variable with dimensions */
- long tmp;
- int id; /* dimension id */
-
- /* set coords and strides */
- for (id = 0; id < test.vars[iv].ndims; id++) {
- hc.cor[id] = 0;
- hc.edg[id] = 1;
- strides[id] = 1;
- }
-
- /* get space for vals */
- hc.vals = emalloc(nctypelen(test.vars[iv].type) + 8);
-
-# define TEST_FAILS(varid) \
- (ncvarputg(cdfid, varid, hc.cor, hc.edg, \
- strides, (long*)NULL, hc.vals) != -1)
-
- id = test.vars[iv].ndims - 1;
- tmp = hc.cor[id];
- hc.cor[id] = -1; /* try negative coordinate, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvargetg should fail for negative corner", pname);
- ncclose(cdfid); return;
- }
- hc.cor[id] = tmp;
- tmp = hc.edg[id];
- hc.edg[id] = -1; /* try negative edge, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvargetg should fail for negative edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[id] = tmp;
- tmp = hc.cor[id];
- hc.cor[id] = test.dims[id].size; /* try big coordinate, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvargetg should fail for too-high coordinate", pname);
- ncclose(cdfid); return;
- }
- hc.cor[id] = tmp;
- tmp = hc.edg[id];
- hc.edg[id] = test.dims[id].size + 1; /* try big edge, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvargetg should fail for too-high edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[id] = tmp;
- tmp = strides[id];
- strides[id] = -1; /* try non-positive stride, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvargetg should fail for non-positive stride", pname);
- ncclose(cdfid); return;
- }
- strides[id] = tmp;
-
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* try in define mode, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvargetg should fail in define mode",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- }
- /* try with bad variable handle, should fail */
- if (TEST_FAILS(-1)) {
- error("%s: ncvargetg should fail for bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netCDF handle, should fail */
- if (TEST_FAILS(0)) {
- error("%s: ncvargetg failed to report bad netcdf handle", pname);
- nerrs++;
- }
- free (hc.vals);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varput.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varput.c
deleted file mode 100644
index ecb9762..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varput.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varput.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "emalloc.h"
-#include "val.h"
-#include "error.h"
-#include "tests.h"
-
-
-/*
- * Test ncvarput
- * check that proper call worked with ncvarget
- * try with negative coords, edges, check error
- * try with too-large coords, edges, check error
- * try with bad variable handle, check error
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvarput(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarput";
- int cdfid; /* netcdf id */
- int iv; /* variable id */
- 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 */
- } hc; /* test hypercube */
- long tmp;
- int id; /* dimension id */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- /* handle case where struct netcdf test is uninitialised */
- hc.cor[0] = 0 ;
- hc.edg[0] = 1 ;
- hc.vals = 0 ;
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
-
- /* opened in data mode, try putting and getting hypercubes of each type */
- nerrs += test_varputget (cdfid); /* prints messages for discrepencies */
-
- /* find a variable with at least one dimension */
- iv = 0;
- while (test.vars[iv].ndims <= 0 && iv < test.nvars)
- iv++;
- if (iv < test.nvars) { /* iv is first varid of var with dimensions */
- /* set coords */
- for (id = 0; id < test.vars[iv].ndims; id++) {
- hc.cor[id] = 0;
- hc.edg[id] = 1;
- }
- /* fill in vals with value of appropriate type */
- hc.vals = emalloc(nctypelen(test.vars[iv].type));
- val_fill(test.vars[iv].type, 1, hc.vals);
-
- id = test.vars[iv].ndims - 1;
- tmp = hc.cor[id];
- hc.cor[id] = -1; /* try negative coordinate, should fail */
- if(ncvarput (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput should fail for negative corner", pname);
- ncclose(cdfid); return;
- }
- hc.cor[id] = tmp;
- tmp = hc.edg[id];
- hc.edg[id] = -1; /* try negative edge, should fail */
- if(ncvarput (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput should fail for negative edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[id] = tmp;
- {
- long mqv = test.vars[iv].ndims -1 ;
- int dim = test.vars[iv].dims[mqv] ;
-
- tmp = hc.cor[mqv];
- hc.cor[mqv] = test.dims[dim].size; /* try big coordinate, should fail */
- if(ncvarput (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput should fail for too-high coordinate", pname);
- ncclose(cdfid); return;
- }
- hc.cor[mqv] = tmp;
-
- tmp = hc.edg[mqv];
- hc.edg[mqv] = test.dims[dim].size + 1; /* try big edge, should fail */
- if(ncvarput (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput should fail for too-high edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[mqv] = tmp;
- }
-
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* try in define mode, should fail */
- if(ncvarput (cdfid, iv, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput should fail in define mode", pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- }
- else
- error("\"struct netcdf test\" uninitialized, no tests performed") ;
- /* try with bad variable handle, should fail */
- if(ncvarput (cdfid, -1, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput should fail for bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netCDF handle, should fail */
- if(ncvarput (cdfid, 0, hc.cor, hc.edg, hc.vals) != -1) {
- error("%s: ncvarput failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if(hc.vals) free (hc.vals);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varputg.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varputg.c
deleted file mode 100644
index 4fe5a32..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/varputg.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: varputg.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "val.h"
-#include "error.h"
-#include "tests.h"
-#include "emalloc.h"
-
-/*
- * Test ncvarputg
- * check that proper call worked with ncvargetg
- * try with negative coords, edges, check error
- * try with too-large coords, edges, check error
- * try with non-positive strides, check error
- * try with bad variable handle, check error
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvarputg(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarputg";
- int cdfid; /* netcdf id */
- int iv; /* variable id */
- 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 */
- } hc; /* test hypercube */
- long tmp;
- int id; /* dimension id */
- long strides[MAX_NC_DIMS]; /* external, I/O strides */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
-
- /* opened in data mode, try putting and getting hypercubes of each type.
- * prints out messages for discrepencies */
- nerrs += test_varputgetg (cdfid);
-
- /* find a variable with at least one dimension */
- iv = 0;
- while (test.vars[iv].ndims <= 0 && iv < test.nvars)
- iv++;
- if (iv < test.nvars) { /* iv is first varid of var with dimensions */
-
- /* set coords and strides */
- for (id = 0; id < test.vars[iv].ndims; id++) {
- hc.cor[id] = 0;
- hc.edg[id] = 1;
- strides[id] = 1;
- }
-
- /* fill in vals with value of appropriate type */
- hc.vals = emalloc(nctypelen(test.vars[iv].type));
- val_fill(test.vars[iv].type, 1, hc.vals);
-
-# define TEST_FAILS(varid) \
- (ncvarputg(cdfid, varid, hc.cor, hc.edg, \
- strides, (long*)NULL, hc.vals) != -1)
-
- id = test.vars[iv].ndims - 1;
- tmp = hc.cor[id];
- hc.cor[id] = -1; /* try negative coordinate, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvarputg should fail for negative corner", pname);
- ncclose(cdfid); return;
- }
- hc.cor[id] = tmp;
- tmp = hc.edg[id];
- hc.edg[id] = -1; /* try negative edge, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvarputg should fail for negative edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[id] = tmp;
- tmp = hc.cor[id];
- hc.cor[id] = test.dims[id].size; /* try big coordinate, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvarputg should fail for too-high coordinate", pname);
- ncclose(cdfid); return;
- }
- hc.cor[id] = tmp;
- tmp = hc.edg[id];
- hc.edg[id] = test.dims[id].size + 1; /* try big edge, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvarputg should fail for too-high edge", pname);
- ncclose(cdfid); return;
- }
- hc.edg[id] = tmp;
- tmp = strides[id];
- strides[id] = -1; /* try non-positive stride, * should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvarputg should fail for non-positive stride", pname);
- ncclose(cdfid); return;
- }
- strides[id] = tmp;
-
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* try in define mode, should fail */
- if (TEST_FAILS(iv)) {
- error("%s: ncvarputg should fail in define mode", pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- }
- /* try with bad variable handle, should fail */
- if (TEST_FAILS(-1)) {
- error("%s: ncvarputg should fail for bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netCDF handle, should fail */
- if (TEST_FAILS(0)) {
- error("%s: ncvarputg failed to report bad netcdf handle", pname);
- nerrs++;
- }
- free (hc.vals);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vartests.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vartests.c
deleted file mode 100644
index d94a0a8..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vartests.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vartests.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "emalloc.h"
-#include "add.h" /* functions to update in-memory netcdf */
-#include "error.h"
-#include "tests.h"
-
-#define LEN_OF(array) ((sizeof array) / (sizeof array[0]))
-
-
-/*
- * Test ncvarid
- * check that proper variable handle returned in both modes
- * try with undefined name, check error
- * try with bad handle, check error
- */
-void
-test_ncvarid(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarid";
- int cdfid; /* netcdf id */
- int id;
- int varid; /* variable id */
- static struct cdfvar xx = /* variable */
- {"xx", NC_FLOAT, 1, ___, 0};
-
- (void) fprintf(stderr, "*** Testing %s ...\t\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, enter define mode */
- if (ncredef(cdfid) == -1) {
- error("%s: cdredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add a variable */
- xx.dims = (int *) emalloc(sizeof(int) * xx.ndims);
- for (id = 0; id < xx.ndims; id++)
- xx.dims[id] = id;
- if ((varid = ncvardef(cdfid,
- xx.name, xx.type, xx.ndims, xx.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &xx); /* keep in-memory netcdf in sync */
-
- /* check id returned for name matches id returned from definition */
- if (ncvarid(cdfid, xx.name) != varid) {
- error("%s: ncvarid returned wrong value in define mode", pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode, check returned id for variable just added */
- if (ncvarid(cdfid, xx.name) != varid) {
- error("%s: ncvarid returned wrong value in data mode", pname);
- ncclose(cdfid); return;
- }
- /* try with undefined variable, should fail */
- if (ncvarid(cdfid, "santa-claus") != -1) {
- error("%s: ncvarid with bogus name should have failed ", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try on bad handle, should fail */
- if (ncvarid(cdfid, xx.name) != -1) {
- error("%s: ncvarid failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncvarinq
- * try in both modes
- * check returned values against defined values
- * try with bad variable handle, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvarinq(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarinq";
- int cdfid; /* netcdf id */
- int varid; /* variable id */
- struct cdfvar var; /* variable */
- int idim;
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened, in data mode */
- var.dims = (int *) emalloc(sizeof(int) * MAX_VAR_DIMS);
- var.name = (char *) emalloc(MAX_NC_NAME);
- for (varid = 0 ; varid < test.nvars; varid++) { /* loop on all var ids */
- if (ncvarinq(cdfid, varid, var.name, &var.type,
- &var.ndims, var.dims, &var.natts) == -1) {
- error("%s: ncvarinq in data mode failed on var id %d",
- pname, varid);
- ncclose(cdfid); return;
- }
- /* compare returned with expected values */
- if (strcmp(var.name, test.vars[varid].name) != 0) {
- error("%s: ncvarinq (data mode), name %s, expected %s for id = %d",
- pname, var.name, test.vars[varid].name, varid);
- nerrs++;
- }
- if (var.type != test.vars[varid].type) {
- error("%s: ncvarinq (data mode), type %d, expected %d for id = %d",
- pname, var.type, test.vars[varid].type, varid);
- nerrs++;
- }
- if (var.ndims != test.vars[varid].ndims) {
- error("%s: ncvarinq (data mode), ndims %d, expected %d for id = %d",
- pname, var.ndims, test.vars[varid].ndims, varid);
- nerrs++;
- }
- else { /* if ndims OK, compare dims */
- for (idim = 0; idim < var.ndims; idim++)
- if (var.dims[idim] != test.vars[varid].dims[idim]) {
- error("%s: ncvarinq (data mode), dims[%d]=%d, expected %d",
- pname, idim, var.dims[idim],
- test.vars[varid].dims[idim]);
- nerrs++;
- }
- }
- }
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, compare returned with expected values again */
- for (varid = 0 ; varid < test.nvars; varid++) { /* loop on all var ids */
- if (ncvarinq(cdfid, varid, var.name, &var.type,
- &var.ndims, var.dims, &var.natts) == -1) {
- error("%s: ncvarinq in data mode failed on var id %d",
- pname, varid);
- ncclose(cdfid); return;
- }
- if (strcmp(var.name, test.vars[varid].name) != 0) {
- error("%s: ncvarinq (define mode), name %s, expected %s for id = %d",
- pname, var.name, test.vars[varid].name, varid);
- nerrs++;
- }
- if (var.type != test.vars[varid].type) {
- error("%s: ncvarinq (define mode), type %d, expected %d for id = %d",
- pname, var.type, test.vars[varid].type, varid);
- nerrs++;
- }
- if (var.ndims != test.vars[varid].ndims) {
- error("%s: ncvarinq (define mode), ndims %d, expected %d for id = %d",
- pname, var.ndims, test.vars[varid].ndims, varid);
- nerrs++;
- }
- else { /* if ndims OK, compare dims */
- for (idim = 0; idim < var.ndims; idim++)
- if (var.dims[idim] != test.vars[varid].dims[idim]) {
- error("%s: ncvarinq (define mode), dims[%d]=%d, expected %d",
- pname, idim, var.dims[idim],
- test.vars[varid].dims[idim]);
- nerrs++;
- }
- }
- }
- /* try with bad variable handles, check for failure */
- if (ncvarinq(cdfid, -1, var.name, &var.type,
- &var.ndims, var.dims, &var.natts) != -1 ||
- ncvarinq(cdfid, test.nvars, var.name, &var.type,
- &var.ndims, var.dims, &var.natts) != -1) {
- error("%s: ncvarinq should have failed on bad variable ids",
- pname, varid);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail, since bad handle */
- if (test.nvars >= 1) { /* if any variables have been defined */
- if (ncvarinq(cdfid, varid, var.name, &var.type,
- &var.ndims, var.dims, &var.natts) != -1) {
- error("%s: ncvarinq failed to report bad netcdf handle ", pname);
- nerrs++;
- }
- }
- free(var.dims);
- free(var.name);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-struct cdfelm { /* coordinates and generic value */
- long coords[MAX_NC_DIMS];
- union generic {
- char by;
- char ch;
- short sh;
- nclong lo;
- float fl;
- double db;
- } val;
-};
-
-
-/*
- * Test both ncvarput1 and ncvarget1 with all types of data
- * use points in "lower-left", "middle", and "upper-right"
- * for each existing variable, put values of its type at each point
- * get values and compare with put values
- */
-static int
-test_varputget1(cdfid)
- int cdfid; /* handle of netcdf open and in data mode */
-{
- int nerrs = 0;
- static char pname[] = "test_varputget1";
- int id, ie, iv;
- int ne = 3; /* number of test points */
- struct cdfelm elm[3]; /* coordinates and values of test points */
- static long edges[] = {1};
- void *voidp;
- void *tmpp;
- char chval;
- short shval;
- nclong loval;
- float flval;
- double dbval;
-
- for (iv = 0; iv < test.nvars; iv++) { /* for each var in netcdf */
- for (id = 0; id < test.vars[iv].ndims; id++) { /* set corners */
- int dsize; /* max dimension size, used for u-r corner */
- /* "lower-left" corner */
- elm[0].coords[id] = 0;
- /* if unlimited dimension, choose record 3 for max, arbitrarily */
- dsize = (int) test.dims[test.vars[iv].dims[id]].size;
- if (dsize == NC_UNLIMITED)
- dsize = 3;
- /* middle */
- elm[1].coords[id] = dsize / 2;
- /* "upper-right" corner */
- elm[2].coords[id] = dsize - 1;
- }
- for (ie = 0; ie < ne; ie++) { /* for each of ne points */
- switch (test.vars[iv].type) { /* get values of right type to put */
- case NC_BYTE:
- case NC_CHAR:
- elm[ie].val.by = (char) (ie+1);
- voidp = (void *) &elm[ie].val.by;
- tmpp = (void *) &chval;
- break;
- case NC_SHORT:
- elm[ie].val.sh = (short) (ie-1);
- voidp = (void *) &elm[ie].val.sh;
- tmpp = (void *) &shval;
- break;
- case NC_LONG:
- elm[ie].val.lo = (nclong) (ie-3);
- voidp = (void *) &elm[ie].val.lo;
- tmpp = (void *) &loval;
- break;
- case NC_FLOAT:
- elm[ie].val.fl = (float) (ie+1);
- voidp = (void *) &elm[ie].val.fl;
- tmpp = (void *) &flval;
- break;
- case NC_DOUBLE:
- elm[ie].val.db = (double) (ie-1);
- voidp = (void *) &elm[ie].val.db;
- tmpp = (void *) &dbval;
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
- if(ncvarput1 (cdfid, iv, elm[ie].coords, voidp) == -1) {
- error("%s: ncvarput1 failed for point %d, variable %s",
- pname, ie, test.vars[iv].name);
- ncclose(cdfid); return 1;
- }
- add_data(&test, iv, elm[ie].coords, edges); /* keep test in sync */
-
- if(ncvarget1 (cdfid, iv, elm[ie].coords, tmpp) == -1) {
- error("%s: ncvarget1 failed for point %d, variable %s",
- pname, ie, test.vars[iv].name);
- ncclose(cdfid); return 1;
- }
- switch (test.vars[iv].type) { /* compare values of right type */
- case NC_BYTE:
- case NC_CHAR:
- if (elm[ie].val.by != chval) {
- error("%s: ncvarget1 returned char %d, expected %d",
- pname, chval, elm[ie].val.by);
- nerrs++;
- }
- break;
- case NC_SHORT:
- if (elm[ie].val.sh != shval) {
- error("%s: ncvarget1 returned short %d, expected %d",
- pname, shval, elm[ie].val.sh);
- nerrs++;
- }
- break;
- case NC_LONG:
- if (elm[ie].val.lo != loval) {
- error("%s: ncvarget1 returned long %ld, expected %ld",
- pname, (long)loval, (long)elm[ie].val.lo);
- nerrs++;
- }
- break;
- case NC_FLOAT:
- if (elm[ie].val.fl != flval) {
- error("%s: ncvarget1 returned float %g, expected %g",
- pname, flval, elm[ie].val.fl);
- nerrs++;
- }
- break;
- case NC_DOUBLE:
- if (elm[ie].val.db != dbval) {
- error("%s: ncvarget1 returned double %g, expected %g",
- pname, dbval, elm[ie].val.db);
- nerrs++;
- }
- break;
- default:
- error("%s: bad type, test program error", pname);
- }
- }
- }
- return nerrs;
-}
-
-
-/*
- * Test ncvarput1
- * check that proper call worked with ncvarget1
- * try with negative coords, check error
- * try with too-large coords, check error
- * try with bad variable handle, check error
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvarput1(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarput1";
- int cdfid; /* netcdf id */
- int iv; /* variable id */
- struct cdfelm elm; /* coordinates and value of test point */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened in data mode, try putting and getting values of each type */
- nerrs += test_varputget1 (cdfid); /* tests ncvarput1 and ncvarget1 */
-
- /* find a variable with at least one dimension */
- iv = 0;
- while (test.vars[iv].ndims <= 0 && iv < test.nvars)
- iv++;
- if (iv < test.nvars) { /* iv is varid of variable with dimensions */
- /* set coords */
- int id; /* dimension id */
- for (id = 0; id < test.vars[iv].ndims; id++)
- elm.coords[id] = 0;
- /* try invalid coordinates, should fail */
- elm.coords[test.vars[iv].ndims/2] = -1;
- if(ncvarput1 (cdfid, iv, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarput1 should fail for negative coordinate", pname);
- ncclose(cdfid); return;
- }
- elm.coords[test.vars[iv].ndims/2] =
- test.dims[test.vars[iv].dims[test.vars[iv].ndims/2]].size;
- if(ncvarput1 (cdfid, iv, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarput1 should fail for too-high coordinate", pname);
- ncclose(cdfid); return;
- }
- }
- /* try with bad variable handle, should fail */
- if(ncvarput1 (cdfid, -1, elm.coords, (void *) &elm.val) != -1 ||
- ncvarput1 (cdfid, test.nvars, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarput1 should fail for bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* try in define mode, should fail */
- if (test.nvars > 0)
- if(ncvarput1 (cdfid, 0, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarput1 should fail in define mode", pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netCDF handle, should fail */
- if(ncvarput1 (cdfid, 0, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarput1 failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncvarget1
- * check that proper call worked after ncvarput1
- * try with negative coords, check error
- * try with too-large coords, check error
- * try with bad variable handle, check error
- * try in define mode, check error
- * try with bad netCDF handle, check error
- */
-void
-test_ncvarget1(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarget1";
- int cdfid; /* netcdf id */
- int iv; /* variable id */
- struct cdfelm elm; /* coordinates and value of test point */
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened in data mode, try putting and getting values of each type */
- nerrs += test_varputget1 (cdfid); /* tests ncvarput1 and ncvarget1 */
-
- /* find a variable with at least one dimension */
- iv = 0;
- while (test.vars[iv].ndims <= 0 && iv < test.nvars)
- iv++;
- if (iv < test.nvars) { /* iv is varid of variable with dimensions */
- /* set coords */
- int id; /* dimension id */
- for (id = 0; id < test.vars[iv].ndims; id++)
- elm.coords[id] = 0;
- /* try invalid coordinates, should fail */
- elm.coords[test.vars[iv].ndims/2] = -1;
- if(ncvarget1 (cdfid, iv, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarget1 should fail for negative coordinate", pname);
- ncclose(cdfid); return;
- }
- elm.coords[test.vars[iv].ndims/2] =
- test.dims[test.vars[iv].dims[test.vars[iv].ndims/2]].size;
- if(ncvarget1 (cdfid, iv, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarget1 should fail for too-high coordinate", pname);
- ncclose(cdfid); return;
- }
- }
- /* try with bad variable handle, should fail */
- if(ncvarget1 (cdfid, -1, elm.coords, (void *) &elm.val) != -1 ||
- ncvarget1 (cdfid, test.nvars, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarget1 should fail for bad variable handle", pname);
- ncclose(cdfid); return;
- }
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* try in define mode, should fail */
- if (test.nvars > 0)
- if(ncvarget1 (cdfid, 0, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarget1 should fail in define mode",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* try with bad netCDF handle, should fail */
- if(ncvarget1 (cdfid, 0, elm.coords, (void *) &elm.val) != -1) {
- error("%s: ncvarget1 failed to report bad netcdf handle", pname);
- nerrs++;
- }
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
-
-
-/*
- * Test ncvarrename
- * check that proper rename worked with ncvarinq
- * try with bad netCDF handle, check error
- * try in data mode, check error
- * try with bad variable handle, check error
- * try renaming to existing variable name, check error
- */
-void
-test_ncvarrename(path)
- char *path; /* name of writable netcdf file to open */
-{
- int nerrs = 0;
- static char pname[] = "test_ncvarrename";
- int cdfid; /* netcdf id */
- int id; /* dimension id */
- int yy_id; /* variable id */
- static struct cdfvar yy = /* variable */
- {"old_name", NC_SHORT, 1, ___, 0};
- static char newname[] = "yyy"; /* variable name */
- static char shortname[] = "yy"; /* variable name */
- struct cdfvar var; /* variable */
- static struct cdfvar zz = /* variable */
- {"zz", NC_BYTE, 2, ___, 0};
-
- (void) fprintf(stderr, "*** Testing %s ...\t", &pname[5]);
-
- if ((cdfid = ncopen(path, NC_WRITE)) == -1) {
- error("%s: ncopen failed", pname);
- return;
- }
- /* opened */
- if (ncredef(cdfid) == -1) {
- error("%s: ncredef failed", pname);
- ncclose(cdfid); return;
- }
- /* in define mode, add two variables */
- yy.dims = (int *) emalloc(sizeof(int) * yy.ndims);
- for (id = 0; id < yy.ndims; id++)
- yy.dims[id] = id;
- if ((yy_id = ncvardef(cdfid,
- yy.name, yy.type, yy.ndims, yy.dims)) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &yy); /* keep in-memory netcdf in sync */
- zz.dims = (int *) emalloc(sizeof(int) * zz.ndims);
- for (id = 0; id < zz.ndims; id++)
- zz.dims[id] = id;
- if (ncvardef(cdfid, zz.name, zz.type, zz.ndims, zz.dims) == -1) {
- error("%s: ncvardef failed", pname);
- ncclose(cdfid); return;
- }
- add_var(&test, &zz); /* keep in-memory netcdf in sync */
-
- /* rename first variable */
- if (ncvarrename(cdfid, yy_id, newname) == -1) {
- error("%s: ncvarrename failed", pname);
- ncclose(cdfid); return;
- }
- /* check new name with ncvarid, ncvarinq */
- if (yy_id != ncvarid(cdfid, newname)) {
- error("%s: lookup by name failed after ncvarrename", pname);
- }
- var.dims = (int *) emalloc(sizeof(int) * MAX_VAR_DIMS);
- var.name = (char *) emalloc(MAX_NC_NAME);
- if (ncvarinq(cdfid, yy_id, var.name,
- &var.type, &var.ndims, var.dims, &var.natts) == -1) {
- error("%s: ncvarinq failed", pname);
- ncclose(cdfid); return;
- }
- if (strcmp(var.name,yy.name) == 0) {
- error("%s: ncvarrename failed to change name", pname);
- ncclose(cdfid); return;
- }
- if (strcmp(var.name,newname) != 0) {
- error("%s: ncvarrename changed name to %s instead of %s",
- pname, var.name, newname);
- ncclose(cdfid); return;
- }
- (void) strcpy(test.vars[yy_id].name, newname); /* keep test consistent */
- /* try to rename second variable same as first, should fail */
- if (ncvarrename(cdfid, yy_id, zz.name) != -1) {
- error("%s: ncvarrename should have failed with used name", pname);
- ncclose(cdfid); return;
- }
- /* try with bad variable handles, check for failure */
- if (ncvarrename(cdfid, -1, var.name) != -1 ||
- ncvarrename(cdfid, test.nvars, var.name) != -1) {
- error("%s: ncvarrename should have failed on bad variable ids",
- pname);
- ncclose(cdfid); return;
- }
- if (ncendef (cdfid) == -1) {
- error("%s: ncendef failed", pname);
- ncclose(cdfid); return;
- }
- /* in data mode */
- if (ncvarrename(cdfid, yy_id, "a_longer_name") != -1) {
- error("%s: ncvarrename to longer should fail in data mode", pname);
- ncclose(cdfid); return;
- }
- if (ncvarrename(cdfid, yy_id, shortname) == -1) {
- error("%s: ncvarrename to shorter should succeed in data mode", pname);
- ncclose(cdfid); return;
- }
- (void) strcpy(test.vars[yy_id].name, shortname); /* keep test consistent */
- /* check new name with ncvarid, ncvarinq */
- if (yy_id != ncvarid(cdfid, shortname)) {
- error("%s: lookup by name in data mode failed after ncvarrename",
- pname);
- }
- if (ncclose (cdfid) == -1) {
- error("%s: ncclose failed", pname);
- return;
- }
- /* should fail, since bad handle */
- if (ncvarrename (cdfid, 0, var.name) != -1) {
- error("%s: ncvarrename failed to report bad netcdf handle ", pname);
- nerrs++;
- }
- free(var.name);
- free(var.dims);
- if (nerrs > 0)
- (void) fprintf(stderr,"FAILED! ***\n");
- else
- (void) fprintf(stderr,"ok ***\n");
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputget.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputget.c
deleted file mode 100644
index 06c8dbd..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputget.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Header: /cvsroot/genesis-sim/genesis2/genesis/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputget.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "add.h" /* functions to update in-memory netcdf */
-#include "val.h"
-#include "error.h"
-#include "tests.h"
-#include "emalloc.h"
-
-#undef max
-#define max(A, B) ((A) > (B) ? (A) : (B))
-
-
-/*
- * For every variable in open netcdf, puts and gets three hypercubes
- * of data of the appropriate type, comparing values from get to
- * values put to check that both ncvarput and ncvarget worked. The
- * three hypercubes are
- * - a large hypercube from (0, 0, ...) to the far corner (diagonally
- * opposite (0, 0, ...),
- * - a size 1 hypercube from the far corner with edge lengths of 1
- * in every direction, and
- * - a hypercube starting about 1/3 of the way along the diagonal
- * from (0,0,...) extending 1/3 of the way in every direction
- * toward the far corner.
- */
-
-int
-test_varputget(cdfid)
- int cdfid; /* handle of netcdf open and in data mode */
-{
- int nerrs = 0;
- static char pname[] = "test_varputget";
- int id, ie, iv; /* 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 */
- 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 */
-
- 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 (id = 0; id < test.vars[iv].ndims; id++) { /* set cubes */
-
- /* max dimension size, 5 for records */
- int dsize = (int)test.dims[test.vars[iv].dims[id]].size;
- if (dsize == NC_UNLIMITED)
- dsize = 5;
-
- /* start at "lower-left" corner, do whole variable */
- hc[0].cor[id] = 0;
- hc[0].edg[id] = dsize;
- nel[0] *= hc[0].edg[id];
-
- /* start at "upper-right" corner, do one point */
- hc[1].cor[id] = dsize - 1;
- hc[1].edg[id] = 1;
- nel[1] *= hc[1].edg[id];
-
- /* start about 1/3 way along diagonal, do 1/3 in each direction */
- hc[2].cor[id] = dsize/3;
- hc[2].edg[id] = max (dsize/3, 1);
- nel[2] *= hc[2].edg[id];
- }
- for (ie = 0; ie < ne; ie++) { /* for each of ne points */
-
- /* allocate space for the cube of values */
- hc[ie].vals = emalloc(nel[ie]*nctypelen(test.vars[iv].type) + 8);
- tmp.vals = emalloc(nel[ie]*nctypelen(test.vars[iv].type) + 8);
-
- /* fill allocated space with different values of right type */
- val_fill(test.vars[iv].type, nel[ie], hc[ie].vals);
-
- if(ncvarput (cdfid, iv, hc[ie].cor, hc[ie].edg, hc[ie].vals)
- == -1) {
- error("%s: ncvarput failed for point %d, variable %s",
- pname, ie, test.vars[iv].name);
- nerrs++;
- errvar(&test, &test.vars[iv]);
- (void)fprintf(stderr," corner = (");
- for (id = 0 ; id < test.vars[iv].ndims; id++)
- (void)fprintf(stderr,"%ld%s",(long)hc[ie].cor[id],
- (id < test.vars[iv].ndims-1) ? ", " : "");
- (void)fprintf(stderr,")\n");
- (void)fprintf(stderr," edge = (");
- for (id = 0 ; id < test.vars[iv].ndims; id++)
- (void)fprintf(stderr,"%ld%s",(long)hc[ie].edg[id],
- (id < test.vars[iv].ndims-1) ? ", " : "");
- (void)fprintf(stderr,")\n");
- }
- else {
- add_data(&test, iv, hc[ie].cor, hc[ie].edg); /* keep test in sync */
- if(ncvarget (cdfid, iv, hc[ie].cor, hc[ie].edg, tmp.vals)
- == -1) {
- error("%s: ncvarget failed for point %d, variable %s",
- pname, ie, test.vars[iv].name);
- nerrs++;
- }
- else {
- if (val_cmp(test.vars[iv].type, nel[ie],
- hc[ie].vals, tmp.vals) != 0) {
- error("%s: bad values returned from ncvarget",
- pname);
- nerrs++;
- errvar(&test, &test.vars[iv]); /* describe var */
- }
- }
- }
- free (hc[ie].vals);
- free (tmp.vals);
- }
- }
- return nerrs;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputgetg.c b/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputgetg.c
deleted file mode 100644
index 337902f..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/nctest/vputgetg.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*********************************************************************
- * Copyright 1993, UCAR/Unidata
- * See netcdf/COPYRIGHT file for copying and redistribution conditions.
- * $Id: vputgetg.c,v 1.1.1.1 2005/06/14 04:38:31 svitak Exp $
- *********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h> /* for free() */
-#include "netcdf.h"
-#include "testcdf.h" /* defines in-memory test cdf structure */
-#include "add.h" /* functions to update in-memory netcdf */
-#include "val.h"
-#include "error.h"
-#include "tests.h"
-#include "emalloc.h"
-
-#undef max
-#define max(A, B) ((A) > (B) ? (A) : (B))
-
-/*
- * For every variable in open netcdf, puts and gets three hypercubes
- * of data of the appropriate type, comparing values from get to
- * values put to check that both ncvarputg and ncvargetg worked. The
- * three hypercubes are
- * - a large hypercube from (0, 0, ...) to the far corner (diagonally
- * opposite (0, 0, ...), trivial strides and index mapping vector;
- * - a size 1 hypercube from the far corner with edge lengths of 1
- * in every direction, trivial strides and index mapping vector; and
- * - a hypercube starting about 1/3 of the way along the diagonal
- * from (0,0,...) extending 1/3 of the way in every direction
- * toward the far corner, dimension-dependent strides and inverted
- * index mapping vector rooted at the "upper-left" corned.
- */
-
-int
-test_varputgetg(cdfid)
- int cdfid; /* handle of netcdf open and in data mode */
-{
- int nerrs = 0;
- static char pname[] = "test_varputgetg";
- int id, ie, iv; /* 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 */
- long npts[MAX_NC_DIMS]; /* netcdf edge lengths to upper corner */
- long strd[MAX_NC_DIMS]; /* external strides */
- long imap[MAX_NC_DIMS]; /* internal, index mapping vector */
- long offset; /* offset in bytes to I/O start corner */
- void *vals; /* pointer to block of values */
- } hc[3], tmp; /* test hypercubes */
- long nel[3]; /* number of elements in hypercube */
-
- 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 */
-
- /*
- * The following macro returns the size of a dimension for a
- * variable with a maximum dimension size of 5 for the record
- * dimension.
- */
-# define EXTNPTS(varid, idim) \
- (test.dims[test.vars[varid].dims[id]].size == NC_UNLIMITED \
- ? 5 \
- : test.dims[test.vars[varid].dims[id]].size)
-# define STRIDE(idim) (idim + 2)
-# define INTNPTS(extnpts, idim) (1 + (extnpts - 1) / STRIDE(idim))
-
-
- for (id = test.vars[iv].ndims-1; id >= 0; --id) { /* set cubes */
-
- /* start at "lower-left" corner, do whole variable. unity
- * strides and trivial index mapping */
- hc[0].cor[id] = 0;
- hc[0].npts[id] = EXTNPTS(iv, id);
- hc[0].strd[id] = 1;
- hc[0].imap[id] = id == test.vars[iv].ndims-1
- ? nctypelen(test.vars[iv].type)
- : hc[0].imap[id+1] * hc[0].npts[id+1];
- nel[0] *= hc[0].npts[id];
- if (id == 0)
- hc[0].offset = 0;
-
- /* start at "upper-right" corner, do one point */
- hc[1].cor[id] = EXTNPTS(iv, id) - 1;
- hc[1].npts[id] = 1;
- hc[1].strd[id] = 1;
- hc[1].imap[id] = id == test.vars[iv].ndims-1
- ? nctypelen(test.vars[iv].type)
- : hc[1].imap[id+1] * hc[1].npts[id+1];
- nel[1] *= hc[1].npts[id];
- if (id == 0)
- hc[1].offset = 0;
-
- /* start about 1/3 way along diagonal, do 1/3 in each direction.
- * dimension-dependent strides; inverted index mapping starting
- * from "upper-right" corner. */
- hc[2].cor[id] = EXTNPTS(iv, id)/3;
- hc[2].npts[id] = INTNPTS(max(EXTNPTS(iv, id)/3, 1), id);
- hc[2].strd[id] = STRIDE(id);
- hc[2].imap[id] = id == test.vars[iv].ndims-1
- ? -nctypelen(test.vars[iv].type)
- : hc[2].imap[id+1] * hc[2].npts[id+1];
- nel[2] *= hc[2].npts[id];
- if (id == 0)
- hc[2].offset = (nel[2]-1)*nctypelen(test.vars[iv].type);
- }
-
- for (ie = 0; ie < ne; ie++) { /* for each test */
- int nelms = (int)nel[ie]*nctypelen(test.vars[iv].type) + 8;
- /* allocate space for the cube of values */
- hc[ie].vals = emalloc(nelms);
- tmp.vals = emalloc(nelms);
-
- /* fill allocated space with different values of right type */
- val_fill(test.vars[iv].type, nel[ie], hc[ie].vals);
-
- if(ncvarputg (cdfid, iv, hc[ie].cor, hc[ie].npts,
- hc[ie].strd, hc[ie].imap,
- (char*)hc[ie].vals+hc[ie].offset)
- == -1) {
- error("%s: ncvarputg failed for point %d, variable %s",
- pname, ie, test.vars[iv].name);
- nerrs++;
- errvar(&test, &test.vars[iv]);
- (void)fprintf(stderr," corner = (");
- for (id = 0 ; id < test.vars[iv].ndims; id++)
- (void)fprintf(stderr,"%ld%s",(long)hc[ie].cor[id],
- (id < test.vars[iv].ndims-1) ? ", " : "");
- (void)fprintf(stderr,")\n");
- (void)fprintf(stderr," npts = (");
- for (id = 0 ; id < test.vars[iv].ndims; id++)
- (void)fprintf(stderr,"%ld%s",(long)hc[ie].npts[id],
- (id < test.vars[iv].ndims-1) ? ", " : "");
- (void)fprintf(stderr,")\n");
- (void)fprintf(stderr," external strides = (");
- for (id = 0 ; id < test.vars[iv].ndims; id++)
- (void)fprintf(stderr,"%ld%s",(long)hc[ie].strd[id],
- (id < test.vars[iv].ndims-1) ? ", " : "");
- (void)fprintf(stderr,")\n");
- (void)fprintf(stderr," internal index mapping vector = (");
- for (id = 0 ; id < test.vars[iv].ndims; id++)
- (void)fprintf(stderr,"%ld%s",(long)hc[ie].imap[id],
- (id < test.vars[iv].ndims-1) ? ", " : "");
- (void)fprintf(stderr,")\n");
- } else {
- long dsize[MAX_NC_DIMS];
-
- for (id = 0; id < test.vars[iv].ndims; id++)
- dsize[id] = EXTNPTS(iv, id);
- add_data(&test, iv, hc[ie].cor, dsize);
- /* keep test in sync */
- if(ncvargetg (cdfid, iv, hc[ie].cor, hc[ie].npts,
- hc[ie].strd, hc[ie].imap,
- (char*)tmp.vals+hc[ie].offset)
- == -1) {
- error("%s: ncvargetg failed for point %d, variable %s",
- pname, ie, test.vars[iv].name);
- nerrs++;
- }
- else {
- if (val_cmp(test.vars[iv].type, nel[ie],
- hc[ie].vals, tmp.vals) != 0) {
- error("%s: bad values returned from ncvargetg",
- pname);
- nerrs++;
- errvar(&test, &test.vars[iv]); /* describe var */
- }
- }
- }
-
- free (hc[ie].vals);
- free (tmp.vals);
- }
- }
- return nerrs;
-}
diff --git a/src/diskio/interface/netcdf/netcdf-3.4/src/rules.make b/src/diskio/interface/netcdf/netcdf-3.4/src/rules.make
deleted file mode 100644
index fdb33dc..0000000
--- a/src/diskio/interface/netcdf/netcdf-3.4/src/rules.make
+++ /dev/null
@@ -1,218 +0,0 @@
-# $Id: rules.make,v 1.1.1.1 2005/06/14 04:38:29 svitak Exp $
-
-# The purpose of this file is to contain common make(1) rules.
-# It should be processed by every execution of the that utility.
-
-.SUFFIXES:
-.SUFFIXES: .a .o .i .f .c .cc .F .y .l .m4
-
-
-################################################################################
-# Compilation (including preprocessing):
-
-.c.o:
- $(COMPILE.c) $<
-
-.c.i:
- $(CPP) $(CPPFLAGS) $< >$@
-
-.cc.o:
- $(COMPILE.cxx) $<
-
-# Not all FORTRAN compilers support C-preprocessing of *.F files; ergo, a
-# relatively complicated rule ensues.
-.F.o:
- @case "$(COMPILE.F)" in \
- '') \
- set -x; \
- $(FPP) $(FPPFLAGS) $*.F | grep -v '^#' >$*.f || \
- (rm $*.f ; exit 1); \
- $(COMPILE.f) $*.f || (rm $*.f; exit 1); \
- rm $*.f; \
- ;; \
- *) \
- set -x; \
- $(COMPILE.F) $<; \
- ;; \
- esac
-
-.f.o:
- $(COMPILE.f) $<
-
-.F.f:
- $(FPP) $(FPPFLAGS) $*.F | grep -v '^#' >$*.f || (rm $*.f; exit 1)
-
-.m4.c:
- $(M4) $(M4FLAGS) $< >$@
-
-.m4.F:
- $(M4) $(M4FLAGS) $< >$@
-
-
-################################################################################
-# Libraries:
-
-lib: $(LIBRARY)
-
-$(LIBRARY): $(LIB_OBJS) FORCE
- $(AR) $(ARFLAGS) $@ $(LIB_OBJS)
- $(RANLIB) $@
-
-#-------------------------------------------------------------------------------
-# Shared Libraries:
-#
-# Here only as a place holder and notebook. Don't try to use this stuff
-# unless you really, really know what you're doing! (And even then we
-# guarantee nothing!)
-#
-shared_library:
- @case `uname -sr` in \
- HP-UX*) \
- $(MAKE) hpux_shared_library;; \
- IRIX*) \
- $(MAKE) irix_shared_library;; \
- Linux*) \
- $(MAKE) linux_shared_library;; \
- OSF1*) \
- $(MAKE) osf1_shared_library;; \
- 'SunOS 4'*) \
- $(MAKE) sunos4_shared_library;; \
- 'SunOS 5'*) \
- $(MAKE) sunos5_shared_library;; \
- *) \
- echo 1>&2 "Don't know how to make a shared library" \
- "on this system"; \
- exit 1;; \
- esac
-
-hpux_shared_library:
- nm libnetcdf.a | grep extern | grep entry | \
- awk '-F|' '{print $$1}' | sed 's/^/-u /' >symbols.log
- ld -o $(LIBRARY:.a=.sl) -b -c symbols.log $(LIBRARY)
- rm symbols.log
-irix_shared_library:
- ld -o $(LIBRARY:.a=.so) -shared -no_archive \
- -all $(LIBRARY) -none -lc -lC $(LIBS)
-linux_shared_library:
- ld -o $(LIBRARY:.a=.so) -shared --whole-archive $(LIBRARY)
-osf1_shared_library:
- ld -o $(LIBRARY:.a=.so) -shared -all $(LIBRARY)
-sunos4_shared_library:
- undefopts=`/bin/nm $(LIBRARY) | awk '$$2~/^T$$/{print $$3}' | \
- sed 's/^/-u /'` && \
- ld -o $(LIBRARY:.a=.so) $$undefopts $(LIBRARY)
-sunos5_shared_library:
- undefopts=`/usr/ccs/bin/nm $(LIBRARY) | grep GLOB | grep FUNC | \
- awk '-F|' '{print $$8}' | sed 's/^/-u /'` && \
- ld -o $(LIBRARY:.a=.so) -G $$undefopts $(LIBRARY)
-
-
-################################################################################
-# Linking:
-
-
-################################################################################
-# Installation:
-
-$(INCDIR)/$(HEADER): $(INCDIR) $(HEADER)
- cp $(HEADER) $@
-$(INCDIR)/$(HEADER1): $(INCDIR) $(HEADER1)
- cp $(HEADER1) $@
-$(INCDIR)/$(HEADER2): $(INCDIR) $(HEADER2)
- cp $(HEADER2) $@
-
-$(LIBDIR)/$(LIBRARY): $(LIBDIR) $(LIBRARY)
- cp $(LIBRARY) $@
-
-$(BINDIR)/$(PROGRAM): $(BINDIR) $(PROGRAM)
- cp $(PROGRAM) $@
-
-$(BINDIR) \
-$(INCDIR) \
-$(LIBDIR) \
-$(MANDIR) :
- -test -d $@ || mkdir $@
-
-$(MANDIR)/man1 \
-$(MANDIR)/man3 \
-$(MANDIR)/man3f : $(MANDIR)
- -test -d $@ || mkdir $@
-
-$(MANDIR)/man1/$(MANUAL): $(MANDIR)/man1 $(MANUAL)
- cp $(MANUAL) $@
-$(MANDIR)/man3/$(MANUAL): $(MANDIR)/man3 $(MANUAL)
- cp $(MANUAL) $@
-$(MANDIR)/man3f/$(MANUAL): $(MANDIR)/man3 $(MANDIR)/man3/$(MANUAL) \
- $(MANDIR)/man3f
- rm -f $@
- ln -s $(MANDIR)/man3/$(MANUAL) $@
-
-whatis: $(MANDIR)/$(WHATIS)
-$(MANDIR)/$(WHATIS): $(MANDIR)
- $(MAKEWHATIS_CMD)
-
-################################################################################
-# Cleanup:
-
-clean: FORCE
- rm -f *.o *.a *.so *.sl *.i *.Z core $(GARBAGE)
-
-distclean: FORCE
- rm -f *.o *.a *.so *.sl *.i *.Z core $(GARBAGE) \
- MANIFEST *.log $(DIST_GARBAGE)
-
-
-################################################################################
-# Dependencies:
-
-# This target should only need to be made at the UPC.
-# NOTES:
-# * The target file might be a symbolic link.
-# * The name of the target doesn't match the name of the created file to
-# prevent constant updating of the included file `depend' by make(1).
-#
-deps: FORCE
- $(CC_MAKEDEPEND) $(CPPFLAGS) *.c | grep -v '/usr/include' >>depend
- sort -u -o depend depend
-
-
-################################################################################
-# Distribution:
-
-# The following rule echoes the contents of $(PACKING_LIST) in the
-# current directory and in all subdirectories. All pathnames are made
-# relative to the current directory.
-#
-MANIFEST.echo: FORCE
- @echo $(PACKING_LIST) | fmt -1
- @if [ -n "$(SUBDIRS)" ]; then \
- subdirs="$(SUBDIRS)"; \
- for subdir in $$subdirs; do \
- (cd $$subdir && \
- echo 1>&2 Creating $@ in `pwd` && \
- $(MAKE) MANIFEST.echo | sed "s|^|$$subdir/|") || exit 1; \
- done; \
- else \
- :; \
- fi
-
-# The following rule ensures that all files in $(PACKING_LIST) exist in
-# the current directory and in all subdirectories.
-#
-ensure_manifest: $(PACKING_LIST) FORCE
- @if [ -n "$(SUBDIRS)" ]; then \
- subdirs="$(SUBDIRS)"; \
- for subdir in $$subdirs; do \
- (cd $$subdir && \
- echo 1>&2 Creating $@ in `pwd` && \
- $(MAKE) ensure_manifest) || exit 1; \
- done; \
- else \
- :; \
- fi
-
-
-################################################################################
-# Misc:
-
-FORCE:
--
general-purpose neural simulator
More information about the debian-science-commits
mailing list