diff --git a/doc/Manual.txt b/doc/Manual.txt index b0857e6c32..f47482fdf2 100644 --- a/doc/Manual.txt +++ b/doc/Manual.txt @@ -85,7 +85,7 @@ it gives quick access to documentation for all LAMMPS commands. .. toctree:: :maxdepth: 2 - :numbered: + :numbered: // comment Section_intro Section_start @@ -105,8 +105,8 @@ it gives quick access to documentation for all LAMMPS commands. Indices and tables ================== -* :ref:`genindex` -* :ref:`search` +* :ref:`genindex` // comment +* :ref:`search` // comment END_RST --> diff --git a/python/lammps.py b/python/lammps.py index deea917187..01c20bc3b5 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -121,22 +121,23 @@ class lammps: # double was allocated by library interface function def extract_fix(self,id,style,type,i=0,j=0): - if type == 0: - if style > 0: return None + if style == 0: self.lib.lammps_extract_fix.restype = POINTER(c_double) ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j) result = ptr[0] self.lib.lammps_free(ptr) return result - if type == 1: - self.lib.lammps_extract_fix.restype = POINTER(c_double) + elif (style == 1) or (style == 2): + if type == 1: + self.lib.lammps_extract_fix.restype = POINTER(c_double) + elif type == 2: + self.lib.lammps_extract_fix.restype = POINTER(POINTER(c_double)) + else: + return None ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j) return ptr - if type == 2: - self.lib.lammps_extract_fix.restype = POINTER(POINTER(c_double)) - ptr = self.lib.lammps_extract_fix(self.lmp,id,style,type,i,j) - return ptr - return None + else: + return None # free memory for 1 double or 1 vector of doubles via lammps_free() # for vector, must copy nlocal returned values to local c_double vector diff --git a/src/USER-MISC/pair_srp.cpp b/src/USER-MISC/pair_srp.cpp index e607c8e86f..33629d8458 100644 --- a/src/USER-MISC/pair_srp.cpp +++ b/src/USER-MISC/pair_srp.cpp @@ -73,10 +73,22 @@ PairSRP::PairSRP(LAMMPS *lmp) : Pair(lmp) nextra = 1; segment = NULL; + + // generate unique fix-id for this pair style instance fix_id = strdup("XX_FIX_SRP"); fix_id[0] = '0' + srp_instance / 10; fix_id[1] = '0' + srp_instance % 10; ++srp_instance; + + // create fix SRP instance here, as it has to + // be executed before all other fixes + char **fixarg = new char*[3]; + fixarg[0] = fix_id; + fixarg[1] = (char *) "all"; + fixarg[2] = (char *) "SRP"; + modify->add_fix(3,fixarg); + f_srp = (FixSRP *) modify->fix[modify->nfix-1]; + delete [] fixarg; } /* ---------------------------------------------------------------------- @@ -436,16 +448,10 @@ void PairSRP::init_style() if (!force->newton_pair) error->all(FLERR,"PairSRP: Pair srp requires newton pair on"); - // need fix srp - // invoke here instead of constructor - // to make restart possible - char **fixarg = new char*[3]; - fixarg[0] = fix_id; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "SRP"; - modify->add_fix(3,fixarg); - f_srp = (FixSRP *) modify->fix[modify->nfix-1]; - delete [] fixarg; + // verify that fix SRP is still defined and has not been changed. + int ifix = modify->find_fix(fix_id); + if (f_srp != (FixSRP *)modify->fix[ifix]) + error->all(FLERR,"Fix SRP has been changed unexpectedly"); // set bond type in fix srp // bonds of this type will be represented by bond particles diff --git a/src/library.cpp b/src/library.cpp index f6d9b621d1..5801cedc5b 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -435,8 +435,7 @@ void lammps_gather_atoms(void *ptr, char *name, if (count == 1) vector = (int *) vptr; else array = (int **) vptr; - int *copy; - lmp->memory->create(copy,count*natoms,"lib/gather:copy"); + int *copy = (int*) data; for (i = 0; i < count*natoms; i++) copy[i] = 0; tagint *tag = lmp->atom->tag; @@ -452,8 +451,7 @@ void lammps_gather_atoms(void *ptr, char *name, copy[offset++] = array[i][0]; } - MPI_Allreduce(copy,data,count*natoms,MPI_INT,MPI_SUM,lmp->world); - lmp->memory->destroy(copy); + MPI_Allreduce(MPI_IN_PLACE,data,count*natoms,MPI_INT,MPI_SUM,lmp->world); } else { double *vector = NULL; @@ -461,8 +459,7 @@ void lammps_gather_atoms(void *ptr, char *name, if (count == 1) vector = (double *) vptr; else array = (double **) vptr; - double *copy; - lmp->memory->create(copy,count*natoms,"lib/gather:copy"); + double *copy = (double*) data; for (i = 0; i < count*natoms; i++) copy[i] = 0.0; tagint *tag = lmp->atom->tag; @@ -479,8 +476,7 @@ void lammps_gather_atoms(void *ptr, char *name, } } - MPI_Allreduce(copy,data,count*natoms,MPI_DOUBLE,MPI_SUM,lmp->world); - lmp->memory->destroy(copy); + MPI_Allreduce(MPI_IN_PLACE,data,count*natoms,MPI_DOUBLE,MPI_SUM,lmp->world); } }