:orphan:
# PetscShmCommGlobalToLocal
Given a global rank returns the local rank in the shared memory communicator 
## Synopsis
```
#include "petscsys.h"  
PetscErrorCode PetscShmCommGlobalToLocal(PetscShmComm pshmcomm, PetscMPIInt grank, PetscMPIInt *lrank)
```

## Input Parameters

- ***pshmcomm -*** the shared memory communicator object
- ***grank    -*** the global rank



## Output Parameter

- ***lrank -*** the local rank, or `MPI_PROC_NULL` if it does not exist





## Developer Notes
Assumes the pshmcomm->globranks[] is sorted

It may be better to rewrite this to map multiple global ranks to local in the same function call


## See Also
 `PetscShmCommGet()`, `PetscShmCommLocalToGlobal()`, `PetscShmCommGetMpiShmComm()`

## Level
developer

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


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