Secondary navigation

Multiple Job Submission

There are many times when users may need to execute their programs multiple times, particularly when random number generation is being used.

The following sample script can be found on the HPC system at /apps/samples/multi-submit/multi-submit.sh which can be copied your home directory (as well as the hello.exe program executable) for use.  Some general notes:

  • The variable $PBS_O_WORKDIR indicates the directory where the PBS script file is located and launched from.
  • The program executable hello.exe is a simple "Hello World" program and can be replaced with your own executable files.
  • The "email user" section within the PBS submission has been purposely removed - as you don't want to have 10 emails sent to you each time you run this script.
  • You can change the number of times you would like the program to execute by simple changing the "for ((i=1; i<=10; i+=1))" and replacing the 10 value with a value of your choice.
  • The "jobname" will be set to Multi-Job_[$1], where $1 is the jobnumber.  You may wish to change the jobname to something different, but note that PBS has a jobname limit of 10 characters.

The details for this script can be found below:

#!/bin/bash

for ((i=1; i<=10; i+=1))
do
    jobname=Multi-Job_$i
    cat << EOF | qsub

###### Select resources #####
#PBS -N $jobname
#PBS -l ncpus=1
#PBS -l mem=1g

##### Queue #####
#PBS -q workq

########## Output File ##########
#PBS -o \$PBS_O_WORKDIR/$jobname.txt

########## Error File ##########
#PBS -e \$PBS_O_WORKDIR/$jobname.err

##### Change to current working directory #####
cd \$PBS_O_WORKDIR

##### Execute Program #####
./hello.exe

EOF

done