MPI_INFO_GET_NTHKEY(3)

πŸ’– MPI_INFO_GET_NTHKEY πŸ’–

okay bestie, so this is a page from the Open MPI manual, and we're about to get so cozy with MPI_Info_get_nthkey. she's a little lookup gremlin β€” you hand her a number, she hands you a key. it's giving ✨index girlie✨.


🌸 NAME 🌸

MPI_Info_get_nthkey β€” Returns the nth defined key in info.

lowkey the whole personality right there. no notes. πŸ’…


✨ 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 lil info bestie. πŸ¦‹
  • n β€” the key number, an integer. it's the which one of it all.

πŸ’œ OUTPUT PARAMETERS πŸ’œ

  • key β€” the key itself, as a string. the glow-up reveal. ✨
  • ierror β€” Fortran only: error status, as an integer. she reports back fr fr.

πŸ’… DESCRIPTION πŸ’…

so MPI_Info_get_nthkey returns the nth defined key in info. that's it. that's the whole vibe.

the keys are numbered 0…N - 1, where N is whatever value MPI_Info_get_nkeys handed you. and β€” no cap β€” every single key between 0 and N - 1 is guaranteed to be defined. like, all of them. full roster. πŸ‘‘

and here's the part bestie, the key detail: the number of a given key does not change as long as info is not modified with MPI_Info_set or MPI_Info_delete. so once you clock a key's number, she stays put. 🫢


😭 ERRORS 😭

almost all MPI routines return an error value, okay? C routines give it back as the return result of the function, and Fortran routines put it in the last argument. classic.

before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. and 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. so it's not, like, orphaned β€” it's got a home. 🏠

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. and the initial error handler can be changed by:

  • calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or
  • the mpi_initial_errhandler CLI argument to mpiexec
  • 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. crumbs of structure, honestly.

also, heads up bestie: Open MPI includes three predefined error handlers that can be used:
  • MPI_ERRORS_ARE_FATAL β€” Causes the program to abort all connected MPI processes. πŸ’€ dramatic but she's honest.
  • 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. so versatile, so scary. πŸ™ˆ
  • MPI_ERRORS_RETURN β€” Returns an error code to the application. the chill 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

do it yourself, DIY queen. πŸ› οΈβœ¨

note that MPI does not guarantee that an MPI program can continue past an error. so like… that's a real caveat, not a vibe. 🫠

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


and that's the whole page, bestie!! πŸŽ€ this was written for Open MPI, and the page source says Sep 10, 2026 β€” so go forth, grab that nth key, and slay. MPI_INFO_GET_NTHKEY(3), out. πŸ’–πŸ¦‹β­

πŸ“¦ where this page comes from