# VecScatterCreate

Creates a vector scatter context.

### Synopsis

    #include "petscvec.h"
    int VecScatterCreate(Vec xin,IS ix,Vec yin,IS iy,VecScatter *newctx)

Collective on Vec

### Input Parameters

| xin | - a vector that defines the shape (parallel data layout of the vector) of vectors from which we scatter
| yin | - a vector that defines the shape (parallel data layout of the vector) of vectors to which we scatter
| ix | - the indices of xin to scatter
| iy | - the indices of yin to hold results

### Output Parameter

newctx -location to store the new scatter context

### Options Database Keys

| -vecscatter_merge | - Merges scatter send and receive (may offer better performance with some MPIs)
| -vecscatter_ssend | - Uses MPI_Ssend_init() instead of MPI_Send_init() (may offer better performance with some MPIs)
| -vecscatter_sendfirst | - Posts sends before receives (may offer better performance with some MPIs)
| -vecscatter_rr | - use ready receiver mode for MPI sends in scatters (rarely used)
| -vecscatter_packtogether | - Pack all messages before sending, receive all messages before unpacking

### Notes

In calls to VecScatter() you can use different vectors than the xin and yin you used above; BUT they must have the same parallel data layout, for example, they could be obtained from VecDuplicate(). A VecScatter context CANNOT be used in two or more simultaneous scatters; that is you cannot call a second VecScatterBegin() with the same scatter context until the VecScatterEnd() has been called on the first VecScatterBegin(). In this case a separate VecScatter is needed for each concurrent scatter.

### See Also

VecScatterDestroy()

Level:intermediate
Location: src/vec/utils/vscat.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/dm/ao/examples/tutorials/ex2.c.html