Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
13 Views

parallel programming using OPENMP

 

Hi ifort develiper and users,

I have written a fortran code(where four loops are present) in openMP. Here i share the openMP code, where the second loop is parallelized.

first: do i=1,NMAX,1
xmsd_1(i) = 0.0
!$omp parallel default(none) &
!$omp shared (NTMAX,nmol,i,com_xu,P_1,xmsd_1) &
!$omp private(k,m,dx,xmsd,pr_1)
!$omp do reduction(+:xmsd_1)
second: do j=1,NTMAX,1
third : do k =1,nmol,1

pr_1 = 1
fourth : do m=jframe,jframe+iframe,1
        pr_1 = pr_1 * P_1(m,k)
end do fourth

if(pr_1 .eq. 1) then
dx = com_xu(k,j+i) - com_xu(k,j)
xmsd = dx*dx
xmsd_1(i) = xmsd_1(i) + xmsd * pr_1
end if

end do third
end do second
!$omp end do 

!$omp end parallel

print*, i,xmsd(i)

end do first

My openMP code(where second loop was parallelized) results do not match the serial code results.  could you please suggest a solution to this problem?

 

0 Kudos
1 Reply
Highlighted
Black Belt
13 Views

Reduction clause doesn't appear appropriate in that position. You have 2 reductions which are local to inner loops which might be eligible for simd reductions but may not require explicit reduction clause.
0 Kudos