diff --git a/.gitignore b/.gitignore index f83211291ef..1ab98a5adcc 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ parm/post/post_tag_gfs128 parm/post/gfs parm/post/gefs parm/post/sfs +parm/post/gcafs parm/post/ocean.csv parm/post/ocean_gefs.csv parm/post/ocean_gfs.csv @@ -96,9 +97,11 @@ parm/ufs/MOM6_data_table.IN parm/ufs/ice_in.IN parm/ufs/ufs.configure.*.IN parm/ufs/post_itag_gfs +parm/ufs/post_itag_gcafs parm/ufs/ww3_shel.nml.IN parm/ufs/global_control.nml.IN parm/regrid_sfc +parm/chem/nexus # Ignore sorc and logs folders from externals #-------------------------------------------- diff --git a/.shellcheckrc b/.shellcheckrc index 67fabfe1576..fc9aa26124b 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -17,3 +17,6 @@ disable=SC2174 # Disable warning of functions in test statements disable=SC2310 + +# Disable masking of return codes from chained commands. Use `set -o pipefail` to trap them. +disable=SC2312 diff --git a/dev/ci/scripts/run_check_ci.sh b/dev/ci/scripts/run_check_ci.sh index f1be7b92de4..f310cc7d059 100755 --- a/dev/ci/scripts/run_check_ci.sh +++ b/dev/ci/scripts/run_check_ci.sh @@ -71,7 +71,6 @@ while true; do # Get job statistics echo "Gather Rocoto statistics" - # shellcheck disable=SC2312 # We want to use the exit code of the command full_state=$("${HOMEgfs}/dev/ci/scripts/utils/rocotostat.py" -w "${xml}" -d "${db}" -v) error_stat=$? diff --git a/dev/ci/scripts/utils/ci_utils.sh b/dev/ci/scripts/utils/ci_utils.sh index 41a61ad2271..ca59cd30251 100755 --- a/dev/ci/scripts/utils/ci_utils.sh +++ b/dev/ci/scripts/utils/ci_utils.sh @@ -253,7 +253,6 @@ function delete_dataroot() { _runtests="${1}" _pslot="${2}" - # shellcheck disable=SC2312 eval "$( PDY=0 cyc=0 source "${_runtests}/EXPDIR/${_pslot}/config.base" >&/dev/null echo _dataroot="${STMP}/RUNDIRS/${_pslot}" diff --git a/dev/job_cards/rocoto/prep.sh b/dev/job_cards/rocoto/prep.sh index 59df45e563e..578b5bbf0f6 100755 --- a/dev/job_cards/rocoto/prep.sh +++ b/dev/job_cards/rocoto/prep.sh @@ -74,11 +74,9 @@ if [[ ! -s "${COMINobsproc_PREV}/${GDUMP}.t${gcyc}z.updated.status.tm00.bufr_d" fi fi # exception handling to ensure no dead link -# shellcheck disable=SC2312 if [[ $(find "${COMOUT_OBS}" -xtype l | wc -l) -ge 1 ]]; then exit 9 fi -# shellcheck disable=SC2312 if [[ $(find "${COMINobsproc_PREV}" -xtype l | wc -l) -ge 1 ]]; then exit 9 fi @@ -155,9 +153,10 @@ export COMSP=${COMSP:-"${COMIN_OBS}/${RUN_local}.t${cyc}z."} # Create or Copy prepbufr, prepbufr.acft_profiles, nsstbufr files # Do not fail on external errors if [[ ${MAKE_PREPBUFR:-"YES"} == "YES" ]]; then - set +eu + unset_strict "${HOMEobsproc}/jobs/JOBSPROC_GLOBAL_PREP" && true export err=$? + set_strict if [[ ${err} -ne 0 ]]; then err_exit "JOBSPROC_GLOBAL_PREP job failed, ABORT!" fi diff --git a/dev/jobs/JGFS_ATMOS_CYCLONE_GENESIS b/dev/jobs/JGFS_ATMOS_CYCLONE_GENESIS index 8b6e87a3477..c5cddebce08 100755 --- a/dev/jobs/JGFS_ATMOS_CYCLONE_GENESIS +++ b/dev/jobs/JGFS_ATMOS_CYCLONE_GENESIS @@ -34,15 +34,14 @@ export JYYYY=${PDY:0:4} ############################################## # Do not fail on errors or unassigned variables in external code -set +eu +unset_strict "${SCRIPTens_tracker}/exgfs_tc_genesis.sh" && true export err=$? +set_strict if [[ ${err} -ne 0 ]]; then err_exit fi -set_strict - ############################################## # Final processing ############################################## diff --git a/dev/jobs/JGFS_ATMOS_VERIFICATION b/dev/jobs/JGFS_ATMOS_VERIFICATION index e15020e2aec..e15eac2f83e 100755 --- a/dev/jobs/JGFS_ATMOS_VERIFICATION +++ b/dev/jobs/JGFS_ATMOS_VERIFICATION @@ -29,13 +29,16 @@ done if [[ "${RUN_GRID2GRID_STEP1}" == "YES" || "${RUN_GRID2OBS_STEP1}" == "YES" || "${RUN_PRECIP_STEP1}" == "YES" ]]; then # Override the -e in VERIF_GLOBALSH's shebang and un-export SHELLOPTS # TODO: clean up the verif-global script so it does not raise false-positive errors - set +eu + unset_strict export -n SHELLOPTS bash -x "${VERIF_GLOBALSH}" err=$? + set_strict if [[ ${err} -ne 0 ]]; then exit "${err}" fi fi -if [[ ${KEEPDATA:-"NO"} == "NO" ]]; then rm -rf "${DATAROOT}"; fi # TODO: This should be $DATA +if [[ ${KEEPDATA:-"NO"} == "NO" ]]; then + rm -rf "${DATAROOT}" # TODO: This should be $DATA +fi diff --git a/dev/jobs/JGLOBAL_ARCHIVE_TARS b/dev/jobs/JGLOBAL_ARCHIVE_TARS index 67b45b993ab..4b059b930d2 100755 --- a/dev/jobs/JGLOBAL_ARCHIVE_TARS +++ b/dev/jobs/JGLOBAL_ARCHIVE_TARS @@ -80,17 +80,15 @@ fi # Run archive script ############################################################### -set +eu # Do not export shell opts to the bash scripts in the htar/hsi wrappers export -n SHELLOPTS +unset_strict ${GLOBALARCHIVESH:-${SCRgfs}/exglobal_archive_tars.py} export err=$? -set +x +set_strict if [[ ${err} -ne 0 ]]; then err_exit "failed to archive the COM structure" fi -set_trace -set_strict ############################################## # End JOB SPECIFIC work @@ -106,10 +104,7 @@ fi ########################################## # Remove the Temporary working directory ########################################## -cd "${DATAROOT}" || ( - echo "${DATAROOT} does not exist. ABORT!" - exit 1 -) +cd "${DATAROOT}" || true if [[ "${KEEPDATA}" == "NO" ]]; then rm -rf "${DATA}" fi diff --git a/dev/jobs/JGLOBAL_ATMENS_ANALYSIS_FINALIZE b/dev/jobs/JGLOBAL_ATMENS_ANALYSIS_FINALIZE index 79ff131257a..6e39de57c88 100755 --- a/dev/jobs/JGLOBAL_ATMENS_ANALYSIS_FINALIZE +++ b/dev/jobs/JGLOBAL_ATMENS_ANALYSIS_FINALIZE @@ -45,13 +45,7 @@ fi ########################################## # Remove the Temporary working directory ########################################## -cd "${DATAROOT}" && true -export err=$? -set +e -if [[ ${err} -ne 0 ]]; then - err_exit "${DATAROOT} does not exist, ABORT!" -fi -set_trace +cd "${DATAROOT}" || true if [[ "${KEEPDATA}" == "NO" ]]; then rm -rf "${DATA}" fi diff --git a/dev/jobs/JGLOBAL_ATMOS_ANALYSIS_CALC_FV3JEDI b/dev/jobs/JGLOBAL_ATMOS_ANALYSIS_CALC_FV3JEDI index e343fd235ca..1af6a422b3d 100755 --- a/dev/jobs/JGLOBAL_ATMOS_ANALYSIS_CALC_FV3JEDI +++ b/dev/jobs/JGLOBAL_ATMOS_ANALYSIS_CALC_FV3JEDI @@ -2,7 +2,6 @@ # Ignore possible spelling error (nothing is misspelled) # shellcheck disable=SC2153 -# shellcheck disable=SC2312 source "${HOMEgfs}/ush/jjob_header.sh" -e "analcalc_fv3jedi" -c "base analcalc_fv3jedi" diff --git a/dev/jobs/JGLOBAL_ENKF_ARCHIVE_TARS b/dev/jobs/JGLOBAL_ENKF_ARCHIVE_TARS index 2e22ada681b..bad4e6a9633 100755 --- a/dev/jobs/JGLOBAL_ENKF_ARCHIVE_TARS +++ b/dev/jobs/JGLOBAL_ENKF_ARCHIVE_TARS @@ -23,16 +23,14 @@ mkdir -p "${COMIN_CONF}" ############################################################### # Calls an external bash command; do not fail on unassigned/error -set +eu export -n SHELLOPTS +unset_strict "${SCRgfs}/exglobal_enkf_earc_tars.py" export err=$? -set +x +set_strict if [[ ${err} -ne 0 ]]; then err_exit "Failed to archive the ensemble COM structure" fi -set_trace -set_strict ############################################################### @@ -50,10 +48,7 @@ fi ########################################## # Remove the Temporary working directory ########################################## -cd "${DATAROOT}" || ( - echo "${DATAROOT} does not exist. ABORT!" - exit 1 -) +cd "${DATAROOT}" || true if [[ "${KEEPDATA}" == "NO" ]]; then rm -rf "${DATA}" fi diff --git a/dev/parm/config/gefs/config.resources.AZUREPW b/dev/parm/config/gefs/config.resources.AZUREPW index a3065bd017a..513699163b3 100644 --- a/dev/parm/config/gefs/config.resources.AZUREPW +++ b/dev/parm/config/gefs/config.resources.AZUREPW @@ -6,7 +6,6 @@ export is_exclusive="True" unset memory -# shellcheck disable=SC2312 for mem_var in $(env | grep '^memory_' | cut -d= -f1); do unset "${mem_var}" done diff --git a/dev/parm/config/gefs/config.resources.GOOGLEPW b/dev/parm/config/gefs/config.resources.GOOGLEPW index 8a148965068..934e9a94a32 100644 --- a/dev/parm/config/gefs/config.resources.GOOGLEPW +++ b/dev/parm/config/gefs/config.resources.GOOGLEPW @@ -6,7 +6,6 @@ export is_exclusive="True" unset memory -# shellcheck disable=SC2312 for mem_var in $(env | grep '^memory_' | cut -d= -f1); do unset "${mem_var}" done diff --git a/dev/parm/config/gfs/config.ecen b/dev/parm/config/gfs/config.ecen index 933ccbd9060..105f186b10a 100644 --- a/dev/parm/config/gfs/config.ecen +++ b/dev/parm/config/gfs/config.ecen @@ -13,7 +13,6 @@ source "${EXPDIR}/config.resources" ecen # below queries IAUFHRS_ENKF to determine NECENGRP export NECENGRP=1 if [[ ${DOIAU_ENKF} = "YES" ]]; then - # shellcheck disable=SC2312 ngrps=$(grep -o ',' <<<"${IAUFHRS_ENKF}" | grep -c .) ((ngrps++)) export NECENGRP=${ngrps} diff --git a/dev/parm/config/gfs/config.resources.AZUREPW b/dev/parm/config/gfs/config.resources.AZUREPW index a3065bd017a..513699163b3 100644 --- a/dev/parm/config/gfs/config.resources.AZUREPW +++ b/dev/parm/config/gfs/config.resources.AZUREPW @@ -6,7 +6,6 @@ export is_exclusive="True" unset memory -# shellcheck disable=SC2312 for mem_var in $(env | grep '^memory_' | cut -d= -f1); do unset "${mem_var}" done diff --git a/dev/parm/config/gfs/config.resources.GOOGLEPW b/dev/parm/config/gfs/config.resources.GOOGLEPW index 8a148965068..934e9a94a32 100644 --- a/dev/parm/config/gfs/config.resources.GOOGLEPW +++ b/dev/parm/config/gfs/config.resources.GOOGLEPW @@ -6,7 +6,6 @@ export is_exclusive="True" unset memory -# shellcheck disable=SC2312 for mem_var in $(env | grep '^memory_' | cut -d= -f1); do unset "${mem_var}" done diff --git a/dev/scripts/exgdas_atmos_verfrad.sh b/dev/scripts/exgdas_atmos_verfrad.sh index 7fe7dbc0934..034d7067720 100755 --- a/dev/scripts/exgdas_atmos_verfrad.sh +++ b/dev/scripts/exgdas_atmos_verfrad.sh @@ -18,7 +18,7 @@ ################################################################################ # Do not exit on errors so that restricted data can be protected -set +eu +unset_strict if [[ ! -s "${radstat}" || ! -s "${biascr}" ]]; then export err=1 @@ -102,7 +102,6 @@ for type in ${SATYPE}; do netcdf=1 fi - # shellcheck disable=SC2312 if [[ $(find . -maxdepth 1 -type f -name "diag_${type}_ges.${PDY}${cyc}*.${Z}" | wc -l) -gt 0 ]]; then mv "diag_${type}_ges.${PDY}${cyc}"*".${Z}" "${type}.${Z}" ${UNCOMPRESS} "./${type}.${Z}" @@ -111,7 +110,6 @@ for type in ${SATYPE}; do fi if [[ ${USE_ANL} -eq 1 ]]; then - # shellcheck disable=SC2312 file_count=$(find . -maxdepth 1 -type f -name "diag_${type}_anl.${PDY}${cyc}*.${Z}" | wc -l) if [[ ${file_count} -gt 0 ]]; then mv "diag_${type}_anl.${PDY}${cyc}"*".${Z}" "${type}_anl.${Z}" diff --git a/dev/scripts/exgfs_atmos_awips_20km_1p0deg.sh b/dev/scripts/exgfs_atmos_awips_20km_1p0deg.sh index 267a0623791..9989b0db0b3 100755 --- a/dev/scripts/exgfs_atmos_awips_20km_1p0deg.sh +++ b/dev/scripts/exgfs_atmos_awips_20km_1p0deg.sh @@ -82,7 +82,6 @@ export opt28=' -new_grid_interpolation budget -fi ' cpreq "${COMIN_ATMOS_GRIB_0p25}/gfs.t${cyc}z.pres_a.0p25.f${fcsthr}.grib2" "tmpfile2${fcsthr}" cpreq "${COMIN_ATMOS_GRIB_0p25}/gfs.t${cyc}z.pres_b.0p25.f${fcsthr}.grib2" "tmpfile2b${fcsthr}" cat "tmpfile2${fcsthr}" "tmpfile2b${fcsthr}" > "tmpfile${fcsthr}" -# shellcheck disable=SC2312 ${WGRIB2} "tmpfile${fcsthr}" | grep -F -f "${PARMgfs}/product/gfs_awips_parmlist_g2" | ${WGRIB2} -i -grib masterfile "tmpfile${fcsthr}" && true export err=$? @@ -91,7 +90,6 @@ if [[ ${err} -ne 0 ]]; then fi ${WGRIB2} masterfile -match ":PWAT:entire atmosphere" -grib gfs_pwat.grb -# shellcheck disable=SC2312 ${WGRIB2} masterfile | grep -v ":PWAT:entire atmosphere" | ${WGRIB2} -i -grib temp_gfs masterfile ################################################################## # Process to change PWAT from level 200 to 10 (Entire Atmosphere) @@ -156,7 +154,6 @@ for GRID in conus ak prico pac 003; do # NOTE: numparm is the total of fields in grib2_awpgfs_20km_conusf000 file ########################################################################### numparm=247 - # shellcheck disable=SC2312 numrec=$(${WGRIB2} "awps_file_f${fcsthr}_${GRID}" | wc -l) if [[ ${numrec} -lt ${numparm} ]]; then diff --git a/dev/scripts/exgfs_atmos_fbwind.sh b/dev/scripts/exgfs_atmos_fbwind.sh index 2c76bb097c4..33aa30c90c0 100755 --- a/dev/scripts/exgfs_atmos_fbwind.sh +++ b/dev/scripts/exgfs_atmos_fbwind.sh @@ -38,7 +38,6 @@ for fhr3 in 006 012 024; do cpreq "${COMIN_ATMOS_GRIB_0p25}/gfs.${cycle}.pres_a.0p25.f${fhr3}.grib2" "tmp_pgrb2_0p25${fhr3}" cpreq "${COMIN_ATMOS_GRIB_0p25}/gfs.${cycle}.pres_b.0p25.f${fhr3}.grib2" "tmp_pgrb2b_0p25${fhr3}" cat "tmp_pgrb2_0p25${fhr3}" "tmp_pgrb2b_0p25${fhr3}" > "tmp0p25filef${fhr3}" - # shellcheck disable=SC2312 ${WGRIB2} "tmp0p25filef${fhr3}" | grep -F -f "${PARMgfs}/product/gfs_fbwnd_parmlist_g2" | ${WGRIB2} -i -grib "tmpfilef${fhr3}" "tmp0p25filef${fhr3}" ${CNVGRIB} -g21 "tmpfilef${fhr3}" "gfs.t${cyc}z.grbf${fhr3}_grb1" diff --git a/dev/scripts/exgfs_atmos_gempak_meta.sh b/dev/scripts/exgfs_atmos_gempak_meta.sh index 130913e918e..87f411d38b7 100755 --- a/dev/scripts/exgfs_atmos_gempak_meta.sh +++ b/dev/scripts/exgfs_atmos_gempak_meta.sh @@ -49,7 +49,6 @@ while [[ ${fhr} -le ${fhend} ]]; do if [[ ${do_all} -eq 1 ]]; then do_all=0 - # shellcheck disable=SC2312 awk '{print $1}' "${HOMEgfs}/gempak/fix/gfs_meta" | envsubst > "poescript" else # @@ -57,7 +56,6 @@ while [[ ${fhr} -le ${fhend} ]]; do # This will work as long as we don't need 12 fhr metafiles # if [[ ${fhr} -ne 12 ]]; then - # shellcheck disable=SC2312 grep "${fhr}" "${HOMEgfs}/gempak/fix/gfs_meta" | awk -F" [0-9]" '{print $1}' | envsubst > "poescript" fi fi diff --git a/dev/scripts/exgfs_atmos_goes_nawips.sh b/dev/scripts/exgfs_atmos_goes_nawips.sh index da085ca4ce1..323f8f7701b 100755 --- a/dev/scripts/exgfs_atmos_goes_nawips.sh +++ b/dev/scripts/exgfs_atmos_goes_nawips.sh @@ -21,8 +21,7 @@ done NAGRIB_TABLE="${HOMEgfs}/gempak/fix/nagrib.tbl" NAGRIB="${GEMEXE}/nagrib2" -# shellcheck disable=SC2312 -entry=$(grep "^${RUN2} " "${NAGRIB_TABLE}" | awk 'index($1,"#") != 1 {print $0}') +entry=$(grep "^${RUN2} " "${NAGRIB_TABLE}" | awk 'index($1,"#") != 1 {print $0}' || echo "") if [[ "${entry}" != "" ]]; then cpyfil=$(echo "${entry}" | awk 'BEGIN {FS="|"} {print $2}') @@ -61,7 +60,7 @@ startmsg ${NAGRIB} << EOF GBFILE = grib${fhr3} -INDXFL = +INDXFL = GDOUTF = ${GEMGRD} PROJ = ${proj} GRDAREA = ${grdarea} @@ -71,7 +70,7 @@ CPYFIL = ${cpyfil} GAREA = ${garea} OUTPUT = ${output} GBTBLS = ${gbtbls} -GBDIAG = +GBDIAG = PDSEXT = ${pdsext} l r diff --git a/dev/scripts/exgfs_atmos_grib2_special_npoess.sh b/dev/scripts/exgfs_atmos_grib2_special_npoess.sh index d1c37c56dd8..51ce9674539 100755 --- a/dev/scripts/exgfs_atmos_grib2_special_npoess.sh +++ b/dev/scripts/exgfs_atmos_grib2_special_npoess.sh @@ -110,7 +110,6 @@ for ((fhr = SHOUR; fhr <= FHOUR; fhr = fhr + FHINC)); do cpreq "${COMIN_ATMOS_GRIB_0p50}/gfs.t${cyc}z.pres_a.0p50.f${fhr3}.grib2" tmpfile2 cpreq "${COMIN_ATMOS_GRIB_0p50}/gfs.t${cyc}z.pres_b.0p50.f${fhr3}.grib2" tmpfile2b cat tmpfile2 tmpfile2b > tmpfile - # shellcheck disable=SC2312 ${WGRIB2} tmpfile | grep -F -f "${paramlist}" | ${WGRIB2} -i -grib pgb2file tmpfile && true export err=$? if [[ ${err} -ne 0 ]]; then diff --git a/dev/scripts/exgfs_wave_post_pnt.sh b/dev/scripts/exgfs_wave_post_pnt.sh index 6525a18339c..deea1f95123 100755 --- a/dev/scripts/exgfs_wave_post_pnt.sh +++ b/dev/scripts/exgfs_wave_post_pnt.sh @@ -86,7 +86,6 @@ if [[ -f "${PARMgfs}/wave/wave_${NET}.buoys" ]]; then cpreq -f "${PARMgfs}/wave/wave_${NET}.buoys" buoy.loc.temp if [[ "${DOBNDPNT_WAV}" == "YES" ]]; then #only do boundary points - # shellcheck disable=SC2312 sed -n '/^\$.*/!p' buoy.loc.temp | grep IBP > buoy.loc || { echo "WARNING: No boundary points found in buoy file ${PARMgfs}/wave/wave_${NET}.buoys" echo " Ending job without doing anything." @@ -94,7 +93,6 @@ if [[ -f "${PARMgfs}/wave/wave_${NET}.buoys" ]]; then } else #exclude boundary points - # shellcheck disable=SC2312 sed -n '/^\$.*/!p' buoy.loc.temp | grep -v IBP > buoy.loc fi fi @@ -182,7 +180,6 @@ if [[ ${err} -ne 0 && ! -f buoy_log.ww3 ]]; then fi # Create new buoy_log.ww3 -# shellcheck disable=SC2312 awk '{print $3}' buoy.loc | sed 's/'\''//g' > ibp_tags grep -F -f ibp_tags buoy_log.ww3 > buoy_log.tmp rm -f buoy_log.dat @@ -199,7 +196,6 @@ fi # 1.f Data summary -# shellcheck disable=SC2312 cat << EOF Input files read and processed at : $(date) @@ -219,11 +215,8 @@ EOF echo ' Making command file for wave post points ' -# shellcheck disable=SC2312 grep -F -f ibp_tags buoy_log.dat | awk '{ print $2 }' > buoys -# shellcheck disable=SC2312 grep -F -f buoys buoy_log.ww3 | awk '{ print $1 }' > points -# shellcheck disable=SC2312 points=$(awk '{print $0 "\\n"}' points | tr -d '\n') rm -f buoys diff --git a/dev/scripts/exgfs_wave_prdgen_bulls.sh b/dev/scripts/exgfs_wave_prdgen_bulls.sh index e1f89b217da..9d6140979e5 100755 --- a/dev/scripts/exgfs_wave_prdgen_bulls.sh +++ b/dev/scripts/exgfs_wave_prdgen_bulls.sh @@ -57,7 +57,6 @@ else fi # 1.b Output locations from bulletin files -# shellcheck disable=SC2312 Nb=$(find . -type f -name "*.cbull" -printf '.' | wc -c) echo ' ' echo " Number of bulletin files : ${Nb}" @@ -79,7 +78,6 @@ source awipsbull.data # 2.c Generate list of bulletins to process echo ' Generating buoy list ...' -# shellcheck disable=SC2312 bulls=$(sed -e 's/export b//g' -e 's/=/ /' awipsbull.data | grep -v "#" | awk '{print $1}') # 2.d Looping over buoys running formbul @@ -89,7 +87,6 @@ echo for bull in ${bulls}; do fname="${RUN}.${bull}.cbull" oname="awipsbull.${bull}.${cycle}.${RUN}.wave" - # shellcheck disable=SC2312 headr=$(grep "b${bull}=" awipsbull.data | sed 's/=/ /g' | awk '{ print $3}') echo "Processing ${bull} (${headr} ${oname}) ..." diff --git a/dev/scripts/exgfs_wave_prdgen_gridded.sh b/dev/scripts/exgfs_wave_prdgen_gridded.sh index 07ee67f5d49..22a6a506e06 100755 --- a/dev/scripts/exgfs_wave_prdgen_gridded.sh +++ b/dev/scripts/exgfs_wave_prdgen_gridded.sh @@ -98,12 +98,9 @@ while [[ "${fhcnt}" -le "${FHMAX_WAV}" ]]; do echo "${nip} ${prepar} ${paridx} ${npart}" rm -f temp.grib2 if [[ ${npart} -eq 0 ]]; then - #shellcheck disable=SC2312 ${WGRIB2} "${GRIBIN}" -s | grep ":${nip}" | "${WGRIB2}" -i "${GRIBIN}" -grib temp.grib2 > wgrib.out 2>&1 - #shellcheck disable=SC2312 ${WGRIB2} temp.grib2 -append -grib "${GRIBOUT}" else - #shellcheck disable=SC2312 ${WGRIB2} "${GRIBIN}" -s | grep ":${prepar}" | grep "${paridx} in sequence" | ${WGRIB2} -i "${GRIBIN}" -grib temp.grib2 > wgrib.out 2>&1 ${WGRIB2} temp.grib2 -append -grib "${GRIBOUT}" diff --git a/dev/scripts/exglobal_atmos_analysis.sh b/dev/scripts/exglobal_atmos_analysis.sh index a53153d97e8..31506dc2365 100755 --- a/dev/scripts/exglobal_atmos_analysis.sh +++ b/dev/scripts/exglobal_atmos_analysis.sh @@ -383,7 +383,6 @@ ${NLN} "${FIXgfs}/gsi/IASI_CLDDET.NL" IASI_CLDDET.NL #If using correlated error, link to the covariance files if [[ "${USE_CORRELATED_OBERRS}" == "YES" ]]; then if grep -q "Rcov" "${ANAVINFO}"; then - # shellcheck disable=SC2312 mapfile -t covfile_array < <(find "${FIXgfs}/gsi/" -name "Rcov*") if ((${#covfile_array[@]} > 0)); then for covfile in "${covfile_array[@]}"; do @@ -413,7 +412,6 @@ fi ############################################################## # CRTM Spectral and Transmittance coefficients mkdir -p crtm_coeffs -# shellcheck disable=SC2312 for file in $(awk '{if($1!~"!"){print $1}}' satinfo | sort | uniq); do if [[ ${file:0:4} == "hirs" ]]; then ${NLN} "${HIRS_FIX}/${file}.SpcCoeff.bin" "./crtm_coeffs/${file}.SpcCoeff.bin" @@ -528,10 +526,9 @@ fi ############################################################## # Required bias guess files -${NLN} "${GBIAS}" satbias_in -${NLN} "${GBIASPC}" satbias_pc -${NLN} "${GBIASAIR}" aircftbias_in -${NLN} "${GRADSTAT}" radstat.gdas +cpreq "${GBIAS}" satbias_in +cpreq "${GBIASPC}" satbias_pc +cpreq "${GBIASAIR}" aircftbias_in ############################################################## # Required model guess files @@ -645,7 +642,6 @@ fi # If requested, link (and if tarred, de-tar obsinput.tar) into obs_input.* files if [[ "${USE_SELECT}" == "YES" ]]; then rm -f obs_input.* - # shellcheck disable=SC2312 nl=$(file "${SELECT_OBS}" | cut -d: -f2 | grep -c tar) if [[ ${nl} -eq 1 ]]; then rm -f obsinput.tar @@ -663,8 +659,8 @@ fi ############################################################## # If requested, copy and de-tar guess radstat file if [[ "${USE_RADSTAT}" == "YES" ]]; then - rm -f "${DATA}/unzip_radstat.sh" - cat > "${DATA}/unzip_radstat.sh" << EOF + rm -f "${DATA}/unzip_diag.sh" + cat > "${DATA}/unzip_diag.sh" << EOF #!/bin/bash diag_file=\$1 diag_suffix=\$2 @@ -674,20 +670,21 @@ ${UNCOMPRESS} \$diag_file fnameges=\$(echo \$fname | sed 's/_ges//g') ${NMV} \$fname.\$fdate\$diag_suffix \$fnameges EOF - chmod 755 "${DATA}/unzip_radstat.sh" + chmod 755 "${DATA}/unzip_diag.sh" rm -f "${DATA}/cmdfile" - #shellcheck disable=SC2312 - listdiag=$(tar -xvf radstat.gdas | cut -d' ' -f2 | grep _ges) + cpreq "${GRADSTAT}" radstat.tar + tar -xvf radstat.tar + listdiag=$(find ./ -maxdepth 1 -path "./diag_*_ges.*" -type f) for type in ${listdiag}; do - diag_file=$(echo "${type}" | cut -d',' -f1) - echo "${DATA}/unzip_radstat.sh ${diag_file} ${DIAG_SUFFIX:-}.nc4" >> "${DATA}/cmdfile" + diag_file=$(basename "${type}") + echo "${DATA}/unzip_diag.sh ${diag_file} ${DIAG_SUFFIX:-}.nc4" >> "${DATA}/cmdfile" done "${USHgfs}/run_mpmd.sh" "${DATA}/cmdfile" && true export err=$? if [[ ${err} -ne 0 ]]; then - err_exit "Failed to unzip radstat.gdas file!" + err_exit "Failed to unzip rad diag file!" fi fi # if [[ $USE_RADSTAT == "YES" ] @@ -860,7 +857,6 @@ cat fort.2* > "${GSISTAT}" # If requested, create obsinput tarball from obs_input.* files if [[ ${RUN_SELECT} == "YES" ]]; then - # shellcheck disable=SC2312 echo "$(date) START tar obs_input" >&2 if [[ -s obsinput.tar ]]; then rm -f obsinput.tar @@ -871,7 +867,6 @@ if [[ ${RUN_SELECT} == "YES" ]]; then chmod 750 "${SELECT_OBS}" ${CHGRP_CMD} "${SELECT_OBS}" rm -f obsinput.tar - # shellcheck disable=SC2312 echo "$(date) END tar obs_input" >&2 fi @@ -907,7 +902,6 @@ if [[ "${GENDIAG}" == "YES" ]]; then cpfs gsidiags.tar "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}gsidiags${DIAG_SUFFIX:-}.tar" fi -# shellcheck disable=SC2312 echo "${rCDUMP} ${PDY}${cyc} atminc done at $(date)" > "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}increment.done.txt" ################################################################################ diff --git a/dev/scripts/exglobal_atmos_analysis_calc.sh b/dev/scripts/exglobal_atmos_analysis_calc.sh index 17f55fd75a6..3f3224c53b5 100755 --- a/dev/scripts/exglobal_atmos_analysis_calc.sh +++ b/dev/scripts/exglobal_atmos_analysis_calc.sh @@ -177,7 +177,6 @@ if [[ "${DOGAUSFCANL}" == "YES" ]]; then fi fi -# shellcheck disable=SC2312 echo "${rCDUMP} ${PDY}${cyc} atmanl and sfcanl done at $(date)" > "${COMOUT_ATMOS_ANALYSIS}/${APREFIX}analysis.done.txt" ################################################################################ diff --git a/dev/scripts/exglobal_atmos_products.sh b/dev/scripts/exglobal_atmos_products.sh index 24f0b311fd4..8ba75e0c40e 100755 --- a/dev/scripts/exglobal_atmos_products.sh +++ b/dev/scripts/exglobal_atmos_products.sh @@ -58,7 +58,6 @@ for ((nset = 1; nset <= downset; nset++)); do paramlist="paramlist${grp}" parmfile="${!paramlist}" - # shellcheck disable=SC2312 ${WGRIB2} "${MASTER_FILE}" | grep -F -f "${parmfile}" | ${WGRIB2} -i -grib "${tmpfile}" "${MASTER_FILE}" && true export err=$? if [[ ${err} -ne 0 ]]; then @@ -68,7 +67,6 @@ for ((nset = 1; nset <= downset; nset++)); do # Number of processors available to process $nset nproc=${ntasks} - # shellcheck disable=SC2312 ncount=$(${WGRIB2} "${tmpfile}" | wc -l) if [[ "${nproc}" -gt "${ncount}" ]]; then echo "WARNING: Total no. of available processors '${nproc}' exceeds no. of records '${ncount}' in ${tmpfile}" @@ -89,8 +87,7 @@ for ((nset = 1; nset <= downset; nset++)); do # if final record of is u-component, add next record v-component # if final record is land, add next record icec # grep returns 1 if no match is found, so temporarily turn off exit on non-zero rc - set +e - # shellcheck disable=SC2312 + unset_strict ${WGRIB2} -d "${last}" "${tmpfile}" | grep -E -i "ugrd|ustm|uflx|u-gwd|land|maxuw" rc=$? set_strict diff --git a/dev/scripts/exglobal_atmos_sfcanl.sh b/dev/scripts/exglobal_atmos_sfcanl.sh index 2a72a8c3ede..e02e5aae0ab 100755 --- a/dev/scripts/exglobal_atmos_sfcanl.sh +++ b/dev/scripts/exglobal_atmos_sfcanl.sh @@ -76,7 +76,6 @@ else fi # If any snow files are missing, don't apply snow in the global_cycle step. -# shellcheck disable=SC2312 if [[ ! -f "${FNSNOA}" ]] || [[ ! -f "${FNSNOG}" ]]; then export FNSNOA=" " export CYCLVARS=FSNOL=99999.,FSNOS=99999., diff --git a/dev/scripts/exglobal_diag.sh b/dev/scripts/exglobal_diag.sh index d5c79a4fd57..4d9aa5de94e 100755 --- a/dev/scripts/exglobal_diag.sh +++ b/dev/scripts/exglobal_diag.sh @@ -97,17 +97,17 @@ cat > "${DATA}/diag.sh" << EOF #!/bin/bash set -x -type=\$1 +dtype=\$1 loop=\$2 string=\$3 count=\$4 suffix=\$5 # Match files with this prefix -diag_files=dir.*/\${type}_\${loop} +diag_files=dir.*/\${dtype}_\${loop} # Name of combined diagnostic file from matched files -out_diag_file=diag_\${type}_\${string}.${PDY}${cyc}\${suffix} +out_diag_file=diag_\${dtype}_\${string}.${PDY}${cyc}\${suffix} # Combine diagnostic files if [[ \${count} -gt 1 ]]; then @@ -149,19 +149,16 @@ for loop in ${loops}; do n=-1 while [[ ${n} -lt ${ntype} ]]; do n=$((n + 1)) - for type in ${diagtype[n]}; do - if [[ "${type}" == *"avhrr"* ]]; then - platform="${type##avhrr[23]}" - atype="avhrr${platform}" - type="${atype}" + for dtype in ${diagtype[n]}; do + if [[ "${dtype}" == *"avhrr"* ]]; then # recast dtype in avhrr form + dtype="avhrr${dtype##avhrr[23]}" fi - #shellcheck disable=SC2012,SC2312 - count=$(ls dir.*/"${type}_${loop}"* 2> /dev/null | wc -l) + count=$(find ./ -path "./dir.*/${dtype}_${loop}*" -type f -printf "." | wc -c) if [[ ${count} -eq 0 ]]; then continue fi - echo "${DATA}/diag.sh ${type} ${loop} ${string} ${count} ${DIAG_SUFFIX:-}.nc4" >> cmdfile - echo "diag_${type}_${string}.${PDY}${cyc}${DIAG_SUFFIX:-}.nc4${COMPRESS_SUFFIX:-}" >> "${diaglist[n]}" + echo "${DATA}/diag.sh ${dtype} ${loop} ${string} ${count} ${DIAG_SUFFIX:-}.nc4" >> cmdfile + echo "diag_${dtype}_${string}.${PDY}${cyc}${DIAG_SUFFIX:-}.nc4${COMPRESS_SUFFIX:-}" >> "${diaglist[n]}" numfile[n]=$((numfile[n] + 1)) done done diff --git a/dev/scripts/exglobal_enkf_sfc.sh b/dev/scripts/exglobal_enkf_sfc.sh index 517b6cd40f6..514d453ff3d 100755 --- a/dev/scripts/exglobal_enkf_sfc.sh +++ b/dev/scripts/exglobal_enkf_sfc.sh @@ -113,9 +113,7 @@ if [[ ! -f "${FNSNOA}" || ! -f "${FNSNOG}" ]]; then export CYCLVARS="FSNOL=99999.,FSNOS=99999.," else # Set CYCLVARS by checking grib date of current snogrb vs that of prev cycle - # shellcheck disable=SC2312 snoa_count=$("${WGRIB}" -4yr "${FNSNOA}" 2> /dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') - # shellcheck disable=SC2312 snog_count=$("${WGRIB}" -4yr "${FNSNOG}" 2> /dev/null | grep -i snowc | awk -F: '{print $3}' | awk -F= '{print $2}') if [[ ${snoa_count} -le ${snog_count} ]]; then export FNSNOA=" " diff --git a/dev/test/f90nmlcmp.sh b/dev/test/f90nmlcmp.sh index 0350f17c32f..977eb2ce1a9 100755 --- a/dev/test/f90nmlcmp.sh +++ b/dev/test/f90nmlcmp.sh @@ -2,7 +2,7 @@ # Compare two F90 namelists (forward and backward) -# shellcheck disable=SC2155,SC2312 +# shellcheck disable=SC2155 HOMEgfs=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}")")/../.." && pwd -P) declare -rx HOMEgfs diff --git a/dev/test/g2cmp.sh b/dev/test/g2cmp.sh index 3a30350dd43..514f8bb163b 100755 --- a/dev/test/g2cmp.sh +++ b/dev/test/g2cmp.sh @@ -3,7 +3,7 @@ # Compare two grib2 files with wgrib2 # The files must have the same fields in the same order -# shellcheck disable=SC2155,SC2312 +# shellcheck disable=SC2155 HOMEgfs=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}")")/../.." && pwd -P) declare -rx HOMEgfs @@ -13,5 +13,4 @@ file2=${2:?} source "${HOMEgfs}/dev/ush/load_modules.sh" run # Use wgrib2 to compute correlations and print any record that does not have corr=1 for mismatch -#shellcheck disable=SC2312 wgrib2 "${file2}" -var -lev -rpn "sto_1" -import_grib "${file1}" -rpn "rcl_1:print_corr:print_rms" | grep -v "rpn_corr=1" diff --git a/dev/test/nccmp.sh b/dev/test/nccmp.sh index f7803fdf671..5c35dae0eca 100755 --- a/dev/test/nccmp.sh +++ b/dev/test/nccmp.sh @@ -1,6 +1,6 @@ #! /usr/bin/env bash -# shellcheck disable=SC2155,SC2312 +# shellcheck disable=SC2155 HOMEgfs=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}")")/../.." && pwd -P) declare -rx HOMEgfs diff --git a/dev/test/netcdf_op_functions.sh b/dev/test/netcdf_op_functions.sh index a9c5b8dc799..dbd7fab85ed 100644 --- a/dev/test/netcdf_op_functions.sh +++ b/dev/test/netcdf_op_functions.sh @@ -1,6 +1,5 @@ #! /bin/env bash -# shellcheck disable=SC2312 # shellcheck disable=SC2317 # TODO: remove this when the script is corrected of errors if [[ -t 0 ]]; then diff --git a/dev/ush/load_modules.sh b/dev/ush/load_modules.sh index 263549f9f6c..673122d95d0 100755 --- a/dev/ush/load_modules.sh +++ b/dev/ush/load_modules.sh @@ -138,7 +138,6 @@ case "${MODULE_TYPE}" in # Detect the Python major.minor version _regex="[0-9]+\.[0-9]+" - # shellcheck disable=SC2312 if [[ $(python --version) =~ ${_regex} ]]; then export PYTHON_VERSION="${BASH_REMATCH[0]}" else diff --git a/dev/workflow/generate_workflows.sh b/dev/workflow/generate_workflows.sh index f74a21bb3ea..8d9517370b9 100755 --- a/dev/workflow/generate_workflows.sh +++ b/dev/workflow/generate_workflows.sh @@ -540,7 +540,6 @@ for _case in "${_yaml_list[@]}"; do fi # Check if DATAROOT is already present; eval will return just DATAROOT from the sourcing - # shellcheck disable=SC2312 eval "$( PDY=0 cyc=0 source "${_runtests}/EXPDIR/${_pslot}/config.base" >&/dev/null echo _dataroot="${STMP}/RUNDIRS/${_pslot}" diff --git a/gempak/ush/gfs_meta_opc_na_ver.sh b/gempak/ush/gfs_meta_opc_na_ver.sh index f3a8ed91074..956c5d72270 100755 --- a/gempak/ush/gfs_meta_opc_na_ver.sh +++ b/gempak/ush/gfs_meta_opc_na_ver.sh @@ -31,7 +31,7 @@ fcsthr="f00" # SET WHAT RUNS TO COMPARE AGAINST BASED ON MODEL CYCLE TIME. # seq won't give us any splitting problems, ignore warnings -# shellcheck disable=SC2207,SC2312 +# shellcheck disable=SC2207 case ${cyc} in 00 | 12) lookbacks=($(IFS=$'\n' seq 6 6 84) $(IFS=$'\n' seq 96 12 120)) ;; 06 | 18) lookbacks=($(IFS=$'\n' seq 6 6 84) $(IFS=$'\n' seq 90 12 126)) ;; diff --git a/gempak/ush/gfs_meta_opc_np_ver.sh b/gempak/ush/gfs_meta_opc_np_ver.sh index e6edfa90400..da95b6a0ba2 100755 --- a/gempak/ush/gfs_meta_opc_np_ver.sh +++ b/gempak/ush/gfs_meta_opc_np_ver.sh @@ -31,7 +31,7 @@ fcsthr="f00" # SET WHAT RUNS TO COMPARE AGAINST BASED ON MODEL CYCLE TIME. # seq won't give us any splitting problems, ignore warnings -# shellcheck disable=SC2207,SC2312 +# shellcheck disable=SC2207 case ${cyc} in 00 | 12) lookbacks=($(IFS=$'\n' seq 6 6 84) $(IFS=$'\n' seq 96 12 120)) ;; 06 | 18) lookbacks=($(IFS=$'\n' seq 6 6 84) $(IFS=$'\n' seq 90 12 126)) ;; diff --git a/gempak/ush/gfs_meta_ver.sh b/gempak/ush/gfs_meta_ver.sh index 8b47f614dd6..7693bee68c4 100755 --- a/gempak/ush/gfs_meta_ver.sh +++ b/gempak/ush/gfs_meta_ver.sh @@ -31,7 +31,7 @@ fcsthr="f00" MDL2="GFSHPC" #GENERATING THE METAFILES. # seq won't give us any splitting problems, ignore warnings -# shellcheck disable=SC2207,SC2312 +# shellcheck disable=SC2207 lookbacks=($(IFS=$'\n' seq 6 6 180) $(IFS=$'\n' seq 192 12 216)) for lookback in "${lookbacks[@]}"; do init_time="$(date --utc +%Y%m%d%H -d "${PDY} ${cyc} - ${lookback} hours")" diff --git a/modulefiles/gw_gsi.wcoss2.lua b/modulefiles/gw_gsi.wcoss2.lua index c3c11c92679..7d30ae3e792 100644 --- a/modulefiles/gw_gsi.wcoss2.lua +++ b/modulefiles/gw_gsi.wcoss2.lua @@ -18,6 +18,8 @@ load(pathJoin("hdf5-D", (os.getenv("hdf5_ver") or "None"))) load(pathJoin("pnetcdf-D", (os.getenv("pnetcdf_ver") or "None"))) load(pathJoin("netcdf-D", (os.getenv("netcdf_ver") or "None"))) +load(pathJoin("libjpeg", (os.getenv("libjpeg_ver") or "None"))) +load(pathJoin("grib_util", (os.getenv("grib_util_ver") or "None"))) load(pathJoin("prod_util", (os.getenv("prod_util_ver") or "None"))) load(pathJoin("ncdiag-A", (os.getenv("ncdiag_ver") or "None"))) load(pathJoin("crtm", (os.getenv("crtm_ver") or "None"))) diff --git a/sorc/build_ww3prepost.sh b/sorc/build_ww3prepost.sh index 6496f66b724..e76a32a5fbc 100755 --- a/sorc/build_ww3prepost.sh +++ b/sorc/build_ww3prepost.sh @@ -1,7 +1,7 @@ #! /usr/bin/env bash set -x -# shellcheck disable=SC2312,SC2155 +# shellcheck disable=SC2155 readonly HOMEgfs_=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}")")/.." && pwd -P) cd "${HOMEgfs_}/sorc" || exit 1 diff --git a/ush/atmos_extractvars.sh b/ush/atmos_extractvars.sh index 31cd61087bd..4a085a1ea9e 100755 --- a/ush/atmos_extractvars.sh +++ b/ush/atmos_extractvars.sh @@ -71,7 +71,6 @@ for outtype in "f2d" "f3d"; do echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." exit 1 fi - # shellcheck disable=SC2312 ${WGRIB2} "${new_infile}" | grep -F -f "${varlist}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" else echo "WARNING: ${infile} does not exist in ${com_dir}." @@ -91,7 +90,6 @@ for outtype in "f2d" "f3d"; do echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." exit 1 fi - # shellcheck disable=SC2312 ${WGRIB2} "${new_infile}" | grep -F -f "${varlist_d}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" else echo "WARNING: ${infile} does not exist in ${com_dir}." diff --git a/ush/extractvars_tools.sh b/ush/extractvars_tools.sh index fe7a4d34a43..ead740aad5e 100644 --- a/ush/extractvars_tools.sh +++ b/ush/extractvars_tools.sh @@ -12,7 +12,6 @@ check_atmos() { touch "${requestedvar_in_allgrb2file}" for infilep in "${infile1p}" "${infile2p}"; do # It is permitted for an empty string to return if no parmlist vars are in infilep, therefore do not return exit 1 error - # shellcheck disable=SC2312 ${WGRIB2} "${infilep}" | grep -F -f "${varlist}" >> "${requestedvar_in_allgrb2file}" || true done mapfile -t requestedvar_in_allgrb2file_arr < "${requestedvar_in_allgrb2file}" @@ -35,9 +34,7 @@ daily_avg_atmos() { vcnt=1 #count variables in varlist_d while read -r vari; do davgtmp=${subdata}/atmos_tmp.ldy${fnd}.${vcnt} - # shellcheck disable=SC2312 ${WGRIB2} "${outfile_p}" | grep "${vari}" | ${WGRIB2} -i "${outfile_p}" -fcst_ave 6hr "${davgtmp}" - # shellcheck disable=SC2312 ${WGRIB2} "${davgtmp}" | ${WGRIB2} -i "${davgtmp}" -append -grib "${davg_file}" rm -f "${davgtmp}" vcnt=$((vcnt + 1)) diff --git a/ush/forecast_det.sh b/ush/forecast_det.sh index 602e7d473fb..558c10ad8e3 100755 --- a/ush/forecast_det.sh +++ b/ush/forecast_det.sh @@ -43,7 +43,6 @@ UFS_det() { # However, if this was run before, a DATArestart/FV3_RESTART must exist with data in it. local file_array nrestarts - # shellcheck disable=SC2312 mapfile -t file_array < <(find "${DATArestart}/FV3_RESTART" -name "????????.??0000.coupler.res" | sort) nrestarts=${#file_array[@]} if [[ ${nrestarts} -eq 0 ]]; then diff --git a/ush/forecast_predet.sh b/ush/forecast_predet.sh index 102ae65a5a4..00bb2b43aa3 100755 --- a/ush/forecast_predet.sh +++ b/ush/forecast_predet.sh @@ -676,7 +676,6 @@ CICE_predet() { # CICE does not have a concept of high frequency output like FV3 # Convert output settings into an explicit list for CICE - # shellcheck disable=SC2312 mapfile -t CICE_OUTPUT_FH < <(seq "${FHMIN}" "${FHOUT_ICE}" "${FHMAX}") || exit 10 # Fix files diff --git a/ush/interp_atmos_master.sh b/ush/interp_atmos_master.sh index b43b05c889b..d592fbfb18a 100755 --- a/ush/interp_atmos_master.sh +++ b/ush/interp_atmos_master.sh @@ -58,7 +58,6 @@ for grid in "${grids[@]}"; do echo "FATAL ERROR: Failed during the execution of trim_rh" exit "${err}" fi - # shellcheck disable=SC2312 var_count=$(${WGRIB2} "${output_file_prefix}_${grid}" -match "LAND|ICEC" | wc -l) if [[ "${var_count}" -eq 2 ]]; then mod_icec "${output_file_prefix}_${grid}" diff --git a/ush/parsing_namelists_FV3.sh b/ush/parsing_namelists_FV3.sh index dfdfecacb52..0d871ccbe17 100755 --- a/ush/parsing_namelists_FV3.sh +++ b/ush/parsing_namelists_FV3.sh @@ -52,7 +52,6 @@ FV3_namelists() { nrec=$(wc -l < "${FIELD_TABLE}") prec=${nrec} if ((dnats > 0)); then - # shellcheck disable=SC2312 prec=$(grep -F -n TRACER "${FIELD_TABLE}" 2> /dev/null | tail -n "${dnats}" | head -1 | cut -d: -f1) prec=${prec:-0} prec=$((prec > 0 ? prec - 1 : prec)) diff --git a/ush/parsing_namelists_FV3_nest.sh b/ush/parsing_namelists_FV3_nest.sh index 89e16efca30..268c600516a 100755 --- a/ush/parsing_namelists_FV3_nest.sh +++ b/ush/parsing_namelists_FV3_nest.sh @@ -4,7 +4,6 @@ # Disable variable not used warnings and 'masking return value' warnings # shellcheck disable=SC2034 -# shellcheck disable=SC2312 FV3_namelists_nest() { # First argument tells us which namelist we're writing: diff --git a/ush/preamble.sh b/ush/preamble.sh index df24338ac83..8e96496e911 100755 --- a/ush/preamble.sh +++ b/ush/preamble.sh @@ -34,11 +34,18 @@ declare -x PS4='+ $(basename ${BASH_SOURCE[0]:-${FUNCNAME[0]:-"Unknown"}})[${LIN set_strict() { if [[ ${STRICT:-"YES"} == "YES" ]]; then # Exit on error or undefined variable - # TODO: Also error in a pipeline (e.g. if and command in "cmd | cmd2" fails) - set -eu # -o pipefail + set -eu + # Exit on error in a pipeline (e.g. if and command in "cmd | cmd2" fails) + set -o pipefail fi } +unset_strict() { + # Turn off strict mode + set +eu + set +o pipefail +} + set_trace() { # Print the script name and line number of each command as it is # executed when using trace. @@ -181,6 +188,7 @@ source "${HOMEgfs}/ush/bash_utils.sh" shopt -s nullglob # Allow null globs instead of treating * as literal export SHELLOPTS declare -xf set_strict +declare -xf unset_strict declare -xf set_trace declare -xf postamble declare -xf err_exit diff --git a/ush/radmon_diag_ck.sh b/ush/radmon_diag_ck.sh index a8e65a57fe5..2f2d9122030 100755 --- a/ush/radmon_diag_ck.sh +++ b/ush/radmon_diag_ck.sh @@ -68,7 +68,6 @@ zero_len_diag="" #--------------------------------------------- # get list of diag files in the radstat file # -# shellcheck disable=SC2312 radstat_contents=$(tar -tf "${radstat_file}" | grep -Po '(?<=diag_).*(?=_ges.*)') #--------------------------------------------- @@ -112,7 +111,6 @@ declare -A file_sizes # Parse the filename and filesize from tar's verbose output and store in an associative array # Field $6 of verbose tar output is the filename, field $3 is the size # Caution: this method is not robust if the filename contains spaces -# shellcheck disable=SC2312 while IFS='|' read -r name size; do file_sizes[${name}]=${size} done < <(tar -vtf "${radstat_file}" --wildcards '*_ges*' | awk '$3 ~ /^[0-9]+$/ { print $6 "|" $3 }') diff --git a/ush/run_mpmd.sh b/ush/run_mpmd.sh index 89e65daaa97..36ddc4bc4cc 100755 --- a/ush/run_mpmd.sh +++ b/ush/run_mpmd.sh @@ -63,13 +63,12 @@ if [[ "${launcher:-}" =~ ^srun.* ]]; then # srun-based system e.g. Hera, Orion, # Slurm requires a counter in front of each line in the script # Read the incoming cmdfile and create srun usable cmdfile nm=0 - # shellcheck disable=SC2312 while IFS= read -r line; do echo "${nm} ${line}" >> "${mpmd_cmdfile}" ((nm = nm + 1)) done < "${cmdfile}" - set +e + unset_strict # shellcheck disable=SC2086 ${launcher:-} ${mpmd_opt:-} -n ${nprocs} "${mpmd_cmdfile}" err=$? @@ -81,7 +80,6 @@ elif [[ "${launcher:-}" =~ ^mpiexec.* ]]; then # mpiexec # Read the incoming cmdfile and create mpiexec usable cmdfile nm=0 echo "#!/bin/bash" >> "${mpmd_cmdfile}" - # shellcheck disable=SC2312 while IFS= read -r line; do echo "${line} > mpmd.${nm}.out" >> "${mpmd_cmdfile}" ((nm = nm + 1)) diff --git a/ush/syndat_getjtbul.sh b/ush/syndat_getjtbul.sh index 0ce21ef7efd..78337be415c 100755 --- a/ush/syndat_getjtbul.sh +++ b/ush/syndat_getjtbul.sh @@ -66,7 +66,6 @@ find="${ymd} ${cyc}" echo "looking for string ${find} in ${jtwcdir}/tropcyc" rm -f jtwcbul -# shellcheck disable=SC2312 grep "${ymd} ${cyc}" "${jtwcdir}/tropcyc" | grep JTWC > jtwcbul if [[ -s jtwcbul ]]; then echo "String found: contents of JTWC bulletin are:" @@ -76,7 +75,6 @@ else fi if [[ "${cyc}" == "00" ]]; then - # shellcheck disable=SC2312 grep "${ymd} ${cyc}" "${jtwcdirm1}/tropcyc" | grep JTWC >> jtwcbul if [[ -s jtwcbul ]]; then echo "String found: contents of JTWC bulletin are:" @@ -104,12 +102,12 @@ fi pgm=$(basename "${EXECgfs}/syndat_getjtbul.x") export pgm if [[ -s prep_step ]]; then - set +u + unset_strict source prep_step - set -u + set_strict else [[ -f errfile ]] && rm errfile - # shellcheck disable=SC2046,SC2312 + #shellcheck disable=SC2046 unset FORT00 $(env | grep "^FORT[0-9]\{1,\}=" | awk -F= '{print $1}') fi @@ -117,7 +115,6 @@ rm -f fnoc export FORT11=jtwcbul export FORT51=fnoc -# shellcheck disable=SC2312 time -p "${EXECgfs}/${pgm}" 2> errfile errget=$? cat errfile diff --git a/ush/syndat_qctropcy.sh b/ush/syndat_qctropcy.sh index deef9ad515a..74db606b0a0 100755 --- a/ush/syndat_qctropcy.sh +++ b/ush/syndat_qctropcy.sh @@ -229,12 +229,12 @@ cpreq "${slmask}" slmask.126 pgm=$(basename "${EXECgfs}/syndat_qctropcy.x") export pgm if [[ -s prep_step ]]; then - set +u + unset_strict source prep_step - set -u + set_strict else [[ -f errfile ]] && rm errfile - # shellcheck disable=SC2046,SC2312 + # shellcheck disable=SC2046 unset FORT00 $(env | grep "^FORT[0-9]\{1,\}=" | awk -F= '{print $1}') fi diff --git a/ush/tropcy_relocate_extrkr.sh b/ush/tropcy_relocate_extrkr.sh index 8427908ba6b..33539aee36f 100755 --- a/ush/tropcy_relocate_extrkr.sh +++ b/ush/tropcy_relocate_extrkr.sh @@ -299,9 +299,9 @@ case ${cmodel} in ;; other) cat << EOF -Model selected by user is ${cmodel}, which is a +Model selected by user is ${cmodel}, which is a user-defined model, NOT operational.... - + EOF model=9 ;; @@ -417,7 +417,7 @@ EOF !!! FATAL ERROR in $(basename "$0"): !!! Input analysis file cannot be found. -!!! The tracker is looking for this file in: +!!! The tracker is looking for this file in: !!! ----> ${otherdir}/${fnamebeg}00${fnameend} !!! Please check the directory to make sure the file !!! is there and then submit this job again. @@ -456,7 +456,6 @@ fi cpfs "${DATA}/tcvitals" "${vdir}/vitals.${symd}${dishh}" -# shellcheck disable=SC2312 grep -v TEST "${vdir}/vitals.${symd}${dishh}" | awk 'substr($0,6,1) !~ /[8-9]/ {print $0}' > "${vdir}/tempvit.nonameless" @@ -558,7 +557,7 @@ if [[ -s "${DATA}/prep_step" ]]; then else [[ -f errfile ]] && rm errfile export XLFUNITS=0 - # shellcheck disable=SC2046,SC2312 + # shellcheck disable=SC2046 unset $(env | grep XLFUNIT | awk -F= '{print $1}') export XLFRTEOPTS="${XLFRTEOPTS:+${XLFRTEOPTS}:}unit_vars=yes" fi @@ -592,7 +591,7 @@ else msg=$( cat << EOF -!!! FATAL ERROR: An error occurred while running supvitql, +!!! FATAL ERROR: An error occurred while running supvitql, !!! which is the program that updates the TC Vitals file. !!! Return code from supvitql = ${err} !!! model= ${cmodel}, forecast initial time = ${symd}${dishh} @@ -614,18 +613,17 @@ fi numvitrecs=$(wc -l "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}") if [[ "${numvitrecs}" -eq 0 ]]; then cat << EOF - -!!! ERROR -- There are no vitals records for this time period + +!!! ERROR -- There are no vitals records for this time period !!! in the UPDATED vitals file. !!! File ${vdir}/vitals.upd.${cmodel}.${symd}${dishh} is empty. !!! Please check the dates and submit this job again.... - + EOF err=8 err_exit fi -# shellcheck disable=SC2312 cat << EOF | tee stormlist @@ -634,7 +632,7 @@ cat << EOF | tee stormlist | STORM SELECTION | *--------------------------------* -Below is a list of the storms to be processed: +Below is a list of the storms to be processed: $(cat "${vdir}/vitals.upd.${cmodel}.${symd}${dishh}") @@ -680,8 +678,8 @@ done cat << EOF ----------------------------------------- - NOW CUTTING APART INPUT GRIB FILES TO - CREATE 1 BIG GRIB INPUT FILE + NOW CUTTING APART INPUT GRIB FILES TO + CREATE 1 BIG GRIB INPUT FILE ----------------------------------------- EOF @@ -706,8 +704,8 @@ if [[ "${model}" -eq 5 ]]; then ******************************************************************* !!! NGM model has been selected, but there are no storms in the !!! TC Vitals file that are from NHC. Therefore, unless you have -!!! entered your own auxiliary TC vitals file that has a storm -!!! within the NGM domain, the tracker will exit after reading +!!! entered your own auxiliary TC vitals file that has a storm +!!! within the NGM domain, the tracker will exit after reading !!! in the analysis data. ******************************************************************* @@ -764,9 +762,9 @@ EOF cat << EOF !!! FATAL ERROR using ${COPYGB} to interpolate ngm data. We will stop execution because -!!! some variables may have been copied okay, while some obviously have not, +!!! some variables may have been copied okay, while some obviously have not, !!! and that could lead to unreliable results from the tracker. Check to make -!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is +!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is !!! typically due to using more memory than you've allocated). Exiting..... EOF @@ -804,8 +802,8 @@ if [[ "${model}" -eq 6 ]]; then ******************************************************************* !!! NAM model has been selected, but there are no storms in the !!! TC Vitals file that are from NHC. Therefore, unless you have -!!! entered your own auxiliary TC vitals file that has a storm -!!! within the NAM domain, the tracker will exit after reading +!!! entered your own auxiliary TC vitals file that has a storm +!!! within the NAM domain, the tracker will exit after reading !!! in the analysis data. ******************************************************************* @@ -861,9 +859,9 @@ EOF cat << EOF !!! FATAL ERROR using ${COPYGB} to interpolate nam data. We will stop execution because -!!! some variables may have been copied okay, while some obviously have not, +!!! some variables may have been copied okay, while some obviously have not, !!! and that could lead to unreliable results from the tracker. Check to make -!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is +!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is !!! typically due to using more memory than you've allocated). Exiting..... EOF @@ -963,7 +961,6 @@ EOF "SurfaceV") parm="VGRD:10 m" ;; *) ;; esac - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/gfs.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ -o "${vdir}/gfsgribfile.${symd}${dishh}" done @@ -1025,7 +1022,6 @@ EOF "SurfaceV") parm="VGRD:10 m" ;; *) ;; esac - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/gdas.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ -o "${vdir}/gdasgribfile.${symd}${dishh}" done @@ -1067,7 +1063,6 @@ EOF "SurfaceV") parm="VGRD:10 m" ;; *) ;; esac - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/gdas.ix" | ${WGRIB2:?} -i "${gfile}" -append -grib \ "${vdir}/gdasgribfile.${symd}${dishh}" done @@ -1116,7 +1111,6 @@ EOF "SurfaceV") parm="VGRD:10 m" ;; *) ;; esac - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/mrf.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ -o "${vdir}/mrfgribfile.${symd}${dishh}" done @@ -1155,7 +1149,6 @@ EOF ${WGRIB:?} -s "${gfile}" > "${TMPDIR}/ukmet.ix" for parm in ${wgrib_parmlist}; do - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/ukmet.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ -o "${vdir}/ukmetgribfile.${symd}${dishh}" done @@ -1208,7 +1201,6 @@ EOF "SurfaceV") parm="VGRD:19 m" ;; *) ;; esac - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/ngps.ix" | grep "${vtstring}" | ${WGRIB:?} -s "${gfile}" -i -grib -append -o "${vdir}/ngpsgribfile.${symd}${dishh}" done @@ -1235,7 +1227,6 @@ if [[ "${model}" -eq 9 ]]; then rm -f "${vdir}/otherlatlon.pgrb.${symdh}" - # shellcheck disable=SC2312 gridtyp=$(${WGRIB:?} -GDS10 "${otherdir}/${fnamebeg}00${fnameend}" | awk -FGDS10= '{print $2}' | awk '{print $6}' | sed -n 1p) @@ -1266,7 +1257,6 @@ EOF "SurfaceV") parm="VGRD:10 m" ;; *) ;; esac - # shellcheck disable=SC2312 grep "${parm}" "${TMPDIR}/other.ix" | ${WGRIB:?} -s "${gfile}" -i -grib -append \ -o "${vdir}/otherlatlon.pgrb.${symdh}" done @@ -1325,9 +1315,9 @@ EOF cat << EOF !!! FATAL ERROR using ${COPYGB} to interpolate data. We will stop execution because -!!! some variables may have been copied okay, while some obviously have not, +!!! some variables may have been copied okay, while some obviously have not, !!! and that could lead to unreliable results from the tracker. Check to make -!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is +!!! sure you've allocated enough memory for this job (error 134 using ${COPYGB} is !!! typically due to using more memory than you've allocated). Exiting..... EOF @@ -1425,7 +1415,7 @@ if [[ -s "${DATA}/prep_step" ]]; then else rm -f errfile export XLFUNITS=0 - # shellcheck disable=SC2046,SC2312 + # shellcheck disable=SC2046 unset $(env | grep XLFUNIT | awk -F= '{print $1}') export XLFRTEOPTS="${XLFRTEOPTS:+${XLFRTEOPTS}:}unit_vars=yes" fi diff --git a/ush/wave_extractvars.sh b/ush/wave_extractvars.sh index dde21a2c690..2bef8368813 100755 --- a/ush/wave_extractvars.sh +++ b/ush/wave_extractvars.sh @@ -34,7 +34,6 @@ for ((nh = FHOUT_WAV_EXTRACT; nh <= FHMAX_WAV; nh = nh + FHOUT_WAV_EXTRACT)); do echo "FATAL ERROR: Failed to copy ${infile} to ${new_infile}." exit 1 fi - # shellcheck disable=SC2312 ${WGRIB2} "${new_infile}" | grep -F -f "${varlist_wav}" | ${WGRIB2} -i "${new_infile}" -append -grib "${outfile}" else echo "WARNING: ${infile} does not exist in ${com_dir}." diff --git a/ush/wave_tar.sh b/ush/wave_tar.sh index e24def1e11f..e23162dd47e 100755 --- a/ush/wave_tar.sh +++ b/ush/wave_tar.sh @@ -87,7 +87,6 @@ tardone='no' sleep_interval=10 while [[ "${tardone}" == "no" ]]; do - # shellcheck disable=SC2312 nf=$(find . -maxdepth 1 -type f -name "*.${filext}" -printf '.' | wc -c) nbm2=$((nb - 2)) if [[ ${nf} -ge ${nbm2} ]]; then