[petsc-dev] PetscPrintf() is never suppose to be used to print error messages

Matthew Knepley knepley at gmail.com
Wed Jan 2 11:32:46 CST 2013

On Wed, Jan 2, 2013 at 2:07 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>   that is what (*PetscErrorPrintf)() is for. Please fix. Thanks Barry
>   ierr = MatSetValues(A, numIndices, indices, numIndices, indices, values,
> mode);
>   if (ierr) {
>     PetscMPIInt    rank;
>     PetscErrorCode ierr2;
>     ierr2 = MPI_Comm_rank(((PetscObject) A)->comm, &rank);CHKERRQ(ierr2);
>     ierr2 = PetscPrintf(PETSC_COMM_SELF, "[%D]ERROR in
> DMPlexMatSetClosure\n", rank);CHKERRQ(ierr2);
>     ierr2 = DMPlexPrintMatSetValues(A, point, numIndices, indices,
> values);CHKERRQ(ierr2);
>     ierr2 = DMRestoreWorkArray(dm, numIndices, PETSC_INT,
> &indices);CHKERRQ(ierr);
>                                       Also the above should be ierr2 ^^^^^
>     CHKERRQ(ierr);
>   }
> Why? Because PetscPrintf() and (*PetscErrorPrintf)() may be completely
> different streams, for example (*PetscErrorPrintf)() going to a nice GUI
> popup or console etc etc

I fixed the simple thing, but the PrintMatSetValues() is problematic. Right
now, it just prints using
PetscPrintf, which is wrong for errors like this, but correct for other
things. For normal things, I
could make it take a viewer, which could be PETSC_VIEWER_STDOUT_SELF, and
this behavior. However, do we need to add default viewers for the error


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/20130102/4568cbd1/attachment.html>

More information about the petsc-dev mailing list