next up previous contents
Next: Conditional Exit Loops Up: Control Constructs Previous: Visualisation of IF ...

 

Nested and Named IF Constructs

All control constructs can be both named and nested.

    outa: IF (a .NE. 0) THEN
            PRINT*, "a /= 0"
            IF (c .NE. 0) THEN
              PRINT*, "a /= 0 AND c /= 0"
            ELSE 
              PRINT*, "a /= 0 BUT c == 0"
            ENDIF   
          ELSEIF (a .GT. 0) THEN outa
            PRINT*, "a > 0"
          ELSE outa
            PRINT*, "a must be < 0"
          ENDIF outa

The names may only be used once per program unit and are only intended to make the code clearer.

For more information, click here gif

Now try this question gif


next up previous contents
Next: Conditional Exit Loops Up: Control Constructs Previous: Visualisation of IF ...

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