A job array is a group of nearly identical jobs submitted with 1 SLURM script.


Sample Job Array Script:

  

#!/bin/sh
#SBATCH --partition=general-compute --qos=general-compute
#SBATCH --time=01:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=8
##SBATCH --mem=23000
#SBATCH --job-name="test-array"
#SBATCH --array=0-19
#SBATCH --output="slurm-%A_%a.out"
#SBATCH --mail-user=username@buffalo.edu
#SBATCH --mail-type=ALL
##SBATCH --requeue
#Specifies that the job will be requeued after a node failure.
#The default is that the job will not be requeued.

echo "SLURM_JOBID="$SLURM_JOBID
echo "SLURM_JOB_NODELIST"=$SLURM_JOB_NODELIST
echo "SLURM_NNODES"=$SLURM_NNODES
echo "SLURMTMPDIR="$SLURMTMPDIR
echo "SLURM_ARRAYID="$SLURM_ARRAYID
echo "SLURM_ARRAY_JOB_ID"=$SLURM_ARRAY_JOB_ID
echo "SLURM_ARRAY_TASK_ID"=$SLURM_ARRAY_TASK_ID
echo "working directory = "$SLURM_SUBMIT_DIR

NPROCS=`srun --nodes=${SLURM_NNODES} bash -c 'hostname' |wc -l`
echo "NPROCS="$NPROCS

module load matlab/R2013a
module list
ulimit -s unlimited

echo "run matlab computation"
matlab < test-${SLURM_ARRAY_TASK_ID}.m
echo "All Done!"

  

SLURM Job Array Info:


#SBATCH <array flag>
--array=<indexes>
--array=1-16

(this example submits 16 jobs)


#SBATCH --array=0-15%4
(this example submits 16 jobs, with a limit of 4 jobs running simultaneously)


Job Array Job Number:

%A - job array master job ID
 

Job Array Index Number:


%a - individual job index number



More information about SLURM job arrays can be found here