简体   繁体   中英

Values in a sbatch --array command different from the job task IDs, each of them run in a different job

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM