FORTRAN Reference Manual
Statements
FORTRAN Reference Manual—528615-001
7-59
IF Statement—Logical
label1, label2, label3
are integers designating the labels of executable statements in the same program
unit. The same statement label can appear more than once in the same arithmetic
IF statement.
Considerations
The arithmetic IF statement transfers control to
•
label1 if the value of exp is negative.
•
label2 if the value of exp is zero.
•
label3 if the value of exp is greater than zero.
Example
The following example transfers control to statement 10 if BALANCE is negative, to
statement 20 if BALANCE equals zero, and to statement 30 if BALANCE is greater
than zero:
READ (8, 99) balance
IF (balance) 10, 20, 30
10 PRINT *, 'You''re overdrawn by', balance
GO TO 40
20 PRINT *, 'You have a zero balance'
GO TO 40
30 PRINT *, 'You have a balance of', balance
40 CONTINUE
IF Statement—Logical
The logical IF statement conditionally executes a specified statement.
exp
is a logical expression.
statement
is any executable statement except a DO, block IF, ELSE IF, ELSE, END IF, END,
or another logical IF statement.
IF ( exp) statement










