I have a script that splits a data structure into chunks. The chunks are processed using a torque job array and then merged back into a single structure.
The merge operation is dependent on the job array completing. How do I make the merge operation wait for the torque job array to complete?
$ qsub --version
Version: 4.1.6
My script is as follows:
# Splits the data structure and processes the chunks
qsub -t 1-100 -l nodes=1:ppn=40,walltime=48:00:00,vmem=120G ./job.sh
# Merges the processed chunks back into a single structure
./merge.sh
I have tried:
qsub -t 1-100 -l nodes=1:ppn=40,walltime=48:00:00,vmem=120G -N job1 ./job.sh
qsub -W depend=afterokarray:job1 ./merge.sh
and also:
qsub -t 1-100 -l nodes=1:ppn=40,walltime=48:00:00,vmem=120G -N job1 ./job.sh
qsub -hold_jid job1 ./merge.sh
Neither worked. The former resulted in error [qsub: illegal -W value], and the latter also resulted in error: qsub: script file 'job1' cannot be loaded - No such file or directory.
The output of
qsub -t 1-100 -l nodes=1:ppn=40,walltime=48:00:00,vmem=120G -N job1 ./job.sh
contains the jobid.
So following should work in bash:
FIRST=`qsub first_1.sh`
qsub -W depend=afterok:$FIRST second_1.sh
The answer
You should user afterokarray:
ID=$(qsub -t 1-100 -l nodes=1:ppn=40,walltime=48:00:00,vmem=120G -N job1 ./job.sh)
qsub -W depend=afterokarray:$(ID) ./merge.sh
Another example
This is another example, let say you need to execute a job two times and after those, execute another one:
#!/bin/bash
#PBS -q batch
#PBS -l walltime=24:00:00
#PBS -o /app/run/KLFLO/nueva_tarea_0.$PBS_ARRAYID.out
#PBS -e /app/run/KLFLO/nueva_tarea_0.$PBS_ARRAYID.err
#PBS -N KLFLO_nueva_tarea_0
#PBS -t 1-2 # times
sleep 20
/bin/cat /etc/hosts
Execute qsub < nueva_tarea_2.bash
an them use (10[].docker) in the other submitssion file
#!/bin/bash
#PBS -q batch
#PBS -l walltime=24:00:00
#PBS -o /app/run/KLFLO/nueva_tarea_2.$PBS_ARRAYID.out
#PBS -e /app/run/KLFLO/nueva_tarea_2.$PBS_ARRAYID.err
#PBS -N KLFLO_nueva_tarea_2
#PBS -t 1-2 # times
#PBS -W depend=afterokarray:10[].docker
/bin/cat /etc/hosts