#! @SHELL@
echo 1..1 # Number of tests to be executed.
#
test -n "$CDO"      || CDO=cdo
test -n "$DATAPATH" || DATAPATH=./data
#
CDOOUT=cout$$
CDOERR=cerr$$
FORMAT="-f srv -b 32"
#
PCTLS="1 20 25 33 50 66 75 80 99 100"
#
IFILE=$DATAPATH/t21_geosp_tsurf.grb
#
NTEST=1
RSTAT=0
echo "Running test: $NTEST"
#
for PCTL in $PCTLS; do
  RFILE=$DATAPATH/fldpctl${PCTL}_ref
  OFILE=fldpctl${STAT}_res

  CDOTEST="fldpctl"
  CDOCOMMAND="$CDO $FORMAT fldpctl,${PCTL} $IFILE $OFILE"

  echo "$CDOCOMMAND"

  $CDOCOMMAND
  test $? -eq 0 || let RSTAT+=1

  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
  test $? -eq 0 || let RSTAT+=1
  test -s $CDOOUT && let RSTAT+=1
  cat $CDOOUT $CDOERR

#  let NTEST+=1
  rm -f $OFILE
done
#
test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
#
rm -f $CDOOUT $CDOERR
#
exit 0
