:orphan:
# TaoSetMonitor
Sets an additional function that is to be used at every iteration of the solver to display the iteration's progress. 
## Synopsis
```
#include "petsctao.h" 
PetscErrorCode TaoSetMonitor(Tao tao, PetscErrorCode (*func)(Tao, void *), void *ctx, PetscErrorCode (*dest)(void **))
```
Logically Collective


## Input Parameters

- ***tao -*** the `Tao` solver context
- ***func -*** monitoring routine
- ***ctx -*** [optional] user-defined context for private data for the monitor routine (may be `NULL`)
- ***dest -*** [optional] function to destroy the context when the `Tao` is destroyed



## Calling sequence of `func`
```none
PetscErrorCode func(Tao tao, void *ctx)
```

- ***tao -*** the `Tao` solver context
- ***ctx -*** [optional] monitoring context



## Calling sequence of `dest`
```none
PetscErrorCode dest(void *ctx)
```

- ***ctx -*** monitoring context



## Options Database Keys

- ***-tao_monitor        -*** sets the default monitor `TaoMonitorDefault()`
- ***-tao_smonitor       -*** sets short monitor
- ***-tao_cmonitor       -*** same as smonitor plus constraint norm
- ***-tao_view_solution   -*** view solution at each iteration
- ***-tao_view_gradient   -*** view gradient at each iteration
- ***-tao_view_ls_residual -*** view least-squares residual vector at each iteration
- ***-tao_cancelmonitors -*** cancels all monitors that have been hardwired into a code by calls to TaoSetMonitor(), but does not cancel those set via the options database.





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


## Fortran Note
Only one monitor function may be set


## See Also
 [](ch_tao), `Tao`, `TaoSolve()`, `TaoMonitorDefault()`, `TaoCancelMonitors()`, `TaoSetDestroyRoutine()`, `TaoView()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/interface/taosolver.c.html#TaoSetMonitor">src/tao/interface/taosolver.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/tutorials/jbearing2.c.html">src/tao/bound/tutorials/jbearing2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/burgers_spectral.c.html">src/tao/unconstrained/tutorials/burgers_spectral.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2f.F90.html">src/tao/unconstrained/tutorials/eptorsion2f.F90</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/minsurf2.c.html">src/tao/unconstrained/tutorials/minsurf2.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/spectraladjointassimilation.c.html">src/tao/unconstrained/tutorials/spectraladjointassimilation.c</A><BR>


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


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