Subroutine to receive solutions Note when blocking == .false. this is actually a wait because the nonblocking receive should have already been posted
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(pf_pfasst_t), | intent(inout) | :: | pf | main pfasst structure |
||
class(pf_level_t), | intent(inout) | :: | level | level to recieve into |
||
integer, | intent(in) | :: | tag | message tag |
||
logical, | intent(in) | :: | blocking | true if receive is blocking |
||
integer, | intent(inout) | :: | ierror | error flag |
||
integer, | intent(in), | optional | :: | direction |
subroutine pf_mpi_recv(pf, level, tag, blocking, ierror, direction)
use pf_mod_mpi, only: MPI_STATUS_SIZE
type(pf_pfasst_t), intent(inout) :: pf !! main pfasst structure
class(pf_level_t), intent(inout) :: level !! level to recieve into
integer, intent(in ) :: tag !! message tag
logical, intent(in ) :: blocking !! true if receive is blocking
integer, intent(inout) :: ierror !! error flag
integer, optional, intent(in) :: direction
integer :: source, dir
integer :: stat(MPI_STATUS_SIZE)
dir = 1 ! default 1: send forward; set to 2 for send backwards
if(present(direction)) dir = direction
if(dir == 2) then
source = modulo(pf%rank+1, pf%comm%nproc)
else
source = modulo(pf%rank-1, pf%comm%nproc)
end if
if (blocking) then
call mpi_recv(level%recv, level%mpibuflen, myMPI_Datatype, &
source, tag, pf%comm%comm, stat, ierror)
else
call mpi_wait(pf%comm%recvreq(level%index), stat, ierror)
end if
end subroutine pf_mpi_recv