Merge pull request #2666 from akohlmey/collected-small-changes
Collected small changes and fixes
This commit is contained in:
@ -30,7 +30,12 @@ if(INTEL_LRT_MODE STREQUAL "THREADS")
|
||||
endif()
|
||||
endif()
|
||||
if(INTEL_LRT_MODE STREQUAL "C++11")
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11)
|
||||
if(Threads_FOUND)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11)
|
||||
target_link_libraries(lammps PRIVATE Threads::Threads)
|
||||
else()
|
||||
message(FATAL_ERROR "Must have working threads library for Long-range thread support")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
|
||||
@ -2330,7 +2330,9 @@ double FixGCMC::energy_full()
|
||||
// unlike Verlet, not performing a reverse_comm() or forces here
|
||||
// b/c GCMC does not care about forces
|
||||
// don't think it will mess up energy due to any post_force() fixes
|
||||
// but Modify::pre_reverse() is needed for USER-INTEL
|
||||
|
||||
if (modify->n_pre_reverse) modify->pre_reverse(eflag,vflag);
|
||||
if (modify->n_post_force) modify->post_force(vflag);
|
||||
if (modify->n_end_of_step) modify->end_of_step();
|
||||
|
||||
|
||||
@ -1057,7 +1057,9 @@ double FixWidom::energy_full()
|
||||
// unlike Verlet, not performing a reverse_comm() or forces here
|
||||
// b/c Widom does not care about forces
|
||||
// don't think it will mess up energy due to any post_force() fixes
|
||||
// but Modify::pre_reverse() is needed for USER-INTEL
|
||||
|
||||
if (modify->n_pre_reverse) modify->pre_reverse(eflag,vflag);
|
||||
if (modify->n_pre_force) modify->pre_force(vflag);
|
||||
if (modify->n_end_of_step) modify->end_of_step();
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
int i,j,k,ii,jj,kk,jnum,iparam_i;
|
||||
tagint itag,jtag;
|
||||
int itype,jtype,ktype,iparam_ij,iparam_ijk;
|
||||
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair;
|
||||
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair;
|
||||
double rsq,rsq1,rsq2;
|
||||
double delr1[3],delr2[3],fi[3],fj[3],fk[3];
|
||||
double zeta_ij,prefactor;
|
||||
@ -102,7 +102,7 @@ void PairCombOMP::eval(int iifrom, int iito, ThrData * const thr)
|
||||
double vionij,fvionij,sr1,sr2,sr3,Eov,Fov;
|
||||
int sht_jnum, *sht_jlist, nj;
|
||||
|
||||
evdwl = ecoul = 0.0;
|
||||
evdwl = 0.0;
|
||||
|
||||
const double * const * const x = atom->x;
|
||||
double * const * const f = thr->get_f();
|
||||
@ -419,7 +419,7 @@ double PairCombOMP::yasu_char(double *qf_fix, int &igroup)
|
||||
#pragma omp parallel for private(ii) LMP_DEFAULT_NONE LMP_SHARED(potal,fac11e)
|
||||
#endif
|
||||
for (ii = 0; ii < inum; ii ++) {
|
||||
double fqi,fqj,fqij,fqji,fqjj,delr1[3];
|
||||
double fqi,fqij,fqji,fqjj,delr1[3];
|
||||
double sr1,sr2,sr3;
|
||||
int mr1,mr2,mr3;
|
||||
|
||||
@ -428,7 +428,7 @@ double PairCombOMP::yasu_char(double *qf_fix, int &igroup)
|
||||
int nj = 0;
|
||||
|
||||
if (mask[i] & groupbit) {
|
||||
fqi = fqj = fqij = fqji = fqjj = 0.0; // should not be needed.
|
||||
fqi = fqij = fqji = fqjj = 0.0; // should not be needed.
|
||||
int itype = map[type[i]];
|
||||
const double xtmp = x[i][0];
|
||||
const double ytmp = x[i][1];
|
||||
|
||||
@ -49,22 +49,15 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
|
||||
// compute ID, group, and style
|
||||
// ID must be all alphanumeric chars or underscores
|
||||
|
||||
int n = strlen(arg[0]) + 1;
|
||||
id = new char[n];
|
||||
strcpy(id,arg[0]);
|
||||
|
||||
for (int i = 0; i < n-1; i++)
|
||||
if (!isalnum(id[i]) && id[i] != '_')
|
||||
error->all(FLERR,
|
||||
"Compute ID must be alphanumeric or underscore characters");
|
||||
id = utils::strdup(arg[0]);
|
||||
if (!utils::is_id(id))
|
||||
error->all(FLERR,"Compute ID must be alphanumeric or underscore characters");
|
||||
|
||||
igroup = group->find(arg[1]);
|
||||
if (igroup == -1) error->all(FLERR,"Could not find compute group ID");
|
||||
groupbit = group->bitmask[igroup];
|
||||
|
||||
n = strlen(arg[2]) + 1;
|
||||
style = new char[n];
|
||||
strcpy(style,arg[2]);
|
||||
style = utils::strdup(arg[2]);
|
||||
|
||||
// set child class defaults
|
||||
|
||||
|
||||
@ -67,9 +67,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
bstyle[nvalues++] = ENG;
|
||||
} else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
bstyle[nvalues++] = VARIABLE;
|
||||
int n = strlen(arg[iarg]);
|
||||
vstr[nvar] = new char[n];
|
||||
strcpy(vstr[nvar],&arg[iarg][2]);
|
||||
vstr[nvar] = utils::strdup(&arg[iarg][2]);
|
||||
nvar++;
|
||||
} else break;
|
||||
}
|
||||
@ -85,9 +83,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal compute angle/local command");
|
||||
if (strcmp(arg[iarg+1],"theta") == 0) {
|
||||
delete [] tstr;
|
||||
int n = strlen(arg[iarg+2]) + 1;
|
||||
tstr = new char[n];
|
||||
strcpy(tstr,arg[iarg+2]);
|
||||
tstr = utils::strdup(arg[iarg+2]);
|
||||
tflag = 1;
|
||||
} else error->all(FLERR,"Illegal compute angle/local command");
|
||||
iarg += 3;
|
||||
|
||||
@ -41,9 +41,7 @@ ComputeAngmomChunk::ComputeAngmomChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -74,9 +74,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
else if (strcmp(arg[iarg],"velvib") == 0) bstyle[nvalues++] = VELVIB;
|
||||
else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
bstyle[nvalues++] = VARIABLE;
|
||||
int n = strlen(arg[iarg]);
|
||||
vstr[nvar] = new char[n];
|
||||
strcpy(vstr[nvar],&arg[iarg][2]);
|
||||
vstr[nvar] = utils::strdup(&arg[iarg][2]);
|
||||
nvar++;
|
||||
} else break;
|
||||
}
|
||||
@ -92,9 +90,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal compute bond/local command");
|
||||
if (strcmp(arg[iarg+1],"dist") == 0) {
|
||||
delete [] dstr;
|
||||
int n = strlen(arg[iarg+2]) + 1;
|
||||
dstr = new char[n];
|
||||
strcpy(dstr,arg[iarg+2]);
|
||||
dstr = utils::strdup(arg[iarg+2]);
|
||||
} else error->all(FLERR,"Illegal compute bond/local command");
|
||||
iarg += 3;
|
||||
} else error->all(FLERR,"Illegal compute bond/local command");
|
||||
|
||||
@ -51,9 +51,7 @@ ComputeCentroidStressAtom::ComputeCentroidStressAtom(LAMMPS *lmp, int narg, char
|
||||
|
||||
if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr;
|
||||
else {
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[3]);
|
||||
id_temp = utils::strdup(arg[3]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
|
||||
@ -185,9 +185,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
int iregion = domain->find_region(arg[iarg+1]);
|
||||
if (iregion == -1)
|
||||
error->all(FLERR,"Region ID for compute chunk/atom does not exist");
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
idregion = new char[n];
|
||||
strcpy(idregion,arg[iarg+1]);
|
||||
idregion = utils::strdup(arg[iarg+1]);
|
||||
regionflag = 1;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"nchunk") == 0) {
|
||||
|
||||
@ -36,9 +36,7 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
init_chunk();
|
||||
|
||||
// expand args if any have wildcard character "*"
|
||||
|
||||
@ -43,9 +43,7 @@ ComputeCOMChunk::ComputeCOMChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -85,9 +85,7 @@ ComputeCoordAtom::ComputeCoordAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
cstyle = ORIENT;
|
||||
if (narg != 6) error->all(FLERR,"Illegal compute coord/atom command");
|
||||
|
||||
int n = strlen(arg[4]) + 1;
|
||||
id_orientorder = new char[n];
|
||||
strcpy(id_orientorder,arg[4]);
|
||||
id_orientorder = utils::strdup(arg[4]);
|
||||
|
||||
int iorientorder = modify->find_compute(id_orientorder);
|
||||
if (iorientorder < 0)
|
||||
|
||||
@ -64,9 +64,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
bstyle[nvalues++] = PHI;
|
||||
} else if (strncmp(arg[iarg],"v_",2) == 0) {
|
||||
bstyle[nvalues++] = VARIABLE;
|
||||
int n = strlen(arg[iarg]);
|
||||
vstr[nvar] = new char[n];
|
||||
strcpy(vstr[nvar],&arg[iarg][2]);
|
||||
vstr[nvar] = utils::strdup(&arg[iarg][2]);
|
||||
nvar++;
|
||||
} else break;
|
||||
}
|
||||
@ -83,9 +81,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
if (strcmp(arg[iarg+1],"phi") == 0) {
|
||||
delete [] pstr;
|
||||
int n = strlen(arg[iarg+2]) + 1;
|
||||
pstr = new char[n];
|
||||
strcpy(pstr,arg[iarg+2]);
|
||||
pstr = utils::strdup(arg[iarg+2]);
|
||||
} else error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
iarg += 3;
|
||||
} else error->all(FLERR,"Illegal compute dihedral/local command");
|
||||
|
||||
@ -49,9 +49,7 @@ ComputeDipoleChunk::ComputeDipoleChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
usecenter = MASSCENTER;
|
||||
|
||||
|
||||
@ -53,9 +53,7 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,"Illegal compute displace/atom command");
|
||||
refreshflag = 1;
|
||||
delete [] rvar;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
rvar = new char[n];
|
||||
strcpy(rvar,arg[iarg+1]);
|
||||
rvar = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal compute displace/atom command");
|
||||
}
|
||||
@ -74,11 +72,9 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
// create a new fix STORE style
|
||||
// id = compute-ID + COMPUTE_STORE, fix group = compute group
|
||||
|
||||
std::string cmd = id + std::string("_COMPUTE_STORE");
|
||||
id_fix = new char[cmd.size()+1];
|
||||
strcpy(id_fix,cmd.c_str());
|
||||
|
||||
cmd += fmt::format(" {} STORE peratom 1 3", group->names[igroup]);
|
||||
id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE");
|
||||
std::string cmd = id_fix + fmt::format(" {} STORE peratom 1 3",
|
||||
group->names[igroup]);
|
||||
modify->add_fix(cmd);
|
||||
fix = (FixStore *) modify->fix[modify->nfix-1];
|
||||
|
||||
|
||||
@ -54,10 +54,7 @@ ComputeGroupGroup::ComputeGroupGroup(LAMMPS *lmp, int narg, char **arg) :
|
||||
extscalar = 1;
|
||||
extvector = 1;
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
group2 = new char[n];
|
||||
strcpy(group2,arg[3]);
|
||||
|
||||
group2 = utils::strdup(arg[3]);
|
||||
jgroup = group->find(group2);
|
||||
if (jgroup == -1)
|
||||
error->all(FLERR,"Compute group/group group ID does not exist");
|
||||
|
||||
@ -36,9 +36,7 @@ ComputeGyrationChunk::ComputeGyrationChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -43,17 +43,9 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) :
|
||||
// store ke/atom, pe/atom, stress/atom IDs used by heat flux computation
|
||||
// insure they are valid for these computations
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_ke = new char[n];
|
||||
strcpy(id_ke,arg[3]);
|
||||
|
||||
n = strlen(arg[4]) + 1;
|
||||
id_pe = new char[n];
|
||||
strcpy(id_pe,arg[4]);
|
||||
|
||||
n = strlen(arg[5]) + 1;
|
||||
id_stress = new char[n];
|
||||
strcpy(id_stress,arg[5]);
|
||||
id_ke = utils::strdup(arg[3]);
|
||||
id_pe = utils::strdup(arg[4]);
|
||||
id_stress = utils::strdup(arg[5]);
|
||||
|
||||
int ike = modify->find_compute(id_ke);
|
||||
int ipe = modify->find_compute(id_pe);
|
||||
|
||||
@ -41,9 +41,7 @@ ComputeInertiaChunk::ComputeInertiaChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -44,9 +44,7 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
firstflag = 1;
|
||||
init();
|
||||
@ -58,11 +56,9 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
// potentially re-populate the fix array (and change it to correct size)
|
||||
// otherwise size reset and init will be done in setup()
|
||||
|
||||
std::string fixcmd = id + std::string("_COMPUTE_STORE");
|
||||
id_fix = new char[fixcmd.size()+1];
|
||||
strcpy(id_fix,fixcmd.c_str());
|
||||
|
||||
fixcmd += fmt::format(" {} STORE global 1 1",group->names[igroup]);
|
||||
id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE");
|
||||
std::string fixcmd = id_fix
|
||||
+ fmt::format(" {} STORE global 1 1",group->names[igroup]);
|
||||
modify->add_fix(fixcmd);
|
||||
fix = (FixStore *) modify->fix[modify->nfix-1];
|
||||
}
|
||||
|
||||
@ -45,9 +45,7 @@ ComputeOmegaChunk::ComputeOmegaChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -37,10 +37,10 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
|
||||
peflag = 1;
|
||||
timeflag = 1;
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
if (lmp->suffix) n += strlen(lmp->suffix) + 1;
|
||||
pstyle = new char[n];
|
||||
strcpy(pstyle,arg[3]);
|
||||
// copy with suffix so we can later chop it off, if needed
|
||||
if (lmp->suffix)
|
||||
pstyle = utils::strdup(fmt::format("{}/{}",arg[3],lmp->suffix));
|
||||
else pstyle = utils::strdup(arg[3]);
|
||||
|
||||
int iarg = 4;
|
||||
nsub = 0;
|
||||
@ -67,8 +67,7 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
if (!pair && lmp->suffix) {
|
||||
strcat(pstyle,"/");
|
||||
strcat(pstyle,lmp->suffix);
|
||||
pstyle[strlen(pstyle) - strlen(lmp->suffix) - 1] = '\0';
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
}
|
||||
|
||||
|
||||
@ -53,9 +53,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr;
|
||||
else {
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[3]);
|
||||
id_temp = utils::strdup(arg[3]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
@ -82,10 +80,10 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"ke") == 0) keflag = 1;
|
||||
else if (strcmp(arg[iarg],"pair/hybrid") == 0) {
|
||||
int n = strlen(arg[++iarg]) + 1;
|
||||
if (lmp->suffix) n += strlen(lmp->suffix) + 1;
|
||||
pstyle = new char[n];
|
||||
strcpy(pstyle,arg[iarg++]);
|
||||
if (lmp->suffix)
|
||||
pstyle = utils::strdup(fmt::format("{}/{}",arg[++iarg],lmp->suffix));
|
||||
else
|
||||
pstyle = utils::strdup(arg[++iarg]);
|
||||
|
||||
nsub = 0;
|
||||
|
||||
@ -102,8 +100,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
pairhybrid = (Pair *) force->pair_match(pstyle,1,nsub);
|
||||
if (!pairhybrid && lmp->suffix) {
|
||||
strcat(pstyle,"/");
|
||||
strcat(pstyle,lmp->suffix);
|
||||
pstyle[strlen(pstyle) - strlen(lmp->suffix) - 1] = '\0';
|
||||
pairhybrid = (Pair *) force->pair_match(pstyle,1,nsub);
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,7 @@ ComputePropertyChunk::ComputePropertyChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -47,9 +47,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
||||
iregion = domain->find_region(arg[3]);
|
||||
if (iregion == -1)
|
||||
error->all(FLERR,"Region ID for compute reduce/region does not exist");
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idregion = new char[n];
|
||||
strcpy(idregion,arg[3]);
|
||||
idregion = utils::strdup(arg[3]);
|
||||
iarg = 4;
|
||||
}
|
||||
|
||||
|
||||
@ -45,9 +45,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
init_chunk();
|
||||
|
||||
// mode
|
||||
|
||||
@ -51,9 +51,7 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr;
|
||||
else {
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[3]);
|
||||
id_temp = utils::strdup(arg[3]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
|
||||
@ -44,9 +44,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
biasflag = 0;
|
||||
init();
|
||||
@ -87,9 +85,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (iarg+2 > narg)
|
||||
error->all(FLERR,"Illegal compute temp/chunk command");
|
||||
biasflag = 1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
id_bias = new char[n];
|
||||
strcpy(id_bias,arg[iarg+1]);
|
||||
id_bias = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"adof") == 0) {
|
||||
if (iarg+2 > narg)
|
||||
|
||||
@ -36,9 +36,7 @@ ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) :
|
||||
iregion = domain->find_region(arg[3]);
|
||||
if (iregion == -1)
|
||||
error->all(FLERR,"Region ID for compute temp/region does not exist");
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idregion = new char[n];
|
||||
strcpy(idregion,arg[3]);
|
||||
idregion = utils::strdup(arg[3]);
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
|
||||
@ -51,9 +51,7 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (iarg+2 > narg)
|
||||
error->all(FLERR,"Illegal compute temp/sphere command");
|
||||
tempbias = 1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
id_bias = new char[n];
|
||||
strcpy(id_bias,arg[iarg+1]);
|
||||
id_bias = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"dof") == 0) {
|
||||
if (iarg+2 > narg)
|
||||
|
||||
@ -40,9 +40,7 @@ ComputeTorqueChunk::ComputeTorqueChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
@ -41,9 +41,7 @@ ComputeVCMChunk::ComputeVCMChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// ID of compute chunk/atom
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[3]);
|
||||
idchunk = utils::strdup(arg[3]);
|
||||
|
||||
init();
|
||||
|
||||
|
||||
14
src/fix.cpp
14
src/fix.cpp
@ -42,21 +42,15 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) :
|
||||
// fix ID, group, and style
|
||||
// ID must be all alphanumeric chars or underscores
|
||||
|
||||
int n = strlen(arg[0]) + 1;
|
||||
id = new char[n];
|
||||
strcpy(id,arg[0]);
|
||||
|
||||
for (int i = 0; i < n-1; i++)
|
||||
if (!isalnum(id[i]) && id[i] != '_')
|
||||
error->all(FLERR,"Fix ID must be alphanumeric or underscore characters");
|
||||
id = utils::strdup(arg[0]);
|
||||
if (!utils::is_id(id))
|
||||
error->all(FLERR,"Fix ID must be alphanumeric or underscore characters");
|
||||
|
||||
igroup = group->find(arg[1]);
|
||||
if (igroup == -1) error->all(FLERR,"Could not find fix group ID");
|
||||
groupbit = group->bitmask[igroup];
|
||||
|
||||
n = strlen(arg[2]) + 1;
|
||||
style = new char[n];
|
||||
strcpy(style,arg[2]);
|
||||
style = utils::strdup(arg[2]);
|
||||
|
||||
restart_global = restart_peratom = restart_file = 0;
|
||||
force_reneighbor = 0;
|
||||
|
||||
@ -57,9 +57,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
nrepeat = utils::inumeric(FLERR,arg[4],false,lmp);
|
||||
nfreq = utils::inumeric(FLERR,arg[5],false,lmp);
|
||||
|
||||
int n = strlen(arg[6]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[6]);
|
||||
idchunk = utils::strdup(arg[6]);
|
||||
|
||||
global_freq = nfreq;
|
||||
no_change_box = 1;
|
||||
@ -190,9 +188,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (iarg+2 > narg)
|
||||
error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
biasflag = 1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
id_bias = new char[n];
|
||||
strcpy(id_bias,arg[iarg+1]);
|
||||
id_bias = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"adof") == 0) {
|
||||
if (iarg+2 > narg)
|
||||
@ -220,31 +216,23 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
} else if (strcmp(arg[iarg],"format") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] format_user;
|
||||
int n = strlen(arg[iarg+1]) + 2;
|
||||
format_user = new char[n];
|
||||
sprintf(format_user," %s",arg[iarg+1]);
|
||||
format_user = utils::strdup(arg[iarg+1]);
|
||||
format = format_user;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title1") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] title1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title1 = new char[n];
|
||||
strcpy(title1,arg[iarg+1]);
|
||||
title1 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title2") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] title2;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title2 = new char[n];
|
||||
strcpy(title2,arg[iarg+1]);
|
||||
title2 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title3") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
delete [] title3;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title3 = new char[n];
|
||||
strcpy(title3,arg[iarg+1]);
|
||||
title3 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal fix ave/chunk command");
|
||||
}
|
||||
|
||||
@ -139,23 +139,17 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
||||
} else if (strcmp(arg[iarg],"title1") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
|
||||
delete [] title1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title1 = new char[n];
|
||||
strcpy(title1,arg[iarg+1]);
|
||||
title1 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title2") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
|
||||
delete [] title2;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title2 = new char[n];
|
||||
strcpy(title2,arg[iarg+1]);
|
||||
title2 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title3") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
|
||||
delete [] title3;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title3 = new char[n];
|
||||
strcpy(title3,arg[iarg+1]);
|
||||
title3 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal fix ave/correlate command");
|
||||
}
|
||||
|
||||
@ -993,23 +993,17 @@ void FixAveHisto::options(int iarg, int narg, char **arg)
|
||||
} else if (strcmp(arg[iarg],"title1") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
|
||||
delete [] title1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title1 = new char[n];
|
||||
strcpy(title1,arg[iarg+1]);
|
||||
title1 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title2") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
|
||||
delete [] title2;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title2 = new char[n];
|
||||
strcpy(title2,arg[iarg+1]);
|
||||
title2 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title3") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
|
||||
delete [] title3;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title3 = new char[n];
|
||||
strcpy(title3,arg[iarg+1]);
|
||||
title3 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal fix ave/histo command");
|
||||
}
|
||||
|
||||
@ -1067,31 +1067,23 @@ void FixAveTime::options(int iarg, int narg, char **arg)
|
||||
} else if (strcmp(arg[iarg],"format") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
|
||||
delete [] format_user;
|
||||
int n = strlen(arg[iarg+1]) + 2;
|
||||
format_user = new char[n];
|
||||
sprintf(format_user," %s",arg[iarg+1]);
|
||||
format_user = utils::strdup(arg[iarg+1]);
|
||||
format = format_user;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title1") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command");
|
||||
delete [] title1;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title1 = new char[n];
|
||||
strcpy(title1,arg[iarg+1]);
|
||||
title1 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title2") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command");
|
||||
delete [] title2;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title2 = new char[n];
|
||||
strcpy(title2,arg[iarg+1]);
|
||||
title2 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"title3") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command");
|
||||
delete [] title3;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
title3 = new char[n];
|
||||
strcpy(title3,arg[iarg+1]);
|
||||
title3 = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal fix ave/time command");
|
||||
}
|
||||
|
||||
@ -761,9 +761,7 @@ int FixBoxRelax::modify_param(int narg, char **arg)
|
||||
tflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[1]);
|
||||
if (icompute < 0)
|
||||
@ -792,9 +790,7 @@ int FixBoxRelax::modify_param(int narg, char **arg)
|
||||
pflag = 0;
|
||||
}
|
||||
delete [] id_press;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_press = new char[n];
|
||||
strcpy(id_press,arg[1]);
|
||||
id_press = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[1]);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");
|
||||
|
||||
@ -67,9 +67,7 @@ FixController::FixController(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// control variable arg
|
||||
|
||||
int n = strlen(arg[iarg]) + 1;
|
||||
cvID = new char[n];
|
||||
strcpy(cvID,arg[iarg]);
|
||||
cvID = utils::strdup(arg[iarg]);
|
||||
|
||||
// error check
|
||||
|
||||
|
||||
@ -126,12 +126,8 @@ rfix(nullptr), irregular(nullptr), set(nullptr)
|
||||
error->all(FLERR,"Illegal fix deform command");
|
||||
delete [] set[index].hstr;
|
||||
delete [] set[index].hratestr;
|
||||
int n = strlen(&arg[iarg+2][2]) + 1;
|
||||
set[index].hstr = new char[n];
|
||||
strcpy(set[index].hstr,&arg[iarg+2][2]);
|
||||
n = strlen(&arg[iarg+3][2]) + 1;
|
||||
set[index].hratestr = new char[n];
|
||||
strcpy(set[index].hratestr,&arg[iarg+3][2]);
|
||||
set[index].hstr = utils::strdup(&arg[iarg+2][2]);
|
||||
set[index].hratestr = utils::strdup(&arg[iarg+3][2]);
|
||||
iarg += 4;
|
||||
} else error->all(FLERR,"Illegal fix deform command");
|
||||
|
||||
@ -188,12 +184,8 @@ rfix(nullptr), irregular(nullptr), set(nullptr)
|
||||
error->all(FLERR,"Illegal fix deform command");
|
||||
delete [] set[index].hstr;
|
||||
delete [] set[index].hratestr;
|
||||
int n = strlen(&arg[iarg+2][2]) + 1;
|
||||
set[index].hstr = new char[n];
|
||||
strcpy(set[index].hstr,&arg[iarg+2][2]);
|
||||
n = strlen(&arg[iarg+3][2]) + 1;
|
||||
set[index].hratestr = new char[n];
|
||||
strcpy(set[index].hratestr,&arg[iarg+3][2]);
|
||||
set[index].hstr = utils::strdup(&arg[iarg+2][2]);
|
||||
set[index].hratestr = utils::strdup(&arg[iarg+3][2]);
|
||||
iarg += 4;
|
||||
} else error->all(FLERR,"Illegal fix deform command");
|
||||
|
||||
|
||||
@ -39,12 +39,9 @@ idregion(nullptr), idvar(nullptr), idprop(nullptr)
|
||||
// dgroupbit = bitmask of dynamic group
|
||||
// group ID is last part of fix ID
|
||||
|
||||
int n = strlen(id) - strlen("GROUP_") + 1;
|
||||
char *dgroup = new char[n];
|
||||
strcpy(dgroup,&id[strlen("GROUP_")]);
|
||||
gbit = group->bitmask[group->find(dgroup)];
|
||||
gbitinverse = group->inversemask[group->find(dgroup)];
|
||||
delete [] dgroup;
|
||||
auto dgroupid = std::string(id).substr(strlen("GROUP_"));
|
||||
gbit = group->bitmask[group->find(dgroupid)];
|
||||
gbitinverse = group->inversemask[group->find(dgroupid)];
|
||||
|
||||
// process optional args
|
||||
|
||||
@ -61,9 +58,7 @@ idregion(nullptr), idvar(nullptr), idprop(nullptr)
|
||||
error->all(FLERR,"Region ID for group dynamic does not exist");
|
||||
regionflag = 1;
|
||||
delete [] idregion;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
idregion = new char[n];
|
||||
strcpy(idregion,arg[iarg+1]);
|
||||
idregion = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"var") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal group command");
|
||||
@ -71,9 +66,7 @@ idregion(nullptr), idvar(nullptr), idprop(nullptr)
|
||||
error->all(FLERR,"Variable name for group dynamic does not exist");
|
||||
varflag = 1;
|
||||
delete [] idvar;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
idvar = new char[n];
|
||||
strcpy(idvar,arg[iarg+1]);
|
||||
idvar = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"property") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal group command");
|
||||
@ -81,9 +74,7 @@ idregion(nullptr), idvar(nullptr), idprop(nullptr)
|
||||
error->all(FLERR,"Per atom property for group dynamic does not exist");
|
||||
propflag = 1;
|
||||
delete [] idprop;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
idprop = new char[n];
|
||||
strcpy(idprop,arg[iarg+1]);
|
||||
idprop = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"every") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal group command");
|
||||
@ -123,7 +114,7 @@ void FixGroup::init()
|
||||
if (group->dynamic[igroup])
|
||||
error->all(FLERR,"Group dynamic parent group cannot be dynamic");
|
||||
|
||||
if (strstr(update->integrate_style,"respa"))
|
||||
if (utils::strmatch(update->integrate_style,"^respa"))
|
||||
nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
||||
|
||||
// set current indices for region and variable
|
||||
|
||||
@ -275,9 +275,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) :
|
||||
else {
|
||||
allremap = 0;
|
||||
delete [] id_dilate;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
id_dilate = new char[n];
|
||||
strcpy(id_dilate,arg[iarg+1]);
|
||||
id_dilate = utils::strdup(arg[iarg+1]);
|
||||
int idilate = group->find(id_dilate);
|
||||
if (idilate == -1)
|
||||
error->all(FLERR,"Fix nvt/npt/nph dilate group ID does not exist");
|
||||
@ -1414,9 +1412,7 @@ int FixNH::modify_param(int narg, char **arg)
|
||||
tcomputeflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[1]);
|
||||
if (icompute < 0)
|
||||
@ -1448,9 +1444,7 @@ int FixNH::modify_param(int narg, char **arg)
|
||||
pcomputeflag = 0;
|
||||
}
|
||||
delete [] id_press;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_press = new char[n];
|
||||
strcpy(id_press,arg[1]);
|
||||
id_press = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[1]);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");
|
||||
|
||||
@ -467,9 +467,7 @@ int FixPressBerendsen::modify_param(int narg, char **arg)
|
||||
tflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[1]);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find fix_modify temperature ID");
|
||||
@ -496,9 +494,7 @@ int FixPressBerendsen::modify_param(int narg, char **arg)
|
||||
pflag = 0;
|
||||
}
|
||||
delete [] id_press;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_press = new char[n];
|
||||
strcpy(id_press,arg[1]);
|
||||
id_press = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(arg[1]);
|
||||
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");
|
||||
|
||||
@ -70,9 +70,7 @@ FixSpring::FixSpring(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (narg != 10) error->all(FLERR,"Illegal fix spring command");
|
||||
styleflag = COUPLE;
|
||||
|
||||
int n = strlen(arg[4]) + 1;
|
||||
group2 = new char[n];
|
||||
strcpy(group2,arg[4]);
|
||||
group2 = utils::strdup(arg[4]);
|
||||
igroup2 = group->find(arg[4]);
|
||||
if (igroup2 == -1)
|
||||
error->all(FLERR,"Fix spring couple group ID does not exist");
|
||||
|
||||
@ -49,13 +49,8 @@ FixSpringChunk::FixSpringChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
k_spring = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
int n = strlen(arg[4]) + 1;
|
||||
idchunk = new char[n];
|
||||
strcpy(idchunk,arg[4]);
|
||||
|
||||
n = strlen(arg[5]) + 1;
|
||||
idcom = new char[n];
|
||||
strcpy(idcom,arg[5]);
|
||||
idchunk = utils::strdup(arg[4]);
|
||||
idcom = utils::strdup(arg[5]);
|
||||
|
||||
esprings = 0.0;
|
||||
nchunk = 0;
|
||||
|
||||
@ -205,9 +205,7 @@ int FixTempBerendsen::modify_param(int narg, char **arg)
|
||||
tflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
|
||||
@ -261,9 +261,7 @@ int FixTempCSLD::modify_param(int narg, char **arg)
|
||||
tflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
|
||||
@ -216,9 +216,7 @@ int FixTempCSVR::modify_param(int narg, char **arg)
|
||||
tflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
|
||||
@ -202,9 +202,7 @@ int FixTempRescale::modify_param(int narg, char **arg)
|
||||
tflag = 0;
|
||||
}
|
||||
delete [] id_temp;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id_temp = new char[n];
|
||||
strcpy(id_temp,arg[1]);
|
||||
id_temp = utils::strdup(arg[1]);
|
||||
|
||||
int icompute = modify->find_compute(id_temp);
|
||||
if (icompute < 0)
|
||||
|
||||
@ -54,9 +54,7 @@ FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) :
|
||||
iregion = domain->find_region(arg[3]);
|
||||
if (iregion == -1)
|
||||
error->all(FLERR,"Region ID for fix wall/region does not exist");
|
||||
int n = strlen(arg[3]) + 1;
|
||||
idregion = new char[n];
|
||||
strcpy(idregion,arg[3]);
|
||||
idregion = utils::strdup(arg[3]);
|
||||
|
||||
if (strcmp(arg[4],"lj93") == 0) style = LJ93;
|
||||
else if (strcmp(arg[4],"lj126") == 0) style = LJ126;
|
||||
|
||||
@ -61,20 +61,12 @@ Force::Force(LAMMPS *lmp) : Pointers(lmp)
|
||||
improper = nullptr;
|
||||
kspace = nullptr;
|
||||
|
||||
char *str = (char *) "none";
|
||||
int n = strlen(str) + 1;
|
||||
pair_style = new char[n];
|
||||
strcpy(pair_style,str);
|
||||
bond_style = new char[n];
|
||||
strcpy(bond_style,str);
|
||||
angle_style = new char[n];
|
||||
strcpy(angle_style,str);
|
||||
dihedral_style = new char[n];
|
||||
strcpy(dihedral_style,str);
|
||||
improper_style = new char[n];
|
||||
strcpy(improper_style,str);
|
||||
kspace_style = new char[n];
|
||||
strcpy(kspace_style,str);
|
||||
pair_style = utils::strdup("none");
|
||||
bond_style = utils::strdup("none");
|
||||
angle_style = utils::strdup("none");
|
||||
dihedral_style = utils::strdup("none");
|
||||
improper_style = utils::strdup("none");
|
||||
kspace_style = utils::strdup("none");
|
||||
|
||||
pair_restart = nullptr;
|
||||
create_factories();
|
||||
|
||||
@ -36,10 +36,7 @@ ImbalanceStore::~ImbalanceStore()
|
||||
int ImbalanceStore::options(int narg, char **arg)
|
||||
{
|
||||
if (narg < 1) error->all(FLERR,"Illegal balance weight command");
|
||||
|
||||
int len = strlen(arg[0]) + 1;
|
||||
name = new char[len];
|
||||
memcpy(name,arg[0],len);
|
||||
name = utils::strdup(arg[0]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -40,10 +40,7 @@ ImbalanceVar::~ImbalanceVar()
|
||||
int ImbalanceVar::options(int narg, char **arg)
|
||||
{
|
||||
if (narg < 1) error->all(FLERR,"Illegal balance weight command");
|
||||
|
||||
int len = strlen(arg[0]) + 1;
|
||||
name = new char[len];
|
||||
memcpy(name,arg[0],len);
|
||||
name = utils::strdup(arg[0]);
|
||||
init(0);
|
||||
|
||||
return 1;
|
||||
|
||||
@ -1013,9 +1013,7 @@ void Input::jump()
|
||||
if (narg == 2) {
|
||||
label_active = 1;
|
||||
if (labelstr) delete [] labelstr;
|
||||
int n = strlen(arg[1]) + 1;
|
||||
labelstr = new char[n];
|
||||
strcpy(labelstr,arg[1]);
|
||||
labelstr = utils::strdup(arg[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1840,17 +1838,11 @@ void Input::suffix()
|
||||
|
||||
if (strcmp(arg[0],"hybrid") == 0) {
|
||||
if (narg != 3) error->all(FLERR,"Illegal suffix command");
|
||||
int n = strlen(arg[1]) + 1;
|
||||
lmp->suffix = new char[n];
|
||||
strcpy(lmp->suffix,arg[1]);
|
||||
n = strlen(arg[2]) + 1;
|
||||
lmp->suffix2 = new char[n];
|
||||
strcpy(lmp->suffix2,arg[2]);
|
||||
lmp->suffix = utils::strdup(arg[1]);
|
||||
lmp->suffix2 = utils::strdup(arg[2]);
|
||||
} else {
|
||||
if (narg != 1) error->all(FLERR,"Illegal suffix command");
|
||||
int n = strlen(arg[0]) + 1;
|
||||
lmp->suffix = new char[n];
|
||||
strcpy(lmp->suffix,arg[0]);
|
||||
lmp->suffix = utils::strdup(arg[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,12 +444,11 @@ is passed to :cpp:func:`lammps_commands_string` for processing.
|
||||
|
||||
void lammps_commands_list(void *handle, int ncmd, const char **cmds)
|
||||
{
|
||||
LAMMPS *lmp = (LAMMPS *) handle;
|
||||
std::string allcmds;
|
||||
|
||||
for (int i = 0; i < ncmd; i++) {
|
||||
allcmds.append(cmds[i]);
|
||||
if (allcmds.back() != '\n') allcmds.append(1,'\n');
|
||||
if (allcmds.empty() || (allcmds.back() != '\n')) allcmds.append(1,'\n');
|
||||
}
|
||||
|
||||
lammps_commands_string(handle,allcmds.c_str());
|
||||
|
||||
@ -1479,7 +1479,8 @@ void Neighbor::print_pairwise_info()
|
||||
rq = requests[i];
|
||||
if (rq->pair) {
|
||||
char *pname = force->pair_match_ptr((Pair *) rq->requestor);
|
||||
out += fmt::format(" ({}) pair {}",i+1,pname);
|
||||
if (pname) out += fmt::format(" ({}) pair {}",i+1,pname);
|
||||
else out += fmt::format(" ({}) pair (none)",i+1);
|
||||
} else if (rq->fix) {
|
||||
out += fmt::format(" ({}) fix {}",i+1,((Fix *) rq->requestor)->style);
|
||||
} else if (rq->compute) {
|
||||
|
||||
@ -337,6 +337,12 @@ void ReadData::command(int narg, char **arg)
|
||||
Dihedral *saved_dihedral = nullptr;
|
||||
Improper *saved_improper = nullptr;
|
||||
KSpace *saved_kspace = nullptr;
|
||||
char *saved_pair_style = nullptr;
|
||||
char *saved_bond_style = nullptr;
|
||||
char *saved_angle_style = nullptr;
|
||||
char *saved_dihedral_style = nullptr;
|
||||
char *saved_improper_style = nullptr;
|
||||
char *saved_kspace_style = nullptr;
|
||||
|
||||
if (coeffflag == 0) {
|
||||
char *coeffs[2];
|
||||
@ -344,33 +350,45 @@ void ReadData::command(int narg, char **arg)
|
||||
coeffs[1] = (char *) "nocoeff";
|
||||
|
||||
saved_pair = force->pair;
|
||||
saved_pair_style = force->pair_style;
|
||||
force->pair = nullptr;
|
||||
force->pair_style = nullptr;
|
||||
force->create_pair("zero",0);
|
||||
if (force->pair) force->pair->settings(2,coeffs);
|
||||
|
||||
coeffs[0] = coeffs[1];
|
||||
saved_bond = force->bond;
|
||||
saved_bond_style = force->bond_style;
|
||||
force->bond = nullptr;
|
||||
force->bond_style = nullptr;
|
||||
force->create_bond("zero",0);
|
||||
if (force->bond) force->bond->settings(1,coeffs);
|
||||
|
||||
saved_angle = force->angle;
|
||||
saved_angle_style = force->angle_style;
|
||||
force->angle = nullptr;
|
||||
force->angle_style = nullptr;
|
||||
force->create_angle("zero",0);
|
||||
if (force->angle) force->angle->settings(1,coeffs);
|
||||
|
||||
saved_dihedral = force->dihedral;
|
||||
saved_dihedral_style = force->dihedral_style;
|
||||
force->dihedral = nullptr;
|
||||
force->dihedral_style = nullptr;
|
||||
force->create_dihedral("zero",0);
|
||||
if (force->dihedral) force->dihedral->settings(1,coeffs);
|
||||
|
||||
saved_improper = force->improper;
|
||||
saved_improper_style = force->improper_style;
|
||||
force->improper = nullptr;
|
||||
force->improper_style = nullptr;
|
||||
force->create_improper("zero",0);
|
||||
if (force->improper) force->improper->settings(1,coeffs);
|
||||
|
||||
saved_kspace = force->kspace;
|
||||
saved_kspace_style = force->kspace_style;
|
||||
force->kspace = nullptr;
|
||||
force->kspace_style = nullptr;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
@ -873,20 +891,26 @@ void ReadData::command(int narg, char **arg)
|
||||
if (coeffflag == 0) {
|
||||
if (force->pair) delete force->pair;
|
||||
force->pair = saved_pair;
|
||||
force->pair_style = saved_pair_style;
|
||||
|
||||
if (force->bond) delete force->bond;
|
||||
force->bond = saved_bond;
|
||||
force->bond_style = saved_bond_style;
|
||||
|
||||
if (force->angle) delete force->angle;
|
||||
force->angle = saved_angle;
|
||||
force->angle_style = saved_angle_style;
|
||||
|
||||
if (force->dihedral) delete force->dihedral;
|
||||
force->dihedral = saved_dihedral;
|
||||
force->dihedral_style = saved_dihedral_style;
|
||||
|
||||
if (force->improper) delete force->improper;
|
||||
force->improper = saved_improper;
|
||||
force->improper_style = saved_improper_style;
|
||||
|
||||
force->kspace = saved_kspace;
|
||||
force->kspace_style = saved_kspace_style;
|
||||
}
|
||||
|
||||
// total time
|
||||
|
||||
@ -201,7 +201,6 @@ std::string ValueTokenizer::next_string() {
|
||||
std::string value = tokens.next();
|
||||
return value;
|
||||
} throw TokenizerException("Not enough tokens","");
|
||||
return "";
|
||||
}
|
||||
|
||||
/*! Retrieve next token and convert to int
|
||||
@ -217,7 +216,6 @@ int ValueTokenizer::next_int() {
|
||||
int value = atoi(current.c_str());
|
||||
return value;
|
||||
} throw TokenizerException("Not enough tokens","");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Retrieve next token and convert to bigint
|
||||
@ -233,7 +231,6 @@ bigint ValueTokenizer::next_bigint() {
|
||||
bigint value = ATOBIGINT(current.c_str());
|
||||
return value;
|
||||
} throw TokenizerException("Not enough tokens","");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Retrieve next token and convert to tagint
|
||||
@ -249,7 +246,6 @@ tagint ValueTokenizer::next_tagint() {
|
||||
tagint value = ATOTAGINT(current.c_str());
|
||||
return value;
|
||||
} throw TokenizerException("Not enough tokens","");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! Retrieve next token and convert to double
|
||||
@ -265,7 +261,6 @@ double ValueTokenizer::next_double() {
|
||||
double value = atof(current.c_str());
|
||||
return value;
|
||||
} throw TokenizerException("Not enough tokens","");
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/*! Skip over a given number of tokens
|
||||
|
||||
@ -473,6 +473,7 @@ int utils::expand_args(const char *file, int line, int narg, char **arg,
|
||||
|
||||
for (iarg = 0; iarg < narg; iarg++) {
|
||||
std::string word(arg[iarg]);
|
||||
expandflag = 0;
|
||||
|
||||
// only match compute/fix reference with a '*' wildcard
|
||||
// number range in the first pair of square brackets
|
||||
|
||||
@ -482,8 +482,6 @@ TEST_F(ResetIDsTest, TopologyData)
|
||||
|
||||
auto num_bond = lmp->atom->num_bond;
|
||||
auto num_angle = lmp->atom->num_angle;
|
||||
auto num_dihedral = lmp->atom->num_dihedral;
|
||||
auto num_improper = lmp->atom->num_improper;
|
||||
auto bond_atom = lmp->atom->bond_atom;
|
||||
auto angle_atom1 = lmp->atom->angle_atom1;
|
||||
auto angle_atom2 = lmp->atom->angle_atom2;
|
||||
@ -568,8 +566,6 @@ TEST_F(ResetIDsTest, TopologyData)
|
||||
|
||||
num_bond = lmp->atom->num_bond;
|
||||
num_angle = lmp->atom->num_angle;
|
||||
num_dihedral = lmp->atom->num_dihedral;
|
||||
num_improper = lmp->atom->num_improper;
|
||||
bond_atom = lmp->atom->bond_atom;
|
||||
angle_atom1 = lmp->atom->angle_atom1;
|
||||
angle_atom2 = lmp->atom->angle_atom2;
|
||||
|
||||
@ -308,7 +308,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// init_forces
|
||||
block.clear();
|
||||
auto f = lmp->atom->f;
|
||||
auto tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
@ -329,7 +328,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
|
||||
@ -308,7 +308,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// init_forces
|
||||
block.clear();
|
||||
auto f = lmp->atom->f;
|
||||
auto tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
@ -329,7 +328,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
|
||||
@ -311,7 +311,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// init_forces
|
||||
block.clear();
|
||||
auto f = lmp->atom->f;
|
||||
auto tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
@ -332,7 +331,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
|
||||
@ -302,7 +302,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// init_forces
|
||||
block.clear();
|
||||
auto f = lmp->atom->f;
|
||||
auto tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
@ -323,7 +322,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
|
||||
@ -308,7 +308,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
// init_forces
|
||||
block.clear();
|
||||
auto f = lmp->atom->f;
|
||||
auto tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
@ -332,7 +331,6 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
block.clear();
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, f[j][0], f[j][1], f[j][2]);
|
||||
|
||||
Reference in New Issue
Block a user