#! /bin/sh # JHMON_LAUNCH - It prepares the initial # directory structure, configures the model for the chosen ocean basin # and forecast center, and produces a few initial files. All later # jobs are dependent on this one. # # Dependencies: # GFS hour 6 forecast files available * # SDM has run the setup_hurricane script * # # Next job: depends on if coupled. # All basins: # JHMON_NPS_IC # JHMON_NPS_BC # JHMON_HYCOM_INIT1 (if coupled) # JHMON_HYCOM_INIT2 (if coupled) ######################################################################## # Setup shell: date export PS4='+ $SECONDS + ' set -xu #################################### # Set default values if not yet set # values from ecFlow or modules will override these #################################### export DATA=${DATA:-${DATAROOT:?}/hmon${storm_num:?}_${cyc:?}_${envir:?}} export cycle=${cycle:-t${cyc}z} export jlogfile=${DATA}/jlogfile #################################### # Initialize work area and cd there #################################### rm -rf "$DATA" mkdir -p "$DATA" cd $DATA #################################### # Variables for logging & DBnet #################################### export NET=hmon RUN=hmon #################################### # Set threading defaults #################################### export OMP_NUM_THREADS=1 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 #################################### # Set HMON-specific vars #################################### # Top of HMON installation tree: export HOMEhmon=${HOMEhmon:-${PACKAGEROOT:?}/hmon.${hmon_ver:?}} export USHhmon=$HOMEhmon/ush export EXhmon=$HOMEhmon/scripts export PARMhmon=$HOMEhmon/parm export FIXhmon=$HOMEhmon/fix export EXEChmon=$HOMEhmon/exec # Initialize PDY for future jobs: setpdy.sh # Get PDY . ./PDY # set up cycle export CYCLE=${PDY}${cyc} # Upstream and downstream areas: export stormlabel=${stormlabel:-storm$storm_num} export COMINarch=${COMINarch:-$(compath.py gfs/${gfs_ver})/syndat} export COMINmsg=${COMINmsg:-$(compath.py hwrf/${hwrf_ver}/inphmon)} export COMINgfs=${COMINgfs:-$(compath.py gfs/${gfs_ver})} export COMINgdas=${COMINgdas:-$(compath.py gfs/${gfs_ver})} # HMON areas: priorymdh=$( $NDATE -6 "$PDY$cyc" ) export HISTDATA=${HISTDATA:-$(compath.py $NET/${hmon_ver})/$RUN.$priorymdh} export COMIN=${COMIN:-$(compath.py $NET/${hmon_ver})/$RUN.$PDY$cyc} export COMOUT=${COMOUT:-$(compath.py -o $NET/${hmon_ver})/$RUN.$PDY$cyc} export COM=${COM:-${COMOUT}} mkdir -p $COMOUT # Prepend $USHhmon to python package search path: export PYTHONPATH=$USHhmon${PYTHONPATH:+:$PYTHONPATH} # Make sure all mandatory variables are set: PDY, cyc, storm_num set -u +x echo "Checking for mandatory variables:" echo "PDY=$PDY cyc=$cyc storm_num=$storm_num" set +u -x env #################################### # Set/check job-specific vars if any #################################### #################################### # 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-5 message=$( head -1 "$messagefile" ) # full message contents set -e # If nstorms file is missing, use message contents to decide: nstorms=${nstorms:-5} if [[ ! ( "$storm_num" -le "$nstorms" ) ]] ; then abort_reason="I am storm $storm_num but only $nstorms storms are requested." # ecflow_client -- event NoStorm 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 "$mYMDH $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 "$mYMDH $what: run $center storm" fi #if [[ "$basin1" == "L" ]]; then ## change for add ocean coupling for AL storms # ecflow_client -- label flag $uncouple, $HYCOM_INIT_1=NO, $HYCOM_INIT_2=NO, $HYCOM_POST=NO # ecflow_client --event run_noncouple if [[ "$basin1" == "L" || "$basin1" == "E" || "$basin1" == "C" ]]; then # ecflow_client -- lable flag $copule,$HYCOM_INIT_1=YES,$HYCOM_INIT_2=YES,$HYCOM_POST=YES ecflow_client --event run_couple else abort_reason="Warning:unexpected basin: $basin1" ecflow_client --label $stormlabel "$mYMDH $what: canceled: $abort_reason" ecflow_client --event NoStorm exit 0 # End processing here. fi #################################### # Run ex-script #################################### # Announce intent: postmsg "$jlogfile" "Starting exhmon_launch.py." # Launcher script needs extra args: $EXhmon/exhmon_launch.py $storm ${mYMDH} export err=$? # Announce success or failure err_chk if [[ "$err" != 0 ]] ; then postmsg "$jlogfile" "err_chk did not exit on err=$err -- exit 99" exit 99 fi postmsg "$jlogfile" "Ended normally."