MPI_CART_GET(3)

πŸ’… MPI_CART_GET(3) β€” the Open MPI one ✨

okay bestie, so this page is literally about MPI_Cart_get from Open MPI, and no cap, it's the glow-up you need when you've got a Cartesian topology and you're like "wait, what even is my grid??" πŸŽ€


🌸 NAME 🌸

MPI_Cart_get β€” retrieves Cartesian topology information associated with a communicator. literally it hands you back the receipts of the grid you built πŸ’–


✨ SYNTAX ✨

πŸ¦‹ C Syntax

#include <mpi.h>

int MPI_Cart_get(MPI_Comm comm, int maxdims, int dims[], int periods[],
    int coords[])

πŸ¦‹ Fortran Syntax

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

MPI_CART_GET(COMM, MAXDIMS, DIMS, PERIODS, COORDS, IERROR)
    INTEGER COMM, MAXDIMS, DIMS(*), COORDS(*), IERROR
    LOGICAL PERIODS(*)

πŸ¦‹ Fortran 2008 Syntax

USE mpi_f08

MPI_Cart_get(comm, maxdims, dims, periods, coords, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    INTEGER, INTENT(IN) :: maxdims
    INTEGER, INTENT(OUT) :: dims(maxdims), coords(maxdims)
    LOGICAL, INTENT(OUT) :: periods(maxdims)
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ’œ INPUT PARAMETERS πŸ’œ

  • comm β€” the communicator with Cartesian structure, a.k.a. the handle. this is the one that's already got the grid vibe going on 🫢
  • maxdims β€” length of the vectors dims, periods, and coords in the calling program. integer energy. don't let it be too smol bestie 😭

🩷 OUTPUT PARAMETERS 🩷

  • dims β€” number of processes for each Cartesian dimension. array of integers, iconic little census of your grid πŸ‘‘
  • periods β€” periodicity (true/false) for each Cartesian dimension. array of logicals, so yes/no vibes per dim πŸ’€
  • coords β€” coordinates of the calling process in the Cartesian structure. array of integers. this is literally your address in the grid πŸ—ΊοΈ
  • ierror β€” Fortran only: error status (integer). the "how did it go" lil note πŸ’Œ

🌈 DESCRIPTION 🌈

the functions MPI_Cartdim_get and MPI_Cart_get return the Cartesian topology information that was associated with a communicator by MPI_Cart_create. so like… you made the grid with MPI_Cart_create, and this is the friend who remembers what the grid actually looks like. no cap, super useful ✨


πŸ”₯ ERRORS πŸ”₯

okay so almost all MPI routines return an error value: C routines as the return result of the function, and Fortran routines in the last argument. iykyk πŸ’…

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_thread, after 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 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_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. fr fr, that's the whole chain 🫠

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? yes. effective? also yes πŸ’€
  • 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, 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, aborts only the local process. it's giving "we're ending this, but exactly how much is context-dependent" 😭
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one, it just hands you the note and lets you deal πŸŽ€

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. that's not me being dramatic, that's literally the spec bestie πŸ™ˆ

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_Cartdim_get β€” the other half of this little duo, go read it too 🧚

2003–2026, The Open MPI Community. protect the copyright bestie πŸ’œ


and that's the whole page, mwah πŸ’‹ β€” signed off with love from Open MPI, dated Sep 11, 2026. slay, go build your grid 🌟

πŸ“¦ where this page comes from