ecmwf / fckit

A Fortran toolkit for interoperating Fortran with C/C++
https://confluence.ecmwf.int/display/fckit
Apache License 2.0
29 stars 13 forks source link

Support for mpi_f08 #32

Closed climbfuji closed 4 months ago

climbfuji commented 5 months ago

Is your feature request related to a problem? Please describe.

At JCSDA, we are seeing that our partners developing the Unified Forecast System (NOAA; UFS), NEPTUNE (NAVY), and others are moving away from the MPI F90 implementation to the MPI F08 implementation. As far as I understand, fckit doesn't support that yet. Interfaces that convert the old MPI communicator used in fckit (an integer) to the new MPI communicator (type(MPI_comm)) need to be put in place.

Is there are plan to move away from the old MPI F90 implementation, or to support both in fckit?

Describe the solution you'd like

The MPI F08 implementation has many advantages, one being that it provides interfaces for all Fortran/MPI data types. This means one can compile MPI codes with gfortran-10+ without having to add -fallow-argument-mismatch, which can cover up real argument mismatches that one would like to detect.

Describe alternatives you've considered

No response

Additional context

No response

Organisation

JCSDA

wdeconinck commented 4 months ago

Hello @climbfuji , in fact fckit does not use any Fortran MPI interface. It is using the MPI C library via eckit, and creates wrappers around it.

However, there is indeed a mechanism to interoperate with Fortran MPI calls via the (older) Fortran integer as a handle. Internally in eckit this would then use functions MPI_Comm_c2f and MPI_Comm_f2c.

In Fortran you could jump between mpi_f08 type(MPI_Comm) :: comm and mpi INTEGER :: comm as follows:

type(MPI_Comm) :: mpi_f08_comm
integer :: comm

mpi_f08_comm%mpi_val = comm

or vice versa:

type(MPI_Comm) :: mpi_f08_comm
integer :: comm

comm = mpi_f08_comm%mpi_val

In summary there is no need to change anything in fckit as it does not expose any Fortran MPI types or routines directly.

climbfuji commented 4 months ago

Thanks for the insight @wdeconinck. I'll close this issue since there's no need to change anything.