array_partition Subroutine

public subroutine array_partition(n, k, p, start, count)

Compute start and count for the p'th partition of an array of size n where p = 0, 1, ... , k - 1.

For k partitions, an array of n elements can be partitioned into r partitions of length q + 1, and k - r partitions of length q where q and r are the quotient and remainder of n divided by k (i.e. n = q * k + r). Note, we assume that the r partitions of length q + 1 precede the k - r partitions of length q in the array.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(in) :: k
integer, intent(in) :: p
integer, intent(out) :: start
integer, intent(out) :: count