next up previous contents
Next: Scope of DO Variables Up: Control Constructs Previous: Indexed DO Loops

 

Examples of Loop Counts

A few examples of different loops,

  1. upper bound not exact,
        loopy: DO i = 1, 30, 2  
         ... ! i is 1,3,5,7,...,29
         ... ! 15 iterations
        END DO loopy
  2. negative stride,
        DO j = 30, 1, -2 
         ... ! j is 30,28,26,...,2
         ... ! 15 iterations
        END DO
  3. a zero-trip loop,
        DO k = 30, 1, 2  
         ... ! 0 iterations
         ... ! loop skipped
        END DO
  4. missing stride -- assume it is 1,
        DO l = 1,30
         ... ! i = 1,2,3,...,30
         ... ! 30 iterations
        END DO

For more information, click here gif


next up previous contents
Next: Scope of DO Variables Up: Control Constructs Previous: Indexed DO Loops

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.