[petsc-dev] Integrating PFLOTRAN, PETSC & SAMRAI
Jed Brown
jed at 59A2.org
Mon Jun 6 17:20:30 CDT 2011
On Tue, Jun 7, 2011 at 00:03, Barry Smith <bsmith at mcs.anl.gov> wrote:
> { PetscInt statey = ((PetscObject)y)->state;
> ierr = (*y->ops->axpy)(y,alpha,x);CHKERRQ(ierr);
> if (((PetscObject)y)->state == statey) SETERRQ("did not increase
> state!"}
>
Hmm, you could have 1,2,3 variants for multiple modifications. I think those
are quite rare at present.
This macro is not a very good citizen, but it gets the job done. It could be
made nicer if we had C99 variadic macros. (SETERRQ*, PetscInfo*, etc. could
be made nicer too.)
#define PetscCallAndMonitorState(inc,obj,method,args) do { \
PetscInt save_ ## inc = ((PetscObject)inc)->state; \
if (!obj->ops->method) SETERRQ(...); \
ierr = (*obj->ops->method) args;CHKERRQ(ierr); \
if (save_ ## inc == ((PetscObject)inc)->state) SETERRQ(...); \
} while(0)
used like
PetscCallAndMonitorState(y,y,axpy,(y,alpha,x));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110607/6518207f/attachment.html>
More information about the petsc-dev
mailing list