FORTRAN and ar problem (solved)

list at decus.com.au list at decus.com.au
Sat Aug 18 00:57:12 AEST 1990


	Following is a summary of the replies to this problem.



1) -----------------------------------------------------
a sort-of-kludgy way around this is to CALL the block data routines.
then the linker will properly drag them into the executable.

at least it works under RSX and VMS linkers...

    MAIN FOO
    if (something .false.) CALL ONE    ! so it never REALLY gets called,
                            ! but sneaky enough so an optimizer won't
                            ! completely delete the CALL
    ...
    END
    BLOCK DATA ONE
    blah blah
    END

2) --------------------------------------------------------------------

This is a common problem with BLOCK DATA.  Whenever an archive is used
individual modules are linked in only when there is a reference from some
other module.  For BLOCK DATA subprograms there is never a reference, so
they are never linked in from an archive.  There is no true solution to
this problem, but there are two possible solutions that may or may not
work:

a)	In every module referring to some COMMON block write a reference
	to the BLOCK DATA subprogram initializing the COMMON block:
		EXTERNAL BLKDAT0
	etc.
	This will link in the BLOCK DATA subprogram on some systems (but
	not on others).

b)	If there is for each COMMON block a major subroutine that is always
	used when the COMMON block is used you can compile that subroutine
	and the BLOCK DATA subprogram as a single file.
	The remark under 1 applies also here, but this works on all
	Unix systems as far as I know.

3) ----------------------------------------------------------------------

as fas as i know you have to have an EXTERNAL <NAME> statement for
each block-data routine to force the linker to load it, e.g. if there
is no reference to a block-data-routine the linker does not load it.


4) ----------------------------------------------------------------------
 
Yes, this is a known problem with the compiler.  It has been fixed in a
later release.
 

Conclusion ---------------------------------------------------------

I have declared all BLOCK DATA <names> as EXTERNALS in my main program.
That seems to work ok. As to this being a known problem, I've contacted
DEC support and they have yet not found a reason for this problem (nor
a work around).

Thanks to all who helped trying to solve this

Leo List
SIR(Australasia)



More information about the Comp.unix.ultrix mailing list