Search code examples
slurm

SLURM array Add variable in #SBATCH options


I have a SLURM array

#SBATCH --array=0-1000%10

and I need to add a variable instead of "1000"

to be something like

#! /bin/bash
num=$1
#SBATCH --array=1-${num}%10

or if there is other way to setup the range. Thanks!


Solution

  • Slurm does not interpret variables in #SBATCH lines, and stops looking for #SBATCH lines as soon as a non-comment line is found so in your case the num=$1 line.

    One option is to pass that parameter as an argument of the sbatch command line

    sbatch --array=1-${num}%10 submit.sh
    

    For more details see here