AND operator

AND operator

Hello

I have a Fortran code with extensive use of .AND. It has been used with the assumption that the second condition is evaluated only if the first condition is true. For e.g.

L= 0

IF (L !=0 .AND. ARRAY(L) > 1.0) THEN
DO SOMETHING
ENDIF

The code executes without problems when compiled with Compaq Visual Fortran compiler but not with Intel Fortran 8.0. Does the Intel compiler not always evaluate the first condition before the second?

Thanks,
Bhanu

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The Fortran language allows compilers to evaluate this or any equivalent expressionin any order it sees fit, as long as parentheses are obeyed. You just got lucky before - your code is incorrect.

Use nested IF-THEN instead.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today