The run of elements that rank r-1 owns and that also lies in [first,last]: a..b, empty when b < a. offsetElem is a decomposition's contiguous ownership table, so rank r-1 owns offsetElem(r)+1 .. offsetElem(r+1).
Both halves of the migration schedule are this one intersection, evaluated from replicated tables: my receive run from peer r-1 is (my window) n (r-1's old range), and my send run to peer r-1 is (r-1's window) n (my old range). Factored out so that the sender and the receiver cannot drift apart, and so a serial test can exercise the arithmetic the exchange actually uses rather than a copy of it.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | offsetElem(:) | |||
| integer, | intent(in) | :: | r | 1-based table index; the rank is r-1 |
||
| integer, | intent(in) | :: | first | |||
| integer, | intent(in) | :: | last | |||
| integer, | intent(out) | :: | a | |||
| integer, | intent(out) | :: | b |
subroutine OwnedRun(offsetElem,r,first,last,a,b)
!! The run of elements that rank r-1 owns and that also lies in [first,last]: a..b, empty when
!! b < a. offsetElem is a decomposition's contiguous ownership table, so rank r-1 owns
!! offsetElem(r)+1 .. offsetElem(r+1).
!!
!! Both halves of the migration schedule are this one intersection, evaluated from replicated
!! tables: my receive run from peer r-1 is (my window) n (r-1's old range), and my send run to
!! peer r-1 is (r-1's window) n (my old range). Factored out so that the sender and the
!! receiver cannot drift apart, and so a serial test can exercise the arithmetic the exchange
!! actually uses rather than a copy of it.
implicit none
integer,intent(in) :: offsetElem(:)
integer,intent(in) :: r !! 1-based table index; the rank is r-1
integer,intent(in) :: first
integer,intent(in) :: last
integer,intent(out) :: a
integer,intent(out) :: b
a = max(first,offsetElem(r)+1)
b = min(last,offsetElem(r+1))
endsubroutine OwnedRun