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

Optional and present

rahzan
Novice
221 Views
I had assumed that for an optional logical dummy argument one can do this:

if(present(dummyLogicalArg) .and. dummyLogicalArg)then

But if the dummyLogicalArg is in fact missing then I get an access violation about the second operand. Am I missing something or do I need a certain level of optimization so that if the first operand fails the second part of an AND need not get evaluated.

Tim
0 Kudos
1 Reply
Steven_L_Intel1
Employee
221 Views
Fortran does not have "short circuit evaluation" for logical expressions. You need to protect the second subexpression in an IF-THEN. You can't rely on a particular order of evaluation - the compiler is free to evaluate both sides of the .and. and to do so in any order that is logically equivalent.

Steve
0 Kudos
Reply