Is it possible to send data from a Fortran program to Python using MPI?

后端 未结 4 748
不知归路
不知归路 2021-01-11 11:42

I am working on a tool to model wave energy converters, where I need to couple two software packages to each other. One program is written in Fortran, the other one in C++.

4条回答
  •  死守一世寂寞
    2021-01-11 12:13

    You certainly cannot have both source and destination 0 when both are different programs. You say "from process 0 to process 0" but you clearly have two different processes! One of them has some different rank number, but you don't show your actual mpirun command so it is hard to say which one is which.

    To clarify: the MPI_COM_WORLD is the communicator for all processes executed in your mpirun or equivalent. You must leave the simple mind picture, that the first Python process is rank 0, first Fortran process is rank 0, first C++ is rank 0...

    If you do

    mpirun -n 1 python main.py : -n 1 ./fortran_main : -n 1 ./c++_main
    

    then in MPI_COMM_WORLD the Python program will be rank 0, the Fortran process will be rank 1 and the C++ will be rank 2. You can create communicators local only to the Python subset or to the Fortran subset or the C++ one and you will have rank 0 in each of them, but that will be numbering within a different communicator, not in MPI_COMM_WORLD.

提交回复
热议问题