PetscOptionsString — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# PetscOptionsString

Gets the string value for a particular option in the database.

## Synopsis

    #include <petscoptions.h>
    PetscErrorCode PetscOptionsString(const char opt[], const char text[], const char man[], const char currentvalue[], char value[], size_t len, PetscBool *set)

Logically Collective on the communicator passed in `PetscOptionsBegin()`

## Input Parameters

- opt - option name

- text - short string that describes the option

- man - manual page with additional information on option

- currentvalue - the current value; caller is responsible for setting this value correctly. This is not used to set value

- len - length of the result string including null terminator

## Output Parameters

- value - the value to return

- set - `PETSC_TRUE` if found, else `PETSC_FALSE`

## Notes

Must be used between a `PetscOptionsBegin()` and a `PetscOptionsEnd()`

If the user provided no string (for example `-optionname` `-someotheroption`) `set` is set to `PETSC_TRUE` (and the string is filled with nulls).

If the user does not supply the option at all `value` is NOT changed. Thus you should ALWAYS initialize `value` if you access it without first checking that `set` is `PETSC_TRUE`.

The `currentvalue` passed into this routine does not get transferred to the output `value` variable automatically.

## See Also

`PetscOptionsGetReal()`, `PetscOptionsHasName()`, `PetscOptionsGetString()`, `PetscOptionsGetInt()`, `PetscOptionsGetIntArray()`, `PetscOptionsGetRealArray()`, `PetscOptionsGetBool()`, `PetscOptionsInt()`, `PetscOptionsReal()`, `PetscOptionsBool()`, `PetscOptionsName()`, `PetscOptionsBegin()`, `PetscOptionsEnd()`, `PetscOptionsHeadBegin()`, `PetscOptionsStringArray()`, `PetscOptionsRealArray()`, `PetscOptionsScalar()`, `PetscOptionsBoolGroupBegin()`, `PetscOptionsBoolGroup()`, `PetscOptionsBoolGroupEnd()`, `PetscOptionsFList()`, `PetscOptionsEList()`

## Level

beginner

## Location

include/petscoptions.h

## Examples

src/dm/impls/plex/tutorials/ex5.c
src/ksp/ksp/tutorials/ex35.cxx
src/dm/impls/plex/tutorials/ex19.c
src/snes/tutorials/ex15.c
src/dm/impls/forest/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex16.c
src/ksp/ksp/tutorials/ex36.cxx
src/dm/impls/plex/tutorials/ex15.c
src/dm/label/tutorials/ex1.c
src/ksp/ksp/tutorials/ex10.c

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