Skip to content

Commit

Permalink
Add capability for tasks to fall back to default modulefile (#204)
Browse files Browse the repository at this point in the history
This PR adds the capability for tasks to fall back to default modulefile if task-specific modulefile does not exist. In doing so, it gets rid of the old, hacky way I got post to build on Cheyenne, and replaces it with a build and run process that utilizes a new cheyenne.default modulefile.

This should allow us to condense down builds on new machines to use fewer task-specific modulefiles.
  • Loading branch information
mkavulich authored May 6, 2020
1 parent eb6dc3b commit ada6f35
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 29 deletions.
16 changes: 16 additions & 0 deletions modulefiles/cheyenne.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#%Module#####################################################
## Default module file for NCAR/UCAR Cheyenne, intel, mpt
#############################################################
module purge
module load ncarenv/1.3
module load intel/19.0.2
module load ncarcompilers/0.5.0
module load mpt/2.19
module load netcdf/4.6.3
# No hdf5 loaded since netcdf and hdf5 reside together on cheyenne

# Add directory to path that contains binaries needed for the regional workflow on Cheyenne
prepend-path PATH /glade/p/ral/jntp/UFS_CAM/bin

# Set NCEPLIBS_DIR, used by post
setenv NCEPLIBS_DIR /glade/p/ral/jntp/UPP/pre-compiled_libraries/NCEPlibs_intel_18.0.5
72 changes: 43 additions & 29 deletions ush/load_modules_run_task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ jjob_fp="$2"
machine=${MACHINE,,}
modules_dir="$HOMErrfs/modulefiles/tasks/$machine"
modulefile_name="${task_name}"

default_modules_dir="$HOMErrfs/modulefiles"
default_modulefile_name="${machine}.default"
use_default_modulefile=0
# Dom says that a correct modules.fv3 file is generated by the forecast
# model build regardless of whether building with or without CCPP.
# Thus, we can have a symlink named "run_fcst" that points to that file
Expand Down Expand Up @@ -229,26 +231,31 @@ modulefile_name="${task_name}"
#
#-----------------------------------------------------------------------
#

if [ "${task_name}" = "${RUN_POST_TN}" ] && [ "${machine}" = "cheyenne" ]; then
if [ "${machine}" = "unknown" ]; then
# This if statement allows for graceful exit in the case where module files are not needed.
# This is not currently used but reserved for future development.
print_info_msg "Modulefile not required for task \"${task_name}\" on machine \"${machine}\""

else

modulefile_path=$( readlink -f "${modules_dir}/${modulefile_name}" )

if [ ! -f "${modulefile_path}" ]; then
if [ -f "${default_modules_dir}/${default_modulefile_name}" ]; then
#If the task-specific modulefile does not exist but a default one does, use it!
print_info_msg "$VERBOSE" "
Task-specific modulefile (${modulefile_path}) does not exist
Will attempt to use default modulefile (${default_modules_dir}/${default_modulefile_name}) ..."
modules_dir=$default_modules_dir
use_default_modulefile=1

if [ "${task_name}" = "${MAKE_OROG_TN}" ] || \
elif [ "${task_name}" = "${MAKE_OROG_TN}" ] || \
[ "${task_name}" = "${MAKE_SFC_CLIMO_TN}" ] || \
[ "${task_name}" = "${MAKE_ICS_TN}" ] || \
[ "${task_name}" = "${MAKE_LBCS_TN}" ] || \
[ "${task_name}" = "${RUN_FCST_TN}" ]; then

print_err_msg_exit "\
The target (modulefile_path) of the symlink (modulefile_name) in the
task modules directory (modules_dir) that points to module file for this
task (task_name) does not exist:
The target modulefile does not exist for this task name:
task_name = \"${task_name}\"
modulefile_name = \"${modulefile_name}\"
modules_dir = \"${modules_dir}\"
Expand Down Expand Up @@ -277,43 +284,50 @@ does not exist:
#
print_info_msg "$VERBOSE" "
Loading modules for task \"${task_name}\" ..."

module purge

module use "${modules_dir}" || print_err_msg_exit "\
Call to \"module use\" 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 "\
if [ $use_default_modulefile -eq 0 ]; then
#
# 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 "\
;;
#
*)
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

fi #End if statement for tasks that load no modules
;;
#
esac
else # using default modulefile
module load ${default_modulefile_name} || print_err_msg_exit "\
Loading of default module file failed:
task_name = \"${task_name}\"
default_modulefile_name = \"${default_modulefile_name}\"
default_modules_dir = \"${default_modules_dir}\""
fi

module list
fi #End if statement for tasks that load no modules
#
#-----------------------------------------------------------------------
#
Expand Down

0 comments on commit ada6f35

Please sign in to comment.