:orphan:
# VecGetArrayAligned
FORTRAN only. Forces alignment of vector arrays so that arrays of derived types may be used. 
## Synopsis
```
VecGetArrayAligned(PetscErrorCode ierr)
```
Not Collective




## Notes
Allows code such as

```none
     type  :: Field
        PetscScalar :: p1
        PetscScalar :: p2
      end type Field

      type(Field)       :: lx_v(0:1)

      call VecGetArray(localX, lx_v, lx_i, ierr)
      call InitialGuessLocal(lx_v(lx_i/2), ierr)

      subroutine InitialGuessLocal(a,ierr)
      type(Field)     :: a(*)
```


If you have not called `VecGetArrayAligned()` the code may generate incorrect data
or crash.

lx_i needs to be divided by the number of entries in Field (in this case 2)

You do NOT need `VecGetArrayAligned()` if lx_v and a are arrays of `PetscScalar`


## See Also
 `VecGetArray()`, `VecGetArrayF90()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/interface/ftn-custom/zvectorf.c.html#VecGetArrayAligned">src/vec/vec/interface/ftn-custom/zvectorf.c</A>


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


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