Skip to content

Instantly share code, notes, and snippets.

@bryan-lunt
Last active January 4, 2016 01:19
Show Gist options
  • Save bryan-lunt/8547702 to your computer and use it in GitHub Desktop.
Save bryan-lunt/8547702 to your computer and use it in GitHub Desktop.
A replacement for the "use.own" module that allows one to separate their private modules by cluster. The advantage of using this instead of just making a conditional "module use --append $CLUSTER_SPECIFIC_PATH" in your .profile is that you can turn this off and on with "module load privatemodules" and "module unload privatemodules" INSTALLATION:…
#%Module1.0#####################################################################
##
## privatemodules modulefile
##
## An alternative to use.own that lets you have a per-cluster private module directory,
## and automatically loads the appropriate one.
##
## Expects to be installed in ~/.privatemodules/base/privatemodules
##
proc ModulesHelp { } {
global rkoversion
puts stderr "\tThis module file will add \$HOME/.privatemodules/\$SDSC_CLUSTER"
puts stderr "\tand \$HOME/.privatemodules/common to the"
puts stderr "\tlist of directories that the module command will search"
puts stderr "\tfor modules. Place your own module files here."
puts stderr "\tThis module, when loaded, will create this directory"
puts stderr "\tif necessary."
puts stderr "\n\tVersion $rkoversion\n"
}
module-whatis "adds your own modulefiles directory to MODULEPATH"
# for Tcl script use only
set rkoversion 3.2.9
#setup a dictionary mapping from cutdown hostname to clustername
proc getClusterName { } {
dict set clustername "trestles" "trestles"
dict set clustername "gordon" "gordon"
dict set clustername "gcn" "gordon"
catch {exec "hostname"} hostname
regsub {(\-|\.).*} $hostname "" hostname
return [dict get $clustername $hostname]
}
eval set [ array get env HOME ]
set thecluster [ getClusterName ]
set ownmoddir $HOME/.privatemodules/$thecluster
module use --append $ownmoddir
module use --append $HOME/.privatemodules/common
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment