[petsc-users] recommended error-checking for PetscInitialize() and PetscFinalize()

Matthew Knepley knepley at gmail.com
Fri Sep 11 14:58:10 CDT 2020


On Fri, Sep 11, 2020 at 3:57 PM Ed Bueler <elbueler at alaska.edu> wrote:

> Dear PETSc --
>
> I notice in the users manual that the C examples show
>
> ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
>
> at the start of main() and
>
> ierr = PetscFinalize();
> return ierr;
>
> at the end of main().  Is this the deliberate, recommended style?
>

Yes.


>   My understanding of these choices is that if PetscInitialize() fails
> then CHKERRQ(ierr) may not do the right thing,
>

Yes, failure early-on in Initialize() can predate setting up error handling.


> while if PetscFinalize() fails then that should be the result of main()
> (without any fiddling by CHKERRQ etc.).  Is this the correct understanding?
>

Yes.

  Thanks,

     Matt


> Thanks,
>
> Ed
>
> --
> Ed Bueler
> Dept of Mathematics and Statistics
> University of Alaska Fairbanks
> Fairbanks, AK 99775-6660
> 306C Chapman
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200911/09d7d22c/attachment.html>


More information about the petsc-users mailing list