I am using Mvapich-3.0 to build F90 parallel codes. Now with gfortran version >= 10, the compiler always complains the following “Type mismatch” error:
Compilation command:
mpif90 -I/opt/mvapich/include -c reduce.f90
Error message:
reduce.f90:27:27:
12 | call MPI_Allreduce(dv_src, dv, vlen, MPI_DOUBLE_PRECISION, &
| 2
......
27 | call MPI_Allreduce(zv_src, zv, vlen, MPI_DOUBLE_COMPLEX, &
| 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (COMPLEX(8)/REAL(8)).
reduce.f90:27:35:
12 | call MPI_Allreduce(dv_src, dv, vlen, MPI_DOUBLE_PRECISION, &
| 2
......
27 | call MPI_Allreduce(zv_src, zv, vlen, MPI_DOUBLE_COMPLEX, &
| 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (COMPLEX(8)/REAL(8)).
Source code: reduce.f90:
subroutine reduceData_Dbl(dv, dv_src, vlen)
include 'mpif.h'
! ----------------------------------------------------------------
double precision :: dv(*), dv_src(*)
integer :: vlen
integer :: i, ierr
! ----------------------------------------------------------------
call MPI_Allreduce(dv_src, dv, vlen, MPI_DOUBLE_PRECISION, &
MPI_SUM, MPI_COMM_WORLD, ierr)
end
subroutine reduceData_Cpx(zv, zv_src, vlen)
include 'mpif.h'
! ----------------------------------------------------------------
double complex :: zv(*), zv_src(*)
integer :: vlen
integer :: i, ierr
! ----------------------------------------------------------------
call MPI_Allreduce(zv_src, zv, vlen, MPI_DOUBLE_COMPLEX, &
MPI_SUM, MPI_COMM_WORLD, ierr)
end
Although we can add the -fallow-argument-mismatch option to bypass this error, but gfortran man page and documents suggest that this is highly discouraged. The proper way is to add use mpi for interface declaration, replacing the line include ‘mpif.h’ in the source code.
But for mvapich-3.0 specific, adding use mpi does not work. The same error message is still there. The only way to solve it, as my test so far, is adding use mpi_f08 instead. However, doing this many MPI specific handles have to be changed from type integer to the new data types, for example, TYPE(MPI_Comm), TYPE(MPI_Group), TYPE(MPI_Request), TYPE(MPI_Status), …. etc. When building a large software, e.g., BerkeleyGW, there are hundreds of F90 codes, each code may have thousands of lines, hence doing this is a terrible work. Further, in such a large software, even adding -fallow-argument-mismatch option cannot bypass the type mismatch error.
So my question, whether there is a way to bypass this error easily ? I suspect that adding use mpi should work, provided that it could supply the completed F90 interfaces of all subroutines. In addition, it seems that using use mpi we don’t have to change the data types of the MPI handles. But for my test so far it cannot work. Is there anything wrong in my test ?
Any suggestions are very appreciated. Thank you very much.
T.H.Hsieh