<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Oct 31, 2018 at 1:34 PM Guido Giuntoli via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi, I have two codes that use PETSc. The first one is parallel and uses MPI and the other doesn't uses MPI (uses sequencial Mats and Vecs because the problem is smaller). I need now to couple both codes and my question is how do I deal with the PetscInitialize in the sequential code ? I know that PetscInitialize calls MPI_Init so I think if the first code just called MPI_Init before I will get an error or not ? Every process in the parallel code needs to use the functions of the sequential code, so every process will call PetscInitialize of the sequential code.<br><br></div>constrain : I would like to use the same compiled library of petsc to link both codes.<br></div></div></blockquote><div><br></div><div>You should only call PetscInitialize() once (just like MPIInit()). You can check whether it has been called using PetscInitialized().</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div>Thank you, Guido.<br></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>