ITEM: E2731L
FORTRAN language problem
Question:
I am running AIX V3.2.4 PMP. We are using the FORTRAN compiler that
came on the PMP tape. I am doing some work utilizing the block data
function. The manual is unclear about how the block data function
works in certain cases and I would like someone to help me clear up
some questions.
The questions I have are related to the use of Fortran "block
data" statements. The Fortran language reference and users guide
from IBM are not specific on the following topics:
I have in the same directory many programs, subroutines and block
datas.
1. For example, block data A has been written to initialize common
block X in program AA. Block data B has been written to initialize
common block Y in program BB. Since a block data is not a callable
function, how does the linker know that block data B and common block Y
belongs to program BB? Is common block Y added to program AA?
2. Block data A and block data B initialize the same common block,
say X. However, the initialization done through block data A is for use
by program AA, while the initialization done through block data B
is for use by program BB. How does the linker know which block data is
used for each program?
3. Is there a need to add the block data procedure in the same file
as the main program, or is it possible to have them in two
different Fortran (Unix) files and generate independent object files for
use by the linker?
Response:
The answers to your questions are as follows:
1. The linker knows that block data A corresponds to named common
block X and block data B corresponds to named common Y because
of the use of named commons. It matches up the name of the
common in the block data subprogram with the FORTRAN program
that references the named common.
2. This scenario is illegal. The same named common block must not
be referenced in two different block data subprograms. If the
same named common is referenced in two separate block data
subprograms the first subprogram is used for data initialization.
3. It is possible to have the block data subprograms in different
files and then link the appropriate block data subprogram file to
the FORTRAN program that references the named common.
You also indicated that you had the block data subprograms in different
files and that you were compiling them to object modules and keeping
them in a library. This will work fine unless you have two block data
subprograms that reference the same named common block (this will result
in the use of the first subprogram for the named common block as
described above). As a workaround, you could put the subprograms that
reference the same named common in different libraries and then link to
the appropriate library, OR you could use the FORTRAN INCLUDE statement
in the program to include the .f file that contains the appropriate
block data subprogram. For example, you could use
include 'blocka.f'
in program AA and
include 'blockb.f'
in program BB where blocka.f contains block data subprogram A and
blockb.f contains block data subprogram B.
Support Line: FORTRAN language problem ITEM: E2731L
Dated: October 1993 Category: N/A
This HTML file was generated 99/06/24~13:30:54
Comments or suggestions?
Contact us