From fd1edaf04f777360156a83945f00d7e58cdbe5fe Mon Sep 17 00:00:00 2001 From: "Steven J. Plimpton" Date: Wed, 7 Mar 2018 08:52:46 -0700 Subject: [PATCH 1/2] allow for mpi4py version 2 or 3 in Python wrapper --- python/lammps.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/lammps.py b/python/lammps.py index c895037c00..62ed272d4b 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -46,17 +46,15 @@ class MPIAbortException(Exception): def __str__(self): return repr(self.message) - class lammps(object): # detect if Python is using version of mpi4py that can pass a communicator - has_mpi4py_v2 = False + has_mpi4py = False try: from mpi4py import MPI from mpi4py import __version__ as mpi4py_version - if mpi4py_version.split('.')[0] == '2': - has_mpi4py_v2 = True + if mpi4py_version.split('.')[0] in ['2','3']: has_mpi4py = True except: pass @@ -111,7 +109,9 @@ class lammps(object): # need to adjust for type of MPI communicator object # allow for int (like MPICH) or void* (like OpenMPI) - if lammps.has_mpi4py_v2 and comm != None: + if comm: + if not lammps.has_mpi4py: + raise Exception('Python mpi4py version is not 2 or 3') if lammps.MPI._sizeof(lammps.MPI.Comm) == sizeof(c_int): MPI_Comm = c_int else: From a1bb877d5526130c56d72e7d982cff6c1f7db475 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 7 Mar 2018 11:17:03 -0500 Subject: [PATCH 2/2] correct commented out MPI examples --- python/examples/simple.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/examples/simple.py b/python/examples/simple.py index da07a69997..ff777c8a09 100755 --- a/python/examples/simple.py +++ b/python/examples/simple.py @@ -88,8 +88,6 @@ lmp.command("run 10"); # uncomment if running in parallel via Pypar #print("Proc %d out of %d procs has" % (me,nprocs), lmp) -#pypar.finalize() # uncomment if running in parallel via mpi4py -#print "Proc %d out of %d procs has" % (me,nprocs), lmp -#MPI.Finalize() +#print("Proc %d out of %d procs has" % (me,nprocs), lmp)