# DMMonitorSet
Sets an additional monitor function that is to be used after a solve to monitor discretization performance. 
## Synopsis
```
#include "petscdm.h"          
#include "petscdmlabel.h"     
#include "petscds.h"     
PetscErrorCode DMMonitorSet(DM dm, PetscErrorCode (*f)(DM, void *), void *mctx, PetscErrorCode (*monitordestroy)(void **))
```
Logically Collective on dm


## Input Parameters

- ***DM -*** the `DM`
- ***f -*** the monitor function
- ***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

- ***-dm_monitor_cancel -*** cancels all monitors that have been hardwired into a code by calls to `DMMonitorSet()`, but
does not cancel those set via the options database.



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


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


## Developer Note
This API has a generic name but seems specific to a very particular aspect of the use of `DM`




## See Also
 `DMMonitorCancel()`, `DMMonitorSetFromOptions()`, `DMMonitor()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/interface/dm.c.html#DMMonitorSet">src/dm/interface/dm.c</A>


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


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