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

Migrating to Intel Fortran 9 from CVF

rtorrens
Beginner
403 Views

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

0 Kudos
2 Replies
TimP
Honored Contributor III
403 Views

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
0 Kudos
Steven_L_Intel1
Employee
403 Views
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.
0 Kudos
Reply