Intel fortran-80 manual Assigned GO to Statement, Arithmetic if Statement

Models: fortran-80

1 130
Download 130 pages 742 b
Page 42
Image 42

Program Execution Controls

FORTRAN-SO

Examples:

GO TO (1010,1020,1030) K

CIF K = 2, FOR EXAMPLE, CONTROL PASSES TO STATEMENT C 1020

INTEGER*1 SWITCH SWITCH = K/J

GO TO (10,500,500,10,10) SWITCH

C NOTE THAT 'J'MUST BE .LE. 'K'IN THIS EXAMPLE GO TO (10, 500, 600, 500) K * L + 1

4.1.3Assigned GO TO Statement

The assigned GO TO statement is used with the ASSIGN statement. The assigned GO TO is similar to the computed GO TO, but in this case the control is an integer variable name. Before the assigned GO TO is executed, the variable name must be defined with the value of a statement label by an ASSIGN statement in the same pro- gram unit.

The format of the assigned GO TO statement is

GO TO name n,] (stl [,stl] ...)]

where

name is an integer variable name

stl is the statement label of an executable statement III the same program unit as the assigned GO TO.

The same statement label may appear more than once in the statement. If the paren-. thesized list of statement labels is present, the statement label assigned to 'name' must be one of the labels in the list.

Examples:

ASSIGN 10TO START

GOTOSTART

ASSIGN 999 TO DONE

GO TO DON E (500, 600, 999)

4.1.4Arithmetic IF Statement

The arithmetic IF statement behaves similarly to a computed GO TO. Control is transferred to one of three possible statements based on the value of a controlling expression. The format of the arithmetic IF is

IF(exp)s1,s2,s3

where

exp is an integer or real expression

sis the statement label of an executable statement in the same program unit as the arithmetic IF.

The same statement label may appear more than once in the statement.

If the value of 'exp' is less than zero, control passes to the first statement listed; if it equals zero, control passes to the second statement; if 'exp' is greater than zero, con- trol passes to the third statement.

4-2

Page 42
Image 42
Intel fortran-80 manual Assigned GO to Statement, Arithmetic if Statement, Assign 10TO Start Gotostart Assign 999 to Done