ASSIGN
Purpose
The ASSIGN statement assigns a statement label to an integer variable.
Syntax
- stmt_label
- specifies the statement label of an executable statement or a FORMAT statement in the scoping unit containing the ASSIGN statement
- variable_name
- is the name of a scalar INTEGER(4) or INTEGER(8) variable
Rules
A statement containing the designated statement label must appear in the same scoping unit as the ASSIGN statement.
- If the statement containing the statement label is an executable statement, you can use the label name in an assigned GO TO statement that is in the same scoping unit.
- If the statement containing the statement label is a FORMAT statement, you can use the label name as the format specifier in a READ, WRITE, or PRINT statement that is in the same scoping unit.
You can redefine an integer variable defined with a statement label value with the same or different statement label value or an integer value. However, you must define the variable with a statement label value before you reference it in an assigned GO TO statement or as a format identifier in an input/output statement.
The value of variable_name is not the integer constant represented by the label itself, and you cannot use it as such.
The ASSIGN statement has been deleted from Fortran 95 and higher.Examples
ASSIGN 30 TO LABEL
NUM = 40
GO TO LABEL
NUM = 50 ! This statement is not executed
30 ASSIGN 1000 TO IFMT
PRINT IFMT, NUM ! IFMT is the format specifier
1000 FORMAT(1X,I4)
END
