diff --git a/src/ATC/fix_atc.cpp b/src/ATC/fix_atc.cpp index d9770d86de..577a488f5e 100644 --- a/src/ATC/fix_atc.cpp +++ b/src/ATC/fix_atc.cpp @@ -700,20 +700,17 @@ int FixATC::size_restart(int /* nlocal */) { void FixATC::write_restart(FILE * /* fp */) { - char ** args = new char*[2]; - args[0] = new char[50]; - args[1] = new char[50]; - sprintf(args[0],"write_restart"); - sprintf(args[1],"ATC.restart"); + char *args[2]; + args[0] = utils::strdup("write_restart"); + args[1] = utils::strdup("sprintf(args[1],"ATC.restart"); // Then call all objects I own to write their data if (comm->me == 0) { atc_->modify(2,args); } - delete [] args[0]; - delete [] args[1]; - delete [] args; + delete[] args[0]; + delete[] args[1]; } /* ---------------------------------------------------------------------- @@ -722,20 +719,17 @@ void FixATC::write_restart(FILE * /* fp */) { void FixATC::restart(char * /* buf */) { - char ** args = new char*[2]; - args[0] = new char[50]; - args[1] = new char[50]; - sprintf(args[0],"read_restart"); - sprintf(args[1],"ATC.restart"); + char *args[2]; + args[0] = utils::strdup("read_restart"); + args[1] = utils::strdup("ATC.restart"); // Then call all objects I own to write their data if (comm->me == 0) { atc_->modify(2,args); } - delete [] args[0]; - delete [] args[1]; - delete [] args; + delete[] args[0]; + delete[] args[1]; } /* ---------------------------------------------------------------------- diff --git a/src/SCAFACOS/scafacos.cpp b/src/SCAFACOS/scafacos.cpp index 51bf4fb45e..6d4db28fb6 100644 --- a/src/SCAFACOS/scafacos.cpp +++ b/src/SCAFACOS/scafacos.cpp @@ -80,7 +80,7 @@ void Scafacos::settings(int narg, char **arg) Scafacos::~Scafacos() { - delete [] method; + delete[] method; memory->destroy(xpbc); memory->destroy(epot); @@ -95,16 +95,15 @@ Scafacos::~Scafacos() void Scafacos::init() { // error checks - if (screen && me == 0) fprintf(screen, - "Setting up ScaFaCoS with solver %s ...\n",method); - if (logfile && me == 0) fprintf(logfile, - "Setting up ScaFaCoS with solver %s ...\n",method); + if (me == 0) { + utils::logmesg(lmp,"Setting up ScaFaCoS with solver {} ...\n",method); - if ((strcmp(method,"p3m") == 0) && (me == 0)) - error->warning(FLERR,"Virial computation for P3M not available"); + if (strcmp(method,"p3m") == 0) + error->warning(FLERR,"Virial computation for P3M not available"); - if ((strcmp(method,"ewald") == 0) && (me == 0)) - error->warning(FLERR,"Virial computation for Ewald not available"); + if (strcmp(method,"ewald") == 0) + error->warning(FLERR,"Virial computation for Ewald not available"); + } if (!atom->q_flag) error->all(FLERR,"Kspace style requires atom attribute q"); @@ -119,8 +118,7 @@ void Scafacos::init() error->all(FLERR,"Scafacos atom count exceeds 2B"); if (atom->molecular != Atom::ATOMIC) - error->all(FLERR, - "Cannot use Scafacos with molecular charged systems yet"); + error->all(FLERR, "Cannot use Scafacos with molecular charged systems yet"); FCSResult result; @@ -358,15 +356,13 @@ int Scafacos::modify_param(int narg, char **arg) // value1 = 0, 1 // 0 -> homogenous system (default) // 1 -> inhomogenous system (more internal tuning is provided (sequential!)) - if (strcmp(arg[1],"fmm_tuning") == 0) - { - if (screen && me == 0) fprintf(screen, - "ScaFaCoS setting fmm inhomogen tuning ...\n"); - if (logfile && me == 0) fprintf(logfile, - "ScaFaCoS setting fmm inhomogen tuning ...\n"); + if (strcmp(arg[1],"fmm_tuning") == 0) { + if (me == 0) + utils::logmesg(lmp, "ScaFaCoS setting fmm inhomogen tuning ...\n"); + if (narg < 3) error->all(FLERR, "Illegal kspace_modify command (fmm_tuning)"); - fmm_tuning_flag = atoi(arg[2]); + fmm_tuning_flag = utils::inumeric(FLERR, arg[2], false, tmp); return 3; }