pUTa432
pUTa432

Reputation: 57

For loop inside slurm script to use a different input for the job to be executed serially

I need to run some 15 instances of an executable at the same location such that it uses the same input files, except one. This one input I need to update with a for loop. Something along the lines of:

#SBATCH -N 1
#SBATCH --ntasks-per-node=256
#SBATCH -p amd
export OMP_NUM_THREADS=2
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/lib64/psm2-compat/

declare -a value_of_parameter=("a" "b" "c")
for i in "${value_of_parameter}"
do
        str="some_random_string $i"
        sed -i "41s/.*/$str/" inputfile
        mpirun -np 128 /path/to/executable | tee -a out
done
exit

I need to modify only one parameter in inputfile but executable uses other files that stay unchanged during the loop, hence the serial execution requirement. I cannot get slurm to stop exiting after the job finished with the first instance of value_of_parameter="a" .

Is job array mandatory? I can extract my required output from the appended out file. Switching to wait in place of exit at the end didn't help either. Any help would be appreciated!

Upvotes: 0

Views: 23

Answers (0)

Related Questions