Dmitri,<br><br>Perfect! Thanks so much for the response. Your guess about the barrier was exactly correct. The problem has disappeared.<br><br>I was ignorant about the proper way to specify shared variables. Thanks for the correction. Is the following use of reduction acceptable?<br>
<br> !$OMP PARALLEL <br> !$OMP& PRIVATE(i,j)<br> !$OMP& SHARED(Ny,Nx,dv,v,boundary))<br> !<br> !$OMP DO <br>...<br>...<br> !$OMP END DO<br><br> max_dv = 0.d0<br> !$OMP BARRIER<br><br> !$OMP DO <br>
!$OMP& REDUCTION(MAX:max_dv)<br> do j=2,(Ny-1)<br> do i=2,(Nx-1)<br> v(i,j) = v(i,j) + dv(i,j)<br> if(dabs(dv(i,j)) .gt. max_dv) then<br> max_dv = dv(i,j)<br> endif<br>
end do<br> end do<br> !$OMP END DO<br><br><br><div class="gmail_quote">On Thu, Nov 27, 2008 at 4:07 AM, Dmitri Chubarov <span dir="ltr"><<a href="mailto:dmitri.chubarov@gmail.com">dmitri.chubarov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Nathan, hello,<br><br>I gave your code a second look and noticed this:<br><br><div class="gmail_quote">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote"> !$OMP PARALLEL </div></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote">
<br> !$OMP DO </div></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote">....<div class="Ih2E3d"><br>
!$OMP END DO<br>
<br> max_dv = 0.d0<br> !$OMP DO <br></div></div></blockquote><div> ....</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote">
!$OMP END DO<br> !$OMP END PARALLEL<br><br></div></blockquote><div> </div></div>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.<br>
<br>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.<br><br>Finally<div class="Ih2E3d"><br> if(dv(i,j) .gt. max_dv) then<br>
max_dv = dv(i,j)<br> endif<br></div>Does not look right since it would not handle negative values of dv(i,j) correctly. I assume it should read<br>as <br> max_dv = max(max_dv, dabs(dv(i,j) ))<br>
<br>Best regards,<br> Dmitri Chubarov<br><font color="#888888"><br>--<br>Junior Researcher<br>Siberian Branch of the Russian Academy of Sciences<br>Institute of Computational Technologies<br><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>- - - - - - - - - - - - - - - - - - - - - <br>Nathan Moore<br>Assistant Professor, Physics<br>Winona State University<br>AIM: nmoorewsu <br>- - - - - - - - - - - - - - - - - - - - -<br>