Converting block distribution to cyclic distribution
BLK_SIZE = (N + NP – 1) / NP
. . .
BLK_START = R * BLK_SIZE
. . .
IF (N – BLK_START >= BLK_SIZE) THEN
BLK_COUNT = BLK_SIZE
ELSEIF (N – BLK_START > 0) THEN
BLK_COUNT = N – BLK_START
ELSE
BLK_COUNT = 0
ENDIF
. . .
I = BLK_START + L
BLK_SIZE = (N + NP – 1) / NP
. . .
BLK_START = R
. . .
BLK_COUNT = (N – R + NP – 1) / NP
. . .
I = BLK_START + NP * (L - 1) + 1