Working on getting cdf5 tests running.

This commit is contained in:
Ward Fisher 2017-09-15 18:00:28 -06:00
parent c0244bc4dc
commit d2cdc4cb5a
6 changed files with 58 additions and 25 deletions

View File

@ -95,9 +95,12 @@ err:
int
nc3_cktype(int mode, nc_type type)
{
#ifdef USE_CDF5
if (mode & NC_CDF5) { /* CDF-5 format */
if (type >= NC_BYTE && type < NC_STRING) return NC_NOERR;
} else if (mode & NC_64BIT_OFFSET) { /* CDF-2 format */
} else
#endif
if (mode & NC_64BIT_OFFSET) { /* CDF-2 format */
if (type >= NC_BYTE && type <= NC_DOUBLE) return NC_NOERR;
} else if ((mode & NC_64BIT_OFFSET) == 0) { /* CDF-1 format */
if (type >= NC_BYTE && type <= NC_DOUBLE) return NC_NOERR;
@ -1086,8 +1089,11 @@ nc_set_default_format(int format, int *old_formatp)
format != NC_FORMAT_NETCDF4 && format != NC_FORMAT_NETCDF4_CLASSIC)
return NC_EINVAL;
#else
if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET &&
format != NC_FORMAT_CDF5)
if (format != NC_FORMAT_CLASSIC && format != NC_FORMAT_64BIT_OFFSET
#ifdef USE_CDF5
&& format != NC_FORMAT_CDF5
#endif
)
return NC_EINVAL;
#endif
default_create_format = format;
@ -1582,9 +1588,12 @@ NC3_inq_format(int ncid, int *formatp)
nc3 = NC3_DATA(nc);
/* only need to check for netCDF-3 variants, since this is never called for netCDF-4 files */
#ifdef USE_CDF5
if (fIsSet(nc3->flags, NC_64BIT_DATA))
*formatp = NC_FORMAT_CDF5;
else if (fIsSet(nc3->flags, NC_64BIT_OFFSET))
else
#endif
if (fIsSet(nc3->flags, NC_64BIT_OFFSET))
*formatp = NC_FORMAT_64BIT_OFFSET;
else
*formatp = NC_FORMAT_CLASSIC;

View File

@ -9,6 +9,8 @@ int numVars; /* number of variables */
int numTypes; /* number of netCDF data types to test */
#include "tests.h"
#include "config.h"
/*
* Test driver for netCDF-3 interface. This program performs tests against

View File

@ -33,6 +33,7 @@ dnl
#endif
#include "tests.h"
#include "config.h"
#include "math.h"
define(`EXPECT_ERR',`error("expecting $1 but got %s",nc_err_code_name($2));')dnl
@ -2405,8 +2406,11 @@ 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 ||
magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5)
magic[MAGIC_NUM_LEN-1] == NC_FORMAT_64BIT_OFFSET
#ifdef USE_CDF5
|| magic[MAGIC_NUM_LEN-1] == NC_FORMAT_CDF5
#endif
)
*version = magic[MAGIC_NUM_LEN-1];
else
return NC_ENOTNC;
@ -2449,8 +2453,8 @@ TestFunc(set_default_format)(void)
ELSE_NOK
/* Cycle through available formats. */
for(i=NC_FORMAT_CLASSIC; i<NC_FORMAT_64BIT_DATA; i++)
{
for(i=NC_FORMAT_CLASSIC; i<NC_FORMAT_64BIT_DATA; i++) {
if (i == NC_FORMAT_NETCDF4 || i == NC_FORMAT_NETCDF4_CLASSIC)
continue; /* test classic formats only */
if ((err = APIFunc(set_default_format)(i, NULL)))

View File

@ -1,23 +1,24 @@
netcdf inttags64 {
netcdf inttags4 {
dimensions:
d = 3 ;
variables:
ubyte ub(d);
ushort us(d);
uint ui(d);
int64 i64(d);
uint64 ui64(d);
ubyte ub(d) ;
ushort us(d) ;
uint ui(d) ;
int64 i64(d) ;
uint64 ui64(d) ;
// global attributes:
:attrll = -23232244LL, 1214124123423LL, -2353424234LL ;
data:
ub = 255UB, 255ub, 255u ;
ub = 255, 255, 255 ;
us = 65534US, 65534us, 65534u ;
us = 65534, 65534, 65534 ;
ui = 4294967294UL, 4294967294ul, 4294967294u ;
ui = 4294967294, 4294967294, 4294967294 ;
i64 = 9223372036854775807LL, 9223372036854775807ll, 9223372036854775807 ;
i64 = 9223372036854775807, 9223372036854775807, 9223372036854775807 ;
ui64 = 18446744073709551615ULL, 18446744073709551615ull, 18446744073709551615uLL;
ui64 = 18446744073709551615, 18446744073709551615, 18446744073709551615 ;
}

View File

@ -8,6 +8,19 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
echo "*** Testing ncgen."
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
CDF5=1
else
CDF5=0
fi
else
echo "Cannot locate config.h"
exit 1
fi
#VALGRIND="valgrind -q --error-exitcode=2 --leak-check=full"
validateNC() {
@ -37,11 +50,15 @@ echo "*** creating 64-bit offset file c0_64.nc from c0.cdl..."
validateNC c0 "c0_64" -k 64-bit-offset -b
echo "*** creating 64-bit offset file c5.nc from c5.cdl..."
${NCGEN} -k 64-bit-data -b -o c5.nc $top_srcdir/ncgen/c5.cdl
if [ ! -f c5.nc ]; then
echo "Failure."
exit 1
if [ "x$USE_CDF5" == "x1" ]; then
echo "*** creating 64-bit data file c5.nc from c5.cdl..."
${NCGEN} -k 64-bit-data -b -o c5.nc $top_srcdir/ncgen/c5.cdl
if [ ! -f c5.nc ]; then
echo "Failure."
exit 1
fi
fi
echo "*** Test successful!"

View File

@ -8,7 +8,7 @@ set -e
echo "*** Test netcdf-4 integer constant suffixes"
echo "*** creating inttags4.nc from inttags4.cdl..."
${NCGEN} -lb -o -k nc4 inttags4.nc $srcdir/inttags4.cdl
${NCGEN} -lb -k nc4 -o inttags4.nc $srcdir/inttags4.cdl
echo "*** creating tst_inttags4.cdl from inttags4.nc..."
${NCDUMP} inttags4.nc > tst_inttags4.cdl
echo "*** comparing tst_inttags4.cdl to ref_inttags4.nc..."