netcdf-c/ncgen/run_nc4_tests.sh

59 lines
1.5 KiB
Bash
Raw Normal View History

2010-06-03 21:24:43 +08:00
#!/bin/sh
# This shell script runs the ncdump tests.
# $Id: run_nc4_tests.sh,v 1.4 2010/05/18 20:05:23 dmh Exp $
2015-11-20 04:44:07 +08:00
if test "x$srcdir" = x ; then srcdir="."; fi
##
# Function to test a netCDF CDL file.
# 1. Generate binary nc.
# Use ncdump to compare against original CDL file.
2016-11-19 02:53:53 +08:00
# Input: CDL file name, minus the suffix, output filename
# Other input: arguments.
#
# Example:
# $ validateNC compound_datasize_test -k nc4
##
validateNC() {
BASENAME=$1
INFILE=$srcdir/$1.cdl
2016-11-19 04:59:57 +08:00
TMPFILE=tst_$2.cdl
2016-11-19 02:53:53 +08:00
shift
shift
ARGS=$@
echo "*** generating $BASENAME.nc ***"
2016-11-19 02:53:53 +08:00
./ncgen $ARGS -o $BASENAME.nc $INFILE
../ncdump/ncdump $BASENAME.nc | sed 's/e+0/e+/g' > $TMPFILE
echo "*** comparing binary against source CDL file *** "
diff -b -w $INFILE $TMPFILE
}
2010-06-03 21:24:43 +08:00
echo "*** Testing ncgen for netCDF-4."
set -e
2015-11-20 04:44:07 +08:00
echo "*** creating netCDF-4 file c0_4.nc from c0_4.cdl..."
2016-11-19 02:53:53 +08:00
validateNC "c0_4" "c0_4" -k nc4 -b -o c0_4.nc
2015-11-20 04:44:07 +08:00
2010-06-03 21:24:43 +08:00
echo "*** creating netCDF-4 classic model file c0_4c.nc from c0.cdl..."
2016-11-19 02:53:53 +08:00
validateNC "c0" "c0_4c" -k nc7 -b
2015-11-20 04:44:07 +08:00
2010-06-03 21:24:43 +08:00
echo "*** creating C code for CAM file ref_camrun.cdl..."
./ncgen -lc $srcdir/ref_camrun.cdl >ref_camrun.c
2012-11-01 04:07:11 +08:00
echo "*** test for jira NCF-199 bug"
2016-11-19 02:53:53 +08:00
validateNC "ncf199" "ncf199" -k nc4
2012-11-01 04:07:11 +08:00
echo "*** creating binary files for github issue 323..."
echo "*** github issue 323 test 1"
2016-11-19 02:53:53 +08:00
validateNC "compound_datasize_test" "compound_datasize_test" -k nc4
echo "*** github issue 323 test 2"
2016-11-19 02:53:53 +08:00
validateNC "compound_datasize_test2" "compound_datasize_test2" -k nc4
2010-06-03 21:24:43 +08:00
echo "*** Test successful!"
exit 0