The arithmetic IF statement conditionally transfers control to one of three statements, based on the value of an arithmetic expression. It is an obsolescent feature in Fortran 95 and Fortran 90.

The arithmetic IF statement takes the following form:

- 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 THETA is less than or equal to the real variable CHI. Control passes to statement 100 only if THETA is greater than CHI.

```
IF (THETA-CHI) 50,50,100
```

The following example transfers control to statement 40 if the value of the integer variable NUMBER is even. It transfers control to statement 20 if the value is odd.

```
IF (NUMBER / 2*2 - NUMBER) 20,40,20
```

**For More Information:**

For details on obsolescent features in Fortran 95 and Fortran 90, see Appendix A.

Previous Page Next Page Table of Contents