<div dir="ltr">Hi Barry,<br><br><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
</span> Likely Matt had a few more beers between writing the first one and the second one.<br></blockquote><div><br></div><div>Heh - thanks for providing the patch to make both functions behave in the same manner.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
><br>
> My use case is that within one of my custom preconditioners, I wanted<br>
> to call PetscLogStageRegister() during the creation phase, but obviously<br>
> I can only register the stage once. To enable multiple instances of the<br>
> preconditioner to exist, I need to ensure that the stage is only registered once.<br>
> Hence I would like to check for the existence of the stage prior to calling<br>
> the register function.<br>
><br>
> Is there currently a way to check for the existence of a registered stage?<br>
<br>
</span> No, we don't recommend doing it this way. The way we do it in PETSc is to have a static global variable that contains the stage ID and simply check the value of that id to determine if it has been set (set it to -1 at compile time) so your test can then just be that it is not -1. The stage register stuff goes through string comparisons so it should not be called a bunch of times.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Okay, thanks for the advice on how best to do this.<br>I did notice that typical usage in petsc was via a static global variable, <br>but as a general rule, I try to not introduce global variables into my code base.<br><br></div><div>Is the string comparison for an event/stage name really that bad a thing to do? <br>I mean, can it be worse than processing the enormous list of command line arguments <br>every time XXXSetFromOptions() is called?<br></div><div><br></div><br><div>Cheers,<br></div><div> Dave<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
Barry<br>
</font></span><br><br>
><br>
><br>
> Cheers<br>
> Dave<br>
><br>
><br>
<br>
<br></blockquote></div><br></div></div>