I am using the Intel MPI on a mixed C/FORTRAN program. All my communicators (MPI_Comm) are instanced in C; yet, I need to pass them through MPI calls to a FORTRAN subroutine.
How does one cast the MPI_Comm handle from C to FORTRAN?
According to, for example, https://www.mpi-forum.org/docs/mpi-2.2/mpi22-report/node361.htm, you can use
MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
I attached a complete example, dvr_parpack.cpp, that I got from the Web that solves for eigenenergies of 1D Harmonic oscillator and uses MPI_Comm_c2f. Disclaimer: I did not test this example - hopefully, it might be used as a starting point.