#!/bin/sh
####################################################################
echo "------------------------------------------------"
echo "This Script generates GDAS Fax Charts"
echo "------------------------------------------------"
echo "History: MAR 1997 - First implementation of this new script."
echo "REVISED: Wed 01/29/98 - Replaced dbn_alert with snd2forgn "
echo "                      - in step AFWAVPLT."
echo "REVISED: Tue 02/02/99 - Adding job step NHWAVPLT.  Output"
echo "                        from this is converted to AWIPS."
echo "                        Output from AFWAVPLT is only sent"
echo "                        to AFOS now."
echo "  15 FEB 2000 - Converted to IBM from Cray jobs 835 and 838."
echo "        OCT  2004     - Convert to CCS Phase II "
#####################################################################

cd $DATA

#####################################################
# START FLOW OF CONTROL
# 1) Execute FAXMAKR - MAPS for NORTH HEMIS.
# 3) Execute FAXMAKR - Fax/Varian Maps for GF12NHFX
#####################################################

set -x
msg="HAS BEGUN!"
postmsg "$jlogfile" "$msg"

if [ $cycle = "t00z" -o $cycle = "t12z" ]
then
#########################################################################
# Part 1)  Execute UPAPREP, PLOTVPAP and FAXMAKR for NORTHERN HEMISPHERE
#########################################################################
#1) Run plotvpap.sh to generate the PlotVpap Tape 55:
    plottype=ft15
    plotparm=""
    region="nh"

    sh $USHutil/plotvpap.sh "$plottype" "$plotparm" "$region"

#2) Execute FAXMAKR - GANLNHFX
    
    FAXOUT=fax.ganlnhfx.$job
    FAXPARM=graph_ganlnhfx.${model}_$cycle
    SENDKEY=fax.ganlnhfx
    PLOTTAPE=OLDlabel55
    sh $USHutil/mkfax.sh "00" $FAXPARM $FAXOUT $SENDKEY $PLOTTAPE
 
fi

if [ $cycle = "t06z" -o $cycle = "t18z" ]
then
#########################################################################
# Part 3)  Execute FAXMAKR produce FAX/VARIAN maps for GF12NHFX
#########################################################################

    FAXPARM=graph_gf12nhfx.${model}_$cycle
    FAXOUT=fax.gf12nhfx.$job
    SENDKEY=fax.gf12nhfx
    sh $USHutil/mkfax.sh "06" $FAXPARM $FAXOUT $SENDKEY

fi
#####################################################################
# GOOD RUN
set +x
echo "**************JOB $job COMPLETED NORMALLY ON THE IBM"
echo "**************JOB $job COMPLETED NORMALLY ON THE IBM"
echo "**************JOB $job COMPLETED NORMALLY ON THE IBM"
set -x
#####################################################################

msg="HAS COMPLETED NORMALLY!"
echo $msg
postmsg "$jlogfile" "$msg"

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