CHAPTER 4 PROGRAM EXECUTION CONTROLS

FORTRAN includes 16 statements, or statement variations, for controlling program execution. These are statements that transfer control (GO TO, IF, and their varia- tions), regulate execution loops (DO, CONTINUE), and terminate program execu- tion (PAUSE, STOP, END).

4.1 Transferring Program Oontrol

The statements in this group pass control to another part of the program, in some cases only when a stated condition is meL These alternatives are usually referred to as conditional and unconditional branching. Some statements also allow an alter- native set of operations to be performed if.the stated conditions are not met.

The statements that transfer program control are:

 

Unconditional GO TO

Block IF

Computed GO TO

ELSE IF

Assigned GO TO

ELSE

Arithmetic IF

END IF

Logical IF

 

4.1.1 Unconditional GO TO Statement

The unconditional GO TO statement transfers control to the next statement to be ex- ecuted. It has the format

GO TO stl

where 'stl' is the statement label of an executable statement in the same program unit as the GO TO statement.

Example:

GO TO 1010

4.1.2 Computed GO TO Statement

The computed GO TO based on the value of GOTO is

statement branches to one of several executable statements a controlling integer expression. The format of the computed

GO TO (stl [,stl] ...)[,]exp

where

exp is an integer expression

stlis the statement label of an executable statement in the same program unit as the computed GO TO.

The same statement label may appear more than once in the statement. If the integer expression has a value in the range 1::5 exp::5 n (where 'n' is the number of statement labels in the list), control passes to the statement pointed to by 'exp.' If 'exp' is out- side this range, execution continues with the statement following the GO TO.

4-1

Page 41
Image 41
Intel fortran-80 manual Program Execution Controls, Transferring Program Oontrol, Unconditional GO to Statement