When using the Strelka Computer Cluster you may want to run many instances of the same job, possibly with different inputs.  Use the Slurm job array command.

Example array submission script

In this case, an array of 10 jobs with ids from 1 to 10 are created.  All jobs share them same Slurm job id ($SLURM_JOB_ID), but have task ids that match their array value ($SLURM_ARRAY_TASK_ID).  The variable a is assigned to the value of the array task id before being passed into the MATLAB script.  The output files are set up to use both the job id and array task id in the filename to avoid being overwritten by other jobs/tasks.  

The --array line configures the number and value of the tasks.  There are many ways to configure this command - see the Slurm job array command reference for more information.

#! /bin/bash
#SBATCH --time=1:00:00
#SBATCH --array=1-10
##SBATCH --nodes=1
#SBATCH --partition=compute 
#SBATCH --account=aruethe2
#SBATCH --output=./output/output_%A_%a.log
 
cd $HOME/matlab_test
module load matlab
matlab -batch "a=$SLURM_ARRAY_TASK_ID;run('./matlab_test.m');exit" >> ./output/testcode.out_$SLURM_JOB_ID.$SLURM_ARRAY_TASK_ID


  • No labels