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

Problem with ifort 2017 and 2018

juillet__olivier
Beginner
401 Views

Dear colleague,

I am encountering a problem with the IFORT 2018 compiler when I run the attached program (that has been extracted from a much more sophisticated project). The array named Kinetic is incorrectly filled. The bug is fixed if I simply add write(*,*) px,py before the calculation of Kinetic(k) in the loop. This is not the case with the 2016 version of the compiler and I absolutely not understand what has become wrong. Such behavior has been highlighted on Mac OS 10.13 and Linux platforms. 

Many thanks for your help. Sincerely, O. Juillet. 

 

 
0 Kudos
2 Replies
Juergen_R_R
Valued Contributor I
401 Views

The newer ifort (v17, 18 , 19) is too aggressively optimizing expressions away from your do loop. If you compile with -O0 or -O1 you get the expected result. Default is -O2. If I rewrite your do loop in a way that expressions only depending on the outer increment are calculated outside of the inner do loop, then also ifort 17, 18, 19 get it correct with default optimization:

DO kx=0,Dx-1
   IF (kx<=ZDBx_Max) THEN
      lx=kx
   ELSE
      lx=kx-Dx
   END IF
   px=2.0_8*Pi*lx/Dx   
   DO ky=0,Dy-1              
      IF (ky<=ZDBy_Max) THEN
         ly=ky
      ELSE
         ly=ky-Dy
      END IF
      py=2.0_8*Pi*ly/Dy
      ! print *, "k = ", k
      Kinetic(Dy*kx+ky+1)=-2.0_8*(tx*COS(px)+ty*COS(py))-4.0_8*t_Prime*COS(px)*COS(py)
        
   END DO
END DO

 

0 Kudos
Xiaoping_D_Intel
Employee
401 Views

Hi Julliet,

This issue is better to be reported via our Online Service Center at https://supporttickets.intel.com/  for further investigation. 

Instructions on how to file a ticket are available here: 

https://software.intel.com/en-us/articles/how-to-create-a-support-request-at-online-service-center  

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos
Reply