# VecScatterCreateToAll
Creates a vector and a scatter context that copies all vector values to each processor 
## Synopsis
```
#include "petscsf.h" 
PetscErrorCode VecScatterCreateToAll(Vec vin, VecScatter *ctx, Vec *vout)
```
Collective


## Input Parameter

- ***vin  -*** an `MPIVEC`



## Output Parameters

- ***ctx -*** scatter context
- ***vout -*** output `SEQVEC` that is large enough to scatter into





## Usage
```none
        VecScatterCreateToAll(vin,&ctx,&vout);

        // scatter as many times as you need
        VecScatterBegin(ctx,vin,vout,INSERT_VALUES,SCATTER_FORWARD);
        VecScatterEnd(ctx,vin,vout,INSERT_VALUES,SCATTER_FORWARD);

        // destroy scatter context and local vector when no longer needed
        VecScatterDestroy(&ctx);
        VecDestroy(&vout);
```



## Notes
vout may be NULL [`PETSC_NULL_VEC` from fortran] if you do not
need to have it created

Do NOT create a vector and then pass it in as the final argument vout! vout is created by this routine
automatically (unless you pass NULL in for that argument if you do not need it).


## See Also
 [](sec_scatter), `VecScatter`, `VecScatterCreate()`, `VecScatterCreateToZero()`, `VecScatterBegin()`, `VecScatterEnd()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/interface/vscat.c.html#VecScatterCreateToAll">src/vec/is/sf/interface/vscat.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex43.c.html">src/ksp/ksp/tutorials/ex43.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex49.c.html">src/ksp/ksp/tutorials/ex49.c.html</A><BR>


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


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