:orphan:
# PetscGatherMessageLengths2
Computes info about messages that a MPI rank will receive, including (from-id,length) pairs for each message. Same functionality as `PetscGatherMessageLengths()` except it takes TWO ilenths and output TWO olengths. 
## Synopsis
```
#include "petscsys.h"  
PetscErrorCode PetscGatherMessageLengths2(MPI_Comm comm, PetscMPIInt nsends, PetscMPIInt nrecvs, const PetscMPIInt ilengths1[], const PetscMPIInt ilengths2[], PetscMPIInt **onodes, PetscMPIInt **olengths1, PetscMPIInt **olengths2)
```
Collective


## Input Parameters

- ***comm      -*** Communicator
- ***nsends    -*** number of messages that are to be sent.
- ***nrecvs    -*** number of messages being received
- ***ilengths1 -*** first array of integers of length sizeof(comm)
- ***ilengths2 -*** second array of integers of length sizeof(comm)



## Output Parameters

- ***onodes    -*** list of ranks from which messages are expected
- ***olengths1 -*** first corresponding message lengths
- ***olengths2 -*** second  message lengths





## Notes
With this info, the correct `MPI_Irecv()` can be posted with the correct
from-id, with a buffer with the right amount of memory required.

The calling function should `PetscFree()` the memory in `onodes` and `olengths`

To determine `nrecvs`, one can use `PetscGatherNumberOfMessages()`


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

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/utils/mpimesg.c.html#PetscGatherMessageLengths2">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)  
