User Manual

1 Getting Started

2 Managing Files

3 Software

4 Running Jobs
4.1 Interactive jobs
4.2 Batch jobs
4.3 Managing jobs
4.4 Partitions
4.5 Job priority
4.6 Condo priority
4.7 Job arrays

5 XSEDE

6 GPU Computing

4.7 Job arrays

A job array is a collection of jobs that all run the same program, but on different values of a parameter. It is very useful for running parameter sweeps, since you don't have to write a separate batch script for each parameter setting.

To use a job array, add the option:

#SARRAY --range=<range-spec>

below the #SBATCH options in your batch script. The range spec can be a comma separated list of integers, along with ranges separated by a dash. For example:

1-20
1-10,12,14,16-20

The values in the range will be substituted for the variable $SLURM_ARRAYID in the remainder of the script. Here is an example of a script for running a serial Matlab script on 16 different parameters:

#!/bin/bash
#SBATCH -J MATLAB
#SBATCH -t 1:00:00
#SARRAY --range=1-16

echo "Starting job $SLURM_ARRAYID on $HOSTNAME"
matlab -r "MyMatlabFunction($SLURM_ARRAYID); quit;"

After you have modified your batch script to use job arrays, you must submit it using the sarray command instead of sbatch:

$ sarray <jobscript>

This will return a list of job IDs, with one job ID per parameter value. The parameter value will also be appended to the job name (-J value).