I would like to try compiling an existing fairly large MPI-based scientific Fortran code with LFortran. The code currently uses use mpi with standard point-to-point and collective operations.
What is the recommended way to use MPI with LFortran today?
I found lfortran/fortran_mpi and the earlier POT3D example. Is fortran_mpi still the recommended approach, and is it sufficiently complete to serve as a mostly drop-in replacement for use mpi in an existing code?
Alternatively, is it now possible/recommended to use LFortran directly with an existing OpenMPI installation, or to build OpenMPI itself with LFortran?
You need to build a version of MPI such as MPICH or Open MPI and tell it to use LFortran to build the Fortran interfaces and modules . I think a gfortran module might also work so if you have access to a prebuilt version that uses gfortran to build the mpi and mpi_08 modules. I’ll let @certik correct me if I’m wrong.
So lfortran/fortran_mpi should work and we can easily fix it for any bugs that you might discover. I think that’s the cleanest way to call MPI from Fortran, as it creates very thin wrappers and calls the C MPI directly, so you install whatever C MPI you want, and then just compile your Fortran code with lfortran/fortran_mpi and things should just work.
If you do not want this approach, then we can also work on getting LFortran working with mpich and openmpi directly, which I think we have all the features in LFortran to support that, so we just need to try it and fix any bugs that we discover (I think we haven’t tried it yet).
@rsci if your code is open source, I can have a look and fix all bugs. If it is not, then simply report all bugs into our issue tracker: Issues · lfortran/lfortran · GitHub and ping me and we’ll take care of it. If your project is large, almost for sure you’ll discover some bugs, so just report them and we’ll fix them.