Skip to content

Commit

Permalink
Replace preamble variable commands with functions
Browse files Browse the repository at this point in the history
Replaces the commands to restore the strict and trace state with functions.
Functions are more logical choice for this sort of behavior.

Refs: #397
  • Loading branch information
WalterKolczynski-NOAA committed Sep 1, 2022
1 parent 855ee86 commit 4b6b506
Show file tree
Hide file tree
Showing 29 changed files with 322 additions and 321 deletions.
4 changes: 2 additions & 2 deletions jobs/rocoto/arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ if [ $CDUMP = "gfs" ]; then
echo "$(echo $TARCMD | tr 'a-z' 'A-Z') $CDATE gfsmos.tar failed"
exit $status
fi
${ERR_EXIT_ON:-set -e}
restore_strict
fi
elif [ $CDUMP = "gdas" ]; then

Expand Down Expand Up @@ -275,7 +275,7 @@ for targrp in $targrp_list; do
echo "$(echo $TARCMD | tr 'a-z' 'A-Z') $CDATE ${targrp}.tar failed"
exit $status
fi
${ERR_EXIT_ON:-set -e}
restore_strict
done
# Turn extended globbing back off
shopt -u extglob
Expand Down
2 changes: 1 addition & 1 deletion jobs/rocoto/earc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ if [ $ENSGRP -eq 0 ]; then
echo "$(echo $TARCMD | tr 'a-z' 'A-Z') $CDATE enkf${CDUMP}.tar failed"
exit $status
fi
${ERR_EXIT_ON:-set -eu}
restore_strict
fi

#-- Archive online for verification and diagnostics
Expand Down
2 changes: 1 addition & 1 deletion scripts/exgfs_atmos_awips_20km_1p0deg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ echo "#######################################"
echo " Process GRIB AWIP GRIB2 PRODUCTS "
echo "#######################################"
echo " "
${TRACE_ON:-set -x}
restore_trace

# Set type of Interpolation for WGRIB2
export opt1=' -set_grib_type same -new_grid_winds earth '
Expand Down
2 changes: 1 addition & 1 deletion scripts/exgfs_atmos_fbwind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo " Process Bulletins of forecast winds and temps for Hawaii "
echo " and 15 sites outside of the Hawaiian Islands. "
echo "#############################################################"
echo " "
${TRACE_ON:-set -x}
restore_trace

export pgm=bulls_fbwndgfs
. prep_step
Expand Down
2 changes: 1 addition & 1 deletion scripts/exgfs_atmos_grib2_special_npoess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ do
err_chk
fi
done
${TRACE_ON:-set -x}
restore_trace

###############################
# Put restart files into /nwges
Expand Down
2 changes: 1 addition & 1 deletion scripts/exgfs_atmos_grib_awips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ echo "###############################################"
echo " Process GFS GRIB1 AWIP PRODUCTS (211) "
echo "###############################################"
echo " "
${TRACE_ON:-set -x}
restore_trace

cp $COMIN/gfs.t${cyc}z.pgrb2.0p25.f${fcsthrs} tmpfile2
cp $COMIN/gfs.t${cyc}z.pgrb2b.0p25.f${fcsthrs} tmpfile2b
Expand Down
24 changes: 12 additions & 12 deletions scripts/exgfs_wave_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo ' '
echo "Starting at : $(date)"
echo ' '
${TRACE_ON:-set -x}
restore_trace

# Script will run only if pre-defined NTASKS
# The actual work is distributed over these tasks.
Expand All @@ -58,7 +58,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo ' '
echo " Script set to run with $NTASKS tasks "
echo ' '
${TRACE_ON:-set -x}
restore_trace


# --------------------------------------------------------------------------- #
Expand All @@ -68,7 +68,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo 'Preparing input files :'
echo '-----------------------'
echo ' '
${TRACE_ON:-set -x}
restore_trace

# 1.a Model definition files

Expand All @@ -88,14 +88,14 @@ source "$HOMEgfs/ush/preamble.sh"
then
set +x
echo " Mod def file for $grdID found in ${COMIN}/rundata. copying ...."
${TRACE_ON:-set -x}
restore_trace
cp $COMIN/rundata/${CDUMP}wave.mod_def.${grdID} mod_def.$grdID

else
set +x
echo " Mod def file for $grdID not found in ${COMIN}/rundata. Setting up to generate ..."
echo ' '
${TRACE_ON:-set -x}
restore_trace
if [ -f $PARMwave/ww3_grid.inp.$grdID ]
then
cp $PARMwave/ww3_grid.inp.$grdID ww3_grid.inp.$grdID
Expand All @@ -107,7 +107,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo ' '
echo " ww3_grid.inp.$grdID copied ($PARMwave/ww3_grid.inp.$grdID)."
echo ' '
${TRACE_ON:-set -x}
restore_trace
else
set +x
echo ' '
Expand All @@ -116,7 +116,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo '*********************************************************** '
echo " grdID = $grdID"
echo ' '
${TRACE_ON:-set -x}
restore_trace
err=2;export err;${errchk}
fi

Expand All @@ -141,7 +141,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo ' '
echo " Generating $nmoddef mod def files"
echo ' '
${TRACE_ON:-set -x}
restore_trace

# Set number of processes for mpmd
wavenproc=$(wc -l cmdfile | awk '{print $1}')
Expand All @@ -154,7 +154,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo " Executing the mod_def command file at : $(date)"
echo ' ------------------------------------'
echo ' '
${TRACE_ON:-set -x}
restore_trace
if [ "$NTASKS" -gt '1' ]
then
if [ ${CFP_MP:-"NO"} = "YES" ]; then
Expand All @@ -177,7 +177,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo '********************************************************'
echo ' See Details Below '
echo ' '
${TRACE_ON:-set -x}
restore_trace
fi

fi
Expand All @@ -192,7 +192,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo ' '
echo " mod_def.$grdID succesfully created/copied "
echo ' '
${TRACE_ON:-set -x}
restore_trace
else
set +x
echo ' '
Expand All @@ -202,7 +202,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo " grdID = $grdID"
echo ' '
sed "s/^/$grdID.out : /g" $grdID.out
${TRACE_ON:-set -x}
restore_trace
err=3;export err;${errchk}
fi
done
Expand Down
4 changes: 2 additions & 2 deletions scripts/exgfs_wave_nawips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ while [ $fhcnt -le $FHMAX_WAV ]; do
echo '**************************** '
echo ' '
echo $msg
${TRACE_ON:-set -x}
restore_trace
echo "$RUNwave $grdID ${fhr} prdgen $date $cycle : GRIB file missing." >> $wavelog
err=1;export err;${errchk} || exit ${err}
fi
Expand All @@ -112,7 +112,7 @@ while [ $fhcnt -le $FHMAX_WAV ]; do
echo '************************************************************* '
echo ' '
echo $msg
#${TRACE_ON:-set -x}
#restore_trace
echo "$RUNwave $grdID prdgen $date $cycle : error in grbindex." >> $wavelog
err=2;export err;err_chk
else
Expand Down
32 changes: 16 additions & 16 deletions scripts/exgfs_wave_post_gridded_sbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo "Starting at : $(date)"
echo '-------------'
echo ' '
${TRACE_ON:-set -x}
restore_trace

# Script will run only if pre-defined NTASKS
# The actual work is distributed over these tasks.
Expand Down Expand Up @@ -81,7 +81,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo " Interpolated grids : $waveinterpGRD"
echo " Post-process grids : $wavepostGRD"
echo ' '
${TRACE_ON:-set -x}
restore_trace


# 0.c.3 Define CDATE_POST
Expand All @@ -100,7 +100,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo ' '
echo 'Preparing input files :'
echo '-----------------------'
${TRACE_ON:-set -x}
restore_trace

# 1.a Model definition files and output files (set up using poe)

Expand All @@ -111,7 +111,7 @@ source "$HOMEgfs/ush/preamble.sh"
then
set +x
echo " Mod def file for $grdID found in ${COMIN}/rundata. copying ...."
${TRACE_ON:-set -x}
restore_trace

cp -f $COMIN/rundata/${CDUMP}wave.mod_def.${grdID} mod_def.$grdID
fi
Expand All @@ -128,14 +128,14 @@ source "$HOMEgfs/ush/preamble.sh"
echo " FATAL ERROR : NO MOD_DEF FILE mod_def.$grdID "
echo '*************************************************** '
echo ' '
${TRACE_ON:-set -x}
restore_trace
err=2; export err;${errchk}
exit $err
DOGRB_WAV='NO'
else
set +x
echo "File mod_def.$grdID found. Syncing to all nodes ..."
${TRACE_ON:-set -x}
restore_trace
fi
done

Expand All @@ -155,15 +155,15 @@ source "$HOMEgfs/ush/preamble.sh"
then
set +x
echo " ${intGRD}_interp.inp.tmpl copied. Syncing to all nodes ..."
${TRACE_ON:-set -x}
restore_trace
else
set +x
echo ' '
echo '*********************************************** '
echo '*** ERROR : NO TEMPLATE FOR GRINT INPUT FILE *** '
echo '*********************************************** '
echo ' '
${TRACE_ON:-set -x}
restore_trace
echo "$WAV_MOD_TAG post $date $cycle : GRINT template file missing."
exit_code=1
DOGRI_WAV='NO'
Expand All @@ -184,15 +184,15 @@ source "$HOMEgfs/ush/preamble.sh"
then
set +x
echo " ww3_grib2.${grbGRD}.inp.tmpl copied. Syncing to all nodes ..."
${TRACE_ON:-set -x}
restore_trace
else
set +x
echo ' '
echo '*********************************************** '
echo "*** ERROR : NO TEMPLATE FOR ${grbGRD} GRIB INPUT FILE *** "
echo '*********************************************** '
echo ' '
${TRACE_ON:-set -x}
restore_trace
exit_code=2
DOGRB_WAV='NO'
fi
Expand All @@ -211,7 +211,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo " Sufficient data for GRID interpolation : $DOGRI_WAV"
echo " Sufficient data for GRIB files : $DOGRB_WAV"
echo ' '
${TRACE_ON:-set -x}
restore_trace

# --------------------------------------------------------------------------- #
# 2. Make consolidated grib2 file for side-by-side grids and interpolate
Expand All @@ -221,7 +221,7 @@ source "$HOMEgfs/ush/preamble.sh"

set +x
echo ' Making command file for sbs grib2 and GRID Interpolation '
${TRACE_ON:-set -x}
restore_trace

# 1.a.2 Loop over forecast time to generate post files
# When executed side-by-side, serial mode (cfp when run after the fcst step)
Expand Down Expand Up @@ -272,7 +272,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo " FATAL ERROR : NO RAW FIELD OUTPUT FILE out_grd.$grdID "
echo '*************************************************** '
echo ' '
${TRACE_ON:-set -x}
restore_trace
echo "$WAV_MOD_TAG post $grdID $date $cycle : field output missing."
err=3; export err;${errchk}
exit $err
Expand Down Expand Up @@ -367,7 +367,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo " Executing the grib2_sbs scripts at : $(date)"
echo ' ------------------------------------'
echo ' '
${TRACE_ON:-set -x}
restore_trace

if [ "$wavenproc" -gt '1' ]
then
Expand All @@ -392,7 +392,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo '*************************************'
echo ' See Details Below '
echo ' '
${TRACE_ON:-set -x}
restore_trace
err=4; export err;${errchk}
exit $err
fi
Expand All @@ -416,7 +416,7 @@ source "$HOMEgfs/ush/preamble.sh"
echo '********************************************'
echo ' See Details Below '
echo ' '
${TRACE_ON:-set -x}
restore_trace
err=5; export err;${errchk}
exit $err
fi
Expand Down
Loading

0 comments on commit 4b6b506

Please sign in to comment.