#!/bin/ksh
######################################################
echo "-----------------------------------------------" 
echo "     exhwrf_prep_hybrid.sh.sms                 "
echo "   Hurricane model control script              "
echo "-----------------------------------------------" 
######################################################
set -x

PS4=' + exhwrf_prep_hybrid.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_prep_hybrid.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
#-------------------------------------------------------

cd $DATA
pwd 

# If the user did not specify which begin or end time to process,
# default to hours 0 and 126, respectively:
export FIRST_PREP=${FIRST_PREP:-0}
export LAST_PREP=${LAST_PREP:-21}

if ( ! ${USHhwrf}/hwrf_prep_hybrid.sh  ${STORM} ${yyyymmddhh}  ${CENLA} ${CENLO} \
    "$( seq $FIRST_PREP $LAST_PREP )" ) ; then
    set +x
    msg="hwrf_prep_hybrid.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 
