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

AND operator

bhanu
Beginner
395 Views
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
0 Kudos
1 Reply
Steven_L_Intel1
Employee
395 Views
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.
0 Kudos
Reply