Welcome to the Custom MPI Wrapper project! This repository contains a Fortran-based implementation of MPI wrappers that bind directly to native MPI library routines using ISO_C_BINDING. The goal is to eliminate intermediate C wrappers and call MPI functions directly from Fortran.
This project currently supports MPI routines such as MPI_Init, MPI_Bcast, MPI_Reduce, MPI_Comm_split_type, MPI_Recv, MPI_Ssend, MPI_Waitall, and more. In addition, the repository provides several tests to verify the correctness of these custom wrappers.
-
Fortran Compiler:
You can use LFortran, gfortran, or any standard Fortran compiler. -
MPI Library:
This project supports OpenMPI and MPICH. Install the desired MPI library along with its development headers. -
Pixi (Optional):
pixi provides an environment<compiler>-<mpi>for each compiler (gfortran,lfortran, and on Linux alsoflangandifx) and MPI (openmpi,mpich), the same ones the CI uses. The compiler is passed to the task:pixi run -e lfortran-mpich test 'lfortran --cpp' pixi run -e gfortran-openmpi test 'gfortran -cpp -O3 -march=native' pixi run -e gfortran-openmpi test-without-wrappers pixi run -e flang-mpich test 'flang -cpp' pixi run -e gfortran-mpich pot3d 'gfortran -cpp' pixi run -e lfortran-openmpi pot3d-lfortran 'lfortran --cpp'
With Open MPI, pixi also passes
-DOPEN_MPI=yesto the compiler. POT3D with flang or ifx needs a larger stack,ulimit -s unlimited.
The repository contains a collection of standalone tests located in the tests/ directory. These tests validate the functionality of the custom MPI wrappers.
To execute all standalone tests, navigate to the tests/ directory and run:
cd tests/
FC='lfortran --cpp' ./run_tests.shor, to run them with GFortran compiler, do:
cd tests/
FC='gfortran -cpp' ./run_tests.shIf you want to run a single test (for example, test_filename.f90), execute:
cd tests/
FC='lfortran --cpp' ./run_tests.sh test_filename.f90or, to run it with GFortran compiler, do:
cd tests/
FC='gfortran -cpp' ./run_tests.sh test_filename.f90To build and run the pot3d test, navigate to the tests/pot3d/ directory.
- For LFortran run:
cd tests/pot3d/
FC='lfortran --cpp' ./build_and_run_lfortran.sh- For GFortran run:
cd tests/pot3d/
FC='gfortran -cpp' ./build_and_run_gfortran.shYou can pass custom flags to your Fortran compiler using the FC environment variable. For example, to compile with optimization flags using gfortran, run:
FC='gfortran -cpp -O3' ./run_tests.shThis enables you to tailor the compilation process to your needs.