Actual source code: ex3.c
petsc-3.13.4 2020-08-01
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: {
13: PetscInt i,n,*indices;
14: PetscMPIInt rank;
15: IS is,newis;
17: PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
18: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
20: /*
21: Create IS
22: */
23: n = 4 + rank;
24: PetscMalloc1(n,&indices);
25: for (i=0; i<n; i++) indices[i] = rank + i;
26: ISCreateGeneral(PETSC_COMM_WORLD,n,indices,PETSC_COPY_VALUES,&is);
27: PetscFree(indices);
29: /*
30: Stick them together from all processors
31: */
32: ISAllGather(is,&newis);
34: if (!rank) {
35: ISView(newis,PETSC_VIEWER_STDOUT_SELF);
36: }
38: ISDestroy(&newis);
39: ISDestroy(&is);
40: PetscFinalize();
41: return ierr;
42: }
44: /*TEST
46: test:
48: TEST*/