Skip to main content
`Ctrl`+`K`

# VecCreateMPI

Creates a parallel vector.

## Synopsis

    #include "petscvec.h"
    PetscErrorCode VecCreateMPI(MPI_Comm comm, PetscInt n, PetscInt N, Vec *v)

Collective

## Input Parameters

- comm - the MPI communicator to use

- n - local vector length (or `PETSC_DECIDE` to have calculated if `N` is given)

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

## Output Parameter

- v - the vector

## Notes

It is recommended to use `VecCreateFromOptions()` instead of this routine

Use `VecDuplicate()` or `VecDuplicateVecs()` to form additional vectors of the same type as an existing vector.

If `n` is not `PETSC_DECIDE`, then the value determines the `PetscLayout` of the vector and the ranges returned by `VecGetOwnershipRange()` and `VecGetOwnershipRanges()`

## See Also

Vectors and Parallel Data, `Vec`, `VecType`, `VecCreateSeq()`, `VecCreate()`, `VecDuplicate()`, `VecDuplicateVecs()`, `VecCreateGhost()`, `VecCreateMPIWithArray()`, `VecCreateGhostWithArray()`, `VecMPISetGhost()`, `PetscLayout`, `VecGetOwnershipRange()`, `VecGetOwnershipRanges()`

## Level

intermediate

## Location

src/vec/vec/impls/mpi/vmpicr.c

## Examples

src/tao/bound/tutorials/plate2.c
src/ts/tutorials/ex30.c
src/tao/bound/tutorials/plate2f.F90

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