FORTRAN 77 Language Reference

ASSIGN

The ASSIGN statement assigns a statement label to a variable.

ASSIGN s TO i

Parameter 

Description 

s

Statement label  

i

Integer variable 

Description

The label s is the label of an executable statement or a FORMAT statement.

The statement label must be the label of a statement that is defined in the same program unit as the ASSIGN statement.

The integer variable i, once assigned a statement label, can be reassigned the same statement label, a different label, or an integer. It can not be declared INTEGER*2.

After assigning a statement label to a variable, you can reference it in:

Restrictions

The variable must be assigned a statement label before referencing it as a label in an assigned GO TO statement, or as a format identifier.

While i is assigned a statement label value, do no arithmetic with i.

On 64-bit platforms, the actual value stored in variable i by the ASSIGN statement is not available to the program, except by the assigned GO TO statement, or as a format identifier in an I/O statement. Also, only variables set by an ASSIGN statement can be used in an assigned GO TO or as a format identifier.

Examples

Example 1: Assign the statement number of an executable statement:


       IF(LB.EQ.0) ASSIGN 9 TO K 
       ... 
       GO TO K 
       ... 
9      AKX = 0.0

Example 2: Assign the statement number of a format statement:


       INTEGER PHORMAT 
2      FORMAT ( A80 ) 
       ASSIGN 2 TO PHORMAT 
       ... 
       WRITE ( *, PHORMAT ) 'Assigned a FORMAT statement no.'