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

 

IF Statement

Example,

    IF (bool_val) A = 3

The basic syntax is,

IF(< logical-expression >)< exec-stmt >

If < logical-expression > evaluates to .TRUE. then execute < exec-stmt > otherwise do not.

For example,

    IF (x .GT. y) Maxi = x
means `if x is greater than y then set Maxi to be equal to the value of x'.

More examples,

    IF (a*b+c <= 47) Boolie = .TRUE.
    IF (i .NE. 0 .AND. j .NE. 0) k = 1/(i*j)
    IF (i /= 0 .AND. j /= 0) k = 1/(i*j) ! same


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

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