#%Module1.0#####################################################################
# slurm/munge support module
# Put into /opt/modulefiles/slurm or some other part of $MODULEPATH
################################################################################

# SUBROUTINES
proc ModulesHelp { } {
	puts stderr "\tThis is Slurm $::version.\n"
	puts stderr "\tPlease consult http://slurm.schedmd.com/cray.html"
}

# CONFIGURATION
conflict	xt-pbs pbs torque
set slurmdir	"@prefix@"
set mungedir	"@MUNGE_DIR@"
set perldir	[exec perl -e "use Config; \$T=\$Config{installsitearch}; \$P=\$Config{installprefix}; \$P1=\"\$P/local\"; \$T =~ s/\$P1//; \$T =~ s/\$P//; print \$T;"]

set version "UNKNOWN"
if {![catch {exec $slurmdir/bin/sbatch --version} out]} {
	set version [lindex  $out 1]
}
set helptext	"Support for the Slurm Workload Manager $version"

# SCRIPT PROPER
module-whatis	$helptext

prepend-path	PATH		"$slurmdir/bin"
prepend-path	PATH		"$mungedir/bin"

prepend-path	MANPATH		"$slurmdir/share/man"
prepend-path	MANPATH		"$mungedir/share/man"

prepend-path    PKG_CONFIG_PATH "@libdir@/pkgconfig"

prepend-path	PERL5LIB	"$slurmdir/$perldir"

# other useful environment variables
setenv	SINFO_FORMAT	{%9P %5a %8s %.10l %.6c %.6z %.7D %10T %N}
setenv	SQUEUE_FORMAT	{%.6i %.8u %.7a %.14j %.3t %9r %19S %.10M %.10L %.5D %.4C}
setenv	SQUEUE_ALL	{yes}	;# show hidden partitions, too
setenv	SQUEUE_SORT	{-t,e,S}

# logfile aliases
set-alias sd_log	{tail -f "/ufs/slurm/var/log/slurmd.log"}
set-alias sc_log	{tail -f "/ufs/slurm/var/log/slurmctld.log"}

if {[exec id -u] == 0} {
	prepend-path	PATH	"$slurmdir/sbin"
	prepend-path	PATH	"$mungedir/sbin"
	set-alias	sdown	{scontrol shutdown}
}
