1 static char help[] = "Tests repeated PetscInitialize/PetscFinalize calls.\n\n"; 2 3 #include <petscsys.h> 4 5 int main(int argc, char **argv) 6 { 7 int i,imax; 8 #if defined(PETSC_HAVE_ELEMENTAL) 9 PetscBool initialized; 10 #endif 11 12 #if defined(PETSC_HAVE_MPIUNI) 13 imax = 32; 14 #else 15 imax = 1024; 16 #endif 17 18 PetscCallMPI(MPI_Init(&argc, &argv)); 19 #if defined(PETSC_HAVE_ELEMENTAL) 20 PetscCall(PetscElementalInitializePackage()); 21 PetscCall(PetscElementalInitialized(&initialized)); 22 if (!initialized) return 1; 23 #endif 24 for (i = 0; i < imax; ++i) { 25 PetscCall(PetscInitialize(&argc, &argv, (char*) 0, help)); 26 PetscCall(PetscFinalize()); 27 #if defined(PETSC_HAVE_ELEMENTAL) 28 PetscCall(PetscElementalInitialized(&initialized)); 29 if (!initialized) return PETSC_ERR_LIB; 30 #endif 31 } 32 #if defined(PETSC_HAVE_ELEMENTAL) 33 PetscCall(PetscElementalFinalizePackage()); 34 PetscCall(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 PetscCall(PetscInitialize(&argc, &argv, (char*) 0, help)); 38 PetscCall(PetscElementalInitialized(&initialized)); 39 PetscCheck(initialized,PETSC_COMM_WORLD, PETSC_ERR_LIB, "Uninitialized Elemental"); 40 PetscCall(PetscFinalize()); 41 PetscCall(PetscElementalInitialized(&initialized)); 42 if (initialized) return PETSC_ERR_LIB; 43 } 44 #endif 45 return MPI_Finalize(); 46 } 47 48 /*TEST 49 50 test: 51 requires: !saws 52 53 test: 54 requires: !saws 55 suffix: 2 56 nsize: 2 57 output_file: output/ex26_1.out 58 59 TEST*/ 60