#/usr/bin/ksh
#
# Script to compare ROPP9.0 and ROPP9.1 versions of GNOS code.
# Third test: BUFR decoding/encoding.
#

ulimit -S -s unlimited

IFILE0=data/A_IUTA14BAWX160008_C_BAWX_20170616025049.bin

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

#if false ; then  #  bypass the control

EXEC_DIR=$ROPP_ROOT/ropp_src/branches/dev/Share/ROPP90_prototype/ropp_io/tools

TOOL=bufr2ropp  ;  EXEC=$EXEC_DIR/$TOOL

IFILE=$IFILE0

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

TFILE=$(echo $IFILE0 |sed -es/'.bin'/'_cntl1.out'/)

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

OFILE2=$(echo $OFILE |sed -es/'.nc'/'.nd'/)

ncdump  $OFILE > $OFILE2

TOOL=ropp2bufr  ;  EXEC=$EXEC_DIR/$TOOL

IFILE=$OFILE

OFILE3=$(echo $IFILE0 |sed -es/'.bin'/'_cntl1.bufr'/)

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

OFILE4=$(echo $OFILE3 |sed -es/'.bufr'/'.decbufr'/)

decbufr -d $OFILE3 > $OFILE4

#fi  #  bypass the control

#------------------------------------------------------
#1. Test: ROPP9.1/ic_gnos
#------------------------------------------------------

#if false ; then  #  bypass the test

#EXEC_DIR=$ROPP_ROOT/ropp_src/branches/dev/Share/ROPP91_prototype/ropp_pp/tools
EXEC_DIR=$ROPP_ROOT/ropp_src/branches/dev/Share/ic_gnos/ropp_io/tools

TOOL=bufr2ropp  ;  EXEC=$EXEC_DIR/$TOOL

IFILE=$IFILE0

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

TFILE=$(echo $IFILE0 |sed -es/'.bin'/'_test1.out'/)

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

OFILE2=$(echo $OFILE |sed -es/'.nc'/'.nd'/)

ncdump  $OFILE > $OFILE2

TOOL=ropp2bufr  ;  EXEC=$EXEC_DIR/$TOOL

IFILE=$OFILE

OFILE3=$(echo $IFILE0 |sed -es/'.bin'/'_test1.bufr'/)

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

OFILE4=$(echo $OFILE3 |sed -es/'.bufr'/'.decbufr'/)

decbufr -d $OFILE3 > $OFILE4

#fi  #  bypass the test
