MPI_INFO_GET_NKEYS(3)

πŸ’– MPI_INFO_GET_NKEYS(3) β€” Open MPI, bestie edition πŸ’–

okay so you're in section 3 of the Open MPI manual, which means we're talking library calls, and today's main character is MPI_Info_get_nkeys. she counts keys. that's her whole thing and she ate.

✨ NAME ✨

MPI_Info_get_nkeys β€” gets the number of keys currently defined in an info object.

like. she tells you how many keys are in your info object. that's it. that's the gig. πŸŽ€


🌸 SYNTAX 🌸

C Syntax

#include <mpi.h>

int MPI_Info_get_nkeys(MPI_Info info, int *nkeys)

Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_INFO_GET_NKEYS(INFO, NKEYS, IERROR)
     INTEGER         INFO, NKEYS, IERROR

Fortran 2008 Syntax

USE mpi_f08
MPI_Info_get_nkeys(info, nkeys, ierror)
     TYPE(MPI_Info), INTENT(IN) :: info
     INTEGER, INTENT(OUT) :: nkeys
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🫢 INPUT PARAMETER 🫢

  • info β€” the Info object, as a handle. bestie, that's the thing you're inspecting. πŸ‘‘

πŸ’… OUTPUT PARAMETERS πŸ’…

  • nkeys β€” number of defined keys, an integer. literally the whole point of this function. πŸ”₯
  • ierror β€” Fortran only: error status, an integer. πŸ‡«

🌈 DESCRIPTION 🌈

MPI_Info_get_nkeys returns the number of currently defined keys in info.

that's it. no cap. she counts, she returns, she leaves. icon behavior. ✨


😭 ERRORS 😭

okay this part is long but it's important so we're doing it properly, no skipping. πŸ™ˆ

Almost all MPI routines return an error value β€” C routines hand it back as the return result of the function, and Fortran routines put it in that last argument. classic.

Before that error value gets returned, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. And if there's no communication object attached to the MPI call? Then the call is considered attached to MPI_COMM_SELF and it calls the error handler associated with that. πŸ’€

And when MPI_COMM_SELF isn't initialized β€” meaning before MPI_Init/MPI_Init_thread, or after MPI_Finalize, or when you're using the Sessions Model exclusively β€” the error raises the initial error handler instead. You can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're 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. And if literally no other appropriate error handler has been set? Then MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all other MPI functions. 🀯

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everybody. gone. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. When it's called on a communicator, it acts as if MPI_Abort was called on that communicator. 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. Called on a session? It aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. chill. polite. hands you the receipt. 🧾

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 keep vibing after an error. 😭

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.

See also:

  • MPI_Info_get
  • MPI_Info_get_nthkey
  • MPI_Info_get_valuelen

2003-2026, The Open MPI Community


and that's the whole page, bestie!! πŸ¦‹ this was the MPI_INFO_GET_NKEYS(3) page from Open MPI, dated Sep 10, 2026 β€” mwah, slay, go count some keys πŸ’…βœ¨πŸ“

πŸ“¦ where this page comes from