:orphan:
# VecCreateGhostWithArray
Creates a parallel vector with ghost padding on each processor; the caller allocates the array space. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecCreateGhostWithArray(MPI_Comm comm, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[], const PetscScalar array[], Vec *vv)
```
Collective


## Input Parameters

- ***comm -*** the MPI communicator to use
- ***n -*** local vector length
- ***N -*** global vector length (or `PETSC_DETERMINE` to have calculated if `n` is given)
- ***nghost -*** number of local ghost points
- ***ghosts -*** global indices of ghost points (or `NULL` if not needed), these do not need to be in increasing order (sorted)
- ***array -*** the space to store the vector values (as long as n + nghost)



## Output Parameter

- ***vv -*** the global vector representation (without ghost points as part of vector)





## Notes
Use `VecGhostGetLocalForm()` to access the local, ghosted representation
of the vector.

This also automatically sets the `ISLocalToGlobalMapping()` for this vector.


## See Also
 [](ch_vectors), `Vec`, `VecType`, `VecCreate()`, `VecGhostGetLocalForm()`, `VecGhostRestoreLocalForm()`,
`VecCreateGhost()`, `VecCreateSeqWithArray()`, `VecCreateMPIWithArray()`,
`VecCreateGhostBlock()`, `VecCreateGhostBlockWithArray()`, `VecMPISetGhost()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/mpi/pbvec.c.html#VecCreateGhostWithArray">src/vec/vec/impls/mpi/pbvec.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex9.c.html">src/vec/vec/tutorials/ex9.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex9f.F90.html">src/vec/vec/tutorials/ex9f.F90</A><BR>


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


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