Actual source code: ex3.c
1: /*$Id: ex3.c,v 1.18 2001/04/10 19:34:49 bsmith Exp $*/
2: /*
3: Tests ISAllGather()
4: */
6: static char help[] = "Tests ISAllGather().nn";
8: #include petscis.h
10: int main(int argc,char **argv)
11: {
12: int i,n,ierr,*indices,rank,size;
13: IS is,newis;
15: PetscInitialize(&argc,&argv,(char*)0,help);
16: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
17: MPI_Comm_size(PETSC_COMM_WORLD,&size);
19: /*
20: Create IS
21: */
22: n = 4 + rank;
23: PetscMalloc(n*sizeof(int),&indices);
24: for (i=0; i<n; i++) {
25: indices[i] = rank + i;
26: }
27: ISCreateGeneral(PETSC_COMM_WORLD,n,indices,&is);
28: PetscFree(indices);
30: /*
31: Stick them together from all processors
32: */
33: ISAllGather(is,&newis);
35: if (!rank) {
36: ISView(newis,PETSC_VIEWER_STDOUT_SELF);
37: }
39: ISDestroy(newis);
40: ISDestroy(is);
41: PetscFinalize();
42: return 0;
43: }
44: