#! /bin/sh
#########################################################################
# Usage: ofs_boxqcv.sh                                                  #
#                                                                       #
# Description: This script does qc of ctd data, construct records of    #
#              original data in 'box' format and creates z-profiles     #
#              from data and climatology.                               #
#                                                                       #
# History:                                                              #
#                                                                       #
#    06-16-2005  Dan Iredell                                            #
#########################################################################
set -x

echo "*** Started script $0"



echo 'platform is                      :' $platform
echo 'infile is                        :' $infile
echo 'outfile is                       :' $qc_outfile
echo 'ctd profile  is                  :' $ctdfile
echo 'file with number of obs in ctdfile is :' $numobsctdfile
echo 'climo_month is                   :' $climo_month
echo 'profiler is                      :' $profiler
echo 't0 is                            :' $t0

#1.b  create file boxinv.in to be read in std input

it0=`echo $t0 | cut -d. -f1`

rm -f boxinv.in
cat>boxinv.in <<EOF
${platform}
${profiler}
${IDM}  ${JDM}  ${it0}      NCEP 1/12 ${climo_month} 2006
EOF

#2     filter data

echo 	 Running boxinv for $platform $profiler $cdate
echo ${gridlabel} '   ' ${IDM} ${JDM} '   ' ${climo_month}

export pgm=ofs_boxinv
. prep_step

export XLFRTEOPTS="unit_vars=yes"
export XLFUNIT_10=$infile
export XLFUNIT_12=${PARMofs}/${RUN}_${modID}.platform.dat
export XLFUNIT_71=${FIXofs}/${RUN}_${modID}.${gridlabel}depth.dat
export XLFUNIT_72=${FIXofs}/${RUN}_${modID}.${gridlabel}mask.dat
export XLFUNIT_73=${FIXofs}/${RUN}_${modID}.${gridlabel}grid.dat
export XLFUNIT_74=${FIXofs}/${RUN}_${modID}.${gridlabel}meanTEM${climo_month}.bin
export XLFUNIT_75=${FIXofs}/${RUN}_${modID}.${gridlabel}sdevTEM${climo_month}.bin
export XLFUNIT_76=${FIXofs}/${RUN}_${modID}.Atlantic.dat
export XLFUNIT_77=${FIXofs}/${RUN}_${modID}.${gridlabel}meanSAL${climo_month}.bin
export XLFUNIT_78=${FIXofs}/${RUN}_${modID}.${gridlabel}sdevSAL${climo_month}.bin
export XLFUNIT_80=$qc_outfile
export XLFUNIT_91=$ctdfile
export XLFUNIT_92=$numobsctdfile

startmsg
$EXECofs/ofs_boxinv < boxinv.in >> $pgmout 2> errfile
export err=$?; err_chk

echo "*** Finished script $0"

