MPI_CLOSE_PORT(3)

πŸ’– MPI_CLOSE_PORT πŸ’–

okay bestie, welcome to the <mpi.h> cinematic universe 🌈 this one's a Open MPI classic β€” MPI_Close_port(3) β€” and she's short, she's sweet, and she's here to release a network address. Periodt. ✨


✨ NAME ✨

MPI_Close_port β€” releases the specified network address. that's the whole job. no notes. πŸ’…


🌸 SYNTAX 🌸

πŸŽ€ C Syntax

#include <mpi.h>

int MPI_Close_port(const char *port_name)

πŸŽ€ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'

MPI_CLOSE_PORT(PORT_NAME, IERROR)
    CHARACTER*(*)   PORT_NAME
    INTEGER     IERROR

πŸŽ€ Fortran 2008 Syntax

USE mpi_f08

MPI_Close_port(port_name, ierror)
    CHARACTER(LEN=*), INTENT(IN) :: port_name
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

like… three whole syntaxes for one little port-close. iconic behavior honestly. πŸ‘‘


πŸ¦‹ INPUT PARAMETER πŸ¦‹

  • port_name β€” a port (string). that's it, that's the argument. she's giving string energy and nothing else. πŸ“

πŸ¦‹ OUTPUT PARAMETER πŸ¦‹

  • ierror β€” Fortran only: error status (integer). C girlies get their error code back as the return value instead, iykyk. πŸ’œ

🌈 DESCRIPTION 🌈

MPI_Close_port releases the network address represented by port_name.

that's literally the whole vibe. you had a port name, you're done with it, you close it, you move on. main character energy: exit gracefully. 🧚


πŸ’€ ERRORS πŸ’€

ok so listen up, because this part is giving "read the fine print" energy and it applies to basically every MPI routine ever:

Almost all MPI routines return an error value. C routines hand it back as the return result of the function, and Fortran routines drop it in the last argument. simple.

Before the error value is even returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets called. and if no communication object is associated with the MPI call? then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler instead.

When MPI_COMM_SELF is not initialized β€” that means before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively β€” the error raises the initial error handler.

And you can change that initial error handler, bestie:

  • by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or
  • via the mpi_initial_errhandler CLI argument to mpiexec, or
  • via the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple.

If no other appropriate error handler has been set, then MPI_ERRORS_RETURN is called for MPI I/O functions, and MPI_ERRORS_ABORT is called for all other MPI functions. that's the default pipeline, no cap. πŸ”₯


πŸ‘‘ the three predefined error handlers

Open MPI ships with three of them, and they're all a little different:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yes, all of them. bestie said "we go down together." πŸ’€
  • 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 was called on that communicator. If called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. If called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. chill. respectful. 🫢

🧚 make your own, you DIY queen

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

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler, or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. like. fr fr. don't assume you can just casually keep vibing after an error, because you might not be able to. 😭

See the MPI man page for a full list of MPI error codes. πŸ“œ

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


2003-2026, The Open MPI Community


and that's the whole page, babe πŸŽ€ β€” MPI_CLOSE_PORT(3) from the Open MPI crew, dated Sep 10, 2026, copyright held by The Open MPI Community (2003-2026). go forth and close your ports responsibly. slay. πŸ’…βœ¨

πŸ“¦ where this page comes from