Now I do not see any problem in the first loop (maybe I'm losing something).
However, the second loop has several issues:
1) As before, race conditions on x and ek
2) Looking for restrictions on reduction variables, I found in the OpenMP spec.
"A list item that appears in a reduction clause must be a named variable of
intrinsic type."
And I have an actual Fortran 90 question: I was looking for "Fortran
90 intrinsic type" and I found in wikipedia:
"Fortran has five intrinsic data types: INTEGER, REAL, COMPLEX,
LOGICAL and CHARACTER."
since I do not usually give for granted wikipedia content/s I would
like people in this forum confirm if this is part of the Fortran 90
standard. Assuming those are the intrinsic types, an array of
intrinsic type would be also an intrinsic type? Or maybe there is not
such a definition in the Fortran standard...
To the OP: what compiler are you using? Does the compiler report
something specifically on "reduction(+, a)"?
Anyway, I would try changing the OpenMP directive in the second loop to
> !omp parallel do private(j, x, ek)
Fernando.
2011/12/22 Cyber Joy <[log in to unmask]>:
> Sorry, there are some spelling mistakes.
> All bad spelling have been checkd .
>
>
> ! oiginal serial codes
> !-------------------------------------------------
> ..................
> call sub(n,dk,ffk,,xi,a)
> ..................
> subroutine sub(n,dk,ffk,xi,a)
> ...
> complex(kind=8) :: a(n,n)
> dk(n),ffk(n),xi(n) computed
> complex(kind=8),external :: func
> ...
> do j=1,n
> x=xi(j)
> do k=1,n
> y=xi(k)
> a(j,k)=func1(x+y)*ffk(j)*ffk(k)*dk(k)
> end do
>
> end do
> do j=1,n
> x=xi(j)
> ek=x**2
> a(j,j)=ek+func(x)+a(j,j)
> end do
> end subroutine sub
> ! ------------------------------------------------
> my parallel codes are
> !------------------------------------------------
> subroutine sub(n,dk,ffk,xi,a)
> ...
> complex(kind=8) :: a(n,n)
> dk(n),ffk(n),xi(n) computed
> complex(kind=8),external :: func
> ...
> !omp parallel do private(k,x,y)
> do i=1,n
> x=xi(i)
> do k=1,n
> y=xi(k)
> a(j,k)=func1(x+y)*ffk(j)*ffk(k)*dk(k)
> end do
> end do
> !omp parallel do 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
> !------------------------------------------------
>
>
>
> ----- Original Message -----
> From: Fernando G. Tinetti
> To: COMP-FORTRAN-90
> Date: 2011-12-22, 20:37:12
> Subject: Re: loop nests in openmp
>
> I reply myself just to fix my own error: as pointed out by Tim Prince,
> having k declared as private in the first loop, varaialbe k is undefined in
> the loop. Maybe declaring it as shared would "solve" the problem (it is not
> assigned a value inside the loop)?
>
> Fernando.
>
|