Skip to main content
`Ctrl`+`K`

# PetscFPrintf

Prints to a file, only from the first MPI process in the communicator.

## Synopsis

    PetscErrorCode PetscFPrintf(MPI_Comm comm, FILE *fd, const char format[], ...)

Not Collective

## Input Parameters

- comm - the MPI communicator

- fd - the file pointer, `PETSC_STDOUT` or value obtained from `PetscFOpen()`

- format - the usual `printf()` format string

## Fortran Note

The call sequence is `PetscFPrintf`(`MPI_Comm`, fp, `character`(*), `PetscErrorCode` ierr). That is, you can only pass a single character string from Fortran.

## Developer Notes

This maybe, and is, called from PETSc error handlers and `PetscMallocValidate()` hence it does not use `PetscCallMPI()` which could recursively restart the malloc validation.

## See Also

`PetscPrintf()`, `PetscSynchronizedPrintf()`, `PetscViewerASCIIPrintf()`, `PetscViewerASCIISynchronizedPrintf()`, `PetscSynchronizedFlush()`, `PetscFFlush()`

## Level

intermediate

## Location

src/sys/fileio/mprint.c

## Examples

src/ksp/ksp/tutorials/ex42.c
src/ksp/ksp/tutorials/ex43.c
src/ksp/ksp/tutorials/ex49.c

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