1#!/bin/sh 2# For a netCDF-3 build, test nccopy on netCDF files in this 3# directory. This test depends on a bunch of other ncdump tests 4# running first, to produce the data files that are used to test 5# nccopy. 6# Dennis Heimbigner 7 8if test "x$srcdir" = x ; then srcdir=`pwd`; fi 9. ../test_common.sh 10 11set -e 12echo "" 13 14# get some config.h parameters 15if test -f ${top_builddir}/config.h ; then 16 if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then 17 HAVE_CDF5=1 18 else 19 HAVE_CDF5=0 20 fi 21else 22 echo "Cannot locate config.h" 23 exit 1 24fi 25 26TESTFILES='tst_output_c0 tst_output_c0tmp ctest0 ctest0_64 test0_offset test1_offset 27 tst_calendars tst_mslp tst_mslp_64 tst_ncml tst_small tst_utf8' 28 29if test "x$HAVE_CDF5" = x1 ; then 30 TESTFILES="$TESTFILES small small2" 31fi 32 33 34echo "*** Testing netCDF-3 features of nccopy on ncdump/*.nc files" 35for i in $TESTFILES ; do 36 echo "*** Testing nccopy $i.nc nccopy3_copy_of_$i.nc ..." 37ls -l $i.nc 38 ${NCCOPY} $i.nc nccopy3_copy_of_$i.nc 39 ${NCDUMP} -n nccopy3_copy_of_$i $i.nc > tmp_tst_nccopy3.cdl 40 ${NCDUMP} nccopy3_copy_of_$i.nc > nccopy3_copy_of_$i.cdl 41 diff nccopy3_copy_of_$i.cdl tmp_tst_nccopy3.cdl 42 rm nccopy3_copy_of_$i.nc nccopy3_copy_of_$i.cdl tmp_tst_nccopy3.cdl 43done 44echo "*** Testing nccopy -u" 45${NCGEN} -b $srcdir/tst_brecs.cdl 46# convert record dimension to fixed-size dimension 47$NCCOPY -u tst_brecs.nc nccopy3_copy_of_tst_brecs.nc 48${NCDUMP} -n nccopy3_copy_of_tst_brecs tst_brecs.nc | sed '/ = UNLIMITED ;/s/\(.*\) = UNLIMITED ; \/\/ (\(.*\) currently)/\1 = \2 ;/' > tmp_tst_nccopy3.cdl 49${NCDUMP} nccopy3_copy_of_tst_brecs.nc > nccopy3_copy_of_tst_brecs.cdl 50diff -b nccopy3_copy_of_tst_brecs.cdl tmp_tst_nccopy3.cdl 51rm nccopy3_copy_of_tst_brecs.cdl tmp_tst_nccopy3.cdl tst_brecs.nc nccopy3_copy_of_tst_brecs.nc 52 53echo "*** All nccopy tests passed!" 54exit 0 55