:orphan:
# PCFieldSplitGetSubKSP
Gets the `KSP` contexts for all splits
## Synopsis
```
#include "petscpc.h"
PetscErrorCode PCFieldSplitGetSubKSP(PC pc, PetscInt *n, KSP *subksp[])
```
Collective
## Input Parameter
- ***pc -*** the preconditioner context
## Output Parameters
- ***n -*** the number of splits
- ***subksp -*** the array of `KSP` contexts
## Notes
After `PCFieldSplitGetSubKSP()` the array of `KSP`s is to be freed by the user with `PetscFree()`
(not the `KSP`, just the array that contains them).
You must call `PCSetUp()` before calling `PCFieldSplitGetSubKSP()`.
If the fieldsplit is of type `PC_COMPOSITE_SCHUR`, it returns the `KSP` object used inside the
Schur complement and the `KSP` object used to iterate over the Schur complement.
To access all the `KSP` objects used in `PC_COMPOSITE_SCHUR`, use `PCFieldSplitSchurGetSubKSP()`.
If the fieldsplit is of type `PC_COMPOSITE_GKB`, it returns the `KSP` object used to solve the
inner linear system defined by the matrix H in each loop.
## Fortran Usage
You must pass in a `KSP` array that is large enough to contain all the `KSP`s.
You can call `PCFieldSplitGetSubKSP`(pc,n,`PETSC_NULL_KSP`,ierr) to determine how large the
`KSP` array must be.
## Developer Note
There should be a `PCFieldSplitRestoreSubKSP()` instead of requiring the user to call `PetscFree()`
The Fortran interface should be modernized to return directly the array of values.
## See Also
[](sec_block_matrices), `PC`, `PCFIELDSPLIT`, `PCFieldSplitSetFields()`, `PCFieldSplitSetIS()`, `PCFieldSplitSchurGetSubKSP()`
## Level
advanced
## Location
src/ksp/pc/impls/fieldsplit/fieldsplit.c
## Examples
src/ksp/ksp/tutorials/ex43.c
src/ksp/ksp/tutorials/ex70.c
src/snes/tutorials/ex70.c
## Implementations
PCFieldSplitGetSubKSP_FieldSplit in src/ksp/pc/impls/fieldsplit/fieldsplit.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/pc/impls/fieldsplit/fieldsplit.c)
[Index of all PC routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)