<p dir="ltr">I would use the same flag, just error earlier so that the trace is more useful. We know that the NaN won't turn into something useful after it is computed.</p>
<div class="gmail_quote">On Feb 22, 2013 9:08 PM, "Barry Smith" <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Feb 22, 2013, at 8:40 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
<br>
><br>
> On Fri, Feb 22, 2013 at 6:19 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> Ok, I did a search through the code to see where we are checking it.<br>
><br>
> 1) VecNorm, VecDot, VecMDot -- and generate an error<br>
><br>
> Yeah, I never liked this.<br>
><br>
><br>
> 2) Many of the Krylov solvers and nonlinear solvers check the results of (most - should be all) norms and dots and either<br>
><br>
> a) generate a not converged KSP or SNES converged reason (good)<br>
><br>
> b) generate an error (bad, most do this).<br>
><br>
> We want the solvers to have an option to raise an error because it helps users track down where they made a mistake (especially if they're running in a shitty environment where -fp_trap and gdb doesn't work nicely). I'm not sure which should be the default.<br>
<br>
Currently KSPSetErrorIfNotConverged() will trigger an error at the end of the KSPSolve() routine if not converged (including NaN). If this is not close enough to the problem for you we could use the same flag to stop the code with a SETERRQ() as soon as the norm, dot, mdot problem is detected? Or we could add yet another flag?<br>
<br>
Barry<br>
<br>
<br>
><br>
><br>
> Note that currently the checks in the solvers are redundant because an error was already generated in the VecNorm, Dot or MDot so NaN never<br>
> gets to the iterative solver<br>
><br>
> 3) Few other irrelevant places.<br>
><br>
> The simplest thing would be to simply remove the checks in 1). Then, eventually, update all the solvers to NOT generate an error but instead return with<br>
> an appropriate diverged reason. The drawback is that other code using dots and norms will always chug along without generating an error if users don't<br>
> check the results themselves.<br>
><br>
> I think this is an event that the caller should deal with since only they have enough context to return cleanly. Yes, it's more code, but it's the right thing.<br>
><br>
> I vote we just make a patch in 3.3 to remove the checks in norm, dot, mdot and Jed adds another project to the bitbucket list saying upgrade the checks in the solvers to return with appropriate diverged reason instead of generating an error. Then the whole flag business goes away.<br>
><br>
> That's fine with me.<br>
<br>
</blockquote></div>