#! /bin/sh date export PS4=' $SECONDS + ' set -xue #################################### # Set default values if not yet set # values from ecFlow or modules will override these #################################### export DATA=${DATA:-${DATAROOT:?}/hwrf${storm_num:?}_${cyc:?}_${envir:?}} export jlogfile=${jlogfile:-${DATA}/jlogfile.${jobid}} export cycle=${cycle:-t${cyc}z} #################################### # Initialize work area and cd there #################################### mkdir -p $DATA cd $DATA #################################### # Set HWRF version number if unset #################################### export HWRF_VERSION=${HWRF_VERSION:-${hwrf_ver/v/}} #################################### # Variables for logging & DBnet #################################### export NET=hwrf RUN=hwrf export EMAIL_SDM=${EMAIL_SDM:-YES} #################################### # Set threading defaults #################################### export OMP_NUM_THREADS=1 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 #################################### # Set HWRF-specific vars #################################### # Top of HWRF installation tree: export HOMEhwrf=${HOMEhwrf:-${OPSROOT:?}/hwrf.$hwrf_ver} # source $HOMEhwrf/versions/run.ver # Do not source the holdvars for the launch job since the holdvars # does not exist yet! # We do need to set these variables that holdvars normally sets: export USHhwrf=$HOMEhwrf/ush export EXhwrf=$HOMEhwrf/scripts export PARMhwrf=$HOMEhwrf/parm # Initialize PDY for future jobs: setpdy.sh # Get PDY . ./PDY # Upstream and downstream areas: export stormlabel=${stormlabel:-storm$storm_num} COMROOTnhc=${COMROOTnhc:-${COMROOT/nhc}} export COMINnhc=${COMINnhc:-${COMROOTnhc:?}/storm-data/ncep} export COMINobs=${COMINobs:-$(compath.py ${envir}/obsproc/${obsproc_ver})} export COMINgfs=${COMINgfs:-$(compath.py ${envir}/gfs/${gfs_ver})} export COMINgdas=${COMINgdas:-$(compath.py ${envir}/gfs/${gfs_ver})} export COMINarch=${COMINarch:-$(compath.py ${envir}/gfs/${gfs_ver})/syndat} export COMINrtofs=${COMINrtofs:-$(compath.py ${envir}/rtofs/$rtofs_ver)} export COMINmsg=${COMINmsg:-$(compath.py ${COMROOT}/${NET}/inphwrf)} # HWRF areas: priorymdh=$( $NDATE -6 "$PDY$cyc" ) pre_YMD=`echo $priorymdh |cut -c1-8` pre_H=`echo $priorymdh |cut -c9-10` export HISTDATA=${HISTDATA:-$(compath.py ${envir}/${NET}/${hwrf_ver})/$RUN.$pre_YMD/$pre_H} export COMIN=${COMIN:-$(compath.py ${envir}/${NET}/${hwrf_ver})/$RUN.$PDY/$cyc} export COMOUT=${COMOUT:-$(compath.py ${envir}/${NET}/${hwrf_ver})/$RUN.$PDY/$cyc} # Prepend $USHhwrf to python package search path: export PYTHONPATH=$USHhwrf${PYTHONPATH:+:$PYTHONPATH} # Make sure all mandatory variables are set: cyc, storm_num set -u +x echo "Checking for mandatory variables:" echo "cyc=$cyc storm_num=$storm_num" set +u -x #################################### # Set/check job-specific vars if any #################################### #################################### # Ensure aprun works #################################### #aprun -n 1 -d 1 -j 1 -N 1 /bin/echo Aprun Test #################################### # Decide whether this storm runs #################################### abort_reason="" # if non-empty, storm does not run what="message$storm_num" # what storm is being run or aborted? messagefile=$COMINmsg/message$storm_num set +e # to ensure later "if" handles empty files nstorms=$( head -1 $COMINmsg/nstorms ) # number of storms: 0-7 message=$( head -1 "$messagefile" ) # full message contents set -e # If nstorms file is missing, use message contents to decide: nstorms=${nstorms:-7} if [[ ! ( "$storm_num" -le "$nstorms" ) ]] ; then abort_reason="I am storm $storm_num but only $nstorms storms are requested." elif [[ -z "$message" ]] ; then abort_reason="Message file empty or missing: $messagefile" else #000000000011111111112222222222333333333344444444445555555555 #012345678901234567890123456789012345678901234567890123456789 #JTWC 91B INVEST 160515 1200 072N 0821E 300 021 1004 1008 ... center=$( echo ${message:0:4} ) # echo strips the trailing space in "NHC " storm=${message:5:3} # 93L basin1=${message:7:1} # L name=$( echo ${message:9:9} ) mYMDH=${PDY:0:2}${message:19:6}${message:26:2} # 2015110418 what="$storm $name" if [[ "$mYMDH" != "$PDY$cyc" ]] ; then abort_reason="Message file cycle $mYMDH is not current cycle $PDY$cyc." fi fi if [[ -n "$abort_reason" ]] ; then ecflow_client --label $stormlabel "$what: canceled: $abort_reason" ecflow_client --event NoStorm exit 0 # End processing here. # Note: no "--complete recursive" because of new complete expressions in def else ecflow_client --label $stormlabel "$what: run $center storm" fi #################################### # Set extra config options here #################################### # NOTE: None needed yet. configmore=" ${HWRF_LAUNCH_EXTRA_CONFIG:-}" env #################################### # Pass control to ex-script #################################### postmsg "$jlogfile" "Starting exhwrf_launch.py." $EXhwrf/exhwrf_launch.py "$PDY$cyc" "$storm" FORECAST $PARMhwrf $configmore export err=$? err_chk postmsg "$jlogfile" "exhwrf_launch.py ended normally."