Molssi Driver Interface Library
Functions
mdi_general.c File Reference

Generic MDI function calls. More...

#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mdi.h"
#include "mdi_general.h"
#include "mdi_mpi.h"
#include "mdi_tcp.h"
#include "mdi_lib.h"
#include "mdi_test.h"

Functions

int general_init_code ()
 Initialize a new code. More...
 
int general_init (const char *options)
 Initialize communication through the MDI library. More...
 
int general_accept_communicator ()
 Accept a new MDI communicator. More...
 
int general_send (const void *buf, int count, MDI_Datatype datatype, MDI_Comm comm)
 Send a message through the MDI connection. More...
 
int general_recv (void *buf, int count, MDI_Datatype datatype, MDI_Comm comm)
 Receive a message through the MDI connection. More...
 
int general_send_command (const char *buf, MDI_Comm comm)
 Send a command of length MDI_COMMAND_LENGTH through the MDI connection. More...
 
int general_builtin_command (const char *buf, MDI_Comm comm, int *flag)
 Respond to a general built-in command. More...
 
int general_recv_command (char *buf, MDI_Comm comm)
 Receive a command of length MDI_COMMAND_LENGTH through the MDI connection. More...
 
int register_node (vector *node_vec, const char *node_name)
 Register a node. More...
 
int register_command (vector *node_vec, const char *node_name, const char *command_name)
 Register a command on a specified node. More...
 
int register_callback (vector *node_vec, const char *node_name, const char *callback_name)
 Register a callback on a specified node. More...
 
int send_command_list (MDI_Comm comm)
 Send the list of supported commands. More...
 
int send_callback_list (MDI_Comm comm)
 Send the list of callbacks. More...
 
int send_node_list (MDI_Comm comm)
 Send the list of nodes. More...
 
int send_ncommands (MDI_Comm comm)
 Send the number of supported commands. More...
 
int send_ncallbacks (MDI_Comm comm)
 Send the number of supported callbacks. More...
 
int send_nnodes (MDI_Comm comm)
 Send the number of supported nodes. More...
 
int get_node_info (MDI_Comm comm)
 Get information about the nodes of a particular code. More...
 
int get_node_vector (MDI_Comm comm, vector **vector_ptr)
 Get the node vector associated with a particular communicator. More...
 

Detailed Description

Generic MDI function calls.

Function Documentation

◆ general_accept_communicator()

int general_accept_communicator ( )

Accept a new MDI communicator.

The function returns an MDI_Comm that describes a connection between two codes. If no new communicators are available, the function returns MDI_COMM_NULL.

◆ general_builtin_command()

int general_builtin_command ( const char *  buf,
MDI_Comm  comm,
int *  flag 
)

Respond to a general built-in command.

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

Parameters
[in]bufPointer to the buffer for the command name.
[in]commMDI communicator associated with the connection to the sending code.
[in]flagReturns 1 if the command is a built-in command and 0 otherwise.

◆ general_init()

int general_init ( const char *  options)

Initialize communication through the MDI library.

If using the "-method MPI" option, this function must be called by all ranks. The function returns 0 on a success.

Parameters
[in]optionsOptions describing the communication method used to connect to codes.

◆ general_init_code()

int general_init_code ( )

Initialize a new code.

The function returns 0 on a success.

◆ general_recv()

int general_recv ( void *  buf,
int  count,
MDI_Datatype  datatype,
MDI_Comm  comm 
)

Receive a message through the MDI connection.

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

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.

◆ general_recv_command()

int general_recv_command ( char *  buf,
MDI_Comm  comm 
)

Receive a command of length MDI_COMMAND_LENGTH through the MDI connection.

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

Parameters
[in]bufPointer to the buffer where the received data will be stored.
[in]commMDI communicator associated with the connection to the sending code.

◆ general_send()

int general_send ( const void *  buf,
int  count,
MDI_Datatype  datatype,
MDI_Comm  comm 
)

Send a message through the MDI connection.

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

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.

◆ general_send_command()

int general_send_command ( const char *  buf,
MDI_Comm  comm 
)

Send a command of length MDI_COMMAND_LENGTH through the MDI connection.

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

Parameters
[in]bufPointer to the data to be sent.
[in]commMDI communicator associated with the intended recipient code.

◆ get_node_info()

int get_node_info ( MDI_Comm  comm)

Get information about the nodes of a particular code.

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

Parameters
[in]commMDI communicator associated with the connection to the sending code.

◆ get_node_vector()

int get_node_vector ( MDI_Comm  comm,
vector **  vector_ptr 
)

Get the node vector associated with a particular communicator.

The function returns the node vector for the communicator.

Parameters
[in]commMDI communicator of the engine. If comm is set to MDI_COMM_NULL, the function will return the node vector for the calling engine.

◆ register_callback()

int register_callback ( vector node_vec,
const char *  node_name,
const char *  callback_name 
)

Register a callback on a specified node.

The function returns 0 on a success.

Parameters
[in]node_vecVector of nodes, into which the new node will be added.
[in]node_nameName of the node on which the callback will be registered.
[in]callback_nameName of the callback.

◆ register_command()

int register_command ( vector node_vec,
const char *  node_name,
const char *  command_name 
)

Register a command on a specified node.

The function returns 0 on a success.

Parameters
[in]node_vecVector of nodes, into which the new node will be added.
[in]node_nameName of the node on which the command will be registered.
[in]command_nameName of the command.

◆ register_node()

int register_node ( vector node_vec,
const char *  node_name 
)

Register a node.

The function returns 0 on a success.

Parameters
[in]node_vecVector of nodes, into which the new node will be added.
[in]node_nameName of the node.

◆ send_callback_list()

int send_callback_list ( MDI_Comm  comm)

Send the list of callbacks.

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

Parameters
[in]commMDI communicator associated with the intended recipient code.

◆ send_command_list()

int send_command_list ( MDI_Comm  comm)

Send the list of supported commands.

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

Parameters
[in]commMDI communicator associated with the intended recipient code.

◆ send_ncallbacks()

int send_ncallbacks ( MDI_Comm  comm)

Send the number of supported callbacks.

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

Parameters
[in]commMDI communicator associated with the intended recipient code.

◆ send_ncommands()

int send_ncommands ( MDI_Comm  comm)

Send the number of supported commands.

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

Parameters
[in]commMDI communicator associated with the intended recipient code.

◆ send_nnodes()

int send_nnodes ( MDI_Comm  comm)

Send the number of supported nodes.

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

Parameters
[in]commMDI communicator associated with the intended recipient code.

◆ send_node_list()

int send_node_list ( MDI_Comm  comm)

Send the list of nodes.

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

Parameters
[in]commMDI communicator associated with the intended recipient code.