diff --git a/roles/enable_modules/templates/lmod.csh.j2 b/roles/enable_modules/templates/lmod.csh.j2 new file mode 100755 index 0000000000000000000000000000000000000000..c4fa65640197c3125218bfeec8ff92a1eafe8dd3 --- /dev/null +++ b/roles/enable_modules/templates/lmod.csh.j2 @@ -0,0 +1,50 @@ +#!/bin/csh +# -*- shell-script -*- +######################################################################## +# This is the system wide source file for setting up +# modules: +# +######################################################################## + +set MY_NAME="{{ lmoddir }}/lmod/lmod/init/cshrc" + + + +if ( ! $?MODULEPATH_ROOT ) then + if ( $?USER) then + setenv USER $LOGNAME + endif + + set UNAME = `uname` + setenv LMOD_sys $UNAME + + setenv LMOD_arch `uname -m` + if ( "x$UNAME" == xAIX ) then + setenv LMOD_arch rs6k + endif + + setenv TARG_TITLE_BAR_PAREN " " + setenv LMOD_FULL_SETTARG_SUPPORT no + setenv LMOD_SETTARG_CMD : + setenv LMOD_COLORIZE yes + setenv LMOD_PREPEND_BLOCK normal + setenv MODULEPATH_ROOT "{{ lmoddir }}/modulefiles" + setenv MODULEPATH `{{ lmoddir }}/lmod/lmod/libexec/addto --append MODULEPATH $MODULEPATH_ROOT/$LMOD_sys $MODULEPATH_ROOT/Core` + setenv MODULEPATH `{{ lmoddir }}/lmod/lmod/libexec/addto --append MODULEPATH {{ lmoddir }}/lmod/lmod/modulefiles/Core` + setenv MODULEPATH "/usr/local/Modules/modulefiles" + setenv MODULESHOME "{{ lmoddir }}/lmod/lmod" + setenv BASH_ENV "$MODULESHOME/init/bash" + + # + # If MANPATH is empty, Lmod is adding a trailing ":" so that + # the system MANPATH will be found + if ( ! $?MANPATH ) then + setenv MANPATH : + endif + setenv MANPATH `{{ lmoddir }}/lmod/lmod/libexec/addto MANPATH {{ lmoddir }}/lmod/lmod/share/man` + +endif + +if ( -f {{ lmoddir }}/lmod/lmod/init/csh ) then + source {{ lmoddir }}/lmod/lmod/init/csh +endif diff --git a/roles/enable_modules/templates/lmod.sh.j2 b/roles/enable_modules/templates/lmod.sh.j2 new file mode 100755 index 0000000000000000000000000000000000000000..fbfd5d22d90d91795acb582d18629b6f9b883448 --- /dev/null +++ b/roles/enable_modules/templates/lmod.sh.j2 @@ -0,0 +1,131 @@ +#!/bin/bash +# -*- shell-script -*- + + +LMOD_PKG={{ lmoddir}}/lmod/lmod +LMOD_DIR={{ lmoddir }}/lmod/lmod/libexec +LMOD_CMD={{ lmoddir }}/lmod/lmod/libexec/lmod +MODULESHOME={{ lmoddir }}/lmod/lmod +MODULEPATH=/usr/local/Modules/modulefiles +export LMOD_PKG +export LMOD_CMD +export LMOD_DIR +export MODULESHOME + +######################################################################## +# Define the module command: The first line runs the "lmod" command +# to generate text: +# export PATH="..." +# then the "eval" converts the text into changes in the current shell. +# +# The second command is the settarg command. Normally LMOD_SETTARG_CMD +# is undefined or is ":". Either way the eval does nothing. When the +# settarg module is loaded, it defines LMOD_SETTARG_CMD. The settarg +# command knows how to read the ModuleTable that Lmod maintains and +# generates a series of env. vars that describe the current state of +# loaded modules. So if one is on a x86_64 linux computer with gcc/4.7.2 +# and openmpi/1.6.3 loaded, then settarg will assign: +# +# TARG=_x86_64_gcc-4.7.2_openmpi-1.6.3 +# TARG_COMPILER=gcc-4.7.2 +# TARG_COMPILER_FAMILY=gcc +# TARG_MACH=x86_64 +# TARG_MPI=openmpi-1.6.3 +# TARG_MPI_FAMILY=openmpi +# TARG_SUMMARY=x86_64_gcc-4.7.2_openmpi-1.6.3 +# TARG_TITLE_BAR=gcc-4.7.2 O-1.6.3 +# TARG_TITLE_BAR_PAREN=(gcc-4.7.2 O-1.6.3) +# +# unloading openmpi/1.6.3 automatically changes these vars to be: +# +# TARG=_x86_64_gcc-4.6.3 +# TARG_COMPILER=gcc-4.6.3 +# TARG_COMPILER_FAMILY=gcc +# TARG_MACH=x86_64 +# TARG_SUMMARY=x86_64_gcc-4.6.3 +# TARG_TITLE_BAR=gcc-4.6.3 +# TARG_TITLE_BAR_PAREN=(gcc-4.6.3) +# +# See Lmod web site for more details. + +module() +{ + eval $($LMOD_CMD bash "$@") + [ $? = 0 ] && eval $(${LMOD_SETTARG_CMD:-:} -s sh) +} + + +if [ "${LMOD_SETTARG_CMD:-:}" != ":" ]; then + settarg () { + eval $(${LMOD_SETTARG_CMD:-:} -s sh "$@" ) + } +fi + + +######################################################################## +# ml is a shorthand tool for people who can't type moduel, err, module +# It is also a combination command: +# ml -> module list +# ml gcc -> module load gcc +# ml -gcc intel -> module unload gcc; module load intel +# It does much more do: "ml --help" for more information. + + +unalias ml > /dev/null 2>&1 +ml() +{ + eval $($LMOD_DIR/ml_cmd "$@") +} + +export_module=$(echo "YES" | tr '[:upper:]' '[:lower:]') +if [ -n "$BASH_VERSION" -a "$export_module" != no ]; then + export -f module + export -f ml +fi +unset export_module + +######################################################################## +# clearMT removes the ModuleTable from your environment. It is rarely +# needed but it useful sometimes. + +clearMT() +{ + eval $($LMOD_DIR/clearMT_cmd bash) +} + +######################################################################## +# The following make the action of the settarg available to the titlebar +# for both xterm's and screen but only for interactive shells. +if [ "$PS1" ]; then + if [ -n "$LMOD_FULL_SETTARG_SUPPORT" -a "$LMOD_FULL_SETTARG_SUPPORT" != no ]; then + xSetTitleLmod() + { + builtin echo -n -e "\033]2;$1\007"; + } + SET_TITLE_BAR=: + + case $TERM in + xterm*) + SET_TITLE_BAR=xSetTitleLmod + ;; + esac + + SHOST=${SHOST-${HOSTNAME%%.*}} + precmd() + { + eval $(${LMOD_SETTARG_CMD:-:} -s bash) + ${SET_TITLE_BAR:-:} "${TARG_TITLE_BAR_PAREN}${USER}@${SHOST}:${PWD/#$HOME/~}" + ${USER_PROMPT_CMD:-:} + } + + # define the PROMPT_COMMAND to be precmd iff it isn't defined already. + : ${PROMPT_COMMAND:=precmd} + fi +fi + +######################################################################## +# Make tab completions available to bash users. + +if [ ${BASH_VERSINFO:-0} -ge 3 ] && [ -r {{ lmoddir }}/lmod/lmod/init/lmod_bash_completions ] && [ -n "$PS1" ]; then + . {{ lmoddir }}/lmod/lmod/init/lmod_bash_completions +fi diff --git a/roles/enable_modules/templates/modulecmd.csh.j2 b/roles/enable_modules/templates/modulecmd.csh.j2 new file mode 100644 index 0000000000000000000000000000000000000000..3bc4c38935e9b59e738c24a5cb3f3197a40b5131 --- /dev/null +++ b/roles/enable_modules/templates/modulecmd.csh.j2 @@ -0,0 +1,45 @@ +if ($?tcsh) then + set modules_shell="tcsh" +else + set modules_shell="csh" +endif +set exec_prefix='/usr/bin' + +set prefix="" +set postfix="" + +if ( $?histchars ) then + set histchar = `echo $histchars | cut -c1` + set _histchars = $histchars + + set prefix = 'unset histchars;' + set postfix = 'set histchars = $_histchars;' +else + set histchar = \! +endif + +if ($?prompt) then + set prefix = "$prefix"'set _prompt="$prompt";set prompt="";' + set postfix = "$postfix"'set prompt="$_prompt";unset _prompt;' +endif + +if ($?noglob) then + set prefix = "$prefix""set noglob;" + set postfix = "$postfix""unset noglob;" +endif +set postfix = "set _exit="'$status'"; $postfix; /usr/bin/test 0 = "'$_exit;' + +alias module $prefix'eval `'$exec_prefix'/modulecmd '$modules_shell' '$histchar'*`; '$postfix +unset exec_prefix +unset prefix +unset postfix + +setenv MODULESHOME /usr/share/Modules + +if (! $?MODULEPATH ) then + setenv MODULEPATH `sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`:/usr/local/Modules/modulefiles +endif + +if (! $?LOADEDMODULES ) then + setenv LOADEDMODULES "" +endif diff --git a/roles/enable_modules/templates/modulecmd.sh.j2 b/roles/enable_modules/templates/modulecmd.sh.j2 new file mode 100644 index 0000000000000000000000000000000000000000..30adea3527df89867728e18ee83b628866175d83 --- /dev/null +++ b/roles/enable_modules/templates/modulecmd.sh.j2 @@ -0,0 +1,20 @@ + +module() { eval `/usr/bin/modulecmd bash $*`; /usr/local/hpcusr/latest/bin/modulelog $*;} +export -f module + +MODULESHOME=/usr/share/Modules +export MODULESHOME + +if [ "${LOADEDMODULES:-}" = "" ]; then + LOADEDMODULES= + export LOADEDMODULES +fi + +if [ "${MODULEPATH:-}" = "" ]; then + MODULEPATH=`sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`:/usr/local/Modules/modulefiles + export MODULEPATH +fi + +if [ ${BASH_VERSINFO:-0} -ge 3 ] && [ -r ${MODULESHOME}/init/bash_completion ]; then + . ${MODULESHOME}/init/bash_completion +fi