From e0322b96ec128991221afa5c93c3e666d222c144 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 24 Mar 2025 04:33:27 -0400 Subject: [PATCH] sync new library interface function across all interfaced derived packages --- examples/COUPLE/plugin/liblammpsplugin.c | 1 + examples/COUPLE/plugin/liblammpsplugin.h | 4 +++- fortran/lammps.f90 | 16 ++++++++++++++++ src/error.cpp | 2 +- src/library.h | 4 +--- tools/swig/lammps.i | 2 ++ 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/COUPLE/plugin/liblammpsplugin.c b/examples/COUPLE/plugin/liblammpsplugin.c index 619b8828fc..87cf58729c 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.c +++ b/examples/COUPLE/plugin/liblammpsplugin.c @@ -204,6 +204,7 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib) ADDSYM(has_error); ADDSYM(get_last_error_message); } + ADDSYM(set_show_error); ADDSYM(python_api_version); return lmp; diff --git a/examples/COUPLE/plugin/liblammpsplugin.h b/examples/COUPLE/plugin/liblammpsplugin.h index c347dac4c1..3732b3a5c0 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.h +++ b/examples/COUPLE/plugin/liblammpsplugin.h @@ -109,6 +109,7 @@ struct _liblammpsplugin { int abiversion; int has_exceptions; void *handle; + #if defined(LAMMPS_LIB_MPI) void *(*open)(int, char **, MPI_Comm, void **); #else @@ -187,7 +188,7 @@ struct _liblammpsplugin { * the ifdef ensures they are compatible with rest of LAMMPS * caller must match to how LAMMPS library is built */ -#ifndef LAMMPS_BIGBIG +#if !defined(LAMMPS_BIGBIG) int (*create_atoms)(void *, int, int *, int *, double *, double *, int *, int); #else int (*create_atoms)(void *, int, int64_t *, int *, double *, double *, int64_t *, int); @@ -255,6 +256,7 @@ struct _liblammpsplugin { int (*has_error)(void *); int (*get_last_error_message)(void *, char *, int); + int (*set_show_error)(void *, const int); int (*python_api_version)(); }; diff --git a/fortran/lammps.f90 b/fortran/lammps.f90 index 9922fd1f2d..fdd10167bf 100644 --- a/fortran/lammps.f90 +++ b/fortran/lammps.f90 @@ -248,6 +248,7 @@ MODULE LIBLAMMPS PROCEDURE :: force_timeout => lmp_force_timeout PROCEDURE :: has_error => lmp_has_error PROCEDURE :: get_last_error_message => lmp_get_last_error_message + PROCEDURE :: set_show_error => lmp_set_show_error END TYPE lammps INTERFACE lammps @@ -1041,6 +1042,13 @@ MODULE LIBLAMMPS INTEGER(c_int), VALUE :: buf_size END FUNCTION lammps_get_last_error_message + INTEGER(c_int) FUNCTION lammps_set_show_error(handle,flag) BIND(C) + IMPORT :: c_ptr, c_int + IMPLICIT NONE + TYPE(c_ptr), VALUE :: handle + INTEGER(c_int), VALUE :: flag + END FUNCTION lammps_set_show_error + !--------------------------------------------------------------------- ! Utility functions imported for convenience (not in library.h) !--------------------------------------------------------------------- @@ -3666,6 +3674,14 @@ CONTAINS END IF END SUBROUTINE lmp_get_last_error_message + ! equivalent function to lammps_set_show_error + INTEGER FUNCTION lmp_set_show_error(self, flag) + CLASS(lammps), INTENT(IN) :: self + INTEGER, INTENT(IN) :: flag + + lmp_set_show_error = lammps_set_show_error(self%handle, flag) + END FUNCTION lmp_set_show_error + ! ---------------------------------------------------------------------- ! functions to assign user-space pointers to LAMMPS data ! ---------------------------------------------------------------------- diff --git a/src/error.cpp b/src/error.cpp index 3e17fec2e8..6de19b6323 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -320,7 +320,7 @@ void Error::set_last_error(const char *msg, ErrorType type) int Error::set_show_error(const int flag) { - int oldflag = show_error + int oldflag = showerror; showerror = flag; return oldflag; } diff --git a/src/library.h b/src/library.h index 1744d99fcf..0d57fdaf78 100644 --- a/src/library.h +++ b/src/library.h @@ -287,10 +287,8 @@ void lammps_decode_image_flags(int64_t image, int *flags); #if defined(LAMMPS_BIGBIG) typedef void (*FixExternalFnPtr)(void *, int64_t, int, int64_t *, double **, double **); -#elif defined(LAMMPS_SMALLBIG) -typedef void (*FixExternalFnPtr)(void *, int64_t, int, int *, double **, double **); #else -typedef void (*FixExternalFnPtr)(void *, int, int, int *, double **, double **); +typedef void (*FixExternalFnPtr)(void *, int64_t, int, int *, double **, double **); #endif void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalFnPtr funcptr, diff --git a/tools/swig/lammps.i b/tools/swig/lammps.i index 476e6ad17d..1ed36d61c8 100644 --- a/tools/swig/lammps.i +++ b/tools/swig/lammps.i @@ -222,6 +222,7 @@ extern int lammps_is_running(void *handle); extern void lammps_force_timeout(void *handle); extern int lammps_has_error(void *handle); extern int lammps_get_last_error_message(void *handle, char *buffer, int buf_size); +extern int lammps_set_show_error(void *handle, const int flag); extern int lammps_python_api_version(); %} @@ -418,6 +419,7 @@ extern int lammps_is_running(void *handle); extern void lammps_force_timeout(void *handle); extern int lammps_has_error(void *handle); extern int lammps_get_last_error_message(void *handle, char *buffer, int buf_size); +extern int lammps_set_show_error(void *handle, const int flag); extern int lammps_python_api_version(); /* last revised on 3 October 2022 */