Molssi Driver Interface Library
Functions
mdi_lib.c File Reference

Implementation of library-based communication. More...

#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "mdi.h"
#include "mdi_lib.h"
#include "mdi_global.h"
#include "mdi_general.h"
#include "mdi_plug_py.h"
#include <dlfcn.h>

Functions

int enable_plug_support (int code_id)
 Enable support for the PLUG method.
 
int plug_on_selection ()
 Callback when the end-user selects PLUG as the method.
 
int plug_on_accept_communicator ()
 Callback when the PLUG method must accept a communicator.
 
int plug_on_send_command (const char *command, MDI_Comm comm, int *skip_flag)
 Callback when the PLUG method must send a command.
 
int plug_after_send_command (const char *command, MDI_Comm comm)
 Callback after the PLUG method has received a command.
 
int plug_on_recv_command (MDI_Comm comm)
 Callback when the PLUG method must receive a command.
 
int library_load_init (const char *plugin_name, void *mpi_comm_ptr, library_data *libd, int mode)
 Load the initialization function for a plugin. More...
 
int library_parse_options (const char *options, library_data *libd)
 Parse command-line plugin options. More...
 
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. More...
 
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. More...
 
int library_close_plugin (MDI_Comm mdi_comm)
 
int library_initialize ()
 Perform initialization of a communicator for library-based communication. More...
 
int library_set_driver_current (MDI_Comm comm)
 Set the driver as the current code. More...
 
int library_set_command (const char *command, MDI_Comm comm)
 Set the next command that will be executed through the library communicator. More...
 
int library_execute_command (MDI_Comm comm)
 Execute a command through a communicator. More...
 
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. More...
 
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. More...
 
int communicator_delete_lib (void *comm)
 Function for LIBRARY-specific deletion operations for communicator deletion.
 
int library_delete_engine (size_t code_id)
 Function to delete all of the engine's state.
 
int library_set_state (void *state)
 Function to set the plugin's state.
 
int library_activate_code (void *codes_in, int code_id)
 Function to set the active code.
 

Detailed Description

Implementation of library-based communication.

Function Documentation

◆ library_execute_command()

int library_execute_command ( MDI_Comm  comm)

Execute a command through a communicator.

If running with MPI, this function must be called only by rank 0. The function returns 0 on a success.

Parameters
[in]commandPointer to the command to be executed.
[in]commMDI communicator associated with the intended recipient code.

◆ library_initialize()

int library_initialize ( )

Perform initialization of a communicator for library-based communication.

◆ 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.

◆ 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.

◆ 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.

◆ library_parse_options()

int library_parse_options ( const char *  options,
library_data libd 
)

Parse command-line plugin options.

◆ 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.

Parameters
[in]bufPointer to the buffer where the received data will be stored.
[in]countNumber of values (integers, double precision floats, characters, etc.) to be received.
[in]datatypeMDI handle (MDI_INT, MDI_DOUBLE, MDI_CHAR, etc.) corresponding to the type of data to be received.
[in]commMDI communicator associated with the connection to the sending code.
[in]msg_flagType of role this data has within a message. 0: Not part of a message. 1: The header of a message. 2: The body (data) of a message.

◆ 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.

Parameters
[in]bufPointer to the data to be sent.
[in]countNumber of values (integers, double precision floats, characters, etc.) to be sent.
[in]datatypeMDI handle (MDI_INT, MDI_DOUBLE, MDI_CHAR, etc.) corresponding to the type of data to be sent.
[in]commMDI communicator associated with the intended recipient code.
[in]msg_flagType of role this data has within a message. 0: Not part of a message. 1: The header of a message. 2: The body (data) of a message.

◆ 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.

If running with MPI, this function must be called only by rank 0. The function returns 0 on a success.

Parameters
[in]commandPointer to the command to be executed.
[in]commMDI communicator associated with the intended recipient code.

◆ library_set_driver_current()

int library_set_driver_current ( MDI_Comm  comm)

Set the driver as the current code.