Search code examples
cluster-computinghpcslurm

Slurm: variable for max SLURM_ARRAY_TASK_ID


I have a simple slurm job file that looks like:

#!/bin/bash

#SBATCH --array=1-1000
#SBATCH -t 60:00
#SBATCH --mail-type=ALL
python cats.py ${SLURM_ARRAY_TASK_ID} 1000

That second argument is so my script know the total number of workers in this job.

I'd like to make that 1000 value into a variable though, so I don't need to hardcode the total number of workers. Is there some slurm variable for the maximum array task id in the current job?


Solution

  • You can use the environment variable SLURM_ARRAY_TASK_MAX