[petsc-users] Two applications with PETSc

Matthew Knepley knepley at gmail.com
Wed Oct 31 13:53:35 CDT 2018


On Wed, Oct 31, 2018 at 1:34 PM Guido Giuntoli via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> 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.
>
> constrain : I would like to use the same compiled library of petsc to link
> both codes.
>

You should only call PetscInitialize() once (just like MPIInit()). You can
check whether it has been called using PetscInitialized().

  Thanks,

    Matt


> Thank you, Guido.
>


-- 
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.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181031/61663614/attachment.html>


More information about the petsc-users mailing list