[Beowulf] Gridengine and bash + Modules

Brian Smith brs at usf.edu
Sat Jan 16 13:14:57 PST 2010


I'm using this in our environment.  I've simply added the Modules
environment code to /etc/bashrc and /etc/csh.cshrc on all nodes (I use
puppet to manage everything, so this is easy).  This ensures that
Modules is properly integrated with your environment regardless of
whether you are using an interactive or non-interactive invocation of
these shells.  This works for SGE (I'm on 6.2u4, ATM)

Users can then do the following:

1. Include 'module add' directives in their job scripts for application
execution (preferred method)
2. Use persistent module add directives w/ 'module initadd' to ensure
their jobs have the correct environment settings (good for interactive
jobs via qrsh, but this is better solved in other ways).

Here's what I added:

## for bash
if [ -d "/opt/admin/Modules" ]; then
	MODULE_VERSION=3.2.6
	MODULE_ROOT=/opt/admin/Modules/$MODULE_VERSION

	case "$0" in
	          -sh|sh|*/sh)  modules_shell=sh ;;
	       -ksh|ksh|*/ksh)  modules_shell=ksh ;;
	       -zsh|zsh|*/zsh)  modules_shell=zsh ;;
	    -bash|bash|*/bash)  modules_shell=bash ;;
		*)		modules_shell=bash ;;
	esac

	MODULEPATH=$MODULE_ROOT/modulefiles:$HOME/.modulefiles

	export WORK SCRATCH MODULEPATH MODULE_ROOT MODULE_VERSION

	module() { eval `$MODULE_ROOT/bin/modulecmd $modules_shell $*`; }

	if [ -f $HOME/.modules ]; then
		eval `egrep '^module(.*load|.*add).*$' $HOME/.modules | head -1`
	fi
fi

## For cshell
if ( -d /opt/admin/Modules ) then
setenv MODULESHOME /opt/admin/Modules/${MODULE_VERSION}

if (! $?MODULEPATH ) then
  setenv MODULEPATH `sed 's/#.*$//' ${MODULESHOME}/init/.modulespath |
awk 'NF==1{printf("%s:",$1)}'`
endif

if (! $?LOADEDMODULES ) then
  setenv LOADEDMODULES ""
endif

if ( -f $HOME/.modules ) then
  eval `egrep '^module(.*add|.*load).*$' $HOME/.modules | head -1`
endif
endif

-- 
Brian Smith
Senior Systems Administrator
IT Research Computing, University of South Florida
4202 E. Fowler Ave. ENB308
Office Phone: +1 813 974-1467
Organization URL: http://rc.usf.edu


On Sat, 2010-01-16 at 10:44 +0000, madskaddie at gmail.com wrote:
> Greetings,
> 
> I'm using gridengine (6.2u4, open source ver.) and I would like to use
> the Modules software. Modules uses a shell function that must be
> exported (bash: "export -f func_name" in order to set environment
> variables), but gridengine has a bug related with bash exported
> functions[1].
> 
> Is anybody using gridengine, bash and modules? How to solve this?
> Changing shell is not  an option ;)
> 
> This issue is also being discussed here[2].
> 
> Thanks,
> 
> Gil
> 
> [1] - http://gridengine.sunsource.net/issues/show_bug.cgi?id=2173
> [2] - http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&viewType=browseAll&dsMessageId=238562#messagefocus
> 




More information about the Beowulf mailing list