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

OpenMP, reduction clause and access violation?

j0e
New Contributor I
555 Views

Hi all,

Can anyone explain while the following code causes a general access violoation (exception code c0000005) when run in parallel (/Qopenmp is specified):

Program

main

implicit none

integer na

real(8) obj

real(8), allocatable:: a(:)

na = 100

allocate( a(na) )

call sub1 (na, a, obj)

deallocate ( a )

stop

end

program main

subroutine

sub1(na, a, obj)

implicit none

integer na

real(8) a(na), obj

integer i, icnt

a = 0.0

obj = 0.0

icnt = 0

!$omp parallel do &

!$omp private (obj) &

!$omp firstprivate (a) lastprivate (a) &

!$omp reduction (+:icnt)

do i=1,4

a(1:na) =

real(i)

obj =

sum(a(1:na))

icnt = icnt + 1

write(6,*) i,': ', obj

end do

!$omp end parallel do

write(6,*) 'icnt = ', icnt

return

end subroutine

sub1

If I remove the reduction clause, then the code does not cause the access violation, and runs correctly.

I'm using the latest version of IVF and running on Vista x64. Also, if i statically allocate arrary a in the

main program, program runs fine.

thanks

-joe

0 Kudos
0 Replies
Reply