Skip to main content
`Ctrl`+`K`

# SNESGetApplicationContext

Gets the user-defined context for the nonlinear solvers set with `SNESGetApplicationContext()` or `SNESSetComputeApplicationContext()`

## Synopsis

    #include "petscsnes.h"
    PetscErrorCode SNESGetApplicationContext(SNES snes, PeCtx ctx)

Not Collective

## Input Parameter

- snes - `SNES` context

## Output Parameter

- ctx - user context

## Fortran Notes

This only works when the context is a Fortran derived type (it cannot be a `PetscObject`) and you must write a Fortran interface definition for this function that tells the Fortran compiler the derived data type that is returned as the `ctx` argument. For example,

      Interface SNESGetApplicationContext
        Subroutine SNESGetApplicationContext(snes,ctx,ierr)
      #include <petsc/finclude/petscsnes.h>
          use petscsnes
          SNES snes
          type(tUsertype), pointer :: ctx
          PetscErrorCode ierr
        End Subroutine
      End Interface SNESGetApplicationContext

The prototype for `ctx` must be

      type(tUsertype), pointer :: ctx

## See Also

SNES: Nonlinear Solvers, `SNESSetApplicationContext()`, `SNESSetComputeApplicationContext()`

## Level

intermediate

## Location

src/snes/interface/snes.c

## Examples

src/snes/tutorials/ex58.c
src/snes/tutorials/ex73f90t.F90
src/snes/tutorials/ex5f90.F90
src/snes/tutorials/ex5f90t.F90

Index of all SNES routines
Table of Contents for all manual pages
Index of all manual pages