[petsc-users] Refactoring an MPI code to call from another mpi code

Matthew Knepley knepley at gmail.com
Sun May 6 06:20:24 CDT 2018


On Sat, May 5, 2018 at 8:51 PM, Navid Shervani-Tabar <nshervt at gmail.com>
wrote:

> Dear All,
>
> I have a question and I was advised that I might find people with related
> expertise here.
>
> I have two programs Main and Solver, each of which uses MPI for parallel
> processing. I am keeping Main as the main code and modifying Solver 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.
>
> The easiest thing to do is call MPI_Initialized() in the programs to check
whether MPI_Init() has already been called (same for MPI_Finalized()).


> I thought this must have been a common problem and there should be
> discussions on how to approach this; However, to my surprise, I couldn't
> find any related topics on common websites like stackoverflow and the
> archives of this mailing list.
>
> Thanks,
>
> Navid
>
> PS1: 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.
>
> PS3: The Main code was originally using Deal.II as solver.
>
No one answered on the Deal.II list? :)

  Matt


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180506/4e621c88/attachment.html>


More information about the petsc-users mailing list