Intel fortran-80 manual ELSE Statement, END IF Statement

Models: fortran-80

1 130
Download 130 pages 742 b
Page 45
Image 45
4.1.9 ELSE Statement

FORTRAN-80

Program Execution Controls

If 'exp' is TRUE, normal execution continues with the first statement of the ELSE IF block. If 'exp' is FALSE, control passes to the next ELSE IF, ELSE, or END IF statement having the same level as the ELSE IF statement.

Control cannot 'be transferred into an ELSE IF block from outside the block (but see section F.2.9.3). The statement label, if any, of the ELSE IF statement cannot be referenced by another statement.

If the last statement in the ELSE IF block does not pass control to another ex- ecutable statement, control passes to the next END IF statement having the same nesting level as the ELSE IF statement.

An example is shown following the description of the END IF statement.

4.1.9 ELSE Statement

Executing the ELSE statement has no effect; execution simply continues. Its format is

ELSE

The ELSE block is terminated by an END IF statement of the same level as the ELSE statement. This END IF statement must appear before the appearance of an ELSE IF or another ELSE statement of the same nesting level.

Control cannot be transferred into an ELSE block from outside the block (but see section F.2.9.3). The statement label, if any, of the ELSE statement cannot be referenced by another statement.

An example is shown following the description of the END IF statement.

4.1.10 END IF Statement

Executing the END IF statement has no effect; normal execution continues. The END IF statement acts as a terminator for IF, ELSE IF, and ELSE blocks. Each block IF statement must have a corresponding END IF statement, that is, an END IF statement of the same nesting level as the block IF statement.

The format of the END IF statement is

ENDIF

Example:

IF (FLAG .EO. 3) THEN

WRITE (6,20) NAME(3), PAY(3)

20FORMAT ...

ELSE IF (FLAG .EO. 2) THEN WRITE (6,40) FEDTAX

40FORMAT ...

ELSE

WRITE(6,60) FICA

60FORMAT ...

ENDIF

4-5

Page 45
Image 45
Intel fortran-80 manual ELSE Statement, END IF Statement