<div dir="ltr"><div dir="ltr">On Mon, Feb 27, 2023 at 8:41 AM Long, Jianbo <<a href="mailto:jl7037@mun.ca">jl7037@mun.ca</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:large">Thanks for the explanations ! It turns out the issue of running sequentially compiled petsc is PetscFinalize() function. Since my subroutine involving petsc functions needs to be called multiple times in the program, I have to comment out PetscFinalize() at the end of the subroutine, otherwise at the next call of this subroutine, petsc would stop and throw out an error about MPI_Comm_set_errhandler !</div></div></blockquote><div><br></div><div>Yes, you are supposed to call PetscInitialize() _once_ at the beginning of the program, and PetscFinalize() _once_ at the end of the program.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:large">Jianbo<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 26, 2023 at 4:39 PM Satish Balay <<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, 26 Feb 2023, Pierre Jolivet wrote:<br>
<br>
> <br>
> <br>
> > On 25 Feb 2023, at 11:44 PM, Long, Jianbo <<a href="mailto:jl7037@mun.ca" target="_blank">jl7037@mun.ca</a>> wrote:<br>
> > <br>
> > Hello,<br>
> > <br>
> > For some of my applications, I need to use petsc without mpi, or use it sequentially. I wonder where I can find examples/tutorials for this ?<br>
> <br>
> You can run sequentially with just a single MPI process (-n 1).<br>
<br>
even if you build with mpich/openmpi - you can run sequentially without mpiexec - i.e:<br>
<br>
./binary<br>
<br>
One reason to do this [instead of building PETSc with --with-mpi=0] - is if you are mixing in multiple pkgs that have MPI dependencies [in which case - its best to build all these pkgs with the same mpich or openmpi - but still run sequentially].<br>
<br>
Satish<br>
<br>
> If you need to run without MPI whatsoever, you’ll need to have a separate PETSc installation which was configured --with-mpi=0<br>
> In both cases, the same user-code will run, i.e., all PETSc examples available with the sources will work (though some are designed purely for parallel experiments and may error out early on purpose).<br>
> <br>
> Thanks,<br>
> Pierre<br>
> <br>
> > Thanks very much,<br>
> > Jianbo Long<br>
> <br>
> <br>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="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>