Actual source code: ex26.c

  1: static char help[] = "Tests repeated PetscInitialize/PetscFinalize calls.\n\n";

  3: #include <petscsys.h>

  5: int main(int argc, char **argv)
  6: {
  7:   int i, imax;
  8: #if defined(PETSC_HAVE_ELEMENTAL)
  9:   PetscBool initialized;
 10: #endif

 12: #if defined(PETSC_HAVE_MPIUNI)
 13:   imax = 32;
 14: #else
 15:   imax = 1024;
 16: #endif

 18:   MPI_Init(&argc, &argv);
 19: #if defined(PETSC_HAVE_ELEMENTAL)
 20:   PetscElementalInitializePackage();
 21:   PetscElementalInitialized(&initialized);
 22:   if (!initialized) return 1;
 23: #endif
 24:   for (i = 0; i < imax; ++i) {
 26:     PetscInitialize(&argc, &argv, (char *)0, help);
 27:     PetscFinalize();
 28: #if defined(PETSC_HAVE_ELEMENTAL)
 29:     PetscElementalInitialized(&initialized);
 30:     if (!initialized) return PETSC_ERR_LIB;
 31: #endif
 32:   }
 33: #if defined(PETSC_HAVE_ELEMENTAL)
 34:   PetscElementalFinalizePackage();
 35:   PetscElementalInitialized(&initialized);
 36:   if (initialized) return 1;
 37:   for (i = 0; i < 32; ++i) { /* increasing the upper bound will generate an error in Elemental */
 39:     PetscInitialize(&argc, &argv, (char *)0, help);
 40:     PetscElementalInitialized(&initialized);
 42:     PetscFinalize();
 43:     PetscElementalInitialized(&initialized);
 44:     if (initialized) return PETSC_ERR_LIB;
 45:   }
 46: #endif
 47:   return MPI_Finalize();
 48: }

 50: /*TEST

 52:    test:
 53:       requires: !saws

 55:    test:
 56:       requires: !saws
 57:       suffix: 2
 58:       nsize: 2
 59:       output_file: output/ex26_1.out

 61: TEST*/