Actual source code: ex3.c
petsc-3.7.3 2016-07-24
1: /*
2: Tests ISAllGather()
3: */
5: static char help[] = "Tests ISAllGather().\n\n";
7: #include <petscis.h>
8: #include <petscviewer.h>
12: int main(int argc,char **argv)
13: {
15: PetscInt i,n,*indices;
16: PetscInt rank,size;
17: IS is,newis;
19: PetscInitialize(&argc,&argv,(char*)0,help);
20: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
21: MPI_Comm_size(PETSC_COMM_WORLD,&size);
23: /*
24: Create IS
25: */
26: n = 4 + rank;
27: PetscMalloc1(n,&indices);
28: for (i=0; i<n; i++) indices[i] = rank + i;
29: ISCreateGeneral(PETSC_COMM_WORLD,n,indices,PETSC_COPY_VALUES,&is);
30: PetscFree(indices);
32: /*
33: Stick them together from all processors
34: */
35: ISAllGather(is,&newis);
37: if (!rank) {
38: ISView(newis,PETSC_VIEWER_STDOUT_SELF);
39: }
41: ISDestroy(&newis);
42: ISDestroy(&is);
43: PetscFinalize();
44: return 0;
45: }