# DMDAGetNeighbors
Gets an array containing the MPI rank of all the current processes neighbors. 
## Synopsis
```
#include "petscdmda.h"   
PetscErrorCode DMDAGetNeighbors(DM da, const PetscMPIInt *ranks[])
```
Not Collective


## Input Parameter

- ***da -*** the `DMDA` object



## Output Parameters

- ***ranks -*** the neighbors ranks, stored with the x index increasing most rapidly.
this process itself is in the list





## Notes
In 2d the array is of length 9, in 3d of length 27

Not supported in 1d

Do not free the array, it is freed when the `DMDA` is destroyed.


## Fortran Note
In fortran you must pass in an array of the appropriate length.


## See Also
 `DMDA`, `DM`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/da.c.html#DMDAGetNeighbors">src/dm/impls/da/da.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/impls/da/da.c)


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