# KSPGMRESSetOrthogonalization
Sets the orthogonalization routine used by `KSPGMRES` and `KSPFGMRES`. 
## Synopsis
```
#include "petscksp.h"  
PetscErrorCode KSPGMRESSetOrthogonalization(KSP ksp, PetscErrorCode (*fcn)(KSP, PetscInt))
```
Logically Collective on ksp


## Input Parameters

- ***ksp -*** iterative context obtained from `KSPCreate()`
- ***fcn -*** orthogonalization function



## Calling Sequence of function
```none
errorcode = PetscErrorCode fcn(KSP ksp,PetscInt it);
```
```none
it is one minus the number of GMRES iterations since last restart;
```
```none
i.e. the size of Krylov space minus one
```


## Options Database Keys

- ***-ksp_gmres_classicalgramschmidt -*** Activates KSPGMRESClassicalGramSchmidtOrthogonalization() (default)
- ***-ksp_gmres_modifiedgramschmidt -*** Activates KSPGMRESModifiedGramSchmidtOrthogonalization()





## Notes
Two orthogonalization routines are predefined, including `KSPGMRESModifiedGramSchmidtOrthogonalization()` and the default
`KSPGMRESClassicalGramSchmidtOrthogonalization()`.

Use `KSPGMRESSetCGSRefinementType()` to determine if iterative refinement is used to increase stability.


## See Also
 [](chapter_ksp), `KSPGMRESSetRestart()`, `KSPGMRESSetPreAllocateVectors()`, `KSPGMRESSetCGSRefinementType()`, `KSPGMRESSetOrthogonalization()`,
`KSPGMRESModifiedGramSchmidtOrthogonalization()`, `KSPGMRESClassicalGramSchmidtOrthogonalization()`, `KSPGMRESGetCGSRefinementType()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/gmres/gmres2.c.html#KSPGMRESSetOrthogonalization">src/ksp/ksp/impls/gmres/gmres2.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex5f.F90.html">src/ksp/ksp/tutorials/ex5f.F90.html</A><BR>

## Implementations

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


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