[petsc-dev] ierr and CHKERRQ stuff

Václav Hapla vaclav.hapla at vsb.cz
Tue Oct 30 04:27:36 CDT 2012


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.

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




More information about the petsc-dev mailing list