Skip to main content
`Ctrl`+`K`

# SNESMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user

## Synopsis

    #include "petscsnes.h"
    #include "petscsnes.h"
    PetscErrorCode SNESMonitorSetFromOptions(SNES snes, const char name[], const char help[], const char manual[], PetscErrorCode (*monitor)(SNES snes, PetscInt it, PetscReal r, PetscViewerAndFormat *vf), PetscErrorCode (*monitorsetup)(SNES snes, PetscViewerAndFormat *vf))

Collective

## Input Parameters

- snes - `SNES` object you wish to monitor

- name - the monitor type one is seeking

- help - message indicating what monitoring is done

- manual - manual page for the monitor

- monitor - the monitor function, this must use a `PetscViewerFormat` as its context

- monitorsetup - a function that is called once ONLY if the user selected this monitor that may set additional features of the `SNES` or `PetscViewer` objects

## Calling sequence of `monitor`

- snes - the nonlinear solver context

- it - the current iteration

- r - the current function norm

- vf - a `PetscViewerAndFormat` struct that contains the `PetscViewer` and `PetscViewerFormat` to use

## Calling sequence of `monitorsetup`

- snes - the nonlinear solver context

- vf - a `PetscViewerAndFormat` struct that contains the `PetscViewer` and `PetscViewerFormat` to use

## Options Database Key

- -name - trigger the use of this monitor in `SNESSetFromOptions()`

## See Also

SNES: Nonlinear Solvers, `PetscOptionsCreateViewer()`, `PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsBool()`, `PetscOptionsInt()`, `PetscOptionsString()`, `PetscOptionsReal()`, `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`, `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, `PetscOptionsFList()`, `PetscOptionsEList()`

## Level

advanced

## Location

src/snes/interface/snes.c

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