simplify using utils::strdup(), update order of include files

This commit is contained in:
Axel Kohlmeyer 2021-03-27 15:52:14 -04:00
parent 35abca1b40
commit dfb18caf5a
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
31 changed files with 191 additions and 402 deletions

View File

@ -1800,14 +1800,8 @@ void PairExp6rxKokkos<DeviceType>::read_file(char *file)
}
params[nparams].ispecies = ispecies;
n = strlen(&atom->dname[ispecies][0]) + 1;
params[nparams].name = new char[n];
strcpy(params[nparams].name,&atom->dname[ispecies][0]);
n = strlen(words[1]) + 1;
params[nparams].potential = new char[n];
strcpy(params[nparams].potential,words[1]);
params[nparams].name = utils::strdup(&atom->dname[ispecies][0]);
params[nparams].potential = utils::strdup(words[1]);
if (strcmp(params[nparams].potential,"exp6") == 0) {
params[nparams].alpha = atof(words[2]);
params[nparams].epsilon = atof(words[3]);

View File

@ -1040,25 +1040,19 @@ void PairTableRXKokkos<DeviceType>::coeff(int narg, char **arg)
nspecies = atom->nspecies_dpd;
if (nspecies==0) error->all(FLERR,"There are no rx species specified.");
int n;
n = strlen(arg[4]) + 1;
site1 = new char[n];
strcpy(site1,arg[4]);
site1 = utils::strdup(arg[4]);
int ispecies;
for (ispecies = 0; ispecies < nspecies; ispecies++) {
for (ispecies = 0; ispecies < nspecies; ispecies++)
if (strcmp(site1,&atom->dname[ispecies][0]) == 0) break;
}
if (ispecies == nspecies && strcmp(site1,"1fluid") != 0)
error->all(FLERR,"Site1 name not recognized in pair coefficients");
n = strlen(arg[5]) + 1;
site2 = new char[n];
strcpy(site2,arg[5]);
for (ispecies = 0; ispecies < nspecies; ispecies++) {
site2 = utils::strdup(arg[5]);
for (ispecies = 0; ispecies < nspecies; ispecies++)
if (strcmp(site2,&atom->dname[ispecies][0]) == 0) break;
}
if (ispecies == nspecies && strcmp(site2,"1fluid") != 0)
error->all(FLERR,"Site2 name not recognized in pair coefficients");

View File

@ -84,10 +84,7 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"Fix latte does not yet support a LAMMPS calculation "
"of a Coulomb potential");
int n = strlen(arg[3]) + 1;
id_pe = new char[n];
strcpy(id_pe,arg[3]);
id_pe = utils::strdup(arg[3]);
int ipe = modify->find_compute(id_pe);
if (ipe < 0) error->all(FLERR,"Could not find fix latte compute ID");
if (modify->compute[ipe]->peatomflag == 0)

View File

@ -18,30 +18,31 @@
#include "fix_atom_swap.h"
#include "angle.h"
#include "atom.h"
#include "bond.h"
#include "comm.h"
#include "compute.h"
#include "dihedral.h"
#include "domain.h"
#include "error.h"
#include "fix.h"
#include "force.h"
#include "group.h"
#include "improper.h"
#include "kspace.h"
#include "memory.h"
#include "modify.h"
#include "neighbor.h"
#include "pair.h"
#include "random_park.h"
#include "region.h"
#include "update.h"
#include <cmath>
#include <cctype>
#include <cfloat>
#include <cstring>
#include "atom.h"
#include "update.h"
#include "modify.h"
#include "fix.h"
#include "comm.h"
#include "compute.h"
#include "group.h"
#include "domain.h"
#include "region.h"
#include "random_park.h"
#include "force.h"
#include "pair.h"
#include "bond.h"
#include "angle.h"
#include "dihedral.h"
#include "improper.h"
#include "kspace.h"
#include "memory.h"
#include "error.h"
#include "neighbor.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -138,9 +139,7 @@ void FixAtomSwap::options(int narg, char **arg)
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix atom/swap 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],"ke") == 0) {

View File

@ -13,27 +13,27 @@
#include "fix_bond_swap.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "force.h"
#include "pair.h"
#include "bond.h"
#include "angle.h"
#include "neighbor.h"
#include "atom.h"
#include "bond.h"
#include "citeme.h"
#include "comm.h"
#include "compute.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "modify.h"
#include "neigh_list.h"
#include "neigh_request.h"
#include "comm.h"
#include "domain.h"
#include "modify.h"
#include "compute.h"
#include "neighbor.h"
#include "pair.h"
#include "random_mars.h"
#include "citeme.h"
#include "memory.h"
#include "error.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -642,9 +642,7 @@ int FixBondSwap::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)

View File

@ -17,32 +17,33 @@
#include "fix_gcmc.h"
#include <cmath>
#include <cstring>
#include "angle.h"
#include "atom.h"
#include "atom_vec.h"
#include "molecule.h"
#include "update.h"
#include "modify.h"
#include "fix.h"
#include "bond.h"
#include "comm.h"
#include "compute.h"
#include "group.h"
#include "domain.h"
#include "region.h"
#include "random_park.h"
#include "force.h"
#include "pair.h"
#include "bond.h"
#include "angle.h"
#include "dihedral.h"
#include "domain.h"
#include "error.h"
#include "fix.h"
#include "force.h"
#include "group.h"
#include "improper.h"
#include "kspace.h"
#include "math_extra.h"
#include "math_const.h"
#include "math_extra.h"
#include "memory.h"
#include "error.h"
#include "modify.h"
#include "molecule.h"
#include "neighbor.h"
#include "pair.h"
#include "random_park.h"
#include "region.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -301,9 +302,7 @@ void FixGCMC::options(int narg, char **arg)
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix gcmc 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],"maxangle") == 0) {
@ -327,18 +326,14 @@ void FixGCMC::options(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"rigid") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
int n = strlen(arg[iarg+1]) + 1;
delete [] idrigid;
idrigid = new char[n];
strcpy(idrigid,arg[iarg+1]);
idrigid = utils::strdup(arg[iarg+1]);
rigidflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"shake") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
int n = strlen(arg[iarg+1]) + 1;
delete [] idshake;
idshake = new char[n];
strcpy(idshake,arg[iarg+1]);
idshake = utils::strdup(arg[iarg+1]);
shakeflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"full_energy") == 0) {
@ -353,9 +348,7 @@ void FixGCMC::options(int narg, char **arg)
ngroupsmax*sizeof(char *),
"fix_gcmc:groupstrings");
}
int n = strlen(arg[iarg+1]) + 1;
groupstrings[ngroups] = new char[n];
strcpy(groupstrings[ngroups],arg[iarg+1]);
groupstrings[ngroups] = utils::strdup(arg[iarg+1]);
ngroups++;
iarg += 2;
} else if (strcmp(arg[iarg],"grouptype") == 0) {
@ -370,9 +363,7 @@ void FixGCMC::options(int narg, char **arg)
"fix_gcmc:grouptypestrings");
}
grouptypes[ngrouptypes] = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
int n = strlen(arg[iarg+2]) + 1;
grouptypestrings[ngrouptypes] = new char[n];
strcpy(grouptypestrings[ngrouptypes],arg[iarg+2]);
grouptypestrings[ngrouptypes] = utils::strdup(arg[iarg+2]);
ngrouptypes++;
iarg += 3;
} else if (strcmp(arg[iarg],"intra_energy") == 0) {

View File

@ -224,9 +224,7 @@ void FixWidom::options(int narg, char **arg)
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix widom 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],"charge") == 0) {

View File

@ -17,17 +17,17 @@
#include "compute_ti.h"
#include <cstring>
#include "atom.h"
#include "update.h"
#include "domain.h"
#include "force.h"
#include "pair.h"
#include "kspace.h"
#include "input.h"
#include "variable.h"
#include "error.h"
#include "force.h"
#include "input.h"
#include "kspace.h"
#include "pair.h"
#include "update.h"
#include "variable.h"
#include <cstring>
using namespace LAMMPS_NS;
@ -77,21 +77,15 @@ ComputeTI::ComputeTI(LAMMPS *lmp, int narg, char **arg) :
else if (strcmp(arg[iarg],"tail") == 0) which[nterms] = TAIL;
else which[nterms] = PAIR;
int n = strlen(arg[iarg]) + 1;
pstyle[nterms] = new char[n];
strcpy(pstyle[nterms],arg[iarg]);
pstyle[nterms] = utils::strdup(arg[iarg]);
utils::bounds(FLERR,arg[iarg+1],1,atom->ntypes,ilo[nterms],ihi[nterms],error);
iarg += 1;
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
int n = strlen(&arg[iarg+1][2]) + 1;
var1[nterms] = new char[n];
strcpy(var1[nterms],&arg[iarg+1][2]);
var1[nterms] = utils::strdup(&arg[iarg+1][2]);
} else error->all(FLERR,"Illegal compute ti command");
if (strstr(arg[iarg+2],"v_") == arg[iarg+2]) {
int n = strlen(&arg[iarg+2][2]) + 1;
var2[nterms] = new char[n];
strcpy(var2[nterms],&arg[iarg+2][2]);
var2[nterms] = utils::strdup(&arg[iarg+2][2]);
} else error->all(FLERR,"Illegal compute ti command");
nterms++;

View File

@ -697,9 +697,7 @@ void FixDeposit::options(int narg, char **arg)
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix deposit 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]);
iarg += 2;
} else if (strcmp(arg[iarg],"mol") == 0) {
@ -728,18 +726,14 @@ void FixDeposit::options(int narg, char **arg)
iarg += nmol+1;
} else if (strcmp(arg[iarg],"rigid") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
int n = strlen(arg[iarg+1]) + 1;
delete [] idrigid;
idrigid = new char[n];
strcpy(idrigid,arg[iarg+1]);
idrigid = utils::strdup(arg[iarg+1]);
rigidflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"shake") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
int n = strlen(arg[iarg+1]) + 1;
delete [] idshake;
idshake = new char[n];
strcpy(idshake,arg[iarg+1]);
idshake = utils::strdup(arg[iarg+1]);
shakeflag = 1;
iarg += 2;

View File

@ -44,9 +44,7 @@ FixEvaporate::FixEvaporate(LAMMPS *lmp, int narg, char **arg) :
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
nflux = utils::inumeric(FLERR,arg[4],false,lmp);
iregion = domain->find_region(arg[5]);
int n = strlen(arg[5]) + 1;
idregion = new char[n];
strcpy(idregion,arg[5]);
idregion = utils::strdup(arg[5]);
int seed = utils::inumeric(FLERR,arg[6],false,lmp);
if (nevery <= 0 || nflux <= 0)

View File

@ -42,9 +42,7 @@ FixOneWay::FixOneWay(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
if (nevery < 1) error->all(FLERR,"Illegal fix oneway command");
int len = strlen(arg[4]);
regionstr = new char[len+1];
strcpy(regionstr,arg[4]);
regionstr = utils::strdup(arg[4]);
if (strcmp(arg[5], "x") == 0) direction = X|PLUS;
if (strcmp(arg[5], "X") == 0) direction = X|PLUS;

View File

@ -82,19 +82,11 @@ FixOrientBCC::FixOrientBCC(LAMMPS *lmp, int narg, char **arg) :
uxif_high = utils::numeric(FLERR,arg[8],false,lmp);
if (direction_of_motion == 0) {
int n = strlen(arg[9]) + 1;
chifilename = new char[n];
strcpy(chifilename,arg[9]);
n = strlen(arg[10]) + 1;
xifilename = new char[n];
strcpy(xifilename,arg[10]);
chifilename = utils::strdup(arg[9]);
xifilename = utils::strdup(arg[10]);
} else if (direction_of_motion == 1) {
int n = strlen(arg[9]) + 1;
xifilename = new char[n];
strcpy(xifilename,arg[9]);
n = strlen(arg[10]) + 1;
chifilename = new char[n];
strcpy(chifilename,arg[10]);
xifilename = utils::strdup(arg[9]);
chifilename = utils::strdup(arg[10]);
} else error->all(FLERR,"Illegal fix orient/bcc command");
// initializations

View File

@ -80,19 +80,11 @@ FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) :
uxif_high = utils::numeric(FLERR,arg[8],false,lmp);
if (direction_of_motion == 0) {
int n = strlen(arg[9]) + 1;
chifilename = new char[n];
strcpy(chifilename,arg[9]);
n = strlen(arg[10]) + 1;
xifilename = new char[n];
strcpy(xifilename,arg[10]);
chifilename = utils::strdup(arg[9]);
xifilename = utils::strdup(arg[10]);
} else if (direction_of_motion == 1) {
int n = strlen(arg[9]) + 1;
xifilename = new char[n];
strcpy(xifilename,arg[9]);
n = strlen(arg[10]) + 1;
chifilename = new char[n];
strcpy(chifilename,arg[10]);
xifilename = utils::strdup(arg[9]);
chifilename = utils::strdup(arg[10]);
} else error->all(FLERR,"Illegal fix orient/fcc command");
// initializations

View File

@ -427,22 +427,19 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename)
if (strcmp(keywd,"elems") == 0) {
for (int ielem = 0; ielem < nelements; ielem++) {
char* elemtmp = keyval;
int n = strlen(elemtmp) + 1;
elements[ielem] = new char[n];
strcpy(elements[ielem],elemtmp);
elements[ielem] = utils::strdup(keyval);
keyval = strtok(nullptr,"' \t\n\r\f");
}
elementsflag = 1;
} else if (strcmp(keywd,"radelems") == 0) {
for (int ielem = 0; ielem < nelements; ielem++) {
radelem[ielem] = atof(keyval);
radelem[ielem] = utils::numeric(FLERR,keyval,false,lmp);
keyval = strtok(nullptr,"' \t\n\r\f");
}
radelemflag = 1;
} else if (strcmp(keywd,"welems") == 0) {
for (int ielem = 0; ielem < nelements; ielem++) {
wjelem[ielem] = atof(keyval);
wjelem[ielem] = utils::numeric(FLERR,keyval,false,lmp);
keyval = strtok(nullptr,"' \t\n\r\f");
}
wjelemflag = 1;

View File

@ -18,9 +18,9 @@
#include "mliap_model_nn.h"
#include "pair_mliap.h"
#include "mliap_data.h"
#include "error.h"
#include "comm.h"
#include "error.h"
#include "memory.h"
#include "tokenizer.h"

View File

@ -206,7 +206,5 @@ void ComputeEventDisplace::reset_extra_compute_fix(const char *id_new)
id_event = nullptr;
if (id_new == nullptr) return;
int n = strlen(id_new) + 1;
id_event = new char[n];
strcpy(id_event,id_new);
id_event = utils::strdup(id_new);
}

View File

@ -77,8 +77,7 @@ void PRD::command(int narg, char **arg)
t_dephase = utils::inumeric(FLERR,arg[3],false,lmp);
t_corr = utils::inumeric(FLERR,arg[4],false,lmp);
char *id_compute = new char[strlen(arg[5])+1];
strcpy(id_compute,arg[5]);
char *id_compute = utils::strdup(arg[5]);
int seed = utils::inumeric(FLERR,arg[6],false,lmp);
options(narg-7,&arg[7]);
@ -875,15 +874,8 @@ void PRD::options(int narg, char **arg)
temp_flag = 0;
stepmode = 0;
char *str = (char *) "geom";
int n = strlen(str) + 1;
loop_setting = new char[n];
strcpy(loop_setting,str);
str = (char *) "gaussian";
n = strlen(str) + 1;
dist_setting = new char[n];
strcpy(dist_setting,str);
loop_setting = utils::strdup("geom");
dist_setting = utils::strdup("gaussian");
int iarg = 0;
while (iarg < narg) {
@ -912,16 +904,12 @@ void PRD::options(int narg, char **arg)
else if (strcmp(arg[iarg+1],"local") == 0) loop_setting = nullptr;
else if (strcmp(arg[iarg+1],"geom") == 0) loop_setting = nullptr;
else error->all(FLERR,"Illegal prd command");
int n = strlen(arg[iarg+1]) + 1;
loop_setting = new char[n];
strcpy(loop_setting,arg[iarg+1]);
loop_setting = utils::strdup(arg[iarg+1]);
if (strcmp(arg[iarg+2],"uniform") == 0) dist_setting = nullptr;
else if (strcmp(arg[iarg+2],"gaussian") == 0) dist_setting = nullptr;
else error->all(FLERR,"Illegal prd command");
n = strlen(arg[iarg+2]) + 1;
dist_setting = new char[n];
strcpy(dist_setting,arg[iarg+2]);
dist_setting = utils::strdup(arg[iarg+2]);
iarg += 3;

View File

@ -89,15 +89,12 @@ void TAD::command(int narg, char **arg)
delta_conf = utils::numeric(FLERR,arg[4],false,lmp);
tmax = utils::numeric(FLERR,arg[5],false,lmp);
char *id_compute = new char[strlen(arg[6])+1];
strcpy(id_compute,arg[6]);
char *id_compute = utils::strdup(arg[6]);
// quench minimizer is set by min_style command
// NEB minimizer is set by options, default = quickmin
int n = strlen(update->minimize_style) + 1;
min_style = new char[n];
strcpy(min_style,update->minimize_style);
min_style = utils::strdup(update->minimize_style);
options(narg-7,&arg[7]);
@ -585,9 +582,7 @@ void TAD::options(int narg, char **arg)
n2steps_neb = 100;
nevery_neb = 10;
int n = strlen("quickmin") + 1;
min_style_neb = new char[n];
strcpy(min_style_neb,"quickmin");
min_style_neb = utils::strdup("quickmin");
dt_neb = update->dt;
neb_logfilename = nullptr;
@ -619,9 +614,7 @@ void TAD::options(int narg, char **arg)
} else if (strcmp(arg[iarg],"neb_style") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal tad command");
delete [] min_style_neb;
int n = strlen(arg[iarg+1]) + 1;
min_style_neb = new char[n];
strcpy(min_style_neb,arg[iarg+1]);
min_style_neb = utils::strdup(arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"neb_step") == 0) {
@ -635,9 +628,7 @@ void TAD::options(int narg, char **arg)
if (iarg+2 > narg) error->all(FLERR,"Illegal tad command");
if (strcmp(arg[iarg+1],"none") == 0) neb_logfilename = nullptr;
else {
int n = strlen(arg[iarg+1]) + 1;
neb_logfilename = new char[n];
strcpy(neb_logfilename,arg[iarg+1]);
neb_logfilename = utils::strdup(arg[iarg+1]);
}
iarg += 2;
} else error->all(FLERR,"Illegal tad command");

View File

@ -12,14 +12,16 @@
------------------------------------------------------------------------- */
#include "compute_erotate_rigid.h"
#include <cstring>
#include "update.h"
#include "force.h"
#include "modify.h"
#include "error.h"
#include "fix.h"
#include "fix_rigid.h"
#include "fix_rigid_small.h"
#include "error.h"
#include "force.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS;
@ -33,9 +35,7 @@ ComputeERotateRigid::ComputeERotateRigid(LAMMPS *lmp, int narg, char **arg) :
scalar_flag = 1;
extscalar = 1;
int n = strlen(arg[3]) + 1;
rfix = new char[n];
strcpy(rfix,arg[3]);
rfix = utils::strdup(arg[3]);
}
/* ---------------------------------------------------------------------- */

View File

@ -12,14 +12,16 @@
------------------------------------------------------------------------- */
#include "compute_ke_rigid.h"
#include <cstring>
#include "update.h"
#include "force.h"
#include "modify.h"
#include "error.h"
#include "fix.h"
#include "fix_rigid.h"
#include "fix_rigid_small.h"
#include "error.h"
#include "force.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS;
@ -33,9 +35,7 @@ ComputeKERigid::ComputeKERigid(LAMMPS *lmp, int narg, char **arg) :
scalar_flag = 1;
extscalar = 1;
int n = strlen(arg[3]) + 1;
rfix = new char[n];
strcpy(rfix,arg[3]);
rfix = utils::strdup(arg[3]);
}
/* ---------------------------------------------------------------------- */

View File

@ -40,9 +40,7 @@ ComputeRigidLocal::ComputeRigidLocal(LAMMPS *lmp, int narg, char **arg) :
local_flag = 1;
nvalues = narg - 4;
int n = strlen(arg[3]) + 1;
idrigid = new char[n];
strcpy(idrigid,arg[3]);
idrigid = utils::strdup(arg[3]);
rstyle = new int[nvalues];

View File

@ -24,17 +24,19 @@
#include "fix_ehex.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "domain.h"
#include "region.h"
#include "group.h"
#include "force.h"
#include "update.h"
#include "modify.h"
#include "memory.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "modify.h"
#include "region.h"
#include "update.h"
#include <cmath>
#include <cstring>
#include "fix_shake.h"
using namespace LAMMPS_NS;
@ -91,9 +93,7 @@ FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix ehex 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]);
iarg += 2;
}

View File

@ -1202,9 +1202,7 @@ int FixRigidNH::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)
@ -1236,9 +1234,7 @@ int FixRigidNH::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");

View File

@ -1319,9 +1319,7 @@ int FixRigidNHSmall::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)
@ -1353,9 +1351,7 @@ int FixRigidNHSmall::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");

View File

@ -55,34 +55,15 @@ FixRigidNPH::FixRigidNPH(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp");
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
id_press = utils::strdup(std::string(id)+"_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press,id_temp));
pcomputeflag = 1;
}

View File

@ -58,34 +58,15 @@ FixRigidNPHSmall::FixRigidNPHSmall(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp");
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
id_press = utils::strdup(std::string(id)+"_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press,id_temp));
pcomputeflag = 1;
}

View File

@ -65,34 +65,15 @@ FixRigidNPT::FixRigidNPT(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp");
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
id_press = utils::strdup(std::string(id)+"_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press,id_temp));
pcomputeflag = 1;
}

View File

@ -69,34 +69,15 @@ FixRigidNPTSmall::FixRigidNPTSmall(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp");
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
id_press = utils::strdup(std::string(id)+"_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press,id_temp));
pcomputeflag = 1;
}

View File

@ -19,19 +19,20 @@
#include "fix_msst.h"
#include <cstring>
#include <cmath>
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "modify.h"
#include "fix_external.h"
#include "compute.h"
#include "kspace.h"
#include "update.h"
#include "domain.h"
#include "memory.h"
#include "error.h"
#include "fix_external.h"
#include "force.h"
#include "kspace.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -840,9 +841,7 @@ int FixMSST::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)
@ -864,9 +863,7 @@ int FixMSST::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(id_press);
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");

View File

@ -12,15 +12,17 @@
------------------------------------------------------------------------- */
#include "fix_nphug.h"
#include <cstring>
#include <cmath>
#include "modify.h"
#include "error.h"
#include "update.h"
#include "compute.h"
#include "force.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "modify.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -118,51 +120,22 @@ FixNPHug::FixNPHug(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(std::string(id_temp)+" all temp");
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
id_press = utils::strdup(std::string(id)+"_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press,id_temp));
pcomputeflag = 1;
// create a new compute potential energy compute
n = strlen(id) + 4;
id_pe = new char[n];
strcpy(id_pe,id);
strcat(id_pe,"_pe");
newarg = new char*[3];
newarg[0] = id_pe;
newarg[1] = (char*)"all";
newarg[2] = (char*)"pe";
modify->add_compute(3,newarg);
delete [] newarg;
id_pe = utils::strdup(std::string(id)+"_pe");
modify->add_compute(std::string(id_pe)+" all pe");
peflag = 1;
}

View File

@ -23,18 +23,19 @@
#include "fix_neb_spin.h"
#include <cmath>
#include <cstring>
#include "universe.h"
#include "update.h"
#include "atom.h"
#include "comm.h"
#include "modify.h"
#include "compute.h"
#include "group.h"
#include "memory.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "modify.h"
#include "universe.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -120,17 +121,8 @@ FixNEBSpin::FixNEBSpin(LAMMPS *lmp, int narg, char **arg) :
// create a new compute pe style
// id = fix-ID + pe, compute group = all
int n = strlen(id) + 4;
id_pe = new char[n];
strcpy(id_pe,id);
strcat(id_pe,"_pe");
char **newarg = new char*[3];
newarg[0] = id_pe;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pe";
modify->add_compute(3,newarg);
delete [] newarg;
id_pe = utils::strdup(std::string(id)+"_pe");
modify->add_compute(std::string(id_pe)+" all pe");
// initialize local storage