Skip to content

Commit

Permalink
Allow building of the ufs-weather-model, WW3 pre/post execs for GFS, …
Browse files Browse the repository at this point in the history
…GEFS, SFS in the same clone of global-workflow (NOAA-EMC#3098)

GFS and GEFS (and now SFS) uses different compile time options for the
UFS-weather-model. For the purposes of CI testing, a multi-build
pipeline under Jenkins was created by @TerrenceMcGuinness-NOAA. This
served well, until now. With the inclusion of SFS, a third variety of
the model is being built. Under the multi-build pipeline paradigm, a
second (or third) clone and build of the global-workflow is required.
This adds cloning and compilation time of the global-workflow.

This PR allows compiling the ufs-weather-model in a single clone of the
global-workflow. The compiled executables based on the options for GFS,
GEFS, and SFS results in a model executable as `gfs_model.x`,
`gefs_model.x`, and `sfs_model.x`. The forecast script uses the right
executable.

This PR also differentiates the WW3 pre/post executables based on `gfs_`
or `gefs_`. SFS variants need to be introduced, when `NET=sfs` is added.
In the process of updating the WW3 pre/post executable names, it was
discovered (via `grep`) the following are not used:
- `ww3_prep`
- `ww3_outf`
- `ww3_ounf`
- `ww3_ounp`
These need to be confirmed by running the workflow to ensure they are
indeed not used at runtime.

This PR also updates the `Jenkinsfile` to use the multi-build from the
single location.
---------

Co-authored-by: Walter Kolczynski - NOAA <Walter.Kolczynski@noaa.gov>
Co-authored-by: David Huber <69919478+DavidHuber-NOAA@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent bef3e0b commit be7626d
Show file tree
Hide file tree
Showing 18 changed files with 359 additions and 374 deletions.
180 changes: 77 additions & 103 deletions ci/Jenkinsfile

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ci/cases/pr/C48_S2SWA_gefs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ arguments:
yaml: {{ HOMEgfs }}/ci/cases/yamls/gefs_defaults_ci.yaml

skip_ci_on_hosts:
- wcoss2
- None
2 changes: 1 addition & 1 deletion ci/cases/pr/C96_S2SWA_gefs_replay_ics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ arguments:
icsdir: {{ 'ICSDIR_ROOT' | getenv }}/C96mx100/20240610

skip_ci_on_hosts:
- wcoss2
- None
3 changes: 0 additions & 3 deletions ci/cases/yamls/build.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions ci/scripts/utils/ci_utils_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
HOMEgfs="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." >/dev/null 2>&1 && pwd )"
source "${HOMEgfs}/ush/detect_machine.sh"

utitilty_function="${1}"
utility_function="${1}"

source "${HOMEgfs}/ci/scripts/utils/ci_utils.sh"
${utitilty_function} "${@:2}"
${utility_function} "${@:2}"
10 changes: 7 additions & 3 deletions parm/config/gefs/config.fcst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ export esmf_logkind="ESMF_LOGKIND_MULTI_ON_ERROR" #Options: ESMF_LOGKIND_MULTI_O

export FORECASTSH="${SCRgfs}/exglobal_forecast.sh"
#export FORECASTSH="${SCRgfs}/exglobal_forecast.py" # Temp. while this is worked on
export FCSTEXEC="ufs_model.x"
if [[ "${SFS_POST:-}" == "YES" ]]; then
export FCSTEXEC="sfs_model.x"
else
export FCSTEXEC="gefs_model.x"
fi

#######################################################################
# Model configuration
Expand Down Expand Up @@ -105,7 +109,7 @@ if (( gwd_opt == 2 )); then
export do_gsl_drag_ls_bl=".true."
export do_gsl_drag_ss=".false."
export do_gsl_drag_tofd=".true."
export do_gwd_opt_psl=".true."
export do_gwd_opt_psl=".true."
export do_ugwp_v1_orog_only=".false."
launch_level=$(echo "${LEVS}/2.35" |bc)
export launch_level
Expand Down Expand Up @@ -133,7 +137,7 @@ if [[ "${progsigma}" == ".true." ]]; then tbp="_progsigma" ; fi
if [[ "${DO_AERO_FCST}" == "YES" ]]; then
export IAER=2011 # spectral band mapping method for aerosol optical properties
else
export IAER=1011
export IAER=1011
fi
export iovr_lw=3 ; #de-correlation length cloud overlap method (Barker, 2008)
export iovr_sw=3 ; #de-correlation length cloud overlap method (Barker, 2008)
Expand Down
6 changes: 3 additions & 3 deletions parm/config/gfs/config.fcst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export esmf_logkind="ESMF_LOGKIND_MULTI_ON_ERROR" #Options: ESMF_LOGKIND_MULTI_O

export FORECASTSH="${SCRgfs}/exglobal_forecast.sh"
#export FORECASTSH="${SCRgfs}/exglobal_forecast.py" # Temp. while this is worked on
export FCSTEXEC="ufs_model.x"
export FCSTEXEC="gfs_model.x"

#######################################################################
# Model configuration
Expand Down Expand Up @@ -116,7 +116,7 @@ if (( gwd_opt == 2 )); then
export do_gsl_drag_ls_bl=".true."
export do_gsl_drag_ss=".false."
export do_gsl_drag_tofd=".true."
export do_gwd_opt_psl=".true."
export do_gwd_opt_psl=".true."
export do_ugwp_v1_orog_only=".false."
launch_level=$(echo "${LEVS}/2.35" |bc)
export launch_level
Expand Down Expand Up @@ -148,7 +148,7 @@ if [[ "${progsigma}" == ".true." ]]; then tbp="_progsigma" ; fi
if [[ "${DO_AERO_FCST}" == "YES" ]]; then
export IAER=2011 # spectral band mapping method for aerosol optical properties
else
export IAER=1011
export IAER=1011
fi
export iovr_lw=3 ; #de-correlation length cloud overlap method (Barker, 2008)
export iovr_sw=3 ; #de-correlation length cloud overlap method (Barker, 2008)
Expand Down
10 changes: 5 additions & 5 deletions scripts/exgfs_wave_post_pnt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,18 @@ source "${USHgfs}/preamble.sh"
rm -f buoy_tmp.loc buoy_log.ww3 ww3_oup.inp
${NLN} ./out_pnt.${waveuoutpGRD} ./out_pnt.ww3
${NLN} ./mod_def.${waveuoutpGRD} ./mod_def.ww3
export pgm=ww3_outp;. prep_step
${EXECgfs}/ww3_outp > buoy_lst.loc 2>&1
export err=$?;err_chk

export pgm="${NET,,}_ww3_outp.x"
source prep_step

"${EXECgfs}/${pgm}" > buoy_lst.loc 2>&1
export err=$?;err_chk
if [ "$err" != '0' ] && [ ! -f buoy_log.ww3 ]
then
pgm=wave_post
set +x
echo ' '
echo '******************************************** '
echo '*** FATAL ERROR : ERROR IN ww3_outp *** '
echo "*** FATAL ERROR : ERROR IN ${pgm} *** "
echo '******************************************** '
echo ' '
cat buoy_tmp.loc
Expand Down
7 changes: 4 additions & 3 deletions sorc/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ _wave_opt=""
_hydro_opt=""
_build_job_max=20
_quick_kill="NO"
_ufs_exec="-e gfs_model.x"
# Reset option counter in case this script is sourced
OPTIND=1
while getopts ":a:dfghj:kuvwy" option; do
Expand All @@ -69,8 +70,8 @@ while getopts ":a:dfghj:kuvwy" option; do
k) _quick_kill="YES" ;;
u) _build_ufsda="YES" ;;
v) _verbose_opt="-v";;
w) _wave_opt="-w";;
y) _hydro_opt="-y";;
w) _wave_opt="-w"; _ufs_exec="-e gefs_model.x";;
y) _hydro_opt="-y"; _ufs_exec="-e sfs_model.x";;
:)
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
_usage
Expand Down Expand Up @@ -133,7 +134,7 @@ declare -A build_opts
big_jobs=0
build_jobs["ufs"]=8
big_jobs=$((big_jobs+1))
build_opts["ufs"]="${_wave_opt} ${_hydro_opt} ${_verbose_opt} ${_build_ufs_opt} ${_build_debug}"
build_opts["ufs"]="${_wave_opt} ${_hydro_opt} ${_verbose_opt} ${_build_ufs_opt} ${_build_debug} ${_ufs_exec}"

build_jobs["upp"]=1
build_opts["upp"]="${_build_debug}"
Expand Down
21 changes: 15 additions & 6 deletions sorc/build_ufs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ APP="S2SWA"
CCPP_SUITES="FV3_GFS_v17_p8_ugwpv1,FV3_GFS_v17_coupled_p8_ugwpv1,FV3_global_nest_v1" # TODO: does the g-w need to build with all these CCPP_SUITES?
PDLIB="ON"
HYDRO="OFF"
EXEC_NAME="gfs_model.x"

while getopts ":da:fj:vwy" option; do
while getopts ":da:fj:e:vwy" option; do
case "${option}" in
d) BUILD_TYPE="Debug";;
a) APP="${OPTARG}";;
Expand All @@ -18,6 +19,7 @@ while getopts ":da:fj:vwy" option; do
v) export BUILD_VERBOSE="YES";;
w) PDLIB="OFF";;
y) HYDRO="ON";;
e) EXEC_NAME="${OPTARG}";;
:)
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
;;
Expand All @@ -40,13 +42,20 @@ if [[ ${BUILD_TYPE:-"Release"} = "DEBUG" ]] ; then
elif [[ "${FASTER:-OFF}" == ON ]] ; then
MAKE_OPT+=" -DFASTER=ON"
fi
COMPILE_NR=0

case "${EXEC_NAME}" in
"ufs_model.x") COMPILE_ID=0 ;;
"gfs_model.x") COMPILE_ID=1 ;;
"gefs_model.x") COMPILE_ID=2 ;;
"sfs_model.x") COMPILE_ID=3 ;;
*) echo "Unsupported executable name: ${EXEC_NAME}"; exit 1 ;;
esac
CLEAN_BEFORE=YES
CLEAN_AFTER=NO

BUILD_JOBS=${BUILD_JOBS:-8} ./tests/compile.sh "${MACHINE_ID}" "${MAKE_OPT}" "${COMPILE_NR}" "intel" "${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
cp "./modulefiles/ufs_common.lua" ./tests/ufs_common.lua
BUILD_JOBS=${BUILD_JOBS:-8} ./tests/compile.sh "${MACHINE_ID}" "${MAKE_OPT}" "${COMPILE_ID}" "intel" "${CLEAN_BEFORE}" "${CLEAN_AFTER}"
mv "./tests/fv3_${COMPILE_ID}.exe" "./tests/${EXEC_NAME}"
if [[ ! -f "./tests/modules.ufs_model.lua" ]]; then mv "./tests/modules.fv3_${COMPILE_ID}.lua" "./tests/modules.ufs_model.lua"; fi
if [[ ! -f "./tests/ufs_common.lua" ]]; then cp "./modulefiles/ufs_common.lua" ./tests/ufs_common.lua; fi

exit 0
133 changes: 54 additions & 79 deletions sorc/build_ww3prepost.sh
Original file line number Diff line number Diff line change
@@ -1,132 +1,107 @@
#! /usr/bin/env bash
set -x

script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${script_dir}" || exit 1
# shellcheck disable=SC2312
_HOMEgfs=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )/.." && pwd -P)
cd "${_HOMEgfs}/sorc" || exit 1

# Default settings
APP="S2SWA"
PDLIB="ON"

while getopts ":j:a:dvw" option; do
case "${option}" in
a) APP="${OPTARG}";;
d) BUILD_TYPE="Debug";;
j) BUILD_JOBS="${OPTARG}";;
v) export BUILD_VERBOSE="YES";;
w) PDLIB="OFF";;
:)
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
usage
;;
*)
echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}"
usage
;;
d) BUILD_TYPE="Debug" ;;
j) BUILD_JOBS="${OPTARG}" ;;
v) export BUILD_VERBOSE="YES" ;;
w) PDLIB="OFF" ;;
:)
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
usage
;;
*)
echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}"
usage
;;
esac
done

# Determine which switch to use
if [[ "${APP}" == "ATMW" ]]; then
ww3switch="model/esmf/switch"
else
if [[ "${PDLIB}" == "ON" ]]; then
ww3switch="model/bin/switch_meshcap_pdlib"
else
ww3switch="model/bin/switch_meshcap"
fi
fi

# Check final exec folder exists
if [[ ! -d "../exec" ]]; then
mkdir ../exec
fi

finalexecdir="$( pwd -P )/../exec"

#Determine machine and load modules
# Determine machine and load modules
set +x
source "${script_dir}/ufs_model.fd/tests/detect_machine.sh"
source "${script_dir}/ufs_model.fd/tests/module-setup.sh"
module use "${script_dir}/ufs_model.fd/modulefiles"
source "${_HOMEgfs}/sorc/ufs_model.fd/tests/detect_machine.sh"
source "${_HOMEgfs}/sorc/ufs_model.fd/tests/module-setup.sh"
module use "${_HOMEgfs}/sorc/ufs_model.fd/modulefiles"
module load "ufs_${MACHINE_ID}.intel"
set -x

#Set WW3 directory, switch, prep and post exes
cd ufs_model.fd/WW3 || exit 1
WW3_DIR=$( pwd -P )
#Set WW3 directory
cd "${_HOMEgfs}/sorc/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:
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"
# Determine which switch to use
if [[ "${PDLIB}" == "ON" ]]; then
ww3switch="model/bin/switch_meshcap_pdlib"
path_build="${WW3_DIR}/build/pdlib_ON"
path_install="${WW3_DIR}/install/pdlib_ON"
else
ww3switch="model/bin/switch_meshcap"
path_build="${WW3_DIR}/build/pdlib_OFF"
path_install="${WW3_DIR}/install/pdlib_OFF"
fi
export SWITCHFILE="${WW3_DIR}/${ww3switch}"

#create build directory:
path_build="${WW3_DIR}/build_SHRD"
[[ -d "${path_build}" ]] && rm -rf "${path_build}"
mkdir -p "${path_build}" || exit 1
cd "${path_build}" || exit 1
echo "Forcing a SHRD build"

buildswitch="${path_build}/switch"

cat "${SWITCHFILE}" > "${path_build}/tempswitch"

sed -e "s/DIST/SHRD/g"\
-e "s/OMPG / /g"\
-e "s/OMPH / /g"\
-e "s/MPIT / /g"\
-e "s/MPI / /g"\
-e "s/PIO / /g"\
-e "s/B4B / /g"\
-e "s/PDLIB / /g"\
-e "s/SCOTCH / /g"\
-e "s/METIS / /g"\
-e "s/NOGRB/NCEP2/g"\
"${path_build}/tempswitch" > "${path_build}/switch"
cat "${SWITCHFILE}" >"${path_build}/tempswitch"

sed -e "s/DIST/SHRD/g" \
-e "s/OMPG / /g" \
-e "s/OMPH / /g" \
-e "s/MPIT / /g" \
-e "s/MPI / /g" \
-e "s/PIO / /g" \
-e "s/B4B / /g" \
-e "s/PDLIB / /g" \
-e "s/SCOTCH / /g" \
-e "s/METIS / /g" \
-e "s/NOGRB/NCEP2/g" \
"${path_build}/tempswitch" >"${path_build}/switch"
rm "${path_build}/tempswitch"

echo "Switch file is ${buildswitch} with switches:"
cat "${buildswitch}"

#define cmake build options
MAKE_OPT="-DCMAKE_INSTALL_PREFIX=install"
MAKE_OPT="-DCMAKE_INSTALL_PREFIX=${path_install}"
[[ ${BUILD_TYPE:-"Release"} = "Debug" ]] && MAKE_OPT+=" -DCMAKE_BUILD_TYPE=Debug"

#Build executables:
# shellcheck disable=SC2086
cmake "${WW3_DIR}" -DSWITCH="${buildswitch}" ${MAKE_OPT}
rc=$?
if (( rc != 0 )); then
if ((rc != 0)); then
echo "Fatal error in cmake."
exit "${rc}"
fi

make -j "${BUILD_JOBS:-8}"
rc=$?
if (( rc != 0 )); then
if ((rc != 0)); then
echo "Fatal error in make."
exit "${rc}"
fi

make install
if (( rc != 0 )); then
rc=$?
if ((rc != 0)); then
echo "Fatal error in make install."
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 != 0 )); then
echo "FATAL: Unable to copy ${path_build}/${prog} to ${finalexecdir} (Error code ${rc})"
exit "${rc}"
fi
done

#clean-up build directory:
echo "executables are in ${finalexecdir}"
echo "cleaning up ${path_build}"
rm -rf "${path_build}"

exit 0
Loading

0 comments on commit be7626d

Please sign in to comment.