Intel® Fortran Compiler 17.0 Developer Guide and Reference
Statement: Conditionally transfers control to one of three statements, based on the value of an arithmetic expression. It is an obsolescent language feature in Standard Fortran.
IF (expr) label1,label2,label3
expr |
Is a scalar numeric expression of type integer or real (enclosed in parentheses). |
label1, label2, label3 |
Are the labels of valid branch target statements that are in the same scoping unit as the arithmetic IF statement. |
All three labels are required, but they do not need to refer to three different statements. The same label can appear more than once in the same arithmetic IF statement.
During execution, the expression is evaluated first. Depending on the value of the expression, control is then transferred as follows:
If the Value of expr is: |
Control Transfers To: |
---|---|
Less than 0 |
Statement label1 |
Equal to 0 |
Statement label2 |
Greater than 0 |
Statement label3 |
The following example transfers control to statement 50 if the real variable THETAis less than or equal to the real variable CHI. Control passes to statement 100 only if THETAis greater than CHI.
IF (THETA-CHI) 50,50,100
The following example transfers control to statement 40 if the value of the integer variable NUMBERis even. It transfers control to statement 20 if the value is odd.
IF (NUMBER / 2*2 - NUMBER) 20,40,20
The following statement transfers control to statement 10 for n < 10, to statement 20 for n = 10, and to statement 30 for n > 10:
IF (n-10) 10, 20, 30
The following statement transfers control to statement 10 if n <= 10, and to statement 30 for n > 10:
IF (n-10) 10, 10, 30