diff --git a/Externals.cfg b/Externals.cfg index 47e8134e13a..0a01cbae8d5 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -8,7 +8,7 @@ protocol = git required = True [gfs-utils] -hash = af933d3 +hash = 0b8ff56 local_path = sorc/gfs_utils.fd repo_url = https://github.com/NOAA-EMC/gfs-utils protocol = git diff --git a/modulefiles/workflow_utils.hera.lua b/modulefiles/workflow_utils.hera.lua deleted file mode 100644 index e0838b2c160..00000000000 --- a/modulefiles/workflow_utils.hera.lua +++ /dev/null @@ -1,34 +0,0 @@ -help([[ -Build environment for workflow utilities on Hera -]]) - -prepend_path("MODULEPATH", "/scratch2/NCEPDEV/nwprod/hpc-stack/libs/hpc-stack/modulefiles/stack") - -load(pathJoin("hpc", "1.1.0")) -load(pathJoin("hpc-intel", "18.0.5.274")) -load(pathJoin("hpc-impi", "2018.0.4")) - -load(pathJoin("cmake", "3.20.0")) - -load(pathJoin("jasper", "2.0.25")) -load(pathJoin("zlib", "1.2.11")) -load(pathJoin("png", "1.6.35")) - -load(pathJoin("hdf5", "1.10.6")) -load(pathJoin("netcdf", "4.7.4")) - -load(pathJoin("bacio", "2.4.1")) -load(pathJoin("g2", "3.4.1")) -load(pathJoin("ip", "3.3.3")) -load(pathJoin("nemsio", "2.5.2")) -load(pathJoin("sp", "2.3.3")) -load(pathJoin("w3emc", "2.7.3")) -load(pathJoin("w3nco", "2.4.1")) -load(pathJoin("nemsiogfs", "2.5.3")) -load(pathJoin("ncio", "1.0.0")) -load(pathJoin("landsfcutil", "2.4.1")) -load(pathJoin("sigio", "2.3.2")) -load(pathJoin("bufr", "11.4.0")) - -load(pathJoin("wgrib2", "2.0.8")) -setenv("WGRIB2","wgrib2") diff --git a/modulefiles/workflow_utils.jet.lua b/modulefiles/workflow_utils.jet.lua deleted file mode 100644 index 27f8ab5db51..00000000000 --- a/modulefiles/workflow_utils.jet.lua +++ /dev/null @@ -1,34 +0,0 @@ -help([[ -Build environment for workflow utilities on Jet -]]) - -prepend_path("MODULEPATH", "/lfs4/HFIP/hfv3gfs/nwprod/hpc-stack/libs/modulefiles/stack") - -load(pathJoin("hpc", "1.1.0")) -load(pathJoin("hpc-intel", "18.0.5.274")) -load(pathJoin("hpc-impi", "2018.4.274")) - -load(pathJoin("cmake", "3.16.1")) - -load(pathJoin("jasper", "2.0.25")) -load(pathJoin("zlib", "1.2.11")) -load(pathJoin("png", "1.6.35")) - -load(pathJoin("hdf5", "1.10.6")) -load(pathJoin("netcdf", "4.7.4")) - -load(pathJoin("bacio", "2.4.1")) -load(pathJoin("g2", "3.4.1")) -load(pathJoin("w3nco", "2.4.1")) -load(pathJoin("w3emc", "2.7.3")) -load(pathJoin("sp", "2.3.3")) -load(pathJoin("ip", "3.3.3")) -load(pathJoin("nemsio", "2.5.2")) -load(pathJoin("nemsiogfs", "2.5.3")) -load(pathJoin("ncio", "1.0.0")) -load(pathJoin("landsfcutil", "2.4.1")) -load(pathJoin("sigio", "2.3.2")) -load(pathJoin("bufr", "11.4.0")) - -load(pathJoin("wgrib2", "2.0.8")) -setenv("WGRIB2","wgrib2") diff --git a/modulefiles/workflow_utils.orion.lua b/modulefiles/workflow_utils.orion.lua deleted file mode 100644 index 4d788725c9e..00000000000 --- a/modulefiles/workflow_utils.orion.lua +++ /dev/null @@ -1,34 +0,0 @@ -help([[ -Build environment for workflow utilities on Orion -]]) - -prepend_path("MODULEPATH", "/apps/contrib/NCEP/libs/hpc-stack/modulefiles/stack") - -load(pathJoin("hpc", "1.1.0")) -load(pathJoin("hpc-intel", "2018.4")) -load(pathJoin("hpc-impi", "2018.4")) - -load(pathJoin("cmake", "3.17.3")) - -load(pathJoin("jasper", "2.0.25")) -load(pathJoin("zlib", "1.2.11")) -load(pathJoin("png", "1.6.35")) - -load(pathJoin("hdf5", "1.10.6")) -load(pathJoin("netcdf", "4.7.4")) - -load(pathJoin("bacio", "2.4.1")) -load(pathJoin("g2", "3.4.1")) -load(pathJoin("w3nco", "2.4.1")) -load(pathJoin("w3emc", "2.7.3")) -load(pathJoin("sp", "2.3.3")) -load(pathJoin("ip", "3.3.3")) -load(pathJoin("nemsio", "2.5.2")) -load(pathJoin("nemsiogfs", "2.5.3")) -load(pathJoin("ncio", "1.0.0")) -load(pathJoin("landsfcutil", "2.4.1")) -load(pathJoin("sigio", "2.3.2")) -load(pathJoin("bufr", "11.4.0")) - -load(pathJoin("wgrib2", "2.0.8")) -setenv("WGRIB2","wgrib2") diff --git a/modulefiles/workflow_utils.s4.lua b/modulefiles/workflow_utils.s4.lua deleted file mode 100644 index 5770ff3cba7..00000000000 --- a/modulefiles/workflow_utils.s4.lua +++ /dev/null @@ -1,35 +0,0 @@ -help([[ -Build environment for workflow utilities on Hera -]]) - -load("license_intel") -prepend_path("MODULEPATH", "/data/prod/hpc-stack/modulefiles/stack") - -load(pathJoin("hpc", "1.1.0")) -load(pathJoin("hpc-intel", "18.0.4")) -load(pathJoin("hpc-impi", "18.0.4")) - -load(pathJoin("jasper", "2.0.25")) -load(pathJoin("zlib", "1.2.11")) -load(pathJoin("png", "1.6.35")) - -load(pathJoin("hdf5", "1.10.6")) -load(pathJoin("netcdf", "4.7.4")) - -load(pathJoin("bacio", "2.4.1")) -load(pathJoin("g2", "3.4.1")) -load(pathJoin("ip", "3.3.3")) -load(pathJoin("nemsio", "2.5.2")) -load(pathJoin("sp", "2.3.3")) -load(pathJoin("w3emc", "2.7.3")) -load(pathJoin("w3nco", "2.4.1")) -load(pathJoin("nemsiogfs", "2.5.3")) -load(pathJoin("ncio", "1.1.2")) -load(pathJoin("landsfcutil", "2.4.1")) -load(pathJoin("sigio", "2.3.2")) -load(pathJoin("bufr", "11.4.0")) - -load(pathJoin("wgrib2", "2.0.8")) -setenv("WGRIB2","wgrib2") - -setenv("FFLAGS","-march=ivybridge") diff --git a/modulefiles/workflow_utils.wcoss2.lua b/modulefiles/workflow_utils.wcoss2.lua deleted file mode 100644 index 34b54a69c50..00000000000 --- a/modulefiles/workflow_utils.wcoss2.lua +++ /dev/null @@ -1,32 +0,0 @@ -help([[ -Build environment for workflow utilities on WCOSS2 -]]) - -load(pathJoin("PrgEnv-intel", "8.1.0")) -load(pathJoin("craype", "2.7.10")) -load(pathJoin("intel", "19.1.3.304")) -load(pathJoin("cray-mpich", "8.1.9")) - -load(pathJoin("cmake", "3.20.2")) - -load(pathJoin("jasper", "2.0.25")) -load(pathJoin("zlib", "1.2.11")) -load(pathJoin("libpng", "1.6.37")) - -load(pathJoin("hdf5", "1.10.6")) -load(pathJoin("netcdf", "4.7.4")) - -load(pathJoin("bacio", "2.4.1")) -load(pathJoin("g2", "3.4.5")) -load(pathJoin("ip", "3.3.3")) -load(pathJoin("nemsio", "2.5.2")) -load(pathJoin("sp", "2.3.3")) -load(pathJoin("w3emc", "2.9.2")) -load(pathJoin("w3nco", "2.4.1")) -load(pathJoin("nemsiogfs", "2.5.3")) -load(pathJoin("ncio", "1.0.0")) -load(pathJoin("landsfcutil", "2.4.1")) -load(pathJoin("sigio", "2.3.2")) -load(pathJoin("bufr", "11.5.0")) - -load(pathJoin("wgrib2", "2.0.8")) diff --git a/sorc/build_all.sh b/sorc/build_all.sh index 3acebb73474..a04c7a95b75 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -35,6 +35,7 @@ cd "${script_dir}" || exit 1 _build_ufs_opt="" _ops_opt="" _verbose_opt="" +_partial_opt="" # Reset option counter in case this script is sourced OPTIND=1 while getopts ":a:c:hov" option; do @@ -59,13 +60,13 @@ done shift $((OPTIND-1)) logs_dir="${script_dir}/logs" -if [ ! -d "${logs_dir}" ]; then +if [[ ! -d "${logs_dir}" ]]; then echo "Creating logs folder" mkdir "${logs_dir}" || exit 1 fi # Check final exec folder exists -if [ ! -d "../exec" ]; then +if [[ ! -d "../exec" ]]; then echo "Creating ../exec folder" mkdir ../exec fi @@ -74,9 +75,8 @@ fi # GET MACHINE #------------------------------------ export COMPILER="intel" -# shellcheck disable=SC1091 source gfs_utils.fd/ush/detect_machine.sh -# shellcheck disable= +source gfs_utils.fd/ush/module-setup.sh if [[ -z "${MACHINE_ID}" ]]; then echo "FATAL: Unable to determine target machine" exit 1 @@ -85,8 +85,9 @@ fi #------------------------------------ # INCLUDE PARTIAL BUILD #------------------------------------ -# shellcheck source-path=sorc -source ./partial_build.sh $_verbose_opt $_partial_opt +# shellcheck disable=SC2086,SC2248 +source ./partial_build.sh ${_verbose_opt} ${_partial_opt} +# shellcheck disable= if [[ ${MACHINE_ID} =~ jet.* ]]; then Build_gldas="false" @@ -96,51 +97,75 @@ fi #------------------------------------ # Exception Handling Init #------------------------------------ +# shellcheck disable=SC2016 ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} +# shellcheck disable= err=0 +#------------------------------------ +# build gfs_utils +#------------------------------------ +if [[ ${Build_gfs_utils} == 'true' ]]; then + echo " .... Building gfs_utils .... " + # shellcheck disable=SC2086,SC2248 + ./build_gfs_utils.sh ${_verbose_opt} > "${logs_dir}/build_gfs_utils.log" 2>&1 + # shellcheck disable= + rc=$? + if (( rc != 0 )) ; then + echo "Fatal error in building gfs_utils." + echo "The log file is in ${logs_dir}/build_gfs_utils.log" + fi + err=$((err + rc)) +fi + #------------------------------------ # build WW3 pre & post execs #------------------------------------ -${Build_ww3_prepost:?} && { +if [[ ${Build_ww3_prepost} == "true" ]]; then echo " .... Building WW3 pre and post execs .... " - ./build_ww3prepost.sh ${_verbose_opt} ${_build_ufs_opt} > ${logs_dir}/build_ww3_prepost.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_ww3prepost.sh ${_verbose_opt} ${_build_ufs_opt} > "${logs_dir}/build_ww3_prepost.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building WW3 pre/post processing." echo "The log file is in ${logs_dir}/build_ww3_prepost.log" fi err=$((err + rc)) -} +fi #------------------------------------ # build forecast model #------------------------------------ -${Build_ufs_model:?} && { +if [[ ${Build_ufs_model} == 'true' ]]; then echo " .... Building forecast model .... " - ./build_ufs.sh ${_verbose_opt} ${_build_ufs_opt} > ${logs_dir}/build_ufs.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_ufs.sh ${_verbose_opt} ${_build_ufs_opt} > "${logs_dir}/build_ufs.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building UFS model." echo "The log file is in ${logs_dir}/build_ufs.log" fi err=$((err + rc)) -} +fi #------------------------------------ # build GSI and EnKF - optional checkout #------------------------------------ -if [ -d gsi_enkf.fd ]; then - ${Build_gsi_enkf:?} && { - echo " .... Building gsi and enkf .... " - ./build_gsi_enkf.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_gsi_enkf.log 2>&1 - rc=$? - if [[ ${rc} -ne 0 ]] ; then - echo "Fatal error in building gsi_enkf." - echo "The log file is in ${logs_dir}/build_gsi_enkf.log" +if [[ -d gsi_enkf.fd ]]; then + if [[ ${Build_gsi_enkf} == 'true' ]]; then + echo " .... Building gsi and enkf .... " + # shellcheck disable=SC2086,SC2248 + ./build_gsi_enkf.sh ${_ops_opt} ${_verbose_opt} > "${logs_dir}/build_gsi_enkf.log" 2>&1 + # shellcheck disable= + rc=$? + if (( rc != 0 )) ; then + echo "Fatal error in building gsi_enkf." + echo "The log file is in ${logs_dir}/build_gsi_enkf.log" + fi + err=$((err + rc)) fi - err=$((err + rc)) -} else echo " .... Skip building gsi and enkf .... " fi @@ -148,17 +173,19 @@ fi #------------------------------------ # build gsi utilities #------------------------------------ -if [ -d gsi_utils.fd ]; then - ${Build_gsi_utils:?} && { - echo " .... Building gsi utilities .... " - ./build_gsi_utils.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_gsi_utils.log 2>&1 - rc=$? - if [[ ${rc} -ne 0 ]] ; then - echo "Fatal error in building gsi utilities." - echo "The log file is in ${logs_dir}/build_gsi_utils.log" +if [[ -d gsi_utils.fd ]]; then + if [[ ${Build_gsi_utils} == 'true' ]]; then + echo " .... Building gsi utilities .... " + # shellcheck disable=SC2086,SC2248 + ./build_gsi_utils.sh ${_ops_opt} ${_verbose_opt} > "${logs_dir}/build_gsi_utils.log" 2>&1 + # shellcheck disable= + rc=$? + if (( rc != 0 )) ; then + echo "Fatal error in building gsi utilities." + echo "The log file is in ${logs_dir}/build_gsi_utils.log" + fi + err=$((err + rc)) fi - err=$((err + rc)) -} else echo " .... Skip building gsi utilities .... " fi @@ -166,17 +193,19 @@ fi #------------------------------------ # build gdas - optional checkout #------------------------------------ -if [ -d gdas.cd ]; then - ${Build_gdas:?} && { - echo " .... Building GDASApp .... " - ./build_gdas.sh ${_verbose_opt} > ${logs_dir}/build_gdas.log 2>&1 - rc=$? - if [[ ${rc} -ne 0 ]] ; then - echo "Fatal error in building GDASApp." - echo "The log file is in ${logs_dir}/build_gdas.log" +if [[ -d gdas.cd ]]; then + if [[ ${Build_gdas} == 'true' ]]; then + echo " .... Building GDASApp .... " + # shellcheck disable=SC2086,SC2248 + ./build_gdas.sh ${_verbose_opt} > "${logs_dir}/build_gdas.log" 2>&1 + # shellcheck disable= + rc=$? + if (( rc != 0 )) ; then + echo "Fatal error in building GDASApp." + echo "The log file is in ${logs_dir}/build_gdas.log" + fi + err=$((err + rc)) fi - err=$((err + rc)) -} else echo " .... Skip building GDASApp .... " fi @@ -184,17 +213,19 @@ fi #------------------------------------ # build gsi monitor #------------------------------------ -if [ -d gsi_monitor.fd ]; then - ${Build_gsi_monitor:?} && { +if [[ -d gsi_monitor.fd ]]; then + if [[ ${Build_gsi_monitor} == 'true' ]]; then echo " .... Building gsi monitor .... " - ./build_gsi_monitor.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_gsi_monitor.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_gsi_monitor.sh ${_ops_opt} ${_verbose_opt} > "${logs_dir}/build_gsi_monitor.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building gsi monitor." echo "The log file is in ${logs_dir}/build_gsi_monitor.log" fi err=$((err + rc)) - } + fi else echo " .... Skip building gsi monitor .... " fi @@ -202,45 +233,51 @@ fi #------------------------------------ # build UPP #------------------------------------ -${Build_upp:?} && { +if [[ ${Build_upp} == 'true' ]]; then echo " .... Building UPP .... " - ./build_upp.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_upp.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_upp.sh ${_ops_opt} ${_verbose_opt} > "${logs_dir}/build_upp.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building UPP." echo "The log file is in ${logs_dir}/build_upp.log" fi err=$((err + rc)) -} +fi #------------------------------------ # build ufs_utils #------------------------------------ -${Build_ufs_utils:?} && { +if [[ ${Build_ufs_utils} == 'true' ]]; then echo " .... Building ufs_utils .... " - ./build_ufs_utils.sh ${_verbose_opt} > ${logs_dir}/build_ufs_utils.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_ufs_utils.sh ${_verbose_opt} > "${logs_dir}/build_ufs_utils.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building ufs_utils." echo "The log file is in ${logs_dir}/build_ufs_utils.log" fi err=$((err + rc)) -} +fi #------------------------------------ # build gldas #------------------------------------ -if [ -d gldas.fd ]; then - ${Build_gldas:?} && { +if [[ -d gldas.fd ]]; then + if [[ ${Build_gldas} == 'true' ]]; then echo " .... Building gldas .... " - ./build_gldas.sh ${_verbose_opt} > ${logs_dir}/build_gldas.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_gldas.sh ${_verbose_opt} > "${logs_dir}/build_gldas.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building gldas." echo "The log file is in ${logs_dir}/build_gldas.log" fi err=$((err + rc)) - } + fi else echo " .... Skip building gldas .... " fi @@ -248,38 +285,31 @@ fi #------------------------------------ # build gfs_wafs - optional checkout #------------------------------------ -if [ -d gfs_wafs.fd ]; then - ${Build_gfs_wafs:?} && { +if [[ -d gfs_wafs.fd ]]; then + if [[ ${Build_gfs_wafs} == 'true' ]]; then echo " .... Building gfs_wafs .... " - ./build_gfs_wafs.sh ${_verbose_opt} > ${logs_dir}/build_gfs_wafs.log 2>&1 + # shellcheck disable=SC2086,SC2248 + ./build_gfs_wafs.sh ${_verbose_opt} > "${logs_dir}/build_gfs_wafs.log" 2>&1 + # shellcheck disable= rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )) ; then echo "Fatal error in building gfs_wafs." echo "The log file is in ${logs_dir}/build_gfs_wafs.log" fi err=$((err + rc)) - } -fi - -#------------------------------------ -# build gfs_utils -#------------------------------------ -${Build_gfs_utils:?} && { - echo " .... Building gfs_utils .... " - target=$target ./build_gfs_utils.sh ${_verbose_opt} > ${logs_dir}/build_gfs_utils.log 2>&1 - rc=$? - if [[ ${rc} -ne 0 ]] ; then - echo "Fatal error in building gfs_utils." - echo "The log file is in ${logs_dir}/build_gfs_utils.log" fi - err=$((err + rc)) -} +fi #------------------------------------ # Exception Handling #------------------------------------ -[[ ${err} -ne 0 ]] && echo "FATAL BUILD ERROR: Please check the log file for detail, ABORT!" -${ERRSCRIPT} || exit ${err} +if (( err != 0 )); then + cat << EOF +BUILD ERROR: One or more components failed to build + Check the associated build log(s) for details. +EOF + ${ERRSCRIPT} || exit "${err}" +fi echo;echo " .... Build system finished .... " diff --git a/sorc/build_gdas.sh b/sorc/build_gdas.sh index 468516ff43a..9c7e024753d 100755 --- a/sorc/build_gdas.sh +++ b/sorc/build_gdas.sh @@ -4,29 +4,26 @@ set -eux script_dir=$(dirname "${BASH_SOURCE[0]}") cd "${script_dir}" || exit 1 -# shellcheck disable=SC1091 source gfs_utils.fd/ush/detect_machine.sh -# shellcheck disable= +source gfs_utils.fd/ush/module-setup.sh # detect_machine now includes the compiler on some machines # but the GDAS build script does not want it MACHINE_ID=$(echo "${MACHINE_ID}" | cut -d "." -f 1) -# use more build jobs if on NOAA HPC -build_jobs=4 case "${MACHINE_ID}" in - hera|orion) - build_jobs=10 - ;; + hera|orion) build_jobs=10 ;; + *) build_jobs=4 ;; esac # Check final exec folder exists -if [ ! -d "../exec" ]; then +if [[ ! -d "../exec" ]]; then mkdir ../exec fi cd gdas.cd + BUILD_JOBS="${build_jobs}" ./build.sh -t "${MACHINE_ID}" -exit +exit $? diff --git a/sorc/build_gfs_wafs.sh b/sorc/build_gfs_wafs.sh index 8e36affd49a..cbbf6ec9507 100755 --- a/sorc/build_gfs_wafs.sh +++ b/sorc/build_gfs_wafs.sh @@ -5,7 +5,7 @@ script_dir=$(dirname "${BASH_SOURCE[0]}") cd "${script_dir}" || exit 1 # Check final exec folder exists -if [ ! -d "../exec" ]; then +if [[ ! -d "../exec" ]]; then mkdir ../exec fi diff --git a/sorc/build_gldas.sh b/sorc/build_gldas.sh index 2b9a9ef5b15..05963b93482 100755 --- a/sorc/build_gldas.sh +++ b/sorc/build_gldas.sh @@ -5,7 +5,7 @@ script_dir=$(dirname "${BASH_SOURCE[0]}") cd "${script_dir}" || exit 1 # Check final exec folder exists -if [ ! -d "../exec" ]; then +if [[ ! -d "../exec" ]]; then mkdir ../exec fi diff --git a/sorc/build_gsi_enkf.sh b/sorc/build_gsi_enkf.sh index 1adb80061b3..671c3d6205b 100755 --- a/sorc/build_gsi_enkf.sh +++ b/sorc/build_gsi_enkf.sh @@ -1,20 +1,18 @@ #! /usr/bin/env bash set -eux -cwd=$(pwd) - OPTIND=1 while getopts ":dov" option; do case "${option}" in d) export BUILD_TYPE="DEBUG";; o) _ops="YES";; v) export BUILD_VERBOSE="YES";; - \?) - echo "[$BASH_SOURCE]: Unrecognized option: ${option}" + :) + echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" usage ;; - :) - echo "[$BASH_SOURCE]: ${option} requires an argument" + *) + echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" usage ;; esac diff --git a/sorc/build_gsi_monitor.sh b/sorc/build_gsi_monitor.sh index 0fa78044d8c..ec3645e52fd 100755 --- a/sorc/build_gsi_monitor.sh +++ b/sorc/build_gsi_monitor.sh @@ -9,12 +9,12 @@ while getopts ":dov" option; do d) export BUILD_TYPE="DEBUG";; o) _ops="YES";; v) export BUILD_VERBOSE="YES";; - \?) - echo "[$BASH_SOURCE]: Unrecognized option: ${option}" + :) + echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" usage ;; - :) - echo "[$BASH_SOURCE]: ${option} requires an argument" + *) + echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" usage ;; esac @@ -23,6 +23,6 @@ shift $((OPTIND-1)) BUILD_TYPE=${BUILD_TYPE:-"Release"} \ BUILD_VERBOSE=${BUILD_VERBOSE:-"NO"} \ -${cwd}/gsi_monitor.fd/ush/build.sh +"${cwd}/gsi_monitor.fd/ush/build.sh" exit diff --git a/sorc/build_gsi_utils.sh b/sorc/build_gsi_utils.sh index bc579300d1d..bcbc110cf6b 100755 --- a/sorc/build_gsi_utils.sh +++ b/sorc/build_gsi_utils.sh @@ -9,12 +9,12 @@ while getopts ":dov" option; do d) export BUILD_TYPE="DEBUG";; o) _ops="YES";; # TODO - unused; remove? v) export BUILD_VERBOSE="YES";; - \?) - echo "[$BASH_SOURCE]: Unrecognized option: ${option}" + :) + echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" usage ;; - :) - echo "[$BASH_SOURCE]: ${option} requires an argument" + *) + echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" usage ;; esac @@ -24,6 +24,6 @@ shift $((OPTIND-1)) BUILD_TYPE=${BUILD_TYPE:-"Release"} \ BUILD_VERBOSE=${BUILD_VERBOSE:-"NO"} \ UTIL_OPTS="-DBUILD_UTIL_ENKF_GFS=ON -DBUILD_UTIL_NCIO=ON" \ -${cwd}/gsi_utils.fd/ush/build.sh +"${cwd}/gsi_utils.fd/ush/build.sh" exit diff --git a/sorc/build_ufs.sh b/sorc/build_ufs.sh index 7c8265b3d8a..bf7d622d387 100755 --- a/sorc/build_ufs.sh +++ b/sorc/build_ufs.sh @@ -8,7 +8,8 @@ APP="S2SWA" CCPP_SUITES="FV3_GFS_v16,FV3_GFS_v16_ugwpv1,FV3_GFS_v17_p8,FV3_GFS_v16_coupled_nsstNoahmpUGWPv1,FV3_GFS_v17_coupled_p8" export RT_COMPILER="intel" -source $cwd/ufs_model.fd/tests/detect_machine.sh +source "${cwd}/ufs_model.fd/tests/detect_machine.sh" +source "${cwd}/ufs_model.fd/tests/module-setup.sh" if [[ ${MACHINE_ID} =~ wcoss2.* ]]; then APP='S2SW' @@ -18,17 +19,17 @@ while getopts ":da:v" option; do case "${option}" in d) BUILD_TYPE="Debug";; a) APP="${OPTARG}" ;; - v) BUILD_VERBOSE="YES";; - \?) - echo "[$BASH_SOURCE]: Unrecognized option: ${option}" - ;; + v) export BUILD_VERBOSE="YES";; :) - echo "[$BASH_SOURCE]: ${option} requires an argument" + echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" + ;; + *) + echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" ;; esac done -cd $cwd/ufs_model.fd +cd "${cwd}/ufs_model.fd" MAKE_OPT="-DAPP=${APP} -DCCPP_SUITES=${CCPP_SUITES}" [[ ${BUILD_TYPE:-"Release"} = "DEBUG" ]] && MAKE_OPT+=" -DDEBUG=ON" @@ -36,8 +37,8 @@ COMPILE_NR=0 CLEAN_BEFORE=YES CLEAN_AFTER=NO -./tests/compile.sh $MACHINE_ID "$MAKE_OPT" $COMPILE_NR $CLEAN_BEFORE $CLEAN_AFTER -mv ./tests/fv3_${COMPILE_NR}.exe ./tests/ufs_model.x -mv ./tests/modules.fv3_${COMPILE_NR}.lua ./tests/modules.ufs_model.lua +./tests/compile.sh "${MACHINE_ID}" "${MAKE_OPT}" "${COMPILE_NR}" "${CLEAN_BEFORE}" "${CLEAN_AFTER}" +mv "./tests/fv3_${COMPILE_NR}.exe" ./tests/ufs_model.x +mv "./tests/modules.fv3_${COMPILE_NR}.lua" ./tests/modules.ufs_model.lua exit 0 diff --git a/sorc/build_upp.sh b/sorc/build_upp.sh index bb9f47dafba..67460487a64 100755 --- a/sorc/build_upp.sh +++ b/sorc/build_upp.sh @@ -11,22 +11,23 @@ while getopts ":dov" option; do d) export BUILD_TYPE="DEBUG";; o) _opts+="-g ";; v) _opts+="-v ";; - \?) - echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" - usage - ;; :) echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" usage ;; + *) + echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}" + usage + ;; esac done shift $((OPTIND-1)) # Check final exec folder exists -if [ ! -d "../exec" ]; then +if [[ ! -d "../exec" ]]; then mkdir ../exec fi cd ufs_model.fd/FV3/upp/tests +# shellcheck disable=SC2086 ./compile_upp.sh ${_opts} diff --git a/sorc/build_ww3prepost.sh b/sorc/build_ww3prepost.sh index 786eeaa7cbf..bf78e7b2ac0 100755 --- a/sorc/build_ww3prepost.sh +++ b/sorc/build_ww3prepost.sh @@ -5,9 +5,8 @@ script_dir=$(dirname "${BASH_SOURCE[0]}") cd "${script_dir}" || exit 1 export RT_COMPILER="intel" -# shellcheck disable=SC1091 -source ${script_dir}/ufs_model.fd/tests/detect_machine.sh -# shellcheck disable= +source "${script_dir}/ufs_model.fd/tests/detect_machine.sh" +source "${script_dir}/ufs_model.fd/tests/module-setup.sh" # Default settings APP="S2SWA" @@ -15,7 +14,7 @@ APP="S2SWA" while getopts "a:v" option; do case "${option}" in a) APP="${OPTARG}" ;; - v) BUILD_VERBOSE="YES";; + v) export BUILD_VERBOSE="YES";; :) echo "[${BASH_SOURCE[0]}]: ${option} requires an argument" usage @@ -37,11 +36,11 @@ fi # Check final exec folder exists -if [ ! -d "../exec" ]; then +if [[ ! -d "../exec" ]]; then mkdir ../exec fi -finalexecdir=$( pwd -P )/../exec +finalexecdir="$( pwd -P )/../exec" #Determine machine and load modules set +x @@ -50,8 +49,9 @@ module load "ufs_${MACHINE_ID}" set -x #Set WW3 directory, switch, prep and post exes -cd ufs_model.fd/WW3 -export WW3_DIR=$( pwd -P ) +cd ufs_model.fd/WW3 || exit 1 +WW3_DIR=$( pwd -P ) +export WW3_DIR export SWITCHFILE="${WW3_DIR}/${ww3switch}" # Build exes for prep jobs and post jobs: @@ -59,12 +59,12 @@ prep_exes="ww3_grid ww3_prep ww3_prnc ww3_grid" post_exes="ww3_outp ww3_outf ww3_outp ww3_gint ww3_ounf ww3_ounp ww3_grib" #create build directory: -path_build="$WW3_DIR/build_SHRD" -mkdir -p "$path_build" || exit 1 -cd "$path_build" || exit 1 +path_build="${WW3_DIR}/build_SHRD" +mkdir -p "${path_build}" || exit 1 +cd "${path_build}" || exit 1 echo "Forcing a SHRD build" -echo $(cat "${SWITCHFILE}") > "${path_build}/tempswitch" +cat "${SWITCHFILE}" > "${path_build}/tempswitch" sed -e "s/DIST/SHRD/g"\ -e "s/OMPG / /g"\ @@ -77,35 +77,35 @@ sed -e "s/DIST/SHRD/g"\ "${path_build}/tempswitch" > "${path_build}/switch" rm "${path_build}/tempswitch" -echo "Switch file is $path_build/switch with switches:" -cat "${path_build}/switch " +echo "Switch file is ${path_build}/switch with switches:" +cat "${path_build}/switch" #Build executables: cmake "${WW3_DIR}" -DSWITCH="${path_build}/switch" -DCMAKE_INSTALL_PREFIX=install rc=$? -if [[ ${rc} -ne 0 ]] ; then +if (( rc != 0 )); then echo "Fatal error in cmake." - exit ${rc} + exit "${rc}" fi make -j 8 rc=$? -if [[ ${rc} -ne 0 ]] ; then +if (( rc != 0 )); then echo "Fatal error in make." - exit ${rc} + exit "${rc}" fi make install -if [[ ${rc} -ne 0 ]] ; then +if (( rc != 0 )); then echo "Fatal error in make install." - exit ${rc} + exit "${rc}" fi # Copy to top-level exe directory for prog in ${prep_exes} ${post_exes}; do cp "${path_build}/install/bin/${prog}" "${finalexecdir}/" rc=$? - if [[ ${rc} -ne 0 ]] ; then + if (( rc != 0 )); then echo "FATAL: Unable to copy ${path_build}/${prog} to ${finalexecdir} (Error code ${rc})" - exit ${rc} + exit "${rc}" fi done diff --git a/sorc/checkout.sh b/sorc/checkout.sh index d35e9a5b9c2..faa6bc21185 100755 --- a/sorc/checkout.sh +++ b/sorc/checkout.sh @@ -151,7 +151,7 @@ mkdir -p "${logdir}" # The checkout version should always be a speciifc commit (hash or tag), not a branch errs=0 -checkout "gfs_utils.fd" "https://github.com/NOAA-EMC/gfs-utils" "af933d3" ; errs=$((errs + $?)) +checkout "gfs_utils.fd" "https://github.com/NOAA-EMC/gfs-utils" "0b8ff56" ; errs=$((errs + $?)) checkout "ufs_model.fd" "https://github.com/ufs-community/ufs-weather-model" "${ufs_model_hash:-6b73f5d}" ; errs=$((errs + $?)) checkout "ufs_utils.fd" "https://github.com/ufs-community/UFS_UTILS.git" "8b990c0" ; errs=$((errs + $?)) checkout "verif-global.fd" "https://github.com/NOAA-EMC/EMC_verif-global.git" "c267780" ; errs=$((errs + $?))