
######################################################################
#  UTILITY SCRIPT NAME :  exnam_bull.sh.sm
#         DATE WRITTEN :  10/06/2004
#
#  Abstract:  This utility script produces the NAM AWIPS GRIB
#
#     Input:  1 arguments are passed to this script.
#             1st argument - Forecast Hour - format of 2I
#
#####################################################################

#####################################################################
echo "------------------------------------------------"
echo "EXNAM_BULL - NAM BULLETINS post processing"
echo "------------------------------------------------"
echo "History: Oct 2004 - First implementation of this new script."
echo "         "
#####################################################################

set -x

export hour=$1

msg="Begin job for $job"
postmsg "$jlogfile" "$msg"

cd $DATA

export comrun=$COMIN/nam.$cycle

if test $hour -eq 84
then

set +x
echo " "
echo " #################################################"
echo "    Execute tracker to generate objective track"
echo "    of tropical cyclones within NAM GRIB output"
echo " #################################################"
echo " "
set -x
  
export cmodel=nam
export trkrscript=/nwprod/util/ush
sh $trkrscript/extrkr.sh

else

set +x
echo " "
echo "#############################################################"
echo "           Process FOUS BULLETINS (NAM32TX) Processing                 "
echo "#############################################################"
echo " "
set -x

if test "$cycle" = "t00z" -o "$cycle" = "t12z"
then
  fhour='00 03 06 09 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60'
else
  fhour='00 03 06 09 12 15 18 21 24 27 30 33 36 39 42 45 48'
fi

echo $cycle > run.cycle

export pgm=nam32tx;. prep_step

xlf=11
xlfi=41
for fhr in $fhour
  do
     cp $comrun.awip32${fhr}.tm00 awip32${fhr}.tm00
     cp $comrun.awip32i${fhr} awip32i${fhr}
     export XLFUNIT_${xlf}="awip32${fhr}.tm00"
     export XLFUNIT_${xlfi}="awip32i${fhr}"
     let xlf=xlf+1
     let xlfi=xlfi+1
  done
#
#   1280 byte transmission file
#

export XLFUNIT_71="tran.nam32tx"

#  The nam.table is generated by request in a checkout run.  It
#  contains the nam model terrain height and normal surface pressure
#  at the nam station locations.
#
#  export XLFUNIT_60="nam32.table"
#

msg="$pgm start"
postmsg "$jlogfile" "$msg"

$EXECutil/nam32tx < run.cycle
err=$?;export err;err_chk

if test "$SENDCOM" = 'YES'
then
    cp tran.nam32tx $pcom/tran.nam32tx.$job
    if test "$SENDDBN" = 'YES'
    then
       $utilities/make_ntc_bull.pl  WMOBH NONE KWNO NONE tran.nam32tx $pcom/tran.nam32tx.$job
    fi
fi

fi
 
#####################################################################
# GOOD RUN
set +x
echo "**************EXNAM_BULL COMPLETED NORMALLY ON THE IBM"
echo "**************EXNAM_BULL COMPLETED NORMALLY ON THE IBM"
echo "**************EXNAM_BULL COMPLETED NORMALLY ON THE IBM"
set -x
#####################################################################
cat break
cat $pgmout
ls -l

#####################################################################

msg='Job completed normally.'
echo $msg
postmsg "$jlogfile" "$msg"

############################### END OF SCRIPT #######################
