# KSPSetApplicationContext
Sets the optional user-defined context for the linear solver. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPSetApplicationContext(KSP ksp, void *usrP)
```
Logically Collective


## Input Parameters

- ***ksp -*** the `KSP` context
- ***usrP -*** optional user context



## Fortran Notes
To use this from Fortran you must write a Fortran interface definition for this
function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument.




## Note
The user context is a way for users to attach any information to the `KSP` that they may need later when interacting with the `KSP`

Use `KSPGetApplicationContext()` to get access to the context at a later time.


## See Also
 [](chapter_ksp), `KSP`, `KSPGetApplicationContext()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/interface/iterativ.c.html#KSPSetApplicationContext">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](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
