:orphan:
# SNESSetMaxLinearSolveFailures
the number of failed linear solve attempts allowed before `SNES` returns with a diverged reason of `SNES_DIVERGED_LINEAR_SOLVE` 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetMaxLinearSolveFailures(SNES snes, PetscInt maxFails)
```
Logically Collective


## Input Parameters

- ***snes     -*** `SNES` context
- ***maxFails -*** maximum allowed linear solve failures



## Options Database Key

- ***-snes_max_linear_solve_fail <num> -*** The number of failures before the solve is terminated





## Note
By default this is 0; that is `SNES` returns on the first failed linear solve


## See Also
 [](ch_snes), `SNESSetErrorIfNotConverged()`, `SNESGetLinearSolveFailures()`, `SNESGetMaxLinearSolveFailures()`, `SNESGetLinearSolveIterations()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/interface/snes.c.html#SNESSetMaxLinearSolveFailures">src/snes/interface/snes.c</A>


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


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