PetscVFPrintfDefault — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# PetscVFPrintfDefault

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.

## Synopsis

    PetscErrorCode PetscVFPrintfDefault(FILE *fd, const char format[], va_list Argp)

No Fortran Support

## Input Parameters

- fd - the file descriptor to write to

- format - the format string to write with

- Argp - the variable argument list of items to format and write

## Note

For error messages this may be called by any MPI process, for regular standard out it is called only by MPI rank 0 of a given communicator

## Example Usage

To use, write your own function for example,

       PetscErrorCode mypetscvfprintf(FILE *fd, const char format[], va_list Argp)
       {
         PetscErrorCode ierr;

         PetscFunctionBegin;
          if (fd != stdout && fd != stderr) {  handle regular files
             CHKERR(PetscVFPrintfDefault(fd,format,Argp));
         } else {
            char   buff[BIG];
            size_t length;
            PetscCall(PetscVSNPrintf(buff,BIG,format,&length,Argp));
            now send buff to whatever stream or whatever you want
        }
        PetscFunctionReturn(PETSC_SUCCESS);
       }

then before the call to `PetscInitialize()` do the assignment `PetscVFPrintf = mypetscvfprintf`;

## Developer Notes

This could be called by an error handler, if that happens then a recursion of the error handler may occur and a resulting crash

## See Also

`PetscVSNPrintf()`, `PetscErrorPrintf()`, `PetscFFlush()`

## Level

developer

## Location

src/sys/fileio/mprint.c

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages