# KSPMonitorRegister
Registers a Krylov subspace solver monitor routine that may be accessed with `KSPMonitorSetFromOptions()` 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPMonitorRegister(const char name[], PetscViewerType vtype, PetscViewerFormat format, PetscErrorCode (*monitor)(KSP, PetscInt, PetscReal, PetscViewerAndFormat *), PetscErrorCode (*create)(PetscViewer, PetscViewerFormat, void *, PetscViewerAndFormat **), PetscErrorCode (*destroy)(PetscViewerAndFormat **))
```
Not Collective


## Input Parameters

- ***name    -*** name of a new monitor routine
- ***vtype   -*** A `PetscViewerType` for the output
- ***format  -*** A `PetscViewerFormat` for the output
- ***monitor -*** Monitor routine
- ***create  -*** Creation routine, or NULL
- ***destroy -*** Destruction routine, or NULL





## Note
`KSPMonitorRegister()` may be called multiple times to add several user-defined monitors.


## Sample usage
```none
  KSPMonitorRegister("my_monitor",PETSCVIEWERASCII,PETSC_VIEWER_ASCII_INFO_DETAIL,MyMonitor,NULL,NULL);
```


Then, your monitor can be chosen with the procedural interface via
```none
KSPMonitorSetFromOptions(ksp,"-ksp_monitor_my_monitor","my_monitor",NULL)
```
or at runtime via the option
```none
-ksp_monitor_my_monitor
```


## See Also
 [](chapter_ksp), `KSP`, `KSPMonitorSet()`, `KSPMonitorRegisterAll()`, `KSPMonitorSetFromOptions()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/interface/itcreate.c.html#KSPMonitorRegister">src/ksp/ksp/interface/itcreate.c</A>


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


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