diff --git a/doc/src/plugin.rst b/doc/src/plugin.rst index a75e39ccae..e8a5f67e3c 100644 --- a/doc/src/plugin.rst +++ b/doc/src/plugin.rst @@ -10,7 +10,7 @@ Syntax plugin command args -* command = *load* or *unload* or *list* +* command = *load* or *unload* or *list* or *clear* * args = list of arguments for a particular plugin command .. parsed-literal:: @@ -19,6 +19,7 @@ Syntax *unload* style name = unload plugin *name* of style *style* *style* = *pair* or *fix* or *command* *list* = print a list of currently loaded plugins + *clear* = unload all currently loaded plugins Examples """""""" @@ -29,6 +30,7 @@ Examples plugin unload pair morse2/omp plugin unload command hello plugin list + plugin clear Description """"""""""" @@ -52,21 +54,25 @@ that style instance will be deleted. The *list* command will print a list of the loaded plugins and their styles and names. +The *clear* command will unload all currently loaded plugins. + Restrictions """""""""""" -Plugins are currently not available on Windows. +Plugins are not available on Windows. -For the loading of plugins to work, the LAMMPS library must be -:ref:`compiled as a shared library `. +For the loading of plugins to work the LAMMPS library must be +:ref:`compiled as a shared library `. If plugins +access functions or classes from a package, LAMMPS must have +been compiled with that package included. Plugins are dependent on the LAMMPS binary interface (ABI) and particularly the MPI library used. So they are not guaranteed to work when the plugin was compiled with a different MPI library or different compilation settings or a different LAMMPS version. -If there is a mismatch the *plugin* command may fail to load the -plugin(s) or data corruption or crashes may happen. +There are no checks, so if there is a mismatch the plugin object +will either not load or data corruption and crashes may happen. Related commands diff --git a/src/input.cpp b/src/input.cpp index 6d1564ecb6..1df60f5298 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1110,6 +1110,8 @@ void Input::plugin() } else if (cmd == "unload") { if (narg != 3) error->all(FLERR,"Illegal plugin unload command"); plugin_unload(arg[1],arg[2],lmp); + } else if (cmd == "clear") { + plugin_clear(lmp); } else if (cmd == "list") { if (comm->me == 0) { int num = plugin_get_num_plugins(); diff --git a/src/plugin.cpp b/src/plugin.cpp index fb3186c69e..99b1b086c5 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -238,6 +238,18 @@ namespace LAMMPS_NS } } + /* -------------------------------------------------------------------- + unload all loaded plugins + -------------------------------------------------------------------- */ + + void plugin_clear(LAMMPS *lmp) + { + while (pluginlist.size() > 0) { + auto p = pluginlist.begin(); + plugin_unload(p->style,p->name,lmp); + } + } + /* -------------------------------------------------------------------- remove plugin of given name and style from internal lists -------------------------------------------------------------------- */ diff --git a/src/plugin.h b/src/plugin.h index 32a5a280a1..90952224a6 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -25,6 +25,7 @@ namespace LAMMPS_NS void plugin_unload(const char *, const char *, LAMMPS *); void plugin_erase(const char *, const char *); + void plugin_clear(LAMMPS *); int plugin_get_num_plugins(); int plugin_find(const char *, const char *); diff --git a/tools/lammps-shell/lammps-shell.cpp b/tools/lammps-shell/lammps-shell.cpp index 8153c1bcfa..6c8873093f 100644 --- a/tools/lammps-shell/lammps-shell.cpp +++ b/tools/lammps-shell/lammps-shell.cpp @@ -350,7 +350,7 @@ static char *variable_expand_generator(const char *text, int state) static char *plugin_generator(const char *text, int state) { - const char *subcmd[] = {"load", "unload", "list", NULL}; + const char *subcmd[] = {"load", "unload", "list", "clear", NULL}; const char *sub; static std::size_t idx, len; if (!state) idx = 0;