2018-08-13 13:01:08 +08:00
|
|
|
#!/bin/sh
|
2017-11-17 04:03:35 +08:00
|
|
|
# This shell script tests ncdump for netcdf-4
|
2017-12-19 05:26:33 +08:00
|
|
|
# Ed Hartnett, Dennis Heimbigner, Ward Fisher
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2017-12-13 00:44:22 +08:00
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
2017-03-09 08:01:10 +08:00
|
|
|
. ../test_common.sh
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
set -e
|
2012-05-12 04:26:11 +08:00
|
|
|
|
2018-08-26 11:44:41 +08:00
|
|
|
# Remove the version information from _NCProperties
|
|
|
|
cleanncprops() {
|
|
|
|
src="$1"
|
|
|
|
dst="$2"
|
|
|
|
rm -f $dst
|
|
|
|
cat $src \
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
| sed -e '/:_Endianness/d' \
|
2021-01-12 05:13:21 +08:00
|
|
|
| sed -e 's/_SuperblockVersion = [12]/_SuperblockVersion = 0/' \
|
2018-08-26 11:44:41 +08:00
|
|
|
| sed -e 's/\(netcdflibversion\|netcdf\)=.*|/\1=NNNN|/' \
|
|
|
|
| sed -e 's/\(hdf5libversion\|hdf5\)=.*"/\1=HHHH"/' \
|
2018-09-07 05:53:25 +08:00
|
|
|
| grep -v '_NCProperties' \
|
2018-08-26 11:44:41 +08:00
|
|
|
| cat >$dst
|
|
|
|
}
|
|
|
|
|
2018-08-13 14:01:53 +08:00
|
|
|
ERR() {
|
2017-12-19 05:26:33 +08:00
|
|
|
RES=$?
|
|
|
|
if [ $RES -ne 0 ]; then
|
|
|
|
echo "Error found: $RES"
|
|
|
|
exit $RES
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
echo ""
|
2017-11-25 19:31:58 +08:00
|
|
|
echo "*** Testing ncgen and ncdump for netCDF-4 format."
|
2017-12-19 05:26:33 +08:00
|
|
|
${NCGEN} -k nc4 -b -o tst_netcdf4_c0_4.nc ${ncgenc04} ;ERR
|
|
|
|
${NCDUMP} -n c1 tst_netcdf4_c0_4.nc | sed 's/e+0/e+/g' > tst_netcdf4_c1_4.cdl ; ERR
|
|
|
|
diff -b tst_netcdf4_c1_4.cdl $srcdir/ref_ctest1_nc4.cdl ; ERR
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2017-11-25 20:19:11 +08:00
|
|
|
echo "*** Creating test output tst_netcdf4_c0.nc."
|
2017-12-19 05:26:33 +08:00
|
|
|
${NCGEN} -k nc7 -b -o tst_netcdf4_c0.nc ${ncgenc0} ; ERR
|
2014-09-19 08:26:06 +08:00
|
|
|
|
2017-11-25 20:19:11 +08:00
|
|
|
echo "*** Testing that program tst_h_rdc0 can read tst_netcdf4_c0.nc."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_h_rdc0 ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
|
|
|
echo "*** Running tst_create_files.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_create_files ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
echo "*** Testing tst_create_files output for netCDF-4 features."
|
2017-12-19 05:26:33 +08:00
|
|
|
${NCDUMP} tst_solar_1.nc | sed 's/e+0/e+/g' > tst_solar_1.cdl ; ERR
|
|
|
|
diff -b tst_solar_1.cdl $srcdir/ref_tst_solar_1.cdl ; ERR
|
|
|
|
${NCDUMP} tst_solar_2.nc | sed 's/e+0/e+/g' > tst_solar_2.cdl ; ERR
|
|
|
|
diff -b tst_solar_2.cdl $srcdir/ref_tst_solar_2.cdl ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
2020-07-03 03:59:37 +08:00
|
|
|
if test -f tst_roman_szip_simple.nc; then
|
|
|
|
echo "*** Testing szip compression."
|
|
|
|
${NCDUMP} tst_roman_szip_simple.nc | sed 's/e+0/e+/g' > tst_roman_szip_simple.cdl ; ERR
|
|
|
|
diff -b tst_roman_szip_simple.cdl $srcdir/ref_roman_szip_simple.cdl ; ERR
|
|
|
|
${NCDUMP} tst_roman_szip_unlim.nc | sed 's/e+0/e+/g' > tst_roman_szip_unlim.cdl ; ERR
|
|
|
|
diff -b tst_roman_szip_unlim.cdl $srcdir/ref_roman_szip_unlim.cdl ; ERR
|
|
|
|
fi
|
|
|
|
|
2017-11-17 04:03:35 +08:00
|
|
|
echo "*** Running tst_group_data.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_group_data ; ERR
|
|
|
|
${NCDUMP} tst_group_data.nc | sed 's/e+0/e+/g' > tst_group_data.cdl ; ERR
|
|
|
|
diff -b tst_group_data.cdl $srcdir/ref_tst_group_data.cdl ; ERR
|
2012-05-12 04:26:11 +08:00
|
|
|
|
2012-06-13 05:50:02 +08:00
|
|
|
echo "*** Testing -v option with absolute name and groups..."
|
2017-12-19 05:26:33 +08:00
|
|
|
${NCDUMP} -v g2/g3/var tst_group_data.nc | sed 's/e+0/e+/g' > tst_group_data.cdl ; ERR
|
|
|
|
diff -b tst_group_data.cdl $srcdir/ref_tst_group_data_v23.cdl ; ERR
|
2012-05-12 04:26:11 +08:00
|
|
|
|
2012-06-13 05:50:02 +08:00
|
|
|
echo "*** Testing -v option with relative name and groups..."
|
2017-12-19 05:26:33 +08:00
|
|
|
${NCDUMP} -v var,var2 tst_group_data.nc | sed 's/e+0/e+/g' > tst_group_data.cdl ; ERR
|
|
|
|
diff -b tst_group_data.cdl $srcdir/ref_tst_group_data.cdl ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
|
|
|
echo "*** Running tst_enum_data.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_enum_data ; ERR
|
|
|
|
${NCDUMP} tst_enum_data.nc | sed 's/e+0/e+/g' > tst_enum_data.cdl ; ERR
|
|
|
|
diff -b tst_enum_data.cdl $srcdir/ref_tst_enum_data.cdl ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
|
|
|
echo "*** Running tst_opaque_data.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_opaque_data ; ERR
|
|
|
|
${NCDUMP} tst_opaque_data.nc | sed 's/e+0/e+/g' > tst_opaque_data.cdl ; ERR
|
|
|
|
diff -b tst_opaque_data.cdl $srcdir/ref_tst_opaque_data.cdl ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
2018-11-16 01:00:38 +08:00
|
|
|
if test "x$NC_VLEN_NOTEST" = x ; then
|
2017-11-17 04:03:35 +08:00
|
|
|
echo "*** Running tst_vlen_data.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_vlen_data ; ERR
|
|
|
|
${NCDUMP} tst_vlen_data.nc | sed 's/e+0/e+/g' > tst_vlen_data.cdl ; ERR
|
|
|
|
diff -b tst_vlen_data.cdl $srcdir/ref_tst_vlen_data.cdl ; ERR
|
2018-11-16 01:00:38 +08:00
|
|
|
fi
|
2017-11-17 04:03:35 +08:00
|
|
|
|
|
|
|
echo "*** Running tst_comp.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_comp ; ERR
|
|
|
|
${NCDUMP} tst_comp.nc | sed 's/e+0/e+/g' > tst_comp.cdl ; ERR
|
|
|
|
diff -b tst_comp.cdl $srcdir/ref_tst_comp.cdl ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
|
|
|
echo "*** Running tst_nans.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_nans ; ERR
|
|
|
|
${NCDUMP} tst_nans.nc | sed 's/e+0/e+/g' > tst_nans.cdl ; ERR
|
|
|
|
diff -b tst_nans.cdl $srcdir/ref_tst_nans.cdl ; ERR
|
2017-11-17 04:03:35 +08:00
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
# Do unicode test only if it exists => BUILD_UTF8 is true
|
|
|
|
if test -f ./tst_unicode -o -f ./tst_unicode.exe ; then
|
|
|
|
echo "*** dumping tst_unicode.nc to tst_unicode.cdl..."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_unicode ; ERR
|
|
|
|
${NCDUMP} tst_unicode.nc | sed 's/e+0/e+/g' > tst_unicode.cdl ; ERR
|
2010-06-03 21:24:43 +08:00
|
|
|
#echo "*** comparing tst_unicode.cdl with ref_tst_unicode.cdl..."
|
2012-05-09 03:36:27 +08:00
|
|
|
#diff -b tst_unicode.cdl $srcdir/ref_tst_unicode.cdl
|
2010-06-03 21:24:43 +08:00
|
|
|
fi
|
2017-11-17 04:03:35 +08:00
|
|
|
|
|
|
|
echo "*** Running tst_special_atts.c to create test files."
|
2017-12-19 05:26:33 +08:00
|
|
|
${execdir}/tst_special_atts ; ERR
|
2018-08-26 11:44:41 +08:00
|
|
|
${NCDUMP} -c -s tst_special_atts.nc > tst_special_atts.cdl ; ERR
|
|
|
|
cleanncprops tst_special_atts.cdl tst_special_atts.tmp
|
|
|
|
cleanncprops $srcdir/ref_tst_special_atts.cdl ref_tst_special_atts.tmp
|
2010-06-03 21:24:43 +08:00
|
|
|
echo "*** comparing tst_special_atts.cdl with ref_tst_special_atts.cdl..."
|
2018-08-26 11:44:41 +08:00
|
|
|
diff -b tst_special_atts.tmp ref_tst_special_atts.tmp ; ERR
|
2017-12-19 05:26:33 +08:00
|
|
|
|
|
|
|
#echo ""
|
|
|
|
#echo "*** Testing ncdump on file with corrupted header "
|
|
|
|
#rm -f ./ignore_tst_netcdf4
|
|
|
|
#if ${NCDUMP} ${srcdir}/ref_test_corrupt_magic.nc > ./ignore_tst_netcdf4 2>&1 ; then
|
|
|
|
#echo "***Fail: ncdump should have failed on ref_test_corrupt_magic.nc"
|
|
|
|
#else
|
|
|
|
#echo "***XFail: ncdump properly failed on ref_test_corrupt_magic.nc"
|
|
|
|
#fi
|
|
|
|
#rm -fr ./ignore_tst_netcdf4
|
re e-support UBS-599337
re pull request https://github.com/Unidata/netcdf-c/pull/405
re pull request https://github.com/Unidata/netcdf-c/pull/446
Notes:
1. This branch is a cleanup of the magic.dmh branch.
2. magic.dmh was originally merged, but caused problems with parallel IO.
It was re-issued as pull request https://github.com/Unidata/netcdf-c/pull/446.
3. This branch + pull request replace any previous pull requests and magic.dmh branch.
Given an otherwise valid netCDF file that has a corrupted header,
the netcdf library currently crashes. Instead, it should return
NC_ENOTNC.
Additionally, the NC_check_file_type code does not do the
forward search required by hdf5 files. It currently only looks
at file position 0 instead of 512, 1024, 2048,... Also, it turns
out that the HDF4 magic number is assumed to always be at the
beginning of the file (unlike HDF5).
The change is localized to libdispatch/dfile.c See
https://support.hdfgroup.org/release4/doc/DSpec_html/DS.pdf
Also, it turns out that the code in NC_check_file_type is duplicated
(mostly) in the function libsrc4/nc4file.c#nc_check_for_hdf.
This branch does the following.
1. Make NC_check_file_type return NC_ENOTNC instead of crashing.
2. Remove nc_check_for_hdf and centralize all file format checking
NC_check_file_type.
3. Add proper forward search for HDF5 files (but not HDF4 files)
to look for the magic number at offsets of 0, 512, 1024...
4. Add test tst_hdf5_offset.sh. This tests that hdf5 files with
an offset are properly recognized. It does so by prefixing
a legal file with some number of zero bytes: 512, 1024, etc.
5. Off-topic: Added -N flag to ncdump to force a specific output dataset name.
2017-10-25 06:25:09 +08:00
|
|
|
|
2018-05-15 22:24:27 +08:00
|
|
|
# This should work, but does not. See github issue 982.
|
|
|
|
#echo "*** creating tst_output_irish_rover.cdl from ref_tst_irish_rover.nc..."
|
2018-05-15 22:13:25 +08:00
|
|
|
#${NCDUMP} ref_tst_irish_rover.nc > tst_output_irish_rover.cdl
|
|
|
|
|
2018-08-26 11:44:41 +08:00
|
|
|
rm -f *.tmp
|
2010-06-03 21:24:43 +08:00
|
|
|
echo "*** All ncgen and ncdump test output for netCDF-4 format passed!"
|
|
|
|
exit 0
|