Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Order of evaluation within expressions

chris-sn
初学者
600 次查看
Converting a CVF project I am finding expressions like:

(I.EQ.0 .OR. ARRAY(I).NE.J)

Which now errors (at least in debug build) when I = 0 (it used to work with CVF either because evaluation ceased after the first clause, or because it didn't detect the array boundary condition)

I appreciate the code is badly written and needs changing, but as it is a runtime problem it's hard to tell if all the instances have been found. I don't suppose there's any compile switch to force evaluation order? Any other suggestions to check they have all been found?
0 项奖励
4 回复数
rase
新分销商 I
600 次查看
Have a look at the thread in this forum at http://software.intel.com/en-us/forums/showthread.php?t=70058&o=a&s=lr. There are several interesting contributions to the topic.
0 项奖励
TimP
名誉分销商 III
600 次查看
It's not discussed prominently in that reference, although mentioned several times on this forum, that CVF did not always follow a left-to-right evaluation when the standard permits it. f2c did so, provided that a strict standard C compiler was in use, and so did HPUX Fortran. Those have been superseded as common models.
I sympathize with the idea that the writers of CVF were next to God, and whatever works there should continue working, but unfortunately, non-standard assumptions are likely to break sooner rather than later.
0 项奖励
chris-sn
初学者
600 次查看
Thanks guys, so be it. Apols I clearly didn't research previous posts well enough!
0 项奖励
Steven_L_Intel1
600 次查看
As one of those CVF developers, I find it amusing when people insist that CVF did left-to-right evaluation with short-circuiting, as it certainly did not, witness the many complaints we got with CVF about that. I wrote a "Doctor Fortran" item in 1999 about it...

The standard allows a compiler to evaluate any logically equivalent expression, in any order, to any degree of completeness it chooses. In CVF and IVF, this is largely up to the optimizer and the results can vary depending on the program.
0 项奖励
回复