- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My code compiles, links and runs - so I'm defintely winning the battle. However, as expected, there are a few compiler gotchaswhich are hindering my progress.
Given the following code:
integer :: x
integer, dimension(1:10) :: a
x=0
if ( x /= 0 .and. a(x) /= 0 ) then
....
endif
Under CVF, the second item in the if statement will not be evaluated in the event that x = 0 - so avoidinganout boundserror.
However,under Intel fortran9.1 - the second item is evaluate if x = 0 - andI get an exception.
Is there a setting I can useto get the compilerto force abreakif the first logical statement is false?
Thanks in advance
Richard
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could check previous posts on this forum. As I recall, they are unanimous in asserting that CVF had no protection against this non-standard practice, which could be counted on only with the old f2c translator. The advice always has been to correct the source code:
if ( x /= 0)then
if( a(x) /= 0 ) then
....
endif
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tim is correct - CVF did not do "short-circuit evaluation", which is what you are looking for. We certainly heard from many customers who thought it should, though the Fortran standard allows "any equivalent expression" to be evaluated. Tim also offers the correct solution.

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