MPI_SEND(3)

πŸ’– MPI_Send πŸ’– (that's MPI_SEND(3) in the Open MPI manual, bestie)

okay so. you wanna send a message in MPI. standard-mode. blocking. no cap, this is THE function. it's giving "hello world but make it distributed." let's get into it πŸ¦‹


✨ SYNTAX ✨

C Syntax πŸ“

#include <mpi.h>

int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest,
     int tag, MPI_Comm comm)

Fortran Syntax 🌸

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_SEND(BUF, COUNT, DATATYPE, DEST, TAG, COMM, IERROR)
     <type>  BUF(*)
     INTEGER COUNT, DATATYPE, DEST, TAG, COMM, IERROR

Fortran 2008 Syntax πŸŽ€

USE mpi_f08
MPI_Send(buf, count, datatype, dest, tag, comm, ierror)
     TYPE(*), DIMENSION(..), INTENT(IN) :: buf
     INTEGER, INTENT(IN) :: count, dest, tag
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     TYPE(MPI_Comm), INTENT(IN) :: comm
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🫢 INPUT PARAMETERS 🫢

the stuff you hand over, bestie:

  • buf β€” initial address of send buffer (choice). like, where your data is literally sitting, waiting to be yeeted across the network. πŸ“¦
  • count β€” number of elements in the send buffer (nonnegative integer). not bytes, bestie, elements. count them πŸ’…
  • datatype β€” datatype of each send buffer element (handle). tells MPI what one element even is.
  • dest β€” rank of destination (integer). who's getting this message πŸ‘€
  • tag β€” message tag (integer). your little label so the receiver knows what's what.
  • comm β€” communicator (handle). the group chat this whole thing happens inside πŸ’¬

🫢 OUTPUT PARAMETER 🫢

  • ierror β€” Fortran only: error status (integer). C girlies get the error back as the function's return value instead, iykyk.

πŸ’… DESCRIPTION πŸ’…

MPI_Send performs a standard-mode, blocking send.

that's it. that's the whole vibe. ✨


πŸ”₯ NOTE πŸ”₯

this routine will block until the message is sent to the destination. like, it does not return early, it just sits there, committed, main character energy. 😭

for an in-depth explanation of the semantics of the standard-mode send, refer to the MPI Standard https://www.mpi-forum.org/docs/.


πŸ’€ ERRORS πŸ’€

okay so this part is long but hear me out, it's important:

almost all MPI routines return an error value; C routines as the return result of the function and Fortran routines in the last argument.

before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized (i.e., before MPI_Init <#mpi-init> / MPI_Init_thread <#mpi-init-thread>, after MPI_Finalize <#mpi-finalize>, or when using the Sessions Model exclusively) the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler <#mpi-comm-set-errhandler> on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn <#mpi-comm-spawn> / MPI_Comm_spawn_multiple <#mpi-comm-spawn-multiple>. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions.

Open MPI includes three predefined error handlers that can be used:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as if MPI_Abort <#mpi-abort> was called on that communicator. if called on a window or file, acts as if MPI_Abort <#mpi-abort> was called on a communicator containing the group of processes in the corresponding window or file. if called on a session, aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. 🫢

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler <#mpi-comm-create-errhandler> then MPI_Comm_set_errhandler <#mpi-comm-set-errhandler>
  • MPI_File_create_errhandler <#mpi-file-create-errhandler> then MPI_File_set_errhandler <#mpi-file-set-errhandler>
  • MPI_Session_create_errhandler <#mpi-session-create-errhandler> then MPI_Session_set_errhandler <#mpi-session-set-errhandler> or at MPI_Session_init <#mpi-session-init>
  • MPI_Win_create_errhandler <#mpi-win-create-errhandler> then MPI_Win_set_errhandler <#mpi-win-set-errhandler>
note that MPI does not guarantee that an MPI program can continue past an error. no promises, bestie πŸ™ˆ

see the MPI man page open-mpi for a full list of MPI error codes open-mpi-errors.

see the Error Handling section of the MPI-3.1 standard for more information.

see also:

  • MPI_Isend <#mpi-isend>
  • MPI_Bsend <#mpi-bsend>
  • MPI_Recv <#mpi-recv>

2003-2026, The Open MPI Community


okay that's the whole thing slay πŸ’– go forth and send your messages, bestie. this page is from Open MPI, and it was last touched Sep 10, 2026 β€” so if you're reading this, hi from the future, ily, now go MPI_Send something iconic πŸŒˆβœ¨πŸ‘‘

πŸ“¦ where this page comes from