Could not resolve generic procedure with MPI and pgfortran

Dear all,

I’m trying to compile the following (very simple) piece of code:

program sendrecv
  use mpi
  implicit none

  integer :: nthreads=1
  integer :: nproc, myrank
  integer :: tag, status, ierr
  integer :: token=0
  integer :: i

  call MPI_Init(ierr)
  call MPI_Comm_Size(MPI_COMM_WORLD, nproc, ierr)
  call MPI_Comm_Rank(MPI_COMM_WORLD, myrank, ierr)

  do i = 1, nproc
     call MPI_Barrier(MPI_COMM_WORLD, ierr)
     if (myrank == (i - 1)) then
        print "('My rank is: ', I2, ' on ', I2, ' total processes')" &
             , myrank, nproc
  call MPI_Barrier(MPI_COMM_WORLD, ierr)

  tag = 42
  if (myrank > 0) then
     call MPI_Recv(token, 1, MPI_INTEGER, myrank-1, tag, MPI_COMM_WORLD &
         , status, ierr)
  call getpid(pid)
  print "('proc: ', I2)", myrank
  if (myrank < (nproc-1)) then
     call MPI_Send(token, 1, MPI_INTEGER, myrank+1, tag, MPI_COMM_WORLD, ierr)
  call MPI_Barrier(MPI_COMM_WORLD, ierr)
  call MPI_Finalize(ierr)

end program sendrecv

But it fails and I get this error:

PGF90-S-0155-Could not resolve generic procedure mpi_recv (sendrecv.f90: 39)

If I understand well, it is linked to the strong typing of Fortran variables, and it means that something is wrong in my MPI_Send/Recv() calls. I failed to see what is wrong though, since “token” is an integer, and I declare it as a “MPI_INTEGER” in these calls.

I’m working with PGI 14.1 and OpenMPI 1.8.

Any help would be appreciated!


Well this was an interesting problem to sort out!

The problem with your code is with the declaration of the status variable here:

integer :: tag, status, ierr

You can fix your code by changing the declaration of status as follows:

integer :: tag, status(MPI_STATUS_SIZE), ierr

This declares status as an array of size MPI_STATUS_SIZE, which ensures that your variable is big enough to receive all the status variables from the MPI runtime. MPI_STATUS_SIZE is defined in the MPI standard. The MPI_Recv call is expecting to receive an array here, which triggers the error.

I made this change, and was able to run your program successfully:

$ mpif90 -o sendrecv sendrecv.f90
$ mpirun -np 2 ./sendrecv
My rank is:  1 on  2 total processes
proc:  1
My rank is:  0 on  2 total processes
proc:  0

Hope this helps.

Best regards,



Thanks a lot for your help on this problem. And it actually solves a problem I had with other compilers (but they didn’t complain at compiling time, they were only producing bad results in -O0 and -O1 (but not in -O2 and -O3!)).