[petsc-users] PetscFinalize()

Barry Smith bsmith at mcs.anl.gov
Wed Oct 3 18:53:48 CDT 2012


On Oct 3, 2012, at 4:58 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> On Wed, Oct 3, 2012 at 11:58 AM, Eleni Siampli <siaeleni at hotmail.com> wrote:
> It doen't work good. I have created a dll for solving the eigenPorblem (eigenSolver.dll) and I included it in my current project.
> lets say that eigenSolver is the name of my class.. What I use is:
> eigensolver eig; 
> for a lot of iterations and works fine. I call only one the PetscInitialize();
>  
> I want also to use:
> eigensolver eig1;
> eigensolver eig2;
>  
> I call only once PetscInitialize(); for each eig1 and eig 2.
> 
> It is much better to call PetscInitialize only once, ever. There are lots of ways to set that up in your code. I would use a static variable and register a finalize routine with my main.

  But note that it is perfectly legitimate to have 

    PetscInitialize()
    PetscFinalize()
    PetscInitialize()
    PetscFinalize()
    etc etc

  in your code. Though it is  not recommended, it should work so long as YOU call MPI_Init () (if using MPI) before the first PetscInitialize() and MPI_Finalize() after the final PetscFinalize().

   Barry

Note that some of the petsc-developers still falsely believe they can only be called once.





More information about the petsc-users mailing list