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

Strange behavior with OpenMP

shiming_chen
Beginner
856 Views
Here is a strange behavior when I compile my code with OpenMP.
My code is:
-------------------
PROGRAM test02
IMPLICIT NONE
INTEGER,PARAMETER ::n1=1, n2=100
REAL :: a(n1-1:n2+1)
INTEGER :: i

DO i = n1, n2
a(i) = 2+i
END DO

CALL sub02(a,n1,n2)

END PROGRAM
-----------------------
SUBROUTINE sub02(a,n1,n2)
IMPLICIT NONE
INTEGER :: n1,n2
REAL :: a(n1-1:n2+1)
INTEGER :: i

DO i = n1, n2
WRITE(*,*) i, a(i)
END DO
WRITE(*,*) "------"
!$OMP PARALLEL DO
DO i = n1, n2
WRITE(*,*) i, a(i)
END DO
END SUBROUTINE
-------------------------

When compiling with "ifort -fpp -openmp", the value of a(i) out of the parallel region is 2+i (that is, a(1) = 3, a(2) = 4,...). But the value of a(i) in the parallel region is 3+i (that is, a(1) = 4, a(2) = 5,...). The values out of parallel region are not consistent with that in the parallel region.

If I compile with "ifort -fpp -openmp -check bounds", they are the same.

The code can work well on the Alpha workstation with Compaq's compiler, without any bounds checking. I turned check bounds on with my actually working code, and it cost so much time and resources to build the code (even the message "Optimization suppressed due to excessive resource requirements; contact Intel Premier Support" occurred).

How can I do with this behavior?

System: RedHat Enterprise Linux 3 for ia64
Compiler: l_fc_pc_8.1.019

Shi-ming Chen
0 Kudos
1 Reply
TimP
Honored Contributor III
856 Views
Shi-Ming,

Unfortunately, that compiler update has a bad reputation. If a problem persists in the next update, due out shortly, please file an issue on premier.intel.com.
0 Kudos
Reply