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