No, you can only call them once for the entire program.<br><br> Matt<br><br><div class="gmail_quote">On Thu, Apr 30, 2009 at 1:25 AM, #DOMINIC DENVER JOHN CHANDAR# <span dir="ltr"><<a href="mailto:DOMI0002@ntu.edu.sg">DOMI0002@ntu.edu.sg</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div><span><font size="2" face="Arial">Hi,</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial"> I have a C++ code in
which I plan to call PETSc for solving a system of equations. My doubt is
regarding PETScInitialize() and PETScFinalize().</font></span></div>
<div><span><font size="2" face="Arial">For example, I have
a class called classX</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">classX</font></span></div>
<div><span><font size="2" face="Arial">{</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">public:</font></span></div>
<div><span><font size="2" face="Arial">initialize();</font></span></div>
<div><span><font size="2" face="Arial">finalize();</font></span></div>
<div><span></span><span><font size="2" face="Arial">};</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">classX::initialize()</font></span></div>
<div><span><font size="2" face="Arial">{</font></span></div>
<div><span><font size="2" face="Arial">PetscInitialize(...)</font></span></div>
<div><span><font size="2" face="Arial">..</font></span></div>
<div><span><font size="2" face="Arial">..</font></span></div>
<div><span><font size="2" face="Arial">more
initializations..</font></span></div>
<div><span><font size="2" face="Arial">}</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">classX::finalize()</font></span></div>
<div><span><font size="2" face="Arial">{</font></span></div>
<div><span><font size="2" face="Arial">PetscFinalize();</font></span></div>
<div><span><font size="2" face="Arial">...</font></span></div>
<div><span><font size="2" face="Arial">...
</font></span></div>
<div><span><font size="2" face="Arial">}</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">main()</font></span></div>
<div><span><font size="2" face="Arial">{</font></span></div>
<div><span><font size="2" face="Arial">
classX ob1, ob2 ; // 2 objects</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">
// Is the following acceptable ??</font></span></div>
<div><span><font size="2" face="Arial">ob1.initialize();</font></span></div>
<div><span><font size="2" face="Arial">ob2.initialize();</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">}</font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div>
<div><span><font size="2" face="Arial">Do I need to call
PetscInitialize() /PetscFinalize() for each object ? </font></span></div>
<div><span><font size="2" face="Arial"></font></span> </div><font color="#888888">
<div><span><font size="2" face="Arial">-Dominic</font></span></div></font></div>
</blockquote></div><br><br clear="all"><br>-- <br>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<br>