#!/bin/ksh
######################################################
echo "-----------------------------------------------" 
echo "     exhwrf_nmm_real.sh.sms                  "
echo "   Hurricane model control script              "
echo "-----------------------------------------------" 

# NOTE: OPTIONAL ENVIRONMENT VARIABLE $FORECAST_LENGTH SPECIFIES THE
# LENGTH OF THE FORECAST IN HOURS, WHICH MUST BE A MULTIPLE OF 6.
# IF $FORECAST_LENGTH IS UNSPECIFIED, 126 IS ASSUMED.

######################################################
set -x

PS4=' + exhwrf_nmm_real.sh.sms line $LINENO: ' 

#-----------------------------------------------------
# Be sure that there is a holdvars.txt file, and source 
# it because it contains needed environmental variables 
# from the JHWRF_PRE_MASTER job that need to be passed 
# into this script
#----------------------------------------------------- 
sh ${utilscript}/setup.sh
export pgm=exhwrf_nmm_real.sh.sms
. prep_step
startmsg

if test -f ${COMOUT}/${stormlabel}.holdvars.txt
then
   . ${COMOUT}/${stormlabel}.holdvars.txt
else
   set +x
   echo " "
   echo "!!! ERROR: holdvars.txt file missing"
   echo " "
   set -x
   msg="Hurricane to Run But No ${stormlabel}.holdvars.txt file found."
   postmsg "$jlogfile" "$msg"
   export err=911;err_chk
   err_exit "Hurricane to Run But No ${stormlabel}.holdvars.txt file found."
fi
#-------------------------------------------------------

export IO_SERVERS=NO

cd $DATA
pwd 

if ( ! ${USHhwrf}/hwrf_nmm_real.sh        $STORM $YYYY $MM $DD $CYC  $FORECAST_LENGTH ) ; then
    set +x
    msg="hwrf_nmm_real.sh returned non-zero exit status.  Assuming a failure.  ABORTING."
    postmsg "$jlogfile" "$msg"
    export err=911;err_chk
    err_exit "$msg"
fi

# end of script 
