This Fortran MPI program is, to my mind, completely straightforward:
program what
use mpi
integer(4), parameter :: ksp = 4
integer(4), parameter :: kdp = 8
integer(ksp) :: nreadslb
integer(ksp), ALLOCATABLE :: all_nreadslb(:)
real(kdp) :: compute_time
real(kdp), ALLOCATABLE :: all_compute_times(:)
integer(ksp) :: myrank
integer :: ierr
call mpi_init(ierr)
allocate(all_nreadslb(10), all_compute_times(10))
CALL MPI_GATHER(compute_time, 1, &
MPI_DOUBLE_PRECISION, all_compute_times, 1, &
MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
CALL MPI_GATHER(nreadslb, 1, MPI_INTEGER4, &
all_nreadslb, 1, MPI_INTEGER4, 0, &
MPI_COMM_WORLD, ierr)
call mpi_finalize(ierr)
end program
But it fails to compile on a Cray platform under GNU. The error returned is:
23 | CALL MPI_GATHER(compute_time, 1, &
| 2
......
26 | CALL MPI_GATHER(nreadslb, 1, MPI_INTEGER4, &
| 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/REAL(8)).
The real kicker is that if I comment out the first MPI_GATHER, the second one compiles just fine, and if I comment out the second MPI_GATHER, the first one compiles just fine. There is something about having the both of them in the code that the GNU compiler does not like. Just for grins, I put a debug statement in between them; got the same error. The code compiles just fine under Cray or Intel Fortran.
Any ideas what the problem could be?
EDIT: I am using the Cray environment PrgEnv-gnu/6.0.9 which uses gfortran from gcc 10.1.0 and Cray MPICH 7.7.16. I am compililng with the Cray "ftn" command, no flags, just ftn what.f90. Also found out that the problem is with gcc 10.1.0; code compiles just fine under 9.3.0. So that solves the immediate problem. But if anyone knows what to do under 10.1.0 (since 9.3.0 won't last forever) would love to hear it! Thanks.