# PetscSequentialPhaseBegin
Begins a sequential section of code. 
## Synopsis
```
#include "petscsys.h"  
PetscErrorCode PetscSequentialPhaseBegin(MPI_Comm comm, int ng)
```
Collective


## Input Parameters

- ***comm -*** Communicator to sequentialize.
- ***ng   -*** Number in processor group.  This many processes are allowed to execute
at the same time (usually 1)





## Notes
`PetscSequentialPhaseBegin()` and `PetscSequentialPhaseEnd()` provide a
way to force a section of code to be executed by the processes in
rank order.  Typically, this is done with
```none
      PetscSequentialPhaseBegin(comm, 1);
      <code to be executed sequentially>
      PetscSequentialPhaseEnd(comm, 1);
```


You should use `PetscSynchronizedPrintf()` to ensure output between MPI ranks is properly order and not these routines.


## See Also
 `PetscSequentialPhaseEnd()`, `PetscSynchronizedPrintf()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/utils/mpiu.c.html#PetscSequentialPhaseBegin">src/sys/utils/mpiu.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/utils/mpiu.c)


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