Merge branch 'master' into byterange.dmh

This commit is contained in:
Ward Fisher 2019-03-19 12:05:44 -06:00 committed by GitHub
commit e2b31ffae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 1793 additions and 1532 deletions

View File

@ -37,4 +37,4 @@ before_install:
script: script:
- docker run --rm -it -h "$CURHOST" -e USEDASH=FALSE -e RUNF=OFF -e RUNCXX=OFF -e RUNP=OFF -e RUNNCO=OFF -e USECMAKE=$USECMAKE -e USEAC=$USEAC -e DISTCHECK=$DISTCHECK -e COPTS="$COPTS" -e AC_OPTS="$AC_OPTS" -e CTEST_OUTPUT_ON_FAILURE=1 -v $(pwd):/netcdf-c -e USE_LOCAL_CP=$USECP -e TESTPROC=100 -e ENABLE_FILTER_TESTING=$TESTFILTER $DOCKIMG - docker run --privileged --rm -it -h "$CURHOST" -e USEDASH=FALSE -e RUNF=OFF -e RUNCXX=OFF -e RUNP=OFF -e RUNNCO=OFF -e USECMAKE=$USECMAKE -e USEAC=$USEAC -e DISTCHECK=$DISTCHECK -e COPTS="$COPTS" -e AC_OPTS="$AC_OPTS" -e CTEST_OUTPUT_ON_FAILURE=1 -v $(pwd):/netcdf-c -e USE_LOCAL_CP=$USECP -e TESTPROC=100 -e ENABLE_FILTER_TESTING=$TESTFILTER -e ENABLE_C_MEMCHECK=OFF $DOCKIMG

View File

@ -26,13 +26,13 @@ set(PACKAGE "netCDF" CACHE STRING "")
SET(NC_VERSION_MAJOR 4) SET(NC_VERSION_MAJOR 4)
SET(NC_VERSION_MINOR 6) SET(NC_VERSION_MINOR 6)
SET(NC_VERSION_PATCH 3) SET(NC_VERSION_PATCH 4)
SET(NC_VERSION_NOTE "-development") SET(NC_VERSION_NOTE "-development")
SET(netCDF_VERSION ${NC_VERSION_MAJOR}.${NC_VERSION_MINOR}.${NC_VERSION_PATCH}${NC_VERSION_NOTE}) SET(netCDF_VERSION ${NC_VERSION_MAJOR}.${NC_VERSION_MINOR}.${NC_VERSION_PATCH}${NC_VERSION_NOTE})
SET(VERSION ${netCDF_VERSION}) SET(VERSION ${netCDF_VERSION})
SET(NC_VERSION ${netCDF_VERSION}) SET(NC_VERSION ${netCDF_VERSION})
SET(netCDF_LIB_VERSION 13) SET(netCDF_LIB_VERSION 15)
SET(netCDF_SO_VERSION 13) SET(netCDF_SO_VERSION 15)
SET(PACKAGE_VERSION ${VERSION}) SET(PACKAGE_VERSION ${VERSION})
# Get system configuration, Use it to determine osname, os release, cpu. These # Get system configuration, Use it to determine osname, os release, cpu. These
@ -737,6 +737,8 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_libver_bounds "" HDF5_HAS_LIBVER_BOUNDS) CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_libver_bounds "" HDF5_HAS_LIBVER_BOUNDS)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5free_memory "" HDF5_HAS_H5FREE) CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5free_memory "" HDF5_HAS_H5FREE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5allocate_memory "" HDF5_HAS_ALLOCATE_MEMORY)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5resize_memory "" HDF5_HAS_RESIZE_MEMORY)
IF(HDF5_PARALLEL) IF(HDF5_PARALLEL)
SET(HDF5_CC h5pcc) SET(HDF5_CC h5pcc)
@ -1862,7 +1864,7 @@ FOREACH(_LIB ${ALL_TLL_LIBS})
LIST(APPEND LINKFLAGS "-L${_LIB_DIR}") LIST(APPEND LINKFLAGS "-L${_LIB_DIR}")
ENDFOREACH() ENDFOREACH()
SET(NC_LIBS "-lnetcdf ${NC_LIBS}") #SET(NC_LIBS "-lnetcdf ${NC_LIBS}")
STRING(REPLACE ";" " " NC_LIBS "${NC_LIBS}") STRING(REPLACE ";" " " NC_LIBS "${NC_LIBS}")
STRING(REPLACE "-lhdf5::hdf5-shared" "-lhdf5" NC_LIBS ${NC_LIBS}) STRING(REPLACE "-lhdf5::hdf5-shared" "-lhdf5" NC_LIBS ${NC_LIBS})
@ -1876,6 +1878,9 @@ STRING(REPLACE ";" " " LINKFLAGS "${LINKFLAGS}")
LIST(REMOVE_DUPLICATES NC_LIBS) LIST(REMOVE_DUPLICATES NC_LIBS)
LIST(REMOVE_DUPLICATES LINKFLAGS) LIST(REMOVE_DUPLICATES LINKFLAGS)
SET(LIBS ${NC_LIBS})
SET(NC_LIBS "-lnetcdf")
configure_file( configure_file(
${netCDF_SOURCE_DIR}/netcdf.pc.in ${netCDF_SOURCE_DIR}/netcdf.pc.in
${netCDF_BINARY_DIR}/netcdf.pc @ONLY) ${netCDF_BINARY_DIR}/netcdf.pc @ONLY)
@ -1936,10 +1941,6 @@ SET(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BU
is_disabled(BUILD_SHARED_LIBS enable_static) is_disabled(BUILD_SHARED_LIBS enable_static)
is_enabled(BUILD_SHARED_LIBS enable_shared) is_enabled(BUILD_SHARED_LIBS enable_shared)
# Remove libnetcdf from NC_LIBS.
STRING(REPLACE "-lnetcdf " "" TMP_NC_LIBS "${NC_LIBS}")
SET(LIBS "${TMP_NC_LIBS}")
is_enabled(ENABLE_V2_API HAS_NC2) is_enabled(ENABLE_V2_API HAS_NC2)
is_enabled(ENABLE_NETCDF_4 HAS_NC4) is_enabled(ENABLE_NETCDF_4 HAS_NC4)
is_enabled(ENABLE_HDF4 HAS_HDF4) is_enabled(ENABLE_HDF4 HAS_HDF4)

View File

@ -5,7 +5,8 @@ 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. 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.3 - TBD
## 4.6.4 - TBD
* [Enhancement] Provide byte-range reading of remote datasets. This allows * [Enhancement] Provide byte-range reading of remote datasets. This allows
read-only access to, for example, Amazon S3 objects and also Thredds Server read-only access to, for example, Amazon S3 objects and also Thredds Server
@ -14,11 +15,16 @@ See [GitHub #1251](https://github.com/Unidata/netcdf-c/issues/1251).
* Update the license from the home-brewed NetCDF license to the standard 3-Clause BSD License. This change does not result in any new restrictions; it is merely the adoption of a standard, well-known and well-understood license in place of the historic NetCDF license written at Unidata. This is part of a broader push by Unidata to adopt modern, standardized licensing. * Update the license from the home-brewed NetCDF license to the standard 3-Clause BSD License. This change does not result in any new restrictions; it is merely the adoption of a standard, well-known and well-understood license in place of the historic NetCDF license written at Unidata. This is part of a broader push by Unidata to adopt modern, standardized licensing.
### Maintenance Release ## 4.6.3 - February 28, 2019
* [Bug Fix] Correctly generated `netcdf.pc` generated either by `configure` or `cmake`. If linking against a static netcdf, you would need to pass the `--static` argument to `pkg-config` in order to list all of the downstream dependencies. See [Github #1324](https://github.com/Unidata/netcdf-c/issues/1324) for more information.
* Now always write hidden coordinates attribute, which allows faster file opens when present. See [Github #1262](https://github.com/Unidata/netcdf-c/issues/1262) for more information.
* Some fixes for rename, including fix for renumbering of varids after a rename (#1307), renaming var to dim without coordinate var. See [Github #1297](https://github.com/Unidata/netcdf-c/issues/1297).
* Fix of NULL parameter causing segfaults in put_vars functions. See [Github #1265](https://github.com/Unidata/netcdf-c/issues/1265) for more information.
* Fix of --enable-benchmark benchmark tests [Github #1211](https://github.com/Unidata/netcdf-c/issues/1211)
* Update the license from the home-brewed NetCDF license to the standard 3-Clause BSD License. This change does not result in any new restrictions; it is merely the adoption of a standard, well-known and well-understood license in place of the historic NetCDF license written at Unidata. This is part of a broader push by Unidata to adopt modern, standardized licensing. * Update the license from the home-brewed NetCDF license to the standard 3-Clause BSD License. This change does not result in any new restrictions; it is merely the adoption of a standard, well-known and well-understood license in place of the historic NetCDF license written at Unidata. This is part of a broader push by Unidata to adopt modern, standardized licensing.
* [BugFix] Corrected DAP-releated issues on big-endian machines. See [Github #1321](https://github.com/Unidata/netcdf-c/issues/1321), [Github #1302](https://github.com/Unidata/netcdf-c/issues/1302) for more information. * [BugFix] Corrected DAP-releated issues on big-endian machines. See [Github #1321](https://github.com/Unidata/netcdf-c/issues/1321), [Github #1302](https://github.com/Unidata/netcdf-c/issues/1302) for more information.
* [BugFix][Enhancement] Various and sundry bugfixes and performance enhancements, thanks to @edhartnett, @gsjaardema, @t-b, @wkliao, and all of our other contributors. * [BugFix][Enhancement] Various and sundry bugfixes and performance enhancements, thanks to \@edhartnett, \@gsjaardema, \@t-b, \@wkliao, and all of our other contributors.
* [Enhancement] Extended `nccopy -F` syntax to support multiple variables with a single invocation. See [Github #1311](https://github.com/Unidata/netcdf-c/issues/1311) for more information. * [Enhancement] Extended `nccopy -F` syntax to support multiple variables with a single invocation. See [Github #1311](https://github.com/Unidata/netcdf-c/issues/1311) for more information.
* [BugFix] Corrected an issue where DAP2 was incorrectly converting signed bytes, resulting in an erroneous error message under some circumstances. See [GitHub #1317](https://github.com/Unidata/netcdf-c/issues/1317) for more information. See [Github #1319](https://github.com/Unidata/netcdf-c/issues/1319) for related information. * [BugFix] Corrected an issue where DAP2 was incorrectly converting signed bytes, resulting in an erroneous error message under some circumstances. See [GitHub #1317](https://github.com/Unidata/netcdf-c/issues/1317) for more information. See [Github #1319](https://github.com/Unidata/netcdf-c/issues/1319) for related information.
* [BugFix][Enhancement] Modified `nccopy` so that `_NCProperties` is not copied over verbatim but is instead generated based on the version of `libnetcdf` used when copying the file. Additionally, `_NCProperties` are displayed if/when associated with a netcdf3 file, now. See [GitHub #803](https://github.com/Unidata/netcdf-c/issues/803) for more information. * [BugFix][Enhancement] Modified `nccopy` so that `_NCProperties` is not copied over verbatim but is instead generated based on the version of `libnetcdf` used when copying the file. Additionally, `_NCProperties` are displayed if/when associated with a netcdf3 file, now. See [GitHub #803](https://github.com/Unidata/netcdf-c/issues/803) for more information.

View File

@ -370,6 +370,12 @@ are set when opening a binary file on Windows. */
nc4file. */ nc4file. */
#cmakedefine HDF5_HAS_H5FREE 1 #cmakedefine HDF5_HAS_H5FREE 1
/* if true, H5allocate_memory() will be used. */
#cmakedefine HDF5_HAS_ALLOCATE_MEMORY 1
/* if true, H5resize_memory() will be used. */
#cmakedefine HDF5_HAS_RESIZE_MEMORY 1
/* if true, hdf5 has parallelism enabled */ /* if true, hdf5 has parallelism enabled */
#cmakedefine HDF5_PARALLEL 1 #cmakedefine HDF5_PARALLEL 1

View File

@ -13,7 +13,7 @@
AC_PREREQ([2.59]) AC_PREREQ([2.59])
# Initialize with name, version, and support email address. # Initialize with name, version, and support email address.
AC_INIT([netCDF], [4.6.3-development], [support-netcdf@unidata.ucar.edu], [netcdf-c]) AC_INIT([netCDF], [4.6.4-development], [support-netcdf@unidata.ucar.edu], [netcdf-c])
## ##
# Prefer an empty CFLAGS variable instead of the default -g -O2. # Prefer an empty CFLAGS variable instead of the default -g -O2.
@ -24,7 +24,7 @@ AC_INIT([netCDF], [4.6.3-development], [support-netcdf@unidata.ucar.edu], [netcd
AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4 AC_SUBST([NC_VERSION_MAJOR]) NC_VERSION_MAJOR=4
AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=6 AC_SUBST([NC_VERSION_MINOR]) NC_VERSION_MINOR=6
AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=3 AC_SUBST([NC_VERSION_PATCH]) NC_VERSION_PATCH=4
AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-development" AC_SUBST([NC_VERSION_NOTE]) NC_VERSION_NOTE="-development"
##### #####
@ -1045,7 +1045,7 @@ if test "x$enable_hdf5" = xyes; then
# H5Pset_fapl_mpiposix and H5Pget_fapl_mpiposix have been removed since HDF5 1.8.12. # H5Pset_fapl_mpiposix and H5Pget_fapl_mpiposix have been removed since HDF5 1.8.12.
# Use H5Pset_fapl_mpio and H5Pget_fapl_mpio, instead. # Use H5Pset_fapl_mpio and H5Pget_fapl_mpio, instead.
AC_CHECK_FUNCS([H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5Pset_libver_bounds H5Pset_all_coll_metadata_ops]) AC_CHECK_FUNCS([H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5resize_memory H5allocate_memory H5Pset_libver_bounds H5Pset_all_coll_metadata_ops])
# Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0) # Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0)
if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then
@ -1079,6 +1079,14 @@ if test "x$enable_hdf5" = xyes; then
AC_DEFINE([HDF5_HAS_H5FREE], [1], [if true, H5free_memory() will be used to free hdf5-allocated memory in nc4file.]) AC_DEFINE([HDF5_HAS_H5FREE], [1], [if true, H5free_memory() will be used to free hdf5-allocated memory in nc4file.])
fi fi
if test "x$ac_cv_func_H5allocate_memory" = xyes; then
AC_DEFINE([HDF5_HAS_ALLOCATE_MEMORY], [1], [if true, H5allocate_memory() will be used.])
fi
if test "x$ac_cv_func_H5resize_memory" = xyes; then
AC_DEFINE([HDF5_HAS_resize_MEMORY], [1], [if true, H5resize_memory() will be used.])
fi
if test "x$ac_cv_func_H5Pset_libver_bounds" = xyes; then if test "x$ac_cv_func_H5Pset_libver_bounds" = xyes; then
AC_DEFINE([HDF5_HAS_LIBVER_BOUNDS], [1], [if true, netcdf4 file properties will be set using H5Pset_libver_bounds]) AC_DEFINE([HDF5_HAS_LIBVER_BOUNDS], [1], [if true, netcdf4 file properties will be set using H5Pset_libver_bounds])
fi fi

View File

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

View File

@ -8,7 +8,6 @@
- \subpage netcdf_data_set_components - \subpage netcdf_data_set_components
- \subpage netcdf_perf_chunking - \subpage netcdf_perf_chunking
- \subpage netcdf_utilities_guide - \subpage netcdf_utilities_guide
- \subpage compress
- \subpage BestPractices - \subpage BestPractices
- \subpage user_defined_formats - \subpage user_defined_formats
- \subpage users_guide_appendices - \subpage users_guide_appendices
@ -48,7 +47,10 @@ web site (http://www.unidata.ucar.edu/netcdf), and with the netCDF
distribution. distribution.
The latest version of this document, and the language specific guides, The latest version of this document, and the language specific guides,
can be found at the netCDF web site (http://www.unidata.ucar.edu/netcdf/docs) along with extensive additional information about netCDF, including pointers to other software that works with netCDF data. can be found at the netCDF web site
(http://www.unidata.ucar.edu/netcdf/docs) along with extensive
additional information about netCDF, including pointers to other
software that works with netCDF data.
Separate documentation of the Java netCDF library can be found at Separate documentation of the Java netCDF library can be found at
http://www.unidata.ucar.edu/software/netcdf-java/. http://www.unidata.ucar.edu/software/netcdf-java/.
@ -88,8 +90,10 @@ were written.
Unidata supports the netCDF interfaces for C (see <a Unidata supports the netCDF interfaces for C (see <a
href="http://www.unidata.ucar.edu/netcdf/docs/" >NetCDF-C User's href="http://www.unidata.ucar.edu/netcdf/docs/" >NetCDF-C User's
Guide</a>), Fortran (see <a href="http://www.unidata.ucar.edu/netcdf/fortran/docs/" >NetCDF-Fortran User's Guide</a>) Guide</a>), Fortran (see <a
and C++ (see <a href="http://www.unidata.ucar.edu/netcdf/documentation/historic/cxx4/index.html" href="http://www.unidata.ucar.edu/netcdf/fortran/docs/"
>NetCDF-Fortran User's Guide</a>) and C++ (see <a
href="http://www.unidata.ucar.edu/netcdf/documentation/historic/cxx4/index.html"
>NetCDF C++ Interface Guide</a>). >NetCDF C++ Interface Guide</a>).
The netCDF library is supported for various UNIX operating systems. A The netCDF library is supported for various UNIX operating systems. A

View File

@ -53,8 +53,9 @@ bytes in length. On a 64-bit machine, the size must be less than 2^64 bytes.
Also note that for a diskless file, there are two notions of Also note that for a diskless file, there are two notions of
*write* with respect to the file. The first notion is that the *write* with respect to the file. The first notion is that the
file is read-only through the netCDF API. For example, if the file file is writeable through the netCDF API, but on disk, the file is
is read-only, then a call to, for example, _nc_def_dim()_ will fail. read-only. This means a call to, for example, _nc_def_dim()_ will succeed,
but no changes will be written to disk.
The second notion of *write* refers to the file on disk to which The second notion of *write* refers to the file on disk to which
the contents of memory might be persisted. the contents of memory might be persisted.

View File

@ -150,18 +150,16 @@ Use this in mode flags for both nc_create() and nc_open(). */
#define NC_NETCDF4 0x1000 /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */ #define NC_NETCDF4 0x1000 /**< Use netCDF-4/HDF5 format. Mode flag for nc_create(). */
/** Turn on MPI I/O. /** The following 3 flags are deprecated as of 4.6.2. Parallel I/O is now
Use this in mode flags for both nc_create() and nc_open(). */ * initiated by calling nc_create_par and nc_open_par, no longer by flags.
*/
#define NC_MPIIO 0x2000 /**< \deprecated */ #define NC_MPIIO 0x2000 /**< \deprecated */
/** Turn on MPI POSIX I/O. #define NC_MPIPOSIX NC_MPIIO /**< \deprecated */
Use this in mode flags for both nc_create() and nc_open(). */ #define NC_PNETCDF (NC_MPIIO) /**< \deprecated */
#define NC_MPIPOSIX NC_MPIIO /**< \deprecated As of libhdf5 1.8.13. Now an alias */
#define NC_PERSIST 0x4000 /**< Save diskless contents to disk. Mode flag for nc_open() or nc_create() */ #define NC_PERSIST 0x4000 /**< Save diskless contents to disk. Mode flag for nc_open() or nc_create() */
#define NC_INMEMORY 0x8000 /**< Read from memory. Mode flag for nc_open() or nc_create() */ #define NC_INMEMORY 0x8000 /**< Read from memory. Mode flag for nc_open() or nc_create() */
#define NC_PNETCDF (NC_MPIIO) /**< \deprecated Use PnetCDF library; alias for NC_MPIIO. */
#define NC_MAX_MAGIC_NUMBER_LEN 8 /**< Max len of user-defined format magic number. */ #define NC_MAX_MAGIC_NUMBER_LEN 8 /**< Max len of user-defined format magic number. */
/** Format specifier for nc_set_default_format() and returned /** Format specifier for nc_set_default_format() and returned

View File

@ -1,76 +1,71 @@
/** \file /* Copyright 2018 University Corporation for Atmospheric
Dimension functions Research/Unidata. See COPYRIGHT file for more info. */
/**
@file
These functions define and inquire about dimensions. The functions in this file define, inquire about, and rename
dimensions.
Copyright 2018 University Corporation for Atmospheric
Research/Unidata. See COPYRIGHT file for more info.
*/ */
#include "ncdispatch.h" #include "ncdispatch.h"
/*! \defgroup dimensions Dimensions /**
@defgroup dimensions Dimensions
Dimensions are used to define the shape of data in netCDF. Dimensions are used to define the shape of data in netCDF.
Dimensions for a netCDF dataset are defined when it is created, while Dimensions for a netCDF dataset are defined when it is created,
the netCDF dataset is in define mode. Additional dimensions may be while the netCDF dataset is in define mode. Additional dimensions
added later by reentering define mode. A netCDF dimension has a name may be added later by reentering define mode. A netCDF dimension
and a length. In a netCDF classic or 64-bit offset file, at most one has a name and a length. In a netCDF classic or 64-bit offset file,
dimension can have the unlimited length, which means variables using at most one dimension can have the unlimited length, which means
this dimension can grow along this dimension. In a netCDF-4 file variables using this dimension can grow along this dimension. In a
multiple unlimited dimensions are supported. netCDF-4 file multiple unlimited dimensions are supported.
There is a suggested limit (1024) to the number of dimensions that can There is a suggested limit (1024) to the number of dimensions that
be defined in a single netCDF dataset. The limit is the value of the can be defined in a single netCDF dataset. The limit is the value
predefined macro NC_MAX_DIMS. The purpose of the limit is to make of the predefined macro ::NC_MAX_DIMS. The purpose of the limit is
writing generic applications simpler. They need only provide an array to make writing generic applications simpler. They need only
of NC_MAX_DIMS dimensions to handle any netCDF dataset. The provide an array of ::NC_MAX_DIMS dimensions to handle any netCDF
implementation of the netCDF library does not enforce this advisory dataset. The implementation of the netCDF library does not enforce
maximum, so it is possible to use more dimensions, if necessary, but this advisory maximum, so it is possible to use more dimensions, if
netCDF utilities that assume the advisory maximums may not be able to necessary, but netCDF utilities that assume the advisory maximums
handle the resulting netCDF datasets. may not be able to handle the resulting netCDF datasets.
NC_MAX_VAR_DIMS, which must not exceed NC_MAX_DIMS, is the maximum ::NC_MAX_VAR_DIMS, which must not exceed ::NC_MAX_DIMS, is the
number of dimensions that can be used to specify the shape of a single maximum number of dimensions that can be used to specify the shape
variable. It is also intended to simplify writing generic of a single variable. It is also intended to simplify writing
applications. generic applications.
Ordinarily, the name and length of a dimension are fixed when the Ordinarily, the name and length of a dimension are fixed when the
dimension is first defined. The name may be changed later, but the dimension is first defined. The name may be changed later, but the
length of a dimension (other than the unlimited dimension) cannot be length of a dimension (other than the unlimited dimension) cannot
changed without copying all the data to a new netCDF dataset with a be changed without copying all the data to a new netCDF dataset
redefined dimension length. with a redefined dimension length.
Dimension lengths in the C interface are type size_t rather than type Dimension lengths in the C interface are type size_t rather than
int to make it possible to access all the data in a netCDF dataset on type int to make it possible to access all the data in a netCDF
a platform that only supports a 16-bit int data type, for example dataset on a platform that only supports a 16-bit int data type,
MSDOS. If dimension lengths were type int instead, it would not be for example MSDOS. If dimension lengths were type int instead, it
possible to access data from variables with a dimension length greater would not be possible to access data from variables with a
than a 16-bit int can accommodate. dimension length greater than a 16-bit int can accommodate.
A netCDF dimension in an open netCDF dataset is referred to by a small A netCDF dimension in an open netCDF dataset is referred to by a
integer called a dimension ID. In the C interface, dimension IDs are small integer called a dimension ID. In the C interface, dimension
0, 1, 2, ..., in the order in which the dimensions were defined. IDs are 0, 1, 2, ..., in the order in which the dimensions were
defined.
Operations supported on dimensions are: Operations supported on dimensions are:
- Create a dimension, given its name and length. - Create a dimension, given its name and length.
- Get a dimension ID from its name. - Get a dimension ID from its name.
- Get a dimension's name and length from its ID. - Get a dimension's name and length from its ID.
- Rename a dimension. - Rename a dimension.
*/ */
/*! \{*/ /* All these functions are part of the above defgroup... */ /** @{ */
/** \name Deleting and Renaming Dimensions /**
Define a new dimension. The function nc_def_dim() adds a new
Functions to delete or rename an dimension. */
/*! \{ */ /* All these functions are part of this named group... */
/*!
Define a new dimension. The function nc_def_dim adds a new
dimension to an open netCDF dataset in define mode. It returns (as an dimension to an open netCDF dataset in define mode. It returns (as an
argument) a dimension ID, given the netCDF ID, the dimension name, and argument) a dimension ID, given the netCDF ID, the dimension name, and
the dimension length. At most one unlimited length dimension, called the dimension length. At most one unlimited length dimension, called
@ -78,34 +73,34 @@ the record dimension, may be defined for each classic or 64-bit offset
netCDF dataset. NetCDF-4 datasets may have multiple unlimited netCDF dataset. NetCDF-4 datasets may have multiple unlimited
dimensions. dimensions.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param name Name of the dimension to be created.
\param name Name of the dimension to be created. @param len Length of the dimension to be created. Use NC_UNLIMITED for
\param len Length of the dimension to be created. Use NC_UNLIMITED for
unlimited dimensions. unlimited dimensions.
@param idp Pointer where dimension ID will be stored.
\param idp Pointer where dimension ID will be stored. @return ::NC_NOERR No error.
@return ::NC_EBADID Not a valid ID.
@return ::NC_EMAXNAME Name is too long.
@return ::NC_EBADNAME Name breaks netCDF name rules.
@return ::NC_EINVAL Invalid input.
@return ::NC_ENOTINDEFINE Not in define mode.
@return ::NC_EDIMSIZE Invalid dimension size.
@return ::NC_EUNLIMIT NC_UNLIMITED size already in use
@return ::NC_EMAXDIMS NC_MAX_DIMS exceeded [not enforced after 4.5.0]
@return ::NC_ENAMEINUSE String match to name in use
@return ::NC_ENOMEM Memory allocation (malloc) failure
@return ::NC_EPERM Write to read only
\retval ::NC_NOERR No error. @section nc_def_dim_example Example
\returns ::NC_EBADID Not a valid ID.
\returns ::NC_ENOTINDEFINE Not in define mode.
\returns ::NC_EDIMSIZE Invalid dimension size.
\returns ::NC_EUNLIMIT NC_UNLIMITED size already in use
\returns ::NC_EMAXDIMS NC_MAX_DIMS exceeded [not enforced after 4.5.0]
\returns ::NC_ENAMEINUSE String match to name in use
\returns ::NC_ENOMEM Memory allocation (malloc) failure
\returns ::NC_EPERM Write to read only
\section nc_def_dim_example Example
Here is an example using nc_def_dim() to create a dimension named lat of Here is an example using nc_def_dim() to create a dimension named lat of
length 18 and a unlimited dimension named rec in a new netCDF dataset length 18 and a unlimited dimension named rec in a new netCDF dataset
named foo.nc: named foo.nc:
\code @code
#include <netcdf.h> #include <netcdf.h>
... ...
int status, ncid, latid, recid; int status, ncid, latid, recid;
@ -117,8 +112,10 @@ named foo.nc:
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
status = nc_def_dim(ncid, "rec", NC_UNLIMITED, &recid); status = nc_def_dim(ncid, "rec", NC_UNLIMITED, &recid);
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
\endcode @endcode
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_def_dim(int ncid, const char *name, size_t len, int *idp) nc_def_dim(int ncid, const char *name, size_t len, int *idp)
@ -130,25 +127,26 @@ nc_def_dim(int ncid, const char *name, size_t len, int *idp)
return ncp->dispatch->def_dim(ncid, name, len, idp); return ncp->dispatch->def_dim(ncid, name, len, idp);
} }
/*! /**
Find the ID of a dimension from the name. Find the ID of a dimension from the name.
The function nc_inq_dimid returns (as an argument) the ID of a netCDF The function nc_inq_dimid returns (as an argument) the ID of a
dimension, given the name of the dimension. If ndims is the number of netCDF dimension, given the name of the dimension. If ndims is the
dimensions defined for a netCDF dataset, each dimension has an ID number of dimensions defined for a netCDF dataset, each dimension
between 0 and ndims-1. has an ID between 0 and ndims-1.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param name Name of the dimension.
@param idp Pointer where dimension ID will be stored.
\param name Name of the dimension. @return ::NC_NOERR No error.
@return ::NC_EBADID Not a valid ID.
@return ::NC_EBADDIM Invalid dimension ID.
\param idp Pointer where dimension ID will be stored. @author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Not a valid ID.
\returns ::NC_EBADDIM Invalid dimension ID or name.
*/ */
int int
nc_inq_dimid(int ncid, const char *name, int *idp) nc_inq_dimid(int ncid, const char *name, int *idp)
@ -160,40 +158,37 @@ nc_inq_dimid(int ncid, const char *name, int *idp)
return ncp->dispatch->inq_dimid(ncid,name,idp); return ncp->dispatch->inq_dimid(ncid,name,idp);
} }
/*! /**
Find the name and length of a dimension. Find the name and length of a dimension.
The length for the unlimited dimension, if any, is the number of The length for the unlimited dimension, if any, is the number of
records written so far. records written so far.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param dimid Dimension ID, from a previous call to nc_inq_dimid() or
\param dimid Dimension ID, from a previous call to nc_inq_dimid() or
nc_def_dim(). nc_def_dim().
@param name Returned dimension name. The caller must allocate space
\param name Returned dimension name. The caller must allocate space
for the returned name. The maximum possible length, in characters, of for the returned name. The maximum possible length, in characters, of
a dimension name is given by the predefined constant a dimension name is given by the predefined constant
NC_MAX_NAME. (This doesn't include the null terminator, so declare ::NC_MAX_NAME. (This doesn't include the null terminator, so declare
your array to be size NC_MAX_NAME+1). The returned character array your array to be size NC_MAX_NAME+1). The returned character array
will be null-terminated. will be null-terminated.
@param lenp Pointer to location for returned length of dimension. For
\param lenp Pointer to location for returned length of dimension. For
the unlimited dimension, this is the number of records written so far. the unlimited dimension, this is the number of records written so far.
\returns ::NC_NOERR No error. @return ::NC_NOERR No error.
\returns ::NC_EBADID Not a valid ID. @return ::NC_EBADID Not a valid ID.
\returns ::NC_EBADDIM Invalid dimension ID or name. @return ::NC_EBADDIM Invalid dimension ID or name.
\section nc_inq_dim_example Example @section nc_inq_dim_example Example
Here is an example using nc_inq_dim() to determine the length of a Here is an example using nc_inq_dim() to determine the length of a
dimension named lat, and the name and current maximum length of the dimension named lat, and the name and current maximum length of the
unlimited dimension for an existing netCDF dataset named foo.nc: unlimited dimension for an existing netCDF dataset named foo.nc:
\code @code
#include <netcdf.h> #include <netcdf.h>
... ...
int status, ncid, latid, recid; int status, ncid, latid, recid;
@ -212,7 +207,10 @@ unlimited dimension for an existing netCDF dataset named foo.nc:
status = nc_inq_dim(ncid, recid, recname, &recs); status = nc_inq_dim(ncid, recid, recname, &recs);
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
\endcode @endcode
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp) nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
@ -224,42 +222,45 @@ nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
return ncp->dispatch->inq_dim(ncid,dimid,name,lenp); return ncp->dispatch->inq_dim(ncid,dimid,name,lenp);
} }
/*! /**
Rename a dimension. Rename a dimension.
This function renames an existing dimension in a netCDF dataset open This function renames an existing dimension in a netCDF dataset
for writing. You cannot rename a dimension to have the same name as open for writing. You cannot rename a dimension to have the same
another dimension. name as another dimension.
For netCDF classic and 64-bit offset files, if the new name is longer For netCDF classic and 64-bit offset files, if the new name is
than the old name, the netCDF dataset must be in define mode. longer than the old name, which has been flushed to disk, the
netCDF dataset must be in define mode.
For netCDF-4 files the dataset is switched to define mode for the For netCDF-4 files the length of the name is not checked against
rename, regardless of the name length. the length of the old name, even for classic model files. This is
due to the difficulty of exactly reproducing classic library
behavior in this case.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param dimid Dimension ID, from a previous call to nc_inq_dimid()
or nc_def_dim().
@param name New name for dimension. Must be a null-terminated
string with length less than ::NC_MAX_NAME.
\param dimid Dimension ID, from a previous call to nc_inq_dimid() or @return ::NC_NOERR No error.
nc_def_dim(). @return ::NC_EBADID Not a valid ID.
@return ::NC_EBADDIM Invalid dimension ID or name.
@return ::NC_ENAMEINUSE String match to name in use
@return ::NC_ENOMEM Memory allocation (malloc) failure
@return ::NC_EPERM Write to read only
@return ::NC_ENOTINDEFINE Not in define mode and new name is longer
than old.
\param name New name for dimension. Must be a null-terminated string @section nc_rename_dim_example Example
with length less than NC_MAX_NAME.
\returns ::NC_NOERR No error. Here is an example using nc_rename_dim to rename the dimension lat
\returns ::NC_EBADID Not a valid ID. to latitude in an existing netCDF dataset named foo.nc:
\returns ::NC_EBADDIM Invalid dimension ID or name.
\returns ::NC_ENAMEINUSE String match to name in use
\returns ::NC_ENOMEM Memory allocation (malloc) failure
\returns ::NC_EPERM Write to read only
\returns ::NC_ENOTINDEFINE Not in define mode and new name is longer than old.
\section nc_rename_dim_example Example
Here is an example using nc_rename_dim to rename the dimension lat to @code
latitude in an existing netCDF dataset named foo.nc:
\code
#include <netcdf.h> #include <netcdf.h>
... ...
int status, ncid, latid; int status, ncid, latid;
@ -275,7 +276,10 @@ latitude in an existing netCDF dataset named foo.nc:
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
status = nc_enddef(ncid); status = nc_enddef(ncid);
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
\endcode @endcode
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_rename_dim(int ncid, int dimid, const char *name) nc_rename_dim(int ncid, int dimid, const char *name)
@ -287,26 +291,27 @@ nc_rename_dim(int ncid, int dimid, const char *name)
return ncp->dispatch->rename_dim(ncid,dimid,name); return ncp->dispatch->rename_dim(ncid,dimid,name);
} }
/*! /**
Find the number of dimensions. Find the number of dimensions.
In a classic model netCDF file, this function returns the number of In a classic model netCDF file, this function returns the number of
defined dimensions. In a netCDF-4/HDF5 file, this function returns the defined dimensions. In a netCDF-4/HDF5 file, this function returns
number of dimensions available in the group specified by ncid, which the number of dimensions available in the group specified by ncid,
may be less than the total number of dimensions in a file. In a which may be less than the total number of dimensions in a file. In
netCDF-4/HDF5 file, dimensions are in all sub-groups, sub-sub-groups, a netCDF-4/HDF5 file, dimensions are in all sub-groups,
etc. sub-sub-groups, etc.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param ndimsp Pointer where number of dimensions will be
\param ndimsp Pointer where number of dimensions will be
written. Ignored if NULL. written. Ignored if NULL.
\returns ::NC_NOERR No error. @return ::NC_NOERR No error.
\returns ::NC_EBADID Not a valid ID. @return ::NC_EBADID Not a valid ID.
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_inq_ndims(int ncid, int *ndimsp) nc_inq_ndims(int ncid, int *ndimsp)
@ -319,25 +324,27 @@ nc_inq_ndims(int ncid, int *ndimsp)
return ncp->dispatch->inq(ncid,ndimsp,NULL,NULL,NULL); return ncp->dispatch->inq(ncid,ndimsp,NULL,NULL,NULL);
} }
/*! /**
Find the ID of the unlimited dimension. Find the ID of the unlimited dimension.
This function finds the ID of the unlimited dimension. For This function finds the ID of the unlimited dimension. For
netCDF-4/HDF5 files (which may have more than one unlimited netCDF-4/HDF5 files (which may have more than one unlimited
dimension), the ID of the first unlimited dimesnion is returned. For dimension), the ID of the first unlimited dimesnion is
these files, nc_inq_unlimdims() will return all the unlimited dimension IDs. returned. For these files, nc_inq_unlimdims() will return all the
unlimited dimension IDs.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param unlimdimidp Pointer where unlimited dimension ID will be
\param unlimdimidp Pointer where unlimited dimension ID will be
stored. If there is no unlimited dimension, -1 will be stored stored. If there is no unlimited dimension, -1 will be stored
here. Ignored if NULL. here. Ignored if NULL.
\returns ::NC_NOERR No error. @return ::NC_NOERR No error.
\returns ::NC_EBADID Not a valid ID. @return ::NC_EBADID Not a valid ID.
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_inq_unlimdim(int ncid, int *unlimdimidp) nc_inq_unlimdim(int ncid, int *unlimdimidp)
@ -349,34 +356,32 @@ nc_inq_unlimdim(int ncid, int *unlimdimidp)
return ncp->dispatch->inq_unlimdim(ncid,unlimdimidp); return ncp->dispatch->inq_unlimdim(ncid,unlimdimidp);
} }
/*! /**
Find out the name of a dimension. Find out the name of a dimension.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param dimid Dimension ID, from a previous call to nc_inq_dimid()
or nc_def_dim().
@param name Returned dimension name. The caller must allocate space
for the returned name. The maximum possible length, in characters,
of a dimension name is given by the predefined constant
::NC_MAX_NAME. (This doesn't include the null terminator, so
declare your array to be size NC_MAX_NAME+1). The returned
character array will be null-terminated. Ignored if NULL.
\param dimid Dimension ID, from a previous call to nc_inq_dimid() or @return ::NC_NOERR No error.
nc_def_dim(). @return ::NC_EBADID Not a valid ID.
@return ::NC_EBADDIM Invalid dimension ID or name.
\param name Returned dimension name. The caller must allocate space @section nc_inq_dim_example2 Example
for the returned name. The maximum possible length, in characters, of
a dimension name is given by the predefined constant
NC_MAX_NAME. (This doesn't include the null terminator, so declare
your array to be size NC_MAX_NAME+1). The returned character array
will be null-terminated. Ignored if NULL.
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Not a valid ID.
\returns ::NC_EBADDIM Invalid dimension ID or name.
\section nc_inq_dim_example2 Example
Here is an example using nc_inq_dim() to determine the length of a Here is an example using nc_inq_dim() to determine the length of a
dimension named lat, and the name and current maximum length of the dimension named lat, and the name and current maximum length of the
unlimited dimension for an existing netCDF dataset named foo.nc: unlimited dimension for an existing netCDF dataset named foo.nc:
\code @code
#include <netcdf.h> #include <netcdf.h>
... ...
int status, ncid, latid, recid; int status, ncid, latid, recid;
@ -395,8 +400,10 @@ unlimited dimension for an existing netCDF dataset named foo.nc:
status = nc_inq_dim(ncid, recid, recname, &recs); status = nc_inq_dim(ncid, recid, recname, &recs);
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
\endcode @endcode
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_inq_dimname(int ncid, int dimid, char *name) nc_inq_dimname(int ncid, int dimid, char *name)
@ -409,32 +416,30 @@ nc_inq_dimname(int ncid, int dimid, char *name)
return ncp->dispatch->inq_dim(ncid,dimid,name,NULL); return ncp->dispatch->inq_dim(ncid,dimid,name,NULL);
} }
/*! /**
Find the length of a dimension. Find the length of a dimension.
The length for the unlimited dimension, if any, is the number of The length for the unlimited dimension, if any, is the number of
records written so far. records written so far.
\param ncid NetCDF or group ID, from a previous call to nc_open(), @param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid(). nc_inq_ncid().
@param dimid Dimension ID, from a previous call to nc_inq_dimid()
or nc_def_dim().
@param lenp Pointer where the length will be stored.
\param dimid Dimension ID, from a previous call to nc_inq_dimid() or @return ::NC_NOERR No error.
nc_def_dim(). @return ::NC_EBADID Not a valid ID.
@return ::NC_EBADDIM Invalid dimension ID or name.
\param lenp Pointer where the length will be stored. @section nc_inq_dim_example3 Example
\returns ::NC_NOERR No error.
\returns ::NC_EBADID Not a valid ID.
\returns ::NC_EBADDIM Invalid dimension ID or name.
\section nc_inq_dim_example3 Example
Here is an example using nc_inq_dim() to determine the length of a Here is an example using nc_inq_dim() to determine the length of a
dimension named lat, and the name and current maximum length of the dimension named lat, and the name and current maximum length of the
unlimited dimension for an existing netCDF dataset named foo.nc: unlimited dimension for an existing netCDF dataset named foo.nc:
\code @code
#include <netcdf.h> #include <netcdf.h>
... ...
int status, ncid, latid, recid; int status, ncid, latid, recid;
@ -453,7 +458,10 @@ unlimited dimension for an existing netCDF dataset named foo.nc:
status = nc_inq_dim(ncid, recid, recname, &recs); status = nc_inq_dim(ncid, recid, recname, &recs);
if (status != NC_NOERR) handle_error(status); if (status != NC_NOERR) handle_error(status);
\endcode @endcode
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
Fisher
*/ */
int int
nc_inq_dimlen(int ncid, int dimid, size_t *lenp) nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
@ -466,6 +474,4 @@ nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
return ncp->dispatch->inq_dim(ncid,dimid,NULL,lenp); return ncp->dispatch->inq_dim(ncid,dimid,NULL,lenp);
} }
/*! \} */ /* End of named group ...*/ /** @} */
/*! \} */ /* End of defgroup. */

View File

@ -1783,10 +1783,6 @@ check_create_mode(int mode)
/* mmap is not allowed for netcdf-4 */ /* mmap is not allowed for netcdf-4 */
if(mmap && (mode & NC_NETCDF4)) return NC_EINVAL; if(mmap && (mode & NC_NETCDF4)) return NC_EINVAL;
/* Can't use both parallel and diskless|inmemory|mmap. */
if (mode & NC_MPIIO && mode & (NC_DISKLESS|NC_INMEMORY|NC_MMAP))
return NC_EINVAL;
#ifndef USE_NETCDF4 #ifndef USE_NETCDF4
/* If the user asks for a netCDF-4 file, and the library was built /* If the user asks for a netCDF-4 file, and the library was built
* without netCDF-4, then return an error.*/ * without netCDF-4, then return an error.*/

View File

@ -123,6 +123,10 @@ int nc_create_par(const char *path, int cmode, MPI_Comm comm,
return NC_ENOTBUILT; return NC_ENOTBUILT;
#endif #endif
/* Can't use both parallel and diskless|inmemory|mmap. */
if (cmode & (NC_DISKLESS|NC_INMEMORY|NC_MMAP))
return NC_EINVAL;
data.comm = comm; data.comm = comm;
data.info = info; data.info = info;
return NC_create(path, cmode, 0, 0, NULL, 1, &data, ncidp); return NC_create(path, cmode, 0, 0, NULL, 1, &data, ncidp);

File diff suppressed because it is too large Load Diff

View File

@ -107,6 +107,7 @@ NC_get_vara(int ncid, int varid,
} }
/** /**
\internal
Get data for a variable. Get data for a variable.
\param ncid NetCDF or group ID. \param ncid NetCDF or group ID.
@ -129,7 +130,6 @@ they are read.
\returns ::NC_EBADID Bad ncid. \returns ::NC_EBADID Bad ncid.
\ingroup variables \ingroup variables
\internal
\author Dennis Heimbigner \author Dennis Heimbigner
*/ */
static int static int
@ -547,6 +547,7 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
} }
/** /**
\internal
Called by externally visible nc_get_vars_xxx routines. Called by externally visible nc_get_vars_xxx routines.
\param ncid NetCDF or group ID. \param ncid NetCDF or group ID.
@ -575,7 +576,6 @@ they are read.
\returns ::NC_EBADID Bad ncid. \returns ::NC_EBADID Bad ncid.
\ingroup variables \ingroup variables
\internal
\author Dennis Heimbigner, Ed Hartnett \author Dennis Heimbigner, Ed Hartnett
*/ */
static int static int
@ -605,6 +605,7 @@ NC_get_vars(int ncid, int varid, const size_t *start,
} }
/** /**
\internal
Called by externally visible nc_get_varm_xxx routines. Note that the Called by externally visible nc_get_varm_xxx routines. Note that the
varm routines are deprecated. Use the vars routines instead for new varm routines are deprecated. Use the vars routines instead for new
code. code.
@ -637,7 +638,6 @@ they are read.
\returns ::NC_EBADID Bad ncid. \returns ::NC_EBADID Bad ncid.
\ingroup variables \ingroup variables
\internal
\author Dennis Heimbigner, Ed Hartnett \author Dennis Heimbigner, Ed Hartnett
*/ */
static int static int

View File

@ -187,6 +187,11 @@ NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
/** /**
* @internal Rename a dimension, for those who like to prevaricate. * @internal Rename a dimension, for those who like to prevaricate.
* *
* @note If we're not in define mode, new name must be of equal or
* less size, if strict nc3 rules are in effect for this file. But we
* don't check this because reproducing the exact classic behavior
* would be too difficult. See github issue #1340.
*
* @param ncid File and group ID. * @param ncid File and group ID.
* @param dimid Dimension ID. * @param dimid Dimension ID.
* @param name New dimension name. * @param name New dimension name.

View File

@ -18,7 +18,7 @@ lib_LTLIBRARIES = libnetcdf.la
# for information regarding incrementing `-version-info`. # for information regarding incrementing `-version-info`.
## ##
libnetcdf_la_LDFLAGS = -version-info 14:1:1 libnetcdf_la_LDFLAGS = -version-info 15:0:0
libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS} libnetcdf_la_CPPFLAGS = ${AM_CPPFLAGS}
libnetcdf_la_LIBADD = libnetcdf_la_LIBADD =

View File

@ -90,7 +90,7 @@ Available values for OPTION include:
--has-parallel4 whether has parallel IO support via HDF5 --has-parallel4 whether has parallel IO support via HDF5
--has-parallel whether has parallel IO support via HDF5 or PnetCDF --has-parallel whether has parallel IO support via HDF5 or PnetCDF
--libs library linking information for netcdf --libs library linking information for netcdf
--prefix Install prefixx --prefix Install prefix
--includedir Include directory --includedir Include directory
--libdir Library directory --libdir Library directory
--version Library version --version Library version

View File

@ -6,7 +6,6 @@ variables:
float var1(dim0, dim1) ; float var1(dim0, dim1) ;
var1:_Storage = "chunked" ; var1:_Storage = "chunked" ;
var1:_ChunkSizes = 2, 2 ; var1:_ChunkSizes = 2, 2 ;
var1:_Endianness = "little" ;
var1:_Filter = "307,9,4" ; var1:_Filter = "307,9,4" ;
var1:_NoFill = "true" ; var1:_NoFill = "true" ;
@ -25,7 +24,6 @@ group: g {
float var2(dim0, dim1) ; float var2(dim0, dim1) ;
var2:_Storage = "chunked" ; var2:_Storage = "chunked" ;
var2:_ChunkSizes = 2, 2 ; var2:_ChunkSizes = 2, 2 ;
var2:_Endianness = "little" ;
var2:_Filter = "307,9,4" ; var2:_Filter = "307,9,4" ;
var2:_NoFill = "true" ; var2:_NoFill = "true" ;

View File

@ -20,7 +20,7 @@ echo "findplugin.sh loaded"
# These attributes might be platform dependent # These attributes might be platform dependent
sclean() { sclean() {
cat $1 \ cat $1 \
| sed -e '/var:_Endianness/d' \ | sed -e '/:_Endianness/d' \
| sed -e '/_NCProperties/d' \ | sed -e '/_NCProperties/d' \
| sed -e '/_SuperblockVersion/d' \ | sed -e '/_SuperblockVersion/d' \
| sed -e '/_IsNetcdf4/d' \ | sed -e '/_IsNetcdf4/d' \
@ -30,12 +30,7 @@ cat $1 \
# Function to extract _Filter attribute from a file # Function to extract _Filter attribute from a file
# These attributes might be platform dependent # These attributes might be platform dependent
getfilterattr() { getfilterattr() {
case "$1" in sed -e '/var.*:_Filter/p' -ed <$1 >$2
var1) sed -e '/var1:_Filter/p' -ed <$1 >$2 ;;
var2) sed -e '/var2:_Filter/p' -ed <$1 >$2 ;;
var) sed -e '/var:_Filter/p' -ed <$1 >$2 ;;
*) sed -e '/var:_Filter/p' -ed <$1 >$2 ;;
esac
} }
trimleft() { trimleft() {

View File

@ -11,6 +11,8 @@
#include "netcdf.h" #include "netcdf.h"
#include "netcdf_filter.h" #include "netcdf_filter.h"
#undef DEBUG
#define PARAMS_ID 32768 #define PARAMS_ID 32768
/* The C standard apparently defines all floating point constants as double; /* The C standard apparently defines all floating point constants as double;
@ -170,14 +172,14 @@ buildbaseline(void)
insert(7,&val4,sizeof(val4)); /* signed int */ insert(7,&val4,sizeof(val4)); /* signed int */
val4 = 4294967295U; /*0xffffffff*/ val4 = 4294967295U; /*0xffffffff*/
insert(8,&val4,sizeof(val4)); /* unsigned int */ insert(8,&val4,sizeof(val4)); /* unsigned int */
float4 = 789.0f; float4 = (float)FLTVAL;
insert(9,&float4,sizeof(float4)); /*float */ insert(9,&float4,sizeof(float4)); /*float */
val8 = -9223372036854775807L; val8 = LONGLONGVAL;
insert(10,&val8,sizeof(val8)); /* signed long long */ insert(10,&val8,sizeof(val8)); /* signed long long */
val8 = 18446744073709551615UL; val8 = ULONGLONGVAL;
insert(12,&val8,sizeof(val8)); /* unsigned long long */ insert(12,&val8,sizeof(val8)); /* unsigned long long */
float8 = DBLVAL; float8 = DBLVAL;
insert(114,&float8,sizeof(float8)); /* double */ insert(14,&float8,sizeof(float8)); /* double */
} }
/**************************************************/ /**************************************************/
@ -188,6 +190,11 @@ main(int argc, char **argv)
unsigned int id = 0; unsigned int id = 0;
size_t i,nparams = 0; size_t i,nparams = 0;
unsigned int* params = NULL; unsigned int* params = NULL;
/* Provide for 8-byte values */
long long basell;
unsigned long long baseull;
float basef;
double based;
printf("\nTesting filter parser.\n"); printf("\nTesting filter parser.\n");
@ -209,28 +216,32 @@ main(int argc, char **argv)
/* float */ /* float */
uf.ui = params[9]; uf.ui = params[9];
if(uf.f != (float)FLTVAL) memcpy(&basef,&baseline[9],4);
if(uf.f != basef)
mismatch(9,params,"uf.f"); mismatch(9,params,"uf.f");
/* signed long long */ /* signed long long */
ul.ui[0] = params[10]; ul.ui[0] = params[10];
ul.ui[1] = params[11]; ul.ui[1] = params[11];
NC_filterfix8((unsigned char*)&ul.ll,1); NC_filterfix8((unsigned char*)&ul.ll,1);
if(ul.ll != LONGLONGVAL) memcpy(&basell,&baseline[10],8);
if(ul.ll != basell)
mismatch2(10,params,"ul.ll"); mismatch2(10,params,"ul.ll");
/* unsigned long long */ /* unsigned long long */
ul.ui[0] = params[12]; ul.ui[0] = params[12];
ul.ui[1] = params[13]; ul.ui[1] = params[13];
NC_filterfix8((unsigned char*)&ul.ull,1); NC_filterfix8((unsigned char*)&ul.ull,1);
if(ul.ull != ULONGLONGVAL) memcpy(&baseull,&baseline[12],8);
if(ul.ull != baseull)
mismatch2(12,params,"ul.ull"); mismatch2(12,params,"ul.ull");
/* double */ /* double */
ud.ui[0] = params[14]; ud.ui[0] = params[14];
ud.ui[1] = params[15]; ud.ui[1] = params[15];
NC_filterfix8((unsigned char*)&ud.d,1); NC_filterfix8((unsigned char*)&ud.d,1);
if(ud.d != (double)DBLVAL) memcpy(&based,&baseline[14],8);
if(ud.d != based)
mismatch2(14,params,"ud.d"); mismatch2(14,params,"ud.d");
if (!nerrs) if (!nerrs)
@ -240,7 +251,8 @@ main(int argc, char **argv)
return (nerrs > 0 ? 1 : 0); return (nerrs > 0 ? 1 : 0);
} }
#if 0 #ifdef DEBUG
/* Look at q0 and q1) to determine type */ /* Look at q0 and q1) to determine type */
static int static int
gettype(const int q0, const int q1, int* isunsignedp) gettype(const int q0, const int q1, int* isunsignedp)
@ -470,4 +482,5 @@ NC_filterfix8(unsigned char* mem, int decode)
#endif #endif
} }
#endif /*0*/ #endif /*DEBUG*/

View File

@ -168,8 +168,10 @@ ENDIF(MSVC)
ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE) ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
add_sh_test(ncdump tst_inmemory_nc3) add_sh_test(ncdump tst_inmemory_nc3)
add_sh_test(ncdump tst_nccopy_w3)
IF(USE_NETCDF4) IF(USE_NETCDF4)
add_sh_test(ncdump tst_inmemory_nc4) add_sh_test(ncdump tst_inmemory_nc4)
add_sh_test(ncdump tst_nccopy_w4)
ENDIF(USE_NETCDF4) ENDIF(USE_NETCDF4)
IF(USE_NETCDF4) IF(USE_NETCDF4)
@ -251,6 +253,7 @@ ENDIF(MSVC)
add_sh_test(ncdump tst_inttags4) add_sh_test(ncdump tst_inttags4)
ENDIF(USE_NETCDF4) ENDIF(USE_NETCDF4)
add_sh_test(ncdump test_radix)
ENDIF() ENDIF()
ENDIF() ENDIF()

View File

@ -54,7 +54,7 @@ TESTS = tst_inttags.sh run_tests.sh tst_64bit.sh ref_ctest \
ref_ctest64 tst_output.sh tst_lengths.sh tst_calendars.sh \ ref_ctest64 tst_output.sh tst_lengths.sh tst_calendars.sh \
run_utf8_tests.sh tst_nccopy3.sh tst_nccopy3_subset.sh \ run_utf8_tests.sh tst_nccopy3.sh tst_nccopy3_subset.sh \
tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \ tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \
tst_dimsizes.sh run_ncgen_tests.sh tst_ncgen4_classic.sh tst_dimsizes.sh run_ncgen_tests.sh tst_ncgen4_classic.sh test_radix.sh
# The tst_nccopy3.sh test uses output from a bunch of other # The tst_nccopy3.sh test uses output from a bunch of other
# tests. This records the dependency so parallel builds work. # tests. This records the dependency so parallel builds work.
@ -93,9 +93,9 @@ tst_fillbug.log tst_netcdf4_4.log tst_h_scalar.log
tst_nccopy5.log: tst_nccopy4.log tst_nccopy5.log: tst_nccopy4.log
endif #!USE_HDF5 endif #!USE_HDF5
TESTS += tst_inmemory_nc3.sh TESTS += tst_inmemory_nc3.sh tst_nccopy_w3.sh
if USE_HDF5 if USE_HDF5
TESTS += tst_inmemory_nc4.sh TESTS += tst_inmemory_nc4.sh tst_nccopy_w4.sh
endif endif
endif BUILD_TESTSETS endif BUILD_TESTSETS
@ -133,7 +133,9 @@ tst_hdf5_offset.sh run_ncgen_nc4_tests.sh tst_nccopy3_subset.sh \
ref_nccopy3_subset.nc ref_test_corrupt_magic.nc tst_ncgen_shared.sh \ ref_nccopy3_subset.nc ref_test_corrupt_magic.nc tst_ncgen_shared.sh \
tst_ncgen4.sh tst_ncgen4_classic.sh tst_ncgen4_diff.sh \ tst_ncgen4.sh tst_ncgen4_classic.sh tst_ncgen4_diff.sh \
tst_ncgen4_cycle.sh tst_null_byte_padding.sh \ tst_ncgen4_cycle.sh tst_null_byte_padding.sh \
ref_null_byte_padding_test.nc ref_tst_irish_rover.nc ref_provenance_v1.nc ref_null_byte_padding_test.nc ref_tst_irish_rover.nc ref_provenance_v1.nc \
ref_tst_radix.cdl tst_radix.cdl test_radix.sh \
ref_nccopy_w.cdl tst_nccopy_w3.sh tst_nccopy_w4.sh
# The L512.bin file is file containing exactly 512 bytes each of value 0. # The L512.bin file is file containing exactly 512 bytes each of value 0.
# It is used for creating hdf5 files with varying offsets for testing. # It is used for creating hdf5 files with varying offsets for testing.
@ -163,4 +165,5 @@ compound_datasize_test.nc compound_datasize_test2.nc ncf199.nc \
tst_c0.cdl tst_c0_4.cdl tst_c0_4c.cdl tst_c0_64.cdl \ tst_c0.cdl tst_c0_4.cdl tst_c0_4c.cdl tst_c0_64.cdl \
tst_compound_datasize_test.cdl tst_compound_datasize_test2.cdl \ tst_compound_datasize_test.cdl tst_compound_datasize_test2.cdl \
tst_ncf199.cdl tst_tst_gattenum.cdl tst_tst_usuffix.cdl ctest.c \ tst_ncf199.cdl tst_tst_gattenum.cdl tst_tst_usuffix.cdl ctest.c \
ctest64.c nccopy3_subset_out.nc camrun.c tst_ncf213.cdl tst_ncf213.nc ctest64.c nccopy3_subset_out.nc camrun.c tst_ncf213.cdl tst_ncf213.nc \
tst_radix.nc tmp_radix.cdl

View File

@ -1894,7 +1894,7 @@ copy(char* infile, char* outfile)
} }
if(option_write_diskless) if(option_write_diskless)
create_mode |= NC_WRITE | NC_DISKLESS; /* NC_WRITE persists diskless file on close */ create_mode |= NC_PERSIST | NC_DISKLESS; /* NC_WRITE persists diskless file on close */
switch(outkind) { switch(outkind) {
case NC_FORMAT_CLASSIC: case NC_FORMAT_CLASSIC:
/* nothing to do */ /* nothing to do */

15
ncdump/ref_nccopy_w.cdl Normal file
View File

@ -0,0 +1,15 @@
netcdf nccopy_w {
dimensions:
d = 3 ;
variables:
byte b(d) ;
short s(d) ;
int i(d) ;
data:
b = -127, 127, -1 ;
s = 32767, -32766, -1 ;
i = -2147483646, 2147483647, -1 ;
}

19
ncdump/ref_tst_radix.cdl Normal file
View File

@ -0,0 +1,19 @@
netcdf tst_radix {
dimensions:
d = 2 ;
variables:
byte b(d);
short s(d);
int i(d);
// global attributes:
:attr1 = 83s ;
:attr2 = 83b ;
data:
b = -128, 127 ;
s = _, 32766 ;
i = -2147483646, 2147483647 ;
}

16
ncdump/test_radix.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
echo "*** Test integer constant radix specifications"
echo "*** creating tst_radix.nc from tst_radix.cdl..."
${NCGEN} -lb -o tst_radix.nc $srcdir/tst_radix.cdl
echo "*** creating tmp_radix.cdl from radix.nc..."
${NCDUMP} tst_radix.nc > tmp_radix.cdl
echo "*** comparing tmp_radix.cdl to ref_tst_radix.cdl..."
diff -b -w tmp_radix.cdl $srcdir/ref_tst_radix.cdl
exit 0

20
ncdump/tst_nccopy_w3.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
echo "*** Test nccopy -w on netcdf classic file"
echo "*** create nccopy_w3.nc from ref_nccopy_w.cdl..."
${NCGEN} -lb -o nccopy_w3.nc -N nccopy_w $srcdir/ref_nccopy_w.cdl
echo "*** diskless copy nccopy_w3.nc to nccopy_w3c.nc..."
${NCCOPY} -w nccopy_w3.nc nccopy_w3c.nc
echo "*** Convert nccopy_w3c.nc to nccopy_w3c.cdl..."
${NCDUMP} -n nccopy_w nccopy_w3c.nc > nccopy_w3c.cdl
echo "*** comparing ref_nccopy_w.cdl nccopy_w3c.cdl..."
diff -b -w $srcdir/ref_nccopy_w.cdl nccopy_w3c.cdl
rm -f nccopy_w3c.cdl nccopy_w3.nc nccopy_w3c.nc
exit 0

21
ncdump/tst_nccopy_w4.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
set -e
echo "*** Test nccopy -w on netcdf enhanced file"
echo "*** create nccopy_w4.nc from ref_nccopy_w.cdl..."
${NCGEN} -lb -o nccopy_w4.nc -N nccopy_w $srcdir/ref_nccopy_w.cdl
echo "*** diskless copy nccopy_w4.nc to nccopy_w4c.nc..."
${NCCOPY} -w nccopy_w4.nc nccopy_w4c.nc
echo "*** Convert nccopy_w4c.nc to nccopy_w4c.cdl..."
${NCDUMP} -n nccopy_w nccopy_w4c.nc > nccopy_w4c.cdl
echo "*** comparing ref_nccopy_w.cdl nccopy_w4c.cdl..."
diff -b -w $srcdir/ref_nccopy_w.cdl nccopy_w4c.cdl
rm -f nccopy_w4c.cdl
rm -f nccopy_w4.nc nccopy_w4c.nc
exit 0

19
ncdump/tst_radix.cdl Normal file
View File

@ -0,0 +1,19 @@
netcdf tst_radix {
dimensions:
d = 2 ;
variables:
byte b(d);
short s(d);
int i(d);
// global attributes:
:attr1 = 0123s ;
:attr2 = '\123' ;
data:
b = -0200, 0177 ;
s = -077777, 077776 ;
i = -017777777776, 017777777777 ;
}

View File

@ -63,7 +63,15 @@ extern char *progname; /* for error messages */
extern "C" { extern "C" {
#endif #endif
/* For NDEBUG builds, provide a version of NC_CHECK that does not
* include a file name. Including a file name causes heartache for the
* debian package builders. They already use NDEBUG to turn off the
* file names in asserts. */
#ifdef NDEBUG
#define NC_CHECK(fncall) {int ncstat=fncall;if(ncstat!=NC_NOERR)check(ncstat,"",__LINE__);}
#else
#define NC_CHECK(fncall) {int ncstat=fncall;if(ncstat!=NC_NOERR)check(ncstat,__FILE__,__LINE__);} #define NC_CHECK(fncall) {int ncstat=fncall;if(ncstat!=NC_NOERR)check(ncstat,__FILE__,__LINE__);}
#endif /* NDEBUG */
/* Print error message to stderr and exit */ /* Print error message to stderr and exit */
extern void error ( const char *fmt, ... ); extern void error ( const char *fmt, ... );

View File

@ -60,7 +60,7 @@ genbin_netcdf(void)
#endif #endif
stat = nc_create(filename, cmode_modifier, &ncid); stat = nc_create(filename, cmode_modifier, &ncid);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
/* ncid created above is also root group*/ /* ncid created above is also root group*/
rootgroup->nc_id = ncid; rootgroup->nc_id = ncid;
@ -72,7 +72,7 @@ genbin_netcdf(void)
Symbol* gsym = (Symbol*)listget(grpdefs,igrp); Symbol* gsym = (Symbol*)listget(grpdefs,igrp);
if(gsym == rootgroup) continue; /* ignore root group*/ if(gsym == rootgroup) continue; /* ignore root group*/
stat = nc_def_grp(gsym->container->nc_id,gsym->name,&gsym->nc_id); stat = nc_def_grp(gsym->container->nc_id,gsym->name,&gsym->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
#endif #endif
@ -95,7 +95,7 @@ genbin_netcdf(void)
dsym->name, dsym->name,
(dsym->dim.isunlimited?NC_UNLIMITED:dsym->dim.declsize), (dsym->dim.isunlimited?NC_UNLIMITED:dsym->dim.declsize),
&dsym->nc_id); &dsym->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
} }
@ -122,7 +122,7 @@ genbin_netcdf(void)
NULL, NULL,
&vsym->nc_id); &vsym->nc_id);
} }
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
} }
@ -154,12 +154,12 @@ genbin_netcdf(void)
if (nofill_flag) { if (nofill_flag) {
stat = nc_set_fill(rootgroup->nc_id, NC_NOFILL, 0); stat = nc_set_fill(rootgroup->nc_id, NC_NOFILL, 0);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
/* leave define mode */ /* leave define mode */
stat = nc_enddef(rootgroup->nc_id); stat = nc_enddef(rootgroup->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
if(!header_only) { if(!header_only) {
/* Load values into those variables with defined data */ /* Load values into those variables with defined data */
@ -189,7 +189,7 @@ genbin_defineglobalspecials(void)
/* Watch out, this is a global Attribute */ /* Watch out, this is a global Attribute */
format = kind_string(/*Main.*/format_flag); format = kind_string(/*Main.*/format_flag);
stat = nc_put_att_text(rootgroup->nc_id,NC_GLOBAL,"_Format",strlen(format),format); stat = nc_put_att_text(rootgroup->nc_id,NC_GLOBAL,"_Format",strlen(format),format);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
#endif /*0*/ #endif /*0*/
@ -206,13 +206,13 @@ genbin_definespecialattributes(Symbol* var)
derror("NC_CHUNKED requested, but no chunksizes specified"); derror("NC_CHUNKED requested, but no chunksizes specified");
stat = nc_def_var_chunking(var->container->nc_id, var->nc_id, NC_CHUNKED, special->_ChunkSizes); stat = nc_def_var_chunking(var->container->nc_id, var->nc_id, NC_CHUNKED, special->_ChunkSizes);
} }
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
if(special->flags & _FLETCHER32_FLAG) { if(special->flags & _FLETCHER32_FLAG) {
stat = nc_def_var_fletcher32(var->container->nc_id, stat = nc_def_var_fletcher32(var->container->nc_id,
var->nc_id, var->nc_id,
special->_Fletcher32); special->_Fletcher32);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
if(special->flags & (_DEFLATE_FLAG | _SHUFFLE_FLAG)) { if(special->flags & (_DEFLATE_FLAG | _SHUFFLE_FLAG)) {
stat = nc_def_var_deflate(var->container->nc_id, stat = nc_def_var_deflate(var->container->nc_id,
@ -221,7 +221,7 @@ genbin_definespecialattributes(Symbol* var)
(special->_DeflateLevel >= 0?1:0), (special->_DeflateLevel >= 0?1:0),
(special->_DeflateLevel >= 0?special->_DeflateLevel (special->_DeflateLevel >= 0?special->_DeflateLevel
:0)); :0));
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
if(special->flags & _ENDIAN_FLAG) { if(special->flags & _ENDIAN_FLAG) {
stat = nc_def_var_endian(var->container->nc_id, stat = nc_def_var_endian(var->container->nc_id,
@ -229,14 +229,14 @@ genbin_definespecialattributes(Symbol* var)
(special->_Endianness == NC_ENDIAN_LITTLE? (special->_Endianness == NC_ENDIAN_LITTLE?
NC_ENDIAN_LITTLE NC_ENDIAN_LITTLE
:NC_ENDIAN_BIG)); :NC_ENDIAN_BIG));
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
if(special->flags & _NOFILL_FLAG) { if(special->flags & _NOFILL_FLAG) {
stat = nc_def_var_fill(var->container->nc_id, stat = nc_def_var_fill(var->container->nc_id,
var->nc_id, var->nc_id,
(special->_Fill?NC_FILL:NC_NOFILL), (special->_Fill?NC_FILL:NC_NOFILL),
NULL); NULL);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
if(special->flags & _FILTER_FLAG) { if(special->flags & _FILTER_FLAG) {
/* Special check for alternate way to specify _Deflate */ /* Special check for alternate way to specify _Deflate */
@ -263,7 +263,7 @@ genbin_definespecialattributes(Symbol* var)
special->_FilterParams special->_FilterParams
); );
} }
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
return stat; return stat;
} }
@ -275,7 +275,7 @@ genbin_close(void)
{ {
int stat; int stat;
stat = nc_close(rootgroup->nc_id); stat = nc_close(rootgroup->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
#ifdef USE_NETCDF4 #ifdef USE_NETCDF4
@ -296,7 +296,7 @@ genbin_deftype(Symbol* tsym)
tsym->typ.size, tsym->typ.size,
tsym->name, tsym->name,
&tsym->nc_id); &tsym->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
break; break;
case NC_ENUM: case NC_ENUM:
{ {
@ -305,7 +305,7 @@ genbin_deftype(Symbol* tsym)
tsym->typ.basetype->nc_id, tsym->typ.basetype->nc_id,
tsym->name, tsym->name,
&tsym->nc_id); &tsym->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
datum = bbNew(); datum = bbNew();
for(i=0;i<listlength(tsym->subnodes);i++) { for(i=0;i<listlength(tsym->subnodes);i++) {
Symbol* econst = (Symbol*)listget(tsym->subnodes,i); Symbol* econst = (Symbol*)listget(tsym->subnodes,i);
@ -317,7 +317,7 @@ genbin_deftype(Symbol* tsym)
tsym->nc_id, tsym->nc_id,
econst->name, econst->name,
bbContents(datum)); bbContents(datum));
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
bbFree(datum); bbFree(datum);
} }
@ -327,14 +327,14 @@ genbin_deftype(Symbol* tsym)
tsym->name, tsym->name,
tsym->typ.basetype->nc_id, tsym->typ.basetype->nc_id,
&tsym->nc_id); &tsym->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
break; break;
case NC_COMPOUND: case NC_COMPOUND:
stat = nc_def_compound(tsym->container->nc_id, stat = nc_def_compound(tsym->container->nc_id,
tsym->typ.size, tsym->typ.size,
tsym->name, tsym->name,
&tsym->nc_id); &tsym->nc_id);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
for(i=0;i<listlength(tsym->subnodes);i++) { for(i=0;i<listlength(tsym->subnodes);i++) {
Symbol* efield = (Symbol*)listget(tsym->subnodes,i); Symbol* efield = (Symbol*)listget(tsym->subnodes,i);
ASSERT(efield->subclass == NC_FIELD); ASSERT(efield->subclass == NC_FIELD);
@ -362,7 +362,7 @@ genbin_deftype(Symbol* tsym)
efield->typ.dimset.ndims, efield->typ.dimset.ndims,
dimsizes); dimsizes);
} }
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
break; break;
default: panic("definectype: unexpected type subclass"); default: panic("definectype: unexpected type subclass");
@ -448,11 +448,11 @@ genbin_writevar(Generator* generator, Symbol* vsym, Bytebuffer* memory,
} else { } else {
stat = nc_put_vara(vsym->container->nc_id, vsym->nc_id, start, count, data); stat = nc_put_vara(vsym->container->nc_id, vsym->nc_id, start, count, data);
} }
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
#if 0 #if 0
/* Reclaim the data */ /* Reclaim the data */
stat = ncaux_reclaim_data(vsym->container->nc_id, vsym->typ.basetype->nc_id, data, nelems); stat = ncaux_reclaim_data(vsym->container->nc_id, vsym->typ.basetype->nc_id, data, nelems);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
bbClear(memory); /* reclaim top-level memory */ bbClear(memory); /* reclaim top-level memory */
#endif #endif
return stat; return stat;
@ -481,7 +481,7 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
case NC_BYTE: { case NC_BYTE: {
signed char* data = (signed char*)bbContents(databuf); signed char* data = (signed char*)bbContents(databuf);
stat = nc_put_att_schar(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_schar(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_CHAR: { case NC_CHAR: {
char* data = (char*)bbContents(databuf); char* data = (char*)bbContents(databuf);
@ -495,27 +495,27 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
slen++; slen++;
} }
stat = nc_put_att_text(grpid,varid,asym->name,slen,data); stat = nc_put_att_text(grpid,varid,asym->name,slen,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_SHORT: { case NC_SHORT: {
short* data = (short*)bbContents(databuf); short* data = (short*)bbContents(databuf);
stat = nc_put_att_short(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_short(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_INT: { case NC_INT: {
int* data = (int*)bbContents(databuf); int* data = (int*)bbContents(databuf);
stat = nc_put_att_int(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_int(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_FLOAT: { case NC_FLOAT: {
float* data = (float*)bbContents(databuf); float* data = (float*)bbContents(databuf);
stat = nc_put_att_float(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_float(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_DOUBLE: { case NC_DOUBLE: {
double* data = (double*)bbContents(databuf); double* data = (double*)bbContents(databuf);
stat = nc_put_att_double(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_double(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_STRING: { case NC_STRING: {
const char** data; const char** data;
@ -527,27 +527,27 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
case NC_UBYTE: { case NC_UBYTE: {
unsigned char* data = (unsigned char*)bbContents(databuf); unsigned char* data = (unsigned char*)bbContents(databuf);
stat = nc_put_att_uchar(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_uchar(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_USHORT: { case NC_USHORT: {
unsigned short* data = (unsigned short*)bbContents(databuf); unsigned short* data = (unsigned short*)bbContents(databuf);
stat = nc_put_att_ushort(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_ushort(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_UINT: { case NC_UINT: {
unsigned int* data = (unsigned int*)bbContents(databuf); unsigned int* data = (unsigned int*)bbContents(databuf);
stat = nc_put_att_uint(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_uint(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
case NC_INT64: { case NC_INT64: {
long long* data = (long long*)bbContents(databuf); long long* data = (long long*)bbContents(databuf);
stat = nc_put_att_longlong(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_longlong(grpid,varid,asym->name,typid,len,data);
check_err2(stat,asym->lineno,__LINE__,__FILE__); check_err2(stat,asym->lineno,__LINE__,"ncgen");
} break; } break;
case NC_UINT64: { case NC_UINT64: {
unsigned long long* data = (unsigned long long*)bbContents(databuf); unsigned long long* data = (unsigned long long*)bbContents(databuf);
stat = nc_put_att_ulonglong(grpid,varid,asym->name,typid,len,data); stat = nc_put_att_ulonglong(grpid,varid,asym->name,typid,len,data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} break; } break;
default: PANIC1("genbin_defineattr: unexpected basetype: %d",basetype->typ.typecode); default: PANIC1("genbin_defineattr: unexpected basetype: %d",basetype->typ.typecode);
} }
@ -556,13 +556,13 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
data = (const char*)bbContents(databuf); data = (const char*)bbContents(databuf);
stat = nc_put_att(grpid,varid,asym->name,typid, stat = nc_put_att(grpid,varid,asym->name,typid,
len,(void*)data); len,(void*)data);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
#ifdef GENDEBUG #ifdef GENDEBUG
{ {
char out[4096]; char out[4096];
memset(out,0x77,sizeof(out)); memset(out,0x77,sizeof(out));
stat = nc_get_att(grpid,varid,asym->name,&out); stat = nc_get_att(grpid,varid,asym->name,&out);
check_err(stat,__LINE__,__FILE__); check_err(stat,__LINE__,"ncgen");
} }
#endif #endif
} }

View File

@ -14,7 +14,7 @@ It has diverged slightly over time.
#include "nc_iter.h" #include "nc_iter.h"
#define CHECK(stat,f) if(stat != NC_NOERR) {check(stat,#f,__FILE__,__LINE__);} else {} #define CHECK(stat,f) if(stat != NC_NOERR) {check(stat,#f,"ncgen",__LINE__);} else {}
/* forward declarations */ /* forward declarations */
static int nc_blkio_init(size_t bufsize, size_t value_size, int rank, static int nc_blkio_init(size_t bufsize, size_t value_size, int rank,

View File

@ -82,6 +82,7 @@ static unsigned int MAX_UINT = NC_MAX_UINT;
#define TAGCHARS "BbSsLlUu" #define TAGCHARS "BbSsLlUu"
#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9') #define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
#define tstoctal(ch) ((ch) == '0')
/*Mnemonics*/ /*Mnemonics*/
#define ISIDENT 1 #define ISIDENT 1
@ -115,7 +116,7 @@ unsigned char ubyte_val; /* last byte value read */
static Symbol* makepath(char* text); static Symbol* makepath(char* text);
static int lexdebug(int); static int lexdebug(int);
static unsigned long long parseULL(char* text, int*); static unsigned long long parseULL(int radix, char* text, int*);
static nc_type downconvert(unsigned long long uint64, int*, int, int); static nc_type downconvert(unsigned long long uint64, int*, int, int);
static int tagmatch(nc_type nct, int tag); static int tagmatch(nc_type nct, int tag);
static int nct2lexeme(nc_type nct); static int nct2lexeme(nc_type nct);
@ -380,6 +381,7 @@ NIL|nil|Nil {
We need to try to see what size of integer ((u)int). We need to try to see what size of integer ((u)int).
Technically, the user should specify, but... Technically, the user should specify, but...
If out of any integer range, then complain If out of any integer range, then complain
Also, if the digits begin with 0, then assume octal.
*/ */
int slen = strlen(ncgtext); int slen = strlen(ncgtext);
char* stag = NULL; char* stag = NULL;
@ -390,28 +392,40 @@ NIL|nil|Nil {
nc_type nct = 0; nc_type nct = 0;
char* pos = NULL; char* pos = NULL;
int hasU = 0; int hasU = 0;
int radix = 10;
pos = ncgtext;
/* capture the tag string */ /* capture the tag string */
tag = collecttag(ncgtext,&stag); tag = collecttag(pos,&stag);
if(tag == NC_NAT) { if(tag == NC_NAT) {
sprintf(errstr,"Illegal integer suffix: %s",stag); sprintf(errstr,"Illegal integer suffix: %s",stag);
yyerror(errstr); yyerror(errstr);
goto done; goto done;
} }
/* drop the tag from the input text */ /* drop the tag from the input text */
ncgtext[slen - strlen(stag)] = '\0'; ncgtext[slen - strlen(stag)] = '\0';
hasU = isuinttype(tag); hasU = isuinttype(tag);
if(!tstdecimal(c)) {
pos = ncgtext+1; /* Capture the sign, if any */
isneg = (c == '-'); isneg = (c == '-');
} else /* skip leading sign */
pos = ncgtext; if(c == '-' || c == '+')
pos++;
c = pos[0];
if(tstoctal(c))
radix = 8;
else
radix = 10;
if(isneg && hasU) { if(isneg && hasU) {
sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext); sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
yyerror(errstr); yyerror(errstr);
goto done; goto done;
} }
uint64_val = parseULL(pos,&fail); uint64_val = parseULL(radix, pos,&fail);
if(fail) { if(fail) {
sprintf(errstr,"integer constant out of range: %s",ncgtext); sprintf(errstr,"integer constant out of range: %s",ncgtext);
yyerror(errstr); yyerror(errstr);
@ -648,24 +662,26 @@ Parse a simple string of digits into an unsigned long long
Return the value. Return the value.
*/ */
static unsigned long long static unsigned long long
parseULL(char* text, int* failp) parseULL(int radix, char* text, int* failp)
{ {
extern int errno; extern int errno;
char* endptr; char* endptr;
unsigned long long uint64 = 0; unsigned long long uint64 = 0;
errno = 0; endptr = NULL; errno = 0; endptr = NULL;
assert(tstdecimal(text[0]));
#ifdef HAVE_STRTOULL #ifdef HAVE_STRTOULL
uint64 = strtoull(text,&endptr,10); uint64 = strtoull(text,&endptr,radix);
if(errno == ERANGE) { if(errno == ERANGE) {
if(failp) *failp = ERANGE; if(failp) *failp = ERANGE;
return 0; return 0;
} }
#else /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/ #else /*!defined HAVE_STRTOULL*/
sscanf((char*)text, "%llu", &uint64);
/* Have no useful way to detect out of range */ /* Have no useful way to detect out of range */
#endif /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/ if(radix == 8)
sscanf((char*)text, "%llo", &uint64);
else
sscanf((char*)text, "%llu", &uint64);
#endif /*!defined HAVE_STRTOULL*/
return uint64; return uint64;
} }

View File

@ -1464,6 +1464,7 @@ static unsigned int MAX_UINT = NC_MAX_UINT;
#define TAGCHARS "BbSsLlUu" #define TAGCHARS "BbSsLlUu"
#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9') #define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
#define tstoctal(ch) ((ch) == '0')
/*Mnemonics*/ /*Mnemonics*/
#define ISIDENT 1 #define ISIDENT 1
@ -1497,7 +1498,7 @@ unsigned char ubyte_val; /* last byte value read */
static Symbol* makepath(char* text); static Symbol* makepath(char* text);
static int lexdebug(int); static int lexdebug(int);
static unsigned long long parseULL(char* text, int*); static unsigned long long parseULL(int radix, char* text, int*);
static nc_type downconvert(unsigned long long uint64, int*, int, int); static nc_type downconvert(unsigned long long uint64, int*, int, int);
static int tagmatch(nc_type nct, int tag); static int tagmatch(nc_type nct, int tag);
static int nct2lexeme(nc_type nct); static int nct2lexeme(nc_type nct);
@ -1520,7 +1521,7 @@ struct Specialtoken specials[] = {
{NULL,0} /* null terminate */ {NULL,0} /* null terminate */
}; };
#line 1523 "ncgenl.c" #line 1524 "ncgenl.c"
/* The most correct (validating) version of UTF8 character set /* The most correct (validating) version of UTF8 character set
(Taken from: http://www.w3.org/2005/03/23-lex-U) (Taken from: http://www.w3.org/2005/03/23-lex-U)
@ -1563,7 +1564,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well, /* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition although it is a very relaxed definition
*/ */
#line 1566 "ncgenl.c" #line 1567 "ncgenl.c"
#define INITIAL 0 #define INITIAL 0
#define ST_C_COMMENT 1 #define ST_C_COMMENT 1
@ -1782,9 +1783,9 @@ YY_DECL
} }
{ {
#line 220 "ncgen.l" #line 221 "ncgen.l"
#line 1787 "ncgenl.c" #line 1788 "ncgenl.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{ {
@ -1843,14 +1844,14 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 221 "ncgen.l" #line 222 "ncgen.l"
{ /* whitespace */ { /* whitespace */
break; break;
} }
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 225 "ncgen.l" #line 226 "ncgen.l"
{ /* comment */ { /* comment */
break; break;
} }
@ -1858,7 +1859,7 @@ YY_RULE_SETUP
case 3: case 3:
/* rule 3 can match eol */ /* rule 3 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 229 "ncgen.l" #line 230 "ncgen.l"
{int len; char* s = NULL; {int len; char* s = NULL;
/* In netcdf4, this will be used in a variety /* In netcdf4, this will be used in a variety
of places, so only remove escapes */ of places, so only remove escapes */
@ -1882,7 +1883,7 @@ yytext[MAXTRST-1] = '\0';
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 250 "ncgen.l" #line 251 "ncgen.l"
{ /* drop leading 0x; pad to even number of chars */ { /* drop leading 0x; pad to even number of chars */
char* p = yytext+2; char* p = yytext+2;
int len = yyleng - 2; int len = yyleng - 2;
@ -1897,118 +1898,118 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 262 "ncgen.l" #line 263 "ncgen.l"
{return lexdebug(COMPOUND);} {return lexdebug(COMPOUND);}
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 263 "ncgen.l" #line 264 "ncgen.l"
{return lexdebug(ENUM);} {return lexdebug(ENUM);}
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 264 "ncgen.l" #line 265 "ncgen.l"
{return lexdebug(OPAQUE_);} {return lexdebug(OPAQUE_);}
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 266 "ncgen.l" #line 267 "ncgen.l"
{return lexdebug(FLOAT_K);} {return lexdebug(FLOAT_K);}
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 267 "ncgen.l" #line 268 "ncgen.l"
{return lexdebug(CHAR_K);} {return lexdebug(CHAR_K);}
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 268 "ncgen.l" #line 269 "ncgen.l"
{return lexdebug(BYTE_K);} {return lexdebug(BYTE_K);}
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 269 "ncgen.l" #line 270 "ncgen.l"
{return lexdebug(UBYTE_K);} {return lexdebug(UBYTE_K);}
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 270 "ncgen.l" #line 271 "ncgen.l"
{return lexdebug(SHORT_K);} {return lexdebug(SHORT_K);}
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 271 "ncgen.l" #line 272 "ncgen.l"
{return lexdebug(USHORT_K);} {return lexdebug(USHORT_K);}
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 272 "ncgen.l" #line 273 "ncgen.l"
{return lexdebug(INT_K);} {return lexdebug(INT_K);}
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 273 "ncgen.l" #line 274 "ncgen.l"
{return lexdebug(UINT_K);} {return lexdebug(UINT_K);}
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 274 "ncgen.l" #line 275 "ncgen.l"
{return lexdebug(INT64_K);} {return lexdebug(INT64_K);}
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 275 "ncgen.l" #line 276 "ncgen.l"
{return lexdebug(UINT64_K);} {return lexdebug(UINT64_K);}
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 276 "ncgen.l" #line 277 "ncgen.l"
{return lexdebug(DOUBLE_K);} {return lexdebug(DOUBLE_K);}
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 277 "ncgen.l" #line 278 "ncgen.l"
{return lexdebug(STRING_K);} {return lexdebug(STRING_K);}
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 279 "ncgen.l" #line 280 "ncgen.l"
{int32_val = -1; {int32_val = -1;
return lexdebug(NC_UNLIMITED_K);} return lexdebug(NC_UNLIMITED_K);}
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 282 "ncgen.l" #line 283 "ncgen.l"
{return lexdebug(TYPES);} {return lexdebug(TYPES);}
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 283 "ncgen.l" #line 284 "ncgen.l"
{return lexdebug(DIMENSIONS);} {return lexdebug(DIMENSIONS);}
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 284 "ncgen.l" #line 285 "ncgen.l"
{return lexdebug(VARIABLES);} {return lexdebug(VARIABLES);}
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 285 "ncgen.l" #line 286 "ncgen.l"
{return lexdebug(DATA);} {return lexdebug(DATA);}
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 286 "ncgen.l" #line 287 "ncgen.l"
{return lexdebug(GROUP);} {return lexdebug(GROUP);}
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 288 "ncgen.l" #line 289 "ncgen.l"
{BEGIN(TEXT);return lexdebug(NETCDF);} {BEGIN(TEXT);return lexdebug(NETCDF);}
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 290 "ncgen.l" #line 291 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */ { /* missing value (pre-2.4 backward compatibility) */
if (yytext[0] == '-') { if (yytext[0] == '-') {
double_val = NEGNC_INFINITE; double_val = NEGNC_INFINITE;
@ -2021,7 +2022,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 299 "ncgen.l" #line 300 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */ { /* missing value (pre-2.4 backward compatibility) */
double_val = NAN; double_val = NAN;
specialconstants = 1; specialconstants = 1;
@ -2030,7 +2031,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 305 "ncgen.l" #line 306 "ncgen.l"
{/* missing value (pre-2.4 backward compatibility)*/ {/* missing value (pre-2.4 backward compatibility)*/
if (yytext[0] == '-') { if (yytext[0] == '-') {
float_val = NEGNC_INFINITEF; float_val = NEGNC_INFINITEF;
@ -2043,7 +2044,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 314 "ncgen.l" #line 315 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */ { /* missing value (pre-2.4 backward compatibility) */
float_val = NANF; float_val = NANF;
specialconstants = 1; specialconstants = 1;
@ -2052,7 +2053,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 320 "ncgen.l" #line 321 "ncgen.l"
{ {
#ifdef USE_NETCDF4 #ifdef USE_NETCDF4
if(l_flag == L_C || l_flag == L_BINARY) if(l_flag == L_C || l_flag == L_BINARY)
@ -2065,7 +2066,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 330 "ncgen.l" #line 331 "ncgen.l"
{ {
bbClear(lextext); bbClear(lextext);
bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */
@ -2076,7 +2077,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
#line 339 "ncgen.l" #line 340 "ncgen.l"
{struct Specialtoken* st; {struct Specialtoken* st;
bbClear(lextext); bbClear(lextext);
bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */
@ -2090,7 +2091,7 @@ YY_RULE_SETUP
case 34: case 34:
/* rule 34 can match eol */ /* rule 34 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 349 "ncgen.l" #line 350 "ncgen.l"
{ {
int c; int c;
char* p; char* q; char* p; char* q;
@ -2110,7 +2111,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 366 "ncgen.l" #line 367 "ncgen.l"
{ char* id = NULL; int len; { char* id = NULL; int len;
len = strlen(yytext); len = strlen(yytext);
len = unescape(yytext,len,ISIDENT,&id); len = unescape(yytext,len,ISIDENT,&id);
@ -2125,12 +2126,13 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 378 "ncgen.l" #line 379 "ncgen.l"
{ {
/* /*
We need to try to see what size of integer ((u)int). We need to try to see what size of integer ((u)int).
Technically, the user should specify, but... Technically, the user should specify, but...
If out of any integer range, then complain If out of any integer range, then complain
Also, if the digits begin with 0, then assume octal.
*/ */
int slen = strlen(ncgtext); int slen = strlen(ncgtext);
char* stag = NULL; char* stag = NULL;
@ -2141,28 +2143,40 @@ YY_RULE_SETUP
nc_type nct = 0; nc_type nct = 0;
char* pos = NULL; char* pos = NULL;
int hasU = 0; int hasU = 0;
int radix = 10;
pos = ncgtext;
/* capture the tag string */ /* capture the tag string */
tag = collecttag(ncgtext,&stag); tag = collecttag(pos,&stag);
if(tag == NC_NAT) { if(tag == NC_NAT) {
sprintf(errstr,"Illegal integer suffix: %s",stag); sprintf(errstr,"Illegal integer suffix: %s",stag);
yyerror(errstr); yyerror(errstr);
goto done; goto done;
} }
/* drop the tag from the input text */ /* drop the tag from the input text */
ncgtext[slen - strlen(stag)] = '\0'; ncgtext[slen - strlen(stag)] = '\0';
hasU = isuinttype(tag); hasU = isuinttype(tag);
if(!tstdecimal(c)) {
pos = ncgtext+1; /* Capture the sign, if any */
isneg = (c == '-'); isneg = (c == '-');
} else /* skip leading sign */
pos = ncgtext; if(c == '-' || c == '+')
pos++;
c = pos[0];
if(tstoctal(c))
radix = 8;
else
radix = 10;
if(isneg && hasU) { if(isneg && hasU) {
sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext); sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
yyerror(errstr); yyerror(errstr);
goto done; goto done;
} }
uint64_val = parseULL(pos,&fail); uint64_val = parseULL(radix, pos,&fail);
if(fail) { if(fail) {
sprintf(errstr,"integer constant out of range: %s",ncgtext); sprintf(errstr,"integer constant out of range: %s",ncgtext);
yyerror(errstr); yyerror(errstr);
@ -2193,7 +2207,7 @@ done: return 0;
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 443 "ncgen.l" #line 457 "ncgen.l"
{ {
int c; int c;
int token = 0; int token = 0;
@ -2244,7 +2258,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 490 "ncgen.l" #line 504 "ncgen.l"
{ {
if (sscanf((char*)yytext, "%le", &double_val) != 1) { if (sscanf((char*)yytext, "%le", &double_val) != 1) {
sprintf(errstr,"bad long or double constant: %s",(char*)yytext); sprintf(errstr,"bad long or double constant: %s",(char*)yytext);
@ -2255,7 +2269,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 497 "ncgen.l" #line 511 "ncgen.l"
{ {
if (sscanf((char*)yytext, "%e", &float_val) != 1) { if (sscanf((char*)yytext, "%e", &float_val) != 1) {
sprintf(errstr,"bad float constant: %s",(char*)yytext); sprintf(errstr,"bad float constant: %s",(char*)yytext);
@ -2267,7 +2281,7 @@ YY_RULE_SETUP
case 40: case 40:
/* rule 40 can match eol */ /* rule 40 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 504 "ncgen.l" #line 518 "ncgen.l"
{ {
(void) sscanf((char*)&yytext[1],"%c",&byte_val); (void) sscanf((char*)&yytext[1],"%c",&byte_val);
return lexdebug(BYTE_CONST); return lexdebug(BYTE_CONST);
@ -2275,7 +2289,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 508 "ncgen.l" #line 522 "ncgen.l"
{ {
int oct = unescapeoct(&yytext[2]); int oct = unescapeoct(&yytext[2]);
if(oct < 0) { if(oct < 0) {
@ -2288,7 +2302,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 42: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 517 "ncgen.l" #line 531 "ncgen.l"
{ {
int hex = unescapehex(&yytext[3]); int hex = unescapehex(&yytext[3]);
if(byte_val < 0) { if(byte_val < 0) {
@ -2301,7 +2315,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 43: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 526 "ncgen.l" #line 540 "ncgen.l"
{ {
switch ((char)yytext[2]) { switch ((char)yytext[2]) {
case 'a': byte_val = '\007'; break; /* not everyone under- case 'a': byte_val = '\007'; break; /* not everyone under-
@ -2323,7 +2337,7 @@ YY_RULE_SETUP
case 44: case 44:
/* rule 44 can match eol */ /* rule 44 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 544 "ncgen.l" #line 558 "ncgen.l"
{ {
lineno++ ; lineno++ ;
break; break;
@ -2331,7 +2345,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 45: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 549 "ncgen.l" #line 563 "ncgen.l"
{/*initial*/ {/*initial*/
BEGIN(ST_C_COMMENT); BEGIN(ST_C_COMMENT);
break; break;
@ -2340,21 +2354,21 @@ YY_RULE_SETUP
case 46: case 46:
/* rule 46 can match eol */ /* rule 46 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 554 "ncgen.l" #line 568 "ncgen.l"
{/* continuation */ {/* continuation */
break; break;
} }
YY_BREAK YY_BREAK
case 47: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 558 "ncgen.l" #line 572 "ncgen.l"
{/* final */ {/* final */
BEGIN(INITIAL); BEGIN(INITIAL);
break; break;
} }
YY_BREAK YY_BREAK
case YY_STATE_EOF(ST_C_COMMENT): case YY_STATE_EOF(ST_C_COMMENT):
#line 563 "ncgen.l" #line 577 "ncgen.l"
{/* final, error */ {/* final, error */
fprintf(stderr,"unterminated /**/ comment"); fprintf(stderr,"unterminated /**/ comment");
BEGIN(INITIAL); BEGIN(INITIAL);
@ -2363,17 +2377,17 @@ case YY_STATE_EOF(ST_C_COMMENT):
YY_BREAK YY_BREAK
case 48: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 569 "ncgen.l" #line 583 "ncgen.l"
{/* Note: this next rule will not work for UTF8 characters */ {/* Note: this next rule will not work for UTF8 characters */
return lexdebug(yytext[0]) ; return lexdebug(yytext[0]) ;
} }
YY_BREAK YY_BREAK
case 49: case 49:
YY_RULE_SETUP YY_RULE_SETUP
#line 572 "ncgen.l" #line 586 "ncgen.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 2376 "ncgenl.c" #line 2390 "ncgenl.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT): case YY_STATE_EOF(TEXT):
yyterminate(); yyterminate();
@ -3379,7 +3393,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 572 "ncgen.l" #line 586 "ncgen.l"
static int static int
lexdebug(int token) lexdebug(int token)
@ -3459,24 +3473,26 @@ Parse a simple string of digits into an unsigned long long
Return the value. Return the value.
*/ */
static unsigned long long static unsigned long long
parseULL(char* text, int* failp) parseULL(int radix, char* text, int* failp)
{ {
extern int errno; extern int errno;
char* endptr; char* endptr;
unsigned long long uint64 = 0; unsigned long long uint64 = 0;
errno = 0; endptr = NULL; errno = 0; endptr = NULL;
assert(tstdecimal(text[0]));
#ifdef HAVE_STRTOULL #ifdef HAVE_STRTOULL
uint64 = strtoull(text,&endptr,10); uint64 = strtoull(text,&endptr,radix);
if(errno == ERANGE) { if(errno == ERANGE) {
if(failp) *failp = ERANGE; if(failp) *failp = ERANGE;
return 0; return 0;
} }
#else /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/ #else /*!defined HAVE_STRTOULL*/
sscanf((char*)text, "%llu", &uint64);
/* Have no useful way to detect out of range */ /* Have no useful way to detect out of range */
#endif /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/ if(radix == 8)
sscanf((char*)text, "%llo", &uint64);
else
sscanf((char*)text, "%llu", &uint64);
#endif /*!defined HAVE_STRTOULL*/
return uint64; return uint64;
} }

View File

@ -9,5 +9,5 @@ Description: NetCDF Client Library for C
URL: http://www.unidata.ucar.edu/netcdf URL: http://www.unidata.ucar.edu/netcdf
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@
Libs: -L${libdir} @NC_LIBS@ Libs: -L${libdir} @NC_LIBS@
Libs.private: @LIBS@
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -7,6 +8,8 @@
/* Older versions of the hdf library may define H5PL_type_t here */ /* Older versions of the hdf library may define H5PL_type_t here */
#include <H5PLextern.h> #include <H5PLextern.h>
#ifndef DLL_EXPORT #ifndef DLL_EXPORT
#define DLL_EXPORT #define DLL_EXPORT
#endif #endif
@ -90,7 +93,11 @@ size_t H5Z_filter_bzip2(unsigned int flags, size_t cd_nelmts,
/* Prepare the output buffer. */ /* Prepare the output buffer. */
outbuflen = nbytes * 3 + 1; /* average bzip2 compression ratio is 3:1 */ outbuflen = nbytes * 3 + 1; /* average bzip2 compression ratio is 3:1 */
#ifdef HDF5_HAS_ALLOCATE_MEMORY
outbuf = H5allocate_memory(outbuflen,0); outbuf = H5allocate_memory(outbuflen,0);
#else
outbuf = (char*)malloc(outbuflen * sizeof(char));
#endif
if (outbuf == NULL) { if (outbuf == NULL) {
fprintf(stderr, "memory allocation failed for bzip2 decompression\n"); fprintf(stderr, "memory allocation failed for bzip2 decompression\n");
goto cleanupAndFail; goto cleanupAndFail;
@ -123,7 +130,11 @@ size_t H5Z_filter_bzip2(unsigned int flags, size_t cd_nelmts,
if (ret != BZ_STREAM_END && stream.avail_out == 0) { if (ret != BZ_STREAM_END && stream.avail_out == 0) {
/* Grow the output buffer. */ /* Grow the output buffer. */
newbuflen = outbuflen * 2; newbuflen = outbuflen * 2;
#ifdef HDF5_HAS_RESIZE_MEMORY
newbuf = H5resize_memory(outbuf, newbuflen); newbuf = H5resize_memory(outbuf, newbuflen);
#else
newbuf = realloc(outbuf,newbuflen);
#endif
if (newbuf == NULL) { if (newbuf == NULL) {
fprintf(stderr, "memory allocation failed for bzip2 decompression\n"); fprintf(stderr, "memory allocation failed for bzip2 decompression\n");
goto cleanupAndFail; goto cleanupAndFail;
@ -167,7 +178,12 @@ size_t H5Z_filter_bzip2(unsigned int flags, size_t cd_nelmts,
/* Prepare the output buffer. */ /* Prepare the output buffer. */
outbuflen = nbytes + nbytes / 100 + 600; /* worst case (bzip2 docs) */ outbuflen = nbytes + nbytes / 100 + 600; /* worst case (bzip2 docs) */
#ifdef HDF5_HAS_ALLOCATE_MEMORY
outbuf = H5allocate_memory(outbuflen,0); outbuf = H5allocate_memory(outbuflen,0);
#else
outbuf = (char*)malloc(outbuflen * sizeof(char));
#endif
if (outbuf == NULL) { if (outbuf == NULL) {
fprintf(stderr, "memory allocation failed for bzip2 compression\n"); fprintf(stderr, "memory allocation failed for bzip2 compression\n");
goto cleanupAndFail; goto cleanupAndFail;
@ -185,13 +201,23 @@ size_t H5Z_filter_bzip2(unsigned int flags, size_t cd_nelmts,
} }
/* Always replace the input buffer with the output buffer. */ /* Always replace the input buffer with the output buffer. */
#ifdef HDF5_HAS_H5FREE
H5free_memory(*buf); H5free_memory(*buf);
#else
free(*buf);
#endif
*buf = outbuf; *buf = outbuf;
*buf_size = outbuflen; *buf_size = outbuflen;
return outdatalen; return outdatalen;
cleanupAndFail: cleanupAndFail:
if (outbuf) if (outbuf)
#ifdef HDF5_HAS_H5FREE
H5free_memory(outbuf); H5free_memory(outbuf);
#else
free(outbuf);
#endif
return 0; return 0;
} }

View File

@ -1,3 +1,4 @@
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
@ -109,21 +110,37 @@ H5Z_filter_test(unsigned int flags, size_t cd_nelmts,
if (flags & H5Z_FLAG_REVERSE) { if (flags & H5Z_FLAG_REVERSE) {
/* Replace buffer */ /* Replace buffer */
#ifdef HDF5_HAS_ALLOCATE_MEMORY
newbuf = H5allocate_memory(*buf_size,0); newbuf = H5allocate_memory(*buf_size,0);
#else
newbuf = malloc(*buf_size * sizeof(void));
#endif
if(newbuf == NULL) abort(); if(newbuf == NULL) abort();
memcpy(newbuf,*buf,*buf_size); memcpy(newbuf,*buf,*buf_size);
/* reclaim old buffer */ /* reclaim old buffer */
#ifdef HDF5_HAS_H5FREE
H5free_memory(*buf); H5free_memory(*buf);
#else
free(*buf);
#endif
*buf = newbuf; *buf = newbuf;
} else { } else {
/* Replace buffer */ /* Replace buffer */
#ifdef HDF5_HAS_ALLOCATE_MEMORY
newbuf = H5allocate_memory(*buf_size,0); newbuf = H5allocate_memory(*buf_size,0);
#else
newbuf = malloc(*buf_size * sizeof(void));
#endif
if(newbuf == NULL) abort(); if(newbuf == NULL) abort();
memcpy(newbuf,*buf,*buf_size); memcpy(newbuf,*buf,*buf_size);
/* reclaim old buffer */ /* reclaim old buffer */
#ifdef HDF5_HAS_H5FREE
H5free_memory(*buf); H5free_memory(*buf);
#else
free(*buf);
#endif
*buf = newbuf; *buf = newbuf;
} }

View File

@ -48,9 +48,8 @@ byteswap4(unsigned char* mem)
void void
NC_filterfix8(void* mem0, int decode) NC_filterfix8(void* mem0, int decode)
{ {
unsigned char* mem = mem0;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
unsigned char* mem = mem0;
if(decode) { /* Apply inverse of the encode case */ if(decode) { /* Apply inverse of the encode case */
byteswap4(mem); /* step 1: byte-swap each piece */ byteswap4(mem); /* step 1: byte-swap each piece */
byteswap4(mem+4); byteswap4(mem+4);
@ -61,8 +60,6 @@ unsigned char* mem = mem0;
byteswap4(mem+4); byteswap4(mem+4);
} }
#else /* Little endian */ #else /* Little endian */
/* No action is necessary */ /* No action is necessary */
#endif #endif
} }

View File

@ -1,6 +1,9 @@
# Copyright 2018, UCAR/Unidata # Copyright 2018, UCAR/Unidata
# See netcdf/COPYRIGHT file for copying and redistribution conditions. # See netcdf/COPYRIGHT file for copying and redistribution conditions.
# Put Together AM_CPPFLAGS and AM_LDFLAGS
include $(top_srcdir)/lib_flags.am
BZIP2HDRS=bzlib.h bzlib_private.h BZIP2HDRS=bzlib.h bzlib_private.h
BZIP2SRC= blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c BZIP2SRC= blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c