FORTRAN Reference Manual

Mixed-Language Programming
FORTRAN Reference Manual528615-001
13-6
Using Global Data in Mixed Language Programming
Using Global Data in Mixed Language Programming
FORTRAN does not have global data in the same sense as some other programming
languages such as C, Pascal, and TAL. Instead, FORTRAN programs share data by
placing specific data items in common blocks and declaring those common blocks in
each program unit that uses them.
FORTRAN follows the standard HP convention by adding a character at the beginning
of the name of each COMMON block when it creates the corresponding data block in
the object file. FORTRAN adds a period (.) if the block is in the user data segment, or a
dollar sign ($) if the block is in the extended data segment. Blank common is called
.BLANK^ if it is in the user data segment, $BLANK^ if it is in the extended data
segment.
FORTRAN does not create a pointer block in the global primary data area for each
COMMON data block. Instead, FORTRAN creates one “special” data block named
COMMON#POINTERS in the global primary data area, which contains pointers to
variables in all blocks in the user data segment. The contents of
COMMON#POINTERS can be affected by the EXTENDCOMMON compiler directive.
For more information, see Section 10, Compiler Directives. FORTRAN creates a
pointer in each program unit’s local data area to each variable in the extended memory
segment that is referenced in that program unit.
For example, if a FORTRAN source program declares:
? LARGECOMMON big
COMMON /big/ a (100, 100), b (100, 100)
COMMON /small/ c (10, 10), d, e
the FORTRAN object file contains:
Common data block “$BIG” in the extended data segment
Common data block “.SMALL” in the user data segment
Special data block “COMMON#POINTERS” allocated in the primary data area and
containing pointers to the variables your program references in data block
“.SMALL”.
If a TAL source program declares:
BLOCK big;
REAL .EXT a [1:10000], .EXT b [1:10000];
END BLOCK;
BLOCK small;
REAL .c [1: 100], .d [0: 0], .e [0: 0];
END BLOCK;