<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 12 May 2016 at 13:01, Miorelli, Federico <span dir="ltr"><<a href="mailto:Federico.Miorelli@cgg.com" target="_blank">Federico.Miorelli@cgg.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)">Dave,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)">Thanks for your answer.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)">For consistency with otehr PETSc routines it would perhaps make sense to create a DMDARestoreAO function?</span></p></div></div></blockquote><div><br></div><div>Not really. The pattern used here is the same as<br><pre>DMGetCoordinateDM()<br>DMGetCoordinates()<br></pre><pre>etc<span style="font-family:arial,helvetica,sans-serif"><br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">I agree it's not always </span><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,helvetica,sans-serif">immediately </span>obvious whether <br>one should call destroy on the object returned. <br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">The best rule I can suggest to follow is that if the man page doesn't <br>explicitly instruct you to call the destroy method, you should not call <br>destroy. If a destroy is required, there will be a note in the man page <br>indicating this, for example <br><br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPChebyshevEstEigGetKSP.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPChebyshevEstEigGetKSP.html</a><br><br>or<br><br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCompositeGetGlobalISs.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCompositeGetGlobalISs.html</a><br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif"><br>The man pages are not 100% consistent:<br>Sometimes they will say "don't call destroy on object XXX as it is <br>used internally by YYY".<br>Other times it will mention the reference counter has been incremented.<br>Other times nothing is stated (implicitly meaning no destroy is required).<br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif"><br>If in doubt, just email the petsc-users list :D<br><br>Thanks,<br> Dave<br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif"><br><br></span></pre></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 link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)">Regards,<u></u><u></u></span></p><span>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)">Federico<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Consolas;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(0,147,208)" lang="IT">______</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="IT">
</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(140,198,63)" lang="IT">______</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="IT">
</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(252,176,52)" lang="IT">______</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="IT"><u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(64,64,64)" lang="IT">Federico Miorelli</span><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)" lang="IT"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)" lang="IT"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)" lang="IT">Senior R&D Geophysicist<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Subsurface Imaging - General Geophysics
</span></b><b><span style="font-size:9pt;font-family:"Calibri","sans-serif";color:rgb(31,73,125)">Italy</span></b><span style="font-size:8pt;font-family:"Calibri","sans-serif";color:rgb(64,64,64)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8pt;font-family:"Calibri","sans-serif";color:rgb(64,64,64)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8pt;font-family:"Calibri","sans-serif";color:rgb(64,64,64)">CGG Electromagnetics (Italy) Srl<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8pt;font-family:"Calibri","sans-serif";color:rgb(64,64,64)" lang="IT"><u></u> <u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</span><p class="MsoNormal"><b><span style="font-size:10pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10pt;font-family:"Tahoma","sans-serif""> Dave May [mailto:<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>]
<br>
<b>Sent:</b> giovedì 12 maggio 2016 13:03<br>
<b>To:</b> Miorelli, Federico<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] DMDAGetAO and AODestroy<u></u><u></u></span></p><div><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On 12 May 2016 at 11:36, Miorelli, Federico <<a href="mailto:Federico.Miorelli@cgg.com" target="_blank">Federico.Miorelli@cgg.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:Consolas">In one of my subroutines I'm calling DMDAGetAO to get the application ordering from a DM structure.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">After using it I was calling AODestroy.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">Everything worked fine until I called the subroutine for the second time, when the program crashed.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">Removing the call to AODestroy solved the crash.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">Am I supposed to AODestroy the output of DMDAGetAO or not? I was worried that DMDAGetAO would allocate memory that I need to release.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">You are not supposed to call AODestroy() on the AO returned.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">The pointer being returned is used internally by the DMDA.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Dave<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border-width:medium medium medium 1pt;border-style:none none none solid;border-color:-moz-use-text-color -moz-use-text-color -moz-use-text-color rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span style="font-family:Consolas"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">Federico</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(0,147,208)" lang="IT">______</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="IT">
</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(140,198,63)" lang="IT">______</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="IT">
</span></b><b><span style="font-size:18.5pt;font-family:"Arial","sans-serif";color:rgb(252,176,52)" lang="IT">______</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(64,64,64)" lang="IT">Federico Miorelli</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="IT"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)" lang="IT">Senior R&D Geophysicist</span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10pt;color:rgb(31,73,125)">Subsurface Imaging - General Geophysics
</span></b><b><span style="font-size:9pt;color:rgb(31,73,125)">Italy</span></b><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8pt;color:rgb(64,64,64)"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:8pt;color:rgb(64,64,64)">CGG Electromagnetics (Italy) Srl</span><u></u><u></u></p>
</div>
<p class="MsoNormal"><i><span style="font-size:7pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="EN-GB">This email and any accompanying attachments are confidential. If you received this email
by mistake, please delete<br>
it from your system. Any review, disclosure, copying, distribution, or use of the email by others is strictly prohibited.</span></i><u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div><div><div>
<p class="MsoNormal"><i><span style="font-size:7pt;font-family:"Arial","sans-serif";color:rgb(106,115,123)" lang="EN-GB">This email and any accompanying attachments are confidential. If you received this email by mistake, please delete<br>
it from your system. Any review, disclosure, copying, distribution, or use of the email by others is strictly prohibited.<u></u><u></u></span></i></p>
</div></div></div>
</blockquote></div><br></div></div>