Repository navigation
Fortran interface: modules kahip and parhip - #186
Merged
Merged
Conversation
Adds the Fortran modules kahip (all routines of kaHIP_interface.h) and parhip (ParHIPPartitionKWay), built with -DBUILDFORTRAN=On. The modules bind directly to the C interface via iso_c_binding; two small C helpers copy the node separator into a caller array (the library allocates it with new[]) and convert the Fortran MPI communicator handle. Node and edge weights are optional arguments. kahip_idx follows 64BITMODE. Examples in misc/example_library_call/fortran call every routine and check the results; they run as ctest tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The example now gathers the whole partition, checks that the reported edge cut matches the recomputed one and that every block is used, and runs a second partition with edge weight 2 (cut must double). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 21, 2026
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.
Makes KaHIP and ParHIP usable from Fortran.
interface/fortran/kahip.F90: modulekahipwithbind(C)interfaces for every routine ofkaHIP_interface.h(kaffpa, kaffpa_balance, kaffpa_connected_blocks, kaffpa_balance_NE, process_mapping, node_separator, reduced_nd, edge_partitioning, kahip_sizeof_idx).kahip_idxfollows64BITMODE; node and edge weights are optional arguments; constants are prefixed (KAHIP_ECO, ...).parallel/parallel_src/interface/fortran/parhip.F90: moduleparhipwithparhip_partition_kway; the Fortran communicator handle is converted withMPI_Comm_f2c.node_separatorcopies the separator into a caller array (the library allocates it withnew[], which Fortran cannot free), and the communicator conversion for ParHIP.-DBUILDFORTRAN=Onbuilds and installslibkahip_fortran.a,libparhip_fortran.a,kahip.mod,parhip.mod.misc/example_library_call/fortrancall every routine and check the results (partition validity, reported cut vs. recomputed cut, perfect balance, connected blocks, separator disconnects the graph, ordering is a permutation). They run asctesttests.Tested locally with gfortran 8.3 and OpenMPI 5.0.11: 32 and 64 bit, ctest (both tests), install, and linking by hand with gfortran/mpifort against the installed prefix exactly as in the README. The ParHIP example passes with 1 to 4 processes; it checks that the reported edge cut equals the recomputed one (unweighted and with edge weight 2) and that every block is used. A CI workflow for the Fortran interface follows once the push token has the workflow scope.
🤖 Generated with Claude Code