Merge branch 'enable-cdf5' of https://github.com/wkliao/netcdf-c into pr-aggregation.wif

This commit is contained in:
Ward Fisher 2018-07-17 11:26:21 -06:00
commit 2f791cc749
21 changed files with 59 additions and 47 deletions

View File

@ -767,12 +767,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF(USE_HDF5 OR ENABLE_NETCDF_4)
# Option to turn on CDF5 support.
OPTION(ENABLE_CDF5 "Enable CDF5 Support." ON)
IF(ENABLE_CDF5)
SET(USE_CDF5 ON CACHE BOOL "")
ENDIF(ENABLE_CDF5)
# Option to Build DAP2+DAP4 Clients
OPTION(ENABLE_DAP "Enable DAP2 and DAP4 Client." ON)
IF(ENABLE_DAP)
@ -1298,6 +1292,26 @@ CHECK_TYPE_SIZE("_Bool" SIZEOF__BOOL)
CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
# Check whether to turn on or off CDF5 support.
SET(ENABLE_CDF5 AUTO CACHE STRING "AUTO")
OPTION(ENABLE_CDF5 "Enable CDF5 support" ON)
IF(SIZEOF_SIZE_T EQUAL 4)
IF(ENABLE_CDF5) # enable or auto
STRING(TOUPPER ${ENABLE_CDF5} ENABLE_CDF5)
IF(ENABLE_CDF5 AND NOT ENABLE_CDF5 STREQUAL "AUTO") # explicitly enabled
MESSAGE(FATAL_ERROR "Unable to support CDF5 feature because size_t is less than 8 bytes")
ENDIF(ENABLE_CDF5 AND NOT ENABLE_CDF5 STREQUAL "AUTO")
SET(ENABLE_CDF5 OFF) # cannot support CDF5
SET(USE_CDF5 OFF CACHE BOOL "") # cannot support CDF5
ENDIF(ENABLE_CDF5)
ELSE(SIZEOF_SIZE_T EQUAL 4)
IF(ENABLE_CDF5) # explicitly set by user or not set
SET(USE_CDF5 ON CACHE BOOL "")
ELSE(ENABLE_CDF5) # explicitly disabled by user
SET(USE_CDF5 OFF CACHE BOOL "")
ENDIF(ENABLE_CDF5)
ENDIF(SIZEOF_SIZE_T EQUAL 4)
CHECK_TYPE_SIZE("ssize_t" SIZEOF_SSIZE_T)
IF(SIZEOF_SSIZE_T)
SET(HAVE_SSIZE_T TRUE)

View File

@ -109,7 +109,6 @@ are set when opening a binary file on Windows. */
/* if true, enable CDF5 Support */
#cmakedefine ENABLE_CDF5 1
#cmakedefine USE_CDF5 1
/* if true, enable strict null byte header padding. */
#cmakedefine USE_STRICT_NULL_BYTE_HEADER_PADDING 1

View File

@ -896,29 +896,28 @@ $SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)
# Check whether we want to enable CDF5 support.
AC_MSG_CHECKING([whether CDF5 support should be enabled])
AC_MSG_CHECKING([whether CDF5 support should be disabled])
AC_ARG_ENABLE([cdf5],
[AS_HELP_STRING([--enable-cdf5],
[AS_HELP_STRING([--disable-cdf5],
[build without CDF5 support.])],
[enable_cdf5=${enableval}], [enable_cdf5=auto]
)
if test "x${enable_cdf5}" = xyes && test "$ac_cv_sizeof_size_t" -lt "8" ; then
dnl unable to support CDF5, but --enable-cdf5 is explicitly set
AC_MSG_ERROR([Unable to support CDF5 feature because size_t is less than 4 bytes])
fi
if test "$ac_cv_sizeof_size_t" -lt "8" ; then
if test "x${enable_cdf5}" = xyes ; then
dnl unable to support CDF5, but --enable-cdf5 is explicitly set
AC_MSG_ERROR([Unable to support CDF5 feature because size_t is less than 8 bytes])
fi
enable_cdf5=no
else
enable_cdf5=yes
if test "x${enable_cdf5}" != xno ; then
enable_cdf5=yes
fi
fi
AC_MSG_RESULT($enable_cdf5)
if test "x${enable_cdf5}" = xyes; then
AC_DEFINE([USE_CDF5], [1], [if true, enable CDF5 Support])
AC_DEFINE([ENABLE_CDF5], [1], [if true, enable CDF5 Support])
fi
AM_CONDITIONAL(USE_CDF5, [test x$enable_cdf5 = xyes ])
AM_CONDITIONAL(ENABLE_CDF5, [test x$enable_cdf5 = xyes ])
$SLEEPCMD

View File

@ -2106,7 +2106,7 @@ NC_create(const char *path0, int cmode, size_t initialsz,
model = NC_FORMATX_NC4;
break;
#endif
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
case NC_FORMAT_CDF5:
xcmode |= NC_64BIT_DATA;
model = NC_FORMATX_NC3;
@ -2322,7 +2322,7 @@ NC_open(const char *path0, int cmode, int basepe, size_t *chunksizehintp,
hdf4built = 1;
#endif
#endif
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
cdf5built = 1;
#endif
if(!hdf5built && model == NC_FORMATX_NC4) {

View File

@ -100,7 +100,7 @@ err:
int
nc3_cktype(int mode, nc_type type)
{
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
if (mode & NC_CDF5) { /* CDF-5 format */
if (type >= NC_BYTE && type < NC_STRING) return NC_NOERR;
} else
@ -1167,7 +1167,7 @@ nc_set_default_format(int format, int *old_formatp)
return NC_EINVAL;
#else
if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
&& format != NC_FORMAT_CDF5
#endif
)
@ -1698,7 +1698,7 @@ NC3_inq_format(int ncid, int *formatp)
return NC_NOERR;
/* only need to check for netCDF-3 variants, since this is never called for netCDF-4 files */
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
if (fIsSet(nc3->flags, NC_64BIT_DATA))
*formatp = NC_FORMAT_CDF5;
else

View File

@ -27,7 +27,7 @@ endif
if TEST_PARALLEL4
if USE_PNETCDF
if USE_CDF5
if ENABLE_CDF5
TESTPROGRAMS += tst_cdf5format
endif
endif

View File

@ -134,7 +134,7 @@ main(int argc, char *argv[])
break;
case NC_FORMAT_CDF5:
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
nc_set_default_format(NC_FORMAT_CDF5, NULL);
fprintf(stderr, "\n\nSwitching to 64-bit data format.\n");
strcpy(testfile, "nc_test_cdf5.nc");

View File

@ -361,7 +361,7 @@ main(int argc, char *argv[])
MPI_Init(&argc, &argv);
cmode |= (NC_PNETCDF);
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
cmode |= (NC_64BIT_DATA);
#endif
ret = nc_create_par(fname,cmode, MPI_COMM_WORLD, MPI_INFO_NULL, &id);

View File

@ -2424,7 +2424,7 @@ APIFunc(get_file_version)(char *path, int *version)
if (strncmp(magic, "CDF", MAGIC_NUM_LEN-1)==0) {
if (magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CLASSIC ||
magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
|| magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5
#endif
)

View File

@ -54,7 +54,7 @@ int main(int argc, char** argv) {
buf = (int*) malloc(NY*NX * sizeof(int));
for (k=0; k<5; k++) {
#ifndef USE_CDF5
#ifndef ENABLE_CDF5
if (formats[k] == NC_FORMAT_CDF5) continue;
#endif
#ifndef USE_NETCDF4

View File

@ -37,7 +37,7 @@ main(int argc, char **argv)
num_formats += 2;
#endif
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
num_formats++;
#endif
@ -46,7 +46,7 @@ main(int argc, char **argv)
formats[n++] = 0;
formats[n++] = NC_64BIT_OFFSET;
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
formats[n++] = NC_64BIT_DATA;
#endif
#ifdef USE_NETCDF4

View File

@ -225,7 +225,7 @@ main(int argc, char **argv)
NC_FORMAT_CLASSIC
,
NC_FORMAT_64BIT_OFFSET
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
,
NC_FORMAT_CDF5
#endif

View File

@ -55,7 +55,7 @@ static int file_create(const char *filename, int cmode, int *ncid)
#ifdef USE_PNETCDF
if (default_format == NC_FORMAT_CLASSIC ||
default_format == NC_FORMAT_64BIT_OFFSET
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
|| default_format == NC_FORMAT_64BIT_DATA
#endif
)
@ -525,7 +525,7 @@ main(int argc, char **argv)
printf("Switching to 64-bit offset format.\n");
strcpy(testfile, "tst_small_64bit.nc");
break;
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
case NC_FORMAT_CDF5:
nc_set_default_format(NC_FORMAT_CDF5, NULL);
printf("Switching to 64-bit data format.\n");

View File

@ -1706,7 +1706,7 @@ copy(char* infile, char* outfile)
create_mode |= NC_64BIT_OFFSET;
break;
case NC_FORMAT_CDF5:
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
create_mode |= NC_64BIT_DATA;
break;
#else

View File

@ -11,7 +11,7 @@ set -e
# This shell script runs the ncdump tests.
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
CDF5=1
else
CDF5=0
@ -51,7 +51,7 @@ echo "*** creating 64-bit offset file c0_64_run_ncgen_tests.nc from c0.cdl..."
validateNC c0 "c0_64" -k 64-bit-offset -b
if test "x$USE_CDF5" = x1 ; then
if test "x$ENABLE_CDF5" = x1 ; then
echo "*** creating 64-bit data file c5.nc from c5.cdl..."
${NCGEN} -k 64-bit-data -b -o tst_c5_run_ncgen_tests.nc $top_srcdir/ncgen/c5.cdl

View File

@ -8,7 +8,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
# This shell script runs the ncdump tests.
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
CDF5=1
else
CDF5=0

View File

@ -12,7 +12,7 @@
#define DIMMAXCLASSIC (NC_MAX_INT - 3)
#define DIMMAX64OFFSET (NC_MAX_UINT - 3)
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
#define DIMMAX64DATA (NC_MAX_UINT64 - 3)
#endif
@ -66,7 +66,7 @@ main(int argc, char **argv)
if(dimsize != DIMMAX64OFFSET) ERR;
if ((stat=nc_close(ncid))) ERRSTAT(stat);
#ifdef USE_CDF5
#ifdef ENABLE_CDF5
if(sizeof(size_t) == 8) {
printf("\n*** Writing Max Dimension Size (%llu) For NC_64BIT_DATA\n",DIMMAX64DATA);
if ((stat=nc_create(FILE64DATA, NC_CLOBBER | NC_64BIT_DATA, &ncid))) ERRSTAT(stat);
@ -81,7 +81,7 @@ main(int argc, char **argv)
if(dimsize != DIMMAX64DATA) ERR;
if ((stat=nc_close(ncid))) ERRSTAT(stat);
}
#endif /* USE_CDF5 */
#endif /* ENABLE_CDF5 */
SUMMARIZE_ERR;
FINAL_RESULTS;

View File

@ -6,10 +6,10 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
# This shell script runs the ncdump tests.
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
USE_CDF5=1
if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
ENABLE_CDF5=1
else
USE_CDF5=0
ENABLE_CDF5=0
fi
else
echo "Cannot locate config.h"
@ -42,9 +42,9 @@ ECODE=1
fi
# Only do following test if USE_CDF5 is true.
# Only do following test if ENABLE_CDF5 is true.
if test "x$USE_CDF5" = x1 ; then
if test "x$ENABLE_CDF5" = x1 ; then
echo "Test extended format output for a 64-bit CDF-5 classic file"
rm -f tmp_tst_formatx3
${NCGEN} -k5 -b -o ./tst_formatx3.nc $srcdir/ref_tst_small.cdl

View File

@ -5,7 +5,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
HAVE_CDF5=1
else
HAVE_CDF5=0

View File

@ -13,7 +13,7 @@ echo ""
# get some config.h parameters
if test -f ${top_builddir}/config.h ; then
if fgrep -e '#define USE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
HAVE_CDF5=1
else
HAVE_CDF5=0

View File

@ -512,7 +512,7 @@ main(
/* Compute the k_flag (1st pass) using rules in the man page (ncgen.1).*/
#ifndef USE_CDF5
#ifndef ENABLE_CDF5
if(k_flag == NC_FORMAT_CDF5) {
derror("Output format CDF5 requested, but netcdf was built without cdf5 support.");
return 0;