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
Nuevo Colaborador I
1.003 Vistas
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 Responder
Steven_L_Intel1
Empleados
1.003 Vistas
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
Responder