[petsc-users] DMDAGetAO and AODestroy

Dave May dave.mayhem23 at gmail.com
Thu May 12 09:37:48 CDT 2016


On 12 May 2016 at 13:01, Miorelli, Federico <Federico.Miorelli at cgg.com>
wrote:

> Dave,
>
>
>
> Thanks for your answer.
>
> For consistency with otehr PETSc routines it would perhaps make sense to
> create a DMDARestoreAO function?
>

Not really. The pattern used here is the same as

DMGetCoordinateDM()
DMGetCoordinates()

etc

I agree it's not always immediately obvious whether
one should call destroy on the object returned.

The best rule I can suggest to follow is that if the man page doesn't
explicitly instruct you to call the destroy method, you should not call
destroy. If a destroy is required, there will be a note in the man page
indicating this, for example

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPChebyshevEstEigGetKSP.html

or

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCompositeGetGlobalISs.html


The man pages are not 100% consistent:
Sometimes they will say "don't call destroy on object XXX as it is
used internally by YYY".
Other times it will mention the reference counter has been incremented.
Other times nothing is stated (implicitly meaning no destroy is required).


If in doubt, just email the petsc-users list :D

Thanks,
  Dave





>
>
> Regards,
>
> Federico
>
>
>
> *______* *______* *______*
>
> Federico Miorelli
>
>
>
> Senior R&D Geophysicist
>
> *Subsurface Imaging - General Geophysics **Italy*
>
>
>
> CGG Electromagnetics (Italy) Srl
>
>
>
>
>
> *From:* Dave May [mailto:dave.mayhem23 at gmail.com]
> *Sent:* giovedì 12 maggio 2016 13:03
> *To:* Miorelli, Federico
> *Cc:* petsc-users at mcs.anl.gov
> *Subject:* Re: [petsc-users] DMDAGetAO and AODestroy
>
>
>
>
>
>
>
> On 12 May 2016 at 11:36, Miorelli, Federico <Federico.Miorelli at cgg.com>
> wrote:
>
> In one of my subroutines I'm calling DMDAGetAO to get the application
> ordering from a DM structure.
>
> After using it I was calling AODestroy.
>
>
>
> Everything worked fine until I called the subroutine for the second time,
> when the program crashed.
>
> Removing the call to AODestroy solved the crash.
>
>
>
> Am I supposed to AODestroy the output of DMDAGetAO or not? I was worried
> that DMDAGetAO would allocate memory that I need to release.
>
>
>
> You are not supposed to call AODestroy() on the AO returned.
>
> The pointer being returned is used internally by the DMDA.
>
> Thanks
>
>   Dave
>
>
>
>
>
>
>
> Thanks,
>
>
>
> Federico
>
>
>
> *______* *______* *______*
>
> Federico Miorelli
>
>
>
> Senior R&D Geophysicist
>
> *Subsurface Imaging - General Geophysics **Italy*
>
>
>
> CGG Electromagnetics (Italy) Srl
>
>
> *This email and any accompanying attachments are confidential. If you
> received this email by mistake, please delete it from your system. Any
> review, disclosure, copying, distribution, or use of the email by others is
> strictly prohibited.*
>
>
>
>
> *This email and any accompanying attachments are confidential. If you
> received this email by mistake, please delete it from your system. Any
> review, disclosure, copying, distribution, or use of the email by others is
> strictly prohibited.*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160512/894ab11c/attachment.html>


More information about the petsc-users mailing list