mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-09 08:11:38 +08:00
3ffe7be446
re: Discussion https://github.com/Unidata/netcdf-c/discussions/2214 The primary change is to support so-called "standard filters". A standard filter is one that is defined by the following netcdf-c API: ```` int nc_def_var_XXX(int ncid, int varid, size_t nparams, unsigned* params); int nc_inq_var_XXXX(int ncid, int varid, int* usefilterp, unsigned* params); ```` So for example, zstandard would be a standard filter by defining the functions *nc_def_var_zstandard* and *nc_inq_var_zstandard*. In order to define these functions, we need a new dispatch function: ```` int nc_inq_filter_avail(int ncid, unsigned filterid); ```` This function, combined with the existing filter API can be used to implement arbitrary standard filters using a simple code pattern. Note that I would have preferred that this function return a list of all available filters, but HDF5 does not support that functionality. So this PR implements the dispatch function and implements the following standard functions: + bzip2 + zstandard + blosc Specific test cases are also provided for HDF5 and NCZarr. Over time, other specific standard filters will be defined. ## Primary Changes * Add nc_inq_filter_avail() to netcdf-c API. * Add standard filter implementations to test use of *nc_inq_filter_avail*. * Bump the dispatch table version number and add to all the relevant dispatch tables (libsrc, libsrcp, etc). * Create a program to invoke nc_inq_filter_avail so that it is accessible to shell scripts. * Cleanup szip support to properly support szip when HDF5 is disabled. This involves detecting libsz separately from testing if HDF5 supports szip. * Integrate shuffle and fletcher32 into the existing filter API. This means that, for example, nc_def_var_fletcher32 is now a wrapper around nc_def_var_filter. * Extend the Codec defaulting to allow multiple default shared libraries. ## Misc. Changes * Modify configure.ac/CMakeLists.txt to look for the relevant libraries implementing standard filters. * Modify libnetcdf.settings to list available standard filters (including deflate and szip). * Add CMake test modules to locate libbz2 and libzstd. * Cleanup the HDF5 memory manager function use in the plugins. * remove unused file include//ncfilter.h * remove tests for the HDF5 memory operations e.g. H5allocate_memory. * Add flag to ncdump to force use of _Filter instead of _Deflate or _Shuffle or _Fletcher32. Used for testing.
80 lines
2.8 KiB
Bash
Executable File
80 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# This shell script runs extra tests ncdump for netcdf-4
|
|
# Dennis Heimbigner, Ward Fisher
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
. ../test_common.sh
|
|
|
|
set -e
|
|
|
|
# Remove the version information from _NCProperties
|
|
cleanncprops() {
|
|
src="$1"
|
|
dst="$2"
|
|
rm -f $dst
|
|
cat $src \
|
|
| sed -e '/:_Endianness/d' \
|
|
| sed -e 's/_SuperblockVersion = [12]/_SuperblockVersion = 0/' \
|
|
| sed -e 's/\(netcdflibversion\|netcdf\)=.*|/\1=NNNN|/' \
|
|
| sed -e 's/\(hdf5libversion\|hdf5\)=.*"/\1=HHHH"/' \
|
|
| grep -v '_NCProperties' \
|
|
| cat >$dst
|
|
}
|
|
|
|
echo ""
|
|
echo "*** Running extra netcdf-4 tests."
|
|
|
|
#
|
|
# In windows, these tests fail because srcdir is prepended.
|
|
# e.g., Instead of 'ncdump ref_tst_compounds2' the file would
|
|
# contain:
|
|
# 'ncdump ./ref_tst_compounds2'. This causes the test to fail.
|
|
# But, 'srcdir' is necessary for make distcheck.
|
|
#
|
|
# Short term solution, use sed when on windows/MSYS to
|
|
# remove the './','../../ncdump'.
|
|
#
|
|
# I am undoing this because libdispatch/dwinpath.c
|
|
# should be taking care of this. If not, then that is
|
|
# what we need to fix. Alternatively, we can use top_srcdir,
|
|
# which is an absolute path
|
|
|
|
echo "*** running tst_string_data to create test files..."
|
|
${execdir}/tst_string_data
|
|
|
|
echo "*** dumping tst_string_data.nc to tst_string_data.cdl..."
|
|
${NCDUMP} tst_string_data.nc > tst_string_data.cdl
|
|
cleanncprops tst_string_data.cdl tst_string_data.tmp
|
|
cleanncprops ${srcdir}/ref_tst_string_data.cdl ref_tst_string_data.tmp
|
|
echo "*** comparing tst_string_data.cdl with ref_tst_string_data.cdl..."
|
|
diff -b tst_string_data.tmp ref_tst_string_data.tmp
|
|
|
|
#echo '*** testing non-coordinate variable of same name as dimension...'
|
|
#${NCGEN} -v4 -b -o tst_noncoord.nc ${top_srcdir}/ncdump/ref_tst_noncoord.cdl
|
|
|
|
echo '*** testing reference file ref_tst_compounds2.nc...'
|
|
${NCDUMP} -n ref_tst_compounds2 ${top_srcdir}/ncdump/ref_tst_compounds2.nc > tst_compounds2.cdl
|
|
diff -b tst_compounds2.cdl ${top_srcdir}/ncdump/ref_tst_compounds2.cdl
|
|
|
|
echo '*** testing reference file ref_tst_compounds3.nc...'
|
|
${NCDUMP} -n ref_tst_compounds3 ${top_srcdir}/ncdump/ref_tst_compounds3.nc > tst_compounds3.cdl
|
|
diff -b tst_compounds3.cdl ${top_srcdir}/ncdump/ref_tst_compounds3.cdl
|
|
|
|
echo '*** testing reference file ref_tst_compounds4.nc...'
|
|
${NCDUMP} -n ref_tst_compounds4 ${top_srcdir}/ncdump/ref_tst_compounds4.nc > tst_compounds4.cdl
|
|
diff -b tst_compounds4.cdl ${top_srcdir}/ncdump/ref_tst_compounds4.cdl
|
|
|
|
# Exercise Jira NCF-213 bug fix
|
|
# rm -f tst_ncf213.cdl tst_ncf213.nc
|
|
# Remove specific _NCProperties values
|
|
${NCGEN} -b -o tst_ncf213.nc $srcdir/ref_tst_ncf213.cdl
|
|
${NCDUMP} -shF tst_ncf213.nc > tst_ncf213.cdl
|
|
cleanncprops tst_ncf213.cdl tst_ncf213.tmp
|
|
cleanncprops ${srcdir}/ref_tst_ncf213.cdl ref_tst_ncf213.tmp
|
|
# Now compare
|
|
diff -b tst_ncf213.tmp ref_tst_ncf213.tmp
|
|
|
|
echo "*** All ncgen and ncdump extra test output for netCDF-4 format passed!"
|
|
exit 0
|
|
|