- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I frequently use "include" to insert a COMMON block into my code. The purpose is to make everything consistent, in case there are changes. However, I have come across something that kept me scratching my head for several days.
Subroutine sub1( argument list)
include "comn1.com"
print *,loc(array)
end subroutine !sub1
Subroutine sub2( argument list)
include "comn1.com"
print *,loc(array)
end subroutine !sub2
The array ARRAY is contained in the COMMON block COMN1. Now you would think that both PRINT statements would give the same address. I made sure that the array "array" was not duplicated in either argument list. However, upon printing out the results, the addresses were different by over a thousand bytes.
Can anyone think of a set of conditions that would cause this? One thing pertaining to this: where should the COMMON blocks be placed in the project, along with the code, in header files, or in resource files? Is it proper to give them the extension .COM or should I call them something else, i.e. .F90 or .HDR, etc? They are just treated as text files regardless, is that correct?
Perhaps going along with some standard way of doing this may make the problem go away. It appears that the linker is thoroughly confused by the way I am doing it.
Subroutine sub1( argument list)
include "comn1.com"
print *,loc(array)
end subroutine !sub1
Subroutine sub2( argument list)
include "comn1.com"
print *,loc(array)
end subroutine !sub2
The array ARRAY is contained in the COMMON block COMN1. Now you would think that both PRINT statements would give the same address. I made sure that the array "array" was not duplicated in either argument list. However, upon printing out the results, the addresses were different by over a thousand bytes.
Can anyone think of a set of conditions that would cause this? One thing pertaining to this: where should the COMMON blocks be placed in the project, along with the code, in header files, or in resource files? Is it proper to give them the extension .COM or should I call them something else, i.e. .F90 or .HDR, etc? They are just treated as text files regardless, is that correct?
Perhaps going along with some standard way of doing this may make the problem go away. It appears that the linker is thoroughly confused by the way I am doing it.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Different IMPLICITs in scoping units?
Is array the first element of COMN1? If not, try printing out LOCs of the previous elements and see where they start to differ.
Just a guess,
Jugoslav
Is array the first element of COMN1? If not, try printing out LOCs of the previous elements and see where they start to differ.
Just a guess,
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have a short compilable example? Are the routines in the same or separate files, how are you initializing the common, etc.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As far as I can tell, the difference in the LOCs is biger than the entire common block. Also all variables in the Common block are explicitly typed, and all routines have an IMPLICIT INTEGER*2(A_Z) in the header.
Unfortunately, when I try to reduce the program, the problem goes away.
Where should I put the COMMON blocks anyway? I think the linker is doing something weird to me.
Unfortunately, when I try to reduce the program, the problem goes away.
Where should I put the COMMON blocks anyway? I think the linker is doing something weird to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One more stupid suggestion (but the problem is so weird that I bet that the cause is stupid): Are perhaps source files in different directories and there are two (different) copies of include file? (I remember banging my head with that one once).
Re include files: you can give them any extension you like but don't use .f90, .for or .f. CVF IDE recognizes .fd and .fi as fixed-form includes (which gives you syntax coloring) and .i90 as free-form (hmmm, does this one still work?), but that's only matter of convenience.
I think it's time to send the copy of your project to vf-support@compaq.com ... and please satisfy our curiosity as well once you find the answer.
Jugoslav
Re include files: you can give them any extension you like but don't use .f90, .for or .f. CVF IDE recognizes .fd and .fi as fixed-form includes (which gives you syntax coloring) and .i90 as free-form (hmmm, does this one still work?), but that's only matter of convenience.
I think it's time to send the copy of your project to vf-support@compaq.com ... and please satisfy our curiosity as well once you find the answer.
Jugoslav
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