Merge branch 'master' into dapparams.dmh

This commit is contained in:
Ward Fisher 2018-04-02 13:55:02 -06:00 committed by GitHub
commit a13b722af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
98 changed files with 3249 additions and 1320 deletions

9
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,9 @@
# These owners will be the default owners for everything in the repo.
# Unless a later match takes precedence, global owners
# will be requested for review when someone opens a pull request.
* @WardF @DennisHeimbigner
# Order is important; the last matching pattern takes the most precedence.
# When someone opens a pull request that only modifies specified file types, only
# that owner will be requested for a review, not the global owner(s).
# Email addresses can be used as well as GitHub user names.

View File

@ -1,5 +1,5 @@
## This is a CMake file, part of Unidata's netCDF package.
# Copyright 2012-2014, see the COPYRIGHT file for more information.
# Copyright 2012-2018, see the COPYRIGHT file for more information.
#
##################################
@ -26,7 +26,7 @@ set(PACKAGE "netCDF" CACHE STRING "")
SET(NC_VERSION_MAJOR 4)
SET(NC_VERSION_MINOR 6)
SET(NC_VERSION_PATCH 1)
SET(NC_VERSION_PATCH 2)
SET(NC_VERSION_NOTE "-development")
SET(netCDF_VERSION ${NC_VERSION_MAJOR}.${NC_VERSION_MINOR}.${NC_VERSION_PATCH}${NC_VERSION_NOTE})
SET(VERSION ${netCDF_VERSION})
@ -1281,9 +1281,18 @@ CHECK_TYPE_SIZE("_Bool" SIZEOF__BOOL)
CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
CHECK_TYPE_SIZE("ssize_t" HAVE_SSIZE_T)
CHECK_TYPE_SIZE("ssize_t" SIZEOF_SSIZE_T)
IF(SIZEOF_SSIZE_T)
SET(HAVE_SSIZE_T TRUE)
ENDIF(SIZEOF_SSIZE_T)
CHECK_TYPE_SIZE("ptrdiff_t" SIZEOF_PTRDIFF_T)
IF(SIZEOF_PTRDIFF_T)
SET(HAVE_PTRDIFF_T TRUE)
ENDIF(SIZEOF_PTRDIFF_T)
CHECK_TYPE_SIZE("uintptr_t" SIZEOF_UINTPTR_T)
IF(SIZEOF_UINTPTR_T)
SET(HAVE_UINTPTR_T TRUE)
ENDIF(SIZEOF_UINTPTR_T)
# __int64 is used on Windows for large file support.
CHECK_TYPE_SIZE("__int64" SIZEOF___INT_64)
@ -1623,6 +1632,7 @@ ENDIF(USE_HDF5)
IF(USE_HDF4)
add_subdirectory(libhdf4)
add_subdirectory(hdf4_test)
ENDIF(USE_HDF4)
IF(ENABLE_DAP2)

46
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support-netcdf@unidata.ucar.edu. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

2
Make0
View File

@ -1,4 +1,4 @@
T=t_dap3a
T=tst_fileinfo
NCLIB=./liblib/.libs/libnetcdf.a
D4LIB=./libdap4/.libs/libdap4.a

View File

@ -7,6 +7,9 @@
# Ed Hartnett, Ward Fisher
# This directory stores libtool macros, put there by aclocal.
ACLOCAL_AMFLAGS = -I m4
@ -64,13 +67,14 @@ endif
# Build HDF4 if desired.
if USE_HDF4
HDF4_TEST_DIR = hdf4_test
LIBHDF4 = libhdf4
endif
# Define Test directories
if BUILD_TESTSETS
TESTDIRS = $(V2_TEST) nc_test $(NC_TEST4) $(NCDAP2TESTDIR) \
$(NCDAP4TESTDIR)
TESTDIRS = $(V2_TEST) nc_test $(NC_TEST4) $(HDF4_TEST_DIR) \
$(NCDAP2TESTDIR) $(NCDAP4TESTDIR)
endif
# This is the list of subdirs for which Makefiles will be constructed

View File

@ -5,8 +5,10 @@ Release Notes {#RELEASE_NOTES}
This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries.
## 4.6.1 - TBD
## 4.6.1 - March 19, 2018
* [Bug Fix] Corrected an issue which could result in a dap4 failure. See [Github #888](https://github.com/Unidata/netcdf-c/pull/888) for more information.
* [Bug Fix][Enhancement] Allow `nccopy` to control output filter suppresion. See [Github #894](https://github.com/Unidata/netcdf-c/pull/894) for more information.
* [Enhancement] Reverted some new behaviors that, while in line with the netCDF specification, broke existing workflows. See [Github #843](https://github.com/Unidata/netcdf-c/issues/843) for more information.
* [Bug Fix] Improved support for CRT builds with Visual Studio, improves zlib detection in hdf5 library. See [Github #853](https://github.com/Unidata/netcdf-c/pull/853) for more information.
* [Enhancement][Internal] Moved HDF4 into a distinct dispatch layer. See [Github #849](https://github.com/Unidata/netcdf-c/pull/849) for more information.

20
cf
View File

@ -1,8 +1,10 @@
#!/bin/bash
#NB=1
#DB=1
DB=1
#X=-x
FAST=1
LEAK=1
#PROF=1
HDF5=1
DAP=1
@ -92,7 +94,6 @@ fi
CXXFLAGS="$CPPFLAGS $CXXFLAGS"
FLAGS="--prefix ${PREFIX}"
#FLAGS="$FLAGS --disable-f77 --disable-f90"
#FLAGS="$FLAGS --disable-cxx"
#FLAGS="$FLAGS --disable-examples"
#FLAGS="$FLAGS --disable-utilities"
@ -117,14 +118,15 @@ FLAGS="$FLAGS --enable-logging"
#FLAGS="$FLAGS --disable-properties-attribute"
#FLAGS="$FLAGS --disable-silent-rules"
#FLAGS="$FLAGS --with-testservers=remotestserver.localhost:8083"
FLAGS="$FLAGS --enable-filter-testing"
#FLAGS="$FLAGS --enable-filter-testing"
if test "x$PAR4" != x1 ; then
FLAGS="$FLAGS --disable-parallel4"
fi
if test "x${DB}" = x1 ; then
FLAGS="$FLAGS --disable-shared --enable-static"
#FLAGS="$FLAGS --disable-shared --enable-static"
FLAGS="$FLAGS --enable-static"
else
FLAGS="$FLAGS --enable-shared"
fi
@ -168,7 +170,15 @@ if test "x$MPIO" = x1 ; then
FLAGS="$FLAGS --enable-parallel-tests"
fi
#FLAGS="${FLAGS} --enable-stdio"
if test "x${PROF}" = x1 ; then
CFLAGS="${CFLAGS} -pg"
LDFLAGS="${LDFLAGS} -pg"
fi
if test "x${LEAK}" = x1 ; then
CFLAGS="${CFLAGS} -fsanitize=address -fno-omit-frame-pointer"
export ASAN_OPTIONS="detect_leaks=1:verbosity=1"
fi
export PATH
export CC

View File

@ -1,7 +1,7 @@
# Visual Studio
# Is netcdf-4 and/or DAP enabled?
#NC4=1
NC4=1
DAP=1
CDF5=1
#HDF4=1

View File

@ -559,6 +559,9 @@ are set when opening a binary file on Windows. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#cmakedefine size_t unsigned int
/* Define to `int' if <sys/types.h> does not define. */
#cmakedefine ssize_t int
/* Define to `unsigned long if <sys/types.h> does not define. */
#cmakedefine uintptr_t unsigned long

View File

@ -16,7 +16,7 @@ AC_REVISION([$Id: configure.ac,v 1.450 2010/05/28 19:42:47 dmh Exp $])
AC_PREREQ([2.59])
# Initialize with name, version, and support email address.
AC_INIT([netCDF], [4.6.1-development], [support-netcdf@unidata.ucar.edu])
AC_INIT([netCDF], [4.6.2-development], [support-netcdf@unidata.ucar.edu])
##
# Prefer an empty CFLAGS variable instead of the default -g -O2.
@ -27,7 +27,7 @@ AC_INIT([netCDF], [4.6.1-development], [support-netcdf@unidata.ucar.edu])
AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4
AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=6
AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=1
AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=2
AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-development"
#####
@ -72,8 +72,8 @@ AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat1.nc:nc_test4/ref_hdf5_compat1.nc])
AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat2.nc:nc_test4/ref_hdf5_compat2.nc])
AC_CONFIG_LINKS([nc_test4/ref_hdf5_compat3.nc:nc_test4/ref_hdf5_compat3.nc])
AC_CONFIG_LINKS([nc_test4/ref_chunked.hdf4:nc_test4/ref_chunked.hdf4])
AC_CONFIG_LINKS([nc_test4/ref_contiguous.hdf4:nc_test4/ref_contiguous.hdf4])
AC_CONFIG_LINKS([hdf4_test/ref_chunked.hdf4:hdf4_test/ref_chunked.hdf4])
AC_CONFIG_LINKS([hdf4_test/ref_contiguous.hdf4:hdf4_test/ref_contiguous.hdf4])
AM_INIT_AUTOMAKE([foreign dist-zip subdir-objects])
@ -794,6 +794,8 @@ AC_STRUCT_ST_BLKSIZE
UD_CHECK_IEEE
AC_CHECK_TYPES([size_t, ssize_t, schar, uchar, longlong, ushort, uint, int64, uint64])
AC_TYPE_OFF_T
AC_TYPE_UINTPTR_T
AC_C_CHAR_UNSIGNED
AC_C_BIGENDIAN
###
@ -1304,12 +1306,12 @@ AC_MSG_RESULT($enable_filter_testing)
if test "x$enable_netcdf_4" = xno ; then
AC_MSG_WARN([netCDF-4 disabled => --disable-filter-testing])
enable_filter_testing = no
enable_filter_testing=no
fi
if test "x$enable_shared" = xno ; then
AC_MSG_WARN([Shared libraries are disabled => --disable-filter-testing])
enable_filter_testing = no
enable_filter_testing=no
fi
AM_CONDITIONAL(ENABLE_FILTER_TESTING, [test x$enable_filter_testing = xyes])
@ -1430,6 +1432,7 @@ AC_CONFIG_FILES([Makefile
include/netcdf_meta.h
include/Makefile
h5_test/Makefile
hdf4_test/Makefile
libsrc/Makefile
libsrc4/Makefile
libsrcp/Makefile

View File

@ -38,7 +38,7 @@ PROJECT_NAME = netCDF-C
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 4.6.1-development
PROJECT_NUMBER = 4.6.2-development
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -750,7 +750,6 @@ INPUT = \
@abs_top_srcdir@/docs/install-fortran.md \
@abs_top_srcdir@/docs/types.dox \
@abs_top_srcdir@/docs/internal.dox \
@abs_top_srcdir@/docs/indexing.dox \
@abs_top_srcdir@/docs/windows-binaries.md \
@abs_top_srcdir@/docs/guide.dox \
@abs_top_srcdir@/docs/OPeNDAP.dox \

View File

@ -4,10 +4,6 @@ netCDF Authorization Support
# netCDF Authorization Support {#Header}
__Author__: Dennis Heimbigner<br>
__Initial Version__: 11/21/2014<br>
__Last Revised__: 08/24/2017
[TOC]
## Introduction {#Introduction}
@ -515,3 +511,10 @@ what you changed to the author so this document can be updated.
yes | keytool -trustcacerts -storepass "$PWD" -v -keystore ./$TRUSTSTORE -alias $alias -importcert -file "${c}"
done
exit
## Provenance
__Author__: Dennis Heimbigner<br>
__Initial Version__: 11/21/2014<br>
__Last Revised__: 08/24/2017

View File

@ -142,10 +142,34 @@ The "-F" option can be used repeatedly as long as the variable name
part is different. A different filter id and parameters can be
specified for each occurrence.
Note that if the input file has compressed variables, that fact
will be invisble to nccopy because it is handled within the
netcdf-c/hdf5 library code. This is true for any program that calls
the netcdf-c library.
As a rule, any input filter on an input variable will be applied
to the equivalent output variable -- assuming the output file type
is netcdf-4. It is, however, sometimes convenient to suppress
output compression either totally or on a per-variable basis.
Total suppression of output filters can be accomplished by specifying
a special case of "-F", namely this.
````
nccopy -F "none" input.nc output.nc
````
Suppression of output filtering for a specific variable can be accomplished
using this format.
````
nccopy -F "var,none" input.nc output.nc
````
where "var" is the fully qualified name of the variable.
The rules for all possible cases of the "-F" flag are defined
by this table.
<table>
<tr><th>-F none<th>-Fvar,...<th>Input Filter<th>Applied Output Filter
<tr><td>true<td>unspecified<td>NA<td>unfiltered
<tr><td>true<td>-Fvar,none<td>NA<td>unfiltered
<tr><td>true<td>-Fvar,...<td>NA<td>use output filter
<tr><td>false<td>unspecified<td>defined<td>use input filter
<tr><td>false<td>-Fvar,none<td>NA<td>unfiltered
<tr><td>false<td>-Fvar,...<td>NA<td>use output filter
</table>
Parameter Encoding {#ParamEncode}
==========
@ -411,10 +435,18 @@ static const unsigned char b[4] = {0x0,0x0,0x0,0x1}; /* value 1 in big-endian*/
int endianness = (1 == *(unsigned int*)b); /* 1=>big 0=>little endian
````
Provenance
================
__Author__: Dennis Heimbigner<br>
__Email__: dmh at ucar dot edu
__Initial Version__: 1/10/2018<br>
__Last Revised__: 2/5/2018
References {#References}
==========
1. https://support.hdfgroup.org/HDF5/doc/Advanced/DynamicallyLoadedFilters/HDF5DynamicallyLoadedFilters.pdf
2. https://support.hdfgroup.org/HDF5/doc/TechNotes/TechNote-HDF5-CompressionTroubleshooting.pdf
3. https://support.hdfgroup.org/services/filters.html
3. https://portal.hdfgroup.org/display/support/Contributions#Contributions-filters
4. https://support.hdfgroup.org/services/contributions.html#filters

View File

@ -8,7 +8,7 @@
The original internal representations of metadata in memory
relied on linear searching of lists to locate various objects
by name or by numeric id (e.g. varid or grpid).
by name or by numeric id (e.g. "varid" or "grpid").
In recent years, the flaws in that approach have become obvious
as users create files with extremely large numbers of objects:
@ -16,7 +16,7 @@ group, variables, attributes, and dimensions. One case
has 14 megabytes of metadata. Creating and (especially) later
opening such files was exceedingly slow.
This problem was partially alleviated in both netcdfd-3 (libsrc)
This problem was partially alleviated in both netcdf-3 (libsrc)
and netcdf-4 (libsrc4) by adding name hashing tables.
However, and especially for netcdf-4, linear search still prevailed.
@ -28,6 +28,7 @@ lookup). The cases left as linear search include these.
1. Enum constants for an enumeration
2. Dimensions associated with a variable
3. Fields of Compound types
4. Searches when we have neither the id nor the name of an object.
This document describes the architecture and details of the netCDF
internal object lookup mechanisms now in place.
@ -38,15 +39,16 @@ There are, as a rule, two searches that are used to locate
metadata object: (1) search by name and (2) search by
externally visible id (e.g. dimid or varid).
Currently, and after all the metadata is read or created,
It is currently the case that after all the metadata is read or created,
hashing is used for locating objects by name. In all other
cases -- apparently -- lookup is by linear search of some
kind of linked list or a vector.
It is relevant that, once created, no metadata object -- except
attributes -- can be deleted. They can be renamed, but that
does not change the associated id. Deletion only occurs when an
error occurs in creating an object or on invoking nc_close.
does not change the associated structure or id. Deletion only
occurs when an error occurs in creating an object or on invoking
"nc_close()".
The numeric identifiers for dimensions, types, and groups are
all globally unique across a file. But note that variable id's
@ -77,7 +79,7 @@ It is possible to append new objects or insert at a specific
vector offset, or overwrite an existing pointer at a specific
offset.
The definition is as follows.
The NClist structure definition is as follows.
\code
typedef struct NClist {
@ -87,16 +89,17 @@ typedef struct NClist {
} NClist;
\endcode
\subsection SS1_2 NC_hashmap
The NC_hashmap type is a hash table mapping a name to a pointer.
As a rule, the pointer points to a metadata object. The current
implementation supports table expansion when the # of entries in
the table starts to get too large. Basically a simple linear
rehash is used for collisions and no separate hash-chain is
used. This means that when expanded, it must be completely
rebuilt. The performance hit for this has yet to be determined.
The NC_hashmap type is a hash table mapping a sequence of bytes
(the key) to a data item. As a rule, the data item is a pointer to a
metadata object. The current implementation supports table
expansion when the # of entries in the table starts to get too
large. Basically a simple linear rehash is used for collisions
and no separate hash-chain is used. This means that when
expanded, it must be completely rebuilt. The performance hit for
this has yet to be determined. The alternative is to move to some
form of extendible hashing as used in databases.
The hashtable definition is as follows.
@ -115,9 +118,10 @@ a vector of entries of this form.
\code
typedef struct NC_hentry {
int flags;
void* data;
size_t hashkey; /* Hash id */
char* key; /* actual key; do not free */
uintptr_t data;
unsigned int hashkey;
size_t keysize;
uintptr_t key;
} NC_hentry;
\endcode
@ -128,40 +132,50 @@ The flags indicate the state of the entry and can be one of three states:
that linear rehash will work.
3. EMPTY - unused
There is an important WARNING with respect to the "key" field.
The key is not a copy of the object's name, but in fact is a duplicate
pointer to that same string. This means (1) that it should never be
free()'d and (2) if the name of the metadata object is changed, then
it must be removed and re-inserted into the table to that the key
points to the current name.
The "data" field is of type "uintptr_t". Note that we assume
that sizeof(unintptr_t) == sizeof(void*). This is very
important. It is supposed to be the case that a value of type
uintptr_t is an integer of sufficient size to hold a void* pointer.
The "data" field is of type void*. Often it is a pointer to an instance
of a variable, or dimension, or other object. When used as part of an
NC_listmap (see below), then the key is an integer index into the
associated vector. In order to do this correctly, we need to rely
on the type "uintptr_t". It is supposed to be the case
that a value of type uintptr_t is an integer of sufficient size to
hold a void* pointer. Usually, but not always, this would be the same
size as an "unsigned long" value. Using this allows the hashtable
to store either pointers or integer indices.
This means that the data field can hold an unsigned integer or a
void* pointer. As a pointer, it often points to an instance of a
variable, or dimension, or other object.
One further WARNING: any object that will be inserted into an NC_hashmap
must have its name as the first field so it can be cast
to char** for use with the hashtable.
The hashkey field is a CRC32 hash of the key. Note that comparing
hashkeys is not sufficient to ensure that the corresponding keys are
the same because hash collisions are possible. Even moving to, say,
64 bit keys, is probably not sufficient to avoid hash collisions.
A 128 bit key might (e.g. MD5) might be sufficient but mathematical
investigation would be required.
Since comparing hash keys is not sufficient, it is necessary to store
a reference to the actual key. The key and keysize fields are used for this.
Again note that the key is of uintptr_t type.
There are some rather nasty hacks associated with storing of the key.
1. If the keysize <= sizeof(uintptr_t), then the actual key is stored
in the key field.
2. Otherwise, a pointer to the key is stored in the key field. It is important
to note that this is NOT a copy of the incoming key, but is the key pointer itself.
Usually this will be the name of a metadata object stored in the metadata structure
(e.g. NC_DIM_INFO_T). This places restraints on the renaming or deletion of
metadata objects since the key in the hash table may be incorrect.
\subsection SS1_3 NC_listmap
A listmap is a combination of an NClist and an NC_hashtable.
It is used to provide name-based lookup with respect to a
A listmap is a combination of an NClist and an NC_hashmap instances.
A listmap is used to provide several kinds of lookup with respect to a
specific list of metadata objects. For example, the subgroups
of a group are stored using a listmap, where the list is a
vector of pointers to the subgroup objects and the hashmap
maps the subgroup name (unique to that group, remember) to
the corresponding index into the vector. In theory, only
the hashmap is needed because it could be walked to get all
of the metadata objects. However, the creation order is sometimes
important, so that is maintained by the vector.
This is especially important for attribute storage.
of a group are stored using a vector of pointers to the subgroup objects.
This also provides information about creation order, which is sometimes
important.
However, we often need fast access to that vector by name
so a list map provides these capabilities.
1. A vector into which the object pointers can be stored
and iterated over.
2. A map from name to the corresponding object index in the vector.
Note that currently, NC_listmap is only used in libsrc4,
but if performance issues warrant, it will also be used in
@ -174,13 +188,13 @@ grpid, typeid) are unique across the whole file. It is therefore
convenient to store in memory a per-file vector for each object
type such that the external id of the object is the same as the
position of that object in the corresponding per-file
vector. This maked lookup by external id efficient.
vector. This makes lookup by external id efficient.
Note that this is was already the case for netcdf-3 (libsrc) so
this is a change for libsrc4 only.
The global set of dimensions, types, and groups is maintained by
three instances of NClist in the NC_HDF5_FILE_INFO structure:
alldims, alltypes, and allgroups.
namely alldims, alltypes, and allgroups.
The position of the object within the corresponding list determines
the object's external id. Thus, a position of a dimension object within the
"alldims" field of the file structure determines its dimid. Similarly
@ -188,31 +202,71 @@ for types and groups.
\section S4 Per-Group Object Access
Each group object (NC_GRP_INFO) contains four
instances of NC_listmap. One is for dimensions, one is for
types, one is for subgroups, and one is for variables. A
listmap is used for two reasons. First, allows name-based lookup
Each group object (NC_GRP_INFO) contains five instances of
NC_listmap. One is for dimensions, one is for types, one is for
subgroups, one is for variables, and one is for attributes. A
listmap is used for two reasons. First, it allows name-based lookup
for these items. Second, the declaration order is maintained by
the list within the listmap's vector. Note that the position of
an object in a group listmap vector has no necessary
relationship to the position of that object within the global
vectors. Note also that there is no global vector for variables
because variable external ids are unique only within the
group. In this special case, the external id for the variable is
vectors.
Note however that the listmap vector for variables does define
the variable id, which is unique only within a group.
In this special case, the external id for the variable is
the same as its offset in the listmap's vector for the group.
A note about typeids. Since user defined types have an external
id starting at NC_FIRSTUSERTYPEID, we leave the global type
vector entries 0..NC_FIRSTUSERTYPEID-1 empty.
\section S5 Exceptions
\section S6 Metadata Object Header
NC_Listmap is currently not used for enum constants and compound fields.
Each metadata object (e.g. NC_DIM_INFO_T, NC_VAR_INFO_T)
now has what is called a "hdr" object as its first field.
This provides a form of pseudo-inheritance for these objects
because they can all be cast to "NC_OBJ" to get common information.
The structure of the header is as follows.
\code
typedef struct NC_OBJ {
NC_SORT sort;
char* name; /* assumed to be null terminated */
size_t id;
} NC_OBJ;
\endcode
The sort is one of the values NCVAR, NCDIM, NCATT, NCTYP, or NCGRP.
The name is assumed to be nul terminated. The id is the assigned id
for the object.
\section S5 Implementation Alternatives.
1. As an alternative to the use of the alldims, allgrps, etc.,
vectors, we could use a listmap that maps the object id to
the vector index of the object with that id. This would allow
us to have holes in the object id space and still have O(1)
access time. This would require keeping (as it was before)
various object id counters.
\section S6 Notes and Warning
1. NC_Listmap is currently not used for enum constants and compound fields.
Additionally, it is not used for listing the dimensions associated
with a variable.
References between meta-data objects (e.g. group parent or
2. References between meta-data objects (e.g. group parent or
containing group) are stored directly and not using any kind
of vector or hashtable.
3. Attribute deletion is still a costly operation because it causes
the whole attribute listmap to be rebuilt.
4. Renaming is still a costly operation because it causes
the whole containing listmap to be rebuilt.
\section Provenance
__Author__: Dennis Heimbigner<br>
__Initial Version__: 01/10/2018<br>
__Last Revised__: 02/24/2018
*/

View File

@ -26,6 +26,7 @@ To date, at least the following dispatch tables are supported.
- DAP2 to netcdf-3
- DAP4 to netcdf-4
- pnetcdf (parallel cdf5)
- HDF4
Internal Dispatch Tables
- \subpage adding_dispatch

View File

@ -10,7 +10,10 @@ TARGETS = ${PLUGINSRC} ${BZIP2SRC}
BUILT_SOURCES = ${TARGETS}
${TARGETS}:
for x in ${TARGETS} ; do 'cp' -f ${top_srcdir}/nc_test4/hdf5plugins/$$x . ; done
for x in ${TARGETS} ; do \
rm -f ./$$x; \
'cp' -f ${top_srcdir}/nc_test4/hdf5plugins/$$x . ; \
done
CLEANFILES = ${TARGETS}
@ -21,7 +24,7 @@ DLLSRC=${PLUGINSRC} ${BZIP2SRC}
lib_LTLIBRARIES = libbzip2.la
libbzip2_la_SOURCES = ${DLLSRC}
libbzip2_la_LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined
libbzip2_la_LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined -rpath ${abs_builddir}
endif #ENABLE_FILTER_TESTING
EXTRA_DIST = CMakeLists.txt H5Zbzip2.c Makefile.am blocksort.c bzlib.c bzlib.h bzlib_private.h compress.c \

16
hdf4_test/CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.hdf4)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
ENDIF()
IF(USE_HDF4_FILE_TESTS AND NOT MSVC)
build_bin_test_no_prefix(tst_interops2)
build_bin_test_no_prefix(tst_interops3)
add_bin_test(hdf4_test tst_chunk_hdf4)
add_bin_test(hdf4_test tst_h4_lendian)
add_sh_test(hdf4_test run_get_hdf4_files)
add_sh_test(hdf4_test run_formatx_hdf4)
ENDIF()

37
hdf4_test/Makefile.am Normal file
View File

@ -0,0 +1,37 @@
# This is part of the netCDF package.
# Copyright 2018 University Corporation for Atmospheric Research/Unidata
# See COPYRIGHT file for conditions of use.
#
# This directory has tests for the HDF4 code. This directory will be
# skipped if HDF4 is not enabled.
#
# Ed Hartnett
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
# Link to our assembled library.
AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
# These are the C tests for HDF4.
check_PROGRAMS = tst_chunk_hdf4 tst_h4_lendian
TESTS = tst_chunk_hdf4 tst_h4_lendian
# This test script depends on ncdump and tst_interops2.c.
if BUILD_UTILITIES
check_PROGRAMS += tst_interops2
TESTS += run_formatx_hdf4.sh
endif # BUILD_UTILITIES
# This test script fetches HDF4 files from an FTP server and uses
# program tst_interops3.c to read them.
if USE_HDF4_FILE_TESTS
check_PROGRAMS += tst_interops3
TESTS += run_get_hdf4_files.sh
endif # USE_HDF4_FILE_TESTS
EXTRA_DIST = CMakeLists.txt ref_contiguous.hdf4 ref_chunked.hdf4 \
run_get_hdf4_files.sh run_formatx_hdf4.sh
CLEANFILES = *.h4 *.hdf

51
hdf4_test/run_formatx_hdf4.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
# This shell script runs tst_interops2 to create a HDF4 file, and read
# it with netCDF. Then the script runs ncdump on the HDF4 file.
# Ed Hartnett
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
FILE=tst_interops2.h4
ECODE=0
echo ""
echo "*** Testing extended file format output."
set -e
echo "Creating HDF4 file"
${execdir}/tst_interops2
echo "Test extended format output for a HDF4 file"
rm -f tmp_tst_formatx_hdf4
${NCDUMP} -K $FILE >tmp_tst_formatx_hdf4
if ! fgrep 'HDF4 mode=00001000' <tmp_tst_formatx_hdf4 ; then
TMP=`cat tmp_tst_formatx_hdf4`
echo "*** Fail: extended format for an HDF4 file: result=" $TMP
ECODE=1
fi
rm -f tmp_tst_formatx_hdf4
# Exit if there was a failure.
if test $ECODE = 1 ; then
exit $ECODE
fi
echo ""
echo "*** Testing reading an individual variable from an HDF4 file."
${NCDUMP} -v hdf4_dataset_type_0 $FILE
${NCDUMP} -v hdf4_dataset_type_1 $FILE
${NCDUMP} -v hdf4_dataset_type_2 $FILE
${NCDUMP} -v hdf4_dataset_type_3 $FILE
${NCDUMP} -v hdf4_dataset_type_4 $FILE
${NCDUMP} -v hdf4_dataset_type_5 $FILE
${NCDUMP} -v hdf4_dataset_type_6 $FILE
${NCDUMP} -v hdf4_dataset_type_7 $FILE
echo "*** Success."

View File

@ -1,5 +1,7 @@
#!/bin/sh
#Q=-q
# This shell gets some sample HDF4 files from the netCDF ftp site for
# testing. Then it runs program tst_interops3 on the test file to
# check that HDF4 reading works.
@ -9,6 +11,20 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Get a file from the ftp site; retry several times
getfile() {
FTPFILE="ftp://ftp.unidata.ucar.edu/pub/netcdf/sample_data/hdf4/$1.gz"
for try in 1 2 3 4 ; do # try 4 times
# signal sucess/failure
if wget -c $Q --passive-ftp $FTPFILE ; then
return 0 # got it
fi
echo "wget failed: try $try"
sleep 5 # seconds
done
return 1 # did not get it
}
set -e
echo ""
echo "Getting HDF4 sample files from Unidata FTP site..."
@ -21,8 +37,12 @@ echo "Getting HDF4 test files $file_list"
for f1 in $file_list
do
if ! test -f $f1; then
curl -O "ftp://ftp.unidata.ucar.edu/pub/netcdf/sample_data/hdf4/$f1.gz"
gunzip $f1.gz
if getfile $f1 ; then
gunzip $f1.gz
else
echo Could not ftp $f1.gz
return 1
fi
fi
done

View File

@ -65,7 +65,7 @@ main(int argc, char **argv)
/* Expected this to return NC_EPERM, but instead it returns
* success. See github issue #744. */
/* if (nc_def_var_chunking_ints(ncid, 0, NC_CONTIGUOUS, NULL) != NC_EPERM) ERR; */
/* if (nc_def_var_chunking_ints(ncid, 0, NC_CONTIGUOUS, NULL)) ERR; */
/* Read the data through a vara function from the netCDF API. */
if (nc_get_vara(ncid, 0, nstart, ncount, data_in)) ERR;

View File

@ -77,7 +77,6 @@ main(int argc, char **argv)
"MOD29.A2000055.0005.005.2006267200024.hdf",
"MYD29.A2002185.0000.005.2007160150627.hdf",
"MYD29.A2009152.0000.005.2009153124331.hdf"};
size_t len_in;
int expected_mode = NC_NETCDF4;
int expected_extended_format = NC_FORMATX_NC_HDF4;
int f;

View File

@ -19,9 +19,10 @@ endif
noinst_HEADERS = nc_logging.h nc_tests.h fbits.h nc.h nclist.h \
ncuri.h ncutf8.h ncdispatch.h ncdimscale.h netcdf_f.h err_macros.h \
ncbytes.h nchashmap.h ceconstraints.h rnd.h nclog.h ncconfigure.h \
nc4internal.h nctime.h nc3internal.h onstack.h nc_hashmap.h ncrc.h \
nc4internal.h nctime.h nc3internal.h onstack.h ncrc.h \
ncauth.h ncoffsets.h nctestserver.h nc4dispatch.h nc3dispatch.h \
ncexternl.h ncwinpath.h ncfilter.h hdf4dispatch.h nclistmap.h
ncexternl.h ncwinpath.h ncfilter.h ncindex.h hdf4dispatch.h \
nc4xinternal.h
if USE_DAP
noinst_HEADERS += ncdap.h

View File

@ -40,7 +40,6 @@ typedef struct {
/* all xdr'd */
size_t nchars;
char *cp;
} NC_string;
/* Define functions that are used across multiple dispatchers */

View File

@ -25,6 +25,8 @@
/* Always needed */
#include "nc.h"
#include "nchashmap.h"
#ifndef NC_ARRAY_GROWBY
#define NC_ARRAY_GROWBY 4
#endif
@ -55,25 +57,6 @@ typedef enum {
NC_ATTRIBUTE = 12
} NCtype;
#ifndef NEWHASHMAP /* temporary hack until new hash is complete */
/*! Hashmap-related structs.
NOTE: 'data' is the dimid or varid which is non-negative.
we store the dimid+1 so a valid entry will have
data > 0
*/
typedef struct {
long data;
int flags;
unsigned long key;
} hEntry;
typedef struct s_hashmap {
hEntry* table;
unsigned long size;
unsigned long count;
} NC_hashmap;
#endif
/*
* NC dimension structure
*/
@ -229,43 +212,13 @@ extern int
NC_findvar(const NC_vararray *ncap, const char *name, NC_var **varpp);
extern int
NC_check_vlen(NC_var *varp, size_t vlen_max);
NC_check_vlen(NC_var *varp, unsigned long long vlen_max);
extern int
NC_lookupvar(NC3_INFO* ncp, int varid, NC_var **varp);
/* End defined in var.c */
/* defined in nc_hashmap.c */
/** Creates a new hashmap near the given size. */
extern NC_hashmap* NC_hashmapCreate(unsigned long startsize);
/** Inserts a new element into the hashmap. */
extern void NC_hashmapAddDim(const NC_dimarray*, long data, const char *name);
/** Removes the storage for the element of the key and returns the element. */
extern long NC_hashmapRemoveDim(const NC_dimarray*, const char *name);
/** Returns the element for the key. */
extern long NC_hashmapGetDim(const NC_dimarray*, const char *name);
/** Inserts a new element into the hashmap. */
extern void NC_hashmapAddVar(const NC_vararray*, long data, const char *name);
/** Removes the storage for the element of the key and returns the element. */
extern long NC_hashmapRemoveVar(const NC_vararray*, const char *name);
/** Returns the element for the key. */
extern long NC_hashmapGetVar(const NC_vararray*, const char *name);
/** Returns the number of saved elements. */
extern unsigned long NC_hashmapCount(NC_hashmap*);
/** Removes the hashmap structure. */
extern void NC_hashmapDelete(NC_hashmap*);
/* end defined in nc_hashmap.c */
#define IS_RECVAR(vp) \
((vp)->shape != NULL ? (*(vp)->shape == NC_UNLIMITED) : 0 )

View File

@ -18,6 +18,8 @@
extern "C" {
#endif
#define NCLOGLEVELENV "NETCDF_LOG_LEVEL"
extern int
NC4_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,

521
include/nc4xinternal.h Normal file
View File

@ -0,0 +1,521 @@
/** \file
This header file contains the definitions of structs used to hold
netCDF file metadata in memory.
Copyright 2005-2011 University Corporation for Atmospheric
Research/Unidata.
*/
#ifndef _NC4INTERNAL_
#define _NC4INTERNAL_
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <hdf5.h>
#include "ncdimscale.h"
#include "nc_logging.h"
#include "ncindex.h"
#ifdef USE_PARALLEL
#include "netcdf_par.h"
#endif /* USE_PARALLEL */
#include "netcdf.h"
#include "netcdf_f.h"
/* Always needed */
#include "nc.h"
#ifdef USE_HDF4
#include <mfhdf.h>
#endif
#define FILE_ID_MASK (0xffff0000)
#define GRP_ID_MASK (0x0000ffff)
#define ID_SHIFT (16)
typedef enum {GET, PUT} NC_PG_T;
typedef enum {NCNAT, NCVAR, NCDIM, NCATT, NCTYP, NCGRP} NC_SORT;
#define NC_MAX_HDF5_NAME (NC_MAX_NAME + 10)
#define NC_V2_ERR (-1)
/* The name of the root group. */
#define NC_GROUP_NAME "/"
#define MEGABYTE 1048576
/*
* 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_LONG_MIN X_INT_MIN
#define X_LONG_MAX X_INT_MAX
#define X_UINT_MAX 4294967295U
#define X_INT64_MIN (-9223372036854775807LL-1LL)
#define X_INT64_MAX 9223372036854775807LL
#define X_UINT64_MAX 18446744073709551615ULL
#ifdef WIN32 /* Windows, of course, has to be a *little* different. */
#define X_FLOAT_MAX 3.402823466e+38f
#else
#define X_FLOAT_MAX 3.40282347e+38f
#endif /* WIN32 */
#define X_FLOAT_MIN (-X_FLOAT_MAX)
#define X_DOUBLE_MAX 1.7976931348623157e+308
#define X_DOUBLE_MIN (-X_DOUBLE_MAX)
/* These have to do with creating chuncked datasets in HDF5. */
#define NC_HDF5_UNLIMITED_DIMSIZE (0)
#define NC_HDF5_CHUNKSIZE_FACTOR (10)
#define NC_HDF5_MIN_CHUNK_SIZE (2)
#define NC_EMPTY_SCALE "NC_EMPTY_SCALE"
/* This is an attribute I had to add to handle multidimensional
* coordinate variables. */
#define COORDINATES "_Netcdf4Coordinates"
#define COORDINATES_LEN (NC_MAX_NAME * 5)
/* This is used when the user defines a non-coordinate variable with
* same name as a dimension. */
#define NON_COORD_PREPEND "_nc4_non_coord_"
/* An attribute in the HDF5 root group of this name means that the
* file must follow strict netCDF classic format rules. */
#define NC3_STRICT_ATT_NAME "_nc3_strict"
/* If this attribute is present on a dimscale variable, use the value
* as the netCDF dimid. */
#define NC_DIMID_ATT_NAME "_Netcdf4Dimid"
/** This is the name of the class HDF5 dimension scale attribute. */
#define HDF5_DIMSCALE_CLASS_ATT_NAME "CLASS"
/** This is the name of the name HDF5 dimension scale attribute. */
#define HDF5_DIMSCALE_NAME_ATT_NAME "NAME"
/* Boolean type, to make the code easier to read */
typedef enum {NC_FALSE = 0, NC_TRUE = 1} nc_bool_t;
/*Forward*/
struct NCFILEINFO;
struct NC_GRP_INFO;
struct NC_TYPE_INFO;
/*
Indexed Access to Meta-data objects:
See the document docs/indexing.dox for detailed information.
WARNING: ALL OBJECTS THAT CAN BE INSERTED INTO AN NC_LISTMAP
MUST HAVE AN INSTANCE of NC_OBJ AS THE FIRST FIELD.
*/
typedef struct NC_OBJ {
NC_SORT sort;
char* name; /* assumed to be null terminated */
size_t id;
/* Consider adding |name| and the hashkey for the name */
} NC_OBJ;
/* This is a struct to handle the dim metadata. */
typedef struct NC_DIM_INFO
{
NC_OBJ hdr;
size_t len;
nc_bool_t unlimited; /* True if the dimension is unlimited */
nc_bool_t extended; /* True if the dimension needs to be extended */
nc_bool_t too_long; /* True if len is too big to fit in local size_t. */
hid_t hdf_dimscaleid; /* Non-zero if a DIM_WITHOUT_VARIABLE dataset is in use (no coord var). */
HDF5_OBJID_T hdf5_objid;
struct NC_VAR_INFO *coord_var; /* The coord var, if it exists. */
} NC_DIM_INFO_T;
typedef struct NC_ATT_INFO
{
NC_OBJ hdr;
int len;
nc_bool_t dirty; /* True if attribute modified */
nc_bool_t created; /* True if attribute already created */
struct NC_TYPE_INFO* type; /* netCDF type of attribute's data */
hid_t native_hdf_typeid; /* Native HDF5 datatype for attribute's data */
void *data;
nc_vlen_t *vldata; /* only used for vlen */
char **stdata; /* only for string type. */
} NC_ATT_INFO_T;
/* This is a struct to handle the var metadata. */
typedef struct NC_VAR_INFO
{
NC_OBJ hdr;
char *hdf5_name; /* used if different from name */
struct NC_GRP_INFO* container; /* containing group */
struct {
size_t ndims;
NC_DIM_INFO_T** dims;
int *dimids;
} dim;
nc_bool_t is_new_var; /* True if variable is newly created */
nc_bool_t was_coord_var; /* True if variable was a coordinate var, but either the dim or var has been renamed */
nc_bool_t became_coord_var; /* True if variable _became_ a coordinate var, because either the dim or var has been renamed */
nc_bool_t fill_val_changed; /* True if variable's fill value changes after it has been created */
nc_bool_t attr_dirty; /* True if variable's attributes are dirty and should be rewritten */
nc_bool_t created; /* Variable has already been created (_not_ that it was just created) */
nc_bool_t written_to; /* True if variable has data written to it */
struct NC_TYPE_INFO *type_info;
hid_t hdf_datasetid;
NCindex* att; /* NCindex<NC_ATT_INFO_T*> */
int endianness; /* What endianness for the base type of this variable? */
/* (Set for integer types as well as "complex"
* types, like compound/enum/vlen, used for the
* endianness of the fields and/or base type)
*/
nc_bool_t no_fill; /* True if no fill value is defined for var */
void *fill_value;
size_t *chunksizes;
nc_bool_t contiguous; /* True if variable is stored contiguously in HDF5 file */
int parallel_access; /* Type of parallel access for I/O on variable (collective or independent) */
nc_bool_t dimscale; /* True if var is a dimscale */
nc_bool_t *dimscale_attached; /* Array of flags that are true if dimscale is attached for that dim index */
HDF5_OBJID_T *dimscale_hdf5_objids;
nc_bool_t deflate; /* True if var has deflate filter applied */
int deflate_level;
nc_bool_t shuffle; /* True if var has shuffle filter applied */
nc_bool_t fletcher32; /* True if var has fletcher32 filter applied */
size_t chunk_cache_size, chunk_cache_nelems;
float chunk_cache_preemption;
#ifdef USE_HDF4
/* Stuff below is for hdf4 files. */
int sdsid;
int hdf4_data_type;
#endif /* USE_HDF4 */
/* Stuff for arbitrary filters */
unsigned int filterid;
size_t nparams;
unsigned int* params;
} NC_VAR_INFO_T;
typedef struct NC_FIELD_INFO
{
NC_OBJ hdr;
#if 0
nc_type nc_typeid;
#else
struct NC_TYPE_INFO* type;
#endif
hid_t hdf_typeid;
hid_t native_hdf_typeid;
size_t offset;
struct {
int ndims;
int *dim_size;
} dims;
} NC_FIELD_INFO_T;
typedef struct NC_ENUM_MEMBER_INFO
{
char *name;
void *value;
} NC_ENUM_MEMBER_INFO_T;
typedef struct NC_TYPE_INFO
{
NC_OBJ hdr; /* contains netCDF type ID, equivalent to a pre-defined type
* for atomic types, but a dynamically
* defined value for user-defined types (stored
* as named datatypes in the HDF5 file).
*/
struct NC_GRP_INFO* container; /* Containing group */
unsigned rc; /* Ref. count of objects using this type */
hid_t hdf_typeid; /* HDF5 type ID, in the file */
hid_t native_hdf_typeid; /* HDF5 type ID, in memory */
size_t size; /* Size of the type in memory, in bytes */
nc_bool_t committed; /* True when datatype is committed in the file */
nc_type nc_type_class; /* NC_VLEN, NC_COMPOUND, NC_OPAQUE, or NC_ENUM
* NOTE: NC_INT is used for all integer types,
* NC_FLOAT is used for all floating-point
* types, and NC_STRING is also used for
* fixed- and variable-length strings.
* (NC_CHAR is used for characters though)
*
* This is somewhat redundant with the
* nc_type field, but allows the code to
* have a single location to look at for
* the "kind" of a type.
*/
/* Information for each type or class */
union {
struct {
NClist* members; /* <! NClist<NC_ENUM_MEMBER_INFO_T*> */
struct NC_TYPE_INFO* base_type;
hid_t base_hdf_typeid;
} e; /* Enum */
struct Fields {
NClist* fields; /* <! NClist<NC_FIELD_INFO_T*> */
} c; /* Compound */
struct {
struct NC_TYPE_INFO* base_type;
hid_t base_hdf_typeid;
} v; /* Variable-length */
} u; /* Union of structs, for each type/class */
} NC_TYPE_INFO_T;
/* This holds information for one group. Groups reproduce with
* parthenogenesis. */
typedef struct NC_GRP_INFO
{
NC_OBJ hdr;
hid_t hdf_grpid;
struct NC_HDF5_FILE_INFO *nc4_info;
struct NC_GRP_INFO *parent;
NCindex* children; /* NCindex<struct NC_GRP_INFO*> */
NCindex* dim; /* NCindex<NC_DIM_INFO_T> * */
NCindex* att; /* NCindex<NC_ATT_INFO_T> * */
NCindex* type; /* NCindex<NC_TYPE_INFO_T> * */
/* Note that this is the list of vars with position == varid */
NCindex* vars; /* NCindex<NC_VAR_INFO_T> * */
} NC_GRP_INFO_T;
/* These constants apply to the cmode parameter in the
* HDF5_FILE_INFO_T defined below. */
#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 */
/* This is the metadata we need to keep track of for each
netcdf-4/HDF5 file. */
typedef struct NC_HDF5_FILE_INFO
{
NC* controller;
hid_t hdfid;
#ifdef USE_PARALLEL4
MPI_Comm comm; /* Copy of MPI Communicator used to open the file */
MPI_Info info; /* Copy of MPI Information Object used to open the file */
#endif
int flags;
int cmode;
nc_bool_t parallel; /* True if file is open for parallel access */
nc_bool_t redef; /* True if redefining an existing file */
int fill_mode; /* Fill mode for vars - Unused internally currently */
nc_bool_t no_write; /* true if nc_open has mode NC_NOWRITE. */
NC_GRP_INFO_T *root_grp;
/* Dim,type, and group ids define position of the object in these vectors */
NClist* alldims;
NClist* alltypes;
NClist* allgroups; /* including root group */
#ifdef USE_HDF4
nc_bool_t hdf4; /* True for HDF4 file */
int sdid;
#endif /* USE_HDF4 */
struct NCFILEINFO* fileinfo;
} NC_HDF5_FILE_INFO_T;
/* These functions convert between netcdf and HDF5 types. */
int nc4_get_typelen_mem(NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
int is_long, size_t *len);
int nc4_convert_type(const void *src, void *dest,
const nc_type src_type, const nc_type dest_type,
const size_t len, int *range_error,
const void *fill_value, int strict_nc3, int src_long,
int dest_long);
/* These functions do HDF5 things. */
int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
int rec_reattach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
int delete_existing_dimscale_dataset(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T *dim);
int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset);
int nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, nc_type xtype, int is_long, void *op);
int nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, nc_type xtype, int is_long, void *op);
int nc4_rec_match_dimscales(NC_GRP_INFO_T *grp);
int nc4_rec_detect_need_to_preserve_dimids(NC_GRP_INFO_T *grp, nc_bool_t *bad_coord_orderp);
int nc4_rec_write_metadata(NC_GRP_INFO_T *grp, nc_bool_t bad_coord_order);
int nc4_rec_write_groups_types(NC_GRP_INFO_T *grp);
int nc4_enddef_netcdf4_file(NC_HDF5_FILE_INFO_T *h5);
int nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var);
int nc4_adjust_var_cache(NC_GRP_INFO_T *grp, NC_VAR_INFO_T * var);
/* The following functions manipulate the in-memory linked list of
metadata, without using HDF calls. */
int nc4_find_nc_grp_h5(int ncid, NC **nc, NC_GRP_INFO_T **grp,
NC_HDF5_FILE_INFO_T **h5);
int nc4_find_grp_h5(int ncid, NC_GRP_INFO_T **grp, NC_HDF5_FILE_INFO_T **h5);
int nc4_find_nc4_grp(int ncid, NC_GRP_INFO_T **grp);
NC_GRP_INFO_T *nc4_find_nc_grp(int ncid);
NC_GRP_INFO_T *nc4_rec_find_grp(NC_GRP_INFO_T *start_grp, int target_nc_grpid);
NC *nc4_find_nc_file(int ncid, NC_HDF5_FILE_INFO_T**);
int nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim, NC_GRP_INFO_T **dim_grp);
int nc4_find_var(NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var);
int nc4_find_dim_len(NC_GRP_INFO_T *grp, int dimid, size_t **len);
int nc4_find_type(const NC_HDF5_FILE_INFO_T *h5, int typeid1, NC_TYPE_INFO_T **type);
int nc4_find_any_type(const NC_HDF5_FILE_INFO_T *h5, int xtype, NC_TYPE_INFO_T **typep);
NC_TYPE_INFO_T *nc4_rec_find_nc_type(NC_GRP_INFO_T *start_grp, nc_type target_nc_typeid);
NC_TYPE_INFO_T *nc4_rec_find_hdf_type(NC_GRP_INFO_T *start_grp, hid_t target_hdf_typeid);
NC_TYPE_INFO_T *nc4_rec_find_named_type(NC_GRP_INFO_T *start_grp, char *name);
NC_TYPE_INFO_T *nc4_rec_find_equal_type(NC_GRP_INFO_T *start_grp, int ncid1, NC_TYPE_INFO_T *type);
int nc4_find_nc_att(int ncid, int varid, const char *name, int attnum,
NC_ATT_INFO_T **att);
int nc4_find_g_var_nc(NC *nc, int ncid, int varid,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var);
int nc4_find_grp_att(NC_GRP_INFO_T *grp, int varid, const char *name, int attnum,
NC_ATT_INFO_T **att);
int nc4_get_hdf_typeid(NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
hid_t *hdf_typeid, int endianness);
int nc4_get_typeclass(const NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
int *type_class);
/* These functions create various kinds of object */
int nc4_grp_new(NC_GRP_INFO_T* parent, const char *name, NC_GRP_INFO_T **grpp);
int nc4_dim_new(const char* name, NC_DIM_INFO_T **);
int nc4_type_new(nc_type typeclass, size_t size, const char *name, NC_TYPE_INFO_T **);
int nc4_var_new(const char* name, NC_TYPE_INFO_T*, int ndims, NC_VAR_INFO_T **var);
int nc4_att_new(const char* name, NC_TYPE_INFO_T*, NC_ATT_INFO_T **attp); /* Does not set value */
int nc4_enum_member_new(size_t size, const char *name, const void *value, NC_ENUM_MEMBER_INFO_T**);
int nc4_field_new(NC_TYPE_INFO_T* parent, const char *name,
size_t offset, hid_t field_hdf_typeid, hid_t native_typeid,
nc_type xtype, int ndims, const int *dim_sizesp, NC_FIELD_INFO_T**);
/* These functions reclaim various kinds of object */
int nc4_grp_free(NC_GRP_INFO_T*);
int nc4_grp_clear(NC_GRP_INFO_T*);
int nc4_dim_free(NC_DIM_INFO_T*);
int nc4_type_free(NC_TYPE_INFO_T*);
int nc4_var_free(NC_VAR_INFO_T*);
int nc4_att_free(NC_ATT_INFO_T*);
int nc4_enum_member_free(NC_ENUM_MEMBER_INFO_T*);
int nc4_field_free(NC_FIELD_INFO_T*);
/* These list functions add and delete vars, atts. */
/* Delete functions only exist when the deletion has complications */
int nc4_vararray_add(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var);
int nc4_nc4f_list_add(NC *nc, const char *path, int mode);
int nc4_dim_list_add(NC_GRP_INFO_T*, NC_DIM_INFO_T *dim);
int nc4_att_list_add(NCindex* list, NC_ATT_INFO_T *att);
int nc4_att_list_del(NCindex* list, NC_ATT_INFO_T *att);
int nc4_type_list_add(NC_HDF5_FILE_INFO_T*, NC_GRP_INFO_T* grp, NC_TYPE_INFO_T *type);
int nc4_field_list_add(NC_TYPE_INFO_T*, NC_FIELD_INFO_T*);
int nc4_member_list_add(NC_TYPE_INFO_T*, NC_ENUM_MEMBER_INFO_T*);
int nc4_grp_list_add(struct NC_HDF5_FILE_INFO*, NC_GRP_INFO_T *grp);
int nc4_rec_grp_del(NC_GRP_INFO_T* list);
void nc4_file_list_del(NC *nc);
/* Break & reform coordinate variables */
int nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T *dim);
int nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T *dim);
/* Check and normalize names. */
int NC_check_name(const char *name);
int nc4_check_name(const char *name, char *norm_name);
int nc4_normalize_name(const char *name, char *norm_name);
int nc4_check_dup_name(NC_GRP_INFO_T *grp, char *norm_name);
/* HDF5 initialization */
extern int nc4_hdf5_initialized;
extern void nc4_hdf5_initialize(void);
/* This is only included if --enable-logging is used for configure; it
prints info about the metadata to stderr. */
#ifdef LOGGING
int log_metadata_nc(NC *nc);
#endif
/* Define accessors for the dispatchdata */
#define NC4_DATA(nc) ((NC_HDF5_FILE_INFO_T*)(nc)->dispatchdata)
#define NC4_DATA_SET(nc,data) ((nc)->dispatchdata = (void*)(data))
/* Reserved Attributes Info */
typedef struct NC_reservedatt {
const char* name;
int flags;
} NC_reservedatt;
/* Reserved attribute flags: must be powers of 2*/
/* Hidden dimscale-related, per-variable attributes; immutable and unreadable thru API */
#define DIMSCALEFLAG 1
/* Readonly global attributes; readable, but immutable thru the API */
#define READONLYFLAG 2
/* Subset of readonly flags; readable by name only thru the API*/
#define NAMEONLYFLAG 4
/* Binary searcher for reserved attributes */
extern const NC_reservedatt* NC_findreserved(const char* name);
/* Generic reserved Attributes */
#define NC_ATT_REFERENCE_LIST "REFERENCE_LIST"
#define NC_ATT_CLASS "CLASS"
#define NC_ATT_DIMENSION_LIST "DIMENSION_LIST"
#define NC_ATT_NAME "NAME"
#define NC_ATT_COORDINATES COORDINATES /*defined above*/
#define NC_ATT_FORMAT "_Format"
/**************************************************/
/**
For netcdf4 files, capture state information about the following:
1. Global: netcdf library version
2. Global: hdf5 library version
3. Per file: superblock version
4. Per File: was it created by netcdf-4?
5. Per file: _NCProperties attribute
*/
#define NCPROPS "_NCProperties"
#define NCPROPS_VERSION (1)
#define NCPROPSSEP '|'
/* Currently used properties */
#define NCPVERSION "version" /* Of the properties format */
#define NCPHDF5LIBVERSION "hdf5libversion"
#define NCPNCLIBVERSION "netcdflibversion"
/* Other hidden attributes */
#define ISNETCDF4ATT "_IsNetcdf4"
#define SUPERBLOCKATT "_SuperblockVersion"
struct NCFILEINFO {
int superblockversion;
/* Following is filled from NCPROPS attribute or from global version */
struct NCPROPINFO {
int version; /* 0 => not defined */
char hdf5ver[NC_MAX_NAME+1];
char netcdfver[NC_MAX_NAME+1];
} propattr;
};
extern struct NCPROPINFO globalpropinfo;
hid_t nc4_h5_native_type_constant_g[NC_MAX_ATOMIC_TYPE];
extern int NC4_fileinfo_init(void); /*libsrc4/ncinfo.c*/
extern int NC4_get_fileinfo(struct NC_HDF5_FILE_INFO* info, struct NCPROPINFO*); /*libsrc4/ncinfo.c*/
extern int NC4_put_propattr(struct NC_HDF5_FILE_INFO* info); /*libsrc4/ncinfo.c*/
extern int NC4_buildpropinfo(struct NCPROPINFO* info,char** propdatap);
extern int NC4_hdf5get_libversion(unsigned*,unsigned*,unsigned*);/*libsrc4/nc4hdf.c*/
extern int NC4_hdf5get_superblock(struct NC_HDF5_FILE_INFO*, int*);/*libsrc4/nc4hdf.c*/
extern int NC4_isnetcdf4(struct NC_HDF5_FILE_INFO*); /*libsrc4/nc4hdf.c*/
extern int nc4_init_type_vector(NC_HDF5_FILE_INFO_T* h5);
extern void nc4_init_native_type_ids(void);
extern int nc4_set_atomic_type_hdf5_info(NC_HDF5_FILE_INFO_T* h5, NC_TYPE_INFO_T* type_info);
#endif /* _NETCDF4_ */

View File

@ -19,24 +19,19 @@ This is included in bottom
of config.h. It is where,
typically, alternatives to
missing functions should be
defined.
defined and missing types defined.
*/
#ifndef HAVE_STRDUP
extern char* strdup(const char*);
#endif
/* #if HAVE_BASETSD_H */
/* #ifndef ssize_t */
/* #ifndef SSIZE_T */
/* #include <BaseTsd.h> */
/* #endif */
/* #define ssize_t SSIZE_T */
/* #endif */
/* #endif */
/*
#ifndef HAVE_SSIZE_T
typedef long ssize_t;
#define HAVE_SSIZE_T
#endif
*/
/* handle null arguments */
#ifndef nulldup
#ifdef HAVE_STRDUP
@ -46,6 +41,13 @@ char *nulldup(const char* s);
#endif
#endif
#ifdef _MSC_VER
#ifndef HAVE_SSIZE_T
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
#endif
#ifndef HAVE_STRLCAT
#ifdef _MSC_VER
/* Windows strlcat_s is equivalent to strlcat, but different arg order */

View File

@ -32,7 +32,7 @@
/* Given a filename, check its magic number */
/* Change magic number size from 4 to 8 to be more precise for HDF5 */
#define MAGIC_NUMBER_LEN 8
#define MAGIC_NUMBER_LEN ((size_t)8)
#define MAGIC_HDF5_FILE 1
#define MAGIC_HDF4_FILE 2
#define MAGIC_CDF1_FILE 1 /* std classic format */

View File

@ -7,23 +7,41 @@
#define NCHASHMAP_H
/*
Data is presumed to be an index into some other table
Assume it can be compared using simple ==
The key is some hash of some null terminated string.
Data is presumed to be an index into some other table Assume it
can be compared using simple == The key is some hash of some
null terminated string.
One problem here is that we need to do a final equality check on
the name string to avoid an accidental hash collision. It would
be nice if we had a large enough hashkey that was known to have
an extremely low probability of collisions so we could compare
the hashkeys to determine exact match. A quick internet search
indicates that this is rather more tricky than just using
e.g. crc64 or such. Needs some thought.
*/
/*! Hashmap-related structs.
NOTES:
1. 'data' is the dimid or varid which is non-negative.
2. 'key' is a copy of the name (char*) of the corresponding object
(e.g. dim or var)
3. hashkey is a hash of key.
1. 'data' is the an arbitrary uintptr_t integer or void* pointer.
2. hashkey is a crc32 hash of key
WARNINGS:
1. It is critical that |uintptr_t| == |void*|
2. We do a bad hack here because we know that the incoming key
might be the object id. In this case, we can
store it directly instead of a pointer to it.
3. If the incoming is a string, then we we do not copy it;
this means we do not free it. This has consequences when renaming
objects.
*/
typedef struct NC_hentry {
int flags;
void* data;
size_t hashkey; /* Hash id */
char* key; /* actual key; do not free */
uintptr_t data;
unsigned int hashkey; /* Hash id */
size_t keysize;
uintptr_t key; /* |key| <= |uintptr_t| =>actual content else ptr to content */
} NC_hentry;
/*
@ -31,34 +49,44 @@ The hashmap object must give us the hash table (table),
the |table| size, and the # of defined entries in the table
*/
typedef struct NC_hashmap {
size_t size; /* allocated */
size_t count;
size_t alloc; /* allocated # of entries */
size_t active; /* # of active entries */
NC_hentry* table;
} NC_hashmap;
/* defined in nc_hashmap.c */
/* defined in nchashmap.c */
/*
There are two "kinds" of functions:
1. those that take the key+size -- they compute the hashkey internally.
2. those that take the hashkey directly
The API here is not complete in that some #1 functions do not have
a corresponding #2 function, and vice-versa.
The NC_hashmapkey function can be used to effectively convert a #2 to a #1.
If both functions cases are present, then the #2 case will be suffixed with 0.
*/
/** Creates a new hashmap near the given size. */
extern NC_hashmap* NC_hashmapnew(size_t startsize);
/** Inserts a new element into the hashmap. */
/* Note we pass the NC_hobjecty struct by value */
extern int NC_hashmapadd(NC_hashmap*, void* data, const char* name);
/** Inserts a new element into the hashmap; takes key+size */
/* key points to size bytes to convert to hash key */
extern int NC_hashmapadd(NC_hashmap*, uintptr_t data, void* key, size_t keysize);
/** Removes the storage for the element of the key.
/** Removes the storage for the element of the key; takes key+size.
Return 1 if found, 0 otherwise; returns the data in datap if !null
*/
extern int NC_hashmapremove(NC_hashmap*, const char* name, void** datap);
extern int NC_hashmapremove(NC_hashmap*, void* key, size_t keysize, uintptr_t* datap);
/** Returns the data for the key.
/** Returns the data for the key; takes key+size.
Return 1 if found, 0 otherwise; returns the data in datap if !null
*/
extern int NC_hashmapget(NC_hashmap*, const char*, void** datap);
extern int NC_hashmapget(NC_hashmap*, void* key, size_t keysize, uintptr_t* datap);
/** Change the data for the specified key
/** Change the data for the specified key; takes hashkey.
Return 1 if found, 0 otherwise
*/
extern int NC_hashmapsetdata(NC_hashmap*, const char*, void* newdata);
extern int NC_hashmapsetdata(NC_hashmap*, void* key, size_t keylen, uintptr_t newdata);
/** Returns the number of saved elements. */
extern size_t NC_hashmapcount(NC_hashmap*);
@ -66,5 +94,27 @@ extern size_t NC_hashmapcount(NC_hashmap*);
/** Reclaims the hashmap structure. */
extern int NC_hashmapfree(NC_hashmap*);
/* Hacks to access internal state: Use with care */
/* Convert an entry from ACTIVE to DELETED;
Return 0 if not found.
*/
extern int NC_hashmapdeactivate(NC_hashmap*, uintptr_t data);
/* Return the hash key for specified key; takes key+size*/
extern unsigned int NC_hashmapkey(void* key, size_t size);
#if 0
/** Removes the storage for the element of the key; takes hashkey.
Return 1 if found, 0 otherwise; returns the data in datap if !null
*/
extern int NC_hashmapremove0(NC_hashmap*, unsigned int key, uintptr_t* datap);
/** Returns the data for the key; takes hashkey
Return 1 if found, 0 otherwise; returns the data in datap if !null
*/
extern int NC_hashmapget0(NC_hashmap*, unsigned int hashkey, uintptr_t* datap);
#endif
#endif /*NCHASHMAP_H*/

89
include/ncindex.h Normal file
View File

@ -0,0 +1,89 @@
/*
Copyright (c) 1998-2017 University Corporation for Atmospheric Research/Unidata
See LICENSE.txt for license information.
*/
#ifndef NCINDEX_H
#define NCINDEX_H
/* If defined, then the hashmap is used.
This for performance experimentation
*/
#undef NCUSEHASH
#include "nclist.h"
#include "nchashmap.h" /* Also includes name map and id map */
/* Forward (see nc4internal.h)*/
struct NC_OBJ;
/*
This index data structure is an ordered list of objects. It is
used pervasively in libsrc4 to store metadata relationships.
The goal is to provide by-name and i'th indexed access (via
NClist) to the objects in the index. Using NCindex might be
overkill for some relationships, but we can sort that out later.
As a rule, we use this to store definitional relationships such
as (in groups) dimension definitions, variable definitions, type
defs and subgroup defs. We do not, as a rule, use this to store
reference relationships such as the list of dimensions for a
variable.
See docs/indexind.dox for more detailed documentation
*/
/* Generic list + matching hashtable */
typedef struct NCindex {
NClist* list;
#ifndef NCUSEHASH
NC_hashmap* map;
#endif
} NCindex;
/* Locate object by name in an NCindex */
extern struct NC_OBJ* ncindexlookup(NCindex* index, const char* name);
/* Get ith object in the index vector */
extern struct NC_OBJ* ncindexith(NCindex* index, size_t i);
/* See if x is contained in the index and return its vector permission*/
extern int ncindexfind(NCindex* index, struct NC_OBJ* o);
/* Add object to the end of the vector, also insert into the hashmaps; */
/* Return 1 if ok, 0 otherwise.*/
extern int ncindexadd(NCindex* index, struct NC_OBJ* obj);
/* Get a copy of the vector contents */
extern struct NC_OBJ** ncindexdup(NCindex* index);
/* Rehash all objects in the vector */
/* Return 1 if ok, 0 otherwise.*/
extern int ncindexrehash(NCindex* index);
/* Remove ith object from the index; WARNING: may affect ids */
/* Return 1 if ok, 0 otherwise.*/
extern int ncindexidel(NCindex* index,size_t i);
/* Free an index. */
/* Return 1 if ok; 0 otherwise */
extern int ncindexfree(NCindex* index);
/* Create an index: size == 0 => use defaults */
/* Return index if ok; NULL otherwise */
extern NCindex* ncindexnew(size_t initsize);
extern int ncindexverify(NCindex* lm, int dump);
/* Lookup object in index; return NULL if not found */
extern struct NC_OBJ* ncindexlookup(NCindex*, const char* name);
/* Inline functions */
/* Test if index has been initialized */
#define ncindexinitialized(index) ((index) != NULL && (index)->list != NULL)
/* Get number of entries in an index */
#define ncindexsize(index) ((index)==NULL?0:(nclistlength((index)->list)))
#endif /*ncindexH*/

View File

@ -1957,8 +1957,7 @@ ncrecget(int ncid, long recnum, void **datap);
EXTERNL int
ncrecput(int ncid, long recnum, void *const *datap);
EXTERNL int
nc_finalize();
EXTERNL int nc_finalize();
/* End v2.4 backward compatibility */
#endif /*!NO_NETCDF_2*/

View File

@ -55,7 +55,7 @@ NCerror
dapmapconstraints(DCEconstraint* constraint,
CDFnode* root)
{
int i;
size_t i;
NCerror ncstat = NC_NOERR;
NClist* nodes = root->tree->nodes;
NClist* dceprojections = constraint->projections;
@ -86,7 +86,7 @@ NCerror
dapqualifyconstraints(DCEconstraint* constraint)
{
NCerror ncstat = NC_NOERR;
int i;
size_t i;
#ifdef DEBUG
fprintf(stderr,"ncqualifyconstraints.before: %s\n",
dumpconstraint(constraint));
@ -137,7 +137,7 @@ fprintf(stderr,"%s\n",
static NCerror
qualifyprojectionsizes(DCEprojection* proj)
{
int i,j;
size_t i,j;
ASSERT(proj->discrim == CES_VAR);
#ifdef DEBUG
fprintf(stderr,"qualifyprojectionsizes.before: %s\n",
@ -174,10 +174,9 @@ fprintf(stderr,"qualifyprojectionsizes.after: %s\n",
static void
completesegments(NClist* fullpath, NClist* segments)
{
int i,delta;
size_t i,delta;
/* add path nodes to segments to create full path */
delta = (nclistlength(fullpath) - nclistlength(segments));
ASSERT((delta >= 0));
for(i=0;i<delta;i++) {
DCEsegment* seg = (DCEsegment*)dcecreate(CES_SEGMENT);
CDFnode* node = (CDFnode*)nclistget(fullpath,i);
@ -232,7 +231,7 @@ Additional constraints (4/12/2010):
static NCerror
matchpartialname(NClist* nodes, NClist* segments, CDFnode** nodep)
{
int i,nsegs;
size_t i,nsegs;
NCerror ncstat = NC_NOERR;
DCEsegment* lastseg = NULL;
NClist* namematches = nclistnew();

View File

@ -505,7 +505,8 @@ movetor(NCDAPCOMMON* nccomm,
if(xnode->etype == NC_STRING || xnode->etype == NC_URL) hasstringdim = 1;
/* Get the mode */
mode = oc_data_mode(conn,currentcontent);
ocstat = oc_data_mode(conn,currentcontent,&mode);
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
#ifdef DEBUG2
fprintf(stderr,"moveto: nctype=%d depth=%d dimindex=%d mode=%s",

View File

@ -200,12 +200,14 @@ set_curl_options(NCD4INFO* state)
for(i=0;i<nclistlength(store);i++) {
struct CURLFLAG* flag;
NCTriple* triple = (NCTriple*)nclistget(store,i);
size_t hostlen = strlen(triple->host);
size_t hostlen = (triple->host ? strlen(triple->host) : 0);
const char* flagname;
if(strncmp("CURL.",triple->key,5) != 0) continue; /* not a curl flag */
/* do hostport prefix comparison */
if(hostport != NULL) {
int t = strncmp(hostport,triple->host,hostlen);
int t = 0;
if(triple->host != NULL)
t = strncmp(hostport,triple->host,hostlen);
if(t != 0) continue;
}
flagname = triple->key+5; /* 5 == strlen("CURL."); */

View File

@ -1,4 +1,4 @@
SET(libdispatch_SOURCES dparallel.c dcopy.c dfile.c ddim.c datt.c dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c dvarinq.c ddispatch.c nclog.c dstring.c dutf8.c dinternal.c doffsets.c ncuri.c nclist.c ncbytes.c nchashmap.c nctime.c nc.c nclistmgr.c utf8proc.h utf8proc.c dwinpath.c dutil.c drc.c dauth.c)
SET(libdispatch_SOURCES dparallel.c dcopy.c dfile.c ddim.c datt.c dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c dvarinq.c ddispatch.c nclog.c dstring.c dutf8.c dinternal.c doffsets.c ncuri.c nclist.c ncbytes.c nchashmap.c nctime.c nc.c nclistmgr.c utf8proc.h utf8proc.c dwinpath.c dutil.c drc.c dauth.c crc32.c)
IF(USE_NETCDF4)
SET(libdispatch_SOURCES ${libdispatch_SOURCES} dgroup.c dvlen.c dcompound.c dtype.c denum.c dopaque.c ncaux.c dfilter.c)

View File

@ -20,7 +20,8 @@ dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c \
dvarinq.c dinternal.c ddispatch.c dutf8.c \
nclog.c dstring.c \
ncuri.c nclist.c ncbytes.c nchashmap.c nctime.c \
nc.c nclistmgr.c drc.c dauth.c doffsets.c dwinpath.c dutil.c
nc.c nclistmgr.c drc.c dauth.c doffsets.c dwinpath.c dutil.c \
crc32.c crc32.h
# Add the utf8 codebase
libdispatch_la_SOURCES += utf8proc.c utf8proc.h

506
libdispatch/crc32.c Normal file
View File

@ -0,0 +1,506 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.11, January 15th, 2017
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
*/
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
* instead of four steps with four exclusive-ors. This results in about a
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
/**
Modified to make it standalone.
Dennis Heimbigner
UCAR
*/
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
* instead of four steps with four exclusive-ors. This results in about a
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
/* @(#) $Id$ */
/*
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
protection on the static variables used to control the first-use generation
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
first call get_crc_table() to initialize the tables before allowing more than
one thread to use crc32().
DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
*/
/* Prototype for the crc32 function
extern unsigned int NC_crc32(unsigned int crc, const unsigned char* buf, unsigned int len);
*/
/* Define some of the macros used here */
#define FAR
#define ZEXPORT
#define local static
#define OF(x) x
#define uLong unsigned long
#define uInt unsigned int
#define z_off64_t long long
#define z_off_t long
#define z_crc_t unsigned long
#define z_size_t size_t
#define Z_NULL NULL
#include <stdlib.h>
#ifdef MAKECRCH
# include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE
# define DYNAMIC_CRC_TABLE
# endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */
/* Definitions for doing the crc four data bytes at a time. */
#if !defined(NOBYFOUR) && defined(Z_U4)
# define BYFOUR
#endif
#ifdef BYFOUR
local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, z_size_t));
local unsigned long crc32_big OF((unsigned long,
const unsigned char FAR *, z_size_t));
# define TBLS 8
#else
# define TBLS 1
#endif /* BYFOUR */
/* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
#ifdef DYNAMIC_CRC_TABLE
local volatile int crc_table_empty = 1;
local z_crc_t FAR crc_table[TBLS][256];
local void make_crc_table OF((void));
#ifdef MAKECRCH
local void write_table OF((FILE *, const z_crc_t FAR *));
#endif /* MAKECRCH */
/*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the
polynomial q, also with the lowest power in the most significant bit (so the
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
where a mod b means the remainder after dividing a by b.
This calculation is done using the shift-register method of multiplying and
taking the remainder. The register is initialized to zero, and for each
incoming bit, x^32 is added mod p to the register if the bit is a one (where
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
x (which is shifting right by one and adding x^32 mod p if the bit shifted
out is a one). We start with the highest power (least significant bit) of
q and repeat for all eight bits of q.
The first table is simply the CRC of all possible eight bit values. This is
all the information needed to generate CRCs on data a byte at a time for all
combinations of CRC register values and incoming bytes. The remaining tables
allow for word-at-a-time CRC calculation for both big-endian and little-
endian machines, where a word is four bytes.
*/
local void make_crc_table()
{
z_crc_t c;
int n, k;
z_crc_t poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* See if another task is already doing this (not thread-safe, but better
than nothing -- significantly reduces duration of vulnerability in
case the advice about DYNAMIC_CRC_TABLE is ignored) */
if (first) {
first = 0;
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0;
for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
poly |= (z_crc_t)1 << (31 - p[n]);
/* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) {
c = (z_crc_t)n;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c;
}
#ifdef BYFOUR
/* generate crc for each value followed by one, two, and three zeros,
and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) {
c = crc_table[0][n];
crc_table[4][n] = ZSWAP32(c);
for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
crc_table[k + 4][n] = ZSWAP32(c);
}
}
#endif /* BYFOUR */
crc_table_empty = 0;
}
else { /* not first */
/* wait for the other guy to finish (not efficient, but rare) */
while (crc_table_empty)
;
}
#ifdef MAKECRCH
/* write out CRC tables to crc32.h */
{
FILE *out;
out = fopen("crc32.h", "w");
if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const z_crc_t FAR ");
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
write_table(out, crc_table[0]);
# ifdef BYFOUR
fprintf(out, "#ifdef BYFOUR\n");
for (k = 1; k < 8; k++) {
fprintf(out, " },\n {\n");
write_table(out, crc_table[k]);
}
fprintf(out, "#endif\n");
# endif /* BYFOUR */
fprintf(out, " }\n};\n");
fclose(out);
}
#endif /* MAKECRCH */
}
#ifdef MAKECRCH
local void write_table(out, table)
FILE *out;
const z_crc_t FAR *table;
{
int n;
for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
(unsigned long)(table[n]),
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
}
#endif /* MAKECRCH */
#else /* !DYNAMIC_CRC_TABLE */
/* ========================================================================
* Tables of CRC-32s of all single-byte values, made by make_crc_table().
*/
#include "crc32.h"
#endif /* DYNAMIC_CRC_TABLE */
/* =========================================================================
* This function can be used by asm versions of crc32()
*/
const z_crc_t FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
return (const z_crc_t FAR *)crc_table;
}
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
unsigned long ZEXPORT crc32_z(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
z_size_t len;
{
if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) {
z_crc_t endian;
endian = 1;
if (*((unsigned char *)(&endian)))
return crc32_little(crc, buf, len);
else
return crc32_big(crc, buf, len);
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;
while (len >= 8) {
DO8;
len -= 8;
}
if (len) do {
DO1;
} while (--len);
return crc ^ 0xffffffffUL;
}
/* ========================================================================= */
unsigned int ZEXPORT NC_crc32(unsigned int crc, const unsigned char* buf, unsigned int len)
{
unsigned long value = (unsigned long)crc;
value = crc32_z(value, buf, len);
return (unsigned int)(value & 0xFFFFFFFF); /* in case |long| is 64 bits */
}
#ifdef BYFOUR
/*
This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
integer pointer type. This violates the strict aliasing rule, where a
compiler can assume, for optimization purposes, that two pointers to
fundamentally different types won't ever point to the same memory. This can
manifest as a problem only if one of the pointers is written to. This code
only reads from those pointers. So long as this code remains isolated in
this compilation unit, there won't be a problem. For this reason, this code
should not be copied and pasted into a compilation unit in which other code
writes to the buffer that is passed to these routines.
*/
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
z_size_t len;
{
register z_crc_t c;
register const z_crc_t FAR *buf4;
c = (z_crc_t)crc;
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
while (len >= 32) {
DOLIT32;
len -= 32;
}
while (len >= 4) {
DOLIT4;
len -= 4;
}
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len);
c = ~c;
return (unsigned long)c;
}
/* ========================================================================= */
#define DOBIG4 c ^= *buf4++; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
z_size_t len;
{
register z_crc_t c;
register const z_crc_t FAR *buf4;
c = ZSWAP32((z_crc_t)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
while (len >= 32) {
DOBIG32;
len -= 32;
}
while (len >= 4) {
DOBIG4;
len -= 4;
}
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
return (unsigned long)(ZSWAP32(c));
}
#endif /* BYFOUR */
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
local unsigned long gf2_matrix_times(mat, vec)
unsigned long *mat;
unsigned long vec;
{
unsigned long sum;
sum = 0;
while (vec) {
if (vec & 1)
sum ^= *mat;
vec >>= 1;
mat++;
}
return sum;
}
/* ========================================================================= */
local void gf2_matrix_square(square, mat)
unsigned long *square;
unsigned long *mat;
{
int n;
for (n = 0; n < GF2_DIM; n++)
square[n] = gf2_matrix_times(mat, mat[n]);
}
/* ========================================================================= */
local uLong crc32_combine_(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off64_t len2;
{
int n;
unsigned long row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
/* degenerate case (also disallow negative lengths) */
if (len2 <= 0)
return crc1;
/* put operator for one zero bit in odd */
odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
row = 1;
for (n = 1; n < GF2_DIM; n++) {
odd[n] = row;
row <<= 1;
}
/* put operator for two zero bits in even */
gf2_matrix_square(even, odd);
/* put operator for four zero bits in odd */
gf2_matrix_square(odd, even);
/* apply len2 zeros to crc1 (first square will put the operator for one
zero byte, eight zero bits, in even) */
do {
/* apply zeros operator for this bit of len2 */
gf2_matrix_square(even, odd);
if (len2 & 1)
crc1 = gf2_matrix_times(even, crc1);
len2 >>= 1;
/* if no more bits set, then done */
if (len2 == 0)
break;
/* another iteration of the loop with odd and even swapped */
gf2_matrix_square(odd, even);
if (len2 & 1)
crc1 = gf2_matrix_times(odd, crc1);
len2 >>= 1;
/* if no more bits set, then done */
} while (len2 != 0);
/* return combined crc */
crc1 ^= crc2;
return crc1;
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off_t len2;
{
return crc32_combine_(crc1, crc2, len2);
}
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off64_t len2;
{
return crc32_combine_(crc1, crc2, len2);
}

441
libdispatch/crc32.h Normal file
View File

@ -0,0 +1,441 @@
/* crc32.h -- tables for rapid CRC calculation
* Generated automatically by crc32.c
*/
local const z_crc_t FAR crc_table[TBLS][256] =
{
{
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
0x2d02ef8dUL
#ifdef BYFOUR
},
{
0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
0x9324fd72UL
},
{
0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
0xbe9834edUL
},
{
0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
0xde0506f1UL
},
{
0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
0x8def022dUL
},
{
0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
0x72fd2493UL
},
{
0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
0xed3498beUL
},
{
0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
0xf10605deUL
#endif
}
};

View File

@ -21,7 +21,10 @@
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* lseek() */
#endif
#include "ncdispatch.h"
#include "netcdf_mem.h"
@ -134,7 +137,7 @@ NC_interpret_magic_number(char* magic, int* model, int* version)
if(magic[3] == '\001') {
*version = 1; /* netcdf classic version 1 */
*model = NC_FORMATX_NC3;
goto done;
goto done;
}
if(magic[3] == '\002') {
*version = 2; /* netcdf classic version 2 */
@ -187,7 +190,7 @@ NC_check_file_type(const char *path, int flags, void *parameters,
*model = 0;
*version = 0;
memset((void*)&file,0,sizeof(file));
memset((void*)&file,0,sizeof(file));
file.path = path; /* do not free */
file.parameters = parameters;
if(inmemory && parameters == NULL)
@ -236,7 +239,7 @@ next:
/* double and try again */
pos = 2*pos;
}
}
}
done:
closemagic(&file);
return status;
@ -527,7 +530,7 @@ nc__create(const char *path, int cmode, size_t initialsz,
}
/**
* @internal Create a file with special (deprecated) Cray settings.
*
*
* @deprecated This function was used in the old days with the Cray at
* NCAR. The Cray is long gone, and this call is supported only for
* backward compatibility. Use nc_create() instead.
@ -579,7 +582,7 @@ nc__create_mp(const char *path, int cmode, size_t initialsz,
* to the dataset, including appending or changing data, adding or
* renaming dimensions, variables, and attributes, or deleting
* attributes.)
*
*
* The NC_SHARE flag is only used for netCDF classic and 64-bit offset
* files. It is appropriate when one process may be writing the
* dataset and one or more other processes reading the dataset
@ -618,14 +621,14 @@ nc__create_mp(const char *path, int cmode, size_t initialsz,
* accessed data to be retrieved from disk. Without MMAP, NC_DISKLESS
* will read the whole file into memory on nc_open. Thus, MMAP will
* provide some performance improvement in this case.
*
*
* It is not necessary to pass any information about the format of the
* file being opened. The file type will be detected automatically by
* the netCDF library.
*
* If a the path is a DAP URL, then the open mode is read-only.
* Setting NC_WRITE will be ignored.
*
*
* As of version 4.3.1.2, multiple calls to nc_open with the same
* path will return the same ncid value.
*
@ -647,10 +650,10 @@ nc__create_mp(const char *path, int cmode, size_t initialsz,
* @returns ::NC_EDIMMETA Error in netCDF-4 dimension metadata. (NetCDF-4 files only.)
*
* <h1>Examples</h1>
*
*
* Here is an example using nc_open()to open an existing netCDF dataset
* named foo.nc for read-only, non-shared access:
*
*
* @code
* #include <netcdf.h>
* ...
@ -1675,12 +1678,12 @@ check_create_mode(int mode)
(mode & NC_CDF5);
if (mode_format && (mode_format & (mode_format - 1)))
return NC_EINVAL;
/* Can't use both NC_MPIIO and NC_MPIPOSIX. Make up your damn
* mind! */
if (mode & NC_MPIIO && mode & NC_MPIPOSIX)
return NC_EINVAL;
/* Can't use both parallel and diskless. */
if ((mode & NC_MPIIO && mode & NC_DISKLESS) ||
(mode & NC_MPIPOSIX && mode & NC_DISKLESS))
@ -1689,11 +1692,11 @@ check_create_mode(int mode)
#ifndef USE_DISKLESS
/* If diskless is requested, but not built, return error. */
if (mode & NC_DISKLESS)
return NC_ENOTBUILT;
return NC_ENOTBUILT;
if (mode & NC_INMEMORY)
return NC_ENOTBUILT;
return NC_ENOTBUILT;
#endif
#ifndef USE_NETCDF4
/* If the user asks for a netCDF-4 file, and the library was built
* without netCDF-4, then return an error.*/
@ -1760,7 +1763,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
/* Check mode flag for sanity. */
if ((stat = check_create_mode(cmode)))
return stat;
/* Initialize the dispatch table. The function pointers in the
* dispatch table will depend on how netCDF was built
* (with/without netCDF-4, DAP, CDMREMOTE). */
@ -1857,7 +1860,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
if((cmode & NC_MPIIO) && (cmode & NC_MPIPOSIX))
{
nullfree(path);
nullfree(path);
return NC_EINVAL;
}
@ -2004,12 +2007,12 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp,
stat = NC_check_file_type(path,flags,parameters,&model,&version);
if(stat == NC_NOERR) {
if(model == 0) {
nullfree(path);
nullfree(path);
return NC_ENOTNC;
}
} else {
/* presumably not a netcdf file */
nullfree(path);
nullfree(path);
return stat;
}
}
@ -2076,7 +2079,7 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp,
/* Invalid to use both NC_MPIIO and NC_MPIPOSIX. Make up your damn
* mind! */
if((cmode & NC_MPIIO && cmode & NC_MPIPOSIX)) {
nullfree(path);
nullfree(path);
return NC_EINVAL;
}
@ -2112,14 +2115,14 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp,
dispatcher = NC3_dispatch_table;
break;
default:
nullfree(path);
nullfree(path);
return NC_ENOTNC;
}
}
/* If we can't figure out what dispatch table to use, give up. */
if (!dispatcher) {
nullfree(path);
nullfree(path);
return NC_ENOTNC;
}
@ -2278,12 +2281,12 @@ readmagic(struct MagicFile* file, long pos, char* magic)
}
#endif /* USE_PARALLEL */
{
size_t count;
int count;
int i = fseek(file->fp,pos,SEEK_SET);
if(i < 0)
{status = errno; goto done;}
for(i=0;i<MAGIC_NUMBER_LEN;) {/* make sure to read proper # of bytes */
count=fread(&magic[i],1,(MAGIC_NUMBER_LEN-i),file->fp);
count=fread(&magic[i],1,(size_t)(MAGIC_NUMBER_LEN-i),file->fp);
if(count == 0 || ferror(file->fp))
{status = errno; goto done;}
i += count;
@ -2295,9 +2298,9 @@ done:
return status;
}
/**
* Close the file opened to check for magic number.
*
/**
* Close the file opened to check for magic number.
*
* @param file pointer to the MagicFile struct for this open file.
* @returns NC_NOERR for success
* @returns NC_EPARINIT if there was a problem closing file with MPI

View File

@ -315,6 +315,8 @@ rccompile(const char* path)
}
ncbytesnull(tmp);
triple->host = ncbytesextract(tmp);
if(strlen(triple->host)==0)
{free(triple->host); triple->host = NULL;}
}
/* split off key and value */
key=line;
@ -331,7 +333,8 @@ rccompile(const char* path)
rctrim(triple->value);
#ifdef D4DEBUG
fprintf(stderr,"rc: host=%s key=%s value=%s\n",
triple->host,triple->key,triple->valu);
(triple->host != NULL ? triple->host : "<null>"),
triple->key,triple->valu);
#endif
nclistpush(rc,triple);
triple = NULL;
@ -371,7 +374,9 @@ rclocate(const char* key, const char* hostport)
(because we have checked all other cases)*/
if(hplen == 0) {found=1;break;}
/* do hostport match */
t = strcmp(hostport,triple->host);
t = 0;
if(triple->host != NULL)
t = strcmp(hostport,triple->host);
if(t == 0) {found=1; break;}
}
return (found?triple:NULL);

View File

@ -426,7 +426,7 @@ NC_inq_recvar(int ncid, int varid, int* nrecdimsp, int *is_recdim)
* Find the length of a type. This is how much space is required by
* the in memory to hold one element of this type.
*
* @parm type A netCDF atomic type.
* @param type A netCDF atomic type.
*
* @return Length of the type in bytes, or -1 if type not found.
* @author Ed Hartnett
@ -1016,6 +1016,9 @@ same as the default endianness of the platform. But with
nc_def_var_endianness the endianness can be explicitly set for a
variable.
Warning: this function is only defined if the type of the variable
is an atomic integer or float type.
This function may only be called after the variable is defined, but
before nc_enddef is called.

View File

@ -11,6 +11,9 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _MSC_VER
#include <io.h>
#endif
@ -30,11 +33,13 @@ Rules:
2. a leading '/cygdrive/X' will be converted to
a drive letter X if X is alpha-char.
3. a leading D:/... is treated as a windows drive letter
4. If #1, #2, or #3 is encounterd, then forward slashes
4. a relative path will be converted to an absolute path.
5. If any of the above is encountered, then forward slashes
will be converted to backslashes.
5. All other cases are passed thru unchanged
All other cases are passed thru unchanged
*/
/* Define legal windows drive letters */
static char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
@ -42,6 +47,8 @@ static size_t cdlen = 10; /* strlen("/cygdrive/") */
static int pathdebug = -1;
static char* makeabsolute(const char* relpath);
EXTERNL
char* /* caller frees */
NCpathcvt(const char* path)
@ -105,7 +112,13 @@ NCpathcvt(const char* path)
goto slashtrans;
}
/* 4. Other: just pass thru */
/* 4. Look for relative path */
if(pathlen > 1 && path[0] == '.') {
outpath = makeabsolute(path);
goto slashtrans;
}
/* Other: just pass thru */
outpath = strdup(path);
goto done;
@ -138,6 +151,20 @@ done:
return outpath;
}
static char*
makeabsolute(const char* relpath)
{
char* path = NULL;
#ifdef _MSC_VER
path = _fullpath(NULL,relpath,8192);
#else
path = realpath(relpath, NULL);
#endif
if(path == NULL)
path = strdup(relpath);
return path;
}
#ifdef WINPATH
/*

View File

@ -3,8 +3,6 @@ Copyright (c) 1998-2017 University Corporation for Atmospheric Research/Unidata
See LICENSE.txt for license information.
*/
#define NEWHASHMAP
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
@ -18,19 +16,38 @@ See LICENSE.txt for license information.
#include "nchashmap.h"
#include "nc3internal.h"
#define VERIFY
#undef DEBUG
#undef DEBUGTRACE
#undef ASSERTIONS
#ifdef VERIFY
/* Prototype for the crc32 function */
extern unsigned int NC_crc32(unsigned int crc, const unsigned char* buf, unsigned int len);
#undef SMALLTABLE
#ifdef ASSERTIONS
#define ASSERT(x) assert(x)
#else
#define ASSERT(x)
#endif
#ifdef DEBUGTRACE
#define TRACE(x) {fprintf(stderr,"NC_hashmap: %s\n",x); fflush(stderr);}
#else
#define TRACE(x)
#endif
#define SEED 37
/* See lookup3.c */
extern unsigned int hash_fast(const void* key, size_t length);
/* this should be prime */
#define TABLE_STARTSIZE 1021
#ifdef SMALLTABLE
#define MINTABLESIZE 7U
#else
#define MINTABLESIZE 131U
#endif
/* Flags must be powers of 2 */
/* Slot has data */
@ -47,64 +64,73 @@ static unsigned int NC_nprimes;
static unsigned int NC_primes[16386];
static unsigned int findPrimeGreaterThan(size_t val);
extern void printhashmapstats(NC_hashmap* hm);
extern void printhashmap(NC_hashmap* hm);
static void
rehash(NC_hashmap* hm)
{
size_t size = hm->size;
size_t count = hm->count;
size_t alloc = hm->alloc;
#ifdef ASSERTIONS
size_t active = hm->active;
#endif
NC_hentry* oldtable = hm->table;
hm->size = findPrimeGreaterThan(size<<1);
hm->table = (NC_hentry*)calloc(sizeof(NC_hentry), hm->size);
hm->count = 0;
TRACE("rehash");
while(size > 0) {
--size;
if(oldtable[size].flags == ACTIVE) {
void* data = oldtable[size].data;
char* key = oldtable[size].key;
NC_hashmapadd(hm, data, key);
#ifdef VERIFY
{ void* data2;
ASSERT(NC_hashmapget(hm, key, &data2) == 1);
ASSERT(data == data2);
}
#endif
hm->alloc = findPrimeGreaterThan(alloc<<1);
hm->table = (NC_hentry*)calloc(sizeof(NC_hentry), hm->alloc);
hm->active = 0;
while(alloc > 0) {
NC_hentry* h = &oldtable[--alloc];
if(h->flags == ACTIVE) {
uintptr_t data = h->data;
void* key = (void*)h->key;
size_t keysize = h->keysize;
if(keysize <= sizeof(uintptr_t))
NC_hashmapadd(hm, data, &key, keysize);
else
NC_hashmapadd(hm, data, key, keysize);
}
}
free(oldtable);
ASSERT(count == hm->count);
ASSERT(active == hm->active);
}
/* Locate where given object is or should be placed in indexp.
if fail to find spot return 0 else 1.
If deletok then a deleted slot is ok to return;
If hashkeyp is non-null, then return hashkey
return invariant: return == 0 || *indexp is defined
*/
static int
locate(NC_hashmap* hash, const char* key, size_t* indexp, size_t* hashkeyp, int deletedok)
locate(NC_hashmap* hash, unsigned int hashkey, void* key, size_t keysize, size_t* indexp, int deletedok)
{
size_t i;
size_t keylen = strlen(key);
size_t hashkey = hash_fast(key, keylen);
size_t index = hashkey % hash->size;
size_t index;
size_t step = 1; /* simple linear probe */
int deletefound = 0;
size_t deletedindex = 0; /* first deleted entry encountered */
if(hashkeyp) *hashkeyp = hashkey;
TRACE("locate");
/* Compute starting point */
index = (size_t)(hashkey % hash->alloc);
/* Search table using linear probing */
for (i = 0; i < hash->size; i++) {
NC_hentry entry = hash->table[index];
if(entry.flags & ACTIVE) {
if(entry.hashkey == hashkey
&& strncmp(key,entry.key,keylen)==0) {
if(indexp) *indexp = index;
return 1;
for (i = 0; i < hash->alloc; i++) {
NC_hentry* entry = &hash->table[index];
if(entry->flags & ACTIVE) {
if(indexp) *indexp = index; /* assume a match */
if(entry->hashkey == hashkey && entry->keysize == keysize) {
/* Check content */
if(entry->keysize <= sizeof(uintptr_t)
&& memcmp((void*)&entry->key,key,keysize)==0)
return 1;
else if(memcmp((void*)entry->key,key,keysize)==0)
return 1;
}
/* Keep looking */
} else if(entry.flags & DELETED) {
} else if(entry->flags & DELETED) {
if(!deletefound) {/* save this position */
deletefound = 1;
deletedindex = index;
@ -115,7 +141,7 @@ locate(NC_hashmap* hash, const char* key, size_t* indexp, size_t* hashkeyp, int
return 1;
}
/* linear probe */
index = (index + step) % hash->size;
index = (index + step) % hash->alloc;
}
if(deletedok && deletefound) {
if(indexp) *indexp = deletedindex;
@ -127,30 +153,41 @@ locate(NC_hashmap* hash, const char* key, size_t* indexp, size_t* hashkeyp, int
NC_hashmap*
NC_hashmapnew(size_t startsize)
{
NC_hashmap* hm = (NC_hashmap*)malloc(sizeof(NC_hashmap));
NC_hashmap* hm = NULL;
if(startsize == 0)
startsize = TABLE_STARTSIZE;
TRACE("NC_hashmapnew");
hm = (NC_hashmap*)malloc(sizeof(NC_hashmap));
if(startsize == 0 || startsize < MINTABLESIZE)
startsize = MINTABLESIZE;
else {
startsize *= 4;
startsize /= 3;
startsize = findPrimeGreaterThan(startsize);
}
hm->table = (NC_hentry*)calloc(sizeof(NC_hentry), (size_t)startsize);
hm->size = startsize;
hm->count = 0;
hm->alloc = startsize;
hm->active = 0;
return hm;
}
int
NC_hashmapadd(NC_hashmap* hash, void* data, const char* key)
NC_hashmapadd(NC_hashmap* hash, uintptr_t data, void* key, size_t keysize)
{
if(hash->size*3/4 <= hash->count)
rehash(hash);
unsigned int hashkey;
TRACE("NC_hashmapadd");
if(key == NULL || keysize == 0)
return 0;
hashkey = NC_crc32(0,(unsigned char*)key,(unsigned int)keysize);
if(hash->alloc*3/4 <= hash->active)
rehash(hash);
for(;;) {
size_t index, hashkey;
if(!locate(hash,key,&index,&hashkey,1)) {
size_t index;
if(!locate(hash,hashkey,key,keysize,&index,1)) {
rehash(hash);
continue; /* try on larger table */
}
@ -163,8 +200,14 @@ NC_hashmapadd(NC_hashmap* hash, void* data, const char* key)
entry->flags = ACTIVE;
entry->data = data;
entry->hashkey = hashkey;
entry->key = (char*)key;
++hash->count;
entry->keysize = keysize;
if(keysize <= sizeof(uintptr_t)) {/* store a copy */
entry->key = 0;
memcpy((void*)&entry->key,key,keysize);
} else {
entry->key = (uintptr_t)key;
}
++hash->active;
return 1;
}
}
@ -172,35 +215,50 @@ NC_hashmapadd(NC_hashmap* hash, void* data, const char* key)
}
int
NC_hashmapremove(NC_hashmap* hash, const char* key, void** datap)
NC_hashmapremove(NC_hashmap* hash, void* key, size_t keysize, uintptr_t* datap)
{
unsigned int hashkey;
size_t index;
NC_hentry entry;
if(!locate(hash,key,&index,NULL,0))
return 0; /* not present */
entry = hash->table[index];
NC_hentry* h;
if(entry.flags & ACTIVE) { /* matching entry found */
hash->table[index].flags = DELETED; /* also turn off ACTIVE */
hash->table[index].key = NULL;
--hash->count;
if(datap) *datap = hash->table[index].data;
TRACE("NC_hashmapremove");
if(key == NULL || keysize == 0)
return 0;
hashkey = NC_crc32(0,(unsigned char*)key,(unsigned int)keysize);
if(!locate(hash,hashkey,key,keysize,&index,0))
return 0; /* not present */
h = &hash->table[index];
if(h->flags & ACTIVE) { /* matching entry found */
h->flags = DELETED; /* also turn off ACTIVE */
h->key = (uintptr_t)NULL;
h->keysize = 0;
--hash->active;
if(datap) *datap = h->data;
return 1;
} else /* !ACTIVE && !DELETED => not in table*/
return 0;
}
int
NC_hashmapget(NC_hashmap* hash, const char* key, void** datap)
NC_hashmapget(NC_hashmap* hash, void* key, size_t keysize, uintptr_t* datap)
{
if(hash->count) {
unsigned int hashkey;
TRACE("NC_hashmapget");
if(key == NULL || keysize == 0)
return 0;
hashkey = NC_crc32(0,(unsigned char*)key,(unsigned int)keysize);
if(hash->active) {
size_t index;
NC_hentry entry;
if(!locate(hash,key,&index,NULL,0))
NC_hentry* h;
if(!locate(hash,hashkey,key,keysize,&index,0))
return 0; /* not present */
entry = hash->table[index];
if(entry.flags & ACTIVE) {
if(datap) *datap = entry.data;
h = &hash->table[index];
if(h->flags & ACTIVE) {
if(datap) *datap = h->data;
return 1;
} else /* Not found */
return 0;
@ -212,36 +270,66 @@ NC_hashmapget(NC_hashmap* hash, const char* key, void** datap)
Return 1 if found, 0 otherwise
*/
int
NC_hashmapsetdata(NC_hashmap* hash, const char* key, void* newdata)
NC_hashmapsetdata(NC_hashmap* hash, void* key, size_t keysize, uintptr_t newdata)
{
size_t index;
NC_hentry* entry;
if(hash == NULL || hash->count == 0 || key == NULL)
NC_hentry* h;
unsigned int hashkey;
TRACE("NC_hashmapsetdata");
if(key == NULL || keysize == 0)
return 0;
hashkey = NC_crc32(0,(unsigned char*)key,(unsigned int)keysize);
if(hash == NULL || hash->active == 0)
return 0; /* no such entry */
if(!locate(hash,key,&index,NULL,0))
if(!locate(hash,hashkey,key,keysize,&index,0))
return 0; /* not present */
entry = &hash->table[index];
assert((entry->flags & ACTIVE) == ACTIVE);
entry->data = newdata;
h = &hash->table[index];
assert((h->flags & ACTIVE) == ACTIVE);
h->data = newdata;
return 1;
}
size_t
NC_hashmapcount(NC_hashmap* hash)
{
return hash->count;
TRACE("NC_hashmapcount");
return hash->active;
}
int
NC_hashmapfree(NC_hashmap* hash)
{
TRACE("NC_hashmapfree");
if(hash) {
#ifdef DEBUG
printhashmapstats(hash);
#endif
free(hash->table);
free(hash);
}
return 1;
}
int
NC_hashmapdeactivate(NC_hashmap* map, uintptr_t data)
{
size_t i;
NC_hentry* h;
for(h=map->table,i=0;i<map->alloc;i++,h++) {
if((h->flags & ACTIVE) && h->data == data) {
h->flags = DELETED;
h->key = (uintptr_t)NULL;
h->keysize = 0;
--map->active;
return 1;
}
}
return 0;
}
/**************************************************/
/* Prime table */
@ -1929,48 +2017,68 @@ static unsigned int NC_nprimes = (sizeof(NC_primes) / sizeof(unsigned int));
/**************************************************/
/* Debug support */
void
printhstring(NC_string* s)
{
size_t n;
char ss[256];
n = (s == NULL?0:s->nchars);
strcpy(ss,"NULL");
if(s != NULL)
strncpy(ss,s->cp,sizeof(ss)-1);
ss[255] = '\0';
if(n == 0 || n > 256)
strcpy(ss,"<undefined>");
fprintf(stderr,"%lx %ld |%s|\n",(unsigned long)s,(unsigned long)n,ss);
void
printhashmapstats(NC_hashmap* hm)
{
size_t n,i;
size_t step = 1;
size_t maxchain = 0;
for(n=0;n<hm->alloc;n++) {
size_t chainlen = 0;
size_t index = n;
/* Follow chain at this index */
for(i=0;i<hm->alloc;i++) {
NC_hentry* entry = &hm->table[index];
switch (entry->flags) {
case ACTIVE: chainlen++; break; /* Keep looking */
case DELETED: chainlen++; break; /* Keep looking */
default: /* empty slot, stop walking */
if(chainlen > maxchain) maxchain = chainlen;
goto next;
}
/* linear probe */
index = (index + step) % hm->alloc;
}
next: continue;
}
fprintf(stderr,"hashmap: alloc=%lu active=%lu maxchain=%lu\n",
(unsigned long)hm->alloc,(unsigned long)hm->active,(unsigned long)maxchain);
fflush(stderr);
}
/* Handle the data key part */
static const char*
keystr(NC_hentry* e)
{
static char s[sizeof(uintptr_t)+1];
size_t x = sizeof(uintptr_t);
if(e == NULL) return "<NULL>";
if(e->keysize <= x) {
memset(s,0,sizeof(s));
memcpy(s,(const char*)(&e->key),e->keysize);
return s;
} else
return (e->key?(const char*)(e->key):"<NULL>");
}
void
printhashmap(NC_hashmap* hm)
{
size_t i;
if(hm == NULL) {fprintf(stderr,"NULL"); fflush(stderr); return;}
fprintf(stderr,"{size=%lu count=%lu table=0x%lx}\n",
(unsigned long)hm->size,(unsigned long)hm->count,(unsigned long)((uintptr_t)hm->table));
if(hm->size > 4000) {
(unsigned long)hm->alloc,(unsigned long)hm->active,(unsigned long)((uintptr_t)hm->table));
if(hm->alloc > 4000) {
fprintf(stderr,"MALFORMED\n");
return;
}
for(i=0;i<hm->size;i++) {
for(i=0;i<hm->alloc;i++) {
NC_hentry e = hm->table[i];
if(e.flags == ACTIVE && e.key == NULL) {
fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p key=NULL\n",
(unsigned long)i,(unsigned long)e.hashkey,e.data);
} else if(e.flags == ACTIVE && e.key != NULL) {
char nm[64];
int elided = 0;
size_t len = strlen(e.key);
if(len > 63) {elided = 1; len = 63;}
memcpy(nm,e.key,len);
nm[63] = '\0';
fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p key=0x%lx |%s|%s\n",
(unsigned long)i, (unsigned long)e.hashkey, e.data,(unsigned long)((uintptr_t)nm),e.key,(elided?"...":""));
if(e.flags == ACTIVE) {
fprintf(stderr,"[%ld] flags=ACTIVE hashkey=%lu data=%p keysize=%u key=|%s|\n",
(unsigned long)i,(unsigned long)e.hashkey,(void*)e.data,(unsigned)e.keysize,keystr(&e));
} else if(e.flags == DELETED) {
fprintf(stderr,"[%ld] flags=DELETED hashkey=%lu\n",
(unsigned long)i,(unsigned long)e.hashkey);

View File

@ -18,7 +18,7 @@ lib_LTLIBRARIES = libnetcdf.la
# for information regarding incrementing `-version-info`.
##
libnetcdf_la_LDFLAGS = -version-info 14:0:1
libnetcdf_la_LDFLAGS = -version-info 14:1:1
libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS}
libnetcdf_la_LIBADD =
@ -62,12 +62,8 @@ endif # ENABLE_DAP4
if USE_NETCDF4
AM_CPPFLAGS += -I${top_srcdir}/libsrc4
libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la
# Not ready for prime time yet
# libnetcdf_la_LIBADD += ${top_builddir}/libdiskless/libdiskless.la
endif #USE_NETCDF4
if ISCYGWIN

View File

@ -10,7 +10,7 @@ foreach (f ${m4_SOURCES})
endforeach(f)
SET(libsrc_SOURCES v1hpg.c putget.c attr.c nc3dispatch.c
nc3internal.c var.c dim.c ncx.c lookup3.c ncio.c nc_hashmap.c)
nc3internal.c var.c dim.c ncx.c lookup3.c ncio.c)
SET(libsrc_SOURCES ${libsrc_SOURCES} pstdint.h ncio.h ncx.h)

View File

@ -10,7 +10,7 @@ libnetcdf3_la_CPPFLAGS = ${AM_CPPFLAGS}
# These files comprise the netCDF-3 classic library code.
libnetcdf3_la_SOURCES = v1hpg.c \
putget.c attr.c nc3dispatch.c nc3internal.c var.c dim.c ncx.c nc_hashmap.c \
putget.c attr.c nc3dispatch.c nc3internal.c var.c dim.c ncx.c \
ncx.h lookup3.c pstdint.h ncio.c ncio.h
if BUILD_DISKLESS

View File

@ -118,29 +118,29 @@ new_NC_attr(
nc_type type,
size_t nelems)
{
NC_string *strp;
NC_attr *attrp;
char *name;
int stat;
NC_string *strp = NULL;
NC_attr *attrp = NULL;
char *name = NULL;
int stat = NC_NOERR;
stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char**)&name);
if(stat != NC_NOERR)
return NULL;
goto done;
assert(name != NULL && *name != 0);
strp = new_NC_string(strlen(name), name);
free(name);
if(strp == NULL)
return NULL;
goto done;
attrp = new_x_NC_attr(strp, type, nelems);
if(attrp == NULL)
{
free_NC_string(strp);
return NULL;
goto done;
}
return(attrp);
done:
if(name) free(name);
return (attrp);
}
@ -345,36 +345,34 @@ NC_attrarray0(NC3_INFO* ncp, int varid)
NC_attr **
NC_findattr(const NC_attrarray *ncap, const char *uname)
{
NC_attr **attrpp;
NC_attr **attrpp = NULL;
size_t attrid;
size_t slen;
char *name;
int stat;
char *name = NULL;
int stat = NC_NOERR;
assert(ncap != NULL);
if(ncap->nelems == 0)
return NULL;
attrpp = (NC_attr **) ncap->value;
goto done;
/* normalized version of uname */
stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char**)&name);
if(stat != NC_NOERR)
return NULL; /* TODO: need better way to indicate no memory */
goto done; /* TODO: need better way to indicate no memory */
slen = strlen(name);
attrpp = (NC_attr **) ncap->value;
for(attrid = 0; attrid < ncap->nelems; attrid++, attrpp++)
{
if(strlen((*attrpp)->name->cp) == slen &&
strncmp((*attrpp)->name->cp, name, slen) == 0)
{
free(name);
return(attrpp); /* Normal return */
}
goto done;
}
free(name);
return(NULL);
attrpp = NULL; /* not found */
done:
if(name) free(name);
return (attrpp); /* Normal return */
}
@ -501,71 +499,65 @@ NC3_inq_att(int ncid,
int
NC3_rename_att( int ncid, int varid, const char *name, const char *unewname)
{
int status;
NC *nc;
NC3_INFO* ncp;
NC_attrarray *ncap;
NC_attr **tmp;
NC_attr *attrp;
int status = NC_NOERR;
NC *nc = NULL;
NC3_INFO* ncp = NULL;
NC_attrarray *ncap = NULL;
NC_attr **tmp = NULL;
NC_attr *attrp = NULL;
NC_string *newStr, *old;
char *newname; /* normalized version */
char *newname = NULL; /* normalized version */
/* start sortof inline clone of NC_lookupattr() */
/* sortof inline clone of NC_lookupattr() */
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR)
return status;
goto done;
ncp = NC3_DATA(nc);
if(NC_readonly(ncp))
return NC_EPERM;
{status = NC_EPERM; goto done;}
ncap = NC_attrarray0(ncp, varid);
if(ncap == NULL)
return NC_ENOTVAR;
{status = NC_ENOTVAR; goto done;}
status = NC_check_name(unewname);
if(status != NC_NOERR)
return status;
goto done;
tmp = NC_findattr(ncap, name);
if(tmp == NULL)
return NC_ENOTATT;
{status = NC_ENOTATT; goto done;}
attrp = *tmp;
/* end inline clone NC_lookupattr() */
/* end inline clone NC_lookupattr() */
if(NC_findattr(ncap, unewname) != NULL)
{
/* name in use */
return NC_ENAMEINUSE;
}
{status = NC_ENAMEINUSE; goto done;} /* name in use */
old = attrp->name;
status = nc_utf8_normalize((const unsigned char *)unewname,(unsigned char**)&newname);
if(status != NC_NOERR)
return status;
goto done;
if(NC_indef(ncp))
{
newStr = new_NC_string(strlen(newname), newname);
free(newname);
if( newStr == NULL)
return NC_ENOMEM;
{status = NC_ENOMEM; goto done;}
attrp->name = newStr;
free_NC_string(old);
return NC_NOERR;
goto done;
}
/* else not in define mode */
/* If new name is longer than old, then complain,
but otherwise, no change (test is same as set_NC_string)*/
if(old->nchars < strlen(newname)) {
free(newname);
return NC_ENOTINDEFINE;
}
if(old->nchars < strlen(newname))
{status = NC_ENOTINDEFINE; goto done;}
status = set_NC_string(old, newname);
free(newname);
if( status != NC_NOERR)
return status;
goto done;
set_NC_hdirty(ncp);
@ -573,43 +565,43 @@ NC3_rename_att( int ncid, int varid, const char *name, const char *unewname)
{
status = NC_sync(ncp);
if(status != NC_NOERR)
return status;
goto done;
}
return NC_NOERR;
done:
if(newname) free(newname);
return status;
}
int
NC3_del_att(int ncid, int varid, const char *uname)
{
int status;
NC *nc;
NC3_INFO* ncp;
NC_attrarray *ncap;
NC_attr **attrpp;
int status = NC_NOERR;
NC *nc = NULL;
NC3_INFO* ncp = NULL;
NC_attrarray *ncap = NULL;
NC_attr **attrpp = NULL;
NC_attr *old = NULL;
int attrid;
size_t slen;
char* name = NULL;
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR)
return status;
goto done;
ncp = NC3_DATA(nc);
if(!NC_indef(ncp))
return NC_ENOTINDEFINE;
{status = NC_ENOTINDEFINE; goto done;}
ncap = NC_attrarray0(ncp, varid);
if(ncap == NULL)
return NC_ENOTVAR;
{status = NC_ENOTVAR; goto done;}
{
char* name;
int stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char**)&name);
if(stat != NC_NOERR)
return stat;
status = nc_utf8_normalize((const unsigned char *)uname,(unsigned char**)&name);
if(status != NC_NOERR)
goto done;
/* sortof inline NC_findattr() */
/* start sortof inline NC_findattr() */
slen = strlen(name);
attrpp = (NC_attr **) ncap->value;
@ -622,11 +614,9 @@ NC3_del_att(int ncid, int varid, const char *uname)
break;
}
}
free(name);
}
if( (size_t) attrid == ncap->nelems )
return NC_ENOTATT;
/* end inline NC_findattr() */
{status = NC_ENOTATT; goto done;}
/* end inline NC_findattr() */
/* shuffle down */
for(attrid++; (size_t) attrid < ncap->nelems; attrid++)
@ -640,7 +630,9 @@ NC3_del_att(int ncid, int varid, const char *uname)
free_NC_attr(old);
return NC_NOERR;
done:
if(name) free(name);
return status;
}
dnl

View File

@ -55,28 +55,29 @@ static NC_dim *
new_NC_dim(const char *uname, size_t size)
{
NC_string *strp;
NC_dim *dimp;
int stat;
char* name;
NC_dim *dimp = NULL;
int stat = NC_NOERR;
char* name = NULL;
stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name);
if(stat != NC_NOERR)
return NULL;
goto done;
strp = new_NC_string(strlen(name), name);
free(name);
if(strp == NULL)
return NULL;
{stat = NC_ENOMEM; goto done;}
dimp = new_x_NC_dim(strp);
if(dimp == NULL)
{
free_NC_string(strp);
return NULL;
goto done;
}
dimp->size = size;
return(dimp);
done:
if(name) free(name);
return (dimp);
}
@ -119,7 +120,6 @@ find_NC_Udim(const NC_dimarray *ncap, NC_dim **dimpp)
}
}
/*
* Step thru NC_DIMENSION array, seeking match on uname.
* Return dimid or -1 on not found.
@ -130,32 +130,24 @@ find_NC_Udim(const NC_dimarray *ncap, NC_dim **dimpp)
static int
NC_finddim(const NC_dimarray *ncap, const char *uname, NC_dim **dimpp)
{
int dimid;
char *name;
int dimid = -1;
char *name = NULL;
uintptr_t data;
assert(ncap != NULL);
if(ncap->nelems == 0)
return -1;
goto done;
/* normalized version of uname */
if(nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name))
goto done;
if(NC_hashmapget(ncap->hashmap, name, strlen(name), &data) == 0)
goto done;
dimid = (int)data;
if(dimpp) *dimpp = ncap->value[dimid];
{
int stat;
dimid = 0;
/* normalized version of uname */
stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name);
if(stat != NC_NOERR)
return stat;
dimid = (int)NC_hashmapGetDim(ncap, name);
free(name);
if (dimid >= 0) {
if (dimpp != NULL)
*dimpp = ncap->value[dimid];
}
return(dimid); /* Normal return */
}
return -1;
done:
if(name) free(name);
return dimid;
}
@ -202,7 +194,7 @@ free_NC_dimarrayV(NC_dimarray *ncap)
if(ncap->nalloc == 0)
return;
NC_hashmapDelete(ncap->hashmap);
NC_hashmapfree(ncap->hashmap);
ncap->hashmap = NULL;
assert(ncap->value != NULL);
@ -281,7 +273,7 @@ incr_NC_dimarray(NC_dimarray *ncap, NC_dim *newelemp)
return NC_ENOMEM;
ncap->value = vp;
ncap->nalloc = NC_ARRAY_GROWBY;
ncap->hashmap = NC_hashmapCreate(0);
ncap->hashmap = NC_hashmapnew(0);
}
else if(ncap->nelems +1 > ncap->nalloc)
{
@ -295,9 +287,10 @@ incr_NC_dimarray(NC_dimarray *ncap, NC_dim *newelemp)
if(newelemp != NULL)
{
NC_hashmapAddDim(ncap, (long)ncap->nelems, newelemp->name->cp);
ncap->value[ncap->nelems] = newelemp;
ncap->nelems++;
uintptr_t intdata = ncap->nelems;
NC_hashmapadd(ncap->hashmap, intdata, newelemp->name->cp, strlen(newelemp->name->cp));
ncap->value[ncap->nelems] = newelemp;
ncap->nelems++;
}
return NC_NOERR;
}
@ -440,69 +433,75 @@ NC3_inq_dim(int ncid, int dimid, char *name, size_t *sizep)
int
NC3_rename_dim( int ncid, int dimid, const char *unewname)
{
int status;
int status = NC_NOERR;
NC *nc;
NC3_INFO* ncp;
int existid;
NC_dim *dimp;
char *newname; /* normalized */
char *newname = NULL; /* normalized */
NC_string *old = NULL;
uintptr_t intdata;
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR)
return status;
goto done;
ncp = NC3_DATA(nc);
if(NC_readonly(ncp))
return NC_EPERM;
{status = NC_EPERM; goto done;}
status = NC_check_name(unewname);
if(status != NC_NOERR)
return status;
goto done;
existid = NC_finddim(&ncp->dims, unewname, &dimp);
if(existid != -1)
return NC_ENAMEINUSE;
{status = NC_ENAMEINUSE; goto done;}
dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
if(dimp == NULL)
return NC_EBADDIM;
{status = NC_EBADDIM; goto done;}
old = dimp->name;
status = nc_utf8_normalize((const unsigned char *)unewname,(unsigned char **)&newname);
if(status != NC_NOERR)
return status;
goto done;
if(NC_indef(ncp))
{
NC_string *newStr = new_NC_string(strlen(newname), newname);
free(newname);
if(newStr == NULL)
return NC_ENOMEM;
{status = NC_ENOMEM; goto done;}
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveDim(&ncp->dims, old->cp);
NC_hashmapremove(ncp->dims.hashmap, old->cp, strlen(old->cp), NULL);
dimp->name = newStr;
NC_hashmapAddDim(&ncp->dims, dimid, newStr->cp);
intdata = dimid;
NC_hashmapadd(ncp->dims.hashmap, intdata, newStr->cp, strlen(newStr->cp));
free_NC_string(old);
return NC_NOERR;
goto done;
}
/* else, not in define mode */
/* If new name is longer than old, then complain,
but otherwise, no change (test is same as set_NC_string)*/
if(dimp->name->nchars < strlen(newname)) {
{status = NC_ENOTINDEFINE; goto done;}
}
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveDim(&ncp->dims, old->cp);
/* WARNING: strlen(NC_string.cp) may be less than NC_string.nchars */
NC_hashmapremove(ncp->dims.hashmap, old->cp, strlen(old->cp), NULL);
/* WARNING: strlen(NC_string.cp) may be less than NC_string.nchars */
status = set_NC_string(dimp->name, newname);
free(newname);
if(status != NC_NOERR)
return status;
goto done;
NC_hashmapAddDim(&ncp->dims, dimid, dimp->name->cp);
intdata = (uintptr_t)dimid;
NC_hashmapadd(ncp->dims.hashmap, intdata, dimp->name->cp, strlen(dimp->name->cp));
set_NC_hdirty(ncp);
@ -510,8 +509,10 @@ NC3_rename_dim( int ncid, int dimid, const char *unewname)
{
status = NC_sync(ncp);
if(status != NC_NOERR)
return status;
goto done;
}
return NC_NOERR;
done:
if(newname) free(newname);
return status;
}

View File

@ -36,10 +36,6 @@
#include <stdio.h>
#endif
#ifndef HAVE_SSIZE_T
typedef int ssize_t;
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
@ -180,7 +176,7 @@ static int memio_new(const char* path, int ioflags, off_t initialsize, void* mem
memio->memory = memory;
} else {
/* malloc memory */
memio->memory = (char*)malloc(memio->alloc);
memio->memory = (char*)malloc((size_t)memio->alloc);
if(memio->memory == NULL) {status = NC_ENOMEM; goto fail;}
}
@ -227,7 +223,7 @@ memio_create(const char* path, int ioflags,
if(path == NULL ||* path == 0)
return NC_EINVAL;
status = memio_new(path, ioflags, initialsz, NULL, &nciop, &memio);
status = memio_new(path, ioflags, (off_t)initialsz, NULL, &nciop, &memio);
if(status != NC_NOERR)
return status;
@ -270,7 +266,7 @@ fprintf(stderr,"memio_create: initial memory: %lu/%lu\n",(unsigned long)memio->m
}
/* Pick a default sizehint */
if(sizehintp) *sizehintp = pagesize;
if(sizehintp) *sizehintp = (size_t)pagesize;
*nciopp = nciop;
return NC_NOERR;
@ -322,7 +318,7 @@ memio_open(const char* path,
sizehint = *sizehintp;
if(inmemory) {
filesize = meminfo->size;
filesize = (off_t)meminfo->size;
} else {
/* Open the file,and make sure we can write it if needed */
oflags = (persist ? O_RDWR : O_RDONLY);
@ -373,7 +369,7 @@ fprintf(stderr,"memio_open: initial memory: %lu/%lu\n",(unsigned long)memio->mem
red = memio->size;
pos = memio->memory;
while(red > 0) {
ssize_t count = read(fd, pos, red);
ssize_t count = (ssize_t)read(fd, pos, (size_t)red);
if(count < 0) {status = errno; goto unwind_open;}
if(count == 0) {status = NC_ENOTNC; goto unwind_open;}
red -= count;
@ -383,7 +379,7 @@ fprintf(stderr,"memio_open: initial memory: %lu/%lu\n",(unsigned long)memio->mem
}
/* Use half the filesize as the blocksize ; why? */
sizehint = filesize/2;
sizehint = (size_t)filesize/2;
/* sizehint must be multiple of 8 */
sizehint = (sizehint / 8) * 8;
@ -454,11 +450,11 @@ memio_pad_length(ncio* nciop, off_t length)
if((newsize % pagesize) != 0)
newsize += (pagesize - (newsize % pagesize));
newmem = (char*)realloc(memio->memory,newsize);
newmem = (char*)realloc(memio->memory,(size_t)newsize);
if(newmem == NULL) return NC_ENOMEM;
/* zero out the extra memory */
memset((void*)((char*)newmem+memio->alloc),0,(newsize - memio->alloc));
memset((void*)((char*)newmem+memio->alloc),0,(size_t)(newsize - memio->alloc));
#ifdef DEBUG
fprintf(stderr,"realloc: %lu/%lu -> %lu/%lu\n",
@ -509,7 +505,7 @@ memio_close(ncio* nciop, int doUnlink)
off_t written = memio->size;
char* pos = memio->memory;
while(written > 0) {
ssize_t count = write(fd, pos, written);
ssize_t count = (ssize_t)write(fd, pos, (size_t)written);
if(count < 0)
{status = errno; goto done;}
if(count == 0)
@ -557,7 +553,7 @@ memio_get(ncio* const nciop, off_t offset, size_t extent, int rflags, void** con
NCMEMIO* memio;
if(nciop == NULL || nciop->pvt == NULL) return NC_EINVAL;
memio = (NCMEMIO*)nciop->pvt;
status = guarantee(nciop, offset+extent);
status = guarantee(nciop, offset+(off_t)extent);
memio->locked++;
if(status != NC_NOERR) return status;
if(vpp) *vpp = memio->memory+offset;
@ -577,11 +573,11 @@ memio_move(ncio* const nciop, off_t to, off_t from, size_t nbytes, int ignored)
memio = (NCMEMIO*)nciop->pvt;
if(from < to) {
/* extend if "to" is not currently allocated */
status = guarantee(nciop,to+nbytes);
status = guarantee(nciop,to+(off_t)nbytes);
if(status != NC_NOERR) return status;
}
/* check for overlap */
if((to + nbytes) > from || (from + nbytes) > to) {
if((to + (off_t)nbytes) > from || (from + (off_t)nbytes) > to) {
/* Ranges overlap */
#ifdef HAVE_MEMMOVE
memmove((void*)(memio->memory+to),(void*)(memio->memory+from),nbytes);

View File

@ -49,10 +49,6 @@
# endif
#endif /*HAVE_MREMAP*/
#ifndef HAVE_SSIZE_T
#define ssize_t int
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1

View File

@ -702,7 +702,7 @@ NC_check_vlens(NC3_INFO *ncp)
/* maximum permitted variable size (or size of one record's worth
of a record variable) in bytes. This is different for format 1
and format 2. */
size_t vlen_max;
unsigned long long vlen_max;
size_t ii;
size_t large_vars_count;
size_t rec_vars_count;
@ -712,7 +712,7 @@ NC_check_vlens(NC3_INFO *ncp)
return NC_NOERR;
if (fIsSet(ncp->flags,NC_64BIT_DATA)) /* CDF-5 */
vlen_max = X_INT64_MAX - 3; /* "- 3" handles rounded-up size */
vlen_max = (size_t)X_INT64_MAX - 3; /* "- 3" handles rounded-up size */
else if (fIsSet(ncp->flags,NC_64BIT_OFFSET) && sizeof(off_t) > 4)
/* CDF2 format and LFS */
vlen_max = X_UINT_MAX - 3; /* "- 3" handles rounded-up size */

View File

@ -1,398 +0,0 @@
#include "nc3internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
/* this should be prime */
#define TABLE_STARTSIZE 1021
#define ACTIVE 1
#define MAX(a,b) ((a) > (b) ? (a) : (b))
extern uint32_t hash_fast(const void *key, size_t length);
static int isPrime(unsigned long val)
{
int i;
for (i = 9; i--;)
{
#ifdef HAVE_RANDOM
unsigned long a = ((unsigned long)random() % (val-4)) + 2;
#else
unsigned long a = ((unsigned long)rand() % (val - 4)) + 2;
#endif
unsigned long p = 1;
unsigned long exp = val-1;
while (exp)
{
if (exp & 1)
p = (p*a)%val;
a = (a*a)%val;
exp >>= 1;
}
if (p != 1)
return 0;
}
return 1;
}
static unsigned long findPrimeGreaterThan(unsigned long val)
{
if (val & 1)
val+=2;
else
val++;
while (!isPrime(val))
val+=2;
return val;
}
static void rehashDim(const NC_dimarray* ncap)
{
NC_hashmap* hm = ncap->hashmap;
unsigned long size = hm->size;
unsigned long count = hm->count;
hEntry* table = hm->table;
hm->size = findPrimeGreaterThan(size<<1);
hm->table = (hEntry*)calloc(sizeof(hEntry), hm->size);
hm->count = 0;
while(size > 0) {
--size;
if (table[size].flags == ACTIVE) {
NC_dim *elem = ncap->value[table[size].data-1];
NC_hashmapAddDim(ncap, table[size].data-1, elem->name->cp);
assert(NC_hashmapGetDim(ncap, elem->name->cp) == table[size].data-1);
}
}
free(table);
assert(count == hm->count);
}
static void rehashVar(const NC_vararray* ncap)
{
NC_hashmap* hm = ncap->hashmap;
unsigned long size = hm->size;
unsigned long count = hm->count;
hEntry* table = hm->table;
hm->size = findPrimeGreaterThan(size<<1);
hm->table = (hEntry*)calloc(sizeof(hEntry), (size_t)hm->size);
hm->count = 0;
while(size > 0) {
--size;
if (table[size].flags == ACTIVE) {
NC_var *elem = ncap->value[table[size].data-1];
NC_hashmapAddVar(ncap, table[size].data-1, elem->name->cp);
assert(NC_hashmapGetVar(ncap, elem->name->cp) == table[size].data-1);
}
}
free(table);
assert(count == hm->count);
}
NC_hashmap* NC_hashmapCreate(unsigned long startsize)
{
NC_hashmap* hm = (NC_hashmap*)malloc(sizeof(NC_hashmap));
if (!startsize)
startsize = TABLE_STARTSIZE;
else {
startsize *= 4;
startsize /= 3;
startsize = findPrimeGreaterThan(startsize-2);
}
hm->table = (hEntry*)calloc(sizeof(hEntry), (size_t)startsize);
hm->size = startsize;
hm->count = 0;
return hm;
}
void NC_hashmapAddDim(const NC_dimarray* ncap, long data, const char *name)
{
unsigned long key = hash_fast(name, strlen(name));
NC_hashmap* hash = ncap->hashmap;
if (hash->size*3/4 <= hash->count) {
rehashDim(ncap);
}
do
{
unsigned long i;
unsigned long index = key % hash->size;
unsigned long step = (key % MAX(1,(hash->size-2))) + 1;
for (i = 0; i < hash->size; i++)
{
if (hash->table[index].flags & ACTIVE)
{
hEntry entry = hash->table[index];
if (entry.key == key &&
strncmp(name, ncap->value[entry.data-1]->name->cp,
ncap->value[entry.data-1]->name->nchars) == 0)
{
hash->table[index].data = data+1;
return;
}
}
else
{
hash->table[index].flags |= ACTIVE;
hash->table[index].data = data+1;
hash->table[index].key = key;
++hash->count;
return;
}
index = (index + step) % hash->size;
}
/* it should not be possible that we EVER come this far, but unfortunately
not every generated prime number is prime (Carmichael numbers...) */
rehashDim(ncap);
}
while (1);
}
void NC_hashmapAddVar(const NC_vararray* ncap, long data, const char *name)
{
unsigned long key = hash_fast(name, strlen(name));
NC_hashmap* hash = ncap->hashmap;
if (hash->size*3/4 <= hash->count) {
rehashVar(ncap);
}
do
{
unsigned long i;
unsigned long index = key % hash->size;
unsigned long step = (key % MAX(1,(hash->size-2))) + 1;
for (i = 0; i < hash->size; i++)
{
if (hash->table[index].flags & ACTIVE)
{
hEntry entry = hash->table[index];
if (entry.key == key &&
strncmp(name, ncap->value[entry.data-1]->name->cp,
ncap->value[entry.data-1]->name->nchars) == 0)
{
hash->table[index].data = data+1;
return;
}
}
else
{
hash->table[index].flags |= ACTIVE;
hash->table[index].data = data+1;
hash->table[index].key = key;
++hash->count;
return;
}
index = (index + step) % hash->size;
}
/* it should not be possible that we EVER come this far, but unfortunately
not every generated prime number is prime (Carmichael numbers...) */
rehashVar(ncap);
}
while (1);
}
long NC_hashmapRemoveDim(const NC_dimarray* ncap, const char *name)
{
unsigned long i;
unsigned long key = hash_fast(name, strlen(name));
NC_hashmap* hash = ncap->hashmap;
unsigned long index = key % hash->size;
unsigned long step = (key % (hash->size-2)) + 1;
for (i = 0; i < hash->size; i++)
{
if (hash->table[index].data > 0)
{
hEntry entry = hash->table[index];
if (entry.key == key &&
strncmp(name, ncap->value[entry.data-1]->name->cp,
ncap->value[entry.data-1]->name->nchars) == 0)
{
if (hash->table[index].flags & ACTIVE)
{
hash->table[index].flags &= ~ACTIVE;
--hash->count;
return hash->table[index].data-1;
}
else /* in, but not active (i.e. deleted) */
return -1;
}
}
else /* found an empty place (can't be in) */
return -1;
index = (index + step) % hash->size;
}
/* everything searched through, but not in */
return -1;
}
long NC_hashmapRemoveVar(const NC_vararray* ncap, const char *name)
{
unsigned long i;
unsigned long key = hash_fast(name, strlen(name));
NC_hashmap* hash = ncap->hashmap;
unsigned long index = key % hash->size;
unsigned long step = (key % (hash->size-2)) + 1;
for (i = 0; i < hash->size; i++)
{
if (hash->table[index].data > 0)
{
hEntry entry = hash->table[index];
if (entry.key == key &&
strncmp(name, ncap->value[entry.data-1]->name->cp,
ncap->value[entry.data-1]->name->nchars) == 0)
{
if (hash->table[index].flags & ACTIVE)
{
hash->table[index].flags &= ~ACTIVE;
--hash->count;
return hash->table[index].data-1;
}
else /* in, but not active (i.e. deleted) */
return -1;
}
}
else /* found an empty place (can't be in) */
return -1;
index = (index + step) % hash->size;
}
/* everything searched through, but not in */
return -1;
}
long NC_hashmapGetDim(const NC_dimarray* ncap, const char *name)
{
NC_hashmap* hash = ncap->hashmap;
if (hash->count)
{
unsigned long key = hash_fast(name, strlen(name));
NC_hashmap* hash = ncap->hashmap;
unsigned long i;
unsigned long index = key % hash->size;
unsigned long step = (key % (hash->size-2)) + 1;
for (i = 0; i < hash->size; i++)
{
hEntry entry = hash->table[index];
if (entry.key == key &&
strncmp(name, ncap->value[entry.data-1]->name->cp,
ncap->value[entry.data-1]->name->nchars) == 0)
{
if (entry.flags & ACTIVE)
return entry.data-1;
break;
}
else
if (!(entry.flags & ACTIVE))
break;
index = (index + step) % hash->size;
}
}
return -1;
}
long NC_hashmapGetVar(const NC_vararray* ncap, const char *name)
{
NC_hashmap* hash = ncap->hashmap;
if (hash->count)
{
unsigned long key = hash_fast(name, strlen(name));
NC_hashmap* hash = ncap->hashmap;
unsigned long i;
unsigned long index = key % hash->size;
unsigned long step = (key % (hash->size-2)) + 1;
for (i = 0; i < hash->size; i++)
{
hEntry entry = hash->table[index];
if (entry.key == key &&
strncmp(name, ncap->value[entry.data-1]->name->cp,
ncap->value[entry.data-1]->name->nchars) == 0)
{
if (entry.flags & ACTIVE)
return entry.data-1;
break;
}
else
if (!(entry.flags & ACTIVE))
break;
index = (index + step) % hash->size;
}
}
return -1;
}
unsigned long NC_hashmapCount(NC_hashmap* hash)
{
return hash->count;
}
void NC_hashmapDelete(NC_hashmap* hash)
{
if (hash) {
free(hash->table);
free(hash);
}
}
void
NC_hashmap_verify(NC_hashmap* hash, NC_dim** dims)
{
unsigned long i;
if(hash->count == 0) {
fprintf(stderr,"<empty>\n");
goto done;
}
for(i=0;i<hash->size;i++) {
hEntry* e = &hash->table[i];
if(e->flags == ACTIVE) {
fprintf(stderr,"[%d] key=%lu data=%ld",(int)i,e->key,e->data-1);
if(dims != NULL) {
fprintf(stderr," name=%s",dims[e->data-1]->name->cp);
}
fprintf(stderr,"\n");
}
}
done:
fflush(stderr);
}

View File

@ -41,10 +41,6 @@
#define NC_NOERR 0
#endif
#ifndef HAVE_SSIZE_T
typedef int ssize_t;
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1

View File

@ -536,12 +536,12 @@ v1h_get_NC_dimarray(v1hs *gsp, NC_dimarray *ncap)
if(type != NC_DIMENSION)
return EINVAL;
ncap->value = (NC_dim **) malloc(ncap->nelems * sizeof(NC_dim *));
ncap->value = (NC_dim **) calloc(1,ncap->nelems * sizeof(NC_dim *));
if(ncap->value == NULL)
return NC_ENOMEM;
ncap->nalloc = ncap->nelems;
ncap->hashmap = NC_hashmapCreate(ncap->nelems);
ncap->hashmap = NC_hashmapnew(ncap->nelems);
{
NC_dim **dpp = ncap->value;
@ -557,7 +557,7 @@ v1h_get_NC_dimarray(v1hs *gsp, NC_dimarray *ncap)
}
{
int dimid = (size_t)(dpp - ncap->value);
NC_hashmapAddDim(ncap, dimid, (*dpp)->name->cp);
NC_hashmapadd(ncap->hashmap, (uintptr_t)dimid, (*dpp)->name->cp,strlen((*dpp)->name->cp));
}
}
}
@ -1176,12 +1176,12 @@ v1h_get_NC_vararray(v1hs *gsp, NC_vararray *ncap)
if(type != NC_VARIABLE)
return EINVAL;
ncap->value = (NC_var **) malloc(ncap->nelems * sizeof(NC_var *));
ncap->value = (NC_var **) calloc(1,ncap->nelems * sizeof(NC_var *));
if(ncap->value == NULL)
return NC_ENOMEM;
ncap->nalloc = ncap->nelems;
ncap->hashmap = NC_hashmapCreate(ncap->nelems);
ncap->hashmap = NC_hashmapnew(ncap->nelems);
{
NC_var **vpp = ncap->value;
NC_var *const *const end = &vpp[ncap->nelems];
@ -1196,7 +1196,7 @@ v1h_get_NC_vararray(v1hs *gsp, NC_vararray *ncap)
}
{
int varid = (size_t)(vpp - ncap->value);
NC_hashmapAddVar(ncap, varid, (*vpp)->name->cp);
NC_hashmapadd(ncap->hashmap, (uintptr_t)varid, (*vpp)->name->cp,strlen((*vpp)->name->cp));
}
}
}

View File

@ -230,7 +230,7 @@ free_NC_vararrayV(NC_vararray *ncap)
if(ncap->nalloc == 0)
return;
NC_hashmapDelete(ncap->hashmap);
NC_hashmapfree(ncap->hashmap);
ncap->hashmap = NULL;
assert(ncap->value != NULL);
@ -310,7 +310,7 @@ incr_NC_vararray(NC_vararray *ncap, NC_var *newelemp)
ncap->value = vp;
ncap->nalloc = NC_ARRAY_GROWBY;
ncap->hashmap = NC_hashmapCreate(0);
ncap->hashmap = NC_hashmapnew(0);
}
else if(ncap->nelems +1 > ncap->nalloc)
{
@ -324,7 +324,7 @@ incr_NC_vararray(NC_vararray *ncap, NC_var *newelemp)
if(newelemp != NULL)
{
NC_hashmapAddVar(ncap, (long)ncap->nelems, newelemp->name->cp);
NC_hashmapadd(ncap->hashmap, (uintptr_t)ncap->nelems, newelemp->name->cp, strlen(newelemp->name->cp));
ncap->value[ncap->nelems] = newelemp;
ncap->nelems++;
}
@ -353,35 +353,33 @@ elem_NC_vararray(const NC_vararray *ncap, size_t elem)
* 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
* Formerly (sort of) NC_hvarid
*/
int
NC_findvar(const NC_vararray *ncap, const char *uname, NC_var **varpp)
{
int hash_var_id;
char *name;
int stat;
int hash_var_id = -1;
uintptr_t data;
char *name = NULL;
assert(ncap != NULL);
if(ncap->nelems == 0)
return -1;
goto done;
/* normalized version of uname */
stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name);
if(stat != NC_NOERR)
return stat;
if(nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name))
goto done;
hash_var_id = (int)NC_hashmapGetVar(ncap, name);
free(name);
if (hash_var_id >= 0) {
if (varpp != NULL)
*varpp = ncap->value[hash_var_id];
return(hash_var_id); /* Normal return */
}
return(-1); /* not found */
if(NC_hashmapget(ncap->hashmap, name, strlen(name), &data) == 0)
goto done;
hash_var_id = (int)data;
if (varpp != NULL)
*varpp = ncap->value[hash_var_id];
done:
if(name != NULL) free(name);
return(hash_var_id); /* Normal return */
}
/*
@ -487,7 +485,7 @@ NC_var_shape(NC_var *varp, const NC_dimarray *dims)
out :
/* No variable size can be > X_INT64_MAX - 3 */
if (0 == NC_check_vlen(varp, X_INT64_MAX-3)) return NC_EVARSIZE;
if (0 == NC_check_vlen(varp, (size_t)X_INT64_MAX-3)) return NC_EVARSIZE;
/*
* For CDF-1 and CDF-2 formats, the total number of array elements
@ -515,8 +513,8 @@ out :
* systems with LFS it should be 2^32 - 4.
*/
int
NC_check_vlen(NC_var *varp, size_t vlen_max) {
size_t prod=varp->xsz; /* product of xsz and dimensions so far */
NC_check_vlen(NC_var *varp, unsigned long long vlen_max) {
unsigned long long prod=varp->xsz; /* product of xsz and dimensions so far */
int ii;
@ -524,7 +522,7 @@ NC_check_vlen(NC_var *varp, size_t vlen_max) {
for(ii = IS_RECVAR(varp) ? 1 : 0; ii < varp->ndims; ii++) {
if(!varp->shape)
return 0; /* Shape is undefined/NULL. */
if (varp->shape[ii] > vlen_max / prod) {
if (varp->shape[ii] > (size_t)(vlen_max / prod)) {
return 0; /* size in bytes won't fit in a 32-bit int */
}
prod *= varp->shape[ii];
@ -734,73 +732,72 @@ NC3_inq_var(int ncid,
int
NC3_rename_var(int ncid, int varid, const char *unewname)
{
int status;
int status = NC_NOERR;
NC *nc;
NC3_INFO* ncp;
uintptr_t intdata;
NC_var *varp;
NC_string *old, *newStr;
int other;
char *newname; /* normalized */
char *newname = NULL; /* normalized */
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR)
return status;
goto done;
ncp = NC3_DATA(nc);
if(NC_readonly(ncp))
{
return NC_EPERM;
}
{status = NC_EPERM; goto done;}
status = NC_check_name(unewname);
if(status != NC_NOERR)
return status;
goto done;
/* check for name in use */
other = NC_findvar(&ncp->vars, unewname, &varp);
if(other != -1)
{
return NC_ENAMEINUSE;
}
{status = NC_ENAMEINUSE; goto done;}
status = NC_lookupvar(ncp, varid, &varp);
if(status != NC_NOERR)
{
/* invalid varid */
return status;
}
goto done; /* invalid varid */
old = varp->name;
status = nc_utf8_normalize((const unsigned char *)unewname,(unsigned char **)&newname);
if(status != NC_NOERR)
return status;
goto done;
if(NC_indef(ncp))
{
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveVar(&ncp->vars, old->cp);
/* WARNING: strlen(NC_string.cp) may be less than NC_string.nchars */
NC_hashmapremove(ncp->vars.hashmap,old->cp,strlen(old->cp),NULL);
newStr = new_NC_string(strlen(newname),newname);
free(newname);
if(newStr == NULL)
return(-1);
{status = NC_ENOMEM; goto done;}
varp->name = newStr;
NC_hashmapAddVar(&ncp->vars, varid, newStr->cp);
intdata = (uintptr_t)varid;
NC_hashmapadd(ncp->vars.hashmap, intdata, varp->name->cp, strlen(varp->name->cp));
free_NC_string(old);
return NC_NOERR;
goto done;
}
/* else, not in define mode */
/* If new name is longer than old, then complain,
but otherwise, no change (test is same as set_NC_string)*/
if(varp->name->nchars < strlen(newname))
{status = NC_ENOTINDEFINE; goto done;}
/* WARNING: strlen(NC_string.cp) may be less than NC_string.nchars */
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveVar(&ncp->vars, old->cp);
NC_hashmapremove(ncp->vars.hashmap,old->cp,strlen(old->cp),NULL);
/* WARNING: strlen(NC_string.cp) may be less than NC_string.nchars */
status = set_NC_string(varp->name, newname);
free(newname);
if(status != NC_NOERR)
return status;
goto done;
NC_hashmapAddVar(&ncp->vars, varid, varp->name->cp);
intdata = (uintptr_t)varid;
NC_hashmapadd(ncp->vars.hashmap, intdata, varp->name->cp, strlen(varp->name->cp));
set_NC_hdirty(ncp);
@ -808,10 +805,11 @@ NC3_rename_var(int ncid, int varid, const char *unewname)
{
status = NC_sync(ncp);
if(status != NC_NOERR)
return status;
goto done;
}
return NC_NOERR;
done:
if(newname) free(newname);
return status;
}
int

View File

@ -4226,7 +4226,7 @@ reportobject(int log, hid_t id, unsigned int type)
LOG((0,"Type = %s(%8" PRId64 ") name='%s'",typename,id,name));
#endif
} else {
fprintf(stderr,"Type = %s(%8" PRId64 ") name='%s'",typename,id,name);
fprintf(stderr,"Type = %s(%lld) name='%s'",typename,(long long)id,name);
}
}
@ -4250,10 +4250,10 @@ reportopenobjectsT(int log, hid_t fid, int ntypes, unsigned int* otypes)
if(log) {
#ifdef LOGGING
LOG((0,"\nReport: open objects on %" PRId64 "\n",fid));
LOG((0,"\nReport: open objects on %lld\n",(long long)fid));
#endif
} else {
fprintf(stdout,"\nReport: open objects on %" PRId64 "\n",fid);
fprintf(stdout,"\nReport: open objects on %lld\n",(long long)fid);
}
maxobjs = H5Fget_obj_count(fid,H5F_OBJ_ALL);
if(idlist != NULL) free(idlist);

View File

@ -1,12 +1,12 @@
# Test c output
T=tst_addvar
T=tst_diskless2
ARGS=test_pnetcdf.nc
ARGS=netcdf4
#CMD=valgrind --leak-check=full
CMD=gdb --args
CMD=export NETCDF_LOG_LEVEL=5 ;gdb --args
PAR=1
#PAR=1
CFLAGS=-Wall -Wno-unused-variable -Wno-unused-function -g -O -I.. -I../include

View File

@ -18,10 +18,6 @@
#endif
#include "error.h"
#ifndef HAVE_SSIZE_T
typedef int ssize_t;
#endif
#if defined(_CRAY) && !defined(_CRAYIEEE) && !defined(__crayx1)
#define CRAYFLOAT 1 /* CRAY Floating point */
#elif defined(_SX) && defined(_FLOAT2) /* NEC SUPER-UX in CRAY mode */

View File

@ -14,6 +14,16 @@ redistribution conditions.
#include <stdlib.h>
#include <netcdf.h>
/*
netcdf tst_diskless {
variables:
int resistor_value;
float capacitor_value;
short number_of_555_timer_chips;
}
*/
#define FLAGS4 (NC_DISKLESS|NC_NETCDF4|NC_CLASSIC_MODEL)
#define FLAGS3 (NC_DISKLESS)

View File

@ -72,7 +72,7 @@ IF(BUILD_BENCHMARKS)
ENDIF()
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/ref_bzip2.c ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.hdf4 ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl)
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/ref_bzip2.c ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.h5 ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
IF(MSVC)
FILE(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
@ -83,20 +83,6 @@ FOREACH(CTEST ${NC4_TESTS})
add_bin_test(nc_test4 ${CTEST})
ENDFOREACH()
# This must go after the 'foreach' stanza
# immediately above this comment.
IF(USE_HDF4_FILE_TESTS AND NOT MSVC)
add_bin_test_no_prefix(tst_interops2)
build_bin_test_no_prefix(tst_interops3)
add_sh_test(nc_test4 run_get_hdf4_files)
add_sh_test(nc_test4 tst_formatx_hdf4)
build_bin_test(tst_chunk_hdf4)
add_sh_test(nc_test4 run_chunk_hdf4)
add_bin_test(nc_test4 tst_h4_lendian)
add_sh_test(nc_test4 tst_hdf4_read_var)
SET_TESTS_PROPERTIES(nc_test4_tst_hdf4_read_var PROPERTIES DEPENDS tst_interops2)
ENDIF()
IF(TEST_PARALLEL4)
build_bin_test(tst_mpi_parallel)
build_bin_test(tst_parallel)

View File

@ -95,26 +95,6 @@ benchmarks: check
./run_bm_ar4.sh
endif # BUILD_BENCHMARKS
# These are the tests for HDF4.
if USE_HDF4
check_PROGRAMS += tst_interops2 tst_chunk_hdf4 tst_h4_lendian
if BUILD_UTILITIES
# This test script depends on ncdump.
TESTS += tst_interops2 tst_formatx_hdf4.sh
tst_formatx_hdf4.log: tst_interops2.log
endif # BUILD_UTILITIES
TESTS += run_chunk_hdf4.sh tst_h4_lendian
if USE_HDF4_FILE_TESTS
check_PROGRAMS += tst_interops3
TESTS += run_get_hdf4_files.sh tst_hdf4_read_var.sh
tst_hdf4_read_var.log: tst_interops2.log
endif # USE_HDF4_FILE_TESTS
endif # USE_HDF4
# Szip Tests (requires ncdump)
if USE_SZIP
if BUILD_UTILITIES
@ -143,17 +123,15 @@ EXTRA_DIST = run_par_test.sh run_bm.sh run_bm_test1.sh \
run_bm_test2.sh run_bm_radar_2D.sh run_bm_radar_2D_compression1.sh \
run_par_bm_test.sh run_bm_elena.sh run_par_bm_radar_2D.sh \
run_bm_radar_2D_endianness1.sh run_tst_chunks.sh ref_chunks1.cdl \
ref_chunks2.cdl run_get_hdf4_files.sh run_bm_ar4.sh \
ref_tst_compounds.nc ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc \
ref_tst_dims.nc ref_tst_interops4.nc run_get_knmi_files.sh \
CMakeLists.txt run_grp_rename.sh tst_formatx_hdf4.sh \
run_chunk_hdf4.sh tst_h5_endians.c tst_h4_lendian.c \
tst_atts_string_rewrite.c tst_put_vars_two_unlim_dim.c \
tst_empty_vlen_unlim.c run_empty_vlen_test.sh ref_hdf5_compat1.nc \
ref_hdf5_compat2.nc ref_hdf5_compat3.nc tst_misc.sh tdset.h5 \
tst_hdf4_read_var.sh ref_contiguous.hdf4 ref_chunked.hdf4 tst_szip.sh \
ref_szip.h5 ref_szip.cdl tst_filter.sh bzip2.cdl filtered.cdl \
unfiltered.cdl ref_bzip2.c findplugin.in
ref_chunks2.cdl run_bm_ar4.sh ref_tst_compounds.nc \
ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc ref_tst_dims.nc \
ref_tst_interops4.nc run_get_knmi_files.sh CMakeLists.txt \
run_grp_rename.sh tst_h5_endians.c tst_atts_string_rewrite.c \
tst_put_vars_two_unlim_dim.c tst_empty_vlen_unlim.c \
run_empty_vlen_test.sh ref_hdf5_compat1.nc ref_hdf5_compat2.nc \
ref_hdf5_compat3.nc tst_misc.sh tdset.h5 tst_szip.sh ref_szip.h5 \
ref_szip.cdl tst_filter.sh bzip2.cdl filtered.cdl unfiltered.cdl \
ref_bzip2.c findplugin.in
CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \
bm_radar.nc bm_radar1.nc radar_3d_compression_test.txt \
@ -171,12 +149,4 @@ szip_dump.cdl
DISTCLEANFILES = findplugin.sh
if USE_HDF4_FILE_TESTS
DISTCLEANFILES += AMSR_E_L2_Rain_V10_200905312326_A.hdf \
AMSR_E_L3_DailyLand_V06_20020619.hdf \
MYD29.A2009152.0000.005.2009153124331.hdf \
MYD29.A2002185.0000.005.2007160150627.hdf \
MOD29.A2000055.0005.005.2006267200024.hdf
endif # HDF4_FILE_TESTS
SUBDIRS=hdf5plugins

View File

@ -18,9 +18,9 @@ DLLSRC=${PLUGINSRC} ${BZIP2SRC} ${PLUGINHDRS} ${BZIP2HDRS}
lib_LTLIBRARIES = libbzip2.la libmisc.la
libbzip2_la_SOURCES = ${DLLSRC}
libbzip2_la_LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined
libbzip2_la_LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined -rpath ${abs_builddir}
libmisc_la_SOURCES = H5Zmisc.c h5misc.h
libmisc_la_LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined
libmisc_la_LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined -rpath ${abs_builddir}
endif #ENABLE_FILTER_TESTING

View File

@ -1,26 +0,0 @@
#!/bin/sh
# Run test_chunk_hdf4 passing ${srcdir}
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
echo ""
echo "*** Testing hdf4 chunking..."
if test "x${srcdir}" = "x" ; then
srcdir="."
fi
if ./tst_chunk_hdf4 ; then
echo "***SUCCESS!! tst_chunk_hdf4"
else
RES=$?
echo "***FAIL: tst_chunk_hdf4"
exit $RES
fi
exit 0

View File

@ -11,6 +11,8 @@
#include <hdf5.h>
#include "netcdf.h"
#undef DEBUG
/* The C standard apparently defines all floating point constants as double;
we rely on that in this code.
*/
@ -443,8 +445,10 @@ init(int argc, char** argv)
int
main(int argc, char **argv)
{
#ifdef DEBUG
H5Eprint(stderr);
nc_set_log_level(1);
#endif
init(argc,argv);
if(!test_test1()) ERRR;
exit(nerrs > 0?1:0);

View File

@ -73,7 +73,6 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing netCDF-4 attributes.\n");
nc_set_log_level(3);
printf("*** testing attribute renaming for read-only file...");
{
int ncid;

View File

@ -14,7 +14,6 @@
int
main(int argc, char **argv)
{
nc_set_log_level(0);
printf("\n*** Testing netcdf-4 dimensions even more.\n");
printf("*** testing netcdf-4 dimension inheritance...");
{

View File

@ -55,11 +55,11 @@ if ! test -f ${MISCPATH} ; then echo "Unable to locate ${MISCPATH}"; exit 1; fi
if test "x$API" = x1 ; then
echo "*** Testing dynamic filters using API"
rm -f ./bzip2.nc ./bzip2.dump ./tmp_tst_filter
rm -f ./bzip2.nc ./bzip2.dump ./tst_filter.txt
${execdir}/test_filter
${NCDUMP} -s bzip2.nc > ./tmp_tst_filter
${NCDUMP} -s bzip2.nc > ./tst_filter.txt
# Remove irrelevant -s output
sclean ./tmp_tst_filter ./bzip2.dump
sclean ./tst_filter.txt ./bzip2.dump
diff -b -w ${srcdir}/bzip2.cdl ./bzip2.dump
echo "*** Pass: API dynamic filter"
fi
@ -67,61 +67,88 @@ fi
if test "x$MISC" = x1 ; then
echo
echo "*** Testing dynamic filters parameter passing"
rm -f ./testmisc.nc tmp_tst_filter tmp_tst_filter2
rm -f ./testmisc.nc tst_filter.txt tst_filter2.txt
${execdir}/test_filter_misc
# Verify the parameters via ncdump
${NCDUMP} -s testmisc.nc > ./tmp_tst_filter
${NCDUMP} -s testmisc.nc > ./tst_filter.txt
# Extract the parameters
getfilterattr ./tmp_tst_filter ./tmp_tst_filter2
rm -f ./tmp_tst_filter
trimleft ./tmp_tst_filter2 ./tmp_tst_filter
rm -f ./tmp_tst_filter2
cat >./tmp_tst_filter2 <<EOF
getfilterattr ./tst_filter.txt ./tst_filter2.txt
rm -f ./tst_filter.txt
trimleft ./tst_filter2.txt ./tst_filter.txt
rm -f ./tst_filter2.txt
cat >./tst_filter2.txt <<EOF
var:_Filter = "32768,1,239,23,65511,27,77,93,1145389056,3287505826,1097305129,1,2147483648,4294967295,4294967295" ;
EOF
diff -b -w ./tmp_tst_filter ./tmp_tst_filter2
diff -b -w ./tst_filter.txt ./tst_filter2.txt
echo "*** Pass: parameter passing"
fi
if test "x$NG" = x1 ; then
echo "*** Testing dynamic filters using ncgen"
rm -f ./bzip2.nc ./bzip2.dump ./tmp_tst_filter
rm -f ./bzip2.nc ./bzip2.dump ./tst_filter.txt
${NCGEN} -lb -4 -o bzip2.nc ${srcdir}/bzip2.cdl
${NCDUMP} -s bzip2.nc > ./tmp_tst_filter
${NCDUMP} -s bzip2.nc > ./tst_filter.txt
# Remove irrelevant -s output
sclean ./tmp_tst_filter ./bzip2.dump
sclean ./tst_filter.txt ./bzip2.dump
diff -b -w ${srcdir}/bzip2.cdl ./bzip2.dump
echo "*** Pass: ncgen dynamic filter"
fi
if test "x$NCP" = x1 ; then
echo "*** Testing dynamic filters using nccopy"
rm -f ./unfiltered.nc ./filtered.nc ./filtered.dump ./tmp_tst_filter
rm -f ./unfiltered.nc ./filtered.nc ./tmp.nc ./filtered.dump ./tst_filter.txt
${NCGEN} -4 -lb -o unfiltered.nc ${srcdir}/unfiltered.cdl
echo " *** Testing simple filter application"
${NCCOPY} -F "/g/var,307,9,4" unfiltered.nc filtered.nc
${NCDUMP} -s filtered.nc > ./tmp_tst_filter
${NCDUMP} -s filtered.nc > ./tst_filter.txt
# Remove irrelevant -s output
sclean ./tmp_tst_filter ./filtered.dump
sclean ./tst_filter.txt ./filtered.dump
diff -b -w ${srcdir}/filtered.cdl ./filtered.dump
echo "*** Pass: nccopy dynamic filter"
echo " *** Pass: nccopy simple filter"
echo " *** Testing pass-thru of filters"
rm -f ./tst_filter.txt tst_filter2.txt ./tst_filter2.nc
${NCCOPY} ./filtered.nc ./tst_filter2.nc
${NCDUMP} -s tst_filter2.nc > ./tst_filter.txt
sed -e '/_Filter/p' -e d < ./tst_filter.txt >tst_filter2.txt
test -s tst_filter2.txt
echo " *** Pass: pass-thru of filters"
echo " *** Testing -F none"
rm -f ./tst_filter.txt ./tst_filter2.txt ./tst_filter.nc
${NCCOPY} -F none ./filtered.nc ./tst_filter.nc
${NCDUMP} -s tst_filter.nc > ./tst_filter.txt
sed -e '/_Filter/p' -e d < ./tst_filter.txt >./tst_filter2.txt
test ! -s tst_filter2.txt
echo " *** Pass: -F none"
echo " *** Testing -F var,none "
rm -f ./tst_filter.txt ./tst_filter.nc
${NCCOPY} -F "/g/var,none" ./filtered.nc ./tst_filter.nc
${NCDUMP} -s tst_filter.nc > ./tst_filter.txt
sed -e '/_Filter/p' -e d < ./tst_filter.txt >tst_filter2.txt
test ! -s tst_filter2.txt
echo " *** Pass: -F var,none"
echo "*** Pass: all nccopy filter tests"
fi
if test "x$UNK" = x1 ; then
echo "*** Testing access to filter info when filter dll is not available"
rm -f bzip2.nc ./tmp_tst_filter
rm -f bzip2.nc ./tst_filter.txt
# build bzip2.nc
${NCGEN} -lb -4 -o bzip2.nc ${srcdir}/bzip2.cdl
# dump and clean bzip2.nc header only when filter is avail
${NCDUMP} -hs bzip2.nc > ./tmp_tst_filter
${NCDUMP} -hs bzip2.nc > ./tst_filter.txt
# Remove irrelevant -s output
sclean ./tmp_tst_filter bzip2.dump
sclean ./tst_filter.txt bzip2.dump
# Now hide the filter code
mv ${BZIP2PATH} ${BZIP2PATH}.save
# dump and clean bzip2.nc header only when filter is not avail
rm -f ./tmp_tst_filter
${NCDUMP} -hs bzip2.nc > ./tmp_tst_filter
rm -f ./tst_filter.txt
${NCDUMP} -hs bzip2.nc > ./tst_filter.txt
# Remove irrelevant -s output
sclean ./tmp_tst_filter bzip2x.dump
sclean ./tst_filter.txt bzip2x.dump
# Restore the filter code
mv ${BZIP2PATH}.save ${BZIP2PATH}
diff -b -w ./bzip2.dump ./bzip2x.dump
@ -137,10 +164,10 @@ echo "*** Pass: ncgen dynamic filter"
fi
#cleanup
rm -f ./bzip*.nc ./unfiltered.nc ./filtered.nc ./tmp_tst_filter ./tmp_tst_filter2 *.dump bzip*hdr.*
rm -fr ./test_bzip2.c
rm -fr ./testmisc.nc
rm -f ./bzip*.nc ./unfiltered.nc ./filtered.nc ./tst_filter.txt ./tst_filter2.txt *.dump bzip*hdr.*
rm -f ./test_bzip2.c
rm -f ./testmisc.nc
rm -f ./tst_filter2.nc
echo "*** Pass: all selected tests passed"
exit 0

View File

@ -63,8 +63,8 @@ mismatch(size_t i, unsigned int *params, const char* tag)
static void
mismatch2(size_t i, unsigned int *params, const char* tag)
{
fprintf(stderr,"mismatch2: %s [%d-%ld] baseline=%ud,%ud params=%u,%u\n",
tag,(int)i,i+1,baseline[i],baseline[i+1],params[i],params[i+1]);
fprintf(stderr,"mismatch2: %s [%ld-%ld] baseline=%ud,%ud params=%u,%u\n",
tag,(long)i,(long)(i+1),baseline[i],baseline[i+1],params[i],params[i+1]);
fflush(stderr);
nerrs++;
}

View File

@ -1,32 +0,0 @@
#!/bin/sh
# This shell script tests the output several previous tests.
# Ed Hartnett
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
FILE=tst_interops2.h4
ECODE=0
echo ""
echo "*** Testing extended file format output."
set -e
echo "Creating HDF4 file"
${execdir}/tst_interops2
echo "Test extended format output for a HDF4 file"
rm -f tmp_tst_formatx_hdf4
${NCDUMP} -K $FILE >tmp_tst_formatx_hdf4
if ! fgrep 'HDF4 mode=00001000' <tmp_tst_formatx_hdf4 ; then
TMP=`cat tmp_tst_formatx_hdf4`
echo "*** Fail: extended format for an HDF4 file: result=" $TMP
ECODE=1
fi
rm -f tmp_tst_formatx_hdf4
exit $ECODE

View File

@ -1,27 +0,0 @@
#!/bin/bash
# This shell script tests that an hdf4 file can be read a
# variable at a time.
#
# this was added in support of https://github.com/Unidata/netcdf-c/issues/264
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
FILE=tst_interops2.h4
set -e
echo ""
echo "*** Testing reading an individual variable from an HDF4 file."
${NCDUMP} -v hdf4_dataset_type_0 $FILE
${NCDUMP} -v hdf4_dataset_type_1 $FILE
${NCDUMP} -v hdf4_dataset_type_2 $FILE
${NCDUMP} -v hdf4_dataset_type_3 $FILE
${NCDUMP} -v hdf4_dataset_type_4 $FILE
${NCDUMP} -v hdf4_dataset_type_5 $FILE
${NCDUMP} -v hdf4_dataset_type_6 $FILE
${NCDUMP} -v hdf4_dataset_type_7 $FILE
echo "*** Success."

View File

@ -178,7 +178,10 @@ main(int argc, char **argv)
fprintf(stderr,"*** Test Charlie's test for renaming with one enddef...");
{
int ncid, dimid, varid;
#ifdef DEBUG
nc_set_log_level(5);
#endif
/* Create a nice, simple file. This file will contain one
* dataset, "lon", which is a dimscale. */

View File

@ -31,6 +31,11 @@ IF(ENABLE_TESTS)
add_sh_test(ncdap tst_ber)
add_sh_test(ncdap tst_remote3)
# not yet add_sh_test(ncdap tst_hyrax)
IF(ENABLE_DAP_LONG_TESTS)
add_sh_test(ncdap tst_longremote3)
ENDIF(ENABLE_DAP_LONG_TESTS)
ENDIF(BUILD_UTILITIES)
IF(ENABLE_DAP_AUTH_TESTS)

View File

@ -81,11 +81,11 @@ SUBDIRS = testdata3 expected3 expectremote3
EXTRA_DIST = tst_ncdap3.sh \
tst_remote3.sh \
tst_longremote3.sh \
tst_ncdap.sh tst_ncdap_shared.sh tst_remote.sh \
tst_filelists.sh tst_urls.sh tst_utils.sh \
t_dap.c CMakeLists.txt tst_formatx.sh testauth.sh testurl.sh \
t_ncf330.c tst_ber.sh
CLEANFILES = test_varm3 test_cvt3 results/*.dmp results/*.das results/*.dds datadds* t_dap3a test_nstride_cached *.exe
CLEANFILES = test_varm3 test_cvt3 file_results/* remote_results/* datadds* t_dap3a test_nstride_cached *.exe
# This should only be left behind if using parallel io
CLEANFILES += tmp_*

View File

@ -149,7 +149,7 @@ main()
#ifdef VERBOSE
for (idim=0; idim<ndim; idim++)
printf("start[%1d]=%3lu count[%1d]=%3lu stride[%1d]=%3lu\n",
idim,start[idim],idim,count[idim],idim,stride[idim]);
idim,(unsigned long)start[idim],idim,(unsigned long)count[idim],idim,(unsigned long)stride[idim]);
#endif
ncstatus = nc_get_vars_float (ncid, varid, start, count, stride, (float*) dat);
@ -199,7 +199,7 @@ main()
#ifdef VERBOSE
for (idim=0; idim<ndim; idim++)
printf("start[%d]=%3lu count[%d]=%3lu stride[%d]=%3lu\n",
idim, start[idim], idim, count[idim], idim, stride[idim]);
idim, (unsigned long)start[idim], idim, (unsigned long)count[idim], idim, (unsigned long)stride[idim]);
#endif
ncstatus = nc_get_vars_float (ncid, varid, start, count, stride, (float*) dat);
@ -256,7 +256,7 @@ main()
#ifdef VERBOSE
for (idim=0; idim<ndim; idim++)
printf("start[%1d]=%3lu count[%1d]=%3lu stride[%1d]=%3lu\n",
idim,start[idim],idim,count[idim],idim,stride[idim]);
idim,(unsigned long)start[idim],idim,(unsigned long)count[idim],idim,(unsigned long)stride[idim]);
#endif
memset((void*)sdat,0,sizeof(sdat));

View File

@ -0,0 +1,50 @@
##################################################
# Local test files
##################################################
# This is not a standalone script; it is invoked by
# one or more of the main scripts
# Synth8 and Synth9 still fail
SYNTHETICDATA="synth1 synth2 synth3 synth4 synth5 synth6 synth7 synth10"
SOURCEFILES=\
"1990-S1700101.HDF.WVC_Lat 1998-6-avhrr.dat \
b31a b31 D1 Drifters \
EOSDB ingrid nestedDAS NestedSeq2 \
NestedSeq OverideExample pbug0001b SimpleDrdsExample \
test.01 test.02 test.03 test.04 \
test.05 test.06a test.07a \
test.07 test.21 test.22 \
test.23 test.31 \
test.50 test.53 test.55 \
test.56 test.57 \
test.66 test.67 test.68 test.69 \
test.an1 \
test.dfp1 test.dfr1 test.dfr2 test.dfr3 \
test.gr1 test.gr2 test.gr3 test.gr4 \
test.gr5 test.PointFile test.sds1 \
test.sds2 test.sds3 test.sds4 test.sds5 \
test.sds6 test.sds7 test.vs1 \
test.vs2 test.vs3 test.vs4 test.vs5 whoi \
123bears.nc 123.nc bears.nc \
ceopL2AIRS2-2.nc \
data.nc fnoc1.nc \
in1.nc in_2.nc in.nc \
in_no_three_double_dmn.nc in_v.nc saco1.nc \
test.nc text.nc \
ber-2002-10-01.nc \
kwcase.nc"
# XFAIL tests should be a subset of the other tests; this is used
# only to detect which are considered XFAIL tests.
XFAILTESTS=
# For now, remove some tests from windows platform.
#if test "x$platform" != xmingw ; then
XFAILTESTS="$XFAILTESTS EOSDB OverideExample SimpleDrdsExample test.67 test.gr5 123bears.nc 123.nc bears.nc ber-2002-10-01 data.nc in1.nc in_2.nc in_no_three_double_dmn.nc test.nc text.nc test.22 test.23 test.gr1 in.nc ber-2002-10-01.nc kwcase.nc"
#fi
FILETESTS="${SYNTHETICDATA} ${SOURCEFILES}"
#DDSTESTS intersect FILETESTS should be empty
DDSTESTS=

View File

@ -1,30 +1,4 @@
#!/bin/sh
# if this is part of a distcheck action, then this script
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
topsrcdir=`./test_environment topsrcdir`
if test "x$topsrcdir" != x ; then
srcdir="$topsrcdir/ncdap_test"
else
srcdir=`dirname $0`
fi
cd $srcdir
srcdir=`pwd`
# Hack for CYGWIN
cd $srcdir
if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then
srcdir=`pwd | sed 's/\/c\//c:\//g'`
builddir="$srcdir"/..
fi
# compute the build directory
builddir=`pwd`/..
cd ${builddir}/ncdap_test
sh ${srcdir}/tst_remote.sh "$srcdir" "$builddir" "3" "" "long"
exit
export longtests=1
bash ${srcdir}/tst_remote3.sh

View File

@ -1,13 +1,48 @@
#!/bin/sh
if test "x$SETX" = x1 ; then set -x ; fi
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
#X="-x"
#grind="checkleaks"
. ${srcdir}/tst_utils.sh
exec sh $X ${srcdir}/tst_ncdap.sh "$srcdir" "$builddir" "file" $grind
#exec sh $X ${srcdir}/tst_ncdap.sh "$srcdir" "$builddir" "dds" $grind
# get the list of test files
. ${srcdir}/tst_filelists.sh
# Test executor
dotests() {
for x in ${FILETESTS} ; do
url="${PARAMS}${FILEURL}/$x"
if test "x$quiet" = "x0" ; then echo "*** Testing: ${x} ; url=$url" ; fi
# determine if this is an xfailtest
isxfail=0
if test "x${XFAILTESTS}" != x ; then
if IGNORE=`echo -n " ${XFAILTESTS} " | fgrep " ${x} "`; then isxfail=1; fi
fi
ok=1
if ${NCDUMP} ${FLAGS} "${url}" | sed 's/\\r//g' > ${x}.dmp ; then ok=$ok; else ok=0; fi
# compare with expected
if diff -w ${EXPECTED}/${x}.dmp ${x}.dmp ; then ok=$ok; else ok=0; fi
processstatus
done
}
TITLE="DAP to netCDF-3 translation using files"
EXPECTED="$expected3"
RESULTSDIR="file_results"
rm -fr ${RESULTSDIR}
mkdir "${RESULTSDIR}"
echo "*** Testing $TITLE "
echo " Base URL: ${TESTURL}"
echo " Client Parameters: ${PARAMS}"
cd ${RESULTSDIR}
dotests file
cd ..
summarize
cleanup
doexit

View File

@ -1,9 +1,46 @@
#!/bin/sh
#!/bin/bash
if test "x$SETX" = x1 ; then set -x ; fi
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
sh ${srcdir}/tst_remote.sh "$srcdir" "$builddir" "3" "" ""
exit
. ${srcdir}/tst_utils.sh
# get the list of test url targets
. ${srcdir}/tst_urls.sh
PARAMS="${PARAMS}[netcdf3]"
# Choose tests to run
if test "x$longtests" != x; then
WHICHTESTS="L1 LC1 LC2"
else # Standard test set
WHICHTESTS="S1 C1"
fi
TITLE="DAP to netCDF-3 translation using remote server"
EXPECTED="$expected3"
RESULTSDIR="remote_results"
rm -fr ${RESULTSDIR}
mkdir "${RESULTSDIR}"
echo "*** Testing $TITLE "
echo " Base URL: ${DTS}"
echo " Client Parameters: ${PARAMS}"
if test "$cache" = 0; then echo " Caching: off"; else echo " Caching: on"; fi
echo " Note: The remote tests may be slow or even fail if the server is overloaded"
cd ${RESULTSDIR}
for i in $WHICHTESTS ; do
computewhich $i
doremotetests remote
done
cd ..
summarize
cleanup
doexit

165
ncdap_test/tst_urls.sh Normal file
View File

@ -0,0 +1,165 @@
##################################################
# Remote test info
##################################################
# This is not a standalone script; it is invoked by
# one or more of the main scripts
# Define various sets of test targets
# Figure our dst server; if none, then just stop
DTS=`${execdir}/findtestserver dap2 dts`
if test "x$DTS" = "x" ; then
echo "WARNING: Cannot locate test server for dts"
exit 1
fi
if test "x$timing" = "x1" ; then TIMECMD="time"; else TIMECMD=""; fi
expected3="${srcdir}/expectremote3"
# For special testing
X="test.03"
XC="test.03;1;s0,s1"
# Set to run a specific test
S0="test.07"
# These shorter tests are always run
S1="\
test.01 test.02 test.04 test.05 test.07a test.07 \
test.21 \
test.50 test.53 test.55 test.56 test.57 \
test.66 test.67 test.68 test.69"
# Server is failing on some tests ; investigate why
S1FAIL="test.06a test.22 test.23 test.31"
# This fails because of the duplicate name problem and the way thredds dap handles grids"
S2FAIL="test.06"
# These longer tests are optional
SL1="\
test.03 \
b31 b31a D1 Drifters EOSDB \
ingrid nestedDAS NestedSeq NestedSeq2 OverideExample \
SimpleDrdsExample test.an1 \
test.dfp1 test.gr1 \
test.gr2 test.gr3 test.gr4 test.gr5 \
test.sds1 test.sds2 test.sds3 \
test.sds4 test.sds5 \
test.vs1 test.vs2 test.vs3 test.vs4 test.vs5 \
whoi"
# Anything larger than about 100k will not be in the distribution
TOOBIGL1="parserBug0001 test.satimage Sat_Images test.32"
# Following contain %XX escapes which I cannot handle yet
ESCAPEDFAIL="test.dfr1 test.dfr2 test.dfr3 test.GridFile test.PointFile test.SwathFile test.sds6 test.sds7"
# Following tests are to check constraint handling
C1="\
test.01;1;f64 \
test.02;1;b[1:2:10] \
test.03;1;i32[0:1][1:2][0:2] \
test.04;1;types.i32 \
test.05;1;types.floats.f32 \
test.07;1;person.age \
test.07;3;person \
test.07;4;types.f32"
# See S2FAIL above
SR1FAIL="test.06;1;ThreeD"
# Constrained long tests
LC1="test.03;2;s1"
# Unknown problem: test.07;2;&age>2
IGNORE="test.07.2"
# Columbia hack test Not sure if operative
COLUMBIA="http://iridl.ldeo.columbia.edu/SOURCES/.Models/.NMME/.NASA-GMAO/.MONTHLY/.sst"
# Known to fail
XFAILTESTS=
# Supress some tests if not windows platform.
if test "x$platform" == xmingw ; then
XFAILTESTS="$XFAILTESTS test.67"
fi
# Following tests must be run as not cached
NOCACHETESTS="test.07"
# Following tests must be run as not prefetch
NOPREFETCHTESTS="test.07"
computewhich() { # set REMOTETESTS and constrained
case "$1" in
S0) REMOTETESTS="$S0" ; constrained=0 ;;
S1) REMOTETESTS="$S1" ; constrained=0 ;;
S2) REMOTETESTS="$S2" ; constrained=0 ;;
L1) REMOTETESTS="$L1" ; constrained=0 ;;
L2) REMOTETESTS="$L2" ; constrained=0 ;;
C1) REMOTETESTS="$C1" ; constrained=1 ;;
C2) REMOTETESTS="$C2" ; constrained=1 ;;
C3) REMOTETESTS="$C3" ; constrained=1 ;;
LC1) REMOTETESTS="$LC1" ; constrained=1 ;;
LC2) REMOTETESTS="$LC2" ; constrained=1 ;;
X) REMOTETESTS="$X" ; constrained=0 ;;
XC) REMOTETESTS="$XC" ; constrained=1 ;;
*) echo "Unknown which test: $1" ; exit 1;;
esac
}
constrain() {
T="$1;;" # add semicolons to fake out the cut command
# see if we are using constraints will set testname and ce and testno and contrained
testname=`echo -n $T | cut "-d;" -f1`
testno=`echo -n $T | cut "-d;" -f2`
ce=`echo -n $T | cut "-d;" -f3`
if test "x$ce" = x ; then constrained=0; else constrained=1; fi
}
setcache() {
CACHE="[cache]"
if test "x${NOCACHETESTS}" != x ; then
if IGNORE=`echo -n " ${NOCACHETESTS} " | fgrep " $1 "`; then CACHE=; fi
fi
PARAMS="${PARAMS}${CACHE}"
}
setprefetch() {
PREFETCH="[prefetch]"
if test "x${NOPREFETCHTESTS}" != x ; then
if IGNORE=`echo -n " ${NOPREFETCHTESTS} " | fgrep " $1 "`; then PREFETCH=; fi
fi
PARAMS="${PARAMS}${PREFETCH}"
}
# Use specialized test executor
doremotetests() {
for x in ${REMOTETESTS} ; do
PARAMS=
setcache $x
setprefetch $x
constrain $x
if test "x$constrained" = "x1" ; then
name="${testname}.${testno}"
url="${PARAMS}${DTS}/$testname?${ce}"
else
name="${testname}"
url="${PARAMS}${DTS}/$testname"
fi
if test "x$quiet" = "x0" ; then echo "*** Testing: ${name} ; url=$url" ; fi
# determine if this is an xfailtest
isxfail=0
if test "x${XFAILTESTS}" != x ; then
if IGNORE=`echo -n " ${XFAILTESTS} " | fgrep " ${name} "`; then isxfail=1; fi
fi
ok=1
if ${NCDUMP} ${FLAGS} "${url}" | sed 's/\\r//g' > ${name}.dmp ; then ok=$ok; else ok=0; fi
# compare with expected
if diff -w ${EXPECTED}/${name}.dmp ${name}.dmp ; then ok=$ok; else ok=0; fi
processstatus
done
}

84
ncdap_test/tst_utils.sh Normal file
View File

@ -0,0 +1,84 @@
# This is not a standalone script; it is invoked by
# one or more of the main scripts
if test "x$SETX" = x1 ; then set -x ; fi
quiet=0
PARAMS="[log]"
#PARAMS="${PARAMS}[fetch=memory]"
#PARAMS="${PARAMS}[show=fetch]"
OCLOGFILE=/dev/null
# Locate directories
testdata3="${srcdir}/testdata3"
expected3="${srcdir}/expected3"
rm -f ./.dodsrc ./.ocrc ./.daprc
passcount=0
xfailcount=0
failcount=0
# Try to figure out our platform
myplatform=`uname -a | cut -d" " -f 1`
case "$myplatform" in
Darwin*) platform=osx ;;
MINGW*) platform=mingw ;;
CYGWIN*) platform=cygwin ;;
linux*) platform=linux ;;
Linux*) platform=linux ;;
*) platform=unknown ;;
esac
# How to access local files
FILEURL="file://${testdata3}"
processstatus() {
if test "$ok" = 1 ; then
status=0 # succeed
elif test "x$isxfail" = "x0" ; then
status=1 # fail
else
status=2 # xfail
fi
case "$status" in
0)
passcount=`expr $passcount + 1`
if test "x$quiet" = "x" ; then echo "*** SUCCEED: ${x}"; fi
;;
1)
failcount=`expr $failcount + 1`
echo "*** FAIL: ${x}"
;;
2)
xfailcount=`expr $xfailcount + 1`
echo "*** XFAIL : ${x}"
;;
esac
}
summarize() {
totalcount=`expr $passcount + $failcount + $xfailcount`
okcount=`expr $passcount + $xfailcount`
if test "$failcount" -gt 0 ; then
echo "*** FAILED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures"
else
echo "*** PASSED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures"
fi
}
cleanup() {
rm -fr ${RESULTSDIR}
}
doexit() {
if test "$failcount" -gt 0
then
exit 1
else
exit 0
fi
}

View File

@ -1,8 +1,8 @@
# Test c output
T=t
T=tst_special_atts
#ARGS=./x.nc
TF=test_atomic_array.cdl
#TF=test_atomic_array.cdl
#CMD=valgrind --leak-check=full
CMD=gdb --args
@ -33,7 +33,7 @@ endif
LLP=/usr/local/lib:${LD_LIBRARY_PATH}
all:: comp ./x.nc
all:: comp
export LD_LIBRARY_PATH=${LLP}; export CFLAGS; export LDFLAGS; \
${CMD} ./t ${ARGS}

View File

@ -4,6 +4,10 @@
# Ed Hartnett, Dennis Heimbigner, Ward Fisher
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#sh_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
LDADD = ${top_builddir}/liblib/libnetcdf.la

View File

@ -61,6 +61,7 @@ typedef struct VarID {
struct FilterSpec {
char* fqn;
int nofilter; /* 1=> do not apply any filters to this variable */
unsigned int filterid;
size_t nparams;
unsigned int* params;
@ -68,6 +69,7 @@ struct FilterSpec {
static int nfilterspecs = 0; /* Number of defined filter specs */
static struct FilterSpec filterspecs[MAX_FILTER_SPECS];
static int suppressfilters = 0; /* 1 => do not apply any output filters unless specified */
#endif
@ -83,9 +85,11 @@ static size_t option_chunk_cache_size = CHUNK_CACHE_SIZE; /* default from config
static size_t option_chunk_cache_nelems = CHUNK_CACHE_NELEMS; /* default from config.h */
static int option_read_diskless = 0; /* default, don't read input into memory on open */
static int option_write_diskless = 0; /* default, don't write output to diskless file */
#ifdef USE_NETCDF4
static int option_min_chunk_bytes = CHUNK_THRESHOLD; /* default, don't chunk variable if prod of
* chunksizes of its dimensions is smaller
* than this */
#endif
static int option_nlgrps = 0; /* Number of groups specified with -g
* option on command line */
static char** option_lgrps = 0; /* list of group names specified with -g
@ -242,6 +246,9 @@ parsefilterspec(const char* optarg0, struct FilterSpec* spec)
char* remainder = NULL;
if(optarg0 == NULL || strlen(optarg0) == 0 || spec == NULL) return 0;
memset(spec,0,sizeof(struct FilterSpec));
optarg = strdup(optarg0);
/* Collect the fqn, taking escapes into account */
@ -253,7 +260,8 @@ parsefilterspec(const char* optarg0, struct FilterSpec* spec)
else if(*p == '\0') {remainder = p; break;}
/* else continue */
}
if(strlen(optarg) == 0) return 0; /* fqn does not exist */
if(strlen(optarg) == 0) {stat = NC_EINVAL; goto done;} /* fqn does not exist */
/* Make sure leading '/' is in place */
if(optarg[0]=='/')
spec->fqn = strdup(optarg);
@ -263,6 +271,12 @@ parsefilterspec(const char* optarg0, struct FilterSpec* spec)
strcat(spec->fqn,optarg);
}
/* Check for special cases */
if(strcmp(remainder,"none") == 0) {
spec->nofilter = 1;
goto done;
}
/* Collect the id+parameters */
if((stat = NC_parsefilterspec(remainder,&id,&nparams,&params)) == NC_NOERR) {
if(spec != NULL) {
@ -271,6 +285,9 @@ parsefilterspec(const char* optarg0, struct FilterSpec* spec)
spec->params = params;
}
}
done:
if(optarg) free(optarg);
return stat;
}
@ -721,57 +738,101 @@ static int
copy_var_filter(int igrp, int varid, int ogrp, int o_varid)
{
int stat = NC_NOERR;
#ifdef USE_NETCDF4
VarID vid = {igrp,varid};
VarID ovid = {ogrp,o_varid};
/* handle filter parameters, copying from input, overriding with command-line options */
struct FilterSpec spec;
int i, found;
struct FilterSpec inspec, ospec, actualspec;
int i;
char* ofqn = NULL;
int format, oformat;
int inputdefined, outputdefined, unfiltered;
/* Get file format of the input and output */
if((stat=nc_inq_format(vid.grpid,&format))) goto done;
if((stat=nc_inq_format(ovid.grpid,&oformat))) goto done;
if(oformat != NC_FORMAT_NETCDF4 && oformat != NC_FORMAT_NETCDF4_CLASSIC)
goto done; /* Can only use filter when output is netcdf4 */
goto done; /* Can only use filter when output is some netcdf4 variant */
/* Compute the output vid's FQN */
if((stat = computeFQN(ovid,&ofqn))) goto done;
/* See if any filter spec is defined for this output variable */
for(found=0,i=0;i<nfilterspecs;i++) {
if(strcmp(filterspecs[i].fqn,ofqn)==0) {spec = filterspecs[i]; found = 1; break;}
}
if(!found) {
spec.filterid = 0; /* marker to indicate not filter to apply */
if((oformat == NC_FORMAT_NETCDF4
|| oformat != NC_FORMAT_NETCDF4_CLASSIC)
&& (format == NC_FORMAT_NETCDF4
|| format != NC_FORMAT_NETCDF4_CLASSIC)
) {
/* Only bother to look if both input and output are netcdf-4 */
if((stat=nc_inq_var_filter(vid.grpid,vid.varid,&spec.filterid,&spec.nparams,NULL)))
goto done;
if(spec.filterid > 0) {/* input has a filter */
spec.params = (unsigned int*)malloc(sizeof(unsigned int)*spec.nparams);
if((stat=nc_inq_var_filter(vid.grpid,vid.varid,&spec.filterid,&spec.nparams,spec.params)))
goto done;
/* Clear the in and out specs */
memset(&inspec,0,sizeof(inspec));
memset(&ospec,0,sizeof(ospec));
memset(&actualspec,0,sizeof(actualspec));
/* Is there a filter on the output variable */
outputdefined = 0; /* default is no filter defined */
/* Only bother to look if output is netcdf-4 variant */
if(oformat == NC_FORMAT_NETCDF4 || oformat == NC_FORMAT_NETCDF4_CLASSIC) {
/* See if any output filter spec is defined for this output variable */
for(i=0;i<nfilterspecs;i++) {
if(strcmp(filterspecs[i].fqn,ofqn)==0) {
ospec = filterspecs[i];
outputdefined = 1;
break;
}
}
}
/* Is there a filter on the input variable */
inputdefined = 0; /* default is no filter defined */
/* Only bother to look if input is netcdf-4 variant */
if(format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_NETCDF4_CLASSIC) {
stat=nc_inq_var_filter(vid.grpid,vid.varid,&inspec.filterid,&inspec.nparams,NULL);
if(stat && stat != NC_EFILTER)
goto done; /* true error */
if(stat == NC_NOERR) {/* input has a filter */
inspec.params = (unsigned int*)malloc(sizeof(unsigned int)*inspec.nparams);
if((stat=nc_inq_var_filter(vid.grpid,vid.varid,&inspec.filterid,&inspec.nparams,inspec.params)))
goto done;
inputdefined = 1;
}
}
/* Apply filter spec if any */
if(spec.filterid > 0) {/* Apply filter */
#ifdef USE_NETCDF4
if((stat=nc_def_var_filter(ovid.grpid,ovid.varid,spec.filterid,spec.nparams,spec.params)))
/* Rules for choosing output filter are as follows:
global output input Actual Output
suppress filter filter filter
-----------------------------------------------
true undefined NA unfiltered
true 'none' NA unfiltered
true defined NA use output filter
false undefined defined use input filter
false 'none' NA unfiltered
false defined NA use output filter
*/
unfiltered = 0;
if(suppressfilters && !outputdefined) /* row 1 */
unfiltered = 1;
else if(suppressfilters && outputdefined && ospec.nofilter) /* row 2 */
unfiltered = 1;
else if(suppressfilters && outputdefined) /* row 3 */
actualspec = ospec;
else if(!suppressfilters && !outputdefined && inputdefined) /* row 4 */
actualspec = inspec;
else if(!suppressfilters && outputdefined && ospec.nofilter) /* row 5 */
unfiltered = 1;
else if(!suppressfilters && outputdefined) /* row 6 */
actualspec = ospec;
/* Apply actual filter spec if any */
if(!unfiltered) {
if((stat=nc_def_var_filter(ovid.grpid,ovid.varid,
actualspec.filterid,
actualspec.nparams,
actualspec.params)))
goto done;
#endif
}
done:
/* Cleanup */
if(spec.filterid > 0 && spec.nparams > 0 && spec.params != NULL)
free(spec.params);
#endif /*USE_NETCDF4*/
if(ofqn != NULL) free(ofqn);
if(inspec.fqn) free(inspec.fqn);
if(inspec.params) free(inspec.params);
/* Note we do not clean actualspec because it is a copy of in|out spec */
return stat;
}
@ -1342,9 +1403,14 @@ copy_data(int igrp, int ogrp)
/* Count total number of dimensions in ncid and all its descendant subgroups */
int
count_dims(int ncid) {
#ifdef USE_NETCDF4
int numgrps;
#endif
int ndims;
NC_CHECK(nc_inq_ndims(ncid, &ndims));
#ifdef USE_NETCDF4
NC_CHECK(nc_inq_grps(ncid, &numgrps, NULL));
if(numgrps > 0) {
@ -1784,10 +1850,12 @@ usage(void)
int
main(int argc, char**argv)
{
int exitcode = EXIT_SUCCESS;
char* inputfile = NULL;
char* outputfile = NULL;
int c;
#ifdef USE_NETCDF4
int i;
struct FilterSpec filterspec;
#endif
@ -1970,14 +2038,20 @@ main(int argc, char**argv)
break;
case 'F': /* optional filter spec for a specified variable */
#ifdef USE_NETCDF4
if(parsefilterspec(optarg,&filterspec) != NC_NOERR)
usage();
if(nfilterspecs >= (MAX_FILTER_SPECS-1))
error("too many -F filterspecs\n");
filterspecs[nfilterspecs] = filterspec;
nfilterspecs++;
// Force output to be netcdf-4
option_kind = NC_FORMAT_NETCDF4;
/* If the arg is "none" then suppress all filters
on output unless explicit */
if(strcmp(optarg,"none")==0) {
suppressfilters = 1;
} else {
if(parsefilterspec(optarg,&filterspec) != NC_NOERR)
usage();
if(nfilterspecs >= (MAX_FILTER_SPECS-1))
error("too many -F filterspecs\n");
filterspecs[nfilterspecs] = filterspec;
nfilterspecs++;
// Force output to be netcdf-4
option_kind = NC_FORMAT_NETCDF4;
}
#else
error("-F requires netcdf-4");
#endif
@ -2001,7 +2075,7 @@ main(int argc, char**argv)
#ifdef USE_NETCDF4
#ifdef DEBUGFILTER
{ int i,j;
{ int j;
for(i=0;i<nfilterspecs;i++) {
struct FilterSpec *spec = &filterspecs[i];
fprintf(stderr,"filterspecs[%d]={fqn=|%s| filterid=%u nparams=%ld params=",
@ -2018,6 +2092,16 @@ main(int argc, char**argv)
#endif /*USE_NETCDF4*/
if(copy(inputfile, outputfile) != NC_NOERR)
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
exitcode = EXIT_FAILURE;
#ifdef USE_NETCDF4
/* Clean up */
for(i=0;i<nfilterspecs;i++) {
struct FilterSpec* spec = &filterspecs[i];
if(spec->fqn) free(spec->fqn);
if(spec->params) free(spec->params);
}
#endif /*USE_NETCDF4*/
exit(exitcode);
}

View File

@ -52,10 +52,6 @@ int optind;
#include "nc4internal.h" /* to get name of the special properties file */
#endif
#if !defined(HAVE_SSIZE_T) && !defined(H5_SIZEOF_SSIZE_T)
typedef int ssize_t;
#endif
#define XML_VERSION "1.0"
#define int64_t long long
@ -1723,17 +1719,27 @@ do_ncdump_rec(int ncid, const char *path)
* ambiguous. */
{
int dimid_test; /* to see if dimname is ambiguous */
int target_dimid; /* from variable dim list */
int locid; /* group id where dimension is defined */
/*Locate the innermost definition of a dimension with given name*/
NC_CHECK( nc_inq_dimid(ncid, dim_name, &dimid_test) );
/* Now, starting with current group, walk the parent chain
upward looking for the target dim_id */
target_dimid = var.dims[id];
locid = ncid;
while(var.dims[id] != dimid_test) { /* not in locid, try ancestors */
while(target_dimid != dimid_test) {/*not in locid, try ancestors*/
int parent_id;
NC_CHECK( nc_inq_grp_parent(locid, &parent_id) );
locid = parent_id;
/* Is dim of this name defined in this group or higher? */
NC_CHECK( nc_inq_dimid(locid, dim_name, &dimid_test) );
}
/* dimid is in group locid, prefix dimname with group name if needed */
if(locid != ncid) {
/* innermost dimid with given name is in group locid.
If this is not current group, then use fully qualified
name (fqn) for the dimension name by prefixing dimname
with group name */
if(locid != ncid) { /* We need to use fqn */
size_t len;
char *locname; /* the group name */
NC_CHECK( nc_inq_grpname_full(locid, &len, NULL) );

View File

@ -9,7 +9,6 @@ set -e
echo ""
echo "*** Testing ncgen and ncdump using some test CDL files."
echo "*** creating tst_small.nc from ref_tst_small.cdl..."
cat $srcdir/ref_tst_small.cdl
${NCGEN} -b -o tst_small.nc $srcdir/ref_tst_small.cdl
echo "*** creating tst_small.cdl from tst_small.nc..."
${NCDUMP} tst_small.nc > tst_small.cdl

View File

@ -25,6 +25,25 @@ Test _NCProperties and other special attributes
#define GROUPNAME "subgroup"
#define DIMNAME "time"
/*
Effective cdl:
netcdf nc4_fileinfo {
dimensions:
time = 4;
variables:
int :int_attr;
int int_var;
int int_var:int_attr;
char int_var:_NCProperties;
int time(time);
group subgroup: {
int :int_attr;
char :_NCProperties;
}
}
*/
int
main(int argc, char **argv)
{

View File

@ -8,13 +8,13 @@ echo ""
EXIT=0
NCF=$srcdir/nc4_fileinfo.nc
HDF=$srcdir/hdf5_fileinfo.hdf
NF=ref_tst_compounds4.nc
NCF=${srcdir}/ncdump/nc4_fileinfo.nc
HDF=${srcdir}/ncdump/hdf5_fileinfo.hdf
NF=${srcdir}/ncdump/ref_tst_compounds4.nc
# Do a false negative test
rm -f ./tmp_tst_fileinfo
if $NCDUMP -s $builddir/$NF | fgrep '_IsNetcdf4 = 0' > ./tmp_tst_fileinfo ; then
if $NCDUMP -s $NF | fgrep '_IsNetcdf4 = 0' > ./tmp_tst_fileinfo ; then
echo "Pass: False negative for file: $NF"
else
echo "FAIL: False negative for file: $NF"

View File

@ -14,8 +14,8 @@ export verbose
echo "*** Performing diff/cycle tests for classic format: k=1"
KFLAG=1 ; export KFLAG
bash -x ${srcdir}/tst_ncgen4_diff.sh
bash -x ${srcdir}/tst_ncgen4_cycle.sh
bash ${srcdir}/tst_ncgen4_diff.sh
bash ${srcdir}/tst_ncgen4_cycle.sh
echo "SUCCESS!!"
exit 0

View File

@ -20,84 +20,50 @@ echo "*** Running extra netcdf-4 tests."
# Short term solution, use sed when on windows/MSYS to
# remove the './','../../ncdump'.
#
# I am undoing this because libdispatch/dwinpath.c
# should be taking care of this. If not, then that is
# what we need to fix. Alternatively, we can use top_srcdir,
# which is an absolute path
echo "*** running tst_string_data to create test files..."
${execdir}/tst_string_data
if [ `uname | cut -d "_" -f 1` = "MINGW32" ]; then # MINGW Platforms
echo "*** dumping tst_string_data.nc to tst_string_data.cdl..."
${NCDUMP} tst_string_data.nc > tst_string_data.cdl
TMPNAME=`head -n 1 tst_string_data.cdl | cut -d" " -f 2`
NEWNAME=`basename $TMPNAME`
sed "s,$TMPNAME,$NEWNAME,g" tst_string_data.cdl > tmp.cdl
mv tmp.cdl tst_string_data.cdl
echo "*** comparing tst_string_data.cdl with ref_tst_string_data.cdl..."
diff -b tst_string_data.cdl $srcdir/ref_tst_string_data.cdl
echo '*** testing reference file ref_tst_compounds2.nc...'
${NCDUMP} $srcdir/ref_tst_compounds2.nc > tst_compounds2.cdl
TMPNAME=`head -n 1 tst_compounds2.cdl | cut -d" " -f 2`
NEWNAME=`basename $TMPNAME`
sed "s,$TMPNAME,$NEWNAME,g" tst_compounds2.cdl > tmp.cdl
mv tmp.cdl tst_compounds2.cdl
diff -b tst_compounds2.cdl $srcdir/ref_tst_compounds2.cdl
echo '*** testing reference file ref_tst_compounds3.nc...'
${NCDUMP} $srcdir/ref_tst_compounds3.nc > tst_compounds3.cdl
TMPNAME=`head -n 1 tst_compounds3.cdl | cut -d" " -f 2`
NEWNAME=`basename $TMPNAME`
sed "s,$TMPNAME,$NEWNAME,g" tst_compounds3.cdl > tmp.cdl
mv tmp.cdl tst_compounds3.cdl
diff -b tst_compounds3.cdl $srcdir/ref_tst_compounds3.cdl
echo '*** testing reference file ref_tst_compounds4.nc...'
${NCDUMP} $srcdir/ref_tst_compounds4.nc > tst_compounds4.cdl
TMPNAME=`head -n 1 tst_compounds4.cdl | cut -d" " -f 2`
NEWNAME=`basename $TMPNAME`
sed "s,$TMPNAME,$NEWNAME,g" tst_compounds4.cdl > tmp.cdl
mv tmp.cdl tst_compounds4.cdl
diff -b tst_compounds4.cdl $srcdir/ref_tst_compounds4.cdl
else # Non-MINGW Platforms
echo "*** dumping tst_string_data.nc to tst_string_data.cdl..."
${NCDUMP} tst_string_data.nc > tst_string_data.cdl
echo "*** comparing tst_string_data.cdl with ref_tst_string_data.cdl..."
diff -b tst_string_data.cdl $srcdir/ref_tst_string_data.cdl
echo "*** dumping tst_string_data.nc to tst_string_data.cdl..."
${NCDUMP} tst_string_data.nc > tst_string_data.cdl
echo "*** comparing tst_string_data.cdl with ref_tst_string_data.cdl..."
diff -b tst_string_data.cdl ${top_srcdir}/ncdump/ref_tst_string_data.cdl
#echo '*** testing non-coordinate variable of same name as dimension...'
#${NCGEN} -v4 -b -o tst_noncoord.nc $srcdir/ref_tst_noncoord.cdl
#${NCGEN} -v4 -b -o tst_noncoord.nc ${top_srcdir}/ncdump/ref_tst_noncoord.cdl
echo '*** testing reference file ref_tst_compounds2.nc...'
${NCDUMP} $srcdir/ref_tst_compounds2.nc > tst_compounds2.cdl
diff -b tst_compounds2.cdl $srcdir/ref_tst_compounds2.cdl
echo '*** testing reference file ref_tst_compounds2.nc...'
${NCDUMP} ${top_srcdir}/ncdump/ref_tst_compounds2.nc > tst_compounds2.cdl
diff -b tst_compounds2.cdl ${top_srcdir}/ncdump/ref_tst_compounds2.cdl
echo '*** testing reference file ref_tst_compounds3.nc...'
${NCDUMP} $srcdir/ref_tst_compounds3.nc > tst_compounds3.cdl
diff -b tst_compounds3.cdl $srcdir/ref_tst_compounds3.cdl
echo '*** testing reference file ref_tst_compounds3.nc...'
${NCDUMP} ${top_srcdir}/ncdump/ref_tst_compounds3.nc > tst_compounds3.cdl
diff -b tst_compounds3.cdl ${top_srcdir}/ncdump/ref_tst_compounds3.cdl
echo '*** testing reference file ref_tst_compounds4.nc...'
${NCDUMP} $srcdir/ref_tst_compounds4.nc > tst_compounds4.cdl
diff -b tst_compounds4.cdl $srcdir/ref_tst_compounds4.cdl
echo '*** testing reference file ref_tst_compounds4.nc...'
${NCDUMP} ${top_srcdir}/ncdump/ref_tst_compounds4.nc > tst_compounds4.cdl
diff -b tst_compounds4.cdl ${top_srcdir}/ncdump/ref_tst_compounds4.cdl
# Exercise Jira NCF-213 bug fix
# Exercise Jira NCF-213 bug fix
# rm -f tst_ncf213.cdl tst_ncf213.nc
${NCGEN} -b -o tst_ncf213.nc $srcdir/ref_tst_ncf213.cdl
${NCDUMP} -s -h tst_ncf213.nc \
| sed -e 's/netcdflibversion=.*[|]/netcdflibversion=0.0.0|/' \
| sed -e 's/hdf5libversion=.*"/hdf5libversion=0.0.0"/' \
| sed -e 's|_SuperblockVersion = [0-9]|_SuperblockVersion = 0|' \
| cat >tst_ncf213.cdl
# Now compare
ok=1;
if diff -b $srcdir/ref_tst_ncf213.cdl tst_ncf213.cdl ; then ok=1; else ok=0; fi
# cleanup
${NCGEN} -b -o tst_ncf213.nc ${top_srcdir}/ncdump/ref_tst_ncf213.cdl
${NCDUMP} -s -h tst_ncf213.nc \
| sed -e 's/netcdflibversion=.*[|]/netcdflibversion=0.0.0|/' \
| sed -e 's/hdf5libversion=.*"/hdf5libversion=0.0.0"/' \
| sed -e 's|_SuperblockVersion = [0-9]|_SuperblockVersion = 0|' \
| cat >tst_ncf213.cdl
# Now compare
ok=1;
if diff -b ${top_srcdir}/ncdump/ref_tst_ncf213.cdl tst_ncf213.cdl ; then ok=1; else ok=0; fi
# cleanup
# rm -f tst_ncf213.cdl tst_ncf213.nc
if test $ok = 0 ; then
echo "*** FAIL: NCF-213 Bug Fix test"
exit 1
fi
if test $ok = 0 ; then
echo "*** FAIL: NCF-213 Bug Fix test"
exit 1
fi
echo "*** All ncgen and ncdump extra test output for netCDF-4 format passed!"

View File

@ -11,12 +11,12 @@
The output file name is chosen by using the following in priority order:
1. -o flag name
2. command line input file with .cdl changed to .nc
3. dataset name as specified in netcdf <name> {...}
3. dataset name as specified in netcdf <name> {...}
*/
void
define_netcdf(void)
{
char filename[2048+1];
char filename[2049];
/* Rule for specifying the dataset name:
1. use -o name
@ -37,8 +37,8 @@ define_netcdf(void)
p = strrchr(filename,'.');
if(p != NULL) {*p= '\0';}
p = strrchr(filename,'/');
if(p != NULL) {memmove(filename,(p+1),2048);}
if(p != NULL) {memmove(filename,(p+1),(2048-strlen(cdlname)));}
} else {/* construct name from dataset name */
strncpy(filename,datasetname,2048); /* Reserve space for extension, terminating '\0' */
}
@ -100,7 +100,7 @@ topfqn(Symbol* sym)
char* parentfqn;
Symbol* parent;
#endif
if(sym->fqn != NULL)
return; /* already defined */
@ -116,9 +116,9 @@ topfqn(Symbol* sym)
topfqn(parent);
}
parentfqn = parent->fqn;
fqnname = fqnescape(sym->name);
fqn = (char*)malloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1);
fqn = (char*)malloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1);
strcpy(fqn,parentfqn);
strcat(fqn,"/");
strcat(fqn,fqnname);
@ -142,7 +142,7 @@ nestedfqn(Symbol* sym)
char* fqn;
char* fqnname;
Symbol* parent;
if(sym->fqn != NULL)
return; /* already defined */
@ -153,7 +153,7 @@ nestedfqn(Symbol* sym)
assert(parent->fqn != NULL);
fqnname = fqnescape(sym->name);
fqn = (char*)malloc(strlen(fqnname) + strlen(parent->fqn) + 1 + 1);
fqn = (char*)malloc(strlen(fqnname) + strlen(parent->fqn) + 1 + 1);
strcpy(fqn,parent->fqn);
strcat(fqn,".");
strcat(fqn,fqnname);
@ -172,7 +172,7 @@ attfqn(Symbol* sym)
char* fqnname;
char* parentfqn;
Symbol* parent;
if(sym->fqn != NULL)
return; /* already defined */
@ -185,7 +185,7 @@ attfqn(Symbol* sym)
parentfqn = parent->fqn;
fqnname = fqnescape(sym->name);
fqn = (char*)malloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1);
fqn = (char*)malloc(strlen(fqnname) + strlen(parentfqn) + 1 + 1);
strcpy(fqn,parentfqn);
strcat(fqn,"_");
strcat(fqn,fqnname);
@ -221,7 +221,7 @@ cprefixed(List* prefix, char* suffix, char* separator)
Symbol* sym = (Symbol*)listget(prefix,i);
strcat(result,sym->name); /* append "<prefix[i]/>"*/
strcat(result,separator);
}
}
strcat(result,suffix); /* append "<suffix>"*/
return result;
}

View File

@ -1929,14 +1929,15 @@ oc_data_ddtree(OCobject link, OCobject ddsroot)
return OCTHROW(OC_NOERR);
}
OCDT
oc_data_mode(OCobject link, OCobject datanode)
OCerror
oc_data_mode(OCobject link, OCobject datanode, OCDT* modep)
{
OCdata* data;
OCVERIFY(OC_Data,datanode);
OCDEREF(OCdata*,data,datanode);
return data->datamode;
if(modep) *modep = data->datamode;
return OC_NOERR;
}
/* Free up a datanode that is no longer being used;

View File

@ -22,7 +22,7 @@ typedef unsigned int OCDT;
#define OCDT_ATOMIC ((OCDT)(32)) /* is atomic leaf */
/* Return mode for this data */
extern OCDT oc_data_mode(OClink, OCdatanode);
extern OCerror oc_data_mode(OClink, OCdatanode, OCDT* modep);
extern OCerror oc_dds_dd(OClink, OCddsnode, int);
extern OCerror oc_dds_ddnode(OClink, OCddsnode);