> On Sep 11, 2020, at 2:58 PM, Matthew Knepley <[email protected]> wrote: > > On Fri, Sep 11, 2020 at 3:57 PM Ed Bueler <[email protected] > <mailto:[email protected]>> 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/>
