(NOTE: The older syntax forms using line number will NOT be discussed !!!)
DO variable = startValue, StopValue [, StepValue] one or more statments END DO |
integer i, j do i = 1, 100, 7 j = i*i print *, "i = ", i, ", i^2 = ", j end do |
DO WHILE (condition) one or more statments END DO |
Example:
l1 = 1; l2 = x/l1 do while ( abs(l1 - l2) > 1e-10 ) l1 = (l1 + l2)/2.0 l2 = x/l1 end do |
do ... ... end do |
DO ! FOREVER !!! .... IF ( ... ) THEN EXIT END IF END DO |
DO X = 1, 100 .... IF ( X == 44 ) THEN CYCLE ! Skip when X == 44 END IF END DO |
DO line# variable = startValue, StopValue multiple statements line# CONTINUE |
Example:SUM = 0 DO 10 I = 1, 10 SUM = SUM + I 10 CONTINUE |
Guess what the new F77 program did...