8.2.4 Loop Peeling

In cases where an array is used to simulate a cylindrical coordinate system where the left edge of the array must be adjacent to its right edge, a method known as a wraparound variable is often used:

JM1 = N
DO 10 J = 1,N
B(J) = (A(J) + A(JM1)) /2
JM1 = J
10    CONTINUE

In the first iteration, JM1 is N . In all iterations except for J=1 , the value of JM1 is J-1 . Thus, JM1 is an induction variable for the loop after the first iteration. By peeling off the first iteration of the loop, the JM1 induction variable can be recognized, as follows:

JM1 = N
IF (N .GE. 1) THEN
RR1 = A(1) + A(N)
JM1 = 1
II1 = N - 1
B(1) = RR1 / 2
DO 3 J=2,N
B(J) = (A(J) + A(J-1)) / 2
3   CONTINUE
IF (II1 .GT. 0) JM1 = II1 + 1
ENDIF

KAP may peel off several iterations in cases where multiple wraparound variables exist.


Previous Page | Next Page | Contents | Index |
Command-Line Qualifiers