* 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.
This commit is contained in:
Wirawan Purwanto
2017-05-24 14:28:24 -04:00
parent 68c0e70d4d
commit 9c82c4d465

View File

@@ -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