I am running a job array with SLURM, with the following job array script (that I run with sbatch job_array_script.sh [args]:
#!/bin/bash
#SBATC
You can use --wait option in sbatch in combination with wait in bash to send jobs off to the cluster, pause script execution until those are complete, and then continue. E.g.
#!/bin/bash
set -e
date
for((i=0; i<5; i++)); do
sbatch -W --wrap='echo "hello from $SLURM_ARRAY_TASK_ID eat $VAR"; sleep 10' &
done;
wait
date
echo "I am finished"