[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::fortran

Title:Digital Fortran
Notice:Read notes 1.* for important information
Moderator:QUARK::LIONEL
Created:Thu Jun 01 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1333
Total number of notes:6734

1166.0. "multiple DATA initializations of a COMMON block " by RDGENG::WOOD_J ([email protected]) Fri Feb 07 1997 05:55

A software vendor is porting his Fortran code from OpenVMS to Digital UNIX.
He has encountered a problem on Digital UNIX due to his code having multiple
COMMON block DATA initialization statements. That is, he has an include-file
which not only declares a common-block but which also contains data
initializations; and this fie is included by many subroutines.

All is well if he compiles all of his sources as one compilation unit
(-presumably the compiler is smart enough to detect the multiple
initializations). However, if compiled as two or more separate compilation
units with each containing data initializations for the same common-block, 
then when linking it fails with a severe warning due to multiple definitions
of the common-block. This was not the case on OpenVMS (-nor apparently on
Windows NT).

From the "DEC Fortran User Manual for DEC OSF/1 AXP Systems"


    A.2.1.4  DEC Fortran Restrictions

    The following DEC Fortran language restrictions do not apply
    to DEC Fortran for OpenVMS VAX systems:

    �   Only one program unit can initialize COMMON with
        DATA statements.


Is Fortran on OpenVMS's support of multiple initializations of a common-block 
a language extension? (Potentially the multiple initializations could set
different values, and thus it would be ambiguous as to which value should
be used, hence I wouldn't expect the Fortran standard to endorse this).

Reading old notes on this problem (e.g. DEC_FORTRAN #109, DEC_FORTRAN_ALPHA
#865), it seems that Fortran on ULTRIX had the same problem/limitation. The
problem is solveable on OpenVMS due to the way the VMS linker works; and
conversely the problem cannot be addressed on ULTRIX because of the way ld
works.

I guess the Digital UNIX linker has the same restriction as ULTRIX,
hence the solution for the software vendor is either:
 a) compile all sources together as one compilation unit, or
 b) edit source code so that only one compilation unit initializes the data


Thanks,
  John Wood
  Software Partner Engineering
T.RTitleUserPersonal
Name
DateLines
1166.1TLE::EKLUNDAlways smiling on the inside!Fri Feb 07 1997 09:2412
    	Your analysis of the situation is 100% accurate.  The restrictions
    on initializing COMMON blocks are quite severe.  The Fortran Standard
    requires that the initializing data statements "must not be ... in a
    named common block unless the DATA statement is in a block data program
    unit".  We try to be considerably more liberal when the linker allows
    us this latitude.  You have already identified the two main ways to
    get the customer back to a working state (and to make their program
    more standard conforming).
    
    Cheers!
    Dave Eklund