I am using Ubuntu for development of Fortran (2008+) programs with MPI. Things were pretty settled on earlier Ubuntu versions, but I am experiencing some difficulties to compile and run Fortran/MPI on Ubuntu 22.04, which I installed on a new PC very recently.
I first installed OpenMPI, but it wouldn't compile my programs at all, complaining that it can't find some include files related to mpi_f08
. (I am sorry, but I can't recall the exact message and I uninstalled the OpenMPI since).
I had better luck with MPICH though. It can compile my programs, but crashes during execution as soon as the first communication between processors should take place. A minimum example which demonstrates the issue is given below:
subroutine global_sum_real(phi_old)
use mpi_f08
implicit none
real :: phi_old
real :: phi_new
integer :: error
call mpi_allreduce(phi_old, & ! send buffer
phi_new, & ! recv buffer
1, & ! length
mpi_real, & ! datatype
mpi_sum, & ! operation
mpi_comm_world, & ! communicator
error)
phi_old = phi_new
end subroutine
program global_sum_mpi
use mpi_f08
implicit none
real :: suml
integer :: error
call mpi_init(error)
suml = 1.0
call global_sum_real(suml)
print *, suml
call mpi_finalize(error)
end program
I hope it is clear what is happening above. The main program (global_sum_mpi
) initializes MPI and calls one subroutine (global_sum_real
) which is essentially an interface to MPI_Allreduce
. Very simple.
If I compile it with mpifort (it is an: mpifort for MPICH version 4.0 ... gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)) and try to run it in parallel, it crashes with the error:
Internal Error: Invalid type in descriptor
in the line which calls MPI_Allreduce
. The funny thing is that if I change the modules I used for MPI from:
use mpi_f08
to the plain:
use mpi
Everything works as expected. This is not a route I would like to take because I believe that mpi_f08
is more up to date with later Fortran standards and I also need the mpi_f08
for better compatibility with external PETSc libraries.
Any ideas on why the use mpi_f08
is causing problems on the new Ubuntu installation?
Kind regards