You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
# -*- bash -*-
|
|
#
|
|
#
|
|
|
|
# Some cluster defaults (may change over time)
|
|
# Reference: /etc/profile.d/modules.sh
|
|
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
|
|
|
|
# RestoreModuleEnv restores module environment at batch-job runtime to be
|
|
# exactly the same as the environment at the time of job submission.
|
|
# It requires the following variables to be set:
|
|
# - MODULESHOME (optional; default provided above)
|
|
# - MODULEPATH
|
|
# - LAODEDMODULES
|
|
|
|
RestoreModuleEnv () {
|
|
local LOADEDMODULES_SAVE
|
|
: ${MODULESHOME:=$MODULESHOME_DEFAULT}
|
|
: ${MODULEPATH:=$MODULEPATH_DEFAULT}
|
|
export MODULESHOME
|
|
export MODULEPATH
|
|
|
|
LOADEDMODULES_SAVE=$LOADEDMODULES
|
|
unset LOADEDMODULES
|
|
|
|
source "$MODULESHOME/init/bash"
|
|
|
|
if [ -n "$LOADEDMODULES_SAVE" ]; then
|
|
module load ${LOADEDMODULES_SAVE//:/" "}
|
|
fi
|
|
|
|
if [ -n "$Debug" -o -n "$DEBUG_MODULES" ]; then
|
|
echo "New loaded modules: $LOADEDMODULES"
|
|
module list
|
|
fi
|
|
}
|
|
|
|
InitModuleEnv () {
|
|
# Only do the initialization part of the module so "module" command
|
|
# is available for the script
|
|
local LOADEDMODULES_SAVE
|
|
: ${MODULESHOME:=$MODULESHOME_DEFAULT}
|
|
: ${MODULEPATH:=$MODULEPATH_DEFAULT}
|
|
export MODULESHOME
|
|
export MODULEPATH
|
|
|
|
source "$MODULESHOME/init/bash"
|
|
}
|
|
|
|
# For convenience:
|
|
if [ "$1" = restore ]; then
|
|
RestoreModuleEnv
|
|
elif [ "$1" = init ]; then
|
|
InitModuleEnv
|
|
fi
|
|
|
|
|