Remove Real And Double Precision Do Loop Counters

Description:  The Remove ­Real ­And Double ­Precision ­Loop ­Counters targets to transform a DO loop with control to a DO loop without control or DO WHILE loop base on user selection. A qualified control DO loop for this refactoring is when the counter is a real or double precision type The refactoring supports both cases where the step-­‐size is explicit or implicit. When the step size is implicit, a value of +1 or ­1 is used (based on comparison of lower and upper loop bounds).

State: Implemeted         Author:  Rita Chow, Nicola Hall, Jerry Hsiao, Mark Mozolewski, Chamil Wijenayaka     Version:  Photran 7

Code Example:

PROGRAM RemoveDoLoopEX2_1
    REAL :: counter, sum
    sum = 0.0
    DO counter = 1.2, 1.8, 0.1
        sum = sum + counter
    END DO
    PRINT *, sum
END PROGRAM RemoveDoLoopEX2_1

PROGRAM RemoveDoLoopEX2_1
    REAL :: counter, sum
    sum = 0.0
    counter = 1.2
    DO
        sum = sum + counter
        counter = counter + 0.1
        IF(counter > 1.8) THEN
            EXIT
        END IF
     END DO
     PRINT *, sum
END PROGRAM RemoveDoLoopEX2_1

ScreenShots

      

HTML Comment Box is loading comments...