Hi all,

I have a loop that is parallelizable. When I use openmp directives, keeping all the variables private but the result, I obtain the same results that if I run without the OpenMP flag. However, when I change the to the !$acc pragma, keeping the same variables private, the results are completly different. How is that possible?

Here is the parallelizable loop using both architectures,

!$omp parallel

!$omp do private(Vbond,Vangle,r1x,r2x), &

!$omp private(r1y,r2y,r1z,r2z), &

!$omp private(r,a,r_1,r_2,th,costh,i)

do 101 i=1,resids

Vbond=0.0D0

Vangle=0.0D0

Vdieh=0.0D0

r1x=(r_n(i,1)-r_ca(i,1))

r1y=(r_n(i,2)-r_ca(i,2))

r1z=(r_n(i,3)-r_ca(i,3))

r=(r1x**2+r1y**2+r1z**2)**0.50D0

r_1=r

Vbond=Vbond+0.50D0*kbond*(r-ro_nca)**2

r2x=(r_c(i,1)-r_ca(i,1))

r2y=(r_c(i,2)-r_ca(i,2))

r2z=(r_c(i,3)-r_ca(i,3))

r=(r2x**2+r2y**2+r2z**2)**0.50D0

r_2=r

Vbond=Vbond+0.50D0*kbond*(r-ro_cac)**2

a=r1x*r2x+r1y*r2y+r1z*r2z
costh=a/(r_1*r_2)

th=acos(costh)

Vangle=Vangle+0.50D0

*kangle*(th-tho_ncac)**2

!$omp critical

E(i)=Vangle+Vbond

!$omp end critical

101 continue

!$omp end do

!$omp end parallel

!$acc region do copyin(r_n,r_ca,r_c), copy(E), &

!$acc private(Vbond,Vangle,r1x,r2x,r1y,r2y,r1z,r2z), &

!$acc private(r,a,r_1,r_2,th,costh,i)

do 101 i=1,resids

Vbond=0.0D0

Vangle=0.0D0

Vdieh=0.0D0

rx=(r_n(i,1)-r_ca(i,1))

ry=(r_n(i,2)-r_ca(i,2))

rz=(r_n(i,3)-r_ca(i,3))

r1x=rx

r1y=ry

r1z=rz

r=(rx**2+ry**2+rz**2)**0.50D0

r_1=r

Vbond=Vbond+0.50D0*kbond*(r-ro_nca)**2

rx=(r_c(i,1)-r_ca(i,1))

ry=(r_c(i,2)-r_ca(i,2))

rz=(r_c(i,3)-r_ca(i,3))

r2x=rx

r2y=ry

r2z=rz

r=(rx**2+ry**2+rz**2)**0.50D0

r_2=r

Vbond=Vbond+0.50D0*kbond*(r-ro_cac)**2

a=r1x*r2x+r1y*r2y+r1z*r2z
costh=a/(r_1*r_2)

th=acos(costh)

Vangle=Vangle+0.50D0

*kangle*(th-tho_ncac)**2

E(i)=Vangle+Vbond

101 continue