Storage Allocation in FORTRAN

Storage Allocation in FORTRAN

  • FORTRAN (Formula translation) was designed to permit static storage allocation. However, there are some issues, such as the treatment of COMMON and EQUIVALENCE declarations, that are fairly special to Fortran.
  • A Fortran compiler can create a number of data areas, i-e., blocks of storage in which the values of objects can be stored.
  • There is one data area for each procedure and one data area for each named COMMON block and for blank COMMON, if used.
  • The symbol table must record for each name the data area in which it belongs and its offset in that data area, that is, its position relative to the beginning of the area.
  • The compiler must eventually decide where the data areas go relative to the executable code and to one another, but this choice is arbitrary, since the data areas are independent.


  • A record is created for each block with the first and last names of the current procedure, that is declared to be in that COMMON block.
    • A declaration is: COMMON / BLOCK1 / NAMEl, NAME2
  • The compiler must do the following:
    • In the table for COMMON block names, create a record for BLOCK1, if one does not already exist.
    • In the symbol-table entries for NAME1 and NAME2, set a pointer to the symbol-table entry for BLOCK1, indicating that these are in COMMON and members of BLOCK1.
      • If the record has just now been created for BLOCK1. set a pointer in that record to the symbol-table entry for NAME1, indicating the first name in this COMMON block. Then, link the symbol-table entry for NAME1 to that for NAME2, using a field of the symbol table reserved for linking members of the same COMMON block. Finally, set a pointer in the record for BLOCK1 to the symbol-table entry for NAME2, indicating the last found member of that block.
      • If, however, this is not the first declaration of BLOCK1, simply link NAME1 and NAME2 to the end of the list of names for BLOCK1. The pointer to the end of the list for BLOCK1, appearing in the record for BLOCK1.
  • After a procedure has been processed, we call the equivalence algorithm. A bit in the symbol-table entry for XYZ is set, indicating that XYZ has been equivalenced to something.
  • Create a memory map for each COMMON block by scanning the list of names for that block.


  • The first algorithms for processing equivalence statements appeared in assemblers rather than compilers. Since these algorithms can be a bit complex, especially when interactions between COMMON and EQUIVALENCE statements are considered, let us treat first a situation typical of an assembly language, where the only EQUIVALENCE statements are of the form
    • EQUIVALENCE A, B+offset
  • Where A and B are the names of locations. This statement makes A denote the location that is offset memory units beyond the location for B. A sequence of EQUIVALENCE statements groups names into equivalence sets whose positions relative to one another are all defined by the EQUIVALENCE statements,
    • EQUIVALENCE A, B+100

Related Searches to Storage Allocation in FORTRAN