- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to recompile an oldmulti module Fortran programme, which have a common block included in all modules. These previously compiled well in VAX Fortran environment as well as recently in MS Developer Studio Fortran PowerStation 4.0 environment. In the latter, it gives warnings about multiply defined symbols. However, I am not being able to invoke the same switch (which comes as default in MS Fortran PowerStation) for Intel Fortran environment.
Can something be done other than trying to separate out the multiply defined symbols in the common block?
BSG
I am trying to recompile an oldmulti module Fortran programme, which have a common block included in all modules. These previously compiled well in VAX Fortran environment as well as recently in MS Developer Studio Fortran PowerStation 4.0 environment. In the latter, it gives warnings about multiply defined symbols. However, I am not being able to invoke the same switch (which comes as default in MS Fortran PowerStation) for Intel Fortran environment.
Can something be done other than trying to separate out the multiply defined symbols in the common block?
BSG
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please show an example of the multiply defined symbols in the common block. Variable names in a common block in F77 code are not put into the compiled object; only the name of the common block is.
For example, with prg.f containing
and sub.f containing
there is no problem. A dump of the two .OBJ files shows "D _XYZ" for prg.obj and "C _XYZ" for sub.obj.
If, however, the DATA statement in sub.f is activated, there is a duplicate initialization of the common block; the dumps of the two .OBJ files both show "D _XYZ" and the linker rightly complains
but its use except in an example such as this may be compared to shooting oneself in the foot.
You must use this migration task as an opportunity to fix this bug in the code. Your code is in violation of the Fortran-77 standard. Attempting to replicate the quirks of an old compiler/OS combination on a new platform is not advised.
For example, with prg.f containing
[fortran]
program tst
double precision A, B, C
common /xyz/A, B, C
data A,B,C/1d0,2d0,3d0/
call sub()
end[/fortran]
and sub.f containing
[fortran]
subroutine sub
double precision A,B,C,D
common /xyz/A,B,C,D
! data A/4.5d0/
write(*,*)A,B,C,D
return
end
[/fortran]
there is no problem. A dump of the two .OBJ files shows "D _XYZ" for prg.obj and "C _XYZ" for sub.obj.
If, however, the DATA statement in sub.f is activated, there is a duplicate initialization of the common block; the dumps of the two .OBJ files both show "D _XYZ" and the linker rightly complains
[bash]sub.obj : error LNK2005: _XYZ already defined in prg.objThere is a linker option /FORCE:multiple, which changes the linker messages to
prg.exe : fatal error LNK1169: one or more multiply defined symbols found
[/bash]
[bash]sub.obj : warning LNK4006: _XYZ already defined in prg.obj; second definition ignored
prg.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
[/bash]
but its use except in an example such as this may be compared to shooting oneself in the foot.
You must use this migration task as an opportunity to fix this bug in the code. Your code is in violation of the Fortran-77 standard. Attempting to replicate the quirks of an old compiler/OS combination on a new platform is not advised.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks......undefining the data initialisation in the sub modules did the trick. Just as a curiosity asking about the second piece of solution you had given - can you get the linker option through the property page gui or do you have to explicity add it on:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to explicitly add it on ... it's too easy to abuse to make it too simple to set.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page