# KSPGCRSetModifyPC
Sets the routine used by `KSPGCR` to modify the preconditioner for each iteration 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPGCRSetModifyPC(KSP ksp, PetscErrorCode (*function)(KSP, PetscInt, PetscReal, void *), void *data, PetscErrorCode (*destroy)(void *))
```
Logically Collective


## Input Parameters
+  ksp      - iterative context obtained from KSPCreate()
.  function - user defined function to modify the preconditioner
.  ctx      - user provided context for the modify preconditioner function
-  destroy  - the function to use to destroy the user provided application context.


## Calling Sequence of function
PetscErrorCode function (KSP ksp, PetscInt n, PetscReal rnorm, void *ctx)

- ***ksp   -*** iterative context
- ***n     -*** the total number of GCR iterations that have occurred
- ***rnorm -*** 2-norm residual value
- ***ctx   -*** the user provided application context





## Note
The default modifypc routine is `KSPGCRModifyPCNoChange()`


## Developer Note
The API should make uniform for all flexible types, [](sec_flexibleksp), and not have separate function calls for each type.


## See Also
 [](chapter_ksp), `KSP`, `KSPGCR`, `KSPGCRModifyPCNoChange()`, [](sec_flexibleksp)

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gcr/gcr.c.html#KSPGCRSetModifyPC">src/ksp/ksp/impls/gcr/gcr.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gcr/gcr.c.html#KSPGCRSetModifyPC_GCR">KSPGCRSetModifyPC_GCR in src/ksp/ksp/impls/gcr/gcr.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/impls/gcr/gcr.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)  
