Skip to main content
`Ctrl`+`K`

# VecCreateGhostBlockWithArray

Creates a parallel vector with ghost padding on each processor; the caller allocates the array space. Indices in the ghost region are based on blocks.

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm comm, PetscInt bs, PetscInt n, PetscInt N, PetscInt nghost, const PetscInt ghosts[], const PetscScalar array[], Vec *vv)

Collective

## Input Parameters

- comm - the MPI communicator to use

- bs - block size

- n - local vector length

- N - global vector length (or `PETSC_DETERMINE` to have calculated if `n` is given)

- nghost - number of local ghost blocks

- ghosts - global indices of ghost blocks (or `NULL` if not needed), counts are by block not by index, these do not need to be in increasing order (sorted)

- array - the space to store the vector values (as long as \(n + nghost*bs\))

## 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.

n is the local vector size (total local size not the number of blocks) while nghost is the number of blocks in the ghost portion, i.e. the number of elements in the ghost portion is bs*nghost

## See Also

Vectors and Parallel Data, `Vec`, `VecType`, `VecCreate()`, `VecGhostGetLocalForm()`, `VecGhostRestoreLocalForm()`, `VecCreateGhost()`, `VecCreateSeqWithArray()`, `VecCreateMPIWithArray()`, `VecCreateGhostWithArray()`, `VecCreateGhostBlock()`, `VecGhostUpdateBegin()`, `VecGhostUpdateEnd()`

## Level

advanced

## Location

src/vec/vec/impls/mpi/pbvec.c

## Examples

src/vec/vec/tutorials/ex14f.F90

Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages