Dmitri, Perfect! Thanks so much for the response. Your guess about the barrier was exactly correct. The problem has disappeared.
I was ignorant about the proper way to specify shared variables. Thanks for the correction. Is the following use of reduction acceptable? !$OMP PARALLEL !$OMP& PRIVATE(i,j) !$OMP& SHARED(Ny,Nx,dv,v,boundary)) ! !$OMP DO ... ... !$OMP END DO max_dv = 0.d0 !$OMP BARRIER !$OMP DO !$OMP& REDUCTION(MAX:max_dv) do j=2,(Ny-1) do i=2,(Nx-1) v(i,j) = v(i,j) + dv(i,j) if(dabs(dv(i,j)) .gt. max_dv) then max_dv = dv(i,j) endif end do end do !$OMP END DO On Thu, Nov 27, 2008 at 4:07 AM, Dmitri Chubarov <[EMAIL PROTECTED]>wrote: > Nathan, hello, > > I gave your code a second look and noticed this: > > !$OMP PARALLEL >> > >> !$OMP DO >> > .... >> !$OMP END DO >> >> max_dv = 0.d0 >> !$OMP DO >> > .... > >> !$OMP END DO >> !$OMP END PARALLEL >> >> > There is a BARRIER missing between max_dv = 0.d0 and the following loop. > One of the threads in the pool might've been late and get to this statement > when the rest have already completed the reduction loop. > > The barrier is also important to ensure that no thread would use the values > of dv(i,j) in the reduction loop before they are updated by the main > computational loop above. > > Finally > if(dv(i,j) .gt. max_dv) then > max_dv = dv(i,j) > endif > Does not look right since it would not handle negative values of dv(i,j) > correctly. I assume it should read > as > max_dv = max(max_dv, dabs(dv(i,j) )) > > Best regards, > Dmitri Chubarov > > -- > Junior Researcher > Siberian Branch of the Russian Academy of Sciences > Institute of Computational Technologies > > -- - - - - - - - - - - - - - - - - - - - - - Nathan Moore Assistant Professor, Physics Winona State University AIM: nmoorewsu - - - - - - - - - - - - - - - - - - - - -
_______________________________________________ Beowulf mailing list, Beowulf@beowulf.org To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf