Commit fa4ca62a authored by Spencer Sherwin's avatar Spencer Sherwin
Browse files

Merge branch 'fix/petsc-finalize' into 'master'

Fix/petsc finalize

This MR fixes the issue on latest OpenMPI (as found on Fedora 21) which produces errors when using MPI that MPI_Attr_get() function is called after MPI_Finalize(). This is because we were previously not calling PetscFinalize(). The PetscInitialize and PetscFinalize calls have been moved to CommMpi to ensure they are called at the right time and in the right order.

Dave should probably review this, since he implemented the PETSc stuff.

See merge request !456
parents d8fcfec5 5ea4237a
......@@ -447,5 +447,10 @@ IF( NEKTAR_USE_BLAS_LAPACK )
ENDIF( NEKTAR_USE_BLAS_LAPACK )
IF( NEKTAR_USE_PETSC )
TARGET_LINK_LIBRARIES(LibUtilities LINK_PRIVATE ${PETSC_LIBRARIES})
ADD_DEPENDENCIES(LibUtilities petsc-3.5.2)
ENDIF( NEKTAR_USE_PETSC )
INSTALL(FILES ${ExpressionTemplates} DESTINATION ${NEKTAR_INCLUDE_DIR}/ExpressionTemplates COMPONENT dev)
INSTALL(DIRECTORY ./ DESTINATION ${NEKTAR_INCLUDE_DIR}/LibUtilities COMPONENT dev FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
......@@ -33,6 +33,10 @@
//
///////////////////////////////////////////////////////////////////////////////
#ifdef NEKTAR_USING_PETSC
#include "petscsys.h"
#endif
#include <LibUtilities/Communication/CommMpi.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
......@@ -66,6 +70,10 @@ namespace Nektar
MPI_Comm_size( m_comm, &m_size );
MPI_Comm_rank( m_comm, &m_rank );
#ifdef NEKTAR_USING_PETSC
PetscInitializeNoArguments();
#endif
m_type = "Parallel MPI";
}
......@@ -107,6 +115,9 @@ namespace Nektar
*/
void CommMpi::v_Finalise()
{
#ifdef NEKTAR_USING_PETSC
PetscFinalize();
#endif
MPI_Finalize();
}
......
......@@ -55,8 +55,10 @@ namespace Nektar
const boost::shared_ptr<AssemblyMap> &pLocToGloMap)
: GlobalLinSys(pKey, pExp, pLocToGloMap)
{
// Initialise PETSc
PetscInitialize(0, NULL, NULL, NULL);
// 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();
// Create matrix
MatCreate(PETSC_COMM_WORLD, &m_matrix);
......
Markdown is supported
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