mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Merge branch 'master' into byterange.dmh
This commit is contained in:
commit
e2b31ffae4
@ -37,4 +37,4 @@ before_install:
|
||||
|
||||
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
|
||||
|
@ -26,13 +26,13 @@ set(PACKAGE "netCDF" CACHE STRING "")
|
||||
|
||||
SET(NC_VERSION_MAJOR 4)
|
||||
SET(NC_VERSION_MINOR 6)
|
||||
SET(NC_VERSION_PATCH 3)
|
||||
SET(NC_VERSION_PATCH 4)
|
||||
SET(NC_VERSION_NOTE "-development")
|
||||
SET(netCDF_VERSION ${NC_VERSION_MAJOR}.${NC_VERSION_MINOR}.${NC_VERSION_PATCH}${NC_VERSION_NOTE})
|
||||
SET(VERSION ${netCDF_VERSION})
|
||||
SET(NC_VERSION ${netCDF_VERSION})
|
||||
SET(netCDF_LIB_VERSION 13)
|
||||
SET(netCDF_SO_VERSION 13)
|
||||
SET(netCDF_LIB_VERSION 15)
|
||||
SET(netCDF_SO_VERSION 15)
|
||||
SET(PACKAGE_VERSION ${VERSION})
|
||||
|
||||
# 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} 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)
|
||||
SET(HDF5_CC h5pcc)
|
||||
@ -1862,7 +1864,7 @@ FOREACH(_LIB ${ALL_TLL_LIBS})
|
||||
LIST(APPEND LINKFLAGS "-L${_LIB_DIR}")
|
||||
ENDFOREACH()
|
||||
|
||||
SET(NC_LIBS "-lnetcdf ${NC_LIBS}")
|
||||
#SET(NC_LIBS "-lnetcdf ${NC_LIBS}")
|
||||
|
||||
STRING(REPLACE ";" " " 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 LINKFLAGS)
|
||||
|
||||
SET(LIBS ${NC_LIBS})
|
||||
SET(NC_LIBS "-lnetcdf")
|
||||
|
||||
configure_file(
|
||||
${netCDF_SOURCE_DIR}/netcdf.pc.in
|
||||
${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_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_NETCDF_4 HAS_NC4)
|
||||
is_enabled(ENABLE_HDF4 HAS_HDF4)
|
||||
|
@ -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.
|
||||
|
||||
## 4.6.3 - TBD
|
||||
|
||||
## 4.6.4 - TBD
|
||||
|
||||
* [Enhancement] Provide byte-range reading of remote datasets. This allows
|
||||
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.
|
||||
|
||||
### 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.
|
||||
* [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.
|
||||
* [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.
|
||||
|
@ -370,6 +370,12 @@ are set when opening a binary file on Windows. */
|
||||
nc4file. */
|
||||
#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 */
|
||||
#cmakedefine HDF5_PARALLEL 1
|
||||
|
||||
|
14
configure.ac
14
configure.ac
@ -13,7 +13,7 @@
|
||||
AC_PREREQ([2.59])
|
||||
|
||||
# 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.
|
||||
@ -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_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"
|
||||
|
||||
#####
|
||||
@ -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.
|
||||
# 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)
|
||||
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.])
|
||||
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
|
||||
AC_DEFINE([HDF5_HAS_LIBVER_BOUNDS], [1], [if true, netcdf4 file properties will be set using H5Pset_libver_bounds])
|
||||
fi
|
||||
|
@ -38,7 +38,7 @@ PROJECT_NAME = netCDF-C
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.6.3-development
|
||||
PROJECT_NUMBER = 4.6.4-development
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@ -8,7 +8,6 @@
|
||||
- \subpage netcdf_data_set_components
|
||||
- \subpage netcdf_perf_chunking
|
||||
- \subpage netcdf_utilities_guide
|
||||
- \subpage compress
|
||||
- \subpage BestPractices
|
||||
- \subpage user_defined_formats
|
||||
- \subpage users_guide_appendices
|
||||
@ -48,7 +47,10 @@ web site (http://www.unidata.ucar.edu/netcdf), and with the netCDF
|
||||
distribution.
|
||||
|
||||
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
|
||||
http://www.unidata.ucar.edu/software/netcdf-java/.
|
||||
@ -88,8 +90,10 @@ were written.
|
||||
|
||||
Unidata supports the netCDF interfaces for C (see <a
|
||||
href="http://www.unidata.ucar.edu/netcdf/docs/" >NetCDF-C User's
|
||||
Guide</a>), Fortran (see <a 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"
|
||||
Guide</a>), Fortran (see <a
|
||||
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>).
|
||||
|
||||
The netCDF library is supported for various UNIX operating systems. A
|
||||
|
@ -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
|
||||
*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
|
||||
is read-only, then a call to, for example, _nc_def_dim()_ will fail.
|
||||
file is writeable through the netCDF API, but on disk, the file is
|
||||
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 contents of memory might be persisted.
|
||||
|
||||
|
@ -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(). */
|
||||
|
||||
/** Turn on MPI I/O.
|
||||
Use this in mode flags for both nc_create() and nc_open(). */
|
||||
/** The following 3 flags are deprecated as of 4.6.2. Parallel I/O is now
|
||||
* initiated by calling nc_create_par and nc_open_par, no longer by flags.
|
||||
*/
|
||||
#define NC_MPIIO 0x2000 /**< \deprecated */
|
||||
/** Turn on MPI POSIX I/O.
|
||||
Use this in mode flags for both nc_create() and nc_open(). */
|
||||
#define NC_MPIPOSIX NC_MPIIO /**< \deprecated As of libhdf5 1.8.13. Now an alias */
|
||||
#define NC_MPIPOSIX NC_MPIIO /**< \deprecated */
|
||||
#define NC_PNETCDF (NC_MPIIO) /**< \deprecated */
|
||||
|
||||
#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_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. */
|
||||
|
||||
/** Format specifier for nc_set_default_format() and returned
|
||||
|
@ -1,125 +1,122 @@
|
||||
/** \file
|
||||
Dimension functions
|
||||
/* Copyright 2018 University Corporation for Atmospheric
|
||||
Research/Unidata. See COPYRIGHT file for more info. */
|
||||
/**
|
||||
@file
|
||||
|
||||
These functions define and inquire about dimensions.
|
||||
|
||||
Copyright 2018 University Corporation for Atmospheric
|
||||
Research/Unidata. See COPYRIGHT file for more info.
|
||||
The functions in this file define, inquire about, and rename
|
||||
dimensions.
|
||||
*/
|
||||
|
||||
#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
|
||||
the netCDF dataset is in define mode. Additional dimensions may be
|
||||
added later by reentering define mode. A netCDF dimension has a name
|
||||
and a length. In a netCDF classic or 64-bit offset file, at most one
|
||||
dimension can have the unlimited length, which means variables using
|
||||
this dimension can grow along this dimension. In a netCDF-4 file
|
||||
multiple unlimited dimensions are supported.
|
||||
Dimensions for a netCDF dataset are defined when it is created,
|
||||
while the netCDF dataset is in define mode. Additional dimensions
|
||||
may be added later by reentering define mode. A netCDF dimension
|
||||
has a name and a length. In a netCDF classic or 64-bit offset file,
|
||||
at most one dimension can have the unlimited length, which means
|
||||
variables using this dimension can grow along this dimension. In a
|
||||
netCDF-4 file multiple unlimited dimensions are supported.
|
||||
|
||||
There is a suggested limit (1024) to the number of dimensions that can
|
||||
be defined in a single netCDF dataset. The limit is the value of the
|
||||
predefined macro NC_MAX_DIMS. The purpose of the limit is to make
|
||||
writing generic applications simpler. They need only provide an array
|
||||
of NC_MAX_DIMS dimensions to handle any netCDF dataset. The
|
||||
implementation of the netCDF library does not enforce this advisory
|
||||
maximum, so it is possible to use more dimensions, if necessary, but
|
||||
netCDF utilities that assume the advisory maximums may not be able to
|
||||
handle the resulting netCDF datasets.
|
||||
There is a suggested limit (1024) to the number of dimensions that
|
||||
can be defined in a single netCDF dataset. The limit is the value
|
||||
of the predefined macro ::NC_MAX_DIMS. The purpose of the limit is
|
||||
to make writing generic applications simpler. They need only
|
||||
provide an array of ::NC_MAX_DIMS dimensions to handle any netCDF
|
||||
dataset. The implementation of the netCDF library does not enforce
|
||||
this advisory maximum, so it is possible to use more dimensions, if
|
||||
necessary, but netCDF utilities that assume the advisory maximums
|
||||
may not be able to handle the resulting netCDF datasets.
|
||||
|
||||
NC_MAX_VAR_DIMS, which must not exceed NC_MAX_DIMS, is the maximum
|
||||
number of dimensions that can be used to specify the shape of a single
|
||||
variable. It is also intended to simplify writing generic
|
||||
applications.
|
||||
::NC_MAX_VAR_DIMS, which must not exceed ::NC_MAX_DIMS, is the
|
||||
maximum number of dimensions that can be used to specify the shape
|
||||
of a single variable. It is also intended to simplify writing
|
||||
generic applications.
|
||||
|
||||
Ordinarily, the name and length of a dimension are fixed when the
|
||||
dimension is first defined. The name may be changed later, but the
|
||||
length of a dimension (other than the unlimited dimension) cannot be
|
||||
changed without copying all the data to a new netCDF dataset with a
|
||||
redefined dimension length.
|
||||
Ordinarily, the name and length of a dimension are fixed when the
|
||||
dimension is first defined. The name may be changed later, but the
|
||||
length of a dimension (other than the unlimited dimension) cannot
|
||||
be changed without copying all the data to a new netCDF dataset
|
||||
with a redefined dimension length.
|
||||
|
||||
Dimension lengths in the C interface are type size_t rather than type
|
||||
int to make it possible to access all the data in a netCDF dataset on
|
||||
a platform that only supports a 16-bit int data type, for example
|
||||
MSDOS. If dimension lengths were type int instead, it would not be
|
||||
possible to access data from variables with a dimension length greater
|
||||
than a 16-bit int can accommodate.
|
||||
Dimension lengths in the C interface are type size_t rather than
|
||||
type int to make it possible to access all the data in a netCDF
|
||||
dataset on a platform that only supports a 16-bit int data type,
|
||||
for example MSDOS. If dimension lengths were type int instead, it
|
||||
would not be possible to access data from variables with a
|
||||
dimension length greater than a 16-bit int can accommodate.
|
||||
|
||||
A netCDF dimension in an open netCDF dataset is referred to by a small
|
||||
integer called a dimension ID. In the C interface, dimension IDs are
|
||||
0, 1, 2, ..., in the order in which the dimensions were defined.
|
||||
|
||||
Operations supported on dimensions are:
|
||||
- Create a dimension, given its name and length.
|
||||
- Get a dimension ID from its name.
|
||||
- Get a dimension's name and length from its ID.
|
||||
- Rename a dimension.
|
||||
A netCDF dimension in an open netCDF dataset is referred to by a
|
||||
small integer called a dimension ID. In the C interface, dimension
|
||||
IDs are 0, 1, 2, ..., in the order in which the dimensions were
|
||||
defined.
|
||||
|
||||
Operations supported on dimensions are:
|
||||
- Create a dimension, given its name and length.
|
||||
- Get a dimension ID from its name.
|
||||
- Get a dimension's name and length from its ID.
|
||||
- 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
|
||||
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
|
||||
the dimension length. At most one unlimited length dimension, called
|
||||
the record dimension, may be defined for each classic or 64-bit offset
|
||||
netCDF dataset. NetCDF-4 datasets may have multiple unlimited
|
||||
dimensions.
|
||||
|
||||
Functions to delete or rename an dimension. */
|
||||
/*! \{ */ /* All these functions are part of this named group... */
|
||||
@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_inq_ncid().
|
||||
@param name Name of the dimension to be created.
|
||||
@param len Length of the dimension to be created. Use NC_UNLIMITED for
|
||||
unlimited dimensions.
|
||||
@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
|
||||
|
||||
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
|
||||
argument) a dimension ID, given the netCDF ID, the dimension name, and
|
||||
the dimension length. At most one unlimited length dimension, called
|
||||
the record dimension, may be defined for each classic or 64-bit offset
|
||||
netCDF dataset. NetCDF-4 datasets may have multiple unlimited
|
||||
dimensions.
|
||||
@section nc_def_dim_example Example
|
||||
|
||||
\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_inq_ncid().
|
||||
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
|
||||
named foo.nc:
|
||||
|
||||
\param name Name of the dimension to be created.
|
||||
@code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
...
|
||||
status = nc_create("foo.nc", NC_NOCLOBBER, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_def_dim(ncid, "lat", 18L, &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_def_dim(ncid, "rec", NC_UNLIMITED, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
@endcode
|
||||
|
||||
\param len Length of the dimension to be created. Use NC_UNLIMITED for
|
||||
unlimited dimensions.
|
||||
|
||||
\param idp Pointer where dimension ID will be stored.
|
||||
|
||||
\retval ::NC_NOERR No error.
|
||||
\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
|
||||
length 18 and a unlimited dimension named rec in a new netCDF dataset
|
||||
named foo.nc:
|
||||
|
||||
\code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
...
|
||||
status = nc_create("foo.nc", NC_NOCLOBBER, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_def_dim(ncid, "lat", 18L, &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_def_dim(ncid, "rec", NC_UNLIMITED, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
\endcode
|
||||
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_def_dim(int ncid, const char *name, size_t len, int *idp)
|
||||
{
|
||||
@ -130,26 +127,27 @@ nc_def_dim(int ncid, const char *name, size_t len, int *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
|
||||
dimension, given the name of the dimension. If ndims is the number of
|
||||
dimensions defined for a netCDF dataset, each dimension has an ID
|
||||
between 0 and ndims-1.
|
||||
The function nc_inq_dimid returns (as an argument) the ID of a
|
||||
netCDF dimension, given the name of the dimension. If ndims is the
|
||||
number of dimensions defined for a netCDF dataset, each dimension
|
||||
has an ID between 0 and ndims-1.
|
||||
|
||||
\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_inq_ncid().
|
||||
@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_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.
|
||||
|
||||
\returns ::NC_NOERR No error.
|
||||
\returns ::NC_EBADID Not a valid ID.
|
||||
\returns ::NC_EBADDIM Invalid dimension ID or name.
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_inq_dimid(int ncid, const char *name, int *idp)
|
||||
{
|
||||
@ -160,60 +158,60 @@ nc_inq_dimid(int ncid, const char *name, int *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
|
||||
records written so far.
|
||||
The length for the unlimited dimension, if any, is the number of
|
||||
records written so far.
|
||||
|
||||
\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_inq_ncid().
|
||||
@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_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.
|
||||
@param lenp Pointer to location for returned length of dimension. For
|
||||
the unlimited dimension, this is the number of records written so far.
|
||||
|
||||
\param dimid Dimension ID, from a previous call to nc_inq_dimid() or
|
||||
nc_def_dim().
|
||||
@return ::NC_NOERR No error.
|
||||
@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
|
||||
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.
|
||||
@section nc_inq_dim_example Example
|
||||
|
||||
\param lenp Pointer to location for returned length of dimension. For
|
||||
the unlimited dimension, this is the number of records written so far.
|
||||
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
|
||||
unlimited dimension for an existing netCDF dataset named foo.nc:
|
||||
|
||||
\returns ::NC_NOERR No error.
|
||||
\returns ::NC_EBADID Not a valid ID.
|
||||
\returns ::NC_EBADDIM Invalid dimension ID or name.
|
||||
@code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
size_t latlength, recs;
|
||||
char recname[NC_MAX_NAME+1];
|
||||
...
|
||||
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_unlimdim(ncid, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimlen(ncid, latid, &latlength);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
|
||||
\section nc_inq_dim_example Example
|
||||
status = nc_inq_dim(ncid, recid, recname, &recs);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
@endcode
|
||||
|
||||
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
|
||||
unlimited dimension for an existing netCDF dataset named foo.nc:
|
||||
|
||||
\code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
size_t latlength, recs;
|
||||
char recname[NC_MAX_NAME+1];
|
||||
...
|
||||
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_unlimdim(ncid, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimlen(ncid, latid, &latlength);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
|
||||
status = nc_inq_dim(ncid, recid, recname, &recs);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
\endcode
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
|
||||
{
|
||||
@ -224,59 +222,65 @@ nc_inq_dim(int ncid, int dimid, char *name, size_t *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
|
||||
for writing. You cannot rename a dimension to have the same name as
|
||||
another dimension.
|
||||
This function renames an existing dimension in a netCDF dataset
|
||||
open for writing. You cannot rename a dimension to have the same
|
||||
name as another dimension.
|
||||
|
||||
For netCDF classic and 64-bit offset files, if the new name is longer
|
||||
than the old name, the netCDF dataset must be in define mode.
|
||||
For netCDF classic and 64-bit offset files, if the new name is
|
||||
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
|
||||
rename, regardless of the name length.
|
||||
For netCDF-4 files the length of the name is not checked against
|
||||
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(),
|
||||
nc_create(), nc_def_grp(), or associated inquiry functions such as
|
||||
nc_inq_ncid().
|
||||
@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_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
|
||||
nc_def_dim().
|
||||
@return ::NC_NOERR No error.
|
||||
@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
|
||||
with length less than NC_MAX_NAME.
|
||||
@section nc_rename_dim_example Example
|
||||
|
||||
\returns ::NC_NOERR No error.
|
||||
\returns ::NC_EBADID Not a valid ID.
|
||||
\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 latitude in an existing netCDF dataset named foo.nc:
|
||||
|
||||
Here is an example using nc_rename_dim to rename the dimension lat to
|
||||
latitude in an existing netCDF dataset named foo.nc:
|
||||
@code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid;
|
||||
...
|
||||
status = nc_open("foo.nc", NC_WRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_redef(ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_rename_dim(ncid, latid, "latitude");
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_enddef(ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
@endcode
|
||||
|
||||
\code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid;
|
||||
...
|
||||
status = nc_open("foo.nc", NC_WRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_redef(ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_rename_dim(ncid, latid, "latitude");
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_enddef(ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
\endcode
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_rename_dim(int ncid, int dimid, const char *name)
|
||||
{
|
||||
@ -287,27 +291,28 @@ nc_rename_dim(int ncid, int dimid, const char *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
|
||||
defined dimensions. In a netCDF-4/HDF5 file, this function returns the
|
||||
number of dimensions available in the group specified by ncid, which
|
||||
may be less than the total number of dimensions in a file. In a
|
||||
netCDF-4/HDF5 file, dimensions are in all sub-groups, sub-sub-groups,
|
||||
etc.
|
||||
In a classic model netCDF file, this function returns the number of
|
||||
defined dimensions. In a netCDF-4/HDF5 file, this function returns
|
||||
the number of dimensions available in the group specified by ncid,
|
||||
which may be less than the total number of dimensions in a file. In
|
||||
a netCDF-4/HDF5 file, dimensions are in all sub-groups,
|
||||
sub-sub-groups, etc.
|
||||
|
||||
\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_inq_ncid().
|
||||
@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_inq_ncid().
|
||||
@param ndimsp Pointer where number of dimensions will be
|
||||
written. Ignored if NULL.
|
||||
|
||||
\param ndimsp Pointer where number of dimensions will be
|
||||
written. Ignored if NULL.
|
||||
@return ::NC_NOERR No error.
|
||||
@return ::NC_EBADID Not a valid ID.
|
||||
|
||||
\returns ::NC_NOERR No error.
|
||||
\returns ::NC_EBADID Not a valid ID.
|
||||
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_inq_ndims(int ncid, int *ndimsp)
|
||||
{
|
||||
@ -319,26 +324,28 @@ nc_inq_ndims(int ncid, int *ndimsp)
|
||||
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
|
||||
netCDF-4/HDF5 files (which may have more than one unlimited
|
||||
dimension), the ID of the first unlimited dimesnion is returned. For
|
||||
these files, nc_inq_unlimdims() will return all the unlimited dimension IDs.
|
||||
This function finds the ID of the unlimited dimension. For
|
||||
netCDF-4/HDF5 files (which may have more than one unlimited
|
||||
dimension), the ID of the first unlimited dimesnion is
|
||||
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(),
|
||||
nc_create(), nc_def_grp(), or associated inquiry functions such as
|
||||
nc_inq_ncid().
|
||||
@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_inq_ncid().
|
||||
@param unlimdimidp Pointer where unlimited dimension ID will be
|
||||
stored. If there is no unlimited dimension, -1 will be stored
|
||||
here. Ignored if NULL.
|
||||
|
||||
\param unlimdimidp Pointer where unlimited dimension ID will be
|
||||
stored. If there is no unlimited dimension, -1 will be stored
|
||||
here. Ignored if NULL.
|
||||
@return ::NC_NOERR No error.
|
||||
@return ::NC_EBADID Not a valid ID.
|
||||
|
||||
\returns ::NC_NOERR No error.
|
||||
\returns ::NC_EBADID Not a valid ID.
|
||||
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_inq_unlimdim(int ncid, int *unlimdimidp)
|
||||
{
|
||||
@ -349,55 +356,55 @@ nc_inq_unlimdim(int ncid, int *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(),
|
||||
nc_create(), nc_def_grp(), or associated inquiry functions such as
|
||||
nc_inq_ncid().
|
||||
@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_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
|
||||
nc_def_dim().
|
||||
@return ::NC_NOERR No error.
|
||||
@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
|
||||
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.
|
||||
@section nc_inq_dim_example2 Example
|
||||
|
||||
\returns ::NC_NOERR No error.
|
||||
\returns ::NC_EBADID Not a valid ID.
|
||||
\returns ::NC_EBADDIM Invalid dimension ID or name.
|
||||
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
|
||||
unlimited dimension for an existing netCDF dataset named foo.nc:
|
||||
|
||||
\section nc_inq_dim_example2 Example
|
||||
@code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
size_t latlength, recs;
|
||||
char recname[NC_MAX_NAME+1];
|
||||
...
|
||||
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_unlimdim(ncid, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimlen(ncid, latid, &latlength);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
|
||||
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
|
||||
unlimited dimension for an existing netCDF dataset named foo.nc:
|
||||
status = nc_inq_dim(ncid, recid, recname, &recs);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
@endcode
|
||||
|
||||
\code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
size_t latlength, recs;
|
||||
char recname[NC_MAX_NAME+1];
|
||||
...
|
||||
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_unlimdim(ncid, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimlen(ncid, latid, &latlength);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
|
||||
status = nc_inq_dim(ncid, recid, recname, &recs);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
\endcode
|
||||
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
nc_inq_dimname(int ncid, int dimid, char *name)
|
||||
{
|
||||
@ -409,52 +416,53 @@ nc_inq_dimname(int ncid, int dimid, char *name)
|
||||
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
|
||||
records written so far.
|
||||
The length for the unlimited dimension, if any, is the number of
|
||||
records written so far.
|
||||
|
||||
\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_inq_ncid().
|
||||
@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_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
|
||||
nc_def_dim().
|
||||
@return ::NC_NOERR No error.
|
||||
@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.
|
||||
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
|
||||
unlimited dimension for an existing netCDF dataset named foo.nc:
|
||||
|
||||
\section nc_inq_dim_example3 Example
|
||||
@code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
size_t latlength, recs;
|
||||
char recname[NC_MAX_NAME+1];
|
||||
...
|
||||
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_unlimdim(ncid, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimlen(ncid, latid, &latlength);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
|
||||
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
|
||||
unlimited dimension for an existing netCDF dataset named foo.nc:
|
||||
status = nc_inq_dim(ncid, recid, recname, &recs);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
@endcode
|
||||
|
||||
\code
|
||||
#include <netcdf.h>
|
||||
...
|
||||
int status, ncid, latid, recid;
|
||||
size_t latlength, recs;
|
||||
char recname[NC_MAX_NAME+1];
|
||||
...
|
||||
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_unlimdim(ncid, &recid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
...
|
||||
status = nc_inq_dimid(ncid, "lat", &latid);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
status = nc_inq_dimlen(ncid, latid, &latlength);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
|
||||
status = nc_inq_dim(ncid, recid, recname, &recs);
|
||||
if (status != NC_NOERR) handle_error(status);
|
||||
\endcode
|
||||
*/
|
||||
@author Glenn Davis, Russ Rew, Ed Hartnett, Dennis Heimbigner, Ward
|
||||
Fisher
|
||||
*/
|
||||
int
|
||||
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);
|
||||
}
|
||||
|
||||
/*! \} */ /* End of named group ...*/
|
||||
|
||||
/*! \} */ /* End of defgroup. */
|
||||
/** @} */
|
||||
|
@ -1783,10 +1783,6 @@ check_create_mode(int mode)
|
||||
/* mmap is not allowed for netcdf-4 */
|
||||
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
|
||||
/* If the user asks for a netCDF-4 file, and the library was built
|
||||
* without netCDF-4, then return an error.*/
|
||||
|
@ -123,6 +123,10 @@ int nc_create_par(const char *path, int cmode, MPI_Comm comm,
|
||||
return NC_ENOTBUILT;
|
||||
#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.info = info;
|
||||
return NC_create(path, cmode, 0, 0, NULL, 1, &data, ncidp);
|
||||
|
2043
libdispatch/dvar.c
2043
libdispatch/dvar.c
File diff suppressed because it is too large
Load Diff
@ -107,6 +107,7 @@ NC_get_vara(int ncid, int varid,
|
||||
}
|
||||
|
||||
/**
|
||||
\internal
|
||||
Get data for a variable.
|
||||
|
||||
\param ncid NetCDF or group ID.
|
||||
@ -129,7 +130,6 @@ they are read.
|
||||
\returns ::NC_EBADID Bad ncid.
|
||||
|
||||
\ingroup variables
|
||||
\internal
|
||||
\author Dennis Heimbigner
|
||||
*/
|
||||
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.
|
||||
|
||||
\param ncid NetCDF or group ID.
|
||||
@ -575,7 +576,6 @@ they are read.
|
||||
\returns ::NC_EBADID Bad ncid.
|
||||
|
||||
\ingroup variables
|
||||
\internal
|
||||
\author Dennis Heimbigner, Ed Hartnett
|
||||
*/
|
||||
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
|
||||
varm routines are deprecated. Use the vars routines instead for new
|
||||
code.
|
||||
@ -637,7 +638,6 @@ they are read.
|
||||
\returns ::NC_EBADID Bad ncid.
|
||||
|
||||
\ingroup variables
|
||||
\internal
|
||||
\author Dennis Heimbigner, Ed Hartnett
|
||||
*/
|
||||
static int
|
||||
|
@ -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.
|
||||
*
|
||||
* @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 dimid Dimension ID.
|
||||
* @param name New dimension name.
|
||||
|
@ -18,7 +18,7 @@ lib_LTLIBRARIES = libnetcdf.la
|
||||
# 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_LIBADD =
|
||||
|
@ -90,7 +90,7 @@ Available values for OPTION include:
|
||||
--has-parallel4 whether has parallel IO support via HDF5
|
||||
--has-parallel whether has parallel IO support via HDF5 or PnetCDF
|
||||
--libs library linking information for netcdf
|
||||
--prefix Install prefixx
|
||||
--prefix Install prefix
|
||||
--includedir Include directory
|
||||
--libdir Library directory
|
||||
--version Library version
|
||||
|
@ -6,7 +6,6 @@ variables:
|
||||
float var1(dim0, dim1) ;
|
||||
var1:_Storage = "chunked" ;
|
||||
var1:_ChunkSizes = 2, 2 ;
|
||||
var1:_Endianness = "little" ;
|
||||
var1:_Filter = "307,9,4" ;
|
||||
var1:_NoFill = "true" ;
|
||||
|
||||
@ -25,7 +24,6 @@ group: g {
|
||||
float var2(dim0, dim1) ;
|
||||
var2:_Storage = "chunked" ;
|
||||
var2:_ChunkSizes = 2, 2 ;
|
||||
var2:_Endianness = "little" ;
|
||||
var2:_Filter = "307,9,4" ;
|
||||
var2:_NoFill = "true" ;
|
||||
|
||||
|
@ -19,23 +19,18 @@ echo "findplugin.sh loaded"
|
||||
# Function to remove selected -s attributes from file;
|
||||
# These attributes might be platform dependent
|
||||
sclean() {
|
||||
cat $1 \
|
||||
| sed -e '/var:_Endianness/d' \
|
||||
| sed -e '/_NCProperties/d' \
|
||||
| sed -e '/_SuperblockVersion/d' \
|
||||
| sed -e '/_IsNetcdf4/d' \
|
||||
| cat > $2
|
||||
cat $1 \
|
||||
| sed -e '/:_Endianness/d' \
|
||||
| sed -e '/_NCProperties/d' \
|
||||
| sed -e '/_SuperblockVersion/d' \
|
||||
| sed -e '/_IsNetcdf4/d' \
|
||||
| cat > $2
|
||||
}
|
||||
|
||||
# Function to extract _Filter attribute from a file
|
||||
# These attributes might be platform dependent
|
||||
getfilterattr() {
|
||||
case "$1" in
|
||||
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
|
||||
sed -e '/var.*:_Filter/p' -ed <$1 >$2
|
||||
}
|
||||
|
||||
trimleft() {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "netcdf.h"
|
||||
#include "netcdf_filter.h"
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
#define PARAMS_ID 32768
|
||||
|
||||
/* The C standard apparently defines all floating point constants as double;
|
||||
@ -170,14 +172,14 @@ buildbaseline(void)
|
||||
insert(7,&val4,sizeof(val4)); /* signed int */
|
||||
val4 = 4294967295U; /*0xffffffff*/
|
||||
insert(8,&val4,sizeof(val4)); /* unsigned int */
|
||||
float4 = 789.0f;
|
||||
float4 = (float)FLTVAL;
|
||||
insert(9,&float4,sizeof(float4)); /*float */
|
||||
val8 = -9223372036854775807L;
|
||||
val8 = LONGLONGVAL;
|
||||
insert(10,&val8,sizeof(val8)); /* signed long long */
|
||||
val8 = 18446744073709551615UL;
|
||||
val8 = ULONGLONGVAL;
|
||||
insert(12,&val8,sizeof(val8)); /* unsigned long long */
|
||||
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;
|
||||
size_t i,nparams = 0;
|
||||
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");
|
||||
|
||||
@ -209,28 +216,32 @@ main(int argc, char **argv)
|
||||
|
||||
/* float */
|
||||
uf.ui = params[9];
|
||||
if(uf.f != (float)FLTVAL)
|
||||
memcpy(&basef,&baseline[9],4);
|
||||
if(uf.f != basef)
|
||||
mismatch(9,params,"uf.f");
|
||||
|
||||
/* signed long long */
|
||||
ul.ui[0] = params[10];
|
||||
ul.ui[1] = params[11];
|
||||
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");
|
||||
|
||||
/* unsigned long long */
|
||||
ul.ui[0] = params[12];
|
||||
ul.ui[1] = params[13];
|
||||
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");
|
||||
|
||||
/* double */
|
||||
ud.ui[0] = params[14];
|
||||
ud.ui[1] = params[15];
|
||||
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");
|
||||
|
||||
if (!nerrs)
|
||||
@ -240,7 +251,8 @@ main(int argc, char **argv)
|
||||
return (nerrs > 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifdef DEBUG
|
||||
|
||||
/* Look at q0 and q1) to determine type */
|
||||
static int
|
||||
gettype(const int q0, const int q1, int* isunsignedp)
|
||||
@ -470,4 +482,5 @@ NC_filterfix8(unsigned char* mem, int decode)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*0*/
|
||||
#endif /*DEBUG*/
|
||||
|
||||
|
@ -168,8 +168,10 @@ ENDIF(MSVC)
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC OR APPLE)
|
||||
|
||||
add_sh_test(ncdump tst_inmemory_nc3)
|
||||
add_sh_test(ncdump tst_nccopy_w3)
|
||||
IF(USE_NETCDF4)
|
||||
add_sh_test(ncdump tst_inmemory_nc4)
|
||||
add_sh_test(ncdump tst_nccopy_w4)
|
||||
ENDIF(USE_NETCDF4)
|
||||
|
||||
IF(USE_NETCDF4)
|
||||
@ -251,6 +253,7 @@ ENDIF(MSVC)
|
||||
add_sh_test(ncdump tst_inttags4)
|
||||
ENDIF(USE_NETCDF4)
|
||||
|
||||
add_sh_test(ncdump test_radix)
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
|
@ -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 \
|
||||
run_utf8_tests.sh tst_nccopy3.sh tst_nccopy3_subset.sh \
|
||||
tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \
|
||||
tst_dimsizes.sh run_ncgen_tests.sh 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
|
||||
# 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
|
||||
endif #!USE_HDF5
|
||||
|
||||
TESTS += tst_inmemory_nc3.sh
|
||||
TESTS += tst_inmemory_nc3.sh tst_nccopy_w3.sh
|
||||
if USE_HDF5
|
||||
TESTS += tst_inmemory_nc4.sh
|
||||
TESTS += tst_inmemory_nc4.sh tst_nccopy_w4.sh
|
||||
endif
|
||||
|
||||
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 \
|
||||
tst_ncgen4.sh tst_ncgen4_classic.sh tst_ncgen4_diff.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.
|
||||
# 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_compound_datasize_test.cdl tst_compound_datasize_test2.cdl \
|
||||
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
|
||||
|
@ -1894,7 +1894,7 @@ copy(char* infile, char* outfile)
|
||||
}
|
||||
|
||||
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) {
|
||||
case NC_FORMAT_CLASSIC:
|
||||
/* nothing to do */
|
||||
|
15
ncdump/ref_nccopy_w.cdl
Normal file
15
ncdump/ref_nccopy_w.cdl
Normal 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
19
ncdump/ref_tst_radix.cdl
Normal 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
16
ncdump/test_radix.sh
Executable 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
20
ncdump/tst_nccopy_w3.sh
Executable 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
21
ncdump/tst_nccopy_w4.sh
Executable 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
19
ncdump/tst_radix.cdl
Normal 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 ;
|
||||
}
|
@ -63,7 +63,15 @@ extern char *progname; /* for error messages */
|
||||
extern "C" {
|
||||
#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__);}
|
||||
#endif /* NDEBUG */
|
||||
|
||||
/* Print error message to stderr and exit */
|
||||
extern void error ( const char *fmt, ... );
|
||||
|
@ -60,7 +60,7 @@ genbin_netcdf(void)
|
||||
#endif
|
||||
|
||||
stat = nc_create(filename, cmode_modifier, &ncid);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
|
||||
/* ncid created above is also root group*/
|
||||
rootgroup->nc_id = ncid;
|
||||
@ -72,7 +72,7 @@ genbin_netcdf(void)
|
||||
Symbol* gsym = (Symbol*)listget(grpdefs,igrp);
|
||||
if(gsym == rootgroup) continue; /* ignore root group*/
|
||||
stat = nc_def_grp(gsym->container->nc_id,gsym->name,&gsym->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -95,7 +95,7 @@ genbin_netcdf(void)
|
||||
dsym->name,
|
||||
(dsym->dim.isunlimited?NC_UNLIMITED:dsym->dim.declsize),
|
||||
&dsym->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ genbin_netcdf(void)
|
||||
NULL,
|
||||
&vsym->nc_id);
|
||||
}
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,12 +154,12 @@ genbin_netcdf(void)
|
||||
|
||||
if (nofill_flag) {
|
||||
stat = nc_set_fill(rootgroup->nc_id, NC_NOFILL, 0);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
|
||||
/* leave define mode */
|
||||
stat = nc_enddef(rootgroup->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
|
||||
if(!header_only) {
|
||||
/* Load values into those variables with defined data */
|
||||
@ -189,7 +189,7 @@ genbin_defineglobalspecials(void)
|
||||
/* Watch out, this is a global Attribute */
|
||||
format = kind_string(/*Main.*/format_flag);
|
||||
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*/
|
||||
|
||||
@ -206,13 +206,13 @@ genbin_definespecialattributes(Symbol* var)
|
||||
derror("NC_CHUNKED requested, but no chunksizes specified");
|
||||
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) {
|
||||
stat = nc_def_var_fletcher32(var->container->nc_id,
|
||||
var->nc_id,
|
||||
special->_Fletcher32);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
if(special->flags & (_DEFLATE_FLAG | _SHUFFLE_FLAG)) {
|
||||
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?special->_DeflateLevel
|
||||
:0));
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
if(special->flags & _ENDIAN_FLAG) {
|
||||
stat = nc_def_var_endian(var->container->nc_id,
|
||||
@ -229,14 +229,14 @@ genbin_definespecialattributes(Symbol* var)
|
||||
(special->_Endianness == NC_ENDIAN_LITTLE?
|
||||
NC_ENDIAN_LITTLE
|
||||
:NC_ENDIAN_BIG));
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
if(special->flags & _NOFILL_FLAG) {
|
||||
stat = nc_def_var_fill(var->container->nc_id,
|
||||
var->nc_id,
|
||||
(special->_Fill?NC_FILL:NC_NOFILL),
|
||||
NULL);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
if(special->flags & _FILTER_FLAG) {
|
||||
/* Special check for alternate way to specify _Deflate */
|
||||
@ -263,7 +263,7 @@ genbin_definespecialattributes(Symbol* var)
|
||||
special->_FilterParams
|
||||
);
|
||||
}
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
return stat;
|
||||
}
|
||||
@ -275,7 +275,7 @@ genbin_close(void)
|
||||
{
|
||||
int stat;
|
||||
stat = nc_close(rootgroup->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
@ -296,7 +296,7 @@ genbin_deftype(Symbol* tsym)
|
||||
tsym->typ.size,
|
||||
tsym->name,
|
||||
&tsym->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
break;
|
||||
case NC_ENUM:
|
||||
{
|
||||
@ -305,7 +305,7 @@ genbin_deftype(Symbol* tsym)
|
||||
tsym->typ.basetype->nc_id,
|
||||
tsym->name,
|
||||
&tsym->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
datum = bbNew();
|
||||
for(i=0;i<listlength(tsym->subnodes);i++) {
|
||||
Symbol* econst = (Symbol*)listget(tsym->subnodes,i);
|
||||
@ -317,7 +317,7 @@ genbin_deftype(Symbol* tsym)
|
||||
tsym->nc_id,
|
||||
econst->name,
|
||||
bbContents(datum));
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
bbFree(datum);
|
||||
}
|
||||
@ -327,14 +327,14 @@ genbin_deftype(Symbol* tsym)
|
||||
tsym->name,
|
||||
tsym->typ.basetype->nc_id,
|
||||
&tsym->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
break;
|
||||
case NC_COMPOUND:
|
||||
stat = nc_def_compound(tsym->container->nc_id,
|
||||
tsym->typ.size,
|
||||
tsym->name,
|
||||
&tsym->nc_id);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
for(i=0;i<listlength(tsym->subnodes);i++) {
|
||||
Symbol* efield = (Symbol*)listget(tsym->subnodes,i);
|
||||
ASSERT(efield->subclass == NC_FIELD);
|
||||
@ -362,7 +362,7 @@ genbin_deftype(Symbol* tsym)
|
||||
efield->typ.dimset.ndims,
|
||||
dimsizes);
|
||||
}
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
break;
|
||||
default: panic("definectype: unexpected type subclass");
|
||||
@ -448,11 +448,11 @@ genbin_writevar(Generator* generator, Symbol* vsym, Bytebuffer* memory,
|
||||
} else {
|
||||
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
|
||||
/* Reclaim the data */
|
||||
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 */
|
||||
#endif
|
||||
return stat;
|
||||
@ -481,7 +481,7 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
|
||||
case NC_BYTE: {
|
||||
signed char* data = (signed char*)bbContents(databuf);
|
||||
stat = nc_put_att_schar(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_CHAR: {
|
||||
char* data = (char*)bbContents(databuf);
|
||||
@ -495,27 +495,27 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
|
||||
slen++;
|
||||
}
|
||||
stat = nc_put_att_text(grpid,varid,asym->name,slen,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_SHORT: {
|
||||
short* data = (short*)bbContents(databuf);
|
||||
stat = nc_put_att_short(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_INT: {
|
||||
int* data = (int*)bbContents(databuf);
|
||||
stat = nc_put_att_int(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_FLOAT: {
|
||||
float* data = (float*)bbContents(databuf);
|
||||
stat = nc_put_att_float(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_DOUBLE: {
|
||||
double* data = (double*)bbContents(databuf);
|
||||
stat = nc_put_att_double(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_STRING: {
|
||||
const char** data;
|
||||
@ -527,27 +527,27 @@ genbin_writeattr(Generator* generator, Symbol* asym, Bytebuffer* databuf,
|
||||
case NC_UBYTE: {
|
||||
unsigned char* data = (unsigned char*)bbContents(databuf);
|
||||
stat = nc_put_att_uchar(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_USHORT: {
|
||||
unsigned short* data = (unsigned short*)bbContents(databuf);
|
||||
stat = nc_put_att_ushort(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_UINT: {
|
||||
unsigned int* data = (unsigned int*)bbContents(databuf);
|
||||
stat = nc_put_att_uint(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
case NC_INT64: {
|
||||
long long* data = (long long*)bbContents(databuf);
|
||||
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;
|
||||
case NC_UINT64: {
|
||||
unsigned long long* data = (unsigned long long*)bbContents(databuf);
|
||||
stat = nc_put_att_ulonglong(grpid,varid,asym->name,typid,len,data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
} break;
|
||||
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);
|
||||
stat = nc_put_att(grpid,varid,asym->name,typid,
|
||||
len,(void*)data);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
#ifdef GENDEBUG
|
||||
{
|
||||
char out[4096];
|
||||
memset(out,0x77,sizeof(out));
|
||||
stat = nc_get_att(grpid,varid,asym->name,&out);
|
||||
check_err(stat,__LINE__,__FILE__);
|
||||
check_err(stat,__LINE__,"ncgen");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ It has diverged slightly over time.
|
||||
#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 */
|
||||
static int nc_blkio_init(size_t bufsize, size_t value_size, int rank,
|
||||
|
@ -82,6 +82,7 @@ static unsigned int MAX_UINT = NC_MAX_UINT;
|
||||
#define TAGCHARS "BbSsLlUu"
|
||||
|
||||
#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
|
||||
#define tstoctal(ch) ((ch) == '0')
|
||||
|
||||
/*Mnemonics*/
|
||||
#define ISIDENT 1
|
||||
@ -115,7 +116,7 @@ unsigned char ubyte_val; /* last byte value read */
|
||||
|
||||
static Symbol* makepath(char* text);
|
||||
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 int tagmatch(nc_type nct, int tag);
|
||||
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).
|
||||
Technically, the user should specify, but...
|
||||
If out of any integer range, then complain
|
||||
Also, if the digits begin with 0, then assume octal.
|
||||
*/
|
||||
int slen = strlen(ncgtext);
|
||||
char* stag = NULL;
|
||||
@ -390,28 +392,40 @@ NIL|nil|Nil {
|
||||
nc_type nct = 0;
|
||||
char* pos = NULL;
|
||||
int hasU = 0;
|
||||
int radix = 10;
|
||||
|
||||
pos = ncgtext;
|
||||
|
||||
/* capture the tag string */
|
||||
tag = collecttag(ncgtext,&stag);
|
||||
tag = collecttag(pos,&stag);
|
||||
if(tag == NC_NAT) {
|
||||
sprintf(errstr,"Illegal integer suffix: %s",stag);
|
||||
yyerror(errstr);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* drop the tag from the input text */
|
||||
ncgtext[slen - strlen(stag)] = '\0';
|
||||
hasU = isuinttype(tag);
|
||||
if(!tstdecimal(c)) {
|
||||
pos = ncgtext+1;
|
||||
isneg = (c == '-');
|
||||
} else
|
||||
pos = ncgtext;
|
||||
|
||||
/* Capture the sign, if any */
|
||||
isneg = (c == '-');
|
||||
/* skip leading sign */
|
||||
if(c == '-' || c == '+')
|
||||
pos++;
|
||||
|
||||
c = pos[0];
|
||||
if(tstoctal(c))
|
||||
radix = 8;
|
||||
else
|
||||
radix = 10;
|
||||
|
||||
if(isneg && hasU) {
|
||||
sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
|
||||
yyerror(errstr);
|
||||
goto done;
|
||||
}
|
||||
uint64_val = parseULL(pos,&fail);
|
||||
uint64_val = parseULL(radix, pos,&fail);
|
||||
if(fail) {
|
||||
sprintf(errstr,"integer constant out of range: %s",ncgtext);
|
||||
yyerror(errstr);
|
||||
@ -648,24 +662,26 @@ Parse a simple string of digits into an unsigned long long
|
||||
Return the value.
|
||||
*/
|
||||
static unsigned long long
|
||||
parseULL(char* text, int* failp)
|
||||
parseULL(int radix, char* text, int* failp)
|
||||
{
|
||||
extern int errno;
|
||||
char* endptr;
|
||||
unsigned long long uint64 = 0;
|
||||
|
||||
errno = 0; endptr = NULL;
|
||||
assert(tstdecimal(text[0]));
|
||||
#ifdef HAVE_STRTOULL
|
||||
uint64 = strtoull(text,&endptr,10);
|
||||
uint64 = strtoull(text,&endptr,radix);
|
||||
if(errno == ERANGE) {
|
||||
if(failp) *failp = ERANGE;
|
||||
return 0;
|
||||
}
|
||||
#else /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/
|
||||
sscanf((char*)text, "%llu", &uint64);
|
||||
#else /*!defined HAVE_STRTOULL*/
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
156
ncgen/ncgenl.c
156
ncgen/ncgenl.c
@ -1464,6 +1464,7 @@ static unsigned int MAX_UINT = NC_MAX_UINT;
|
||||
#define TAGCHARS "BbSsLlUu"
|
||||
|
||||
#define tstdecimal(ch) ((ch) >= '0' && (ch) <= '9')
|
||||
#define tstoctal(ch) ((ch) == '0')
|
||||
|
||||
/*Mnemonics*/
|
||||
#define ISIDENT 1
|
||||
@ -1497,7 +1498,7 @@ unsigned char ubyte_val; /* last byte value read */
|
||||
|
||||
static Symbol* makepath(char* text);
|
||||
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 int tagmatch(nc_type nct, int tag);
|
||||
static int nct2lexeme(nc_type nct);
|
||||
@ -1520,7 +1521,7 @@ struct Specialtoken specials[] = {
|
||||
{NULL,0} /* null terminate */
|
||||
};
|
||||
|
||||
#line 1523 "ncgenl.c"
|
||||
#line 1524 "ncgenl.c"
|
||||
|
||||
/* The most correct (validating) version of UTF8 character set
|
||||
(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,
|
||||
although it is a very relaxed definition
|
||||
*/
|
||||
#line 1566 "ncgenl.c"
|
||||
#line 1567 "ncgenl.c"
|
||||
|
||||
#define INITIAL 0
|
||||
#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 */
|
||||
{
|
||||
@ -1843,14 +1844,14 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
|
||||
case 1:
|
||||
YY_RULE_SETUP
|
||||
#line 221 "ncgen.l"
|
||||
#line 222 "ncgen.l"
|
||||
{ /* whitespace */
|
||||
break;
|
||||
}
|
||||
YY_BREAK
|
||||
case 2:
|
||||
YY_RULE_SETUP
|
||||
#line 225 "ncgen.l"
|
||||
#line 226 "ncgen.l"
|
||||
{ /* comment */
|
||||
break;
|
||||
}
|
||||
@ -1858,7 +1859,7 @@ YY_RULE_SETUP
|
||||
case 3:
|
||||
/* rule 3 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 229 "ncgen.l"
|
||||
#line 230 "ncgen.l"
|
||||
{int len; char* s = NULL;
|
||||
/* In netcdf4, this will be used in a variety
|
||||
of places, so only remove escapes */
|
||||
@ -1882,7 +1883,7 @@ yytext[MAXTRST-1] = '\0';
|
||||
YY_BREAK
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
#line 250 "ncgen.l"
|
||||
#line 251 "ncgen.l"
|
||||
{ /* drop leading 0x; pad to even number of chars */
|
||||
char* p = yytext+2;
|
||||
int len = yyleng - 2;
|
||||
@ -1897,118 +1898,118 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
#line 262 "ncgen.l"
|
||||
#line 263 "ncgen.l"
|
||||
{return lexdebug(COMPOUND);}
|
||||
YY_BREAK
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 263 "ncgen.l"
|
||||
#line 264 "ncgen.l"
|
||||
{return lexdebug(ENUM);}
|
||||
YY_BREAK
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 264 "ncgen.l"
|
||||
#line 265 "ncgen.l"
|
||||
{return lexdebug(OPAQUE_);}
|
||||
YY_BREAK
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 266 "ncgen.l"
|
||||
#line 267 "ncgen.l"
|
||||
{return lexdebug(FLOAT_K);}
|
||||
YY_BREAK
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 267 "ncgen.l"
|
||||
#line 268 "ncgen.l"
|
||||
{return lexdebug(CHAR_K);}
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 268 "ncgen.l"
|
||||
#line 269 "ncgen.l"
|
||||
{return lexdebug(BYTE_K);}
|
||||
YY_BREAK
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 269 "ncgen.l"
|
||||
#line 270 "ncgen.l"
|
||||
{return lexdebug(UBYTE_K);}
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 270 "ncgen.l"
|
||||
#line 271 "ncgen.l"
|
||||
{return lexdebug(SHORT_K);}
|
||||
YY_BREAK
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
#line 271 "ncgen.l"
|
||||
#line 272 "ncgen.l"
|
||||
{return lexdebug(USHORT_K);}
|
||||
YY_BREAK
|
||||
case 14:
|
||||
YY_RULE_SETUP
|
||||
#line 272 "ncgen.l"
|
||||
#line 273 "ncgen.l"
|
||||
{return lexdebug(INT_K);}
|
||||
YY_BREAK
|
||||
case 15:
|
||||
YY_RULE_SETUP
|
||||
#line 273 "ncgen.l"
|
||||
#line 274 "ncgen.l"
|
||||
{return lexdebug(UINT_K);}
|
||||
YY_BREAK
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
#line 274 "ncgen.l"
|
||||
#line 275 "ncgen.l"
|
||||
{return lexdebug(INT64_K);}
|
||||
YY_BREAK
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 275 "ncgen.l"
|
||||
#line 276 "ncgen.l"
|
||||
{return lexdebug(UINT64_K);}
|
||||
YY_BREAK
|
||||
case 18:
|
||||
YY_RULE_SETUP
|
||||
#line 276 "ncgen.l"
|
||||
#line 277 "ncgen.l"
|
||||
{return lexdebug(DOUBLE_K);}
|
||||
YY_BREAK
|
||||
case 19:
|
||||
YY_RULE_SETUP
|
||||
#line 277 "ncgen.l"
|
||||
#line 278 "ncgen.l"
|
||||
{return lexdebug(STRING_K);}
|
||||
YY_BREAK
|
||||
case 20:
|
||||
YY_RULE_SETUP
|
||||
#line 279 "ncgen.l"
|
||||
#line 280 "ncgen.l"
|
||||
{int32_val = -1;
|
||||
return lexdebug(NC_UNLIMITED_K);}
|
||||
YY_BREAK
|
||||
case 21:
|
||||
YY_RULE_SETUP
|
||||
#line 282 "ncgen.l"
|
||||
#line 283 "ncgen.l"
|
||||
{return lexdebug(TYPES);}
|
||||
YY_BREAK
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
#line 283 "ncgen.l"
|
||||
#line 284 "ncgen.l"
|
||||
{return lexdebug(DIMENSIONS);}
|
||||
YY_BREAK
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
#line 284 "ncgen.l"
|
||||
#line 285 "ncgen.l"
|
||||
{return lexdebug(VARIABLES);}
|
||||
YY_BREAK
|
||||
case 24:
|
||||
YY_RULE_SETUP
|
||||
#line 285 "ncgen.l"
|
||||
#line 286 "ncgen.l"
|
||||
{return lexdebug(DATA);}
|
||||
YY_BREAK
|
||||
case 25:
|
||||
YY_RULE_SETUP
|
||||
#line 286 "ncgen.l"
|
||||
#line 287 "ncgen.l"
|
||||
{return lexdebug(GROUP);}
|
||||
YY_BREAK
|
||||
case 26:
|
||||
YY_RULE_SETUP
|
||||
#line 288 "ncgen.l"
|
||||
#line 289 "ncgen.l"
|
||||
{BEGIN(TEXT);return lexdebug(NETCDF);}
|
||||
YY_BREAK
|
||||
case 27:
|
||||
YY_RULE_SETUP
|
||||
#line 290 "ncgen.l"
|
||||
#line 291 "ncgen.l"
|
||||
{ /* missing value (pre-2.4 backward compatibility) */
|
||||
if (yytext[0] == '-') {
|
||||
double_val = NEGNC_INFINITE;
|
||||
@ -2021,7 +2022,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 28:
|
||||
YY_RULE_SETUP
|
||||
#line 299 "ncgen.l"
|
||||
#line 300 "ncgen.l"
|
||||
{ /* missing value (pre-2.4 backward compatibility) */
|
||||
double_val = NAN;
|
||||
specialconstants = 1;
|
||||
@ -2030,7 +2031,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 29:
|
||||
YY_RULE_SETUP
|
||||
#line 305 "ncgen.l"
|
||||
#line 306 "ncgen.l"
|
||||
{/* missing value (pre-2.4 backward compatibility)*/
|
||||
if (yytext[0] == '-') {
|
||||
float_val = NEGNC_INFINITEF;
|
||||
@ -2043,7 +2044,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 30:
|
||||
YY_RULE_SETUP
|
||||
#line 314 "ncgen.l"
|
||||
#line 315 "ncgen.l"
|
||||
{ /* missing value (pre-2.4 backward compatibility) */
|
||||
float_val = NANF;
|
||||
specialconstants = 1;
|
||||
@ -2052,7 +2053,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 31:
|
||||
YY_RULE_SETUP
|
||||
#line 320 "ncgen.l"
|
||||
#line 321 "ncgen.l"
|
||||
{
|
||||
#ifdef USE_NETCDF4
|
||||
if(l_flag == L_C || l_flag == L_BINARY)
|
||||
@ -2065,7 +2066,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 32:
|
||||
YY_RULE_SETUP
|
||||
#line 330 "ncgen.l"
|
||||
#line 331 "ncgen.l"
|
||||
{
|
||||
bbClear(lextext);
|
||||
bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */
|
||||
@ -2076,7 +2077,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 33:
|
||||
YY_RULE_SETUP
|
||||
#line 339 "ncgen.l"
|
||||
#line 340 "ncgen.l"
|
||||
{struct Specialtoken* st;
|
||||
bbClear(lextext);
|
||||
bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */
|
||||
@ -2090,7 +2091,7 @@ YY_RULE_SETUP
|
||||
case 34:
|
||||
/* rule 34 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 349 "ncgen.l"
|
||||
#line 350 "ncgen.l"
|
||||
{
|
||||
int c;
|
||||
char* p; char* q;
|
||||
@ -2110,7 +2111,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 35:
|
||||
YY_RULE_SETUP
|
||||
#line 366 "ncgen.l"
|
||||
#line 367 "ncgen.l"
|
||||
{ char* id = NULL; int len;
|
||||
len = strlen(yytext);
|
||||
len = unescape(yytext,len,ISIDENT,&id);
|
||||
@ -2125,12 +2126,13 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 36:
|
||||
YY_RULE_SETUP
|
||||
#line 378 "ncgen.l"
|
||||
#line 379 "ncgen.l"
|
||||
{
|
||||
/*
|
||||
We need to try to see what size of integer ((u)int).
|
||||
Technically, the user should specify, but...
|
||||
If out of any integer range, then complain
|
||||
Also, if the digits begin with 0, then assume octal.
|
||||
*/
|
||||
int slen = strlen(ncgtext);
|
||||
char* stag = NULL;
|
||||
@ -2141,28 +2143,40 @@ YY_RULE_SETUP
|
||||
nc_type nct = 0;
|
||||
char* pos = NULL;
|
||||
int hasU = 0;
|
||||
int radix = 10;
|
||||
|
||||
pos = ncgtext;
|
||||
|
||||
/* capture the tag string */
|
||||
tag = collecttag(ncgtext,&stag);
|
||||
tag = collecttag(pos,&stag);
|
||||
if(tag == NC_NAT) {
|
||||
sprintf(errstr,"Illegal integer suffix: %s",stag);
|
||||
yyerror(errstr);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* drop the tag from the input text */
|
||||
ncgtext[slen - strlen(stag)] = '\0';
|
||||
hasU = isuinttype(tag);
|
||||
if(!tstdecimal(c)) {
|
||||
pos = ncgtext+1;
|
||||
isneg = (c == '-');
|
||||
} else
|
||||
pos = ncgtext;
|
||||
|
||||
/* Capture the sign, if any */
|
||||
isneg = (c == '-');
|
||||
/* skip leading sign */
|
||||
if(c == '-' || c == '+')
|
||||
pos++;
|
||||
|
||||
c = pos[0];
|
||||
if(tstoctal(c))
|
||||
radix = 8;
|
||||
else
|
||||
radix = 10;
|
||||
|
||||
if(isneg && hasU) {
|
||||
sprintf(errstr,"Unsigned integer cannot be signed: %s",ncgtext);
|
||||
yyerror(errstr);
|
||||
goto done;
|
||||
}
|
||||
uint64_val = parseULL(pos,&fail);
|
||||
uint64_val = parseULL(radix, pos,&fail);
|
||||
if(fail) {
|
||||
sprintf(errstr,"integer constant out of range: %s",ncgtext);
|
||||
yyerror(errstr);
|
||||
@ -2193,7 +2207,7 @@ done: return 0;
|
||||
YY_BREAK
|
||||
case 37:
|
||||
YY_RULE_SETUP
|
||||
#line 443 "ncgen.l"
|
||||
#line 457 "ncgen.l"
|
||||
{
|
||||
int c;
|
||||
int token = 0;
|
||||
@ -2244,7 +2258,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
#line 490 "ncgen.l"
|
||||
#line 504 "ncgen.l"
|
||||
{
|
||||
if (sscanf((char*)yytext, "%le", &double_val) != 1) {
|
||||
sprintf(errstr,"bad long or double constant: %s",(char*)yytext);
|
||||
@ -2255,7 +2269,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 39:
|
||||
YY_RULE_SETUP
|
||||
#line 497 "ncgen.l"
|
||||
#line 511 "ncgen.l"
|
||||
{
|
||||
if (sscanf((char*)yytext, "%e", &float_val) != 1) {
|
||||
sprintf(errstr,"bad float constant: %s",(char*)yytext);
|
||||
@ -2267,7 +2281,7 @@ YY_RULE_SETUP
|
||||
case 40:
|
||||
/* rule 40 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 504 "ncgen.l"
|
||||
#line 518 "ncgen.l"
|
||||
{
|
||||
(void) sscanf((char*)&yytext[1],"%c",&byte_val);
|
||||
return lexdebug(BYTE_CONST);
|
||||
@ -2275,7 +2289,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 41:
|
||||
YY_RULE_SETUP
|
||||
#line 508 "ncgen.l"
|
||||
#line 522 "ncgen.l"
|
||||
{
|
||||
int oct = unescapeoct(&yytext[2]);
|
||||
if(oct < 0) {
|
||||
@ -2288,7 +2302,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 42:
|
||||
YY_RULE_SETUP
|
||||
#line 517 "ncgen.l"
|
||||
#line 531 "ncgen.l"
|
||||
{
|
||||
int hex = unescapehex(&yytext[3]);
|
||||
if(byte_val < 0) {
|
||||
@ -2301,7 +2315,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
#line 526 "ncgen.l"
|
||||
#line 540 "ncgen.l"
|
||||
{
|
||||
switch ((char)yytext[2]) {
|
||||
case 'a': byte_val = '\007'; break; /* not everyone under-
|
||||
@ -2323,7 +2337,7 @@ YY_RULE_SETUP
|
||||
case 44:
|
||||
/* rule 44 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 544 "ncgen.l"
|
||||
#line 558 "ncgen.l"
|
||||
{
|
||||
lineno++ ;
|
||||
break;
|
||||
@ -2331,7 +2345,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 45:
|
||||
YY_RULE_SETUP
|
||||
#line 549 "ncgen.l"
|
||||
#line 563 "ncgen.l"
|
||||
{/*initial*/
|
||||
BEGIN(ST_C_COMMENT);
|
||||
break;
|
||||
@ -2340,21 +2354,21 @@ YY_RULE_SETUP
|
||||
case 46:
|
||||
/* rule 46 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 554 "ncgen.l"
|
||||
#line 568 "ncgen.l"
|
||||
{/* continuation */
|
||||
break;
|
||||
}
|
||||
YY_BREAK
|
||||
case 47:
|
||||
YY_RULE_SETUP
|
||||
#line 558 "ncgen.l"
|
||||
#line 572 "ncgen.l"
|
||||
{/* final */
|
||||
BEGIN(INITIAL);
|
||||
break;
|
||||
}
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(ST_C_COMMENT):
|
||||
#line 563 "ncgen.l"
|
||||
#line 577 "ncgen.l"
|
||||
{/* final, error */
|
||||
fprintf(stderr,"unterminated /**/ comment");
|
||||
BEGIN(INITIAL);
|
||||
@ -2363,17 +2377,17 @@ case YY_STATE_EOF(ST_C_COMMENT):
|
||||
YY_BREAK
|
||||
case 48:
|
||||
YY_RULE_SETUP
|
||||
#line 569 "ncgen.l"
|
||||
#line 583 "ncgen.l"
|
||||
{/* Note: this next rule will not work for UTF8 characters */
|
||||
return lexdebug(yytext[0]) ;
|
||||
}
|
||||
YY_BREAK
|
||||
case 49:
|
||||
YY_RULE_SETUP
|
||||
#line 572 "ncgen.l"
|
||||
#line 586 "ncgen.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 2376 "ncgenl.c"
|
||||
#line 2390 "ncgenl.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(TEXT):
|
||||
yyterminate();
|
||||
@ -3379,7 +3393,7 @@ void yyfree (void * ptr )
|
||||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
#line 572 "ncgen.l"
|
||||
#line 586 "ncgen.l"
|
||||
|
||||
static int
|
||||
lexdebug(int token)
|
||||
@ -3459,24 +3473,26 @@ Parse a simple string of digits into an unsigned long long
|
||||
Return the value.
|
||||
*/
|
||||
static unsigned long long
|
||||
parseULL(char* text, int* failp)
|
||||
parseULL(int radix, char* text, int* failp)
|
||||
{
|
||||
extern int errno;
|
||||
char* endptr;
|
||||
unsigned long long uint64 = 0;
|
||||
|
||||
errno = 0; endptr = NULL;
|
||||
assert(tstdecimal(text[0]));
|
||||
#ifdef HAVE_STRTOULL
|
||||
uint64 = strtoull(text,&endptr,10);
|
||||
uint64 = strtoull(text,&endptr,radix);
|
||||
if(errno == ERANGE) {
|
||||
if(failp) *failp = ERANGE;
|
||||
return 0;
|
||||
}
|
||||
#else /*!(defined HAVE_STRTOLL && defined HAVE_STRTOULL)*/
|
||||
sscanf((char*)text, "%llu", &uint64);
|
||||
#else /*!defined HAVE_STRTOULL*/
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -9,5 +9,5 @@ Description: NetCDF Client Library for C
|
||||
URL: http://www.unidata.ucar.edu/netcdf
|
||||
Version: @PACKAGE_VERSION@
|
||||
Libs: -L${libdir} @NC_LIBS@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "config.h"
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -7,6 +8,8 @@
|
||||
/* Older versions of the hdf library may define H5PL_type_t here */
|
||||
#include <H5PLextern.h>
|
||||
|
||||
|
||||
|
||||
#ifndef DLL_EXPORT
|
||||
#define DLL_EXPORT
|
||||
#endif
|
||||
@ -90,7 +93,11 @@ size_t H5Z_filter_bzip2(unsigned int flags, size_t cd_nelmts,
|
||||
|
||||
/* Prepare the output buffer. */
|
||||
outbuflen = nbytes * 3 + 1; /* average bzip2 compression ratio is 3:1 */
|
||||
#ifdef HDF5_HAS_ALLOCATE_MEMORY
|
||||
outbuf = H5allocate_memory(outbuflen,0);
|
||||
#else
|
||||
outbuf = (char*)malloc(outbuflen * sizeof(char));
|
||||
#endif
|
||||
if (outbuf == NULL) {
|
||||
fprintf(stderr, "memory allocation failed for bzip2 decompression\n");
|
||||
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) {
|
||||
/* Grow the output buffer. */
|
||||
newbuflen = outbuflen * 2;
|
||||
#ifdef HDF5_HAS_RESIZE_MEMORY
|
||||
newbuf = H5resize_memory(outbuf, newbuflen);
|
||||
#else
|
||||
newbuf = realloc(outbuf,newbuflen);
|
||||
#endif
|
||||
if (newbuf == NULL) {
|
||||
fprintf(stderr, "memory allocation failed for bzip2 decompression\n");
|
||||
goto cleanupAndFail;
|
||||
@ -167,7 +178,12 @@ size_t H5Z_filter_bzip2(unsigned int flags, size_t cd_nelmts,
|
||||
|
||||
/* Prepare the output buffer. */
|
||||
outbuflen = nbytes + nbytes / 100 + 600; /* worst case (bzip2 docs) */
|
||||
#ifdef HDF5_HAS_ALLOCATE_MEMORY
|
||||
outbuf = H5allocate_memory(outbuflen,0);
|
||||
#else
|
||||
outbuf = (char*)malloc(outbuflen * sizeof(char));
|
||||
#endif
|
||||
|
||||
if (outbuf == NULL) {
|
||||
fprintf(stderr, "memory allocation failed for bzip2 compression\n");
|
||||
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. */
|
||||
#ifdef HDF5_HAS_H5FREE
|
||||
H5free_memory(*buf);
|
||||
#else
|
||||
free(*buf);
|
||||
#endif
|
||||
|
||||
*buf = outbuf;
|
||||
*buf_size = outbuflen;
|
||||
return outdatalen;
|
||||
|
||||
cleanupAndFail:
|
||||
if (outbuf)
|
||||
#ifdef HDF5_HAS_H5FREE
|
||||
H5free_memory(outbuf);
|
||||
#else
|
||||
free(outbuf);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
@ -109,21 +110,37 @@ H5Z_filter_test(unsigned int flags, size_t cd_nelmts,
|
||||
if (flags & H5Z_FLAG_REVERSE) {
|
||||
|
||||
/* Replace buffer */
|
||||
#ifdef HDF5_HAS_ALLOCATE_MEMORY
|
||||
newbuf = H5allocate_memory(*buf_size,0);
|
||||
#else
|
||||
newbuf = malloc(*buf_size * sizeof(void));
|
||||
#endif
|
||||
if(newbuf == NULL) abort();
|
||||
memcpy(newbuf,*buf,*buf_size);
|
||||
/* reclaim old buffer */
|
||||
H5free_memory(*buf);
|
||||
/* reclaim old buffer */
|
||||
#ifdef HDF5_HAS_H5FREE
|
||||
H5free_memory(*buf);
|
||||
#else
|
||||
free(*buf);
|
||||
#endif
|
||||
*buf = newbuf;
|
||||
|
||||
} else {
|
||||
|
||||
/* Replace buffer */
|
||||
newbuf = H5allocate_memory(*buf_size,0);
|
||||
if(newbuf == NULL) abort();
|
||||
#ifdef HDF5_HAS_ALLOCATE_MEMORY
|
||||
newbuf = H5allocate_memory(*buf_size,0);
|
||||
#else
|
||||
newbuf = malloc(*buf_size * sizeof(void));
|
||||
#endif
|
||||
if(newbuf == NULL) abort();
|
||||
memcpy(newbuf,*buf,*buf_size);
|
||||
/* reclaim old buffer */
|
||||
H5free_memory(*buf);
|
||||
#ifdef HDF5_HAS_H5FREE
|
||||
H5free_memory(*buf);
|
||||
#else
|
||||
free(*buf);
|
||||
#endif
|
||||
*buf = newbuf;
|
||||
|
||||
}
|
||||
|
@ -48,10 +48,9 @@ byteswap4(unsigned char* mem)
|
||||
void
|
||||
NC_filterfix8(void* mem0, int decode)
|
||||
{
|
||||
|
||||
unsigned char* mem = mem0;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if(decode) { /* Apply inverse of the encode case */
|
||||
unsigned char* mem = mem0;
|
||||
if(decode) { /* Apply inverse of the encode case */
|
||||
byteswap4(mem); /* step 1: byte-swap each piece */
|
||||
byteswap4(mem+4);
|
||||
byteswap8(mem); /* step 2: convert to little endian format */
|
||||
@ -61,8 +60,6 @@ unsigned char* mem = mem0;
|
||||
byteswap4(mem+4);
|
||||
}
|
||||
#else /* Little endian */
|
||||
|
||||
|
||||
/* No action is necessary */
|
||||
#endif
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
# Copyright 2018, UCAR/Unidata
|
||||
# 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
|
||||
BZIP2SRC= blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user