# SNESMonitorSet
Sets an ADDITIONAL function that is to be used at every iteration of the nonlinear solver to display the iteration's progress. 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESMonitorSet(SNES snes, PetscErrorCode (*f)(SNES, PetscInt, PetscReal, void *), void *mctx, PetscErrorCode (*monitordestroy)(void **))
```
Logically Collective


## Input Parameters

- ***snes -*** the `SNES` context
- ***f -*** the monitor function, see `SNESMonitorFunction` for the calling sequence
- ***mctx -*** [optional] user-defined context for private data for the
monitor routine (use NULL if no context is desired)
- ***monitordestroy -*** [optional] routine that frees monitor context
(may be NULL)



## Options Database Keys

- ***-snes_monitor        -*** sets `SNESMonitorDefault()`
- ***-snes_monitor draw::draw_lg -*** sets line graph monitor,
- ***-snes_monitor_cancel -*** cancels all monitors that have
been hardwired into a code by
calls to SNESMonitorSet(), but
does not cancel those set via
the options database.



## Note
Several different monitoring routines may be set by calling
`SNESMonitorSet()` multiple times; all will be called in the
order in which they were set.


## Fortran Note
Only a single monitor function can be set for each `SNES` object




## See Also
 `SNES`, `SNESSolve()`, `SNESMonitorDefault()`, `SNESMonitorCancel()`, `SNESMonitorFunction`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/interface/snes.c.html#SNESMonitorSet">src/snes/interface/snes.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex2.c.html">src/snes/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex21.c.html">src/snes/tutorials/ex21.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex22.c.html">src/snes/tutorials/ex22.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex3.c.html">src/snes/tutorials/ex3.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex12.c.html">src/ts/tutorials/ex12.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex52.c.html">src/ts/tutorials/ex52.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex7.c.html">src/ts/tutorials/ex7.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/snes/interface/snes.c)


[Index of all SNES routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
