netcdf-c/nczarr_test/test_nczarr.sh
Dennis Heimbigner 11fe00ea05 Add filter support to NCZarr
Filter support has three goals:

1. Use the existing HDF5 filter implementations,
2. Allow filter metadata to be stored in the NumCodecs metadata format used by Zarr,
3. Allow filters to be used even when HDF5 is disabled

Detailed usage directions are define in docs/filters.md.

For now, the existing filter API is left in place. So filters
are defined using ''nc_def_var_filter'' using the HDF5 style
where the id and parameters are unsigned integers.

This is a big change since filters affect many parts of the code.

In the following, the terms "compressor" and "filter" and "codec" are generally
used synonomously.

### Filter-Related Changes:
* In order to support dynamic loading of shared filter libraries, a new library was added in the libncpoco directory; it helps to isolate dynamic loading across multiple platforms.
* Provide a json parsing library for use by plugins; this is created by merging libdispatch/ncjson.c with include/ncjson.h.
* Add a new _Codecs attribute to allow clients to see what codecs are being used; let ncdump -s print it out.
* Provide special headers to help support compilation of HDF5 filters when HDF5 is not enabled: netcdf_filter_hdf5_build.h and netcdf_filter_build.h.
* Add a number of new test to test the new nczarr filters.
* Let ncgen parse _Codecs attribute, although it is ignored.

### Plugin directory changes:
* Add support for the Blosc compressor; this is essential because it is the most common compressor used in Zarr datasets. This also necessitated adding a CMake FindBlosc.cmake file
* Add NCZarr support for the big-four filters provided by HDF5: shuffle, fletcher32, deflate (zlib), and szip
* Add a Codec defaulter (see docs/filters.md) for the big four filters.
* Make plugins work with windows by properly adding __declspec declaration.

### Misc. Non-Filter Changes
* Replace most uses of USE_NETCDF4 (deprecated) with USE_HDF5.
* Improve support for caching
* More fixes for path conversion code
* Fix misc. memory leaks
* Add new utility -- ncdump/ncpathcvt -- that does more or less the same thing as cygpath.
* Add a number of new test to test the non-filter fixes.
* Update the parsers
* Convert most instances of '#ifdef _MSC_VER' to '#ifdef _WIN32'
2021-09-02 17:04:26 -06:00

150 lines
3.4 KiB
Bash
Executable File

#!/bin/sh
if test "x$SETX" != x; then set -x; fi
# Figure out which cloud repo to use
if test "x$NCZARR_S3_TEST_HOST" = x ; then
export NCZARR_S3_TEST_HOST=stratus.ucar.edu
fi
if test "x$NCZARR_S3_TEST_BUCKET" = x ; then
export NCZARR_S3_TEST_BUCKET=unidata-netcdf-zarr-testing
fi
export NCZARR_S3_TEST_URL="https://${NCZARR_S3_TEST_HOST}/${NCZARR_S3_TEST_BUCKET}"
ZMD="${execdir}/zmapio"
awsdelete() {
${execdir}/s3util -u "${NCZARR_S3_TEST_URL}/" -k "$1" clear
#aws s3api delete-object --endpoint-url=https://${NCZARR_S3_TEST_HOST} --bucket=${NCZARR_S3_TEST_BUCKET} --key="netcdf-c/$1"
}
# Check settings
checksetting() {
if test -f ${TOPBUILDDIR}/libnetcdf.settings ; then
local PATTERN
PATTERN="${1}:[ ]*yes"
if grep "$PATTERN" <${TOPBUILDDIR}/libnetcdf.settings ; then
HAVE_SETTING=1
else
unset HAVE_SETTING
fi
fi
}
checkprops() {
specflag=
headflag=
isxfail=
# determine if this is an xfailtest
for t in ${XFAILTESTS} ; do
if test "x${t}" = "x${x}" ; then isxfail=1; fi
done
for t in ${SPECTESTS} ; do
if test "x${t}" = "x${f}" ; then specflag="-s"; fi
done
for t in ${HEADTESTS} ; do
if test "x${t}" = "x${f}" ; then headflag="-h"; fi
done
}
extfor() {
case "$1" in
file) zext="file" ;;
zip) zext="zip" ;;
s3) zext="s3" ;;
*) echo "unknown kind: $1" ; exit 1;;
esac
}
deletemap() {
case "$1" in
file) rm -fr $2;;
zip) rm -f $2;;
s3) S3KEY=`${execdir}/zs3parse -k $2`; awsdelete $S3KEY;;
*) echo "unknown kind: $1" ; exit 1;;
esac
}
mapstillexists() {
mapstillexists=0
if "./zmapio $fileurl" ; then
echo "delete failed: $1"
mapstillexists=1
fi
}
fileargs() {
f="$1"
frag="$2"
if test "x$frag" = x ; then frag="mode=nczarr,$zext" ; fi
case "$zext" in
s3)
S3PATH="${NCZARR_S3_TEST_URL}/netcdf-c"
fileurl="${S3PATH}/${f}#${frag}"
file=$fileurl
S3HOST=`${execdir}/zs3parse -h $S3PATH`
S3BUCKET=`${execdir}/zs3parse -b $S3PATH`
S3PREFIX=`${execdir}/zs3parse -k $S3PATH`
;;
*)
file="${f}.$zext"
fileurl="file://${f}.$zext#${frag}"
;;
esac
}
dumpmap() {
zext=$1
zbase=`basename $2 ".$zext"`
fileargs $zbase
${execdir}/zmapio -t int -x objdump $fileurl > $3
}
# Function to remove selected -s attributes from file;
# These attributes might be platform dependent
sclean() {
cat $1 \
| sed -e '/:_IsNetcdf4/d' \
| sed -e '/:_Endianness/d' \
| sed -e '/_NCProperties/d' \
| sed -e '/_SuperblockVersion/d' \
| cat > $2
}
# Make sure execdir and srcdir absolute paths are available
WD=`pwd`
cd $srcdir ; abs_srcdir=`pwd` ; cd $WD
cd $execdir ; abs_execdir=`pwd` ; cd $WD
# Clear out any existing .rc files
WD=`pwd`
if test "x$NCAUTH_HOMETEST" != x ; then RCHOME=1; fi
# Set plugin path
#cd ../plugins; make clean all >/dev/null; cd ../nczarr_test
# Load the findplugins function
. ${builddir}/findplugin.sh
echo "findplugin.sh loaded"
# Locate the plugin path and the library names; argument order is critical
# Find bzip2 and capture
# Assume all test filters are in same plugin dir
findplugin h5misc
echo "final HDF5_PLUGIN_PATH=${HDF5_PLUGIN_PATH}"
export HDF5_PLUGIN_PATH
resetrc() {
if test "x$RCHOME" = x1 ; then
rm -f ${HOME}/.dodsrc ${HOME}/.daprc ${HOME}/.ncrc
fi
rm -f ${WD}/.dodsrc ${WD}/.daprc ${WD}/.ncrc
unset NCRCENV_IGNORE
unset NCRCENV_RC
unset DAPRCFILE
}
resetrc