#!/bin/ksh

##################################################################################
#  UTILITY SCRIPT NAME :  exhiresw_awips.sh.sms 
#         DATE WRITTEN :  April 08, 2008
#
#  Abstract:  This utility script produces the Hiresw for AWIPS
#
#  History: April 8, 2008 - Original script from Boi Vuong at NCO
#
##################################################################################

set -x

cd $DATA

msg="Hiresw post-processing for AWIPS has begun on `hostname` at `date`"
postmsg "$jlogfile" "$msg"
startmsg

for fhr in 00 03 06 09 12 15 18 21 24 27 30 33 36 39 42 45 48 ;
do
    export XLFRTEOPTS="unit_vars=yes"     # Allow overriding default names.

    export XLFUNIT_11=$COMIN/${RUN}.t${cyc}z.awpreg${fhr}.tm00.grib2
    export XLFUNIT_31=""
    export XLFUNIT_51=grib2.t${cyc}z.awpreg_${RUN}f${fhr}
    $utilexec/tocgrib2 < $PARMutil/grib2_${NEST}_hiresw.awpreg_f${fhr}

    ##############################
    # Post Files to PCOM
    ##############################

    if [ $SENDCOM = "YES" ] ; then
       cp  grib2.t${cyc}z.awpreg_${RUN}f${fhr}  $pcom
    fi

    ##############################
    # Distribute Data TO NTC
    ##############################

    if [ $SENDDBN = "YES" ] ; then
       $DBNROOT/bin/dbn_alert NTC_LOW NAM_${DBN_NEST}_AWIP_GB2 $job $pcom/grib2.t${cyc}z.awpreg_${RUN}f${fhr}
    else
       msg="File $output_grb.$job not posted to db_net."
       postmsg "$jlogfile" "$msg"
    fi

done

#####################################################################
# GOOD RUN
set +x
echo "**************JOB $job COMPLETED NORMALLY on `hostname` at `date`"
echo "**************JOB $job COMPLETED NORMALLY on `hostname` at `date`"
echo "**************JOB $job COMPLETED NORMALLY on `hostname` at `date`"
set -x
#####################################################################
