git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8656 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,25 +1,35 @@
|
||||
#!/usr/local/bin/python
|
||||
|
||||
# copy lammps.py and LAMMPS shared library src/liblmp.so to
|
||||
# Python site-packages dir
|
||||
# copy LAMMPS shared library src/liblmp.so and lammps.py to system dirs
|
||||
# Syntax: python install.py [libdir] [pydir]
|
||||
# libdir = target dir for src/liblammps.so, default = /usr/local/lib
|
||||
# pydir = target dir for lammps.py, default = Python site-packages dir
|
||||
|
||||
import sys,commands
|
||||
|
||||
# find this Python's site-packages dir in sys.path list
|
||||
if len(sys.argv) > 3:
|
||||
print "Syntax: python install.py [libdir] [pydir]"
|
||||
sys.exit()
|
||||
|
||||
paths = sys.path
|
||||
for i,path in enumerate(paths):
|
||||
if len(sys.argv) >= 2: libdir = sys.argv[1]
|
||||
else: libdir = "/usr/local/lib"
|
||||
|
||||
if len(sys.argv) == 3: pydir = sys.argv[2]
|
||||
else:
|
||||
paths = sys.path
|
||||
for i,path in enumerate(paths):
|
||||
index = path.rfind("site-packages")
|
||||
if index < 0: continue
|
||||
if index == len(path) - len("site-packages"): break
|
||||
sitedir = paths[i]
|
||||
pydir = paths[i]
|
||||
|
||||
str = "cp ../python/lammps.py %s" % sitedir
|
||||
str = "cp ../src/liblammps.so %s" % libdir
|
||||
print str
|
||||
outstr = commands.getoutput(str)
|
||||
if len(outstr.strip()): print outstr
|
||||
|
||||
str = "cp ../src/liblmp.so %s" % sitedir
|
||||
str = "cp ../python/lammps.py %s" % pydir
|
||||
print str
|
||||
outstr = commands.getoutput(str)
|
||||
if len(outstr.strip()): print outstr
|
||||
|
||||
|
||||
@ -19,12 +19,12 @@ from ctypes import *
|
||||
class lammps:
|
||||
def __init__(self,name="",cmdargs=None):
|
||||
|
||||
# load liblmp.so by default
|
||||
# if name = "g++", load liblmp_g++.so
|
||||
# load liblammps.so by default
|
||||
# if name = "g++", load liblammps_g++.so
|
||||
|
||||
try:
|
||||
if not name: self.lib = CDLL("liblmp.so")
|
||||
else: self.lib = CDLL("liblmp_%s.so" % name)
|
||||
if not name: self.lib = CDLL("liblammps.so")
|
||||
else: self.lib = CDLL("liblammps_%s.so" % name)
|
||||
except:
|
||||
raise OSError,"Could not load LAMMPS dynamic library"
|
||||
|
||||
|
||||
@ -85,6 +85,9 @@ $(EXE): $(OBJ)
|
||||
lib: $(OBJ)
|
||||
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
||||
|
||||
#shlib: $(OBJ)
|
||||
# $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
||||
|
||||
shlib: $(OBJ)
|
||||
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
|
||||
$(OBJ) $(EXTRA_LIB) $(LIB)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -389,15 +389,15 @@ void lammps_gather_atoms(void *ptr, char *name,
|
||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||
|
||||
int i,j,offset;
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
|
||||
// copy = Natom length vector of per-atom values
|
||||
// use atom ID to insert each atom's values into copy
|
||||
// MPI_Allreduce with MPI_SUM to merge into data, ordered by atom ID
|
||||
|
||||
if (type == 0) {
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
int *vector;
|
||||
int **array;
|
||||
int *vector = NULL;
|
||||
int **array = NULL;
|
||||
if (count == 1) vector = (int *) vptr;
|
||||
else array = (int **) vptr;
|
||||
|
||||
@ -422,9 +422,8 @@ void lammps_gather_atoms(void *ptr, char *name,
|
||||
lmp->memory->destroy(copy);
|
||||
|
||||
} else {
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
double *vector;
|
||||
double **array;
|
||||
double *vector = NULL;
|
||||
double **array = NULL;
|
||||
if (count == 1) vector = (double *) vptr;
|
||||
else array = (double **) vptr;
|
||||
|
||||
@ -473,15 +472,15 @@ void lammps_scatter_atoms(void *ptr, char *name,
|
||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||
|
||||
int i,j,m,offset;
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
|
||||
// copy = Natom length vector of per-atom values
|
||||
// use atom ID to insert each atom's values into copy
|
||||
// MPI_Allreduce with MPI_SUM to merge into data, ordered by atom ID
|
||||
|
||||
if (type == 0) {
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
int *vector;
|
||||
int **array;
|
||||
int *vector = NULL;
|
||||
int **array = NULL;
|
||||
if (count == 1) vector = (int *) vptr;
|
||||
else array = (int **) vptr;
|
||||
int *dptr = (int *) data;
|
||||
@ -499,16 +498,12 @@ void lammps_scatter_atoms(void *ptr, char *name,
|
||||
}
|
||||
|
||||
} else {
|
||||
void *vptr = lmp->atom->extract(name);
|
||||
double *vector;
|
||||
double **array;
|
||||
double *vector = NULL;
|
||||
double **array = NULL;
|
||||
if (count == 1) vector = (double *) vptr;
|
||||
else array = (double **) vptr;
|
||||
double *dptr = (double *) data;
|
||||
|
||||
int *tag = lmp->atom->tag;
|
||||
int nlocal = lmp->atom->nlocal;
|
||||
|
||||
if (count == 1) {
|
||||
for (i = 0; i < natoms; i++)
|
||||
if ((m = lmp->atom->map(i+1)) >= 0)
|
||||
|
||||
Reference in New Issue
Block a user