Initiates a non-blocking receive operation. The request must be waited on using wait() or test() before the buffer can be used.
data is allocated here when it arrives unallocated, to the size
the incoming message actually carries. Passing an unallocated
buffer is therefore how a caller that cannot know the size asks
for one, and matches what the blocking recv and the 2-D
irecv already do.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(comm_t), | intent(in) | :: | comm | |||
| integer(kind=int32), | intent(inout), | allocatable | :: | data(:) | ||
| integer(kind=int32), | intent(in) | :: | source | |||
| integer(kind=int32), | intent(in) | :: | tag | |||
| type(request_t), | intent(out) | :: | request |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int32), | private | :: | count | ||||
| integer(kind=int32), | private | :: | ierr | ||||
| integer(kind=int32), | private | :: | msg_source | ||||
| integer(kind=int32), | private | :: | msg_tag | ||||
| integer, | private | :: | stat(MPI_STATUS_SIZE) |
subroutine comm_irecv_integer_array(comm, data, source, tag, request) !! Initiates a non-blocking receive operation. The request must be !! waited on using wait() or test() before the buffer can be used. !! !! `data` is allocated here when it arrives unallocated, to the size !! the incoming message actually carries. Passing an unallocated !! buffer is therefore how a caller that cannot know the size asks !! for one, and matches what the blocking `recv` and the 2-D !! `irecv` already do. type(comm_t), intent(in) :: comm integer(int32), allocatable, intent(inout) :: data(:) integer(int32), intent(in) :: source integer(int32), intent(in) :: tag type(request_t), intent(out) :: request integer(int32) :: ierr integer(int32) :: count integer(int32) :: msg_source, msg_tag integer :: stat(MPI_STATUS_SIZE) msg_source = source msg_tag = tag ! Sizing an unallocated buffer needs the message to have been matched, ! so probe first. That blocks until the envelope arrives, not until the ! data does, and the receive below is still the non-blocking one. The ! probed source and tag are what the receive then asks for, so that a ! wildcard cannot match a second, differently sized message between the ! two calls; for a fixed pair MPI's non-overtaking rule already gives ! the receive the message that was probed. if (.not. allocated(data)) then call MPI_Probe(source, tag, comm%m_comm, stat, ierr) call MPI_Get_count(stat, MPI_INTEGER, count, ierr) msg_source = stat(MPI_SOURCE) msg_tag = stat(MPI_TAG) allocate (data(count)) end if call MPI_Irecv(data, size(data), MPI_INTEGER, msg_source, msg_tag, comm%m_comm, & request%m_request, ierr) request%is_valid = .true. end subroutine comm_irecv_integer_array