static char help[]= " Test VecScatter with x, y on different communicators\n\n"; #include int main(int argc,char **argv) { PetscInt i,n=5,rstart; PetscScalar *val; const PetscScalar *dat; Vec x,y1,y2; MPI_Comm newcomm; PetscMPIInt nproc,rank; IS ix; VecScatter vscat1,vscat2; PetscFunctionBegin; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&nproc)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCheck(nproc == 2,PETSC_COMM_WORLD,PETSC_ERR_WRONG_MPI_SIZE,"This test must run with exactly two MPI ranks"); /* Create MPI vectors x and y, which are on the same comm (i.e., MPI_IDENT) */ PetscCall(VecCreateMPI(PETSC_COMM_WORLD,n,PETSC_DECIDE,&x)); PetscCall(VecDuplicate(x,&y1)); PetscCall(VecGetOwnershipRange(x,&rstart,NULL)); /* Set x's value locally. x would be {0., 1., 2., ..., 9.} */ PetscCall(VecGetArray(x,&val)); for (i=0; i