# VecRestoreArray

Restores a vector after VecGetArray() has been called. Not Collective

### Synopsis

    PetscErrorCode VecRestoreArray(Vec x,PetscScalar *a[])

### Input Parameters

| x | - the vector
| a | - location of pointer to array obtained from VecGetArray()

### Notes

For regular PETSc vectors this routine does not involve any copies. For any special vectors that do not store local vector data in a contiguous array, this routine will copy the data back into the underlying vector data structure from the array obtained with VecGetArray().

This routine actually zeros out the a pointer. This is to prevent accidental us of the array after it has been restored. If you pass null for a it will not zero the array pointer a.

### Fortran Note

This routine is used differently from Fortran 77

       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)

See the Fortran chapter of the users manual and petsc/src/snes/examples/tutorials/ex5f.F for details. For Fortran 90 see VecRestoreArrayF90()

### See Also

VecGetArray(), VecRestoreArrays(), VecRestoreArrayF90(), VecPlaceArray(), VecRestoreArray2d()

Level:beginner
Location:src/vec/interface/vector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages src/vec/examples/tutorials/ex3.c.html
src/vec/examples/tutorials/ex6.c.html
src/vec/examples/tutorials/ex9.c.html
src/vec/examples/tutorials/ex13.c.html
src/vec/examples/tutorials/ex4f.F.html
src/vec/examples/tutorials/ex4f90.F.html
src/mat/examples/tutorials/ex4.c.html
src/ksp/examples/tutorials/ex10.c.html
src/ksp/examples/tutorials/ex11.c.html
src/ksp/examples/tutorials/ex27.c.html