From 4b6b50617cad8ab047b4764a75d15a771e54e07f Mon Sep 17 00:00:00 2001 From: "Walter.Kolczynski" Date: Thu, 1 Sep 2022 04:34:18 +0000 Subject: [PATCH] Replace preamble variable commands with functions Replaces the commands to restore the strict and trace state with functions. Functions are more logical choice for this sort of behavior. Refs: #397 --- jobs/rocoto/arch.sh | 4 +- jobs/rocoto/earc.sh | 2 +- scripts/exgfs_atmos_awips_20km_1p0deg.sh | 2 +- scripts/exgfs_atmos_fbwind.sh | 2 +- scripts/exgfs_atmos_grib2_special_npoess.sh | 2 +- scripts/exgfs_atmos_grib_awips.sh | 2 +- scripts/exgfs_wave_init.sh | 24 +++--- scripts/exgfs_wave_nawips.sh | 4 +- scripts/exgfs_wave_post_gridded_sbs.sh | 32 ++++---- scripts/exgfs_wave_post_pnt.sh | 54 ++++++------- scripts/exgfs_wave_prdgen_bulls.sh | 32 ++++---- scripts/exgfs_wave_prdgen_gridded.sh | 20 ++--- scripts/exgfs_wave_prep.sh | 30 +++---- ush/fv3gfs_downstream_nems.sh | 4 +- ush/global_extrkr.sh | 66 ++++++++-------- ush/load_fv3gfs_modules.sh | 2 +- ush/parsing_namelists_WW3.sh | 4 +- ush/preamble.sh | 83 ++++++++++---------- ush/syndat_getjtbul.sh | 12 +-- ush/syndat_qctropcy.sh | 24 +++--- ush/tropcy_relocate.sh | 26 +++---- ush/tropcy_relocate_extrkr.sh | 86 ++++++++++----------- ush/wave_grib2_sbs.sh | 26 +++---- ush/wave_grid_interp_sbs.sh | 16 ++-- ush/wave_grid_moddef.sh | 12 +-- ush/wave_outp_cat.sh | 10 +-- ush/wave_outp_spec.sh | 22 +++--- ush/wave_prnc_ice.sh | 18 ++--- ush/wave_tar.sh | 22 +++--- 29 files changed, 322 insertions(+), 321 deletions(-) diff --git a/jobs/rocoto/arch.sh b/jobs/rocoto/arch.sh index 4e74f0ca26e..9aaf7943e38 100755 --- a/jobs/rocoto/arch.sh +++ b/jobs/rocoto/arch.sh @@ -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 @@ -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 diff --git a/jobs/rocoto/earc.sh b/jobs/rocoto/earc.sh index 8b80b4b9e88..e10e7c81003 100755 --- a/jobs/rocoto/earc.sh +++ b/jobs/rocoto/earc.sh @@ -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 diff --git a/scripts/exgfs_atmos_awips_20km_1p0deg.sh b/scripts/exgfs_atmos_awips_20km_1p0deg.sh index 3f9f84f2372..49a3c58749d 100755 --- a/scripts/exgfs_atmos_awips_20km_1p0deg.sh +++ b/scripts/exgfs_atmos_awips_20km_1p0deg.sh @@ -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 ' diff --git a/scripts/exgfs_atmos_fbwind.sh b/scripts/exgfs_atmos_fbwind.sh index a4ecd248f00..fb74c513ce2 100755 --- a/scripts/exgfs_atmos_fbwind.sh +++ b/scripts/exgfs_atmos_fbwind.sh @@ -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 diff --git a/scripts/exgfs_atmos_grib2_special_npoess.sh b/scripts/exgfs_atmos_grib2_special_npoess.sh index ad24bf64354..f7709f06cef 100755 --- a/scripts/exgfs_atmos_grib2_special_npoess.sh +++ b/scripts/exgfs_atmos_grib2_special_npoess.sh @@ -150,7 +150,7 @@ do err_chk fi done - ${TRACE_ON:-set -x} + restore_trace ############################### # Put restart files into /nwges diff --git a/scripts/exgfs_atmos_grib_awips.sh b/scripts/exgfs_atmos_grib_awips.sh index 5252d71983e..2aa48cd575b 100755 --- a/scripts/exgfs_atmos_grib_awips.sh +++ b/scripts/exgfs_atmos_grib_awips.sh @@ -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 diff --git a/scripts/exgfs_wave_init.sh b/scripts/exgfs_wave_init.sh index 31c39fd52a7..16a27ddcd87 100755 --- a/scripts/exgfs_wave_init.sh +++ b/scripts/exgfs_wave_init.sh @@ -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. @@ -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 # --------------------------------------------------------------------------- # @@ -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 @@ -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 @@ -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 ' ' @@ -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 @@ -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}') @@ -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 @@ -177,7 +177,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '********************************************************' echo ' See Details Below ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace fi fi @@ -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 ' ' @@ -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 diff --git a/scripts/exgfs_wave_nawips.sh b/scripts/exgfs_wave_nawips.sh index 8d41578d7e1..5fe2094cd2c 100755 --- a/scripts/exgfs_wave_nawips.sh +++ b/scripts/exgfs_wave_nawips.sh @@ -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 @@ -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 diff --git a/scripts/exgfs_wave_post_gridded_sbs.sh b/scripts/exgfs_wave_post_gridded_sbs.sh index b602ba3a0e4..6720880bb05 100755 --- a/scripts/exgfs_wave_post_gridded_sbs.sh +++ b/scripts/exgfs_wave_post_gridded_sbs.sh @@ -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. @@ -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 @@ -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) @@ -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 @@ -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 @@ -155,7 +155,7 @@ 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 ' ' @@ -163,7 +163,7 @@ source "$HOMEgfs/ush/preamble.sh" 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' @@ -184,7 +184,7 @@ 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 ' ' @@ -192,7 +192,7 @@ source "$HOMEgfs/ush/preamble.sh" echo "*** ERROR : NO TEMPLATE FOR ${grbGRD} GRIB INPUT FILE *** " echo '*********************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit_code=2 DOGRB_WAV='NO' fi @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/scripts/exgfs_wave_post_pnt.sh b/scripts/exgfs_wave_post_pnt.sh index cf42db0bb42..23776ae8af3 100755 --- a/scripts/exgfs_wave_post_pnt.sh +++ b/scripts/exgfs_wave_post_pnt.sh @@ -54,7 +54,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. @@ -91,7 +91,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '-------------------' echo " Output points : $waveuoutpGRD" echo ' ' - ${TRACE_ON:-set -x} + restore_trace # --------------------------------------------------------------------------- # # 1. Get files that are used by most child scripts @@ -102,7 +102,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) @@ -112,7 +112,7 @@ source "$HOMEgfs/ush/preamble.sh" touch cmdfile chmod 744 cmdfile - ${TRACE_ON:-set -x} + restore_trace # Copy model definition files iloop=0 @@ -122,7 +122,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 iloop=$(expr $iloop + 1) @@ -139,13 +139,13 @@ 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 else set +x echo "File mod_def.$grdID found. Syncing to all nodes ..." - ${TRACE_ON:-set -x} + restore_trace fi done @@ -169,7 +169,7 @@ source "$HOMEgfs/ush/preamble.sh" then set +x echo " buoy.loc and buoy.ibp copied and processed ($PARMwave/wave_${NET}.buoys)." - ${TRACE_ON:-set -x} + restore_trace else set +x echo ' ' @@ -177,7 +177,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' FATAL ERROR : NO BUOY LOCATION FILE ' echo '************************************* ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=3; export err;${errchk} exit $err DOSPC_WAV='NO' @@ -195,7 +195,7 @@ source "$HOMEgfs/ush/preamble.sh" then set +x echo " ww3_outp_spec.inp.tmpl copied. Syncing to all grids ..." - ${TRACE_ON:-set -x} + restore_trace else set +x echo ' ' @@ -203,7 +203,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** ERROR : NO TEMPLATE FOR SPEC INPUT FILE *** ' echo '*********************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit_code=3 DOSPC_WAV='NO' DOBLL_WAV='NO' @@ -218,7 +218,7 @@ source "$HOMEgfs/ush/preamble.sh" then set +x echo " ww3_outp_bull.inp.tmpl copied. Syncing to all nodes ..." - ${TRACE_ON:-set -x} + restore_trace else set +x echo ' ' @@ -226,7 +226,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** ERROR : NO TEMPLATE FOR BULLETIN INPUT FILE *** ' echo '*************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit_code=4 DOBLL_WAV='NO' fi @@ -256,7 +256,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " FATAL ERROR : NO RAW POINT OUTPUT FILE out_pnt.${waveuoutpGRD}.${YMD}.${HMS} " echo '*************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace echo "$WAV_MOD_TAG post $waveuoutpGRD $CDATE $cycle : field output missing." err=4; export err;${errchk} fi @@ -280,7 +280,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' cat buoy_tmp.loc echo "$WAV_MOD_TAG post $date $cycle : buoy log file failed to be created." - ${TRACE_ON:-set -x} + restore_trace err=5;export err;${errchk} DOSPC_WAV='NO' DOBLL_WAV='NO' @@ -303,7 +303,7 @@ source "$HOMEgfs/ush/preamble.sh" then set +x echo 'Buoy log file created. Syncing to all nodes ...' - ${TRACE_ON:-set -x} + restore_trace else set +x echo ' ' @@ -311,7 +311,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** ERROR : NO BUOY LOG FILE CREATED *** ' echo '**************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=6;export err;${errchk} DOSPC_WAV='NO' DOBLL_WAV='NO' @@ -331,7 +331,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Sufficient data for bulletins : $DOBLL_WAV ($Nb points)" echo " Boundary points : $DOBNDPNT_WAV" echo ' ' - ${TRACE_ON:-set -x} + restore_trace # --------------------------------------------------------------------------- # # 2. Make files for processing boundary points @@ -340,7 +340,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' Making command file for wave post points ' - ${TRACE_ON:-set -x} + restore_trace rm -f cmdfile touch cmdfile @@ -374,7 +374,7 @@ source "$HOMEgfs/ush/preamble.sh" else echo " FATAL ERROR : NO RAW POINT OUTPUT FILE out_pnt.$waveuoutpGRD.${YMD}.${HMS} " echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=7; export err;${errchk} exit $err fi @@ -468,7 +468,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Executing the wave point scripts at : $(date)" echo ' ------------------------------------' echo ' ' - ${TRACE_ON:-set -x} + restore_trace if [ "$wavenproc" -gt '1' ] then @@ -493,7 +493,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*************************************' echo ' See Details Below ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=8; export err;${errchk} exit $err fi @@ -560,7 +560,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Executing the boundary point cat script at : $(date)" echo ' ------------------------------------' echo ' ' - ${TRACE_ON:-set -x} + restore_trace if [ "$wavenproc" -gt '1' ] then @@ -585,7 +585,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*************************************' echo ' See Details Below ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=9; export err;${errchk} exit $err fi @@ -604,7 +604,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo ' Making command file for taring all point output files.' - ${TRACE_ON:-set -x} + restore_trace # 6.b Spectral data files @@ -662,7 +662,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Executing the wave_tar scripts at : $(date)" echo ' ------------------------------------' echo ' ' - ${TRACE_ON:-set -x} + restore_trace if [ "$wavenproc" -gt '1' ] then @@ -687,7 +687,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*************************************' echo ' See Details Below ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=10; export err;${errchk} exit $err fi diff --git a/scripts/exgfs_wave_prdgen_bulls.sh b/scripts/exgfs_wave_prdgen_bulls.sh index 10bdee523b0..85ea00ccb38 100755 --- a/scripts/exgfs_wave_prdgen_bulls.sh +++ b/scripts/exgfs_wave_prdgen_bulls.sh @@ -54,12 +54,12 @@ source "$HOMEgfs/ush/preamble.sh" echo "Starting at : $(date)" echo ' ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace # 1. Get necessary files set +x echo " Copying bulletins from $COMIN" - ${TRACE_ON:-set -x} + restore_trace # 1.a Link the input file and untar it BullIn=$COMIN/station/${RUNwave}.$cycle.cbull_tar @@ -75,7 +75,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '************************************ ' echo ' ' echo $msg - ${TRACE_ON:-set -x} + restore_trace msg="FATAL ERROR ${RUNwave} prdgen $date $cycle : bulletin tar missing." echo $msg >> $wavelog export err=1; ${errchk} @@ -84,14 +84,14 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Untarring bulletins ..." - ${TRACE_ON:-set -x} + restore_trace tar -xf cbull.tar OK=$? if [ "$OK" = '0' ]; then set +x echo " Unpacking successfull ..." - ${TRACE_ON:-set -x} + restore_trace rm -f cbull.tar else msg="ABNORMAL EXIT: ERROR IN BULLETIN UNTAR" @@ -103,7 +103,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '****************************************** ' echo ' ' echo $msg - ${TRACE_ON:-set -x} + restore_trace echo "${RUNwave} prdgen $date $cycle : bulletin untar error." >> $wavelog err=2;export err;err_chk exit $err @@ -113,7 +113,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' Nb=$(ls -1 *.cbull | wc -l)' Nb=$(ls -1 *.cbull | wc -l) - ${TRACE_ON:-set -x} + restore_trace echo ' ' echo " Number of bulletin files : $Nb" echo ' --------------------------' @@ -131,7 +131,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '******************************************* ' echo ' ' echo $msg - ${TRACE_ON:-set -x} + restore_trace echo "${RUNwave} prdgen $date $cycle : Bulletin header data file missing." >> $wavelog err=3;export err;err_chk exit $err @@ -144,7 +144,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' Sourcing data file with header info ...' # 2.b Set up environment variables - ${TRACE_ON:-set -x} + restore_trace . awipsbull.data # 2.c Generate list of bulletins to process @@ -162,7 +162,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Processing $bull ($headr $oname) ..." if [ -z "$headr" ] || [ ! -s $fname ]; then - ${TRACE_ON:-set -x} + restore_trace msg="ABNORMAL EXIT: MISSING BULLETING INFO" set +x echo ' ' @@ -171,20 +171,20 @@ source "$HOMEgfs/ush/preamble.sh" echo '******************************************** ' echo ' ' echo $msg - ${TRACE_ON:-set -x} + restore_trace echo "${RUNwave} prdgen $date $cycle : Missing bulletin data." >> $wavelog err=4;export err;err_chk exit $err fi - ${TRACE_ON:-set -x} + restore_trace formbul.pl -d $headr -f $fname -j $job -m ${RUNwave} \ -p $PCOM -s NO -o $oname > formbul.out 2>&1 OK=$? if [ "$OK" != '0' ] || [ ! -f $oname ]; then - ${TRACE_ON:-set -x} + restore_trace cat formbul.out msg="ABNORMAL EXIT: ERROR IN formbul" postmsg "$jlogfile" "$msg" @@ -195,7 +195,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '************************************** ' echo ' ' echo $msg - ${TRACE_ON:-set -x} + restore_trace echo "${RUNwave} prdgen $date $cycle : error in formbul." >> $wavelog err=5;export err;err_chk exit $err @@ -206,7 +206,7 @@ source "$HOMEgfs/ush/preamble.sh" done # 3. Send output files to the proper destination - ${TRACE_ON:-set -x} + restore_trace if [ "$SENDCOM" = YES ]; then cp awipsbull.$cycle.${RUNwave} $PCOM/awipsbull.$cycle.${RUNwave} if [ "$SENDDBN_NTC" = YES ]; then @@ -214,7 +214,7 @@ source "$HOMEgfs/ush/preamble.sh" else if [ "${envir}" = "para" ] || [ "${envir}" = "test" ] || [ "${envir}" = "dev" ]; then echo "Making NTC bulletin for parallel environment, but do not alert." - ${TRACE_ON:-set -x} + restore_trace (export SENDDBN=NO; make_ntc_bull.pl WMOBH NONE KWBC NONE \ $DATA/awipsbull.$cycle.${RUNwave} $PCOM/awipsbull.$cycle.${RUNwave}) fi diff --git a/scripts/exgfs_wave_prdgen_gridded.sh b/scripts/exgfs_wave_prdgen_gridded.sh index b56fb15819f..7cce6e7310b 100755 --- a/scripts/exgfs_wave_prdgen_gridded.sh +++ b/scripts/exgfs_wave_prdgen_gridded.sh @@ -63,14 +63,14 @@ source "$HOMEgfs/ush/preamble.sh" echo " AWIPS grib fields" echo " Wave Grids : $grids" echo ' ' - ${TRACE_ON:-set -x} + restore_trace # --------------------------------------------------------------------------- # # 1. Get necessary files echo ' ' echo 'Preparing input files :' echo '-----------------------' - ${TRACE_ON:-set -x} + restore_trace #======================================================================= ASWELL=(SWELL1 SWELL2) # Indices of HS from partitions @@ -120,7 +120,7 @@ source "$HOMEgfs/ush/preamble.sh" 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 @@ -177,12 +177,12 @@ source "$HOMEgfs/ush/preamble.sh" # 2.a.1 Set up for tocgrib2 echo " Do set up for tocgrib2." - ${TRACE_ON:-set -x} + restore_trace #AWIPSGRB=awipsgrib.$grdID.f${fhr} AWIPSGRB=awipsgrib # 2.a.2 Make GRIB index echo " Make GRIB index for tocgrib2." - ${TRACE_ON:-set -x} + restore_trace $GRB2INDEX gribfile.$grdID.f${fhr} gribindex.$grdID.f${fhr} OK=$? @@ -197,7 +197,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '******************************************** ' echo ' ' echo $msg - #${TRACE_ON:-set -x} + #restore_trace echo "$RUNwave $grdID prdgen $date $cycle : error in grbindex." >> $wavelog err=4;export err;err_chk fi @@ -205,7 +205,7 @@ source "$HOMEgfs/ush/preamble.sh" # 2.a.3 Run AWIPS GRIB packing program tocgrib2 echo " Run tocgrib2" - ${TRACE_ON:-set -x} + restore_trace export pgm=tocgrib2 export pgmout=tocgrib2.out . prep_step @@ -227,7 +227,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*************************************** ' echo ' ' echo $msg - #${TRACE_ON:-set -x} + #restore_trace echo "$RUNwave prdgen $date $cycle : error in tocgrib2." >> $wavelog err=5;export err;err_chk else @@ -236,13 +236,13 @@ source "$HOMEgfs/ush/preamble.sh" # 2.a.7 Get the AWIPS grib bulletin out ... #set +x echo " Get awips GRIB bulletins out ..." - #${TRACE_ON:-set -x} + #restore_trace if [ "$SENDCOM" = 'YES' ] then #set +x echo " Saving $AWIPSGRB.$grdOut.f${fhr} as grib2.$cycle.awipsww3_${grdID}.f${fhr}" echo " in $PCOM" - #${TRACE_ON:-set -x} + #restore_trace cp $AWIPSGRB.$grdID.f${fhr} $PCOM/grib2.$cycle.f${fhr}.awipsww3_${grdOut} #set +x fi diff --git a/scripts/exgfs_wave_prep.sh b/scripts/exgfs_wave_prep.sh index f3ecf388beb..0fd84ba9288 100755 --- a/scripts/exgfs_wave_prep.sh +++ b/scripts/exgfs_wave_prep.sh @@ -64,7 +64,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo "Starting at : $(date)" echo ' ' - ${TRACE_ON:-set -x} + restore_trace if [ "$INDRUN" = 'no' ] then @@ -136,7 +136,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " starting time : $time_beg" echo " ending time : $time_end" echo ' ' - ${TRACE_ON:-set -x} + restore_trace # Script will run only if pre-defined NTASKS # The actual work is distributed over these tasks. @@ -153,7 +153,7 @@ source "$HOMEgfs/ush/preamble.sh" echo 'Preparing input files :' echo '-----------------------' echo ' ' - ${TRACE_ON:-set -x} + restore_trace # 1.a Model definition files @@ -173,7 +173,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 $COMIN/rundata/${CDUMP}wave.mod_def.${grdID} mod_def.$grdID else @@ -185,7 +185,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " grdID = $grdID" echo ' ' echo "FATAL ERROR: NO MODEL DEFINITION FILE" - ${TRACE_ON:-set -x} + restore_trace err=2;export err;${errchk} fi done @@ -225,7 +225,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo " ww3_prnc.${type}.$grdID.inp.tmpl copied ($PARMwave)." echo ' ' - ${TRACE_ON:-set -x} + restore_trace else set +x echo ' ' @@ -236,7 +236,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo "ABNORMAL EXIT: NO FILE $file" echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=4;export err;${errchk} fi done @@ -265,7 +265,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' sed "s/^/wave_prnc_ice.out : /g" wave_prnc_ice.out echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=5;export err;${errchk} else mv -f wave_prnc_ice.out $DATA/outtmp @@ -273,7 +273,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo ' Ice field unpacking successful.' echo ' ' - ${TRACE_ON:-set -x} + restore_trace fi else echo ' ' @@ -295,7 +295,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : Not set-up to preprocess wind *** ' echo '*************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=6;export err;${errchk} fi @@ -313,7 +313,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo ' Concatenate binary current fields ...' echo ' ' - ${TRACE_ON:-set -x} + restore_trace # Prepare files for cfp process rm -f cmdfile @@ -390,7 +390,7 @@ source "$HOMEgfs/ush/preamble.sh" echo "*** FATAL ERROR: NO CUR FILE $curfile *** " echo '************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace echo "FATAL ERROR - NO CURRENT FILE (RTOFS)" err=11;export err;${errchk} exit $err @@ -423,7 +423,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Executing the curr prnc cmdfile at : $(date)" echo ' ------------------------------------' echo ' ' - ${TRACE_ON:-set -x} + restore_trace if [ $wavenproc -gt '1' ] then @@ -448,7 +448,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '********************************************' echo ' See Details Below ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace fi files=$(ls ${WAVECUR_DID}.* 2> /dev/null) @@ -462,7 +462,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '******************************************** ' echo ' ' echo "ABNORMAL EXIT: NO ${WAVECUR_FID}.* FILES FOUND" - ${TRACE_ON:-set -x} + restore_trace err=11;export err;${errchk} fi diff --git a/ush/fv3gfs_downstream_nems.sh b/ush/fv3gfs_downstream_nems.sh index 3b15b00cb20..4da02c8939d 100755 --- a/ush/fv3gfs_downstream_nems.sh +++ b/ush/fv3gfs_downstream_nems.sh @@ -130,7 +130,7 @@ while [ $nset -le $totalset ]; do set +e $WGRIB2 -d $end $tmpfile | egrep -i "ugrd|ustm|uflx|u-gwd" export rc=$? - ${ERR_EXIT_ON:-set -eu} + restore_strict if [[ $rc -eq 0 ]] ; then export end=$(expr ${end} + 1) elif [[ $rc -gt 1 ]]; then @@ -141,7 +141,7 @@ while [ $nset -le $totalset ]; do set +e $WGRIB2 -d $end $tmpfile | egrep -i "land" export rc=$? - ${ERR_EXIT_ON:-set -eu} + restore_strict if [[ $rc -eq 0 ]] ; then export end=$(expr ${end} + 1) elif [[ $rc -gt 1 ]]; then diff --git a/ush/global_extrkr.sh b/ush/global_extrkr.sh index ad0b249b28a..e3d0b975252 100755 --- a/ush/global_extrkr.sh +++ b/ush/global_extrkr.sh @@ -149,7 +149,7 @@ while [[ "$#" -gt 0 ]] ; do echo $allhours | fold -s -w 72 echo "and I will keep all forecast hours up to $lasthour." echo "Calculating forecast hours now." - ${TRACE_ON:-set -x} + restore_trace prev=0 for now in $allhours ; do if [[ ! ( "$now" -le "$lasthour" ) ]] ; then @@ -242,7 +242,7 @@ then echo "Something wrong with input data. One or more input variables has length 0" echo "PDY= ${PDY}, CYL= ${CYL}, cmodel= ${cmodel}" echo "EXITING...." - ${TRACE_ON:-set -x} + restore_trace err_exit " FAILED ${jobid} -- BAD INPUTS AT LINE $LINENO IN TRACKER SCRIPT - ABNORMAL EX IT" else @@ -260,7 +260,7 @@ else echo " SENDCOM ............................... $SENDCOM" echo " SENDNHC ............................... $SENDNHC" echo " " - ${TRACE_ON:-set -x} + restore_trace fi scc=$(echo ${PDY} | cut -c1-2) @@ -310,7 +310,7 @@ export maxtime=65 # Max number of forecast time levels cmodel=$(echo ${cmodel} | tr "[A-Z]" "[a-z]") -${TRACE_ON:-set -x} +restore_trace # "gribver" is an environmental variable that should be defined # and exported in the parent script that calls this script. export gribver=${gribver:-2} @@ -454,7 +454,7 @@ if [[ ! -z "$override_fcsthrs" && ! -z "$override_fcstlen" ]] ; then echo "Forecast hours to process: $override_fcsthrs" echo "ATCF frequency: $override_atcffreq (in centihours)" echo " ---------------------------------------- " - ${TRACE_ON:-set -x} + restore_trace fcsthrs="$override_fcsthrs" fcstlen="$override_fcstlen" atcffreq="$override_atcffreq" @@ -531,7 +531,7 @@ echo " -----------------------------" echo " " echo " Now sorting and updating the TC Vitals file. Please wait...." echo " " -${TRACE_ON:-set -x} +restore_trace current_str="${symd} ${CYL}00" @@ -553,7 +553,7 @@ else echo " nor is there a TC vitals file for ${future_hh}z in ${synvitfuture_dir}," echo " Checking the raw TC Vitals file ....." echo " " - ${TRACE_ON:-set -x} + restore_trace fi # Take the vitals from Steve Lord's /com/gfs/prod tcvitals file, @@ -643,7 +643,7 @@ then echo "!!! It could just be that there are no storms for the current" echo "!!! time. Please check the dates and submit this job again...." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 1 fi @@ -750,7 +750,7 @@ then echo "!!! model= ${atcfout}, forecast initial time = ${PDY}${CYL}" echo "!!! Exiting...." echo " " - ${TRACE_ON:-set -x} + restore_trace err_exit " FAILED ${jobid} - ERROR RUNNING SUPVIT IN TRACKER SCRIPT- ABNORMAL EXIT" fi @@ -787,7 +787,7 @@ then echo "!!! It could just be that there are no storms for the current" echo "!!! time. Please check the dates and submit this job again...." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 1 fi fi @@ -798,7 +798,7 @@ echo " *--------------------------------*" echo " | STORM SELECTION |" echo " *--------------------------------*" echo " " -${TRACE_ON:-set -x} +restore_trace ict=1 while [ $ict -le 15 ] @@ -894,7 +894,7 @@ echo " " echo " for the times 6h ago, current and 6h ahead:" echo " " echo " " -${TRACE_ON:-set -x} +restore_trace touch ${DATA}/genvitals.upd.${cmodel}.${atcfout}.${PDY}${CYL} @@ -917,7 +917,7 @@ echo " NOW CUTTING APART INPUT GRIB FILES TO " echo " CREATE 1 BIG GRIB INPUT FILE " echo " -----------------------------------------" echo " " -${TRACE_ON:-set -x} +restore_trace #gix=$NWPROD/util/exec/grbindex #g2ix=$NWPROD/util/exec/grb2index @@ -939,7 +939,7 @@ find_gfile() { shift 2 gfile=none echo "Searching for input $nicename data for forecast hour $nicehour" - ${TRACE_ON:-set -x} + restore_trace now=$( date +%s ) later=$(( now + wait_max_time )) # Note: the loop has only one iteration if --wait-max-time is @@ -949,17 +949,17 @@ find_gfile() { if [[ ! -e "$gfile" ]] ; then set +x echo "$gfile: does not exist" - ${TRACE_ON:-set -x} + restore_trace gfile=none elif [[ ! -s "$gfile" ]] ; then set +x echo "$gfile: exists, but is empty" - ${TRACE_ON:-set -x} + restore_trace gfile=none else set +x echo "$gfile: exists, is non-empty, so I will use this file" - ${TRACE_ON:-set -x} + restore_trace return 0 fi done @@ -977,7 +977,7 @@ find_gfile() { done echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " " - ${TRACE_ON:-set -x} + restore_trace err_exit "ERROR: mandatory input GFS file for hour $nicehour is missing or empty. Aborting. Checked for these files: $*" continue else @@ -990,7 +990,7 @@ find_gfile() { echo " !!! $nicename File: $gfile" done echo " " - ${TRACE_ON:-set -x} + restore_trace sleep $sleep_time fi fi @@ -1027,7 +1027,7 @@ if [[ ${model} -eq 1 || $model == 8 ]] ; then echo " " echo "Time before gfs wgrib loop is $(date)" echo " " - ${TRACE_ON:-set -x} + restore_trace if [[ "$model" -eq 8 ]] ; then name=gdas @@ -1147,7 +1147,7 @@ if [[ ${model} -eq 1 || $model == 8 ]] ; then echo " " echo "Date in interpolation for model= $cmodel and fhour= $fhour000 before = $(date)" echo " " - ${TRACE_ON:-set -x} + restore_trace gfile=${DATA}/gfsgribfile.${PDY}${CYL} ifile=${DATA}/gfsixfile.${PDY}${CYL} @@ -1230,7 +1230,7 @@ if [[ ${model} -eq 1 || $model == 8 ]] ; then echo " " echo "Date in interpolation for cmodel= $cmodel and fhour= $fhour000 after = $(date)" echo " " - ${TRACE_ON:-set -x} + restore_trace done fi # end of "If PhaseFlag is on" @@ -1264,9 +1264,9 @@ while [ $ist -le 15 ] do if [ ${stormflag[${ist}]} -ne 1 ] then - set +x; echo "Storm number $ist NOT selected for processing"; ${TRACE_ON:-set -x} + set +x; echo "Storm number $ist NOT selected for processing"; restore_trace else - set +x; echo "Storm number $ist IS selected for processing...."; ${TRACE_ON:-set -x} + set +x; echo "Storm number $ist IS selected for processing...."; restore_trace fi let ist=ist+1 done @@ -1432,20 +1432,20 @@ echo " -----------------------------------------------" echo " NOW EXECUTING TRACKER......" echo " -----------------------------------------------" echo " " -${TRACE_ON:-set -x} +restore_trace msg="$pgm start for $atcfout at ${CYL}z" $postmsg "$jlogfile" "$msg" set +x echo "+++ TIMING: BEFORE gettrk ---> $(date)" -${TRACE_ON:-set -x} +restore_trace set +x echo " " echo "TIMING: Before call to gettrk at $(date)" echo " " -${TRACE_ON:-set -x} +restore_trace ##/usrx/local/bin/getrusage -a /hwrf/save/Qingfu.Liu/trak/para/exec/gettrk <${namelist} @@ -1456,11 +1456,11 @@ set +x echo " " echo "TIMING: After call to gettrk at $(date)" echo " " -${TRACE_ON:-set -x} +restore_trace set +x echo "+++ TIMING: AFTER gettrk ---> $(date)" -${TRACE_ON:-set -x} +restore_trace #--------------------------------------------------------------# # Send a message to the jlogfile for each storm that used @@ -1490,7 +1490,7 @@ echo " -----------------------------------------------" echo " NOW COPYING OUTPUT TRACK FILES TO COM " echo " -----------------------------------------------" echo " " -${TRACE_ON:-set -x} +restore_trace if [[ ! -e "$track_file_path" ]] ; then $postmsg "$jlogfile" "WARNING: tracker output file does not exist. This is probably an error. File: $track_file_path" @@ -1659,12 +1659,12 @@ if [ ${gettrk_rcc} -eq 0 ]; then echo " " echo "+++ Adding records to TPC ATCFUNIX directory: /tpcprd/atcf_unix/${at}${NO}${syyyy}" echo " " - ${TRACE_ON:-set -x} + restore_trace else set +x echo " " echo "There is no TPC ATCFUNIX directory for: /tpcprd/atcf_unix/${at}${NO}${syyyy}" - ${TRACE_ON:-set -x} + restore_trace fi done fi @@ -1691,7 +1691,7 @@ else echo "!!! model= ${atcfout}, forecast initial time = ${PDY}${CYL}" echo "!!! Exiting...." echo " " - ${TRACE_ON:-set -x} + restore_trace err_exit " FAILED ${jobid} - ERROR RUNNING GETTRK IN TRACKER SCRIPT- ABNORMAL EXIT" fi diff --git a/ush/load_fv3gfs_modules.sh b/ush/load_fv3gfs_modules.sh index 73aa0fbd068..df2ce3e2ab1 100755 --- a/ush/load_fv3gfs_modules.sh +++ b/ush/load_fv3gfs_modules.sh @@ -41,4 +41,4 @@ fi ulimit -S -s "$ulimit_s" unset ulimit_s -${TRACE_ON:-set -x} +restore_trace diff --git a/ush/parsing_namelists_WW3.sh b/ush/parsing_namelists_WW3.sh index 209fe9d11ae..4dbc635888b 100755 --- a/ush/parsing_namelists_WW3.sh +++ b/ush/parsing_namelists_WW3.sh @@ -70,7 +70,7 @@ WW3_namelists(){ echo " starting time : $time_beg" echo " ending time : $time_end" echo ' ' - ${TRACE_ON:-set -x} + restore_trace @@ -108,7 +108,7 @@ WW3_namelists(){ then set +x echo " buoy.loc copied ($PARMwave/wave_${NET}.buoys)." - ${TRACE_ON:-set -x} + restore_trace else echo " FATAL ERROR : buoy.loc ($PARMwave/wave_${NET}.buoys) NOT FOUND" exit 12 diff --git a/ush/preamble.sh b/ush/preamble.sh index dbd5f690047..c731209e426 100644 --- a/ush/preamble.sh +++ b/ush/preamble.sh @@ -20,9 +20,9 @@ ####### set +x if (( $# > 0 )); then - id="(${1})" + id="(${1})" else - id="" + id="" fi # Record the start time so we can calculate the elapsed time later @@ -35,49 +35,50 @@ _calling_script=$(basename "${BASH_SOURCE[1]}") start_time_human=$(date -d"@${start_time}" -u) echo "Begin ${_calling_script} at ${start_time_human}" -# Stage our variables -export STRICT=${STRICT:-"YES"} -export TRACE=${TRACE:-"YES"} -export ERR_EXIT_ON="" -export TRACE_ON="" +export PS4='+ $(basename ${BASH_SOURCE})[${LINENO}]'"${id}: " -if [[ ${STRICT} == "YES" ]]; then - # Exit on error and undefined variable - export ERR_EXIT_ON="set -eu" -fi -if [[ ${TRACE} == "YES" ]]; then - export TRACE_ON="set -x" - # Print the script name and line number of each command as it is executed - export PS4='+ $(basename ${BASH_SOURCE})[${LINENO}]'"${id}: " -fi +restore_strict() { + if [[ ${STRICT:-"YES"} == "YES" ]]; then + # Exit on error and undefined variable + set -eu + fi +} + +restore_trace() { + # Print the script name and line number of each command as it is + # executed when using trace. + if [[ ${TRACE:-"YES"} == "YES" ]]; then + set -x + fi +} postamble() { - # - # Commands to execute when a script ends. - # - # Syntax: - # postamble script start_time rc - # - # Arguments: - # script: name of the script ending - # start_time: start time of script (in seconds) - # rc: the exit code of the script - # + # + # Commands to execute when a script ends. + # + # Syntax: + # postamble script start_time rc + # + # Arguments: + # script: name of the script ending + # start_time: start time of script (in seconds) + # rc: the exit code of the script + # - set +x - script="${1}" - start_time="${2}" - rc="${3}" + set +x + script="${1}" + start_time="${2}" + rc="${3}" - # Calculate the elapsed time - end_time=$(date +%s) - end_time_human=$(date -d@"${end_time}" -u +%H:%M:%S) - elapsed_sec=$((end_time - start_time)) - elapsed=$(date -d@"${elapsed_sec}" -u +%H:%M:%S) + # Calculate the elapsed time + end_time=$(date +%s) + end_time_human=$(date -d@"${end_time}" -u +%H:%M:%S) + elapsed_sec=$((end_time - start_time)) + elapsed=$(date -d@"${elapsed_sec}" -u +%H:%M:%S) - # Announce the script has ended, then pass the error code up - echo "End ${script} at ${end_time_human} with error code ${rc:-0} (time elapsed: ${elapsed})" - exit "${rc}" + # Announce the script has ended, then pass the error code up + echo "End ${script} at ${end_time_human} with error code ${rc:-0} (time elapsed: ${elapsed})" + exit "${rc}" } # Place the postamble in a trap so it is always called no matter how the script exits @@ -87,5 +88,5 @@ trap "postamble ${_calling_script} ${start_time} \$?" EXIT # shellcheck disable= # Turn on our settings -${ERR_EXIT_ON} -${TRACE_ON} +restore_strict +restore_trace diff --git a/ush/syndat_getjtbul.sh b/ush/syndat_getjtbul.sh index 89196d05966..65555b9b472 100755 --- a/ush/syndat_getjtbul.sh +++ b/ush/syndat_getjtbul.sh @@ -39,7 +39,7 @@ positional parameter 1" echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout set +u [ -n "$jlogfile" ] && postmsg "$jlogfile" "$msg" @@ -94,7 +94,7 @@ echo " pdym1 is $pdym1" echo echo " ymddir is $ymddir" echo -${TRACE_ON:-set -x} +restore_trace find=$ymd" "$hour echo "looking for string $find in $jtwcdir/tropcyc" >> $pgmout @@ -159,7 +159,7 @@ set +x echo echo 'The foreground exit status for SYNDAT_GETJTBUL is ' $errget echo -${TRACE_ON:-set -x} +restore_trace if [ "$errget" -gt '0' ];then if [ "$errget" -eq '1' ];then msg="No JTWC bulletins in $jtwcdir/tropcyc, no JTWC tcvitals \ @@ -182,7 +182,7 @@ RETURN CODE $errget" echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout set +u [ -n "$jlogfile" ] && postmsg "$jlogfile" "$msg" @@ -194,7 +194,7 @@ rec. passed to qctropcy" echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout set +u [ -n "$jlogfile" ] && postmsg "$jlogfile" "$msg" @@ -206,7 +206,7 @@ echo "----------------------------------------------------------" echo "*********** COMPLETED PROGRAM syndat_getjtbul **********" echo "----------------------------------------------------------" echo -${TRACE_ON:-set -x} +restore_trace if [ "$errget" -eq '0' ];then echo "Completed JTWC tcvitals records are:" >> $pgmout diff --git a/ush/syndat_qctropcy.sh b/ush/syndat_qctropcy.sh index 571a7543b53..4d7055d6dce 100755 --- a/ush/syndat_qctropcy.sh +++ b/ush/syndat_qctropcy.sh @@ -95,7 +95,7 @@ set +x echo echo $msg echo -${TRACE_ON:-set -x} +restore_trace echo $msg >> $pgmout if [ "$#" -ne '1' ]; then @@ -105,14 +105,14 @@ positional parameter 1" echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout msg="**NO TROPICAL CYCLONE tcvitals processed --> non-fatal" set +x echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout # Copy null files into "${COMSP}syndata.tcvitals.$tmmark" and @@ -137,7 +137,7 @@ set +x echo echo "Run date is $CDATE10" echo -${TRACE_ON:-set -x} +restore_trace year=$(echo $CDATE10 | cut -c1-4) @@ -159,7 +159,7 @@ if [ $dateck_size -lt 10 ]; then echo 1900010100 > dateck set +x echo -e "\n${msg}\n" - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout fi @@ -188,7 +188,7 @@ if [ -n "$files_override" ]; then # for testing, typically want FILES=F fi set +x echo -e "\n${msg}\n" - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout fi @@ -273,21 +273,21 @@ set +x echo echo "The foreground exit status for SYNDAT_QCTROPCY is " $errqct echo -${TRACE_ON:-set -x} +restore_trace if [ "$errqct" -gt '0' ];then msg="**NON-FATAL ERROR PROGRAM SYNDAT_QCTROPCY RETURN CODE $errqct" set +x echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout msg="**NO TROPICAL CYCLONE tcvitals processed --> non-fatal" set +x echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout # In the event of a ERROR in PROGRAM SYNDAT_QCTROPCY, copy null files into @@ -311,7 +311,7 @@ echo "----------------------------------------------------------" echo "********** COMPLETED PROGRAM syndat_qctropcy **********" echo "----------------------------------------------------------" echo -${TRACE_ON:-set -x} +restore_trace if [ "$copy_back" = 'YES' ]; then cat lthistry>>$ARCHSYND/syndat_lthistry.$year @@ -356,7 +356,7 @@ $HOMENHC/tcvitals successfully updated by syndat_qctropcy" echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout fi @@ -368,7 +368,7 @@ not changed by syndat_qctropcy" echo echo $msg echo - ${TRACE_ON:-set -x} + restore_trace echo $msg >> $pgmout fi diff --git a/ush/tropcy_relocate.sh b/ush/tropcy_relocate.sh index e3a82efaf7c..4ab04cb2a4a 100755 --- a/ush/tropcy_relocate.sh +++ b/ush/tropcy_relocate.sh @@ -256,7 +256,7 @@ then echo "problem with obtaining date record;" echo "ABNORMAL EXIT!!!!!!!!!!!" echo - ${TRACE_ON:-set -x} + restore_trace if [ -s $DATA/err_exit ]; then $DATA/err_exit else @@ -274,7 +274,7 @@ set +x echo echo "CENTER DATE/TIME FOR RELOCATION PROCESSING IS $CDATE10" echo -${TRACE_ON:-set -x} +restore_trace #---------------------------------------------------------------------------- @@ -344,7 +344,7 @@ if [ $modhr -ne 0 ]; then not a multiple of 3-hrs;" echo "ABNORMAL EXIT!!!!!!!!!!!" echo - ${TRACE_ON:-set -x} + restore_trace if [ -s $DATA/err_exit ]; then $DATA/err_exit else @@ -367,14 +367,14 @@ echo " Get TCVITALS file valid for -$fhr hrs relative to center" echo " relocation processing date/time" echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" echo - ${TRACE_ON:-set -x} + restore_trace $USHGETGES/getges.sh -e $envir_getges -n $network_getges \ -v $CDATE10 -f $fhr -t tcvges tcvitals.m${fhr} set +x echo echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" echo - ${TRACE_ON:-set -x} + restore_trace fi done @@ -417,7 +417,7 @@ echo " Get global sigma GUESS valid for $fhr hrs relative to center" echo " relocation processing date/time" echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" echo - ${TRACE_ON:-set -x} + restore_trace $USHGETGES/getges.sh -e $envir_getges -n $network_getges \ -v $CDATE10 -t $stype $sges errges=$? @@ -429,7 +429,7 @@ echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" to center relocation date/time;" echo "ABNORMAL EXIT!!!!!!!!!!!" echo - ${TRACE_ON:-set -x} + restore_trace if [ -s $DATA/err_exit ]; then $DATA/err_exit else @@ -461,7 +461,7 @@ to center relocation date/time;" echo echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" echo - ${TRACE_ON:-set -x} + restore_trace fi if [ ! -s $pges ]; then set +x @@ -471,7 +471,7 @@ echo " Get global pressure grib GUESS valid for $fhr hrs relative to center" echo " relocation processing date/time" echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" echo - ${TRACE_ON:-set -x} + restore_trace $USHGETGES/getges.sh -e $envir_getges -n $network_getges \ -v $CDATE10 -t $ptype $pges errges=$? @@ -483,7 +483,7 @@ echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" relative to center relocation date/time;" echo "ABNORMAL EXIT!!!!!!!!!!!" echo - ${TRACE_ON:-set -x} + restore_trace if [ -s $DATA/err_exit ]; then $DATA/err_exit else @@ -496,7 +496,7 @@ relative to center relocation date/time;" echo echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" echo - ${TRACE_ON:-set -x} + restore_trace fi done @@ -568,7 +568,7 @@ else echo "$USHRELO/tropcy_relocate_extrkr.sh failed" echo "ABNORMAL EXIT!!!!!!!!!!!" echo - ${TRACE_ON:-set -x} + restore_trace if [ -s $DATA/err_exit ]; then $DATA/err_exit "Script $USHRELO/tropcy_relocate_extrkr.sh failed" else @@ -651,7 +651,7 @@ else # check for success # ----------------- - echo; ${TRACE_ON:-set -x} + echo; restore_trace if [ "$errSTATUS" -gt '0' ]; then if [ -s $DATA/err_exit ]; then $DATA/err_exit "Script RELOCATE_GES failed" diff --git a/ush/tropcy_relocate_extrkr.sh b/ush/tropcy_relocate_extrkr.sh index 79295cead0a..dab8e3d6f75 100755 --- a/ush/tropcy_relocate_extrkr.sh +++ b/ush/tropcy_relocate_extrkr.sh @@ -239,7 +239,7 @@ cmodel=$(echo ${cmodel} | tr "[A-Z]" "[a-z]") case ${cmodel} in - gdas) set +x; echo " "; echo " ++ operational GDAS chosen"; ${TRACE_ON:-set -x}; + gdas) set +x; echo " "; echo " ++ operational GDAS chosen"; restore_trace; fcstlen=9 ; fcsthrs="" for fhr in $( seq 0 $BKGFREQ 9); do @@ -272,48 +272,48 @@ case ${cmodel} in # jpdtn=0 for deterministic data. g2_jpdtn=0 model=8;; - gfs) set +x; echo " "; echo " ++ operational GFS chosen"; ${TRACE_ON:-set -x}; + gfs) set +x; echo " "; echo " ++ operational GFS chosen"; restore_trace; fcsthrsgfs=' 00 06 12 18 24 30 36 42 48 54 60 66 72 78'; gfsdir=$COMIN; gfsgfile=gfs.t${dishh}z.pgrbf; model=1;; - mrf) set +x; echo " "; echo " ++ operational MRF chosen"; ${TRACE_ON:-set -x}; + mrf) set +x; echo " "; echo " ++ operational MRF chosen"; restore_trace; fcsthrsmrf=' 00 12 24 36 48 60 72'; mrfdir=$COMIN; mrfgfile=drfmr.t${dishh}z.pgrbf; model=2;; - ukmet) set +x; echo " "; echo " ++ operational UKMET chosen"; ${TRACE_ON:-set -x}; + ukmet) set +x; echo " "; echo " ++ operational UKMET chosen"; restore_trace; fcsthrsukmet=' 00 12 24 36 48 60 72'; ukmetdir=$COMIN; ukmetgfile=ukmet.t${dishh}z.ukmet; model=3;; - ecmwf) set +x; echo " "; echo " ++ operational ECMWF chosen"; ${TRACE_ON:-set -x}; + ecmwf) set +x; echo " "; echo " ++ operational ECMWF chosen"; restore_trace; fcsthrsecmwf=' 00 24 48 72'; ecmwfdir=$COMIN; ecmwfgfile=ecmgrb25.t12z; model=4;; - ngm) set +x; echo " "; echo " ++ operational NGM chosen"; ${TRACE_ON:-set -x}; + ngm) set +x; echo " "; echo " ++ operational NGM chosen"; restore_trace; fcsthrsngm=' 00 06 12 18 24 30 36 42 48'; ngmdir=$COMIN; ngmgfile=ngm.t${dishh}z.pgrb.f; model=5;; - nam) set +x; echo " "; echo " ++ operational Early NAM chosen"; ${TRACE_ON:-set -x}; + nam) set +x; echo " "; echo " ++ operational Early NAM chosen"; restore_trace; fcsthrsnam=' 00 06 12 18 24 30 36 42 48'; namdir=$COMIN; namgfile=nam.t${dishh}z.awip32; model=6;; - ngps) set +x; echo " "; echo " ++ operational NAVGEM chosen"; ${TRACE_ON:-set -x}; + ngps) set +x; echo " "; echo " ++ operational NAVGEM chosen"; restore_trace; fcsthrsngps=' 00 12 24 36 48 60 72'; #ngpsdir=/com/hourly/prod/hourly.${CENT}${symd}; ngpsdir=$OMIN; ngpsgfile=fnoc.t${dishh}z; model=7;; other) set +x; echo " "; echo " Model selected by user is ${cmodel}, which is a "; - echo "user-defined model, NOT operational...."; echo " "; ${TRACE_ON:-set -x}; + echo "user-defined model, NOT operational...."; echo " "; restore_trace; model=9;; *) set +x; echo " "; echo " !!! Model selected is not recognized."; echo " Model= ---> ${cmodel} <--- ..... Please submit the script again...."; - echo " "; ${TRACE_ON:-set -x}; exit 8;; + echo " "; restore_trace; exit 8;; esac @@ -377,7 +377,7 @@ if [ ${cmodel} = 'other' ]; then echo " replace the forecast hour characters 00 with XX. Please check the" echo " name in the kickoff script and qsub it again. Exiting....." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -400,7 +400,7 @@ if [ ${cmodel} = 'other' ]; then echo " " echo " !!! Exiting loop, only processing 14 forecast files ...." echo " " - ${TRACE_ON:-set -x} + restore_trace break fi @@ -415,7 +415,7 @@ if [ ${cmodel} = 'other' ]; then echo " " echo " +++ Found file ${fnamebeg}${fhour}${fnameend}" echo " " - ${TRACE_ON:-set -x} + restore_trace let fhrct=fhrct+1 else fflag='n' @@ -435,7 +435,7 @@ if [ ${cmodel} = 'other' ]; then echo " !!! Please check the directory to make sure the file" echo " !!! is there and then submit this job again." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -444,7 +444,7 @@ if [ ${cmodel} = 'other' ]; then echo " Max forecast hour is $maxhour" echo " List of forecast hours: $fcsthrsother" echo " " - ${TRACE_ON:-set -x} + restore_trace # -------------------------------------------------- # In order for the fortran program to know how many @@ -526,7 +526,7 @@ if [ ${numvitrecs} -eq 0 ]; then echo "!!! It could just be that there are no storms for the current" echo "!!! time. Please check the dates and submit this job again...." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -574,7 +574,7 @@ pgm=$(basename $SUPVX) if [ -s $DATA/prep_step ]; then set +e . $DATA/prep_step - ${ERR_EXIT_ON:-set -eu} + restore_strict else [ -f errfile ] && rm errfile export XLFUNITS=0 @@ -613,14 +613,14 @@ set +x echo echo 'The foreground exit status for SUPVIT is ' $err echo -${TRACE_ON:-set -x} +restore_trace if [ $err -eq 0 ]; then set +x echo " " echo " Normal end for program supvitql (which updates TC vitals file)." echo " " - ${TRACE_ON:-set -x} + restore_trace else set +x echo " " @@ -630,7 +630,7 @@ else echo "!!! model= ${cmodel}, forecast initial time = ${symd}${dishh}" echo "!!! Exiting...." echo " " - ${TRACE_ON:-set -x} + restore_trace fi if [ -s $DATA/err_chk ]; then $DATA/err_chk @@ -660,7 +660,7 @@ if [ ${numvitrecs} -eq 0 ]; then echo "!!! File ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} is empty." echo "!!! Please check the dates and submit this job again...." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -676,7 +676,7 @@ echo " Below is a list of the storms to be processed: " | tee -a storm_list echo " " | tee -a storm_list cat ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} | tee -a storm_list echo " " | tee -a storm_list -${TRACE_ON:-set -x} +restore_trace set +u [ -n "../$pgmout" ] && cat storm_list >> ../$pgmout @@ -729,7 +729,7 @@ echo " NOW CUTTING APART INPUT GRIB FILES TO " echo " CREATE 1 BIG GRIB INPUT FILE " echo " -----------------------------------------" echo " " -${TRACE_ON:-set -x} +restore_trace #grid='255 0 151 71 70000 190000 128 0000 340000 1000 1000 64' #grid='255 0 360 181 90000 0000 128 -90000 -1000 1000 1000 64' @@ -756,7 +756,7 @@ if [ ${model} -eq 5 ]; then echo " !!! in the analysis data." echo " *******************************************************************" echo " " - ${TRACE_ON:-set -x} + restore_trace fi if [ -s ${vdir}/ngmlatlon.pgrb.${symd}${dishh} ]; then @@ -772,7 +772,7 @@ if [ ${model} -eq 5 ]; then echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " !!! NGM File missing: ${ngmdir}/${ngmgfile}${fhour}" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - ${TRACE_ON:-set -x} + restore_trace continue fi if [ -s $TMPDIR/tmpixfile ]; then rm $TMPDIR/tmpixfile; fi @@ -783,7 +783,7 @@ if [ ${model} -eq 5 ]; then echo " " echo " Extracting NGM GRIB data for forecast hour = $fhour" echo " " - ${TRACE_ON:-set -x} + restore_trace g1=${ngmdir}/${ngmgfile}${fhour} @@ -807,7 +807,7 @@ if [ ${model} -eq 5 ]; then echo "!!! sure you've allocated enough memory for this job (error 134 using $COPYGB is " echo "!!! typically due to using more memory than you've allocated). Exiting....." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -846,7 +846,7 @@ if [ ${model} -eq 6 ]; then echo " !!! in the analysis data." echo " *******************************************************************" echo " " - ${TRACE_ON:-set -x} + restore_trace fi if [ -s ${vdir}/namlatlon.pgrb.${symd}${dishh} ]; then @@ -862,7 +862,7 @@ if [ ${model} -eq 6 ]; then echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " !!! Early NAM File missing: ${namdir}/${namgfile}${fhour}.tm00" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - ${TRACE_ON:-set -x} + restore_trace continue fi if [ -s $TMPDIR/tmpixfile ]; then rm $TMPDIR/tmpixfile; fi @@ -873,7 +873,7 @@ if [ ${model} -eq 6 ]; then echo " " echo " Extracting Early NAM GRIB data for forecast hour = $fhour" echo " " - ${TRACE_ON:-set -x} + restore_trace g1=${namdir}/${namgfile}${fhour}.tm00 @@ -898,7 +898,7 @@ if [ ${model} -eq 6 ]; then echo "!!! sure you've allocated enough memory for this job (error 134 using $COPYGB is " echo "!!! typically due to using more memory than you've allocated). Exiting....." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -946,7 +946,7 @@ if [ ${model} -eq 4 ]; then echo " " echo " !!! Due to missing ECMWF file, execution is ending...." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -989,7 +989,7 @@ if [ ${model} -eq 1 ]; then echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " !!! GFS File missing: ${gfsdir}/${gfsgfile}${fhour}" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - ${TRACE_ON:-set -x} + restore_trace continue fi @@ -1060,7 +1060,7 @@ if [ ${model} -eq 8 ]; then echo " !!! gdas File missing: $gfile" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " " - ${TRACE_ON:-set -x} + restore_trace continue fi @@ -1109,7 +1109,7 @@ if [ ${model} -eq 8 ]; then echo " !!! gdas File missing: $gfile" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " " - ${TRACE_ON:-set -x} + restore_trace continue fi @@ -1164,7 +1164,7 @@ if [ ${model} -eq 2 ]; then echo " !!! MRF File missing: ${mrfdir}/${mrfgfile}${fhour}" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " " - ${TRACE_ON:-set -x} + restore_trace continue fi @@ -1219,7 +1219,7 @@ if [ ${model} -eq 3 ]; then echo " !!! UKMET File missing: ${ukmetdir}/${ukmetgfile}${fhour}" echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " " - ${TRACE_ON:-set -x} + restore_trace continue fi @@ -1260,7 +1260,7 @@ if [ ${model} -eq 7 ]; then echo " " echo " !!! Due to missing NAVGEM file, execution is ending...." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -1335,7 +1335,7 @@ if [ ${model} -eq 9 ]; then echo "!!! Forecast File missing: ${otherdir}/${fnamebeg}00${fnameend}" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo " " - ${TRACE_ON:-set -x} + restore_trace continue fi @@ -1409,7 +1409,7 @@ if [ ${model} -eq 9 ]; then echo "!!! sure you've allocated enough memory for this job (error 134 using $COPYGB is " echo "!!! typically due to using more memory than you've allocated). Exiting....." echo " " - ${TRACE_ON:-set -x} + restore_trace exit 8 fi @@ -1440,9 +1440,9 @@ while [ $ist -le 15 ] do if [ ${stormflag[${ist}]} -ne 1 ] then - set +x; echo "Storm number $ist NOT selected for processing"; ${TRACE_ON:-set -x} + set +x; echo "Storm number $ist NOT selected for processing"; restore_trace else - set +x; echo "Storm number $ist IS selected for processing...."; ${TRACE_ON:-set -x} + set +x; echo "Storm number $ist IS selected for processing...."; restore_trace fi let ist=ist+1 done @@ -1561,7 +1561,7 @@ set +x echo echo 'The foreground exit status for GETTRK is ' $err echo -${TRACE_ON:-set -x} +restore_trace if [ -s $DATA/err_chk ]; then $DATA/err_chk diff --git a/ush/wave_grib2_sbs.sh b/ush/wave_grib2_sbs.sh index a4463156f64..e9614f4bc6b 100755 --- a/ush/wave_grib2_sbs.sh +++ b/ush/wave_grib2_sbs.sh @@ -46,7 +46,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_grib2 (COULD NOT CREATE TEMP DIRECTORY) *** ' echo '******************************************************************************* ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 fi @@ -81,7 +81,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '! Make GRIB files |' echo '+--------------------------------+' echo " Model ID : $WAV_MOD_TAG" - ${TRACE_ON:-set -x} + restore_trace if [ -z "$CDATE" ] || [ -z "$cycle" ] || [ -z "$EXECwave" ] || \ [ -z "$COMOUT" ] || [ -z "$WAV_MOD_TAG" ] || [ -z "$SENDCOM" ] || \ @@ -94,7 +94,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** EXPORTED VARIABLES IN postprocessor NOT SET ***' echo '***************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 fi @@ -108,7 +108,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Number of times : Single SBS echo " GRIB field flags : $gribflags" echo ' ' - ${TRACE_ON:-set -x} + restore_trace # 0.e Links to working directory @@ -122,7 +122,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Generate input file for ww3_grib2" - ${TRACE_ON:-set -x} + restore_trace sed -e "s/TIME/$tstart/g" \ -e "s/DT/$dtgrib/g" \ @@ -140,7 +140,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Run ww3_grib2" echo " Executing $EXECwave/ww3_grib" - ${TRACE_ON:-set -x} + restore_trace export pgm=ww3_grib;. prep_step $EXECwave/ww3_grib > grib2_${grdnam}_${FH3}.out 2>&1 @@ -153,7 +153,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_grib encoding *** ' echo '************************************************ ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -173,7 +173,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_grib2 *** ' echo '********************************************* ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -204,7 +204,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo " Error in moving grib file ${outfile} to com" echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 4 fi if [ ! -s $COMOUT/gridded/${outfile} ] @@ -217,7 +217,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo " Error in moving grib file ${outfile}.idx to com" echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 4 fi @@ -226,7 +226,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Alerting GRIB file as $COMOUT/gridded/${outfile}" echo " Alerting GRIB index file as $COMOUT/gridded/${outfile}.idx" - ${TRACE_ON:-set -x} + restore_trace $DBNROOT/bin/dbn_alert MODEL ${alertName}_WAVE_GB2 $job $COMOUT/gridded/${outfile} $DBNROOT/bin/dbn_alert MODEL ${alertName}_WAVE_GB2_WIDX $job $COMOUT/gridded/${outfile}.idx else @@ -241,7 +241,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Removing work directory after success." - ${TRACE_ON:-set -x} + restore_trace cd ../ mv -f ${gribDIR} done.${gribDIR} @@ -251,7 +251,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo " File ${COMOUT}/gridded/${outfile} found, skipping generation process" echo ' ' - ${TRACE_ON:-set -x} + restore_trace fi diff --git a/ush/wave_grid_interp_sbs.sh b/ush/wave_grid_interp_sbs.sh index 59a604d0f5c..3707c0f0ab1 100755 --- a/ush/wave_grid_interp_sbs.sh +++ b/ush/wave_grid_interp_sbs.sh @@ -48,7 +48,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_grid_interp (COULD NOT CREATE TEMP DIRECTORY) *** ' echo '************************************************************************************* ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 fi @@ -63,7 +63,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '! Make GRID files |' echo '+--------------------------------+' echo " Model ID : $WAV_MOD_TAG" - ${TRACE_ON:-set -x} + restore_trace if [ -z "$CDATE" ] || [ -z "$cycle" ] || [ -z "$EXECwave" ] || \ [ -z "$COMOUT" ] || [ -z "$WAV_MOD_TAG" ] || [ -z "$SENDCOM" ] || \ @@ -76,7 +76,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '***************************************************' echo ' ' echo "$CDATE $cycle $EXECwave $COMOUT $WAV_MOD_TAG $SENDCOM $SENDDBN $waveGRD" - ${TRACE_ON:-set -x} + restore_trace exit 1 fi @@ -118,7 +118,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' ' echo " Copying $FIXwave/WHTGRIDINT.bin.${grdID} " - ${TRACE_ON:-set -x} + restore_trace cp $FIXwave/WHTGRIDINT.bin.${grdID} ${DATA} wht_OK='yes' else @@ -138,7 +138,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Run ww3_gint echo " Executing $EXECwave/ww3_gint - ${TRACE_ON:-set -x} + restore_trace export pgm=ww3_gint;. prep_step $EXECwave/ww3_gint 1> gint.${grdID}.out 2>&1 @@ -160,7 +160,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_gint interpolation * ' echo '*************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -176,14 +176,14 @@ source "$HOMEgfs/ush/preamble.sh" then set +x echo " Saving GRID file as $COMOUT/rundata/$WAV_MOD_TAG.out_grd.$grdID.${CDATE}" - ${TRACE_ON:-set -x} + restore_trace cp ${DATA}/output_${ymdh}0000/out_grd.$grdID $COMOUT/rundata/$WAV_MOD_TAG.out_grd.$grdID.${CDATE} # if [ "$SENDDBN" = 'YES' ] # then # set +x # echo " Alerting GRID file as $COMOUT/rundata/$WAV_MOD_TAG.out_grd.$grdID.${CDATE} -# ${TRACE_ON:-set -x} +# restore_trace # # PUT DBNET ALERT HERE .... diff --git a/ush/wave_grid_moddef.sh b/ush/wave_grid_moddef.sh index 80c041df37c..b1f1307c22e 100755 --- a/ush/wave_grid_moddef.sh +++ b/ush/wave_grid_moddef.sh @@ -38,7 +38,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '+--------------------------------+' echo " Grid : $1" echo ' ' - ${TRACE_ON:-set -x} + restore_trace # 0.b Check if grid set @@ -50,7 +50,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** Grid not identifife in ww3_mod_def.sh ***' echo '**************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 else grdID=$1 @@ -67,7 +67,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** EXPORTED VARIABLES IN ww3_mod_def.sh NOT SET ***' echo '*********************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 2 fi @@ -79,7 +79,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' Creating mod_def file ...' echo " Executing $EXECwave/ww3_grid" echo ' ' - ${TRACE_ON:-set -x} + restore_trace rm -f ww3_grid.inp ln -sf ../ww3_grid.inp.$grdID ww3_grid.inp @@ -95,7 +95,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_grid *** ' echo '******************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -110,7 +110,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : MOD DEF FILE NOT FOUND *** ' echo '******************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 4 fi diff --git a/ush/wave_outp_cat.sh b/ush/wave_outp_cat.sh index 7adf77dbf0c..10879db63c1 100755 --- a/ush/wave_outp_cat.sh +++ b/ush/wave_outp_cat.sh @@ -38,7 +38,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** LOCATION ID IN ww3_outp_spec.sh NOT SET ***' echo '***********************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 else buoy=$bloc @@ -56,7 +56,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** EXPORTED VARIABLES IN ww3_outp_cat.sh NOT SET ***' echo '******************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -66,7 +66,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Generate input file for ww3_outp." - ${TRACE_ON:-set -x} + restore_trace if [ "$specdir" = "bull" ] then @@ -113,7 +113,7 @@ source "$HOMEgfs/ush/preamble.sh" echo "*** FATAL ERROR : OUTPUT DATA FILE FOR BOUY $bouy at ${ymdh} NOT FOUND *** " echo '************************************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=2; export err;${errchk} exit $err fi @@ -137,7 +137,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " FATAL ERROR : OUTPUTFILE ${outfile} not created " echo '*************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace err=2; export err;${errchk} exit $err fi diff --git a/ush/wave_outp_spec.sh b/ush/wave_outp_spec.sh index a652d36745e..38cb0dfd390 100755 --- a/ush/wave_outp_spec.sh +++ b/ush/wave_outp_spec.sh @@ -45,7 +45,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_outp_spec (COULD NOT CREATE TEMP DIRECTORY) *** ' echo '****************************************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 fi @@ -57,7 +57,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '! Make spectral file |' echo '+--------------------------------+' echo " Model ID : $WAV_MOD_TAG" - ${TRACE_ON:-set -x} + restore_trace # 0.b Check if buoy location set @@ -69,7 +69,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** LOCATION ID IN ww3_outp_spec.sh NOT SET ***' echo '***********************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 else buoy=$bloc @@ -84,7 +84,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Location ID/# : $buoy (${point})" echo " Spectral output start time : $ymdh " echo ' ' - ${TRACE_ON:-set -x} + restore_trace break fi done < tmp_list.loc @@ -95,7 +95,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** LOCATION ID IN ww3_outp_spec.sh NOT RECOGNIZED ***' echo '******************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 2 fi fi @@ -113,7 +113,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** EXPORTED VARIABLES IN ww3_outp_spec.sh NOT SET ***' echo '******************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -125,7 +125,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Output starts at $tstart." echo ' ' - ${TRACE_ON:-set -x} + restore_trace # 0.e sync important files @@ -144,7 +144,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Generate input file for ww3_outp." - ${TRACE_ON:-set -x} + restore_trace if [ "$specdir" = "bull" ] then @@ -171,7 +171,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Executing $EXECwave/ww3_outp" - ${TRACE_ON:-set -x} + restore_trace export pgm=ww3_outp;. prep_step $EXECwave/ww3_outp 1> outp_${specdir}_${buoy}.out 2>&1 @@ -186,7 +186,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : ERROR IN ww3_outp *** ' echo '******************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 4 fi @@ -230,7 +230,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : OUTPUT DATA FILE FOR BOUY $bouy NOT FOUND *** ' echo '***************************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 5 fi diff --git a/ush/wave_prnc_ice.sh b/ush/wave_prnc_ice.sh index 16473dbd1f2..74ac63245c7 100755 --- a/ush/wave_prnc_ice.sh +++ b/ush/wave_prnc_ice.sh @@ -51,7 +51,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " Ice grid ID : $WAVEICE_FID" echo " Ice file : $WAVICEFILE" echo ' ' - ${TRACE_ON:-set -x} + restore_trace echo "Making ice fields." if [ -z "$YMDH" ] || [ -z "$cycle" ] || \ @@ -66,7 +66,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '**************************************************' echo ' ' exit 1 - ${TRACE_ON:-set -x} + restore_trace echo "NON-FATAL ERROR - EXPORTED VARIABLES IN preprocessor NOT SET" fi @@ -89,7 +89,7 @@ source "$HOMEgfs/ush/preamble.sh" then set +x echo " ice.grib copied ($file)." - ${TRACE_ON:-set -x} + restore_trace else set +x echo ' ' @@ -97,7 +97,7 @@ source "$HOMEgfs/ush/preamble.sh" echo "*** FATAL ERROR: NO ICE FILE $file *** " echo '************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace echo "FATAL ERROR - NO ICE FILE (GFS GRIB)" exit 2 fi @@ -108,7 +108,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' Extracting data from ice.grib ...' - ${TRACE_ON:-set -x} + restore_trace $WGRIB2 ice.grib -netcdf icean_5m.nc 2>&1 > wgrib.out @@ -124,7 +124,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** ERROR IN UNPACKING GRIB ICE FILE *** ' echo '**************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace echo "ERROR IN UNPACKING GRIB ICE FILE." exit 3 fi @@ -139,7 +139,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' Run through preprocessor ...' echo ' ' - ${TRACE_ON:-set -x} + restore_trace cp -f ${DATA}/ww3_prnc.ice.$WAVEICE_FID.inp.tmpl ww3_prnc.inp @@ -157,7 +157,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** WARNING: NON-FATAL ERROR IN ww3_prnc *** ' echo '******************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace echo "WARNING: NON-FATAL ERROR IN ww3_prnc." exit 4 fi @@ -180,7 +180,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo " Saving ice.ww3 as $COMOUT/rundata/${icefile}" - ${TRACE_ON:-set -x} + restore_trace cp ice.ww3 $COMOUT/rundata/${icefile} rm -f ice.ww3 diff --git a/ush/wave_tar.sh b/ush/wave_tar.sh index 452601dceb4..0b5a1edb8f3 100755 --- a/ush/wave_tar.sh +++ b/ush/wave_tar.sh @@ -42,7 +42,7 @@ source "$HOMEgfs/ush/preamble.sh" echo " ID : $1" echo " Type : $2" echo " Number of files : $3" - ${TRACE_ON:-set -x} + restore_trace # 0.b Check if type set @@ -55,7 +55,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** VARIABLES IN ww3_tar.sh NOT SET ***' echo '********************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 1 else ID=$1 @@ -85,7 +85,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** EXPORTED VARIABLES IN ww3_tar.sh NOT SET ***' echo '*****************************************************' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 2 fi @@ -97,7 +97,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' ' echo ' Making tar file ...' - ${TRACE_ON:-set -x} + restore_trace count=0 countMAX=5 @@ -121,7 +121,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : TAR CREATION FAILED *** ' echo '***************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -132,7 +132,7 @@ source "$HOMEgfs/ush/preamble.sh" else set +x echo ' All files not found for tar. Sleeping 10 seconds and trying again ..' - ${TRACE_ON:-set -x} + restore_trace sleep 10 count=$(expr $count + 1) fi @@ -147,7 +147,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : TAR CREATION FAILED *** ' echo '***************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 3 fi @@ -167,7 +167,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : SPECTRAL TAR COMPRESSION FAILED *** ' echo '***************************************************** ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 4 fi fi @@ -181,7 +181,7 @@ source "$HOMEgfs/ush/preamble.sh" set +x echo ' ' echo " Moving tar file ${file_name} to $COMOUT ..." - ${TRACE_ON:-set -x} + restore_trace cp ${file_name} $COMOUT/station/. @@ -195,7 +195,7 @@ source "$HOMEgfs/ush/preamble.sh" echo '*** FATAL ERROR : TAR COPY FAILED *** ' echo '************************************* ' echo ' ' - ${TRACE_ON:-set -x} + restore_trace exit 4 fi @@ -205,7 +205,7 @@ source "$HOMEgfs/ush/preamble.sh" echo ' ' echo " Alerting TAR file as $COMOUT/station/${file_name}" echo ' ' - ${TRACE_ON:-set -x} + restore_trace $DBNROOT/bin/dbn_alert MODEL ${alertName}_WAVE_TAR $job $COMOUT/station/${file_name} fi