Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646

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
Black Belt
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.