VecGetArray

Returns a pointer to a contiguous array that contains this processor's portion of the vector data. For the standard PETSc vectors, VecGetArray() returns a pointer to the local data array and does not use any copies. If the underlying vector data is not stored in a contiquous array this routine will copy the data to a contiquous array and return a pointer to that. You MUST call VecRestoreArray() when you no longer need access to the array.

Synopsis

#include "vec.h" 
int VecGetArray(Vec x,Scalar *a[])
Not Collective

Input Parameter

x -the vector

Output Parameter

a -location to put pointer to the array

Fortran Note

This routine is used differently from Fortran 77
   Vec         x
   Scalar      x_array(1)
   PetscOffset i_x
   int         ierr
      call VecGetArray(x,x_array,i_x,ierr)

  Access first local entry in vector with
     value = x_array(i_x + 1)

     ...... other code
      call VecRestoreArray(x,x_array,i_x,ierr)
For Fortran 90 see VecGetArrayF90()

See the Fortran chapter of the users manual and petsc/src/snes/examples/tutorials/ex5f.F for details.

Keywords

vector, get, array

See Also

VecRestoreArray(), VecGetArrays(), VecGetArrayF90(), VecPlaceArray()

Examples

src/vec/examples/tutorials/ex4f.F
src/vec/examples/tutorials/ex9.c
src/vec/examples/tutorials/ex13.c
src/snes/examples/tutorials/ex5.c

Level:beginner
Location:src/vec/interface/vector.c
Vector Index
Table of Contents