Merge branch 'master' into patch-4

This commit is contained in:
Greg Sjaardema 2016-09-15 11:04:30 -06:00 committed by GitHub
commit dab30468f9
46 changed files with 1381 additions and 1332 deletions

View File

@ -5,25 +5,25 @@ services:
env:
matrix:
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-gcc-x64-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-clang-x64-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-gcc-x86-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-clang-x86-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-fsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x64-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-fsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x64-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-fsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x86-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-fsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x86-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-gcc-x64-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-clang-x64-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-gcc-x86-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-clang-x86-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-funsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x64-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-funsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x64-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-funsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x86-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-funsigned-char --disable-netcdf-4 --disable-dap-remote-tests' COPTS='-DENABLE_NETCDF_4=OFF -DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x86-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-gcc-x64-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-clang-x64-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-gcc-x86-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DCMAKE_C_FLAGS=-fsigned-char' CURHOST=docker-clang-x86-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-fsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x64-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-fsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x64-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-fsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x86-signed
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-fsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-fsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x86-signed
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-gcc-x64-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-clang-x64-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc COPTS='-DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-gcc-x86-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang COPTS='-DCMAKE_C_FLAGS=-funsigned-char' CURHOST=docker-clang-x86-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-funsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x64-unsigned
- DOCKIMG=unidata/nctests:serial USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-funsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x64-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=gcc AC_COPTS='CFLAGS=-funsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-gcc-x86-unsigned
- DOCKIMG=unidata/nctests:serial32 USECMAKE=TRUE USEAC=TRUE DISTCHECK=TRUE USE_CC=clang AC_COPTS='CFLAGS=-funsigned-char --disable-dap-remote-tests' COPTS='-DCMAKE_C_FLAGS=-funsigned-char -DENABLE_DAP_REMOTE_TESTS=OFF' CURHOST=docker-clang-x86-unsigned
before_install:
- docker pull $DOCKIMG > /dev/null

View File

@ -572,6 +572,10 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
##
# Include the HDF5 include directory.
##
IF(HDF5_INCLUDE_DIRS AND NOT HDF5_INCLUDE_DIR)
SET(HDF5_INCLUDE_DIR ${HDF5_INCLUDE_DIRS})
ENDIF()
MESSAGE(STATUS "Using HDF5 include dir: ${HDF5_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
###
@ -1074,14 +1078,6 @@ MARK_AS_ADVANCED(ENABLE_DAP_REMOTE_TESTS ENABLE_DAP_LONG_TESTS USE_REMOTE_CDASH)
MARK_AS_ADVANCED(ENABLE_DOXYGEN_BUILD_RELEASE_DOCS DOXYGEN_ENABLE_TASKS ENABLE_DOXYGEN_SERVER_SIDE_SEARCH)
MARK_AS_ADVANCED(ENABLE_SHARED_LIBRARY_VERSION)
# This option is temporary and should always be on except if netcdf-4 is off.
IF(ENABLE_NETCDF_4)
OPTION(ENABLE_FILEINFO "Enable FILEINFO." ON)
ELSE()
OPTION(ENABLE_FILEINFO "Enable FILEINFO." OFF)
ENDIF()
MARK_AS_ADVANCED(ENABLE_FILEINFO)
################################
# Option checks
################################

View File

@ -7,6 +7,14 @@ This file contains a high-level description of this package's evolution. Release
> Note: The combination of netCDF-C library versions earlier than 4.4.1 and libhdf5 1.10.0+ should be avoided, as they will result in binary files not readable by systems using earlier libhdf5 versions.
## 4.4.2 - TBD
* [Bug] Fixed an issue with `nc_inq_type()` not returning proper value in some circumstances. See [GitHub #317](https://github.com/Unidata/netcdf-c/issues/317) for more information.
* [Bug] Corrected an issue related to test failures when `--disable-utilities` or `-DENABLE_UTILITIES=OFF` are specified when building with autotools or cmake, respectively. See [GitHub #313](https://github.com/Unidata/netcdf-c/issues/313) for more information.
* [Bug][Enhancement] Corrected a behavioral issue with the `_NCProperties` attribute taking up too much space. See [GitHub #300](https://github.com/Unidata/netcdf-c/issues/300) and [GitHub #301](https://github.com/Unidata/netcdf-c/pull/301) for more information.
* [Bug] Corrected behavior for `nc-config` so that, if `nf-config` is found in system, the proper fortran-related information will be conveyed. See [GitHub #296](https://github.com/Unidata/netcdf-c/issues/296] for more information.
## 4.4.1 - June 28, 2016
* [File Change] Starting with release 4.4.1, netCDF-4 files created will have superblock version 0 instead of superblock version 2, as was observed in previous netCDF versions. This is due to a workaround required to avoid backwards binary incompatibility when using libhdf5 1.10.x or greater. Superblock versions 0 and 2 appear to be forward and backward compatible. Other than a different superblock number the data should remain consistent.

View File

@ -87,7 +87,6 @@ are set when opening a binary file on Windows. */
#cmakedefine ENABLE_DAP 1
#cmakedefine ENABLE_DAP_GROUPS 1
#cmakedefine ENABLE_DAP_REMOTE_TESTS 1
#cmakedefine ENABLE_FILEINFO 1
#cmakedefine EXTRA_TESTS
#cmakedefine USE_NETCDF4 1
#cmakedefine USE_LIBDL 1

View File

@ -1,4 +1,4 @@
M# -*- Autoconf -*-
# -*- Autoconf -*-
## Process this file with autoconf to produce a configure script.
# This is part of Unidata's netCDF package. Copyright 2005-2012, see
@ -204,21 +204,6 @@ enable_netcdf_4=no
fi
AC_MSG_RESULT([$enable_netcdf_4])
####
# Is Netcdf4 file info capture enabled; includes properties attribute
# We do not actually provide a direct flag for disabling this
if test "x$enable_netcdf_4" = xyes ; then
enable_fileinfo=yes
else
enable_fileinfo=no
fi
AC_MSG_CHECKING([If file info capture is enabled])
AC_MSG_RESULT([$enable_fileinfo])
if test "x$enable_fileinfo" = xyes ; then
AC_DEFINE([ENABLE_FILEINFO], [1], [file info])
fi
AM_CONDITIONAL(ENABLE_FILEINFO, [test x$enable_fileinfo = xyes])
# Does the user require dynamic loading?
# This is only for those hdf5 installs that support it.
AC_MSG_CHECKING([do we require hdf5 dynamic-loading support])

View File

@ -322,7 +322,7 @@ We test releases on the following operating systems with various compilers:
- Solaris
- Windows (some versions, see below)
The [NetCDF Installation and Porting Guide](http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/index.html) explains how to build netCDF from source on various platforms. Often, it's as easy as running
The [NetCDF Installation and Porting Guide](@ref getting_and_building_netcdf) explains how to build netCDF from source on various platforms. Often, it's as easy as running
~~~~ {.boldcode}
./configure
@ -483,7 +483,7 @@ How do I build and install netCDF for a specific development environment? {#How-
You have to build and install the netCDF C library first, before you build and install other language libraries that depend on it, such as Fortran, C++, or Python netCDF libraries. The netCDF Java library is mostly independent of the netCDF C library, unless you need to write netCDF-4 files from Java, in which case you will also need an installed netCDF C library.
For more details, see
[Getting and Building netCDF](http://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html).
[NetCDF Installation and Porting Guide](@ref getting_and_building_netcdf).
----------

View File

@ -131,10 +131,11 @@ It is strongly recommended that applicable conventions be followed unless there
These attributes can occur in netCDF enhanced (netcdf-4) files beginning
with version 4.4.1. They all are associated with the root group as
global attributes. They are hidden in the sense that they have no
attribute number, so they can only be accessed thru the netcdf-C api
calls via the name. Additionally, these attributes will not be counted
in the number of global attributes in the root group.
global attributes, although only _NCProperties is actually stored in the
file; the others are computed. They are hidden in the sense that they
have no attribute number, so they can only be accessed thru the netcdf-C
API calls via the name. Additionally, these attributes will not be
counted in the number of global attributes in the root group.
The simplest way to view these attributes is to use the -s flag to the
ncdump command. Alternatively, one can use the following API calls to
@ -152,7 +153,6 @@ Using the following API calls will fail.
- nc_del_att
- nc_put_att (and derivatives)
`_NCProperties`
> This attribute is persistent in the file, but hidden. It is inserted in the file at creation time and is never modified after that point. It specifies the following.

View File

@ -774,15 +774,15 @@ Learn about a compound type.
.HP
FDECL(def_vlen, (INCID(), INAME(), INCTYPE(base_typeid), ONCTYPE(xtypep)))
.sp
Create a varaible length array type.
Create a variable length array type.
.HP
FDECL(inq_vlen, (INCID(), INCTYPE(), ONAME(), OSIZET(datum_sizep), ONCTYPE(base_nc_typep)))
.sp
Learn about a varaible length array type.
Learn about a variable length array type.
.HP
FDECL(free_vlen, (nc_vlen_t *vl))
.sp
Free memory comsumed by reading data of a varaible length array type.
Free memory comsumed by reading data of a variable length array type.
.HP
FDECL(put_vlen_element, (INCID(), INCTYPE(), IVOIDP(vlen_element), ISIZET(len), IVOIDP(data)))
.sp

View File

@ -5180,7 +5180,7 @@ rh in an existing netCDF dataset named foo.nc:
@findex NF90_INQ_VARID
@cindex NF90_INQ_VARID, example
Given the name of a varaible, nf90_inq_varid finds the variable ID.
Given the name of a variable, nf90_inq_varid finds the variable ID.
@heading Usage
@example

View File

@ -14,7 +14,7 @@ INSTALL(FILES ${netCDF_BINARY_DIR}/include/netcdf_meta.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers)
IF(ENABLE_PNETCDF OR ENABLE_PARALLEL)
IF(ENABLE_PNETCDF OR ENABLE_PARALLEL4)
INSTALL(FILES ${netCDF_SOURCE_DIR}/include/netcdf_par.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers)

View File

@ -102,10 +102,8 @@ typedef enum {VAR, DIM, ATT} NC_OBJ_T;
/* Boolean type, to make the code easier to read */
typedef enum {NC_FALSE = 0, NC_TRUE = 1} nc_bool_t;
#ifdef ENABLE_FILEINFO
/*Forward*/
struct NCFILEINFO;
#endif
/* Generic doubly-linked list node */
typedef struct NC_LIST_NODE
@ -322,9 +320,7 @@ typedef struct NC_HDF5_FILE_INFO
nc_bool_t hdf4; /* True for HDF4 file */
int sdid;
#endif /* USE_HDF4 */
#ifdef ENABLE_FILEINFO
struct NCFILEINFO* fileinfo;
#endif
} NC_HDF5_FILE_INFO_T;
@ -452,12 +448,9 @@ For netcdf4 files, capture state information about the following:
5. Per file: _NCProperties attribute
*/
#ifdef ENABLE_FILEINFO
#define NCPROPS "_NCProperties"
#define NCPROPS_VERSION (1)
#define NCPROPSSEP '|'
#define NCPROPS_LENGTH (8192)
/* Currently used properties */
#define NCPVERSION "version" /* Of the properties format */
@ -475,7 +468,6 @@ struct NCFILEINFO {
int version; /* 0 => not defined */
char hdf5ver[NC_MAX_NAME+1];
char netcdfver[NC_MAX_NAME+1];
char text[NCPROPS_LENGTH+1]; /* Value of the NCPROPS attribute */
} propattr;
};
@ -484,11 +476,10 @@ extern struct NCPROPINFO globalpropinfo;
extern int NC4_fileinfo_init(void); /*libsrc4/ncinfo.c*/
extern int NC4_get_fileinfo(struct NC_HDF5_FILE_INFO* info, struct NCPROPINFO*); /*libsrc4/ncinfo.c*/
extern int NC4_put_propattr(struct NC_HDF5_FILE_INFO* info); /*libsrc4/ncinfo.c*/
extern int NC4_buildpropinfo(struct NCPROPINFO* info,char** propdatap);
/* ENABLE_FILEINFO => ENABLE_NETCDF4 */
extern int NC4_hdf5get_libversion(unsigned*,unsigned*,unsigned*);/*libsrc4/nc4hdf.c*/
extern int NC4_hdf5get_superblock(struct NC_HDF5_FILE_INFO*, int*);/*libsrc4/nc4hdf.c*/
extern int NC4_isnetcdf4(struct NC_HDF5_FILE_INFO*); /*libsrc4/nc4hdf.c*/
#endif /*ENABLE_FILEINFO*/
#endif /* _NETCDF4_ */

View File

@ -4,7 +4,7 @@ alias xx="cd ..;make; cd libdap2"
PARMS=""; ARGS=""; CON="" ; CE=""; OCON="" ; VAR=""; SHARP='#'
alias q0=;alias qq=;alias qv=;alias q=;alias qh=;alias qqh=;alias qall=;alias qv=;alias qo=;
F="https://eosdap.hdfgroup.org:8080/opendap/data/test/kent/ceres-converted/edition_4/CER_SSF1deg-Hour_Terra-MODIS_TestSuite_000000.200407D01.hdf"
F="http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.reanalysis.dailyavgs/pressure/air.1947.nc"
if test -e "/cygdrive/f/git/netcdf-c" ; then
TOP="/cygdrive/f/git/netcdf-c"

View File

@ -1587,7 +1587,7 @@ nc_inq_type(int ncid, nc_type xtype, char *name, size_t *size)
if(stat != NC_NOERR) { /* bad ncid; do what we can */
/* For compatibility, we need to allow inq about
atomic types, even if ncid is ill-defined */
if(xtype <= ATOMICTYPEMAX5) {
if(xtype <= ATOMICTYPEMAX4) {
if(name) strncpy(name,NC_atomictypename(xtype),NC_MAX_NAME);
if(size) *size = NC_atomictypelen(xtype);
return NC_NOERR;

View File

@ -40,9 +40,17 @@ than 32767. Similarly, the number of simultaneously open netCDF-4
files in one program context is limited to 32767.
*/
/** \{ */
/*!
/** \{*/ /* All these functions are part of the above defgroup... */
/*! Return the group ID for a group given the name.
@param[in] ncid A valid file or group ncid.
@param[in] name The name of the group you are querying.
@param[out] grp_ncid Pointer to memory to hold the group ncid.
@returns Error code or ::NC_NOERR or no error.
*/
int nc_inq_ncid(int ncid, const char *name, int *grp_ncid)
@ -53,6 +61,15 @@ int nc_inq_ncid(int ncid, const char *name, int *grp_ncid)
return ncp->dispatch->inq_ncid(ncid,name,grp_ncid);
}
/*! Get a list of groups or subgroups from a file or groupID.
@param[in] ncid The ncid of the file or parent group.
@param[out] numgrps Pointer to memory to hold the number of groups.
@param[out] ncids Pointer to memory to hold the ncid for each group.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_grps(int ncid, int *numgrps, int *ncids)
{
NC* ncp;
@ -61,6 +78,13 @@ int nc_inq_grps(int ncid, int *numgrps, int *ncids)
return ncp->dispatch->inq_grps(ncid,numgrps,ncids);
}
/*! Get the name of a group given an ID.
@param[in] ncid The ncid of the file or parent group.
@param[out] name The name of the group associated with the id.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_grpname(int ncid, char *name)
{
NC* ncp;
@ -69,6 +93,16 @@ int nc_inq_grpname(int ncid, char *name)
return ncp->dispatch->inq_grpname(ncid,name);
}
/*! Get the full path/groupname of a group/subgroup given an ID.
@param[in] ncid The ncid of the file or parent group.
@param[out] lenp Pointer to memory to hold the length of the full name.
@param[out] full_name Pointer to memory to hold the full name of the group including root/parent.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
{
NC* ncp;
@ -77,12 +111,28 @@ int nc_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
return ncp->dispatch->inq_grpname_full(ncid,lenp,full_name);
}
/*! Get the length of a group name given an ID.
@param[in] ncid The ncid of the group in question.
@param[out] lenp Pointer to memory to hold the length of the name of the group in question.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_grpname_len(int ncid, size_t *lenp)
{
int stat = nc_inq_grpname_full(ncid,lenp,NULL);
return stat;
}
/*! Get the ID of the parent based on a group ID.
@param[in] ncid The ncid of the group in question.
@param[out] parent_ncid Pointer to memory to hold the identifier of the parent of the group in question.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_grp_parent(int ncid, int *parent_ncid)
{
NC* ncp;
@ -91,7 +141,15 @@ int nc_inq_grp_parent(int ncid, int *parent_ncid)
return ncp->dispatch->inq_grp_parent(ncid,parent_ncid);
}
/*! This has same semantics as nc_inq_ncid
/*! Get a group ncid given the group name.
@param[in] ncid The ncid of the file.
@param[in] grp_name The name of the group in question.
@param[out] grp_ncid Pointer to memory to hold the identifier of the group in question.
@returns Error code or ::NC_NOERR for no error.
\note{This has same semantics as nc_inq_ncid}
*/
int nc_inq_grp_ncid(int ncid, const char *grp_name, int *grp_ncid)
@ -99,6 +157,15 @@ int nc_inq_grp_ncid(int ncid, const char *grp_name, int *grp_ncid)
return nc_inq_ncid(ncid,grp_name,grp_ncid);
}
/*! Get the full ncid given a group name.
@param[in] ncid The ncid of the file.
@param[in] full_name The full name of the group in question.
@param[out] grp_ncid Pointer to memory to hold the identifier of the full group in question.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid)
{
NC* ncp;
@ -107,6 +174,16 @@ int nc_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid)
return ncp->dispatch->inq_grp_full_ncid(ncid,full_name,grp_ncid);
}
/*! Get a list of varids associated with a group given a group ID.
@param[in] ncid The ncid of the group in question.
@param[out] nvars Pointer to memory to hold the number of variables in the group in question.
@param[out] varids Pointer to memory to hold the variable ids contained by the group in question.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_varids(int ncid, int *nvars, int *varids)
{
NC* ncp;
@ -115,6 +192,16 @@ int nc_inq_varids(int ncid, int *nvars, int *varids)
return ncp->dispatch->inq_varids(ncid,nvars,varids);
}
/*! Retrieve a list of dimension ids associated with a group.
@param[in] ncid The ncid of the group in question.
@param[out] ndims Pointer to memory to contain the number of dimids associated with the group.
@param[out] dimids Pointer to memory to contain the number of dimensions associated with the group.
@param[in] include_parents If non-zero, parent groups are also traversed.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents)
{
NC* ncp;
@ -123,6 +210,16 @@ int nc_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents)
return ncp->dispatch->inq_dimids(ncid,ndims,dimids,include_parents);
}
/*! Retrieve a list of types associated with a group
@param[in] ncid The ncid for the group in question.
@param[out] ntypes Pointer to memory to hold the number of typeids contained by the group in question.
@param[out] typeids Pointer to memory to hold the typeids contained by the group in question.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_inq_typeids(int ncid, int *ntypes, int *typeids)
{
NC* ncp;
@ -131,6 +228,43 @@ int nc_inq_typeids(int ncid, int *ntypes, int *typeids)
return ncp->dispatch->inq_typeids(ncid,ntypes,typeids);
}
/*! Define a new group.
The function nc_def_grp() adds a new
group to an open netCDF dataset in define mode. It returns (as an
argument) a group id, given the parent ncid and the name of the group.
A group may be a top-level group if it is passed the ncid of the file,
or a sub-group if passed the ncid of an existing group.
@param[in] parent_ncid The ncid of the parent for the group.
@param[in] name Name of the new group.
@param[out] new_ncid Pointer to memory to hold the new ncid.
@returns Error code or ::NC_NOERR for no error.
@retval ::NC_NOERR No error.
@retval ::NC_ENOTNC4 Not an nc4 file.
@retval ::NC_ENOTINDEFINE Not in define mode.
@retval ::NC_ESTRICTNC3 Not permissible in nc4 classic mode.
@retval ::NC_EPERM Write to read only.
@retval ::NC_ENOMEM Memory allocation (malloc) failure.
@retval ::NC_ENAMEINUSE String match to name in use.
\section nc_def_grp_example Example
Here is an example using nc_def_grp() to create a new group.
\code{.c}
#include <netcdf.h>
...
int status, ncid, grpid, latid, recid;
...
\endcode
*/
int nc_def_grp(int parent_ncid, const char *name, int *new_ncid)
{
NC* ncp;
@ -139,6 +273,14 @@ int nc_def_grp(int parent_ncid, const char *name, int *new_ncid)
return ncp->dispatch->def_grp(parent_ncid,name,new_ncid);
}
/*! Rename a group.
@param[in] grpid The ID for the group in question.
@param[in] name The new name for the group.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_rename_grp(int grpid, const char *name)
{
NC* ncp;
@ -147,6 +289,13 @@ int nc_rename_grp(int grpid, const char *name)
return ncp->dispatch->rename_grp(grpid,name);
}
/*! Print the metadata for a file.
@param[in] ncid The ncid of an open file.
@returns Error code or ::NC_NOERR for no error.
*/
int nc_show_metadata(int ncid)
{
NC* ncp;

View File

@ -571,12 +571,34 @@ nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
#endif /* USE_NETCDF4 */
/**
/*!
Used in libdap2 and libdap4.
@param[in] ncid ncid for file.
@param[in] varid varid for variable in question.
@param[out] name Pointer to memory to contain the name of the variable.
@param[out] xtypep Pointer to memory to contain the type of the variable.
@param[out] ndimsp Pointer to memory to store the number of associated dimensions for the variable.
@param[out] dimidsp Pointer to memory to store the dimids associated with the variable.
@param[out] nattsp Pointer to memory to store the number of attributes associated with the variable.
@param[out] shufflep Pointer to memory to store shuffle information associated with the variable.
@param[out] deflatep Pointer to memory to store compression type associated with the variable.
@param[out] deflate_levelp Pointer to memory to store compression level associated with the variable.
@param[out] fletcher32p Pointer to memory to store compression information associated with the variable.
@param[out] contiguousp Pointer to memory to store contiguous-data information associated with the variable.
@param[out] chunksizesp Pointer to memory to store chunksize information associated with the variable.
@param[out] no_fill Pointer to memory to store whether or not there is a fill value associated with the variable.
@param[out] fill_valuep Pointer to memory to store the fill value (if one exists) for the variable.
@param[out] endiannessp Pointer to memory to store endianness value. One of ::NC_ENDIAN_BIG ::NC_ENDIAN_LITTLE ::NC_ENDIAN_NATIVE
@param[out] options_maskp Pointer to memory to store mask options information.
@param[out] pixels_per_blockp Pointer to memory to store pixels-per-block information for chunked data.
\note Expose access to nc_inq_var_all().
\internal
\ingroup variables
Expose access to nc_inq_var_all().
Used in libdap2 and libdap4.
*/
int
@ -597,7 +619,7 @@ NC_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
contiguousp, chunksizesp,
no_fill, fill_valuep,
endiannessp,
options_maskp,
options_maskp,
pixels_per_blockp);
}

View File

@ -67,11 +67,8 @@ nc_initialize()
#endif
#ifdef USE_NETCDF4
if((stat = NC4_initialize())) goto done;
#endif /* USE_NETCDF4 */
#ifdef ENABLE_FILEINFO
stat = NC4_fileinfo_init();
#endif
#endif /* USE_NETCDF4 */
done:
return stat;

View File

@ -475,10 +475,12 @@ NC3_rename_dim( int ncid, int dimid, const char *unewname)
free(newname);
if(newStr == NULL)
return NC_ENOMEM;
dimp->name = newStr;
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveDim(&ncp->dims, old->cp);
dimp->name = newStr;
NC_hashmapAddDim(&ncp->dims, dimid, newStr->cp);
free_NC_string(old);
@ -487,13 +489,15 @@ NC3_rename_dim( int ncid, int dimid, const char *unewname)
/* else, not in define mode */
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveDim(&ncp->dims, old->cp);
status = set_NC_string(dimp->name, newname);
free(newname);
if(status != NC_NOERR)
return status;
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveDim(&ncp->dims, old->cp);
NC_hashmapAddDim(&ncp->dims, dimid, dimp->name->cp);
set_NC_hdirty(ncp);

View File

@ -740,14 +740,14 @@ NC3_rename_var(int ncid, int varid, const char *unewname)
return NC_ENOMEM;
if(NC_indef(ncp))
{
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveVar(&ncp->vars, old->cp);
newStr = new_NC_string(strlen(newname),newname);
free(newname);
if(newStr == NULL)
return(-1);
varp->name = newStr;
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveVar(&ncp->vars, old->cp);
NC_hashmapAddVar(&ncp->vars, varid, newStr->cp);
free_NC_string(old);
@ -755,13 +755,14 @@ NC3_rename_var(int ncid, int varid, const char *unewname)
}
/* else, not in define mode */
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveVar(&ncp->vars, old->cp);
status = set_NC_string(varp->name, newname);
free(newname);
if(status != NC_NOERR)
return status;
/* Remove old name from hashmap; add new... */
NC_hashmapRemoveVar(&ncp->vars, old->cp);
NC_hashmapAddVar(&ncp->vars, varid, varp->name->cp);
set_NC_hdirty(ncp);

View File

@ -15,10 +15,8 @@ endif
# This is our output. The netCDF-4 convenience library.
noinst_LTLIBRARIES = libnetcdf4.la
libnetcdf4_la_SOURCES = nc4dispatch.c nc4dispatch.h nc4attr.c nc4dim.c \
nc4file.c nc4grp.c nc4hdf.c nc4internal.c nc4type.c nc4var.c ncfunc.c error4.c
if ENABLE_FILEINFO
libnetcdf4_la_SOURCES += nc4info.c
endif
nc4file.c nc4grp.c nc4hdf.c nc4internal.c nc4type.c nc4var.c ncfunc.c error4.c \
nc4info.c
EXTRA_DIST=CMakeLists.txt

View File

@ -17,10 +17,8 @@ conditions.
#include "nc4dispatch.h"
#include "ncdispatch.h"
#ifdef ENABLE_FILEINFO
static int nc4_get_att_special(NC_HDF5_FILE_INFO_T*, const char*,
nc_type*, nc_type, size_t*, int*, int, void*);
#endif
int nc4typelen(nc_type type);
@ -62,7 +60,6 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name,
if ((retval = nc4_normalize_name(name, norm_name)))
BAIL(retval);
#ifdef ENABLE_FILEINFO
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** sp;
for(sp = NC_RESERVED_SPECIAL_LIST;*sp;sp++) {
@ -71,7 +68,6 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name,
}
}
}
#endif
/* Find the attribute, if it exists.
<strike>If we don't find it, we are major failures.</strike>
@ -251,7 +247,6 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
if ((retval = nc4_check_name(name, norm_name)))
return retval;
#ifdef ENABLE_FILEINFO
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** sp;
for(sp = NC_RESERVED_SPECIAL_LIST;*sp;sp++) {
@ -260,7 +255,6 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
}
}
}
#endif
/* Find att, if it exists. */
if (varid == NC_GLOBAL)
@ -877,7 +871,6 @@ nc4_put_att_tc(int ncid, int varid, const char *name, nc_type file_type,
mem_type_is_long, op);
}
#ifdef ENABLE_FILEINFO
static int
nc4_get_att_special(NC_HDF5_FILE_INFO_T* h5, const char* name,
nc_type* filetypep, nc_type mem_type, size_t* lenp,
@ -888,14 +881,21 @@ nc4_get_att_special(NC_HDF5_FILE_INFO_T* h5, const char* name,
return NC_EATTMETA;
if(strcmp(name,NCPROPS)==0) {
char* propdata = NULL;
int stat = NC_NOERR;
int len;
if(h5->fileinfo->propattr.version == 0)
return NC_ENOTATT;
if(mem_type == NC_NAT) mem_type = NC_CHAR;
if(mem_type != NC_CHAR)
return NC_ECHAR;
if(filetypep) *filetypep = NC_CHAR;
if(lenp) *lenp = strlen(h5->fileinfo->propattr.text);
if(data) strcpy((char*)data,h5->fileinfo->propattr.text);
stat = NC4_buildpropinfo(&h5->fileinfo->propattr, &propdata);
if(stat != NC_NOERR) return stat;
len = strlen(propdata);
if(lenp) *lenp = len;
if(data) strncpy((char*)data,propdata,len+1);
free(propdata);
} else if(strcmp(name,ISNETCDF4ATT)==0
|| strcmp(name,SUPERBLOCKATT)==0) {
unsigned long long iv = 0;
@ -922,7 +922,6 @@ nc4_get_att_special(NC_HDF5_FILE_INFO_T* h5, const char* name,
}
return NC_NOERR;
}
#endif
/* Read an attribute of any type, with type conversion. This may be
* called by any of the nc_get_att_* functions. */

View File

@ -101,15 +101,12 @@ NULL
const char* NC_RESERVED_ATT_LIST[] = {
NC_ATT_FORMAT,
NC3_STRICT_ATT_NAME,
#ifdef ENABLE_FILEINFO
NCPROPS,
ISNETCDF4ATT,
SUPERBLOCKATT,
#endif
NULL
};
#ifdef ENABLE_FILEINFO
/* Define the subset of the reserved list that is readable by name only */
const char* NC_RESERVED_SPECIAL_LIST[] = {
ISNETCDF4ATT,
@ -117,7 +114,6 @@ SUPERBLOCKATT,
NCPROPS,
NULL
};
#endif
/* These are the default chunk cache sizes for HDF5 files created or
* opened with netCDF-4. */
@ -468,10 +464,8 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
/* Define mode gets turned on automatically on create. */
nc4_info->flags |= NC_INDEF;
#ifdef ENABLE_FILEINFO
NC4_get_fileinfo(nc4_info,&globalpropinfo);
NC4_put_propattr(nc4_info);
#endif
return NC_NOERR;
@ -2355,9 +2349,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
num_plists--;
#endif
#ifdef ENABLE_FILEINFO
NC4_get_fileinfo(nc4_info,NULL);
#endif
return NC_NOERR;
@ -3094,9 +3086,7 @@ close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5, int abort)
}
#endif
#ifdef ENABLE_FILEINFO
if(h5->fileinfo) free(h5->fileinfo);
#endif
if (H5Fclose(h5->hdfid) < 0)
{

View File

@ -550,9 +550,9 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
NC_VAR_INFO_T *var;
NC_DIM_INFO_T *dim;
hid_t file_spaceid = 0, mem_spaceid = 0, xfer_plistid = 0;
hsize_t xtend_size[NC_MAX_VAR_DIMS] , count[NC_MAX_VAR_DIMS];
long long unsigned xtend_size[NC_MAX_VAR_DIMS];
hsize_t fdims[NC_MAX_VAR_DIMS], fmaxdims[NC_MAX_VAR_DIMS];
hsize_t start[NC_MAX_VAR_DIMS];
hsize_t start[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
char *name_to_use;
int need_to_extend = 0;
int retval = NC_NOERR, range_error = 0, i, d2;
@ -617,7 +617,7 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
log_dim_info(var, fdims, fmaxdims, start, count);
#endif
/* Check dimension bounds. Remember that unlimited dimnsions can
/* Check dimension bounds. Remember that unlimited dimensions can
* put data beyond their current length. */
for (d2 = 0; d2 < var->ndims; d2++)
{
@ -625,7 +625,8 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
assert(dim && dim->dimid == var->dimids[d2]);
if (!dim->unlimited)
{
if (start[d2] >= (hssize_t)fdims[d2])
if (start[d2] > (hssize_t)fdims[d2] ||
(start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
BAIL_QUIET(NC_EINVALCOORDS);
if (start[d2] + count[d2] > fdims[d2])
BAIL_QUIET(NC_EEDGE);
@ -733,11 +734,11 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
{
if (start[d2] + count[d2] > fdims[d2])
{
xtend_size[d2] = start[d2] + count[d2];
xtend_size[d2] = (long long unsigned)(start[d2] + count[d2]);
need_to_extend++;
}
else
xtend_size[d2] = fdims[d2];
xtend_size[d2] = (long long unsigned)fdims[d2];
if (start[d2] + count[d2] > dim->len)
{
@ -747,7 +748,7 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
}
else
{
xtend_size[d2] = dim->len;
xtend_size[d2] = (long long unsigned)dim->len;
}
}
@ -775,15 +776,15 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
BAIL(NC_ECANTEXTEND);
/* Reach consensus about dimension sizes to extend to */
/* (Note: Somewhat hackish, with the use of MPI_INTEGER, but MPI_MAX is
* correct with this usage, as long as it's not executed on
* heterogeneous systems)
*/
if(MPI_SUCCESS != MPI_Allreduce(MPI_IN_PLACE, &xtend_size, (var->ndims * (sizeof(hsize_t) / sizeof(int))), MPI_UNSIGNED, MPI_MAX, h5->comm))
if(MPI_SUCCESS != MPI_Allreduce(MPI_IN_PLACE, xtend_size, var->ndims, MPI_UNSIGNED_LONG_LONG, MPI_MAX, h5->comm))
BAIL(NC_EMPI);
}
#endif /* USE_PARALLEL4 */
if (H5Dset_extent(var->hdf_datasetid, xtend_size) < 0)
/* Convert xtend_size back to hsize_t for use with H5Dset_extent */
for (d2 = 0; d2 < var->ndims; d2++)
fdims[d2] = (hsize_t)xtend_size[d2];
if (H5Dset_extent(var->hdf_datasetid, fdims) < 0)
BAIL(NC_EHDFERR);
if (file_spaceid > 0 && H5Sclose(file_spaceid) < 0)
BAIL2(NC_EHDFERR);
@ -956,7 +957,8 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
BAIL(retval);
/* Check for out of bound requests. */
if (start[d2] >= (hssize_t)ulen && count[d2])
if (start[d2] > (hssize_t)ulen ||
(start[d2] == (hssize_t)ulen && count[d2] > 0))
BAIL_QUIET(NC_EINVALCOORDS);
if (start[d2] + count[d2] > ulen)
BAIL_QUIET(NC_EEDGE);
@ -979,7 +981,8 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
else
{
/* Check for out of bound requests. */
if (start[d2] >= (hssize_t)fdims[d2])
if (start[d2] > (hssize_t)fdims[d2] ||
(start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
BAIL_QUIET(NC_EINVALCOORDS);
if (start[d2] + count[d2] > fdims[d2])
BAIL_QUIET(NC_EEDGE);
@ -1952,7 +1955,7 @@ write_nc3_strict_att(hid_t hdf_grpid)
{
hid_t attid = 0, spaceid = 0;
int one = 1, num, a;
char att_name[NC_MAX_NAME + 1];
char att_name[NC_MAX_HDF5_NAME + 1];
int retval = NC_NOERR;
htri_t attr_exists;
@ -1977,12 +1980,12 @@ write_nc3_strict_att(hid_t hdf_grpid)
BAIL(NC_EFILEMETA);
exit:
if (spaceid && (H5Sclose(spaceid) < 0))
if (spaceid > 0 && (H5Sclose(spaceid) < 0))
BAIL2(NC_EFILEMETA);
#ifdef EXTRA_TESTS
num_spaces--;
#endif
if (attid && (H5Aclose(attid) < 0))
if (attid > 0 && (H5Aclose(attid) < 0))
BAIL2(NC_EFILEMETA);
return retval;
}
@ -3990,7 +3993,6 @@ reportopenobjects(int log, hid_t fid)
}
#ifdef ENABLE_FILEINFO
int
NC4_hdf5get_libversion(unsigned* major,unsigned* minor,unsigned* release)
{
@ -4063,7 +4065,6 @@ NC4_get_strict_att(NC_HDF5_FILE_INFO_T* h5)
{
int ncstat = NC_NOERR;
size_t size;
char text[NCPROPS_LENGTH+1];
hid_t grp = -1;
hid_t attid = -1;
herr_t herr = 0;
@ -4134,4 +4135,4 @@ NC4_walk(hid_t gid, int* countp)
return ncstat;
}
#endif

View File

@ -26,7 +26,6 @@ NC4_fileinfo_init(void)
int stat = NC_NOERR;
unsigned major,minor,release;
int super;
size_t total = 0;
/* Build nc properties */
memset((void*)&globalpropinfo,0,sizeof(globalpropinfo));
@ -39,75 +38,60 @@ NC4_fileinfo_init(void)
snprintf(globalpropinfo.hdf5ver,sizeof(globalpropinfo.hdf5ver),
"%1u.%1u.%1u",major,minor,release);
strncpy(globalpropinfo.netcdfver,PACKAGE_VERSION,sizeof(globalpropinfo.netcdfver));
/* Now build actual attribute text */
total = 0;
total += strlen(NCPVERSION);
total += strlen("=00000000|");
total += strlen(NCPNCLIBVERSION);
total += strlen(globalpropinfo.netcdfver);
total += strlen("=|");
total += strlen(NCPHDF5LIBVERSION);
total += strlen(globalpropinfo.hdf5ver);
total += strlen("="); /* Last pair has no trailing '|' */
if(total >= sizeof(globalpropinfo.text)) {
fprintf(stderr,"%s size is too small\n",NCPROPS);
goto done;
}
globalpropinfo.text[0] = '\0';
snprintf(globalpropinfo.text,sizeof(globalpropinfo.text),
"%s=%d|%s=%s|%s=%s",
NCPVERSION,globalpropinfo.version,
NCPNCLIBVERSION,globalpropinfo.netcdfver,
NCPHDF5LIBVERSION,globalpropinfo.hdf5ver);
done:
return stat;
}
static int
NC4_properties_parse(struct NCPROPINFO* ncprops)
NC4_properties_parse(struct NCPROPINFO* ncprops, const char* text)
{
int ret = NC_NOERR;
size_t len;
char propdata[NCPROPS_LENGTH]; /* match nc.h struct NCProperties */
char* p;
char* propdata = NULL;
ncprops->version = 0;
ncprops->hdf5ver[0] = '\0';
ncprops->netcdfver[0] = '\0';
strncpy(propdata,ncprops->text,sizeof(propdata)-1);
propdata[sizeof(propdata)-1] = '\0';
len = strlen(propdata);
len = strlen(text);
if(len == 0) return NC_NOERR;
propdata = (char*)malloc(len+1);
if(propdata == NULL) return NC_ENOMEM;
memcpy(propdata,text,len+1);
propdata[len] = '\0'; /* guarantee */
/* Walk and fill in ncinfo */
p = propdata;
while(*p) {
char* name = p;
char* value = NULL;
char* q = strchr(p,'=');
if(q == NULL)
return NC_EINVAL;
*q++ = '\0';
value = p = q;
q = strchr(p,NCPROPSSEP);
if(q == NULL) q = (p+strlen(p)); else* q++ = '\0';
p = q;
if(name != NULL && value != NULL) {
char* name = p;
char* value = NULL;
char* q = strchr(p,'=');
if(q == NULL)
{ret = NC_EINVAL; goto done;}
*q++ = '\0';
value = p = q;
q = strchr(p,NCPROPSSEP);
if(q == NULL) q = (p+strlen(p)); else* q++ = '\0';
p = q;
if(value != NULL) {
if(strcmp(name,NCPVERSION) == 0) {
int v = atoi(value);
if(v < 0) v = 0;
ncprops->version = v;
int v = atoi(value);
if(v < 0) v = 0;
ncprops->version = v;
} else if(strcmp(name,NCPNCLIBVERSION) == 0)
strncpy(ncprops->netcdfver,value,sizeof(ncprops->netcdfver)-1);
strncpy(ncprops->netcdfver,value,sizeof(ncprops->netcdfver)-1);
else if(strcmp(name,NCPHDF5LIBVERSION) == 0)
strncpy(ncprops->hdf5ver,value,sizeof(ncprops->hdf5ver)-1);
strncpy(ncprops->hdf5ver,value,sizeof(ncprops->hdf5ver)-1);
/* else ignore */
}
}
}
/* Guarantee null term */
ncprops->netcdfver[sizeof(ncprops->netcdfver)-1] = '\0';
ncprops->hdf5ver[sizeof(ncprops->hdf5ver)-1] = '\0';
return NC_NOERR;
done:
if(propdata != NULL) free(propdata);
return ret;
}
static int
@ -115,14 +99,14 @@ NC4_get_propattr(NC_HDF5_FILE_INFO_T* h5)
{
int ncstat = NC_NOERR;
size_t size;
H5T_class_t t_class;
char text[NCPROPS_LENGTH+1];
H5T_class_t t_class;
hid_t grp = -1;
hid_t attid = -1;
hid_t aspace = -1;
hid_t atype = -1;
hid_t ntype = -1;
herr_t herr = 0;
char* text = NULL;
/* Get root group */
grp = h5->root_grp->hdf_grpid; /* get root group */
@ -136,20 +120,24 @@ NC4_get_propattr(NC_HDF5_FILE_INFO_T* h5)
t_class = H5Tget_class(atype);
if(t_class != H5T_STRING) {ncstat = NC_EATTMETA; goto done;}
size = H5Tget_size(atype);
if(size != NCPROPS_LENGTH) {ncstat = NC_EATTMETA; goto done;}
if(size == 0) goto done;
text = (char*)malloc(size+1);
if(text == NULL)
{ncstat = NC_ENOMEM; goto done;}
HCHECK((ntype = H5Tget_native_type(atype, H5T_DIR_ASCEND)));
HCHECK((H5Aread(attid, ntype, text)));
/* Make sure its null terminated */
text[size] = '\0';
/* Try to parse text */
strncpy(h5->fileinfo->propattr.text,text,NCPROPS_LENGTH);
h5->fileinfo->propattr.text[NCPROPS_LENGTH-1] = '\0';
ncstat = NC4_properties_parse(&h5->fileinfo->propattr);
ncstat = NC4_properties_parse(&h5->fileinfo->propattr,text);
herr = 0;
}
}
done:
if(attid >= 0) HCHECK((H5Aclose(attid)));
if(aspace >= 0) HCHECK((H5Sclose(aspace)));
if(ntype >= 0) HCHECK((H5Tclose(ntype)));
if(atype >= 0) HCHECK((H5Tclose(atype)));
if(text != NULL) free(text);
return ncstat;
}
@ -157,8 +145,7 @@ int
NC4_put_propattr(NC_HDF5_FILE_INFO_T* h5)
{
int ncstat = NC_NOERR;
char text[NCPROPS_LENGTH+1];
H5T_class_t t_class;
H5T_class_t t_class;
size_t size;
hid_t grp = -1;
hid_t exists = -1;
@ -166,22 +153,33 @@ NC4_put_propattr(NC_HDF5_FILE_INFO_T* h5)
hid_t aspace = -1;
hid_t atype = -1;
herr_t herr = 0;
char* text = NULL;
/* Get root group */
grp = h5->root_grp->hdf_grpid; /* get root group */
/* See if the NCPROPS attribute exists */
if(H5Aexists(grp,NCPROPS) == 0) { /* Does not exist */
herr = -1;
/* Create a datatype to refer to. */
HCHECK((atype = H5Tcopy(H5T_C_S1)));
HCHECK((H5Tset_cset(atype, H5T_CSET_UTF8)));
HCHECK((H5Tset_size(atype, NCPROPS_LENGTH)));
HCHECK((aspace = H5Screate(H5S_SCALAR)));
HCHECK((attid = H5Acreate(grp, NCPROPS, atype, aspace, H5P_DEFAULT)));
HCHECK((H5Awrite(attid, atype, h5->fileinfo->propattr.text)));
herr = 0;
ncstat = NC4_buildpropinfo(&h5->fileinfo->propattr,&text);
if(text == NULL || ncstat != NC_NOERR) {
goto done;
}
herr = -1;
/* Create a datatype to refer to. */
HCHECK((atype = H5Tcopy(H5T_C_S1)));
HCHECK((H5Tset_cset(atype, H5T_CSET_ASCII)));
HCHECK((H5Tset_size(atype, strlen(text)+1))); /*keep nul term */
HCHECK((aspace = H5Screate(H5S_SCALAR)));
HCHECK((attid = H5Acreate(grp, NCPROPS, atype, aspace, H5P_DEFAULT)));
HCHECK((H5Awrite(attid, atype, text)));
herr = 0;
}
done:
done:
if(ncstat != NC_NOERR) {
if(text != NULL) {
free(text);
}
}
if(attid >= 0) HCHECK((H5Aclose(attid)));
if(aspace >= 0) HCHECK((H5Sclose(aspace)));
if(atype >= 0) HCHECK((H5Tclose(atype)));
@ -207,5 +205,54 @@ NC4_get_fileinfo(NC_HDF5_FILE_INFO_T* h5, struct NCPROPINFO* init)
h5->fileinfo->propattr = *init; /* Initialize */
}
done:
return ncstat;
return ncstat;
}
int
NC4_buildpropinfo(struct NCPROPINFO* info,char** propdatap)
{
size_t total;
char* propdata = NULL;
if(info == NULL || info->version == 0) return NC_EINVAL;
if(propdatap == NULL)
return NC_NOERR;
*propdatap = NULL;
/* compute attribute length */
total = 0;
total += strlen(NCPVERSION);
total += strlen("=00000000");
if(strlen(info->netcdfver) > 0) {
total += 1; /*|NCPROPSEP|*/
total += strlen(NCPNCLIBVERSION);
total += strlen("=");
total += strlen(info->netcdfver);
}
if(strlen(info->hdf5ver) > 0) {
total += 1; /*|NCPROPSEP|*/
total += strlen(NCPHDF5LIBVERSION);
total += strlen("=");
total += strlen(info->hdf5ver);
}
propdata = (char*)malloc(total+1);
if(propdata == NULL)
return NC_ENOMEM;
snprintf(propdata,total+1,
"%s=%d|%s=%s|%s=%s",
NCPVERSION,info->version,
NCPNCLIBVERSION,info->netcdfver,
NCPHDF5LIBVERSION,info->hdf5ver);
/* Force null termination */
propdata[total] = '\0';
*propdatap = propdata;
/* propdatap is checked against being NULL above already. */
//if(propdatap) {
// *propdatap = propdata;
//} else {
// free(propdata);
//}
return NC_NOERR;
}

View File

@ -22,6 +22,7 @@ fi
has_nc2="@BUILD_V2@"
if [ -z $has_nc2 -o "$has_nc2" = "OFF" ]; then
has_nc2="no"
else
@ -73,9 +74,16 @@ fi
version="@PACKAGE@ @VERSION@"
has_fortran="no"
has_f90="no"
has_f03="no"
if type -p nf-config > /dev/null 2>&1; then
nfconf=$(which nf-config 2>/dev/null)
if [ -f "$nfconf" ]; then
echo "Using nf-config: $nfconf"
has_fortran="yes"
fc=`nf-config --fc`
fflags=`nf-config --fflags`
flibs=`nf-config --flibs`
@ -87,9 +95,13 @@ has_cxx="no"
has_cxx4="no"
if type -p ncxx4-config > /dev/null 2>&1; then
cxx4=`ncxx4-config --cxx`
cxx4flags=`ncxx4-config --cflags`
cxx4libs=`ncxx4-config --libs`
has_cxx4="yes"
elif type -p ncxx-config > /dev/null 2>&1; then
cxx=`ncxx-config --cxx`
cxxflags=`ncxx-config --cflags`
cxxlibs=`ncxx-config --libs`
has_cxx="yes"
fi
@ -104,6 +116,9 @@ Available values for OPTION include:
--all display all options
--cc C compiler
--cflags pre-processor and compiler flags
--has-c++ whether C++ API is installed
--has-c++4 whether netCDF-4 C++ API is installed
--has-fortran whether Fortran API is installed
--has-dap whether OPeNDAP is enabled in this build
--has-nc2 whether NetCDF-2 API is enabled
--has-nc4 whether NetCDF-4/HDF-5 is enabled in this build
@ -115,25 +130,24 @@ Available values for OPTION include:
--libs library linking information for netcdf
--prefix Install prefix
--includedir Include directory
--libdir Library directory
--version Library version
EOF
# When supported by ncxx4-config and ncxx-config, add
# --cxxflags flags needed to compile a netCDF-4 C++ program
# --cxxlibs libraries needed to link a netCDF-4 C++ program
if type -p ncxx4-config > /dev/null 2>&1; then
cat <<EOF
--cxx4 C++ compiler for netCDF-4 C++ library
--has-c++4 whether netCDF-4 C++ API is installed
--cxx4 C++ compiler for netCDF-4 C++ library
--cxx4flags flags needed to compile a C++ program
--cxx4libs libraries needed to link a C++ program
EOF
elif type -p ncxx-config > /dev/null 2>&1; then
cat <<EOF
--cxx C++ compiler
--has-c++ whether C++ API is installed
--cxxflags flags needed to compile a C++ program
--cxxlibs libraries needed to link a C++ program
EOF
fi
if type -p nf-config > /dev/null 2>&1; then
if [ -f "$nfconf" ]; then
cat <<EOF
--fc Fortran compiler
--fflags flags needed to compile a Fortran program
@ -156,15 +170,29 @@ all()
echo
echo " --has-c++ -> $has_cxx"
echo " --cxx -> $cxx"
if type -p ncxx-config > /dev/null 2>&1; then
echo " --cxxflags -> $cxxflags"
echo " --cxxlibs -> $cxxlibs"
fi
echo
echo " --has-c++4 -> $has_cxx4"
echo " --cxx4 -> $cxx4"
if type -p ncxx4-config > /dev/null 2>&1; then
echo " --cxx4flags -> $cxx4flags"
echo " --cxx4libs -> $cxx4libs"
fi
echo
echo " --has-fortran-> $has_fortran"
if [ -f "$nfconf" ]; then
echo " --fc -> $fc"
echo " --fflags -> $fflags"
echo " --flibs -> $flibs"
echo " --has-f90 -> $has_f90"
echo " --has-f03 -> $has_f03"
echo
fi
echo " --has-dap -> $has_dap"
echo " --has-nc2 -> $has_nc2"
echo " --has-nc4 -> $has_nc4"
@ -176,6 +204,7 @@ all()
echo
echo " --prefix -> $prefix"
echo " --includedir-> $includedir"
echo " --libdir -> $libdir"
echo " --version -> $version"
echo
}
@ -255,6 +284,10 @@ while test $# -gt 0; do
echo "${includedir}"
;;
--libdir)
echo "${libdir}"
;;
--version)
echo $version
;;
@ -267,6 +300,14 @@ while test $# -gt 0; do
echo $cxx
;;
--cxxflags)
echo $cxxflags
;;
--cxxlibs)
echo $cxxlibs
;;
--has-c++4)
echo $has_cxx4
;;
@ -275,13 +316,17 @@ while test $# -gt 0; do
echo $cxx4
;;
# --cxxflags)
# echo $cxxflags
# ;;
#
# --cxxlibs)
# echo $cxxlibs
# ;;
--cxx4flags)
echo $cxx4flags
;;
--cxx4libs)
echo $cxx4libs
;;
--has-fortran)
echo $has_fortran
;;
--fc)
echo $fc
@ -305,9 +350,8 @@ while test $# -gt 0; do
*)
echo "unknown option: $1"
usage
exit 1
;;
usage 1
;;
esac
shift
done

87
nc-config.in Normal file → Executable file
View File

@ -5,12 +5,14 @@
# contributed by netCDF user Arlindo DaSilva. Thanks Arlindo!
prefix=@prefix@
exec_prefix=${prefix}
includedir=${prefix}/include
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
cc="@CC@"
cflags=" -I${includedir} @CPPFLAGS@"
cflags="-I${includedir} @CPPFLAGS@"
libs="-L${libdir} @NC_LIBS@"
has_dap="@HAS_DAP@"
has_nc2="@HAS_NC2@"
has_nc4="@HAS_NC4@"
@ -20,9 +22,15 @@ has_hdf5="@HAS_HDF5@"
has_logging="@HAS_LOGGING@"
version="@PACKAGE_NAME@ @PACKAGE_VERSION@"
has_fortran="no"
has_f90="no"
has_f03="no"
if type -p nf-config > /dev/null 2>&1; then
nfconf=$(which nf-config 2>/dev/null)
if [ -f "$nfconf" ]; then
echo "Using nf-config: $nfconf"
has_fortran="yes"
fc=`nf-config --fc`
fflags=`nf-config --fflags`
flibs=`nf-config --flibs`
@ -34,9 +42,13 @@ has_cxx="no"
has_cxx4="no"
if type -p ncxx4-config > /dev/null 2>&1; then
cxx4=`ncxx4-config --cxx`
cxx4flags=`ncxx4-config --cflags`
cxx4libs=`ncxx4-config --libs`
has_cxx4="yes"
elif type -p ncxx-config > /dev/null 2>&1; then
cxx=`ncxx-config --cxx`
cxxflags=`ncxx-config --cflags`
cxxlibs=`ncxx-config --libs`
has_cxx="yes"
fi
@ -51,6 +63,9 @@ Available values for OPTION include:
--all display all options
--cc C compiler
--cflags pre-processor and compiler flags
--has-c++ whether C++ API is installed
--has-c++4 whether netCDF-4 C++ API is installed
--has-fortran whether Fortran API is installed
--has-dap whether OPeNDAP is enabled in this build
--has-nc2 whether NetCDF-2 API is enabled
--has-nc4 whether NetCDF-4/HDF-5 is enabled in this build
@ -62,25 +77,24 @@ Available values for OPTION include:
--libs library linking information for netcdf
--prefix Install prefix
--includedir Include directory
--libdir Library directory
--version Library version
EOF
# When supported by ncxx4-config and ncxx-config, add
# --cxxflags flags needed to compile a netCDF-4 C++ program
# --cxxlibs libraries needed to link a netCDF-4 C++ program
if type -p ncxx4-config > /dev/null 2>&1; then
cat <<EOF
--cxx4 C++ compiler for netCDF-4 C++ library
--has-c++4 whether netCDF-4 C++ API is installed
--cxx4 C++ compiler for netCDF-4 C++ library
--cxx4flags flags needed to compile a C++ program
--cxx4libs libraries needed to link a C++ program
EOF
elif type -p ncxx-config > /dev/null 2>&1; then
cat <<EOF
--cxx C++ compiler
--has-c++ whether C++ API is installed
--cxxflags flags needed to compile a C++ program
--cxxlibs libraries needed to link a C++ program
EOF
fi
if type -p nf-config > /dev/null 2>&1; then
if [ -f "$nfconf" ]; then
cat <<EOF
--fc Fortran compiler
--fflags flags needed to compile a Fortran program
@ -104,17 +118,28 @@ all()
echo " --has-c++ -> $has_cxx"
echo " --cxx -> $cxx"
# echo " --cxxflags -> $cxxflags"
# echo " --cxxlibs -> $cxxlibs"
if type -p ncxx-config > /dev/null 2>&1; then
echo " --cxxflags -> $cxxflags"
echo " --cxxlibs -> $cxxlibs"
fi
echo
echo " --has-c++4 -> $has_cxx4"
echo " --cxx4 -> $cxx4"
if type -p ncxx4-config > /dev/null 2>&1; then
echo " --cxx4flags -> $cxx4flags"
echo " --cxx4libs -> $cxx4libs"
fi
echo
echo " --has-fortran-> $has_fortran"
if [ -f "$nfconf" ]; then
echo " --fc -> $fc"
echo " --fflags -> $fflags"
echo " --flibs -> $flibs"
echo " --has-f90 -> $has_f90"
echo " --has-f03 -> $has_f03"
echo
fi
echo " --has-dap -> $has_dap"
echo " --has-nc2 -> $has_nc2"
echo " --has-nc4 -> $has_nc4"
@ -126,6 +151,7 @@ all()
echo
echo " --prefix -> $prefix"
echo " --includedir-> $includedir"
echo " --libdir -> $libdir"
echo " --version -> $version"
echo
}
@ -194,7 +220,7 @@ while test $# -gt 0; do
;;
--libs)
PKG_CONFIG_PATH=${prefix}/lib/pkgconfig pkg-config netcdf --libs
echo $libs
;;
--prefix)
@ -205,6 +231,10 @@ while test $# -gt 0; do
echo "${includedir}"
;;
--libdir)
echo "${libdir}"
;;
--version)
echo $version
;;
@ -217,6 +247,14 @@ while test $# -gt 0; do
echo $cxx
;;
--cxxflags)
echo $cxxflags
;;
--cxxlibs)
echo $cxxlibs
;;
--has-c++4)
echo $has_cxx4
;;
@ -225,6 +263,18 @@ while test $# -gt 0; do
echo $cxx4
;;
--cxx4flags)
echo $cxx4flags
;;
--cxx4libs)
echo $cxx4libs
;;
--has-fortran)
echo $has_fortran
;;
--fc)
echo $fc
;;
@ -247,9 +297,8 @@ while test $# -gt 0; do
*)
echo "unknown option: $1"
usage
exit 1
;;
usage 1
;;
esac
shift
done

View File

@ -68,16 +68,19 @@ ENDFOREACH()
ADD_TEST(nc_test ${EXECUTABLE_OUTPUT_PATH}/nc_test)
IF(BUILD_DISKLESS)
add_sh_test(nc_test run_diskless)
IF(BUILD_MMAP)
add_sh_test(nc_test run_mmap)
ENDIF()
IF(LARGE_FILE_TESTS)
add_sh_test(nc_test run_diskless2)
ENDIF()
IF(BUILD_UTILITIES)
ENDIF()
IF(BUILD_DISKLESS)
add_sh_test(nc_test run_diskless)
IF(BUILD_MMAP)
add_sh_test(nc_test run_mmap)
ENDIF(BUILD_MMAP)
IF(LARGE_FILE_TESTS)
add_sh_test(nc_test run_diskless2)
ENDIF(LARGE_FILE_TESTS)
ENDIF(BUILD_DISKLESS)
ENDIF(BUILD_UTILITIES)
# Copy some test files from current source dir to out-of-tree build dir.
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)

View File

@ -62,14 +62,16 @@ endif
TESTS = $(TESTPROGRAMS)
if BUILD_DISKLESS
TESTS += run_diskless.sh
if BUILD_MMAP
TESTS += run_mmap.sh
endif
if LARGE_FILE_TESTS
TESTS += run_diskless2.sh
endif
if BUILD_UTILITIES
if BUILD_DISKLESS
TESTS += run_diskless.sh
if BUILD_MMAP
TESTS += run_mmap.sh
endif
if LARGE_FILE_TESTS
TESTS += run_diskless2.sh
endif
endif
endif
if USE_PNETCDF

View File

@ -308,15 +308,6 @@ test_nc_get_vara_$1(void)
err = nc_get_vara_$1(ncid, BAD_VARID, start, edge, value);
IF (err != NC_ENOTVAR)
error("bad var id: status = %d", err);
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] > 0) { /* skip record dim */
start[j] = var_shape[i][j];
err = nc_get_vara_$1(ncid, i, start, edge, value);
IF (canConvert && err != NC_EINVALCOORDS)
error("bad start: status = %d", err);
start[j] = 0;
}
}
err = nc_get_vara_$1(ncid, i, start, edge, value);
if (canConvert) {
IF (err)

View File

@ -614,25 +614,6 @@ test_nc_put_vara_$1(void)
edge[j] = 1;
}
}
/* Check correct error returned even when nothing to put */
for (j = 0; j < var_rank[i]; j++) {
edge[j] = 0;
}
err = nc_put_vara_$1(BAD_ID, i, start, edge, value);
IF (err != NC_EBADID)
error("bad ncid: status = %d", err);
err = nc_put_vara_$1(ncid, BAD_VARID, start, edge, value);
IF (err != NC_ENOTVAR)
error("bad var id: status = %d", err);
for (j = 0; j < var_rank[i]; j++) {
if (var_dimid[i][j] > 0) { /* skip record dim */
start[j] = var_shape[i][j];
err = nc_put_vara_$1(ncid, i, start, edge, value);
IF (canConvert && err != NC_EINVALCOORDS)
error("bad start: status = %d", err);
start[j] = 0;
}
}
/* wkliao: this test below of put_vara is redundant and incorrectly uses the
value[] set from the previously iteration. There is no such test

View File

@ -5,15 +5,21 @@ SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars
tst_strings2 tst_interops tst_interops4 tst_interops6
tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 tst_vars4
tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug
tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts
tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts
t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite
tst_put_vars_two_unlim_dim tst_hdf5_file_compat tst_fill_attr_vanish)
tst_put_vars_two_unlim_dim tst_hdf5_file_compat tst_fill_attr_vanish
tst_rehash)
# Note, renamegroup needs to be compiled before run_grp_rename
build_bin_test(renamegroup)
add_sh_test(nc_test4 run_grp_rename)
IF(BUILD_UTILITIES)
SET(NC4_TESTS ${NC4_TESTS} tst_xplatform)
build_bin_test(renamegroup)
add_sh_test(nc_test4 run_grp_rename)
ADD_SH_TEST(nc_test4 tst_misc)
ENDIF(BUILD_UTILITIES)
##
# The shell script, run_empty_vlen_test.sh,
@ -22,7 +28,7 @@ add_sh_test(nc_test4 run_grp_rename)
BUILD_BIN_TEST(tst_empty_vlen_unlim)
ADD_SH_TEST(nc_test4 run_empty_vlen_test)
ADD_SH_TEST(nc_test4 tst_misc)
IF(NOT MSVC)
SET(NC4_TESTS ${NC4_TESTS} tst_interops5 tst_camrun)

View File

@ -22,7 +22,7 @@ tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \
t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs \
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \
tst_hdf5_file_compat tst_fill_attr_vanish
tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash
check_PROGRAMS = $(NC4_TESTS) renamegroup tst_empty_vlen_unlim
@ -33,7 +33,11 @@ endif
TESTS = $(NC4_TESTS)
TESTS += run_grp_rename.sh run_empty_vlen_test.sh tst_misc.sh
if BUILD_UTILITIES
TESTS += run_grp_rename.sh tst_misc.sh
endif
TESTS += run_empty_vlen_test.sh
# If the v2 API was built, add its test program.
if BUILD_V2
@ -125,8 +129,8 @@ run_grp_rename.sh tst_formatx_hdf4.sh \
run_chunk_hdf4.sh contiguous.hdf4 chunked.hdf4 \
tst_h5_endians.c tst_h4_lendian.c tst_atts_string_rewrite.c \
tst_put_vars_two_unlim_dim.c tst_empty_vlen_unlim.c run_empty_vlen_test.sh \
ref_hdf5_compat1.nc ref_hdf5_compat2.nc ref_hdf5_compat3.nc tst_misc.sh tdset.h5 \
tst_hdf4_read_var.sh
ref_hdf5_compat1.nc ref_hdf5_compat2.nc ref_hdf5_compat3.nc tst_misc.sh \
tdset.h5 tst_hdf4_read_var.sh
CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \
@ -139,7 +143,7 @@ usi_01.* thetau_01.* tst_*.nc tst_*.h5 \
tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \
foo1.nc tst_interops2.h4 tst_h5_endians.nc tst_h4_lendian.h4 test.nc \
tst_atts_string_rewrite.nc tst_empty_vlen_unlim.nc tst_empty_vlen_lim.nc \
tst_parallel4_simplerw_coll.nc tst_fill_attr_vanish.nc
tst_parallel4_simplerw_coll.nc tst_fill_attr_vanish.nc tst_rehash.nc
if USE_HDF4_FILE_TESTS
DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \

View File

@ -45,13 +45,13 @@ int main(int argc, char **argv) {
{
printf("Testing %s\n",FILE_NAME2);
if (nc_open(FILE_NAME1, NC_NOWRITE, &ncid)) ERR;
if (nc_open(FILE_NAME2, NC_NOWRITE, &ncid)) ERR;
if (nc_close(ncid)) ERR;
}
{
printf("Testing %s\n",FILE_NAME3);
if (nc_open(FILE_NAME1, NC_NOWRITE, &ncid)) ERR;
if (nc_open(FILE_NAME3, NC_NOWRITE, &ncid)) ERR;
if (nc_close(ncid)) ERR;
}

43
nc_test4/tst_rehash.c Normal file
View File

@ -0,0 +1,43 @@
/* This is part of the netCDF package.
Copyright 2016 University Corporation for Atmospheric Research/Unidata
See COPYRIGHT file for conditions of use.
Provided in support of https://github.com/Unidata/netcdf-c/issues/282
Test provided by Greg Sjaardema
Tests to see if the hashmap is being properly updated.
*/
#define FILENAME "tst_rehash.nc"
#include <netcdf.h>
int main()
{
int status;
int id;
int rh_id, varid, v1, v2, v3, v4;
int dimids[2];
nc_create(FILENAME, NC_CLOBBER, &id);
nc_redef(id);
status = nc_def_dim(id, "dim1", 10, &dimids[0]);
status = nc_def_var(id, "dim1", NC_FLOAT, 1, dimids, &v1);
status = nc_def_var(id, "var1", NC_FLOAT, 1, dimids, &v2);
nc_close(id);
nc_open(FILENAME, NC_WRITE, &id);
nc_redef(id);
nc_rename_var(id, v1,"dim_new1");
nc_rename_dim(id, dimids[0], "dim_new1");
status = nc_def_dim(id, "dim2", 20, &dimids[1]);
nc_def_var(id, "dim2", NC_FLOAT, 1, &dimids[1], &v3);
nc_def_var(id, "var2", NC_FLOAT, 2, dimids, &v4);
nc_close(id);
}

View File

@ -43,8 +43,10 @@ IF(ENABLE_TESTS)
ENDIF()
IF(ENABLE_DAP_REMOTE_TESTS)
add_sh_test(ncdap tst_remote3)
add_sh_test(ncdap tst_formatx)
IF(BUILD_UTILITIES)
add_sh_test(ncdap tst_remote3)
add_sh_test(ncdap tst_formatx)
ENDIF(BUILD_UTILITIES)
add_bin_test(ncdap test_partvar)
IF(ENABLE_DAP_LONG_TESTS)
add_sh_test(ncdap tst_longremote3)

View File

@ -33,7 +33,11 @@ if ENABLE_DAP_REMOTE_TESTS
check_PROGRAMS += nctestserver
nctestserver_SOURCES = nctestserver.c
TESTS += tst_remote3.sh tst_formatx.sh test_partvar testurl.sh
if BUILD_UTILITIES
TESTS += tst_remote3.sh tst_formatx.sh
endif
TESTS += test_partvar testurl.sh
if ENABLE_DAP_LONG_TESTS
TESTS += tst_longremote3.sh

View File

@ -59,7 +59,7 @@ IF(ENABLE_TESTS)
TARGET_LINK_LIBRARIES(bom netcdf)
TARGET_LINK_LIBRARIES(tst_dimsizes netcdf)
IF(ENABLE_FILEINFO)
IF(USE_NETCDF4)
ADD_EXECUTABLE(tst_fileinfo tst_fileinfo.c)
TARGET_LINK_LIBRARIES(tst_fileinfo netcdf)
add_sh_test(ncdump tst_fileinfo)

View File

@ -35,7 +35,7 @@ tst_lengths.sh tst_calendars.sh tst_utf8 run_utf8_tests.sh \
tst_nccopy3.sh tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \
tst_dimsizes.sh
if ENABLE_FILEINFO
if USE_NETCDF4
check_PROGRAMS += tst_fileinfo
TESTS += tst_fileinfo.sh
endif

View File

@ -763,7 +763,7 @@ pr_att(
ncatt_t att; /* attribute */
NC_CHECK( nc_inq_attname(ncid, varid, ia, att.name) );
#ifdef ENABLE_FILEINFO
#ifdef USE_NETCDF4
if (ncid == getrootid(ncid)
&& varid == NC_GLOBAL
&& strcmp(att.name,NCPROPS)==0)
@ -1074,7 +1074,7 @@ pr_att_specials(
}
#endif /* USE_NETCDF4 */
#ifdef ENABLE_FILEINFO /*=>NETCDF4*/
#ifdef USE_NETCDF4
static void
pr_att_hidden(
int ncid,
@ -1083,7 +1083,6 @@ pr_att_hidden(
{
int stat;
size_t len;
char propdata[NCPROPS_LENGTH];
/* No special variable attributes for classic or 64-bit offset data */
if(kind == 1 || kind == 2)
@ -1091,14 +1090,18 @@ pr_att_hidden(
/* Print out Selected hidden attributes */
/* NCPROPS */
stat = nc_inq_att(ncid,NC_GLOBAL,NCPROPS,NULL,&len);
if(stat == NC_NOERR && len < sizeof(propdata)) {
if(stat == NC_NOERR) {
char* propdata = (char*)malloc(len+1);
if(propdata == NULL)
return;
stat = nc_get_att_text(ncid,NC_GLOBAL,NCPROPS,propdata);
if(stat == NC_NOERR) {
pr_att_name(ncid, "", NCPROPS);
/* make sure its null terminated */
propdata[NCPROPS_LENGTH-1] = '\0';
propdata[len] = '\0';
printf(" = \"%s\" ;\n",propdata);
}
free(propdata);
}
/* _SuperblockVersion */
stat = nc_inq_att(ncid,NC_GLOBAL,SUPERBLOCKATT,NULL,&len);
@ -1121,7 +1124,7 @@ pr_att_hidden(
}
}
}
#endif /* ENABLE_FILEINFO */
#endif /* USE_NETCDF4 */
/*
* Print a variable attribute for NcML
@ -1138,7 +1141,7 @@ pr_attx(
int attvalslen = 0;
NC_CHECK( nc_inq_attname(ncid, varid, ia, att.name) );
#ifdef ENABLE_FILEINFO
#ifdef USE_NETCDF4
if (ncid == getrootid(ncid)
&& varid == NC_GLOBAL
&& strcmp(att.name,NCPROPS)==0
@ -1751,7 +1754,7 @@ do_ncdump_rec(int ncid, const char *path)
}
if (is_root && formatting_specs.special_atts) { /* output special attribute
* for format variant */
#ifdef ENABLE_FILEINFO
#ifdef USE_NETCDF4
pr_att_hidden(ncid, kind);
#endif
pr_att_global_format(ncid, kind);

View File

@ -746,11 +746,11 @@ nc_inq_grps_full(int rootid, int *numgrps, int *grpids)
return stat;
}
#ifdef ENABLE_FILEINFO
int
getrootid(int grpid)
{
int current = grpid;
#ifdef USE_NETCDF4
int parent = current;
/* see if root id */
for(;;) {
@ -758,7 +758,7 @@ getrootid(int grpid)
if(stat) break;
current = parent;
}
#endif
return current;
}
#endif

View File

@ -64,7 +64,7 @@ lput(const char *cp) {
linep = (int)strlen(LINEPIND) + indent_get();
}
(void) fputs(cp,stdout);
if (cp[nn - 1] == '\n') {
if (nn > 0 && cp[nn - 1] == '\n') {
linep = indent_get();
} else
linep += nn;

View File

@ -1,6 +1,7 @@
# Test c output
T=test0
K=1
T=t
K=4
L=-L5
#VG=valgrind --leak-check=full
STDLIB=/usr/local
@ -13,19 +14,23 @@ LDFLAGS=../liblib/.libs/libnetcdf.a -L${STDLIB}/lib -lhdf5_hl -lhdf5 -lz -lm -lc
CLASSPATH=".:ncCore-4.2.jar"
btest::
./ncgen -k$K -lb -o ${T}.nc ${T}.cdl
../ncdump/ncdump ./${T}.nc >${T}.dmp
./ncgen ${L} -$K -lb -o ${T}.nc ${T}.cdl
../ncdump/ncdump -L2 ./${T}.nc >${T}.dmp
diff -wBb ${T}.cdl ${T}.dmp
rm -f ./junk.nc
../ncdump/nccopy ./${T}.nc ./junk.nc
ctest::
./ncgen -k$K -lc ${T}.cdl >${T}.c
./ncgen ${L} -$K -lc ${T}.cdl >${T}.c
gcc -o ${T} ${CFLAGS} ${T}.c ${LDFLAGS}
./${T}
../ncdump/ncdump ./${T}.nc >${T}.dmp
../ncdump/ncdump ${L} ./${T}.nc >${T}.dmp
diff -wBb ${T}.cdl ${T}.dmp
rm -f ./junk.nc
../ncdump/nccopy ./${T}.nc ./junk.nc
gtest::
./ncgen -k$K -lc ${T}.cdl >${T}.c
./ncgen -$K -lc ${T}.cdl >${T}.c
gcc -g -O0 -o ${T} ${CFLAGS} ${T}.c ${LDFLAGS}
gdb --args ./${T}
@ -35,11 +40,11 @@ vctest::
${VG} ./vt
ftest::
./ncgen -k$K -lf77 ${T}.cdl >${T}.f77
./ncgen -$K -lf77 ${T}.cdl >${T}.f77
gfortran -c ${CFLAGS} ${T}.f77
jtest::
./ncgen -k$K -lj ${T}.cdl >Main.java
./ncgen -$K -lj ${T}.cdl >Main.java
javac -d . -classpath "${CLASSPATH}" Main.java
# java -cp ${CPATH} ./${T}

View File

@ -229,6 +229,14 @@ gen_ncc(const char *filename)
}
codeflush();
/* Set log level */
if(ncloglevel >= 0) {
codeline("");
bbprintf0(stmt," nc_set_log_level(%d); /* set log level */",ncloglevel);
codedump(stmt);
codeline("");
}
/* create netCDF file, uses NC_CLOBBER mode */
codeline("");
codelined(1,"/* enter define mode */");

View File

@ -864,7 +864,7 @@ There are three other cases of note.
.IP 1. 3
If there is only a single, unlimited dimension,
then all of the constants are concatenated
and fill characers are added to the
and fill characters are added to the
end of the resulting string to make its
length be that of the unlimited dimension.
If the length is larger than

View File

@ -236,7 +236,7 @@ errorbody:
;
errorcode: /*empty*/ {$$=null;} | SCAN_CODE '=' WORD_WORD ';' {$$=$3;}
errormsg: /*empty*/ {$$=null;} | SCAN_MESSAGE '=' WORD_WORD ';' {$$=$3;}
errormsg: /*empty*/ {$$=null;} | SCAN_MESSAGE '=' WORD_STRING ';' {$$=$3;}
errorptype: /*empty*/ {$$=null;} | SCAN_PTYPE '=' WORD_WORD ';' {$$=$3;}
errorprog : /*empty*/ {$$=null;} | SCAN_PROG '=' WORD_WORD ';' {$$=$3;}

1659
oc2/dapy.c

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@ -26,54 +26,62 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
SCAN_ALIAS = 258,
SCAN_ARRAY = 259,
SCAN_ATTR = 260,
SCAN_BYTE = 261,
SCAN_CODE = 262,
SCAN_DATASET = 263,
SCAN_DATA = 264,
SCAN_ERROR = 265,
SCAN_FLOAT32 = 266,
SCAN_FLOAT64 = 267,
SCAN_GRID = 268,
SCAN_INT16 = 269,
SCAN_INT32 = 270,
SCAN_MAPS = 271,
SCAN_MESSAGE = 272,
SCAN_SEQUENCE = 273,
SCAN_STRING = 274,
SCAN_STRUCTURE = 275,
SCAN_UINT16 = 276,
SCAN_UINT32 = 277,
SCAN_URL = 278,
SCAN_PTYPE = 279,
SCAN_PROG = 280,
WORD_WORD = 281,
WORD_STRING = 282
};
#ifndef YY_DAP_DAP_TAB_H_INCLUDED
# define YY_DAP_DAP_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int dapdebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
SCAN_ALIAS = 258,
SCAN_ARRAY = 259,
SCAN_ATTR = 260,
SCAN_BYTE = 261,
SCAN_CODE = 262,
SCAN_DATASET = 263,
SCAN_DATA = 264,
SCAN_ERROR = 265,
SCAN_FLOAT32 = 266,
SCAN_FLOAT64 = 267,
SCAN_GRID = 268,
SCAN_INT16 = 269,
SCAN_INT32 = 270,
SCAN_MAPS = 271,
SCAN_MESSAGE = 272,
SCAN_SEQUENCE = 273,
SCAN_STRING = 274,
SCAN_STRUCTURE = 275,
SCAN_UINT16 = 276,
SCAN_UINT32 = 277,
SCAN_URL = 278,
SCAN_PTYPE = 279,
SCAN_PROG = 280,
WORD_WORD = 281,
WORD_STRING = 282
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
int dapparse (DAPparsestate* parsestate);
#endif /* !YY_DAP_DAP_TAB_H_INCLUDED */