ABI: Changes to Fortran-related get/set routines - #7942
Open
dalcinl wants to merge 2 commits into
Open
Conversation
dalcinl
commented
Aug 26, 2026
dalcinl
force-pushed
the
fix-fortran-logical128
branch
3 times, most recently
from
September 1, 2026 19:05
26546f3 to
2934406
Compare
Collaborator
Author
* Implement MPI_Abi_get_fortran_booleans in the MPIR layer * Implement MPI_Abi_get_fortran_info in the MPIR layer * Support Fortran booleans of size 16 * Use MPI_ERR_ARG to signal bad logical_size * Do not expose MPIR_fortran_true/false as a visible symbol.
…essor * Allow for get/set Fortran booleans in arbitrary and thus possibly unaligned memory locations by using an intermediate value and memcpy. * Refactor repetitive code using C preprocessor macros.
dalcinl
force-pushed
the
fix-fortran-logical128
branch
from
September 1, 2026 19:13
2934406 to
859a7c9
Compare
Collaborator
hzhou
requested changes
Sep 1, 2026
| intN_t true_value = (intN_t) MPIR_fortran_true; \ | ||
| intN_t false_value = (intN_t) MPIR_fortran_false; \ | ||
| (void) memcpy(logical_true, &true_value, sizeof(intN_t)); \ | ||
| (void) memcpy(logical_false, &false_value, sizeof(intN_t)); \ |
Collaborator
There was a problem hiding this comment.
Wait. We need consider endian to use memcpy
Collaborator
Author
There was a problem hiding this comment.
What do you mean? The C compiler and the Fortran compiler would use the same endianness. The use of memcpy here preserves endianness. I'm using memcpy to avoid alignment issues, in case the user is trying to get/set the booleans from unaligned memory (e.g. members of a packed struct or something like that, or even maybe a byte array).
Am I missing something obvious?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Changes to Fortran ABI get/set routines. Some bits may be controversial. this is a middle ground of my interpretation of the standard and what Open MPI has implemented (note: not by me). Split in two commits to help review, can be squashed.
Partially addresses #7938, remove symbol visibility
MPIR_fortran_true/falsefrom the MPI libraries.Commit messages pasted below for the reviewer convenience:
bindings/c/abi: Refactor bindings generation for Fortran APIs
bindings/c/abi: Implement Fortran get/set booleans with the C preprocessor
unaligned memory locations by using an intermediate value and memcpy.
Author Checklist
Particularly focus on why, not what. Reference background, issues, test failures, xfail entries, etc.
Commits are self-contained and do not do two things at once.
Commit message is of the form:
module: short descriptionCommit message explains what's in the commit.
Whitespace checker. Warnings test. Additional tests via comments.
For non-Argonne authors, check contribution agreement.
If necessary, request an explicit comment from your companies PR approval manager.