Update pair_kim to check for ModelRoutine requirements
Also fixup cmake settings for PKG_KIM
This commit is contained in:
@ -609,7 +609,7 @@ if(PKG_KIM)
|
||||
message(FATAL_ERROR "KIM not found, help CMake to find it by setting PKG_CONFIG_PATH, or set DOWNLOAD_KIM=ON to download it")
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS ${KIM-API-V2_LIBRARIES})
|
||||
list(APPEND LAMMPS_LINK_LIBS "${KIM-API-V2_LDFLAGS}")
|
||||
include_directories(${KIM-API-V2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
|
||||
@ -789,6 +789,14 @@ void PairKIM::kim_init()
|
||||
error->all(FLERR,"KIM Model did not accept the requested unit system");
|
||||
}
|
||||
|
||||
// check that the model does not require unknown capabilities
|
||||
kimerror = check_for_routine_compatibility();
|
||||
if (kimerror)
|
||||
{
|
||||
error->all(FLERR,
|
||||
"KIM Model requires unknown Routines. Unable to proceed.");
|
||||
}
|
||||
|
||||
kimerror = KIM_Model_ComputeArgumentsCreate(pkim, &pargs);
|
||||
if (kimerror)
|
||||
{
|
||||
@ -987,6 +995,49 @@ void PairKIM::set_lmps_flags()
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int PairKIM::check_for_routine_compatibility()
|
||||
{
|
||||
/* Check that we know about all required routines */
|
||||
int numberOfModelRoutineNames;
|
||||
KIM_MODEL_ROUTINE_NAME_GetNumberOfModelRoutineNames(
|
||||
&numberOfModelRoutineNames);
|
||||
for (int i = 0; i < numberOfModelRoutineNames; ++i)
|
||||
{
|
||||
KIM_ModelRoutineName modelRoutineName;
|
||||
KIM_MODEL_ROUTINE_NAME_GetModelRoutineName(i, &modelRoutineName);
|
||||
|
||||
int present;
|
||||
int required;
|
||||
int error = KIM_Model_IsRoutinePresent(
|
||||
pkim, modelRoutineName, &present, &required);
|
||||
if (error) { return true; }
|
||||
|
||||
if ((present == true) && (required == true))
|
||||
{
|
||||
if (!(KIM_ModelRoutineName_Equal(modelRoutineName,
|
||||
KIM_MODEL_ROUTINE_NAME_Create)
|
||||
|| KIM_ModelRoutineName_Equal(
|
||||
modelRoutineName,
|
||||
KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate)
|
||||
|| KIM_ModelRoutineName_Equal(modelRoutineName,
|
||||
KIM_MODEL_ROUTINE_NAME_Compute)
|
||||
|| KIM_ModelRoutineName_Equal(modelRoutineName,
|
||||
KIM_MODEL_ROUTINE_NAME_Refresh)
|
||||
|| KIM_ModelRoutineName_Equal(
|
||||
modelRoutineName,
|
||||
KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy)
|
||||
|| KIM_ModelRoutineName_Equal(modelRoutineName,
|
||||
KIM_MODEL_ROUTINE_NAME_Destroy)))
|
||||
{ return true; }
|
||||
}
|
||||
}
|
||||
|
||||
/* everything is good */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairKIM::set_kim_model_has_flags()
|
||||
{
|
||||
int numberOfComputeArgumentNames;
|
||||
|
||||
@ -158,6 +158,7 @@ namespace LAMMPS_NS {
|
||||
virtual void set_argument_pointers();
|
||||
virtual void set_lmps_flags();
|
||||
virtual void set_kim_model_has_flags();
|
||||
virtual int check_for_routine_compatibility();
|
||||
// static methods used as callbacks from KIM
|
||||
static int get_neigh(
|
||||
void const * const dataObject,
|
||||
|
||||
Reference in New Issue
Block a user