- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Steve
![](/skins/images/8B6E2C8F64F54CBD7F7262AA46F575DA/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page