check that wrapper for lammps_open() was compiled with -DLAMMPS_LIB_MPI=1

This commit is contained in:
Axel Kohlmeyer
2022-10-31 16:12:56 -04:00
parent 3ae2f9966b
commit 5d115fec90
3 changed files with 12 additions and 1 deletions

View File

@ -67,7 +67,10 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib)
#if defined(LAMMPS_LIB_MPI) #if defined(LAMMPS_LIB_MPI)
ADDSYM(open); ADDSYM(open);
#else
lmp->open = NULL;
#endif #endif
ADDSYM(open_no_mpi); ADDSYM(open_no_mpi);
ADDSYM(open_fortran); ADDSYM(open_fortran);
ADDSYM(close); ADDSYM(close);

View File

@ -111,6 +111,8 @@ struct _liblammpsplugin {
void *handle; void *handle;
#if defined(LAMMPS_LIB_MPI) #if defined(LAMMPS_LIB_MPI)
void *(*open)(int, char **, MPI_Comm, void **); void *(*open)(int, char **, MPI_Comm, void **);
#else
void *open;
#endif #endif
void *(*open_no_mpi)(int, char **, void **); void *(*open_no_mpi)(int, char **, void **);
void *(*open_fortran)(int, char **, void **, int); void *(*open_fortran)(int, char **, void **, int);

View File

@ -93,7 +93,13 @@ int main(int narg, char **arg)
MPI_Abort(MPI_COMM_WORLD,1); MPI_Abort(MPI_COMM_WORLD,1);
} }
} }
if (lammps == 1) lmp = plugin->open(0,NULL,comm_lammps,NULL); if (lammps == 1) {
if (plugin->open == NULL) {
printf("ERROR: liblammpsmpi.c must be compiled with -DLAMMPS_LIB_MPI=1 for this program\n");
MPI_Abort(MPI_COMM_WORLD,2);
}
lmp = plugin->open(0,NULL,comm_lammps,NULL);
}
while (1) { while (1) {
if (me == 0) { if (me == 0) {