:orphan:
# KSPCheckSolve
Checks if the `PCSetUp()` or `KSPSolve()` failed and set the error flag for the outer `PC`. A `KSP_DIVERGED_ITS` is not considered a failure in this context 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPCheckSolve(KSP ksp, PC pc, Vec vec)
```
Collective


## Input Parameters

- ***ksp -*** the linear solver `KSP` context.
- ***pc -*** the preconditioner context
- ***vec -*** a vector that will be initialized with Inf to indicate lack of convergence





## Note
This is called within `KSPSolve()` and `PCApply()` to check if an error has been detected on any particular MPI ranks. By initializing the vector
with Inf the next call to `KSPCheckNorm()` or `KSPCheckDot()` will provide the same information to all the MPI ranks that an error occurred on
at least one of the ranks.

This may be called by a subset of the processes in the `PC`.


## Developer Note
This is used to manage returning with appropriate information from preconditioners whose inner `KSP` solvers have failed in some way


## See Also
 [](ch_ksp), `KSP`, `KSPCreate()`, `KSPSetType()`, `KSP`, `KSPCheckNorm()`, `KSPCheckDot()`

## Level
developer

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


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


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