Passing Variables
How to pass environment variables to SLURM jobs
The BMRC cluster uses software libraries optimised for the each hardware generation in use, with a shell module loading the correct library for the hardware the job runs on. This means that fsl_sub cannot pass your current shell environment variables to the job (as it would on Jalapeno).
You can request that a sub-set of the environment variables in your session are passed to your job with the --export option (pass this multiple times to export multiple variables). You can also use this option to set an environment variable in your job that is not already set in your session.
fsl_sub will automatically load any currently loaded shell modules in your job's shell, so if possible use shell modules to configure software rather than setting environment variables. For very complicated use cases or dynamic variable setting, create a script that sets up all your variables and then calls the software and submit this script to the cluster.
There are two ways to use --export:
- --export VARIABLENAME {--export VARIABLENAME} This will copy the current environment variable setting into your job (specify multiple times for multiple variables)
- --export VARIABLENAME=VARIABLEVALUE This will set the environment variable to the value after the '=' in the queued job only (not effecting your shell) so is ideal where you need to specify a job specific value
fsl_sub will automatically transfer some internal variables and may have been configured to include some additional useful ones, see the 'exports:' option in the output of
fsl_sub --show_config
for the list of default exports. Any --export passed on the commandline will override these configured options. It is also possible to configure fsl_sub for your account to always copy over particular variables, see Configuring fsl_sub.
Option 2, where you provide the variable with a value is particularly useful if you are scheduling many similar tasks and need to specify a different value for an environment variable for each run, for example SUBJECTS_DIR which FreeSurfer uses to specify where your data sets reside.