I am trying to install an OpenMPI on my Ubuntu (14.04) machine, and I thought that I had succeeded, because I can run codes with mpirun
, but recently I have noticed that it's not truly running in parallel.
I installed openmpi
with the following options:
./configure CXX=g++ CC=gcc F77=gfortran \
F90=gfortran \
FC=gfortran \
--enable-mpi-f77 \
--enable-mpi-f90 \
--prefix=/opt/openmpi-1.6.5
make all
sudo make install
As I said, I have run a code ( not written by myself ) and it seemed to work in parallel, because I checked with top
and it was running in several nodes.
But now I have written a simple FORTRAN code:
PROGRAM hello_MPI
INCLUDE "mpif.h"
INTEGER :: err, size, rank
CALL MPI_INIT(err)
IF (err /= MPI_SUCCESS) STOP 'Init failed'
CALL MPI_COMM_RANK(MPI_COMM_WORLD, rank, err)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, size, err)
PRINT*, "Hello world from process ", rank, " of ", size, " processes"
CALL MPI_FINALIZE(err)
END PROGRAM
But when I run it with
mpirun -n 4 ./hello_MPI
I get the same output 4 times, showing that it is just running the same single process in 4 different processors
Hello world from process 0 of 1 processes
Hello world from process 0 of 1 processes
Hello world from process 0 of 1 processes
Hello world from process 0 of 1 processes
I have run this same code in a different machine and I get the expected output:
Hello world from process 0 of 4 processes
Hello world from process 1 of 4 processes
Hello world from process 2 of 4 processes
Hello world from process 3 of 4 processes