[petsc-dev] ierr and CHKERRQ stuff
Matthew Knepley
knepley at gmail.com
Tue Oct 30 07:47:20 CDT 2012
On Tue, Oct 30, 2012 at 5:27 AM, Václav Hapla <vaclav.hapla at vsb.cz> wrote:
> Dear all,
> I probably don't see something important and I am sorry for that in
> advance, but anyway I want to make it clear to me:
>
> What would I spoil by using kind of
> TRY( ... );
> concept instead of
> ierr = ...;CHKERRQ(ierr);
> stuff?
> The first concept seems to me making the code more readable and is faster
> to type of course.
>
There is nothing wrong with that. A small nitpick is that it assumes that
ierr is declared.
Matt
> I have the following two lines in one of my headers included by all C
> files:
> static PetscErrorCode ierr;
> #define TRY(f) {ierr = f; CHKERRQ(ierr);}
> and the PETSc' error catching system works normally I mean.
>
> I know of course that for instance following is wrong:
> if (something) TRY( somefun1 );
> else TRY( somefun2 );
> which is a little bit nonintuitive.
>
> This is not against already existing code; I would just like to understand
> the reasons - if I am wrong I am about to switch my codebase to the
> original PETSc' concept.
>
> Thanks in advance,
> BR,
> Vaclav
>
> --
>
> Vaclav Hapla
> Research assistant
> SPOMECH project <http://spomech.vsb.cz/>
> Centre of Excellence IT4Innovations <http://www.it4i.eu/>
>
> VSB-Technical University of Ostrava
> 17.listopadu 15/2172
> 708 33 Ostrava-Poruba
> Czech Republic
>
>
--
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20121030/808f9206/attachment.html>
More information about the petsc-dev
mailing list