Calculate block sizes and ranges. author: Seyed Ali Ghasemi
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | d | |||
integer, | intent(in) | :: | nimg | |||
integer, | intent(out) | :: | block_size(nimg) | |||
integer, | intent(out) | :: | start_elem(nimg) | |||
integer, | intent(out) | :: | end_elem(nimg) |
pure subroutine compute_block_ranges(d, nimg, block_size, start_elem, end_elem) integer, intent(in) :: d, nimg integer, intent(out) :: block_size(nimg), start_elem(nimg), end_elem(nimg) integer :: i, remainder block_size = d / nimg remainder = mod(d, nimg) block_size(1:remainder) = block_size(1:remainder) + 1 start_elem(1) = 1 do i = 2, nimg start_elem(i) = start_elem(i - 1) + block_size(i - 1) end do end_elem(1) = block_size(1) end_elem(2:) = start_elem(2:) + block_size(2:) - 1 ! Check if the block sizes are valid. if (minval(block_size) <= 0) error stop 'ForDot: reduce the number of images of coarray.' end subroutine compute_block_ranges