Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

different "IF" lazy evalation in Windows and Linux

$
0
0

Hello  

Theres is a legacy code  we  have to compile in Linux and Windows. 

in Linux we have  ifort 15 and in Windows  ifort 11,  and the project is rather  big, so code modification will be the last option

our Problem  is in the following IF, for example:

INTEGER VECTOR(10)
DO I=1,10
    IF ( I .LT.10 .AND.  VECTOR(I+1) .GT. 0) THEN
!        do something
    END IF
ENDDO

The classic  IF Lazy Evaluation : If the first condition is false, in Linux , the rest  will be not evaluated , therefore, VECTOR(11) will be not evaluated. In Windows, however,  the same code produces the expected out of bound error:  forrtl: severe Subcript #1 of Array VECTOR has value 11

I am not aware of the details , I think we had another Compiler in Windows, which didn't have this behavior, and the  code was developed that way.

Of course this works everywhere

INTEGER VECTOR(10)
DO I=1,10
    IF ( I .LT.10 ) THEN
        IF (VECTOR(I+1) .GT. 0) THEN
!          do something
        ENDIF
    END IF
ENDDO

Unfortunately, our  IF's are a bit more complex than that, and we have to  much code  to edit . Is there a  flag we can use in compile time to force the same behavior in Windows as in Linux?

Thanks 


Viewing all articles
Browse latest Browse all 2746

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>