#!/bin/sh #========================================================================= # # DESCRIPTION: This unix korn shell script creates a POE script to create # the NHC tropical cyclone wind speed probabilities for # on-demand cases from NHC's hurricane specialist unit # # HISTORY: 03/08/12 J. Gross, created from awips_wind.sh # 04/07/27 J. Gross, adding POE processing to awips_prblty.sh # 01/17/07 C.Lauer, port to mist # 11/14/2012 A. Krautkramer, fix error with nslookup # 12/31/2012 A. Krautkramer, Transfer to WCOSS # Fix tocgrib2 call my changing XLFUNIT_ env vars to FORT # 04/12/2013 M. Sardi, Converted LoadLever to LSF syntax; Updated # 'is this production' test logic for WCOSS. # # 05/30/2013 M. DeMaria, grads turned on, but DBNET off. # prob_single_storm.x routine modified to fix # e-deck reader and update mc_prob routine to 2013 # version. dataio and related routines used by # prob_single_storm.x also updated. # 06/20/2013 M. Sardi, Corrected several WCOSS vs. CCS syntax # variances, including 'gawk' command; moved prod # vs. dev check to lsf_windprob.sh driver script. # 08/21/2013 S. Earle, Modified scripts to comply with production # implementation standards. # 10/15/2021 S. Stevenson, modified for WCOSS2 transition # 04/29/2024 M. Onderlinde, updated for on-demand runs #============================================================================== date export PS4=' $SECONDS + ' set -xa #################################### ## Specify NET and RUN Name and model ##################################### export NET=${NET:-wsp} export RUN=${RUN:-wsp} #################################### # obtain unique process id (pid) and make temp directory #################################### export DATA=${DATA:-${DATAROOT:?}/${jobid:?}} mkdir $DATA cd $DATA #################################### # Determine Job Output Name on System #################################### export pgmout="OUTPUT.$$" #export cyc=${cyc:-$(printf "%02d" $(bc <<< "$(date +%H/2*2)"))} #################################### # SENDECF - Flag Events on ECF # SENDCOM - Copy Files From TMPDIR to $COMOUT # SENDDBN - Issue DBNet Client Calls # SENDRZDM - Send output to ncorzdm #################################### export KEEPDATA=${KEEPDATA:-NO} export SENDECF=${SENDECF:-YES} export SENDCOM=${SENDCOM:-YES} export SENDDBN=${SENDDBN:-YES} export SENDDBN_NTC=${SENDDBN_NTC:-YES} export SENDRZDM=${SENDRZDM:-YES} export RZDMENVIR=${RZDMENVIR:-$envir} export ALERT_TYPE=${ALERT_TYPE:-} #################################### # Specify Execution Areas #################################### export EXECwsp=${EXECwsp:-$HOMEwsp/exec} export USHwsp=${USHwsp:-$HOMEwsp/ush} export SCRIPTwsp=${SCRIPTwsp:-$HOMEwsp/scripts} export FIXwsp=${FIXwsp:-$HOMEwsp/fix} export PARMwsp=${PARMwsp:-$HOMEwsp/parm} export UTILwsp=${UTILwsp:-$HOMEwsp/util} ######################################################################################## # CHECK FOR ON-DEMAND TRIGGER FILE # # Sample wspTrigger.go.202408290613 single-line file contents: al092024 202408290613 # ######################################################################################## export NHCINROOT=${NHCINROOT:-${DCOMROOT?}/nhc/atcf} export NHCIN=${NHCIN:-${NHCINROOT}/zfst} export TRIGGER_DIRECTORY=${TRIGGER_DIRECTORY:-${NHCIN}/ondemand} corruptfile=0 newfile=0 runid=NaN cyc=00 triggerfile=${TRIGGER_DIRECTORY}/$(ls -Art $TRIGGER_DIRECTORY | tail -n 1 | grep wsptrigger.go) if [[ -f $triggerfile ]]; then runid=$(cat $triggerfile) echo "found runid=$runid" export tcid=$( cut -f 1 -d " " ${triggerfile} ) export PDYcyc=$( cut -f 2 -d " " ${triggerfile} ) if [[ $tcid != '' ]]; then echo "tcid = $tcid is found continue" fstfile=${NHCIN}/${tcid}.fst echo "fstfile=$fstfile" else echo "WARNING: file looks corrupt, tcid" corruptfile=1 fi if [[ ${#PDYcyc} -eq 10 ]]; then echo "PDYcyc = $PDYcyc is found continue" export cyc=${PDYcyc:(-2)} if [[ ${cyc} == "00" || ${cyc} == "06" || ${cyc} == "12" || ${cyc} == "18" ]]; then echo "Found a cyc that is in 06 hour intervals with cyc=$cyc" else echo "WARNING cyc=$cyc is not in 00,06,12,18 ignoring the file" corruptfile=1 cyc=00 fi export PDY=${PDY:-${PDYcyc::8}} export cycle=t${cyc}z else echo "WARNING: file looks corrupt, PDY" corruptfile=1 fi if [[ $last_runid != $runid && $corruptfile == 0 ]];then newfile=1 fi else echo "WARNING : file does not exist at $triggerfile" export cyc=00 export cycle=t${cyc}z corruptfile=1 fi if [[ "$newfile" == 1 ]]; then if [[ -s $fstfile ]]; then echo "Found the fst file at $fstfile" if grep -q $PDYcyc $fstfile; then echo "Found the fstfile with correct PDY" else echo "WARNING: fstfile is old and does not contain PDYcyc=$PDYcyc, ignoring ondemand trigger" newfile=0 fi else echo "WARNING: missing fst file at $fstfile" fi fi ############################## # Run setpdy and initialize PDY variables ############################## setpdy.sh . ./PDY ############################################## # Define COM directories ############################################## export COMIN=${COMIN:-$(compath.py -v ${envir}/${NET}/${wsp_ver})/${RUN}.${PDY}} export COMOUT=${COMOUT:-$(compath.py -v -o ${NET}/${wsp_ver}/${RUN}.${PDY})} export PCOM=${PCOM:-${COMOUT?}/wmo} ###--- Set para test flags if [ "$PARATEST" == "YES" ] || [ "${EVAL}" == "YES" ];then echo "Parallel Production Test is Running Changing rzdmenvir to para" export RZDMENVIR=para else echo "Parallel Production Test is Not Running and rzdmenvir is set to $RZDMENVIR" fi mkdir -p -m 775 ${COMOUT} ${PCOM} env ################################################### # Execute the Script ################################################### if [[ ${newfile} == 1 && ${corruptfile} == 0 ]];then label_msg="Processing : $last_runid" ecflow_client --label=info $label_msg ${SCRIPTwsp}/exnhc_windprob.sh export err=$?; err_chk last_runid=$runid ecflow_client --alter=add variable LAST_RUNID "$last_runid" $ecf_name ecflow_client --alter=change variable LAST_RUNID "$last_runid" $ecf_name ecflow_client --alter=add variable LAST_OUTPUT "$pgmout" $ecf_name ecflow_client --alter=change variable LAST_OUTPUT "$pgmout" $ecf_name label_msg="Last ondemand processed: $last_runid" ecflow_client --label=info "$label_msg" else echo "No new ondemand file was found, not going to run exnhc_windprob.sh" label_msg="Last ondemand processed: $last_runid" ecflow_client --label=info "$label_msg" fi ################################################## postmsg "${pgmout}" "$0 completed normally" if [ -e "${pgmout}" ] ; then cat ${pgmout} fi if [ -e "${errfile}" ] ; then cat ${errfile} fi if [ "${KEEPDATA^^}" != "YES" ]; then rm -rf $DATA fi date exit