Molssi Driver Interface Library
mdi_lib.h
Go to the documentation of this file.
1 
6 #ifndef MDI_LIBRARY_IMPL
7 #define MDI_LIBRARY_IMPL
8 
9 #include "mdi.h"
10 #include "mdi_global.h"
11 
12 typedef int (*MDI_Plugin_init_t)();
13 
14 typedef struct library_data_struct {
19  char command[MDI_COMMAND_LENGTH_];
25  MPI_Comm mpi_comm;
29  MDI_Driver_node_callback_t driver_node_callback;
31  void* buf;
32 #ifdef _WIN32
33 
34  HINSTANCE plugin_handle;
35 #else
36 
38 #endif
39 
40  MDI_Plugin_init_t plugin_init;
42  int is_python;
46  char** plugin_argv;
49 } library_data;
50 
52 int plug_on_selection();
54 int plug_on_send_command(const char* command, MDI_Comm comm, int* skip_flag);
55 int plug_after_send_command(const char* command, MDI_Comm comm);
56 int plug_on_recv_command(MDI_Comm comm);
57 
58 int library_load_init(const char* plugin_name, void* mpi_comm_ptr,
59  library_data* libd, int mode);
60 int library_parse_options(const char* options, library_data* libd);
61 int library_launch_plugin(const char* plugin_name, const char* options, void* mpi_comm_ptr,
62  MDI_Driver_node_callback_t driver_node_callback,
63  void* driver_callback_object);
64 int library_open_plugin(const char* plugin_name, const char* options, void* mpi_comm_ptr,
65  MDI_Comm* mdi_comm_ptr);
66 int library_close_plugin(MDI_Comm mdi_comm);
67 int library_initialize();
70 int library_get_matching_handle(MDI_Comm comm);
71 int library_set_command(const char* command, MDI_Comm comm);
72 int library_execute_command(MDI_Comm comm);
73 int library_send(const void* buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag);
74 int library_recv(void* buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag);
75 int library_send_msg(const void* buf, int count, MDI_Datatype datatype, MDI_Comm comm);
76 int library_recv_msg(void* buf, int count, MDI_Datatype datatype, MDI_Comm comm);
77 
78 int communicator_delete_lib(void* comm);
79 
80 #endif
library_data_struct::driver_node_callback
MDI_Driver_node_callback_t driver_node_callback
Function pointer to the driver node's callback function.
Definition: mdi_lib.h:29
library_set_command
int library_set_command(const char *command, MDI_Comm comm)
Set the next command that will be executed through the library communicator.
Definition: mdi_lib.c:745
library_data_struct::plugin_argv_allocated
int plugin_argv_allocated
Flag whether plugin_argv is allocted for this code.
Definition: mdi_lib.h:48
plug_on_send_command
int plug_on_send_command(const char *command, MDI_Comm comm, int *skip_flag)
Callback when the PLUG method must send a command.
Definition: mdi_lib.c:75
library_execute_command
int library_execute_command(MDI_Comm comm)
Execute a command through a communicator.
Definition: mdi_lib.c:775
library_accept_communicator
int library_accept_communicator()
Perform LIBRARY method operations upon a call to MDI_Accept_Communicator.
Definition: mdi_lib.c:649
library_data_struct::connected_code
int connected_code
Handle of the code to which this communicator connects.
Definition: mdi_lib.h:16
mdi_global.h
Global structures used by MDI.
library_data_struct::buf
void * buf
Buffer used for communication of data.
Definition: mdi_lib.h:31
library_send
int library_send(const void *buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag)
Function to handle sending data through an MDI connection, using library-based communication.
Definition: mdi_lib.c:826
plug_on_selection
int plug_on_selection()
Callback when the end-user selects PLUG as the method.
Definition: mdi_lib.c:39
library_data_struct::plugin_argv
char ** plugin_argv
Argument vector for plugin command-line options.
Definition: mdi_lib.h:46
library_data_struct::buf_allocated
int buf_allocated
Flag whether buf is allocated.
Definition: mdi_lib.h:21
communicator_delete_lib
int communicator_delete_lib(void *comm)
Function for LIBRARY-specific deletion operations for communicator deletion.
Definition: mdi_lib.c:1025
library_data_struct::plugin_argc
int plugin_argc
Argument count for plugin command-line options.
Definition: mdi_lib.h:44
plug_on_recv_command
int plug_on_recv_command(MDI_Comm comm)
Callback when the PLUG method must receive a command.
Definition: mdi_lib.c:151
library_data_struct::is_python
int is_python
Flag whether this communicator connects to a Python library.
Definition: mdi_lib.h:42
library_launch_plugin
int library_launch_plugin(const char *plugin_name, const char *options, void *mpi_comm_ptr, MDI_Driver_node_callback_t driver_node_callback, void *driver_callback_object)
Launch an MDI plugin.
Definition: mdi_lib.c:372
library_get_matching_handle
int library_get_matching_handle(MDI_Comm comm)
Get the handle to the matching communicator on the code to which comm points.
Definition: mdi_lib.c:704
library_open_plugin
int library_open_plugin(const char *plugin_name, const char *options, void *mpi_comm_ptr, MDI_Comm *mdi_comm_ptr)
Open an MDI plugin in the background.
Definition: mdi_lib.c:461
library_data_struct::plugin_init
MDI_Plugin_init_t plugin_init
Initialization function for the plugin library.
Definition: mdi_lib.h:40
library_set_driver_current
int library_set_driver_current()
Set the driver as the current code.
Definition: mdi_lib.c:619
library_data_struct::command
char command[MDI_COMMAND_LENGTH_]
Name of the next command to be executed on this code. This is only used by engines.
Definition: mdi_lib.h:19
library_load_init
int library_load_init(const char *plugin_name, void *mpi_comm_ptr, library_data *libd, int mode)
Load the initialization function for a plugin.
Definition: mdi_lib.c:186
enable_plug_support
int enable_plug_support()
Enable support for the PLUG method.
Definition: mdi_lib.c:25
plug_on_accept_communicator
int plug_on_accept_communicator()
Callback when the PLUG method must accept a communicator.
Definition: mdi_lib.c:54
library_recv
int library_recv(void *buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag)
Function to handle receiving data through an MDI connection, using library-based communication.
Definition: mdi_lib.c:948
library_data_struct::mpi_comm
MPI_Comm mpi_comm
MPI intra-communicator for the engine.
Definition: mdi_lib.h:25
library_data_struct::execute_on_send
int execute_on_send
Flag whether the next MDI_Send call should trigger execution of the engine's command.
Definition: mdi_lib.h:23
library_initialize
int library_initialize()
Perform initialization of a communicator for library-based communication.
Definition: mdi_lib.c:551
library_data_struct::plugin_handle
void * plugin_handle
Non-windows handle for the plugin library.
Definition: mdi_lib.h:37
library_data_struct
Definition: mdi_lib.h:14
library_data_struct::driver_callback_obj
void * driver_callback_obj
Pointer to the class object that is used for the driver_node_callback function.
Definition: mdi_lib.h:27
plug_after_send_command
int plug_after_send_command(const char *command, MDI_Comm comm)
Callback after the PLUG method has received a command.
Definition: mdi_lib.c:144
library_parse_options
int library_parse_options(const char *options, library_data *libd)
Parse command-line plugin options.
Definition: mdi_lib.c:291