From 9c82c4d4656d95746fcf1a4c926f74d7175f25d5 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 24 May 2017 14:28:24 -0400 Subject: [PATCH] * Update bash module support: with recent changes on Turing, 'module' seems to be supported out of the box for bash. If 'module' environment is detected, we skip the initiation step. --- turing/support/bash-module-env.sh | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/turing/support/bash-module-env.sh b/turing/support/bash-module-env.sh index b302de5..a0c0fbd 100755 --- a/turing/support/bash-module-env.sh +++ b/turing/support/bash-module-env.sh @@ -1,3 +1,4 @@ + # -*- bash -*- # # BASH support scriplet for environment modules. @@ -21,6 +22,7 @@ # Some cluster defaults (may change over time) # Reference: /etc/profile.d/modules.sh +# These are the *old* module environment, pre-2016 upgrade MODULESHOME_DEFAULT=/cm/local/apps/environment-modules/3.2.10/Modules/3.2.10 MODULEPATH_DEFAULT=/cm/local/modulefiles:/cm/shared/modulefiles:/cm/shared/compilers @@ -33,7 +35,25 @@ MODULEPATH_DEFAULT=/cm/local/modulefiles:/cm/shared/modulefiles:/cm/shared/compi RestoreModuleEnv () { local LOADEDMODULES_SAVE - : ${MODULESHOME:=$MODULESHOME_DEFAULT} + + # Update 20170314: now Turing has support for old-style module even in + # batch job. We will leverage that if we find that! + # For proper operation, both LOADEDMODULES and _LMFILES_ must be exported + # into the running environment. + if [ -n "${MODULESHOME}" \ + -a -n "${MODULEPATH}" \ + -a "$(type -t module)" = "function" ]; then + return 0 + fi + case "${MODULESHOME}" in + */lmod*) + # FORCE reloading OLD modules for now. + MODULESHOME=$MODULESHOME_DEFAULT + ;; + *) + : ${MODULESHOME:=$MODULESHOME_DEFAULT} + ;; + esac _AppendPaths MODULEPATH "$MODULEPATH_DEFAULT" export MODULESHOME export MODULEPATH @@ -56,7 +76,20 @@ RestoreModuleEnv () { InitModuleEnv () { # Only do the initialization part of the module so "module" command # is available for the script - : ${MODULESHOME:=$MODULESHOME_DEFAULT} + if [ -n "${MODULESHOME}" \ + -a -n "${MODULEPATH}" \ + -a "$(type -t module)" = "function" ]; then + return 0 + fi + case "${MODULESHOME}" in + */lmod*) + # FORCE reloading OLD modules for now. + MODULESHOME=$MODULESHOME_DEFAULT + ;; + *) + : ${MODULESHOME:=$MODULESHOME_DEFAULT} + ;; + esac _AppendPaths MODULEPATH "$MODULEPATH_DEFAULT" #: ${MODULEPATH:=$MODULEPATH_DEFAULT} export MODULESHOME