<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo;
        panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.gmailsignatureprefix
        {mso-style-name:gmailsignatureprefix;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word;overflow-wrap: break-word;-webkit-nbsp-mode: space;line-break:after-white-space">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Barry,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks for your reply.  Yes, for
</span><span style="font-size:11.0pt">SNESNGMRES, I use N(x) – x as the residuals, with basic line search. This converges in half the “iterations” as the original CFD solver, but each SNESNGMRES iteration requires two residual calls, so ends up converging in
 almost exactly the same amount of time as the CFD solver alone.  <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I will try the </span><span style="font-size:11.0pt">SNESSetNPC/SNESNRICHARSON/SNESSHELL combination for the “bare CFD” version.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks for your helpful comments and reply.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Kenneth</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Barry Smith <bsmith@petsc.dev><br>
<b>Date: </b>Wednesday, May 31, 2023 at 5:50 PM<br>
<b>To: </b>Kenneth C Hall <kenneth.c.hall@duke.edu><br>
<b>Cc: </b>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject: </b>Re: [petsc-users] Using SNESSHELL as a wrapper for a CFD solver.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt">  Sorry, I wrote to quickly in my last email. You will need to create a SNESSHELL its solve simply calls your solver (for its one iteration) SNESNRICHARSON handles the rest.<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On May 31, 2023, at 4:16 PM, Kenneth C Hall <kenneth.c.hall@duke.edu> wrote:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Matt,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks for your quick reply.  I think what you say makes sense.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">You asked what my code does. The MySolver program performs one iteration of a CFD iteration. The CFD scheme is an explicit scheme that uses multigrid, Mach number preconditioning, and residual smoothing. 
 Typically, I have to call MySolver on the order of 40 to 100 times to get acceptable convergence. </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">And in fact, I have another version of this Petsc code that uses SNESNGMRES to solve the problem with MySolver providing the residuals as R =  N(x) - x.  But I would like a version where I am using just MySolver,
 without any other operations applied to it.  So I am trying to plug MySolver into the PETSc system to provide monitoring and other features, and for consistency and comparison to these other (more appropriate!) uses of PETSc.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Kenneth</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div style="border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;border-color:currentcolor currentcolor;border-image: none">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt">From:<span class="apple-converted-space"> </span></span></b><span style="font-size:12.0pt">Matthew Knepley <</span><a href="mailto:knepley@gmail.com"><span style="font-size:12.0pt">knepley@gmail.com</span></a><span style="font-size:12.0pt">><br>
<b>Date:<span class="apple-converted-space"> </span></b>Wednesday, May 31, 2023 at 3:48 PM<br>
<b>To:<span class="apple-converted-space"> </span></b>Kenneth C Hall <</span><a href="mailto:kenneth.c.hall@duke.edu"><span style="font-size:12.0pt">kenneth.c.hall@duke.edu</span></a><span style="font-size:12.0pt">><br>
<b>Cc:<span class="apple-converted-space"> </span></b></span><a href="mailto:petsc-users@mcs.anl.gov"><span style="font-size:12.0pt">petsc-users@mcs.anl.gov</span></a><span class="apple-converted-space"><span style="font-size:12.0pt"> </span></span><span style="font-size:12.0pt"><</span><a href="mailto:petsc-users@mcs.anl.gov"><span style="font-size:12.0pt">petsc-users@mcs.anl.gov</span></a><span style="font-size:12.0pt">><br>
<b>Subject:<span class="apple-converted-space"> </span></b>Re: [petsc-users] Using SNESSHELL as a wrapper for a CFD solver.</span><o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On Wed, May 31, 2023 at 3:21 PM Kenneth C Hall <</span><a href="mailto:kenneth.c.hall@duke.edu" target="_blank"><span style="font-size:11.0pt">kenneth.c.hall@duke.edu</span></a><span style="font-size:11.0pt">>
 wrote:</span><o:p></o:p></p>
</div>
</div>
<div>
<blockquote style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-color:currentcolor currentcolor currentcolor rgb(204, 204, 204);border-image: none">
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I am doing a number of problems using PETSc/SLEPc, but I also work on some non-PETSc/SLEPc flow solvers.   I would like to use PETSc as a wrapper for this non-PETSc flow solver for compatibility,  so I can
 use the tolerance monitoring, options, viewers, and for direct comparison to PETSc methods I am using.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Here is what I am trying to do… I have a CFD solver that iterates with a nonlinear iterator of the form x := N(x).  This can be expressed in a fortran routine of the form,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">SUBROUTINE MySolver(x)<span class="apple-converted-space"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">or<span class="apple-converted-space"> </span></span></p>
</div>
<div>
<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">SUBROUTINE MySolver(x,y)</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">In the first case, x is over written. In the second, y = N(x).  In any event, I want to do something like what is shown in the subroutine at the bottom of this email.<span class="apple-converted-space"> </span></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">The code below “works” in the sense that MySolver is called, but it is called exactly *<b>once</b>*. But MyMonitor and MyConverged are *<b>not</b>* called. Again, I want to iterate so MySolver should be called
 many times, as should MyMonitor and MyConverged.</span></p>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">The SNESolve() method is called once per nonlinear solve, just as KSPSolve() is called once per linear solve. There may be iteration inside the method, but that is handled inside the particular implementation.
 For example, both Newton's method and Nonlinear Conjugate Gradient iterate, but the iteration is internal to both, and they both call the monitor and convergence test at each internal iterate.</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">So, if your nonlinear solver should iterate, it should happen inside the SNESSolve call for the SNESSHELL object. Does this make sense? What does your solver do?</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">  Thanks,</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">     Matt</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
</div>
<blockquote style="border:none;border-left:solid windowtext 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-color:currentcolor currentcolor currentcolor rgb(204, 204, 204);border-image: none">
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">The SNESView before and after SNESSolve looks like this:</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">SNES Object: 1 MPI process</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  type: shell</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  SNES has not been set up so information may be incomplete</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  maximum iterations=50, maximum function evaluations=10000</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  tolerances: relative=1e-50, absolute=1e-10, solution=1e+06</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  total number of function evaluations=0</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  norm schedule ALWAYS</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div style="margin-left:.5in">
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">SNES Object: 1 MPI process</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  type: shell</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  maximum iterations=50, maximum function evaluations=10000</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  tolerances: relative=1e-50, absolute=1e-10, solution=1e+06</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  total number of function evaluations=0</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0in;margin-bottom:0in;margin-left:.5in;background:white">
<span style="font-size:9.0pt;font-family:Menlo;color:black">  norm schedule ALWAYS</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:8.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Any suggestions on how to do what I am trying to accomplish?</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Kenneth Hall</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><b><span style="font-size:9.0pt;font-family:Menlo;color:silver">#include <petsc/finclude/petsc.h></span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><b><span style="font-size:9.0pt;font-family:Menlo;color:silver">#include "macros.h"</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">MODULE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SolveWithSNESShell_module</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">USE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyPetscModule</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">CONTAINS</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MySolver</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">USE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyPetscModule</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">IMPLICIT</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">NONE</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... declared passed variables</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNES</span><span style="font-size:9.0pt;font-family:Menlo;color:black">    
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">Vec</span><span style="font-size:9.0pt;font-family:Menlo;color:black">     
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscErrorCode</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... code to find residual  x := N(x)</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... (or alternatively      y := N(x))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">           </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">   </span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">END</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MySolver</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyMonitor</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">its</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">rnorm</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">USE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyPetscModule</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">IMPLICIT</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">NONE</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Declare passed variables</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNES</span><span style="font-size:9.0pt;font-family:Menlo;color:black">          
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscInt</span><span style="font-size:9.0pt;font-family:Menlo;color:black">      
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">its</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscReal</span><span style="font-size:9.0pt;font-family:Menlo;color:black">     
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">rnorm</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscErrorCode</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Code to print out convergence history</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Code to print out convergence history</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">END</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyMonitor</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyConverged</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">it</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">xnorm</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ynorm</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">znorm</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">reason,
 ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">USE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyPetscModule</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">      </span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">IMPLICIT</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">NONE</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNES</span><span style="font-size:9.0pt;font-family:Menlo;color:black">    
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscInt</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">it</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ctx</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscReal</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">xnorm</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ynorm</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">znorm</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">KSPConvergedReason</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">reason</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscErrorCode</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!      ... add convergence test here ...</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!      set reason to a positive value if convergence has been achieved</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">END</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyConverged</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">END</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">MODULE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SolveWithSNESShell_module</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SolveWithSNESShell</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!====================================================================================================</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">USE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SolveWithSNESShell_module</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">IMPLICIT</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">NONE</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Declare passed variables</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">INTEGER</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">       
     ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level_tmp</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Declare local variables</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">INTEGER</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">           
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">iz</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">INTEGER</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">           
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">imax</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">INTEGER</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">           
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">jmax</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">INTEGER</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">           
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">kmax</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNES</span><span style="font-size:9.0pt;font-family:Menlo;color:black">              
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">KSP</span><span style="font-size:9.0pt;font-family:Menlo;color:black">               
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ksp</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">Vec</span><span style="font-size:9.0pt;font-family:Menlo;color:black">  
              ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">      </span><span style="font-size:9.0pt;font-family:Menlo;color:blue">Vec</span><span style="font-size:9.0pt;font-family:Menlo;color:black">               
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">y</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscViewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">       
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscErrorCode</span><span style="font-size:9.0pt;font-family:Menlo;color:black">    
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscReal</span><span style="font-size:9.0pt;font-family:Menlo;color:black">         
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">rtol</span><span style="font-size:9.0pt;font-family:Menlo;color:black">   = 1.0</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">D</span><span style="font-size:9.0pt;font-family:Menlo;color:black">-10  <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:green">!!
 relative tolerance</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscReal</span><span style="font-size:9.0pt;font-family:Menlo;color:black">         
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">atol</span><span style="font-size:9.0pt;font-family:Menlo;color:black">   = 1.0</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">D</span><span style="font-size:9.0pt;font-family:Menlo;color:black">-50  <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:green">!!
 absolute tolerance</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscReal</span><span style="font-size:9.0pt;font-family:Menlo;color:black">         
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">dtol</span><span style="font-size:9.0pt;font-family:Menlo;color:black">   = 1.0</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">D</span><span style="font-size:9.0pt;font-family:Menlo;color:black">+06  <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:green">!!
 divergence tolerance</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscInt</span><span style="font-size:9.0pt;font-family:Menlo;color:black">          
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">maxits</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=
 50</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscInt</span><span style="font-size:9.0pt;font-family:Menlo;color:black">          
 ::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">maxf</span><span style="font-size:9.0pt;font-family:Menlo;color:black">   = 10000</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">character</span></b><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><i><span style="font-size:9.0pt;font-family:Menlo;color:teal">len</span></i><span style="font-size:9.0pt;font-family:Menlo;color:black">=1000)::<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">args</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... count the number of degrees of freedom.</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level_tmp</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=
 0</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">DO</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">iz</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=
 1,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">hb</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">nzone</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">        <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">imax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">hb</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">zone</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">iz</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">imax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">-
 1</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">        <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">jmax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">hb</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">zone</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">iz</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">jmax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">-
 1</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">        <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">kmax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">hb</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">level</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">zone</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">iz</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)%</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">kmax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">-
 1</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">         </span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">+<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">imax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">*<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">jmax</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">*<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">kmax</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">END</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">DO</span></b><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">=<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:black">*<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">neqn</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Initialize PETSc</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscInitialize</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_CHARACTER</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Log</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscLogDefaultBegin</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Hard-wired options.</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!     PetscCall(PetscOptionsInsertString(PETSC_NULL_OPTIONS, "command line style option here" , ierr))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Command line options.</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">call</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><i><span style="font-size:9.0pt;font-family:Menlo;color:teal">GET_COMMAND</span></i><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">args</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscOptionsInsertString</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_OPTIONS</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">args</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... view command line table</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">      </span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscViewerASCIIOpen</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_COMM_SELF</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_VIEWER_STDOUT_SELF</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscOptionsView</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_OPTIONS</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscViewerDestroy</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Create PETSc vectors</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">VecCreateSeq</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_COMM_SELF</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">VecCreateSeq</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_COMM_SELF</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">n</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">y</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">VecSet</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,
 0.0</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">d0</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">VecSet</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">y</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,
 0.0</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">d0</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... SNES context</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESCreate</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_COMM_SELF</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSetType</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSHELL</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESShellSetSolve</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MySolver</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">!!!! <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSetFunction</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MySolver</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_INTEGER</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">!!!!  this line causes a segmentation error if uncommented.</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSetConvergenceTest</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyConverged</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,
 0,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_FUNCTION</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Set SNES options</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSetFromOptions</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Set tolerances</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSetTolerances</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">rtol</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">atol</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">dtol</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">maxits</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">maxf</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... SNES montior</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESMonitorSet</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">MyMonitor</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_INTEGER</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_FUNCTION</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Set the initial solution</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">CALL</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">HBToVecX</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">)</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... View snes context</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESView</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Solve SNES problem</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESSolve</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PETSC_NULL_VEC</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... View snes context</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESView</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... dump the logs</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!     call PetscLogDump(ierr)  ! Why does this cause error</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Destroy PETSc objects</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SNESDestroy</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">snes</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">VecDestroy</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">x</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">VecDestroy</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">y</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscViewerDestroy</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">viewer</span><span style="font-size:9.0pt;font-family:Menlo;color:black">,<span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:green">!.... Finish</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">     <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscCall</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">PetscFinalize</span><span style="font-size:9.0pt;font-family:Menlo;color:black">(</span><span style="font-size:9.0pt;font-family:Menlo;color:blue">ierr</span><span style="font-size:9.0pt;font-family:Menlo;color:black">))</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<p style="margin:0in;background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:Menlo;color:black">  <span class="apple-converted-space"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">END</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><b><span style="font-size:9.0pt;font-family:Menlo;color:maroon">SUBROUTINE</span></b><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:Menlo;color:black"> </span></span><span style="font-size:9.0pt;font-family:Menlo;color:blue">SolveWithSNESShell</span><span style="font-size:13.5pt;font-family:Helvetica"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><br clear="all">
</span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span class="gmailsignatureprefix"><span style="font-size:11.0pt">--</span></span></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">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</span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><a href="https://urldefense.com/v3/__http:/www.cse.buffalo.edu/*knepley/__;fg!!OToaGQ!sE2W1qI_dqcEHL1dOCnJ3Rdv9TATFVDBiBqx_tlQsOnjvGF7StDjsmVcm9Qkfe4XcTFOBtVjtFl5om07Rdjw$" target="_blank"><span style="font-size:11.0pt">https://www.cse.buffalo.edu/~knepley/</span></a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>