Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Order of evaluation within expressions

chris-sn
Beginner
604 Views
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 Kudos
4 Replies
rase
New Contributor I
604 Views
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 Kudos
TimP
Honored Contributor III
604 Views
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 Kudos
chris-sn
Beginner
604 Views
Thanks guys, so be it. Apols I clearly didn't research previous posts well enough!
0 Kudos
Steven_L_Intel1
Employee
604 Views
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 Kudos
Reply