VMS Help
FORTRAN, Statements, IF
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Conditionally transfers control or executes a statement or block of
statements.
For each type of IF statement, the decision to transfer control or
to execute the statement or block of statements is based on the
evaluation of an expression within the IF statement.
Executes the statement at the first label if the arithmetic
expression evaluates to a value less than 0; the statement at the
second label if the arithmetic expression evaluates to 0; or the
statement at the third label if the arithmetic expression evaluates
to a value greater than 0. Statement format:
IF (e) s1,s2,s3
e Is an arithmetic expression.
s1,s2,s3 Are labels of executable statements in the same
program unit. All three labels are required,
but they need not refer to different statements.
Executes the statement at the first label ("s1") if the arithmetic
expression evaluates to a value less than 0; the statement at the
second label ("s2") if the arithmetic expression evaluates to 0; or
the statement at the third label ("s3") if the arithmetic
expression evaluates to a value greater than 0.
Executes the statement if the logical expression is true.
Statement format:
IF (e) st
e Is a logical expression.
st Is a complete Fortran statement. The statement can
be any statement except DO, END DO, END, block IF,
or another logical IF statement.
Executes a block of statements if the logical expression is true.
The block of statements starts immediately following the IF
statement. The block of statements can be followed by optional
ELSE IF statements (any number) and one optional ELSE statement.
The entire block IF construct must be terminated by an END IF
statement. Format:
IF (e) THEN
block
ELSE IF (e1) THEN
block
ELSE
block
END IF
e,e1 Are logical expressions.
block Is a series of zero or more Fortran statements
(called a statement block).
NOTE: No additional statement can be placed after the IF THEN
statement in a block IF construct. For example, the following
statement is invalid in the block IF construct:
IF (e) THEN I = J
This statement is translated as the following logical IF statement:
IF (e) THENI = J
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.