$ cp -r /share/apps/samples/openmpi-c++ ./
// Filename: mpi_hello.cpp
// Description: A parallel hello world program
#include <iostream>
#include <mpi.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
MPI::Init(argc, argv);
int rank = MPI::COMM_WORLD.Get_rank();
int size = MPI::COMM_WORLD.Get_size();
std::cout<<"Returned: "<<system("sleep 2")<<" ";
std::cout << "Hello World! I am " << rank << " of " << size <<
std::endl;
MPI::Finalize();
return(0);
}
$ module load openmpi-intel
(Loads the openmpi/intel-12 module)
$ module load openmpi/intel-11
$ module load openmpi/intel-12
$ module load openmpi-gnu
$ module load openmpi/gcc45
$ module load openmpi/gcc46
$ module load openmpi/gcc47
$ mpiCC -o openmpi-hello mpi_hello.cpp
#PBS -N openmpi-hello
#PBS -q @nic-cluster.mst.edu
#PBS -l nodes=2
#PBS -l walltime=01:00:00
#PBS -m abe
#PBS -M joeminer@mst.edu
#PBS -V
cd $PBS_O_WORKDIR
mpirun -np 2 ./openmpi-hello
$ qsub jobfile.job
Returned: 0 Hello World! I am 1 of 2
Returned: 0 Hello World! I am 0 of 2