MPI_INFO_GET_NTHKEY(3)

πŸ’… MPI_INFO_GET_NTHKEY(3) β€” Open MPI, bestie edition πŸŽ€

okay so this is a page from Open MPI (yes, the MPI_INFO_GET_NTHKEY(3) one, you found it, slay) and it's genuinely so simple it's almost cute. It returns the nth defined key in an info object. That's the whole vibe. Let's get into it ✨


🌸 SYNTAX 🌸

πŸ’» C Syntax

#include <mpi.h>

int MPI_Info_get_nthkey(MPI_Info info, int n, char *key)

🧚 Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_INFO_GET_NTHKEY(INFO, N, KEY, IERROR)
     INTEGER         INFO, N, IERROR
     CHARACTER*(*)   KEY

πŸ¦‹ Fortran 2008 Syntax

USE mpi_f08
MPI_Info_get_nthkey(info, n, key, ierror)
     TYPE(MPI_Info), INTENT(IN) :: info
     INTEGER, INTENT(IN) :: n
     CHARACTER(LEN=*), INTENT(OUT) :: key
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ’– INPUT PARAMETERS πŸ’–

  • info β€” the Info object, aka the handle. Your little bag of key/value gossip πŸ‘œ
  • n β€” the key number, an integer. Which one you want, bestie ✨

🫢 OUTPUT PARAMETERS 🫢

  • key β€” the key itself, as a string. There she is πŸ’…
  • ierror β€” Fortran only: the error status, an integer 😌

πŸ‘‘ DESCRIPTION πŸ‘‘

So MPI_Info_get_nthkey returns the nth defined key in info, bestie. The keys are numbered 0…N - 1, where N is whatever MPI_Info_get_nkeys handed you. Every key between 0 and N - 1 is guaranteed to be defined β€” no cap, that's a promise 🫢.

And the number of a given key does not change as long as info isn't modified with MPI_Info_set or MPI_Info_delete. So like, once you know a key's number, it stays put. iconic behaviour honestly πŸ”₯


πŸ’€ ERRORS πŸ’€

Almost all MPI routines return an error value, just so you know: C routines give it back as the return result of the function, and Fortran routines put it in the last argument. classic 😌

Before that error value is returned, the current MPI error handler associated with the communication object (think communicator, window, file) gets called. And if no communication object is associated with the MPI call, then the call counts as attached to MPI_COMM_SELF and will call its associated MPI error handler. When MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively) the error raises the initial error handler. That initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or by the mpi_initial_errhandler CLI argument to mpiexec, or by the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. And 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. yes that's a lot, no I'm not skipping it πŸ’…

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic much πŸ’€
  • 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. the polite one πŸŽ€

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, it might just be over. fr fr.

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_nkeys
  • MPI_Info_get_valuelen

2003-2026, The Open MPI Community β€” protect them at all costs πŸ‘‘


aaaand that's the page, bestie πŸŽ€ it's dated Sep 11, 2026, it comes from Open MPI, and it lives under the name MPI_INFO_GET_NTHKEY(3) in the manual β€” go forth and get that nth key πŸ’œβœ¨πŸŒΈ

πŸ“¦ where this page comes from