Refactoring an MPI code to call from another MPI code RRS feed

  • Question

  • Dear All,

    I have two programs Main and Aux, each of which uses MPI for parallel processing. I am keeping Main as the main code and modifying Aux as a subroutine which is being called by Main.

    The problem arises when both codes initiate the MPI (since both were originally standalone programs) and then each have their own parallel structure, which leads the code to crash as MPI_init can only be called once in the now combined program.

    I thought this must have been a common problem and there should be discussions on how to approach connecting two standalone program with their own individual parallel computing structure; However, to my surprise, I couldn't find any related topics on common websites like stackoverflow and here. 



    PS: When connecting the two codes, I decided to call Aux by Main rather than running the Aux as executable by Main to have a more optimized and robust setting and also avoid the overhead.

    PS2: Code Main is written in c++ and code Aux is written in Fortran.

    Sunday, May 6, 2018 12:31 AM