Commit 0e54ff7f authored by Dave Moxey's avatar Dave Moxey Committed by Spencer Sherwin
Browse files

Hopefully fix finalize problem on snow leopard

parent 3592ddec
......@@ -72,10 +72,15 @@ namespace Nektar
->GetSolverInfoAsEnum<PETScMatMult>(
"PETScMatMult");
// Check PETSc is initialized
// For some reason, this is needed on OS X as logging is not
// initialized properly in the call within CommMpi.
PetscInitializeNoArguments();
// Check PETSc is initialized. For some reason, this is needed on
// OS X as logging is not initialized properly in the call within
// CommMpi.
PetscBool isInitialized;
PetscInitialized(&isInitialized);
if (!isInitialized)
{
PetscInitializeNoArguments();
}
// Create matrix
MatCreate(PETSC_COMM_WORLD, &m_matrix);
......@@ -94,6 +99,17 @@ namespace Nektar
PetscBool isFinalized;
PetscFinalized(&isFinalized);
// Sometimes, PetscFinalized returns false when (in fact) CommMpi's
// Finalise routine has been called. We therefore also need to check
// whether MPI has been finalised. This might arise from the
// additional call to PetscInitializeNoArguments in the constructor
// above.
#ifdef NEKTAR_USE_MPI
int mpiFinal = 0;
MPI_Finalized(&mpiFinal);
isFinalized = isFinalized || mpiFinal ? PETSC_TRUE : PETSC_FALSE;
#endif
if (!isFinalized)
{
KSPDestroy(&m_ksp);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment