git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8602 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2012-08-10 23:13:26 +00:00
parent 9d3193011b
commit c6878811f0

View File

@ -23,16 +23,14 @@ LMPDPTR = 3
LMPDPTRPTR = 4 LMPDPTRPTR = 4
class lammps: class lammps:
def __init__(self,args=None): def __init__(self,name="",cmdlineargs=None):
# attempt to load parallel library first, serial library next # load liblmp.so by default
# could provide caller a flag to choose which library to load # if name = "g++", load liblmp_g++.so
try: try:
self.lib = CDLL("_lammps.so") if not name: self.lib = CDLL("liblmp.so")
except: else: self.lib = CDLL("liblmp_%s.so" % name)
try:
self.lib = CDLL("_lammps_serial.so")
except: except:
raise OSError,"Could not load LAMMPS dynamic library" raise OSError,"Could not load LAMMPS dynamic library"
@ -41,10 +39,10 @@ class lammps:
# no_mpi call lets LAMMPS use MPI_COMM_WORLD # no_mpi call lets LAMMPS use MPI_COMM_WORLD
# cargs = array of C strings from args # cargs = array of C strings from args
if args: if cmdlineargs:
args.insert(0,"lammps.py") cmdlineargs.insert(0,"lammps.py")
narg = len(args) narg = len(cmdlineargs)
cargs = (c_char_p*narg)(*args) cargs = (c_char_p*narg)(*cmdlineargs)
self.lmp = c_void_p() self.lmp = c_void_p()
self.lib.lammps_open_no_mpi(narg,cargs,byref(self.lmp)) self.lib.lammps_open_no_mpi(narg,cargs,byref(self.lmp))
else: else: