#/usr/bin/ksh
#
# Script to test some anomalous unit conversion problems in ROPP9.1 - see
# https://trac.romsaf.org/ropp/ticket/524
#

ulimit -S -s unlimited

IFILE0=data/MT-IO-02.nc
IFILE1=data/MT-IO-02.3.nc
#IFILE1=data/MT-IO-02.3a.nc

#var=lat
#var=lat_tp
#var=lon
#var=lon_tp
#var=azimuth
var=azimuth_tp

#------------------------------------------------------
#0. Cntl: ROPP9.1
#------------------------------------------------------

#if false ; then  #  bypass the control

EXEC=$ROPP_ROOT/ropp_src/branches/dev/Share/ROPP91_prototype/ropp_io/tools/ropp2ropp

OFILE=$(echo $IFILE0 |sed -es/'.nc'/'_cntl1.nc'/)

TFILE=$(echo $IFILE0 |sed -es/'.nc'/'_cntl1.out'/)  ;  rm -f $TFILE

IFILE=$IFILE0
banner $IFILE  >> $TFILE 2>&1
echo "ncdump -h $IFILE |grep ${var}:  >> $TFILE 2>&1"
      ncdump -h $IFILE |grep ${var}:  >> $TFILE 2>&1
echo "ncks -H -Q -v$var -ddim_lev1b,0 $IFILE  >> $TFILE 2>&1"
      ncks -H -Q -v$var -ddim_lev1b,0 $IFILE  >> $TFILE 2>&1

IFILE=$IFILE1
banner $IFILE  >> $TFILE 2>&1
echo "ncdump -h $IFILE |grep ${var}\:  >> $TFILE 2>&1"
      ncdump -h $IFILE |grep ${var}\:  >> $TFILE 2>&1
echo "ncks -H -Q -v$var -ddim_lev1b,0 $IFILE  >> $TFILE 2>&1"
      ncks -H -Q -v$var -ddim_lev1b,0 $IFILE  >> $TFILE 2>&1

echo "$EXEC  $IFILE  -m  -o $OFILE  -d  >> $TFILE 2>&1"
      $EXEC  $IFILE  -m  -o $OFILE  -d  >> $TFILE 2>&1

IFILE=$OFILE
banner $IFILE  >> $TFILE 2>&1
echo "ncdump -h $IFILE |grep ${var}\:  >> $TFILE 2>&1"
      ncdump -h $IFILE |grep ${var}\:  >> $TFILE 2>&1
echo "ncks -H -Q -v$var -ddim_lev1b,0 $IFILE  >> $TFILE 2>&1"
      ncks -H -Q -v$var -ddim_lev1b,0 $IFILE  >> $TFILE 2>&1

#fi  #  bypass the control

#------------------------------------------------------
#1. Test: ROPP9.1
#------------------------------------------------------

if false ; then  #  bypass the test
echo " " 
fi  #  bypass the test
