FORTRAN 77 Language Reference

ELSE

The ELSE statement indicates the beginning of an ELSE block.

IF (e) THEN

...

ELSE

...

END IF

where e is a logical expression.

Description

Execution of an ELSE statement has no effect on the program.

An ELSE block consists of all the executable statements following the ELSE statements, up to but not including the next END IF statement at the same IF level as the ELSE statement. See "IF (Block)" for more information.

An ELSE block can be empty.

Restrictions

You cannot jump into an ELSE block from outside the ELSE block.

The statement label, if any, of an ELSE statement cannot be referenced by any statement.

A matching END IF statement of the same IF level as the ELSE must appear before any ELSE IF or ELSE statement at the same IF level.

Examples

Example 1: ELSE:


       CHARACTER S 
       ... 
       IF ( S .GE. '0' .AND. S .LE. '9' ) THEN 
              CALL PUSH 
       ELSE 
              CALL TOLOWER 
       END IF 
       ... 

Example 2: An invalid ELSE IF where an END IF is expected:


       IF ( K .GT. 5 ) THEN 
              N = 1 
       ELSE 
              N = 0 
       ELSE IF ( K .EQ. 5 ) THEN 	           Incorrect 
       ...