# PetscCommDuplicate
Duplicates the communicator only if it is not already a PETSc communicator. 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscCommDuplicate(MPI_Comm comm_in, MPI_Comm *comm_out, PetscMPIInt *first_tag)
```
Collective


## Input Parameter

- ***comm_in -*** Input communicator



## Output Parameters

- ***comm_out -*** Output communicator.  May be comm_in.
- ***first_tag -*** Tag available that has not already been used with this communicator (you may pass in NULL if you do not need a tag)



## Note
PETSc communicators are just regular MPI communicators that keep track of which
tags have been used to prevent tag conflict. If you pass a non-PETSc communicator into
a PETSc creation routine it will attach a private communicator for use in the objects communications.
The internal `MPI_Comm` is used to perform all the MPI calls for PETSc, the outer `MPI_Comm` is a user
level `MPI_Comm` that may be performing communication for the user or other library and so IS NOT used by PETSc.




## See Also
 `PetscObjectGetNewTag()`, `PetscCommGetNewTag()`, `PetscCommDestroy()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/tagm.c.html#PetscCommDuplicate">src/sys/objects/tagm.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex73.c.html">src/ksp/ksp/tutorials/ex73.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/tagm.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)  
