Alex Chitsazan
Alex Chitsazan

Reputation: 88

How to loop through a script with SLURM? (sbatch and srun)

New to slurm, I have a script that was written to run the same command many times that has multiple inputs and outputs. If i have another shell script, is there a way that I can loop through that in multiple srun commands. My thought you would be something along the lines of:

shell script:

#!/bin/bash
ExCommand -f input1a -b input2a -c input3a -o outputa
ExCommand -f input1b -b input2b -c input3b -o outputb
ExCommand -f input1c -b input2c -c input3c -o outputc
ExCommand -f input1d -b input2d -c input3d -o outputd
ExCommand -f input1e -b input2e -c input3e -o outpute

sbatch script

#!/bin/bash
## Job Name
#SBATCH --job-name=collectAlignmentMetrics
## Allocation Definition
## Resources
## Nodes
#SBATCH --nodes=1
## Time limir
#SBATCH --time=4:00:00
## Memory per node
#SBATCH --mem=64G
## Specify the working directory for this job

for line in shellscript
do
    srun command
done

Any ideas?

Upvotes: 2

Views: 4696

Answers (1)

damienfrancois
damienfrancois

Reputation: 59300

Try replace your for loop with this:

while read -r line; 
do 
    if [[ $line == \#* ]]; continue ; fi
    srun $line
done < shellscript

Upvotes: 1

Related Questions