Lahey/Fujitsu Fortran

IF Statement

Description

The IF statement controls whether or not a statement is executed based on the value of a logical expression.

Syntax

IF (expr) action-statement
Where:

expr is a scalar LOGICAL expression.

action-statement is an executable statement other than another IF

or the END statement of a program, function, or subroutine.

Remarks

Execution of an IF statement causes evaluation of the logical expression.

If the expression is true, the action-statement is executed.

If the value is false, the action-statement is not executed.

Example

real :: a=-1 if (a < 0) write(*,*) " a must be less than zero,& & because this statement was executed"