- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to compile old source code withIVF.The oldsourcewas written taking advantage of lazy evaluation.
for example inthe following code:
IVAL = 0
IF ( IVAL .GT. 0 .AND. IFUNCTION(ARGS) .GT. 0)THEN
.
.
.
ENDIF
the IFUNCTION was never evaluated since IVAL is not greater than 0. Therefore, there was not need to continue evaluation after the .AND.
Using IVF, the IFUNCTION is allways evaluated, even when IVAL is greater than zero. How can I force IVF to use lazy evaluation, to avoid the evaluation of IFUNCTION when IVAL is not greater than zero?
Thanks for your help!
for example inthe following code:
IVAL = 0
IF ( IVAL .GT. 0 .AND. IFUNCTION(ARGS) .GT. 0)THEN
.
.
.
ENDIF
the IFUNCTION was never evaluated since IVAL is not greater than 0. Therefore, there was not need to continue evaluation after the .AND.
Using IVF, the IFUNCTION is allways evaluated, even when IVAL is greater than zero. How can I force IVF to use lazy evaluation, to avoid the evaluation of IFUNCTION when IVAL is not greater than zero?
Thanks for your help!
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should use
IF ( IVAL .GT. 0) then
if (IFUNCTION(ARGS) .GT. 0)THEN
because IVF allways evaluate whole logical expression.
Jakub
IF ( IVAL .GT. 0) then
if (IFUNCTION(ARGS) .GT. 0)THEN
because IVF allways evaluate whole logical expression.
Jakub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You shouldn't expect short-circuit evaluation in a Fortran IF statement. If it worked with other compilers, then it was a feature (or a bug?) in those compilers.
In general, keep in mind that the compiler is free to optimize the code you provide in whatever way it likes ---and that includes removing statements, optimizing variables away, changing the order of evaluation, etc.
See this old thread for a much better explanation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
:( it seems that I am going to have to spend several days looking for those IF statements.
Thanks for your help!!!
Thanks for your help!!!

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