MPI Programs must be run from a program that acts as a launcher, mpirun. In order to run an MPI program from within PBS, there are a couple of points to remember:
Be sure to tell PBS how many processors your MPI job needs:
#PBS -l nodes=4
Now, run your executable on the nodes that PBS has assigned to your job. Make sure that the number of nodes you asked PBS for (-l nodes=4) matches the number that you tell mpirun to use!
You must use mpirun's -machinefile option to tell it what nodes to run on. The environment variable $PBS_NODEFILE contains the list of nodes PBS has assigned to the job, and will ensure that your mpirun program runs on the nodes that PBS has allocated for it.
mpirun -np 4 -machinefile $PBS_NODEFILE mpi-program