diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index 34bd855879..f7e2db69b9 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -582,8 +582,12 @@ void ComputeChunkAtom::init() // fixstore initializes all values to 0.0 if ((idsflag == ONCE || lockcount) && !fixstore) { - modify->add_fix(fmt::format("{}_COMPUTE_STORE {} STORE peratom 1 1", - id,group->names[igroup])); + 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 1", group->names[igroup]); + modify->add_fix(cmd); fixstore = (FixStore *) modify->fix[modify->nfix-1]; } diff --git a/src/compute_displace_atom.cpp b/src/compute_displace_atom.cpp index 9a82924acb..b20dd3bec3 100644 --- a/src/compute_displace_atom.cpp +++ b/src/compute_displace_atom.cpp @@ -73,8 +73,12 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) : // create a new fix STORE style // id = compute-ID + COMPUTE_STORE, fix group = compute group - modify->add_fix(fmt::format("{}_COMPUTE_STORE {} STORE peratom 1 3", - id,group->names[igroup])); + 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]); + modify->add_fix(cmd); fix = (FixStore *) modify->fix[modify->nfix-1]; // calculate xu,yu,zu for fix store array diff --git a/src/fix_numdiff.cpp b/src/fix_numdiff.cpp index 0fc5b4ada0..a4ac86e0c5 100644 --- a/src/fix_numdiff.cpp +++ b/src/fix_numdiff.cpp @@ -55,17 +55,12 @@ FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) : if (nevery <= 0 || delta <= 0.0) error->all(FLERR,"Illegal fix numdiff command"); - int n = strlen(id) + 6; - id_pe = new char[n]; - strcpy(id_pe,id); - strcat(id_pe,"_pe"); + std::string cmd = id + std::string("_pe"); + id_pe = new char[cmd.size()+1]; + strcpy(id_pe,cmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_pe; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pe"; - modify->add_compute(3,newarg); - delete [] newarg; + cmd += " all pe"; + modify->add_compute(cmd); maxatom = 0; diff --git a/src/fix_press_berendsen.cpp b/src/fix_press_berendsen.cpp index 184f02c440..db6d56799a 100644 --- a/src/fix_press_berendsen.cpp +++ b/src/fix_press_berendsen.cpp @@ -14,6 +14,7 @@ #include "fix_press_berendsen.h" #include #include +#include #include "atom.h" #include "force.h" #include "comm.h" @@ -217,35 +218,24 @@ FixPressBerendsen::FixPressBerendsen(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"); + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp,tcmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + tcmd += " all temp"; + modify->add_compute(tcmd); tflag = 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"); + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press,pcmd.c_str()); - 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; + pcmd += " all pressure " + std::string(id_temp); + modify->add_compute(pcmd); pflag = 1; nrigid = 0; diff --git a/src/fix_temp_berendsen.cpp b/src/fix_temp_berendsen.cpp index be8922be4e..2f687aeecf 100644 --- a/src/fix_temp_berendsen.cpp +++ b/src/fix_temp_berendsen.cpp @@ -13,6 +13,7 @@ #include "fix_temp_berendsen.h" #include +#include #include #include "atom.h" #include "force.h" @@ -70,17 +71,12 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp, compute group = fix group - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string cmd = id + std::string("_temp"); + id_temp = new char[cmd.size()+1]; + strcpy(id_temp,cmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + cmd += group->names[igroup] + std::string(" temp"); + modify->add_compute(cmd); tflag = 1; energy = 0; diff --git a/src/fix_temp_csld.cpp b/src/fix_temp_csld.cpp index f827c88f51..715d9a8692 100644 --- a/src/fix_temp_csld.cpp +++ b/src/fix_temp_csld.cpp @@ -17,6 +17,7 @@ #include "fix_temp_csld.h" #include +#include #include #include "atom.h" #include "force.h" @@ -79,17 +80,12 @@ FixTempCSLD::FixTempCSLD(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp, compute group = fix group - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string cmd = id + std::string("_temp"); + id_temp = new char[cmd.size()+1]; + strcpy(id_temp,cmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + cmd += group->names[igroup] + std::string(" temp"); + modify->add_compute(cmd); tflag = 1; vhold = NULL; diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index 55cbb60407..aabdcf2bc3 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "atom.h" #include "force.h" #include "comm.h" @@ -156,17 +157,12 @@ FixTempCSVR::FixTempCSVR(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp style // id = fix-ID + temp, compute group = fix group - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string cmd = id + std::string("_temp"); + id_temp = new char[cmd.size()+1]; + strcpy(id_temp,cmd.c_str()); - char **newarg = new char*[3]; - newarg[0] = id_temp; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + cmd += group->names[igroup] + std::string(" temp"); + modify->add_compute(cmd); tflag = 1; nmax = -1; diff --git a/src/fix_temp_rescale.cpp b/src/fix_temp_rescale.cpp index a9d605d5ba..f25d1408cc 100644 --- a/src/fix_temp_rescale.cpp +++ b/src/fix_temp_rescale.cpp @@ -13,6 +13,7 @@ #include "fix_temp_rescale.h" #include +#include #include #include "atom.h" #include "force.h" @@ -66,17 +67,12 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) : // create a new compute temp // id = fix-ID + temp, compute group = fix group - int n = strlen(id) + 6; - id_temp = new char[n]; - strcpy(id_temp,id); - strcat(id_temp,"_temp"); + std::string cmd = id + std::string("_temp"); + id_temp = new char[cmd.size()+1]; + strcpy(id_temp,cmd.c_str()); - char **newarg = new char*[6]; - newarg[0] = id_temp; - newarg[1] = group->names[igroup]; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + cmd += group->names[igroup] + std::string(" temp"); + modify->add_compute(cmd); tflag = 1; energy = 0.0;