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