user3443033
user3443033

Reputation: 779

There is no specific subroutine for the generic ‘mpi_send

subroutine collect(rank, nprocs, n_local, n_global, u_initial_local)

use mpi

implicit none

integer*8                           :: i_local_low, i_local_high
integer*8                           :: i_global_low, i_global_high
integer*8                           :: i_local, i_global
integer*8                           :: n_local, n_global
real*8                              :: u_initial_local(n_local)
real*8, dimension(:), allocatable   :: u_global
integer                             :: procs
integer*8                           :: n_local_procs

! Data declarations for MPI
integer     :: ierr ! error signal variable, Standard value - 0
integer     :: rank ! process ID (pid) / Number
integer     :: nprocs ! number of processors

! MPI send/ receive arguments
integer                             :: buffer(2)
integer, parameter                  :: collect1 = 10
integer, parameter                  :: collect2 = 20


! status variable - tells the status of send/ received calls
! Needed for receive subroutine
integer, dimension(MPI_STATUS_SIZE) :: status1

i_global_low  = (rank       *(n_global-1))/nprocs
i_global_high = ((rank+1)   *(n_global-1))/nprocs

if (rank > 0) then
    i_global_low = i_global_low - 1
end if

i_local_low = 0
i_local_high = i_global_high - i_global_low

if (rank == 0) then
    allocate(u_global(1:n_global))

    do i_local = i_local_low, i_local_high
        i_global = i_global_low + i_local - i_local_low
        u_global(i_global) = u_initial_local(i_local)
    end do

    do procs = 1,nprocs-1

        call MPI_RECV(buffer, 2, MPI_INTEGER, procs, collect1, MPI_COMM_WORLD, status1, ierr)

        i_global_low = buffer(1)
        n_local_procs = buffer(2)

        call MPI_RECV(u_global(i_global_low+1), n_local_procs, MPI_DOUBLE_PRECISION, procs, collect2, MPI_COMM_WORLD, status1, ierr)        
    end do

    print *, u_global

else

    buffer(1) = i_global_low
    buffer(2) = n_local


    call MPI_SEND(buffer, 2, MPI_INTEGER, 0, collect1, MPI_COMM_WORLD, ierr)


    call MPI_SEND(u_initial_local, n_local, MPI_DOUBLE_PRECISION, 0, collect2, MPI_COMM_WORLD, ierr)
end if

return
end subroutine collect

I am getting the error for MPI_SEND and MPI_RECV corresponding to collect2 tag. "There is no specific subroutine for the generic ‘mpi_recv’ at (1)" and 1 is at the end of .......ierr). MPI_SEND for collect2 tag is sending an array and MPI_RECV is receiving that array. This does not happen for collect1 tag.

Upvotes: 1

Views: 2704

Answers (1)

Your n_local is integer*8 but it must be integer (see How to debug Fortran 90 compile error "There is no specific subroutine for the generic 'foo' at (1)"?).

There are many articles (like https://blogs.cisco.com/performance/can-i-mpi_send-and-mpi_recv-with-a-count-larger-than-2-billion) about the problem with large arrays (more than maxint elements) and MPI. If you do have the problems with n_local being too large for integer, you can use derived types (like MPI_Type_contiguous) to lower the number of elements passed to MPI procedures so that it fits into a 4-byte integer.

Upvotes: 3

Related Questions