I am working with the following .sh script which I submit using sbatch. Pairwise_3_P_a.do and Pairwise_3_P_c.do are linear steps that should be run only once, but Pairwise_3_P_b.do uses an array. I am having problems with Pairwise_3_P_c.do being run before the array is done.
Is there a way to fix this script using --wait or the wait bash command? Do I need to use srun, as in this answer: How to hold up a script until a slurm job (start with srun) is completely finished? ? I do not fully understand how to implement wait and --wait as mentioned there and in the documentation.
#!/bin/bash
#SBATCH --array=1-248
module load stata
stata-mp Pairwise_3_P_a.do
stata-mp Pairwise_3_P_b.do $SLURM_ARRAY_TASK_ID
stata-mp Pairwise_3_P_c.do
So far I have been trying to split the parallel step off into a separate .sh script, but this is annoying to run.
Thanks.