In order to use certain software packages on the Shared Compute Clusters, it is often necessary to set one or more environment variables. This is accomplished automatically with the module command associated with the software package. However, it might also be necessary for these environment variables to be visible from within a SLURM batch script, yet the module command will not work with a SLURM batch script on a compute node. The following document describes the preferred way of setting environment variables inside a SLURM batch script.
Inheriting Environment Variables
The preferred way of setting environment variables in a SLURM batch script is to simply have the script inherit the environment of the parent shell from the login node. For example, you might execute the following command on login node:
This will set the necessary environment variables to use the mpich package.
In order for these variables to be inherited in the SLURM batch script that will execute on a compute node, include the #SBATCH --export=ALL option in the batch script as follows: