diff --git a/src/angle_deprecated.cpp b/src/angle_deprecated.cpp index cc29c9978e..968445f3f1 100644 --- a/src/angle_deprecated.cpp +++ b/src/angle_deprecated.cpp @@ -16,7 +16,7 @@ ------------------------------------------------------------------------- */ #include "angle_deprecated.h" -#include +#include #include "angle_hybrid.h" #include "comm.h" #include "force.h" @@ -25,21 +25,11 @@ using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This angle style is no longer available"); -} - /* ---------------------------------------------------------------------- */ void AngleDeprecated::settings(int, char **) { - const char *my_style = force->angle_style; + std::string my_style = force->angle_style; // hybrid substyles are created in AngleHybrid::settings(), so when this is // called, our style was just added at the end of the list of substyles @@ -49,10 +39,13 @@ void AngleDeprecated::settings(int, char **) my_style = hybrid->keywords[hybrid->nstyles]; } - if (strcmp(my_style,"DEPRECATED") == 0) { - writemsg(lmp,"\nAngle style 'DEPRECATED' is a dummy style\n\n",0); - + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nAngle style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This angle style is no longer available"); } diff --git a/src/bond_deprecated.cpp b/src/bond_deprecated.cpp index 3e20553cac..7bd65b795d 100644 --- a/src/bond_deprecated.cpp +++ b/src/bond_deprecated.cpp @@ -16,42 +16,36 @@ ------------------------------------------------------------------------- */ #include "bond_deprecated.h" -#include +#include #include "bond_hybrid.h" #include "comm.h" #include "force.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This bond style is no longer available"); -} - /* ---------------------------------------------------------------------- */ void BondDeprecated::settings(int, char **) { - const char *my_style = force->bond_style; + std::string my_style = force->bond_style; // hybrid substyles are created in BondHybrid::settings(), so when this is // called, our style was just added at the end of the list of substyles - if (strncmp(my_style,"hybrid",6) == 0) { + if (utils::strmatch(my_style,"^hybrid")) { BondHybrid *hybrid = (BondHybrid *)force->bond; my_style = hybrid->keywords[hybrid->nstyles]; } - if (strcmp(my_style,"DEPRECATED") == 0) { - writemsg(lmp,"\nBond style 'DEPRECATED' is a dummy style\n\n",0); - + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nBond style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This bond style is no longer available"); } diff --git a/src/compute_deprecated.cpp b/src/compute_deprecated.cpp index 1db78b6bdf..356e6b372a 100644 --- a/src/compute_deprecated.cpp +++ b/src/compute_deprecated.cpp @@ -12,28 +12,25 @@ ------------------------------------------------------------------------- */ #include "compute_deprecated.h" -#include +#include #include "comm.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This compute style is no longer available"); -} - /* ---------------------------------------------------------------------- */ ComputeDeprecated::ComputeDeprecated(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { - if (strcmp(style,"DEPRECATED") == 0) { - writemsg(lmp,"\nCompute style 'DEPRECATED' is a dummy style\n\n",0); + std::string my_style = style; + + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nCompute style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This compute style is no longer available"); } diff --git a/src/dihedral_deprecated.cpp b/src/dihedral_deprecated.cpp index 0205b1b887..a44dcae9d9 100644 --- a/src/dihedral_deprecated.cpp +++ b/src/dihedral_deprecated.cpp @@ -16,42 +16,35 @@ ------------------------------------------------------------------------- */ #include "dihedral_deprecated.h" -#include +#include #include "dihedral_hybrid.h" #include "comm.h" #include "force.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This dihedral style is no longer available"); -} - /* ---------------------------------------------------------------------- */ void DihedralDeprecated::settings(int, char **) { - const char *my_style = force->dihedral_style; + std::string my_style = force->dihedral_style; - // hybrid substyles are created in DihedralHybrid::settings(), so when this is - // called, our style was just added at the end of the list of substyles + // hybrid substyles are created in DihedralHybrid::settings(), + // so when this is called, our style was just added at the end + // of the list of substyles - if (strncmp(my_style,"hybrid",6) == 0) { + if (utils::strmatch(my_style,"^hybrid")) { DihedralHybrid *hybrid = (DihedralHybrid *)force->dihedral; my_style = hybrid->keywords[hybrid->nstyles]; } - if (strcmp(my_style,"DEPRECATED") == 0) { - writemsg(lmp,"\nDihedral style 'DEPRECATED' is a dummy style\n\n",0); - + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nDihedral style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This dihedral style is no longer available"); } - - diff --git a/src/dump_deprecated.cpp b/src/dump_deprecated.cpp index 4263b9801f..3dae66248d 100644 --- a/src/dump_deprecated.cpp +++ b/src/dump_deprecated.cpp @@ -12,29 +12,25 @@ ------------------------------------------------------------------------- */ #include "dump_deprecated.h" -#include +#include #include "comm.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This dump style is no longer available"); -} - /* ---------------------------------------------------------------------- */ DumpDeprecated::DumpDeprecated(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) { - if (strcmp(style,"DEPRECATED") == 0) { - writemsg(lmp,"\nDump style 'DEPRECATED' is a dummy style\n\n",0); + std::string my_style = style; + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nDump style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This dump style is no longer available"); } diff --git a/src/fix_deprecated.cpp b/src/fix_deprecated.cpp index 0c212668b3..c6313bd872 100644 --- a/src/fix_deprecated.cpp +++ b/src/fix_deprecated.cpp @@ -12,39 +12,37 @@ ------------------------------------------------------------------------- */ #include "fix_deprecated.h" -#include +#include #include "comm.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This fix style is no longer available"); -} - /* ---------------------------------------------------------------------- */ FixDeprecated::FixDeprecated(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (strcmp(style,"DEPRECATED") == 0) { - writemsg(lmp,"\nFix style 'DEPRECATED' is a dummy style\n\n",0); + std::string my_style = style; - } else if (strncmp(style,"ave/spatial",11) == 0) { - writemsg(lmp,"\nFix styles 'ave/spatial' and 'ave/spatial/sphere' have " - "been replaced\nby the more general fix ave/chunk and compute " - "chunk/atom commands.\nAll ave/spatial and ave/spatial/sphere " - "functionality is available in these\nnew commands. These " - "ave/spatial keywords & options are part of fix ave/chunk:\n" - " Nevery, Nrepeat, Nfreq, input values, norm, ave, file, " - "overwrite, title123\nThese ave/spatial keywords & options for " - "binning are part of compute chunk/atom:\n dim, origin, delta," - " region, bound, discard, units\n\n"); + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nFix style 'DEPRECATED' is a dummy style\n\n"); + return; + } else if (utils::strmatch(my_style,"^ave/spatial")) { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nFix styles 'ave/spatial' and 'ave/spatial/sphere'" + " have been replaced\nby the more general fix ave/chunk " + "and compute chunk/atom commands.\nAll ave/spatial and " + "ave/spatial/sphere functionality is available in these" + "\nnew commands. These ave/spatial keywords & options are" + " part of fix ave/chunk:\n Nevery, Nrepeat, Nfreq, input" + " values, norm, ave, file, overwrite, title123\nThese " + "ave/spatial keywords & options for binning are part of " + "compute chunk/atom:\n dim, origin, delta, region, " + "bound, discard, units\n\n"); } + + lmp->error->all(FLERR,"This fix style is no longer available"); } diff --git a/src/improper_deprecated.cpp b/src/improper_deprecated.cpp index 62a688527a..ea089b5da6 100644 --- a/src/improper_deprecated.cpp +++ b/src/improper_deprecated.cpp @@ -16,42 +16,37 @@ ------------------------------------------------------------------------- */ #include "improper_deprecated.h" -#include +#include #include "improper_hybrid.h" #include "comm.h" #include "force.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This improper style is no longer available"); -} - /* ---------------------------------------------------------------------- */ void ImproperDeprecated::settings(int, char **) { - const char *my_style = force->improper_style; + std::string my_style = force->improper_style; - // hybrid substyles are created in ImproperHybrid::settings(), so when this is - // called, our style was just added at the end of the list of substyles + // hybrid substyles are created in ImproperHybrid::settings(), + // so when this is called, our style was just added at the end + // of the list of substyles - if (strncmp(my_style,"hybrid",6) == 0) { + if (utils::strmatch(my_style,"^hybrid")) { ImproperHybrid *hybrid = (ImproperHybrid *)force->improper; my_style = hybrid->keywords[hybrid->nstyles]; } - if (strcmp(my_style,"DEPRECATED") == 0) { - writemsg(lmp,"\nImproper style 'DEPRECATED' is a dummy style\n\n",0); - + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nImproper style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This improper style is no longer available"); } diff --git a/src/kspace_deprecated.cpp b/src/kspace_deprecated.cpp index 0b6490b4cf..076bd8a186 100644 --- a/src/kspace_deprecated.cpp +++ b/src/kspace_deprecated.cpp @@ -16,33 +16,27 @@ ------------------------------------------------------------------------- */ #include "kspace_deprecated.h" -#include +#include #include "comm.h" #include "force.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This kspace style is no longer available"); -} - /* ---------------------------------------------------------------------- */ void KSpaceDeprecated::settings(int, char **) { - const char *my_style = force->kspace_style; - - if (strcmp(my_style,"DEPRECATED") == 0) { - writemsg(lmp,"\nKSpace style 'DEPRECATED' is a dummy style\n\n",0); + std::string my_style = force->kspace_style; + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nKSpace style 'DEPRECATED' is a dummy style\n\n"); + return; } + + lmp->error->all(FLERR,"This kspace style is no longer available"); } diff --git a/src/pair_deprecated.cpp b/src/pair_deprecated.cpp index 058809eb80..d48638a456 100644 --- a/src/pair_deprecated.cpp +++ b/src/pair_deprecated.cpp @@ -16,45 +16,40 @@ ------------------------------------------------------------------------- */ #include "pair_deprecated.h" -#include +#include #include "pair_hybrid.h" #include "comm.h" #include "force.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This pair style is no longer available"); -} - /* ---------------------------------------------------------------------- */ void PairDeprecated::settings(int, char **) { - const char *my_style = force->pair_style; + std::string my_style = force->pair_style; // hybrid substyles are created in PairHybrid::settings(), so when this is // called, our style was just added at the end of the list of substyles - if (strncmp(my_style,"hybrid",6) == 0) { + if (utils::strmatch(my_style,"^hybrid")) { PairHybrid *hybrid = (PairHybrid *)force->pair; my_style = hybrid->keywords[hybrid->nstyles]; } - if (strcmp(my_style,"reax") == 0) { - writemsg(lmp,"\nPair style 'reax' has been removed from LAMMPS " - "after the 12 December 2018 version\n\n",1); + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nPair style 'DEPRECATED' is a dummy style\n\n"); + return; } - if (strcmp(my_style,"DEPRECATED") == 0) { - writemsg(lmp,"\nPair style 'DEPRECATED' is a dummy style\n\n",0); - + if (my_style == "reax") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nPair style 'reax' has been removed from LAMMPS " + "after the 12 December 2018 version\n\n"); } + + lmp->error->all(FLERR,"This pair style is no longer available"); } diff --git a/src/region_deprecated.cpp b/src/region_deprecated.cpp index a2e4e88393..d0f1fb8e1f 100644 --- a/src/region_deprecated.cpp +++ b/src/region_deprecated.cpp @@ -12,29 +12,24 @@ ------------------------------------------------------------------------- */ #include "region_deprecated.h" -#include +#include #include "comm.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; -static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) -{ - if (lmp->comm->me == 0) { - if (lmp->screen) fputs(msg,lmp->screen); - if (lmp->logfile) fputs(msg,lmp->logfile); - } - if (abend) - lmp->error->all(FLERR,"This region style is no longer available"); -} - /* ---------------------------------------------------------------------- */ RegionDeprecated::RegionDeprecated(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg) { - if (strcmp(style,"DEPRECATED") == 0) { - writemsg(lmp,"\nRegion style 'DEPRECATED' is a dummy style\n\n",0); + std::string my_style = style; + if (my_style == "DEPRECATED") { + if (lmp->comm->me == 0) + utils::logmesg(lmp,"\nRegion style 'DEPRECATED' is a dummy style\n\n"); + return; } + lmp->error->all(FLERR,"This region style is no longer available"); }