From 2fbf86a58d64a85d4d2b42d47c0cd03155d076c8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 7 Apr 2019 20:50:26 -0400 Subject: [PATCH 01/27] add support for creating packages_*.h files in conventional make --- src/Make.sh | 72 +++++++++++++++++++++++++++++++++++--------------- src/Makefile | 1 + src/Purge.list | 24 +++++++++++++++++ 3 files changed, 76 insertions(+), 21 deletions(-) diff --git a/src/Make.sh b/src/Make.sh index 83880780ec..49a673d8ee 100755 --- a/src/Make.sh +++ b/src/Make.sh @@ -55,6 +55,34 @@ style () { fi } +packages () { + list=`grep -sl $1 */$2*.h` + if (test -e packages_$3.tmp) then + rm -f packages_$3.tmp + fi + for file in $list; do + dir="\"`dirname $file`\"" + echo "#undef PACKAGE" >> packages_$3.tmp + echo "#define PACKAGE $dir" >> packages_$3.tmp + qfile="\"$file\"" + echo "#include $qfile" >> packages_$3.tmp + done + if (test ! -e packages_$3.tmp) then + if (test ! -e packages_$3.h) then + touch packages_$3.h + elif (test "`cat packages_$3.h`" != "") then + rm -f packages_$3.h + touch packages_$3.h + fi + elif (test ! -e packages_$3.h) then + mv packages_$3.tmp packages_$3.h + elif (test "`diff --brief packages_$3.h packages_$3.tmp`" != "") then + mv packages_$3.tmp packages_$3.h + else + rm -f packages_$3.tmp + fi +} + # create individual style files # called by "make machine" # col 1 = string to search for @@ -63,28 +91,30 @@ style () { # col 4 = file that includes the style file # col 5 = optional 2nd file that includes the style file -if (test $1 = "style") then +cmd=$1 - style ANGLE_CLASS angle_ angle force - style ATOM_CLASS atom_vec_ atom atom atom_vec_hybrid - style BODY_CLASS body_ body atom_vec_body - style BOND_CLASS bond_ bond force - style COMMAND_CLASS "" command input - style COMPUTE_CLASS compute_ compute modify - style DIHEDRAL_CLASS dihedral_ dihedral force - style DUMP_CLASS dump_ dump output write_dump - style FIX_CLASS fix_ fix modify - style IMPROPER_CLASS improper_ improper force - style INTEGRATE_CLASS "" integrate update - style KSPACE_CLASS "" kspace force - style MINIMIZE_CLASS min_ minimize update - style NBIN_CLASS nbin_ nbin neighbor - style NPAIR_CLASS npair_ npair neighbor - style NSTENCIL_CLASS nstencil_ nstencil neighbor - style NTOPO_CLASS ntopo_ ntopo neighbor - style PAIR_CLASS pair_ pair force - style READER_CLASS reader_ reader read_dump - style REGION_CLASS region_ region domain +if (test $cmd = "style") || (test $cmd = "packages") then + + $cmd ANGLE_CLASS angle_ angle force + $cmd ATOM_CLASS atom_vec_ atom atom atom_vec_hybrid + $cmd BODY_CLASS body_ body atom_vec_body + $cmd BOND_CLASS bond_ bond force + $cmd COMMAND_CLASS "" command input + $cmd COMPUTE_CLASS compute_ compute modify + $cmd DIHEDRAL_CLASS dihedral_ dihedral force + $cmd DUMP_CLASS dump_ dump output write_dump + $cmd FIX_CLASS fix_ fix modify + $cmd IMPROPER_CLASS improper_ improper force + $cmd INTEGRATE_CLASS "" integrate update + $cmd KSPACE_CLASS "" kspace force + $cmd MINIMIZE_CLASS min_ minimize update + $cmd NBIN_CLASS nbin_ nbin neighbor + $cmd NPAIR_CLASS npair_ npair neighbor + $cmd NSTENCIL_CLASS nstencil_ nstencil neighbor + $cmd NTOPO_CLASS ntopo_ ntopo neighbor + $cmd PAIR_CLASS pair_ pair force + $cmd READER_CLASS reader_ reader read_dump + $cmd REGION_CLASS region_ region domain # edit Makefile.lib, for creating non-shared lib # called by "make makelib" diff --git a/src/Makefile b/src/Makefile index 3be4e3e78f..2e6ad9a89f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -205,6 +205,7 @@ gitversion: -f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@ @if [ ! -d $(objdir) ]; then mkdir $(objdir); fi @$(SHELL) Make.sh style + @$(SHELL) Make.sh packages @$(MAKE) $(MFLAGS) lmpinstalledpkgs.h gitversion @echo 'Compiling LAMMPS for machine $@' @if [ -f MAKE/MACHINES/Makefile.$@ ]; \ diff --git a/src/Purge.list b/src/Purge.list index a02697d2bf..634c38c58d 100644 --- a/src/Purge.list +++ b/src/Purge.list @@ -22,6 +22,30 @@ style_nbin.h style_npair.h style_nstencil.h style_ntopo.h +# auto-generated packages files +packages_angle.h +packages_atom.h +packages_body.h +packages_bond.h +packages_command.h +packages_compute.h +packages_dihedral.h +packages_dump.h +packages_fix.h +packages_improper.h +packages_integrate.h +packages_kspace.h +packages_minimize.h +packages_pair.h +packages_reader.h +packages_region.h +packages_neigh_bin.h +packages_neigh_pair.h +packages_neigh_stencil.h +packages_nbin.h +packages_npair.h +packages_nstencil.h +packages_ntopo.h # other auto-generated files lmpinstalledpkgs.h lmpgitversion.h From 916600104111cd0fa37623975a4ffde0db0d1a6c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 7 Apr 2019 20:55:00 -0400 Subject: [PATCH 02/27] add code to allow reporting which styles are part of what package --- src/.gitignore | 1 + src/lammps.cpp | 172 ++++++++++++++++++++++++++++++++++++++++++++++++- src/lammps.h | 4 ++ src/utils.cpp | 20 ++++++ src/utils.h | 10 +++ 5 files changed, 205 insertions(+), 2 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 27f4f8a64c..615c35ed11 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -5,6 +5,7 @@ /lmp_* /style_*.h +/packages_*.h /lmpinstalledpkgs.h /lmpgitversion.h diff --git a/src/lammps.cpp b/src/lammps.cpp index 2b3f001b09..24012c0f18 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "lammps.h" #include "style_angle.h" #include "style_atom.h" @@ -54,10 +56,29 @@ #include "lmpinstalledpkgs.h" #include "lmpgitversion.h" -using namespace LAMMPS_NS; - static void print_style(FILE *fp, const char *str, int &pos); +struct LAMMPS_NS::package_styles_lists { + std::map angle_styles; + std::map atom_styles; + std::map body_styles; + std::map bond_styles; + std::map command_styles; + std::map compute_styles; + std::map dihedral_styles; + std::map dump_styles; + std::map fix_styles; + std::map improper_styles; + std::map integrate_styles; + std::map kspace_styles; + std::map minimize_styles; + std::map pair_styles; + std::map reader_styles; + std::map region_styles; +}; + +using namespace LAMMPS_NS; + /* ---------------------------------------------------------------------- start up LAMMPS allocate fundamental classes (memory, error, universe, input) @@ -86,6 +107,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : initclock = MPI_Wtime(); + init_pkg_lists(); + // check if -mpi is first arg // if so, then 2 apps were launched with one mpirun command // this means passed communicator (e.g. MPI_COMM_WORLD) is bigger than LAMMPS @@ -693,6 +716,8 @@ LAMMPS::~LAMMPS() delete universe; delete error; delete memory; + + delete pkg_lists; } /* ---------------------------------------------------------------------- @@ -867,6 +892,149 @@ void LAMMPS::destroy() python = NULL; } +/* ---------------------------------------------------------------------- + initialize lists of styles in packages +------------------------------------------------------------------------- */ + +void LAMMPS::init_pkg_lists() +{ + pkg_lists = new package_styles_lists; +#define PACKAGE "UNKNOWN" +#define ANGLE_CLASS +#define AngleStyle(key,Class) \ + pkg_lists->angle_styles[#key] = PACKAGE; +#include "packages_angle.h" +#undef AngleStyle +#undef ANGLE_CLASS +#define ATOM_CLASS +#define AtomStyle(key,Class) \ + pkg_lists->atom_styles[#key] = PACKAGE; +#include "packages_atom.h" +#undef AtomStyle +#undef ATOM_CLASS +#define BODY_CLASS +#define BodyStyle(key,Class) \ + pkg_lists->body_styles[#key] = PACKAGE; +#include "packages_body.h" +#undef BodyStyle +#undef BODY_CLASS +#define BOND_CLASS +#define BondStyle(key,Class) \ + pkg_lists->bond_styles[#key] = PACKAGE; +#include "packages_bond.h" +#undef BondStyle +#undef BOND_CLASS +#define COMMAND_CLASS +#define CommandStyle(key,Class) \ + pkg_lists->command_styles[#key] = PACKAGE; +#include "packages_command.h" +#undef CommandStyle +#undef COMMAND_CLASS +#define COMPUTE_CLASS +#define ComputeStyle(key,Class) \ + pkg_lists->compute_styles[#key] = PACKAGE; +#include "packages_compute.h" +#undef ComputeStyle +#undef COMPUTE_CLASS +#define DIHEDRAL_CLASS +#define DihedralStyle(key,Class) \ + pkg_lists->dihedral_styles[#key] = PACKAGE; +#include "packages_dihedral.h" +#undef DihedralStyle +#undef DIHEDRAL_CLASS +#define DUMP_CLASS +#define DumpStyle(key,Class) \ + pkg_lists->dump_styles[#key] = PACKAGE; +#include "packages_dump.h" +#undef DumpStyle +#undef DUMP_CLASS +#define FIX_CLASS +#define FixStyle(key,Class) \ + pkg_lists->fix_styles[#key] = PACKAGE; +#include "packages_fix.h" +#undef FixStyle +#undef FIX_CLASS +#define IMPROPER_CLASS +#define ImproperStyle(key,Class) \ + pkg_lists->improper_styles[#key] = PACKAGE; +#include "packages_improper.h" +#undef ImproperStyle +#undef IMPROPER_CLASS +#define INTEGRATE_CLASS +#define IntegrateStyle(key,Class) \ + pkg_lists->integrate_styles[#key] = PACKAGE; +#include "packages_integrate.h" +#undef IntegrateStyle +#undef INTEGRATE_CLASS +#define KSPACE_CLASS +#define KSpaceStyle(key,Class) \ + pkg_lists->kspace_styles[#key] = PACKAGE; +#include "packages_kspace.h" +#undef KSpaceStyle +#undef KSPACE_CLASS +#define MINIMIZE_CLASS +#define MinimizeStyle(key,Class) \ + pkg_lists->minimize_styles[#key] = PACKAGE; +#include "packages_minimize.h" +#undef MinimizeStyle +#undef MINIMIZE_CLASS +#define PAIR_CLASS +#define PairStyle(key,Class) \ + pkg_lists->pair_styles[#key] = PACKAGE; +#include "packages_pair.h" +#undef PairStyle +#undef PAIR_CLASS +#define READER_CLASS +#define ReaderStyle(key,Class) \ + pkg_lists->reader_styles[#key] = PACKAGE; +#include "packages_reader.h" +#undef ReaderStyle +#undef READER_CLASS +#define REGION_CLASS +#define RegionStyle(key,Class) \ + pkg_lists->region_styles[#key] = PACKAGE; +#include "packages_region.h" +#undef RegionStyle +#undef REGION_CLASS +} + +bool LAMMPS::is_installed_pkg(const char *pkg) +{ + for (int i=0; installed_packages[i] != NULL; ++i) + if (strcmp(installed_packages[i],pkg) == 0) return true; + + return false; +} + +#define check_for_match(style,list,name) \ + if (strcmp(list,#style) == 0) { \ + std::map &styles(pkg_lists-> style ## _styles); \ + if (styles.find(name) != styles.end()) { \ + return styles[name].c_str(); \ + } \ + } + +const char *LAMMPS::match_style(const char *style, const char *name) +{ + check_for_match(angle,style,name); + check_for_match(atom,style,name); + check_for_match(body,style,name); + check_for_match(bond,style,name); + check_for_match(command,style,name); + check_for_match(compute,style,name); + check_for_match(dump,style,name); + check_for_match(fix,style,name); + check_for_match(compute,style,name); + check_for_match(improper,style,name); + check_for_match(integrate,style,name); + check_for_match(kspace,style,name); + check_for_match(minimize,style,name); + check_for_match(pair,style,name); + check_for_match(reader,style,name); + check_for_match(region,style,name); + return NULL; +} + /* ---------------------------------------------------------------------- help message for command line options and styles present in executable ------------------------------------------------------------------------- */ diff --git a/src/lammps.h b/src/lammps.h index 2e052e5ed2..e02d0c764a 100644 --- a/src/lammps.h +++ b/src/lammps.h @@ -63,7 +63,9 @@ class LAMMPS { class CiteMe *citeme; // citation info + const char *match_style(const char *style, const char *name); static const char * installed_packages[]; + static bool is_installed_pkg(const char *pkg); static const bool has_git_info; static const char git_commit[]; @@ -79,6 +81,8 @@ class LAMMPS { void print_config(FILE *); // print compile time settings private: + struct package_styles_lists *pkg_lists; + void init_pkg_lists(); void help(); LAMMPS() {}; // prohibit using the default constructor LAMMPS(const LAMMPS &) {}; // prohibit using the copy constructor diff --git a/src/utils.cpp b/src/utils.cpp index c3c173a73f..42140db0ba 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -11,8 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include #include #include "utils.h" +#include "lammps.h" #include "error.h" /*! \file utils.cpp */ @@ -123,6 +125,24 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size, /* ------------------------------------------------------------------ */ +std::string utils::check_packages_for_style(std::string style, + std::string name, LAMMPS *lmp) +{ + std::string errmsg = "Unrecognized " + style + " style " + name; + const char *pkg = lmp->match_style(style.c_str(),name.c_str()); + + if (pkg) { + errmsg += " is part of the " + std::string(pkg) + " package"; + if (lmp->is_installed_pkg(pkg)) + errmsg += ", but seems to be missing because of a dependency"; + else + errmsg += " which is not enabled in this LAMMPS binary."; + } + return errmsg; +} + +/* ------------------------------------------------------------------ */ + extern "C" { /* Typedef'd pointer to get abstract datatype. */ typedef struct regex_t *re_t; diff --git a/src/utils.h b/src/utils.h index 2596fcd774..7dfba8ead0 100644 --- a/src/utils.h +++ b/src/utils.h @@ -23,6 +23,7 @@ namespace LAMMPS_NS { // forward declarations class Error; + class LAMMPS; namespace utils { @@ -66,6 +67,15 @@ namespace LAMMPS_NS { */ void sfgets(const char *srcname, int srcline, char *s, int size, FILE *fp, const char *filename, Error *error); + + /** \brief Report if a requested style is in a package or may have a typo + * + * \param style type of style that is to be checked for + * \param name name of style that was not found + * \param lmp pointer to top-level LAMMPS class instance + * \return string usable for error messages + */ + std::string check_packages_for_style(std::string style, std::string name, LAMMPS *lmp); } } From d640c712f8df0b8718e894b4f141ae8122ff63ea Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 7 Apr 2019 20:55:39 -0400 Subject: [PATCH 03/27] apply new utility function to most places creating new styles --- src/atom.cpp | 3 ++- src/atom_vec_body.cpp | 3 ++- src/domain.cpp | 8 +++++--- src/force.cpp | 24 ++++++------------------ src/modify.cpp | 14 ++++---------- src/output.cpp | 4 ++-- src/read_dump.cpp | 3 ++- src/utils.cpp | 2 +- src/write_dump.cpp | 3 ++- 9 files changed, 26 insertions(+), 38 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 34ea253751..dfea9348c9 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -39,6 +39,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" #ifdef LMP_USER_INTEL #include "neigh_request.h" @@ -509,7 +510,7 @@ AtomVec *Atom::new_avec(const char *style, int trysuffix, int &sflag) return avec_creator(lmp); } - error->all(FLERR,"Unknown atom style"); + error->all(FLERR,utils::check_packages_for_style("atom",style,lmp).c_str()); return NULL; } diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 893a4c7dc4..d5f286c077 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -25,6 +25,7 @@ #include "fix.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -96,7 +97,7 @@ void AtomVecBody::process_args(int narg, char **arg) #undef BodyStyle #undef BODY_CLASS - else error->all(FLERR,"Unknown body style"); + else error->all(FLERR,utils::check_packages_for_style("body",arg[0],lmp).c_str()); bptr->avec = this; icp = bptr->icp; diff --git a/src/domain.cpp b/src/domain.cpp index 86c4eb2c02..8c3ec97946 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -40,6 +40,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -1714,6 +1715,9 @@ void Domain::add_region(int narg, char **arg) return; } + if (strcmp(arg[1],"none") == 0) + error->all(FLERR,"Unrecognized region style 'none'"); + if (find_region(arg[0]) >= 0) error->all(FLERR,"Reuse of region ID"); // extend Region list if necessary @@ -1752,12 +1756,10 @@ void Domain::add_region(int narg, char **arg) } } - if (strcmp(arg[1],"none") == 0) error->all(FLERR,"Unknown region style"); if (region_map->find(arg[1]) != region_map->end()) { RegionCreator region_creator = (*region_map)[arg[1]]; regions[nregion] = region_creator(lmp, narg, arg); - } - else error->all(FLERR,"Unknown region style"); + } else error->all(FLERR,utils::check_packages_for_style("region",arg[1],lmp).c_str()); // initialize any region variables via init() // in case region is used between runs, e.g. to print a variable diff --git a/src/force.cpp b/src/force.cpp index 7ff5096ee4..2691cb3fd8 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -258,9 +258,7 @@ Pair *Force::new_pair(const char *style, int trysuffix, int &sflag) return pair_creator(lmp); } - char str[128]; - sprintf(str,"Unknown pair style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("pair",style,lmp).c_str()); return NULL; } @@ -373,9 +371,7 @@ Bond *Force::new_bond(const char *style, int trysuffix, int &sflag) return bond_creator(lmp); } - char str[128]; - sprintf(str,"Unknown bond style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("bond",style,lmp).c_str()); return NULL; } @@ -454,9 +450,7 @@ Angle *Force::new_angle(const char *style, int trysuffix, int &sflag) return angle_creator(lmp); } - char str[128]; - sprintf(str,"Unknown angle style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("angle",style,lmp).c_str()); return NULL; } @@ -536,9 +530,7 @@ Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag) return dihedral_creator(lmp); } - char str[128]; - sprintf(str,"Unknown dihedral style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("dihedral",style,lmp).c_str()); return NULL; } @@ -617,9 +609,7 @@ Improper *Force::new_improper(const char *style, int trysuffix, int &sflag) return improper_creator(lmp); } - char str[128]; - sprintf(str,"Unknown improper style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("improper",style,lmp).c_str()); return NULL; } @@ -702,9 +692,7 @@ KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag) return kspace_creator(lmp); } - char str[128]; - sprintf(str,"Unknown kspace style %s",style); - error->all(FLERR,str); + error->all(FLERR,utils::check_packages_for_style("kspace",style,lmp).c_str()); return NULL; } diff --git a/src/modify.cpp b/src/modify.cpp index 7f43f035d2..69cdb424b2 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -893,11 +893,8 @@ void Modify::add_fix(int narg, char **arg, int trysuffix) fix[ifix] = fix_creator(lmp,narg,arg); } - if (fix[ifix] == NULL) { - char str[128]; - snprintf(str,128,"Unknown fix style %s",arg[2]); - error->all(FLERR,str); - } + if (fix[ifix] == NULL) + error->all(FLERR,utils::check_packages_for_style("fix",arg[2],lmp).c_str()); // check if Fix is in restart_global list // if yes, pass state info to the Fix so it can reset itself @@ -1195,11 +1192,8 @@ void Modify::add_compute(int narg, char **arg, int trysuffix) compute[ncompute] = compute_creator(lmp,narg,arg); } - if (compute[ncompute] == NULL) { - char str[128]; - snprintf(str,128,"Unknown compute style %s",arg[2]); - error->all(FLERR,str); - } + if (compute[ncompute] == NULL) + error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp).c_str()); ncompute++; } diff --git a/src/output.cpp b/src/output.cpp index 884647f478..2dcf18e7eb 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -32,6 +32,7 @@ #include "write_restart.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -585,8 +586,7 @@ void Output::add_dump(int narg, char **arg) if (dump_map->find(arg[2]) != dump_map->end()) { DumpCreator dump_creator = (*dump_map)[arg[2]]; dump[ndump] = dump_creator(lmp, narg, arg); - } - else error->all(FLERR,"Unknown dump style"); + } else error->all(FLERR,utils::check_packages_for_style("dump",arg[2],lmp).c_str()); every_dump[ndump] = force->inumeric(FLERR,arg[3]); if (every_dump[ndump] <= 0) error->all(FLERR,"Illegal dump command"); diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 7a05f4b1b5..395f4c8edd 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -40,6 +40,7 @@ #include "variable.h" #include "error.h" #include "memory.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -266,7 +267,7 @@ void ReadDump::setup_reader(int narg, char **arg) // unrecognized style - else error->all(FLERR,"Unknown dump reader style"); + else error->all(FLERR,utils::check_packages_for_style("reader",readerstyle,lmp).c_str()); // pass any arguments to readers diff --git a/src/utils.cpp b/src/utils.cpp index 42140db0ba..8468b22d8c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -128,7 +128,7 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size, std::string utils::check_packages_for_style(std::string style, std::string name, LAMMPS *lmp) { - std::string errmsg = "Unrecognized " + style + " style " + name; + std::string errmsg = "Unrecognized " + style + " style '" + name + "'"; const char *pkg = lmp->match_style(style.c_str(),name.c_str()); if (pkg) { diff --git a/src/write_dump.cpp b/src/write_dump.cpp index 6c7375012e..072680a8a5 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -26,6 +26,7 @@ #include "input.h" #include "update.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -64,7 +65,7 @@ void WriteDump::command(int narg, char **arg) #include "style_dump.h" #undef DUMP_CLASS - else error->all(FLERR,"Unknown dump style"); + else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp).c_str()); if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]); From 6ee002d6cf8fe2687ccac2bea05846360273f3ef Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 7 Apr 2019 22:32:31 -0400 Subject: [PATCH 04/27] add cmake support for enhanced missing style error reports --- cmake/CMakeLists.txt | 36 ++++++------ cmake/Modules/StyleHeaderUtils.cmake | 85 ++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 18 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b9a93a110e..b2a99a2306 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -87,6 +87,7 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) # this is fast, so check for it all the time message(STATUS "Running check for auto-generated files from make-based build system") file(GLOB SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/style_*.h) +file(GLOB SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/lmpinstalledpkgs.h ${LAMMPS_SOURCE_DIR}/lmpgitversion.h) foreach(_SRC ${SRC_AUTOGEN_FILES}) get_filename_component(FILENAME "${_SRC}" NAME) @@ -172,21 +173,17 @@ set(LAMMPS_LINK_LIBS) set(LAMMPS_DEPS) set(LAMMPS_API_DEFINES) -set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR - KSPACE MANYBODY MC MESSAGE MISC MOLECULE PERI REPLICA RIGID SHOCK - SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI POEMS LATTE USER-ATC USER-AWPMD - USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS USER-DIFFRACTION - USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD - USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF - USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC USER-SCAFACOS - USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-VTK - USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) +set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE + GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MOLECULE PERI POEMS QEQ + REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI + USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS + USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB + USER-MANIFOLD USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE + USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC + USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF + USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU) -set(OTHER_PACKAGES CORESHELL QEQ) -foreach(PKG ${DEFAULT_PACKAGES}) - option(PKG_${PKG} "Build ${PKG} Package" OFF) -endforeach() -foreach(PKG ${ACCEL_PACKAGES} ${OTHER_PACKAGES}) +foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) option(PKG_${PKG} "Build ${PKG} Package" OFF) endforeach() @@ -213,7 +210,6 @@ if(PKG_USER-ADIOS) list(APPEND LAMMPS_LINK_LIBS adios2::adios2) endif() - # do MPI detection after language activation, if MPI for these language is required find_package(MPI QUIET) option(BUILD_MPI "Build MPI version" ${MPI_FOUND}) @@ -233,7 +229,6 @@ else() list(APPEND LAMMPS_LINK_LIBS mpi_stubs) endif() - set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)") set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall) set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES}) @@ -844,6 +839,8 @@ foreach(PKG ${DEFAULT_PACKAGES}) list(APPEND LIB_SOURCES ${${PKG}_SOURCES}) include_directories(${${PKG}_SOURCES_DIR}) endif() + + RegisterPackages(${${PKG}_SOURCES_DIR}) endforeach() # packages that need defines set @@ -862,6 +859,8 @@ foreach(PKG ${ACCEL_PACKAGES}) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) + + RegisterPackages(${${PKG}_SOURCES_DIR}) endforeach() ############################################## @@ -1370,6 +1369,7 @@ endif() set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles) GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR}) +GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR}) include_directories(${LAMMPS_STYLE_HEADERS_DIR}) @@ -1378,7 +1378,7 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR}) ###################################### set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n") set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n") -set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES} ${OTHER_PACKAGES}) +set(temp_PKG_LIST ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) list(SORT temp_PKG_LIST) foreach(PKG ${temp_PKG_LIST}) if(PKG_${PKG}) @@ -1598,7 +1598,7 @@ endif() ############################################################################### # Print package summary ############################################################################### -foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES} ${OTHER_PACKAGES}) +foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES}) if(PKG_${PKG}) message(STATUS "Building package: ${PKG}") endif() diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index ebaa5dae8e..04883d0292 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -181,3 +181,88 @@ function(DetectBuildSystemConflict lammps_src_dir) endforeach() endif() endfunction(DetectBuildSystemConflict) + + +function(FindPackagesHeaders path style_class file_pattern headers) + file(GLOB files "${path}/${file_pattern}*.h") + get_property(plist GLOBAL PROPERTY ${headers}) + + foreach(file_name ${files}) + file(STRINGS ${file_name} is_style LIMIT_COUNT 1 REGEX ${style_class}) + if(is_style) + list(APPEND plist ${file_name}) + endif() + endforeach() + set_property(GLOBAL PROPERTY ${headers} "${plist}") +endfunction(FindPackagesHeaders) + +function(RegisterPackages search_path) + FindPackagesHeaders(${search_path} ANGLE_CLASS angle_ PKGANGLE ) # angle ) # force + FindPackagesHeaders(${search_path} ATOM_CLASS atom_vec_ PKGATOM_VEC ) # atom ) # atom atom_vec_hybrid + FindPackagesHeaders(${search_path} BODY_CLASS body_ PKGBODY ) # body ) # atom_vec_body + FindPackagesHeaders(${search_path} BOND_CLASS bond_ PKGBOND ) # bond ) # force + FindPackagesHeaders(${search_path} COMMAND_CLASS "[^.]" PKGCOMMAND ) # command ) # input + FindPackagesHeaders(${search_path} COMPUTE_CLASS compute_ PKGCOMPUTE ) # compute ) # modify + FindPackagesHeaders(${search_path} DIHEDRAL_CLASS dihedral_ PKGDIHEDRAL ) # dihedral ) # force + FindPackagesHeaders(${search_path} DUMP_CLASS dump_ PKGDUMP ) # dump ) # output write_dump + FindPackagesHeaders(${search_path} FIX_CLASS fix_ PKGFIX ) # fix ) # modify + FindPackagesHeaders(${search_path} IMPROPER_CLASS improper_ PKGIMPROPER ) # improper ) # force + FindPackagesHeaders(${search_path} INTEGRATE_CLASS "[^.]" PKGINTEGRATE ) # integrate ) # update + FindPackagesHeaders(${search_path} KSPACE_CLASS "[^.]" PKGKSPACE ) # kspace ) # force + FindPackagesHeaders(${search_path} MINIMIZE_CLASS min_ PKGMINIMIZE ) # minimize ) # update + FindPackagesHeaders(${search_path} NBIN_CLASS nbin_ PKGNBIN ) # nbin ) # neighbor + FindPackagesHeaders(${search_path} NPAIR_CLASS npair_ PKGNPAIR ) # npair ) # neighbor + FindPackagesHeaders(${search_path} NSTENCIL_CLASS nstencil_ PKGNSTENCIL ) # nstencil ) # neighbor + FindPackagesHeaders(${search_path} NTOPO_CLASS ntopo_ PKGNTOPO ) # ntopo ) # neighbor + FindPackagesHeaders(${search_path} PAIR_CLASS pair_ PKGPAIR ) # pair ) # force + FindPackagesHeaders(${search_path} READER_CLASS reader_ PKGREADER ) # reader ) # read_dump + FindPackagesHeaders(${search_path} REGION_CLASS region_ PKGREGION ) # region ) # domain +endfunction(RegisterPackages) + +function(CreatePackagesHeader path filename) + set(temp "") + if(ARGC GREATER 2) + list(REMOVE_AT ARGV 0 1) + foreach(FNAME ${ARGV}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${FNAME}") + get_filename_component(DNAME ${FNAME} DIRECTORY) + get_filename_component(DNAME ${DNAME} NAME) + get_filename_component(FNAME ${FNAME} NAME) + set(temp "${temp}#undef PACKAGE\n#define PACKAGE \"${DNAME}\"\n") + set(temp "${temp}#include \"${DNAME}/${FNAME}\"\n") + endforeach() + endif() + message(STATUS "Generating ${filename}...") + file(WRITE "${path}/${filename}.tmp" "${temp}" ) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${path}/${filename}.tmp" "${path}/${filename}") + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${path}/${filename}") +endfunction(CreatePackagesHeader) + +function(GeneratePackagesHeader path property style) + get_property(files GLOBAL PROPERTY ${property}) + CreatePackagesHeader("${path}" "packages_${style}.h" ${files}) +endfunction(GeneratePackagesHeader) + +function(GeneratePackagesHeaders output_path) + GeneratePackagesHeader(${output_path} PKGANGLE angle ) # force + GeneratePackagesHeader(${output_path} PKGATOM_VEC atom ) # atom atom_vec_hybrid + GeneratePackagesHeader(${output_path} PKGBODY body ) # atom_vec_body + GeneratePackagesHeader(${output_path} PKGBOND bond ) # force + GeneratePackagesHeader(${output_path} PKGCOMMAND command ) # input + GeneratePackagesHeader(${output_path} PKGCOMPUTE compute ) # modify + GeneratePackagesHeader(${output_path} PKGDIHEDRAL dihedral ) # force + GeneratePackagesHeader(${output_path} PKGDUMP dump ) # output write_dump + GeneratePackagesHeader(${output_path} PKGFIX fix ) # modify + GeneratePackagesHeader(${output_path} PKGIMPROPER improper ) # force + GeneratePackagesHeader(${output_path} PKGINTEGRATE integrate ) # update + GeneratePackagesHeader(${output_path} PKGKSPACE kspace ) # force + GeneratePackagesHeader(${output_path} PKGMINIMIZE minimize ) # update + GeneratePackagesHeader(${output_path} PKGNBIN nbin ) # neighbor + GeneratePackagesHeader(${output_path} PKGNPAIR npair ) # neighbor + GeneratePackagesHeader(${output_path} PKGNSTENCIL nstencil ) # neighbor + GeneratePackagesHeader(${output_path} PKGNTOPO ntopo ) # neighbor + GeneratePackagesHeader(${output_path} PKGPAIR pair ) # force + GeneratePackagesHeader(${output_path} PKGREADER reader ) # read_dump + GeneratePackagesHeader(${output_path} PKGREGION region ) # domain +endfunction(GeneratePackagesHeaders) + From dc40886d23ff7b3abe3ac1ed73f1805d660e9ef5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Apr 2019 06:40:39 -0400 Subject: [PATCH 05/27] improve comments and formatting --- cmake/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b2a99a2306..57978bb020 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -200,7 +200,6 @@ endif() include_directories(${LAMMPS_SOURCE_DIR}) - if(PKG_USER-ADIOS) # The search for ADIOS2 must come before MPI because # it includes its own MPI search with the latest FindMPI.cmake @@ -436,7 +435,6 @@ else() set(CUDA_REQUEST_PIC) endif() - if(PKG_VORONOI) option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" OFF) if(DOWNLOAD_VORO) @@ -909,7 +907,6 @@ if(PKG_USER-H5MD) include_directories(${HDF5_INCLUDE_DIRS}) endif() - ###################################################################### # packages which selectively include variants based on enabled styles # e.g. accelerator packages @@ -1365,6 +1362,7 @@ endif() ###################################################### # Generate style headers based on global list of # styles registered during package selection +# Generate packages headers from all packages ###################################################### set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles) @@ -1448,7 +1446,6 @@ if(BUILD_EXE) endif() endif() - ############################################################################### # Build documentation ############################################################################### From f2113ab04a9df11c71f0d5d7f306e8db15b50e0c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Apr 2019 07:16:22 -0400 Subject: [PATCH 06/27] update manual and headers for updated error message --- doc/src/Errors_messages.txt | 33 +++++++++++++++++++-------------- src/atom.h | 2 +- src/atom_vec_body.h | 2 +- src/domain.h | 2 +- src/force.h | 27 ++++++++++++++------------- src/modify.h | 8 ++++---- src/output.h | 2 +- src/read_dump.h | 2 +- src/write_dump.h | 2 +- 9 files changed, 43 insertions(+), 37 deletions(-) diff --git a/doc/src/Errors_messages.txt b/doc/src/Errors_messages.txt index fb5003e602..4504cbeb11 100644 --- a/doc/src/Errors_messages.txt +++ b/doc/src/Errors_messages.txt @@ -7448,6 +7448,11 @@ The Atoms section of a data file must come before a Triangles section. :dd The Atoms section of a data file must come before a Velocities section. :dd +{Must re-specify non-restarted pair style (xxx) after read_restart} :dt + +For pair styles, that do not store their settings in a restart file, +it must be defined with a new 'pair_style' command after read_restart. :dd + {Must set both respa inner and outer} :dt Cannot use just the inner or outer option with respa without using the @@ -10049,19 +10054,19 @@ create_box command. :dd A universe or uloop style variable must specify a number of values >= to the number of processor partitions. :dd -{Unknown angle style} :dt +{Unrecognized angle style} :dt The choice of angle style is unknown. :dd -{Unknown atom style} :dt +{Unrecognized atom style} :dt The choice of atom style is unknown. :dd -{Unknown body style} :dt +{Unrecognized body style} :dt The choice of body style is unknown. :dd -{Unknown bond style} :dt +{Unrecognized bond style} :dt The choice of bond style is unknown. :dd @@ -10077,23 +10082,23 @@ Self-explanatory. :dd Self-explanatory. :dd -{Unknown command: %s} :dt +{Unrecognized command: %s} :dt The command is not known to LAMMPS. Check the input script. :dd -{Unknown compute style} :dt +{Unrecognized compute style} :dt The choice of compute style is unknown. :dd -{Unknown dihedral style} :dt +{Unrecognized dihedral style} :dt The choice of dihedral style is unknown. :dd -{Unknown dump reader style} :dt +{Unrecognized dump reader style} :dt The choice of dump reader style via the format keyword is unknown. :dd -{Unknown dump style} :dt +{Unrecognized dump style} :dt The choice of dump style is unknown. :dd @@ -10101,7 +10106,7 @@ The choice of dump style is unknown. :dd Self-explanatory. :dd -{Unknown fix style} :dt +{Unrecognized fix style} :dt The choice of fix style is unknown. :dd @@ -10109,7 +10114,7 @@ The choice of fix style is unknown. :dd A section of the data file cannot be read by LAMMPS. :dd -{Unknown improper style} :dt +{Unrecognized improper style} :dt The choice of improper style is unknown. :dd @@ -10117,7 +10122,7 @@ The choice of improper style is unknown. :dd One or more specified keywords are not recognized. :dd -{Unknown kspace style} :dt +{Unrecognized kspace style} :dt The choice of kspace style is unknown. :dd @@ -10133,7 +10138,7 @@ Self-explanatory. :dd Self-explanatory. :dd -{Unknown pair style} :dt +{Unrecognized pair style} :dt The choice of pair style is unknown. :dd @@ -10141,7 +10146,7 @@ The choice of pair style is unknown. :dd The choice of sub-style is unknown. :dd -{Unknown region style} :dt +{Unrecognized region style} :dt The choice of region style is unknown. :dd diff --git a/src/atom.h b/src/atom.h index b2a657cf1a..ff7bd0c538 100644 --- a/src/atom.h +++ b/src/atom.h @@ -361,7 +361,7 @@ E: Atom IDs must be used for molecular systems Atom IDs are used to identify and find partner atoms in bonds. -E: Unknown atom style +E: Unrecognized atom style The choice of atom style is unknown. diff --git a/src/atom_vec_body.h b/src/atom_vec_body.h index 7cc052b6c5..4d02c4b3e0 100644 --- a/src/atom_vec_body.h +++ b/src/atom_vec_body.h @@ -130,7 +130,7 @@ E: Invalid atom_style body command No body style argument was provided. -E: Unknown body style +E: Unrecognized body style The choice of body style is unknown. diff --git a/src/domain.h b/src/domain.h index 9ebdd6ae94..e131d07a1b 100644 --- a/src/domain.h +++ b/src/domain.h @@ -269,7 +269,7 @@ E: Reuse of region ID A region ID cannot be used twice. -E: Unknown region style +E: Unrecognized region style The choice of region style is unknown. diff --git a/src/force.h b/src/force.h index e4bb0f990e..2b4298d049 100644 --- a/src/force.h +++ b/src/force.h @@ -159,35 +159,36 @@ class Force : protected Pointers { E: Must re-specify non-restarted pair style (%s) after read_restart -UNDOCUMENTED +For pair styles, that do not store their settings in a restart file, +it must be defined with a new 'pair_style' command after read_restart. -E: Unknown pair style %s +E: Unrecognized pair style %s -UNDOCUMENTED +The choice of pair style is unknown. -E: Unknown bond style %s +E: Unrecognized bond style %s -UNDOCUMENTED +The choice of bond style is unknown. -E: Unknown angle style %s +E: Unrecognized angle style %s -UNDOCUMENTED +The choice of angle style is unknown. -E: Unknown dihedral style %s +E: Unrecognized dihedral style %s -UNDOCUMENTED +The choice of dihedral style is unknown. -E: Unknown improper style %s +E: Unrecognized improper style %s -UNDOCUMENTED +The choice of improper style is unknown. E: Cannot yet use KSpace solver with grid with comm style tiled This is current restriction in LAMMPS. -E: Unknown kspace style %s +E: Unrecognized kspace style %s -UNDOCUMENTED +The choice of kspace style is unknown. E: Illegal ... command diff --git a/src/modify.h b/src/modify.h index eca4e07859..537ff81543 100644 --- a/src/modify.h +++ b/src/modify.h @@ -224,9 +224,9 @@ The ID and style of a fix match for a fix you are changing with a fix command, but the new group you are specifying does not match the old group. -E: Unknown fix style %s +E: Unrecognized fix style %s -UNDOCUMENTED +The choice of fix style is unknown. E: Could not find fix_modify ID @@ -240,9 +240,9 @@ E: Reuse of compute ID A compute ID cannot be used twice. -E: Unknown compute style %s +E: Unrecognized compute style %s -UNDOCUMENTED +The choice of compute style is unknown. E: Could not find compute_modify ID diff --git a/src/output.h b/src/output.h index 5354759343..1bf4128ee0 100644 --- a/src/output.h +++ b/src/output.h @@ -152,7 +152,7 @@ E: Invalid dump frequency Dump frequency must be 1 or greater. -E: Unknown dump style +E: Unrecognized dump style The choice of dump style is unknown. diff --git a/src/read_dump.h b/src/read_dump.h index de174c3df6..3ee13f779c 100644 --- a/src/read_dump.h +++ b/src/read_dump.h @@ -134,7 +134,7 @@ E: Dump file does not contain requested snapshot Self-explanatory. -E: Unknown dump reader style +E: Unrecognized dump reader style The choice of dump reader style via the format keyword is unknown. diff --git a/src/write_dump.h b/src/write_dump.h index 18fff6345b..db39a75d4b 100644 --- a/src/write_dump.h +++ b/src/write_dump.h @@ -43,7 +43,7 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: Unknown dump style +E: Unrecognized dump style The choice of dump style is unknown. From 69c1a7954a3b7219eab47d9662123b1183c83e71 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Apr 2019 17:14:59 -0400 Subject: [PATCH 07/27] correct test for leftovers from conventional builds --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 57978bb020..fada17d168 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -87,8 +87,8 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) # this is fast, so check for it all the time message(STATUS "Running check for auto-generated files from make-based build system") file(GLOB SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/style_*.h) -file(GLOB SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/packages_*.h) -list(APPEND SRC_AUTOGEN_FILES ${LAMMPS_SOURCE_DIR}/lmpinstalledpkgs.h ${LAMMPS_SOURCE_DIR}/lmpgitversion.h) +file(GLOB SRC_AUTOGEN_PACKAGES ${LAMMPS_SOURCE_DIR}/packages_*.h) +list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${LAMMPS_SOURCE_DIR}/lmpinstalledpkgs.h ${LAMMPS_SOURCE_DIR}/lmpgitversion.h) foreach(_SRC ${SRC_AUTOGEN_FILES}) get_filename_component(FILENAME "${_SRC}" NAME) if(EXISTS ${LAMMPS_SOURCE_DIR}/${FILENAME}) From 2ee02cfadd4484833fa32c6a503c0941ce83fb98 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 24 May 2019 11:27:09 -0600 Subject: [PATCH 08/27] Don't reallocate views every time in neigh_bond_kokkos --- src/KOKKOS/neigh_bond_kokkos.cpp | 8 ++++++-- src/atom.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/neigh_bond_kokkos.cpp b/src/KOKKOS/neigh_bond_kokkos.cpp index 05a6fd605c..34858ff1e1 100644 --- a/src/KOKKOS/neigh_bond_kokkos.cpp +++ b/src/KOKKOS/neigh_bond_kokkos.cpp @@ -200,6 +200,7 @@ void NeighBondKokkos::build_topology_kk() { atomKK->sync(execution_space, X_MASK | TAG_MASK); int nall = atom->nlocal + atom->nghost; + int nmax = atom->nmax; nlocal = atom->nlocal; x = atomKK->k_x.view(); @@ -215,7 +216,9 @@ void NeighBondKokkos::build_topology_kk() int* map_array_host = atom->get_map_array(); int map_size = atom->get_map_size(); - k_map_array = DAT::tdual_int_1d("NeighBond:map_array",map_size); + int map_maxarray = atom->get_map_maxarray(); + if (map_maxarray > k_map_array.extent(0)) + k_map_array = DAT::tdual_int_1d("NeighBond:map_array",map_maxarray); for (int i=0; i(); @@ -223,7 +226,8 @@ void NeighBondKokkos::build_topology_kk() map_array = k_map_array.view(); int* sametag_host = atomKK->sametag; - k_sametag = DAT::tdual_int_1d("NeighBond:sametag",nall); + if (nmax > k_sametag.extent(0)) + k_sametag = DAT::tdual_int_1d("NeighBond:sametag",nmax); for (int i=0; i(); diff --git a/src/atom.h b/src/atom.h index b2a657cf1a..6a26c24dfe 100644 --- a/src/atom.h +++ b/src/atom.h @@ -286,6 +286,7 @@ class Atom : protected Pointers { inline int* get_map_array() {return map_array;}; inline int get_map_size() {return map_tag_max+1;}; + inline int get_map_maxarray() {return map_maxarray+1;}; bigint memory_usage(); int memcheck(const char *); From e82e1c695a8233905fe2d35babb4b1f13e5a5fe4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 24 May 2019 19:45:48 -0400 Subject: [PATCH 09/27] correct links in package documentation --- doc/src/Packages_details.txt | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/src/Packages_details.txt b/doc/src/Packages_details.txt index 4f9bcc1910..1528adc420 100644 --- a/doc/src/Packages_details.txt +++ b/doc/src/Packages_details.txt @@ -208,7 +208,7 @@ available on your system. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#compress on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -358,7 +358,7 @@ developed the pair style. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#kim on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -404,7 +404,7 @@ lib/kokkos. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#kokkos on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -477,7 +477,7 @@ Cawkwell, Anders Niklasson, and Christian Negre. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#latte on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -654,7 +654,7 @@ University of Chicago. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#mscg on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -686,7 +686,7 @@ and Vincent Natoli (Stone Ridge Technolgy). [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#opt on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -743,7 +743,7 @@ connections at hinge points. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#poems on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -775,7 +775,7 @@ lib/python/README for more details. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#python on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -965,7 +965,7 @@ and LBNL. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#voronoi on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1017,7 +1017,7 @@ atomic information to continuum fields. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-atc on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1044,7 +1044,7 @@ model. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-awpmd on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1184,7 +1184,7 @@ Tribello. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-plumed on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1362,7 +1362,7 @@ H5MD format. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-h5md on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1400,7 +1400,7 @@ NOTE: the USER-INTEL package contains styles that require using the [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-intel on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1620,7 +1620,7 @@ at [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-molfile on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1660,7 +1660,7 @@ tools: [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-netcdf on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1704,7 +1704,7 @@ install/un-install the package and build LAMMPS in the usual manner: [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-omp on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1788,7 +1788,7 @@ without changes to LAMMPS itself. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-qmmm on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1846,7 +1846,7 @@ on your system. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-quip on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -1964,7 +1964,7 @@ Dynamics, Ernst Mach Institute, Germany). [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-smd on the "Build extras"_Build_extras.html doc page. [Supporting info:] @@ -2090,7 +2090,7 @@ system. [Install:] This package has "specific installation -instructions"_Build_extras.html#gpu on the "Build +instructions"_Build_extras.html#user-vtk on the "Build extras"_Build_extras.html doc page. [Supporting info:] From c8d50c04a4e977cd14eb567e9a25e1cf55c897fe Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 10:12:24 -0400 Subject: [PATCH 10/27] avoid memory leak and initialize class member pointers --- src/USER-QUIP/pair_quip.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index c3b03bc5e0..4795e08e33 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -44,6 +44,11 @@ PairQUIP::PairQUIP(LAMMPS *lmp) : Pair(lmp) one_coeff = 1; no_virial_fdotr_compute = 1; manybody_flag = 1; + + map = NULL; + quip_potential = NULL; + quip_file = NULL; + quip_string = NULL; } PairQUIP::~PairQUIP() @@ -52,8 +57,10 @@ PairQUIP::~PairQUIP() memory->destroy(setflag); memory->destroy(cutsq); delete [] map; - delete [] quip_potential; } + delete [] quip_potential; + delete [] quip_file; + delete [] quip_string; } void PairQUIP::compute(int eflag, int vflag) From cb8d89855d937140167f09cb89cad6cf1af4b675 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 13:59:51 -0400 Subject: [PATCH 11/27] remove limitation to hybrid/overlay --- src/USER-QUIP/pair_quip.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 4795e08e33..e2340ab3d1 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -218,11 +218,9 @@ void PairQUIP::compute(int eflag, int vflag) global settings ------------------------------------------------------------------------- */ -void PairQUIP::settings(int narg, char **/*arg*/) +void PairQUIP::settings(int narg, char ** /* arg */) { if (narg != 0) error->all(FLERR,"Illegal pair_style command"); - if (strcmp(force->pair_style,"hybrid") == 0) - error->all(FLERR,"Pair style quip is only compatible with hybrid/overlay"); // check if linked to the correct QUIP library API version // as of 2017-07-19 this is API_VERSION 1 From 12fcf5f5ef1c7053938f54f08fa22e7e2dc89101 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 14:00:33 -0400 Subject: [PATCH 12/27] properly set up pair style quip for hybrid and hybrid/overlay --- src/USER-QUIP/pair_quip.cpp | 72 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index e2340ab3d1..55bc587094 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -244,43 +244,53 @@ void PairQUIP::allocate() void PairQUIP::coeff(int narg, char **arg) { - if (!allocated) allocate(); + if (!allocated) allocate(); - int n = atom->ntypes; + int n = atom->ntypes; + if (narg != (4+n)) { + char str[1024]; + sprintf(str,"Number of arguments %d is not correct, it should be %d", narg, 4+n); + error->all(FLERR,str); + } // ensure I,J args are * * - for (int i = 1; i <= n; i++){ - for (int j = 1; j <= n; j++) { - setflag[i][j] = 1; + if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) + error->all(FLERR,"Incorrect args for pair coefficients"); + + n_quip_file = strlen(arg[2]); + quip_file = new char[n_quip_file+1]; + strcpy(quip_file,arg[2]); + + n_quip_string = strlen(arg[3]); + quip_string = new char[n_quip_string+1]; + strcpy(quip_string,arg[3]); + + for (int i = 4; i < narg; i++) { + if (strcmp(arg[i],"NULL") == 0) + map[i-3] = -1; + else + map[i-3] = force->inumeric(FLERR,arg[i]); + } + + // clear setflag since coeff() called once with I,J = * * + + n = atom->ntypes; + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + // set setflag i,j for type pairs where both are mapped to elements + + int count = 0; + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + if (map[i] >= 0 && map[j] >= 0) { + setflag[i][j] = 1; + count++; } - } - if (narg != (4+n)) { - char str[1024]; - sprintf(str,"Number of arguments %d is not correct, it should be %d", narg, 4+n); - error->all(FLERR,str); - } - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - - n_quip_file = strlen(arg[2]); - quip_file = new char[n_quip_file+1]; - strcpy(quip_file,arg[2]); - - n_quip_string = strlen(arg[3]); - quip_string = new char[n_quip_string+1]; - strcpy(quip_string,arg[3]); - - for (int i = 4; i < narg; i++) { - - if (0 == sscanf(arg[i],"%d",&map[i-4])) { - char str[1024]; - sprintf(str,"Incorrect atomic number %s at position %d",arg[i],i); - error->all(FLERR,str); - } - } + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); // Initialise potential // First call initialises potential via the fortran code in memory, and returns the necessary size From c0cfceb95c1cb8cf889cf607331bf358f36169f6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 14:03:00 -0400 Subject: [PATCH 13/27] fix off-by-one errors --- src/USER-QUIP/pair_quip.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 55bc587094..c05f2d6871 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -107,14 +107,14 @@ void PairQUIP::compute(int eflag, int vflag) jnum = numneigh[i]; for (jj = 0; jj < jnum; jj++) { - quip_neigh[iquip] = (jlist[jj] & NEIGHMASK) + 1; - iquip++; + quip_neigh[iquip] = (jlist[jj] & NEIGHMASK) + 1; + iquip++; } } atomic_numbers = new int[ntotal]; for (ii = 0; ii < ntotal; ii++) - atomic_numbers[ii] = map[type[ii]-1]; + atomic_numbers[ii] = map[type[ii]]; quip_local_e = new double [ntotal]; quip_force = new double [ntotal*3]; @@ -239,7 +239,7 @@ void PairQUIP::allocate() setflag = memory->create(setflag,n+1,n+1,"pair:setflag"); cutsq = memory->create(cutsq,n+1,n+1,"pair:cutsq"); - map = new int[n]; + map = new int[n+1]; } void PairQUIP::coeff(int narg, char **arg) From fec2f8f69b565cfee12434e6d33f33f296de95b0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 14:39:45 -0400 Subject: [PATCH 14/27] update docs for fully supporting hybrid styles --- doc/src/pair_quip.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/src/pair_quip.txt b/doc/src/pair_quip.txt index 30f1d80450..e6b01b8853 100644 --- a/doc/src/pair_quip.txt +++ b/doc/src/pair_quip.txt @@ -92,10 +92,6 @@ pairs from the neighbor list. This needs to be very carefully tested, because it may remove pairs from the neighbor list that are still required. -Pair style {quip} cannot be used with pair style {hybrid}, only -with {hybrid/overlay} and only the {quip} sub-style is applied to -all atom types. - [Related commands:] "pair_coeff"_pair_coeff.html From 29d36ffec0a2309d6329623ecd4cd673f0c583ff Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 14:40:09 -0400 Subject: [PATCH 15/27] error out when not using metal units with QUIP --- src/USER-QUIP/pair_quip.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index c05f2d6871..89153f148c 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -227,6 +227,11 @@ void PairQUIP::settings(int narg, char ** /* arg */) if (quip_lammps_api_version() != 1) error->all(FLERR,"QUIP LAMMPS wrapper API version is not compatible " "with this version of LAMMPS"); + + // QUIP potentials are parameterized in metal units + + if (strcmp("metal",update->unit_style) != 0) + error->all(FLERR,"QUIP potentials require 'metal' units"); } /* ---------------------------------------------------------------------- From d3cbccff3554a31a9f36f714d76a6de042757d58 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 14:41:33 -0400 Subject: [PATCH 16/27] whitespace cleanup --- src/USER-QUIP/pair_quip.cpp | 18 +++++++++--------- src/USER-QUIP/pair_quip.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/USER-QUIP/pair_quip.cpp b/src/USER-QUIP/pair_quip.cpp index 89153f148c..ffc6ac1c70 100644 --- a/src/USER-QUIP/pair_quip.cpp +++ b/src/USER-QUIP/pair_quip.cpp @@ -39,16 +39,16 @@ using namespace LAMMPS_NS; PairQUIP::PairQUIP(LAMMPS *lmp) : Pair(lmp) { - single_enable = 0; - restartinfo = 0; - one_coeff = 1; - no_virial_fdotr_compute = 1; - manybody_flag = 1; + single_enable = 0; + restartinfo = 0; + one_coeff = 1; + no_virial_fdotr_compute = 1; + manybody_flag = 1; - map = NULL; - quip_potential = NULL; - quip_file = NULL; - quip_string = NULL; + map = NULL; + quip_potential = NULL; + quip_file = NULL; + quip_string = NULL; } PairQUIP::~PairQUIP() diff --git a/src/USER-QUIP/pair_quip.h b/src/USER-QUIP/pair_quip.h index debdc2cb83..216bf0dc28 100644 --- a/src/USER-QUIP/pair_quip.h +++ b/src/USER-QUIP/pair_quip.h @@ -26,10 +26,10 @@ extern "C" { int quip_lammps_api_version(); void quip_lammps_wrapper(int*, int*, int*, int*, - int*, int*, int*, - int*, int*, double*, - int*, int*, double*, - double*, double*, double*, double*, double*); + int*, int*, int*, + int*, int*, double*, + int*, int*, double*, + double*, double*, double*, double*, double*); void quip_lammps_potential_initialise(int*, int*, double*, char*, int*, char*, int*); } From a48f1cbf00c6162770ef5d76689ef001fb4ecea2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 20:07:00 -0400 Subject: [PATCH 17/27] fix spelling error --- src/lmpwindows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lmpwindows.h b/src/lmpwindows.h index 92a248a05e..b1b8dbcaff 100644 --- a/src/lmpwindows.h +++ b/src/lmpwindows.h @@ -19,7 +19,7 @@ #define strdup _strdup // the following functions ared defined to get rid of -// 'ambiguous call to overloaded function' error in VSS for mismathched type arguments +// 'ambiguous call to overloaded function' error in VSS for mismatched type arguments #if !defined(__MINGW32__) inline double pow(int i, int j){ return pow((double)i,j); From 8dcd6fc48ce94abcc65f889c4cc3c7e8b8cfe284 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 20:13:26 -0400 Subject: [PATCH 18/27] provide alternative to gettimeofday() for MSVC compilation --- src/STUBS/mpi.c | 8 ++++++++ src/USER-REAXC/reaxc_tool_box.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/STUBS/mpi.c b/src/STUBS/mpi.c index 09bb48ecdc..af7a489bb1 100644 --- a/src/STUBS/mpi.c +++ b/src/STUBS/mpi.c @@ -148,12 +148,20 @@ int MPI_Finalize() double MPI_Wtime() { +#if defined(_MSC_VER) + double t; + + t = GetTickCount(); + t /= 1000.0; + return t; +#else double time; struct timeval tv; gettimeofday(&tv,NULL); time = 1.0 * tv.tv_sec + 1.0e-6 * tv.tv_usec; return time; +#endif } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-REAXC/reaxc_tool_box.cpp b/src/USER-REAXC/reaxc_tool_box.cpp index b6058b2516..ffe42e37bb 100644 --- a/src/USER-REAXC/reaxc_tool_box.cpp +++ b/src/USER-REAXC/reaxc_tool_box.cpp @@ -34,8 +34,16 @@ double t_end; double Get_Time( ) { +#if defined(_MSC_VER) + double t; + + t = GetTickCount(); + t /= 1000.0; + return t; +#else gettimeofday(&tim, NULL ); return( tim.tv_sec + (tim.tv_usec / 1000000.0) ); +#endif } int Tokenize( char* s, char*** tok ) From 1a5c3c6dcbdf0fc35c13b25a02096e991d19a2e0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 14:46:07 -0400 Subject: [PATCH 19/27] add check that allows only %f and %g conversions in variable format strings --- doc/src/Errors_messages.txt | 6 ++++++ src/input.cpp | 6 ++++++ src/input.h | 5 +++++ src/variable.cpp | 3 +++ src/variable.h | 4 ++++ 5 files changed, 24 insertions(+) diff --git a/doc/src/Errors_messages.txt b/doc/src/Errors_messages.txt index 4f3bbe8c24..b930dbce30 100644 --- a/doc/src/Errors_messages.txt +++ b/doc/src/Errors_messages.txt @@ -5828,6 +5828,12 @@ Must have periodic x,y dimensions and non-periodic z dimension to use Must have periodic x,y dimensions and non-periodic z dimension to use 2d slab option with pppm/disp. :dd +{Incorrect conversion in format string} :dt + +A format style variable was not using either a %f or a %g conversion. +Or an immediate variable with format suffix was not using either +a %f or a %g conversion in the format suffix. :dd + {Incorrect element names in ADP potential file} :dt The element names in the ADP file do not match those requested. :dd diff --git a/src/input.cpp b/src/input.cpp index f88c8ca0c0..029c155ee8 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -50,6 +50,7 @@ #include "accelerator_kokkos.h" #include "error.h" #include "memory.h" +#include "utils.h" #ifdef _OPENMP #include @@ -526,6 +527,11 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag) *fmtflag='\0'; } + // quick check for proper format string + + if (!utils::strmatch(fmtstr,"%[0-9 ]*\\.[0-9]+[fg]")) + error->all(FLERR,"Incorrect conversion in format string"); + snprintf(immediate,256,fmtstr,variable->compute_equal(var)); value = immediate; diff --git a/src/input.h b/src/input.h index 47ad7779f1..d62ab11234 100644 --- a/src/input.h +++ b/src/input.h @@ -173,6 +173,11 @@ E: Unbalanced quotes in input line No matching end double quote was found following a leading double quote. +E: Incorrect conversion in format string + +An immediate variable with format suffix was not using +either a %f or a %g conversion in the format suffix. + E: Input line quote not followed by white-space An end quote must be followed by white-space. diff --git a/src/variable.cpp b/src/variable.cpp index 56b66cad0d..0fe18700ee 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -38,6 +38,7 @@ #include "memory.h" #include "info.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -383,6 +384,8 @@ void Variable::set(int narg, char **arg) num[nvar] = 3; which[nvar] = 0; pad[nvar] = 0; + if (!utils::strmatch(arg[2],"%[0-9 ]*\\.[0-9]+[fg]")) + error->all(FLERR,"Incorrect conversion in format string"); data[nvar] = new char*[num[nvar]]; copy(2,&arg[2],data[nvar]); data[nvar][2] = new char[VALUELENGTH]; diff --git a/src/variable.h b/src/variable.h index a37ee4cff7..a071fdb021 100644 --- a/src/variable.h +++ b/src/variable.h @@ -210,6 +210,10 @@ E: Invalid variable style with next command Variable styles {equal} and {world} cannot be used in a next command. +E: Incorrect conversion in format string + +A format style variable was not using either a %f or a %g conversion. + E: Next command must list all universe and uloop variables This is to insure they stay in sync. From 02e7dd571660b12eb79c4a2dc2878ce7ff606364 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 14:52:26 -0400 Subject: [PATCH 20/27] also allow %e in format variables of suffix --- doc/src/Errors_messages.txt | 4 ++-- src/input.cpp | 2 +- src/input.h | 2 +- src/variable.cpp | 2 +- src/variable.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/Errors_messages.txt b/doc/src/Errors_messages.txt index b930dbce30..ce0356a4e7 100644 --- a/doc/src/Errors_messages.txt +++ b/doc/src/Errors_messages.txt @@ -5830,9 +5830,9 @@ Must have periodic x,y dimensions and non-periodic z dimension to use {Incorrect conversion in format string} :dt -A format style variable was not using either a %f or a %g conversion. +A format style variable was not using either a %f, a %g, or a %e conversion. Or an immediate variable with format suffix was not using either -a %f or a %g conversion in the format suffix. :dd +a %f, a %g or a %e conversion in the format suffix. :dd {Incorrect element names in ADP potential file} :dt diff --git a/src/input.cpp b/src/input.cpp index 029c155ee8..0111cb5738 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -529,7 +529,7 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag) // quick check for proper format string - if (!utils::strmatch(fmtstr,"%[0-9 ]*\\.[0-9]+[fg]")) + if (!utils::strmatch(fmtstr,"%[0-9 ]*\\.[0-9]+[efgEFG]")) error->all(FLERR,"Incorrect conversion in format string"); snprintf(immediate,256,fmtstr,variable->compute_equal(var)); diff --git a/src/input.h b/src/input.h index d62ab11234..33e83bfb06 100644 --- a/src/input.h +++ b/src/input.h @@ -176,7 +176,7 @@ quote. E: Incorrect conversion in format string An immediate variable with format suffix was not using -either a %f or a %g conversion in the format suffix. +either a %f, a %g, or a %e conversion in the format suffix. E: Input line quote not followed by white-space diff --git a/src/variable.cpp b/src/variable.cpp index 0fe18700ee..fdef9985bf 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -384,7 +384,7 @@ void Variable::set(int narg, char **arg) num[nvar] = 3; which[nvar] = 0; pad[nvar] = 0; - if (!utils::strmatch(arg[2],"%[0-9 ]*\\.[0-9]+[fg]")) + if (!utils::strmatch(arg[2],"%[0-9 ]*\\.[0-9]+[efgEFG]")) error->all(FLERR,"Incorrect conversion in format string"); data[nvar] = new char*[num[nvar]]; copy(2,&arg[2],data[nvar]); diff --git a/src/variable.h b/src/variable.h index a071fdb021..512195bd14 100644 --- a/src/variable.h +++ b/src/variable.h @@ -212,7 +212,7 @@ command. E: Incorrect conversion in format string -A format style variable was not using either a %f or a %g conversion. +A format style variable was not using either a %f, a %g, or a %e conversion. E: Next command must list all universe and uloop variables From c903a110fea048b2de3375e550a602565f00a77c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 18:36:09 -0400 Subject: [PATCH 21/27] fix typo --- src/lmpwindows.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lmpwindows.h b/src/lmpwindows.h index b1b8dbcaff..5083f0cbb3 100644 --- a/src/lmpwindows.h +++ b/src/lmpwindows.h @@ -18,7 +18,7 @@ #define pclose _pclose #define strdup _strdup -// the following functions ared defined to get rid of +// the following functions are defined to get rid of // 'ambiguous call to overloaded function' error in VSS for mismatched type arguments #if !defined(__MINGW32__) inline double pow(int i, int j){ From 9d51ee17b0d8f82af96e8da6e610e1258c5d8270 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 22:23:50 -0400 Subject: [PATCH 22/27] change the default for gcc 9.x and beyond to not enable OpenMP by default even if it is found to be supported this is so that using CMake by default will compile LAMMPS, since gcc 9.x expects different sharing semantics for constants than previous versions. --- cmake/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9721e03515..c572d6f27a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -316,7 +316,18 @@ pkg_depends(USER-SCAFACOS MPI) include(CheckIncludeFileCXX) find_package(OpenMP QUIET) -option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND}) + +# TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30 +# GNU GCC 9.x uses settings incompatible with our use of 'default(none)' in OpenMP pragmas +# where we assume older GCC semantics. For the time being, we disable OpenMP by default +# for GCC 9.x and beyond. People may manually turn it on, but need to run the script +# src/USER-OMP/hack_openmp_for_pgi_gcc9.sh on all sources to make it compatible with gcc 9. +if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0.0)) + option(BUILD_OMP "Build with OpenMP support" OFF) +else() + option(BUILD_OMP "Build with OpenMP support" ${OpenMP_FOUND}) +endif() + if(BUILD_OMP) find_package(OpenMP REQUIRED) check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE) From 4243af30d7ed4781534730adf11c417ffd9148c1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 30 May 2019 23:54:59 -0400 Subject: [PATCH 23/27] properly store 64-bit integers for next_reneighbor into double type buffers for restarts of fixes also store number of attemps and number of successes in restart and retrieve those from it --- src/MC/fix_atom_swap.cpp | 11 ++++++++--- src/MC/fix_gcmc.cpp | 24 +++++++++++++++++++++--- src/MISC/fix_deposit.cpp | 4 ++-- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/MC/fix_atom_swap.cpp b/src/MC/fix_atom_swap.cpp index 12b5d65f4a..aad8d7447f 100644 --- a/src/MC/fix_atom_swap.cpp +++ b/src/MC/fix_atom_swap.cpp @@ -771,10 +771,12 @@ double FixAtomSwap::memory_usage() void FixAtomSwap::write_restart(FILE *fp) { int n = 0; - double list[4]; + double list[6]; list[n++] = random_equal->state(); list[n++] = random_unequal->state(); - list[n++] = next_reneighbor; + list[n++] = ubuf(next_reneighbor).d; + list[n++] = nswap_attempts; + list[n++] = nswap_successes; if (comm->me == 0) { int size = n * sizeof(double); @@ -798,5 +800,8 @@ void FixAtomSwap::restart(char *buf) seed = static_cast (list[n++]); random_unequal->reset(seed); - next_reneighbor = static_cast (list[n++]); + next_reneighbor = (bigint) ubuf(list[n++]).i; + + nswap_attempts = static_cast(list[n++]); + nswap_successes = static_cast(list[n++]); } diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index f1664e3540..f3a11a1000 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -2531,10 +2531,19 @@ double FixGCMC::memory_usage() void FixGCMC::write_restart(FILE *fp) { int n = 0; - double list[4]; + double list[12]; list[n++] = random_equal->state(); list[n++] = random_unequal->state(); - list[n++] = next_reneighbor; + list[n++] = ubuf(next_reneighbor).d; + list[n++] = ntranslation_attempts; + list[n++] = ntranslation_successes; + list[n++] = nrotation_attempts; + list[n++] = nrotation_successes; + list[n++] = ndeletion_attempts; + list[n++] = ndeletion_successes; + list[n++] = ninsertion_attempts; + list[n++] = ninsertion_successes; + if (comm->me == 0) { int size = n * sizeof(double); @@ -2558,7 +2567,16 @@ void FixGCMC::restart(char *buf) seed = static_cast (list[n++]); random_unequal->reset(seed); - next_reneighbor = static_cast (list[n++]); + next_reneighbor = (bigint) ubuf(list[n++]).i; + + ntranslation_attempts = list[n++]; + ntranslation_successes = list[n++]; + nrotation_attempts = list[n++]; + nrotation_successes = list[n++]; + ndeletion_attempts = list[n++]; + ndeletion_successes = list[n++]; + ninsertion_attempts = list[n++]; + ninsertion_successes = list[n++]; } void FixGCMC::grow_molecule_arrays(int nmolatoms) { diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index 1428299eb7..a1d0669f32 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -802,7 +802,7 @@ void FixDeposit::write_restart(FILE *fp) list[n++] = random->state(); list[n++] = ninserted; list[n++] = nfirst; - list[n++] = next_reneighbor; + list[n++] = ubuf(next_reneighbor).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -823,7 +823,7 @@ void FixDeposit::restart(char *buf) seed = static_cast (list[n++]); ninserted = static_cast (list[n++]); nfirst = static_cast (list[n++]); - next_reneighbor = static_cast (list[n++]); + next_reneighbor = (bigint) ubuf(list[n++]).i; random->reset(seed); } From f73c848ee404be8a704bf247e42b99b14bf8b6d2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 31 May 2019 00:31:36 -0400 Subject: [PATCH 24/27] detect and error out when timestep was reset when restarting fixes atom/swap, gcmc, or deposit --- src/MC/fix_atom_swap.cpp | 5 +++++ src/MC/fix_gcmc.cpp | 6 +++++- src/MISC/fix_deposit.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/MC/fix_atom_swap.cpp b/src/MC/fix_atom_swap.cpp index aad8d7447f..7d817ffbb1 100644 --- a/src/MC/fix_atom_swap.cpp +++ b/src/MC/fix_atom_swap.cpp @@ -777,6 +777,7 @@ void FixAtomSwap::write_restart(FILE *fp) list[n++] = ubuf(next_reneighbor).d; list[n++] = nswap_attempts; list[n++] = nswap_successes; + list[n++] = ubuf(update->ntimestep).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -804,4 +805,8 @@ void FixAtomSwap::restart(char *buf) nswap_attempts = static_cast(list[n++]); nswap_successes = static_cast(list[n++]); + + bigint ntimestep_restart = (bigint) ubuf(list[n++]).i; + if (ntimestep_restart != update->ntimestep) + error->all(FLERR,"Must not reset timestep when restarting fix atom/swap"); } diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index f3a11a1000..7ab0879335 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -2543,7 +2543,7 @@ void FixGCMC::write_restart(FILE *fp) list[n++] = ndeletion_successes; list[n++] = ninsertion_attempts; list[n++] = ninsertion_successes; - + list[n++] = ubuf(update->ntimestep).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -2577,6 +2577,10 @@ void FixGCMC::restart(char *buf) ndeletion_successes = list[n++]; ninsertion_attempts = list[n++]; ninsertion_successes = list[n++]; + + bigint ntimestep_restart = (bigint) ubuf(list[n++]).i; + if (ntimestep_restart != update->ntimestep) + error->all(FLERR,"Must not reset timestep when restarting fix gcmc"); } void FixGCMC::grow_molecule_arrays(int nmolatoms) { diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index a1d0669f32..66aed34846 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -798,11 +798,12 @@ void FixDeposit::options(int narg, char **arg) void FixDeposit::write_restart(FILE *fp) { int n = 0; - double list[4]; + double list[5]; list[n++] = random->state(); list[n++] = ninserted; list[n++] = nfirst; list[n++] = ubuf(next_reneighbor).d; + list[n++] = ubuf(update->ntimestep).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -825,6 +826,10 @@ void FixDeposit::restart(char *buf) nfirst = static_cast (list[n++]); next_reneighbor = (bigint) ubuf(list[n++]).i; + bigint ntimestep_restart = (bigint) ubuf(list[n++]).i; + if (ntimestep_restart != update->ntimestep) + error->all(FLERR,"Must not reset timestep when restarting this fix"); + random->reset(seed); } From 8b169d97f5fc063081edaec35764412cc97d12a3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 31 May 2019 00:58:10 -0400 Subject: [PATCH 25/27] update documentation for updates to fix restarting --- doc/src/fix_atom_swap.txt | 7 ++++++- doc/src/fix_deposit.txt | 4 ++++ doc/src/fix_gcmc.txt | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/src/fix_atom_swap.txt b/doc/src/fix_atom_swap.txt index 22091eca00..cb6bc26aa1 100644 --- a/doc/src/fix_atom_swap.txt +++ b/doc/src/fix_atom_swap.txt @@ -141,11 +141,16 @@ specify if this should be done. This fix writes the state of the fix to "binary restart files"_restart.html. This includes information about the random -number generator seed, the next timestep for MC exchanges, etc. See +number generator seed, the next timestep for MC exchanges, the number +of exchange attempts and successes etc. See the "read_restart"_read_restart.html command for info on how to re-specify a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +NOTE: For this to work correctly, the timestep must [not] be changed +after reading the restart with "reset_timestep"_reset_timestep.html. +The fix will try to detect it and stop with an error. + None of the "fix_modify"_fix_modify.html options are relevant to this fix. diff --git a/doc/src/fix_deposit.txt b/doc/src/fix_deposit.txt index fd12d4bb45..9ab125a55f 100644 --- a/doc/src/fix_deposit.txt +++ b/doc/src/fix_deposit.txt @@ -261,6 +261,10 @@ next timestep for deposition, etc. See the a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +NOTE: For this to work correctly, the timestep must [not] be changed +after reading the restart with "reset_timestep"_reset_timestep.html. +The fix will try to detect it and stop with an error. + None of the "fix_modify"_fix_modify.html options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various "output commands"_Howto_output.html. No parameter diff --git a/doc/src/fix_gcmc.txt b/doc/src/fix_gcmc.txt index 8a66a007a3..3c0f2c2f17 100644 --- a/doc/src/fix_gcmc.txt +++ b/doc/src/fix_gcmc.txt @@ -373,11 +373,16 @@ adds all inserted atoms of the specified type to the This fix writes the state of the fix to "binary restart files"_restart.html. This includes information about the random -number generator seed, the next timestep for MC exchanges, etc. See +number generator seed, the next timestep for MC exchanges, the number +of MC step attempts and successes etc. See the "read_restart"_read_restart.html command for info on how to re-specify a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +NOTE: For this to work correctly, the timestep must [not] be changed +after reading the restart with "reset_timestep"_reset_timestep.html. +The fix will try to detect it and stop with an error. + None of the "fix_modify"_fix_modify.html options are relevant to this fix. From 5f657b91842de2b649c3097828085e717ea7198d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 29 May 2019 15:42:28 -0400 Subject: [PATCH 26/27] step version string for next release --- doc/lammps.1 | 2 +- doc/src/Manual.txt | 4 ++-- src/version.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/lammps.1 b/doc/lammps.1 index ac23e7abf8..8517abcdd5 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "15 May 2019" "2019-05-15" +.TH LAMMPS "31 May 2019" "2019-05-31" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/doc/src/Manual.txt b/doc/src/Manual.txt index 396155cc45..0fb707746c 100644 --- a/doc/src/Manual.txt +++ b/doc/src/Manual.txt @@ -1,7 +1,7 @@ LAMMPS Users Manual - + @@ -21,7 +21,7 @@ :line LAMMPS Documentation :c,h1 -15 May 2019 version :c,h2 +31 May 2019 version :c,h2 "What is a LAMMPS version?"_Manual_version.html diff --git a/src/version.h b/src/version.h index 0377cb9b35..312c87bd0c 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "15 May 2019" +#define LAMMPS_VERSION "31 May 2019" From 68d69955d0bebbf8c6a93501aadbaf0d59dcee20 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 31 May 2019 14:38:12 -0400 Subject: [PATCH 27/27] fix off-by-one error --- src/variable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/variable.cpp b/src/variable.cpp index fdef9985bf..376cc8045a 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -384,7 +384,7 @@ void Variable::set(int narg, char **arg) num[nvar] = 3; which[nvar] = 0; pad[nvar] = 0; - if (!utils::strmatch(arg[2],"%[0-9 ]*\\.[0-9]+[efgEFG]")) + if (!utils::strmatch(arg[3],"%[0-9 ]*\\.[0-9]+[efgEFG]")) error->all(FLERR,"Incorrect conversion in format string"); data[nvar] = new char*[num[nvar]]; copy(2,&arg[2],data[nvar]);