1#!/bin/sh
2
3if test "x$srcdir" = x ; then srcdir=`pwd`; fi
4. ../test_common.sh
5
6# This shell script runs the ncdump tests.
7# get some config.h parameters
8if test -f ${top_builddir}/config.h ; then
9  if fgrep -e '#define ENABLE_CDF5 1' ${top_builddir}/config.h >/dev/null ; then
10    ENABLE_CDF5=1
11  else
12    ENABLE_CDF5=0
13  fi
14else
15  echo "Cannot locate config.h"
16  exit 1
17fi
18
19# This shell script tests the output several previous tests.
20
21ECODE=0
22
23echo ""
24echo "*** Testing extended file format output."
25set -e
26echo "Test extended format output for a netcdf-3 file"
27rm -f tmp_tst_formatx3
28${NCGEN} -k nc3 -b -o ./tst_formatx3.nc $srcdir/ref_tst_small.cdl
29${NCDUMP} -K tst_formatx3.nc >tmp_tst_formatx3
30if ! grep 'classic mode=00000000' <tmp_tst_formatx3 ; then
31echo "*** Fail: extended format for a classic file"
32ECODE=1
33fi
34
35echo "Test extended format output for a 64-bit offset netcdf-3 file"
36rm -f tmp_tst_formatx3
37${NCGEN} -k nc6 -b -o ./tst_formatx3.nc $srcdir/ref_tst_small.cdl
38${NCDUMP} -K tst_formatx3.nc >tmp_tst_formatx3
39if ! grep '64-bit offset mode=00000200' <tmp_tst_formatx3 ; then
40echo "*** Fail: extended format for a 64-bit classic file"
41ECODE=1
42fi
43
44
45# Only do following test if ENABLE_CDF5 is true.
46
47if test "x$ENABLE_CDF5" = x1 ; then
48    echo "Test extended format output for a 64-bit CDF-5 classic file"
49    rm -f tmp_tst_formatx3
50    ${NCGEN} -k5 -b -o ./tst_formatx3.nc $srcdir/ref_tst_small.cdl
51    ${NCDUMP} -K tst_formatx3.nc >tmp_tst_formatx3
52    if ! grep -F '64-bit data mode=00000020' <tmp_tst_formatx3 ; then
53        echo "*** Fail: extended format for a 64-bit CDF-5 classic file"
54        ECODE=1
55    fi
56fi
57
58rm -f tmp_tst_formatx3 tst_formatx3.nc
59
60exit $ECODE
61