1
votes

I'm working on building an MPI-based molecular dynamics program against several MPI implementations (separately), and I've run into a snag with MPICH 3.0: it seems not to provide explicit interfaces for several MPI procedures. Some of the affected procedures are mpi_bcast(), mpi_ssend(), mpi_recv(), and mpi_finalize(). MPICH 3.0 does provide explicit interfaces for some procedures, however, such as mpi_init(). This example code demonstrates the problem:

program mpitest
use mpi
integer ierr

ierr = 0
call dummy_implicit(ierr)

call mpi_init(ierr)
if (ierr /= 0) then
    write(*,*) 'MPI_Init() failed'
    stop
endif

call mpi_finalize(ierr)
if (ierr /= 0) then
    write(*,*) 'MPI_Finalize() failed'
endif

stop
end program

If I build this program on CentOS 7 against MPICH 3.0.4, I get this result:

$which mpif90
/usr/lib64/mpich/bin/mpif90
$ mpif90 -Wimplicit-interface -c -o mpitest.o mpitest.f90 mpitest.f90:6.31:

      call dummy_implicit(ierr)
                               1 Warning: Procedure 'dummy_implicit' called with an implicit interface at (1) mpitest.f90:15.29:

      call mpi_finalize(ierr)
                             1 Warning: Procedure 'mpi_finalize' called with an implicit interface at (1)
$

The warning about procedure dummy_implicit() is expected and correct, but I expect MPICH to provide an explicit interface for mpi_finalize(), just as it apparently does for mpi_init(). Moreover, I find that if I build the same program against MPICH 3.2 or OpenMPI 1.10.3 then an implicit interface warning is emitted only for procedure dummy_implicit().

This issue bears some resemblance to one reported against MPICH2, but that one (1) was reported against MPICH 2, not MPICH 3, and (2) was closed about 5 years ago.

I do want to ensure that I have explicit interfaces in scope for all my procedure calls. I can provide the missing ones manually if need be, but surely that's not the intended usage model, nor is it required for other MPI implementations.

What am I doing wrong? Do I really need to provide explicit interfaces manually?

1

1 Answers

2
votes

There is no guarantee that the mpi Fortran module will contain explicit interface for particular procedure. Some are contained more commonly (those with fixed datatypes), some very rarely (those where buffers of various types are passed, just think how many versions would have to be generated...).

The number of procedures in the module will differ from library to library, from version to version and could also be affected by configuration before compiling the MPI library.

I just wouldn't use -Wimplicit-interface with MPI. I tried providing some interfaces myself, but then you will find out that at some other computer the interface is provided and you have a clash and it will not compile at all.

You can try the mpi_f08 module if your library supports it, it typically contains everything with an explicit interface. But that also requires some advanced features from the compiler and some of them are not widely supported yet.