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;
17: PetscInitialize(&argc, &argv, (char *)0, help);
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 == 0) ISView(newis, PETSC_VIEWER_STDOUT_SELF);
36: ISDestroy(&newis);
37: ISDestroy(&is);
38: PetscFinalize();
39: return 0;
40: }
42: /*TEST
44: test:
46: TEST*/