[petsc-users] Error and success codes
Cedric Doucet
cedric.doucet at inria.fr
Wed Aug 27 04:26:28 CDT 2014
Hello,
thank you very much for your answer!
> No, use 0. It's less typing and that is something that will definitely
> never change.
I understand but it could be a good thing to give it the same value as EXIT_SUCCESS (from cstdlib) because this value is not always zero.
However, that's ok for me.
Best,
Cédric
----- Mail original -----
> De: "Jed Brown" <jed at jedbrown.org>
> À: "Cedric Doucet" <cedric.doucet at inria.fr>, petsc-users at mcs.anl.gov
> Envoyé: Lundi 25 Août 2014 18:47:25
> Objet: Re: [petsc-users] Error and success codes
>
> Cedric Doucet <cedric.doucet at inria.fr> writes:
>
> > Hello,
> >
> > I want to manage errors with CHKERRQ macro in void functions.
> >
> > I do not want to use CHKERRV.
> > I prefer to modify void functions so that they return an error code.
> >
> > However, it seems CHKERRQ returns a value in case of failure only.
> > Example below does not seem to compile without warning (Wreturn-type flag):
> >
> > --------------------------
> > PetscErrorCode foo()
> > {
> > PetscErrorCode code = somePetscFunction();
> > CHKERRQ(code);
> > }
> > --------------------------
> >
> > I guess I need to return a success code like this:
> >
> > --------------------------
> > PetscErrorCode foo()
> > {
> > PetscErrorCode code = somePetscFunction();
> > CHKERRQ(code);
> > return PETSC_SUCCESS_CODE;
> > }
> > --------------------------
> >
> > However, I do not know the value of the success code of Petsc.
> > I guess it is zero but I would prefer to use a macro sucha as
> > PETSC_SUCCESS_CODE in the above example.
> > Does such a macro exist?
>
> No, use 0. It's less typing and that is something that will definitely
> never change.
>
More information about the petsc-users
mailing list