From badcf6be44e946b761826c9c76a3671d9b23e091 Mon Sep 17 00:00:00 2001 From: DavidHuber Date: Mon, 30 Oct 2023 15:41:38 +0000 Subject: [PATCH] Address shellcheck warnings; fix gfs_utils build job count #1978 --- sorc/build_all.sh | 24 ++++++++++++------------ sorc/build_ufs_utils.sh | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sorc/build_all.sh b/sorc/build_all.sh index 3c9dc067c7..8ca7d52953 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -119,7 +119,7 @@ big_jobs=0 # The UPP is hardcoded to use 6 cores [[ ${Build_upp} == 'true' ]] && build_jobs["upp"]=6 [[ ${Build_ufs_utils} == 'true' ]] && build_jobs["ufs_utils"]=3 -[[ ${Build_gfs_utils} == 'true' ]] && build_jobs["gfs_utils"]=16 +[[ ${Build_gfs_utils} == 'true' ]] && build_jobs["gfs_utils"]=1 [[ ${Build_ww3prepost} == "true" ]] && build_jobs["ww3prepost"]=2 # Optional DA builds @@ -160,7 +160,7 @@ builds_started=0 # Now start looping through all of the remaining jobs until everything is done while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do if [[ ${procs_in_use} -lt ${_build_job_max} ]]; then - if [[ "${build_jobs[gdas]+0}" && ! "${build_ids[gdas]+0}" ]]; then + if [[ -n "${build_jobs[gdas]+0}" && ! -n "${build_ids[gdas]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['gdas'] + procs_in_use )) ]]; then ./build_gdas.sh -j "${build_jobs[gdas]}" "${_verbose_opt}" > \ "${logs_dir}/build_gdas.log" 2>&1 & @@ -169,7 +169,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['gdas'] )) fi fi - if [[ "${build_jobs[ufs_model]+0}" && ! "${build_ids[ufs_model]+0}" ]]; then + if [[ -n "${build_jobs[ufs_model]+0}" && ! -n "${build_ids[ufs_model]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['ufs_model'] + procs_in_use )) ]]; then ./build_ufs.sh -j "${build_jobs[ufs_model]}" "${_verbose_opt}" "${_build_ufs_opt}" > \ "${logs_dir}/build_ufs.log" 2>&1 & @@ -178,7 +178,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['ufs_model'] )) fi fi - if [[ "${build_jobs[gsi_enkf]+0}" && ! "${build_ids[gsi_enkf]+0}" ]]; then + if [[ -n "${build_jobs[gsi_enkf]+0}" && ! -n "${build_ids[gsi_enkf]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['gsi_enkf'] + procs_in_use )) ]]; then ./build_gsi_enkf.sh -j "${build_jobs[gsi_enkf]}" "${_verbose_opt}" > \ "${logs_dir}/build_gsi_enkf.log" 2>&1 & @@ -187,7 +187,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['gsi_enkf'] )) fi fi - if [[ "${build_jobs[ufs_utils]+0}" && ! "${build_ids[ufs_utils]+0}" ]]; then + if [[ -n "${build_jobs[ufs_utils]+0}" && ! -n "${build_ids[ufs_utils]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['ufs_utils'] + procs_in_use )) ]]; then ./build_ufs_utils.sh -j "${build_jobs[ufs_utils]}" "${_verbose_opt}" > \ "${logs_dir}/build_ufs_utils.log" 2>&1 & @@ -196,7 +196,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['ufs_utils'] )) fi fi - if [[ "${build_jobs[gsi_utils]+0}" && ! "${build_ids[gsi_utils]+0}" ]]; then + if [[ -n "${build_jobs[gsi_utils]+0}" && ! -n "${build_ids[gsi_utils]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['gsi_utils'] + procs_in_use )) ]]; then ./build_gsi_utils.sh -j "${build_jobs[gsi_utils]}" "${_verbose_opt}" > \ "${logs_dir}/build_gsi_utils.log" 2>&1 & @@ -205,7 +205,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['gsi_utils'] )) fi fi - if [[ "${build_jobs[upp]+0}" && ! "${build_ids[upp]+0}" ]]; then + if [[ -n "${build_jobs[upp]+0}" && ! -n "${build_ids[upp]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['upp'] + procs_in_use )) ]]; then ./build_upp.sh "${_verbose_opt}" > \ "${logs_dir}/build_upp.log" 2>&1 & @@ -214,7 +214,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['upp'] )) fi fi - if [[ "${build_jobs[ww3prepost]+0}" && ! "${build_ids[ww3prepost]+0}" ]]; then + if [[ -n "${build_jobs[ww3prepost]+0}" && ! -n "${build_ids[ww3prepost]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['ww3prepost'] + procs_in_use )) ]]; then ./build_ww3prepost.sh -j "${build_jobs[ww3prepost]}" "${_verbose_opt}" "${_build_ufs_opt}" > \ "${logs_dir}/build_ww3prepost.log" 2>&1 & @@ -223,7 +223,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['ww3prepost'] )) fi fi - if [[ "${build_jobs[gsi_monitor]+0}" && ! "${build_ids[gsi_monitor]+0}" ]]; then + if [[ -n "${build_jobs[gsi_monitor]+0}" && ! -n "${build_ids[gsi_monitor]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['gsi_monitor'] + procs_in_use )) ]]; then ./build_gsi_monitor.sh -j "${build_jobs[gsi_monitor]}" "${_verbose_opt}" > \ "${logs_dir}/build_gsi_monitor.log" 2>&1 & @@ -232,7 +232,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do procs_in_use=$(( procs_in_use + build_jobs['gsi_monitor'] )) fi fi - if [[ "${build_jobs[gfs_utils]+0}" && ! "${build_ids[gfs_utils]+0}" ]]; then + if [[ -n "${build_jobs[gfs_utils]+0}" && ! -n "${build_ids[gfs_utils]+0}" ]]; then if [[ ${_build_job_max} -ge $(( build_jobs['gfs_utils'] + procs_in_use )) ]]; then ./build_gfs_utils.sh -j "${build_jobs[gfs_utils]}" "${_verbose_opt}" > \ "${logs_dir}/build_gfs_utils.log" 2>&1 & @@ -248,7 +248,7 @@ while [[ ${builds_started} -lt ${#build_jobs[@]} ]]; do builds_started=0 procs_in_use=0 for build in "${!build_jobs[@]}"; do - if [[ "${build_ids[${build}]+0}" ]]; then + if [[ -n "${build_ids[${build}]+0}" ]]; then builds_started=$(( builds_started + 1)) # Calculate how many processors are in use if ps -p "${build_ids[${build}]}" > /dev/null; then @@ -265,7 +265,7 @@ errs=0 while [[ ${#build_jobs[@]} -gt 0 ]]; do for build in "${!build_jobs[@]}"; do # Test if each job is complete and if so, notify and remove from the array - if [[ "${build_ids[${build}]+0}" ]]; then + if [[ -n "${build_ids[${build}]+0}" ]]; then if ! ps -p "${build_ids[${build}]}" > /dev/null; then wait "${build_ids[${build}]}" && build_stat=$? errs=$((errs+build_stat)) diff --git a/sorc/build_ufs_utils.sh b/sorc/build_ufs_utils.sh index 5eabdea471..e78ca3c180 100755 --- a/sorc/build_ufs_utils.sh +++ b/sorc/build_ufs_utils.sh @@ -5,7 +5,6 @@ OPTIND=1 while getopts ":j:dv" option; do case "${option}" in j) export BUILD_JOBS="${OPTARG}";; - o) _ops="YES";; v) export BUILD_VERBOSE="YES";; :) echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"