Actual source code: ex3.c
1: /*
2: Tests ISAllGather()
3: */
5: static char help[] = "Tests ISAllGather().\n\n";
7: #include petscis.h
11: int main(int argc,char **argv)
12: {
14: PetscInt i,n,*indices;
15: PetscInt rank,size;
16: IS is,newis;
18: PetscInitialize(&argc,&argv,(char*)0,help);
19: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
20: MPI_Comm_size(PETSC_COMM_WORLD,&size);
22: /*
23: Create IS
24: */
25: n = 4 + rank;
26: PetscMalloc(n*sizeof(PetscInt),&indices);
27: for (i=0; i<n; i++) {
28: indices[i] = rank + i;
29: }
30: ISCreateGeneral(PETSC_COMM_WORLD,n,indices,&is);
31: PetscFree(indices);
33: /*
34: Stick them together from all processors
35: */
36: ISAllGather(is,&newis);
38: if (!rank) {
39: ISView(newis,PETSC_VIEWER_STDOUT_SELF);
40: }
42: ISDestroy(newis);
43: ISDestroy(is);
44: PetscFinalize();
45: return 0;
46: }
47: