FORTRAN Reference Manual

Statements
FORTRAN Reference Manual528615-001
7-57
Assigned GO TO
statement and a GO TO statement that uses the label stored by the ASSIGN
statement:
ASSIGN 10 to j
.
IF (x .GT. 0) THEN
ASSIGN 20 to j
END IF
GO TO j,(10,20)
.
10 CONTINUE
.
20 CONTINUE
The program branches to 20 if X is greater than 0 and to 10 if X is less than or equal to
0.
Considerations
FORTRAN ensures that all labels referenced in the assigned GO TO statement are in
the current program unit and are associated with executable statements. At run time,
however, FORTRAN does not check that the label to which your program branches is
in the list of labels. FORTRAN transfers control to the statement whose label was
specified in the last ASSIGN statement executed before the GO TO statement,
regardless of whether that label is in the list of labels for the current assigned GO TO
statement.
Examples
The following example shows an unconditional GO TO:
IF (x .GT. y) GO TO 30
.
30 difference = x - y