2010-06-03 21:24:43 +08:00
|
|
|
#!/bin/sh
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
|
|
. ../test_common.sh
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
# For a netCDF-4 build, test nccopy on netCDF files in this directory
|
|
|
|
|
|
|
|
set -e
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
# These files are actually in $srcdir in distcheck builds, so they
|
|
|
|
# need to be handled differently.
|
2015-04-21 03:15:02 +08:00
|
|
|
# ref_tst_compounds2 ref_tst_compounds3 ref_tst_compounds4
|
|
|
|
TESTFILES='tst_comp tst_comp2 tst_enum_data tst_fillbug
|
2010-09-01 06:41:00 +08:00
|
|
|
tst_group_data tst_nans tst_opaque_data tst_solar_1 tst_solar_2
|
|
|
|
tst_solar_cmp tst_special_atts tst_string_data tst_unicode
|
|
|
|
tst_vlen_data'
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2010-09-01 06:41:00 +08:00
|
|
|
echo "*** Testing netCDF-4 features of nccopy on ncdump/*.nc files"
|
2010-06-03 21:24:43 +08:00
|
|
|
for i in $TESTFILES ; do
|
2012-06-13 05:50:02 +08:00
|
|
|
echo "*** Test nccopy $i.nc copy_of_$i.nc ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY $i.nc copy_of_$i.nc
|
|
|
|
${NCDUMP} -n copy_of_$i $i.nc > tmp.cdl
|
|
|
|
${NCDUMP} copy_of_$i.nc > copy_of_$i.cdl
|
2012-06-13 05:50:02 +08:00
|
|
|
# echo "*** compare " with copy_of_$i.cdl
|
2010-06-03 21:24:43 +08:00
|
|
|
diff copy_of_$i.cdl tmp.cdl
|
|
|
|
rm copy_of_$i.nc copy_of_$i.cdl tmp.cdl
|
|
|
|
done
|
2012-06-13 05:50:02 +08:00
|
|
|
# echo "*** Testing compression of deflatable files ..."
|
2010-09-01 23:45:55 +08:00
|
|
|
./tst_compress
|
2011-06-21 23:10:17 +08:00
|
|
|
echo "*** Test nccopy -d1 can compress a classic format file ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -d1 tst_inflated.nc tst_deflated.nc
|
2010-09-01 06:41:00 +08:00
|
|
|
if test `wc -c < tst_deflated.nc` -ge `wc -c < tst_inflated.nc`; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-06-21 23:10:17 +08:00
|
|
|
echo "*** Test nccopy -d1 can compress a netCDF-4 format file ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -d1 tst_inflated4.nc tst_deflated.nc
|
2011-06-21 23:10:17 +08:00
|
|
|
if test `wc -c < tst_deflated.nc` -ge `wc -c < tst_inflated4.nc`; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "*** Test nccopy -d1 -s can compress a classic model netCDF-4 file even more ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -d1 -s tst_inflated.nc tmp.nc
|
2010-09-01 06:41:00 +08:00
|
|
|
if test `wc -c < tmp.nc` -ge `wc -c < tst_inflated.nc`; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-06-21 23:10:17 +08:00
|
|
|
echo "*** Test nccopy -d1 -s can compress a netCDF-4 file even more ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -d1 -s tst_inflated4.nc tmp.nc
|
2011-06-21 23:10:17 +08:00
|
|
|
if test `wc -c < tmp.nc` -ge `wc -c < tst_inflated4.nc`; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-03-24 07:25:45 +08:00
|
|
|
echo "*** Test nccopy -d0 turns off compression, shuffling of compressed, shuffled file ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -d0 tst_inflated4.nc tmp.nc
|
|
|
|
${NCDUMP} -sh tmp.nc > tmp.cdl
|
2014-03-24 07:25:45 +08:00
|
|
|
if fgrep '_DeflateLevel' < tmp.cdl ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if fgrep '_Shuffle' < tmp.cdl ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rm tst_deflated.nc tst_inflated.nc tst_inflated4.nc tmp.nc tmp.cdl
|
2010-09-01 06:41:00 +08:00
|
|
|
|
|
|
|
echo "*** Testing nccopy -d1 -s on ncdump/*.nc files"
|
|
|
|
for i in $TESTFILES ; do
|
2012-06-13 05:50:02 +08:00
|
|
|
echo "*** Test nccopy -d1 -s $i.nc copy_of_$i.nc ..."
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -d1 -s $i.nc copy_of_$i.nc
|
|
|
|
${NCDUMP} -n copy_of_$i $i.nc > tmp.cdl
|
|
|
|
${NCDUMP} copy_of_$i.nc > copy_of_$i.cdl
|
2012-06-13 05:50:02 +08:00
|
|
|
# echo "*** compare " with copy_of_$i.cdl
|
2010-09-01 06:41:00 +08:00
|
|
|
diff copy_of_$i.cdl tmp.cdl
|
|
|
|
rm copy_of_$i.nc copy_of_$i.cdl tmp.cdl
|
|
|
|
done
|
2011-01-18 06:15:26 +08:00
|
|
|
./tst_chunking
|
|
|
|
echo "*** Test that nccopy -c can chunk and unchunk files"
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY tst_chunking.nc tmp.nc
|
|
|
|
${NCDUMP} tmp.nc > tmp.cdl
|
|
|
|
$NCCOPY -c dim0/,dim1/1,dim2/,dim3/1,dim4/,dim5/1,dim6/ tst_chunking.nc tmp-chunked.nc
|
|
|
|
${NCDUMP} -n tmp tmp-chunked.nc > tmp-chunked.cdl
|
2011-01-18 06:15:26 +08:00
|
|
|
diff tmp.cdl tmp-chunked.cdl
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -c dim0/,dim1/,dim2/,dim3/,dim4/,dim5/,dim6/ tmp-chunked.nc tmp-unchunked.nc
|
|
|
|
${NCDUMP} -n tmp tmp-unchunked.nc > tmp-unchunked.cdl
|
2011-01-18 06:15:26 +08:00
|
|
|
diff tmp.cdl tmp-unchunked.cdl
|
2017-03-09 08:01:10 +08:00
|
|
|
$NCCOPY -c / tmp-chunked.nc tmp-unchunked.nc
|
|
|
|
${NCDUMP} -n tmp tmp-unchunked.nc > tmp-unchunked.cdl
|
2014-03-24 07:25:45 +08:00
|
|
|
diff tmp.cdl tmp-unchunked.cdl
|
2015-01-04 08:18:14 +08:00
|
|
|
echo "*** Test that nccopy -c works as intended for record dimension default (1)"
|
2017-03-09 08:01:10 +08:00
|
|
|
${NCGEN} -b -o tst_bug321.nc $srcdir/tst_bug321.cdl
|
|
|
|
$NCCOPY -k nc7 -c"lat/2,lon/2" tst_bug321.nc tmp.nc
|
|
|
|
${NCDUMP} -n tst_bug321 tmp.nc > tmp.cdl
|
2015-01-04 08:18:14 +08:00
|
|
|
diff $srcdir/tst_bug321.cdl tmp.cdl
|
2011-01-18 06:15:26 +08:00
|
|
|
# echo "*** Test that nccopy compression with chunking can improve compression"
|
|
|
|
rm tst_chunking.nc tmp.nc tmp.cdl tmp-chunked.nc tmp-chunked.cdl tmp-unchunked.nc tmp-unchunked.cdl
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
echo "*** All nccopy tests passed!"
|
|
|
|
exit 0
|