- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi:
I tried to initialize a variable in block data, twice, like:
block data
common /test/ x
data x/0.5/
data x/0.6/
end
the result is x=0.5.
can I change some settings to let it initialize more than twice?
Thank you
I tried to initialize a variable in block data, twice, like:
block data
common /test/ x
data x/0.5/
data x/0.6/
end
the result is x=0.5.
can I change some settings to let it initialize more than twice?
Thank you
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
More than twice? It's invalid Fortran to do it more than once. The compiler will complain if you turn on standards checking. If you do this, you get the first value and the second is ignored. You can try a third and the same thing will happen.
I very strongly recommend against your depending on this behavior. It's going to bite you later.
I very strongly recommend against your depending on this behavior. It's going to bite you later.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this happened when I use intel compiler to compile an old code which is developed in 1980's. in the code, an array is initialized in block data, and some variables are set to be EQUIVALENCE with the elements of the array. then the variables are initialized again. like:
COMMON/XFLOAT/A(500)
DATA A/500*55555.0/
EQUIVALENCE (A( 1), PHI )
EQUIVALENCE (A( 2), THET )
EQUIVALENCE (A( 3), PSI ) ......
DATA PHI/0.0/, THET/0.0/, PSI/0.0/
.....
the original code is huge. under CVF, the A(1),A(2),A(3) are initialized with 0 but IVF initialize them as 55555.0.
I can delete DATA A/500*55555.0/ to achieve the same results as CVF, but there might be some other thing different cause not all the elements of A are initialized as zero.
COMMON/XFLOAT/A(500)
DATA A/500*55555.0/
EQUIVALENCE (A( 1), PHI )
EQUIVALENCE (A( 2), THET )
EQUIVALENCE (A( 3), PSI ) ......
DATA PHI/0.0/, THET/0.0/, PSI/0.0/
.....
the original code is huge. under CVF, the A(1),A(2),A(3) are initialized with 0 but IVF initialize them as 55555.0.
I can delete DATA A/500*55555.0/ to achieve the same results as CVF, but there might be some other thing different cause not all the elements of A are initialized as zero.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to your code all the elements of A should be 55555.0. My reading of this is that CVF is in error, not IVF.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code is not legal Fortran and the results are unpredictable. I suggest compiling with standards checking on to see where the compiler complains about multiple definition and then do whatever is needed to correct the code.
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