Skip to content

Commit

Permalink
First wave of linter fixes
Browse files Browse the repository at this point in the history
First wave of linter fixes for removing gfs-utils code/fix reorg.

Refs: NOAA-EMC#966
  • Loading branch information
WalterKolczynski-NOAA committed Oct 4, 2022
1 parent d7e1f29 commit 797dd70
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 331 deletions.
167 changes: 84 additions & 83 deletions sorc/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function _usage() {
Builds all of the global-workflow components by calling the individual build
scripts in sequence.
Usage: $BASH_SOURCE [-a UFS_app][-c build_config][-h][-v]
Usage: ${BASH_SOURCE[0]} [-a UFS_app][-c build_config][-h][-v]
-a UFS_app:
Build a specific UFS app instead of the default
-c build_config:
Expand All @@ -30,7 +30,7 @@ EOF
}

script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") &> /dev/null && pwd)
cd ${script_dir}
cd "${script_dir}" || exit 1

_build_ufs_opt=""
_ops_opt=""
Expand All @@ -46,22 +46,22 @@ while getopts ":a:c:hov" option; do
# s) _build_ufs_opt+="-s ${OPTARG} ";;
v) _verbose_opt="-v";;
\?)
echo "[$BASH_SOURCE]: Unrecognized option: ${option}"
echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}"
usage
;;
:)
echo "[$BASH_SOURCE]: ${option} requires an argument"
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
usage
;;
esac
done

shift $((OPTIND-1))

logs_dir=${script_dir}/logs
if [ ! -d $logs_dir ]; then
logs_dir="${script_dir}/logs"
if [ ! -d "${logs_dir}" ]; then
echo "Creating logs folder"
mkdir $logs_dir
mkdir "${logs_dir}" || exit 1
fi

# Check final exec folder exists
Expand All @@ -74,7 +74,9 @@ fi
# GET MACHINE
#------------------------------------
target=""
# shellcheck disable=SC1091
source gfs_utils.fd/ush/machine-setup.sh > /dev/null 2>&1
# shellcheck disable=
if [[ -z "${target}" ]]; then
echo "FATAL: Unable to determine target machine"
exit 1
Expand All @@ -85,10 +87,9 @@ fi
#------------------------------------
source ./partial_build.sh $_verbose_opt $_partial_opt

if [ $target = jet ]; then
Build_gldas=false
Build_gfs_util=false
Build_ww3_prepost=false
if [[ ${target} == "jet" ]]; then
Build_gldas="false"
Build_ww3_prepost="false"
fi

#------------------------------------
Expand All @@ -100,44 +101,44 @@ err=0
#------------------------------------
# build WW3 pre & post execs
#------------------------------------
$Build_ww3_prepost && {
${Build_ww3_prepost} && {
echo " .... Building WW3 pre and post execs .... "
./build_ww3prepost.sh ${_verbose_opt} ${_build_ufs_opt} > $logs_dir/build_ww3_prepost.log 2>&1
./build_ww3prepost.sh ${_verbose_opt} ${_build_ufs_opt} > ${logs_dir}/build_ww3_prepost.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building WW3 pre/post processing."
echo "The log file is in $logs_dir/build_ww3_prepost.log"
echo "The log file is in ${logs_dir}/build_ww3_prepost.log"
fi
((err+=$rc))
err=$((err + rc))
}

#------------------------------------
# build forecast model
#------------------------------------
$Build_ufs_model && {
${Build_ufs_model} && {
echo " .... Building forecast model .... "
./build_ufs.sh $_verbose_opt ${_build_ufs_opt} > $logs_dir/build_ufs.log 2>&1
./build_ufs.sh ${_verbose_opt} ${_build_ufs_opt} > ${logs_dir}/build_ufs.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building UFS model."
echo "The log file is in $logs_dir/build_ufs.log"
echo "The log file is in ${logs_dir}/build_ufs.log"
fi
((err+=$rc))
err=$((err + rc))
}

#------------------------------------
# build GSI and EnKF - optional checkout
#------------------------------------
if [ -d gsi_enkf.fd ]; then
$Build_gsi_enkf && {
${Build_gsi_enkf} && {
echo " .... Building gsi and enkf .... "
./build_gsi_enkf.sh $_ops_opt $_verbose_opt > $logs_dir/build_gsi_enkf.log 2>&1
./build_gsi_enkf.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_gsi_enkf.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building gsi_enkf."
echo "The log file is in $logs_dir/build_gsi_enkf.log"
echo "The log file is in ${logs_dir}/build_gsi_enkf.log"
fi
((err+=$rc))
err=$((err + rc))
}
else
echo " .... Skip building gsi and enkf .... "
Expand All @@ -147,15 +148,15 @@ fi
# build gsi utilities
#------------------------------------
if [ -d gsi_utils.fd ]; then
$Build_gsi_utils && {
${Build_gsi_utils} && {
echo " .... Building gsi utilities .... "
./build_gsi_utils.sh $_ops_opt $_verbose_opt > $logs_dir/build_gsi_utils.log 2>&1
./build_gsi_utils.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_gsi_utils.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building gsi utilities."
echo "The log file is in $logs_dir/build_gsi_utils.log"
echo "The log file is in ${logs_dir}/build_gsi_utils.log"
fi
((err+=$rc))
err=$((err + rc))
}
else
echo " .... Skip building gsi utilities .... "
Expand All @@ -165,15 +166,15 @@ fi
# build gdas - optional checkout
#------------------------------------
if [ -d gdas.cd ]; then
$Build_gdas && {
${Build_gdas} && {
echo " .... Building GDASApp .... "
./build_gdas.sh $_verbose_opt > $logs_dir/build_gdas.log 2>&1
./build_gdas.sh ${_verbose_opt} > ${logs_dir}/build_gdas.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building GDASApp."
echo "The log file is in $logs_dir/build_gdas.log"
echo "The log file is in ${logs_dir}/build_gdas.log"
fi
((err+=$rc))
err=$((err + rc))
}
else
echo " .... Skip building GDASApp .... "
Expand All @@ -183,62 +184,62 @@ fi
# build gsi monitor
#------------------------------------
if [ -d gsi_monitor.fd ]; then
$Build_gsi_monitor && {
echo " .... Building gsi monitor .... "
./build_gsi_monitor.sh $_ops_opt $_verbose_opt > $logs_dir/build_gsi_monitor.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gsi monitor."
echo "The log file is in $logs_dir/build_gsi_monitor.log"
fi
((err+=$rc))
}
${Build_gsi_monitor} && {
echo " .... Building gsi monitor .... "
./build_gsi_monitor.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_gsi_monitor.log 2>&1
rc=$?
if [[ ${rc} -ne 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))
}
else
echo " .... Skip building gsi monitor .... "
fi

#------------------------------------
# build UPP
#------------------------------------
$Build_upp && {
${Build_upp} && {
echo " .... Building UPP .... "
./build_upp.sh $_ops_opt $_verbose_opt > $logs_dir/build_upp.log 2>&1
./build_upp.sh ${_ops_opt} ${_verbose_opt} > ${logs_dir}/build_upp.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building UPP."
echo "The log file is in $logs_dir/build_upp.log"
echo "The log file is in ${logs_dir}/build_upp.log"
fi
((err+=$rc))
err=$((err + rc))
}

#------------------------------------
# build ufs_utils
#------------------------------------
$Build_ufs_utils && {
${Build_ufs_utils} && {
echo " .... Building ufs_utils .... "
./build_ufs_utils.sh $_verbose_opt > $logs_dir/build_ufs_utils.log 2>&1
./build_ufs_utils.sh ${_verbose_opt} > ${logs_dir}/build_ufs_utils.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building ufs_utils."
echo "The log file is in $logs_dir/build_ufs_utils.log"
echo "The log file is in ${logs_dir}/build_ufs_utils.log"
fi
((err+=$rc))
err=$((err + rc))
}

#------------------------------------
# build gldas
#------------------------------------
if [ -d gldas.fd ]; then
$Build_gldas && {
echo " .... Building gldas .... "
./build_gldas.sh $_verbose_opt > $logs_dir/build_gldas.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gldas."
echo "The log file is in $logs_dir/build_gldas.log"
fi
((err+=$rc))
}
${Build_gldas} && {
echo " .... Building gldas .... "
./build_gldas.sh ${_verbose_opt} > ${logs_dir}/build_gldas.log 2>&1
rc=$?
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building gldas."
echo "The log file is in ${logs_dir}/build_gldas.log"
fi
err=$((err + rc))
}
else
echo " .... Skip building gldas .... "
fi
Expand All @@ -247,37 +248,37 @@ fi
# build gfs_wafs - optional checkout
#------------------------------------
if [ -d gfs_wafs.fd ]; then
$Build_gfs_wafs && {
echo " .... Building gfs_wafs .... "
./build_gfs_wafs.sh $_verbose_opt > $logs_dir/build_gfs_wafs.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_wafs."
echo "The log file is in $logs_dir/build_gfs_wafs.log"
fi
((err+=$rc))
}
${Build_gfs_wafs} && {
echo " .... Building gfs_wafs .... "
./build_gfs_wafs.sh ${_verbose_opt} > ${logs_dir}/build_gfs_wafs.log 2>&1
rc=$?
if [[ ${rc} -ne 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 && {
${Build_gfs_utils} && {
echo " .... Building gfs_utils .... "
target=$target ./build_gfs_utils.sh $_verbose_opt > $logs_dir/build_gfs_utils.log 2>&1
target=$target ./build_gfs_utils.sh ${_verbose_opt} > ${logs_dir}/build_gfs_utils.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
if [[ ${rc} -ne 0 ]] ; then
echo "Fatal error in building gfs_utils."
echo "The log file is in $logs_dir/build_gfs_utils.log"
echo "The log file is in ${logs_dir}/build_gfs_utils.log"
fi
((err+=$rc))
err=$((err + rc))
}

#------------------------------------
# Exception Handling
#------------------------------------
[[ $err -ne 0 ]] && echo "FATAL BUILD ERROR: Please check the log file for detail, ABORT!"
$ERRSCRIPT || exit $err
[[ ${err} -ne 0 ]] && echo "FATAL BUILD ERROR: Please check the log file for detail, ABORT!"
${ERRSCRIPT} || exit ${err}

echo;echo " .... Build system finished .... "

Expand Down
10 changes: 6 additions & 4 deletions sorc/build_gdas.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#! /usr/bin/env bash
set -eux

script_dir=$(dirname ${BASH_SOURCE[0]})
cd ${script_dir}
script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${script_dir}" || exit 1

# shellcheck disable=SC1091
source gfs_utils.fd/ush/machine-setup.sh > /dev/null 2>&1
# shellcheck disable=

export BUILD_TARGET=$target
export BUILD_TARGET="${target}"

# use more build jobs if on NOAA HPC
build_jobs=4
Expand All @@ -22,7 +24,7 @@ if [ ! -d "../exec" ]; then
fi

cd gdas.cd
BUILD_JOBS=$build_jobs ./build.sh -t $BUILD_TARGET
BUILD_JOBS="${build_jobs}" ./build.sh -t "${BUILD_TARGET}"

exit

22 changes: 19 additions & 3 deletions sorc/build_gfs_utils.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
#! /usr/bin/env bash
set -eux

function _usage() {
cat << EOF
Builds all of the global-workflow components by calling the individual build
scripts in sequence.
Usage: ${BASH_SOURCE[0]} [-d][-h][-v]
-d:
Build with debug options
-h:
Print this help message and exit
-v:
Turn on verbose output
EOF
exit 1
}

cwd=$(pwd)

OPTIND=1
while getopts ":dov" option; do
while getopts ":dv" option; do
case "${option}" in
d) export BUILD_TYPE="DEBUG";;
v) export BUILD_VERBOSE="YES";;
\?)
echo "[$BASH_SOURCE]: Unrecognized option: ${option}"
echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}"
usage
;;
:)
echo "[$BASH_SOURCE]: ${option} requires an argument"
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
usage
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions sorc/build_gfs_wafs.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /usr/bin/env bash
set -eux

script_dir=$(dirname ${BASH_SOURCE[0]})
cd ${script_dir}
script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${script_dir}" || exit 1

# Check final exec folder exists
if [ ! -d "../exec" ]; then
Expand Down
Loading

0 comments on commit 797dd70

Please sign in to comment.