:orphan:
# PetscAssert
Assert that a particular condition is true 
## Synopsis
```
#include <petscerror.h>
void PetscAssert(bool cond, MPI_Comm comm, PetscErrorCode ierr, const char *message, ...)
```
Collective; No Fortran Support


## Input Parameters

- ***cond    -*** The boolean condition
- ***comm    -*** The communicator on which the check can be collective on
- ***ierr    -*** A nonzero error code, see include/petscerror.h for the complete list
- ***message -*** Error message in printf format





## Notes
Equivalent to `PetscCheck()` if debugging is enabled, and `PetscAssume(cond)` otherwise.

See `PetscCheck()` for usage and behaviour.

This is needed instead of simply using `assert()` because this correctly handles the collective nature of errors under MPI


## See Also
 `PetscCheck()`, `SETERRQ()`, `PetscError()`, `PetscAssertAbort()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscerror.h.html#PetscAssert">include/petscerror.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscerror.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
