netcdf-c/ncdump/tst_iter.sh

57 lines
1008 B
Bash
Raw Normal View History

2012-03-08 07:38:51 +08:00
#!/bin/sh
# This shell script runs an ncdump bug test for netcdf
2012-03-09 02:13:08 +08:00
# Test if the nciter code is working [NCF-154]
2012-03-08 07:38:51 +08:00
set -e
echo ""
2012-03-08 07:38:51 +08:00
echo "*** Running ncdump nc_iter test."
if test "x$CC" = "x" ; then CC="gcc"; fi
2012-03-09 02:13:08 +08:00
CLEANUP="iter.*"
2012-03-08 07:38:51 +08:00
rm -f $CLEANUP
# echo "create iter.cdl"
2012-03-09 02:13:08 +08:00
cat > iter.cdl <<EOF
netcdf iter {
2012-03-08 07:38:51 +08:00
dimensions:
x = 5 ;
y = 256 ;
z = 256;
variables:
int var(x,y,z) ;
data:
var =
EOF
2012-03-09 02:13:08 +08:00
cat >./iter.c <<EOF
2012-03-08 07:38:51 +08:00
#include <stdlib.h>
#include <stdio.h>
#define N (5*256*256)
int main() {
int i;
for(i=0;i<N-1;i++) {printf("%d,\n",i);}
printf("%d;\n}\n",N);
return 0;
}
EOF
2012-03-09 02:13:08 +08:00
$CC ./iter.c -o iter.exe
./iter.exe >>iter.cdl
2012-03-08 07:38:51 +08:00
# echo "*** create iter.nc "
2012-03-09 02:13:08 +08:00
../ncgen/ncgen -k1 -o iter.nc ./iter.cdl
echo "*** dumping iter.nc to iter.dmp"
./ncdump iter.nc > iter.dmp
echo "*** reformat iter.dmp"
mv iter.dmp iter.tmp
sed -e 's/\([0-9][,]\) /\1@/g' <iter.tmp |tr '@' '\n' |sed -e '/^$/d' >./iter.dmp
2012-03-08 07:38:51 +08:00
2012-03-09 02:13:08 +08:00
echo "*** comparing iter.dmp with iter.cdl..."
diff -b -w ./iter.dmp ./iter.cdl
2012-03-08 07:38:51 +08:00
# cleanup
rm -f $CLEANUP
exit 0