#!/usr/bin/ksh

set +x
#####################################################################
echo "----------------------------------------------------------"
echo "gfdl_post_swath_wind.sh  "
echo "----------------------------------------------------------"
echo "History: MAY 2005 - First implementation of this new script."
#####################################################################
set -x

PS4=' + gfdl_post_swath_wind.sh line $LINENO: '

#####################################################################
# MAKE UNIQUE DIRECTORY FOR PROCESSING TO RUN IN
#####################################################################
mkdir ${DATA}/swath_wind
cd ${DATA}/swath_wind

$utilities/setup.sh

ih_check=` cat $COMIN/$ATCFNAME.ihours`
if [ ${ih_check} -lt 0 ]
then
  echo "  1" >tmphrs
  mv tmphrs $COMIN/$ATCFNAME.ihours
fi
     
echo $NMO       > nmo
echo $HRIN      > hrin
echo $DAY       > day
echo $STORMENV  > stormenv
echo ${Y4PREFIX}$YEARA   > yeara
cp ${COMIN}/coupled_status.${ATCFNAME}.${PDY}${cyc} .

export pgm=gfdl_swathps
. prep_step

ln -s -f coupled_status.${ATCFNAME}.${PDY}${cyc}    fort.2
ln -s -f $COMIN/$ATCFNAME.swath                     fort.9
ln -s -f $COMIN/$ATCFNAME.swathc                    fort.36
ln -s -f $COMIN/$stormenv.${PDY}${cyc}.sfcwind.asci fort.76
ln -s -f $COMIN/$stormenv.${PDY}${cyc}.900m.asci    fort.77
ln -s -f $COMIN/$ATCFNAME.ihours                    fort.78
ln -s -f nmo                                        fort.31
ln -s -f hrin                                       fort.32
ln -s -f day                                        fort.33
ln -s -f stormenv                                   fort.34
ln -s -f yeara                                      fort.35

startmsg
$EXEChur/gfdl_swathps >> $pgmout 2>errfile
export err=$?
if [ $err -ne 0 ] ; then
  postmsg "$jlogfile" "GFDL WIND SWATH PS FILE NOT AVAILABLE -- NON FATAL"
fi

if [ -e $COMIN/$stormenv.${PDY}${cyc}.sfcwind.asci ] ; then
  if [ $SENDDBN = 'YES' ] ; then
    $DBNROOT/bin/dbn_alert MODEL GFDL_ASCII $job $COMIN/$stormenv.${PDY}${cyc}.sfcwind.asci
  fi
else
  echo "FILE $COMIN/$stormenv.${PDY}${cyc}.sfcwind.asci DOES NOT EXIST"
fi
     
#################################################################
# The generated meta file and postscript version will be stored in
# /com region for NHC to ftp to their site.....>
#################################################################
if [ $SENDCOM = 'YES' ]
then
  cp gmeta $COMOUT/$stormenv.${YMDH}.swath.meta
  cp gmeta gmeta.wind
  ctrans -d ps.mono  gmeta   > psstorm
  mv psstorm $COMOUT/$stormenv.${YMDH}.swath.ps
fi




