#/usr/bin/ksh
#
# Script to test effect of allowing FY3C data in
# ropp_io/bufr/roppbufrcodes.nl and ropp_io/bufr/convertcodes.f90.
# Ref #377.
#
# IDC, 28/7/2014.
#

IFILE0=ropp_test.nc

cp /data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ROPP80_prototype/ropp_io/data/$IFILE0 .

#  Make this appear to come from FY3C.

ncatted -h -ainstitution,global,o,c,"CMA" $IFILE0
ncdump -h $IFILE0 |grep institution


ncatted -h -aprocessing_centre,global,o,c,"CMA" $IFILE0
ncdump -h $IFILE0 |grep processing_centre


ncap2 -h -s 'gns_id(:,0:3)="B027";leo_id(:,0:3)="FY3C"' $IFILE0 -O temp.nc
mv temp.nc $IFILE0
ncks -H -vgns_id,leo_id $IFILE0


# -------------------
# Cntl: ROPP6.1 ifort
# -------------------

NLFILE=roppbufrcodes_old.nl

cp $NLFILE /data/nwp1/idculv/ROPP/data/bufr/roppbufrcodes.nl

TOOL=ropp_io/tools/ropp2bufr

EXEC=/data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ROPP61_prototype/$TOOL

IFILE=$IFILE0

OFILE=`echo $IFILE |sed -es/'.nc'/'_cntl.bufr'/`
TFILE=`echo $IFILE |sed -es/'.nc'/'_cntl.out'/`

echo "$EXEC  $IFILE  -o $OFILE  -d"
echo "$EXEC  $IFILE  -o $OFILE  -d"  > $TFILE
      $EXEC  $IFILE  -o $OFILE  -d  >> $TFILE


$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "Originating Centre" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "SATELLITE IDENTIFIER" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "SATELLITE INSTRUMENTS" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "IDENTIFICATION OF ORIGINATING/GENERATING CENTRE" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "SATELLITE CLASSIFICATION" >> $TFILE




# --------------
# Test1: ROPP8.0
# --------------

NLFILE=roppbufrcodes_new.nl
#NLFILE=roppbufrcodes_old.nl

cp $NLFILE /data/nwp1/idculv/ROPP/data/bufr/roppbufrcodes.nl

TOOL=ropp_io/tools/ropp2bufr

EXEC=/data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ROPP80_prototype/$TOOL

IFILE=$IFILE0

OFILE=`echo $IFILE |sed -es/'.nc'/'_test.bufr'/`
TFILE=`echo $IFILE |sed -es/'.nc'/'_test.out'/`

echo "$EXEC  $IFILE  -o $OFILE  -d"
echo "$EXEC  $IFILE  -o $OFILE  -d"  > $TFILE
      $EXEC  $IFILE  -o $OFILE  -d  >> $TFILE


$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "Originating Centre" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "SATELLITE IDENTIFIER" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "SATELLITE INSTRUMENTS" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "IDENTIFICATION OF ORIGINATING/GENERATING CENTRE" >> $TFILE
$ROPP_ROOT/ifort/bin/decbufr -d $OFILE |grep "SATELLITE CLASSIFICATION" >> $TFILE
