IF Directive [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Reference
IF Directive
The IF directive conditionally compiles blocks of source code.
Syntax
$IF (condition_list)
condition_list is a logical expression for conditional
compilation.
Default None.
Location The IF directive can appear anywhere in the source
code. It must be the only directive that appears
on the line.
Toggling/ Duration The IF directive remains in effect until
terminated by an ENDIF directive.
Additional Information
The condition list is interpreted as having identifiers for operands and
.NOT., .AND., and .OR. for operators. The operator precedence ranking is
from .NOT.,highest, to .OR., lowest; this precedence can be overridden
with parentheses.
Directives used with IF are ELSE, ENDIF, and SET. The IF directive has an
optional ELSE block, and a required ENDIF that delimits it. An
identifier is given a value with the SET compiler directive.
The semantics of conditional compilation closely parallel those of the IF
statement. If the expression evaluates to true, the text between the $IF
and the next ENDIF or next ELSE is compiled. If the expression evaluates
to false, that text is treated as a comment.
IF directives can be nested to 16 levels. If a user nests further than
16 levels, an error message is issued and the code within the illegal $IF
block is not compiled.
There can be, at most, one ELSE corresponding to each IF.
The identifiers in SET and IF compiler directives are in no way related
to FORTRAN variables in the source text. That is, if the same variable
name is used both as an identifier for one of these directives and
elsewhere within a program, the one has no effect upon the other.
Examples
$SET (DEBUG=.TRUE.,TOGGLE=.FALSE.)
$SET (SYSTEM1=.TRUE.)
.
.
.
$IF (DEBUG .AND. TOGGLE)
$IF (SYSTEM1)
$IF (.NOT. (DEBUG .AND. TOGGLE))
$IF (.TRUE.)
.
.
.
$ELSE
.
.
.
$ENDIF
$ENDIF
$ENDIF
$ENDIF
$IF (SYSTEM1 .OR. TOGGLE)
.
.
.
$ENDIF
.
.
.
MPE/iX 5.0 Documentation