I am using slurm scripts to run arrays for Matlab computing on a cluster. Each script uses an array to loop over a matlab parameter.
1) Is it possible to create a shell script to loop over another variable?
2) Can I pass variables to a slurm script?
For example, my slurm files currently look like
#!/bin/bash
#SBATCH --array=1-128
...
matlab -nodesktop r "frame=[${SLURM_ARRAY_TASK_ID}]; filename=['Person24']; myfunction(frame, filename);";
I frequently need to run this array to process a number of different files. This means I will submit the job (sbatch exampleScript.slurm), edit the file, update 'Person24' to 'Person25', and then resubmit the job. This is pretty inefficient when I have a large number of files to process.
Could I make a shell script that would pass a variable to the slurm script? For example, something like this:
Shell Script (myshell.sh)
#!/bin/bash
for ((FNUM=24; FNUM<=30; FNUM+=1));
do
sbatch myscript.slurm >> SOMEHOW PASS ${FNUM} HERE (?)
done
Slurm script (myscript.slurm)
#!/bin/bash
#SBATCH --array=1-128
...
matlab -nodesktop -nodisplay r "frame=[${SLURM_ARRAY_TASK_ID}]; filename=[${FNUM}]; myfunction(frame, filename);";
where I could efficiently submit all of the jobs using something like sbatch myshell.sh
Thank you!