1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscVFPrintf.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>PetscVFPrintf</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.4.2 2013-07-02</b></div>
<A NAME="PetscVFPrintf"><H1>PetscVFPrintf</H1></A>
All PETSc standard out and error messages are sent through this function; so, in theory, this can can be replaced with something that does not simply write to a file.
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
PetscErrorCode PetscVFPrintfDefault(FILE *fd,const char *format,va_list Argp)
</PRE>
To use, write your own function for example,
.<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> mypetscvfprintf(FILE *fd,const char format[],va_list Argp)
</pre>
.{ $ <A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> ierr;
</pre>
<pre>
</pre>
<pre>
<A HREF="../Sys/PetscFunctionBegin.html#PetscFunctionBegin">PetscFunctionBegin</A>;
</pre>
<pre>
if (fd != stdout && fd != stderr) { handle regular files
</pre>
<pre>
ierr = PetscVFPrintfDefault(fd,format,Argp);CHKERR(ierr);
</pre>
<pre>
} else {
</pre>
<pre>
char buff[BIG];
</pre>
<pre>
size_t length;
</pre>
<pre>
ierr = <A HREF="../Sys/PetscVSNPrintf.html#PetscVSNPrintf">PetscVSNPrintf</A>(buff,BIG,format,&length,Argp);<A HREF="../Sys/CHKERRQ.html#CHKERRQ">CHKERRQ</A>(ierr);
</pre>
<pre>
now send buff to whatever stream or whatever you want
</pre>
<pre>
}
</pre>
<pre>
<A HREF="../Sys/PetscFunctionReturn.html#PetscFunctionReturn">PetscFunctionReturn</A>(0);
</pre>
.} then before the call to <A HREF="../Sys/PetscInitialize.html#PetscInitialize">PetscInitialize</A>() do the assignment
</pre>
<pre>
<A HREF="../Sys/PetscVFPrintf.html#PetscVFPrintf">PetscVFPrintf</A> = mypetscvfprintf;
</pre>
<P>
Notes: For error messages this may be called by any process, for regular standard out it is
called only by process 0 of a given communicator
<P>
Developer Notes: this could be called by an error handler, if that happens then a recursion of the error handler may occur
and a crash
<P>
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../Sys/PetscVSNPrintf.html#PetscVSNPrintf">PetscVSNPrintf</A>(), <A HREF="../Sys/PetscErrorPrintf.html#PetscErrorPrintf">PetscErrorPrintf</A>()
<BR>
<P>
<P><B><P><B><FONT COLOR="#CC3333">Level:</FONT></B>developer
<BR><FONT COLOR="#CC3333">Location:</FONT></B><A HREF="../../../src/sys/fileio/mprint.c.html#PetscVFPrintf">src/sys/fileio/mprint.c</A>
<BR><A HREF="./index.html">Index of all Sys routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
</BODY></HTML>
|