PETSC_COMM_WORLD — PETSc 3.25.2 documentation

Skip to main content
`Ctrl`+`K`

# PETSC_COMM_WORLD

the equivalent of the `MPI_COMM_WORLD` communicator which represents all the processes that PETSc knows about.

## Notes

By default `PETSC_COMM_WORLD` and `MPI_COMM_WORLD` are identical unless you wish to run PETSc on ONLY a subset of `MPI_COMM_WORLD`. In that case create your new (smaller) communicator, call it, say comm, and set `PETSC_COMM_WORLD` = comm BEFORE calling `PetscInitialize()`, but after `MPI_Init()` has been called.

The value of `PETSC_COMM_WORLD` should never be used or accessed before `PetscInitialize()` is called because it may not have a valid value yet.

## See Also

`PETSC_COMM_SELF`

## Level

beginner

## Location

include/petscsys.h

## Examples

src/dm/tutorials/ex10.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/tutorials/ex21.c
src/dm/label/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex18.c
src/dm/impls/stag/tutorials/ex8.c
src/dm/tutorials/ex20.c
src/dm/tutorials/ex22.c
src/dm/tutorials/ex3.c
src/dm/impls/plex/tutorials/dmplexgetrestoreclosureindices.F90

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