You are right! I just didn't read all the way to the end of your email. Sorry about that.<br>So here is a little more code that does it correctly:<br><br> PetscInt, pointer :: ltog(:)<br><br> call DAGetGlobalIndicesF90(da,nloc,ltog,ierr); CHKERRQ(ierr)<br>
<br> do kk=zs,zs+zm-1<br> do jj=ys,ys+ym-1<br> do ii=xs,xs+xm-1<br><br> row=ii-gxs + (jj-gys)*gxm + (kk-gzs)*gxm*gym<br> grow=ltog(3*row + 1)<br><br>[all your code here]<br><br> call MatSetValues(A,i1,grow,ic,col,v,INSERT_VALUES,<br>
. ierr); CHKERRQ(ierr)<br><br>[more code here]<br><br> call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr); CHKERRQ(ierr)<br> call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr); CHKERRQ(ierr)<br><br><br>
<br>Hope this is a little more helpful. As Jed points out, there are other ways to do the same<br>thing (and probably more efficiently than what I've outlined here).<br><br>Randy M.<br><br><br><div class="gmail_quote">
On Tue, Apr 19, 2011 at 12:00 AM, ilyas ilyas <span dir="ltr"><<a href="mailto:ilyascfd@gmail.com">ilyascfd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>Hi Randy,<br></div><div><br></div><div>Thank you for your answer.</div><div><br></div><div>I have already done it. You can see it in my first e-mail.</div><div><br></div><div>It does not work properly for all number of processors.</div>
<div>For certain number of processors, it works correctly,</div><div>not for all number of processors.</div><div>For example, for 1,2,or 3 processors, it's ok. </div><div>For 4 processors, it gives wrong location, so on.</div>
<div>"Problem" occurs in 3rd dimension ( (kk-gzs)*gxm*gym )</div>
<div><br></div><div>Here is another suggestion (I have not tried yet) ;</div><div><br></div><div><div class="im"> do kk=zs,zs+zm-1<br> do jj=ys,ys+ym-1<br> do ii=xs,xs+xm-1<br><br></div> row=ii-gxs + (jj-gys)*MX + (kk-gzs)*MX*MY</div>
<div><br></div><div>MX,MY,MZ are global dimensions.This is also what I do serially</div><div><br></div><div>Do you think that it is correct or any other suggestions?</div><div><br></div><div>Regards,<br></div><font color="#888888"><div>
Ilyas.</div></font><div><div></div><div class="h5">
<div><br></div><div class="gmail_quote">2011/4/18 Randall Mackie <span dir="ltr"><<a href="mailto:rlmackie862@gmail.com" target="_blank">rlmackie862@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Here's how I do it:<br><br> do kk=zs,zs+zm-1<br> do jj=ys,ys+ym-1<br> do ii=xs,xs+xm-1<br>
<br>
row=ii-gxs + (jj-gys)*gxm + (kk-gzs)*gxm*gym<br><br><br>Good luck,<br><br>Randy M.<div><div><br><br>
<br><div class="gmail_quote">On Mon, Apr 18, 2011 at 6:54 AM, ilyas ilyas <span dir="ltr"><<a href="mailto:ilyascfd@gmail.com" target="_blank">ilyascfd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>Hi, <br></div><div>Thank you for your suggestion. I will take it into account.</div><div>Since changing this structure in my "massive" code may take too much time,</div><div>I would like to know that how "row" is calculated in 3D, independently from processor numbers.</div>
<div><br></div><div>Regards,</div><div>Ilyas</div><div><div><br><div class="gmail_quote">2011/4/18 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>On Mon, Apr 18, 2011 at 8:34 AM, ilyas ilyas <span dir="ltr"><<a href="mailto:ilyascfd@gmail.com" target="_blank">ilyascfd@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>Hi,<br></div><div><br></div><div>In ex14f.F in KSP, "row" variable is calculated either</div></blockquote><div><br></div></div><div>These are very old. I suggest you use the FormFunctionLocal() approach in ex5f.F which</div>
<div>does not calculate global row numbers when using a DA.</div><div><br></div><div> Matt</div><div><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>349: do 30 j=ys,ys+ym-1<br>
350: ...</div><div>351: do 40 i=xs,xs+xm-1<br>
352: row = i - gxs + (j - gys)*gxm + 1<br></div><div><br></div><div>or</div><div><br></div><div>442: do 50 j=ys,ys+ym-1<br>443: ...<br>444: row = (j - gys)*gxm + xs - gxs<br>445: do 60 i=xs,xs+xm-1<br>
446: row = row + 1<br></div><div><br></div><div>How can I calculate "row" in 3D ? </div><div><br></div><div>I tried this;</div><div><br></div><div>do k=zs,zs+zm-1<br> do j=ys,ys+ym-1<br> do i=xs,xs+xm-1<br>
<br>                  row = i - gxs + (j - gys)*gxm + (k - gzs)*gxm*gym + 1<br><br></div><div>It does not work for certain number of processors.</div><div><br></div><div><br></div><div>Thanks,</div><div><br></div><font color="#888888"><div>
Ilyas</div>
</font></blockquote></div></div><font color="#888888"><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>