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().\n\n";
8: #include petscis.h
12: int main(int argc,char **argv)
13: {
14: int i,n,ierr,*indices,rank,size;
15: IS is,newis;
17: PetscInitialize(&argc,&argv,(char*)0,help);
18: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
19: MPI_Comm_size(PETSC_COMM_WORLD,&size);
21: /*
22: Create IS
23: */
24: n = 4 + rank;
25: PetscMalloc(n*sizeof(int),&indices);
26: for (i=0; i<n; i++) {
27: indices[i] = rank + i;
28: }
29: ISCreateGeneral(PETSC_COMM_WORLD,n,indices,&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: }
46: