Lahey/Fujitsu Fortran

Assigned GOTO Statement (obsolescent)


The assigned GOTO statement causes a transfer of control to the branch target statement indicated by a variable that was assigned a statement label in an ASSIGN statement. If the parenthesized list of labels is present, the variable must be one of the labels in the list.


GOTO assign-variable [[,] (labels)]


assign-variable is a scalar INTEGER variable that was assigned a label in an ASSIGN statement.
labels is a comma-separated list of statement labels.


At the time of execution of the GOTO statement, assign-variable must be defined with the value of a label of a branch target statement in the same scoping unit.

The assigned GOTO statement is a construct created in the early days of Fortran, and was suitable for the tiny programs which the machines of that era were able to execute. As hardware got better and programs grew larger, the assigned GOTO statement was identified as a major contributor to a logic snarled condition known as "spaghetti code", which made a program difficult to read and debug. The assigned GOTO statement may be replaced by the CASE Construct or the IF Construct. Although the assigned GOTO statement is obsolescent and should never be used when writing new code, it is fully supported.


assign 10 to i goto i 20 assign 30 to i goto i 10 write(*,*) " assigned goto construct" assign 20 to i goto i, (10,20,30) 30 continue

See Also

CASE Construct

IF Construct