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 int i, imax; 7 #if defined(PETSC_HAVE_ELEMENTAL) 8 PetscBool initialized; 9 #endif 10 11 #if defined(PETSC_HAVE_MPIUNI) 12 imax = 32; 13 #else 14 imax = 1024; 15 #endif 16 17 PetscCallMPI(MPI_Init(&argc, &argv)); 18 #if defined(PETSC_HAVE_ELEMENTAL) 19 PetscCall(PetscElementalInitializePackage()); 20 PetscCall(PetscElementalInitialized(&initialized)); 21 if (!initialized) return 1; 22 #endif 23 for (i = 0; i < imax; ++i) { 24 PetscFunctionBeginUser; 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 PetscFunctionBeginUser; 38 PetscCall(PetscInitialize(&argc, &argv, (char *)0, help)); 39 PetscCall(PetscElementalInitialized(&initialized)); 40 PetscCheck(initialized, PETSC_COMM_WORLD, PETSC_ERR_LIB, "Uninitialized Elemental"); 41 PetscCall(PetscFinalize()); 42 PetscCall(PetscElementalInitialized(&initialized)); 43 if (initialized) return PETSC_ERR_LIB; 44 } 45 #endif 46 return MPI_Finalize(); 47 } 48 49 /*TEST 50 51 test: 52 requires: !saws 53 54 test: 55 requires: !saws 56 suffix: 2 57 nsize: 2 58 output_file: output/ex26_1.out 59 60 TEST*/ 61