#!/bin/bash # Companion code for Chapter 15: Parallel Computing. # PBS Professional / OpenPBS submission example for ch15_mpi_heat_strips. # This requests one allocation chunk with four CPUs and four MPI processes. # PBS/Torque installations may use different resource syntax. # # Before submitting, compile with an MPI compiler compatible with the # cluster's MPI installation, for example: # mpic++ -std=c++11 -O3 ch15_mpi_heat_strips.cpp -o ch15_mpi_heat_strips # Then run: qsub ch15_mpi_heat_pbs.pbs # # Some sites require a queue/project selection (#PBS -q ... / #PBS -A ...). # Consult your HPC center's policy; do not guess queue or account names. # #PBS -N ch15_mpi_heat #PBS -l select=1:ncpus=4:mpiprocs=4 #PBS -l walltime=00:10:00 #PBS -j oe set -eu cd "${PBS_O_WORKDIR:?Submit this file with qsub}" # Add site-specific module loading if required, e.g. compiler and MPI. # The job runs four MPI processes; it is not an OpenMP threaded job. if [ ! -x ./ch15_mpi_heat_strips ]; then echo 'Missing executable: ./ch15_mpi_heat_strips' >&2 echo 'Compile the C++ MPI program first, in the submission directory.' >&2 exit 1 fi echo "PBS job ${PBS_JOBID:-unknown}; requested MPI processes: 4" # With PBS-aware Open MPI, mpirun uses the PBS allocation automatically. # Your center may prescribe a launcher or flags; follow its documentation. mpirun ./ch15_mpi_heat_strips