# PetscSequentialPhaseBegin

Begins a sequential section of code.

### Synopsis

    #include "petsc.h"
    PetscErrorCode PETSC_DLLEXPORT PetscSequentialPhaseBegin(MPI_Comm comm,int ng)

Collective on MPI_Comm

### Input Parameters

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

### C++ variants

| PetscSequentialPhaseBegin(void) |  | -> |  | PetscSequentialPhaseBegin(PETSC_COMM_WORLD,1)
| PetscSequentialPhaseBegin(MPI_Comm comm) |  | -> |  | PetscSequentialPhaseBegin(comm,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

          PetscSequentialPhaseBegin(comm, 1);
          <code to be executed sequentially>
          PetscSequentialPhaseEnd(comm, 1);

Often, the sequential code contains output statements (e.g., printf) to be executed. Note that you may need to flush the I/O buffers before calling PetscSequentialPhaseEnd(). Also, note that some systems do not propagate I/O in any order to the controling terminal (in other words, even if you flush the output, you may not get the data in the order that you want).

### See Also

PetscSequentialPhaseEnd()

Level:intermediate
Location:src/sys/src/utils/mpiu.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/vec/examples/tutorials/ex17.c.html