# VecGetArrayWriteAndMemType
Like VecGetArrayWrite(), but if this is a device vector it will aways return a device pointer to the device memory that contains this processor's portion of the vector data. 
## Synopsis
```
#include "petscvec.h"   
PetscErrorCode VecGetArrayWriteAndMemType(Vec x, PetscScalar **a, PetscMemType *mtype)
```
Not Collective


## Input Parameter

- ***x -*** the vector



## Output Parameters

- ***a -*** the array
- ***mtype -*** memory type of the array





## Notes
The array must be returned using a matching call to VecRestoreArrayWriteAndMemType(), where it will label the device memory as most recent.


## See Also
 `VecRestoreArrayWriteAndMemType()`, `VecGetArrayReadAndMemType()`, `VecGetArrayAndMemType()`, `VecGetArray()`, `VecRestoreArray()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`,

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/interface/rvector.c.html#VecGetArrayWriteAndMemType">src/vec/vec/interface/rvector.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx.html#VecGetArrayWriteAndMemType_SeqKokkos">VecGetArrayWriteAndMemType_SeqKokkos in src/vec/vec/impls/seq/kokkos/veckok.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqcuda/veccuda.c.html#VecGetArrayWriteAndMemType_SeqCUDA">VecGetArrayWriteAndMemType_SeqCUDA in src/vec/vec/impls/seq/seqcuda/veccuda.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/impls/seq/seqhip/vechip.hip.c.html#VecGetArrayWriteAndMemType_SeqHIP">VecGetArrayWriteAndMemType_SeqHIP in src/vec/vec/impls/seq/seqhip/vechip.hip.c</A><BR>


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


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