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

Check just first condition in if statement if false?

Andreas_G_
Beginner
289 Views

Hello, and thanks in advance for the help

I am porting some code from Linux and am purturbed that the following, which worked with the Portland Group Compiler for the case when L=0, does not work now:

      IF(L .GT. 200 .AND. AERO(L) .GT. 2.0) THEN                       
           CALL ....................
      ENDIF

In IVF, I must apparently to do this, otherwise it complains about AERO(0):

      IF(L .GT. 200 ) THEN
         IF( AERO(L) .GT. 2.0) THEN
           CALL ....................
         ENDIF
      ENDIF

Does IVF always check all conditions in an IF, even when the first one fails? I’m going to have to do a lot of rework if true. Someone in the office suggested turning off subscript error checking, but I still want to able able to trap other instances of subscript out of bounds. Is there a flag to make IVF stop checking when it finds a false IF condition?

Thanks
Andy

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
289 Views

It is a language requirement that Fortran to be able to check in any order and check all logical (sub) expressions. Sorry, you will have to use the THEN. I advise against relying on turning off subscript checking. That will trip you up at times (bogus index producing SIGSEV for invalid memory access).

Jim Dempsey

0 Kudos
Andreas_G_
Beginner
289 Views

Thank you Jim

I may have preferred a different answer, but now I have it. In any case, I'll have more robust code.

Thanks!
Andy

0 Kudos
Reply