Intel® MPI Library
Get help with building, analyzing, optimizing, and scaling high-performance computing (HPC) applications.

MPI in mixed C and FORTRAN

Gordon_F_
Beginner
1,384 Views

Hello,

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?

Thanks.

0 Kudos
2 Replies
Mark_L_Intel
Moderator
1,384 Views

Hello,

   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. 

Regards,

Mark

 

 

 

 

0 Kudos
Gordon_F_
Beginner
1,384 Views

Mark,

Perfect! That's exactly what I needed to know. Thanks.

0 Kudos
Reply