# SNESSetMonitor

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 PETSCSNES_DLLEXPORT SNESSetMonitor(SNES snes,PetscErrorCode (*func)(SNES,PetscInt,PetscReal,void*),void *mctx,PetscErrorCode (*monitordestroy)(void*))

Collective on SNES

### Input Parameters

| snes | - the SNES context
| func | - monitoring routine
| mctx | - [optional] user-defined context for private data for the monitor routine (use PETSC_NULL if no context is desitre)
| monitordestroy | - [optional] routine that frees monitor context (may be PETSC_NULL)

### Calling sequence of func

        int func(SNES snes,PetscInt its, PetscReal norm,void *mctx)

| snes | - the SNES context
| its | - iteration number
| norm | - 2-norm function value (may be estimated)
| mctx | - [optional] monitoring context

### Options Database Keys

| -snes_monitor | - sets SNESDefaultMonitor()
| -snes_xmonitor | - sets line graph monitor, uses SNESLGMonitorCreate() _ -snes_cancelmonitors - cancels all monitors that have been hardwired into a code by calls to SNESSetMonitor(), but does not cancel those set via the options database.

### Notes

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

### Keywords

SNES, nonlinear, set, monitor

### See Also

SNESDefaultMonitor(), SNESClearMonitor()

Level:intermediate
Location:src/snes/interface/snes.c
Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex2.c.html
src/snes/examples/tutorials/ex3.c.html
src/snes/examples/tutorials/ex21.c.html
src/snes/examples/tutorials/ex22.c.html