7.7.2 IF Statement

The IF statement conditionally executes one statement based on the value of a logical expression. (This statement was called a logical IF statement in FORTRAN 77.)

The IF statement takes the following form:

IF (expr) stmt

expr
Is a scalar logical expression enclosed in parentheses.

stmt
Is any complete, unlabeled, executable Fortran statement, except for the following:

When an IF statement is executed, the logical expression is evaluated first. If the value is true, the statement is executed. If the value is false, the statement is not executed and control transfers to the next statement in the program.

Examples

The following examples show valid IF statements:

IF (J.GT.4 .OR. J.LT.1) GO TO 250

IF (REF(J,K) .NE. HOLD) REF(J,K) = REF(J,K) * (-1.5D0)

IF (ENDRUN) CALL EXIT


Previous Page Next Page Table of Contents