Actual source code: ex57.c
2: static char help[] = "Tests PetscCommGetComm().\n";
4: #include <petscsys.h>
6: int main(int argc, char **argv)
7: {
8: MPI_Comm comms[10], comm;
9: PetscInt i;
10: PetscRandom rand;
12: PetscFunctionBeginUser;
13: PetscCall(PetscInitialize(&argc, &argv, (char *)0, help));
14: PetscCall(PetscRandomCreate(PETSC_COMM_WORLD, &rand));
15: PetscCall(PetscObjectGetComm((PetscObject)rand, &comm));
16: for (i = 0; i < 10; i++) PetscCall(PetscCommGetComm(comm, &comms[i]));
17: for (i = 0; i < 5; i++) PetscCall(PetscCommRestoreComm(comm, &comms[i]));
18: for (i = 0; i < 5; i++) PetscCall(PetscCommGetComm(comm, &comms[i]));
19: for (i = 0; i < 10; i++) PetscCall(PetscCommRestoreComm(comm, &comms[i]));
20: PetscCall(PetscRandomDestroy(&rand));
21: PetscCall(PetscFinalize());
22: return 0;
23: }
25: /*TEST
27: test:
28: requires: defined(PETSC_USE_LOG)
29: args: -info
30: filter: grep Reusing | wc -l
32: TEST*/