Answering my own question so that it may serve as a reference:

This can be done by setting up a task prolog as shown below :
```
#!/bin/sh
#
# Sample TaskProlog script that will print a batch job's
# job ID and node list to the job's stdout.
# Also sets the modulepath based on nodelist
#

if [ X"$SLURM_STEP_ID" = "X" -a X"$SLURM_PROCID" = "X"0 ]
then
        echo "print =========================================="
        echo "print SLURM_JOB_ID = $SLURM_JOB_ID"
        echo "print SLURM_JOB_NODELIST = $SLURM_JOB_NODELIST"
        echo "print =========================================="
fi
short_list=${SLURM_JOB_NODELIST##worker}
if [ $short_list == "01" ]
then
        echo "export MODULEPATH=/home/path1"
fi
if [ $short_list == "02" ]
then
        echo "export MODULEPATH=/home/path2"
fi
```

Note:  This was tested on my laptop using a set of docker containers using
this configuration : https://github.com/SciDAS/slurm-in-docker .



-- 
Sajid Ali | PhD Candidate
Applied Physics
Northwestern University
s-sajid-ali.github.io

Reply via email to