MPI_TYPE_CREATE_F90_INTEGER(3)
π« MPI_TYPE_CREATE_F90_INTEGER β the Open MPI manual page, bestie edition π«
Okay so picture this: you're deep in mpi.h land, it's 3am, and you need an MPI integer datatype that's actually bounded the way your Fortran code expects. That's this function. Its whole job? Returns a bounded MPI integer datatype. Iconic behavior, honestly.
It lives in the Open MPI MPI_TYPE_CREATE_F90_INTEGER(3) section of the manual, and yes we're gonna walk through every single bit of it together. Grab a snack π.
β¨ SYNTAX β¨
Three flavors, because of course there are. Pick your fighter.
πΈ C Syntax
#include <mpi.h>
int MPI_Type_create_f90_integer(int r, MPI_Datatype *newtype)
π¦ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_CREATE_F90_INTEGER (R, NEWTYPE, IERROR)
INTEGER R, NEWTYPE, IERROR
π§ Fortran 2008 Syntax
USE mpi_f08
MPI_Type_create_f90_integer(r, newtype, ierror)
INTEGER, INTENT(IN) :: r
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETER
rβ the precision, in decimal digits, as an integer. Basically "how many digits do you want, bestie?"
π OUTPUT PARAMETERS
newtypeβ the new data type (a handle). Your shiny new toy πierrorβ Fortran only: the error status (integer).
π₯ DESCRIPTION
So here's the tea: this function is literally the way you declare KIND-parameterized INTEGER MPI datatypes. The argument gets interpreted kinda like the F90 function SELECTED_INT_KIND does β r has to be a scalar integer, and it represents the level of numerical precision you want, counted in decimal digits. That's it, that's the whole concept. Slay. β¨
π NOTES
It is erroneous to supply a value for r that the compiler doesn't support. Like, don't do it. Fr fr. π
The Fortran function SELECTED_INT_KIND maps a large number of r values down to a much smaller number of KIND parameters that the compiler actually supports. And here's the catch β KIND parameters are not specified by the language and they are not portable. From the language's own point of view, two variables of the same base type and the same KIND parameter are equivalent, even if those KIND parameters came from totally different r arguments to SELECTED_INT_KIND. Kind of a vibe check fail, right?
But! To help facilitate interoperability in a heterogeneous environment, equivalency is defined more strictly for datatypes returned by MPI_Type_create_f90_integer. The rule, and this is the important one: two MPI datatypes, each generated by this function, will match if and only if they have identical values for r. No cap. π
π the external32 situation
The interaction between the datatypes returned by this function and the external32 data representation β the one used by MPI_Pack_external, MPI_Unpack_external and many MPI_File functions β is subtle. Genuinely subtle. Pay attention, bestie:
if (r > 38):
external32 size = n/a (undefined)
else if (r > 18):
external32 size = 16
else if (r > 9):
external32 size = 8
else if (r > 4):
external32 size = 4
else if (r > 2):
external32 size = 2
else:
external32 size = 1
β οΈ If the external32 representation of a datatype is undefined, then the results of using that datatype in operations that require the external32 format are also undefined. Care should be taken not to use incompatible datatypes indirectly β like, as part of another datatype, or through a duplicated datatype β in these functions. This is the part where you slow down and read twice. π
And one more thing: if a variable is declared specifying a nondefault KIND value that was not obtained with SELECTED_INT_KIND (i.e. r is unknown), the only way to obtain a matching MPI datatype is to use the functions MPI_Sizeof and MPI_Type_match_size. That's the escape hatch. Remember it. π«Ά
π ERRORS
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 the last argument.
Before that error value comes back, the current MPI error handler associated with the communication object (e.g. communicator, window, file) gets called. And if there's no communication object associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and it'll 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. You can change that initial error handler 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 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.
π the three predefined error handlers
Open MPI includes three of these bad boys, ready to go:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. Dramatic, but make it real.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 ifMPI_Abortwas called on that communicator. If called on a window or file, it acts as ifMPI_Abortwas 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 chill one.
π§ roll your own
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
π Note that MPI does not guarantee that an MPI program can continue past an error. Like, no promises, bestie.
See the MPI man page for a full list of MPI error codes. And see the Error Handling section of the MPI-3.1 standard for more information. π
π SEE ALSO
MPI_Pack_externalMPI_SizeofMPI_Type_match_sizeMPI_Unpack_externalSELECTED_INT_KIND
π COPYRIGHT
2003-2026, The Open MPI Community
Sep 11, 2026 β that's the date, and the source is Open MPI, section MPI_TYPE_CREATE_F90_INTEGER(3). Ok bye bestie, go declare some KIND-parameterized integers, you absolute icon πβ¨π¦
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms