- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
링크가 복사됨
4 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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.