- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Neither compiler deliberately short-circuts. You get whatever the optimizer feels like doing at the time.
I am aware that the IVF Building Applications manual section on CVF compatibility says that CVF did short-circuiting - it is wrong. I verified this today with the engineer who worked on this part of the compiler.
You need to fix your code. It's broken. See this article I wrote in 1999 for more details.
Sorry if this sounds blunt, but I don't know of a better way to put it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thanks for your reply. If CVF and IVF don't behave the way I described them, why hasn't Intel fixed the documentation. We just bought compiler licenses, and the documentation clearly indicates that CVF and IVF behave the way I described them. It can be very confusing for someone migrating from one environment to the other.
Manny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If nothing else, this documentation error might alert users to look for this kind of bug in their code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
The IVF 9.0 documentation that I'm referring to comes from the section describing Compatibility with Compact Visual Fortran, and it reads as follows:
Expressions in an IF statement containing clauses joined by a logical AND are handled differently in Intel Visual Fortran 8.x and later versions than in Compaq Visual Fortran. CVF evaluated the first clause, and if it was false, did not evaluate the remaining clauses. Intel Visual Fortran first evaluates all clauses and then performs the logical AND. Since the Fortran standard neither requires nor forbids short-circuiting of logical expressions, both behaviors are correct.
If there's something wrong with the above Intel interpretation of both CVF and IVF, I really would appreciate if you could clarify it (how shouldthe statement aboveread?).
Thanks for your help,
Manny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your first post I believe you say that it might be possible to get different results if the IF conditions are evaluated differently in CVF and IVF. For example:
IF (A .and. B .and. C .and. D) then
ENDIF
I do not see howit ispossible to get different results in the restof the codewhether A,B,C and D are *all* evaluated before the testor if the test fails on A and therefor B,C, and D are not evaluated (short circuit). UNLESS there are "side effects". that is if any of B,C,D are functions say,which change the values of variables in common blocks or modules used elsewhere.
Have I understood correctly?
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The text you cite is the text that is wrong in that it should not say that CVF stops evaluating if the "first clause" is false. This entire paragraph should be deleted and I have asked for it to be removed, as this is not a difference between the compilers.
The usual case where this coding error bites you is if you write something like:
if (j > 0 .and. array(j) > 5)
People who write this, often C programmers where the C language DOES specify left to right and short-circuit evaluation, assume that if J is less than or equal to zero that the array(j) reference won't occur. They are then surprised by array bounds errors or other odd behavior.
The correct way to code this in Fortran is as a series of nested IF-THEN clauses. Yes, it's awkward, but them's the language rules. There have been proposals for AND_THEN and OR_ELSE operators but they never got very far in the standards committee.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the clarification.
Manny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page