2012-03-08 07:38:51 +08:00
|
|
|
#!/bin/sh
|
2017-03-09 08:01:10 +08:00
|
|
|
|
|
|
|
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
|
|
|
|
. ../test_common.sh
|
|
|
|
|
2012-03-08 07:38:51 +08:00
|
|
|
# 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
|
2012-06-13 05:50:02 +08:00
|
|
|
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
|
|
|
|
|
2012-06-13 05:50:02 +08:00
|
|
|
# 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
|
|
|
|
2012-06-13 05:50:02 +08:00
|
|
|
# echo "*** create iter.nc "
|
2017-03-09 08:01:10 +08:00
|
|
|
${NCGEN} -k nc3 -o iter.nc ./iter.cdl
|
2012-03-09 02:13:08 +08:00
|
|
|
echo "*** dumping iter.nc to iter.dmp"
|
2017-03-09 08:01:10 +08:00
|
|
|
${NCDUMP} iter.nc > iter.dmp
|
2012-03-09 02:13:08 +08:00
|
|
|
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..."
|
2012-05-09 03:36:27 +08:00
|
|
|
diff -b -w ./iter.dmp ./iter.cdl
|
2012-03-08 07:38:51 +08:00
|
|
|
|
|
|
|
# cleanup
|
|
|
|
rm -f $CLEANUP
|
|
|
|
|
|
|
|
exit 0
|