:orphan:
# KSPMonitorResidual
Print the (possibly preconditioned) residual norm at each iteration of an iterative solver.
## Synopsis
```
#include "petscksp.h"
PetscErrorCode KSPMonitorResidual(KSP ksp, PetscInt n, PetscReal rnorm, PetscViewerAndFormat *vf)
```
Collective
## Input Parameters
- ***ksp -*** iterative context
- ***n -*** iteration number
- ***rnorm -*** 2-norm (preconditioned) residual value (may be estimated).
- ***vf -*** The viewer context
## Options Database Key
- ***-ksp_monitor -*** Activates `KSPMonitorResidual()`
## Note
For some methods, such as `KSPGMRES`, the norm is not computed directly from the residual.
The type of norm used by the method can be controlled with `KSPSetNormType()`
This is not called directly by users, rather one calls `KSPMonitorSet()`, with this function as an argument, to cause the monitor
to be used during the KSP solve.
## See Also
[](ch_ksp), `KSP`, `KSPMonitorSet()`, `KSPMonitorTrueResidual()`, `KSPMonitorResidualDraw()`, `KSPMonitorResidualDrawLG()`,
`KSPMonitorResidualRange()`, `KSPMonitorTrueResidualDraw()`, `KSPMonitorTrueResidualDrawLG()`, `KSPMonitorTrueResidualMax()`,
`KSPMonitorSingularValue()`, `KSPMonitorSolutionDrawLG()`, `KSPMonitorSolutionDraw()`, `KSPMonitorSolution()`,
`KSPMonitorErrorDrawLG()`, `KSPMonitorErrorDraw()`, KSPMonitorError()`
## Level
intermediate
## Location
src/ksp/ksp/interface/iterativ.c
## Examples
src/ksp/ksp/tutorials/ex2f.F90
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/interface/iterativ.c)
[Index of all KSP routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)