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' ./run_tests.sh
If you want to run a single test (for example, testFilename.f90
), execute:
cd tests/
FC='lfortran' ./run_tests.sh testFilename.f90
To build and run the pot3d
test, navigate to the tests/pot3d/
directory.
- For Lfortran run:
cd tests/pot3d/
FC='lfortran' ./build_and_run_lfortran.sh
- For GFortran run:
cd tests/pot3d/
FC='gfortran' ./build_and_run_gfortran.sh
You 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 -O3' ./run_tests.sh
This enables you to tailor the compilation process to your needs.