:orphan:
# PetscGatherNumberOfMessages
Computes the number of messages an MPI rank expects to receive during a neighbor communication 
## Synopsis
```
#include "petscsys.h"  
PetscErrorCode PetscGatherNumberOfMessages(MPI_Comm comm, const PetscMPIInt iflags[], const PetscMPIInt ilengths[], PetscMPIInt *nrecvs)
```
Collective


## Input Parameters

- ***comm     -*** Communicator
- ***iflags   -*** an array of integers of length sizeof(comm). A '1' in `ilengths`[i] represent a
message from current node to ith node. Optionally `NULL`
- ***ilengths -*** Non zero ilengths[i] represent a message to i of length `ilengths`[i].
Optionally `NULL`.



## Output Parameter

- ***nrecvs    -*** number of messages received





## Notes
With this info, the correct message lengths can be determined using
`PetscGatherMessageLengths()`

Either `iflags` or `ilengths` should be provided.  If `iflags` is not
provided (`NULL`) it can be computed from `ilengths`. If `iflags` is
provided, `ilengths` is not required.


## See Also
 `PetscGatherMessageLengths()`, `PetscGatherMessageLengths2()`, `PetscCommBuildTwoSided()`

## Level
developer

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


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


[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)  
