Just two comments:
1) I'm inclined to explicitly define at least all private variables, even when there are defaults for loop control variables (this is just because I always forget/misunderstand OpenMP rules).
2) I think the second DO definitely has race conditions on x and ek.
Thus I would try
!omp parallel do private(i, j, k, x, y)
do i=1,n
x=xi(i)
do j=1,n
y=xi(n)
a(j,k)=func1(x+y)*ffk(j)*ffk(n)*dk(k)
end do
end do
!omp parallel do private(i, x, ek) reduction(+:a)
do j=1,n
x=xi(j)
ek=x**2
a(j,j)=ek+func(x)+a(j,j)
end do
end subroutine sub
|