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

Is there a way get the compiler to evaluate if's intelligently?

ferrad
New User
352 Views
The specific issue I have at the moment is statements like:
if(i .gt. 0 .and. array(i) .gt. 10.0) then ...
if the first bit is false, it doesn't need to evaulate the second bit, in fact it must not, as it will fail with full checking on.
Adrian
0 Kudos
1 Reply
Steven_L_Intel1
Employee
352 Views
The Fortran language does not have short-circuit evaluation nor does it specify order of evaluation for logical operands. The compiler chooses order based on optimization criteria (register pressure, etc.)

What you should do is use IF-THEN to nest the conditions the way you want. Then you will not be subject to the whim of the compiler and your code will be more portable.
0 Kudos
Reply