1#!/bin/sh
2
3if test "x$srcdir" = x ; then srcdir=`pwd`; fi
4. ../test_common.sh
5
6# This shell script runs an ncdump bug test for netcdf
7# Test if the nciter code is working [NCF-154]
8
9set -e
10echo ""
11echo "*** Running ncdump nc_iter test."
12
13if test "x$CC" = "x" ; then CC="gcc"; fi
14
15CLEANUP="iter.*"
16
17rm -f $CLEANUP
18
19# echo "create iter.cdl"
20cat > iter.cdl <<EOF
21netcdf iter {
22dimensions:
23x = 5 ;
24y = 256 ;
25z = 256;
26variables:
27int var(x,y,z) ;
28data:
29var =
30EOF
31cat >./iter.c <<EOF
32#include <stdlib.h>
33#include <stdio.h>
34#define N (5*256*256)
35int main() {
36  int i;
37  for(i=0;i<N-1;i++) {printf("%d,\n",i);}
38  printf("%d;\n}\n",N);
39  return 0;
40}
41EOF
42
43$CC ./iter.c -o iter.exe
44./iter.exe >>iter.cdl
45
46# echo "*** create iter.nc "
47${NCGEN} -k nc3 -o iter.nc ./iter.cdl
48echo "*** dumping iter.nc to iter.dmp"
49${NCDUMP} iter.nc > iter.dmp
50echo "*** reformat iter.dmp"
51mv iter.dmp iter.tmp
52sed -e 's/\([0-9][,]\) /\1@/g' <iter.tmp |tr '@' '\n' |sed -e '/^$/d' >./iter.dmp
53
54echo "*** comparing iter.dmp with iter.cdl..."
55diff -b -w ./iter.dmp ./iter.cdl
56
57# cleanup
58rm -f $CLEANUP
59
60exit 0
61