Skip to content

Commit 71b985c

Browse files
committed
a few comments for serial batch jobs
1 parent 4b65060 commit 71b985c

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#PBS -j oe
3+
#PBS -l nodes=4:ppn=2
4+
#PBS -l walltime=1:00:00
5+
6+
cd $PBS_O_WORKDIR
7+
8+
# Run 20 serial jobs, 8 at a time (using 8 processors)
9+
10+
# define the total number of jobs here
11+
num_serial_jobs=20
12+
num_procs=$(cat $PBS_NODEFILE | wc -l)
13+
count=0
14+
15+
while [ $count -lt $num_serial_jobs ]
16+
do
17+
rank_base=$count
18+
count=`expr $count + $num_procs`
19+
remain=`expr $num_serial_jobs - $count`
20+
if [ $remain -lt 0 ]; then
21+
run_count=`expr $num_serial_jobs % $num_procs`
22+
else
23+
run_count=$num_procs
24+
fi
25+
mpirun -np $run_count ./wrapper.sh $rank_base
26+
done

pbs-serial-batch/one-job-per-proc.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
#PBS -j oe
3+
#PBS -l nodes=2:ppn=4
4+
#PBS -l walltime=1:00:00
5+
6+
cd $PBS_O_WORKDIR
7+
num_procs=$(cat $PBS_NODEFILE | wc -l)
8+
9+
# run the mpi process with total number of 8 processes ( 2 x 8 )
10+
# 'wrapper.sh' is the wrapper script for instructing mpi how to
11+
# execute the program in batch
12+
# '0' is the command line input that can be arbitrarily defined
13+
mpirun -np $num_procs wrapper.sh 0

pbs-serial-batch/wrapper.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# this the shell script for wrapping your program
3+
4+
# 'rank' is taken from the MPI environment variable
5+
# for the 'multi-jobs' case, it also needs the command line argument $1
6+
rank=`expr ${OMPI_COMM_WORLD_RANK} + $1`
7+
8+
# define your commands here
9+
echo "hello, this is processor ${rank}!" > output_${rank}.out

0 commit comments

Comments
 (0)