* Fortran Block Data statements not recognized in libraries
@ 1994-08-04 15:12 Chuck Henkel
1994-08-04 16:55 ` James Tappin
1994-08-05 14:09 ` Dennis Murphy
0 siblings, 2 replies; 5+ messages in thread
From: Chuck Henkel @ 1994-08-04 15:12 UTC (permalink / raw)
Context: DEC AXP 3000 model 300
OSF/1 v 2.0
DEC Fortran v3.4
Problem: When I bundle my block data routines into a library, the
initializations are not performed. Outside of a library,
things appear to work, but I'm not crazy about the prospect
of having to restructure my makefiles.
The release notes contain the following statement:
o The following changes were made to the decfort compiler
since DFAO V3.3:
[...]
- Make named block data in library work.
What am I missing? Is it generally advisable to avoid using
libraries and just string out all the .o's on the link line?
Illustration:
c=== main.f
common /waa/ foo
real foo
write (*,*) 'before sub, foo=',foo
call sub
write (*,*) 'after sub, foo=',foo
end
c=== sub.f
subroutine sub
common /waa/ foo
real foo
foo = 2.0
end
c=== bd.f
block data bd
common /waa/ foo
real foo
data foo / 1.0 /
end
==== WORKS ====
% f77 -o waa main.f sub.f bd.f
% ./waa
before sub, foo= 1.000000
after sub, foo= 2.000000
==== WORKS ====
==== FAILS ====
% f77 -c main.f
% f77 -c sub.f
% f77 -c bd.f
% ar rv waa.a sub.o bd.o
% f77 -o waa main.o waa.a
% ./waa
before sub, foo= 0.0000000E+00
after sub, foo= 2.000000
==== FAILS ====
--
Chuck Henkel
NCSU Nuclear Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fortran Block Data statements not recognized in libraries
1994-08-04 15:12 Fortran Block Data statements not recognized in libraries Chuck Henkel
@ 1994-08-04 16:55 ` James Tappin
1994-08-05 7:53 ` David L Terrett
1994-08-05 14:09 ` Dennis Murphy
1 sibling, 1 reply; 5+ messages in thread
From: James Tappin @ 1994-08-04 16:55 UTC (permalink / raw)
Chuck Henkel (csh@eos.ncsu.edu) wrote:
: Context: DEC AXP 3000 model 300
: OSF/1 v 2.0
: DEC Fortran v3.4
: Problem: When I bundle my block data routines into a library, the
: initializations are not performed. Outside of a library,
: things appear to work, but I'm not crazy about the prospect
: of having to restructure my makefiles.
: The release notes contain the following statement:
: o The following changes were made to the decfort compiler
: since DFAO V3.3:
: [...]
: - Make named block data in library work.
: What am I missing? Is it generally advisable to avoid using
: libraries and just string out all the .o's on the link line?
[illustrations deleted]
: Chuck Henkel
: NCSU Nuclear Engineering
This is a fundamental problem in fortran (not just OSF), because a BLOCK
DATA is never explicitly accessed it won't be picked up from the library
unless there is a way of forcing a given member to be linked in. I'm
afraid it's long enough since I did any serious fortran that I've never
checked to see if there is a linker option to do that.
--
James Tappin, School of Physics & Space Research
University of Birmingham
sjt@xun8.sr.bham.ac.uk
"If all else fails--read the instructions!"
O__
-- \/`
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fortran Block Data statements not recognized in libraries
1994-08-04 16:55 ` James Tappin
@ 1994-08-05 7:53 ` David L Terrett
0 siblings, 0 replies; 5+ messages in thread
From: David L Terrett @ 1994-08-05 7:53 UTC (permalink / raw)
In article <31r6hf$4e6@sun4.bham.ac.uk>, sjt@xun8.sr.bham.ac.uk (James Tappin)
writes:
|>
|>This is a fundamental problem in fortran (not just OSF), because a BLOCK
|>DATA is never explicitly accessed it won't be picked up from the library
|>unless there is a way of forcing a given member to be linked in. I'm
|>afraid it's long enough since I did any serious fortran that I've never
|>checked to see if there is a linker option to do that.
--
On most systems (including OSF/1) you can get a block data subprogram to be
loaded from a library by declaring the name of the subprogram as EXTERNAL
in some subroutine that is being loaded.
This behaviour isn't specified by the FORTRAN standard but I haven't yet
encountered a system on which it doesn't work (apart from the field test
version of OSF/1!).
===============================================================
David Terrett Rutherford Appleton Laboratory
Chilton, Dicot
D.Terrett@rl.ac.uk Oxfordshire
+44-235-446478 OX11 0QX
United Kingdom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fortran Block Data statements not recognized in libraries
1994-08-04 15:12 Fortran Block Data statements not recognized in libraries Chuck Henkel
1994-08-04 16:55 ` James Tappin
@ 1994-08-05 14:09 ` Dennis Murphy
1994-08-08 18:00 ` Dave Eklund
1 sibling, 1 reply; 5+ messages in thread
From: Dennis Murphy @ 1994-08-05 14:09 UTC (permalink / raw)
Chuck, if you modify your program as follows:
gemosf.zko.dec.com> more main.f
common /waa/ foo
external bd
real foo
write (*,*) 'before sub, foo=',foo
call sub
write (*,*) 'after sub, foo=',foo
end
gemosf.zko.dec.com>
gemosf.zko.dec.com> f77 -c main.f
gemosf.zko.dec.com> f77 -o waa main.o waa.a
gemosf.zko.dec.com> waa
before sub, foo= 1.000000
after sub, foo= 2.000000
gemosf.zko.dec.com>
everything works correctly.
The problem you encounter is that the linker doesnt pull the common waa
out of the block dat bd contribution. I'll let the Fortran Gurus explain
why.
Hope this helps
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fortran Block Data statements not recognized in libraries
1994-08-05 14:09 ` Dennis Murphy
@ 1994-08-08 18:00 ` Dave Eklund
0 siblings, 0 replies; 5+ messages in thread
From: Dave Eklund @ 1994-08-08 18:00 UTC (permalink / raw)
Consider that a library might contain more than one possible
block data initialization subprogram - initializing the SAME
common block to different values... There is no way to select
which block data subprogram to load, EXCEPT by specifying the
name in an external statement. This is the reason that none
of the block data initialization routines are selected unless
there is an external reference to resolve from the main routine,
the name of the particular block data routine desired!
Dave Eklund
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1994-08-08 18:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-08-04 15:12 Fortran Block Data statements not recognized in libraries Chuck Henkel
1994-08-04 16:55 ` James Tappin
1994-08-05 7:53 ` David L Terrett
1994-08-05 14:09 ` Dennis Murphy
1994-08-08 18:00 ` Dave Eklund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox