Dmitri,<br><br>Perfect!&nbsp; Thanks so much for the response.&nbsp; Your guess about the barrier was exactly correct.&nbsp; The problem has disappeared.<br><br>I was ignorant about the proper way to specify shared variables.&nbsp; Thanks for the correction.&nbsp; Is the following use of reduction acceptable?<br>
<br>&nbsp;&nbsp; !$OMP PARALLEL <br>&nbsp;&nbsp;&nbsp; !$OMP&amp; PRIVATE(i,j)<br>&nbsp;&nbsp;&nbsp; !$OMP&amp; SHARED(Ny,Nx,dv,v,boundary))<br>&nbsp;&nbsp;&nbsp; !<br>&nbsp;&nbsp;&nbsp; !$OMP DO <br>...<br>...<br>&nbsp;&nbsp;&nbsp; !$OMP END DO<br><br>&nbsp;&nbsp;&nbsp; max_dv = 0.d0<br>&nbsp;&nbsp;&nbsp; !$OMP BARRIER<br><br>&nbsp;&nbsp;&nbsp; !$OMP DO <br>
&nbsp;&nbsp;&nbsp; !$OMP&amp; REDUCTION(MAX:max_dv)<br>&nbsp;&nbsp;&nbsp; do j=2,(Ny-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do i=2,(Nx-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v(i,j) = v(i,j) + dv(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(dabs(dv(i,j)) .gt. max_dv) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_dv = dv(i,j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endif<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end do<br>&nbsp;&nbsp;&nbsp; end do<br>&nbsp;&nbsp;&nbsp; !$OMP END DO<br><br><br><div class="gmail_quote">On Thu, Nov 27, 2008 at 4:07 AM, Dmitri Chubarov <span dir="ltr">&lt;<a href="mailto:dmitri.chubarov@gmail.com">dmitri.chubarov@gmail.com</a>&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP END DO<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_dv = 0.d0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP DO <br></div></div></blockquote><div>&nbsp;....</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">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP END DO<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !$OMP END PARALLEL<br><br></div></blockquote><div>&nbsp;</div></div>There is a BARRIER missing between max_dv = 0.d0 and the following loop. One of the threads in the pool might&#39;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>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(dv(i,j) .gt. max_dv) then<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; max_dv = dv(i,j)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_dv = max(max_dv, dabs(dv(i,j) ))<br>

<br>Best regards,<br>&nbsp; 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>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - - <br>Nathan Moore<br>Assistant Professor, Physics<br>Winona State University<br>AIM: nmoorewsu <br>- - - - - - - &nbsp; - - - - - - - &nbsp; - - - - - - -<br>

<br />-- 
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.