PrincetonUniversity / EDIPIC-2D

GNU General Public License v3.0
33 stars 20 forks source link

Fixing type mismatch error in MPI calls when compiling with gcc/gfortran version >=10 #14

Closed stephethier closed 1 year ago

stephethier commented 1 year ago

We were getting compilation errors when building EDIPIC2D with gfortran >= 10. It happens when two or more of the same MPI calls appear in the same subroutine but are used with different data types. Here is an example (not from EDIPIC2D, though):

  call MPI_BCAST(n,1,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
  call MPI_BCAST(tt0,1,MPI_DOUBLE_PRECISION,0,MPI_COMM_WORLD,ierr)

This is very common and happens all over the code. The errors come from the fact that EDIPIC2D uses include 'mpif.h' instead of the proper MPI Fortran module. A way to turn those errors into simple warnings was to add -fallow-argument-mismatch as a compiler option but this is not an ideal solution. We should use the "mpi" Fortran module instead.

In this PR, all "include 'mpif.h'" were replaced with "use mpi" to have proper Fortran interfaces to the generic MPI subroutines. This avoids the errors put out by the gfortran compiler (version >+ 10) when calling the same MPI subroutine with different datatypes. There was also a problem with all the MPI_SEND() calls having an extra argument ("request") that should not be there. The extra argument was removed.