<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> The code will not work as written because KSPConvergedDefault() requires a context created with KSPConvergedDefaultCreate(). <div><br></div><div> Here is a starting point for what you need, in main</div><div><br></div><div> integer*8 defaultctx</div><div> extern MyKSPConverged, KSPConvergedDefaultDestroy</div><div><br></div><div>KSPDefaultConvergedCreate(defaultctx,ierr)</div><div><pre width="80"><a href="https://petsc.org/main/manualpages/KSP/KSPSetConvergenceTest/">KSPSetConvergenceTest</a>(ksp,MyKSPConverged,defaultctx,KSPConvergedDefaultDestroy, ierr)</pre><pre width="80"><br></pre></div><div><br></div><div><i style="caret-color: rgb(34, 34, 34); color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif;">subroutine MyKSPConverged(ksp,n,rnorm,flag,defaultctx,ierr)<br><br> KSP ksp<br> PetscErrorCode ierr<br> PetscInt n</i></div><div><i style="caret-color: rgb(34, 34, 34); color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif;"> integer*8 defaultctx<br> KSPConvergedReason flag<br> PetscReal rnorm<br><br> if (n>1) then<br> call KSPConvergedDefault(ksp, n, rnorm, flag,defaultctx, ierr)<br> else<br> flag = 0<br> endif<br> ierr = 0<br><br> end subroutine MyKSPConverged</i></div><div><font color="#222222" face="Arial, Helvetica, sans-serif"><span style="caret-color: rgb(34, 34, 34);"><i><br></i></span></font></div><div><font color="#222222" face="Arial, Helvetica, sans-serif"><span style="caret-color: rgb(34, 34, 34);"><i><br></i></span></font><div><br><blockquote type="cite"><div>On May 7, 2023, at 10:09 AM, Matthew Knepley <knepley@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr">On Sun, May 7, 2023 at 10:02 AM Edoardo alinovi <<a href="mailto:edoardo.alinovi@gmail.com">edoardo.alinovi@gmail.com</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">Thanks, <div><br></div><div>Is this a reasonable thing to do if I want to replicate what KSP is doing by default?</div></div>
</blockquote></div><br clear="all"><div>Yes. The other option is to pass along 'dummy'</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div><br></div><span class="gmail_signature_prefix">-- </span><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>
</div></blockquote></div><br></div></body></html>