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 |
©
|
Cornell University
|
Center for Advanced Computing
|
Copyright Statement
|
Access Statement
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)