I was trying to install openpi on ubuntu. I have an Ubuntu 18.04.4 LTS (64 bit) desktop. I installed openmpi using
sudo apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi2 libopenmpi-dev openssh-client openssh-server
Then, in the .bashrc, I have added the following two lines:
echo export PATH="$PATH:/home/$USER/.openmpi/bin" >> /home/$USER/.bashrc
echo export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/$USER/.openmpi/lib/" >> /home/$USER/.bashrc
After that, I used dartmouth hello world mpi to write a small program, compile it and run it to check that the openmpi installation is OK by typing gfortran ubuntu.f90
which leads to the following error
ubuntu.f90:2: Error: Can't open included file 'mpif.h'
the code in ubuntu.f90 :
program hello
include 'mpif.h'
integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
print*, 'node', rank, ': Hello world'
call MPI_FINALIZE(ierror)
end
I have tried installing libblacs-mpi-dev as in the answer to this question. This question does not seem relevant.
To include a C-style header file in a Fortran program, you need to use a C-style pre-processor directive
rather than a native Fortran
include
statement, and then tellgfortran
to run the pre-processor by adding the-cpp
command-line switch (or change the source file suffix to upper-caseF90
which causes the pre-processor to be run by default). See for exampleHowever including
mpif.h
is apparently deprecated, and instead you should probably use the MPI module, and compile your program usingmpif90
instead of invokinggfortran
directly.Ex.
FWIW, your changes to
PATH
andLD_LIBRAY_PATH
likely have no effect since you have installedopenmpi
into system directories usingapt