<div dir="ltr"><div dir="ltr">Answering my own question so that it may serve as a reference: <br></div><div><br>This can be done by setting up a task prolog as shown below : <br>```<br>#!/bin/sh<br>#<br># Sample TaskProlog script that will print a batch job's<br># job ID and node list to the job's stdout. <br># Also sets the modulepath based on nodelist<br>#<br><br>if [ X"$SLURM_STEP_ID" = "X" -a X"$SLURM_PROCID" = "X"0 ]<br>then<br>        echo "print =========================================="<br>        echo "print SLURM_JOB_ID = $SLURM_JOB_ID"<br>        echo "print SLURM_JOB_NODELIST = $SLURM_JOB_NODELIST"<br>        echo "print =========================================="<br>fi<br>short_list=${SLURM_JOB_NODELIST##worker}<br>if [ $short_list == "01" ]<br>then<br>        echo "export MODULEPATH=/home/path1"<br>fi<br>if [ $short_list == "02" ]<br>then<br>        echo "export MODULEPATH=/home/path2"<br>fi<br>```<br><br></div><div>Note:  This was tested on my laptop using a set of docker containers using this configuration : <a href="https://github.com/SciDAS/slurm-in-docker">https://github.com/SciDAS/slurm-in-docker</a> .<br><br><br></div><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:12.8px">Sajid Ali | PhD Candidate<br></div><div style="font-size:12.8px">Applied Physics<br></div><div style="font-size:12.8px">Northwestern University</div><div style="font-size:12.8px"><a href="http://s-sajid-ali.github.io" target="_blank">s-sajid-ali.github.io</a></div></div></div></div></div></div></div></div>