#! /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}} @** if JJOBNAME!=CLEANUP 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 #################################### @** if JJOBNAME==RELOCATE export OMP_NUM_THREADS=24 export PURE_OPENMP_THREADS=24 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** elseif JJOBNAME==MERGE export OMP_NUM_THREADS=24 export PURE_OPENMP_THREADS=24 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** elseif JJOBNAME==HYCOM_POST export OMP_NUM_THREADS=24 export PURE_OPENMP_THREADS=24 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** elseif JJOBNAME==ENSDA export OMP_NUM_THREADS=24 export PURE_OPENMP_THREADS=24 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** elseif JJOBNAME==ENSDA_RELOCATE export OMP_NUM_THREADS=24 export PURE_OPENMP_THREADS=24 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** elseif JJOBNAME==INIT export OMP_NUM_THREADS=24 export PURE_OPENMP_THREADS=24 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** else export OMP_NUM_THREADS=1 export OMP_STACKSIZE=128M export MKL_NUM_THREADS=1 @** endif #################################### # 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 @** if JJOBNAME==LAUNCH # Initialize PDY for future jobs: setpdy.sh @** endif # Get PDY . ./PDY # Upstream and downstream areas: export stormlabel=${stormlabel:-storm$storm_num} @** if JJOBNAME!=BUFRDUMP 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)} @** endif @** if JJOBNAME==OUTPUT export COMOUTatcf=${COMOUTatcf:-$(compath.py nhc/$envir/atcf)} export COMOUTgltrk=${COMOUTgltrk:-$(compath.py hur/$envir/global)} @** elseif JJOBNAME==PRODUCTS export COMOUTatcf=${COMOUTatcf:-$(compath.py nhc/$envir/atcf)} export COMOUTgltrk=${COMOUTgltrk:-$(compath.py hur/$envir/global)} @** elseif JJOBNAME==WAVE_POST export COMOUTatcf=${COMOUTatcf:-$(compath.py nhc/$envir/atcf)} export COMOUTgltrk=${COMOUTgltrk:-$(compath.py hur/$envir/global)} @** elseif JJOBNAME==WAVE_INIT export COMINwave=${COMINwave:-$(compath.py ${envir}/gfs/${gfs_ver})/gfs.$PDY/$cyc/wave} @** endif # 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} @** if JJOBNAME!=LAUNCH # Point to stormX.conf generated by launcher job: export CONFhwrf=$COMIN/storm$storm_num.conf @** endif # 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 #################################### @** if JJOBNAME==GSI script=gsi set -u +x echo "GSI_DOMAIN=$GSI_DOMAIN" if [[ "$GSI_DOMAIN" != d02 && "$GSI_DOMAIN" != d03 ]] ; then echo "Wrong GSI_DOMAIN value; must be d02 or d03" exit 99 fi set -u -x @** elseif JJOBNAME==ENSDA set +u echo "ENSDA member is $ENSDA_MEMB" # ensure this variable is set set -u @** elseif JJOBNAME==INIT set +u echo "Checking mandatory init job variables:" echo "INIT_MODEL=$INIT_MODEL" echo "INIT_FHR=$INIT_FHR" echo "INIT_PARTS=$INIT_PARTS" set -u @** elseif JJOBNAME==RELOCATE set +u echo "Checking mandatory relocate job variables:" echo "INIT_MODEL=$INIT_MODEL" echo "INIT_FHR=$INIT_FHR" set -u @** endif #################################### # Ensure aprun works #################################### #aprun -n 1 -d 1 -j 1 -N 1 /bin/echo Aprun Test @** endif @** if JJOBNAME==LAUNCH #################################### # 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_@[EXNAME].py." $EXhwrf/exhwrf_@[EXNAME].py "$PDY$cyc" "$storm" FORECAST $PARMhwrf $configmore export err=$? err_chk postmsg "$jlogfile" "exhwrf_@[EXNAME].py ended normally." @** elseif JJOBNAME==CLEANUP postmsg "$jlogfile" "Cleaning up $DATA" rm -rf $DATA postmsg "$jlogfile" "Cleanup of $DATA complete" @** elseif JJOBNAME==BUFRDUMP dcom="$DCOMROOT" tank1="$dcom/$PDYm1/b006/xx070" tank2="$dcom/$PDY/b006/xx070" if [[ -s $tank1 || -s $tank2 ]] ; then postmsg "$jlogfile" "Dumping TDR data from tank." export TANK="$dcom" set -u /nwprod/ush/dumpjb "$PDY$cyc" 3.00 tldplr export err=$? err_chk postmsg "$jlogfile" "TDR dump complete." else postmsg "$jlogfile" "No TDR data in tank." fi exit 0 @** else #################################### # Pass control to ex-script #################################### @** if JJOBNAME==FORECAST echo "$FORECAST_CONF_OVERRIDE" > "$COMOUT/storm$storm_num.forecast_override" postmsg "$jlogfile" "Starting exhwrf_forecast.py $FORECAST_CONF_OVERRIDE" $EXhwrf/exhwrf_@[EXNAME].py $FORECAST_CONF_OVERRIDE @** elseif JJOBNAME==PRODUCTS forecast_override_file="$COMOUT/storm$storm_num.forecast_override" FORECAST_CONF_OVERRIDE=" " if [[ -s "$forecast_override_file" ]] ; then FORECAST_CONF_OVERRIDE=$( head -1 "$forecast_override_file" ) fi postmsg "$jlogfile" "Starting exhwrf_@[EXNAME].py $FORECAST_CONF_OVERRIDE" $EXhwrf/exhwrf_@[EXNAME].py $FORECAST_CONF_OVERRIDE @** elseif JJOBNAME==OUTPUT forecast_override_file="$COMOUT/storm$storm_num.forecast_override" FORECAST_CONF_OVERRIDE=" " if [[ -s "$forecast_override_file" ]] ; then FORECAST_CONF_OVERRIDE=$( head -1 "$forecast_override_file" ) fi postmsg "$jlogfile" "Starting exhwrf_@[EXNAME].py $FORECAST_CONF_OVERRIDE" $EXhwrf/exhwrf_@[EXNAME].py $FORECAST_CONF_OVERRIDE @** else postmsg "$jlogfile" "Starting exhwrf_@[EXNAME].py." $EXhwrf/exhwrf_@[EXNAME].py @** endif export err=$? err_chk postmsg "$jlogfile" "exhwrf_@[EXNAME].py ended normally." @** endif