Melissa Client APIs

Melissa provides functionalities for sending data with,

  • C
  • Python
  • Fortran & Fortran90

C API

melissa_init

Initializes the Melissa connection using an MPI communicator. Retrieves the rank and size of the communicator and calls melissa_init_internal.

Parameters

  • field_name: Field name to initialize.
  • local_vect_size: Size of the local data vector.
  • comm: MPI communicator.

melissa_init_f

Wrapper function to initialize Melissa from Fortran. Converts an MPI Fortran communicator to a C communicator and calls melissa_init.

Parameters

  • field_name: Field name to initialize.
  • local_vect_size: Pointer to local vector size (Fortran-style).
  • comm_fortran: Pointer to MPI Fortran communicator.

melissa_send

Sends a data vector to the Melissa server for the specified field. Used to transmit simulation results or data points during execution.

Parameters

Parameter Type Description
field_name const char* The name of the field to which data is sent.
send_vect const double* Pointer to the data vector to be sent.

Notes

  • The data in send_vect should match the size expected by Melissa for the specified field_name.
  • Ensure that melissa_init has been called prior to sending data.

melissa_send_with_metadata

Sends a data vector to the Melissa server for the specified field. Used to transmit simulation results or data points during execution along with the extra metadata in JSON format.

Parameters

Parameter Type Description
field_name const char* The name of the field to which data is sent.
send_vect const double* Pointer to the data vector to be sent.
metadata_json const char* Pointer to the metadata json as a string.

Notes

  • The data in send_vect should match the size expected by Melissa for the specified field_name.
  • Ensure that metadata_json is a valid JSON string.
  • Ensure that melissa_init has been called prior to sending data.

melissa_finalize

Finalizes the connection with the Melissa server, performing any necessary cleanup operations. This function ensures that all resources associated with the Melissa server are released properly.

Notes

  • Call this function after all data transfers to the Melissa server are complete.
  • Should be called before the MPI environment is finalized (i.e., before MPI_Finalize).

Python API

This code loads the Melissa C API shared library (libmelissa_api.so) using np.ctypeslib.load_library. It then defines C function prototypes for melissa_init, melissa_send, and melissa_finalize, specifying the argument types for each function using ctypes. These prototypes enable interaction with the C API from Python.

melissa_init(field_name, local_vect_size, comm=MPI.COMM_WORLD)

Initializes a connection with the Melissa server.

Parameters
  • field_name (str): The name of the field to initialize.

  • local_vect_size (int): The size of the local data vector for this field.

melissa_send(field_name, send_vect, metadata_json='')

Sends data to the Melissa server for a specific field.

Parameters
  • field_name (str): The name of the field to which the data is being sent.

  • send_vect (NDArray): A NumPy array containing the data vector to be sent to the server.

  • metadata_json (str): The user-given metadata to be sent alognside as a JSON string.

melissa_finalize()

Finalizes the connection with the server.

Fortran(90) API

The Fortran API for Melissa is a thin interface to the underlying C API. It allows Fortran applications to interact seamlessly with the Melissa server by internally converting Fortran-style data structures, such as MPI communicators, into their C counterparts.

melissa_init

  • Acts as a wrapper for melissa_init in the C API.
  • Converts the Fortran MPI communicator (MPI_Fint) to a C MPI communicator (MPI_Comm).

melissa_send

  • Invokes the C function melissa_send for data transmission.

melissa_finalize

  • Calls melissa_finalize to properly close the Melissa connection.

Notes

  • All core functionality is implemented in the C API, ensuring efficient communication and data handling.
  • The Fortran API primarily handles type conversion and calling conventions to maintain compatibility with Fortran applications.