If-Then-Else
There are a variety of control constructs available in Fortran. The most essential ones are the if-then-else construct and the loop construct (do
). An if-then-else construct looks like this:
If the logical expression evaluates to .true.
, then the associated code block is executed. If not, the next else if
statement is evaluated, or the else
branch is executed. The else if
and the else
parts of the construct are optional.
The logical expression may use these symbols:
Synbol | Logical expression |
---|---|
== |
equal |
/= |
not equal |
< , <= |
less than, less than or equal |
> , >= |
greater than, greater than or equal |
.not. |
negation |
.and. |
logical and |
.or. |
logical or |
() |
parentheses for ordering |