next up previous contents
Next: Visualisation of the IF Up: Control Constructs Previous: Visualisation of the IF

 

IF ... THEN ... ELSE Construct

The block-IF is a more flexible version of the single line IF. A simple example,

    IF (i .EQ. 0) THEN
     PRINT*, "I is Zero"
    ELSE
     PRINT*, "I is NOT Zero"
    ENDIF

note the how indentation helps.

Can also have one or more ELSEIF branches:

    IF (i .EQ. 0) THEN
     PRINT*, "I is Zero"
    ELSE IF (i .GT. 0) THEN
     PRINT*, "I is greater than Zero"
    ELSE 
     PRINT*, "I must be less than Zero"
    ENDIF

Both ELSE and ELSEIF are optional.


next up previous contents
Next: Visualisation of the IF Up: Control Constructs Previous: Visualisation of the IF

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