Skip to content

Commit

Permalink
Address shellcheck warnings; fix gfs_utils build job count NOAA-EMC#1978
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHuber-NOAA committed Oct 30, 2023
1 parent abd7fdf commit badcf6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
24 changes: 12 additions & 12 deletions sorc/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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 &
Expand All @@ -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
Expand All @@ -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))
Expand Down
1 change: 0 additions & 1 deletion sorc/build_ufs_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit badcf6b

Please sign in to comment.