PetscBool — PETSc 3.25.4 documentation

Skip to main content
`Ctrl`+`K`

# PetscBool

Logical variable.

## Synopsis

    typedef/*E
       PetscBool3 - Ternary logical variable. Actually an enum in C and a 4 byte integer in Fortran.

       Note:
       Should not be used with the `if (flg)` or `if (!flg)` syntax.

    .seealso: `PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PETSC_BOOL3_TRUE`, `PETSC_BOOL3_FALSE`, `PETSC_BOOL3_UNKNOWN`, `PetscBool3ToBool()`, `PetscBoolToBool3()`
    E*/ {
      PETSC_BOOL3_FALSE   = 0,
      PETSC_BOOL3_TRUE    = 1,
      PETSC_BOOL3_UNKNOWN = -1 /* the value is unknown at the time of query, but might be determined later */
    } PetscBool3;

## Notes

This is a C bool.

Use `MPI_C_BOOL` for communicating with MPI calls in C, C++, and Fortran.

## Fortran Note

This is a `logical(C_BOOL)` with an internal representation that is equivalent to that of a `bool` in C and C++. It typically has a size of 1 byte, in contrast to a default `logical` which has the size of a default integer (typically 4 bytes).

## Developer Note

We should deprecate this definition since there is a native representation in all the languages.

## See Also

`PETSC_TRUE`, `PETSC_FALSE`, `PetscNot()`, `PetscBool3`, `PetscBool3ToBool()`, `PetscBoolToBool3()`

## Level

beginner

## Location

include/petscsystypes.h

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