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. -
Conda Environment (Optional):
It is recommended to create separate conda environments for MPICH and OpenMPI:- For MPICH:
conda create -n mpich_env mpich=4.3.0 conda activate mpich_env
- For OpenMPI:
conda create -n openmpi_env openmpi=5.0.6 conda activate openmpi_env
- For MPICH:
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.