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) {
 25:     PetscInitialize(&argc, &argv, (char*) 0, help);
 26:     PetscFinalize();
 27: #if defined(PETSC_HAVE_ELEMENTAL)
 28:     PetscElementalInitialized(&initialized);
 29:     if (!initialized) return PETSC_ERR_LIB;
 30: #endif
 31:   }
 32: #if defined(PETSC_HAVE_ELEMENTAL)
 33:   PetscElementalFinalizePackage();
 34:   PetscElementalInitialized(&initialized);
 35:   if (initialized) return 1;
 36:   for (i = 0; i < 32; ++i) { /* increasing the upper bound will generate an error in Elemental */
 37:     PetscInitialize(&argc, &argv, (char*) 0, help);
 38:     PetscElementalInitialized(&initialized);
 40:     PetscFinalize();
 41:     PetscElementalInitialized(&initialized);
 42:     if (initialized) return PETSC_ERR_LIB;
 43:   }
 44: #endif
 45:   return MPI_Finalize();
 46: }

 48: /*TEST

 50:    test:
 51:       requires: !saws

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

 59: TEST*/