petsc-3.7.1 2016-05-15
Report Typos and Errors

# 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 "petscvec.h"
    PetscErrorCode VecGetArray(Vec x,PetscScalar **a)

Logically Collective on Vec Many br

### Input Parameter

x -the vector Many br

### Output Parameter

a -location to put pointer to the array Many br

### Fortran Note

This routine is used differently from Fortran 77 Many br

       Vec         x

       PetscScalar x_array(1)

       PetscOffset i_x

       PetscErrorCode 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() Many br

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

Many br

### See Also

VecRestoreArray(), VecGetArrayRead(), VecGetArrays(), VecGetArrayF90(), VecGetArrayReadF90(), VecPlaceArray(), VecGetArray2d()

Level:beginner
Location:src/vec/vec/interface/rvector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages src/vec/vec/examples/tutorials/ex3.c.html
src/vec/vec/examples/tutorials/ex6.c.html
src/vec/vec/examples/tutorials/ex9.c.html
src/vec/vec/examples/tutorials/ex18.c.html
src/vec/vec/examples/tutorials/ex19.c.html
src/vec/vec/examples/tutorials/ex21.c.html
src/vec/vec/examples/tutorials/ex4f.F.html
src/vec/is/sf/examples/tutorials/ex2.c.html
src/mat/examples/tutorials/ex4.c.html
src/mat/examples/tutorials/ex12.c.html