check for compatible LAMMPS version when creating LAMMPS instance

This check must be done at runtime, since the LAMMPS shared library
may have been loaded dynamically and thus required library functions
may not be present or missing features with too only a LAMMPS version.
This commit is contained in:
Axel Kohlmeyer
2023-09-25 08:07:36 -04:00
parent 082d2bec9f
commit 2c636c83f5
3 changed files with 23 additions and 0 deletions

View File

@ -1398,6 +1398,15 @@ void LammpsGui::start_lammps()
lammps.open(narg, args); lammps.open(narg, args);
lammpsstatus->show(); lammpsstatus->show();
// must have at least 2 August 2023 version of LAMMPS
// TODO: must update this check before next feature release
if (lammps.version() < 20230802) {
QMessageBox::critical(this, "Incompatible LAMMPS Version",
"LAMMPS-GUI version " LAMMPS_GUI_VERSION " requires\n"
"LAMMPS version 2 August 2023 or later");
exit(1);
}
// delete additional arguments again (3 were there initially // delete additional arguments again (3 were there initially
while ((int)lammps_args.size() > initial_narg) { while ((int)lammps_args.size() > initial_narg) {
delete lammps_args.back(); delete lammps_args.back();

View File

@ -36,6 +36,19 @@ void LammpsWrapper::open(int narg, char **args)
#endif #endif
} }
int LammpsWrapper::version()
{
int val = 0;
if (lammps_handle) {
#if defined(LAMMPS_GUI_USE_PLUGIN)
val = ((liblammpsplugin_t *)plugin_handle)->version(lammps_handle);
#else
val = lammps_version(lammps_handle);
#endif
}
return val;
}
int LammpsWrapper::extract_setting(const char *keyword) int LammpsWrapper::extract_setting(const char *keyword)
{ {
int val = 0; int val = 0;

View File

@ -29,6 +29,7 @@ public:
void force_timeout(); void force_timeout();
int version();
int extract_setting(const char *keyword); int extract_setting(const char *keyword);
void *extract_global(const char *keyword); void *extract_global(const char *keyword);
void *extract_atom(const char *keyword); void *extract_atom(const char *keyword);