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:   PetscInitialize(&argc,&argv,(char*)0,help);
 13:   PetscRandomCreate(PETSC_COMM_WORLD,&rand);
 14:   PetscObjectGetComm((PetscObject)rand,&comm);
 15:   for (i=0; i<10; i++) {
 16:     PetscCommGetComm(comm,&comms[i]);
 17:   }
 18:   for (i=0; i<5; i++) {
 19:     PetscCommRestoreComm(comm,&comms[i]);
 20:   }
 21:   for (i=0; i<5; i++) {
 22:     PetscCommGetComm(comm,&comms[i]);
 23:   }
 24:   for (i=0; i<10; i++) {
 25:     PetscCommRestoreComm(comm,&comms[i]);
 26:   }
 27:   PetscRandomDestroy(&rand);
 28:   PetscFinalize();
 29:   return 0;
 30: }

 32: /*TEST

 34:    test:
 35:      requires: defined(PETSC_USE_LOG)
 36:      args: -info
 37:      filter: grep Reusing | wc -l

 39: TEST*/