I have been trying to build an application which seems to be mixing files that use mpi_f08
and files that use mpi
. The problem is that it failed at compiling some MPI calls. It took me a while to figure out that it was a communicator data type the real problem:
error #6285: There is no matching specific subroutine for this generic subroutine call. [MPI_BCAST]
Here it is an extracted section:
module submod
use mpi_f08
implicit none
contains
subroutine callmpi(pe, nproc, comm)
integer :: pe,nproc
integer :: comm
integer :: ierr
integer :: sbuf
sbuf = 0
call mpi_bcast( sbuf, 1, mpi_integer, 0, comm, ierr )
end subroutine callmpi
end module submod
Changing the comm
datatype from integer
to type(mpi_comm)
fixes the problem. Now, the application is huge and I was wondering if there was a compiler flag (Intel) that could do this without modifying the code.
Compiler flags are not magic.
In the Fortran 2008 MPI bindings the interface of MPI_Bcast
is, as noted, not compatible with the "older" Fortran bindings. The (MPI standard) mpi_f08
module does not provide a generic MPI_Bcast
with a specific procedure matching this other binding.
A Fortran compiler does not know how to map an integer to a different type and it's extreme to expect a Fortran compiler to special-case MPI.
Now, you modified your use mpi
(or include 'mpif.h'
) code to move to use mpi_f08
, so you can make further modifications. To incrementally update your codebase to the Fortran 2008 bindings you can use a renaming technique like:
use mpi_f08, MPI_Bcast_unported => MPI_Bcast
use mpi, only : MPI_Bcast
call MPI_Init ! F2008 binding, with optional ierror absent
call MPI_Bcast(...) ! Pre-F2008 binding call