Merge pull request #1070 from rbberger/pylammps_mpi_bugfix

Fixes issue #1069
This commit is contained in:
Steve Plimpton 2018-08-22 08:35:52 -06:00 committed by GitHub
commit 25bc74eb21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -173,6 +173,9 @@ class lammps(object):
self.lib.lammps_open(narg,cargs,comm_val,byref(self.lmp)) self.lib.lammps_open(narg,cargs,comm_val,byref(self.lmp))
else: else:
if lammps.has_mpi4py:
from mpi4py import MPI
self.comm = MPI.COMM_WORLD
self.opened = 1 self.opened = 1
if cmdargs: if cmdargs:
cmdargs.insert(0,"lammps.py") cmdargs.insert(0,"lammps.py")
@ -862,6 +865,10 @@ class PyLammps(object):
def run(self, *args, **kwargs): def run(self, *args, **kwargs):
output = self.__getattr__('run')(*args, **kwargs) output = self.__getattr__('run')(*args, **kwargs)
if(lammps.has_mpi4py):
output = self.lmp.comm.bcast(output, root=0)
self.runs += get_thermo_data(output) self.runs += get_thermo_data(output)
return output return output