Skip to content

Commit

Permalink
Changes to the way modules for the various workflow tasks are loaded …
Browse files Browse the repository at this point in the history
…to make the process more flexible, as follows:

1) Rename the module files for several tasks (only for hera thus far) from ${filename} to ${filename}.hardcoded.  These are for backup and will be removed once it is clear that the "dynamic" modulefile method (see #2 below) is working reliably.
2) Put in code in the experiment/workflow generation scripts that create links to "dynamic" versions of these files in the external repos.  These are dynamic in the sense that they should be compatible with the version of code in the repository.  This will (hopefully!) eliminate the need to maintain hard-coded module files in the workflow repository (at least for codes that are external to the repository).
3) Modify the load_modules_run_task.sh script so that some of the "dynamic" module files are sourced like a shells script instead of being loaded using "module load ...".  This is because this subset of "dynamic" module files are in fact shell scripts because they contain shell commands (like "export ${SOME_VARIABLE}").  These module files need to be fixed in the external repos (notably in the UFS_UTILS repository) so that they are true Lua module files.
  • Loading branch information
gsketefian committed Dec 11, 2019
1 parent 4427da4 commit 8fed29a
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 11 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion modulefiles/hera/run_fcst_ccpp

This file was deleted.

41 changes: 41 additions & 0 deletions ush/generate_FV3SAR_wflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,47 @@ all_cycledefs=${all_cycledefs//&/\\\&}
sed -i -r -e "s|${regex_search}|${all_cycledefs}|g" "${WFLOW_XML_FP}"


#
#-----------------------------------------------------------------------
#
# For select workflow tasks, create symlinks (in an appropriate subdi-
# rectory under the workflow directory tree) that point to module files
# in the various cloned external repositories. In principle, this is
# better than having hard-coded module files for tasks because the sym-
# links will always point to updated module files. However, it does re-
# quire that these module files in the external repositories be coded
# correctly, e.g. that they really be lua module files and not contain
# any shell commands (like "export SOME_VARIABLE").
#
#-----------------------------------------------------------------------
#
machine=${MACHINE,,}

cd_vrfy "${MODULES_DIR}/$machine"

#
# The "module" file (really a shell script) for orog in the UFS_UTILS
# repo uses a shell variable named MOD_PATH, but it is not clear where
# that is defined. That needs to be fixed. Until then, we have to use
# a hard-coded module file, which may or may not be compatible with the
# modules used in the UFS_UTILS repo to build the orog code.
#ln_vrfy -fs "${UFS_UTILS_DIR}/modulefiles/fv3gfs/orog.$machine" \
# "${MAKE_OROG_TN}"
ln_vrfy -fs "make_orog.hardcoded" "${MAKE_OROG_TN}"

ln_vrfy -fs "${UFS_UTILS_DIR}/modulefiles/modulefile.sfc_climo_gen.$machine" \
"${MAKE_SFC_CLIMO_TN}"

ln_vrfy -fs "${CHGRES_DIR}/modulefiles/chgres_cube.$machine" \
"${MAKE_ICS_TN}"

ln_vrfy -fs "${CHGRES_DIR}/modulefiles/chgres_cube.$machine" \
"${MAKE_LBCS_TN}"

ln_vrfy -fs "${UFS_WTHR_MDL_DIR}/NEMS/src/conf/modules.nems" \
"${RUN_FCST_TN}"

cd_vrfy -
#
#-----------------------------------------------------------------------
#
Expand Down
51 changes: 41 additions & 10 deletions ush/load_modules_run_task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,18 @@ modulefile_name="${task_name}"
# regardless of the setting of USE_CCPP. But this requires that we then
# test the non-CCPP-enabled version, which we've never done. Leave this
# for another time...
if [ "${task_name}" = "run_fcst" ]; then
if [ "${USE_CCPP}" = "TRUE" ]; then
modulefile_name=${modulefile_name}_ccpp
else
modulefile_name=${modulefile_name}_no_ccpp
fi
fi
#if [ "${task_name}" = "run_fcst" ]; then
# if [ "${USE_CCPP}" = "TRUE" ]; then
# modulefile_name=${modulefile_name}_ccpp
# else
# modulefile_name=${modulefile_name}_no_ccpp
# fi
#fi
#
#-----------------------------------------------------------------------
#
# This comment needs to be updated:
#
# Use the "readlink" command to resolve the full path to the module file
# and then verify that the file exists. This is not necessary for most
# tasks, but for the run_fcst task, when CCPP is enabled, the module
Expand All @@ -228,7 +230,11 @@ modulefile_path=$( readlink -f "${modules_dir}/${modulefile_name}" )

if [ ! -f "${modulefile_path}" ]; then

if [ "${task_name}" = "run_fcst" ]; then
if [ "${task_name}" = "${MAKE_OROG_TN}" -o \
"${task_name}" = "${MAKE_SFC_CLIMO_TN}" -o \
"${task_name}" = "${MAKE_ICS_TN}" -o \
"${task_name}" = "${MAKE_LBCS_TN}" -o \
"${task_name}" = "${RUN_FCST_TN}" ]; then

print_err_msg_exit "\
The target (modulefile_path) of the symlink (modulefile_name) in the
Expand Down Expand Up @@ -267,8 +273,33 @@ module purge
module use "${modules_dir}" || print_err_msg_exit "\
Call to \"module use\" command failed."

module load ${modulefile_name} || print_err_msg_exit "\
Call to \"module load\" command failed."
#
# Some of the task module files that are symlinks to module files in the
# external repositories are in fact shell scripts (they shouldn't be;
# such cases should be fixed in the external repositories). For such
# files, we source the "module" file. For true module files, we use the
# "module load" command.
#
case "${task_name}" in
#
"${MAKE_ICS_TN}" | "${MAKE_LBCS_TN}" | "${MAKE_SFC_CLIMO_TN}")
. ${modulefile_path} || print_err_msg_exit "\
Sourcing of \"module\" file (modulefile_path; really a shell script) for
the specified task (task_name) failed:
task_name = \"${task_name}\"
modulefile_path = \"${modulefile_path}\""
;;
#
*)
module load ${modulefile_name} || print_err_msg_exit "\
Loading of module file (modulefile_name; in directory specified by mod-
ules_dir) for the specified task (task_name) failed:
task_name = \"${task_name}\"
modulefile_name = \"${modulefile_name}\"
modules_dir = \"${modules_dir}\""
;;
#
esac

module list
#
Expand Down
2 changes: 2 additions & 0 deletions ush/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ SCRIPTSDIR="$HOMErrfs/scripts"
JOBSDIR="$HOMErrfs/jobs"
SORCDIR="$HOMErrfs/sorc"
PARMDIR="$HOMErrfs/parm"
MODULES_DIR="$HOMErrfs/modulefiles"
EXECDIR="$HOMErrfs/exec"
FIXrrfs="$HOMErrfs/fix"
FIXupp="$FIXrrfs/fix_upp"
Expand Down Expand Up @@ -1907,6 +1908,7 @@ SCRIPTSDIR="$SCRIPTSDIR"
JOBSDIR="$JOBSDIR"
SORCDIR="$SORCDIR"
PARMDIR="$PARMDIR"
MODULES_DIR="${MODULES_DIR}"
EXECDIR="$EXECDIR"
FIXrrfs="$FIXrrfs"
FIXam="$FIXam"
Expand Down

0 comments on commit 8fed29a

Please sign in to comment.