#%Module1.0#####################################################################
# slurm 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 https://slurm.schedmd.com/cray.html"
}

# CONFIGURATION
conflict	xt-pbs pbs torque
set slurmdir	"@prefix@"
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	MANPATH		"$slurmdir/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	{%.8i %.8u %.7a %.14j %.3t %9r %19S %.10M %.10L %.5D %.4C}
setenv	SQUEUE_ALL	{yes}	;# show hidden partitions, too
setenv	SQUEUE_SORT	{-t,e,S}

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