From ALICE Documentation
Any environment variables that you have set with the
sbatch command will be passed to your job. For this reason, if your program needs certain environment variables set to function properly, it is best to put them in your job script. This also makes it easier to reproduce your job results later, if necessary.
In addition to setting environment variables yourself, Slurm provides some environment variables of its own that you can use in your job scripts. Information on some of the common slurm environment variables is listed in the chart below. For additional information, see the man page for sbatch.
|$SLURM_JOB_ID||ID of job allocation|
|$SLURM_SUBMIT_DIR||Directory job where was submitted|
|$SLURM_JOB_NODELIST||File containing allocated hostnames|
|$SLURM_NTASKS||Total number of cores for job|
NOTE: Environment variables override any options set in a batch script. Command-line options override any previously set environment variables.