Skip to content
Snippets Groups Projects
Commit 7277d735 authored by Patrick Shriwise's avatar Patrick Shriwise
Browse files

Feature: adding detectin of MPI support via libmesh-config

parent ed474bb4
No related branches found
No related tags found
No related merge requests found
import os
from pathlib import Path
import subprocess
try:
from ConfigParser import ConfigParser
......@@ -45,6 +46,18 @@ class PyGriffinConfig():
'of the Griffin executable have failed.')
raise RuntimeError(msg)
# check libMesh configuration for MPI
libmesh_config = self.griffin_dir / 'moose/libmesh/installed/bin/libmesh-config'
out = subprocess.Popen([libmesh_config, '--cxx'], stdout=subprocess.PIPE)
libmesh_config_out = out.stdout.read()
if 'mpi' in libmesh_config_out.decode():
self.mpi_enabled = True
else:
self.mpi_enabled = False
def get(self, *args, **kwargs):
"""
Attempts to get a configuration option from the .rc file.
......@@ -75,6 +88,15 @@ class PyGriffinConfig():
def griffin_exec(self):
return self._griffin_exec
@property
def mpi_enabled(self):
return self._mpi_enabled
@mpi_enabled.setter
def mpi_enabled(self, val):
cv.check_type('MPI Enabled', val, bool)
self._mpi_enabled = val
@griffin_exec.setter
def griffin_exec(self, exec):
cv.check_type('Griffin executable path', exec, (Path, str))
......
......@@ -2,6 +2,7 @@ from numbers import Integral
from pathlib import Path
import subprocess
from typing import Iterable
import warnings
import pygriffin.checkvalue as cv
from pygriffin.config import PyGriffinConfig
......@@ -41,7 +42,12 @@ class PyGriffin:
cmd = []
if self.n_procs > 1:
cmd += ['mpirun', '-n', str(self.n_procs)]
if self.config.mpi_enabled:
cmd += ['mpirun', '-n', str(self.n_procs)]
else:
msg = ("MPI is not enabled for this Griffin executable. "
"The n_procs argument will be ignored.")
warnings.warn(msg)
# add griffin executable to command line
cmd.append(str(self.config.griffin_exec))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment