diff --git a/src/lammps.cpp b/src/lammps.cpp index 69945a805f..6f9025a900 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -594,15 +594,32 @@ void LAMMPS::create() } /* ---------------------------------------------------------------------- + check suffix consistency with installed packages + do this for GPU, USER-INTEL, USER-OMP + already done in constructor for USER-CUDA, KOKKOS + turn off suffix2 = omp if USER-OMP is not installed invoke package-specific setup commands + only invoke if suffix is set and enabled + also check if suffix2 is set called from LAMMPS constructor and after clear() command - only invoke if suffix is set and enabled - also check if suffix2 is set ------------------------------------------------------------------------- */ void LAMMPS::post_create() { if (!suffix_enable) return; + + if (strcmp(suffix,"gpu") == 0 && !modify->check_package("GPU")) + error->all(FLERR,"Using suffix gpu without GPU package installed"); + if (strcmp(suffix,"intel") == 0 && !modify->check_package("Intel")) + error->all(FLERR,"Using suffix intel without USER-INTEL package installed"); + if (strcmp(suffix,"omp") == 0 && !modify->check_package("OMP")) + error->all(FLERR,"Using suffix omp without USER-OMP package installed"); + + if (strcmp(suffix2,"omp") == 0 && !modify->check_package("OMP")) { + delete [] suffix2; + suffix2 = NULL; + } + if (suffix) { if (strcmp(suffix,"gpu") == 0) input->one("package gpu force/neigh 0 0 1"); if (strcmp(suffix,"omp") == 0) input->one("package omp *"); diff --git a/src/modify.cpp b/src/modify.cpp index 065838f4ce..637cfc0863 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -860,6 +860,19 @@ int Modify::find_fix(const char *id) return ifix; } +/* ---------------------------------------------------------------------- + check for fix associated with package name + return 1 if found else 0 + used to determine whether LAMMPS was built with + GPU, USER-INTEL, USER-OMP packages +------------------------------------------------------------------------- */ + +int Modify::check_package(const char *package_fix_name) +{ + if (fix_map->find(package_fix_name) == fix_map->end()) return 0; + return 1; +} + /* ---------------------------------------------------------------------- add a new compute ------------------------------------------------------------------------- */ diff --git a/src/modify.h b/src/modify.h index ba7101a934..dbe4b5a3fa 100644 --- a/src/modify.h +++ b/src/modify.h @@ -86,6 +86,7 @@ class Modify : protected Pointers { void modify_fix(int, char **); void delete_fix(const char *); int find_fix(const char *); + int check_package(const char *); void add_compute(int, char **, int trysuffix=0); void modify_compute(int, char **);