1

Is it possible to feed a script some values in the sbatch --array command line different from the job task IDs, and each of them be run in a different job?

sbatch --array=1-2 script.sh 4 6

with script.sh being

#!/bin/bash

VALUE=$"$SLURM_ARRAY_TASK_ID"

echo $VALUE

then, after they have run,

cat slurm*

returns

1
2

But I wonder whether it is possible to make the 2 jobs return instead the "4 6" values fed in the sbatch --array command, one apiece:

4
6
Miguel
  • 356
  • 1
  • 15

1 Answers1

2

You can use indirect variable expansion:

#!/bin/bash

VALUE=${!SLURM_ARRAY_TASK_ID}

echo $VALUE

Note the exclamation mark. After

sbatch --array=1-2 script.sh 4 6

you should have two output files, one with 4 and one with 6.

damienfrancois
  • 52,978
  • 9
  • 96
  • 110