<div dir="ltr"><div dir="ltr">On Tue, Feb 5, 2019 at 4:31 AM Marco Tiberga <<a href="mailto:M.Tiberga@tudelft.nl">M.Tiberga@tudelft.nl</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-GB">
<div class="gmail-m_6453364946762150577WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Dear Matt,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Thanks for your reply, now it’s clear to me also why matArray is not destroyed, contrarily to Amat.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Do you think that declaring explicitly matArray as a (Fortran) pointer (at line 113) and then using “matArray(1) => Amat” would be equivalent? It would be certainly clearer
from the Fortran point of view.</span></p></div></div></blockquote><div><br></div><div>Looks like it. I am not a Fortran expert.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-GB"><div class="gmail-m_6453364946762150577WordSection1"><p class="MsoNormal"><span style="font-family:Calibri,sans-serif;font-size:11pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">With kind regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif">Marco Tiberga<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> Matthew Knepley [mailto:<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>]
<br>
<b>Sent:</b> maandag 4 februari 2019 17:46<br>
<b>To:</b> Marco Tiberga<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>; Aldo Hennink - TNW; Danny Lathouwers - TNW<br>
<b>Subject:</b> Re: [petsc-users] Doubt on how to copy a Mat into another (Fortran)<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Mon, Feb 4, 2019 at 11:16 AM Marco Tiberga via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<u></u><u></u></p>
</div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Dear PETSc developers,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Since I am learning how to use MatCreateNest, I was looking at example
<a href="https://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex73f90t.F90.html" target="_blank">
ex73f90t.F90</a> (I am using Fortran).<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">At line 297, the array of matrices to be passed to MatCreateNest is initialized with code lines as “matArray(1) = Amat”.<u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">That is a pointer. It does not create a replica in memory, as the calls below do. Fortran is not explicit about this distinction<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">which can lead to confusion.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"> Matt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I was surprised to find such a simple command, I thought a matrix copy should be done by a sequence like<u></u><u></u></p>
<p class="MsoNormal">“ call MatDuplicate(Amat, MAT_SHARE_NONZERO_PATTERN,matArray(1),ierr); CHKERRA(ierr)<u></u><u></u></p>
<p class="MsoNormal"> call MatCopy(Amat,matArray(1), SAME_NONZERO_PATTERN,ierr); CHKERRA(ierr) “<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">So, I was wondering: are the two ways completely equivalent, and therefore the second unnecessarily more complex? or is the latter more robust and therefore preferable?<u></u><u></u></p>
<p class="MsoNormal">Is there any difference in terms of performance?<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thanks a lot for the clarification.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Best regards,<u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:4pt">Marco Tiberga<u></u><u></u></p>
<p class="MsoNormal">PhD candidate<u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(0,176,240)">Delft University of Technology</span><u></u><u></u></p>
<p class="MsoNormal">Faculty of Applied Sciences<u></u><u></u></p>
<p class="MsoNormal">Radiation Science & Technology Department<u></u><u></u></p>
<p class="MsoNormal">Mekelweg 15, 2629 JB Delft, The Netherlands<u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:2pt">E-Mail:<span style="color:gray"> </span><u><span style="color:blue"><a href="mailto:m.tiberga@tudelft.nl" target="_blank">m.tiberga@tudelft.nl</a></span></u><u></u><u></u></p>
<p class="MsoNormal"><span lang="NL">Website:
</span><a href="http://www.nera.rst.tudelft.nl/" target="_blank"><span lang="NL">http://www.nera.rst.tudelft.nl/</span></a><u></u><u></u></p>
<p class="MsoNormal"><span lang="NL"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="NL"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="NL"> </span><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>