static char help[]= "Scatters from a parallel vector to a sequential vector. \n\ uses block index sets\n\n"; #include int main(int argc,char **argv) { PetscInt bs=1,n=5,i,low; PetscInt ix0[3] = {5,7,9},iy0[3] = {1,2,4},ix1[3] = {2,3,4},iy1[3] = {0,1,3}; PetscMPIInt size,rank; PetscScalar *array; Vec x,y; IS isx,isy; VecScatter ctx; PetscFunctionBeginUser; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCheck(size >=2,PETSC_COMM_WORLD,PETSC_ERR_WRONG_MPI_SIZE,"Must run more than one processor"); PetscCall(PetscOptionsGetInt(NULL,NULL,"-bs",&bs,NULL)); n = bs*n; /* Create vector x over shared memory */ PetscCall(VecCreate(PETSC_COMM_WORLD,&x)); PetscCall(VecSetSizes(x,n,PETSC_DECIDE)); PetscCall(VecSetFromOptions(x)); PetscCall(VecGetOwnershipRange(x,&low,NULL)); PetscCall(VecGetArray(x,&array)); for (i=0; i