Skip to main content
`Ctrl`+`K`

# PetscOptionsGetScalar

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

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscOptionsGetScalar(PetscOptions options, const char pre[], const char name[], PetscScalar *dvalue, PetscBool *set)

Not Collective

## Input Parameters

- options - options database, use `NULL` for default global database

- pre - string to prepend to each name or `NULL`

- name - the option one is seeking

## Output Parameters

- dvalue - the scalar value to return

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

## Example Usage

A complex number 2+3i must be specified with NO spaces

## Note

If the user does not supply the option `dvalue` is NOT changed. Thus you should ALWAYS initialize `dvalue` if you access it without first checking if the `set` flag is true.

## See Also

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

## Level

beginner

## Location

src/sys/objects/options.c

## Examples

src/ts/tutorials/ex45.c
src/ksp/ksp/tutorials/ex49.c
src/ts/tutorials/ex21.c
src/snes/tutorials/ex58.c
src/dm/impls/stag/tutorials/ex1.c
src/dm/impls/stag/tutorials/ex4.c
src/ksp/ksp/tutorials/ex25.c

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