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

Ed Bueler elbueler at alaska.edu
Fri Sep 11 17:31:39 CDT 2020


Thanks Matt and Barry.  Clear.

Ed

On Fri, Sep 11, 2020 at 2:05 PM Barry Smith <bsmith at petsc.dev> wrote:

>
>
> On Sep 11, 2020, at 2:58 PM, Matthew Knepley <knepley at gmail.com> wrote:
>
> 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.
>
>
>   If there is a failure in PetscFinalize() then PETSc will be in some
> unknown state where the CHKERRQ macros will no longer work so PETSc error
> handling should not be called.
>
>   Barry
>
>
>   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/>
>
>
>

-- 
Ed Bueler
Dept of Mathematics and Statistics
University of Alaska Fairbanks
Fairbanks, AK 99775-6660
306C Chapman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200911/7cd21477/attachment.html>


More information about the petsc-users mailing list